Mercurial > hg > graal-compiler
annotate src/share/vm/graal/graalRuntime.cpp @ 21554:b1530a6cce8c
renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 26 May 2015 23:21:15 +0200 |
parents | 5324104ac4f3 |
children |
rev | line source |
---|---|
21033
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1 /* |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. |
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" |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
26 #include "compiler/compileBroker.hpp" |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
27 #include "compiler/disassembler.hpp" |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
28 #include "graal/graalRuntime.hpp" |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
29 #include "graal/graalCompilerToVM.hpp" |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
30 #include "graal/graalCompiler.hpp" |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
31 #include "graal/graalJavaAccess.hpp" |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
32 #include "graal/graalEnv.hpp" |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
33 #include "memory/oopFactory.hpp" |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
34 #include "prims/jvm.h" |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
35 #include "runtime/biasedLocking.hpp" |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
36 #include "runtime/interfaceSupport.hpp" |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
37 #include "runtime/arguments.hpp" |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
38 #include "runtime/reflection.hpp" |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
39 #include "utilities/debug.hpp" |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
40 |
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
|
41 jobject GraalRuntime::_HotSpotJVMCIRuntime_instance = NULL; |
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
|
42 bool GraalRuntime::_HotSpotJVMCIRuntime_initialized = false; |
21033
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
43 bool GraalRuntime::_shutdown_called = false; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
44 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
45 void GraalRuntime::initialize_natives(JNIEnv *env, jclass c2vmClass) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
46 uintptr_t heap_end = (uintptr_t) Universe::heap()->reserved_region().end(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
47 uintptr_t allocation_end = heap_end + ((uintptr_t)16) * 1024 * 1024 * 1024; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
48 AMD64_ONLY(guarantee(heap_end < allocation_end, "heap end too close to end of address space (might lead to erroneous TLAB allocations)")); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
49 NOT_LP64(error("check TLAB allocation code for address space conflicts")); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
50 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
51 ensure_graal_class_loader_is_initialized(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
52 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
53 JavaThread* THREAD = JavaThread::current(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
54 { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
55 ThreadToNativeFromVM trans(THREAD); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
56 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
57 ResourceMark rm; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
58 HandleMark hm; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
59 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
60 graal_compute_offsets(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
61 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
62 // Ensure _non_oop_bits is initialized |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
63 Universe::non_oop_word(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
64 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
65 env->RegisterNatives(c2vmClass, CompilerToVM_methods, CompilerToVM_methods_count()); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
66 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
67 if (HAS_PENDING_EXCEPTION) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
68 abort_on_pending_exception(PENDING_EXCEPTION, "Could not register natives"); |
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 BufferBlob* GraalRuntime::initialize_buffer_blob() { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
73 JavaThread* THREAD = JavaThread::current(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
74 BufferBlob* buffer_blob = THREAD->get_buffer_blob(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
75 if (buffer_blob == NULL) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
76 buffer_blob = BufferBlob::create("Graal thread-local CodeBuffer", GraalNMethodSizeLimit); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
77 if (buffer_blob != NULL) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
78 THREAD->set_buffer_blob(buffer_blob); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
79 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
80 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
81 return buffer_blob; |
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 BasicType GraalRuntime::kindToBasicType(jchar ch) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
85 switch(ch) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
86 case 'z': return T_BOOLEAN; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
87 case 'b': return T_BYTE; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
88 case 's': return T_SHORT; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
89 case 'c': return T_CHAR; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
90 case 'i': return T_INT; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
91 case 'f': return T_FLOAT; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
92 case 'j': return T_LONG; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
93 case 'd': return T_DOUBLE; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
94 case 'a': return T_OBJECT; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
95 case '-': return T_ILLEGAL; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
96 default: |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
97 fatal(err_msg("unexpected Kind: %c", ch)); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
98 break; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
99 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
100 return T_ILLEGAL; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
101 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
102 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
103 // 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
|
104 // 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
|
105 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
106 static bool caller_is_deopted() { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
107 JavaThread* thread = JavaThread::current(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
108 RegisterMap reg_map(thread, false); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
109 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
|
110 frame caller_frame = runtime_frame.sender(®_map); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
111 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
|
112 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
|
113 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
114 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
115 // Stress deoptimization |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
116 static void deopt_caller() { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
117 if ( !caller_is_deopted()) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
118 JavaThread* thread = JavaThread::current(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
119 RegisterMap reg_map(thread, false); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
120 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
|
121 frame caller_frame = runtime_frame.sender(®_map); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
122 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
|
123 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
|
124 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
125 } |
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 JRT_BLOCK_ENTRY(void, GraalRuntime::new_instance(JavaThread* thread, Klass* klass)) |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
128 JRT_BLOCK; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
129 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
|
130 instanceKlassHandle h(thread, klass); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
131 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
|
132 // make sure klass is initialized |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
133 h->initialize(CHECK); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
134 // 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
|
135 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
|
136 thread->set_vm_result(obj); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
137 JRT_BLOCK_END; |
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 if (GraalDeferredInitBarriers) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
140 new_store_pre_barrier(thread); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
141 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
142 JRT_END |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
143 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
144 JRT_BLOCK_ENTRY(void, GraalRuntime::new_array(JavaThread* thread, Klass* array_klass, jint length)) |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
145 JRT_BLOCK; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
146 // 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
|
147 // 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
|
148 // (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
|
149 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
|
150 oop obj; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
151 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
|
152 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
|
153 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
|
154 } else { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
155 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
|
156 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
|
157 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
158 thread->set_vm_result(obj); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
159 // 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
|
160 // 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
|
161 if (DeoptimizeALot) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
162 static int deopts = 0; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
163 // 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
|
164 if (deopts++ % 2 == 0) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
165 ResourceMark rm(THREAD); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
166 THROW(vmSymbols::java_lang_OutOfMemoryError()); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
167 } else { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
168 deopt_caller(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
169 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
170 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
171 JRT_BLOCK_END; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
172 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
173 if (GraalDeferredInitBarriers) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
174 new_store_pre_barrier(thread); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
175 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
176 JRT_END |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
177 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
178 void GraalRuntime::new_store_pre_barrier(JavaThread* thread) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
179 // 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
|
180 // 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
|
181 // 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
|
182 // 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
|
183 // 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
|
184 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
185 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
|
186 if (new_obj == NULL) return; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
187 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
188 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
|
189 "compiler must check this first"); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
190 // 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
|
191 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
|
192 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
|
193 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
194 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
195 JRT_ENTRY(void, GraalRuntime::new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims)) |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
196 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
|
197 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
|
198 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
|
199 thread->set_vm_result(obj); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
200 JRT_END |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
201 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
202 JRT_ENTRY(void, GraalRuntime::dynamic_new_array(JavaThread* thread, oopDesc* element_mirror, jint length)) |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
203 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
|
204 thread->set_vm_result(obj); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
205 JRT_END |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
206 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
207 JRT_ENTRY(void, GraalRuntime::dynamic_new_instance(JavaThread* thread, oopDesc* type_mirror)) |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
208 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
|
209 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
210 if (klass == NULL) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
211 ResourceMark rm(THREAD); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
212 THROW(vmSymbols::java_lang_InstantiationException()); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
213 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
214 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
215 // Create new instance (the receiver) |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
216 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
|
217 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
218 // Make sure klass gets initialized |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
219 klass->initialize(CHECK); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
220 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
221 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
|
222 thread->set_vm_result(obj); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
223 JRT_END |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
224 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
225 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
|
226 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
227 // 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
|
228 // 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
|
229 // 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
|
230 // 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
|
231 // 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
|
232 // cpu directories. |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
233 // |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
234 // 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
|
235 // 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
|
236 // 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
|
237 // 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
|
238 // 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
|
239 // 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
|
240 // 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
|
241 // 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
|
242 // 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
|
243 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
|
244 // Reset method handle flag. |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
245 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
|
246 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
247 Handle exception(thread, ex); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
248 nm = CodeCache::find_nmethod(pc); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
249 assert(nm != NULL, "this is not an nmethod"); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
250 // Adjust the pc as needed/ |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
251 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
|
252 RegisterMap map(thread, false); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
253 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
|
254 // 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
|
255 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
|
256 pc = exception_frame.pc(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
257 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
258 #ifdef ASSERT |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
259 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
|
260 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
|
261 // 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
|
262 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
|
263 if (ExitVMOnVerifyError) vm_exit(-1); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
264 ShouldNotReachHere(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
265 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
266 #endif |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
267 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
268 // 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
|
269 // 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
|
270 // pages are enabled. |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
271 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
|
272 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
|
273 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
274 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
|
275 // 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
|
276 // 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
|
277 // 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
|
278 // 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
|
279 // 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
|
280 // 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
|
281 // 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
|
282 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
283 RegisterMap reg_map(thread); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
284 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
|
285 frame caller_frame = stub_frame.sender(®_map); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
286 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
287 // 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
|
288 // 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
|
289 // 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
|
290 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
|
291 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
|
292 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
293 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
|
294 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
295 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
296 // 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
|
297 if (guard_pages_enabled) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
298 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
|
299 if (fast_continuation != NULL) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
300 // 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
|
301 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
|
302 return fast_continuation; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
303 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
304 } |
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 // 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
|
307 // 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
|
308 // 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
|
309 address continuation = NULL; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
310 if (guard_pages_enabled) { |
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 // 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
|
313 // 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
|
314 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
315 // debugging support |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
316 // tracing |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
317 if (TraceExceptions) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
318 ttyLocker ttyl; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
319 ResourceMark rm; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
320 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
|
321 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
|
322 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
323 // for AbortVMOnException flag |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
324 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
|
325 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
326 // 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
|
327 // 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
|
328 // 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
|
329 // normal bytecode execution. |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
330 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
|
331 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
332 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
|
333 // 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
|
334 thread->set_exception_oop(exception()); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
335 thread->set_exception_pc(pc); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
336 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
337 // 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
|
338 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
|
339 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
|
340 } |
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 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
343 // 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
|
344 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
|
345 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
346 if (TraceExceptions) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
347 ttyLocker ttyl; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
348 ResourceMark rm; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
349 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
|
350 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
|
351 } |
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 return continuation; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
354 JRT_END |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
355 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
356 // 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
|
357 // 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
|
358 // 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
|
359 // 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
|
360 // searched for an exception handler has been deoptimized in the meantime. |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
361 address GraalRuntime::exception_handler_for_pc(JavaThread* thread) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
362 oop exception = thread->exception_oop(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
363 address pc = thread->exception_pc(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
364 // Still in Java mode |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
365 DEBUG_ONLY(ResetNoHandleMark rnhm); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
366 nmethod* nm = NULL; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
367 address continuation = NULL; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
368 { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
369 // 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
|
370 ResetNoHandleMark rnhm; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
371 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
|
372 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
373 // 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
|
374 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
375 // Now check to see if the nmethod we were called from is now deoptimized. |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
376 // 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
|
377 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
|
378 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
|
379 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
380 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
381 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
|
382 return continuation; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
383 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
384 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
385 JRT_ENTRY(void, GraalRuntime::create_null_exception(JavaThread* thread)) |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
386 SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_NullPointerException()); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
387 thread->set_vm_result(PENDING_EXCEPTION); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
388 CLEAR_PENDING_EXCEPTION; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
389 JRT_END |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
390 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
391 JRT_ENTRY(void, GraalRuntime::create_out_of_bounds_exception(JavaThread* thread, jint index)) |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
392 char message[jintAsStringSize]; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
393 sprintf(message, "%d", index); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
394 SharedRuntime::throw_and_post_jvmti_exception(thread, vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), message); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
395 thread->set_vm_result(PENDING_EXCEPTION); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
396 CLEAR_PENDING_EXCEPTION; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
397 JRT_END |
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 JRT_ENTRY_NO_ASYNC(void, GraalRuntime::monitorenter(JavaThread* thread, oopDesc* obj, BasicLock* lock)) |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
400 if (TraceGraal >= 3) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
401 char type[O_BUFLEN]; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
402 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
|
403 markOop mark = obj->mark(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
404 tty->print_cr("%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)); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
405 tty->flush(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
406 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
407 #ifdef ASSERT |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
408 if (PrintBiasedLockingStatistics) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
409 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
|
410 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
411 #endif |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
412 Handle h_obj(thread, obj); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
413 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
|
414 if (UseBiasedLocking) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
415 // 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
|
416 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
|
417 } else { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
418 if (GraalUseFastLocking) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
419 // 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
|
420 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
|
421 } else { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
422 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
|
423 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
424 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
425 if (TraceGraal >= 3) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
426 tty->print_cr("%s: exiting locking slow with obj=" INTPTR_FORMAT, thread->name(), p2i(obj)); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
427 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
428 JRT_END |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
429 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
430 JRT_LEAF(void, GraalRuntime::monitorexit(JavaThread* thread, oopDesc* obj, BasicLock* lock)) |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
431 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
|
432 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
|
433 // 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
|
434 EXCEPTION_MARK; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
435 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
436 #ifdef DEBUG |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
437 if (!obj->is_oop()) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
438 ResetNoHandleMark rhm; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
439 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
|
440 if (method != NULL) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
441 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
|
442 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
443 thread->print_stack_on(tty); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
444 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
|
445 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
446 #endif |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
447 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
448 if (GraalUseFastLocking) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
449 // 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
|
450 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
|
451 } else { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
452 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
|
453 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
454 if (TraceGraal >= 3) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
455 char type[O_BUFLEN]; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
456 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
|
457 tty->print_cr("%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)); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
458 tty->flush(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
459 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
460 JRT_END |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
461 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
462 JRT_LEAF(void, GraalRuntime::log_object(JavaThread* thread, oopDesc* obj, jint flags)) |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
463 bool string = mask_bits_are_true(flags, LOG_OBJECT_STRING); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
464 bool addr = mask_bits_are_true(flags, LOG_OBJECT_ADDRESS); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
465 bool newline = mask_bits_are_true(flags, LOG_OBJECT_NEWLINE); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
466 if (!string) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
467 if (!addr && obj->is_oop_or_null(true)) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
468 char buf[O_BUFLEN]; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
469 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
|
470 } else { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
471 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
|
472 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
473 } else { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
474 ResourceMark rm; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
475 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
|
476 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
|
477 tty->print_raw(buf); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
478 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
479 if (newline) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
480 tty->cr(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
481 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
482 JRT_END |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
483 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
484 JRT_LEAF(void, GraalRuntime::write_barrier_pre(JavaThread* thread, oopDesc* obj)) |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
485 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
|
486 JRT_END |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
487 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
488 JRT_LEAF(void, GraalRuntime::write_barrier_post(JavaThread* thread, void* card_addr)) |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
489 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
|
490 JRT_END |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
491 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
492 JRT_LEAF(jboolean, GraalRuntime::validate_object(JavaThread* thread, oopDesc* parent, oopDesc* child)) |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
493 bool ret = true; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
494 if(!Universe::heap()->is_in_closed_subset(parent)) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
495 tty->print_cr("Parent Object "INTPTR_FORMAT" not in heap", p2i(parent)); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
496 parent->print(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
497 ret=false; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
498 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
499 if(!Universe::heap()->is_in_closed_subset(child)) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
500 tty->print_cr("Child Object "INTPTR_FORMAT" not in heap", p2i(child)); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
501 child->print(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
502 ret=false; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
503 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
504 return (jint)ret; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
505 JRT_END |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
506 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
507 JRT_ENTRY(void, GraalRuntime::vm_error(JavaThread* thread, jlong where, jlong format, jlong value)) |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
508 ResourceMark rm; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
509 const char *error_msg = where == 0L ? "<internal Graal error>" : (char*) (address) where; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
510 char *detail_msg = NULL; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
511 if (format != 0L) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
512 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
|
513 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
|
514 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
|
515 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
|
516 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
517 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
|
518 JRT_END |
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 JRT_LEAF(oopDesc*, GraalRuntime::load_and_clear_exception(JavaThread* thread)) |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
521 oop exception = thread->exception_oop(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
522 assert(exception != NULL, "npe"); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
523 thread->set_exception_oop(NULL); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
524 thread->set_exception_pc(0); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
525 return exception; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
526 JRT_END |
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 JRT_LEAF(void, GraalRuntime::log_printf(JavaThread* thread, oopDesc* format, jlong v1, jlong v2, jlong v3)) |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
529 ResourceMark rm; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
530 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
|
531 char *buf = java_lang_String::as_utf8_string(format); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
532 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
|
533 JRT_END |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
534 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
535 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
|
536 if (v != 0 || !ignoreZero) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
537 void* p = (void *)(address) v; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
538 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
|
539 if (cb) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
540 if (cb->is_nmethod()) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
541 char buf[O_BUFLEN]; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
542 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
|
543 return; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
544 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
545 cb->print_value_on(tty); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
546 return; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
547 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
548 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
|
549 oop obj = oop(p); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
550 obj->print_value_on(tty); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
551 return; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
552 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
553 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
|
554 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
555 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
556 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
557 JRT_LEAF(void, GraalRuntime::vm_message(jboolean vmError, jlong format, jlong v1, jlong v2, jlong v3)) |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
558 ResourceMark rm; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
559 char *buf = (char*) (address) format; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
560 if (vmError) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
561 if (buf != NULL) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
562 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
|
563 } else { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
564 fatal("<anonymous error>"); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
565 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
566 } else if (buf != NULL) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
567 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
|
568 } else { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
569 assert(v2 == 0, "v2 != 0"); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
570 assert(v3 == 0, "v3 != 0"); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
571 decipher(v1, false); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
572 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
573 JRT_END |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
574 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
575 JRT_LEAF(void, GraalRuntime::log_primitive(JavaThread* thread, jchar typeChar, jlong value, jboolean newline)) |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
576 union { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
577 jlong l; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
578 jdouble d; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
579 jfloat f; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
580 } uu; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
581 uu.l = value; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
582 switch (typeChar) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
583 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
|
584 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
|
585 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
|
586 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
|
587 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
|
588 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
|
589 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
|
590 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
|
591 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
|
592 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
593 if (newline) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
594 tty->cr(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
595 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
596 JRT_END |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
597 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
598 JRT_ENTRY(jint, GraalRuntime::identity_hash_code(JavaThread* thread, oopDesc* obj)) |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
599 return (jint) obj->identity_hash(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
600 JRT_END |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
601 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
602 JRT_ENTRY(jboolean, GraalRuntime::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
|
603 // 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
|
604 // 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
|
605 Handle receiverHandle(thread, receiver); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
606 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
|
607 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
|
608 if (receiverThread == NULL) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
609 // 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
|
610 return JNI_FALSE; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
611 } else { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
612 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
|
613 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
614 JRT_END |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
615 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
616 JRT_ENTRY(jint, GraalRuntime::test_deoptimize_call_int(JavaThread* thread, int value)) |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
617 deopt_caller(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
618 return value; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
619 JRT_END |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
620 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
621 // private static void Factory.init() |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
622 JVM_ENTRY(void, JVM_InitGraalClassLoader(JNIEnv *env, jclass c, jobject loader_handle)) |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
623 SystemDictionary::init_graal_loader(JNIHandles::resolve(loader_handle)); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
624 SystemDictionary::WKID scan = SystemDictionary::FIRST_GRAAL_WKID; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
625 SystemDictionary::initialize_wk_klasses_through(SystemDictionary::LAST_GRAAL_WKID, scan, CHECK); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
626 JVM_END |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
627 |
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
|
628 // 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
|
629 JVM_ENTRY(jobject, JVM_GetJVMCIRuntime(JNIEnv *env, jclass c)) |
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
|
630 GraalRuntime::initialize_HotSpotJVMCIRuntime(); |
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
|
631 return GraalRuntime::get_HotSpotJVMCIRuntime_jobject(); |
21033
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
632 JVM_END |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
633 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
634 // private static String[] Services.getServiceImpls(Class service) |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
635 JVM_ENTRY(jobject, JVM_GetGraalServiceImpls(JNIEnv *env, jclass c, jclass serviceClass)) |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
636 HandleMark hm; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
637 ResourceMark rm; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
638 KlassHandle serviceKlass(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(serviceClass))); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
639 return JNIHandles::make_local(THREAD, GraalRuntime::get_service_impls(serviceKlass, THREAD)()); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
640 JVM_END |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
641 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
642 // private static TruffleRuntime Truffle.createRuntime() |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
643 JVM_ENTRY(jobject, JVM_CreateTruffleRuntime(JNIEnv *env, jclass c)) |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
644 GraalRuntime::ensure_graal_class_loader_is_initialized(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
645 TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime", CHECK_NULL); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
646 KlassHandle klass = GraalRuntime::resolve_or_fail(name, CHECK_NULL); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
647 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
648 TempNewSymbol makeInstance = SymbolTable::new_symbol("makeInstance", CHECK_NULL); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
649 TempNewSymbol sig = SymbolTable::new_symbol("()Lcom/oracle/truffle/api/TruffleRuntime;", CHECK_NULL); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
650 JavaValue result(T_OBJECT); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
651 JavaCalls::call_static(&result, klass, makeInstance, sig, CHECK_NULL); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
652 return JNIHandles::make_local(THREAD, (oop) result.get_jobject()); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
653 JVM_END |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
654 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
655 // private static NativeFunctionInterfaceRuntime.createInterface() |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
656 JVM_ENTRY(jobject, JVM_CreateNativeFunctionInterface(JNIEnv *env, jclass c)) |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
657 GraalRuntime::ensure_graal_class_loader_is_initialized(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
658 TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/truffle/hotspot/HotSpotTruffleRuntime", CHECK_NULL); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
659 KlassHandle klass = GraalRuntime::resolve_or_fail(name, CHECK_NULL); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
660 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
661 TempNewSymbol makeInstance = SymbolTable::new_symbol("createNativeFunctionInterface", CHECK_NULL); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
662 TempNewSymbol sig = SymbolTable::new_symbol("()Lcom/oracle/nfi/api/NativeFunctionInterface;", CHECK_NULL); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
663 JavaValue result(T_OBJECT); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
664 JavaCalls::call_static(&result, klass, makeInstance, sig, CHECK_NULL); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
665 return JNIHandles::make_local(THREAD, (oop) result.get_jobject()); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
666 JVM_END |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
667 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
668 void GraalRuntime::check_generated_sources_sha1(TRAPS) { |
21551
5324104ac4f3
moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21531
diff
changeset
|
669 TempNewSymbol name = SymbolTable::new_symbol("com/oracle/jvmci/hotspot/sourcegen/GeneratedSourcesSha1", CHECK_ABORT); |
21033
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
670 KlassHandle klass = load_required_class(name); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
671 fieldDescriptor fd; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
672 if (!InstanceKlass::cast(klass())->find_field(vmSymbols::value_name(), vmSymbols::string_signature(), true, &fd)) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
673 THROW_MSG(vmSymbols::java_lang_NoSuchFieldError(), "GeneratedSourcesSha1.value"); |
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 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
676 Symbol* value = java_lang_String::as_symbol(klass->java_mirror()->obj_field(fd.offset()), CHECK); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
677 if (!value->equals(_generated_sources_sha1)) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
678 char buf[200]; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
679 jio_snprintf(buf, sizeof(buf), "Generated sources SHA1 check failed (%s != %s) - need to rebuild the VM", value->as_C_string(), _generated_sources_sha1); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
680 THROW_MSG(vmSymbols::java_lang_InternalError(), buf); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
681 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
682 } |
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 Handle GraalRuntime::callInitializer(const char* className, const char* methodName, const char* returnType) { |
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
|
685 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
|
686 Thread* THREAD = Thread::current(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
687 check_generated_sources_sha1(CHECK_ABORT_(Handle())); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
688 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
689 TempNewSymbol name = SymbolTable::new_symbol(className, CHECK_ABORT_(Handle())); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
690 KlassHandle klass = load_required_class(name); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
691 TempNewSymbol runtime = SymbolTable::new_symbol(methodName, CHECK_ABORT_(Handle())); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
692 TempNewSymbol sig = SymbolTable::new_symbol(returnType, CHECK_ABORT_(Handle())); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
693 JavaValue result(T_OBJECT); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
694 JavaCalls::call_static(&result, klass, runtime, sig, CHECK_ABORT_(Handle())); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
695 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
|
696 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
697 |
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
|
698 void GraalRuntime::initialize_HotSpotJVMCIRuntime() { |
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
|
699 if (JNIHandles::resolve(_HotSpotJVMCIRuntime_instance) == NULL) { |
21033
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
700 #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
|
701 // This should only be called in the context of the JVMCI class being initialized |
21033
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
702 Thread* THREAD = Thread::current(); |
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
|
703 TempNewSymbol name = SymbolTable::new_symbol("com/oracle/jvmci/runtime/JVMCI", CHECK_ABORT); |
21033
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
704 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
|
705 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
|
706 "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
|
707 #endif |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
708 |
21551
5324104ac4f3
moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21531
diff
changeset
|
709 Handle result = callInitializer("com/oracle/jvmci/hotspot/HotSpotJVMCIRuntime", "runtime", |
5324104ac4f3
moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21531
diff
changeset
|
710 "()Lcom/oracle/jvmci/hotspot/HotSpotJVMCIRuntime;"); |
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
|
711 _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
|
712 _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
|
713 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
714 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
715 |
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
|
716 void GraalRuntime::initialize_JVMCI() { |
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
|
717 if (JNIHandles::resolve(_HotSpotJVMCIRuntime_instance) == NULL) { |
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
|
718 callInitializer("com/oracle/jvmci/runtime/JVMCI", "getRuntime", "()Lcom/oracle/jvmci/runtime/JVMCIRuntime;"); |
21033
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
719 } |
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
|
720 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
|
721 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
722 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
723 // private static void CompilerToVMImpl.init() |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
724 JVM_ENTRY(void, JVM_InitializeGraalNatives(JNIEnv *env, jclass c2vmClass)) |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
725 GraalRuntime::initialize_natives(env, c2vmClass); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
726 JVM_END |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
727 |
21531
01319414783b
added extension point for post Option parsing actions and used it to remove another JVMCI to non-JVMCI dependency (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21527
diff
changeset
|
728 // private static OptionsParsed[] HotSpotOptions.parseVMOptions(Class) |
01319414783b
added extension point for post Option parsing actions and used it to remove another JVMCI to non-JVMCI dependency (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21527
diff
changeset
|
729 JVM_ENTRY(jobject, JVM_ParseGraalOptions(JNIEnv *env, jclass c, jobject optionsParsedClass_obj)) |
21033
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
730 HandleMark hm; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
731 KlassHandle hotSpotOptionsClass(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(c))); |
21531
01319414783b
added extension point for post Option parsing actions and used it to remove another JVMCI to non-JVMCI dependency (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21527
diff
changeset
|
732 GraalRuntime::parse_arguments(hotSpotOptionsClass, CHECK_NULL); |
01319414783b
added extension point for post Option parsing actions and used it to remove another JVMCI to non-JVMCI dependency (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21527
diff
changeset
|
733 KlassHandle optionsParsedClass(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(optionsParsedClass_obj))); |
01319414783b
added extension point for post Option parsing actions and used it to remove another JVMCI to non-JVMCI dependency (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21527
diff
changeset
|
734 return JNIHandles::make_local(THREAD, GraalRuntime::get_service_impls(optionsParsedClass, THREAD)()); |
21033
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
735 JVM_END |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
736 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
737 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
738 void GraalRuntime::ensure_graal_class_loader_is_initialized() { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
739 // This initialization code is guarded by a static pointer to the Factory class. |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
740 // Once it is non-null, the Graal class loader and well known Graal classes are |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
741 // 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
|
742 // 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
|
743 // 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
|
744 static Klass* _FactoryKlass = NULL; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
745 if (_FactoryKlass == NULL) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
746 Thread* THREAD = Thread::current(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
747 TempNewSymbol name = SymbolTable::new_symbol("com/oracle/graal/hotspot/loader/Factory", CHECK_ABORT); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
748 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
|
749 if (HAS_PENDING_EXCEPTION) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
750 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
|
751 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
|
752 // Only report the failure on the first thread that hits it |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
753 abort_on_pending_exception(PENDING_EXCEPTION, "Graal classes are not available"); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
754 } else { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
755 CLEAR_PENDING_EXCEPTION; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
756 // 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
|
757 os::sleep(THREAD, 100, false); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
758 vm_abort(false); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
759 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
760 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
761 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
762 // We cannot use graalJavaAccess for this because we are currently in the |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
763 // process of initializing that mechanism. |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
764 TempNewSymbol field_name = SymbolTable::new_symbol("useGraalClassLoader", CHECK_ABORT); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
765 fieldDescriptor field_desc; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
766 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
|
767 ResourceMark rm; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
768 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
|
769 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
770 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
771 InstanceKlass* ik = InstanceKlass::cast(klass()); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
772 address addr = ik->static_field_addr(field_desc.offset() - InstanceMirrorKlass::offset_of_static_fields()); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
773 *((jboolean *) addr) = (jboolean) UseGraalClassLoader; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
774 klass->initialize(CHECK_ABORT); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
775 _FactoryKlass = klass(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
776 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
777 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
778 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
779 jint GraalRuntime::check_arguments(TRAPS) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
780 KlassHandle nullHandle; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
781 parse_arguments(nullHandle, THREAD); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
782 if (HAS_PENDING_EXCEPTION) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
783 // Errors in parsing Graal arguments cause exceptions. |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
784 // We now load and initialize HotSpotOptions which in turn |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
785 // causes argument parsing to be redone with better error messages. |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
786 CLEAR_PENDING_EXCEPTION; |
21551
5324104ac4f3
moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21531
diff
changeset
|
787 TempNewSymbol name = SymbolTable::new_symbol("Lcom/oracle/jvmci/hotspot/HotSpotOptions;", CHECK_ABORT_(JNI_ERR)); |
21033
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
788 instanceKlassHandle hotSpotOptionsClass = resolve_or_fail(name, CHECK_ABORT_(JNI_ERR)); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
789 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
790 parse_arguments(hotSpotOptionsClass, THREAD); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
791 assert(HAS_PENDING_EXCEPTION, "must be"); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
792 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
793 ResourceMark rm; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
794 Handle exception = PENDING_EXCEPTION; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
795 CLEAR_PENDING_EXCEPTION; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
796 oop message = java_lang_Throwable::message(exception); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
797 if (message != NULL) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
798 tty->print_cr("Error parsing Graal options: %s", java_lang_String::as_utf8_string(message)); |
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 call_printStackTrace(exception, THREAD); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
801 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
802 return JNI_ERR; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
803 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
804 return JNI_OK; |
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 |
21473
923c37b10fb4
compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents:
21207
diff
changeset
|
807 void GraalRuntime::parse_arguments(KlassHandle hotSpotOptionsClass, TRAPS) { |
21033
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
808 ResourceMark rm(THREAD); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
809 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
810 // Process option overrides from graal.options first |
21473
923c37b10fb4
compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents:
21207
diff
changeset
|
811 parse_graal_options_file(hotSpotOptionsClass, CHECK); |
21033
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
812 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
813 // Now process options on the command line |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
814 int numOptions = Arguments::num_graal_args(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
815 for (int i = 0; i < numOptions; i++) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
816 char* arg = Arguments::graal_args_array()[i]; |
21473
923c37b10fb4
compute compiled bytecodes using method inlining recording instead of a DebugMetric
Doug Simon <doug.simon@oracle.com>
parents:
21207
diff
changeset
|
817 parse_argument(hotSpotOptionsClass, arg, CHECK); |
21033
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
818 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
819 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
820 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
821 void GraalRuntime::check_required_value(const char* name, size_t name_len, const char* value, TRAPS) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
822 if (value == NULL) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
823 char buf[200]; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
824 jio_snprintf(buf, sizeof(buf), "Must use '-G:%.*s=<value>' format for %.*s option", name_len, name, name_len, name); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
825 THROW_MSG(vmSymbols::java_lang_InternalError(), buf); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
826 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
827 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
828 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
829 void GraalRuntime::parse_argument(KlassHandle hotSpotOptionsClass, char* arg, TRAPS) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
830 ensure_graal_class_loader_is_initialized(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
831 char first = arg[0]; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
832 char* name; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
833 size_t name_len; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
834 bool recognized = true; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
835 if (first == '+' || first == '-') { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
836 name = arg + 1; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
837 name_len = strlen(name); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
838 recognized = set_option_bool(hotSpotOptionsClass, name, name_len, first, CHECK); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
839 } else { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
840 char* sep = strchr(arg, '='); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
841 name = arg; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
842 char* value = NULL; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
843 if (sep != NULL) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
844 name_len = sep - name; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
845 value = sep + 1; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
846 } else { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
847 name_len = strlen(name); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
848 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
849 recognized = set_option(hotSpotOptionsClass, name, name_len, value, CHECK); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
850 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
851 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
852 if (!recognized) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
853 bool throw_err = hotSpotOptionsClass.is_null(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
854 if (!hotSpotOptionsClass.is_null()) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
855 set_option_helper(hotSpotOptionsClass, name, name_len, Handle(), ' ', Handle(), 0L); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
856 if (!HAS_PENDING_EXCEPTION) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
857 throw_err = true; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
858 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
859 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
860 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
861 if (throw_err) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
862 char buf[200]; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
863 jio_snprintf(buf, sizeof(buf), "Unrecognized Graal option %.*s", name_len, name); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
864 THROW_MSG(vmSymbols::java_lang_InternalError(), buf); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
865 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
866 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
867 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
868 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
869 void GraalRuntime::parse_graal_options_file(KlassHandle hotSpotOptionsClass, TRAPS) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
870 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
|
871 size_t path_len = strlen(home) + strlen("/lib/graal.options") + 1; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
872 char* path = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, path_len); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
873 char sep = os::file_separator()[0]; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
874 sprintf(path, "%s%clib%cgraal.options", home, sep, sep); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
875 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
876 struct stat st; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
877 if (os::stat(path, &st) == 0) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
878 int file_handle = os::open(path, 0, 0); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
879 if (file_handle != -1) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
880 char* buffer = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, st.st_size); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
881 int num_read = (int) os::read(file_handle, (char*) buffer, st.st_size); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
882 if (num_read == -1) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
883 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
|
884 } 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
|
885 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
|
886 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
887 os::close(file_handle); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
888 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
|
889 char* line = buffer; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
890 int lineNo = 1; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
891 while (line - buffer < num_read) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
892 char* nl = strchr(line, '\n'); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
893 if (nl != NULL) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
894 *nl = '\0'; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
895 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
896 parse_argument(hotSpotOptionsClass, line, THREAD); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
897 if (HAS_PENDING_EXCEPTION) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
898 warning("Error in %s:%d", path, lineNo); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
899 return; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
900 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
901 if (nl != NULL) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
902 line = nl + 1; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
903 lineNo++; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
904 } else { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
905 // 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
|
906 break; |
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 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
909 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
910 } else { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
911 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
|
912 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
913 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
914 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
915 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
916 jlong GraalRuntime::parse_primitive_option_value(char spec, const char* name, size_t name_len, const char* value, TRAPS) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
917 check_required_value(name, name_len, value, CHECK_(0L)); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
918 union { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
919 jint i; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
920 jlong l; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
921 double d; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
922 } uu; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
923 uu.l = 0L; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
924 char dummy; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
925 switch (spec) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
926 case 'd': |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
927 case 'f': { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
928 if (sscanf(value, "%lf%c", &uu.d, &dummy) == 1) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
929 return uu.l; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
930 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
931 break; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
932 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
933 case 'i': { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
934 if (sscanf(value, "%d%c", &uu.i, &dummy) == 1) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
935 return (jlong)uu.i; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
936 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
937 break; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
938 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
939 default: |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
940 ShouldNotReachHere(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
941 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
942 ResourceMark rm(THREAD); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
943 char buf[200]; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
944 bool missing = strlen(value) == 0; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
945 if (missing) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
946 jio_snprintf(buf, sizeof(buf), "Missing %s value for Graal option %.*s", (spec == 'i' ? "numeric" : "float/double"), name_len, name); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
947 } else { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
948 jio_snprintf(buf, sizeof(buf), "Invalid %s value for Graal option %.*s: %s", (spec == 'i' ? "numeric" : "float/double"), name_len, name, value); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
949 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
950 THROW_MSG_(vmSymbols::java_lang_InternalError(), buf, 0L); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
951 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
952 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
953 void GraalRuntime::set_option_helper(KlassHandle hotSpotOptionsClass, char* name, size_t name_len, Handle option, jchar spec, Handle stringValue, jlong primitiveValue) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
954 Thread* THREAD = Thread::current(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
955 Handle name_handle; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
956 if (name != NULL) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
957 if (strlen(name) > name_len) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
958 // Temporarily replace '=' with NULL to create the Java string for the option name |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
959 char save = name[name_len]; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
960 name[name_len] = '\0'; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
961 name_handle = java_lang_String::create_from_str(name, THREAD); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
962 name[name_len] = '='; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
963 if (HAS_PENDING_EXCEPTION) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
964 return; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
965 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
966 } else { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
967 assert(strlen(name) == name_len, "must be"); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
968 name_handle = java_lang_String::create_from_str(name, CHECK); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
969 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
970 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
971 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
972 TempNewSymbol setOption = SymbolTable::new_symbol("setOption", CHECK); |
21554
b1530a6cce8c
renamed com.oracle.graal.[debug|options|hotspotvmconfig]* modules to com.oracle.jvmci.[debug|options|hotspotvmconfig]* modules (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21551
diff
changeset
|
973 TempNewSymbol sig = SymbolTable::new_symbol("(Ljava/lang/String;Lcom/oracle/jvmci/options/OptionValue;CLjava/lang/String;J)V", CHECK); |
21033
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
974 JavaValue result(T_VOID); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
975 JavaCallArguments args; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
976 args.push_oop(name_handle()); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
977 args.push_oop(option()); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
978 args.push_int(spec); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
979 args.push_oop(stringValue()); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
980 args.push_long(primitiveValue); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
981 JavaCalls::call_static(&result, hotSpotOptionsClass, setOption, sig, &args, CHECK); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
982 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
983 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
984 Handle GraalRuntime::get_OptionValue(const char* declaringClass, const char* fieldName, const char* fieldSig, TRAPS) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
985 TempNewSymbol name = SymbolTable::new_symbol(declaringClass, CHECK_NH); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
986 Klass* klass = resolve_or_fail(name, CHECK_NH); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
987 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
988 // The class has been loaded so the field and signature should already be in the symbol |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
989 // table. If they're not there, the field doesn't exist. |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
990 TempNewSymbol fieldname = SymbolTable::probe(fieldName, (int)strlen(fieldName)); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
991 TempNewSymbol signame = SymbolTable::probe(fieldSig, (int)strlen(fieldSig)); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
992 if (fieldname == NULL || signame == NULL) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
993 THROW_MSG_(vmSymbols::java_lang_NoSuchFieldError(), (char*) fieldName, Handle()); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
994 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
995 // Make sure class is initialized before handing id's out to fields |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
996 klass->initialize(CHECK_NH); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
997 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
998 fieldDescriptor fd; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
999 if (!InstanceKlass::cast(klass)->find_field(fieldname, signame, true, &fd)) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1000 THROW_MSG_(vmSymbols::java_lang_NoSuchFieldError(), (char*) fieldName, Handle()); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1001 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1002 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1003 Handle ret = klass->java_mirror()->obj_field(fd.offset()); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1004 return ret; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1005 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1006 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1007 Handle GraalRuntime::create_Service(const char* name, TRAPS) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1008 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
|
1009 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
|
1010 instanceKlassHandle klass(THREAD, k); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1011 klass->initialize(CHECK_NH); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1012 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
|
1013 JavaValue result(T_VOID); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1014 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
|
1015 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
|
1016 return service; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1017 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1018 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1019 void GraalRuntime::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
|
1020 if (_HotSpotJVMCIRuntime_instance != NULL) { |
21033
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1021 _shutdown_called = true; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1022 JavaThread* THREAD = JavaThread::current(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1023 HandleMark hm(THREAD); |
21551
5324104ac4f3
moved com.oracle.graal.hotspot.jvmci classes to com.oracle.jvmci.hotspot module (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21531
diff
changeset
|
1024 TempNewSymbol name = SymbolTable::new_symbol("com/oracle/jvmci/hotspot/HotSpotJVMCIRuntime", CHECK_ABORT); |
21033
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1025 KlassHandle klass = load_required_class(name); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1026 JavaValue result(T_VOID); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1027 JavaCallArguments args; |
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
|
1028 args.push_oop(get_HotSpotJVMCIRuntime()); |
21033
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1029 JavaCalls::call_special(&result, klass, vmSymbols::shutdown_method_name(), vmSymbols::void_method_signature(), &args, CHECK_ABORT); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1030 |
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
|
1031 JNIHandles::destroy_global(_HotSpotJVMCIRuntime_instance); |
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
|
1032 _HotSpotJVMCIRuntime_instance = NULL; |
21033
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1033 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1034 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1035 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1036 void GraalRuntime::call_printStackTrace(Handle exception, Thread* thread) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1037 assert(exception->is_a(SystemDictionary::Throwable_klass()), "Throwable instance expected"); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1038 JavaValue result(T_VOID); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1039 JavaCalls::call_virtual(&result, |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1040 exception, |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1041 KlassHandle(thread, |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1042 SystemDictionary::Throwable_klass()), |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1043 vmSymbols::printStackTrace_name(), |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1044 vmSymbols::void_method_signature(), |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1045 thread); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1046 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1047 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1048 void GraalRuntime::abort_on_pending_exception(Handle exception, const char* message, bool dump_core) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1049 Thread* THREAD = Thread::current(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1050 CLEAR_PENDING_EXCEPTION; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1051 tty->print_raw_cr(message); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1052 call_printStackTrace(exception, THREAD); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1053 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1054 // 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
|
1055 // 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
|
1056 // failures. |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1057 os::sleep(THREAD, 200, false); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1058 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1059 vm_abort(dump_core); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1060 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1061 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1062 Klass* GraalRuntime::resolve_or_null(Symbol* name, TRAPS) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1063 return SystemDictionary::resolve_or_null(name, SystemDictionary::graal_loader(), Handle(), CHECK_NULL); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1064 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1065 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1066 Klass* GraalRuntime::resolve_or_fail(Symbol* name, TRAPS) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1067 return SystemDictionary::resolve_or_fail(name, SystemDictionary::graal_loader(), Handle(), true, CHECK_NULL); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1068 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1069 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1070 Klass* GraalRuntime::load_required_class(Symbol* name) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1071 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
|
1072 if (klass == NULL) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1073 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
|
1074 vm_abort(false); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1075 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1076 return klass; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1077 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1078 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1079 Handle GraalRuntime::get_service_impls(KlassHandle serviceKlass, TRAPS) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1080 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
|
1081 const char* serviceName = serviceKlass->external_name(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1082 size_t path_len = strlen(home) + strlen("/lib/graal/services/") + strlen(serviceName) + 1; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1083 char* path = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, path_len); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1084 char sep = os::file_separator()[0]; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1085 sprintf(path, "%s%clib%cgraal%cservices%c%s", home, sep, sep, sep, sep, serviceName); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1086 struct stat st; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1087 if (os::stat(path, &st) == 0) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1088 int file_handle = os::open(path, 0, 0); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1089 if (file_handle != -1) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1090 char* buffer = NEW_RESOURCE_ARRAY_IN_THREAD(THREAD, char, st.st_size + 1); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1091 int num_read = (int) os::read(file_handle, (char*) buffer, st.st_size); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1092 if (num_read == -1) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1093 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
|
1094 } 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
|
1095 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
|
1096 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1097 os::close(file_handle); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1098 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
|
1099 buffer[num_read] = '\0'; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1100 GrowableArray<char*>* implNames = new GrowableArray<char*>(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1101 char* line = buffer; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1102 while (line - buffer < num_read) { |
21123
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1103 // 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
|
1104 char* nextline = NULL; |
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1105 char* cr = strchr(line, '\r'); |
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1106 char* lf = strchr(line, '\n'); |
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1107 if (cr != NULL && lf != NULL) { |
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1108 char* min = MIN2(cr, lf); |
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1109 *min = '\0'; |
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1110 if (lf == cr + 1) { |
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1111 nextline = lf + 1; |
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1112 } else { |
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1113 nextline = min + 1; |
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1114 } |
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1115 } else if (cr != NULL) { |
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1116 *cr = '\0'; |
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1117 nextline = cr + 1; |
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1118 } else if (lf != NULL) { |
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1119 *lf = '\0'; |
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1120 nextline = lf + 1; |
21033
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1121 } |
21123
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1122 // trim left |
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1123 while (*line == ' ' || *line == '\t') line++; |
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1124 char* end = line + strlen(line); |
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1125 // trim right |
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1126 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
|
1127 *end = '\0'; |
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1128 // skip comments and empty lines |
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1129 if (*line != '#' && strlen(line) > 0) { |
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1130 // Turn all '.'s into '/'s |
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1131 for (size_t index = 0; line[index] != '\0'; index++) { |
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1132 if (line[index] == '.') { |
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1133 line[index] = '/'; |
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1134 } |
21033
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1135 } |
21123
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1136 implNames->append(line); |
21033
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1137 } |
21123
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1138 if (nextline != NULL) { |
85b0935625c1
graalRuntime: make service file parsing more robust:
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21033
diff
changeset
|
1139 line = nextline; |
21033
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1140 } else { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1141 // 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
|
1142 break; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1143 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1144 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1145 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1146 objArrayOop servicesOop = oopFactory::new_objArray(serviceKlass(), implNames->length(), CHECK_NH); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1147 objArrayHandle services(THREAD, servicesOop); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1148 for (int i = 0; i < implNames->length(); ++i) { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1149 char* implName = implNames->at(i); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1150 Handle service = create_Service(implName, CHECK_NH); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1151 services->obj_at_put(i, service()); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1152 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1153 return services; |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1154 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1155 } else { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1156 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
|
1157 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1158 } else { |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1159 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
|
1160 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1161 return Handle(); |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1162 } |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1163 |
4527d2428f37
Convert graalRuntime.cpp to unix line delimiters
Gilles Duboscq <gilles.m.duboscq@oracle.com>
parents:
21031
diff
changeset
|
1164 #include "graalRuntime.inline.hpp" |