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

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

Issue 1192103004: VM: New calling convention for generated code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: preserve CODE_REG in ARM Integer_shl intrinsic. Created 5 years, 3 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
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 __ AddImmediate(ESP, Immediate(-INT32_SIZEOF(NativeArguments))); 73 __ AddImmediate(ESP, Immediate(-INT32_SIZEOF(NativeArguments)));
74 if (OS::ActivationFrameAlignment() > 1) { 74 if (OS::ActivationFrameAlignment() > 1) {
75 __ andl(ESP, Immediate(~(OS::ActivationFrameAlignment() - 1))); 75 __ andl(ESP, Immediate(~(OS::ActivationFrameAlignment() - 1)));
76 } 76 }
77 77
78 // Pass NativeArguments structure by value and call runtime. 78 // Pass NativeArguments structure by value and call runtime.
79 __ movl(Address(ESP, thread_offset), THR); // Set thread in NativeArgs. 79 __ movl(Address(ESP, thread_offset), THR); // Set thread in NativeArgs.
80 // There are no runtime calls to closures, so we do not need to set the tag 80 // There are no runtime calls to closures, so we do not need to set the tag
81 // bits kClosureFunctionBit and kInstanceFunctionBit in argc_tag_. 81 // bits kClosureFunctionBit and kInstanceFunctionBit in argc_tag_.
82 __ movl(Address(ESP, argc_tag_offset), EDX); // Set argc in NativeArguments. 82 __ movl(Address(ESP, argc_tag_offset), EDX); // Set argc in NativeArguments.
83 __ leal(EAX, Address(EBP, EDX, TIMES_4, 1 * kWordSize)); // Compute argv. 83 // Compute argv.
84 __ leal(EAX, Address(EBP, EDX, TIMES_4, kParamEndSlotFromFp * kWordSize));
84 __ movl(Address(ESP, argv_offset), EAX); // Set argv in NativeArguments. 85 __ movl(Address(ESP, argv_offset), EAX); // Set argv in NativeArguments.
85 __ addl(EAX, Immediate(1 * kWordSize)); // Retval is next to 1st argument. 86 __ addl(EAX, Immediate(1 * kWordSize)); // Retval is next to 1st argument.
86 __ movl(Address(ESP, retval_offset), EAX); // Set retval in NativeArguments. 87 __ movl(Address(ESP, retval_offset), EAX); // Set retval in NativeArguments.
87 __ call(ECX); 88 __ call(ECX);
88 89
89 // Mark that the isolate is executing Dart code. EDI is callee saved. 90 // Mark that the isolate is executing Dart code. EDI is callee saved.
90 __ movl(Address(EDI, Isolate::vm_tag_offset()), 91 __ movl(Address(EDI, Isolate::vm_tag_offset()),
91 Immediate(VMTag::kDartTagId)); 92 Immediate(VMTag::kDartTagId));
92 93
93 // Reset exit frame information in Isolate structure. 94 // Reset exit frame information in Isolate structure.
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 // - Materialize objects that require allocation (e.g. Double instances). 363 // - Materialize objects that require allocation (e.g. Double instances).
363 // GC can occur only after frame is fully rewritten. 364 // GC can occur only after frame is fully rewritten.
364 // Stack after EnterDartFrame(0) below: 365 // Stack after EnterDartFrame(0) below:
365 // +------------------+ 366 // +------------------+
366 // | PC marker | <- TOS 367 // | PC marker | <- TOS
367 // +------------------+ 368 // +------------------+
368 // | Saved FP | <- FP of stub 369 // | Saved FP | <- FP of stub
369 // +------------------+ 370 // +------------------+
370 // | return-address | (deoptimization point) 371 // | return-address | (deoptimization point)
371 // +------------------+ 372 // +------------------+
373 // | Saved CODE_REG |
374 // +------------------+
372 // | ... | <- SP of optimized frame 375 // | ... | <- SP of optimized frame
373 // 376 //
374 // Parts of the code cannot GC, part of the code can GC. 377 // Parts of the code cannot GC, part of the code can GC.
375 static void GenerateDeoptimizationSequence(Assembler* assembler, 378 static void GenerateDeoptimizationSequence(Assembler* assembler,
376 bool preserve_result) { 379 DeoptStubKind kind) {
377 // Leaf runtime function DeoptimizeCopyFrame expects a Dart frame. 380 // Leaf runtime function DeoptimizeCopyFrame expects a Dart frame.
378 __ EnterDartFrame(0); 381 __ EnterDartFrame(0);
379 // The code in this frame may not cause GC. kDeoptimizeCopyFrameRuntimeEntry 382 // The code in this frame may not cause GC. kDeoptimizeCopyFrameRuntimeEntry
380 // and kDeoptimizeFillFrameRuntimeEntry are leaf runtime calls. 383 // and kDeoptimizeFillFrameRuntimeEntry are leaf runtime calls.
381 const intptr_t saved_result_slot_from_fp = 384 const intptr_t saved_result_slot_from_fp =
382 kFirstLocalSlotFromFp + 1 - (kNumberOfCpuRegisters - EAX); 385 kFirstLocalSlotFromFp + 1 - (kNumberOfCpuRegisters - EAX);
383 // Result in EAX is preserved as part of pushing all registers below. 386 // Result in EAX is preserved as part of pushing all registers below.
384 387
385 // Push registers in their enumeration order: lowest register number at 388 // Push registers in their enumeration order: lowest register number at
386 // lowest address. 389 // lowest address.
387 for (intptr_t i = kNumberOfCpuRegisters - 1; i >= 0; i--) { 390 for (intptr_t i = kNumberOfCpuRegisters - 1; i >= 0; i--) {
388 __ pushl(static_cast<Register>(i)); 391 if (i == CODE_REG) {
392 __ pushl(Address(EBP, 2 * kWordSize));
393 } else {
394 __ pushl(static_cast<Register>(i));
395 }
389 } 396 }
390 __ subl(ESP, Immediate(kNumberOfXmmRegisters * kFpuRegisterSize)); 397 __ subl(ESP, Immediate(kNumberOfXmmRegisters * kFpuRegisterSize));
391 intptr_t offset = 0; 398 intptr_t offset = 0;
392 for (intptr_t reg_idx = 0; reg_idx < kNumberOfXmmRegisters; ++reg_idx) { 399 for (intptr_t reg_idx = 0; reg_idx < kNumberOfXmmRegisters; ++reg_idx) {
393 XmmRegister xmm_reg = static_cast<XmmRegister>(reg_idx); 400 XmmRegister xmm_reg = static_cast<XmmRegister>(reg_idx);
394 __ movups(Address(ESP, offset), xmm_reg); 401 __ movups(Address(ESP, offset), xmm_reg);
395 offset += kFpuRegisterSize; 402 offset += kFpuRegisterSize;
396 } 403 }
397 404
398 __ movl(ECX, ESP); // Preserve saved registers block. 405 __ movl(ECX, ESP); // Preserve saved registers block.
399 __ ReserveAlignedFrameSpace(1 * kWordSize); 406 __ ReserveAlignedFrameSpace(2 * kWordSize);
400 __ movl(Address(ESP, 0), ECX); // Start of register block. 407 __ movl(Address(ESP, 0 * kWordSize), ECX); // Start of register block.
401 __ CallRuntime(kDeoptimizeCopyFrameRuntimeEntry, 1); 408 __ movl(Address(ESP, 1 * kWordSize), Immediate(kind == kLazyDeopt ? 1 : 0));
409 __ CallRuntime(kDeoptimizeCopyFrameRuntimeEntry, 2);
402 // Result (EAX) is stack-size (FP - SP) in bytes. 410 // Result (EAX) is stack-size (FP - SP) in bytes.
403 411
412 const bool preserve_result = (kind == kLazyDeopt);
404 if (preserve_result) { 413 if (preserve_result) {
405 // Restore result into EBX temporarily. 414 // Restore result into EBX temporarily.
406 __ movl(EBX, Address(EBP, saved_result_slot_from_fp * kWordSize)); 415 __ movl(EBX, Address(EBP, saved_result_slot_from_fp * kWordSize));
407 } 416 }
408 417
409 __ LeaveFrame(); 418 __ LeaveFrame();
410 __ popl(EDX); // Preserve return address. 419 __ popl(EDX); // Preserve return address.
411 __ movl(ESP, EBP); // Discard optimized frame. 420 __ movl(ESP, EBP); // Discard optimized frame.
412 __ subl(ESP, EAX); // Reserve space for deoptimized frame. 421 __ subl(ESP, EAX); // Reserve space for deoptimized frame.
413 __ pushl(EDX); // Restore return address. 422 __ pushl(EDX); // Restore return address.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 462
454 463
455 // TOS: return address + call-instruction-size (5 bytes). 464 // TOS: return address + call-instruction-size (5 bytes).
456 // EAX: result, must be preserved 465 // EAX: result, must be preserved
457 void StubCode::GenerateDeoptimizeLazyStub(Assembler* assembler) { 466 void StubCode::GenerateDeoptimizeLazyStub(Assembler* assembler) {
458 // Correct return address to point just after the call that is being 467 // Correct return address to point just after the call that is being
459 // deoptimized. 468 // deoptimized.
460 __ popl(EBX); 469 __ popl(EBX);
461 __ subl(EBX, Immediate(CallPattern::pattern_length_in_bytes())); 470 __ subl(EBX, Immediate(CallPattern::pattern_length_in_bytes()));
462 __ pushl(EBX); 471 __ pushl(EBX);
463 GenerateDeoptimizationSequence(assembler, true); // Preserve EAX. 472 GenerateDeoptimizationSequence(assembler, kLazyDeopt);
464 } 473 }
465 474
466 475
467 void StubCode::GenerateDeoptimizeStub(Assembler* assembler) { 476 void StubCode::GenerateDeoptimizeStub(Assembler* assembler) {
468 GenerateDeoptimizationSequence(assembler, false); // Don't preserve EAX. 477 GenerateDeoptimizationSequence(assembler, kEagerDeopt);
469 } 478 }
470 479
471 480
472 static void GenerateDispatcherCode(Assembler* assembler, 481 static void GenerateDispatcherCode(Assembler* assembler,
473 Label* call_target_function) { 482 Label* call_target_function) {
474 __ Comment("NoSuchMethodDispatch"); 483 __ Comment("NoSuchMethodDispatch");
475 // When lazily generated invocation dispatchers are disabled, the 484 // When lazily generated invocation dispatchers are disabled, the
476 // miss-handler may return null. 485 // miss-handler may return null.
477 const Immediate& raw_null = 486 const Immediate& raw_null =
478 Immediate(reinterpret_cast<intptr_t>(Object::null())); 487 Immediate(reinterpret_cast<intptr_t>(Object::null()));
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 __ popl(EDX); // Pop array length argument (preserved). 686 __ popl(EDX); // Pop array length argument (preserved).
678 __ popl(EAX); // Pop return value from return slot. 687 __ popl(EAX); // Pop return value from return slot.
679 __ LeaveFrame(); 688 __ LeaveFrame();
680 __ ret(); 689 __ ret();
681 } 690 }
682 691
683 692
684 // Called when invoking dart code from C++ (VM code). 693 // Called when invoking dart code from C++ (VM code).
685 // Input parameters: 694 // Input parameters:
686 // ESP : points to return address. 695 // ESP : points to return address.
687 // ESP + 4 : entrypoint of the dart function to call. 696 // ESP + 4 : code object of the dart function to call.
688 // ESP + 8 : arguments descriptor array. 697 // ESP + 8 : arguments descriptor array.
689 // ESP + 12 : arguments array. 698 // ESP + 12 : arguments array.
690 // ESP + 16 : current thread. 699 // ESP + 16 : current thread.
691 // Uses EAX, EDX, ECX, EDI as temporary registers. 700 // Uses EAX, EDX, ECX, EDI as temporary registers.
692 void StubCode::GenerateInvokeDartCodeStub(Assembler* assembler) { 701 void StubCode::GenerateInvokeDartCodeStub(Assembler* assembler) {
693 const intptr_t kEntryPointOffset = 2 * kWordSize; 702 const intptr_t kTargetCodeOffset = 2 * kWordSize;
694 const intptr_t kArgumentsDescOffset = 3 * kWordSize; 703 const intptr_t kArgumentsDescOffset = 3 * kWordSize;
695 const intptr_t kArgumentsOffset = 4 * kWordSize; 704 const intptr_t kArgumentsOffset = 4 * kWordSize;
696 const intptr_t kThreadOffset = 5 * kWordSize; 705 const intptr_t kThreadOffset = 5 * kWordSize;
697 706
698 // Save frame pointer coming in. 707 // Save frame pointer coming in.
699 __ EnterFrame(0); 708 __ EnterFrame(0);
700 709
701 // Save C++ ABI callee-saved registers. 710 // Save C++ ABI callee-saved registers.
702 __ pushl(EBX); 711 __ pushl(EBX);
703 __ pushl(ESI); 712 __ pushl(ESI);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 758
750 __ Bind(&push_arguments); 759 __ Bind(&push_arguments);
751 __ movl(ECX, Address(EDI, EAX, TIMES_4, 0)); 760 __ movl(ECX, Address(EDI, EAX, TIMES_4, 0));
752 __ pushl(ECX); 761 __ pushl(ECX);
753 __ incl(EAX); 762 __ incl(EAX);
754 __ cmpl(EAX, EBX); 763 __ cmpl(EAX, EBX);
755 __ j(LESS, &push_arguments, Assembler::kNearJump); 764 __ j(LESS, &push_arguments, Assembler::kNearJump);
756 __ Bind(&done_push_arguments); 765 __ Bind(&done_push_arguments);
757 766
758 // Call the dart code entrypoint. 767 // Call the dart code entrypoint.
759 __ call(Address(EBP, kEntryPointOffset)); 768 __ movl(EAX, Address(EBP, kTargetCodeOffset));
769 __ movl(EAX, Address(EAX, VMHandles::kOffsetOfRawPtrInHandle));
770 __ call(FieldAddress(EAX, Code::entry_point_offset()));
760 771
761 // Reread the arguments descriptor array to obtain the number of passed 772 // Reread the arguments descriptor array to obtain the number of passed
762 // arguments. 773 // arguments.
763 __ movl(EDX, Address(EBP, kArgumentsDescOffset)); 774 __ movl(EDX, Address(EBP, kArgumentsDescOffset));
764 __ movl(EDX, Address(EDX, VMHandles::kOffsetOfRawPtrInHandle)); 775 __ movl(EDX, Address(EDX, VMHandles::kOffsetOfRawPtrInHandle));
765 __ movl(EDX, FieldAddress(EDX, ArgumentsDescriptor::count_offset())); 776 __ movl(EDX, FieldAddress(EDX, ArgumentsDescriptor::count_offset()));
766 // Get rid of arguments pushed on the stack. 777 // Get rid of arguments pushed on the stack.
767 __ leal(ESP, Address(ESP, EDX, TIMES_2, 0)); // EDX is a Smi. 778 __ leal(ESP, Address(ESP, EDX, TIMES_2, 0)); // EDX is a Smi.
768 779
769 // Restore the saved top exit frame info and top resource back into the 780 // Restore the saved top exit frame info and top resource back into the
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 1005
995 1006
996 // Called for inline allocation of objects. 1007 // Called for inline allocation of objects.
997 // Input parameters: 1008 // Input parameters:
998 // ESP + 4 : type arguments object (only if class is parameterized). 1009 // ESP + 4 : type arguments object (only if class is parameterized).
999 // ESP : points to return address. 1010 // ESP : points to return address.
1000 // Uses EAX, EBX, ECX, EDX, EDI as temporary registers. 1011 // Uses EAX, EBX, ECX, EDX, EDI as temporary registers.
1001 // Returns patch_code_pc offset where patching code for disabling the stub 1012 // Returns patch_code_pc offset where patching code for disabling the stub
1002 // has been generated (similar to regularly generated Dart code). 1013 // has been generated (similar to regularly generated Dart code).
1003 void StubCode::GenerateAllocationStubForClass( 1014 void StubCode::GenerateAllocationStubForClass(
1004 Assembler* assembler, const Class& cls, 1015 Assembler* assembler, const Class& cls) {
1005 uword* entry_patch_offset, uword* patch_code_pc_offset) {
1006 *entry_patch_offset = assembler->CodeSize();
1007 const intptr_t kObjectTypeArgumentsOffset = 1 * kWordSize; 1016 const intptr_t kObjectTypeArgumentsOffset = 1 * kWordSize;
1008 const Immediate& raw_null = 1017 const Immediate& raw_null =
1009 Immediate(reinterpret_cast<intptr_t>(Object::null())); 1018 Immediate(reinterpret_cast<intptr_t>(Object::null()));
1010 // The generated code is different if the class is parameterized. 1019 // The generated code is different if the class is parameterized.
1011 const bool is_cls_parameterized = cls.NumTypeArguments() > 0; 1020 const bool is_cls_parameterized = cls.NumTypeArguments() > 0;
1012 ASSERT(!is_cls_parameterized || 1021 ASSERT(!is_cls_parameterized ||
1013 (cls.type_arguments_field_offset() != Class::kNoTypeArguments)); 1022 (cls.type_arguments_field_offset() != Class::kNoTypeArguments));
1014 // kInlineInstanceSize is a constant used as a threshold for determining 1023 // kInlineInstanceSize is a constant used as a threshold for determining
1015 // when the object initialization should be done as a loop or as 1024 // when the object initialization should be done as a loop or as
1016 // straight line code. 1025 // straight line code.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1118 __ pushl(raw_null); // Push null type arguments. 1127 __ pushl(raw_null); // Push null type arguments.
1119 } 1128 }
1120 __ CallRuntime(kAllocateObjectRuntimeEntry, 2); // Allocate object. 1129 __ CallRuntime(kAllocateObjectRuntimeEntry, 2); // Allocate object.
1121 __ popl(EAX); // Pop argument (type arguments of object). 1130 __ popl(EAX); // Pop argument (type arguments of object).
1122 __ popl(EAX); // Pop argument (class of object). 1131 __ popl(EAX); // Pop argument (class of object).
1123 __ popl(EAX); // Pop result (newly allocated object). 1132 __ popl(EAX); // Pop result (newly allocated object).
1124 // EAX: new object 1133 // EAX: new object
1125 // Restore the frame pointer. 1134 // Restore the frame pointer.
1126 __ LeaveFrame(); 1135 __ LeaveFrame();
1127 __ ret(); 1136 __ ret();
1128 // Emit function patching code. This will be swapped with the first 5 bytes
1129 // at entry point.
1130 *patch_code_pc_offset = assembler->CodeSize();
1131 __ Jmp(*StubCode::FixAllocationStubTarget_entry());
1132 } 1137 }
1133 1138
1134 1139
1135 // Called for invoking "dynamic noSuchMethod(Invocation invocation)" function 1140 // Called for invoking "dynamic noSuchMethod(Invocation invocation)" function
1136 // from the entry code of a dart function after an error in passed argument 1141 // from the entry code of a dart function after an error in passed argument
1137 // name or number is detected. 1142 // name or number is detected.
1138 // Input parameters: 1143 // Input parameters:
1139 // ESP : points to return address. 1144 // ESP : points to return address.
1140 // ESP + 4 : address of last argument. 1145 // ESP + 4 : address of last argument.
1141 // EDX : arguments descriptor array. 1146 // EDX : arguments descriptor array.
(...skipping 19 matching lines...) Expand all
1161 __ CallRuntime(kInvokeClosureNoSuchMethodRuntimeEntry, kNumArgs); 1166 __ CallRuntime(kInvokeClosureNoSuchMethodRuntimeEntry, kNumArgs);
1162 // noSuchMethod on closures always throws an error, so it will never return. 1167 // noSuchMethod on closures always throws an error, so it will never return.
1163 __ int3(); 1168 __ int3();
1164 } 1169 }
1165 1170
1166 1171
1167 // Cannot use function object from ICData as it may be the inlined 1172 // Cannot use function object from ICData as it may be the inlined
1168 // function and not the top-scope function. 1173 // function and not the top-scope function.
1169 void StubCode::GenerateOptimizedUsageCounterIncrement(Assembler* assembler) { 1174 void StubCode::GenerateOptimizedUsageCounterIncrement(Assembler* assembler) {
1170 Register ic_reg = ECX; 1175 Register ic_reg = ECX;
1171 Register func_reg = EDI; 1176 Register func_reg = EBX;
1172 if (FLAG_trace_optimized_ic_calls) { 1177 if (FLAG_trace_optimized_ic_calls) {
1173 __ EnterStubFrame(); 1178 __ EnterStubFrame();
1174 __ pushl(func_reg); // Preserve 1179 __ pushl(func_reg); // Preserve
1175 __ pushl(ic_reg); // Preserve. 1180 __ pushl(ic_reg); // Preserve.
1176 __ pushl(ic_reg); // Argument. 1181 __ pushl(ic_reg); // Argument.
1177 __ pushl(func_reg); // Argument. 1182 __ pushl(func_reg); // Argument.
1178 __ CallRuntime(kTraceICCallRuntimeEntry, 2); 1183 __ CallRuntime(kTraceICCallRuntimeEntry, 2);
1179 __ popl(EAX); // Discard argument; 1184 __ popl(EAX); // Discard argument;
1180 __ popl(EAX); // Discard argument; 1185 __ popl(EAX); // Discard argument;
1181 __ popl(ic_reg); // Restore. 1186 __ popl(ic_reg); // Restore.
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
1697 void StubCode::GenerateICCallBreakpointStub(Assembler* assembler) { 1702 void StubCode::GenerateICCallBreakpointStub(Assembler* assembler) {
1698 __ EnterStubFrame(); 1703 __ EnterStubFrame();
1699 // Save IC data. 1704 // Save IC data.
1700 __ pushl(ECX); 1705 __ pushl(ECX);
1701 // Room for result. Debugger stub returns address of the 1706 // Room for result. Debugger stub returns address of the
1702 // unpatched runtime stub. 1707 // unpatched runtime stub.
1703 const Immediate& raw_null = 1708 const Immediate& raw_null =
1704 Immediate(reinterpret_cast<intptr_t>(Object::null())); 1709 Immediate(reinterpret_cast<intptr_t>(Object::null()));
1705 __ pushl(raw_null); // Room for result. 1710 __ pushl(raw_null); // Room for result.
1706 __ CallRuntime(kBreakpointRuntimeHandlerRuntimeEntry, 0); 1711 __ CallRuntime(kBreakpointRuntimeHandlerRuntimeEntry, 0);
1707 __ popl(EAX); // Address of original stub. 1712 __ popl(EAX); // Code of original stub.
1708 __ popl(ECX); // Restore IC data. 1713 __ popl(ECX); // Restore IC data.
1709 __ LeaveFrame(); 1714 __ LeaveFrame();
1710 __ jmp(EAX); // Jump to original stub. 1715 // Jump to original stub.
1716 __ movl(EAX, FieldAddress(EAX, Code::entry_point_offset()));
1717 __ jmp(EAX);
1711 } 1718 }
1712 1719
1713 1720
1714 void StubCode::GenerateRuntimeCallBreakpointStub(Assembler* assembler) { 1721 void StubCode::GenerateRuntimeCallBreakpointStub(Assembler* assembler) {
1715 __ EnterStubFrame(); 1722 __ EnterStubFrame();
1716 // Room for result. Debugger stub returns address of the 1723 // Room for result. Debugger stub returns address of the
1717 // unpatched runtime stub. 1724 // unpatched runtime stub.
1718 const Immediate& raw_null = 1725 const Immediate& raw_null =
1719 Immediate(reinterpret_cast<intptr_t>(Object::null())); 1726 Immediate(reinterpret_cast<intptr_t>(Object::null()));
1720 __ pushl(raw_null); // Room for result. 1727 __ pushl(raw_null); // Room for result.
1721 __ CallRuntime(kBreakpointRuntimeHandlerRuntimeEntry, 0); 1728 __ CallRuntime(kBreakpointRuntimeHandlerRuntimeEntry, 0);
1722 __ popl(EAX); // Address of original stub. 1729 __ popl(EAX); // Code of the original stub
1723 __ LeaveFrame(); 1730 __ LeaveFrame();
1724 __ jmp(EAX); // Jump to original stub. 1731 // Jump to original stub.
1732 __ movl(EAX, FieldAddress(EAX, Code::entry_point_offset()));
1733 __ jmp(EAX);
1725 } 1734 }
1726 1735
1727 1736
1728 // Called only from unoptimized code. 1737 // Called only from unoptimized code.
1729 void StubCode::GenerateDebugStepCheckStub(Assembler* assembler) { 1738 void StubCode::GenerateDebugStepCheckStub(Assembler* assembler) {
1730 // Check single stepping. 1739 // Check single stepping.
1731 Label stepping, done_stepping; 1740 Label stepping, done_stepping;
1732 __ LoadIsolate(EAX); 1741 __ LoadIsolate(EAX);
1733 __ movzxb(EAX, Address(EAX, Isolate::single_step_offset())); 1742 __ movzxb(EAX, Address(EAX, Isolate::single_step_offset()));
1734 __ cmpl(EAX, Immediate(0)); 1743 __ cmpl(EAX, Immediate(0));
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1886 // Set tag. 1895 // Set tag.
1887 __ movl(Address(EDI, Isolate::vm_tag_offset()), 1896 __ movl(Address(EDI, Isolate::vm_tag_offset()),
1888 Immediate(VMTag::kDartTagId)); 1897 Immediate(VMTag::kDartTagId));
1889 // Clear top exit frame. 1898 // Clear top exit frame.
1890 __ movl(Address(THR, Thread::top_exit_frame_info_offset()), Immediate(0)); 1899 __ movl(Address(THR, Thread::top_exit_frame_info_offset()), Immediate(0));
1891 __ jmp(EBX); // Jump to the exception handler code. 1900 __ jmp(EBX); // Jump to the exception handler code.
1892 } 1901 }
1893 1902
1894 1903
1895 // Calls to the runtime to optimize the given function. 1904 // Calls to the runtime to optimize the given function.
1896 // EDI: function to be reoptimized. 1905 // EBX: function to be reoptimized.
1897 // EDX: argument descriptor (preserved). 1906 // EDX: argument descriptor (preserved).
1898 void StubCode::GenerateOptimizeFunctionStub(Assembler* assembler) { 1907 void StubCode::GenerateOptimizeFunctionStub(Assembler* assembler) {
1899 const Immediate& raw_null = 1908 const Immediate& raw_null =
1900 Immediate(reinterpret_cast<intptr_t>(Object::null())); 1909 Immediate(reinterpret_cast<intptr_t>(Object::null()));
1901 __ EnterStubFrame(); 1910 __ EnterStubFrame();
1902 __ pushl(EDX); 1911 __ pushl(EDX);
1903 __ pushl(raw_null); // Setup space on stack for return value. 1912 __ pushl(raw_null); // Setup space on stack for return value.
1904 __ pushl(EDI); 1913 __ pushl(EBX);
1905 __ CallRuntime(kOptimizeInvokedFunctionRuntimeEntry, 1); 1914 __ CallRuntime(kOptimizeInvokedFunctionRuntimeEntry, 1);
1906 __ popl(EAX); // Discard argument. 1915 __ popl(EAX); // Discard argument.
1907 __ popl(EAX); // Get Code object 1916 __ popl(EAX); // Get Code object
1908 __ popl(EDX); // Restore argument descriptor. 1917 __ popl(EDX); // Restore argument descriptor.
1909 __ movl(EAX, FieldAddress(EAX, Code::entry_point_offset())); 1918 __ movl(EAX, FieldAddress(EAX, Code::entry_point_offset()));
1910 __ LeaveFrame(); 1919 __ LeaveFrame();
1911 __ jmp(EAX); 1920 __ jmp(EAX);
1912 __ int3(); 1921 __ int3();
1913 } 1922 }
1914 1923
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
2061 // Call the target found in the cache. For a class id match, this is a 2070 // Call the target found in the cache. For a class id match, this is a
2062 // proper target for the given name and arguments descriptor. If the 2071 // proper target for the given name and arguments descriptor. If the
2063 // illegal class id was found, the target is a cache miss handler that can 2072 // illegal class id was found, the target is a cache miss handler that can
2064 // be invoked as a normal Dart function. 2073 // be invoked as a normal Dart function.
2065 __ movl(EAX, FieldAddress(EDI, ECX, TIMES_4, base + kWordSize)); 2074 __ movl(EAX, FieldAddress(EDI, ECX, TIMES_4, base + kWordSize));
2066 __ movl(target, FieldAddress(EAX, Function::entry_point_offset())); 2075 __ movl(target, FieldAddress(EAX, Function::entry_point_offset()));
2067 } 2076 }
2068 2077
2069 2078
2070 // Called from megamorphic calls. 2079 // Called from megamorphic calls.
2071 // EDI: receiver. 2080 // ECX: receiver.
2072 // EBX: lookup cache. 2081 // EBX: lookup cache.
2073 // Result: 2082 // Result:
2074 // EBX: entry point. 2083 // EBX: entry point.
2075 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) { 2084 void StubCode::GenerateMegamorphicLookupStub(Assembler* assembler) {
2076 EmitMegamorphicLookup(assembler, EDI, EBX, EBX); 2085 EmitMegamorphicLookup(assembler, ECX, EBX, EBX);
2077 __ ret(); 2086 __ ret();
2078 } 2087 }
2079 2088
2080 2089
2081 } // namespace dart 2090 } // namespace dart
2082 2091
2083 #endif // defined TARGET_ARCH_IA32 2092 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698