Import Cobalt 6.14838

Change-Id: I49864fe26f7f6fca3777d185823aa31251e8ae57
diff --git a/src/third_party/harfbuzz-ng/src/hb-starboard.hh b/src/third_party/harfbuzz-ng/src/hb-starboard.hh
index e235306..4ba44c3 100644
--- a/src/third_party/harfbuzz-ng/src/hb-starboard.hh
+++ b/src/third_party/harfbuzz-ng/src/hb-starboard.hh
@@ -23,7 +23,7 @@
 #define hb_malloc_impl SbMemoryAllocate
 #define hb_realloc_impl SbMemoryReallocate
 #define hb_calloc_impl SbMemoryCalloc
-#define hb_free_impl SbMemoryFree
+#define hb_free_impl SbMemoryDeallocate
 
 // Micro Posix Emulation
 #define assert SB_DCHECK
diff --git a/src/third_party/libevent/libevent.gyp b/src/third_party/libevent/libevent.gyp
index d82ba5c..2a7bf21 100644
--- a/src/third_party/libevent/libevent.gyp
+++ b/src/third_party/libevent/libevent.gyp
@@ -68,6 +68,16 @@
                     ],
                   },
                 }],
+                # TODO: Make this android specific, not a linux copy.
+                [ 'target_os == "android"', {
+                  'sources': [ 'epoll_sub.c' ],
+                  'include_dirs': [ 'starboard/linux' ],
+                  'link_settings': {
+                    'libraries': [
+                      '-lrt',
+                    ],
+                  },
+                }],
                 [ 'target_os == "orbis"', {
                   'include_dirs': [ 'starboard/ps4' ],
                   }
diff --git a/src/third_party/mozjs/js/src/jit/Ion.cpp b/src/third_party/mozjs/js/src/jit/Ion.cpp
index 66cce66..2f00859 100644
--- a/src/third_party/mozjs/js/src/jit/Ion.cpp
+++ b/src/third_party/mozjs/js/src/jit/Ion.cpp
@@ -2031,7 +2031,8 @@
 IonExecStatus
 jit::Cannon(JSContext *cx, RunState &state)
 {
-    IonScript *ion = state.script()->ionScript();
+    JSScript *script = state.script();
+    IonScript *ion = script->ionScript();
 
     EnterJitData data(cx);
     data.jitcode = ion->method()->raw();
diff --git a/src/third_party/mozjs/js/src/jit/arm/Architecture-arm.cpp b/src/third_party/mozjs/js/src/jit/arm/Architecture-arm.cpp
index a5b04e8..770fd12 100644
--- a/src/third_party/mozjs/js/src/jit/arm/Architecture-arm.cpp
+++ b/src/third_party/mozjs/js/src/jit/arm/Architecture-arm.cpp
@@ -99,6 +99,13 @@
     return flags;
 #endif
 
+#if defined(__GNUC__) && defined(__VFP_FP__)
+    // Mimic behavior of JSC::isVFPPresent().
+    // On ARMv6, lack of this feature will prevent the ion jit path.
+    flags |= HWCAP_VFP;
+    return flags;
+#endif
+
     return false;
 }
 
diff --git a/src/third_party/mozjs/mozjs.gyp b/src/third_party/mozjs/mozjs.gyp
index 8895e64..3de7f79 100644
--- a/src/third_party/mozjs/mozjs.gyp
+++ b/src/third_party/mozjs/mozjs.gyp
@@ -88,6 +88,11 @@
           'JS_DEBUG',
         ],
       }],
