[compiler] Remove isolate from CompilationJob.
Also removes can_execute_on_background_thread() since all compilation jobs can now do that. Part of the work towards enabling off-thread bytecode compilation. BUG=v8:5203 Change-Id: I6a52c26d599ce74482b5fb49926603cb326f1e31 Reviewed-on: https://chromium-review.googlesource.com/731285 Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Commit-Queue: Ross McIlroy <rmcilroy@chromium.org> Cr-Commit-Position: refs/heads/master@{#48826}
This commit is contained in:
parent
db09c2a60b
commit
6f028d6a4e
@ -188,7 +188,8 @@ class AsmJsCompilationJob final : public CompilationJob {
|
||||
public:
|
||||
explicit AsmJsCompilationJob(ParseInfo* parse_info, FunctionLiteral* literal,
|
||||
Isolate* isolate)
|
||||
: CompilationJob(isolate, parse_info, &compilation_info_, "AsmJs"),
|
||||
: CompilationJob(parse_info->stack_limit(), parse_info,
|
||||
&compilation_info_, "AsmJs"),
|
||||
zone_(isolate->allocator(), ZONE_NAME),
|
||||
compilation_info_(&zone_, isolate, parse_info, literal),
|
||||
module_(nullptr),
|
||||
|
@ -367,7 +367,6 @@ void UnoptimizedCompileJob::PrepareToCompileOnMainThread(Isolate* isolate) {
|
||||
return;
|
||||
}
|
||||
|
||||
CHECK(compilation_job_->can_execute_on_background_thread());
|
||||
status_ = Status::kReadyToCompile;
|
||||
}
|
||||
|
||||
|
@ -71,21 +71,19 @@ struct ScopedTimer {
|
||||
// ----------------------------------------------------------------------------
|
||||
// Implementation of CompilationJob
|
||||
|
||||
CompilationJob::CompilationJob(Isolate* isolate, ParseInfo* parse_info,
|
||||
CompilationJob::CompilationJob(uintptr_t stack_limit, ParseInfo* parse_info,
|
||||
CompilationInfo* compilation_info,
|
||||
const char* compiler_name, State initial_state)
|
||||
: parse_info_(parse_info),
|
||||
compilation_info_(compilation_info),
|
||||
isolate_thread_id_(isolate->thread_id()),
|
||||
compiler_name_(compiler_name),
|
||||
state_(initial_state),
|
||||
stack_limit_(isolate->stack_guard()->real_climit()),
|
||||
executed_on_background_thread_(false) {}
|
||||
stack_limit_(stack_limit) {}
|
||||
|
||||
CompilationJob::Status CompilationJob::PrepareJob() {
|
||||
DCHECK(
|
||||
ThreadId::Current().Equals(compilation_info()->isolate()->thread_id()));
|
||||
DisallowJavascriptExecution no_js(isolate());
|
||||
DisallowJavascriptExecution no_js(compilation_info()->isolate());
|
||||
|
||||
if (FLAG_trace_opt && compilation_info()->IsOptimizing()) {
|
||||
OFStream os(stdout);
|
||||
@ -102,20 +100,10 @@ CompilationJob::Status CompilationJob::PrepareJob() {
|
||||
}
|
||||
|
||||
CompilationJob::Status CompilationJob::ExecuteJob() {
|
||||
base::Optional<DisallowHeapAllocation> no_allocation;
|
||||
base::Optional<DisallowHandleAllocation> no_handles;
|
||||
base::Optional<DisallowHandleDereference> no_deref;
|
||||
base::Optional<DisallowCodeDependencyChange> no_dependency_change;
|
||||
if (can_execute_on_background_thread()) {
|
||||
no_allocation.emplace();
|
||||
no_handles.emplace();
|
||||
no_deref.emplace();
|
||||
no_dependency_change.emplace();
|
||||
executed_on_background_thread_ =
|
||||
!ThreadId::Current().Equals(isolate_thread_id_);
|
||||
} else {
|
||||
DCHECK(ThreadId::Current().Equals(isolate_thread_id_));
|
||||
}
|
||||
DisallowHeapAllocation no_allocation;
|
||||
DisallowHandleAllocation no_handles;
|
||||
DisallowHandleDereference no_deref;
|
||||
DisallowCodeDependencyChange no_dependency_change;
|
||||
|
||||
// Delegate to the underlying implementation.
|
||||
DCHECK_EQ(state(), State::kReadyToExecute);
|
||||
@ -127,7 +115,7 @@ CompilationJob::Status CompilationJob::FinalizeJob() {
|
||||
DCHECK(
|
||||
ThreadId::Current().Equals(compilation_info()->isolate()->thread_id()));
|
||||
DisallowCodeDependencyChange no_dependency_change;
|
||||
DisallowJavascriptExecution no_js(isolate());
|
||||
DisallowJavascriptExecution no_js(compilation_info()->isolate());
|
||||
DCHECK(!compilation_info()->dependencies()->HasAborted());
|
||||
|
||||
// Delegate to the underlying implementation.
|
||||
@ -158,7 +146,7 @@ void CompilationJob::RecordUnoptimizedCompilationStats() const {
|
||||
code_size = compilation_info()->code()->SizeIncludingMetadata();
|
||||
}
|
||||
|
||||
Counters* counters = isolate()->counters();
|
||||
Counters* counters = compilation_info()->isolate()->counters();
|
||||
// TODO(4280): Rename counters from "baseline" to "unoptimized" eventually.
|
||||
counters->total_baseline_code_size()->Increment(code_size);
|
||||
counters->total_baseline_compile_count()->Increment(1);
|
||||
@ -191,10 +179,6 @@ void CompilationJob::RecordOptimizedCompilationStats() const {
|
||||
}
|
||||
}
|
||||
|
||||
Isolate* CompilationJob::isolate() const {
|
||||
return compilation_info()->isolate();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Local helper methods that make up the compilation pipeline.
|
||||
|
||||
|
@ -164,9 +164,8 @@ class V8_EXPORT_PRIVATE CompilationJob {
|
||||
kSucceeded,
|
||||
kFailed,
|
||||
};
|
||||
|
||||
CompilationJob(Isolate* isolate, ParseInfo* parse_info, CompilationInfo* info,
|
||||
const char* compiler_name,
|
||||
CompilationJob(uintptr_t stack_limit, ParseInfo* parse_info,
|
||||
CompilationInfo* compilation_info, const char* compiler_name,
|
||||
State initial_state = State::kReadyToPrepare);
|
||||
virtual ~CompilationJob() {}
|
||||
|
||||
@ -191,20 +190,12 @@ class V8_EXPORT_PRIVATE CompilationJob {
|
||||
void RecordOptimizedCompilationStats() const;
|
||||
void RecordUnoptimizedCompilationStats() const;
|
||||
|
||||
virtual bool can_execute_on_background_thread() const { return true; }
|
||||
|
||||
void set_stack_limit(uintptr_t stack_limit) { stack_limit_ = stack_limit; }
|
||||
uintptr_t stack_limit() const { return stack_limit_; }
|
||||
|
||||
bool executed_on_background_thread() const {
|
||||
DCHECK_IMPLIES(!can_execute_on_background_thread(),
|
||||
!executed_on_background_thread_);
|
||||
return executed_on_background_thread_;
|
||||
}
|
||||
State state() const { return state_; }
|
||||
ParseInfo* parse_info() const { return parse_info_; }
|
||||
CompilationInfo* compilation_info() const { return compilation_info_; }
|
||||
Isolate* isolate() const;
|
||||
virtual size_t AllocatedMemory() const { return 0; }
|
||||
|
||||
protected:
|
||||
@ -217,14 +208,12 @@ class V8_EXPORT_PRIVATE CompilationJob {
|
||||
// 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_;
|
||||
base::TimeDelta time_taken_to_finalize_;
|
||||
const char* compiler_name_;
|
||||
State state_;
|
||||
uintptr_t stack_limit_;
|
||||
bool executed_on_background_thread_;
|
||||
|
||||
MUST_USE_RESULT Status UpdateState(Status status, State next_state) {
|
||||
if (status == SUCCEEDED) {
|
||||
|
@ -737,12 +737,13 @@ 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(), parse_info, &compilation_info_,
|
||||
"TurboFan"),
|
||||
: CompilationJob(parse_info->stack_limit(), parse_info,
|
||||
&compilation_info_, "TurboFan"),
|
||||
isolate_(function->GetIsolate()),
|
||||
parse_info_(parse_info),
|
||||
zone_stats_(function->GetIsolate()->allocator()),
|
||||
compilation_info_(parse_info_.get()->zone(), function->GetIsolate(),
|
||||
shared_info, function),
|
||||
zone_stats_(isolate_->allocator()),
|
||||
compilation_info_(parse_info_.get()->zone(), isolate_, shared_info,
|
||||
function),
|
||||
pipeline_statistics_(CreatePipelineStatistics(
|
||||
parse_info_->script(), compilation_info(), &zone_stats_)),
|
||||
data_(&zone_stats_, compilation_info(), pipeline_statistics_.get()),
|
||||
@ -754,10 +755,13 @@ class PipelineCompilationJob final : public CompilationJob {
|
||||
Status ExecuteJobImpl() final;
|
||||
Status FinalizeJobImpl() final;
|
||||
|
||||
Isolate* isolate() { return isolate_; }
|
||||
|
||||
// Registers weak object to optimized code dependencies.
|
||||
void RegisterWeakObjectsInOptimizedCode(Handle<Code> code);
|
||||
|
||||
private:
|
||||
Isolate* isolate_;
|
||||
std::unique_ptr<ParseInfo> parse_info_;
|
||||
ZoneStats zone_stats_;
|
||||
CompilationInfo compilation_info_;
|
||||
@ -889,8 +893,8 @@ class PipelineWasmCompilationJob final : public CompilationJob {
|
||||
SourcePositionTable* source_positions,
|
||||
ZoneVector<trap_handler::ProtectedInstructionData>* protected_insts,
|
||||
bool asmjs_origin)
|
||||
: CompilationJob(info->isolate(), nullptr, info, "TurboFan",
|
||||
State::kReadyToExecute),
|
||||
: CompilationJob(info->isolate()->stack_guard()->real_climit(), nullptr,
|
||||
info, "TurboFan", State::kReadyToExecute),
|
||||
zone_stats_(info->isolate()->allocator()),
|
||||
pipeline_statistics_(CreatePipelineStatistics(Handle<Script>::null(),
|
||||
info, &zone_stats_)),
|
||||
|
@ -58,6 +58,12 @@ class InterpreterCompilationJob final : public CompilationJob {
|
||||
DISALLOW_COPY_AND_ASSIGN(TimerScope);
|
||||
};
|
||||
|
||||
bool executed_on_background_thread() {
|
||||
// TODO(rmcilroy): Fix once we create InterpreterCompilationJob on
|
||||
// background thread.
|
||||
return false;
|
||||
}
|
||||
|
||||
BytecodeGenerator* generator() { return &generator_; }
|
||||
|
||||
Zone zone_;
|
||||
@ -166,7 +172,8 @@ bool ShouldPrintBytecode(Handle<SharedFunctionInfo> shared) {
|
||||
InterpreterCompilationJob::InterpreterCompilationJob(ParseInfo* parse_info,
|
||||
FunctionLiteral* literal,
|
||||
Isolate* isolate)
|
||||
: CompilationJob(isolate, parse_info, &compilation_info_, "Ignition"),
|
||||
: CompilationJob(parse_info->stack_limit(), parse_info, &compilation_info_,
|
||||
"Ignition"),
|
||||
zone_(isolate->allocator(), ZONE_NAME),
|
||||
compilation_info_(&zone_, isolate, parse_info, literal),
|
||||
generator_(&compilation_info_),
|
||||
@ -207,8 +214,8 @@ InterpreterCompilationJob::Status InterpreterCompilationJob::FinalizeJobImpl() {
|
||||
!executed_on_background_thread() ? runtime_call_stats_ : nullptr,
|
||||
&RuntimeCallStats::CompileIgnitionFinalization);
|
||||
|
||||
Handle<BytecodeArray> bytecodes =
|
||||
generator()->FinalizeBytecode(isolate(), parse_info()->script());
|
||||
Handle<BytecodeArray> bytecodes = generator()->FinalizeBytecode(
|
||||
compilation_info()->isolate(), parse_info()->script());
|
||||
if (generator()->HasStackOverflow()) {
|
||||
return FAILED;
|
||||
}
|
||||
|
@ -26,7 +26,8 @@ namespace {
|
||||
class BlockingCompilationJob : public CompilationJob {
|
||||
public:
|
||||
BlockingCompilationJob(Isolate* isolate, Handle<JSFunction> function)
|
||||
: CompilationJob(isolate, &parse_info_, &info_, "BlockingCompilationJob",
|
||||
: CompilationJob(isolate->stack_guard()->real_climit(), &parse_info_,
|
||||
&info_, "BlockingCompilationJob",
|
||||
State::kReadyToExecute),
|
||||
shared_(function->shared()),
|
||||
parse_info_(shared_),
|
||||
|
Loading…
Reference in New Issue
Block a user