| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 ScaleFactor scale; | 67 ScaleFactor scale; |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 // MacroAssembler implements a collection of frequently used macros. | 70 // MacroAssembler implements a collection of frequently used macros. |
| 71 class MacroAssembler: public Assembler { | 71 class MacroAssembler: public Assembler { |
| 72 public: | 72 public: |
| 73 MacroAssembler(void* buffer, int size); | 73 MacroAssembler(void* buffer, int size); |
| 74 | 74 |
| 75 void LoadRoot(Register destination, Heap::RootListIndex index); | 75 void LoadRoot(Register destination, Heap::RootListIndex index); |
| 76 void CompareRoot(Register with, Heap::RootListIndex index); | 76 void CompareRoot(Register with, Heap::RootListIndex index); |
| 77 void CompareRoot(Operand with, Heap::RootListIndex index); | 77 void CompareRoot(const Operand& with, Heap::RootListIndex index); |
| 78 void PushRoot(Heap::RootListIndex index); | 78 void PushRoot(Heap::RootListIndex index); |
| 79 void StoreRoot(Register source, Heap::RootListIndex index); | 79 void StoreRoot(Register source, Heap::RootListIndex index); |
| 80 | 80 |
| 81 // --------------------------------------------------------------------------- | 81 // --------------------------------------------------------------------------- |
| 82 // GC Support | 82 // GC Support |
| 83 | 83 |
| 84 // For page containing |object| mark region covering |addr| dirty. | 84 // For page containing |object| mark region covering |addr| dirty. |
| 85 // RecordWriteHelper only works if the object is not in new | 85 // RecordWriteHelper only works if the object is not in new |
| 86 // space. | 86 // space. |
| 87 void RecordWriteHelper(Register object, | 87 void RecordWriteHelper(Register object, |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 void Move(const Operand& dst, Smi* source) { | 533 void Move(const Operand& dst, Smi* source) { |
| 534 Register constant = GetSmiConstant(source); | 534 Register constant = GetSmiConstant(source); |
| 535 movq(dst, constant); | 535 movq(dst, constant); |
| 536 } | 536 } |
| 537 | 537 |
| 538 void Push(Smi* smi); | 538 void Push(Smi* smi); |
| 539 void Test(const Operand& dst, Smi* source); | 539 void Test(const Operand& dst, Smi* source); |
| 540 | 540 |
| 541 // --------------------------------------------------------------------------- | 541 // --------------------------------------------------------------------------- |
| 542 // String macros. | 542 // String macros. |
| 543 |
| 544 // If object is a string, its map is loaded into object_map. |
| 545 template <typename LabelType> |
| 546 void JumpIfNotString(Register object, |
| 547 Register object_map, |
| 548 LabelType* not_string); |
| 549 |
| 550 |
| 543 template <typename LabelType> | 551 template <typename LabelType> |
| 544 void JumpIfNotBothSequentialAsciiStrings(Register first_object, | 552 void JumpIfNotBothSequentialAsciiStrings(Register first_object, |
| 545 Register second_object, | 553 Register second_object, |
| 546 Register scratch1, | 554 Register scratch1, |
| 547 Register scratch2, | 555 Register scratch2, |
| 548 LabelType* on_not_both_flat_ascii); | 556 LabelType* on_not_both_flat_ascii); |
| 549 | 557 |
| 550 // Check whether the instance type represents a flat ascii string. Jump to the | 558 // Check whether the instance type represents a flat ascii string. Jump to the |
| 551 // label if not. If the instance type can be scratched specify same register | 559 // label if not. If the instance type can be scratched specify same register |
| 552 // for both instance type and scratch. | 560 // for both instance type and scratch. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 589 | 597 |
| 590 // Control Flow | 598 // Control Flow |
| 591 void Jump(Address destination, RelocInfo::Mode rmode); | 599 void Jump(Address destination, RelocInfo::Mode rmode); |
| 592 void Jump(ExternalReference ext); | 600 void Jump(ExternalReference ext); |
| 593 void Jump(Handle<Code> code_object, RelocInfo::Mode rmode); | 601 void Jump(Handle<Code> code_object, RelocInfo::Mode rmode); |
| 594 | 602 |
| 595 void Call(Address destination, RelocInfo::Mode rmode); | 603 void Call(Address destination, RelocInfo::Mode rmode); |
| 596 void Call(ExternalReference ext); | 604 void Call(ExternalReference ext); |
| 597 void Call(Handle<Code> code_object, RelocInfo::Mode rmode); | 605 void Call(Handle<Code> code_object, RelocInfo::Mode rmode); |
| 598 | 606 |
| 607 // Emit call to the code we are currently generating. |
| 608 void CallSelf() { |
| 609 Handle<Code> self(reinterpret_cast<Code**>(CodeObject().location())); |
| 610 Call(self, RelocInfo::CODE_TARGET); |
| 611 } |
| 612 |
| 599 // Non-x64 instructions. | 613 // Non-x64 instructions. |
| 600 // Push/pop all general purpose registers. | 614 // Push/pop all general purpose registers. |
| 601 // Does not push rsp/rbp nor any of the assembler's special purpose registers | 615 // Does not push rsp/rbp nor any of the assembler's special purpose registers |
| 602 // (kScratchRegister, kSmiConstantRegister, kRootRegister). | 616 // (kScratchRegister, kSmiConstantRegister, kRootRegister). |
| 603 void Pushad(); | 617 void Pushad(); |
| 604 void Popad(); | 618 void Popad(); |
| 605 // Sets the stack as after performing Popad, without actually loading the | 619 // Sets the stack as after performing Popad, without actually loading the |
| 606 // registers. | 620 // registers. |
| 607 void Dropad(); | 621 void Dropad(); |
| 608 | 622 |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 | 913 |
| 900 // Calculate the number of stack slots to reserve for arguments when calling a | 914 // Calculate the number of stack slots to reserve for arguments when calling a |
| 901 // C function. | 915 // C function. |
| 902 int ArgumentStackSlotsForCFunctionCall(int num_arguments); | 916 int ArgumentStackSlotsForCFunctionCall(int num_arguments); |
| 903 | 917 |
| 904 // --------------------------------------------------------------------------- | 918 // --------------------------------------------------------------------------- |
| 905 // Utilities | 919 // Utilities |
| 906 | 920 |
| 907 void Ret(); | 921 void Ret(); |
| 908 | 922 |
| 923 // Return and drop arguments from stack, where the number of arguments |
| 924 // may be bigger than 2^16 - 1. Requires a scratch register. |
| 925 void Ret(int bytes_dropped, Register scratch); |
| 926 |
| 909 Handle<Object> CodeObject() { return code_object_; } | 927 Handle<Object> CodeObject() { return code_object_; } |
| 910 | 928 |
| 911 | 929 |
| 912 // --------------------------------------------------------------------------- | 930 // --------------------------------------------------------------------------- |
| 913 // StatsCounter support | 931 // StatsCounter support |
| 914 | 932 |
| 915 void SetCounter(StatsCounter* counter, int value); | 933 void SetCounter(StatsCounter* counter, int value); |
| 916 void IncrementCounter(StatsCounter* counter, int value); | 934 void IncrementCounter(StatsCounter* counter, int value); |
| 917 void DecrementCounter(StatsCounter* counter, int value); | 935 void DecrementCounter(StatsCounter* counter, int value); |
| 918 | 936 |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1451 | 1469 |
| 1452 template <typename LabelType> | 1470 template <typename LabelType> |
| 1453 void MacroAssembler::SmiShiftLogicalRight(Register dst, | 1471 void MacroAssembler::SmiShiftLogicalRight(Register dst, |
| 1454 Register src1, | 1472 Register src1, |
| 1455 Register src2, | 1473 Register src2, |
| 1456 LabelType* on_not_smi_result) { | 1474 LabelType* on_not_smi_result) { |
| 1457 ASSERT(!dst.is(kScratchRegister)); | 1475 ASSERT(!dst.is(kScratchRegister)); |
| 1458 ASSERT(!src1.is(kScratchRegister)); | 1476 ASSERT(!src1.is(kScratchRegister)); |
| 1459 ASSERT(!src2.is(kScratchRegister)); | 1477 ASSERT(!src2.is(kScratchRegister)); |
| 1460 ASSERT(!dst.is(rcx)); | 1478 ASSERT(!dst.is(rcx)); |
| 1479 // dst and src1 can be the same, because the one case that bails out |
| 1480 // is a shift by 0, which leaves dst, and therefore src1, unchanged. |
| 1461 NearLabel result_ok; | 1481 NearLabel result_ok; |
| 1462 if (src1.is(rcx) || src2.is(rcx)) { | 1482 if (src1.is(rcx) || src2.is(rcx)) { |
| 1463 movq(kScratchRegister, rcx); | 1483 movq(kScratchRegister, rcx); |
| 1464 } | 1484 } |
| 1465 if (!dst.is(src1)) { | 1485 if (!dst.is(src1)) { |
| 1466 movq(dst, src1); | 1486 movq(dst, src1); |
| 1467 } | 1487 } |
| 1468 SmiToInteger32(rcx, src2); | 1488 SmiToInteger32(rcx, src2); |
| 1469 orl(rcx, Immediate(kSmiShift)); | 1489 orl(rcx, Immediate(kSmiShift)); |
| 1470 shr_cl(dst); // Shift is rcx modulo 0x1f + 32. | 1490 shr_cl(dst); // Shift is rcx modulo 0x1f + 32. |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1585 template <typename LabelType> | 1605 template <typename LabelType> |
| 1586 void MacroAssembler::JumpUnlessBothNonNegativeSmi(Register src1, | 1606 void MacroAssembler::JumpUnlessBothNonNegativeSmi(Register src1, |
| 1587 Register src2, | 1607 Register src2, |
| 1588 LabelType* on_not_both_smi) { | 1608 LabelType* on_not_both_smi) { |
| 1589 Condition both_smi = CheckBothNonNegativeSmi(src1, src2); | 1609 Condition both_smi = CheckBothNonNegativeSmi(src1, src2); |
| 1590 j(NegateCondition(both_smi), on_not_both_smi); | 1610 j(NegateCondition(both_smi), on_not_both_smi); |
| 1591 } | 1611 } |
| 1592 | 1612 |
| 1593 | 1613 |
| 1594 template <typename LabelType> | 1614 template <typename LabelType> |
| 1615 void MacroAssembler::JumpIfNotString(Register object, |
| 1616 Register object_map, |
| 1617 LabelType* not_string) { |
| 1618 Condition is_smi = CheckSmi(object); |
| 1619 j(is_smi, not_string); |
| 1620 CmpObjectType(object, FIRST_NONSTRING_TYPE, object_map); |
| 1621 j(above_equal, not_string); |
| 1622 } |
| 1623 |
| 1624 |
| 1625 template <typename LabelType> |
| 1595 void MacroAssembler::JumpIfNotBothSequentialAsciiStrings(Register first_object, | 1626 void MacroAssembler::JumpIfNotBothSequentialAsciiStrings(Register first_object, |
| 1596 Register second_object, | 1627 Register second_object, |
| 1597 Register scratch1, | 1628 Register scratch1, |
| 1598 Register scratch2, | 1629 Register scratch2, |
| 1599 LabelType* on_fail) { | 1630 LabelType* on_fail) { |
| 1600 // Check that both objects are not smis. | 1631 // Check that both objects are not smis. |
| 1601 Condition either_smi = CheckEitherSmi(first_object, second_object); | 1632 Condition either_smi = CheckEitherSmi(first_object, second_object); |
| 1602 j(either_smi, on_fail); | 1633 j(either_smi, on_fail); |
| 1603 | 1634 |
| 1604 // Load instance type for both strings. | 1635 // Load instance type for both strings. |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1769 Jump(adaptor, RelocInfo::CODE_TARGET); | 1800 Jump(adaptor, RelocInfo::CODE_TARGET); |
| 1770 } | 1801 } |
| 1771 bind(&invoke); | 1802 bind(&invoke); |
| 1772 } | 1803 } |
| 1773 } | 1804 } |
| 1774 | 1805 |
| 1775 | 1806 |
| 1776 } } // namespace v8::internal | 1807 } } // namespace v8::internal |
| 1777 | 1808 |
| 1778 #endif // V8_X64_MACRO_ASSEMBLER_X64_H_ | 1809 #endif // V8_X64_MACRO_ASSEMBLER_X64_H_ |
| OLD | NEW |