mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 00:01:16 +00:00
DEBUG HACKS, DO NOT MERGE
This commit is contained in:
parent
3e511acbcc
commit
e95d32e821
10 changed files with 120 additions and 7 deletions
|
@ -45,13 +45,26 @@ use std::path::{Path, PathBuf};
|
|||
use std::str::from_utf8_unchecked;
|
||||
use std::sync::Arc;
|
||||
use std::{env, fs};
|
||||
use wasm_bindgen::prelude::wasm_bindgen;
|
||||
|
||||
#[wasm_bindgen]
|
||||
extern "C" {
|
||||
#[wasm_bindgen(js_namespace = console)]
|
||||
fn log(s: &str);
|
||||
}
|
||||
|
||||
// In-browser debugging
|
||||
#[allow(unused_macros)]
|
||||
macro_rules! console_log {
|
||||
($($t:tt)*) => (log(&format_args!($($t)*).to_string()))
|
||||
}
|
||||
|
||||
use crate::work::{Dependencies, Phase};
|
||||
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
use std::time::{Duration, SystemTime};
|
||||
#[cfg(target_family = "wasm")]
|
||||
use crate::wasm_system_time::{Duration, SystemTime};
|
||||
#[cfg(not(target_family = "wasm"))]
|
||||
use std::time::{Duration, SystemTime};
|
||||
|
||||
/// Default name for the binary generated for an app, if an invalid one was specified.
|
||||
const DEFAULT_APP_OUTPUT_PATH: &str = "app";
|
||||
|
@ -718,6 +731,7 @@ enum BuildTask<'a> {
|
|||
},
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
enum WorkerMsg {
|
||||
Shutdown,
|
||||
TaskAdded,
|
||||
|
@ -831,6 +845,8 @@ pub fn load_and_monomorphize_from_str<'a>(
|
|||
) -> Result<MonomorphizedModule<'a>, LoadingProblem<'a>> {
|
||||
use LoadResult::*;
|
||||
|
||||
console_log!("load_and_monomorphize_from_str");
|
||||
|
||||
let load_start = LoadStart::from_str(arena, filename, src)?;
|
||||
|
||||
match load(
|
||||
|
@ -997,6 +1013,8 @@ fn load<'a>(
|
|||
goal_phase: Phase,
|
||||
target_info: TargetInfo,
|
||||
) -> Result<LoadResult<'a>, LoadingProblem<'a>> {
|
||||
console_log!("load start");
|
||||
|
||||
let LoadStart {
|
||||
arc_modules,
|
||||
ident_ids_by_module,
|
||||
|
@ -1008,10 +1026,14 @@ fn load<'a>(
|
|||
|
||||
let (msg_tx, msg_rx) = bounded(1024);
|
||||
|
||||
console_log!("before msg_tx.send");
|
||||
|
||||
msg_tx
|
||||
.send(root_msg)
|
||||
.map_err(|_| LoadingProblem::MsgChannelDied)?;
|
||||
|
||||
console_log!("after msg_tx.send");
|
||||
|
||||
let mut state = State {
|
||||
root_id,
|
||||
target_info,
|
||||
|
@ -1038,15 +1060,21 @@ fn load<'a>(
|
|||
// We'll add tasks to this, and then worker threads will take tasks from it.
|
||||
let injector = Injector::new();
|
||||
|
||||
console_log!("after injector");
|
||||
|
||||
let (worker_msg_tx, worker_msg_rx) = bounded(1024);
|
||||
let worker_listener = worker_msg_tx;
|
||||
let worker_listeners = arena.alloc([worker_listener]);
|
||||
|
||||
console_log!("before Worker lifo");
|
||||
|
||||
let worker = Worker::new_lifo();
|
||||
let stealer = worker.stealer();
|
||||
let stealers = &[stealer];
|
||||
|
||||
console_log!("before loop");
|
||||
loop {
|
||||
console_log!("inside loop");
|
||||
match state_thread_step(arena, state, worker_listeners, &injector, &msg_tx, &msg_rx) {
|
||||
Ok(ControlFlow::Break(done)) => return Ok(done),
|
||||
Ok(ControlFlow::Continue(new_state)) => {
|
||||
|
@ -1054,8 +1082,9 @@ fn load<'a>(
|
|||
}
|
||||
Err(e) => return Err(e),
|
||||
}
|
||||
console_log!("after match");
|
||||
|
||||
match worker_task_step(
|
||||
let control_flow = worker_task_step(
|
||||
arena,
|
||||
&worker,
|
||||
&injector,
|
||||
|
@ -1064,7 +1093,11 @@ fn load<'a>(
|
|||
&msg_tx,
|
||||
src_dir,
|
||||
target_info,
|
||||
) {
|
||||
);
|
||||
|
||||
console_log!("control flow {:?}", control_flow);
|
||||
|
||||
match control_flow {
|
||||
Ok(ControlFlow::Break(())) => panic!("the worker should not break!"),
|
||||
Ok(ControlFlow::Continue(())) => {
|
||||
// progress was made
|
||||
|
@ -1453,7 +1486,10 @@ fn worker_task_step<'a>(
|
|||
src_dir: &Path,
|
||||
target_info: TargetInfo,
|
||||
) -> Result<ControlFlow<(), ()>, LoadingProblem<'a>> {
|
||||
match worker_msg_rx.try_recv() {
|
||||
console_log!("worker_task_step");
|
||||
let recv = worker_msg_rx.try_recv();
|
||||
console_log!("recv {:?}", &recv);
|
||||
match recv {
|
||||
Ok(msg) => {
|
||||
match msg {
|
||||
WorkerMsg::Shutdown => {
|
||||
|
@ -1474,8 +1510,10 @@ fn worker_task_step<'a>(
|
|||
// added. In that case, do nothing, and keep waiting
|
||||
// until we receive a Shutdown message.
|
||||
if let Some(task) = find_task(&worker, injector, stealers) {
|
||||
console_log!("found Some task {:?}", task);
|
||||
let result =
|
||||
run_task(task, worker_arena, src_dir, msg_tx.clone(), target_info);
|
||||
console_log!("run_task result {:?}", &result);
|
||||
|
||||
match result {
|
||||
Ok(()) => {}
|
||||
|
@ -1495,6 +1533,7 @@ fn worker_task_step<'a>(
|
|||
}
|
||||
}
|
||||
}
|
||||
console_log!("after if let Some(task)");
|
||||
|
||||
Ok(ControlFlow::Continue(()))
|
||||
}
|
||||
|
@ -3129,12 +3168,15 @@ fn run_solve<'a>(
|
|||
dep_idents: MutMap<ModuleId, IdentIds>,
|
||||
unused_imports: MutMap<ModuleId, Region>,
|
||||
) -> Msg<'a> {
|
||||
|
||||
console_log!("run_solve");
|
||||
// We have more constraining work to do now, so we'll add it to our timings.
|
||||
let constrain_start = SystemTime::now();
|
||||
|
||||
// Finish constraining the module by wrapping the existing Constraint
|
||||
// in the ones we just computed. We can do this off the main thread.
|
||||
let constraint = constrain_imports(imported_symbols, constraint, &mut var_store);
|
||||
console_log!("after constrain_imports");
|
||||
|
||||
let constrain_end = SystemTime::now();
|
||||
|
||||
|
@ -3154,12 +3196,16 @@ fn run_solve<'a>(
|
|||
let (solved_subs, solved_env, problems) =
|
||||
roc_solve::module::run_solve(aliases, rigid_variables, constraint, var_store);
|
||||
|
||||
console_log!("after run_solve");
|
||||
|
||||
let mut exposed_vars_by_symbol: MutMap<Symbol, Variable> = solved_env.vars_by_symbol.clone();
|
||||
exposed_vars_by_symbol.retain(|k, _| exposed_symbols.contains(k));
|
||||
|
||||
let solved_types =
|
||||
roc_solve::module::make_solved_types(&solved_env, &solved_subs, &exposed_vars_by_symbol);
|
||||
|
||||
console_log!("after make_solved_types");
|
||||
|
||||
let solved_module = SolvedModule {
|
||||
exposed_vars_by_symbol,
|
||||
exposed_symbols: exposed_symbols.into_iter().collect::<Vec<_>>(),
|
||||
|
@ -3175,6 +3221,8 @@ fn run_solve<'a>(
|
|||
module_timing.constrain += constrain_elapsed;
|
||||
module_timing.solve = solve_end.duration_since(constrain_end).unwrap();
|
||||
|
||||
console_log!("creating Msg::SolvedTypes");
|
||||
|
||||
// Send the subs to the main thread for processing,
|
||||
Msg::SolvedTypes {
|
||||
module_id,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue