Changeset 56759 in webkit
- Timestamp:
- Mar 29, 2010 7:59:20 PM (14 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r56740 r56759 1 2010-03-29 Chao-ying Fu <fu@mips.com> 2 3 Reviewed by Oliver Hunt. 4 5 MIPS JIT Supports 6 https://bugs.webkit.org/show_bug.cgi?id=30144 7 8 The following changes enable MIPS JIT. 9 10 * assembler/MIPSAssembler.h: 11 (JSC::MIPSAssembler::lbu): 12 (JSC::MIPSAssembler::linkWithOffset): 13 * assembler/MacroAssemblerMIPS.h: 14 (JSC::MacroAssemblerMIPS::load8): 15 (JSC::MacroAssemblerMIPS::branch8): 16 (JSC::MacroAssemblerMIPS::branchTest8): 17 (JSC::MacroAssemblerMIPS::setTest8): 18 (JSC::MacroAssemblerMIPS::setTest32): 19 * jit/JIT.h: 20 * jit/JITInlineMethods.h: 21 (JSC::JIT::preserveReturnAddressAfterCall): 22 (JSC::JIT::restoreReturnAddressBeforeReturn): 23 * jit/JITOpcodes.cpp: 24 * jit/JITStubs.cpp: 25 (JSC::JITThunks::JITThunks): 26 * jit/JITStubs.h: 27 (JSC::JITStackFrame::returnAddressSlot): 28 * wtf/Platform.h: 29 1 30 2010-02-26 Kenneth Rohde Christiansen <kenneth@webkit.org> 2 31 -
trunk/JavaScriptCore/assembler/MIPSAssembler.h
r55633 r56759 393 393 } 394 394 395 void lbu(RegisterID rt, RegisterID rs, int offset) 396 { 397 emitInst(0x90000000 | (rt << OP_SH_RT) | (rs << OP_SH_RS) 398 | (offset & 0xffff)); 399 loadDelayNop(); 400 } 401 395 402 void lw(RegisterID rt, RegisterID rs, int offset) 396 403 { … … 858 865 1: 859 866 860 Note: beq/bne/bc1t are converted to bne/beq/bc1f.867 Note: beq/bne/bc1t/bc1f are converted to bne/beq/bc1f/bc1t. 861 868 */ 862 869 … … 868 875 else if ((*insn & 0xffff0000) == 0x45010000) // bc1t 869 876 *insn = 0x45000005; // bc1f 877 else if ((*insn & 0xffff0000) == 0x45000000) // bc1f 878 *insn = 0x45010005; // bc1t 870 879 else 871 880 ASSERT(0); -
trunk/JavaScriptCore/assembler/MacroAssemblerMIPS.h
r55633 r56759 443 443 // register is passed. 444 444 445 /* Need to use zero-extened load byte for load8. */ 446 void load8(ImplicitAddress address, RegisterID dest) 447 { 448 if (address.offset >= -32768 && address.offset <= 32767 449 && !m_fixedWidth) 450 m_assembler.lbu(dest, address.base, address.offset); 451 else { 452 /* 453 lui addrTemp, (offset + 0x8000) >> 16 454 addu addrTemp, addrTemp, base 455 lbu dest, (offset & 0xffff)(addrTemp) 456 */ 457 m_assembler.lui(addrTempRegister, (address.offset + 0x8000) >> 16); 458 m_assembler.addu(addrTempRegister, addrTempRegister, address.base); 459 m_assembler.lbu(dest, addrTempRegister, address.offset); 460 } 461 } 462 445 463 void load32(ImplicitAddress address, RegisterID dest) 446 464 { … … 857 875 // an optional second operand of a mask under which to perform the test. 858 876 877 Jump branch8(Condition cond, Address left, Imm32 right) 878 { 879 // Make sure the immediate value is unsigned 8 bits. 880 ASSERT(!(right.m_value & 0xFFFFFF00)); 881 load8(left, dataTempRegister); 882 move(right, immTempRegister); 883 return branch32(cond, dataTempRegister, immTempRegister); 884 } 885 859 886 Jump branch32(Condition cond, RegisterID left, RegisterID right) 860 887 { … … 1036 1063 { 1037 1064 load32(address, dataTempRegister); 1065 return branchTest32(cond, dataTempRegister, mask); 1066 } 1067 1068 Jump branchTest8(Condition cond, Address address, Imm32 mask = Imm32(-1)) 1069 { 1070 load8(address, dataTempRegister); 1038 1071 return branchTest32(cond, dataTempRegister, mask); 1039 1072 } … … 1333 1366 } 1334 1367 1368 void setTest8(Condition cond, Address address, Imm32 mask, RegisterID dest) 1369 { 1370 ASSERT((cond == Zero) || (cond == NonZero)); 1371 load8(address, dataTempRegister); 1372 if (mask.m_value == -1 && !m_fixedWidth) { 1373 if (cond == Zero) 1374 m_assembler.sltiu(dest, dataTempRegister, 1); 1375 else 1376 m_assembler.sltu(dest, MIPSRegisters::zero, dataTempRegister); 1377 } else { 1378 move(mask, immTempRegister); 1379 m_assembler.andInsn(cmpTempRegister, dataTempRegister, 1380 immTempRegister); 1381 if (cond == Zero) 1382 m_assembler.sltiu(dest, cmpTempRegister, 1); 1383 else 1384 m_assembler.sltu(dest, MIPSRegisters::zero, cmpTempRegister); 1385 } 1386 } 1387 1335 1388 void setTest32(Condition cond, Address address, Imm32 mask, RegisterID dest) 1336 1389 { … … 1345 1398 move(mask, immTempRegister); 1346 1399 m_assembler.andInsn(cmpTempRegister, dataTempRegister, 1347 1400 immTempRegister); 1348 1401 if (cond == Zero) 1349 1402 m_assembler.sltiu(dest, cmpTempRegister, 1); -
trunk/JavaScriptCore/jit/JIT.h
r55633 r56759 267 267 static const FPRegisterID fpRegT1 = ARMRegisters::d1; 268 268 static const FPRegisterID fpRegT2 = ARMRegisters::d2; 269 #elif CPU(MIPS) 270 static const RegisterID returnValueRegister = MIPSRegisters::v0; 271 static const RegisterID cachedResultRegister = MIPSRegisters::v0; 272 static const RegisterID firstArgumentRegister = MIPSRegisters::a0; 273 274 // regT0 must be v0 for returning a 32-bit value. 275 static const RegisterID regT0 = MIPSRegisters::v0; 276 277 // regT1 must be v1 for returning a pair of 32-bit value. 278 static const RegisterID regT1 = MIPSRegisters::v1; 279 280 static const RegisterID regT2 = MIPSRegisters::t4; 281 282 // regT3 must be saved in the callee, so use an S register. 283 static const RegisterID regT3 = MIPSRegisters::s2; 284 285 static const RegisterID callFrameRegister = MIPSRegisters::s0; 286 static const RegisterID timeoutCheckRegister = MIPSRegisters::s1; 287 288 static const FPRegisterID fpRegT0 = MIPSRegisters::f4; 289 static const FPRegisterID fpRegT1 = MIPSRegisters::f6; 290 static const FPRegisterID fpRegT2 = MIPSRegisters::f8; 269 291 #else 270 292 #error "JIT not supported on this platform." … … 685 707 static const int sequencePutByIdInstructionSpace = 28; 686 708 static const int sequencePutByIdConstantSpace = 3; 709 #elif CPU(MIPS) 710 #if WTF_MIPS_ISA(1) 711 static const int patchOffsetPutByIdStructure = 16; 712 static const int patchOffsetPutByIdExternalLoad = 48; 713 static const int patchLengthPutByIdExternalLoad = 20; 714 static const int patchOffsetPutByIdPropertyMapOffset = 68; 715 static const int patchOffsetGetByIdStructure = 16; 716 static const int patchOffsetGetByIdBranchToSlowCase = 48; 717 static const int patchOffsetGetByIdExternalLoad = 48; 718 static const int patchLengthGetByIdExternalLoad = 20; 719 static const int patchOffsetGetByIdPropertyMapOffset = 68; 720 static const int patchOffsetGetByIdPutResult = 88; 721 #if ENABLE(OPCODE_SAMPLING) 722 #error "OPCODE_SAMPLING is not yet supported" 723 #else 724 static const int patchOffsetGetByIdSlowCaseCall = 40; 725 #endif 726 static const int patchOffsetOpCallCompareToJump = 32; 727 static const int patchOffsetMethodCheckProtoObj = 32; 728 static const int patchOffsetMethodCheckProtoStruct = 56; 729 static const int patchOffsetMethodCheckPutFunction = 88; 730 #else // WTF_MIPS_ISA(1) 731 static const int patchOffsetPutByIdStructure = 12; 732 static const int patchOffsetPutByIdExternalLoad = 44; 733 static const int patchLengthPutByIdExternalLoad = 16; 734 static const int patchOffsetPutByIdPropertyMapOffset = 60; 735 static const int patchOffsetGetByIdStructure = 12; 736 static const int patchOffsetGetByIdBranchToSlowCase = 44; 737 static const int patchOffsetGetByIdExternalLoad = 44; 738 static const int patchLengthGetByIdExternalLoad = 16; 739 static const int patchOffsetGetByIdPropertyMapOffset = 60; 740 static const int patchOffsetGetByIdPutResult = 76; 741 #if ENABLE(OPCODE_SAMPLING) 742 #error "OPCODE_SAMPLING is not yet supported" 743 #else 744 static const int patchOffsetGetByIdSlowCaseCall = 40; 745 #endif 746 static const int patchOffsetOpCallCompareToJump = 32; 747 static const int patchOffsetMethodCheckProtoObj = 32; 748 static const int patchOffsetMethodCheckProtoStruct = 52; 749 static const int patchOffsetMethodCheckPutFunction = 84; 750 #endif 687 751 #endif 688 752 #endif // USE(JSVALUE32_64) -
trunk/JavaScriptCore/jit/JITInlineMethods.h
r55633 r56759 161 161 } 162 162 163 #elif CPU(MIPS) 164 165 ALWAYS_INLINE void JIT::preserveReturnAddressAfterCall(RegisterID reg) 166 { 167 move(returnAddressRegister, reg); 168 } 169 170 ALWAYS_INLINE void JIT::restoreReturnAddressBeforeReturn(RegisterID reg) 171 { 172 move(reg, returnAddressRegister); 173 } 174 175 ALWAYS_INLINE void JIT::restoreReturnAddressBeforeReturn(Address address) 176 { 177 loadPtr(address, returnAddressRegister); 178 } 179 163 180 #else // CPU(X86) || CPU(X86_64) 164 181 -
trunk/JavaScriptCore/jit/JITOpcodes.cpp
r55684 r56759 1835 1835 #endif // OS(WINCE) 1836 1836 1837 #elif CPU(MIPS) 1838 emitGetFromCallFrameHeader32(RegisterFile::ArgumentCount, regT0); 1839 1840 // Allocate stack space for our arglist 1841 COMPILE_ASSERT(!(sizeof(ArgList) & 0x7), ArgList_should_by_8byte_aligned); 1842 subPtr(Imm32(sizeof(ArgList) + 24), stackPointerRegister); 1843 1844 // Set up arguments 1845 subPtr(Imm32(1), regT0); // Don't include 'this' in argcount 1846 1847 // Push argcount to 24 + offset($sp) 1848 storePtr(regT0, Address(stackPointerRegister, 24 + OBJECT_OFFSETOF(ArgList, m_argCount))); 1849 1850 // Calculate the start of the callframe header, and store in regT1 1851 move(callFrameRegister, regT1); 1852 sub32(Imm32(RegisterFile::CallFrameHeaderSize * (int32_t)sizeof(Register)), regT1); 1853 1854 // Calculate start of arguments as callframe header - sizeof(Register) * argcount (regT1) 1855 mul32(Imm32(sizeof(Register)), regT0, regT0); 1856 subPtr(regT0, regT1); 1857 1858 // push pointer to arguments to 24 + offset($sp) 1859 storePtr(regT1, Address(stackPointerRegister, 24 + OBJECT_OFFSETOF(ArgList, m_args))); 1860 1861 // Setup arg3: regT1 currently points to the first argument, regT1-sizeof(Register) points to 'this' 1862 loadPtr(Address(regT1, -(int32_t)sizeof(Register)), MIPSRegisters::a3); 1863 1864 // Setup arg2: 1865 emitGetFromCallFrameHeaderPtr(RegisterFile::Callee, MIPSRegisters::a2); 1866 1867 // Setup arg1: 1868 move(callFrameRegister, MIPSRegisters::a1); 1869 1870 // Setup arg4: ArgList is passed by reference. At 16($sp), store ($sp + 24) 1871 addPtr(Imm32(24), stackPointerRegister, regT2); 1872 storePtr(regT2, Address(stackPointerRegister, 16)); 1873 1874 // Setup arg0 as 20($sp) to hold the returned structure. 1875 ASSERT(sizeof(JSValue) == 4); 1876 addPtr(Imm32(20), stackPointerRegister, MIPSRegisters::a0); 1877 1878 // Call 1879 call(Address(MIPSRegisters::a2, OBJECT_OFFSETOF(JSFunction, m_data))); 1880 1881 // Get returned value from 0($v0) which is the same as 20($sp) 1882 loadPtr(Address(returnValueRegister, 0), returnValueRegister); 1883 1884 // Restore stack space 1885 addPtr(Imm32(sizeof(ArgList) + 24), stackPointerRegister); 1886 1837 1887 #elif ENABLE(JIT_OPTIMIZE_NATIVE_CALL) 1838 1888 #error "JIT_OPTIMIZE_NATIVE_CALL not yet supported on this platform." -
trunk/JavaScriptCore/jit/JITStubs.cpp
r56000 r56759 481 481 #define PRESERVEDR4_OFFSET 36 482 482 483 #elif CPU(MIPS) 484 485 #if USE(JIT_STUB_ARGUMENT_VA_LIST) 486 #error "JIT_STUB_ARGUMENT_VA_LIST not supported on MIPS." 487 #endif 488 489 asm volatile( 490 ".text" "\n" 491 ".align 2" "\n" 492 ".set noreorder" "\n" 493 ".set nomacro" "\n" 494 ".set nomips16" "\n" 495 ".globl " SYMBOL_STRING(ctiTrampoline) "\n" 496 ".ent " SYMBOL_STRING(ctiTrampoline) "\n" 497 SYMBOL_STRING(ctiTrampoline) ":" "\n" 498 "addiu $29,$29,-72" "\n" 499 "sw $31,44($29)" "\n" 500 "sw $18,40($29)" "\n" 501 "sw $17,36($29)" "\n" 502 "sw $16,32($29)" "\n" 503 #if WTF_MIPS_PIC 504 "sw $28,28($29)" "\n" 505 #endif 506 "move $16,$6 # set callFrameRegister" "\n" 507 "li $17,512 # set timeoutCheckRegister" "\n" 508 "move $25,$4 # move executableAddress to t9" "\n" 509 "sw $5,52($29) # store registerFile to current stack" "\n" 510 "sw $6,56($29) # store callFrame to curent stack" "\n" 511 "sw $7,60($29) # store exception to current stack" "\n" 512 "lw $8,88($29) # load enableProfilerReference from previous stack" "\n" 513 "lw $9,92($29) # load globalData from previous stack" "\n" 514 "sw $8,64($29) # store enableProfilerReference to current stack" "\n" 515 "jalr $25" "\n" 516 "sw $9,68($29) # store globalData to current stack" "\n" 517 "lw $16,32($29)" "\n" 518 "lw $17,36($29)" "\n" 519 "lw $18,40($29)" "\n" 520 "lw $31,44($29)" "\n" 521 "jr $31" "\n" 522 "addiu $29,$29,72" "\n" 523 ".set reorder" "\n" 524 ".set macro" "\n" 525 ".end " SYMBOL_STRING(ctiTrampoline) "\n" 526 ); 527 528 asm volatile( 529 ".text" "\n" 530 ".align 2" "\n" 531 ".set noreorder" "\n" 532 ".set nomacro" "\n" 533 ".set nomips16" "\n" 534 ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" 535 ".ent " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" 536 SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" 537 #if WTF_MIPS_PIC 538 "lw $28,28($29)" "\n" 539 ".set macro" "\n" 540 "la $25," SYMBOL_STRING(cti_vm_throw) "\n" 541 ".set nomacro" "\n" 542 "bal " SYMBOL_STRING(cti_vm_throw) "\n" 543 "move $4,$29" "\n" 544 #else 545 "jal " SYMBOL_STRING(cti_vm_throw) "\n" 546 "move $4,$29" "\n" 547 #endif 548 "lw $16,32($29)" "\n" 549 "lw $17,36($29)" "\n" 550 "lw $18,40($29)" "\n" 551 "lw $31,44($29)" "\n" 552 "jr $31" "\n" 553 "addiu $29,$29,72" "\n" 554 ".set reorder" "\n" 555 ".set macro" "\n" 556 ".end " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" 557 ); 558 559 asm volatile( 560 ".text" "\n" 561 ".align 2" "\n" 562 ".set noreorder" "\n" 563 ".set nomacro" "\n" 564 ".set nomips16" "\n" 565 ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" 566 ".ent " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" 567 SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" 568 "lw $16,32($29)" "\n" 569 "lw $17,36($29)" "\n" 570 "lw $18,40($29)" "\n" 571 "lw $31,44($29)" "\n" 572 "jr $31" "\n" 573 "addiu $29,$29,72" "\n" 574 ".set reorder" "\n" 575 ".set macro" "\n" 576 ".end " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" 577 ); 578 483 579 #elif COMPILER(RVCT) && CPU(ARM_TRADITIONAL) 484 580 … … 723 819 ASSERT(OBJECT_OFFSETOF(struct JITStackFrame, preservedR4) == PRESERVEDR4_OFFSET); 724 820 821 822 #elif CPU(MIPS) 823 ASSERT(OBJECT_OFFSETOF(struct JITStackFrame, preservedGP) == 28); 824 ASSERT(OBJECT_OFFSETOF(struct JITStackFrame, preservedS0) == 32); 825 ASSERT(OBJECT_OFFSETOF(struct JITStackFrame, preservedS1) == 36); 826 ASSERT(OBJECT_OFFSETOF(struct JITStackFrame, preservedS2) == 40); 827 ASSERT(OBJECT_OFFSETOF(struct JITStackFrame, preservedReturnAddress) == 44); 828 ASSERT(OBJECT_OFFSETOF(struct JITStackFrame, thunkReturnAddress) == 48); 829 ASSERT(OBJECT_OFFSETOF(struct JITStackFrame, registerFile) == 52); 830 ASSERT(OBJECT_OFFSETOF(struct JITStackFrame, callFrame) == 56); 831 ASSERT(OBJECT_OFFSETOF(struct JITStackFrame, exception) == 60); 832 ASSERT(OBJECT_OFFSETOF(struct JITStackFrame, enabledProfilerReference) == 64); 833 ASSERT(OBJECT_OFFSETOF(struct JITStackFrame, globalData) == 68); 834 725 835 #endif 726 836 } … … 980 1090 ); \ 981 1091 rtype JITStubThunked_##op(STUB_ARGS_DECLARATION) \ 1092 1093 #elif CPU(MIPS) 1094 #if WTF_MIPS_PIC 1095 #define DEFINE_STUB_FUNCTION(rtype, op) \ 1096 extern "C" { \ 1097 rtype JITStubThunked_##op(STUB_ARGS_DECLARATION); \ 1098 }; \ 1099 asm volatile( \ 1100 ".text" "\n" \ 1101 ".align 2" "\n" \ 1102 ".set noreorder" "\n" \ 1103 ".set nomacro" "\n" \ 1104 ".set nomips16" "\n" \ 1105 ".globl " SYMBOL_STRING(cti_##op) "\n" \ 1106 ".ent " SYMBOL_STRING(cti_##op) "\n" \ 1107 SYMBOL_STRING(cti_##op) ":" "\n" \ 1108 "lw $28,28($29)" "\n" \ 1109 "sw $31,48($29)" "\n" \ 1110 ".set macro" "\n" \ 1111 "la $25," SYMBOL_STRING(JITStubThunked_##op) "\n" \ 1112 ".set nomacro" "\n" \ 1113 "bal " SYMBOL_STRING(JITStubThunked_##op) "\n" \ 1114 "nop" "\n" \ 1115 "lw $31,48($29)" "\n" \ 1116 "jr $31" "\n" \ 1117 "nop" "\n" \ 1118 ".set reorder" "\n" \ 1119 ".set macro" "\n" \ 1120 ".end " SYMBOL_STRING(cti_##op) "\n" \ 1121 ); \ 1122 rtype JITStubThunked_##op(STUB_ARGS_DECLARATION) 1123 1124 #else // WTF_MIPS_PIC 1125 #define DEFINE_STUB_FUNCTION(rtype, op) \ 1126 extern "C" { \ 1127 rtype JITStubThunked_##op(STUB_ARGS_DECLARATION); \ 1128 }; \ 1129 asm volatile( \ 1130 ".text" "\n" \ 1131 ".align 2" "\n" \ 1132 ".set noreorder" "\n" \ 1133 ".set nomacro" "\n" \ 1134 ".set nomips16" "\n" \ 1135 ".globl " SYMBOL_STRING(cti_##op) "\n" \ 1136 ".ent " SYMBOL_STRING(cti_##op) "\n" \ 1137 SYMBOL_STRING(cti_##op) ":" "\n" \ 1138 "sw $31,48($29)" "\n" \ 1139 "jal " SYMBOL_STRING(JITStubThunked_##op) "\n" \ 1140 "nop" "\n" \ 1141 "lw $31,48($29)" "\n" \ 1142 "jr $31" "\n" \ 1143 "nop" "\n" \ 1144 ".set reorder" "\n" \ 1145 ".set macro" "\n" \ 1146 ".end " SYMBOL_STRING(cti_##op) "\n" \ 1147 ); \ 1148 rtype JITStubThunked_##op(STUB_ARGS_DECLARATION) 1149 1150 #endif 982 1151 983 1152 #elif CPU(ARM_TRADITIONAL) && COMPILER(GCC) -
trunk/JavaScriptCore/jit/JITStubs.h
r55633 r56759 188 188 189 189 // When JIT code makes a call, it pushes its return address just below the rest of the stack. 190 ReturnAddressPtr* returnAddressSlot() { return &thunkReturnAddress; } 191 }; 192 #elif CPU(MIPS) 193 struct JITStackFrame { 194 void* reserved; // Unused 195 JITStubArg args[6]; 196 197 void* preservedGP; // store GP when using PIC code 198 void* preservedS0; 199 void* preservedS1; 200 void* preservedS2; 201 void* preservedReturnAddress; 202 203 ReturnAddressPtr thunkReturnAddress; 204 205 // These arguments passed in a1..a3 (a0 contained the entry code pointed, which is not preserved) 206 RegisterFile* registerFile; 207 CallFrame* callFrame; 208 JSValue* exception; 209 210 // These arguments passed on the stack. 211 Profiler** enabledProfilerReference; 212 JSGlobalData* globalData; 213 190 214 ReturnAddressPtr* returnAddressSlot() { return &thunkReturnAddress; } 191 215 }; -
trunk/JavaScriptCore/wtf/Platform.h
r56740 r56759 930 930 #elif CPU(ARM_TRADITIONAL) && OS(LINUX) 931 931 #define ENABLE_JIT 1 932 #elif CPU(MIPS) && OS(LINUX) 933 #define ENABLE_JIT 1 934 #define WTF_USE_JIT_STUB_ARGUMENT_VA_LIST 0 932 935 #endif 933 936 #endif /* PLATFORM(QT) */
Note: See TracChangeset
for help on using the changeset viewer.