Skip to content

Java frontend: treat CProver stubbed methods more like normal stubs #4258

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
Copy link
Contributor

@smowton smowton commented Feb 22, 2019

We already tried to ignore org.cprover.CProver methods such as nondetInt, relying upon
the front-end to supply stub bodies if desired based on their type. However, by creating
symbols for them as for normal (non-stub) methods, but then refusing to provide a body or
advertise them as normal methods, we failed to set up their type properly (specifically
the parameter names), as they were neither set like a stub (upon symbol creation, upon
discovery by a caller) or like a normal method (during java_bytecode_convert_method). By
refusing to create the symbol at all, this treats the special CProver methods more like
normal stubs: their symbols are now created on demand.

It is also no longer necessary for java_bytecode_languaget::methods_provided to special
case them, as they are not added to method_bytecodet either, again matching "real" stub
methods more closely.

^SIGNAL=0$
--
--
This calls to CProver.startThread, which are special-cased by the Java front-end (which omits the method's body
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit-pick: s/are/is/

--
--
This calls to CProver.startThread, which are special-cased by the Java front-end (which omits the method's body
in hope of the front-end handling it like a stub), but which don't get their parameter names assigned by the usual
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/don't/doesn't/ s/their/its/

Copy link
Contributor

@thk123 thk123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean fine, but this seems like a messy approach and I don't fully understand it. Why not just not load these methods (however it is they are inviting the front ends to ignore them?)

@@ -406,8 +415,9 @@ void java_bytecode_convert_methodt::convert(
// (e.g. "my.package.ClassName.myMethodName:(II)I") and query the symbol table
// to retrieve the symbol (constructed by java_bytecode_convert_method_lazy)
// associated to the method
const irep_idt method_identifier=
id2string(class_symbol.name)+"."+id2string(m.name)+":"+m.descriptor;
const irep_idt method_identifier =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean not your code, but why do we have a local variable method_identifier that then is immediately assigned into method_id, perhaps just directly assign?

@smowton smowton force-pushed the smowton/fix/java-fake-stubs-parameter-identifiers branch from 73a2c88 to 1681dfa Compare February 22, 2019 17:45
@smowton smowton changed the title Java frontend: set parameter identifiers for forcibly-stubbed methods Java frontend: treat CProver stubbed methods more like normal stubs Feb 22, 2019
@smowton smowton requested review from thk123 and tautschnig February 22, 2019 17:46
@smowton
Copy link
Contributor Author

smowton commented Feb 22, 2019

@tautschnig @thk123 that solution didn't work for symex-driven-lazy-loading, so I completely changed my approach; see updated description.

Copy link
Contributor

@thk123 thk123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Orders of magnitude better I'd say 🎉

static irep_idt org_cprover_CProver_name = "org.cprover.CProver";
return
(class_name == org_cprover_CProver_name &&
cprover_methods_to_ignore.count(id2string(method.name))) ||
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit-pick: Visual Studio would like to have an explicit != 0 with .count(...).

@tautschnig tautschnig assigned smowton and unassigned thk123 and peterschrammel Feb 22, 2019
We already tried to ignore org.cprover.CProver methods such as nondetInt, relying upon
the front-end to supply stub bodies if desired based on their type. However, by creating
symbols for them as for normal (non-stub) methods, but then refusing to provide a body or
advertise them as normal methods, we failed to set up their type properly (specifically
the parameter names), as they were neither set like a stub (upon symbol creation, upon
discovery by a caller) or like a normal method (during java_bytecode_convert_method). By
refusing to create the symbol at all, this treats the special CProver methods more like
normal stubs: their symbols are now created on demand.

It is also no longer necessary for java_bytecode_languaget::methods_provided to special
case them, as they are not added to method_bytecodet either, again matching "real" stub
methods more closely.
@smowton smowton force-pushed the smowton/fix/java-fake-stubs-parameter-identifiers branch from 1681dfa to 4c724de Compare February 22, 2019 18:00
@smowton smowton merged commit 272ba02 into diffblue:develop Feb 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants