| 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 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 766 __ j(ZERO, ¬_closure, Assembler::kNearJump); // Not a closure, but a smi. | 766 __ j(ZERO, ¬_closure, Assembler::kNearJump); // Not a closure, but a smi. |
| 767 // Verify that the class of the object is a closure class by checking that | 767 // Verify that the class of the object is a closure class by checking that |
| 768 // class.signature_function() is not null. | 768 // class.signature_function() is not null. |
| 769 __ LoadClass(EAX, EDI, ECX); | 769 __ LoadClass(EAX, EDI, ECX); |
| 770 __ movl(EAX, FieldAddress(EAX, Class::signature_function_offset())); | 770 __ movl(EAX, FieldAddress(EAX, Class::signature_function_offset())); |
| 771 __ cmpl(EAX, raw_null); | 771 __ cmpl(EAX, raw_null); |
| 772 // Actual class is not a closure class. | 772 // Actual class is not a closure class. |
| 773 __ j(EQUAL, ¬_closure, Assembler::kNearJump); | 773 __ j(EQUAL, ¬_closure, Assembler::kNearJump); |
| 774 | 774 |
| 775 // EAX is just the signature function. Load the actual closure function. | 775 // EAX is just the signature function. Load the actual closure function. |
| 776 __ movl(ECX, FieldAddress(EDI, Closure::function_offset())); | 776 __ movl(EAX, FieldAddress(EDI, Closure::function_offset())); |
| 777 | 777 |
| 778 // Load closure context in CTX; note that CTX has already been preserved. | 778 // Load closure context in CTX; note that CTX has already been preserved. |
| 779 __ movl(CTX, FieldAddress(EDI, Closure::context_offset())); | 779 __ movl(CTX, FieldAddress(EDI, Closure::context_offset())); |
| 780 | 780 |
| 781 // Load closure function code in EAX. | 781 // EBX: Code (compiled code or lazy compile stub). |
| 782 __ movl(EAX, FieldAddress(ECX, Function::code_offset())); | 782 __ movl(EBX, FieldAddress(EAX, Function::code_offset())); |
| 783 __ cmpl(EAX, raw_null); | |
| 784 Label function_compiled; | |
| 785 __ j(NOT_EQUAL, &function_compiled, Assembler::kNearJump); | |
| 786 | 783 |
| 787 // Create a stub frame as we are pushing some objects on the stack before | 784 // EAX: Function. |
| 788 // calling into the runtime. | |
| 789 __ EnterStubFrame(); | |
| 790 | |
| 791 __ pushl(EDX); // Preserve arguments descriptor array. | |
| 792 __ pushl(ECX); // Preserve read-only function object argument. | |
| 793 __ CallRuntime(kCompileFunctionRuntimeEntry, 1); | |
| 794 __ popl(ECX); // Restore read-only function object argument in ECX. | |
| 795 __ popl(EDX); // Restore arguments descriptor array. | |
| 796 // Restore EAX. | |
| 797 __ movl(EAX, FieldAddress(ECX, Function::code_offset())); | |
| 798 | |
| 799 // Remove the stub frame as we are about to jump to the closure function. | |
| 800 __ LeaveFrame(); | |
| 801 | |
| 802 __ Bind(&function_compiled); | |
| 803 // EAX: Code. | |
| 804 // ECX: Function. | |
| 805 // EDX: Arguments descriptor array. | 785 // EDX: Arguments descriptor array. |
| 806 | 786 __ movl(ECX, FieldAddress(EBX, Code::instructions_offset())); |
| 807 __ movl(ECX, FieldAddress(EAX, Code::instructions_offset())); | |
| 808 __ addl(ECX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 787 __ addl(ECX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
| 809 __ jmp(ECX); | 788 __ jmp(ECX); |
| 810 | 789 |
| 811 __ Bind(¬_closure); | 790 __ Bind(¬_closure); |
| 812 // Call runtime to attempt to resolve and invoke a call method on a | 791 // Call runtime to attempt to resolve and invoke a call method on a |
| 813 // non-closure object, passing the non-closure object and its arguments array, | 792 // non-closure object, passing the non-closure object and its arguments array, |
| 814 // returning here. | 793 // returning here. |
| 815 // If no call method exists, throw a NoSuchMethodError. | 794 // If no call method exists, throw a NoSuchMethodError. |
| 816 // EDI: non-closure object. | 795 // EDI: non-closure object. |
| 817 // EDX: arguments descriptor array. | 796 // EDX: arguments descriptor array. |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1501 const intptr_t target_offset = ICData::TargetIndexFor(num_args) * kWordSize; | 1480 const intptr_t target_offset = ICData::TargetIndexFor(num_args) * kWordSize; |
| 1502 const intptr_t count_offset = ICData::CountIndexFor(num_args) * kWordSize; | 1481 const intptr_t count_offset = ICData::CountIndexFor(num_args) * kWordSize; |
| 1503 __ movl(EAX, Address(EBX, target_offset)); | 1482 __ movl(EAX, Address(EBX, target_offset)); |
| 1504 __ addl(Address(EBX, count_offset), Immediate(Smi::RawValue(1))); | 1483 __ addl(Address(EBX, count_offset), Immediate(Smi::RawValue(1))); |
| 1505 __ j(NO_OVERFLOW, &call_target_function, Assembler::kNearJump); | 1484 __ j(NO_OVERFLOW, &call_target_function, Assembler::kNearJump); |
| 1506 __ movl(Address(EBX, count_offset), | 1485 __ movl(Address(EBX, count_offset), |
| 1507 Immediate(Smi::RawValue(Smi::kMaxValue))); | 1486 Immediate(Smi::RawValue(Smi::kMaxValue))); |
| 1508 | 1487 |
| 1509 __ Bind(&call_target_function); | 1488 __ Bind(&call_target_function); |
| 1510 // EAX: Target function. | 1489 // EAX: Target function. |
| 1511 Label is_compiled; | |
| 1512 __ movl(EBX, FieldAddress(EAX, Function::code_offset())); | 1490 __ movl(EBX, FieldAddress(EAX, Function::code_offset())); |
| 1513 if (FLAG_collect_code) { | 1491 if (FLAG_collect_code) { |
| 1514 // If code might be GC'd, then EBX might be null. If it is, recompile. | 1492 // If code might be GC'd, then EBX might be null. If it is, recompile. |
| 1515 __ cmpl(EBX, raw_null); | 1493 __ cmpl(EBX, raw_null); |
| 1516 __ j(NOT_EQUAL, &is_compiled, Assembler::kNearJump); | 1494 __ j(EQUAL, &StubCode::LazyCompileLabel()); |
| 1517 __ EnterStubFrame(); | |
| 1518 __ pushl(EDX); // Preserve arguments descriptor array. | |
| 1519 __ pushl(ECX); // Preserve IC data object. | |
| 1520 __ pushl(EAX); // Pass function. | |
| 1521 __ CallRuntime(kCompileFunctionRuntimeEntry, 1); | |
| 1522 __ popl(EAX); // Restore function. | |
| 1523 __ popl(ECX); // Restore IC data array. | |
| 1524 __ popl(EDX); // Restore arguments descriptor array. | |
| 1525 __ LeaveFrame(); | |
| 1526 __ movl(EBX, FieldAddress(EAX, Function::code_offset())); | |
| 1527 __ Bind(&is_compiled); | |
| 1528 } | 1495 } |
| 1529 __ movl(EAX, FieldAddress(EBX, Code::instructions_offset())); | 1496 __ movl(EAX, FieldAddress(EBX, Code::instructions_offset())); |
| 1530 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 1497 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
| 1531 __ jmp(EAX); | 1498 __ jmp(EAX); |
| 1532 | 1499 |
| 1533 // Instance in EAX, return its class-id in EAX as Smi. | 1500 // Instance in EAX, return its class-id in EAX as Smi. |
| 1534 __ Bind(&get_class_id_as_smi); | 1501 __ Bind(&get_class_id_as_smi); |
| 1535 Label not_smi; | 1502 Label not_smi; |
| 1536 // Test if Smi -> load Smi class for comparison. | 1503 // Test if Smi -> load Smi class for comparison. |
| 1537 __ testl(EAX, Immediate(kSmiTagMask)); | 1504 __ testl(EAX, Immediate(kSmiTagMask)); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1665 const intptr_t target_offset = ICData::TargetIndexFor(0) * kWordSize; | 1632 const intptr_t target_offset = ICData::TargetIndexFor(0) * kWordSize; |
| 1666 const intptr_t count_offset = ICData::CountIndexFor(0) * kWordSize; | 1633 const intptr_t count_offset = ICData::CountIndexFor(0) * kWordSize; |
| 1667 | 1634 |
| 1668 // Increment count for this call. | 1635 // Increment count for this call. |
| 1669 Label increment_done; | 1636 Label increment_done; |
| 1670 __ addl(Address(EBX, count_offset), Immediate(Smi::RawValue(1))); | 1637 __ addl(Address(EBX, count_offset), Immediate(Smi::RawValue(1))); |
| 1671 __ j(NO_OVERFLOW, &increment_done, Assembler::kNearJump); | 1638 __ j(NO_OVERFLOW, &increment_done, Assembler::kNearJump); |
| 1672 __ movl(Address(EBX, count_offset), Immediate(Smi::RawValue(Smi::kMaxValue))); | 1639 __ movl(Address(EBX, count_offset), Immediate(Smi::RawValue(Smi::kMaxValue))); |
| 1673 __ Bind(&increment_done); | 1640 __ Bind(&increment_done); |
| 1674 | 1641 |
| 1642 // Load arguments descriptor into EDX. |
| 1643 __ movl(EDX, FieldAddress(ECX, ICData::arguments_descriptor_offset())); |
| 1644 |
| 1675 const Immediate& raw_null = | 1645 const Immediate& raw_null = |
| 1676 Immediate(reinterpret_cast<intptr_t>(Object::null())); | 1646 Immediate(reinterpret_cast<intptr_t>(Object::null())); |
| 1677 Label target_is_compiled; | |
| 1678 // Get function and call it, if possible. | 1647 // Get function and call it, if possible. |
| 1679 __ movl(EDI, Address(EBX, target_offset)); | 1648 __ movl(EAX, Address(EBX, target_offset)); |
| 1680 __ movl(EAX, FieldAddress(EDI, Function::code_offset())); | 1649 __ movl(EBX, FieldAddress(EAX, Function::code_offset())); |
| 1681 __ cmpl(EAX, raw_null); | 1650 __ cmpl(EBX, raw_null); |
| 1682 __ j(NOT_EQUAL, &target_is_compiled, Assembler::kNearJump); | 1651 __ j(EQUAL, &StubCode::LazyCompileLabel()); |
| 1683 __ EnterStubFrame(); | |
| 1684 __ pushl(EDI); // Preserve target function. | |
| 1685 __ pushl(ECX); // Preserve IC data object. | |
| 1686 __ pushl(EDI); // Pass function. | |
| 1687 __ CallRuntime(kCompileFunctionRuntimeEntry, 1); | |
| 1688 __ popl(EAX); // Discard argument. | |
| 1689 __ popl(ECX); // Restore IC data object. | |
| 1690 __ popl(EDI); // Restore target function. | |
| 1691 __ LeaveFrame(); | |
| 1692 __ movl(EAX, FieldAddress(EDI, Function::code_offset())); | |
| 1693 | 1652 |
| 1694 __ Bind(&target_is_compiled); | 1653 // EBX: Target code. |
| 1695 // EAX: Target code. | 1654 __ movl(EAX, FieldAddress(EBX, Code::instructions_offset())); |
| 1696 __ movl(EAX, FieldAddress(EAX, Code::instructions_offset())); | |
| 1697 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); | 1655 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
| 1698 // Load arguments descriptor into EDX. | |
| 1699 __ movl(EDX, FieldAddress(ECX, ICData::arguments_descriptor_offset())); | |
| 1700 __ jmp(EAX); | 1656 __ jmp(EAX); |
| 1701 } | 1657 } |
| 1702 | 1658 |
| 1703 | 1659 |
| 1704 void StubCode::GenerateTwoArgsUnoptimizedStaticCallStub(Assembler* assembler) { | 1660 void StubCode::GenerateTwoArgsUnoptimizedStaticCallStub(Assembler* assembler) { |
| 1705 GenerateUsageCounterIncrement(assembler, EBX); | 1661 GenerateUsageCounterIncrement(assembler, EBX); |
| 1706 GenerateNArgsCheckInlineCacheStub( | 1662 GenerateNArgsCheckInlineCacheStub( |
| 1707 assembler, 2, kStaticCallMissHandlerTwoArgsRuntimeEntry); | 1663 assembler, 2, kStaticCallMissHandlerTwoArgsRuntimeEntry); |
| 1708 } | 1664 } |
| 1709 | 1665 |
| 1710 | 1666 |
| 1711 // Stub for calling the CompileFunction runtime call. | 1667 // Stub for compiling a function and jumping to the compiled code. |
| 1712 // ECX: IC-Data. | 1668 // ECX: IC-Data. |
| 1713 // EDX: Arguments descriptor. | 1669 // EDX: Arguments descriptor. |
| 1714 // EAX: Function. | 1670 // EAX: Function. |
| 1715 void StubCode::GenerateCompileFunctionRuntimeCallStub(Assembler* assembler) { | 1671 void StubCode::GenerateLazyCompileStub(Assembler* assembler) { |
| 1716 __ EnterStubFrame(); | 1672 __ EnterStubFrame(); |
| 1717 __ pushl(EDX); // Preserve arguments descriptor array. | 1673 __ pushl(EDX); // Preserve arguments descriptor array. |
| 1718 __ pushl(ECX); // Preserve IC data object. | 1674 __ pushl(ECX); // Preserve IC data object. |
| 1719 __ pushl(EAX); // Pass function. | 1675 __ pushl(EAX); // Pass function. |
| 1720 __ CallRuntime(kCompileFunctionRuntimeEntry, 1); | 1676 __ CallRuntime(kCompileFunctionRuntimeEntry, 1); |
| 1721 __ popl(EAX); // Restore function. | 1677 __ popl(EAX); // Restore function. |
| 1722 __ popl(ECX); // Restore IC data array. | 1678 __ popl(ECX); // Restore IC data array. |
| 1723 __ popl(EDX); // Restore arguments descriptor array. | 1679 __ popl(EDX); // Restore arguments descriptor array. |
| 1724 __ LeaveFrame(); | 1680 __ LeaveFrame(); |
| 1681 |
| 1682 __ movl(EAX, FieldAddress(EAX, Function::code_offset())); |
| 1683 __ movl(EAX, FieldAddress(EAX, Code::instructions_offset())); |
| 1684 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
| 1685 __ jmp(EAX); |
| 1686 } |
| 1687 |
| 1688 |
| 1689 // Stub for compiling a closure and jumping to the compiled code. |
| 1690 // EDX: Arguments descriptor. |
| 1691 // EAX: Function. |
| 1692 void StubCode::GenerateLazyCompileClosureStub(Assembler* assembler) { |
| 1693 __ EnterStubFrame(); |
| 1694 __ pushl(EDX); // Preserve arguments descriptor array. |
| 1695 __ pushl(EAX); // Pass function. |
| 1696 __ CallRuntime(kCompileFunctionRuntimeEntry, 1); |
| 1697 __ popl(EAX); // Restore function. |
| 1698 __ popl(EDX); // Restore arguments descriptor array. |
| 1699 __ LeaveFrame(); |
| 1700 |
| 1701 __ movl(EAX, FieldAddress(EAX, Function::code_offset())); |
| 1702 __ movl(EAX, FieldAddress(EAX, Code::instructions_offset())); |
| 1703 __ addl(EAX, Immediate(Instructions::HeaderSize() - kHeapObjectTag)); |
| 1704 __ jmp(EAX); |
| 1705 } |
| 1706 |
| 1707 |
| 1708 // Stub for calling the CompileFunction runtime call. |
| 1709 // EAX: Function. |
| 1710 void StubCode::GenerateCompileFunctionRuntimeCallStub(Assembler* assembler) { |
| 1711 __ EnterStubFrame(); |
| 1712 __ pushl(EAX); // Pass function. |
| 1713 __ CallRuntime(kCompileFunctionRuntimeEntry, 1); |
| 1714 __ popl(EAX); // Restore function. |
| 1715 __ LeaveFrame(); |
| 1725 __ ret(); | 1716 __ ret(); |
| 1726 } | 1717 } |
| 1727 | 1718 |
| 1728 | 1719 |
| 1729 // EDX, ECX: May contain arguments to runtime stub. | 1720 // EDX, ECX: May contain arguments to runtime stub. |
| 1730 void StubCode::GenerateBreakpointRuntimeStub(Assembler* assembler) { | 1721 void StubCode::GenerateBreakpointRuntimeStub(Assembler* assembler) { |
| 1731 __ EnterStubFrame(); | 1722 __ EnterStubFrame(); |
| 1732 // Save runtime args. | 1723 // Save runtime args. |
| 1733 __ pushl(ECX); | 1724 __ pushl(ECX); |
| 1734 __ pushl(EDX); | 1725 __ pushl(EDX); |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2035 const Register temp = ECX; | 2026 const Register temp = ECX; |
| 2036 __ movl(left, Address(ESP, 2 * kWordSize)); | 2027 __ movl(left, Address(ESP, 2 * kWordSize)); |
| 2037 __ movl(right, Address(ESP, 1 * kWordSize)); | 2028 __ movl(right, Address(ESP, 1 * kWordSize)); |
| 2038 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); | 2029 GenerateIdenticalWithNumberCheckStub(assembler, left, right, temp); |
| 2039 __ ret(); | 2030 __ ret(); |
| 2040 } | 2031 } |
| 2041 | 2032 |
| 2042 } // namespace dart | 2033 } // namespace dart |
| 2043 | 2034 |
| 2044 #endif // defined TARGET_ARCH_IA32 | 2035 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |