Skip to content

Commit 161e111

Browse files
gezalorewebkit-commit-queue
authored andcommitted
[JSC] Unify most Baseline ops between JSVALUE64 and JSVALUE32_64
https://bugs.webkit.org/show_bug.cgi?id=233424 Patch by Geza Lore <glore@igalia.com> on 2021-11-30 Reviewed by Yusuke Suzuki. This patch unifies the Baseline JIT implementations of most bytecode ops between the JSVALUE32_64 and JSVALUE64 platforms. There are very few changes to the generated code on JSVALUE64 (and all are fairly trivial, e.g.: removal of redundant moves in the slow path), apart from machine register substitutions. My measurements on x86_64 indicate the patch is performance neutral there (which is what we expect). On ARMv7/Thumb-2 JetStream2 shows a 0.4% improvement. This is due to some of the improved implementations picked up from the JSVALUE64 versions. Also remove various unused code. * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * bytecode/StructureStubInfo.cpp: (JSC::StructureStubInfo::initializeFromUnlinkedStructureStubInfo): * jit/AssemblyHelpers.h: (JSC::AssemblyHelpers::branchIfBoolean): (JSC::AssemblyHelpers::branchIfNotBoolean): (JSC::AssemblyHelpers::isUndefined): * jit/GPRInfo.h: * jit/JIT.cpp: * jit/JIT.h: * jit/JITArithmetic.cpp: (JSC::JIT::emit_op_unsigned): (JSC::JIT::emit_compareAndJumpImpl): (JSC::JIT::emit_compareUnsignedAndJumpImpl): (JSC::JIT::emit_compareUnsignedImpl): (JSC::JIT::emit_compareAndJumpSlowImpl): (JSC::JIT::emit_op_inc): (JSC::JIT::emit_op_dec): (JSC::JIT::emit_op_mod): (JSC::JIT::emitBitBinaryOpFastPath): (JSC::JIT::emit_op_bitnot): (JSC::JIT::emitRightShiftFastPath): (JSC::JIT::emitMathICFast): (JSC::JIT::emitMathICSlow): (JSC::JIT::emit_op_div): * jit/JITArithmetic32_64.cpp: Removed. * jit/JITInlineCacheGenerator.h: * jit/JITInlines.h: (JSC::JIT::emitGetVirtualRegisterPayload): (JSC::JIT::emitPutVirtualRegister): (JSC::JIT::emitJumpSlowCaseIfNotInt): (JSC::JIT::loadCodeBlockConstantPayload): * jit/JITOpcodes.cpp: (JSC::JIT::emit_op_overrides_has_instance): (JSC::JIT::emit_op_instanceof): (JSC::JIT::emitSlow_op_instanceof): (JSC::JIT::emit_op_is_empty): (JSC::JIT::emit_op_typeof_is_undefined): (JSC::JIT::emit_op_is_boolean): (JSC::JIT::emit_op_is_number): (JSC::JIT::emit_op_is_big_int): (JSC::JIT::emit_op_is_cell_with_type): (JSC::JIT::emit_op_is_object): (JSC::JIT::emit_op_to_primitive): (JSC::JIT::emit_op_to_property_key): (JSC::JIT::emit_op_not): (JSC::JIT::emit_op_jundefined_or_null): (JSC::JIT::emit_op_jnundefined_or_null): (JSC::JIT::emit_op_jeq_ptr): (JSC::JIT::emit_op_jneq_ptr): (JSC::JIT::emit_op_eq): (JSC::JIT::emit_op_neq): (JSC::JIT::compileOpStrictEq): (JSC::JIT::emit_op_to_number): (JSC::JIT::emit_op_to_numeric): (JSC::JIT::emit_op_to_string): (JSC::JIT::emit_op_to_object): (JSC::JIT::emit_op_catch): (JSC::JIT::emit_op_get_parent_scope): (JSC::JIT::emit_op_get_scope): (JSC::JIT::emit_op_to_this): (JSC::JIT::emit_op_check_tdz): (JSC::JIT::emit_op_new_regexp): (JSC::JIT::emit_op_get_rest_length): (JSC::JIT::emit_op_get_prototype_of): * jit/JITOpcodes32_64.cpp: (JSC::JIT::compileOpEqCommon): (JSC::JIT::compileOpEqSlowCommon): (JSC::JIT::emit_op_eq): (JSC::JIT::emit_op_neq): (JSC::JIT::emit_op_jeq): (JSC::JIT::emit_op_jneq): (JSC::JIT::emitSlow_op_eq): (JSC::JIT::emitSlow_op_neq): (JSC::JIT::emitSlow_op_jeq): (JSC::JIT::emitSlow_op_jneq): (JSC::JIT::compileOpStrictEqCommon): (JSC::JIT::emit_op_stricteq): (JSC::JIT::emit_op_nstricteq): (JSC::JIT::emit_op_jstricteq): (JSC::JIT::emit_op_jnstricteq): (JSC::JIT::emitSlow_op_jstricteq): (JSC::JIT::emitSlow_op_jnstricteq): * jit/JITPropertyAccess.cpp: (JSC::JIT::generateGetByValSlowCase): (JSC::JIT::emitSlow_op_get_private_name): (JSC::JIT::emitSlow_op_get_by_id_direct): (JSC::JIT::emitSlow_op_get_by_id): (JSC::JIT::emitSlow_op_get_by_id_with_this): (JSC::JIT::emit_op_enumerator_get_by_val): (JSC::JIT::emit_enumerator_has_propertyImpl): (JSC::JIT::emitWriteBarrier): * jit/JSInterfaceJIT.h: (JSC::JSInterfaceJIT::emitLoadJSCell): Canonical link: https://commits.webkit.org/244655@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@286296 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent db136fe commit 161e111

