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

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

Issue 240213004: Fixes a problem with the recovery of contexts in the debugger at closure calls. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 8 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/stack_frame.cc ('k') | no next file » | 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"
11 #include "vm/flow_graph_compiler.h" 11 #include "vm/flow_graph_compiler.h"
12 #include "vm/instructions.h" 12 #include "vm/instructions.h"
13 #include "vm/heap.h" 13 #include "vm/heap.h"
14 #include "vm/object_store.h" 14 #include "vm/object_store.h"
15 #include "vm/resolver.h" 15 #include "vm/resolver.h"
16 #include "vm/scavenger.h" 16 #include "vm/scavenger.h"
17 #include "vm/stack_frame.h" 17 #include "vm/stack_frame.h"
18 #include "vm/stub_code.h" 18 #include "vm/stub_code.h"
19 #include "vm/tags.h" 19 #include "vm/tags.h"
20 20
21 21
22 #define __ assembler-> 22 #define __ assembler->
23 23
24 namespace dart { 24 namespace dart {
25 25
26 DEFINE_FLAG(bool, inline_alloc, true, "Inline allocation of objects."); 26 DEFINE_FLAG(bool, inline_alloc, true, "Inline allocation of objects.");
27 DEFINE_FLAG(bool, use_slow_path, false, 27 DEFINE_FLAG(bool, use_slow_path, false,
28 "Set to true for debugging & verifying the slow paths."); 28 "Set to true for debugging & verifying the slow paths.");
29 DECLARE_FLAG(bool, trace_optimized_ic_calls); 29 DECLARE_FLAG(bool, trace_optimized_ic_calls);
30 DEFINE_FLAG(bool, verify_incoming_contexts, false, "");
30 31
31 32
32 // Input parameters: 33 // Input parameters:
33 // ESP : points to return address. 34 // ESP : points to return address.
34 // ESP + 4 : address of last argument in argument array. 35 // ESP + 4 : address of last argument in argument array.
35 // ESP + 4*EDX : address of first argument in argument array. 36 // ESP + 4*EDX : address of first argument in argument array.
36 // ESP + 4*EDX + 4 : address of return value. 37 // ESP + 4*EDX + 4 : address of return value.
37 // ECX : address of the runtime function to call. 38 // ECX : address of the runtime function to call.
38 // EDX : number of arguments to the call. 39 // EDX : number of arguments to the call.
39 // Must preserve callee saved registers EDI and EBX. 40 // Must preserve callee saved registers EDI and EBX.
40 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) { 41 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) {
41 const intptr_t isolate_offset = NativeArguments::isolate_offset(); 42 const intptr_t isolate_offset = NativeArguments::isolate_offset();
42 const intptr_t argc_tag_offset = NativeArguments::argc_tag_offset(); 43 const intptr_t argc_tag_offset = NativeArguments::argc_tag_offset();
43 const intptr_t argv_offset = NativeArguments::argv_offset(); 44 const intptr_t argv_offset = NativeArguments::argv_offset();
44 const intptr_t retval_offset = NativeArguments::retval_offset(); 45 const intptr_t retval_offset = NativeArguments::retval_offset();
45 46
46 __ EnterFrame(0); 47 __ EnterFrame(0);
47 48
48 // Load current Isolate pointer from Context structure into EAX. 49 // Load current Isolate pointer from Context structure into EAX.
49 __ movl(EAX, FieldAddress(CTX, Context::isolate_offset())); 50 __ movl(EAX, FieldAddress(CTX, Context::isolate_offset()));
50 51
51 // Save exit frame information to enable stack walking as we are about 52 // Save exit frame information to enable stack walking as we are about
52 // to transition to Dart VM C++ code. 53 // to transition to Dart VM C++ code.
53 __ movl(Address(EAX, Isolate::top_exit_frame_info_offset()), ESP); 54 __ movl(Address(EAX, Isolate::top_exit_frame_info_offset()), ESP);
54 55
56 #if defined(DEBUG)
57 if (FLAG_verify_incoming_contexts) {
58 Label ok;
59 // Check that the isolate's saved ctx is null.
60 const Immediate& raw_null =
61 Immediate(reinterpret_cast<intptr_t>(Object::null()));
62 __ cmpl(Address(EAX, Isolate::top_context_offset()), raw_null);
63 __ j(EQUAL, &ok, Assembler::kNearJump);
64 __ Stop("Found non-null incoming top context: call to runtime stub");
65 __ Bind(&ok);
66 }
67 #endif
68
55 // Save current Context pointer into Isolate structure. 69 // Save current Context pointer into Isolate structure.
56 __ movl(Address(EAX, Isolate::top_context_offset()), CTX); 70 __ movl(Address(EAX, Isolate::top_context_offset()), CTX);
57 71
58 // Cache Isolate pointer into CTX while executing runtime code. 72 // Cache Isolate pointer into CTX while executing runtime code.
59 __ movl(CTX, EAX); 73 __ movl(CTX, EAX);
60 74
61 #if defined(DEBUG) 75 #if defined(DEBUG)
62 { Label ok; 76 { Label ok;
63 // Check that we are always entering from Dart code. 77 // Check that we are always entering from Dart code.
64 __ movl(EAX, Address(CTX, Isolate::vm_tag_offset())); 78 __ movl(EAX, Address(CTX, Isolate::vm_tag_offset()));
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 167
154 __ EnterFrame(0); 168 __ EnterFrame(0);
155 169
156 // Load current Isolate pointer from Context structure into EDI. 170 // Load current Isolate pointer from Context structure into EDI.
157 __ movl(EDI, FieldAddress(CTX, Context::isolate_offset())); 171 __ movl(EDI, FieldAddress(CTX, Context::isolate_offset()));
158 172
159 // Save exit frame information to enable stack walking as we are about 173 // Save exit frame information to enable stack walking as we are about
160 // to transition to dart VM code. 174 // to transition to dart VM code.
161 __ movl(Address(EDI, Isolate::top_exit_frame_info_offset()), ESP); 175 __ movl(Address(EDI, Isolate::top_exit_frame_info_offset()), ESP);
162 176
177 #if defined(DEBUG)
178 if (FLAG_verify_incoming_contexts) {
179 Label ok;
180 // Check that the isolate's saved ctx is null.
181 const Immediate& raw_null =
182 Immediate(reinterpret_cast<intptr_t>(Object::null()));
183 __ cmpl(Address(EDI, Isolate::top_context_offset()), raw_null);
184 __ j(EQUAL, &ok, Assembler::kNearJump);
185 __ Stop("Found non-null incoming top context: "
186 "call to native c function stub");
187 __ Bind(&ok);
188 }
189 #endif
190
163 // Save current Context pointer into Isolate structure. 191 // Save current Context pointer into Isolate structure.
164 __ movl(Address(EDI, Isolate::top_context_offset()), CTX); 192 __ movl(Address(EDI, Isolate::top_context_offset()), CTX);
165 193
166 // Cache Isolate pointer into CTX while executing native code. 194 // Cache Isolate pointer into CTX while executing native code.
167 __ movl(CTX, EDI); 195 __ movl(CTX, EDI);
168 196
169 #if defined(DEBUG) 197 #if defined(DEBUG)
170 { Label ok; 198 { Label ok;
171 // Check that we are always entering from Dart code. 199 // Check that we are always entering from Dart code.
172 __ movl(EDI, Address(CTX, Isolate::vm_tag_offset())); 200 __ movl(EDI, Address(CTX, Isolate::vm_tag_offset()));
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 281
254 __ EnterFrame(0); 282 __ EnterFrame(0);
255 283
256 // Load current Isolate pointer from Context structure into EDI. 284 // Load current Isolate pointer from Context structure into EDI.
257 __ movl(EDI, FieldAddress(CTX, Context::isolate_offset())); 285 __ movl(EDI, FieldAddress(CTX, Context::isolate_offset()));
258 286
259 // Save exit frame information to enable stack walking as we are about 287 // Save exit frame information to enable stack walking as we are about
260 // to transition to dart VM code. 288 // to transition to dart VM code.
261 __ movl(Address(EDI, Isolate::top_exit_frame_info_offset()), ESP); 289 __ movl(Address(EDI, Isolate::top_exit_frame_info_offset()), ESP);
262 290
291 #if defined(DEBUG)
292 if (FLAG_verify_incoming_contexts) {
293 Label ok;
294 // Check that the isolate's saved ctx is null.
295 const Immediate& raw_null =
296 Immediate(reinterpret_cast<intptr_t>(Object::null()));
297 __ cmpl(Address(EDI, Isolate::top_context_offset()), raw_null);
298 __ j(EQUAL, &ok, Assembler::kNearJump);
299 __ Stop("Found non-null incoming top context: "
300 "call to bootstrap c function stub");
301 __ Bind(&ok);
302 }
303 #endif
304
263 // Save current Context pointer into Isolate structure. 305 // Save current Context pointer into Isolate structure.
264 __ movl(Address(EDI, Isolate::top_context_offset()), CTX); 306 __ movl(Address(EDI, Isolate::top_context_offset()), CTX);
265 307
266 // Cache Isolate pointer into CTX while executing native code. 308 // Cache Isolate pointer into CTX while executing native code.
267 __ movl(CTX, EDI); 309 __ movl(CTX, EDI);
268 310
269 #if defined(DEBUG) 311 #if defined(DEBUG)
270 { Label ok; 312 { Label ok;
271 // Check that we are always entering from Dart code. 313 // Check that we are always entering from Dart code.
272 __ movl(EDI, Address(CTX, Isolate::vm_tag_offset())); 314 __ movl(EDI, Address(CTX, Isolate::vm_tag_offset()));
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 // Note that VisitObjectPointers will find this saved Context pointer during 875 // Note that VisitObjectPointers will find this saved Context pointer during
834 // GC marking, since it traverses any information between SP and 876 // GC marking, since it traverses any information between SP and
835 // FP - kExitLinkSlotFromEntryFp. 877 // FP - kExitLinkSlotFromEntryFp.
836 // EntryFrame::SavedContext reads the context saved in this frame. 878 // EntryFrame::SavedContext reads the context saved in this frame.
837 // The constant kSavedContextSlotFromEntryFp must be kept in sync with 879 // The constant kSavedContextSlotFromEntryFp must be kept in sync with
838 // the code below. 880 // the code below.
839 ASSERT(kSavedContextSlotFromEntryFp == -6); 881 ASSERT(kSavedContextSlotFromEntryFp == -6);
840 __ movl(ECX, Address(EDI, Isolate::top_context_offset())); 882 __ movl(ECX, Address(EDI, Isolate::top_context_offset()));
841 __ pushl(ECX); 883 __ pushl(ECX);
842 884
885 // TODO(turnidge): This code should probably be emitted all the time
886 // on all architectures but I am leaving it under DEBUG/flag for
887 // now.
888 #if defined(DEBUG)
889 if (FLAG_verify_incoming_contexts) {
890 // Clear Context pointer in Isolate structure.
891 const Immediate& raw_null =
892 Immediate(reinterpret_cast<intptr_t>(Object::null()));
893 __ movl(Address(EDI, Isolate::top_context_offset()), raw_null);
894 }
895 #endif
896
843 // Load arguments descriptor array into EDX. 897 // Load arguments descriptor array into EDX.
844 __ movl(EDX, Address(EBP, kArgumentsDescOffset)); 898 __ movl(EDX, Address(EBP, kArgumentsDescOffset));
845 __ movl(EDX, Address(EDX, VMHandles::kOffsetOfRawPtrInHandle)); 899 __ movl(EDX, Address(EDX, VMHandles::kOffsetOfRawPtrInHandle));
846 900
847 // Load number of arguments into EBX. 901 // Load number of arguments into EBX.
848 __ movl(EBX, FieldAddress(EDX, ArgumentsDescriptor::count_offset())); 902 __ movl(EBX, FieldAddress(EDX, ArgumentsDescriptor::count_offset()));
849 __ SmiUntag(EBX); 903 __ SmiUntag(EBX);
850 904
851 // Set up arguments for the dart call. 905 // Set up arguments for the dart call.
852 Label push_arguments; 906 Label push_arguments;
(...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after
1940 const Register temp = ECX; 1994 const Register temp = ECX;
1941 __ movl(left, Address(ESP, 2 * kWordSize)); 1995 __ movl(left, Address(ESP, 2 * kWordSize));
1942 __ movl(right, Address(ESP, 1 * kWordSize)); 1996 __ movl(right, Address(ESP, 1 * kWordSize));
1943 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); 1997 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp);
1944 __ ret(); 1998 __ ret();
1945 } 1999 }
1946 2000
1947 } // namespace dart 2001 } // namespace dart
1948 2002
1949 #endif // defined TARGET_ARCH_IA32 2003 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/stack_frame.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698