Minor compiler pipeline refactoring. Inline UpdateSharedFunctionInfo and make Parser...
authortitzer@chromium.org <titzer@chromium.org>
Wed, 17 Sep 2014 12:34:46 +0000 (12:34 +0000)
committertitzer@chromium.org <titzer@chromium.org>
Wed, 17 Sep 2014 12:34:46 +0000 (12:34 +0000)
R=mstarzinger@chromium.org
BUG=

Review URL: https://codereview.chromium.org/555553003

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24001 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/compiler.cc
src/compiler/js-inlining.cc
src/parser.h
test/cctest/compiler/function-tester.h
test/cctest/compiler/test-changes-lowering.cc
test/cctest/compiler/test-codegen-deopt.cc
test/cctest/compiler/test-pipeline.cc
test/mjsunit/compiler/osr-warm.js
test/mjsunit/mjsunit.status

index acfeaa4..cd8b75b 100644 (file)
@@ -619,37 +619,6 @@ void SetExpectedNofPropertiesFromEstimate(Handle<SharedFunctionInfo> shared,
 }
 
 
-static void UpdateSharedFunctionInfo(CompilationInfo* info) {
-  // Update the shared function info with the compiled code and the
-  // scope info.  Please note, that the order of the shared function
-  // info initialization is important since set_scope_info might
-  // trigger a GC, causing the DCHECK below to be invalid if the code
-  // was flushed. By setting the code object last we avoid this.
-  Handle<SharedFunctionInfo> shared = info->shared_info();
-  Handle<ScopeInfo> scope_info =
-      ScopeInfo::Create(info->scope(), info->zone());
-  shared->set_scope_info(*scope_info);
-
-  Handle<Code> code = info->code();
-  CHECK(code->kind() == Code::FUNCTION);
-  shared->ReplaceCode(*code);
-  if (shared->optimization_disabled()) code->set_optimizable(false);
-
-  shared->set_feedback_vector(*info->feedback_vector());
-
-  // Set the expected number of properties for instances.
-  FunctionLiteral* lit = info->function();
-  int expected = lit->expected_property_count();
-  SetExpectedNofPropertiesFromEstimate(shared, expected);
-
-  // Check the function has compiled code.
-  DCHECK(shared->is_compiled());
-  shared->set_bailout_reason(lit->dont_optimize_reason());
-  shared->set_ast_node_count(lit->ast_node_count());
-  shared->set_strict_mode(lit->strict_mode());
-}
-
-
 // Sets the function info on a function.
 // The start_position points to the first '(' character after the function name
 // in the full script source. When counting characters in the script source the
@@ -702,14 +671,33 @@ MUST_USE_RESULT static MaybeHandle<Code> GetUnoptimizedCodeCommon(
     CompilationInfo* info) {
   VMState<COMPILER> state(info->isolate());
   PostponeInterruptsScope postpone(info->isolate());
+
+  // Parse and update CompilationInfo with the results.
   if (!Parser::Parse(info)) return MaybeHandle<Code>();
-  info->SetStrictMode(info->function()->strict_mode());
+  Handle<SharedFunctionInfo> shared = info->shared_info();
+  FunctionLiteral* lit = info->function();
+  shared->set_strict_mode(lit->strict_mode());
+  SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count());
+  shared->set_bailout_reason(lit->dont_optimize_reason());
+  shared->set_ast_node_count(lit->ast_node_count());
 
+  // Compile unoptimized code.
   if (!CompileUnoptimizedCode(info)) return MaybeHandle<Code>();
+
+  CHECK_EQ(Code::FUNCTION, info->code()->kind());
   Compiler::RecordFunctionCompilation(
       Logger::LAZY_COMPILE_TAG, info, info->shared_info());
-  UpdateSharedFunctionInfo(info);
-  DCHECK_EQ(Code::FUNCTION, info->code()->kind());
+
+  // Update the shared function info with the scope info. Allocating the
+  // ScopeInfo object may cause a GC.
+  Handle<ScopeInfo> scope_info = ScopeInfo::Create(info->scope(), info->zone());
+  shared->set_scope_info(*scope_info);
+
+  // Update the code and feedback vector for the shared function info.
+  shared->ReplaceCode(*info->code());
+  if (shared->optimization_disabled()) info->code()->set_optimizable(false);
+  shared->set_feedback_vector(*info->feedback_vector());
+
   return info->code();
 }
 
