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

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

Issue 10701054: Enable stub generation using Hydrogen/Lithium (again) (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback 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
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 explicit CodeStubGraphBuilderBase(Isolate* isolate,
Jakob Kummerow 2012/11/28 16:28:22 nit: no need for "explicit"
danno 2012/11/30 16:23:24 Done.
54 HydrogenCodeStub* stub)
55 : HGraphBuilder(&info_), info_(stub, isolate) {}
56 virtual bool BuildGraph();
57 protected:
Jakob Kummerow 2012/11/28 16:28:22 nit: empty line before visibility sections (doesn'
danno 2012/11/30 16:23:24 Nope. Runs clean. Done.
58 virtual void BuildCodeStub() = 0;
59 HParameter* GetParameter(int parameter) { return parameters_[parameter]; }
60 HydrogenCodeStub* stub() { return info_.code_stub(); }
61 private:
Jakob Kummerow 2012/11/28 16:28:22 nit: empty line before visibility sections
danno 2012/11/30 16:23:24 Done.
62 SmartArrayPointer<HParameter*> parameters_;
63 CompilationInfoWithZone info_;
64 };
65
66
67 bool CodeStubGraphBuilderBase::BuildGraph() {
68 if (FLAG_trace_hydrogen) {
69 PrintF("-----------------------------------------------------------\n");
70 PrintF("Compiling stub using hydrogen\n");
71 HTracer::Instance()->TraceCompilation(&info_);
72 }
73 HBasicBlock* next_block = graph()->CreateBasicBlock();
74 next_block->SetInitialEnvironment(graph()->start_environment());
75 HGoto* jump = new(zone()) HGoto(next_block);
76 graph()->entry_block()->Finish(jump);
77 set_current_block(next_block);
78
79 int major_key = stub()->MajorKey();
80 CodeStubInterfaceDescriptor** decsriptors =
Jakob Kummerow 2012/11/28 16:28:22 nit: descriptors
danno 2012/11/30 16:23:24 Done.
81 info_.isolate()->code_stub_interface_descriptors();
82 if (decsriptors[major_key] == NULL) {
83 decsriptors[major_key] = stub()->GetInterfaceDescriptor(info_.isolate());
84 }
85
86 CodeStubInterfaceDescriptor* descriptor = decsriptors[major_key];
87 parameters_.Reset(new HParameter*[descriptor->number_of_register_params]);
88
89 HGraph* graph = this->graph();
90 Zone* zone = this->zone();
91 for (int i = 0; i < descriptor->number_of_register_params; ++i) {
92 HParameter* param = new(zone) HParameter(i);
93 AddInstruction(param);
94 graph->start_environment()->Push(param);
95 parameters_[i] = param;
96 }
97 AddSimulate(BailoutId::StubEntry());
98
99 BuildCodeStub();
100
101 return true;
102 }
103
104 template <class Stub>
105 class CodeStubGraphBuilder: public CodeStubGraphBuilderBase {
106 public:
107 explicit CodeStubGraphBuilder(Stub* stub)
108 : CodeStubGraphBuilderBase(Isolate::Current(), stub) {}
109 protected:
110 virtual void BuildCodeStub();
111 Stub* casted_stub() { return static_cast<Stub*>(stub()); }
112 private:
Jakob Kummerow 2012/11/28 16:28:22 nit: don't need an empty "private:" section
danno 2012/11/30 16:23:24 Done.
113 };
114
115
116 template <>
117 void CodeStubGraphBuilder<KeyedLoadFastElementStub>::BuildCodeStub() {
118 Zone* zone = this->zone();
119
120 HInstruction* load = BuildUncheckedMonomorphicElementAccess(
121 GetParameter(0), GetParameter(1), NULL, NULL,
122 casted_stub()->is_js_array(), casted_stub()->elements_kind(), false);
123 AddInstruction(load);
124
125 HReturn* ret = new(zone) HReturn(load);
126 current_block()->Finish(ret);
127 }
128
129
130 Handle<Code> KeyedLoadFastElementStub::GenerateCode() {
131 CodeStubGraphBuilder<KeyedLoadFastElementStub> builder(this);
132 return CodeFromGraph(builder.CreateGraph());
133 }
134
135
136 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698