Home | History | Annotate | Download | only in compiler

Lines Matching refs:node

8 #include "src/compiler/node-matchers.h"
40 Reduction JSCallReducer::Reduce(Node* node) {
41 switch (node->opcode()) {
43 return ReduceJSCallConstruct(node);
45 return ReduceJSCallFunction(node);
54 Reduction JSCallReducer::ReduceArrayConstructor(Node* node) {
55 DCHECK_EQ(IrOpcode::kJSCallFunction, node->opcode());
56 Node* target = NodeProperties::GetValueInput(node, 0);
57 CallFunctionParameters const& p = CallFunctionParametersOf(node->op());
69 // Turn the {node} into a {JSCreateArray} call.
72 NodeProperties::ReplaceValueInput(node, target, 0);
73 NodeProperties::ReplaceValueInput(node, target, 1);
77 NodeProperties::ChangeOp(node, javascript()->CreateArray(arity, site));
78 return Changed(node);
83 Reduction JSCallReducer::ReduceNumberConstructor(Node* node) {
84 DCHECK_EQ(IrOpcode::kJSCallFunction, node->opcode());
85 CallFunctionParameters const& p = CallFunctionParametersOf(node->op());
87 // Turn the {node} into a {JSToNumber} call.
89 Node* value = (p.arity() == 2) ? jsgraph()->ZeroConstant()
90 : NodeProperties::GetValueInput(node, 2);
91 NodeProperties::ReplaceValueInputs(node, value);
92 NodeProperties::ChangeOp(node, javascript()->ToNumber());
93 return Changed(node);
98 Reduction JSCallReducer::ReduceFunctionPrototypeApply(Node* node) {
99 DCHECK_EQ(IrOpcode::kJSCallFunction, node->opcode());
100 Node* target = NodeProperties::GetValueInput(node, 0);
101 CallFunctionParameters const& p = CallFunctionParametersOf(node->op());
110 node->ReplaceInput(0, node->InputAt(1));
111 node->ReplaceInput(1, jsgraph()->UndefinedConstant());
114 node->RemoveInput(0);
117 // Check if argArray is an arguments object, and {node} is the only value
119 Node* arg_array = NodeProperties::GetValueInput(node, 3);
124 if (edge.from() == node) continue;
128 // we can only optimize this in case the {node} was already inlined into
131 Node* frame_state = NodeProperties::GetFrameStateInput(arg_array, 0);
132 Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
151 // Remove the argArray input from the {node}.
152 node->RemoveInput(static_cast<int>(--arity));
153 // Add the actual parameters to the {node}, skipping the receiver.
154 Node* const parameters = frame_state->InputAt(kFrameStateParametersInput);
156 node->InsertInput(graph()->zone(), static_cast<int>(arity),
160 // Drop the {target} from the {node}.
161 node->RemoveInput(0);
166 // Change {node} to the new {JSCallFunction} operator.
168 node, javascript()->CallFunction(arity, CallCountFeedback(p.feedback()),
170 // Change context of {node} to the Function.prototype.apply context,
173 node, jsgraph()->HeapConstant(handle(apply->context(), isolate())));
174 // Try to further reduce the JSCallFunction {node}.
175 Reduction const reduction = ReduceJSCallFunction(node);
176 return reduction.Changed() ? reduction : Changed(node);
181 Reduction JSCallReducer::ReduceFunctionPrototypeCall(Node* node) {
182 DCHECK_EQ(IrOpcode::kJSCallFunction, node->opcode());
183 CallFunctionParameters const& p = CallFunctionParametersOf(node->op());
185 HeapObjectMatcher(NodeProperties::GetValueInput(node, 0)).Value());
186 // Change context of {node} to the Function.prototype.call context,
189 node, jsgraph()->HeapConstant(handle(call->context(), isolate())));
190 // Remove the target from {node} and use the receiver as target instead, and
199 node->ReplaceInput(0, node->InputAt(1));
200 node->ReplaceInput(1, jsgraph()->UndefinedConstant());
204 node->RemoveInput(0);
208 node, javascript()->CallFunction(arity, CallCountFeedback(p.feedback()),
210 // Try to further reduce the JSCallFunction {node}.
211 Reduction const reduction = ReduceJSCallFunction(node);
212 return reduction.Changed() ? reduction : Changed(node);
216 Reduction JSCallReducer::ReduceJSCallFunction(Node* node) {
217 DCHECK_EQ(IrOpcode::kJSCallFunction, node->opcode());
218 CallFunctionParameters const& p = CallFunctionParametersOf(node->op());
219 Node* target = NodeProperties::GetValueInput(node, 0);
220 Node* context = NodeProperties::GetContextInput(node);
221 Node* control = NodeProperties::GetControlInput(node);
222 Node* effect = NodeProperties::GetEffectInput(node);
223 Node* frame_state = NodeProperties::FindFrameStateBefore(node);
225 // Try to specialize JSCallFunction {node}s with constant {target}s.
234 NodeProperties::ReplaceValueInputs(node, target);
236 node, javascript()->CallRuntime(
238 return Changed(node);
245 return ReduceFunctionPrototypeApply(node);
247 return ReduceFunctionPrototypeCall(node);
255 return ReduceArrayConstructor(node);
260 return ReduceNumberConstructor(node);
270 CallFunctionParameters const& p = CallFunctionParametersOf(node->op());
277 // Patch {node} to use [[BoundTargetFunction]] and [[BoundThis]].
279 node, jsgraph()->Constant(bound_target_function), 0);
280 NodeProperties::ReplaceValueInput(node, jsgraph()->Constant(bound_this),
282 // Insert the [[BoundArguments]] for {node}.
284 node->InsertInput(
289 NodeProperties::ChangeOp(node, javascript()->CallFunction(
292 // Try to further reduce the JSCallFunction {node}.
293 Reduction const reduction = ReduceJSCallFunction(node);
294 return reduction.Changed() ? reduction : Changed(node);
297 // Don't mess with other {node}s that have a constant {target}.
305 // Extract feedback from the {node} using the CallICNexus.
310 // Retrieve the Array function from the {node}.
311 Node* array_function;
313 if (GetNativeContext(node).ToHandle(&native_context)) {
317 Node* native_context = effect = graph()->NewNode(
326 Node* check = graph()->NewNode(
332 // Turn the {node} into a {JSCreateArray} call.
333 NodeProperties::ReplaceValueInput(node, array_function, 0);
334 NodeProperties::ReplaceEffectInput(node, effect);
335 NodeProperties::ReplaceControlInput(node, control);
336 return ReduceArrayConstructor(node);
340 Node* target_function =
344 Node* check = graph()->NewNode(
350 // Specialize the JSCallFunction node to the {target_function}.
351 NodeProperties::ReplaceValueInput(node, target_function, 0);
352 NodeProperties::ReplaceEffectInput(node, effect);
353 NodeProperties::ReplaceControlInput(node, control);
355 // Try to further reduce the JSCallFunction {node}.
356 Reduction const reduction = ReduceJSCallFunction(node);
357 return reduction.Changed() ? reduction : Changed(node);
364 Reduction JSCallReducer::ReduceJSCallConstruct(Node* node) {
365 DCHECK_EQ(IrOpcode::kJSCallConstruct, node->opcode());
366 CallConstructParameters const& p = CallConstructParametersOf(node->op());
369 Node* target = NodeProperties::GetValueInput(node, 0);
370 Node* new_target = NodeProperties::GetValueInput(node, arity + 1);
371 Node* context = NodeProperties::GetContextInput(node);
372 Node* effect = NodeProperties::GetEffectInput(node);
373 Node* control = NodeProperties::GetControlInput(node);
374 Node* frame_state = NodeProperties::FindFrameStateBefore(node);
376 // Try to specialize JSCallConstruct {node}s with constant {target}s.
384 NodeProperties::ReplaceValueInputs(node, target);
386 node, javascript()->CallRuntime(Runtime::kThrowCalledNonCallable));
387 return Changed(node);
402 // Turn the {node} into a {JSCreateArray} call.
405 node, NodeProperties::GetValueInput(node, i), i + 1);
407 NodeProperties::ReplaceValueInput(node, new_target, 1);
408 NodeProperties::ChangeOp(node, javascript()->CreateArray(arity, site));
409 return Changed(node);
413 // Don't mess with other {node}s that have a constant {target}.
432 // Retrieve the Array function from the {node}.
433 Node* array_function;
435 if (GetNativeContext(node).ToHandle(&native_context)) {
439 Node* native_context = effect = graph()->NewNode(
448 Node* check = graph()->NewNode(
454 // Turn the {node} into a {JSCreateArray} call.
455 NodeProperties::ReplaceEffectInput(node, effect);
456 NodeProperties::ReplaceControlInput(node, control);
459 node, NodeProperties::GetValueInput(node, i), i + 1);
461 NodeProperties::ReplaceValueInput(node, new_target, 1);
462 NodeProperties::ChangeOp(node, javascript()->CreateArray(arity, site));
463 return Changed(node);
467 Node* target_function =
471 Node* check = graph()->NewNode(
477 // Specialize the JSCallConstruct node to the {target_function}.
478 NodeProperties::ReplaceValueInput(node, target_function, 0);
479 NodeProperties::ReplaceEffectInput(node, effect);
480 NodeProperties::ReplaceControlInput(node, control);
482 NodeProperties::ReplaceValueInput(node, target_function, arity + 1);
485 // Try to further reduce the JSCallConstruct {node}.
486 Reduction const reduction = ReduceJSCallConstruct(node);
487 return reduction.Changed() ? reduction : Changed(node);
495 MaybeHandle<Context> JSCallReducer::GetNativeContext(Node* node) {
496 Node* const context = NodeProperties::GetContextInput(node);