-
Notifications
You must be signed in to change notification settings - Fork 273
sort bytecode_info table by bytecode #4670
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
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.
✔️
Passed Diffblue compatibility checks (cbmc commit: 5d8125e).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/112355616
04c83d3
to
ccab473
Compare
i_it->statement!="jsr" && | ||
i_it->statement!="jsr_w" && | ||
i_it->statement!="ret") | ||
const std::string statement = bytecode_info[i_it->bytecode].mnemonic; |
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.
Const ref?
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.
No, this is turning a const char *
into a string, for comparison.
Won't fix now, since this will be replaced by bytecode comparisons.
const std::string statement = bytecode_info[i_it->bytecode].mnemonic; | ||
|
||
if( | ||
statement != "goto" && statement != "return" && |
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.
Suggested followup -- create symbolic constants for these JAVA_BYTECODE_NOP
and so on, and compare those instead of the mnemonics
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.
Yes, that's the plan.
instruction.statement == "ldc2" || | ||
instruction.statement == "ldc_w" || | ||
instruction.statement == "ldc2_w") | ||
const std::string statement = |
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.
const ref?
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.
same here.
@@ -311,8 +311,9 @@ static void infer_opaque_type_fields( | |||
for(const java_bytecode_parse_treet::instructiont &instruction : | |||
method.instructions) | |||
{ | |||
if(instruction.statement == "getfield" || | |||
instruction.statement == "putfield") | |||
const std::string statement = |
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.
const ref?
@@ -584,8 +586,9 @@ static void create_stub_global_symbols( | |||
for(const java_bytecode_parse_treet::instructiont &instruction : | |||
method.instructions) | |||
{ | |||
if(instruction.statement == "getstatic" || | |||
instruction.statement == "putstatic") | |||
const std::string statement = |
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.
const ref?
@@ -15,86 +15,139 @@ Author: Daniel Kroening, [email protected] | |||
// clang-format off | |||
struct bytecode_infot const bytecode_info[]= | |||
{ | |||
{ "aaload", 0x32, ' ', 2, 1, ' ' }, // arrayref, index → value; load onto the stack a reference from an array NOLINT(*) | |||
{ "aastore", 0x53, ' ', 3, 0, ' ' }, // arrayref, index, value →; store into a reference in an array NOLINT(*) | |||
{ "nop", 0x00, ' ', 0, 0, ' ' }, // [No change]; perform no operation NOLINT(*) |
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.
Given anyone using this table already has a bytecode, the second field is useless now
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.
Keeping for audit!
{ "impdep1", 0xfe, ' ', 0, 0, ' ' }, // ; reserved for implementation-dependent operations within debuggers; should not appear in any class file NOLINT(*) | ||
{ "impdep2", 0xff, ' ', 0, 0, ' ' }, // ; reserved for implementation-dependent operations within debuggers; should not appear in any class file NOLINT(*) | ||
{ "wide", 0xc4, ' ', 0, 0, ' ' }, // modifier for others NOLINT(*) | ||
{ nullptr, 0x00, '\0',0, 0, '\0'}, // zero-initialized NOLINT (*) |
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.
This looks like a magic terminator, but nothing about it is unique (0x00
is also nop
, and a nullptr
mnemonic is shared by the missing entries)-- suggest removing it
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.
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.
This PR failed Diffblue compatibility checks (cbmc commit: ccab473).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/112420225
Status will be re-evaluated on next push.
Common spurious failures include: the cbmc commit has disappeared in the mean time (e.g. in a force-push); the author is not in the list of contributors (e.g. first-time contributors); compatibility was already broken by an earlier merge.
ccab473
to
3b70661
Compare
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.
This PR failed Diffblue compatibility checks (cbmc commit: 3b70661).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/112439621
Status will be re-evaluated on next push.
Common spurious failures include: the cbmc commit has disappeared in the mean time (e.g. in a force-push); the author is not in the list of contributors (e.g. first-time contributors); compatibility was already broken by an earlier merge.
3b70661
to
46daf81
Compare
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.
This PR failed Diffblue compatibility checks (cbmc commit: 46daf81).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/112482347
Status will be re-evaluated on next push.
Common spurious failures include: the cbmc commit has disappeared in the mean time (e.g. in a force-push); the author is not in the list of contributors (e.g. first-time contributors); compatibility was already broken by an earlier merge.
46daf81
to
c60a918
Compare
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.
✔️
Passed Diffblue compatibility checks (cbmc commit: c60a918).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/113236477
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.
Formatting grumbles only, otherwise lgtm
i_it->statement=="invokeinterface" || | ||
(threading_support && (i_it->statement=="monitorenter" || | ||
i_it->statement=="monitorexit"))) | ||
if( |
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.
Suggest killing clang-format here to keep the nicer one-cndition-per-line format
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.
done
i_it->statement=="ifnull" || | ||
i_it->statement=="jsr" || | ||
i_it->statement=="jsr_w") | ||
if( |
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.
Same here
const std::string statement = | ||
bytecode_info[instruction.bytecode].mnemonic; | ||
if( | ||
statement == "ldc" || statement == "ldc2" || statement == "ldc_w" || |
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.
Same here
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.
🚫 This will need a manual bump - I'll take care of this but please wait before merging
💡 I would add a unit test that verifies the table has the correct structure (e.g. that the position matches the bytecode, that there are no gaps etc)
I will do the bump once rebased - please let me know when |
c60a918
to
7822fac
Compare
@thk123 done! |
Sorry could I have one more rebase as I think #4705 is required for TG compatibility and this is just before it. |
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.
✔️
Passed Diffblue compatibility checks (cbmc commit: 7822fac).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/113427828
@kroening sorry didn't tag you - can I have one more rebase as #4705 has been merged into TG submodule |
5023dd0
to
7cca038
Compare
The bytecode_info table is now sorted by bytecode, instead of alphabetically. This is enables direct lookup of bytecodes, and can replace the table that is currently built at runtime. We do not have any use for the alphabetic ordering. Obtained from previous file with sort -t, -k2 bytecode_info.cpp -b
The run-time generated bytecode table is replaced by bytecode_info. The linear search for the mnemonic is replaced by an array access.
7cca038
to
b149012
Compare
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.
✔️
Passed Diffblue compatibility checks (cbmc commit: b149012).
Build URL: https://travis-ci.com/diffblue/test-gen/builds/113731628
The bytecode_info table is now sorted by bytecode, instead of
alphabetically. This is enables direct lookup of bytecodes, and can replace
the table that is currently built at runtime. We do not have any use for
the alphabetic ordering.
Obtained from previous file with
sort -t, -k2 bytecode_info.cpp -b