| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/assembler_macros.h" | 9 #include "vm/assembler_macros.h" |
| 10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 | 84 |
| 85 // Cache Context pointer into CTX while executing Dart code. | 85 // Cache Context pointer into CTX while executing Dart code. |
| 86 __ movq(CTX, RBX); | 86 __ movq(CTX, RBX); |
| 87 | 87 |
| 88 __ LeaveFrame(); | 88 __ LeaveFrame(); |
| 89 __ ret(); | 89 __ ret(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 | 92 |
| 93 // Print the stop message. | 93 // Print the stop message. |
| 94 static void PrintStopMessage(const char* message) { | 94 DEFINE_LEAF_RUNTIME_ENTRY(void, PrintStopMessage, const char* message) { |
| 95 OS::Print("Stop message: %s\n", message); | 95 OS::Print("Stop message: %s\n", message); |
| 96 } | 96 } |
| 97 END_LEAF_RUNTIME_ENTRY |
| 97 | 98 |
| 98 | 99 |
| 99 // Input parameters: | 100 // Input parameters: |
| 100 // RSP : points to return address. | 101 // RSP : points to return address. |
| 101 // RDI : stop message (const char*). | 102 // RDI : stop message (const char*). |
| 102 // Must preserve all registers, except RDI and TMP. | 103 // Must preserve all registers. |
| 103 void StubCode::GeneratePrintStopMessageStub(Assembler* assembler) { | 104 void StubCode::GeneratePrintStopMessageStub(Assembler* assembler) { |
| 104 // Preserve caller-saved registers. | 105 __ enter(Immediate(0)); |
| 105 __ pushq(RAX); | 106 __ PreserveCallerSavedRegisters(); |
| 106 __ pushq(RCX); | |
| 107 __ pushq(RDX); | |
| 108 __ pushq(RSI); | |
| 109 __ pushq(R8); | |
| 110 __ pushq(R9); | |
| 111 __ pushq(R10); | |
| 112 | 107 |
| 113 AssemblerMacros::EnterStubFrame(assembler); | 108 // Call the runtime leaf function. RDI already contains the parameter. |
| 109 __ ReserveAlignedFrameSpace(0); |
| 110 __ CallRuntime(kPrintStopMessageRuntimeEntry); |
| 114 | 111 |
| 115 // Align frame before entering C++ world. | 112 __ RestoreCallerSavedRegisters(); |
| 116 if (OS::ActivationFrameAlignment() > 0) { | 113 __ leave(); |
| 117 __ andq(RSP, Immediate(~(OS::ActivationFrameAlignment() - 1))); | |
| 118 } | |
| 119 | |
| 120 // Stop message is already in RDI. | |
| 121 __ movq(TMP, Immediate(reinterpret_cast<uword>(&PrintStopMessage))); | |
| 122 __ call(TMP); | |
| 123 | |
| 124 __ LeaveFrame(); | |
| 125 | |
| 126 // Restore caller-saved registers. | |
| 127 __ popq(R10); | |
| 128 __ popq(R9); | |
| 129 __ popq(R8); | |
| 130 __ popq(RSI); | |
| 131 __ popq(RDX); | |
| 132 __ popq(RCX); | |
| 133 __ popq(RAX); | |
| 134 | |
| 135 __ ret(); | 114 __ ret(); |
| 136 } | 115 } |
| 137 | 116 |
| 138 | 117 |
| 139 // Input parameters: | 118 // Input parameters: |
| 140 // RSP : points to return address. | 119 // RSP : points to return address. |
| 141 // RSP + 8 : address of return value. | 120 // RSP + 8 : address of return value. |
| 142 // RAX : address of first argument in argument array. | 121 // RAX : address of first argument in argument array. |
| 143 // RAX - 8*R10 + 8 : address of last argument in argument array. | 122 // RAX - 8*R10 + 8 : address of last argument in argument array. |
| 144 // RBX : address of the native function to call. | 123 // RBX : address of the native function to call. |
| (...skipping 914 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1059 __ CallRuntime(kAllocateContextRuntimeEntry); // Allocate context. | 1038 __ CallRuntime(kAllocateContextRuntimeEntry); // Allocate context. |
| 1060 __ popq(RAX); // Pop number of context variables argument. | 1039 __ popq(RAX); // Pop number of context variables argument. |
| 1061 __ popq(RAX); // Pop the new context object. | 1040 __ popq(RAX); // Pop the new context object. |
| 1062 // RAX: new object | 1041 // RAX: new object |
| 1063 // Restore the frame pointer. | 1042 // Restore the frame pointer. |
| 1064 __ LeaveFrame(); | 1043 __ LeaveFrame(); |
| 1065 __ ret(); | 1044 __ ret(); |
| 1066 } | 1045 } |
| 1067 | 1046 |
| 1068 | 1047 |
| 1048 DECLARE_LEAF_RUNTIME_ENTRY(void, StoreBufferBlockProcess, Isolate* isolate); |
| 1049 |
| 1069 // Helper stub to implement Assembler::StoreIntoObject. | 1050 // Helper stub to implement Assembler::StoreIntoObject. |
| 1070 // Input parameters: | 1051 // Input parameters: |
| 1071 // RAX: Address being stored | 1052 // RAX: Address being stored |
| 1072 void StubCode::GenerateUpdateStoreBufferStub(Assembler* assembler) { | 1053 void StubCode::GenerateUpdateStoreBufferStub(Assembler* assembler) { |
| 1073 // Save registers being destroyed. | 1054 // Save registers being destroyed. |
| 1074 __ pushq(CTX); | 1055 __ pushq(RDX); |
| 1075 __ pushq(RBX); | 1056 __ pushq(RCX); |
| 1076 | 1057 |
| 1077 // Load the isolate out of the context. | 1058 // Load the isolate out of the context. |
| 1078 // RAX: Address being stored | 1059 // RAX: Address being stored |
| 1079 __ movq(CTX, FieldAddress(CTX, Context::isolate_offset())); | 1060 __ movq(RDX, FieldAddress(CTX, Context::isolate_offset())); |
| 1080 | 1061 |
| 1081 // Load top_ out of the StoreBufferBlock and add the address to the pointers_. | 1062 // Load top_ out of the StoreBufferBlock and add the address to the pointers_. |
| 1082 // RAX: Address being stored | 1063 // RAX: Address being stored |
| 1083 // CTX: Isolate | 1064 // RDX: Isolate |
| 1084 intptr_t store_buffer_offset = Isolate::store_buffer_block_offset(); | 1065 intptr_t store_buffer_offset = Isolate::store_buffer_block_offset(); |
| 1085 __ movl(RBX, | 1066 __ movl(RCX, |
| 1086 Address(CTX, store_buffer_offset + StoreBufferBlock::top_offset())); | 1067 Address(RDX, store_buffer_offset + StoreBufferBlock::top_offset())); |
| 1087 __ movq(Address(CTX, | 1068 __ movq(Address(RDX, |
| 1088 RBX, TIMES_8, | 1069 RCX, TIMES_8, |
| 1089 store_buffer_offset + StoreBufferBlock::pointers_offset()), | 1070 store_buffer_offset + StoreBufferBlock::pointers_offset()), |
| 1090 RAX); | 1071 RAX); |
| 1091 | 1072 |
| 1092 // Increment top_ and check for overflow. | 1073 // Increment top_ and check for overflow. |
| 1093 // RBX: top_ | 1074 // RCX: top_ |
| 1094 // CTX: Isolate | 1075 // RDX: Isolate |
| 1095 Label L; | 1076 Label L; |
| 1096 __ incq(RBX); | 1077 __ incq(RCX); |
| 1097 __ movl(Address(CTX, store_buffer_offset + StoreBufferBlock::top_offset()), | 1078 __ movl(Address(RDX, store_buffer_offset + StoreBufferBlock::top_offset()), |
| 1098 RBX); | 1079 RCX); |
| 1099 __ cmpl(RBX, Immediate(StoreBufferBlock::kSize)); | 1080 __ cmpl(RCX, Immediate(StoreBufferBlock::kSize)); |
| 1100 __ j(NOT_EQUAL, &L, Assembler::kNearJump); | 1081 // Restore values. |
| 1082 __ popq(RCX); |
| 1083 __ popq(RDX); |
| 1084 __ j(EQUAL, &L, Assembler::kNearJump); |
| 1085 __ ret(); |
| 1101 | 1086 |
| 1102 // Handle overflow: Reset the top_ pointer. | 1087 // Handle overflow: Call the runtime leaf function. |
| 1103 // CTX: Isolate | |
| 1104 __ movl(RBX, Immediate(0)); | |
| 1105 __ movl(Address(CTX, store_buffer_offset + StoreBufferBlock::top_offset()), | |
| 1106 RBX); | |
| 1107 | |
| 1108 __ Bind(&L); | 1088 __ Bind(&L); |
| 1109 // Restore values. | 1089 // Setup frame, push callee-saved registers. |
| 1110 __ popq(RBX); | 1090 __ enter(Immediate(0)); |
| 1111 __ popq(CTX); | 1091 __ PreserveCallerSavedRegisters(); |
| 1092 __ ReserveAlignedFrameSpace(0); |
| 1093 __ movq(RDI, FieldAddress(CTX, Context::isolate_offset())); |
| 1094 __ CallRuntime(kStoreBufferBlockProcessRuntimeEntry); |
| 1095 // Restore callee-saved registers, tear down frame. |
| 1096 __ RestoreCallerSavedRegisters(); |
| 1097 __ leave(); |
| 1112 __ ret(); | 1098 __ ret(); |
| 1113 } | 1099 } |
| 1114 | 1100 |
| 1115 | 1101 |
| 1116 // Called for inline allocation of objects. | 1102 // Called for inline allocation of objects. |
| 1117 // Input parameters: | 1103 // Input parameters: |
| 1118 // RSP + 16 : type arguments object (only if class is parameterized). | 1104 // RSP + 16 : type arguments object (only if class is parameterized). |
| 1119 // RSP + 8 : type arguments of instantiator (only if class is parameterized). | 1105 // RSP + 8 : type arguments of instantiator (only if class is parameterized). |
| 1120 // RSP : points to return address. | 1106 // RSP : points to return address. |
| 1121 void StubCode::GenerateAllocationStubForClass(Assembler* assembler, | 1107 void StubCode::GenerateAllocationStubForClass(Assembler* assembler, |
| (...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1913 void StubCode::GenerateJumpToErrorHandlerStub(Assembler* assembler) { | 1899 void StubCode::GenerateJumpToErrorHandlerStub(Assembler* assembler) { |
| 1914 __ movq(RAX, RCX); // error object. | 1900 __ movq(RAX, RCX); // error object. |
| 1915 __ movq(RBP, RDX); // target frame_pointer. | 1901 __ movq(RBP, RDX); // target frame_pointer. |
| 1916 __ movq(RSP, RSI); // target stack_pointer. | 1902 __ movq(RSP, RSI); // target stack_pointer. |
| 1917 __ jmp(RDI); // Jump to the exception handler code. | 1903 __ jmp(RDI); // Jump to the exception handler code. |
| 1918 } | 1904 } |
| 1919 | 1905 |
| 1920 } // namespace dart | 1906 } // namespace dart |
| 1921 | 1907 |
| 1922 #endif // defined TARGET_ARCH_X64 | 1908 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |