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

Side by Side Diff: vm/stub_code_ia32.cc

Issue 10173008: Simplify representation of stack frames. Remove the special types DartFrame/StubFrame and instead u… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 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
OLDNEW
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/object_store.h" 10 #include "vm/object_store.h"
(...skipping 13 matching lines...) Expand all
24 DECLARE_FLAG(int, optimization_counter_threshold); 24 DECLARE_FLAG(int, optimization_counter_threshold);
25 25
26 // Input parameters: 26 // Input parameters:
27 // ESP : points to return address. 27 // ESP : points to return address.
28 // ESP + 4 : address of last argument in argument array. 28 // ESP + 4 : address of last argument in argument array.
29 // ESP + 4*EDX : address of first argument in argument array. 29 // ESP + 4*EDX : address of first argument in argument array.
30 // ESP + 4*EDX + 4 : address of return value. 30 // ESP + 4*EDX + 4 : address of return value.
31 // ECX : address of the runtime function to call. 31 // ECX : address of the runtime function to call.
32 // EDX : number of arguments to the call. 32 // EDX : number of arguments to the call.
33 // Must preserve callee saved registers EDI and EBX. 33 // Must preserve callee saved registers EDI and EBX.
34 static void GenerateCallRuntimeStub(Assembler* assembler) { 34 void StubCode::GenerateCallToRuntimeStub(Assembler* assembler) {
35 const intptr_t isolate_offset = NativeArguments::isolate_offset(); 35 const intptr_t isolate_offset = NativeArguments::isolate_offset();
36 const intptr_t argc_offset = NativeArguments::argc_offset(); 36 const intptr_t argc_offset = NativeArguments::argc_offset();
37 const intptr_t argv_offset = NativeArguments::argv_offset(); 37 const intptr_t argv_offset = NativeArguments::argv_offset();
38 const intptr_t retval_offset = NativeArguments::retval_offset(); 38 const intptr_t retval_offset = NativeArguments::retval_offset();
39 39
40 __ EnterFrame(0); 40 __ EnterFrame(0);
41 41
42 // Load current Isolate pointer from Context structure into EAX. 42 // Load current Isolate pointer from Context structure into EAX.
43 __ movl(EAX, FieldAddress(CTX, Context::isolate_offset())); 43 __ movl(EAX, FieldAddress(CTX, Context::isolate_offset()));
44 44
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 __ movl(Address(CTX, Isolate::top_context_offset()), raw_null); 79 __ movl(Address(CTX, Isolate::top_context_offset()), raw_null);
80 80
81 // Cache Context pointer into CTX while executing Dart code. 81 // Cache Context pointer into CTX while executing Dart code.
82 __ movl(CTX, ECX); 82 __ movl(CTX, ECX);
83 83
84 __ LeaveFrame(); 84 __ LeaveFrame();
85 __ ret(); 85 __ ret();
86 } 86 }
87 87
88 88
89 // Input parameters:
90 // ESP : points to return address.
91 // ESP + 4 : address of last argument in argument array.
92 // ESP + 4*EDX : address of first argument in argument array.
93 // ESP + 4*EDX + 4 : address of return value.
94 // ECX : address of the runtime function to call.
95 // EDX : number of arguments to the call.
96 // Must preserve callee saved registers EDI and EBX.
97 void StubCode::GenerateDartCallToRuntimeStub(Assembler* assembler) {
98 GenerateCallRuntimeStub(assembler);
99 }
100
101
102 // Input parameters:
103 // ESP : points to return address.
104 // ESP + 4 : address of last argument in argument array.
105 // ESP + 4*EDX : address of first argument in argument array.
106 // ESP + 4*EDX + 4 : address of return value.
107 // ECX : address of the runtime function to call.
108 // EDX : number of arguments to the call.
109 // Must preserve callee saved registers EDI and EBX.
110 void StubCode::GenerateStubCallToRuntimeStub(Assembler* assembler) {
111 GenerateCallRuntimeStub(assembler);
112 }
113
114
115 // Print the stop message. 89 // Print the stop message.
116 static void PrintStopMessage(const char* message) { 90 static void PrintStopMessage(const char* message) {
117 OS::Print("Stop message: %s\n", message); 91 OS::Print("Stop message: %s\n", message);
118 } 92 }
119 93
120 94
121 // Input parameters: 95 // Input parameters:
122 // ESP : points to return address. 96 // ESP : points to return address.
123 // EAX : stop message (const char*). 97 // EAX : stop message (const char*).
124 // Must preserve all registers, except EAX. 98 // Must preserve all registers, except EAX.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 __ cmpl(EAX, raw_null); 208 __ cmpl(EAX, raw_null);
235 Label function_compiled; 209 Label function_compiled;
236 __ j(NOT_EQUAL, &function_compiled, Assembler::kNearJump); 210 __ j(NOT_EQUAL, &function_compiled, Assembler::kNearJump);
237 211
238 // Create a stub frame as we are pushing some objects on the stack before 212 // Create a stub frame as we are pushing some objects on the stack before
239 // calling into the runtime. 213 // calling into the runtime.
240 __ EnterFrame(0); 214 __ EnterFrame(0);
241 215
242 __ pushl(EDX); // Preserve arguments descriptor array. 216 __ pushl(EDX); // Preserve arguments descriptor array.
243 __ pushl(ECX); 217 __ pushl(ECX);
244 __ CallRuntimeFromStub(kCompileFunctionRuntimeEntry); 218 __ CallRuntime(kCompileFunctionRuntimeEntry);
245 __ popl(ECX); // Restore read-only function object argument in ECX. 219 __ popl(ECX); // Restore read-only function object argument in ECX.
246 __ popl(EDX); // Restore arguments descriptor array. 220 __ popl(EDX); // Restore arguments descriptor array.
247 // Restore EAX. 221 // Restore EAX.
248 __ movl(EAX, FieldAddress(ECX, Function::code_offset())); 222 __ movl(EAX, FieldAddress(ECX, Function::code_offset()));
249 223
250 // Remove the stub frame as we are about to jump to the dart function. 224 // Remove the stub frame as we are about to jump to the dart function.
251 __ LeaveFrame(); 225 __ LeaveFrame();
252 226
253 __ Bind(&function_compiled); 227 __ Bind(&function_compiled);
254 // Patch caller. 228 // Patch caller.
255 __ EnterFrame(0); 229 __ EnterFrame(0);
256 230
257 __ pushl(EDX); // Preserve arguments descriptor array. 231 __ pushl(EDX); // Preserve arguments descriptor array.
258 __ pushl(ECX); // Preserve function object. 232 __ pushl(ECX); // Preserve function object.
259 __ CallRuntimeFromStub(kPatchStaticCallRuntimeEntry); 233 __ CallRuntime(kPatchStaticCallRuntimeEntry);
260 __ popl(ECX); // Restore function object argument in ECX. 234 __ popl(ECX); // Restore function object argument in ECX.
261 __ popl(EDX); // Restore arguments descriptor array. 235 __ popl(EDX); // Restore arguments descriptor array.
262 // Remove the stub frame as we are about to jump to the dart function. 236 // Remove the stub frame as we are about to jump to the dart function.
263 __ LeaveFrame(); 237 __ LeaveFrame();
264 __ movl(EAX, FieldAddress(ECX, Function::code_offset())); 238 __ movl(EAX, FieldAddress(ECX, Function::code_offset()));
265 239
266 __ movl(ECX, FieldAddress(EAX, Code::instructions_offset())); 240 __ movl(ECX, FieldAddress(EAX, Code::instructions_offset()));
267 __ addl(ECX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); 241 __ addl(ECX, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
268 __ jmp(ECX); 242 __ jmp(ECX);
269 } 243 }
270 244
271 245
272 // Called from a static call only when an invalid code has been entered 246 // Called from a static call only when an invalid code has been entered
273 // (invalid because its function was optimized or deoptimized). 247 // (invalid because its function was optimized or deoptimized).
274 // ECX: function object. 248 // ECX: function object.
275 // EDX: arguments descriptor array (num_args is first Smi element). 249 // EDX: arguments descriptor array (num_args is first Smi element).
276 void StubCode::GenerateFixCallersTargetStub(Assembler* assembler) { 250 void StubCode::GenerateFixCallersTargetStub(Assembler* assembler) {
277 __ EnterFrame(0); 251 __ EnterFrame(0);
278 __ pushl(EDX); // Preserve arguments descriptor array. 252 __ pushl(EDX); // Preserve arguments descriptor array.
279 __ pushl(ECX); // Preserve target function. 253 __ pushl(ECX); // Preserve target function.
280 __ pushl(ECX); // Target function. 254 __ pushl(ECX); // Target function.
281 __ CallRuntimeFromStub(kFixCallersTargetRuntimeEntry); 255 __ CallRuntime(kFixCallersTargetRuntimeEntry);
282 __ popl(EAX); // discard argument. 256 __ popl(EAX); // discard argument.
283 __ popl(EAX); // Restore function. 257 __ popl(EAX); // Restore function.
284 __ popl(EDX); // Restore arguments descriptor array. 258 __ popl(EDX); // Restore arguments descriptor array.
285 __ movl(EAX, FieldAddress(EAX, Function::code_offset())); 259 __ movl(EAX, FieldAddress(EAX, Function::code_offset()));
286 __ movl(EAX, FieldAddress(EAX, Code::instructions_offset())); 260 __ movl(EAX, FieldAddress(EAX, Code::instructions_offset()));
287 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); 261 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
288 __ LeaveFrame(); 262 __ LeaveFrame();
289 __ jmp(EAX); 263 __ jmp(EAX);
290 __ int3(); 264 __ int3();
291 } 265 }
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 // Total number of args is the first Smi in args descriptor array (EDX). 406 // Total number of args is the first Smi in args descriptor array (EDX).
433 __ movl(EAX, FieldAddress(EDX, Array::data_offset())); 407 __ movl(EAX, FieldAddress(EDX, Array::data_offset()));
434 __ movl(EAX, Address(ESP, EAX, TIMES_2, kWordSize)); // Get receiver. 408 __ movl(EAX, Address(ESP, EAX, TIMES_2, kWordSize)); // Get receiver.
435 __ pushl(EDX); // Preserve arguments descriptor array. 409 __ pushl(EDX); // Preserve arguments descriptor array.
436 __ pushl(EAX); // Preserve receiver. 410 __ pushl(EAX); // Preserve receiver.
437 __ pushl(ECX); // Preserve ic-data. 411 __ pushl(ECX); // Preserve ic-data.
438 // First resolve the function to get the function object. 412 // First resolve the function to get the function object.
439 413
440 __ pushl(raw_null); // Setup space on stack for return value. 414 __ pushl(raw_null); // Setup space on stack for return value.
441 __ pushl(EAX); // Push receiver. 415 __ pushl(EAX); // Push receiver.
442 __ CallRuntimeFromStub(kResolveCompileInstanceFunctionRuntimeEntry); 416 __ CallRuntime(kResolveCompileInstanceFunctionRuntimeEntry);
443 __ popl(EAX); // Remove receiver pushed earlier. 417 __ popl(EAX); // Remove receiver pushed earlier.
444 __ popl(ECX); // Pop returned code object into ECX. 418 __ popl(ECX); // Pop returned code object into ECX.
445 // Pop preserved values 419 // Pop preserved values
446 __ popl(EDX); // Restore ic-data. 420 __ popl(EDX); // Restore ic-data.
447 __ popl(EAX); // Restore receiver. 421 __ popl(EAX); // Restore receiver.
448 __ popl(EDI); // Restore arguments descriptor array. 422 __ popl(EDI); // Restore arguments descriptor array.
449 423
450 __ cmpl(ECX, raw_null); 424 __ cmpl(ECX, raw_null);
451 Label check_implicit_closure; 425 Label check_implicit_closure;
452 __ j(EQUAL, &check_implicit_closure, Assembler::kNearJump); 426 __ j(EQUAL, &check_implicit_closure, Assembler::kNearJump);
(...skipping 15 matching lines...) Expand all
468 // First check to see if this is a getter function and we are 442 // First check to see if this is a getter function and we are
469 // trying to create a closure of an instance function. 443 // trying to create a closure of an instance function.
470 // Push values that need to be preserved across runtime call. 444 // Push values that need to be preserved across runtime call.
471 __ pushl(EAX); // Preserve receiver. 445 __ pushl(EAX); // Preserve receiver.
472 __ pushl(EDX); // Preserve ic-data. 446 __ pushl(EDX); // Preserve ic-data.
473 __ pushl(EDI); // Preserve arguments descriptor array. 447 __ pushl(EDI); // Preserve arguments descriptor array.
474 448
475 __ pushl(raw_null); // Setup space on stack for return value. 449 __ pushl(raw_null); // Setup space on stack for return value.
476 __ pushl(EAX); // Push receiver. 450 __ pushl(EAX); // Push receiver.
477 __ pushl(EDX); // Ic-data. 451 __ pushl(EDX); // Ic-data.
478 __ CallRuntimeFromStub(kResolveImplicitClosureFunctionRuntimeEntry); 452 __ CallRuntime(kResolveImplicitClosureFunctionRuntimeEntry);
479 __ popl(EAX); 453 __ popl(EAX);
480 __ popl(EAX); 454 __ popl(EAX);
481 __ popl(ECX); // Get return value into ECX, might be Closure object. 455 __ popl(ECX); // Get return value into ECX, might be Closure object.
482 456
483 // Pop preserved values. 457 // Pop preserved values.
484 __ popl(EDI); // Restore arguments descriptor array. 458 __ popl(EDI); // Restore arguments descriptor array.
485 __ popl(EDX); // Restore ic-data. 459 __ popl(EDX); // Restore ic-data.
486 __ popl(EAX); // Restore receiver. 460 __ popl(EAX); // Restore receiver.
487 461
488 __ cmpl(ECX, raw_null); 462 __ cmpl(ECX, raw_null);
(...skipping 14 matching lines...) Expand all
503 // same name and see if we get a closure back which we are then 477 // same name and see if we get a closure back which we are then
504 // supposed to invoke. 478 // supposed to invoke.
505 // Push values that need to be preserved across runtime call. 479 // Push values that need to be preserved across runtime call.
506 __ pushl(EAX); // Preserve receiver. 480 __ pushl(EAX); // Preserve receiver.
507 __ pushl(EDX); // Preserve ic-data. 481 __ pushl(EDX); // Preserve ic-data.
508 __ pushl(EDI); // Preserve arguments descriptor array. 482 __ pushl(EDI); // Preserve arguments descriptor array.
509 483
510 __ pushl(raw_null); // Setup space on stack for return value. 484 __ pushl(raw_null); // Setup space on stack for return value.
511 __ pushl(EAX); // Push receiver. 485 __ pushl(EAX); // Push receiver.
512 __ pushl(EDX); // Ic-data. 486 __ pushl(EDX); // Ic-data.
513 __ CallRuntimeFromStub(kResolveImplicitClosureThroughGetterRuntimeEntry); 487 __ CallRuntime(kResolveImplicitClosureThroughGetterRuntimeEntry);
514 __ popl(EDX); // Pop argument. 488 __ popl(EDX); // Pop argument.
515 __ popl(EAX); // Pop argument. 489 __ popl(EAX); // Pop argument.
516 __ popl(ECX); // get return value into ECX, might be Closure object. 490 __ popl(ECX); // get return value into ECX, might be Closure object.
517 491
518 // Pop preserved values. 492 // Pop preserved values.
519 __ popl(EDI); // Restore arguments descriptor array. 493 __ popl(EDI); // Restore arguments descriptor array.
520 __ popl(EDX); // Restore ic-data. 494 __ popl(EDX); // Restore ic-data.
521 __ popl(EAX); // Restore receiver. 495 __ popl(EAX); // Restore receiver.
522 496
523 __ cmpl(ECX, raw_null); 497 __ cmpl(ECX, raw_null);
(...skipping 12 matching lines...) Expand all
536 // Stack layout explaining "(kWordSize * 5)" offset. 510 // Stack layout explaining "(kWordSize * 5)" offset.
537 // TOS + 0: Argument array. 511 // TOS + 0: Argument array.
538 // TOS + 1: Arguments descriptor array. 512 // TOS + 1: Arguments descriptor array.
539 // TOS + 2: Closure object. 513 // TOS + 2: Closure object.
540 // TOS + 3: Place for result from closure function. 514 // TOS + 3: Place for result from closure function.
541 // TOS + 4: Saved EBP of previous frame. <== EBP 515 // TOS + 4: Saved EBP of previous frame. <== EBP
542 // TOS + 5: Dart code return address 516 // TOS + 5: Dart code return address
543 // TOS + 6: Last argument of caller. 517 // TOS + 6: Last argument of caller.
544 // .... 518 // ....
545 519
546 __ CallRuntimeFromStub(kInvokeImplicitClosureFunctionRuntimeEntry); 520 __ CallRuntime(kInvokeImplicitClosureFunctionRuntimeEntry);
547 // Remove arguments. 521 // Remove arguments.
548 __ popl(EAX); 522 __ popl(EAX);
549 __ popl(EAX); 523 __ popl(EAX);
550 __ popl(EAX); 524 __ popl(EAX);
551 __ popl(EAX); // Get result into EAX. 525 __ popl(EAX); // Get result into EAX.
552 526
553 // Remove the stub frame as we are about to return. 527 // Remove the stub frame as we are about to return.
554 __ LeaveFrame(); 528 __ LeaveFrame();
555 __ ret(); 529 __ ret();
556 530
(...skipping 19 matching lines...) Expand all
576 // TOS + 0: Argument array. 550 // TOS + 0: Argument array.
577 // TOS + 1: Argument descriptor array. 551 // TOS + 1: Argument descriptor array.
578 // TOS + 2: IC-data. 552 // TOS + 2: IC-data.
579 // TOS + 3: Receiver. 553 // TOS + 3: Receiver.
580 // TOS + 4: Place for result from noSuchMethod. 554 // TOS + 4: Place for result from noSuchMethod.
581 // TOS + 5: Saved EBP of previous frame. <== EBP 555 // TOS + 5: Saved EBP of previous frame. <== EBP
582 // TOS + 6: Dart code return address 556 // TOS + 6: Dart code return address
583 // TOS + 7: Last argument of caller. 557 // TOS + 7: Last argument of caller.
584 // .... 558 // ....
585 559
586 __ CallRuntimeFromStub(kInvokeNoSuchMethodFunctionRuntimeEntry); 560 __ CallRuntime(kInvokeNoSuchMethodFunctionRuntimeEntry);
587 // Remove arguments. 561 // Remove arguments.
588 __ popl(EAX); 562 __ popl(EAX);
589 __ popl(EAX); 563 __ popl(EAX);
590 __ popl(EAX); 564 __ popl(EAX);
591 __ popl(EAX); 565 __ popl(EAX);
592 __ popl(EAX); // Get result into EAX. 566 __ popl(EAX); // Get result into EAX.
593 567
594 // Remove the stub frame as we are about to return. 568 // Remove the stub frame as we are about to return.
595 __ LeaveFrame(); 569 __ LeaveFrame();
596 __ ret(); 570 __ ret();
597 } 571 }
598 572
599 573
600 void StubCode::GenerateDeoptimizeStub(Assembler* assembler) { 574 void StubCode::GenerateDeoptimizeStub(Assembler* assembler) {
601 __ EnterFrame(0); 575 __ EnterFrame(0);
602 // EAX: deoptimization reason id. 576 // EAX: deoptimization reason id.
603 // Stack at this point: 577 // Stack at this point:
604 // TOS + 0: Saved EBP of function frame that will be deoptimized. <== EBP 578 // TOS + 0: Saved EBP of function frame that will be deoptimized. <== EBP
605 // TOS + 1: Deoptimization point (return address), will be patched. 579 // TOS + 1: Deoptimization point (return address), will be patched.
606 // TOS + 2: top-of-stack at deoptimization point (all arguments on stack). 580 // TOS + 2: top-of-stack at deoptimization point (all arguments on stack).
607 __ pushl(EAX); 581 __ pushl(EAX);
608 __ CallRuntimeFromStub(kDeoptimizeRuntimeEntry); 582 __ CallRuntime(kDeoptimizeRuntimeEntry);
609 __ popl(EAX); 583 __ popl(EAX);
610 __ LeaveFrame(); 584 __ LeaveFrame();
611 __ ret(); 585 __ ret();
612 } 586 }
613 587
614 588
615 // Called for inline allocation of arrays. 589 // Called for inline allocation of arrays.
616 // Input parameters: 590 // Input parameters:
617 // EDX : Array length as Smi. 591 // EDX : Array length as Smi.
618 // ECX : array element type (either NULL or an instantiated type). 592 // ECX : array element type (either NULL or an instantiated type).
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 __ ret(); 711 __ ret();
738 } 712 }
739 713
740 // Unable to allocate the array using the fast inline code, just call 714 // Unable to allocate the array using the fast inline code, just call
741 // into the runtime. 715 // into the runtime.
742 __ Bind(&slow_case); 716 __ Bind(&slow_case);
743 __ EnterFrame(0); 717 __ EnterFrame(0);
744 __ pushl(raw_null); // Setup space on stack for return value. 718 __ pushl(raw_null); // Setup space on stack for return value.
745 __ pushl(EDX); // Array length as Smi. 719 __ pushl(EDX); // Array length as Smi.
746 __ pushl(ECX); // Element type. 720 __ pushl(ECX); // Element type.
747 __ CallRuntimeFromStub(kAllocateArrayRuntimeEntry); 721 __ CallRuntime(kAllocateArrayRuntimeEntry);
748 __ popl(EAX); // Pop element type argument. 722 __ popl(EAX); // Pop element type argument.
749 __ popl(EDX); // Pop array length argument. 723 __ popl(EDX); // Pop array length argument.
750 __ popl(EAX); // Pop return value from return slot. 724 __ popl(EAX); // Pop return value from return slot.
751 __ LeaveFrame(); 725 __ LeaveFrame();
752 __ ret(); 726 __ ret();
753 } 727 }
754 728
755 729
756 // Input parameters: 730 // Input parameters:
757 // EDX: Arguments descriptor array (num_args is first Smi element, closure 731 // EDX: Arguments descriptor array (num_args is first Smi element, closure
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 __ cmpl(EAX, raw_null); 769 __ cmpl(EAX, raw_null);
796 Label function_compiled; 770 Label function_compiled;
797 __ j(NOT_EQUAL, &function_compiled, Assembler::kNearJump); 771 __ j(NOT_EQUAL, &function_compiled, Assembler::kNearJump);
798 772
799 // Create a stub frame as we are pushing some objects on the stack before 773 // Create a stub frame as we are pushing some objects on the stack before
800 // calling into the runtime. 774 // calling into the runtime.
801 __ EnterFrame(0); 775 __ EnterFrame(0);
802 776
803 __ pushl(EDX); // Preserve arguments descriptor array. 777 __ pushl(EDX); // Preserve arguments descriptor array.
804 __ pushl(ECX); 778 __ pushl(ECX);
805 __ CallRuntimeFromStub(kCompileFunctionRuntimeEntry); 779 __ CallRuntime(kCompileFunctionRuntimeEntry);
806 __ popl(ECX); // Restore read-only function object argument in ECX. 780 __ popl(ECX); // Restore read-only function object argument in ECX.
807 __ popl(EDX); // Restore arguments descriptor array. 781 __ popl(EDX); // Restore arguments descriptor array.
808 // Restore EAX. 782 // Restore EAX.
809 __ movl(EAX, FieldAddress(ECX, Function::code_offset())); 783 __ movl(EAX, FieldAddress(ECX, Function::code_offset()));
810 784
811 // Remove the stub frame as we are about to jump to the closure function. 785 // Remove the stub frame as we are about to jump to the closure function.
812 __ LeaveFrame(); 786 __ LeaveFrame();
813 787
814 __ Bind(&function_compiled); 788 __ Bind(&function_compiled);
815 // EAX: Code. 789 // EAX: Code.
(...skipping 24 matching lines...) Expand all
840 PushArgumentsArray(assembler, (kWordSize * 4)); 814 PushArgumentsArray(assembler, (kWordSize * 4));
841 815
842 // Stack: 816 // Stack:
843 // TOS + 0: Argument array. 817 // TOS + 0: Argument array.
844 // TOS + 1: Non-closure object. 818 // TOS + 1: Non-closure object.
845 // TOS + 2: Place for result from reporting the error. 819 // TOS + 2: Place for result from reporting the error.
846 // TOS + 3: Saved EBP of previous frame. <== EBP 820 // TOS + 3: Saved EBP of previous frame. <== EBP
847 // TOS + 4: Dart code return address 821 // TOS + 4: Dart code return address
848 // TOS + 5: Last argument of caller. 822 // TOS + 5: Last argument of caller.
849 // .... 823 // ....
850 __ CallRuntimeFromStub(kReportObjectNotClosureRuntimeEntry); 824 __ CallRuntime(kReportObjectNotClosureRuntimeEntry);
851 __ Stop("runtime call throws an exception"); 825 __ Stop("runtime call throws an exception");
852 } 826 }
853 827
854 828
855 // Called when invoking dart code from C++ (VM code). 829 // Called when invoking dart code from C++ (VM code).
856 // Input parameters: 830 // Input parameters:
857 // ESP : points to return address. 831 // ESP : points to return address.
858 // ESP + 4 : entrypoint of the dart function to call. 832 // ESP + 4 : entrypoint of the dart function to call.
859 // ESP + 8 : arguments descriptor array. 833 // ESP + 8 : arguments descriptor array.
860 // ESP + 12 : pointer to the argument array. 834 // ESP + 12 : pointer to the argument array.
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1075 // EAX: new object. 1049 // EAX: new object.
1076 __ ret(); 1050 __ ret();
1077 1051
1078 __ Bind(&slow_case); 1052 __ Bind(&slow_case);
1079 } 1053 }
1080 // Create a stub frame. 1054 // Create a stub frame.
1081 __ EnterFrame(0); 1055 __ EnterFrame(0);
1082 __ pushl(raw_null); // Setup space on stack for return value. 1056 __ pushl(raw_null); // Setup space on stack for return value.
1083 __ SmiTag(EDX); 1057 __ SmiTag(EDX);
1084 __ pushl(EDX); 1058 __ pushl(EDX);
1085 __ CallRuntimeFromStub(kAllocateContextRuntimeEntry); // Allocate context. 1059 __ CallRuntime(kAllocateContextRuntimeEntry); // Allocate context.
1086 __ popl(EAX); // Pop number of context variables argument. 1060 __ popl(EAX); // Pop number of context variables argument.
1087 __ popl(EAX); // Pop the new context object. 1061 __ popl(EAX); // Pop the new context object.
1088 // EAX: new object 1062 // EAX: new object
1089 // Restore the frame pointer. 1063 // Restore the frame pointer.
1090 __ LeaveFrame(); 1064 __ LeaveFrame();
1091 __ ret(); 1065 __ ret();
1092 } 1066 }
1093 1067
1094 1068
1095 // Called for inline allocation of objects. 1069 // Called for inline allocation of objects.
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1266 __ EnterFrame(0); 1240 __ EnterFrame(0);
1267 __ pushl(raw_null); // Setup space on stack for return value. 1241 __ pushl(raw_null); // Setup space on stack for return value.
1268 __ PushObject(cls); // Push class of object to be allocated. 1242 __ PushObject(cls); // Push class of object to be allocated.
1269 if (is_cls_parameterized) { 1243 if (is_cls_parameterized) {
1270 __ pushl(EAX); // Push type arguments of object to be allocated. 1244 __ pushl(EAX); // Push type arguments of object to be allocated.
1271 __ pushl(EDX); // Push type arguments of instantiator. 1245 __ pushl(EDX); // Push type arguments of instantiator.
1272 } else { 1246 } else {
1273 __ pushl(raw_null); // Push null type arguments. 1247 __ pushl(raw_null); // Push null type arguments.
1274 __ pushl(Immediate(Smi::RawValue(StubCode::kNoInstantiator))); 1248 __ pushl(Immediate(Smi::RawValue(StubCode::kNoInstantiator)));
1275 } 1249 }
1276 __ CallRuntimeFromStub(kAllocateObjectRuntimeEntry); // Allocate object. 1250 __ CallRuntime(kAllocateObjectRuntimeEntry); // Allocate object.
1277 __ popl(EAX); // Pop argument (instantiator). 1251 __ popl(EAX); // Pop argument (instantiator).
1278 __ popl(EAX); // Pop argument (type arguments of object). 1252 __ popl(EAX); // Pop argument (type arguments of object).
1279 __ popl(EAX); // Pop argument (class of object). 1253 __ popl(EAX); // Pop argument (class of object).
1280 __ popl(EAX); // Pop result (newly allocated object). 1254 __ popl(EAX); // Pop result (newly allocated object).
1281 // EAX: new object 1255 // EAX: new object
1282 // Restore the frame pointer. 1256 // Restore the frame pointer.
1283 __ LeaveFrame(); 1257 __ LeaveFrame();
1284 __ ret(); 1258 __ ret();
1285 } 1259 }
1286 1260
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 __ movl(ECX, Address(ESP, kTypeArgumentsOffset)); 1386 __ movl(ECX, Address(ESP, kTypeArgumentsOffset));
1413 } 1387 }
1414 if (is_implicit_instance_closure) { 1388 if (is_implicit_instance_closure) {
1415 __ movl(EAX, Address(ESP, kReceiverOffset)); 1389 __ movl(EAX, Address(ESP, kReceiverOffset));
1416 } 1390 }
1417 // Create a stub frame. 1391 // Create a stub frame.
1418 __ EnterFrame(0); 1392 __ EnterFrame(0);
1419 __ pushl(raw_null); // Setup space on stack for return value. 1393 __ pushl(raw_null); // Setup space on stack for return value.
1420 __ PushObject(func); 1394 __ PushObject(func);
1421 if (is_implicit_static_closure) { 1395 if (is_implicit_static_closure) {
1422 __ CallRuntimeFromStub(kAllocateImplicitStaticClosureRuntimeEntry); 1396 __ CallRuntime(kAllocateImplicitStaticClosureRuntimeEntry);
1423 } else { 1397 } else {
1424 if (is_implicit_instance_closure) { 1398 if (is_implicit_instance_closure) {
1425 __ pushl(EAX); // Receiver. 1399 __ pushl(EAX); // Receiver.
1426 } 1400 }
1427 if (has_type_arguments) { 1401 if (has_type_arguments) {
1428 __ pushl(ECX); // Push type arguments of closure to be allocated. 1402 __ pushl(ECX); // Push type arguments of closure to be allocated.
1429 } else { 1403 } else {
1430 __ pushl(raw_null); // Push null type arguments. 1404 __ pushl(raw_null); // Push null type arguments.
1431 } 1405 }
1432 if (is_implicit_instance_closure) { 1406 if (is_implicit_instance_closure) {
1433 __ CallRuntimeFromStub(kAllocateImplicitInstanceClosureRuntimeEntry); 1407 __ CallRuntime(kAllocateImplicitInstanceClosureRuntimeEntry);
1434 __ popl(EAX); // Pop argument (type arguments of object). 1408 __ popl(EAX); // Pop argument (type arguments of object).
1435 __ popl(EAX); // Pop receiver. 1409 __ popl(EAX); // Pop receiver.
1436 } else { 1410 } else {
1437 ASSERT(func.IsNonImplicitClosureFunction()); 1411 ASSERT(func.IsNonImplicitClosureFunction());
1438 __ CallRuntimeFromStub(kAllocateClosureRuntimeEntry); 1412 __ CallRuntime(kAllocateClosureRuntimeEntry);
1439 __ popl(EAX); // Pop argument (type arguments of object). 1413 __ popl(EAX); // Pop argument (type arguments of object).
1440 } 1414 }
1441 } 1415 }
1442 __ popl(EAX); // Pop function object. 1416 __ popl(EAX); // Pop function object.
1443 __ popl(EAX); 1417 __ popl(EAX);
1444 // EAX: new object 1418 // EAX: new object
1445 // Restore the frame pointer. 1419 // Restore the frame pointer.
1446 __ LeaveFrame(); 1420 __ LeaveFrame();
1447 __ ret(); 1421 __ ret();
1448 } 1422 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1489 // TOS + 1: Arguments descriptor array. 1463 // TOS + 1: Arguments descriptor array.
1490 // TOS + 2: Ic-data. 1464 // TOS + 2: Ic-data.
1491 // TOS + 3: Receiver. 1465 // TOS + 3: Receiver.
1492 // TOS + 4: Place for result from noSuchMethod. 1466 // TOS + 4: Place for result from noSuchMethod.
1493 // TOS + 5: Saved EBP of previous frame. <== EBP 1467 // TOS + 5: Saved EBP of previous frame. <== EBP
1494 // TOS + 6: Dart callee (or stub) code return address 1468 // TOS + 6: Dart callee (or stub) code return address
1495 // TOS + 7: Saved EBP of dart caller frame. 1469 // TOS + 7: Saved EBP of dart caller frame.
1496 // TOS + 8: Dart caller code return address 1470 // TOS + 8: Dart caller code return address
1497 // TOS + 9: Last argument of caller. 1471 // TOS + 9: Last argument of caller.
1498 // .... 1472 // ....
1499 __ CallRuntimeFromStub(kInvokeNoSuchMethodFunctionRuntimeEntry); 1473 __ CallRuntime(kInvokeNoSuchMethodFunctionRuntimeEntry);
1500 // Remove arguments. 1474 // Remove arguments.
1501 __ popl(EAX); 1475 __ popl(EAX);
1502 __ popl(EAX); 1476 __ popl(EAX);
1503 __ popl(EAX); 1477 __ popl(EAX);
1504 __ popl(EAX); 1478 __ popl(EAX);
1505 __ popl(EAX); // Get result into EAX. 1479 __ popl(EAX); // Get result into EAX.
1506 1480
1507 // Remove the stub frame as we are about to return. 1481 // Remove the stub frame as we are about to return.
1508 __ LeaveFrame(); 1482 __ LeaveFrame();
1509 __ ret(); 1483 __ ret();
(...skipping 18 matching lines...) Expand all
1528 __ incl(FieldAddress(EBX, Function::usage_counter_offset())); 1502 __ incl(FieldAddress(EBX, Function::usage_counter_offset()));
1529 if (CodeGenerator::CanOptimize()) { 1503 if (CodeGenerator::CanOptimize()) {
1530 __ cmpl(FieldAddress(EBX, Function::usage_counter_offset()), 1504 __ cmpl(FieldAddress(EBX, Function::usage_counter_offset()),
1531 Immediate(FLAG_optimization_counter_threshold)); 1505 Immediate(FLAG_optimization_counter_threshold));
1532 Label not_yet_hot; 1506 Label not_yet_hot;
1533 __ j(LESS_EQUAL, &not_yet_hot); 1507 __ j(LESS_EQUAL, &not_yet_hot);
1534 __ EnterFrame(0); 1508 __ EnterFrame(0);
1535 __ pushl(ECX); // Preserve inline cache data object. 1509 __ pushl(ECX); // Preserve inline cache data object.
1536 __ pushl(EDX); // Preserve arguments array. 1510 __ pushl(EDX); // Preserve arguments array.
1537 __ pushl(EBX); // Argument for runtime: function object. 1511 __ pushl(EBX); // Argument for runtime: function object.
1538 __ CallRuntimeFromStub(kOptimizeInvokedFunctionRuntimeEntry); 1512 __ CallRuntime(kOptimizeInvokedFunctionRuntimeEntry);
1539 __ popl(EBX); // Remove argument. 1513 __ popl(EBX); // Remove argument.
1540 __ popl(EDX); // Restore arguments array. 1514 __ popl(EDX); // Restore arguments array.
1541 __ popl(ECX); // Restore inline cache data object. 1515 __ popl(ECX); // Restore inline cache data object.
1542 __ LeaveFrame(); 1516 __ LeaveFrame();
1543 __ Bind(&not_yet_hot); 1517 __ Bind(&not_yet_hot);
1544 } 1518 }
1545 1519
1546 ASSERT(num_args > 0); 1520 ASSERT(num_args > 0);
1547 // Get receiver (first read number of arguments from argument descriptor array 1521 // Get receiver (first read number of arguments from argument descriptor array
1548 // and then access the receiver from the stack). 1522 // and then access the receiver from the stack).
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
1621 __ EnterFrame(0); 1595 __ EnterFrame(0);
1622 __ pushl(EDX); // Preserve arguments array. 1596 __ pushl(EDX); // Preserve arguments array.
1623 __ pushl(ECX); // Preserve IC data array 1597 __ pushl(ECX); // Preserve IC data array
1624 __ pushl(raw_null); // Setup space on stack for result (target code object). 1598 __ pushl(raw_null); // Setup space on stack for result (target code object).
1625 // Push call arguments. 1599 // Push call arguments.
1626 for (intptr_t i = 0; i < num_args; i++) { 1600 for (intptr_t i = 0; i < num_args; i++) {
1627 __ movl(EDX, Address(EAX, -kWordSize * i)); 1601 __ movl(EDX, Address(EAX, -kWordSize * i));
1628 __ pushl(EDX); 1602 __ pushl(EDX);
1629 } 1603 }
1630 if (num_args == 1) { 1604 if (num_args == 1) {
1631 __ CallRuntimeFromStub(kInlineCacheMissHandlerOneArgRuntimeEntry); 1605 __ CallRuntime(kInlineCacheMissHandlerOneArgRuntimeEntry);
1632 } else if (num_args == 2) { 1606 } else if (num_args == 2) {
1633 __ CallRuntimeFromStub(kInlineCacheMissHandlerTwoArgsRuntimeEntry); 1607 __ CallRuntime(kInlineCacheMissHandlerTwoArgsRuntimeEntry);
1634 } else { 1608 } else {
1635 UNIMPLEMENTED(); 1609 UNIMPLEMENTED();
1636 } 1610 }
1637 // Remove call arguments pushed earlier. 1611 // Remove call arguments pushed earlier.
1638 for (intptr_t i = 0; i < num_args; i++) { 1612 for (intptr_t i = 0; i < num_args; i++) {
1639 __ popl(EAX); 1613 __ popl(EAX);
1640 } 1614 }
1641 __ popl(EAX); // Pop returned code object into EAX (null if not found). 1615 __ popl(EAX); // Pop returned code object into EAX (null if not found).
1642 __ popl(ECX); // Restore IC data array. 1616 __ popl(ECX); // Restore IC data array.
1643 __ popl(EDX); // Restore arguments array. 1617 __ popl(EDX); // Restore arguments array.
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1695 return GenerateNArgsCheckInlineCacheStub(assembler, 2); 1669 return GenerateNArgsCheckInlineCacheStub(assembler, 2);
1696 } 1670 }
1697 1671
1698 // ECX: Function object. 1672 // ECX: Function object.
1699 // EDX: Arguments array. 1673 // EDX: Arguments array.
1700 // TOS(0): return address (Dart code). 1674 // TOS(0): return address (Dart code).
1701 void StubCode::GenerateBreakpointStaticStub(Assembler* assembler) { 1675 void StubCode::GenerateBreakpointStaticStub(Assembler* assembler) {
1702 __ EnterFrame(0); 1676 __ EnterFrame(0);
1703 __ pushl(EDX); 1677 __ pushl(EDX);
1704 __ pushl(ECX); 1678 __ pushl(ECX);
1705 __ CallRuntimeFromStub(kBreakpointStaticHandlerRuntimeEntry); 1679 __ CallRuntime(kBreakpointStaticHandlerRuntimeEntry);
1706 __ popl(ECX); 1680 __ popl(ECX);
1707 __ popl(EDX); 1681 __ popl(EDX);
1708 __ LeaveFrame(); 1682 __ LeaveFrame();
1709 1683
1710 // Now call the static function. The breakpoint handler function 1684 // Now call the static function. The breakpoint handler function
1711 // ensures that the call target is compiled. 1685 // ensures that the call target is compiled.
1712 __ movl(EAX, FieldAddress(ECX, Function::code_offset())); 1686 __ movl(EAX, FieldAddress(ECX, Function::code_offset()));
1713 __ movl(ECX, FieldAddress(EAX, Code::instructions_offset())); 1687 __ movl(ECX, FieldAddress(EAX, Code::instructions_offset()));
1714 __ addl(ECX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); 1688 __ addl(ECX, Immediate(Instructions::HeaderSize() - kHeapObjectTag));
1715 __ jmp(ECX); 1689 __ jmp(ECX);
1716 } 1690 }
1717 1691
1718 1692
1719 // TOS(0): return address (Dart code). 1693 // TOS(0): return address (Dart code).
1720 void StubCode::GenerateBreakpointReturnStub(Assembler* assembler) { 1694 void StubCode::GenerateBreakpointReturnStub(Assembler* assembler) {
1721 __ EnterFrame(0); 1695 __ EnterFrame(0);
1722 __ pushl(EAX); 1696 __ pushl(EAX);
1723 __ CallRuntimeFromStub(kBreakpointReturnHandlerRuntimeEntry); 1697 __ CallRuntime(kBreakpointReturnHandlerRuntimeEntry);
1724 __ popl(EAX); 1698 __ popl(EAX);
1725 __ LeaveFrame(); 1699 __ LeaveFrame();
1726 1700
1727 // Instead of returning to the patched Dart function, emulate the 1701 // Instead of returning to the patched Dart function, emulate the
1728 // smashed return code pattern and return to the function's caller. 1702 // smashed return code pattern and return to the function's caller.
1729 __ popl(ECX); // Discard return address to patched dart code. 1703 __ popl(ECX); // Discard return address to patched dart code.
1730 // Execute function epilog code that was smashed in the Dart code. 1704 // Execute function epilog code that was smashed in the Dart code.
1731 __ LeaveFrame(); 1705 __ LeaveFrame();
1732 __ ret(); 1706 __ ret();
1733 } 1707 }
1734 1708
1735 1709
1736 // ECX: Inline cache data array. 1710 // ECX: Inline cache data array.
1737 // EDX: Arguments array. 1711 // EDX: Arguments array.
1738 // TOS(0): return address (Dart code). 1712 // TOS(0): return address (Dart code).
1739 void StubCode::GenerateBreakpointDynamicStub(Assembler* assembler) { 1713 void StubCode::GenerateBreakpointDynamicStub(Assembler* assembler) {
1740 __ EnterFrame(0); 1714 __ EnterFrame(0);
1741 __ pushl(ECX); 1715 __ pushl(ECX);
1742 __ pushl(EDX); 1716 __ pushl(EDX);
1743 __ CallRuntimeFromStub(kBreakpointDynamicHandlerRuntimeEntry); 1717 __ CallRuntime(kBreakpointDynamicHandlerRuntimeEntry);
1744 __ popl(EDX); 1718 __ popl(EDX);
1745 __ popl(ECX); 1719 __ popl(ECX);
1746 __ LeaveFrame(); 1720 __ LeaveFrame();
1747 1721
1748 // Find out which dispatch stub to call. 1722 // Find out which dispatch stub to call.
1749 Label ic_cache_one_arg; 1723 Label ic_cache_one_arg;
1750 __ movl(EBX, FieldAddress(ECX, ICData::num_args_tested_offset())); 1724 __ movl(EBX, FieldAddress(ECX, ICData::num_args_tested_offset()));
1751 __ cmpl(EBX, Immediate(1)); 1725 __ cmpl(EBX, Immediate(1));
1752 __ j(EQUAL, &ic_cache_one_arg, Assembler::kNearJump); 1726 __ j(EQUAL, &ic_cache_one_arg, Assembler::kNearJump);
1753 __ jmp(&StubCode::TwoArgsCheckInlineCacheLabel()); 1727 __ jmp(&StubCode::TwoArgsCheckInlineCacheLabel());
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1830 __ j(EQUAL, &not_found, Assembler::kNearJump); 1804 __ j(EQUAL, &not_found, Assembler::kNearJump);
1831 __ movl(ECX, FieldAddress(ECX, Type::type_class_offset())); 1805 __ movl(ECX, FieldAddress(ECX, Type::type_class_offset()));
1832 __ cmpl(EDX, ECX); 1806 __ cmpl(EDX, ECX);
1833 __ j(NOT_EQUAL, &super_loop, Assembler::kNearJump); 1807 __ j(NOT_EQUAL, &super_loop, Assembler::kNearJump);
1834 __ jmp(&found, Assembler::kNearJump); 1808 __ jmp(&found, Assembler::kNearJump);
1835 } 1809 }
1836 1810
1837 } // namespace dart 1811 } // namespace dart
1838 1812
1839 #endif // defined TARGET_ARCH_IA32 1813 #endif // defined TARGET_ARCH_IA32
OLDNEW
« vm/stack_frame.cc ('K') | « vm/stub_code.cc ('k') | vm/stub_code_ia32_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698