Skip to content

Commit c6693dd

Browse files
phatedospencer
andauthored
chore(compiler)!: Remove memory import from _genv (#1830)
* chore(compiler)!: Remove memory import from `_genv` * reorder memory import * keep the name from this branch * Update snapshots --------- Co-authored-by: Oscar Spencer <oscar@grain-lang.org>
1 parent 9bd7412 commit c6693dd

File tree

345 files changed

+346
-347
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

345 files changed

+346
-347
lines changed

compiler/src/codegen/compcore.re

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3278,7 +3278,6 @@ let compile_imports = (wasm_mod, env, {imports}) => {
32783278
);
32793279

32803280
List.iter(compile_import, imports);
3281-
Import.add_memory_import(wasm_mod, "mem", grain_env_mod, "mem", false);
32823281
Import.add_table_import(
32833282
wasm_mod,
32843283
grain_global_function_table,

compiler/src/linking/link.re

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -655,9 +655,6 @@ let link_all = (linked_mod, dependencies, signature) => {
655655
Type.funcref,
656656
);
657657

658-
if (Config.import_memory^) {
659-
Import.add_memory_import(linked_mod, "memory", "env", "memory", false);
660-
};
661658
let (initial_memory, maximum_memory) =
662659
switch (Config.initial_memory_pages^, Config.maximum_memory_pages^) {
663660
| (initial_memory, Some(maximum_memory)) => (
@@ -693,6 +690,9 @@ let link_all = (linked_mod, dependencies, signature) => {
693690
data_segments,
694691
false,
695692
);
693+
if (Config.import_memory^) {
694+
Import.add_memory_import(linked_mod, "memory", "env", "memory", false);
695+
};
696696

697697
let starts =
698698
List.filter_map(

compiler/test/__snapshots__/arrays.0f9e7d37.0.snapshot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ arrays › array_access
33
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
44
(type $none_=>_i32 (func (result i32)))
55
(type $none_=>_none (func))
6-
(import \"_genv\" \"mem\" (memory $0 0))
76
(import \"_genv\" \"tbl\" (table $tbl 0 funcref))
87
(import \"_genv\" \"relocBase\" (global $relocBase_0 i32))
98
(import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32))
@@ -16,6 +15,7 @@ arrays › array_access
1615
(import \"GRAIN$MODULE$runtime/exception\" \"panicWithException\" (func $panicWithException_0 (param i32 i32) (result i32)))
1716
(global $x_1113 (mut i32) (i32.const 0))
1817
(global $GRAIN$TABLE_SIZE i32 (i32.const 0))
18+
(memory $0 0)
1919
(elem $elem (global.get $relocBase_0))
2020
(export \"memory\" (memory $0))
2121
(export \"_gmain\" (func $_gmain))

compiler/test/__snapshots__/arrays.1deb7b51.0.snapshot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ arrays › array_access5
33
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
44
(type $none_=>_i32 (func (result i32)))
55
(type $none_=>_none (func))
6-
(import \"_genv\" \"mem\" (memory $0 0))
76
(import \"_genv\" \"tbl\" (table $tbl 0 funcref))
87
(import \"_genv\" \"relocBase\" (global $relocBase_0 i32))
98
(import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32))
@@ -17,6 +16,7 @@ arrays › array_access5
1716
(import \"GRAIN$MODULE$runtime/gc\" \"decRef\" (func $decRef_0 (param i32 i32) (result i32)))
1817
(import \"GRAIN$MODULE$runtime/exception\" \"panicWithException\" (func $panicWithException_0 (param i32 i32) (result i32)))
1918
(global $GRAIN$TABLE_SIZE i32 (i32.const 0))
19+
(memory $0 0)
2020
(elem $elem (global.get $relocBase_0))
2121
(export \"memory\" (memory $0))
2222
(export \"_gmain\" (func $_gmain))

compiler/test/__snapshots__/arrays.24453e6e.0.snapshot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ arrays › array1_trailing
33
(type $none_=>_i32 (func (result i32)))
44
(type $none_=>_none (func))
55
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
6-
(import \"_genv\" \"mem\" (memory $0 0))
76
(import \"_genv\" \"tbl\" (table $tbl 0 funcref))
87
(import \"_genv\" \"relocBase\" (global $relocBase_0 i32))
98
(import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32))
109
(import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32))
1110
(import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32)))
1211
(import \"GRAIN$MODULE$runtime/gc\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32)))
1312
(global $GRAIN$TABLE_SIZE i32 (i32.const 0))
13+
(memory $0 0)
1414
(elem $elem (global.get $relocBase_0))
1515
(export \"memory\" (memory $0))
1616
(export \"_gmain\" (func $_gmain))

compiler/test/__snapshots__/arrays.28fcc534.0.snapshot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ arrays › array_access4
33
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
44
(type $none_=>_i32 (func (result i32)))
55
(type $none_=>_none (func))
6-
(import \"_genv\" \"mem\" (memory $0 0))
76
(import \"_genv\" \"tbl\" (table $tbl 0 funcref))
87
(import \"_genv\" \"relocBase\" (global $relocBase_0 i32))
98
(import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32))
@@ -16,6 +15,7 @@ arrays › array_access4
1615
(import \"GRAIN$MODULE$runtime/exception\" \"panicWithException\" (func $panicWithException_0 (param i32 i32) (result i32)))
1716
(global $x_1113 (mut i32) (i32.const 0))
1817
(global $GRAIN$TABLE_SIZE i32 (i32.const 0))
18+
(memory $0 0)
1919
(elem $elem (global.get $relocBase_0))
2020
(export \"memory\" (memory $0))
2121
(export \"_gmain\" (func $_gmain))

compiler/test/__snapshots__/arrays.4c8c9f91.0.snapshot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ arrays › array_access2
33
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
44
(type $none_=>_i32 (func (result i32)))
55
(type $none_=>_none (func))
6-
(import \"_genv\" \"mem\" (memory $0 0))
76
(import \"_genv\" \"tbl\" (table $tbl 0 funcref))
87
(import \"_genv\" \"relocBase\" (global $relocBase_0 i32))
98
(import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32))
@@ -16,6 +15,7 @@ arrays › array_access2
1615
(import \"GRAIN$MODULE$runtime/exception\" \"panicWithException\" (func $panicWithException_0 (param i32 i32) (result i32)))
1716
(global $x_1113 (mut i32) (i32.const 0))
1817
(global $GRAIN$TABLE_SIZE i32 (i32.const 0))
18+
(memory $0 0)
1919
(elem $elem (global.get $relocBase_0))
2020
(export \"memory\" (memory $0))
2121
(export \"_gmain\" (func $_gmain))

compiler/test/__snapshots__/arrays.6eac4e1f.0.snapshot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ arrays › array_access3
33
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
44
(type $none_=>_i32 (func (result i32)))
55
(type $none_=>_none (func))
6-
(import \"_genv\" \"mem\" (memory $0 0))
76
(import \"_genv\" \"tbl\" (table $tbl 0 funcref))
87
(import \"_genv\" \"relocBase\" (global $relocBase_0 i32))
98
(import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32))
@@ -16,6 +15,7 @@ arrays › array_access3
1615
(import \"GRAIN$MODULE$runtime/exception\" \"panicWithException\" (func $panicWithException_0 (param i32 i32) (result i32)))
1716
(global $x_1113 (mut i32) (i32.const 0))
1817
(global $GRAIN$TABLE_SIZE i32 (i32.const 0))
18+
(memory $0 0)
1919
(elem $elem (global.get $relocBase_0))
2020
(export \"memory\" (memory $0))
2121
(export \"_gmain\" (func $_gmain))

compiler/test/__snapshots__/arrays.74d79181.0.snapshot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ arrays › array_access5
33
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
44
(type $none_=>_i32 (func (result i32)))
55
(type $none_=>_none (func))
6-
(import \"_genv\" \"mem\" (memory $0 0))
76
(import \"_genv\" \"tbl\" (table $tbl 0 funcref))
87
(import \"_genv\" \"relocBase\" (global $relocBase_0 i32))
98
(import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32))
@@ -16,6 +15,7 @@ arrays › array_access5
1615
(import \"GRAIN$MODULE$runtime/exception\" \"panicWithException\" (func $panicWithException_0 (param i32 i32) (result i32)))
1716
(global $x_1113 (mut i32) (i32.const 0))
1817
(global $GRAIN$TABLE_SIZE i32 (i32.const 0))
18+
(memory $0 0)
1919
(elem $elem (global.get $relocBase_0))
2020
(export \"memory\" (memory $0))
2121
(export \"_gmain\" (func $_gmain))

compiler/test/__snapshots__/arrays.9e17b4d1.0.snapshot

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ arrays › array3
33
(type $none_=>_i32 (func (result i32)))
44
(type $none_=>_none (func))
55
(type $i32_i32_=>_i32 (func (param i32 i32) (result i32)))
6-
(import \"_genv\" \"mem\" (memory $0 0))
76
(import \"_genv\" \"tbl\" (table $tbl 0 funcref))
87
(import \"_genv\" \"relocBase\" (global $relocBase_0 i32))
98
(import \"_genv\" \"moduleRuntimeId\" (global $moduleRuntimeId_0 i32))
109
(import \"_genv\" \"runtimeHeapStart\" (global $runtimeHeapStart_0 i32))
1110
(import \"GRAIN$MODULE$runtime/gc\" \"GRAIN$EXPORT$malloc\" (global $GRAIN$EXPORT$malloc_0 (mut i32)))
1211
(import \"GRAIN$MODULE$runtime/gc\" \"malloc\" (func $malloc_0 (param i32 i32) (result i32)))
1312
(global $GRAIN$TABLE_SIZE i32 (i32.const 0))
13+
(memory $0 0)
1414
(elem $elem (global.get $relocBase_0))
1515
(export \"memory\" (memory $0))
1616
(export \"_gmain\" (func $_gmain))

0 commit comments

Comments
 (0)