Skip to content
Merged
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/js/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ hashbrown.workspace = true
indexmap-allocator-api.workspace = true
num-bigint.workspace = true
num-traits.workspace = true
paste = "1.0.15"
rand.workspace = true
ryu-js.workspace = true
supports-color.workspace = true
Expand Down
12 changes: 12 additions & 0 deletions src/js/runtime/bytecode/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::{
function::{set_function_length, set_function_name},
gc::{HeapItem, HeapVisitor},
heap_item_descriptor::{HeapItemDescriptor, HeapItemKind},
ic::vector::ICVector,
intrinsics::{intrinsics::Intrinsic, rust_runtime::RuntimeFunctionId},
object_value::ObjectValue,
ordinary_object::{
Expand Down Expand Up @@ -252,6 +253,8 @@ pub struct BytecodeFunction {
/// This function may be a stub function back into the Rust runtime. If this is set then this
/// function has an empty bytecode array and default values for many other fields.
runtime_function_id: Option<RuntimeFunctionId>,
/// Feedback vector for IC stubs
feedback_vector: Option<HeapPtr<ICVector>>,
/// Inlined bytecode array for the function.
bytecode: InlineArray<u8>,
}
Expand All @@ -276,6 +279,7 @@ impl BytecodeFunction {
name: Option<Handle<StringValue>>,
source_file: Handle<SourceFile>,
source_map: Handle<ByteArray>,
feedback_vector: Option<Handle<ICVector>>,
) -> AllocResult<Handle<BytecodeFunction>> {
let size = Self::calculate_size_in_bytes(bytecode.len());
let mut object = cx.alloc_uninit_with_size::<BytecodeFunction>(size)?;
Expand All @@ -298,6 +302,7 @@ impl BytecodeFunction {
set_uninit!(object.source_file, Some(*source_file));
set_uninit!(object.source_map, Some(*source_map));
set_uninit!(object.runtime_function_id, None);
set_uninit!(object.feedback_vector, feedback_vector.map(|v| *v));
object.bytecode.init_from_slice(&bytecode);

Ok(object.to_handle())
Expand Down Expand Up @@ -339,6 +344,7 @@ impl BytecodeFunction {
set_uninit!(object.name, name.map(|n| *n));
set_uninit!(object.source_file, None);
set_uninit!(object.source_map, None);
set_uninit!(object.feedback_vector, None);
set_uninit!(object.runtime_function_id, Some(runtime_func_id));
object.bytecode.init_from_slice(&[]);

Expand All @@ -361,6 +367,11 @@ impl BytecodeFunction {
self.constant_table
}

#[inline]
pub fn feedback_vector_ptr(&self) -> Option<HeapPtr<ICVector>> {
self.feedback_vector
}

#[inline]
pub fn exception_handlers_ptr(&self) -> Option<HeapPtr<ExceptionHandlers>> {
self.exception_handlers
Expand Down Expand Up @@ -517,6 +528,7 @@ impl HeapItem for HeapPtr<BytecodeFunction> {
visitor.visit_pointer(&mut self.descriptor);

visitor.visit_pointer_opt(&mut self.constant_table);
visitor.visit_pointer_opt(&mut self.feedback_vector);
visitor.visit_pointer_opt(&mut self.exception_handlers);
visitor.visit_pointer(&mut self.realm);
visitor.visit_pointer_opt(&mut self.name);
Expand Down
Loading