Repository navigation
Commit 40aa4a4
committed
[JSC] Fix operand semantics of some ARM64 and x86_64 integer operations
https://bugs.webkit.org/show_bug.cgi?id=329725
rdar://191514638
Reviewed by Vassili Bykov.
64-bit operations must sign-extend a TrustedImm32 operand. On ARM64, branch64,
moveConditionally64, moveDoubleConditionally64, branchAdd64 and branchSub64
zero-extended an immediate they had to materialize, and branchTest64 treated
INT32_MIN as a single-bit mask. Blinded addPtr / subPtr could also be off by 2^32.
This patch fixes them.
Also drive-by fixes for operations that clobbered or mis-sized an operand.
- ARM64: branchTest64, or32 and branch64 memory forms overwrote the loaded value.
add64(reg, Address) swapped its operands. loadPairFloat / storePairFloat fallbacks
used offset + 8. an absolute load into memoryTempRegister left a stale cached address.
- x86_64: test32 / branchTest32 narrowed masks with bit 7 set to testb, breaking Signed
and PositiveOrZero. They now take the condition and keep the byte-wide form for
Zero / NonZero, so the common flag-byte tests do not grow. ARM64 gains a test32
overload taking the condition, so the CSS selector JIT passes it on both architectures.
branchAdd64(Address, reg, dest) loaded 32 bits. Add the missing branchAdd64(reg, imm, reg).
- Air declared ClearBitField's destination write-only, though BFC reads it.
Nothing lowers to ClearBitField yet, so only testair reaches it.
- IPInt checked an argument opcode byte with a signed compare on x86_64. The byte
is generated internally and always in range, so this is hardening.
- offlineasm's x86 bblteq emitted jlteq. No .asm file uses bblteq today.
- A B3 BitAnd(SExt32, mask) rule never fired and built a malformed ZExt32.
Tests: Source/JavaScriptCore/assembler/testmasm.cpp
Source/JavaScriptCore/b3/air/testair.cpp
Source/JavaScriptCore/b3/testb3_4.cpp
Source/JavaScriptCore/b3/testb3_6.cpp
* Source/JavaScriptCore/assembler/MacroAssembler.h:
(JSC::MacroAssembler::additionBlindedConstant):
* Source/JavaScriptCore/assembler/MacroAssemblerARM64.h:
(JSC::MacroAssemblerARM64::add64):
(JSC::MacroAssemblerARM64::or32):
(JSC::MacroAssemblerARM64::loadPair32):
(JSC::MacroAssemblerARM64::storePair32):
(JSC::MacroAssemblerARM64::moveConditionally64):
(JSC::MacroAssemblerARM64::moveDoubleConditionally64):
(JSC::MacroAssemblerARM64::branch64):
(JSC::MacroAssemblerARM64::test32):
(JSC::MacroAssemblerARM64::branchTest64):
(JSC::MacroAssemblerARM64::branchAdd64):
(JSC::MacroAssemblerARM64::branchSub64):
(JSC::MacroAssemblerARM64::load):
* Source/JavaScriptCore/assembler/MacroAssemblerX86_64.h:
(JSC::MacroAssemblerX86_64::moveConditionallyTest32):
(JSC::MacroAssemblerX86_64::test32):
(JSC::MacroAssemblerX86_64::branchTest32):
(JSC::MacroAssemblerX86_64::branchAdd64):
(JSC::MacroAssemblerX86_64::byteMaskForTest32):
(JSC::MacroAssemblerX86_64::generateTest32):
* Source/JavaScriptCore/assembler/testmasm.cpp:
(JSC::compare64ForTest):
(JSC::testCompare64WithImm32):
(JSC::testBranchAddSub64WithImm32):
(JSC::testBranchTest64WithImm32Mask):
(JSC::testBranchTest32WithNarrowMask):
(JSC::testAddSubPtrWithImm32):
(JSC::testBranch64AbsoluteAddressWithStackPointer):
(JSC::testBranchAdd64AddressBaseIsDest):
(JSC::testOr32ImmToAddress):
(JSC::testAdd64RegisterToAddress):
(JSC::testLoadStorePairFloat):
(JSC::testLoadFromAbsoluteAddressIntoMemoryTempRegister):
* Source/JavaScriptCore/b3/B3ReduceStrength.cpp:
* Source/JavaScriptCore/b3/air/AirOpcode.opcodes:
* Source/JavaScriptCore/b3/air/testair.cpp:
* Source/JavaScriptCore/b3/testb3.h:
* Source/JavaScriptCore/b3/testb3_4.cpp:
(JSC::addSExtTests):
* Source/JavaScriptCore/b3/testb3_6.cpp:
(testBitAndSExt32WithOtherUse):
* Source/JavaScriptCore/llint/InPlaceInterpreter64.asm:
* Source/JavaScriptCore/offlineasm/x86.rb:
* Source/WebCore/cssjit/FunctionCall.h:
(WebCore::FunctionCall::callAndBranchOnCondition):
* Source/WebCore/cssjit/SelectorCompiler.cpp:
(WebCore::SelectorCompiler::SelectorCodeGenerator::modulo):
Canonical link: https://commits.webkit.org/325567@main1 parent 083f770 commit 40aa4a4
14 files changed
Lines changed: 469 additions & 36 deletions
File tree
- Source
- JavaScriptCore
- assembler
- b3
- air
- llint
- offlineasm
- WebCore/cssjit
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2009 | 2009 | | |
2010 | 2010 | | |
2011 | 2011 | | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + | |
| 2015 | + | |
2012 | 2016 | | |
2013 | 2017 | | |
2014 | 2018 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4508 | 4508 | | |
4509 | 4509 | | |
4510 | 4510 | | |
4511 | | - | |
| 4511 | + | |
4512 | 4512 | | |
4513 | 4513 | | |
4514 | 4514 | | |
| |||
4639 | 4639 | | |
4640 | 4640 | | |
4641 | 4641 | | |
4642 | | - | |
| 4642 | + | |
4643 | 4643 | | |
4644 | 4644 | | |
4645 | 4645 | | |
| |||
4783 | 4783 | | |
4784 | 4784 | | |
4785 | 4785 | | |
4786 | | - | |
| 4786 | + | |
4787 | 4787 | | |
4788 | 4788 | | |
4789 | 4789 | | |
| |||
4827 | 4827 | | |
4828 | 4828 | | |
4829 | 4829 | | |
4830 | | - | |
4831 | | - | |
| 4830 | + | |
| 4831 | + | |
4832 | 4832 | | |
4833 | 4833 | | |
4834 | 4834 | | |
| |||
4933 | 4933 | | |
4934 | 4934 | | |
4935 | 4935 | | |
| 4936 | + | |
| 4937 | + | |
| 4938 | + | |
| 4939 | + | |
| 4940 | + | |
4936 | 4941 | | |
4937 | 4942 | | |
4938 | 4943 | | |
| |||
4993 | 4998 | | |
4994 | 4999 | | |
4995 | 5000 | | |
4996 | | - | |
| 5001 | + | |
4997 | 5002 | | |
4998 | 5003 | | |
4999 | 5004 | | |
| |||
5239 | 5244 | | |
5240 | 5245 | | |
5241 | 5246 | | |
5242 | | - | |
| 5247 | + | |
5243 | 5248 | | |
5244 | 5249 | | |
5245 | 5250 | | |
| |||
5385 | 5390 | | |
5386 | 5391 | | |
5387 | 5392 | | |
5388 | | - | |
| 5393 | + | |
5389 | 5394 | | |
5390 | 5395 | | |
5391 | 5396 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3024 | 3024 | | |
3025 | 3025 | | |
3026 | 3026 | | |
3027 | | - | |
| 3027 | + | |
3028 | 3028 | | |
3029 | 3029 | | |
3030 | 3030 | | |
| |||
3033 | 3033 | | |
3034 | 3034 | | |
3035 | 3035 | | |
3036 | | - | |
| 3036 | + | |
3037 | 3037 | | |
3038 | 3038 | | |
3039 | 3039 | | |
| |||
3051 | 3051 | | |
3052 | 3052 | | |
3053 | 3053 | | |
3054 | | - | |
| 3054 | + | |
3055 | 3055 | | |
3056 | 3056 | | |
3057 | 3057 | | |
| |||
3281 | 3281 | | |
3282 | 3282 | | |
3283 | 3283 | | |
3284 | | - | |
| 3284 | + | |
3285 | 3285 | | |
3286 | | - | |
| 3286 | + | |
| 3287 | + | |
3287 | 3288 | | |
3288 | | - | |
| 3289 | + | |
| 3290 | + | |
| 3291 | + | |
| 3292 | + | |
3289 | 3293 | | |
3290 | 3294 | | |
3291 | 3295 | | |
3292 | 3296 | | |
3293 | | - | |
3294 | | - | |
| 3297 | + | |
| 3298 | + | |
| 3299 | + | |
3295 | 3300 | | |
3296 | 3301 | | |
3297 | 3302 | | |
| |||
3301 | 3306 | | |
3302 | 3307 | | |
3303 | 3308 | | |
3304 | | - | |
| 3309 | + | |
3305 | 3310 | | |
3306 | 3311 | | |
3307 | 3312 | | |
3308 | 3313 | | |
3309 | 3314 | | |
3310 | | - | |
| 3315 | + | |
3311 | 3316 | | |
3312 | 3317 | | |
3313 | 3318 | | |
| |||
3653 | 3658 | | |
3654 | 3659 | | |
3655 | 3660 | | |
3656 | | - | |
| 3661 | + | |
3657 | 3662 | | |
3658 | 3663 | | |
3659 | 3664 | | |
| |||
3665 | 3670 | | |
3666 | 3671 | | |
3667 | 3672 | | |
3668 | | - | |
| 3673 | + | |
3669 | 3674 | | |
3670 | 3675 | | |
3671 | 3676 | | |
| |||
4790 | 4795 | | |
4791 | 4796 | | |
4792 | 4797 | | |
4793 | | - | |
| 4798 | + | |
| 4799 | + | |
| 4800 | + | |
| 4801 | + | |
| 4802 | + | |
| 4803 | + | |
| 4804 | + | |
4794 | 4805 | | |
| 4806 | + | |
4795 | 4807 | | |
4796 | 4808 | | |
4797 | | - | |
| 4809 | + | |
4798 | 4810 | | |
4799 | | - | |
| 4811 | + | |
4800 | 4812 | | |
4801 | | - | |
| 4813 | + | |
4802 | 4814 | | |
4803 | 4815 | | |
4804 | 4816 | | |
| |||
6902 | 6914 | | |
6903 | 6915 | | |
6904 | 6916 | | |
| 6917 | + | |
| 6918 | + | |
| 6919 | + | |
| 6920 | + | |
| 6921 | + | |
| 6922 | + | |
6905 | 6923 | | |
6906 | 6924 | | |
6907 | 6925 | | |
| |||
6915 | 6933 | | |
6916 | 6934 | | |
6917 | 6935 | | |
6918 | | - | |
| 6936 | + | |
6919 | 6937 | | |
6920 | 6938 | | |
6921 | 6939 | | |
| |||
0 commit comments