CC="gcc"
WARNINGS='-Wimplicit -Wmisleading-indentation -Wparentheses -Wsequence-point -Wreturn-type -Wshift-negative-value -Wunused-but-set-parameter -Wunused-but-set-variable -Wunused-function -Wunused-label -Wmaybe-uninitialized -Wsign-compare -Wstrict-overflow -Wduplicated-branches -Wduplicated-cond -Wtrigraphs -Waddress -Wlogical-op'
-FLAGS="-g3"
+FLAGS="-O3"
LIBS="-pthread"
INCLUDES="-I include"
TARGET="libonyx_embedder.so"
#ifdef BH_STATIC
#define BH_DEF static
#else
- #define BH_DEF
+ #ifdef BH_INTERNAL
+ #define BH_DEF __attribute__((visibility("hidden")))
+ #else
+ #define BH_DEF
+ #endif
#endif
// NOTE: For lseek64
u64 size = 64;
u8 byte;
- while (1) {
+ do {
byte = bytes[(*byte_count)++];
res |= (byte & 0x7f) << shift;
- if ((byte & 0x80) == 0) break;
shift += 7;
- }
+ } while ((byte & 0x80) != 0);
if ((shift < size) && (byte & 0x40) != 0) {
- return res | ((~(u64) 0x0) << shift);
+ i64 zero_shifted = ~ 0x0;
+ zero_shifted = zero_shifted << shift;
+ return res | zero_shifted;
}
return res;
static inline int NEXT_VALUE(ovm_code_builder_t *b) {
#if defined(BUILDER_DEBUG)
b->highest_value_number += 1;
- return b->highest_value_number;
+ return b->highest_value_number - 1;
#else
if (bh_arr_length(b->execution_stack) == 0) {
case OVMI_MOV:
VAL(instr.r) = VAL(instr.a);
+ // printf("$%d = %lx\n", instr.r, VAL(instr.r).u64);
break;
#define OVM_LOAD(type_, stype) \
i32 fidx = func_idx; \
ovm_func_t *func = &program->funcs[fidx]; \
i32 extra_params = bh_arr_length(state->params) - func->param_count; \
+ assert(extra_params >= 0); \
if (func->kind == OVM_FUNC_INTERNAL) { \
ovm__func_setup_stack_frame(engine, state, program, fidx, instr.r); \
\
#define BH_DEFINE
#define BH_NO_TABLE
+#define BH_INTERNAL
#define STB_DS_IMPLEMENTATION
#include "bh.h"
#include "stb_ds.h"
}
case 0x42: {
- unsigned long long value = uleb128_to_uint(ctx->binary.data, &ctx->offset);
+ long long value = leb128_to_int(ctx->binary.data, &ctx->offset);
ovm_code_builder_add_imm(&ctx->builder, OVM_TYPE_I64, &value);
break;
}