mirror of
https://github.com/i-net-software/JWebAssembly.git
synced 2025-03-25 07:27:52 +01:00
optimize the memory section, write only if needed
This commit is contained in:
parent
1dd644b67a
commit
fac7e68b43
@ -194,16 +194,19 @@ public class BinaryModuleWriter extends ModuleWriter implements InstructionOpcod
|
|||||||
* if any I/O error occur
|
* if any I/O error occur
|
||||||
*/
|
*/
|
||||||
private void writeMemorySection() throws IOException {
|
private void writeMemorySection() throws IOException {
|
||||||
WasmOutputStream stream = new WasmOutputStream();
|
int dataSize = dataStream.size();
|
||||||
int pages = (dataStream.size() + 0xFFFF) / 0x10000; // a page is defined with a size of 64KiB
|
if( dataSize > 0 ) {
|
||||||
int count = 1;
|
WasmOutputStream stream = new WasmOutputStream();
|
||||||
stream.writeVaruint32( count );
|
int pages = (dataSize + 0xFFFF) / 0x10000; // a page is defined with a size of 64KiB
|
||||||
for( int i = 0; i < count; i++ ) {
|
int count = 1;
|
||||||
stream.writeVaruint32( 1 ); // flags; 1-maximum is available, 0-no maximum value available
|
stream.writeVaruint32( count );
|
||||||
stream.writeVaruint32( pages ); // initial length
|
for( int i = 0; i < count; i++ ) {
|
||||||
stream.writeVaruint32( pages ); // maximum length
|
stream.writeVaruint32( 0 ); // flags; 1-maximum is available, 0-no maximum value available
|
||||||
|
stream.writeVaruint32( pages ); // initial length
|
||||||
|
//stream.writeVaruint32( pages ); // maximum length
|
||||||
|
}
|
||||||
|
wasm.writeSection( SectionType.Memory, stream );
|
||||||
}
|
}
|
||||||
wasm.writeSection( SectionType.Memory, stream );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user