annotate src/share/vm/jvmci/jvmciRuntime.cpp @ 23392:b3a816d3b844

Backed out changeset: a920338dd4d4
author Doug Simon <doug.simon@oracle.com>
date Thu, 12 May 2016 11:06:49 +0200
parents a920338dd4d4
children 1d4ce2d19e52
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1 /*
23322
f8178417d018 Expose SharedRuntime::throw_and_post_jvmti_exception to JVMCI compilers.
Roland Schatz <roland.schatz@oracle.com>
parents: 23319
diff changeset
2 * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
4 *
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
7 * published by the Free Software Foundation.
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
8 *
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
13 * accompanied this code).
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
14 *
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
15 * You should have received a copy of the GNU General Public License version
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
18 *
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
21 * questions.
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
22 */
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
23
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
24 #include "precompiled.hpp"
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
25 #include "asm/codeBuffer.hpp"
22517
0915f5bfdfaa Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22515
diff changeset
26 #include "code/codeCache.hpp"
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
27 #include "compiler/compileBroker.hpp"
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
28 #include "compiler/disassembler.hpp"
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
29 #include "jvmci/jvmciRuntime.hpp"
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
30 #include "jvmci/jvmciCompilerToVM.hpp"
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
31 #include "jvmci/jvmciCompiler.hpp"
22548
02fc27dc1da7 Rename jvmciJavaAccess.* to jvmciJavaClasses.*
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22547
diff changeset
32 #include "jvmci/jvmciJavaClasses.hpp"
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
33 #include "jvmci/jvmciEnv.hpp"
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
34 #include "memory/oopFactory.hpp"
22517
0915f5bfdfaa Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22515
diff changeset
35 #include "oops/oop.inline.hpp"
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
36 #include "prims/jvm.h"
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
37 #include "runtime/biasedLocking.hpp"
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
38 #include "runtime/interfaceSupport.hpp"
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
39 #include "runtime/reflection.hpp"
22517
0915f5bfdfaa Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22515
diff changeset
40 #include "runtime/sharedRuntime.hpp"
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
41 #include "utilities/debug.hpp"
21519
cecb4e39521c Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21516
diff changeset
42 #include "utilities/defaultStream.hpp"
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
43
21587
59c3f921e454 fixes for windows build (size_t conversion, missing precompiled.hpp, missing strtof, strtoll in Windows SDK)
Christian Wirth <christian.wirth@oracle.com>
parents: 21564
diff changeset
44 #if defined(_MSC_VER)
59c3f921e454 fixes for windows build (size_t conversion, missing precompiled.hpp, missing strtof, strtoll in Windows SDK)
Christian Wirth <christian.wirth@oracle.com>
parents: 21564
diff changeset
45 #define strtoll _strtoi64
59c3f921e454 fixes for windows build (size_t conversion, missing precompiled.hpp, missing strtof, strtoll in Windows SDK)
Christian Wirth <christian.wirth@oracle.com>
parents: 21564
diff changeset
46 #endif
59c3f921e454 fixes for windows build (size_t conversion, missing precompiled.hpp, missing strtof, strtoll in Windows SDK)
Christian Wirth <christian.wirth@oracle.com>
parents: 21564
diff changeset
47
59c3f921e454 fixes for windows build (size_t conversion, missing precompiled.hpp, missing strtof, strtoll in Windows SDK)
Christian Wirth <christian.wirth@oracle.com>
parents: 21564
diff changeset
48 jobject JVMCIRuntime::_HotSpotJVMCIRuntime_instance = NULL;
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
49 bool JVMCIRuntime::_HotSpotJVMCIRuntime_initialized = false;
22575
569c82ebb96e Replace JVMCICompileWithC1Only with package based controls
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22574
diff changeset
50 int JVMCIRuntime::_trivial_prefixes_count = 0;
569c82ebb96e Replace JVMCICompileWithC1Only with package based controls
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22574
diff changeset
51 char** JVMCIRuntime::_trivial_prefixes = NULL;
23379
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
52 JVMCIRuntime::CompLevelAdjustment JVMCIRuntime::_comp_level_adjustment = JVMCIRuntime::none;
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
53 bool JVMCIRuntime::_shutdown_called = false;
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
54
22722
0229a2ca608b Make kindToBasicType trapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 22711
diff changeset
55 BasicType JVMCIRuntime::kindToBasicType(jchar ch, TRAPS) {
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
56 switch(ch) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
57 case 'z': return T_BOOLEAN;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
58 case 'b': return T_BYTE;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
59 case 's': return T_SHORT;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
60 case 'c': return T_CHAR;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
61 case 'i': return T_INT;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
62 case 'f': return T_FLOAT;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
63 case 'j': return T_LONG;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
64 case 'd': return T_DOUBLE;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
65 case 'a': return T_OBJECT;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
66 case '-': return T_ILLEGAL;
22722
0229a2ca608b Make kindToBasicType trapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 22711
diff changeset
67 default:
0229a2ca608b Make kindToBasicType trapping.
Roland Schatz <roland.schatz@oracle.com>
parents: 22711
diff changeset
68 JVMCI_ERROR_(T_ILLEGAL, "unexpected Kind: %c", ch);
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
69 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
70 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
71
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
72 // Simple helper to see if the caller of a runtime stub which
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
73 // entered the VM has been deoptimized
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
74
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
75 static bool caller_is_deopted() {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
76 JavaThread* thread = JavaThread::current();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
77 RegisterMap reg_map(thread, false);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
78 frame runtime_frame = thread->last_frame();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
79 frame caller_frame = runtime_frame.sender(&reg_map);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
80 assert(caller_frame.is_compiled_frame(), "must be compiled");
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
81 return caller_frame.is_deoptimized_frame();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
82 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
83
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
84 // Stress deoptimization
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
85 static void deopt_caller() {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
86 if ( !caller_is_deopted()) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
87 JavaThread* thread = JavaThread::current();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
88 RegisterMap reg_map(thread, false);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
89 frame runtime_frame = thread->last_frame();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
90 frame caller_frame = runtime_frame.sender(&reg_map);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
91 Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_constraint);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
92 assert(caller_is_deopted(), "Must be deoptimized");
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
93 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
94 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
95
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
96 JRT_BLOCK_ENTRY(void, JVMCIRuntime::new_instance(JavaThread* thread, Klass* klass))
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
97 JRT_BLOCK;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
98 assert(klass->is_klass(), "not a class");
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
99 instanceKlassHandle h(thread, klass);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
100 h->check_valid_for_instantiation(true, CHECK);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
101 // make sure klass is initialized
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
102 h->initialize(CHECK);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
103 // allocate instance and return via TLS
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
104 oop obj = h->allocate_instance(CHECK);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
105 thread->set_vm_result(obj);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
106 JRT_BLOCK_END;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
107
22447
ecbf949a9dcd replace JVMCIDeferredInitBarriers with ReduceInitialCardMarks
Doug Simon <doug.simon@oracle.com>
parents: 22438
diff changeset
108 if (ReduceInitialCardMarks) {
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
109 new_store_pre_barrier(thread);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
110 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
111 JRT_END
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
112
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
113 JRT_BLOCK_ENTRY(void, JVMCIRuntime::new_array(JavaThread* thread, Klass* array_klass, jint length))
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
114 JRT_BLOCK;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
115 // Note: no handle for klass needed since they are not used
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
116 // anymore after new_objArray() and no GC can happen before.
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
117 // (This may have to change if this code changes!)
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
118 assert(array_klass->is_klass(), "not a class");
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
119 oop obj;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
120 if (array_klass->oop_is_typeArray()) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
121 BasicType elt_type = TypeArrayKlass::cast(array_klass)->element_type();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
122 obj = oopFactory::new_typeArray(elt_type, length, CHECK);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
123 } else {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
124 Klass* elem_klass = ObjArrayKlass::cast(array_klass)->element_klass();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
125 obj = oopFactory::new_objArray(elem_klass, length, CHECK);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
126 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
127 thread->set_vm_result(obj);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
128 // This is pretty rare but this runtime patch is stressful to deoptimization
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
129 // if we deoptimize here so force a deopt to stress the path.
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
130 if (DeoptimizeALot) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
131 static int deopts = 0;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
132 // Alternate between deoptimizing and raising an error (which will also cause a deopt)
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
133 if (deopts++ % 2 == 0) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
134 ResourceMark rm(THREAD);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
135 THROW(vmSymbols::java_lang_OutOfMemoryError());
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
136 } else {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
137 deopt_caller();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
138 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
139 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
140 JRT_BLOCK_END;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
141
22447
ecbf949a9dcd replace JVMCIDeferredInitBarriers with ReduceInitialCardMarks
Doug Simon <doug.simon@oracle.com>
parents: 22438
diff changeset
142 if (ReduceInitialCardMarks) {
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
143 new_store_pre_barrier(thread);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
144 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
145 JRT_END
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
146
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
147 void JVMCIRuntime::new_store_pre_barrier(JavaThread* thread) {
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
148 // After any safepoint, just before going back to compiled code,
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
149 // we inform the GC that we will be doing initializing writes to
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
150 // this object in the future without emitting card-marks, so
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
151 // GC may take any compensating steps.
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
152 // NOTE: Keep this code consistent with GraphKit::store_barrier.
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
153
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
154 oop new_obj = thread->vm_result();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
155 if (new_obj == NULL) return;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
156
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
157 assert(Universe::heap()->can_elide_tlab_store_barriers(),
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
158 "compiler must check this first");
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
159 // GC may decide to give back a safer copy of new_obj.
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
160 new_obj = Universe::heap()->new_store_pre_barrier(thread, new_obj);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
161 thread->set_vm_result(new_obj);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
162 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
163
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
164 JRT_ENTRY(void, JVMCIRuntime::new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims))
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
165 assert(klass->is_klass(), "not a class");
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
166 assert(rank >= 1, "rank must be nonzero");
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
167 oop obj = ArrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
168 thread->set_vm_result(obj);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
169 JRT_END
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
170
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
171 JRT_ENTRY(void, JVMCIRuntime::dynamic_new_array(JavaThread* thread, oopDesc* element_mirror, jint length))
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
172 oop obj = Reflection::reflect_new_array(element_mirror, length, CHECK);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
173 thread->set_vm_result(obj);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
174 JRT_END
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
175
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
176 JRT_ENTRY(void, JVMCIRuntime::dynamic_new_instance(JavaThread* thread, oopDesc* type_mirror))
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
177 instanceKlassHandle klass(THREAD, java_lang_Class::as_Klass(type_mirror));
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
178
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
179 if (klass == NULL) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
180 ResourceMark rm(THREAD);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
181 THROW(vmSymbols::java_lang_InstantiationException());
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
182 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
183
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
184 // Create new instance (the receiver)
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
185 klass->check_valid_for_instantiation(false, CHECK);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
186
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
187 // Make sure klass gets initialized
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
188 klass->initialize(CHECK);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
189
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
190 oop obj = klass->allocate_instance(CHECK);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
191 thread->set_vm_result(obj);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
192 JRT_END
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
193
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
194 extern void vm_exit(int code);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
195
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
196 // Enter this method from compiled code handler below. This is where we transition
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
197 // to VM mode. This is done as a helper routine so that the method called directly
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
198 // from compiled code does not have to transition to VM. This allows the entry
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
199 // method to see if the nmethod that we have just looked up a handler for has
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
200 // been deoptimized while we were in the vm. This simplifies the assembly code
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
201 // cpu directories.
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
202 //
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
203 // We are entering here from exception stub (via the entry method below)
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
204 // If there is a compiled exception handler in this method, we will continue there;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
205 // otherwise we will unwind the stack and continue at the caller of top frame method
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
206 // Note: we enter in Java using a special JRT wrapper. This wrapper allows us to
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
207 // control the area where we can allow a safepoint. After we exit the safepoint area we can
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
208 // check to see if the handler we are going to return is now in a nmethod that has
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
209 // been deoptimized. If that is the case we return the deopt blob
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
210 // unpack_with_exception entry instead. This makes life for the exception blob easier
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
211 // because making that same check and diverting is painful from assembly language.
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
212 JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* thread, oopDesc* ex, address pc, nmethod*& nm))
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
213 // Reset method handle flag.
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
214 thread->set_is_method_handle_return(false);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
215
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
216 Handle exception(thread, ex);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
217 nm = CodeCache::find_nmethod(pc);
22517
0915f5bfdfaa Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22515
diff changeset
218 assert(nm != NULL, "this is not a compiled method");
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
219 // Adjust the pc as needed/
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
220 if (nm->is_deopt_pc(pc)) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
221 RegisterMap map(thread, false);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
222 frame exception_frame = thread->last_frame().sender(&map);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
223 // if the frame isn't deopted then pc must not correspond to the caller of last_frame
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
224 assert(exception_frame.is_deoptimized_frame(), "must be deopted");
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
225 pc = exception_frame.pc();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
226 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
227 #ifdef ASSERT
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
228 assert(exception.not_null(), "NULL exceptions should be handled by throw_exception");
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
229 assert(exception->is_oop(), "just checking");
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
230 // Check that exception is a subclass of Throwable, otherwise we have a VerifyError
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
231 if (!(exception->is_a(SystemDictionary::Throwable_klass()))) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
232 if (ExitVMOnVerifyError) vm_exit(-1);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
233 ShouldNotReachHere();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
234 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
235 #endif
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
236
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
237 // Check the stack guard pages and reenable them if necessary and there is
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
238 // enough space on the stack to do so. Use fast exceptions only if the guard
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
239 // pages are enabled.
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
240 bool guard_pages_enabled = thread->stack_yellow_zone_enabled();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
241 if (!guard_pages_enabled) guard_pages_enabled = thread->reguard_stack();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
242
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
243 if (JvmtiExport::can_post_on_exceptions()) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
244 // To ensure correct notification of exception catches and throws
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
245 // we have to deoptimize here. If we attempted to notify the
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
246 // catches and throws during this exception lookup it's possible
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
247 // we could deoptimize on the way out of the VM and end back in
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
248 // the interpreter at the throw site. This would result in double
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
249 // notifications since the interpreter would also notify about
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
250 // these same catches and throws as it unwound the frame.
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
251
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
252 RegisterMap reg_map(thread);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
253 frame stub_frame = thread->last_frame();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
254 frame caller_frame = stub_frame.sender(&reg_map);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
255
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
256 // We don't really want to deoptimize the nmethod itself since we
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
257 // can actually continue in the exception handler ourselves but I
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
258 // don't see an easy way to have the desired effect.
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
259 Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_constraint);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
260 assert(caller_is_deopted(), "Must be deoptimized");
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
261
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
262 return SharedRuntime::deopt_blob()->unpack_with_exception_in_tls();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
263 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
264
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
265 // ExceptionCache is used only for exceptions at call sites and not for implicit exceptions
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
266 if (guard_pages_enabled) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
267 address fast_continuation = nm->handler_for_exception_and_pc(exception, pc);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
268 if (fast_continuation != NULL) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
269 // Set flag if return address is a method handle call site.
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
270 thread->set_is_method_handle_return(nm->is_method_handle_return(pc));
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
271 return fast_continuation;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
272 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
273 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
274
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
275 // If the stack guard pages are enabled, check whether there is a handler in
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
276 // the current method. Otherwise (guard pages disabled), force an unwind and
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
277 // skip the exception cache update (i.e., just leave continuation==NULL).
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
278 address continuation = NULL;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
279 if (guard_pages_enabled) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
280
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
281 // New exception handling mechanism can support inlined methods
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
282 // with exception handlers since the mappings are from PC to PC
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
283
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
284 // debugging support
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
285 // tracing
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
286 if (TraceExceptions) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
287 ttyLocker ttyl;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
288 ResourceMark rm;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
289 tty->print_cr("Exception <%s> (" INTPTR_FORMAT ") thrown in compiled method <%s> at PC " INTPTR_FORMAT " for thread " INTPTR_FORMAT "",
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
290 exception->print_value_string(), p2i((address)exception()), nm->method()->print_value_string(), p2i(pc), p2i(thread));
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
291 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
292 // for AbortVMOnException flag
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
293 NOT_PRODUCT(Exceptions::debug_check_abort(exception));
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
294
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
295 // Clear out the exception oop and pc since looking up an
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
296 // exception handler can cause class loading, which might throw an
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
297 // exception and those fields are expected to be clear during
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
298 // normal bytecode execution.
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
299 thread->clear_exception_oop_and_pc();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
300
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
301 continuation = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, false, false);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
302 // If an exception was thrown during exception dispatch, the exception oop may have changed
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
303 thread->set_exception_oop(exception());
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
304 thread->set_exception_pc(pc);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
305
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
306 // the exception cache is used only by non-implicit exceptions
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
307 if (continuation != NULL && !SharedRuntime::deopt_blob()->contains(continuation)) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
308 nm->add_handler_for_exception_and_pc(exception, pc, continuation);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
309 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
310 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
311
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
312 // Set flag if return address is a method handle call site.
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
313 thread->set_is_method_handle_return(nm->is_method_handle_return(pc));
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
314
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
315 if (TraceExceptions) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
316 ttyLocker ttyl;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
317 ResourceMark rm;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
318 tty->print_cr("Thread " PTR_FORMAT " continuing at PC " PTR_FORMAT " for exception thrown at PC " PTR_FORMAT,
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
319 p2i(thread), p2i(continuation), p2i(pc));
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
320 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
321
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
322 return continuation;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
323 JRT_END
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
324
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
325 // Enter this method from compiled code only if there is a Java exception handler
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
326 // in the method handling the exception.
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
327 // We are entering here from exception stub. We don't do a normal VM transition here.
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
328 // We do it in a helper. This is so we can check to see if the nmethod we have just
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
329 // searched for an exception handler has been deoptimized in the meantime.
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
330 address JVMCIRuntime::exception_handler_for_pc(JavaThread* thread) {
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
331 oop exception = thread->exception_oop();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
332 address pc = thread->exception_pc();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
333 // Still in Java mode
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
334 DEBUG_ONLY(ResetNoHandleMark rnhm);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
335 nmethod* nm = NULL;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
336 address continuation = NULL;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
337 {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
338 // Enter VM mode by calling the helper
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
339 ResetNoHandleMark rnhm;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
340 continuation = exception_handler_for_pc_helper(thread, exception, pc, nm);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
341 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
342 // Back in JAVA, use no oops DON'T safepoint
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
343
22517
0915f5bfdfaa Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22515
diff changeset
344 // Now check to see if the compiled method we were called from is now deoptimized.
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
345 // If so we must return to the deopt blob and deoptimize the nmethod
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
346 if (nm != NULL && caller_is_deopted()) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
347 continuation = SharedRuntime::deopt_blob()->unpack_with_exception_in_tls();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
348 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
349
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
350 assert(continuation != NULL, "no handler found");
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
351 return continuation;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
352 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
353
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
354 JRT_ENTRY_NO_ASYNC(void, JVMCIRuntime::monitorenter(JavaThread* thread, oopDesc* obj, BasicLock* lock))
22544
b87d1bf3cd9a renamed TraceJVMCI option to JVMCITraceLevel and ensured all tracing controlled by this option uses the TRACE_jvmci_* macros
Doug Simon <doug.simon@oracle.com>
parents: 22543
diff changeset
355 IF_TRACE_jvmci_3 {
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
356 char type[O_BUFLEN];
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
357 obj->klass()->name()->as_C_string(type, O_BUFLEN);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
358 markOop mark = obj->mark();
22544
b87d1bf3cd9a renamed TraceJVMCI option to JVMCITraceLevel and ensured all tracing controlled by this option uses the TRACE_jvmci_* macros
Doug Simon <doug.simon@oracle.com>
parents: 22543
diff changeset
359 TRACE_jvmci_3("%s: entered locking slow case with obj=" INTPTR_FORMAT ", type=%s, mark=" INTPTR_FORMAT ", lock=" INTPTR_FORMAT, thread->name(), p2i(obj), type, p2i(mark), p2i(lock));
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
360 tty->flush();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
361 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
362 #ifdef ASSERT
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
363 if (PrintBiasedLockingStatistics) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
364 Atomic::inc(BiasedLocking::slow_path_entry_count_addr());
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
365 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
366 #endif
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
367 Handle h_obj(thread, obj);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
368 assert(h_obj()->is_oop(), "must be NULL or an object");
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
369 if (UseBiasedLocking) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
370 // Retry fast entry if bias is revoked to avoid unnecessary inflation
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
371 ObjectSynchronizer::fast_enter(h_obj, lock, true, CHECK);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
372 } else {
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
373 if (JVMCIUseFastLocking) {
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
374 // When using fast locking, the compiled code has already tried the fast case
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
375 ObjectSynchronizer::slow_enter(h_obj, lock, THREAD);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
376 } else {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
377 ObjectSynchronizer::fast_enter(h_obj, lock, false, THREAD);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
378 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
379 }
22544
b87d1bf3cd9a renamed TraceJVMCI option to JVMCITraceLevel and ensured all tracing controlled by this option uses the TRACE_jvmci_* macros
Doug Simon <doug.simon@oracle.com>
parents: 22543
diff changeset
380 TRACE_jvmci_3("%s: exiting locking slow with obj=" INTPTR_FORMAT, thread->name(), p2i(obj));
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
381 JRT_END
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
382
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
383 JRT_LEAF(void, JVMCIRuntime::monitorexit(JavaThread* thread, oopDesc* obj, BasicLock* lock))
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
384 assert(thread == JavaThread::current(), "threads must correspond");
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
385 assert(thread->last_Java_sp(), "last_Java_sp must be set");
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
386 // monitorexit is non-blocking (leaf routine) => no exceptions can be thrown
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
387 EXCEPTION_MARK;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
388
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
389 #ifdef DEBUG
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
390 if (!obj->is_oop()) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
391 ResetNoHandleMark rhm;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
392 nmethod* method = thread->last_frame().cb()->as_nmethod_or_null();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
393 if (method != NULL) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
394 tty->print_cr("ERROR in monitorexit in method %s wrong obj " INTPTR_FORMAT, method->name(), p2i(obj));
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
395 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
396 thread->print_stack_on(tty);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
397 assert(false, "invalid lock object pointer dected");
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
398 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
399 #endif
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
400
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
401 if (JVMCIUseFastLocking) {
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
402 // When using fast locking, the compiled code has already tried the fast case
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
403 ObjectSynchronizer::slow_exit(obj, lock, THREAD);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
404 } else {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
405 ObjectSynchronizer::fast_exit(obj, lock, THREAD);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
406 }
22544
b87d1bf3cd9a renamed TraceJVMCI option to JVMCITraceLevel and ensured all tracing controlled by this option uses the TRACE_jvmci_* macros
Doug Simon <doug.simon@oracle.com>
parents: 22543
diff changeset
407 IF_TRACE_jvmci_3 {
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
408 char type[O_BUFLEN];
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
409 obj->klass()->name()->as_C_string(type, O_BUFLEN);
22544
b87d1bf3cd9a renamed TraceJVMCI option to JVMCITraceLevel and ensured all tracing controlled by this option uses the TRACE_jvmci_* macros
Doug Simon <doug.simon@oracle.com>
parents: 22543
diff changeset
410 TRACE_jvmci_3("%s: exited locking slow case with obj=" INTPTR_FORMAT ", type=%s, mark=" INTPTR_FORMAT ", lock=" INTPTR_FORMAT, thread->name(), p2i(obj), type, p2i(obj->mark()), p2i(lock));
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
411 tty->flush();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
412 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
413 JRT_END
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
414
23367
041534002323 Use strings instead of Symbol* for exception names (JDK-8155735).
Roland Schatz <roland.schatz@oracle.com>
parents: 23337
diff changeset
415 JRT_ENTRY(void, JVMCIRuntime::throw_and_post_jvmti_exception(JavaThread* thread, const char* exception, const char* message))
23372
1c7bac3f1f20 Use CHECK instead of HAS_PENDING_EXCEPTION (JDK-8155735).
Roland Schatz <roland.schatz@oracle.com>
parents: 23371
diff changeset
416 TempNewSymbol symbol = SymbolTable::new_symbol(exception, CHECK);
1c7bac3f1f20 Use CHECK instead of HAS_PENDING_EXCEPTION (JDK-8155735).
Roland Schatz <roland.schatz@oracle.com>
parents: 23371
diff changeset
417 SharedRuntime::throw_and_post_jvmti_exception(thread, symbol, message);
23322
f8178417d018 Expose SharedRuntime::throw_and_post_jvmti_exception to JVMCI compilers.
Roland Schatz <roland.schatz@oracle.com>
parents: 23319
diff changeset
418 JRT_END
f8178417d018 Expose SharedRuntime::throw_and_post_jvmti_exception to JVMCI compilers.
Roland Schatz <roland.schatz@oracle.com>
parents: 23319
diff changeset
419
23367
041534002323 Use strings instead of Symbol* for exception names (JDK-8155735).
Roland Schatz <roland.schatz@oracle.com>
parents: 23337
diff changeset
420 JRT_ENTRY(void, JVMCIRuntime::throw_klass_external_name_exception(JavaThread* thread, const char* exception, Klass* klass))
23334
e0a15983ab51 Create exception throwing routines for exceptions with complex messages.
Roland Schatz <roland.schatz@oracle.com>
parents: 23329
diff changeset
421 ResourceMark rm(thread);
23372
1c7bac3f1f20 Use CHECK instead of HAS_PENDING_EXCEPTION (JDK-8155735).
Roland Schatz <roland.schatz@oracle.com>
parents: 23371
diff changeset
422 TempNewSymbol symbol = SymbolTable::new_symbol(exception, CHECK);
1c7bac3f1f20 Use CHECK instead of HAS_PENDING_EXCEPTION (JDK-8155735).
Roland Schatz <roland.schatz@oracle.com>
parents: 23371
diff changeset
423 SharedRuntime::throw_and_post_jvmti_exception(thread, symbol, klass->external_name());
23334
e0a15983ab51 Create exception throwing routines for exceptions with complex messages.
Roland Schatz <roland.schatz@oracle.com>
parents: 23329
diff changeset
424 JRT_END
e0a15983ab51 Create exception throwing routines for exceptions with complex messages.
Roland Schatz <roland.schatz@oracle.com>
parents: 23329
diff changeset
425
23367
041534002323 Use strings instead of Symbol* for exception names (JDK-8155735).
Roland Schatz <roland.schatz@oracle.com>
parents: 23337
diff changeset
426 JRT_ENTRY(void, JVMCIRuntime::throw_class_cast_exception(JavaThread* thread, const char* exception, Klass* caster_klass, Klass* target_klass))
23334
e0a15983ab51 Create exception throwing routines for exceptions with complex messages.
Roland Schatz <roland.schatz@oracle.com>
parents: 23329
diff changeset
427 ResourceMark rm(thread);
23337
62804a7d3877 Remove `desc` argument from JVMCIRuntime::throw_class_cast_exception.
Roland Schatz <roland.schatz@oracle.com>
parents: 23334
diff changeset
428 const char* message = SharedRuntime::generate_class_cast_message(caster_klass->external_name(), target_klass->external_name());
23372
1c7bac3f1f20 Use CHECK instead of HAS_PENDING_EXCEPTION (JDK-8155735).
Roland Schatz <roland.schatz@oracle.com>
parents: 23371
diff changeset
429 TempNewSymbol symbol = SymbolTable::new_symbol(exception, CHECK);
1c7bac3f1f20 Use CHECK instead of HAS_PENDING_EXCEPTION (JDK-8155735).
Roland Schatz <roland.schatz@oracle.com>
parents: 23371
diff changeset
430 SharedRuntime::throw_and_post_jvmti_exception(thread, symbol, message);
23334
e0a15983ab51 Create exception throwing routines for exceptions with complex messages.
Roland Schatz <roland.schatz@oracle.com>
parents: 23329
diff changeset
431 JRT_END
e0a15983ab51 Create exception throwing routines for exceptions with complex messages.
Roland Schatz <roland.schatz@oracle.com>
parents: 23329
diff changeset
432
22668
da5bdbf4a008 Simplify log_object interface
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22650
diff changeset
433 JRT_LEAF(void, JVMCIRuntime::log_object(JavaThread* thread, oopDesc* obj, bool as_string, bool newline))
da5bdbf4a008 Simplify log_object interface
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22650
diff changeset
434 ttyLocker ttyl;
da5bdbf4a008 Simplify log_object interface
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22650
diff changeset
435
da5bdbf4a008 Simplify log_object interface
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22650
diff changeset
436 if (obj == NULL) {
da5bdbf4a008 Simplify log_object interface
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22650
diff changeset
437 tty->print("NULL");
da5bdbf4a008 Simplify log_object interface
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22650
diff changeset
438 } else if (obj->is_oop_or_null(true) && (!as_string || !java_lang_String::is_instance(obj))) {
da5bdbf4a008 Simplify log_object interface
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22650
diff changeset
439 if (obj->is_oop_or_null(true)) {
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
440 char buf[O_BUFLEN];
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
441 tty->print("%s@" INTPTR_FORMAT, obj->klass()->name()->as_C_string(buf, O_BUFLEN), p2i(obj));
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
442 } else {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
443 tty->print(INTPTR_FORMAT, p2i(obj));
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
444 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
445 } else {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
446 ResourceMark rm;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
447 assert(obj != NULL && java_lang_String::is_instance(obj), "must be");
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
448 char *buf = java_lang_String::as_utf8_string(obj);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
449 tty->print_raw(buf);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
450 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
451 if (newline) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
452 tty->cr();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
453 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
454 JRT_END
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
455
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
456 JRT_LEAF(void, JVMCIRuntime::write_barrier_pre(JavaThread* thread, oopDesc* obj))
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
457 thread->satb_mark_queue().enqueue(obj);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
458 JRT_END
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
459
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
460 JRT_LEAF(void, JVMCIRuntime::write_barrier_post(JavaThread* thread, void* card_addr))
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
461 thread->dirty_card_queue().enqueue(card_addr);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
462 JRT_END
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
463
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
464 JRT_LEAF(jboolean, JVMCIRuntime::validate_object(JavaThread* thread, oopDesc* parent, oopDesc* child))
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
465 bool ret = true;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
466 if(!Universe::heap()->is_in_closed_subset(parent)) {
22507
693e1df2b808 Add spaces around format macros
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22501
diff changeset
467 tty->print_cr("Parent Object " INTPTR_FORMAT " not in heap", p2i(parent));
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
468 parent->print();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
469 ret=false;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
470 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
471 if(!Universe::heap()->is_in_closed_subset(child)) {
22507
693e1df2b808 Add spaces around format macros
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22501
diff changeset
472 tty->print_cr("Child Object " INTPTR_FORMAT " not in heap", p2i(child));
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
473 child->print();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
474 ret=false;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
475 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
476 return (jint)ret;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
477 JRT_END
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
478
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
479 JRT_ENTRY(void, JVMCIRuntime::vm_error(JavaThread* thread, jlong where, jlong format, jlong value))
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
480 ResourceMark rm;
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
481 const char *error_msg = where == 0L ? "<internal JVMCI error>" : (char*) (address) where;
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
482 char *detail_msg = NULL;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
483 if (format != 0L) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
484 const char* buf = (char*) (address) format;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
485 size_t detail_msg_length = strlen(buf) * 2;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
486 detail_msg = (char *) NEW_RESOURCE_ARRAY(u_char, detail_msg_length);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
487 jio_snprintf(detail_msg, detail_msg_length, buf, value);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
488 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
489 report_vm_error(__FILE__, __LINE__, error_msg, detail_msg);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
490 JRT_END
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
491
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
492 JRT_LEAF(oopDesc*, JVMCIRuntime::load_and_clear_exception(JavaThread* thread))
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
493 oop exception = thread->exception_oop();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
494 assert(exception != NULL, "npe");
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
495 thread->set_exception_oop(NULL);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
496 thread->set_exception_pc(0);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
497 return exception;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
498 JRT_END
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
499
22517
0915f5bfdfaa Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22515
diff changeset
500 PRAGMA_DIAG_PUSH
0915f5bfdfaa Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22515
diff changeset
501 PRAGMA_FORMAT_NONLITERAL_IGNORED
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
502 JRT_LEAF(void, JVMCIRuntime::log_printf(JavaThread* thread, oopDesc* format, jlong v1, jlong v2, jlong v3))
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
503 ResourceMark rm;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
504 assert(format != NULL && java_lang_String::is_instance(format), "must be");
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
505 char *buf = java_lang_String::as_utf8_string(format);
22517
0915f5bfdfaa Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22515
diff changeset
506 tty->print((const char*)buf, v1, v2, v3);
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
507 JRT_END
22517
0915f5bfdfaa Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22515
diff changeset
508 PRAGMA_DIAG_POP
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
509
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
510 static void decipher(jlong v, bool ignoreZero) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
511 if (v != 0 || !ignoreZero) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
512 void* p = (void *)(address) v;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
513 CodeBlob* cb = CodeCache::find_blob(p);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
514 if (cb) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
515 if (cb->is_nmethod()) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
516 char buf[O_BUFLEN];
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
517 tty->print("%s [" INTPTR_FORMAT "+" JLONG_FORMAT "]", cb->as_nmethod_or_null()->method()->name_and_sig_as_C_string(buf, O_BUFLEN), p2i(cb->code_begin()), (jlong)((address)v - cb->code_begin()));
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
518 return;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
519 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
520 cb->print_value_on(tty);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
521 return;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
522 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
523 if (Universe::heap()->is_in(p)) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
524 oop obj = oop(p);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
525 obj->print_value_on(tty);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
526 return;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
527 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
528 tty->print(INTPTR_FORMAT " [long: " JLONG_FORMAT ", double %lf, char %c]",p2i((void *)v), (jlong)v, (jdouble)v, (char)v);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
529 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
530 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
531
22517
0915f5bfdfaa Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22515
diff changeset
532 PRAGMA_DIAG_PUSH
0915f5bfdfaa Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22515
diff changeset
533 PRAGMA_FORMAT_NONLITERAL_IGNORED
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
534 JRT_LEAF(void, JVMCIRuntime::vm_message(jboolean vmError, jlong format, jlong v1, jlong v2, jlong v3))
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
535 ResourceMark rm;
22517
0915f5bfdfaa Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22515
diff changeset
536 const char *buf = (const char*) (address) format;
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
537 if (vmError) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
538 if (buf != NULL) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
539 fatal(err_msg(buf, v1, v2, v3));
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
540 } else {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
541 fatal("<anonymous error>");
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
542 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
543 } else if (buf != NULL) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
544 tty->print(buf, v1, v2, v3);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
545 } else {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
546 assert(v2 == 0, "v2 != 0");
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
547 assert(v3 == 0, "v3 != 0");
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
548 decipher(v1, false);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
549 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
550 JRT_END
22517
0915f5bfdfaa Adopt some jvmci-9 source changes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22515
diff changeset
551 PRAGMA_DIAG_POP
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
552
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
553 JRT_LEAF(void, JVMCIRuntime::log_primitive(JavaThread* thread, jchar typeChar, jlong value, jboolean newline))
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
554 union {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
555 jlong l;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
556 jdouble d;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
557 jfloat f;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
558 } uu;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
559 uu.l = value;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
560 switch (typeChar) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
561 case 'z': tty->print(value == 0 ? "false" : "true"); break;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
562 case 'b': tty->print("%d", (jbyte) value); break;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
563 case 'c': tty->print("%c", (jchar) value); break;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
564 case 's': tty->print("%d", (jshort) value); break;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
565 case 'i': tty->print("%d", (jint) value); break;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
566 case 'f': tty->print("%f", uu.f); break;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
567 case 'j': tty->print(JLONG_FORMAT, value); break;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
568 case 'd': tty->print("%lf", uu.d); break;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
569 default: assert(false, "unknown typeChar"); break;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
570 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
571 if (newline) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
572 tty->cr();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
573 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
574 JRT_END
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
575
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
576 JRT_ENTRY(jint, JVMCIRuntime::identity_hash_code(JavaThread* thread, oopDesc* obj))
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
577 return (jint) obj->identity_hash();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
578 JRT_END
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
579
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
580 JRT_ENTRY(jboolean, JVMCIRuntime::thread_is_interrupted(JavaThread* thread, oopDesc* receiver, jboolean clear_interrupted))
21207
93dc70e47fb0 documented why THREAD_IS_INTERRUPTED foreign call is NOT_LEAF
Doug Simon <doug.simon@oracle.com>
parents: 21123
diff changeset
581 // Ensure that the C++ Thread and OSThread structures aren't freed before we operate.
93dc70e47fb0 documented why THREAD_IS_INTERRUPTED foreign call is NOT_LEAF
Doug Simon <doug.simon@oracle.com>
parents: 21123
diff changeset
582 // This locking requires thread_in_vm which is why this method cannot be JRT_LEAF.
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
583 Handle receiverHandle(thread, receiver);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
584 MutexLockerEx ml(thread->threadObj() == (void*)receiver ? NULL : Threads_lock);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
585 JavaThread* receiverThread = java_lang_Thread::thread(receiverHandle());
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
586 if (receiverThread == NULL) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
587 // The other thread may exit during this process, which is ok so return false.
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
588 return JNI_FALSE;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
589 } else {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
590 return (jint) Thread::is_interrupted(receiverThread, clear_interrupted != 0);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
591 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
592 JRT_END
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
593
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
594 JRT_ENTRY(jint, JVMCIRuntime::test_deoptimize_call_int(JavaThread* thread, int value))
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
595 deopt_caller();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
596 return value;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
597 JRT_END
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
598
22398
4f6caa445b92 moved JVMCI option parsing back into Java
Doug Simon <doug.simon@oracle.com>
parents: 22054
diff changeset
599 // private static void JVMCIClassLoaderFactory.init(ClassLoader loader)
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
600 JVM_ENTRY(void, JVM_InitJVMCIClassLoader(JNIEnv *env, jclass c, jobject loader_handle))
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
601 SystemDictionary::init_jvmci_loader(JNIHandles::resolve(loader_handle));
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
602 SystemDictionary::WKID scan = SystemDictionary::FIRST_JVMCI_WKID;
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
603 SystemDictionary::initialize_wk_klasses_through(SystemDictionary::LAST_JVMCI_WKID, scan, CHECK);
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
604 JVM_END
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
605
21527
07b088d61d5d added HotSpotJVMCIRuntime* classes, replaced references to HotSpotGraalRuntime in VM with HotSpotJVMCIRuntime (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21526
diff changeset
606 // private static JVMCIRuntime JVMCI.initializeRuntime()
07b088d61d5d added HotSpotJVMCIRuntime* classes, replaced references to HotSpotGraalRuntime in VM with HotSpotJVMCIRuntime (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21526
diff changeset
607 JVM_ENTRY(jobject, JVM_GetJVMCIRuntime(JNIEnv *env, jclass c))
22574
5a706439be63 Propagate exceptions up instead of aborting
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22553
diff changeset
608 JVMCIRuntime::initialize_HotSpotJVMCIRuntime(CHECK_NULL);
5a706439be63 Propagate exceptions up instead of aborting
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22553
diff changeset
609 return JVMCIRuntime::get_HotSpotJVMCIRuntime_jobject(CHECK_NULL);
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
610 JVM_END
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
611
22761
f2206f5bb62e removed @ServiceProvider mechanism (GRAAL-1380)
Doug Simon <doug.simon@oracle.com>
parents: 22758
diff changeset
612 // private static Object[] Services.getServiceImpls(String serviceClass)
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
613 JVM_ENTRY(jobject, JVM_GetJVMCIServiceImpls(JNIEnv *env, jclass c, jclass serviceClass))
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
614 HandleMark hm;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
615 ResourceMark rm;
22416
8abc6030cf1c ensure JVMCI class loader is initialized before attempting to load service provider
Andreas Woess <andreas.woess@oracle.com>
parents: 22401
diff changeset
616 JVMCIRuntime::ensure_jvmci_class_loader_is_initialized();
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
617 KlassHandle serviceKlass(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(serviceClass)));
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
618 return JNIHandles::make_local(THREAD, JVMCIRuntime::get_service_impls(serviceKlass, THREAD)());
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
619 JVM_END
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
620
22574
5a706439be63 Propagate exceptions up instead of aborting
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22553
diff changeset
621 Handle JVMCIRuntime::callStatic(const char* className, const char* methodName, const char* signature, JavaCallArguments* args, TRAPS) {
21527
07b088d61d5d added HotSpotJVMCIRuntime* classes, replaced references to HotSpotGraalRuntime in VM with HotSpotJVMCIRuntime (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21526
diff changeset
622 guarantee(!_HotSpotJVMCIRuntime_initialized, "cannot reinitialize HotSpotJVMCIRuntime");
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
623
22574
5a706439be63 Propagate exceptions up instead of aborting
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22553
diff changeset
624 TempNewSymbol name = SymbolTable::new_symbol(className, CHECK_(Handle()));
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
625 KlassHandle klass = load_required_class(name);
22574
5a706439be63 Propagate exceptions up instead of aborting
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22553
diff changeset
626 TempNewSymbol runtime = SymbolTable::new_symbol(methodName, CHECK_(Handle()));
5a706439be63 Propagate exceptions up instead of aborting
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22553
diff changeset
627 TempNewSymbol sig = SymbolTable::new_symbol(signature, CHECK_(Handle()));
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
628 JavaValue result(T_OBJECT);
22398
4f6caa445b92 moved JVMCI option parsing back into Java
Doug Simon <doug.simon@oracle.com>
parents: 22054
diff changeset
629 if (args == NULL) {
22574
5a706439be63 Propagate exceptions up instead of aborting
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22553
diff changeset
630 JavaCalls::call_static(&result, klass, runtime, sig, CHECK_(Handle()));
22398
4f6caa445b92 moved JVMCI option parsing back into Java
Doug Simon <doug.simon@oracle.com>
parents: 22054
diff changeset
631 } else {
22574
5a706439be63 Propagate exceptions up instead of aborting
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22553
diff changeset
632 JavaCalls::call_static(&result, klass, runtime, sig, args, CHECK_(Handle()));
22398
4f6caa445b92 moved JVMCI option parsing back into Java
Doug Simon <doug.simon@oracle.com>
parents: 22054
diff changeset
633 }
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
634 return Handle((oop)result.get_jobject());
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
635 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
636
22574
5a706439be63 Propagate exceptions up instead of aborting
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22553
diff changeset
637 void JVMCIRuntime::initialize_HotSpotJVMCIRuntime(TRAPS) {
21527
07b088d61d5d added HotSpotJVMCIRuntime* classes, replaced references to HotSpotGraalRuntime in VM with HotSpotJVMCIRuntime (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21526
diff changeset
638 if (JNIHandles::resolve(_HotSpotJVMCIRuntime_instance) == NULL) {
22398
4f6caa445b92 moved JVMCI option parsing back into Java
Doug Simon <doug.simon@oracle.com>
parents: 22054
diff changeset
639 Thread* THREAD = Thread::current();
23304
3dab35122bce Add missing ResourceMark
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 23296
diff changeset
640 ResourceMark rm;
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
641 #ifdef ASSERT
21527
07b088d61d5d added HotSpotJVMCIRuntime* classes, replaced references to HotSpotGraalRuntime in VM with HotSpotJVMCIRuntime (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21526
diff changeset
642 // This should only be called in the context of the JVMCI class being initialized
22672
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22668
diff changeset
643 TempNewSymbol name = SymbolTable::new_symbol("jdk/vm/ci/runtime/JVMCI", CHECK);
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
644 instanceKlassHandle klass = InstanceKlass::cast(load_required_class(name));
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
645 assert(klass->is_being_initialized() && klass->is_reentrant_initialization(THREAD),
21527
07b088d61d5d added HotSpotJVMCIRuntime* classes, replaced references to HotSpotGraalRuntime in VM with HotSpotJVMCIRuntime (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21526
diff changeset
646 "HotSpotJVMCIRuntime initialization should only be triggered through JVMCI initialization");
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
647 #endif
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
648
22672
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22668
diff changeset
649 Handle result = callStatic("jdk/vm/ci/hotspot/HotSpotJVMCIRuntime",
22461
07d9f0909560 Rename callInitializer to callStatic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22454
diff changeset
650 "runtime",
22672
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22668
diff changeset
651 "()Ljdk/vm/ci/hotspot/HotSpotJVMCIRuntime;", NULL, CHECK);
22575
569c82ebb96e Replace JVMCICompileWithC1Only with package based controls
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22574
diff changeset
652 objArrayOop trivial_prefixes = HotSpotJVMCIRuntime::trivialPrefixes(result);
569c82ebb96e Replace JVMCICompileWithC1Only with package based controls
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22574
diff changeset
653 if (trivial_prefixes != NULL) {
22586
cf99b5e5b0b4 Fix race in initialization of trivial prefixes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22585
diff changeset
654 char** prefixes = NEW_C_HEAP_ARRAY(char*, trivial_prefixes->length(), mtCompiler);
22575
569c82ebb96e Replace JVMCICompileWithC1Only with package based controls
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22574
diff changeset
655 for (int i = 0; i < trivial_prefixes->length(); i++) {
569c82ebb96e Replace JVMCICompileWithC1Only with package based controls
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22574
diff changeset
656 oop str = trivial_prefixes->obj_at(i);
569c82ebb96e Replace JVMCICompileWithC1Only with package based controls
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22574
diff changeset
657 if (str == NULL) {
569c82ebb96e Replace JVMCICompileWithC1Only with package based controls
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22574
diff changeset
658 THROW(vmSymbols::java_lang_NullPointerException());
569c82ebb96e Replace JVMCICompileWithC1Only with package based controls
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22574
diff changeset
659 } else {
22588
3e3d5678a6bf Fix trivial prefixes code
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22586
diff changeset
660 prefixes[i] = strdup(java_lang_String::as_utf8_string(str));
22575
569c82ebb96e Replace JVMCICompileWithC1Only with package based controls
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22574
diff changeset
661 }
569c82ebb96e Replace JVMCICompileWithC1Only with package based controls
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22574
diff changeset
662 }
22586
cf99b5e5b0b4 Fix race in initialization of trivial prefixes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22585
diff changeset
663 _trivial_prefixes = prefixes;
cf99b5e5b0b4 Fix race in initialization of trivial prefixes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22585
diff changeset
664 _trivial_prefixes_count = trivial_prefixes->length();
22575
569c82ebb96e Replace JVMCICompileWithC1Only with package based controls
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22574
diff changeset
665 }
23379
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
666 int adjustment = HotSpotJVMCIRuntime::compilationLevelAdjustment(result);
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
667 assert(adjustment >= JVMCIRuntime::none &&
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
668 adjustment <= JVMCIRuntime::by_full_signature,
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
669 "compilation level adjustment out of bounds");
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
670 _comp_level_adjustment = (CompLevelAdjustment) adjustment;
21527
07b088d61d5d added HotSpotJVMCIRuntime* classes, replaced references to HotSpotGraalRuntime in VM with HotSpotJVMCIRuntime (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21526
diff changeset
671 _HotSpotJVMCIRuntime_initialized = true;
07b088d61d5d added HotSpotJVMCIRuntime* classes, replaced references to HotSpotGraalRuntime in VM with HotSpotJVMCIRuntime (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21526
diff changeset
672 _HotSpotJVMCIRuntime_instance = JNIHandles::make_global(result());
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
673 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
674 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
675
22574
5a706439be63 Propagate exceptions up instead of aborting
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22553
diff changeset
676 void JVMCIRuntime::initialize_JVMCI(TRAPS) {
21527
07b088d61d5d added HotSpotJVMCIRuntime* classes, replaced references to HotSpotGraalRuntime in VM with HotSpotJVMCIRuntime (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21526
diff changeset
677 if (JNIHandles::resolve(_HotSpotJVMCIRuntime_instance) == NULL) {
22672
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22668
diff changeset
678 callStatic("jdk/vm/ci/runtime/JVMCI",
22461
07d9f0909560 Rename callInitializer to callStatic
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22454
diff changeset
679 "getRuntime",
22672
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22668
diff changeset
680 "()Ljdk/vm/ci/runtime/JVMCIRuntime;", NULL, CHECK);
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
681 }
21527
07b088d61d5d added HotSpotJVMCIRuntime* classes, replaced references to HotSpotGraalRuntime in VM with HotSpotJVMCIRuntime (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21526
diff changeset
682 assert(_HotSpotJVMCIRuntime_initialized == true, "what?");
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
683 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
684
22454
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
685 void JVMCIRuntime::metadata_do(void f(Metadata*)) {
22543
97ca867d3622 Fix assertion failure in JVMCIRuntime::metadata_do
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22538
diff changeset
686 // For simplicity, the existence of HotSpotJVMCIMetaAccessContext in
97ca867d3622 Fix assertion failure in JVMCIRuntime::metadata_do
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22538
diff changeset
687 // the SystemDictionary well known classes should ensure the other
97ca867d3622 Fix assertion failure in JVMCIRuntime::metadata_do
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22538
diff changeset
688 // classes have already been loaded, so make sure their order in the
97ca867d3622 Fix assertion failure in JVMCIRuntime::metadata_do
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22538
diff changeset
689 // table enforces that.
22672
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22668
diff changeset
690 assert(SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotResolvedJavaMethodImpl) <
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22668
diff changeset
691 SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotJVMCIMetaAccessContext), "must be loaded earlier");
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22668
diff changeset
692 assert(SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotConstantPool) <
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22668
diff changeset
693 SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotJVMCIMetaAccessContext), "must be loaded earlier");
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22668
diff changeset
694 assert(SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotResolvedObjectTypeImpl) <
1bbd4a7c274b Rename jdk.internal.jvmci to jdk.vm.ci
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22668
diff changeset
695 SystemDictionary::WK_KLASS_ENUM_NAME(jdk_vm_ci_hotspot_HotSpotJVMCIMetaAccessContext), "must be loaded earlier");
22543
97ca867d3622 Fix assertion failure in JVMCIRuntime::metadata_do
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22538
diff changeset
696
97ca867d3622 Fix assertion failure in JVMCIRuntime::metadata_do
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22538
diff changeset
697 if (HotSpotJVMCIMetaAccessContext::klass() == NULL ||
97ca867d3622 Fix assertion failure in JVMCIRuntime::metadata_do
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22538
diff changeset
698 !HotSpotJVMCIMetaAccessContext::klass()->is_linked()) {
97ca867d3622 Fix assertion failure in JVMCIRuntime::metadata_do
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22538
diff changeset
699 // Nothing could be registered yet
22464
3fb432661d59 make JVMCIRuntime::metadata_do return immediately if HotSpotJVMCIMetaAccessContext has not yet been loaded
Doug Simon <doug.simon@oracle.com>
parents: 22461
diff changeset
700 return;
3fb432661d59 make JVMCIRuntime::metadata_do return immediately if HotSpotJVMCIMetaAccessContext has not yet been loaded
Doug Simon <doug.simon@oracle.com>
parents: 22461
diff changeset
701 }
22515
feb4131657bb JVMCIRuntime::metadata_do shouldn't run until HotSpotJVMCIRuntime is initialized
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22511
diff changeset
702
22454
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
703 // WeakReference<HotSpotJVMCIMetaAccessContext>[]
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
704 objArrayOop allContexts = HotSpotJVMCIMetaAccessContext::allContexts();
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
705 if (allContexts == NULL) {
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
706 return;
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
707 }
22543
97ca867d3622 Fix assertion failure in JVMCIRuntime::metadata_do
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22538
diff changeset
708
97ca867d3622 Fix assertion failure in JVMCIRuntime::metadata_do
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22538
diff changeset
709 // These must be loaded at this point but the linking state doesn't matter.
97ca867d3622 Fix assertion failure in JVMCIRuntime::metadata_do
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22538
diff changeset
710 assert(SystemDictionary::HotSpotResolvedJavaMethodImpl_klass() != NULL, "must be loaded");
97ca867d3622 Fix assertion failure in JVMCIRuntime::metadata_do
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22538
diff changeset
711 assert(SystemDictionary::HotSpotConstantPool_klass() != NULL, "must be loaded");
97ca867d3622 Fix assertion failure in JVMCIRuntime::metadata_do
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22538
diff changeset
712 assert(SystemDictionary::HotSpotResolvedObjectTypeImpl_klass() != NULL, "must be loaded");
22650
939d5da65929 reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22637
diff changeset
713
22454
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
714 for (int i = 0; i < allContexts->length(); i++) {
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
715 oop ref = allContexts->obj_at(i);
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
716 if (ref != NULL) {
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
717 oop referent = java_lang_ref_Reference::referent(ref);
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
718 if (referent != NULL) {
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
719 // Chunked Object[] with last element pointing to next chunk
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
720 objArrayOop metadataRoots = HotSpotJVMCIMetaAccessContext::metadataRoots(referent);
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
721 while (metadataRoots != NULL) {
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
722 for (int typeIndex = 0; typeIndex < metadataRoots->length() - 1; typeIndex++) {
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
723 oop reference = metadataRoots->obj_at(typeIndex);
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
724 if (reference == NULL) {
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
725 continue;
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
726 }
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
727 oop metadataRoot = java_lang_ref_Reference::referent(reference);
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
728 if (metadataRoot == NULL) {
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
729 continue;
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
730 }
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
731 if (metadataRoot->is_a(SystemDictionary::HotSpotResolvedJavaMethodImpl_klass())) {
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
732 Method* method = CompilerToVM::asMethod(metadataRoot);
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
733 f(method);
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
734 } else if (metadataRoot->is_a(SystemDictionary::HotSpotConstantPool_klass())) {
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
735 ConstantPool* constantPool = CompilerToVM::asConstantPool(metadataRoot);
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
736 f(constantPool);
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
737 } else if (metadataRoot->is_a(SystemDictionary::HotSpotResolvedObjectTypeImpl_klass())) {
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
738 Klass* klass = CompilerToVM::asKlass(metadataRoot);
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
739 f(klass);
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
740 } else {
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
741 metadataRoot->print();
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
742 ShouldNotReachHere();
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
743 }
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
744 }
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
745 metadataRoots = (objArrayOop)metadataRoots->obj_at(metadataRoots->length() - 1);
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
746 assert(metadataRoots == NULL || metadataRoots->is_objArray(), "wrong type");
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
747 }
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
748 }
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
749 }
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
750 }
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
751 }
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22447
diff changeset
752
22650
939d5da65929 reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22637
diff changeset
753 // private static void CompilerToVM.registerNatives()
939d5da65929 reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22637
diff changeset
754 JVM_ENTRY(void, JVM_RegisterJVMCINatives(JNIEnv *env, jclass c2vmClass))
939d5da65929 reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22637
diff changeset
755 #ifdef _LP64
939d5da65929 reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22637
diff changeset
756 #ifndef TARGET_ARCH_sparc
939d5da65929 reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22637
diff changeset
757 uintptr_t heap_end = (uintptr_t) Universe::heap()->reserved_region().end();
939d5da65929 reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22637
diff changeset
758 uintptr_t allocation_end = heap_end + ((uintptr_t)16) * 1024 * 1024 * 1024;
939d5da65929 reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22637
diff changeset
759 guarantee(heap_end < allocation_end, "heap end too close to end of address space (might lead to erroneous TLAB allocations)");
939d5da65929 reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22637
diff changeset
760 #endif // TARGET_ARCH_sparc
939d5da65929 reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22637
diff changeset
761 #else
939d5da65929 reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22637
diff changeset
762 fatal("check TLAB allocation code for address space conflicts");
939d5da65929 reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22637
diff changeset
763 #endif
939d5da65929 reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22637
diff changeset
764
939d5da65929 reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22637
diff changeset
765 JVMCIRuntime::ensure_jvmci_class_loader_is_initialized();
939d5da65929 reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22637
diff changeset
766
939d5da65929 reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22637
diff changeset
767 {
939d5da65929 reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22637
diff changeset
768 ThreadToNativeFromVM trans(thread);
939d5da65929 reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22637
diff changeset
769
939d5da65929 reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22637
diff changeset
770 ResourceMark rm;
939d5da65929 reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22637
diff changeset
771 HandleMark hm;
939d5da65929 reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22637
diff changeset
772
939d5da65929 reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22637
diff changeset
773 // Ensure _non_oop_bits is initialized
939d5da65929 reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22637
diff changeset
774 Universe::non_oop_word();
939d5da65929 reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22637
diff changeset
775
939d5da65929 reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22637
diff changeset
776 env->RegisterNatives(c2vmClass, CompilerToVM::methods, CompilerToVM::methods_count());
939d5da65929 reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22637
diff changeset
777 }
939d5da65929 reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22637
diff changeset
778 if (HAS_PENDING_EXCEPTION) {
939d5da65929 reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22637
diff changeset
779 JVMCIRuntime::abort_on_pending_exception(PENDING_EXCEPTION, "Could not register natives");
939d5da65929 reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22637
diff changeset
780 }
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
781 JVM_END
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
782
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
783 void JVMCIRuntime::ensure_jvmci_class_loader_is_initialized() {
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
784 // This initialization code is guarded by a static pointer to the Factory class.
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
785 // Once it is non-null, the JVMCI class loader and well known JVMCI classes are
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
786 // guaranteed to have been initialized. By going through the static
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
787 // initializer of Factory, we can rely on class initialization semantics to
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
788 // synchronize threads racing to do the initialization.
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
789 static Klass* _FactoryKlass = NULL;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
790 if (_FactoryKlass == NULL) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
791 Thread* THREAD = Thread::current();
22761
f2206f5bb62e removed @ServiceProvider mechanism (GRAAL-1380)
Doug Simon <doug.simon@oracle.com>
parents: 22758
diff changeset
792 TempNewSymbol name = SymbolTable::new_symbol("jdk/vm/ci/services/JVMCIClassLoaderFactory", CHECK_ABORT);
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
793 KlassHandle klass = SystemDictionary::resolve_or_fail(name, true, THREAD);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
794 if (HAS_PENDING_EXCEPTION) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
795 static volatile int seen_error = 0;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
796 if (!seen_error && Atomic::cmpxchg(1, &seen_error, 0) == 0) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
797 // Only report the failure on the first thread that hits it
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
798 abort_on_pending_exception(PENDING_EXCEPTION, "JVMCI classes are not available");
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
799 } else {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
800 CLEAR_PENDING_EXCEPTION;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
801 // Give first thread time to report the error.
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
802 os::sleep(THREAD, 100, false);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
803 vm_abort(false);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
804 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
805 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
806
22551
71ea8d7db665 removed author tags in comments
Doug Simon <doug.simon@oracle.com>
parents: 22548
diff changeset
807 // We cannot use jvmciJavaClasses for this because we are currently in the
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
808 // process of initializing that mechanism.
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
809 TempNewSymbol field_name = SymbolTable::new_symbol("useJVMCIClassLoader", CHECK_ABORT);
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
810 fieldDescriptor field_desc;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
811 if (klass->find_field(field_name, vmSymbols::bool_signature(), &field_desc) == NULL) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
812 ResourceMark rm;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
813 fatal(err_msg("Invalid layout of %s at %s", field_name->as_C_string(), klass->external_name()));
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
814 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
815
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
816 InstanceKlass* ik = InstanceKlass::cast(klass());
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
817 address addr = ik->static_field_addr(field_desc.offset() - InstanceMirrorKlass::offset_of_static_fields());
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
818 *((jboolean *) addr) = (jboolean) UseJVMCIClassLoader;
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
819 klass->initialize(CHECK_ABORT);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
820 _FactoryKlass = klass();
21562
Doug Simon <doug.simon@oracle.com>
parents: 21519 21559
diff changeset
821 assert(!UseJVMCIClassLoader || SystemDictionary::jvmci_loader() != NULL, "JVMCI classloader should have been initialized");
23296
f41d4011035d reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22761
diff changeset
822
f41d4011035d reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22761
diff changeset
823 JVMCIJavaClasses::compute_offsets(THREAD);
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
824 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
825 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
826
23327
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
827 /**
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
828 * Closure for parsing a line from a *.properties file in jre/lib/jvmci/properties.
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
829 * The line must match the regular expression "[^=]+=.*". That is one or more
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
830 * characters other than '=' followed by '=' followed by zero or more characters.
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
831 * Everything before the '=' is the property name and everything after '=' is the value.
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
832 * Lines that start with '#' are treated as comments and ignored.
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
833 * No special processing of whitespace or any escape characters is performed.
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
834 * The last definition of a property "wins" (i.e., it overrides all earlier
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
835 * definitions of the property).
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
836 */
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
837 class JVMCIPropertiesFileClosure : public ParseClosure {
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
838 SystemProperty** _plist;
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
839 public:
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
840 JVMCIPropertiesFileClosure(SystemProperty** plist) : _plist(plist) {}
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
841 void do_line(char* line) {
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
842 if (line[0] == '#') {
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
843 // skip comment
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
844 return;
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
845 }
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
846 size_t len = strlen(line);
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
847 char* sep = strchr(line, '=');
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
848 if (sep == NULL) {
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
849 warn_and_abort("invalid format: could not find '=' character");
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
850 return;
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
851 }
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
852 if (sep == line) {
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
853 warn_and_abort("invalid format: name cannot be empty");
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
854 return;
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
855 }
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
856 *sep = '\0';
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
857 const char* name = line;
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
858 char* value = sep + 1;
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
859 Arguments::PropertyList_unique_add(_plist, name, value);
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
860 }
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
861 };
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
862
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
863 void JVMCIRuntime::init_system_properties(SystemProperty** plist) {
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
864 char jvmciDir[JVM_MAXPATHLEN];
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
865 const char* fileSep = os::file_separator();
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
866 jio_snprintf(jvmciDir, sizeof(jvmciDir), "%s%slib%sjvmci",
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
867 Arguments::get_java_home(), fileSep, fileSep, fileSep);
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
868 DIR* dir = os::opendir(jvmciDir);
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
869 if (dir != NULL) {
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
870 struct dirent *entry;
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
871 char *dbuf = NEW_C_HEAP_ARRAY(char, os::readdir_buf_size(jvmciDir), mtInternal);
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
872 JVMCIPropertiesFileClosure closure(plist);
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
873 const unsigned suffix_len = (unsigned)strlen(".properties");
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
874 while ((entry = os::readdir(dir, (dirent *) dbuf)) != NULL && !closure.is_aborted()) {
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
875 const char* name = entry->d_name;
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
876 if (strlen(name) > suffix_len && strcmp(name + strlen(name) - suffix_len, ".properties") == 0) {
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
877 char propertiesFilePath[JVM_MAXPATHLEN];
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
878 jio_snprintf(propertiesFilePath, sizeof(propertiesFilePath), "%s%s%s",jvmciDir, fileSep, name);
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
879 JVMCIRuntime::parse_lines(propertiesFilePath, &closure, false);
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
880 }
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
881 }
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
882 FREE_C_HEAP_ARRAY(char, dbuf, mtInternal);
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
883 os::closedir(dir);
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
884 }
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
885 }
19c85f6618ed re-add support for parsing jre/jvmci/*.properties files
Doug Simon <doug.simon@oracle.com>
parents: 23323
diff changeset
886
21519
cecb4e39521c Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21516
diff changeset
887 #define CHECK_WARN_ABORT_(message) THREAD); \
cecb4e39521c Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21516
diff changeset
888 if (HAS_PENDING_EXCEPTION) { \
cecb4e39521c Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21516
diff changeset
889 warning(message); \
cecb4e39521c Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21516
diff changeset
890 char buf[512]; \
cecb4e39521c Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21516
diff changeset
891 jio_snprintf(buf, 512, "Uncaught exception at %s:%d", __FILE__, __LINE__); \
21562
Doug Simon <doug.simon@oracle.com>
parents: 21519 21559
diff changeset
892 JVMCIRuntime::abort_on_pending_exception(PENDING_EXCEPTION, buf); \
21519
cecb4e39521c Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21516
diff changeset
893 return; \
cecb4e39521c Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21516
diff changeset
894 } \
cecb4e39521c Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21516
diff changeset
895 (void)(0
cecb4e39521c Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21516
diff changeset
896
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
897 Handle JVMCIRuntime::create_Service(const char* name, TRAPS) {
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
898 TempNewSymbol kname = SymbolTable::new_symbol(name, CHECK_NH);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
899 Klass* k = resolve_or_fail(kname, CHECK_NH);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
900 instanceKlassHandle klass(THREAD, k);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
901 klass->initialize(CHECK_NH);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
902 klass->check_valid_for_instantiation(true, CHECK_NH);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
903 JavaValue result(T_VOID);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
904 instanceHandle service = klass->allocate_instance_handle(CHECK_NH);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
905 JavaCalls::call_special(&result, service, klass, vmSymbols::object_initializer_name(), vmSymbols::void_method_signature(), THREAD);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
906 return service;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
907 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
908
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
909 void JVMCIRuntime::shutdown() {
21527
07b088d61d5d added HotSpotJVMCIRuntime* classes, replaced references to HotSpotGraalRuntime in VM with HotSpotJVMCIRuntime (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21526
diff changeset
910 if (_HotSpotJVMCIRuntime_instance != NULL) {
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
911 _shutdown_called = true;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
912 JavaThread* THREAD = JavaThread::current();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
913 HandleMark hm(THREAD);
22574
5a706439be63 Propagate exceptions up instead of aborting
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22553
diff changeset
914 Handle receiver = get_HotSpotJVMCIRuntime(CHECK_ABORT);
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
915 JavaValue result(T_VOID);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
916 JavaCallArguments args;
21616
4c146c9367b6 recast VM compilation request via JVMCI to be a HotSpot JVMCI event, removing the last direct reference to a Graal class in the VM (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21614
diff changeset
917 args.push_oop(receiver);
4c146c9367b6 recast VM compilation request via JVMCI to be a HotSpot JVMCI event, removing the last direct reference to a Graal class in the VM (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21614
diff changeset
918 JavaCalls::call_special(&result, receiver->klass(), vmSymbols::shutdown_method_name(), vmSymbols::void_method_signature(), &args, CHECK_ABORT);
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
919 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
920 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
921
23385
6ee2af864395 8156034: update 01
Josef Eisl <josef.eisl@jku.at>
parents: 23383
diff changeset
922 void JVMCIRuntime::bootstrap_finished(TRAPS) {
23383
0226d6bcb0d2 Notify the compiler on completion of a bootstrap (JDK-8156034)
Josef Eisl <josef.eisl@jku.at>
parents: 23379
diff changeset
923 if (_HotSpotJVMCIRuntime_instance != NULL) {
0226d6bcb0d2 Notify the compiler on completion of a bootstrap (JDK-8156034)
Josef Eisl <josef.eisl@jku.at>
parents: 23379
diff changeset
924 HandleMark hm(THREAD);
0226d6bcb0d2 Notify the compiler on completion of a bootstrap (JDK-8156034)
Josef Eisl <josef.eisl@jku.at>
parents: 23379
diff changeset
925 Handle receiver = get_HotSpotJVMCIRuntime(CHECK_ABORT);
0226d6bcb0d2 Notify the compiler on completion of a bootstrap (JDK-8156034)
Josef Eisl <josef.eisl@jku.at>
parents: 23379
diff changeset
926 JavaValue result(T_VOID);
0226d6bcb0d2 Notify the compiler on completion of a bootstrap (JDK-8156034)
Josef Eisl <josef.eisl@jku.at>
parents: 23379
diff changeset
927 JavaCallArguments args;
0226d6bcb0d2 Notify the compiler on completion of a bootstrap (JDK-8156034)
Josef Eisl <josef.eisl@jku.at>
parents: 23379
diff changeset
928 args.push_oop(receiver);
0226d6bcb0d2 Notify the compiler on completion of a bootstrap (JDK-8156034)
Josef Eisl <josef.eisl@jku.at>
parents: 23379
diff changeset
929 JavaCalls::call_special(&result, receiver->klass(), vmSymbols::bootstrapFinished_method_name(), vmSymbols::void_method_signature(), &args, CHECK_ABORT);
0226d6bcb0d2 Notify the compiler on completion of a bootstrap (JDK-8156034)
Josef Eisl <josef.eisl@jku.at>
parents: 23379
diff changeset
930 }
0226d6bcb0d2 Notify the compiler on completion of a bootstrap (JDK-8156034)
Josef Eisl <josef.eisl@jku.at>
parents: 23379
diff changeset
931 }
0226d6bcb0d2 Notify the compiler on completion of a bootstrap (JDK-8156034)
Josef Eisl <josef.eisl@jku.at>
parents: 23379
diff changeset
932
22575
569c82ebb96e Replace JVMCICompileWithC1Only with package based controls
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22574
diff changeset
933 bool JVMCIRuntime::treat_as_trivial(Method* method) {
22586
cf99b5e5b0b4 Fix race in initialization of trivial prefixes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22585
diff changeset
934 if (_HotSpotJVMCIRuntime_initialized) {
22609
c42b12eb270a trivial prefixes shoudl only apply to the compiler itself
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22602
diff changeset
935 oop loader = method->method_holder()->class_loader();
c42b12eb270a trivial prefixes shoudl only apply to the compiler itself
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22602
diff changeset
936 if (loader == NULL || loader == SystemDictionary::jvmci_loader()) {
c42b12eb270a trivial prefixes shoudl only apply to the compiler itself
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22602
diff changeset
937 for (int i = 0; i < _trivial_prefixes_count; i++) {
c42b12eb270a trivial prefixes shoudl only apply to the compiler itself
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22602
diff changeset
938 if (method->method_holder()->name()->starts_with(_trivial_prefixes[i])) {
c42b12eb270a trivial prefixes shoudl only apply to the compiler itself
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22602
diff changeset
939 return true;
c42b12eb270a trivial prefixes shoudl only apply to the compiler itself
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22602
diff changeset
940 }
22586
cf99b5e5b0b4 Fix race in initialization of trivial prefixes
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22585
diff changeset
941 }
22575
569c82ebb96e Replace JVMCICompileWithC1Only with package based controls
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22574
diff changeset
942 }
569c82ebb96e Replace JVMCICompileWithC1Only with package based controls
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22574
diff changeset
943 }
569c82ebb96e Replace JVMCICompileWithC1Only with package based controls
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22574
diff changeset
944 return false;
569c82ebb96e Replace JVMCICompileWithC1Only with package based controls
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22574
diff changeset
945 }
569c82ebb96e Replace JVMCICompileWithC1Only with package based controls
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22574
diff changeset
946
23379
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
947 CompLevel JVMCIRuntime::adjust_comp_level(methodHandle method, bool is_osr, CompLevel level, JavaThread* thread) {
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
948 if (!thread->adjusting_comp_level()) {
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
949 thread->set_adjusting_comp_level(true);
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
950 level = adjust_comp_level_inner(method, is_osr, level, thread);
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
951 thread->set_adjusting_comp_level(false);
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
952 }
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
953 return level;
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
954 }
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
955
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
956 CompLevel JVMCIRuntime::adjust_comp_level_inner(methodHandle method, bool is_osr, CompLevel level, JavaThread* thread) {
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
957 #ifdef COMPILERJVMCI
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
958 JVMCICompiler* compiler = JVMCICompiler::instance(thread);
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
959 if (compiler != NULL && compiler->is_bootstrapping()) {
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
960 return level;
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
961 }
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
962 #endif
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
963 if (!is_HotSpotJVMCIRuntime_initialized() || !_comp_level_adjustment) {
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
964 // JVMCI cannot participate in compilation scheduling until
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
965 // JVMCI is initialized and indicates it wants to participate.
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
966 return level;
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
967 }
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
968
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
969 #define CHECK_RETURN THREAD); \
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
970 if (HAS_PENDING_EXCEPTION) { \
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
971 Handle exception(THREAD, PENDING_EXCEPTION); \
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
972 CLEAR_PENDING_EXCEPTION; \
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
973 \
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
974 java_lang_Throwable::print(exception, tty); \
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
975 tty->cr(); \
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
976 java_lang_Throwable::print_stack_trace(exception(), tty); \
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
977 if (HAS_PENDING_EXCEPTION) { \
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
978 CLEAR_PENDING_EXCEPTION; \
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
979 } \
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
980 return level; \
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
981 } \
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
982 (void)(0
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
983
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
984 Thread* THREAD = thread;
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
985 HandleMark hm;
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
986 Handle receiver = JVMCIRuntime::get_HotSpotJVMCIRuntime(CHECK_RETURN);
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
987 Handle name;
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
988 Handle sig;
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
989 if (_comp_level_adjustment == JVMCIRuntime::by_full_signature) {
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
990 name = java_lang_String::create_from_symbol(method->name(), CHECK_RETURN);
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
991 sig = java_lang_String::create_from_symbol(method->signature(), CHECK_RETURN);
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
992 } else {
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
993 name = Handle();
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
994 sig = Handle();
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
995 }
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
996
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
997 JavaValue result(T_INT);
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
998 JavaCallArguments args;
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
999 args.push_oop(receiver);
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
1000 args.push_oop(method->method_holder()->java_mirror());
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
1001 args.push_oop(name());
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
1002 args.push_oop(sig());
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
1003 args.push_int(is_osr);
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
1004 args.push_int(level);
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
1005 JavaCalls::call_special(&result, receiver->klass(), vmSymbols::adjustCompilationLevel_name(),
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
1006 vmSymbols::adjustCompilationLevel_signature(), &args, CHECK_RETURN);
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
1007
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
1008 // An uncaught exception was thrown. Generally these
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
1009 // should be handled by the Java code in some useful way but if they leak
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
1010 // through to here report them instead of dying or silently ignoring them.
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
1011 if (HAS_PENDING_EXCEPTION) {
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
1012 Handle throwable = PENDING_EXCEPTION;
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
1013 CLEAR_PENDING_EXCEPTION;
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
1014
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
1015 java_lang_Throwable::print(throwable, tty);
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
1016 tty->cr();
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
1017 java_lang_Throwable::print_stack_trace(throwable(), tty);
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
1018 return level;
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
1019 }
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
1020 int comp_level = result.get_jint();
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
1021 if (comp_level < CompLevel_none || comp_level > CompLevel_full_optimization) {
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
1022 assert(false, "compilation level out of bounds");
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
1023 return level;
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
1024 }
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
1025 return (CompLevel) comp_level;
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
1026 #undef CHECK_RETURN
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
1027 }
24505bf61633 allow JVMCI compiler to change the compilation policy for a method (JDK-8152311)
Doug Simon <doug.simon@oracle.com>
parents: 23372
diff changeset
1028
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
1029 void JVMCIRuntime::abort_on_pending_exception(Handle exception, const char* message, bool dump_core) {
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1030 Thread* THREAD = Thread::current();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1031 CLEAR_PENDING_EXCEPTION;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1032 tty->print_raw_cr(message);
23329
bc5552dc384b Use VM routines to print stack traces from C++ code.
Roland Schatz <roland.schatz@oracle.com>
parents: 23327
diff changeset
1033
bc5552dc384b Use VM routines to print stack traces from C++ code.
Roland Schatz <roland.schatz@oracle.com>
parents: 23327
diff changeset
1034 java_lang_Throwable::print(exception, tty);
bc5552dc384b Use VM routines to print stack traces from C++ code.
Roland Schatz <roland.schatz@oracle.com>
parents: 23327
diff changeset
1035 tty->cr();
bc5552dc384b Use VM routines to print stack traces from C++ code.
Roland Schatz <roland.schatz@oracle.com>
parents: 23327
diff changeset
1036 java_lang_Throwable::print_stack_trace(exception(), tty);
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1037
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1038 // Give other aborting threads to also print their stack traces.
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1039 // This can be very useful when debugging class initialization
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1040 // failures.
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1041 os::sleep(THREAD, 200, false);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1042
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1043 vm_abort(dump_core);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1044 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1045
23392
b3a816d3b844 Backed out changeset: a920338dd4d4
Doug Simon <doug.simon@oracle.com>
parents: 23387
diff changeset
1046 void JVMCIRuntime::fthrow_error(Thread* thread, const char* file, int line, const char* format, ...) {
b3a816d3b844 Backed out changeset: a920338dd4d4
Doug Simon <doug.simon@oracle.com>
parents: 23387
diff changeset
1047 const int max_msg_size = 1024;
b3a816d3b844 Backed out changeset: a920338dd4d4
Doug Simon <doug.simon@oracle.com>
parents: 23387
diff changeset
1048 va_list ap;
b3a816d3b844 Backed out changeset: a920338dd4d4
Doug Simon <doug.simon@oracle.com>
parents: 23387
diff changeset
1049 va_start(ap, format);
b3a816d3b844 Backed out changeset: a920338dd4d4
Doug Simon <doug.simon@oracle.com>
parents: 23387
diff changeset
1050 char msg[max_msg_size];
b3a816d3b844 Backed out changeset: a920338dd4d4
Doug Simon <doug.simon@oracle.com>
parents: 23387
diff changeset
1051 vsnprintf(msg, max_msg_size, format, ap);
b3a816d3b844 Backed out changeset: a920338dd4d4
Doug Simon <doug.simon@oracle.com>
parents: 23387
diff changeset
1052 msg[max_msg_size-1] = '\0';
b3a816d3b844 Backed out changeset: a920338dd4d4
Doug Simon <doug.simon@oracle.com>
parents: 23387
diff changeset
1053 va_end(ap);
b3a816d3b844 Backed out changeset: a920338dd4d4
Doug Simon <doug.simon@oracle.com>
parents: 23387
diff changeset
1054 Handle h_loader = Handle(thread, SystemDictionary::jvmci_loader());
b3a816d3b844 Backed out changeset: a920338dd4d4
Doug Simon <doug.simon@oracle.com>
parents: 23387
diff changeset
1055 Handle h_protection_domain = Handle();
b3a816d3b844 Backed out changeset: a920338dd4d4
Doug Simon <doug.simon@oracle.com>
parents: 23387
diff changeset
1056 Exceptions::_throw_msg(thread, file, line, vmSymbols::jdk_vm_ci_common_JVMCIError(), msg, h_loader, h_protection_domain);
b3a816d3b844 Backed out changeset: a920338dd4d4
Doug Simon <doug.simon@oracle.com>
parents: 23387
diff changeset
1057 }
b3a816d3b844 Backed out changeset: a920338dd4d4
Doug Simon <doug.simon@oracle.com>
parents: 23387
diff changeset
1058
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
1059 Klass* JVMCIRuntime::resolve_or_null(Symbol* name, TRAPS) {
23296
f41d4011035d reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22761
diff changeset
1060 assert(!UseJVMCIClassLoader || SystemDictionary::jvmci_loader() != NULL, "JVMCI classloader should have been initialized");
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
1061 return SystemDictionary::resolve_or_null(name, SystemDictionary::jvmci_loader(), Handle(), CHECK_NULL);
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1062 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1063
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
1064 Klass* JVMCIRuntime::resolve_or_fail(Symbol* name, TRAPS) {
23296
f41d4011035d reduced delta against jvmci-9
Doug Simon <doug.simon@oracle.com>
parents: 22761
diff changeset
1065 assert(!UseJVMCIClassLoader || SystemDictionary::jvmci_loader() != NULL, "JVMCI classloader should have been initialized");
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
1066 return SystemDictionary::resolve_or_fail(name, SystemDictionary::jvmci_loader(), Handle(), true, CHECK_NULL);
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1067 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1068
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 21554
diff changeset
1069 Klass* JVMCIRuntime::load_required_class(Symbol* name) {
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1070 Klass* klass = resolve_or_null(name, Thread::current());
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1071 if (klass == NULL) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1072 tty->print_cr("Could not load class %s", name->as_C_string());
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1073 vm_abort(false);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1074 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1075 return klass;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1076 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1077
21562
Doug Simon <doug.simon@oracle.com>
parents: 21519 21559
diff changeset
1078 void JVMCIRuntime::parse_lines(char* path, ParseClosure* closure, bool warnStatFailure) {
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1079 struct stat st;
22553
114750c43459 JVMCIRuntime::parse_properties use ::read instead of os::read
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 22551
diff changeset
1080 if (::stat(path, &st) == 0 && (st.st_mode & S_IFREG) == S_IFREG) { // exists & is regular file
22589
ca8e46278bae Create default for os::default_file_open_flags on Solaris; JVMCIRuntime::parse_lines: use ::open instead of os::open
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 22588
diff changeset
1081 int file_handle = ::open(path, os::default_file_open_flags(), 0);
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1082 if (file_handle != -1) {
21519
cecb4e39521c Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21516
diff changeset
1083 char* buffer = NEW_C_HEAP_ARRAY(char, st.st_size + 1, mtInternal);
21626
ca3c6538bcec JVMCI update makefiles for Solaris/SPARC; os::read at early stage of VM does not work, use ::read as fallback in JVMCIRuntime::parse_lines (JBS:GRAAL-54)
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 21617
diff changeset
1084 int num_read;
22553
114750c43459 JVMCIRuntime::parse_properties use ::read instead of os::read
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 22551
diff changeset
1085 num_read = (int) ::read(file_handle, (char*) buffer, st.st_size);
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1086 if (num_read == -1) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1087 warning("Error reading file %s due to %s", path, strerror(errno));
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1088 } else if (num_read != st.st_size) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1089 warning("Only read %d of " SIZE_FORMAT " bytes from %s", num_read, (size_t) st.st_size, path);
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1090 }
22553
114750c43459 JVMCIRuntime::parse_properties use ::read instead of os::read
Stefan Anzinger <stefan.anzinger@oracle.com>
parents: 22551
diff changeset
1091 ::close(file_handle);
21519
cecb4e39521c Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21516
diff changeset
1092 closure->set_filename(path);
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1093 if (num_read == st.st_size) {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1094 buffer[num_read] = '\0';
21515
1ab7802d35c9 Factor GraalRuntime::parse_lines out of GraalRuntime::get_service_impls
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21207
diff changeset
1095
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1096 char* line = buffer;
21519
cecb4e39521c Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21516
diff changeset
1097 while (line - buffer < num_read && !closure->is_aborted()) {
21123
85b0935625c1 graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21033
diff changeset
1098 // find line end (\r, \n or \r\n)
85b0935625c1 graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21033
diff changeset
1099 char* nextline = NULL;
85b0935625c1 graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21033
diff changeset
1100 char* cr = strchr(line, '\r');
85b0935625c1 graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21033
diff changeset
1101 char* lf = strchr(line, '\n');
85b0935625c1 graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21033
diff changeset
1102 if (cr != NULL && lf != NULL) {
85b0935625c1 graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21033
diff changeset
1103 char* min = MIN2(cr, lf);
85b0935625c1 graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21033
diff changeset
1104 *min = '\0';
85b0935625c1 graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21033
diff changeset
1105 if (lf == cr + 1) {
85b0935625c1 graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21033
diff changeset
1106 nextline = lf + 1;
85b0935625c1 graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21033
diff changeset
1107 } else {
85b0935625c1 graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21033
diff changeset
1108 nextline = min + 1;
85b0935625c1 graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21033
diff changeset
1109 }
85b0935625c1 graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21033
diff changeset
1110 } else if (cr != NULL) {
85b0935625c1 graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21033
diff changeset
1111 *cr = '\0';
85b0935625c1 graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21033
diff changeset
1112 nextline = cr + 1;
85b0935625c1 graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21033
diff changeset
1113 } else if (lf != NULL) {
85b0935625c1 graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21033
diff changeset
1114 *lf = '\0';
85b0935625c1 graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21033
diff changeset
1115 nextline = lf + 1;
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1116 }
21123
85b0935625c1 graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21033
diff changeset
1117 // trim left
85b0935625c1 graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21033
diff changeset
1118 while (*line == ' ' || *line == '\t') line++;
85b0935625c1 graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21033
diff changeset
1119 char* end = line + strlen(line);
85b0935625c1 graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21033
diff changeset
1120 // trim right
85b0935625c1 graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21033
diff changeset
1121 while (end > line && (*(end -1) == ' ' || *(end -1) == '\t')) end--;
85b0935625c1 graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21033
diff changeset
1122 *end = '\0';
85b0935625c1 graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21033
diff changeset
1123 // skip comments and empty lines
85b0935625c1 graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21033
diff changeset
1124 if (*line != '#' && strlen(line) > 0) {
21519
cecb4e39521c Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21516
diff changeset
1125 closure->parse_line(line);
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1126 }
21123
85b0935625c1 graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21033
diff changeset
1127 if (nextline != NULL) {
85b0935625c1 graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21033
diff changeset
1128 line = nextline;
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1129 } else {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1130 // File without newline at the end
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1131 break;
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1132 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1133 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1134 }
21519
cecb4e39521c Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21516
diff changeset
1135 FREE_C_HEAP_ARRAY(char, buffer, mtInternal);
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1136 } else {
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1137 warning("Error opening file %s due to %s", path, strerror(errno));
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1138 }
21519
cecb4e39521c Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21516
diff changeset
1139 } else if (warnStatFailure) {
cecb4e39521c Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21516
diff changeset
1140 warning("Could not stat file %s due to %s", path, strerror(errno));
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1141 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1142 }
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1143
21515
1ab7802d35c9 Factor GraalRuntime::parse_lines out of GraalRuntime::get_service_impls
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21207
diff changeset
1144 class ServiceParseClosure : public ParseClosure {
1ab7802d35c9 Factor GraalRuntime::parse_lines out of GraalRuntime::get_service_impls
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21207
diff changeset
1145 GrowableArray<char*> _implNames;
1ab7802d35c9 Factor GraalRuntime::parse_lines out of GraalRuntime::get_service_impls
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21207
diff changeset
1146 public:
1ab7802d35c9 Factor GraalRuntime::parse_lines out of GraalRuntime::get_service_impls
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21207
diff changeset
1147 ServiceParseClosure() : _implNames() {}
1ab7802d35c9 Factor GraalRuntime::parse_lines out of GraalRuntime::get_service_impls
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21207
diff changeset
1148 void do_line(char* line) {
21519
cecb4e39521c Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21516
diff changeset
1149 size_t lineLen = strlen(line);
21876
d358434dd6b7 Use ressource array while parsing services rather than leak a heap array
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21875
diff changeset
1150 char* implName = NEW_RESOURCE_ARRAY(char, lineLen + 1);
21515
1ab7802d35c9 Factor GraalRuntime::parse_lines out of GraalRuntime::get_service_impls
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21207
diff changeset
1151 // Turn all '.'s into '/'s
21519
cecb4e39521c Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21516
diff changeset
1152 for (size_t index = 0; index < lineLen; ++index) {
21515
1ab7802d35c9 Factor GraalRuntime::parse_lines out of GraalRuntime::get_service_impls
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21207
diff changeset
1153 if (line[index] == '.') {
21519
cecb4e39521c Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21516
diff changeset
1154 implName[index] = '/';
cecb4e39521c Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21516
diff changeset
1155 } else {
cecb4e39521c Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21516
diff changeset
1156 implName[index] = line[index];
21515
1ab7802d35c9 Factor GraalRuntime::parse_lines out of GraalRuntime::get_service_impls
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21207
diff changeset
1157 }
1ab7802d35c9 Factor GraalRuntime::parse_lines out of GraalRuntime::get_service_impls
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21207
diff changeset
1158 }
21519
cecb4e39521c Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21516
diff changeset
1159 implName[lineLen] = '\0';
cecb4e39521c Use files in lib/graal/options to define Graal options (-G:...) instead of generating code for them
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21516
diff changeset
1160 _implNames.append(implName);
21515
1ab7802d35c9 Factor GraalRuntime::parse_lines out of GraalRuntime::get_service_impls
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21207
diff changeset
1161 }
1ab7802d35c9 Factor GraalRuntime::parse_lines out of GraalRuntime::get_service_impls
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21207
diff changeset
1162 GrowableArray<char*>* implNames() {return &_implNames;}
1ab7802d35c9 Factor GraalRuntime::parse_lines out of GraalRuntime::get_service_impls
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21207
diff changeset
1163 };
1ab7802d35c9 Factor GraalRuntime::parse_lines out of GraalRuntime::get_service_impls
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21207
diff changeset
1164
1ab7802d35c9 Factor GraalRuntime::parse_lines out of GraalRuntime::get_service_impls
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21207
diff changeset
1165
21563
4f63449b4422 revived post option parsing handler notification
Doug Simon <doug.simon@oracle.com>
parents: 21562
diff changeset
1166 objArrayHandle JVMCIRuntime::get_service_impls(KlassHandle serviceKlass, TRAPS) {
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1167 const char* home = Arguments::get_java_home();
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1168 const char* serviceName = serviceKlass->external_name();
22401
31e0737e2fce added -XX:JVMCIServicesDir for specifying an alternative to <jre>/lib/jvmci/services
Doug Simon <doug.simon@oracle.com>
parents: 22398
diff changeset
1169 char* path;
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1170 char sep = os::file_separator()[0];
22401
31e0737e2fce added -XX:JVMCIServicesDir for specifying an alternative to <jre>/lib/jvmci/services
Doug Simon <doug.simon@oracle.com>
parents: 22398
diff changeset
1171 if (JVMCIServicesDir == NULL) {
31e0737e2fce added -XX:JVMCIServicesDir for specifying an alternative to <jre>/lib/jvmci/services
Doug Simon <doug.simon@oracle.com>
parents: 22398
diff changeset
1172 size_t path_len = strlen(home) + strlen("/lib/jvmci/services/") + strlen(serviceName) + 1;
31e0737e2fce added -XX:JVMCIServicesDir for specifying an alternative to <jre>/lib/jvmci/services
Doug Simon <doug.simon@oracle.com>
parents: 22398
diff changeset
1173 path = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, path_len);
31e0737e2fce added -XX:JVMCIServicesDir for specifying an alternative to <jre>/lib/jvmci/services
Doug Simon <doug.simon@oracle.com>
parents: 22398
diff changeset
1174 sprintf(path, "%s%clib%cjvmci%cservices%c%s", home, sep, sep, sep, sep, serviceName);
31e0737e2fce added -XX:JVMCIServicesDir for specifying an alternative to <jre>/lib/jvmci/services
Doug Simon <doug.simon@oracle.com>
parents: 22398
diff changeset
1175 } else {
31e0737e2fce added -XX:JVMCIServicesDir for specifying an alternative to <jre>/lib/jvmci/services
Doug Simon <doug.simon@oracle.com>
parents: 22398
diff changeset
1176 size_t path_len = strlen(JVMCIServicesDir) + strlen(serviceName) + 1;
31e0737e2fce added -XX:JVMCIServicesDir for specifying an alternative to <jre>/lib/jvmci/services
Doug Simon <doug.simon@oracle.com>
parents: 22398
diff changeset
1177 path = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, path_len);
31e0737e2fce added -XX:JVMCIServicesDir for specifying an alternative to <jre>/lib/jvmci/services
Doug Simon <doug.simon@oracle.com>
parents: 22398
diff changeset
1178 sprintf(path, "%s%c%s", JVMCIServicesDir, sep, serviceName);
31e0737e2fce added -XX:JVMCIServicesDir for specifying an alternative to <jre>/lib/jvmci/services
Doug Simon <doug.simon@oracle.com>
parents: 22398
diff changeset
1179 }
21515
1ab7802d35c9 Factor GraalRuntime::parse_lines out of GraalRuntime::get_service_impls
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21207
diff changeset
1180 ServiceParseClosure closure;
21633
9966b358bc2b Services: don't throw exceptions or print warnings when there are no implementations for a non-required service
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21626
diff changeset
1181 parse_lines(path, &closure, false);
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1182
21515
1ab7802d35c9 Factor GraalRuntime::parse_lines out of GraalRuntime::get_service_impls
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21207
diff changeset
1183 GrowableArray<char*>* implNames = closure.implNames();
21563
4f63449b4422 revived post option parsing handler notification
Doug Simon <doug.simon@oracle.com>
parents: 21562
diff changeset
1184 objArrayOop servicesOop = oopFactory::new_objArray(serviceKlass(), implNames->length(), CHECK_(objArrayHandle()));
21515
1ab7802d35c9 Factor GraalRuntime::parse_lines out of GraalRuntime::get_service_impls
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21207
diff changeset
1185 objArrayHandle services(THREAD, servicesOop);
1ab7802d35c9 Factor GraalRuntime::parse_lines out of GraalRuntime::get_service_impls
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21207
diff changeset
1186 for (int i = 0; i < implNames->length(); ++i) {
1ab7802d35c9 Factor GraalRuntime::parse_lines out of GraalRuntime::get_service_impls
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21207
diff changeset
1187 char* implName = implNames->at(i);
21563
4f63449b4422 revived post option parsing handler notification
Doug Simon <doug.simon@oracle.com>
parents: 21562
diff changeset
1188 Handle service = create_Service(implName, CHECK_(objArrayHandle()));
21515
1ab7802d35c9 Factor GraalRuntime::parse_lines out of GraalRuntime::get_service_impls
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21207
diff changeset
1189 services->obj_at_put(i, service());
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1190 }
21515
1ab7802d35c9 Factor GraalRuntime::parse_lines out of GraalRuntime::get_service_impls
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21207
diff changeset
1191 return services;
21033
4527d2428f37 Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents: 21031
diff changeset
1192 }