Commit 1fc93f2e authored by rmcilroy's avatar rmcilroy Committed by Commit bot

[Compiler] Enable use of seperate zones for parsing and compiling.

In order to allow parallel compilation of eager inner functions, we need to
seperate the zone used for parsing (which will be shared between all the
parallel compile jobs) and the zone used for compilation. This CL changes
CompilationInfo to require a zone (which can be different from the zone in
ParseInfo). We then seal the ParseInfo zone after parsing and analysis is done
to prevent any further allocation in that zone, so that it can be shared
(read-only) with the parallel compile jobs.

BUG=v8:5203

Review-Url: https://codereview.chromium.org/2645403002
Cr-Commit-Position: refs/heads/master@{#43089}
parent 7ef8cb56
...@@ -53,10 +53,10 @@ bool CompilationInfo::has_shared_info() const { ...@@ -53,10 +53,10 @@ bool CompilationInfo::has_shared_info() const {
return parse_info_ && !parse_info_->shared_info().is_null(); return parse_info_ && !parse_info_->shared_info().is_null();
} }
CompilationInfo::CompilationInfo(ParseInfo* parse_info, CompilationInfo::CompilationInfo(Zone* zone, ParseInfo* parse_info,
Handle<JSFunction> closure) Handle<JSFunction> closure)
: CompilationInfo(parse_info, {}, Code::ComputeFlags(Code::FUNCTION), BASE, : CompilationInfo(parse_info, {}, Code::ComputeFlags(Code::FUNCTION), BASE,
parse_info->isolate(), parse_info->zone()) { parse_info->isolate(), zone) {
closure_ = closure; closure_ = closure;
// Compiling for the snapshot typically results in different code than // Compiling for the snapshot typically results in different code than
......
...@@ -53,7 +53,8 @@ class V8_EXPORT_PRIVATE CompilationInfo final { ...@@ -53,7 +53,8 @@ class V8_EXPORT_PRIVATE CompilationInfo final {
kLoopPeelingEnabled = 1 << 16, kLoopPeelingEnabled = 1 << 16,
}; };
CompilationInfo(ParseInfo* parse_info, Handle<JSFunction> closure); CompilationInfo(Zone* zone, ParseInfo* parse_info,
Handle<JSFunction> closure);
CompilationInfo(Vector<const char> debug_name, Isolate* isolate, Zone* zone, CompilationInfo(Vector<const char> debug_name, Isolate* isolate, Zone* zone,
Code::Flags code_flags); Code::Flags code_flags);
~CompilationInfo(); ~CompilationInfo();
......
...@@ -97,8 +97,8 @@ CompilerDispatcherJob::CompilerDispatcherJob(Isolate* isolate, ...@@ -97,8 +97,8 @@ CompilerDispatcherJob::CompilerDispatcherJob(Isolate* isolate,
max_stack_size_(max_stack_size), max_stack_size_(max_stack_size),
parse_info_( parse_info_(
new ParseInfo(Handle<Script>(Script::cast(shared->script())))), new ParseInfo(Handle<Script>(Script::cast(shared->script())))),
compile_info_( compile_info_(new CompilationInfo(parse_info_->zone(), parse_info_.get(),
new CompilationInfo(parse_info_.get(), Handle<JSFunction>::null())), Handle<JSFunction>::null())),
trace_compiler_dispatcher_jobs_(FLAG_trace_compiler_dispatcher_jobs) { trace_compiler_dispatcher_jobs_(FLAG_trace_compiler_dispatcher_jobs) {
parse_info_->set_literal(literal); parse_info_->set_literal(literal);
parse_info_->set_shared_info(shared); parse_info_->set_shared_info(shared);
...@@ -318,8 +318,8 @@ bool CompilerDispatcherJob::AnalyzeOnMainThread() { ...@@ -318,8 +318,8 @@ bool CompilerDispatcherJob::AnalyzeOnMainThread() {
PrintF("CompilerDispatcherJob[%p]: Analyzing\n", static_cast<void*>(this)); PrintF("CompilerDispatcherJob[%p]: Analyzing\n", static_cast<void*>(this));
} }
compile_info_.reset( compile_info_.reset(new CompilationInfo(
new CompilationInfo(parse_info_.get(), Handle<JSFunction>::null())); parse_info_->zone(), parse_info_.get(), Handle<JSFunction>::null()));
DeferredHandleScope scope(isolate_); DeferredHandleScope scope(isolate_);
{ {
......
...@@ -28,7 +28,6 @@ class SharedFunctionInfo; ...@@ -28,7 +28,6 @@ class SharedFunctionInfo;
class String; class String;
class UnicodeCache; class UnicodeCache;
class Utf16CharacterStream; class Utf16CharacterStream;
class Zone;
enum class CompileJobStatus { enum class CompileJobStatus {
kInitial, kInitial,
......
This diff is collapsed.
...@@ -550,7 +550,8 @@ Reduction JSInliner::ReduceJSCall(Node* node) { ...@@ -550,7 +550,8 @@ Reduction JSInliner::ReduceJSCall(Node* node) {
} }
ParseInfo parse_info(shared_info); ParseInfo parse_info(shared_info);
CompilationInfo info(&parse_info, Handle<JSFunction>::null()); CompilationInfo info(parse_info.zone(), &parse_info,
Handle<JSFunction>::null());
if (info_->is_deoptimization_enabled()) info.MarkAsDeoptimizationEnabled(); if (info_->is_deoptimization_enabled()) info.MarkAsDeoptimizationEnabled();
info.MarkAsOptimizeFromBytecode(); info.MarkAsOptimizeFromBytecode();
......
...@@ -551,7 +551,7 @@ class PipelineCompilationJob final : public CompilationJob { ...@@ -551,7 +551,7 @@ class PipelineCompilationJob final : public CompilationJob {
: CompilationJob(isolate, &info_, "TurboFan"), : CompilationJob(isolate, &info_, "TurboFan"),
parse_info_(handle(function->shared())), parse_info_(handle(function->shared())),
zone_stats_(isolate->allocator()), zone_stats_(isolate->allocator()),
info_(&parse_info_, function), info_(parse_info_.zone(), &parse_info_, function),
pipeline_statistics_(CreatePipelineStatistics(info(), &zone_stats_)), pipeline_statistics_(CreatePipelineStatistics(info(), &zone_stats_)),
data_(&zone_stats_, info(), pipeline_statistics_.get()), data_(&zone_stats_, info(), pipeline_statistics_.get()),
pipeline_(&data_), pipeline_(&data_),
......
...@@ -8043,7 +8043,7 @@ bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target, ...@@ -8043,7 +8043,7 @@ bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target,
top_info()->parse_info()->ast_value_factory()); top_info()->parse_info()->ast_value_factory());
parse_info.set_ast_value_factory_owned(false); parse_info.set_ast_value_factory_owned(false);
CompilationInfo target_info(&parse_info, target); CompilationInfo target_info(parse_info.zone(), &parse_info, target);
if (inlining_kind != CONSTRUCT_CALL_RETURN && if (inlining_kind != CONSTRUCT_CALL_RETURN &&
IsClassConstructor(target_shared->kind())) { IsClassConstructor(target_shared->kind())) {
......
...@@ -39,7 +39,7 @@ class HCompilationJob final : public CompilationJob { ...@@ -39,7 +39,7 @@ class HCompilationJob final : public CompilationJob {
explicit HCompilationJob(Handle<JSFunction> function) explicit HCompilationJob(Handle<JSFunction> function)
: CompilationJob(function->GetIsolate(), &info_, "Crankshaft"), : CompilationJob(function->GetIsolate(), &info_, "Crankshaft"),
parse_info_(handle(function->shared())), parse_info_(handle(function->shared())),
info_(&parse_info_, function), info_(parse_info_.zone(), &parse_info_, function),
graph_(nullptr), graph_(nullptr),
chunk_(nullptr) {} chunk_(nullptr) {}
......
...@@ -49,7 +49,8 @@ Zone::Zone(AccountingAllocator* allocator, const char* name) ...@@ -49,7 +49,8 @@ Zone::Zone(AccountingAllocator* allocator, const char* name)
limit_(0), limit_(0),
allocator_(allocator), allocator_(allocator),
segment_head_(nullptr), segment_head_(nullptr),
name_(name) { name_(name),
sealed_(false) {
allocator_->ZoneCreation(this); allocator_->ZoneCreation(this);
} }
...@@ -62,6 +63,8 @@ Zone::~Zone() { ...@@ -62,6 +63,8 @@ Zone::~Zone() {
} }
void* Zone::New(size_t size) { void* Zone::New(size_t size) {
CHECK(!sealed_);
// Round up the requested size to fit the alignment. // Round up the requested size to fit the alignment.
size = RoundUp(size, kAlignmentInBytes); size = RoundUp(size, kAlignmentInBytes);
......
...@@ -50,6 +50,9 @@ class V8_EXPORT_PRIVATE Zone final { ...@@ -50,6 +50,9 @@ class V8_EXPORT_PRIVATE Zone final {
return static_cast<T*>(New(length * sizeof(T))); return static_cast<T*>(New(length * sizeof(T)));
} }
// Seals the zone to prevent any further allocation.
void Seal() { sealed_ = true; }
// Returns true if more memory has been allocated in zones than // Returns true if more memory has been allocated in zones than
// the limit allows. // the limit allows.
bool excess_allocation() const { bool excess_allocation() const {
...@@ -106,6 +109,7 @@ class V8_EXPORT_PRIVATE Zone final { ...@@ -106,6 +109,7 @@ class V8_EXPORT_PRIVATE Zone final {
Segment* segment_head_; Segment* segment_head_;
const char* name_; const char* name_;
bool sealed_;
}; };
// ZoneObject is an abstraction that helps define classes of objects // ZoneObject is an abstraction that helps define classes of objects
......
...@@ -156,7 +156,7 @@ Handle<JSFunction> FunctionTester::ForMachineGraph(Graph* graph, ...@@ -156,7 +156,7 @@ Handle<JSFunction> FunctionTester::ForMachineGraph(Graph* graph,
Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) { Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) {
ParseInfo parse_info(handle(function->shared())); ParseInfo parse_info(handle(function->shared()));
CompilationInfo info(&parse_info, function); CompilationInfo info(parse_info.zone(), &parse_info, function);
info.SetOptimizing(); info.SetOptimizing();
info.MarkAsDeoptimizationEnabled(); info.MarkAsDeoptimizationEnabled();
...@@ -185,7 +185,7 @@ Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) { ...@@ -185,7 +185,7 @@ Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) {
// and replace the JSFunction's code with the result. // and replace the JSFunction's code with the result.
Handle<JSFunction> FunctionTester::CompileGraph(Graph* graph) { Handle<JSFunction> FunctionTester::CompileGraph(Graph* graph) {
ParseInfo parse_info(handle(function->shared())); ParseInfo parse_info(handle(function->shared()));
CompilationInfo info(&parse_info, function); CompilationInfo info(parse_info.zone(), &parse_info, function);
CHECK(parsing::ParseFunction(info.parse_info())); CHECK(parsing::ParseFunction(info.parse_info()));
info.SetOptimizing(); info.SetOptimizing();
......
...@@ -44,7 +44,7 @@ TEST(TestLinkageCreate) { ...@@ -44,7 +44,7 @@ TEST(TestLinkageCreate) {
HandleAndZoneScope handles; HandleAndZoneScope handles;
Handle<JSFunction> function = Compile("a + b"); Handle<JSFunction> function = Compile("a + b");
ParseInfo parse_info(handle(function->shared())); ParseInfo parse_info(handle(function->shared()));
CompilationInfo info(&parse_info, function); CompilationInfo info(parse_info.zone(), &parse_info, function);
CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info); CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info);
CHECK(descriptor); CHECK(descriptor);
} }
...@@ -60,7 +60,7 @@ TEST(TestLinkageJSFunctionIncoming) { ...@@ -60,7 +60,7 @@ TEST(TestLinkageJSFunctionIncoming) {
Handle<JSFunction>::cast(v8::Utils::OpenHandle( Handle<JSFunction>::cast(v8::Utils::OpenHandle(
*v8::Local<v8::Function>::Cast(CompileRun(sources[i])))); *v8::Local<v8::Function>::Cast(CompileRun(sources[i]))));
ParseInfo parse_info(handle(function->shared())); ParseInfo parse_info(handle(function->shared()));
CompilationInfo info(&parse_info, function); CompilationInfo info(parse_info.zone(), &parse_info, function);
CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info); CallDescriptor* descriptor = Linkage::ComputeIncoming(info.zone(), &info);
CHECK(descriptor); CHECK(descriptor);
...@@ -76,7 +76,7 @@ TEST(TestLinkageJSCall) { ...@@ -76,7 +76,7 @@ TEST(TestLinkageJSCall) {
HandleAndZoneScope handles; HandleAndZoneScope handles;
Handle<JSFunction> function = Compile("a + c"); Handle<JSFunction> function = Compile("a + c");
ParseInfo parse_info(handle(function->shared())); ParseInfo parse_info(handle(function->shared()));
CompilationInfo info(&parse_info, function); CompilationInfo info(parse_info.zone(), &parse_info, function);
for (int i = 0; i < 32; i++) { for (int i = 0; i < 32; i++) {
CallDescriptor* descriptor = Linkage::GetJSCallDescriptor( CallDescriptor* descriptor = Linkage::GetJSCallDescriptor(
......
...@@ -34,7 +34,7 @@ struct TestHelper : public HandleAndZoneScope { ...@@ -34,7 +34,7 @@ struct TestHelper : public HandleAndZoneScope {
void CheckLoopAssignedCount(int expected, const char* var_name) { void CheckLoopAssignedCount(int expected, const char* var_name) {
// TODO(titzer): don't scope analyze every single time. // TODO(titzer): don't scope analyze every single time.
ParseInfo parse_info(handle(function->shared())); ParseInfo parse_info(handle(function->shared()));
CompilationInfo info(&parse_info, function); CompilationInfo info(parse_info.zone(), &parse_info, function);
CHECK(parsing::ParseFunction(&parse_info)); CHECK(parsing::ParseFunction(&parse_info));
CHECK(Rewriter::Rewrite(&parse_info)); CHECK(Rewriter::Rewrite(&parse_info));
......
...@@ -124,7 +124,7 @@ class BytecodeGraphTester { ...@@ -124,7 +124,7 @@ class BytecodeGraphTester {
// having to instantiate a ParseInfo first. Fix this! // having to instantiate a ParseInfo first. Fix this!
ParseInfo parse_info(handle(function->shared())); ParseInfo parse_info(handle(function->shared()));
CompilationInfo compilation_info(&parse_info, function); CompilationInfo compilation_info(parse_info.zone(), &parse_info, function);
compilation_info.SetOptimizing(); compilation_info.SetOptimizing();
compilation_info.MarkAsDeoptimizationEnabled(); compilation_info.MarkAsDeoptimizationEnabled();
compilation_info.MarkAsOptimizeFromBytecode(); compilation_info.MarkAsOptimizeFromBytecode();
......
...@@ -29,7 +29,7 @@ class BlockingCompilationJob : public CompilationJob { ...@@ -29,7 +29,7 @@ class BlockingCompilationJob : public CompilationJob {
: CompilationJob(isolate, &info_, "BlockingCompilationJob", : CompilationJob(isolate, &info_, "BlockingCompilationJob",
State::kReadyToExecute), State::kReadyToExecute),
parse_info_(handle(function->shared())), parse_info_(handle(function->shared())),
info_(&parse_info_, function), info_(parse_info_.zone(), &parse_info_, function),
blocking_(false), blocking_(false),
semaphore_(0) {} semaphore_(0) {}
~BlockingCompilationJob() override = default; ~BlockingCompilationJob() override = default;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment