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

Side by Side Diff: src/compiler/raw-machine-assembler.cc

Issue 1362783004: Revert of [turbofan] Checking of input counts on node creation (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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
« no previous file with comments | « src/compiler/raw-machine-assembler.h ('k') | src/compiler/simplified-lowering.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/raw-machine-assembler.h" 5 #include "src/compiler/raw-machine-assembler.h"
6 6
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 #include "src/compiler/pipeline.h" 8 #include "src/compiler/pipeline.h"
9 #include "src/compiler/scheduler.h" 9 #include "src/compiler/scheduler.h"
10 10
(...skipping 14 matching lines...) Expand all
25 parameters_(nullptr), 25 parameters_(nullptr),
26 current_block_(schedule()->start()) { 26 current_block_(schedule()->start()) {
27 int param_count = static_cast<int>(parameter_count()); 27 int param_count = static_cast<int>(parameter_count());
28 // Add an extra input node for the JSFunction parameter to the start node. 28 // Add an extra input node for the JSFunction parameter to the start node.
29 Node* s = graph->NewNode(common_.Start(param_count + 1)); 29 Node* s = graph->NewNode(common_.Start(param_count + 1));
30 graph->SetStart(s); 30 graph->SetStart(s);
31 if (parameter_count() == 0) return; 31 if (parameter_count() == 0) return;
32 parameters_ = zone()->NewArray<Node*>(param_count); 32 parameters_ = zone()->NewArray<Node*>(param_count);
33 for (size_t i = 0; i < parameter_count(); ++i) { 33 for (size_t i = 0; i < parameter_count(); ++i) {
34 parameters_[i] = 34 parameters_[i] =
35 AddNode(common()->Parameter(static_cast<int>(i)), graph->start()); 35 NewNode(common()->Parameter(static_cast<int>(i)), graph->start());
36 } 36 }
37 } 37 }
38 38
39 39
40 Schedule* RawMachineAssembler::Export() { 40 Schedule* RawMachineAssembler::Export() {
41 // Compute the correct codegen order. 41 // Compute the correct codegen order.
42 DCHECK(schedule_->rpo_order()->empty()); 42 DCHECK(schedule_->rpo_order()->empty());
43 Scheduler::ComputeSpecialRPO(zone(), schedule_); 43 Scheduler::ComputeSpecialRPO(zone(), schedule_);
44 // Invalidate RawMachineAssembler. 44 // Invalidate RawMachineAssembler.
45 Schedule* schedule = schedule_; 45 Schedule* schedule = schedule_;
(...skipping 11 matching lines...) Expand all
57 void RawMachineAssembler::Goto(Label* label) { 57 void RawMachineAssembler::Goto(Label* label) {
58 DCHECK(current_block_ != schedule()->end()); 58 DCHECK(current_block_ != schedule()->end());
59 schedule()->AddGoto(CurrentBlock(), Use(label)); 59 schedule()->AddGoto(CurrentBlock(), Use(label));
60 current_block_ = nullptr; 60 current_block_ = nullptr;
61 } 61 }
62 62
63 63
64 void RawMachineAssembler::Branch(Node* condition, Label* true_val, 64 void RawMachineAssembler::Branch(Node* condition, Label* true_val,
65 Label* false_val) { 65 Label* false_val) {
66 DCHECK(current_block_ != schedule()->end()); 66 DCHECK(current_block_ != schedule()->end());
67 Node* branch = AddNode(common()->Branch(), condition); 67 Node* branch = NewNode(common()->Branch(), condition);
68 schedule()->AddBranch(CurrentBlock(), branch, Use(true_val), Use(false_val)); 68 schedule()->AddBranch(CurrentBlock(), branch, Use(true_val), Use(false_val));
69 current_block_ = nullptr; 69 current_block_ = nullptr;
70 } 70 }
71 71
72 72
73 void RawMachineAssembler::Switch(Node* index, Label* default_label, 73 void RawMachineAssembler::Switch(Node* index, Label* default_label,
74 int32_t* case_values, Label** case_labels, 74 int32_t* case_values, Label** case_labels,
75 size_t case_count) { 75 size_t case_count) {
76 DCHECK_NE(schedule()->end(), current_block_); 76 DCHECK_NE(schedule()->end(), current_block_);
77 size_t succ_count = case_count + 1; 77 size_t succ_count = case_count + 1;
78 Node* switch_node = AddNode(common()->Switch(succ_count), index); 78 Node* switch_node = NewNode(common()->Switch(succ_count), index);
79 BasicBlock** succ_blocks = zone()->NewArray<BasicBlock*>(succ_count); 79 BasicBlock** succ_blocks = zone()->NewArray<BasicBlock*>(succ_count);
80 for (size_t index = 0; index < case_count; ++index) { 80 for (size_t index = 0; index < case_count; ++index) {
81 int32_t case_value = case_values[index]; 81 int32_t case_value = case_values[index];
82 BasicBlock* case_block = Use(case_labels[index]); 82 BasicBlock* case_block = Use(case_labels[index]);
83 Node* case_node = 83 Node* case_node =
84 graph()->NewNode(common()->IfValue(case_value), switch_node); 84 graph()->NewNode(common()->IfValue(case_value), switch_node);
85 schedule()->AddNode(case_block, case_node); 85 schedule()->AddNode(case_block, case_node);
86 succ_blocks[index] = case_block; 86 succ_blocks[index] = case_block;
87 } 87 }
88 BasicBlock* default_block = Use(default_label); 88 BasicBlock* default_block = Use(default_label);
89 Node* default_node = graph()->NewNode(common()->IfDefault(), switch_node); 89 Node* default_node = graph()->NewNode(common()->IfDefault(), switch_node);
90 schedule()->AddNode(default_block, default_node); 90 schedule()->AddNode(default_block, default_node);
91 succ_blocks[case_count] = default_block; 91 succ_blocks[case_count] = default_block;
92 schedule()->AddSwitch(CurrentBlock(), switch_node, succ_blocks, succ_count); 92 schedule()->AddSwitch(CurrentBlock(), switch_node, succ_blocks, succ_count);
93 current_block_ = nullptr; 93 current_block_ = nullptr;
94 } 94 }
95 95
96 96
97 void RawMachineAssembler::Return(Node* value) { 97 void RawMachineAssembler::Return(Node* value) {
98 Node* ret = MakeNode(common()->Return(), 1, &value); 98 Node* ret = graph()->NewNode(common()->Return(), value);
99 schedule()->AddReturn(CurrentBlock(), ret); 99 schedule()->AddReturn(CurrentBlock(), ret);
100 current_block_ = nullptr; 100 current_block_ = nullptr;
101 } 101 }
102 102
103 103
104 Node* RawMachineAssembler::CallN(CallDescriptor* desc, Node* function, 104 Node* RawMachineAssembler::CallN(CallDescriptor* desc, Node* function,
105 Node** args) { 105 Node** args) {
106 int param_count = 106 int param_count =
107 static_cast<int>(desc->GetMachineSignature()->parameter_count()); 107 static_cast<int>(desc->GetMachineSignature()->parameter_count());
108 int input_count = param_count + 3; 108 int input_count = param_count + 3;
109 Node** buffer = zone()->NewArray<Node*>(input_count); 109 Node** buffer = zone()->NewArray<Node*>(input_count);
110 int index = 0; 110 int index = 0;
111 buffer[index++] = function; 111 buffer[index++] = function;
112 for (int i = 0; i < param_count; i++) { 112 for (int i = 0; i < param_count; i++) {
113 buffer[index++] = args[i]; 113 buffer[index++] = args[i];
114 } 114 }
115 buffer[index++] = graph()->start(); 115 buffer[index++] = graph()->start();
116 buffer[index++] = graph()->start(); 116 buffer[index++] = graph()->start();
117 return AddNode(common()->Call(desc), input_count, buffer); 117 Node* call = graph()->NewNode(common()->Call(desc), input_count, buffer);
118 schedule()->AddNode(CurrentBlock(), call);
119 return call;
118 } 120 }
119 121
120 122
121 Node* RawMachineAssembler::CallNWithFrameState(CallDescriptor* desc, 123 Node* RawMachineAssembler::CallNWithFrameState(CallDescriptor* desc,
122 Node* function, Node** args, 124 Node* function, Node** args,
123 Node* frame_state) { 125 Node* frame_state) {
124 DCHECK(desc->NeedsFrameState()); 126 DCHECK(desc->NeedsFrameState());
125 int param_count = 127 int param_count =
126 static_cast<int>(desc->GetMachineSignature()->parameter_count()); 128 static_cast<int>(desc->GetMachineSignature()->parameter_count());
127 int input_count = param_count + 4; 129 int input_count = param_count + 4;
128 Node** buffer = zone()->NewArray<Node*>(input_count); 130 Node** buffer = zone()->NewArray<Node*>(input_count);
129 int index = 0; 131 int index = 0;
130 buffer[index++] = function; 132 buffer[index++] = function;
131 for (int i = 0; i < param_count; i++) { 133 for (int i = 0; i < param_count; i++) {
132 buffer[index++] = args[i]; 134 buffer[index++] = args[i];
133 } 135 }
134 buffer[index++] = frame_state; 136 buffer[index++] = frame_state;
135 buffer[index++] = graph()->start(); 137 buffer[index++] = graph()->start();
136 buffer[index++] = graph()->start(); 138 buffer[index++] = graph()->start();
137 return AddNode(common()->Call(desc), input_count, buffer); 139 Node* call = graph()->NewNode(common()->Call(desc), input_count, buffer);
140 schedule()->AddNode(CurrentBlock(), call);
141 return call;
138 } 142 }
139 143
140 144
141 Node* RawMachineAssembler::TailCallN(CallDescriptor* desc, Node* function, 145 Node* RawMachineAssembler::TailCallN(CallDescriptor* desc, Node* function,
142 Node** args) { 146 Node** args) {
143 int param_count = 147 int param_count =
144 static_cast<int>(desc->GetMachineSignature()->parameter_count()); 148 static_cast<int>(desc->GetMachineSignature()->parameter_count());
145 int input_count = param_count + 3; 149 int input_count = param_count + 3;
146 Node** buffer = zone()->NewArray<Node*>(input_count); 150 Node** buffer = zone()->NewArray<Node*>(input_count);
147 int index = 0; 151 int index = 0;
148 buffer[index++] = function; 152 buffer[index++] = function;
149 for (int i = 0; i < param_count; i++) { 153 for (int i = 0; i < param_count; i++) {
150 buffer[index++] = args[i]; 154 buffer[index++] = args[i];
151 } 155 }
152 buffer[index++] = graph()->start(); 156 buffer[index++] = graph()->start();
153 buffer[index++] = graph()->start(); 157 buffer[index++] = graph()->start();
154 Node* tail_call = MakeNode(common()->TailCall(desc), input_count, buffer); 158 Node* tail_call =
159 graph()->NewNode(common()->TailCall(desc), input_count, buffer);
155 schedule()->AddTailCall(CurrentBlock(), tail_call); 160 schedule()->AddTailCall(CurrentBlock(), tail_call);
156 return tail_call; 161 return tail_call;
157 } 162 }
158 163
159 164
160 Node* RawMachineAssembler::CallFunctionStub0(Node* function, Node* receiver, 165 Node* RawMachineAssembler::CallFunctionStub0(Node* function, Node* receiver,
161 Node* context, Node* frame_state, 166 Node* context, Node* frame_state,
162 CallFunctionFlags flags) { 167 CallFunctionFlags flags) {
163 Callable callable = CodeFactory::CallFunction(isolate(), 0, flags); 168 Callable callable = CodeFactory::CallFunction(isolate(), 0, flags);
164 CallDescriptor* desc = Linkage::GetStubCallDescriptor( 169 CallDescriptor* desc = Linkage::GetStubCallDescriptor(
165 isolate(), zone(), callable.descriptor(), 1, 170 isolate(), zone(), callable.descriptor(), 1,
166 CallDescriptor::kNeedsFrameState, Operator::kNoProperties); 171 CallDescriptor::kNeedsFrameState, Operator::kNoProperties);
167 Node* stub_code = HeapConstant(callable.code()); 172 Node* stub_code = HeapConstant(callable.code());
168 return AddNode(common()->Call(desc), stub_code, function, receiver, context, 173 Node* call = graph()->NewNode(common()->Call(desc), stub_code, function,
169 frame_state, graph()->start(), graph()->start()); 174 receiver, context, frame_state,
175 graph()->start(), graph()->start());
176 schedule()->AddNode(CurrentBlock(), call);
177 return call;
170 } 178 }
171 179
172 180
173 Node* RawMachineAssembler::CallRuntime1(Runtime::FunctionId function, 181 Node* RawMachineAssembler::CallRuntime1(Runtime::FunctionId function,
174 Node* arg1, Node* context) { 182 Node* arg1, Node* context) {
175 CallDescriptor* descriptor = Linkage::GetRuntimeCallDescriptor( 183 CallDescriptor* descriptor = Linkage::GetRuntimeCallDescriptor(
176 zone(), function, 1, Operator::kNoProperties, false); 184 zone(), function, 1, Operator::kNoProperties, false);
177 185
178 Node* centry = HeapConstant(CEntryStub(isolate(), 1).GetCode()); 186 Node* centry = HeapConstant(CEntryStub(isolate(), 1).GetCode());
179 Node* ref = AddNode( 187 Node* ref = NewNode(
180 common()->ExternalConstant(ExternalReference(function, isolate()))); 188 common()->ExternalConstant(ExternalReference(function, isolate())));
181 Node* arity = Int32Constant(1); 189 Node* arity = Int32Constant(1);
182 190
183 return AddNode(common()->Call(descriptor), centry, arg1, ref, arity, context, 191 Node* call =
184 graph()->start(), graph()->start()); 192 graph()->NewNode(common()->Call(descriptor), centry, arg1, ref, arity,
193 context, graph()->start(), graph()->start());
194 schedule()->AddNode(CurrentBlock(), call);
195 return call;
185 } 196 }
186 197
187 198
188 Node* RawMachineAssembler::CallRuntime2(Runtime::FunctionId function, 199 Node* RawMachineAssembler::CallRuntime2(Runtime::FunctionId function,
189 Node* arg1, Node* arg2, Node* context) { 200 Node* arg1, Node* arg2, Node* context) {
190 CallDescriptor* descriptor = Linkage::GetRuntimeCallDescriptor( 201 CallDescriptor* descriptor = Linkage::GetRuntimeCallDescriptor(
191 zone(), function, 2, Operator::kNoProperties, false); 202 zone(), function, 2, Operator::kNoProperties, false);
192 203
193 Node* centry = HeapConstant(CEntryStub(isolate(), 1).GetCode()); 204 Node* centry = HeapConstant(CEntryStub(isolate(), 1).GetCode());
194 Node* ref = AddNode( 205 Node* ref = NewNode(
195 common()->ExternalConstant(ExternalReference(function, isolate()))); 206 common()->ExternalConstant(ExternalReference(function, isolate())));
196 Node* arity = Int32Constant(2); 207 Node* arity = Int32Constant(2);
197 208
198 return AddNode(common()->Call(descriptor), centry, arg1, arg2, ref, arity, 209 Node* call =
199 context, graph()->start(), graph()->start()); 210 graph()->NewNode(common()->Call(descriptor), centry, arg1, arg2, ref,
211 arity, context, graph()->start(), graph()->start());
212 schedule()->AddNode(CurrentBlock(), call);
213 return call;
200 } 214 }
201 215
202 216
203 Node* RawMachineAssembler::CallCFunction0(MachineType return_type, 217 Node* RawMachineAssembler::CallCFunction0(MachineType return_type,
204 Node* function) { 218 Node* function) {
205 MachineSignature::Builder builder(zone(), 1, 0); 219 MachineSignature::Builder builder(zone(), 1, 0);
206 builder.AddReturn(return_type); 220 builder.AddReturn(return_type);
207 const CallDescriptor* descriptor = 221 const CallDescriptor* descriptor =
208 Linkage::GetSimplifiedCDescriptor(zone(), builder.Build()); 222 Linkage::GetSimplifiedCDescriptor(zone(), builder.Build());
209 223
210 return AddNode(common()->Call(descriptor), function, graph()->start(), 224 Node* call = graph()->NewNode(common()->Call(descriptor), function,
211 graph()->start()); 225 graph()->start(), graph()->start());
226 schedule()->AddNode(CurrentBlock(), call);
227 return call;
212 } 228 }
213 229
214 230
215 Node* RawMachineAssembler::CallCFunction1(MachineType return_type, 231 Node* RawMachineAssembler::CallCFunction1(MachineType return_type,
216 MachineType arg0_type, Node* function, 232 MachineType arg0_type, Node* function,
217 Node* arg0) { 233 Node* arg0) {
218 MachineSignature::Builder builder(zone(), 1, 1); 234 MachineSignature::Builder builder(zone(), 1, 1);
219 builder.AddReturn(return_type); 235 builder.AddReturn(return_type);
220 builder.AddParam(arg0_type); 236 builder.AddParam(arg0_type);
221 const CallDescriptor* descriptor = 237 const CallDescriptor* descriptor =
222 Linkage::GetSimplifiedCDescriptor(zone(), builder.Build()); 238 Linkage::GetSimplifiedCDescriptor(zone(), builder.Build());
223 239
224 return AddNode(common()->Call(descriptor), function, arg0, graph()->start(), 240 Node* call = graph()->NewNode(common()->Call(descriptor), function, arg0,
225 graph()->start()); 241 graph()->start(), graph()->start());
242 schedule()->AddNode(CurrentBlock(), call);
243 return call;
226 } 244 }
227 245
228 246
229 Node* RawMachineAssembler::CallCFunction2(MachineType return_type, 247 Node* RawMachineAssembler::CallCFunction2(MachineType return_type,
230 MachineType arg0_type, 248 MachineType arg0_type,
231 MachineType arg1_type, Node* function, 249 MachineType arg1_type, Node* function,
232 Node* arg0, Node* arg1) { 250 Node* arg0, Node* arg1) {
233 MachineSignature::Builder builder(zone(), 1, 2); 251 MachineSignature::Builder builder(zone(), 1, 2);
234 builder.AddReturn(return_type); 252 builder.AddReturn(return_type);
235 builder.AddParam(arg0_type); 253 builder.AddParam(arg0_type);
236 builder.AddParam(arg1_type); 254 builder.AddParam(arg1_type);
237 const CallDescriptor* descriptor = 255 const CallDescriptor* descriptor =
238 Linkage::GetSimplifiedCDescriptor(zone(), builder.Build()); 256 Linkage::GetSimplifiedCDescriptor(zone(), builder.Build());
239 257
240 return AddNode(common()->Call(descriptor), function, arg0, arg1, 258 Node* call = graph()->NewNode(common()->Call(descriptor), function, arg0,
241 graph()->start(), graph()->start()); 259 arg1, graph()->start(), graph()->start());
260 schedule()->AddNode(CurrentBlock(), call);
261 return call;
242 } 262 }
243 263
244 264
245 Node* RawMachineAssembler::CallCFunction8( 265 Node* RawMachineAssembler::CallCFunction8(
246 MachineType return_type, MachineType arg0_type, MachineType arg1_type, 266 MachineType return_type, MachineType arg0_type, MachineType arg1_type,
247 MachineType arg2_type, MachineType arg3_type, MachineType arg4_type, 267 MachineType arg2_type, MachineType arg3_type, MachineType arg4_type,
248 MachineType arg5_type, MachineType arg6_type, MachineType arg7_type, 268 MachineType arg5_type, MachineType arg6_type, MachineType arg7_type,
249 Node* function, Node* arg0, Node* arg1, Node* arg2, Node* arg3, Node* arg4, 269 Node* function, Node* arg0, Node* arg1, Node* arg2, Node* arg3, Node* arg4,
250 Node* arg5, Node* arg6, Node* arg7) { 270 Node* arg5, Node* arg6, Node* arg7) {
251 MachineSignature::Builder builder(zone(), 1, 8); 271 MachineSignature::Builder builder(zone(), 1, 8);
(...skipping 12 matching lines...) Expand all
264 arg2, 284 arg2,
265 arg3, 285 arg3,
266 arg4, 286 arg4,
267 arg5, 287 arg5,
268 arg6, 288 arg6,
269 arg7, 289 arg7,
270 graph()->start(), 290 graph()->start(),
271 graph()->start()}; 291 graph()->start()};
272 const CallDescriptor* descriptor = 292 const CallDescriptor* descriptor =
273 Linkage::GetSimplifiedCDescriptor(zone(), builder.Build()); 293 Linkage::GetSimplifiedCDescriptor(zone(), builder.Build());
274 return AddNode(common()->Call(descriptor), arraysize(args), args); 294 Node* call =
295 graph()->NewNode(common()->Call(descriptor), arraysize(args), args);
296 schedule()->AddNode(CurrentBlock(), call);
297 return call;
275 } 298 }
276 299
277 300
278 void RawMachineAssembler::Bind(Label* label) { 301 void RawMachineAssembler::Bind(Label* label) {
279 DCHECK(current_block_ == nullptr); 302 DCHECK(current_block_ == nullptr);
280 DCHECK(!label->bound_); 303 DCHECK(!label->bound_);
281 label->bound_ = true; 304 label->bound_ = true;
282 current_block_ = EnsureBlock(label); 305 current_block_ = EnsureBlock(label);
283 } 306 }
284 307
285 308
286 BasicBlock* RawMachineAssembler::Use(Label* label) { 309 BasicBlock* RawMachineAssembler::Use(Label* label) {
287 label->used_ = true; 310 label->used_ = true;
288 return EnsureBlock(label); 311 return EnsureBlock(label);
289 } 312 }
290 313
291 314
292 BasicBlock* RawMachineAssembler::EnsureBlock(Label* label) { 315 BasicBlock* RawMachineAssembler::EnsureBlock(Label* label) {
293 if (label->block_ == nullptr) label->block_ = schedule()->NewBasicBlock(); 316 if (label->block_ == nullptr) label->block_ = schedule()->NewBasicBlock();
294 return label->block_; 317 return label->block_;
295 } 318 }
296 319
297 320
298 BasicBlock* RawMachineAssembler::CurrentBlock() { 321 BasicBlock* RawMachineAssembler::CurrentBlock() {
299 DCHECK(current_block_); 322 DCHECK(current_block_);
300 return current_block_; 323 return current_block_;
301 } 324 }
302 325
303 326
304 Node* RawMachineAssembler::AddNode(const Operator* op, int input_count,
305 Node** inputs) {
306 DCHECK_NOT_NULL(schedule_);
307 DCHECK(current_block_ != nullptr);
308 Node* node = MakeNode(op, input_count, inputs);
309 schedule()->AddNode(CurrentBlock(), node);
310 return node;
311 }
312
313
314 Node* RawMachineAssembler::MakeNode(const Operator* op, int input_count, 327 Node* RawMachineAssembler::MakeNode(const Operator* op, int input_count,
315 Node** inputs) { 328 Node** inputs) {
316 // The raw machine assembler nodes do not have effect and control inputs, 329 DCHECK_NOT_NULL(schedule_);
317 // so we disable checking input counts here. 330 DCHECK(current_block_ != nullptr);
318 return graph()->NewNodeUnchecked(op, input_count, inputs); 331 Node* node = graph()->NewNode(op, input_count, inputs);
332 schedule()->AddNode(CurrentBlock(), node);
333 return node;
319 } 334 }
320 335
321 } // namespace compiler 336 } // namespace compiler
322 } // namespace internal 337 } // namespace internal
323 } // namespace v8 338 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/raw-machine-assembler.h ('k') | src/compiler/simplified-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698