Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1264)

Unified Diff: runtime/vm/compiler.cc

Issue 982873004: Thread/Isolate refactoring: new(Isolate) -> new(Zone) (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/compiler.cc
===================================================================
--- runtime/vm/compiler.cc (revision 44266)
+++ runtime/vm/compiler.cc (working copy)
@@ -73,13 +73,14 @@
// 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(
ParsedFunction* parsed_function,
const ZoneGrowableArray<const ICData*>& ic_data_array,
- intptr_t osr_id) = 0;
+ intptr_t osr_id,
+ Zone* zone) = 0;
Ivan Posva 2015/03/13 21:56:49 We generally pass Isolate* as the first parameter,
koda 2015/03/14 00:46:36 Done.
virtual void FinalizeCompilation() = 0;
virtual ~CompilationPipeline() { }
};
@@ -95,7 +96,8 @@
virtual FlowGraph* BuildFlowGraph(
ParsedFunction* parsed_function,
const ZoneGrowableArray<const ICData*>& ic_data_array,
- intptr_t osr_id) {
+ intptr_t osr_id,
+ Zone* zone) {
// Build the flow graph.
FlowGraphBuilder builder(*parsed_function,
ic_data_array,
@@ -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);
@@ -123,7 +123,8 @@
virtual FlowGraph* BuildFlowGraph(
ParsedFunction* parsed_function,
const ZoneGrowableArray<const ICData*>& ic_data_array,
- intptr_t osr_id) {
+ intptr_t osr_id,
+ Zone* zone) {
// Compile to the dart IR.
RegExpEngine::CompilationResult result =
RegExpEngine::Compile(parsed_function->regexp_compile_data(),
@@ -140,26 +141,26 @@
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_;
+ Zone* zone_;
Ivan Posva 2015/03/13 21:56:49 Where is zone_ being set?
koda 2015/03/14 00:46:36 Removed (leftover from previous version).
};
-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 +170,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 +375,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 +407,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
@@ -424,7 +427,8 @@
flow_graph = pipeline->BuildFlowGraph(parsed_function,
*ic_data_array,
- osr_id);
+ osr_id,
+ zone);
}
const bool print_flow_graph =
@@ -1040,19 +1044,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 +1092,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 +1110,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 +1121,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();
}

Powered by Google App Engine
This is Rietveld 408576698