OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "src/compiler/js-frame-specialization.h" |
| 6 |
| 7 #include "src/compiler/js-graph.h" |
| 8 #include "src/compiler/linkage.h" |
| 9 #include "src/frames-inl.h" |
| 10 |
| 11 namespace v8 { |
| 12 namespace internal { |
| 13 namespace compiler { |
| 14 |
| 15 Reduction JSFrameSpecialization::Reduce(Node* node) { |
| 16 switch (node->opcode()) { |
| 17 case IrOpcode::kOsrValue: |
| 18 return ReduceOsrValue(node); |
| 19 case IrOpcode::kParameter: |
| 20 return ReduceParameter(node); |
| 21 default: |
| 22 break; |
| 23 } |
| 24 return NoChange(); |
| 25 } |
| 26 |
| 27 |
| 28 Reduction JSFrameSpecialization::ReduceOsrValue(Node* node) { |
| 29 DCHECK_EQ(IrOpcode::kOsrValue, node->opcode()); |
| 30 DisallowHeapAllocation no_gc; |
| 31 Object* object; |
| 32 int const index = OpParameter<int>(node); |
| 33 int const parameters_count = frame()->ComputeParametersCount() + 1; |
| 34 if (index == Linkage::kOsrContextSpillSlotIndex) { |
| 35 object = frame()->context(); |
| 36 } else if (index >= parameters_count) { |
| 37 object = frame()->GetExpression(index - parameters_count); |
| 38 } else { |
| 39 // The OsrValue index 0 is the receiver. |
| 40 object = index ? frame()->GetParameter(index - 1) : frame()->receiver(); |
| 41 } |
| 42 return Replace(jsgraph()->Constant(handle(object, isolate()))); |
| 43 } |
| 44 |
| 45 |
| 46 Reduction JSFrameSpecialization::ReduceParameter(Node* node) { |
| 47 DCHECK_EQ(IrOpcode::kParameter, node->opcode()); |
| 48 DisallowHeapAllocation no_gc; |
| 49 Object* object; |
| 50 int const index = ParameterIndexOf(node->op()); |
| 51 int const parameters_count = frame()->ComputeParametersCount() + 1; |
| 52 if (index == Linkage::kJSFunctionCallClosureParamIndex) { |
| 53 object = frame()->function(); |
| 54 } else if (index == parameters_count) { |
| 55 // The Parameter index (arity + 1) is the context. |
| 56 object = frame()->context(); |
| 57 } else { |
| 58 // The Parameter index 0 is the receiver. |
| 59 object = index ? frame()->GetParameter(index - 1) : frame()->receiver(); |
| 60 } |
| 61 return Replace(jsgraph()->Constant(handle(object, isolate()))); |
| 62 } |
| 63 |
| 64 |
| 65 Isolate* JSFrameSpecialization::isolate() const { return jsgraph()->isolate(); } |
| 66 |
| 67 } // namespace compiler |
| 68 } // namespace internal |
| 69 } // namespace v8 |
OLD | NEW |