| 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-frame-specialization.h" | 5 #include "src/compiler/js-frame-specialization.h" |
| 6 | 6 |
| 7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
| 8 #include "src/compiler/linkage.h" | 8 #include "src/compiler/linkage.h" |
| 9 #include "src/frames-inl.h" | 9 #include "src/frames-inl.h" |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 namespace compiler { | 13 namespace compiler { |
| 14 | 14 |
| 15 Reduction JSFrameSpecialization::Reduce(Node* node) { | 15 Reduction JSFrameSpecialization::Reduce(Node* node) { |
| 16 switch (node->opcode()) { | 16 switch (node->opcode()) { |
| 17 case IrOpcode::kOsrValue: | 17 case IrOpcode::kOsrValue: |
| 18 return ReduceOsrValue(node); | 18 return ReduceOsrValue(node); |
| 19 case IrOpcode::kOsrGuard: |
| 20 return ReduceOsrGuard(node); |
| 19 case IrOpcode::kParameter: | 21 case IrOpcode::kParameter: |
| 20 return ReduceParameter(node); | 22 return ReduceParameter(node); |
| 21 default: | 23 default: |
| 22 break; | 24 break; |
| 23 } | 25 } |
| 24 return NoChange(); | 26 return NoChange(); |
| 25 } | 27 } |
| 26 | 28 |
| 27 | |
| 28 Reduction JSFrameSpecialization::ReduceOsrValue(Node* node) { | 29 Reduction JSFrameSpecialization::ReduceOsrValue(Node* node) { |
| 29 DCHECK_EQ(IrOpcode::kOsrValue, node->opcode()); | 30 DCHECK_EQ(IrOpcode::kOsrValue, node->opcode()); |
| 30 Handle<Object> value; | 31 Handle<Object> value; |
| 31 int const index = OpParameter<int>(node); | 32 int index = OsrValueIndexOf(node->op()); |
| 32 int const parameters_count = frame()->ComputeParametersCount() + 1; | 33 int const parameters_count = frame()->ComputeParametersCount() + 1; |
| 33 if (index == Linkage::kOsrContextSpillSlotIndex) { | 34 if (index == Linkage::kOsrContextSpillSlotIndex) { |
| 34 value = handle(frame()->context(), isolate()); | 35 value = handle(frame()->context(), isolate()); |
| 35 } else if (index >= parameters_count) { | 36 } else if (index >= parameters_count) { |
| 36 value = handle(frame()->GetExpression(index - parameters_count), isolate()); | 37 value = handle(frame()->GetExpression(index - parameters_count), isolate()); |
| 37 } else { | 38 } else { |
| 38 // The OsrValue index 0 is the receiver. | 39 // The OsrValue index 0 is the receiver. |
| 39 value = | 40 value = |
| 40 handle(index ? frame()->GetParameter(index - 1) : frame()->receiver(), | 41 handle(index ? frame()->GetParameter(index - 1) : frame()->receiver(), |
| 41 isolate()); | 42 isolate()); |
| 42 } | 43 } |
| 43 return Replace(jsgraph()->Constant(value)); | 44 return Replace(jsgraph()->Constant(value)); |
| 44 } | 45 } |
| 45 | 46 |
| 47 Reduction JSFrameSpecialization::ReduceOsrGuard(Node* node) { |
| 48 DCHECK_EQ(IrOpcode::kOsrGuard, node->opcode()); |
| 49 ReplaceWithValue(node, node->InputAt(0), |
| 50 NodeProperties::GetEffectInput(node)); |
| 51 return Changed(node); |
| 52 } |
| 46 | 53 |
| 47 Reduction JSFrameSpecialization::ReduceParameter(Node* node) { | 54 Reduction JSFrameSpecialization::ReduceParameter(Node* node) { |
| 48 DCHECK_EQ(IrOpcode::kParameter, node->opcode()); | 55 DCHECK_EQ(IrOpcode::kParameter, node->opcode()); |
| 49 Handle<Object> value; | 56 Handle<Object> value; |
| 50 int const index = ParameterIndexOf(node->op()); | 57 int const index = ParameterIndexOf(node->op()); |
| 51 int const parameters_count = frame()->ComputeParametersCount() + 1; | 58 int const parameters_count = frame()->ComputeParametersCount() + 1; |
| 52 if (index == Linkage::kJSCallClosureParamIndex) { | 59 if (index == Linkage::kJSCallClosureParamIndex) { |
| 53 // The Parameter index references the closure. | 60 // The Parameter index references the closure. |
| 54 value = handle(frame()->function(), isolate()); | 61 value = handle(frame()->function(), isolate()); |
| 55 } else if (index == Linkage::GetJSCallArgCountParamIndex(parameters_count)) { | 62 } else if (index == Linkage::GetJSCallArgCountParamIndex(parameters_count)) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 66 } | 73 } |
| 67 return Replace(jsgraph()->Constant(value)); | 74 return Replace(jsgraph()->Constant(value)); |
| 68 } | 75 } |
| 69 | 76 |
| 70 | 77 |
| 71 Isolate* JSFrameSpecialization::isolate() const { return jsgraph()->isolate(); } | 78 Isolate* JSFrameSpecialization::isolate() const { return jsgraph()->isolate(); } |
| 72 | 79 |
| 73 } // namespace compiler | 80 } // namespace compiler |
| 74 } // namespace internal | 81 } // namespace internal |
| 75 } // namespace v8 | 82 } // namespace v8 |
| OLD | NEW |