Mercurial > hg > graal-jvmci-8
annotate src/share/vm/graal/graalRuntime.cpp @ 15582:063ec2920d21
made Graal runtime initialization in hosted mode lazy
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Fri, 09 May 2014 18:46:41 +0200 |
parents | 0cb5c4d276d4 |
children | ddb3ef30fcd2 |
rev | line source |
---|---|
7221 | 1 /* |
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
23 | |
24 #include "precompiled.hpp" | |
7735 | 25 #include "asm/codeBuffer.hpp" |
7221 | 26 #include "graal/graalRuntime.hpp" |
27 #include "graal/graalVMToCompiler.hpp" | |
15582
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
28 #include "graal/graalCompilerToVM.hpp" |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
29 #include "graal/graalJavaAccess.hpp" |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
30 #include "graal/graalEnv.hpp" |
7735 | 31 #include "memory/oopFactory.hpp" |
32 #include "prims/jvm.h" | |
7221 | 33 #include "runtime/biasedLocking.hpp" |
7735 | 34 #include "runtime/interfaceSupport.hpp" |
15582
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
35 #include "runtime/arguments.hpp" |
10542
554f67e4ff3f
Use slow-path stub call instead of deopt in lowering of DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
10475
diff
changeset
|
36 #include "runtime/reflection.hpp" |
8499
96a337d307bd
-More progress in G1 WBs
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
8496
diff
changeset
|
37 #include "utilities/debug.hpp" |
7221 | 38 |
15582
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
39 address GraalRuntime::_external_deopt_i2c_entry = NULL; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
40 volatile int GraalRuntime::_state = uninitialized; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
41 |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
42 void GraalRuntime::initialize() { |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
43 { |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
44 MutexLocker locker(GraalInitialization_lock); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
45 if (_state == uninitialized) { |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
46 _state = initializing; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
47 } else { |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
48 while (_state == initializing) { |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
49 GraalInitialization_lock->wait(); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
50 } |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
51 return; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
52 } |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
53 } |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
54 |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
55 uintptr_t heap_end = (uintptr_t) Universe::heap()->reserved_region().end(); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
56 uintptr_t allocation_end = heap_end + ((uintptr_t)16) * 1024 * 1024 * 1024; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
57 AMD64_ONLY(guarantee(heap_end < allocation_end, "heap end too close to end of address space (might lead to erroneous TLAB allocations)")); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
58 NOT_LP64(error("check TLAB allocation code for address space conflicts")); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
59 |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
60 ThreadToNativeFromVM trans(JavaThread::current()); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
61 JavaThread* THREAD = JavaThread::current(); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
62 TRACE_graal_1("GraalRuntime::initialize"); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
63 |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
64 JNIEnv *env = ((JavaThread *) Thread::current())->jni_environment(); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
65 jclass klass = env->FindClass("com/oracle/graal/hotspot/bridge/CompilerToVMImpl"); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
66 if (klass == NULL) { |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
67 tty->print_cr("graal CompilerToVMImpl class not found"); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
68 vm_abort(false); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
69 } |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
70 env->RegisterNatives(klass, CompilerToVM_methods, CompilerToVM_methods_count()); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
71 |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
72 ResourceMark rm; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
73 HandleMark hm; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
74 { |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
75 GRAAL_VM_ENTRY_MARK; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
76 check_pending_exception("Could not register natives"); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
77 } |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
78 |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
79 graal_compute_offsets(); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
80 |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
81 // Ensure _non_oop_bits is initialized |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
82 Universe::non_oop_word(); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
83 |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
84 { |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
85 GRAAL_VM_ENTRY_MARK; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
86 HandleMark hm; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
87 VMToCompiler::initOptions(); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
88 for (int i = 0; i < Arguments::num_graal_args(); ++i) { |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
89 const char* arg = Arguments::graal_args_array()[i]; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
90 Handle option = java_lang_String::create_from_str(arg, THREAD); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
91 jboolean result = VMToCompiler::setOption(option); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
92 if (!result) { |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
93 tty->print_cr("Invalid option for graal: -G:%s", arg); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
94 vm_abort(false); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
95 } |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
96 } |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
97 VMToCompiler::finalizeOptions(CITime || CITimeEach); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
98 |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
99 _external_deopt_i2c_entry = create_external_deopt_i2c(); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
100 |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
101 VMToCompiler::startRuntime(); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
102 |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
103 { |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
104 MutexLocker locker(GraalInitialization_lock); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
105 _state = initialized; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
106 } |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
107 |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
108 #if !defined(PRODUCT) && !defined(COMPILERGRAAL) |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
109 // In COMPILERGRAAL, we want to allow GraalBootstrap |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
110 // to happen first so GraalCompiler::initialize() |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
111 // duplicates the following code. |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
112 if (CompileTheWorld) { |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
113 VMToCompiler::compileTheWorld(); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
114 } |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
115 #endif |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
116 } |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
117 } |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
118 |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
119 BufferBlob* GraalRuntime::initialize_buffer_blob() { |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
120 JavaThread* THREAD = JavaThread::current(); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
121 BufferBlob* buffer_blob = THREAD->get_buffer_blob(); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
122 if (buffer_blob == NULL) { |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
123 buffer_blob = BufferBlob::create("Graal thread-local CodeBuffer", GraalNMethodSizeLimit); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
124 if (buffer_blob != NULL) { |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
125 THREAD->set_buffer_blob(buffer_blob); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
126 } |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
127 } |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
128 return buffer_blob; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
129 } |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
130 |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
131 address GraalRuntime::create_external_deopt_i2c() { |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
132 ResourceMark rm; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
133 BufferBlob* buffer = BufferBlob::create("externalDeopt", 1*K); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
134 CodeBuffer cb(buffer); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
135 short buffer_locs[20]; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
136 cb.insts()->initialize_shared_locs((relocInfo*)buffer_locs, sizeof(buffer_locs)/sizeof(relocInfo)); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
137 MacroAssembler masm(&cb); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
138 |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
139 int total_args_passed = 5; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
140 |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
141 BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, total_args_passed); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
142 VMRegPair* regs = NEW_RESOURCE_ARRAY(VMRegPair, total_args_passed); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
143 int i = 0; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
144 sig_bt[i++] = T_INT; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
145 sig_bt[i++] = T_LONG; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
146 sig_bt[i++] = T_VOID; // long stakes 2 slots |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
147 sig_bt[i++] = T_INT; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
148 sig_bt[i++] = T_OBJECT; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
149 |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
150 int comp_args_on_stack = SharedRuntime::java_calling_convention(sig_bt, regs, total_args_passed, false); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
151 |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
152 SharedRuntime::gen_i2c_adapter(&masm, total_args_passed, comp_args_on_stack, sig_bt, regs); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
153 masm.flush(); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
154 |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
155 return AdapterBlob::create(&cb)->content_begin(); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
156 } |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
157 |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
158 BasicType GraalRuntime::kindToBasicType(jchar ch) { |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
159 switch(ch) { |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
160 case 'z': return T_BOOLEAN; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
161 case 'b': return T_BYTE; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
162 case 's': return T_SHORT; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
163 case 'c': return T_CHAR; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
164 case 'i': return T_INT; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
165 case 'f': return T_FLOAT; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
166 case 'j': return T_LONG; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
167 case 'd': return T_DOUBLE; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
168 case 'a': return T_OBJECT; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
169 case 'r': return T_ADDRESS; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
170 case '-': return T_ILLEGAL; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
171 default: |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
172 fatal(err_msg("unexpected Kind: %c", ch)); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
173 break; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
174 } |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
175 return T_ILLEGAL; |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
176 } |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
177 |
7221 | 178 // Simple helper to see if the caller of a runtime stub which |
179 // entered the VM has been deoptimized | |
180 | |
181 static bool caller_is_deopted() { | |
182 JavaThread* thread = JavaThread::current(); | |
183 RegisterMap reg_map(thread, false); | |
184 frame runtime_frame = thread->last_frame(); | |
185 frame caller_frame = runtime_frame.sender(®_map); | |
186 assert(caller_frame.is_compiled_frame(), "must be compiled"); | |
187 return caller_frame.is_deoptimized_frame(); | |
188 } | |
189 | |
190 // Stress deoptimization | |
191 static void deopt_caller() { | |
192 if ( !caller_is_deopted()) { | |
193 JavaThread* thread = JavaThread::current(); | |
194 RegisterMap reg_map(thread, false); | |
195 frame runtime_frame = thread->last_frame(); | |
196 frame caller_frame = runtime_frame.sender(®_map); | |
197 Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_constraint); | |
198 assert(caller_is_deopted(), "Must be deoptimized"); | |
199 } | |
200 } | |
201 | |
12433
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
202 JRT_BLOCK_ENTRY(void, GraalRuntime::new_instance(JavaThread* thread, Klass* klass)) |
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
203 JRT_BLOCK; |
7221 | 204 assert(klass->is_klass(), "not a class"); |
205 instanceKlassHandle h(thread, klass); | |
206 h->check_valid_for_instantiation(true, CHECK); | |
207 // make sure klass is initialized | |
208 h->initialize(CHECK); | |
209 // allocate instance and return via TLS | |
210 oop obj = h->allocate_instance(CHECK); | |
12433
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
211 thread->set_vm_result(obj); |
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
212 JRT_BLOCK_END; |
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
213 |
12366
0991c12c4186
Defer barriers upon slow-path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10953
diff
changeset
|
214 if (GraalDeferredInitBarriers) { |
12433
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
215 new_store_pre_barrier(thread); |
12366
0991c12c4186
Defer barriers upon slow-path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10953
diff
changeset
|
216 } |
7221 | 217 JRT_END |
218 | |
12433
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
219 JRT_BLOCK_ENTRY(void, GraalRuntime::new_array(JavaThread* thread, Klass* array_klass, jint length)) |
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
220 JRT_BLOCK; |
7221 | 221 // Note: no handle for klass needed since they are not used |
222 // anymore after new_objArray() and no GC can happen before. | |
223 // (This may have to change if this code changes!) | |
224 assert(array_klass->is_klass(), "not a class"); | |
225 oop obj; | |
226 if (array_klass->oop_is_typeArray()) { | |
227 BasicType elt_type = TypeArrayKlass::cast(array_klass)->element_type(); | |
228 obj = oopFactory::new_typeArray(elt_type, length, CHECK); | |
229 } else { | |
230 Klass* elem_klass = ObjArrayKlass::cast(array_klass)->element_klass(); | |
231 obj = oopFactory::new_objArray(elem_klass, length, CHECK); | |
232 } | |
233 thread->set_vm_result(obj); | |
234 // This is pretty rare but this runtime patch is stressful to deoptimization | |
235 // if we deoptimize here so force a deopt to stress the path. | |
236 if (DeoptimizeALot) { | |
9338
0266549ff6e0
added support from compiled stubs to be installed as RuntimeStubs and to be able to directly call C/C++ runtime functions (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
237 static int deopts = 0; |
0266549ff6e0
added support from compiled stubs to be installed as RuntimeStubs and to be able to directly call C/C++ runtime functions (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
238 // Alternate between deoptimizing and raising an error (which will also cause a deopt) |
0266549ff6e0
added support from compiled stubs to be installed as RuntimeStubs and to be able to directly call C/C++ runtime functions (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
239 if (deopts++ % 2 == 0) { |
0266549ff6e0
added support from compiled stubs to be installed as RuntimeStubs and to be able to directly call C/C++ runtime functions (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
240 ResourceMark rm(THREAD); |
0266549ff6e0
added support from compiled stubs to be installed as RuntimeStubs and to be able to directly call C/C++ runtime functions (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
241 THROW(vmSymbols::java_lang_OutOfMemoryError()); |
0266549ff6e0
added support from compiled stubs to be installed as RuntimeStubs and to be able to directly call C/C++ runtime functions (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
242 } else { |
0266549ff6e0
added support from compiled stubs to be installed as RuntimeStubs and to be able to directly call C/C++ runtime functions (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
243 deopt_caller(); |
0266549ff6e0
added support from compiled stubs to be installed as RuntimeStubs and to be able to directly call C/C++ runtime functions (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
244 } |
7221 | 245 } |
12433
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
246 JRT_BLOCK_END; |
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
247 |
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
248 if (GraalDeferredInitBarriers) { |
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
249 new_store_pre_barrier(thread); |
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
250 } |
9338
0266549ff6e0
added support from compiled stubs to be installed as RuntimeStubs and to be able to directly call C/C++ runtime functions (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9232
diff
changeset
|
251 JRT_END |
7221 | 252 |
12433
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
253 void GraalRuntime::new_store_pre_barrier(JavaThread* thread) { |
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
254 // After any safepoint, just before going back to compiled code, |
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
255 // we inform the GC that we will be doing initializing writes to |
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
256 // this object in the future without emitting card-marks, so |
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
257 // GC may take any compensating steps. |
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
258 // NOTE: Keep this code consistent with GraphKit::store_barrier. |
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
259 |
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
260 oop new_obj = thread->vm_result(); |
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
261 if (new_obj == NULL) return; |
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
262 |
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
263 assert(Universe::heap()->can_elide_tlab_store_barriers(), |
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
264 "compiler must check this first"); |
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
265 // GC may decide to give back a safer copy of new_obj. |
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
266 new_obj = Universe::heap()->new_store_pre_barrier(thread, new_obj); |
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
267 thread->set_vm_result(new_obj); |
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
268 } |
808348377021
Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
12372
diff
changeset
|
269 |
7221 | 270 JRT_ENTRY(void, GraalRuntime::new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims)) |
271 assert(klass->is_klass(), "not a class"); | |
272 assert(rank >= 1, "rank must be nonzero"); | |
273 oop obj = ArrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK); | |
274 thread->set_vm_result(obj); | |
275 JRT_END | |
276 | |
12423
370b5f07f9e2
The runtime entries need to use oopDesc* rather than oop in their signature
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12372
diff
changeset
|
277 JRT_ENTRY(void, GraalRuntime::dynamic_new_array(JavaThread* thread, oopDesc* element_mirror, jint length)) |
10542
554f67e4ff3f
Use slow-path stub call instead of deopt in lowering of DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
10475
diff
changeset
|
278 oop obj = Reflection::reflect_new_array(element_mirror, length, CHECK); |
554f67e4ff3f
Use slow-path stub call instead of deopt in lowering of DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
10475
diff
changeset
|
279 thread->set_vm_result(obj); |
554f67e4ff3f
Use slow-path stub call instead of deopt in lowering of DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
10475
diff
changeset
|
280 JRT_END |
554f67e4ff3f
Use slow-path stub call instead of deopt in lowering of DynamicNewArrayNode.
Roland Schatz <roland.schatz@oracle.com>
parents:
10475
diff
changeset
|
281 |
13578
d8143c431d63
Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12668
diff
changeset
|
282 JRT_ENTRY(void, GraalRuntime::dynamic_new_instance(JavaThread* thread, oopDesc* type_mirror)) |
d8143c431d63
Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12668
diff
changeset
|
283 instanceKlassHandle klass(THREAD, java_lang_Class::as_Klass(type_mirror)); |
d8143c431d63
Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12668
diff
changeset
|
284 |
d8143c431d63
Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12668
diff
changeset
|
285 if (klass == NULL) { |
d8143c431d63
Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12668
diff
changeset
|
286 ResourceMark rm(THREAD); |
d8143c431d63
Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12668
diff
changeset
|
287 THROW(vmSymbols::java_lang_InstantiationException()); |
d8143c431d63
Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12668
diff
changeset
|
288 } |
d8143c431d63
Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12668
diff
changeset
|
289 |
d8143c431d63
Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12668
diff
changeset
|
290 // Create new instance (the receiver) |
d8143c431d63
Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12668
diff
changeset
|
291 klass->check_valid_for_instantiation(false, CHECK); |
d8143c431d63
Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12668
diff
changeset
|
292 |
d8143c431d63
Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12668
diff
changeset
|
293 // Make sure klass gets initialized |
d8143c431d63
Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12668
diff
changeset
|
294 klass->initialize(CHECK); |
d8143c431d63
Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12668
diff
changeset
|
295 |
d8143c431d63
Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12668
diff
changeset
|
296 oop obj = klass->allocate_instance(CHECK); |
d8143c431d63
Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12668
diff
changeset
|
297 thread->set_vm_result(obj); |
d8143c431d63
Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12668
diff
changeset
|
298 JRT_END |
d8143c431d63
Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12668
diff
changeset
|
299 |
7221 | 300 extern void vm_exit(int code); |
301 | |
302 // Enter this method from compiled code handler below. This is where we transition | |
303 // to VM mode. This is done as a helper routine so that the method called directly | |
304 // from compiled code does not have to transition to VM. This allows the entry | |
305 // method to see if the nmethod that we have just looked up a handler for has | |
306 // been deoptimized while we were in the vm. This simplifies the assembly code | |
307 // cpu directories. | |
308 // | |
309 // We are entering here from exception stub (via the entry method below) | |
310 // If there is a compiled exception handler in this method, we will continue there; | |
311 // otherwise we will unwind the stack and continue at the caller of top frame method | |
312 // Note: we enter in Java using a special JRT wrapper. This wrapper allows us to | |
313 // control the area where we can allow a safepoint. After we exit the safepoint area we can | |
314 // check to see if the handler we are going to return is now in a nmethod that has | |
315 // been deoptimized. If that is the case we return the deopt blob | |
316 // unpack_with_exception entry instead. This makes life for the exception blob easier | |
317 // because making that same check and diverting is painful from assembly language. | |
318 JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* thread, oopDesc* ex, address pc, nmethod*& nm)) | |
319 // Reset method handle flag. | |
320 thread->set_is_method_handle_return(false); | |
321 | |
322 Handle exception(thread, ex); | |
323 nm = CodeCache::find_nmethod(pc); | |
324 assert(nm != NULL, "this is not an nmethod"); | |
325 // Adjust the pc as needed/ | |
326 if (nm->is_deopt_pc(pc)) { | |
327 RegisterMap map(thread, false); | |
328 frame exception_frame = thread->last_frame().sender(&map); | |
329 // if the frame isn't deopted then pc must not correspond to the caller of last_frame | |
330 assert(exception_frame.is_deoptimized_frame(), "must be deopted"); | |
331 pc = exception_frame.pc(); | |
332 } | |
333 #ifdef ASSERT | |
334 assert(exception.not_null(), "NULL exceptions should be handled by throw_exception"); | |
335 assert(exception->is_oop(), "just checking"); | |
336 // Check that exception is a subclass of Throwable, otherwise we have a VerifyError | |
337 if (!(exception->is_a(SystemDictionary::Throwable_klass()))) { | |
338 if (ExitVMOnVerifyError) vm_exit(-1); | |
339 ShouldNotReachHere(); | |
340 } | |
341 #endif | |
342 | |
343 // Check the stack guard pages and reenable them if necessary and there is | |
344 // enough space on the stack to do so. Use fast exceptions only if the guard | |
345 // pages are enabled. | |
346 bool guard_pages_enabled = thread->stack_yellow_zone_enabled(); | |
347 if (!guard_pages_enabled) guard_pages_enabled = thread->reguard_stack(); | |
348 | |
349 if (JvmtiExport::can_post_on_exceptions()) { | |
350 // To ensure correct notification of exception catches and throws | |
351 // we have to deoptimize here. If we attempted to notify the | |
352 // catches and throws during this exception lookup it's possible | |
353 // we could deoptimize on the way out of the VM and end back in | |
354 // the interpreter at the throw site. This would result in double | |
355 // notifications since the interpreter would also notify about | |
356 // these same catches and throws as it unwound the frame. | |
357 | |
358 RegisterMap reg_map(thread); | |
359 frame stub_frame = thread->last_frame(); | |
360 frame caller_frame = stub_frame.sender(®_map); | |
361 | |
362 // We don't really want to deoptimize the nmethod itself since we | |
363 // can actually continue in the exception handler ourselves but I | |
364 // don't see an easy way to have the desired effect. | |
365 Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_constraint); | |
366 assert(caller_is_deopted(), "Must be deoptimized"); | |
367 | |
368 return SharedRuntime::deopt_blob()->unpack_with_exception_in_tls(); | |
369 } | |
370 | |
371 // ExceptionCache is used only for exceptions at call sites and not for implicit exceptions | |
372 if (guard_pages_enabled) { | |
373 address fast_continuation = nm->handler_for_exception_and_pc(exception, pc); | |
374 if (fast_continuation != NULL) { | |
375 // Set flag if return address is a method handle call site. | |
376 thread->set_is_method_handle_return(nm->is_method_handle_return(pc)); | |
377 return fast_continuation; | |
378 } | |
379 } | |
380 | |
381 // If the stack guard pages are enabled, check whether there is a handler in | |
382 // the current method. Otherwise (guard pages disabled), force an unwind and | |
383 // skip the exception cache update (i.e., just leave continuation==NULL). | |
384 address continuation = NULL; | |
385 if (guard_pages_enabled) { | |
386 | |
387 // New exception handling mechanism can support inlined methods | |
388 // with exception handlers since the mappings are from PC to PC | |
389 | |
390 // debugging support | |
391 // tracing | |
392 if (TraceExceptions) { | |
393 ttyLocker ttyl; | |
394 ResourceMark rm; | |
395 int offset = pc - nm->code_begin(); | |
396 tty->print_cr("Exception <%s> (0x%x) thrown in compiled method <%s> at PC " PTR_FORMAT " [" PTR_FORMAT "+%d] for thread 0x%x", | |
397 exception->print_value_string(), (address)exception(), nm->method()->print_value_string(), pc, nm->code_begin(), offset, thread); | |
398 } | |
399 // for AbortVMOnException flag | |
400 NOT_PRODUCT(Exceptions::debug_check_abort(exception)); | |
401 | |
402 // Clear out the exception oop and pc since looking up an | |
403 // exception handler can cause class loading, which might throw an | |
404 // exception and those fields are expected to be clear during | |
405 // normal bytecode execution. | |
406 thread->set_exception_oop(NULL); | |
407 thread->set_exception_pc(NULL); | |
408 | |
409 continuation = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, false, false); | |
410 // If an exception was thrown during exception dispatch, the exception oop may have changed | |
411 thread->set_exception_oop(exception()); | |
412 thread->set_exception_pc(pc); | |
413 | |
414 // the exception cache is used only by non-implicit exceptions | |
415 if (continuation != NULL && !SharedRuntime::deopt_blob()->contains(continuation)) { | |
416 nm->add_handler_for_exception_and_pc(exception, pc, continuation); | |
417 } | |
418 } | |
419 | |
420 // Set flag if return address is a method handle call site. | |
421 thread->set_is_method_handle_return(nm->is_method_handle_return(pc)); | |
422 | |
423 if (TraceExceptions) { | |
424 ttyLocker ttyl; | |
425 ResourceMark rm; | |
426 tty->print_cr("Thread " PTR_FORMAT " continuing at PC " PTR_FORMAT " for exception thrown at PC " PTR_FORMAT, | |
427 thread, continuation, pc); | |
428 } | |
429 | |
430 return continuation; | |
431 JRT_END | |
432 | |
433 // Enter this method from compiled code only if there is a Java exception handler | |
434 // in the method handling the exception. | |
435 // We are entering here from exception stub. We don't do a normal VM transition here. | |
436 // We do it in a helper. This is so we can check to see if the nmethod we have just | |
437 // searched for an exception handler has been deoptimized in the meantime. | |
438 address GraalRuntime::exception_handler_for_pc(JavaThread* thread) { | |
439 oop exception = thread->exception_oop(); | |
440 address pc = thread->exception_pc(); | |
441 // Still in Java mode | |
442 DEBUG_ONLY(ResetNoHandleMark rnhm); | |
443 nmethod* nm = NULL; | |
444 address continuation = NULL; | |
445 { | |
446 // Enter VM mode by calling the helper | |
447 ResetNoHandleMark rnhm; | |
448 continuation = exception_handler_for_pc_helper(thread, exception, pc, nm); | |
449 } | |
450 // Back in JAVA, use no oops DON'T safepoint | |
451 | |
452 // Now check to see if the nmethod we were called from is now deoptimized. | |
453 // If so we must return to the deopt blob and deoptimize the nmethod | |
454 if (nm != NULL && caller_is_deopted()) { | |
455 continuation = SharedRuntime::deopt_blob()->unpack_with_exception_in_tls(); | |
456 } | |
457 | |
458 assert(continuation != NULL, "no handler found"); | |
459 return continuation; | |
460 } | |
461 | |
7911
983f7bdb85ff
removed redundant graal_ prefix from Graal specific functions and variable in native code
Doug Simon <doug.simon@oracle.com>
parents:
7735
diff
changeset
|
462 JRT_ENTRY(void, GraalRuntime::create_null_exception(JavaThread* thread)) |
12668
e27f3169460e
notify JVMTI about exception throws from runtime
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
12435
diff
changeset
|
463 SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_NullPointerException()); |
e27f3169460e
notify JVMTI about exception throws from runtime
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
12435
diff
changeset
|
464 thread->set_vm_result(PENDING_EXCEPTION); |
e27f3169460e
notify JVMTI about exception throws from runtime
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
12435
diff
changeset
|
465 CLEAR_PENDING_EXCEPTION; |
7221 | 466 JRT_END |
467 | |
7911
983f7bdb85ff
removed redundant graal_ prefix from Graal specific functions and variable in native code
Doug Simon <doug.simon@oracle.com>
parents:
7735
diff
changeset
|
468 JRT_ENTRY(void, GraalRuntime::create_out_of_bounds_exception(JavaThread* thread, jint index)) |
7221 | 469 char message[jintAsStringSize]; |
470 sprintf(message, "%d", index); | |
12668
e27f3169460e
notify JVMTI about exception throws from runtime
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
12435
diff
changeset
|
471 SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), message); |
e27f3169460e
notify JVMTI about exception throws from runtime
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
12435
diff
changeset
|
472 thread->set_vm_result(PENDING_EXCEPTION); |
e27f3169460e
notify JVMTI about exception throws from runtime
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
12435
diff
changeset
|
473 CLEAR_PENDING_EXCEPTION; |
7221 | 474 JRT_END |
475 | |
7911
983f7bdb85ff
removed redundant graal_ prefix from Graal specific functions and variable in native code
Doug Simon <doug.simon@oracle.com>
parents:
7735
diff
changeset
|
476 JRT_ENTRY_NO_ASYNC(void, GraalRuntime::monitorenter(JavaThread* thread, oopDesc* obj, BasicLock* lock)) |
7221 | 477 if (TraceGraal >= 3) { |
478 char type[O_BUFLEN]; | |
479 obj->klass()->name()->as_C_string(type, O_BUFLEN); | |
480 markOop mark = obj->mark(); | |
481 tty->print_cr("%s: entered locking slow case with obj=" INTPTR_FORMAT ", type=%s, mark=" INTPTR_FORMAT ", lock=" INTPTR_FORMAT, thread->name(), obj, type, mark, lock); | |
482 tty->flush(); | |
483 } | |
484 #ifdef ASSERT | |
485 if (PrintBiasedLockingStatistics) { | |
486 Atomic::inc(BiasedLocking::slow_path_entry_count_addr()); | |
487 } | |
488 #endif | |
489 Handle h_obj(thread, obj); | |
490 assert(h_obj()->is_oop(), "must be NULL or an object"); | |
491 if (UseBiasedLocking) { | |
492 // Retry fast entry if bias is revoked to avoid unnecessary inflation | |
493 ObjectSynchronizer::fast_enter(h_obj, lock, true, CHECK); | |
494 } else { | |
7226 | 495 if (GraalUseFastLocking) { |
7221 | 496 // When using fast locking, the compiled code has already tried the fast case |
497 ObjectSynchronizer::slow_enter(h_obj, lock, THREAD); | |
498 } else { | |
499 ObjectSynchronizer::fast_enter(h_obj, lock, false, THREAD); | |
500 } | |
501 } | |
502 if (TraceGraal >= 3) { | |
503 tty->print_cr("%s: exiting locking slow with obj=" INTPTR_FORMAT, thread->name(), obj); | |
504 } | |
505 JRT_END | |
506 | |
7911
983f7bdb85ff
removed redundant graal_ prefix from Graal specific functions and variable in native code
Doug Simon <doug.simon@oracle.com>
parents:
7735
diff
changeset
|
507 JRT_LEAF(void, GraalRuntime::monitorexit(JavaThread* thread, oopDesc* obj, BasicLock* lock)) |
7221 | 508 assert(thread == JavaThread::current(), "threads must correspond"); |
509 assert(thread->last_Java_sp(), "last_Java_sp must be set"); | |
510 // monitorexit is non-blocking (leaf routine) => no exceptions can be thrown | |
511 EXCEPTION_MARK; | |
512 | |
513 #ifdef DEBUG | |
514 if (!obj->is_oop()) { | |
515 ResetNoHandleMark rhm; | |
516 nmethod* method = thread->last_frame().cb()->as_nmethod_or_null(); | |
517 if (method != NULL) { | |
518 tty->print_cr("ERROR in monitorexit in method %s wrong obj " INTPTR_FORMAT, method->name(), obj); | |
519 } | |
520 thread->print_stack_on(tty); | |
521 assert(false, "invalid lock object pointer dected"); | |
522 } | |
523 #endif | |
524 | |
7226 | 525 if (GraalUseFastLocking) { |
7221 | 526 // When using fast locking, the compiled code has already tried the fast case |
527 ObjectSynchronizer::slow_exit(obj, lock, THREAD); | |
528 } else { | |
529 ObjectSynchronizer::fast_exit(obj, lock, THREAD); | |
530 } | |
531 if (TraceGraal >= 3) { | |
532 char type[O_BUFLEN]; | |
533 obj->klass()->name()->as_C_string(type, O_BUFLEN); | |
534 tty->print_cr("%s: exited locking slow case with obj=" INTPTR_FORMAT ", type=%s, mark=" INTPTR_FORMAT ", lock=" INTPTR_FORMAT, thread->name(), obj, type, obj->mark(), lock); | |
535 tty->flush(); | |
536 } | |
537 JRT_END | |
538 | |
12423
370b5f07f9e2
The runtime entries need to use oopDesc* rather than oop in their signature
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12372
diff
changeset
|
539 JRT_ENTRY(void, GraalRuntime::log_object(JavaThread* thread, oopDesc* obj, jint flags)) |
7221 | 540 bool string = mask_bits_are_true(flags, LOG_OBJECT_STRING); |
12356
359f7e70ae7f
Reduce HotSpot diff and fix previous merge
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
10953
diff
changeset
|
541 bool addr = mask_bits_are_true(flags, LOG_OBJECT_ADDRESS); |
7221 | 542 bool newline = mask_bits_are_true(flags, LOG_OBJECT_NEWLINE); |
543 if (!string) { | |
12356
359f7e70ae7f
Reduce HotSpot diff and fix previous merge
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
10953
diff
changeset
|
544 if (!addr && obj->is_oop_or_null(true)) { |
7221 | 545 char buf[O_BUFLEN]; |
12356
359f7e70ae7f
Reduce HotSpot diff and fix previous merge
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
10953
diff
changeset
|
546 tty->print("%s@%p", obj->klass()->name()->as_C_string(buf, O_BUFLEN), (address)obj); |
7221 | 547 } else { |
12356
359f7e70ae7f
Reduce HotSpot diff and fix previous merge
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
10953
diff
changeset
|
548 tty->print("%p", (address)obj); |
7221 | 549 } |
550 } else { | |
551 ResourceMark rm; | |
552 assert(obj != NULL && java_lang_String::is_instance(obj), "must be"); | |
553 char *buf = java_lang_String::as_utf8_string(obj); | |
554 tty->print(buf); | |
555 } | |
556 if (newline) { | |
557 tty->cr(); | |
558 } | |
559 JRT_END | |
560 | |
10434
8b22524df53b
Add G1 Barriers' foreign calls
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10072
diff
changeset
|
561 JRT_LEAF(void, GraalRuntime::write_barrier_pre(JavaThread* thread, oopDesc* obj)) |
8b22524df53b
Add G1 Barriers' foreign calls
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10072
diff
changeset
|
562 thread->satb_mark_queue().enqueue(obj); |
8b22524df53b
Add G1 Barriers' foreign calls
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10072
diff
changeset
|
563 JRT_END |
8b22524df53b
Add G1 Barriers' foreign calls
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10072
diff
changeset
|
564 |
8b22524df53b
Add G1 Barriers' foreign calls
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10072
diff
changeset
|
565 JRT_LEAF(void, GraalRuntime::write_barrier_post(JavaThread* thread, void* card_addr)) |
8b22524df53b
Add G1 Barriers' foreign calls
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10072
diff
changeset
|
566 thread->dirty_card_queue().enqueue(card_addr); |
8b22524df53b
Add G1 Barriers' foreign calls
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10072
diff
changeset
|
567 JRT_END |
8b22524df53b
Add G1 Barriers' foreign calls
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10072
diff
changeset
|
568 |
12356
359f7e70ae7f
Reduce HotSpot diff and fix previous merge
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
10953
diff
changeset
|
569 JRT_LEAF(jboolean, GraalRuntime::validate_object(JavaThread* thread, oopDesc* parent, oopDesc* child)) |
10953
97e282186b5b
Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10542
diff
changeset
|
570 bool ret = true; |
97e282186b5b
Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10542
diff
changeset
|
571 if(!Universe::heap()->is_in_closed_subset(parent)) { |
97e282186b5b
Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10542
diff
changeset
|
572 tty->print_cr("Parent Object "INTPTR_FORMAT" not in heap", parent); |
97e282186b5b
Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10542
diff
changeset
|
573 parent->print(); |
97e282186b5b
Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10542
diff
changeset
|
574 ret=false; |
97e282186b5b
Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10542
diff
changeset
|
575 } |
97e282186b5b
Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10542
diff
changeset
|
576 if(!Universe::heap()->is_in_closed_subset(child)) { |
97e282186b5b
Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10542
diff
changeset
|
577 tty->print_cr("Child Object "INTPTR_FORMAT" not in heap", child); |
97e282186b5b
Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10542
diff
changeset
|
578 child->print(); |
97e282186b5b
Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10542
diff
changeset
|
579 ret=false; |
97e282186b5b
Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10542
diff
changeset
|
580 } |
97e282186b5b
Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10542
diff
changeset
|
581 return (jint)ret; |
97e282186b5b
Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10542
diff
changeset
|
582 JRT_END |
97e282186b5b
Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents:
10542
diff
changeset
|
583 |
14731
0cb5c4d276d4
use raw data support to fix incorrect use of String.intern() for embedding strings in code
Doug Simon <doug.simon@oracle.com>
parents:
14608
diff
changeset
|
584 JRT_ENTRY(void, GraalRuntime::vm_error(JavaThread* thread, jlong where, jlong format, jlong value)) |
7221 | 585 ResourceMark rm; |
14731
0cb5c4d276d4
use raw data support to fix incorrect use of String.intern() for embedding strings in code
Doug Simon <doug.simon@oracle.com>
parents:
14608
diff
changeset
|
586 const char *error_msg = where == 0L ? "<internal Graal error>" : (char*) (address) where; |
7221 | 587 char *detail_msg = NULL; |
14731
0cb5c4d276d4
use raw data support to fix incorrect use of String.intern() for embedding strings in code
Doug Simon <doug.simon@oracle.com>
parents:
14608
diff
changeset
|
588 if (format != 0L) { |
0cb5c4d276d4
use raw data support to fix incorrect use of String.intern() for embedding strings in code
Doug Simon <doug.simon@oracle.com>
parents:
14608
diff
changeset
|
589 const char* buf = (char*) (address) format; |
7221 | 590 size_t detail_msg_length = strlen(buf) * 2; |
591 detail_msg = (char *) NEW_RESOURCE_ARRAY(u_char, detail_msg_length); | |
592 jio_snprintf(detail_msg, detail_msg_length, buf, value); | |
593 } | |
594 report_vm_error(__FILE__, __LINE__, error_msg, detail_msg); | |
595 JRT_END | |
596 | |
12423
370b5f07f9e2
The runtime entries need to use oopDesc* rather than oop in their signature
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12372
diff
changeset
|
597 JRT_LEAF(oopDesc*, GraalRuntime::load_and_clear_exception(JavaThread* thread)) |
9820
1b60f639ac4b
implemented alternative implementation for loading the exception object from the thread at the start of an exception dispatcher
Doug Simon <doug.simon@oracle.com>
parents:
9596
diff
changeset
|
598 oop exception = thread->exception_oop(); |
1b60f639ac4b
implemented alternative implementation for loading the exception object from the thread at the start of an exception dispatcher
Doug Simon <doug.simon@oracle.com>
parents:
9596
diff
changeset
|
599 assert(exception != NULL, "npe"); |
1b60f639ac4b
implemented alternative implementation for loading the exception object from the thread at the start of an exception dispatcher
Doug Simon <doug.simon@oracle.com>
parents:
9596
diff
changeset
|
600 thread->set_exception_oop(NULL); |
1b60f639ac4b
implemented alternative implementation for loading the exception object from the thread at the start of an exception dispatcher
Doug Simon <doug.simon@oracle.com>
parents:
9596
diff
changeset
|
601 thread->set_exception_pc(0); |
1b60f639ac4b
implemented alternative implementation for loading the exception object from the thread at the start of an exception dispatcher
Doug Simon <doug.simon@oracle.com>
parents:
9596
diff
changeset
|
602 return exception; |
1b60f639ac4b
implemented alternative implementation for loading the exception object from the thread at the start of an exception dispatcher
Doug Simon <doug.simon@oracle.com>
parents:
9596
diff
changeset
|
603 JRT_END |
8506 | 604 |
12423
370b5f07f9e2
The runtime entries need to use oopDesc* rather than oop in their signature
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12372
diff
changeset
|
605 JRT_LEAF(void, GraalRuntime::log_printf(JavaThread* thread, oopDesc* format, jlong v1, jlong v2, jlong v3)) |
7221 | 606 ResourceMark rm; |
607 assert(format != NULL && java_lang_String::is_instance(format), "must be"); | |
608 char *buf = java_lang_String::as_utf8_string(format); | |
7235
a6bd253a770f
expanded LOG_PRINTF stub to handle up to 3 arguments in addition to the format string
Doug Simon <doug.simon@oracle.com>
parents:
7226
diff
changeset
|
609 tty->print(buf, v1, v2, v3); |
7221 | 610 JRT_END |
611 | |
9573
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
612 static void decipher(jlong v, bool ignoreZero) { |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
613 if (v != 0 || !ignoreZero) { |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
614 void* p = (void *)(address) v; |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
615 CodeBlob* cb = CodeCache::find_blob(p); |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
616 if (cb) { |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
617 if (cb->is_nmethod()) { |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
618 char buf[O_BUFLEN]; |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
619 tty->print("%s [%p+%d]", cb->as_nmethod_or_null()->method()->name_and_sig_as_C_string(buf, O_BUFLEN), cb->code_begin(), (address)v - cb->code_begin()); |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
620 return; |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
621 } |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
622 cb->print_value_on(tty); |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
623 return; |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
624 } |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
625 if (Universe::heap()->is_in(p)) { |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
626 oop obj = oop(p); |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
627 obj->print_value_on(tty); |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
628 return; |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
629 } |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
630 tty->print("%p [long: %d, double %f, char %c]", v, v, v, v); |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
631 } |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
632 } |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
633 |
9471
5fa54bf57f8c
replaced exception_handler_nofpu assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9457
diff
changeset
|
634 JRT_LEAF(void, GraalRuntime::vm_message(jboolean vmError, jlong format, jlong v1, jlong v2, jlong v3)) |
9232
bb2447c64055
strings used in compiled stubs are lowered to malloc'ed C strings so that there are no embedded oops (for the strings) in the resulting installed code
Doug Simon <doug.simon@oracle.com>
parents:
8506
diff
changeset
|
635 ResourceMark rm; |
bb2447c64055
strings used in compiled stubs are lowered to malloc'ed C strings so that there are no embedded oops (for the strings) in the resulting installed code
Doug Simon <doug.simon@oracle.com>
parents:
8506
diff
changeset
|
636 char *buf = (char*) (address) format; |
9471
5fa54bf57f8c
replaced exception_handler_nofpu assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9457
diff
changeset
|
637 if (vmError) { |
9573
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
638 if (buf != NULL) { |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
639 fatal(err_msg(buf, v1, v2, v3)); |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
640 } else { |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
641 fatal("<anonymous error>"); |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
642 } |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
643 } else if (buf != NULL) { |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
644 tty->print(buf, v1, v2, v3); |
9471
5fa54bf57f8c
replaced exception_handler_nofpu assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9457
diff
changeset
|
645 } else { |
9573
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
646 assert(v2 == 0, "v2 != 0"); |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
647 assert(v3 == 0, "v3 != 0"); |
a79e8020ad4b
added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents:
9565
diff
changeset
|
648 decipher(v1, false); |
9471
5fa54bf57f8c
replaced exception_handler_nofpu assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents:
9457
diff
changeset
|
649 } |
9232
bb2447c64055
strings used in compiled stubs are lowered to malloc'ed C strings so that there are no embedded oops (for the strings) in the resulting installed code
Doug Simon <doug.simon@oracle.com>
parents:
8506
diff
changeset
|
650 JRT_END |
bb2447c64055
strings used in compiled stubs are lowered to malloc'ed C strings so that there are no embedded oops (for the strings) in the resulting installed code
Doug Simon <doug.simon@oracle.com>
parents:
8506
diff
changeset
|
651 |
7911
983f7bdb85ff
removed redundant graal_ prefix from Graal specific functions and variable in native code
Doug Simon <doug.simon@oracle.com>
parents:
7735
diff
changeset
|
652 JRT_ENTRY(void, GraalRuntime::log_primitive(JavaThread* thread, jchar typeChar, jlong value, jboolean newline)) |
7221 | 653 union { |
654 jlong l; | |
655 jdouble d; | |
656 jfloat f; | |
657 } uu; | |
658 uu.l = value; | |
659 switch (typeChar) { | |
660 case 'z': tty->print(value == 0 ? "false" : "true"); break; | |
661 case 'b': tty->print("%d", (jbyte) value); break; | |
662 case 'c': tty->print("%c", (jchar) value); break; | |
663 case 's': tty->print("%d", (jshort) value); break; | |
664 case 'i': tty->print("%d", (jint) value); break; | |
665 case 'f': tty->print("%f", uu.f); break; | |
666 case 'j': tty->print(INT64_FORMAT, value); break; | |
667 case 'd': tty->print("%lf", uu.d); break; | |
668 default: assert(false, "unknown typeChar"); break; | |
669 } | |
670 if (newline) { | |
671 tty->cr(); | |
672 } | |
673 JRT_END | |
674 | |
12423
370b5f07f9e2
The runtime entries need to use oopDesc* rather than oop in their signature
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12372
diff
changeset
|
675 JRT_ENTRY(jint, GraalRuntime::identity_hash_code(JavaThread* thread, oopDesc* obj)) |
7221 | 676 return (jint) obj->identity_hash(); |
677 JRT_END | |
678 | |
12423
370b5f07f9e2
The runtime entries need to use oopDesc* rather than oop in their signature
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12372
diff
changeset
|
679 JRT_ENTRY(jboolean, GraalRuntime::thread_is_interrupted(JavaThread* thread, oopDesc* receiver, jboolean clear_interrupted)) |
7220
fcae6d960acd
added more compiler intrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7216
diff
changeset
|
680 // Ensure that the C++ Thread and OSThread structures aren't freed before we operate |
fcae6d960acd
added more compiler intrinsics
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7216
diff
changeset
|
681 Handle receiverHandle(thread, receiver); |
12423
370b5f07f9e2
The runtime entries need to use oopDesc* rather than oop in their signature
Gilles Duboscq <duboscq@ssw.jku.at>
parents:
12372
diff
changeset
|
682 MutexLockerEx ml(thread->threadObj() == (void*)receiver ? NULL : Threads_lock); |
7386
707e9cca11de
fixed HotSpot windows build
Christian Haeubl <haeubl@ssw.jku.at>
parents:
7235
diff
changeset
|
683 JavaThread* receiverThread = java_lang_Thread::thread(receiverHandle()); |
14608
682fba1bcf95
add missing null check in is_interrupted
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13578
diff
changeset
|
684 if (receiverThread == NULL) { |
682fba1bcf95
add missing null check in is_interrupted
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13578
diff
changeset
|
685 // The other thread may exit during this process, which is ok so return false. |
682fba1bcf95
add missing null check in is_interrupted
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13578
diff
changeset
|
686 return JNI_FALSE; |
682fba1bcf95
add missing null check in is_interrupted
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13578
diff
changeset
|
687 } else { |
682fba1bcf95
add missing null check in is_interrupted
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13578
diff
changeset
|
688 return (jint) Thread::is_interrupted(receiverThread, clear_interrupted != 0); |
682fba1bcf95
add missing null check in is_interrupted
Tom Rodriguez <tom.rodriguez@oracle.com>
parents:
13578
diff
changeset
|
689 } |
7221 | 690 JRT_END |
691 | |
692 // JVM_InitializeGraalRuntime | |
693 JVM_ENTRY(jobject, JVM_InitializeGraalRuntime(JNIEnv *env, jclass graalclass)) | |
15582
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
694 GraalRuntime::initialize(); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
695 return VMToCompiler::get_HotSpotGraalRuntime_jobject(); |
7221 | 696 JVM_END |
10475
3489047ffea2
Restructure the handling of HotSpotInstalledCode and their link to nmethods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10434
diff
changeset
|
697 |
3489047ffea2
Restructure the handling of HotSpotInstalledCode and their link to nmethods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10434
diff
changeset
|
698 // JVM_InitializeTruffleRuntime |
3489047ffea2
Restructure the handling of HotSpotInstalledCode and their link to nmethods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10434
diff
changeset
|
699 JVM_ENTRY(jobject, JVM_InitializeTruffleRuntime(JNIEnv *env, jclass graalclass)) |
15582
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
700 GraalRuntime::initialize(); |
063ec2920d21
made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents:
14731
diff
changeset
|
701 return JNIHandles::make_local(VMToCompiler::create_HotSpotTruffleRuntime()()); |
10475
3489047ffea2
Restructure the handling of HotSpotInstalledCode and their link to nmethods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
10434
diff
changeset
|
702 JVM_END |