Skip to content

Commit 404a00a

Browse files
committed
B3 should support tuple types
https://bugs.webkit.org/show_bug.cgi?id=200327 Reviewed by Filip Pizlo. As part of the Wasm multi-value proposal, we need to teach B3 that patchpoints can return more than one value. This is done by adding a new B3::Type called Tuple. Unlike, other B3 types Tuple is actually an encoded index into a numeric B3::Type vector on the procedure. This lets us distinguish any two tuples from each other, moreover, it's possible to get the vector of types with just the B3::Tuple type and the procedure. Since most B3 operations only expect to see a single numeric child there is a new Opcode, Extract, that takes yields the some, fixed, entry from a tuple value. Extract would be the only other change needed to make tuples work in B3 except that some optimizations expect to be able to take any non-Void value and stick it into a Variable of the same type. This means both Get/Set from a variable have to support Tuples as well. For simplicity and consistency, the ability to accept tuples is also applied to Phi and Upsilon. In order to lower a Tuple, B3Lowering needs to have a Tmp for each nested type in a Tuple. While we could reuse the existing IndexedTables to hold the extra information we need to lower Tuples, we instead use a two new HashTables for Value->Tmp(s) and Phi->Tmp(s). It's expected that Tuples will be sufficiently uncommon the overhead of tracking everything together would be prohibitive. On the other hand, we don't worry about this for Variables because we don't expect those to make it to lowering. * JavaScriptCore.xcodeproj/project.pbxproj: * Sources.txt: * b3/B3Bank.h: (JSC::B3::bankForType): * b3/B3CheckValue.cpp: (JSC::B3::CheckValue::CheckValue): * b3/B3ExtractValue.cpp: Copied from Source/JavaScriptCore/b3/B3ProcedureInlines.h. (JSC::B3::ExtractValue::~ExtractValue): (JSC::B3::ExtractValue::dumpMeta const): * b3/B3ExtractValue.h: Copied from Source/JavaScriptCore/b3/B3FixSSA.h. * b3/B3FixSSA.h: * b3/B3LowerMacros.cpp: * b3/B3LowerMacrosAfterOptimizations.cpp: * b3/B3LowerToAir.cpp: * b3/B3NativeTraits.h: * b3/B3Opcode.cpp: (JSC::B3::invertedCompare): (WTF::printInternal): * b3/B3Opcode.h: (JSC::B3::opcodeForConstant): * b3/B3PatchpointSpecial.cpp: (JSC::B3::PatchpointSpecial::forEachArg): (JSC::B3::PatchpointSpecial::isValid): (JSC::B3::PatchpointSpecial::admitsStack): (JSC::B3::PatchpointSpecial::generate): * b3/B3PatchpointValue.cpp: (JSC::B3::PatchpointValue::dumpMeta const): (JSC::B3::PatchpointValue::PatchpointValue): * b3/B3PatchpointValue.h: * b3/B3Procedure.cpp: (JSC::B3::Procedure::addTuple): (JSC::B3::Procedure::isValidTuple const): (JSC::B3::Procedure::tupleForType const): (JSC::B3::Procedure::addIntConstant): (JSC::B3::Procedure::addConstant): * b3/B3Procedure.h: (JSC::B3::Procedure::returnCount const): * b3/B3ProcedureInlines.h: (JSC::B3::Procedure::extractFromTuple const): * b3/B3ReduceStrength.cpp: * b3/B3StackmapSpecial.cpp: (JSC::B3::StackmapSpecial::isValidImpl): (JSC::B3::StackmapSpecial::isArgValidForType): (JSC::B3::StackmapSpecial::isArgValidForRep): (JSC::B3::StackmapSpecial::isArgValidForValue): Deleted. * b3/B3StackmapSpecial.h: * b3/B3StackmapValue.h: * b3/B3Type.cpp: (WTF::printInternal): * b3/B3Type.h: (JSC::B3::Type::Type): (JSC::B3::Type::tupleFromIndex): (JSC::B3::Type::kind const): (JSC::B3::Type::tupleIndex const): (JSC::B3::Type::hash const): (JSC::B3::Type::operator== const): (JSC::B3::Type::operator!= const): (JSC::B3::Type::isInt const): (JSC::B3::Type::isFloat const): (JSC::B3::Type::isNumeric const): (JSC::B3::Type::isTuple const): (JSC::B3::sizeofType): (JSC::B3::isInt): Deleted. (JSC::B3::isFloat): Deleted. * b3/B3TypeMap.h: (JSC::B3::TypeMap::at): * b3/B3Validate.cpp: * b3/B3Value.cpp: (JSC::B3::Value::isRounded const): (JSC::B3::Value::effects const): (JSC::B3::Value::typeFor): * b3/B3Value.h: * b3/B3ValueInlines.h: * b3/B3ValueKey.cpp: (JSC::B3::ValueKey::intConstant): * b3/B3ValueKey.h: (JSC::B3::ValueKey::hash const): * b3/B3ValueRep.h: * b3/B3Width.h: (JSC::B3::widthForType): * b3/air/AirArg.cpp: (JSC::B3::Air::Arg::canRepresent const): * b3/air/AirArg.h: * b3/air/AirCCallingConvention.cpp: (JSC::B3::Air::cCallResult): * b3/air/AirLowerMacros.cpp: (JSC::B3::Air::lowerMacros): * b3/testb3.h: (populateWithInterestingValues): * b3/testb3_1.cpp: (run): * b3/testb3_3.cpp: (testStorePartial8BitRegisterOnX86): * b3/testb3_5.cpp: (testPatchpointWithRegisterResult): (testPatchpointWithStackArgumentResult): (testPatchpointWithAnyResult): * b3/testb3_6.cpp: (testPatchpointDoubleRegs): (testSomeEarlyRegister): * b3/testb3_7.cpp: (testShuffleDoesntTrashCalleeSaves): (testReportUsedRegistersLateUseFollowedByEarlyDefDoesNotMarkUseAsDead): (testSimpleTuplePair): (testSimpleTuplePairUnused): (testSimpleTuplePairStack): (tailDupedTuplePair): (tuplePairVariableLoop): (tupleNestedLoop): (addTupleTests): * b3/testb3_8.cpp: (testLoad): (addLoadTests): * ftl/FTLAbbreviatedTypes.h: * ftl/FTLLowerDFGToB3.cpp: (JSC::FTL::DFG::LowerDFGToB3::compileCallOrConstruct): (JSC::FTL::DFG::LowerDFGToB3::compileDirectCallOrConstruct): (JSC::FTL::DFG::LowerDFGToB3::compileCallOrConstructVarargsSpread): (JSC::FTL::DFG::LowerDFGToB3::compileCallOrConstructVarargs): (JSC::FTL::DFG::LowerDFGToB3::compileCallEval): (JSC::FTL::DFG::LowerDFGToB3::compileCPUIntrinsic): (JSC::FTL::DFG::LowerDFGToB3::compileInstanceOf): (JSC::FTL::DFG::LowerDFGToB3::compileCallDOMGetter): (JSC::FTL::DFG::LowerDFGToB3::emitBinarySnippet): (JSC::FTL::DFG::LowerDFGToB3::emitBinaryBitOpSnippet): (JSC::FTL::DFG::LowerDFGToB3::emitRightShiftSnippet): (JSC::FTL::DFG::LowerDFGToB3::allocateHeapCell): * wasm/WasmAirIRGenerator.cpp: (JSC::Wasm::AirIRGenerator::emitPatchpoint): * wasm/WasmB3IRGenerator.cpp: (JSC::Wasm::B3IRGenerator::B3IRGenerator): * wasm/WasmCallingConvention.h: (JSC::Wasm::CallingConvention::marshallArgument const): (JSC::Wasm::CallingConvention::setupFrameInPrologue const): (JSC::Wasm::CallingConvention::setupCall const): (JSC::Wasm::CallingConventionAir::setupCall const): Canonical link: https://commits.webkit.org/214174@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248178 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent 4e21518 commit 404a00a

