@@ -810,14 +810,15 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
810
810
read_leb_uint32(p, p_end, cur_value.global_index);
811
811
global_idx = cur_value.global_index;
812
812
813
- #if WASM_ENABLE_GC == 0
813
+ /*
814
+ * Currently, constant expressions occurring as initializers
815
+ * of globals are further constrained in that contained
816
+ * global.get instructions are
817
+ * only allowed to refer to imported globals.
818
+ *
819
+ * https://webassembly.github.io/spec/core/valid/instructions.html#constant-expressions
820
+ */
814
821
if (global_idx >= module->import_global_count) {
815
- /**
816
- * Currently, constant expressions occurring as initializers
817
- * of globals are further constrained in that contained
818
- * global.get instructions are
819
- * only allowed to refer to imported globals.
820
- */
821
822
set_error_buf_v(error_buf, error_buf_size,
822
823
"unknown global %u", global_idx);
823
824
goto fail;
@@ -827,20 +828,6 @@ load_init_expr(WASMModule *module, const uint8 **p_buf, const uint8 *buf_end,
827
828
"constant expression required");
828
829
goto fail;
829
830
}
830
- #else
831
- if (global_idx
832
- >= module->import_global_count + module->global_count) {
833
- set_error_buf_v(error_buf, error_buf_size,
834
- "unknown global %u", global_idx);
835
- goto fail;
836
- }
837
- if (global_idx < module->import_global_count
838
- && module->import_globals[global_idx].u.global.is_mutable) {
839
- set_error_buf_v(error_buf, error_buf_size,
840
- "constant expression required");
841
- goto fail;
842
- }
843
- #endif
844
831
845
832
if (global_idx < module->import_global_count) {
846
833
global_type =
0 commit comments