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

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

Issue 12317044: Fix bugs in generating and printing of Crankshaft stubs (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Final version Created 7 years, 10 months 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 | « no previous file | src/deoptimizer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 if (chunk == NULL) { 49 if (chunk == NULL) {
50 FATAL(graph->info()->bailout_reason()); 50 FATAL(graph->info()->bailout_reason());
51 } 51 }
52 return chunk; 52 return chunk;
53 } 53 }
54 54
55 55
56 class CodeStubGraphBuilderBase : public HGraphBuilder { 56 class CodeStubGraphBuilderBase : public HGraphBuilder {
57 public: 57 public:
58 CodeStubGraphBuilderBase(Isolate* isolate, HydrogenCodeStub* stub) 58 CodeStubGraphBuilderBase(Isolate* isolate, HydrogenCodeStub* stub)
59 : HGraphBuilder(&info_), info_(stub, isolate), context_(NULL) {} 59 : HGraphBuilder(&info_), info_(stub, isolate), context_(NULL) {
60 int major_key = stub->MajorKey();
61 descriptor_ = info_.isolate()->code_stub_interface_descriptor(major_key);
62 if (descriptor_->register_param_count_ < 0) {
63 stub->InitializeInterfaceDescriptor(info_.isolate(), descriptor_);
64 }
65 parameters_.Reset(new HParameter*[descriptor_->register_param_count_]);
66 }
60 virtual bool BuildGraph(); 67 virtual bool BuildGraph();
61 68
62 protected: 69 protected:
63 virtual void BuildCodeStub() = 0; 70 virtual void BuildCodeStub() = 0;
64 HParameter* GetParameter(int parameter) { return parameters_[parameter]; } 71 HParameter* GetParameter(int parameter) { return parameters_[parameter]; }
65 CompilationInfo* info() { return &info_; } 72 CompilationInfo* info() { return &info_; }
66 HydrogenCodeStub* stub() { return info_.code_stub(); } 73 HydrogenCodeStub* stub() { return info_.code_stub(); }
67 HContext* context() { return context_; } 74 HContext* context() { return context_; }
68 Isolate* isolate() { return info_.isolate(); } 75 Isolate* isolate() { return info_.isolate(); }
69 76
70 private: 77 private:
71 SmartArrayPointer<HParameter*> parameters_; 78 SmartArrayPointer<HParameter*> parameters_;
72 CompilationInfoWithZone info_; 79 CompilationInfoWithZone info_;
80 CodeStubInterfaceDescriptor* descriptor_;
73 HContext* context_; 81 HContext* context_;
74 }; 82 };
75 83
76 84
77 bool CodeStubGraphBuilderBase::BuildGraph() { 85 bool CodeStubGraphBuilderBase::BuildGraph() {
78 if (FLAG_trace_hydrogen) { 86 if (FLAG_trace_hydrogen) {
79 const char* name = CodeStub::MajorName(stub()->MajorKey(), false); 87 const char* name = CodeStub::MajorName(stub()->MajorKey(), false);
80 PrintF("-----------------------------------------------------------\n"); 88 PrintF("-----------------------------------------------------------\n");
81 PrintF("Compiling stub %s using hydrogen\n", name); 89 PrintF("Compiling stub %s using hydrogen\n", name);
82 HTracer::Instance()->TraceCompilation(&info_); 90 HTracer::Instance()->TraceCompilation(&info_);
83 } 91 }
84 HBasicBlock* next_block = graph()->CreateBasicBlock(); 92
85 next_block->SetInitialEnvironment(graph()->start_environment()); 93 Zone* zone = this->zone();
86 HGoto* jump = new(zone()) HGoto(next_block); 94 HEnvironment* start_environment =
87 graph()->entry_block()->Finish(jump); 95 new(zone) HEnvironment(zone, descriptor_->register_param_count_);
96 HBasicBlock* next_block = CreateBasicBlock(start_environment);
97
98 current_block()->Goto(next_block);
99 next_block->SetJoinId(BailoutId::StubEntry());
88 set_current_block(next_block); 100 set_current_block(next_block);
89 101
90 int major_key = stub()->MajorKey(); 102 HConstant* undefined_constant = new(zone) HConstant(
91 CodeStubInterfaceDescriptor* descriptor =
92 info_.isolate()->code_stub_interface_descriptor(major_key);
93 if (descriptor->register_param_count_ < 0) {
94 stub()->InitializeInterfaceDescriptor(info_.isolate(), descriptor);
95 }
96 parameters_.Reset(new HParameter*[descriptor->register_param_count_]);
97
98 HConstant* undefined_constant = new(zone()) HConstant(
99 isolate()->factory()->undefined_value(), Representation::Tagged()); 103 isolate()->factory()->undefined_value(), Representation::Tagged());
100 AddInstruction(undefined_constant); 104 AddInstruction(undefined_constant);
101 graph()->set_undefined_constant(undefined_constant); 105 graph()->set_undefined_constant(undefined_constant);
102 106
103 HGraph* graph = this->graph(); 107 int param_count = descriptor_->register_param_count_;
104 Zone* zone = this->zone(); 108 for (int i = 0; i < param_count; ++i) {
105 for (int i = 0; i < descriptor->register_param_count_; ++i) {
106 HParameter* param = 109 HParameter* param =
107 new(zone) HParameter(i, HParameter::REGISTER_PARAMETER); 110 new(zone) HParameter(i, HParameter::REGISTER_PARAMETER);
108 AddInstruction(param); 111 AddInstruction(param);
109 graph->start_environment()->Push(param); 112 start_environment->Bind(i, param);
110 parameters_[i] = param; 113 parameters_[i] = param;
111 } 114 }
112 115
113 context_ = new(zone) HContext(); 116 context_ = new(zone) HContext();
114 AddInstruction(context_); 117 AddInstruction(context_);
118 start_environment->Bind(param_count, context_);
115 119
116 AddSimulate(BailoutId::StubEntry()); 120 AddSimulate(BailoutId::StubEntry());
117 121
118 BuildCodeStub(); 122 BuildCodeStub();
119 123
120 return true; 124 return true;
121 } 125 }
122 126
123 template <class Stub> 127 template <class Stub>
124 class CodeStubGraphBuilder: public CodeStubGraphBuilderBase { 128 class CodeStubGraphBuilder: public CodeStubGraphBuilderBase {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 181
178 HConstant* max_alloc_size = 182 HConstant* max_alloc_size =
179 new(zone) HConstant(kMinFreeNewSpaceAfterGC, Representation::Integer32()); 183 new(zone) HConstant(kMinFreeNewSpaceAfterGC, Representation::Integer32());
180 AddInstruction(max_alloc_size); 184 AddInstruction(max_alloc_size);
181 // Since we're forcing Integer32 representation for this HBoundsCheck, 185 // Since we're forcing Integer32 representation for this HBoundsCheck,
182 // there's no need to Smi-check the index. 186 // there's no need to Smi-check the index.
183 AddInstruction( 187 AddInstruction(
184 new(zone) HBoundsCheck(array_length, max_alloc_size, 188 new(zone) HBoundsCheck(array_length, max_alloc_size,
185 DONT_ALLOW_SMI_KEY, Representation::Integer32())); 189 DONT_ALLOW_SMI_KEY, Representation::Integer32()));
186 190
187 current_block()->UpdateEnvironment(new(zone) HEnvironment(zone));
188
189 IfBuilder if_builder(this); 191 IfBuilder if_builder(this);
190 192
191 if_builder.BeginTrue(array_length, graph()->GetConstant0(), Token::EQ); 193 if_builder.BeginTrue(array_length, graph()->GetConstant0(), Token::EQ);
192 194
193 // Nothing to do, just change the map. 195 // Nothing to do, just change the map.
194 196
195 if_builder.BeginFalse(); 197 if_builder.BeginFalse();
196 198
197 HInstruction* elements = 199 HInstruction* elements =
198 AddInstruction(new(zone) HLoadElements(js_array, js_array)); 200 AddInstruction(new(zone) HLoadElements(js_array, js_array));
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 251
250 252
251 Handle<Code> TransitionElementsKindStub::GenerateCode() { 253 Handle<Code> TransitionElementsKindStub::GenerateCode() {
252 CodeStubGraphBuilder<TransitionElementsKindStub> builder(this); 254 CodeStubGraphBuilder<TransitionElementsKindStub> builder(this);
253 LChunk* chunk = OptimizeGraph(builder.CreateGraph()); 255 LChunk* chunk = OptimizeGraph(builder.CreateGraph());
254 return chunk->Codegen(Code::COMPILED_STUB); 256 return chunk->Codegen(Code::COMPILED_STUB);
255 } 257 }
256 258
257 259
258 } } // namespace v8::internal 260 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/deoptimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698