diff --git a/src/compilation-info.cc b/src/compilation-info.cc index 55542a3e16..f5298a130c 100644 --- a/src/compilation-info.cc +++ b/src/compilation-info.cc @@ -30,7 +30,6 @@ CompilationInfo::CompilationInfo(Zone* zone, Isolate* isolate, literal_ = literal; source_range_map_ = parse_info->source_range_map(); - if (parse_info->is_debug()) MarkAsDebug(); if (parse_info->is_eval()) MarkAsEval(); if (parse_info->is_native()) MarkAsNative(); if (parse_info->will_serialize()) MarkAsSerializing(); diff --git a/src/compilation-info.h b/src/compilation-info.h index 06e9d96886..9355288b85 100644 --- a/src/compilation-info.h +++ b/src/compilation-info.h @@ -36,18 +36,17 @@ class V8_EXPORT_PRIVATE CompilationInfo final { // Various configuration flags for a compilation, as well as some properties // of the compiled code produced by a compilation. enum Flag { - kIsDebug = 1 << 0, - kIsEval = 1 << 1, - kIsNative = 1 << 2, - kSerializing = 1 << 3, - kAccessorInliningEnabled = 1 << 4, - kFunctionContextSpecializing = 1 << 5, - kInliningEnabled = 1 << 6, - kDisableFutureOptimization = 1 << 7, - kSplittingEnabled = 1 << 8, - kSourcePositionsEnabled = 1 << 9, - kBailoutOnUninitialized = 1 << 10, - kLoopPeelingEnabled = 1 << 11, + kIsEval = 1 << 0, + kIsNative = 1 << 1, + kSerializing = 1 << 2, + kAccessorInliningEnabled = 1 << 3, + kFunctionContextSpecializing = 1 << 4, + kInliningEnabled = 1 << 5, + kDisableFutureOptimization = 1 << 6, + kSplittingEnabled = 1 << 7, + kSourcePositionsEnabled = 1 << 8, + kBailoutOnUninitialized = 1 << 9, + kLoopPeelingEnabled = 1 << 10, }; // Construct a compilation info for unoptimized compilation. @@ -108,11 +107,6 @@ class V8_EXPORT_PRIVATE CompilationInfo final { // Flags used by unoptimized compilation. - // Compiles marked as debug produce unoptimized code with debug break slots. - // Inner functions that cannot be compiled w/o context are compiled eagerly. - void MarkAsDebug() { SetFlag(kIsDebug); } - bool is_debug() const { return GetFlag(kIsDebug); } - void MarkAsSerializing() { SetFlag(kSerializing); } bool will_serialize() const { return GetFlag(kSerializing); } @@ -161,7 +155,7 @@ class V8_EXPORT_PRIVATE CompilationInfo final { // Generate a pre-aged prologue if we are optimizing for size, which // will make code old more aggressive. Only apply to Code::FUNCTION, // since only functions are aged in the compilation cache. - return FLAG_optimize_for_size && FLAG_age_code && !is_debug() && + return FLAG_optimize_for_size && FLAG_age_code && output_code_kind() == Code::FUNCTION; } diff --git a/src/compiler.cc b/src/compiler.cc index 043afbe0f2..cd4b4689dc 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -255,7 +255,7 @@ void EnsureFeedbackMetadata(CompilationInfo* compilation_info) { compilation_info->literal()->feedback_vector_spec())); } -bool UseAsmWasm(FunctionLiteral* literal, bool asm_wasm_broken, bool is_debug) { +bool UseAsmWasm(FunctionLiteral* literal, bool asm_wasm_broken) { // Check whether asm.js validation is enabled. if (!FLAG_validate_asm) return false; @@ -263,9 +263,6 @@ bool UseAsmWasm(FunctionLiteral* literal, bool asm_wasm_broken, bool is_debug) { // invalid module instantiation attempts are off limit forever. if (asm_wasm_broken) return false; - // Compiling for debugging is not supported, fall back. - if (is_debug) return false; - // In stress mode we want to run the validator on everything. if (FLAG_stress_validate_asm) return true; @@ -296,13 +293,6 @@ void InstallUnoptimizedCode(CompilationInfo* compilation_info) { shared->set_outer_scope_info(*outer_scope->scope_info()); } - // Install compilation result on the shared function info. - // TODO(mstarzinger): Compiling for debug code might be used to reveal inner - // functions via {FindSharedFunctionInfoInScript}, in which case we end up - // regenerating existing bytecode. Fix this! - if (compilation_info->is_debug() && compilation_info->has_bytecode_array()) { - shared->ClearBytecodeArray(); - } DCHECK(!compilation_info->code().is_null()); shared->ReplaceCode(*compilation_info->code()); if (compilation_info->has_bytecode_array()) { @@ -385,8 +375,7 @@ bool Renumber(ParseInfo* parse_info, std::unique_ptr PrepareAndExecuteUnoptimizedCompileJob( ParseInfo* parse_info, FunctionLiteral* literal, Isolate* isolate) { - if (UseAsmWasm(literal, parse_info->is_asm_wasm_broken(), - parse_info->is_debug())) { + if (UseAsmWasm(literal, parse_info->is_asm_wasm_broken())) { std::unique_ptr asm_job( AsmJs::NewCompilationJob(parse_info, literal, isolate)); if (asm_job->PrepareJob() == CompilationJob::SUCCEEDED && @@ -448,26 +437,10 @@ bool FinalizeUnoptimizedCode( std::forward_list>* inner_function_jobs) { DCHECK(AllowCompilation::IsAllowed(isolate)); - // Internalize ast values onto the heap. - parse_info->ast_value_factory()->Internalize(isolate); - // Allocate scope infos for the literal. DeclarationScope::AllocateScopeInfos(parse_info, isolate, AnalyzeMode::kRegular); - // If compiling top-level code, allocate a shared function info and an array - // for shared function infos for inner functions. - if (parse_info->is_toplevel()) { - EnsureSharedFunctionInfosArrayOnScript(parse_info, isolate); - DCHECK_EQ(kNoSourcePosition, - parse_info->literal()->function_token_position()); - if (shared_info.is_null()) { - shared_info = isolate->factory()->NewSharedFunctionInfoForLiteral( - parse_info->literal(), parse_info->script()); - shared_info->set_is_toplevel(true); - } - } - // Finalize the outer-most function's compilation job. outer_function_job->compilation_info()->set_shared_info(shared_info); if (FinalizeUnoptimizedCompilationJob(outer_function_job) != @@ -493,39 +466,6 @@ bool FinalizeUnoptimizedCode( return true; } -MUST_USE_RESULT MaybeHandle CompileUnoptimizedFunction( - ParseInfo* parse_info, Isolate* isolate, - Handle shared_info) { - RuntimeCallTimerScope runtimeTimer( - isolate, &RuntimeCallStats::CompileUnoptimizedFunction); - VMState state(isolate); - PostponeInterruptsScope postpone(isolate); - - // Parse and update ParseInfo with the results. - if (!parsing::ParseFunction(parse_info, shared_info, isolate)) { - return MaybeHandle(); - } - - // Generate the unoptimized bytecode or asm-js data. - std::forward_list> inner_function_jobs; - std::unique_ptr outer_function_job( - GenerateUnoptimizedCode(parse_info, isolate, &inner_function_jobs)); - if (!outer_function_job) { - if (!isolate->has_pending_exception()) isolate->StackOverflow(); - return MaybeHandle(); - } - - // Finalize compilation of the unoptimized bytecode or asm-js data. - if (!FinalizeUnoptimizedCode(parse_info, isolate, shared_info, - outer_function_job.get(), - &inner_function_jobs)) { - if (!isolate->has_pending_exception()) isolate->StackOverflow(); - return MaybeHandle(); - } - - return handle(shared_info->code(), isolate); -} - MUST_USE_RESULT MaybeHandle GetCodeFromOptimizedCodeCache( Handle function, BailoutId osr_ast_id) { RuntimeCallTimerScope runtimeTimer( @@ -814,81 +754,9 @@ CompilationJob::Status FinalizeOptimizedCompilationJob(CompilationJob* job) { return CompilationJob::FAILED; } -MaybeHandle GetLazyCode(Handle function) { - Isolate* isolate = function->GetIsolate(); - DCHECK(!isolate->has_pending_exception()); - DCHECK(!function->is_compiled()); - TimerEventScope compile_timer(isolate); - RuntimeCallTimerScope runtimeTimer(isolate, - &RuntimeCallStats::CompileFunction); - TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileCode"); - AggregatedHistogramTimerScope timer(isolate->counters()->compile_lazy()); - - if (function->shared()->is_compiled()) { - // Function has already been compiled. Normally we'd expect the CompileLazy - // builtin to catch cases where we already have compiled code or optimized - // code, but there are paths that call the CompileLazy runtime function - // directly (e.g. failed asm.js compilations), so we include a check for - // those. - Handle cached_code; - if (GetCodeFromOptimizedCodeCache(function, BailoutId::None()) - .ToHandle(&cached_code)) { - if (FLAG_trace_opt) { - PrintF("[found optimized code for "); - function->ShortPrint(); - PrintF(" during unoptimized compile]\n"); - } - return cached_code; - } - // TODO(leszeks): Either handle optimization markers here, or DCHECK that - // there aren't any. - return Handle(function->shared()->code()); - } else { - // Function doesn't have any baseline compiled code, compile now. - DCHECK(!function->shared()->HasBytecodeArray()); - - Handle shared(function->shared()); - ParseInfo parse_info(shared); - parse_info.set_lazy_compile(); - if (FLAG_preparser_scope_analysis) { - if (shared->HasPreParsedScopeData()) { - Handle data( - PreParsedScopeData::cast(shared->preparsed_scope_data())); - parse_info.consumed_preparsed_scope_data()->SetData(data); - // After we've compiled the function, we don't need data about its - // skippable functions any more. - shared->set_preparsed_scope_data(isolate->heap()->null_value()); - } - } - Handle result; - ASSIGN_RETURN_ON_EXCEPTION( - isolate, result, - CompileUnoptimizedFunction(&parse_info, isolate, shared), Code); - - if (FLAG_always_opt && !shared->HasAsmWasmData()) { - if (FLAG_trace_opt) { - PrintF("[optimizing "); - function->ShortPrint(); - PrintF(" because --always-opt]\n"); - } - // Getting optimized code assumes that we have literals. - JSFunction::EnsureLiterals(function); - - Handle opt_code; - if (GetOptimizedCode(function, ConcurrencyMode::kNotConcurrent) - .ToHandle(&opt_code)) { - result = opt_code; - } - } - - return result; - } -} - -Handle CompileToplevel( - ParseInfo* parse_info, Isolate* isolate, - Handle shared_info) { - TimerEventScope timer(isolate); +MaybeHandle CompileToplevel(ParseInfo* parse_info, + Isolate* isolate) { + TimerEventScope top_level_timer(isolate); TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), "V8.CompileCode"); PostponeInterruptsScope postpone(isolate); DCHECK(!isolate->native_context().is_null()); @@ -898,48 +766,66 @@ Handle CompileToplevel( Handle