Skip to content

Commit 6135887

Browse files
committed
remove table allocator
1 parent eccbf7f commit 6135887

5 files changed

Lines changed: 62 additions & 291 deletions

File tree

crates/luars/src/gc/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ mod gc_object;
3939
mod object_allocator;
4040
mod paged_pool;
4141
mod string_interner;
42-
mod table_allocator;
4342

4443
#[cfg(debug_assertions)]
4544
use std::collections::HashMap;
@@ -54,7 +53,6 @@ pub use gc_object::*;
5453
pub use object_allocator::*;
5554
pub use paged_pool::*;
5655
pub use string_interner::*;
57-
pub use table_allocator::*;
5856

5957
// GC Parameters (from lua.h)
6058
pub const MINORMUL: usize = 0; // Minor collection multiplier

crates/luars/src/gc/object_allocator.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ use crate::{
88
LuaRawFunction, LuaRawTable, LuaResult, LuaValue,
99
gc::{
1010
GC, GcCClosure, GcFunction, GcObjectOwner, GcProto, GcRClosure, GcString, GcTable,
11-
GcThread, GcUpvalue, GcUserdata, PagedPool, Pooled, ProtoPtr, StringPtr, TableAllocHandle,
12-
UpvaluePtr,
11+
GcThread, GcUpvalue, GcUserdata, PagedPool, Pooled, ProtoPtr, StringPtr, UpvaluePtr,
1312
},
1413
};
1514

@@ -26,7 +25,6 @@ pub struct ObjectAllocator {
2625
userdata_pool: PagedPool<GcUserdata>,
2726
proto_pool: PagedPool<GcProto>,
2827
call_info_pool: PagedPool<CallInfo>,
29-
table_allocator: TableAllocHandle,
3028
}
3129

3230
impl Default for ObjectAllocator {
@@ -48,7 +46,6 @@ impl ObjectAllocator {
4846
userdata_pool: PagedPool::new(16),
4947
proto_pool: PagedPool::new(16),
5048
call_info_pool: PagedPool::new(64),
51-
table_allocator: TableAllocHandle::default(),
5249
}
5350
}
5451

@@ -121,11 +118,7 @@ impl ObjectAllocator {
121118
};
122119
let size = (base_size + array_bytes + hash_bytes) as u32;
123120
let ptr = self.table_pool.alloc(GcTable::new(
124-
LuaRawTable::new(
125-
array_size as u32,
126-
hash_size as u32,
127-
self.table_allocator.clone(),
128-
),
121+
LuaRawTable::new(array_size as u32, hash_size as u32),
129122
current_white,
130123
size,
131124
));
@@ -280,7 +273,6 @@ impl ObjectAllocator {
280273
pub fn trim_after_full_gc(&mut self) {
281274
self.table_pool.release_empty_pages();
282275
self.string_pool.release_empty_pages();
283-
self.table_allocator.clear_cached_blocks();
284276
self.cclosure_pool.release_empty_pages();
285277
self.rclosure_pool.release_empty_pages();
286278
self.upvalue_pool.release_empty_pages();

crates/luars/src/gc/table_allocator.rs

Lines changed: 0 additions & 230 deletions
This file was deleted.

crates/luars/src/lua_value/lua_table/mod.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@
22
pub mod native_table;
33

44
use super::lua_value::LuaValue;
5-
use crate::{
6-
LuaError, LuaResult,
7-
gc::{TableAllocHandle, TablePtr},
8-
};
5+
use crate::{LuaError, LuaResult, gc::TablePtr};
96
use native_table::NativeTable;
107

118
/// Mask covering all TM flags — any bit set to 1 represents a cacheable TM.
@@ -23,11 +20,11 @@ pub struct LuaRawTable {
2320

2421
impl LuaRawTable {
2522
/// 创建新table
26-
pub fn new(asize: u32, hsize: u32, allocator: TableAllocHandle) -> Self {
23+
pub fn new(asize: u32, hsize: u32) -> Self {
2724
Self {
2825
meta: TablePtr::null(),
2926
flags: 0,
30-
impl_table: NativeTable::new(asize, hsize, allocator),
27+
impl_table: NativeTable::new(asize, hsize),
3128
}
3229
}
3330

0 commit comments

Comments
 (0)