Commit 5a54000e authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[compiler] Rename OptimizingCompileJob to CompilationJob.

R=bmeurer@chromium.org

Review-Url: https://codereview.chromium.org/1925743002
Cr-Commit-Position: refs/heads/master@{#35832}
parent 82ffd160
......@@ -307,9 +307,9 @@ void CompilationInfo::PrintAstForTesting() {
#endif
// ----------------------------------------------------------------------------
// Implementation of OptimizedCompileJob
// Implementation of CompilationJob
OptimizedCompileJob::Status OptimizedCompileJob::CreateGraph() {
CompilationJob::Status CompilationJob::CreateGraph() {
DisallowJavascriptExecution no_js(isolate());
DCHECK(info()->IsOptimizing());
......@@ -327,8 +327,7 @@ OptimizedCompileJob::Status OptimizedCompileJob::CreateGraph() {
return SetLastStatus(CreateGraphImpl());
}
OptimizedCompileJob::Status OptimizedCompileJob::OptimizeGraph() {
CompilationJob::Status CompilationJob::OptimizeGraph() {
DisallowHeapAllocation no_allocation;
DisallowHandleAllocation no_handles;
DisallowHandleDereference no_deref;
......@@ -340,7 +339,7 @@ OptimizedCompileJob::Status OptimizedCompileJob::OptimizeGraph() {
return SetLastStatus(OptimizeGraphImpl());
}
OptimizedCompileJob::Status OptimizedCompileJob::GenerateCode() {
CompilationJob::Status CompilationJob::GenerateCode() {
DisallowCodeDependencyChange no_dependency_change;
DisallowJavascriptExecution no_js(isolate());
DCHECK(!info()->dependencies()->HasAborted());
......@@ -365,8 +364,7 @@ void AddWeakObjectToCodeDependency(Isolate* isolate, Handle<HeapObject> object,
} // namespace
void OptimizedCompileJob::RegisterWeakObjectsInOptimizedCode(
Handle<Code> code) {
void CompilationJob::RegisterWeakObjectsInOptimizedCode(Handle<Code> code) {
// TODO(turbofan): Move this to pipeline.cc once Crankshaft dies.
Isolate* const isolate = code->GetIsolate();
DCHECK(code->is_optimized_code());
......@@ -406,8 +404,7 @@ void OptimizedCompileJob::RegisterWeakObjectsInOptimizedCode(
code->set_can_have_weak_objects(true);
}
void OptimizedCompileJob::RecordOptimizationStats() {
void CompilationJob::RecordOptimizationStats() {
Handle<JSFunction> function = info()->closure();
if (!function->IsOptimized()) {
// Concurrent recompilation and OSR may race. Increment only once.
......@@ -699,7 +696,7 @@ bool UseTurboFan(CompilationInfo* info) {
passes_osr_test;
}
bool GetOptimizedCodeNow(OptimizedCompileJob* job) {
bool GetOptimizedCodeNow(CompilationJob* job) {
CompilationInfo* info = job->info();
Isolate* isolate = info->isolate();
......@@ -711,9 +708,9 @@ bool GetOptimizedCodeNow(OptimizedCompileJob* job) {
TimerEventScope<TimerEventRecompileSynchronous> timer(isolate);
TRACE_EVENT0("v8", "V8.RecompileSynchronous");
if (job->CreateGraph() != OptimizedCompileJob::SUCCEEDED ||
job->OptimizeGraph() != OptimizedCompileJob::SUCCEEDED ||
job->GenerateCode() != OptimizedCompileJob::SUCCEEDED) {
if (job->CreateGraph() != CompilationJob::SUCCEEDED ||
job->OptimizeGraph() != CompilationJob::SUCCEEDED ||
job->GenerateCode() != CompilationJob::SUCCEEDED) {
if (FLAG_trace_opt) {
PrintF("[aborted optimizing ");
info->closure()->ShortPrint();
......@@ -730,7 +727,7 @@ bool GetOptimizedCodeNow(OptimizedCompileJob* job) {
return true;
}
bool GetOptimizedCodeLater(OptimizedCompileJob* job) {
bool GetOptimizedCodeLater(CompilationJob* job) {
CompilationInfo* info = job->info();
Isolate* isolate = info->isolate();
......@@ -759,7 +756,7 @@ bool GetOptimizedCodeLater(OptimizedCompileJob* job) {
TimerEventScope<TimerEventRecompileSynchronous> timer(info->isolate());
TRACE_EVENT0("v8", "V8.RecompileSynchronous");
if (job->CreateGraph() != OptimizedCompileJob::SUCCEEDED) return false;
if (job->CreateGraph() != CompilationJob::SUCCEEDED) return false;
isolate->optimizing_compile_dispatcher()->QueueForOptimization(job);
if (FLAG_trace_concurrent_recompilation) {
......@@ -836,7 +833,7 @@ MaybeHandle<Code> GetOptimizedCode(Handle<JSFunction> function,
TRACE_EVENT0("v8", "V8.OptimizeCode");
bool use_turbofan = UseTurboFan(info.get());
base::SmartPointer<OptimizedCompileJob> job(
base::SmartPointer<CompilationJob> job(
use_turbofan ? compiler::Pipeline::NewCompilationJob(info.get())
: new HCompilationJob(info.get()));
......@@ -1720,7 +1717,7 @@ MaybeHandle<Code> Compiler::GetOptimizedCodeForOSR(Handle<JSFunction> function,
return GetOptimizedCode(function, NOT_CONCURRENT, osr_ast_id, osr_frame);
}
void Compiler::FinalizeOptimizedCompileJob(OptimizedCompileJob* job) {
void Compiler::FinalizeCompilationJob(CompilationJob* job) {
// Take ownership of compilation info. Deleting compilation info
// also tears down the zone.
base::SmartPointer<CompilationInfo> info(job->info());
......@@ -1740,12 +1737,12 @@ void Compiler::FinalizeOptimizedCompileJob(OptimizedCompileJob* job) {
// Except when OSR already disabled optimization for some reason.
// 3) The code may have already been invalidated due to dependency change.
// 4) Code generation may have failed.
if (job->last_status() == OptimizedCompileJob::SUCCEEDED) {
if (job->last_status() == CompilationJob::SUCCEEDED) {
if (shared->optimization_disabled()) {
job->RetryOptimization(kOptimizationDisabled);
} else if (info->dependencies()->HasAborted()) {
job->RetryOptimization(kBailedOutDueToDependencyChange);
} else if (job->GenerateCode() == OptimizedCompileJob::SUCCEEDED) {
} else if (job->GenerateCode() == CompilationJob::SUCCEEDED) {
job->RecordOptimizationStats();
RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info.get());
if (shared->SearchOptimizedCodeMap(info->context()->native_context(),
......@@ -1763,7 +1760,7 @@ void Compiler::FinalizeOptimizedCompileJob(OptimizedCompileJob* job) {
}
}
DCHECK(job->last_status() != OptimizedCompileJob::SUCCEEDED);
DCHECK(job->last_status() != CompilationJob::SUCCEEDED);
if (FLAG_trace_opt) {
PrintF("[aborted optimizing ");
info->closure()->ShortPrint();
......
......@@ -17,8 +17,8 @@ namespace internal {
// Forward declarations.
class CompilationInfo;
class CompilationJob;
class JavaScriptFrame;
class OptimizedCompileJob;
class ParseInfo;
class ScriptData;
......@@ -50,8 +50,8 @@ class Compiler : public AllStatic {
static bool CompileDebugCode(Handle<SharedFunctionInfo> shared);
static bool CompileForLiveEdit(Handle<Script> script);
// Generate and install code from previously queued optimization job.
static void FinalizeOptimizedCompileJob(OptimizedCompileJob* job);
// Generate and install code from previously queued compilation job.
static void FinalizeCompilationJob(CompilationJob* job);
// Give the compiler a chance to perform low-latency initialization tasks of
// the given {function} on its instantiation. Note that only the runtime will
......@@ -572,11 +572,11 @@ class CompilationInfo {
// succeed. Apart from their return value, the status of the phase last run can
// be checked using {last_status()} as well.
// TODO(mstarzinger): Make CompilationInfo base embedded.
class OptimizedCompileJob {
class CompilationJob {
public:
explicit OptimizedCompileJob(CompilationInfo* info, const char* compiler_name)
explicit CompilationJob(CompilationInfo* info, const char* compiler_name)
: info_(info), compiler_name_(compiler_name), last_status_(SUCCEEDED) {}
virtual ~OptimizedCompileJob() {}
virtual ~CompilationJob() {}
enum Status {
FAILED, BAILED_OUT, SUCCEEDED
......
......@@ -500,10 +500,10 @@ PipelineStatistics* CreatePipelineStatistics(CompilationInfo* info,
return pipeline_statistics;
}
class PipelineCompilationJob final : public OptimizedCompileJob {
class PipelineCompilationJob final : public CompilationJob {
public:
explicit PipelineCompilationJob(CompilationInfo* info)
: OptimizedCompileJob(info, "TurboFan"),
: CompilationJob(info, "TurboFan"),
zone_pool_(info->isolate()->allocator()),
pipeline_statistics_(CreatePipelineStatistics(info, &zone_pool_)),
data_(&zone_pool_, info, pipeline_statistics_.get()),
......@@ -572,12 +572,12 @@ PipelineCompilationJob::Status PipelineCompilationJob::GenerateCodeImpl() {
return SUCCEEDED;
}
class PipelineWasmCompilationJob final : public OptimizedCompileJob {
class PipelineWasmCompilationJob final : public CompilationJob {
public:
explicit PipelineWasmCompilationJob(CompilationInfo* info, Graph* graph,
CallDescriptor* descriptor,
SourcePositionTable* source_positions)
: OptimizedCompileJob(info, "TurboFan"),
: CompilationJob(info, "TurboFan"),
zone_pool_(info->isolate()->allocator()),
data_(&zone_pool_, info, graph, source_positions),
pipeline_(&data_),
......@@ -1461,12 +1461,12 @@ Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info,
}
// static
OptimizedCompileJob* Pipeline::NewCompilationJob(CompilationInfo* info) {
CompilationJob* Pipeline::NewCompilationJob(CompilationInfo* info) {
return new PipelineCompilationJob(info);
}
// static
OptimizedCompileJob* Pipeline::NewWasmCompilationJob(
CompilationJob* Pipeline::NewWasmCompilationJob(
CompilationInfo* info, Graph* graph, CallDescriptor* descriptor,
SourcePositionTable* source_positions) {
return new PipelineWasmCompilationJob(info, graph, descriptor,
......
......@@ -13,7 +13,7 @@ namespace v8 {
namespace internal {
class CompilationInfo;
class OptimizedCompileJob;
class CompilationJob;
class RegisterConfiguration;
namespace compiler {
......@@ -73,10 +73,10 @@ class Pipeline {
Schedule* schedule = nullptr);
// Returns a new compilation job for the given compilation info.
static OptimizedCompileJob* NewCompilationJob(CompilationInfo* info);
static CompilationJob* NewCompilationJob(CompilationInfo* info);
// Returns a new compilation job for the WebAssembly compilation info.
static OptimizedCompileJob* NewWasmCompilationJob(
static CompilationJob* NewWasmCompilationJob(
CompilationInfo* info, Graph* graph, CallDescriptor* descriptor,
SourcePositionTable* source_positions);
......
......@@ -2968,11 +2968,11 @@ Handle<Code> CompileWasmFunction(wasm::ErrorThrower& thrower, Isolate* isolate,
}
}
CompilationInfo info(func_name, isolate, jsgraph->graph()->zone(), flags);
base::SmartPointer<OptimizedCompileJob> job(Pipeline::NewWasmCompilationJob(
base::SmartPointer<CompilationJob> job(Pipeline::NewWasmCompilationJob(
&info, jsgraph->graph(), descriptor, source_positions));
Handle<Code> code = Handle<Code>::null();
if (job->OptimizeGraph() == OptimizedCompileJob::SUCCEEDED &&
job->GenerateCode() == OptimizedCompileJob::SUCCEEDED) {
if (job->OptimizeGraph() == CompilationJob::SUCCEEDED &&
job->GenerateCode() == CompilationJob::SUCCEEDED) {
code = info.code();
}
......
......@@ -30,12 +30,10 @@ class LAllocator;
class LChunk;
class LiveRange;
class HCompilationJob final : public OptimizedCompileJob {
class HCompilationJob final : public CompilationJob {
public:
explicit HCompilationJob(CompilationInfo* info)
: OptimizedCompileJob(info, "Crankshaft"),
graph_(nullptr),
chunk_(nullptr) {}
: CompilationJob(info, "Crankshaft"), graph_(nullptr), chunk_(nullptr) {}
protected:
virtual Status CreateGraphImpl();
......
......@@ -15,8 +15,7 @@ namespace internal {
namespace {
void DisposeOptimizedCompileJob(OptimizedCompileJob* job,
bool restore_function_code) {
void DisposeCompilationJob(CompilationJob* job, bool restore_function_code) {
// The recompile job is allocated in the CompilationInfo's zone.
CompilationInfo* info = job->info();
if (restore_function_code) {
......@@ -86,33 +85,30 @@ OptimizingCompileDispatcher::~OptimizingCompileDispatcher() {
DeleteArray(input_queue_);
}
OptimizedCompileJob* OptimizingCompileDispatcher::NextInput(
bool check_if_flushing) {
CompilationJob* OptimizingCompileDispatcher::NextInput(bool check_if_flushing) {
base::LockGuard<base::Mutex> access_input_queue_(&input_queue_mutex_);
if (input_queue_length_ == 0) return NULL;
OptimizedCompileJob* job = input_queue_[InputQueueIndex(0)];
CompilationJob* job = input_queue_[InputQueueIndex(0)];
DCHECK_NOT_NULL(job);
input_queue_shift_ = InputQueueIndex(1);
input_queue_length_--;
if (check_if_flushing) {
if (static_cast<ModeFlag>(base::Acquire_Load(&mode_)) == FLUSH) {
AllowHandleDereference allow_handle_dereference;
DisposeOptimizedCompileJob(job, true);
DisposeCompilationJob(job, true);
return NULL;
}
}
return job;
}
void OptimizingCompileDispatcher::CompileNext(OptimizedCompileJob* job) {
void OptimizingCompileDispatcher::CompileNext(CompilationJob* job) {
if (!job) return;
// The function may have already been optimized by OSR. Simply continue.
OptimizedCompileJob::Status status = job->OptimizeGraph();
CompilationJob::Status status = job->OptimizeGraph();
USE(status); // Prevent an unused-variable error in release mode.
DCHECK(status != OptimizedCompileJob::FAILED);
DCHECK(status != CompilationJob::FAILED);
// The function may have already been optimized by OSR. Simply continue.
// Use a mutex to make sure that functions marked for install
......@@ -125,7 +121,7 @@ void OptimizingCompileDispatcher::CompileNext(OptimizedCompileJob* job) {
void OptimizingCompileDispatcher::FlushOutputQueue(bool restore_function_code) {
for (;;) {
OptimizedCompileJob* job = NULL;
CompilationJob* job = NULL;
{
base::LockGuard<base::Mutex> access_output_queue_(&output_queue_mutex_);
if (output_queue_.empty()) return;
......@@ -133,7 +129,7 @@ void OptimizingCompileDispatcher::FlushOutputQueue(bool restore_function_code) {
output_queue_.pop();
}
DisposeOptimizedCompileJob(job, restore_function_code);
DisposeCompilationJob(job, restore_function_code);
}
}
......@@ -177,7 +173,7 @@ void OptimizingCompileDispatcher::InstallOptimizedFunctions() {
HandleScope handle_scope(isolate_);
for (;;) {
OptimizedCompileJob* job = NULL;
CompilationJob* job = NULL;
{
base::LockGuard<base::Mutex> access_output_queue_(&output_queue_mutex_);
if (output_queue_.empty()) return;
......@@ -192,16 +188,14 @@ void OptimizingCompileDispatcher::InstallOptimizedFunctions() {
function->ShortPrint();
PrintF(" as it has already been optimized.\n");
}
DisposeOptimizedCompileJob(job, false);
DisposeCompilationJob(job, false);
} else {
Compiler::FinalizeOptimizedCompileJob(job);
Compiler::FinalizeCompilationJob(job);
}
}
}
void OptimizingCompileDispatcher::QueueForOptimization(
OptimizedCompileJob* job) {
void OptimizingCompileDispatcher::QueueForOptimization(CompilationJob* job) {
DCHECK(IsQueueAvailable());
{
// Add job to the back of the input queue.
......
......@@ -17,8 +17,7 @@
namespace v8 {
namespace internal {
class HOptimizedGraphBuilder;
class OptimizedCompileJob;
class CompilationJob;
class SharedFunctionInfo;
class OptimizingCompileDispatcher {
......@@ -32,7 +31,7 @@ class OptimizingCompileDispatcher {
ref_count_(0),
recompilation_delay_(FLAG_concurrent_recompilation_delay) {
base::NoBarrier_Store(&mode_, static_cast<base::AtomicWord>(COMPILE));
input_queue_ = NewArray<OptimizedCompileJob*>(input_queue_capacity_);
input_queue_ = NewArray<CompilationJob*>(input_queue_capacity_);
}
~OptimizingCompileDispatcher();
......@@ -40,7 +39,7 @@ class OptimizingCompileDispatcher {
void Run();
void Stop();
void Flush();
void QueueForOptimization(OptimizedCompileJob* optimizing_compiler);
void QueueForOptimization(CompilationJob* job);
void Unblock();
void InstallOptimizedFunctions();
......@@ -57,8 +56,8 @@ class OptimizingCompileDispatcher {
enum ModeFlag { COMPILE, FLUSH };
void FlushOutputQueue(bool restore_function_code);
void CompileNext(OptimizedCompileJob* job);
OptimizedCompileJob* NextInput(bool check_if_flushing = false);
void CompileNext(CompilationJob* job);
CompilationJob* NextInput(bool check_if_flushing = false);
inline int InputQueueIndex(int i) {
int result = (i + input_queue_shift_) % input_queue_capacity_;
......@@ -70,14 +69,14 @@ class OptimizingCompileDispatcher {
Isolate* isolate_;
// Circular queue of incoming recompilation tasks (including OSR).
OptimizedCompileJob** input_queue_;
CompilationJob** input_queue_;
int input_queue_capacity_;
int input_queue_length_;
int input_queue_shift_;
base::Mutex input_queue_mutex_;
// Queue of recompilation tasks ready to be installed (excluding OSR).
std::queue<OptimizedCompileJob*> output_queue_;
std::queue<CompilationJob*> output_queue_;
// Used for job based recompilation which has multiple producers on
// different threads.
base::Mutex output_queue_mutex_;
......
......@@ -485,12 +485,11 @@ class WasmFunctionCompiler : public HandleAndZoneScope,
}
CompilationInfo info(debug_name_, this->isolate(), this->zone(),
Code::ComputeFlags(Code::WASM_FUNCTION));
v8::base::SmartPointer<OptimizedCompileJob> job(
Pipeline::NewWasmCompilationJob(&info, graph(), desc,
&source_position_table_));
v8::base::SmartPointer<CompilationJob> job(Pipeline::NewWasmCompilationJob(
&info, graph(), desc, &source_position_table_));
Handle<Code> code = Handle<Code>::null();
if (job->OptimizeGraph() == OptimizedCompileJob::SUCCEEDED &&
job->GenerateCode() == OptimizedCompileJob::SUCCEEDED) {
if (job->OptimizeGraph() == CompilationJob::SUCCEEDED &&
job->GenerateCode() == CompilationJob::SUCCEEDED) {
code = info.code();
}
#ifdef ENABLE_DISASSEMBLER
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment