wasm_runtime.wasm_extern_as_func = &wasm_extern_as_func;
wasm_runtime.wasm_func_call = &wasm_func_call;
wasm_runtime.wasm_instance_new = &wasm_instance_new;
+ wasm_runtime.wasm_instance_delete = &wasm_instance_delete;
wasm_runtime.wasm_store_new = &wasm_store_new;
wasm_runtime.wasm_store_delete = &wasm_store_delete;
wasm_runtime.onyx_print_trap = &onyx_print_trap;
. ../settings.sh
-# FLAGS="-g3 -DOVM_DEBUG=1 -fno-stack-protector"
+# FLAGS="-g3 -O2 -DOVM_DEBUG=1 -fno-stack-protector"
# FLAGS="-g3 -DOVM_VERBOSE=1"
FLAGS="-Ofast -fno-stack-protector"
LIBS="-pthread"
ovm_value_t *__frame_values;
debug_thread_state_t *debug;
+ i32 call_depth;
};
ovm_state_t *ovm_state_new(ovm_engine_t *engine, ovm_program_t *program);
#define EVT_NOP 0
#define EVT_BRK_HIT 1
#define EVT_PAUSE 2
-#define EVT_NEW_THREAD 3 // Not Implemented
#define EVT_RESPONSE 0xffffffff
struct msg_parse_ctx_t {
while (debug->debug_thread_running) {
poll(poll_fds, 2, 1000);
+ //
+ // If there are no functions on the main thread,
+ // assume the program has exited and do not continue to
+ // do anything.
+ if (debug->threads[0]->ovm_state->call_depth <= 0) {
+ debug->debug_thread_running = false;
+ break;
+ }
+
//
// Try to read commands from the client.
// If an error was returned, bail out of this thread.
ovm_func_t *func = &program->funcs[func_idx];
ovm_assert(func->value_number_count >= func->param_count);
+ state->call_depth += 1;
+
switch (func->kind) {
case OVM_FUNC_INTERNAL: {
ovm__func_setup_stack_frame(state, func, 0);
state->pc = func->start_instr;
ovm_value_t result = ovm_run_code(engine, state, program);
+ state->call_depth -= 1;
return result;
}
external_func.native_func(external_func.userdata, params, &result);
ovm__func_teardown_stack_frame(state);
+
+ state->call_depth -= 1;
return result;
}
"onyxFiles": {
"type": "array",
"description": "The Onyx files for compiling.",
- "default": "[]"
+ "default": []
},
"workingDir": {
"type": "string",
trap = runtime->wasm_func_call(exit_func, &args_array, &results);
}
+ runtime->wasm_instance_delete(thread->instance);
runtime->wasm_store_delete(wasm_store);
return 0;
// for this function to exist, yet.
wasm_table_t *wasm_func_table;
void (*(*wasm_func_from_idx)(wasm_table_t *table, unsigned int index, char *signature))(void);
+
+ void (*wasm_instance_delete)(wasm_instance_t *instance);
} OnyxRuntime;
OnyxRuntime* runtime;