17 files changed

Lines changed: 652 additions & 1740 deletions

‎Source/JavaScriptCore/ChangeLog‎

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,120 @@
1+
2021-11-30 Geza Lore <glore@igalia.com>
2+
3+
[JSC] Unify most Baseline ops between JSVALUE64 and JSVALUE32_64
4+
https://bugs.webkit.org/show_bug.cgi?id=233424
5+
6+
Reviewed by Yusuke Suzuki.
7+
8+
This patch unifies the Baseline JIT implementations of most bytecode
9+
ops between the JSVALUE32_64 and JSVALUE64 platforms. There are very
10+
few changes to the generated code on JSVALUE64 (and all are fairly
11+
trivial, e.g.: removal of redundant moves in the slow path), apart
12+
from machine register substitutions. My measurements on x86_64
13+
indicate the patch is performance neutral there (which is what we
14+
expect).
15+
16+
On ARMv7/Thumb-2 JetStream2 shows a 0.4% improvement. This is due to
17+
some of the improved implementations picked up from the JSVALUE64
18+
versions.
19+
20+
Also remove various unused code.
21+
22+
* JavaScriptCore.xcodeproj/project.pbxproj:
23+
* Sources.txt:
24+
* bytecode/StructureStubInfo.cpp:
25+
(JSC::StructureStubInfo::initializeFromUnlinkedStructureStubInfo):
26+
* jit/AssemblyHelpers.h:
27+
(JSC::AssemblyHelpers::branchIfBoolean):
28+
(JSC::AssemblyHelpers::branchIfNotBoolean):
29+
(JSC::AssemblyHelpers::isUndefined):
30+
* jit/GPRInfo.h:
31+
* jit/JIT.cpp:
32+
* jit/JIT.h:
33+
* jit/JITArithmetic.cpp:
34+
(JSC::JIT::emit_op_unsigned):
35+
(JSC::JIT::emit_compareAndJumpImpl):
36+
(JSC::JIT::emit_compareUnsignedAndJumpImpl):
37+
(JSC::JIT::emit_compareUnsignedImpl):
38+
(JSC::JIT::emit_compareAndJumpSlowImpl):
39+
(JSC::JIT::emit_op_inc):
40+
(JSC::JIT::emit_op_dec):
41+
(JSC::JIT::emit_op_mod):
42+
(JSC::JIT::emitBitBinaryOpFastPath):
43+
(JSC::JIT::emit_op_bitnot):
44+
(JSC::JIT::emitRightShiftFastPath):
45+
(JSC::JIT::emitMathICFast):
46+
(JSC::JIT::emitMathICSlow):
47+
(JSC::JIT::emit_op_div):
48+
* jit/JITArithmetic32_64.cpp: Removed.
49+
* jit/JITInlineCacheGenerator.h:
50+
* jit/JITInlines.h:
51+
(JSC::JIT::emitGetVirtualRegisterPayload):
52+
(JSC::JIT::emitPutVirtualRegister):
53+
(JSC::JIT::emitJumpSlowCaseIfNotInt):
54+
(JSC::JIT::loadCodeBlockConstantPayload):
55+
* jit/JITOpcodes.cpp:
56+
(JSC::JIT::emit_op_overrides_has_instance):
57+
(JSC::JIT::emit_op_instanceof):
58+
(JSC::JIT::emitSlow_op_instanceof):
59+
(JSC::JIT::emit_op_is_empty):
60+
(JSC::JIT::emit_op_typeof_is_undefined):
61+
(JSC::JIT::emit_op_is_boolean):
62+
(JSC::JIT::emit_op_is_number):
63+
(JSC::JIT::emit_op_is_big_int):
64+
(JSC::JIT::emit_op_is_cell_with_type):
65+
(JSC::JIT::emit_op_is_object):
66+
(JSC::JIT::emit_op_to_primitive):
67+
(JSC::JIT::emit_op_to_property_key):
68+
(JSC::JIT::emit_op_not):
69+
(JSC::JIT::emit_op_jundefined_or_null):
70+
(JSC::JIT::emit_op_jnundefined_or_null):
71+
(JSC::JIT::emit_op_jeq_ptr):
72+
(JSC::JIT::emit_op_jneq_ptr):
73+
(JSC::JIT::emit_op_eq):
74+
(JSC::JIT::emit_op_neq):
75+
(JSC::JIT::compileOpStrictEq):
76+
(JSC::JIT::emit_op_to_number):
77+
(JSC::JIT::emit_op_to_numeric):
78+
(JSC::JIT::emit_op_to_string):
79+
(JSC::JIT::emit_op_to_object):
80+
(JSC::JIT::emit_op_catch):
81+
(JSC::JIT::emit_op_get_parent_scope):
82+
(JSC::JIT::emit_op_get_scope):
83+
(JSC::JIT::emit_op_to_this):
84+
(JSC::JIT::emit_op_check_tdz):
85+
(JSC::JIT::emit_op_new_regexp):
86+
(JSC::JIT::emit_op_get_rest_length):
87+
(JSC::JIT::emit_op_get_prototype_of):
88+
* jit/JITOpcodes32_64.cpp:
89+
(JSC::JIT::compileOpEqCommon):
90+
(JSC::JIT::compileOpEqSlowCommon):
91+
(JSC::JIT::emit_op_eq):
92+
(JSC::JIT::emit_op_neq):
93+
(JSC::JIT::emit_op_jeq):
94+
(JSC::JIT::emit_op_jneq):
95+
(JSC::JIT::emitSlow_op_eq):
96+
(JSC::JIT::emitSlow_op_neq):
97+
(JSC::JIT::emitSlow_op_jeq):
98+
(JSC::JIT::emitSlow_op_jneq):
99+
(JSC::JIT::compileOpStrictEqCommon):
100+
(JSC::JIT::emit_op_stricteq):
101+
(JSC::JIT::emit_op_nstricteq):
102+
(JSC::JIT::emit_op_jstricteq):
103+
(JSC::JIT::emit_op_jnstricteq):
104+
(JSC::JIT::emitSlow_op_jstricteq):
105+
(JSC::JIT::emitSlow_op_jnstricteq):
106+
* jit/JITPropertyAccess.cpp:
107+
(JSC::JIT::generateGetByValSlowCase):
108+
(JSC::JIT::emitSlow_op_get_private_name):
109+
(JSC::JIT::emitSlow_op_get_by_id_direct):
110+
(JSC::JIT::emitSlow_op_get_by_id):
111+
(JSC::JIT::emitSlow_op_get_by_id_with_this):
112+
(JSC::JIT::emit_op_enumerator_get_by_val):
113+
(JSC::JIT::emit_enumerator_has_propertyImpl):
114+
(JSC::JIT::emitWriteBarrier):
115+
* jit/JSInterfaceJIT.h:
116+
(JSC::JSInterfaceJIT::emitLoadJSCell):
117+
1118
2021-11-29 Yusuke Suzuki <ysuzuki@apple.com>
2119

3120
[JSC] jumpForTypedArrayOutOfBounds should use asAnyInt since it uses isAnyInt

‎Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4728,7 +4728,6 @@
47284728
A74DEF8E182D991400522C22 /* MapIteratorPrototype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MapIteratorPrototype.h; sourceTree = "<group>"; };
47294729
A74DEF8F182D991400522C22 /* JSMapIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMapIterator.cpp; sourceTree = "<group>"; };
47304730
A74DEF90182D991400522C22 /* JSMapIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMapIterator.h; sourceTree = "<group>"; };
4731-
A75706DD118A2BCF0057F88F /* JITArithmetic32_64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JITArithmetic32_64.cpp; sourceTree = "<group>"; };
47324731
A75EE9B018AAB7E200AAD043 /* BuiltinNames.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BuiltinNames.h; sourceTree = "<group>"; };
47334732
A767B5B317A0B9650063D940 /* DFGLoopPreHeaderCreationPhase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = DFGLoopPreHeaderCreationPhase.cpp; path = dfg/DFGLoopPreHeaderCreationPhase.cpp; sourceTree = "<group>"; };
47344733
A767B5B417A0B9650063D940 /* DFGLoopPreHeaderCreationPhase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGLoopPreHeaderCreationPhase.h; path = dfg/DFGLoopPreHeaderCreationPhase.h; sourceTree = "<group>"; };
@@ -6375,7 +6374,6 @@
63756374
FE1220261BE7F5640039E6F2 /* JITAddGenerator.h */,
63766375
0F75A0652013E4EF0038E2CF /* JITAllocator.h */,
63776376
86A90ECF0EE7D51F00AB350D /* JITArithmetic.cpp */,
6378-
A75706DD118A2BCF0057F88F /* JITArithmetic32_64.cpp */,
63796377
FE3A06AD1C10CB6F00390FDD /* JITBitAndGenerator.cpp */,
63806378
FE3A06AE1C10CB6F00390FDD /* JITBitAndGenerator.h */,
63816379
FE3A06A71C10BC7400390FDD /* JITBitBinaryOpGenerator.h */,

