Changeset 153197 in webkit for trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86.h
- Timestamp:
- Jul 24, 2013, 9:01:38 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/assembler/MacroAssemblerX86.h
r153162 r153197 293 293 294 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 295 // For details about probe(), see comment in MacroAssemblerX86_64.h. 311 296 void probe(ProbeFunction, void* arg1 = 0, void* arg2 = 0); 312 297 #endif // USE(MASM_PROBE) … … 353 338 extern "C" void ctiMasmProbeTrampoline(); 354 339 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. 340 // For details on "What code is emitted for the probe?" and "What values are in 341 // the saved registers?", see comment for MacroAssemblerX86::probe() in 342 // MacroAssemblerX86_64.h. 379 343 380 344 inline void MacroAssemblerX86::probe(MacroAssemblerX86::ProbeFunction function, void* arg1, void* arg2) 381 345 { 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)); 346 push(RegisterID::esp); 347 push(RegisterID::eax); 348 push(trustedImm32FromPtr(arg2)); 349 push(trustedImm32FromPtr(arg1)); 350 push(trustedImm32FromPtr(function)); 399 351 400 352 move(trustedImm32FromPtr(ctiMasmProbeTrampoline), RegisterID::eax); 401 353 call(RegisterID::eax); 402 403 #undef probeContextField404 354 } 405 355 #endif // USE(MASM_PROBE)
Note:
See TracChangeset
for help on using the changeset viewer.