annotate src/share/vm/jvmci/jvmciJavaClasses.cpp @ 23992:1b8892b4ce9c

lazily cache the name of a HotSpotResolvedJavaMethodImpl
author Doug Simon <doug.simon@oracle.com>
date Tue, 31 Jan 2017 16:44:20 +0100
parents c5dfcc7bdfaf
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2516
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
1 /*
4181
319860ae697a Simplify FrameMap: make offsets of spill slots and outgoing parameters independent so that they can be allocated at the same time, eliminating the separate phases. This makes the separate StackBlock unnecesary. Change CiStackSlot to use byte offsets instead of spill slot index. This makes CiTarget.spillSlotSize unnecessary.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 3706
diff changeset
2 * Copyright (c) 2011, 2012 Oracle and/or its affiliates. All rights reserved.
2516
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
4 *
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
7 * published by the Free Software Foundation.
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
8 *
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
13 * accompanied this code).
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
14 *
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
15 * You should have received a copy of the GNU General Public License version
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
18 *
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
21 * questions.
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
22 */
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
23
2045
9c96c873c42b Fix includes to match new hotspot mechanism.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1435
diff changeset
24 #include "precompiled.hpp"
22734
ab84ba890aa4 8142511: must eagerly initialize classes with static fields accessed by JVMCI native code
Doug Simon <doug.simon@oracle.com>
parents: 22643
diff changeset
25 #include "utilities/exceptions.hpp"
22548
02fc27dc1da7 Rename jvmciJavaAccess.* to jvmciJavaClasses.*
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22454
diff changeset
26 #include "jvmci/jvmciJavaClasses.hpp"
2663
d7c0775d7e72 added includes to build without precompiled headers
Christian.Wimmer@Oracle.com
parents: 2516
diff changeset
27 #include "runtime/jniHandles.hpp"
d7c0775d7e72 added includes to build without precompiled headers
Christian.Wimmer@Oracle.com
parents: 2516
diff changeset
28 #include "classfile/symbolTable.hpp"
22734
ab84ba890aa4 8142511: must eagerly initialize classes with static fields accessed by JVMCI native code
Doug Simon <doug.simon@oracle.com>
parents: 22643
diff changeset
29
1434
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
30 // This function is similar to javaClasses.cpp, it computes the field offset of a (static or instance) field.
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
31 // It looks up the name and signature symbols without creating new ones, all the symbols of these classes need to be already loaded.
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
32
22734
ab84ba890aa4 8142511: must eagerly initialize classes with static fields accessed by JVMCI native code
Doug Simon <doug.simon@oracle.com>
parents: 22643
diff changeset
33 void compute_offset(int &dest_offset, Klass* klass, const char* name, const char* signature, bool static_field, TRAPS) {
17375
467ffc7f01cb print InstanceKlass information when graalJavaAccess can't find a field
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15264
diff changeset
34 InstanceKlass* ik = InstanceKlass::cast(klass);
2215
999f8086cc4f More changes to make it compile and work on win64.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 2182
diff changeset
35 Symbol* name_symbol = SymbolTable::probe(name, (int)strlen(name));
999f8086cc4f More changes to make it compile and work on win64.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 2182
diff changeset
36 Symbol* signature_symbol = SymbolTable::probe(signature, (int)strlen(signature));
9338
0266549ff6e0 added support from compiled stubs to be installed as RuntimeStubs and to be able to directly call C/C++ runtime functions (GRAAL-81)
Doug Simon <doug.simon@oracle.com>
parents: 6948
diff changeset
37 if (name_symbol == NULL || signature_symbol == NULL) {
17375
467ffc7f01cb print InstanceKlass information when graalJavaAccess can't find a field
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15264
diff changeset
38 #ifndef PRODUCT
467ffc7f01cb print InstanceKlass information when graalJavaAccess can't find a field
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15264
diff changeset
39 ik->print_on(tty);
467ffc7f01cb print InstanceKlass information when graalJavaAccess can't find a field
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 15264
diff changeset
40 #endif
22054
0e095e2c24e2 Rename com.oracle.jvmci to jdk.internal.jvmci
twisti
parents: 21559
diff changeset
41 fatal(err_msg("symbol with name %s and signature %s was not found in symbol table (klass=%s)", name, signature, klass->name()->as_C_string()));
5553
511612d1b5c1 Fix renamings in C++ part.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 4181
diff changeset
42 }
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
43
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
44 fieldDescriptor fd;
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
45 if (!ik->find_field(name_symbol, signature_symbol, &fd)) {
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
46 ResourceMark rm;
9669
ed6202820ecf renamed HotSpotCompilationResult to HotSpotCompiledCode and added subclasses HotSpotCompiledNmethod and HotSpotCompiledRuntimeStub
Doug Simon <doug.simon@oracle.com>
parents: 9661
diff changeset
47 fatal(err_msg("Invalid layout of %s at %s", name_symbol->as_C_string(), ik->external_name()));
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
48 }
4181
319860ae697a Simplify FrameMap: make offsets of spill slots and outgoing parameters independent so that they can be allocated at the same time, eliminating the separate phases. This makes the separate StackBlock unnecesary. Change CiStackSlot to use byte offsets instead of spill slot index. This makes CiTarget.spillSlotSize unnecessary.
Christian Wimmer <Christian.Wimmer@Oracle.com>
parents: 3706
diff changeset
49 guarantee(fd.is_static() == static_field, "static/instance mismatch");
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
50 dest_offset = fd.offset();
22454
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22054
diff changeset
51 assert(dest_offset != 0, "must be valid offset");
22734
ab84ba890aa4 8142511: must eagerly initialize classes with static fields accessed by JVMCI native code
Doug Simon <doug.simon@oracle.com>
parents: 22643
diff changeset
52 if (static_field) {
ab84ba890aa4 8142511: must eagerly initialize classes with static fields accessed by JVMCI native code
Doug Simon <doug.simon@oracle.com>
parents: 22643
diff changeset
53 // Must ensure classes for static fields are initialized as the
ab84ba890aa4 8142511: must eagerly initialize classes with static fields accessed by JVMCI native code
Doug Simon <doug.simon@oracle.com>
parents: 22643
diff changeset
54 // accessor itself does not include a class initialization check.
ab84ba890aa4 8142511: must eagerly initialize classes with static fields accessed by JVMCI native code
Doug Simon <doug.simon@oracle.com>
parents: 22643
diff changeset
55 ik->initialize(CHECK);
ab84ba890aa4 8142511: must eagerly initialize classes with static fields accessed by JVMCI native code
Doug Simon <doug.simon@oracle.com>
parents: 22643
diff changeset
56 }
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
57 }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
58
21559
be896a1983c0 recast all Graal native code as JVMCI code (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents: 19782
diff changeset
59 // This piece of macro magic creates the contents of the jvmci_compute_offsets method that initializes the field indices of all the access classes.
1434
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
60
6948
e522a00b91aa Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/ after NPG - C++ build works
Doug Simon <doug.simon@oracle.com>
parents: 5553
diff changeset
61 #define START_CLASS(name) { Klass* k = SystemDictionary::name##_klass(); assert(k != NULL, "Could not find class " #name "");
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
62
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
63 #define END_CLASS }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
64
22734
ab84ba890aa4 8142511: must eagerly initialize classes with static fields accessed by JVMCI native code
Doug Simon <doug.simon@oracle.com>
parents: 22643
diff changeset
65 #define FIELD(klass, name, signature, static_field) compute_offset(klass::_##name##_offset, k, #name, signature, static_field, CHECK);
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
66 #define CHAR_FIELD(klass, name) FIELD(klass, name, "C", false)
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
67 #define INT_FIELD(klass, name) FIELD(klass, name, "I", false)
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
68 #define BOOLEAN_FIELD(klass, name) FIELD(klass, name, "Z", false)
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
69 #define LONG_FIELD(klass, name) FIELD(klass, name, "J", false)
2926
0e3ec0a4eda4 RiTypeProfile information and invocation counters for RiMethods
Lukas Stadler <lukas.stadler@jku.at>
parents: 2891
diff changeset
70 #define FLOAT_FIELD(klass, name) FIELD(klass, name, "F", false)
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
71 #define OOP_FIELD(klass, name, signature) FIELD(klass, name, signature, false)
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
72 #define STATIC_OOP_FIELD(klass, name, signature) FIELD(klass, name, signature, true)
15264
29e3ba750c9e graalCodeInstaller translate BytecodeFrame::BEFORE_BCI into SynchronizationEntryBCI
Gilles Duboscq <duboscq@ssw.jku.at>
parents: 15161
diff changeset
73 #define STATIC_INT_FIELD(klass, name) FIELD(klass, name, "I", true)
19782
29916dcee0b8 Verify dependencies when assertions are enabled
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 18172
diff changeset
74 #define STATIC_BOOLEAN_FIELD(klass, name) FIELD(klass, name, "Z", true)
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
75
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
76
22752
c5dfcc7bdfaf Make JVMCIJavaClasses look a little more like JDK9 version
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22734
diff changeset
77 void JVMCIJavaClasses::compute_offsets(TRAPS) {
22454
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22054
diff changeset
78 COMPILER_CLASSES_DO(START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, BOOLEAN_FIELD, LONG_FIELD, FLOAT_FIELD, OOP_FIELD, OOP_FIELD, OOP_FIELD, STATIC_OOP_FIELD, STATIC_OOP_FIELD, STATIC_INT_FIELD, STATIC_BOOLEAN_FIELD)
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
79 }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
80
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
81 #define EMPTY0
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
82 #define EMPTY1(x)
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
83 #define EMPTY2(x,y)
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
84 #define FIELD2(klass, name) int klass::_##name##_offset = 0;
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
85 #define FIELD3(klass, name, sig) FIELD2(klass, name)
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
86
22454
76af33d4d504 Make jvmci redefinition safe
Tom Rodriguez <tom.rodriguez@oracle.com>
parents: 22054
diff changeset
87 COMPILER_CLASSES_DO(EMPTY1, EMPTY0, FIELD2, FIELD2, FIELD2, FIELD2, FIELD2, FIELD3, FIELD3, FIELD3, FIELD3, FIELD3, FIELD2, FIELD2)
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
88
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
89
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
90
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
91
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
92