diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/shared-validator.cc | 9 | ||||
-rw-r--r-- | src/type-checker.cc | 12 |
2 files changed, 15 insertions, 6 deletions
diff --git a/src/shared-validator.cc b/src/shared-validator.cc index 0bff3266..efbd02f8 100644 --- a/src/shared-validator.cc +++ b/src/shared-validator.cc @@ -909,10 +909,11 @@ Result SharedValidator::OnMemoryCopy(const Location& loc, Var srcmemidx, Var destmemidx) { Result result = CheckInstr(Opcode::MemoryCopy, loc); - MemoryType mt; - result |= CheckMemoryIndex(srcmemidx, &mt); - result |= CheckMemoryIndex(destmemidx, &mt); - result |= typechecker_.OnMemoryCopy(mt.limits); + MemoryType srcmt; + MemoryType dstmt; + result |= CheckMemoryIndex(srcmemidx, &srcmt); + result |= CheckMemoryIndex(destmemidx, &dstmt); + result |= typechecker_.OnMemoryCopy(srcmt.limits, dstmt.limits); return result; } diff --git a/src/type-checker.cc b/src/type-checker.cc index aadcfd01..e02ca260 100644 --- a/src/type-checker.cc +++ b/src/type-checker.cc @@ -706,8 +706,16 @@ Result TypeChecker::OnLoop(const TypeVector& param_types, return result; } -Result TypeChecker::OnMemoryCopy(const Limits& limits) { - return CheckOpcode3(Opcode::MemoryCopy, &limits, &limits, &limits); +Result TypeChecker::OnMemoryCopy(const Limits& src_limits, + const Limits& dst_limits) { + Limits size_limits = src_limits; + // The memory64 proposal specifies that the type of the size argument should + // be the mimimum of the two memory types. + if (src_limits.is_64 && !dst_limits.is_64) { + size_limits = dst_limits; + } + return CheckOpcode3(Opcode::MemoryCopy, &src_limits, &dst_limits, + &size_limits); } Result TypeChecker::OnDataDrop(uint32_t segment) { |