annotate src/share/vm/graal/graalRuntime.cpp @ 7154:5d0bb7d52783

changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
author Doug Simon <doug.simon@oracle.com>
date Wed, 12 Dec 2012 21:36:40 +0100
parents 6c46172c04bf
children 8a3efb8c831d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5523
861f8d5a5153 Added code to resolve GraalRuntime into HotSpot. Added graal.api.test project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
861f8d5a5153 Added code to resolve GraalRuntime into HotSpot. Added graal.api.test project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
861f8d5a5153 Added code to resolve GraalRuntime into HotSpot. Added graal.api.test project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
861f8d5a5153 Added code to resolve GraalRuntime into HotSpot. Added graal.api.test project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
861f8d5a5153 Added code to resolve GraalRuntime into HotSpot. Added graal.api.test project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
861f8d5a5153 Added code to resolve GraalRuntime into HotSpot. Added graal.api.test project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
861f8d5a5153 Added code to resolve GraalRuntime into HotSpot. Added graal.api.test project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
861f8d5a5153 Added code to resolve GraalRuntime into HotSpot. Added graal.api.test project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
861f8d5a5153 Added code to resolve GraalRuntime into HotSpot. Added graal.api.test project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
861f8d5a5153 Added code to resolve GraalRuntime into HotSpot. Added graal.api.test project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
861f8d5a5153 Added code to resolve GraalRuntime into HotSpot. Added graal.api.test project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
861f8d5a5153 Added code to resolve GraalRuntime into HotSpot. Added graal.api.test project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
861f8d5a5153 Added code to resolve GraalRuntime into HotSpot. Added graal.api.test project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
861f8d5a5153 Added code to resolve GraalRuntime into HotSpot. Added graal.api.test project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
861f8d5a5153 Added code to resolve GraalRuntime into HotSpot. Added graal.api.test project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
861f8d5a5153 Added code to resolve GraalRuntime into HotSpot. Added graal.api.test project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
861f8d5a5153 Added code to resolve GraalRuntime into HotSpot. Added graal.api.test project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
861f8d5a5153 Added code to resolve GraalRuntime into HotSpot. Added graal.api.test project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
861f8d5a5153 Added code to resolve GraalRuntime into HotSpot. Added graal.api.test project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
861f8d5a5153 Added code to resolve GraalRuntime into HotSpot. Added graal.api.test project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
861f8d5a5153 Added code to resolve GraalRuntime into HotSpot. Added graal.api.test project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
861f8d5a5153 Added code to resolve GraalRuntime into HotSpot. Added graal.api.test project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 */
861f8d5a5153 Added code to resolve GraalRuntime into HotSpot. Added graal.api.test project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
23
861f8d5a5153 Added code to resolve GraalRuntime into HotSpot. Added graal.api.test project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24 #include "precompiled.hpp"
6559
d5f7e737827f fixed compilation issues on Solaris. When using SunStudio compiler, Solaris build with DONT_USE_PRECOMPILED_HEADER
Laurent Daynes <Laurent.Daynes@oracle.com>
parents: 6505
diff changeset
25 #include "runtime/interfaceSupport.hpp"
d5f7e737827f fixed compilation issues on Solaris. When using SunStudio compiler, Solaris build with DONT_USE_PRECOMPILED_HEADER
Laurent Daynes <Laurent.Daynes@oracle.com>
parents: 6505
diff changeset
26 #include "prims/jvm.h"
7125
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
27 #include "graal/graalRuntime.hpp"
5526
87e4aed94b26 Remove HotSpotCompiler interface, let HotSpotCompilerImpl implement GraalRuntime (in preparation of renaming).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5525
diff changeset
28 #include "graal/graalVMToCompiler.hpp"
7125
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
29 #include "asm/codeBuffer.hpp"
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
30 #include "runtime/biasedLocking.hpp"
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
31
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
32 // Implementation of GraalStubAssembler
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
33
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
34 GraalStubAssembler::GraalStubAssembler(CodeBuffer* code, const char * name, int stub_id) : MacroAssembler(code) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
35 _name = name;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
36 _must_gc_arguments = false;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
37 _frame_size = no_frame_size;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
38 _num_rt_args = 0;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
39 _stub_id = stub_id;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
40 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
41
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
42
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
43 void GraalStubAssembler::set_info(const char* name, bool must_gc_arguments) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
44 _name = name;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
45 _must_gc_arguments = must_gc_arguments;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
46 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
47
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
48
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
49 void GraalStubAssembler::set_frame_size(int size) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
50 if (_frame_size == no_frame_size) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
51 _frame_size = size;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
52 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
53 assert(_frame_size == size, "can't change the frame size");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
54 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
55
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
56
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
57 void GraalStubAssembler::set_num_rt_args(int args) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
58 if (_num_rt_args == 0) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
59 _num_rt_args = args;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
60 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
61 assert(_num_rt_args == args, "can't change the number of args");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
62 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
63
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
64 // Implementation of GraalRuntime
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
65
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
66 CodeBlob* GraalRuntime::_blobs[GraalRuntime::number_of_ids];
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
67 const char *GraalRuntime::_blob_names[] = {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
68 GRAAL_STUBS(STUB_NAME, LAST_STUB_NAME)
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
69 };
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
70
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
71 // Simple helper to see if the caller of a runtime stub which
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
72 // entered the VM has been deoptimized
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
73
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
74 static bool caller_is_deopted() {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
75 JavaThread* thread = JavaThread::current();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
76 RegisterMap reg_map(thread, false);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
77 frame runtime_frame = thread->last_frame();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
78 frame caller_frame = runtime_frame.sender(&reg_map);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
79 assert(caller_frame.is_compiled_frame(), "must be compiled");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
80 return caller_frame.is_deoptimized_frame();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
81 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
82
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
83 // Stress deoptimization
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
84 static void deopt_caller() {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
85 if ( !caller_is_deopted()) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
86 JavaThread* thread = JavaThread::current();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
87 RegisterMap reg_map(thread, false);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
88 frame runtime_frame = thread->last_frame();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
89 frame caller_frame = runtime_frame.sender(&reg_map);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
90 Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_constraint);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
91 assert(caller_is_deopted(), "Must be deoptimized");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
92 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
93 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
94
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
95 static bool setup_code_buffer(CodeBuffer* code) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
96 // Preinitialize the consts section to some large size:
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
97 int locs_buffer_size = 1 * (relocInfo::length_limit + sizeof(relocInfo));
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
98 char* locs_buffer = NEW_RESOURCE_ARRAY(char, locs_buffer_size);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
99 code->insts()->initialize_shared_locs((relocInfo*)locs_buffer,
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
100 locs_buffer_size / sizeof(relocInfo));
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
101
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
102 // Global stubs have neither constants nor local stubs
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
103 code->initialize_consts_size(0);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
104 code->initialize_stubs_size(0);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
105
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
106 return true;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
107 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
108
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
109 void GraalRuntime::generate_blob_for(BufferBlob* buffer_blob, StubID id) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
110 assert(0 <= id && id < number_of_ids, "illegal stub id");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
111 ResourceMark rm;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
112 // create code buffer for code storage
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
113 CodeBuffer code(buffer_blob);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
114
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
115 setup_code_buffer(&code);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
116
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
117 // create assembler for code generation
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
118 GraalStubAssembler* sasm = new GraalStubAssembler(&code, name_for(id), id);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
119 // generate code for runtime stub
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
120 OopMapSet* oop_maps;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
121 oop_maps = generate_code_for(id, sasm);
7154
5d0bb7d52783 changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
122 assert(oop_maps == NULL || sasm->frame_size() != GraalStubAssembler::no_frame_size,
7125
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
123 "if stub has an oop map it must have a valid frame size");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
124
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
125 #ifdef ASSERT
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
126 // Make sure that stubs that need oopmaps have them
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
127 switch (id) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
128 // These stubs don't need to have an oopmap
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
129 case graal_slow_subtype_check_id:
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
130 #if defined(SPARC) || defined(PPC)
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
131 case handle_exception_nofpu_id: // Unused on sparc
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
132 #endif
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
133 case graal_verify_oop_id:
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
134 case graal_unwind_exception_call_id:
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
135 case graal_OSR_migration_end_id:
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
136 case graal_arithmetic_frem_id:
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
137 case graal_arithmetic_drem_id:
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
138 case graal_set_deopt_info_id:
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
139 break;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
140
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
141 // All other stubs should have oopmaps
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
142 default:
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
143 assert(oop_maps != NULL, "must have an oopmap");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
144 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
145 #endif
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
146
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
147 // align so printing shows nop's instead of random code at the end (SimpleStubs are aligned)
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
148 sasm->align(BytesPerWord);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
149 // make sure all code is in code buffer
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
150 sasm->flush();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
151 // create blob - distinguish a few special cases
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
152 CodeBlob* blob = RuntimeStub::new_runtime_stub(name_for(id),
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
153 &code,
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
154 CodeOffsets::frame_never_safe,
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
155 sasm->frame_size(),
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
156 oop_maps,
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
157 sasm->must_gc_arguments());
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
158 // install blob
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
159 assert(blob != NULL, "blob must exist");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
160 _blobs[id] = blob;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
161 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
162
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
163
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
164 void GraalRuntime::initialize(BufferBlob* blob) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
165 // generate stubs
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
166 for (int id = 0; id < number_of_ids; id++) generate_blob_for(blob, (StubID)id);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
167 // printing
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
168 #ifndef PRODUCT
7154
5d0bb7d52783 changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
169 if (GraalPrintSimpleStubs) {
7125
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
170 ResourceMark rm;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
171 for (int id = 0; id < number_of_ids; id++) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
172 _blobs[id]->print();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
173 if (_blobs[id]->oop_maps() != NULL) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
174 _blobs[id]->oop_maps()->print();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
175 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
176 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
177 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
178 #endif
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
179 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
180
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
181
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
182 CodeBlob* GraalRuntime::blob_for(StubID id) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
183 assert(0 <= id && id < number_of_ids, "illegal stub id");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
184 return _blobs[id];
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
185 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
186
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
187
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
188 const char* GraalRuntime::name_for(StubID id) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
189 assert(0 <= id && id < number_of_ids, "illegal stub id");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
190 return _blob_names[id];
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
191 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
192
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
193 const char* GraalRuntime::name_for_address(address entry) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
194 for (int id = 0; id < number_of_ids; id++) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
195 if (entry == entry_for((StubID)id)) return name_for((StubID)id);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
196 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
197
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
198 #define FUNCTION_CASE(a, f) \
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
199 if ((intptr_t)a == CAST_FROM_FN_PTR(intptr_t, f)) return #f
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
200
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
201 FUNCTION_CASE(entry, os::javaTimeMillis);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
202 FUNCTION_CASE(entry, os::javaTimeNanos);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
203 FUNCTION_CASE(entry, SharedRuntime::OSR_migration_end);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
204 FUNCTION_CASE(entry, SharedRuntime::d2f);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
205 FUNCTION_CASE(entry, SharedRuntime::d2i);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
206 FUNCTION_CASE(entry, SharedRuntime::d2l);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
207 FUNCTION_CASE(entry, SharedRuntime::dcos);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
208 FUNCTION_CASE(entry, SharedRuntime::dexp);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
209 FUNCTION_CASE(entry, SharedRuntime::dlog);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
210 FUNCTION_CASE(entry, SharedRuntime::dlog10);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
211 FUNCTION_CASE(entry, SharedRuntime::dpow);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
212 FUNCTION_CASE(entry, SharedRuntime::drem);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
213 FUNCTION_CASE(entry, SharedRuntime::dsin);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
214 FUNCTION_CASE(entry, SharedRuntime::dtan);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
215 FUNCTION_CASE(entry, SharedRuntime::f2i);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
216 FUNCTION_CASE(entry, SharedRuntime::f2l);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
217 FUNCTION_CASE(entry, SharedRuntime::frem);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
218 FUNCTION_CASE(entry, SharedRuntime::l2d);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
219 FUNCTION_CASE(entry, SharedRuntime::l2f);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
220 FUNCTION_CASE(entry, SharedRuntime::ldiv);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
221 FUNCTION_CASE(entry, SharedRuntime::lmul);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
222 FUNCTION_CASE(entry, SharedRuntime::lrem);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
223 FUNCTION_CASE(entry, SharedRuntime::lrem);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
224 FUNCTION_CASE(entry, SharedRuntime::dtrace_method_entry);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
225 FUNCTION_CASE(entry, SharedRuntime::dtrace_method_exit);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
226 #ifdef TRACE_HAVE_INTRINSICS
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
227 FUNCTION_CASE(entry, TRACE_TIME_METHOD);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
228 #endif
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
229
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
230 #undef FUNCTION_CASE
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
231 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
232
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
233
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
234 JRT_ENTRY(void, GraalRuntime::new_instance(JavaThread* thread, Klass* klass))
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
235 assert(klass->is_klass(), "not a class");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
236 instanceKlassHandle h(thread, klass);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
237 h->check_valid_for_instantiation(true, CHECK);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
238 // make sure klass is initialized
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
239 h->initialize(CHECK);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
240 // allocate instance and return via TLS
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
241 oop obj = h->allocate_instance(CHECK);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
242 thread->set_vm_result(obj);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
243 JRT_END
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
244
7145
6c46172c04bf consolidated new_type_array and new_object_array stubs into one as there no difference between them
Doug Simon <doug.simon@oracle.com>
parents: 7125
diff changeset
245 JRT_ENTRY(void, GraalRuntime::new_array(JavaThread* thread, Klass* array_klass, jint length))
7125
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
246 // Note: no handle for klass needed since they are not used
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
247 // anymore after new_objArray() and no GC can happen before.
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
248 // (This may have to change if this code changes!)
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
249 assert(array_klass->is_klass(), "not a class");
7145
6c46172c04bf consolidated new_type_array and new_object_array stubs into one as there no difference between them
Doug Simon <doug.simon@oracle.com>
parents: 7125
diff changeset
250 oop obj;
6c46172c04bf consolidated new_type_array and new_object_array stubs into one as there no difference between them
Doug Simon <doug.simon@oracle.com>
parents: 7125
diff changeset
251 if (array_klass->oop_is_typeArray()) {
6c46172c04bf consolidated new_type_array and new_object_array stubs into one as there no difference between them
Doug Simon <doug.simon@oracle.com>
parents: 7125
diff changeset
252 BasicType elt_type = TypeArrayKlass::cast(array_klass)->element_type();
6c46172c04bf consolidated new_type_array and new_object_array stubs into one as there no difference between them
Doug Simon <doug.simon@oracle.com>
parents: 7125
diff changeset
253 obj = oopFactory::new_typeArray(elt_type, length, CHECK);
6c46172c04bf consolidated new_type_array and new_object_array stubs into one as there no difference between them
Doug Simon <doug.simon@oracle.com>
parents: 7125
diff changeset
254 } else {
6c46172c04bf consolidated new_type_array and new_object_array stubs into one as there no difference between them
Doug Simon <doug.simon@oracle.com>
parents: 7125
diff changeset
255 Klass* elem_klass = ObjArrayKlass::cast(array_klass)->element_klass();
6c46172c04bf consolidated new_type_array and new_object_array stubs into one as there no difference between them
Doug Simon <doug.simon@oracle.com>
parents: 7125
diff changeset
256 obj = oopFactory::new_objArray(elem_klass, length, CHECK);
6c46172c04bf consolidated new_type_array and new_object_array stubs into one as there no difference between them
Doug Simon <doug.simon@oracle.com>
parents: 7125
diff changeset
257 }
7125
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
258 thread->set_vm_result(obj);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
259 // This is pretty rare but this runtime patch is stressful to deoptimization
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
260 // if we deoptimize here so force a deopt to stress the path.
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
261 if (DeoptimizeALot) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
262 deopt_caller();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
263 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
264 JRT_END
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
265
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
266
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
267 JRT_ENTRY(void, GraalRuntime::new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims))
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
268 assert(klass->is_klass(), "not a class");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
269 assert(rank >= 1, "rank must be nonzero");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
270 oop obj = ArrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
271 thread->set_vm_result(obj);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
272 JRT_END
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
273
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
274 JRT_ENTRY(void, GraalRuntime::unimplemented_entry(JavaThread* thread, StubID id))
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
275 tty->print_cr("GraalRuntime::entry_for(%d) returned unimplemented entry point", id);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
276 JRT_END
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
277
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
278 extern void vm_exit(int code);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
279
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
280 // Enter this method from compiled code handler below. This is where we transition
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
281 // to VM mode. This is done as a helper routine so that the method called directly
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
282 // from compiled code does not have to transition to VM. This allows the entry
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
283 // method to see if the nmethod that we have just looked up a handler for has
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
284 // been deoptimized while we were in the vm. This simplifies the assembly code
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
285 // cpu directories.
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
286 //
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
287 // We are entering here from exception stub (via the entry method below)
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
288 // If there is a compiled exception handler in this method, we will continue there;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
289 // otherwise we will unwind the stack and continue at the caller of top frame method
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
290 // Note: we enter in Java using a special JRT wrapper. This wrapper allows us to
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
291 // control the area where we can allow a safepoint. After we exit the safepoint area we can
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
292 // check to see if the handler we are going to return is now in a nmethod that has
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
293 // been deoptimized. If that is the case we return the deopt blob
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
294 // unpack_with_exception entry instead. This makes life for the exception blob easier
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
295 // because making that same check and diverting is painful from assembly language.
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
296 JRT_ENTRY_NO_ASYNC(static address, exception_handler_for_pc_helper(JavaThread* thread, oopDesc* ex, address pc, nmethod*& nm))
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
297 // Reset method handle flag.
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
298 thread->set_is_method_handle_return(false);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
299
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
300 Handle exception(thread, ex);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
301 nm = CodeCache::find_nmethod(pc);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
302 assert(nm != NULL, "this is not an nmethod");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
303 // Adjust the pc as needed/
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
304 if (nm->is_deopt_pc(pc)) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
305 RegisterMap map(thread, false);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
306 frame exception_frame = thread->last_frame().sender(&map);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
307 // if the frame isn't deopted then pc must not correspond to the caller of last_frame
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
308 assert(exception_frame.is_deoptimized_frame(), "must be deopted");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
309 pc = exception_frame.pc();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
310 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
311 #ifdef ASSERT
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
312 assert(exception.not_null(), "NULL exceptions should be handled by throw_exception");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
313 assert(exception->is_oop(), "just checking");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
314 // Check that exception is a subclass of Throwable, otherwise we have a VerifyError
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
315 if (!(exception->is_a(SystemDictionary::Throwable_klass()))) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
316 if (ExitVMOnVerifyError) vm_exit(-1);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
317 ShouldNotReachHere();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
318 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
319 #endif
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
320
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
321 // Check the stack guard pages and reenable them if necessary and there is
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
322 // enough space on the stack to do so. Use fast exceptions only if the guard
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
323 // pages are enabled.
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
324 bool guard_pages_enabled = thread->stack_yellow_zone_enabled();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
325 if (!guard_pages_enabled) guard_pages_enabled = thread->reguard_stack();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
326
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
327 if (JvmtiExport::can_post_on_exceptions()) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
328 // To ensure correct notification of exception catches and throws
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
329 // we have to deoptimize here. If we attempted to notify the
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
330 // catches and throws during this exception lookup it's possible
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
331 // we could deoptimize on the way out of the VM and end back in
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
332 // the interpreter at the throw site. This would result in double
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
333 // notifications since the interpreter would also notify about
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
334 // these same catches and throws as it unwound the frame.
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
335
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
336 RegisterMap reg_map(thread);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
337 frame stub_frame = thread->last_frame();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
338 frame caller_frame = stub_frame.sender(&reg_map);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
339
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
340 // We don't really want to deoptimize the nmethod itself since we
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
341 // can actually continue in the exception handler ourselves but I
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
342 // don't see an easy way to have the desired effect.
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
343 Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_constraint);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
344 assert(caller_is_deopted(), "Must be deoptimized");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
345
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
346 return SharedRuntime::deopt_blob()->unpack_with_exception_in_tls();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
347 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
348
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
349 // ExceptionCache is used only for exceptions at call sites and not for implicit exceptions
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
350 if (guard_pages_enabled) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
351 address fast_continuation = nm->handler_for_exception_and_pc(exception, pc);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
352 if (fast_continuation != NULL) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
353 // Set flag if return address is a method handle call site.
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
354 thread->set_is_method_handle_return(nm->is_method_handle_return(pc));
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
355 return fast_continuation;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
356 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
357 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
358
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
359 // If the stack guard pages are enabled, check whether there is a handler in
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
360 // the current method. Otherwise (guard pages disabled), force an unwind and
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
361 // skip the exception cache update (i.e., just leave continuation==NULL).
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
362 address continuation = NULL;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
363 if (guard_pages_enabled) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
364
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
365 // New exception handling mechanism can support inlined methods
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
366 // with exception handlers since the mappings are from PC to PC
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
367
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
368 // debugging support
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
369 // tracing
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
370 if (TraceExceptions) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
371 ttyLocker ttyl;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
372 ResourceMark rm;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
373 int offset = pc - nm->code_begin();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
374 tty->print_cr("Exception <%s> (0x%x) thrown in compiled method <%s> at PC " PTR_FORMAT " [" PTR_FORMAT "+%d] for thread 0x%x",
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
375 exception->print_value_string(), (address)exception(), nm->method()->print_value_string(), pc, nm->code_begin(), offset, thread);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
376 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
377 // for AbortVMOnException flag
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
378 NOT_PRODUCT(Exceptions::debug_check_abort(exception));
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
379
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
380 // Clear out the exception oop and pc since looking up an
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
381 // exception handler can cause class loading, which might throw an
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
382 // exception and those fields are expected to be clear during
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
383 // normal bytecode execution.
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
384 thread->set_exception_oop(NULL);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
385 thread->set_exception_pc(NULL);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
386
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
387 continuation = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, false, false);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
388 // If an exception was thrown during exception dispatch, the exception oop may have changed
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
389 thread->set_exception_oop(exception());
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
390 thread->set_exception_pc(pc);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
391
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
392 // the exception cache is used only by non-implicit exceptions
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
393 if (continuation != NULL && !SharedRuntime::deopt_blob()->contains(continuation)) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
394 nm->add_handler_for_exception_and_pc(exception, pc, continuation);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
395 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
396 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
397
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
398 thread->set_vm_result(exception());
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
399 // Set flag if return address is a method handle call site.
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
400 thread->set_is_method_handle_return(nm->is_method_handle_return(pc));
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
401
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
402 if (TraceExceptions) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
403 ttyLocker ttyl;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
404 ResourceMark rm;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
405 tty->print_cr("Thread " PTR_FORMAT " continuing at PC " PTR_FORMAT " for exception thrown at PC " PTR_FORMAT,
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
406 thread, continuation, pc);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
407 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
408
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
409 return continuation;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
410 JRT_END
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
411
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
412 // Enter this method from compiled code only if there is a Java exception handler
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
413 // in the method handling the exception.
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
414 // We are entering here from exception stub. We don't do a normal VM transition here.
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
415 // We do it in a helper. This is so we can check to see if the nmethod we have just
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
416 // searched for an exception handler has been deoptimized in the meantime.
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
417 address GraalRuntime::exception_handler_for_pc(JavaThread* thread) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
418 oop exception = thread->exception_oop();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
419 address pc = thread->exception_pc();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
420 // Still in Java mode
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
421 DEBUG_ONLY(ResetNoHandleMark rnhm);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
422 nmethod* nm = NULL;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
423 address continuation = NULL;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
424 {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
425 // Enter VM mode by calling the helper
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
426 ResetNoHandleMark rnhm;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
427 continuation = exception_handler_for_pc_helper(thread, exception, pc, nm);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
428 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
429 // Back in JAVA, use no oops DON'T safepoint
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
430
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
431 // Now check to see if the nmethod we were called from is now deoptimized.
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
432 // If so we must return to the deopt blob and deoptimize the nmethod
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
433 if (nm != NULL && caller_is_deopted()) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
434 continuation = SharedRuntime::deopt_blob()->unpack_with_exception_in_tls();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
435 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
436
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
437 assert(continuation != NULL, "no handler found");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
438 return continuation;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
439 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
440
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
441 JRT_ENTRY(void, GraalRuntime::graal_create_null_exception(JavaThread* thread))
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
442 thread->set_vm_result(Exceptions::new_exception(thread, vmSymbols::java_lang_NullPointerException(), NULL)());
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
443 JRT_END
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
444
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
445 JRT_ENTRY(void, GraalRuntime::graal_create_out_of_bounds_exception(JavaThread* thread, jint index))
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
446 char message[jintAsStringSize];
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
447 sprintf(message, "%d", index);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
448 thread->set_vm_result(Exceptions::new_exception(thread, vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), message)());
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
449 JRT_END
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
450
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
451 JRT_ENTRY_NO_ASYNC(void, GraalRuntime::graal_monitorenter(JavaThread* thread, oopDesc* obj, BasicLock* lock))
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
452 if (TraceGraal >= 3) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
453 char type[O_BUFLEN];
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
454 obj->klass()->name()->as_C_string(type, O_BUFLEN);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
455 markOop mark = obj->mark();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
456 tty->print_cr("%s: entered locking slow case with obj=" INTPTR_FORMAT ", type=%s, mark=" INTPTR_FORMAT ", lock=" INTPTR_FORMAT, thread->name(), obj, type, mark, lock);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
457 tty->flush();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
458 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
459 #ifdef ASSERT
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
460 if (PrintBiasedLockingStatistics) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
461 Atomic::inc(BiasedLocking::slow_path_entry_count_addr());
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
462 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
463 #endif
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
464 Handle h_obj(thread, obj);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
465 assert(h_obj()->is_oop(), "must be NULL or an object");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
466 if (UseBiasedLocking) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
467 // Retry fast entry if bias is revoked to avoid unnecessary inflation
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
468 ObjectSynchronizer::fast_enter(h_obj, lock, true, CHECK);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
469 } else {
7154
5d0bb7d52783 changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
470 if (GraalUseFastLocking) {
7125
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
471 // When using fast locking, the compiled code has already tried the fast case
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
472 ObjectSynchronizer::slow_enter(h_obj, lock, THREAD);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
473 } else {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
474 ObjectSynchronizer::fast_enter(h_obj, lock, false, THREAD);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
475 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
476 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
477 if (TraceGraal >= 3) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
478 tty->print_cr("%s: exiting locking slow with obj=" INTPTR_FORMAT, thread->name(), obj);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
479 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
480 JRT_END
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
481
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
482
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
483 JRT_LEAF(void, GraalRuntime::graal_monitorexit(JavaThread* thread, oopDesc* obj, BasicLock* lock))
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
484 assert(thread == JavaThread::current(), "threads must correspond");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
485 assert(thread->last_Java_sp(), "last_Java_sp must be set");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
486 // monitorexit is non-blocking (leaf routine) => no exceptions can be thrown
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
487 EXCEPTION_MARK;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
488
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
489 #ifdef DEBUG
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
490 if (!obj->is_oop()) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
491 ResetNoHandleMark rhm;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
492 nmethod* method = thread->last_frame().cb()->as_nmethod_or_null();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
493 if (method != NULL) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
494 tty->print_cr("ERROR in monitorexit in method %s wrong obj " INTPTR_FORMAT, method->name(), obj);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
495 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
496 thread->print_stack_on(tty);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
497 assert(false, "invalid lock object pointer dected");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
498 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
499 #endif
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
500
7154
5d0bb7d52783 changes to support Graal co-existing with the other HotSpot compiler(s) and being used for explicit compilation requests and code installation via the Graal API
Doug Simon <doug.simon@oracle.com>
parents: 7145
diff changeset
501 if (GraalUseFastLocking) {
7125
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
502 // When using fast locking, the compiled code has already tried the fast case
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
503 ObjectSynchronizer::slow_exit(obj, lock, THREAD);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
504 } else {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
505 ObjectSynchronizer::fast_exit(obj, lock, THREAD);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
506 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
507 if (TraceGraal >= 3) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
508 char type[O_BUFLEN];
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
509 obj->klass()->name()->as_C_string(type, O_BUFLEN);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
510 tty->print_cr("%s: exited locking slow case with obj=" INTPTR_FORMAT ", type=%s, mark=" INTPTR_FORMAT ", lock=" INTPTR_FORMAT, thread->name(), obj, type, obj->mark(), lock);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
511 tty->flush();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
512 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
513 JRT_END
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
514
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
515 JRT_ENTRY(void, GraalRuntime::graal_log_object(JavaThread* thread, oop obj, jint flags))
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
516 bool string = mask_bits_are_true(flags, LOG_OBJECT_STRING);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
517 bool address = mask_bits_are_true(flags, LOG_OBJECT_ADDRESS);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
518 bool newline = mask_bits_are_true(flags, LOG_OBJECT_NEWLINE);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
519 if (!string) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
520 if (!address && obj->is_oop_or_null(true)) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
521 char buf[O_BUFLEN];
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
522 tty->print("%s@%p", obj->klass()->name()->as_C_string(buf, O_BUFLEN), obj);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
523 } else {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
524 tty->print("%p", obj);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
525 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
526 } else {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
527 ResourceMark rm;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
528 assert(obj != NULL && java_lang_String::is_instance(obj), "must be");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
529 char *buf = java_lang_String::as_utf8_string(obj);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
530 tty->print(buf);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
531 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
532 if (newline) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
533 tty->cr();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
534 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
535 JRT_END
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
536
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
537 JRT_ENTRY(void, GraalRuntime::graal_vm_error(JavaThread* thread, oop where, oop format, jlong value))
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
538 ResourceMark rm;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
539 assert(where == NULL || java_lang_String::is_instance(where), "must be");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
540 const char *error_msg = where == NULL ? "<internal Graal error>" : java_lang_String::as_utf8_string(where);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
541 char *detail_msg = NULL;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
542 if (format != NULL) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
543 const char* buf = java_lang_String::as_utf8_string(format);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
544 size_t detail_msg_length = strlen(buf) * 2;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
545 detail_msg = (char *) NEW_RESOURCE_ARRAY(u_char, detail_msg_length);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
546 jio_snprintf(detail_msg, detail_msg_length, buf, value);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
547 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
548 report_vm_error(__FILE__, __LINE__, error_msg, detail_msg);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
549 JRT_END
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
550
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
551 JRT_ENTRY(void, GraalRuntime::graal_log_printf(JavaThread* thread, oop format, jlong val))
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
552 ResourceMark rm;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
553 assert(format != NULL && java_lang_String::is_instance(format), "must be");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
554 char *buf = java_lang_String::as_utf8_string(format);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
555 tty->print(buf, val);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
556 JRT_END
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
557
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
558 JRT_ENTRY(void, GraalRuntime::graal_log_primitive(JavaThread* thread, jchar typeChar, jlong value, jboolean newline))
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
559 union {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
560 jlong l;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
561 jdouble d;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
562 jfloat f;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
563 } uu;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
564 uu.l = value;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
565 switch (typeChar) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
566 case 'z': tty->print(value == 0 ? "false" : "true"); break;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
567 case 'b': tty->print("%d", (jbyte) value); break;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
568 case 'c': tty->print("%c", (jchar) value); break;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
569 case 's': tty->print("%d", (jshort) value); break;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
570 case 'i': tty->print("%d", (jint) value); break;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
571 case 'f': tty->print("%f", uu.f); break;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
572 case 'j': tty->print(INT64_FORMAT, value); break;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
573 case 'd': tty->print("%lf", uu.d); break;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
574 default: assert(false, "unknown typeChar"); break;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
575 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
576 if (newline) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
577 tty->cr();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
578 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
579 JRT_END
5526
87e4aed94b26 Remove HotSpotCompiler interface, let HotSpotCompilerImpl implement GraalRuntime (in preparation of renaming).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 5525
diff changeset
580
5523
861f8d5a5153 Added code to resolve GraalRuntime into HotSpot. Added graal.api.test project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
581 // JVM_InitializeGraalRuntime
861f8d5a5153 Added code to resolve GraalRuntime into HotSpot. Added graal.api.test project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
582 JVM_ENTRY(jobject, JVM_InitializeGraalRuntime(JNIEnv *env, jclass graalclass))
6505
1ecf984d490c fixed an ordering issue in the initialization and retrieval of the platform specific HotSpotGraalRuntime instance
Doug Simon <doug.simon@oracle.com>
parents: 5747
diff changeset
583 return VMToCompiler::graalRuntimePermObject();
1ecf984d490c fixed an ordering issue in the initialization and retrieval of the platform specific HotSpotGraalRuntime instance
Doug Simon <doug.simon@oracle.com>
parents: 5747
diff changeset
584 JVM_END