Skip to content

Commit df79b32

Browse files
committed
fix: space_bitmap test
1 parent 4083b0e commit df79b32

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

crates/starlight/src/bin/sl.rs

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const SNAPSHOT_FILENAME: &str = ".startup-snapshot";
1616
fn main() {
1717
Platform::initialize();
1818
let options = Options::from_args();
19-
2019
let mut deserialized = false;
2120
let mut rt = if Path::new(SNAPSHOT_FILENAME).exists() {
2221
let mut src = std::fs::read(SNAPSHOT_FILENAME);

crates/starlight/src/bytecompiler.rs

-4
Original file line numberDiff line numberDiff line change
@@ -1322,10 +1322,6 @@ impl ByteCompiler {
13221322
}
13231323
self.emit(Opcode::OP_FAST_RET,&[], false);
13241324
}
1325-
Stmt::Debugger(_) => todo!(),
1326-
Stmt::With(_) => todo!(),
1327-
Stmt::Labeled(_) => todo!(),
1328-
Stmt::DoWhile(_) => todo!(),
13291325
x => {
13301326
return Err(JsValue::new(
13311327
self.rt.new_syntax_error(format!("NYI: {:?}", x)),

crates/starlight/src/gc.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ use crate::{
1212
serializer::{Serializable, SnapshotSerializer},
1313
},
1414
};
15+
use std::usize;
1516
use std::{any::TypeId, cmp::Ordering, fmt, marker::PhantomData};
1617
use std::{
1718
mem::size_of,
@@ -487,9 +488,11 @@ impl Tracer for SlotVisitor {
487488
if scan > end {
488489
swap(&mut scan, &mut end);
489490
}
491+
// end = scan;
490492
unsafe {
491493
while scan < end {
492494
let ptr = (scan as *mut *mut u8).read();
495+
// println!("{}", ptr as usize);
493496

494497
if (*self.heap).is_heap_pointer(ptr) {
495498
let mut ptr = ptr.cast::<GcPointerBase>();
@@ -639,16 +642,13 @@ impl Heap {
639642
}
640643

641644
fn collect_internal(&mut self) {
642-
fn current_stack_pointer() -> usize {
643-
let mut sp: usize = 0;
644-
sp = &sp as *const usize as usize;
645-
sp
646-
}
647645
// Capture all the registers to scan them conservatively. Note that this also captures
648646
// FPU registers too because JS values is NaN boxed and exist in FPU registers.
649647

650648
// Get stack pointer for scanning thread stack.
651-
self.sp = current_stack_pointer();
649+
let sp : usize = 0;
650+
let sp = &sp as *const usize;
651+
self.sp = sp as usize;
652652
if self.defers > 0 {
653653
return;
654654
}
@@ -662,7 +662,7 @@ impl Heap {
662662
visitor.add_conservative(thread.bounds.origin as _, sp as usize);
663663
});
664664
self.process_roots(&mut visitor);
665-
665+
666666
if let Some(ref mut pool) = self.threadpool {
667667
crate::gc::pmarking::start(
668668
&visitor.queue,
@@ -673,6 +673,7 @@ impl Heap {
673673
} else {
674674
self.process_worklist(&mut visitor);
675675
}
676+
676677
self.update_weak_references();
677678
self.reset_weak_references();
678679
let alloc = self.allocated;

crates/starlight/src/gc/space_bitmap.rs

+3
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ impl<const ALIGNMENT: usize> SpaceBitmap<ALIGNMENT> {
8686
let offset = object as isize - self.heap_begin as isize;
8787
let index = Self::offset_to_index(offset as _);
8888
let mask = Self::offset_to_mask(offset as _);
89+
if index >= self.bitmap_size / size_of::<usize>() {
90+
return false;
91+
}
8992
let atomic_entry = unsafe { *self.bitmap_begin.add(index) };
9093
(atomic_entry & mask) != 0
9194
}

crates/starlight/src/vm/interpreter.rs

+1
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ pub unsafe fn eval(rt: &mut Runtime, frame: *mut CallFrame) -> Result<JsValue, J
407407
} else {
408408
ip = last_fast_call_ip;
409409
last_fast_call_ip = null_mut();
410+
continue;
410411
}
411412
}
412413
Opcode::OP_RET => {

0 commit comments

Comments
 (0)