Diff
Modified: trunk/JSTests/ChangeLog (293509 => 293510)
--- trunk/JSTests/ChangeLog 2022-04-27 15:49:37 UTC (rev 293509)
+++ trunk/JSTests/ChangeLog 2022-04-27 15:49:39 UTC (rev 293510)
@@ -1,3 +1,18 @@
+2022-04-27 Dmitry Bezhetskov <[email protected]>
+
+ [WASM-GC] Introduce rtt types
+ https://bugs.webkit.org/show_bug.cgi?id=239493
+
+ Reviewed by Keith Miller.
+
+ Added basic tests for manipulation of rtt types.
+
+ * wasm/gc/rtt.js: Added.
+ (module):
+ (testRttTypes):
+ (testRttCanon):
+ * wasm/wasm.json:
+
2022-04-26 Yusuke Suzuki <[email protected]>
[JSC] Add forceUnlinkedDFG option
Added: trunk/JSTests/wasm/gc/rtt.js (0 => 293510)
--- trunk/JSTests/wasm/gc/rtt.js (rev 0)
+++ trunk/JSTests/wasm/gc/rtt.js 2022-04-27 15:49:39 UTC (rev 293510)
@@ -0,0 +1,57 @@
+//@ runWebAssemblySuite("--useWebAssemblyTypedFunctionReferences=true", "--useWebAssemblyGC=true")
+
+import * as assert from "../assert.js";
+import { instantiate } from "../wabt-wrapper.js";
+
+function module(bytes, valid = true) {
+ let buffer = new ArrayBuffer(bytes.length);
+ let view = new Uint8Array(buffer);
+ for (let i = 0; i < bytes.length; ++i) {
+ view[i] = bytes.charCodeAt(i);
+ }
+ return new WebAssembly.Module(buffer);
+}
+
+function testRttTypes() {
+ /*
+ (module
+ (type $Point (struct (field i32) (field i32)))
+ (func (param (rtt $Point)))
+ )
+ */
+ module("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x0c\x02\x5f\x02\x7f\x00\x7f\x00\x60\x01\x68\x00\x00\x03\x02\x01\x01\x0a\x05\x01\x03\x00\x01\x0b");
+}
+
+function testRttCanon() {
+ {
+ /*
+ (module
+ (type $Point (struct (field $x i32) (field $y i32)))
+ (func $foo (param (rtt $Point)) (result i32) (i32.const 37))
+ (func (export "main")
+ (drop
+ (call $foo (rtt.canon $Point))
+ )
+ )
+ )
+ */
+ let instance = new WebAssembly.Instance(module("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x10\x03\x5f\x02\x7f\x00\x7f\x00\x60\x01\x68\x00\x01\x7f\x60\x00\x00\x03\x03\x02\x01\x02\x07\x08\x01\x04\x6d\x61\x69\x6e\x00\x01\x0a\x0f\x02\x04\x00\x41\x25\x0b\x08\x00\xfb\x30\x00\x10\x00\x1a\x0b"));
+ instance.exports.main();
+ }
+
+ {
+ /*
+ (module
+ (type $Point (struct (field $x i32) (field $y i32)))
+ (func (export "main")
+ (unreachable)
+ (rtt.canon $Point)
+ )
+ )
+ */
+ new WebAssembly.Instance(module("\x00\x61\x73\x6d\x01\x00\x00\x00\x01\x0a\x02\x60\x00\x00\x5f\x02\x7f\x00\x7f\x00\x03\x02\x01\x00\x07\x08\x01\x04\x6d\x61\x69\x6e\x00\x00\x0a\x08\x01\x06\x00\x00\xfb\x30\x01\x0b"));
+ }
+}
+
+testRttTypes();
+testRttCanon();
Modified: trunk/JSTests/wasm/wasm.json (293509 => 293510)
--- trunk/JSTests/wasm/wasm.json 2022-04-27 15:49:37 UTC (rev 293509)
+++ trunk/JSTests/wasm/wasm.json 2022-04-27 15:49:39 UTC (rev 293510)
@@ -17,6 +17,7 @@
"ref": { "type": "varint7", "value": -21, "b3type": "B3::Int64" },
"func": { "type": "varint7", "value": -32, "b3type": "B3::Void" },
"struct": { "type": "varint7", "value": -33, "b3type": "B3::Void" },
+ "rtt": { "type": "varint7", "value": -24, "b3type": "B3::Void" },
"void": { "type": "varint7", "value": -64, "b3type": "B3::Void" }
},
"value_type": ["i32", "i64", "f32", "f64", "externref", "funcref"],
@@ -77,6 +78,7 @@
"ref.null": { "category": "special", "value": 208, "return": ["externref", "funcref"], "parameter": [], "immediate": [{"name": "reftype", "type": "ref_type"}], "description": "a constant null reference" },
"ref.is_null": { "category": "special", "value": 209, "return": ["i32"], "parameter": ["externref"], "immediate": [], "description": "determine if a reference is null" },
"ref.func": { "category": "special", "value": 210, "return": ["funcref"], "parameter": [], "immediate": [{"name": "function_index", "type": "varuint32"}], "description": "return a reference to the function at the given index" },
+ "rtt.canon": { "category": "gc", "value": 251, "return": ["rtt"], "parameter": [], "immediate": [{"name": "type_index", "type": "varuint32"}], "description": "returns the RTT of the specified type", "extendedOp": 48 },
"get_local": { "category": "special", "value": 32, "return": ["any"], "parameter": [], "immediate": [{"name": "local_index", "type": "varuint32"}], "description": "read a local variable or parameter" },
"set_local": { "category": "special", "value": 33, "return": [], "parameter": ["any"], "immediate": [{"name": "local_index", "type": "varuint32"}], "description": "write a local variable or parameter" },
"tee_local": { "category": "special", "value": 34, "return": ["any"], "parameter": ["any"], "immediate": [{"name": "local_index", "type": "varuint32"}], "description": "write a local variable or parameter and return the same value" },
Modified: trunk/Source/_javascript_Core/ChangeLog (293509 => 293510)
--- trunk/Source/_javascript_Core/ChangeLog 2022-04-27 15:49:37 UTC (rev 293509)
+++ trunk/Source/_javascript_Core/ChangeLog 2022-04-27 15:49:39 UTC (rev 293510)
@@ -1,3 +1,52 @@
+2022-04-27 Dmitry Bezhetskov <[email protected]>
+
+ [WASM-GC] Introduce rtt types
+ https://bugs.webkit.org/show_bug.cgi?id=239493
+
+ Reviewed by Keith Miller.
+
+ Add a basic support through runtime call for rtt.canon and rtt types.
+ It is a prototype implementation of rtt types needed to move forward
+ with wasm gc proposal (https://github.com/WebAssembly/gc/blob/main/proposals/gc/MVP.md).
+ For example, we don't need to use rtt values for struct.new,
+ but we do need them for the future js api.
+ So, rtt.canon returns jsNull for now, but we can replace it with
+ properly defined values when the spec will be ready.
+
+ * bytecode/BytecodeList.rb:
+ * llint/WebAssembly.asm:
+ * wasm/WasmAirIRGenerator.cpp:
+ (JSC::Wasm::AirIRGenerator::tmpForType):
+ (JSC::Wasm::AirIRGenerator::AirIRGenerator):
+ (JSC::Wasm::AirIRGenerator::addRttCanon):
+ * wasm/WasmB3IRGenerator.cpp:
+ (JSC::Wasm::B3IRGenerator::addRttCanon):
+ * wasm/WasmCallingConvention.h:
+ (JSC::Wasm::WasmCallingConvention::marshallLocation const):
+ * wasm/WasmFormat.h:
+ (JSC::Wasm::isValueType):
+ (JSC::Wasm::isValidHeapTypeKind):
+ * wasm/WasmFunctionParser.h:
+ (JSC::Wasm::FunctionParser<Context>::parseExpression):
+ (JSC::Wasm::FunctionParser<Context>::parseUnreachableExpression):
+ * wasm/WasmLLIntGenerator.cpp:
+ (JSC::Wasm::LLIntGenerator::callInformationForCaller):
+ (JSC::Wasm::LLIntGenerator::callInformationForCallee):
+ (JSC::Wasm::LLIntGenerator::addArguments):
+ (JSC::Wasm::LLIntGenerator::addRttCanon):
+ * wasm/WasmOperations.cpp:
+ (JSC::Wasm::JSC_DEFINE_JIT_OPERATION):
+ * wasm/WasmOperations.h:
+ * wasm/WasmParser.h:
+ (JSC::Wasm::Parser<SuccessType>::parseValueType):
+ * wasm/WasmSlowPaths.cpp:
+ (JSC::LLInt::WASM_SLOW_PATH_DECL):
+ * wasm/WasmSlowPaths.h:
+ * wasm/generateWasmOpsHeader.py:
+ * wasm/js/WasmToJS.cpp:
+ (JSC::Wasm::wasmToJS):
+ * wasm/wasm.json:
+
2022-04-26 Dmitry Bezhetskov <[email protected]>
[WASM] Fix warning: cast from ‘char*’ to ‘JSC::Wasm::Type*’ increases required alignment of target type [-Wcast-align]
Modified: trunk/Source/_javascript_Core/bytecode/BytecodeList.rb (293509 => 293510)
--- trunk/Source/_javascript_Core/bytecode/BytecodeList.rb 2022-04-27 15:49:37 UTC (rev 293509)
+++ trunk/Source/_javascript_Core/bytecode/BytecodeList.rb 2022-04-27 15:49:39 UTC (rev 293510)
@@ -1892,4 +1892,10 @@
exception: VirtualRegister,
}
+op :rtt_canon,
+ args: {
+ dst: VirtualRegister,
+ typeIndex: unsigned,
+ }
+
end_section :Wasm
Modified: trunk/Source/_javascript_Core/llint/WebAssembly.asm (293509 => 293510)
--- trunk/Source/_javascript_Core/llint/WebAssembly.asm 2022-04-27 15:49:37 UTC (rev 293509)
+++ trunk/Source/_javascript_Core/llint/WebAssembly.asm 2022-04-27 15:49:39 UTC (rev 293510)
@@ -602,6 +602,7 @@
slowWasmOp(memory_atomic_wait32)
slowWasmOp(memory_atomic_wait64)
slowWasmOp(memory_atomic_notify)
+slowWasmOp(rtt_canon)
wasmOp(grow_memory, WasmGrowMemory, macro(ctx)
callWasmSlowPath(_slow_path_wasm_grow_memory)
Modified: trunk/Source/_javascript_Core/wasm/WasmAirIRGenerator.cpp (293509 => 293510)
--- trunk/Source/_javascript_Core/wasm/WasmAirIRGenerator.cpp 2022-04-27 15:49:37 UTC (rev 293509)
+++ trunk/Source/_javascript_Core/wasm/WasmAirIRGenerator.cpp 2022-04-27 15:49:39 UTC (rev 293510)
@@ -377,6 +377,9 @@
// Saturated truncation.
PartialResult WARN_UNUSED_RETURN truncSaturated(Ext1OpType, ExpressionType operand, ExpressionType& result, Type returnType, Type operandType);
+ // GC
+ PartialResult WARN_UNUSED_RETURN addRttCanon(uint32_t typeIndex, ExpressionType& result);
+
// Basic operators
template<OpType>
PartialResult WARN_UNUSED_RETURN addOp(ExpressionType arg, ExpressionType& result);
@@ -525,6 +528,7 @@
return gFuncref();
case TypeKind::Ref:
case TypeKind::RefNull:
+ case TypeKind::Rtt:
return gRef(type);
case TypeKind::Externref:
return gExternref();
@@ -1059,6 +1063,7 @@
case TypeKind::Funcref:
case TypeKind::Ref:
case TypeKind::RefNull:
+ case TypeKind::Rtt:
append(Move, arg, m_locals[i]);
break;
case TypeKind::F32:
@@ -2994,6 +2999,14 @@
return { };
}
+auto AirIRGenerator::addRttCanon(uint32_t typeIndex, ExpressionType& result) -> PartialResult
+{
+ result = tmpForType(Types::I32);
+ emitCCall(&operationWasmRttCanon, result, instanceValue(), addConstant(Types::I32, typeIndex));
+
+ return { };
+}
+
auto AirIRGenerator::addSelect(ExpressionType condition, ExpressionType nonZero, ExpressionType zero, ExpressionType& result) -> PartialResult
{
ASSERT(nonZero.type() == zero.type());
Modified: trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp (293509 => 293510)
--- trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp 2022-04-27 15:49:37 UTC (rev 293509)
+++ trunk/Source/_javascript_Core/wasm/WasmB3IRGenerator.cpp 2022-04-27 15:49:39 UTC (rev 293510)
@@ -354,6 +354,9 @@
// Saturated truncation.
PartialResult WARN_UNUSED_RETURN truncSaturated(Ext1OpType, ExpressionType operand, ExpressionType& result, Type returnType, Type operandType);
+ // GC
+ PartialResult WARN_UNUSED_RETURN addRttCanon(uint32_t typeIndex, ExpressionType& result);
+
// Basic operators
template<OpType>
PartialResult WARN_UNUSED_RETURN addOp(ExpressionType arg, ExpressionType& result);
@@ -2251,6 +2254,15 @@
return { };
}
+auto B3IRGenerator::addRttCanon(uint32_t typeIndex, ExpressionType& result) -> PartialResult
+{
+ result = push(m_currentBlock->appendNew<CCallValue>(m_proc, toB3Type(Types::I32), origin(),
+ m_currentBlock->appendNew<ConstPtrValue>(m_proc, origin(), tagCFunction<OperationPtrTag>(operationWasmRttCanon)),
+ instanceValue(), m_currentBlock->appendNew<Const32Value>(m_proc, origin(), typeIndex)));
+
+ return { };
+}
+
auto B3IRGenerator::addSelect(ExpressionType condition, ExpressionType nonZero, ExpressionType zero, ExpressionType& result) -> PartialResult
{
result = push(m_currentBlock->appendNew<Value>(m_proc, B3::Select, origin(), get(condition), get(nonZero), get(zero)));
Modified: trunk/Source/_javascript_Core/wasm/WasmCallingConvention.h (293509 => 293510)
--- trunk/Source/_javascript_Core/wasm/WasmCallingConvention.h 2022-04-27 15:49:37 UTC (rev 293509)
+++ trunk/Source/_javascript_Core/wasm/WasmCallingConvention.h 2022-04-27 15:49:39 UTC (rev 293510)
@@ -109,6 +109,7 @@
case TypeKind::Externref:
case TypeKind::Ref:
case TypeKind::RefNull:
+ case TypeKind::Rtt:
return marshallLocationImpl(role, gprArgs, gpArgumentCount, stackOffset);
case TypeKind::F32:
case TypeKind::F64:
Modified: trunk/Source/_javascript_Core/wasm/WasmFormat.h (293509 => 293510)
--- trunk/Source/_javascript_Core/wasm/WasmFormat.h 2022-04-27 15:49:37 UTC (rev 293509)
+++ trunk/Source/_javascript_Core/wasm/WasmFormat.h 2022-04-27 15:49:39 UTC (rev 293510)
@@ -74,6 +74,8 @@
case TypeKind::Ref:
case TypeKind::RefNull:
return Options::useWebAssemblyTypedFunctionReferences();
+ case TypeKind::Rtt:
+ return Options::useWebAssemblyGC();
default:
break;
}
@@ -165,6 +167,7 @@
switch (kind) {
case TypeKind::Funcref:
case TypeKind::Externref:
+ case TypeKind::Rtt:
return true;
default:
break;
Modified: trunk/Source/_javascript_Core/wasm/WasmFunctionParser.h (293509 => 293510)
--- trunk/Source/_javascript_Core/wasm/WasmFunctionParser.h 2022-04-27 15:49:37 UTC (rev 293509)
+++ trunk/Source/_javascript_Core/wasm/WasmFunctionParser.h 2022-04-27 15:49:39 UTC (rev 293510)
@@ -1039,6 +1039,32 @@
return { };
}
+ case GCPrefix: {
+ WASM_PARSER_FAIL_IF(!Options::useWebAssemblyGC(), "Wasm GC is not enabled");
+
+ uint8_t extOp;
+ WASM_PARSER_FAIL_IF(!parseUInt8(extOp), "can't parse extended GC opcode");
+
+ switch (static_cast<GCOpType>(extOp)) {
+ case GCOpType::RttCanon: {
+ uint32_t typeIndex;
+ WASM_PARSER_FAIL_IF(!parseVarUInt32(typeIndex), "can't get type index for rtt.canon");
+ WASM_VALIDATOR_FAIL_IF(typeIndex >= m_info.typeCount(), "rtt.canon index ", typeIndex, " is out of bounds");
+
+ ExpressionType result;
+ WASM_TRY_ADD_TO_CONTEXT(addRttCanon(typeIndex, result));
+
+ m_expressionStack.constructAndAppend(Type { TypeKind::Rtt, Nullable::No, static_cast<TypeIndex>(typeIndex) }, result);
+ return { };
+ }
+
+ default:
+ WASM_PARSER_FAIL_IF(true, "invalid extended GC op ", extOp);
+ break;
+ }
+ return { };
+ }
+
case ExtAtomic: {
WASM_PARSER_FAIL_IF(!Options::useWebAssemblyThreading(), "wasm-threading is not enabled");
uint8_t extOp;
@@ -1928,6 +1954,26 @@
return { };
}
+ case GCPrefix: {
+ WASM_PARSER_FAIL_IF(!Options::useWebAssemblyGC(), "Wasm GC is not enabled");
+
+ uint8_t extOp;
+ WASM_PARSER_FAIL_IF(!parseUInt8(extOp), "can't parse extended GC opcode");
+
+ switch (static_cast<GCOpType>(extOp)) {
+ case GCOpType::RttCanon: {
+ uint32_t unused;
+ WASM_PARSER_FAIL_IF(!parseVarUInt32(unused), "can't get type index immediate for rtt.canon in unreachable context");
+ return { };
+ }
+ default:
+ WASM_PARSER_FAIL_IF(true, "invalid extended GC op ", extOp);
+ break;
+ }
+
+ return { };
+ }
+
case GrowMemory:
case CurrentMemory: {
uint8_t reserved;
Modified: trunk/Source/_javascript_Core/wasm/WasmLLIntGenerator.cpp (293509 => 293510)
--- trunk/Source/_javascript_Core/wasm/WasmLLIntGenerator.cpp 2022-04-27 15:49:37 UTC (rev 293509)
+++ trunk/Source/_javascript_Core/wasm/WasmLLIntGenerator.cpp 2022-04-27 15:49:39 UTC (rev 293510)
@@ -271,6 +271,9 @@
// Saturated truncation.
PartialResult WARN_UNUSED_RETURN truncSaturated(Ext1OpType, ExpressionType operand, ExpressionType& result, Type, Type);
+ // GC
+ PartialResult WARN_UNUSED_RETURN addRttCanon(uint32_t index, ExpressionType& result);
+
// Basic operators
template<OpType>
PartialResult WARN_UNUSED_RETURN addOp(ExpressionType arg, ExpressionType& result);
@@ -608,6 +611,7 @@
case TypeKind::Funcref:
case TypeKind::RefNull:
case TypeKind::Ref:
+ case TypeKind::Rtt:
if (gprIndex < gprCount)
++gprIndex;
else if (stackIndex++ >= stackCount)
@@ -666,6 +670,7 @@
case TypeKind::Funcref:
case TypeKind::RefNull:
case TypeKind::Ref:
+ case TypeKind::Rtt:
if (gprIndex > gprLimit)
arguments[i] = virtualRegisterForLocal(--gprIndex);
else
@@ -711,6 +716,7 @@
case TypeKind::Void:
case TypeKind::Func:
case TypeKind::Struct:
+ case TypeKind::Rtt:
RELEASE_ASSERT_NOT_REACHED();
}
}
@@ -769,6 +775,7 @@
case TypeKind::Void:
case TypeKind::Func:
case TypeKind::Struct:
+ case TypeKind::Rtt:
RELEASE_ASSERT_NOT_REACHED();
}
}
@@ -811,6 +818,7 @@
case TypeKind::Funcref:
case TypeKind::RefNull:
case TypeKind::Ref:
+ case TypeKind::Rtt:
addArgument(i, gprIndex, maxGPRIndex);
break;
case TypeKind::F32:
@@ -1825,6 +1833,14 @@
return { };
}
+auto LLIntGenerator::addRttCanon(uint32_t index, ExpressionType& result) -> PartialResult
+{
+ result = push();
+ WasmRttCanon::emit(this, result, index);
+
+ return { };
+}
+
void LLIntGenerator::linkSwitchTargets(Label& label, unsigned location)
{
auto it = m_switches.find(&label);
Modified: trunk/Source/_javascript_Core/wasm/WasmOperations.cpp (293509 => 293510)
--- trunk/Source/_javascript_Core/wasm/WasmOperations.cpp 2022-04-27 15:49:37 UTC (rev 293509)
+++ trunk/Source/_javascript_Core/wasm/WasmOperations.cpp 2022-04-27 15:49:39 UTC (rev 293510)
@@ -821,6 +821,12 @@
return JSValue::encode(value);
}
+JSC_DEFINE_JIT_OPERATION(operationWasmRttCanon, EncodedJSValue, (Instance*, uint32_t))
+{
+ // FIXME: We don't need real RTT values right now, so let's use jsNull.
+ return JSValue::encode(jsNull());
+}
+
JSC_DEFINE_JIT_OPERATION(operationGetWasmTableSize, int32_t, (Instance* instance, unsigned tableIndex))
{
return instance->table(tableIndex)->length();
Modified: trunk/Source/_javascript_Core/wasm/WasmOperations.h (293509 => 293510)
--- trunk/Source/_javascript_Core/wasm/WasmOperations.h 2022-04-27 15:49:37 UTC (rev 293509)
+++ trunk/Source/_javascript_Core/wasm/WasmOperations.h 2022-04-27 15:49:39 UTC (rev 293510)
@@ -88,6 +88,8 @@
JSC_DECLARE_JIT_OPERATION(operationWasmMemoryInit, size_t, (Instance*, unsigned dataSegmentIndex, uint32_t dstAddress, uint32_t srcAddress, uint32_t length));
JSC_DECLARE_JIT_OPERATION(operationWasmDataDrop, void, (Instance*, unsigned dataSegmentIndex));
+JSC_DECLARE_JIT_OPERATION(operationWasmRttCanon, EncodedJSValue, (Instance*, uint32_t));
+
JSC_DECLARE_JIT_OPERATION(operationWasmThrow, void*, (Instance*, CallFrame*, unsigned exceptionIndex, uint64_t*));
JSC_DECLARE_JIT_OPERATION(operationWasmRethrow, void*, (Instance*, CallFrame*, EncodedJSValue thrownValue));
Modified: trunk/Source/_javascript_Core/wasm/WasmParser.h (293509 => 293510)
--- trunk/Source/_javascript_Core/wasm/WasmParser.h 2022-04-27 15:49:37 UTC (rev 293509)
+++ trunk/Source/_javascript_Core/wasm/WasmParser.h 2022-04-27 15:49:39 UTC (rev 293510)
@@ -340,6 +340,14 @@
if (!parseHeapType(info, heapType))
return false;
typeIndex = heapType < 0 ? static_cast<TypeIndex>(heapType) : TypeInformation::get(info.typeSignatures[heapType].get());
+ } else if (Options::useWebAssemblyGC() && typeKind == TypeKind::Rtt) {
+ typeKind = TypeKind::Rtt;
+ isNullable = false;
+
+ int32_t heapType;
+ if (!parseHeapType(info, heapType))
+ return false;
+ typeIndex = static_cast<TypeIndex>(heapType);
}
Type type = { typeKind, static_cast<Nullable>(isNullable), typeIndex };
Modified: trunk/Source/_javascript_Core/wasm/WasmSlowPaths.cpp (293509 => 293510)
--- trunk/Source/_javascript_Core/wasm/WasmSlowPaths.cpp 2022-04-27 15:49:37 UTC (rev 293509)
+++ trunk/Source/_javascript_Core/wasm/WasmSlowPaths.cpp 2022-04-27 15:49:39 UTC (rev 293510)
@@ -322,6 +322,12 @@
WASM_RETURN(Wasm::operationWasmRefFunc(instance, instruction.m_functionIndex));
}
+WASM_SLOW_PATH_DECL(rtt_canon)
+{
+ auto instruction = pc->as<WasmRttCanon>();
+ WASM_RETURN(Wasm::operationWasmRttCanon(instance, instruction.m_typeIndex));
+}
+
WASM_SLOW_PATH_DECL(table_get)
{
auto instruction = pc->as<WasmTableGet>();
Modified: trunk/Source/_javascript_Core/wasm/WasmSlowPaths.h (293509 => 293510)
--- trunk/Source/_javascript_Core/wasm/WasmSlowPaths.h 2022-04-27 15:49:37 UTC (rev 293509)
+++ trunk/Source/_javascript_Core/wasm/WasmSlowPaths.h 2022-04-27 15:49:39 UTC (rev 293510)
@@ -89,6 +89,7 @@
WASM_SLOW_PATH_HIDDEN_DECL(throw);
WASM_SLOW_PATH_HIDDEN_DECL(rethrow);
WASM_SLOW_PATH_HIDDEN_DECL(retrieve_and_clear_exception);
+WASM_SLOW_PATH_HIDDEN_DECL(rtt_canon);
extern "C" SlowPathReturnType slow_path_wasm_throw_exception(CallFrame*, const WasmInstruction*, Wasm::Instance* instance, Wasm::ExceptionType) REFERENCED_FROM_ASM WTF_INTERNAL;
extern "C" SlowPathReturnType slow_path_wasm_popcount(const WasmInstruction* pc, uint32_t) REFERENCED_FROM_ASM WTF_INTERNAL;
Modified: trunk/Source/_javascript_Core/wasm/generateWasmOpsHeader.py (293509 => 293510)
--- trunk/Source/_javascript_Core/wasm/generateWasmOpsHeader.py 2022-04-27 15:49:37 UTC (rev 293509)
+++ trunk/Source/_javascript_Core/wasm/generateWasmOpsHeader.py 2022-04-27 15:49:39 UTC (rev 293510)
@@ -126,7 +126,7 @@
defines = ["#define FOR_EACH_WASM_SPECIAL_OP(macro)"]
-defines.extend([op for op in opcodeMacroizer(lambda op: not (isUnary(op) or isBinary(op) or op["category"] == "control" or op["category"] == "memory" or op["value"] == 0xfc or isAtomic(op)))])
+defines.extend([op for op in opcodeMacroizer(lambda op: not (isUnary(op) or isBinary(op) or op["category"] == "control" or op["category"] == "memory" or op["value"] == 0xfc or op["category"] == "gc" or isAtomic(op)))])
defines.append("\n\n#define FOR_EACH_WASM_CONTROL_FLOW_OP(macro)")
defines.extend([op for op in opcodeMacroizer(lambda op: op["category"] == "control")])
defines.append("\n\n#define FOR_EACH_WASM_SIMPLE_UNARY_OP(macro)")
@@ -153,6 +153,8 @@
defines.extend([op for op in atomicBinaryRMWMacroizer()])
defines.append("\n\n#define FOR_EACH_WASM_EXT_ATOMIC_OTHER_OP(macro)")
defines.extend([op for op in opcodeMacroizer(lambda op: isAtomic(op) and (not isAtomicLoad(op) and not isAtomicStore(op) and not isAtomicBinaryRMW(op)), opcodeField="extendedOp")])
+defines.append("\n\n#define FOR_EACH_WASM_GC_OP(macro)")
+defines.extend([op for op in opcodeMacroizer(lambda op: (op["category"] == "gc"), opcodeField="extendedOp")])
defines.append("\n\n")
defines = "".join(defines)
@@ -334,6 +336,7 @@
FOR_EACH_WASM_MEMORY_LOAD_OP(macro) \\
FOR_EACH_WASM_MEMORY_STORE_OP(macro) \\
macro(Ext1, 0xFC, Oops, 0) \\
+ macro(GCPrefix, 0xFB, Oops, 0) \\
macro(ExtAtomic, 0xFE, Oops, 0)
#define CREATE_ENUM_VALUE(name, id, ...) name = id,
@@ -371,6 +374,10 @@
FOR_EACH_WASM_TRUNC_SATURATED_OP(CREATE_ENUM_VALUE)
};
+enum class GCOpType : uint8_t {
+ FOR_EACH_WASM_GC_OP(CREATE_ENUM_VALUE)
+};
+
enum class ExtAtomicOpType : uint8_t {
FOR_EACH_WASM_EXT_ATOMIC_LOAD_OP(CREATE_ENUM_VALUE)
FOR_EACH_WASM_EXT_ATOMIC_STORE_OP(CREATE_ENUM_VALUE)
Modified: trunk/Source/_javascript_Core/wasm/js/WasmToJS.cpp (293509 => 293510)
--- trunk/Source/_javascript_Core/wasm/js/WasmToJS.cpp 2022-04-27 15:49:37 UTC (rev 293509)
+++ trunk/Source/_javascript_Core/wasm/js/WasmToJS.cpp 2022-04-27 15:49:39 UTC (rev 293510)
@@ -108,6 +108,7 @@
case TypeKind::Struct:
case TypeKind::RefNull:
case TypeKind::Ref:
+ case TypeKind::Rtt:
RELEASE_ASSERT_NOT_REACHED(); // Handled above.
case TypeKind::Externref:
case TypeKind::Funcref:
@@ -183,6 +184,7 @@
case TypeKind::Struct:
case TypeKind::RefNull:
case TypeKind::Ref:
+ case TypeKind::Rtt:
RELEASE_ASSERT_NOT_REACHED(); // Handled above.
case TypeKind::Externref:
case TypeKind::Funcref:
Modified: trunk/Source/_javascript_Core/wasm/wasm.json (293509 => 293510)
--- trunk/Source/_javascript_Core/wasm/wasm.json 2022-04-27 15:49:37 UTC (rev 293509)
+++ trunk/Source/_javascript_Core/wasm/wasm.json 2022-04-27 15:49:39 UTC (rev 293510)
@@ -17,6 +17,7 @@
"ref": { "type": "varint7", "value": -21, "b3type": "B3::Int64" },
"func": { "type": "varint7", "value": -32, "b3type": "B3::Void" },
"struct": { "type": "varint7", "value": -33, "b3type": "B3::Void" },
+ "rtt": { "type": "varint7", "value": -24, "b3type": "B3::Void" },
"void": { "type": "varint7", "value": -64, "b3type": "B3::Void" }
},
"value_type": ["i32", "i64", "f32", "f64", "externref", "funcref"],
@@ -77,6 +78,7 @@
"ref.null": { "category": "special", "value": 208, "return": ["externref", "funcref"], "parameter": [], "immediate": [{"name": "reftype", "type": "ref_type"}], "description": "a constant null reference" },
"ref.is_null": { "category": "special", "value": 209, "return": ["i32"], "parameter": ["externref"], "immediate": [], "description": "determine if a reference is null" },
"ref.func": { "category": "special", "value": 210, "return": ["funcref"], "parameter": [], "immediate": [{"name": "function_index", "type": "varuint32"}], "description": "return a reference to the function at the given index" },
+ "rtt.canon": { "category": "gc", "value": 251, "return": ["rtt"], "parameter": [], "immediate": [{"name": "type_index", "type": "varuint32"}], "description": "returns the RTT of the specified type", "extendedOp": 48 },
"get_local": { "category": "special", "value": 32, "return": ["any"], "parameter": [], "immediate": [{"name": "local_index", "type": "varuint32"}], "description": "read a local variable or parameter" },
"set_local": { "category": "special", "value": 33, "return": [], "parameter": ["any"], "immediate": [{"name": "local_index", "type": "varuint32"}], "description": "write a local variable or parameter" },
"tee_local": { "category": "special", "value": 34, "return": ["any"], "parameter": ["any"], "immediate": [{"name": "local_index", "type": "varuint32"}], "description": "write a local variable or parameter and return the same value" },