Lines Matching refs:node
11 #include "src/compiler/node-matchers.h"
12 #include "src/compiler/node-properties.h"
19 static CallDescriptor::Flags AdjustFrameStatesForCall(Node* node) {
20 int count = OperatorProperties::GetFrameStateInputCount(node->op());
22 int index = NodeProperties::FirstFrameStateIndex(node) + 1;
24 node->RemoveInput(index);
39 Reduction JSGenericLowering::Reduce(Node* node) {
40 switch (node->opcode()) {
43 Lower##x(node); \
52 Node* condition = node->InputAt(0);
53 Node* test = graph()->NewNode(machine()->WordEqual(), condition,
55 node->ReplaceInput(0, test);
62 return Changed(node);
67 void JSGenericLowering::Lower##Op(Node* node) { \
69 BinaryOperationParametersOf(node->op()); \
70 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node); \
71 ReplaceWithStubCall(node, \
93 void JSGenericLowering::Lower##op(Node* node) { \
94 ReplaceWithCompareIC(node, token, Strength::WEAK); \
104 void JSGenericLowering::Lower##op(Node* node) { \
105 ReplaceWithCompareIC(node, token, \
106 strength(OpParameter<LanguageMode>(node))); \
116 void JSGenericLowering::Lower##op(Node* node) { \
117 ReplaceWithRuntimeCall(node, fun); \
126 static CallDescriptor::Flags FlagsForNode(Node* node) {
128 if (OperatorProperties::GetFrameStateInputCount(node->op()) > 0) {
135 void JSGenericLowering::ReplaceWithCompareIC(Node* node, Token::Value token,
139 // Create a new call node asking a CompareIC for help.
141 inputs.reserve(node->InputCount() + 1);
143 inputs.push_back(NodeProperties::GetValueInput(node, 0));
144 inputs.push_back(NodeProperties::GetValueInput(node, 1));
145 inputs.push_back(NodeProperties::GetContextInput(node));
148 if (OperatorProperties::GetFrameStateInputCount(node->op()) > 0) {
149 inputs.push_back(NodeProperties::GetFrameStateInput(node, 0));
151 Node* effect = (node->op()->EffectInputCount() > 0)
152 ? NodeProperties::GetEffectInput(node)
155 Node* control = (node->op()->ControlInputCount() > 0)
156 ? NodeProperties::GetControlInput(node)
161 CallDescriptor::kPatchableCallSiteWithNop | FlagsForNode(node),
163 Node* compare =
169 Node* false_value = jsgraph()->FalseConstant();
170 Node* true_value = jsgraph()->TrueConstant();
199 Node* booleanize = graph()->NewNode(op, compare, jsgraph()->ZeroConstant());
201 // Finally patch the original node to select a boolean.
202 NodeProperties::ReplaceUses(node, node, compare, compare, compare);
203 node->TrimInputCount(3);
204 node->ReplaceInput(0, booleanize);
205 node->ReplaceInput(1, true_value);
206 node->ReplaceInput(2, false_value);
207 NodeProperties::ChangeOp(node,
212 void JSGenericLowering::ReplaceWithStubCall(Node* node, Callable callable,
214 Operator::Properties properties = node->op()->properties();
217 Node* stub_code = jsgraph()->HeapConstant(callable.code());
218 node->InsertInput(zone(), 0, stub_code);
219 NodeProperties::ChangeOp(node, common()->Call(desc));
223 void JSGenericLowering::ReplaceWithRuntimeCall(Node* node,
226 Operator::Properties properties = node->op()->properties();
231 Node* ref = jsgraph()->ExternalConstant(ExternalReference(f, isolate()));
232 Node* arity = jsgraph()->Int32Constant(nargs);
233 node->InsertInput(zone(), 0, jsgraph()->CEntryStubConstant(fun->result_size));
234 node->InsertInput(zone(), nargs + 1, ref);
235 node->InsertInput(zone(), nargs + 2, arity);
236 NodeProperties::ChangeOp(node, common()->Call(desc));
240 void JSGenericLowering::LowerJSTypeOf(Node* node) {
241 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
243 ReplaceWithStubCall(node, callable, flags);
247 void JSGenericLowering::LowerJSToBoolean(Node* node) {
248 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
250 ReplaceWithStubCall(node, callable,
255 void JSGenericLowering::LowerJSToNumber(Node* node) {
256 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
258 ReplaceWithStubCall(node, callable, flags);
262 void JSGenericLowering::LowerJSToString(Node* node) {
263 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
265 ReplaceWithStubCall(node, callable, flags);
269 void JSGenericLowering::LowerJSToName(Node* node) {
270 ReplaceWithRuntimeCall(node, Runtime::kToName);
274 void JSGenericLowering::LowerJSToObject(Node* node) {
275 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
277 ReplaceWithStubCall(node, callable, flags);
281 void JSGenericLowering::LowerJSLoadProperty(Node* node) {
282 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
283 const PropertyAccess& p = PropertyAccessOf(node->op());
286 node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
287 ReplaceWithStubCall(node, callable, flags);
291 void JSGenericLowering::LowerJSLoadNamed(Node* node) {
292 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
293 NamedAccess const& p = NamedAccessOf(node->op());
296 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
297 node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
298 ReplaceWithStubCall(node, callable, flags);
302 void JSGenericLowering::LowerJSLoadGlobal(Node* node) {
303 Node* context = NodeProperties::GetContextInput(node);
304 Node* effect = NodeProperties::GetEffectInput(node);
305 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
306 const LoadGlobalParameters& p = LoadGlobalParametersOf(node->op());
310 Node* native_context =
315 Node* global = graph()->NewNode(
319 node->InsertInput(zone(), 0, global);
320 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
321 node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
322 ReplaceWithStubCall(node, callable, flags);
326 void JSGenericLowering::LowerJSStoreProperty(Node* node) {
327 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
328 PropertyAccess const& p = PropertyAccessOf(node->op());
333 node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
334 ReplaceWithStubCall(node, callable,
339 void JSGenericLowering::LowerJSStoreNamed(Node* node) {
340 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
341 NamedAccess const& p = NamedAccessOf(node->op());
344 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
346 node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
347 ReplaceWithStubCall(node, callable,
352 void JSGenericLowering::LowerJSStoreGlobal(Node* node) {
353 Node* context = NodeProperties::GetContextInput(node);
354 Node* effect = NodeProperties::GetEffectInput(node);
355 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
356 const StoreGlobalParameters& p = StoreGlobalParametersOf(node->op());
360 Node* native_context =
365 Node* global = graph()->NewNode(
369 node->InsertInput(zone(), 0, global);
370 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
372 node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
373 ReplaceWithStubCall(node, callable,
378 void JSGenericLowering::LowerJSDeleteProperty(Node* node) {
379 LanguageMode language_mode = OpParameter<LanguageMode>(node);
380 ReplaceWithRuntimeCall(node, is_strict(language_mode)
386 void JSGenericLowering::LowerJSHasProperty(Node* node) {
387 ReplaceWithRuntimeCall(node, Runtime::kHasProperty);
391 void JSGenericLowering::LowerJSInstanceOf(Node* node) {
392 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
394 ReplaceWithStubCall(node, callable, flags);
398 void JSGenericLowering::LowerJSLoadContext(Node* node) {
399 const ContextAccess& access = ContextAccessOf(node->op());
401 node
403 NodeProperties::GetValueInput(node, 0),
406 NodeProperties::GetEffectInput(node),
409 node->ReplaceInput(1, jsgraph()->Int32Constant(Context::SlotOffset(
411 node->AppendInput(zone(), graph()->start());
412 NodeProperties::ChangeOp(node, machine()->Load(MachineType::AnyTagged()));
416 void JSGenericLowering::LowerJSStoreContext(Node* node) {
417 const ContextAccess& access = ContextAccessOf(node->op());
419 node->ReplaceInput(
421 NodeProperties::GetValueInput(node, 0),
424 NodeProperties::GetEffectInput(node),
427 node->ReplaceInput(2, NodeProperties::GetValueInput(node, 1));
428 node->ReplaceInput(1, jsgraph()->Int32Constant(Context::SlotOffset(
431 node, machine()->Store(StoreRepresentation(MachineRepresentation::kTagged,
436 void JSGenericLowering::LowerJSLoadDynamic(Node* node) {
437 const DynamicAccess& access = DynamicAccessOf(node->op());
442 Node* projection = graph()->NewNode(common()->Projection(0), node);
443 NodeProperties::ReplaceUses(node, projection, node, node, node);
444 node->RemoveInput(NodeProperties::FirstValueIndex(node));
445 node->InsertInput(zone(), 1, jsgraph()->Constant(access.name()));
446 ReplaceWithRuntimeCall(node, function_id);
447 projection->ReplaceInput(0, node);
451 void JSGenericLowering::LowerJSCreate(Node* node) {
452 ReplaceWithRuntimeCall(node, Runtime::kNewObject);
456 void JSGenericLowering::LowerJSCreateArguments(Node* node) {
457 const CreateArgumentsParameters& p = CreateArgumentsParametersOf(node->op());
460 ReplaceWithRuntimeCall(node, Runtime::kNewSloppyArguments_Generic);
463 ReplaceWithRuntimeCall(node, Runtime::kNewStrictArguments_Generic);
466 node->InsertInput(zone(), 1, jsgraph()->Constant(p.start_index()));
467 ReplaceWithRuntimeCall(node, Runtime::kNewRestArguments_Generic);
473 void JSGenericLowering::LowerJSCreateArray(Node* node) {
474 CreateArrayParameters const& p = CreateArrayParametersOf(node->op());
476 Node* new_target = node->InputAt(1);
484 Node* type_info = p.site().is_null() ? jsgraph()->UndefinedConstant()
486 node->RemoveInput(1);
487 node->InsertInput(zone(), 1 + arity, new_target);
488 node->InsertInput(zone(), 2 + arity, type_info);
489 ReplaceWithRuntimeCall(node, Runtime::kNewArray, arity + 3);
493 void JSGenericLowering::LowerJSCreateClosure(Node* node) {
494 CreateClosureParameters p = CreateClosureParametersOf(node->op());
495 node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.shared_info()));
496 ReplaceWithRuntimeCall(node, (p.pretenure() == TENURED)
502 void JSGenericLowering::LowerJSCreateIterResultObject(Node* node) {
503 ReplaceWithRuntimeCall(node, Runtime::kCreateIterResultObject);
507 void JSGenericLowering::LowerJSCreateLiteralArray(Node* node) {
508 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op());
509 node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.index()));
510 node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant()));
511 node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags()));
512 ReplaceWithRuntimeCall(node, Runtime::kCreateArrayLiteral);
516 void JSGenericLowering::LowerJSCreateLiteralObject(Node* node) {
517 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op());
518 node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.index()));
519 node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant()));
520 node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags()));
521 ReplaceWithRuntimeCall(node, Runtime::kCreateObjectLiteral);
525 void JSGenericLowering::LowerJSCreateLiteralRegExp(Node* node) {
526 CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op());
527 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
529 Node* literal_index = jsgraph()->SmiConstant(p.index());
530 Node* literal_flags = jsgraph()->SmiConstant(p.flags());
531 Node* pattern = jsgraph()->HeapConstant(p.constant());
532 node->InsertInput(graph()->zone(), 1, literal_index);
533 node->InsertInput(graph()->zone(), 2, pattern);
534 node->InsertInput(graph()->zone(), 3, literal_flags);
535 ReplaceWithStubCall(node, callable, flags);
539 void JSGenericLowering::LowerJSCreateCatchContext(Node* node) {
540 Handle<String> name = OpParameter<Handle<String>>(node);
541 node->InsertInput(zone(), 0, jsgraph()->HeapConstant(name));
542 ReplaceWithRuntimeCall(node, Runtime::kPushCatchContext);
546 void JSGenericLowering::LowerJSCreateBlockContext(Node* node) {
547 Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node);
548 node->InsertInput(zone(), 0, jsgraph()->HeapConstant(scope_info));
549 ReplaceWithRuntimeCall(node, Runtime::kPushBlockContext);
553 void JSGenericLowering::LowerJSCreateScriptContext(Node* node) {
554 Handle<ScopeInfo> scope_info = OpParameter<Handle<ScopeInfo>>(node);
555 node->InsertInput(zone(), 1, jsgraph()->HeapConstant(scope_info));
556 ReplaceWithRuntimeCall(node, Runtime::kNewScriptContext);
560 void JSGenericLowering::LowerJSCallConstruct(Node* node) {
561 CallConstructParameters const& p = CallConstructParametersOf(node->op());
563 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
567 Node* stub_code = jsgraph()->HeapConstant(callable.code());
568 Node* stub_arity = jsgraph()->Int32Constant(arg_count);
569 Node* new_target = node->InputAt(arg_count + 1);
570 Node* receiver = jsgraph()->UndefinedConstant();
571 node->RemoveInput(arg_count + 1); // Drop new target.
572 node->InsertInput(zone(), 0, stub_code);
573 node->InsertInput(zone(), 2, new_target);
574 node->InsertInput(zone(), 3, stub_arity);
575 node->InsertInput(zone(), 4, receiver);
576 NodeProperties::ChangeOp(node, common()->Call(desc));
580 void JSGenericLowering::LowerJSCallFunction(Node* node) {
581 CallFunctionParameters const& p = CallFunctionParametersOf(node->op());
585 CallDescriptor::Flags flags = AdjustFrameStatesForCall(node);
591 Node* stub_code = jsgraph()->HeapConstant(callable.code());
592 Node* stub_arity = jsgraph()->Int32Constant(arg_count);
593 node->InsertInput(zone(), 0, stub_code);
594 node->InsertInput(zone(), 2, stub_arity);
595 NodeProperties::ChangeOp(node, common()->Call(desc));
599 void JSGenericLowering::LowerJSCallRuntime(Node* node) {
600 const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op());
601 AdjustFrameStatesForCall(node);
602 ReplaceWithRuntimeCall(node, p.id(), static_cast<int>(p.arity()));
606 void JSGenericLowering::LowerJSForInDone(Node* node) {
607 ReplaceWithRuntimeCall(node, Runtime::kForInDone);
611 void JSGenericLowering::LowerJSForInNext(Node* node) {
612 ReplaceWithRuntimeCall(node, Runtime::kForInNext);
616 void JSGenericLowering::LowerJSForInPrepare(Node* node) {
617 Node* object = NodeProperties::GetValueInput(node, 0);
618 Node* context = NodeProperties::GetContextInput(node);
619 Node* effect = NodeProperties::GetEffectInput(node);
620 Node* control = NodeProperties::GetControlInput(node);
621 Node* frame_state = NodeProperties::GetFrameStateInput(node, 0);
629 Node* cache_type = effect = graph()->NewNode(
636 Node* object_map = effect = graph()->NewNode(
640 Node* cache_type_map = effect = graph()->NewNode(
644 Node* meta_map = jsgraph()->HeapConstant(isolate()->factory()->meta_map());
649 Node* check0 =
651 Node* branch0 =
654 Node* if_true0 = graph()->NewNode(common()->IfTrue(), branch0);
655 Node* cache_array_true0;
656 Node* cache_length_true0;
657 Node* cache_type_true0;
658 Node* etrue0;
661 Node* cache_type_enum_length = etrue0 = graph()->NewNode(
669 Node* check1 =
672 Node* branch1 =
675 Node* if_true1 = graph()->NewNode(common()->IfTrue(), branch1);
676 Node* cache_array_true1;
677 Node* etrue1;
685 Node* if_false1 = graph()->NewNode(common()->IfFalse(), branch1);
686 Node* cache_array_false1;
687 Node* efalse1;
690 Node* object_map_descriptors = efalse1 = graph()->NewNode(
694 Node* object_map_enum_cache = efalse1 = graph()->NewNode(
723 Node* if_false0 = graph()->NewNode(common()->IfFalse(), branch0);
724 Node* cache_array_false0;
725 Node* cache_length_false0;
726 Node* cache_type_false0;
727 Node* efalse0;
740 Node* cache_array =
743 Node* cache_length =
750 for (auto edge : node->use_edges()) {
754 Node* const use = edge.from();
764 Node* const use = edge.from();
787 void JSGenericLowering::LowerJSForInStep(Node* node) {
788 ReplaceWithRuntimeCall(node, Runtime::kForInStep);
792 void JSGenericLowering::LowerJSLoadMessage(Node* node) {
795 node->RemoveInput(NodeProperties::FirstContextIndex(node));
796 node->InsertInput(zone(), 0, jsgraph()->ExternalConstant(message_address));
797 node->InsertInput(zone(), 1, jsgraph()->IntPtrConstant(0));
798 NodeProperties::ChangeOp(node, machine()->Load(MachineType::AnyTagged()));
802 void JSGenericLowering::LowerJSStoreMessage(Node* node) {
805 node->RemoveInput(NodeProperties::FirstContextIndex(node));
806 node->InsertInput(zone(), 0, jsgraph()->ExternalConstant(message_address));
807 node->InsertInput(zone(), 1, jsgraph()->IntPtrConstant(0));
810 NodeProperties::ChangeOp(node, machine()->Store(representation));
814 void JSGenericLowering::LowerJSYield(Node* node) { UNIMPLEMENTED(); }
817 void JSGenericLowering::LowerJSStackCheck(Node* node) {
818 Node* effect = NodeProperties::GetEffectInput(node);
819 Node* control = NodeProperties::GetControlInput(node);
821 Node* limit = graph()->NewNode(
826 Node* pointer = graph()->NewNode(machine()->LoadStackPointer());
828 Node* check = graph()->NewNode(machine()->UintLessThan(), limit, pointer);
829 Node* branch =
832 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
833 Node* etrue = effect;
835 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
836 NodeProperties::ReplaceControlInput(node, if_false);
837 Node* efalse = node;
839 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false);
840 Node* ephi = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, merge);
842 // Wire the new diamond into the graph, {node} can still throw.
843 NodeProperties::ReplaceUses(node, node, ephi, node, node);
847 // the node and places it inside the diamond. Come up with a helper method!
848 for (Node* use : node->uses()) {
856 ReplaceWithRuntimeCall(node, Runtime::kStackGuard);