| OLD | NEW |
| 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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 __ CallRuntime(kFixAllocationStubTargetRuntimeEntry, 0); | 404 __ CallRuntime(kFixAllocationStubTargetRuntimeEntry, 0); |
| 405 __ popl(EAX); // Get Code object. | 405 __ popl(EAX); // Get Code object. |
| 406 __ movl(EAX, FieldAddress(EAX, Code::instructions_offset())); | 406 __ movl(EAX, FieldAddress(EAX, Code::instructions_offset())); |
| 407 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 407 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
| 408 __ LeaveFrame(); | 408 __ LeaveFrame(); |
| 409 __ jmp(EAX); | 409 __ jmp(EAX); |
| 410 __ int3(); | 410 __ int3(); |
| 411 } | 411 } |
| 412 | 412 |
| 413 | 413 |
| 414 // Called from array allocate instruction when the allocation stub has been |
| 415 // disabled. |
| 416 // EDX: length (preserved). |
| 417 // ECX: element type (preserved). |
| 418 void StubCode::GenerateFixAllocateArrayStubTargetStub(Assembler* assembler) { |
| 419 const Immediate& raw_null = |
| 420 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 421 __ EnterStubFrame(); |
| 422 __ pushl(EDX); // Preserve length. |
| 423 __ pushl(ECX); // Preserve element type. |
| 424 __ pushl(raw_null); // Setup space on stack for return value. |
| 425 __ CallRuntime(kFixAllocationStubTargetRuntimeEntry, 0); |
| 426 __ popl(EAX); // Get Code object. |
| 427 __ popl(ECX); // Restore element type. |
| 428 __ popl(EDX); // Restore length. |
| 429 __ movl(EAX, FieldAddress(EAX, Code::instructions_offset())); |
| 430 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
| 431 __ LeaveFrame(); |
| 432 __ jmp(EAX); |
| 433 __ int3(); |
| 434 } |
| 435 |
| 436 |
| 414 // Input parameters: | 437 // Input parameters: |
| 415 // EDX: smi-tagged argument count, may be zero. | 438 // EDX: smi-tagged argument count, may be zero. |
| 416 // EBP[kParamEndSlotFromFp + 1]: last argument. | 439 // EBP[kParamEndSlotFromFp + 1]: last argument. |
| 417 // Uses EAX, EBX, ECX, EDX. | 440 // Uses EAX, EBX, ECX, EDX. |
| 418 static void PushArgumentsArray(Assembler* assembler) { | 441 static void PushArgumentsArray(Assembler* assembler) { |
| 419 const Immediate& raw_null = | 442 const Immediate& raw_null = |
| 420 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 443 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 421 StubCode* stub_code = Isolate::Current()->stub_code(); | 444 StubCode* stub_code = Isolate::Current()->stub_code(); |
| 422 | 445 |
| 423 // Allocate array to store arguments of caller. | 446 // Allocate array to store arguments of caller. |
| 424 __ movl(ECX, raw_null); // Null element type for raw Array. | 447 __ movl(ECX, raw_null); // Null element type for raw Array. |
| 425 __ call(&stub_code->AllocateArrayLabel()); | 448 const Code& array_stub = Code::Handle(stub_code->GetAllocateArrayStub()); |
| 449 const ExternalLabel array_label(array_stub.EntryPoint()); |
| 450 __ call(&array_label); |
| 426 __ SmiUntag(EDX); | 451 __ SmiUntag(EDX); |
| 427 // EAX: newly allocated array. | 452 // EAX: newly allocated array. |
| 428 // EDX: length of the array (was preserved by the stub). | 453 // EDX: length of the array (was preserved by the stub). |
| 429 __ pushl(EAX); // Array is in EAX and on top of stack. | 454 __ pushl(EAX); // Array is in EAX and on top of stack. |
| 430 __ leal(EBX, Address(EBP, EDX, TIMES_4, kParamEndSlotFromFp * kWordSize)); | 455 __ leal(EBX, Address(EBP, EDX, TIMES_4, kParamEndSlotFromFp * kWordSize)); |
| 431 __ leal(ECX, FieldAddress(EAX, Array::data_offset())); | 456 __ leal(ECX, FieldAddress(EAX, Array::data_offset())); |
| 432 // EBX: address of first argument on stack. | 457 // EBX: address of first argument on stack. |
| 433 // ECX: address of first argument in array. | 458 // ECX: address of first argument in array. |
| 434 Label loop, loop_condition; | 459 Label loop, loop_condition; |
| 435 __ jmp(&loop_condition, Assembler::kNearJump); | 460 __ jmp(&loop_condition, Assembler::kNearJump); |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 __ jmp(EBX); | 628 __ jmp(EBX); |
| 604 } | 629 } |
| 605 | 630 |
| 606 | 631 |
| 607 // Called for inline allocation of arrays. | 632 // Called for inline allocation of arrays. |
| 608 // Input parameters: | 633 // Input parameters: |
| 609 // EDX : Array length as Smi (must be preserved). | 634 // EDX : Array length as Smi (must be preserved). |
| 610 // ECX : array element type (either NULL or an instantiated type). | 635 // ECX : array element type (either NULL or an instantiated type). |
| 611 // Uses EAX, EBX, ECX, EDI as temporary registers. | 636 // Uses EAX, EBX, ECX, EDI as temporary registers. |
| 612 // The newly allocated object is returned in EAX. | 637 // The newly allocated object is returned in EAX. |
| 613 void StubCode::GenerateAllocateArrayStub(Assembler* assembler) { | 638 void StubCode::GeneratePatchableAllocateArrayStub(Assembler* assembler, |
| 639 uword* entry_patch_offset, uword* patch_code_pc_offset) { |
| 640 *entry_patch_offset = assembler->CodeSize(); |
| 614 Label slow_case; | 641 Label slow_case; |
| 615 const Immediate& raw_null = | 642 const Immediate& raw_null = |
| 616 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 643 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 617 | 644 |
| 618 // Compute the size to be allocated, it is based on the array length | 645 // Compute the size to be allocated, it is based on the array length |
| 619 // and is computed as: | 646 // and is computed as: |
| 620 // RoundedAllocationSize((array_length * kwordSize) + sizeof(RawArray)). | 647 // RoundedAllocationSize((array_length * kwordSize) + sizeof(RawArray)). |
| 621 // Assert that length is a Smi. | 648 // Assert that length is a Smi. |
| 622 __ testl(EDX, Immediate(kSmiTagMask)); | 649 __ testl(EDX, Immediate(kSmiTagMask)); |
| 623 if (FLAG_use_slow_path) { | 650 if (FLAG_use_slow_path) { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 731 __ EnterStubFrame(); | 758 __ EnterStubFrame(); |
| 732 __ pushl(raw_null); // Setup space on stack for return value. | 759 __ pushl(raw_null); // Setup space on stack for return value. |
| 733 __ pushl(EDX); // Array length as Smi. | 760 __ pushl(EDX); // Array length as Smi. |
| 734 __ pushl(ECX); // Element type. | 761 __ pushl(ECX); // Element type. |
| 735 __ CallRuntime(kAllocateArrayRuntimeEntry, 2); | 762 __ CallRuntime(kAllocateArrayRuntimeEntry, 2); |
| 736 __ popl(EAX); // Pop element type argument. | 763 __ popl(EAX); // Pop element type argument. |
| 737 __ popl(EDX); // Pop array length argument (preserved). | 764 __ popl(EDX); // Pop array length argument (preserved). |
| 738 __ popl(EAX); // Pop return value from return slot. | 765 __ popl(EAX); // Pop return value from return slot. |
| 739 __ LeaveFrame(); | 766 __ LeaveFrame(); |
| 740 __ ret(); | 767 __ ret(); |
| 768 // Emit function patching code. This will be swapped with the first 5 bytes |
| 769 // at entry point. |
| 770 *patch_code_pc_offset = assembler->CodeSize(); |
| 771 StubCode* stub_code = Isolate::Current()->stub_code(); |
| 772 __ jmp(&stub_code->FixAllocateArrayStubTargetLabel()); |
| 741 } | 773 } |
| 742 | 774 |
| 743 | 775 |
| 744 // Called when invoking dart code from C++ (VM code). | 776 // Called when invoking dart code from C++ (VM code). |
| 745 // Input parameters: | 777 // Input parameters: |
| 746 // ESP : points to return address. | 778 // ESP : points to return address. |
| 747 // ESP + 4 : entrypoint of the dart function to call. | 779 // ESP + 4 : entrypoint of the dart function to call. |
| 748 // ESP + 8 : arguments descriptor array. | 780 // ESP + 8 : arguments descriptor array. |
| 749 // ESP + 12 : arguments array. | 781 // ESP + 12 : arguments array. |
| 750 // ESP + 16 : new context containing the current isolate pointer. | 782 // ESP + 16 : new context containing the current isolate pointer. |
| (...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2050 const Register temp = ECX; | 2082 const Register temp = ECX; |
| 2051 __ movl(left, Address(ESP, 2 * kWordSize)); | 2083 __ movl(left, Address(ESP, 2 * kWordSize)); |
| 2052 __ movl(right, Address(ESP, 1 * kWordSize)); | 2084 __ movl(right, Address(ESP, 1 * kWordSize)); |
| 2053 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); | 2085 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); |
| 2054 __ ret(); | 2086 __ ret(); |
| 2055 } | 2087 } |
| 2056 | 2088 |
| 2057 } // namespace dart | 2089 } // namespace dart |
| 2058 | 2090 |
| 2059 #endif // defined TARGET_ARCH_IA32 | 2091 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |