From f67a87c397af4590fb73cca6c2c1be9af76ac9bb Mon Sep 17 00:00:00 2001 From: Agent Smith Date: Thu, 19 Dec 2024 18:30:31 +0800 Subject: [PATCH] chore: make clippy happy --- .github/workflows/test.yml | 4 ++-- immix | 2 +- planglib/std/task/reactor.pi | 3 +++ src/ast/ctx/cast.rs | 4 +--- src/ast/test.rs | 1 + test/test/std_test.pi | 5 ++++- vm/src/lib.rs | 11 +++++++---- vm/src/mutex/mod.rs | 3 +++ 8 files changed, 22 insertions(+), 11 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index af2978de..12511b56 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -88,7 +88,7 @@ jobs: CARGO_TARGET_DIR: ${{ matrix.CARGO_TARGET_DIR }} KAGARI_LIB_ROOT: ${{ github.workspace }}${{ matrix.KAGARI_LIB_ROOT }} PL_ROOT: ${{ github.workspace }}${{ matrix.PL_ROOT }} - GC_LOG: warn + GC_LOG: trace steps: - uses: actions/checkout@v4 with: @@ -120,7 +120,7 @@ jobs: uses: actions-rs/cargo@v1 with: command: build - args: --manifest-path vm/Cargo.toml --target-dir target -vv + args: --manifest-path vm/Cargo.toml --target-dir target -vv --no-default-features --features "static,immix,jitdylib" # - name: build plc # uses: actions-rs/cargo@v1 diff --git a/immix b/immix index e8ee732b..9523d1c0 160000 --- a/immix +++ b/immix @@ -1 +1 @@ -Subproject commit e8ee732bdfaeba9b122245573937fb27ab09f692 +Subproject commit 9523d1c035a5969a77f3101cf916b8230ca46108 diff --git a/planglib/std/task/reactor.pi b/planglib/std/task/reactor.pi index 506d23f1..79306c30 100644 --- a/planglib/std/task/reactor.pi +++ b/planglib/std/task/reactor.pi @@ -180,7 +180,10 @@ fn async_cb(async_t:*libuv::uv_async_t) void { return; } +fn eprinti64ln(i:i64) void ; + fn idle_cb(_idle: *libuv::uv_idle_t) void { + eprinti64ln(9877); gc::DioGC__safepoint(asm_sp()); return; } diff --git a/src/ast/ctx/cast.rs b/src/ast/ctx/cast.rs index 35e72991..cbfecdd4 100644 --- a/src/ast/ctx/cast.rs +++ b/src/ast/ctx/cast.rs @@ -288,9 +288,7 @@ impl<'a, 'ctx> Ctx<'a> { if let PLType::Union(u) = &*target_pltype.borrow() { let mut union_members = vec![]; for tp in &u.sum_types { - let tp = self.run_in_type_mod(u, |ctx,u|{ - tp.get_type(ctx, builder, true) - })?; + let tp = self.run_in_type_mod(u, |ctx, _| tp.get_type(ctx, builder, true))?; union_members.push(tp); } for (i, tp) in union_members.iter().enumerate() { diff --git a/src/ast/test.rs b/src/ast/test.rs index 375cc9df..09191093 100644 --- a/src/ast/test.rs +++ b/src/ast/test.rs @@ -511,6 +511,7 @@ fn test_compile() { .unwrap_or_else(|_| panic!("static compiled file not found {:?}", exe)); eprintln!("exec: {:?}", exe); let mut child = Command::new(exe.to_str().unwrap()) + .env("GC_LOG", "info") .spawn() .expect("failed to execute compiled program"); diff --git a/test/test/std_test.pi b/test/test/std_test.pi index 9e1de084..74f7dc73 100644 --- a/test/test/std_test.pi +++ b/test/test/std_test.pi @@ -39,6 +39,7 @@ impl Task for CustomTask { pub fn test_std() void { iter::test_generator(); + println!("test_gen done"); let re = "abcde".index_of("cde"); let chars = [1,2,3]; let subchars = [3]; @@ -72,7 +73,7 @@ pub fn test_std() void { let mi = math::min(1.0, 2.0); panic::assert(mi==1.0); panic::assert((math::cos(math::PI) - -1.0).abs() < 0.0000001); - + println!("math done"); let task = async_f1(); task.poll(||=>{ return; @@ -103,7 +104,9 @@ pub fn test_std() void { }); panic::assert(b == 100); fn1(test{a:9999}); + println!("async done"); test_json(); + println!("json done"); return; } diff --git a/vm/src/lib.rs b/vm/src/lib.rs index 54ae1758..73653755 100644 --- a/vm/src/lib.rs +++ b/vm/src/lib.rs @@ -28,6 +28,11 @@ fn printi64ln(i: i64) { println!("{}", i); } +#[is_runtime] +fn eprinti64ln(i: i64) { + eprintln!("{}", i); +} + #[is_runtime] fn pl_panic() { println!("pivot lang panic occured!"); @@ -91,21 +96,19 @@ fn vm_ftoa(f: f32, rec: *mut u8) { } #[is_runtime] -fn new_thread(f: *mut i128, sp:*mut u8) { +fn new_thread(f: *mut i128, sp: *mut u8) { // f's first 8 byte is fn pointer, next 8 byte is data pointer let ptr = f as *const i64; let f_ptr = ptr as *const extern "C" fn(i64); let data_ptr = unsafe { *ptr.offset(1) }; let func = unsafe { *f_ptr }; let (s, r) = channel::<()>(); - let ptr_i = ptr as i64; + // let ptr_i = ptr as i64; immix::pin(data_ptr as _); // immix::gc_keep_live(data_ptr as _); // immix::gc_add_root(data_ptr as *mut _, ObjectType::Pointer.int_value()); let c = move || { // thread::sleep(std::time::Duration::from_secs(1)); - let sp = immix::Collector::current_sp(); - immix::set_high_sp(sp); // immix::gc_keep_live(data_ptr as _); // immix::set_evacuation(false); // immix::gc_add_root(&mut f as *mut _ as *mut _, ObjectType::Trait.int_value()); diff --git a/vm/src/mutex/mod.rs b/vm/src/mutex/mod.rs index d5446ece..918a30b8 100644 --- a/vm/src/mutex/mod.rs +++ b/vm/src/mutex/mod.rs @@ -6,6 +6,8 @@ use std::{ use internal_macro::is_runtime; +use crate::logger::SimpleLogger; + struct MutexContainer { mutex: Mutex<()>, guard: Cell>>, @@ -16,6 +18,7 @@ pub struct OpaqueMutex { #[is_runtime] fn create_mutex(mutex: *mut *mut OpaqueMutex) -> u64 { + SimpleLogger::init_from_env("GC_LOG"); // immix::pin(mutex.cast()); // immix::gc_keep_live_pinned(mutex.cast()); *mutex = Box::into_raw(Box::new(MutexContainer {