Fri, 31 Oct 2014 12:16:20 +0100
8062169: Multiple OSR compilations issued for same bci
Summary: Fixed 'SimpleThresholdPolicy::event' to always perform OSR if an OSR nmethod is available.
Reviewed-by: kvn, iveresov
duke@435 | 1 | /* |
drchase@6680 | 2 | * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #include "precompiled.hpp" |
stefank@2314 | 26 | #include "code/debugInfo.hpp" |
stefank@2314 | 27 | #include "oops/oop.inline.hpp" |
stefank@2314 | 28 | #include "runtime/frame.inline.hpp" |
stefank@2314 | 29 | #include "runtime/handles.inline.hpp" |
stefank@2314 | 30 | #include "runtime/stackValue.hpp" |
duke@435 | 31 | |
duke@435 | 32 | StackValue* StackValue::create_stack_value(const frame* fr, const RegisterMap* reg_map, ScopeValue* sv) { |
duke@435 | 33 | if (sv->is_location()) { |
duke@435 | 34 | // Stack or register value |
duke@435 | 35 | Location loc = ((LocationValue *)sv)->location(); |
duke@435 | 36 | |
duke@435 | 37 | #ifdef SPARC |
duke@435 | 38 | // %%%%% Callee-save floats will NOT be working on a Sparc until we |
duke@435 | 39 | // handle the case of a 2 floats in a single double register. |
duke@435 | 40 | assert( !(loc.is_register() && loc.type() == Location::float_in_dbl), "Sparc does not handle callee-save floats yet" ); |
duke@435 | 41 | #endif // SPARC |
duke@435 | 42 | |
duke@435 | 43 | // First find address of value |
duke@435 | 44 | |
duke@435 | 45 | address value_addr = loc.is_register() |
duke@435 | 46 | // Value was in a callee-save register |
duke@435 | 47 | ? reg_map->location(VMRegImpl::as_VMReg(loc.register_number())) |
duke@435 | 48 | // Else value was directly saved on the stack. The frame's original stack pointer, |
duke@435 | 49 | // before any extension by its callee (due to Compiler1 linkage on SPARC), must be used. |
duke@435 | 50 | : ((address)fr->unextended_sp()) + loc.stack_offset(); |
duke@435 | 51 | |
duke@435 | 52 | // Then package it right depending on type |
duke@435 | 53 | // Note: the transfer of the data is thru a union that contains |
duke@435 | 54 | // an intptr_t. This is because an interpreter stack slot is |
duke@435 | 55 | // really an intptr_t. The use of a union containing an intptr_t |
duke@435 | 56 | // ensures that on a 64 bit platform we have proper alignment |
duke@435 | 57 | // and that we store the value where the interpreter will expect |
duke@435 | 58 | // to find it (i.e. proper endian). Similarly on a 32bit platform |
duke@435 | 59 | // using the intptr_t ensures that when a value is larger than |
duke@435 | 60 | // a stack slot (jlong/jdouble) that we capture the proper part |
duke@435 | 61 | // of the value for the stack slot in question. |
duke@435 | 62 | // |
duke@435 | 63 | switch( loc.type() ) { |
duke@435 | 64 | case Location::float_in_dbl: { // Holds a float in a double register? |
duke@435 | 65 | // The callee has no clue whether the register holds a float, |
duke@435 | 66 | // double or is unused. He always saves a double. Here we know |
duke@435 | 67 | // a double was saved, but we only want a float back. Narrow the |
duke@435 | 68 | // saved double to the float that the JVM wants. |
duke@435 | 69 | assert( loc.is_register(), "floats always saved to stack in 1 word" ); |
duke@435 | 70 | union { intptr_t p; jfloat jf; } value; |
duke@435 | 71 | value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); |
duke@435 | 72 | value.jf = (jfloat) *(jdouble*) value_addr; |
duke@435 | 73 | return new StackValue(value.p); // 64-bit high half is stack junk |
duke@435 | 74 | } |
duke@435 | 75 | case Location::int_in_long: { // Holds an int in a long register? |
duke@435 | 76 | // The callee has no clue whether the register holds an int, |
duke@435 | 77 | // long or is unused. He always saves a long. Here we know |
duke@435 | 78 | // a long was saved, but we only want an int back. Narrow the |
duke@435 | 79 | // saved long to the int that the JVM wants. |
duke@435 | 80 | assert( loc.is_register(), "ints always saved to stack in 1 word" ); |
duke@435 | 81 | union { intptr_t p; jint ji;} value; |
duke@435 | 82 | value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); |
duke@435 | 83 | value.ji = (jint) *(jlong*) value_addr; |
duke@435 | 84 | return new StackValue(value.p); // 64-bit high half is stack junk |
duke@435 | 85 | } |
duke@435 | 86 | #ifdef _LP64 |
duke@435 | 87 | case Location::dbl: |
duke@435 | 88 | // Double value in an aligned adjacent pair |
duke@435 | 89 | return new StackValue(*(intptr_t*)value_addr); |
duke@435 | 90 | case Location::lng: |
duke@435 | 91 | // Long value in an aligned adjacent pair |
duke@435 | 92 | return new StackValue(*(intptr_t*)value_addr); |
kvn@766 | 93 | case Location::narrowoop: { |
kvn@766 | 94 | union { intptr_t p; narrowOop noop;} value; |
kvn@766 | 95 | value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); |
kvn@766 | 96 | if (loc.is_register()) { |
kvn@766 | 97 | // The callee has no clue whether the register holds an int, |
kvn@766 | 98 | // long or is unused. He always saves a long. Here we know |
kvn@766 | 99 | // a long was saved, but we only want an int back. Narrow the |
kvn@766 | 100 | // saved long to the int that the JVM wants. |
kvn@766 | 101 | value.noop = (narrowOop) *(julong*) value_addr; |
kvn@766 | 102 | } else { |
kvn@766 | 103 | value.noop = *(narrowOop*) value_addr; |
kvn@766 | 104 | } |
kvn@766 | 105 | // Decode narrowoop and wrap a handle around the oop |
kvn@766 | 106 | Handle h(oopDesc::decode_heap_oop(value.noop)); |
kvn@766 | 107 | return new StackValue(h); |
kvn@766 | 108 | } |
duke@435 | 109 | #endif |
duke@435 | 110 | case Location::oop: { |
kvn@1293 | 111 | oop val = *(oop *)value_addr; |
kvn@1293 | 112 | #ifdef _LP64 |
kvn@1293 | 113 | if (Universe::is_narrow_oop_base(val)) { |
kvn@1293 | 114 | // Compiled code may produce decoded oop = narrow_oop_base |
kvn@1293 | 115 | // when a narrow oop implicit null check is used. |
kvn@1293 | 116 | // The narrow_oop_base could be NULL or be the address |
kvn@1293 | 117 | // of the page below heap. Use NULL value for both cases. |
kvn@1293 | 118 | val = (oop)NULL; |
kvn@1293 | 119 | } |
kvn@1293 | 120 | #endif |
kvn@1293 | 121 | Handle h(val); // Wrap a handle around the oop |
duke@435 | 122 | return new StackValue(h); |
duke@435 | 123 | } |
duke@435 | 124 | case Location::addr: { |
duke@435 | 125 | ShouldNotReachHere(); // both C1 and C2 now inline jsrs |
duke@435 | 126 | } |
duke@435 | 127 | case Location::normal: { |
duke@435 | 128 | // Just copy all other bits straight through |
duke@435 | 129 | union { intptr_t p; jint ji;} value; |
duke@435 | 130 | value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); |
duke@435 | 131 | value.ji = *(jint*)value_addr; |
duke@435 | 132 | return new StackValue(value.p); |
duke@435 | 133 | } |
duke@435 | 134 | case Location::invalid: |
duke@435 | 135 | return new StackValue(); |
duke@435 | 136 | default: |
duke@435 | 137 | ShouldNotReachHere(); |
duke@435 | 138 | } |
duke@435 | 139 | |
duke@435 | 140 | } else if (sv->is_constant_int()) { |
duke@435 | 141 | // Constant int: treat same as register int. |
duke@435 | 142 | union { intptr_t p; jint ji;} value; |
duke@435 | 143 | value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); |
duke@435 | 144 | value.ji = (jint)((ConstantIntValue*)sv)->value(); |
duke@435 | 145 | return new StackValue(value.p); |
duke@435 | 146 | } else if (sv->is_constant_oop()) { |
duke@435 | 147 | // constant oop |
coleenp@4037 | 148 | return new StackValue(sv->as_ConstantOopReadValue()->value()); |
duke@435 | 149 | #ifdef _LP64 |
duke@435 | 150 | } else if (sv->is_constant_double()) { |
duke@435 | 151 | // Constant double in a single stack slot |
duke@435 | 152 | union { intptr_t p; double d; } value; |
duke@435 | 153 | value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); |
duke@435 | 154 | value.d = ((ConstantDoubleValue *)sv)->value(); |
duke@435 | 155 | return new StackValue(value.p); |
duke@435 | 156 | } else if (sv->is_constant_long()) { |
duke@435 | 157 | // Constant long in a single stack slot |
duke@435 | 158 | union { intptr_t p; jlong jl; } value; |
duke@435 | 159 | value.p = (intptr_t) CONST64(0xDEADDEAFDEADDEAF); |
duke@435 | 160 | value.jl = ((ConstantLongValue *)sv)->value(); |
duke@435 | 161 | return new StackValue(value.p); |
duke@435 | 162 | #endif |
kvn@1253 | 163 | } else if (sv->is_object()) { // Scalar replaced object in compiled frame |
kvn@1253 | 164 | Handle ov = ((ObjectValue *)sv)->value(); |
kvn@1253 | 165 | return new StackValue(ov, (ov.is_null()) ? 1 : 0); |
duke@435 | 166 | } |
duke@435 | 167 | |
duke@435 | 168 | // Unknown ScopeValue type |
duke@435 | 169 | ShouldNotReachHere(); |
duke@435 | 170 | return new StackValue((intptr_t) 0); // dummy |
duke@435 | 171 | } |
duke@435 | 172 | |
duke@435 | 173 | |
duke@435 | 174 | BasicLock* StackValue::resolve_monitor_lock(const frame* fr, Location location) { |
duke@435 | 175 | assert(location.is_stack(), "for now we only look at the stack"); |
duke@435 | 176 | int word_offset = location.stack_offset() / wordSize; |
duke@435 | 177 | // (stack picture) |
duke@435 | 178 | // high: [ ] word_offset + 1 |
duke@435 | 179 | // low [ ] word_offset |
duke@435 | 180 | // |
duke@435 | 181 | // sp-> [ ] 0 |
duke@435 | 182 | // the word_offset is the distance from the stack pointer to the lowest address |
duke@435 | 183 | // The frame's original stack pointer, before any extension by its callee |
duke@435 | 184 | // (due to Compiler1 linkage on SPARC), must be used. |
duke@435 | 185 | return (BasicLock*) (fr->unextended_sp() + word_offset); |
duke@435 | 186 | } |
duke@435 | 187 | |
duke@435 | 188 | |
duke@435 | 189 | #ifndef PRODUCT |
duke@435 | 190 | |
duke@435 | 191 | void StackValue::print_on(outputStream* st) const { |
duke@435 | 192 | switch(_type) { |
duke@435 | 193 | case T_INT: |
duke@435 | 194 | st->print("%d (int) %f (float) %x (hex)", *(int *)&_i, *(float *)&_i, *(int *)&_i); |
duke@435 | 195 | break; |
duke@435 | 196 | |
duke@435 | 197 | case T_OBJECT: |
duke@435 | 198 | _o()->print_value_on(st); |
drchase@6680 | 199 | st->print(" <" INTPTR_FORMAT ">", p2i((address)_o())); |
duke@435 | 200 | break; |
duke@435 | 201 | |
duke@435 | 202 | case T_CONFLICT: |
duke@435 | 203 | st->print("conflict"); |
duke@435 | 204 | break; |
duke@435 | 205 | |
duke@435 | 206 | default: |
duke@435 | 207 | ShouldNotReachHere(); |
duke@435 | 208 | } |
duke@435 | 209 | } |
duke@435 | 210 | |
duke@435 | 211 | #endif |