Changeset 153162 in webkit for trunk/Source/JavaScriptCore/assembler
- Timestamp:
- Jul 24, 2013, 9:00:16 PM (12 years ago)
- Location:
- trunk/Source/JavaScriptCore/assembler
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/assembler/MacroAssembler.h
r143408 r153162 1 1 /* 2 * Copyright (C) 2008, 2012 Apple Inc. All rights reserved.2 * Copyright (C) 2008, 2012, 2013 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 572 572 return MacroAssemblerBase::branchTest8(cond, Address(address.base, address.offset), mask); 573 573 } 574 #else 574 575 #else // !CPU(X86_64) 576 575 577 void addPtr(RegisterID src, RegisterID dest) 576 578 { … … 1068 1070 } 1069 1071 1070 #endif 1072 #endif // ENABLE(JIT_CONSTANT_BLINDING) 1071 1073 1072 1074 #endif // !CPU(X86_64) … … 1080 1082 // if we've broken blinding during patch development. 1081 1083 return true; 1082 #else 1084 #else // ENABLE(FORCED_JIT_BLINDING) 1083 1085 1084 1086 // First off we'll special case common, "safe" values to avoid hurting … … 1101 1103 1102 1104 return shouldBlindForSpecificArch(value); 1103 #endif 1105 #endif // ENABLE(FORCED_JIT_BLINDING) 1104 1106 } 1105 1107 … … 1272 1274 store64(value, addressForPoke(index)); 1273 1275 } 1274 #endif 1276 #endif // CPU(X86_64) 1275 1277 1276 1278 void store32(Imm32 imm, Address dest) … … 1281 1283 store32(blind.value1, dest); 1282 1284 xor32(blind.value2, dest); 1283 #else 1285 #else // CPU(X86) || CPU(X86_64) 1284 1286 if (RegisterID scratchRegister = (RegisterID)scratchRegisterForBlinding()) { 1285 1287 loadXorBlindedConstant(xorBlindConstant(imm), scratchRegister); … … 1293 1295 store32(imm.asTrustedImm32(), dest); 1294 1296 } 1295 #endif 1297 #endif // CPU(X86) || CPU(X86_64) 1296 1298 } else 1297 1299 store32(imm.asTrustedImm32(), dest); … … 1441 1443 urshift32(src, trustedImm32ForShift(amount), dest); 1442 1444 } 1443 #endif 1445 #endif // ENABLE(JIT_CONSTANT_BLINDING) 1444 1446 }; 1445 1447 -
trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86.h
r135330 r153162 31 31 #include "MacroAssemblerX86Common.h" 32 32 33 #if USE(MASM_PROBE) 34 #include <wtf/StdLibExtras.h> 35 #endif 36 33 37 namespace JSC { 34 38 … … 288 292 } 289 293 294 #if USE(MASM_PROBE) 295 // This function emits code to preserve the CPUState (e.g. registers), 296 // call a user supplied probe function, and restore the CPUState before 297 // continuing with other JIT generated code. 298 // 299 // The user supplied probe function will be called with a single pointer to 300 // a ProbeContext struct (defined above) which contains, among other things, 301 // the preserved CPUState. This allows the user probe function to inspect 302 // the CPUState at that point in the JIT generated code. 303 // 304 // If the user probe function alters the register values in the ProbeContext, 305 // the altered values will be loaded into the CPU registers when the probe 306 // returns. 307 // 308 // The ProbeContext is stack allocated and is only valid for the duration 309 // of the call to the user probe function. 310 311 void probe(ProbeFunction, void* arg1 = 0, void* arg2 = 0); 312 #endif // USE(MASM_PROBE) 313 290 314 private: 291 315 friend class LinkBuffer; … … 306 330 X86Assembler::relinkCall(call.dataLocation(), destination.executableAddress()); 307 331 } 332 333 #if USE(MASM_PROBE) 334 inline TrustedImm32 trustedImm32FromPtr(void* ptr) 335 { 336 return TrustedImm32(TrustedImmPtr(ptr)); 337 } 338 339 inline TrustedImm32 trustedImm32FromPtr(ProbeFunction function) 340 { 341 return TrustedImm32(TrustedImmPtr(reinterpret_cast<void*>(function))); 342 } 343 344 inline TrustedImm32 trustedImm32FromPtr(void (*function)()) 345 { 346 return TrustedImm32(TrustedImmPtr(reinterpret_cast<void*>(function))); 347 } 348 #endif 308 349 }; 309 350 351 #if USE(MASM_PROBE) 352 353 extern "C" void ctiMasmProbeTrampoline(); 354 355 // What code is emitted for the probe? 356 // ================================== 357 // We want to keep the size of the emitted probe invocation code as compact as 358 // possible to minimize the perturbation to the JIT generated code. However, 359 // we also need to preserve the CPU registers and set up the ProbeContext to be 360 // passed to the user probe function. 361 // 362 // Hence, we do only the minimum here to preserve the eax (to be used as a 363 // scratch register) and esp registers, and pass the probe arguments. We'll let 364 // the ctiMasmProbeTrampoline handle the rest of the probe invocation work 365 // i.e. saving the CPUState (and setting up the ProbeContext), calling the user 366 // probe function, and restoring the CPUState before returning to JIT generated 367 // code. 368 // 369 // What values are in the saved registers? 370 // ====================================== 371 // Conceptually, the saved registers should contain values as if the probe 372 // is not present in the JIT generated code. Hence, they should contain values 373 // that are expected at the start of the instruction immediately following the 374 // probe. 375 // 376 // Specifcally, the saved esp will point to the stack position before we 377 // push the ProbeContext frame. The saved eip will point to the address of 378 // the instruction immediately following the probe. 379 380 inline void MacroAssemblerX86::probe(MacroAssemblerX86::ProbeFunction function, void* arg1, void* arg2) 381 { 382 RegisterID esp = RegisterID::esp; 383 #define probeContextField(field) Address(esp, offsetof(ProbeContext, field)) 384 385 // The X86_64 ABI specifies that the worse case stack alignment requirement 386 // is 32 bytes. 387 const int probeFrameSize = WTF::roundUpToMultipleOf(32, sizeof(ProbeContext)); 388 sub32(TrustedImm32(probeFrameSize), esp); 389 390 store32(RegisterID::eax, probeContextField(cpu.eax)); 391 392 move(TrustedImm32(probeFrameSize), RegisterID::eax); 393 add32(esp, RegisterID::eax); 394 store32(RegisterID::eax, probeContextField(cpu.esp)); 395 396 store32(trustedImm32FromPtr(function), probeContextField(probeFunction)); 397 store32(trustedImm32FromPtr(arg1), probeContextField(arg1)); 398 store32(trustedImm32FromPtr(arg2), probeContextField(arg2)); 399 400 move(trustedImm32FromPtr(ctiMasmProbeTrampoline), RegisterID::eax); 401 call(RegisterID::eax); 402 403 #undef probeContextField 404 } 405 #endif // USE(MASM_PROBE) 406 310 407 } // namespace JSC 311 408 -
trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86Common.h
r153121 r153162 34 34 namespace JSC { 35 35 36 struct JITStackFrame; 37 36 38 class MacroAssemblerX86Common : public AbstractMacroAssembler<X86Assembler> { 37 39 protected: … … 1439 1441 return X86Assembler::maxJumpReplacementSize(); 1440 1442 } 1443 1444 #if USE(MASM_PROBE) 1445 struct CPUState { 1446 #define DECLARE_REGISTER(_type, _regName) \ 1447 _type _regName; 1448 FOR_EACH_CPU_REGISTER(DECLARE_REGISTER) 1449 #undef DECLARE_REGISTER 1450 }; 1451 1452 struct ProbeContext; 1453 typedef void (*ProbeFunction)(struct ProbeContext*); 1454 1455 struct ProbeContext { 1456 ProbeFunction probeFunction; 1457 void* arg1; 1458 void* arg2; 1459 JITStackFrame* jitStackFrame; 1460 CPUState cpu; 1461 1462 void dump(const char* indentation = 0); 1463 private: 1464 void dumpCPURegisters(const char* indentation); 1465 }; 1466 #endif // USE(MASM_PROBE) 1441 1467 1442 1468 protected: -
trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86_64.h
r135330 r153162 31 31 #include "MacroAssemblerX86Common.h" 32 32 33 #if USE(MASM_PROBE) 34 #include <wtf/StdLibExtras.h> 35 #endif 36 33 37 #define REPTACH_OFFSET_CALL_R11 3 34 38 … … 613 617 } 614 618 619 #if USE(MASM_PROBE) 620 // This function emits code to preserve the CPUState (e.g. registers), 621 // call a user supplied probe function, and restore the CPUState before 622 // continuing with other JIT generated code. 623 // 624 // The user supplied probe function will be called with a single pointer to 625 // a ProbeContext struct (defined above) which contains, among other things, 626 // the preserved CPUState. This allows the user probe function to inspect 627 // the CPUState at that point in the JIT generated code. 628 // 629 // If the user probe function alters the register values in the ProbeContext, 630 // the altered values will be loaded into the CPU registers when the probe 631 // returns. 632 // 633 // The ProbeContext is stack allocated and is only valid for the duration 634 // of the call to the user probe function. 635 636 void probe(ProbeFunction, void* arg1 = 0, void* arg2 = 0); 637 #endif // USE(MASM_PROBE) 638 615 639 private: 616 640 friend class LinkBuffer; … … 635 659 } 636 660 661 #if USE(MASM_PROBE) 662 inline TrustedImm64 trustedImm64FromPtr(void* ptr) 663 { 664 return TrustedImm64(TrustedImmPtr(ptr)); 665 } 666 667 inline TrustedImm64 trustedImm64FromPtr(ProbeFunction function) 668 { 669 return TrustedImm64(TrustedImmPtr(reinterpret_cast<void*>(function))); 670 } 671 672 inline TrustedImm64 trustedImm64FromPtr(void (*function)()) 673 { 674 return TrustedImm64(TrustedImmPtr(reinterpret_cast<void*>(function))); 675 } 676 #endif 637 677 }; 638 678 679 #if USE(MASM_PROBE) 680 681 extern "C" void ctiMasmProbeTrampoline(); 682 683 // What code is emitted for the probe? 684 // ================================== 685 // We want to keep the size of the emitted probe invocation code as compact as 686 // possible to minimize the perturbation to the JIT generated code. However, 687 // we also need to preserve the CPU registers and set up the ProbeContext to be 688 // passed to the user probe function. 689 // 690 // Hence, we do only the minimum here to preserve the rax (to be used as a 691 // scratch register) and rsp registers, and pass the probe arguments. We'll let 692 // the ctiMasmProbeTrampoline handle the rest of the probe invocation work 693 // i.e. saving the CPUState (and setting up the ProbeContext), calling the user 694 // probe function, and restoring the CPUState before returning to JIT generated 695 // code. 696 // 697 // What values are in the saved registers? 698 // ====================================== 699 // Conceptually, the saved registers should contain values as if the probe 700 // is not present in the JIT generated code. Hence, they should contain values 701 // that are expected at the start of the instruction immediately following the 702 // probe. 703 // 704 // Specifcally, the saved rsp will point to the stack position before we 705 // push the ProbeContext frame. The saved rip will point to the address of 706 // the instruction immediately following the probe. 707 708 inline void MacroAssemblerX86_64::probe(MacroAssemblerX86_64::ProbeFunction function, void* arg1, void* arg2) 709 { 710 RegisterID esp = RegisterID::esp; 711 #define probeContextField(field) Address(esp, offsetof(ProbeContext, field)) 712 713 // The X86_64 ABI specifies that the worse case stack alignment requirement 714 // is 32 bytes. 715 const int probeFrameSize = WTF::roundUpToMultipleOf(32, sizeof(ProbeContext)); 716 sub64(TrustedImm32(probeFrameSize), esp); 717 718 store64(RegisterID::eax, probeContextField(cpu.eax)); 719 720 move(TrustedImm32(probeFrameSize), RegisterID::eax); 721 add64(esp, RegisterID::eax); 722 store64(RegisterID::eax, probeContextField(cpu.esp)); 723 724 store64(trustedImm64FromPtr(function), probeContextField(probeFunction)); 725 store64(trustedImm64FromPtr(arg1), probeContextField(arg1)); 726 store64(trustedImm64FromPtr(arg2), probeContextField(arg2)); 727 728 move(trustedImm64FromPtr(ctiMasmProbeTrampoline), RegisterID::eax); 729 call(RegisterID::eax); 730 731 #undef probeContextField 732 } 733 #endif // USE(MASM_PROBE) 734 639 735 } // namespace JSC 640 736 -
trunk/Source/JavaScriptCore/assembler/X86Assembler.h
r148696 r153162 1 1 /* 2 * Copyright (C) 2008, 2012 Apple Inc. All rights reserved.2 * Copyright (C) 2008, 2012, 2013 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 35 35 #include <wtf/Vector.h> 36 36 37 #if USE(MASM_PROBE) 38 #include <xmmintrin.h> 39 #endif 40 37 41 namespace JSC { 38 42 … … 72 76 xmm7, 73 77 } XMMRegisterID; 78 79 #if USE(MASM_PROBE) 80 #define FOR_EACH_CPU_REGISTER(V) \ 81 FOR_EACH_CPU_GPREGISTER(V) \ 82 FOR_EACH_CPU_FPREGISTER(V) 83 84 #define FOR_EACH_CPU_GPREGISTER(V) \ 85 V(void*, eax) \ 86 V(void*, ecx) \ 87 V(void*, edx) \ 88 V(void*, ebx) \ 89 V(void*, esp) \ 90 V(void*, ebp) \ 91 V(void*, esi) \ 92 V(void*, edi) \ 93 FOR_EACH_X86_64_CPU_GPREGISTER(V) \ 94 V(void*, eip) 95 96 #define FOR_EACH_CPU_FPREGISTER(V) \ 97 V(__m128, xmm0) \ 98 V(__m128, xmm1) \ 99 V(__m128, xmm2) \ 100 V(__m128, xmm3) \ 101 V(__m128, xmm4) \ 102 V(__m128, xmm5) \ 103 V(__m128, xmm6) \ 104 V(__m128, xmm7) 105 106 #if CPU(X86) 107 #define FOR_EACH_X86_64_CPU_GPREGISTER(V) // Nothing to add. 108 #elif CPU(X86_64) 109 #define FOR_EACH_X86_64_CPU_GPREGISTER(V) \ 110 V(void*, r8) \ 111 V(void*, r9) \ 112 V(void*, r10) \ 113 V(void*, r11) \ 114 V(void*, r12) \ 115 V(void*, r13) \ 116 V(void*, r14) \ 117 V(void*, r15) 118 #endif // CPU(X86_64) 119 #endif // USE(MASM_PROBE) 74 120 } 75 121
Note:
See TracChangeset
for help on using the changeset viewer.