Index: src/code-stubs-hydrogen.cc |
diff --git a/src/code-stubs-hydrogen.cc b/src/code-stubs-hydrogen.cc |
index 58e17f43f2adf7f98883e97db94b7297710949cb..db51b22896fefb2b5b95cf1394038b44769aa29d 100644 |
--- a/src/code-stubs-hydrogen.cc |
+++ b/src/code-stubs-hydrogen.cc |
@@ -35,16 +35,22 @@ namespace v8 { |
namespace internal { |
-Handle<Code> HydrogenCodeStub::CodeFromGraph(HGraph* graph) { |
- graph->OrderBlocks(); |
- graph->AssignDominators(); |
- graph->CollectPhis(); |
- graph->InsertRepresentationChanges(); |
- graph->EliminateRedundantBoundsChecks(); |
+// TODO(svenpanne) Merge with OptimizingCompiler::OptimizeGraph(). |
+static LChunk* OptimizeGraph(HGraph* graph) { |
+ AssertNoAllocation no_gc; |
+ NoHandleAllocation no_handles; |
+ NoHandleDereference no_deref; |
+ |
+ ASSERT(graph != NULL); |
+ SmartArrayPointer<char> bailout_reason; |
+ if (!graph->Optimize(&bailout_reason)) { |
+ FATAL(bailout_reason.is_empty() ? "unknown" : *bailout_reason); |
+ } |
LChunk* chunk = LChunk::NewChunk(graph); |
- ASSERT(chunk != NULL); |
- Handle<Code> stub = chunk->Codegen(Code::COMPILED_STUB); |
- return stub; |
+ if (chunk == NULL) { |
+ FATAL(graph->info()->bailout_reason()); |
+ } |
+ return chunk; |
} |
@@ -133,7 +139,8 @@ void CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() { |
Handle<Code> KeyedLoadFastElementStub::GenerateCode() { |
CodeStubGraphBuilder<KeyedLoadFastElementStub> builder(this); |
- return CodeFromGraph(builder.CreateGraph()); |
+ LChunk* chunk = OptimizeGraph(builder.CreateGraph()); |
+ return chunk->Codegen(Code::COMPILED_STUB); |
} |