annotate src/share/vm/graal/graalRuntime.cpp @ 7125:1baf7f1e3f23

decoupled C++ Graal runtime from C1
author Doug Simon <doug.simon@oracle.com>
date Mon, 03 Dec 2012 15:32:17 +0100
parents d5f7e737827f
children 6c46172c04bf 5a95c784febf
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);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
122 assert(oop_maps == NULL || sasm->frame_size() != no_frame_size,
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 #ifdef GRAAL
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
134 case graal_verify_oop_id:
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
135 case graal_unwind_exception_call_id:
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
136 case graal_OSR_migration_end_id:
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
137 case graal_arithmetic_frem_id:
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
138 case graal_arithmetic_drem_id:
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
139 case graal_set_deopt_info_id:
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
140 #endif
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
141 break;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
142
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
143 // All other stubs should have oopmaps
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
144 default:
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
145 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
146 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
147 #endif
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
148
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
149 // 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
150 sasm->align(BytesPerWord);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
151 // 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
152 sasm->flush();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
153 // create blob - distinguish a few special cases
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
154 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
155 &code,
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
156 CodeOffsets::frame_never_safe,
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
157 sasm->frame_size(),
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
158 oop_maps,
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
159 sasm->must_gc_arguments());
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
160 // install blob
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
161 assert(blob != NULL, "blob must exist");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
162 _blobs[id] = blob;
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
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
165
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
166 void GraalRuntime::initialize(BufferBlob* blob) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
167 // generate stubs
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
168 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
169 // printing
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
170 #ifndef PRODUCT
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
171 if (PrintSimpleStubs) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
172 ResourceMark rm;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
173 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
174 _blobs[id]->print();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
175 if (_blobs[id]->oop_maps() != NULL) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
176 _blobs[id]->oop_maps()->print();
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 }
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 #endif
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
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
183
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
184 CodeBlob* GraalRuntime::blob_for(StubID id) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
185 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
186 return _blobs[id];
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
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
189
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
190 const char* GraalRuntime::name_for(StubID id) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
191 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
192 return _blob_names[id];
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
193 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
194
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
195 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
196 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
197 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
198 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
199
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
200 #define FUNCTION_CASE(a, f) \
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
201 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
202
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
203 FUNCTION_CASE(entry, os::javaTimeMillis);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
204 FUNCTION_CASE(entry, os::javaTimeNanos);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
205 FUNCTION_CASE(entry, SharedRuntime::OSR_migration_end);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
206 FUNCTION_CASE(entry, SharedRuntime::d2f);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
207 FUNCTION_CASE(entry, SharedRuntime::d2i);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
208 FUNCTION_CASE(entry, SharedRuntime::d2l);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
209 FUNCTION_CASE(entry, SharedRuntime::dcos);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
210 FUNCTION_CASE(entry, SharedRuntime::dexp);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
211 FUNCTION_CASE(entry, SharedRuntime::dlog);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
212 FUNCTION_CASE(entry, SharedRuntime::dlog10);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
213 FUNCTION_CASE(entry, SharedRuntime::dpow);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
214 FUNCTION_CASE(entry, SharedRuntime::drem);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
215 FUNCTION_CASE(entry, SharedRuntime::dsin);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
216 FUNCTION_CASE(entry, SharedRuntime::dtan);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
217 FUNCTION_CASE(entry, SharedRuntime::f2i);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
218 FUNCTION_CASE(entry, SharedRuntime::f2l);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
219 FUNCTION_CASE(entry, SharedRuntime::frem);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
220 FUNCTION_CASE(entry, SharedRuntime::l2d);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
221 FUNCTION_CASE(entry, SharedRuntime::l2f);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
222 FUNCTION_CASE(entry, SharedRuntime::ldiv);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
223 FUNCTION_CASE(entry, SharedRuntime::lmul);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
224 FUNCTION_CASE(entry, SharedRuntime::lrem);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
225 FUNCTION_CASE(entry, SharedRuntime::lrem);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
226 FUNCTION_CASE(entry, SharedRuntime::dtrace_method_entry);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
227 FUNCTION_CASE(entry, SharedRuntime::dtrace_method_exit);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
228 #ifdef TRACE_HAVE_INTRINSICS
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
229 FUNCTION_CASE(entry, TRACE_TIME_METHOD);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
230 #endif
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 #undef FUNCTION_CASE
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
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
235
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
236 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
237 assert(klass->is_klass(), "not a class");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
238 instanceKlassHandle h(thread, klass);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
239 h->check_valid_for_instantiation(true, CHECK);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
240 // make sure klass is initialized
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
241 h->initialize(CHECK);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
242 // allocate instance and return via TLS
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
243 oop obj = h->allocate_instance(CHECK);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
244 thread->set_vm_result(obj);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
245 JRT_END
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
246
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
247
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
248 JRT_ENTRY(void, GraalRuntime::new_type_array(JavaThread* thread, Klass* klass, jint length))
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
249 // 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
250 // anymore after new_typeArray() and no GC can happen before.
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
251 // (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
252 assert(klass->is_klass(), "not a class");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
253 BasicType elt_type = TypeArrayKlass::cast(klass)->element_type();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
254 oop obj = oopFactory::new_typeArray(elt_type, length, CHECK);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
255 thread->set_vm_result(obj);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
256 // 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
257 // 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
258 if (DeoptimizeALot) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
259 deopt_caller();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
260 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
261
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
262 JRT_END
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
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
265 JRT_ENTRY(void, GraalRuntime::new_object_array(JavaThread* thread, Klass* array_klass, jint length))
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
266 // 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
267 // 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
268 // (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
269 assert(array_klass->is_klass(), "not a class");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
270 Klass* elem_klass = ObjArrayKlass::cast(array_klass)->element_klass();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
271 objArrayOop obj = oopFactory::new_objArray(elem_klass, length, CHECK);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
272 thread->set_vm_result(obj);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
273 // 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
274 // 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
275 if (DeoptimizeALot) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
276 deopt_caller();
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 JRT_END
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
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
281 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
282 assert(klass->is_klass(), "not a class");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
283 assert(rank >= 1, "rank must be nonzero");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
284 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
285 thread->set_vm_result(obj);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
286 JRT_END
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
287
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
288 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
289 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
290 JRT_END
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
291
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
292 extern void vm_exit(int code);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
293
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
294 // 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
295 // 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
296 // 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
297 // 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
298 // 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
299 // cpu directories.
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
300 //
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
301 // 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
302 // 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
303 // 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
304 // 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
305 // 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
306 // 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
307 // 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
308 // 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
309 // 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
310 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
311 // Reset method handle flag.
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
312 thread->set_is_method_handle_return(false);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
313
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
314 Handle exception(thread, ex);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
315 nm = CodeCache::find_nmethod(pc);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
316 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
317 // Adjust the pc as needed/
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
318 if (nm->is_deopt_pc(pc)) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
319 RegisterMap map(thread, false);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
320 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
321 // 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
322 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
323 pc = exception_frame.pc();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
324 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
325 #ifdef ASSERT
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
326 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
327 assert(exception->is_oop(), "just checking");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
328 // 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
329 if (!(exception->is_a(SystemDictionary::Throwable_klass()))) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
330 if (ExitVMOnVerifyError) vm_exit(-1);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
331 ShouldNotReachHere();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
332 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
333 #endif
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
334
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
335 // 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
336 // 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
337 // pages are enabled.
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
338 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
339 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
340
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
341 if (JvmtiExport::can_post_on_exceptions()) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
342 // 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
343 // 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
344 // 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
345 // 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
346 // 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
347 // 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
348 // 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
349
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
350 RegisterMap reg_map(thread);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
351 frame stub_frame = thread->last_frame();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
352 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
353
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
354 // 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
355 // 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
356 // 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
357 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
358 assert(caller_is_deopted(), "Must be deoptimized");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
359
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
360 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
361 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
362
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
363 // 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
364 if (guard_pages_enabled) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
365 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
366 if (fast_continuation != NULL) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
367 // 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
368 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
369 return fast_continuation;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
370 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
371 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
372
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
373 // 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
374 // 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
375 // 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
376 address continuation = NULL;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
377 if (guard_pages_enabled) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
378
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
379 // 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
380 // 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
381
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
382 // debugging support
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
383 // tracing
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
384 if (TraceExceptions) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
385 ttyLocker ttyl;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
386 ResourceMark rm;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
387 int offset = pc - nm->code_begin();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
388 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
389 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
390 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
391 // for AbortVMOnException flag
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
392 NOT_PRODUCT(Exceptions::debug_check_abort(exception));
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
393
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
394 // 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
395 // 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
396 // 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
397 // normal bytecode execution.
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
398 thread->set_exception_oop(NULL);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
399 thread->set_exception_pc(NULL);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
400
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
401 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
402 // 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
403 thread->set_exception_oop(exception());
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
404 thread->set_exception_pc(pc);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
405
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
406 // 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
407 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
408 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
409 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
410 }
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 thread->set_vm_result(exception());
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
413 // 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
414 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
415
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
416 if (TraceExceptions) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
417 ttyLocker ttyl;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
418 ResourceMark rm;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
419 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
420 thread, continuation, pc);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
421 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
422
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
423 return continuation;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
424 JRT_END
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
425
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
426 // 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
427 // in the method handling the exception.
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
428 // 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
429 // 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
430 // 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
431 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
432 oop exception = thread->exception_oop();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
433 address pc = thread->exception_pc();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
434 // Still in Java mode
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
435 DEBUG_ONLY(ResetNoHandleMark rnhm);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
436 nmethod* nm = NULL;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
437 address continuation = NULL;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
438 {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
439 // Enter VM mode by calling the helper
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
440 ResetNoHandleMark rnhm;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
441 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
442 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
443 // 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
444
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
445 // 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
446 // 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
447 if (nm != NULL && caller_is_deopted()) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
448 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
449 }
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 assert(continuation != NULL, "no handler found");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
452 return continuation;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
453 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
454
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
455 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
456 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
457 JRT_END
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 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
460 char message[jintAsStringSize];
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
461 sprintf(message, "%d", index);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
462 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
463 JRT_END
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
464
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
465 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
466 if (TraceGraal >= 3) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
467 char type[O_BUFLEN];
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
468 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
469 markOop mark = obj->mark();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
470 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
471 tty->flush();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
472 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
473 #ifdef ASSERT
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
474 if (PrintBiasedLockingStatistics) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
475 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
476 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
477 #endif
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
478 Handle h_obj(thread, obj);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
479 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
480 if (UseBiasedLocking) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
481 // 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
482 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
483 } else {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
484 if (UseFastLocking) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
485 // 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
486 ObjectSynchronizer::slow_enter(h_obj, lock, THREAD);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
487 } else {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
488 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
489 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
490 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
491 if (TraceGraal >= 3) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
492 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
493 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
494 JRT_END
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
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
497 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
498 assert(thread == JavaThread::current(), "threads must correspond");
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
499 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
500 // 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
501 EXCEPTION_MARK;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
502
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
503 #ifdef DEBUG
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
504 if (!obj->is_oop()) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
505 ResetNoHandleMark rhm;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
506 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
507 if (method != NULL) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
508 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
509 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
510 thread->print_stack_on(tty);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
511 assert(false, "invalid lock object pointer dected");
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 #endif
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 if (UseFastLocking) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
516 // 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
517 ObjectSynchronizer::slow_exit(obj, lock, THREAD);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
518 } else {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
519 ObjectSynchronizer::fast_exit(obj, lock, THREAD);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
520 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
521 if (TraceGraal >= 3) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
522 char type[O_BUFLEN];
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
523 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
524 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
525 tty->flush();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
526 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
527 JRT_END
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
528
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
529 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
530 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
531 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
532 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
533 if (!string) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
534 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
535 char buf[O_BUFLEN];
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
536 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
537 } else {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
538 tty->print("%p", obj);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
539 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
540 } else {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
541 ResourceMark rm;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
542 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
543 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
544 tty->print(buf);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
545 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
546 if (newline) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
547 tty->cr();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
548 }
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_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
552 ResourceMark rm;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
553 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
554 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
555 char *detail_msg = NULL;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
556 if (format != NULL) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
557 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
558 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
559 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
560 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
561 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
562 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
563 JRT_END
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
564
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
565 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
566 ResourceMark rm;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
567 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
568 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
569 tty->print(buf, val);
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
570 JRT_END
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
571
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
572 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
573 union {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
574 jlong l;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
575 jdouble d;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
576 jfloat f;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
577 } uu;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
578 uu.l = value;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
579 switch (typeChar) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
580 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
581 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
582 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
583 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
584 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
585 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
586 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
587 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
588 default: assert(false, "unknown typeChar"); break;
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
589 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
590 if (newline) {
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
591 tty->cr();
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
592 }
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 6559
diff changeset
593 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
594
5523
861f8d5a5153 Added code to resolve GraalRuntime into HotSpot. Added graal.api.test project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
595 // JVM_InitializeGraalRuntime
861f8d5a5153 Added code to resolve GraalRuntime into HotSpot. Added graal.api.test project.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
596 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
597 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
598 JVM_END