Enhance wasm loader and interpreter, enhance code security and update document (#149)

This commit is contained in:
wenyongh
2019-12-13 15:30:30 +08:00
committed by GitHub
parent 1c81ad6da5
commit 631b7a2403
45 changed files with 678 additions and 646 deletions

View File

@ -0,0 +1,20 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef WAMR_GRAPHIC_LIBRARY_H
#define WAMR_GRAPHIC_LIBRARY_H
#ifdef __cplusplus
extern "C" {
#endif
void wgl_init(void);
void wgl_exit(void);
#ifdef __cplusplus
}
#endif
#endif /* WAMR_GRAPHIC_LIBRARY_H */

View File

@ -1,4 +1,7 @@
/*
* Copyright (C) 2019 Intel Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
*/
#ifndef WAMR_GRAPHIC_LIBRARY_NATIVE_UTILS_H
#define WAMR_GRAPHIC_LIBRARY_NATIVE_UTILS_H

View File

@ -9,6 +9,7 @@
#include "bh_list.h"
#include "bh_thread.h"
#include "wgl_native_utils.h"
#include "wgl.h"
typedef struct {
@ -36,6 +37,8 @@ static bh_list g_object_list;
static korp_mutex g_object_list_mutex;
static bool lv_task_handler_thread_run = true;
static void app_mgr_object_event_callback(module_data *m_data, bh_message_t msg)
{
uint32 argv[2];
@ -62,8 +65,10 @@ static void app_mgr_object_event_callback(module_data *m_data, bh_message_t msg)
argv[0] = object_event->obj_id;
argv[1] = object_event->event;
if (!wasm_runtime_call_wasm(inst, NULL, func_on_object_event, 2, argv)) {
const char *exception = wasm_runtime_get_exception(inst);
bh_assert(exception);
printf(":Got exception running wasm code: %s\n",
wasm_runtime_get_exception(inst));
exception);
wasm_runtime_clear_exception(inst);
return;
}
@ -270,11 +275,13 @@ static void* lv_task_handler_thread_routine (void *arg)
vm_sem_init(&sem, 0);
while (true) {
while (lv_task_handler_thread_run) {
vm_sem_reltimedwait(&sem, 100);
lv_task_handler();
}
vm_sem_destroy(&sem);
return NULL;
}
@ -295,6 +302,11 @@ void wgl_init(void)
BH_APPLET_PRESERVED_STACK_SIZE);
}
void wgl_exit(void)
{
lv_task_handler_thread_run = false;
}
/* -------------------------------------------------------------------------
* Obj native function wrappers
* -------------------------------------------------------------------------*/