Merge branch 'trunk' into run-all-examples

This commit is contained in:
Richard Feldman 2021-07-24 10:10:49 -04:00 committed by GitHub
commit a973262133
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 36 additions and 61 deletions

View File

@ -245,6 +245,11 @@ fn jit_to_ast_help<'a>(
Builtin::Int16 => {
*(ptr.add(offset as usize) as *const i16) as i64
}
Builtin::Int64 => {
// used by non-recursive tag unions at the
// moment, remove if that is no longer the case
*(ptr.add(offset as usize) as *const i64) as i64
}
_ => unreachable!("invalid tag id layout"),
};

View File

@ -3,8 +3,6 @@ const utils = @import("utils.zig");
const RocResult = utils.RocResult;
const mem = std.mem;
const TAG_WIDTH = 8;
const EqFn = fn (?[*]u8, ?[*]u8) callconv(.C) bool;
const CompareFn = fn (?[*]u8, ?[*]u8, ?[*]u8) callconv(.C) u8;
const Opaque = ?[*]u8;

View File

@ -370,7 +370,7 @@ fn add_intrinsics<'ctx>(ctx: &'ctx Context, module: &Module<'ctx>) {
let i64_type = ctx.i64_type();
if let Some(func) = module.get_function("__muloti4") {
func.set_linkage(Linkage::External);
func.set_linkage(Linkage::WeakAny);
}
add_intrinsic(
@ -2389,7 +2389,7 @@ pub fn build_exp_stmt<'a, 'ctx, 'env>(
let exception_object = scope.get(&exception_id.into_inner()).unwrap().1;
env.builder.build_resume(exception_object);
env.context.i64_type().const_zero().into()
env.ptr_int().const_zero().into()
}
Switch {
@ -2827,7 +2827,7 @@ fn build_switch_ir<'a, 'ctx, 'env>(
.into_int_value()
}
Layout::Union(variant) => {
cond_layout = Layout::Builtin(Builtin::Int64);
cond_layout = variant.tag_id_layout();
get_tag_id(env, parent, &variant, cond_value)
}

View File

@ -129,7 +129,6 @@ pub fn list_prepend<'a, 'ctx, 'env>(
elem_layout: &Layout<'a>,
) -> BasicValueEnum<'ctx> {
let builder = env.builder;
let ctx = env.context;
// Load the usize length from the wrapper.
let len = list_len(builder, original_wrapper);
@ -139,7 +138,7 @@ pub fn list_prepend<'a, 'ctx, 'env>(
// The output list length, which is the old list length + 1
let new_list_len = env.builder.build_int_add(
ctx.i64_type().const_int(1_u64, false),
env.ptr_int().const_int(1_u64, false),
len,
"new_list_length",
);
@ -152,7 +151,7 @@ pub fn list_prepend<'a, 'ctx, 'env>(
let index_1_ptr = unsafe {
builder.build_in_bounds_gep(
clone_ptr,
&[ctx.i64_type().const_int(1_u64, false)],
&[env.ptr_int().const_int(1_u64, false)],
"load_index",
)
};

View File

