Reviewers: Michael Starzinger,
Description:
Minor compiler pipeline refactoring. Inline UpdateSharedFunctionInfo and
make
Parser::Parse responsible for setting the strict mode of the
CompilationInfo.
[email protected]
BUG=
Please review this at https://codereview.chromium.org/555553003/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+29, -40 lines):
M src/compiler.cc
M src/parser.h
M test/mjsunit/compiler/osr-warm.js
Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index
acfeaa48ccb303b3722600ed435a8233abcff79e..cd8b75b42a5dc912d7a48e3c6f34b3e36bee2fe6
100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -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: src/parser.h
diff --git a/src/parser.h b/src/parser.h
index
ab9c61a91daaefc55aec14d9811dac57f46f5ac7..d73075a42ad6b7cd15a6083f7139783c353893f4
100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -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: test/mjsunit/compiler/osr-warm.js
diff --git a/test/mjsunit/compiler/osr-warm.js
b/test/mjsunit/compiler/osr-warm.js
index
65ada1e114856109ab2261d0bc670bf59daa983c..73e1fd5cd27941d4f56e6d7147c3b30eb7ce79b0
100644
--- a/test/mjsunit/compiler/osr-warm.js
+++ b/test/mjsunit/compiler/osr-warm.js
@@ -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));
--
--
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.