| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/globals.h" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "vm/code_generator.h" | 8 #include "vm/code_generator.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/ic_data.h" | 10 #include "vm/ic_data.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 // RSP + 8*R10 : address of first argument in argument array. | 106 // RSP + 8*R10 : address of first argument in argument array. |
| 107 // RSP + 8*R10 + 8 : address of return value. | 107 // RSP + 8*R10 + 8 : address of return value. |
| 108 // RBX : address of the runtime function to call. | 108 // RBX : address of the runtime function to call. |
| 109 // R10 : number of arguments to the call. | 109 // R10 : number of arguments to the call. |
| 110 // Must preserve callee saved registers R12 and R13. | 110 // Must preserve callee saved registers R12 and R13. |
| 111 void StubCode::GenerateStubCallToRuntimeStub(Assembler* assembler) { | 111 void StubCode::GenerateStubCallToRuntimeStub(Assembler* assembler) { |
| 112 GenerateCallRuntimeStub(assembler); | 112 GenerateCallRuntimeStub(assembler); |
| 113 } | 113 } |
| 114 | 114 |
| 115 | 115 |
| 116 // Print the stop message. |
| 117 static void PrintStopMessage(const char* message) { |
| 118 OS::Print("Stop message: %s\n", message); |
| 119 } |
| 120 |
| 121 |
| 122 // Input parameters: |
| 123 // RSP : points to return address. |
| 124 // RDI : stop message (const char*). |
| 125 // Must preserve all registers, except RDI and TMP. |
| 126 void StubCode::GeneratePrintStopMessageStub(Assembler* assembler) { |
| 127 // Preserve caller-saved registers. |
| 128 __ pushq(RAX); |
| 129 __ pushq(RCX); |
| 130 __ pushq(RDX); |
| 131 __ pushq(RSI); |
| 132 __ pushq(R8); |
| 133 __ pushq(R9); |
| 134 __ pushq(R10); |
| 135 |
| 136 __ EnterFrame(0); |
| 137 |
| 138 // Align frame before entering C++ world. |
| 139 if (OS::ActivationFrameAlignment() > 0) { |
| 140 __ andq(RSP, Immediate(~(OS::ActivationFrameAlignment() - 1))); |
| 141 } |
| 142 |
| 143 // Stop message is already in RDI. |
| 144 __ movq(TMP, Immediate(reinterpret_cast<uword>(&PrintStopMessage))); |
| 145 __ call(TMP); |
| 146 |
| 147 __ LeaveFrame(); |
| 148 |
| 149 // Restore caller-saved registers. |
| 150 __ popq(R10); |
| 151 __ popq(R9); |
| 152 __ popq(R8); |
| 153 __ popq(RSI); |
| 154 __ popq(RDX); |
| 155 __ popq(RCX); |
| 156 __ popq(RAX); |
| 157 |
| 158 __ ret(); |
| 159 } |
| 160 |
| 161 |
| 116 // Input parameters: | 162 // Input parameters: |
| 117 // RSP : points to return address. | 163 // RSP : points to return address. |
| 118 // RSP + 8 : address of return value. | 164 // RSP + 8 : address of return value. |
| 119 // RAX : address of first argument in argument array. | 165 // RAX : address of first argument in argument array. |
| 120 // RAX - 8*R10 + 8 : address of last argument in argument array. | 166 // RAX - 8*R10 + 8 : address of last argument in argument array. |
| 121 // RBX : address of the native function to call. | 167 // RBX : address of the native function to call. |
| 122 // R10 : number of arguments to the call. | 168 // R10 : number of arguments to the call. |
| 123 // Uses R8. | 169 // Uses R8. |
| 124 void StubCode::GenerateCallNativeCFunctionStub(Assembler* assembler) { | 170 void StubCode::GenerateCallNativeCFunctionStub(Assembler* assembler) { |
| 125 const intptr_t native_args_struct_offset = 0; | 171 const intptr_t native_args_struct_offset = 0; |
| (...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1026 // RAX: new object | 1072 // RAX: new object |
| 1027 // Restore the frame pointer. | 1073 // Restore the frame pointer. |
| 1028 __ LeaveFrame(); | 1074 __ LeaveFrame(); |
| 1029 __ ret(); | 1075 __ ret(); |
| 1030 } | 1076 } |
| 1031 | 1077 |
| 1032 | 1078 |
| 1033 // Called for inline allocation of closures. | 1079 // Called for inline allocation of closures. |
| 1034 // Input parameters: | 1080 // Input parameters: |
| 1035 // If the signature class is not parameterized, the receiver, if any, will be | 1081 // If the signature class is not parameterized, the receiver, if any, will be |
| 1036 // at RSP + 4 instead of RSP + 8, since no type arguments are passed. | 1082 // at RSP + 8 instead of RSP + 16, since no type arguments are passed. |
| 1037 // RSP + 8 (or RSP + 4): receiver (only if implicit instance closure). | 1083 // RSP + 16 (or RSP + 8): receiver (only if implicit instance closure). |
| 1038 // RSP + 4 : type arguments object (only if signature class is parameterized). | 1084 // RSP + 8 : type arguments object (only if signature class is parameterized). |
| 1039 // RSP : points to return address. | 1085 // RSP : points to return address. |
| 1040 // Uses RAX, RBX, RCX, RDX as temporary registers. | 1086 // Uses RAX, RCX as temporary registers. |
| 1041 void StubCode::GenerateAllocationStubForClosure(Assembler* assembler, | 1087 void StubCode::GenerateAllocationStubForClosure(Assembler* assembler, |
| 1042 const Function& func) { | 1088 const Function& func) { |
| 1043 const Immediate raw_null = | 1089 const Immediate raw_null = |
| 1044 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 1090 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 1045 ASSERT(func.IsClosureFunction()); | 1091 ASSERT(func.IsClosureFunction()); |
| 1046 const bool is_implicit_static_closure = | 1092 const bool is_implicit_static_closure = |
| 1047 func.IsImplicitStaticClosureFunction(); | 1093 func.IsImplicitStaticClosureFunction(); |
| 1048 const bool is_implicit_instance_closure = | 1094 const bool is_implicit_instance_closure = |
| 1049 func.IsImplicitInstanceClosureFunction(); | 1095 func.IsImplicitInstanceClosureFunction(); |
| 1050 const Class& cls = Class::ZoneHandle(func.signature_class()); | 1096 const Class& cls = Class::ZoneHandle(func.signature_class()); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1266 } | 1312 } |
| 1267 | 1313 |
| 1268 | 1314 |
| 1269 void StubCode::GenerateBreakpointDynamicStub(Assembler* assembler) { | 1315 void StubCode::GenerateBreakpointDynamicStub(Assembler* assembler) { |
| 1270 __ Unimplemented("BreakpointDynamic stub"); | 1316 __ Unimplemented("BreakpointDynamic stub"); |
| 1271 } | 1317 } |
| 1272 | 1318 |
| 1273 } // namespace dart | 1319 } // namespace dart |
| 1274 | 1320 |
| 1275 #endif // defined TARGET_ARCH_X64 | 1321 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |