[wasm-gc] Rename array opcodes
Rename: - array.init(_static) -> array.new_fixed(_static) - array.init_from_data(_static) -> array.new_data(_static) - array.init_from_elem_static -> array.new_elem_static - (Wasm)ArrayInitFromSegment -> (Wasm)ArrayNewSegment Bug: v8:7748 Change-Id: I5ea314d653dd0e9f7f1f556469794d880934e01b Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3726207 Reviewed-by: Jakob Kummerow <jkummerow@chromium.org> Commit-Queue: Manos Koukoutos <manoskouk@chromium.org> Cr-Commit-Position: refs/heads/main@{#81393}
This commit is contained in:
parent
5c0a114a4f
commit
114a03ac82
@ -36,7 +36,7 @@ extern runtime WasmI64AtomicWait(
|
||||
Context, WasmInstanceObject, Number, BigInt, BigInt): Smi;
|
||||
extern runtime WasmArrayCopy(
|
||||
Context, WasmArray, Smi, WasmArray, Smi, Smi): JSAny;
|
||||
extern runtime WasmArrayInitFromSegment(
|
||||
extern runtime WasmArrayNewSegment(
|
||||
Context, WasmInstanceObject, Smi, Smi, Smi, Map): Object;
|
||||
extern runtime WasmStringNewWtf8(
|
||||
Context, WasmInstanceObject, Smi, Smi, Number, Number): String;
|
||||
@ -370,14 +370,14 @@ builtin WasmAllocateArray_Uninitialized(
|
||||
return %RawDownCast<WasmArray>(result);
|
||||
}
|
||||
|
||||
builtin WasmArrayInitFromSegment(
|
||||
builtin WasmArrayNewSegment(
|
||||
dataSegment: uint32, offset: uint32, length: uint32, rtt: Map): Object {
|
||||
const instance = LoadInstanceFromFrame();
|
||||
try {
|
||||
const smiOffset =
|
||||
Convert<PositiveSmi>(offset) otherwise ElementSegmentOutOfBounds;
|
||||
const smiLength = Convert<PositiveSmi>(length) otherwise ArrayTooLarge;
|
||||
tail runtime::WasmArrayInitFromSegment(
|
||||
tail runtime::WasmArrayNewSegment(
|
||||
LoadContextFromInstance(instance), instance, SmiFromUint32(dataSegment),
|
||||
smiOffset, smiLength, rtt);
|
||||
} label ElementSegmentOutOfBounds {
|
||||
|
@ -5316,8 +5316,8 @@ Node* WasmGraphBuilder::ArrayNewWithRtt(uint32_t array_index,
|
||||
return a;
|
||||
}
|
||||
|
||||
Node* WasmGraphBuilder::ArrayInit(const wasm::ArrayType* type, Node* rtt,
|
||||
base::Vector<Node*> elements) {
|
||||
Node* WasmGraphBuilder::ArrayNewFixed(const wasm::ArrayType* type, Node* rtt,
|
||||
base::Vector<Node*> elements) {
|
||||
wasm::ValueType element_type = type->element_type();
|
||||
Node* array = gasm_->Allocate(RoundUp(element_type.value_kind_size() *
|
||||
static_cast<int>(elements.size()),
|
||||
@ -5346,15 +5346,13 @@ Node* WasmGraphBuilder::ArrayInit(const wasm::ArrayType* type, Node* rtt,
|
||||
return array;
|
||||
}
|
||||
|
||||
Node* WasmGraphBuilder::ArrayInitFromSegment(const wasm::ArrayType* type,
|
||||
uint32_t data_segment,
|
||||
Node* offset, Node* length,
|
||||
Node* rtt,
|
||||
wasm::WasmCodePosition position) {
|
||||
return gasm_->CallBuiltin(Builtin::kWasmArrayInitFromSegment,
|
||||
Operator::kNoDeopt | Operator::kNoThrow,
|
||||
gasm_->Uint32Constant(data_segment), offset, length,
|
||||
rtt);
|
||||
Node* WasmGraphBuilder::ArrayNewSegment(const wasm::ArrayType* type,
|
||||
uint32_t data_segment, Node* offset,
|
||||
Node* length, Node* rtt,
|
||||
wasm::WasmCodePosition position) {
|
||||
return gasm_->CallBuiltin(
|
||||
Builtin::kWasmArrayNewSegment, Operator::kNoDeopt | Operator::kNoThrow,
|
||||
gasm_->Uint32Constant(data_segment), offset, length, rtt);
|
||||
}
|
||||
|
||||
Node* WasmGraphBuilder::RttCanon(uint32_t type_index) {
|
||||
|
@ -496,11 +496,11 @@ class WasmGraphBuilder {
|
||||
void ArrayCopy(Node* dst_array, Node* dst_index, CheckForNull dst_null_check,
|
||||
Node* src_array, Node* src_index, CheckForNull src_null_check,
|
||||
Node* length, wasm::WasmCodePosition position);
|
||||
Node* ArrayInit(const wasm::ArrayType* type, Node* rtt,
|
||||
base::Vector<Node*> elements);
|
||||
Node* ArrayInitFromSegment(const wasm::ArrayType* type, uint32_t data_segment,
|
||||
Node* offset, Node* length, Node* rtt,
|
||||
wasm::WasmCodePosition position);
|
||||
Node* ArrayNewFixed(const wasm::ArrayType* type, Node* rtt,
|
||||
base::Vector<Node*> elements);
|
||||
Node* ArrayNewSegment(const wasm::ArrayType* type, uint32_t data_segment,
|
||||
Node* offset, Node* length, Node* rtt,
|
||||
wasm::WasmCodePosition position);
|
||||
Node* I31New(Node* input);
|
||||
Node* I31GetS(Node* input);
|
||||
Node* I31GetU(Node* input);
|
||||
|
@ -715,7 +715,7 @@ RUNTIME_FUNCTION(Runtime_WasmArrayCopy) {
|
||||
return ReadOnlyRoots(isolate).undefined_value();
|
||||
}
|
||||
|
||||
RUNTIME_FUNCTION(Runtime_WasmArrayInitFromSegment) {
|
||||
RUNTIME_FUNCTION(Runtime_WasmArrayNewSegment) {
|
||||
ClearThreadInWasmScope flag_scope(isolate);
|
||||
HandleScope scope(isolate);
|
||||
DCHECK_EQ(5, args.length());
|
||||
|
@ -608,7 +608,7 @@ namespace internal {
|
||||
F(WasmTriggerTierUp, 1, 1) \
|
||||
F(WasmDebugBreak, 0, 1) \
|
||||
F(WasmArrayCopy, 5, 1) \
|
||||
F(WasmArrayInitFromSegment, 5, 1) \
|
||||
F(WasmArrayNewSegment, 5, 1) \
|
||||
F(WasmAllocateContinuation, 1, 1) \
|
||||
F(WasmSyncStackLimit, 0, 1) \
|
||||
F(WasmCreateResumePromise, 2, 1) \
|
||||
|
@ -5530,9 +5530,10 @@ class LiftoffCompiler {
|
||||
__ cache_state()->stack_state.pop_back(5);
|
||||
}
|
||||
|
||||
void ArrayInit(FullDecoder* decoder, const ArrayIndexImmediate<validate>& imm,
|
||||
const base::Vector<Value>& elements, const Value& rtt,
|
||||
Value* result) {
|
||||
void ArrayNewFixed(FullDecoder* decoder,
|
||||
const ArrayIndexImmediate<validate>& imm,
|
||||
const base::Vector<Value>& elements, const Value& rtt,
|
||||
Value* result) {
|
||||
ValueKind rtt_kind = rtt.type.kind();
|
||||
ValueKind elem_kind = imm.array_type->element_type().kind();
|
||||
// Allocate the array.
|
||||
@ -5563,7 +5564,7 @@ class LiftoffCompiler {
|
||||
|
||||
// Initialize the array with stack arguments.
|
||||
LiftoffRegister array(kReturnRegister0);
|
||||
if (!CheckSupportedType(decoder, elem_kind, "array.init")) return;
|
||||
if (!CheckSupportedType(decoder, elem_kind, "array.new_fixed")) return;
|
||||
for (int i = static_cast<int>(elements.size()) - 1; i >= 0; i--) {
|
||||
LiftoffRegList pinned{array};
|
||||
LiftoffRegister element = pinned.set(__ PopToRegister(pinned));
|
||||
@ -5580,12 +5581,11 @@ class LiftoffCompiler {
|
||||
__ PushRegister(kRef, array);
|
||||
}
|
||||
|
||||
void ArrayInitFromSegment(FullDecoder* decoder,
|
||||
const ArrayIndexImmediate<validate>& array_imm,
|
||||
const IndexImmediate<validate>& data_segment,
|
||||
const Value& /* offset */,
|
||||
const Value& /* length */, const Value& /* rtt */,
|
||||
Value* /* result */) {
|
||||
void ArrayNewSegment(FullDecoder* decoder,
|
||||
const ArrayIndexImmediate<validate>& array_imm,
|
||||
const IndexImmediate<validate>& data_segment,
|
||||
const Value& /* offset */, const Value& /* length */,
|
||||
const Value& /* rtt */, Value* /* result */) {
|
||||
LiftoffRegList pinned;
|
||||
LiftoffRegister data_segment_reg =
|
||||
pinned.set(__ GetUnusedRegister(kGpReg, pinned));
|
||||
@ -5593,7 +5593,7 @@ class LiftoffCompiler {
|
||||
WasmValue(static_cast<int32_t>(data_segment.index)));
|
||||
LiftoffAssembler::VarState data_segment_var(kI32, data_segment_reg, 0);
|
||||
|
||||
CallRuntimeStub(WasmCode::kWasmArrayInitFromSegment,
|
||||
CallRuntimeStub(WasmCode::kWasmArrayNewSegment,
|
||||
MakeSig::Returns(kRef).Params(kI32, kI32, kI32, kRtt),
|
||||
{
|
||||
data_segment_var,
|
||||
|
@ -195,7 +195,7 @@ void ConstantExpressionInterface::StructNewDefault(
|
||||
ValueType::Ref(HeapType(imm.index), kNonNullable));
|
||||
}
|
||||
|
||||
void ConstantExpressionInterface::ArrayInit(
|
||||
void ConstantExpressionInterface::ArrayNewFixed(
|
||||
FullDecoder* decoder, const ArrayIndexImmediate<validate>& imm,
|
||||
const base::Vector<Value>& elements, const Value& rtt, Value* result) {
|
||||
if (!generate_value()) return;
|
||||
@ -208,7 +208,7 @@ void ConstantExpressionInterface::ArrayInit(
|
||||
ValueType::Ref(HeapType(imm.index), kNonNullable));
|
||||
}
|
||||
|
||||
void ConstantExpressionInterface::ArrayInitFromSegment(
|
||||
void ConstantExpressionInterface::ArrayNewSegment(
|
||||
FullDecoder* decoder, const ArrayIndexImmediate<validate>& array_imm,
|
||||
const IndexImmediate<validate>& segment_imm, const Value& offset_value,
|
||||
const Value& length_value, const Value& rtt, Value* result) {
|
||||
|
@ -983,9 +983,9 @@ struct ControlBase : public PcForErrors<validate> {
|
||||
const Value& rtt, const Value args[], Value* result) \
|
||||
F(StructNewDefault, const StructIndexImmediate<validate>& imm, \
|
||||
const Value& rtt, Value* result) \
|
||||
F(ArrayInit, const ArrayIndexImmediate<validate>& imm, \
|
||||
F(ArrayNewFixed, const ArrayIndexImmediate<validate>& imm, \
|
||||
const base::Vector<Value>& elements, const Value& rtt, Value* result) \
|
||||
F(ArrayInitFromSegment, const ArrayIndexImmediate<validate>& array_imm, \
|
||||
F(ArrayNewSegment, const ArrayIndexImmediate<validate>& array_imm, \
|
||||
const IndexImmediate<validate>& data_segment, const Value& offset, \
|
||||
const Value& length, const Value& rtt, Value* result) \
|
||||
F(I31New, const Value& input, Value* result) \
|
||||
@ -1963,8 +1963,8 @@ class WasmDecoder : public Decoder {
|
||||
ArrayIndexImmediate<validate> imm(decoder, pc + length);
|
||||
return length + imm.length;
|
||||
}
|
||||
case kExprArrayInit:
|
||||
case kExprArrayInitStatic: {
|
||||
case kExprArrayNewFixed:
|
||||
case kExprArrayNewFixedStatic: {
|
||||
ArrayIndexImmediate<validate> array_imm(decoder, pc + length);
|
||||
IndexImmediate<validate> length_imm(
|
||||
decoder, pc + length + array_imm.length, "array length");
|
||||
@ -1976,9 +1976,9 @@ class WasmDecoder : public Decoder {
|
||||
pc + length + dst_imm.length);
|
||||
return length + dst_imm.length + src_imm.length;
|
||||
}
|
||||
case kExprArrayInitFromData:
|
||||
case kExprArrayInitFromDataStatic:
|
||||
case kExprArrayInitFromElemStatic: {
|
||||
case kExprArrayNewData:
|
||||
case kExprArrayNewDataStatic:
|
||||
case kExprArrayNewElemStatic: {
|
||||
ArrayIndexImmediate<validate> array_imm(decoder, pc + length);
|
||||
IndexImmediate<validate> data_imm(
|
||||
decoder, pc + length + array_imm.length, "segment index");
|
||||
@ -2226,8 +2226,8 @@ class WasmDecoder : public Decoder {
|
||||
return {2, 0};
|
||||
case kExprArrayNew:
|
||||
case kExprArrayNewDefaultWithRtt:
|
||||
case kExprArrayInitFromDataStatic:
|
||||
case kExprArrayInitFromElemStatic:
|
||||
case kExprArrayNewDataStatic:
|
||||
case kExprArrayNewElemStatic:
|
||||
case kExprArrayGet:
|
||||
case kExprArrayGetS:
|
||||
case kExprArrayGetU:
|
||||
@ -2244,7 +2244,7 @@ class WasmDecoder : public Decoder {
|
||||
case kExprStructNewDefault:
|
||||
return {0, 1};
|
||||
case kExprArrayNewWithRtt:
|
||||
case kExprArrayInitFromData:
|
||||
case kExprArrayNewData:
|
||||
return {3, 1};
|
||||
case kExprStructNewWithRtt: {
|
||||
StructIndexImmediate<validate> imm(this, pc + 2);
|
||||
@ -2256,12 +2256,12 @@ class WasmDecoder : public Decoder {
|
||||
CHECK(Validate(pc + 2, imm));
|
||||
return {imm.struct_type->field_count(), 1};
|
||||
}
|
||||
case kExprArrayInit:
|
||||
case kExprArrayInitStatic: {
|
||||
case kExprArrayNewFixed:
|
||||
case kExprArrayNewFixedStatic: {
|
||||
ArrayIndexImmediate<validate> array_imm(this, pc + 2);
|
||||
IndexImmediate<validate> length_imm(this, pc + 2 + array_imm.length,
|
||||
"array length");
|
||||
return {length_imm.index + (opcode == kExprArrayInit ? 1 : 0), 1};
|
||||
return {length_imm.index + (opcode == kExprArrayNewFixed ? 1 : 0), 1};
|
||||
}
|
||||
case kExprStringConst:
|
||||
return { 0, 1 };
|
||||
@ -4420,16 +4420,16 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> {
|
||||
Push(value);
|
||||
return opcode_length + imm.length;
|
||||
}
|
||||
case kExprArrayInitFromData:
|
||||
case kExprArrayInitFromDataStatic: {
|
||||
case kExprArrayNewData:
|
||||
case kExprArrayNewDataStatic: {
|
||||
ArrayIndexImmediate<validate> array_imm(this,
|
||||
this->pc_ + opcode_length);
|
||||
if (!this->Validate(this->pc_ + opcode_length, array_imm)) return 0;
|
||||
ValueType element_type = array_imm.array_type->element_type();
|
||||
if (element_type.is_reference()) {
|
||||
this->DecodeError(
|
||||
"array.init_from_data can only be used with numeric-type arrays, "
|
||||
"found array type #%d instead",
|
||||
"array.new_data can only be used with numeric-type arrays, found "
|
||||
"array type #%d instead",
|
||||
array_imm.index);
|
||||
return 0;
|
||||
}
|
||||
@ -4448,10 +4448,9 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> {
|
||||
if (!this->ValidateDataSegment(data_index_pc, data_segment)) return 0;
|
||||
|
||||
ValueType rtt_type = ValueType::Rtt(array_imm.index);
|
||||
Value rtt = opcode == kExprArrayInitFromDataStatic
|
||||
? CreateValue(rtt_type)
|
||||
: Peek(0, 2, rtt_type);
|
||||
if (opcode == kExprArrayInitFromDataStatic) {
|
||||
Value rtt = opcode == kExprArrayNewDataStatic ? CreateValue(rtt_type)
|
||||
: Peek(0, 2, rtt_type);
|
||||
if (opcode == kExprArrayNewDataStatic) {
|
||||
CALL_INTERFACE_IF_OK_AND_REACHABLE(RttCanon, array_imm.index, &rtt);
|
||||
Push(rtt);
|
||||
}
|
||||
@ -4461,22 +4460,22 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> {
|
||||
|
||||
Value array =
|
||||
CreateValue(ValueType::Ref(array_imm.index, kNonNullable));
|
||||
CALL_INTERFACE_IF_OK_AND_REACHABLE(ArrayInitFromSegment, array_imm,
|
||||
CALL_INTERFACE_IF_OK_AND_REACHABLE(ArrayNewSegment, array_imm,
|
||||
data_segment, offset, length, rtt,
|
||||
&array);
|
||||
Drop(3); // rtt, length, offset
|
||||
Push(array);
|
||||
return opcode_length + array_imm.length + data_segment.length;
|
||||
}
|
||||
case kExprArrayInitFromElemStatic: {
|
||||
case kExprArrayNewElemStatic: {
|
||||
ArrayIndexImmediate<validate> array_imm(this,
|
||||
this->pc_ + opcode_length);
|
||||
if (!this->Validate(this->pc_ + opcode_length, array_imm)) return 0;
|
||||
ValueType element_type = array_imm.array_type->element_type();
|
||||
if (element_type.is_numeric()) {
|
||||
this->DecodeError(
|
||||
"array.init_from_elem can only be used with reference-type "
|
||||
"arrays, found array type #%d instead",
|
||||
"array.new_elem can only be used with reference-type arrays, "
|
||||
"found array type #%d instead",
|
||||
array_imm.index);
|
||||
return 0;
|
||||
}
|
||||
@ -4499,7 +4498,7 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> {
|
||||
if (V8_UNLIKELY(
|
||||
!IsSubtypeOf(elem_segment_type, element_type, this->module_))) {
|
||||
this->DecodeError(
|
||||
"array.init_from_elem: segment type %s is not a subtype of array "
|
||||
"array.new_elem: segment type %s is not a subtype of array "
|
||||
"element type %s",
|
||||
elem_segment_type.name().c_str(), element_type.name().c_str());
|
||||
return 0;
|
||||
@ -4508,7 +4507,7 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> {
|
||||
Value length = Peek(1, 1, kWasmI32);
|
||||
Value offset = Peek(2, 0, kWasmI32);
|
||||
|
||||
CALL_INTERFACE_IF_OK_AND_REACHABLE(ArrayInitFromSegment, array_imm,
|
||||
CALL_INTERFACE_IF_OK_AND_REACHABLE(ArrayNewSegment, array_imm,
|
||||
elem_segment, offset, length, rtt,
|
||||
&array);
|
||||
Drop(3); // rtt, length, offset
|
||||
@ -4622,25 +4621,26 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> {
|
||||
Drop(5);
|
||||
return opcode_length + dst_imm.length + src_imm.length;
|
||||
}
|
||||
case kExprArrayInit:
|
||||
case kExprArrayInitStatic: {
|
||||
case kExprArrayNewFixed:
|
||||
case kExprArrayNewFixedStatic: {
|
||||
ArrayIndexImmediate<validate> array_imm(this,
|
||||
this->pc_ + opcode_length);
|
||||
if (!this->Validate(this->pc_ + opcode_length, array_imm)) return 0;
|
||||
IndexImmediate<validate> length_imm(
|
||||
this, this->pc_ + opcode_length + array_imm.length,
|
||||
"array.init length");
|
||||
"array.new_fixed length");
|
||||
uint32_t elem_count = length_imm.index;
|
||||
if (!VALIDATE(elem_count <= kV8MaxWasmArrayInitLength)) {
|
||||
if (!VALIDATE(elem_count <= kV8MaxWasmArrayNewFixedLength)) {
|
||||
this->DecodeError(
|
||||
"Requested length %u for array.init too large, maximum is %zu",
|
||||
length_imm.index, kV8MaxWasmArrayInitLength);
|
||||
"Requested length %u for array.new_fixed too large, maximum is "
|
||||
"%zu",
|
||||
length_imm.index, kV8MaxWasmArrayNewFixedLength);
|
||||
return 0;
|
||||
}
|
||||
Value rtt = opcode == kExprArrayInit
|
||||
Value rtt = opcode == kExprArrayNewFixed
|
||||
? Peek(0, elem_count, ValueType::Rtt(array_imm.index))
|
||||
: CreateValue(ValueType::Rtt(array_imm.index));
|
||||
if (opcode == kExprArrayInitStatic) {
|
||||
if (opcode == kExprArrayNewFixedStatic) {
|
||||
CALL_INTERFACE_IF_OK_AND_REACHABLE(RttCanon, array_imm.index, &rtt);
|
||||
Push(rtt);
|
||||
}
|
||||
@ -4651,8 +4651,8 @@ class WasmFullDecoder : public WasmDecoder<validate, decoding_mode> {
|
||||
ArgVector elements = PeekArgs(&element_sig, 1);
|
||||
Value result =
|
||||
CreateValue(ValueType::Ref(array_imm.index, kNonNullable));
|
||||
CALL_INTERFACE_IF_OK_AND_REACHABLE(ArrayInit, array_imm, elements, rtt,
|
||||
&result);
|
||||
CALL_INTERFACE_IF_OK_AND_REACHABLE(ArrayNewFixed, array_imm, elements,
|
||||
rtt, &result);
|
||||
Drop(elem_count + 1);
|
||||
Push(result);
|
||||
return opcode_length + array_imm.length + length_imm.length;
|
||||
|
@ -1184,24 +1184,25 @@ class WasmGraphBuildingInterface {
|
||||
length.node, decoder->position());
|
||||
}
|
||||
|
||||
void ArrayInit(FullDecoder* decoder, const ArrayIndexImmediate<validate>& imm,
|
||||
const base::Vector<Value>& elements, const Value& rtt,
|
||||
Value* result) {
|
||||
void ArrayNewFixed(FullDecoder* decoder,
|
||||
const ArrayIndexImmediate<validate>& imm,
|
||||
const base::Vector<Value>& elements, const Value& rtt,
|
||||
Value* result) {
|
||||
NodeVector element_nodes(elements.size());
|
||||
for (uint32_t i = 0; i < elements.size(); i++) {
|
||||
element_nodes[i] = elements[i].node;
|
||||
}
|
||||
SetAndTypeNode(result, builder_->ArrayInit(imm.array_type, rtt.node,
|
||||
VectorOf(element_nodes)));
|
||||
SetAndTypeNode(result, builder_->ArrayNewFixed(imm.array_type, rtt.node,
|
||||
VectorOf(element_nodes)));
|
||||
}
|
||||
|
||||
void ArrayInitFromSegment(FullDecoder* decoder,
|
||||
const ArrayIndexImmediate<validate>& array_imm,
|
||||
const IndexImmediate<validate>& data_segment,
|
||||
const Value& offset, const Value& length,
|
||||
const Value& rtt, Value* result) {
|
||||
void ArrayNewSegment(FullDecoder* decoder,
|
||||
const ArrayIndexImmediate<validate>& array_imm,
|
||||
const IndexImmediate<validate>& data_segment,
|
||||
const Value& offset, const Value& length,
|
||||
const Value& rtt, Value* result) {
|
||||
SetAndTypeNode(result,
|
||||
builder_->ArrayInitFromSegment(
|
||||
builder_->ArrayNewSegment(
|
||||
array_imm.array_type, data_segment.index, offset.node,
|
||||
length.node, rtt.node, decoder->position()));
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ struct WasmModule;
|
||||
V(WasmAllocateArray_Uninitialized) \
|
||||
V(WasmArrayCopy) \
|
||||
V(WasmArrayCopyWithChecks) \
|
||||
V(WasmArrayInitFromSegment) \
|
||||
V(WasmArrayNewSegment) \
|
||||
V(WasmAllocateStructWithRtt) \
|
||||
V(WasmSubtypeCheck) \
|
||||
V(WasmOnStackReplace) \
|
||||
|
@ -42,8 +42,8 @@ ValueType WasmInitExpr::type(const WasmModule* module,
|
||||
case kStructNew:
|
||||
case kStructNewDefaultWithRtt:
|
||||
case kStructNewDefault:
|
||||
case kArrayInit:
|
||||
case kArrayInitStatic:
|
||||
case kArrayNewFixed:
|
||||
case kArrayNewFixedStatic:
|
||||
return ValueType::Ref(immediate().index, kNonNullable);
|
||||
case kI31New:
|
||||
return kWasmI31Ref.AsNonNull();
|
||||
|
@ -40,8 +40,8 @@ class WasmInitExpr : public ZoneObject {
|
||||
kStructNew,
|
||||
kStructNewDefaultWithRtt,
|
||||
kStructNewDefault,
|
||||
kArrayInit,
|
||||
kArrayInitStatic,
|
||||
kArrayNewFixed,
|
||||
kArrayNewFixedStatic,
|
||||
kI31New,
|
||||
kRttCanon,
|
||||
kStringConst,
|
||||
@ -128,16 +128,16 @@ class WasmInitExpr : public ZoneObject {
|
||||
return expr;
|
||||
}
|
||||
|
||||
static WasmInitExpr ArrayInit(uint32_t index,
|
||||
ZoneVector<WasmInitExpr>* elements) {
|
||||
WasmInitExpr expr(kArrayInit, elements);
|
||||
static WasmInitExpr ArrayNewFixed(uint32_t index,
|
||||
ZoneVector<WasmInitExpr>* elements) {
|
||||
WasmInitExpr expr(kArrayNewFixed, elements);
|
||||
expr.immediate_.index = index;
|
||||
return expr;
|
||||
}
|
||||
|
||||
static WasmInitExpr ArrayInitStatic(uint32_t index,
|
||||
ZoneVector<WasmInitExpr>* elements) {
|
||||
WasmInitExpr expr(kArrayInitStatic, elements);
|
||||
static WasmInitExpr ArrayNewFixedStatic(uint32_t index,
|
||||
ZoneVector<WasmInitExpr>* elements) {
|
||||
WasmInitExpr expr(kArrayNewFixedStatic, elements);
|
||||
expr.immediate_.index = index;
|
||||
return expr;
|
||||
}
|
||||
@ -199,8 +199,8 @@ class WasmInitExpr : public ZoneObject {
|
||||
if (operands()[i] != other.operands()[i]) return false;
|
||||
}
|
||||
return true;
|
||||
case kArrayInit:
|
||||
case kArrayInitStatic:
|
||||
case kArrayNewFixed:
|
||||
case kArrayNewFixedStatic:
|
||||
if (immediate().index != other.immediate().index) return false;
|
||||
if (operands()->size() != other.operands()->size()) return false;
|
||||
for (uint32_t i = 0; i < operands()->size(); i++) {
|
||||
|
@ -58,7 +58,7 @@ constexpr size_t kV8MaxWasmMemories = 1;
|
||||
// GC proposal. These limits are not standardized yet.
|
||||
constexpr size_t kV8MaxWasmStructFields = 999;
|
||||
constexpr uint32_t kV8MaxRttSubtypingDepth = 31;
|
||||
constexpr size_t kV8MaxWasmArrayInitLength = 10000;
|
||||
constexpr size_t kV8MaxWasmArrayNewFixedLength = 10000;
|
||||
|
||||
// Stringref proposal. This limit is not standardized yet.
|
||||
constexpr size_t kV8MaxWasmStringLiterals = 1000000;
|
||||
|
@ -557,17 +557,18 @@ void WriteInitializerExpressionWithEnd(ZoneBuffer* buffer,
|
||||
buffer->write_u8(static_cast<uint8_t>(opcode));
|
||||
buffer->write_u32v(init.immediate().index);
|
||||
break;
|
||||
case WasmInitExpr::kArrayInit:
|
||||
case WasmInitExpr::kArrayInitStatic:
|
||||
static_assert((kExprArrayInit >> 8) == kGCPrefix);
|
||||
static_assert((kExprArrayInitStatic >> 8) == kGCPrefix);
|
||||
case WasmInitExpr::kArrayNewFixed:
|
||||
case WasmInitExpr::kArrayNewFixedStatic:
|
||||
static_assert((kExprArrayNewFixed >> 8) == kGCPrefix);
|
||||
static_assert((kExprArrayNewFixedStatic >> 8) == kGCPrefix);
|
||||
for (const WasmInitExpr& operand : *init.operands()) {
|
||||
WriteInitializerExpressionWithEnd(buffer, operand, kWasmBottom);
|
||||
}
|
||||
buffer->write_u8(kGCPrefix);
|
||||
buffer->write_u8(static_cast<uint8_t>(
|
||||
init.kind() == WasmInitExpr::kArrayInit ? kExprArrayInit
|
||||
: kExprArrayInitStatic));
|
||||
buffer->write_u8(
|
||||
static_cast<uint8_t>(init.kind() == WasmInitExpr::kArrayNewFixed
|
||||
? kExprArrayNewFixed
|
||||
: kExprArrayNewFixedStatic));
|
||||
buffer->write_u32v(init.immediate().index);
|
||||
buffer->write_u32v(static_cast<uint32_t>(init.operands()->size() - 1));
|
||||
break;
|
||||
|
@ -703,13 +703,13 @@ bool V8_EXPORT_PRIVATE IsJSCompatibleSignature(const FunctionSig* sig,
|
||||
V(ArrayLen, 0xfb17, _, "array.len") \
|
||||
V(ArrayCopy, 0xfb18, _, \
|
||||
"array.copy") /* not standardized - V8 experimental */ \
|
||||
V(ArrayInit, 0xfb19, _, "array.init") \
|
||||
V(ArrayInitStatic, 0xfb1a, _, "array.init_static") \
|
||||
V(ArrayNewFixed, 0xfb19, _, "array.new_fixed") \
|
||||
V(ArrayNewFixedStatic, 0xfb1a, _, "array.new_fixed_static") \
|
||||
V(ArrayNew, 0xfb1b, _, "array.new") \
|
||||
V(ArrayNewDefault, 0xfb1c, _, "array.new_default") \
|
||||
V(ArrayInitFromData, 0xfb1e, _, "array.init_from_data") \
|
||||
V(ArrayInitFromDataStatic, 0xfb1d, _, "array.init_from_data_static") \
|
||||
V(ArrayInitFromElemStatic, 0xfb1f, _, "array.init_from_elem_static") \
|
||||
V(ArrayNewData, 0xfb1e, _, "array.new_data") \
|
||||
V(ArrayNewDataStatic, 0xfb1d, _, "array.new_data_static") \
|
||||
V(ArrayNewElemStatic, 0xfb1f, _, "array.new_elem_static") \
|
||||
V(I31New, 0xfb20, _, "i31.new") \
|
||||
V(I31GetS, 0xfb21, _, "i31.get_s") \
|
||||
V(I31GetU, 0xfb22, _, "i31.get_u") \
|
||||
|
@ -1026,17 +1026,17 @@ WASM_COMPILED_EXEC_TEST(WasmBasicArray) {
|
||||
|
||||
const byte kInit = tester.DefineFunction(
|
||||
&sig_q_v, {},
|
||||
{WASM_ARRAY_INIT(type_index, 3, WASM_I32V(10), WASM_I32V(20),
|
||||
WASM_I32V(30), WASM_RTT_CANON(type_index)),
|
||||
{WASM_ARRAY_NEW_FIXED(type_index, 3, WASM_I32V(10), WASM_I32V(20),
|
||||
WASM_I32V(30), WASM_RTT_CANON(type_index)),
|
||||
kExprEnd});
|
||||
|
||||
const byte kImmutable = tester.DefineFunction(
|
||||
tester.sigs.i_v(), {},
|
||||
{WASM_ARRAY_GET(
|
||||
immut_type_index,
|
||||
WASM_ARRAY_INIT(immut_type_index, 2, WASM_I32V(42), WASM_I32V(43),
|
||||
WASM_RTT_CANON(immut_type_index)),
|
||||
WASM_I32V(0)),
|
||||
{WASM_ARRAY_GET(immut_type_index,
|
||||
WASM_ARRAY_NEW_FIXED(immut_type_index, 2, WASM_I32V(42),
|
||||
WASM_I32V(43),
|
||||
WASM_RTT_CANON(immut_type_index)),
|
||||
WASM_I32V(0)),
|
||||
kExprEnd});
|
||||
|
||||
const uint32_t kLongLength = 1u << 16;
|
||||
|
@ -594,11 +594,11 @@ inline uint16_t ExtractPrefixedOpcodeBytes(WasmOpcode opcode) {
|
||||
dst_array, dst_index, src_array, src_index, length, \
|
||||
WASM_GC_OP(kExprArrayCopy), static_cast<byte>(dst_idx), \
|
||||
static_cast<byte>(src_idx)
|
||||
#define WASM_ARRAY_INIT(index, length, ...) \
|
||||
__VA_ARGS__, WASM_GC_OP(kExprArrayInit), static_cast<byte>(index), \
|
||||
#define WASM_ARRAY_NEW_FIXED(index, length, ...) \
|
||||
__VA_ARGS__, WASM_GC_OP(kExprArrayNewFixed), static_cast<byte>(index), \
|
||||
static_cast<byte>(length)
|
||||
#define WASM_ARRAY_INIT_STATIC(index, length, ...) \
|
||||
__VA_ARGS__, WASM_GC_OP(kExprArrayInitStatic), static_cast<byte>(index), \
|
||||
#define WASM_ARRAY_NEW_FIXED_STATIC(index, length, ...) \
|
||||
__VA_ARGS__, WASM_GC_OP(kExprArrayNewFixedStatic), static_cast<byte>(index), \
|
||||
static_cast<byte>(length)
|
||||
|
||||
#define WASM_RTT(typeidx) kRttCode, U32V_1(typeidx)
|
||||
|
@ -2414,7 +2414,7 @@ WasmInitExpr GenerateInitExpr(Zone* zone, WasmModuleBuilder* builder,
|
||||
zone, builder, builder->GetArrayType(index)->element_type(),
|
||||
num_struct_and_array_types));
|
||||
elements->push_back(WasmInitExpr::RttCanon(index));
|
||||
return WasmInitExpr::ArrayInit(index, elements);
|
||||
return WasmInitExpr::ArrayNewFixed(index, elements);
|
||||
}
|
||||
if (builder->IsSignature(index)) {
|
||||
// Transform from signature index to function index.
|
||||
|
@ -389,25 +389,26 @@ class InitExprInterface {
|
||||
zone_, imm.index, rtt.init_expr);
|
||||
}
|
||||
|
||||
void ArrayInit(FullDecoder* decoder, const ArrayIndexImmediate<validate>& imm,
|
||||
const base::Vector<Value>& elements, const Value& rtt,
|
||||
Value* result) {
|
||||
void ArrayNewFixed(FullDecoder* decoder,
|
||||
const ArrayIndexImmediate<validate>& imm,
|
||||
const base::Vector<Value>& elements, const Value& rtt,
|
||||
Value* result) {
|
||||
ZoneVector<WasmInitExpr>* args =
|
||||
zone_->New<ZoneVector<WasmInitExpr>>(zone_);
|
||||
for (Value expr : elements) args->push_back(expr.init_expr);
|
||||
bool nominal = decoder->module_->has_supertype(imm.index);
|
||||
|
||||
if (!nominal) args->push_back(rtt.init_expr);
|
||||
result->init_expr = nominal ? WasmInitExpr::ArrayInitStatic(imm.index, args)
|
||||
: WasmInitExpr::ArrayInit(imm.index, args);
|
||||
result->init_expr = nominal
|
||||
? WasmInitExpr::ArrayNewFixedStatic(imm.index, args)
|
||||
: WasmInitExpr::ArrayNewFixed(imm.index, args);
|
||||
}
|
||||
|
||||
void ArrayInitFromSegment(FullDecoder* decoder,
|
||||
const ArrayIndexImmediate<validate>& array_imm,
|
||||
const IndexImmediate<validate>& data_segment_imm,
|
||||
const Value& offset_value,
|
||||
const Value& length_value, const Value& rtt,
|
||||
Value* result) {
|
||||
void ArrayNewSegment(FullDecoder* decoder,
|
||||
const ArrayIndexImmediate<validate>& array_imm,
|
||||
const IndexImmediate<validate>& data_segment_imm,
|
||||
const Value& offset_value, const Value& length_value,
|
||||
const Value& rtt, Value* result) {
|
||||
// TODO(7748): Implement.
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
@ -491,12 +492,12 @@ void AppendInitExpr(std::ostream& os, const WasmInitExpr& expr) {
|
||||
case WasmInitExpr::kStructNewDefault:
|
||||
os << "StructNewDefault(" << expr.immediate().index;
|
||||
break;
|
||||
case WasmInitExpr::kArrayInit:
|
||||
os << "ArrayInit(" << expr.immediate().index;
|
||||
case WasmInitExpr::kArrayNewFixed:
|
||||
os << "ArrayNewFixed(" << expr.immediate().index;
|
||||
append_operands = true;
|
||||
break;
|
||||
case WasmInitExpr::kArrayInitStatic:
|
||||
os << "ArrayInitStatic(" << expr.immediate().index;
|
||||
case WasmInitExpr::kArrayNewFixedStatic:
|
||||
os << "ArrayNewFixedStatic(" << expr.immediate().index;
|
||||
append_operands = true;
|
||||
break;
|
||||
case WasmInitExpr::kI31New:
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
|
||||
(function TestArrayInitFromElemStatic() {
|
||||
(function TestArrayNewElemStatic() {
|
||||
print(arguments.callee.name);
|
||||
let builder = new WasmModuleBuilder();
|
||||
let struct_type_index = builder.addStruct([makeField(kWasmI32, false)]);
|
||||
@ -36,7 +36,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
.addBody([
|
||||
kExprI32Const, 0, // offset
|
||||
kExprLocalGet, 0, // length
|
||||
kGCPrefix, kExprArrayInitFromElemStatic, array_type_index,
|
||||
kGCPrefix, kExprArrayNewElemStatic, array_type_index,
|
||||
segment,
|
||||
kExprLocalGet, 1, // index in the array
|
||||
kGCPrefix, kExprArrayGet, array_type_index,
|
||||
@ -78,7 +78,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
assertTraps(kTrapElementSegmentOutOfBounds, () => init_and_get_active(1, 0));
|
||||
})();
|
||||
|
||||
(function TestArrayInitFromElemStaticConstant() {
|
||||
(function TestArrayNewElemStaticConstant() {
|
||||
print(arguments.callee.name);
|
||||
let builder = new WasmModuleBuilder();
|
||||
let struct_type_index = builder.addStruct([makeField(kWasmI32, false)]);
|
||||
@ -107,10 +107,10 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
|
||||
let array_segment = builder.addPassiveElementSegment(
|
||||
[[...wasmI32Const(0), ...wasmI32Const(3),
|
||||
kGCPrefix, kExprArrayInitFromElemStatic,
|
||||
kGCPrefix, kExprArrayNewElemStatic,
|
||||
array_type_index, passive_segment],
|
||||
[...wasmI32Const(0), ...wasmI32Const(0),
|
||||
kGCPrefix, kExprArrayInitFromElemStatic,
|
||||
kGCPrefix, kExprArrayNewElemStatic,
|
||||
array_type_index, active_segment]],
|
||||
array_type);
|
||||
|
||||
@ -159,7 +159,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
assertTraps(kTrapArrayOutOfBounds, () => table_get(0, 3));
|
||||
})();
|
||||
|
||||
(function TestArrayInitFromElemStaticMistypedSegment() {
|
||||
(function TestArrayNewElemStaticMistypedSegment() {
|
||||
print(arguments.callee.name);
|
||||
let builder = new WasmModuleBuilder();
|
||||
let struct_type_index = builder.addStruct([makeField(kWasmI32, false)]);
|
||||
@ -174,7 +174,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
.addBody([
|
||||
kExprI32Const, 0, // offset
|
||||
kExprLocalGet, 0, // length
|
||||
kGCPrefix, kExprArrayInitFromElemStatic, array_type_index,
|
||||
kGCPrefix, kExprArrayNewElemStatic, array_type_index,
|
||||
passive_segment,
|
||||
kExprLocalGet, 1, // index in the array
|
||||
kGCPrefix, kExprArrayGet, array_type_index,
|
||||
@ -187,7 +187,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
|
||||
// Element segments are defined after globals, so currently it is not valid
|
||||
// to refer to an element segment in the global section.
|
||||
(function TestArrayInitFromElemInGlobal() {
|
||||
(function TestArrayNewFixedFromElemInGlobal() {
|
||||
print(arguments.callee.name);
|
||||
let builder = new WasmModuleBuilder();
|
||||
let struct_type_index = builder.addStruct([makeField(kWasmI32, false)]);
|
||||
@ -201,14 +201,14 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
builder.addGlobal(
|
||||
wasmOptRefType(array_type_index), false,
|
||||
[...wasmI32Const(0), ...wasmI32Const(1),
|
||||
kGCPrefix, kExprArrayInitFromElemStatic,
|
||||
kGCPrefix, kExprArrayNewElemStatic,
|
||||
array_type_index, passive_segment]);
|
||||
|
||||
assertThrows(() => builder.instantiate(), WebAssembly.CompileError,
|
||||
/invalid element segment index/);
|
||||
})();
|
||||
|
||||
(function TestArrayInitFromElemStaticConstantArrayTooLarge() {
|
||||
(function TestArrayNewElemStaticConstantArrayTooLarge() {
|
||||
print(arguments.callee.name);
|
||||
let builder = new WasmModuleBuilder();
|
||||
let struct_type_index = builder.addStruct([makeField(kWasmI32, false)]);
|
||||
@ -233,7 +233,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
|
||||
let array_segment = builder.addPassiveElementSegment(
|
||||
[[...wasmI32Const(0), ...wasmI32Const(1 << 30),
|
||||
kGCPrefix, kExprArrayInitFromElemStatic,
|
||||
kGCPrefix, kExprArrayNewElemStatic,
|
||||
array_type_index, passive_segment]],
|
||||
array_type
|
||||
);
|
||||
@ -247,7 +247,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
assertTraps(kTrapArrayTooLarge, () => instance.exports.init());
|
||||
})();
|
||||
|
||||
(function TestArrayInitFromElemStaticConstantElementSegmentOutOfBounds() {
|
||||
(function TestArrayNewElemStaticConstantElementSegmentOutOfBounds() {
|
||||
print(arguments.callee.name);
|
||||
let builder = new WasmModuleBuilder();
|
||||
let struct_type_index = builder.addStruct([makeField(kWasmI32, false)]);
|
||||
@ -272,7 +272,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
|
||||
let array_segment = builder.addPassiveElementSegment(
|
||||
[[...wasmI32Const(0), ...wasmI32Const(10),
|
||||
kGCPrefix, kExprArrayInitFromElemStatic,
|
||||
kGCPrefix, kExprArrayNewElemStatic,
|
||||
array_type_index, passive_segment]],
|
||||
array_type
|
||||
);
|
||||
@ -286,7 +286,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
assertTraps(kTrapElementSegmentOutOfBounds, () => instance.exports.init());
|
||||
})();
|
||||
|
||||
(function TestArrayInitFromElemStaticConstantActiveSegment() {
|
||||
(function TestArrayNewElemStaticConstantActiveSegment() {
|
||||
print(arguments.callee.name);
|
||||
let builder = new WasmModuleBuilder();
|
||||
let struct_type_index = builder.addStruct([makeField(kWasmI32, false)]);
|
||||
@ -312,7 +312,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
|
||||
let array_segment = builder.addPassiveElementSegment(
|
||||
[[...wasmI32Const(0), ...wasmI32Const(3),
|
||||
kGCPrefix, kExprArrayInitFromElemStatic,
|
||||
kGCPrefix, kExprArrayNewElemStatic,
|
||||
array_type_index, active_segment]],
|
||||
array_type
|
||||
);
|
||||
|
@ -13,8 +13,8 @@ let i16Array = builder.addArray(kWasmI16, true);
|
||||
builder.addFunction('getHelloArray', makeSig([], [kWasmAnyRef]))
|
||||
.addBody([
|
||||
...wasmI32Const(72), ...wasmI32Const(69), ...wasmI32Const(76),
|
||||
...wasmI32Const(76), ...wasmI32Const(79), kGCPrefix, kExprArrayInitStatic,
|
||||
i16Array, 5
|
||||
...wasmI32Const(76), ...wasmI32Const(79),
|
||||
kGCPrefix, kExprArrayNewFixedStatic, i16Array, 5
|
||||
])
|
||||
.exportFunc();
|
||||
|
||||
|
@ -54,7 +54,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
/subtyping depth is greater than allowed/);
|
||||
})();
|
||||
|
||||
(function TestArrayInitFromDataStatic() {
|
||||
(function TestArrayNewDataStatic() {
|
||||
print(arguments.callee.name);
|
||||
let builder = new WasmModuleBuilder();
|
||||
builder.setNominal();
|
||||
@ -72,7 +72,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
let global = builder.addGlobal(
|
||||
wasmRefType(array_type_index), true,
|
||||
[...wasmI32Const(1), ...wasmI32Const(2),
|
||||
kGCPrefix, kExprArrayInitFromDataStatic, array_type_index, data_segment],
|
||||
kGCPrefix, kExprArrayNewDataStatic, array_type_index, data_segment],
|
||||
builder);
|
||||
|
||||
builder.addFunction("global_get", kSig_i_i)
|
||||
@ -86,7 +86,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
builder.addFunction("init_from_data", kSig_i_iii)
|
||||
.addBody([
|
||||
kExprLocalGet, 0, kExprLocalGet, 1,
|
||||
kGCPrefix, kExprArrayInitFromDataStatic,
|
||||
kGCPrefix, kExprArrayNewDataStatic,
|
||||
array_type_index, data_segment,
|
||||
kExprLocalGet, 2,
|
||||
kGCPrefix, kExprArrayGetS, array_type_index])
|
||||
@ -114,7 +114,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
assertTraps(kTrapDataSegmentOutOfBounds, () => init(1, 2, 0));
|
||||
})();
|
||||
|
||||
(function TestArrayInitFromData() {
|
||||
(function TestArrayNewData() {
|
||||
print(arguments.callee.name);
|
||||
let builder = new WasmModuleBuilder();
|
||||
builder.setNominal();
|
||||
@ -133,7 +133,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
wasmRefType(array_type_index), true,
|
||||
[...wasmI32Const(1), ...wasmI32Const(2),
|
||||
kGCPrefix, kExprRttCanon, array_type_index,
|
||||
kGCPrefix, kExprArrayInitFromData, array_type_index, data_segment],
|
||||
kGCPrefix, kExprArrayNewData, array_type_index, data_segment],
|
||||
builder);
|
||||
|
||||
builder.addFunction("global_get", kSig_i_i)
|
||||
@ -148,7 +148,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
.addBody([
|
||||
kExprLocalGet, 0, kExprLocalGet, 1,
|
||||
kGCPrefix, kExprRttCanon, array_type_index,
|
||||
kGCPrefix, kExprArrayInitFromData, array_type_index, data_segment,
|
||||
kGCPrefix, kExprArrayNewData, array_type_index, data_segment,
|
||||
kExprLocalGet, 2,
|
||||
kGCPrefix, kExprArrayGetS, array_type_index])
|
||||
.exportFunc();
|
||||
|
@ -187,7 +187,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
assertEquals(0, instance.exports.field_3_default());
|
||||
})();
|
||||
|
||||
(function TestArrayInitExprNumeric() {
|
||||
(function TestArrayNewFixedExprNumeric() {
|
||||
print(arguments.callee.name);
|
||||
|
||||
var builder = new WasmModuleBuilder();
|
||||
@ -204,7 +204,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
wasmRefType(array_index), false,
|
||||
[kExprGlobalGet, global0.index, ...wasmI32Const(element1_value),
|
||||
kGCPrefix, kExprRttCanon, array_index,
|
||||
kGCPrefix, kExprArrayInit, array_index, 2]);
|
||||
kGCPrefix, kExprArrayNewFixed, array_index, 2]);
|
||||
|
||||
builder.addFunction("get_element", kSig_i_i)
|
||||
.addBody([
|
||||
@ -219,7 +219,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
assertEquals(element1_value, instance.exports.get_element(1));
|
||||
})();
|
||||
|
||||
(function TestArrayInitExprRef() {
|
||||
(function TestArrayNewFixedExprRef() {
|
||||
print(arguments.callee.name);
|
||||
|
||||
var builder = new WasmModuleBuilder();
|
||||
@ -241,7 +241,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
kGCPrefix, kExprRttCanon, struct_index,
|
||||
kGCPrefix, kExprStructNewWithRtt, struct_index,
|
||||
kGCPrefix, kExprRttCanon, array_index,
|
||||
kGCPrefix, kExprArrayInit, array_index, 3]);
|
||||
kGCPrefix, kExprArrayNewFixed, array_index, 3]);
|
||||
|
||||
builder.addFunction("element0", kSig_i_v)
|
||||
.addBody([
|
||||
@ -285,7 +285,7 @@ d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
|
||||
wasmRefType(array_index), true,
|
||||
[...values.flatMap(
|
||||
value => [...wasmI32Const(value), kGCPrefix, kExprI31New]),
|
||||
kGCPrefix, kExprArrayInitStatic, array_index, 5]);
|
||||
kGCPrefix, kExprArrayNewFixedStatic, array_index, 5]);
|
||||
|
||||
for (signed of [true, false]) {
|
||||
builder.addFunction(`get_${signed ? "s" : "u"}`, kSig_i_i)
|
||||
|
@ -495,13 +495,13 @@ let kExprArrayGetU = 0x15;
|
||||
let kExprArraySet = 0x16;
|
||||
let kExprArrayLen = 0x17;
|
||||
let kExprArrayCopy = 0x18;
|
||||
let kExprArrayInit = 0x19;
|
||||
let kExprArrayInitStatic = 0x1a;
|
||||
let kExprArrayNewFixed = 0x19;
|
||||
let kExprArrayNewFixedStatic = 0x1a;
|
||||
let kExprArrayNew = 0x1b;
|
||||
let kExprArrayNewDefault = 0x1c;
|
||||
let kExprArrayInitFromData = 0x1e;
|
||||
let kExprArrayInitFromDataStatic = 0x1d;
|
||||
let kExprArrayInitFromElemStatic = 0x1f;
|
||||
let kExprArrayNewData = 0x1e;
|
||||
let kExprArrayNewDataStatic = 0x1d;
|
||||
let kExprArrayNewElemStatic = 0x1f;
|
||||
let kExprI31New = 0x20;
|
||||
let kExprI31GetS = 0x21;
|
||||
let kExprI31GetU = 0x22;
|
||||
|
@ -4185,8 +4185,8 @@ TEST_F(FunctionBodyDecoderTest, GCArray) {
|
||||
sigs.i_v(),
|
||||
{WASM_ARRAY_GET(
|
||||
immutable_array_type_index,
|
||||
WASM_ARRAY_INIT(immutable_array_type_index, 1, WASM_I32V(42),
|
||||
WASM_RTT_CANON(immutable_array_type_index)),
|
||||
WASM_ARRAY_NEW_FIXED(immutable_array_type_index, 1, WASM_I32V(42),
|
||||
WASM_RTT_CANON(immutable_array_type_index)),
|
||||
WASM_I32V(0))});
|
||||
// Writing fails:
|
||||
ExpectFailure(&sig_v_r2,
|
||||
|
@ -37,10 +37,10 @@ namespace module_decoder_unittest {
|
||||
#define WASM_INIT_EXPR_GLOBAL(index) WASM_GLOBAL_GET(index), kExprEnd
|
||||
#define WASM_INIT_EXPR_STRUCT_NEW(index, ...) \
|
||||
WASM_STRUCT_NEW_WITH_RTT(index, __VA_ARGS__), kExprEnd
|
||||
#define WASM_INIT_EXPR_ARRAY_INIT(index, length, ...) \
|
||||
WASM_ARRAY_INIT(index, length, __VA_ARGS__), kExprEnd
|
||||
#define WASM_INIT_EXPR_ARRAY_INIT_STATIC(index, length, ...) \
|
||||
WASM_ARRAY_INIT_STATIC(index, length, __VA_ARGS__), kExprEnd
|
||||
#define WASM_INIT_EXPR_ARRAY_NEW_FIXED(index, length, ...) \
|
||||
WASM_ARRAY_NEW_FIXED(index, length, __VA_ARGS__), kExprEnd
|
||||
#define WASM_INIT_EXPR_ARRAY_NEW_FIXED_STATIC(index, length, ...) \
|
||||
WASM_ARRAY_NEW_FIXED_STATIC(index, length, __VA_ARGS__), kExprEnd
|
||||
#define WASM_INIT_EXPR_RTT_CANON(index) WASM_RTT_CANON(index), kExprEnd
|
||||
|
||||
#define REF_NULL_ELEMENT kExprRefNull, kFuncRefCode, kExprEnd
|
||||
@ -862,42 +862,44 @@ TEST_F(WasmModuleVerifyTest, StructNewInitExpr) {
|
||||
"rtt.canon of type (rtt 1)");
|
||||
}
|
||||
|
||||
TEST_F(WasmModuleVerifyTest, ArrayInitInitExpr) {
|
||||
TEST_F(WasmModuleVerifyTest, ArrayNewFixedInitExpr) {
|
||||
WASM_FEATURE_SCOPE(typed_funcref);
|
||||
WASM_FEATURE_SCOPE(gc);
|
||||
|
||||
static const byte basic[] = {
|
||||
SECTION(Type, ENTRY_COUNT(1), WASM_ARRAY_DEF(kI16Code, true)),
|
||||
SECTION(Global, ENTRY_COUNT(1), // --
|
||||
kRefCode, 0, 0, // type, mutability
|
||||
WASM_INIT_EXPR_ARRAY_INIT(0, 3, WASM_I32V(10), WASM_I32V(20),
|
||||
WASM_I32V(30), WASM_RTT_CANON(0)))};
|
||||
SECTION(
|
||||
Global, ENTRY_COUNT(1), // --
|
||||
kRefCode, 0, 0, // type, mutability
|
||||
WASM_INIT_EXPR_ARRAY_NEW_FIXED(0, 3, WASM_I32V(10), WASM_I32V(20),
|
||||
WASM_I32V(30), WASM_RTT_CANON(0)))};
|
||||
EXPECT_VERIFIES(basic);
|
||||
|
||||
static const byte basic_nominal[] = {
|
||||
SECTION(Type, ENTRY_COUNT(1), WASM_ARRAY_DEF(kI16Code, true)),
|
||||
SECTION(Global, ENTRY_COUNT(1), // --
|
||||
kRefCode, 0, 0, // type, mutability
|
||||
WASM_INIT_EXPR_ARRAY_INIT_STATIC(0, 3, WASM_I32V(10),
|
||||
WASM_I32V(20), WASM_I32V(30)))};
|
||||
WASM_INIT_EXPR_ARRAY_NEW_FIXED_STATIC(
|
||||
0, 3, WASM_I32V(10), WASM_I32V(20), WASM_I32V(30)))};
|
||||
EXPECT_VERIFIES(basic_nominal);
|
||||
|
||||
static const byte basic_immutable[] = {
|
||||
SECTION(Type, ENTRY_COUNT(1), WASM_ARRAY_DEF(kI32Code, false)),
|
||||
SECTION(Global, ENTRY_COUNT(1), // --
|
||||
kRefCode, 0, 0, // type, mutability
|
||||
WASM_INIT_EXPR_ARRAY_INIT(0, 3, WASM_I32V(10), WASM_I32V(20),
|
||||
WASM_I32V(30), WASM_RTT_CANON(0)))};
|
||||
SECTION(
|
||||
Global, ENTRY_COUNT(1), // --
|
||||
kRefCode, 0, 0, // type, mutability
|
||||
WASM_INIT_EXPR_ARRAY_NEW_FIXED(0, 3, WASM_I32V(10), WASM_I32V(20),
|
||||
WASM_I32V(30), WASM_RTT_CANON(0)))};
|
||||
EXPECT_VERIFIES(basic_immutable);
|
||||
|
||||
static const byte type_error[] = {
|
||||
SECTION(Type, ENTRY_COUNT(2), // --
|
||||
WASM_ARRAY_DEF(kI32Code, true),
|
||||
WASM_ARRAY_DEF(WASM_SEQ(kRefCode, 0), true)),
|
||||
SECTION(
|
||||
Global, ENTRY_COUNT(1), // --
|
||||
kRefCode, 1, 0, // type, mutability
|
||||
WASM_INIT_EXPR_ARRAY_INIT(0, 1, WASM_I32V(42), WASM_RTT_CANON(0)))};
|
||||
SECTION(Global, ENTRY_COUNT(1), // --
|
||||
kRefCode, 1, 0, // type, mutability
|
||||
WASM_INIT_EXPR_ARRAY_NEW_FIXED(0, 1, WASM_I32V(42),
|
||||
WASM_RTT_CANON(0)))};
|
||||
EXPECT_FAILURE_WITH_MSG(
|
||||
type_error,
|
||||
"type error in init. expression[0] (expected (ref 1), got (ref 0))");
|
||||
@ -906,21 +908,22 @@ TEST_F(WasmModuleVerifyTest, ArrayInitInitExpr) {
|
||||
SECTION(Type, ENTRY_COUNT(1), WASM_ARRAY_DEF(kI64Code, true)),
|
||||
SECTION(Global, ENTRY_COUNT(1), // --
|
||||
kRefCode, 0, 0, // type, mutability
|
||||
WASM_INIT_EXPR_ARRAY_INIT(0, 2, WASM_I64V(42), WASM_I32V(142),
|
||||
WASM_RTT_CANON(0)))};
|
||||
WASM_INIT_EXPR_ARRAY_NEW_FIXED(
|
||||
0, 2, WASM_I64V(42), WASM_I32V(142), WASM_RTT_CANON(0)))};
|
||||
EXPECT_FAILURE_WITH_MSG(
|
||||
subexpr_type_error,
|
||||
"array.init[1] expected type i64, found i32.const of type i32");
|
||||
"array.new_fixed[1] expected type i64, found i32.const of type i32");
|
||||
|
||||
static const byte length_error[] = {
|
||||
SECTION(Type, ENTRY_COUNT(1), WASM_ARRAY_DEF(kI16Code, true)),
|
||||
SECTION(Global, ENTRY_COUNT(1), // --
|
||||
kRefCode, 0, 0, // type, mutability
|
||||
WASM_INIT_EXPR_ARRAY_INIT(0, 10, WASM_I32V(10), WASM_I32V(20),
|
||||
WASM_I32V(30), WASM_RTT_CANON(0)))};
|
||||
SECTION(
|
||||
Global, ENTRY_COUNT(1), // --
|
||||
kRefCode, 0, 0, // type, mutability
|
||||
WASM_INIT_EXPR_ARRAY_NEW_FIXED(0, 10, WASM_I32V(10), WASM_I32V(20),
|
||||
WASM_I32V(30), WASM_RTT_CANON(0)))};
|
||||
EXPECT_FAILURE_WITH_MSG(
|
||||
length_error,
|
||||
"not enough arguments on the stack for array.init (need 11, got 4)");
|
||||
"not enough arguments on the stack for array.new_fixed (need 11, got 4)");
|
||||
}
|
||||
|
||||
TEST_F(WasmModuleVerifyTest, EmptyStruct) {
|
||||
@ -1204,7 +1207,7 @@ TEST_F(WasmModuleVerifyTest, TypeCanonicalization) {
|
||||
kWasmArrayTypeCode, kI32Code, 0),
|
||||
SECTION(Global, // --
|
||||
ENTRY_COUNT(1), kRefCode, 0, 0, // Type, mutability
|
||||
WASM_ARRAY_INIT_STATIC(1, 1, WASM_I32V(10)),
|
||||
WASM_ARRAY_NEW_FIXED_STATIC(1, 1, WASM_I32V(10)),
|
||||
kExprEnd) // Init. expression
|
||||
};
|
||||
|
||||
@ -1221,7 +1224,7 @@ TEST_F(WasmModuleVerifyTest, TypeCanonicalization) {
|
||||
kWasmStructTypeCode, ENTRY_COUNT(0)),
|
||||
SECTION(Global, // --
|
||||
ENTRY_COUNT(1), kRefCode, 0, 0, // Type, mutability
|
||||
WASM_ARRAY_INIT_STATIC(1, 1, WASM_I32V(10)),
|
||||
WASM_ARRAY_NEW_FIXED_STATIC(1, 1, WASM_I32V(10)),
|
||||
kExprEnd) // Init. expression
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user