51 files changed

Lines changed: 1056 additions & 215 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Source/JavaScriptCore/ChangeLog‎

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,173 @@
1+
2019-08-01 Keith Miller <keith_miller@apple.com>
2+
3+
B3 should support tuple types
4+
https://bugs.webkit.org/show_bug.cgi?id=200327
5+
6+
Reviewed by Filip Pizlo.
7+
8+
As part of the Wasm multi-value proposal, we need to teach B3 that
9+
patchpoints can return more than one value. This is done by
10+
adding a new B3::Type called Tuple. Unlike, other B3 types Tuple
11+
is actually an encoded index into a numeric B3::Type vector on the
12+
procedure. This lets us distinguish any two tuples from each
13+
other, moreover, it's possible to get the vector of types with
14+
just the B3::Tuple type and the procedure.
15+
16+
Since most B3 operations only expect to see a single numeric child
17+
there is a new Opcode, Extract, that takes yields the some, fixed,
18+
entry from a tuple value. Extract would be the only other change
19+
needed to make tuples work in B3 except that some optimizations
20+
expect to be able to take any non-Void value and stick it into a
21+
Variable of the same type. This means both Get/Set from a variable
22+
have to support Tuples as well. For simplicity and consistency,
23+
the ability to accept tuples is also applied to Phi and Upsilon.
24+
25+
In order to lower a Tuple, B3Lowering needs to have a Tmp for each
26+
nested type in a Tuple. While we could reuse the existing
27+
IndexedTables to hold the extra information we need to lower
28+
Tuples, we instead use a two new HashTables for Value->Tmp(s) and
29+
Phi->Tmp(s). It's expected that Tuples will be sufficiently
30+
uncommon the overhead of tracking everything together would be
31+
prohibitive. On the other hand, we don't worry about this for
32+
Variables because we don't expect those to make it to lowering.
33+
34+
* JavaScriptCore.xcodeproj/project.pbxproj:
35+
* Sources.txt:
36+
* b3/B3Bank.h:
37+
(JSC::B3::bankForType):
38+
* b3/B3CheckValue.cpp:
39+
(JSC::B3::CheckValue::CheckValue):
40+
* b3/B3ExtractValue.cpp: Copied from Source/JavaScriptCore/b3/B3ProcedureInlines.h.
41+
(JSC::B3::ExtractValue::~ExtractValue):
42+
(JSC::B3::ExtractValue::dumpMeta const):
43+
* b3/B3ExtractValue.h: Copied from Source/JavaScriptCore/b3/B3FixSSA.h.
44+
* b3/B3FixSSA.h:
45+
* b3/B3LowerMacros.cpp:
46+
* b3/B3LowerMacrosAfterOptimizations.cpp:
47+
* b3/B3LowerToAir.cpp:
48+
* b3/B3NativeTraits.h:
49+
* b3/B3Opcode.cpp:
50+
(JSC::B3::invertedCompare):
51+
(WTF::printInternal):
52+
* b3/B3Opcode.h:
53+
(JSC::B3::opcodeForConstant):
54+
* b3/B3PatchpointSpecial.cpp:
55+
(JSC::B3::PatchpointSpecial::forEachArg):
56+
(JSC::B3::PatchpointSpecial::isValid):
57+
(JSC::B3::PatchpointSpecial::admitsStack):
58+
(JSC::B3::PatchpointSpecial::generate):
59+
* b3/B3PatchpointValue.cpp:
60+
(JSC::B3::PatchpointValue::dumpMeta const):
61+
(JSC::B3::PatchpointValue::PatchpointValue):
62+
* b3/B3PatchpointValue.h:
63+
* b3/B3Procedure.cpp:
64+
(JSC::B3::Procedure::addTuple):
65+
(JSC::B3::Procedure::isValidTuple const):
66+
(JSC::B3::Procedure::tupleForType const):
67+
(JSC::B3::Procedure::addIntConstant):
68+
(JSC::B3::Procedure::addConstant):
69+
* b3/B3Procedure.h:
70+
(JSC::B3::Procedure::returnCount const):
71+
* b3/B3ProcedureInlines.h:
72+
(JSC::B3::Procedure::extractFromTuple const):
73+
* b3/B3ReduceStrength.cpp:
74+
* b3/B3StackmapSpecial.cpp:
75+
(JSC::B3::StackmapSpecial::isValidImpl):
76+
(JSC::B3::StackmapSpecial::isArgValidForType):
77+
(JSC::B3::StackmapSpecial::isArgValidForRep):
78+
(JSC::B3::StackmapSpecial::isArgValidForValue): Deleted.
79+
* b3/B3StackmapSpecial.h:
80+
* b3/B3StackmapValue.h:
81+
* b3/B3Type.cpp:
82+
(WTF::printInternal):
83+
* b3/B3Type.h:
84+
(JSC::B3::Type::Type):
85+
(JSC::B3::Type::tupleFromIndex):
86+
(JSC::B3::Type::kind const):
87+
(JSC::B3::Type::tupleIndex const):
88+
(JSC::B3::Type::hash const):
89+
(JSC::B3::Type::operator== const):
90+
(JSC::B3::Type::operator!= const):
91+
(JSC::B3::Type::isInt const):
92+
(JSC::B3::Type::isFloat const):
93+
(JSC::B3::Type::isNumeric const):
94+
(JSC::B3::Type::isTuple const):
95+
(JSC::B3::sizeofType):
96+
(JSC::B3::isInt): Deleted.
97+
(JSC::B3::isFloat): Deleted.
98+
* b3/B3TypeMap.h:
99+
(JSC::B3::TypeMap::at):
100+
* b3/B3Validate.cpp:
101+
* b3/B3Value.cpp:
102+
(JSC::B3::Value::isRounded const):
103+
(JSC::B3::Value::effects const):
104+
(JSC::B3::Value::typeFor):
105+
* b3/B3Value.h:
106+
* b3/B3ValueInlines.h:
107+
* b3/B3ValueKey.cpp:
108+
(JSC::B3::ValueKey::intConstant):
109+
* b3/B3ValueKey.h:
110+
(JSC::B3::ValueKey::hash const):
111+
* b3/B3ValueRep.h:
112+
* b3/B3Width.h:
113+
(JSC::B3::widthForType):
114+
* b3/air/AirArg.cpp:
115+
(JSC::B3::Air::Arg::canRepresent const):
116+
* b3/air/AirArg.h:
117+
* b3/air/AirCCallingConvention.cpp:
118+
(JSC::B3::Air::cCallResult):
119+
* b3/air/AirLowerMacros.cpp:
120+
(JSC::B3::Air::lowerMacros):
121+
* b3/testb3.h:
122+
(populateWithInterestingValues):
123+
* b3/testb3_1.cpp:
124+
(run):
125+
* b3/testb3_3.cpp:
126+
(testStorePartial8BitRegisterOnX86):
127+
* b3/testb3_5.cpp:
128+
(testPatchpointWithRegisterResult):
129+
(testPatchpointWithStackArgumentResult):
130+
(testPatchpointWithAnyResult):
131+
* b3/testb3_6.cpp:
132+
(testPatchpointDoubleRegs):
133+
(testSomeEarlyRegister):
134+
* b3/testb3_7.cpp:
135+
(testShuffleDoesntTrashCalleeSaves):
136+
(testReportUsedRegistersLateUseFollowedByEarlyDefDoesNotMarkUseAsDead):
137+
(testSimpleTuplePair):
138+
(testSimpleTuplePairUnused):
139+
(testSimpleTuplePairStack):
140+
(tailDupedTuplePair):
141+
(tuplePairVariableLoop):
142+
(tupleNestedLoop):
143+
(addTupleTests):
144+
* b3/testb3_8.cpp:
145+
(testLoad):
146+
(addLoadTests):
147+
* ftl/FTLAbbreviatedTypes.h:
148+
* ftl/FTLLowerDFGToB3.cpp:
149+
(JSC::FTL::DFG::LowerDFGToB3::compileCallOrConstruct):
150+
(JSC::FTL::DFG::LowerDFGToB3::compileDirectCallOrConstruct):
151+
(JSC::FTL::DFG::LowerDFGToB3::compileCallOrConstructVarargsSpread):
152+
(JSC::FTL::DFG::LowerDFGToB3::compileCallOrConstructVarargs):
153+
(JSC::FTL::DFG::LowerDFGToB3::compileCallEval):
154+
(JSC::FTL::DFG::LowerDFGToB3::compileCPUIntrinsic):
155+
(JSC::FTL::DFG::LowerDFGToB3::compileInstanceOf):
156+
(JSC::FTL::DFG::LowerDFGToB3::compileCallDOMGetter):
157+
(JSC::FTL::DFG::LowerDFGToB3::emitBinarySnippet):
158+
(JSC::FTL::DFG::LowerDFGToB3::emitBinaryBitOpSnippet):
159+
(JSC::FTL::DFG::LowerDFGToB3::emitRightShiftSnippet):
160+
(JSC::FTL::DFG::LowerDFGToB3::allocateHeapCell):
161+
* wasm/WasmAirIRGenerator.cpp:
162+
(JSC::Wasm::AirIRGenerator::emitPatchpoint):
163+
* wasm/WasmB3IRGenerator.cpp:
164+
(JSC::Wasm::B3IRGenerator::B3IRGenerator):
165+
* wasm/WasmCallingConvention.h:
166+
(JSC::Wasm::CallingConvention::marshallArgument const):
167+
(JSC::Wasm::CallingConvention::setupFrameInPrologue const):
168+
(JSC::Wasm::CallingConvention::setupCall const):
169+
(JSC::Wasm::CallingConventionAir::setupCall const):
170+
1171
2019-08-02 Yusuke Suzuki <ysuzuki@apple.com>
2172

