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 {
return parse_info_ && !parse_info_->shared_info().is_null();
}
CompilationInfo::CompilationInfo(ParseInfo* parse_info,
CompilationInfo::CompilationInfo(Zone* zone, ParseInfo* parse_info,
Handle<JSFunction> closure)
: CompilationInfo(parse_info, {}, Code::ComputeFlags(Code::FUNCTION), BASE,
parse_info->isolate(), parse_info->zone()) {
parse_info->isolate(), zone) {
closure_ = closure;
// Compiling for the snapshot typically results in different code than
......
......@@ -53,7 +53,8 @@ class V8_EXPORT_PRIVATE CompilationInfo final {
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,
Code::Flags code_flags);
~CompilationInfo();
......
......@@ -97,8 +97,8 @@ CompilerDispatcherJob::CompilerDispatcherJob(Isolate* isolate,
max_stack_size_(max_stack_size),
parse_info_(
new ParseInfo(Handle<Script>(Script::cast(shared->script())))),
compile_info_(
new CompilationInfo(parse_info_.get(), Handle<JSFunction>::null())),
compile_info_(new CompilationInfo(parse_info_->zone(), parse_info_.get(),
Handle<JSFunction>::null())),
trace_compiler_dispatcher_jobs_(FLAG_trace_compiler_dispatcher_jobs) {
parse_info_->set_literal(literal);
parse_info_->set_shared_info(shared);
......@@ -318,8 +318,8 @@ bool CompilerDispatcherJob::AnalyzeOnMainThread() {
PrintF("CompilerDispatcherJob[%p]: Analyzing\n", static_cast<void*>(this));
}
compile_info_.reset(
new CompilationInfo(parse_info_.get(), Handle<JSFunction>::null()));
compile_info_.reset(new CompilationInfo(
parse_info_->zone(), parse_info_.get(), Handle<JSFunction>::null()));
DeferredHandleScope scope(isolate_);
{
......
......@@ -28,7 +28,6 @@ class SharedFunctionInfo;
class String;
class UnicodeCache;
class Utf16CharacterStream;
class Zone;
enum class CompileJobStatus {
kInitial,
......
This diff is collapsed.
......@@ -550,7 +550,8 @@ Reduction JSInliner::ReduceJSCall(Node* node) {
}
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();
info.MarkAsOptimizeFromBytecode();
......
......@@ -551,7 +551,7 @@ class PipelineCompilationJob final : public CompilationJob {
: CompilationJob(isolate, &info_, "TurboFan"),
parse_info_(handle(function->shared())),
zone_stats_(isolate->allocator()),
info_(&parse_info_, function),
info_(parse_info_.zone(), &parse_info_, function),
pipeline_statistics_(CreatePipelineStatistics(info(), &zone_stats_)),
data_(&zone_stats_, info(), pipeline_statistics_.get()),
pipeline_(&data_),
......
......@@ -8043,7 +8043,7 @@ bool HOptimizedGraphBuilder::TryInline(Handle<JSFunction> target,
top_info()->parse_info()->ast_value_factory());
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 &&
IsClassConstructor(target_shared->kind())) {
......
......@@ -39,7 +39,7 @@ class HCompilationJob final : public CompilationJob {
explicit HCompilationJob(Handle<JSFunction> function)
: CompilationJob(function->GetIsolate(), &info_, "Crankshaft"),
parse_info_(handle(function->shared())),
info_(&parse_info_, function),
info_(parse_info_.zone(), &parse_info_, function),
graph_(nullptr),
chunk_(nullptr) {}
......
......@@ -49,7 +49,8 @@ Zone::Zone(AccountingAllocator* allocator, const char* name)
limit_(0),
allocator_(allocator),
segment_head_(nullptr),
name_(name) {
name_(name),
sealed_(false) {
allocator_->ZoneCreation(this);
}
......@@ -62,6 +63,8 @@ Zone::~Zone() {
}
void* Zone::New(size_t size) {
CHECK(!sealed_);
// Round up the requested size to fit the alignment.
size = RoundUp(size, kAlignmentInBytes);
......
......@@ -50,6 +50,9 @@ class V8_EXPORT_PRIVATE Zone final {
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
// the limit allows.
bool excess_allocation() const {
......@@ -106,6 +109,7 @@ class V8_EXPORT_PRIVATE Zone final {
Segment* segment_head_;
const char* name_;
bool sealed_;
};
// ZoneObject is an abstraction that helps define classes of objects
......
......@@ -156,7 +156,7 @@ Handle<JSFunction> FunctionTester::ForMachineGraph(Graph* graph,
Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) {
ParseInfo parse_info(handle(function->shared()));
CompilationInfo info(&parse_info, function);
CompilationInfo info(parse_info.zone(), &parse_info, function);
info.SetOptimizing();
info.MarkAsDeoptimizationEnabled();
......@@ -185,7 +185,7 @@ Handle<JSFunction> FunctionTester::Compile(Handle<JSFunction> function) {
// and replace the JSFunction's code with the result.
Handle<JSFunction> FunctionTester::CompileGraph(Graph* graph) {
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()));
info.SetOptimizing();
......
......@@ -44,7 +44,7 @@ TEST(TestLinkageCreate) {
HandleAndZoneScope handles;
Handle<JSFunction> function = Compile("a + b");
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);
CHECK(descriptor);
}
......@@ -60,7 +60,7 @@ TEST(TestLinkageJSFunctionIncoming) {
Handle<JSFunction>::cast(v8::Utils::OpenHandle(
*v8::Local<v8::Function>::Cast(CompileRun(sources[i]))));
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);
CHECK(descriptor);
......@@ -76,7 +76,7 @@ TEST(TestLinkageJSCall) {
HandleAndZoneScope handles;
Handle<JSFunction> function = Compile("a + c");
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++) {
CallDescriptor* descriptor = Linkage::GetJSCallDescriptor(
......
......@@ -34,7 +34,7 @@ struct TestHelper : public HandleAndZoneScope {
void CheckLoopAssignedCount(int expected, const char* var_name) {
// TODO(titzer): don't scope analyze every single time.
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(Rewriter::Rewrite(&parse_info));
......
......@@ -124,7 +124,7 @@ class BytecodeGraphTester {
// having to instantiate a ParseInfo first. Fix this!
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.MarkAsDeoptimizationEnabled();
compilation_info.MarkAsOptimizeFromBytecode();
......
......@@ -29,7 +29,7 @@ class BlockingCompilationJob : public CompilationJob {
: CompilationJob(isolate, &info_, "BlockingCompilationJob",
State::kReadyToExecute),
parse_info_(handle(function->shared())),
info_(&parse_info_, function),
info_(parse_info_.zone(), &parse_info_, function),
blocking_(false),
semaphore_(0) {}
~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