‎Source/JavaScriptCore/Sources.txt‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,6 @@ jit/IntrinsicEmitter.cpp
639639
jit/JIT.cpp
640640
jit/JITAddGenerator.cpp
641641
jit/JITArithmetic.cpp
642-
jit/JITArithmetic32_64.cpp
643642
jit/JITBitAndGenerator.cpp
644643
jit/JITBitOrGenerator.cpp
645644
jit/JITBitXorGenerator.cpp

‎Source/JavaScriptCore/assembler/MacroAssemblerX86_64.h‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,12 @@ class MacroAssemblerX86_64 : public MacroAssemblerX86Common {
897897
m_assembler.xorq_ir(imm.m_value, srcDest);
898898
}
899899

900+
void xor64(TrustedImm32 imm, RegisterID src, RegisterID dest)
901+
{
902+
move(src, dest);
903+
xor64(imm, dest);
904+
}
905+
900906
void xor64(TrustedImm64 imm, RegisterID srcDest)
901907
{
902908
move(imm, scratchRegister());

‎Source/JavaScriptCore/bytecode/StructureStubInfo.cpp‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -564,19 +564,14 @@ void StructureStubInfo::initializeFromUnlinkedStructureStubInfo(CodeBlock*, Unli
564564
case AccessType::InstanceOf:
565565
hasConstantIdentifier = false;
566566
prototypeIsKnownObject = false;
567-
#if USE(JSVALUE64)
568-
baseGPR = BaselineInstanceofRegisters::value;
569-
valueGPR = BaselineInstanceofRegisters::result;
570-
regs.prototypeGPR = BaselineInstanceofRegisters::proto;
571-
m_stubInfoGPR = BaselineInstanceofRegisters::stubInfo;
572-
#elif USE(JSVALUE32_64)
573567
baseGPR = BaselineInstanceofRegisters::valueJSR.payloadGPR();
574-
valueGPR = BaselineInstanceofRegisters::resultGPR;
568+
valueGPR = BaselineInstanceofRegisters::resultJSR.payloadGPR();
575569
regs.prototypeGPR = BaselineInstanceofRegisters::protoJSR.payloadGPR();
576570
m_stubInfoGPR = BaselineInstanceofRegisters::stubInfoGPR;
577-
baseTagGPR = InvalidGPRReg;
571+
#if USE(JSVALUE32_64)
572+
baseTagGPR = BaselineInstanceofRegisters::valueJSR.tagGPR();
578573
valueTagGPR = InvalidGPRReg;
579-
v.propertyTagGPR = InvalidGPRReg;
574+
v.propertyTagGPR = BaselineInstanceofRegisters::protoJSR.tagGPR();
580575
#endif
581576
break;
582577
case AccessType::InByVal:

‎Source/JavaScriptCore/jit/AssemblyHelpers.h‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -821,8 +821,7 @@ class AssemblyHelpers : public MacroAssembler {
821821
{
822822
#if USE(JSVALUE64)
823823
ASSERT(tempGPR != InvalidGPRReg);
824-
move(gpr, tempGPR);
825-
xor64(TrustedImm32(JSValue::ValueFalse), tempGPR);
824+
xor64(TrustedImm32(JSValue::ValueFalse), gpr, tempGPR);
826825
return branchTest64(Zero, tempGPR, TrustedImm32(static_cast<int32_t>(~1)));
827826
#else
828827
UNUSED_PARAM(tempGPR);
@@ -845,8 +844,7 @@ class AssemblyHelpers : public MacroAssembler {
845844
{
846845
#if USE(JSVALUE64)
847846
ASSERT(tempGPR != InvalidGPRReg);
848-
move(gpr, tempGPR);
849-
xor64(TrustedImm32(JSValue::ValueFalse), tempGPR);
847+
xor64(TrustedImm32(JSValue::ValueFalse), gpr, tempGPR);
850848
return branchTest64(NonZero, tempGPR, TrustedImm32(static_cast<int32_t>(~1)));
851849
#else
852850
UNUSED_PARAM(tempGPR);
@@ -1033,6 +1031,15 @@ class AssemblyHelpers : public MacroAssembler {
10331031
#endif
10341032
}
10351033

1034+
void isUndefined(JSValueRegs regs, GPRReg dst)
1035+
{
1036+
#if USE(JSVALUE64)
1037+
compare64(Equal, regs.payloadGPR(), TrustedImm32(JSValue::ValueUndefined), dst);
1038+
#elif USE(JSVALUE32_64)
1039+
compare32(Equal, regs.tagGPR(), TrustedImm32(JSValue::UndefinedTag), dst);
1040+
#endif
1041+
}
1042+
10361043
// Note that this function does not respect MasqueradesAsUndefined.
10371044
Jump branchIfUndefined(GPRReg gpr)
10381045
{

‎Source/JavaScriptCore/jit/GPRInfo.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,9 +939,11 @@ class JSRInfo {
939939
#if USE(JSVALUE64)
940940
static constexpr JSValueRegs jsRegT10 { GPRInfo::regT0 };
941941
static constexpr JSValueRegs jsRegT32 { GPRInfo::regT2 };
942+
static constexpr JSValueRegs jsRegT54 { GPRInfo::regT4 };
942943
#elif USE(JSVALUE32_64)
943944
static constexpr JSValueRegs jsRegT10 { GPRInfo::regT1, GPRInfo::regT0 };
944945
static constexpr JSValueRegs jsRegT32 { GPRInfo::regT3, GPRInfo::regT2 };
946+
static constexpr JSValueRegs jsRegT54 { GPRInfo::regT5, GPRInfo::regT4 };
945947
#endif
946948

947949
// Return value register

‎Source/JavaScriptCore/jit/JIT.cpp‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,6 @@ void JIT::emitEnterOptimizationCheck()
126126
}
127127
#endif
128128

129-
void JIT::emitNotifyWrite(WatchpointSet* set)
130-
{
131-
if (!set || set->state() == IsInvalidated) {
132-
addSlowCase(Jump());
133-
return;
134-
}
135-
136-
addSlowCase(branch8(NotEqual, AbsoluteAddress(set->addressOfState()), TrustedImm32(IsInvalidated)));
137-
}
138-
139129
void JIT::emitNotifyWriteWatchpoint(GPRReg pointerToSet)
140130
{
141131
auto ok = branchTestPtr(Zero, pointerToSet);

0 commit comments

Comments
 (0)