@@ -817,7 +805,6 @@ void Compiler::CompileForLiveEdit(Handle<Script> script) {
 
   info.MarkAsGlobal();
   if (!Parser::Parse(&info)) return;
-  info.SetStrictMode(info.function()->strict_mode());
 
   LiveEditFunctionTracker tracker(info.isolate(), info.function());
   if (!CompileUnoptimizedCode(&info)) return;
@@ -1192,8 +1179,6 @@ static void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) {
 
 static bool CompileOptimizedPrologue(CompilationInfo* info) {
   if (!Parser::Parse(info)) return false;
-  info->SetStrictMode(info->function()->strict_mode());
-
   if (!Rewriter::Rewrite(info)) return false;
   if (!Scope::Analyze(info)) return false;
   DCHECK(info->scope() != NULL);
index 7c12dd5..b908ae8 100644 (file)
@@ -54,8 +54,6 @@ void JSInliner::Inline() {
 // test cases, where similar code is currently duplicated).
 static void Parse(Handle<JSFunction> function, CompilationInfoWithZone* info) {
   CHECK(Parser::Parse(info));
-  StrictMode strict_mode = info->function()->strict_mode();
-  info->SetStrictMode(strict_mode);
   info->SetOptimizing(BailoutId::None(), Handle<Code>(function->code()));
   CHECK(Rewriter::Rewrite(info));
   CHECK(Scope::Analyze(info));
index ab9c61a..d73075a 100644 (file)
@@ -627,7 +627,11 @@ class Parser : public ParserBase<ParserTraits> {
                             info->isolate()->unicode_cache()};
     Parser parser(info, &parse_info);
     parser.set_allow_lazy(allow_lazy);
-    return parser.Parse();
+    if (parser.Parse()) {
+      info->SetStrictMode(info->function()->strict_mode());
+      return true;
+    }
+    return false;
   }
   bool Parse();
   void ParseOnBackground();
index 0fc777c..2ef46eb 100644 (file)
@@ -45,8 +45,6 @@ class FunctionTester : public InitializedHandleScope {
     CompilationInfoWithZone info(function);
 
     CHECK(Parser::Parse(&info));
-    StrictMode strict_mode = info.function()->strict_mode();
-    info.SetStrictMode(strict_mode);
     info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code()));
     if (flags_ & CompilationInfo::kContextSpecializing) {
       info.MarkAsContextSpecializing();
index b91d583..06308a0 100644 (file)
@@ -55,8 +55,6 @@ class ChangesLoweringTester : public GraphBuilderTester<ReturnType> {
               "(function() { 'use strict'; return 2.7123; })")));
       CompilationInfoWithZone info(function);
       CHECK(Parser::Parse(&info));
-      StrictMode strict_mode = info.function()->strict_mode();
-      info.SetStrictMode(strict_mode);
       info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code()));
       CHECK(Rewriter::Rewrite(&info));
       CHECK(Scope::Analyze(&info));
index 7c5e05a..fb036a0 100644 (file)
@@ -45,8 +45,6 @@ class DeoptCodegenTester {
         info(function, scope->main_zone()),
         bailout_id(-1) {
     CHECK(Parser::Parse(&info));
-    StrictMode strict_mode = info.function()->strict_mode();
-    info.SetStrictMode(strict_mode);
     info.SetOptimizing(BailoutId::None(), Handle<Code>(function->code()));
     CHECK(Rewriter::Rewrite(&info));
     CHECK(Scope::Analyze(&info));
index 7efedee..f0b750a 100644 (file)
@@ -23,8 +23,6 @@ TEST(PipelineAdd) {
   CompilationInfoWithZone info(function);
 
   CHECK(Parser::Parse(&info));
-  StrictMode strict_mode = info.function()->strict_mode();
-  info.SetStrictMode(strict_mode);
   CHECK(Rewriter::Rewrite(&info));
   CHECK(Scope::Analyze(&info));
   CHECK_NE(NULL, info.scope());
index 65ada1e..73e1fd5 100644 (file)
@@ -35,7 +35,7 @@ function f1(x) {
 }
 
 assertEquals(0, f1(1));
-assertEquals(0, f1(10000000));
+assertEquals(0, f1(200000));
 
 function f2(x) {
   var sum = 1;
@@ -47,4 +47,4 @@ function f2(x) {
 }
 
 assertEquals(2, f2(1));
-assertEquals(10000001, f2(10000000));
+assertEquals(200001, f2(200000));
index 6d0aa51..bba86bd 100644 (file)
 
   # TODO(mstarzinger): Takes too long with TF.
   'array-sort': [PASS, NO_VARIANTS],
-  'compiler/osr-warm': [PASS, NO_VARIANTS],
   'regress/regress-91008': [PASS, NO_VARIANTS],
 }],  # 'gc_stress == True'
 
   'bit-not': [PASS, SLOW],
   'compiler/alloc-number': [PASS, SLOW],
   'compiler/osr-assert': [PASS, SLOW],
-  'compiler/osr-warm': [PASS, TIMEOUT, SLOW],
   'compiler/osr-with-args': [PASS, SLOW],
   'debug-scopes': [PASS, SLOW],
   'generated-transition-stub': [PASS, SLOW],