diff --git a/RELEASES.md b/RELEASES.md index 085229b4..1a849ca7 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -18,6 +18,10 @@ NEXT ==== Compiler -------- +- Place constants into static section in linked executable. + - This was the case in the old linker before the `tameld` + proof-of-concept. The benefits are significant when large constants are + used (e.g. for large tables of data). - Do not report value list optimization error on duplicate conjunctive predicates. - This doesn't emit code any differently, it merely permits the situation, diff --git a/tamer/src/ir/asg/base.rs b/tamer/src/ir/asg/base.rs index b7759759..4b4bd24c 100644 --- a/tamer/src/ir/asg/base.rs +++ b/tamer/src/ir/asg/base.rs @@ -310,6 +310,7 @@ where IdentKind::RetMapHead | IdentKind::RetMap | IdentKind::RetMapTail => deps.retmap.push_body(ident), + IdentKind::Const(_, _) => deps.consts.push_body(ident), _ => deps.rater.push_body(ident), }, None => { @@ -387,7 +388,8 @@ mod test { use super::super::graph::AsgError; use super::*; use crate::ir::asg::{ - Dim, IdentObject, TransitionError, TransitionResult, UnresolvedError, + DataType, Dim, IdentObject, TransitionError, TransitionResult, + UnresolvedError, }; use crate::ir::legacyir::SymDtype; use crate::sym::SymbolIndex; @@ -854,9 +856,10 @@ mod test { } macro_rules! assert_section_sym { - ( $iter:expr, $s:ident ) => {{ + ( $iterable:expr, $s:ident ) => {{ let mut pos = 0; - for obj in $iter { + assert_eq!($iterable.len(), $s.len()); + for obj in $iterable.iter() { let sym = obj.name().expect("missing object"); assert_eq!($s.get(pos), Some(sym)); @@ -866,7 +869,7 @@ mod test { } macro_rules! add_syms { - ($sut:ident, $base:expr, {$($dest:ident <- $name:ident: $kind:path,)*}) => { + ($sut:ident, $base:expr, {$($dest:ident <- $name:ident: $kind:expr,)*}) => { let mut i = 1; $( @@ -890,6 +893,7 @@ mod test { let mut worksheet = vec![]; let mut map = vec![]; let mut retmap = vec![]; + let mut consts = vec![]; let base = symbol_dummy!(1, "sym1"); let base_node = sut @@ -899,6 +903,7 @@ mod test { add_syms!(sut, &base, { meta <- meta1: IdentKind::Meta, worksheet <- work1: IdentKind::Worksheet, + consts <- const1: IdentKind::Const(Dim::from_u8(0), DataType::Float), map <- map1: IdentKind::MapHead, map <- map2: IdentKind::Map, map <- map3: IdentKind::MapTail, @@ -913,16 +918,18 @@ mod test { worksheet <- work2: IdentKind::Worksheet, map <- map6: IdentKind::MapTail, retmap <- retmap6: IdentKind::RetMapHead, + consts <- const2: IdentKind::Const(Dim::from_u8(2), DataType::Float), }); map.push(base); let sections = sut.sort(&vec![base_node])?; - assert_section_sym!(sections.meta.iter(), meta); - assert_section_sym!(sections.worksheet.iter(), worksheet); - assert_section_sym!(sections.map.iter(), map); - assert_section_sym!(sections.retmap.iter(), retmap); + assert_section_sym!(sections.meta, meta); + assert_section_sym!(sections.worksheet, worksheet); + assert_section_sym!(sections.map, map); + assert_section_sym!(sections.retmap, retmap); + assert_section_sym!(sections.consts, consts); Ok(()) } diff --git a/tamer/src/ir/asg/section.rs b/tamer/src/ir/asg/section.rs index 17eb174a..1eed78b4 100644 --- a/tamer/src/ir/asg/section.rs +++ b/tamer/src/ir/asg/section.rs @@ -129,6 +129,7 @@ pub struct Sections<'a, T> { pub params: Section<'a, T>, pub types: Section<'a, T>, pub funcs: Section<'a, T>, + pub consts: Section<'a, T>, pub rater: Section<'a, T>, } @@ -143,6 +144,7 @@ impl<'a, T> Sections<'a, T> { params: Section::new(), types: Section::new(), funcs: Section::new(), + consts: Section::new(), rater: Section::new(), } } diff --git a/tamer/src/obj/xmle/writer/xmle.rs b/tamer/src/obj/xmle/writer/xmle.rs index 9f57ce0c..5fdee44b 100644 --- a/tamer/src/obj/xmle/writer/xmle.rs +++ b/tamer/src/obj/xmle/writer/xmle.rs @@ -117,7 +117,8 @@ impl XmleWriter { .write_section(sections.worksheet.iter())? .write_section(sections.params.iter())? .write_section(sections.types.iter())? - .write_section(sections.funcs.iter()) + .write_section(sections.funcs.iter())? + .write_section(sections.consts.iter()) })? .write_element(b"l:exec", |writer| { writer.write_section(sections.rater.iter())