mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-25 03:01:12 +08:00
chore: rustfmt 全量格式化——CI fmt check 差异清零
This commit is contained in:
@@ -893,11 +893,7 @@ pub fn bind_temporal(core: &Arc<KernelCore>, session: &KernelSession, global: &m
|
||||
core,
|
||||
&[
|
||||
("from", oxide_builtins::temporal::duration_from::<crate::vm::Vm> as *const (), 1),
|
||||
(
|
||||
"compare",
|
||||
oxide_builtins::temporal::duration_compare::<crate::vm::Vm> as *const (),
|
||||
2,
|
||||
),
|
||||
("compare", oxide_builtins::temporal::duration_compare::<crate::vm::Vm> as *const (), 2),
|
||||
],
|
||||
);
|
||||
let duration_proto_ptr = world.duration_proto.as_ptr() as *mut JsObject;
|
||||
@@ -935,11 +931,7 @@ pub fn bind_temporal(core: &Arc<KernelCore>, session: &KernelSession, global: &m
|
||||
("abs", oxide_builtins::temporal::duration_abs::<crate::vm::Vm> as *const (), 0),
|
||||
("negated", oxide_builtins::temporal::duration_negated::<crate::vm::Vm> as *const (), 0),
|
||||
("add", oxide_builtins::temporal::duration_add::<crate::vm::Vm> as *const (), 1),
|
||||
(
|
||||
"subtract",
|
||||
oxide_builtins::temporal::duration_subtract::<crate::vm::Vm> as *const (),
|
||||
1,
|
||||
),
|
||||
("subtract", oxide_builtins::temporal::duration_subtract::<crate::vm::Vm> as *const (), 1),
|
||||
("equals", oxide_builtins::temporal::duration_equals::<crate::vm::Vm> as *const (), 1),
|
||||
("round", oxide_builtins::temporal::duration_round::<crate::vm::Vm> as *const (), 1),
|
||||
("with", oxide_builtins::temporal::duration_with::<crate::vm::Vm> as *const (), 1),
|
||||
|
||||
@@ -12,6 +12,8 @@ pub mod bind_async_disposable_stack;
|
||||
pub mod bind_bigint;
|
||||
/// Boolean 构造器与原型的 native 方法绑定。
|
||||
pub mod bind_boolean;
|
||||
/// Console 单例对象及其方法绑定。
|
||||
pub mod bind_console;
|
||||
/// DataView 构造器与原型的 native 方法绑定。
|
||||
pub mod bind_data_view;
|
||||
/// Date 构造器与原型的 native 方法绑定。
|
||||
@@ -52,8 +54,6 @@ pub mod bind_symbol;
|
||||
pub mod bind_temporal;
|
||||
/// 各 TypedArray 构造器与共享原型的 native 方法绑定。
|
||||
pub mod bind_typed_array;
|
||||
/// Console 单例对象及其方法绑定。
|
||||
pub mod bind_console;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
|
||||
@@ -1301,8 +1301,7 @@ fn promise_static_with_resolvers(vm: &mut Vm, args: &[u8]) -> NativeResult {
|
||||
Ok(t) => t,
|
||||
Err(err) => return NativeResult::Err(err),
|
||||
};
|
||||
let object_proto =
|
||||
JsValue::from_js_object(vm.session.builtin_world().object_proto.as_ptr() as *mut JsObject);
|
||||
let object_proto = JsValue::from_js_object(vm.session.builtin_world().object_proto.as_ptr() as *mut JsObject);
|
||||
let ptr = vm.alloc_object(JsObject::new_empty(EMPTY_SHAPE_ID, object_proto));
|
||||
let obj = unsafe { &mut *ptr };
|
||||
let sf = vm.kernel_core.perm_interner().as_ref();
|
||||
|
||||
@@ -97,8 +97,8 @@ impl Vm {
|
||||
regexp::clone_regexp_native(src_ref, dst_ref);
|
||||
}
|
||||
// 账目计入:对象头 + 堆数据(属性/元素/meta Vec + native 状态盒),用 clone 后的 dst 核算。
|
||||
self.gc_state.session_bytes_allocated += std::mem::size_of::<JsObject>()
|
||||
+ crate::session_gc::SessionGc::object_heap_data_bytes(dst_ref) as usize;
|
||||
self.gc_state.session_bytes_allocated +=
|
||||
std::mem::size_of::<JsObject>() + crate::session_gc::SessionGc::object_heap_data_bytes(dst_ref) as usize;
|
||||
dst
|
||||
}
|
||||
|
||||
@@ -135,7 +135,8 @@ mod tests {
|
||||
|
||||
fn plain_object(vm: &mut Vm) -> *mut JsObject {
|
||||
let proto = vm.session.builtin_world().object_proto.as_ptr() as *mut JsObject;
|
||||
let ptr = vm.epoch
|
||||
let ptr = vm
|
||||
.epoch
|
||||
.alloc(JsObject::new_empty(EMPTY_SHAPE_ID, JsValue::from_js_object(proto)));
|
||||
// 测试辅助函数绕过 alloc_object,需手动置位 EPOCH_BIT。
|
||||
unsafe { (*ptr).set_is_epoch(true) };
|
||||
|
||||
@@ -62,8 +62,7 @@ impl SessionGc {
|
||||
let elems_ptr = obj.array_elements_raw() as *const Vec<JsValue>;
|
||||
if !elems_ptr.is_null() {
|
||||
unsafe {
|
||||
bytes += size_of::<Vec<JsValue>>() as u64
|
||||
+ ((*elems_ptr).capacity() * size_of::<JsValue>()) as u64;
|
||||
bytes += size_of::<Vec<JsValue>>() as u64 + ((*elems_ptr).capacity() * size_of::<JsValue>()) as u64;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,8 +77,7 @@ impl SessionGc {
|
||||
let hash_ptr = obj.hash_props_raw() as *const Vec<JsValue>;
|
||||
if !hash_ptr.is_null() {
|
||||
unsafe {
|
||||
bytes += size_of::<Vec<JsValue>>() as u64
|
||||
+ ((*hash_ptr).capacity() * size_of::<JsValue>()) as u64;
|
||||
bytes += size_of::<Vec<JsValue>>() as u64 + ((*hash_ptr).capacity() * size_of::<JsValue>()) as u64;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,9 +110,7 @@ impl SessionGc {
|
||||
/// 单趟替代原 `object_edges` + `record_object_string_edges` 双遍模式:消除每对象
|
||||
/// Vec 分配与重复字段遍历。
|
||||
fn scan_edges_for_mark(
|
||||
obj: &JsObject,
|
||||
vm: &Vm,
|
||||
stack: &mut Vec<*mut JsObject>,
|
||||
obj: &JsObject, vm: &Vm, stack: &mut Vec<*mut JsObject>,
|
||||
live_strings: &mut HashSet<*mut JsString, FxBuildHasher>,
|
||||
live_bigints: &mut HashSet<*mut num_bigint::BigInt, FxBuildHasher>,
|
||||
) {
|
||||
@@ -209,9 +205,7 @@ impl SessionGc {
|
||||
|
||||
#[inline]
|
||||
fn process_edge(
|
||||
value: JsValue,
|
||||
vm: &Vm,
|
||||
stack: &mut Vec<*mut JsObject>,
|
||||
value: JsValue, vm: &Vm, stack: &mut Vec<*mut JsObject>,
|
||||
live_strings: &mut HashSet<*mut JsString, FxBuildHasher>,
|
||||
live_bigints: &mut HashSet<*mut num_bigint::BigInt, FxBuildHasher>,
|
||||
) {
|
||||
@@ -591,7 +585,8 @@ impl SessionGc {
|
||||
forwarding.clear();
|
||||
vm.gc_state.forwarding = forwarding;
|
||||
vm.gc_state.session_epoch = new_arena;
|
||||
vm.gc_state.session_bytes_allocated = vm.gc_state
|
||||
vm.gc_state.session_bytes_allocated = vm
|
||||
.gc_state
|
||||
.session_object_ptrs
|
||||
.iter()
|
||||
.filter(|&&ptr| !ptr.is_null())
|
||||
@@ -811,7 +806,8 @@ impl SessionGc {
|
||||
self.debug_assert_marked_object_strings_live(vm);
|
||||
|
||||
// 扣减字符串账目(保留对象账目),再补回存活串字节。
|
||||
let object_bytes: usize = vm.gc_state
|
||||
let object_bytes: usize = vm
|
||||
.gc_state
|
||||
.session_object_ptrs
|
||||
.iter()
|
||||
.filter(|&&ptr| !ptr.is_null())
|
||||
|
||||
@@ -141,8 +141,10 @@ impl Vm {
|
||||
)?;
|
||||
Ok(true)
|
||||
} else {
|
||||
let error =
|
||||
oxide_builtins::error::create_from_text(self, "NEW_EXPRESSION: bytecode constructors not yet supported");
|
||||
let error = oxide_builtins::error::create_from_text(
|
||||
self,
|
||||
"NEW_EXPRESSION: bytecode constructors not yet supported",
|
||||
);
|
||||
self.exception_value = Some(error);
|
||||
self.pending_error_kind = Some(self.thrown_error_kind(error));
|
||||
self.unwind().map(|_| true)
|
||||
@@ -1053,7 +1055,8 @@ impl Vm {
|
||||
// 免 promote 搬移——若按 epoch 分配,首次写入 session 根会把对象搬到新
|
||||
// 地址,缓存中的旧指针与新实例分叉,同一 site 两次取值将返回不同对象。
|
||||
let mut alloc_session_array = |n: usize| {
|
||||
let mut clone = JsObject::new_array(oxide_kernel::shape_forge::EMPTY_SHAPE_ID, proto_val, n, self.epoch.bump());
|
||||
let mut clone =
|
||||
JsObject::new_array(oxide_kernel::shape_forge::EMPTY_SHAPE_ID, proto_val, n, self.epoch.bump());
|
||||
// 标记 session 归属:session_epoch 分配的对象须显式置位,GC/释放路径
|
||||
// 据 SESSION_EPOCH_BIT 判定归属(与 promote_object 的 clone 路径一致)。
|
||||
clone.set_session_epoch(true);
|
||||
@@ -1095,7 +1098,7 @@ impl Vm {
|
||||
// 键,DefinePropertyOrThrow 默认 false)。先于冻结定义(冻结后不可扩展,
|
||||
// 新增属性会被拒)。
|
||||
let raw_si = self.kernel_core.perm_interner().intern("raw").0;
|
||||
// SAFETY: cooked 为本函数分配的 epoch 对象,借用仅在本次 define 内消费。
|
||||
// SAFETY: cooked 为本函数分配的 epoch 对象,借用仅在本次 define 内消费。
|
||||
self.define_data_property(unsafe { &mut *cooked }, raw_si, raw_val, PropAttributes::new(false, false, false))?;
|
||||
|
||||
// 冻结两个数组:不可扩展 + length writable=false(is_frozen 使 length
|
||||
|
||||
Reference in New Issue
Block a user