Skip to content

Commit 8680b68

Browse files
committed
Update stack overflow assertion in Source 2
1 parent bbb6357 commit 8680b68

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/virtual-machines/source-2-with-mark-region-gc.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1818,7 +1818,7 @@ function PUSH_OS() {
18181818
B = B + 1;
18191819
HEAP[OS + LAST_CHILD_SLOT] = B; // update address of current top of OS
18201820
HEAP[OS + B] = A;
1821-
// assert_os_overflow(OS, trace_root);
1821+
assert_os_overflow(OS, trace_root);
18221822
}
18231823

18241824
// POP puts the top-most value into RES
@@ -2888,7 +2888,7 @@ function remove_duplicates(lst) { \
28882888
? null \
28892889
: accumulate((x, y) => pair(x, remove_all(x, y)), lst, lst); \
28902890
} \
2891-
remove_duplicates(list(1, 2, 3, 4, 2, 1, 2, 5)); ");
2891+
remove_duplicates(list(1, 2, 2, 1)); ");
28922892

28932893
// parse_and_compile_and_run(20, 20, 4, " \
28942894
// function permutations(lst) { \

src/virtual-machines/source-2.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1255,7 +1255,9 @@ function PUSH_OS() {
12551255
B = B + 1;
12561256
HEAP[OS + LAST_CHILD_SLOT] = B; // update address of current top of OS
12571257
HEAP[OS + B] = A;
1258-
if (B >= HEAP[OS + LAST_CHILD_SLOT]) {
1258+
if (B >= HEAP[OS + SIZE_SLOT]) {
1259+
show_node(OS);
1260+
display(B, "new top");
12591261
error('stack overflow');
12601262
} else {}
12611263
}
@@ -1941,6 +1943,17 @@ function run() {
19411943
}
19421944
}
19431945

1946+
function show_node(address) {
1947+
const tag = HEAP[address];
1948+
const size = HEAP[address + SIZE_SLOT];
1949+
display("======================");
1950+
display(node_kind(tag), address);
1951+
for (let i = 1; i < size + 1; i = i + 1) {
1952+
display(stringify(address + i) + ": " + stringify(HEAP[address + i]));
1953+
}
1954+
display("======================");
1955+
}
1956+
19441957
parse_and_compile_and_run(" \
19451958
function subset(lst) { \
19461959
return is_null(lst) \

0 commit comments

Comments
 (0)