[wasm][memory64] Test executing memory.size
This fixes typing (and type conversions) in the two compilers and adds a test for executing a memory.size instruction in memory64. R=manoskouk@chromium.org Bug: v8:10949 Change-Id: Ic06b224437cb818ad74d0732fc4c8e08c9095231 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2632594 Commit-Queue: Clemens Backes <clemensb@chromium.org> Reviewed-by: Manos Koukoutos <manoskouk@chromium.org> Cr-Commit-Position: refs/heads/master@{#72219}
This commit is contained in:
parent
c86110789f
commit
e6cfe142c9
@ -3353,6 +3353,11 @@ Node* WasmGraphBuilder::BuildChangeInt32ToIntPtr(Node* value) {
|
||||
: value;
|
||||
}
|
||||
|
||||
Node* WasmGraphBuilder::BuildChangeIntPtrToInt64(Node* value) {
|
||||
return mcgraph()->machine()->Is32() ? gasm_->ChangeInt32ToInt64(value)
|
||||
: value;
|
||||
}
|
||||
|
||||
Node* WasmGraphBuilder::BuildChangeInt32ToSmi(Node* value) {
|
||||
// With pointer compression, only the lower 32 bits are used.
|
||||
return COMPRESS_POINTERS_BOOL
|
||||
@ -3626,9 +3631,9 @@ Node* WasmGraphBuilder::CurrentMemoryPages() {
|
||||
Node* mem_size = instance_cache_->mem_size;
|
||||
DCHECK_NOT_NULL(mem_size);
|
||||
Node* result =
|
||||
graph()->NewNode(mcgraph()->machine()->WordShr(), mem_size,
|
||||
mcgraph()->Int32Constant(wasm::kWasmPageSizeLog2));
|
||||
result = BuildTruncateIntPtrToInt32(result);
|
||||
gasm_->WordShr(mem_size, gasm_->Int32Constant(wasm::kWasmPageSizeLog2));
|
||||
result = env_->module->is_memory64 ? BuildChangeIntPtrToInt64(result)
|
||||
: BuildTruncateIntPtrToInt32(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -589,6 +589,7 @@ class WasmGraphBuilder {
|
||||
|
||||
Node* BuildTruncateIntPtrToInt32(Node* value);
|
||||
Node* BuildChangeInt32ToIntPtr(Node* value);
|
||||
Node* BuildChangeIntPtrToInt64(Node* value);
|
||||
Node* BuildChangeInt32ToSmi(Node* value);
|
||||
Node* BuildChangeUint31ToSmi(Node* value);
|
||||
Node* BuildSmiShiftBitsConstant();
|
||||
|
@ -2613,11 +2613,19 @@ class LiftoffCompiler {
|
||||
unsupported(decoder, kSimd, "simd load lane");
|
||||
}
|
||||
|
||||
void CurrentMemoryPages(FullDecoder* decoder, Value* result) {
|
||||
void CurrentMemoryPages(FullDecoder* /* decoder */, Value* /* result */) {
|
||||
Register mem_size = __ GetUnusedRegister(kGpReg, {}).gp();
|
||||
LOAD_INSTANCE_FIELD(mem_size, MemorySize, kSystemPointerSize);
|
||||
__ emit_ptrsize_shri(mem_size, mem_size, kWasmPageSizeLog2);
|
||||
__ PushRegister(kWasmI32, LiftoffRegister(mem_size));
|
||||
LiftoffRegister result{mem_size};
|
||||
if (env_->module->is_memory64 && kNeedI64RegPair) {
|
||||
LiftoffRegister high_word =
|
||||
__ GetUnusedRegister(kGpReg, LiftoffRegList::ForRegs(mem_size));
|
||||
// The high word is always 0 on 32-bit systems.
|
||||
__ LoadConstant(high_word, WasmValue{uint32_t{0}});
|
||||
result = LiftoffRegister::ForPair(mem_size, high_word.gp());
|
||||
}
|
||||
__ PushRegister(env_->module->is_memory64 ? kWasmI64 : kWasmI32, result);
|
||||
}
|
||||
|
||||
void MemoryGrow(FullDecoder* decoder, const Value& value, Value* result_val) {
|
||||
|
@ -85,6 +85,19 @@ WASM_EXEC_TEST(InitExpression) {
|
||||
}
|
||||
}
|
||||
|
||||
WASM_EXEC_TEST(MemorySize) {
|
||||
// TODO(clemensb): Implement memory64 in the interpreter.
|
||||
if (execution_tier == TestExecutionTier::kInterpreter) return;
|
||||
|
||||
Memory64Runner<uint64_t> r(execution_tier);
|
||||
constexpr int kNumPages = 13;
|
||||
r.builder().AddMemoryElems<uint8_t>(kNumPages * kWasmPageSize);
|
||||
|
||||
BUILD(r, WASM_MEMORY_SIZE);
|
||||
|
||||
CHECK_EQ(kNumPages, r.Call());
|
||||
}
|
||||
|
||||
} // namespace wasm
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
Loading…
Reference in New Issue
Block a user