Changeset 69080 in webkit
- Timestamp:
- Oct 4, 2010 10:56:55 PM (14 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r69060 r69080 1 2010-10-04 David Goodwin <david_goodwin@apple.com> 2 3 Reviewed by Oliver Hunt. 4 5 ARMv7 JIT should take advantage of 2-byte branches to reduce code size 6 https://bugs.webkit.org/show_bug.cgi?id=47007 7 8 * assembler/ARMv7Assembler.cpp: 9 * assembler/ARMv7Assembler.h: 10 (JSC::ARMv7Assembler::computeJumpType): 11 (JSC::ARMv7Assembler::link): 12 (JSC::ARMv7Assembler::canBeJumpT2): 13 (JSC::ARMv7Assembler::canBeJumpT4): 14 (JSC::ARMv7Assembler::linkBX): 15 (JSC::ARMv7Assembler::linkJumpT4): 16 (JSC::ARMv7Assembler::linkJumpT2): 17 (JSC::ARMv7Assembler::linkJumpAbsolute): 18 1 19 2010-10-04 Gyuyoung Kim <gyuyoung.kim@samsung.com> 2 20 -
trunk/JavaScriptCore/assembler/ARMv7Assembler.cpp
r65042 r69080 32 32 namespace JSC { 33 33 34 const int ARMv7Assembler::JumpSizes[] = { 0xffffffff, 2 * sizeof(uint16_t), 2 * sizeof(uint16_t), 5 * sizeof(uint16_t) }; 34 const int ARMv7Assembler::JumpSizes[] = { 0xffffffff, sizeof(uint16_t), sizeof(uint16_t), 35 2 * sizeof(uint16_t), 2 * sizeof(uint16_t), 5 * sizeof(uint16_t) }; 35 36 36 37 } -
trunk/JavaScriptCore/assembler/ARMv7Assembler.h
r68764 r69080 1 1 /* 2 * Copyright (C) 2009 Apple Inc. All rights reserved.2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. 3 3 * Copyright (C) 2010 University of Szeged 4 4 * … … 480 480 481 481 enum JumpType { JumpNoCondition, JumpCondition, JumpFullSize }; 482 enum JumpLinkType { LinkInvalid, LinkShortJump, LinkConditionalShortJump, LinkLongJump, JumpTypeCount }; 482 enum JumpLinkType { LinkInvalid, LinkJumpT2, LinkConditionalJumpT2, 483 LinkJumpT4, LinkConditionalJumpT4, LinkBX, JumpTypeCount }; 483 484 static const int JumpSizes[JumpTypeCount]; 484 485 enum { JumpPaddingSize = 5 * sizeof(uint16_t) }; … … 629 630 630 631 typedef enum { 632 OP_B_T2 = 0xE000, 631 633 OP_AND_reg_T2 = 0xEA00, 632 634 OP_TST_reg_T2 = 0xEA10, … … 1680 1682 { 1681 1683 if (record.type() >= JumpFullSize) { 1682 record.setLinkType(LinkLongJump); 1683 return LinkLongJump; 1684 record.setLinkType(LinkBX); 1685 return LinkBX; 1686 } 1687 const uint16_t* jumpT2Location = reinterpret_cast<const uint16_t*>(from - (JumpPaddingSize - JumpSizes[LinkJumpT2])); 1688 if (canBeJumpT2(jumpT2Location, to)) { 1689 if (record.type() == JumpCondition) { 1690 record.setLinkType(LinkConditionalJumpT2); 1691 return LinkConditionalJumpT2; 1692 } 1693 record.setLinkType(LinkJumpT2); 1694 return LinkJumpT2; 1684 1695 } 1685 1696 bool mayTriggerErrata = false; 1686 const uint16_t* shortJumpLocation = reinterpret_cast<const uint16_t*>(from - (JumpPaddingSize - JumpSizes[LinkShortJump]));1687 if (!canBe ShortJump(shortJumpLocation, to, mayTriggerErrata)) {1688 record.setLinkType(Link LongJump);1689 return Link LongJump;1697 const uint16_t* jumpT4Location = reinterpret_cast<const uint16_t*>(from - (JumpPaddingSize - JumpSizes[LinkJumpT4])); 1698 if (!canBeJumpT4(jumpT4Location, to, mayTriggerErrata)) { 1699 record.setLinkType(LinkBX); 1700 return LinkBX; 1690 1701 } 1691 1702 if (mayTriggerErrata) { 1692 record.setLinkType(Link LongJump);1693 return Link LongJump;1703 record.setLinkType(LinkBX); 1704 return LinkBX; 1694 1705 } 1695 1706 if (record.type() == JumpCondition) { 1696 record.setLinkType(LinkConditional ShortJump);1697 return LinkConditional ShortJump;1698 } 1699 record.setLinkType(Link ShortJump);1700 return Link ShortJump;1707 record.setLinkType(LinkConditionalJumpT4); 1708 return LinkConditionalJumpT4; 1709 } 1710 record.setLinkType(LinkJumpT4); 1711 return LinkJumpT4; 1701 1712 } 1702 1713 … … 1718 1729 void link(LinkRecord& record, uint8_t* from, uint8_t* to) 1719 1730 { 1720 uint16_t* itttLocation; 1721 if (record.linkType() == LinkConditionalShortJump) { 1722 itttLocation = reinterpret_cast<uint16_t*>(from - JumpSizes[LinkConditionalShortJump] - 2); 1731 JumpLinkType linkType = record.linkType(); 1732 ASSERT(linkType != LinkInvalid); 1733 if ((linkType == LinkConditionalJumpT2) || (linkType == LinkConditionalJumpT4)) { 1734 uint16_t* itttLocation = reinterpret_cast<uint16_t*>(from - JumpSizes[linkType] - 2); 1723 1735 itttLocation[0] = ifThenElse(record.condition()) | OP_IT; 1724 1736 } 1725 ASSERT(record.linkType() != LinkInvalid); 1726 if (record.linkType() != LinkLongJump) 1727 linkShortJump(reinterpret_cast<uint16_t*>(from), to); 1728 else 1729 linkLongJump(reinterpret_cast<uint16_t*>(from), to); 1737 switch (linkType) { 1738 case LinkJumpT2: 1739 case LinkConditionalJumpT2: 1740 linkJumpT2(reinterpret_cast<uint16_t*>(from), to); 1741 break; 1742 case LinkJumpT4: 1743 case LinkConditionalJumpT4: 1744 linkJumpT4(reinterpret_cast<uint16_t*>(from), to); 1745 break; 1746 case LinkBX: 1747 linkBX(reinterpret_cast<uint16_t*>(from), to); 1748 break; 1749 default: 1750 ASSERT_NOT_REACHED(); 1751 break; 1752 } 1730 1753 } 1731 1754 … … 1947 1970 } 1948 1971 1949 static bool canBeShortJump(const uint16_t* instruction, const void* target, bool& mayTriggerErrata) 1972 static bool canBeJumpT2(const uint16_t* instruction, const void* target) 1973 { 1974 ASSERT(!(reinterpret_cast<intptr_t>(instruction) & 1)); 1975 ASSERT(!(reinterpret_cast<intptr_t>(target) & 1)); 1976 1977 intptr_t relative = reinterpret_cast<intptr_t>(target) - (reinterpret_cast<intptr_t>(instruction)); 1978 // It does not appear to be documented in the ARM ARM (big surprise), but 1979 // for OP_B_T2 the branch displacement encoded in the instruction is 2 1980 // less than the actual displacement. 1981 relative -= 2; 1982 return ((relative << 20) >> 20) == relative; 1983 } 1984 1985 static bool canBeJumpT4(const uint16_t* instruction, const void* target, bool& mayTriggerErrata) 1950 1986 { 1951 1987 ASSERT(!(reinterpret_cast<intptr_t>(instruction) & 1)); … … 1968 2004 } 1969 2005 1970 static void link LongJump(uint16_t* instruction, void* target)2006 static void linkBX(uint16_t* instruction, void* target) 1971 2007 { 1972 2008 linkJumpAbsolute(instruction, target); 1973 2009 } 1974 2010 1975 static void link ShortJump(uint16_t* instruction, void* target)2011 static void linkJumpT4(uint16_t* instruction, void* target) 1976 2012 { 1977 2013 // FIMXE: this should be up in the MacroAssembler layer. :-( … … 1982 2018 bool scratch; 1983 2019 UNUSED_PARAM(scratch); 1984 ASSERT(canBe ShortJump(instruction, target, scratch));2020 ASSERT(canBeJumpT4(instruction, target, scratch)); 1985 2021 // ARM encoding for the top two bits below the sign bit is 'peculiar'. 1986 2022 if (relative >= 0) … … 1993 2029 } 1994 2030 2031 static void linkJumpT2(uint16_t* instruction, void* target) 2032 { 2033 // FIMXE: this should be up in the MacroAssembler layer. :-( 2034 ASSERT(!(reinterpret_cast<intptr_t>(instruction) & 1)); 2035 ASSERT(!(reinterpret_cast<intptr_t>(target) & 1)); 2036 ASSERT(canBeJumpT2(instruction, target)); 2037 2038 intptr_t relative = reinterpret_cast<intptr_t>(target) - (reinterpret_cast<intptr_t>(instruction)); 2039 // It does not appear to be documented in the ARM ARM (big surprise), but 2040 // for OP_B_T2 the branch displacement encoded in the instruction is 2 2041 // less than the actual displacement. 2042 relative -= 2; 2043 2044 // All branch offsets should be an even distance. 2045 ASSERT(!(relative & 1)); 2046 instruction[-1] = OP_B_T2 | ((relative & 0xffe) >> 1); 2047 } 2048 1995 2049 static void linkJumpAbsolute(uint16_t* instruction, void* target) 1996 2050 { … … 2004 2058 intptr_t relative = reinterpret_cast<intptr_t>(target) - (reinterpret_cast<intptr_t>(instruction)); 2005 2059 bool scratch; 2006 if (canBe ShortJump(instruction, target, scratch)) {2060 if (canBeJumpT4(instruction, target, scratch)) { 2007 2061 // ARM encoding for the top two bits below the sign bit is 'peculiar'. 2008 2062 if (relative >= 0)
Note: See TracChangeset
for help on using the changeset viewer.