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 12 matching lines...) Expand all Loading... |
23 | 23 |
24 // Input parameters: | 24 // Input parameters: |
25 // ESP : points to return address. | 25 // ESP : points to return address. |
26 // ESP + 4 : address of last argument in argument array. | 26 // ESP + 4 : address of last argument in argument array. |
27 // ESP + 4*EDX : address of first argument in argument array. | 27 // ESP + 4*EDX : address of first argument in argument array. |
28 // ESP + 4*EDX + 4 : address of return value. | 28 // ESP + 4*EDX + 4 : address of return value. |
29 // ECX : address of the runtime function to call. | 29 // ECX : address of the runtime function to call. |
30 // EDX : number of arguments to the call. | 30 // EDX : number of arguments to the call. |
31 // Must preserve callee saved registers EDI and EBX. | 31 // Must preserve callee saved registers EDI and EBX. |
32 static void GenerateCallRuntimeStub(Assembler* assembler) { | 32 static void GenerateCallRuntimeStub(Assembler* assembler) { |
| 33 const intptr_t isolate_offset = NativeArguments::isolate_offset(); |
33 const intptr_t argc_offset = NativeArguments::argc_offset(); | 34 const intptr_t argc_offset = NativeArguments::argc_offset(); |
34 const intptr_t argv_offset = NativeArguments::argv_offset(); | 35 const intptr_t argv_offset = NativeArguments::argv_offset(); |
35 const intptr_t retval_offset = NativeArguments::retval_offset(); | 36 const intptr_t retval_offset = NativeArguments::retval_offset(); |
36 | 37 |
37 __ EnterFrame(0); | 38 __ EnterFrame(0); |
38 | 39 |
39 // Load current Isolate pointer from Context structure into EAX. | 40 // Load current Isolate pointer from Context structure into EAX. |
40 __ movl(EAX, FieldAddress(CTX, Context::isolate_offset())); | 41 __ movl(EAX, FieldAddress(CTX, Context::isolate_offset())); |
41 | 42 |
42 // Save exit frame information to enable stack walking as we are about | 43 // Save exit frame information to enable stack walking as we are about |
43 // to transition to dart VM code. | 44 // to transition to dart VM code. |
44 __ movl(Address(EAX, Isolate::top_exit_frame_info_offset()), ESP); | 45 __ movl(Address(EAX, Isolate::top_exit_frame_info_offset()), ESP); |
45 | 46 |
46 // Save current Context pointer into Isolate structure. | 47 // Save current Context pointer into Isolate structure. |
47 __ movl(Address(EAX, Isolate::top_context_offset()), CTX); | 48 __ movl(Address(EAX, Isolate::top_context_offset()), CTX); |
48 | 49 |
49 // Cache Isolate pointer into CTX while executing runtime code. | 50 // Cache Isolate pointer into CTX while executing runtime code. |
50 __ movl(CTX, EAX); | 51 __ movl(CTX, EAX); |
51 | 52 |
52 // Reserve space for arguments and align frame before entering C++ world. | 53 // Reserve space for arguments and align frame before entering C++ world. |
53 __ AddImmediate(ESP, Immediate(-sizeof(NativeArguments))); | 54 __ AddImmediate(ESP, Immediate(-sizeof(NativeArguments))); |
54 if (OS::ActivationFrameAlignment() > 0) { | 55 if (OS::ActivationFrameAlignment() > 0) { |
55 __ andl(ESP, Immediate(~(OS::ActivationFrameAlignment() - 1))); | 56 __ andl(ESP, Immediate(~(OS::ActivationFrameAlignment() - 1))); |
56 } | 57 } |
57 | 58 |
58 // Pass NativeArguments structure by value and call runtime. | 59 // Pass NativeArguments structure by value and call runtime. |
| 60 __ movl(Address(ESP, isolate_offset), CTX); // Set isolate in NativeArgs. |
59 __ movl(Address(ESP, argc_offset), EDX); // Set argc in NativeArguments. | 61 __ movl(Address(ESP, argc_offset), EDX); // Set argc in NativeArguments. |
60 __ leal(EAX, Address(EBP, EDX, TIMES_4, 1 * kWordSize)); // Compute argv. | 62 __ leal(EAX, Address(EBP, EDX, TIMES_4, 1 * kWordSize)); // Compute argv. |
61 __ movl(Address(ESP, argv_offset), EAX); // Set argv in NativeArguments. | 63 __ movl(Address(ESP, argv_offset), EAX); // Set argv in NativeArguments. |
62 __ addl(EAX, Immediate(1 * kWordSize)); // Retval is next to 1st argument. | 64 __ addl(EAX, Immediate(1 * kWordSize)); // Retval is next to 1st argument. |
63 __ movl(Address(ESP, retval_offset), EAX); // Set retval in NativeArguments. | 65 __ movl(Address(ESP, retval_offset), EAX); // Set retval in NativeArguments. |
64 __ call(ECX); | 66 __ call(ECX); |
65 | 67 |
66 // Reset exit frame information in Isolate structure. | 68 // Reset exit frame information in Isolate structure. |
67 __ movl(Address(CTX, Isolate::top_exit_frame_info_offset()), Immediate(0)); | 69 __ movl(Address(CTX, Isolate::top_exit_frame_info_offset()), Immediate(0)); |
68 | 70 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // Input parameters: | 113 // Input parameters: |
112 // ESP : points to return address. | 114 // ESP : points to return address. |
113 // ESP + 4 : address of return value. | 115 // ESP + 4 : address of return value. |
114 // EAX : address of first argument in argument array. | 116 // EAX : address of first argument in argument array. |
115 // EAX - 4*EDX + 4 : address of last argument in argument array. | 117 // EAX - 4*EDX + 4 : address of last argument in argument array. |
116 // ECX : address of the native function to call. | 118 // ECX : address of the native function to call. |
117 // EDX : number of arguments to the call. | 119 // EDX : number of arguments to the call. |
118 // Uses EDI. | 120 // Uses EDI. |
119 void StubCode::GenerateCallNativeCFunctionStub(Assembler* assembler) { | 121 void StubCode::GenerateCallNativeCFunctionStub(Assembler* assembler) { |
120 const intptr_t native_args_struct_offset = kWordSize; | 122 const intptr_t native_args_struct_offset = kWordSize; |
| 123 const intptr_t isolate_offset = |
| 124 NativeArguments::isolate_offset() + native_args_struct_offset; |
121 const intptr_t argc_offset = | 125 const intptr_t argc_offset = |
122 NativeArguments::argc_offset() + native_args_struct_offset; | 126 NativeArguments::argc_offset() + native_args_struct_offset; |
123 const intptr_t argv_offset = | 127 const intptr_t argv_offset = |
124 NativeArguments::argv_offset() + native_args_struct_offset; | 128 NativeArguments::argv_offset() + native_args_struct_offset; |
125 const intptr_t retval_offset = | 129 const intptr_t retval_offset = |
126 NativeArguments::retval_offset() + native_args_struct_offset; | 130 NativeArguments::retval_offset() + native_args_struct_offset; |
127 | 131 |
128 __ EnterFrame(0); | 132 __ EnterFrame(0); |
129 | 133 |
130 // Load current Isolate pointer from Context structure into EDI. | 134 // Load current Isolate pointer from Context structure into EDI. |
(...skipping 11 matching lines...) Expand all Loading... |
142 | 146 |
143 // Reserve space for the native arguments structure, the outgoing parameter | 147 // Reserve space for the native arguments structure, the outgoing parameter |
144 // (pointer to the native arguments structure) and align frame before | 148 // (pointer to the native arguments structure) and align frame before |
145 // entering the C++ world. | 149 // entering the C++ world. |
146 __ AddImmediate(ESP, Immediate(-sizeof(NativeArguments) - kWordSize)); | 150 __ AddImmediate(ESP, Immediate(-sizeof(NativeArguments) - kWordSize)); |
147 if (OS::ActivationFrameAlignment() > 0) { | 151 if (OS::ActivationFrameAlignment() > 0) { |
148 __ andl(ESP, Immediate(~(OS::ActivationFrameAlignment() - 1))); | 152 __ andl(ESP, Immediate(~(OS::ActivationFrameAlignment() - 1))); |
149 } | 153 } |
150 | 154 |
151 // Pass NativeArguments structure by value and call runtime. | 155 // Pass NativeArguments structure by value and call runtime. |
| 156 __ movl(Address(ESP, isolate_offset), CTX); // Set isolate in NativeArgs. |
152 __ movl(Address(ESP, argc_offset), EDX); // Set argc in NativeArguments. | 157 __ movl(Address(ESP, argc_offset), EDX); // Set argc in NativeArguments. |
153 __ movl(Address(ESP, argv_offset), EAX); // Set argv in NativeArguments. | 158 __ movl(Address(ESP, argv_offset), EAX); // Set argv in NativeArguments. |
154 __ leal(EAX, Address(EBP, 2 * kWordSize)); // Compute return value addr. | 159 __ leal(EAX, Address(EBP, 2 * kWordSize)); // Compute return value addr. |
155 __ movl(Address(ESP, retval_offset), EAX); // Set retval in NativeArguments. | 160 __ movl(Address(ESP, retval_offset), EAX); // Set retval in NativeArguments. |
156 __ leal(EAX, Address(ESP, kWordSize)); // Pointer to the NativeArguments. | 161 __ leal(EAX, Address(ESP, kWordSize)); // Pointer to the NativeArguments. |
157 __ movl(Address(ESP, 0), EAX); // Pass the pointer to the NativeArguments. | 162 __ movl(Address(ESP, 0), EAX); // Pass the pointer to the NativeArguments. |
158 __ call(ECX); | 163 __ call(ECX); |
159 | 164 |
160 // Reset exit frame information in Isolate structure. | 165 // Reset exit frame information in Isolate structure. |
161 __ movl(Address(CTX, Isolate::top_exit_frame_info_offset()), Immediate(0)); | 166 __ movl(Address(CTX, Isolate::top_exit_frame_info_offset()), Immediate(0)); |
(...skipping 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1510 // EAX: Target function. | 1515 // EAX: Target function. |
1511 __ movl(EAX, FieldAddress(EAX, Function::code_offset())); | 1516 __ movl(EAX, FieldAddress(EAX, Function::code_offset())); |
1512 __ movl(EAX, FieldAddress(EAX, Code::instructions_offset())); | 1517 __ movl(EAX, FieldAddress(EAX, Code::instructions_offset())); |
1513 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 1518 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
1514 __ jmp(EAX); | 1519 __ jmp(EAX); |
1515 } | 1520 } |
1516 | 1521 |
1517 } // namespace dart | 1522 } // namespace dart |
1518 | 1523 |
1519 #endif // defined TARGET_ARCH_IA32 | 1524 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |