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 | /* |
mikael@6198 | 2 | * Copyright (c) 1999, 2013, 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_RUNTIME_ATOMIC_HPP |
stefank@2314 | 26 | #define SHARE_VM_RUNTIME_ATOMIC_HPP |
stefank@2314 | 27 | |
stefank@2314 | 28 | #include "memory/allocation.hpp" |
stefank@2314 | 29 | |
duke@435 | 30 | class Atomic : AllStatic { |
duke@435 | 31 | public: |
jwilhelm@4647 | 32 | // Atomic operations on jlong types are not available on all 32-bit |
jwilhelm@4647 | 33 | // platforms. If atomic ops on jlongs are defined here they must only |
jwilhelm@4647 | 34 | // be used from code that verifies they are available at runtime and |
jwilhelm@4647 | 35 | // can provide an alternative action if not - see supports_cx8() for |
jwilhelm@4647 | 36 | // a means to test availability. |
jwilhelm@4647 | 37 | |
duke@435 | 38 | // Atomically store to a location |
twisti@4318 | 39 | inline static void store (jbyte store_value, jbyte* dest); |
twisti@4318 | 40 | inline static void store (jshort store_value, jshort* dest); |
twisti@4318 | 41 | inline static void store (jint store_value, jint* dest); |
jwilhelm@4647 | 42 | // See comment above about using jlong atomics on 32-bit platforms |
twisti@4318 | 43 | inline static void store (jlong store_value, jlong* dest); |
twisti@4318 | 44 | inline static void store_ptr(intptr_t store_value, intptr_t* dest); |
twisti@4318 | 45 | inline static void store_ptr(void* store_value, void* dest); |
duke@435 | 46 | |
twisti@4318 | 47 | inline static void store (jbyte store_value, volatile jbyte* dest); |
twisti@4318 | 48 | inline static void store (jshort store_value, volatile jshort* dest); |
twisti@4318 | 49 | inline static void store (jint store_value, volatile jint* dest); |
jwilhelm@4647 | 50 | // See comment above about using jlong atomics on 32-bit platforms |
twisti@4318 | 51 | inline static void store (jlong store_value, volatile jlong* dest); |
twisti@4318 | 52 | inline static void store_ptr(intptr_t store_value, volatile intptr_t* dest); |
twisti@4318 | 53 | inline static void store_ptr(void* store_value, volatile void* dest); |
duke@435 | 54 | |
jwilhelm@4647 | 55 | // See comment above about using jlong atomics on 32-bit platforms |
twisti@4318 | 56 | inline static jlong load(volatile jlong* src); |
kvn@1329 | 57 | |
duke@435 | 58 | // Atomically add to a location, return updated value |
twisti@4318 | 59 | inline static jint add (jint add_value, volatile jint* dest); |
twisti@4318 | 60 | inline static intptr_t add_ptr(intptr_t add_value, volatile intptr_t* dest); |
twisti@4318 | 61 | inline static void* add_ptr(intptr_t add_value, volatile void* dest); |
jwilhelm@4647 | 62 | // See comment above about using jlong atomics on 32-bit platforms |
twisti@4318 | 63 | static jlong add (jlong add_value, volatile jlong* dest); |
minqi@2964 | 64 | |
duke@435 | 65 | // Atomically increment location |
twisti@4318 | 66 | inline static void inc (volatile jint* dest); |
iklam@5306 | 67 | static void inc (volatile jshort* dest); |
twisti@4318 | 68 | inline static void inc_ptr(volatile intptr_t* dest); |
twisti@4318 | 69 | inline static void inc_ptr(volatile void* dest); |
duke@435 | 70 | |
duke@435 | 71 | // Atomically decrement a location |
twisti@4318 | 72 | inline static void dec (volatile jint* dest); |
iklam@5306 | 73 | static void dec (volatile jshort* dest); |
twisti@4318 | 74 | inline static void dec_ptr(volatile intptr_t* dest); |
twisti@4318 | 75 | inline static void dec_ptr(volatile void* dest); |
duke@435 | 76 | |
duke@435 | 77 | // Performs atomic exchange of *dest with exchange_value. Returns old prior value of *dest. |
twisti@4318 | 78 | inline static jint xchg(jint exchange_value, volatile jint* dest); |
twisti@4318 | 79 | static unsigned int xchg(unsigned int exchange_value, volatile unsigned int* dest); |
coleenp@548 | 80 | |
twisti@4318 | 81 | inline static intptr_t xchg_ptr(intptr_t exchange_value, volatile intptr_t* dest); |
twisti@4318 | 82 | inline static void* xchg_ptr(void* exchange_value, volatile void* dest); |
duke@435 | 83 | |
duke@435 | 84 | // Performs atomic compare of *dest and compare_value, and exchanges *dest with exchange_value |
duke@435 | 85 | // if the comparison succeeded. Returns prior value of *dest. Guarantees a two-way memory |
duke@435 | 86 | // barrier across the cmpxchg. I.e., it's really a 'fence_cmpxchg_acquire'. |
twisti@4318 | 87 | static jbyte cmpxchg (jbyte exchange_value, volatile jbyte* dest, jbyte compare_value); |
twisti@4318 | 88 | inline static jint cmpxchg (jint exchange_value, volatile jint* dest, jint compare_value); |
jwilhelm@4647 | 89 | // See comment above about using jlong atomics on 32-bit platforms |
twisti@4318 | 90 | inline static jlong cmpxchg (jlong exchange_value, volatile jlong* dest, jlong compare_value); |
coleenp@548 | 91 | |
twisti@4318 | 92 | static unsigned int cmpxchg(unsigned int exchange_value, |
twisti@4318 | 93 | volatile unsigned int* dest, |
twisti@4318 | 94 | unsigned int compare_value); |
coleenp@548 | 95 | |
twisti@4318 | 96 | inline static intptr_t cmpxchg_ptr(intptr_t exchange_value, volatile intptr_t* dest, intptr_t compare_value); |
twisti@4318 | 97 | inline static void* cmpxchg_ptr(void* exchange_value, volatile void* dest, void* compare_value); |
duke@435 | 98 | }; |
stefank@2314 | 99 | |
iklam@5306 | 100 | // To use Atomic::inc(jshort* dest) and Atomic::dec(jshort* dest), the address must be specially |
iklam@5306 | 101 | // aligned, such that (*dest) occupies the upper 16 bits of an aligned 32-bit word. The best way to |
iklam@5306 | 102 | // achieve is to place your short value next to another short value, which doesn't need atomic ops. |
iklam@5306 | 103 | // |
iklam@5306 | 104 | // Example |
iklam@5306 | 105 | // ATOMIC_SHORT_PAIR( |
iklam@5306 | 106 | // volatile short _refcount, // needs atomic operation |
iklam@5306 | 107 | // unsigned short _length // number of UTF8 characters in the symbol (does not need atomic op) |
iklam@5306 | 108 | // ); |
iklam@5306 | 109 | |
iklam@5306 | 110 | #ifdef VM_LITTLE_ENDIAN |
iklam@5306 | 111 | #define ATOMIC_SHORT_PAIR(atomic_decl, non_atomic_decl) \ |
iklam@5306 | 112 | non_atomic_decl; \ |
iklam@5306 | 113 | atomic_decl |
iklam@5306 | 114 | #else |
iklam@5306 | 115 | #define ATOMIC_SHORT_PAIR(atomic_decl, non_atomic_decl) \ |
iklam@5306 | 116 | atomic_decl ; \ |
iklam@5306 | 117 | non_atomic_decl |
iklam@5306 | 118 | #endif |
iklam@5306 | 119 | |
stefank@2314 | 120 | #endif // SHARE_VM_RUNTIME_ATOMIC_HPP |