2273N/A * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1472N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A//---------------------------------array_load---------------------------------- 0N/A//--------------------------------array_store---------------------------------- 0N/A//------------------------------array_addressing------------------------------- 0N/A// Pull array and index from the stack. Compute pointer-to-element. 0N/A // Null check the array base, with correct stack contents 0N/A // Compile-time detect of null-exception? 0N/A // If we load from "AbstractClass[]" we must see "ConcreteSubClass". 0N/A // Check for big class initializers with all constant offsets 0N/A // feeding into a known-size array. 0N/A // See if the highest idx value is less than the lowest array bound, 0N/A // and if the idx value cannot be negative: 0N/A // Only fails for some -Xcomp runs 0N/A // The class is unloaded. We have to run this bytecode in the interpreter. 0N/A // Do the range check 366N/A // The greatest array bound is negative, so we can conclude that we're 129N/A // compiling unreachable code, but the unsigned compare trick used below 129N/A // only works with non-negative lengths. Instead, hack "tst" to be zero so 129N/A // the uncommon_trap path will always be taken. 366N/A // Range is constant in array-oop, so we can use the original state of mem 129N/A // Test length vs index (standard trick using unsigned compare) 0N/A // Branch to failure if out of bounds 0N/A // Do not use builtin_throw, since range checks are sometimes 0N/A // made more stringent by an optimistic transformation. 0N/A // This creates "tentative" range checks at this point, 0N/A // which are not guaranteed to throw exceptions. 0N/A // See IfNode::Ideal, is_range_check, adjust_check. 0N/A // If we have already recompiled with the range-check-widening 0N/A // heroic optimization turned off, then we must really be throwing 0N/A // range check exceptions. 0N/A // Check for always knowing you are throwing a range-check exception 0N/A// return Region node 0N/A//------------------------------helper for tableswitch------------------------- 0N/A // True branch, use existing map info 0N/A // True branch, use existing map info 0N/A // False branch, use existing map and control() 0N/A return a > b ?
1 : a < b ? -
1 : 0;
0N/A// Default value for methodData switch indexing. Must be a negative value to avoid 0N/A// conflict with any legal switch index. 0N/A // a range of integers coupled with a bci destination 0N/A//-------------------------------do_tableswitch-------------------------------- 0N/A // Get information about tableswitch 0N/A // If this is a backward branch, add safepoint 0N/A // generate decision tree, using trichotomy when possible 0N/A for (
int j = 0; j <
len; j++) {
0N/A // Safepoint in case if backward branch observed 0N/A//------------------------------do_lookupswitch-------------------------------- 0N/A // Get information about lookupswitch 0N/A if (
len <
1) {
// If this is a backward branch, add safepoint 0N/A // generate decision tree, using trichotomy when possible 0N/A for(
int j = 0; j <
len; j++ ) {
0N/A for(
int j = 0; j <
len; j++ ) {
0N/A // Safepoint in case backward branch observed 0N/A//----------------------------create_jump_tables------------------------------- 0N/A // Are jumptables enabled 0N/A // Are jumptables supported 0N/A // Don't make jump table if profiling 0N/A // Decide if a guard is needed to lop off big ranges at either (or 0N/A // both) end(s) of the input set. We'll call this the default target 0N/A // even though we can't be sure that it is the true "default". 0N/A // If a guard test will eliminate very sparse end ranges, then 0N/A // it is worth the cost of an extra jump. 0N/A // Find the total number of cases and ranges 0N/A // Don't create table if: too large, too small, or too sparse. 0N/A // Normalize table lookups to zero 0N/A // Generate a guard to protect against input keyvals that aren't 0N/A // in the switch domain. 0N/A // Create an ideal node JumpTable that has projections 0N/A // of all possible ranges for a switch statement 0N/A // The key_val input must be converted to a pointer offset and scaled. 0N/A // Compare Parse::array_addressing above. 0N/A // Clean the 32-bit int into a real 64-bit offset. 0N/A // Otherwise, the jint value 0 might turn into an offset of 0x0800000000. 0N/A // Shift the value by wordsize so we have an index into the table, rather 0N/A // than a switch value 0N/A // Create the JumpNode 0N/A // These are the switch destinations hanging off the jumpnode 0N/A for (
int j = r->
lo(); j <= r->
hi(); j++, i++) {
0N/A//----------------------------jump_switch_ranges------------------------------- 0N/A // Do special processing for the top-level call. 0N/A // Decrement pred-numbers for the unique set of nodes. 0N/A // Ensure that the block's successors are a (duplicate-free) set. 0N/A // Check that the set of successors is the same in both places. 0N/A // Maybe prune the inputs, based on the type of key_val. 0N/A // if there is an easy choice, pivot at a singleton: 0N/A // Special Case: If there are exactly three ranges, and the high 0N/A // and low range each go to the same place, omit the "gt" test, 0N/A // since it will not discriminate anything. 0N/A // if there is a higher range, test for it and process it: 0N/A // two comparisons of same values--should enable 1 test for 2 branches 0N/A // Use BoolTest::le instead of BoolTest::gt 0N/A // mid is a range, not a singleton, so treat mid..hi as a unit 0N/A // if there is a higher range, test for it and process it: 0N/A // in any case, process the lower range 0N/A // Decrease pred_count for each successor after all is done. 0N/A // Throw away the pre-allocated path for each unique successor. 0N/A tty->
print_cr(
" %d ranges (%d singletons), max_depth=%d, est_depth=%d",
0N/A // Must keep both values on the expression-stack during null-check 0N/A // Compile-time detect of null-exception? 0N/A // check for positive power of 2 0N/A // Sigh, must handle negative dividends 0N/A // Fast positive case 0N/A// Handle jsr and jsr_w bytecode 0N/A // Store information about current state, tagged with new _jsr_bci 0N/A // Update method data 0N/A // The way we do things now, there is only one successor block 0N/A // for the jsr, because the target code is cloned by ciTypeFlow. 0N/A // Effect on jsr on stack 0N/A// Handle ret bytecode 0N/A // Find to whom we return. 0N/A//--------------------------dynamic_branch_prediction-------------------------- 0N/A// Try to gather dynamic branch prediction behavior. Return a probability 0N/A// of the branch being taken and set the "cnt" field. Returns a -1.0 0N/A// if we need to use static prediction for some reason. 0N/A // Use MethodData information if it is available 0N/A // FIXME: free the ProfileData structure 0N/A // get taken and not taken values 0N/A // scale the counts to be commensurate with invocation counts: 2328N/A // Give up if too few (or too many, in which case the sum will overflow) counts to be meaningful. 2328N/A // We also check that individual counters are positive first, overwise the sum can become positive. 0N/A // Compute frequency that we arrive here 0N/A // Adjust, if this block is a cloned private block but the 0N/A // Jump counts are shared. Taken the private counts for 0N/A // just this path instead of the shared counts. 0N/A // Pin probability to sane limits 0N/A else {
// Compute probability of true path 0N/A "Bad frequency assignment in if");
0N/A C->
log()->
elem(
"branch target_bci='%d' taken='%d' not_taken='%d' cnt='%g' prob='%s'",
0N/A//-----------------------------branch_prediction------------------------------- 0N/A // If prob is unknown, switch to static prediction 0N/A // If this is a conditional test guarding a backwards branch, 0N/A // assume its a loop-back edge. Make it a likely taken branch. 0N/A // Since it's an OSR, we probably have profile data, but since 0N/A // branch_prediction returned PROB_UNKNOWN, the counts are too small. 0N/A // Let's make a special check here for completely zero counts. 0N/A // Only stop for truly zero counts, which mean an unknown part 0N/A // of the OSR-ed method, and we want to deopt to gather more stats. 0N/A // If you have ANY counts, then this loop is simply 'cold' relative 0N/A // This is the only way to return PROB_UNKNOWN: 0N/A// The magic constants are chosen so as to match the output of 0N/A// branch_prediction() when the profile reports a zero taken count. 0N/A// It is important to distinguish zero counts unambiguously, because 0N/A// some branches (e.g., _213_javac.Assembler.eliminate) validly produce 0N/A// very small but nonzero probabilities, which if confused with zero 0N/A// counts would keep the program recompiling indefinitely. 1666N/A// True if the comparison seems to be the kind that will not change its 1666N/A// statistics from true to false. See comments in adjust_map_after_if. 1666N/A// This question is only asked along paths which are already 1666N/A// classifed as untaken (by seems_never_taken), so really, 1666N/A// if a path is never taken, its controlling comparison is 1666N/A// already acting in a stable fashion. If the comparison 1666N/A// seems stable, we will put an expensive uncommon trap 1666N/A// on the untaken path. To be conservative, and to allow 1666N/A// partially executed counted loops to be compiled fully, 1666N/A// we will plant uncommon traps only after pointer comparisons. 1666N/A // The following switch can find CmpP here over half the time for 1666N/A // dynamic language code rich with type tests. 1666N/A // Code using counted loops or array manipulations (typical 1666N/A // of benchmarks) will have many (>80%) CmpI instructions. 1666N/A // These certainly should be closed off as uncommon traps. 1666N/A // Let's put traps on those, too, so that we don't have to compile 1666N/A // unused paths with indeterminate dynamic type information. 1666N/A // A small minority (< 10%) of CmpP are masked as CmpI, 1666N/A // as if by boolean conversion ((p == q? 1: 0) != 0). 1666N/A // Detect that here, even if it hasn't optimized away yet. 1666N/A // Specifically, this covers the 'instanceof' operator. 1666N/A // phi->region->if_proj->ifnode->bool->cmp 246N/A//-------------------------------repush_if_args-------------------------------- 246N/A// Push arguments of an "if" bytecode back onto the stack by adjusting _sp. 0N/A tty->
print(
"defending against excessive implicit null exceptions on %s @%d in ",
0N/A//----------------------------------do_ifnull---------------------------------- 0N/A // (An earlier version of do_ifnull omitted this trap for OSR methods.) 0N/A // We need to mark this branch as taken so that if we recompile we will 0N/A // see that it is possible. In the tiered system the interpreter doesn't 0N/A // do profiling and by the time we get to the lower tier from the interpreter 0N/A // the path may be cold again. Make sure it doesn't look untaken 17N/A // Mark the successor blocks as parsed 0N/A // Generate real control flow 0N/A // Sanity check the probability value 0N/A // Need xform to put node in hash table 17N/A // Mark the successor block as parsed 0N/A }
else {
// Path is live. 0N/A // Update method data 17N/A // Mark the successor block as parsed 0N/A }
else {
// Path is live. 0N/A // Update method data 0N/A//------------------------------------do_if------------------------------------ 0N/A // We need to mark this branch as taken so that if we recompile we will 0N/A // see that it is possible. In the tiered system the interpreter doesn't 0N/A // do profiling and by the time we get to the lower tier from the interpreter 0N/A // the path may be cold again. Make sure it doesn't look untaken 17N/A // Mark the successor blocks as parsed 0N/A // Sanity check the probability value 0N/A // Convert BoolTest to canonical form: 0N/A // prob is NOT updated here; it remains the probability of the taken 0N/A // path (as opposed to the prob of the path guarded by an 'IfTrueNode'). 37N/A // Refresh c from the transformed bool node, since it may be 37N/A // simpler than the original c. Also re-canonicalize btest. 37N/A // This wins when (Bool ne (Conv2B p) 0) => (Bool ne (CmpP p NULL)). 37N/A // That can arise from statements like: if (x instanceof C) ... 37N/A // Canonicalize one more time since transform can change it. 37N/A // Reverse edges one more time... 0N/A // Generate real control flow 17N/A // Mark the successor block as parsed 0N/A // Update method data 0N/A // Branch not taken. 17N/A // Mark the successor block as parsed 0N/A // Update method data 0N/A//----------------------------adjust_map_after_if------------------------------ 0N/A// Adjust the JVM state to reflect the result of taking this path. 0N/A// Basically, it means inspecting the CmpNode controlling this 0N/A// branch, seeing how it constrains a tested value, and then 0N/A// deciding if it's worth our while to encode this constraint 0N/A// as graph nodes in the current abstract interpretation map. 0N/A return;
// nothing to do 0N/A // If this might possibly turn into an implicit null check, 0N/A // and the null has never yet been seen, we need to generate 0N/A // an uncommon trap, so as to recompile instead of suffering 0N/A // with very slow branches. (We'll get the slow branches if 0N/A // the program ever changes phase and starts seeing nulls here.) 1666N/A // We do not inspect for a null constant, since a node may 0N/A // optimize to 'null' later on. 1666N/A // Null checks, and other tests which expect inequality, 1666N/A // show btest == BoolTest::eq along the non-taken branch. 1666N/A // On the other hand, type tests, must-be-null tests, 1666N/A // and other tests which expect pointer equality, 1666N/A // show btest == BoolTest::ne along the non-taken branch. 1666N/A // We prune both types of branches if they look unused. 0N/A // We need to mark this branch as taken so that if we recompile we will 0N/A // see that it is possible. In the tiered system the interpreter doesn't 0N/A // do profiling and by the time we get to the lower tier from the interpreter 0N/A // the path may be cold again. Make sure it doesn't look untaken 0N/A // Swap, so constant is in con. 0N/A // Do we have two constants? Then leave well enough alone. 3798N/A // Look for opportunities to sharpen the type of a node 3798N/A // whose klass is compared with a constant klass. 3798N/A // Bool(CmpP(LoadKlass(obj._klass), ConP(Foo.klass)), [eq]) 3798N/A // or the narrowOop equivalent. 3798N/A // obj has to be of the exact type Foo if the CmpP succeeds. 3798N/A // Delay transform() call to allow recovery of pre-cast value 0N/A return;
// again, it would be useless 0N/A // Check for a comparison to a constant, and "know" that the compared 0N/A // value is constrained on this path. 0N/A // Cast to null, but keep the pointer identity temporarily live. 0N/A // either +0 or -0. Just because you are equal to +0 0N/A // doesn't mean you ARE +0! 3798N/A // Note, following code also replaces Long and Oop values. 0N/A // (At this point we could record int range types with CastII.) 0N/A // Delay transform() call to allow recovery of pre-cast value 0N/A // at the control merge. 0N/A//------------------------------do_one_bytecode-------------------------------- 0N/A// Parse this bytecode, and alter the Parsers JVM->Node mapping 0N/A Node *a, *b, *c, *d;
// Handy temps 0N/A "out of nodes parsing method")) {
0N/A // for setting breakpoints 0N/A // If the constant is unresolved, run this BC once in the interpreter. 1522N/A "must be java_mirror of klass");
0N/A // before: .. c, b, a 0N/A // after: .. b, a, c, b, a 0N/A // before: .. d, c, b, a 0N/A // after: .. b, a, d, c, b, a 0N/A // Must do null-check with value on expression stack 0N/A // Compile-time detect of null-exception? 0N/A b =
pop();
// index (already used) 0N/A a =
pop();
// the array itself 0N/A // Must keep both values on the expression-stack during null-check 0N/A // Compile-time detect of null-exception? 0N/A // Generate a ModF node. 0N/A // Same as fcmpl but need to flip the unordered case. Swap the inputs, 0N/A // which negates the result sign except for unordered. Flip the unordered 0N/A // as well by using CmpF3 which implements unordered-lesser instead of 0N/A // unordered-greater semantics. Finally, commute the result bits. Result 0N/A // is same as using a CmpF3Greater except we did it with CmpF3 alone. 0N/A // This breaks _227_mtrt (speed & correctness) and _222_mpegaudio (speed) 4022N/A //b = _gvn.transform(new (C) RoundFloatNode(0, b) ); 0N/A // For i486.ad, FILD doesn't restrict precision to 24 or 53 bits. 0N/A // Rather than storing the result into an FP register then pushing 0N/A // out to memory to round, the machine instruction that implements 0N/A // ConvL2D is responsible for rounding. 0N/A // c = precision_rounding(b); 0N/A // For i486.ad, rounding is always necessary (see _l2f above). 0N/A // c = dprecision_rounding(b); 0N/A // Generate a ModD node. 0N/A // Same as dcmpl but need to flip the unordered case. 0N/A // Commute the inputs, which negates the result sign except for unordered. 0N/A // Flip the unordered as well by using CmpD3 which implements 0N/A // unordered-lesser instead of unordered-greater semantics. 0N/A // Finally, negate the result bits. Result is same as using a 0N/A // CmpD3Greater except we did it with CmpD3 alone. 0N/A // Note for longs -> lo word is on TOS, hi word is on TOS - 1 0N/A // Must keep both values on the expression-stack during null-check 0N/A // Compile-time detect of null-exception? 0N/A // Must keep both values on the expression-stack during null-check 0N/A // Compile-time detect of null-exception? 0N/A // Safepoints are now inserted _before_ branches. The long-compare 0N/A // bytecode painfully produces a 3-way value (-1,0,+1) which requires a 0N/A // slew of control flow. These are usually followed by a CmpI vs zero and 0N/A // a branch; this pattern then optimizes to the obvious long-compare and 0N/A // branch. However, if the branch is backwards there's a Safepoint 0N/A // inserted. The inserted Safepoint captures the JVM state at the 0N/A // pre-branch point, i.e. it captures the 3-way value. Thus if a 0N/A // long-compare is used to control a loop the debug info will force 0N/A // computation of the 3-way value, even though the generated code uses a 0N/A // long-compare and branch. We try to rectify the situation by inserting 0N/A // a SafePoint here and have it dominate and kill the safepoint added at a 0N/A // following backwards branch. At this point the JVM state merely holds 2 0N/A // longs but not the 3-way value. 0N/A // If this is a backwards branch in the bytecodes, add Safepoint 0N/A // Exit points of synchronized methods must have an unlock node 0N/A // null exception oop throws NULL pointer exception 0N/A // Hook the thrown exception directly to subsequent handlers. 0N/A // Keep method interpreted from now on. 1213N/A // check if we must post exception events, take uncommon trap if so (with must_throw = false) 1213N/A // Here if either can_post_on_exceptions or should_post_on_exceptions is false 0N/A // If this is a backwards branch in the bytecodes, add Safepoint 0N/A // Update method data 0N/A // Merge the current control into the target basic block 0N/A // See if we can get some profile data and hand it off to the next block 254N/A // If this is a backwards branch in the bytecodes, add Safepoint 254N/A // If this is a backwards branch in the bytecodes, add Safepoint 254N/A // If this is a backwards branch in the bytecodes, add Safepoint 254N/A // If this is a backwards branch in the bytecodes, add Safepoint 0N/A // Breakpoint set concurrently to compile 0N/A // %%% use an uncommon trap?