[wasm] Remove non-const arguments from interpreter
R=ahaas@chromium.org Bug: v8:9429, v8:9396 Change-Id: If26b9a480261c1625b6844b05de5323648ab34b6 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1687544 Reviewed-by: Andreas Haas <ahaas@chromium.org> Commit-Queue: Clemens Hammacher <clemensh@chromium.org> Cr-Commit-Position: refs/heads/master@{#62625}
This commit is contained in:
parent
f41d3a9b89
commit
3a8e6fb72f
@ -1665,8 +1665,7 @@ class ThreadImpl {
|
|||||||
|
|
||||||
template <typename ctype, typename mtype>
|
template <typename ctype, typename mtype>
|
||||||
bool ExecuteLoad(Decoder* decoder, InterpreterCode* code, pc_t pc,
|
bool ExecuteLoad(Decoder* decoder, InterpreterCode* code, pc_t pc,
|
||||||
int& len, // NOLINT(runtime/references)
|
int* const len, MachineRepresentation rep) {
|
||||||
MachineRepresentation rep) {
|
|
||||||
MemoryAccessImmediate<Decoder::kNoValidate> imm(decoder, code->at(pc),
|
MemoryAccessImmediate<Decoder::kNoValidate> imm(decoder, code->at(pc),
|
||||||
sizeof(ctype));
|
sizeof(ctype));
|
||||||
uint32_t index = Pop().to<uint32_t>();
|
uint32_t index = Pop().to<uint32_t>();
|
||||||
@ -1679,7 +1678,7 @@ class ThreadImpl {
|
|||||||
converter<ctype, mtype>{}(ReadLittleEndianValue<mtype>(addr)));
|
converter<ctype, mtype>{}(ReadLittleEndianValue<mtype>(addr)));
|
||||||
|
|
||||||
Push(result);
|
Push(result);
|
||||||
len = 1 + imm.length;
|
*len = 1 + imm.length;
|
||||||
|
|
||||||
if (FLAG_trace_wasm_memory) {
|
if (FLAG_trace_wasm_memory) {
|
||||||
MemoryTracingInfo info(imm.offset + index, false, rep);
|
MemoryTracingInfo info(imm.offset + index, false, rep);
|
||||||
@ -1693,8 +1692,7 @@ class ThreadImpl {
|
|||||||
|
|
||||||
template <typename ctype, typename mtype>
|
template <typename ctype, typename mtype>
|
||||||
bool ExecuteStore(Decoder* decoder, InterpreterCode* code, pc_t pc,
|
bool ExecuteStore(Decoder* decoder, InterpreterCode* code, pc_t pc,
|
||||||
int& len, // NOLINT(runtime/references)
|
int* const len, MachineRepresentation rep) {
|
||||||
MachineRepresentation rep) {
|
|
||||||
MemoryAccessImmediate<Decoder::kNoValidate> imm(decoder, code->at(pc),
|
MemoryAccessImmediate<Decoder::kNoValidate> imm(decoder, code->at(pc),
|
||||||
sizeof(ctype));
|
sizeof(ctype));
|
||||||
ctype val = Pop().to<ctype>();
|
ctype val = Pop().to<ctype>();
|
||||||
@ -1706,7 +1704,7 @@ class ThreadImpl {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
WriteLittleEndianValue<mtype>(addr, converter<mtype, ctype>{}(val));
|
WriteLittleEndianValue<mtype>(addr, converter<mtype, ctype>{}(val));
|
||||||
len = 1 + imm.length;
|
*len = 1 + imm.length;
|
||||||
|
|
||||||
if (FLAG_trace_wasm_memory) {
|
if (FLAG_trace_wasm_memory) {
|
||||||
MemoryTracingInfo info(imm.offset + index, true, rep);
|
MemoryTracingInfo info(imm.offset + index, true, rep);
|
||||||
@ -1738,26 +1736,24 @@ class ThreadImpl {
|
|||||||
|
|
||||||
template <typename type, typename op_type>
|
template <typename type, typename op_type>
|
||||||
bool ExtractAtomicOpParams(Decoder* decoder, InterpreterCode* code,
|
bool ExtractAtomicOpParams(Decoder* decoder, InterpreterCode* code,
|
||||||
Address& address, // NOLINT(runtime/references)
|
Address* address, pc_t pc, int* const len,
|
||||||
pc_t pc, int& len, // NOLINT(runtime/references)
|
|
||||||
type* val = nullptr, type* val2 = nullptr) {
|
type* val = nullptr, type* val2 = nullptr) {
|
||||||
MemoryAccessImmediate<Decoder::kNoValidate> imm(decoder, code->at(pc + 1),
|
MemoryAccessImmediate<Decoder::kNoValidate> imm(decoder, code->at(pc + 1),
|
||||||
sizeof(type));
|
sizeof(type));
|
||||||
if (val2) *val2 = static_cast<type>(Pop().to<op_type>());
|
if (val2) *val2 = static_cast<type>(Pop().to<op_type>());
|
||||||
if (val) *val = static_cast<type>(Pop().to<op_type>());
|
if (val) *val = static_cast<type>(Pop().to<op_type>());
|
||||||
uint32_t index = Pop().to<uint32_t>();
|
uint32_t index = Pop().to<uint32_t>();
|
||||||
address = BoundsCheckMem<type>(imm.offset, index);
|
*address = BoundsCheckMem<type>(imm.offset, index);
|
||||||
if (!address) {
|
if (!address) {
|
||||||
DoTrap(kTrapMemOutOfBounds, pc);
|
DoTrap(kTrapMemOutOfBounds, pc);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
len = 2 + imm.length;
|
*len = 2 + imm.length;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ExecuteNumericOp(WasmOpcode opcode, Decoder* decoder,
|
bool ExecuteNumericOp(WasmOpcode opcode, Decoder* decoder,
|
||||||
InterpreterCode* code, pc_t pc,
|
InterpreterCode* code, pc_t pc, int* const len) {
|
||||||
int& len) { // NOLINT(runtime/references)
|
|
||||||
switch (opcode) {
|
switch (opcode) {
|
||||||
case kExprI32SConvertSatF32:
|
case kExprI32SConvertSatF32:
|
||||||
Push(WasmValue(ExecuteConvertSaturate<int32_t>(Pop().to<float>())));
|
Push(WasmValue(ExecuteConvertSaturate<int32_t>(Pop().to<float>())));
|
||||||
@ -1786,7 +1782,7 @@ class ThreadImpl {
|
|||||||
case kExprMemoryInit: {
|
case kExprMemoryInit: {
|
||||||
MemoryInitImmediate<Decoder::kNoValidate> imm(decoder, code->at(pc));
|
MemoryInitImmediate<Decoder::kNoValidate> imm(decoder, code->at(pc));
|
||||||
DCHECK_LT(imm.data_segment_index, module()->num_declared_data_segments);
|
DCHECK_LT(imm.data_segment_index, module()->num_declared_data_segments);
|
||||||
len += imm.length;
|
*len += imm.length;
|
||||||
if (!CheckDataSegmentIsPassiveAndNotDropped(imm.data_segment_index,
|
if (!CheckDataSegmentIsPassiveAndNotDropped(imm.data_segment_index,
|
||||||
pc)) {
|
pc)) {
|
||||||
return false;
|
return false;
|
||||||
@ -1809,7 +1805,7 @@ class ThreadImpl {
|
|||||||
}
|
}
|
||||||
case kExprDataDrop: {
|
case kExprDataDrop: {
|
||||||
DataDropImmediate<Decoder::kNoValidate> imm(decoder, code->at(pc));
|
DataDropImmediate<Decoder::kNoValidate> imm(decoder, code->at(pc));
|
||||||
len += imm.length;
|
*len += imm.length;
|
||||||
if (!CheckDataSegmentIsPassiveAndNotDropped(imm.index, pc)) {
|
if (!CheckDataSegmentIsPassiveAndNotDropped(imm.index, pc)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1835,7 +1831,7 @@ class ThreadImpl {
|
|||||||
memory_copy_wrapper(dst_addr, src_addr, size);
|
memory_copy_wrapper(dst_addr, src_addr, size);
|
||||||
}
|
}
|
||||||
if (!ok) DoTrap(kTrapMemOutOfBounds, pc);
|
if (!ok) DoTrap(kTrapMemOutOfBounds, pc);
|
||||||
len += imm.length;
|
*len += imm.length;
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
case kExprMemoryFill: {
|
case kExprMemoryFill: {
|
||||||
@ -1848,12 +1844,12 @@ class ThreadImpl {
|
|||||||
bool ok = BoundsCheckMemRange(dst, &size, &dst_addr);
|
bool ok = BoundsCheckMemRange(dst, &size, &dst_addr);
|
||||||
memory_fill_wrapper(dst_addr, value, size);
|
memory_fill_wrapper(dst_addr, value, size);
|
||||||
if (!ok) DoTrap(kTrapMemOutOfBounds, pc);
|
if (!ok) DoTrap(kTrapMemOutOfBounds, pc);
|
||||||
len += imm.length;
|
*len += imm.length;
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
case kExprTableInit: {
|
case kExprTableInit: {
|
||||||
TableInitImmediate<Decoder::kNoValidate> imm(decoder, code->at(pc));
|
TableInitImmediate<Decoder::kNoValidate> imm(decoder, code->at(pc));
|
||||||
len += imm.length;
|
*len += imm.length;
|
||||||
if (!CheckElemSegmentIsPassiveAndNotDropped(imm.elem_segment_index,
|
if (!CheckElemSegmentIsPassiveAndNotDropped(imm.elem_segment_index,
|
||||||
pc)) {
|
pc)) {
|
||||||
return false;
|
return false;
|
||||||
@ -1870,7 +1866,7 @@ class ThreadImpl {
|
|||||||
}
|
}
|
||||||
case kExprElemDrop: {
|
case kExprElemDrop: {
|
||||||
ElemDropImmediate<Decoder::kNoValidate> imm(decoder, code->at(pc));
|
ElemDropImmediate<Decoder::kNoValidate> imm(decoder, code->at(pc));
|
||||||
len += imm.length;
|
*len += imm.length;
|
||||||
if (!CheckElemSegmentIsPassiveAndNotDropped(imm.index, pc)) {
|
if (!CheckElemSegmentIsPassiveAndNotDropped(imm.index, pc)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1887,7 +1883,7 @@ class ThreadImpl {
|
|||||||
isolate_, instance_object_, imm.table_dst.index,
|
isolate_, instance_object_, imm.table_dst.index,
|
||||||
imm.table_src.index, dst, src, size);
|
imm.table_src.index, dst, src, size);
|
||||||
if (!ok) DoTrap(kTrapTableOutOfBounds, pc);
|
if (!ok) DoTrap(kTrapTableOutOfBounds, pc);
|
||||||
len += imm.length;
|
*len += imm.length;
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
case kExprTableGrow: {
|
case kExprTableGrow: {
|
||||||
@ -1901,7 +1897,7 @@ class ThreadImpl {
|
|||||||
auto value = Pop().to_anyref();
|
auto value = Pop().to_anyref();
|
||||||
int32_t result = WasmTableObject::Grow(isolate_, table, delta, value);
|
int32_t result = WasmTableObject::Grow(isolate_, table, delta, value);
|
||||||
Push(WasmValue(result));
|
Push(WasmValue(result));
|
||||||
len += imm.length;
|
*len += imm.length;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case kExprTableSize: {
|
case kExprTableSize: {
|
||||||
@ -1913,7 +1909,7 @@ class ThreadImpl {
|
|||||||
isolate_);
|
isolate_);
|
||||||
uint32_t table_size = table->current_length();
|
uint32_t table_size = table->current_length();
|
||||||
Push(WasmValue(table_size));
|
Push(WasmValue(table_size));
|
||||||
len += imm.length;
|
*len += imm.length;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -1947,8 +1943,7 @@ class ThreadImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ExecuteAtomicOp(WasmOpcode opcode, Decoder* decoder,
|
bool ExecuteAtomicOp(WasmOpcode opcode, Decoder* decoder,
|
||||||
InterpreterCode* code, pc_t pc,
|
InterpreterCode* code, pc_t pc, int* const len) {
|
||||||
int& len) { // NOLINT(runtime/references)
|
|
||||||
#if V8_TARGET_BIG_ENDIAN
|
#if V8_TARGET_BIG_ENDIAN
|
||||||
constexpr bool kBigEndian = true;
|
constexpr bool kBigEndian = true;
|
||||||
#else
|
#else
|
||||||
@ -1961,7 +1956,7 @@ class ThreadImpl {
|
|||||||
type val; \
|
type val; \
|
||||||
Address addr; \
|
Address addr; \
|
||||||
op_type result; \
|
op_type result; \
|
||||||
if (!ExtractAtomicOpParams<type, op_type>(decoder, code, addr, pc, len, \
|
if (!ExtractAtomicOpParams<type, op_type>(decoder, code, &addr, pc, len, \
|
||||||
&val)) { \
|
&val)) { \
|
||||||
return false; \
|
return false; \
|
||||||
} \
|
} \
|
||||||
@ -2045,7 +2040,7 @@ class ThreadImpl {
|
|||||||
type old_val; \
|
type old_val; \
|
||||||
type new_val; \
|
type new_val; \
|
||||||
Address addr; \
|
Address addr; \
|
||||||
if (!ExtractAtomicOpParams<type, op_type>(decoder, code, addr, pc, len, \
|
if (!ExtractAtomicOpParams<type, op_type>(decoder, code, &addr, pc, len, \
|
||||||
&old_val, &new_val)) { \
|
&old_val, &new_val)) { \
|
||||||
return false; \
|
return false; \
|
||||||
} \
|
} \
|
||||||
@ -2077,7 +2072,8 @@ class ThreadImpl {
|
|||||||
#define ATOMIC_LOAD_CASE(name, type, op_type, operation) \
|
#define ATOMIC_LOAD_CASE(name, type, op_type, operation) \
|
||||||
case kExpr##name: { \
|
case kExpr##name: { \
|
||||||
Address addr; \
|
Address addr; \
|
||||||
if (!ExtractAtomicOpParams<type, op_type>(decoder, code, addr, pc, len)) { \
|
if (!ExtractAtomicOpParams<type, op_type>(decoder, code, &addr, pc, \
|
||||||
|
len)) { \
|
||||||
return false; \
|
return false; \
|
||||||
} \
|
} \
|
||||||
static_assert(sizeof(std::atomic<type>) == sizeof(type), \
|
static_assert(sizeof(std::atomic<type>) == sizeof(type), \
|
||||||
@ -2100,7 +2096,7 @@ class ThreadImpl {
|
|||||||
case kExpr##name: { \
|
case kExpr##name: { \
|
||||||
type val; \
|
type val; \
|
||||||
Address addr; \
|
Address addr; \
|
||||||
if (!ExtractAtomicOpParams<type, op_type>(decoder, code, addr, pc, len, \
|
if (!ExtractAtomicOpParams<type, op_type>(decoder, code, &addr, pc, len, \
|
||||||
&val)) { \
|
&val)) { \
|
||||||
return false; \
|
return false; \
|
||||||
} \
|
} \
|
||||||
@ -2155,7 +2151,7 @@ class ThreadImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ExecuteSimdOp(WasmOpcode opcode, Decoder* decoder, InterpreterCode* code,
|
bool ExecuteSimdOp(WasmOpcode opcode, Decoder* decoder, InterpreterCode* code,
|
||||||
pc_t pc, int& len) { // NOLINT(runtime/references)
|
pc_t pc, int* const len) {
|
||||||
switch (opcode) {
|
switch (opcode) {
|
||||||
#define SPLAT_CASE(format, sType, valType, num) \
|
#define SPLAT_CASE(format, sType, valType, num) \
|
||||||
case kExpr##format##Splat: { \
|
case kExpr##format##Splat: { \
|
||||||
@ -2176,7 +2172,7 @@ class ThreadImpl {
|
|||||||
#define EXTRACT_LANE_CASE(format, name) \
|
#define EXTRACT_LANE_CASE(format, name) \
|
||||||
case kExpr##format##ExtractLane: { \
|
case kExpr##format##ExtractLane: { \
|
||||||
SimdLaneImmediate<Decoder::kNoValidate> imm(decoder, code->at(pc)); \
|
SimdLaneImmediate<Decoder::kNoValidate> imm(decoder, code->at(pc)); \
|
||||||
++len; \
|
*len += 1; \
|
||||||
WasmValue val = Pop(); \
|
WasmValue val = Pop(); \
|
||||||
Simd128 s = val.to_s128(); \
|
Simd128 s = val.to_s128(); \
|
||||||
auto ss = s.to_##name(); \
|
auto ss = s.to_##name(); \
|
||||||
@ -2355,7 +2351,7 @@ class ThreadImpl {
|
|||||||
#define REPLACE_LANE_CASE(format, name, stype, ctype) \
|
#define REPLACE_LANE_CASE(format, name, stype, ctype) \
|
||||||
case kExpr##format##ReplaceLane: { \
|
case kExpr##format##ReplaceLane: { \
|
||||||
SimdLaneImmediate<Decoder::kNoValidate> imm(decoder, code->at(pc)); \
|
SimdLaneImmediate<Decoder::kNoValidate> imm(decoder, code->at(pc)); \
|
||||||
++len; \
|
*len += 1; \
|
||||||
WasmValue new_val = Pop(); \
|
WasmValue new_val = Pop(); \
|
||||||
WasmValue simd_val = Pop(); \
|
WasmValue simd_val = Pop(); \
|
||||||
stype s = simd_val.to_s128().to_##name(); \
|
stype s = simd_val.to_s128().to_##name(); \
|
||||||
@ -2378,7 +2374,7 @@ class ThreadImpl {
|
|||||||
#define SHIFT_CASE(op, name, stype, count, expr) \
|
#define SHIFT_CASE(op, name, stype, count, expr) \
|
||||||
case kExpr##op: { \
|
case kExpr##op: { \
|
||||||
SimdShiftImmediate<Decoder::kNoValidate> imm(decoder, code->at(pc)); \
|
SimdShiftImmediate<Decoder::kNoValidate> imm(decoder, code->at(pc)); \
|
||||||
++len; \
|
*len += 1; \
|
||||||
WasmValue v = Pop(); \
|
WasmValue v = Pop(); \
|
||||||
stype s = v.to_s128().to_##name(); \
|
stype s = v.to_s128().to_##name(); \
|
||||||
stype res; \
|
stype res; \
|
||||||
@ -2515,7 +2511,7 @@ class ThreadImpl {
|
|||||||
case kExprS8x16Shuffle: {
|
case kExprS8x16Shuffle: {
|
||||||
Simd8x16ShuffleImmediate<Decoder::kNoValidate> imm(decoder,
|
Simd8x16ShuffleImmediate<Decoder::kNoValidate> imm(decoder,
|
||||||
code->at(pc));
|
code->at(pc));
|
||||||
len += 16;
|
*len += 16;
|
||||||
int16 v2 = Pop().to_s128().to_i8x16();
|
int16 v2 = Pop().to_s128().to_i8x16();
|
||||||
int16 v1 = Pop().to_s128().to_i8x16();
|
int16 v1 = Pop().to_s128().to_i8x16();
|
||||||
int16 res;
|
int16 res;
|
||||||
@ -3250,7 +3246,7 @@ class ThreadImpl {
|
|||||||
}
|
}
|
||||||
#define LOAD_CASE(name, ctype, mtype, rep) \
|
#define LOAD_CASE(name, ctype, mtype, rep) \
|
||||||
case kExpr##name: { \
|
case kExpr##name: { \
|
||||||
if (!ExecuteLoad<ctype, mtype>(&decoder, code, pc, len, \
|
if (!ExecuteLoad<ctype, mtype>(&decoder, code, pc, &len, \
|
||||||
MachineRepresentation::rep)) \
|
MachineRepresentation::rep)) \
|
||||||
return; \
|
return; \
|
||||||
break; \
|
break; \
|
||||||
@ -3274,7 +3270,7 @@ class ThreadImpl {
|
|||||||
|
|
||||||
#define STORE_CASE(name, ctype, mtype, rep) \
|
#define STORE_CASE(name, ctype, mtype, rep) \
|
||||||
case kExpr##name: { \
|
case kExpr##name: { \
|
||||||
if (!ExecuteStore<ctype, mtype>(&decoder, code, pc, len, \
|
if (!ExecuteStore<ctype, mtype>(&decoder, code, pc, &len, \
|
||||||
MachineRepresentation::rep)) \
|
MachineRepresentation::rep)) \
|
||||||
return; \
|
return; \
|
||||||
break; \
|
break; \
|
||||||
@ -3391,16 +3387,16 @@ class ThreadImpl {
|
|||||||
}
|
}
|
||||||
case kNumericPrefix: {
|
case kNumericPrefix: {
|
||||||
++len;
|
++len;
|
||||||
if (!ExecuteNumericOp(opcode, &decoder, code, pc, len)) return;
|
if (!ExecuteNumericOp(opcode, &decoder, code, pc, &len)) return;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case kAtomicPrefix: {
|
case kAtomicPrefix: {
|
||||||
if (!ExecuteAtomicOp(opcode, &decoder, code, pc, len)) return;
|
if (!ExecuteAtomicOp(opcode, &decoder, code, pc, &len)) return;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case kSimdPrefix: {
|
case kSimdPrefix: {
|
||||||
++len;
|
++len;
|
||||||
if (!ExecuteSimdOp(opcode, &decoder, code, pc, len)) return;
|
if (!ExecuteSimdOp(opcode, &decoder, code, pc, &len)) return;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user