annotate hotspot/src/share/vm/c1/c1_Compiler.cpp @ 45055:1c7bbc426b1e

8159995: Rename internal Unsafe.compare methods Reviewed-by: psandoz, dholmes Contributed-by: ron.pressler@oracle.com
author psandoz
date Thu, 11 May 2017 12:55:56 -0700
parents 70ec5a09a0d5
children 3c12af929e7d
rev   line source
duke@1 1 /*
psandoz@45055 2 * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
duke@1 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@1 4 *
duke@1 5 * This code is free software; you can redistribute it and/or modify it
duke@1 6 * under the terms of the GNU General Public License version 2 only, as
duke@1 7 * published by the Free Software Foundation.
duke@1 8 *
duke@1 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@1 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@1 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@1 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@1 13 * accompanied this code).
duke@1 14 *
duke@1 15 * You should have received a copy of the GNU General Public License version
duke@1 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@1 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@1 18 *
trims@5547 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@5547 20 * or visit www.oracle.com if you need additional information or have any
trims@5547 21 * questions.
duke@1 22 *
duke@1 23 */
duke@1 24
stefank@7397 25 #include "precompiled.hpp"
stefank@7397 26 #include "c1/c1_Compilation.hpp"
stefank@7397 27 #include "c1/c1_Compiler.hpp"
stefank@7397 28 #include "c1/c1_FrameMap.hpp"
stefank@7397 29 #include "c1/c1_GraphBuilder.hpp"
stefank@7397 30 #include "c1/c1_LinearScan.hpp"
stefank@7397 31 #include "c1/c1_MacroAssembler.hpp"
stefank@7397 32 #include "c1/c1_Runtime1.hpp"
stefank@7397 33 #include "c1/c1_ValueType.hpp"
stefank@7397 34 #include "compiler/compileBroker.hpp"
stefank@7397 35 #include "interpreter/linkResolver.hpp"
stefank@7397 36 #include "memory/allocation.hpp"
stefank@7397 37 #include "memory/allocation.inline.hpp"
stefank@7397 38 #include "memory/resourceArea.hpp"
stefank@7397 39 #include "prims/nativeLookup.hpp"
stefank@7397 40 #include "runtime/arguments.hpp"
stefank@7397 41 #include "runtime/interfaceSupport.hpp"
stefank@7397 42 #include "runtime/sharedRuntime.hpp"
duke@1 43
duke@1 44
neliasso@42040 45 Compiler::Compiler() : AbstractCompiler(compiler_c1) {
twisti@22236 46 }
duke@1 47
anoll@20707 48 void Compiler::init_c1_runtime() {
iveresov@5707 49 BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob();
zgu@25946 50 Arena* arena = new (mtCompiler) Arena(mtCompiler);
iveresov@5707 51 Runtime1::initialize(buffer_blob);
iveresov@5707 52 FrameMap::initialize();
iveresov@5707 53 // initialize data structures
iveresov@5707 54 ValueType::initialize(arena);
iveresov@5707 55 GraphBuilder::initialize();
iveresov@5707 56 // note: to use more than one instance of LinearScan at a time this function call has to
iveresov@5707 57 // be moved somewhere outside of this constructor:
iveresov@5707 58 Interval::initialize(arena);
iveresov@5707 59 }
iveresov@5707 60
iveresov@5707 61
duke@1 62 void Compiler::initialize() {
anoll@20707 63 // Buffer blob must be allocated per C1 compiler thread at startup
anoll@20707 64 BufferBlob* buffer_blob = init_buffer_blob();
anoll@20707 65
anoll@20707 66 if (should_perform_init()) {
anoll@20707 67 if (buffer_blob == NULL) {
anoll@20707 68 // When we come here we are in state 'initializing'; entire C1 compilation
anoll@20707 69 // can be shut down.
anoll@20707 70 set_state(failed);
anoll@20707 71 } else {
anoll@20707 72 init_c1_runtime();
anoll@20707 73 set_state(initialized);
anoll@20707 74 }
duke@1 75 }
duke@1 76 }
duke@1 77
thartmann@26796 78 int Compiler::code_buffer_size() {
thartmann@26796 79 assert(SegmentedCodeCache, "Should be only used with a segmented code cache");
thartmann@26796 80 return Compilation::desired_max_code_buffer_size() + Compilation::desired_max_constant_size();
thartmann@26796 81 }
thartmann@26796 82
anoll@20707 83 BufferBlob* Compiler::init_buffer_blob() {
anoll@17623 84 // Allocate buffer blob once at startup since allocation for each
anoll@17623 85 // compilation seems to be too expensive (at least on Intel win32).
anoll@20707 86 assert (CompilerThread::current()->get_buffer_blob() == NULL, "Should initialize only once");
anoll@17623 87
iveresov@5707 88 // setup CodeBuffer. Preallocate a BufferBlob of size
iveresov@5707 89 // NMethodSizeLimit plus some extra space for constants.
iveresov@5707 90 int code_buffer_size = Compilation::desired_max_code_buffer_size() +
iveresov@5707 91 Compilation::desired_max_constant_size();
anoll@17623 92
anoll@20707 93 BufferBlob* buffer_blob = BufferBlob::create("C1 temporary CodeBuffer", code_buffer_size);
anoll@20707 94 if (buffer_blob != NULL) {
anoll@17623 95 CompilerThread::current()->set_buffer_blob(buffer_blob);
anoll@17623 96 }
anoll@17623 97
anoll@17623 98 return buffer_blob;
iveresov@5707 99 }
iveresov@5707 100
coleenp@33593 101 bool Compiler::is_intrinsic_supported(const methodHandle& method) {
zmajo@31962 102 vmIntrinsics::ID id = method->intrinsic_id();
zmajo@31962 103 assert(id != vmIntrinsics::_none, "must be a VM intrinsic");
zmajo@31962 104
zmajo@31962 105 if (method->is_synchronized()) {
zmajo@31962 106 // C1 does not support intrinsification of synchronized methods.
zmajo@31962 107 return false;
zmajo@31962 108 }
zmajo@31962 109
zmajo@31962 110 switch (id) {
psandoz@45055 111 case vmIntrinsics::_compareAndSetLong:
zmajo@31962 112 if (!VM_Version::supports_cx8()) return false;
zmajo@31962 113 break;
zmajo@31962 114 case vmIntrinsics::_getAndAddInt:
zmajo@31962 115 if (!VM_Version::supports_atomic_getadd4()) return false;
zmajo@31962 116 break;
zmajo@31962 117 case vmIntrinsics::_getAndAddLong:
zmajo@31962 118 if (!VM_Version::supports_atomic_getadd8()) return false;
zmajo@31962 119 break;
zmajo@31962 120 case vmIntrinsics::_getAndSetInt:
zmajo@31962 121 if (!VM_Version::supports_atomic_getset4()) return false;
zmajo@31962 122 break;
zmajo@31962 123 case vmIntrinsics::_getAndSetLong:
zmajo@31962 124 if (!VM_Version::supports_atomic_getset8()) return false;
zmajo@31962 125 break;
zmajo@31962 126 case vmIntrinsics::_getAndSetObject:
zmajo@31962 127 #ifdef _LP64
zmajo@31962 128 if (!UseCompressedOops && !VM_Version::supports_atomic_getset8()) return false;
zmajo@31962 129 if (UseCompressedOops && !VM_Version::supports_atomic_getset4()) return false;
zmajo@31962 130 #else
zmajo@31962 131 if (!VM_Version::supports_atomic_getset4()) return false;
zmajo@31962 132 #endif
zmajo@31962 133 break;
ikrylov@38017 134 case vmIntrinsics::_onSpinWait:
ikrylov@38017 135 if (!VM_Version::supports_on_spin_wait()) return false;
ikrylov@38017 136 break;
zmajo@31962 137 case vmIntrinsics::_arraycopy:
zmajo@31962 138 case vmIntrinsics::_currentTimeMillis:
zmajo@31962 139 case vmIntrinsics::_nanoTime:
zmajo@31962 140 case vmIntrinsics::_Reference_get:
zmajo@31962 141 // Use the intrinsic version of Reference.get() so that the value in
zmajo@31962 142 // the referent field can be registered by the G1 pre-barrier code.
zmajo@31962 143 // Also to prevent commoning reads from this field across safepoint
zmajo@31962 144 // since GC can change its value.
zmajo@31962 145 case vmIntrinsics::_loadFence:
zmajo@31962 146 case vmIntrinsics::_storeFence:
zmajo@31962 147 case vmIntrinsics::_fullFence:
zmajo@31962 148 case vmIntrinsics::_floatToRawIntBits:
zmajo@31962 149 case vmIntrinsics::_intBitsToFloat:
zmajo@31962 150 case vmIntrinsics::_doubleToRawLongBits:
zmajo@31962 151 case vmIntrinsics::_longBitsToDouble:
zmajo@31962 152 case vmIntrinsics::_getClass:
zmajo@31962 153 case vmIntrinsics::_isInstance:
shade@36552 154 case vmIntrinsics::_isPrimitive:
zmajo@31962 155 case vmIntrinsics::_currentThread:
zmajo@31962 156 case vmIntrinsics::_dabs:
zmajo@31962 157 case vmIntrinsics::_dsqrt:
zmajo@31962 158 case vmIntrinsics::_dsin:
zmajo@31962 159 case vmIntrinsics::_dcos:
zmajo@31962 160 case vmIntrinsics::_dtan:
zmajo@31962 161 case vmIntrinsics::_dlog:
zmajo@31962 162 case vmIntrinsics::_dlog10:
zmajo@31962 163 case vmIntrinsics::_dexp:
zmajo@31962 164 case vmIntrinsics::_dpow:
vdeshpande@41323 165 case vmIntrinsics::_fmaD:
vdeshpande@41323 166 case vmIntrinsics::_fmaF:
zmajo@31962 167 case vmIntrinsics::_getObject:
zmajo@31962 168 case vmIntrinsics::_getBoolean:
zmajo@31962 169 case vmIntrinsics::_getByte:
zmajo@31962 170 case vmIntrinsics::_getShort:
zmajo@31962 171 case vmIntrinsics::_getChar:
zmajo@31962 172 case vmIntrinsics::_getInt:
zmajo@31962 173 case vmIntrinsics::_getLong:
zmajo@31962 174 case vmIntrinsics::_getFloat:
zmajo@31962 175 case vmIntrinsics::_getDouble:
zmajo@31962 176 case vmIntrinsics::_putObject:
zmajo@31962 177 case vmIntrinsics::_putBoolean:
zmajo@31962 178 case vmIntrinsics::_putByte:
zmajo@31962 179 case vmIntrinsics::_putShort:
zmajo@31962 180 case vmIntrinsics::_putChar:
zmajo@31962 181 case vmIntrinsics::_putInt:
zmajo@31962 182 case vmIntrinsics::_putLong:
zmajo@31962 183 case vmIntrinsics::_putFloat:
zmajo@31962 184 case vmIntrinsics::_putDouble:
zmajo@31962 185 case vmIntrinsics::_getObjectVolatile:
zmajo@31962 186 case vmIntrinsics::_getBooleanVolatile:
zmajo@31962 187 case vmIntrinsics::_getByteVolatile:
zmajo@31962 188 case vmIntrinsics::_getShortVolatile:
zmajo@31962 189 case vmIntrinsics::_getCharVolatile:
zmajo@31962 190 case vmIntrinsics::_getIntVolatile:
zmajo@31962 191 case vmIntrinsics::_getLongVolatile:
zmajo@31962 192 case vmIntrinsics::_getFloatVolatile:
zmajo@31962 193 case vmIntrinsics::_getDoubleVolatile:
zmajo@31962 194 case vmIntrinsics::_putObjectVolatile:
zmajo@31962 195 case vmIntrinsics::_putBooleanVolatile:
zmajo@31962 196 case vmIntrinsics::_putByteVolatile:
zmajo@31962 197 case vmIntrinsics::_putShortVolatile:
zmajo@31962 198 case vmIntrinsics::_putCharVolatile:
zmajo@31962 199 case vmIntrinsics::_putIntVolatile:
zmajo@31962 200 case vmIntrinsics::_putLongVolatile:
zmajo@31962 201 case vmIntrinsics::_putFloatVolatile:
zmajo@31962 202 case vmIntrinsics::_putDoubleVolatile:
zmajo@31962 203 case vmIntrinsics::_getShortUnaligned:
zmajo@31962 204 case vmIntrinsics::_getCharUnaligned:
zmajo@31962 205 case vmIntrinsics::_getIntUnaligned:
zmajo@31962 206 case vmIntrinsics::_getLongUnaligned:
zmajo@31962 207 case vmIntrinsics::_putShortUnaligned:
zmajo@31962 208 case vmIntrinsics::_putCharUnaligned:
zmajo@31962 209 case vmIntrinsics::_putIntUnaligned:
zmajo@31962 210 case vmIntrinsics::_putLongUnaligned:
zmajo@31962 211 case vmIntrinsics::_checkIndex:
zmajo@31962 212 case vmIntrinsics::_updateCRC32:
zmajo@31962 213 case vmIntrinsics::_updateBytesCRC32:
zmajo@31962 214 case vmIntrinsics::_updateByteBufferCRC32:
kvn@38237 215 #ifdef SPARC
kvn@38237 216 case vmIntrinsics::_updateBytesCRC32C:
kvn@38237 217 case vmIntrinsics::_updateDirectByteBufferCRC32C:
kvn@38237 218 #endif
psandoz@38238 219 case vmIntrinsics::_vectorizedMismatch:
psandoz@45055 220 case vmIntrinsics::_compareAndSetInt:
psandoz@45055 221 case vmIntrinsics::_compareAndSetObject:
thartmann@33628 222 case vmIntrinsics::_getCharStringU:
thartmann@33628 223 case vmIntrinsics::_putCharStringU:
zmajo@31962 224 #ifdef TRACE_HAVE_INTRINSICS
zmajo@31962 225 case vmIntrinsics::_counterTime:
mgronlun@42037 226 case vmIntrinsics::_getBufferWriter:
rehn@40899 227 #if defined(_LP64) || !defined(TRACE_ID_CLASS_SHIFT)
rehn@40899 228 case vmIntrinsics::_getClassId:
rehn@40899 229 #endif
zmajo@31962 230 #endif
zmajo@31962 231 break;
zmajo@31962 232 default:
zmajo@31962 233 return false; // Intrinsics not on the previous list are not available.
zmajo@31962 234 }
zmajo@31962 235
zmajo@31962 236 return true;
zmajo@31962 237 }
zmajo@31962 238
neliasso@33451 239 void Compiler::compile_method(ciEnv* env, ciMethod* method, int entry_bci, DirectiveSet* directive) {
anoll@20707 240 BufferBlob* buffer_blob = CompilerThread::current()->get_buffer_blob();
anoll@20707 241 assert(buffer_blob != NULL, "Must exist");
duke@1 242 // invoke compilation
duke@1 243 {
duke@1 244 // We are nested here because we need for the destructor
duke@1 245 // of Compilation to occur before we release the any
duke@1 246 // competing compiler thread
duke@1 247 ResourceMark rm;
neliasso@33451 248 Compilation c(this, env, method, entry_bci, buffer_blob, directive);
duke@1 249 }
duke@1 250 }
duke@1 251
duke@1 252
duke@1 253 void Compiler::print_timers() {
duke@1 254 Compilation::print_timers();
duke@1 255 }