Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: runtime/vm/stub_code_ia32.cc

Issue 22303002: Auto create ApiLocalScope before calling native functions, this ensures that (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/stub_code_arm.cc ('k') | runtime/vm/stub_code_mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/dart_entry.h" 10 #include "vm/dart_entry.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 114
115 115
116 // Input parameters: 116 // Input parameters:
117 // ESP : points to return address. 117 // ESP : points to return address.
118 // ESP + 4 : address of return value. 118 // ESP + 4 : address of return value.
119 // EAX : address of first argument in argument array. 119 // EAX : address of first argument in argument array.
120 // ECX : address of the native function to call. 120 // ECX : address of the native function to call.
121 // EDX : argc_tag including number of arguments and function kind. 121 // EDX : argc_tag including number of arguments and function kind.
122 // Uses EDI. 122 // Uses EDI.
123 void StubCode::GenerateCallNativeCFunctionStub(Assembler* assembler) { 123 void StubCode::GenerateCallNativeCFunctionStub(Assembler* assembler) {
124 const intptr_t native_args_struct_offset =
125 NativeEntry::kNumCallWrapperArguments * kWordSize;
126 const intptr_t isolate_offset =
127 NativeArguments::isolate_offset() + native_args_struct_offset;
128 const intptr_t argc_tag_offset =
129 NativeArguments::argc_tag_offset() + native_args_struct_offset;
130 const intptr_t argv_offset =
131 NativeArguments::argv_offset() + native_args_struct_offset;
132 const intptr_t retval_offset =
133 NativeArguments::retval_offset() + native_args_struct_offset;
134
135 __ EnterFrame(0);
136
137 // Load current Isolate pointer from Context structure into EDI.
138 __ movl(EDI, FieldAddress(CTX, Context::isolate_offset()));
139
140 // Save exit frame information to enable stack walking as we are about
141 // to transition to dart VM code.
142 __ movl(Address(EDI, Isolate::top_exit_frame_info_offset()), ESP);
143
144 // Save current Context pointer into Isolate structure.
145 __ movl(Address(EDI, Isolate::top_context_offset()), CTX);
146
147 // Cache Isolate pointer into CTX while executing native code.
148 __ movl(CTX, EDI);
149
150 // Reserve space for the native arguments structure, the outgoing parameters
151 // (pointer to the native arguments structure, the C function entry point)
152 // and align frame before entering the C++ world.
153 __ AddImmediate(ESP, Immediate(-sizeof(NativeArguments) - (2 * kWordSize)));
154 if (OS::ActivationFrameAlignment() > 0) {
155 __ andl(ESP, Immediate(~(OS::ActivationFrameAlignment() - 1)));
156 }
157
158 // Pass NativeArguments structure by value and call native function.
159 __ movl(Address(ESP, isolate_offset), CTX); // Set isolate in NativeArgs.
160 __ movl(Address(ESP, argc_tag_offset), EDX); // Set argc in NativeArguments.
161 __ movl(Address(ESP, argv_offset), EAX); // Set argv in NativeArguments.
162 __ leal(EAX, Address(EBP, 2 * kWordSize)); // Compute return value addr.
163 __ movl(Address(ESP, retval_offset), EAX); // Set retval in NativeArguments.
164 __ leal(EAX, Address(ESP, 2 * kWordSize)); // Pointer to the NativeArguments.
165 __ movl(Address(ESP, 0), EAX); // Pass the pointer to the NativeArguments.
166 __ movl(Address(ESP, kWordSize), ECX); // Function to call.
167 __ call(&NativeEntry::NativeCallWrapperLabel());
168
169 // Reset exit frame information in Isolate structure.
170 __ movl(Address(CTX, Isolate::top_exit_frame_info_offset()), Immediate(0));
171
172 // Load Context pointer from Isolate structure into EDI.
173 __ movl(EDI, Address(CTX, Isolate::top_context_offset()));
174
175 // Reset Context pointer in Isolate structure.
176 const Immediate& raw_null =
177 Immediate(reinterpret_cast<intptr_t>(Object::null()));
178 __ movl(Address(CTX, Isolate::top_context_offset()), raw_null);
179
180 // Cache Context pointer into CTX while executing Dart code.
181 __ movl(CTX, EDI);
182
183 __ LeaveFrame();
184 __ ret();
185 }
186
187
188 // Input parameters:
189 // ESP : points to return address.
190 // ESP + 4 : address of return value.
191 // EAX : address of first argument in argument array.
192 // ECX : address of the native function to call.
193 // EDX : argc_tag including number of arguments and function kind.
194 // Uses EDI.
195 void StubCode::GenerateCallBootstrapCFunctionStub(Assembler* assembler) {
124 const intptr_t native_args_struct_offset = kWordSize; 196 const intptr_t native_args_struct_offset = kWordSize;
125 const intptr_t isolate_offset = 197 const intptr_t isolate_offset =
126 NativeArguments::isolate_offset() + native_args_struct_offset; 198 NativeArguments::isolate_offset() + native_args_struct_offset;
127 const intptr_t argc_tag_offset = 199 const intptr_t argc_tag_offset =
128 NativeArguments::argc_tag_offset() + native_args_struct_offset; 200 NativeArguments::argc_tag_offset() + native_args_struct_offset;
129 const intptr_t argv_offset = 201 const intptr_t argv_offset =
130 NativeArguments::argv_offset() + native_args_struct_offset; 202 NativeArguments::argv_offset() + native_args_struct_offset;
131 const intptr_t retval_offset = 203 const intptr_t retval_offset =
132 NativeArguments::retval_offset() + native_args_struct_offset; 204 NativeArguments::retval_offset() + native_args_struct_offset;
133 205
(...skipping 2066 matching lines...) Expand 10 before | Expand all | Expand 10 after
2200 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); 2272 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp);
2201 __ popl(temp); 2273 __ popl(temp);
2202 __ popl(right); 2274 __ popl(right);
2203 __ popl(left); 2275 __ popl(left);
2204 __ ret(); 2276 __ ret();
2205 } 2277 }
2206 2278
2207 } // namespace dart 2279 } // namespace dart
2208 2280
2209 #endif // defined TARGET_ARCH_IA32 2281 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/stub_code_arm.cc ('k') | runtime/vm/stub_code_mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698