OLD | NEW |
---|---|
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/js-intrinsic-lowering.h" | 5 #include "src/compiler/js-intrinsic-lowering.h" |
6 | 6 |
7 #include <stack> | 7 #include <stack> |
8 | 8 |
9 #include "src/compiler/access-builder.h" | 9 #include "src/compiler/access-builder.h" |
10 #include "src/compiler/js-graph.h" | 10 #include "src/compiler/js-graph.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
77 case Runtime::kInlineUnlikely: | 77 case Runtime::kInlineUnlikely: |
78 return ReduceUnLikely(node, BranchHint::kFalse); | 78 return ReduceUnLikely(node, BranchHint::kFalse); |
79 case Runtime::kInlineValueOf: | 79 case Runtime::kInlineValueOf: |
80 return ReduceValueOf(node); | 80 return ReduceValueOf(node); |
81 case Runtime::kInlineIsMinusZero: | 81 case Runtime::kInlineIsMinusZero: |
82 return ReduceIsMinusZero(node); | 82 return ReduceIsMinusZero(node); |
83 case Runtime::kInlineFixedArraySet: | 83 case Runtime::kInlineFixedArraySet: |
84 return ReduceFixedArraySet(node); | 84 return ReduceFixedArraySet(node); |
85 case Runtime::kInlineGetTypeFeedbackVector: | 85 case Runtime::kInlineGetTypeFeedbackVector: |
86 return ReduceGetTypeFeedbackVector(node); | 86 return ReduceGetTypeFeedbackVector(node); |
87 case Runtime::kInlineGetCallerJSFunction: | |
88 return ReduceGetCallerJSFunction(node); | |
87 default: | 89 default: |
88 break; | 90 break; |
89 } | 91 } |
90 return NoChange(); | 92 return NoChange(); |
91 } | 93 } |
92 | 94 |
93 | 95 |
94 Reduction JSIntrinsicLowering::ReduceConstructDouble(Node* node) { | 96 Reduction JSIntrinsicLowering::ReduceConstructDouble(Node* node) { |
95 Node* high = NodeProperties::GetValueInput(node, 0); | 97 Node* high = NodeProperties::GetValueInput(node, 0); |
96 Node* low = NodeProperties::GetValueInput(node, 1); | 98 Node* low = NodeProperties::GetValueInput(node, 1); |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
448 Node* effect = NodeProperties::GetEffectInput(node); | 450 Node* effect = NodeProperties::GetEffectInput(node); |
449 Node* control = NodeProperties::GetControlInput(node); | 451 Node* control = NodeProperties::GetControlInput(node); |
450 FieldAccess access = AccessBuilder::ForJSFunctionSharedFunctionInfo(); | 452 FieldAccess access = AccessBuilder::ForJSFunctionSharedFunctionInfo(); |
451 Node* load = | 453 Node* load = |
452 graph()->NewNode(simplified()->LoadField(access), func, effect, control); | 454 graph()->NewNode(simplified()->LoadField(access), func, effect, control); |
453 access = AccessBuilder::ForSharedFunctionInfoTypeFeedbackVector(); | 455 access = AccessBuilder::ForSharedFunctionInfoTypeFeedbackVector(); |
454 return Change(node, simplified()->LoadField(access), load, load, control); | 456 return Change(node, simplified()->LoadField(access), load, load, control); |
455 } | 457 } |
456 | 458 |
457 | 459 |
460 Reduction JSIntrinsicLowering::ReduceGetCallerJSFunction(Node* node) { | |
461 Node* effect = NodeProperties::GetEffectInput(node); | |
462 Node* control = NodeProperties::GetControlInput(node); | |
463 | |
464 if (FLAG_turbo_deoptimization) { | |
465 Node* const frame_state = NodeProperties::GetFrameStateInput(node, 0); | |
466 Node* const outer_frame = frame_state->InputAt(kFrameStateOuterStateInput); | |
467 if (outer_frame->opcode() == IrOpcode::kFrameState) { | |
468 // The intrinsic is inlined, return the function from the outer frame. | |
469 Node* outer_function = outer_frame->InputAt(kFrameStateFunctionInput); | |
470 NodeProperties::ReplaceWithValue(node, outer_frame, effect, control); | |
Michael Starzinger
2015/05/20 14:25:18
nit: Please use AdvancedReducer::ReplaceWithValue
danno
2015/05/22 11:21:35
Done.
| |
471 return Changed(outer_function); | |
472 } | |
473 } | |
474 | |
475 // TODO(danno): If FLAG_turbo_deoptimization is false then this intrinsic | |
476 // always returns the JSFunction from the caller's frame, regardless of | |
477 // inlining depth, which isn't correct. This implementation also forces | |
478 // intrinsic lowering to happen after inlining, which is fine for now, but | |
479 // eventually the frame-querying logic probably should go later, e.g. in | |
480 // instruction selection, so that there is no phase-ordering dependency. | |
481 FieldAccess access = AccessBuilder::ForFrameCallerFramePtr(); | |
482 Node* fp = graph()->NewNode(machine()->LoadFramePointer()); | |
483 Node* next_fp = | |
484 graph()->NewNode(simplified()->LoadField(access), fp, effect, control); | |
485 | |
486 access = AccessBuilder::ForFrameMarker(); | |
Michael Starzinger
2015/05/20 14:25:18
Does this work with arguments adapter frames and c
danno
2015/05/22 11:21:35
Now it does :-)
| |
487 return Change(node, simplified()->LoadField(access), next_fp, effect, | |
488 control); | |
489 } | |
490 | |
491 | |
458 Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op, Node* a, | 492 Reduction JSIntrinsicLowering::Change(Node* node, const Operator* op, Node* a, |
459 Node* b) { | 493 Node* b) { |
460 node->set_op(op); | 494 node->set_op(op); |
461 node->ReplaceInput(0, a); | 495 node->ReplaceInput(0, a); |
462 node->ReplaceInput(1, b); | 496 node->ReplaceInput(1, b); |
463 node->TrimInputCount(2); | 497 node->TrimInputCount(2); |
464 RelaxControls(node); | 498 RelaxControls(node); |
465 return Changed(node); | 499 return Changed(node); |
466 } | 500 } |
467 | 501 |
(...skipping 24 matching lines...) Expand all Loading... | |
492 } | 526 } |
493 | 527 |
494 | 528 |
495 MachineOperatorBuilder* JSIntrinsicLowering::machine() const { | 529 MachineOperatorBuilder* JSIntrinsicLowering::machine() const { |
496 return jsgraph()->machine(); | 530 return jsgraph()->machine(); |
497 } | 531 } |
498 | 532 |
499 } // namespace compiler | 533 } // namespace compiler |
500 } // namespace internal | 534 } // namespace internal |
501 } // namespace v8 | 535 } // namespace v8 |
OLD | NEW |