[wasm-gc] Update ref.cast_nop to behave like ref.cast
This updates the (experimental, unsafe, non-standard) ref.cast_nop to take the same immediate as the new ref.cast. This is being done in order to align with Binaryen, per discussion in https://github.com/WebAssembly/binaryen/pull/5473. Bug: v8:7748 Change-Id: Ifcd2bab95a1601406370939301a5c6dfd854347c Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4224632 Commit-Queue: Jakob Kummerow <jkummerow@chromium.org> Auto-Submit: Jakob Kummerow <jkummerow@chromium.org> Reviewed-by: Matthias Liedtke <mliedtke@chromium.org> Cr-Commit-Position: refs/heads/main@{#85685}
This commit is contained in:
parent
e0d7681e31
commit
5472313c96
@ -5128,27 +5128,29 @@ class WasmFullDecoder : public WasmDecoder<ValidationTag, decoding_mode> {
|
|||||||
// Temporary non-standard instruction, for performance experiments.
|
// Temporary non-standard instruction, for performance experiments.
|
||||||
if (!VALIDATE(this->enabled_.has_ref_cast_nop())) {
|
if (!VALIDATE(this->enabled_.has_ref_cast_nop())) {
|
||||||
this->DecodeError(
|
this->DecodeError(
|
||||||
"Invalid opcode 0xfb48 (enable with "
|
"Invalid opcode 0xfb4c (enable with "
|
||||||
"--experimental-wasm-ref-cast-nop)");
|
"--experimental-wasm-ref-cast-nop)");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
IndexImmediate imm(this, this->pc_ + opcode_length, "type index",
|
HeapTypeImmediate imm(this->enabled_, this, this->pc_ + opcode_length,
|
||||||
validate);
|
validate);
|
||||||
if (!this->ValidateType(this->pc_ + opcode_length, imm)) return 0;
|
if (!this->Validate(this->pc_ + opcode_length, imm)) return 0;
|
||||||
opcode_length += imm.length;
|
opcode_length += imm.length;
|
||||||
|
HeapType target_type = imm.type;
|
||||||
Value obj = Peek(0);
|
Value obj = Peek(0);
|
||||||
if (!VALIDATE(IsSubtypeOf(obj.type, kWasmFuncRef, this->module_) ||
|
if (!VALIDATE((obj.type.is_object_reference() &&
|
||||||
IsSubtypeOf(obj.type, kWasmStructRef, this->module_) ||
|
IsSameTypeHierarchy(obj.type.heap_type(), target_type,
|
||||||
IsSubtypeOf(obj.type, kWasmArrayRef, this->module_) ||
|
this->module_)) ||
|
||||||
obj.type.is_bottom())) {
|
obj.type.is_bottom())) {
|
||||||
PopTypeError(0, obj,
|
this->DecodeError(
|
||||||
"subtype of (ref null func), (ref null struct) or (ref "
|
obj.pc(),
|
||||||
"null array)");
|
"Invalid types for %s: %s of type %s has to "
|
||||||
|
"be in the same reference type hierarchy as (ref %s)",
|
||||||
|
WasmOpcodes::OpcodeName(opcode), SafeOpcodeNameAt(obj.pc()),
|
||||||
|
obj.type.name().c_str(), target_type.name().c_str());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Value value = CreateValue(ValueType::RefMaybeNull(
|
Value value = CreateValue(ValueType::Ref(target_type));
|
||||||
imm.index,
|
|
||||||
obj.type.is_bottom() ? kNonNullable : obj.type.nullability()));
|
|
||||||
CALL_INTERFACE_IF_OK_AND_REACHABLE(Forward, obj, &value);
|
CALL_INTERFACE_IF_OK_AND_REACHABLE(Forward, obj, &value);
|
||||||
Drop(obj);
|
Drop(obj);
|
||||||
Push(value);
|
Push(value);
|
||||||
|
Loading…
Reference in New Issue
Block a user