Changeset 154016 in webkit for trunk/Source/JavaScriptCore/assembler/SH4Assembler.h
- Timestamp:
- Aug 13, 2013, 11:59:14 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/assembler/SH4Assembler.h
r151174 r154016 338 338 339 339 SH4Assembler() 340 {341 m_claimscratchReg = 0x0;340 : m_claimscratchReg(0x0) 341 { 342 342 } 343 343 … … 1190 1190 } 1191 1191 1192 void movlImm8r(int imm8, RegisterID dst)1193 {1194 ASSERT((imm8 <= 127) && (imm8 >= -128));1195 1196 uint16_t opc = getOpcodeGroup3(MOVIMM_OPCODE, dst, imm8);1197 oneShortOp(opc);1198 }1199 1200 1192 void loadConstant(uint32_t constant, RegisterID dst) 1201 1193 { … … 1332 1324 static void changePCrelativeAddress(int offset, uint16_t* instructionPtr, uint32_t newAddress) 1333 1325 { 1326 ASSERT((instructionPtr[0] & 0xf000) == MOVL_READ_OFFPC_OPCODE); 1334 1327 uint32_t address = (offset << 2) + ((reinterpret_cast<uint32_t>(instructionPtr) + 4) &(~0x3)); 1335 1328 *reinterpret_cast<uint32_t*>(address) = newAddress; … … 1338 1331 static uint32_t readPCrelativeAddress(int offset, uint16_t* instructionPtr) 1339 1332 { 1333 ASSERT((instructionPtr[0] & 0xf000) == MOVL_READ_OFFPC_OPCODE); 1340 1334 uint32_t address = (offset << 2) + ((reinterpret_cast<uint32_t>(instructionPtr) + 4) &(~0x3)); 1341 1335 return *reinterpret_cast<uint32_t*>(address); … … 1375 1369 nop nop 1376 1370 */ 1377 ASSERT((*(instructionPtr + 1) & BRAF_OPCODE) == BRAF_OPCODE); 1378 1379 offsetBits -= 4; 1380 if (offsetBits >= -4096 && offsetBits <= 4094) { 1381 *instructionPtr = getOpcodeGroup6(BRA_OPCODE, offsetBits >> 1); 1382 *(++instructionPtr) = NOP_OPCODE; 1383 printBlockInstr(instructionPtr - 1, from.m_offset, 2); 1384 return; 1385 } 1386 1387 changePCrelativeAddress((*instructionPtr & 0xff), instructionPtr, offsetBits - 2); 1371 ASSERT((instructionPtr[0] & 0xf000) == MOVL_READ_OFFPC_OPCODE); 1372 ASSERT((instructionPtr[1] & 0xf0ff) == BRAF_OPCODE); 1373 changePCrelativeAddress((*instructionPtr & 0xff), instructionPtr, offsetBits - 6); 1388 1374 printInstr(*instructionPtr, from.m_offset + 2); 1389 1375 } … … 1393 1379 uint16_t* instructionPtr = getInstructionPtr(code, from.m_offset); 1394 1380 instructionPtr -= 3; 1381 ASSERT((instructionPtr[0] & 0xf000) == MOVL_READ_OFFPC_OPCODE); 1395 1382 changePCrelativeAddress((*instructionPtr & 0xff), instructionPtr, reinterpret_cast<uint32_t>(to)); 1396 1383 } … … 1399 1386 { 1400 1387 uint16_t* instructionPtr = getInstructionPtr(code, where.m_offset); 1388 ASSERT((instructionPtr[0] & 0xf000) == MOVL_READ_OFFPC_OPCODE); 1401 1389 changePCrelativeAddress((*instructionPtr & 0xff), instructionPtr, reinterpret_cast<uint32_t>(value)); 1402 1390 } … … 1442 1430 1443 1431 int offset = reinterpret_cast<uint32_t>(constPoolAddr) + (index * 4) - ((reinterpret_cast<uint32_t>(instructionPtr) & ~0x03) + 4); 1444 instruction &= 0xf00;1432 instruction &= 0x0f00; 1445 1433 instruction |= 0xd000; 1446 1434 offset &= 0x03ff; … … 1463 1451 { 1464 1452 uint16_t* instructionPtr = reinterpret_cast<uint16_t*>(where); 1453 ASSERT((instructionPtr[0] & 0xf000) == MOVL_READ_OFFPC_OPCODE); 1465 1454 changePCrelativeAddress((*instructionPtr & 0xff), instructionPtr, value); 1466 1455 } … … 1478 1467 uint16_t* instructionPtr = reinterpret_cast<uint16_t*>(from); 1479 1468 instructionPtr -= 3; 1469 ASSERT((instructionPtr[0] & 0xf000) == MOVL_READ_OFFPC_OPCODE); 1480 1470 changePCrelativeAddress((*instructionPtr & 0xff), instructionPtr, reinterpret_cast<uint32_t>(to)); 1481 1471 } … … 1490 1480 offsetBits -= 8; 1491 1481 instructionPtr++; 1482 ASSERT((instructionPtr[0] & 0xf000) == MOVL_READ_OFFPC_OPCODE); 1492 1483 changePCrelativeAddress((*instructionPtr & 0xff), instructionPtr, offsetBits); 1493 1484 instruction = (BRAF_OPCODE | (*instructionPtr++ & 0xf00)); 1494 1485 *instructionPtr = instruction; 1495 1486 printBlockInstr(instructionPtr, reinterpret_cast<uint32_t>(from) + 1, 3); 1496 return; 1497 } 1498 1499 ASSERT((*(instructionPtr + 1) & BRAF_OPCODE) == BRAF_OPCODE); 1500 offsetBits -= 4; 1501 if (offsetBits >= -4096 && offsetBits <= 4094) { 1502 *instructionPtr = getOpcodeGroup6(BRA_OPCODE, offsetBits >> 1); 1503 *(++instructionPtr) = NOP_OPCODE; 1504 printBlockInstr(instructionPtr - 2, reinterpret_cast<uint32_t>(from), 2); 1505 return; 1506 } 1507 1508 changePCrelativeAddress((*instructionPtr & 0xff), instructionPtr, offsetBits - 2); 1487 cacheFlush(instructionPtr, sizeof(SH4Word)); 1488 return; 1489 } 1490 1491 ASSERT((instructionPtr[1] & 0xf0ff) == BRAF_OPCODE); 1492 changePCrelativeAddress((*instructionPtr & 0xff), instructionPtr, offsetBits - 6); 1509 1493 printInstr(*instructionPtr, reinterpret_cast<uint32_t>(from)); 1510 1494 } … … 1521 1505 SH4Word* instruction = reinterpret_cast<SH4Word*>(instructionStart); 1522 1506 intptr_t difference = reinterpret_cast<intptr_t>(to) - (reinterpret_cast<intptr_t>(instruction) + 2 * sizeof(SH4Word)); 1523 int nbinst = 0; 1524 1525 if ((difference >= -4096) && (difference <= 4094)) { 1526 instruction[0] = getOpcodeGroup6(BRA_OPCODE, difference >> 1); 1527 instruction[1] = NOP_OPCODE; 1528 cacheFlush(instruction, sizeof(SH4Word) * 2); 1529 return; 1530 } 1531 1532 instruction[nbinst++] = getOpcodeGroup3(MOVL_READ_OFFPC_OPCODE, scratchReg2, 1); 1533 instruction[nbinst++] = getOpcodeGroup2(JMP_OPCODE, scratchReg2); 1534 instruction[nbinst++] = NOP_OPCODE; 1535 1536 if (!(reinterpret_cast<unsigned>(instruction) & 3)) 1537 instruction[nbinst++] = NOP_OPCODE; 1538 1539 instruction[nbinst++] = reinterpret_cast<unsigned>(to) & 0xffff; 1540 instruction[nbinst++] = reinterpret_cast<unsigned>(to) >> 16; 1541 cacheFlush(instruction, sizeof(SH4Word) * nbinst); 1542 } 1543 1544 static void revertJump(void* instructionStart, void *immptr) 1507 1508 if ((instruction[0] & 0xf000) == MOVL_READ_OFFPC_OPCODE) { 1509 instruction[1] = (BRAF_OPCODE | (instruction[0] & 0x0f00)); 1510 instruction[2] = NOP_OPCODE; 1511 cacheFlush(&instruction[1], 2 * sizeof(SH4Word)); 1512 } else { 1513 instruction[0] = getOpcodeGroup3(MOVL_READ_OFFPC_OPCODE, SH4Registers::r13, 1); 1514 instruction[1] = getOpcodeGroup2(BRAF_OPCODE, SH4Registers::r13); 1515 instruction[2] = NOP_OPCODE; 1516 cacheFlush(instruction, 3 * sizeof(SH4Word)); 1517 } 1518 1519 changePCrelativeAddress(instruction[0] & 0x00ff, instruction, difference - 2); 1520 } 1521 1522 static void revertJumpToMove(void* instructionStart, RegisterID rd, int imm) 1545 1523 { 1546 1524 SH4Word *insn = reinterpret_cast<SH4Word*>(instructionStart); 1547 1525 ASSERT((insn[0] & 0xf000) == MOVL_READ_OFFPC_OPCODE); 1548 changePCrelativeAddress(insn[0] & 0x00ff, insn, reinterpret_cast<uint32_t>(immptr)); 1526 1527 if ((insn[1] & 0xf000) == CMPEQ_OPCODE) { 1528 insn[0] = getOpcodeGroup3(MOVL_READ_OFFPC_OPCODE, SH4Registers::r13, insn[0] & 0x00ff); 1529 insn[1] = (insn[1] & 0xf00f) | (rd << 8) | (SH4Registers::r13 << 4); 1530 cacheFlush(insn, 2 * sizeof(SH4Word)); 1531 changePCrelativeAddress(insn[0] & 0x00ff, insn, imm); 1532 return; 1533 } 1534 1535 if ((insn[0] & 0x00ff) == 1) 1536 insn[1] = getOpcodeGroup6(BRA_OPCODE, 3); 1537 else 1538 insn[1] = NOP_OPCODE; 1539 1540 insn[2] = NOP_OPCODE; 1541 cacheFlush(&insn[1], 2 * sizeof(SH4Word)); 1542 1543 changePCrelativeAddress(insn[0] & 0x00ff, insn, imm); 1549 1544 } 1550 1545 … … 1559 1554 1560 1555 if (type == JumpNear) { 1561 ASSERT((instruction == BT_OPCODE) || (instruction == BF_OPCODE) || (instruction == BRA_OPCODE));1562 1556 int offset = (codeSize() - from.m_offset) - 4; 1557 ASSERT((((instruction == BT_OPCODE) || (instruction == BF_OPCODE)) && (offset >= -256) && (offset <= 254)) 1558 || ((instruction == BRA_OPCODE) && (offset >= -4096) && (offset <= 4094))); 1563 1559 *instructionPtr++ = instruction | (offset >> 1); 1564 1560 printInstr(*instructionPtr, from.m_offset + 2); … … 1575 1571 instruction ^= 0x0202; 1576 1572 *instructionPtr++ = instruction; 1577 if ((*instructionPtr & 0xf000) == 0xe000) {1573 if ((*instructionPtr & 0xf000) == MOVIMM_OPCODE) { 1578 1574 uint32_t* addr = getLdrImmAddressOnPool(instructionPtr, m_buffer.poolAddress()); 1579 1575 *addr = offsetBits; … … 1591 1587 */ 1592 1588 ASSERT((*(instructionPtr + 1) & BRAF_OPCODE) == BRAF_OPCODE); 1593 offsetBits = (to.m_offset - from.m_offset) - 4; 1594 if (offsetBits >= -4096 && offsetBits <= 4094) { 1595 *instructionPtr = getOpcodeGroup6(BRA_OPCODE, offsetBits >> 1); 1596 *(++instructionPtr) = NOP_OPCODE; 1597 printBlockInstr(instructionPtr - 1, from.m_offset, 2); 1598 return; 1599 } 1589 offsetBits = (to.m_offset - from.m_offset) - 6; 1600 1590 1601 1591 instruction = *instructionPtr; 1602 if ((instruction & 0xf000) == 0xe000) {1592 if ((instruction & 0xf000) == MOVIMM_OPCODE) { 1603 1593 uint32_t* addr = getLdrImmAddressOnPool(instructionPtr, m_buffer.poolAddress()); 1604 *addr = offsetBits - 2;1594 *addr = offsetBits; 1605 1595 printInstr(*instructionPtr, from.m_offset + 2); 1606 1596 return; 1607 1597 } 1608 1598 1609 changePCrelativeAddress((*instructionPtr & 0xff), instructionPtr, offsetBits - 2); 1599 ASSERT((instructionPtr[0] & 0xf000) == MOVL_READ_OFFPC_OPCODE); 1600 changePCrelativeAddress((*instructionPtr & 0xff), instructionPtr, offsetBits); 1610 1601 printInstr(*instructionPtr, from.m_offset + 2); 1611 1602 }
Note:
See TracChangeset
for help on using the changeset viewer.