3173
[JSC] Use "destroy" function directly for JSWebAssemblyCodeBlock and WebAssemblyFunction

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,7 @@
916916
530FDE7521FAB00600059D65 /* testIncludes.m in Sources */ = {isa = PBXBuildFile; fileRef = 530FDE7321FAAFC600059D65 /* testIncludes.m */; };
917917
5311BD4B1EA581E500525281 /* WasmOMGPlan.h in Headers */ = {isa = PBXBuildFile; fileRef = 5311BD491EA581E500525281 /* WasmOMGPlan.h */; };
918918
531374BD1D5CE67600AF7A0B /* WasmPlan.h in Headers */ = {isa = PBXBuildFile; fileRef = 531374BC1D5CE67600AF7A0B /* WasmPlan.h */; };
919+
5318045C22EAAC4B004A7342 /* B3ExtractValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 5318045B22EAAC4B004A7342 /* B3ExtractValue.h */; };
919920
5333BBDB2110F7D2007618EC /* DFGSpeculativeJIT32_64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86880F1B14328BB900B08D42 /* DFGSpeculativeJIT32_64.cpp */; };
920921
5333BBDC2110F7D9007618EC /* DFGSpeculativeJIT.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86EC9DC21328DF82002B2AD7 /* DFGSpeculativeJIT.cpp */; };
921922
5333BBDD2110F7E1007618EC /* DFGSpeculativeJIT64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86880F4C14353B2100B08D42 /* DFGSpeculativeJIT64.cpp */; };
@@ -3469,6 +3470,8 @@
34693470
5311BD491EA581E500525281 /* WasmOMGPlan.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmOMGPlan.h; sourceTree = "<group>"; };
34703471
531374BC1D5CE67600AF7A0B /* WasmPlan.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmPlan.h; sourceTree = "<group>"; };
34713472
531374BE1D5CE95000AF7A0B /* WasmPlan.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WasmPlan.cpp; sourceTree = "<group>"; };
3473+
5318045B22EAAC4B004A7342 /* B3ExtractValue.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = B3ExtractValue.h; path = b3/B3ExtractValue.h; sourceTree = "<group>"; };
3474+
5318045D22EAAF0F004A7342 /* B3ExtractValue.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = B3ExtractValue.cpp; path = b3/B3ExtractValue.cpp; sourceTree = "<group>"; };
34723475
531D4E191F59CDD200EC836C /* testapi.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = testapi.cpp; path = API/tests/testapi.cpp; sourceTree = "<group>"; };
34733476
532631B3218777A5007B8191 /* JavaScriptCore.modulemap */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = "sourcecode.module-map"; path = JavaScriptCore.modulemap; sourceTree = "<group>"; };
34743477
533B15DE1DC7F463004D500A /* WasmOps.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WasmOps.h; sourceTree = "<group>"; };
@@ -5443,6 +5446,8 @@
54435446
3395C70522555F6D00BDBFAD /* B3EliminateDeadCode.h */,
54445447
0F5BF16E1F23A5A10029D91D /* B3EnsureLoopPreHeaders.cpp */,
54455448
0F5BF16F1F23A5A10029D91D /* B3EnsureLoopPreHeaders.h */,
5449+
5318045D22EAAF0F004A7342 /* B3ExtractValue.cpp */,
5450+
5318045B22EAAC4B004A7342 /* B3ExtractValue.h */,
54465451
0F6971E81D92F42100BA02A5 /* B3FenceValue.cpp */,
54475452
0F6971E91D92F42100BA02A5 /* B3FenceValue.h */,
54485453
0F6B8AE01C4EFE1700969052 /* B3FixSSA.cpp */,
@@ -8730,6 +8735,7 @@
87308735
0F725CA81C503DED00AD943A /* B3EliminateCommonSubexpressions.h in Headers */,
87318736
3395C70722555F6D00BDBFAD /* B3EliminateDeadCode.h in Headers */,
87328737
0F5BF1711F23A5A10029D91D /* B3EnsureLoopPreHeaders.h in Headers */,
8738+
5318045C22EAAC4B004A7342 /* B3ExtractValue.h in Headers */,
87338739
0F6971EA1D92F42400BA02A5 /* B3FenceValue.h in Headers */,
87348740
0F6B8AE51C4EFE1700969052 /* B3FixSSA.h in Headers */,
87358741
0F725CB01C506D3B00AD943A /* B3FoldPathConstants.h in Headers */,

