[Compiler] Split up Unoptimized/Optimized CompilationInfo and CompilationJobs
With the Ignition + Turbofan pipeline there is very little overlap between the data needed for unoptimized compilation and optimized compilation. As a result, it is cleaner to split up the CompilationInfo into UnoptimizedCompilationInfo and OptimizedCompilationInfo. Doing so also necessitate splitting up CompilationJob into UnoptimizedCompilationJob and OptimizedCompilationJob - again there is not much overlap so this seems cleaner. Change-Id: I1056ad520937b7f8582e4fc3ca8f4910742de30a Reviewed-on: https://chromium-review.googlesource.com/995895 Commit-Queue: Ross McIlroy <rmcilroy@chromium.org> Reviewed-by: Leszek Swirski <leszeks@chromium.org> Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Cr-Commit-Position: refs/heads/master@{#52369}
This commit is contained in:
parent
f56e2a022f
commit
3a0419a635
6
BUILD.gn
6
BUILD.gn
@ -1440,8 +1440,6 @@ v8_source_set("v8_base") {
|
||||
"src/compilation-cache.h",
|
||||
"src/compilation-dependencies.cc",
|
||||
"src/compilation-dependencies.h",
|
||||
"src/compilation-info.cc",
|
||||
"src/compilation-info.h",
|
||||
"src/compilation-statistics.cc",
|
||||
"src/compilation-statistics.h",
|
||||
"src/compiler-dispatcher/compiler-dispatcher-job.cc",
|
||||
@ -1991,6 +1989,8 @@ v8_source_set("v8_base") {
|
||||
"src/objects/string.h",
|
||||
"src/objects/template-objects.cc",
|
||||
"src/objects/template-objects.h",
|
||||
"src/optimized-compilation-info.cc",
|
||||
"src/optimized-compilation-info.h",
|
||||
"src/ostreams.cc",
|
||||
"src/ostreams.h",
|
||||
"src/parsing/duplicate-finder.h",
|
||||
@ -2208,6 +2208,8 @@ v8_source_set("v8_base") {
|
||||
"src/unicode-inl.h",
|
||||
"src/unicode.cc",
|
||||
"src/unicode.h",
|
||||
"src/unoptimized-compilation-info.cc",
|
||||
"src/unoptimized-compilation-info.h",
|
||||
"src/uri.cc",
|
||||
"src/uri.h",
|
||||
"src/utils-inl.h",
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "src/ast/ast.h"
|
||||
#include "src/base/optional.h"
|
||||
#include "src/base/platform/elapsed-timer.h"
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler.h"
|
||||
#include "src/execution.h"
|
||||
#include "src/factory.h"
|
||||
@ -20,6 +19,7 @@
|
||||
#include "src/parsing/parse-info.h"
|
||||
#include "src/parsing/scanner-character-streams.h"
|
||||
#include "src/parsing/scanner.h"
|
||||
#include "src/unoptimized-compilation-info.h"
|
||||
|
||||
#include "src/wasm/wasm-engine.h"
|
||||
#include "src/wasm/wasm-js.h"
|
||||
@ -184,12 +184,12 @@ void ReportInstantiationFailure(Handle<Script> script, int position,
|
||||
// [2] FinalizeJobImpl: The module is handed to WebAssembly which decodes it
|
||||
// into an internal representation and eventually compiles it to machine
|
||||
// code.
|
||||
class AsmJsCompilationJob final : public CompilationJob {
|
||||
class AsmJsCompilationJob final : public UnoptimizedCompilationJob {
|
||||
public:
|
||||
explicit AsmJsCompilationJob(ParseInfo* parse_info, FunctionLiteral* literal,
|
||||
AccountingAllocator* allocator)
|
||||
: CompilationJob(parse_info->stack_limit(), parse_info,
|
||||
&compilation_info_, "AsmJs", State::kReadyToExecute),
|
||||
: UnoptimizedCompilationJob(parse_info->stack_limit(), parse_info,
|
||||
&compilation_info_),
|
||||
allocator_(allocator),
|
||||
zone_(allocator, ZONE_NAME),
|
||||
compilation_info_(&zone_, parse_info, literal),
|
||||
@ -202,16 +202,16 @@ class AsmJsCompilationJob final : public CompilationJob {
|
||||
translate_zone_size_(0) {}
|
||||
|
||||
protected:
|
||||
Status PrepareJobImpl(Isolate* isolate) final;
|
||||
Status ExecuteJobImpl() final;
|
||||
Status FinalizeJobImpl(Isolate* isolate) final;
|
||||
Status FinalizeJobImpl(Handle<SharedFunctionInfo> shared_info,
|
||||
Isolate* isolate) final;
|
||||
|
||||
private:
|
||||
void RecordHistograms(Isolate* isolate);
|
||||
|
||||
AccountingAllocator* allocator_;
|
||||
Zone zone_;
|
||||
CompilationInfo compilation_info_;
|
||||
UnoptimizedCompilationInfo compilation_info_;
|
||||
wasm::ZoneBuffer* module_;
|
||||
wasm::ZoneBuffer* asm_offsets_;
|
||||
wasm::AsmJsParser::StdlibSet stdlib_uses_;
|
||||
@ -225,12 +225,7 @@ class AsmJsCompilationJob final : public CompilationJob {
|
||||
DISALLOW_COPY_AND_ASSIGN(AsmJsCompilationJob);
|
||||
};
|
||||
|
||||
CompilationJob::Status AsmJsCompilationJob::PrepareJobImpl(Isolate* isolate) {
|
||||
UNREACHABLE(); // Prepare should always be skipped.
|
||||
return SUCCEEDED;
|
||||
}
|
||||
|
||||
CompilationJob::Status AsmJsCompilationJob::ExecuteJobImpl() {
|
||||
UnoptimizedCompilationJob::Status AsmJsCompilationJob::ExecuteJobImpl() {
|
||||
// Step 1: Translate asm.js module to WebAssembly module.
|
||||
size_t compile_zone_start = compilation_info()->zone()->allocation_size();
|
||||
base::ElapsedTimer translate_timer;
|
||||
@ -275,7 +270,8 @@ CompilationJob::Status AsmJsCompilationJob::ExecuteJobImpl() {
|
||||
return SUCCEEDED;
|
||||
}
|
||||
|
||||
CompilationJob::Status AsmJsCompilationJob::FinalizeJobImpl(Isolate* isolate) {
|
||||
UnoptimizedCompilationJob::Status AsmJsCompilationJob::FinalizeJobImpl(
|
||||
Handle<SharedFunctionInfo> shared_info, Isolate* isolate) {
|
||||
// Step 2: Compile and decode the WebAssembly module.
|
||||
base::ElapsedTimer compile_timer;
|
||||
compile_timer.Start();
|
||||
@ -327,9 +323,9 @@ void AsmJsCompilationJob::RecordHistograms(Isolate* isolate) {
|
||||
translation_throughput);
|
||||
}
|
||||
|
||||
CompilationJob* AsmJs::NewCompilationJob(ParseInfo* parse_info,
|
||||
FunctionLiteral* literal,
|
||||
AccountingAllocator* allocator) {
|
||||
UnoptimizedCompilationJob* AsmJs::NewCompilationJob(
|
||||
ParseInfo* parse_info, FunctionLiteral* literal,
|
||||
AccountingAllocator* allocator) {
|
||||
return new AsmJsCompilationJob(parse_info, literal, allocator);
|
||||
}
|
||||
|
||||
|
@ -13,19 +13,18 @@ namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
class AccountingAllocator;
|
||||
class CompilationInfo;
|
||||
class CompilationJob;
|
||||
class FunctionLiteral;
|
||||
class JSArrayBuffer;
|
||||
class ParseInfo;
|
||||
class SharedFunctionInfo;
|
||||
class UnoptimizedCompilationJob;
|
||||
|
||||
// Interface to compile and instantiate for asm.js modules.
|
||||
class AsmJs {
|
||||
public:
|
||||
static CompilationJob* NewCompilationJob(ParseInfo* parse_info,
|
||||
FunctionLiteral* literal,
|
||||
AccountingAllocator* allocator);
|
||||
static UnoptimizedCompilationJob* NewCompilationJob(
|
||||
ParseInfo* parse_info, FunctionLiteral* literal,
|
||||
AccountingAllocator* allocator);
|
||||
static MaybeHandle<Object> InstantiateAsmWasm(Isolate* isolate,
|
||||
Handle<SharedFunctionInfo>,
|
||||
Handle<FixedArray> wasm_data,
|
||||
|
@ -14,7 +14,7 @@
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
class CompilationInfo;
|
||||
class OptimizedCompilationInfo;
|
||||
class CompilationStatistics;
|
||||
|
||||
struct AsPrintableStatistics {
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "src/base/platform/time.h"
|
||||
#include "src/base/template-utils.h"
|
||||
#include "src/cancelable-task.h"
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler-dispatcher/compiler-dispatcher-job.h"
|
||||
#include "src/compiler-dispatcher/compiler-dispatcher-tracer.h"
|
||||
#include "src/compiler-dispatcher/unoptimized-compile-job.h"
|
||||
|
@ -7,10 +7,10 @@
|
||||
#include "src/base/atomicops.h"
|
||||
#include "src/base/template-utils.h"
|
||||
#include "src/cancelable-task.h"
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler.h"
|
||||
#include "src/isolate.h"
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
#include "src/tracing/trace-event.h"
|
||||
#include "src/v8.h"
|
||||
|
||||
@ -19,7 +19,8 @@ namespace internal {
|
||||
|
||||
namespace {
|
||||
|
||||
void DisposeCompilationJob(CompilationJob* job, bool restore_function_code) {
|
||||
void DisposeCompilationJob(OptimizedCompilationJob* job,
|
||||
bool restore_function_code) {
|
||||
if (restore_function_code) {
|
||||
Handle<JSFunction> function = job->compilation_info()->closure();
|
||||
function->set_code(function->shared()->GetCode());
|
||||
@ -92,10 +93,11 @@ OptimizingCompileDispatcher::~OptimizingCompileDispatcher() {
|
||||
DeleteArray(input_queue_);
|
||||
}
|
||||
|
||||
CompilationJob* OptimizingCompileDispatcher::NextInput(bool check_if_flushing) {
|
||||
OptimizedCompilationJob* OptimizingCompileDispatcher::NextInput(
|
||||
bool check_if_flushing) {
|
||||
base::LockGuard<base::Mutex> access_input_queue_(&input_queue_mutex_);
|
||||
if (input_queue_length_ == 0) return nullptr;
|
||||
CompilationJob* job = input_queue_[InputQueueIndex(0)];
|
||||
OptimizedCompilationJob* job = input_queue_[InputQueueIndex(0)];
|
||||
DCHECK_NOT_NULL(job);
|
||||
input_queue_shift_ = InputQueueIndex(1);
|
||||
input_queue_length_--;
|
||||
@ -109,7 +111,7 @@ CompilationJob* OptimizingCompileDispatcher::NextInput(bool check_if_flushing) {
|
||||
return job;
|
||||
}
|
||||
|
||||
void OptimizingCompileDispatcher::CompileNext(CompilationJob* job) {
|
||||
void OptimizingCompileDispatcher::CompileNext(OptimizedCompilationJob* job) {
|
||||
if (!job) return;
|
||||
|
||||
// The function may have already been optimized by OSR. Simply continue.
|
||||
@ -126,7 +128,7 @@ void OptimizingCompileDispatcher::CompileNext(CompilationJob* job) {
|
||||
|
||||
void OptimizingCompileDispatcher::FlushOutputQueue(bool restore_function_code) {
|
||||
for (;;) {
|
||||
CompilationJob* job = nullptr;
|
||||
OptimizedCompilationJob* job = nullptr;
|
||||
{
|
||||
base::LockGuard<base::Mutex> access_output_queue_(&output_queue_mutex_);
|
||||
if (output_queue_.empty()) return;
|
||||
@ -143,7 +145,7 @@ void OptimizingCompileDispatcher::Flush(BlockingBehavior blocking_behavior) {
|
||||
if (FLAG_block_concurrent_recompilation) Unblock();
|
||||
base::LockGuard<base::Mutex> access_input_queue_(&input_queue_mutex_);
|
||||
while (input_queue_length_ > 0) {
|
||||
CompilationJob* job = input_queue_[InputQueueIndex(0)];
|
||||
OptimizedCompilationJob* job = input_queue_[InputQueueIndex(0)];
|
||||
DCHECK_NOT_NULL(job);
|
||||
input_queue_shift_ = InputQueueIndex(1);
|
||||
input_queue_length_--;
|
||||
@ -191,14 +193,14 @@ void OptimizingCompileDispatcher::InstallOptimizedFunctions() {
|
||||
HandleScope handle_scope(isolate_);
|
||||
|
||||
for (;;) {
|
||||
CompilationJob* job = nullptr;
|
||||
OptimizedCompilationJob* job = nullptr;
|
||||
{
|
||||
base::LockGuard<base::Mutex> access_output_queue_(&output_queue_mutex_);
|
||||
if (output_queue_.empty()) return;
|
||||
job = output_queue_.front();
|
||||
output_queue_.pop();
|
||||
}
|
||||
CompilationInfo* info = job->compilation_info();
|
||||
OptimizedCompilationInfo* info = job->compilation_info();
|
||||
Handle<JSFunction> function(*info->closure());
|
||||
if (function->HasOptimizedCode()) {
|
||||
if (FLAG_trace_concurrent_recompilation) {
|
||||
@ -213,7 +215,8 @@ void OptimizingCompileDispatcher::InstallOptimizedFunctions() {
|
||||
}
|
||||
}
|
||||
|
||||
void OptimizingCompileDispatcher::QueueForOptimization(CompilationJob* job) {
|
||||
void OptimizingCompileDispatcher::QueueForOptimization(
|
||||
OptimizedCompilationJob* job) {
|
||||
DCHECK(IsQueueAvailable());
|
||||
{
|
||||
// Add job to the back of the input queue.
|
||||
|
@ -18,7 +18,7 @@
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
class CompilationJob;
|
||||
class OptimizedCompilationJob;
|
||||
class SharedFunctionInfo;
|
||||
|
||||
class V8_EXPORT_PRIVATE OptimizingCompileDispatcher {
|
||||
@ -32,7 +32,7 @@ class V8_EXPORT_PRIVATE OptimizingCompileDispatcher {
|
||||
ref_count_(0),
|
||||
recompilation_delay_(FLAG_concurrent_recompilation_delay) {
|
||||
base::Relaxed_Store(&mode_, static_cast<base::AtomicWord>(COMPILE));
|
||||
input_queue_ = NewArray<CompilationJob*>(input_queue_capacity_);
|
||||
input_queue_ = NewArray<OptimizedCompilationJob*>(input_queue_capacity_);
|
||||
}
|
||||
|
||||
~OptimizingCompileDispatcher();
|
||||
@ -40,7 +40,7 @@ class V8_EXPORT_PRIVATE OptimizingCompileDispatcher {
|
||||
void Stop();
|
||||
void Flush(BlockingBehavior blocking_behavior);
|
||||
// Takes ownership of |job|.
|
||||
void QueueForOptimization(CompilationJob* job);
|
||||
void QueueForOptimization(OptimizedCompilationJob* job);
|
||||
void Unblock();
|
||||
void InstallOptimizedFunctions();
|
||||
|
||||
@ -57,8 +57,8 @@ class V8_EXPORT_PRIVATE OptimizingCompileDispatcher {
|
||||
enum ModeFlag { COMPILE, FLUSH };
|
||||
|
||||
void FlushOutputQueue(bool restore_function_code);
|
||||
void CompileNext(CompilationJob* job);
|
||||
CompilationJob* NextInput(bool check_if_flushing = false);
|
||||
void CompileNext(OptimizedCompilationJob* job);
|
||||
OptimizedCompilationJob* NextInput(bool check_if_flushing = false);
|
||||
|
||||
inline int InputQueueIndex(int i) {
|
||||
int result = (i + input_queue_shift_) % input_queue_capacity_;
|
||||
@ -70,14 +70,14 @@ class V8_EXPORT_PRIVATE OptimizingCompileDispatcher {
|
||||
Isolate* isolate_;
|
||||
|
||||
// Circular queue of incoming recompilation tasks (including OSR).
|
||||
CompilationJob** input_queue_;
|
||||
OptimizedCompilationJob** 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<CompilationJob*> output_queue_;
|
||||
std::queue<OptimizedCompilationJob*> output_queue_;
|
||||
// Used for job based recompilation which has multiple producers on
|
||||
// different threads.
|
||||
base::Mutex output_queue_mutex_;
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include "src/assert-scope.h"
|
||||
#include "src/base/optional.h"
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler-dispatcher/compiler-dispatcher-tracer.h"
|
||||
#include "src/compiler.h"
|
||||
#include "src/flags.h"
|
||||
@ -18,6 +17,7 @@
|
||||
#include "src/parsing/parser.h"
|
||||
#include "src/parsing/scanner-character-streams.h"
|
||||
#include "src/unicode-cache.h"
|
||||
#include "src/unoptimized-compilation-info.h"
|
||||
#include "src/utils.h"
|
||||
|
||||
namespace v8 {
|
||||
@ -292,9 +292,8 @@ void UnoptimizedCompileJob::FinalizeOnMainThread(Isolate* isolate) {
|
||||
// Allocate scope infos for the literal.
|
||||
DeclarationScope::AllocateScopeInfos(parse_info_.get(), isolate,
|
||||
AnalyzeMode::kRegular);
|
||||
compilation_job_->compilation_info()->set_shared_info(shared_);
|
||||
if (compilation_job_->state() == CompilationJob::State::kFailed ||
|
||||
!Compiler::FinalizeCompilationJob(compilation_job_.release(),
|
||||
!Compiler::FinalizeCompilationJob(compilation_job_.release(), shared_,
|
||||
isolate)) {
|
||||
if (!isolate->has_pending_exception()) isolate->StackOverflow();
|
||||
set_status(Status::kFailed);
|
||||
|
@ -18,8 +18,6 @@ namespace internal {
|
||||
class AstValueFactory;
|
||||
class AstStringConstants;
|
||||
class CompilerDispatcherTracer;
|
||||
class CompilationInfo;
|
||||
class CompilationJob;
|
||||
class DeferredHandles;
|
||||
class FunctionLiteral;
|
||||
class Isolate;
|
||||
@ -28,6 +26,7 @@ class Parser;
|
||||
class SharedFunctionInfo;
|
||||
class String;
|
||||
class UnicodeCache;
|
||||
class UnoptimizedCompilationJob;
|
||||
class Utf16CharacterStream;
|
||||
|
||||
class V8_EXPORT_PRIVATE UnoptimizedCompileJob : public CompilerDispatcherJob {
|
||||
@ -77,7 +76,7 @@ class V8_EXPORT_PRIVATE UnoptimizedCompileJob : public CompilerDispatcherJob {
|
||||
std::unique_ptr<Parser> parser_;
|
||||
|
||||
// Members required for compiling.
|
||||
std::unique_ptr<CompilationJob> compilation_job_;
|
||||
std::unique_ptr<UnoptimizedCompilationJob> compilation_job_;
|
||||
|
||||
bool trace_compiler_dispatcher_jobs_;
|
||||
|
||||
|
427
src/compiler.cc
427
src/compiler.cc
@ -15,7 +15,6 @@
|
||||
#include "src/base/optional.h"
|
||||
#include "src/bootstrapper.h"
|
||||
#include "src/compilation-cache.h"
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler-dispatcher/compiler-dispatcher.h"
|
||||
#include "src/compiler-dispatcher/optimizing-compile-dispatcher.h"
|
||||
#include "src/compiler/pipeline.h"
|
||||
@ -29,6 +28,7 @@
|
||||
#include "src/log-inl.h"
|
||||
#include "src/messages.h"
|
||||
#include "src/objects/map.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
#include "src/parsing/parse-info.h"
|
||||
#include "src/parsing/parser.h"
|
||||
#include "src/parsing/parsing.h"
|
||||
@ -37,23 +37,25 @@
|
||||
#include "src/runtime-profiler.h"
|
||||
#include "src/snapshot/code-serializer.h"
|
||||
#include "src/unicode-cache.h"
|
||||
#include "src/unoptimized-compilation-info.h"
|
||||
#include "src/vm-state-inl.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
// A wrapper around a CompilationInfo that detaches the Handles from
|
||||
// A wrapper around a OptimizedCompilationInfo that detaches the Handles from
|
||||
// the underlying DeferredHandleScope and stores them in info_ on
|
||||
// destruction.
|
||||
class CompilationHandleScope final {
|
||||
public:
|
||||
explicit CompilationHandleScope(Isolate* isolate, CompilationInfo* info)
|
||||
explicit CompilationHandleScope(Isolate* isolate,
|
||||
OptimizedCompilationInfo* info)
|
||||
: deferred_(isolate), info_(info) {}
|
||||
~CompilationHandleScope() { info_->set_deferred_handles(deferred_.Detach()); }
|
||||
|
||||
private:
|
||||
DeferredHandleScope deferred_;
|
||||
CompilationInfo* info_;
|
||||
OptimizedCompilationInfo* info_;
|
||||
};
|
||||
|
||||
// Helper that times a scoped region and records the elapsed time.
|
||||
@ -69,19 +71,128 @@ struct ScopedTimer {
|
||||
base::TimeDelta* location_;
|
||||
};
|
||||
|
||||
namespace {
|
||||
|
||||
void LogFunctionCompilation(CodeEventListener::LogEventsAndTags tag,
|
||||
Handle<SharedFunctionInfo> shared,
|
||||
Handle<Script> script,
|
||||
Handle<AbstractCode> abstract_code, bool optimizing,
|
||||
double time_taken_ms, Isolate* isolate) {
|
||||
DCHECK(!abstract_code.is_null());
|
||||
DCHECK(!abstract_code.is_identical_to(BUILTIN_CODE(isolate, CompileLazy)));
|
||||
|
||||
// Log the code generation. If source information is available include
|
||||
// script name and line number. Check explicitly whether logging is
|
||||
// enabled as finding the line number is not free.
|
||||
if (!isolate->logger()->is_logging_code_events() &&
|
||||
!isolate->is_profiling() && !FLAG_log_function_events) {
|
||||
return;
|
||||
}
|
||||
|
||||
int line_num = Script::GetLineNumber(script, shared->StartPosition()) + 1;
|
||||
int column_num = Script::GetColumnNumber(script, shared->StartPosition()) + 1;
|
||||
String* script_name = script->name()->IsString()
|
||||
? String::cast(script->name())
|
||||
: isolate->heap()->empty_string();
|
||||
CodeEventListener::LogEventsAndTags log_tag =
|
||||
Logger::ToNativeByScript(tag, *script);
|
||||
PROFILE(isolate, CodeCreateEvent(log_tag, *abstract_code, *shared,
|
||||
script_name, line_num, column_num));
|
||||
if (!FLAG_log_function_events) return;
|
||||
|
||||
DisallowHeapAllocation no_gc;
|
||||
|
||||
std::string name = optimizing ? "optimize" : "compile";
|
||||
switch (tag) {
|
||||
case CodeEventListener::EVAL_TAG:
|
||||
name += "-eval";
|
||||
break;
|
||||
case CodeEventListener::SCRIPT_TAG:
|
||||
break;
|
||||
case CodeEventListener::LAZY_COMPILE_TAG:
|
||||
name += "-lazy";
|
||||
break;
|
||||
case CodeEventListener::FUNCTION_TAG:
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
LOG(isolate, FunctionEvent(name.c_str(), nullptr, script->id(), time_taken_ms,
|
||||
shared->StartPosition(), shared->EndPosition(),
|
||||
shared->DebugName()));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Implementation of CompilationJob
|
||||
// Implementation of UnoptimizedCompilationJob
|
||||
|
||||
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),
|
||||
compiler_name_(compiler_name),
|
||||
state_(initial_state),
|
||||
stack_limit_(stack_limit) {}
|
||||
CompilationJob::Status UnoptimizedCompilationJob::ExecuteJob() {
|
||||
DisallowHeapAllocation no_allocation;
|
||||
DisallowHandleAllocation no_handles;
|
||||
DisallowHandleDereference no_deref;
|
||||
DisallowCodeDependencyChange no_dependency_change;
|
||||
|
||||
CompilationJob::Status CompilationJob::PrepareJob(Isolate* isolate) {
|
||||
// Delegate to the underlying implementation.
|
||||
DCHECK_EQ(state(), State::kReadyToExecute);
|
||||
ScopedTimer t(&time_taken_to_execute_);
|
||||
return UpdateState(ExecuteJobImpl(), State::kReadyToFinalize);
|
||||
}
|
||||
|
||||
CompilationJob::Status UnoptimizedCompilationJob::FinalizeJob(
|
||||
Handle<SharedFunctionInfo> shared_info, Isolate* isolate) {
|
||||
DCHECK(ThreadId::Current().Equals(isolate->thread_id()));
|
||||
DisallowCodeDependencyChange no_dependency_change;
|
||||
DisallowJavascriptExecution no_js(isolate);
|
||||
|
||||
// Delegate to the underlying implementation.
|
||||
DCHECK_EQ(state(), State::kReadyToFinalize);
|
||||
ScopedTimer t(&time_taken_to_finalize_);
|
||||
return UpdateState(FinalizeJobImpl(shared_info, isolate), State::kSucceeded);
|
||||
}
|
||||
|
||||
void UnoptimizedCompilationJob::RecordCompilationStats(Isolate* isolate) const {
|
||||
int code_size;
|
||||
if (compilation_info()->has_bytecode_array()) {
|
||||
code_size = compilation_info()->bytecode_array()->SizeIncludingMetadata();
|
||||
} else {
|
||||
DCHECK(compilation_info()->has_asm_wasm_data());
|
||||
code_size = compilation_info()->asm_wasm_data()->Size();
|
||||
}
|
||||
|
||||
Counters* counters = 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);
|
||||
|
||||
// TODO(5203): Add timers for each phase of compilation.
|
||||
}
|
||||
|
||||
void UnoptimizedCompilationJob::RecordFunctionCompilation(
|
||||
CodeEventListener::LogEventsAndTags tag, Handle<SharedFunctionInfo> shared,
|
||||
Isolate* isolate) const {
|
||||
Handle<AbstractCode> abstract_code;
|
||||
if (compilation_info()->has_bytecode_array()) {
|
||||
abstract_code =
|
||||
Handle<AbstractCode>::cast(compilation_info()->bytecode_array());
|
||||
} else {
|
||||
DCHECK(compilation_info()->has_asm_wasm_data());
|
||||
abstract_code =
|
||||
Handle<AbstractCode>::cast(BUILTIN_CODE(isolate, InstantiateAsmJs));
|
||||
}
|
||||
|
||||
double time_taken_ms = time_taken_to_execute_.InMillisecondsF() +
|
||||
time_taken_to_finalize_.InMillisecondsF();
|
||||
|
||||
LogFunctionCompilation(tag, shared, parse_info()->script(), abstract_code,
|
||||
false, time_taken_ms, isolate);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// Implementation of OptimizedCompilationJob
|
||||
|
||||
CompilationJob::Status OptimizedCompilationJob::PrepareJob(Isolate* isolate) {
|
||||
DCHECK(ThreadId::Current().Equals(isolate->thread_id()));
|
||||
DisallowJavascriptExecution no_js(isolate);
|
||||
|
||||
@ -99,7 +210,7 @@ CompilationJob::Status CompilationJob::PrepareJob(Isolate* isolate) {
|
||||
return UpdateState(PrepareJobImpl(isolate), State::kReadyToExecute);
|
||||
}
|
||||
|
||||
CompilationJob::Status CompilationJob::ExecuteJob() {
|
||||
CompilationJob::Status OptimizedCompilationJob::ExecuteJob() {
|
||||
DisallowHeapAllocation no_allocation;
|
||||
DisallowHandleAllocation no_handles;
|
||||
DisallowHandleDereference no_deref;
|
||||
@ -111,7 +222,7 @@ CompilationJob::Status CompilationJob::ExecuteJob() {
|
||||
return UpdateState(ExecuteJobImpl(), State::kReadyToFinalize);
|
||||
}
|
||||
|
||||
CompilationJob::Status CompilationJob::FinalizeJob(Isolate* isolate) {
|
||||
CompilationJob::Status OptimizedCompilationJob::FinalizeJob(Isolate* isolate) {
|
||||
DCHECK(ThreadId::Current().Equals(isolate->thread_id()));
|
||||
DisallowCodeDependencyChange no_dependency_change;
|
||||
DisallowJavascriptExecution no_js(isolate);
|
||||
@ -124,38 +235,21 @@ CompilationJob::Status CompilationJob::FinalizeJob(Isolate* isolate) {
|
||||
return UpdateState(FinalizeJobImpl(isolate), State::kSucceeded);
|
||||
}
|
||||
|
||||
CompilationJob::Status CompilationJob::RetryOptimization(BailoutReason reason) {
|
||||
CompilationJob::Status OptimizedCompilationJob::RetryOptimization(
|
||||
BailoutReason reason) {
|
||||
DCHECK(compilation_info_->IsOptimizing());
|
||||
compilation_info_->RetryOptimization(reason);
|
||||
state_ = State::kFailed;
|
||||
return FAILED;
|
||||
return UpdateState(FAILED, State::kFailed);
|
||||
}
|
||||
|
||||
CompilationJob::Status CompilationJob::AbortOptimization(BailoutReason reason) {
|
||||
CompilationJob::Status OptimizedCompilationJob::AbortOptimization(
|
||||
BailoutReason reason) {
|
||||
DCHECK(compilation_info_->IsOptimizing());
|
||||
compilation_info_->AbortOptimization(reason);
|
||||
state_ = State::kFailed;
|
||||
return FAILED;
|
||||
return UpdateState(FAILED, State::kFailed);
|
||||
}
|
||||
|
||||
void CompilationJob::RecordUnoptimizedCompilationStats(Isolate* isolate) const {
|
||||
int code_size;
|
||||
if (compilation_info()->has_bytecode_array()) {
|
||||
code_size = compilation_info()->bytecode_array()->SizeIncludingMetadata();
|
||||
} else {
|
||||
DCHECK(compilation_info()->has_asm_wasm_data());
|
||||
code_size = compilation_info()->asm_wasm_data()->Size();
|
||||
}
|
||||
|
||||
Counters* counters = 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);
|
||||
|
||||
// TODO(5203): Add timers for each phase of compilation.
|
||||
}
|
||||
|
||||
void CompilationJob::RecordOptimizedCompilationStats() const {
|
||||
void OptimizedCompilationJob::RecordCompilationStats() const {
|
||||
DCHECK(compilation_info()->IsOptimizing());
|
||||
Handle<JSFunction> function = compilation_info()->closure();
|
||||
double ms_creategraph = time_taken_to_prepare_.InMillisecondsF();
|
||||
@ -180,71 +274,18 @@ void CompilationJob::RecordOptimizedCompilationStats() const {
|
||||
}
|
||||
}
|
||||
|
||||
void CompilationJob::RecordFunctionCompilation(
|
||||
void OptimizedCompilationJob::RecordFunctionCompilation(
|
||||
CodeEventListener::LogEventsAndTags tag, Isolate* isolate) const {
|
||||
// Log the code generation. If source information is available include
|
||||
// script name and line number. Check explicitly whether logging is
|
||||
// enabled as finding the line number is not free.
|
||||
CompilationInfo* compilation_info = this->compilation_info();
|
||||
if (!isolate->logger()->is_logging_code_events() &&
|
||||
!isolate->is_profiling() && !FLAG_log_function_events) {
|
||||
return;
|
||||
}
|
||||
Handle<AbstractCode> abstract_code =
|
||||
Handle<AbstractCode>::cast(compilation_info()->code());
|
||||
|
||||
Handle<SharedFunctionInfo> shared = compilation_info->shared_info();
|
||||
Handle<Script> script = parse_info()->script();
|
||||
Handle<AbstractCode> abstract_code;
|
||||
if (compilation_info->has_bytecode_array()) {
|
||||
abstract_code =
|
||||
Handle<AbstractCode>::cast(compilation_info->bytecode_array());
|
||||
} else if (compilation_info->has_asm_wasm_data()) {
|
||||
abstract_code =
|
||||
Handle<AbstractCode>::cast(BUILTIN_CODE(isolate, InstantiateAsmJs));
|
||||
} else {
|
||||
DCHECK(!compilation_info->code().is_null());
|
||||
abstract_code = Handle<AbstractCode>::cast(compilation_info->code());
|
||||
}
|
||||
double time_taken_ms = time_taken_to_prepare_.InMillisecondsF() +
|
||||
time_taken_to_execute_.InMillisecondsF() +
|
||||
time_taken_to_finalize_.InMillisecondsF();
|
||||
|
||||
if (abstract_code.is_identical_to(BUILTIN_CODE(isolate, CompileLazy))) {
|
||||
return;
|
||||
}
|
||||
|
||||
int line_num = Script::GetLineNumber(script, shared->StartPosition()) + 1;
|
||||
int column_num = Script::GetColumnNumber(script, shared->StartPosition()) + 1;
|
||||
String* script_name = script->name()->IsString()
|
||||
? String::cast(script->name())
|
||||
: isolate->heap()->empty_string();
|
||||
CodeEventListener::LogEventsAndTags log_tag =
|
||||
Logger::ToNativeByScript(tag, *script);
|
||||
PROFILE(isolate, CodeCreateEvent(log_tag, *abstract_code, *shared,
|
||||
script_name, line_num, column_num));
|
||||
if (!FLAG_log_function_events) return;
|
||||
|
||||
DisallowHeapAllocation no_gc;
|
||||
|
||||
double ms = time_taken_to_prepare_.InMillisecondsF();
|
||||
ms += time_taken_to_execute_.InMillisecondsF();
|
||||
ms += time_taken_to_finalize_.InMillisecondsF();
|
||||
|
||||
std::string name = compilation_info->IsOptimizing() ? "optimize" : "compile";
|
||||
switch (tag) {
|
||||
case CodeEventListener::EVAL_TAG:
|
||||
name += "-eval";
|
||||
break;
|
||||
case CodeEventListener::SCRIPT_TAG:
|
||||
break;
|
||||
case CodeEventListener::LAZY_COMPILE_TAG:
|
||||
name += "-lazy";
|
||||
break;
|
||||
case CodeEventListener::FUNCTION_TAG:
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
LOG(isolate, FunctionEvent(name.c_str(), nullptr, script->id(), ms,
|
||||
shared->StartPosition(), shared->EndPosition(),
|
||||
shared->DebugName()));
|
||||
LogFunctionCompilation(tag, compilation_info()->shared_info(),
|
||||
parse_info()->script(), abstract_code, true,
|
||||
time_taken_ms, isolate);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -252,25 +293,24 @@ void CompilationJob::RecordFunctionCompilation(
|
||||
|
||||
namespace {
|
||||
|
||||
void EnsureFeedbackMetadata(CompilationInfo* compilation_info,
|
||||
void EnsureFeedbackMetadata(UnoptimizedCompilationInfo* compilation_info,
|
||||
Handle<SharedFunctionInfo> shared_info,
|
||||
Isolate* isolate) {
|
||||
DCHECK(compilation_info->has_shared_info());
|
||||
|
||||
// If no type feedback metadata exists, create it. At this point the
|
||||
// AstNumbering pass has already run. Note the snapshot can contain outdated
|
||||
// vectors for a different configuration, hence we also recreate a new vector
|
||||
// when the function is not compiled (i.e. no code was serialized).
|
||||
|
||||
if (compilation_info->shared_info()->feedback_metadata()->is_empty() ||
|
||||
!compilation_info->shared_info()->is_compiled()) {
|
||||
if (shared_info->feedback_metadata()->is_empty() ||
|
||||
!shared_info->is_compiled()) {
|
||||
Handle<FeedbackMetadata> feedback_metadata = FeedbackMetadata::New(
|
||||
isolate, compilation_info->feedback_vector_spec());
|
||||
compilation_info->shared_info()->set_feedback_metadata(*feedback_metadata);
|
||||
shared_info->set_feedback_metadata(*feedback_metadata);
|
||||
}
|
||||
|
||||
// It's very important that recompiles do not alter the structure of the type
|
||||
// feedback vector. Verify that the structure fits the function literal.
|
||||
CHECK(!compilation_info->shared_info()->feedback_metadata()->SpecDiffersFrom(
|
||||
CHECK(!shared_info->feedback_metadata()->SpecDiffersFrom(
|
||||
compilation_info->feedback_vector_spec()));
|
||||
}
|
||||
|
||||
@ -289,36 +329,35 @@ bool UseAsmWasm(FunctionLiteral* literal, bool asm_wasm_broken) {
|
||||
return literal->scope()->IsAsmModule();
|
||||
}
|
||||
|
||||
void InstallUnoptimizedCode(CompilationInfo* compilation_info,
|
||||
void InstallUnoptimizedCode(UnoptimizedCompilationInfo* compilation_info,
|
||||
Handle<SharedFunctionInfo> shared_info,
|
||||
Isolate* isolate) {
|
||||
Handle<SharedFunctionInfo> shared = compilation_info->shared_info();
|
||||
DCHECK_EQ(compilation_info->shared_info()->language_mode(),
|
||||
DCHECK_EQ(shared_info->language_mode(),
|
||||
compilation_info->literal()->language_mode());
|
||||
|
||||
// Ensure feedback metadata is installed.
|
||||
EnsureFeedbackMetadata(compilation_info, isolate);
|
||||
EnsureFeedbackMetadata(compilation_info, shared_info, isolate);
|
||||
|
||||
// Update the shared function info with the scope info.
|
||||
Handle<ScopeInfo> scope_info = compilation_info->scope()->scope_info();
|
||||
shared->set_scope_info(*scope_info);
|
||||
shared_info->set_scope_info(*scope_info);
|
||||
Scope* outer_scope = compilation_info->scope()->GetOuterScopeWithContext();
|
||||
if (outer_scope) shared->set_outer_scope_info(*outer_scope->scope_info());
|
||||
if (outer_scope)
|
||||
shared_info->set_outer_scope_info(*outer_scope->scope_info());
|
||||
|
||||
// We shouldn't have a code object, just bytecode or asm-wasm data.
|
||||
DCHECK(compilation_info->code().is_null());
|
||||
if (compilation_info->has_bytecode_array()) {
|
||||
DCHECK(!shared->HasBytecodeArray()); // Only compiled once.
|
||||
DCHECK(!shared_info->HasBytecodeArray()); // Only compiled once.
|
||||
DCHECK(!compilation_info->has_asm_wasm_data());
|
||||
shared->set_bytecode_array(*compilation_info->bytecode_array());
|
||||
shared_info->set_bytecode_array(*compilation_info->bytecode_array());
|
||||
} else {
|
||||
DCHECK(compilation_info->has_asm_wasm_data());
|
||||
shared->set_asm_wasm_data(*compilation_info->asm_wasm_data());
|
||||
shared_info->set_asm_wasm_data(*compilation_info->asm_wasm_data());
|
||||
}
|
||||
|
||||
// Install coverage info on the shared function info.
|
||||
if (compilation_info->has_coverage_info()) {
|
||||
DCHECK(isolate->is_block_code_coverage());
|
||||
isolate->debug()->InstallCoverageInfo(compilation_info->shared_info(),
|
||||
isolate->debug()->InstallCoverageInfo(shared_info,
|
||||
compilation_info->coverage_info());
|
||||
}
|
||||
}
|
||||
@ -351,17 +390,17 @@ void SetSharedFunctionFlagsFromLiteral(FunctionLiteral* literal,
|
||||
}
|
||||
}
|
||||
|
||||
CompilationJob::Status FinalizeUnoptimizedCompilationJob(CompilationJob* job,
|
||||
Isolate* isolate) {
|
||||
CompilationInfo* compilation_info = job->compilation_info();
|
||||
CompilationJob::Status FinalizeUnoptimizedCompilationJob(
|
||||
UnoptimizedCompilationJob* job, Handle<SharedFunctionInfo> shared_info,
|
||||
Isolate* isolate) {
|
||||
UnoptimizedCompilationInfo* compilation_info = job->compilation_info();
|
||||
ParseInfo* parse_info = job->parse_info();
|
||||
|
||||
SetSharedFunctionFlagsFromLiteral(compilation_info->literal(),
|
||||
compilation_info->shared_info());
|
||||
SetSharedFunctionFlagsFromLiteral(compilation_info->literal(), shared_info);
|
||||
|
||||
CompilationJob::Status status = job->FinalizeJob(isolate);
|
||||
CompilationJob::Status status = job->FinalizeJob(shared_info, isolate);
|
||||
if (status == CompilationJob::SUCCEEDED) {
|
||||
InstallUnoptimizedCode(compilation_info, isolate);
|
||||
InstallUnoptimizedCode(compilation_info, shared_info, isolate);
|
||||
CodeEventListener::LogEventsAndTags log_tag;
|
||||
if (parse_info->is_toplevel()) {
|
||||
log_tag = compilation_info->is_eval() ? CodeEventListener::EVAL_TAG
|
||||
@ -370,17 +409,18 @@ CompilationJob::Status FinalizeUnoptimizedCompilationJob(CompilationJob* job,
|
||||
log_tag = parse_info->lazy_compile() ? CodeEventListener::LAZY_COMPILE_TAG
|
||||
: CodeEventListener::FUNCTION_TAG;
|
||||
}
|
||||
job->RecordFunctionCompilation(log_tag, isolate);
|
||||
job->RecordUnoptimizedCompilationStats(isolate);
|
||||
job->RecordFunctionCompilation(log_tag, shared_info, isolate);
|
||||
job->RecordCompilationStats(isolate);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
std::unique_ptr<CompilationJob> PrepareAndExecuteUnoptimizedCompileJobs(
|
||||
std::unique_ptr<UnoptimizedCompilationJob> ExecuteUnoptimizedCompileJobs(
|
||||
ParseInfo* parse_info, FunctionLiteral* literal,
|
||||
AccountingAllocator* allocator, CompilationJobList* inner_function_jobs) {
|
||||
AccountingAllocator* allocator,
|
||||
UnoptimizedCompilationJobList* inner_function_jobs) {
|
||||
if (UseAsmWasm(literal, parse_info->is_asm_wasm_broken())) {
|
||||
std::unique_ptr<CompilationJob> asm_job(
|
||||
std::unique_ptr<UnoptimizedCompilationJob> asm_job(
|
||||
AsmJs::NewCompilationJob(parse_info, literal, allocator));
|
||||
if (asm_job->ExecuteJob() == CompilationJob::SUCCEEDED) {
|
||||
return asm_job;
|
||||
@ -392,45 +432,45 @@ std::unique_ptr<CompilationJob> PrepareAndExecuteUnoptimizedCompileJobs(
|
||||
// through to standard unoptimized compile.
|
||||
}
|
||||
ZoneVector<FunctionLiteral*> eager_inner_literals(0, parse_info->zone());
|
||||
std::unique_ptr<CompilationJob> job(
|
||||
std::unique_ptr<UnoptimizedCompilationJob> job(
|
||||
interpreter::Interpreter::NewCompilationJob(
|
||||
parse_info, literal, allocator, &eager_inner_literals));
|
||||
|
||||
if (job->ExecuteJob() != CompilationJob::SUCCEEDED) {
|
||||
// Compilation failed, return null.
|
||||
return std::unique_ptr<CompilationJob>();
|
||||
return std::unique_ptr<UnoptimizedCompilationJob>();
|
||||
}
|
||||
|
||||
// Recursively compile eager inner literals.
|
||||
for (FunctionLiteral* inner_literal : eager_inner_literals) {
|
||||
std::unique_ptr<CompilationJob> inner_job(
|
||||
PrepareAndExecuteUnoptimizedCompileJobs(
|
||||
parse_info, inner_literal, allocator, inner_function_jobs));
|
||||
std::unique_ptr<UnoptimizedCompilationJob> inner_job(
|
||||
ExecuteUnoptimizedCompileJobs(parse_info, inner_literal, allocator,
|
||||
inner_function_jobs));
|
||||
// Compilation failed, return null.
|
||||
if (!inner_job) return std::unique_ptr<CompilationJob>();
|
||||
if (!inner_job) return std::unique_ptr<UnoptimizedCompilationJob>();
|
||||
inner_function_jobs->emplace_front(std::move(inner_job));
|
||||
}
|
||||
|
||||
return job;
|
||||
}
|
||||
|
||||
std::unique_ptr<CompilationJob> GenerateUnoptimizedCode(
|
||||
std::unique_ptr<UnoptimizedCompilationJob> GenerateUnoptimizedCode(
|
||||
ParseInfo* parse_info, AccountingAllocator* allocator,
|
||||
CompilationJobList* inner_function_jobs) {
|
||||
UnoptimizedCompilationJobList* inner_function_jobs) {
|
||||
DisallowHeapAllocation no_allocation;
|
||||
DisallowHandleAllocation no_handles;
|
||||
DisallowHandleDereference no_deref;
|
||||
DCHECK(inner_function_jobs->empty());
|
||||
|
||||
if (!Compiler::Analyze(parse_info)) {
|
||||
return std::unique_ptr<CompilationJob>();
|
||||
return std::unique_ptr<UnoptimizedCompilationJob>();
|
||||
}
|
||||
|
||||
// Prepare and execute compilation of the outer-most function.
|
||||
std::unique_ptr<CompilationJob> outer_function_job(
|
||||
PrepareAndExecuteUnoptimizedCompileJobs(parse_info, parse_info->literal(),
|
||||
allocator, inner_function_jobs));
|
||||
if (!outer_function_job) return std::unique_ptr<CompilationJob>();
|
||||
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();
|
||||
@ -438,10 +478,11 @@ std::unique_ptr<CompilationJob> GenerateUnoptimizedCode(
|
||||
return outer_function_job;
|
||||
}
|
||||
|
||||
bool FinalizeUnoptimizedCode(ParseInfo* parse_info, Isolate* isolate,
|
||||
Handle<SharedFunctionInfo> shared_info,
|
||||
CompilationJob* outer_function_job,
|
||||
CompilationJobList* inner_function_jobs) {
|
||||
bool FinalizeUnoptimizedCode(
|
||||
ParseInfo* parse_info, Isolate* isolate,
|
||||
Handle<SharedFunctionInfo> shared_info,
|
||||
UnoptimizedCompilationJob* outer_function_job,
|
||||
UnoptimizedCompilationJobList* inner_function_jobs) {
|
||||
DCHECK(AllowCompilation::IsAllowed(isolate));
|
||||
|
||||
// Allocate scope infos for the literal.
|
||||
@ -449,9 +490,8 @@ bool FinalizeUnoptimizedCode(ParseInfo* parse_info, Isolate* isolate,
|
||||
AnalyzeMode::kRegular);
|
||||
|
||||
// Finalize the outer-most function's compilation job.
|
||||
outer_function_job->compilation_info()->set_shared_info(shared_info);
|
||||
if (FinalizeUnoptimizedCompilationJob(outer_function_job, isolate) !=
|
||||
CompilationJob::SUCCEEDED) {
|
||||
if (FinalizeUnoptimizedCompilationJob(outer_function_job, shared_info,
|
||||
isolate) != CompilationJob::SUCCEEDED) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -464,8 +504,8 @@ bool FinalizeUnoptimizedCode(ParseInfo* parse_info, Isolate* isolate,
|
||||
// The inner function might be compiled already if compiling for debug.
|
||||
// TODO(rmcilroy): Fix this and DCHECK !is_compiled() once Full-Codegen dies
|
||||
if (inner_shared_info->is_compiled()) continue;
|
||||
inner_job->compilation_info()->set_shared_info(inner_shared_info);
|
||||
if (FinalizeUnoptimizedCompilationJob(inner_job.get(), isolate) !=
|
||||
if (FinalizeUnoptimizedCompilationJob(inner_job.get(), inner_shared_info,
|
||||
isolate) !=
|
||||
CompilationJob::SUCCEEDED) {
|
||||
return false;
|
||||
}
|
||||
@ -505,7 +545,7 @@ MUST_USE_RESULT MaybeHandle<Code> GetCodeFromOptimizedCodeCache(
|
||||
return MaybeHandle<Code>();
|
||||
}
|
||||
|
||||
void ClearOptimizedCodeCache(CompilationInfo* compilation_info) {
|
||||
void ClearOptimizedCodeCache(OptimizedCompilationInfo* compilation_info) {
|
||||
Handle<JSFunction> function = compilation_info->closure();
|
||||
if (compilation_info->osr_offset().IsNone()) {
|
||||
Handle<FeedbackVector> vector =
|
||||
@ -514,7 +554,8 @@ void ClearOptimizedCodeCache(CompilationInfo* compilation_info) {
|
||||
}
|
||||
}
|
||||
|
||||
void InsertCodeIntoOptimizedCodeCache(CompilationInfo* compilation_info) {
|
||||
void InsertCodeIntoOptimizedCodeCache(
|
||||
OptimizedCompilationInfo* compilation_info) {
|
||||
Handle<Code> code = compilation_info->code();
|
||||
if (code->kind() != Code::OPTIMIZED_FUNCTION) return; // Nothing to do.
|
||||
|
||||
@ -538,11 +579,11 @@ void InsertCodeIntoOptimizedCodeCache(CompilationInfo* compilation_info) {
|
||||
}
|
||||
}
|
||||
|
||||
bool GetOptimizedCodeNow(CompilationJob* job, Isolate* isolate) {
|
||||
bool GetOptimizedCodeNow(OptimizedCompilationJob* job, Isolate* isolate) {
|
||||
TimerEventScope<TimerEventRecompileSynchronous> timer(isolate);
|
||||
RuntimeCallTimerScope runtimeTimer(
|
||||
isolate, RuntimeCallCounterId::kRecompileSynchronous);
|
||||
CompilationInfo* compilation_info = job->compilation_info();
|
||||
OptimizedCompilationInfo* compilation_info = job->compilation_info();
|
||||
TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"),
|
||||
"V8.RecompileSynchronous");
|
||||
|
||||
@ -559,15 +600,15 @@ bool GetOptimizedCodeNow(CompilationJob* job, Isolate* isolate) {
|
||||
}
|
||||
|
||||
// Success!
|
||||
job->RecordOptimizedCompilationStats();
|
||||
job->RecordCompilationStats();
|
||||
DCHECK(!isolate->has_pending_exception());
|
||||
InsertCodeIntoOptimizedCodeCache(compilation_info);
|
||||
job->RecordFunctionCompilation(CodeEventListener::LAZY_COMPILE_TAG, isolate);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GetOptimizedCodeLater(CompilationJob* job, Isolate* isolate) {
|
||||
CompilationInfo* compilation_info = job->compilation_info();
|
||||
bool GetOptimizedCodeLater(OptimizedCompilationJob* job, Isolate* isolate) {
|
||||
OptimizedCompilationInfo* compilation_info = job->compilation_info();
|
||||
if (!isolate->optimizing_compile_dispatcher()->IsQueueAvailable()) {
|
||||
if (FLAG_trace_concurrent_recompilation) {
|
||||
PrintF(" ** Compilation queue full, will retry optimizing ");
|
||||
@ -646,9 +687,9 @@ MaybeHandle<Code> GetOptimizedCode(Handle<JSFunction> function,
|
||||
// BUG(5946): This DCHECK is necessary to make certain that we won't
|
||||
// tolerate the lack of a script without bytecode.
|
||||
DCHECK_IMPLIES(!has_script, shared->HasBytecodeArray());
|
||||
std::unique_ptr<CompilationJob> job(
|
||||
std::unique_ptr<OptimizedCompilationJob> job(
|
||||
compiler::Pipeline::NewCompilationJob(function, has_script));
|
||||
CompilationInfo* compilation_info = job->compilation_info();
|
||||
OptimizedCompilationInfo* compilation_info = job->compilation_info();
|
||||
ParseInfo* parse_info = job->parse_info();
|
||||
|
||||
compilation_info->SetOptimizingForOsr(osr_offset, osr_frame);
|
||||
@ -715,9 +756,9 @@ MaybeHandle<Code> GetOptimizedCode(Handle<JSFunction> function,
|
||||
return MaybeHandle<Code>();
|
||||
}
|
||||
|
||||
CompilationJob::Status FinalizeOptimizedCompilationJob(CompilationJob* job,
|
||||
Isolate* isolate) {
|
||||
CompilationInfo* compilation_info = job->compilation_info();
|
||||
CompilationJob::Status FinalizeOptimizedCompilationJob(
|
||||
OptimizedCompilationJob* job, Isolate* isolate) {
|
||||
OptimizedCompilationInfo* compilation_info = job->compilation_info();
|
||||
|
||||
TimerEventScope<TimerEventRecompileSynchronous> timer(isolate);
|
||||
RuntimeCallTimerScope runtimeTimer(
|
||||
@ -743,7 +784,7 @@ CompilationJob::Status FinalizeOptimizedCompilationJob(CompilationJob* job,
|
||||
} else if (compilation_info->dependencies()->HasAborted()) {
|
||||
job->RetryOptimization(BailoutReason::kBailedOutDueToDependencyChange);
|
||||
} else if (job->FinalizeJob(isolate) == CompilationJob::SUCCEEDED) {
|
||||
job->RecordOptimizedCompilationStats();
|
||||
job->RecordCompilationStats();
|
||||
job->RecordFunctionCompilation(CodeEventListener::LAZY_COMPILE_TAG,
|
||||
isolate);
|
||||
InsertCodeIntoOptimizedCodeCache(compilation_info);
|
||||
@ -788,8 +829,9 @@ bool FailWithPendingException(Isolate* isolate, ParseInfo* parse_info,
|
||||
}
|
||||
|
||||
MaybeHandle<SharedFunctionInfo> FinalizeTopLevel(
|
||||
ParseInfo* parse_info, Isolate* isolate, CompilationJob* outer_function_job,
|
||||
CompilationJobList* inner_function_jobs) {
|
||||
ParseInfo* parse_info, Isolate* isolate,
|
||||
UnoptimizedCompilationJob* outer_function_job,
|
||||
UnoptimizedCompilationJobList* inner_function_jobs) {
|
||||
Handle<Script> script = parse_info->script();
|
||||
|
||||
// Internalize ast values onto the heap.
|
||||
@ -847,9 +889,10 @@ MaybeHandle<SharedFunctionInfo> CompileToplevel(ParseInfo* parse_info,
|
||||
parse_info->is_eval() ? "V8.CompileEval" : "V8.Compile");
|
||||
|
||||
// Generate the unoptimized bytecode or asm-js data.
|
||||
CompilationJobList inner_function_jobs;
|
||||
std::unique_ptr<CompilationJob> outer_function_job(GenerateUnoptimizedCode(
|
||||
parse_info, isolate->allocator(), &inner_function_jobs));
|
||||
UnoptimizedCompilationJobList inner_function_jobs;
|
||||
std::unique_ptr<UnoptimizedCompilationJob> outer_function_job(
|
||||
GenerateUnoptimizedCode(parse_info, isolate->allocator(),
|
||||
&inner_function_jobs));
|
||||
if (!outer_function_job) {
|
||||
FailWithPendingException(isolate, parse_info,
|
||||
Compiler::ClearExceptionFlag::KEEP_EXCEPTION);
|
||||
@ -860,9 +903,9 @@ MaybeHandle<SharedFunctionInfo> CompileToplevel(ParseInfo* parse_info,
|
||||
&inner_function_jobs);
|
||||
}
|
||||
|
||||
std::unique_ptr<CompilationJob> CompileTopLevelOnBackgroundThread(
|
||||
std::unique_ptr<UnoptimizedCompilationJob> CompileTopLevelOnBackgroundThread(
|
||||
ParseInfo* parse_info, AccountingAllocator* allocator,
|
||||
CompilationJobList* inner_function_jobs) {
|
||||
UnoptimizedCompilationJobList* inner_function_jobs) {
|
||||
DisallowHeapAllocation no_allocation;
|
||||
DisallowHandleAllocation no_handles;
|
||||
DisallowHandleDereference no_deref;
|
||||
@ -881,7 +924,7 @@ std::unique_ptr<CompilationJob> CompileTopLevelOnBackgroundThread(
|
||||
DCHECK(!parse_info->consumed_preparsed_scope_data()->HasData());
|
||||
|
||||
// Generate the unoptimized bytecode or asm-js data.
|
||||
std::unique_ptr<CompilationJob> outer_function_job(
|
||||
std::unique_ptr<UnoptimizedCompilationJob> outer_function_job(
|
||||
GenerateUnoptimizedCode(parse_info, allocator, inner_function_jobs));
|
||||
return outer_function_job;
|
||||
}
|
||||
@ -1043,9 +1086,10 @@ bool Compiler::Compile(Handle<SharedFunctionInfo> shared_info,
|
||||
}
|
||||
|
||||
// Generate the unoptimized bytecode or asm-js data.
|
||||
CompilationJobList inner_function_jobs;
|
||||
std::unique_ptr<CompilationJob> outer_function_job(GenerateUnoptimizedCode(
|
||||
&parse_info, isolate->allocator(), &inner_function_jobs));
|
||||
UnoptimizedCompilationJobList inner_function_jobs;
|
||||
std::unique_ptr<UnoptimizedCompilationJob> outer_function_job(
|
||||
GenerateUnoptimizedCode(&parse_info, isolate->allocator(),
|
||||
&inner_function_jobs));
|
||||
if (!outer_function_job) {
|
||||
return FailWithPendingException(isolate, &parse_info, flag);
|
||||
}
|
||||
@ -1874,20 +1918,23 @@ MaybeHandle<Code> Compiler::GetOptimizedCodeForOSR(Handle<JSFunction> function,
|
||||
osr_frame);
|
||||
}
|
||||
|
||||
bool Compiler::FinalizeCompilationJob(CompilationJob* raw_job,
|
||||
bool Compiler::FinalizeCompilationJob(OptimizedCompilationJob* raw_job,
|
||||
Isolate* isolate) {
|
||||
VMState<COMPILER> state(isolate);
|
||||
// Take ownership of compilation job. Deleting job also tears down the zone.
|
||||
std::unique_ptr<CompilationJob> job(raw_job);
|
||||
std::unique_ptr<OptimizedCompilationJob> job(raw_job);
|
||||
return FinalizeOptimizedCompilationJob(job.get(), isolate) ==
|
||||
CompilationJob::SUCCEEDED;
|
||||
}
|
||||
|
||||
if (job->compilation_info()->IsOptimizing()) {
|
||||
VMState<COMPILER> state(isolate);
|
||||
return FinalizeOptimizedCompilationJob(job.get(), isolate) ==
|
||||
CompilationJob::SUCCEEDED;
|
||||
} else {
|
||||
VMState<BYTECODE_COMPILER> state(isolate);
|
||||
return FinalizeUnoptimizedCompilationJob(job.get(), isolate) ==
|
||||
CompilationJob::SUCCEEDED;
|
||||
}
|
||||
bool Compiler::FinalizeCompilationJob(UnoptimizedCompilationJob* raw_job,
|
||||
Handle<SharedFunctionInfo> shared_info,
|
||||
Isolate* isolate) {
|
||||
VMState<BYTECODE_COMPILER> state(isolate);
|
||||
// Take ownership of compilation job. Deleting job also tears down the zone.
|
||||
std::unique_ptr<UnoptimizedCompilationJob> job(raw_job);
|
||||
return FinalizeUnoptimizedCompilationJob(job.get(), shared_info, isolate) ==
|
||||
CompilationJob::SUCCEEDED;
|
||||
}
|
||||
|
||||
void Compiler::PostInstantiation(Handle<JSFunction> function,
|
||||
|
146
src/compiler.h
146
src/compiler.h
@ -20,15 +20,18 @@ namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
// Forward declarations.
|
||||
class CompilationInfo;
|
||||
class CompilationJob;
|
||||
class JavaScriptFrame;
|
||||
class OptimizedCompilationInfo;
|
||||
class OptimizedCompilationJob;
|
||||
class ParseInfo;
|
||||
class Parser;
|
||||
class ScriptData;
|
||||
struct ScriptStreamingData;
|
||||
class UnoptimizedCompilationInfo;
|
||||
class UnoptimizedCompilationJob;
|
||||
|
||||
typedef std::forward_list<std::unique_ptr<CompilationJob>> CompilationJobList;
|
||||
typedef std::forward_list<std::unique_ptr<UnoptimizedCompilationJob>>
|
||||
UnoptimizedCompilationJobList;
|
||||
|
||||
// The V8 compiler API.
|
||||
//
|
||||
@ -64,7 +67,11 @@ class V8_EXPORT_PRIVATE Compiler : public AllStatic {
|
||||
ScriptStreamingData* streaming_data, Isolate* isolate);
|
||||
|
||||
// Generate and install code from previously queued compilation job.
|
||||
static bool FinalizeCompilationJob(CompilationJob* job, Isolate* isolate);
|
||||
static bool FinalizeCompilationJob(UnoptimizedCompilationJob* job,
|
||||
Handle<SharedFunctionInfo> shared_info,
|
||||
Isolate* isolate);
|
||||
static bool FinalizeCompilationJob(OptimizedCompilationJob* job,
|
||||
Isolate* isolate);
|
||||
|
||||
// Give the compiler a chance to perform low-latency initialization tasks of
|
||||
// the given {function} on its instantiation. Note that only the runtime will
|
||||
@ -168,14 +175,7 @@ class V8_EXPORT_PRIVATE Compiler : public AllStatic {
|
||||
};
|
||||
|
||||
// A base class for compilation jobs intended to run concurrent to the main
|
||||
// thread. The job is split into three phases which are called in sequence on
|
||||
// different threads and with different limitations:
|
||||
// 1) PrepareJob: Runs on main thread. No major limitations.
|
||||
// 2) ExecuteJob: Runs concurrently. No heap allocation or handle derefs.
|
||||
// 3) FinalizeJob: Runs on main thread. No dependency changes.
|
||||
//
|
||||
// Each of the three phases can either fail or succeed. The current state of
|
||||
// the job can be checked using {state()}.
|
||||
// thread. The current state of the job can be checked using {state()}.
|
||||
class V8_EXPORT_PRIVATE CompilationJob {
|
||||
public:
|
||||
enum Status { SUCCEEDED, FAILED };
|
||||
@ -186,11 +186,97 @@ class V8_EXPORT_PRIVATE CompilationJob {
|
||||
kSucceeded,
|
||||
kFailed,
|
||||
};
|
||||
CompilationJob(uintptr_t stack_limit, ParseInfo* parse_info,
|
||||
CompilationInfo* compilation_info, const char* compiler_name,
|
||||
State initial_state = State::kReadyToPrepare);
|
||||
|
||||
CompilationJob(uintptr_t stack_limit, State initial_state)
|
||||
: state_(initial_state), stack_limit_(stack_limit) {}
|
||||
virtual ~CompilationJob() {}
|
||||
|
||||
void set_stack_limit(uintptr_t stack_limit) { stack_limit_ = stack_limit; }
|
||||
uintptr_t stack_limit() const { return stack_limit_; }
|
||||
|
||||
State state() const { return state_; }
|
||||
|
||||
protected:
|
||||
MUST_USE_RESULT Status UpdateState(Status status, State next_state) {
|
||||
if (status == SUCCEEDED) {
|
||||
state_ = next_state;
|
||||
} else {
|
||||
state_ = State::kFailed;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
private:
|
||||
State state_;
|
||||
uintptr_t stack_limit_;
|
||||
};
|
||||
|
||||
// A base class for unoptimized compilation jobs.
|
||||
//
|
||||
// The job is split into two phases which are called in sequence on
|
||||
// different threads and with different limitations:
|
||||
// 1) ExecuteJob: Runs concurrently. No heap allocation or handle derefs.
|
||||
// 2) FinalizeJob: Runs on main thread. No dependency changes.
|
||||
//
|
||||
// Either of phases can either fail or succeed.
|
||||
class UnoptimizedCompilationJob : public CompilationJob {
|
||||
public:
|
||||
UnoptimizedCompilationJob(intptr_t stack_limit, ParseInfo* parse_info,
|
||||
UnoptimizedCompilationInfo* compilation_info)
|
||||
: CompilationJob(stack_limit, State::kReadyToExecute),
|
||||
parse_info_(parse_info),
|
||||
compilation_info_(compilation_info) {}
|
||||
|
||||
// Executes the compile job. Can be called on a background thread.
|
||||
MUST_USE_RESULT Status ExecuteJob();
|
||||
|
||||
// Finalizes the compile job. Must be called on the main thread.
|
||||
MUST_USE_RESULT Status FinalizeJob(Handle<SharedFunctionInfo> shared_info,
|
||||
Isolate* isolate);
|
||||
|
||||
void RecordCompilationStats(Isolate* isolate) const;
|
||||
void RecordFunctionCompilation(CodeEventListener::LogEventsAndTags tag,
|
||||
Handle<SharedFunctionInfo> shared,
|
||||
Isolate* isolate) const;
|
||||
|
||||
ParseInfo* parse_info() const { return parse_info_; }
|
||||
UnoptimizedCompilationInfo* compilation_info() const {
|
||||
return compilation_info_;
|
||||
}
|
||||
|
||||
protected:
|
||||
// Overridden by the actual implementation.
|
||||
virtual Status ExecuteJobImpl() = 0;
|
||||
virtual Status FinalizeJobImpl(Handle<SharedFunctionInfo> shared_info,
|
||||
Isolate* isolate) = 0;
|
||||
|
||||
private:
|
||||
ParseInfo* parse_info_;
|
||||
UnoptimizedCompilationInfo* compilation_info_;
|
||||
base::TimeDelta time_taken_to_execute_;
|
||||
base::TimeDelta time_taken_to_finalize_;
|
||||
};
|
||||
|
||||
// A base class for optimized compilation jobs.
|
||||
//
|
||||
// The job is split into three phases which are called in sequence on
|
||||
// different threads and with different limitations:
|
||||
// 1) PrepareJob: Runs on main thread. No major limitations.
|
||||
// 2) ExecuteJob: Runs concurrently. No heap allocation or handle derefs.
|
||||
// 3) FinalizeJob: Runs on main thread. No dependency changes.
|
||||
//
|
||||
// Each of the three phases can either fail or succeed.
|
||||
class OptimizedCompilationJob : public CompilationJob {
|
||||
public:
|
||||
OptimizedCompilationJob(uintptr_t stack_limit, ParseInfo* parse_info,
|
||||
OptimizedCompilationInfo* compilation_info,
|
||||
const char* compiler_name,
|
||||
State initial_state = State::kReadyToPrepare)
|
||||
: CompilationJob(stack_limit, initial_state),
|
||||
parse_info_(parse_info),
|
||||
compilation_info_(compilation_info),
|
||||
compiler_name_(compiler_name) {}
|
||||
|
||||
// Prepare the compile job. Must be called on the main thread.
|
||||
MUST_USE_RESULT Status PrepareJob(Isolate* isolate);
|
||||
|
||||
@ -209,17 +295,14 @@ class V8_EXPORT_PRIVATE CompilationJob {
|
||||
// Should only be called on optimization compilation jobs.
|
||||
Status AbortOptimization(BailoutReason reason);
|
||||
|
||||
void RecordOptimizedCompilationStats() const;
|
||||
void RecordUnoptimizedCompilationStats(Isolate* isolate) const;
|
||||
void RecordCompilationStats() const;
|
||||
void RecordFunctionCompilation(CodeEventListener::LogEventsAndTags tag,
|
||||
Isolate* isolate) const;
|
||||
|
||||
void set_stack_limit(uintptr_t stack_limit) { stack_limit_ = stack_limit; }
|
||||
uintptr_t stack_limit() const { return stack_limit_; }
|
||||
|
||||
State state() const { return state_; }
|
||||
ParseInfo* parse_info() const { return parse_info_; }
|
||||
CompilationInfo* compilation_info() const { return compilation_info_; }
|
||||
OptimizedCompilationInfo* compilation_info() const {
|
||||
return compilation_info_;
|
||||
}
|
||||
virtual size_t AllocatedMemory() const { return 0; }
|
||||
|
||||
protected:
|
||||
@ -229,24 +312,13 @@ class V8_EXPORT_PRIVATE CompilationJob {
|
||||
virtual Status FinalizeJobImpl(Isolate* isolate) = 0;
|
||||
|
||||
private:
|
||||
// TODO(6409): Remove parse_info once Fullcode and AstGraphBuilder are gone.
|
||||
// TODO(rmcilroy): Remove parse_info.
|
||||
ParseInfo* parse_info_;
|
||||
CompilationInfo* compilation_info_;
|
||||
OptimizedCompilationInfo* compilation_info_;
|
||||
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_;
|
||||
|
||||
MUST_USE_RESULT Status UpdateState(Status status, State next_state) {
|
||||
if (status == SUCCEEDED) {
|
||||
state_ = next_state;
|
||||
} else {
|
||||
state_ = State::kFailed;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
};
|
||||
|
||||
// Contains all data which needs to be transmitted between threads for
|
||||
@ -271,8 +343,8 @@ struct ScriptStreamingData {
|
||||
std::unique_ptr<Parser> parser;
|
||||
|
||||
// Data needed for finalizing compilation after background compilation.
|
||||
std::unique_ptr<CompilationJob> outer_function_job;
|
||||
CompilationJobList inner_function_jobs;
|
||||
std::unique_ptr<UnoptimizedCompilationJob> outer_function_job;
|
||||
UnoptimizedCompilationJobList inner_function_jobs;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ScriptStreamingData);
|
||||
};
|
||||
|
@ -7,13 +7,13 @@
|
||||
#include "src/arm/macro-assembler-arm.h"
|
||||
#include "src/assembler-inl.h"
|
||||
#include "src/boxed-float.h"
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler/code-generator-impl.h"
|
||||
#include "src/compiler/gap-resolver.h"
|
||||
#include "src/compiler/node-matchers.h"
|
||||
#include "src/compiler/osr.h"
|
||||
#include "src/double.h"
|
||||
#include "src/heap/heap-inl.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
@ -6,13 +6,13 @@
|
||||
|
||||
#include "src/arm64/assembler-arm64-inl.h"
|
||||
#include "src/arm64/macro-assembler-arm64-inl.h"
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler/code-generator-impl.h"
|
||||
#include "src/compiler/gap-resolver.h"
|
||||
#include "src/compiler/node-matchers.h"
|
||||
#include "src/compiler/osr.h"
|
||||
#include "src/frame-constants.h"
|
||||
#include "src/heap/heap-inl.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler/common-operator.h"
|
||||
#include "src/compiler/graph.h"
|
||||
#include "src/compiler/machine-operator.h"
|
||||
@ -14,6 +13,7 @@
|
||||
#include "src/compiler/operator-properties.h"
|
||||
#include "src/compiler/schedule.h"
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -48,7 +48,8 @@ static const Operator* PointerConstant(CommonOperatorBuilder* common,
|
||||
}
|
||||
|
||||
BasicBlockProfiler::Data* BasicBlockInstrumentor::Instrument(
|
||||
CompilationInfo* info, Graph* graph, Schedule* schedule, Isolate* isolate) {
|
||||
OptimizedCompilationInfo* info, Graph* graph, Schedule* schedule,
|
||||
Isolate* isolate) {
|
||||
// Skip the exit block in profiles, since the register allocator can't handle
|
||||
// it and entry into it means falling off the end of the function anyway.
|
||||
size_t n_blocks = static_cast<size_t>(schedule->RpoBlockCount()) - 1;
|
||||
|
@ -11,7 +11,7 @@
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
class CompilationInfo;
|
||||
class OptimizedCompilationInfo;
|
||||
|
||||
namespace compiler {
|
||||
|
||||
@ -20,7 +20,7 @@ class Schedule;
|
||||
|
||||
class BasicBlockInstrumentor : public AllStatic {
|
||||
public:
|
||||
static BasicBlockProfiler::Data* Instrument(CompilationInfo* info,
|
||||
static BasicBlockProfiler::Data* Instrument(OptimizedCompilationInfo* info,
|
||||
Graph* graph, Schedule* schedule,
|
||||
Isolate* isolate);
|
||||
};
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include "src/address-map.h"
|
||||
#include "src/assembler-inl.h"
|
||||
#include "src/base/adapters.h"
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler/code-generator-impl.h"
|
||||
#include "src/compiler/linkage.h"
|
||||
#include "src/compiler/pipeline.h"
|
||||
@ -15,6 +14,7 @@
|
||||
#include "src/eh-frame.h"
|
||||
#include "src/frames.h"
|
||||
#include "src/macro-assembler-inl.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -38,8 +38,8 @@ class CodeGenerator::JumpTable final : public ZoneObject {
|
||||
};
|
||||
|
||||
CodeGenerator::CodeGenerator(Zone* codegen_zone, Frame* frame, Linkage* linkage,
|
||||
InstructionSequence* code, CompilationInfo* info,
|
||||
Isolate* isolate,
|
||||
InstructionSequence* code,
|
||||
OptimizedCompilationInfo* info, Isolate* isolate,
|
||||
base::Optional<OsrHelper> osr_helper,
|
||||
int start_source_position,
|
||||
JumpOptimizationInfo* jump_opt,
|
||||
@ -73,7 +73,8 @@ CodeGenerator::CodeGenerator(Zone* codegen_zone, Frame* frame, Linkage* linkage,
|
||||
osr_helper_(osr_helper),
|
||||
osr_pc_offset_(-1),
|
||||
optimized_out_literal_id_(-1),
|
||||
source_position_table_builder_(info->SourcePositionRecordingMode()),
|
||||
source_position_table_builder_(
|
||||
SourcePositionTableBuilder::RECORD_SOURCE_POSITIONS),
|
||||
wasm_compilation_data_(wasm_compilation_data),
|
||||
result_(kSuccess),
|
||||
poisoning_enabled_(poisoning_enabled) {
|
||||
@ -138,7 +139,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleDeoptimizerCall(
|
||||
}
|
||||
|
||||
void CodeGenerator::AssembleCode() {
|
||||
CompilationInfo* info = this->info();
|
||||
OptimizedCompilationInfo* info = this->info();
|
||||
|
||||
// Open a frame scope to indicate that there is a frame on the stack. The
|
||||
// MANUAL indicates that the scope shouldn't actually generate code to set up
|
||||
@ -175,7 +176,7 @@ void CodeGenerator::AssembleCode() {
|
||||
|
||||
// Define deoptimization literals for all inlined functions.
|
||||
DCHECK_EQ(0u, deoptimization_literals_.size());
|
||||
for (CompilationInfo::InlinedFunctionHolder& inlined :
|
||||
for (OptimizedCompilationInfo::InlinedFunctionHolder& inlined :
|
||||
info->inlined_functions()) {
|
||||
if (!inlined.shared_info.equals(info->shared_info())) {
|
||||
int index = DefineDeoptimizationLiteral(
|
||||
@ -691,7 +692,7 @@ void CodeGenerator::AssembleSourcePosition(SourcePosition source_position) {
|
||||
source_position_table_builder_.AddPosition(tasm()->pc_offset(),
|
||||
source_position, false);
|
||||
if (FLAG_code_comments) {
|
||||
CompilationInfo* info = this->info();
|
||||
OptimizedCompilationInfo* info = this->info();
|
||||
if (info->IsStub()) return;
|
||||
std::ostringstream buffer;
|
||||
buffer << "-- ";
|
||||
@ -733,8 +734,8 @@ void CodeGenerator::AssembleGaps(Instruction* instr) {
|
||||
namespace {
|
||||
|
||||
Handle<PodArray<InliningPosition>> CreateInliningPositions(
|
||||
CompilationInfo* info, Isolate* isolate) {
|
||||
const CompilationInfo::InlinedFunctionList& inlined_functions =
|
||||
OptimizedCompilationInfo* info, Isolate* isolate) {
|
||||
const OptimizedCompilationInfo::InlinedFunctionList& inlined_functions =
|
||||
info->inlined_functions();
|
||||
if (inlined_functions.size() == 0) {
|
||||
return Handle<PodArray<InliningPosition>>::cast(
|
||||
@ -752,7 +753,7 @@ Handle<PodArray<InliningPosition>> CreateInliningPositions(
|
||||
} // namespace
|
||||
|
||||
Handle<DeoptimizationData> CodeGenerator::GenerateDeoptimizationData() {
|
||||
CompilationInfo* info = this->info();
|
||||
OptimizedCompilationInfo* info = this->info();
|
||||
int deopt_count = static_cast<int>(deoptimization_states_.size());
|
||||
if (deopt_count == 0 && !info->is_osr()) {
|
||||
return DeoptimizationData::Empty(isolate());
|
||||
|
@ -18,7 +18,7 @@
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
class CompilationInfo;
|
||||
class OptimizedCompilationInfo;
|
||||
|
||||
namespace compiler {
|
||||
|
||||
@ -78,8 +78,9 @@ class DeoptimizationLiteral {
|
||||
class CodeGenerator final : public GapResolver::Assembler {
|
||||
public:
|
||||
explicit CodeGenerator(Zone* codegen_zone, Frame* frame, Linkage* linkage,
|
||||
InstructionSequence* code, CompilationInfo* info,
|
||||
Isolate* isolate, base::Optional<OsrHelper> osr_helper,
|
||||
InstructionSequence* code,
|
||||
OptimizedCompilationInfo* info, Isolate* isolate,
|
||||
base::Optional<OsrHelper> osr_helper,
|
||||
int start_source_position,
|
||||
JumpOptimizationInfo* jump_opt,
|
||||
WasmCompilationData* wasm_compilation_data,
|
||||
@ -125,7 +126,7 @@ class CodeGenerator final : public GapResolver::Assembler {
|
||||
private:
|
||||
GapResolver* resolver() { return &resolver_; }
|
||||
SafepointTableBuilder* safepoints() { return &safepoints_; }
|
||||
CompilationInfo* info() const { return info_; }
|
||||
OptimizedCompilationInfo* info() const { return info_; }
|
||||
OsrHelper* osr_helper() { return &(*osr_helper_); }
|
||||
|
||||
// Create the FrameAccessState object. The Frame is immutable from here on.
|
||||
@ -376,7 +377,7 @@ class CodeGenerator final : public GapResolver::Assembler {
|
||||
Linkage* const linkage_;
|
||||
InstructionSequence* const code_;
|
||||
UnwindingInfoWriter unwinding_info_writer_;
|
||||
CompilationInfo* const info_;
|
||||
OptimizedCompilationInfo* const info_;
|
||||
Label* const labels_;
|
||||
Label return_label_;
|
||||
RpoNumber current_block_;
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include <string>
|
||||
|
||||
#include "src/code-stubs.h"
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler/all-nodes.h"
|
||||
#include "src/compiler/compiler-source-position-table.h"
|
||||
#include "src/compiler/graph.h"
|
||||
@ -23,13 +22,14 @@
|
||||
#include "src/compiler/scheduler.h"
|
||||
#include "src/interpreter/bytecodes.h"
|
||||
#include "src/objects/script-inl.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
#include "src/ostreams.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
namespace compiler {
|
||||
|
||||
std::unique_ptr<char[]> GetVisualizerLogFileName(CompilationInfo* info,
|
||||
std::unique_ptr<char[]> GetVisualizerLogFileName(OptimizedCompilationInfo* info,
|
||||
const char* phase,
|
||||
const char* suffix) {
|
||||
EmbeddedVector<char, 256> filename(0);
|
||||
@ -255,7 +255,7 @@ class GraphC1Visualizer {
|
||||
public:
|
||||
GraphC1Visualizer(std::ostream& os, Zone* zone); // NOLINT
|
||||
|
||||
void PrintCompilation(const CompilationInfo* info);
|
||||
void PrintCompilation(const OptimizedCompilationInfo* info);
|
||||
void PrintSchedule(const char* phase, const Schedule* schedule,
|
||||
const SourcePositionTable* positions,
|
||||
const InstructionSequence* instructions);
|
||||
@ -343,8 +343,7 @@ void GraphC1Visualizer::PrintIntProperty(const char* name, int value) {
|
||||
os_ << name << " " << value << "\n";
|
||||
}
|
||||
|
||||
|
||||
void GraphC1Visualizer::PrintCompilation(const CompilationInfo* info) {
|
||||
void GraphC1Visualizer::PrintCompilation(const OptimizedCompilationInfo* info) {
|
||||
Tag tag(this, "compilation");
|
||||
std::unique_ptr<char[]> name = info->GetDebugName();
|
||||
if (info->IsOptimizing()) {
|
||||
|
@ -14,7 +14,7 @@
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
class CompilationInfo;
|
||||
class OptimizedCompilationInfo;
|
||||
|
||||
namespace compiler {
|
||||
|
||||
@ -24,7 +24,7 @@ class RegisterAllocationData;
|
||||
class Schedule;
|
||||
class SourcePositionTable;
|
||||
|
||||
std::unique_ptr<char[]> GetVisualizerLogFileName(CompilationInfo* info,
|
||||
std::unique_ptr<char[]> GetVisualizerLogFileName(OptimizedCompilationInfo* info,
|
||||
const char* phase,
|
||||
const char* suffix);
|
||||
|
||||
@ -44,8 +44,9 @@ struct AsRPO {
|
||||
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os, const AsRPO& ad);
|
||||
|
||||
struct AsC1VCompilation {
|
||||
explicit AsC1VCompilation(const CompilationInfo* info) : info_(info) {}
|
||||
const CompilationInfo* info_;
|
||||
explicit AsC1VCompilation(const OptimizedCompilationInfo* info)
|
||||
: info_(info) {}
|
||||
const OptimizedCompilationInfo* info_;
|
||||
};
|
||||
|
||||
struct AsScheduledGraph {
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include "src/assembler-inl.h"
|
||||
#include "src/callable.h"
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler/code-generator-impl.h"
|
||||
#include "src/compiler/gap-resolver.h"
|
||||
#include "src/compiler/node-matchers.h"
|
||||
@ -16,6 +15,7 @@
|
||||
#include "src/heap/heap-inl.h"
|
||||
#include "src/ia32/assembler-ia32.h"
|
||||
#include "src/ia32/macro-assembler-ia32.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
@ -4,12 +4,12 @@
|
||||
|
||||
#include "src/compiler/js-inlining-heuristic.h"
|
||||
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler/common-operator.h"
|
||||
#include "src/compiler/compiler-source-position-table.h"
|
||||
#include "src/compiler/node-matchers.h"
|
||||
#include "src/compiler/simplified-operator.h"
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
@ -15,7 +15,7 @@ class JSInliningHeuristic final : public AdvancedReducer {
|
||||
public:
|
||||
enum Mode { kGeneralInlining, kRestrictedInlining, kStressInlining };
|
||||
JSInliningHeuristic(Editor* editor, Mode mode, Zone* local_zone,
|
||||
CompilationInfo* info, JSGraph* jsgraph,
|
||||
OptimizedCompilationInfo* info, JSGraph* jsgraph,
|
||||
SourcePositionTable* source_positions)
|
||||
: AdvancedReducer(editor),
|
||||
mode_(mode),
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include "src/compiler/js-inlining.h"
|
||||
|
||||
#include "src/ast/ast.h"
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler.h"
|
||||
#include "src/compiler/all-nodes.h"
|
||||
#include "src/compiler/bytecode-graph-builder.h"
|
||||
@ -18,6 +17,7 @@
|
||||
#include "src/compiler/operator-properties.h"
|
||||
#include "src/compiler/simplified-operator.h"
|
||||
#include "src/isolate-inl.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
#include "src/parsing/parse-info.h"
|
||||
|
||||
namespace v8 {
|
||||
|
@ -12,7 +12,7 @@ namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
class BailoutId;
|
||||
class CompilationInfo;
|
||||
class OptimizedCompilationInfo;
|
||||
|
||||
namespace compiler {
|
||||
|
||||
@ -23,7 +23,7 @@ class SourcePositionTable;
|
||||
// heuristics that decide what and how much to inline are beyond its scope.
|
||||
class JSInliner final : public AdvancedReducer {
|
||||
public:
|
||||
JSInliner(Editor* editor, Zone* local_zone, CompilationInfo* info,
|
||||
JSInliner(Editor* editor, Zone* local_zone, OptimizedCompilationInfo* info,
|
||||
JSGraph* jsgraph, SourcePositionTable* source_positions)
|
||||
: AdvancedReducer(editor),
|
||||
local_zone_(local_zone),
|
||||
@ -50,7 +50,7 @@ class JSInliner final : public AdvancedReducer {
|
||||
Handle<Context> native_context() const;
|
||||
|
||||
Zone* const local_zone_;
|
||||
CompilationInfo* info_;
|
||||
OptimizedCompilationInfo* info_;
|
||||
JSGraph* const jsgraph_;
|
||||
SourcePositionTable* const source_positions_;
|
||||
|
||||
|
@ -6,12 +6,12 @@
|
||||
|
||||
#include "src/assembler-inl.h"
|
||||
#include "src/code-stubs.h"
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler/common-operator.h"
|
||||
#include "src/compiler/frame.h"
|
||||
#include "src/compiler/node.h"
|
||||
#include "src/compiler/osr.h"
|
||||
#include "src/compiler/pipeline.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -135,7 +135,8 @@ int CallDescriptor::CalculateFixedFrameSize() const {
|
||||
UNREACHABLE();
|
||||
}
|
||||
|
||||
CallDescriptor* Linkage::ComputeIncoming(Zone* zone, CompilationInfo* info) {
|
||||
CallDescriptor* Linkage::ComputeIncoming(Zone* zone,
|
||||
OptimizedCompilationInfo* info) {
|
||||
DCHECK(!info->IsStub());
|
||||
if (!info->closure().is_null()) {
|
||||
// If we are compiling a JS function, use a JS call descriptor,
|
||||
|
@ -20,7 +20,7 @@ namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
class CallInterfaceDescriptor;
|
||||
class CompilationInfo;
|
||||
class OptimizedCompilationInfo;
|
||||
|
||||
namespace compiler {
|
||||
|
||||
@ -364,7 +364,8 @@ class V8_EXPORT_PRIVATE Linkage : public NON_EXPORTED_BASE(ZoneObject) {
|
||||
|
||||
explicit Linkage(CallDescriptor* incoming) : incoming_(incoming) {}
|
||||
|
||||
static CallDescriptor* ComputeIncoming(Zone* zone, CompilationInfo* info);
|
||||
static CallDescriptor* ComputeIncoming(Zone* zone,
|
||||
OptimizedCompilationInfo* info);
|
||||
|
||||
// The call descriptor for this compilation unit describes the locations
|
||||
// of incoming parameters and the outgoing return value(s).
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
#include "src/assembler-inl.h"
|
||||
#include "src/callable.h"
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler/code-generator-impl.h"
|
||||
#include "src/compiler/code-generator.h"
|
||||
#include "src/compiler/gap-resolver.h"
|
||||
@ -12,6 +11,7 @@
|
||||
#include "src/compiler/osr.h"
|
||||
#include "src/heap/heap-inl.h"
|
||||
#include "src/mips/macro-assembler-mips.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
#include "src/assembler-inl.h"
|
||||
#include "src/callable.h"
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler/code-generator-impl.h"
|
||||
#include "src/compiler/code-generator.h"
|
||||
#include "src/compiler/gap-resolver.h"
|
||||
@ -12,6 +11,7 @@
|
||||
#include "src/compiler/osr.h"
|
||||
#include "src/heap/heap-inl.h"
|
||||
#include "src/mips64/macro-assembler-mips64.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
@ -4,17 +4,17 @@
|
||||
|
||||
#include "src/compiler/osr.h"
|
||||
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler/frame.h"
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/objects.h"
|
||||
#include "src/objects/shared-function-info.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
namespace compiler {
|
||||
|
||||
OsrHelper::OsrHelper(CompilationInfo* info)
|
||||
OsrHelper::OsrHelper(OptimizedCompilationInfo* info)
|
||||
: parameter_count_(
|
||||
info->shared_info()->bytecode_array()->parameter_count()),
|
||||
stack_slot_count_(
|
||||
|
@ -10,7 +10,7 @@
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
class CompilationInfo;
|
||||
class OptimizedCompilationInfo;
|
||||
|
||||
namespace compiler {
|
||||
|
||||
@ -20,7 +20,7 @@ class Frame;
|
||||
// details of the frame layout.
|
||||
class OsrHelper {
|
||||
public:
|
||||
explicit OsrHelper(CompilationInfo* info);
|
||||
explicit OsrHelper(OptimizedCompilationInfo* info);
|
||||
|
||||
// Prepares the frame w.r.t. OSR.
|
||||
void SetupFrame(Frame* frame);
|
||||
|
@ -4,12 +4,12 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler/pipeline-statistics.h"
|
||||
#include "src/compiler/zone-stats.h"
|
||||
#include "src/isolate.h"
|
||||
#include "src/objects/shared-function-info.h"
|
||||
#include "src/objects/string.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -45,8 +45,8 @@ void PipelineStatistics::CommonStats::End(
|
||||
timer_.Stop();
|
||||
}
|
||||
|
||||
PipelineStatistics::PipelineStatistics(CompilationInfo* info, Isolate* isolate,
|
||||
ZoneStats* zone_stats)
|
||||
PipelineStatistics::PipelineStatistics(OptimizedCompilationInfo* info,
|
||||
Isolate* isolate, ZoneStats* zone_stats)
|
||||
: isolate_(isolate),
|
||||
outer_zone_(info->zone()),
|
||||
zone_stats_(zone_stats),
|
||||
|
@ -20,7 +20,7 @@ class PhaseScope;
|
||||
|
||||
class PipelineStatistics : public Malloced {
|
||||
public:
|
||||
PipelineStatistics(CompilationInfo* info, Isolate* isolate,
|
||||
PipelineStatistics(OptimizedCompilationInfo* info, Isolate* isolate,
|
||||
ZoneStats* zone_stats);
|
||||
~PipelineStatistics();
|
||||
|
||||
|
@ -13,7 +13,6 @@
|
||||
#include "src/base/optional.h"
|
||||
#include "src/base/platform/elapsed-timer.h"
|
||||
#include "src/bootstrapper.h"
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler.h"
|
||||
#include "src/compiler/basic-block-instrumentor.h"
|
||||
#include "src/compiler/branch-elimination.h"
|
||||
@ -69,6 +68,7 @@
|
||||
#include "src/compiler/verifier.h"
|
||||
#include "src/compiler/zone-stats.h"
|
||||
#include "src/isolate-inl.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
#include "src/ostreams.h"
|
||||
#include "src/parsing/parse-info.h"
|
||||
#include "src/register-configuration.h"
|
||||
@ -91,7 +91,8 @@ const int kMaxBytecodeSizeForTurbofan = 128 * 1024;
|
||||
class PipelineData {
|
||||
public:
|
||||
// For main entry point.
|
||||
PipelineData(ZoneStats* zone_stats, Isolate* isolate, CompilationInfo* info,
|
||||
PipelineData(ZoneStats* zone_stats, Isolate* isolate,
|
||||
OptimizedCompilationInfo* info,
|
||||
PipelineStatistics* pipeline_statistics)
|
||||
: isolate_(isolate),
|
||||
info_(info),
|
||||
@ -122,8 +123,9 @@ class PipelineData {
|
||||
}
|
||||
|
||||
// For WebAssembly compile entry point.
|
||||
PipelineData(ZoneStats* zone_stats, Isolate* isolate, CompilationInfo* info,
|
||||
JSGraph* jsgraph, PipelineStatistics* pipeline_statistics,
|
||||
PipelineData(ZoneStats* zone_stats, Isolate* isolate,
|
||||
OptimizedCompilationInfo* info, JSGraph* jsgraph,
|
||||
PipelineStatistics* pipeline_statistics,
|
||||
SourcePositionTable* source_positions,
|
||||
WasmCompilationData* wasm_compilation_data)
|
||||
: isolate_(isolate),
|
||||
@ -147,8 +149,8 @@ class PipelineData {
|
||||
wasm_compilation_data_(wasm_compilation_data) {}
|
||||
|
||||
// For machine graph testing entry point.
|
||||
PipelineData(ZoneStats* zone_stats, CompilationInfo* info, Isolate* isolate,
|
||||
Graph* graph, Schedule* schedule,
|
||||
PipelineData(ZoneStats* zone_stats, OptimizedCompilationInfo* info,
|
||||
Isolate* isolate, Graph* graph, Schedule* schedule,
|
||||
SourcePositionTable* source_positions,
|
||||
JumpOptimizationInfo* jump_opt)
|
||||
: isolate_(isolate),
|
||||
@ -168,8 +170,8 @@ class PipelineData {
|
||||
jump_optimization_info_(jump_opt) {}
|
||||
|
||||
// For register allocation testing entry point.
|
||||
PipelineData(ZoneStats* zone_stats, CompilationInfo* info, Isolate* isolate,
|
||||
InstructionSequence* sequence)
|
||||
PipelineData(ZoneStats* zone_stats, OptimizedCompilationInfo* info,
|
||||
Isolate* isolate, InstructionSequence* sequence)
|
||||
: isolate_(isolate),
|
||||
info_(info),
|
||||
debug_name_(info_->GetDebugName()),
|
||||
@ -193,7 +195,7 @@ class PipelineData {
|
||||
}
|
||||
|
||||
Isolate* isolate() const { return isolate_; }
|
||||
CompilationInfo* info() const { return info_; }
|
||||
OptimizedCompilationInfo* info() const { return info_; }
|
||||
ZoneStats* zone_stats() const { return zone_stats_; }
|
||||
PipelineStatistics* pipeline_statistics() { return pipeline_statistics_; }
|
||||
OsrHelper* osr_helper() { return &(*osr_helper_); }
|
||||
@ -364,7 +366,7 @@ class PipelineData {
|
||||
|
||||
private:
|
||||
Isolate* const isolate_;
|
||||
CompilationInfo* const info_;
|
||||
OptimizedCompilationInfo* const info_;
|
||||
std::unique_ptr<char[]> debug_name_;
|
||||
bool may_have_unverifiable_graph_ = true;
|
||||
ZoneStats* const zone_stats_;
|
||||
@ -458,7 +460,7 @@ class PipelineImpl final {
|
||||
void AllocateRegisters(const RegisterConfiguration* config,
|
||||
CallDescriptor* call_descriptor, bool run_verifier);
|
||||
|
||||
CompilationInfo* info() const;
|
||||
OptimizedCompilationInfo* info() const;
|
||||
Isolate* isolate() const;
|
||||
|
||||
PipelineData* const data_;
|
||||
@ -468,7 +470,7 @@ namespace {
|
||||
|
||||
// Print function's source if it was not printed before.
|
||||
// Return a sequential id under which this function was printed.
|
||||
int PrintFunctionSource(CompilationInfo* info, Isolate* isolate,
|
||||
int PrintFunctionSource(OptimizedCompilationInfo* info, Isolate* isolate,
|
||||
std::vector<Handle<SharedFunctionInfo>>* printed,
|
||||
int inlining_id, Handle<SharedFunctionInfo> shared) {
|
||||
// Outermost function has source id -1 and inlined functions take
|
||||
@ -518,9 +520,9 @@ int PrintFunctionSource(CompilationInfo* info, Isolate* isolate,
|
||||
|
||||
// Print information for the given inlining: which function was inlined and
|
||||
// where the inlining occurred.
|
||||
void PrintInlinedFunctionInfo(CompilationInfo* info, Isolate* isolate,
|
||||
int source_id, int inlining_id,
|
||||
const CompilationInfo::InlinedFunctionHolder& h) {
|
||||
void PrintInlinedFunctionInfo(
|
||||
OptimizedCompilationInfo* info, Isolate* isolate, int source_id,
|
||||
int inlining_id, const OptimizedCompilationInfo::InlinedFunctionHolder& h) {
|
||||
CodeTracer::Scope tracing_scope(isolate->GetCodeTracer());
|
||||
OFStream os(tracing_scope.file());
|
||||
os << "INLINE (" << h.shared_info->DebugName()->ToCString().get() << ") id{"
|
||||
@ -537,7 +539,7 @@ void PrintInlinedFunctionInfo(CompilationInfo* info, Isolate* isolate,
|
||||
|
||||
// Print the source of all functions that participated in this optimizing
|
||||
// compilation. For inlined functions print source position of their inlining.
|
||||
void DumpParticipatingSource(CompilationInfo* info, Isolate* isolate) {
|
||||
void DumpParticipatingSource(OptimizedCompilationInfo* info, Isolate* isolate) {
|
||||
AllowDeferredHandleDereference allow_deference_for_print_code;
|
||||
|
||||
std::vector<Handle<SharedFunctionInfo>> printed;
|
||||
@ -554,7 +556,7 @@ void DumpParticipatingSource(CompilationInfo* info, Isolate* isolate) {
|
||||
}
|
||||
|
||||
// Print the code after compiling it.
|
||||
void PrintCode(Handle<Code> code, CompilationInfo* info) {
|
||||
void PrintCode(Handle<Code> code, OptimizedCompilationInfo* info) {
|
||||
Isolate* isolate = code->GetIsolate();
|
||||
if (FLAG_print_opt_source && info->IsOptimizing()) {
|
||||
DumpParticipatingSource(info, isolate);
|
||||
@ -618,12 +620,12 @@ struct TurboCfgFile : public std::ofstream {
|
||||
};
|
||||
|
||||
struct TurboJsonFile : public std::ofstream {
|
||||
TurboJsonFile(CompilationInfo* info, std::ios_base::openmode mode)
|
||||
TurboJsonFile(OptimizedCompilationInfo* info, std::ios_base::openmode mode)
|
||||
: std::ofstream(GetVisualizerLogFileName(info, nullptr, "json").get(),
|
||||
mode) {}
|
||||
};
|
||||
|
||||
void TraceSchedule(CompilationInfo* info, Isolate* isolate,
|
||||
void TraceSchedule(OptimizedCompilationInfo* info, Isolate* isolate,
|
||||
Schedule* schedule) {
|
||||
if (FLAG_trace_turbo) {
|
||||
AllowHandleDereference allow_deref;
|
||||
@ -707,7 +709,7 @@ class PipelineRunScope {
|
||||
};
|
||||
|
||||
PipelineStatistics* CreatePipelineStatistics(Handle<Script> script,
|
||||
CompilationInfo* info,
|
||||
OptimizedCompilationInfo* info,
|
||||
Isolate* isolate,
|
||||
ZoneStats* zone_stats) {
|
||||
PipelineStatistics* pipeline_statistics = nullptr;
|
||||
@ -740,15 +742,16 @@ PipelineStatistics* CreatePipelineStatistics(Handle<Script> script,
|
||||
|
||||
} // namespace
|
||||
|
||||
class PipelineCompilationJob final : public CompilationJob {
|
||||
class PipelineCompilationJob final : public OptimizedCompilationJob {
|
||||
public:
|
||||
PipelineCompilationJob(ParseInfo* parse_info,
|
||||
Handle<SharedFunctionInfo> shared_info,
|
||||
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(parse_info->stack_limit(), parse_info,
|
||||
&compilation_info_, "TurboFan"),
|
||||
// Note that the OptimizedCompilationInfo is not initialized at the time
|
||||
// we pass it to the CompilationJob constructor, but it is not
|
||||
// dereferenced there.
|
||||
: OptimizedCompilationJob(parse_info->stack_limit(), parse_info,
|
||||
&compilation_info_, "TurboFan"),
|
||||
parse_info_(parse_info),
|
||||
zone_stats_(function->GetIsolate()->allocator()),
|
||||
compilation_info_(parse_info_.get()->zone(), function->GetIsolate(),
|
||||
@ -772,7 +775,7 @@ class PipelineCompilationJob final : public CompilationJob {
|
||||
private:
|
||||
std::unique_ptr<ParseInfo> parse_info_;
|
||||
ZoneStats zone_stats_;
|
||||
CompilationInfo compilation_info_;
|
||||
OptimizedCompilationInfo compilation_info_;
|
||||
std::unique_ptr<PipelineStatistics> pipeline_statistics_;
|
||||
PipelineData data_;
|
||||
PipelineImpl pipeline_;
|
||||
@ -880,14 +883,14 @@ void PipelineCompilationJob::RegisterWeakObjectsInOptimizedCode(
|
||||
code->set_can_have_weak_objects(true);
|
||||
}
|
||||
|
||||
class PipelineWasmCompilationJob final : public CompilationJob {
|
||||
class PipelineWasmCompilationJob final : public OptimizedCompilationJob {
|
||||
public:
|
||||
explicit PipelineWasmCompilationJob(
|
||||
CompilationInfo* info, Isolate* isolate, JSGraph* jsgraph,
|
||||
OptimizedCompilationInfo* info, Isolate* isolate, JSGraph* jsgraph,
|
||||
CallDescriptor* call_descriptor, SourcePositionTable* source_positions,
|
||||
WasmCompilationData* wasm_compilation_data, bool asmjs_origin)
|
||||
: CompilationJob(isolate->stack_guard()->real_climit(), nullptr, info,
|
||||
"TurboFan", State::kReadyToExecute),
|
||||
: OptimizedCompilationJob(isolate->stack_guard()->real_climit(), nullptr,
|
||||
info, "TurboFan", State::kReadyToExecute),
|
||||
zone_stats_(isolate->allocator()),
|
||||
pipeline_statistics_(CreatePipelineStatistics(
|
||||
Handle<Script>::null(), info, isolate, &zone_stats_)),
|
||||
@ -966,7 +969,7 @@ size_t PipelineWasmCompilationJob::AllocatedMemory() const {
|
||||
PipelineWasmCompilationJob::Status PipelineWasmCompilationJob::FinalizeJobImpl(
|
||||
Isolate* isolate) {
|
||||
CodeGenerator* code_generator = pipeline_.data_->code_generator();
|
||||
CompilationInfo::WasmCodeDesc* wasm_code_desc =
|
||||
OptimizedCompilationInfo::WasmCodeDesc* wasm_code_desc =
|
||||
compilation_info()->wasm_code_desc();
|
||||
code_generator->tasm()->GetCode(isolate, &wasm_code_desc->code_desc);
|
||||
wasm_code_desc->safepoint_table_offset =
|
||||
@ -1080,7 +1083,8 @@ Maybe<OuterContext> GetModuleContext(Handle<JSFunction> closure) {
|
||||
return Nothing<OuterContext>();
|
||||
}
|
||||
|
||||
Maybe<OuterContext> ChooseSpecializationContext(CompilationInfo* info) {
|
||||
Maybe<OuterContext> ChooseSpecializationContext(
|
||||
OptimizedCompilationInfo* info) {
|
||||
if (info->is_function_context_specializing()) {
|
||||
DCHECK(info->has_context());
|
||||
return Just(OuterContext(handle(info->context()), 0));
|
||||
@ -1737,7 +1741,7 @@ struct PrintGraphPhase {
|
||||
static const char* phase_name() { return nullptr; }
|
||||
|
||||
void Run(PipelineData* data, Zone* temp_zone, const char* phase) {
|
||||
CompilationInfo* info = data->info();
|
||||
OptimizedCompilationInfo* info = data->info();
|
||||
Graph* graph = data->graph();
|
||||
|
||||
if (FLAG_trace_turbo) { // Print JSON.
|
||||
@ -1962,7 +1966,7 @@ Handle<Code> Pipeline::GenerateCodeForCodeStub(
|
||||
Schedule* schedule, Code::Kind kind, const char* debug_name,
|
||||
uint32_t stub_key, int32_t builtin_index, JumpOptimizationInfo* jump_opt,
|
||||
PoisoningMitigationLevel poisoning_enabled) {
|
||||
CompilationInfo info(CStrVector(debug_name), graph->zone(), kind);
|
||||
OptimizedCompilationInfo info(CStrVector(debug_name), graph->zone(), kind);
|
||||
info.set_builtin_index(builtin_index);
|
||||
info.set_stub_key(stub_key);
|
||||
|
||||
@ -2004,7 +2008,7 @@ Handle<Code> Pipeline::GenerateCodeForCodeStub(
|
||||
}
|
||||
|
||||
// static
|
||||
Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info,
|
||||
Handle<Code> Pipeline::GenerateCodeForTesting(OptimizedCompilationInfo* info,
|
||||
Isolate* isolate) {
|
||||
ZoneStats zone_stats(isolate->allocator());
|
||||
std::unique_ptr<PipelineStatistics> pipeline_statistics(
|
||||
@ -2023,7 +2027,7 @@ Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info,
|
||||
}
|
||||
|
||||
// static
|
||||
Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info,
|
||||
Handle<Code> Pipeline::GenerateCodeForTesting(OptimizedCompilationInfo* info,
|
||||
Isolate* isolate, Graph* graph,
|
||||
Schedule* schedule) {
|
||||
auto call_descriptor = Linkage::ComputeIncoming(info->zone(), info);
|
||||
@ -2033,8 +2037,9 @@ Handle<Code> Pipeline::GenerateCodeForTesting(CompilationInfo* info,
|
||||
|
||||
// static
|
||||
Handle<Code> Pipeline::GenerateCodeForTesting(
|
||||
CompilationInfo* info, Isolate* isolate, CallDescriptor* call_descriptor,
|
||||
Graph* graph, Schedule* schedule, SourcePositionTable* source_positions) {
|
||||
OptimizedCompilationInfo* info, Isolate* isolate,
|
||||
CallDescriptor* call_descriptor, Graph* graph, Schedule* schedule,
|
||||
SourcePositionTable* source_positions) {
|
||||
// Construct a pipeline for scheduling and code generation.
|
||||
ZoneStats zone_stats(isolate->allocator());
|
||||
// TODO(wasm): Refactor code generation to check for non-existing source
|
||||
@ -2069,8 +2074,8 @@ Handle<Code> Pipeline::GenerateCodeForTesting(
|
||||
}
|
||||
|
||||
// static
|
||||
CompilationJob* Pipeline::NewCompilationJob(Handle<JSFunction> function,
|
||||
bool has_script) {
|
||||
OptimizedCompilationJob* Pipeline::NewCompilationJob(
|
||||
Handle<JSFunction> function, bool has_script) {
|
||||
Handle<SharedFunctionInfo> shared = handle(function->shared());
|
||||
ParseInfo* parse_info;
|
||||
if (!has_script) {
|
||||
@ -2082,8 +2087,8 @@ CompilationJob* Pipeline::NewCompilationJob(Handle<JSFunction> function,
|
||||
}
|
||||
|
||||
// static
|
||||
CompilationJob* Pipeline::NewWasmCompilationJob(
|
||||
CompilationInfo* info, Isolate* isolate, JSGraph* jsgraph,
|
||||
OptimizedCompilationJob* Pipeline::NewWasmCompilationJob(
|
||||
OptimizedCompilationInfo* info, Isolate* isolate, JSGraph* jsgraph,
|
||||
CallDescriptor* call_descriptor, SourcePositionTable* source_positions,
|
||||
WasmCompilationData* wasm_compilation_data,
|
||||
wasm::ModuleOrigin asmjs_origin) {
|
||||
@ -2095,7 +2100,8 @@ CompilationJob* Pipeline::NewWasmCompilationJob(
|
||||
bool Pipeline::AllocateRegistersForTesting(const RegisterConfiguration* config,
|
||||
InstructionSequence* sequence,
|
||||
bool run_verifier) {
|
||||
CompilationInfo info(ArrayVector("testing"), sequence->zone(), Code::STUB);
|
||||
OptimizedCompilationInfo info(ArrayVector("testing"), sequence->zone(),
|
||||
Code::STUB);
|
||||
ZoneStats zone_stats(sequence->isolate()->allocator());
|
||||
PipelineData data(&zone_stats, &info, sequence->isolate(), sequence);
|
||||
PipelineImpl pipeline(&data);
|
||||
@ -2382,7 +2388,7 @@ void PipelineImpl::AllocateRegisters(const RegisterConfiguration* config,
|
||||
data->DeleteRegisterAllocationZone();
|
||||
}
|
||||
|
||||
CompilationInfo* PipelineImpl::info() const { return data_->info(); }
|
||||
OptimizedCompilationInfo* PipelineImpl::info() const { return data_->info(); }
|
||||
|
||||
Isolate* PipelineImpl::isolate() const { return data_->isolate(); }
|
||||
|
||||
|
@ -15,8 +15,8 @@
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
class CompilationInfo;
|
||||
class CompilationJob;
|
||||
class OptimizedCompilationInfo;
|
||||
class OptimizedCompilationJob;
|
||||
class RegisterConfiguration;
|
||||
class JumpOptimizationInfo;
|
||||
|
||||
@ -37,12 +37,12 @@ class WasmCompilationData;
|
||||
class Pipeline : public AllStatic {
|
||||
public:
|
||||
// Returns a new compilation job for the given function.
|
||||
static CompilationJob* NewCompilationJob(Handle<JSFunction> function,
|
||||
bool has_script);
|
||||
static OptimizedCompilationJob* NewCompilationJob(Handle<JSFunction> function,
|
||||
bool has_script);
|
||||
|
||||
// Returns a new compilation job for the WebAssembly compilation info.
|
||||
static CompilationJob* NewWasmCompilationJob(
|
||||
CompilationInfo* info, Isolate* isolate, JSGraph* jsgraph,
|
||||
static OptimizedCompilationJob* NewWasmCompilationJob(
|
||||
OptimizedCompilationInfo* info, Isolate* isolate, JSGraph* jsgraph,
|
||||
CallDescriptor* call_descriptor, SourcePositionTable* source_positions,
|
||||
WasmCompilationData* wasm_compilation_data,
|
||||
wasm::ModuleOrigin wasm_origin);
|
||||
@ -57,12 +57,12 @@ class Pipeline : public AllStatic {
|
||||
|
||||
// Run the entire pipeline and generate a handle to a code object suitable for
|
||||
// testing.
|
||||
static Handle<Code> GenerateCodeForTesting(CompilationInfo* info,
|
||||
static Handle<Code> GenerateCodeForTesting(OptimizedCompilationInfo* info,
|
||||
Isolate* isolate);
|
||||
|
||||
// Run the pipeline on a machine graph and generate code. If {schedule} is
|
||||
// {nullptr}, then compute a new schedule for code generation.
|
||||
static Handle<Code> GenerateCodeForTesting(CompilationInfo* info,
|
||||
static Handle<Code> GenerateCodeForTesting(OptimizedCompilationInfo* info,
|
||||
Isolate* isolate, Graph* graph,
|
||||
Schedule* schedule = nullptr);
|
||||
|
||||
@ -74,8 +74,9 @@ class Pipeline : public AllStatic {
|
||||
// Run the pipeline on a machine graph and generate code. If {schedule} is
|
||||
// {nullptr}, then compute a new schedule for code generation.
|
||||
V8_EXPORT_PRIVATE static Handle<Code> GenerateCodeForTesting(
|
||||
CompilationInfo* info, Isolate* isolate, CallDescriptor* call_descriptor,
|
||||
Graph* graph, Schedule* schedule = nullptr,
|
||||
OptimizedCompilationInfo* info, Isolate* isolate,
|
||||
CallDescriptor* call_descriptor, Graph* graph,
|
||||
Schedule* schedule = nullptr,
|
||||
SourcePositionTable* source_positions = nullptr);
|
||||
|
||||
private:
|
||||
|
@ -6,12 +6,12 @@
|
||||
|
||||
#include "src/assembler-inl.h"
|
||||
#include "src/callable.h"
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler/code-generator-impl.h"
|
||||
#include "src/compiler/gap-resolver.h"
|
||||
#include "src/compiler/node-matchers.h"
|
||||
#include "src/compiler/osr.h"
|
||||
#include "src/double.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
#include "src/ppc/macro-assembler-ppc.h"
|
||||
|
||||
namespace v8 {
|
||||
|
@ -6,11 +6,11 @@
|
||||
|
||||
#include "src/assembler-inl.h"
|
||||
#include "src/callable.h"
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler/code-generator-impl.h"
|
||||
#include "src/compiler/gap-resolver.h"
|
||||
#include "src/compiler/node-matchers.h"
|
||||
#include "src/compiler/osr.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
#include "src/s390/macro-assembler-s390.h"
|
||||
|
||||
namespace v8 {
|
||||
|
@ -4718,7 +4718,7 @@ Handle<Code> CompileJSToWasmWrapper(Isolate* isolate, wasm::WasmModule* module,
|
||||
Vector<const char> func_name = CStrVector("js-to-wasm");
|
||||
#endif
|
||||
|
||||
CompilationInfo info(func_name, &zone, Code::JS_TO_WASM_FUNCTION);
|
||||
OptimizedCompilationInfo info(func_name, &zone, Code::JS_TO_WASM_FUNCTION);
|
||||
Handle<Code> code =
|
||||
Pipeline::GenerateCodeForTesting(&info, isolate, incoming, &graph);
|
||||
#ifdef ENABLE_DISASSEMBLER
|
||||
@ -4840,7 +4840,7 @@ Handle<Code> CompileWasmToJSWrapper(
|
||||
Vector<const char> func_name = CStrVector("wasm-to-js");
|
||||
#endif
|
||||
|
||||
CompilationInfo info(func_name, &zone, Code::WASM_TO_JS_FUNCTION);
|
||||
OptimizedCompilationInfo info(func_name, &zone, Code::WASM_TO_JS_FUNCTION);
|
||||
Handle<Code> code = Pipeline::GenerateCodeForTesting(
|
||||
&info, isolate, incoming, &graph, nullptr, source_position_table);
|
||||
ValidateImportWrapperReferencesImmovables(code);
|
||||
@ -4919,7 +4919,7 @@ Handle<Code> CompileWasmToWasmWrapper(Isolate* isolate, wasm::WasmCode* target,
|
||||
func_name = Vector<const char>::cast(buffer.SubVector(0, chars));
|
||||
}
|
||||
|
||||
CompilationInfo info(func_name, &zone, Code::WASM_TO_WASM_FUNCTION);
|
||||
OptimizedCompilationInfo info(func_name, &zone, Code::WASM_TO_WASM_FUNCTION);
|
||||
Handle<Code> code =
|
||||
Pipeline::GenerateCodeForTesting(&info, isolate, incoming, &graph);
|
||||
#ifdef ENABLE_DISASSEMBLER
|
||||
@ -4985,7 +4985,8 @@ Handle<Code> CompileWasmInterpreterEntry(Isolate* isolate, uint32_t func_index,
|
||||
Vector<const char> func_name = CStrVector("wasm-interpreter-entry");
|
||||
#endif
|
||||
|
||||
CompilationInfo info(func_name, &zone, Code::WASM_INTERPRETER_ENTRY);
|
||||
OptimizedCompilationInfo info(func_name, &zone,
|
||||
Code::WASM_INTERPRETER_ENTRY);
|
||||
code = Pipeline::GenerateCodeForTesting(&info, isolate, incoming, &graph,
|
||||
nullptr);
|
||||
#ifdef ENABLE_DISASSEMBLER
|
||||
@ -5052,7 +5053,7 @@ Handle<Code> CompileCWasmEntry(Isolate* isolate, wasm::FunctionSig* sig) {
|
||||
debug_name[name_len] = '\0';
|
||||
Vector<const char> debug_name_vec(debug_name, name_len);
|
||||
|
||||
CompilationInfo info(debug_name_vec, &zone, Code::C_WASM_ENTRY);
|
||||
OptimizedCompilationInfo info(debug_name_vec, &zone, Code::C_WASM_ENTRY);
|
||||
Handle<Code> code =
|
||||
Pipeline::GenerateCodeForTesting(&info, isolate, incoming, &graph);
|
||||
#ifdef ENABLE_DISASSEMBLER
|
||||
@ -5252,7 +5253,7 @@ void WasmCompilationUnit::ExecuteTurbofanCompilation() {
|
||||
call_descriptor = GetI32WasmCallDescriptor(tf_.compilation_zone_.get(),
|
||||
call_descriptor);
|
||||
}
|
||||
tf_.info_.reset(new CompilationInfo(
|
||||
tf_.info_.reset(new OptimizedCompilationInfo(
|
||||
GetDebugName(tf_.compilation_zone_.get(), func_name_, func_index_),
|
||||
tf_.compilation_zone_.get(), Code::WASM_FUNCTION));
|
||||
|
||||
|
@ -9,8 +9,8 @@
|
||||
|
||||
// Clients of this interface shouldn't depend on lots of compiler internals.
|
||||
// Do not include anything from src/compiler here!
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
#include "src/trap-handler/trap-handler.h"
|
||||
#include "src/wasm/baseline/liftoff-assembler.h"
|
||||
#include "src/wasm/function-body-decoder.h"
|
||||
@ -168,8 +168,8 @@ class WasmCompilationUnit final {
|
||||
// ExecuteCompilation, onto FinishCompilation (which happens on the main
|
||||
// thread).
|
||||
std::unique_ptr<Zone> compilation_zone_;
|
||||
std::unique_ptr<CompilationInfo> info_;
|
||||
std::unique_ptr<CompilationJob> job_;
|
||||
std::unique_ptr<OptimizedCompilationInfo> info_;
|
||||
std::unique_ptr<OptimizedCompilationJob> job_;
|
||||
wasm::Result<wasm::DecodeStruct*> graph_construction_result_;
|
||||
};
|
||||
|
||||
|
@ -6,12 +6,12 @@
|
||||
|
||||
#include <limits>
|
||||
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler/code-generator-impl.h"
|
||||
#include "src/compiler/gap-resolver.h"
|
||||
#include "src/compiler/node-matchers.h"
|
||||
#include "src/compiler/osr.h"
|
||||
#include "src/heap/heap-inl.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
#include "src/x64/assembler-x64.h"
|
||||
#include "src/x64/macro-assembler-x64.h"
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include "src/ast/scopes.h"
|
||||
#include "src/builtins/builtins-constructor.h"
|
||||
#include "src/code-stubs.h"
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler.h"
|
||||
#include "src/interpreter/bytecode-flags.h"
|
||||
#include "src/interpreter/bytecode-jump-table.h"
|
||||
@ -22,6 +21,7 @@
|
||||
#include "src/objects/literal-objects-inl.h"
|
||||
#include "src/parsing/parse-info.h"
|
||||
#include "src/parsing/token.h"
|
||||
#include "src/unoptimized-compilation-info.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -710,7 +710,7 @@ class BytecodeGenerator::GlobalDeclarationsBuilder final : public ZoneObject {
|
||||
declarations_.push_back(Declaration(name, slot, nullptr));
|
||||
}
|
||||
|
||||
Handle<FixedArray> AllocateDeclarations(CompilationInfo* info,
|
||||
Handle<FixedArray> AllocateDeclarations(UnoptimizedCompilationInfo* info,
|
||||
Handle<Script> script,
|
||||
Isolate* isolate) {
|
||||
DCHECK(has_constant_pool_entry_);
|
||||
@ -873,7 +873,8 @@ static bool IsInEagerLiterals(
|
||||
#endif // DEBUG
|
||||
|
||||
BytecodeGenerator::BytecodeGenerator(
|
||||
CompilationInfo* info, const AstStringConstants* ast_string_constants,
|
||||
UnoptimizedCompilationInfo* info,
|
||||
const AstStringConstants* ast_string_constants,
|
||||
ZoneVector<FunctionLiteral*>* eager_inner_literals)
|
||||
: zone_(info->zone()),
|
||||
builder_(zone(), info->num_parameters_including_this(),
|
||||
@ -919,7 +920,7 @@ Handle<BytecodeArray> BytecodeGenerator::FinalizeBytecode(
|
||||
info()->set_coverage_info(
|
||||
isolate->factory()->NewCoverageInfo(block_coverage_builder_->slots()));
|
||||
if (FLAG_trace_block_coverage) {
|
||||
info()->coverage_info()->Print(info()->shared_info()->Name());
|
||||
info()->coverage_info()->Print(info()->literal()->GetDebugName());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1297,7 +1298,8 @@ void BytecodeGenerator::VisitDeclarations(Declaration::List* declarations) {
|
||||
|
||||
globals_builder()->set_constant_pool_entry(
|
||||
builder()->AllocateDeferredConstantPoolEntry());
|
||||
int encoded_flags = info()->GetDeclareGlobalsFlags();
|
||||
int encoded_flags = DeclareGlobalsEvalFlag::encode(info()->is_eval()) |
|
||||
DeclareGlobalsNativeFlag::encode(info()->is_native());
|
||||
|
||||
// Emit code to declare globals.
|
||||
RegisterList args = register_allocator()->NewRegisterList(3);
|
||||
|
@ -16,7 +16,7 @@ namespace internal {
|
||||
|
||||
class AstNodeSourceRanges;
|
||||
class AstStringConstants;
|
||||
class CompilationInfo;
|
||||
class UnoptimizedCompilationInfo;
|
||||
enum class SourceRangeKind;
|
||||
|
||||
namespace interpreter {
|
||||
@ -29,7 +29,8 @@ class BytecodeJumpTable;
|
||||
class BytecodeGenerator final : public AstVisitor<BytecodeGenerator> {
|
||||
public:
|
||||
explicit BytecodeGenerator(
|
||||
CompilationInfo* info, const AstStringConstants* ast_string_constants,
|
||||
UnoptimizedCompilationInfo* info,
|
||||
const AstStringConstants* ast_string_constants,
|
||||
ZoneVector<FunctionLiteral*>* eager_inner_literals);
|
||||
|
||||
void GenerateBytecode(uintptr_t stack_limit);
|
||||
@ -278,7 +279,7 @@ class BytecodeGenerator final : public AstVisitor<BytecodeGenerator> {
|
||||
inline BytecodeArrayBuilder* builder() { return &builder_; }
|
||||
inline Zone* zone() const { return zone_; }
|
||||
inline DeclarationScope* closure_scope() const { return closure_scope_; }
|
||||
inline CompilationInfo* info() const { return info_; }
|
||||
inline UnoptimizedCompilationInfo* info() const { return info_; }
|
||||
inline const AstStringConstants* ast_string_constants() const {
|
||||
return ast_string_constants_;
|
||||
}
|
||||
@ -324,7 +325,7 @@ class BytecodeGenerator final : public AstVisitor<BytecodeGenerator> {
|
||||
|
||||
Zone* zone_;
|
||||
BytecodeArrayBuilder builder_;
|
||||
CompilationInfo* info_;
|
||||
UnoptimizedCompilationInfo* info_;
|
||||
const AstStringConstants* ast_string_constants_;
|
||||
DeclarationScope* closure_scope_;
|
||||
Scope* current_scope_;
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
#include "src/ast/prettyprinter.h"
|
||||
#include "src/bootstrapper.h"
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler.h"
|
||||
#include "src/counters-inl.h"
|
||||
#include "src/interpreter/bytecode-generator.h"
|
||||
@ -20,28 +19,29 @@
|
||||
#include "src/parsing/parse-info.h"
|
||||
#include "src/setup-isolate.h"
|
||||
#include "src/snapshot/snapshot.h"
|
||||
#include "src/unoptimized-compilation-info.h"
|
||||
#include "src/visitors.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
namespace interpreter {
|
||||
|
||||
class InterpreterCompilationJob final : public CompilationJob {
|
||||
class InterpreterCompilationJob final : public UnoptimizedCompilationJob {
|
||||
public:
|
||||
InterpreterCompilationJob(ParseInfo* parse_info, FunctionLiteral* literal,
|
||||
AccountingAllocator* allocator,
|
||||
ZoneVector<FunctionLiteral*>* eager_inner_literals);
|
||||
|
||||
protected:
|
||||
Status PrepareJobImpl(Isolate* isolate) final;
|
||||
Status ExecuteJobImpl() final;
|
||||
Status FinalizeJobImpl(Isolate* isolate) final;
|
||||
Status FinalizeJobImpl(Handle<SharedFunctionInfo> shared_info,
|
||||
Isolate* isolate) final;
|
||||
|
||||
private:
|
||||
BytecodeGenerator* generator() { return &generator_; }
|
||||
|
||||
Zone zone_;
|
||||
CompilationInfo compilation_info_;
|
||||
UnoptimizedCompilationInfo compilation_info_;
|
||||
BytecodeGenerator generator_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(InterpreterCompilationJob);
|
||||
@ -132,13 +132,13 @@ int Interpreter::InterruptBudget() {
|
||||
|
||||
namespace {
|
||||
|
||||
void MaybePrintAst(ParseInfo* parse_info, CompilationInfo* compilation_info) {
|
||||
void MaybePrintAst(ParseInfo* parse_info,
|
||||
UnoptimizedCompilationInfo* compilation_info) {
|
||||
if (!FLAG_print_ast) return;
|
||||
|
||||
OFStream os(stdout);
|
||||
std::unique_ptr<char[]> name = compilation_info->GetDebugName();
|
||||
os << "[generating bytecode for function: "
|
||||
<< compilation_info->GetDebugName().get() << "]" << std::endl;
|
||||
std::unique_ptr<char[]> name = compilation_info->literal()->GetDebugName();
|
||||
os << "[generating bytecode for function: " << name.get() << "]" << std::endl;
|
||||
#ifdef DEBUG
|
||||
os << "--- AST ---" << std::endl
|
||||
<< AstPrinter(parse_info->stack_limit())
|
||||
@ -165,19 +165,13 @@ InterpreterCompilationJob::InterpreterCompilationJob(
|
||||
ParseInfo* parse_info, FunctionLiteral* literal,
|
||||
AccountingAllocator* allocator,
|
||||
ZoneVector<FunctionLiteral*>* eager_inner_literals)
|
||||
: CompilationJob(parse_info->stack_limit(), parse_info, &compilation_info_,
|
||||
"Ignition", State::kReadyToExecute),
|
||||
: UnoptimizedCompilationJob(parse_info->stack_limit(), parse_info,
|
||||
&compilation_info_),
|
||||
zone_(allocator, ZONE_NAME),
|
||||
compilation_info_(&zone_, parse_info, literal),
|
||||
generator_(&compilation_info_, parse_info->ast_string_constants(),
|
||||
eager_inner_literals) {}
|
||||
|
||||
InterpreterCompilationJob::Status InterpreterCompilationJob::PrepareJobImpl(
|
||||
Isolate* isolate) {
|
||||
UNREACHABLE(); // Prepare should always be skipped.
|
||||
return SUCCEEDED;
|
||||
}
|
||||
|
||||
InterpreterCompilationJob::Status InterpreterCompilationJob::ExecuteJobImpl() {
|
||||
RuntimeCallTimerScope runtimeTimerScope(
|
||||
parse_info()->runtime_call_stats(),
|
||||
@ -200,7 +194,7 @@ InterpreterCompilationJob::Status InterpreterCompilationJob::ExecuteJobImpl() {
|
||||
}
|
||||
|
||||
InterpreterCompilationJob::Status InterpreterCompilationJob::FinalizeJobImpl(
|
||||
Isolate* isolate) {
|
||||
Handle<SharedFunctionInfo> shared_info, Isolate* isolate) {
|
||||
RuntimeCallTimerScope runtimeTimerScope(
|
||||
parse_info()->runtime_call_stats(),
|
||||
RuntimeCallCounterId::kCompileIgnitionFinalization);
|
||||
@ -213,11 +207,12 @@ InterpreterCompilationJob::Status InterpreterCompilationJob::FinalizeJobImpl(
|
||||
return FAILED;
|
||||
}
|
||||
|
||||
if (ShouldPrintBytecode(compilation_info()->shared_info())) {
|
||||
if (ShouldPrintBytecode(shared_info)) {
|
||||
OFStream os(stdout);
|
||||
std::unique_ptr<char[]> name = compilation_info()->GetDebugName();
|
||||
os << "[generated bytecode for function: "
|
||||
<< compilation_info()->GetDebugName().get() << "]" << std::endl;
|
||||
std::unique_ptr<char[]> name =
|
||||
compilation_info()->literal()->GetDebugName();
|
||||
os << "[generated bytecode for function: " << name.get() << "]"
|
||||
<< std::endl;
|
||||
bytecodes->Disassemble(os);
|
||||
os << std::flush;
|
||||
}
|
||||
@ -226,7 +221,7 @@ InterpreterCompilationJob::Status InterpreterCompilationJob::FinalizeJobImpl(
|
||||
return SUCCEEDED;
|
||||
}
|
||||
|
||||
CompilationJob* Interpreter::NewCompilationJob(
|
||||
UnoptimizedCompilationJob* Interpreter::NewCompilationJob(
|
||||
ParseInfo* parse_info, FunctionLiteral* literal,
|
||||
AccountingAllocator* allocator,
|
||||
ZoneVector<FunctionLiteral*>* eager_inner_literals) {
|
||||
|
@ -21,8 +21,7 @@ namespace internal {
|
||||
class Isolate;
|
||||
class BuiltinDeserializerAllocator;
|
||||
class Callable;
|
||||
class CompilationInfo;
|
||||
class CompilationJob;
|
||||
class UnoptimizedCompilationJob;
|
||||
class FunctionLiteral;
|
||||
class ParseInfo;
|
||||
class RootVisitor;
|
||||
@ -45,7 +44,7 @@ class Interpreter {
|
||||
// Creates a compilation job which will generate bytecode for |literal|.
|
||||
// Additionally, if |eager_inner_literals| is not null, adds any eagerly
|
||||
// compilable inner FunctionLiterals to this list.
|
||||
static CompilationJob* NewCompilationJob(
|
||||
static UnoptimizedCompilationJob* NewCompilationJob(
|
||||
ParseInfo* parse_info, FunctionLiteral* literal,
|
||||
AccountingAllocator* allocator,
|
||||
ZoneVector<FunctionLiteral*>* eager_inner_literals);
|
||||
|
@ -346,15 +346,14 @@ void CoverageInfo::ResetBlockCount(int slot_index) {
|
||||
set(slot_start + kSlotBlockCountIndex, Smi::kZero);
|
||||
}
|
||||
|
||||
void CoverageInfo::Print(String* function_name) {
|
||||
void CoverageInfo::Print(std::unique_ptr<char[]> function_name) {
|
||||
DCHECK(FLAG_trace_block_coverage);
|
||||
DisallowHeapAllocation no_gc;
|
||||
|
||||
OFStream os(stdout);
|
||||
os << "Coverage info (";
|
||||
if (function_name->length() > 0) {
|
||||
auto function_name_cstr = function_name->ToCString();
|
||||
os << function_name_cstr.get();
|
||||
if (strlen(function_name.get()) > 0) {
|
||||
os << function_name.get();
|
||||
} else {
|
||||
os << "{anonymous}";
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ class CoverageInfo : public FixedArray {
|
||||
DECL_CAST(CoverageInfo)
|
||||
|
||||
// Print debug info.
|
||||
void Print(String* function_name);
|
||||
void Print(std::unique_ptr<char[]> function_name);
|
||||
|
||||
private:
|
||||
static int FirstIndexForSlot(int slot_index) {
|
||||
|
@ -2,7 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
|
||||
#include "src/api.h"
|
||||
#include "src/ast/ast.h"
|
||||
@ -16,27 +16,10 @@
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
CompilationInfo::CompilationInfo(Zone* zone, ParseInfo* parse_info,
|
||||
FunctionLiteral* literal)
|
||||
: CompilationInfo({}, AbstractCode::INTERPRETED_FUNCTION, zone) {
|
||||
// NOTE: The parse_info passed here represents the global information gathered
|
||||
// during parsing, but does not represent specific details of the actual
|
||||
// function literal being compiled for this CompilationInfo. As such,
|
||||
// parse_info->literal() might be different from literal, and only global
|
||||
// details of the script being parsed are relevant to this CompilationInfo.
|
||||
DCHECK_NOT_NULL(literal);
|
||||
literal_ = literal;
|
||||
source_range_map_ = parse_info->source_range_map();
|
||||
|
||||
if (parse_info->is_eval()) MarkAsEval();
|
||||
if (parse_info->is_native()) MarkAsNative();
|
||||
if (parse_info->collect_type_profile()) MarkAsCollectTypeProfile();
|
||||
}
|
||||
|
||||
CompilationInfo::CompilationInfo(Zone* zone, Isolate* isolate,
|
||||
Handle<SharedFunctionInfo> shared,
|
||||
Handle<JSFunction> closure)
|
||||
: CompilationInfo({}, AbstractCode::OPTIMIZED_FUNCTION, zone) {
|
||||
OptimizedCompilationInfo::OptimizedCompilationInfo(
|
||||
Zone* zone, Isolate* isolate, Handle<SharedFunctionInfo> shared,
|
||||
Handle<JSFunction> closure)
|
||||
: OptimizedCompilationInfo({}, AbstractCode::OPTIMIZED_FUNCTION, zone) {
|
||||
shared_info_ = shared;
|
||||
closure_ = closure;
|
||||
optimization_id_ = isolate->NextOptimizationId();
|
||||
@ -61,12 +44,12 @@ CompilationInfo::CompilationInfo(Zone* zone, Isolate* isolate,
|
||||
}
|
||||
}
|
||||
|
||||
CompilationInfo::CompilationInfo(Vector<const char> debug_name, Zone* zone,
|
||||
Code::Kind code_kind)
|
||||
: CompilationInfo(debug_name, static_cast<AbstractCode::Kind>(code_kind),
|
||||
zone) {
|
||||
OptimizedCompilationInfo::OptimizedCompilationInfo(
|
||||
Vector<const char> debug_name, Zone* zone, Code::Kind code_kind)
|
||||
: OptimizedCompilationInfo(
|
||||
debug_name, static_cast<AbstractCode::Kind>(code_kind), zone) {
|
||||
if (code_kind == Code::BYTECODE_HANDLER) {
|
||||
SetFlag(CompilationInfo::kCalledWithCodeStartRegister);
|
||||
SetFlag(OptimizedCompilationInfo::kCalledWithCodeStartRegister);
|
||||
}
|
||||
#if ENABLE_GDB_JIT_INTERFACE
|
||||
#if DEBUG
|
||||
@ -77,16 +60,13 @@ CompilationInfo::CompilationInfo(Vector<const char> debug_name, Zone* zone,
|
||||
#endif
|
||||
}
|
||||
|
||||
CompilationInfo::CompilationInfo(Vector<const char> debug_name,
|
||||
AbstractCode::Kind code_kind, Zone* zone)
|
||||
: literal_(nullptr),
|
||||
source_range_map_(nullptr),
|
||||
flags_(FLAG_untrusted_code_mitigations ? kUntrustedCodeMitigations : 0),
|
||||
OptimizedCompilationInfo::OptimizedCompilationInfo(
|
||||
Vector<const char> debug_name, AbstractCode::Kind code_kind, Zone* zone)
|
||||
: flags_(FLAG_untrusted_code_mitigations ? kUntrustedCodeMitigations : 0),
|
||||
code_kind_(code_kind),
|
||||
stub_key_(0),
|
||||
builtin_index_(Builtins::kNoBuiltinId),
|
||||
osr_offset_(BailoutId::None()),
|
||||
feedback_vector_spec_(zone),
|
||||
zone_(zone),
|
||||
deferred_handles_(nullptr),
|
||||
dependencies_(nullptr),
|
||||
@ -94,7 +74,7 @@ CompilationInfo::CompilationInfo(Vector<const char> debug_name,
|
||||
optimization_id_(-1),
|
||||
debug_name_(debug_name) {}
|
||||
|
||||
CompilationInfo::~CompilationInfo() {
|
||||
OptimizedCompilationInfo::~OptimizedCompilationInfo() {
|
||||
if (GetFlag(kDisableFutureOptimization) && has_shared_info()) {
|
||||
shared_info()->DisableOptimization(bailout_reason());
|
||||
}
|
||||
@ -103,33 +83,19 @@ CompilationInfo::~CompilationInfo() {
|
||||
}
|
||||
}
|
||||
|
||||
DeclarationScope* CompilationInfo::scope() const {
|
||||
DCHECK_NOT_NULL(literal_);
|
||||
return literal_->scope();
|
||||
}
|
||||
|
||||
int CompilationInfo::num_parameters() const {
|
||||
DCHECK(!IsStub());
|
||||
return scope()->num_parameters();
|
||||
}
|
||||
|
||||
int CompilationInfo::num_parameters_including_this() const {
|
||||
DCHECK(!IsStub());
|
||||
return scope()->num_parameters() + 1;
|
||||
}
|
||||
|
||||
void CompilationInfo::set_deferred_handles(
|
||||
void OptimizedCompilationInfo::set_deferred_handles(
|
||||
std::shared_ptr<DeferredHandles> deferred_handles) {
|
||||
DCHECK_NULL(deferred_handles_);
|
||||
deferred_handles_.swap(deferred_handles);
|
||||
}
|
||||
|
||||
void CompilationInfo::set_deferred_handles(DeferredHandles* deferred_handles) {
|
||||
void OptimizedCompilationInfo::set_deferred_handles(
|
||||
DeferredHandles* deferred_handles) {
|
||||
DCHECK_NULL(deferred_handles_);
|
||||
deferred_handles_.reset(deferred_handles);
|
||||
}
|
||||
|
||||
void CompilationInfo::ReopenHandlesInNewHandleScope() {
|
||||
void OptimizedCompilationInfo::ReopenHandlesInNewHandleScope() {
|
||||
if (!shared_info_.is_null()) {
|
||||
shared_info_ = Handle<SharedFunctionInfo>(*shared_info_);
|
||||
}
|
||||
@ -138,14 +104,7 @@ void CompilationInfo::ReopenHandlesInNewHandleScope() {
|
||||
}
|
||||
}
|
||||
|
||||
bool CompilationInfo::has_simple_parameters() {
|
||||
return scope()->has_simple_parameters();
|
||||
}
|
||||
|
||||
std::unique_ptr<char[]> CompilationInfo::GetDebugName() const {
|
||||
if (literal()) {
|
||||
return literal()->GetDebugName();
|
||||
}
|
||||
std::unique_ptr<char[]> OptimizedCompilationInfo::GetDebugName() const {
|
||||
if (!shared_info().is_null()) {
|
||||
return shared_info()->DebugName()->ToCString();
|
||||
}
|
||||
@ -157,7 +116,7 @@ std::unique_ptr<char[]> CompilationInfo::GetDebugName() const {
|
||||
return name;
|
||||
}
|
||||
|
||||
StackFrame::Type CompilationInfo::GetOutputStackFrameType() const {
|
||||
StackFrame::Type OptimizedCompilationInfo::GetOutputStackFrameType() const {
|
||||
switch (code_kind()) {
|
||||
case Code::STUB:
|
||||
case Code::BYTECODE_HANDLER:
|
||||
@ -179,38 +138,31 @@ StackFrame::Type CompilationInfo::GetOutputStackFrameType() const {
|
||||
}
|
||||
}
|
||||
|
||||
int CompilationInfo::GetDeclareGlobalsFlags() const {
|
||||
return DeclareGlobalsEvalFlag::encode(is_eval()) |
|
||||
DeclareGlobalsNativeFlag::encode(is_native());
|
||||
bool OptimizedCompilationInfo::has_context() const {
|
||||
return !closure().is_null();
|
||||
}
|
||||
|
||||
SourcePositionTableBuilder::RecordingMode
|
||||
CompilationInfo::SourcePositionRecordingMode() const {
|
||||
return is_native() ? SourcePositionTableBuilder::OMIT_SOURCE_POSITIONS
|
||||
: SourcePositionTableBuilder::RECORD_SOURCE_POSITIONS;
|
||||
}
|
||||
|
||||
bool CompilationInfo::has_context() const { return !closure().is_null(); }
|
||||
|
||||
Context* CompilationInfo::context() const {
|
||||
Context* OptimizedCompilationInfo::context() const {
|
||||
return has_context() ? closure()->context() : nullptr;
|
||||
}
|
||||
|
||||
bool CompilationInfo::has_native_context() const {
|
||||
bool OptimizedCompilationInfo::has_native_context() const {
|
||||
return !closure().is_null() && (closure()->native_context() != nullptr);
|
||||
}
|
||||
|
||||
Context* CompilationInfo::native_context() const {
|
||||
Context* OptimizedCompilationInfo::native_context() const {
|
||||
return has_native_context() ? closure()->native_context() : nullptr;
|
||||
}
|
||||
|
||||
bool CompilationInfo::has_global_object() const { return has_native_context(); }
|
||||
bool OptimizedCompilationInfo::has_global_object() const {
|
||||
return has_native_context();
|
||||
}
|
||||
|
||||
JSGlobalObject* CompilationInfo::global_object() const {
|
||||
JSGlobalObject* OptimizedCompilationInfo::global_object() const {
|
||||
return has_global_object() ? native_context()->global_object() : nullptr;
|
||||
}
|
||||
|
||||
int CompilationInfo::AddInlinedFunction(
|
||||
int OptimizedCompilationInfo::AddInlinedFunction(
|
||||
Handle<SharedFunctionInfo> inlined_function, SourcePosition pos) {
|
||||
int id = static_cast<int>(inlined_functions_.size());
|
||||
inlined_functions_.push_back(InlinedFunctionHolder(inlined_function, pos));
|
@ -2,8 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef V8_COMPILATION_INFO_H_
|
||||
#define V8_COMPILATION_INFO_H_
|
||||
#ifndef V8_OPTIMIZED_COMPILATION_INFO_H_
|
||||
#define V8_OPTIMIZED_COMPILATION_INFO_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
@ -30,39 +30,35 @@ class ParseInfo;
|
||||
class SourceRangeMap;
|
||||
class Zone;
|
||||
|
||||
// CompilationInfo encapsulates some information known at compile time. It
|
||||
// is constructed based on the resources available at compile-time.
|
||||
// TODO(rmcilroy): Split CompilationInfo into two classes, one for unoptimized
|
||||
// compilation and one for optimized compilation, since they don't share much.
|
||||
class V8_EXPORT_PRIVATE CompilationInfo final {
|
||||
// OptimizedCompilationInfo encapsulates the information needed to compile
|
||||
// optimized code for a given function, and the results of the optimized
|
||||
// compilation.
|
||||
class V8_EXPORT_PRIVATE OptimizedCompilationInfo final {
|
||||
public:
|
||||
// Various configuration flags for a compilation, as well as some properties
|
||||
// of the compiled code produced by a compilation.
|
||||
enum Flag {
|
||||
kIsEval = 1 << 0,
|
||||
kIsNative = 1 << 1,
|
||||
kCollectTypeProfile = 1 << 2,
|
||||
kAccessorInliningEnabled = 1 << 3,
|
||||
kFunctionContextSpecializing = 1 << 4,
|
||||
kInliningEnabled = 1 << 5,
|
||||
kPoisonLoads = 1 << 6,
|
||||
kDisableFutureOptimization = 1 << 7,
|
||||
kSplittingEnabled = 1 << 8,
|
||||
kSourcePositionsEnabled = 1 << 9,
|
||||
kBailoutOnUninitialized = 1 << 10,
|
||||
kLoopPeelingEnabled = 1 << 11,
|
||||
kUntrustedCodeMitigations = 1 << 12,
|
||||
kSwitchJumpTableEnabled = 1 << 13,
|
||||
kCalledWithCodeStartRegister = 1 << 14,
|
||||
kPoisonRegisterArguments = 1 << 15,
|
||||
kAllocationFoldingEnabled = 1 << 16,
|
||||
kAnalyzeEnvironmentLiveness = 1 << 17,
|
||||
kAccessorInliningEnabled = 1 << 0,
|
||||
kFunctionContextSpecializing = 1 << 1,
|
||||
kInliningEnabled = 1 << 2,
|
||||
kPoisonLoads = 1 << 3,
|
||||
kDisableFutureOptimization = 1 << 4,
|
||||
kSplittingEnabled = 1 << 5,
|
||||
kSourcePositionsEnabled = 1 << 6,
|
||||
kBailoutOnUninitialized = 1 << 7,
|
||||
kLoopPeelingEnabled = 1 << 8,
|
||||
kUntrustedCodeMitigations = 1 << 9,
|
||||
kSwitchJumpTableEnabled = 1 << 10,
|
||||
kCalledWithCodeStartRegister = 1 << 11,
|
||||
kPoisonRegisterArguments = 1 << 12,
|
||||
kAllocationFoldingEnabled = 1 << 13,
|
||||
kAnalyzeEnvironmentLiveness = 1 << 14,
|
||||
};
|
||||
|
||||
// TODO(mtrofin): investigate if this might be generalized outside wasm, with
|
||||
// the goal of better separating the compiler from where compilation lands. At
|
||||
// that point, the Handle<Code> member of CompilationInfo would also be
|
||||
// removed.
|
||||
// that point, the Handle<Code> member of OptimizedCompilationInfo would also
|
||||
// be removed.
|
||||
struct WasmCodeDesc {
|
||||
CodeDesc code_desc;
|
||||
size_t safepoint_table_offset = 0;
|
||||
@ -71,37 +67,19 @@ class V8_EXPORT_PRIVATE CompilationInfo final {
|
||||
Handle<ByteArray> source_positions_table;
|
||||
};
|
||||
|
||||
// Construct a compilation info for unoptimized compilation.
|
||||
CompilationInfo(Zone* zone, ParseInfo* parse_info, FunctionLiteral* literal);
|
||||
// Construct a compilation info for optimized compilation.
|
||||
CompilationInfo(Zone* zone, Isolate* isolate,
|
||||
Handle<SharedFunctionInfo> shared,
|
||||
Handle<JSFunction> closure);
|
||||
OptimizedCompilationInfo(Zone* zone, Isolate* isolate,
|
||||
Handle<SharedFunctionInfo> shared,
|
||||
Handle<JSFunction> closure);
|
||||
// Construct a compilation info for stub compilation (or testing).
|
||||
CompilationInfo(Vector<const char> debug_name, Zone* zone,
|
||||
Code::Kind code_kind);
|
||||
~CompilationInfo();
|
||||
OptimizedCompilationInfo(Vector<const char> debug_name, Zone* zone,
|
||||
Code::Kind code_kind);
|
||||
|
||||
FunctionLiteral* literal() const { return literal_; }
|
||||
void set_literal(FunctionLiteral* literal) {
|
||||
DCHECK_NOT_NULL(literal);
|
||||
literal_ = literal;
|
||||
}
|
||||
|
||||
bool has_source_range_map() const { return source_range_map_ != nullptr; }
|
||||
SourceRangeMap* source_range_map() const { return source_range_map_; }
|
||||
void set_source_range_map(SourceRangeMap* source_range_map) {
|
||||
source_range_map_ = source_range_map;
|
||||
}
|
||||
|
||||
DeclarationScope* scope() const;
|
||||
~OptimizedCompilationInfo();
|
||||
|
||||
Zone* zone() { return zone_; }
|
||||
bool is_osr() const { return !osr_offset_.IsNone(); }
|
||||
Handle<SharedFunctionInfo> shared_info() const { return shared_info_; }
|
||||
void set_shared_info(Handle<SharedFunctionInfo> shared_info) {
|
||||
shared_info_ = shared_info;
|
||||
}
|
||||
bool has_shared_info() const { return !shared_info().is_null(); }
|
||||
Handle<JSFunction> closure() const { return closure_; }
|
||||
Handle<Code> code() const { return code_; }
|
||||
@ -116,25 +94,6 @@ class V8_EXPORT_PRIVATE CompilationInfo final {
|
||||
void set_builtin_index(int32_t index) { builtin_index_ = index; }
|
||||
BailoutId osr_offset() const { return osr_offset_; }
|
||||
JavaScriptFrame* osr_frame() const { return osr_frame_; }
|
||||
int num_parameters() const;
|
||||
int num_parameters_including_this() const;
|
||||
|
||||
bool has_bytecode_array() const { return !bytecode_array_.is_null(); }
|
||||
Handle<BytecodeArray> bytecode_array() const { return bytecode_array_; }
|
||||
|
||||
bool has_asm_wasm_data() const { return !asm_wasm_data_.is_null(); }
|
||||
Handle<FixedArray> asm_wasm_data() const { return asm_wasm_data_; }
|
||||
|
||||
// Flags used by unoptimized compilation.
|
||||
|
||||
void MarkAsEval() { SetFlag(kIsEval); }
|
||||
bool is_eval() const { return GetFlag(kIsEval); }
|
||||
|
||||
void MarkAsNative() { SetFlag(kIsNative); }
|
||||
bool is_native() const { return GetFlag(kIsNative); }
|
||||
|
||||
void MarkAsCollectTypeProfile() { SetFlag(kCollectTypeProfile); }
|
||||
bool collect_type_profile() const { return GetFlag(kCollectTypeProfile); }
|
||||
|
||||
// Flags used by optimized compilation.
|
||||
|
||||
@ -212,16 +171,6 @@ class V8_EXPORT_PRIVATE CompilationInfo final {
|
||||
|
||||
void SetCode(Handle<Code> code) { code_ = code; }
|
||||
|
||||
void SetBytecodeArray(Handle<BytecodeArray> bytecode_array) {
|
||||
bytecode_array_ = bytecode_array;
|
||||
}
|
||||
|
||||
void SetAsmWasmData(Handle<FixedArray> asm_wasm_data) {
|
||||
asm_wasm_data_ = asm_wasm_data;
|
||||
}
|
||||
|
||||
FeedbackVectorSpec* feedback_vector_spec() { return &feedback_vector_spec_; }
|
||||
|
||||
bool has_context() const;
|
||||
Context* context() const;
|
||||
|
||||
@ -240,8 +189,7 @@ class V8_EXPORT_PRIVATE CompilationInfo final {
|
||||
}
|
||||
bool IsStub() const {
|
||||
return abstract_code_kind() != AbstractCode::OPTIMIZED_FUNCTION &&
|
||||
abstract_code_kind() != AbstractCode::WASM_FUNCTION &&
|
||||
abstract_code_kind() != AbstractCode::INTERPRETED_FUNCTION;
|
||||
abstract_code_kind() != AbstractCode::WASM_FUNCTION;
|
||||
}
|
||||
void SetOptimizingForOsr(BailoutId osr_offset, JavaScriptFrame* osr_frame) {
|
||||
DCHECK(IsOptimizing());
|
||||
@ -278,8 +226,6 @@ class V8_EXPORT_PRIVATE CompilationInfo final {
|
||||
return optimization_id_;
|
||||
}
|
||||
|
||||
bool has_simple_parameters();
|
||||
|
||||
struct InlinedFunctionHolder {
|
||||
Handle<SharedFunctionInfo> shared_info;
|
||||
|
||||
@ -309,33 +255,16 @@ class V8_EXPORT_PRIVATE CompilationInfo final {
|
||||
|
||||
StackFrame::Type GetOutputStackFrameType() const;
|
||||
|
||||
int GetDeclareGlobalsFlags() const;
|
||||
|
||||
SourcePositionTableBuilder::RecordingMode SourcePositionRecordingMode() const;
|
||||
|
||||
bool has_coverage_info() const { return !coverage_info_.is_null(); }
|
||||
Handle<CoverageInfo> coverage_info() const { return coverage_info_; }
|
||||
void set_coverage_info(Handle<CoverageInfo> coverage_info) {
|
||||
coverage_info_ = coverage_info;
|
||||
}
|
||||
|
||||
WasmCodeDesc* wasm_code_desc() { return &wasm_code_desc_; }
|
||||
|
||||
private:
|
||||
CompilationInfo(Vector<const char> debug_name, AbstractCode::Kind code_kind,
|
||||
Zone* zone);
|
||||
OptimizedCompilationInfo(Vector<const char> debug_name,
|
||||
AbstractCode::Kind code_kind, Zone* zone);
|
||||
|
||||
void SetFlag(Flag flag) { flags_ |= flag; }
|
||||
|
||||
void SetFlag(Flag flag, bool value) {
|
||||
flags_ = value ? flags_ | flag : flags_ & ~flag;
|
||||
}
|
||||
|
||||
bool GetFlag(Flag flag) const { return (flags_ & flag) != 0; }
|
||||
|
||||
FunctionLiteral* literal_;
|
||||
SourceRangeMap* source_range_map_; // Used when block coverage is enabled.
|
||||
|
||||
// Compilation flags.
|
||||
unsigned flags_;
|
||||
|
||||
AbstractCode::Kind code_kind_;
|
||||
@ -353,19 +282,8 @@ class V8_EXPORT_PRIVATE CompilationInfo final {
|
||||
// Entry point when compiling for OSR, {BailoutId::None} otherwise.
|
||||
BailoutId osr_offset_;
|
||||
|
||||
// Holds the bytecode array generated by the interpreter.
|
||||
// TODO(rmcilroy/mstarzinger): Temporary work-around until compiler.cc is
|
||||
// refactored to avoid us needing to carry the BytcodeArray around.
|
||||
Handle<BytecodeArray> bytecode_array_;
|
||||
|
||||
// Holds the asm_wasm array generated by the asmjs compiler.
|
||||
Handle<FixedArray> asm_wasm_data_;
|
||||
|
||||
// Holds the feedback vector spec generated during compilation
|
||||
FeedbackVectorSpec feedback_vector_spec_;
|
||||
|
||||
// The zone from which the compilation pipeline working on this
|
||||
// CompilationInfo allocates.
|
||||
// OptimizedCompilationInfo allocates.
|
||||
Zone* zone_;
|
||||
|
||||
std::shared_ptr<DeferredHandles> deferred_handles_;
|
||||
@ -384,14 +302,10 @@ class V8_EXPORT_PRIVATE CompilationInfo final {
|
||||
|
||||
Vector<const char> debug_name_;
|
||||
|
||||
// Encapsulates coverage information gathered by the bytecode generator.
|
||||
// Needs to be stored on the shared function info once compilation completes.
|
||||
Handle<CoverageInfo> coverage_info_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(CompilationInfo);
|
||||
DISALLOW_COPY_AND_ASSIGN(OptimizedCompilationInfo);
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
#endif // V8_COMPILATION_INFO_H_
|
||||
#endif // V8_OPTIMIZED_COMPILATION_INFO_H_
|
@ -3,8 +3,8 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "src/source-position.h"
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -50,7 +50,7 @@ std::ostream& operator<<(std::ostream& out, const SourcePosition& pos) {
|
||||
}
|
||||
|
||||
std::vector<SourcePositionInfo> SourcePosition::InliningStack(
|
||||
CompilationInfo* cinfo) const {
|
||||
OptimizedCompilationInfo* cinfo) const {
|
||||
SourcePosition pos = *this;
|
||||
std::vector<SourcePositionInfo> stack;
|
||||
while (pos.isInlined()) {
|
||||
|
@ -16,7 +16,7 @@ namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
class Code;
|
||||
class CompilationInfo;
|
||||
class OptimizedCompilationInfo;
|
||||
class Script;
|
||||
class SharedFunctionInfo;
|
||||
struct SourcePositionInfo;
|
||||
@ -26,7 +26,7 @@ struct SourcePositionInfo;
|
||||
// - inlining_id (16 bit non-negative int or kNotInlined).
|
||||
//
|
||||
// A defined inlining_id refers to positions in
|
||||
// CompilationInfo::inlined_functions or
|
||||
// OptimizedCompilationInfo::inlined_functions or
|
||||
// DeoptimizationData::InliningPositions, depending on the compilation stage.
|
||||
class SourcePosition final {
|
||||
public:
|
||||
@ -44,7 +44,8 @@ class SourcePosition final {
|
||||
|
||||
// Assumes that the code object is optimized
|
||||
std::vector<SourcePositionInfo> InliningStack(Handle<Code> code) const;
|
||||
std::vector<SourcePositionInfo> InliningStack(CompilationInfo* cinfo) const;
|
||||
std::vector<SourcePositionInfo> InliningStack(
|
||||
OptimizedCompilationInfo* cinfo) const;
|
||||
|
||||
void Print(std::ostream& out, Code* code) const;
|
||||
|
||||
|
64
src/unoptimized-compilation-info.cc
Normal file
64
src/unoptimized-compilation-info.cc
Normal file
@ -0,0 +1,64 @@
|
||||
// Copyright 2018 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "src/unoptimized-compilation-info.h"
|
||||
|
||||
#include "src/api.h"
|
||||
#include "src/ast/ast.h"
|
||||
#include "src/ast/scopes.h"
|
||||
#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 {
|
||||
|
||||
UnoptimizedCompilationInfo::UnoptimizedCompilationInfo(Zone* zone,
|
||||
ParseInfo* parse_info,
|
||||
FunctionLiteral* literal)
|
||||
: flags_(FLAG_untrusted_code_mitigations ? kUntrustedCodeMitigations : 0),
|
||||
zone_(zone),
|
||||
feedback_vector_spec_(zone) {
|
||||
// NOTE: The parse_info passed here represents the global information gathered
|
||||
// during parsing, but does not represent specific details of the actual
|
||||
// function literal being compiled for this OptimizedCompilationInfo. As such,
|
||||
// parse_info->literal() might be different from literal, and only global
|
||||
// details of the script being parsed are relevant to this
|
||||
// OptimizedCompilationInfo.
|
||||
DCHECK_NOT_NULL(literal);
|
||||
literal_ = literal;
|
||||
source_range_map_ = parse_info->source_range_map();
|
||||
|
||||
if (parse_info->is_eval()) MarkAsEval();
|
||||
if (parse_info->is_native()) MarkAsNative();
|
||||
if (parse_info->collect_type_profile()) MarkAsCollectTypeProfile();
|
||||
}
|
||||
|
||||
DeclarationScope* UnoptimizedCompilationInfo::scope() const {
|
||||
DCHECK_NOT_NULL(literal_);
|
||||
return literal_->scope();
|
||||
}
|
||||
|
||||
int UnoptimizedCompilationInfo::num_parameters() const {
|
||||
return scope()->num_parameters();
|
||||
}
|
||||
|
||||
int UnoptimizedCompilationInfo::num_parameters_including_this() const {
|
||||
return scope()->num_parameters() + 1;
|
||||
}
|
||||
|
||||
bool UnoptimizedCompilationInfo::has_simple_parameters() {
|
||||
return scope()->has_simple_parameters();
|
||||
}
|
||||
|
||||
SourcePositionTableBuilder::RecordingMode
|
||||
UnoptimizedCompilationInfo::SourcePositionRecordingMode() const {
|
||||
return is_native() ? SourcePositionTableBuilder::OMIT_SOURCE_POSITIONS
|
||||
: SourcePositionTableBuilder::RECORD_SOURCE_POSITIONS;
|
||||
}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
138
src/unoptimized-compilation-info.h
Normal file
138
src/unoptimized-compilation-info.h
Normal file
@ -0,0 +1,138 @@
|
||||
// Copyright 2018 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef V8_UNOPTIMIZED_COMPILATION_INFO_H_
|
||||
#define V8_UNOPTIMIZED_COMPILATION_INFO_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "src/feedback-vector.h"
|
||||
#include "src/globals.h"
|
||||
#include "src/handles.h"
|
||||
#include "src/objects.h"
|
||||
#include "src/source-position-table.h"
|
||||
#include "src/utils.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
|
||||
class CoverageInfo;
|
||||
class DeclarationScope;
|
||||
class FunctionLiteral;
|
||||
class Isolate;
|
||||
class ParseInfo;
|
||||
class SourceRangeMap;
|
||||
class Zone;
|
||||
|
||||
// UnoptimizedCompilationInfo encapsulates the information needed to compile
|
||||
// unoptimized code for a given function, and the results of the compilation.
|
||||
class V8_EXPORT_PRIVATE UnoptimizedCompilationInfo final {
|
||||
public:
|
||||
UnoptimizedCompilationInfo(Zone* zone, ParseInfo* parse_info,
|
||||
FunctionLiteral* literal);
|
||||
|
||||
Zone* zone() { return zone_; }
|
||||
|
||||
// Compilation flag accessors.
|
||||
|
||||
void MarkAsEval() { SetFlag(kIsEval); }
|
||||
bool is_eval() const { return GetFlag(kIsEval); }
|
||||
|
||||
void MarkAsNative() { SetFlag(kIsNative); }
|
||||
bool is_native() const { return GetFlag(kIsNative); }
|
||||
|
||||
void MarkAsCollectTypeProfile() { SetFlag(kCollectTypeProfile); }
|
||||
bool collect_type_profile() const { return GetFlag(kCollectTypeProfile); }
|
||||
|
||||
// Accessors for the input data of the function being compiled.
|
||||
|
||||
FunctionLiteral* literal() const { return literal_; }
|
||||
void set_literal(FunctionLiteral* literal) {
|
||||
DCHECK_NOT_NULL(literal);
|
||||
literal_ = literal;
|
||||
}
|
||||
|
||||
DeclarationScope* scope() const;
|
||||
|
||||
bool has_simple_parameters();
|
||||
|
||||
int num_parameters() const;
|
||||
int num_parameters_including_this() const;
|
||||
|
||||
// Accessors for optional compilation features.
|
||||
|
||||
SourcePositionTableBuilder::RecordingMode SourcePositionRecordingMode() const;
|
||||
|
||||
bool has_source_range_map() const { return source_range_map_ != nullptr; }
|
||||
SourceRangeMap* source_range_map() const { return source_range_map_; }
|
||||
void set_source_range_map(SourceRangeMap* source_range_map) {
|
||||
source_range_map_ = source_range_map;
|
||||
}
|
||||
|
||||
bool has_coverage_info() const { return !coverage_info_.is_null(); }
|
||||
Handle<CoverageInfo> coverage_info() const { return coverage_info_; }
|
||||
void set_coverage_info(Handle<CoverageInfo> coverage_info) {
|
||||
coverage_info_ = coverage_info;
|
||||
}
|
||||
|
||||
// Accessors for the output of compilation.
|
||||
|
||||
bool has_bytecode_array() const { return !bytecode_array_.is_null(); }
|
||||
Handle<BytecodeArray> bytecode_array() const { return bytecode_array_; }
|
||||
void SetBytecodeArray(Handle<BytecodeArray> bytecode_array) {
|
||||
bytecode_array_ = bytecode_array;
|
||||
}
|
||||
|
||||
bool has_asm_wasm_data() const { return !asm_wasm_data_.is_null(); }
|
||||
Handle<FixedArray> asm_wasm_data() const { return asm_wasm_data_; }
|
||||
void SetAsmWasmData(Handle<FixedArray> asm_wasm_data) {
|
||||
asm_wasm_data_ = asm_wasm_data;
|
||||
}
|
||||
|
||||
FeedbackVectorSpec* feedback_vector_spec() { return &feedback_vector_spec_; }
|
||||
|
||||
private:
|
||||
// Various configuration flags for a compilation, as well as some properties
|
||||
// of the compiled code produced by a compilation.
|
||||
enum Flag {
|
||||
kIsEval = 1 << 0,
|
||||
kIsNative = 1 << 1,
|
||||
kCollectTypeProfile = 1 << 2,
|
||||
kUntrustedCodeMitigations = 1 << 3,
|
||||
};
|
||||
|
||||
void SetFlag(Flag flag) { flags_ |= flag; }
|
||||
bool GetFlag(Flag flag) const { return (flags_ & flag) != 0; }
|
||||
|
||||
// Compilation flags.
|
||||
unsigned flags_;
|
||||
|
||||
// The zone from which the compilation pipeline working on this
|
||||
// OptimizedCompilationInfo allocates.
|
||||
Zone* zone_;
|
||||
|
||||
// The root AST node of the function literal being compiled.
|
||||
FunctionLiteral* literal_;
|
||||
|
||||
// Used when block coverage is enabled.
|
||||
SourceRangeMap* source_range_map_;
|
||||
|
||||
// Encapsulates coverage information gathered by the bytecode generator.
|
||||
// Needs to be stored on the shared function info once compilation completes.
|
||||
Handle<CoverageInfo> coverage_info_;
|
||||
|
||||
// Holds the bytecode array generated by the interpreter.
|
||||
Handle<BytecodeArray> bytecode_array_;
|
||||
|
||||
// Holds the asm_wasm array generated by the asmjs compiler.
|
||||
Handle<FixedArray> asm_wasm_data_;
|
||||
|
||||
// Holds the feedback vector spec generated during compilation
|
||||
FeedbackVectorSpec feedback_vector_spec_;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
||||
#endif // V8_UNOPTIMIZED_COMPILATION_INFO_H_
|
@ -5,10 +5,10 @@
|
||||
#ifndef V8_CCTEST_COMPILER_CODEGEN_TESTER_H_
|
||||
#define V8_CCTEST_COMPILER_CODEGEN_TESTER_H_
|
||||
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler/instruction-selector.h"
|
||||
#include "src/compiler/pipeline.h"
|
||||
#include "src/compiler/raw-machine-assembler.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
#include "src/simulator.h"
|
||||
#include "test/cctest/cctest.h"
|
||||
#include "test/cctest/compiler/call-tester.h"
|
||||
@ -64,7 +64,8 @@ class RawMachineAssemblerTester : public HandleAndZoneScope,
|
||||
Schedule* schedule = this->Export();
|
||||
auto call_descriptor = this->call_descriptor();
|
||||
Graph* graph = this->graph();
|
||||
CompilationInfo info(ArrayVector("testing"), main_zone(), Code::STUB);
|
||||
OptimizedCompilationInfo info(ArrayVector("testing"), main_zone(),
|
||||
Code::STUB);
|
||||
code_ = Pipeline::GenerateCodeForTesting(
|
||||
&info, main_isolate(), call_descriptor, graph, schedule);
|
||||
}
|
||||
|
@ -5,13 +5,13 @@
|
||||
#include "test/cctest/compiler/function-tester.h"
|
||||
|
||||
#include "src/api.h"
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler.h"
|
||||
#include "src/compiler/linkage.h"
|
||||
#include "src/compiler/pipeline.h"
|
||||
#include "src/execution.h"
|
||||
#include "src/handles.h"
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
#include "src/parsing/parse-info.h"
|
||||
#include "test/cctest/cctest.h"
|
||||
|
||||
@ -24,7 +24,7 @@ FunctionTester::FunctionTester(const char* source, uint32_t flags)
|
||||
function((FLAG_allow_natives_syntax = true, NewFunction(source))),
|
||||
flags_(flags) {
|
||||
Compile(function);
|
||||
const uint32_t supported_flags = CompilationInfo::kInliningEnabled;
|
||||
const uint32_t supported_flags = OptimizedCompilationInfo::kInliningEnabled;
|
||||
CHECK_EQ(0u, flags_ & ~supported_flags);
|
||||
}
|
||||
|
||||
@ -139,10 +139,10 @@ 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(), function->GetIsolate(), shared,
|
||||
function);
|
||||
OptimizedCompilationInfo info(parse_info.zone(), function->GetIsolate(),
|
||||
shared, function);
|
||||
|
||||
if (flags_ & CompilationInfo::kInliningEnabled) {
|
||||
if (flags_ & OptimizedCompilationInfo::kInliningEnabled) {
|
||||
info.MarkAsInliningEnabled();
|
||||
}
|
||||
|
||||
@ -165,8 +165,8 @@ 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(), function->GetIsolate(), shared,
|
||||
function);
|
||||
OptimizedCompilationInfo info(parse_info.zone(), function->GetIsolate(),
|
||||
shared, function);
|
||||
|
||||
Handle<Code> code =
|
||||
Pipeline::GenerateCodeForTesting(&info, function->GetIsolate(), graph);
|
||||
|
@ -5,7 +5,6 @@
|
||||
#ifndef V8_CCTEST_COMPILER_GRAPH_BUILDER_TESTER_H_
|
||||
#define V8_CCTEST_COMPILER_GRAPH_BUILDER_TESTER_H_
|
||||
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler/common-operator.h"
|
||||
#include "src/compiler/instruction-selector.h"
|
||||
#include "src/compiler/linkage.h"
|
||||
@ -13,6 +12,7 @@
|
||||
#include "src/compiler/operator-properties.h"
|
||||
#include "src/compiler/pipeline.h"
|
||||
#include "src/compiler/simplified-operator.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
#include "test/cctest/cctest.h"
|
||||
#include "test/cctest/compiler/call-tester.h"
|
||||
|
||||
@ -249,7 +249,8 @@ class GraphBuilderTester : public HandleAndZoneScope,
|
||||
Zone* zone = graph()->zone();
|
||||
auto call_descriptor =
|
||||
Linkage::GetSimplifiedCDescriptor(zone, this->csig_);
|
||||
CompilationInfo info(ArrayVector("testing"), main_zone(), Code::STUB);
|
||||
OptimizedCompilationInfo info(ArrayVector("testing"), main_zone(),
|
||||
Code::STUB);
|
||||
code_ = Pipeline::GenerateCodeForTesting(&info, main_isolate(),
|
||||
call_descriptor, graph());
|
||||
#ifdef ENABLE_DISASSEMBLER
|
||||
|
@ -6,12 +6,12 @@
|
||||
#include "src/base/utils/random-number-generator.h"
|
||||
#include "src/code-stub-assembler.h"
|
||||
#include "src/codegen.h"
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler/code-generator.h"
|
||||
#include "src/compiler/instruction.h"
|
||||
#include "src/compiler/linkage.h"
|
||||
#include "src/isolate.h"
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
|
||||
#include "test/cctest/cctest.h"
|
||||
#include "test/cctest/compiler/code-assembler-tester.h"
|
||||
@ -1068,7 +1068,7 @@ class CodeGeneratorTester {
|
||||
|
||||
private:
|
||||
Zone* zone_;
|
||||
CompilationInfo info_;
|
||||
OptimizedCompilationInfo info_;
|
||||
Linkage linkage_;
|
||||
Frame frame_;
|
||||
CodeGenerator generator_;
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include "src/api.h"
|
||||
#include "src/code-factory.h"
|
||||
#include "src/code-stubs.h"
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler.h"
|
||||
#include "src/compiler/common-operator.h"
|
||||
#include "src/compiler/graph.h"
|
||||
@ -16,6 +15,7 @@
|
||||
#include "src/compiler/pipeline.h"
|
||||
#include "src/compiler/schedule.h"
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
#include "src/parsing/parse-info.h"
|
||||
#include "src/zone/zone.h"
|
||||
#include "test/cctest/cctest.h"
|
||||
@ -48,8 +48,8 @@ TEST(TestLinkageCreate) {
|
||||
HandleAndZoneScope handles;
|
||||
Handle<JSFunction> function = Compile("a + b");
|
||||
Handle<SharedFunctionInfo> shared(function->shared());
|
||||
CompilationInfo info(handles.main_zone(), function->GetIsolate(), shared,
|
||||
function);
|
||||
OptimizedCompilationInfo info(handles.main_zone(), function->GetIsolate(),
|
||||
shared, function);
|
||||
auto call_descriptor = Linkage::ComputeIncoming(info.zone(), &info);
|
||||
CHECK(call_descriptor);
|
||||
}
|
||||
@ -65,8 +65,8 @@ TEST(TestLinkageJSFunctionIncoming) {
|
||||
Handle<JSFunction>::cast(v8::Utils::OpenHandle(
|
||||
*v8::Local<v8::Function>::Cast(CompileRun(sources[i]))));
|
||||
Handle<SharedFunctionInfo> shared(function->shared());
|
||||
CompilationInfo info(handles.main_zone(), function->GetIsolate(), shared,
|
||||
function);
|
||||
OptimizedCompilationInfo info(handles.main_zone(), function->GetIsolate(),
|
||||
shared, function);
|
||||
auto call_descriptor = Linkage::ComputeIncoming(info.zone(), &info);
|
||||
CHECK(call_descriptor);
|
||||
|
||||
@ -82,8 +82,8 @@ TEST(TestLinkageJSCall) {
|
||||
HandleAndZoneScope handles;
|
||||
Handle<JSFunction> function = Compile("a + c");
|
||||
Handle<SharedFunctionInfo> shared(function->shared());
|
||||
CompilationInfo info(handles.main_zone(), function->GetIsolate(), shared,
|
||||
function);
|
||||
OptimizedCompilationInfo info(handles.main_zone(), function->GetIsolate(),
|
||||
shared, function);
|
||||
|
||||
for (int i = 0; i < 32; i++) {
|
||||
auto call_descriptor = Linkage::GetJSCallDescriptor(
|
||||
@ -106,7 +106,7 @@ TEST(TestLinkageStubCall) {
|
||||
Isolate* isolate = CcTest::InitIsolateOnce();
|
||||
Zone zone(isolate->allocator(), ZONE_NAME);
|
||||
Callable callable = Builtins::CallableFor(isolate, Builtins::kToNumber);
|
||||
CompilationInfo info(ArrayVector("test"), &zone, Code::STUB);
|
||||
OptimizedCompilationInfo info(ArrayVector("test"), &zone, Code::STUB);
|
||||
auto call_descriptor = Linkage::GetStubCallDescriptor(
|
||||
isolate, &zone, callable.descriptor(), 0, CallDescriptor::kNoFlags,
|
||||
Operator::kNoProperties);
|
||||
|
@ -157,8 +157,8 @@ void TestReturnMultipleValues(MachineType type) {
|
||||
}
|
||||
m.Return(count, returns.get());
|
||||
|
||||
CompilationInfo info(ArrayVector("testing"), handles.main_zone(),
|
||||
Code::STUB);
|
||||
OptimizedCompilationInfo info(ArrayVector("testing"), handles.main_zone(),
|
||||
Code::STUB);
|
||||
Handle<Code> code = Pipeline::GenerateCodeForTesting(
|
||||
&info, handles.main_isolate(), desc, m.graph(), m.Export());
|
||||
#ifdef ENABLE_DISASSEMBLER
|
||||
@ -250,8 +250,8 @@ void ReturnLastValue(MachineType type) {
|
||||
|
||||
m.Return(return_count, returns.get());
|
||||
|
||||
CompilationInfo info(ArrayVector("testing"), handles.main_zone(),
|
||||
Code::STUB);
|
||||
OptimizedCompilationInfo info(ArrayVector("testing"), handles.main_zone(),
|
||||
Code::STUB);
|
||||
Handle<Code> code = Pipeline::GenerateCodeForTesting(
|
||||
&info, handles.main_isolate(), desc, m.graph(), m.Export());
|
||||
|
||||
@ -310,8 +310,8 @@ void ReturnSumOfReturns(MachineType type) {
|
||||
|
||||
m.Return(return_count, returns.get());
|
||||
|
||||
CompilationInfo info(ArrayVector("testing"), handles.main_zone(),
|
||||
Code::STUB);
|
||||
OptimizedCompilationInfo info(ArrayVector("testing"), handles.main_zone(),
|
||||
Code::STUB);
|
||||
Handle<Code> code = Pipeline::GenerateCodeForTesting(
|
||||
&info, handles.main_isolate(), desc, m.graph(), m.Export());
|
||||
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include <utility>
|
||||
|
||||
#include "src/api.h"
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler/pipeline.h"
|
||||
#include "src/debug/debug-interface.h"
|
||||
#include "src/execution.h"
|
||||
@ -13,6 +12,7 @@
|
||||
#include "src/interpreter/bytecode-array-builder.h"
|
||||
#include "src/interpreter/interpreter.h"
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
#include "src/parsing/parse-info.h"
|
||||
#include "test/cctest/cctest.h"
|
||||
|
||||
@ -119,8 +119,8 @@ class BytecodeGraphTester {
|
||||
|
||||
Zone zone(function->GetIsolate()->allocator(), ZONE_NAME);
|
||||
Handle<SharedFunctionInfo> shared(function->shared());
|
||||
CompilationInfo compilation_info(&zone, function->GetIsolate(), shared,
|
||||
function);
|
||||
OptimizedCompilationInfo compilation_info(&zone, function->GetIsolate(),
|
||||
shared, function);
|
||||
|
||||
// Compiler relies on canonicalized handles, let's create
|
||||
// a canonicalized scope and migrate existing handles there.
|
||||
|
@ -2,16 +2,15 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/objects/string.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
#include "test/cctest/compiler/function-tester.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
namespace compiler {
|
||||
|
||||
uint32_t flags = CompilationInfo::kInliningEnabled;
|
||||
|
||||
uint32_t flags = OptimizedCompilationInfo::kInliningEnabled;
|
||||
|
||||
TEST(Call) {
|
||||
FunctionTester T("(function(a,b) { return %_Call(b, a, 1, 2, 3); })", flags);
|
||||
|
@ -255,7 +255,8 @@ class Int32Signature : public MachineSignature {
|
||||
Handle<Code> CompileGraph(const char* name, CallDescriptor* call_descriptor,
|
||||
Graph* graph, Schedule* schedule = nullptr) {
|
||||
Isolate* isolate = CcTest::InitIsolateOnce();
|
||||
CompilationInfo info(ArrayVector("testing"), graph->zone(), Code::STUB);
|
||||
OptimizedCompilationInfo info(ArrayVector("testing"), graph->zone(),
|
||||
Code::STUB);
|
||||
Handle<Code> code = Pipeline::GenerateCodeForTesting(
|
||||
&info, isolate, call_descriptor, graph, schedule);
|
||||
CHECK(!code.is_null());
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include "src/bootstrapper.h"
|
||||
#include "src/callable.h"
|
||||
#include "src/code-stubs.h"
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler/common-operator.h"
|
||||
#include "src/compiler/graph.h"
|
||||
#include "src/compiler/js-graph.h"
|
||||
@ -14,6 +13,7 @@
|
||||
#include "src/compiler/machine-operator.h"
|
||||
#include "src/compiler/pipeline.h"
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
#include "test/cctest/compiler/function-tester.h"
|
||||
|
||||
namespace v8 {
|
||||
@ -93,7 +93,7 @@ class StubTester {
|
||||
}
|
||||
|
||||
Zone* zone_;
|
||||
CompilationInfo info_;
|
||||
OptimizedCompilationInfo info_;
|
||||
CallInterfaceDescriptor interface_descriptor_;
|
||||
CallDescriptor* descriptor_;
|
||||
Graph graph_;
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
#include "src/compilation-cache.h"
|
||||
#include "src/compilation-dependencies.h"
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/execution.h"
|
||||
#include "src/factory.h"
|
||||
#include "src/field-type.h"
|
||||
@ -19,6 +18,7 @@
|
||||
#include "src/ic/stub-cache.h"
|
||||
#include "src/macro-assembler.h"
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
#include "src/property.h"
|
||||
#include "src/transitions.h"
|
||||
|
||||
|
@ -383,8 +383,8 @@ Handle<Code> WasmFunctionWrapper::GetWrapperCode() {
|
||||
r.LowerGraph();
|
||||
}
|
||||
|
||||
CompilationInfo info(ArrayVector("testing"), graph()->zone(),
|
||||
Code::C_WASM_ENTRY);
|
||||
OptimizedCompilationInfo info(ArrayVector("testing"), graph()->zone(),
|
||||
Code::C_WASM_ENTRY);
|
||||
code_ = compiler::Pipeline::GenerateCodeForTesting(
|
||||
&info, isolate, call_descriptor, graph(), nullptr);
|
||||
CHECK(!code_.is_null());
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler/graph.h"
|
||||
#include "src/compiler/instruction-selector.h"
|
||||
#include "src/compiler/linkage.h"
|
||||
@ -17,6 +16,7 @@
|
||||
#include "src/machine-type.h"
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/objects.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
#include "src/simulator.h"
|
||||
#include "src/wasm/wasm-engine.h"
|
||||
#include "src/wasm/wasm-limits.h"
|
||||
@ -249,7 +249,7 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
}
|
||||
callee.Return(static_cast<int>(desc->ReturnCount()), returns.get());
|
||||
|
||||
CompilationInfo info(ArrayVector("testing"), &zone, Code::STUB);
|
||||
OptimizedCompilationInfo info(ArrayVector("testing"), &zone, Code::STUB);
|
||||
Handle<Code> code = Pipeline::GenerateCodeForTesting(
|
||||
&info, i_isolate, desc, callee.graph(), callee.Export());
|
||||
|
||||
@ -292,7 +292,8 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||
caller.Return(ret);
|
||||
|
||||
// Call the wrapper.
|
||||
CompilationInfo wrapper_info(ArrayVector("wrapper"), &zone, Code::STUB);
|
||||
OptimizedCompilationInfo wrapper_info(ArrayVector("wrapper"), &zone,
|
||||
Code::STUB);
|
||||
Handle<Code> wrapper_code = Pipeline::GenerateCodeForTesting(
|
||||
&wrapper_info, i_isolate, wrapper_desc, caller.graph(), caller.Export());
|
||||
auto fn = GeneratedCode<int32_t>::FromCode(*wrapper_code);
|
||||
|
@ -6,11 +6,11 @@
|
||||
|
||||
#include "src/base/atomic-utils.h"
|
||||
#include "src/base/platform/semaphore.h"
|
||||
#include "src/compilation-info.h"
|
||||
#include "src/compiler.h"
|
||||
#include "src/handles.h"
|
||||
#include "src/isolate.h"
|
||||
#include "src/objects-inl.h"
|
||||
#include "src/optimized-compilation-info.h"
|
||||
#include "src/parsing/parse-info.h"
|
||||
#include "test/unittests/test-helpers.h"
|
||||
#include "test/unittests/test-utils.h"
|
||||
@ -23,12 +23,12 @@ typedef TestWithNativeContext OptimizingCompileDispatcherTest;
|
||||
|
||||
namespace {
|
||||
|
||||
class BlockingCompilationJob : public CompilationJob {
|
||||
class BlockingCompilationJob : public OptimizedCompilationJob {
|
||||
public:
|
||||
BlockingCompilationJob(Isolate* isolate, Handle<JSFunction> function)
|
||||
: CompilationJob(isolate->stack_guard()->real_climit(), &parse_info_,
|
||||
&info_, "BlockingCompilationJob",
|
||||
State::kReadyToExecute),
|
||||
: OptimizedCompilationJob(isolate->stack_guard()->real_climit(),
|
||||
&parse_info_, &info_, "BlockingCompilationJob",
|
||||
State::kReadyToExecute),
|
||||
shared_(function->shared()),
|
||||
parse_info_(shared_),
|
||||
info_(parse_info_.zone(), function->GetIsolate(), shared_, function),
|
||||
@ -39,7 +39,7 @@ class BlockingCompilationJob : public CompilationJob {
|
||||
bool IsBlocking() const { return blocking_.Value(); }
|
||||
void Signal() { semaphore_.Signal(); }
|
||||
|
||||
// CompilationJob implementation.
|
||||
// OptimiziedCompilationJob implementation.
|
||||
Status PrepareJobImpl(Isolate* isolate) override { UNREACHABLE(); }
|
||||
|
||||
Status ExecuteJobImpl() override {
|
||||
@ -54,7 +54,7 @@ class BlockingCompilationJob : public CompilationJob {
|
||||
private:
|
||||
Handle<SharedFunctionInfo> shared_;
|
||||
ParseInfo parse_info_;
|
||||
CompilationInfo info_;
|
||||
OptimizedCompilationInfo info_;
|
||||
base::AtomicValue<bool> blocking_;
|
||||
base::Semaphore semaphore_;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user