+      [ 'cobalt_config != "gold"', {
+        'defines': [
+          'JS_TRACE_LOGGING=1',
+        ],
+      }],
     ],
   },
   'targets': [
diff --git a/src/third_party/super_fast_hash/LICENSE b/src/third_party/super_fast_hash/LICENSE
new file mode 100644
index 0000000..3f9e016
--- /dev/null
+++ b/src/third_party/super_fast_hash/LICENSE
@@ -0,0 +1,28 @@
+// Copyright (c) 2010, Paul Hsieh
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// * Redistributions of source code must retain the above copyright notice, this
+//   list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright notice,
+//   this list of conditions and the following disclaimer in the documentation
+//   and/or other materials provided with the distribution.
+// * Neither my name, Paul Hsieh, nor the names of any other contributors to the
+//   code use may not be used to endorse or promote products derived from this
+//   software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+// From http://www.azillionmonkeys.com/qed/hash.html
\ No newline at end of file
diff --git a/src/third_party/super_fast_hash/README.chromium b/src/third_party/super_fast_hash/README.chromium
new file mode 100644
index 0000000..5e8134e
--- /dev/null
+++ b/src/third_party/super_fast_hash/README.chromium
@@ -0,0 +1,13 @@
+Name: SuperFastHash
+Short Name: super_fast_hash
+URL: http://www.azillionmonkeys.com/qed/hash.html
+Version: unknown
+License: BSD 3-Clause
+Security Critical: yes
+
+Description:
+The super_hash_file was modified to use the big/little endian platform
+defines provided by starboard/configuration.h. Therefore the hash function
+definition should be cc included. Additionally, a previous hash value can
+be used if this hash is being chained.
+Example: #include "third_party/super_fast_hash.cc"
diff --git a/src/third_party/super_fast_hash/super_fast_hash.cc b/src/third_party/super_fast_hash/super_fast_hash.cc
new file mode 100644
index 0000000..6618791
--- /dev/null
+++ b/src/third_party/super_fast_hash/super_fast_hash.cc
@@ -0,0 +1,88 @@
+// Copyright (c) 2010, Paul Hsieh
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are met:
+//
+// * Redistributions of source code must retain the above copyright notice, this
+//   list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above copyright notice,
+//   this list of conditions and the following disclaimer in the documentation
+//   and/or other materials provided with the distribution.
+// * Neither my name, Paul Hsieh, nor the names of any other contributors to the
+//   code use may not be used to endorse or promote products derived from this
+//   software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+// POSSIBILITY OF SUCH DAMAGE.
+
+// From http://www.azillionmonkeys.com/qed/hash.html
+
+
+#if SB_IS(BIG_ENDIAN)
+#define get16bits(d) (*((const uint16_t *) (d)))
+#else
+#define get16bits(d) ((((uint32_t)(((const uint8_t *)(d))[1])) << 8)\
+                       +(uint32_t)(((const uint8_t *)(d))[0]) )
+#endif
+
+uint32_t SuperFastHash(const char* data, int len, uint32_t prev_hash) {
+  uint32_t hash = prev_hash, tmp;
+  int rem;
+
+  if (len <= 0 || data == NULL)
+    return 0;
+
+  rem = len & 3;
+  len >>= 2;
+
+  /* Main loop */
+  for (; len > 0; len--) {
+    hash  += get16bits(data);
+    tmp    = (get16bits(data + 2) << 11) ^ hash;
+    hash   = (hash << 16) ^ tmp;
+    data  += 2 * sizeof(uint16_t);
+    hash  += hash >> 11;
+  }
+
+  /* Handle end cases */
+  switch (rem) {
+    case 3:
+      hash += get16bits(data);
+      hash ^= hash << 16;
+
+      // Treat the final character as signed. This ensures all platforms behave
+      // consistently with the original x86 code.
+      hash ^= static_cast<signed char>(data[sizeof(uint16_t)]) << 18;
+      hash += hash >> 11;
+      break;
+    case 2:
+      hash += get16bits(data);
+      hash ^= hash << 11;
+      hash += hash >> 17;
+      break;
+    case 1:
+      hash += static_cast<signed char>(*data);
+      hash ^= hash << 10;
+      hash += hash >> 1;
+  }
+
+  /* Force "avalanching" of final 127 bits */
+  hash ^= hash << 3;
+  hash += hash >> 5;
+  hash ^= hash << 4;
+  hash += hash >> 17;
+  hash ^= hash << 25;
+  hash += hash >> 6;
+
+  return hash;
+}
\ No newline at end of file