Skip to content

Commit

Permalink
fix: space_bitmap test
Browse files Browse the repository at this point in the history
  • Loading branch information
jameslahm committed Jun 30, 2021
1 parent 4083b0e commit df79b32
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
1 change: 0 additions & 1 deletion crates/starlight/src/bin/sl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const SNAPSHOT_FILENAME: &str = ".startup-snapshot";
fn main() {
Platform::initialize();
let options = Options::from_args();

let mut deserialized = false;
let mut rt = if Path::new(SNAPSHOT_FILENAME).exists() {
let mut src = std::fs::read(SNAPSHOT_FILENAME);
Expand Down
4 changes: 0 additions & 4 deletions crates/starlight/src/bytecompiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1322,10 +1322,6 @@ impl ByteCompiler {
}
self.emit(Opcode::OP_FAST_RET,&[], false);
}
Stmt::Debugger(_) => todo!(),
Stmt::With(_) => todo!(),
Stmt::Labeled(_) => todo!(),
Stmt::DoWhile(_) => todo!(),
x => {
return Err(JsValue::new(
self.rt.new_syntax_error(format!("NYI: {:?}", x)),
Expand Down
15 changes: 8 additions & 7 deletions crates/starlight/src/gc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::{
serializer::{Serializable, SnapshotSerializer},
},
};
use std::usize;
use std::{any::TypeId, cmp::Ordering, fmt, marker::PhantomData};
use std::{
mem::size_of,
Expand Down Expand Up @@ -487,9 +488,11 @@ impl Tracer for SlotVisitor {
if scan > end {
swap(&mut scan, &mut end);
}
// end = scan;
unsafe {
while scan < end {
let ptr = (scan as *mut *mut u8).read();
// println!("{}", ptr as usize);

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

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

// Get stack pointer for scanning thread stack.
self.sp = current_stack_pointer();
let sp : usize = 0;
let sp = &sp as *const usize;
self.sp = sp as usize;
if self.defers > 0 {
return;
}
Expand All @@ -662,7 +662,7 @@ impl Heap {
visitor.add_conservative(thread.bounds.origin as _, sp as usize);
});
self.process_roots(&mut visitor);

if let Some(ref mut pool) = self.threadpool {
crate::gc::pmarking::start(
&visitor.queue,
Expand All @@ -673,6 +673,7 @@ impl Heap {
} else {
self.process_worklist(&mut visitor);
}

self.update_weak_references();
self.reset_weak_references();
let alloc = self.allocated;
Expand Down
3 changes: 3 additions & 0 deletions crates/starlight/src/gc/space_bitmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ impl<const ALIGNMENT: usize> SpaceBitmap<ALIGNMENT> {
let offset = object as isize - self.heap_begin as isize;
let index = Self::offset_to_index(offset as _);
let mask = Self::offset_to_mask(offset as _);
if index >= self.bitmap_size / size_of::<usize>() {
return false;
}
let atomic_entry = unsafe { *self.bitmap_begin.add(index) };
(atomic_entry & mask) != 0
}
Expand Down
1 change: 1 addition & 0 deletions crates/starlight/src/vm/interpreter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ pub unsafe fn eval(rt: &mut Runtime, frame: *mut CallFrame) -> Result<JsValue, J
} else {
ip = last_fast_call_ip;
last_fast_call_ip = null_mut();
continue;
}
}
Opcode::OP_RET => {
Expand Down

0 comments on commit df79b32

Please sign in to comment.