Diff
Modified: trunk/JSTests/ChangeLog (265073 => 265074)
--- trunk/JSTests/ChangeLog 2020-07-30 01:01:04 UTC (rev 265073)
+++ trunk/JSTests/ChangeLog 2020-07-30 04:42:46 UTC (rev 265074)
@@ -1,5 +1,17 @@
2020-07-29 Yusuke Suzuki <[email protected]>
+ [JSC] Add B3::BottomTupleValue node
+ https://bugs.webkit.org/show_bug.cgi?id=214956
+ <rdar://problem/65192877>
+
+ Reviewed by Keith Miller.
+
+ * wasm/stress/bottom-tuple.js: Added.
+ (try.main):
+ (catch):
+
+2020-07-29 Yusuke Suzuki <[email protected]>
+
[JSC] Upgrade test262
https://bugs.webkit.org/show_bug.cgi?id=214949
Added: trunk/JSTests/wasm/stress/bottom-tuple.js (0 => 265074)
--- trunk/JSTests/wasm/stress/bottom-tuple.js (rev 0)
+++ trunk/JSTests/wasm/stress/bottom-tuple.js 2020-07-30 04:42:46 UTC (rev 265074)
@@ -0,0 +1,26 @@
+//@ runDefault("--useConcurrentJIT=0")
+
+let buffer = new Uint8Array([
+ 0,97,115,109,1,0,0,0,1,7,1,96,0,3,127,127,127,3,2,1,0,4,6,
+ 1,111,1,16,255,1,5,4,1,1,4,4,6,13,1,124,0,68,0,0,0,0,0,0,
+ 0,0,11,7,23,4,2,116,49,1,0,2,109,49,2,0,2,103,49,3,0,4,109,
+ 97,105,110,0,0,10,116,1,114,0,65,0,16,0,65,65,65,0,16,0,65,
+ 0,65,0,109,16,0,13,0,0,109,65,109,16,0,0,16,4,16,109,0,109,
+ 109,109,0,83,0,151,151,151,151,67,212,0,67,0,168,33,67,67,
+ 67,175,99,175,0,67,212,0,67,0,168,33,67,67,67,128,42,151,
+ 151,151,1,0,0,0,0,0,0,129,151,151,151,151,151,67,212,0,67,
+ 0,168,33,67,67,67,128,42,151,0,175,0,67,0,0,0,0,0,0,65,65,
+ 65,0,65,0,11,0,14,4,110,97,109,101,1,7,1,0,4,109,97,105,110
+]);
+
+var error = undefined;
+try {
+ let module = new WebAssembly.Module(buffer);
+ let instance = new WebAssembly.Instance(module);
+ main = function() { return instance.exports.main(); };
+ main();
+} catch (err) {
+ error = err;
+}
+if (!error || error.message !== "Maximum call stack size exceeded.")
+ throw "Expected stack overflow error";
Modified: trunk/Source/_javascript_Core/ChangeLog (265073 => 265074)
--- trunk/Source/_javascript_Core/ChangeLog 2020-07-30 01:01:04 UTC (rev 265073)
+++ trunk/Source/_javascript_Core/ChangeLog 2020-07-30 04:42:46 UTC (rev 265074)
@@ -1,3 +1,50 @@
+2020-07-29 Yusuke Suzuki <[email protected]>
+
+ [JSC] Add B3::BottomTupleValue node
+ https://bugs.webkit.org/show_bug.cgi?id=214956
+ <rdar://problem/65192877>
+
+ Reviewed by Keith Miller.
+
+ In B3 strength reduction, we convert B3 values to bottom value based on type after Oops kind, and then they are *typically* removed later.
+ While we support bottom values for usual types, we do not have a bottom value for tuple type. So when replaceWithBottom is called, we
+ fail to replace Patchpoints producing tuples with bottom values.
+
+ This patch newly adds B3 BottomTupleValue, which is just a BottomValue for tuple. We can extend it to generate arbitrary constant
+ tuple values, but for now, we just support bottom tuple values. We add a new node instead of generating patchpoint which generates bottom
+ values since BottomTupleValues implementation is simpler: BottomTupleValue just emits bunch of zero clear for Air tmps and Air does everything
+ automatically. On the other hand, implementing a patchpoint needs to add code which clears things with zero while checking the ValueRep. And
+ since we have Const32, Const64, etc. values, having this kind of value for tuple too is natural. Plus, this design allows us to remove bunch
+ of unnecessary instructions after lowering this to Air since Air knows what instructions will be emitted by this BottomTupleValue, and Air
+ can remove a lot of zero clear instructions if they are not read later by Extract.
+
+ * _javascript_Core.xcodeproj/project.pbxproj:
+ * Sources.txt:
+ * b3/B3BottomTupleValue.cpp: Copied from Source/_javascript_Core/b3/B3InsertionSet.cpp.
+ (JSC::B3::BottomTupleValue::dumpMeta const):
+ * b3/B3BottomTupleValue.h: Copied from Source/_javascript_Core/b3/B3InsertionSet.cpp.
+ * b3/B3InsertionSet.cpp:
+ (JSC::B3::InsertionSet::insertBottom):
+ * b3/B3LowerToAir.cpp:
+ * b3/B3Opcode.cpp:
+ (WTF::printInternal):
+ * b3/B3Opcode.h:
+ * b3/B3Procedure.cpp:
+ (JSC::B3::Procedure::addBottom):
+ * b3/B3TypeMap.h:
+ (JSC::B3::TypeMap::TypeMap): Deleted.
+ * b3/B3Validate.cpp:
+ * b3/B3Value.cpp:
+ (JSC::B3::Value::effects const):
+ (JSC::B3::Value::key const):
+ * b3/B3Value.h:
+ * b3/B3ValueInlines.h:
+ * b3/B3ValueKey.cpp:
+ (JSC::B3::ValueKey::materialize const):
+ * b3/testb3_7.cpp:
+ (testBottomTupleValue):
+ (addTupleTests):
+
2020-07-29 Tadeu Zagallo <[email protected]>
WebAssembly validation for call_indirect is incorrect
Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (265073 => 265074)
--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2020-07-30 01:01:04 UTC (rev 265073)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2020-07-30 04:42:46 UTC (rev 265074)
@@ -1844,6 +1844,8 @@
E38652E3237CA0C900E1D5EE /* BlockDirectoryBits.h in Headers */ = {isa = PBXBuildFile; fileRef = E38652E2237CA0C800E1D5EE /* BlockDirectoryBits.h */; settings = {ATTRIBUTES = (Private, ); }; };
E3893A1D2203A7C600E79A74 /* AsyncFromSyncIteratorPrototype.lut.h in Headers */ = {isa = PBXBuildFile; fileRef = E3893A1C2203A7C600E79A74 /* AsyncFromSyncIteratorPrototype.lut.h */; };
E39006212208BFC4001019CF /* SubspaceAccess.h in Headers */ = {isa = PBXBuildFile; fileRef = E39006202208BFC3001019CF /* SubspaceAccess.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ E392E6F824D25FA600B20767 /* B3BottomTupleValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E392E6F624D25FA600B20767 /* B3BottomTupleValue.cpp */; };
+ E392E6F924D25FA900B20767 /* B3BottomTupleValue.h in Headers */ = {isa = PBXBuildFile; fileRef = E392E6F724D25FA600B20767 /* B3BottomTupleValue.h */; };
E393ADD81FE702D00022D681 /* WeakMapImplInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = E393ADD71FE702CC0022D681 /* WeakMapImplInlines.h */; };
E39BF39922A2288B00BD183E /* SymbolTableInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = E39BF39822A2288B00BD183E /* SymbolTableInlines.h */; };
E39D45F51D39005600B3B377 /* InterpreterInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = E39D9D841D39000600667282 /* InterpreterInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -5042,6 +5044,8 @@
E38D060D1F8E814100649CF2 /* JSScriptFetchParameters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSScriptFetchParameters.cpp; sourceTree = "<group>"; };
E39006202208BFC3001019CF /* SubspaceAccess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SubspaceAccess.h; sourceTree = "<group>"; };
E3915C062309682900CB2561 /* WasmContext.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = WasmContext.cpp; sourceTree = "<group>"; };
+ E392E6F624D25FA600B20767 /* B3BottomTupleValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = B3BottomTupleValue.cpp; path = b3/B3BottomTupleValue.cpp; sourceTree = "<group>"; };
+ E392E6F724D25FA600B20767 /* B3BottomTupleValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = B3BottomTupleValue.h; path = b3/B3BottomTupleValue.h; sourceTree = "<group>"; };
E393ADD71FE702CC0022D681 /* WeakMapImplInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WeakMapImplInlines.h; sourceTree = "<group>"; };
E3963CEC1B73F75000EB4CE5 /* NodesAnalyzeModule.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NodesAnalyzeModule.cpp; sourceTree = "<group>"; };
E39BF39822A2288B00BD183E /* SymbolTableInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SymbolTableInlines.h; sourceTree = "<group>"; };
@@ -5658,6 +5662,8 @@
0F338E181BF286EA0013C88F /* B3BlockInsertionSet.h */,
0FEC84BA1BDACDAC0080FF74 /* B3BlockWorklist.h */,
DCFDFBD71D1F5D9800FE3D72 /* B3BottomProvider.h */,
+ E392E6F624D25FA600B20767 /* B3BottomTupleValue.cpp */,
+ E392E6F724D25FA600B20767 /* B3BottomTupleValue.h */,
0F6B8ADE1C4EFE1700969052 /* B3BreakCriticalEdges.cpp */,
0F6B8ADF1C4EFE1700969052 /* B3BreakCriticalEdges.h */,
DC9A0C1C1D2D94EF0085124E /* B3CaseCollection.cpp */,
@@ -9073,6 +9079,7 @@
0F338E1C1BF286EA0013C88F /* B3BlockInsertionSet.h in Headers */,
0FEC85041BDACDAC0080FF74 /* B3BlockWorklist.h in Headers */,
DCFDFBD91D1F5D9B00FE3D72 /* B3BottomProvider.h in Headers */,
+ E392E6F924D25FA900B20767 /* B3BottomTupleValue.h in Headers */,
0F6B8AE31C4EFE1700969052 /* B3BreakCriticalEdges.h in Headers */,
DC9A0C201D2D9CB30085124E /* B3CaseCollection.h in Headers */,
DC9A0C1F1D2D9CB10085124E /* B3CaseCollectionInlines.h in Headers */,
@@ -11175,6 +11182,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ E392E6F824D25FA600B20767 /* B3BottomTupleValue.cpp in Sources */,
0FEC85AF1BDB5D5E0080FF74 /* testb3_1.cpp in Sources */,
5C3A77BA22F2480F003827FF /* testb3_2.cpp in Sources */,
5C3A77B922F2480B003827FF /* testb3_3.cpp in Sources */,
Modified: trunk/Source/_javascript_Core/Sources.txt (265073 => 265074)
--- trunk/Source/_javascript_Core/Sources.txt 2020-07-30 01:01:04 UTC (rev 265073)
+++ trunk/Source/_javascript_Core/Sources.txt 2020-07-30 04:42:46 UTC (rev 265074)
@@ -109,6 +109,7 @@
b3/B3Bank.cpp
b3/B3BasicBlock.cpp
b3/B3BlockInsertionSet.cpp
+b3/B3BottomTupleValue.cpp
b3/B3BreakCriticalEdges.cpp
b3/B3CCallValue.cpp
b3/B3CaseCollection.cpp
Copied: trunk/Source/_javascript_Core/b3/B3BottomTupleValue.cpp (from rev 265073, trunk/Source/_javascript_Core/b3/B3InsertionSet.cpp) (0 => 265074)
--- trunk/Source/_javascript_Core/b3/B3BottomTupleValue.cpp (rev 0)
+++ trunk/Source/_javascript_Core/b3/B3BottomTupleValue.cpp 2020-07-30 04:42:46 UTC (rev 265074)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "B3BottomTupleValue.h"
+
+#if ENABLE(B3_JIT)
+
+namespace JSC { namespace B3 {
+
+BottomTupleValue::~BottomTupleValue() = default;
+
+void BottomTupleValue::dumpMeta(CommaPrinter& comma, PrintStream& out) const
+{
+ out.print(comma, "<<", m_index);
+}
+
+} } // namespace JSC::B3
+
+#endif // ENABLE(B3_JIT)
Copied: trunk/Source/_javascript_Core/b3/B3BottomTupleValue.h (from rev 265073, trunk/Source/_javascript_Core/b3/B3InsertionSet.cpp) (0 => 265074)
--- trunk/Source/_javascript_Core/b3/B3BottomTupleValue.h (rev 0)
+++ trunk/Source/_javascript_Core/b3/B3BottomTupleValue.h 2020-07-30 04:42:46 UTC (rev 265074)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2020 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(B3_JIT)
+
+#include "B3Value.h"
+
+namespace JSC { namespace B3 {
+
+class JS_EXPORT_PRIVATE BottomTupleValue final : public Value {
+public:
+ static bool accepts(Kind kind) { return kind == BottomTuple; }
+
+ ~BottomTupleValue() final;
+
+ B3_SPECIALIZE_VALUE_FOR_NO_CHILDREN
+
+private:
+ void dumpMeta(CommaPrinter&, PrintStream&) const final;
+
+ static Opcode opcodeFromConstructor(Origin, Type) { return BottomTuple; }
+
+ BottomTupleValue(Origin origin, Type type)
+ : Value(CheckedOpcode, BottomTuple, type, Zero, origin)
+ {
+ ASSERT(type.isTuple());
+ }
+
+ friend class Procedure;
+ friend class Value;
+};
+
+} } // namespace JSC::B3
+
+#endif // ENABLE(B3_JIT)
Modified: trunk/Source/_javascript_Core/b3/B3InsertionSet.cpp (265073 => 265074)
--- trunk/Source/_javascript_Core/b3/B3InsertionSet.cpp 2020-07-30 01:01:04 UTC (rev 265073)
+++ trunk/Source/_javascript_Core/b3/B3InsertionSet.cpp 2020-07-30 04:42:46 UTC (rev 265074)
@@ -47,6 +47,8 @@
Value* InsertionSet::insertBottom(size_t index, Origin origin, Type type)
{
+ if (type.isTuple())
+ return insertValue(index, m_procedure.addBottom(origin, type));
Value*& bottom = m_bottomForType[type];
if (!bottom)
bottom = insertValue(index, m_procedure.addBottom(origin, type));
Modified: trunk/Source/_javascript_Core/b3/B3LowerToAir.cpp (265073 => 265074)
--- trunk/Source/_javascript_Core/b3/B3LowerToAir.cpp 2020-07-30 01:01:04 UTC (rev 265073)
+++ trunk/Source/_javascript_Core/b3/B3LowerToAir.cpp 2020-07-30 04:42:46 UTC (rev 265074)
@@ -142,7 +142,8 @@
break;
}
case Get:
- case Patchpoint: {
+ case Patchpoint:
+ case BottomTuple: {
if (value->type().isTuple())
ensureTupleTmps(value, m_tupleValueToTmps);
break;
@@ -436,7 +437,8 @@
switch (tupleValue->opcode()) {
case Phi:
- case Patchpoint: {
+ case Patchpoint:
+ case BottomTuple: {
return m_tupleValueToTmps.find(tupleValue)->value;
}
case Get:
@@ -2975,6 +2977,27 @@
return;
}
+ case BottomTuple: {
+ forEachImmOrTmp(m_value, [&] (Arg tmp, Type type, unsigned) {
+ switch (type.kind()) {
+ case Void:
+ case Tuple:
+ RELEASE_ASSERT_NOT_REACHED();
+ break;
+ case Int32:
+ case Int64:
+ ASSERT(Arg::isValidImmForm(0));
+ append(Move, imm(static_cast<int64_t>(0)), tmp.tmp());
+ break;
+ case Float:
+ case Double:
+ append(MoveZeroToDouble, tmp.tmp());
+ break;
+ }
+ });
+ return;
+ }
+
case FramePointer: {
ASSERT(tmp(m_value) == Tmp(GPRInfo::callFrameRegister));
return;
Modified: trunk/Source/_javascript_Core/b3/B3Opcode.cpp (265073 => 265074)
--- trunk/Source/_javascript_Core/b3/B3Opcode.cpp 2020-07-30 01:01:04 UTC (rev 265073)
+++ trunk/Source/_javascript_Core/b3/B3Opcode.cpp 2020-07-30 04:42:46 UTC (rev 265074)
@@ -120,6 +120,9 @@
case ConstFloat:
out.print("ConstFloat");
return;
+ case BottomTuple:
+ out.print("BottomTuple");
+ return;
case Get:
out.print("Get");
return;
Modified: trunk/Source/_javascript_Core/b3/B3Opcode.h (265073 => 265074)
--- trunk/Source/_javascript_Core/b3/B3Opcode.h 2020-07-30 01:01:04 UTC (rev 265073)
+++ trunk/Source/_javascript_Core/b3/B3Opcode.h 2020-07-30 04:42:46 UTC (rev 265074)
@@ -56,6 +56,9 @@
ConstDouble,
ConstFloat,
+ // Tuple filled with zeros. This appears when Tuple Patchpoints are replaced with Bottom values.
+ BottomTuple,
+
// B3 supports non-SSA variables. These are accessed using Get and Set opcodes. Use the
// VariableValue class. It's a good idea to run fixSSA() to turn these into SSA. The
// optimizer will do that eventually, but if your input tends to use these opcodes, you
@@ -296,7 +299,7 @@
// stack.
Patchpoint,
- // This is a projection out of a tuple. Currently only Patchpoints, Get, and Phi can produce tuples.
+ // This is a projection out of a tuple. Currently only Patchpoints, Get, Phi, and BottomTuple can produce tuples.
// It's assumumed that each entry in a tuple has a fixed Numeric B3 Type (i.e. not Void or Tuple).
Extract,
Modified: trunk/Source/_javascript_Core/b3/B3Procedure.cpp (265073 => 265074)
--- trunk/Source/_javascript_Core/b3/B3Procedure.cpp 2020-07-30 01:01:04 UTC (rev 265073)
+++ trunk/Source/_javascript_Core/b3/B3Procedure.cpp 2020-07-30 04:42:46 UTC (rev 265074)
@@ -150,6 +150,8 @@
Value* Procedure::addBottom(Origin origin, Type type)
{
+ if (type.isTuple())
+ return add<BottomTupleValue>(origin, type);
return addIntConstant(origin, type, 0);
}
Modified: trunk/Source/_javascript_Core/b3/B3Procedure.h (265073 => 265074)
--- trunk/Source/_javascript_Core/b3/B3Procedure.h 2020-07-30 01:01:04 UTC (rev 265073)
+++ trunk/Source/_javascript_Core/b3/B3Procedure.h 2020-07-30 04:42:46 UTC (rev 265074)
@@ -119,7 +119,7 @@
const Vector<Vector<Type>>& tuples() const { return m_tuples; };
bool isValidTuple(Type tuple) const;
Type extractFromTuple(Type tuple, unsigned index) const;
- const Vector<Type>& tupleForType(Type tuple) const;
+ JS_EXPORT_PRIVATE const Vector<Type>& tupleForType(Type tuple) const;
unsigned resultCount(Type type) const { return type.isTuple() ? tupleForType(type).size() : type.isNumeric(); }
Type typeAtOffset(Type type, unsigned index) const { ASSERT(index < resultCount(type)); return type.isTuple() ? extractFromTuple(type, index) : type; }
Modified: trunk/Source/_javascript_Core/b3/B3TypeMap.h (265073 => 265074)
--- trunk/Source/_javascript_Core/b3/B3TypeMap.h 2020-07-30 01:01:04 UTC (rev 265073)
+++ trunk/Source/_javascript_Core/b3/B3TypeMap.h 2020-07-30 04:42:46 UTC (rev 265074)
@@ -39,14 +39,7 @@
template<typename T>
class TypeMap {
public:
- TypeMap()
- : m_void()
- , m_int32()
- , m_int64()
- , m_float()
- , m_double()
- {
- }
+ TypeMap() = default;
T& at(Type type)
{
@@ -93,12 +86,12 @@
}
private:
- T m_void;
- T m_int32;
- T m_int64;
- T m_float;
- T m_double;
- T m_tuple;
+ T m_void { };
+ T m_int32 { };
+ T m_int64 { };
+ T m_float { };
+ T m_double { };
+ T m_tuple { };
};
} } // namespace JSC::B3
Modified: trunk/Source/_javascript_Core/b3/B3Validate.cpp (265073 => 265074)
--- trunk/Source/_javascript_Core/b3/B3Validate.cpp 2020-07-30 01:01:04 UTC (rev 265073)
+++ trunk/Source/_javascript_Core/b3/B3Validate.cpp 2020-07-30 04:42:46 UTC (rev 265074)
@@ -171,6 +171,11 @@
VALIDATE(!value->numChildren(), ("At ", *value));
VALIDATE(value->type() == Float, ("At ", *value));
break;
+ case BottomTuple:
+ VALIDATE(!value->kind().hasExtraBits(), ("At ", *value));
+ VALIDATE(!value->numChildren(), ("At ", *value));
+ VALIDATE(value->type().isTuple(), ("At ", *value));
+ break;
case Set:
VALIDATE(!value->kind().hasExtraBits(), ("At ", *value));
VALIDATE(value->numChildren() == 1, ("At ", *value));
Modified: trunk/Source/_javascript_Core/b3/B3Value.cpp (265073 => 265074)
--- trunk/Source/_javascript_Core/b3/B3Value.cpp 2020-07-30 01:01:04 UTC (rev 265073)
+++ trunk/Source/_javascript_Core/b3/B3Value.cpp 2020-07-30 04:42:46 UTC (rev 265074)
@@ -533,6 +533,7 @@
case Const64:
case ConstDouble:
case ConstFloat:
+ case BottomTuple:
case SlotBase:
case ArgumentReg:
case FramePointer:
@@ -748,6 +749,8 @@
return ValueKey(ConstDouble, type(), asDouble());
case ConstFloat:
return ValueKey(ConstFloat, type(), asFloat());
+ case BottomTuple:
+ return ValueKey(BottomTuple, type());
case ArgumentReg:
return ValueKey(
ArgumentReg, type(),
Modified: trunk/Source/_javascript_Core/b3/B3Value.h (265073 => 265074)
--- trunk/Source/_javascript_Core/b3/B3Value.h 2020-07-30 01:01:04 UTC (rev 265073)
+++ trunk/Source/_javascript_Core/b3/B3Value.h 2020-07-30 04:42:46 UTC (rev 265074)
@@ -391,6 +391,7 @@
case Const64:
case ConstFloat:
case ConstDouble:
+ case BottomTuple:
case Fence:
case SlotBase:
case Get:
Modified: trunk/Source/_javascript_Core/b3/B3ValueInlines.h (265073 => 265074)
--- trunk/Source/_javascript_Core/b3/B3ValueInlines.h 2020-07-30 01:01:04 UTC (rev 265073)
+++ trunk/Source/_javascript_Core/b3/B3ValueInlines.h 2020-07-30 04:42:46 UTC (rev 265074)
@@ -29,6 +29,7 @@
#include "B3ArgumentRegValue.h"
#include "B3AtomicValue.h"
+#include "B3BottomTupleValue.h"
#include "B3CCallValue.h"
#include "B3CheckValue.h"
#include "B3Const32Value.h"
@@ -119,6 +120,8 @@
return MACRO(ConstFloatValue); \
case ConstDouble: \
return MACRO(ConstDoubleValue); \
+ case BottomTuple: \
+ return MACRO(BottomTupleValue); \
case Fence: \
return MACRO(FenceValue); \
case SlotBase: \
Modified: trunk/Source/_javascript_Core/b3/B3ValueKey.cpp (265073 => 265074)
--- trunk/Source/_javascript_Core/b3/B3ValueKey.cpp 2020-07-30 01:01:04 UTC (rev 265073)
+++ trunk/Source/_javascript_Core/b3/B3ValueKey.cpp 2020-07-30 04:42:46 UTC (rev 265074)
@@ -116,6 +116,8 @@
return proc.add<ConstDoubleValue>(origin, doubleValue());
case ConstFloat:
return proc.add<ConstFloatValue>(origin, floatValue());
+ case BottomTuple:
+ return proc.add<BottomTupleValue>(origin, type());
case ArgumentReg:
return proc.add<ArgumentRegValue>(origin, Reg::fromIndex(static_cast<unsigned>(value())));
case SlotBase:
Modified: trunk/Source/_javascript_Core/b3/testb3_7.cpp (265073 => 265074)
--- trunk/Source/_javascript_Core/b3/testb3_7.cpp 2020-07-30 01:01:04 UTC (rev 265073)
+++ trunk/Source/_javascript_Core/b3/testb3_7.cpp 2020-07-30 04:42:46 UTC (rev 265074)
@@ -1611,6 +1611,55 @@
CHECK_EQ(compileAndRun<int64_t>(proc), first + second);
}
+template<B3::TypeKind kind, typename ResultType>
+static void testBottomTupleValue()
+{
+ Procedure proc;
+ BasicBlock* root = proc.addBlock();
+
+ auto* tuple = root->appendNew<BottomTupleValue>(proc, Origin(), proc.addTuple({
+ kind, kind, kind, kind, kind,
+ kind, kind, kind, kind, kind,
+ kind, kind, kind, kind, kind,
+ kind, kind, kind, kind, kind,
+ kind, kind, kind, kind, kind,
+ kind, kind, kind, kind, kind,
+ kind, kind, kind, kind, kind,
+ kind, kind, kind, kind, kind,
+ kind, kind, kind, kind, kind,
+ kind, kind, kind, kind, kind,
+ }));
+ Value* result = root->appendNew<ExtractValue>(proc, Origin(), kind, tuple, 0);
+ root->appendNew<Value>(proc, Return, Origin(), result);
+ CHECK_EQ(compileAndRun<ResultType>(proc), 0);
+}
+
+template<B3::TypeKind kind, typename ResultType>
+static void testTouchAllBottomTupleValue()
+{
+ Procedure proc;
+ BasicBlock* root = proc.addBlock();
+
+ Type tupleType = proc.addTuple({
+ kind, kind, kind, kind, kind,
+ kind, kind, kind, kind, kind,
+ kind, kind, kind, kind, kind,
+ kind, kind, kind, kind, kind,
+ kind, kind, kind, kind, kind,
+ kind, kind, kind, kind, kind,
+ kind, kind, kind, kind, kind,
+ kind, kind, kind, kind, kind,
+ kind, kind, kind, kind, kind,
+ kind, kind, kind, kind, kind,
+ });
+ auto* tuple = root->appendNew<BottomTupleValue>(proc, Origin(), tupleType);
+ Value* result = root->appendNew<ExtractValue>(proc, Origin(), kind, tuple, 0);
+ for (unsigned index = 1; index < proc.resultCount(tupleType); ++index)
+ result = root->appendNew<Value>(proc, Add, Origin(), result, root->appendNew<ExtractValue>(proc, Origin(), kind, tuple, index));
+ root->appendNew<Value>(proc, Return, Origin(), result);
+ CHECK_EQ(compileAndRun<ResultType>(proc), 0);
+}
+
template<bool shouldFixSSA>
static void tailDupedTuplePair(unsigned first, double second)
{
@@ -1811,6 +1860,14 @@
RUN_BINARY(testSimpleTuplePair, int32Operands(), int64Operands());
RUN_BINARY(testSimpleTuplePairUnused, int32Operands(), int64Operands());
RUN_BINARY(testSimpleTuplePairStack, int32Operands(), int64Operands());
+ RUN((testBottomTupleValue<Int32, int32_t>)());
+ RUN((testBottomTupleValue<Int64, int64_t>)());
+ RUN((testBottomTupleValue<Float, float>)());
+ RUN((testBottomTupleValue<Double, double>)());
+ RUN((testTouchAllBottomTupleValue<Int32, int32_t>)());
+ RUN((testTouchAllBottomTupleValue<Int64, int64_t>)());
+ RUN((testTouchAllBottomTupleValue<Float, float>)());
+ RUN((testTouchAllBottomTupleValue<Double, double>)());
// use int64 as second argument because checking for NaN is annoying and doesn't really matter for this test.
RUN_BINARY(tailDupedTuplePair<true>, int32Operands(), int64Operands());
RUN_BINARY(tailDupedTuplePair<false>, int32Operands(), int64Operands());