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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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::kJSFunctionCallClosureParamIndex) { |
53 object = frame()->function(); | 53 object = frame()->function(); |
54 } else if (index == parameters_count) { | 54 } else if (index == parameters_count) { |
55 // The Parameter index (arity + 1) is the context. | 55 // The Parameter index (arity + 1) is the parameter count. |
| 56 object = Smi::FromInt(parameters_count - 1); |
| 57 } else if (index == parameters_count + 1) { |
| 58 // The Parameter index (arity + 2) is the context. |
56 object = frame()->context(); | 59 object = frame()->context(); |
57 } else { | 60 } else { |
58 // The Parameter index 0 is the receiver. | 61 // The Parameter index 0 is the receiver. |
59 object = index ? frame()->GetParameter(index - 1) : frame()->receiver(); | 62 object = index ? frame()->GetParameter(index - 1) : frame()->receiver(); |
60 } | 63 } |
61 return Replace(jsgraph()->Constant(handle(object, isolate()))); | 64 return Replace(jsgraph()->Constant(handle(object, isolate()))); |
62 } | 65 } |
63 | 66 |
64 | 67 |
65 Isolate* JSFrameSpecialization::isolate() const { return jsgraph()->isolate(); } | 68 Isolate* JSFrameSpecialization::isolate() const { return jsgraph()->isolate(); } |
66 | 69 |
67 } // namespace compiler | 70 } // namespace compiler |
68 } // namespace internal | 71 } // namespace internal |
69 } // namespace v8 | 72 } // namespace v8 |
OLD | NEW |