Commit cbf66711 authored by titzer@chromium.org's avatar titzer@chromium.org

Minor compiler pipeline refactoring. Inline UpdateSharedFunctionInfo and make...

Minor compiler pipeline refactoring. Inline UpdateSharedFunctionInfo and make Parser::Parse responsible for setting the strict mode of the CompilationInfo.

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
parent 1cc4b0b9
......@@ -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);
......
......@@ -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));
......
......@@ -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();
......
......@@ -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();
......
......@@ -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));
......
......@@ -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));
......
......@@ -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());
......
......@@ -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));
......@@ -232,7 +232,6 @@
# 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'
......@@ -288,7 +287,6 @@
'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],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment