annotate src/share/vm/graal/graalEnv.cpp @ 7126:ce248dc0a656

removed all Graal modifications to ci and c1
author Doug Simon <doug.simon@oracle.com>
date Mon, 03 Dec 2012 17:54:05 +0100
parents 1baf7f1e3f23
children 5d0bb7d52783
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"
3690
f8d7ab42c479 Call NMethodSweeper::possibly_sweep() before registering a method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3674
diff changeset
30 #include "runtime/sweeper.hpp"
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
31 #include "compiler/compileBroker.hpp"
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
32 #include "compiler/compileLog.hpp"
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
33 #include "compiler/compilerOracle.hpp"
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
34 #include "interpreter/linkResolver.hpp"
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
35 #include "memory/allocation.inline.hpp"
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
36 #include "memory/oopFactory.hpp"
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
37 #include "memory/universe.inline.hpp"
6948
e522a00b91aa Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
parents: 6275
diff changeset
38 #include "oops/methodData.hpp"
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
39 #include "oops/objArrayKlass.hpp"
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
40 #include "prims/jvmtiExport.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"
7125
1baf7f1e3f23 decoupled C++ Graal runtime from C1
Doug Simon <doug.simon@oracle.com>
parents: 7113
diff changeset
45 #include "graal/graalRuntime.hpp"
3635
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 // 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
49 // constantPoolOopDesc::verify_constant_pool_resolve.
3674
d3d3dd0a3421 Fixed a regression.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3672
diff changeset
50 bool GraalEnv::check_klass_accessibility(KlassHandle accessing_klass, KlassHandle resolved_klass) {
3654
4123781869da More handles, fixed broken cast.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3653
diff changeset
51 if (accessing_klass->oop_is_objArray()) {
6948
e522a00b91aa Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
parents: 6275
diff changeset
52 accessing_klass = ObjArrayKlass::cast(accessing_klass())->bottom_klass();
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
53 }
3654
4123781869da More handles, fixed broken cast.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3653
diff changeset
54 if (!accessing_klass->oop_is_instance()) {
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
55 return true;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
56 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
57
3654
4123781869da More handles, fixed broken cast.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3653
diff changeset
58 if (resolved_klass->oop_is_objArray()) {
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
59 // Find the element klass, if this is an array.
6948
e522a00b91aa Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
parents: 6275
diff changeset
60 resolved_klass = ObjArrayKlass::cast(resolved_klass())->bottom_klass();
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
61 }
3654
4123781869da More handles, fixed broken cast.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3653
diff changeset
62 if (resolved_klass->oop_is_instance()) {
4123781869da More handles, fixed broken cast.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3653
diff changeset
63 return Reflection::verify_class_access(accessing_klass(), resolved_klass(), true);
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
64 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
65 return 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
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
68 // ------------------------------------------------------------------
3670
f198b24093f3 put back in thread transitions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3664
diff changeset
69 KlassHandle GraalEnv::get_klass_by_name_impl(KlassHandle& accessing_klass,
f198b24093f3 put back in thread transitions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3664
diff changeset
70 constantPoolHandle& cpool,
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
71 Symbol* sym,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
72 bool require_local) {
7126
ce248dc0a656 removed all Graal modifications to ci and c1
Doug Simon <doug.simon@oracle.com>
parents: 7125
diff changeset
73 GRAAL_EXCEPTION_CONTEXT;
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
74
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
75 // Now we need to check the SystemDictionary
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
76 if (sym->byte_at(0) == 'L' &&
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
77 sym->byte_at(sym->utf8_length()-1) == ';') {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
78 // 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
79 // Call recursive to keep scope of strippedsym.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
80 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
81 sym->utf8_length()-2,
3654
4123781869da More handles, fixed broken cast.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3653
diff changeset
82 CHECK_(KlassHandle()));
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
83 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
84 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
85
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
86 Handle loader(THREAD, (oop)NULL);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
87 Handle domain(THREAD, (oop)NULL);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
88 if (!accessing_klass.is_null()) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
89 loader = Handle(THREAD, accessing_klass->class_loader());
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
90 domain = Handle(THREAD, accessing_klass->protection_domain());
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
91 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
92
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
93 KlassHandle found_klass;
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 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
96 MutexLocker ml(Compile_lock);
6948
e522a00b91aa Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
parents: 6275
diff changeset
97 Klass* kls;
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
98 if (!require_local) {
3654
4123781869da More handles, fixed broken cast.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3653
diff changeset
99 kls = SystemDictionary::find_constrained_instance_or_array_klass(sym, loader, CHECK_(KlassHandle()));
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
100 } else {
3654
4123781869da More handles, fixed broken cast.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3653
diff changeset
101 kls = SystemDictionary::find_instance_or_array_klass(sym, loader, domain, CHECK_(KlassHandle()));
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
102 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
103 found_klass = KlassHandle(THREAD, kls);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
104 }
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 // 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
107 // 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
108 // 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
109 // 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
110 // 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
111 // is exhausted.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
112 if (sym->byte_at(0) == '[' &&
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
113 (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
114 // We have an unloaded array.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
115 // 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
116 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
117 sym->utf8_length()-1,
3654
4123781869da More handles, fixed broken cast.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3653
diff changeset
118 CHECK_(KlassHandle()));
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
119
7094
eec7173947a1 removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents: 7089
diff changeset
120 // Get element Klass recursively.
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
121 KlassHandle elem_klass =
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
122 get_klass_by_name_impl(accessing_klass,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
123 cpool,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
124 elem_sym,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
125 require_local);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
126 if (!elem_klass.is_null()) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
127 // Now make an array for it
3654
4123781869da More handles, fixed broken cast.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3653
diff changeset
128 return elem_klass->array_klass(CHECK_(KlassHandle()));
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
129 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
130 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
131
3639
2fd96b3040b9 Fixed build issue.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3636
diff changeset
132 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
133 // 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
134 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
135 if (cpool->tag_at(i).is_klass()) {
6948
e522a00b91aa Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
parents: 6275
diff changeset
136 Klass* kls = cpool->resolved_klass_at(i);
6989
2afd99933ae6 Remove Klass::cast from graalEnv
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6948
diff changeset
137 if (kls->name() == sym) {
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
138 return kls;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
139 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
140 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
141 }
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 return found_klass();
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 // ------------------------------------------------------------------
3670
f198b24093f3 put back in thread transitions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3664
diff changeset
148 KlassHandle GraalEnv::get_klass_by_name(KlassHandle& accessing_klass,
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
149 Symbol* klass_name,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
150 bool require_local) {
3650
0e8a2a629afb Pass-by compilation broker.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3639
diff changeset
151 ResourceMark rm;
3672
5e331d5f760e removed transition to vm in ci interface
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3670
diff changeset
152 constantPoolHandle cpool;
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
153 return get_klass_by_name_impl(accessing_klass,
3672
5e331d5f760e removed transition to vm in ci interface
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3670
diff changeset
154 cpool,
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
155 klass_name,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
156 require_local);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
157 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
158
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
159 // ------------------------------------------------------------------
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
160 // Implementation of get_klass_by_index.
3670
f198b24093f3 put back in thread transitions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3664
diff changeset
161 KlassHandle GraalEnv::get_klass_by_index_impl(constantPoolHandle& cpool,
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
162 int index,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
163 bool& is_accessible,
3670
f198b24093f3 put back in thread transitions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3664
diff changeset
164 KlassHandle& accessor) {
7126
ce248dc0a656 removed all Graal modifications to ci and c1
Doug Simon <doug.simon@oracle.com>
parents: 7125
diff changeset
165 GRAAL_EXCEPTION_CONTEXT;
6948
e522a00b91aa Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
parents: 6275
diff changeset
166 KlassHandle klass (THREAD, ConstantPool::klass_at_if_loaded(cpool, index));
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
167 Symbol* klass_name = NULL;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
168 if (klass.is_null()) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
169 // 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
170 // Try to look it up by name.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
171 {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
172 // 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
173 // while we are accessing it.
7069
e5ec98288b91 minor changes
Christian Haeubl <haeubl@ssw.jku.at>
parents: 7068
diff changeset
174 MutexLockerEx ml(cpool->lock(), Mutex::_no_safepoint_check_flag);
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
175
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
176 constantTag tag = cpool->tag_at(index);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
177 if (tag.is_klass()) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
178 // 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
179 // very recently.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
180 klass = KlassHandle(THREAD, cpool->resolved_klass_at(index));
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
181 } else if (tag.is_symbol()) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
182 klass_name = cpool->symbol_at(index);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
183 } else {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
184 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
185 klass_name = cpool->unresolved_klass_at(index);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
186 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
187 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
188 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
189
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
190 if (klass.is_null()) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
191 // 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
192 KlassHandle k = get_klass_by_name_impl(accessor,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
193 cpool,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
194 klass_name,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
195 false);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
196 // Calculate accessibility the hard way.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
197 if (k.is_null()) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
198 is_accessible = false;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
199 } else if (k->class_loader() != accessor->class_loader() &&
3674
d3d3dd0a3421 Fixed a regression.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3672
diff changeset
200 get_klass_by_name_impl(accessor, cpool, k->name(), true).is_null()) {
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
201 // Loaded only remotely. Not linked yet.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
202 is_accessible = false;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
203 } else {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
204 // Linked locally, and we must also check public/private, etc.
3670
f198b24093f3 put back in thread transitions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3664
diff changeset
205 is_accessible = check_klass_accessibility(accessor, k);
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
206 }
3674
d3d3dd0a3421 Fixed a regression.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3672
diff changeset
207 if (!is_accessible) {
d3d3dd0a3421 Fixed a regression.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3672
diff changeset
208 return KlassHandle();
d3d3dd0a3421 Fixed a regression.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3672
diff changeset
209 }
3654
4123781869da More handles, fixed broken cast.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3653
diff changeset
210 return k;
3635
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
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
213 // 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
214 is_accessible = true;
3654
4123781869da More handles, fixed broken cast.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3653
diff changeset
215 return klass;
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
216 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
217
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 // Get a klass from the constant pool.
3670
f198b24093f3 put back in thread transitions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3664
diff changeset
220 KlassHandle GraalEnv::get_klass_by_index(constantPoolHandle& cpool,
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
221 int index,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
222 bool& is_accessible,
3670
f198b24093f3 put back in thread transitions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3664
diff changeset
223 KlassHandle& accessor) {
3650
0e8a2a629afb Pass-by compilation broker.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3639
diff changeset
224 ResourceMark rm;
3674
d3d3dd0a3421 Fixed a regression.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3672
diff changeset
225 KlassHandle result = get_klass_by_index_impl(cpool, index, is_accessible, accessor);
d3d3dd0a3421 Fixed a regression.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3672
diff changeset
226 return result;
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
227 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
228
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
229 // ------------------------------------------------------------------
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
230 // Implementation of get_field_by_index.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
231 //
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
232 // 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
233 // in the accessor klass.
3670
f198b24093f3 put back in thread transitions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3664
diff changeset
234 void GraalEnv::get_field_by_index_impl(instanceKlassHandle& klass, fieldDescriptor& field_desc,
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
235 int index) {
7126
ce248dc0a656 removed all Graal modifications to ci and c1
Doug Simon <doug.simon@oracle.com>
parents: 7125
diff changeset
236 GRAAL_EXCEPTION_CONTEXT;
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
237
4603
a1238d5c6991 Small comment fix to test native code building guard in the gate.
Doug Simon <doug.simon@oracle.com>
parents: 4174
diff changeset
238 assert(klass->is_linked(), "must be linked before using its constant-pool");
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
239
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
240 constantPoolHandle cpool(thread, klass->constants());
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
241
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
242 // Get the field's name, signature, and type.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
243 Symbol* name = cpool->name_ref_at(index);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
244
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
245 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
246 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
247 Symbol* signature = cpool->symbol_at(sig_index);
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 // Get the field's declared holder.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
250 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
251 bool holder_is_accessible;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
252 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
253 holder_is_accessible,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
254 klass);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
255
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
256 // 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
257 // Bail out with partial field information.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
258 if (!holder_is_accessible) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
259 return;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
260 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
261
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
262
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
263 // Perform the field lookup.
6948
e522a00b91aa Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
parents: 6275
diff changeset
264 Klass* canonical_holder =
e522a00b91aa Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
parents: 6275
diff changeset
265 InstanceKlass::cast(declared_holder())->find_field(name, signature, &field_desc);
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
266 if (canonical_holder == NULL) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
267 return;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
268 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
269
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
270 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
271 }
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 // Get a field by index from a klass's constant pool.
6948
e522a00b91aa Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
parents: 6275
diff changeset
275 void GraalEnv::get_field_by_index(instanceKlassHandle& accessor, fieldDescriptor& fd, int index) {
3650
0e8a2a629afb Pass-by compilation broker.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3639
diff changeset
276 ResourceMark rm;
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
277 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
278 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
279
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 // 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
282 // name, signature, and bytecode.
3670
f198b24093f3 put back in thread transitions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3664
diff changeset
283 methodHandle GraalEnv::lookup_method(instanceKlassHandle& h_accessor,
f198b24093f3 put back in thread transitions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3664
diff changeset
284 instanceKlassHandle& h_holder,
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
285 Symbol* name,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
286 Symbol* sig,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
287 Bytecodes::Code bc) {
7126
ce248dc0a656 removed all Graal modifications to ci and c1
Doug Simon <doug.simon@oracle.com>
parents: 7125
diff changeset
288 GRAAL_EXCEPTION_CONTEXT;
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
289 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
290 methodHandle dest_method;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
291 switch (bc) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
292 case Bytecodes::_invokestatic:
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
293 dest_method =
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
294 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
295 break;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
296 case Bytecodes::_invokespecial:
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
297 dest_method =
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
298 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
299 break;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
300 case Bytecodes::_invokeinterface:
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
301 dest_method =
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
302 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
303 h_accessor, true);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
304 break;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
305 case Bytecodes::_invokevirtual:
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
306 dest_method =
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
307 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
308 h_accessor, true);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
309 break;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
310 default: ShouldNotReachHere();
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
311 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
312
3653
6aef50c6d967 Handlize to fix GC issue.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3650
diff changeset
313 return dest_method;
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
314 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
315
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
316
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
317 // ------------------------------------------------------------------
3670
f198b24093f3 put back in thread transitions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3664
diff changeset
318 methodHandle GraalEnv::get_method_by_index_impl(constantPoolHandle& cpool,
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
319 int index, Bytecodes::Code bc,
3670
f198b24093f3 put back in thread transitions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3664
diff changeset
320 instanceKlassHandle& accessor) {
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
321 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
322 bool holder_is_accessible;
3653
6aef50c6d967 Handlize to fix GC issue.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3650
diff changeset
323 KlassHandle holder = get_klass_by_index_impl(cpool, holder_index, holder_is_accessible, accessor);
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
324
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
325 // Get the method's name and signature.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
326 Symbol* name_sym = cpool->name_ref_at(index);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
327 Symbol* sig_sym = cpool->signature_ref_at(index);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
328
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
329 if (holder_is_accessible) { // Our declared holder is loaded.
3653
6aef50c6d967 Handlize to fix GC issue.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3650
diff changeset
330 instanceKlassHandle lookup = get_instance_klass_for_declared_method_holder(holder);
6aef50c6d967 Handlize to fix GC issue.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3650
diff changeset
331 methodHandle m = lookup_method(accessor, lookup, name_sym, sig_sym, bc);
6aef50c6d967 Handlize to fix GC issue.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3650
diff changeset
332 if (!m.is_null() &&
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
333 (bc == Bytecodes::_invokestatic
6948
e522a00b91aa Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
parents: 6275
diff changeset
334 ? InstanceKlass::cast(m->method_holder())->is_not_initialized()
e522a00b91aa Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
parents: 6275
diff changeset
335 : !InstanceKlass::cast(m->method_holder())->is_loaded())) {
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
336 m = NULL;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
337 }
3653
6aef50c6d967 Handlize to fix GC issue.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3650
diff changeset
338 if (!m.is_null()) {
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
339 // We found the method.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
340 return m;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
341 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
342 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
343
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
344 // Either the declared holder was not loaded, or the method could
7094
eec7173947a1 removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents: 7089
diff changeset
345 // not be found.
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
346
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
347 return NULL;
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
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
350 // ------------------------------------------------------------------
3670
f198b24093f3 put back in thread transitions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3664
diff changeset
351 instanceKlassHandle GraalEnv::get_instance_klass_for_declared_method_holder(KlassHandle& method_holder) {
7094
eec7173947a1 removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents: 7089
diff changeset
352 // For the case of <array>.clone(), the method holder can be an ArrayKlass*
eec7173947a1 removed remaining use of the C++ "compiler interface" (i.e. ci) by Graal for installing dependencies
Doug Simon <doug.simon@oracle.com>
parents: 7089
diff changeset
353 // instead of an InstanceKlass*. For that case simply pretend that the
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
354 // 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
355 if (method_holder->oop_is_instance()) {
3653
6aef50c6d967 Handlize to fix GC issue.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3650
diff changeset
356 return instanceKlassHandle(method_holder());
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
357 } else if (method_holder->oop_is_array()) {
3653
6aef50c6d967 Handlize to fix GC issue.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3650
diff changeset
358 return instanceKlassHandle(SystemDictionary::Object_klass());
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
359 } else {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
360 ShouldNotReachHere();
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 return NULL;
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
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
365
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
366 // ------------------------------------------------------------------
3670
f198b24093f3 put back in thread transitions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3664
diff changeset
367 methodHandle GraalEnv::get_method_by_index(constantPoolHandle& cpool,
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
368 int index, Bytecodes::Code bc,
3670
f198b24093f3 put back in thread transitions.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3664
diff changeset
369 instanceKlassHandle& accessor) {
3650
0e8a2a629afb Pass-by compilation broker.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3639
diff changeset
370 ResourceMark rm;
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
371 assert(bc != Bytecodes::_invokedynamic, "invokedynamic not yet supported");
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
372 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
373 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
374
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
375 // ------------------------------------------------------------------
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
376 // 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
377 // class loads, evolution, breakpoints
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
378 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
379 // 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
380 // 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
381 // 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
382 // 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
383 // 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
384 // the tty.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
385
5056
2f2c6347fce4 comments cleanup/retagging
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 4603
diff changeset
386 // TODO (thomaswue): Always check dependency for now.
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
387 //bool counter_changed = system_dictionary_modification_counter_changed();
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
388 //bool test_deps = counter_changed;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
389 //DEBUG_ONLY(test_deps = true);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
390 //if (!test_deps) return;
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 for (Dependencies::DepStream deps(dependencies); deps.next(); ) {
6948
e522a00b91aa Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
parents: 6275
diff changeset
393 Klass* witness = deps.check_dependency();
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
394 if (witness != NULL) {
7113
38076efb9062 Do not print code installation failures from Java.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7094
diff changeset
395 // TODO (gd) remove when thing look stable
38076efb9062 Do not print code installation failures from Java.
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 7094
diff changeset
396 deps.print_dependency(witness, true);
3636
c7d4198a9bce Use GraalEnv for installing code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3635
diff changeset
397 return false;
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
398 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
399 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
400
3636
c7d4198a9bce Use GraalEnv for installing code.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3635
diff changeset
401 return true;
3635
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 // ------------------------------------------------------------------
7089
af30115c9d0e added metering of code installation failure rate to detect excessive failure caused by overly optimistic assumptions
Doug Simon <doug.simon@oracle.com>
parents: 7069
diff changeset
405 GraalEnv::CodeInstallResult GraalEnv::register_method(
af30115c9d0e added metering of code installation failure rate to detect excessive failure caused by overly optimistic assumptions
Doug Simon <doug.simon@oracle.com>
parents: 7069
diff changeset
406 methodHandle& method,
af30115c9d0e added metering of code installation failure rate to detect excessive failure caused by overly optimistic assumptions
Doug Simon <doug.simon@oracle.com>
parents: 7069
diff changeset
407 nmethod*& nm,
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
408 int entry_bci,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
409 CodeOffsets* offsets,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
410 int orig_pc_offset,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
411 CodeBuffer* code_buffer,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
412 int frame_words,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
413 OopMapSet* oop_map_set,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
414 ExceptionHandlerTable* handler_table,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
415 ImplicitExceptionTable* inc_table,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
416 AbstractCompiler* compiler,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
417 DebugInformationRecorder* debug_info,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
418 Dependencies* dependencies,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
419 CompileTask* task,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
420 int compile_id,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
421 bool has_debug_info,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
422 bool has_unsafe_access,
7000
bf2ea3ed3bce Fixed nmethod not being unloaded after their classloader has been unloaded by initializing _graal_installed_code in an nmethod's constructor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6989
diff changeset
423 Handle installed_code) {
7126
ce248dc0a656 removed all Graal modifications to ci and c1
Doug Simon <doug.simon@oracle.com>
parents: 7125
diff changeset
424 GRAAL_EXCEPTION_CONTEXT;
3690
f8d7ab42c479 Call NMethodSweeper::possibly_sweep() before registering a method.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3674
diff changeset
425 NMethodSweeper::possibly_sweep();
7089
af30115c9d0e added metering of code installation failure rate to detect excessive failure caused by overly optimistic assumptions
Doug Simon <doug.simon@oracle.com>
parents: 7069
diff changeset
426 nm = NULL;
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
427 int comp_level = CompLevel_simple;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
428 {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
429 // To prevent compile queue updates.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
430 MutexLocker locker(MethodCompileQueue_lock, THREAD);
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 // Prevent SystemDictionary::add_to_hierarchy from running
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
433 // 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
434 MutexLocker ml(Compile_lock);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
435
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
436 // 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
437 dependencies->encode_content_bytes();
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
438
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
439 // Check for {class loads, evolution, breakpoints} during compilation
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
440 if (!check_for_system_dictionary_modification(dependencies)) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
441 // While not a true deoptimization, it is a preemptive decompile.
6948
e522a00b91aa Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
parents: 6275
diff changeset
442 MethodData* mdp = method()->method_data();
e522a00b91aa Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
parents: 6275
diff changeset
443 if (mdp != NULL) {
e522a00b91aa Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
parents: 6275
diff changeset
444 mdp->inc_decompile_count();
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
445 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
446
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
447 // 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
448 // 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
449 // as in C2, then it must be freed.
3664
6e1abd79e7c8 Register assumptions before anything else. Don't free code blob (it is reused).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3661
diff changeset
450 //code_buffer->free_blob();
7089
af30115c9d0e added metering of code installation failure rate to detect excessive failure caused by overly optimistic assumptions
Doug Simon <doug.simon@oracle.com>
parents: 7069
diff changeset
451 return GraalEnv::dependencies_failed;
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
452 }
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 nm = nmethod::new_nmethod(method,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
455 compile_id,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
456 entry_bci,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
457 offsets,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
458 orig_pc_offset,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
459 debug_info, dependencies, code_buffer,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
460 frame_words, oop_map_set,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
461 handler_table, inc_table,
7000
bf2ea3ed3bce Fixed nmethod not being unloaded after their classloader has been unloaded by initializing _graal_installed_code in an nmethod's constructor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6989
diff changeset
462 compiler, comp_level, installed_code);
3635
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 // Free codeBlobs
3664
6e1abd79e7c8 Register assumptions before anything else. Don't free code blob (it is reused).
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3661
diff changeset
465 //code_buffer->free_blob();
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
466
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
467 // stress test 6243940 by immediately making the method
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
468 // 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
469 // 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
470 // general stress testing
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
471 if (nm != NULL && StressNonEntrant) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
472 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
473 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
474 SharedRuntime::get_handle_wrong_method_stub());
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
475 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
476
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
477 if (nm == NULL) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
478 // 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
479 {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
480 MutexUnlocker ml(Compile_lock);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
481 MutexUnlocker locker(MethodCompileQueue_lock);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
482 CompileBroker::handle_full_code_cache();
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
483 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
484 } else {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
485 nm->set_has_unsafe_access(has_unsafe_access);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
486
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
487 // Record successful registration.
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
488 // (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
489 if (task != NULL) task->set_code(nm);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
490
7000
bf2ea3ed3bce Fixed nmethod not being unloaded after their classloader has been unloaded by initializing _graal_installed_code in an nmethod's constructor
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 6989
diff changeset
491 if (installed_code.is_null()) {
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
492 if (entry_bci == InvocationEntryBci) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
493 if (TieredCompilation) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
494 // 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
495 nmethod* old = method->code();
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
496 if (TraceMethodReplacement && old != NULL) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
497 ResourceMark rm;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
498 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
499 tty->print_cr("Replacing method %s", method_name);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
500 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
501 if (old != NULL ) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
502 old->make_not_entrant();
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 }
5251
467de393651a optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents: 5056
diff changeset
505 if (TraceNMethodInstalls) {
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
506 ResourceMark rm;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
507 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
508 ttyLocker ttyl;
5251
467de393651a optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents: 5056
diff changeset
509 tty->print_cr("Installing method (%d) %s [entry point: %p]",
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
510 comp_level,
5251
467de393651a optimization: frame prologue & epilogue ommitted for methods with no spills, no callee-saved registers, no incoming stack args and no debug info
Doug Simon <doug.simon@oracle.com>
parents: 5056
diff changeset
511 method_name, nm->entry_point());
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
512 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
513 // Allow the code to be executed
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
514 method->set_code(method, nm);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
515 } else {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
516 if (TraceNMethodInstalls ) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
517 ResourceMark rm;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
518 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
519 ttyLocker ttyl;
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
520 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
521 comp_level,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
522 method_name,
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
523 entry_bci);
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
524 }
6948
e522a00b91aa Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
parents: 6275
diff changeset
525 InstanceKlass::cast(method->method_holder())->add_osr_nmethod(nm);
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
526
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
527 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
528 }
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 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
531 // 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
532 if (nm != NULL) {
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
533 nm->post_compiled_method_load_event();
7089
af30115c9d0e added metering of code installation failure rate to detect excessive failure caused by overly optimistic assumptions
Doug Simon <doug.simon@oracle.com>
parents: 7069
diff changeset
534 return GraalEnv::ok;
3635
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
535 }
cb1181db8bec Initial port of ciEnv to graalEnv.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
diff changeset
536
7089
af30115c9d0e added metering of code installation failure rate to detect excessive failure caused by overly optimistic assumptions
Doug Simon <doug.simon@oracle.com>
parents: 7069
diff changeset
537 return GraalEnv::cache_full;
3703
50a1d38cd7ac Add newlines at the end of files, otherwise my version of gcc complains
Christian Wimmer <christian.wimmer@oracle.com>
parents: 3690
diff changeset
538 }
50a1d38cd7ac Add newlines at the end of files, otherwise my version of gcc complains
Christian Wimmer <christian.wimmer@oracle.com>
parents: 3690
diff changeset
539