Index: src/compiler.cc |
diff --git a/src/compiler.cc b/src/compiler.cc |
index ff6e05d6070cc14b620f2ce3868edf94360214b7..f79a66c54c9450e9985b8891a7219bcdff312440 100644 |
--- a/src/compiler.cc |
+++ b/src/compiler.cc |
@@ -55,7 +55,7 @@ CompilationInfo::CompilationInfo(Handle<Script> script, Zone* zone) |
: flags_(LanguageModeField::encode(CLASSIC_MODE)), |
script_(script), |
osr_ast_id_(BailoutId::None()) { |
- Initialize(zone); |
+ Initialize(script->GetIsolate(), BASE, zone); |
} |
@@ -65,7 +65,7 @@ CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info, |
shared_info_(shared_info), |
script_(Handle<Script>(Script::cast(shared_info->script()))), |
osr_ast_id_(BailoutId::None()) { |
- Initialize(zone); |
+ Initialize(script_->GetIsolate(), BASE, zone); |
} |
@@ -76,12 +76,22 @@ CompilationInfo::CompilationInfo(Handle<JSFunction> closure, Zone* zone) |
script_(Handle<Script>(Script::cast(shared_info_->script()))), |
context_(closure->context()), |
osr_ast_id_(BailoutId::None()) { |
- Initialize(zone); |
+ Initialize(script_->GetIsolate(), BASE, zone); |
} |
-void CompilationInfo::Initialize(Zone* zone) { |
- isolate_ = script_->GetIsolate(); |
+CompilationInfo::CompilationInfo(HydrogenCodeStub* stub, |
+ Isolate* isolate, Zone* zone) |
+ : flags_(LanguageModeField::encode(CLASSIC_MODE) | |
+ IsLazy::encode(true)), |
+ osr_ast_id_(BailoutId::None()) { |
+ Initialize(isolate, STUB, zone); |
+ code_stub_ = stub; |
+} |
+ |
+ |
+void CompilationInfo::Initialize(Isolate* isolate, Mode mode, Zone* zone) { |
+ isolate_ = isolate; |
function_ = NULL; |
scope_ = NULL; |
global_scope_ = NULL; |
@@ -89,8 +99,13 @@ void CompilationInfo::Initialize(Zone* zone) { |
pre_parse_data_ = NULL; |
zone_ = zone; |
deferred_handles_ = NULL; |
+ code_stub_ = NULL; |
prologue_offset_ = kPrologueOffsetNotSet; |
- mode_ = V8::UseCrankshaft() ? BASE : NONOPT; |
+ if (mode == STUB) { |
+ mode_ = STUB; |
+ return; |
+ } |
+ mode_ = V8::UseCrankshaft() ? mode : NONOPT; |
if (script_->type()->value() == Script::TYPE_NATIVE) { |
MarkAsNative(); |
} |
@@ -107,6 +122,33 @@ CompilationInfo::~CompilationInfo() { |
} |
+int CompilationInfo::num_parameters() const { |
+ if (IsStub()) { |
+ return 0; |
+ } else { |
+ return scope()->num_parameters(); |
+ } |
+} |
+ |
+ |
+int CompilationInfo::num_heap_slots() const { |
+ if (IsStub()) { |
+ return 0; |
+ } else { |
+ return scope()->num_heap_slots(); |
+ } |
+} |
+ |
+ |
+Code::Flags CompilationInfo::flags() const { |
+ if (IsStub()) { |
+ return Code::ComputeFlags(Code::COMPILED_STUB); |
+ } else { |
+ return Code::ComputeFlags(Code::OPTIMIZED_FUNCTION); |
+ } |
+} |
+ |
+ |
// Disable optimization for the rest of the compilation pipeline. |
void CompilationInfo::DisableOptimization() { |
bool is_optimizable_closure = |
@@ -317,13 +359,13 @@ OptimizingCompiler::Status OptimizingCompiler::CreateGraph() { |
if (FLAG_trace_hydrogen) { |
PrintF("-----------------------------------------------------------\n"); |
PrintF("Compiling method %s using hydrogen\n", *name->ToCString()); |
- HTracer::Instance()->TraceCompilation(info()->function()); |
+ HTracer::Instance()->TraceCompilation(info()); |
} |
Handle<Context> native_context( |
info()->closure()->context()->native_context()); |
oracle_ = new(info()->zone()) TypeFeedbackOracle( |
code, native_context, info()->isolate(), info()->zone()); |
- graph_builder_ = new(info()->zone()) HGraphBuilder(info(), oracle_); |
+ graph_builder_ = new(info()->zone()) HOptimizedGraphBuilder(info(), oracle_); |
Timer t(this, &time_taken_to_create_graph_); |
graph_ = graph_builder_->CreateGraph(); |
@@ -376,7 +418,7 @@ OptimizingCompiler::Status OptimizingCompiler::GenerateAndInstallCode() { |
Timer timer(this, &time_taken_to_codegen_); |
ASSERT(chunk_ != NULL); |
ASSERT(graph_ != NULL); |
- Handle<Code> optimized_code = chunk_->Codegen(); |
+ Handle<Code> optimized_code = chunk_->Codegen(Code::OPTIMIZED_FUNCTION); |
if (optimized_code.is_null()) { |
info()->set_bailout_reason("code generation failed"); |
return AbortOptimization(); |