| 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 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 return Replace(jsgraph()->Constant(handle(object, isolate()))); | 42 return Replace(jsgraph()->Constant(handle(object, isolate()))); |
| 43 } | 43 } |
| 44 | 44 |
| 45 | 45 |
| 46 Reduction JSFrameSpecialization::ReduceParameter(Node* node) { | 46 Reduction JSFrameSpecialization::ReduceParameter(Node* node) { |
| 47 DCHECK_EQ(IrOpcode::kParameter, node->opcode()); | 47 DCHECK_EQ(IrOpcode::kParameter, node->opcode()); |
| 48 DisallowHeapAllocation no_gc; | 48 DisallowHeapAllocation no_gc; |
| 49 Object* object; | 49 Object* object; |
| 50 int const index = ParameterIndexOf(node->op()); | 50 int const index = ParameterIndexOf(node->op()); |
| 51 int const parameters_count = frame()->ComputeParametersCount() + 1; | 51 int const parameters_count = frame()->ComputeParametersCount() + 1; |
| 52 if (index == Linkage::kJSFunctionCallClosureParamIndex) { | 52 if (index == Linkage::kJSCallClosureParamIndex) { |
| 53 // The Parameter index references the closure. |
| 53 object = frame()->function(); | 54 object = frame()->function(); |
| 54 } else if (index == parameters_count) { | 55 } else if (index == Linkage::GetJSCallArgCountParamIndex(parameters_count)) { |
| 55 // The Parameter index (arity + 1) is the parameter count. | 56 // The Parameter index references the parameter count. |
| 56 object = Smi::FromInt(parameters_count - 1); | 57 object = Smi::FromInt(parameters_count - 1); |
| 57 } else if (index == parameters_count + 1) { | 58 } else if (index == Linkage::GetJSCallContextParamIndex(parameters_count)) { |
| 58 // The Parameter index (arity + 2) is the context. | 59 // The Parameter index references the context. |
| 59 object = frame()->context(); | 60 object = frame()->context(); |
| 60 } else { | 61 } else { |
| 61 // The Parameter index 0 is the receiver. | 62 // The Parameter index 0 is the receiver. |
| 62 object = index ? frame()->GetParameter(index - 1) : frame()->receiver(); | 63 object = index ? frame()->GetParameter(index - 1) : frame()->receiver(); |
| 63 } | 64 } |
| 64 return Replace(jsgraph()->Constant(handle(object, isolate()))); | 65 return Replace(jsgraph()->Constant(handle(object, isolate()))); |
| 65 } | 66 } |
| 66 | 67 |
| 67 | 68 |
| 68 Isolate* JSFrameSpecialization::isolate() const { return jsgraph()->isolate(); } | 69 Isolate* JSFrameSpecialization::isolate() const { return jsgraph()->isolate(); } |
| 69 | 70 |
| 70 } // namespace compiler | 71 } // namespace compiler |
| 71 } // namespace internal | 72 } // namespace internal |
| 72 } // namespace v8 | 73 } // namespace v8 |
| OLD | NEW |