‎Source/JavaScriptCore/Sources.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ b3/B3Effects.cpp
127127
b3/B3EliminateCommonSubexpressions.cpp
128128
b3/B3EliminateDeadCode.cpp
129129
b3/B3EnsureLoopPreHeaders.cpp
130+
b3/B3ExtractValue.cpp
130131
b3/B3FenceValue.cpp
131132
b3/B3FixSSA.cpp
132133
b3/B3FoldPathConstants.cpp

‎Source/JavaScriptCore/b3/B3Bank.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ void forEachBank(const Func& func)
4747

4848
inline Bank bankForType(Type type)
4949
{
50-
switch (type) {
50+
switch (type.kind()) {
5151
case Void:
52+
case Tuple:
5253
ASSERT_NOT_REACHED();
5354
return GP;
5455
case Int32:

‎Source/JavaScriptCore/b3/B3CheckValue.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void CheckValue::convertToAdd()
4444
CheckValue::CheckValue(Kind kind, Origin origin, Value* left, Value* right)
4545
: StackmapValue(CheckedOpcode, kind, left->type(), origin)
4646
{
47-
ASSERT(B3::isInt(type()));
47+
ASSERT(type().isInt());
4848
ASSERT(left->type() == right->type());
4949
ASSERT(kind == CheckAdd || kind == CheckSub || kind == CheckMul);
5050
append(ConstrainedValue(left, ValueRep::WarmAny));
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (C) 2019 Apple Inc. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
*
13+
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21+
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
26+
#include "config.h"
27+
#include "B3ExtractValue.h"
28+
29+
#if ENABLE(B3_JIT)
30+
31+
namespace JSC { namespace B3 {
32+
33+
ExtractValue::~ExtractValue()
34+
{
35+
}
36+
37+
void ExtractValue::dumpMeta(CommaPrinter& comma, PrintStream& out) const
38+
{
39+
out.print(comma, "<<", m_index);
40+
}
41+
42+
} } // namespace JSC::B3
43+
44+
#endif // ENABLE(B3_JIT)
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/*
2+
* Copyright (C) 2019 Apple Inc. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
* 1. Redistributions of source code must retain the above copyright
8+
* notice, this list of conditions and the following disclaimer.
9+
* 2. Redistributions in binary form must reproduce the above copyright
10+
* notice, this list of conditions and the following disclaimer in the
11+
* documentation and/or other materials provided with the distribution.
12+
*
13+
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
17+
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19+
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20+
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21+
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24+
*/
25+
26+
#pragma once
27+
28+
#if ENABLE(B3_JIT)
29+
30+
#include "B3Value.h"
31+
32+
namespace JSC { namespace B3 {
33+
34+
class JS_EXPORT_PRIVATE ExtractValue final : public Value {
35+
public:
36+
static bool accepts(Kind kind) { return kind == Extract; }
37+
38+
~ExtractValue();
39+
40+
int32_t index() const { return m_index; }
41+
42+
B3_SPECIALIZE_VALUE_FOR_FIXED_CHILDREN(1)
43+
B3_SPECIALIZE_VALUE_FOR_FINAL_SIZE_FIXED_CHILDREN
44+
45+
protected:
46+
void dumpMeta(CommaPrinter&, PrintStream&) const override;
47+
48+
static Opcode opcodeFromConstructor(Origin, Type, Value*, int32_t) { return Extract; }
49+
50+
ExtractValue(Origin origin, Type type, Value* tuple, int32_t index)
51+
: Value(CheckedOpcode, Extract, type, One, origin, tuple)
52+
, m_index(index)
53+
{
54+
}
55+
56+
private:
57+
friend class Procedure;
58+
friend class Value;
59+
60+
int32_t m_index;
61+
};
62+
63+
} } // namespace JSC::B3
64+
65+
#endif // ENABLE(B3_JIT)

‎Source/JavaScriptCore/b3/B3FixSSA.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ JS_EXPORT_PRIVATE void demoteValues(Procedure&, const IndexSet<Value*>&);
4141

4242
// This fixes SSA for you. Use this after you have done demoteValues() and you have performed
4343
// whatever evil transformation you needed.
44-
bool fixSSA(Procedure&);
44+
JS_EXPORT_PRIVATE bool fixSSA(Procedure&);
4545

4646
} } // namespace JSC::B3
4747

‎Source/JavaScriptCore/b3/B3LowerMacros.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ class LowerMacros {
418418
zeroDenCase->setSuccessors(FrequentedBlock(m_block));
419419

420420
int64_t badNumeratorConst = 0;
421-
switch (m_value->type()) {
421+
switch (m_value->type().kind()) {
422422
case Int32:
423423
badNumeratorConst = std::numeric_limits<int32_t>::min();
424424
break;

‎Source/JavaScriptCore/b3/B3LowerMacrosAfterOptimizations.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class LowerMacrosAfterOptimizations {
138138
break;
139139
}
140140
case Neg: {
141-
if (!isFloat(m_value->type()))
141+
if (!m_value->type().isFloat())
142142
break;
143143

144144
// X86 is odd in that it requires this.

0 commit comments

Comments
 (0)