|
|
|
|
@@ -184,13 +184,12 @@ struct Call_Frame{
|
|
|
|
|
Call_Frame *previous_call;
|
|
|
|
|
Instruction *saved_instruction_pointer;
|
|
|
|
|
Register_Index first_register_index_in_window;
|
|
|
|
|
Register_Index register_where_you_write_return_value;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct Bc{
|
|
|
|
|
U32 dis; // @debug_ids
|
|
|
|
|
|
|
|
|
|
U8 *stack_bottom;
|
|
|
|
|
U8 *stack_base;
|
|
|
|
|
U8 *stack_pointer;
|
|
|
|
|
U8 *stack_top;
|
|
|
|
|
|
|
|
|
|
@@ -225,6 +224,8 @@ allocate_register(Bc *b){
|
|
|
|
|
|
|
|
|
|
function void
|
|
|
|
|
release_register(Bc *b, Register_Index reg){
|
|
|
|
|
if(reg == -1) return;
|
|
|
|
|
|
|
|
|
|
B32 found = false;
|
|
|
|
|
For(b->used_registers){
|
|
|
|
|
if(it == reg){
|
|
|
|
|
@@ -306,6 +307,7 @@ emit_load_constant(Bc *b, Token *pos, Register_Index dst, Value value){
|
|
|
|
|
CASE_UINT: i->constant.u64 = bigint_as_unsigned(&value.big_int_val); break;
|
|
|
|
|
CASE_SINT: i->constant.s64 = bigint_as_signed(&value.big_int_val); break;
|
|
|
|
|
CASE_FLOAT: i->constant.f64 = value.f64_val; break;
|
|
|
|
|
case TYPE_TYPE: i->constant.u64 = value.type_val->type_id; break;
|
|
|
|
|
invalid_default_case;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -313,6 +315,16 @@ emit_load_constant(Bc *b, Token *pos, Register_Index dst, Value value){
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function Instruction *
|
|
|
|
|
emit_load_constant_address(Bc *b, Token *pos, Register_Index dst, void *address){
|
|
|
|
|
auto i = new_instruction(b, pos);
|
|
|
|
|
i->operation = BC_LOAD_CONSTANT;
|
|
|
|
|
i->index_c = dst;
|
|
|
|
|
i->constant.u64 = (U64)address;
|
|
|
|
|
i->debug_type_flag = TYPE_POINTER;
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function void
|
|
|
|
|
emit_push(Bc *b, Token *pos, Register_Index src){
|
|
|
|
|
auto i = new_instruction(b, pos);
|
|
|
|
|
@@ -364,11 +376,11 @@ bc_stack_push_size(Bc *b, U64 size){
|
|
|
|
|
function Call_Frame *
|
|
|
|
|
bc_push_call_frame(Bc *b, Register_Index function_address_register){
|
|
|
|
|
auto call = bc_stack_push(b, Call_Frame);
|
|
|
|
|
call->first_register_index_in_window = function_address_register + 1;
|
|
|
|
|
call->register_where_you_write_return_value = function_address_register;
|
|
|
|
|
call->first_register_index_in_window = function_address_register;
|
|
|
|
|
call->previous_call = b->top_call;
|
|
|
|
|
call->saved_instruction_pointer = 0;
|
|
|
|
|
|
|
|
|
|
b->stack_pointer = b->stack_base = (U8 *)(call+1);
|
|
|
|
|
b->top_call = call;
|
|
|
|
|
return call;
|
|
|
|
|
}
|
|
|
|
|
@@ -376,7 +388,7 @@ bc_push_call_frame(Bc *b, Register_Index function_address_register){
|
|
|
|
|
function void
|
|
|
|
|
run_bytecode_interp(Bc *b){
|
|
|
|
|
b->instruction_pointer = (Instruction *)b->instructions.memory.data;
|
|
|
|
|
b->stack_pointer = b->stack_bottom = b->stack.memory.data;
|
|
|
|
|
b->stack_pointer = b->stack_base = b->stack.memory.data;
|
|
|
|
|
b->stack_top = (b->stack.memory.data + b->stack.len);
|
|
|
|
|
bc_push_call_frame(b, 0);
|
|
|
|
|
|
|
|
|
|
@@ -386,7 +398,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
#if BC_ASSERTS
|
|
|
|
|
print_token_line(instr->debug_pos);
|
|
|
|
|
assert_msg(b->stack_pointer < b->stack_top, "Bytecode stack overflow");
|
|
|
|
|
assert_msg(b->stack_pointer >= b->stack_bottom, "Bytecode stack underflow");
|
|
|
|
|
assert_msg(b->stack_pointer >= b->stack_base, "Bytecode stack underflow");
|
|
|
|
|
assert_msg(b->top_call->first_register_index_in_window < b->registers.cap, "Bytecode interpreter bug, register pointer is pointing over last possible register");
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
@@ -435,6 +447,8 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
Call_Frame *prev = call->previous_call;
|
|
|
|
|
assert(prev);
|
|
|
|
|
|
|
|
|
|
b->stack_base = (U8 *)(prev + 1);
|
|
|
|
|
b->stack_pointer = (U8 *)call;
|
|
|
|
|
b->top_call = prev;
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
@@ -498,7 +512,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
S64 right = R(instr->index_b).s64;
|
|
|
|
|
S64 result = left + right;
|
|
|
|
|
R(instr->index_c).s64 = result;
|
|
|
|
|
bc_log("[r%s, %lld] + [r%s, %lld] = [r%s, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %lld] + [r%d, %lld] = [r%d, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_SUB_S64:{
|
|
|
|
|
@@ -506,7 +520,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
S64 right = R(instr->index_b).s64;
|
|
|
|
|
S64 result = left - right;
|
|
|
|
|
R(instr->index_c).s64 = result;
|
|
|
|
|
bc_log("[r%s, %lld] - [r%s, %lld] = [r%s, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %lld] - [r%d, %lld] = [r%d, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_DIV_S64:{
|
|
|
|
|
@@ -514,7 +528,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
S64 right = R(instr->index_b).s64;
|
|
|
|
|
S64 result = left / right;
|
|
|
|
|
R(instr->index_c).s64 = result;
|
|
|
|
|
bc_log("[r%s, %lld] / [r%s, %lld] = [r%s, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %lld] / [r%d, %lld] = [r%d, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_MUL_S64:{
|
|
|
|
|
@@ -522,7 +536,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
S64 right = R(instr->index_b).s64;
|
|
|
|
|
S64 result = left * right;
|
|
|
|
|
R(instr->index_c).s64 = result;
|
|
|
|
|
bc_log("[r%s, %lld] * [r%s, %lld] = [r%s, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %lld] * [r%d, %lld] = [r%d, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_MOD_S64:{
|
|
|
|
|
@@ -530,7 +544,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
S64 right = R(instr->index_b).s64;
|
|
|
|
|
S64 result = left % right;
|
|
|
|
|
R(instr->index_c).s64 = result;
|
|
|
|
|
bc_log("[r%s, %lld] % [r%s, %lld] = [r%s, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %lld] % [r%d, %lld] = [r%d, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_SHR_S64:{
|
|
|
|
|
@@ -538,7 +552,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
S64 right = R(instr->index_b).s64;
|
|
|
|
|
S64 result = left >> right;
|
|
|
|
|
R(instr->index_c).s64 = result;
|
|
|
|
|
bc_log("[r%s, %lld] >> [r%s, %lld] = [r%s, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %lld] >> [r%d, %lld] = [r%d, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_SHL_S64:{
|
|
|
|
|
@@ -546,7 +560,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
S64 right = R(instr->index_b).s64;
|
|
|
|
|
S64 result = left << right;
|
|
|
|
|
R(instr->index_c).s64 = result;
|
|
|
|
|
bc_log("[r%s, %lld] << [r%s, %lld] = [r%s, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %lld] << [r%d, %lld] = [r%d, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_BITAND_S64:{
|
|
|
|
|
@@ -554,7 +568,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
S64 right = R(instr->index_b).s64;
|
|
|
|
|
S64 result = left & right;
|
|
|
|
|
R(instr->index_c).s64 = result;
|
|
|
|
|
bc_log("[r%s, %lld] & [r%s, %lld] = [r%s, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %lld] & [r%d, %lld] = [r%d, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_BITOR_S64:{
|
|
|
|
|
@@ -562,7 +576,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
S64 right = R(instr->index_b).s64;
|
|
|
|
|
S64 result = left | right;
|
|
|
|
|
R(instr->index_c).s64 = result;
|
|
|
|
|
bc_log("[r%s, %lld] | [r%s, %lld] = [r%s, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %lld] | [r%d, %lld] = [r%d, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_BITXOR_S64:{
|
|
|
|
|
@@ -570,7 +584,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
S64 right = R(instr->index_b).s64;
|
|
|
|
|
S64 result = left ^ right;
|
|
|
|
|
R(instr->index_c).s64 = result;
|
|
|
|
|
bc_log("[r%s, %lld] ^ [r%s, %lld] = [r%s, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %lld] ^ [r%d, %lld] = [r%d, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_BITNOT_S64:{
|
|
|
|
|
@@ -586,7 +600,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
S64 right = R(instr->index_b).s64;
|
|
|
|
|
S64 result = left == right;
|
|
|
|
|
R(instr->index_c).s64 = result;
|
|
|
|
|
bc_log("[r%s, %lld] == [r%s, %lld] = [r%s, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %lld] == [r%d, %lld] = [r%d, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_NEQ_S64:{
|
|
|
|
|
@@ -594,7 +608,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
S64 right = R(instr->index_b).s64;
|
|
|
|
|
S64 result = left != right;
|
|
|
|
|
R(instr->index_c).s64 = result;
|
|
|
|
|
bc_log("[r%s, %lld] != [r%s, %lld] = [r%s, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %lld] != [r%d, %lld] = [r%d, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_GT_S64:{
|
|
|
|
|
@@ -602,7 +616,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
S64 right = R(instr->index_b).s64;
|
|
|
|
|
S64 result = left > right;
|
|
|
|
|
R(instr->index_c).s64 = result;
|
|
|
|
|
bc_log("[r%s, %lld] > [r%s, %lld] = [r%s, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %lld] > [r%d, %lld] = [r%d, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_LT_S64:{
|
|
|
|
|
@@ -610,7 +624,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
S64 right = R(instr->index_b).s64;
|
|
|
|
|
S64 result = left < right;
|
|
|
|
|
R(instr->index_c).s64 = result;
|
|
|
|
|
bc_log("[r%s, %lld] < [r%s, %lld] = [r%s, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %lld] < [r%d, %lld] = [r%d, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_OR_S64:{
|
|
|
|
|
@@ -618,7 +632,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
S64 right = R(instr->index_b).s64;
|
|
|
|
|
S64 result = left || right;
|
|
|
|
|
R(instr->index_c).s64 = result;
|
|
|
|
|
bc_log("[r%s, %lld] || [r%s, %lld] = [r%s, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %lld] || [r%d, %lld] = [r%d, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_GTE_S64:{
|
|
|
|
|
@@ -626,7 +640,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
S64 right = R(instr->index_b).s64;
|
|
|
|
|
S64 result = left >= right;
|
|
|
|
|
R(instr->index_c).s64 = result;
|
|
|
|
|
bc_log("[r%s, %lld] >= [r%s, %lld] = [r%s, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %lld] >= [r%d, %lld] = [r%d, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_LTE_S64:{
|
|
|
|
|
@@ -634,7 +648,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
S64 right = R(instr->index_b).s64;
|
|
|
|
|
S64 result = left <= right;
|
|
|
|
|
R(instr->index_c).s64 = result;
|
|
|
|
|
bc_log("[r%s, %lld] <= [r%s, %lld] = [r%s, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %lld] <= [r%d, %lld] = [r%d, %lld]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_ADD_U64:{
|
|
|
|
|
@@ -642,7 +656,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
U64 right = R(instr->index_b).u64;
|
|
|
|
|
U64 result = left + right;
|
|
|
|
|
R(instr->index_c).u64 = result;
|
|
|
|
|
bc_log("[r%s, %llu] + [r%s, %llu] = [r%s, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %llu] + [r%d, %llu] = [r%d, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_SUB_U64:{
|
|
|
|
|
@@ -650,7 +664,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
U64 right = R(instr->index_b).u64;
|
|
|
|
|
U64 result = left - right;
|
|
|
|
|
R(instr->index_c).u64 = result;
|
|
|
|
|
bc_log("[r%s, %llu] - [r%s, %llu] = [r%s, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %llu] - [r%d, %llu] = [r%d, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_DIV_U64:{
|
|
|
|
|
@@ -658,7 +672,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
U64 right = R(instr->index_b).u64;
|
|
|
|
|
U64 result = left / right;
|
|
|
|
|
R(instr->index_c).u64 = result;
|
|
|
|
|
bc_log("[r%s, %llu] / [r%s, %llu] = [r%s, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %llu] / [r%d, %llu] = [r%d, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_MUL_U64:{
|
|
|
|
|
@@ -666,7 +680,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
U64 right = R(instr->index_b).u64;
|
|
|
|
|
U64 result = left * right;
|
|
|
|
|
R(instr->index_c).u64 = result;
|
|
|
|
|
bc_log("[r%s, %llu] * [r%s, %llu] = [r%s, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %llu] * [r%d, %llu] = [r%d, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_MOD_U64:{
|
|
|
|
|
@@ -674,7 +688,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
U64 right = R(instr->index_b).u64;
|
|
|
|
|
U64 result = left % right;
|
|
|
|
|
R(instr->index_c).u64 = result;
|
|
|
|
|
bc_log("[r%s, %llu] % [r%s, %llu] = [r%s, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %llu] % [r%d, %llu] = [r%d, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_SHR_U64:{
|
|
|
|
|
@@ -682,7 +696,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
U64 right = R(instr->index_b).u64;
|
|
|
|
|
U64 result = left >> right;
|
|
|
|
|
R(instr->index_c).u64 = result;
|
|
|
|
|
bc_log("[r%s, %llu] >> [r%s, %llu] = [r%s, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %llu] >> [r%d, %llu] = [r%d, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_SHL_U64:{
|
|
|
|
|
@@ -690,7 +704,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
U64 right = R(instr->index_b).u64;
|
|
|
|
|
U64 result = left << right;
|
|
|
|
|
R(instr->index_c).u64 = result;
|
|
|
|
|
bc_log("[r%s, %llu] << [r%s, %llu] = [r%s, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %llu] << [r%d, %llu] = [r%d, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_BITAND_U64:{
|
|
|
|
|
@@ -698,7 +712,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
U64 right = R(instr->index_b).u64;
|
|
|
|
|
U64 result = left & right;
|
|
|
|
|
R(instr->index_c).u64 = result;
|
|
|
|
|
bc_log("[r%s, %llu] & [r%s, %llu] = [r%s, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %llu] & [r%d, %llu] = [r%d, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_BITOR_U64:{
|
|
|
|
|
@@ -706,7 +720,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
U64 right = R(instr->index_b).u64;
|
|
|
|
|
U64 result = left | right;
|
|
|
|
|
R(instr->index_c).u64 = result;
|
|
|
|
|
bc_log("[r%s, %llu] | [r%s, %llu] = [r%s, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %llu] | [r%d, %llu] = [r%d, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_BITXOR_U64:{
|
|
|
|
|
@@ -714,7 +728,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
U64 right = R(instr->index_b).u64;
|
|
|
|
|
U64 result = left ^ right;
|
|
|
|
|
R(instr->index_c).u64 = result;
|
|
|
|
|
bc_log("[r%s, %llu] ^ [r%s, %llu] = [r%s, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %llu] ^ [r%d, %llu] = [r%d, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_BITNOT_U64:{
|
|
|
|
|
@@ -730,7 +744,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
U64 right = R(instr->index_b).u64;
|
|
|
|
|
U64 result = left == right;
|
|
|
|
|
R(instr->index_c).u64 = result;
|
|
|
|
|
bc_log("[r%s, %llu] == [r%s, %llu] = [r%s, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %llu] == [r%d, %llu] = [r%d, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_NEQ_U64:{
|
|
|
|
|
@@ -738,7 +752,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
U64 right = R(instr->index_b).u64;
|
|
|
|
|
U64 result = left != right;
|
|
|
|
|
R(instr->index_c).u64 = result;
|
|
|
|
|
bc_log("[r%s, %llu] != [r%s, %llu] = [r%s, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %llu] != [r%d, %llu] = [r%d, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_GT_U64:{
|
|
|
|
|
@@ -746,7 +760,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
U64 right = R(instr->index_b).u64;
|
|
|
|
|
U64 result = left > right;
|
|
|
|
|
R(instr->index_c).u64 = result;
|
|
|
|
|
bc_log("[r%s, %llu] > [r%s, %llu] = [r%s, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %llu] > [r%d, %llu] = [r%d, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_LT_U64:{
|
|
|
|
|
@@ -754,7 +768,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
U64 right = R(instr->index_b).u64;
|
|
|
|
|
U64 result = left < right;
|
|
|
|
|
R(instr->index_c).u64 = result;
|
|
|
|
|
bc_log("[r%s, %llu] < [r%s, %llu] = [r%s, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %llu] < [r%d, %llu] = [r%d, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_OR_U64:{
|
|
|
|
|
@@ -762,7 +776,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
U64 right = R(instr->index_b).u64;
|
|
|
|
|
U64 result = left || right;
|
|
|
|
|
R(instr->index_c).u64 = result;
|
|
|
|
|
bc_log("[r%s, %llu] || [r%s, %llu] = [r%s, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %llu] || [r%d, %llu] = [r%d, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_GTE_U64:{
|
|
|
|
|
@@ -770,7 +784,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
U64 right = R(instr->index_b).u64;
|
|
|
|
|
U64 result = left >= right;
|
|
|
|
|
R(instr->index_c).u64 = result;
|
|
|
|
|
bc_log("[r%s, %llu] >= [r%s, %llu] = [r%s, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %llu] >= [r%d, %llu] = [r%d, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_LTE_U64:{
|
|
|
|
|
@@ -778,7 +792,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
U64 right = R(instr->index_b).u64;
|
|
|
|
|
U64 result = left <= right;
|
|
|
|
|
R(instr->index_c).u64 = result;
|
|
|
|
|
bc_log("[r%s, %llu] <= [r%s, %llu] = [r%s, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %llu] <= [r%d, %llu] = [r%d, %llu]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_ADD_F64:{
|
|
|
|
|
@@ -786,7 +800,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
F64 right = R(instr->index_b).f64;
|
|
|
|
|
F64 result = left + right;
|
|
|
|
|
R(instr->index_c).f64 = result;
|
|
|
|
|
bc_log("[r%s, %f] + [r%s, %f] = [r%s, %f]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %f] + [r%d, %f] = [r%d, %f]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_SUB_F64:{
|
|
|
|
|
@@ -794,7 +808,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
F64 right = R(instr->index_b).f64;
|
|
|
|
|
F64 result = left - right;
|
|
|
|
|
R(instr->index_c).f64 = result;
|
|
|
|
|
bc_log("[r%s, %f] - [r%s, %f] = [r%s, %f]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %f] - [r%d, %f] = [r%d, %f]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_DIV_F64:{
|
|
|
|
|
@@ -802,7 +816,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
F64 right = R(instr->index_b).f64;
|
|
|
|
|
F64 result = left / right;
|
|
|
|
|
R(instr->index_c).f64 = result;
|
|
|
|
|
bc_log("[r%s, %f] / [r%s, %f] = [r%s, %f]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %f] / [r%d, %f] = [r%d, %f]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_MUL_F64:{
|
|
|
|
|
@@ -810,7 +824,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
F64 right = R(instr->index_b).f64;
|
|
|
|
|
F64 result = left * right;
|
|
|
|
|
R(instr->index_c).f64 = result;
|
|
|
|
|
bc_log("[r%s, %f] * [r%s, %f] = [r%s, %f]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %f] * [r%d, %f] = [r%d, %f]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_EQ_F64:{
|
|
|
|
|
@@ -818,7 +832,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
F64 right = R(instr->index_b).f64;
|
|
|
|
|
F64 result = left == right;
|
|
|
|
|
R(instr->index_c).f64 = result;
|
|
|
|
|
bc_log("[r%s, %f] == [r%s, %f] = [r%s, %f]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %f] == [r%d, %f] = [r%d, %f]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_NEQ_F64:{
|
|
|
|
|
@@ -826,7 +840,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
F64 right = R(instr->index_b).f64;
|
|
|
|
|
F64 result = left != right;
|
|
|
|
|
R(instr->index_c).f64 = result;
|
|
|
|
|
bc_log("[r%s, %f] != [r%s, %f] = [r%s, %f]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %f] != [r%d, %f] = [r%d, %f]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_GT_F64:{
|
|
|
|
|
@@ -834,7 +848,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
F64 right = R(instr->index_b).f64;
|
|
|
|
|
F64 result = left > right;
|
|
|
|
|
R(instr->index_c).f64 = result;
|
|
|
|
|
bc_log("[r%s, %f] > [r%s, %f] = [r%s, %f]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %f] > [r%d, %f] = [r%d, %f]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_LT_F64:{
|
|
|
|
|
@@ -842,7 +856,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
F64 right = R(instr->index_b).f64;
|
|
|
|
|
F64 result = left < right;
|
|
|
|
|
R(instr->index_c).f64 = result;
|
|
|
|
|
bc_log("[r%s, %f] < [r%s, %f] = [r%s, %f]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %f] < [r%d, %f] = [r%d, %f]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_GTE_F64:{
|
|
|
|
|
@@ -850,7 +864,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
F64 right = R(instr->index_b).f64;
|
|
|
|
|
F64 result = left >= right;
|
|
|
|
|
R(instr->index_c).f64 = result;
|
|
|
|
|
bc_log("[r%s, %f] >= [r%s, %f] = [r%s, %f]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %f] >= [r%d, %f] = [r%d, %f]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
case BC_LTE_F64:{
|
|
|
|
|
@@ -858,7 +872,7 @@ run_bytecode_interp(Bc *b){
|
|
|
|
|
F64 right = R(instr->index_b).f64;
|
|
|
|
|
F64 result = left <= right;
|
|
|
|
|
R(instr->index_c).f64 = result;
|
|
|
|
|
bc_log("[r%s, %f] <= [r%s, %f] = [r%s, %f]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
bc_log("[r%d, %f] <= [r%d, %f] = [r%d, %f]", instr->index_a, left, instr->index_b, right, instr->index_c, result);
|
|
|
|
|
}break;
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|