Refine opcode br_table for classic interpreter (#1112)

Refine opcode br_table for classic interpreter as there may be a lot of
leb128 decoding when the br count is big:
1. Use the bytecode itself to store the decoded leb br depths if each
    decoded depth can be stored with one byte
2. Create br_table cache to store the decode leb br depths if the decoded
    depth cannot be stored with one byte
After the optimization, the class interpreter can access the br depths array
with index, no need to decode the leb128 again.

And fix function record_fast_op() return value unchecked issue in source
debugging feature.
This commit is contained in:
Wenyong Huang
2022-04-23 19:15:55 +08:00
committed by GitHub
parent 5f8d1428d5
commit adaaf348ed
7 changed files with 292 additions and 17 deletions

View File

@ -319,6 +319,14 @@ typedef struct StringNode {
char *str;
} StringNode, *StringList;
typedef struct BrTableCache {
struct BrTableCache *next;
/* Address of br_table opcode */
uint8 *br_table_op_addr;
uint32 br_count;
uint32 br_depths[1];
} BrTableCache;
#if WASM_ENABLE_DEBUG_INTERP != 0
typedef struct WASMFastOPCodeNode {
struct WASMFastOPCodeNode *next;
@ -326,6 +334,7 @@ typedef struct WASMFastOPCodeNode {
uint8 orig_op;
} WASMFastOPCodeNode;
#endif
struct WASMModule {
/* Module type, for module loaded from WASM bytecode binary,
this field is Wasm_Module_Bytecode;
@ -403,6 +412,10 @@ struct WASMModule {
bool possible_memory_grow;
StringList const_str_list;
#if WASM_ENABLE_FAST_INTERP == 0
bh_list br_table_cache_list_head;
bh_list *br_table_cache_list;
#endif
#if WASM_ENABLE_LIBC_WASI != 0
WASIArguments wasi_args;