mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
cleanup
This commit is contained in:
parent
b39c592bea
commit
c0d67edfd3
5 changed files with 12 additions and 19 deletions
|
@ -271,11 +271,6 @@ pub const RocStr = extern struct {
|
||||||
const source_ptr = self.asU8ptr();
|
const source_ptr = self.asU8ptr();
|
||||||
const dest_ptr = result.asU8ptrMut();
|
const dest_ptr = result.asU8ptrMut();
|
||||||
|
|
||||||
const builtin = @import("builtin");
|
|
||||||
if (builtin.target.cpu.arch != .wasm32) {
|
|
||||||
std.debug.print("allocating a big thing? {s}\n", .{source_ptr[0..old_length]});
|
|
||||||
}
|
|
||||||
|
|
||||||
std.mem.copy(u8, dest_ptr[0..old_length], source_ptr[0..old_length]);
|
std.mem.copy(u8, dest_ptr[0..old_length], source_ptr[0..old_length]);
|
||||||
std.mem.set(u8, dest_ptr[old_length .. old_length + delta_length], 0);
|
std.mem.set(u8, dest_ptr[old_length .. old_length + delta_length], 0);
|
||||||
|
|
||||||
|
@ -285,16 +280,13 @@ pub const RocStr = extern struct {
|
||||||
} else {
|
} else {
|
||||||
var string = RocStr.empty();
|
var string = RocStr.empty();
|
||||||
|
|
||||||
|
// I believe taking this reference on the stack here is important for correctness.
|
||||||
|
// Doing it via a method call seemed to cause issues
|
||||||
const dest_ptr = @ptrCast([*]u8, &string);
|
const dest_ptr = @ptrCast([*]u8, &string);
|
||||||
dest_ptr[@sizeOf(RocStr) - 1] = @intCast(u8, new_length) | 0b1000_0000;
|
dest_ptr[@sizeOf(RocStr) - 1] = @intCast(u8, new_length) | 0b1000_0000;
|
||||||
|
|
||||||
const source_ptr = self.asU8ptr();
|
const source_ptr = self.asU8ptr();
|
||||||
|
|
||||||
const builtin = @import("builtin");
|
|
||||||
if (builtin.target.cpu.arch != .wasm32) {
|
|
||||||
std.debug.print("allocating a small thing? {s}\n", .{source_ptr[0..old_length]});
|
|
||||||
}
|
|
||||||
|
|
||||||
std.mem.copy(u8, dest_ptr[0..old_length], source_ptr[0..old_length]);
|
std.mem.copy(u8, dest_ptr[0..old_length], source_ptr[0..old_length]);
|
||||||
std.mem.set(u8, dest_ptr[old_length .. old_length + delta_length], 0);
|
std.mem.set(u8, dest_ptr[old_length .. old_length + delta_length], 0);
|
||||||
|
|
||||||
|
|
|
@ -219,9 +219,6 @@ pub fn decrefDataPtrC(
|
||||||
bytes_or_null: ?[*]isize,
|
bytes_or_null: ?[*]isize,
|
||||||
alignment: u32,
|
alignment: u32,
|
||||||
) callconv(.C) void {
|
) callconv(.C) void {
|
||||||
if (DEBUG_ALLOC and builtin.target.cpu.arch != .wasm32) {
|
|
||||||
std.debug.print("we will decref the data pointer {*}\n", .{bytes_or_null});
|
|
||||||
}
|
|
||||||
var bytes = bytes_or_null orelse return;
|
var bytes = bytes_or_null orelse return;
|
||||||
|
|
||||||
const data_ptr = @ptrToInt(bytes);
|
const data_ptr = @ptrToInt(bytes);
|
||||||
|
|
|
@ -510,6 +510,7 @@ impl CallConv<AArch64GeneralReg, AArch64FloatReg, AArch64Assembler> for AArch64C
|
||||||
args: &'a [(InLayout<'a>, Symbol)],
|
args: &'a [(InLayout<'a>, Symbol)],
|
||||||
ret_layout: &InLayout<'a>,
|
ret_layout: &InLayout<'a>,
|
||||||
) {
|
) {
|
||||||
|
// loading arguments occurs at an offset (but storing arguments does not)
|
||||||
let mut state = AArch64CallLoadArgs {
|
let mut state = AArch64CallLoadArgs {
|
||||||
general_i: 0,
|
general_i: 0,
|
||||||
float_i: 0,
|
float_i: 0,
|
||||||
|
@ -550,6 +551,7 @@ impl CallConv<AArch64GeneralReg, AArch64FloatReg, AArch64Assembler> for AArch64C
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// storing arguments does not have a stack offset (loading arguments does)
|
||||||
let mut state = AArch64CallStoreArgs {
|
let mut state = AArch64CallStoreArgs {
|
||||||
general_i: 0,
|
general_i: 0,
|
||||||
float_i: 0,
|
float_i: 0,
|
||||||
|
@ -1137,9 +1139,7 @@ impl AArch64CallStoreArgs {
|
||||||
self.general_i += 1;
|
self.general_i += 1;
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
// Copy to stack using return reg as buffer.
|
|
||||||
let tmp = AArch64GeneralReg::X15;
|
let tmp = AArch64GeneralReg::X15;
|
||||||
|
|
||||||
ASM::mov_reg64_base32(buf, tmp, offset);
|
ASM::mov_reg64_base32(buf, tmp, offset);
|
||||||
ASM::mov_stack32_reg64(buf, self.tmp_stack_offset, tmp);
|
ASM::mov_stack32_reg64(buf, self.tmp_stack_offset, tmp);
|
||||||
|
|
||||||
|
@ -1167,9 +1167,7 @@ impl AArch64CallStoreArgs {
|
||||||
|
|
||||||
self.general_i += 2;
|
self.general_i += 2;
|
||||||
} else {
|
} else {
|
||||||
// Copy to stack using return reg as buffer.
|
|
||||||
let reg = AArch64GeneralReg::X15;
|
let reg = AArch64GeneralReg::X15;
|
||||||
|
|
||||||
ASM::mov_reg64_base32(buf, reg, offset);
|
ASM::mov_reg64_base32(buf, reg, offset);
|
||||||
ASM::mov_stack32_reg64(buf, self.tmp_stack_offset, reg);
|
ASM::mov_stack32_reg64(buf, self.tmp_stack_offset, reg);
|
||||||
|
|
||||||
|
|
|
@ -3184,6 +3184,12 @@ impl<
|
||||||
|
|
||||||
let mut element_symbols = std::vec::Vec::new();
|
let mut element_symbols = std::vec::Vec::new();
|
||||||
|
|
||||||
|
// NOTE: this realizes all the list elements on the stack before they are put into the
|
||||||
|
// list. This turns out to be important. Creating the literals as we go causes issues with
|
||||||
|
// register usage.
|
||||||
|
//
|
||||||
|
// Of course this is inefficient when there are many elements (causes lots of stack
|
||||||
|
// spillage.
|
||||||
for (i, elem) in elements.iter().enumerate() {
|
for (i, elem) in elements.iter().enumerate() {
|
||||||
match elem {
|
match elem {
|
||||||
ListLiteralElement::Symbol(sym) => {
|
ListLiteralElement::Symbol(sym) => {
|
||||||
|
@ -3228,11 +3234,9 @@ impl<
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup list on stack.
|
// Setup list on stack.
|
||||||
dbg!("we will now be putting things onto the stack");
|
|
||||||
self.storage_manager.with_tmp_general_reg(
|
self.storage_manager.with_tmp_general_reg(
|
||||||
&mut self.buf,
|
&mut self.buf,
|
||||||
|storage_manager, buf, tmp_reg| {
|
|storage_manager, buf, tmp_reg| {
|
||||||
dbg!(tmp_reg);
|
|
||||||
let alignment = Ord::max(8, element_alignment) as u32;
|
let alignment = Ord::max(8, element_alignment) as u32;
|
||||||
let base_offset =
|
let base_offset =
|
||||||
storage_manager.claim_stack_area_with_alignment(*sym, 24, alignment);
|
storage_manager.claim_stack_area_with_alignment(*sym, 24, alignment);
|
||||||
|
|
|
@ -2039,6 +2039,8 @@ impl Assembler<X86_64GeneralReg, X86_64FloatReg> for X86_64Assembler {
|
||||||
name: fn_name,
|
name: fn_name,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// on X86_64, we actually get a pointer to a pointer
|
||||||
|
// so we just dereference to get just a pointer to the data
|
||||||
X86_64Assembler::mov_reg64_mem64_offset32(buf, dst, dst, 0);
|
X86_64Assembler::mov_reg64_mem64_offset32(buf, dst, dst, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue