[Compiler] Decouple CompilationInfo and ParseInfo.
Don't hold a pointer to parse_info in compilation_info, and instead explicitly add the fields needed in compiation_info. The intention is to make ParseInfo only actually needed for parsing, and eventually make it possible to compile with only a CompileInfo. BUG=v8:5203 Change-Id: Iecd39245e44c218874401c3991eeaf3ceef2816f Reviewed-on: https://chromium-review.googlesource.com/595738 Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Reviewed-by: Andreas Haas <ahaas@chromium.org> Commit-Queue: Ross McIlroy <rmcilroy@chromium.org> Cr-Commit-Position: refs/heads/master@{#47119}
This commit is contained in:
parent
e44c2af0c0
commit
b4e55e9443
@ -184,8 +184,8 @@ void ReportInstantiationFailure(Handle<Script> script, int position,
|
||||
// code.
|
||||
class AsmJsCompilationJob final : public CompilationJob {
|
||||
public:
|
||||
explicit AsmJsCompilationJob(CompilationInfo* info)
|
||||
: CompilationJob(info->isolate(), info, "AsmJs"),
|
||||
explicit AsmJsCompilationJob(ParseInfo* parse_info, CompilationInfo* info)
|
||||
: CompilationJob(info->isolate(), parse_info, info, "AsmJs"),
|
||||
module_(nullptr),
|
||||
asm_offsets_(nullptr),
|
||||
translate_time_(0),
|
||||
@ -210,23 +210,25 @@ class AsmJsCompilationJob final : public CompilationJob {
|
||||
CompilationJob::Status AsmJsCompilationJob::PrepareJobImpl() {
|
||||
// Step 1: Translate asm.js module to WebAssembly module.
|
||||
HistogramTimerScope translate_time_scope(
|
||||
info()->isolate()->counters()->asm_wasm_translation_time());
|
||||
size_t compile_zone_start = info()->zone()->allocation_size();
|
||||
compilation_info()->isolate()->counters()->asm_wasm_translation_time());
|
||||
size_t compile_zone_start = compilation_info()->zone()->allocation_size();
|
||||
base::ElapsedTimer translate_timer;
|
||||
translate_timer.Start();
|
||||
|
||||
Zone* compile_zone = info()->zone();
|
||||
Zone translate_zone(info()->isolate()->allocator(), ZONE_NAME);
|
||||
Zone* compile_zone = compilation_info()->zone();
|
||||
Zone translate_zone(compilation_info()->isolate()->allocator(), ZONE_NAME);
|
||||
|
||||
// TODO(mstarzinger): In order to move translation to the non-main thread
|
||||
// ExecuteJob phase, the scanner stream needs to be off-heap.
|
||||
std::unique_ptr<Utf16CharacterStream> stream(ScannerStream::For(
|
||||
handle(String::cast(info()->script()->source())),
|
||||
info()->literal()->start_position(), info()->literal()->end_position()));
|
||||
handle(String::cast(compilation_info()->script()->source())),
|
||||
compilation_info()->literal()->start_position(),
|
||||
compilation_info()->literal()->end_position()));
|
||||
wasm::AsmJsParser parser(&translate_zone, stack_limit(), std::move(stream));
|
||||
if (!parser.Run()) {
|
||||
DCHECK(!info()->isolate()->has_pending_exception());
|
||||
ReportCompilationFailure(info()->script(), parser.failure_location(),
|
||||
DCHECK(!compilation_info()->isolate()->has_pending_exception());
|
||||
ReportCompilationFailure(compilation_info()->script(),
|
||||
parser.failure_location(),
|
||||
parser.failure_message());
|
||||
return FAILED;
|
||||
}
|
||||
@ -237,9 +239,9 @@ CompilationJob::Status AsmJsCompilationJob::PrepareJobImpl() {
|
||||
stdlib_uses_ = *parser.stdlib_uses();
|
||||
|
||||
size_t compile_zone_size =
|
||||
info()->zone()->allocation_size() - compile_zone_start;
|
||||
compilation_info()->zone()->allocation_size() - compile_zone_start;
|
||||
size_t translate_zone_size = translate_zone.allocation_size();
|
||||
info()
|
||||
compilation_info()
|
||||
->isolate()
|
||||
->counters()
|
||||
->asm_wasm_translation_peak_memory_bytes()
|
||||
@ -266,15 +268,15 @@ CompilationJob::Status AsmJsCompilationJob::FinalizeJobImpl() {
|
||||
compile_timer.Start();
|
||||
|
||||
Handle<HeapNumber> uses_bitset =
|
||||
info()->isolate()->factory()->NewHeapNumberFromBits(
|
||||
compilation_info()->isolate()->factory()->NewHeapNumberFromBits(
|
||||
stdlib_uses_.ToIntegral());
|
||||
|
||||
wasm::ErrorThrower thrower(info()->isolate(), "AsmJs::Compile");
|
||||
wasm::ErrorThrower thrower(compilation_info()->isolate(), "AsmJs::Compile");
|
||||
Handle<WasmModuleObject> compiled =
|
||||
SyncCompileTranslatedAsmJs(
|
||||
info()->isolate(), &thrower,
|
||||
compilation_info()->isolate(), &thrower,
|
||||
wasm::ModuleWireBytes(module_->begin(), module_->end()),
|
||||
info()->script(),
|
||||
compilation_info()->script(),
|
||||
Vector<const byte>(asm_offsets_->begin(), asm_offsets_->size()))
|
||||
.ToHandleChecked();
|
||||
DCHECK(!thrower.error());
|
||||
@ -282,19 +284,23 @@ CompilationJob::Status AsmJsCompilationJob::FinalizeJobImpl() {
|
||||
|
||||
// The result is a compiled module and serialized standard library uses.
|
||||
Handle<FixedArray> result =
|
||||
info()->isolate()->factory()->NewFixedArray(kWasmDataEntryCount);
|
||||
compilation_info()->isolate()->factory()->NewFixedArray(
|
||||
kWasmDataEntryCount);
|
||||
result->set(kWasmDataCompiledModule, *compiled);
|
||||
result->set(kWasmDataUsesBitSet, *uses_bitset);
|
||||
info()->SetAsmWasmData(result);
|
||||
info()->SetCode(BUILTIN_CODE(info()->isolate(), InstantiateAsmJs));
|
||||
compilation_info()->SetAsmWasmData(result);
|
||||
compilation_info()->SetCode(
|
||||
BUILTIN_CODE(compilation_info()->isolate(), InstantiateAsmJs));
|
||||
|
||||
ReportCompilationSuccess(info()->script(), info()->literal()->position(),
|
||||
ReportCompilationSuccess(compilation_info()->script(),
|
||||
compilation_info()->literal()->position(),
|
||||
translate_time_, compile_time_, module_->size());
|
||||
return SUCCEEDED;
|
||||
}
|
||||
|
||||
CompilationJob* AsmJs::NewCompilationJob(CompilationInfo* info) {
|
||||
return new AsmJsCompilationJob(info);
|
||||
CompilationJob* AsmJs::NewCompilationJob(ParseInfo* parse_info,
|
||||
CompilationInfo* compilation_info) {
|
||||
return new AsmJsCompilationJob(parse_info, compilation_info);
|
||||
}
|
||||
|
||||
MaybeHandle<Object> AsmJs::InstantiateAsmWasm(Isolate* isolate,
|
||||
|
@ -15,12 +15,14 @@ namespace internal {
|
||||
class CompilationInfo;
|
||||
class CompilationJob;
|
||||
class JSArrayBuffer;
|
||||
class ParseInfo;
|
||||
class SharedFunctionInfo;
|
||||
|
||||
// Interface to compile and instantiate for asm.js modules.
|
||||
class AsmJs {
|
||||
public:
|
||||
static CompilationJob* NewCompilationJob(CompilationInfo* info);
|
||||
static CompilationJob* NewCompilationJob(ParseInfo* parse_info,
|
||||
CompilationInfo* compilation_info);
|
||||
static MaybeHandle<Object> InstantiateAsmWasm(Isolate* isolate,
|
||||
Handle<SharedFunctionInfo>,
|
||||
Handle<FixedArray> wasm_data,
|
||||
|
@ -84,8 +84,8 @@ Comment::~Comment() {
|
||||
|
||||
#endif // DEBUG
|
||||
|
||||
|
||||
void CodeGenerator::MakeCodePrologue(CompilationInfo* info, const char* kind) {
|
||||
void CodeGenerator::MakeCodePrologue(ParseInfo* parse_info,
|
||||
CompilationInfo* info, const char* kind) {
|
||||
bool print_ast = false;
|
||||
const char* ftype;
|
||||
|
||||
@ -103,7 +103,7 @@ void CodeGenerator::MakeCodePrologue(CompilationInfo* info, const char* kind) {
|
||||
DCHECK(ThreadId::Current().Equals(info->isolate()->thread_id()));
|
||||
AllowDeferredHandleDereference allow_deref;
|
||||
AllowHeapAllocation allow_gc;
|
||||
info->parse_info()->ast_value_factory()->Internalize(info->isolate());
|
||||
parse_info->ast_value_factory()->Internalize(info->isolate());
|
||||
|
||||
if (FLAG_trace_codegen || print_ast) {
|
||||
std::unique_ptr<char[]> name = info->GetDebugName();
|
||||
@ -112,7 +112,7 @@ void CodeGenerator::MakeCodePrologue(CompilationInfo* info, const char* kind) {
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if (info->parse_info() && print_ast) {
|
||||
if (!info->IsStub() && print_ast) {
|
||||
PrintF("--- AST ---\n%s\n",
|
||||
AstPrinter(info->isolate()).PrintProgram(info->literal()));
|
||||
}
|
||||
@ -252,8 +252,7 @@ void CodeGenerator::PrintCode(Handle<Code> code, CompilationInfo* info) {
|
||||
OFStream os(tracing_scope.file());
|
||||
|
||||
// Print the source code if available.
|
||||
bool print_source =
|
||||
info->parse_info() && (code->kind() == Code::OPTIMIZED_FUNCTION);
|
||||
bool print_source = code->kind() == Code::OPTIMIZED_FUNCTION;
|
||||
if (print_source) {
|
||||
Handle<SharedFunctionInfo> shared = info->shared_info();
|
||||
Handle<Script> script = info->script();
|
||||
@ -274,7 +273,7 @@ void CodeGenerator::PrintCode(Handle<Code> code, CompilationInfo* info) {
|
||||
}
|
||||
}
|
||||
if (info->IsOptimizing()) {
|
||||
if (FLAG_print_unopt_code && info->parse_info()) {
|
||||
if (FLAG_print_unopt_code) {
|
||||
os << "--- Unoptimized code ---\n";
|
||||
info->closure()->shared()->code()->Disassemble(debug_name.get(), os);
|
||||
}
|
||||
|
@ -69,11 +69,13 @@ namespace internal {
|
||||
|
||||
class CompilationInfo;
|
||||
class EhFrameWriter;
|
||||
class ParseInfo;
|
||||
|
||||
class CodeGenerator {
|
||||
public:
|
||||
// Printing of AST, etc. as requested by flags.
|
||||
static void MakeCodePrologue(CompilationInfo* info, const char* kind);
|
||||
static void MakeCodePrologue(ParseInfo* parse_info, CompilationInfo* info,
|
||||
const char* kind);
|
||||
|
||||
// Allocate and install the code.
|
||||
static Handle<Code> MakeCodeEpilogue(TurboAssembler* tasm,
|
||||
|
@ -10,49 +10,16 @@
|
||||
#include "src/debug/debug.h"
|
||||
#include "src/isolate.h"
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/parsing/parse-info.h"
|
||||
#include "src/source-position.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
#define PARSE_INFO_GETTER(type, name) \
|
||||
type CompilationInfo::name() const { \
|
||||
CHECK(parse_info()); \
|
||||
return parse_info()->name(); \
|
||||
}
|
||||
|
||||
#define PARSE_INFO_GETTER_WITH_DEFAULT(type, name, def) \
|
||||
type CompilationInfo::name() const { \
|
||||
return parse_info() ? parse_info()->name() : def; \
|
||||
}
|
||||
|
||||
PARSE_INFO_GETTER(Handle<Script>, script)
|
||||
PARSE_INFO_GETTER(FunctionLiteral*, literal)
|
||||
PARSE_INFO_GETTER_WITH_DEFAULT(DeclarationScope*, scope, nullptr)
|
||||
|
||||
#undef PARSE_INFO_GETTER
|
||||
#undef PARSE_INFO_GETTER_WITH_DEFAULT
|
||||
|
||||
bool CompilationInfo::is_debug() const {
|
||||
return parse_info() ? parse_info()->is_debug() : false;
|
||||
}
|
||||
|
||||
void CompilationInfo::set_is_debug() {
|
||||
CHECK(parse_info());
|
||||
parse_info()->set_is_debug();
|
||||
}
|
||||
|
||||
void CompilationInfo::PrepareForSerializing() {
|
||||
if (parse_info()) parse_info()->set_will_serialize();
|
||||
SetFlag(kSerializing);
|
||||
}
|
||||
|
||||
CompilationInfo::CompilationInfo(Zone* zone, ParseInfo* parse_info,
|
||||
Isolate* isolate,
|
||||
CompilationInfo::CompilationInfo(Zone* zone, Isolate* isolate,
|
||||
Handle<Script> script,
|
||||
Handle<SharedFunctionInfo> shared,
|
||||
Handle<JSFunction> closure)
|
||||
: CompilationInfo(parse_info, {}, Code::ComputeFlags(Code::FUNCTION), BASE,
|
||||
: CompilationInfo(script, {}, Code::ComputeFlags(Code::FUNCTION), BASE,
|
||||
isolate, zone) {
|
||||
shared_info_ = shared;
|
||||
closure_ = closure;
|
||||
@ -68,22 +35,31 @@ CompilationInfo::CompilationInfo(Zone* zone, ParseInfo* parse_info,
|
||||
}
|
||||
|
||||
if (FLAG_block_coverage && isolate->is_block_code_coverage() &&
|
||||
parse_info->script()->IsUserJavaScript()) {
|
||||
script_->IsUserJavaScript()) {
|
||||
MarkAsBlockCoverageEnabled();
|
||||
}
|
||||
|
||||
if (script_->type() == Script::TYPE_NATIVE) {
|
||||
MarkAsNative();
|
||||
}
|
||||
if (script_->compilation_type() == Script::COMPILATION_TYPE_EVAL) {
|
||||
MarkAsEval();
|
||||
}
|
||||
}
|
||||
|
||||
CompilationInfo::CompilationInfo(Vector<const char> debug_name,
|
||||
Isolate* isolate, Zone* zone,
|
||||
Code::Flags code_flags)
|
||||
: CompilationInfo(nullptr, debug_name, code_flags, STUB, isolate, zone) {}
|
||||
: CompilationInfo(Handle<Script>::null(), debug_name, code_flags, STUB,
|
||||
isolate, zone) {}
|
||||
|
||||
CompilationInfo::CompilationInfo(ParseInfo* parse_info,
|
||||
CompilationInfo::CompilationInfo(Handle<Script> script,
|
||||
Vector<const char> debug_name,
|
||||
Code::Flags code_flags, Mode mode,
|
||||
Isolate* isolate, Zone* zone)
|
||||
: parse_info_(parse_info),
|
||||
isolate_(isolate),
|
||||
: isolate_(isolate),
|
||||
script_(script),
|
||||
literal_(nullptr),
|
||||
flags_(0),
|
||||
code_flags_(code_flags),
|
||||
mode_(mode),
|
||||
@ -105,6 +81,11 @@ CompilationInfo::~CompilationInfo() {
|
||||
dependencies()->Rollback();
|
||||
}
|
||||
|
||||
DeclarationScope* CompilationInfo::scope() const {
|
||||
DCHECK_NOT_NULL(literal_);
|
||||
return literal_->scope();
|
||||
}
|
||||
|
||||
int CompilationInfo::num_parameters() const {
|
||||
return !IsStub() ? scope()->num_parameters() : parameter_count_;
|
||||
}
|
||||
@ -137,6 +118,9 @@ void CompilationInfo::set_deferred_handles(DeferredHandles* deferred_handles) {
|
||||
}
|
||||
|
||||
void CompilationInfo::ReopenHandlesInNewHandleScope() {
|
||||
if (!script_.is_null()) {
|
||||
script_ = Handle<Script>(*script_);
|
||||
}
|
||||
if (!shared_info_.is_null()) {
|
||||
shared_info_ = Handle<SharedFunctionInfo>(*shared_info_);
|
||||
}
|
||||
@ -150,9 +134,9 @@ bool CompilationInfo::has_simple_parameters() {
|
||||
}
|
||||
|
||||
std::unique_ptr<char[]> CompilationInfo::GetDebugName() const {
|
||||
if (parse_info() && parse_info()->literal()) {
|
||||
if (literal()) {
|
||||
AllowHandleDereference allow_deref;
|
||||
return parse_info()->literal()->debug_name()->ToCString();
|
||||
return literal()->debug_name()->ToCString();
|
||||
}
|
||||
if (!shared_info().is_null()) {
|
||||
return shared_info()->DebugName()->ToCString();
|
||||
@ -190,15 +174,14 @@ StackFrame::Type CompilationInfo::GetOutputStackFrameType() const {
|
||||
}
|
||||
|
||||
int CompilationInfo::GetDeclareGlobalsFlags() const {
|
||||
return DeclareGlobalsEvalFlag::encode(parse_info()->is_eval()) |
|
||||
DeclareGlobalsNativeFlag::encode(parse_info()->is_native());
|
||||
return DeclareGlobalsEvalFlag::encode(is_eval()) |
|
||||
DeclareGlobalsNativeFlag::encode(is_native());
|
||||
}
|
||||
|
||||
SourcePositionTableBuilder::RecordingMode
|
||||
CompilationInfo::SourcePositionRecordingMode() const {
|
||||
return parse_info() && parse_info()->is_native()
|
||||
? SourcePositionTableBuilder::OMIT_SOURCE_POSITIONS
|
||||
: SourcePositionTableBuilder::RECORD_SOURCE_POSITIONS;
|
||||
return is_native() ? SourcePositionTableBuilder::OMIT_SOURCE_POSITIONS
|
||||
: SourcePositionTableBuilder::RECORD_SOURCE_POSITIONS;
|
||||
}
|
||||
|
||||
bool CompilationInfo::has_context() const { return !closure().is_null(); }
|
||||
|
@ -23,9 +23,9 @@ class CoverageInfo;
|
||||
class DeclarationScope;
|
||||
class DeferredHandles;
|
||||
class FunctionLiteral;
|
||||
class JavaScriptFrame;
|
||||
class ParseInfo;
|
||||
class Isolate;
|
||||
class JavaScriptFrame;
|
||||
class SourceRangeMap;
|
||||
class Zone;
|
||||
|
||||
// CompilationInfo encapsulates some information known at compile time. It
|
||||
@ -52,24 +52,32 @@ class V8_EXPORT_PRIVATE CompilationInfo final {
|
||||
kOptimizeFromBytecode = 1 << 14,
|
||||
kLoopPeelingEnabled = 1 << 15,
|
||||
kBlockCoverageEnabled = 1 << 16,
|
||||
kIsDebug = 1 << 17,
|
||||
kIsEval = 1 << 18,
|
||||
kIsNative = 1 << 19,
|
||||
};
|
||||
|
||||
CompilationInfo(Zone* zone, ParseInfo* parse_info, Isolate* isolate,
|
||||
CompilationInfo(Zone* zone, Isolate* isolate, Handle<Script> script,
|
||||
Handle<SharedFunctionInfo> shared,
|
||||
Handle<JSFunction> closure);
|
||||
CompilationInfo(Vector<const char> debug_name, Isolate* isolate, Zone* zone,
|
||||
Code::Flags code_flags);
|
||||
~CompilationInfo();
|
||||
|
||||
ParseInfo* parse_info() const { return parse_info_; }
|
||||
Handle<Script> script() const { return script_; }
|
||||
|
||||
FunctionLiteral* literal() const { return literal_; }
|
||||
void set_literal(FunctionLiteral* literal) {
|
||||
DCHECK_NOT_NULL(literal);
|
||||
literal_ = literal;
|
||||
}
|
||||
|
||||
SourceRangeMap* source_range_map() const { return source_range_map_; }
|
||||
void set_source_range_map(SourceRangeMap* source_range_map) {
|
||||
source_range_map_ = source_range_map;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------
|
||||
// TODO(titzer): inline and delete accessors of ParseInfo
|
||||
// -----------------------------------------------------------
|
||||
Handle<Script> script() const;
|
||||
FunctionLiteral* literal() const;
|
||||
DeclarationScope* scope() const;
|
||||
// -----------------------------------------------------------
|
||||
|
||||
Isolate* isolate() const { return isolate_; }
|
||||
Zone* zone() { return zone_; }
|
||||
@ -121,13 +129,11 @@ class V8_EXPORT_PRIVATE CompilationInfo final {
|
||||
|
||||
// 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() {
|
||||
set_is_debug();
|
||||
}
|
||||
void MarkAsDebug() { SetFlag(kIsDebug); }
|
||||
|
||||
bool is_debug() const;
|
||||
bool is_debug() const { return GetFlag(kIsDebug); }
|
||||
|
||||
void PrepareForSerializing();
|
||||
void MarkAsSerializing() { SetFlag(kSerializing); }
|
||||
|
||||
bool will_serialize() const { return GetFlag(kSerializing); }
|
||||
|
||||
@ -191,6 +197,14 @@ class V8_EXPORT_PRIVATE CompilationInfo final {
|
||||
return GetFlag(kBlockCoverageEnabled);
|
||||
}
|
||||
|
||||
void MarkAsEval() { SetFlag(kIsEval); }
|
||||
|
||||
bool is_eval() const { return GetFlag(kIsEval); }
|
||||
|
||||
void MarkAsNative() { SetFlag(kIsNative); }
|
||||
|
||||
bool is_native() const { return GetFlag(kIsNative); }
|
||||
|
||||
bool GeneratePreagedPrologue() const {
|
||||
// Generate a pre-aged prologue if we are optimizing for size, which
|
||||
// will make code old more aggressive. Only apply to Code::FUNCTION,
|
||||
@ -335,13 +349,10 @@ class V8_EXPORT_PRIVATE CompilationInfo final {
|
||||
// OPTIMIZE is optimized code generated by the Hydrogen-based backend.
|
||||
enum Mode { BASE, OPTIMIZE, STUB };
|
||||
|
||||
CompilationInfo(ParseInfo* parse_info, Vector<const char> debug_name,
|
||||
CompilationInfo(Handle<Script> script, Vector<const char> debug_name,
|
||||
Code::Flags code_flags, Mode mode, Isolate* isolate,
|
||||
Zone* zone);
|
||||
|
||||
ParseInfo* parse_info_;
|
||||
Isolate* isolate_;
|
||||
|
||||
void SetMode(Mode mode) { mode_ = mode; }
|
||||
|
||||
void SetFlag(Flag flag) { flags_ |= flag; }
|
||||
@ -352,7 +363,10 @@ class V8_EXPORT_PRIVATE CompilationInfo final {
|
||||
|
||||
bool GetFlag(Flag flag) const { return (flags_ & flag) != 0; }
|
||||
|
||||
void set_is_debug();
|
||||
Isolate* isolate_;
|
||||
Handle<Script> script_;
|
||||
FunctionLiteral* literal_;
|
||||
SourceRangeMap* source_range_map_; // Used when block coverage is enabled.
|
||||
|
||||
unsigned flags_;
|
||||
|
||||
|
@ -20,7 +20,7 @@ namespace {
|
||||
|
||||
void DisposeCompilationJob(CompilationJob* job, bool restore_function_code) {
|
||||
if (restore_function_code) {
|
||||
Handle<JSFunction> function = job->info()->closure();
|
||||
Handle<JSFunction> function = job->compilation_info()->closure();
|
||||
function->ReplaceCode(function->shared()->code());
|
||||
if (function->IsInOptimizationQueue()) {
|
||||
function->ClearOptimizationMarker();
|
||||
@ -197,7 +197,7 @@ void OptimizingCompileDispatcher::InstallOptimizedFunctions() {
|
||||
job = output_queue_.front();
|
||||
output_queue_.pop();
|
||||
}
|
||||
CompilationInfo* info = job->info();
|
||||
CompilationInfo* info = job->compilation_info();
|
||||
Handle<JSFunction> function(*info->closure());
|
||||
if (function->HasOptimizedCode()) {
|
||||
if (FLAG_trace_concurrent_recompilation) {
|
||||
|
@ -400,20 +400,21 @@ void UnoptimizedCompileJob::AnalyzeOnMainThread(Isolate* isolate) {
|
||||
}
|
||||
|
||||
compile_zone_.reset(new Zone(isolate->allocator(), ZONE_NAME));
|
||||
compile_info_.reset(new CompilationInfo(
|
||||
compile_zone_.get(), parse_info_.get(), isolate,
|
||||
compilation_info_.reset(new CompilationInfo(
|
||||
compile_zone_.get(), isolate, parse_info_->script(),
|
||||
Handle<SharedFunctionInfo>::null(), Handle<JSFunction>::null()));
|
||||
compilation_info_->set_literal(parse_info_->literal());
|
||||
|
||||
DeferredHandleScope scope(isolate);
|
||||
{
|
||||
if (Compiler::Analyze(compile_info_.get())) {
|
||||
if (Compiler::Analyze(parse_info_.get(), isolate)) {
|
||||
status_ = Status::kAnalyzed;
|
||||
} else {
|
||||
status_ = Status::kFailed;
|
||||
if (!isolate->has_pending_exception()) isolate->StackOverflow();
|
||||
}
|
||||
}
|
||||
compile_info_->set_deferred_handles(scope.Detach());
|
||||
compilation_info_->set_deferred_handles(scope.Detach());
|
||||
}
|
||||
|
||||
void UnoptimizedCompileJob::PrepareToCompileOnMainThread(Isolate* isolate) {
|
||||
@ -422,15 +423,15 @@ void UnoptimizedCompileJob::PrepareToCompileOnMainThread(Isolate* isolate) {
|
||||
DCHECK(status() == Status::kAnalyzed);
|
||||
COMPILER_DISPATCHER_TRACE_SCOPE(tracer_, kPrepareToCompile);
|
||||
|
||||
compile_job_.reset(
|
||||
Compiler::PrepareUnoptimizedCompilationJob(compile_info_.get()));
|
||||
if (!compile_job_.get()) {
|
||||
compilation_job_.reset(Compiler::PrepareUnoptimizedCompilationJob(
|
||||
parse_info_.get(), compilation_info_.get()));
|
||||
if (!compilation_job_.get()) {
|
||||
if (!isolate->has_pending_exception()) isolate->StackOverflow();
|
||||
status_ = Status::kFailed;
|
||||
return;
|
||||
}
|
||||
|
||||
CHECK(compile_job_->can_execute_on_background_thread());
|
||||
CHECK(compilation_job_->can_execute_on_background_thread());
|
||||
status_ = Status::kReadyToCompile;
|
||||
}
|
||||
|
||||
@ -445,9 +446,9 @@ void UnoptimizedCompileJob::Compile() {
|
||||
// CompilationJob::ExecuteJob.
|
||||
|
||||
uintptr_t stack_limit = GetCurrentStackPosition() - max_stack_size_ * KB;
|
||||
compile_job_->set_stack_limit(stack_limit);
|
||||
compilation_job_->set_stack_limit(stack_limit);
|
||||
|
||||
CompilationJob::Status status = compile_job_->ExecuteJob();
|
||||
CompilationJob::Status status = compilation_job_->ExecuteJob();
|
||||
USE(status);
|
||||
|
||||
// Always transition to kCompiled - errors will be reported by
|
||||
@ -467,17 +468,17 @@ void UnoptimizedCompileJob::FinalizeCompilingOnMainThread(Isolate* isolate) {
|
||||
|
||||
{
|
||||
HandleScope scope(isolate);
|
||||
compile_info_->set_shared_info(shared_);
|
||||
if (compile_job_->state() == CompilationJob::State::kFailed ||
|
||||
!Compiler::FinalizeCompilationJob(compile_job_.release())) {
|
||||
compilation_info_->set_shared_info(shared_);
|
||||
if (compilation_job_->state() == CompilationJob::State::kFailed ||
|
||||
!Compiler::FinalizeCompilationJob(compilation_job_.release())) {
|
||||
if (!isolate->has_pending_exception()) isolate->StackOverflow();
|
||||
status_ = Status::kFailed;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
compile_job_.reset();
|
||||
compile_info_.reset();
|
||||
compilation_job_.reset();
|
||||
compilation_info_.reset();
|
||||
compile_zone_.reset();
|
||||
parse_info_.reset();
|
||||
|
||||
@ -489,8 +490,8 @@ void UnoptimizedCompileJob::ResetOnMainThread(Isolate* isolate) {
|
||||
PrintF("UnoptimizedCompileJob[%p]: Resetting\n", static_cast<void*>(this));
|
||||
}
|
||||
|
||||
compile_job_.reset();
|
||||
compile_info_.reset();
|
||||
compilation_job_.reset();
|
||||
compilation_info_.reset();
|
||||
compile_zone_.reset();
|
||||
parser_.reset();
|
||||
unicode_cache_.reset();
|
||||
|
@ -132,8 +132,8 @@ class V8_EXPORT_PRIVATE UnoptimizedCompileJob : public CompilerDispatcherJob {
|
||||
|
||||
// Members required for compiling.
|
||||
std::shared_ptr<Zone> compile_zone_;
|
||||
std::unique_ptr<CompilationInfo> compile_info_;
|
||||
std::unique_ptr<CompilationJob> compile_job_;
|
||||
std::unique_ptr<CompilationInfo> compilation_info_;
|
||||
std::unique_ptr<CompilationJob> compilation_job_;
|
||||
|
||||
bool trace_compiler_dispatcher_jobs_;
|
||||
|
||||
|
591
src/compiler.cc
591
src/compiler.cc
File diff suppressed because it is too large
Load Diff
@ -54,7 +54,7 @@ class V8_EXPORT_PRIVATE Compiler : public AllStatic {
|
||||
|
||||
// Prepare a compilation job for unoptimized code. Requires ParseAndAnalyse.
|
||||
static CompilationJob* PrepareUnoptimizedCompilationJob(
|
||||
CompilationInfo* info);
|
||||
ParseInfo* parse_info, CompilationInfo* compilation_info);
|
||||
|
||||
// Generate and install code from previously queued compilation job.
|
||||
static bool FinalizeCompilationJob(CompilationJob* job);
|
||||
@ -68,20 +68,16 @@ class V8_EXPORT_PRIVATE Compiler : public AllStatic {
|
||||
EagerInnerFunctionLiterals;
|
||||
|
||||
// Parser::Parse, then Compiler::Analyze.
|
||||
static bool ParseAndAnalyze(ParseInfo* info,
|
||||
static bool ParseAndAnalyze(ParseInfo* parse_info,
|
||||
Handle<SharedFunctionInfo> shared_info,
|
||||
Isolate* isolate);
|
||||
// Convenience function.
|
||||
static bool ParseAndAnalyze(CompilationInfo* info);
|
||||
// Rewrite, analyze scopes, and renumber. If |eager_literals| is non-null, it
|
||||
// is appended with inner function literals which should be eagerly compiled.
|
||||
static bool Analyze(ParseInfo* info, Isolate* isolate,
|
||||
EagerInnerFunctionLiterals* eager_literals = nullptr);
|
||||
// Convenience function
|
||||
static bool Analyze(CompilationInfo* info,
|
||||
static bool Analyze(ParseInfo* parse_info, Isolate* isolate,
|
||||
EagerInnerFunctionLiterals* eager_literals = nullptr);
|
||||
// Ensures that bytecode is generated, calls ParseAndAnalyze internally.
|
||||
static bool EnsureBytecode(CompilationInfo* info);
|
||||
static bool EnsureBytecode(ParseInfo* parse_info,
|
||||
CompilationInfo* compilation_info);
|
||||
|
||||
// ===========================================================================
|
||||
// The following family of methods instantiates new functions for scripts or
|
||||
@ -169,7 +165,7 @@ class V8_EXPORT_PRIVATE CompilationJob {
|
||||
kFailed,
|
||||
};
|
||||
|
||||
CompilationJob(Isolate* isolate, CompilationInfo* info,
|
||||
CompilationJob(Isolate* isolate, ParseInfo* parse_info, CompilationInfo* info,
|
||||
const char* compiler_name,
|
||||
State initial_state = State::kReadyToPrepare);
|
||||
virtual ~CompilationJob() {}
|
||||
@ -206,7 +202,8 @@ class V8_EXPORT_PRIVATE CompilationJob {
|
||||
return executed_on_background_thread_;
|
||||
}
|
||||
State state() const { return state_; }
|
||||
CompilationInfo* info() const { return info_; }
|
||||
ParseInfo* parse_info() const { return parse_info_; }
|
||||
CompilationInfo* compilation_info() const { return compilation_info_; }
|
||||
Isolate* isolate() const;
|
||||
virtual size_t AllocatedMemory() const { return 0; }
|
||||
|
||||
@ -217,7 +214,9 @@ class V8_EXPORT_PRIVATE CompilationJob {
|
||||
virtual Status FinalizeJobImpl() = 0;
|
||||
|
||||
private:
|
||||
CompilationInfo* info_;
|
||||
// TODO(6409): Remove parse_info once Fullcode and AstGraphBuilder are gone.
|
||||
ParseInfo* parse_info_;
|
||||
CompilationInfo* compilation_info_;
|
||||
ThreadId isolate_thread_id_;
|
||||
base::TimeDelta time_taken_to_prepare_;
|
||||
base::TimeDelta time_taken_to_execute_;
|
||||
|
@ -527,7 +527,7 @@ void CodeGenerator::AssembleSourcePosition(SourcePosition source_position) {
|
||||
source_position, false);
|
||||
if (FLAG_code_comments) {
|
||||
CompilationInfo* info = this->info();
|
||||
if (!info->parse_info()) return;
|
||||
if (info->IsStub()) return;
|
||||
std::ostringstream buffer;
|
||||
buffer << "-- ";
|
||||
if (FLAG_trace_turbo ||
|
||||
|
@ -46,7 +46,7 @@ std::unique_ptr<char[]> GetVisualizerLogFileName(CompilationInfo* info,
|
||||
}
|
||||
EmbeddedVector<char, 256> source_file(0);
|
||||
bool source_available = false;
|
||||
if (FLAG_trace_file_names && info->parse_info()) {
|
||||
if (FLAG_trace_file_names && !info->script().is_null()) {
|
||||
Object* source_name = info->script()->name();
|
||||
if (source_name->IsString()) {
|
||||
String* str = String::cast(source_name);
|
||||
|
@ -507,13 +507,13 @@ Reduction JSInliner::ReduceJSCall(Node* node) {
|
||||
}
|
||||
|
||||
ParseInfo parse_info(shared_info);
|
||||
CompilationInfo info(parse_info.zone(), &parse_info,
|
||||
shared_info->GetIsolate(), shared_info,
|
||||
CompilationInfo info(parse_info.zone(), shared_info->GetIsolate(),
|
||||
parse_info.script(), shared_info,
|
||||
Handle<JSFunction>::null());
|
||||
if (info_->is_deoptimization_enabled()) info.MarkAsDeoptimizationEnabled();
|
||||
info.MarkAsOptimizeFromBytecode();
|
||||
|
||||
if (!Compiler::EnsureBytecode(&info)) {
|
||||
if (!Compiler::EnsureBytecode(&parse_info, &info)) {
|
||||
TRACE("Not inlining %s into %s because bytecode generation failed\n",
|
||||
shared_info->DebugName()->ToCString().get(),
|
||||
info_->shared_info()->DebugName()->ToCString().get());
|
||||
|
@ -574,12 +574,11 @@ PipelineStatistics* CreatePipelineStatistics(CompilationInfo* info,
|
||||
if (FLAG_trace_turbo) {
|
||||
TurboJsonFile json_of(info, std::ios_base::trunc);
|
||||
std::unique_ptr<char[]> function_name = info->GetDebugName();
|
||||
int pos = info->parse_info() ? info->shared_info()->start_position() : 0;
|
||||
int pos = info->IsStub() ? 0 : info->shared_info()->start_position();
|
||||
json_of << "{\"function\":\"" << function_name.get()
|
||||
<< "\", \"sourcePosition\":" << pos << ", \"source\":\"";
|
||||
Isolate* isolate = info->isolate();
|
||||
Handle<Script> script =
|
||||
info->parse_info() ? info->script() : Handle<Script>::null();
|
||||
Handle<Script> script = info->script();
|
||||
if (!script.is_null() && !script->source()->IsUndefined(isolate)) {
|
||||
DisallowHeapAllocation no_allocation;
|
||||
int start = info->shared_info()->start_position();
|
||||
@ -604,13 +603,15 @@ class PipelineCompilationJob final : public CompilationJob {
|
||||
Handle<JSFunction> function)
|
||||
// Note that the CompilationInfo is not initialized at the time we pass it
|
||||
// to the CompilationJob constructor, but it is not dereferenced there.
|
||||
: CompilationJob(function->GetIsolate(), &info_, "TurboFan"),
|
||||
: CompilationJob(function->GetIsolate(), parse_info, &compilation_info_,
|
||||
"TurboFan"),
|
||||
parse_info_(parse_info),
|
||||
zone_stats_(function->GetIsolate()->allocator()),
|
||||
info_(parse_info_.get()->zone(), parse_info_.get(),
|
||||
function->GetIsolate(), shared_info, function),
|
||||
pipeline_statistics_(CreatePipelineStatistics(info(), &zone_stats_)),
|
||||
data_(&zone_stats_, info(), pipeline_statistics_.get()),
|
||||
compilation_info_(parse_info_.get()->zone(), function->GetIsolate(),
|
||||
parse_info_->script(), shared_info, function),
|
||||
pipeline_statistics_(
|
||||
CreatePipelineStatistics(compilation_info(), &zone_stats_)),
|
||||
data_(&zone_stats_, compilation_info(), pipeline_statistics_.get()),
|
||||
pipeline_(&data_),
|
||||
linkage_(nullptr) {}
|
||||
|
||||
@ -625,7 +626,7 @@ class PipelineCompilationJob final : public CompilationJob {
|
||||
private:
|
||||
std::unique_ptr<ParseInfo> parse_info_;
|
||||
ZoneStats zone_stats_;
|
||||
CompilationInfo info_;
|
||||
CompilationInfo compilation_info_;
|
||||
std::unique_ptr<PipelineStatistics> pipeline_statistics_;
|
||||
PipelineData data_;
|
||||
PipelineImpl pipeline_;
|
||||
@ -635,45 +636,47 @@ class PipelineCompilationJob final : public CompilationJob {
|
||||
};
|
||||
|
||||
PipelineCompilationJob::Status PipelineCompilationJob::PrepareJobImpl() {
|
||||
if (info()->shared_info()->asm_function()) {
|
||||
if (info()->osr_frame() && !info()->is_optimizing_from_bytecode()) {
|
||||
info()->MarkAsFrameSpecializing();
|
||||
if (compilation_info()->shared_info()->asm_function()) {
|
||||
if (compilation_info()->osr_frame() &&
|
||||
!compilation_info()->is_optimizing_from_bytecode()) {
|
||||
compilation_info()->MarkAsFrameSpecializing();
|
||||
}
|
||||
info()->MarkAsFunctionContextSpecializing();
|
||||
compilation_info()->MarkAsFunctionContextSpecializing();
|
||||
} else {
|
||||
if (!FLAG_always_opt) {
|
||||
info()->MarkAsBailoutOnUninitialized();
|
||||
compilation_info()->MarkAsBailoutOnUninitialized();
|
||||
}
|
||||
if (FLAG_turbo_loop_peeling) {
|
||||
info()->MarkAsLoopPeelingEnabled();
|
||||
compilation_info()->MarkAsLoopPeelingEnabled();
|
||||
}
|
||||
}
|
||||
if (info()->is_optimizing_from_bytecode()) {
|
||||
info()->MarkAsDeoptimizationEnabled();
|
||||
if (compilation_info()->is_optimizing_from_bytecode()) {
|
||||
compilation_info()->MarkAsDeoptimizationEnabled();
|
||||
if (FLAG_turbo_inlining) {
|
||||
info()->MarkAsInliningEnabled();
|
||||
compilation_info()->MarkAsInliningEnabled();
|
||||
}
|
||||
if (FLAG_inline_accessors) {
|
||||
info()->MarkAsAccessorInliningEnabled();
|
||||
compilation_info()->MarkAsAccessorInliningEnabled();
|
||||
}
|
||||
if (info()->closure()->feedback_vector_cell()->map() ==
|
||||
if (compilation_info()->closure()->feedback_vector_cell()->map() ==
|
||||
isolate()->heap()->one_closure_cell_map()) {
|
||||
info()->MarkAsFunctionContextSpecializing();
|
||||
compilation_info()->MarkAsFunctionContextSpecializing();
|
||||
}
|
||||
info()->MarkAsInliningEnabled();
|
||||
compilation_info()->MarkAsInliningEnabled();
|
||||
}
|
||||
|
||||
data_.set_start_source_position(info()->shared_info()->start_position());
|
||||
data_.set_start_source_position(
|
||||
compilation_info()->shared_info()->start_position());
|
||||
|
||||
linkage_ = new (info()->zone())
|
||||
Linkage(Linkage::ComputeIncoming(info()->zone(), info()));
|
||||
linkage_ = new (compilation_info()->zone()) Linkage(
|
||||
Linkage::ComputeIncoming(compilation_info()->zone(), compilation_info()));
|
||||
|
||||
if (!pipeline_.CreateGraph()) {
|
||||
if (isolate()->has_pending_exception()) return FAILED; // Stack overflowed.
|
||||
return AbortOptimization(kGraphBuildingFailed);
|
||||
}
|
||||
|
||||
if (info()->is_osr()) data_.InitializeOsrHelper();
|
||||
if (compilation_info()->is_osr()) data_.InitializeOsrHelper();
|
||||
|
||||
// Make sure that we have generated the maximal number of deopt entries.
|
||||
// This is in order to avoid triggering the generation of deopt entries later
|
||||
@ -692,15 +695,15 @@ PipelineCompilationJob::Status PipelineCompilationJob::ExecuteJobImpl() {
|
||||
PipelineCompilationJob::Status PipelineCompilationJob::FinalizeJobImpl() {
|
||||
Handle<Code> code = pipeline_.FinalizeCode();
|
||||
if (code.is_null()) {
|
||||
if (info()->bailout_reason() == kNoReason) {
|
||||
if (compilation_info()->bailout_reason() == kNoReason) {
|
||||
return AbortOptimization(kCodeGenerationFailed);
|
||||
}
|
||||
return FAILED;
|
||||
}
|
||||
info()->dependencies()->Commit(code);
|
||||
info()->SetCode(code);
|
||||
if (info()->is_deoptimization_enabled()) {
|
||||
info()->context()->native_context()->AddOptimizedCode(*code);
|
||||
compilation_info()->dependencies()->Commit(code);
|
||||
compilation_info()->SetCode(code);
|
||||
if (compilation_info()->is_deoptimization_enabled()) {
|
||||
compilation_info()->context()->native_context()->AddOptimizedCode(*code);
|
||||
RegisterWeakObjectsInOptimizedCode(code);
|
||||
}
|
||||
return SUCCEEDED;
|
||||
@ -765,7 +768,7 @@ class PipelineWasmCompilationJob final : public CompilationJob {
|
||||
SourcePositionTable* source_positions,
|
||||
ZoneVector<trap_handler::ProtectedInstructionData>* protected_insts,
|
||||
wasm::ModuleOrigin wasm_origin)
|
||||
: CompilationJob(info->isolate(), info, "TurboFan",
|
||||
: CompilationJob(info->isolate(), nullptr, info, "TurboFan",
|
||||
State::kReadyToExecute),
|
||||
zone_stats_(info->isolate()->allocator()),
|
||||
pipeline_statistics_(CreatePipelineStatistics(info, &zone_stats_)),
|
||||
@ -806,8 +809,8 @@ PipelineWasmCompilationJob::PrepareJobImpl() {
|
||||
PipelineWasmCompilationJob::Status
|
||||
PipelineWasmCompilationJob::ExecuteJobImpl() {
|
||||
if (FLAG_trace_turbo) {
|
||||
TurboJsonFile json_of(info(), std::ios_base::trunc);
|
||||
json_of << "{\"function\":\"" << info()->GetDebugName().get()
|
||||
TurboJsonFile json_of(compilation_info(), std::ios_base::trunc);
|
||||
json_of << "{\"function\":\"" << compilation_info()->GetDebugName().get()
|
||||
<< "\", \"source\":\"\",\n\"phases\":[";
|
||||
}
|
||||
|
||||
@ -1873,7 +1876,7 @@ Handle<Code> Pipeline::GenerateCodeForCodeStub(Isolate* isolate,
|
||||
Code::Flags flags,
|
||||
const char* debug_name) {
|
||||
CompilationInfo info(CStrVector(debug_name), isolate, graph->zone(), flags);
|
||||
if (isolate->serializer_enabled()) info.PrepareForSerializing();
|
||||
if (isolate->serializer_enabled()) info.MarkAsSerializing();
|
||||
|
||||
// Construct a pipeline for scheduling and code generation.
|
||||
ZoneStats zone_stats(isolate->allocator());
|
||||
|
@ -29,8 +29,9 @@ namespace internal {
|
||||
|
||||
class FullCodegenCompilationJob final : public CompilationJob {
|
||||
public:
|
||||
explicit FullCodegenCompilationJob(CompilationInfo* info)
|
||||
: CompilationJob(info->isolate(), info, "Full-Codegen") {}
|
||||
explicit FullCodegenCompilationJob(ParseInfo* parse_info,
|
||||
CompilationInfo* info)
|
||||
: CompilationJob(info->isolate(), parse_info, info, "Full-Codegen") {}
|
||||
|
||||
bool can_execute_on_background_thread() const override { return false; }
|
||||
|
||||
@ -38,8 +39,10 @@ class FullCodegenCompilationJob final : public CompilationJob {
|
||||
|
||||
CompilationJob::Status ExecuteJobImpl() final {
|
||||
DCHECK(ThreadId::Current().Equals(isolate()->thread_id()));
|
||||
return FullCodeGenerator::MakeCode(info(), stack_limit()) ? SUCCEEDED
|
||||
: FAILED;
|
||||
return FullCodeGenerator::MakeCode(parse_info(), compilation_info(),
|
||||
stack_limit())
|
||||
? SUCCEEDED
|
||||
: FAILED;
|
||||
}
|
||||
|
||||
CompilationJob::Status FinalizeJobImpl() final { return SUCCEEDED; }
|
||||
@ -70,17 +73,14 @@ FullCodeGenerator::FullCodeGenerator(MacroAssembler* masm,
|
||||
}
|
||||
|
||||
// static
|
||||
CompilationJob* FullCodeGenerator::NewCompilationJob(CompilationInfo* info) {
|
||||
return new FullCodegenCompilationJob(info);
|
||||
CompilationJob* FullCodeGenerator::NewCompilationJob(
|
||||
ParseInfo* parse_info, CompilationInfo* compilation_info) {
|
||||
return new FullCodegenCompilationJob(parse_info, compilation_info);
|
||||
}
|
||||
|
||||
// static
|
||||
bool FullCodeGenerator::MakeCode(CompilationInfo* info) {
|
||||
return MakeCode(info, info->isolate()->stack_guard()->real_climit());
|
||||
}
|
||||
|
||||
// static
|
||||
bool FullCodeGenerator::MakeCode(CompilationInfo* info, uintptr_t stack_limit) {
|
||||
bool FullCodeGenerator::MakeCode(ParseInfo* parse_info, CompilationInfo* info,
|
||||
uintptr_t stack_limit) {
|
||||
Isolate* isolate = info->isolate();
|
||||
|
||||
DCHECK(!info->literal()->must_use_ignition());
|
||||
@ -96,7 +96,7 @@ bool FullCodeGenerator::MakeCode(CompilationInfo* info, uintptr_t stack_limit) {
|
||||
int len = String::cast(script->source())->length();
|
||||
isolate->counters()->total_full_codegen_source_size()->Increment(len);
|
||||
}
|
||||
CodeGenerator::MakeCodePrologue(info, "full");
|
||||
CodeGenerator::MakeCodePrologue(parse_info, info, "full");
|
||||
const int kInitialBufferSize = 4 * KB;
|
||||
MacroAssembler masm(info->isolate(), NULL, kInitialBufferSize,
|
||||
CodeObjectRequired::kYes);
|
||||
|
@ -25,6 +25,7 @@ namespace internal {
|
||||
class CompilationInfo;
|
||||
class CompilationJob;
|
||||
class JumpPatchSite;
|
||||
class ParseInfo;
|
||||
class Scope;
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
@ -37,10 +38,11 @@ class FullCodeGenerator final : public AstVisitor<FullCodeGenerator> {
|
||||
|
||||
void Initialize(uintptr_t stack_limit);
|
||||
|
||||
static CompilationJob* NewCompilationJob(CompilationInfo* info);
|
||||
static CompilationJob* NewCompilationJob(ParseInfo* parse_info,
|
||||
CompilationInfo* compilation_info);
|
||||
|
||||
static bool MakeCode(CompilationInfo* info, uintptr_t stack_limit);
|
||||
static bool MakeCode(CompilationInfo* info);
|
||||
static bool MakeCode(ParseInfo* parse_info, CompilationInfo* info,
|
||||
uintptr_t stack_limit);
|
||||
|
||||
static const int kMaxBackEdgeWeight = 127;
|
||||
|
||||
|
@ -774,8 +774,8 @@ BytecodeGenerator::BytecodeGenerator(CompilationInfo* info)
|
||||
DCHECK_EQ(closure_scope(), closure_scope()->GetClosureScope());
|
||||
if (info->is_block_coverage_enabled()) {
|
||||
DCHECK(FLAG_block_coverage);
|
||||
block_coverage_builder_ = new (zone()) BlockCoverageBuilder(
|
||||
zone(), builder(), info->parse_info()->source_range_map());
|
||||
block_coverage_builder_ = new (zone())
|
||||
BlockCoverageBuilder(zone(), builder(), info->source_range_map());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,8 @@ namespace interpreter {
|
||||
|
||||
class InterpreterCompilationJob final : public CompilationJob {
|
||||
public:
|
||||
explicit InterpreterCompilationJob(CompilationInfo* info);
|
||||
InterpreterCompilationJob(ParseInfo* pare_info,
|
||||
CompilationInfo* compilation_info);
|
||||
|
||||
protected:
|
||||
Status PrepareJobImpl() final;
|
||||
@ -143,15 +144,19 @@ bool ShouldPrintBytecode(Handle<SharedFunctionInfo> shared) {
|
||||
|
||||
} // namespace
|
||||
|
||||
InterpreterCompilationJob::InterpreterCompilationJob(CompilationInfo* info)
|
||||
: CompilationJob(info->isolate(), info, "Ignition"),
|
||||
generator_(info),
|
||||
runtime_call_stats_(info->isolate()->counters()->runtime_call_stats()),
|
||||
InterpreterCompilationJob::InterpreterCompilationJob(
|
||||
ParseInfo* parse_info, CompilationInfo* compilation_info)
|
||||
: CompilationJob(compilation_info->isolate(), parse_info, compilation_info,
|
||||
"Ignition"),
|
||||
generator_(compilation_info),
|
||||
runtime_call_stats_(
|
||||
compilation_info->isolate()->counters()->runtime_call_stats()),
|
||||
background_execute_counter_("CompileBackgroundIgnition") {}
|
||||
|
||||
InterpreterCompilationJob::Status InterpreterCompilationJob::PrepareJobImpl() {
|
||||
// TODO(5203): Move code out of codegen.cc once FCG goes away.
|
||||
CodeGenerator::MakeCodePrologue(info(), "interpreter");
|
||||
CodeGenerator::MakeCodePrologue(parse_info(), compilation_info(),
|
||||
"interpreter");
|
||||
return SUCCEEDED;
|
||||
}
|
||||
|
||||
@ -186,22 +191,24 @@ InterpreterCompilationJob::Status InterpreterCompilationJob::FinalizeJobImpl() {
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
if (ShouldPrintBytecode(info()->shared_info())) {
|
||||
if (ShouldPrintBytecode(compilation_info()->shared_info())) {
|
||||
OFStream os(stdout);
|
||||
std::unique_ptr<char[]> name = info()->GetDebugName();
|
||||
os << "[generating bytecode for function: " << info()->GetDebugName().get()
|
||||
<< "]" << std::endl;
|
||||
std::unique_ptr<char[]> name = compilation_info()->GetDebugName();
|
||||
os << "[generating bytecode for function: "
|
||||
<< compilation_info()->GetDebugName().get() << "]" << std::endl;
|
||||
bytecodes->Disassemble(os);
|
||||
os << std::flush;
|
||||
}
|
||||
|
||||
info()->SetBytecodeArray(bytecodes);
|
||||
info()->SetCode(BUILTIN_CODE(info()->isolate(), InterpreterEntryTrampoline));
|
||||
compilation_info()->SetBytecodeArray(bytecodes);
|
||||
compilation_info()->SetCode(
|
||||
BUILTIN_CODE(compilation_info()->isolate(), InterpreterEntryTrampoline));
|
||||
return SUCCEEDED;
|
||||
}
|
||||
|
||||
CompilationJob* Interpreter::NewCompilationJob(CompilationInfo* info) {
|
||||
return new InterpreterCompilationJob(info);
|
||||
CompilationJob* Interpreter::NewCompilationJob(
|
||||
ParseInfo* parse_info, CompilationInfo* compilation_info) {
|
||||
return new InterpreterCompilationJob(parse_info, compilation_info);
|
||||
}
|
||||
|
||||
bool Interpreter::IsDispatchTableInitialized() {
|
||||
|
@ -23,6 +23,7 @@ class Isolate;
|
||||
class Callable;
|
||||
class CompilationInfo;
|
||||
class CompilationJob;
|
||||
class ParseInfo;
|
||||
class SetupIsolateDelegate;
|
||||
class RootVisitor;
|
||||
|
||||
@ -38,8 +39,10 @@ class Interpreter {
|
||||
// Returns the interrupt budget which should be used for the profiler counter.
|
||||
static int InterruptBudget();
|
||||
|
||||
// Creates a compilation job which will generate bytecode for |info|.
|
||||
static CompilationJob* NewCompilationJob(CompilationInfo* info);
|
||||
// Creates a compilation job which will generate bytecode for |parse_info| and
|
||||
// |compilation_info|.
|
||||
static CompilationJob* NewCompilationJob(ParseInfo* parse_info,
|
||||
CompilationInfo* compilation_info);
|
||||
|
||||
// Return bytecode handler for |bytecode|.
|
||||
Code* GetBytecodeHandler(Bytecode bytecode, OperandScale operand_scale);
|
||||
|
@ -141,8 +141,8 @@ Handle<JSFunction> FunctionTester::ForMachineGraph(Graph* graph,
|
||||
Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) {
|
||||
Handle<SharedFunctionInfo> shared(function->shared());
|
||||
ParseInfo parse_info(shared);
|
||||
CompilationInfo info(parse_info.zone(), &parse_info, function->GetIsolate(),
|
||||
shared, function);
|
||||
CompilationInfo info(parse_info.zone(), function->GetIsolate(),
|
||||
parse_info.script(), shared, function);
|
||||
|
||||
info.SetOptimizing();
|
||||
if (flags_ & CompilationInfo::kInliningEnabled) {
|
||||
@ -154,7 +154,7 @@ Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) {
|
||||
info.MarkAsDeoptimizationEnabled();
|
||||
info.MarkAsOptimizeFromBytecode();
|
||||
} else {
|
||||
CHECK(Compiler::ParseAndAnalyze(&info));
|
||||
CHECK(Compiler::ParseAndAnalyze(&parse_info, shared, info.isolate()));
|
||||
parse_info.ast_value_factory()->Internalize(info.isolate());
|
||||
}
|
||||
JSFunction::EnsureLiterals(function);
|
||||
@ -172,11 +172,11 @@ Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) {
|
||||
Handle<JSFunction> FunctionTester::CompileGraph(Graph* graph) {
|
||||
Handle<SharedFunctionInfo> shared(function->shared());
|
||||
ParseInfo parse_info(shared);
|
||||
CompilationInfo info(parse_info.zone(), &parse_info, function->GetIsolate(),
|
||||
shared, function);
|
||||
CompilationInfo info(parse_info.zone(), function->GetIsolate(),
|
||||
parse_info.script(), shared, function);
|
||||
|
||||
CHECK(parsing::ParseFunction(info.parse_info(), info.shared_info(),
|
||||
info.isolate()));
|
||||
CHECK(
|
||||
parsing::ParseFunction(&parse_info, info.shared_info(), info.isolate()));
|
||||
info.SetOptimizing();
|
||||
|
||||
Handle<Code> code = Pipeline::GenerateCodeForTesting(&info, graph);
|
||||
|
@ -46,8 +46,8 @@ TEST(TestLinkageCreate) {
|
||||
HandleAndZoneScope handles;
|
||||
Handle<JSFunction> function = Compile("a + b");
|
||||
Handle<SharedFunctionInfo> shared(function->shared());
|
||||
ParseInfo parse_info(shared);
|
||||
CompilationInfo info(parse_info.zone(), &parse_info, function->GetIsolate(),
|
||||
Handle<Script> script(Script::cast(shared->script()));
|
||||
CompilationInfo info(handles.main_zone(), function->GetIsolate(), script,
|
||||
shared, function);
|
||||
CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info);
|
||||
CHECK(descriptor);
|
||||
@ -64,8 +64,8 @@ TEST(TestLinkageJSFunctionIncoming) {
|
||||
Handle<JSFunction>::cast(v8::Utils::OpenHandle(
|
||||
*v8::Local<v8::Function>::Cast(CompileRun(sources[i]))));
|
||||
Handle<SharedFunctionInfo> shared(function->shared());
|
||||
ParseInfo parse_info(shared);
|
||||
CompilationInfo info(parse_info.zone(), &parse_info, function->GetIsolate(),
|
||||
Handle<Script> script(Script::cast(shared->script()));
|
||||
CompilationInfo info(handles.main_zone(), function->GetIsolate(), script,
|
||||
shared, function);
|
||||
CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info);
|
||||
CHECK(descriptor);
|
||||
@ -82,8 +82,8 @@ TEST(TestLinkageJSCall) {
|
||||
HandleAndZoneScope handles;
|
||||
Handle<JSFunction> function = Compile("a + c");
|
||||
Handle<SharedFunctionInfo> shared(function->shared());
|
||||
ParseInfo parse_info(shared);
|
||||
CompilationInfo info(parse_info.zone(), &parse_info, function->GetIsolate(),
|
||||
Handle<Script> script(Script::cast(shared->script()));
|
||||
CompilationInfo info(handles.main_zone(), function->GetIsolate(), script,
|
||||
shared, function);
|
||||
|
||||
for (int i = 0; i < 32; i++) {
|
||||
|
@ -35,11 +35,12 @@ struct TestHelper : public HandleAndZoneScope {
|
||||
// TODO(titzer): don't scope analyze every single time.
|
||||
Handle<SharedFunctionInfo> shared(function->shared());
|
||||
ParseInfo parse_info(shared);
|
||||
CompilationInfo info(parse_info.zone(), &parse_info, function->GetIsolate(),
|
||||
shared, function);
|
||||
CompilationInfo info(parse_info.zone(), function->GetIsolate(),
|
||||
parse_info.script(), shared, function);
|
||||
|
||||
CHECK(parsing::ParseFunction(&parse_info, info.shared_info(),
|
||||
info.isolate()));
|
||||
info.set_literal(parse_info.literal());
|
||||
CHECK(Rewriter::Rewrite(&parse_info));
|
||||
DeclarationScope::Analyze(&parse_info, info.isolate());
|
||||
|
||||
|
@ -118,13 +118,11 @@ class BytecodeGraphTester {
|
||||
Handle<JSFunction>::cast(v8::Utils::OpenHandle(*api_function));
|
||||
CHECK(function->shared()->HasBytecodeArray());
|
||||
|
||||
// TODO(mstarzinger): We should be able to prime CompilationInfo without
|
||||
// having to instantiate a ParseInfo first. Fix this!
|
||||
Zone zone(function->GetIsolate()->allocator(), ZONE_NAME);
|
||||
Handle<SharedFunctionInfo> shared(function->shared());
|
||||
ParseInfo parse_info(shared);
|
||||
|
||||
CompilationInfo compilation_info(parse_info.zone(), &parse_info,
|
||||
function->GetIsolate(), shared, function);
|
||||
Handle<Script> script(Script::cast(shared->script()));
|
||||
CompilationInfo compilation_info(&zone, function->GetIsolate(), script,
|
||||
shared, function);
|
||||
compilation_info.SetOptimizing();
|
||||
compilation_info.MarkAsDeoptimizationEnabled();
|
||||
compilation_info.MarkAsOptimizeFromBytecode();
|
||||
|
@ -26,12 +26,12 @@ namespace {
|
||||
class BlockingCompilationJob : public CompilationJob {
|
||||
public:
|
||||
BlockingCompilationJob(Isolate* isolate, Handle<JSFunction> function)
|
||||
: CompilationJob(isolate, &info_, "BlockingCompilationJob",
|
||||
: CompilationJob(isolate, &parse_info_, &info_, "BlockingCompilationJob",
|
||||
State::kReadyToExecute),
|
||||
shared_(function->shared()),
|
||||
parse_info_(shared_),
|
||||
info_(parse_info_.zone(), &parse_info_, function->GetIsolate(), shared_,
|
||||
function),
|
||||
info_(parse_info_.zone(), function->GetIsolate(), parse_info_.script(),
|
||||
shared_, function),
|
||||
blocking_(false),
|
||||
semaphore_(0) {}
|
||||
~BlockingCompilationJob() override = default;
|
||||
|
Loading…
Reference in New Issue
Block a user