Question on arithmetic overflow detection support in C2

Krystal Mok rednaxelafx at
Wed Jun 20 09:45:57 PDT 2012

Thank you for all your input, John and Vladimir!
I'm close to getting some prototype that could actually run...but not there
just yet.

I've got Match.addExact(int, int) compiled down to this graph:
with the CheckedAddI node resembling the way DivModI works.

But apparently I'm not getting the Matcher part right yet. I'm getting this
error message:

#  Internal Error
pid=16856, tid=1117243712
#  assert(false) failed: bad AD file

from this stack trace:

V  []  VMError::report(outputStream*)+0xfa4
V  []  VMError::report_and_die()+0x649
V  []  report_vm_error(char const*, int, char const*,
char const*)+0x9c
V  []  Matcher::Label_Root(Node const*, State*, Node*,
Node const*)+0x48c
V  []  Matcher::match_tree(Node const*)+0x205
V  []  Matcher::xform(Node*, int)+0x16d
V  []  Matcher::match()+0xb0e
V  []  Compile::Code_Gen()+0x91
V  []  Compile::Compile(ciEnv*, C2Compiler*, ciMethod*,
int, bool, bool)+0x101e
V  []  C2Compiler::compile_method(ciEnv*, ciMethod*,
V  []
V  []  CompileBroker::compiler_thread_loop()+0x2fa
V  []  compiler_thread_entry(JavaThread*, Thread*)+0x54
V  []  JavaThread::thread_main_inner()+0x102
V  []  JavaThread::run()+0xef
V  []  java_start(Thread*)+0x16f

The current status of the patch is avaiable here:

I haven't done a full-fledged intrinsic for Math.addExact(int, int) yet;
just as a prototype, I'm faking the use of CmpAddI node right now. At the
end of Optimize(), I pattern match for the overflow checking logic, replace
it with a new fake CmpAddI node, then make the actual CheckedAddI node from
the CmpAddI, finally replace the old AddI and Bool nodes.

Most of the changes besides the new nodes are for adding the
overflow/no-overflow conditions to BoolTest and cmpOp.

If there were separate AddI and CmpAddI nodes, they would have had a (Set
dst ...) and (Set cr ...) in their match rule. But I can't see how I can
express it here.

-------------- next part --------------
An HTML attachment was scrubbed...

More information about the hotspot-compiler-dev mailing list