diff options
-rwxr-xr-x | test/run-spec-wasm2c.py | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/test/run-spec-wasm2c.py b/test/run-spec-wasm2c.py index 8c7ec8fc..9e4d3f2b 100755 --- a/test/run-spec-wasm2c.py +++ b/test/run-spec-wasm2c.py @@ -33,6 +33,7 @@ SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) WASM2C_DIR = os.path.join(find_exe.REPO_ROOT_DIR, 'wasm2c') IS_WINDOWS = sys.platform == 'win32' IS_MACOS = platform.mac_ver()[0] != '' +MAX_COMMANDS_PER_FUNCTION = 1024 # GCC has trouble with extremely long function bodies def ReinterpretF32(f32_bits): @@ -129,11 +130,20 @@ class CWriter(object): def Write(self): self._WriteIncludes() self.out_file.write(self.prefix) - self.out_file.write("\nvoid run_spec_tests(void) {\n\n") - for command in self.commands: + self._WriteModuleInstances() + test_function_num = 0 + self.out_file.write('\nvoid run_spec_tests_0(void) {\n\n') + for i, command in enumerate(self.commands): self._WriteCommand(command) + if i % MAX_COMMANDS_PER_FUNCTION == MAX_COMMANDS_PER_FUNCTION - 1: + test_function_num += 1 + self.out_file.write('\n}\n\nvoid run_spec_tests_%d(void) {\n\n' % test_function_num) + + self.out_file.write('\n}\n\nvoid run_spec_tests(void) {\n\n') + for i in range(test_function_num + 1): + self.out_file.write('run_spec_tests_%d();\n' % i) self._WriteModuleCleanUps() - self.out_file.write("\n}\n") + self.out_file.write('\n}\n') def GetModuleFilenames(self): return [c['filename'] for c in self.commands if IsModuleCommand(c)] @@ -147,7 +157,7 @@ class CWriter(object): return self.unmangled_names[idx] def GetModuleInstanceName(self, idx_or_name=None): - return self.GetModulePrefix() + '_instance' + return self.GetModulePrefix(idx_or_name) + '_instance' def _CacheModulePrefixes(self): idx = 0 @@ -243,9 +253,15 @@ class CWriter(object): def _WriteModuleCommand(self, command): self.module_idx += 1 self.out_file.write('%s_init_module();\n' % self.GetModulePrefix()) - self.out_file.write('%s_instance_t %s;\n' % (self.GetModulePrefix(), self.GetModuleInstanceName())) self._WriteModuleInitCall(command, False) + def _WriteModuleInstances(self): + idx = 0 + for command in self.commands: + if IsModuleCommand(command): + self.out_file.write('%s_instance_t %s;\n' % (self.GetModulePrefix(idx), self.GetModuleInstanceName(idx))) + idx += 1 + def _WriteModuleCleanUps(self): for idx in range(self.module_idx): self.out_file.write("%s_free(&%s_instance);\n" % (self.GetModulePrefix(idx), self.GetModulePrefix(idx))) @@ -253,7 +269,6 @@ class CWriter(object): def _WriteAssertUninstantiableCommand(self, command): self.module_idx += 1 self.out_file.write('%s_init_module();\n' % self.GetModulePrefix()) - self.out_file.write('%s_instance_t %s;\n' % (self.GetModulePrefix(), self.GetModuleInstanceName())) self._WriteModuleInitCall(command, True) def _WriteActionCommand(self, command): |