annotate src/share/vm/graal/graalEnv.cpp @ 3650:0e8a2a629afb

Pass-by compilation broker.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Wed, 16 Nov 2011 21:27:28 +0100
parents 2fd96b3040b9
children 6aef50c6d967
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
1 /*
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
4 *
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
7 * published by the Free Software Foundation.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
8 *
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
13 * accompanied this code).
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
14 *
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
18 *
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
21 * questions.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
22 *
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
23 */
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
24
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
25 #include "precompiled.hpp"
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
26 #include "graal/graalEnv.hpp"
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
27 #include "classfile/systemDictionary.hpp"
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
28 #include "classfile/vmSymbols.hpp"
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
29 #include "code/scopeDesc.hpp"
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
30 #include "compiler/compileBroker.hpp"
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31 #include "compiler/compileLog.hpp"
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
32 #include "compiler/compilerOracle.hpp"
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
33 #include "interpreter/linkResolver.hpp"
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34 #include "memory/allocation.inline.hpp"
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
35 #include "memory/oopFactory.hpp"
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
36 #include "memory/universe.inline.hpp"
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
37 #include "oops/methodDataOop.hpp"
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
38 #include "oops/objArrayKlass.hpp"
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
39 #include "prims/jvmtiExport.hpp"
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
40 #include "prims/methodHandleWalk.hpp"
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
41 #include "runtime/init.hpp"
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
42 #include "runtime/reflection.hpp"
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
43 #include "runtime/sharedRuntime.hpp"
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
44 #include "utilities/dtrace.hpp"
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
45 #include "c1/c1_Runtime1.hpp"
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
46
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
47 // ------------------------------------------------------------------
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
48 // ciEnv::check_klass_accessiblity
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
49 //
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
50 // Note: the logic of this method should mirror the logic of
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
51 // constantPoolOopDesc::verify_constant_pool_resolve.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
52 bool GraalEnv::check_klass_accessibility(klassOop accessing_klass, klassOop resolved_klass) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
53 if (accessing_klass->klass_part()->oop_is_objArray()) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
54 accessing_klass = ((objArrayKlass*)accessing_klass)->bottom_klass();
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
55 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
56 if (!accessing_klass->klass_part()->oop_is_instance()) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
57 return true;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
58 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
59
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
60 if (resolved_klass->klass_part()->oop_is_objArray()) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
61 // Find the element klass, if this is an array.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
62 resolved_klass = objArrayKlass::cast(resolved_klass)->bottom_klass();
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
63 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
64 if (resolved_klass->klass_part()->oop_is_instance()) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
65 return Reflection::verify_class_access(accessing_klass, resolved_klass, true);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
66 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
67 return true;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
68 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
69
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
70 // ------------------------------------------------------------------
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
71 // ciEnv::get_klass_by_name_impl
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
72 klassOop GraalEnv::get_klass_by_name_impl(KlassHandle accessing_klass,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
73 constantPoolHandle cpool,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
74 Symbol* sym,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
75 bool require_local) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
76 EXCEPTION_CONTEXT;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
77
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
78 // Now we need to check the SystemDictionary
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
79 if (sym->byte_at(0) == 'L' &&
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
80 sym->byte_at(sym->utf8_length()-1) == ';') {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
81 // This is a name from a signature. Strip off the trimmings.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
82 // Call recursive to keep scope of strippedsym.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
83 TempNewSymbol strippedsym = SymbolTable::new_symbol(sym->as_utf8()+1,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
84 sym->utf8_length()-2,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
85 CHECK_NULL);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
86 return get_klass_by_name_impl(accessing_klass, cpool, strippedsym, require_local);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
87 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
88
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
89 Handle loader(THREAD, (oop)NULL);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
90 Handle domain(THREAD, (oop)NULL);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
91 if (!accessing_klass.is_null()) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
92 loader = Handle(THREAD, accessing_klass->class_loader());
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
93 domain = Handle(THREAD, accessing_klass->protection_domain());
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
94 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
95
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
96 KlassHandle found_klass;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
97 {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
98 ttyUnlocker ttyul; // release tty lock to avoid ordering problems
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
99 MutexLocker ml(Compile_lock);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
100 klassOop kls;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
101 if (!require_local) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
102 kls = SystemDictionary::find_constrained_instance_or_array_klass(sym, loader, CHECK_NULL);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
103 } else {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
104 kls = SystemDictionary::find_instance_or_array_klass(sym, loader, domain, CHECK_NULL);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
105 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
106 found_klass = KlassHandle(THREAD, kls);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
107 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
108
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
109 // If we fail to find an array klass, look again for its element type.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
110 // The element type may be available either locally or via constraints.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
111 // In either case, if we can find the element type in the system dictionary,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
112 // we must build an array type around it. The CI requires array klasses
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
113 // to be loaded if their element klasses are loaded, except when memory
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
114 // is exhausted.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
115 if (sym->byte_at(0) == '[' &&
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
116 (sym->byte_at(1) == '[' || sym->byte_at(1) == 'L')) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
117 // We have an unloaded array.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
118 // Build it on the fly if the element class exists.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
119 TempNewSymbol elem_sym = SymbolTable::new_symbol(sym->as_utf8()+1,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
120 sym->utf8_length()-1,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
121 CHECK_NULL);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
122
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
123 // Get element ciKlass recursively.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
124 KlassHandle elem_klass =
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
125 get_klass_by_name_impl(accessing_klass,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
126 cpool,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
127 elem_sym,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
128 require_local);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
129 if (!elem_klass.is_null()) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
130 // Now make an array for it
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
131 return elem_klass->array_klass(CHECK_NULL);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
132 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
133 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
134
3639
2fd96b3040b9 Fixed build issue.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3636
diff changeset
135 if (found_klass.is_null() && !cpool.is_null() && cpool->has_preresolution()) {
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
136 // Look inside the constant pool for pre-resolved class entries.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
137 for (int i = cpool->length() - 1; i >= 1; i--) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
138 if (cpool->tag_at(i).is_klass()) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
139 klassOop kls = cpool->resolved_klass_at(i);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
140 if (Klass::cast(kls)->name() == sym) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
141 return kls;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
142 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
143 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
144 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
145 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
146
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
147 return found_klass();
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
148 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
149
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
150 // ------------------------------------------------------------------
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
151 // ciEnv::get_klass_by_name
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
152 KlassHandle GraalEnv::get_klass_by_name(KlassHandle accessing_klass,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
153 Symbol* klass_name,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
154 bool require_local) {
3650
0e8a2a629afb Pass-by compilation broker.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3639
diff changeset
155 ResourceMark rm;
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
156 return get_klass_by_name_impl(accessing_klass,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
157 constantPoolHandle(),
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
158 klass_name,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
159 require_local);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
160 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
161
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
162 // ------------------------------------------------------------------
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
163 // ciEnv::get_klass_by_index_impl
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
164 //
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
165 // Implementation of get_klass_by_index.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
166 klassOop GraalEnv::get_klass_by_index_impl(constantPoolHandle cpool,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
167 int index,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
168 bool& is_accessible,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
169 KlassHandle accessor) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
170 EXCEPTION_CONTEXT;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
171 KlassHandle klass (THREAD, constantPoolOopDesc::klass_at_if_loaded(cpool, index));
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
172 Symbol* klass_name = NULL;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
173 if (klass.is_null()) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
174 // The klass has not been inserted into the constant pool.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
175 // Try to look it up by name.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
176 {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
177 // We have to lock the cpool to keep the oop from being resolved
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
178 // while we are accessing it.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
179 ObjectLocker ol(cpool, THREAD);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
180
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
181 constantTag tag = cpool->tag_at(index);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
182 if (tag.is_klass()) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
183 // The klass has been inserted into the constant pool
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
184 // very recently.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
185 klass = KlassHandle(THREAD, cpool->resolved_klass_at(index));
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
186 } else if (tag.is_symbol()) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
187 klass_name = cpool->symbol_at(index);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
188 } else {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
189 assert(cpool->tag_at(index).is_unresolved_klass(), "wrong tag");
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
190 klass_name = cpool->unresolved_klass_at(index);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
191 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
192 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
193 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
194
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
195 if (klass.is_null()) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
196 // Not found in constant pool. Use the name to do the lookup.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
197 KlassHandle k = get_klass_by_name_impl(accessor,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
198 cpool,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
199 klass_name,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
200 false);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
201 // Calculate accessibility the hard way.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
202 if (k.is_null()) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
203 is_accessible = false;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
204 } else if (k->class_loader() != accessor->class_loader() &&
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
205 get_klass_by_name_impl(accessor, cpool, k->name(), true) == NULL) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
206 // Loaded only remotely. Not linked yet.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
207 is_accessible = false;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
208 } else {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
209 // Linked locally, and we must also check public/private, etc.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
210 is_accessible = check_klass_accessibility(accessor(), k());
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
211 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
212 return k();
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
213 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
214
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
215 // Check for prior unloaded klass. The SystemDictionary's answers
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
216 // can vary over time but the compiler needs consistency.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
217 Symbol* name = klass()->klass_part()->name();
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
218
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
219 // It is known to be accessible, since it was found in the constant pool.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
220 is_accessible = true;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
221 return klass();
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
222 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
223
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
224 // ------------------------------------------------------------------
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
225 // ciEnv::get_klass_by_index
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
226 //
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
227 // Get a klass from the constant pool.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
228 KlassHandle GraalEnv::get_klass_by_index(constantPoolHandle cpool,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
229 int index,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
230 bool& is_accessible,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
231 KlassHandle accessor) {
3650
0e8a2a629afb Pass-by compilation broker.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3639
diff changeset
232 ResourceMark rm;
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
233 return get_klass_by_index_impl(cpool, index, is_accessible, accessor);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
234 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
235
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
236 // ------------------------------------------------------------------
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
237 // ciEnv::get_field_by_index_impl
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
238 //
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
239 // Implementation of get_field_by_index.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
240 //
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
241 // Implementation note: the results of field lookups are cached
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
242 // in the accessor klass.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
243 void GraalEnv::get_field_by_index_impl(instanceKlassHandle klass, fieldDescriptor& field_desc,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
244 int index) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
245 EXCEPTION_CONTEXT;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
246
3636
c7d4198a9bce Use GraalEnv for installing code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3635
diff changeset
247 assert(klass->is_linked(), "must be linked before using its constan-pool");
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
248
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
249 constantPoolHandle cpool(thread, klass->constants());
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
250
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
251 // Get the field's name, signature, and type.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
252 Symbol* name = cpool->name_ref_at(index);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
253
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
254 int nt_index = cpool->name_and_type_ref_index_at(index);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
255 int sig_index = cpool->signature_ref_index_at(nt_index);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
256 Symbol* signature = cpool->symbol_at(sig_index);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
257
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
258 // Get the field's declared holder.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
259 //
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
260 // Note: we actually create a ciInstanceKlass for this klass,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
261 // even though we may not need to.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
262 int holder_index = cpool->klass_ref_index_at(index);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
263 bool holder_is_accessible;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
264 KlassHandle declared_holder = get_klass_by_index(cpool, holder_index,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
265 holder_is_accessible,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
266 klass);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
267
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
268 // The declared holder of this field may not have been loaded.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
269 // Bail out with partial field information.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
270 if (!holder_is_accessible) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
271 return;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
272 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
273
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
274
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
275 // Perform the field lookup.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
276 klassOop canonical_holder =
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
277 instanceKlass::cast(declared_holder())->find_field(name, signature, &field_desc);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
278 if (canonical_holder == NULL) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
279 return;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
280 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
281
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
282 assert(canonical_holder == field_desc.field_holder(), "just checking");
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
283 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
284
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
285 // ------------------------------------------------------------------
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
286 // ciEnv::get_field_by_index
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
287 //
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
288 // Get a field by index from a klass's constant pool.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
289 void GraalEnv::get_field_by_index(instanceKlassHandle accessor, fieldDescriptor& fd,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
290 int index) {
3650
0e8a2a629afb Pass-by compilation broker.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3639
diff changeset
291 ResourceMark rm;
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
292 return get_field_by_index_impl(accessor, fd, index);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
293 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
294
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
295 // ------------------------------------------------------------------
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
296 // ciEnv::lookup_method
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
297 //
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
298 // Perform an appropriate method lookup based on accessor, holder,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
299 // name, signature, and bytecode.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
300 methodOop GraalEnv::lookup_method(instanceKlass* accessor,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
301 instanceKlass* holder,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
302 Symbol* name,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
303 Symbol* sig,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
304 Bytecodes::Code bc) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
305 EXCEPTION_CONTEXT;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
306 KlassHandle h_accessor(THREAD, accessor);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
307 KlassHandle h_holder(THREAD, holder);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
308 LinkResolver::check_klass_accessability(h_accessor, h_holder, KILL_COMPILE_ON_FATAL_(NULL));
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
309 methodHandle dest_method;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
310 switch (bc) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
311 case Bytecodes::_invokestatic:
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
312 dest_method =
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
313 LinkResolver::resolve_static_call_or_null(h_holder, name, sig, h_accessor);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
314 break;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
315 case Bytecodes::_invokespecial:
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
316 dest_method =
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
317 LinkResolver::resolve_special_call_or_null(h_holder, name, sig, h_accessor);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
318 break;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
319 case Bytecodes::_invokeinterface:
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
320 dest_method =
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
321 LinkResolver::linktime_resolve_interface_method_or_null(h_holder, name, sig,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
322 h_accessor, true);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
323 break;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
324 case Bytecodes::_invokevirtual:
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
325 dest_method =
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
326 LinkResolver::linktime_resolve_virtual_method_or_null(h_holder, name, sig,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
327 h_accessor, true);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
328 break;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
329 default: ShouldNotReachHere();
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
330 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
331
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
332 return dest_method();
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
333 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
334
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
335
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
336 // ------------------------------------------------------------------
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
337 // ciEnv::get_method_by_index_impl
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
338 methodHandle GraalEnv::get_method_by_index_impl(constantPoolHandle cpool,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
339 int index, Bytecodes::Code bc,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
340 instanceKlass* accessor) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
341 int holder_index = cpool->klass_ref_index_at(index);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
342 bool holder_is_accessible;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
343 KlassHandle holder = get_klass_by_index_impl(cpool, holder_index, holder_is_accessible, KlassHandle(Thread::current(), accessor));
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
344
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
345 // Get the method's name and signature.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
346 Symbol* name_sym = cpool->name_ref_at(index);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
347 Symbol* sig_sym = cpool->signature_ref_at(index);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
348
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
349 if (holder_is_accessible) { // Our declared holder is loaded.
3650
0e8a2a629afb Pass-by compilation broker.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3639
diff changeset
350 instanceKlass* lookup = get_instance_klass_for_declared_method_holder(holder);
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
351 methodOop m = lookup_method(accessor, lookup, name_sym, sig_sym, bc);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
352 if (m != NULL &&
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
353 (bc == Bytecodes::_invokestatic
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
354 ? instanceKlass::cast(m->method_holder())->is_not_initialized()
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
355 : !instanceKlass::cast(m->method_holder())->is_loaded())) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
356 m = NULL;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
357 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
358 if (m != NULL) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
359 // We found the method.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
360 return m;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
361 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
362 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
363
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
364 // Either the declared holder was not loaded, or the method could
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
365 // not be found. Create a dummy ciMethod to represent the failed
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
366 // lookup.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
367
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
368 return NULL;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
369 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
370
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
371 // ------------------------------------------------------------------
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
372 // ciEnv::get_instance_klass_for_declared_method_holder
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
373 instanceKlass* GraalEnv::get_instance_klass_for_declared_method_holder(KlassHandle method_holder) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
374 // For the case of <array>.clone(), the method holder can be a ciArrayKlass
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
375 // instead of a ciInstanceKlass. For that case simply pretend that the
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
376 // declared holder is Object.clone since that's where the call will bottom out.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
377 // A more correct fix would trickle out through many interfaces in CI,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
378 // requiring ciInstanceKlass* to become ciKlass* and many more places would
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
379 // require checks to make sure the expected type was found. Given that this
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
380 // only occurs for clone() the more extensive fix seems like overkill so
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
381 // instead we simply smear the array type into Object.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
382 if (method_holder->oop_is_instance()) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
383 return instanceKlass::cast(method_holder());
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
384 } else if (method_holder->oop_is_array()) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
385 return instanceKlass::cast(SystemDictionary::Object_klass());
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
386 } else {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
387 ShouldNotReachHere();
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
388 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
389 return NULL;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
390 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
391
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
392
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
393 // ------------------------------------------------------------------
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
394 // ciEnv::get_method_by_index
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
395 methodHandle GraalEnv::get_method_by_index(constantPoolHandle cpool,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
396 int index, Bytecodes::Code bc,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
397 instanceKlass* accessor) {
3650
0e8a2a629afb Pass-by compilation broker.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3639
diff changeset
398 ResourceMark rm;
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
399 assert(bc != Bytecodes::_invokedynamic, "invokedynamic not yet supported");
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
400 return get_method_by_index_impl(cpool, index, bc, accessor);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
401 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
402
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
403 // ------------------------------------------------------------------
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
404 // ciEnv::check_for_system_dictionary_modification
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
405 // Check for changes to the system dictionary during compilation
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
406 // class loads, evolution, breakpoints
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
407 bool GraalEnv::check_for_system_dictionary_modification(Dependencies* dependencies) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
408 // Dependencies must be checked when the system dictionary changes.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
409 // If logging is enabled all violated dependences will be recorded in
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
410 // the log. In debug mode check dependencies even if the system
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
411 // dictionary hasn't changed to verify that no invalid dependencies
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
412 // were inserted. Any violated dependences in this case are dumped to
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
413 // the tty.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
414
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
415 // TODO (tw): Always check dependency for now.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
416 //bool counter_changed = system_dictionary_modification_counter_changed();
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
417 //bool test_deps = counter_changed;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
418 //DEBUG_ONLY(test_deps = true);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
419 //if (!test_deps) return;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
420
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
421 for (Dependencies::DepStream deps(dependencies); deps.next(); ) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
422 klassOop witness = deps.check_dependency();
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
423 if (witness != NULL) {
3636
c7d4198a9bce Use GraalEnv for installing code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3635
diff changeset
424 return false;
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
425 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
426 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
427
3636
c7d4198a9bce Use GraalEnv for installing code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3635
diff changeset
428 return true;
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
429 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
430
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
431 // ------------------------------------------------------------------
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
432 // ciEnv::register_method
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
433 nmethod* GraalEnv::register_method(methodHandle method,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
434 int entry_bci,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
435 CodeOffsets* offsets,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
436 int orig_pc_offset,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
437 CodeBuffer* code_buffer,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
438 int frame_words,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
439 OopMapSet* oop_map_set,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
440 ExceptionHandlerTable* handler_table,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
441 ImplicitExceptionTable* inc_table,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
442 AbstractCompiler* compiler,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
443 DebugInformationRecorder* debug_info,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
444 Dependencies* dependencies,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
445 CompileTask* task,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
446 int compile_id,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
447 bool has_debug_info,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
448 bool has_unsafe_access,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
449 bool install_code) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
450 VM_ENTRY_MARK;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
451 nmethod* nm = NULL;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
452 int comp_level = CompLevel_simple;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
453 {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
454 // To prevent compile queue updates.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
455 MutexLocker locker(MethodCompileQueue_lock, THREAD);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
456
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
457 // Prevent SystemDictionary::add_to_hierarchy from running
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
458 // and invalidating our dependencies until we install this method.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
459 MutexLocker ml(Compile_lock);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
460
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
461 // Encode the dependencies now, so we can check them right away.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
462 dependencies->encode_content_bytes();
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
463
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
464 // Check for {class loads, evolution, breakpoints} during compilation
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
465 if (!check_for_system_dictionary_modification(dependencies)) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
466 // While not a true deoptimization, it is a preemptive decompile.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
467 methodDataOop mdo = method()->method_data();
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
468 if (mdo != NULL) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
469 mdo->inc_decompile_count();
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
470 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
471
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
472 // All buffers in the CodeBuffer are allocated in the CodeCache.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
473 // If the code buffer is created on each compile attempt
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
474 // as in C2, then it must be freed.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
475 code_buffer->free_blob();
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
476 return NULL;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
477 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
478
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
479 assert(offsets->value(CodeOffsets::Deopt) != -1, "must have deopt entry");
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
480 assert(offsets->value(CodeOffsets::Exceptions) != -1, "must have exception entry");
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
481
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
482 nm = nmethod::new_nmethod(method,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
483 compile_id,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
484 entry_bci,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
485 offsets,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
486 orig_pc_offset,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
487 debug_info, dependencies, code_buffer,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
488 frame_words, oop_map_set,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
489 handler_table, inc_table,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
490 compiler, comp_level);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
491
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
492 // Free codeBlobs
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
493 code_buffer->free_blob();
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
494
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
495 // stress test 6243940 by immediately making the method
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
496 // non-entrant behind the system's back. This has serious
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
497 // side effects on the code cache and is not meant for
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
498 // general stress testing
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
499 if (nm != NULL && StressNonEntrant) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
500 MutexLockerEx pl(Patching_lock, Mutex::_no_safepoint_check_flag);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
501 NativeJump::patch_verified_entry(nm->entry_point(), nm->verified_entry_point(),
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
502 SharedRuntime::get_handle_wrong_method_stub());
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
503 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
504
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
505 if (nm == NULL) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
506 // The CodeCache is full. Print out warning and disable compilation.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
507 {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
508 MutexUnlocker ml(Compile_lock);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
509 MutexUnlocker locker(MethodCompileQueue_lock);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
510 CompileBroker::handle_full_code_cache();
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
511 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
512 } else {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
513 NOT_PRODUCT(nm->set_has_debug_info(has_debug_info); )
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
514 nm->set_has_unsafe_access(has_unsafe_access);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
515
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
516 // Record successful registration.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
517 // (Put nm into the task handle *before* publishing to the Java heap.)
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
518 if (task != NULL) task->set_code(nm);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
519
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
520 if (install_code) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
521 if (entry_bci == InvocationEntryBci) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
522 if (TieredCompilation) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
523 // If there is an old version we're done with it
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
524 nmethod* old = method->code();
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
525 if (TraceMethodReplacement && old != NULL) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
526 ResourceMark rm;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
527 char *method_name = method->name_and_sig_as_C_string();
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
528 tty->print_cr("Replacing method %s", method_name);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
529 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
530 if (old != NULL ) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
531 old->make_not_entrant();
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
532 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
533 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
534 if (TraceNMethodInstalls ) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
535 ResourceMark rm;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
536 char *method_name = method->name_and_sig_as_C_string();
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
537 ttyLocker ttyl;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
538 tty->print_cr("Installing method (%d) %s ",
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
539 comp_level,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
540 method_name);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
541 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
542 // Allow the code to be executed
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
543 method->set_code(method, nm);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
544 } else {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
545 if (TraceNMethodInstalls ) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
546 ResourceMark rm;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
547 char *method_name = method->name_and_sig_as_C_string();
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
548 ttyLocker ttyl;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
549 tty->print_cr("Installing osr method (%d) %s @ %d",
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
550 comp_level,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
551 method_name,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
552 entry_bci);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
553 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
554 instanceKlass::cast(method->method_holder())->add_osr_nmethod(nm);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
555
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
556 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
557 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
558 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
559 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
560 // JVMTI -- compiled method notification (must be done outside lock)
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
561 if (nm != NULL) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
562 nm->post_compiled_method_load_event();
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
563 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
564
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
565 return nm;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
566 }