Chromium Code Reviews| 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_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 // ECX : address of the runtime function to call. | 107 // ECX : address of the runtime function to call. |
| 108 // EDX : number of arguments to the call. | 108 // EDX : number of arguments to the call. |
| 109 // Must preserve callee saved registers EDI and EBX. | 109 // Must preserve callee saved registers EDI and EBX. |
| 110 void StubCode::GenerateStubCallToRuntimeStub(Assembler* assembler) { | 110 void StubCode::GenerateStubCallToRuntimeStub(Assembler* assembler) { |
| 111 GenerateCallRuntimeStub(assembler); | 111 GenerateCallRuntimeStub(assembler); |
| 112 } | 112 } |
| 113 | 113 |
| 114 | 114 |
| 115 // Input parameters: | 115 // Input parameters: |
| 116 // ESP : points to return address. | 116 // ESP : points to return address. |
| 117 // ESP + 4 : address of last argument in argument array. | |
| 118 // ESP + 4*EDX : address of first argument in argument array. | |
| 119 // ESP + 4*EDX + 4 : address of return value. | |
| 120 // ECX : address of the leaf function to call. | |
| 121 // EDX : number of arguments to the call. | |
| 122 // Must preserve callee saved registers EDI and EBX. | |
| 123 static void GenerateCallLeafStub(Assembler* assembler) { | |
| 124 const intptr_t isolate_offset = NativeArguments::isolate_offset(); | |
| 125 const intptr_t argc_offset = NativeArguments::argc_offset(); | |
| 126 const intptr_t argv_offset = NativeArguments::argv_offset(); | |
| 127 const intptr_t retval_offset = NativeArguments::retval_offset(); | |
| 128 | |
| 129 __ EnterFrame(0); | |
| 130 | |
| 131 // Reserve space for arguments and align frame before entering C++ world. | |
| 132 __ AddImmediate(ESP, Immediate(-sizeof(NativeArguments))); | |
| 133 if (OS::ActivationFrameAlignment() > 0) { | |
| 134 __ andl(ESP, Immediate(~(OS::ActivationFrameAlignment() - 1))); | |
| 135 } | |
| 136 | |
| 137 // Pass NativeArguments structure by value and call runtime. | |
|
Ivan Posva
2012/01/09 17:26:42
I don't think we should pass NativeArguments when
regis
2012/01/10 00:09:16
Done.
| |
| 138 __ movl(Address(ESP, isolate_offset), Immediate(0)); // Set null isolate. | |
| 139 __ movl(Address(ESP, argc_offset), EDX); // Set argc in NativeArguments. | |
| 140 __ leal(EAX, Address(EBP, EDX, TIMES_4, 1 * kWordSize)); // Compute argv. | |
| 141 __ movl(Address(ESP, argv_offset), EAX); // Set argv in NativeArguments. | |
| 142 __ addl(EAX, Immediate(1 * kWordSize)); // Retval is next to 1st argument. | |
| 143 __ movl(Address(ESP, retval_offset), EAX); // Set retval in NativeArguments. | |
| 144 __ call(ECX); | |
| 145 | |
| 146 __ LeaveFrame(); | |
| 147 __ ret(); | |
| 148 } | |
| 149 | |
| 150 | |
| 151 // Print the stop message. | |
| 152 static void PrintStopMessage(NativeArguments arguments) { | |
| 153 ASSERT(arguments.Count() == 1); | |
| 154 const char* message = reinterpret_cast<const char*>(arguments.At(0)); | |
| 155 OS::Print("Stop message: %s\n", message); | |
| 156 } | |
| 157 | |
| 158 | |
| 159 // Input parameters: | |
| 160 // ESP : points to return address. | |
| 161 // ESP + 4 : stop message (const char*). | |
| 162 void StubCode::GeneratePrintStopMessageStub(Assembler* assembler) { | |
| 163 __ movl(ECX, Immediate(reinterpret_cast<uword>(&PrintStopMessage))); | |
|
Ivan Posva
2012/01/09 17:26:42
This kills ECX and EDX as well.
regis
2012/01/10 00:09:16
Done.
| |
| 164 __ movl(EDX, Immediate(1)); // One argument. | |
| 165 GenerateCallLeafStub(assembler); | |
| 166 } | |
| 167 | |
| 168 | |
| 169 // Input parameters: | |
| 170 // ESP : points to return address. | |
| 117 // ESP + 4 : address of return value. | 171 // ESP + 4 : address of return value. |
| 118 // EAX : address of first argument in argument array. | 172 // EAX : address of first argument in argument array. |
| 119 // EAX - 4*EDX + 4 : address of last argument in argument array. | 173 // EAX - 4*EDX + 4 : address of last argument in argument array. |
| 120 // ECX : address of the native function to call. | 174 // ECX : address of the native function to call. |
| 121 // EDX : number of arguments to the call. | 175 // EDX : number of arguments to the call. |
| 122 // Uses EDI. | 176 // Uses EDI. |
| 123 void StubCode::GenerateCallNativeCFunctionStub(Assembler* assembler) { | 177 void StubCode::GenerateCallNativeCFunctionStub(Assembler* assembler) { |
| 124 const intptr_t native_args_struct_offset = kWordSize; | 178 const intptr_t native_args_struct_offset = kWordSize; |
| 125 const intptr_t isolate_offset = | 179 const intptr_t isolate_offset = |
| 126 NativeArguments::isolate_offset() + native_args_struct_offset; | 180 NativeArguments::isolate_offset() + native_args_struct_offset; |
| (...skipping 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1687 __ popl(EDX); | 1741 __ popl(EDX); |
| 1688 __ popl(ECX); | 1742 __ popl(ECX); |
| 1689 __ LeaveFrame(); | 1743 __ LeaveFrame(); |
| 1690 // Now call the dynamic function. | 1744 // Now call the dynamic function. |
| 1691 __ jmp(&StubCode::OneArgCheckInlineCacheLabel()); | 1745 __ jmp(&StubCode::OneArgCheckInlineCacheLabel()); |
| 1692 } | 1746 } |
| 1693 | 1747 |
| 1694 } // namespace dart | 1748 } // namespace dart |
| 1695 | 1749 |
| 1696 #endif // defined TARGET_ARCH_IA32 | 1750 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |