Skip to content

Commit

Permalink
Remove comment and fix duplicate main trace
Browse files Browse the repository at this point in the history
  • Loading branch information
nekevss committed Apr 20, 2024
1 parent 1b95f81 commit 94045e1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
1 change: 0 additions & 1 deletion core/engine/src/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,6 @@ impl Context {
#[cfg(feature = "trace")]
/// Sets custom handling of trace messages.
pub fn set_tracer_implementation(&mut self, tracer: Box<dyn trace::Tracer>) {
// self.init_trace();
self.vm.trace.set_tracer(tracer);
}

Expand Down
2 changes: 1 addition & 1 deletion core/engine/src/vm/code_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ bitflags! {
#[cfg(feature = "trace")]
const TRACEABLE = 0b0100_0000_0000_0000;

/// Stores whether the `CodeBlock` been traced.
/// Stores whether the `CodeBlock` has been traced.
#[cfg(feature = "trace")]
const WAS_TRACED = 0b1000_0000_0000_0000;
}
Expand Down
17 changes: 8 additions & 9 deletions core/engine/src/vm/trace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ pub trait Tracer: fmt::Debug {
/// Whether the current call frame should trace.
fn should_trace(&self, frame: &CallFrame) -> TraceAction {
if frame.code_block.name().to_std_string_escaped().as_str() == "<main>" {
if frame.code_block().was_traced() {
return TraceAction::Block;
}
frame.code_block().set_frame_traced(true);
return TraceAction::BlockWithFullBytecode;
}
TraceAction::Block
Expand All @@ -35,7 +39,7 @@ pub enum TraceAction {
Block,
/// Partial codeblock with bytecode
BlockWithBytecode,
/// Full trace with bytecode
/// Full trace with the compiled bytecode
BlockWithFullBytecode,
}

Expand Down Expand Up @@ -63,12 +67,7 @@ impl Tracer for ActiveTracer {
/// `VmTrace` is a boa spcific structure for running Boa's Virtual Machine trace.
///
/// It holds registered `Tracer` implementations and actions messages depending on
/// those implementations.
///
/// About the actions
///
/// After the Global callframe is initially provided. It searches
/// for all possible compiled output
/// the `should_trace` method of the `Tracers`.
#[derive(Default)]
pub struct VmTrace {
tracers: Vec<Box<dyn Tracer>>,
Expand All @@ -95,7 +94,7 @@ impl VmTrace {
.fold(TraceAction::None, |a, b| a.max(b.should_trace(frame)))
}

/// Sets the current `Tracer` of `VmTrace`.
/// Adds Boa's default implementation of `Tracer` onto `VmTrace`'s current traces.
pub fn activate_trace(&mut self) {
self.tracers.push(Box::new(ActiveTracer));
}
Expand Down Expand Up @@ -162,7 +161,7 @@ impl VmTrace {
}
}

/// Searches traces all of the current `CallFrame`'s available `CodeBlock`s.
/// Searches all of the current `CallFrame`'s available `CodeBlock`s.
pub(crate) fn trace_compiled_bytecode(&self, vm: &Vm) {
let mut queue = VecDeque::new();
queue.push_back(vm.frame().code_block.clone());
Expand Down

0 comments on commit 94045e1

Please sign in to comment.