mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 06:44:46 +00:00
Add linker data for strings, and deduplicate them
For references to addresses of constant strings, we make an entry in reloc.CODE and configure the relocation type to say it points at a memory address. (At least I think this is right, I can't test it yet!) The same info can also be used for de-duplication. It turns out we don't need reloc.DATA. I had misunderstood it. The use case for that would be constant nested data structures, where constant data would contain pointers to other constant data. I don't think we're doing this in Roc at all, but not sure.
This commit is contained in:
parent
2f0296a5fa
commit
38d9fc5bbd
5 changed files with 113 additions and 65 deletions
|
@ -5,7 +5,7 @@ use std::fmt::Debug;
|
|||
|
||||
use roc_module::symbol::Symbol;
|
||||
|
||||
use super::linking::{IndexRelocType, RelocationEntry};
|
||||
use super::linking::{IndexRelocType, OffsetRelocType, RelocationEntry};
|
||||
use super::opcodes::*;
|
||||
use super::serialize::{SerialBuffer, Serialize};
|
||||
use crate::{round_up_to_alignment, FRAME_ALIGNMENT_BYTES, STACK_POINTER_GLOBAL_ID};
|
||||
|
@ -461,6 +461,16 @@ impl<'a> CodeBuilder<'a> {
|
|||
self.code.encode_u32(offset);
|
||||
}
|
||||
|
||||
/// Insert a linker relocation for a memory address
|
||||
pub fn insert_memory_relocation(&mut self, symbol_index: u32) {
|
||||
self.relocations.push(RelocationEntry::Offset {
|
||||
type_id: OffsetRelocType::MemoryAddrLeb,
|
||||
offset: self.code.len() as u32,
|
||||
symbol_index,
|
||||
addend: 0,
|
||||
});
|
||||
}
|
||||
|
||||
/**********************************************************
|
||||
|
||||
INSTRUCTION METHODS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue