Reviewers: Benedikt Meurer,

Description:
Do not look for existing shared function info when compiling a new script.

LOG=N
BUG=chromium:502908

Please review this at https://codereview.chromium.org/1196223002/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+22, -6 lines):
  M src/compiler.h
  M src/compiler.cc
  M src/objects.cc


Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index 7441f19e5a0467720ba2ff1141443e900979749a..5f3a55325bce243a3fa0e0ac5e47cf33aff3f123 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -1075,6 +1075,8 @@ static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
       }
     }

+    info->MarkAsNewScript();
+
     FunctionLiteral* lit = info->function();
     LiveEditFunctionTracker live_edit_tracker(isolate, lit);

@@ -1335,8 +1337,13 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo(
     FunctionLiteral* literal, Handle<Script> script,
     CompilationInfo* outer_info) {
   // Precondition: code has been parsed and scopes have been analyzed.
-  MaybeHandle<SharedFunctionInfo> maybe_existing =
-      script->FindSharedFunctionInfo(literal);
+  MaybeHandle<SharedFunctionInfo> maybe_existing;
+  if (outer_info->is_new_script()) {
+ // There is no existing shared function info when compiling a new script.
+    DCHECK(script->FindSharedFunctionInfo(literal).is_null());
+  } else {
+    maybe_existing = script->FindSharedFunctionInfo(literal);
+  }
   // We found an existing shared function info. If it's already compiled,
   // don't worry about compiling it, and simply return it. If it's not yet
   // compiled, continue to decide whether to eagerly compile.
@@ -1352,6 +1359,7 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo(
   parse_info.set_scope(literal->scope());
   parse_info.set_language_mode(literal->scope()->language_mode());
   if (outer_info->will_serialize()) info.PrepareForSerializing();
+  if (outer_info->is_new_script()) info.MarkAsNewScript();

   Isolate* isolate = info.isolate();
   Factory* factory = isolate->factory();
Index: src/compiler.h
diff --git a/src/compiler.h b/src/compiler.h
index a1f97df269c053951b279d691c1c03af74ae846d..cbcfec6a9f35cff263464a93f70adb12bf40c954 100644
--- a/src/compiler.h
+++ b/src/compiler.h
@@ -127,7 +127,8 @@ class CompilationInfo {
     kSplittingEnabled = 1 << 13,
     kTypeFeedbackEnabled = 1 << 14,
     kDeoptimizationEnabled = 1 << 15,
-    kSourcePositionsEnabled = 1 << 16
+    kSourcePositionsEnabled = 1 << 16,
+    kNewScript = 1 << 17,
   };

   explicit CompilationInfo(ParseInfo* parse_info);
@@ -245,6 +246,10 @@ class CompilationInfo {

   bool is_splitting_enabled() const { return GetFlag(kSplittingEnabled); }

+  void MarkAsNewScript() { SetFlag(kNewScript); }
+
+  bool is_new_script() const { return GetFlag(kNewScript); }
+
   bool IsCodePreAgingActive() const {
     return FLAG_optimize_for_size && FLAG_age_code && !will_serialize() &&
            !is_debug();
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index e4d58b7f57d1943a5c75099f69b3412e222fd8a6..f85a3d8a392d20728d47f459407ae3fae865b6de 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -10436,8 +10436,7 @@ MaybeHandle<SharedFunctionInfo> Script::FindSharedFunctionInfo(
       if (!obj->IsSharedFunctionInfo()) continue;
       SharedFunctionInfo* shared = SharedFunctionInfo::cast(obj);
if (fun->function_token_position() == shared->function_token_position() &&
-          fun->start_position() == shared->start_position() &&
-          fun->end_position() == shared->end_position()) {
+          fun->start_position() == shared->start_position()) {
         return Handle<SharedFunctionInfo>(shared);
       }
     }
@@ -10461,11 +10460,15 @@ void SharedFunctionInfo::SetScript(Handle<SharedFunctionInfo> shared,
   // Add shared function info to new script's list.
   if (script_object->IsScript()) {
     Handle<Script> script = Handle<Script>::cast(script_object);
-    bool found = false;
Handle<Object> list(script->shared_function_infos(), shared->GetIsolate());
+#ifdef DEBUG
+    bool found = false;
list = WeakFixedArray::Add(list, shared, WeakFixedArray::kAddIfNotFound,
                                &found);
     CHECK(!found);
+#else
+    list = WeakFixedArray::Add(list, shared, WeakFixedArray::kAlwaysAdd);
+#endif  // DEBUG
     script->set_shared_function_infos(*list);
   }
   // Finally set new script.


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to