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/code-factory.h" | 9 #include "src/code-factory.h" |
10 #include "src/compiler/access-builder.h" | 10 #include "src/compiler/access-builder.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 case Runtime::kInlineStringGetLength: | 76 case Runtime::kInlineStringGetLength: |
77 return ReduceStringGetLength(node); | 77 return ReduceStringGetLength(node); |
78 case Runtime::kInlineValueOf: | 78 case Runtime::kInlineValueOf: |
79 return ReduceValueOf(node); | 79 return ReduceValueOf(node); |
80 case Runtime::kInlineIsMinusZero: | 80 case Runtime::kInlineIsMinusZero: |
81 return ReduceIsMinusZero(node); | 81 return ReduceIsMinusZero(node); |
82 case Runtime::kInlineFixedArrayGet: | 82 case Runtime::kInlineFixedArrayGet: |
83 return ReduceFixedArrayGet(node); | 83 return ReduceFixedArrayGet(node); |
84 case Runtime::kInlineFixedArraySet: | 84 case Runtime::kInlineFixedArraySet: |
85 return ReduceFixedArraySet(node); | 85 return ReduceFixedArraySet(node); |
86 case Runtime::kInlineGetTypeFeedbackVector: | |
87 return ReduceGetTypeFeedbackVector(node); | |
88 case Runtime::kInlineGetCallerJSFunction: | |
89 return ReduceGetCallerJSFunction(node); | |
90 case Runtime::kInlineToInteger: | 86 case Runtime::kInlineToInteger: |
91 return ReduceToInteger(node); | 87 return ReduceToInteger(node); |
92 case Runtime::kInlineToLength: | 88 case Runtime::kInlineToLength: |
93 return ReduceToLength(node); | 89 return ReduceToLength(node); |
94 case Runtime::kInlineToName: | 90 case Runtime::kInlineToName: |
95 return ReduceToName(node); | 91 return ReduceToName(node); |
96 case Runtime::kInlineToNumber: | 92 case Runtime::kInlineToNumber: |
97 return ReduceToNumber(node); | 93 return ReduceToNumber(node); |
98 case Runtime::kInlineToObject: | 94 case Runtime::kInlineToObject: |
99 return ReduceToObject(node); | 95 return ReduceToObject(node); |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 Node* effect = NodeProperties::GetEffectInput(node); | 448 Node* effect = NodeProperties::GetEffectInput(node); |
453 Node* control = NodeProperties::GetControlInput(node); | 449 Node* control = NodeProperties::GetControlInput(node); |
454 Node* store = (graph()->NewNode( | 450 Node* store = (graph()->NewNode( |
455 simplified()->StoreElement(AccessBuilder::ForFixedArrayElement()), base, | 451 simplified()->StoreElement(AccessBuilder::ForFixedArrayElement()), base, |
456 index, value, effect, control)); | 452 index, value, effect, control)); |
457 ReplaceWithValue(node, value, store); | 453 ReplaceWithValue(node, value, store); |
458 return Changed(store); | 454 return Changed(store); |
459 } | 455 } |
460 | 456 |
461 | 457 |
462 Reduction JSIntrinsicLowering::ReduceGetTypeFeedbackVector(Node* node) { | |
463 Node* func = node->InputAt(0); | |
464 Node* effect = NodeProperties::GetEffectInput(node); | |
465 Node* control = NodeProperties::GetControlInput(node); | |
466 FieldAccess access = AccessBuilder::ForJSFunctionSharedFunctionInfo(); | |
467 Node* load = | |
468 graph()->NewNode(simplified()->LoadField(access), func, effect, control); | |
469 access = AccessBuilder::ForSharedFunctionInfoTypeFeedbackVector(); | |
470 return Change(node, simplified()->LoadField(access), load, load, control); | |
471 } | |
472 | |
473 | |
474 Reduction JSIntrinsicLowering::ReduceGetCallerJSFunction(Node* node) { | |
475 Node* effect = NodeProperties::GetEffectInput(node); | |
476 Node* control = NodeProperties::GetControlInput(node); | |
477 | |
478 Node* const frame_state = NodeProperties::GetFrameStateInput(node, 0); | |
479 Node* outer_frame = frame_state->InputAt(kFrameStateOuterStateInput); | |
480 if (outer_frame->opcode() == IrOpcode::kFrameState) { | |
481 // Use the runtime implementation to throw the appropriate error if the | |
482 // containing function is inlined. | |
483 return NoChange(); | |
484 } | |
485 | |
486 // TODO(danno): This implementation forces intrinsic lowering to happen after | |
487 // inlining, which is fine for now, but eventually the frame-querying logic | |
488 // probably should go later, e.g. in instruction selection, so that there is | |
489 // no phase-ordering dependency. | |
490 FieldAccess access = AccessBuilder::ForFrameCallerFramePtr(); | |
491 Node* fp = graph()->NewNode(machine()->LoadFramePointer()); | |
492 Node* next_fp = | |
493 graph()->NewNode(simplified()->LoadField(access), fp, effect, control); | |
494 return Change(node, simplified()->LoadField(AccessBuilder::ForFrameMarker()), | |
495 next_fp, effect, control); | |
496 } | |
497 | |
498 | |
499 Reduction JSIntrinsicLowering::ReduceThrowNotDateError(Node* node) { | 458 Reduction JSIntrinsicLowering::ReduceThrowNotDateError(Node* node) { |
500 if (mode() != kDeoptimizationEnabled) return NoChange(); | 459 if (mode() != kDeoptimizationEnabled) return NoChange(); |
501 Node* const frame_state = NodeProperties::GetFrameStateInput(node, 1); | 460 Node* const frame_state = NodeProperties::GetFrameStateInput(node, 1); |
502 Node* const effect = NodeProperties::GetEffectInput(node); | 461 Node* const effect = NodeProperties::GetEffectInput(node); |
503 Node* const control = NodeProperties::GetControlInput(node); | 462 Node* const control = NodeProperties::GetControlInput(node); |
504 | 463 |
505 // TODO(bmeurer): Move MergeControlToEnd() to the AdvancedReducer. | 464 // TODO(bmeurer): Move MergeControlToEnd() to the AdvancedReducer. |
506 Node* deoptimize = | 465 Node* deoptimize = |
507 graph()->NewNode(common()->Deoptimize(), frame_state, effect, control); | 466 graph()->NewNode(common()->Deoptimize(), frame_state, effect, control); |
508 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize); | 467 NodeProperties::MergeControlToEnd(graph(), common(), deoptimize); |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
684 } | 643 } |
685 | 644 |
686 | 645 |
687 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const { | 646 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const { |
688 return jsgraph()->simplified(); | 647 return jsgraph()->simplified(); |
689 } | 648 } |
690 | 649 |
691 } // namespace compiler | 650 } // namespace compiler |
692 } // namespace internal | 651 } // namespace internal |
693 } // namespace v8 | 652 } // namespace v8 |
OLD | NEW |