mirror of
https://github.com/dart-lang/sdk
synced 2024-09-04 16:03:44 +00:00
[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:
parent
6484fa91ab
commit
f0ab6fb6ef
|
@ -175,8 +175,8 @@ class Constants {
|
||||||
..add(oneByteStringsAsBytes))
|
..add(oneByteStringsAsBytes))
|
||||||
.toBytes();
|
.toBytes();
|
||||||
|
|
||||||
w.Memory stringMemory =
|
double minSize = stringsAsBytes.length / w.Module.memoryBlockSize;
|
||||||
m.addMemory(false, stringsAsBytes.length, stringsAsBytes.length);
|
w.Memory stringMemory = m.addMemory(false, minSize.ceil(), minSize.ceil());
|
||||||
m.addDataSegment(stringsAsBytes, stringMemory, 0);
|
m.addDataSegment(stringsAsBytes, stringMemory, 0);
|
||||||
makeStringFunctionBody(translator.oneByteStringClass, oneByteStringFunction,
|
makeStringFunctionBody(translator.oneByteStringClass, oneByteStringFunction,
|
||||||
(b) {
|
(b) {
|
||||||
|
|
|
@ -35,6 +35,8 @@ class Module with SerializerMixin {
|
||||||
|
|
||||||
int functionNameCount = 0;
|
int functionNameCount = 0;
|
||||||
|
|
||||||
|
static const int memoryBlockSize = 0x10000;
|
||||||
|
|
||||||
/// Create a new, initially empty, module.
|
/// Create a new, initially empty, module.
|
||||||
///
|
///
|
||||||
/// The [watchPoints] is a list of byte offsets within the final module of
|
/// The [watchPoints] is a list of byte offsets within the final module of
|
||||||
|
@ -170,7 +172,8 @@ class Module with SerializerMixin {
|
||||||
initialContent ??= Uint8List(0);
|
initialContent ??= Uint8List(0);
|
||||||
assert((memory != null) == (offset != null));
|
assert((memory != null) == (offset != null));
|
||||||
assert(memory == null ||
|
assert(memory == null ||
|
||||||
offset! >= 0 && offset + initialContent.length <= memory.minSize);
|
offset! >= 0 &&
|
||||||
|
offset + initialContent.length <= memory.minSize * memoryBlockSize);
|
||||||
final DataSegment data =
|
final DataSegment data =
|
||||||
DataSegment(dataSegments.length, initialContent, memory, offset);
|
DataSegment(dataSegments.length, initialContent, memory, offset);
|
||||||
dataSegments.add(data);
|
dataSegments.add(data);
|
||||||
|
|
Loading…
Reference in a new issue