fixing nasty bug

This commit is contained in:
Jakub Doka 2024-10-17 15:48:22 +02:00
parent f386c332e5
commit f5ef62c6bb
No known key found for this signature in database
GPG key ID: C6E9A89936B8C143
9 changed files with 178 additions and 114 deletions

View file

@ -331,10 +331,11 @@ function cacheInputs(target) {
}
}
function updaetTab() {
/** @param {string} [path] */
function updaetTab(path) {
for (const elem of document.querySelectorAll("button[hx-push-url]")) {
if (elem instanceof HTMLButtonElement)
elem.disabled = elem.getAttribute("hx-push-url") === window.location.pathname;
elem.disabled = elem.getAttribute("hx-push-url") === (path ?? window.location.pathname);
}
}
@ -368,17 +369,11 @@ if (window.location.hostname === 'localhost') {
document.body.addEventListener('htmx:afterSwap', (ev) => {
if (!(ev.target instanceof HTMLElement)) never();
wireUp(ev.target);
if (ev.target.tagName == "MAIN") updaetTab();
if (ev.target.tagName == "MAIN" || ev.target.tagName == "BODY")
updaetTab(ev['detail'].pathInfo.finalRequestPath);
console.log(ev);
});
//document.body.addEventListener('htmx:beforeSend', (ev) => {
// const target = ev.target;
// if (target instanceof HTMLButtonElement && target.hasAttribute("hx-push-url")) {
//
// document.getElementById("extra-style").textContent = `[hx-push-url="${target.getAttribute("hx-push-url")}"]{background: var(--primary)}`
// }
//});
getFmtInstance().then(inst => {
document.body.addEventListener('htmx:configRequest', (ev) => {
const details = ev['detail'];

View file

@ -175,8 +175,8 @@ impl Page for Feed {
let mut last_timestamp = None;
for post in cursor {
write!(buf, "{}", post).unwrap();
last_timestamp = Some(post.timestamp);
if buf.len() - base_len > MAX_FEED_SIZE {
last_timestamp = Some(post.timestamp);
break;
}
}
@ -561,9 +561,6 @@ fn base(body: impl FnOnce(&mut String), path: &str, session: Option<&Session>) -
<meta name="charset" content="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="/index.css">
//<style id="extra-style">
// "[hx-push-url='" !path "']{background:var(--primary)}"
//</style>
</head>
<body>
<nav>

View file

@ -204,7 +204,15 @@ Rect := struct {
b: Point,
}
Color := packed struct {b: u8, g: u8, r: u8, a: u8}
main := fn(): int {
i := Color.(0, 0, 0, 0)
i += .(1, 1, 1, 1)
if i.r + i.g + i.b + i.a != 4 {
return 1008
}
a := Point.(1, 2)
b := Point.(3, 4)

View file

@ -13,6 +13,7 @@ use {
},
alloc::{boxed::Box, string::String, vec::Vec},
core::fmt::Display,
std::assert_matches::debug_assert_matches,
};
type Offset = u32;
@ -409,7 +410,7 @@ impl Loc {
}
fn is_reg(&self) -> bool {
matches!(self, Self::Rt { derefed: false, reg: _, stack: None, offset: 0 })
matches!(self, Self::Rt { derefed: false, reg: _, stack, offset } if ({ debug_assert_eq!(*offset, 0); debug_assert_matches!(stack, None); true }))
}
}
@ -2126,7 +2127,7 @@ impl Codegen {
let size = self.tys.size_of(ty);
match size {
0 => Loc::default(),
1..=8 => Loc::reg(self.loc_to_reg(loc, size)),
1..=8 if !loc.is_stack() => Loc::reg(self.loc_to_reg(loc, size)),
_ if loc.is_ref() => {
let new_loc = Loc::stack(self.ci.stack.allocate(size));
self.store_sized(loc, &new_loc, size);
@ -2367,7 +2368,17 @@ impl Codegen {
let value = ensure_loaded(value, derefed, size) << (8 * (off % 8));
self.ci.emit(ori(freg, freg, value));
}
(lpat!(true, src, soff, ref ssta), lpat!(true, dst, doff, ref dsta)) => {
(lpat!(true, src, soff, ref ssta), lpat!(true, dst, doff, ref dsta)) => 'a: {
if size <= 8 {
let tmp = self.ci.regs.allocate();
let off = self.opt_stack_reloc(ssta.as_ref(), soff, 3);
self.ci.emit(ld(tmp.get(), src.get(), off, size as _));
let off = self.opt_stack_reloc(dsta.as_ref(), soff, 3);
self.ci.emit(st(tmp.get(), dst.get(), off, size as _));
self.ci.regs.free(tmp);
break 'a;
}
// TODO: some oportuinies to ellit more optimal code
let src_off = if src.is_ref() { self.ci.regs.allocate() } else { src.as_ref() };
let dst_off = if dst.is_ref() { self.ci.regs.allocate() } else { dst.as_ref() };

View file

@ -1,6 +1,6 @@
main:
ADDI64 r254, r254, -80d
ST r31, r254, 32a, 48h
ADDI64 r254, r254, -76d
ST r31, r254, 28a, 48h
LI64 r32, 511d
LI64 r33, 0d
ST r33, r254, 0a, 1h
@ -13,29 +13,26 @@ main:
SRUI16 r33, r33, 8b
ANDI r33, r33, 255d
ST r33, r254, 3a, 1h
CP r33, r0
LD r33, r254, 0a, 4h
ST r33, r254, 4a, 4h
ADDI64 r33, r254, 4d
ADDI64 r33, r254, 0d
LI64 r34, 1d
ST r34, r254, 8a, 8h
ST r34, r254, 4a, 8h
LI64 r34, 2d
ST r34, r254, 16a, 8h
ST r34, r254, 12a, 8h
LI64 r34, 4d
ST r34, r254, 24a, 8h
ADDI64 r34, r254, 8d
ST r34, r254, 20a, 8h
ADDI64 r34, r254, 4d
CP r2, r34
JAL r31, r0, :pass
CP r34, r1
ADDI64 r35, r254, 4d
ADDI64 r35, r254, 0d
LI64 r36, 3d
ADD64 r35, r35, r36
CP r36, r0
LD r36, r35, 4a, 1h
LD r36, r35, 0a, 1h
SXT8 r36, r36
ADD64 r1, r34, r36
LD r31, r254, 32a, 48h
ADDI64 r254, r254, 80d
LD r31, r254, 28a, 48h
ADDI64 r254, r254, 76d
JALA r0, r31, 0a
pass:
ADDI64 r254, r254, -48d
@ -65,6 +62,6 @@ pass:
LD r31, r254, 0a, 48h
ADDI64 r254, r254, 48d
JALA r0, r31, 0a
code size: 586
ret: 7
code size: 557
ret: 8
status: Ok(())

View file

@ -75,8 +75,8 @@ new:
ADDI64 r254, r254, 24d
JALA r0, r31, 0a
push:
ADDI64 r254, r254, -72d
ST r31, r254, 0a, 72h
ADDI64 r254, r254, -80d
ST r31, r254, 0a, 80h
CP r32, r2
CP r33, r3
LD r34, r32, 8a, 8h
@ -111,7 +111,8 @@ push:
JMP :6
5: CP r38, r36
CP r39, r35
BMC r39, r38, 8h
LD r40, r39, 0a, 8h
ST r40, r38, 0a, 8h
ADDI64 r35, r35, 8d
ADDI64 r36, r36, 8d
JMP :7
@ -135,9 +136,9 @@ push:
ADDI64 r38, r38, 1d
ST r38, r32, 8a, 8h
CP r1, r39
4: LD r31, r254, 0a, 72h
ADDI64 r254, r254, 72d
4: LD r31, r254, 0a, 80h
ADDI64 r254, r254, 80d
JALA r0, r31, 0a
code size: 1204
code size: 1225
ret: 69
status: Ok(())

View file

@ -1,75 +1,130 @@
main:
ADDI64 r254, r254, -152d
ST r31, r254, 128a, 24h
ADDI64 r254, r254, -160d
ST r31, r254, 136a, 24h
LI64 r32, 0d
ST r32, r254, 0a, 1h
LI64 r32, 0d
ST r32, r254, 1a, 1h
LI64 r32, 0d
ST r32, r254, 2a, 1h
LI64 r32, 0d
ST r32, r254, 3a, 1h
LI64 r32, 1d
ST r32, r254, 0a, 8h
LI64 r32, 2d
ST r32, r254, 8a, 8h
LI64 r32, 3d
ST r32, r254, 16a, 8h
LI64 r32, 4d
ST r32, r254, 24a, 8h
LD r32, r254, 0a, 8h
LD r33, r254, 16a, 8h
ADD64 r32, r32, r33
ST r32, r254, 32a, 8h
LD r32, r254, 8a, 8h
LD r33, r254, 24a, 8h
ADD64 r32, r32, r33
ST r32, r254, 40a, 8h
LD r32, r254, 16a, 8h
LD r33, r254, 0a, 8h
SUB64 r32, r32, r33
ST r32, r254, 48a, 8h
LD r32, r254, 24a, 8h
ST r32, r254, 4a, 1h
LI64 r32, 1d
ST r32, r254, 5a, 1h
LI64 r32, 1d
ST r32, r254, 6a, 1h
LI64 r32, 1d
ST r32, r254, 7a, 1h
CP r32, r0
LD r32, r254, 0a, 1h
CP r33, r0
LD r33, r254, 4a, 1h
ADD8 r32, r32, r33
ST r32, r254, 0a, 1h
CP r32, r0
LD r32, r254, 1a, 1h
CP r33, r0
LD r33, r254, 5a, 1h
ADD8 r32, r32, r33
ST r32, r254, 1a, 1h
CP r32, r0
LD r32, r254, 2a, 1h
CP r33, r0
LD r33, r254, 6a, 1h
ADD8 r32, r32, r33
ST r32, r254, 2a, 1h
CP r32, r0
LD r32, r254, 3a, 1h
CP r33, r0
LD r33, r254, 7a, 1h
ADD8 r32, r32, r33
ST r32, r254, 3a, 1h
CP r32, r0
LD r32, r254, 2a, 1h
CP r33, r0
LD r33, r254, 1a, 1h
ADD8 r32, r32, r33
CP r33, r0
LD r33, r254, 0a, 1h
ADD8 r32, r32, r33
CP r33, r0
LD r33, r254, 3a, 1h
ADD8 r32, r32, r33
LI64 r33, 4d
JEQ r32, r33, :0
LI64 r1, 1008d
JMP :1
0: LI64 r33, 1d
ST r33, r254, 8a, 8h
LI64 r33, 2d
ST r33, r254, 16a, 8h
LI64 r33, 3d
ST r33, r254, 24a, 8h
LI64 r33, 4d
ST r33, r254, 32a, 8h
LD r33, r254, 8a, 8h
SUB64 r32, r32, r33
ST r32, r254, 56a, 8h
LI64 r32, 0d
ST r32, r254, 64a, 8h
LI64 r32, 0d
ST r32, r254, 72a, 8h
LD r32, r254, 64a, 8h
LD r32, r254, 24a, 8h
ADD64 r33, r33, r32
ST r33, r254, 40a, 8h
LD r33, r254, 16a, 8h
SUB64 r32, r32, r33
ST r32, r254, 80a, 8h
LD r32, r254, 72a, 8h
LD r33, r254, 24a, 8h
SUB64 r32, r32, r33
ST r32, r254, 88a, 8h
ADDI64 r32, r254, 0d
ADDI64 r33, r254, 96d
BMC r32, r33, 16h
LD r33, r254, 80a, 8h
LD r32, r254, 32a, 8h
ADD64 r33, r33, r32
ST r33, r254, 48a, 8h
LD r33, r254, 24a, 8h
LD r32, r254, 8a, 8h
SUB64 r33, r33, r32
ST r33, r254, 56a, 8h
LD r33, r254, 32a, 8h
LD r32, r254, 16a, 8h
SUB64 r33, r33, r32
ST r33, r254, 64a, 8h
LI64 r33, 0d
ST r33, r254, 72a, 8h
LI64 r33, 0d
ST r33, r254, 80a, 8h
LD r33, r254, 88a, 8h
LD r32, r254, 40a, 8h
ADD64 r33, r33, r32
LD r33, r254, 72a, 8h
LD r32, r254, 24a, 8h
SUB64 r33, r33, r32
ST r33, r254, 88a, 8h
LD r33, r254, 96a, 8h
LD r32, r254, 48a, 8h
ADD64 r33, r33, r32
ST r33, r254, 96a, 8h
LD r33, r254, 104a, 8h
LD r32, r254, 56a, 8h
ADD64 r33, r33, r32
ST r33, r254, 104a, 8h
LD r33, r254, 80a, 8h
LD r32, r254, 32a, 8h
SUB64 r33, r33, r32
ST r33, r254, 96a, 8h
ADDI64 r33, r254, 8d
ADDI64 r32, r254, 104d
BMC r33, r32, 16h
LD r32, r254, 88a, 8h
LD r33, r254, 40a, 8h
ADD64 r32, r32, r33
ST r32, r254, 88a, 8h
LD r32, r254, 96a, 8h
ADD64 r33, r33, r32
ST r33, r254, 112a, 8h
LD r33, r254, 88a, 8h
LD r33, r254, 48a, 8h
ADD64 r32, r32, r33
ST r32, r254, 96a, 8h
LD r32, r254, 104a, 8h
ADD64 r33, r33, r32
ST r33, r254, 120a, 8h
LD r33, r254, 56a, 8h
ADD64 r32, r32, r33
ST r32, r254, 104a, 8h
LD r32, r254, 112a, 8h
LD r33, r254, 64a, 8h
ADD64 r32, r32, r33
ST r32, r254, 112a, 8h
LD r32, r254, 88a, 8h
LD r33, r254, 104a, 8h
ADD64 r32, r32, r33
ST r32, r254, 120a, 8h
LD r32, r254, 96a, 8h
LD r33, r254, 112a, 8h
ADD64 r32, r32, r33
ST r32, r254, 128a, 8h
LD r32, r254, 120a, 8h
ADD64 r1, r33, r32
LD r31, r254, 128a, 24h
ADDI64 r254, r254, 152d
LD r33, r254, 128a, 8h
ADD64 r1, r32, r33
1: LD r31, r254, 136a, 24h
ADDI64 r254, r254, 160d
JALA r0, r31, 0a
code size: 778
code size: 1264
ret: 10
status: Ok(())

View file

@ -40,26 +40,25 @@ fib_iter:
ADDI64 r254, r254, 40d
JALA r0, r31, 0a
main:
ADDI64 r254, r254, -42d
ST r31, r254, 2a, 40h
ADDI64 r254, r254, -34d
ST r31, r254, 2a, 32h
LI64 r32, 10d
ST r32, r254, 0a, 1h
LI64 r32, 10d
ST r32, r254, 1a, 1h
CP r32, r0
LD r32, r254, 0a, 1h
CP r33, r0
LD r33, r254, 1a, 1h
CP r2, r32
LD r32, r254, 1a, 1h
CP r2, r0
LD r2, r254, 0a, 1h
JAL r31, r0, :fib
CP r34, r1
CP r2, r33
CP r33, r1
CP r2, r32
JAL r31, r0, :fib_iter
CP r35, r1
SUB64 r1, r34, r35
LD r31, r254, 2a, 40h
ADDI64 r254, r254, 42d
CP r34, r1
SUB64 r1, r33, r34
LD r31, r254, 2a, 32h
ADDI64 r254, r254, 34d
JALA r0, r31, 0a
code size: 452
code size: 449
ret: 0
status: Ok(())

View file

@ -23,7 +23,8 @@ main:
ST r34, r254, 7a, 1h
LD r34, r254, 0a, 8h
ST r34, r254, 8a, 8h
ST r34, r254, 16a, 8h
LD r34, r254, 0a, 8h
ST r34, r254, 8a, 8h
LD r1, r254, 8a, 16h
LD r31, r254, 24a, 32h
ADDI64 r254, r254, 56d
@ -40,6 +41,6 @@ small_struct:
LD r31, r254, 4a, 16h
ADDI64 r254, r254, 20d
JALA r0, r31, 0a
code size: 440
code size: 453
ret: 0
status: Ok(())