Do not duplicate the compilation pipeline for stub compilation.
authorsvenpanne@chromium.org <svenpanne@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 28 Jan 2013 13:24:41 +0000 (13:24 +0000)
committersvenpanne@chromium.org <svenpanne@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 28 Jan 2013 13:24:41 +0000 (13:24 +0000)
The previous duplication is quite bad from an architectural point of
view. Furthermore, it messes up the output of --hydrogen-stats.

As remarked in a comment, there is still more unification work to do, but at
least this CL is a step in the right direction...

Review URL: https://codereview.chromium.org/12091016

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13527 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/code-stubs-hydrogen.cc
src/code-stubs.h

index 58e17f4..db51b22 100644 (file)
@@ -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);
 }
 
 
index bf0e261..96c2089 100644 (file)
@@ -274,9 +274,6 @@ class HydrogenCodeStub : public CodeStub {
   virtual void InitializeInterfaceDescriptor(
       Isolate* isolate,
       CodeStubInterfaceDescriptor* descriptor) = 0;
-
- protected:
-  Handle<Code> CodeFromGraph(HGraph* graph);
 };