src/share/vm/opto/library_call.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Cdiff src/share/vm/opto/library_call.cpp

src/share/vm/opto/library_call.cpp

Print this page
rev 7652 : 8063137: Never-taken branches should be pruned when GWT LambdaForms are shared
Reviewed-by: ?
rev 7653 : [mq]: branch.freq.1

*** 39,48 **** --- 39,49 ---- #include "opto/idealKit.hpp" #include "opto/mathexactnode.hpp" #include "opto/movenode.hpp" #include "opto/mulnode.hpp" #include "opto/narrowptrnode.hpp" + #include "opto/opaquenode.hpp" #include "opto/parse.hpp" #include "opto/runtime.hpp" #include "opto/subnode.hpp" #include "prims/nativeLookup.hpp" #include "runtime/sharedRuntime.hpp"
*** 285,294 **** --- 286,297 ---- bool inline_encodeISOArray(); bool inline_updateCRC32(); bool inline_updateBytesCRC32(); bool inline_updateByteBufferCRC32(); bool inline_multiplyToLen(); + + bool inline_profileBranch(); }; //---------------------------make_vm_intrinsic---------------------------- CallGenerator* Compile::make_vm_intrinsic(ciMethod* m, bool is_virtual) {
*** 898,907 **** --- 901,913 ---- case vmIntrinsics::_updateBytesCRC32: return inline_updateBytesCRC32(); case vmIntrinsics::_updateByteBufferCRC32: return inline_updateByteBufferCRC32(); + case vmIntrinsics::_profileBranch: + return inline_profileBranch(); + default: // If you get here, it may be that someone has added a new intrinsic // to the list in vmSymbols.hpp without implementing it here. #ifndef PRODUCT if ((PrintMiscellaneous && (Verbose || WizardMode)) || PrintOpto) {
*** 5871,5875 **** --- 5877,5922 ---- Node* bool_instof = _gvn.transform(new BoolNode(cmp_instof, BoolTest::ne)); Node* instof_false = generate_guard(bool_instof, NULL, PROB_MIN); return instof_false; // even if it is NULL } + + bool LibraryCallKit::inline_profileBranch() { + Node* counts = argument(1); + const TypeAryPtr* ary = NULL; + ciArray* aobj = NULL; + if (counts->is_Con() + && (ary = counts->bottom_type()->isa_aryptr()) != NULL + && (aobj = ary->const_oop()->as_array()) != NULL + && (aobj->length() == 2)) { + jint taken = aobj->element_value(1).as_int(); + jint not_taken = aobj->element_value(0).as_int(); + + if (C->log() != NULL) { + C->log()->elem("observe source='profileBranch' taken='%d' not_taken='%d'", + taken, not_taken); + } + + if (taken + not_taken == 0) { + // According to profile, never executed. + uncommon_trap_exact(Deoptimization::Reason_intrinsic, + Deoptimization::Action_reinterpret); + return true; + } + // Stop profiling. + // MethodHandleImpl::profileBranch() has profiling logic in it's bytecode. + // By replacing method's body with profile data (represented as ProfileBranchNode + // on IR level) we effectively disable profiling. + // It enables full speed execution once optimized code is generated. + Node* profile = _gvn.transform(new ProfileBranchNode(argument(0), taken, not_taken)); + C->record_for_igvn(profile); + set_result(profile); + return true; + } else { + // Continue profiling. + // Profile data isn't available at the moment. So, execute method's bytecode version. + // Usually, when GWT LambdaForms are profiled it means that a stand-alone nmethod + // is compiled and counters aren't available since corresponding MethodHandle + // isn't a compile-time constant. + return false; + } + }
src/share/vm/opto/library_call.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File