Upgrade V8 to version 4.9.385.28

https://chromium.googlesource.com/v8/v8/+/4.9.385.28

FPIIM-449

Change-Id: I4b2e74289d4bf3667f2f3dc8aa2e541f63e26eb4
diff --git a/src/compilation-cache.cc b/src/compilation-cache.cc
index 6c9f95a..aca8cee 100644
--- a/src/compilation-cache.cc
+++ b/src/compilation-cache.cc
@@ -2,11 +2,12 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
-#include "src/v8.h"
+#include "src/compilation-cache.h"
 
 #include "src/assembler.h"
-#include "src/compilation-cache.h"
-#include "src/serialize.h"
+#include "src/counters.h"
+#include "src/factory.h"
+#include "src/objects-inl.h"
 
 namespace v8 {
 namespace internal {
@@ -111,12 +112,10 @@
 // We only re-use a cached function for some script source code if the
 // script originates from the same place. This is to avoid issues
 // when reporting errors, etc.
-bool CompilationCacheScript::HasOrigin(
-    Handle<SharedFunctionInfo> function_info,
-    Handle<Object> name,
-    int line_offset,
-    int column_offset,
-    bool is_shared_cross_origin) {
+bool CompilationCacheScript::HasOrigin(Handle<SharedFunctionInfo> function_info,
+                                       Handle<Object> name, int line_offset,
+                                       int column_offset,
+                                       ScriptOriginOptions resource_options) {
   Handle<Script> script =
       Handle<Script>(Script::cast(function_info->script()), isolate());
   // If the script name isn't set, the boilerplate script should have
@@ -125,12 +124,13 @@
     return script->name()->IsUndefined();
   }
   // Do the fast bailout checks first.
-  if (line_offset != script->line_offset()->value()) return false;
-  if (column_offset != script->column_offset()->value()) return false;
+  if (line_offset != script->line_offset()) return false;
+  if (column_offset != script->column_offset()) return false;
   // Check that both names are strings. If not, no match.
   if (!name->IsString() || !script->name()->IsString()) return false;
-  // Were both scripts tagged by the embedder as being shared cross-origin?
-  if (is_shared_cross_origin != script->is_shared_cross_origin()) return false;
+  // Are the origin_options same?
+  if (resource_options.Flags() != script->origin_options().Flags())
+    return false;
   // Compare the two name strings for equality.
   return String::Equals(Handle<String>::cast(name),
                         Handle<String>(String::cast(script->name())));
@@ -142,12 +142,9 @@
 // will be cached, but subsequent code from different source / line
 // won't.
 Handle<SharedFunctionInfo> CompilationCacheScript::Lookup(
-    Handle<String> source,
-    Handle<Object> name,
-    int line_offset,
-    int column_offset,
-    bool is_shared_cross_origin,
-    Handle<Context> context) {
+    Handle<String> source, Handle<Object> name, int line_offset,
+    int column_offset, ScriptOriginOptions resource_options,
+    Handle<Context> context, LanguageMode language_mode) {
   Object* result = NULL;
   int generation;
 
@@ -156,17 +153,14 @@
   { HandleScope scope(isolate());
     for (generation = 0; generation < generations(); generation++) {
       Handle<CompilationCacheTable> table = GetTable(generation);
-      Handle<Object> probe = table->Lookup(source, context);
+      Handle<Object> probe = table->Lookup(source, context, language_mode);
       if (probe->IsSharedFunctionInfo()) {
         Handle<SharedFunctionInfo> function_info =
             Handle<SharedFunctionInfo>::cast(probe);
         // Break when we've found a suitable shared function info that
         // matches the origin.
-        if (HasOrigin(function_info,
-                      name,
-                      line_offset,
-                      column_offset,
-                      is_shared_cross_origin)) {
+        if (HasOrigin(function_info, name, line_offset, column_offset,
+                      resource_options)) {
           result = *function_info;
           break;
         }
@@ -180,14 +174,11 @@
   if (result != NULL) {
     Handle<SharedFunctionInfo> shared(SharedFunctionInfo::cast(result),
                                       isolate());
-    DCHECK(HasOrigin(shared,
-                     name,
-                     line_offset,
-                     column_offset,
-                     is_shared_cross_origin));
+    DCHECK(
+        HasOrigin(shared, name, line_offset, column_offset, resource_options));
     // If the script was found in a later generation, we promote it to
     // the first generation to let it survive longer in the cache.
-    if (generation != 0) Put(source, context, shared);
+    if (generation != 0) Put(source, context, language_mode, shared);
     isolate()->counters()->compilation_cache_hits()->Increment();
     return shared;
   } else {
@@ -199,17 +190,18 @@
 
 void CompilationCacheScript::Put(Handle<String> source,
                                  Handle<Context> context,
+                                 LanguageMode language_mode,
                                  Handle<SharedFunctionInfo> function_info) {
   HandleScope scope(isolate());
   Handle<CompilationCacheTable> table = GetFirstTable();
-  SetFirstTable(
-      CompilationCacheTable::Put(table, source, context, function_info));
+  SetFirstTable(CompilationCacheTable::Put(table, source, context,
+                                           language_mode, function_info));
 }
 
 
 MaybeHandle<SharedFunctionInfo> CompilationCacheEval::Lookup(
     Handle<String> source, Handle<SharedFunctionInfo> outer_info,
-    StrictMode strict_mode, int scope_position) {
+    LanguageMode language_mode, int scope_position) {
   HandleScope scope(isolate());
   // Make sure not to leak the table into the surrounding handle
   // scope. Otherwise, we risk keeping old tables around even after
@@ -218,7 +210,8 @@
   int generation;
   for (generation = 0; generation < generations(); generation++) {
     Handle<CompilationCacheTable> table = GetTable(generation);
-    result = table->LookupEval(source, outer_info, strict_mode, scope_position);
+    result =
+        table->LookupEval(source, outer_info, language_mode, scope_position);
     if (result->IsSharedFunctionInfo()) break;
   }
   if (result->IsSharedFunctionInfo()) {
@@ -295,31 +288,28 @@
 
 
 MaybeHandle<SharedFunctionInfo> CompilationCache::LookupScript(
-    Handle<String> source,
-    Handle<Object> name,
-    int line_offset,
-    int column_offset,
-    bool is_shared_cross_origin,
-    Handle<Context> context) {
+    Handle<String> source, Handle<Object> name, int line_offset,
+    int column_offset, ScriptOriginOptions resource_options,
+    Handle<Context> context, LanguageMode language_mode) {
   if (!IsEnabled()) return MaybeHandle<SharedFunctionInfo>();
 
   return script_.Lookup(source, name, line_offset, column_offset,
-                        is_shared_cross_origin, context);
+                        resource_options, context, language_mode);
 }
 
 
 MaybeHandle<SharedFunctionInfo> CompilationCache::LookupEval(
     Handle<String> source, Handle<SharedFunctionInfo> outer_info,
-    Handle<Context> context, StrictMode strict_mode, int scope_position) {
+    Handle<Context> context, LanguageMode language_mode, int scope_position) {
   if (!IsEnabled()) return MaybeHandle<SharedFunctionInfo>();
 
   MaybeHandle<SharedFunctionInfo> result;
   if (context->IsNativeContext()) {
     result =
-        eval_global_.Lookup(source, outer_info, strict_mode, scope_position);
+        eval_global_.Lookup(source, outer_info, language_mode, scope_position);
   } else {
     DCHECK(scope_position != RelocInfo::kNoPosition);
-    result = eval_contextual_.Lookup(source, outer_info, strict_mode,
+    result = eval_contextual_.Lookup(source, outer_info, language_mode,
                                      scope_position);
   }
   return result;
@@ -336,10 +326,11 @@
 
 void CompilationCache::PutScript(Handle<String> source,
                                  Handle<Context> context,
+                                 LanguageMode language_mode,
                                  Handle<SharedFunctionInfo> function_info) {
   if (!IsEnabled()) return;
 
-  script_.Put(source, context, function_info);
+  script_.Put(source, context, language_mode, function_info);
 }
 
 
@@ -411,4 +402,5 @@
 }
 
 
-} }  // namespace v8::internal
+}  // namespace internal
+}  // namespace v8