OLD | NEW |
---|---|
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef V8_COMPILER_LINKAGE_IMPL_H_ | 5 #ifndef V8_COMPILER_LINKAGE_IMPL_H_ |
6 #define V8_COMPILER_LINKAGE_IMPL_H_ | 6 #define V8_COMPILER_LINKAGE_IMPL_H_ |
7 | 7 |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/compiler/osr.h" | 9 #include "src/compiler/osr.h" |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... | |
22 DCHECK(locations->return_count_ <= 2); | 22 DCHECK(locations->return_count_ <= 2); |
23 if (locations->return_count_ > 0) { | 23 if (locations->return_count_ > 0) { |
24 locations->AddReturn(regloc(LinkageTraits::ReturnValueReg())); | 24 locations->AddReturn(regloc(LinkageTraits::ReturnValueReg())); |
25 } | 25 } |
26 if (locations->return_count_ > 1) { | 26 if (locations->return_count_ > 1) { |
27 locations->AddReturn(regloc(LinkageTraits::ReturnValue2Reg())); | 27 locations->AddReturn(regloc(LinkageTraits::ReturnValue2Reg())); |
28 } | 28 } |
29 } | 29 } |
30 | 30 |
31 // TODO(turbofan): cache call descriptors for JSFunction calls. | 31 // TODO(turbofan): cache call descriptors for JSFunction calls. |
32 static CallDescriptor* GetJSCallDescriptor(Zone* zone, int js_parameter_count, | 32 static CallDescriptor* GetJSCallDescriptor(Zone* zone, bool is_osr, |
33 int js_parameter_count, | |
33 CallDescriptor::Flags flags) { | 34 CallDescriptor::Flags flags) { |
34 const size_t return_count = 1; | 35 const size_t return_count = 1; |
35 const size_t context_count = 1; | 36 const size_t context_count = 1; |
36 const size_t parameter_count = js_parameter_count + context_count; | 37 const size_t parameter_count = js_parameter_count + context_count; |
37 | 38 |
38 LocationSignature::Builder locations(zone, return_count, parameter_count); | 39 LocationSignature::Builder locations(zone, return_count, parameter_count); |
39 MachineSignature::Builder types(zone, return_count, parameter_count); | 40 MachineSignature::Builder types(zone, return_count, parameter_count); |
40 | 41 |
41 // Add returns. | 42 // Add returns. |
42 AddReturnLocations(&locations); | 43 AddReturnLocations(&locations); |
43 for (size_t i = 0; i < return_count; i++) { | 44 for (size_t i = 0; i < return_count; i++) { |
44 types.AddReturn(kMachAnyTagged); | 45 types.AddReturn(kMachAnyTagged); |
45 } | 46 } |
46 | 47 |
47 // All parameters to JS calls go on the stack. | 48 // All parameters to JS calls go on the stack. |
48 for (int i = 0; i < js_parameter_count; i++) { | 49 for (int i = 0; i < js_parameter_count; i++) { |
49 int spill_slot_index = i - js_parameter_count; | 50 int spill_slot_index = i - js_parameter_count; |
50 locations.AddParam(stackloc(spill_slot_index)); | 51 locations.AddParam(stackloc(spill_slot_index)); |
51 types.AddParam(kMachAnyTagged); | 52 types.AddParam(kMachAnyTagged); |
52 } | 53 } |
53 // Add context. | 54 // Add context. |
54 locations.AddParam(regloc(LinkageTraits::ContextReg())); | 55 locations.AddParam(regloc(LinkageTraits::ContextReg())); |
55 types.AddParam(kMachAnyTagged); | 56 types.AddParam(kMachAnyTagged); |
56 | 57 |
57 // The target for JS function calls is the JSFunction object. | 58 // The target for JS function calls is the JSFunction object. |
58 MachineType target_type = kMachAnyTagged; | 59 MachineType target_type = kMachAnyTagged; |
59 LinkageLocation target_loc = regloc(LinkageTraits::JSCallFunctionReg()); | 60 // Fullcode doesn't preserve the JSCallFunctionReg, so expect the |
61 // JSFunction object on the stack. | |
62 LinkageLocation target_loc = | |
63 is_osr ? stackloc(-1 - js_parameter_count) | |
Michael Starzinger
2015/01/30 10:06:02
Magic "-1" is being very magic. Is there any const
| |
64 : regloc(LinkageTraits::JSCallFunctionReg()); | |
60 return new (zone) CallDescriptor( // -- | 65 return new (zone) CallDescriptor( // -- |
61 CallDescriptor::kCallJSFunction, // kind | 66 CallDescriptor::kCallJSFunction, // kind |
62 target_type, // target MachineType | 67 target_type, // target MachineType |
63 target_loc, // target location | 68 target_loc, // target location |
64 types.Build(), // machine_sig | 69 types.Build(), // machine_sig |
65 locations.Build(), // location_sig | 70 locations.Build(), // location_sig |
66 js_parameter_count, // js_parameter_count | 71 js_parameter_count, // js_parameter_count |
67 Operator::kNoProperties, // properties | 72 Operator::kNoProperties, // properties |
68 kNoCalleeSaved, // callee-saved | 73 kNoCalleeSaved, // callee-saved |
69 flags, // flags | 74 flags, // flags |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
247 return incoming_->GetInputLocation(parameter_index); | 252 return incoming_->GetInputLocation(parameter_index); |
248 } | 253 } |
249 } | 254 } |
250 | 255 |
251 | 256 |
252 } // namespace compiler | 257 } // namespace compiler |
253 } // namespace internal | 258 } // namespace internal |
254 } // namespace v8 | 259 } // namespace v8 |
255 | 260 |
256 #endif // V8_COMPILER_LINKAGE_IMPL_H_ | 261 #endif // V8_COMPILER_LINKAGE_IMPL_H_ |
OLD | NEW |