-
Notifications
You must be signed in to change notification settings - Fork 273
Lazy loading: load static initializers for needed classes. Fixes #846 #855
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
Conversation
@smowton could you please take a look at the overly long lines reported? |
\*******************************************************************/ | ||
|
||
#include "ci_lazy_methods.h" | ||
#include <string> |
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.
Nit picking: STL headers first, blank line, local include
#include "ci_lazy_methods.h" | ||
#include <string> | ||
|
||
void ci_lazy_methodst::add_needed_method(const irep_idt &method_symbol_name) |
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.
Function comment headers missing
src/java_bytecode/ci_lazy_methods.h
Outdated
|
||
class ci_lazy_methodst | ||
{ | ||
public: |
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.
Single-character indent - no indent needed for public
/private
/protected
src/java_bytecode/ci_lazy_methods.h
Outdated
|
||
private: | ||
std::vector<irep_idt> &needed_methods; | ||
std::set<irep_idt> &needed_classes; |
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.
Why is one of those a vector while the other is a set?
94832db
to
5bbec11
Compare
Amended and added comments to address your question about vector vs. set. |
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.
See one more comment for a suggested improvement, but otherwise looks good to me.
// needed_classes on the other hand is a true set of every class | ||
// found so far, so we can use a membership test to avoid | ||
// repeatedly exploring a class hierarchy. | ||
std::set<irep_idt> &needed_classes; |
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.
Thanks a lot for the clarification; I'd suggest to use std::unordered_set<irep_idt, irep_id_hash> &needed_classes
as a minor improvement.
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.
I'd want to make change a few others too, so I'll do that in a subsequent PR
{ | ||
if(!needed_classes.insert(class_symbol_name).second) | ||
return false; | ||
const irep_idt &clinit_name=id2string(class_symbol_name)+".<clinit>:()V"; |
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.
What's the reason for taking a const ref to a temporary here vs. the following?
const irep_idt clinit_name(id2string(class_symbol_name)+".<clinit>:()V");
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.
Whoops, fixed
5bbec11
to
286fcc5
Compare
This adds a wrapper for the needed-methods and needed-classes objects used to accumulate dependencies during lazy loading, such that the first time a class is noted needed, its static initializer if any is also queued for elaboration.
The test case is borrowed from @reuk.