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

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

Issue 15110003: Make deoptimization architecture dependent (it depends on the frame layout). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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_x64.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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 // This stub translates optimized frame into unoptimized frame. The optimized 316 // This stub translates optimized frame into unoptimized frame. The optimized
317 // frame can contain values in registers and on stack, the unoptimized 317 // frame can contain values in registers and on stack, the unoptimized
318 // frame contains all values on stack. 318 // frame contains all values on stack.
319 // Deoptimization occurs in following steps: 319 // Deoptimization occurs in following steps:
320 // - Push all registers that can contain values. 320 // - Push all registers that can contain values.
321 // - Call C routine to copy the stack and saved registers into temporary buffer. 321 // - Call C routine to copy the stack and saved registers into temporary buffer.
322 // - Adjust caller's frame to correct unoptimized frame size. 322 // - Adjust caller's frame to correct unoptimized frame size.
323 // - Fill the unoptimized frame. 323 // - Fill the unoptimized frame.
324 // - Materialize objects that require allocation (e.g. Double instances). 324 // - Materialize objects that require allocation (e.g. Double instances).
325 // GC can occur only after frame is fully rewritten. 325 // GC can occur only after frame is fully rewritten.
326 // Stack after EnterFrame(0) below: 326 // Stack after EnterDartFrame(0) below:
327 // +------------------+ 327 // +------------------+
328 // | Saved FP | <- TOS 328 // | PC marker | <- TOS
329 // +------------------+
330 // | Saved FP | <- FP of stub
329 // +------------------+ 331 // +------------------+
330 // | return-address | (deoptimization point) 332 // | return-address | (deoptimization point)
331 // +------------------+ 333 // +------------------+
332 // | optimized frame | 334 // | ... | <- SP of optimized frame
333 // | ... |
334 // 335 //
335 // Parts of the code cannot GC, part of the code can GC. 336 // Parts of the code cannot GC, part of the code can GC.
336 static void GenerateDeoptimizationSequence(Assembler* assembler, 337 static void GenerateDeoptimizationSequence(Assembler* assembler,
337 bool preserve_eax) { 338 bool preserve_result) {
338 __ EnterFrame(0); 339 // Leaf runtime function DeoptimizeCopyFrame expects a Dart frame.
340 __ EnterDartFrame(0);
339 // The code in this frame may not cause GC. kDeoptimizeCopyFrameRuntimeEntry 341 // The code in this frame may not cause GC. kDeoptimizeCopyFrameRuntimeEntry
340 // and kDeoptimizeFillFrameRuntimeEntry are leaf runtime calls. 342 // and kDeoptimizeFillFrameRuntimeEntry are leaf runtime calls.
341 const intptr_t saved_eax_offset_from_ebp = -(kNumberOfCpuRegisters - EAX); 343 const intptr_t saved_result_slot_from_fp =
344 kFirstLocalSlotFromFp + 1 - (kNumberOfCpuRegisters - EAX);
342 // Result in EAX is preserved as part of pushing all registers below. 345 // Result in EAX is preserved as part of pushing all registers below.
343 346
344 // Push registers in their enumeration order: lowest register number at 347 // Push registers in their enumeration order: lowest register number at
345 // lowest address. 348 // lowest address.
346 for (intptr_t i = kNumberOfCpuRegisters - 1; i >= 0; i--) { 349 for (intptr_t i = kNumberOfCpuRegisters - 1; i >= 0; i--) {
347 __ pushl(static_cast<Register>(i)); 350 __ pushl(static_cast<Register>(i));
348 } 351 }
349 __ subl(ESP, Immediate(kNumberOfXmmRegisters * kFpuRegisterSize)); 352 __ subl(ESP, Immediate(kNumberOfXmmRegisters * kFpuRegisterSize));
350 intptr_t offset = 0; 353 intptr_t offset = 0;
351 for (intptr_t reg_idx = 0; reg_idx < kNumberOfXmmRegisters; ++reg_idx) { 354 for (intptr_t reg_idx = 0; reg_idx < kNumberOfXmmRegisters; ++reg_idx) {
352 XmmRegister xmm_reg = static_cast<XmmRegister>(reg_idx); 355 XmmRegister xmm_reg = static_cast<XmmRegister>(reg_idx);
353 __ movups(Address(ESP, offset), xmm_reg); 356 __ movups(Address(ESP, offset), xmm_reg);
354 offset += kFpuRegisterSize; 357 offset += kFpuRegisterSize;
355 } 358 }
356 359
357 __ movl(ECX, ESP); // Preserve saved registers block. 360 __ movl(ECX, ESP); // Preserve saved registers block.
358 __ ReserveAlignedFrameSpace(1 * kWordSize); 361 __ ReserveAlignedFrameSpace(1 * kWordSize);
359 __ movl(Address(ESP, 0), ECX); // Start of register block. 362 __ movl(Address(ESP, 0), ECX); // Start of register block.
360 __ CallRuntime(kDeoptimizeCopyFrameRuntimeEntry); 363 __ CallRuntime(kDeoptimizeCopyFrameRuntimeEntry);
361 // Result (EAX) is stack-size (FP - SP) in bytes, incl. the return address. 364 // Result (EAX) is stack-size (FP - SP) in bytes.
362 365
363 if (preserve_eax) { 366 if (preserve_result) {
364 // Restore result into EBX temporarily. 367 // Restore result into EBX temporarily.
365 __ movl(EBX, Address(EBP, saved_eax_offset_from_ebp * kWordSize)); 368 __ movl(EBX, Address(EBP, saved_result_slot_from_fp * kWordSize));
366 } 369 }
367 370
368 __ LeaveFrame(); 371 __ LeaveFrame();
369 __ popl(EDX); // Preserve return address. 372 __ popl(EDX); // Preserve return address.
370 __ movl(ESP, EBP); 373 __ movl(ESP, EBP); // Discard optimized frame.
371 __ subl(ESP, EAX); 374 __ subl(ESP, EAX); // Reserve space for deoptimized frame.
372 __ movl(Address(ESP, 0), EDX); 375 __ pushl(EDX); // Restore return address.
373 376
374 __ EnterFrame(0); 377 // Leaf runtime function DeoptimizeFillFrame expects a Dart frame.
375 __ movl(ECX, ESP); // Get last FP address. 378 __ EnterDartFrame(0);
376 if (preserve_eax) { 379 if (preserve_result) {
377 __ pushl(EBX); // Preserve result. 380 __ pushl(EBX); // Preserve result as first local.
378 } 381 }
379 __ ReserveAlignedFrameSpace(1 * kWordSize); 382 __ ReserveAlignedFrameSpace(1 * kWordSize);
380 __ movl(Address(ESP, 0), ECX); 383 __ movl(Address(ESP, 0), EBP); // Pass last FP as parameter on stack.
381 __ CallRuntime(kDeoptimizeFillFrameRuntimeEntry); 384 __ CallRuntime(kDeoptimizeFillFrameRuntimeEntry);
382 // Result (EAX) is our FP. 385 if (preserve_result) {
383 if (preserve_eax) {
384 // Restore result into EBX. 386 // Restore result into EBX.
385 __ movl(EBX, Address(EBP, -1 * kWordSize)); 387 __ movl(EBX, Address(EBP, kFirstLocalSlotFromFp * kWordSize));
386 } 388 }
387 // Code above cannot cause GC. 389 // Code above cannot cause GC.
388 __ LeaveFrame(); 390 __ LeaveFrame();
389 __ movl(EBP, EAX);
390 391
391 // Frame is fully rewritten at this point and it is safe to perform a GC. 392 // Frame is fully rewritten at this point and it is safe to perform a GC.
392 // Materialize any objects that were deferred by FillFrame because they 393 // Materialize any objects that were deferred by FillFrame because they
393 // require allocation. 394 // require allocation.
394 __ EnterStubFrame(); 395 __ EnterStubFrame();
395 if (preserve_eax) { 396 if (preserve_result) {
396 __ pushl(EBX); // Preserve result, it will be GC-d here. 397 __ pushl(EBX); // Preserve result, it will be GC-d here.
397 } 398 }
398 __ pushl(Immediate(Smi::RawValue(0))); // Space for the result. 399 __ pushl(Immediate(Smi::RawValue(0))); // Space for the result.
399 __ CallRuntime(kDeoptimizeMaterializeRuntimeEntry); 400 __ CallRuntime(kDeoptimizeMaterializeRuntimeEntry);
400 // Result tells stub how many bytes to remove from the expression stack 401 // Result tells stub how many bytes to remove from the expression stack
401 // of the bottom-most frame. They were used as materialization arguments. 402 // of the bottom-most frame. They were used as materialization arguments.
402 __ popl(EBX); 403 __ popl(EBX);
403 __ SmiUntag(EBX); 404 __ SmiUntag(EBX);
404 if (preserve_eax) { 405 if (preserve_result) {
405 __ popl(EAX); // Restore result. 406 __ popl(EAX); // Restore result.
406 } 407 }
407 __ LeaveFrame(); 408 __ LeaveFrame();
408 409
409 __ popl(ECX); // Pop return address. 410 __ popl(ECX); // Pop return address.
410 __ addl(ESP, EBX); // Remove materialization arguments. 411 __ addl(ESP, EBX); // Remove materialization arguments.
411 __ pushl(ECX); // Push return address. 412 __ pushl(ECX); // Push return address.
412 __ ret(); 413 __ ret();
413 } 414 }
414 415
(...skipping 1719 matching lines...) Expand 10 before | Expand all | Expand 10 after
2134 __ Bind(&done); 2135 __ Bind(&done);
2135 __ popl(temp); 2136 __ popl(temp);
2136 __ popl(right); 2137 __ popl(right);
2137 __ popl(left); 2138 __ popl(left);
2138 __ ret(); 2139 __ ret();
2139 } 2140 }
2140 2141
2141 } // namespace dart 2142 } // namespace dart
2142 2143
2143 #endif // defined TARGET_ARCH_IA32 2144 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/stub_code_arm.cc ('k') | runtime/vm/stub_code_x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698