diff options
author | Myles Borins <mylesborins@google.com> | 2019-09-24 11:56:38 -0400 |
---|---|---|
committer | Myles Borins <myles.borins@gmail.com> | 2019-10-07 03:19:23 -0400 |
commit | f7f6c928c1c9c136b7926f892b8a2fda11d8b4b2 (patch) | |
tree | f5edbccb3ffda2573d70a6e291e7157f290e0ae0 /deps/v8/src/codegen/compiler.cc | |
parent | ffd22e81983056d09c064c59343a0e488236272d (diff) | |
download | android-node-v8-f7f6c928c1c9c136b7926f892b8a2fda11d8b4b2.tar.gz android-node-v8-f7f6c928c1c9c136b7926f892b8a2fda11d8b4b2.tar.bz2 android-node-v8-f7f6c928c1c9c136b7926f892b8a2fda11d8b4b2.zip |
deps: update V8 to 7.8.279.9
PR-URL: https://github.com/nodejs/node/pull/29694
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Diffstat (limited to 'deps/v8/src/codegen/compiler.cc')
-rw-r--r-- | deps/v8/src/codegen/compiler.cc | 129 |
1 files changed, 80 insertions, 49 deletions
diff --git a/deps/v8/src/codegen/compiler.cc b/deps/v8/src/codegen/compiler.cc index 906eb0f0ca..3a8ab3398a 100644 --- a/deps/v8/src/codegen/compiler.cc +++ b/deps/v8/src/codegen/compiler.cc @@ -410,6 +410,12 @@ void InstallUnoptimizedCode(UnoptimizedCompilationInfo* compilation_info, DCHECK(!compilation_info->has_asm_wasm_data()); DCHECK(!shared_info->HasFeedbackMetadata()); + // If the function failed asm-wasm compilation, mark asm_wasm as broken + // to ensure we don't try to compile as asm-wasm. + if (compilation_info->literal()->scope()->IsAsmModule()) { + shared_info->set_is_asm_wasm_broken(true); + } + InstallBytecodeArray(compilation_info->bytecode_array(), shared_info, parse_info, isolate); @@ -529,20 +535,16 @@ std::unique_ptr<UnoptimizedCompilationJob> GenerateUnoptimizedCode( DisallowHeapAccess no_heap_access; DCHECK(inner_function_jobs->empty()); - if (!Compiler::Analyze(parse_info)) { - return std::unique_ptr<UnoptimizedCompilationJob>(); + std::unique_ptr<UnoptimizedCompilationJob> job; + if (Compiler::Analyze(parse_info)) { + job = ExecuteUnoptimizedCompileJobs(parse_info, parse_info->literal(), + allocator, inner_function_jobs); } - // Prepare and execute compilation of the outer-most function. - std::unique_ptr<UnoptimizedCompilationJob> outer_function_job( - ExecuteUnoptimizedCompileJobs(parse_info, parse_info->literal(), - allocator, inner_function_jobs)); - if (!outer_function_job) return std::unique_ptr<UnoptimizedCompilationJob>(); - // Character stream shouldn't be used again. parse_info->ResetCharacterStream(); - return outer_function_job; + return job; } MaybeHandle<SharedFunctionInfo> GenerateUnoptimizedCodeForToplevel( @@ -1181,6 +1183,9 @@ bool Compiler::CollectSourcePositions(Isolate* isolate, DCHECK(shared_info->HasBytecodeArray()); DCHECK(!shared_info->GetBytecodeArray().HasSourcePositionTable()); + // Source position collection should be context independent. + NullContextScope null_context_scope(isolate); + // Collecting source positions requires allocating a new source position // table. DCHECK(AllowHeapAllocation::IsAllowed()); @@ -1215,59 +1220,51 @@ bool Compiler::CollectSourcePositions(Isolate* isolate, parse_info.set_collect_source_positions(); if (FLAG_allow_natives_syntax) parse_info.set_allow_natives_syntax(); - // Parse and update ParseInfo with the results. - if (!parsing::ParseAny(&parse_info, shared_info, isolate)) { + // Parse and update ParseInfo with the results. Don't update parsing + // statistics since we've already parsed the code before. + if (!parsing::ParseAny(&parse_info, shared_info, isolate, + parsing::ReportErrorsAndStatisticsMode::kNo)) { // Parsing failed probably as a result of stack exhaustion. bytecode->SetSourcePositionsFailedToCollect(); return FailWithPendingException( isolate, &parse_info, Compiler::ClearExceptionFlag::CLEAR_EXCEPTION); } + // Character stream shouldn't be used again. + parse_info.ResetCharacterStream(); + // Generate the unoptimized bytecode. // TODO(v8:8510): Consider forcing preparsing of inner functions to avoid // wasting time fully parsing them when they won't ever be used. - UnoptimizedCompilationJobList inner_function_jobs; - std::unique_ptr<UnoptimizedCompilationJob> outer_function_job( - GenerateUnoptimizedCode(&parse_info, isolate->allocator(), - &inner_function_jobs)); - if (!outer_function_job) { - // Recompiling failed probably as a result of stack exhaustion. - bytecode->SetSourcePositionsFailedToCollect(); - return FailWithPendingException( - isolate, &parse_info, Compiler::ClearExceptionFlag::CLEAR_EXCEPTION); - } + std::unique_ptr<UnoptimizedCompilationJob> job; + { + if (!Compiler::Analyze(&parse_info)) { + // Recompiling failed probably as a result of stack exhaustion. + bytecode->SetSourcePositionsFailedToCollect(); + return FailWithPendingException( + isolate, &parse_info, Compiler::ClearExceptionFlag::CLEAR_EXCEPTION); + } - DCHECK(outer_function_job->compilation_info()->collect_source_positions()); + job = interpreter::Interpreter::NewSourcePositionCollectionJob( + &parse_info, parse_info.literal(), bytecode, isolate->allocator()); - // TODO(v8:8510) Avoid re-allocating bytecode array/constant pool and - // re-internalizeing the ast values. Maybe we could use the - // unoptimized_compilation_flag to signal that all we need is the source - // position table (and we could do the DCHECK that the bytecode array is the - // same in the bytecode-generator, by comparing the real bytecode array on the - // SFI with the off-heap bytecode array). + if (!job || job->ExecuteJob() != CompilationJob::SUCCEEDED || + job->FinalizeJob(shared_info, isolate) != CompilationJob::SUCCEEDED) { + // Recompiling failed probably as a result of stack exhaustion. + bytecode->SetSourcePositionsFailedToCollect(); + return FailWithPendingException( + isolate, &parse_info, Compiler::ClearExceptionFlag::CLEAR_EXCEPTION); + } + } - // Internalize ast values onto the heap. - parse_info.ast_value_factory()->Internalize(isolate); + DCHECK(job->compilation_info()->collect_source_positions()); - { - // Allocate scope infos for the literal. - DeclarationScope::AllocateScopeInfos(&parse_info, isolate); - CHECK_EQ(outer_function_job->FinalizeJob(shared_info, isolate), - CompilationJob::SUCCEEDED); - } - - // Update the source position table on the original bytecode. - DCHECK(bytecode->IsBytecodeEqual( - *outer_function_job->compilation_info()->bytecode_array())); - DCHECK(outer_function_job->compilation_info()->has_bytecode_array()); - ByteArray source_position_table = outer_function_job->compilation_info() - ->bytecode_array() - ->SourcePositionTable(); - bytecode->set_source_position_table(source_position_table); // If debugging, make sure that instrumented bytecode has the source position // table set on it as well. if (shared_info->HasDebugInfo() && shared_info->GetDebugInfo().HasInstrumentedBytecodeArray()) { + ByteArray source_position_table = + job->compilation_info()->bytecode_array()->SourcePositionTable(); shared_info->GetDebugBytecodeArray().set_source_position_table( source_position_table); } @@ -1352,6 +1349,16 @@ bool Compiler::Compile(Handle<SharedFunctionInfo> shared_info, // Collect source positions immediately to try and flush out bytecode // mismatches. SharedFunctionInfo::EnsureSourcePositionsAvailable(isolate, shared_info); + + // Do the same for eagerly compiled inner functions. + for (auto&& inner_job : inner_function_jobs) { + Handle<SharedFunctionInfo> inner_shared_info = + Compiler::GetSharedFunctionInfo( + inner_job->compilation_info()->literal(), parse_info.script(), + isolate); + SharedFunctionInfo::EnsureSourcePositionsAvailable(isolate, + inner_shared_info); + } } return true; @@ -2110,7 +2117,11 @@ MaybeHandle<JSFunction> Compiler::GetWrappedFunction( script->set_wrapped_arguments(*arguments); parse_info.set_eval(); // Use an eval scope as declaration scope. - parse_info.set_wrapped_as_function(); + parse_info.set_function_syntax_kind(FunctionSyntaxKind::kWrapped); + // TODO(delphick): Remove this and instead make the wrapped and wrapper + // functions fully non-lazy instead thus preventing source positions from + // being omitted. + parse_info.set_collect_source_positions(true); // parse_info.set_eager(compile_options == ScriptCompiler::kEagerCompile); if (!context->IsNativeContext()) { parse_info.set_outer_scope_info(handle(context->scope_info(), isolate)); @@ -2217,7 +2228,28 @@ Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfo( // If we found an existing shared function info, return it. Handle<SharedFunctionInfo> existing; - if (maybe_existing.ToHandle(&existing)) return existing; + if (maybe_existing.ToHandle(&existing)) { + // If the function has been uncompiled (bytecode flushed) it will have lost + // any preparsed data. If we produced preparsed data during this compile for + // this function, replace the uncompiled data with one that includes it. + if (literal->produced_preparse_data() != nullptr && + existing->HasUncompiledDataWithoutPreparseData()) { + DCHECK(literal->inferred_name()->Equals( + existing->uncompiled_data().inferred_name())); + DCHECK_EQ(literal->start_position(), + existing->uncompiled_data().start_position()); + DCHECK_EQ(literal->end_position(), + existing->uncompiled_data().end_position()); + Handle<PreparseData> preparse_data = + literal->produced_preparse_data()->Serialize(isolate); + Handle<UncompiledData> new_uncompiled_data = + isolate->factory()->NewUncompiledDataWithPreparseData( + literal->inferred_name(), literal->start_position(), + literal->end_position(), preparse_data); + existing->set_uncompiled_data(*new_uncompiled_data); + } + return existing; + } // Allocate a shared function info object which will be compiled lazily. Handle<SharedFunctionInfo> result = @@ -2294,8 +2326,7 @@ bool Compiler::FinalizeOptimizedCompilationJob(OptimizedCompilationJob* job, return CompilationJob::FAILED; } -void Compiler::PostInstantiation(Handle<JSFunction> function, - AllocationType allocation) { +void Compiler::PostInstantiation(Handle<JSFunction> function) { Isolate* isolate = function->GetIsolate(); Handle<SharedFunctionInfo> shared(function->shared(), isolate); IsCompiledScope is_compiled_scope(shared->is_compiled_scope()); |