[dart2wasm] Fix memory definition.

Size is number of 64kb pages.

Change-Id: I4c2876ebee553d0dc219e8dd8bb6b1169799a465
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/257260
Commit-Queue: Joshua Litt <joshualitt@google.com>
Reviewed-by: Aske Simon Christensen <askesc@google.com>
This commit is contained in:
Joshua Litt 2022-09-06 18:25:36 +00:00 committed by Commit Bot
parent 6484fa91ab
commit f0ab6fb6ef
2 changed files with 6 additions and 3 deletions

View file

@ -175,8 +175,8 @@ class Constants {
..add(oneByteStringsAsBytes))
.toBytes();
w.Memory stringMemory =
m.addMemory(false, stringsAsBytes.length, stringsAsBytes.length);
double minSize = stringsAsBytes.length / w.Module.memoryBlockSize;
w.Memory stringMemory = m.addMemory(false, minSize.ceil(), minSize.ceil());
m.addDataSegment(stringsAsBytes, stringMemory, 0);
makeStringFunctionBody(translator.oneByteStringClass, oneByteStringFunction,
(b) {

View file

@ -35,6 +35,8 @@ class Module with SerializerMixin {
int functionNameCount = 0;
static const int memoryBlockSize = 0x10000;
/// Create a new, initially empty, module.
///
/// The [watchPoints] is a list of byte offsets within the final module of
@ -170,7 +172,8 @@ class Module with SerializerMixin {
initialContent ??= Uint8List(0);
assert((memory != null) == (offset != null));
assert(memory == null ||
offset! >= 0 && offset + initialContent.length <= memory.minSize);
offset! >= 0 &&
offset + initialContent.length <= memory.minSize * memoryBlockSize);
final DataSegment data =
DataSegment(dataSegments.length, initialContent, memory, offset);
dataSegments.add(data);