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

Side by Side Diff: src/code-stubs-hydrogen.cc

Issue 11414262: Revert 13105: "Enable stub generation using Hydrogen/Lithium." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/code-stubs.cc ('k') | src/codegen.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 #include "v8.h"
29
30 #include "code-stubs.h"
31 #include "hydrogen.h"
32 #include "lithium.h"
33
34 namespace v8 {
35 namespace internal {
36
37
38 Handle<Code> HydrogenCodeStub::CodeFromGraph(HGraph* graph) {
39 graph->OrderBlocks();
40 graph->AssignDominators();
41 graph->CollectPhis();
42 graph->InsertRepresentationChanges();
43 graph->EliminateRedundantBoundsChecks();
44 LChunk* chunk = LChunk::NewChunk(graph);
45 ASSERT(chunk != NULL);
46 Handle<Code> stub = chunk->Codegen(Code::COMPILED_STUB);
47 return stub;
48 }
49
50
51 class CodeStubGraphBuilderBase : public HGraphBuilder {
52 public:
53 CodeStubGraphBuilderBase(Isolate* isolate, HydrogenCodeStub* stub)
54 : HGraphBuilder(&info_), info_(stub, isolate) {}
55 virtual bool BuildGraph();
56
57 protected:
58 virtual void BuildCodeStub() = 0;
59 HParameter* GetParameter(int parameter) { return parameters_[parameter]; }
60 HydrogenCodeStub* stub() { return info_.code_stub(); }
61
62 private:
63 SmartArrayPointer<HParameter*> parameters_;
64 CompilationInfoWithZone info_;
65 };
66
67
68 bool CodeStubGraphBuilderBase::BuildGraph() {
69 if (FLAG_trace_hydrogen) {
70 PrintF("-----------------------------------------------------------\n");
71 PrintF("Compiling stub using hydrogen\n");
72 HTracer::Instance()->TraceCompilation(&info_);
73 }
74 HBasicBlock* next_block = graph()->CreateBasicBlock();
75 next_block->SetInitialEnvironment(graph()->start_environment());
76 HGoto* jump = new(zone()) HGoto(next_block);
77 graph()->entry_block()->Finish(jump);
78 set_current_block(next_block);
79
80 int major_key = stub()->MajorKey();
81 CodeStubInterfaceDescriptor** descriptors =
82 info_.isolate()->code_stub_interface_descriptors();
83 if (descriptors[major_key] == NULL) {
84 descriptors[major_key] = stub()->GetInterfaceDescriptor(info_.isolate());
85 }
86
87 CodeStubInterfaceDescriptor* descriptor = descriptors[major_key];
88 parameters_.Reset(new HParameter*[descriptor->number_of_register_params]);
89
90 HGraph* graph = this->graph();
91 Zone* zone = this->zone();
92 for (int i = 0; i < descriptor->number_of_register_params; ++i) {
93 HParameter* param = new(zone) HParameter(i);
94 AddInstruction(param);
95 graph->start_environment()->Push(param);
96 parameters_[i] = param;
97 }
98 AddSimulate(BailoutId::StubEntry());
99
100 BuildCodeStub();
101
102 return true;
103 }
104
105 template <class Stub>
106 class CodeStubGraphBuilder: public CodeStubGraphBuilderBase {
107 public:
108 explicit CodeStubGraphBuilder(Stub* stub)
109 : CodeStubGraphBuilderBase(Isolate::Current(), stub) {}
110
111 protected:
112 virtual void BuildCodeStub();
113 Stub* casted_stub() { return static_cast<Stub*>(stub()); }
114 };
115
116
117 template <>
118 void CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() {
119 Zone* zone = this->zone();
120
121 HInstruction* load = BuildUncheckedMonomorphicElementAccess(
122 GetParameter(0), GetParameter(1), NULL, NULL,
123 casted_stub()->is_js_array(), casted_stub()->elements_kind(), false);
124 AddInstruction(load);
125
126 HReturn* ret = new(zone) HReturn(load);
127 current_block()->Finish(ret);
128 }
129
130
131 Handle<Code> KeyedLoadFastElementStub::GenerateCode() {
132 CodeStubGraphBuilder<KeyedLoadFastElementStub> builder(this);
133 return CodeFromGraph(builder.CreateGraph());
134 }
135
136
137 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/code-stubs.cc ('k') | src/codegen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698