| 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 #include "src/assembler.h" | 5 #include "src/assembler.h" |
| 6 #include "src/code-stubs.h" | 6 #include "src/code-stubs.h" |
| 7 #include "src/compiler/linkage.h" | 7 #include "src/compiler/linkage.h" |
| 8 #include "src/compiler/linkage-impl.h" | 8 #include "src/compiler/linkage-impl.h" |
| 9 #include "src/zone.h" | 9 #include "src/zone.h" |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 namespace compiler { | 13 namespace compiler { |
| 14 | 14 |
| 15 #ifdef _WIN64 | |
| 16 const bool kWin64 = true; | |
| 17 #else | |
| 18 const bool kWin64 = false; | |
| 19 #endif | |
| 20 | |
| 21 struct X64LinkageHelperTraits { | 15 struct X64LinkageHelperTraits { |
| 22 static Register ReturnValueReg() { return rax; } | 16 static Register ReturnValueReg() { return rax; } |
| 23 static Register ReturnValue2Reg() { return rdx; } | 17 static Register ReturnValue2Reg() { return rdx; } |
| 24 static Register JSCallFunctionReg() { return rdi; } | 18 static Register JSCallFunctionReg() { return rdi; } |
| 25 static Register ContextReg() { return rsi; } | 19 static Register ContextReg() { return rsi; } |
| 26 static Register InterpreterBytecodePointerReg() { return rbx; } | 20 static Register InterpreterBytecodePointerReg() { return rbx; } |
| 27 static Register InterpreterDispatchTableReg() { return rdi; } | 21 static Register InterpreterDispatchTableReg() { return rdi; } |
| 28 static Register RuntimeCallFunctionReg() { return rbx; } | 22 static Register RuntimeCallFunctionReg() { return rbx; } |
| 29 static Register RuntimeCallArgCountReg() { return rax; } | 23 static Register RuntimeCallArgCountReg() { return rax; } |
| 30 static RegList CCalleeSaveRegisters() { | |
| 31 if (kWin64) { | |
| 32 return rbx.bit() | rdi.bit() | rsi.bit() | r12.bit() | r13.bit() | | |
| 33 r14.bit() | r15.bit(); | |
| 34 } else { | |
| 35 return rbx.bit() | r12.bit() | r13.bit() | r14.bit() | r15.bit(); | |
| 36 } | |
| 37 } | |
| 38 static RegList CCalleeSaveFPRegisters() { | |
| 39 if (kWin64) { | |
| 40 return (1 << xmm6.code()) | (1 << xmm7.code()) | (1 << xmm8.code()) | | |
| 41 (1 << xmm9.code()) | (1 << xmm10.code()) | (1 << xmm11.code()) | | |
| 42 (1 << xmm12.code()) | (1 << xmm13.code()) | (1 << xmm14.code()) | | |
| 43 (1 << xmm15.code()); | |
| 44 } else { | |
| 45 return 0; | |
| 46 } | |
| 47 } | |
| 48 static Register CRegisterParameter(int i) { | |
| 49 if (kWin64) { | |
| 50 static Register register_parameters[] = {rcx, rdx, r8, r9}; | |
| 51 return register_parameters[i]; | |
| 52 } else { | |
| 53 static Register register_parameters[] = {rdi, rsi, rdx, rcx, r8, r9}; | |
| 54 return register_parameters[i]; | |
| 55 } | |
| 56 } | |
| 57 static int CRegisterParametersLength() { return kWin64 ? 4 : 6; } | |
| 58 static int CStackBackingStoreLength() { return kWin64 ? 4 : 0; } | |
| 59 }; | 24 }; |
| 60 | 25 |
| 61 typedef LinkageHelper<X64LinkageHelperTraits> LH; | 26 typedef LinkageHelper<X64LinkageHelperTraits> LH; |
| 62 | 27 |
| 63 CallDescriptor* Linkage::GetJSCallDescriptor(Zone* zone, bool is_osr, | 28 CallDescriptor* Linkage::GetJSCallDescriptor(Zone* zone, bool is_osr, |
| 64 int parameter_count, | 29 int parameter_count, |
| 65 CallDescriptor::Flags flags) { | 30 CallDescriptor::Flags flags) { |
| 66 return LH::GetJSCallDescriptor(zone, is_osr, parameter_count, flags); | 31 return LH::GetJSCallDescriptor(zone, is_osr, parameter_count, flags); |
| 67 } | 32 } |
| 68 | 33 |
| 69 | 34 |
| 70 CallDescriptor* Linkage::GetRuntimeCallDescriptor( | 35 CallDescriptor* Linkage::GetRuntimeCallDescriptor( |
| 71 Zone* zone, Runtime::FunctionId function, int parameter_count, | 36 Zone* zone, Runtime::FunctionId function, int parameter_count, |
| 72 Operator::Properties properties) { | 37 Operator::Properties properties) { |
| 73 return LH::GetRuntimeCallDescriptor(zone, function, parameter_count, | 38 return LH::GetRuntimeCallDescriptor(zone, function, parameter_count, |
| 74 properties); | 39 properties); |
| 75 } | 40 } |
| 76 | 41 |
| 77 | 42 |
| 78 CallDescriptor* Linkage::GetStubCallDescriptor( | 43 CallDescriptor* Linkage::GetStubCallDescriptor( |
| 79 Isolate* isolate, Zone* zone, const CallInterfaceDescriptor& descriptor, | 44 Isolate* isolate, Zone* zone, const CallInterfaceDescriptor& descriptor, |
| 80 int stack_parameter_count, CallDescriptor::Flags flags, | 45 int stack_parameter_count, CallDescriptor::Flags flags, |
| 81 Operator::Properties properties, MachineType return_type) { | 46 Operator::Properties properties, MachineType return_type) { |
| 82 return LH::GetStubCallDescriptor(isolate, zone, descriptor, | 47 return LH::GetStubCallDescriptor(isolate, zone, descriptor, |
| 83 stack_parameter_count, flags, properties, | 48 stack_parameter_count, flags, properties, |
| 84 return_type); | 49 return_type); |
| 85 } | 50 } |
| 86 | 51 |
| 87 | 52 |
| 88 CallDescriptor* Linkage::GetSimplifiedCDescriptor(Zone* zone, | |
| 89 const MachineSignature* sig) { | |
| 90 return LH::GetSimplifiedCDescriptor(zone, sig); | |
| 91 } | |
| 92 | |
| 93 | |
| 94 CallDescriptor* Linkage::GetInterpreterDispatchDescriptor(Zone* zone) { | 53 CallDescriptor* Linkage::GetInterpreterDispatchDescriptor(Zone* zone) { |
| 95 return LH::GetInterpreterDispatchDescriptor(zone); | 54 return LH::GetInterpreterDispatchDescriptor(zone); |
| 96 } | 55 } |
| 97 | 56 |
| 98 } // namespace compiler | 57 } // namespace compiler |
| 99 } // namespace internal | 58 } // namespace internal |
| 100 } // namespace v8 | 59 } // namespace v8 |
| OLD | NEW |