Repository navigation
Commit 861ea3b
committed
[JSC] Add linkThunk mechanism
https://bugs.webkit.org/show_bug.cgi?id=265854
rdar://119171337
Reviewed by Mark Lam.
This patch adds linkThunk mechanism to Jump and Call. Previously, we were using LinkBuffer::link when jumping to a thunk or calling a thunk.
But the implementation of this is really costly and it was not so good. (1) it uses performJITMemcpy to rewrite code, which does JIT memory
permission switch every time. And (2) it does not leverage branch compaction. So even though it is thunk address, we never do branch compaction
and typically we have several nops around it.
Instead, we have linkThunk mechanism which can just link Jump and Call to a thunk. On ARM64, this is fully integrated into our branch compaction
mechanism so that we can repatch it through LinkBuffer's branch compaction. On the other architectures, it is the same to the current behavior.
* Source/JavaScriptCore/assembler/ARM64Assembler.h:
(JSC::ARM64Assembler::LinkRecord::LinkRecord):
(JSC::ARM64Assembler::LinkRecord::isThunk const):
* Source/JavaScriptCore/assembler/ARMv7Assembler.h:
(JSC::ARMv7Assembler::LinkRecord::setFrom):
(JSC::ARMv7Assembler::LinkRecord::to const):
* Source/JavaScriptCore/assembler/AbstractMacroAssembler.h:
(JSC::AbstractMacroAssembler::Jump::linkThunk const):
(JSC::AbstractMacroAssembler::JumpList::linkTo const):
(JSC::AbstractMacroAssembler::JumpList::linkThunk const):
* Source/JavaScriptCore/assembler/LinkBuffer.cpp:
(JSC::LinkBuffer::copyCompactAndLinkCode):
* Source/JavaScriptCore/assembler/MacroAssemblerARM64.h:
(JSC::MacroAssemblerARM64::callOperation):
(JSC::MacroAssemblerARM64::callThunk):
(JSC::MacroAssemblerARM64::jumpThunk):
* Source/JavaScriptCore/assembler/MacroAssemblerARM64E.h:
(JSC::MacroAssemblerARM64E::callOperation):
* Source/JavaScriptCore/assembler/MacroAssemblerARMv7.h:
(JSC::MacroAssemblerARMv7::callOperation):
(JSC::MacroAssemblerARMv7::callThunk):
(JSC::MacroAssemblerARMv7::jumpThunk):
* Source/JavaScriptCore/assembler/MacroAssemblerRISCV64.h:
(JSC::MacroAssemblerRISCV64::callOperation):
(JSC::MacroAssemblerRISCV64::callThunk):
(JSC::MacroAssemblerRISCV64::jumpThunk):
* Source/JavaScriptCore/assembler/MacroAssemblerX86_64.h:
(JSC::MacroAssemblerX86_64::callOperation):
(JSC::MacroAssemblerX86_64::callThunk):
(JSC::MacroAssemblerX86_64::jumpThunk):
* Source/JavaScriptCore/bytecode/AccessCaseSnippetParams.cpp:
* Source/JavaScriptCore/bytecode/InlineCacheCompiler.cpp:
(JSC::InlineCacheCompiler::emitExplicitExceptionHandler):
(JSC::getByIdSlowPathCodeGenerator):
(JSC::getByIdWithThisSlowPathCodeGenerator):
(JSC::getByValSlowPathCodeGenerator):
(JSC::getPrivateNameSlowPathCodeGenerator):
(JSC::getByValWithThisSlowPathCodeGenerator):
(JSC::putByIdSlowPathCodeGenerator):
(JSC::putByValSlowPathCodeGenerator):
(JSC::instanceOfSlowPathCodeGenerator):
(JSC::delByIdSlowPathCodeGenerator):
(JSC::delByValSlowPathCodeGenerator):
(JSC::InlineCacheCompiler::generateImpl):
(JSC::InlineCacheCompiler::regenerate):
* Source/JavaScriptCore/bytecode/Repatch.cpp:
(JSC::linkPolymorphicCall):
* Source/JavaScriptCore/ftl/FTLCompile.cpp:
(JSC::FTL::compile):
* Source/JavaScriptCore/ftl/FTLLink.cpp:
(JSC::FTL::link):
* Source/JavaScriptCore/jit/JIT.cpp:
(JSC::JIT::compileAndLinkWithoutFinalizing):
(JSC::JIT::link):
* Source/JavaScriptCore/jit/JITMathIC.h:
(JSC::JITMathIC::generateOutOfLine):
* Source/JavaScriptCore/jit/JITOpcodes.cpp:
(JSC::JIT::op_check_traps_handlerGenerator):
* Source/JavaScriptCore/jit/JITPropertyAccess.cpp:
(JSC::JIT::slow_op_resolve_scopeGenerator):
(JSC::JIT::slow_op_put_to_scopeGenerator):
* Source/JavaScriptCore/jit/SlowPathCall.cpp:
(JSC::JITSlowPathCall::generateThunk):
* Source/JavaScriptCore/jit/SpecializedThunkJIT.h:
(JSC::SpecializedThunkJIT::finalize):
* Source/JavaScriptCore/jit/ThunkGenerators.cpp:
(JSC::popThunkStackPreservesAndHandleExceptionGenerator):
(JSC::checkExceptionGenerator):
(JSC::nativeForGenerator):
* Source/JavaScriptCore/wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::B3IRGenerator::B3IRGenerator):
(JSC::Wasm::B3IRGenerator::emitExceptionCheck):
* Source/JavaScriptCore/wasm/WasmBBQJIT.cpp:
(JSC::Wasm::BBQJIT::emitWriteBarrier):
(JSC::Wasm::BBQJIT::emitThrowException):
(JSC::Wasm::BBQJIT::addTopLevel):
(JSC::Wasm::BBQJIT::addLoopOSREntrypoint):
* Source/JavaScriptCore/wasm/WasmIRGeneratorHelpers.h:
(JSC::Wasm::emitRethrowImpl):
(JSC::Wasm::emitThrowImpl):
* Source/JavaScriptCore/wasm/WasmThunks.cpp:
(JSC::Wasm::catchInWasmThunkGenerator):
* Source/JavaScriptCore/wasm/js/JSToWasm.cpp:
(JSC::Wasm::marshallJSResult):
* Source/JavaScriptCore/wasm/js/WasmToJS.cpp:
(JSC::Wasm::wasmToJS):
(JSC::Wasm::emitThrowWasmToJSException):
Canonical link: https://commits.webkit.org/271801@main1 parent e9e0f31 commit 861ea3b
41 files changed
Lines changed: 387 additions & 496 deletions
File tree
- Source/JavaScriptCore
- assembler
- bytecode
- dfg
- ftl
- jit
- wasm
- js
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
337 | 348 | | |
338 | 349 | | |
339 | | - | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
340 | 364 | | |
341 | 365 | | |
342 | 366 | | |
| |||
346 | 370 | | |
347 | 371 | | |
348 | 372 | | |
349 | | - | |
350 | 373 | | |
| 374 | + | |
351 | 375 | | |
352 | | - | |
| 376 | + | |
353 | 377 | | |
354 | 378 | | |
355 | 379 | | |
| |||
359 | 383 | | |
360 | 384 | | |
361 | 385 | | |
362 | | - | |
363 | 386 | | |
364 | 387 | | |
| 388 | + | |
365 | 389 | | |
366 | 390 | | |
367 | | - | |
| 391 | + | |
368 | 392 | | |
369 | 393 | | |
370 | 394 | | |
| |||
374 | 398 | | |
375 | 399 | | |
376 | 400 | | |
377 | | - | |
378 | 401 | | |
379 | 402 | | |
| 403 | + | |
380 | 404 | | |
381 | 405 | | |
382 | 406 | | |
| |||
412 | 436 | | |
413 | 437 | | |
414 | 438 | | |
| 439 | + | |
415 | 440 | | |
416 | 441 | | |
417 | 442 | | |
| 443 | + | |
418 | 444 | | |
419 | 445 | | |
420 | 446 | | |
421 | 447 | | |
422 | 448 | | |
423 | 449 | | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
433 | 461 | | |
434 | 462 | | |
435 | 463 | | |
| |||
529 | 557 | | |
530 | 558 | | |
531 | 559 | | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
536 | | - | |
537 | | - | |
538 | 560 | | |
539 | 561 | | |
540 | 562 | | |
| |||
3412 | 3434 | | |
3413 | 3435 | | |
3414 | 3436 | | |
3415 | | - | |
| 3437 | + | |
3416 | 3438 | | |
3417 | 3439 | | |
3418 | 3440 | | |
3419 | 3441 | | |
3420 | 3442 | | |
3421 | 3443 | | |
3422 | | - | |
| 3444 | + | |
3423 | 3445 | | |
3424 | 3446 | | |
3425 | 3447 | | |
3426 | 3448 | | |
3427 | 3449 | | |
3428 | 3450 | | |
3429 | | - | |
| 3451 | + | |
| 3452 | + | |
| 3453 | + | |
| 3454 | + | |
| 3455 | + | |
| 3456 | + | |
| 3457 | + | |
| 3458 | + | |
| 3459 | + | |
| 3460 | + | |
| 3461 | + | |
| 3462 | + | |
| 3463 | + | |
| 3464 | + | |
| 3465 | + | |
| 3466 | + | |
| 3467 | + | |
| 3468 | + | |
| 3469 | + | |
| 3470 | + | |
| 3471 | + | |
| 3472 | + | |
| 3473 | + | |
| 3474 | + | |
| 3475 | + | |
| 3476 | + | |
| 3477 | + | |
| 3478 | + | |
| 3479 | + | |
3430 | 3480 | | |
3431 | 3481 | | |
3432 | 3482 | | |
| |||
3636 | 3686 | | |
3637 | 3687 | | |
3638 | 3688 | | |
| 3689 | + | |
3639 | 3690 | | |
3640 | 3691 | | |
3641 | 3692 | | |
| |||
3711 | 3762 | | |
3712 | 3763 | | |
3713 | 3764 | | |
3714 | | - | |
3715 | | - | |
| 3765 | + | |
| 3766 | + | |
| 3767 | + | |
| 3768 | + | |
| 3769 | + | |
| 3770 | + | |
| 3771 | + | |
| 3772 | + | |
| 3773 | + | |
| 3774 | + | |
| 3775 | + | |
| 3776 | + | |
3716 | 3777 | | |
| 3778 | + | |
3717 | 3779 | | |
3718 | 3780 | | |
3719 | 3781 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
459 | 459 | | |
460 | 460 | | |
461 | 461 | | |
462 | | - | |
463 | | - | |
| 462 | + | |
| 463 | + | |
464 | 464 | | |
465 | 465 | | |
466 | 466 | | |
467 | 467 | | |
| 468 | + | |
468 | 469 | | |
469 | 470 | | |
470 | 471 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
575 | 575 | | |
576 | 576 | | |
577 | 577 | | |
578 | | - | |
| 578 | + | |
579 | 579 | | |
580 | 580 | | |
581 | 581 | | |
| |||
585 | 585 | | |
586 | 586 | | |
587 | 587 | | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
588 | 606 | | |
589 | 607 | | |
590 | 608 | | |
| |||
695 | 713 | | |
696 | 714 | | |
697 | 715 | | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
698 | 734 | | |
699 | 735 | | |
700 | 736 | | |
| |||
723 | 759 | | |
724 | 760 | | |
725 | 761 | | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
726 | 768 | | |
727 | 769 | | |
728 | 770 | | |
| |||
751 | 793 | | |
752 | 794 | | |
753 | 795 | | |
754 | | - | |
755 | | - | |
756 | | - | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
757 | 805 | | |
758 | 806 | | |
759 | 807 | | |
| |||
0 commit comments