| Index: runtime/vm/compiler.cc
|
| ===================================================================
|
| --- runtime/vm/compiler.cc (revision 44266)
|
| +++ runtime/vm/compiler.cc (working copy)
|
| @@ -73,10 +73,11 @@
|
| // separate helpers functions & `optimizing` args.
|
| class CompilationPipeline : public ZoneAllocated {
|
| public:
|
| - static CompilationPipeline* New(Isolate* isolate, const Function& function);
|
| + static CompilationPipeline* New(Zone* zone, const Function& function);
|
|
|
| virtual void ParseFunction(ParsedFunction* parsed_function) = 0;
|
| virtual FlowGraph* BuildFlowGraph(
|
| + Zone* zone,
|
| ParsedFunction* parsed_function,
|
| const ZoneGrowableArray<const ICData*>& ic_data_array,
|
| intptr_t osr_id) = 0;
|
| @@ -93,6 +94,7 @@
|
| }
|
|
|
| virtual FlowGraph* BuildFlowGraph(
|
| + Zone* zone,
|
| ParsedFunction* parsed_function,
|
| const ZoneGrowableArray<const ICData*>& ic_data_array,
|
| intptr_t osr_id) {
|
| @@ -111,9 +113,7 @@
|
|
|
| class IrregexpCompilationPipeline : public CompilationPipeline {
|
| public:
|
| - explicit IrregexpCompilationPipeline(Isolate* isolate)
|
| - : backtrack_goto_(NULL),
|
| - isolate_(isolate) { }
|
| + IrregexpCompilationPipeline() : backtrack_goto_(NULL) { }
|
|
|
| virtual void ParseFunction(ParsedFunction* parsed_function) {
|
| RegExpParser::ParseFunction(parsed_function);
|
| @@ -121,6 +121,7 @@
|
| }
|
|
|
| virtual FlowGraph* BuildFlowGraph(
|
| + Zone* zone,
|
| ParsedFunction* parsed_function,
|
| const ZoneGrowableArray<const ICData*>& ic_data_array,
|
| intptr_t osr_id) {
|
| @@ -140,26 +141,25 @@
|
| NULL, // NULL = not inlining.
|
| osr_id);
|
|
|
| - return new(isolate_) FlowGraph(*parsed_function,
|
| - result.graph_entry,
|
| - result.num_blocks);
|
| + return new(zone) FlowGraph(*parsed_function,
|
| + result.graph_entry,
|
| + result.num_blocks);
|
| }
|
|
|
| virtual void FinalizeCompilation() {
|
| - backtrack_goto_->ComputeOffsetTable(isolate_);
|
| + backtrack_goto_->ComputeOffsetTable();
|
| }
|
|
|
| private:
|
| IndirectGotoInstr* backtrack_goto_;
|
| - Isolate* isolate_;
|
| };
|
|
|
| -CompilationPipeline* CompilationPipeline::New(Isolate* isolate,
|
| +CompilationPipeline* CompilationPipeline::New(Zone* zone,
|
| const Function& function) {
|
| if (function.IsIrregexpFunction()) {
|
| - return new(isolate) IrregexpCompilationPipeline(isolate);
|
| + return new(zone) IrregexpCompilationPipeline();
|
| } else {
|
| - return new(isolate) DartCompilationPipeline();
|
| + return new(zone) DartCompilationPipeline();
|
| }
|
| }
|
|
|
| @@ -169,7 +169,7 @@
|
| DEFINE_RUNTIME_ENTRY(CompileFunction, 1) {
|
| const Function& function = Function::CheckedHandle(arguments.ArgAt(0));
|
| ASSERT(!function.HasCode());
|
| - const Error& error = Error::Handle(Compiler::CompileFunction(isolate,
|
| + const Error& error = Error::Handle(Compiler::CompileFunction(thread,
|
| function));
|
| if (!error.IsNull()) {
|
| Exceptions::PropagateError(error);
|
| @@ -374,7 +374,9 @@
|
| }
|
| TimerScope timer(FLAG_compiler_stats, &CompilerStats::codegen_timer);
|
| bool is_compiled = false;
|
| - Isolate* isolate = Isolate::Current();
|
| + Thread* thread = Thread::Current();
|
| + Zone* zone = thread->zone();
|
| + Isolate* isolate = thread->isolate();
|
| HANDLESCOPE(isolate);
|
|
|
| // We may reattempt compilation if the function needs to be assembled using
|
| @@ -404,7 +406,7 @@
|
| &CompilerStats::graphbuilder_timer,
|
| isolate);
|
| ZoneGrowableArray<const ICData*>* ic_data_array =
|
| - new(isolate) ZoneGrowableArray<const ICData*>();
|
| + new(zone) ZoneGrowableArray<const ICData*>();
|
| if (optimized) {
|
| ASSERT(function.HasCode());
|
| // Extract type feedback before the graph is built, as the graph
|
| @@ -422,7 +424,8 @@
|
| }
|
| }
|
|
|
| - flow_graph = pipeline->BuildFlowGraph(parsed_function,
|
| + flow_graph = pipeline->BuildFlowGraph(zone,
|
| + parsed_function,
|
| *ic_data_array,
|
| osr_id);
|
| }
|
| @@ -1040,19 +1043,21 @@
|
| }
|
|
|
|
|
| -RawError* Compiler::CompileFunction(Isolate* isolate,
|
| +RawError* Compiler::CompileFunction(Thread* thread,
|
| const Function& function) {
|
| - VMTagScope tagScope(isolate, VMTag::kCompileUnoptimizedTagId);
|
| - CompilationPipeline* pipeline = CompilationPipeline::New(isolate, function);
|
| + VMTagScope tagScope(thread->isolate(), VMTag::kCompileUnoptimizedTagId);
|
| + CompilationPipeline* pipeline =
|
| + CompilationPipeline::New(thread->zone(), function);
|
| return CompileFunctionHelper(pipeline, function, false, Isolate::kNoDeoptId);
|
| }
|
|
|
|
|
| -RawError* Compiler::CompileOptimizedFunction(Isolate* isolate,
|
| +RawError* Compiler::CompileOptimizedFunction(Thread* thread,
|
| const Function& function,
|
| intptr_t osr_id) {
|
| - VMTagScope tagScope(isolate, VMTag::kCompileOptimizedTagId);
|
| - CompilationPipeline* pipeline = CompilationPipeline::New(isolate, function);
|
| + VMTagScope tagScope(thread->isolate(), VMTag::kCompileOptimizedTagId);
|
| + CompilationPipeline* pipeline =
|
| + CompilationPipeline::New(thread->zone(), function);
|
| return CompileFunctionHelper(pipeline, function, true, osr_id);
|
| }
|
|
|
| @@ -1086,10 +1091,11 @@
|
|
|
|
|
| RawError* Compiler::CompileAllFunctions(const Class& cls) {
|
| - Isolate* isolate = Isolate::Current();
|
| - Error& error = Error::Handle(isolate);
|
| - Array& functions = Array::Handle(isolate, cls.functions());
|
| - Function& func = Function::Handle(isolate);
|
| + Thread* thread = Thread::Current();
|
| + Zone* zone = thread->zone();
|
| + Error& error = Error::Handle(zone);
|
| + Array& functions = Array::Handle(zone, cls.functions());
|
| + Function& func = Function::Handle(zone);
|
| // Class dynamic lives in the vm isolate. Its array fields cannot be set to
|
| // an empty array.
|
| if (functions.IsNull()) {
|
| @@ -1103,7 +1109,7 @@
|
| if (!func.HasCode() &&
|
| !func.is_abstract() &&
|
| !func.IsRedirectingFactory()) {
|
| - error = CompileFunction(isolate, func);
|
| + error = CompileFunction(thread, func);
|
| if (!error.IsNull()) {
|
| return error.raw();
|
| }
|
| @@ -1114,12 +1120,12 @@
|
| // more closures can be added to the end of the array. Compile all the
|
| // closures until we have reached the end of the "worklist".
|
| GrowableObjectArray& closures =
|
| - GrowableObjectArray::Handle(isolate, cls.closures());
|
| + GrowableObjectArray::Handle(zone, cls.closures());
|
| if (!closures.IsNull()) {
|
| for (int i = 0; i < closures.Length(); i++) {
|
| func ^= closures.At(i);
|
| if (!func.HasCode()) {
|
| - error = CompileFunction(isolate, func);
|
| + error = CompileFunction(thread, func);
|
| if (!error.IsNull()) {
|
| return error.raw();
|
| }
|
|
|