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

Side by Side Diff: src/compiler/js-generic-lowering.cc

Issue 761143002: Remove deprecated constant helpers from JSGenericLowering. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 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
« no previous file with comments | « src/compiler/js-generic-lowering.h ('k') | no next file » | 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/code-factory.h" 5 #include "src/code-factory.h"
6 #include "src/code-stubs.h" 6 #include "src/code-stubs.h"
7 #include "src/compiler/common-operator.h" 7 #include "src/compiler/common-operator.h"
8 #include "src/compiler/graph-inl.h" 8 #include "src/compiler/graph-inl.h"
9 #include "src/compiler/js-generic-lowering.h" 9 #include "src/compiler/js-generic-lowering.h"
10 #include "src/compiler/machine-operator.h" 10 #include "src/compiler/machine-operator.h"
(...skipping 15 matching lines...) Expand all
26 void JSGenericLowering::PatchOperator(Node* node, const Operator* op) { 26 void JSGenericLowering::PatchOperator(Node* node, const Operator* op) {
27 node->set_op(op); 27 node->set_op(op);
28 } 28 }
29 29
30 30
31 void JSGenericLowering::PatchInsertInput(Node* node, int index, Node* input) { 31 void JSGenericLowering::PatchInsertInput(Node* node, int index, Node* input) {
32 node->InsertInput(zone(), index, input); 32 node->InsertInput(zone(), index, input);
33 } 33 }
34 34
35 35
36 Node* JSGenericLowering::SmiConstant(int32_t immediate) {
37 return jsgraph()->SmiConstant(immediate);
38 }
39
40
41 Node* JSGenericLowering::Int32Constant(int immediate) {
42 return jsgraph()->Int32Constant(immediate);
43 }
44
45
46 Node* JSGenericLowering::CodeConstant(Handle<Code> code) {
47 return jsgraph()->HeapConstant(code);
48 }
49
50
51 Node* JSGenericLowering::FunctionConstant(Handle<JSFunction> function) {
52 return jsgraph()->HeapConstant(function);
53 }
54
55
56 Node* JSGenericLowering::ExternalConstant(ExternalReference ref) {
57 return jsgraph()->ExternalConstant(ref);
58 }
59
60
61 Reduction JSGenericLowering::Reduce(Node* node) { 36 Reduction JSGenericLowering::Reduce(Node* node) {
62 switch (node->opcode()) { 37 switch (node->opcode()) {
63 #define DECLARE_CASE(x) \ 38 #define DECLARE_CASE(x) \
64 case IrOpcode::k##x: \ 39 case IrOpcode::k##x: \
65 Lower##x(node); \ 40 Lower##x(node); \
66 break; 41 break;
67 DECLARE_CASE(Branch) 42 DECLARE_CASE(Branch)
68 JS_OP_LIST(DECLARE_CASE) 43 JS_OP_LIST(DECLARE_CASE)
69 #undef DECLARE_CASE 44 #undef DECLARE_CASE
70 default: 45 default:
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 118
144 void JSGenericLowering::ReplaceWithCompareIC(Node* node, Token::Value token, 119 void JSGenericLowering::ReplaceWithCompareIC(Node* node, Token::Value token,
145 bool pure) { 120 bool pure) {
146 Callable callable = CodeFactory::CompareIC(isolate(), token); 121 Callable callable = CodeFactory::CompareIC(isolate(), token);
147 bool has_frame_state = OperatorProperties::HasFrameStateInput(node->op()); 122 bool has_frame_state = OperatorProperties::HasFrameStateInput(node->op());
148 CallDescriptor* desc_compare = linkage()->GetStubCallDescriptor( 123 CallDescriptor* desc_compare = linkage()->GetStubCallDescriptor(
149 callable.descriptor(), 0, 124 callable.descriptor(), 0,
150 CallDescriptor::kPatchableCallSiteWithNop | FlagsForNode(node)); 125 CallDescriptor::kPatchableCallSiteWithNop | FlagsForNode(node));
151 NodeVector inputs(zone()); 126 NodeVector inputs(zone());
152 inputs.reserve(node->InputCount() + 1); 127 inputs.reserve(node->InputCount() + 1);
153 inputs.push_back(CodeConstant(callable.code())); 128 inputs.push_back(jsgraph()->HeapConstant(callable.code()));
154 inputs.push_back(NodeProperties::GetValueInput(node, 0)); 129 inputs.push_back(NodeProperties::GetValueInput(node, 0));
155 inputs.push_back(NodeProperties::GetValueInput(node, 1)); 130 inputs.push_back(NodeProperties::GetValueInput(node, 1));
156 inputs.push_back(NodeProperties::GetContextInput(node)); 131 inputs.push_back(NodeProperties::GetContextInput(node));
157 if (pure) { 132 if (pure) {
158 // A pure (strict) comparison doesn't have an effect, control or frame 133 // A pure (strict) comparison doesn't have an effect, control or frame
159 // state. But for the graph, we need to add control and effect inputs. 134 // state. But for the graph, we need to add control and effect inputs.
160 DCHECK(!has_frame_state); 135 DCHECK(!has_frame_state);
161 inputs.push_back(graph()->start()); 136 inputs.push_back(graph()->start());
162 inputs.push_back(graph()->start()); 137 inputs.push_back(graph()->start());
163 } else { 138 } else {
164 DCHECK(has_frame_state == FLAG_turbo_deoptimization); 139 DCHECK(has_frame_state == FLAG_turbo_deoptimization);
165 if (FLAG_turbo_deoptimization) { 140 if (FLAG_turbo_deoptimization) {
166 inputs.push_back(NodeProperties::GetFrameStateInput(node)); 141 inputs.push_back(NodeProperties::GetFrameStateInput(node));
167 } 142 }
168 inputs.push_back(NodeProperties::GetEffectInput(node)); 143 inputs.push_back(NodeProperties::GetEffectInput(node));
169 inputs.push_back(NodeProperties::GetControlInput(node)); 144 inputs.push_back(NodeProperties::GetControlInput(node));
170 } 145 }
171 Node* compare = 146 Node* compare =
172 graph()->NewNode(common()->Call(desc_compare), 147 graph()->NewNode(common()->Call(desc_compare),
173 static_cast<int>(inputs.size()), &inputs.front()); 148 static_cast<int>(inputs.size()), &inputs.front());
174 149
175 node->ReplaceInput(0, compare); 150 node->ReplaceInput(0, compare);
176 node->ReplaceInput(1, SmiConstant(token)); 151 node->ReplaceInput(1, jsgraph()->SmiConstant(token));
177 152
178 if (has_frame_state) { 153 if (has_frame_state) {
179 // Remove the frame state from inputs. 154 // Remove the frame state from inputs.
180 node->RemoveInput(NodeProperties::FirstFrameStateIndex(node)); 155 node->RemoveInput(NodeProperties::FirstFrameStateIndex(node));
181 } 156 }
182 157
183 ReplaceWithRuntimeCall(node, Runtime::kBooleanize); 158 ReplaceWithRuntimeCall(node, Runtime::kBooleanize);
184 } 159 }
185 160
186 161
187 void JSGenericLowering::ReplaceWithStubCall(Node* node, Callable callable, 162 void JSGenericLowering::ReplaceWithStubCall(Node* node, Callable callable,
188 CallDescriptor::Flags flags) { 163 CallDescriptor::Flags flags) {
189 CallDescriptor* desc = linkage()->GetStubCallDescriptor( 164 CallDescriptor* desc = linkage()->GetStubCallDescriptor(
190 callable.descriptor(), 0, flags | FlagsForNode(node)); 165 callable.descriptor(), 0, flags | FlagsForNode(node));
191 Node* stub_code = CodeConstant(callable.code()); 166 Node* stub_code = jsgraph()->HeapConstant(callable.code());
192 PatchInsertInput(node, 0, stub_code); 167 PatchInsertInput(node, 0, stub_code);
193 PatchOperator(node, common()->Call(desc)); 168 PatchOperator(node, common()->Call(desc));
194 } 169 }
195 170
196 171
197 void JSGenericLowering::ReplaceWithBuiltinCall(Node* node, 172 void JSGenericLowering::ReplaceWithBuiltinCall(Node* node,
198 Builtins::JavaScript id, 173 Builtins::JavaScript id,
199 int nargs) { 174 int nargs) {
200 Callable callable = 175 Callable callable =
201 CodeFactory::CallFunction(isolate(), nargs - 1, NO_CALL_FUNCTION_FLAGS); 176 CodeFactory::CallFunction(isolate(), nargs - 1, NO_CALL_FUNCTION_FLAGS);
202 CallDescriptor* desc = linkage()->GetStubCallDescriptor( 177 CallDescriptor* desc = linkage()->GetStubCallDescriptor(
203 callable.descriptor(), nargs, FlagsForNode(node)); 178 callable.descriptor(), nargs, FlagsForNode(node));
204 // TODO(mstarzinger): Accessing the builtins object this way prevents sharing 179 // TODO(mstarzinger): Accessing the builtins object this way prevents sharing
205 // of code across native contexts. Fix this by loading from given context. 180 // of code across native contexts. Fix this by loading from given context.
206 Handle<JSFunction> function( 181 Handle<JSFunction> function(
207 JSFunction::cast(info()->context()->builtins()->javascript_builtin(id))); 182 JSFunction::cast(info()->context()->builtins()->javascript_builtin(id)));
208 Node* stub_code = CodeConstant(callable.code()); 183 Node* stub_code = jsgraph()->HeapConstant(callable.code());
209 Node* function_node = FunctionConstant(function); 184 Node* function_node = jsgraph()->HeapConstant(function);
210 PatchInsertInput(node, 0, stub_code); 185 PatchInsertInput(node, 0, stub_code);
211 PatchInsertInput(node, 1, function_node); 186 PatchInsertInput(node, 1, function_node);
212 PatchOperator(node, common()->Call(desc)); 187 PatchOperator(node, common()->Call(desc));
213 } 188 }
214 189
215 190
216 void JSGenericLowering::ReplaceWithRuntimeCall(Node* node, 191 void JSGenericLowering::ReplaceWithRuntimeCall(Node* node,
217 Runtime::FunctionId f, 192 Runtime::FunctionId f,
218 int nargs_override) { 193 int nargs_override) {
219 Operator::Properties properties = node->op()->properties(); 194 Operator::Properties properties = node->op()->properties();
220 const Runtime::Function* fun = Runtime::FunctionForId(f); 195 const Runtime::Function* fun = Runtime::FunctionForId(f);
221 int nargs = (nargs_override < 0) ? fun->nargs : nargs_override; 196 int nargs = (nargs_override < 0) ? fun->nargs : nargs_override;
222 CallDescriptor* desc = 197 CallDescriptor* desc =
223 linkage()->GetRuntimeCallDescriptor(f, nargs, properties); 198 linkage()->GetRuntimeCallDescriptor(f, nargs, properties);
224 Node* ref = ExternalConstant(ExternalReference(f, isolate())); 199 Node* ref = jsgraph()->ExternalConstant(ExternalReference(f, isolate()));
225 Node* arity = Int32Constant(nargs); 200 Node* arity = jsgraph()->Int32Constant(nargs);
226 PatchInsertInput(node, 0, jsgraph()->CEntryStubConstant(fun->result_size)); 201 PatchInsertInput(node, 0, jsgraph()->CEntryStubConstant(fun->result_size));
227 PatchInsertInput(node, nargs + 1, ref); 202 PatchInsertInput(node, nargs + 1, ref);
228 PatchInsertInput(node, nargs + 2, arity); 203 PatchInsertInput(node, nargs + 2, arity);
229 PatchOperator(node, common()->Call(desc)); 204 PatchOperator(node, common()->Call(desc));
230 } 205 }
231 206
232 207
233 void JSGenericLowering::LowerBranch(Node* node) { 208 void JSGenericLowering::LowerBranch(Node* node) {
234 if (!info()->is_typing_enabled()) { 209 if (!info()->is_typing_enabled()) {
235 // TODO(mstarzinger): If typing is enabled then simplified lowering will 210 // TODO(mstarzinger): If typing is enabled then simplified lowering will
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 void JSGenericLowering::LowerJSStoreNamed(Node* node) { 281 void JSGenericLowering::LowerJSStoreNamed(Node* node) {
307 const StoreNamedParameters& p = StoreNamedParametersOf(node->op()); 282 const StoreNamedParameters& p = StoreNamedParametersOf(node->op());
308 Callable callable = CodeFactory::StoreIC(isolate(), p.strict_mode()); 283 Callable callable = CodeFactory::StoreIC(isolate(), p.strict_mode());
309 PatchInsertInput(node, 1, jsgraph()->HeapConstant(p.name())); 284 PatchInsertInput(node, 1, jsgraph()->HeapConstant(p.name()));
310 ReplaceWithStubCall(node, callable, CallDescriptor::kPatchableCallSite); 285 ReplaceWithStubCall(node, callable, CallDescriptor::kPatchableCallSite);
311 } 286 }
312 287
313 288
314 void JSGenericLowering::LowerJSDeleteProperty(Node* node) { 289 void JSGenericLowering::LowerJSDeleteProperty(Node* node) {
315 StrictMode strict_mode = OpParameter<StrictMode>(node); 290 StrictMode strict_mode = OpParameter<StrictMode>(node);
316 PatchInsertInput(node, 2, SmiConstant(strict_mode)); 291 PatchInsertInput(node, 2, jsgraph()->SmiConstant(strict_mode));
317 ReplaceWithBuiltinCall(node, Builtins::DELETE, 3); 292 ReplaceWithBuiltinCall(node, Builtins::DELETE, 3);
318 } 293 }
319 294
320 295
321 void JSGenericLowering::LowerJSHasProperty(Node* node) { 296 void JSGenericLowering::LowerJSHasProperty(Node* node) {
322 ReplaceWithBuiltinCall(node, Builtins::IN, 2); 297 ReplaceWithBuiltinCall(node, Builtins::IN, 2);
323 } 298 }
324 299
325 300
326 void JSGenericLowering::LowerJSInstanceOf(Node* node) { 301 void JSGenericLowering::LowerJSInstanceOf(Node* node) {
327 InstanceofStub::Flags flags = static_cast<InstanceofStub::Flags>( 302 InstanceofStub::Flags flags = static_cast<InstanceofStub::Flags>(
328 InstanceofStub::kReturnTrueFalseObject | 303 InstanceofStub::kReturnTrueFalseObject |
329 InstanceofStub::kArgsInRegisters); 304 InstanceofStub::kArgsInRegisters);
330 InstanceofStub stub(isolate(), flags); 305 InstanceofStub stub(isolate(), flags);
331 CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor(); 306 CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor();
332 CallDescriptor* desc = 307 CallDescriptor* desc =
333 linkage()->GetStubCallDescriptor(d, 0, FlagsForNode(node)); 308 linkage()->GetStubCallDescriptor(d, 0, FlagsForNode(node));
334 Node* stub_code = CodeConstant(stub.GetCode()); 309 Node* stub_code = jsgraph()->HeapConstant(stub.GetCode());
335 PatchInsertInput(node, 0, stub_code); 310 PatchInsertInput(node, 0, stub_code);
336 PatchOperator(node, common()->Call(desc)); 311 PatchOperator(node, common()->Call(desc));
337 } 312 }
338 313
339 314
340 void JSGenericLowering::LowerJSLoadContext(Node* node) { 315 void JSGenericLowering::LowerJSLoadContext(Node* node) {
341 const ContextAccess& access = ContextAccessOf(node->op()); 316 const ContextAccess& access = ContextAccessOf(node->op());
342 for (size_t i = 0; i < access.depth(); ++i) { 317 for (size_t i = 0; i < access.depth(); ++i) {
343 node->ReplaceInput( 318 node->ReplaceInput(
344 0, graph()->NewNode( 319 0, graph()->NewNode(machine()->Load(kMachAnyTagged),
345 machine()->Load(kMachAnyTagged), 320 NodeProperties::GetValueInput(node, 0),
346 NodeProperties::GetValueInput(node, 0), 321 jsgraph()->Int32Constant(
347 Int32Constant(Context::SlotOffset(Context::PREVIOUS_INDEX)), 322 Context::SlotOffset(Context::PREVIOUS_INDEX)),
348 NodeProperties::GetEffectInput(node), graph()->start())); 323 NodeProperties::GetEffectInput(node),
324 graph()->start()));
349 } 325 }
350 node->ReplaceInput( 326 node->ReplaceInput(1, jsgraph()->Int32Constant(Context::SlotOffset(
351 1, Int32Constant(Context::SlotOffset(static_cast<int>(access.index())))); 327 static_cast<int>(access.index()))));
352 node->AppendInput(zone(), graph()->start()); 328 node->AppendInput(zone(), graph()->start());
353 PatchOperator(node, machine()->Load(kMachAnyTagged)); 329 PatchOperator(node, machine()->Load(kMachAnyTagged));
354 } 330 }
355 331
356 332
357 void JSGenericLowering::LowerJSStoreContext(Node* node) { 333 void JSGenericLowering::LowerJSStoreContext(Node* node) {
358 const ContextAccess& access = ContextAccessOf(node->op()); 334 const ContextAccess& access = ContextAccessOf(node->op());
359 for (size_t i = 0; i < access.depth(); ++i) { 335 for (size_t i = 0; i < access.depth(); ++i) {
360 node->ReplaceInput( 336 node->ReplaceInput(
361 0, graph()->NewNode( 337 0, graph()->NewNode(machine()->Load(kMachAnyTagged),
362 machine()->Load(kMachAnyTagged), 338 NodeProperties::GetValueInput(node, 0),
363 NodeProperties::GetValueInput(node, 0), 339 jsgraph()->Int32Constant(
364 Int32Constant(Context::SlotOffset(Context::PREVIOUS_INDEX)), 340 Context::SlotOffset(Context::PREVIOUS_INDEX)),
365 NodeProperties::GetEffectInput(node), graph()->start())); 341 NodeProperties::GetEffectInput(node),
342 graph()->start()));
366 } 343 }
367 node->ReplaceInput(2, NodeProperties::GetValueInput(node, 1)); 344 node->ReplaceInput(2, NodeProperties::GetValueInput(node, 1));
368 node->ReplaceInput( 345 node->ReplaceInput(1, jsgraph()->Int32Constant(Context::SlotOffset(
369 1, Int32Constant(Context::SlotOffset(static_cast<int>(access.index())))); 346 static_cast<int>(access.index()))));
370 PatchOperator(node, machine()->Store(StoreRepresentation(kMachAnyTagged, 347 PatchOperator(node, machine()->Store(StoreRepresentation(kMachAnyTagged,
371 kFullWriteBarrier))); 348 kFullWriteBarrier)));
372 } 349 }
373 350
374 351
375 void JSGenericLowering::LowerJSCallConstruct(Node* node) { 352 void JSGenericLowering::LowerJSCallConstruct(Node* node) {
376 int arity = OpParameter<int>(node); 353 int arity = OpParameter<int>(node);
377 CallConstructStub stub(isolate(), NO_CALL_CONSTRUCTOR_FLAGS); 354 CallConstructStub stub(isolate(), NO_CALL_CONSTRUCTOR_FLAGS);
378 CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor(); 355 CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor();
379 CallDescriptor* desc = 356 CallDescriptor* desc =
380 linkage()->GetStubCallDescriptor(d, arity, FlagsForNode(node)); 357 linkage()->GetStubCallDescriptor(d, arity, FlagsForNode(node));
381 Node* stub_code = CodeConstant(stub.GetCode()); 358 Node* stub_code = jsgraph()->HeapConstant(stub.GetCode());
382 Node* construct = NodeProperties::GetValueInput(node, 0); 359 Node* construct = NodeProperties::GetValueInput(node, 0);
383 PatchInsertInput(node, 0, stub_code); 360 PatchInsertInput(node, 0, stub_code);
384 PatchInsertInput(node, 1, Int32Constant(arity - 1)); 361 PatchInsertInput(node, 1, jsgraph()->Int32Constant(arity - 1));
385 PatchInsertInput(node, 2, construct); 362 PatchInsertInput(node, 2, construct);
386 PatchInsertInput(node, 3, jsgraph()->UndefinedConstant()); 363 PatchInsertInput(node, 3, jsgraph()->UndefinedConstant());
387 PatchOperator(node, common()->Call(desc)); 364 PatchOperator(node, common()->Call(desc));
388 } 365 }
389 366
390 367
391 bool JSGenericLowering::TryLowerDirectJSCall(Node* node) { 368 bool JSGenericLowering::TryLowerDirectJSCall(Node* node) {
392 // Lower to a direct call to a constant JSFunction if legal. 369 // Lower to a direct call to a constant JSFunction if legal.
393 const CallFunctionParameters& p = CallFunctionParametersOf(node->op()); 370 const CallFunctionParameters& p = CallFunctionParametersOf(node->op());
394 int arg_count = static_cast<int>(p.arity() - 2); 371 int arg_count = static_cast<int>(p.arity() - 2);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
429 // Fast case: call function directly. 406 // Fast case: call function directly.
430 if (TryLowerDirectJSCall(node)) return; 407 if (TryLowerDirectJSCall(node)) return;
431 408
432 // General case: CallFunctionStub. 409 // General case: CallFunctionStub.
433 const CallFunctionParameters& p = CallFunctionParametersOf(node->op()); 410 const CallFunctionParameters& p = CallFunctionParametersOf(node->op());
434 int arg_count = static_cast<int>(p.arity() - 2); 411 int arg_count = static_cast<int>(p.arity() - 2);
435 CallFunctionStub stub(isolate(), arg_count, p.flags()); 412 CallFunctionStub stub(isolate(), arg_count, p.flags());
436 CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor(); 413 CallInterfaceDescriptor d = stub.GetCallInterfaceDescriptor();
437 CallDescriptor* desc = linkage()->GetStubCallDescriptor( 414 CallDescriptor* desc = linkage()->GetStubCallDescriptor(
438 d, static_cast<int>(p.arity() - 1), FlagsForNode(node)); 415 d, static_cast<int>(p.arity() - 1), FlagsForNode(node));
439 Node* stub_code = CodeConstant(stub.GetCode()); 416 Node* stub_code = jsgraph()->HeapConstant(stub.GetCode());
440 PatchInsertInput(node, 0, stub_code); 417 PatchInsertInput(node, 0, stub_code);
441 PatchOperator(node, common()->Call(desc)); 418 PatchOperator(node, common()->Call(desc));
442 } 419 }
443 420
444 421
445 void JSGenericLowering::LowerJSCallRuntime(Node* node) { 422 void JSGenericLowering::LowerJSCallRuntime(Node* node) {
446 const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op()); 423 const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op());
447 ReplaceWithRuntimeCall(node, p.id(), static_cast<int>(p.arity())); 424 ReplaceWithRuntimeCall(node, p.id(), static_cast<int>(p.arity()));
448 } 425 }
449 426
450 } // namespace compiler 427 } // namespace compiler
451 } // namespace internal 428 } // namespace internal
452 } // namespace v8 429 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-generic-lowering.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698