annotate src/share/vm/graal/graalRuntime.cpp @ 16270:d56a09df1a1f

implemented eager checking of Graal options (GRAAL-807)
author Doug Simon <doug.simon@oracle.com>
date Fri, 27 Jun 2014 19:55:54 +0200
parents 66a9286203a2
children d6ffc6164830
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
1 /*
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
4 *
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
7 * published by the Free Software Foundation.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
8 *
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
13 * accompanied this code).
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
14 *
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
15 * You should have received a copy of the GNU General Public License version
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
18 *
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
21 * questions.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
22 */
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
23
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
24 #include "precompiled.hpp"
7735
a7a93887b4c4 fix Solaris build and initial SPARC support
twisti
parents: 7386
diff changeset
25 #include "asm/codeBuffer.hpp"
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
26 #include "compiler/compileBroker.hpp"
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
27 #include "graal/graalRuntime.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"
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
29 #include "graal/graalCompiler.hpp"
15582
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
30 #include "graal/graalJavaAccess.hpp"
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
31 #include "graal/graalEnv.hpp"
7735
a7a93887b4c4 fix Solaris build and initial SPARC support
twisti
parents: 7386
diff changeset
32 #include "memory/oopFactory.hpp"
a7a93887b4c4 fix Solaris build and initial SPARC support
twisti
parents: 7386
diff changeset
33 #include "prims/jvm.h"
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
34 #include "runtime/biasedLocking.hpp"
7735
a7a93887b4c4 fix Solaris build and initial SPARC support
twisti
parents: 7386
diff changeset
35 #include "runtime/interfaceSupport.hpp"
15582
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
36 #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
37 #include "runtime/reflection.hpp"
8499
96a337d307bd -More progress in G1 WBs
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 8496
diff changeset
38 #include "utilities/debug.hpp"
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
39
15582
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
40 address GraalRuntime::_external_deopt_i2c_entry = NULL;
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
41 jobject GraalRuntime::_HotSpotGraalRuntime_instance = NULL;
15582
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
42
15603
b7fb36e57da8 made Graal initialization be driven from Java to simplify sequencing and synchronization
Doug Simon <doug.simon@oracle.com>
parents: 15589
diff changeset
43 void GraalRuntime::initialize_natives(JNIEnv *env, jclass c2vmClass) {
15582
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
44 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
45 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
46 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
47 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
48
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
49 JavaThread* THREAD = JavaThread::current();
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
50 {
15603
b7fb36e57da8 made Graal initialization be driven from Java to simplify sequencing and synchronization
Doug Simon <doug.simon@oracle.com>
parents: 15589
diff changeset
51 ThreadToNativeFromVM trans(THREAD);
15582
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
52
15603
b7fb36e57da8 made Graal initialization be driven from Java to simplify sequencing and synchronization
Doug Simon <doug.simon@oracle.com>
parents: 15589
diff changeset
53 ResourceMark rm;
15582
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
54 HandleMark hm;
15603
b7fb36e57da8 made Graal initialization be driven from Java to simplify sequencing and synchronization
Doug Simon <doug.simon@oracle.com>
parents: 15589
diff changeset
55
b7fb36e57da8 made Graal initialization be driven from Java to simplify sequencing and synchronization
Doug Simon <doug.simon@oracle.com>
parents: 15589
diff changeset
56 graal_compute_offsets();
15582
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
57
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
58 _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
59
15603
b7fb36e57da8 made Graal initialization be driven from Java to simplify sequencing and synchronization
Doug Simon <doug.simon@oracle.com>
parents: 15589
diff changeset
60 // Ensure _non_oop_bits is initialized
b7fb36e57da8 made Graal initialization be driven from Java to simplify sequencing and synchronization
Doug Simon <doug.simon@oracle.com>
parents: 15589
diff changeset
61 Universe::non_oop_word();
15582
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
62
15603
b7fb36e57da8 made Graal initialization be driven from Java to simplify sequencing and synchronization
Doug Simon <doug.simon@oracle.com>
parents: 15589
diff changeset
63 env->RegisterNatives(c2vmClass, CompilerToVM_methods, CompilerToVM_methods_count());
15582
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
64 }
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
65 GUARANTEE_NO_PENDING_EXCEPTION("Could not register natives");
15582
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
66 }
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
67
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
68 BufferBlob* GraalRuntime::initialize_buffer_blob() {
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
69 JavaThread* THREAD = JavaThread::current();
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
70 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
71 if (buffer_blob == NULL) {
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
72 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
73 if (buffer_blob != NULL) {
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
74 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
75 }
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
76 }
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
77 return buffer_blob;
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
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
80 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
81 ResourceMark rm;
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
82 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
83 CodeBuffer cb(buffer);
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
84 short buffer_locs[20];
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
85 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
86 MacroAssembler masm(&cb);
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
87
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
88 int total_args_passed = 5;
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
89
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
90 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
91 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
92 int i = 0;
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
93 sig_bt[i++] = T_INT;
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
94 sig_bt[i++] = T_LONG;
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
95 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
96 sig_bt[i++] = T_INT;
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
97 sig_bt[i++] = T_OBJECT;
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 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
100
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
101 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
102 masm.flush();
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 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
105 }
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 BasicType GraalRuntime::kindToBasicType(jchar ch) {
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
108 switch(ch) {
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
109 case 'z': return T_BOOLEAN;
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
110 case 'b': return T_BYTE;
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
111 case 's': return T_SHORT;
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
112 case 'c': return T_CHAR;
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
113 case 'i': return T_INT;
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
114 case 'f': return T_FLOAT;
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
115 case 'j': return T_LONG;
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
116 case 'd': return T_DOUBLE;
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
117 case 'a': return T_OBJECT;
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
118 case 'r': return T_ADDRESS;
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
119 case '-': return T_ILLEGAL;
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
120 default:
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
121 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
122 break;
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
123 }
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
124 return T_ILLEGAL;
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
125 }
063ec2920d21 made Graal runtime initialization in hosted mode lazy
Doug Simon <doug.simon@oracle.com>
parents: 14731
diff changeset
126
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
127 // Simple helper to see if the caller of a runtime stub which
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
128 // entered the VM has been deoptimized
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
129
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
130 static bool caller_is_deopted() {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
131 JavaThread* thread = JavaThread::current();
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
132 RegisterMap reg_map(thread, false);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
133 frame runtime_frame = thread->last_frame();
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
134 frame caller_frame = runtime_frame.sender(&reg_map);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
135 assert(caller_frame.is_compiled_frame(), "must be compiled");
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
136 return caller_frame.is_deoptimized_frame();
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
137 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
138
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
139 // Stress deoptimization
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
140 static void deopt_caller() {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
141 if ( !caller_is_deopted()) {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
142 JavaThread* thread = JavaThread::current();
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
143 RegisterMap reg_map(thread, false);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
144 frame runtime_frame = thread->last_frame();
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
145 frame caller_frame = runtime_frame.sender(&reg_map);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
146 Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_constraint);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
147 assert(caller_is_deopted(), "Must be deoptimized");
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
148 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
149 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
150
12433
808348377021 Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 12372
diff changeset
151 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
152 JRT_BLOCK;
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
153 assert(klass->is_klass(), "not a class");
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
154 instanceKlassHandle h(thread, klass);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
155 h->check_valid_for_instantiation(true, CHECK);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
156 // make sure klass is initialized
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
157 h->initialize(CHECK);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
158 // allocate instance and return via TLS
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
159 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
160 thread->set_vm_result(obj);
808348377021 Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 12372
diff changeset
161 JRT_BLOCK_END;
808348377021 Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 12372
diff changeset
162
12366
0991c12c4186 Defer barriers upon slow-path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10953
diff changeset
163 if (GraalDeferredInitBarriers) {
12433
808348377021 Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 12372
diff changeset
164 new_store_pre_barrier(thread);
12366
0991c12c4186 Defer barriers upon slow-path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10953
diff changeset
165 }
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
166 JRT_END
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
167
12433
808348377021 Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 12372
diff changeset
168 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
169 JRT_BLOCK;
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
170 // Note: no handle for klass needed since they are not used
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
171 // anymore after new_objArray() and no GC can happen before.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
172 // (This may have to change if this code changes!)
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
173 assert(array_klass->is_klass(), "not a class");
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
174 oop obj;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
175 if (array_klass->oop_is_typeArray()) {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
176 BasicType elt_type = TypeArrayKlass::cast(array_klass)->element_type();
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
177 obj = oopFactory::new_typeArray(elt_type, length, CHECK);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
178 } else {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
179 Klass* elem_klass = ObjArrayKlass::cast(array_klass)->element_klass();
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
180 obj = oopFactory::new_objArray(elem_klass, length, CHECK);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
181 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
182 thread->set_vm_result(obj);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
183 // This is pretty rare but this runtime patch is stressful to deoptimization
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
184 // if we deoptimize here so force a deopt to stress the path.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
185 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
186 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
187 // 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
188 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
189 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
190 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
191 } 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
192 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
193 }
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
194 }
12433
808348377021 Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 12372
diff changeset
195 JRT_BLOCK_END;
808348377021 Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 12372
diff changeset
196
808348377021 Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 12372
diff changeset
197 if (GraalDeferredInitBarriers) {
808348377021 Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 12372
diff changeset
198 new_store_pre_barrier(thread);
808348377021 Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 12372
diff changeset
199 }
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
200 JRT_END
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
201
12433
808348377021 Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 12372
diff changeset
202 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
203 // 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
204 // 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
205 // 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
206 // GC may take any compensating steps.
808348377021 Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 12372
diff changeset
207 // 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
208
808348377021 Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 12372
diff changeset
209 oop new_obj = thread->vm_result();
808348377021 Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 12372
diff changeset
210 if (new_obj == NULL) return;
808348377021 Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 12372
diff changeset
211
808348377021 Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 12372
diff changeset
212 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
213 "compiler must check this first");
808348377021 Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 12372
diff changeset
214 // 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
215 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
216 thread->set_vm_result(new_obj);
808348377021 Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 12372
diff changeset
217 }
808348377021 Fix inconsistent oops in slow path allocation
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 12372
diff changeset
218
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
219 JRT_ENTRY(void, GraalRuntime::new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims))
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
220 assert(klass->is_klass(), "not a class");
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
221 assert(rank >= 1, "rank must be nonzero");
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
222 oop obj = ArrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
223 thread->set_vm_result(obj);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
224 JRT_END
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
225
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
226 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
227 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
228 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
229 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
230
13578
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12668
diff changeset
231 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
232 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
233
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12668
diff changeset
234 if (klass == NULL) {
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12668
diff changeset
235 ResourceMark rm(THREAD);
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12668
diff changeset
236 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
237 }
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12668
diff changeset
238
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12668
diff changeset
239 // 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
240 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
241
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12668
diff changeset
242 // 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
243 klass->initialize(CHECK);
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12668
diff changeset
244
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12668
diff changeset
245 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
246 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
247 JRT_END
d8143c431d63 Add DynamicNewInstanceNode and use it to intrinsify Unsafe.allocateInstance
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 12668
diff changeset
248
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
249 extern void vm_exit(int code);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
250
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
251 // Enter this method from compiled code handler below. This is where we transition
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
252 // to VM mode. This is done as a helper routine so that the method called directly
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
253 // from compiled code does not have to transition to VM. This allows the entry
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
254 // method to see if the nmethod that we have just looked up a handler for has
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
255 // been deoptimized while we were in the vm. This simplifies the assembly code
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
256 // cpu directories.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
257 //
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
258 // We are entering here from exception stub (via the entry method below)
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
259 // If there is a compiled exception handler in this method, we will continue there;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
260 // otherwise we will unwind the stack and continue at the caller of top frame method
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
261 // Note: we enter in Java using a special JRT wrapper. This wrapper allows us to
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
262 // control the area where we can allow a safepoint. After we exit the safepoint area we can
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
263 // check to see if the handler we are going to return is now in a nmethod that has
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
264 // been deoptimized. If that is the case we return the deopt blob
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
265 // unpack_with_exception entry instead. This makes life for the exception blob easier
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
266 // because making that same check and diverting is painful from assembly language.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
267 JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* thread, oopDesc* ex, address pc, nmethod*& nm))
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
268 // Reset method handle flag.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
269 thread->set_is_method_handle_return(false);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
270
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
271 Handle exception(thread, ex);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
272 nm = CodeCache::find_nmethod(pc);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
273 assert(nm != NULL, "this is not an nmethod");
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
274 // Adjust the pc as needed/
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
275 if (nm->is_deopt_pc(pc)) {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
276 RegisterMap map(thread, false);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
277 frame exception_frame = thread->last_frame().sender(&map);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
278 // if the frame isn't deopted then pc must not correspond to the caller of last_frame
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
279 assert(exception_frame.is_deoptimized_frame(), "must be deopted");
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
280 pc = exception_frame.pc();
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
281 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
282 #ifdef ASSERT
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
283 assert(exception.not_null(), "NULL exceptions should be handled by throw_exception");
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
284 assert(exception->is_oop(), "just checking");
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
285 // Check that exception is a subclass of Throwable, otherwise we have a VerifyError
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
286 if (!(exception->is_a(SystemDictionary::Throwable_klass()))) {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
287 if (ExitVMOnVerifyError) vm_exit(-1);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
288 ShouldNotReachHere();
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
289 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
290 #endif
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
291
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
292 // Check the stack guard pages and reenable them if necessary and there is
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
293 // enough space on the stack to do so. Use fast exceptions only if the guard
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
294 // pages are enabled.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
295 bool guard_pages_enabled = thread->stack_yellow_zone_enabled();
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
296 if (!guard_pages_enabled) guard_pages_enabled = thread->reguard_stack();
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
297
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
298 if (JvmtiExport::can_post_on_exceptions()) {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
299 // To ensure correct notification of exception catches and throws
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
300 // we have to deoptimize here. If we attempted to notify the
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
301 // catches and throws during this exception lookup it's possible
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
302 // we could deoptimize on the way out of the VM and end back in
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
303 // the interpreter at the throw site. This would result in double
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
304 // notifications since the interpreter would also notify about
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
305 // these same catches and throws as it unwound the frame.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
306
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
307 RegisterMap reg_map(thread);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
308 frame stub_frame = thread->last_frame();
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
309 frame caller_frame = stub_frame.sender(&reg_map);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
310
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
311 // We don't really want to deoptimize the nmethod itself since we
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
312 // can actually continue in the exception handler ourselves but I
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
313 // don't see an easy way to have the desired effect.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
314 Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_constraint);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
315 assert(caller_is_deopted(), "Must be deoptimized");
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
316
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
317 return SharedRuntime::deopt_blob()->unpack_with_exception_in_tls();
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
318 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
319
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
320 // ExceptionCache is used only for exceptions at call sites and not for implicit exceptions
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
321 if (guard_pages_enabled) {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
322 address fast_continuation = nm->handler_for_exception_and_pc(exception, pc);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
323 if (fast_continuation != NULL) {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
324 // Set flag if return address is a method handle call site.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
325 thread->set_is_method_handle_return(nm->is_method_handle_return(pc));
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
326 return fast_continuation;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
327 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
328 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
329
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
330 // If the stack guard pages are enabled, check whether there is a handler in
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
331 // the current method. Otherwise (guard pages disabled), force an unwind and
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
332 // skip the exception cache update (i.e., just leave continuation==NULL).
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
333 address continuation = NULL;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
334 if (guard_pages_enabled) {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
335
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
336 // New exception handling mechanism can support inlined methods
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
337 // with exception handlers since the mappings are from PC to PC
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
338
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
339 // debugging support
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
340 // tracing
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
341 if (TraceExceptions) {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
342 ttyLocker ttyl;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
343 ResourceMark rm;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
344 int offset = pc - nm->code_begin();
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
345 tty->print_cr("Exception <%s> (0x%x) thrown in compiled method <%s> at PC " PTR_FORMAT " [" PTR_FORMAT "+%d] for thread 0x%x",
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
346 exception->print_value_string(), (address)exception(), nm->method()->print_value_string(), pc, nm->code_begin(), offset, thread);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
347 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
348 // for AbortVMOnException flag
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
349 NOT_PRODUCT(Exceptions::debug_check_abort(exception));
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
350
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
351 // Clear out the exception oop and pc since looking up an
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
352 // exception handler can cause class loading, which might throw an
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
353 // exception and those fields are expected to be clear during
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
354 // normal bytecode execution.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
355 thread->set_exception_oop(NULL);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
356 thread->set_exception_pc(NULL);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
357
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
358 continuation = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, false, false);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
359 // If an exception was thrown during exception dispatch, the exception oop may have changed
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
360 thread->set_exception_oop(exception());
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
361 thread->set_exception_pc(pc);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
362
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
363 // the exception cache is used only by non-implicit exceptions
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
364 if (continuation != NULL && !SharedRuntime::deopt_blob()->contains(continuation)) {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
365 nm->add_handler_for_exception_and_pc(exception, pc, continuation);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
366 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
367 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
368
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
369 // Set flag if return address is a method handle call site.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
370 thread->set_is_method_handle_return(nm->is_method_handle_return(pc));
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
371
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
372 if (TraceExceptions) {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
373 ttyLocker ttyl;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
374 ResourceMark rm;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
375 tty->print_cr("Thread " PTR_FORMAT " continuing at PC " PTR_FORMAT " for exception thrown at PC " PTR_FORMAT,
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
376 thread, continuation, pc);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
377 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
378
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
379 return continuation;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
380 JRT_END
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
381
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
382 // Enter this method from compiled code only if there is a Java exception handler
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
383 // in the method handling the exception.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
384 // We are entering here from exception stub. We don't do a normal VM transition here.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
385 // We do it in a helper. This is so we can check to see if the nmethod we have just
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
386 // searched for an exception handler has been deoptimized in the meantime.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
387 address GraalRuntime::exception_handler_for_pc(JavaThread* thread) {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
388 oop exception = thread->exception_oop();
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
389 address pc = thread->exception_pc();
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
390 // Still in Java mode
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
391 DEBUG_ONLY(ResetNoHandleMark rnhm);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
392 nmethod* nm = NULL;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
393 address continuation = NULL;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
394 {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
395 // Enter VM mode by calling the helper
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
396 ResetNoHandleMark rnhm;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
397 continuation = exception_handler_for_pc_helper(thread, exception, pc, nm);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
398 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
399 // Back in JAVA, use no oops DON'T safepoint
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
400
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
401 // Now check to see if the nmethod we were called from is now deoptimized.
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
402 // If so we must return to the deopt blob and deoptimize the nmethod
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
403 if (nm != NULL && caller_is_deopted()) {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
404 continuation = SharedRuntime::deopt_blob()->unpack_with_exception_in_tls();
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
405 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
406
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
407 assert(continuation != NULL, "no handler found");
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
408 return continuation;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
409 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
410
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
411 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
412 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
413 thread->set_vm_result(PENDING_EXCEPTION);
e27f3169460e notify JVMTI about exception throws from runtime
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 12435
diff changeset
414 CLEAR_PENDING_EXCEPTION;
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
415 JRT_END
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
416
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
417 JRT_ENTRY(void, GraalRuntime::create_out_of_bounds_exception(JavaThread* thread, jint index))
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
418 char message[jintAsStringSize];
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
419 sprintf(message, "%d", index);
12668
e27f3169460e notify JVMTI about exception throws from runtime
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 12435
diff changeset
420 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
421 thread->set_vm_result(PENDING_EXCEPTION);
e27f3169460e notify JVMTI about exception throws from runtime
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 12435
diff changeset
422 CLEAR_PENDING_EXCEPTION;
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
423 JRT_END
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
424
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
425 JRT_ENTRY_NO_ASYNC(void, GraalRuntime::monitorenter(JavaThread* thread, oopDesc* obj, BasicLock* lock))
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
426 if (TraceGraal >= 3) {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
427 char type[O_BUFLEN];
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
428 obj->klass()->name()->as_C_string(type, O_BUFLEN);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
429 markOop mark = obj->mark();
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
430 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);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
431 tty->flush();
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
432 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
433 #ifdef ASSERT
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
434 if (PrintBiasedLockingStatistics) {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
435 Atomic::inc(BiasedLocking::slow_path_entry_count_addr());
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
436 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
437 #endif
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
438 Handle h_obj(thread, obj);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
439 assert(h_obj()->is_oop(), "must be NULL or an object");
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
440 if (UseBiasedLocking) {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
441 // Retry fast entry if bias is revoked to avoid unnecessary inflation
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
442 ObjectSynchronizer::fast_enter(h_obj, lock, true, CHECK);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
443 } else {
7226
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7222 7154
diff changeset
444 if (GraalUseFastLocking) {
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
445 // When using fast locking, the compiled code has already tried the fast case
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
446 ObjectSynchronizer::slow_enter(h_obj, lock, THREAD);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
447 } else {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
448 ObjectSynchronizer::fast_enter(h_obj, lock, false, THREAD);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
449 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
450 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
451 if (TraceGraal >= 3) {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
452 tty->print_cr("%s: exiting locking slow with obj=" INTPTR_FORMAT, thread->name(), obj);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
453 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
454 JRT_END
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
455
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
456 JRT_LEAF(void, GraalRuntime::monitorexit(JavaThread* thread, oopDesc* obj, BasicLock* lock))
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
457 assert(thread == JavaThread::current(), "threads must correspond");
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
458 assert(thread->last_Java_sp(), "last_Java_sp must be set");
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
459 // monitorexit is non-blocking (leaf routine) => no exceptions can be thrown
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
460 EXCEPTION_MARK;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
461
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
462 #ifdef DEBUG
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
463 if (!obj->is_oop()) {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
464 ResetNoHandleMark rhm;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
465 nmethod* method = thread->last_frame().cb()->as_nmethod_or_null();
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
466 if (method != NULL) {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
467 tty->print_cr("ERROR in monitorexit in method %s wrong obj " INTPTR_FORMAT, method->name(), obj);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
468 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
469 thread->print_stack_on(tty);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
470 assert(false, "invalid lock object pointer dected");
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
471 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
472 #endif
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
473
7226
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7222 7154
diff changeset
474 if (GraalUseFastLocking) {
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
475 // When using fast locking, the compiled code has already tried the fast case
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
476 ObjectSynchronizer::slow_exit(obj, lock, THREAD);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
477 } else {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
478 ObjectSynchronizer::fast_exit(obj, lock, THREAD);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
479 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
480 if (TraceGraal >= 3) {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
481 char type[O_BUFLEN];
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
482 obj->klass()->name()->as_C_string(type, O_BUFLEN);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
483 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);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
484 tty->flush();
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
485 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
486 JRT_END
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
487
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
488 JRT_ENTRY(void, GraalRuntime::log_object(JavaThread* thread, oopDesc* obj, jint flags))
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
489 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
490 bool addr = mask_bits_are_true(flags, LOG_OBJECT_ADDRESS);
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
491 bool newline = mask_bits_are_true(flags, LOG_OBJECT_NEWLINE);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
492 if (!string) {
12356
359f7e70ae7f Reduce HotSpot diff and fix previous merge
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10953
diff changeset
493 if (!addr && obj->is_oop_or_null(true)) {
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
494 char buf[O_BUFLEN];
12356
359f7e70ae7f Reduce HotSpot diff and fix previous merge
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10953
diff changeset
495 tty->print("%s@%p", obj->klass()->name()->as_C_string(buf, O_BUFLEN), (address)obj);
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
496 } else {
12356
359f7e70ae7f Reduce HotSpot diff and fix previous merge
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10953
diff changeset
497 tty->print("%p", (address)obj);
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
498 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
499 } else {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
500 ResourceMark rm;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
501 assert(obj != NULL && java_lang_String::is_instance(obj), "must be");
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
502 char *buf = java_lang_String::as_utf8_string(obj);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
503 tty->print(buf);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
504 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
505 if (newline) {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
506 tty->cr();
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
507 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
508 JRT_END
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
509
10434
8b22524df53b Add G1 Barriers' foreign calls
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10072
diff changeset
510 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
511 thread->satb_mark_queue().enqueue(obj);
8b22524df53b Add G1 Barriers' foreign calls
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10072
diff changeset
512 JRT_END
8b22524df53b Add G1 Barriers' foreign calls
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10072
diff changeset
513
8b22524df53b Add G1 Barriers' foreign calls
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10072
diff changeset
514 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
515 thread->dirty_card_queue().enqueue(card_addr);
8b22524df53b Add G1 Barriers' foreign calls
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10072
diff changeset
516 JRT_END
8b22524df53b Add G1 Barriers' foreign calls
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10072
diff changeset
517
12356
359f7e70ae7f Reduce HotSpot diff and fix previous merge
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 10953
diff changeset
518 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
519 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
520 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
521 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
522 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
523 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
524 }
97e282186b5b Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10542
diff changeset
525 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
526 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
527 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
528 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
529 }
97e282186b5b Add heap sanity checker with premature hard crash for debugging write barriers
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 10542
diff changeset
530 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
531 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
532
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
533 JRT_ENTRY(void, GraalRuntime::vm_error(JavaThread* thread, jlong where, jlong format, jlong value))
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
534 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
535 const char *error_msg = where == 0L ? "<internal Graal error>" : (char*) (address) where;
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
536 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
537 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
538 const char* buf = (char*) (address) format;
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
539 size_t detail_msg_length = strlen(buf) * 2;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
540 detail_msg = (char *) NEW_RESOURCE_ARRAY(u_char, detail_msg_length);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
541 jio_snprintf(detail_msg, detail_msg_length, buf, value);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
542 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
543 report_vm_error(__FILE__, __LINE__, error_msg, detail_msg);
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
544 JRT_END
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
545
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
546 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
547 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
548 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
549 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
550 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
551 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
552 JRT_END
8506
c3657d00e343 -Merge with tip
Christos Kotselidis <christos.kotselidis@oracle.com>
parents: 8504 8127
diff changeset
553
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
554 JRT_LEAF(void, GraalRuntime::log_printf(JavaThread* thread, oopDesc* format, jlong v1, jlong v2, jlong v3))
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
555 ResourceMark rm;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
556 assert(format != NULL && java_lang_String::is_instance(format), "must be");
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
557 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
558 tty->print(buf, v1, v2, v3);
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
559 JRT_END
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
560
9573
a79e8020ad4b added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents: 9565
diff changeset
561 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
562 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
563 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
564 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
565 if (cb) {
a79e8020ad4b added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents: 9565
diff changeset
566 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
567 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
568 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
569 return;
a79e8020ad4b added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents: 9565
diff changeset
570 }
a79e8020ad4b added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents: 9565
diff changeset
571 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
572 return;
a79e8020ad4b added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents: 9565
diff changeset
573 }
a79e8020ad4b added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents: 9565
diff changeset
574 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
575 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
576 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
577 return;
a79e8020ad4b added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents: 9565
diff changeset
578 }
a79e8020ad4b added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents: 9565
diff changeset
579 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
580 }
a79e8020ad4b added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents: 9565
diff changeset
581 }
a79e8020ad4b added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents: 9565
diff changeset
582
9471
5fa54bf57f8c replaced exception_handler_nofpu assembler stub with a compiled stub (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 9457
diff changeset
583 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
584 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
585 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
586 if (vmError) {
9573
a79e8020ad4b added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents: 9565
diff changeset
587 if (buf != NULL) {
a79e8020ad4b added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents: 9565
diff changeset
588 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
589 } else {
a79e8020ad4b added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents: 9565
diff changeset
590 fatal("<anonymous error>");
a79e8020ad4b added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents: 9565
diff changeset
591 }
a79e8020ad4b added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents: 9565
diff changeset
592 } 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
593 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
594 } else {
9573
a79e8020ad4b added Stub.decipher() to print information about values in stubs
Doug Simon <doug.simon@oracle.com>
parents: 9565
diff changeset
595 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
596 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
597 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
598 }
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
599 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
600
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
601 JRT_ENTRY(void, GraalRuntime::log_primitive(JavaThread* thread, jchar typeChar, jlong value, jboolean newline))
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
602 union {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
603 jlong l;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
604 jdouble d;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
605 jfloat f;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
606 } uu;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
607 uu.l = value;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
608 switch (typeChar) {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
609 case 'z': tty->print(value == 0 ? "false" : "true"); break;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
610 case 'b': tty->print("%d", (jbyte) value); break;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
611 case 'c': tty->print("%c", (jchar) value); break;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
612 case 's': tty->print("%d", (jshort) value); break;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
613 case 'i': tty->print("%d", (jint) value); break;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
614 case 'f': tty->print("%f", uu.f); break;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
615 case 'j': tty->print(INT64_FORMAT, value); break;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
616 case 'd': tty->print("%lf", uu.d); break;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
617 default: assert(false, "unknown typeChar"); break;
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
618 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
619 if (newline) {
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
620 tty->cr();
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
621 }
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
622 JRT_END
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
623
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
624 JRT_ENTRY(jint, GraalRuntime::identity_hash_code(JavaThread* thread, oopDesc* obj))
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
625 return (jint) obj->identity_hash();
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
626 JRT_END
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
627
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
628 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
629 // 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
630 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
631 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
632 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
633 if (receiverThread == NULL) {
682fba1bcf95 add missing null check in is_interrupted
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13578
diff changeset
634 // 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
635 return JNI_FALSE;
682fba1bcf95 add missing null check in is_interrupted
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13578
diff changeset
636 } else {
682fba1bcf95 add missing null check in is_interrupted
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 13578
diff changeset
637 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
638 }
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
639 JRT_END
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
640
15603
b7fb36e57da8 made Graal initialization be driven from Java to simplify sequencing and synchronization
Doug Simon <doug.simon@oracle.com>
parents: 15589
diff changeset
641 // private static GraalRuntime Graal.initializeRuntime()
b7fb36e57da8 made Graal initialization be driven from Java to simplify sequencing and synchronization
Doug Simon <doug.simon@oracle.com>
parents: 15589
diff changeset
642 JVM_ENTRY(jobject, JVM_GetGraalRuntime(JNIEnv *env, jclass c))
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
643 return GraalRuntime::get_HotSpotGraalRuntime_jobject();
7221
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7220 7145
diff changeset
644 JVM_END
10475
3489047ffea2 Restructure the handling of HotSpotInstalledCode and their link to nmethods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10434
diff changeset
645
15916
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents: 15894
diff changeset
646 // private static String[] Graal.getServiceImpls(Class service)
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents: 15894
diff changeset
647 JVM_ENTRY(jobject, JVM_GetGraalServiceImpls(JNIEnv *env, jclass c, jclass serviceClass))
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents: 15894
diff changeset
648 HandleMark hm;
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents: 15894
diff changeset
649 KlassHandle serviceKlass(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(serviceClass)));
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents: 15894
diff changeset
650 return JNIHandles::make_local(THREAD, GraalRuntime::get_service_impls(serviceKlass, THREAD)());
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents: 15894
diff changeset
651 JVM_END
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents: 15894
diff changeset
652
15603
b7fb36e57da8 made Graal initialization be driven from Java to simplify sequencing and synchronization
Doug Simon <doug.simon@oracle.com>
parents: 15589
diff changeset
653 // private static TruffleRuntime Truffle.createRuntime()
b7fb36e57da8 made Graal initialization be driven from Java to simplify sequencing and synchronization
Doug Simon <doug.simon@oracle.com>
parents: 15589
diff changeset
654 JVM_ENTRY(jobject, JVM_CreateTruffleRuntime(JNIEnv *env, jclass c))
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
655 TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime", THREAD);
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
656 KlassHandle klass = GraalRuntime::load_required_class(name);
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
657
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
658 TempNewSymbol makeInstance = SymbolTable::new_symbol("makeInstance", THREAD);
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
659 TempNewSymbol sig = SymbolTable::new_symbol("()Lcom/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime;", THREAD);
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
660 JavaValue result(T_OBJECT);
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
661 JavaCalls::call_static(&result, klass, makeInstance, sig, THREAD);
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
662 GUARANTEE_NO_PENDING_EXCEPTION("Couldn't initialize HotSpotTruffleRuntime");
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
663 return JNIHandles::make_local((oop) result.get_jobject());
10475
3489047ffea2 Restructure the handling of HotSpotInstalledCode and their link to nmethods.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 10434
diff changeset
664 JVM_END
15603
b7fb36e57da8 made Graal initialization be driven from Java to simplify sequencing and synchronization
Doug Simon <doug.simon@oracle.com>
parents: 15589
diff changeset
665
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
666 Handle GraalRuntime::get_HotSpotGraalRuntime() {
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
667 if (JNIHandles::resolve(_HotSpotGraalRuntime_instance) == NULL) {
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
668 Thread* THREAD = Thread::current();
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
669 TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/HotSpotGraalRuntime", THREAD);
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
670 KlassHandle klass = load_required_class(name);
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
671 TempNewSymbol runtime = SymbolTable::new_symbol("runtime", THREAD);
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
672 TempNewSymbol sig = SymbolTable::new_symbol("()Lcom/oracle/graal/hotspot/HotSpotGraalRuntime;", THREAD);
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
673 JavaValue result(T_OBJECT);
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
674 JavaCalls::call_static(&result, klass, runtime, sig, THREAD);
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
675 GUARANTEE_NO_PENDING_EXCEPTION("Couldn't initialize HotSpotGraalRuntime");
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
676 _HotSpotGraalRuntime_instance = JNIHandles::make_global((oop) result.get_jobject());
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
677 }
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
678 return Handle(JNIHandles::resolve_non_null(_HotSpotGraalRuntime_instance));
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
679 }
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
680
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
681 // private static void CompilerToVMImpl.init()
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
682 JVM_ENTRY(void, JVM_InitializeGraalNatives(JNIEnv *env, jclass c2vmClass))
15603
b7fb36e57da8 made Graal initialization be driven from Java to simplify sequencing and synchronization
Doug Simon <doug.simon@oracle.com>
parents: 15589
diff changeset
683 GraalRuntime::initialize_natives(env, c2vmClass);
b7fb36e57da8 made Graal initialization be driven from Java to simplify sequencing and synchronization
Doug Simon <doug.simon@oracle.com>
parents: 15589
diff changeset
684 JVM_END
b7fb36e57da8 made Graal initialization be driven from Java to simplify sequencing and synchronization
Doug Simon <doug.simon@oracle.com>
parents: 15589
diff changeset
685
15870
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
686 // private static boolean HotSpotOptions.parseVMOptions()
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
687 JVM_ENTRY(jboolean, JVM_ParseGraalOptions(JNIEnv *env, jclass c))
15603
b7fb36e57da8 made Graal initialization be driven from Java to simplify sequencing and synchronization
Doug Simon <doug.simon@oracle.com>
parents: 15589
diff changeset
688 HandleMark hm;
15870
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
689 KlassHandle hotSpotOptionsClass(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(c)));
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
690 return GraalRuntime::parse_arguments(hotSpotOptionsClass, CHECK_false);
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
691 JVM_END
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
692
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
693 #ifdef COMPILERGRAAL
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
694 // private static boolean CompilationQueue.printAndResetCompRate()
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
695 JVM_ENTRY(void, JVM_PrintAndResetGraalCompRate(JNIEnv *env, jclass c))
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
696 GraalCompiler* comp = GraalCompiler::instance();
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
697 CompileBroker::print_times(comp);
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
698 CompilerStatistics* stats = comp->stats();
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
699 stats->_standard.reset();
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
700 stats->_osr.reset();
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
701 JVM_END
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
702 #endif
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
703
16270
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
704 jint GraalRuntime::check_arguments(TRAPS) {
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
705 KlassHandle nullHandle;
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
706 parse_arguments(nullHandle, THREAD);
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
707 if (HAS_PENDING_EXCEPTION) {
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
708 // Errors in parsing Graal arguments cause exceptions.
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
709 // We now load and initialize HotSpotOptions which in turn
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
710 // causes argument parsing to be redone with better error messages.
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
711 CLEAR_PENDING_EXCEPTION;
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
712 TempNewSymbol name = SymbolTable::new_symbol("Lcom/oracle/graal/hotspot/HotSpotOptions;", THREAD);
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
713 instanceKlassHandle hotSpotOptionsClass = SystemDictionary::resolve_or_fail(name, true, THREAD);
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
714 GUARANTEE_NO_PENDING_EXCEPTION("Error in check_arguments");
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
715
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
716 parse_arguments(hotSpotOptionsClass, THREAD);
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
717 assert(HAS_PENDING_EXCEPTION, "must be");
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
718
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
719 ResourceMark rm;
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
720 oop message = java_lang_Throwable::message(PENDING_EXCEPTION);
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
721 assert(message != NULL, "Graal argument parsing exception is expected to hava message");
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
722 tty->print_cr("Error parsing Graal options: %s", java_lang_String::as_utf8_string(message));
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
723 CLEAR_PENDING_EXCEPTION;
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
724 return JNI_ERR;
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
725 }
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
726 return JNI_OK;
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
727 }
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
728
15870
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
729 bool GraalRuntime::parse_arguments(KlassHandle hotSpotOptionsClass, TRAPS) {
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
730 ResourceMark rm(THREAD);
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
731
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
732 // Process option overrides from graal.options first
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
733 parse_graal_options_file(hotSpotOptionsClass, CHECK_false);
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
734
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
735 // Now process options on the command line
15603
b7fb36e57da8 made Graal initialization be driven from Java to simplify sequencing and synchronization
Doug Simon <doug.simon@oracle.com>
parents: 15589
diff changeset
736 int numOptions = Arguments::num_graal_args();
b7fb36e57da8 made Graal initialization be driven from Java to simplify sequencing and synchronization
Doug Simon <doug.simon@oracle.com>
parents: 15589
diff changeset
737 for (int i = 0; i < numOptions; i++) {
15870
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
738 char* arg = Arguments::graal_args_array()[i];
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
739 parse_argument(hotSpotOptionsClass, arg, CHECK_false);
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
740 }
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
741 return CITime || CITimeEach;
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
742 }
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
743
16270
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
744 void GraalRuntime::check_required_value(const char* name, int name_len, const char* value, TRAPS) {
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
745 if (value == NULL) {
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
746 char buf[200];
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
747 jio_snprintf(buf, sizeof(buf), "Value for option %.*s must use '-G:%.*s=<value>' format", name_len, name, name_len, name);
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
748 THROW_MSG(vmSymbols::java_lang_InternalError(), buf);
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
749 }
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
750 }
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
751
15870
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
752 void GraalRuntime::parse_argument(KlassHandle hotSpotOptionsClass, char* arg, TRAPS) {
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
753 char first = arg[0];
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
754 char* name;
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
755 size_t name_len;
16270
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
756 bool recognized = true;
15870
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
757 if (first == '+' || first == '-') {
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
758 name = arg + 1;
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
759 name_len = strlen(name);
16270
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
760 recognized = set_option(hotSpotOptionsClass, name, (int)name_len, arg, CHECK);
15870
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
761 } else {
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
762 char* sep = strchr(arg, '=');
16270
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
763 name = arg;
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
764 char* value = NULL;
15870
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
765 if (sep != NULL) {
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
766 name_len = sep - name;
16270
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
767 value = sep + 1;
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
768 } else {
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
769 name_len = strlen(name);
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
770 }
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
771 recognized = set_option(hotSpotOptionsClass, name, (int)name_len, value, CHECK);
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
772 }
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
773
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
774 if (!recognized) {
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
775 bool throw_err = hotSpotOptionsClass.is_null();
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
776 if (!hotSpotOptionsClass.is_null()) {
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
777 instanceKlassHandle ikh(hotSpotOptionsClass());
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
778 if (!ikh->is_reentrant_initialization(THREAD)) {
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
779 set_option_helper(hotSpotOptionsClass, name, name_len, Handle(), ' ', Handle(), 0L);
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
780 throw_err = true;
15870
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
781 }
16270
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
782 }
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
783
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
784 if (throw_err) {
15870
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
785 char buf[200];
16270
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
786 jio_snprintf(buf, sizeof(buf), "Unrecognized Graal option %.*s", name_len, name);
15870
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
787 THROW_MSG(vmSymbols::java_lang_InternalError(), buf);
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
788 }
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
789 }
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
790 }
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
791
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
792 void GraalRuntime::parse_graal_options_file(KlassHandle hotSpotOptionsClass, TRAPS) {
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
793 const char* home = Arguments::get_java_home();
15894
a9810ed7cad2 explicit conversion to int, fixes windows build
Christian Wirth <christian.wirth@oracle.com>
parents: 15870
diff changeset
794 int path_len = (int)strlen(home) + (int)strlen("/lib/graal.options") + 1;
15870
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
795 char* path = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, path_len);
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
796 char sep = os::file_separator()[0];
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
797 sprintf(path, "%s%clib%cgraal.options", home, sep, sep);
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
798
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
799 struct stat st;
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
800 if (os::stat(path, &st) == 0) {
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
801 int file_handle = os::open(path, 0, 0);
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
802 if (file_handle != -1) {
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
803 char* buffer = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, st.st_size);
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
804 int num_read = (int) os::read(file_handle, (char*) buffer, st.st_size);
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
805 if (num_read == -1) {
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
806 warning("Error reading file %s due to %s", path, strerror(errno));
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
807 } else if (num_read != st.st_size) {
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
808 warning("Only read %d of %d bytes from %s", num_read, st.st_size, path);
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
809 }
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
810 os::close(file_handle);
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
811 if (num_read == st.st_size) {
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
812 char* line = buffer;
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
813 int lineNo = 1;
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
814 while (line - buffer < num_read) {
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
815 char* nl = strchr(line, '\n');
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
816 if (nl != NULL) {
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
817 *nl = '\0';
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
818 }
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
819 parse_argument(hotSpotOptionsClass, line, THREAD);
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
820 if (HAS_PENDING_EXCEPTION) {
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
821 warning("Error in %s:%d", path, lineNo);
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
822 return;
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
823 }
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
824 if (nl != NULL) {
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
825 line = nl + 1;
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
826 lineNo++;
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
827 } else {
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
828 // File without newline at the end
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
829 break;
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
830 }
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
831 }
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
832 }
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
833 } else {
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
834 warning("Error opening file %s due to %s", path, strerror(errno));
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
835 }
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
836 }
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
837 }
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
838
16270
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
839 jlong GraalRuntime::parse_primitive_option_value(char spec, const char* name, int name_len, const char* value, TRAPS) {
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
840 check_required_value(name, name_len, value, CHECK_(0L));
15870
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
841 union {
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
842 jint i;
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
843 jlong l;
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
844 double d;
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
845 } uu;
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
846 uu.l = 0L;
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
847 char dummy;
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
848 switch (spec) {
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
849 case 'd':
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
850 case 'f': {
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
851 if (sscanf(value, "%lf%c", &uu.d, &dummy) == 1) {
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
852 return uu.l;
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
853 }
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
854 break;
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
855 }
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
856 case 'i': {
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
857 if (sscanf(value, "%d%c", &uu.i, &dummy) == 1) {
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
858 return uu.l;
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
859 }
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
860 break;
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
861 }
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
862 default:
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
863 ShouldNotReachHere();
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
864 }
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
865 ResourceMark rm(THREAD);
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
866 char buf[200];
16270
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
867 jio_snprintf(buf, sizeof(buf), "Invalid %s value for Graal option %.*s: %s", (spec == 'i' ? "numeric" : "float/double"), name, name_len, value);
15870
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
868 THROW_MSG_(vmSymbols::java_lang_InternalError(), buf, 0L);
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
869 }
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
870
16270
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
871 void GraalRuntime::set_option_helper(KlassHandle hotSpotOptionsClass, char* name, int name_len, Handle option, jchar spec, Handle stringValue, jlong primitiveValue) {
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
872 Thread* THREAD = Thread::current();
16270
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
873 Handle name_handle;
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
874 if (name != NULL) {
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
875 if ((int) strlen(name) > name_len) {
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
876 // Temporarily replace '=' with NULL to create the Java string for the option name
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
877 char save = name[name_len];
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
878 name[name_len] = '\0';
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
879 name_handle = java_lang_String::create_from_str(name, THREAD);
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
880 name[name_len] = '=';
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
881 if (HAS_PENDING_EXCEPTION) {
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
882 return;
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
883 }
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
884 } else {
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
885 assert((int) strlen(name) == name_len, "must be");
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
886 name_handle = java_lang_String::create_from_str(name, CHECK);
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
887 }
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
888 }
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
889
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
890 TempNewSymbol setOption = SymbolTable::new_symbol("setOption", THREAD);
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
891 TempNewSymbol sig = SymbolTable::new_symbol("(Ljava/lang/String;Lcom/oracle/graal/options/OptionValue;CLjava/lang/String;J)V", THREAD);
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
892 JavaValue result(T_VOID);
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
893 JavaCallArguments args;
16270
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
894 args.push_oop(name_handle());
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
895 args.push_oop(option());
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
896 args.push_int(spec);
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
897 args.push_oop(stringValue());
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
898 args.push_long(primitiveValue);
16270
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
899 JavaCalls::call_static(&result, hotSpotOptionsClass, setOption, sig, &args, CHECK);
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
900 }
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
901
15870
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
902 Handle GraalRuntime::get_OptionValue(const char* declaringClass, const char* fieldName, const char* fieldSig, TRAPS) {
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
903 TempNewSymbol name = SymbolTable::new_symbol(declaringClass, THREAD);
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
904 Klass* klass = SystemDictionary::resolve_or_fail(name, true, CHECK_NH);
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
905
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
906 // The class has been loaded so the field and signature should already be in the symbol
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
907 // table. If they're not there, the field doesn't exist.
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
908 TempNewSymbol fieldname = SymbolTable::probe(fieldName, (int)strlen(fieldName));
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
909 TempNewSymbol signame = SymbolTable::probe(fieldSig, (int)strlen(fieldSig));
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
910 if (fieldname == NULL || signame == NULL) {
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
911 THROW_MSG_(vmSymbols::java_lang_NoSuchFieldError(), (char*) fieldName, Handle());
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
912 }
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
913 // Make sure class is initialized before handing id's out to fields
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
914 klass->initialize(CHECK_NH);
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
915
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
916 fieldDescriptor fd;
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
917 if (!InstanceKlass::cast(klass)->find_field(fieldname, signame, true, &fd)) {
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
918 THROW_MSG_(vmSymbols::java_lang_NoSuchFieldError(), (char*) fieldName, Handle());
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
919 }
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
920
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
921 Handle ret = klass->java_mirror()->obj_field(fd.offset());
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
922 return ret;
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
923 }
fe608a56e3f7 made HotSpotOptions processing faster by removing use of service loader in VM startup and only doing work for options specified on the command line
Doug Simon <doug.simon@oracle.com>
parents: 15603
diff changeset
924
15916
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents: 15894
diff changeset
925 Handle GraalRuntime::create_Service(const char* name, TRAPS) {
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents: 15894
diff changeset
926 TempNewSymbol kname = SymbolTable::new_symbol(name, THREAD);
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents: 15894
diff changeset
927 Klass* k = SystemDictionary::resolve_or_fail(kname, true, CHECK_NH);
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents: 15894
diff changeset
928 instanceKlassHandle klass(THREAD, k);
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents: 15894
diff changeset
929 klass->initialize(CHECK_NH);
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents: 15894
diff changeset
930 klass->check_valid_for_instantiation(true, CHECK_NH);
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents: 15894
diff changeset
931 JavaValue result(T_VOID);
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents: 15894
diff changeset
932 instanceHandle service = klass->allocate_instance_handle(CHECK_NH);
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents: 15894
diff changeset
933 JavaCalls::call_special(&result, service, klass, vmSymbols::object_initializer_name(), vmSymbols::void_method_signature(), THREAD);
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents: 15894
diff changeset
934 return service;
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents: 15894
diff changeset
935 }
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents: 15894
diff changeset
936
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
937 void GraalRuntime::shutdown() {
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
938 if (_HotSpotGraalRuntime_instance != NULL) {
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
939 JavaThread* THREAD = JavaThread::current();
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
940 HandleMark hm(THREAD);
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
941 TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/HotSpotGraalRuntime", THREAD);
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
942 KlassHandle klass = load_required_class(name);
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
943 JavaValue result(T_VOID);
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
944 JavaCallArguments args;
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
945 args.push_oop(get_HotSpotGraalRuntime());
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
946 JavaCalls::call_special(&result, klass, vmSymbols::shutdown_method_name(), vmSymbols::void_method_signature(), &args, THREAD);
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
947 GUARANTEE_NO_PENDING_EXCEPTION("Error while calling shutdown");
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
948
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
949 JNIHandles::destroy_global(_HotSpotGraalRuntime_instance);
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
950 _HotSpotGraalRuntime_instance = NULL;
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
951 }
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
952 }
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
953
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
954 void GraalRuntime::abort_on_pending_exception(Handle exception, const char* message, bool dump_core) {
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
955 Thread* THREAD = Thread::current();
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
956 CLEAR_PENDING_EXCEPTION;
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
957
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
958 assert(exception->is_a(SystemDictionary::Throwable_klass()), "Throwable instance expected");
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
959 JavaValue result(T_VOID);
16270
d56a09df1a1f implemented eager checking of Graal options (GRAAL-807)
Doug Simon <doug.simon@oracle.com>
parents: 16006
diff changeset
960 tty->print_cr(message);
16006
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
961 JavaCalls::call_virtual(&result,
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
962 exception,
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
963 KlassHandle(THREAD,
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
964 SystemDictionary::Throwable_klass()),
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
965 vmSymbols::printStackTrace_name(),
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
966 vmSymbols::void_method_signature(),
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
967 THREAD);
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
968
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
969 vm_abort(dump_core);
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
970 }
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
971
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
972 Klass* GraalRuntime::load_required_class(Symbol* name) {
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
973 Klass* klass = SystemDictionary::resolve_or_null(name, SystemDictionary::java_system_loader(), Handle(), Thread::current());
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
974 if (klass == NULL) {
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
975 tty->print_cr("Could not load class %s", name->as_C_string());
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
976 vm_abort(false);
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
977 }
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
978 return klass;
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
979 }
66a9286203a2 decoupled Graal runtime initialization and Graal compilation queue initialization
Doug Simon <doug.simon@oracle.com>
parents: 15916
diff changeset
980
15916
6aa352b260f4 removed use of ServiceLoader in runtime initialization
Doug Simon <doug.simon@oracle.com>
parents: 15894
diff changeset
981 #include "graalRuntime.inline.hpp"