| 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/code_generator.h" | 10 #include "vm/code_generator.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 __ movq(Address(CTX, Isolate::top_context_offset()), raw_null); | 83 __ movq(Address(CTX, Isolate::top_context_offset()), raw_null); |
| 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 // Input parameters: | |
| 94 // RSP : points to return address. | |
| 95 // RSP + 8 : address of last argument in argument array. | |
| 96 // RSP + 8*R10 : address of first argument in argument array. | |
| 97 // RSP + 8*R10 + 8 : address of return value. | |
| 98 // RBX : address of the runtime function to call. | |
| 99 // R10 : number of arguments to the call. | |
| 100 // Must preserve callee saved registers R12 and R13. | |
| 101 void StubCode::GenerateCallToLeafRuntimeStub(Assembler* assembler) { | |
| 102 ASSERT((R12 != CTX) && (R13 != CTX)); | |
| 103 const intptr_t isolate_offset = NativeArguments::isolate_offset(); | |
| 104 const intptr_t argc_offset = NativeArguments::argc_offset(); | |
| 105 const intptr_t argv_offset = NativeArguments::argv_offset(); | |
| 106 | |
| 107 __ EnterFrame(0); | |
| 108 | |
| 109 // Reserve space for arguments and align frame before entering C++ world. | |
| 110 __ AddImmediate(RSP, Immediate(-sizeof(NativeArguments))); | |
| 111 if (OS::ActivationFrameAlignment() > 0) { | |
| 112 __ andq(RSP, Immediate(~(OS::ActivationFrameAlignment() - 1))); | |
| 113 } | |
| 114 | |
| 115 // Pass NativeArguments structure by value. | |
| 116 // NOTE: the retvalue area in the NativeArguments structure is not setup | |
| 117 // as leaf routines return the value in RAX. | |
| 118 __ movq(Address(RSP, isolate_offset), CTX); // Set isolate in NativeArgs. | |
| 119 __ movq(Address(RSP, argc_offset), R10); // Set argc in NativeArguments. | |
| 120 __ leaq(RAX, Address(RBP, R10, TIMES_8, 1 * kWordSize)); // Compute argv. | |
| 121 __ movq(Address(RSP, argv_offset), RAX); // Set argv in NativeArguments. | |
| 122 | |
| 123 // Make call to leaf runtime entry. | |
| 124 __ call(RBX); | |
| 125 | |
| 126 // Set return value in caller's frame. | |
| 127 __ movq(RBX, Address(RSP, argv_offset)); | |
| 128 __ addq(RBX, Immediate(1 * kWordSize)); // Retval is next to 1st argument. | |
| 129 __ movq(Address(RBX, 0), RAX); | |
| 130 | |
| 131 __ LeaveFrame(); | |
| 132 __ ret(); | |
| 133 } | |
| 134 | |
| 135 | |
| 136 // Print the stop message. | 93 // Print the stop message. |
| 137 static void PrintStopMessage(const char* message) { | 94 static void PrintStopMessage(const char* message) { |
| 138 OS::Print("Stop message: %s\n", message); | 95 OS::Print("Stop message: %s\n", message); |
| 139 } | 96 } |
| 140 | 97 |
| 141 | 98 |
| 142 // Input parameters: | 99 // Input parameters: |
| 143 // RSP : points to return address. | 100 // RSP : points to return address. |
| 144 // RDI : stop message (const char*). | 101 // RDI : stop message (const char*). |
| 145 // Must preserve all registers, except RDI and TMP. | 102 // Must preserve all registers, except RDI and TMP. |
| (...skipping 1721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1867 // TOS + 2: instance. | 1824 // TOS + 2: instance. |
| 1868 // TOS + 3: cache array. | 1825 // TOS + 3: cache array. |
| 1869 // Result in RCX: null -> not found, otherwise result (true or false). | 1826 // Result in RCX: null -> not found, otherwise result (true or false). |
| 1870 void StubCode::GenerateSubtype3TestCacheStub(Assembler* assembler) { | 1827 void StubCode::GenerateSubtype3TestCacheStub(Assembler* assembler) { |
| 1871 GenerateSubtypeNTestCacheStub(assembler, 3); | 1828 GenerateSubtypeNTestCacheStub(assembler, 3); |
| 1872 } | 1829 } |
| 1873 | 1830 |
| 1874 } // namespace dart | 1831 } // namespace dart |
| 1875 | 1832 |
| 1876 #endif // defined TARGET_ARCH_X64 | 1833 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |