diff --git a/Cargo.toml b/Cargo.toml
index 42d9c17e46..41e5ee0aca 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -270,6 +270,10 @@ debug = false
incremental = false
overflow-checks = false
+[profile.benchmark]
+inherits = "release"
+debug = true
+
[profile.release.package.tailcall-cloudflare]
strip = true
codegen-units = 1
diff --git a/benches/bench_synth.rs b/benches/bench_synth.rs
index da69c0a990..1ddad96992 100644
--- a/benches/bench_synth.rs
+++ b/benches/bench_synth.rs
@@ -1,5 +1,5 @@
use criterion::Criterion;
-use tailcall::core::jit::common::JP;
+use tailcall::core::jit::fixtures::JP;
pub fn bench_synth_nested(c: &mut Criterion) {
c.bench_function("synth_nested", |b| {
diff --git a/src/core/jit/context.rs b/src/core/jit/context.rs
index 5c865b9369..41dddc368e 100644
--- a/src/core/jit/context.rs
+++ b/src/core/jit/context.rs
@@ -8,21 +8,21 @@ use super::error::*;
use super::{Field, OperationPlan, Positioned};
use crate::core::ir::{ResolverContextLike, SelectionField};
-#[derive(Debug, Clone)]
-pub struct RequestContext {
- plan: OperationPlan,
+#[derive(Debug)]
+pub struct RequestContext<'a, Input> {
+ plan: &'a OperationPlan,
errors: Arc>>>,
}
-impl RequestContext {
- pub fn new(plan: OperationPlan) -> Self {
+impl<'a, Input> RequestContext<'a, Input> {
+ pub fn new(plan: &'a OperationPlan) -> Self {
Self { plan, errors: Arc::new(Mutex::new(vec![])) }
}
pub fn add_error(&self, new_error: Positioned) {
self.errors().push(new_error);
}
pub fn plan(&self) -> &OperationPlan {
- &self.plan
+ self.plan
}
pub fn errors(&self) -> MutexGuard>> {
self.errors.lock().unwrap()
@@ -37,7 +37,7 @@ pub struct Context<'a, Input, Output> {
// TODO: remove the args, since they're already present inside the fields and add support for
// default values.
field: &'a Field,
- request: &'a RequestContext,
+ request: &'a RequestContext<'a, Input>,
}
impl<'a, Input: Clone, Output> Context<'a, Input, Output> {
pub fn new(field: &'a Field, request: &'a RequestContext) -> Self {
@@ -136,7 +136,7 @@ mod test {
fn test_field() {
let plan = setup("query {posts {id title}}").unwrap();
let field = &plan.selection;
- let env = RequestContext::new(plan.clone());
+ let env = RequestContext::new(&plan);
let ctx = Context::::new(&field[0], &env);
let expected = as ResolverContextLike>::field(&ctx).unwrap();
insta::assert_debug_snapshot!(expected);
@@ -145,7 +145,7 @@ mod test {
#[test]
fn test_is_query() {
let plan = setup("query {posts {id title}}").unwrap();
- let env = RequestContext::new(plan.clone());
+ let env = RequestContext::new(&plan);
let ctx = Context::new(&plan.selection[0], &env);
assert!(ctx.is_query());
}
diff --git a/src/core/jit/error.rs b/src/core/jit/error.rs
index fdff5ef18f..7a92d1f740 100644
--- a/src/core/jit/error.rs
+++ b/src/core/jit/error.rs
@@ -51,6 +51,8 @@ pub enum Error {
Validation(#[from] ValidationError),
#[error("{0}")]
ServerError(async_graphql::ServerError),
+ #[error("Unexpected error")]
+ Unknown,
}
impl ErrorExtensions for Error {
@@ -61,6 +63,7 @@ impl ErrorExtensions for Error {
Error::IR(error) => error.extend(),
Error::Validation(error) => error.extend(),
Error::ServerError(error) => error.extend(),
+ Error::Unknown => async_graphql::Error::new(self.to_string()),
}
}
}
diff --git a/src/core/jit/exec.rs b/src/core/jit/exec.rs
index 7dcb2f7371..0381bb53c4 100644
--- a/src/core/jit/exec.rs
+++ b/src/core/jit/exec.rs
@@ -18,18 +18,18 @@ type SharedStore