| Index: src/compiler.cc
|
| diff --git a/src/compiler.cc b/src/compiler.cc
|
| index aa56ca92e72b667c4c5f9ad8d5de431abab02d0d..c39936cc254b531c891beb50a23cb7afdfda9333 100644
|
| --- a/src/compiler.cc
|
| +++ b/src/compiler.cc
|
| @@ -64,10 +64,10 @@ PARSE_INFO_GETTER(Handle<Script>, script)
|
| PARSE_INFO_GETTER(bool, is_eval)
|
| PARSE_INFO_GETTER(bool, is_native)
|
| PARSE_INFO_GETTER(bool, is_module)
|
| +PARSE_INFO_GETTER(FunctionLiteral*, literal)
|
| PARSE_INFO_GETTER_WITH_DEFAULT(LanguageMode, language_mode, STRICT)
|
| PARSE_INFO_GETTER_WITH_DEFAULT(Handle<JSFunction>, closure,
|
| Handle<JSFunction>::null())
|
| -PARSE_INFO_GETTER(FunctionLiteral*, function)
|
| PARSE_INFO_GETTER_WITH_DEFAULT(Scope*, scope, nullptr)
|
| PARSE_INFO_GETTER(Handle<Context>, context)
|
| PARSE_INFO_GETTER(Handle<SharedFunctionInfo>, shared_info)
|
| @@ -108,6 +108,16 @@ bool CompilationInfo::has_context() const {
|
| }
|
|
|
|
|
| +bool CompilationInfo::has_literal() const {
|
| + return parse_info_ && parse_info_->literal() != nullptr;
|
| +}
|
| +
|
| +
|
| +bool CompilationInfo::has_scope() const {
|
| + return parse_info_ && parse_info_->scope() != nullptr;
|
| +}
|
| +
|
| +
|
| CompilationInfo::CompilationInfo(ParseInfo* parse_info)
|
| : CompilationInfo(parse_info, nullptr, BASE, parse_info->isolate(),
|
| parse_info->zone()) {
|
| @@ -210,9 +220,9 @@ Code::Flags CompilationInfo::flags() const {
|
| // for the SharedFunctionInfo::kCallsUntilPrimitiveOptimization-th time.
|
| bool CompilationInfo::ShouldSelfOptimize() {
|
| return FLAG_crankshaft &&
|
| - !(function()->flags() & AstProperties::kDontSelfOptimize) &&
|
| - !function()->dont_optimize() &&
|
| - function()->scope()->AllowsLazyCompilation() &&
|
| + !(literal()->flags() & AstProperties::kDontSelfOptimize) &&
|
| + !literal()->dont_optimize() &&
|
| + literal()->scope()->AllowsLazyCompilation() &&
|
| (!has_shared_info() || !shared_info()->optimization_disabled());
|
| }
|
|
|
| @@ -220,12 +230,12 @@ bool CompilationInfo::ShouldSelfOptimize() {
|
| void CompilationInfo::EnsureFeedbackVector() {
|
| if (feedback_vector_.is_null()) {
|
| feedback_vector_ = isolate()->factory()->NewTypeFeedbackVector(
|
| - function()->feedback_vector_spec());
|
| + literal()->feedback_vector_spec());
|
| }
|
|
|
| // It's very important that recompiles do not alter the structure of the
|
| // type feedback vector.
|
| - CHECK(!feedback_vector_->SpecDiffersFrom(function()->feedback_vector_spec()));
|
| + CHECK(!feedback_vector_->SpecDiffersFrom(literal()->feedback_vector_spec()));
|
| }
|
|
|
|
|
| @@ -687,7 +697,7 @@ MUST_USE_RESULT static MaybeHandle<Code> GetUnoptimizedCodeCommon(
|
| // Parse and update CompilationInfo with the results.
|
| if (!Parser::ParseStatic(info->parse_info())) return MaybeHandle<Code>();
|
| Handle<SharedFunctionInfo> shared = info->shared_info();
|
| - FunctionLiteral* lit = info->function();
|
| + FunctionLiteral* lit = info->literal();
|
| shared->set_language_mode(lit->language_mode());
|
| SetExpectedNofPropertiesFromEstimate(shared, lit->expected_property_count());
|
| MaybeDisableOptimization(shared, lit->dont_optimize_reason());
|
| @@ -771,12 +781,12 @@ static void InsertCodeIntoOptimizedCodeMap(CompilationInfo* info) {
|
|
|
| static bool Renumber(ParseInfo* parse_info) {
|
| if (!AstNumbering::Renumber(parse_info->isolate(), parse_info->zone(),
|
| - parse_info->function())) {
|
| + parse_info->literal())) {
|
| return false;
|
| }
|
| Handle<SharedFunctionInfo> shared_info = parse_info->shared_info();
|
| if (!shared_info.is_null()) {
|
| - FunctionLiteral* lit = parse_info->function();
|
| + FunctionLiteral* lit = parse_info->literal();
|
| shared_info->set_ast_node_count(lit->ast_node_count());
|
| MaybeDisableOptimization(shared_info, lit->dont_optimize_reason());
|
| shared_info->set_dont_crankshaft(lit->flags() &
|
| @@ -787,11 +797,11 @@ static bool Renumber(ParseInfo* parse_info) {
|
|
|
|
|
| bool Compiler::Analyze(ParseInfo* info) {
|
| - DCHECK(info->function() != NULL);
|
| + DCHECK_NOT_NULL(info->literal());
|
| if (!Rewriter::Rewrite(info)) return false;
|
| if (!Scope::Analyze(info)) return false;
|
| if (!Renumber(info)) return false;
|
| - DCHECK(info->scope() != NULL);
|
| + DCHECK_NOT_NULL(info->scope());
|
| return true;
|
| }
|
|
|
| @@ -950,8 +960,8 @@ bool Compiler::EnsureCompiled(Handle<JSFunction> function,
|
| // TODO(turbofan): In the future, unoptimized code with deopt support could
|
| // be generated lazily once deopt is triggered.
|
| bool Compiler::EnsureDeoptimizationSupport(CompilationInfo* info) {
|
| - DCHECK(info->function() != NULL);
|
| - DCHECK(info->scope() != NULL);
|
| + DCHECK_NOT_NULL(info->literal());
|
| + DCHECK(info->has_scope());
|
| Handle<SharedFunctionInfo> shared = info->shared_info();
|
| if (!shared->has_deoptimization_support()) {
|
| // TODO(titzer): just reuse the ParseInfo for the unoptimized compile.
|
| @@ -959,7 +969,7 @@ bool Compiler::EnsureDeoptimizationSupport(CompilationInfo* info) {
|
| // Note that we use the same AST that we will use for generating the
|
| // optimized code.
|
| ParseInfo* parse_info = unoptimized.parse_info();
|
| - parse_info->set_literal(info->function());
|
| + parse_info->set_literal(info->literal());
|
| parse_info->set_scope(info->scope());
|
| parse_info->set_context(info->context());
|
| unoptimized.EnableDeoptimizationSupport();
|
| @@ -1018,7 +1028,7 @@ bool CompileEvalForDebugging(Handle<JSFunction> function,
|
| return false;
|
| }
|
|
|
| - FunctionLiteral* lit = info.function();
|
| + FunctionLiteral* lit = parse_info.literal();
|
| LiveEditFunctionTracker live_edit_tracker(isolate, lit);
|
|
|
| if (!CompileUnoptimizedCode(&info)) {
|
| @@ -1081,7 +1091,7 @@ void Compiler::CompileForLiveEdit(Handle<Script> script) {
|
| info.parse_info()->set_global();
|
| if (!Parser::ParseStatic(info.parse_info())) return;
|
|
|
| - LiveEditFunctionTracker tracker(info.isolate(), info.function());
|
| + LiveEditFunctionTracker tracker(info.isolate(), parse_info.literal());
|
| if (!CompileUnoptimizedCode(&info)) return;
|
| if (info.has_shared_info()) {
|
| Handle<ScopeInfo> scope_info =
|
| @@ -1114,7 +1124,7 @@ static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
|
|
|
| { VMState<COMPILER> state(info->isolate());
|
| if (parse_info->literal() == NULL) {
|
| - // Parse the script if needed (if it's already parsed, function() is
|
| + // Parse the script if needed (if it's already parsed, literal() is
|
| // non-NULL). If compiling for debugging, we may eagerly compile inner
|
| // functions, so do not parse lazily in that case.
|
| ScriptCompiler::CompileOptions options = parse_info->compile_options();
|
| @@ -1143,7 +1153,7 @@ static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) {
|
|
|
| info->MarkAsFirstCompile();
|
|
|
| - FunctionLiteral* lit = info->function();
|
| + FunctionLiteral* lit = parse_info->literal();
|
| LiveEditFunctionTracker live_edit_tracker(isolate, lit);
|
|
|
| // Measure how long it takes to do the compilation; only take the
|
| @@ -1709,7 +1719,7 @@ bool CompilationPhase::ShouldProduceTraceOutput() const {
|
| #if DEBUG
|
| void CompilationInfo::PrintAstForTesting() {
|
| PrintF("--- Source from AST ---\n%s\n",
|
| - PrettyPrinter(isolate(), zone()).PrintProgram(function()));
|
| + PrettyPrinter(isolate(), zone()).PrintProgram(literal()));
|
| }
|
| #endif
|
| } // namespace internal
|
|
|