Tue, 11 Nov 2014 11:05:41 +0100
8056071: compiler/whitebox/IsMethodCompilableTest.java fails with 'method() is not compilable after 3 iterations'
Summary: Always use MDO if valid and always compile trivial methods with C1 if available.
Reviewed-by: kvn, iveresov
duke@435 | 1 | /* |
coleenp@4037 | 2 | * Copyright (c) 1998, 2012, 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 | #ifndef SHARE_VM_OOPS_COMPILEDICHOLDEROOP_HPP |
stefank@2314 | 26 | #define SHARE_VM_OOPS_COMPILEDICHOLDEROOP_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #include "oops/oop.hpp" |
stefank@2314 | 29 | |
coleenp@4037 | 30 | // A CompiledICHolder* is a helper object for the inline cache implementation. |
duke@435 | 31 | // It holds an intermediate value (method+klass pair) used when converting from |
duke@435 | 32 | // compiled to an interpreted call. |
duke@435 | 33 | // |
coleenp@4037 | 34 | // These are always allocated in the C heap and are freed during a |
coleenp@4037 | 35 | // safepoint by the ICBuffer logic. It's unsafe to free them earlier |
coleenp@4037 | 36 | // since they might be in use. |
coleenp@4037 | 37 | // |
duke@435 | 38 | |
duke@435 | 39 | |
coleenp@4037 | 40 | class CompiledICHolder : public CHeapObj<mtCompiler> { |
duke@435 | 41 | friend class VMStructs; |
duke@435 | 42 | private: |
coleenp@4037 | 43 | static volatile int _live_count; // allocated |
coleenp@4037 | 44 | static volatile int _live_not_claimed_count; // allocated but not yet in use so not |
coleenp@4037 | 45 | // reachable by iterating over nmethods |
coleenp@4037 | 46 | |
coleenp@4037 | 47 | Method* _holder_method; |
coleenp@4037 | 48 | Klass* _holder_klass; // to avoid name conflict with oopDesc::_klass |
coleenp@4037 | 49 | CompiledICHolder* _next; |
coleenp@4037 | 50 | |
duke@435 | 51 | public: |
coleenp@4037 | 52 | // Constructor |
coleenp@4037 | 53 | CompiledICHolder(Method* method, Klass* klass) |
coleenp@4037 | 54 | : _holder_method(method), _holder_klass(klass) { |
coleenp@4037 | 55 | #ifdef ASSERT |
coleenp@4037 | 56 | Atomic::inc(&_live_count); |
coleenp@4037 | 57 | Atomic::inc(&_live_not_claimed_count); |
coleenp@4037 | 58 | #endif |
coleenp@4037 | 59 | } |
coleenp@4037 | 60 | |
coleenp@4037 | 61 | ~CompiledICHolder() { |
coleenp@4037 | 62 | #ifdef ASSERT |
coleenp@4037 | 63 | assert(_live_count > 0, "underflow"); |
coleenp@4037 | 64 | Atomic::dec(&_live_count); |
coleenp@4037 | 65 | #endif |
coleenp@4037 | 66 | } |
coleenp@4037 | 67 | |
coleenp@4037 | 68 | static int live_count() { return _live_count; } |
coleenp@4037 | 69 | static int live_not_claimed_count() { return _live_not_claimed_count; } |
coleenp@4037 | 70 | |
duke@435 | 71 | // accessors |
coleenp@4037 | 72 | Method* holder_method() const { return _holder_method; } |
coleenp@4037 | 73 | Klass* holder_klass() const { return _holder_klass; } |
duke@435 | 74 | |
coleenp@4037 | 75 | void set_holder_method(Method* m) { _holder_method = m; } |
coleenp@4037 | 76 | void set_holder_klass(Klass* k) { _holder_klass = k; } |
duke@435 | 77 | |
duke@435 | 78 | // interpreter support (offsets in bytes) |
coleenp@4037 | 79 | static int holder_method_offset() { return offset_of(CompiledICHolder, _holder_method); } |
coleenp@4037 | 80 | static int holder_klass_offset() { return offset_of(CompiledICHolder, _holder_klass); } |
duke@435 | 81 | |
coleenp@4037 | 82 | CompiledICHolder* next() { return _next; } |
coleenp@4037 | 83 | void set_next(CompiledICHolder* n) { _next = n; } |
coleenp@4037 | 84 | |
coleenp@4037 | 85 | // Verify |
coleenp@4037 | 86 | void verify_on(outputStream* st); |
coleenp@4037 | 87 | |
coleenp@4037 | 88 | // Printing |
coleenp@4037 | 89 | void print_on(outputStream* st) const; |
coleenp@4037 | 90 | void print_value_on(outputStream* st) const; |
coleenp@4037 | 91 | |
coleenp@4037 | 92 | const char* internal_name() const { return "{compiledICHolder}"; } |
coleenp@4037 | 93 | |
coleenp@4037 | 94 | void claim() { |
coleenp@4037 | 95 | #ifdef ASSERT |
coleenp@4037 | 96 | Atomic::dec(&_live_not_claimed_count); |
coleenp@4037 | 97 | #endif |
coleenp@4037 | 98 | } |
duke@435 | 99 | }; |
stefank@2314 | 100 | |
stefank@2314 | 101 | #endif // SHARE_VM_OOPS_COMPILEDICHOLDEROOP_HPP |