Home | History | Annotate | Download | only in compiler

Lines Matching refs:Node

18 #include "src/compiler/node-matchers.h"
34 Reduction JSCallReducer::ReduceMathUnary(Node* node, const Operator* op) {
35 CallParameters const& p = CallParametersOf(node->op());
39 if (node->op()->ValueInputCount() < 3) {
40 Node* value = jsgraph()->NaNConstant();
41 ReplaceWithValue(node, value);
45 Node* effect = NodeProperties::GetEffectInput(node);
46 Node* control = NodeProperties::GetControlInput(node);
47 Node* input = NodeProperties::GetValueInput(node, 2);
53 Node* value = graph()->NewNode(op, input);
54 ReplaceWithValue(node, value, effect);
58 Reduction JSCallReducer::ReduceMathBinary(Node* node, const Operator* op) {
59 CallParameters const& p = CallParametersOf(node->op());
63 if (node->op()->ValueInputCount() < 3) {
64 Node* value = jsgraph()->NaNConstant();
65 ReplaceWithValue(node, value);
68 Node* effect = NodeProperties::GetEffectInput(node);
69 Node* control = NodeProperties::GetControlInput(node);
71 Node* left = NodeProperties::GetValueInput(node, 2);
72 Node* right = node->op()->ValueInputCount() > 3
73 ? NodeProperties::GetValueInput(node, 3)
83 Node* value = graph()->NewNode(op, left, right);
84 ReplaceWithValue(node, value, effect);
89 Reduction JSCallReducer::ReduceMathImul(Node* node) {
90 CallParameters const& p = CallParametersOf(node->op());
94 if (node->op()->ValueInputCount() < 3) {
95 Node* value = jsgraph()->ZeroConstant();
96 ReplaceWithValue(node, value);
99 Node* left = NodeProperties::GetValueInput(node, 2);
100 Node* right = node->op()->ValueInputCount() > 3
101 ? NodeProperties::GetValueInput(node, 3)
103 Node* effect = NodeProperties::GetEffectInput(node);
104 Node* control = NodeProperties::GetControlInput(node);
116 Node* value = graph()->NewNode(simplified()->NumberImul(), left, right);
117 ReplaceWithValue(node, value, effect);
122 Reduction JSCallReducer::ReduceMathClz32(Node* node) {
123 CallParameters const& p = CallParametersOf(node->op());
127 if (node->op()->ValueInputCount() < 3) {
128 Node* value = jsgraph()->Constant(32);
129 ReplaceWithValue(node, value);
132 Node* input = NodeProperties::GetValueInput(node, 2);
133 Node* effect = NodeProperties::GetEffectInput(node);
134 Node* control = NodeProperties::GetControlInput(node);
141 Node* value = graph()->NewNode(simplified()->NumberClz32(), input);
142 ReplaceWithValue(node, value, effect);
148 Reduction JSCallReducer::ReduceMathMinMax(Node* node, const Operator* op,
149 Node* empty_value) {
150 CallParameters const& p = CallParametersOf(node->op());
154 if (node->op()->ValueInputCount() <= 2) {
155 ReplaceWithValue(node, empty_value);
158 Node* effect = NodeProperties::GetEffectInput(node);
159 Node* control = NodeProperties::GetControlInput(node);
161 Node* value = effect =
164 NodeProperties::GetValueInput(node, 2), effect, control);
165 for (int i = 3; i < node->op()->ValueInputCount(); i++) {
166 Node* input = effect = graph()->NewNode(
169 NodeProperties::GetValueInput(node, i), effect, control);
173 ReplaceWithValue(node, value, effect);
177 Reduction JSCallReducer::Reduce(Node* node) {
178 switch (node->opcode()) {
180 return ReduceJSConstruct(node);
182 return ReduceJSConstructWithArrayLike(node);
184 return ReduceJSConstructWithSpread(node);
186 return ReduceJSCall(node);
188 return ReduceJSCallWithArrayLike(node);
190 return ReduceJSCallWithSpread(node);
200 // nodes, even if they don't show up in the use list of the other node.
201 std::set<Node*> const waitlist = std::move(waitlist_);
202 for (Node* node : waitlist) {
203 if (!node->IsDead()) {
204 Reduction const reduction = Reduce(node);
206 Node* replacement = reduction.replacement();
207 if (replacement != node) {
208 Replace(node, replacement);
216 Reduction JSCallReducer::ReduceArrayConstructor(Node* node) {
217 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
218 Node* target = NodeProperties::GetValueInput(node, 0);
219 CallParameters const& p = CallParametersOf(node->op());
221 // Turn the {node} into a {JSCreateArray} call.
224 NodeProperties::ReplaceValueInput(node, target, 0);
225 NodeProperties::ReplaceValueInput(node, target, 1);
227 node, javascript()->CreateArray(arity, MaybeHandle<AllocationSite>()));
228 return Changed(node);
232 Reduction JSCallReducer::ReduceBooleanConstructor(Node* node) {
233 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
234 CallParameters const& p = CallParametersOf(node->op());
236 // Replace the {node} with a proper {ToBoolean} operator.
238 Node* value = (p.arity() == 2) ? jsgraph()->UndefinedConstant()
239 : NodeProperties::GetValueInput(node, 2);
241 ReplaceWithValue(node, value);
246 Reduction JSCallReducer::ReduceObjectConstructor(Node* node) {
247 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
248 CallParameters const& p = CallParametersOf(node->op());
250 Node* value = (p.arity() >= 3) ? NodeProperties::GetValueInput(node, 2)
252 Node* effect = NodeProperties::GetEffectInput(node);
257 // Turn the {node} into a {JSToObject} call if we know that
259 NodeProperties::ReplaceValueInputs(node, value);
260 NodeProperties::ChangeOp(node, javascript()->ToObject());
261 return Changed(node);
264 ReplaceWithValue(node, value);
271 Reduction JSCallReducer::ReduceFunctionPrototypeApply(Node* node) {
272 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
273 CallParameters const& p = CallParametersOf(node->op());
280 node->ReplaceInput(0, node->InputAt(1));
281 node->ReplaceInput(1, jsgraph()->UndefinedConstant());
284 node->RemoveInput(0);
287 Node* target = NodeProperties::GetValueInput(node, 1);
288 Node* this_argument = NodeProperties::GetValueInput(node, 2);
289 Node* arguments_list = NodeProperties::GetValueInput(node, 3);
290 Node* context = NodeProperties::GetContextInput(node);
291 Node* frame_state = NodeProperties::GetFrameStateInput(node);
292 Node* effect = NodeProperties::GetEffectInput(node);
293 Node* control = NodeProperties::GetControlInput(node);
296 // to expand this {node} to control-flow.
300 node->ReplaceInput(0, target);
301 node->ReplaceInput(1, this_argument);
302 node->ReplaceInput(2, arguments_list);
303 while (arity-- > 3) node->RemoveInput(3);
305 // Morph the {node} to a {JSCallWithArrayLike}.
306 NodeProperties::ChangeOp(node,
308 Reduction const reduction = ReduceJSCallWithArrayLike(node);
309 return reduction.Changed() ? reduction : Changed(node);
312 Node* check_null =
317 Node* if_null = graph()->NewNode(common()->IfTrue(), control);
321 Node* check_undefined =
326 Node* if_undefined = graph()->NewNode(common()->IfTrue(), control);
331 Node* effect0 = effect;
332 Node* control0 = control;
333 Node* value0 = effect0 = control0 = graph()->NewNode(
338 Node* effect1 = effect;
339 Node* control1 =
341 Node* value1 = effect1 = control1 =
346 Node* if_exception = nullptr;
347 if (NodeProperties::IsExceptionalCall(node, &if_exception)) {
349 Node* if_exception0 =
352 Node* if_exception1 =
357 Node* merge =
359 Node* ephi = graph()->NewNode(common()->EffectPhi(2), if_exception0,
361 Node* phi =
371 Node* value =
374 ReplaceWithValue(node, value, effect, control);
378 // Change {node} to the new {JSCall} operator.
380 node,
382 // Try to further reduce the JSCall {node}.
383 Reduction const reduction = ReduceJSCall(node);
384 return reduction.Changed() ? reduction : Changed(node);
388 Reduction JSCallReducer::ReduceFunctionPrototypeBind(Node* node) {
389 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
390 // Value inputs to the {node} are as follows:
396 Node* receiver = NodeProperties::GetValueInput(node, 1);
397 Node* bound_this = (node->op()->ValueInputCount() < 3)
399 : NodeProperties::GetValueInput(node, 2);
400 Node* context = NodeProperties::GetContextInput(node);
401 Node* effect = NodeProperties::GetEffectInput(node);
402 Node* control = NodeProperties::GetControlInput(node);
471 // Replace the {node} with a JSCreateBoundFunction.
472 int const arity = std::max(0, node->op()->ValueInputCount() - 3);
474 Node** inputs = graph()->zone()->NewArray<Node*>(input_count);
478 inputs[2 + i] = NodeProperties::GetValueInput(node, 3 + i);
483 Node* value = effect = graph()->NewNode(
485 ReplaceWithValue(node, value, effect, control);
490 Reduction JSCallReducer::ReduceFunctionPrototypeCall(Node* node) {
491 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
492 CallParameters const& p = CallParametersOf(node->op());
493 Node* target = NodeProperties::GetValueInput(node, 0);
494 Node* effect = NodeProperties::GetEffectInput(node);
495 Node* control = NodeProperties::GetControlInput(node);
497 // Change context of {node} to the Function.prototype.call context,
499 Node* context;
509 NodeProperties::ReplaceContextInput(node, context);
510 NodeProperties::ReplaceEffectInput(node, effect);
512 // Remove the target from {node} and use the receiver as target instead, and
521 node->ReplaceInput(0, node->InputAt(1));
522 node->ReplaceInput(1, jsgraph()->UndefinedConstant());
526 node->RemoveInput(0);
530 node,
532 // Try to further reduce the JSCall {node}.
533 Reduction const reduction = ReduceJSCall(node);
534 return reduction.Changed() ? reduction : Changed(node);
538 Reduction JSCallReducer::ReduceFunctionPrototypeHasInstance(Node* node) {
539 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
540 Node* receiver = NodeProperties::GetValueInput(node, 1);
541 Node* object = (node->op()->ValueInputCount() >= 3)
542 ? NodeProperties::GetValueInput(node, 2)
544 Node* context = NodeProperties::GetContextInput(node);
545 Node* frame_state = NodeProperties::GetFrameStateInput(node);
546 Node* effect = NodeProperties::GetEffectInput(node);
547 Node* control = NodeProperties::GetControlInput(node);
554 // Morph this {node} into a JSOrdinaryHasInstance node.
555 node->ReplaceInput(0, receiver);
556 node->ReplaceInput(1, object);
557 node->ReplaceInput(2, context);
558 node->ReplaceInput(3, frame_state);
559 node->ReplaceInput(4, effect);
560 node->ReplaceInput(5, control);
561 node->TrimInputCount(6);
562 NodeProperties::ChangeOp(node, javascript()->OrdinaryHasInstance());
563 return Changed(node);
566 Reduction JSCallReducer::ReduceObjectGetPrototype(Node* node, Node* object) {
567 Node* effect = NodeProperties::GetEffectInput(node);
603 Node* value = jsgraph()->Constant(candidate_prototype);
604 ReplaceWithValue(node, value);
612 Reduction JSCallReducer::ReduceObjectGetPrototypeOf(Node* node) {
613 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
614 Node* object = (node->op()->ValueInputCount() >= 3)
615 ? NodeProperties::GetValueInput(node, 2)
617 return ReduceObjectGetPrototype(node, object);
621 Reduction JSCallReducer::ReduceObjectIs(Node* node) {
622 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
623 CallParameters const& params = CallParametersOf(node->op());
625 Node* lhs = (argc >= 1) ? NodeProperties::GetValueInput(node, 2)
627 Node* rhs = (argc >= 2) ? NodeProperties::GetValueInput(node, 3)
629 Node* value = graph()->NewNode(simplified()->SameValue(), lhs, rhs);
630 ReplaceWithValue(node, value);
635 Reduction JSCallReducer::ReduceObjectPrototypeGetProto(Node* node) {
636 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
637 Node* receiver = NodeProperties::GetValueInput(node, 1);
638 return ReduceObjectGetPrototype(node, receiver);
642 Reduction JSCallReducer::ReduceObjectPrototypeHasOwnProperty(Node* node) {
643 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
644 CallParameters const& params = CallParametersOf(node->op());
646 Node* receiver = NodeProperties::GetValueInput(node, 1);
647 Node* name = (argc >= 1) ? NodeProperties::GetValueInput(node, 2)
649 Node* effect = NodeProperties::GetEffectInput(node);
650 Node* control = NodeProperties::GetControlInput(node);
679 // We can constant-fold the {node} to True in this case, and insert
692 Node* object = NodeProperties::GetValueInput(name, 0);
693 Node* cache_type = NodeProperties::GetValueInput(name, 2);
701 Node* receiver_map = effect =
704 Node* check = graph()->NewNode(simplified()->ReferenceEqual(),
710 Node* value = jsgraph()->TrueConstant();
711 ReplaceWithValue(node, value, effect, control);
721 Reduction JSCallReducer::ReduceObjectPrototypeIsPrototypeOf(Node* node) {
722 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
723 Node* receiver = NodeProperties::GetValueInput(node, 1);
724 Node* value = node->op()->ValueInputCount() > 2
725 ? NodeProperties::GetValueInput(node, 2)
727 Node* effect = NodeProperties::GetEffectInput(node);
744 NodeProperties::ReplaceValueInput(node, value, 0);
745 NodeProperties::ReplaceValueInput(node, receiver, 1);
746 for (int i = node->op()->ValueInputCount(); i-- > 2;) {
747 node->RemoveInput(i);
749 NodeProperties::ChangeOp(node, javascript()->HasInPrototypeChain());
750 return Changed(node);
754 Reduction JSCallReducer::ReduceReflectApply(Node* node) {
755 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
756 CallParameters const& p = CallParametersOf(node->op());
760 node->RemoveInput(0);
761 node->RemoveInput(0);
763 node->InsertInput(graph()->zone(), arity++, jsgraph()->UndefinedConstant());
766 node->RemoveInput(arity);
768 NodeProperties::ChangeOp(node,
770 Reduction const reduction = ReduceJSCallWithArrayLike(node);
771 return reduction.Changed() ? reduction : Changed(node);
775 Reduction JSCallReducer::ReduceReflectConstruct(Node* node) {
776 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
777 CallParameters const& p = CallParametersOf(node
781 node->RemoveInput(0);
782 node->RemoveInput(0);
784 node->InsertInput(graph()->zone(), arity++, jsgraph()->UndefinedConstant());
787 node->InsertInput(graph()->zone(), arity++, node->InputAt(0));
790 node->RemoveInput(arity);
792 NodeProperties::ChangeOp(node,
794 Reduction const reduction = ReduceJSConstructWithArrayLike(node);
795 return reduction.Changed() ? reduction : Changed(node);
799 Reduction JSCallReducer::ReduceReflectGetPrototypeOf(Node* node) {
800 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
801 Node* target = (node->op()->ValueInputCount() >= 3)
802 ? NodeProperties::GetValueInput(node, 2)
804 return ReduceObjectGetPrototype(node, target);
808 Reduction JSCallReducer::ReduceObjectCreate(Node* node) {
809 int arg_count = node->op()->ValueInputCount();
810 Node* properties = arg_count >= 4 ? NodeProperties::GetValueInput(node, 3)
814 Node* effect = NodeProperties::GetEffectInput(node);
815 Node* control = NodeProperties::GetControlInput(node);
816 Node* context = NodeProperties::GetContextInput(node);
817 Node* frame_state = NodeProperties::GetFrameStateInput(node);
818 Node* prototype = arg_count >= 3 ? NodeProperties::GetValueInput(node, 2)
820 node->ReplaceInput(0, prototype);
821 node->ReplaceInput(1, context);
822 node->ReplaceInput(2, frame_state);
823 node->ReplaceInput(3, effect);
824 node->ReplaceInput(4, control);
825 node->TrimInputCount(5);
826 NodeProperties::ChangeOp(node, javascript()->CreateObject());
827 return Changed(node);
831 Reduction JSCallReducer::ReduceReflectGet(Node* node) {
832 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
833 CallParameters const& p = CallParametersOf(node->op());
836 Node* target = NodeProperties::GetValueInput(node, 2);
837 Node* key = NodeProperties::GetValueInput(node, 3);
838 Node* context = NodeProperties::GetContextInput(node);
839 Node* frame_state = NodeProperties::GetFrameStateInput(node);
840 Node* effect = NodeProperties::GetEffectInput(node);
841 Node* control = NodeProperties::GetControlInput(node);
844 Node* check = graph()->NewNode(simplified()->ObjectIsReceiver(), target);
845 Node* branch =
849 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
850 Node* efalse = effect;
861 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
862 Node* etrue = effect;
863 Node* vtrue;
870 Node* stub_code = jsgraph()->HeapConstant(callable.code());
877 Node* on_exception = nullptr;
878 if (NodeProperties::IsExceptionalCall(node, &on_exception)) {
880 Node* extrue = graph()->NewNode(common()->IfException(), etrue, if_true);
882 Node* exfalse = graph()->NewNode(common()->IfException(), efalse, if_false);
886 Node* merge = graph()->NewNode(common()->Merge(2), extrue, exfalse);
887 Node* ephi =
889 Node* phi =
900 ReplaceWithValue(node, vtrue, etrue, if_true);
905 Reduction JSCallReducer::ReduceReflectHas(Node* node) {
906 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
907 CallParameters const& p = CallParametersOf(node->op());
910 Node* target = (arity >= 1) ? NodeProperties::GetValueInput(node, 2)
912 Node* key = (arity >= 2) ? NodeProperties::GetValueInput(node, 3)
914 Node* context = NodeProperties::GetContextInput(node);
915 Node* frame_state = NodeProperties::GetFrameStateInput(node);
916 Node* effect = NodeProperties::GetEffectInput(node);
917 Node* control = NodeProperties::GetControlInput(node);
920 Node* check = graph()->NewNode(simplified()->ObjectIsReceiver(), target);
921 Node* branch =
925 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
926 Node* efalse = effect;
937 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
938 Node* etrue = effect;
939 Node* vtrue;
947 Node* on_exception = nullptr;
948 if (NodeProperties::IsExceptionalCall(node, &on_exception)) {
950 Node* extrue = graph()->NewNode(common()->IfException(), etrue, if_true);
952 Node* exfalse = graph()->NewNode(common()->IfException(), efalse, if_false);
956 Node* merge = graph()->NewNode(common()->Merge(2), extrue, exfalse);
957 Node* ephi =
959 Node* phi =
970 ReplaceWithValue(node, vtrue, etrue, if_true);
985 Node* JSCallReducer::WireInLoopStart(Node* k, Node** control, Node** effect) {
986 Node* loop = *control =
988 Node* eloop = *effect =
990 Node* terminate = graph()->NewNode(common()->Terminate(), eloop, loop);
996 void JSCallReducer::WireInLoopEnd(Node* loop, Node* eloop, Node* vloop, Node* k,
997 Node* control, Node* effect) {
1003 Reduction JSCallReducer::ReduceArrayForEach(Node* node,
1006 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
1007 CallParameters const& p = CallParametersOf(node->op());
1012 Node* outer_frame_state = NodeProperties::GetFrameStateInput(node);
1013 Node* effect = NodeProperties::GetEffectInput(node);
1014 Node* control = NodeProperties::GetControlInput(node);
1015 Node* context = NodeProperties::GetContextInput(node);
1018 Node* receiver = NodeProperties::GetValueInput(node, 1);
1019 Node* fncallback = node->op()->ValueInputCount() > 2
1020 ? NodeProperties::GetValueInput(node, 2)
1022 Node* this_arg = node->op()->ValueInputCount() > 3
1023 ? NodeProperties::GetValueInput(node, 3)
1066 Node* k = jsgraph()->ZeroConstant();
1068 Node* original_length = effect = graph()->NewNode(
1072 std::vector<Node*> checkpoint_params(
1078 Node* check_frame_state = CreateJavaScriptBuiltinContinuationFrameState(
1080 node->InputAt(0), context, &checkpoint_params[0], stack_parameters,
1082 Node* check_fail = nullptr;
1083 Node* check_throw = nullptr;
1088 Node* vloop = k = WireInLoopStart(k, &control, &effect);
1089 Node *loop = control, *eloop = effect;
1092 Node* continue_test =
1094 Node* continue_branch = graph()->NewNode(common()->Branch(BranchHint::kTrue),
1097 Node* if_true = graph()->NewNode(common()->IfTrue(), continue_branch);
1098 Node* if_false = graph()->NewNode(common()->IfFalse(), continue_branch);
1101 Node* frame_state = CreateJavaScriptBuiltinContinuationFrameState(
1103 node->InputAt(0), context, &checkpoint_params[0], stack_parameters,
1115 Node* element =
1118 Node* next_k =
1122 Node* hole_true = nullptr;
1123 Node* hole_false = nullptr;
1124 Node* effect_true = effect;
1129 Node* check;
1136 Node* branch =
1151 node->InputAt(0), context, &checkpoint_params[0], stack_parameters,
1159 Node* on_exception = nullptr;
1160 if (NodeProperties::IsExceptionalCall(node, &on_exception)) {
1166 Node* after_call_control = control;
1167 Node* after_call_effect = effect;
1185 Node* throw_node =
1189 ReplaceWithValue(node, jsgraph()->UndefinedConstant(), effect, control);
1193 Reduction JSCallReducer::ReduceArrayReduce(Node* node,
1197 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
1198 CallParameters const& p = CallParametersOf(node->op());
1204 Node* outer_frame_state = NodeProperties::GetFrameStateInput(node);
1205 Node* effect = NodeProperties::GetEffectInput(node);
1206 Node* control = NodeProperties::GetControlInput(node);
1207 Node* context = NodeProperties::GetContextInput(node);
1210 Node* receiver = NodeProperties::GetValueInput(node, 1);
1211 Node* fncallback = node->op()->ValueInputCount() > 2
1212 ? NodeProperties::GetValueInput(node, 2)
1229 std::function<Node*(Node*)> hole_check = [this, kind](Node* element) {
1251 Node* original_length = effect = graph()->NewNode(
1255 Node* initial_index =
1261 Node* k = initial_index;
1263 Node* check_frame_state;
1268 const std::vector<Node*> checkpoint_params(
1273 jsgraph(), shared, builtin_lazy, node->InputAt(0), context,
1277 Node* check_fail = nullptr;
1278 Node* check_throw = nullptr;
1286 Node* cur = jsgraph()->TheHoleConstant();
1288 if (node->op()->ValueInputCount() > 3) {
1289 cur = NodeProperties::GetValueInput(node, 3);
1296 const std::vector<Node*> checkpoint_params(
1299 Node* find_first_element_frame_state =
1301 jsgraph(), shared, builtin_eager, node->InputAt(0), context,
1305 Node* vloop = k = WireInLoopStart(k, &control, &effect);
1306 Node* loop = control;
1307 Node* eloop = effect;
1310 Node* continue_test =
1320 Node* next_k = graph()->NewNode(next_op, k, jsgraph()->OneConstant());
1322 Node* hole_branch = graph()->NewNode(common()->Branch(BranchHint::kTrue),
1324 Node* found_el = graph()->NewNode(common()->IfFalse(), hole_branch);
1326 Node* is_hole = graph()->NewNode(common()->IfTrue(), hole_branch);
1336 Node* loop = control = graph()->NewNode(common()->Loop(2), control, control);
1337 Node* eloop = effect =
1339 Node* terminate = graph()->NewNode(common()->Terminate(), eloop, loop);
1341 Node* kloop = k = graph()->NewNode(
1343 Node* curloop = cur = graph()->NewNode(
1349 Node* continue_test =
1355 Node* continue_branch = graph()->NewNode(common()->Branch(BranchHint::kTrue),
1358 Node* if_true = graph()->NewNode(common()->IfTrue(), continue_branch);
1359 Node* if_false = graph()->NewNode(common()->IfFalse(), continue_branch);
1366 const std::vector<Node*> checkpoint_params(
1369 Node* frame_state = CreateJavaScriptBuiltinContinuationFrameState(
1370 jsgraph(), shared, builtin_eager, node->InputAt(0), context,
1382 Node* element =
1385 Node* next_k = graph()->NewNode(next_op, k, jsgraph()->OneConstant());
1387 Node* hole_true = nullptr;
1388 Node* hole_false = nullptr;
1389 Node* effect_true = effect;
1394 Node* branch = graph()->NewNode(common()->Branch(BranchHint::kFalse),
1407 Node* next_cur;
1412 const std::vector<Node*> checkpoint_params(
1415 Node* frame_state = CreateJavaScriptBuiltinContinuationFrameState(
1416 jsgraph(), shared, builtin_lazy, node->InputAt(0), context,
1427 Node* on_exception = nullptr;
1428 if (NodeProperties::IsExceptionalCall(node, &on_exception)) {
1434 Node* after_call_control = control;
1435 Node* after_call_effect = effect;
1462 Node* throw_node =
1466 ReplaceWithValue(node, curloop, effect, control);
1470 Reduction JSCallReducer::ReduceArrayMap(Node* node,
1473 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
1474 CallParameters const& p = CallParametersOf(node->op());
1479 Node* outer_frame_state = NodeProperties::GetFrameStateInput(node);
1480 Node* effect = NodeProperties::GetEffectInput(node);
1481 Node* control = NodeProperties::GetControlInput(node);
1482 Node* context = NodeProperties::GetContextInput(node);
1485 Node* receiver = NodeProperties::GetValueInput(node, 1);
1486 Node* fncallback = node->op()->ValueInputCount() > 2
1487 ? NodeProperties::GetValueInput(node, 2)
1489 Node* this_arg = node->op()->ValueInputCount() > 3
1490 ? NodeProperties::GetValueInput(node, 3)
1523 Node* array_constructor = jsgraph()->HeapConstant(handle_constructor);
1526 Node* k = jsgraph()->ZeroConstant();
1536 Node* original_length = effect = graph()->NewNode(
1542 Node* a = control = effect = graph()->NewNode(
1547 Node*> checkpoint_params(
1553 Node* check_frame_state = CreateJavaScriptBuiltinContinuationFrameState(
1555 node->InputAt(0), context, &checkpoint_params[0], stack_parameters,
1557 Node* check_fail = nullptr;
1558 Node* check_throw = nullptr;
1563 Node* vloop = k = WireInLoopStart(k, &control, &effect);
1564 Node *loop = control, *eloop = effect;
1567 Node* continue_test =
1569 Node* continue_branch = graph()->NewNode(common()->Branch(BranchHint::kTrue),
1572 Node* if_true = graph()->NewNode(common()->IfTrue(), continue_branch);
1573 Node* if_false = graph()->NewNode(common()->IfFalse(), continue_branch);
1576 Node* frame_state = CreateJavaScriptBuiltinContinuationFrameState(
1578 node->InputAt(0), context, &checkpoint_params[0], stack_parameters,
1590 Node* element =
1593 Node* next_k =
1596 Node* hole_true = nullptr;
1597 Node* hole_false = nullptr;
1598 Node* effect_true = effect;
1603 Node* check;
1610 Node* branch =
1627 node->InputAt(0), context, &checkpoint_params[0], stack_parameters,
1630 Node* callback_value = control = effect = graph()->NewNode(
1635 Node* on_exception = nullptr;
1636 if (NodeProperties::IsExceptionalCall(node, &on_exception)) {
1655 Node* after_call_and_store_control = control;
1656 Node* after_call_and_store_effect = effect;
1675 Node* throw_node =
1679 ReplaceWithValue(node, a, effect, control);
1683 Reduction JSCallReducer::ReduceArrayFilter(Node* node,
1686 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
1687 CallParameters const& p = CallParametersOf(node->op());
1692 Node* outer_frame_state = NodeProperties::GetFrameStateInput(node);
1693 Node* effect = NodeProperties::GetEffectInput(node);
1694 Node* control = NodeProperties::GetControlInput(node);
1695 Node* context = NodeProperties::GetContextInput(node);
1697 Node* receiver = NodeProperties::GetValueInput(node, 1);
1698 Node* fncallback = node->op()->ValueInputCount() > 2
1699 ? NodeProperties::GetValueInput(node, 2)
1701 Node* this_arg = node->op()->ValueInputCount() > 3
1702 ? NodeProperties::GetValueInput(node, 3)
1738 Node* k = jsgraph()->ZeroConstant();
1739 Node* to = jsgraph()->ZeroConstant();
1749 Node* a; // Construct the output array.
1754 Node* empty_fixed_array = jsgraph()->EmptyFixedArrayConstant();
1767 Node* original_length = effect = graph()->NewNode(
1773 Node* check_fail = nullptr;
1774 Node* check_throw = nullptr;
1782 std::vector<Node*> checkpoint_params(
1786 Node* check_frame_state = CreateJavaScriptBuiltinContinuationFrameState(
1788 node->InputAt(0), context, &checkpoint_params[0], stack_parameters,
1795 Node* vloop = k = WireInLoopStart(k, &control, &effect);
1796 Node *loop = control, *eloop = effect;
1797 Node* v_to_loop = to = graph()->NewNode(
1800 Node* continue_test =
1802 Node* continue_branch = graph()->NewNode(common()->Branch(BranchHint::kTrue),
1805 Node* if_true = graph()->NewNode(common()->IfTrue(), continue_branch);
1806 Node* if_false = graph()->NewNode(common()->IfFalse(), continue_branch);
1810 std::vector<Node*> checkpoint_params(
1814 Node* frame_state = CreateJavaScriptBuiltinContinuationFrameState(
1816 node->InputAt(0), context, &checkpoint_params[0], stack_parameters,
1829 Node* element =
1832 Node* next_k =
1835 Node* hole_true = nullptr;
1836 Node* hole_false = nullptr;
1837 Node* effect_true = effect;
1838 Node* hole_true_vto = to;
1843 Node* check;
1850 Node* branch =
1863 Node* callback_value = nullptr;
1867 std::vector<Node*> checkpoint_params(
1871 Node* frame_state = CreateJavaScriptBuiltinContinuationFrameState(
1873 node->InputAt(0), context, &checkpoint_params[0], stack_parameters,
1882 Node* on_exception = nullptr;
1883 if (NodeProperties::IsExceptionalCall(node, &on_exception)) {
1896 std::vector<Node*> checkpoint_params({receiver, fncallback, this_arg, a, k,
1900 Node* frame_state = CreateJavaScriptBuiltinContinuationFrameState(
1902 node->InputAt(0), context, &checkpoint_params[0], stack_parameters,
1916 Node* after_call_control = control;
1917 Node* after_call_effect = effect;
1939 Node* throw_node =
1943 ReplaceWithValue(node, a, effect, control);
1947 Reduction JSCallReducer::ReduceArrayFind(Node* node, ArrayFindVariant variant,
1950 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
1951 CallParameters const& p = CallParametersOf(node->op());
1974 Node* outer_frame_state = NodeProperties::GetFrameStateInput(node);
1975 Node* effect = NodeProperties::GetEffectInput(node);
1976 Node* control = NodeProperties::GetControlInput(node);
1977 Node* context = NodeProperties::GetContextInput(node);
1980 Node* receiver = NodeProperties::GetValueInput(node, 1);
1981 Node* fncallback = node->op()->ValueInputCount() > 2
1982 ? NodeProperties::GetValueInput(node, 2)
1984 Node* this_arg = node->op()->ValueInputCount() > 3
1985 ? NodeProperties::GetValueInput(node, 3)
2016 Node* k = jsgraph()->ZeroConstant();
2018 Node* original_length = effect = graph()->NewNode(
2022 std::vector<Node*> checkpoint_params(
2028 Node* check_fail = nullptr;
2029 Node* check_throw = nullptr;
2031 Node* frame_state = CreateJavaScriptBuiltinContinuationFrameState(
2032 jsgraph(), shared, lazy_continuation_builtin, node->InputAt(0), context,
2040 Node* vloop = k = WireInLoopStart(k, &control, &effect);
2041 Node *loop = control, *eloop = effect;
2045 Node* if_false = nullptr;
2047 Node* continue_test =
2049 Node* continue_branch = graph()->NewNode(
2057 Node* frame_state = CreateJavaScriptBuiltinContinuationFrameState(
2058 jsgraph(), shared, eager_continuation_builtin, node->InputAt(0),
2072 Node* element =
2076 Node* next_k = checkpoint_params[3] =
2091 Node* if_found_return_value =
2095 Node* callback_value = nullptr;
2097 std::vector<Node*> call_checkpoint_params({receiver, fncallback, this_arg,
2103 Node* frame_state = CreateJavaScriptBuiltinContinuationFrameState(
2105 node->InputAt(0), context, &call_checkpoint_params[0],
2115 Node* on_exception = nullptr;
2116 if (NodeProperties::IsExceptionalCall(node, &on_exception)) {
2122 Node* boolean_result =
2124 Node* efound_branch = effect;
2125 Node* found_branch = graph()->NewNode(common()->Branch(BranchHint::kFalse),
2127 Node* if_found = graph()->NewNode(common()->IfTrue(), found_branch);
2128 Node* if_notfound = graph()->NewNode(common()->IfFalse(), found_branch);
2138 Node* if_not_found_value = (variant == ArrayFindVariant::kFind)
2141 Node* return_value =
2149 Node* throw_node =
2153 ReplaceWithValue(node, return_value, effect, control);
2157 Node* JSCallReducer::DoFilterPostCallbackWork(ElementsKind kind, Node** control,
2158 Node** effect, Node* a, Node* to,
2159 Node* element,
2160 Node* callback_value) {
2161 Node* boolean_result =
2164 Node* check_boolean_result =
2167 Node* boolean_branch = graph()->NewNode(common()->Branch(BranchHint::kTrue),
2170 Node* if_true = graph()->NewNode(common()->IfTrue(), boolean_branch);
2171 Node* etrue = *effect;
2172 Node* vtrue;
2175 Node* elements = etrue = graph()->NewNode(
2181 Node* checked_to = etrue = graph()->NewNode(
2184 Node* elements_length = etrue = graph()->NewNode(
2196 Node* new_length_a = graph()->NewNode(simplified()->NumberAdd(), checked_to,
2211 Node* if_false = graph()->NewNode(common()->IfFalse(), boolean_branch);
2212 Node* efalse = *effect;
2213 Node* vfalse = to;
2223 Node* fncallback, Node* context, Node* check_frame_state, Node* effect,
2224 Node** control, Node** check_fail, Node** check_throw) {
2225 Node* check = graph()->NewNode(simplified()->ObjectIsCallable(), fncallback);
2226 Node* check_branch =
2236 void JSCallReducer::RewirePostCallbackExceptionEdges(Node* check_throw,
2237 Node* on_exception,
2238 Node* effect,
2239 Node** check_fail,
2240 Node** control) {
2242 Node* if_exception0 =
2245 Node* if_exception1 =
2250 Node* merge =
2252 Node* ephi = graph()->NewNode(common()->EffectPhi(2), if_exception0,
2254 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2),
2259 Node* JSCallReducer::SafeLoadElement(ElementsKind kind, Node* receiver,
2260 Node* control, Node** effect, Node** k,
2264 Node* length = *effect = graph()->NewNode(
2273 Node* elements = *effect = graph()->NewNode(
2277 Node* element = *effect = graph()->NewNode(
2284 Reduction JSCallReducer::ReduceArrayEvery(Node* node,
2287 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
2288 CallParameters const& p = CallParametersOf(node->op());
2293 Node* outer_frame_state = NodeProperties::GetFrameStateInput(node);
2294 Node* effect = NodeProperties::GetEffectInput(node);
2295 Node* control = NodeProperties::GetControlInput(node);
2296 Node* context = NodeProperties::GetContextInput(node);
2298 Node* receiver = NodeProperties::GetValueInput(node, 1);
2299 Node* fncallback = node->op()->ValueInputCount() > 2
2300 ? NodeProperties::GetValueInput(node, 2)
2302 Node* this_arg = node->op()->ValueInputCount() > 3
2303 ? NodeProperties::GetValueInput(node, 3)
2340 Node* k = jsgraph()->ZeroConstant();
2347 Node* original_length = effect = graph()->NewNode(
2353 Node* check_fail = nullptr;
2354 Node* check_throw = nullptr;
2359 std::vector<Node*> checkpoint_params(
2363 Node* check_frame_state = CreateJavaScriptBuiltinContinuationFrameState(
2365 node->InputAt(0), context, &checkpoint_params[0], stack_parameters,
2372 Node* vloop = k = WireInLoopStart(k, &control, &effect);
2373 Node *loop = control, *eloop = effect;
2375 Node* continue_test =
2377 Node* continue_branch = graph()->NewNode(common()->Branch(BranchHint::kTrue),
2380 Node* if_true = graph()->NewNode(common()->IfTrue(), continue_branch);
2381 Node* if_false = graph()->NewNode(common()->IfFalse(), continue_branch);
2385 std::vector<Node*> checkpoint_params(
2389 Node* frame_state = CreateJavaScriptBuiltinContinuationFrameState(
2391 node->InputAt(0), context, &checkpoint_params[0], stack_parameters,
2404 Node* element =
2407 Node* next_k =
2410 Node* hole_true = nullptr;
2411 Node* hole_false = nullptr;
2412 Node* effect_true = effect;
2417 Node* check;
2424 Node* branch =
2437 Node* callback_value = nullptr;
2441 std::vector<Node*> checkpoint_params(
2445 Node* frame_state = CreateJavaScriptBuiltinContinuationFrameState(
2447 node->InputAt(0), context, &checkpoint_params[0], stack_parameters,
2456 Node* on_exception = nullptr;
2457 if (NodeProperties::IsExceptionalCall(node, &on_exception)) {
2463 Node* if_false_callback;
2464 Node* efalse_callback;
2466 Node* boolean_result =
2468 Node* check_boolean_result =
2471 Node* boolean_branch = graph()->NewNode(common()->Branch(BranchHint::kTrue),
2481 Node* after_call_control = control;
2482 Node* after_call_effect = effect;
2496 Node* return_value = graph()->NewNode(
2504 Node* throw_node =
2508 ReplaceWithValue(node, return_value, effect, control);
2564 SearchVariant search_variant, Node* node) {
2565 CallParameters const& p = CallParametersOf(node->op());
2571 if (!NodeProperties::GetMapWitness(isolate(), node).ToHandle(&receiver_map))
2593 Node* receiver = NodeProperties::GetValueInput(node, 1);
2594 Node* effect = NodeProperties::GetEffectInput(node);
2595 Node* control = NodeProperties::GetControlInput(node);
2596 Node* elements = effect = graph()->NewNode(
2599 Node* search_element = (node->op()->ValueInputCount() >= 3)
2600 ? NodeProperties::GetValueInput(node, 2)
2602 Node* length = effect = graph()->NewNode(
2606 Node* new_from_index = jsgraph()->ZeroConstant();
2607 if (node->op()->ValueInputCount() >= 4) {
2608 Node* from_index = NodeProperties::GetValueInput(node, 3);
2625 Node* context = NodeProperties::GetContextInput(node);
2626 Node* replacement_node = effect = graph()->NewNode(
2629 ReplaceWithValue(node, replacement_node, effect);
2633 Reduction JSCallReducer::ReduceArraySome(Node* node,
2636 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
2637 CallParameters const& p = CallParametersOf(node->op());
2642 Node* outer_frame_state = NodeProperties::GetFrameStateInput(node);
2643 Node* effect = NodeProperties::GetEffectInput(node);
2644 Node* control = NodeProperties::GetControlInput(node);
2645 Node* context = NodeProperties::GetContextInput(node);
2647 Node* receiver = NodeProperties::GetValueInput(node, 1);
2648 Node* fncallback = node->op()->ValueInputCount() > 2
2649 ? NodeProperties::GetValueInput(node, 2)
2651 Node* this_arg = node->op()->ValueInputCount() > 3
2652 ? NodeProperties::GetValueInput(node, 3)
2683 Node* k = jsgraph()->ZeroConstant();
2698 Node* original_length = effect = graph()->NewNode(
2704 Node* check_fail = nullptr;
2705 Node* check_throw = nullptr;
2710 std::vector<Node*> checkpoint_params(
2714 Node* check_frame_state = CreateJavaScriptBuiltinContinuationFrameState(
2716 node->InputAt(0), context, &checkpoint_params[0], stack_parameters,
2723 Node* loop = control = graph()->NewNode(common()->Loop(2), control, control);
2724 Node* eloop = effect =
2726 Node* terminate = graph()->NewNode(common()->Terminate(), eloop, loop);
2728 Node* vloop = k = graph()->NewNode(
2731 Node* continue_test =
2733 Node* continue_branch = graph()->NewNode(common()->Branch(BranchHint::kTrue),
2736 Node* if_true = graph()->NewNode(common()->IfTrue(), continue_branch);
2737 Node* if_false = graph()->NewNode(common()->IfFalse(), continue_branch);
2741 std::vector<Node*> checkpoint_params(
2745 Node* frame_state = CreateJavaScriptBuiltinContinuationFrameState(
2747 node->InputAt(0), context, &checkpoint_params[0], stack_parameters,
2760 Node* element =
2763 Node* next_k =
2766 Node* hole_true = nullptr;
2767 Node* hole_false = nullptr;
2768 Node* effect_true = effect;
2773 Node* check;
2780 Node* branch =
2793 Node* callback_value = nullptr;
2797 std::vector<Node*> checkpoint_params(
2801 Node* frame_state = CreateJavaScriptBuiltinContinuationFrameState(
2803 node->InputAt(0), context, &checkpoint_params[0], stack_parameters,
2812 Node* on_exception = nullptr;
2813 if (NodeProperties::IsExceptionalCall(node, &on_exception)) {
2819 Node* if_true_callback;
2820 Node* etrue_callback;
2822 Node* boolean_result =
2824 Node* check_boolean_result =
2827 Node* boolean_branch = graph()->NewNode(
2837 Node* after_call_control = control;
2838 Node* after_call_effect = effect;
2854 Node* return_value = graph()->NewNode(
2862 Node* throw_node =
2866 ReplaceWithValue(node, return_value, effect, control);
2871 Node* node, Handle<SharedFunctionInfo> shared) {
2872 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
2873 CallParameters const& p = CallParametersOf(node->op());
2875 Node* target = NodeProperties::GetValueInput(node, 0);
2876 Node* receiver = (p.convert_mode() == ConvertReceiverMode::kNullOrUndefined)
2878 : NodeProperties::GetValueInput(node, 1);
2879 Node* effect = NodeProperties::GetEffectInput(node);
2880 Node* control = NodeProperties::GetControlInput(node);
2935 Node* context = effect = graph()->NewNode(
2954 Node* holder = lookup == CallOptimization::kHolderFound
2959 node->InsertInput(graph()->zone(), 0,
2961 node->ReplaceInput(1, context);
2962 node->InsertInput(graph()->zone(), 2, jsgraph()->Constant(data));
2963 node->InsertInput(graph()->zone(), 3, holder);
2964 node->InsertInput(graph()->zone(), 4,
2966 node->ReplaceInput(5, receiver);
2967 node->RemoveInput(6 + argc); // Remove context input.
2968 node->ReplaceInput(7 + argc, effect); // Update effect input.
2969 NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
2970 return Changed(node);
2976 // explicitly checking that {node} is only used by {LoadField} or {LoadElement}.
2977 bool IsSafeArgumentsElements(Node* node) {
2978 for (Edge const edge : node->use_edges()) {
2991 Node* node, int arity, CallFrequency const& frequency,
2993 DCHECK(node->opcode() == IrOpcode::kJSCallWithArrayLike ||
2994 node->opcode() == IrOpcode::kJSCallWithSpread ||
2995 node->opcode() == IrOpcode::kJSConstructWithArrayLike ||
2996 node->opcode() == IrOpcode::kJSConstructWithSpread);
3000 if ((node->opcode() == IrOpcode::kJSCallWithSpread ||
3001 node->opcode() == IrOpcode::kJSConstructWithSpread) &&
3006 // Check if {arguments_list} is an arguments object, and {node} is the only
3008 Node* arguments_list = NodeProperties::GetValueInput(node, arity);
3014 Node* const user = edge.from();
3062 // We cannot currently reduce the {node} to something better than what
3063 // it already is, but we might be able to do something about the {node}
3065 waitlist_.insert(node);
3070 // we can only optimize this in case the {node} was already inlined into
3073 Node* frame_state = NodeProperties::GetFrameStateInput(arguments_list);
3082 // here if there's no side-effect between the {node} and the {arg_array}.
3085 Node* effect = NodeProperties::GetEffectInput(node);
3098 if (node->opcode() == IrOpcode::kJSCallWithSpread ||
3099 node->opcode() == IrOpcode::kJSConstructWithSpread) {
3104 // Remove the {arguments_list} input from the {node}.
3105 node->RemoveInput(arity--);
3108 Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
3111 (node->opcode() == IrOpcode::kJSCallWithArrayLike ||
3112 node->opcode() == IrOpcode::kJSCallWithSpread)
3115 NodeProperties::ChangeOp(node, op);
3116 return Changed(node);
3119 // we can only optimize this in case the {node} was already inlined into
3126 // Add the actual parameters to the {node}, skipping the receiver.
3127 Node* const parameters = frame_state->InputAt(kFrameStateParametersInput);
3129 node->InsertInput(graph()->zone(), static_cast<int>(++arity),
3133 if (node->opcode() == IrOpcode::kJSCallWithArrayLike ||
3134 node->opcode() == IrOpcode::kJSCallWithSpread) {
3136 node, javascript()->Call(arity + 1, frequency, feedback));
3137 Reduction const reduction = ReduceJSCall(node);
3138 return reduction.Changed() ? reduction : Changed(node);
3141 node, javascript()->Construct(arity + 2, frequency, feedback));
3142 Node* new_target = NodeProperties::GetValueInput(node, arity + 1);
3143 Node* frame_state = NodeProperties::GetFrameStateInput(node);
3144 Node* context = NodeProperties::GetContextInput(node);
3145 Node* effect = NodeProperties::GetEffectInput(node);
3146 Node* control = NodeProperties::GetControlInput(node);
3151 Node* check =
3153 Node* check_branch =
3155 Node* check_fail = graph()->NewNode(common()->IfFalse(), check_branch);
3156 Node* check_throw = check_fail =
3161 NodeProperties::ReplaceControlInput(node, control);
3164 Node* on_exception = nullptr;
3165 if (NodeProperties::IsExceptionalCall(node, &on_exception)) {
3167 Node* if_exception =
3172 Node* merge =
3174 Node* ephi = graph()->NewNode(common()->EffectPhi(2), if_exception,
3176 Node* phi =
3188 Node* throw_node =
3192 Reduction const reduction = ReduceJSConstruct(node);
3193 return reduction.Changed() ? reduction : Changed(node);
3199 bool ShouldUseCallICFeedback(Node* node) {
3200 HeapObjectMatcher m(node);
3208 Node* control = NodeProperties::GetControlInput(node);
3210 // Check if {node} is a Phi of nodes which shouldn't
3212 int const value_input_count = m.node()->op()->ValueInputCount();
3214 if (ShouldUseCallICFeedback(node->InputAt(n))) return true;
3223 Reduction JSCallReducer::ReduceJSCall(Node* node) {
3224 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
3225 CallParameters const& p = CallParametersOf(node->op());
3226 Node* target = NodeProperties::GetValueInput(node, 0);
3227 Node* control = NodeProperties::GetControlInput(node);
3228 Node* effect = NodeProperties::GetEffectInput(node);
3232 // Try to specialize JSCall {node}s with constant {target}s.
3241 return ReduceJSCall(node, handle(function->shared(), isolate()));
3254 // Patch {node} to use [[BoundTargetFunction]] and [[BoundThis]].
3256 node, jsgraph()->Constant(bound_target_function), 0);
3257 NodeProperties::ReplaceValueInput(node, jsgraph()->Constant(bound_this),
3259 // Insert the [[BoundArguments]] for {node}.
3261 node->InsertInput(
3267 node, javascript()->Call(arity, p.frequency(), VectorSlotPair(),
3269 // Try to further reduce the JSCall {node}.
3270 Reduction const reduction = ReduceJSCall(node);
3271 return reduction.Changed() ? reduction : Changed(node);
3274 // Don't mess with other {node}s that have a constant {target}.
3285 return ReduceJSCall(node, p.shared_info());
3292 Node* bound_target_function = NodeProperties::GetValueInput(target, 0);
3293 Node* bound_this = NodeProperties::GetValueInput(target, 1);
3297 // Patch the {node} to use [[BoundTargetFunction]] and [[BoundThis]].
3298 NodeProperties::ReplaceValueInput(node, bound_target_function, 0);
3299 NodeProperties::ReplaceValueInput(node, bound_this, 1);
3301 // Insert the [[BoundArguments]] for {node}.
3303 Node* value = NodeProperties::GetValueInput(target, 2 + i);
3304 node->InsertInput(graph()->zone(), 2 + i, value);
3308 // Update the JSCall operator on {node}.
3314 node, javascript()->Call(arity, p.frequency(), VectorSlotPair(),
3317 // Try to further reduce the JSCall {node}.
3318 Reduction const reduction = ReduceJSCall(node);
3319 return reduction.Changed() ? reduction : Changed(node);
3322 // Extract feedback from the {node} using the FeedbackNexus.
3327 // Introduce a SOFT deopt if the call {node} wasn't executed so far.
3329 node, DeoptimizeReason::kInsufficientTypeFeedbackForCall);
3341 Node* target_function = jsgraph()->Constant(feedback);
3344 Node* check = graph()->NewNode(simplified()->ReferenceEqual(), target,
3350 // Specialize the JSCall node to the {target_function}.
3351 NodeProperties::ReplaceValueInput(node, target_function, 0);
3352 NodeProperties::ReplaceEffectInput(node, effect);
3354 // Try to further reduce the JSCall {node}.
3355 Reduction const reduction = ReduceJSCall(node);
3356 return reduction.Changed() ? reduction : Changed(node);
3362 Reduction JSCallReducer::ReduceJSCall(Node* node,
3364 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
3365 Node* target = NodeProperties::GetValueInput(node, 0);
3372 NodeProperties::ReplaceValueInputs(node, target);
3374 node, javascript()->CallRuntime(
3376 return Changed(node);
3385 return ReduceArrayConstructor(node);
3387 return ReduceBooleanConstructor(node);
3389 return ReduceFunctionPrototypeApply(node);
3391 return ReduceFunctionPrototypeBind(node);
3393 return ReduceFunctionPrototypeCall(node);
3395 return ReduceFunctionPrototypeHasInstance(node);
3397 return ReduceObjectConstructor(node);
3399 return ReduceObjectCreate(node);
3401 return ReduceObjectGetPrototypeOf(node);
3403 return ReduceObjectIs(node);
3405 return ReduceObjectPrototypeGetProto(node);
3407 return ReduceObjectPrototypeHasOwnProperty(node);
3409 return ReduceObjectPrototypeIsPrototypeOf(node);
3411 return ReduceReflectApply(node);
3413 return ReduceReflectConstruct(node);
3415 return ReduceReflectGet(node);
3417 return ReduceReflectGetPrototypeOf(node);
3419 return ReduceReflectHas(node);
3421 node, shared);
3423 return ReduceArrayMap(node, shared);
3425 return ReduceArrayFilter(node, shared);
3427 return ReduceArrayReduce(node, ArrayReduceDirection::kLeft, shared);
3429 return ReduceArrayReduce(node, ArrayReduceDirection::kRight, shared);
3431 return ReduceArrayFind(node, ArrayFindVariant::kFind, shared);
3433 return ReduceArrayFind(node, ArrayFindVariant::kFindIndex, shared);
3435 return ReduceArrayEvery(node, shared);
3437 return ReduceArrayIndexOfIncludes(SearchVariant::kIndexOf, node);
3439 return ReduceArrayIndexOfIncludes(SearchVariant::kIncludes, node);
3441 return ReduceArraySome(node, shared);
3443 return ReduceArrayPrototypePush(node);
3445 return ReduceArrayPrototypePop(node);
3447 return ReduceArrayPrototypeShift(node);
3449 return ReduceArrayPrototypeSlice(node);
3451 return ReduceArrayIterator(node, IterationKind::kEntries);
3453 return ReduceArrayIterator(node, IterationKind::kKeys);
3455 return ReduceArrayIterator(node, IterationKind::kValues);
3457 return ReduceArrayIteratorPrototypeNext(node);
3459 return ReduceArrayIsArray(node);
3461 return ReduceArrayBufferIsView(node);
3464 node, JS_DATA_VIEW_TYPE,
3468 node, JS_DATA_VIEW_TYPE,
3471 return ReduceDataViewPrototypeGet(node,
3474 return ReduceDataViewPrototypeGet(node,
3478 node, ExternalArrayType::kExternalUint16Array);
3480 return ReduceDataViewPrototypeGet(node,
3484 node, ExternalArrayType::kExternalUint32Array);
3486 return ReduceDataViewPrototypeGet(node,
3490 node, ExternalArrayType::kExternalFloat32Array);
3493 node, ExternalArrayType::kExternalFloat64Array);
3495 return ReduceDataViewPrototypeSet(node,
3498 return ReduceDataViewPrototypeSet(node,
3502 node, ExternalArrayType::kExternalUint16Array);
3504 return ReduceDataViewPrototypeSet(node,
3508 node, ExternalArrayType::kExternalUint32Array);
3510 return ReduceDataViewPrototypeSet(node,
3514 node, ExternalArrayType::kExternalFloat32Array);
3517 node, ExternalArrayType::kExternalFloat64Array);
3520 node, JS_TYPED_ARRAY_TYPE,
3524 node, JS_TYPED_ARRAY_TYPE,
3528 node, JS_TYPED_ARRAY_TYPE, AccessBuilder::ForJSTypedArrayLength());
3530 return ReduceTypedArrayPrototypeToStringTag(node);
3532 return ReduceMathUnary(node, simplified()->NumberAbs());
3534 return ReduceMathUnary(node, simplified()->NumberAcos());
3536 return ReduceMathUnary(node, simplified()->NumberAcosh());
3538 return ReduceMathUnary(node, simplified()->NumberAsin());
3540 return ReduceMathUnary(node, simplified()->NumberAsinh());
3542 return ReduceMathUnary(node, simplified()->NumberAtan());
3544 return ReduceMathUnary(node, simplified()->NumberAtanh());
3546 return ReduceMathUnary(node, simplified()->NumberCbrt());
3548 return ReduceMathUnary(node, simplified()->NumberCeil());
3550 return ReduceMathUnary(node, simplified()->NumberCos());
3552 return ReduceMathUnary(node, simplified()->NumberCosh());
3554 return ReduceMathUnary(node, simplified()->NumberExp());
3556 return ReduceMathUnary(node, simplified()->NumberExpm1());
3558 return ReduceMathUnary(node, simplified()->NumberFloor());
3560 return ReduceMathUnary(node, simplified()->NumberFround());
3562 return ReduceMathUnary(node, simplified()->NumberLog());
3564 return ReduceMathUnary(node, simplified()->NumberLog1p());
3566 return ReduceMathUnary(node, simplified()->NumberLog10());
3568 return ReduceMathUnary(node, simplified()->NumberLog2());
3570 return ReduceMathUnary(node, simplified()->NumberRound());
3572 return ReduceMathUnary(node, simplified()->NumberSign());
3574 return ReduceMathUnary(node, simplified()->NumberSin());
3576 return ReduceMathUnary(node, simplified()->NumberSinh());
3578 return ReduceMathUnary(node, simplified()->NumberSqrt());
3580 return ReduceMathUnary(node, simplified()->NumberTan());
3582 return ReduceMathUnary(node, simplified()->NumberTanh());
3584 return ReduceMathUnary(node, simplified()->NumberTrunc());
3586 return ReduceMathBinary(node, simplified()->NumberAtan2());
3588 return ReduceMathBinary(node, simplified()->NumberPow());
3590 return ReduceMathClz32(node);
3592 return ReduceMathImul(node);
3594 return ReduceMathMinMax(node, simplified()->NumberMax(),
3597 return ReduceMathMinMax(node, simplified()->NumberMin(),
3600 return ReduceNumberIsFinite(node);
3602 return ReduceNumberIsInteger(node);
3604 return ReduceNumberIsSafeInteger(node);
3606 return ReduceNumberIsNaN(node);
3608 return ReduceNumberParseInt(node);
3610 return ReduceGlobalIsFinite(node);
3612 return ReduceGlobalIsNaN(node);
3614 return ReduceMapPrototypeGet(node);
3616 return ReduceMapPrototypeHas(node);
3618 return ReduceRegExpPrototypeTest(node);
3620 return ReduceReturnReceiver(node);
3622 return ReduceStringPrototypeIndexOf(node);
3624 return ReduceStringPrototypeCharAt(node);
3627 node);
3630 simplified()->StringCodePointAt(UnicodeEncoding::UTF32), node);
3632 return ReduceStringPrototypeSubstring(node);
3634 return ReduceStringPrototypeSlice(node);
3636 return ReduceStringPrototypeSubstr(node);
3639 return ReduceStringPrototypeToLowerCaseIntl(node);
3641 return ReduceStringPrototypeToUpperCaseIntl(node);
3644 return ReduceStringFromCharCode(node);
3646 return ReduceStringFromCodePoint(node);
3648 return ReduceStringPrototypeIterator(node);
3650 return ReduceStringIteratorPrototypeNext(node);
3652 return ReduceStringPrototypeConcat(node, shared);
3654 return ReduceArrayIterator(node, IterationKind::kEntries);
3656 return ReduceArrayIterator(node, IterationKind::kKeys);
3658 return ReduceArrayIterator(node, IterationKind::kValues);
3660 return ReduceAsyncFunctionPromiseCreate(node);
3662 return ReduceAsyncFunctionPromiseRelease(node);
3664 return ReducePromiseInternalConstructor(node);
3666 return ReducePromiseInternalReject(node);
3668 return ReducePromiseInternalResolve(node);
3670 return ReducePromisePrototypeCatch(node);
3672 return ReducePromisePrototypeFinally(node);
3674 return ReducePromisePrototypeThen(node);
3676 return ReduceCollectionIteration(node, CollectionKind::kMap,
3679 return ReduceCollectionIteration(node, CollectionKind::kMap,
3682 return ReduceCollectionPrototypeSize(node, CollectionKind::kMap);
3684 return ReduceCollectionIteration(node, CollectionKind::kMap,
3688 node, OrderedHashMap::kEntrySize, factory()->empty_ordered_hash_map(),
3691 return ReduceCollectionIteration(node, CollectionKind::kSet,
3694 return ReduceCollectionPrototypeSize(node, CollectionKind::kSet);
3696 return ReduceCollectionIteration(node, CollectionKind::kSet,
3700 node, OrderedHashSet::kEntrySize, factory()->empty_ordered_hash_set(),
3703 return ReduceDatePrototypeGetTime(node);
3705 return ReduceDateNow(node);
3707 return ReduceNumberConstructor(node);
3713 return ReduceCallApiFunction(node, shared);
3718 Reduction JSCallReducer::ReduceJSCallWithArrayLike(Node* node) {
3719 DCHECK_EQ(IrOpcode::kJSCallWithArrayLike, node->opcode());
3720 CallFrequency frequency = CallFrequencyOf(node->op());
3722 return ReduceCallOrConstructWithArrayLikeOrSpread(node, 2, frequency,
3726 Reduction JSCallReducer::ReduceJSCallWithSpread(Node* node) {
3727 DCHECK_EQ(IrOpcode::kJSCallWithSpread, node->opcode());
3728 CallParameters const& p = CallParametersOf(node->op());
3733 return ReduceCallOrConstructWithArrayLikeOrSpread(node, arity, frequency,
3737 Reduction JSCallReducer::ReduceJSConstruct(Node* node) {
3738 DCHECK_EQ(IrOpcode::kJSConstruct, node->opcode());
3739 ConstructParameters const& p = ConstructParametersOf(node->op());
3742 Node* target = NodeProperties::GetValueInput(node, 0);
3743 Node* new_target = NodeProperties::GetValueInput(node, arity + 1);
3744 Node* effect = NodeProperties::GetEffectInput(node);
3745 Node* control = NodeProperties::GetControlInput(node);
3747 // Extract feedback from the {node} using the FeedbackNexus.
3752 // Introduce a SOFT deopt if the construct {node} wasn't executed so
3755 node, DeoptimizeReason::kInsufficientTypeFeedbackForConstruct);
3770 // Retrieve the Array function from the {node}.
3771 Node* array_function = jsgraph()->HeapConstant(
3775 Node* check = graph()->NewNode(simplified()->ReferenceEqual(), target,
3781 // Turn the {node} into a {JSCreateArray} call.
3782 NodeProperties::ReplaceEffectInput(node, effect);
3785 node, NodeProperties::GetValueInput(node, i), i + 1);
3787 NodeProperties::ReplaceValueInput(node, array_function, 1);
3788 NodeProperties::ChangeOp(node, javascript()->CreateArray(arity, site));
3789 return Changed(node);
3794 Node* new_target_feedback = jsgraph()->Constant(object);
3797 Node* check = graph()->NewNode(simplified()->ReferenceEqual(),
3803 // Specialize the JSConstruct node to the {new_target_feedback}.
3804 NodeProperties::ReplaceValueInput(node, new_target_feedback, arity + 1);
3805 NodeProperties::ReplaceEffectInput(node, effect);
3807 NodeProperties::ReplaceValueInput(node, new_target_feedback, 0);
3810 // Try to further reduce the JSConstruct {node}.
3811 Reduction const reduction = ReduceJSConstruct(node);
3812 return reduction.Changed() ? reduction : Changed(node);
3817 // Try to specialize JSConstruct {node}s with constant {target}s.
3822 NodeProperties::ReplaceValueInputs(node, target);
3823 NodeProperties::ChangeOp(node,
3826 return Changed(node);
3846 // Turn the {node} into a {JSCreateArray} call.
3849 node, NodeProperties::GetValueInput(node, i), i + 1);
3851 NodeProperties::ReplaceValueInput(node, new_target, 1);
3852 NodeProperties::ChangeOp(node,
3854 return Changed(node);
3858 // JSCreate and don't need to do any massaging of the {node}.
3860 NodeProperties::ChangeOp(node, javascript()->Create());
3861 return Changed(node);
3870 for (int i = arity; i > 0; --i) node->RemoveInput(i);
3871 NodeProperties::ChangeOp(node, javascript()->Create());
3872 return Changed(node);
3877 return ReducePromiseConstructor(node);
3880 node, handle(function->shared(), isolate()));
3892 // Patch {node} to use [[BoundTargetFunction]].
3894 node, jsgraph()->Constant(bound_target_function), 0);
3896 // Patch {node} to use [[BoundTargetFunction]]
3899 node,
3907 // Insert the [[BoundArguments]] for {node}.
3909 node->InsertInput(
3915 // Update the JSConstruct operator on {node}.
3917 node,
3920 // Try to further reduce the JSConstruct {node}.
3921 Reduction const reduction = ReduceJSConstruct(node);
3922 return reduction.Changed() ? reduction : Changed(node);
3932 Node* bound_target_function = NodeProperties::GetValueInput(target, 0);
3936 // Patch the {node} to use [[BoundTargetFunction]].
3937 NodeProperties::ReplaceValueInput(node, bound_target_function, 0);
3939 // Patch {node} to use [[BoundTargetFunction]]
3942 node,
3949 // Insert the [[BoundArguments]] for {node}.
3951 Node* value = NodeProperties::GetValueInput(target, 2 + i);
3952 node->InsertInput(graph()->zone(), 1 + i, value);
3956 // Update the JSConstruct operator on {node}.
3958 node,
3961 // Try to further reduce the JSConstruct {node}.
3962 Reduction const reduction = ReduceJSConstruct(node);
3963 return reduction.Changed() ? reduction : Changed(node);
3970 Reduction JSCallReducer::ReduceStringPrototypeIndexOf(Node* node) {
3971 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
3972 CallParameters const& p = CallParametersOf(node->op());
3977 Node* effect = NodeProperties::GetEffectInput(node);
3978 Node* control = NodeProperties::GetControlInput(node);
3979 if (node->op()->ValueInputCount() >= 3) {
3980 Node* receiver = NodeProperties::GetValueInput(node, 1);
3981 Node* new_receiver = effect = graph()->NewNode(
3984 Node* search_string = NodeProperties::GetValueInput(node, 2);
3985 Node* new_search_string = effect =
3989 Node* new_position = jsgraph()->ZeroConstant();
3990 if (node->op()->ValueInputCount() >= 4) {
3991 Node* position = NodeProperties::GetValueInput(node, 3);
3996 NodeProperties::ReplaceEffectInput(node, effect);
3997 RelaxEffectsAndControls(node);
3998 node->ReplaceInput(0, new_receiver);
3999 node->ReplaceInput(1, new_search_string);
4000 node->ReplaceInput(2, new_position);
4001 node->TrimInputCount(3);
4002 NodeProperties::ChangeOp(node, simplified()->StringIndexOf());
4003 return Changed(node);
4009 Reduction JSCallReducer::ReduceStringPrototypeSubstring(Node* node) {
4010 if (node->op()->ValueInputCount() < 3) return NoChange();
4011 CallParameters const& p = CallParametersOf(node->op());
4016 Node* effect = NodeProperties::GetEffectInput(node);
4017 Node* control = NodeProperties::GetControlInput(node);
4018 Node* receiver = NodeProperties::GetValueInput(node, 1);
4019 Node* start = NodeProperties::GetValueInput(node, 2);
4020 Node* end = node->op()->ValueInputCount() > 3
4021 ? NodeProperties::GetValueInput(node, 3)
4030 Node* length = graph()->NewNode(simplified()->StringLength(), receiver);
4032 Node* check = graph()->NewNode(simplified()->ReferenceEqual(), end,
4034 Node* branch =
4037 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
4038 Node* etrue = effect;
4039 Node* vtrue = length;
4041 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
4042 Node* efalse = effect;
4043 Node* vfalse = efalse = graph()->NewNode(simplified()->CheckSmi(p.feedback()),
4050 Node* finalStart =
4055 Node* finalEnd =
4061 Node* from =
4063 Node* to = graph()->NewNode(simplified()->NumberMax(), finalStart, finalEnd);
4065 Node* value = effect = graph()->NewNode(simplified()->StringSubstring(),
4067 ReplaceWithValue(node, value, effect, control);
4072 Reduction JSCallReducer::ReduceStringPrototypeSlice(Node* node) {
4073 if (node->op()->ValueInputCount() < 3) return NoChange();
4074 CallParameters const& p = CallParametersOf(node->op());
4079 Node* effect = NodeProperties::GetEffectInput(node);
4080 Node* control = NodeProperties::GetControlInput(node);
4081 Node* receiver = NodeProperties::GetValueInput(node, 1);
4082 Node* start = NodeProperties::GetValueInput(node, 2);
4083 Node* end = node->op()->ValueInputCount() > 3
4084 ? NodeProperties::GetValueInput(node, 3)
4093 Node* length = graph()->NewNode(simplified()->StringLength(), receiver);
4097 Node* check = graph()->NewNode(simplified()->ReferenceEqual(), end,
4100 Node* branch =
4103 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
4104 Node* etrue = effect;
4105 Node* vtrue = length;
4107 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
4108 Node* efalse = effect;
4109 Node* vfalse = efalse = graph()->NewNode(
4118 Node* from = graph()->NewNode(
4132 Node* to = graph()->NewNode(
4145 Node* result_string = nullptr;
4148 Node* check = graph()->NewNode(simplified()->NumberLessThan(), from, to);
4150 Node* branch =
4153 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
4154 Node* etrue = effect;
4155 Node* vtrue = etrue = graph()->NewNode(simplified()->StringSubstring(),
4158 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
4159 Node* efalse = effect;
4160 Node* vfalse = jsgraph()->EmptyStringConstant();
4169 ReplaceWithValue(node, result_string, effect, control);
4174 Reduction JSCallReducer::ReduceStringPrototypeSubstr(Node* node) {
4175 if (node->op()->ValueInputCount() < 3) return NoChange();
4176 CallParameters const& p = CallParametersOf(node->op());
4181 Node* effect = NodeProperties::GetEffectInput(node);
4182 Node* control = NodeProperties::GetControlInput(node);
4183 Node* receiver = NodeProperties::GetValueInput(node, 1);
4184 Node* start = NodeProperties::GetValueInput(node, 2);
4185 Node* end = node->op()->ValueInputCount() > 3
4186 ? NodeProperties::GetValueInput(node, 3)
4195 Node* length = graph()->NewNode(simplified()->StringLength(), receiver);
4199 Node* check = graph()->NewNode(simplified()->ReferenceEqual(), end,
4201 Node* branch =
4204 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
4205 Node* etrue = effect;
4206 Node* vtrue = length;
4208 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
4209 Node* efalse = effect;
4210 Node* vfalse = efalse = graph()->NewNode(
4219 Node* initStart = graph()->NewNode(
4233 Node* resultLength = graph()->NewNode(
4241 Node* to = effect = graph()->NewNode(
4246 Node* result_string = nullptr;
4249 Node* check = graph()->NewNode(simplified()->NumberLessThan(),
4252 Node* branch =
4255 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
4256 Node* etrue = effect;
4257 Node* vtrue = etrue =
4261 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
4262 Node* efalse = effect;
4263 Node* vfalse = jsgraph()->EmptyStringConstant();
4272 ReplaceWithValue(node, result_string, effect, control);
4276 Reduction JSCallReducer::ReduceJSConstructWithArrayLike(Node* node) {
4277 DCHECK_EQ(IrOpcode::kJSConstructWithArrayLike, node->opcode());
4278 CallFrequency frequency = CallFrequencyOf(node->op());
4280 return ReduceCallOrConstructWithArrayLikeOrSpread(node, 1, frequency,
4284 Reduction JSCallReducer::ReduceJSConstructWithSpread(Node* node) {
4285 DCHECK_EQ(IrOpcode::kJSConstructWithSpread, node->opcode());
4286 ConstructParameters const& p = ConstructParametersOf(node->op());
4291 return ReduceCallOrConstructWithArrayLikeOrSpread(node, arity, frequency,
4295 Reduction JSCallReducer::ReduceReturnReceiver(Node* node) {
4296 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
4297 Node* receiver = NodeProperties::GetValueInput(node, 1);
4298 ReplaceWithValue(node, receiver);
4302 Reduction JSCallReducer::ReduceSoftDeoptimize(Node* node,
4304 Node* effect = NodeProperties::GetEffectInput(node);
4305 Node* control = NodeProperties::GetControlInput(node);
4306 Node* frame_state = NodeProperties::FindFrameStateBefore(node);
4307 Node* deoptimize = graph()->NewNode(
4313 node->TrimInputCount(0);
4314 NodeProperties::ChangeOp(node, common()->Dead());
4315 return Changed(node);
4345 Reduction JSCallReducer::ReduceArrayPrototypePush(Node* node) {
4346 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
4347 CallParameters const& p = CallParametersOf(node->op());
4354 int const num_values = node->op()->ValueInputCount() - 2;
4355 Node* receiver = NodeProperties::GetValueInput(node, 1);
4356 Node* effect = NodeProperties::GetEffectInput(node);
4357 Node* control = NodeProperties::GetControlInput(node);
4390 std::vector<Node*> values(num_values);
4392 values[i] = NodeProperties::GetValueInput(node, 2 + i);
4408 Node* length = effect = graph()->NewNode(
4411 Node* value = length;
4416 Node* new_length = value = graph()->NewNode(
4420 Node* elements = effect = graph()->NewNode(
4423 Node* elements_length = effect = graph()->NewNode(
4445 Node* value = values[i];
4446 Node* index = graph()->NewNode(simplified()->NumberAdd(), length,
4454 ReplaceWithValue(node, value, effect, control);
4459 Reduction JSCallReducer::ReduceArrayPrototypePop(Node* node) {
4460 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
4461 CallParameters const& p = CallParametersOf(node->op());
4468 Node* receiver = NodeProperties::GetValueInput(node, 1);
4469 Node* effect = NodeProperties::GetEffectInput(node);
4470 Node* control = NodeProperties::GetControlInput(node);
4505 Node* length = effect = graph()->NewNode(
4510 Node* check = graph()->NewNode(simplified()->NumberEqual(), length,
4512 Node* branch =
4515 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
4516 Node* etrue = effect;
4517 Node* vtrue = jsgraph()->UndefinedConstant();
4519 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
4520 Node* efalse = effect;
4521 Node* vfalse;
4527 Node* elements = efalse = graph()->NewNode(
4561 Node* value = graph()->NewNode(
4571 ReplaceWithValue(node, value, effect, control);
4576 Reduction JSCallReducer::ReduceArrayPrototypeShift(Node* node) {
4577 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
4578 CallParameters const& p = CallParametersOf(node->op());
4584 Node* target = NodeProperties::GetValueInput(node, 0);
4585 Node* receiver = NodeProperties::GetValueInput(node, 1);
4586 Node* context = NodeProperties::GetContextInput(node);
4587 Node* frame_state = NodeProperties::GetFrameStateInput(node);
4588 Node* effect = NodeProperties::GetEffectInput(node);
4589 Node* control = NodeProperties::GetControlInput(node);
4624 Node* length = effect = graph()->NewNode(
4629 Node* check0 = graph()->NewNode(simplified()->NumberEqual(), length,
4631 Node* branch0 =
4634 Node* if_true0 = graph()->NewNode(common()->IfTrue(), branch0);
4635 Node* etrue0 = effect;
4636 Node* vtrue0 = jsgraph()->UndefinedConstant();
4638 Node* if_false0 = graph()->NewNode(common()->IfFalse(), branch0);
4639 Node* efalse0 = effect;
4640 Node* vfalse0;
4643 Node* check1 =
4646 Node* branch1 = graph()->NewNode(common()->Branch(BranchHint::kTrue),
4649 Node* if_true1 = graph()->NewNode(common()->IfTrue(), branch1);
4650 Node* etrue1 = efalse0;
4651 Node* vtrue1;
4653 Node* elements = etrue1 = graph()->NewNode(
4670 Node* loop = graph()->NewNode(common()->Loop(2), if_true1, if_true1);
4671 Node* eloop =
4673 Node* terminate = graph()->NewNode(common()->Terminate(), eloop, loop);
4675 Node* index = graph()->NewNode(
4681 Node* check2 =
4683 Node* branch2 = graph()->NewNode(common()->Branch(), check2, loop);
4688 Node* control = graph()->NewNode(common()->IfTrue(), branch2);
4689 Node* effect = etrue1;
4692 Node* value = effect =
4724 Node* if_false1 = graph()->NewNode(common()->IfFalse(), branch1);
4725 Node* efalse1 = efalse0;
4726 Node* vfalse1;
4732 Builtins::name(builtin_index), node->op()->properties(),
4734 Node* stub_code =
4737 Node* entry =
4739 Node* argc =
4757 Node* value =
4768 ReplaceWithValue(node, value, effect, control);
4773 Reduction JSCallReducer::ReduceArrayPrototypeSlice(Node* node) {
4775 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
4776 CallParameters const& p = CallParametersOf(node->op());
4786 NumberMatcher m(NodeProperties::GetValueInput(node, 2));
4791 Node* receiver = NodeProperties::GetValueInput(node, 1);
4792 Node* effect = NodeProperties::GetEffectInput(node);
4793 Node* control = NodeProperties::GetControlInput(node);
4833 Node* context = NodeProperties::GetContextInput(node);
4843 Node* clone = effect = graph()->NewNode(
4847 ReplaceWithValue(node, clone, effect, control);
4852 Reduction JSCallReducer::ReduceArrayIsArray(Node* node) {
4854 if (node->op()->ValueInputCount() < 3) {
4855 Node* value = jsgraph()->FalseConstant();
4856 ReplaceWithValue(node, value);
4860 Node* effect = NodeProperties::GetEffectInput(node);
4861 Node* control = NodeProperties::GetControlInput(node);
4862 Node* context = NodeProperties::GetContextInput(node);
4863 Node* frame_state = NodeProperties::GetFrameStateInput(node);
4864 Node* object = NodeProperties::GetValueInput(node, 2);
4865 node->ReplaceInput(0, object);
4866 node->ReplaceInput(1, context);
4867 node->ReplaceInput(2, frame_state);
4868 node->ReplaceInput(3, effect);
4869 node->ReplaceInput(4, control);
4870 node->TrimInputCount(5);
4871 NodeProperties::ChangeOp(node, javascript()->ObjectIsArray());
4872 return Changed(node);
4875 Reduction JSCallReducer::ReduceArrayIterator(Node* node, IterationKind kind) {
4876 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
4877 Node* receiver = NodeProperties::GetValueInput(node, 1);
4878 Node* context = NodeProperties::GetContextInput(node);
4879 Node* effect = NodeProperties::GetEffectInput(node);
4880 Node* control = NodeProperties::GetControlInput(node);
4893 // Morph the {node} into a JSCreateArrayIterator with the given {kind}.
4894 RelaxControls(node);
4895 node->ReplaceInput(0, receiver);
4896 node->ReplaceInput(1, context);
4897 node->ReplaceInput(2, effect);
4898 node->ReplaceInput(3, control);
4899 node->TrimInputCount(4);
4900 NodeProperties::ChangeOp(node, javascript()->CreateArrayIterator(kind));
4901 return Changed(node);
4906 bool InferIteratedObjectMaps(Isolate* isolate, Node* iterator,
4909 Node* iterated_object = NodeProperties::GetValueInput(iterator, 0);
4910 Node* effect = NodeProperties::GetEffectInput(iterator);
4921 Node* node) {
4922 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
4923 CallParameters const& p = CallParametersOf(node->op());
4924 Node* iterator = NodeProperties::GetValueInput(node, 1);
4925 Node* context = NodeProperties::GetContextInput(node);
4926 Node* effect = NodeProperties::GetEffectInput(node);
4927 Node* control = NodeProperties::GetControlInput(node);
4977 Node* iterated_object = effect =
4997 Node* buffer = effect = graph()->NewNode(
5001 Node* check = effect = graph()->NewNode(
5024 Node* index = effect = graph()->NewNode(simplified()->LoadField(index_access),
5033 Node* elements = effect = graph()->NewNode(
5044 Node* length = effect = graph()->NewNode(
5048 Node* check = graph()->NewNode(simplified()->NumberLessThan(), index, length);
5049 Node* branch =
5052 Node* done_true;
5053 Node* value_true;
5054 Node* etrue = effect;
5055 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
5072 Node* base_ptr = etrue = graph()->NewNode(
5076 Node* external_ptr = etrue = graph()->NewNode(
5093 Node* buffer = etrue =
5133 Node* next_index = graph()->NewNode(simplified()->NumberAdd(), index,
5139 Node* done_false;
5140 Node* value_false;
5141 Node* efalse = effect;
5142 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
5159 Node* end_index = jsgraph()->Constant(index_access.type.Max());
5167 Node* value =
5170 Node* done =
5177 ReplaceWithValue(node, value, effect, control);
5184 const Operator* string_access_operator, Node* node) {
5187 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
5188 CallParameters const& p = CallParametersOf(node->op());
5193 Node* receiver = NodeProperties::GetValueInput(node, 1);
5194 Node* index = node->op()->ValueInputCount() >= 3
5195 ? NodeProperties::GetValueInput(node, 2)
5197 Node* effect = NodeProperties::GetEffectInput(node);
5198 Node* control = NodeProperties::GetControlInput(node);
5205 Node* receiver_length =
5213 Node* masked_index = graph()->NewNode(simplified()->PoisonIndex(), index);
5214 Node* value = effect = graph()->NewNode(string_access_operator, receiver,
5217 ReplaceWithValue(node, value, effect, control);
5222 Reduction JSCallReducer::ReduceStringPrototypeCharAt(Node* node) {
5223 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
5224 CallParameters const& p = CallParametersOf(node->op());
5229 Node* receiver = NodeProperties::GetValueInput(node, 1);
5230 Node* index = node->op()->ValueInputCount() >= 3
5231 ? NodeProperties::GetValueInput(node, 2)
5233 Node* effect = NodeProperties::GetEffectInput(node);
5234 Node* control = NodeProperties::GetControlInput(node);
5241 Node* receiver_length =
5249 Node* masked_index = graph()->NewNode(simplified()->PoisonIndex(), index);
5250 Node* value = effect =
5255 ReplaceWithValue(node, value, effect, control);
5261 Reduction JSCallReducer::ReduceStringPrototypeToLowerCaseIntl(Node* node) {
5262 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
5263 CallParameters const& p = CallParametersOf(node->op());
5267 Node* effect = NodeProperties::GetEffectInput(node);
5268 Node* control = NodeProperties::GetControlInput(node);
5270 Node* receiver = effect =
5272 NodeProperties::GetValueInput(node, 1), effect, control);
5274 NodeProperties::ReplaceEffectInput(node, effect);
5275 RelaxEffectsAndControls(node);
5276 node->ReplaceInput(0, receiver);
5277 node->TrimInputCount(1);
5278 NodeProperties::ChangeOp(node, simplified()->StringToLowerCaseIntl());
5279 NodeProperties::SetType(node, Type::String());
5280 return Changed(node);
5283 Reduction JSCallReducer::ReduceStringPrototypeToUpperCaseIntl(Node* node) {
5284 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
5285 CallParameters const& p = CallParametersOf(node->op());
5289 Node* effect = NodeProperties::GetEffectInput(node);
5290 Node* control = NodeProperties::GetControlInput(node);
5292 Node* receiver = effect =
5294 NodeProperties::GetValueInput(node, 1), effect, control);
5296 NodeProperties::ReplaceEffectInput(node, effect);
5297 node);
5298 node->ReplaceInput(0, receiver);
5299 node->TrimInputCount(1);
5300 NodeProperties::ChangeOp(node, simplified()->StringToUpperCaseIntl());
5301 NodeProperties::SetType(node, Type::String());
5302 return Changed(node);
5308 Reduction JSCallReducer::ReduceStringFromCharCode(Node* node) {
5309 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
5310 CallParameters const& p = CallParametersOf(node->op());
5314 if (node->op()->ValueInputCount() == 3) {
5315 Node* effect = NodeProperties::GetEffectInput(node);
5316 Node* control = NodeProperties::GetControlInput(node);
5317 Node* input = NodeProperties::GetValueInput(node, 2);
5324 Node* value =
5326 ReplaceWithValue(node, value, effect);
5333 Reduction JSCallReducer::ReduceStringFromCodePoint(Node* node) {
5334 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
5335 CallParameters const& p = CallParametersOf(node->op());
5339 if (node->op()->ValueInputCount() == 3) {
5340 Node* effect = NodeProperties::GetEffectInput(node);
5341 Node* control = NodeProperties::GetControlInput(node);
5342 Node* input = NodeProperties::GetValueInput(node, 2);
5351 Node* value = graph()->NewNode(
5353 ReplaceWithValue(node, value, effect);
5359 Reduction JSCallReducer::ReduceStringPrototypeIterator(Node* node) {
5360 CallParameters const& p = CallParametersOf(node->op());
5364 Node* effect = NodeProperties::GetEffectInput(node);
5365 Node* control = NodeProperties::GetControlInput(node);
5366 Node* receiver = effect =
5368 NodeProperties::GetValueInput(node, 1), effect, control);
5369 Node* iterator = effect =
5372 ReplaceWithValue(node, iterator, effect, control);
5376 Reduction JSCallReducer::ReduceStringIteratorPrototypeNext(Node* node) {
5377 Node* receiver = NodeProperties::GetValueInput(node, 1);
5378 Node* effect = NodeProperties::GetEffectInput(node);
5379 Node* control = NodeProperties::GetControlInput(node);
5380 Node* context = NodeProperties::GetContextInput(node);
5383 Node* string = effect = graph()->NewNode(
5386 Node* index = effect = graph()->NewNode(
5389 Node* length = graph()->NewNode(simplified()->StringLength(), string);
5392 Node* check0 =
5394 Node* branch0 =
5397 Node* etrue0 = effect;
5398 Node* if_true0 = graph()->NewNode(common()->IfTrue(), branch0);
5399 Node* done_true;
5400 Node* vtrue0;
5403 Node* codepoint = etrue0 = graph()->NewNode(
5411 Node* char_length =
5419 Node* if_false0 = graph()->NewNode(common()->IfFalse(), branch0);
5420 Node* done_false;
5421 Node* vfalse0;
5429 Node* value =
5432 Node* done =
5439 ReplaceWithValue(node, value, effect, control);
5447 Node* node, Handle<SharedFunctionInfo> shared) {
5448 if (node->op()->ValueInputCount() < 2 || node->op()->ValueInputCount() > 3) {
5451 CallParameters const& p = CallParametersOf(node->op());
5455 Node* effect = NodeProperties::GetEffectInput(node);
5456 Node* control = NodeProperties::GetControlInput(node);
5457 Node* context = NodeProperties::GetContextInput(node);
5458 Node* receiver = effect =
5460 NodeProperties::GetValueInput(node, 1), effect, control);
5462 if (node->op()->ValueInputCount() < 3) {
5463 ReplaceWithValue(node, receiver, effect, control);
5466 Node* argument = effect =
5468 NodeProperties::GetValueInput(node, 2), effect, control);
5477 // TODO(turbofan): Massage the FrameState of the {node} here once we
5481 Node* outer_frame_state = NodeProperties::GetFrameStateInput(node);
5483 Node* value = effect = control = graph()->NewNode(
5487 ReplaceWithValue(node, value, effect, control);
5491 Reduction JSCallReducer::ReduceAsyncFunctionPromiseCreate(Node* node) {
5492 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
5493 Node* context = NodeProperties::GetContextInput(node);
5494 Node* effect = NodeProperties::GetEffectInput(node);
5501 // Morph this {node} into a JSCreatePromise node.
5502 RelaxControls(node);
5503 node->ReplaceInput(0, context);
5504 node->ReplaceInput(1, effect);
5505 node->TrimInputCount(2);
5506 NodeProperties::ChangeOp(node, javascript()->CreatePromise());
5507 return Changed(node);
5510 Reduction JSCallReducer::ReduceAsyncFunctionPromiseRelease(Node* node) {
5511 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
5519 Node* value = jsgraph()->UndefinedConstant();
5520 ReplaceWithValue(node, value);
5524 Node* JSCallReducer::CreateArtificialFrameState(
5525 Node* node, Node* outer_frame_state, int parameter_count,
5535 Node* node0 = graph()->NewNode(op0);
5536 std::vector<Node*> params;
5538 params.push_back(node->InputAt(1 + parameter));
5542 Node* params_node = graph()->NewNode(
5545 jsgraph()->UndefinedConstant(), node->InputAt(0),
5549 Reduction JSCallReducer::ReducePromiseConstructor(Node* node) {
5550 DCHECK_EQ(IrOpcode::kJSConstruct, node->opcode());
5551 ConstructParameters const& p = ConstructParametersOf(node->op());
5555 Node* target = NodeProperties::GetValueInput(node, 0);
5556 Node* executor = NodeProperties::GetValueInput(node, 1);
5557 Node* new_target = NodeProperties::GetValueInput(node, arity + 1);
5559 Node* context = NodeProperties::GetContextInput(node);
5560 Node* outer_frame_state = NodeProperties::GetFrameStateInput(node);
5561 Node* effect = NodeProperties::GetEffectInput(node);
5562 Node* control = NodeProperties::GetControlInput(node);
5581 Node* constructor_frame_state = CreateArtificialFrameState(
5582 node, outer_frame_state, 1, BailoutId::ConstructStubInvoke(),
5587 const std::vector<Node*> checkpoint_parameters({
5595 Node* frame_state = CreateJavaScriptBuiltinContinuationFrameState(
5602 Node* check_fail = nullptr;
5603 Node* check_throw = nullptr;
5608 Node* promise = effect =
5613 Node* promise_context = effect =
5637 Node* resolve = effect =
5647 Node* reject = effect =
5653 const std::vector<Node*> checkpoint_parameters_continuation(
5674 Node* exception_effect = effect;
5675 Node* exception_control = control;
5677 Node* reason = exception_effect = exception_control = graph()->NewNode(
5688 Node* on_exception = nullptr;
5689 if (NodeProperties::IsExceptionalCall(node, &on_exception)) {
5696 Node* success_effect = effect;
5697 Node* success_control = control;
5711 Node* throw_node =
5715 ReplaceWithValue(node, promise, effect, control);
5720 Reduction JSCallReducer::ReducePromiseInternalConstructor(Node* node) {
5721 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
5722 Node* context = NodeProperties::GetContextInput(node);
5723 Node* effect = NodeProperties::GetEffectInput(node);
5732 Node* value = effect =
5735 ReplaceWithValue(node, value, effect);
5740 Reduction JSCallReducer::ReducePromiseInternalReject(Node* node) {
5741 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
5742 Node* promise = node->op()->ValueInputCount() >= 2
5743 ? NodeProperties::GetValueInput(node, 2)
5745 Node* reason = node->op()->ValueInputCount() >= 3
5746 ? NodeProperties::GetValueInput(node, 3)
5748 Node* debug_event = jsgraph()->TrueConstant();
5749 Node* frame_state = NodeProperties::GetFrameStateInput(node);
5750 Node* context = NodeProperties::GetContextInput(node);
5751 Node* effect = NodeProperties::GetEffectInput(node);
5752 Node* control = NodeProperties::GetControlInput(node);
5755 Node* value = effect =
5759 ReplaceWithValue(node, value, effect, control);
5764 Reduction JSCallReducer::ReducePromiseInternalResolve(Node* node) {
5765 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
5766 Node* promise = node->op()->ValueInputCount() >= 2
5767 ? NodeProperties::GetValueInput(node, 2)
5769 Node* resolution = node->op()->ValueInputCount() >= 3
5770 ? NodeProperties::GetValueInput(node, 3)
5772 Node* frame_state = NodeProperties::GetFrameStateInput(node);
5773 Node* context = NodeProperties::GetContextInput(node);
5774 Node* effect = NodeProperties::GetEffectInput(node);
5775 Node* control = NodeProperties::GetControlInput(node);
5778 Node* value = effect =
5782 ReplaceWithValue(node, value, effect, control);
5787 Reduction JSCallReducer::ReducePromisePrototypeCatch(Node* node) {
5788 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
5789 CallParameters const& p = CallParametersOf(node->op());
5794 Node* receiver = NodeProperties::GetValueInput(node, 1);
5795 Node* effect = NodeProperties::GetEffectInput(node);
5796 Node* control = NodeProperties::GetControlInput(node);
5833 // Massage the {node} to call "then" instead by first removing all inputs
5836 Node* target =
5838 NodeProperties::ReplaceValueInput(node, target, 0);
5839 NodeProperties::ReplaceEffectInput(node, effect);
5840 for (; arity > 1; --arity) node->RemoveInput(3);
5842 node->InsertInput(graph()->zone(), 2, jsgraph()->UndefinedConstant());
5845 node, javascript()->Call(2 + arity, p.frequency(), p.feedback(),
5848 Reduction const reduction = ReducePromisePrototypeThen(node);
5849 return reduction.Changed() ? reduction : Changed(node);
5853 Reduction JSCallReducer::ReducePromisePrototypeFinally(Node* node) {
5854 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
5855 CallParameters const& p = CallParametersOf(node->op());
5857 Node* receiver = NodeProperties::GetValueInput(node, 1);
5858 Node* on_finally = arity >= 1 ? NodeProperties::GetValueInput(node, 2)
5860 Node* effect = NodeProperties::GetEffectInput(node);
5861 Node* control = NodeProperties::GetControlInput(node);
5916 Node* check = graph()->NewNode(simplified()->ObjectIsCallable(), on_finally);
5917 Node* branch =
5920 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
5921 Node* etrue = effect;
5922 Node* catch_true;
5923 Node* then_true;
5925 Node* context = jsgraph()->HeapConstant(native_context());
5926 Node* constructor = jsgraph()->HeapConstant(
5965 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
5966 Node* efalse = effect;
5967 Node* catch_false = on_finally;
5968 Node* then_false = on_finally;
5972 Node* catch_finally =
5975 Node* then_finally =
5985 // Massage the {node} to call "then" instead by first removing all inputs
5988 Node* target =
5990 NodeProperties::ReplaceValueInput(node, target, 0);
5991 NodeProperties::ReplaceEffectInput(node, effect);
5992 NodeProperties::ReplaceControlInput(node, control);
5993 for (; arity > 2; --arity) node->RemoveInput(2);
5995 node->InsertInput(graph()->zone(), 2, then_finally);
5996 node->ReplaceInput(2, then_finally);
5997 node->ReplaceInput(3, catch_finally);
5999 node, javascript()->Call(2 + arity, p.frequency(), p.feedback(),
6002 Reduction const reduction = ReducePromisePrototypeThen(node);
6003 return reduction.Changed() ? reduction : Changed(node);
6006 Reduction JSCallReducer::ReducePromisePrototypeThen(Node* node) {
6007 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
6008 CallParameters const& p = CallParametersOf(node->op());
6013 Node* receiver = NodeProperties::GetValueInput(node, 1);
6014 Node* on_fulfilled = node->op()->ValueInputCount() > 2
6015 ? NodeProperties::GetValueInput(node, 2)
6017 Node* on_rejected = node->op()->ValueInputCount() > 3
6018 ? NodeProperties::GetValueInput(node, 3)
6020 Node* context = NodeProperties::GetContextInput(node);
6021 Node* effect = NodeProperties::GetEffectInput(node);
6022 Node* control = NodeProperties::GetControlInput(node);
6023 Node* frame_state = NodeProperties::GetFrameStateInput(node);
6080 Node* result = effect =
6087 ReplaceWithValue(node, result, effect, control);
6092 Reduction JSCallReducer::ReducePromiseResolveTrampoline(Node* node) {
6093 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
6094 Node* receiver = NodeProperties::GetValueInput(node, 1);
6095 Node* value = node->op()->ValueInputCount() > 2
6096 ? NodeProperties::GetValueInput(node, 2)
6098 Node* context = NodeProperties::GetContextInput(node);
6099 Node* frame_state = NodeProperties::GetFrameStateInput(node);
6100 Node* effect = NodeProperties::GetEffectInput(node);
6101 Node* control = NodeProperties::GetControlInput(node);
6118 // Morph the {node} into a JSPromiseResolve operation.
6119 node->ReplaceInput(0, receiver);
6120 node->ReplaceInput(1, value);
6121 node->ReplaceInput(2, context);
6122 node->ReplaceInput(3, frame_state);
6123 node->ReplaceInput(4, effect);
6124 node->ReplaceInput(5, control);
6125 node->TrimInputCount(6);
6126 NodeProperties::ChangeOp(node, javascript()->PromiseResolve());
6127 return Changed(node);
6132 Node* node, Handle<SharedFunctionInfo> shared) {
6133 DCHECK_EQ(IrOpcode::kJSConstruct, node->opcode());
6134 ConstructParameters const& p = ConstructParametersOf(node->op());
6136 Node* target = NodeProperties::GetValueInput(node, 0);
6137 Node* arg1 = (arity >= 1) ? NodeProperties::GetValueInput(node, 1)
6139 Node* arg2 = (arity >= 2) ? NodeProperties::GetValueInput(node, 2)
6141 Node* arg3 = (arity >= 3) ? NodeProperties::GetValueInput(node, 3)
6143 Node* new_target = NodeProperties::GetValueInput(node, arity + 1);
6144 Node* context = NodeProperties::GetContextInput(node);
6145 Node* frame_state = NodeProperties::GetFrameStateInput(node);
6146 Node* effect = NodeProperties::GetEffectInput(node);
6147 Node* control = NodeProperties::GetControlInput(node);
6152 node, frame_state, arity, BailoutId::ConstructStubInvoke(),
6158 Node* const parameters[] = {jsgraph()->TheHoleConstant()};
6165 Node* result =
6172 Reduction JSCallReducer::ReduceTypedArrayPrototypeToStringTag(Node* node) {
6173 Node* receiver = NodeProperties::GetValueInput(node, 1);
6174 Node* effect = NodeProperties::GetEffectInput(node);
6175 Node* control = NodeProperties::GetControlInput(node);
6181 Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), receiver);
6190 Node* receiver_map = effect =
6193 Node* receiver_bit_field2 = effect = graph()->NewNode(
6196 Node* receiver_elements_kind = graph()->NewNode(
6211 Node* check = graph()->NewNode( \
6235 Node* value =
6238 ReplaceWithValue(node, value, effect, control);
6243 Reduction JSCallReducer::ReduceNumberIsFinite(Node* node) {
6244 if (node->op()->ValueInputCount() < 3) {
6245 Node* value = jsgraph()->FalseConstant();
6246 ReplaceWithValue(node, value);
6249 Node* input = NodeProperties::GetValueInput(node, 2);
6250 Node* value = graph()->NewNode(simplified()->ObjectIsFiniteNumber(), input);
6251 ReplaceWithValue(node, value);
6256 Reduction JSCallReducer::ReduceNumberIsInteger(Node* node) {
6257 if (node->op()->ValueInputCount() < 3) {
6258 Node* value = jsgraph()->FalseConstant();
6259 ReplaceWithValue(node, value);
6262 Node* input = NodeProperties::GetValueInput(node, 2);
6263 Node* value = graph()->NewNode(simplified()->ObjectIsInteger(), input);
6264 ReplaceWithValue(node, value);
6269 Reduction JSCallReducer::ReduceNumberIsSafeInteger(Node* node) {
6270 if (node->op()->ValueInputCount() < 3) {
6271 Node* value = jsgraph()->FalseConstant();
6272 ReplaceWithValue(node, value);
6275 Node* input = NodeProperties::GetValueInput(node, 2);
6276 Node* value = graph()->NewNode(simplified()->ObjectIsSafeInteger(), input);
6277 ReplaceWithValue(node, value);
6282 Reduction JSCallReducer::ReduceNumberIsNaN(Node* node) {
6283 if (node->op()->ValueInputCount() < 3) {
6284 Node* value = jsgraph()->FalseConstant();
6285 ReplaceWithValue(node, value);
6288 Node* input = NodeProperties::GetValueInput(node, 2);
6289 Node* value = graph()->NewNode(simplified()->ObjectIsNaN(), input);
6290 ReplaceWithValue(node, value);
6294 Reduction JSCallReducer::ReduceMapPrototypeGet(Node* node) {
6296 if (node->op()->ValueInputCount() != 3) return NoChange();
6297 Node* receiver = NodeProperties::GetValueInput(node, 1);
6298 Node* effect = NodeProperties::GetEffectInput(node);
6299 Node* control = NodeProperties::GetControlInput(node);
6300 Node* key = NodeProperties::GetValueInput(node, 2);
6306 Node* table = effect = graph()->NewNode(
6310 Node* entry = effect = graph()->NewNode(
6313 Node* check = graph()->NewNode(simplified()->NumberEqual(), entry,
6316 Node* branch = graph()->NewNode(common()->Branch(), check, control);
6319 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
6320 Node* etrue = effect;
6321 Node* vtrue = jsgraph()->UndefinedConstant();
6324 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
6325 Node* efalse = effect;
6326 Node* vfalse = efalse = graph()->NewNode(
6331 Node* value = graph()->NewNode(
6335 ReplaceWithValue(node, value, effect, control);
6339 Reduction JSCallReducer::ReduceMapPrototypeHas(Node* node) {
6341 if (node->op()->ValueInputCount() != 3) return NoChange();
6342 Node* receiver = NodeProperties::GetValueInput(node, 1);
6343 Node* effect = NodeProperties::GetEffectInput(node);
6344 Node* control = NodeProperties::GetControlInput(node);
6345 Node* key = NodeProperties::GetValueInput(node, 2);
6351 Node* table = effect = graph()->NewNode(
6355 Node* index = effect = graph()->NewNode(
6358 Node* value = graph()->NewNode(simplified()->NumberEqual(), index,
6362 ReplaceWithValue(node, value, effect, control);
6381 Node* node, CollectionKind collection_kind, IterationKind iteration_kind) {
6382 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
6383 Node* receiver = NodeProperties::GetValueInput(node, 1);
6384 Node* context = NodeProperties::GetContextInput(node);
6385 Node* effect = NodeProperties::GetEffectInput(node);
6386 Node* control = NodeProperties::GetControlInput(node);
6390 Node* js_create_iterator = effect = graph()->NewNode(
6393 ReplaceWithValue(node, js_create_iterator, effect);
6400 Node* node, CollectionKind collection_kind) {
6401 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
6402 Node* receiver = NodeProperties::GetValueInput(node, 1);
6403 Node* effect = NodeProperties::GetEffectInput(node);
6404 Node* control = NodeProperties::GetControlInput(node);
6408 Node* table = effect = graph()->NewNode(
6411 Node* value = effect = graph()->NewNode(
6415 ReplaceWithValue(node, value, effect, control);
6422 Node* node, int entry_size, Handle<HeapObject> empty_collection,
6425 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
6426 Node* receiver = NodeProperties::GetValueInput(node, 1);
6427 Node* context = NodeProperties::GetContextInput(node);
6428 Node* effect = NodeProperties::GetEffectInput(node);
6429 Node* control = NodeProperties::GetControlInput(node);
6465 Node* done_loop;
6466 Node* done_eloop;
6467 Node* loop = control =
6469 Node* eloop = effect =
6471 Node* terminate = graph()->NewNode(common()->Terminate(), eloop, loop);
6475 Node* table = effect = graph()->NewNode(
6478 Node* next_table = effect =
6482 Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), next_table);
6494 Node* index = effect = graph()->NewNode(
6528 Node* index = effect = graph()->NewNode(
6531 Node* table = effect = graph()->NewNode(
6536 // a dominating Allocate node for the allocation folding phase.
6537 Node* iterator_result = effect = graph()->NewNode(
6542 Node* controls[2];
6543 Node* effects[3];
6546 Node* number_of_buckets = effect = graph()->NewNode(
6550 Node* number_of_elements = effect = graph()->NewNode(
6554 Node* number_of_deleted_elements = effect = graph()->NewNode(
6558 Node* used_capacity =
6563 Node* loop = graph()->NewNode(common()->Loop(2), control, control);
6564 Node* eloop =
6566 Node* terminate = graph()->NewNode(common()->Terminate(), eloop, loop);
6568 Node* iloop = graph()->NewNode(
6571 Node* index = effect = graph()->NewNode(
6575 Node* check0 = graph()->NewNode(simplified()->NumberLessThan(), index,
6577 Node* branch0 =
6580 Node* if_false0 = graph()->NewNode(common()->IfFalse(), branch0);
6581 Node* efalse0 = effect;
6594 Node* if_true0 = graph()->NewNode(common()->IfTrue(), branch0);
6595 Node* etrue0 = effect;
6598 Node* entry_start_position = graph()->NewNode(
6606 Node* entry_key = etrue0 = graph()->NewNode(
6614 Node* check1 =
6617 Node* branch1 = graph()->NewNode(common()->Branch(BranchHint::kFalse),
6622 Node* control = graph()->NewNode(common()->IfFalse(), branch1);
6623 Node* effect = etrue0;
6624 Node* value = effect =
6627 Node* done = jsgraph()->FalseConstant();
6703 ReplaceWithValue(node, iterator_result, effect, control);
6707 Reduction JSCallReducer::ReduceArrayBufferIsView(Node* node) {
6708 Node* value = node->op()->ValueInputCount() >= 3
6709 ? NodeProperties::GetValueInput(node, 2)
6711 RelaxEffectsAndControls(node);
6712 node->ReplaceInput(0, value);
6713 node->TrimInputCount(1);
6714 NodeProperties::ChangeOp(node, simplified()->ObjectIsArrayBufferView());
6715 return Changed(node);
6719 Node* node, InstanceType instance_type, FieldAccess const& access) {
6720 Node* receiver = NodeProperties::GetValueInput(node, 1);
6721 Node* effect = NodeProperties::GetEffectInput(node);
6722 Node* control = NodeProperties::GetControlInput(node);
6726 Node* value = effect = graph()->NewNode(simplified()->LoadField(access),
6737 Node* buffer = effect = graph()->NewNode(
6740 Node* check = effect = graph()->NewNode(
6749 ReplaceWithValue(node, value, effect, control);
6771 Node* node, ExternalArrayType element_type) {
6773 CallParameters const& p = CallParametersOf(node->op());
6774 Node* effect = NodeProperties::GetEffectInput(node);
6775 Node* control = NodeProperties::GetControlInput(node);
6776 Node* receiver = NodeProperties::GetValueInput(node, 1);
6782 Node* offset = node->op()->ValueInputCount() > 2
6783 ? NodeProperties::GetValueInput(node, 2)
6786 Node* is_little_endian = node->op()->ValueInputCount() > 3
6787 ? NodeProperties::GetValueInput(node, 3)
6810 Node* byte_length = jsgraph()->Constant(
6817 Node* byte_offset =
6822 Node* byte_length = effect =
6837 Node* end_offset =
6845 Node* byte_offset = effect =
6861 Node* buffer = effect = graph()->NewNode(
6872 Node* check_neutered = effect = graph()->NewNode(
6883 Node* backing_store = effect = graph()->NewNode(
6888 Node* value = effect = graph()->NewNode(
6893 ReplaceWithValue(node, value, effect, control);
6901 Node* node, ExternalArrayType element_type) {
6903 CallParameters const& p = CallParametersOf(node->op());
6904 Node* effect = NodeProperties::GetEffectInput(node);
6905 Node* control = NodeProperties::GetControlInput(node);
6906 Node* receiver = NodeProperties::GetValueInput(node, 1);
6912 Node* offset = node->op()->ValueInputCount() > 2
6913 ? NodeProperties::GetValueInput(node, 2)
6916 Node* value = node->op()->ValueInputCount() > 3
6917 ? NodeProperties::GetValueInput(node, 3)
6920 Node* is_little_endian = node->op()->ValueInputCount() > 4
6921 ? NodeProperties::GetValueInput(node, 4)
6944 Node* byte_length = jsgraph()->Constant(
6951 Node* byte_offset =
6956 Node* byte_length = effect =
6971 Node* end_offset =
6979 Node* byte_offset = effect =
7001 Node* buffer = effect = graph()->NewNode(
7012 Node* check_neutered = effect = graph()->NewNode(
7023 Node* backing_store = effect = graph()->NewNode(
7032 Node* value = jsgraph()->UndefinedConstant();
7035 ReplaceWithValue(node, value, effect, control);
7043 Reduction JSCallReducer::ReduceGlobalIsFinite(Node* node) {
7044 CallParameters const& p = CallParametersOf(node->op());
7048 if (node->op()->ValueInputCount() < 3) {
7049 Node* value = jsgraph()->FalseConstant();
7050 ReplaceWithValue(node, value);
7054 Node* effect = NodeProperties::GetEffectInput(node);
7055 Node* control = NodeProperties::GetControlInput(node);
7056 Node* input = NodeProperties::GetValueInput(node, 2);
7062 Node* value = graph()->NewNode(simplified()->NumberIsFinite(), input);
7063 ReplaceWithValue(node, value, effect);
7068 Reduction JSCallReducer::ReduceGlobalIsNaN(Node* node) {
7069 CallParameters const& p = CallParametersOf(node->op());
7073 if (node->op()->ValueInputCount() < 3) {
7074 Node* value = jsgraph()->TrueConstant();
7075 ReplaceWithValue(node, value);
7079 Node* effect = NodeProperties::GetEffectInput(node);
7080 Node* control = NodeProperties::GetControlInput(node);
7081 Node* input = NodeProperties::GetValueInput(node, 2);
7087 Node* value = graph()->NewNode(simplified()->NumberIsNaN(), input);
7088 ReplaceWithValue(node, value, effect);
7093 Reduction JSCallReducer::ReduceDatePrototypeGetTime(Node* node) {
7094 Node* receiver = NodeProperties::GetValueInput(node, 1);
7095 Node* effect = NodeProperties::GetEffectInput(node);
7096 Node* control = NodeProperties::GetControlInput(node);
7099 Node* value = effect = graph()->NewNode(
7102 ReplaceWithValue(node, value, effect, control);
7109 Reduction JSCallReducer::ReduceDateNow(Node* node) {
7110 Node* effect = NodeProperties::GetEffectInput(node);
7111 Node* control = NodeProperties::GetControlInput(node);
7112 Node* value = effect =
7114 ReplaceWithValue(node, value, effect, control);
7119 Reduction JSCallReducer::ReduceNumberParseInt(Node* node) {
7121 if (node->op()->ValueInputCount() < 3) {
7122 Node* value = jsgraph()->NaNConstant();
7123 ReplaceWithValue(node, value);
7127 int arg_count = node->op()->ValueInputCount();
7128 Node* effect = NodeProperties::GetEffectInput(node);
7129 Node* control = NodeProperties::GetControlInput(node);
7130 Node* context = NodeProperties::GetContextInput(node);
7131 Node* frame_state = NodeProperties::GetFrameStateInput(node);
7132 Node* object = NodeProperties::GetValueInput(node, 2);
7133 Node* radix = arg_count >= 4 ? NodeProperties::GetValueInput(node, 3)
7135 node->ReplaceInput(0, object);
7136 node->ReplaceInput(1, radix);
7137 node->ReplaceInput(2, context);
7138 node->ReplaceInput(3, frame_state);
7139 node->ReplaceInput(4, effect);
7140 node->ReplaceInput(5, control);
7141 node->TrimInputCount(6);
7142 NodeProperties::ChangeOp(node, javascript()->ParseInt());
7143 return Changed(node);
7146 Reduction JSCallReducer::ReduceRegExpPrototypeTest(Node* node) {
7148 if (node->op()->ValueInputCount() < 3) return NoChange();
7149 CallParameters const& p = CallParametersOf(node->op());
7154 Node* effect = NodeProperties::GetEffectInput(node);
7155 Node* control = NodeProperties::GetControlInput(node);
7156 Node* regexp = NodeProperties::GetValueInput(node, 1);
7210 Node* context = NodeProperties::GetContextInput(node);
7211 Node* frame_state = NodeProperties::GetFrameStateInput(node);
7212 Node* search = NodeProperties::GetValueInput(node, 2);
7213 Node* search_string = effect = graph()->NewNode(
7216 Node* lastIndex = effect = graph()->NewNode(
7220 Node* lastIndexSmi = effect = graph()->NewNode(
7223 Node* is_positive = graph()->NewNode(simplified()->NumberLessThanOrEqual(),
7230 node->ReplaceInput(0, regexp);
7231 node->ReplaceInput(1, search_string);
7232 node->ReplaceInput(2, context);
7233 node->ReplaceInput(3, frame_state);
7234 node->ReplaceInput(4, effect);
7235 node->ReplaceInput(5, control);
7236 node->TrimInputCount(6);
7237 NodeProperties::ChangeOp(node, javascript()->RegExpTest());
7238 return Changed(node);
7242 Reduction JSCallReducer::ReduceNumberConstructor(Node* node) {
7243 DCHECK_EQ(IrOpcode::kJSCall, node->opcode());
7244 CallParameters const& p = CallParametersOf(node->op());
7247 ReplaceWithValue(node, jsgraph()->ZeroConstant());
7253 Node* target = NodeProperties::GetValueInput(node, 0);
7254 Node* context = NodeProperties::GetContextInput(node);
7255 Node* value = NodeProperties::GetValueInput(node, 2);
7256 Node* outer_frame_state = NodeProperties::GetFrameStateInput(node);
7260 const std::vector<Node*> checkpoint_parameters({
7266 Node* frame_state = CreateJavaScriptBuiltinContinuationFrameState(
7272 NodeProperties::ReplaceValueInputs(node, value);
7273 NodeProperties::ChangeOp(node, javascript()->ToNumberConvertBigInt());
7274 NodeProperties::ReplaceFrameStateInput(node, frame_state);
7275 return Changed(node);