--- old/src/share/vm/opto/compile.cpp 2014-05-21 16:16:15.749859766 +0200 +++ new/src/share/vm/opto/compile.cpp 2014-05-21 16:16:15.546383388 +0200 @@ -672,6 +672,7 @@ _print_inlining_list(NULL), _print_inlining_stream(NULL), _print_inlining_idx(0), + _print_inlining_output(NULL), _preserve_jvm_state(0), _interpreter_frame_size(0) { C = this; @@ -978,6 +979,7 @@ _print_inlining_list(NULL), _print_inlining_stream(NULL), _print_inlining_idx(0), + _print_inlining_output(NULL), _preserve_jvm_state(0), _allowed_reasons(0), _interpreter_frame_size(0) { @@ -2207,7 +2209,7 @@ } // (End scope of igvn; run destructor if necessary for asserts.) - dump_inlining(); + process_print_inlining(); // A method with only infinite loops has no edges entering loops from root { NOT_PRODUCT( TracePhase t2("graphReshape", &_t_graphReshaping, TimeCompiler); ) @@ -3868,7 +3870,7 @@ assert(!_print_inlining || _print_inlining_stream->size() == 0, "loosing data"); } -void Compile::dump_inlining() { +void Compile::process_print_inlining() { bool do_print_inlining = print_inlining() || print_intrinsics(); if (do_print_inlining || log() != NULL) { // Print inlining message for candidates that we couldn't inline @@ -3885,9 +3887,21 @@ } } if (do_print_inlining) { + ResourceMark rm; + stringStream ss; for (int i = 0; i < _print_inlining_list->length(); i++) { - tty->print("%s", _print_inlining_list->adr_at(i)->ss()->as_string()); + ss.print("%s", _print_inlining_list->adr_at(i)->ss()->as_string()); } + size_t end = ss.size(); + _print_inlining_output = NEW_ARENA_ARRAY(comp_arena(), char, end+1); + strncpy(_print_inlining_output, ss.base(), end+1); + _print_inlining_output[end] = 0; + } +} + +void Compile::dump_print_inlining() { + if (_print_inlining_output != NULL) { + tty->print_raw(_print_inlining_output); } } --- old/src/share/vm/opto/c2compiler.cpp 2014-05-21 16:16:15.801728438 +0200 +++ new/src/share/vm/opto/c2compiler.cpp 2014-05-21 16:16:15.592587964 +0200 @@ -154,6 +154,9 @@ continue; // retry } } + + // print inlining for last compilation only + C.dump_print_inlining(); // No retry; just break the loop. break; --- old/src/share/vm/opto/compile.hpp 2014-05-21 16:16:15.802755655 +0200 +++ new/src/share/vm/opto/compile.hpp 2014-05-21 16:16:15.564774851 +0200 @@ -420,6 +420,7 @@ stringStream* _print_inlining_stream; GrowableArray* _print_inlining_list; int _print_inlining_idx; + char* _print_inlining_output; // Only keep nodes in the expensive node list that need to be optimized void cleanup_expensive_nodes(PhaseIterGVN &igvn); @@ -917,7 +918,8 @@ void remove_useless_late_inlines(GrowableArray* inlines, Unique_Node_List &useful); - void dump_inlining(); + void process_print_inlining(); + void dump_print_inlining(); bool over_inlining_cutoff() const { if (!inlining_incrementally()) { --- old/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Compilation.java 2014-05-21 16:16:15.880805043 +0200 +++ new/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/Compilation.java 2014-05-21 16:16:15.682987730 +0200 @@ -49,6 +49,12 @@ this.id = id; } + void reset() { + call = new CallSite(); + lateInlineCall = new CallSite(); + phases = new ArrayList(4); + } + Phase getPhase(String s) { for (Phase p : getPhases()) { if (p.getName().equals(s)) { @@ -212,10 +218,6 @@ return phases; } - public void setPhases(ArrayList phases) { - this.setPhases(phases); - } - public String getFailureReason() { return failureReason; } @@ -240,10 +242,6 @@ return call; } - public void setCall(CallSite call) { - this.call = call; - } - public CallSite getLateInlineCall() { return lateInlineCall; } --- old/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/CallSite.java 2014-05-21 16:16:15.928717849 +0200 +++ new/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/CallSite.java 2014-05-21 16:16:15.706378567 +0200 @@ -231,6 +231,9 @@ // identical call sites with the same method name/bci are // possible so we have to try them all until we find the late // inline call site that has a matching inline id. + if (calls == null) { + return null; + } CallSite site = sites.pop(); for (CallSite c : calls) { if (c.matches(site)) { @@ -250,6 +253,27 @@ return null; } + public ArrayDeque findCallSite2(CallSite site) { + if (calls == null) { + return null; + } + + for (CallSite c : calls) { + if (c.matches(site)) { + ArrayDeque stack = new ArrayDeque(); + stack.push(c); + return stack; + } else { + ArrayDeque stack = c.findCallSite2(site); + if (stack != null) { + stack.push(c); + return stack; + } + } + } + return null; + } + public long getInlineId() { return inlineId; } --- old/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogParser.java 2014-05-21 16:16:15.947238245 +0200 +++ new/src/share/tools/LogCompilation/src/com/sun/hotspot/tools/compiler/LogParser.java 2014-05-21 16:16:15.744499772 +0200 @@ -395,6 +395,7 @@ compile.setEnd(Double.parseDouble(search(atts, "stamp"))); if (Integer.parseInt(search(atts, "success")) == 0) { compile.setFailureReason(failureReason); + failureReason = null; } } else if (qname.equals("make_not_entrant")) { String id = makeId(atts); @@ -451,6 +452,12 @@ nmethods.put(id, nm); events.add(nm); } else if (qname.equals("parse")) { + if (failureReason != null && scopes.size() == 0 && !lateInlining) { + failureReason = null; + compile.reset(); + site = compile.getCall(); + } + if (methodHandleSite != null) { throw new InternalError("method handle site should have been replaced"); } @@ -529,6 +536,18 @@ site = compile.getCall().findCallSite(thisCallScopes); if (site == null) { + System.out.println("call scopes:"); + for (CallSite c : thisCallScopes) { + System.out.println(c.getMethod() + " " + c.getBci() + " " + c.getInlineId()); + } + CallSite c = thisCallScopes.getLast(); + if (c.getInlineId() != 0) { + System.out.println("Looking for call site in entire tree:"); + ArrayDeque stack = compile.getCall().findCallSite2(c); + for (CallSite c2 : stack) { + System.out.println(c2.getMethod() + " " + c2.getBci() + " " + c2.getInlineId()); + } + } System.out.println(caller.getMethod() + " bci: " + bci); throw new InternalError("couldn't find call site"); }