From ea8312ba3379de0010016e42f1b6a00d4b619ec0 Mon Sep 17 00:00:00 2001 From: "ager@chromium.org" Date: Fri, 1 Apr 2011 19:46:21 +0000 Subject: [PATCH] Reapply: Never use classic code generator. Crankshaft is now the default on all platforms. This is the first patch on the way to removing the classic code generator from the system. This time with no removal of the crankshaft flag. --nocrankshaft is not at all the same as --always-full-compiler which I had used instead for testing. That was what caused timeouts on the buildbots because of repeated attempts to optimize hot functions. It makes sense to keep the crankshaft flag in case you want to run only with the full compiler and with no adaptive compilation. R=vitalyr@chromium.org Review URL: http://codereview.chromium.org/6759070 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7486 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/arm/full-codegen-arm.cc | 10 ------- src/ast.h | 7 +---- src/compiler.cc | 61 ++++++------------------------------------- src/flag-definitions.h | 2 +- src/ia32/full-codegen-ia32.cc | 9 ------- src/objects-inl.h | 6 +---- src/objects.h | 16 +++++------- src/v8.cc | 2 +- src/x64/full-codegen-x64.cc | 9 ------- tools/test.py | 4 ++- 10 files changed, 21 insertions(+), 105 deletions(-) diff --git a/src/arm/full-codegen-arm.cc b/src/arm/full-codegen-arm.cc index 7ab9102..3267951 100644 --- a/src/arm/full-codegen-arm.cc +++ b/src/arm/full-codegen-arm.cc @@ -2351,16 +2351,6 @@ void FullCodeGenerator::VisitCall(Call* expr) { } } } else { - // Call to some other expression. If the expression is an anonymous - // function literal not called in a loop, mark it as one that should - // also use the fast code generator. - FunctionLiteral* lit = fun->AsFunctionLiteral(); - if (lit != NULL && - lit->name()->Equals(isolate()->heap()->empty_string()) && - loop_depth() == 0) { - lit->set_try_full_codegen(true); - } - { PreservePositionScope scope(masm()->positions_recorder()); VisitForStackValue(fun); } diff --git a/src/ast.h b/src/ast.h index 4886b8d..d8bc18e 100644 --- a/src/ast.h +++ b/src/ast.h @@ -1,4 +1,4 @@ -// Copyright 2010 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -1748,7 +1748,6 @@ class FunctionLiteral: public Expression { contains_loops_(contains_loops), function_token_position_(RelocInfo::kNoPosition), inferred_name_(HEAP->empty_string()), - try_full_codegen_(false), pretenure_(false) { } DECLARE_NODE_TYPE(FunctionLiteral) @@ -1786,9 +1785,6 @@ class FunctionLiteral: public Expression { inferred_name_ = inferred_name; } - bool try_full_codegen() { return try_full_codegen_; } - void set_try_full_codegen(bool flag) { try_full_codegen_ = flag; } - bool pretenure() { return pretenure_; } void set_pretenure(bool value) { pretenure_ = value; } @@ -1808,7 +1804,6 @@ class FunctionLiteral: public Expression { bool strict_mode_; int function_token_position_; Handle inferred_name_; - bool try_full_codegen_; bool pretenure_; }; diff --git a/src/compiler.cc b/src/compiler.cc index 1ec4414..dea94fa 100755 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -1,4 +1,4 @@ -// Copyright 2010 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -326,30 +326,9 @@ static bool MakeCode(CompilationInfo* info) { if (Rewriter::Rewrite(info) && Scope::Analyze(info)) { if (V8::UseCrankshaft()) return MakeCrankshaftCode(info); - - // Generate code and return it. Code generator selection is governed by - // which backends are enabled and whether the function is considered - // run-once code or not. - // - // --full-compiler enables the dedicated backend for code we expect to - // be run once - // - // The normal choice of backend can be overridden with the flags - // --always-full-compiler. - if (Rewriter::Analyze(info)) { - Handle shared = info->shared_info(); - bool is_run_once = (shared.is_null()) - ? info->scope()->is_global_scope() - : (shared->is_toplevel() || shared->try_full_codegen()); - bool can_use_full = - FLAG_full_compiler && !info->function()->contains_loops(); - if (AlwaysFullCompiler() || (is_run_once && can_use_full)) { - return FullCodeGenerator::MakeCode(info); - } else { - return AssignedVariablesAnalyzer::Analyze(info) && - CodeGenerator::MakeCode(info); - } - } + // If crankshaft is not supported fall back to full code generator + // for all compilation. + return FullCodeGenerator::MakeCode(info); } return false; @@ -721,35 +700,12 @@ Handle Compiler::BuildFunctionInfo(FunctionLiteral* literal, if (FLAG_lazy && allow_lazy) { Handle code = info.isolate()->builtins()->LazyCompile(); info.SetCode(code); - } else { - if (V8::UseCrankshaft()) { - if (!MakeCrankshaftCode(&info)) { - return Handle::null(); - } - } else { - // The bodies of function literals have not yet been visited by the - // AST optimizer/analyzer. - if (!Rewriter::Analyze(&info)) return Handle::null(); - - bool is_run_once = literal->try_full_codegen(); - bool can_use_full = FLAG_full_compiler && !literal->contains_loops(); - - if (AlwaysFullCompiler() || (is_run_once && can_use_full)) { - if (!FullCodeGenerator::MakeCode(&info)) { - return Handle::null(); - } - } else { - // We fall back to the classic V8 code generator. - if (!AssignedVariablesAnalyzer::Analyze(&info) || - !CodeGenerator::MakeCode(&info)) { - return Handle::null(); - } - } - } + } else if ((V8::UseCrankshaft() && MakeCrankshaftCode(&info)) || + (!V8::UseCrankshaft() && FullCodeGenerator::MakeCode(&info))) { ASSERT(!info.code().is_null()); - - // Function compilation complete. scope_info = SerializedScopeInfo::Create(info.scope()); + } else { + return Handle::null(); } // Create a shared function info object. @@ -791,7 +747,6 @@ void Compiler::SetFunctionInfo(Handle function_info, function_info->SetThisPropertyAssignmentsInfo( lit->has_only_simple_this_property_assignments(), *lit->this_property_assignments()); - function_info->set_try_full_codegen(lit->try_full_codegen()); function_info->set_allows_lazy_compilation(lit->AllowsLazyCompilation()); function_info->set_strict_mode(lit->strict_mode()); } diff --git a/src/flag-definitions.h b/src/flag-definitions.h index 0bc6409..d6cb6e3 100644 --- a/src/flag-definitions.h +++ b/src/flag-definitions.h @@ -1,4 +1,4 @@ -// Copyright 2010 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: diff --git a/src/ia32/full-codegen-ia32.cc b/src/ia32/full-codegen-ia32.cc index e8e4980..3f72def 100644 --- a/src/ia32/full-codegen-ia32.cc +++ b/src/ia32/full-codegen-ia32.cc @@ -2267,15 +2267,6 @@ void FullCodeGenerator::VisitCall(Call* expr) { } } } else { - // Call to some other expression. If the expression is an anonymous - // function literal not called in a loop, mark it as one that should - // also use the full code generator. - FunctionLiteral* lit = fun->AsFunctionLiteral(); - if (lit != NULL && - lit->name()->Equals(isolate()->heap()->empty_string()) && - loop_depth() == 0) { - lit->set_try_full_codegen(true); - } { PreservePositionScope scope(masm()->positions_recorder()); VisitForStackValue(fun); } diff --git a/src/objects-inl.h b/src/objects-inl.h index 4465cbe..37c51d7 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -1,4 +1,4 @@ -// Copyright 2010 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -3056,10 +3056,6 @@ BOOL_GETTER(SharedFunctionInfo, compiler_hints, kHasOnlySimpleThisPropertyAssignments) BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, - try_full_codegen, - kTryFullCodegen) -BOOL_ACCESSORS(SharedFunctionInfo, - compiler_hints, allows_lazy_compilation, kAllowLazyCompilation) diff --git a/src/objects.h b/src/objects.h index 1024298..874dcbc 100644 --- a/src/objects.h +++ b/src/objects.h @@ -1,4 +1,4 @@ -// Copyright 2010 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: @@ -4259,9 +4259,6 @@ class SharedFunctionInfo: public HeapObject { // this.x = y; where y is either a constant or refers to an argument. inline bool has_only_simple_this_property_assignments(); - inline bool try_full_codegen(); - inline void set_try_full_codegen(bool flag); - // Indicates if this function can be lazy compiled. // This is used to determine if we can safely flush code from a function // when doing GC if we expect that the function will no longer be used. @@ -4461,13 +4458,12 @@ class SharedFunctionInfo: public HeapObject { // Bit positions in compiler_hints. static const int kHasOnlySimpleThisPropertyAssignments = 0; - static const int kTryFullCodegen = 1; - static const int kAllowLazyCompilation = 2; - static const int kLiveObjectsMayExist = 3; - static const int kCodeAgeShift = 4; + static const int kAllowLazyCompilation = 1; + static const int kLiveObjectsMayExist = 2; + static const int kCodeAgeShift = 3; static const int kCodeAgeMask = 0x7; - static const int kOptimizationDisabled = 7; - static const int kStrictModeFunction = 8; + static const int kOptimizationDisabled = 6; + static const int kStrictModeFunction = 7; private: #if V8_HOST_ARCH_32_BIT diff --git a/src/v8.cc b/src/v8.cc index 082d7fb..f89ed83 100644 --- a/src/v8.cc +++ b/src/v8.cc @@ -1,4 +1,4 @@ -// Copyright 2006-2009 the V8 project authors. All rights reserved. +// Copyright 2011 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: diff --git a/src/x64/full-codegen-x64.cc b/src/x64/full-codegen-x64.cc index 45ffefe..4bf84a8 100644 --- a/src/x64/full-codegen-x64.cc +++ b/src/x64/full-codegen-x64.cc @@ -2247,15 +2247,6 @@ void FullCodeGenerator::VisitCall(Call* expr) { } } } else { - // Call to some other expression. If the expression is an anonymous - // function literal not called in a loop, mark it as one that should - // also use the full code generator. - FunctionLiteral* lit = fun->AsFunctionLiteral(); - if (lit != NULL && - lit->name()->Equals(isolate()->heap()->empty_string()) && - loop_depth() == 0) { - lit->set_try_full_codegen(true); - } { PreservePositionScope scope(masm()->positions_recorder()); VisitForStackValue(fun); } diff --git a/tools/test.py b/tools/test.py index 43c11e2..707e725 100755 --- a/tools/test.py +++ b/tools/test.py @@ -584,7 +584,9 @@ class TestSuite(object): # Use this to run several variants of the tests, e.g.: # VARIANT_FLAGS = [[], ['--always_compact', '--noflush_code']] -VARIANT_FLAGS = [[], ['--stress-opt', '--always-opt'], ['--nocrankshaft']] +VARIANT_FLAGS = [[], + ['--stress-opt', '--always-opt'], + ['--nocrankshaft']] class TestRepository(TestSuite): -- 2.7.4