@ -1217,13 +1217,7 @@ fn test_to_equality<'a>(
cond_layout: &Layout<'a>,
path: &[PathInstruction],
test: Test<'a>,
) -> (
StoresVec<'a>,
Symbol,
Symbol,
Layout<'a>,
Option<ConstructorKnown<'a>>,
) {
) -> (StoresVec<'a>, Symbol, Symbol, Option<ConstructorKnown<'a>>) {
let (rhs_symbol, mut stores, test_layout) =
path_to_expr_help(env, cond_symbol, &path, *cond_layout);
@ -1255,7 +1249,6 @@ fn test_to_equality<'a>(
stores,
lhs_symbol,
rhs_symbol,
Layout::Builtin(Builtin::Int64),
Some(ConstructorKnown::OnlyPass {
scrutinee: path_symbol,
layout: *cond_layout,
@ -1273,13 +1266,7 @@ fn test_to_equality<'a>(
let lhs_symbol = env.unique_symbol();
stores.push((lhs_symbol, Layout::Builtin(Builtin::Int64), lhs));
(
stores,
lhs_symbol,
rhs_symbol,
Layout::Builtin(Builtin::Int64),
None,
)
(stores, lhs_symbol, rhs_symbol, None)
}
Test::IsFloat(test_int) => {
@ -1289,13 +1276,7 @@ fn test_to_equality<'a>(
let lhs_symbol = env.unique_symbol();
stores.push((lhs_symbol, Layout::Builtin(Builtin::Float64), lhs));
(
stores,
lhs_symbol,
rhs_symbol,
Layout::Builtin(Builtin::Float64),
None,
)
(stores, lhs_symbol, rhs_symbol, None)
}
Test::IsByte {
@ -1305,13 +1286,7 @@ fn test_to_equality<'a>(
let lhs_symbol = env.unique_symbol();
stores.push((lhs_symbol, Layout::Builtin(Builtin::Int8), lhs));
(
stores,
lhs_symbol,
rhs_symbol,
Layout::Builtin(Builtin::Int8),
None,
)
(stores, lhs_symbol, rhs_symbol, None)
}
Test::IsBit(test_bit) => {
@ -1319,13 +1294,7 @@ fn test_to_equality<'a>(
let lhs_symbol = env.unique_symbol();
stores.push((lhs_symbol, Layout::Builtin(Builtin::Int1), lhs));
(
stores,
lhs_symbol,
rhs_symbol,
Layout::Builtin(Builtin::Int1),
None,
)
(stores, lhs_symbol, rhs_symbol, None)
}
Test::IsStr(test_str) => {
@ -1334,13 +1303,7 @@ fn test_to_equality<'a>(
stores.push((lhs_symbol, Layout::Builtin(Builtin::Str), lhs));
(
stores,
lhs_symbol,
rhs_symbol,
Layout::Builtin(Builtin::Str),
None,
)
(stores, lhs_symbol, rhs_symbol, None)
}
}
}
@ -1349,7 +1312,6 @@ type Tests<'a> = std::vec::Vec<(
bumpalo::collections::Vec<'a, (Symbol, Layout<'a>, Expr<'a>)>,
Symbol,
Symbol,
Layout<'a>,
Option<ConstructorKnown<'a>>,
)>;
@ -1495,7 +1457,7 @@ fn compile_tests<'a>(
fail: &'a Stmt<'a>,
mut cond: Stmt<'a>,
) -> Stmt<'a> {
for (new_stores, lhs, rhs, _layout, opt_constructor_info) in tests.into_iter() {
for (new_stores, lhs, rhs, opt_constructor_info) in tests.into_iter() {
match opt_constructor_info {
None => {
cond = compile_test(env, ret_layout, new_stores, lhs, rhs, fail, cond);
@ -1684,7 +1646,7 @@ fn decide_to_branching<'a>(
if number_of_tests == 1 {
// if there is just one test, compile to a simple if-then-else
let (new_stores, lhs, rhs, _layout, _cinfo) = tests.into_iter().next().unwrap();
let (new_stores, lhs, rhs, _cinfo) = tests.into_iter().next().unwrap();
compile_test_help(
env,

View File

@ -2106,8 +2106,6 @@ fn specialize_external<'a>(
let expr = Expr::UnionAtIndex {
tag_id,
structure: Symbol::ARG_CLOSURE,
// union at index still expects the index to be +1; it thinks
// the tag id is stored
index: index as u64,
union_layout,
};

View File

@ -170,7 +170,16 @@ impl<'a> UnionLayout<'a> {
pub fn tag_id_builtin(&self) -> Builtin<'a> {
match self {
UnionLayout::NonRecursive(tags) | UnionLayout::Recursive(tags) => {
UnionLayout::NonRecursive(_tags) => {
// let union_size = tags.len();
// Self::tag_id_builtin_help(union_size)
// The quicksort-benchmarks version of Quicksort.roc segfaults when
// this number is not I64. There must be some dependence on that fact
// somewhere in the code, I have not found where that is yet...
Builtin::Int64
}
UnionLayout::Recursive(tags) => {
let union_size = tags.len();
Self::tag_id_builtin_help(union_size)
@ -656,7 +665,7 @@ impl<'a> Layout<'a> {
.max()
.unwrap_or_default()
// the size of the tag_id
+ pointer_size
+ variant.tag_id_builtin().stack_size(pointer_size)
}
Recursive(_)

View File

@ -247,8 +247,6 @@ fn insert_reset<'a>(
let reset_expr = Expr::Reset(x);
// const I64: Layout<'static> = Layout::Builtin(crate::layout::Builtin::Int64);
let layout = Layout::Union(union_layout);
stmt = env.arena.alloc(Stmt::Let(w, reset_expr, layout, stmt));

View File

@ -37,7 +37,7 @@ fn hash_record() {
fn hash_result() {
assert_evals_to!(
"Dict.hashTestOnly 0 (List.get [ 0x1 ] 0) ",
6707068610910845221,
2878521786781103245,
u64
);
}

View File

@ -231,6 +231,12 @@ e.g. you have a test `calculate_sum_test` that only uses the function `add`, whe
- [Boop](https://github.com/IvanMathy/Boop) scriptable scratchpad for developers. Contains collection of useful conversions: json formatting, url encoding, encode to base64...
## High performance
### Inspiration
- [10x editor](http://www.10xeditor.com/) IDE/Editor targeted at the professional developer with an emphasis on performance and scalability.
## General Thoughts/Ideas
Thoughts and ideas possibly taken from above inspirations or separate.