Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions src/v1/00_core.dag
Original file line number Diff line number Diff line change
Expand Up @@ -218,31 +218,6 @@ fn is_interpreter_blocking_diagnostic(d: CompilerDiagnostic) -> Bool {
}
}

fn is_discovery_corpus_advisory_typecheck_diagnostic(d: CompilerDiagnostic) -> Bool {
match d {
UnresolvedType { name: _, span: _ } => true
TypeMismatch { expected: _, got: _, span: _ } => true
ArityMismatch { name: _, expected: _, got: _, span: _ } => true
VariantNotFound { variant: _, type_name: _, span: _ } => true
FieldNotFound { field: _, type_name: _, span: _ } => true
NonExhaustiveMatch { missing: _, span: _ } => true
MissingAnnotation { fn_name: _, what: _, span: _ } => true
VariantCollision { variant: _, enum1: _, enum2: _, span: _ } => true
SoleConstructorViolation { type_name: _, span: _ } => true
_ => false
}
}

fn is_discovery_corpus_blocking_diagnostic(d: CompilerDiagnostic) -> Bool {
if is_interpreter_blocking_diagnostic(d: d) == false {
false
} else if is_discovery_corpus_advisory_typecheck_diagnostic(d: d) {
false
} else {
true
}
}

fn make_error_node(diagnostic: CompilerDiagnostic, module_name: String) -> ErrorNode {
ErrorNode { diagnostic: diagnostic, module_name: module_name }
}
Expand Down
4 changes: 0 additions & 4 deletions src/v1/compile.dag
Original file line number Diff line number Diff line change
Expand Up @@ -1182,10 +1182,6 @@ fn compile_to_resolved(sources: List<SourceFile>) -> ResolvedPipelineResult {
)
}

fn compile_to_resolved_discovery_corpus_advisory(sources: List<SourceFile>) -> ResolvedPipelineResult {
compile_to_resolved(sources: sources)
}

fn compile_to_resolved_with_options(sources: List<SourceFile>, options: CompilePipelineOptions) -> ResolvedPipelineResult {
let frontend = front_end_sources(sources: sources)
let newline_indices = frontend.newline_indices
Expand Down
103 changes: 18 additions & 85 deletions src/v1/stage0/src/cli_run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,9 @@
use crate::v1_std_core::{
authored_name_at, build_newline_index, byte_to_line_col, diagnostic_to_message,
diagnostic_to_span, empty_intern_table, expr_var_name_at, field_init_node_name_at,
field_init_node_value, has_child_named, intern,
is_discovery_corpus_advisory_typecheck_diagnostic, is_discovery_corpus_blocking_diagnostic,
is_error_diagnostic, is_interpreter_blocking_diagnostic, CompilerDiagnostic, ErrorNode,
ExprData, InferredNode, InternTable, NewlineIndex, Node,
field_init_node_value, has_child_named, intern, is_error_diagnostic,
is_interpreter_blocking_diagnostic, CompilerDiagnostic, ErrorNode, ExprData, InferredNode,
InternTable, NewlineIndex, Node,
};
use serde::Serialize;

Expand All @@ -32,40 +31,6 @@
write as cross_process_write, CacheLookupResult,
};

#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ResolveTypecheckGate {
Strict,
DiscoveryCorpusAdvisory,
}

fn is_resolve_typecheck_blocking(d: Rc<CompilerDiagnostic>, gate: ResolveTypecheckGate) -> bool {
match gate {
ResolveTypecheckGate::Strict => is_interpreter_blocking_diagnostic(d),
ResolveTypecheckGate::DiscoveryCorpusAdvisory => is_discovery_corpus_blocking_diagnostic(d),
}
}

fn log_discovery_advisory_typecheck(
d: &Rc<ErrorNode>,
source_indices: &HashMap<String, Rc<NewlineIndex>>,
gate: ResolveTypecheckGate,
) {
if gate != ResolveTypecheckGate::DiscoveryCorpusAdvisory {
return;
}
if is_discovery_corpus_advisory_typecheck_diagnostic(d.diagnostic.clone())
&& is_interpreter_blocking_diagnostic(d.diagnostic.clone())
{
let span = diagnostic_to_span(d.diagnostic.clone());
let loc = format_error_loc(&span.file, span.start, source_indices);
eprintln!(
"advisory(typecheck): {}: error: {}",
loc,
diagnostic_to_message(d.diagnostic.clone())
);
}
}

pub const UNIFIED_CLAIM_VERIFICATION_MODULE: &str = "v2.std.verification";
pub const BOOL_WITNESS_CLAIM_TYPE: &str = "BoolWitnessClaim";
pub const NODE_CORPUS_TYPE: &str = "NodeCorpus";
Expand Down Expand Up @@ -155,9 +120,9 @@
index
}

type ModuleSourceIndex = HashMap<String, Rc<v1_compiler_compile::SourceFile>>;
pub type ModuleSourceIndex = HashMap<String, Rc<v1_compiler_compile::SourceFile>>;

fn build_module_index(source_roots: &[String]) -> ModuleSourceIndex {
pub fn build_module_index(source_roots: &[String]) -> ModuleSourceIndex {
let mut index = ModuleSourceIndex::new();
for root in source_roots {
let root_path = std::path::Path::new(root);
Expand Down Expand Up @@ -241,7 +206,7 @@
}))
}

fn load_sources_for_entry_with_index(
pub fn load_sources_for_entry_with_index(
index: &ModuleSourceIndex,
entry_path: &str,
) -> Result<Vec<Rc<v1_compiler_compile::SourceFile>>, String> {
Expand Down Expand Up @@ -357,24 +322,7 @@
),
String,
> {
resolve_entry_with_parse_cache(index, entry_file, ResolveTypecheckGate::Strict)
}

pub fn resolve_entry_with_index_for_discovery_corpus(
index: &MultiEntryIndex,
entry_file: &str,
) -> Result<
(
Rc<v1_compiler_compile::ResolvedGraph>,
Rc<HashMap<String, Rc<NewlineIndex>>>,
),
String,
> {
resolve_entry_with_parse_cache(
index,
entry_file,
ResolveTypecheckGate::DiscoveryCorpusAdvisory,
)
resolve_entry_with_parse_cache(index, entry_file)
}

fn resolve_entry_graph_with_index(
Expand All @@ -388,13 +336,12 @@
String,
> {
let sources = load_sources_for_entry_with_index(index, entry_file)?;
resolved_graph_from_sources(sources, ResolveTypecheckGate::Strict)
resolved_graph_from_sources(sources)
}

fn resolve_entry_with_parse_cache(
index: &MultiEntryIndex,
entry_file: &str,
typecheck_gate: ResolveTypecheckGate,
) -> Result<
(
Rc<v1_compiler_compile::ResolvedGraph>,
Expand Down Expand Up @@ -489,18 +436,15 @@
&index.typed_module_cache,
);

for d in typed.diagnostics.iter() {
log_discovery_advisory_typecheck(d, &source_indices, typecheck_gate);
}
let has_type_errors = typed
.diagnostics
.iter()
.any(|d| is_resolve_typecheck_blocking(d.diagnostic.clone(), typecheck_gate));
.any(|d| is_interpreter_blocking_diagnostic(d.diagnostic.clone()));
if has_type_errors {
let msgs: Vec<String> = typed
.diagnostics
.iter()
.filter(|d| is_resolve_typecheck_blocking(d.diagnostic.clone(), typecheck_gate))
.filter(|d| is_interpreter_blocking_diagnostic(d.diagnostic.clone()))
.map(|d| format_error_node(d, &source_indices))
.collect();
return Err(msgs.join("\n"));
Expand Down Expand Up @@ -625,25 +569,19 @@

fn resolved_graph_from_sources(
sources: Vec<Rc<v1_compiler_compile::SourceFile>>,
typecheck_gate: ResolveTypecheckGate,
) -> Result<
(
Rc<v1_compiler_compile::ResolvedGraph>,
Rc<HashMap<String, Rc<NewlineIndex>>>,
),
String,
> {
let result = match typecheck_gate {
ResolveTypecheckGate::Strict => v1_compiler_compile::compile_to_resolved(Rc::new(sources)),
ResolveTypecheckGate::DiscoveryCorpusAdvisory => {
v1_compiler_compile::compile_to_resolved_discovery_corpus_advisory(Rc::new(sources))
}
};
let result = v1_compiler_compile::compile_to_resolved(Rc::new(sources));

let has_errors = result
.diagnostics
.iter()
.any(|d| is_resolve_typecheck_blocking(d.diagnostic.clone(), typecheck_gate));
.any(|d| is_interpreter_blocking_diagnostic(d.diagnostic.clone()));
if has_errors {
let si: HashMap<String, Rc<NewlineIndex>> = result
.newline_indices
Expand All @@ -652,8 +590,7 @@
.collect();
let mut msgs = Vec::new();
for d in result.diagnostics.iter() {
if !is_resolve_typecheck_blocking(d.diagnostic.clone(), typecheck_gate) {
log_discovery_advisory_typecheck(d, &si, typecheck_gate);
if !is_interpreter_blocking_diagnostic(d.diagnostic.clone()) {
continue;
}
let span = diagnostic_to_span(d.diagnostic.clone());
Expand Down Expand Up @@ -751,8 +688,7 @@
if all_sources.is_empty() {
return Ok(std::collections::HashSet::new());
}
let (graph, source_indices) =
resolved_graph_from_sources(all_sources, ResolveTypecheckGate::Strict)?;
let (graph, source_indices) = resolved_graph_from_sources(all_sources)?;
let ctx = v1_interpreter::InterpContext::with_runtime_options(
&graph,
source_indices,
Expand Down Expand Up @@ -813,8 +749,7 @@
return Err("whole-tree corpus is empty (no .dag modules under source roots)".to_string());
}
let modules_excluded = total - all_sources.len();
let (graph, source_indices) =
resolved_graph_from_sources(all_sources, ResolveTypecheckGate::Strict)?;
let (graph, source_indices) = resolved_graph_from_sources(all_sources)?;
Ok(WholeTreeCtx {
ctx: v1_interpreter::InterpContext::with_runtime_options(
graph.as_ref(),
Expand Down Expand Up @@ -1610,8 +1545,7 @@
let mut sources: Vec<Rc<v1_compiler_compile::SourceFile>> =
group.sources.into_values().collect();
sources.sort_by(|a, b| a.path.cmp(&b.path));
let (graph, source_indices) =
resolved_graph_from_sources(sources, ResolveTypecheckGate::DiscoveryCorpusAdvisory)?;
let (graph, source_indices) = resolved_graph_from_sources(sources)?;
let si: HashMap<String, Rc<NewlineIndex>> = source_indices
.iter()
.map(|(k, v)| (k.clone(), v.clone()))
Expand Down Expand Up @@ -1990,7 +1924,7 @@
let mut resolve_times: Vec<u128> = Vec::new();
let mut eval_times: Vec<u128> = Vec::new();
let mut skipped_missing_entry_resolve = 0;

Check warning on line 1927 in src/v1/stage0/src/cli_run.rs

View workflow job for this annotation

GitHub Actions / rust_tests

Diff in /opt/actions-runner/srv1-10/_work/gunbc/gunbc/src/v1/stage0/src/cli_run.rs
// performance_receipts and witness_outcomes are both generated in the same discovery pass
// with matching cardinality and order, so positional matching is stable across discovery runs.
for (perf, outcome) in summary.performance_receipts.iter().zip(summary.witness_outcomes.iter()) {
Expand All @@ -2012,7 +1946,7 @@
let included_witnesses = total_times.len();
let total_percentiles = compute_percentiles(total_times);
let resolve_percentiles = compute_percentiles(resolve_times);
let eval_percentiles = compute_percentiles(eval_times);

Check warning on line 1949 in src/v1/stage0/src/cli_run.rs

View workflow job for this annotation

GitHub Actions / rust_tests

Diff in /opt/actions-runner/srv1-10/_work/gunbc/gunbc/src/v1/stage0/src/cli_run.rs

let mut output = String::new();
output.push_str("╔════════════════════════════════════════════════════════════════════════════╗\n");
Expand All @@ -2022,7 +1956,7 @@

output.push_str(&format!(
"Total witnesses: {} (included in histogram); {} skipped (no entry-resolve timing)\n",
included_witnesses, skipped_missing_entry_resolve

Check warning on line 1959 in src/v1/stage0/src/cli_run.rs

View workflow job for this annotation

GitHub Actions / rust_tests

Diff in /opt/actions-runner/srv1-10/_work/gunbc/gunbc/src/v1/stage0/src/cli_run.rs
));
output.push_str("Note: Resolve times are per-entry-amortized (all witnesses in an entry share the\n");
output.push_str("entry's resolve cost). Eval times are per-witness measurements.\n\n");
Expand All @@ -2033,7 +1967,7 @@
format_nanos(total_percentiles.p50),
format_nanos(total_percentiles.p90),
format_nanos(total_percentiles.p95),
format_nanos(total_percentiles.p99),

Check warning on line 1970 in src/v1/stage0/src/cli_run.rs

View workflow job for this annotation

GitHub Actions / rust_tests

Diff in /opt/actions-runner/srv1-10/_work/gunbc/gunbc/src/v1/stage0/src/cli_run.rs
format_nanos(total_percentiles.p100),
));
output.push_str("└─────────────────────────────────────────────────────────────────────────────┘\n\n");
Expand All @@ -2044,7 +1978,7 @@
format_nanos(resolve_percentiles.p50),
format_nanos(resolve_percentiles.p90),
format_nanos(resolve_percentiles.p95),
format_nanos(resolve_percentiles.p99),

Check warning on line 1981 in src/v1/stage0/src/cli_run.rs

View workflow job for this annotation

GitHub Actions / rust_tests

Diff in /opt/actions-runner/srv1-10/_work/gunbc/gunbc/src/v1/stage0/src/cli_run.rs
format_nanos(resolve_percentiles.p100),
));
output.push_str("└─────────────────────────────────────────────────────────────────────────────┘\n\n");
Expand All @@ -2055,7 +1989,7 @@
format_nanos(eval_percentiles.p50),
format_nanos(eval_percentiles.p90),
format_nanos(eval_percentiles.p95),
format_nanos(eval_percentiles.p99),

Check warning on line 1992 in src/v1/stage0/src/cli_run.rs

View workflow job for this annotation

GitHub Actions / rust_tests

Diff in /opt/actions-runner/srv1-10/_work/gunbc/gunbc/src/v1/stage0/src/cli_run.rs
format_nanos(eval_percentiles.p100),
));
output.push_str("└─────────────────────────────────────────────────────────────────────────────┘\n");
Expand Down Expand Up @@ -3144,9 +3078,8 @@
.map_err(|msg| format!("load sources failed for {}: {}", row.entry, msg))?;
let closure_subject = subject_digest_for_closure(&sources);
let resolve_started = std::time::Instant::now();
let (graph, source_indices) =
resolve_entry_with_index_for_discovery_corpus(index, &row.entry)
.map_err(|msg| format!("resolve failed for {}: {}", row.entry, msg))?;
let (graph, source_indices) = resolve_entry_with_index(index, &row.entry)
.map_err(|msg| format!("resolve failed for {}: {}", row.entry, msg))?;
let resolve_nanos = resolve_started.elapsed().as_nanos();
summary.total_resolve_nanos += resolve_nanos;
summary.entry_resolve_receipts.push(EntryResolveReceipt {
Expand Down
6 changes: 0 additions & 6 deletions src/v1/stage0/src/v1_compiler_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2356,12 +2356,6 @@ pub fn compile_to_resolved(sources: Rc<Vec<Rc<SourceFile>>>) -> Rc<ResolvedPipel
compile_to_resolved_with_options(sources, default_compile_pipeline_options())
}

pub fn compile_to_resolved_discovery_corpus_advisory(
sources: Rc<Vec<Rc<SourceFile>>>,
) -> Rc<ResolvedPipelineResult> {
compile_to_resolved(sources)
}

pub fn compile_to_resolved_with_options(
sources: Rc<Vec<Rc<SourceFile>>>,
options: CompilePipelineOptions,
Expand Down
25 changes: 0 additions & 25 deletions src/v1/stage0/src/v1_std_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -685,31 +685,6 @@ pub fn is_interpreter_blocking_diagnostic(d: Rc<CompilerDiagnostic>) -> bool {
}
}

pub fn is_discovery_corpus_advisory_typecheck_diagnostic(d: Rc<CompilerDiagnostic>) -> bool {
match (*d).clone() {
CompilerDiagnostic::UnresolvedType { .. } => true,
CompilerDiagnostic::TypeMismatch { .. } => true,
CompilerDiagnostic::ArityMismatch { .. } => true,
CompilerDiagnostic::VariantNotFound { .. } => true,
CompilerDiagnostic::FieldNotFound { .. } => true,
CompilerDiagnostic::NonExhaustiveMatch { .. } => true,
CompilerDiagnostic::MissingAnnotation { .. } => true,
CompilerDiagnostic::VariantCollision { .. } => true,
CompilerDiagnostic::SoleConstructorViolation { .. } => true,
_ => false,
}
}

pub fn is_discovery_corpus_blocking_diagnostic(d: Rc<CompilerDiagnostic>) -> bool {
if !is_interpreter_blocking_diagnostic(d.clone()) {
false
} else if is_discovery_corpus_advisory_typecheck_diagnostic(d.clone()) {
false
} else {
true
}
}

pub fn make_error_node(diagnostic: Rc<CompilerDiagnostic>, module_name: String) -> Rc<ErrorNode> {
Rc::new(ErrorNode {
diagnostic: diagnostic,
Expand Down
Loading
Loading