-
Notifications
You must be signed in to change notification settings - Fork 556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add statements->functions map to SierraDebugInfo
#5325
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 22 files at r1, all commit messages.
Reviewable status: 1 of 22 files reviewed, 1 unresolved discussion (waiting on @piotmag769)
crates/cairo-lang-sierra/src/debug_info.rs
line 40 at r1 (raw file):
pub annotations: Annotations, pub statements_functions: Option<StatementsFunctions>,
how difficult would it be to just insert into the annotations structure?
this would add no dependencies here.
Code quote:
pub statements_functions: Option<StatementsFunctions>,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 1 of 23 files reviewed, 1 unresolved discussion (waiting on @orizi)
crates/cairo-lang-sierra/src/debug_info.rs
line 40 at r1 (raw file):
Previously, orizi wrote…
how difficult would it be to just insert into the annotations structure?
this would add no dependencies here.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 7 of 22 files at r1, 16 of 16 files at r2, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @orizi)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 12 of 12 files at r3, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @orizi)
crates/cairo-lang-compiler/src/lib.rs
line 38 at r3 (raw file):
/// Adds mappings used by [cairo-profiler](https://github.com/software-mansion/cairo-profiler) /// to debug info annotations. pub add_cairo_profiler_annotations: bool,
Decided to make it configurable so it doesn't slow down the compiler
crates/cairo-lang-starknet/src/test_utils.rs
line 85 at r3 (raw file):
allowed_libfuncs_list_name: Some(BUILTIN_ALL_LIBFUNCS_LIST.to_string()), diagnostics_reporter, add_cairo_profiler_annotations: true,
Here for testing purposes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @piotmag769)
crates/cairo-lang-sierra/src/debug_info.rs
line 83 at r3 (raw file):
} else { Default::default() };
add all of this externally - not here.
Code quote:
/// The mapping from sierra statement index to fully qualified Cairo path of the Cairo function
/// (if obtainable) which caused the statement to be generated.
/// Should be created using [`StatementsLocation::extract_statements_functions`].
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize)]
pub struct StatementsFunctions {
pub statements_to_functions_map: HashMap<StatementIdx, Option<String>>,
}
impl DebugInfo {
/// Extracts the existing debug info from a program.
pub fn extract(program: &Program, statements_functions: Option<StatementsFunctions>) -> Self {
let annotations = if let Some(sf) = statements_functions {
let mapping = serde_json::to_value(sf.statements_to_functions_map).unwrap();
OrderedHashMap::from([(
"github.com/software-mansion/cairo-profiler".to_string(),
serde_json::Value::from_iter([("statements_functions", mapping)]),
)])
} else {
Default::default()
};
crates/cairo-lang-sierra-generator/src/program_generator.rs
line 336 at r3 (raw file):
db: &dyn SierraGenGroup, requested_crate_ids: Vec<CrateId>, add_cairo_profiler_annotations: bool,
probably - since this is not directly profiler related
Suggestion:
add_location_annotations: bool,
crates/cairo-lang-sierra-generator/src/statements_locations.rs
line 152 at r3 (raw file):
} pub fn extract_statements_functions(&self, db: &dyn DefsGroup) -> StatementsFunctions {
doc.
crates/cairo-lang-starknet/src/test_utils.rs
line 85 at r3 (raw file):
Previously, piotmag769 (Piotr Magiera) wrote…
Here for testing purposes
make it false - as i don't want this data for the starknet tests.
you should do a specific test for it somewhere else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @orizi)
crates/cairo-lang-sierra/src/debug_info.rs
line 83 at r3 (raw file):
Previously, orizi wrote…
add all of this externally - not here.
You mean in the other function? Done.
crates/cairo-lang-sierra-generator/src/program_generator.rs
line 336 at r3 (raw file):
Previously, orizi wrote…
probably - since this is not directly profiler related
Done.
crates/cairo-lang-sierra-generator/src/statements_locations.rs
line 152 at r3 (raw file):
Previously, orizi wrote…
doc.
Done.
crates/cairo-lang-starknet/src/test_utils.rs
line 85 at r3 (raw file):
Previously, orizi wrote…
make it false - as i don't want this data for the starknet tests.
you should do a specific test for it somewhere else.
Done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 22 of 22 files at r4, 14 of 14 files at r5, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @orizi)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 12 files at r3, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @piotmag769)
crates/cairo-lang-sierra/src/debug_info.rs
line 83 at r3 (raw file):
Previously, piotmag769 (Piotr Magiera) wrote…
You mean in the other function? Done.
this shouldn't be in this crate at all.
move this to the place where it is actually added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @piotmag769)
crates/cairo-lang-sierra/src/debug_info.rs
line 83 at r3 (raw file):
Previously, orizi wrote…
this shouldn't be in this crate at all.
move this to the place where it is actually added.
or a completely different crate.
i expect to see no changes in the sierra crate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 10 of 10 files at r6, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @orizi)
crates/cairo-lang-sierra/src/debug_info.rs
line 83 at r3 (raw file):
Previously, orizi wrote…
or a completely different crate.
i expect to see no changes in the sierra crate.
Created a different crate, done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 11 of 11 files at r7, all commit messages.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @orizi)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 22 files at r4, 13 of 14 files at r5, 1 of 10 files at r6, 3 of 11 files at r7, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @piotmag769)
crates/cairo-lang-sierra-generator/src/program_generator.rs
line 291 at r7 (raw file):
program, debug_info: SierraProgramDebugInfo { statements_locations, statements_functions }, }))
can't you call this externally?
you already have the db and the extra results.
Code quote:
let statements_locations = StatementsLocations::from_locations_vec(&statements_locations);
let statements_functions = if add_location_annotations {
Some(statements_locations.extract_statements_functions(db.upcast()))
} else {
None
};
Ok(Arc::new(SierraProgramWithDebug {
program,
debug_info: SierraProgramDebugInfo { statements_locations, statements_functions },
}))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 5 of 5 files at r8, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @orizi)
crates/cairo-lang-sierra-generator/src/program_generator.rs
line 291 at r7 (raw file):
Previously, orizi wrote…
can't you call this externally?
you already have the db and the extra results.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @piotmag769)
crates/cairo-lang-sierra-generator/src/program_generator.rs
line 291 at r7 (raw file):
Previously, piotmag769 (Piotr Magiera) wrote…
Done
You can remove it (and the bool) from here completely.
just call extract_statement_functions
directly on the output if required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 6 of 6 files at r9, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @orizi)
crates/cairo-lang-sierra-generator/src/program_generator.rs
line 291 at r7 (raw file):
Previously, orizi wrote…
You can remove it (and the bool) from here completely.
just call
extract_statement_functions
directly on the output if required.
Misunderstood you, done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 6 files at r9, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @piotmag769)
crates/cairo-lang-sierra-generator/src/program_generator.rs
line 291 at r7 (raw file):
Previously, piotmag769 (Piotr Magiera) wrote…
Misunderstood you, done.
remove it completely.
pub statements_functions: Option<StatementsFunctions>,
is not needed as part of the structure at all IIUC.
you can just have the db available, and extract statements_functions
from statements_functions
and strait into annotations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @piotmag769)
crates/cairo-lang-sierra-generator/src/function_generator_test_data/generics
line 14 at r9 (raw file):
foo //! > module_code
revert
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: 28 of 37 files reviewed, 2 unresolved discussions (waiting on @orizi)
crates/cairo-lang-sierra-generator/src/program_generator.rs
line 291 at r7 (raw file):
Previously, orizi wrote…
remove it completely.
pub statements_functions: Option<StatementsFunctions>,
is not needed as part of the structure at all IIUC.
you can just have the db available, and extractstatements_functions
fromstatements_functions
and strait into annotations.
Forgot it is not necessary here as it is not the debug info that is used in VersionedProgram
crates/cairo-lang-sierra-generator/src/function_generator_test_data/generics
line 14 at r9 (raw file):
Previously, orizi wrote…
revert
This was actually generated by running CAIRO_FIX_TESTS=1 cargo test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 9 of 9 files at r10, all commit messages.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @orizi)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 5 of 9 files at r10, all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @piotmag769)
crates/cairo-lang-sierra-generator/src/statements_functions.rs
line 23 at r10 (raw file):
serde_json::Value::from_iter([("statements_functions", mapping)]), )]) }
make the function add instead - in case there are other annotations.
Code quote:
impl From<StatementsFunctions> for Annotations {
fn from(value: StatementsFunctions) -> Self {
let mapping = serde_json::to_value(value.statements_to_functions_map).unwrap();
OrderedHashMap::from([(
"github.com/software-mansion/cairo-profiler".to_string(),
serde_json::Value::from_iter([("statements_functions", mapping)]),
)])
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on @orizi)
crates/cairo-lang-sierra-generator/src/statements_functions.rs
line 23 at r10 (raw file):
Previously, orizi wrote…
make the function add instead - in case there are other annotations.
The adding is done in ContractClass::new
, this one is a cast
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 3 of 11 files at r7, 1 of 6 files at r9, 1 of 9 files at r10.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @piotmag769)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @piotmag769)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 2 of 2 files at r11, all commit messages.
Reviewable status: complete! all files reviewed, all discussions resolved (waiting on @piotmag769)
Follow up to #5306
This change is