diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/binaryen-c.cpp | 6 | ||||
-rw-r--r-- | src/binaryen-c.h | 2 | ||||
-rw-r--r-- | src/gen-s-parser.inc | 16 | ||||
-rw-r--r-- | src/ir/child-typer.h | 4 | ||||
-rw-r--r-- | src/ir/effects.h | 2 | ||||
-rw-r--r-- | src/ir/possible-contents.cpp | 2 | ||||
-rw-r--r-- | src/ir/properties.cpp | 2 | ||||
-rw-r--r-- | src/ir/properties.h | 8 | ||||
-rw-r--r-- | src/js/binaryen.js-post.js | 6 | ||||
-rw-r--r-- | src/passes/OptimizeCasts.cpp | 2 | ||||
-rw-r--r-- | src/passes/OptimizeInstructions.cpp | 2 | ||||
-rw-r--r-- | src/passes/Print.cpp | 8 | ||||
-rw-r--r-- | src/passes/TypeGeneralizing.cpp | 4 | ||||
-rw-r--r-- | src/tools/wasm-ctor-eval.cpp | 2 | ||||
-rw-r--r-- | src/wasm-binary.h | 4 | ||||
-rw-r--r-- | src/wasm-builder.h | 2 | ||||
-rw-r--r-- | src/wasm-interpreter.h | 6 | ||||
-rw-r--r-- | src/wasm.h | 4 | ||||
-rw-r--r-- | src/wasm/wasm-binary.cpp | 12 | ||||
-rw-r--r-- | src/wasm/wasm-stack.cpp | 8 | ||||
-rw-r--r-- | src/wasm/wasm-validator.cpp | 12 | ||||
-rw-r--r-- | src/wasm/wasm.cpp | 4 |
22 files changed, 68 insertions, 50 deletions
diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp index 841fa61ee..9c9a1c54f 100644 --- a/src/binaryen-c.cpp +++ b/src/binaryen-c.cpp @@ -1012,8 +1012,10 @@ BinaryenOp BinaryenDotI8x16I7x16SToVecI16x8(void) { return DotI8x16I7x16SToVecI16x8; } BinaryenOp BinaryenRefAsNonNull(void) { return RefAsNonNull; } -BinaryenOp BinaryenRefAsExternInternalize(void) { return ExternInternalize; } -BinaryenOp BinaryenRefAsExternExternalize(void) { return ExternExternalize; } +BinaryenOp BinaryenRefAsExternInternalize(void) { return AnyConvertExtern; } +BinaryenOp BinaryenRefAsExternExternalize(void) { return ExternConvertAny; } +BinaryenOp BinaryenRefAsAnyConvertExtern(void) { return AnyConvertExtern; } +BinaryenOp BinaryenRefAsExternConvertAny(void) { return ExternConvertAny; } BinaryenOp BinaryenBrOnNull(void) { return BrOnNull; } BinaryenOp BinaryenBrOnNonNull(void) { return BrOnNonNull; } BinaryenOp BinaryenBrOnCast(void) { return BrOnCast; } diff --git a/src/binaryen-c.h b/src/binaryen-c.h index 3f2cab20c..45230a117 100644 --- a/src/binaryen-c.h +++ b/src/binaryen-c.h @@ -678,6 +678,8 @@ BINARYEN_API BinaryenOp BinaryenDotI8x16I7x16SToVecI16x8(void); BINARYEN_API BinaryenOp BinaryenRefAsNonNull(void); BINARYEN_API BinaryenOp BinaryenRefAsExternInternalize(void); BINARYEN_API BinaryenOp BinaryenRefAsExternExternalize(void); +BINARYEN_API BinaryenOp BinaryenRefAsAnyConvertExtern(void); +BINARYEN_API BinaryenOp BinaryenRefAsExternConvertAny(void); BINARYEN_API BinaryenOp BinaryenBrOnNull(void); BINARYEN_API BinaryenOp BinaryenBrOnNonNull(void); BINARYEN_API BinaryenOp BinaryenBrOnCast(void); diff --git a/src/gen-s-parser.inc b/src/gen-s-parser.inc index 03b346113..8a3dcba0b 100644 --- a/src/gen-s-parser.inc +++ b/src/gen-s-parser.inc @@ -14,6 +14,12 @@ memcpy(buf, op.data(), op.size()); switch (buf[0]) { case 'a': { switch (buf[1]) { + case 'n': + if (op == "any.convert_extern"sv) { + CHECK_ERR(makeRefAs(ctx, pos, annotations, AnyConvertExtern)); + return Ok{}; + } + goto parse_error; case 'r': { switch (buf[6]) { case 'c': @@ -278,15 +284,21 @@ switch (buf[0]) { } case 'e': { switch (buf[7]) { + case 'c': + if (op == "extern.convert_any"sv) { + CHECK_ERR(makeRefAs(ctx, pos, annotations, ExternConvertAny)); + return Ok{}; + } + goto parse_error; case 'e': if (op == "extern.externalize"sv) { - CHECK_ERR(makeRefAs(ctx, pos, annotations, ExternExternalize)); + CHECK_ERR(makeRefAs(ctx, pos, annotations, ExternConvertAny)); return Ok{}; } goto parse_error; case 'i': if (op == "extern.internalize"sv) { - CHECK_ERR(makeRefAs(ctx, pos, annotations, ExternInternalize)); + CHECK_ERR(makeRefAs(ctx, pos, annotations, AnyConvertExtern)); return Ok{}; } goto parse_error; diff --git a/src/ir/child-typer.h b/src/ir/child-typer.h index 7c09dddb0..5e2dc237d 100644 --- a/src/ir/child-typer.h +++ b/src/ir/child-typer.h @@ -949,10 +949,10 @@ template<typename Subtype> struct ChildTyper : OverriddenVisitor<Subtype> { case RefAsNonNull: noteAnyReference(&curr->value); return; - case ExternInternalize: + case AnyConvertExtern: note(&curr->value, Type(HeapType::ext, Nullable)); return; - case ExternExternalize: + case ExternConvertAny: note(&curr->value, Type(HeapType::any, Nullable)); return; } diff --git a/src/ir/effects.h b/src/ir/effects.h index 46138d03c..be949a8bf 100644 --- a/src/ir/effects.h +++ b/src/ir/effects.h @@ -926,7 +926,7 @@ private: void visitArrayInitData(ArrayInitData* curr) { visitArrayInit(curr); } void visitArrayInitElem(ArrayInitElem* curr) { visitArrayInit(curr); } void visitRefAs(RefAs* curr) { - if (curr->op == ExternInternalize || curr->op == ExternExternalize) { + if (curr->op == AnyConvertExtern || curr->op == ExternConvertAny) { // These conversions are infallible. return; } diff --git a/src/ir/possible-contents.cpp b/src/ir/possible-contents.cpp index ac320c419..38fa3e5f6 100644 --- a/src/ir/possible-contents.cpp +++ b/src/ir/possible-contents.cpp @@ -697,7 +697,7 @@ struct InfoCollector receiveChildValue(curr->ref, curr); } void visitRefAs(RefAs* curr) { - if (curr->op == ExternExternalize || curr->op == ExternInternalize) { + if (curr->op == ExternConvertAny || curr->op == AnyConvertExtern) { // The external conversion ops emit something of a completely different // type, which we must mark as a root. addRoot(curr); diff --git a/src/ir/properties.cpp b/src/ir/properties.cpp index dd9a10a8e..d04771885 100644 --- a/src/ir/properties.cpp +++ b/src/ir/properties.cpp @@ -65,7 +65,7 @@ static bool isValidInConstantExpression(Module& wasm, Expression* expr) { } if (auto* refAs = expr->dynCast<RefAs>()) { - if (refAs->op == ExternExternalize || refAs->op == ExternInternalize) { + if (refAs->op == ExternConvertAny || refAs->op == AnyConvertExtern) { return true; } } diff --git a/src/ir/properties.h b/src/ir/properties.h index 4b73b7211..ccb2392b0 100644 --- a/src/ir/properties.h +++ b/src/ir/properties.h @@ -83,7 +83,7 @@ inline bool isNamedControlFlow(Expression* curr) { // isValidInConstantExpression or find better names(#4845) inline bool isSingleConstantExpression(const Expression* curr) { if (auto* refAs = curr->dynCast<RefAs>()) { - if (refAs->op == ExternExternalize || refAs->op == ExternInternalize) { + if (refAs->op == ExternConvertAny || refAs->op == AnyConvertExtern) { return isSingleConstantExpression(refAs->value); } } @@ -124,9 +124,9 @@ inline Literal getLiteral(const Expression* curr) { } else if (auto* s = curr->dynCast<StringConst>()) { return Literal(s->string.toString()); } else if (auto* r = curr->dynCast<RefAs>()) { - if (r->op == ExternExternalize) { + if (r->op == ExternConvertAny) { return getLiteral(r->value).externalize(); - } else if (r->op == ExternInternalize) { + } else if (r->op == AnyConvertExtern) { return getLiteral(r->value).internalize(); } } @@ -329,7 +329,7 @@ inline Expression** getImmediateFallthroughPtr( // Extern conversions are not casts and actually produce new values. // Treating them as fallthroughs would lead to misoptimizations of // subsequent casts. - if (as->op != ExternInternalize && as->op != ExternExternalize) { + if (as->op != AnyConvertExtern && as->op != ExternConvertAny) { return &as->value; } } else if (auto* br = curr->dynCast<BrOn>()) { diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js index 8d7bd6d7f..097c28bc7 100644 --- a/src/js/binaryen.js-post.js +++ b/src/js/binaryen.js-post.js @@ -564,6 +564,8 @@ function initializeConstants() { 'RefAsNonNull', 'RefAsExternInternalize', 'RefAsExternExternalize', + 'RefAsAnyConvertExtern', + 'RefAsExternConvertAny', 'BrOnNull', 'BrOnNonNull', 'BrOnCast', @@ -2380,8 +2382,8 @@ function wrapModule(module, self = {}) { } }; - // TODO: extern.internalize - // TODO: extern.externalize + // TODO: any.convert_extern + // TODO: extern.convert_any // TODO: ref.test // TODO: ref.cast // TODO: br_on_* diff --git a/src/passes/OptimizeCasts.cpp b/src/passes/OptimizeCasts.cpp index 5edde4d2f..efa00948b 100644 --- a/src/passes/OptimizeCasts.cpp +++ b/src/passes/OptimizeCasts.cpp @@ -90,7 +90,7 @@ // ) // // Note that right now, we only consider RefAs with op RefAsNonNull as a cast. -// RefAs with ExternInternalize and ExternExternalize are not considered casts +// RefAs with AnyConvertExtern and ExternConvertAny are not considered casts // when obtaining fallthroughs, and so are ignored. // // TODO: Look past individual basic blocks? This may be worth considering diff --git a/src/passes/OptimizeInstructions.cpp b/src/passes/OptimizeInstructions.cpp index 10c1aac9e..c470fa060 100644 --- a/src/passes/OptimizeInstructions.cpp +++ b/src/passes/OptimizeInstructions.cpp @@ -2440,7 +2440,7 @@ struct OptimizeInstructions return; } - if (curr->op == ExternExternalize || curr->op == ExternInternalize) { + if (curr->op == ExternConvertAny || curr->op == AnyConvertExtern) { // We can't optimize these. Even removing a non-null cast is not valid as // they allow nulls to filter through, unlike other RefAs*. return; diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp index 4ca5f722b..1d07b7f3c 100644 --- a/src/passes/Print.cpp +++ b/src/passes/Print.cpp @@ -2236,11 +2236,11 @@ struct PrintExpressionContents case RefAsNonNull: printMedium(o, "ref.as_non_null"); break; - case ExternInternalize: - printMedium(o, "extern.internalize"); + case AnyConvertExtern: + printMedium(o, "any.convert_extern"); break; - case ExternExternalize: - printMedium(o, "extern.externalize"); + case ExternConvertAny: + printMedium(o, "extern.convert_any"); break; default: WASM_UNREACHABLE("invalid ref.is_*"); diff --git a/src/passes/TypeGeneralizing.cpp b/src/passes/TypeGeneralizing.cpp index 720830400..faf01f173 100644 --- a/src/passes/TypeGeneralizing.cpp +++ b/src/passes/TypeGeneralizing.cpp @@ -850,10 +850,10 @@ struct TransferFn : OverriddenVisitor<TransferFn> { case RefAsNonNull: push(Type(type.getHeapType(), Nullable)); return; - case ExternInternalize: + case AnyConvertExtern: push(Type(HeapType::ext, type.getNullability())); return; - case ExternExternalize: + case ExternConvertAny: push(Type(HeapType::any, type.getNullability())); return; } diff --git a/src/tools/wasm-ctor-eval.cpp b/src/tools/wasm-ctor-eval.cpp index c025764e7..df4e7a9bf 100644 --- a/src/tools/wasm-ctor-eval.cpp +++ b/src/tools/wasm-ctor-eval.cpp @@ -916,7 +916,7 @@ public: if (original != value) { // The original is externalized. assert(original.type.getHeapType() == HeapType::ext); - ret = builder.makeRefAs(ExternExternalize, ret); + ret = builder.makeRefAs(ExternConvertAny, ret); } return ret; } diff --git a/src/wasm-binary.h b/src/wasm-binary.h index 9ce9bf181..0b9615c7e 100644 --- a/src/wasm-binary.h +++ b/src/wasm-binary.h @@ -1120,8 +1120,8 @@ enum ASTNodes { RefCastNull = 0x17, BrOnCast = 0x18, BrOnCastFail = 0x19, - ExternInternalize = 0x1a, - ExternExternalize = 0x1b, + AnyConvertExtern = 0x1a, + ExternConvertAny = 0x1b, RefI31 = 0x1c, I31GetS = 0x1d, I31GetU = 0x1e, diff --git a/src/wasm-builder.h b/src/wasm-builder.h index f37e45240..a20ba46a6 100644 --- a/src/wasm-builder.h +++ b/src/wasm-builder.h @@ -1233,7 +1233,7 @@ public: return makeStringConst(wtf16.str()); } if (type.isRef() && type.getHeapType() == HeapType::ext) { - return makeRefAs(ExternExternalize, + return makeRefAs(ExternConvertAny, makeConstantExpression(value.internalize())); } TODO_SINGLE_COMPOUND(type); diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index c12f9cc33..93739d1c9 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -1858,9 +1858,9 @@ public: trap("null ref"); } return value; - case ExternInternalize: + case AnyConvertExtern: return value.internalize(); - case ExternExternalize: + case ExternConvertAny: return value.externalize(); } WASM_UNREACHABLE("unimplemented ref.as_*"); @@ -2436,7 +2436,7 @@ public: } Flow visitRefAs(RefAs* curr) { // TODO: Remove this once interpretation is implemented. - if (curr->op == ExternInternalize || curr->op == ExternExternalize) { + if (curr->op == AnyConvertExtern || curr->op == ExternConvertAny) { return Flow(NONCONSTANT_FLOW); } return ExpressionRunner<SubType>::visitRefAs(curr); diff --git a/src/wasm.h b/src/wasm.h index ebb5a04f6..4a4ed561f 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -561,8 +561,8 @@ enum SIMDTernaryOp { enum RefAsOp { RefAsNonNull, - ExternInternalize, - ExternExternalize, + AnyConvertExtern, + ExternConvertAny, }; enum BrOnOp { diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp index c4aaec5e9..78470324c 100644 --- a/src/wasm/wasm-binary.cpp +++ b/src/wasm/wasm-binary.cpp @@ -4329,8 +4329,8 @@ BinaryConsts::ASTNodes WasmBinaryReader::readExpression(Expression*& curr) { if (maybeVisitStringSliceWTF(curr, opcode)) { break; } - if (opcode == BinaryConsts::ExternInternalize || - opcode == BinaryConsts::ExternExternalize) { + if (opcode == BinaryConsts::AnyConvertExtern || + opcode == BinaryConsts::ExternConvertAny) { visitRefAs((curr = allocator.alloc<RefAs>())->cast<RefAs>(), opcode); break; } @@ -7730,11 +7730,11 @@ void WasmBinaryReader::visitRefAs(RefAs* curr, uint8_t code) { case BinaryConsts::RefAsNonNull: curr->op = RefAsNonNull; break; - case BinaryConsts::ExternInternalize: - curr->op = ExternInternalize; + case BinaryConsts::AnyConvertExtern: + curr->op = AnyConvertExtern; break; - case BinaryConsts::ExternExternalize: - curr->op = ExternExternalize; + case BinaryConsts::ExternConvertAny: + curr->op = ExternConvertAny; break; default: WASM_UNREACHABLE("invalid code for ref.as_*"); diff --git a/src/wasm/wasm-stack.cpp b/src/wasm/wasm-stack.cpp index ac117e2e0..40a50706a 100644 --- a/src/wasm/wasm-stack.cpp +++ b/src/wasm/wasm-stack.cpp @@ -2334,13 +2334,13 @@ void BinaryInstWriter::visitRefAs(RefAs* curr) { case RefAsNonNull: o << int8_t(BinaryConsts::RefAsNonNull); break; - case ExternInternalize: + case AnyConvertExtern: o << int8_t(BinaryConsts::GCPrefix) - << U32LEB(BinaryConsts::ExternInternalize); + << U32LEB(BinaryConsts::AnyConvertExtern); break; - case ExternExternalize: + case ExternConvertAny: o << int8_t(BinaryConsts::GCPrefix) - << U32LEB(BinaryConsts::ExternExternalize); + << U32LEB(BinaryConsts::ExternConvertAny); break; default: WASM_UNREACHABLE("invalid ref.as_*"); diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp index a491fb951..9732f54a9 100644 --- a/src/wasm/wasm-validator.cpp +++ b/src/wasm/wasm-validator.cpp @@ -2215,30 +2215,30 @@ void FunctionValidator::visitRefAs(RefAs* curr) { default: // TODO: validate all the other ref.as_* break; - case ExternInternalize: { + case AnyConvertExtern: { shouldBeTrue(getModule()->features.hasGC(), curr, - "extern.internalize requries GC [--enable-gc]"); + "any.convert_extern requries GC [--enable-gc]"); if (curr->type == Type::unreachable) { return; } shouldBeSubType(curr->value->type, Type(HeapType::ext, Nullable), curr->value, - "extern.internalize value should be an externref"); + "any.convert_extern value should be an externref"); break; } - case ExternExternalize: { + case ExternConvertAny: { shouldBeTrue(getModule()->features.hasGC(), curr, - "extern.externalize requries GC [--enable-gc]"); + "extern.convert_any requries GC [--enable-gc]"); if (curr->type == Type::unreachable) { return; } shouldBeSubType(curr->value->type, Type(HeapType::any, Nullable), curr->value, - "extern.externalize value should be an anyref"); + "extern.convert_any value should be an anyref"); break; } } diff --git a/src/wasm/wasm.cpp b/src/wasm/wasm.cpp index ed05e9b47..58699ad8b 100644 --- a/src/wasm/wasm.cpp +++ b/src/wasm/wasm.cpp @@ -1231,10 +1231,10 @@ void RefAs::finalize() { case RefAsNonNull: type = Type(value->type.getHeapType(), NonNullable); break; - case ExternInternalize: + case AnyConvertExtern: type = Type(HeapType::any, value->type.getNullability()); break; - case ExternExternalize: + case ExternConvertAny: type = Type(HeapType::ext, value->type.getNullability()); break; default: |