difftreelog
refactor remove debug gc trace
in: master
5 files changed
crates/jrsonnet-evaluator/src/builtin/manifest.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/builtin/manifest.rs
+++ b/crates/jrsonnet-evaluator/src/builtin/manifest.rs
@@ -126,7 +126,6 @@
buf.push('}');
}
Val::Func(_) => throw!(RuntimeError("tried to manifest function".into())),
- Val::DebugGcTraceValue(v) => manifest_json_ex_buf(&v.value, buf, cur_padding, options)?,
};
Ok(())
}
crates/jrsonnet-evaluator/src/builtin/mod.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/builtin/mod.rs
+++ b/crates/jrsonnet-evaluator/src/builtin/mod.rs
@@ -1,8 +1,8 @@
use crate::{
equals,
error::{Error::*, Result},
- parse_args, primitive_equals, push, throw, with_state, ArrValue, Context, DebugGcTraceValue,
- EvaluationState, FuncVal, LazyVal, Val,
+ parse_args, primitive_equals, push, throw, with_state, ArrValue, Context, EvaluationState,
+ FuncVal, LazyVal, Val,
};
use format::{format_arr, format_obj};
use jrsonnet_gc::Gc;
@@ -69,8 +69,6 @@
("md5".into(), builtin_md5),
("base64".into(), builtin_base64),
("trace".into(), builtin_trace),
- ("gc".into(), builtin_gc),
- ("gcTrace".into(), builtin_gc_trace),
("join".into(), builtin_join),
("escapeStringJson".into(), builtin_escape_string_json),
("manifestJsonEx".into(), builtin_manifest_json_ex),
@@ -446,27 +444,6 @@
}
eprintln!(" {}", str);
Ok(rest)
- })
-}
-
-fn builtin_gc(context: Context, _loc: Option<&ExprLocation>, args: &ArgsDesc) -> Result<Val> {
- parse_args!(context, "gc", args, 1, [
- 0, rest: ty!(any);
- ], {
- println!("GC start");
- jrsonnet_gc::force_collect();
- println!("GC done");
-
- Ok(rest)
- })
-}
-
-fn builtin_gc_trace(context: Context, _loc: Option<&ExprLocation>, args: &ArgsDesc) -> Result<Val> {
- parse_args!(context, "gcTrace", args, 2, [
- 0, name: ty!(string) => Val::Str;
- 1, rest: ty!(any);
- ], {
- Ok(DebugGcTraceValue::create(name, rest))
})
}
crates/jrsonnet-evaluator/src/evaluate.rsdiffbeforeafterboth215215216pub fn evaluate_add_op(a: &Val, b: &Val) -> Result<Val> {216pub fn evaluate_add_op(a: &Val, b: &Val) -> Result<Val> {217 Ok(match (a, b) {217 Ok(match (a, b) {218 (Val::DebugGcTraceValue(v1), Val::DebugGcTraceValue(v2)) => {219 evaluate_add_op(&v1.value, &v2.value)?220 }221 (Val::Str(v1), Val::Str(v2)) => Val::Str(((**v1).to_owned() + v2).into()),218 (Val::Str(v1), Val::Str(v2)) => Val::Str(((**v1).to_owned() + v2).into()),222219223 // Can't use generic json serialization way, because it depends on number to string concatenation (std.jsonnet:890)220 // Can't use generic json serialization way, because it depends on number to string concatenation (std.jsonnet:890)crates/jrsonnet-evaluator/src/integrations/serde.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/integrations/serde.rs
+++ b/crates/jrsonnet-evaluator/src/integrations/serde.rs
@@ -42,7 +42,6 @@
Self::Object(out)
}
Val::Func(_) => throw!(RuntimeError("tried to manifest function".into())),
- Val::DebugGcTraceValue(v) => Self::try_from(&*v.value as &Val)?,
})
}
}
crates/jrsonnet-evaluator/src/val.rsdiffbeforeafterboth--- a/crates/jrsonnet-evaluator/src/val.rs
+++ b/crates/jrsonnet-evaluator/src/val.rs
@@ -9,7 +9,7 @@
native::NativeCallback,
throw, with_state, Context, ObjValue, Result,
};
-use jrsonnet_gc::{Finalize, Gc, GcCell, Trace};
+use jrsonnet_gc::{Gc, GcCell, Trace};
use jrsonnet_interner::IStr;
use jrsonnet_parser::{el, Arg, ArgsDesc, Expr, ExprLocation, LiteralType, LocExpr, ParamsDesc};
use jrsonnet_types::ValType;
@@ -345,65 +345,6 @@
}
}
-#[derive(Debug)]
-pub struct DebugGcTraceValue {
- name: IStr,
- pub value: Box<Val>,
-}
-impl DebugGcTraceValue {
- fn print(&self, action: &str) {
- println!("{} {}#{:?}", action, self.name, &*self.value as *const _)
- }
-}
-impl Finalize for DebugGcTraceValue {
- fn finalize(&self) {
- self.print("Garbage-collecting")
- }
-}
-impl Drop for DebugGcTraceValue {
- fn drop(&mut self) {
- self.print("Garbage-collected")
- }
-}
-unsafe impl Trace for DebugGcTraceValue {
- unsafe fn trace(&self) {
- self.print("Traced");
- self.value.trace()
- }
- unsafe fn root(&self) {
- self.print("Rooted");
- self.value.root()
- }
- unsafe fn unroot(&self) {
- self.print("Unrooted");
- self.value.unroot()
- }
- fn finalize_glue(&self) {
- Finalize::finalize(self)
- }
-}
-impl Clone for DebugGcTraceValue {
- fn clone(&self) -> Self {
- self.print("Cloned");
- let value = Self {
- name: self.name.clone(),
- value: self.value.clone(),
- };
- value.print("I'm clone");
- value
- }
-}
-impl DebugGcTraceValue {
- pub fn create(name: IStr, value: Val) -> Val {
- let value = Self {
- name,
- value: Box::new(value),
- };
- value.print("Constructed");
- Val::DebugGcTraceValue(value)
- }
-}
-
#[derive(Debug, Clone, Trace)]
#[trivially_drop]
pub enum Val {
@@ -414,7 +355,6 @@
Arr(ArrValue),
Obj(ObjValue),
Func(Gc<FuncVal>),
- DebugGcTraceValue(DebugGcTraceValue),
}
macro_rules! matches_unwrap {
@@ -471,7 +411,6 @@
Self::Bool(_) => ValType::Bool,
Self::Null => ValType::Null,
Self::Func(..) => ValType::Func,
- Self::DebugGcTraceValue(v) => v.value.value_type(),
}
}