mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 15:51:12 +00:00
quick fix for failing expects on wasm
This commit is contained in:
parent
5cb7dbd3cc
commit
85e4afefe8
2 changed files with 30 additions and 25 deletions
|
@ -5175,22 +5175,37 @@ fn run_low_level<'a, 'ctx, 'env>(
|
|||
|
||||
bd.build_conditional_branch(condition, then_block, throw_block);
|
||||
|
||||
bd.position_at_end(throw_block);
|
||||
{
|
||||
bd.position_at_end(throw_block);
|
||||
|
||||
let fn_ptr_type = context
|
||||
.void_type()
|
||||
.fn_type(&[], false)
|
||||
.ptr_type(AddressSpace::Generic);
|
||||
let fn_addr = env
|
||||
.ptr_int()
|
||||
.const_int(expect_failed as *const () as u64, false);
|
||||
let func: PointerValue<'ctx> =
|
||||
bd.build_int_to_ptr(fn_addr, fn_ptr_type, "cast_expect_failed_addr_to_ptr");
|
||||
let callable = CallableValue::try_from(func).unwrap();
|
||||
match env.ptr_bytes {
|
||||
8 => {
|
||||
let fn_ptr_type = context
|
||||
.void_type()
|
||||
.fn_type(&[], false)
|
||||
.ptr_type(AddressSpace::Generic);
|
||||
let fn_addr = env
|
||||
.ptr_int()
|
||||
.const_int(expect_failed as *const () as u64, false);
|
||||
let func: PointerValue<'ctx> = bd.build_int_to_ptr(
|
||||
fn_addr,
|
||||
fn_ptr_type,
|
||||
"cast_expect_failed_addr_to_ptr",
|
||||
);
|
||||
let callable = CallableValue::try_from(func).unwrap();
|
||||
|
||||
bd.build_call(callable, &[], "call_expect_failed");
|
||||
bd.build_call(callable, &[], "call_expect_failed");
|
||||
|
||||
bd.build_unconditional_branch(then_block);
|
||||
}
|
||||
4 => {
|
||||
// temporary WASM implementation
|
||||
throw_exception(env, "An expectation failed!");
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
bd.build_unconditional_branch(then_block);
|
||||
bd.position_at_end(then_block);
|
||||
|
||||
cond
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
use crate::debug_info_init;
|
||||
use crate::llvm::bitcode::{self, call_void_bitcode_fn};
|
||||
use crate::llvm::bitcode::call_void_bitcode_fn;
|
||||
use crate::llvm::build::{
|
||||
add_func, cast_basic_basic, cast_block_of_memory_to_tag, get_tag_id, get_tag_id_non_recursive,
|
||||
tag_pointer_clear_tag_id, Env, FAST_CALL_CONV, LLVM_SADD_WITH_OVERFLOW_I32,
|
||||
LLVM_SADD_WITH_OVERFLOW_I64, TAG_DATA_INDEX,
|
||||
tag_pointer_clear_tag_id, Env, FAST_CALL_CONV, TAG_DATA_INDEX,
|
||||
};
|
||||
use crate::llvm::build_list::{incrementing_elem_loop, list_len, load_list};
|
||||
use crate::llvm::convert::{basic_type_from_layout, ptr_int};
|
||||
|
@ -213,21 +212,12 @@ impl<'ctx> PointerToRefcount<'ctx> {
|
|||
) {
|
||||
let builder = env.builder;
|
||||
let ctx = env.context;
|
||||
let refcount_type = ptr_int(ctx, env.ptr_bytes);
|
||||
|
||||
let entry = ctx.append_basic_block(parent, "entry");
|
||||
builder.position_at_end(entry);
|
||||
|
||||
debug_info_init!(env, parent);
|
||||
|
||||
let refcount_ptr = {
|
||||
let raw_refcount_ptr = parent.get_nth_param(0).unwrap();
|
||||
debug_assert!(raw_refcount_ptr.is_pointer_value());
|
||||
Self {
|
||||
value: raw_refcount_ptr.into_pointer_value(),
|
||||
}
|
||||
};
|
||||
|
||||
let alignment = env.context.i32_type().const_int(alignment as _, false);
|
||||
|
||||
// has to be non-zero, or the deallocation is skipped
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue