summaryrefslogtreecommitdiff
path: root/src/binary-reader-opcnt.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/binary-reader-opcnt.c')
-rw-r--r--src/binary-reader-opcnt.c102
1 files changed, 51 insertions, 51 deletions
diff --git a/src/binary-reader-opcnt.c b/src/binary-reader-opcnt.c
index 8d184e70..0a3a3035 100644
--- a/src/binary-reader-opcnt.c
+++ b/src/binary-reader-opcnt.c
@@ -27,117 +27,117 @@
#include "common.h"
typedef struct Context {
- WasmAllocator* allocator;
- WasmOpcntData* opcnt_data;
+ WabtAllocator* allocator;
+ WabtOpcntData* opcnt_data;
} Context;
-static WasmResult add_int_counter_value(struct WasmAllocator* allocator,
- WasmIntCounterVector* vec,
+static WabtResult add_int_counter_value(struct WabtAllocator* allocator,
+ WabtIntCounterVector* vec,
intmax_t value) {
size_t i;
for (i = 0; i < vec->size; ++i) {
if (vec->data[i].value == value) {
++vec->data[i].count;
- return WASM_OK;
+ return WABT_OK;
}
}
- WasmIntCounter counter;
+ WabtIntCounter counter;
counter.value = value;
counter.count = 1;
- wasm_append_int_counter_value(allocator, vec, &counter);
- return WASM_OK;
+ wabt_append_int_counter_value(allocator, vec, &counter);
+ return WABT_OK;
}
-static WasmResult add_int_pair_counter_value(struct WasmAllocator* allocator,
- WasmIntPairCounterVector* vec,
+static WabtResult add_int_pair_counter_value(struct WabtAllocator* allocator,
+ WabtIntPairCounterVector* vec,
intmax_t first, intmax_t second) {
size_t i;
for (i = 0; i < vec->size; ++i) {
if (vec->data[i].first == first && vec->data[i].second == second) {
++vec->data[i].count;
- return WASM_OK;
+ return WABT_OK;
}
}
- WasmIntPairCounter counter;
+ WabtIntPairCounter counter;
counter.first = first;
counter.second = second;
counter.count = 1;
- wasm_append_int_pair_counter_value(allocator, vec, &counter);
- return WASM_OK;
+ wabt_append_int_pair_counter_value(allocator, vec, &counter);
+ return WABT_OK;
}
-static WasmResult on_opcode(WasmBinaryReaderContext* context,
- WasmOpcode opcode) {
+static WabtResult on_opcode(WabtBinaryReaderContext* context,
+ WabtOpcode opcode) {
Context* ctx = context->user_data;
- WasmIntCounterVector* opcnt_vec = &ctx->opcnt_data->opcode_vec;
+ WabtIntCounterVector* opcnt_vec = &ctx->opcnt_data->opcode_vec;
while (opcode >= opcnt_vec->size) {
- WasmIntCounter Counter;
+ WabtIntCounter Counter;
Counter.value = opcnt_vec->size;
Counter.count = 0;
- wasm_append_int_counter_value(ctx->opcnt_data->allocator,
+ wabt_append_int_counter_value(ctx->opcnt_data->allocator,
opcnt_vec, &Counter);
}
++opcnt_vec->data[opcode].count;
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_i32_const_expr(uint32_t value, void* user_data) {
+static WabtResult on_i32_const_expr(uint32_t value, void* user_data) {
Context* ctx = user_data;
return add_int_counter_value(ctx->opcnt_data->allocator,
&ctx->opcnt_data->i32_const_vec, (int32_t)value);
}
-static WasmResult on_get_local_expr(uint32_t local_index, void* user_data) {
+static WabtResult on_get_local_expr(uint32_t local_index, void* user_data) {
Context* ctx = user_data;
return add_int_counter_value(ctx->opcnt_data->allocator,
&ctx->opcnt_data->get_local_vec, local_index);
}
-static WasmResult on_set_local_expr(uint32_t local_index, void* user_data) {
+static WabtResult on_set_local_expr(uint32_t local_index, void* user_data) {
Context* ctx = user_data;
return add_int_counter_value(ctx->opcnt_data->allocator,
&ctx->opcnt_data->set_local_vec, local_index);
}
-static WasmResult on_tee_local_expr(uint32_t local_index, void* user_data) {
+static WabtResult on_tee_local_expr(uint32_t local_index, void* user_data) {
Context* ctx = user_data;
return add_int_counter_value(ctx->opcnt_data->allocator,
&ctx->opcnt_data->tee_local_vec, local_index);
}
-static WasmResult on_load_expr(WasmOpcode opcode,
+static WabtResult on_load_expr(WabtOpcode opcode,
uint32_t alignment_log2,
uint32_t offset,
void* user_data) {
Context* ctx = user_data;
- if (opcode == WASM_OPCODE_I32_LOAD)
+ if (opcode == WABT_OPCODE_I32_LOAD)
return add_int_pair_counter_value(ctx->opcnt_data->allocator,
&ctx->opcnt_data->i32_load_vec,
alignment_log2, offset);
- return WASM_OK;
+ return WABT_OK;
}
-static WasmResult on_store_expr(WasmOpcode opcode,
+static WabtResult on_store_expr(WabtOpcode opcode,
uint32_t alignment_log2,
uint32_t offset,
void* user_data) {
Context* ctx = user_data;
- if (opcode == WASM_OPCODE_I32_STORE)
+ if (opcode == WABT_OPCODE_I32_STORE)
return add_int_pair_counter_value(ctx->opcnt_data->allocator,
&ctx->opcnt_data->i32_store_vec,
alignment_log2, offset);
- return WASM_OK;
+ return WABT_OK;
}
-static void on_error(WasmBinaryReaderContext* ctx, const char* message) {
- WasmDefaultErrorHandlerInfo info;
+static void on_error(WabtBinaryReaderContext* ctx, const char* message) {
+ WabtDefaultErrorHandlerInfo info;
info.header = "error reading binary";
info.out_file = stdout;
- info.print_header = WASM_PRINT_ERROR_HEADER_ONCE;
- wasm_default_binary_error_callback(ctx->offset, message, &info);
+ info.print_header = WABT_PRINT_ERROR_HEADER_ONCE;
+ wabt_default_binary_error_callback(ctx->offset, message, &info);
}
-static WasmBinaryReader s_binary_reader = {
+static WabtBinaryReader s_binary_reader = {
.user_data = NULL,
.on_error = on_error,
.on_opcode = on_opcode,
@@ -149,36 +149,36 @@ static WasmBinaryReader s_binary_reader = {
.on_store_expr = on_store_expr
};
-void wasm_init_opcnt_data(struct WasmAllocator* allocator,
- WasmOpcntData* data) {
- WASM_ZERO_MEMORY(*data);
+void wabt_init_opcnt_data(struct WabtAllocator* allocator,
+ WabtOpcntData* data) {
+ WABT_ZERO_MEMORY(*data);
data->allocator = allocator;
}
-void wasm_destroy_opcnt_data(struct WasmAllocator* allocator,
- WasmOpcntData* data) {
+void wabt_destroy_opcnt_data(struct WabtAllocator* allocator,
+ WabtOpcntData* data) {
assert(allocator == data->allocator);
- wasm_destroy_int_counter_vector(allocator, &data->opcode_vec);
- wasm_destroy_int_counter_vector(allocator, &data->i32_const_vec);
- wasm_destroy_int_counter_vector(allocator, &data->get_local_vec);
- wasm_destroy_int_pair_counter_vector(allocator, &data->i32_load_vec);
+ wabt_destroy_int_counter_vector(allocator, &data->opcode_vec);
+ wabt_destroy_int_counter_vector(allocator, &data->i32_const_vec);
+ wabt_destroy_int_counter_vector(allocator, &data->get_local_vec);
+ wabt_destroy_int_pair_counter_vector(allocator, &data->i32_load_vec);
}
-WasmResult wasm_read_binary_opcnt(struct WasmAllocator* allocator,
+WabtResult wabt_read_binary_opcnt(struct WabtAllocator* allocator,
const void* data,
size_t size,
- const struct WasmReadBinaryOptions* options,
- WasmOpcntData* opcnt_data) {
+ const struct WabtReadBinaryOptions* options,
+ WabtOpcntData* opcnt_data) {
Context ctx;
- WASM_ZERO_MEMORY(ctx);
+ WABT_ZERO_MEMORY(ctx);
ctx.allocator = allocator;
ctx.opcnt_data = opcnt_data;
- WasmBinaryReader reader;
- WASM_ZERO_MEMORY(reader);
+ WabtBinaryReader reader;
+ WABT_ZERO_MEMORY(reader);
reader = s_binary_reader;
reader.user_data = &ctx;
- return wasm_read_binary(allocator, data, size, &reader, 1, options);
+ return wabt_read_binary(allocator, data, size, &reader, 1, options);
}