annotate src/share/vm/graal/graalCodeInstaller.cpp @ 3619:5e9645341ec3

support for new RiRuntime features: add code without making it the default for the method, executing Java tasks on the compile thread, communicate nmethod reference to Java code as HotSpotCompiledMethod
author Lukas Stadler <lukas.stadler@jku.at>
date Wed, 09 Nov 2011 11:27:38 +0100
parents af1319bc4fd5
children c7d4198a9bce 6c04a4f268e5
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 /*
a384fac3fd34 Removed anything OSR-related.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2502
diff changeset
2 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
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: 1942
diff changeset
24 #include "precompiled.hpp"
2891
75a99b4f1c98 Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2890
diff changeset
25 #include "graal/graalCompiler.hpp"
75a99b4f1c98 Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2890
diff changeset
26 #include "graal/graalCodeInstaller.hpp"
75a99b4f1c98 Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2890
diff changeset
27 #include "graal/graalJavaAccess.hpp"
3011
f00918f35c7f inlining and runtime interface related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2951
diff changeset
28 #include "graal/graalVMEntries.hpp"
2891
75a99b4f1c98 Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2890
diff changeset
29 #include "graal/graalVmIds.hpp"
2045
9c96c873c42b Fix includes to match new hotspot mechanism.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1942
diff changeset
30 #include "c1/c1_Runtime1.hpp"
2048
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
31 #include "classfile/vmSymbols.hpp"
2045
9c96c873c42b Fix includes to match new hotspot mechanism.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1942
diff changeset
32 #include "vmreg_x86.inline.hpp"
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
33
1434
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
34
1433
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
35 // TODO this should be handled in a more robust way - not hard coded...
1444
c0e244017dad Corrections of oop map generation.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1441
diff changeset
36 Register CPU_REGS[] = { rax, rcx, rdx, rbx, rsp, rbp, rsi, rdi, r8, r9, r10, r11, r12, r13, r14, r15 };
c0e244017dad Corrections of oop map generation.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1441
diff changeset
37 bool OOP_ALLOWED[] = {true, true, true, true, false, false, true, true, true, true, false, true, true, true, true, true};
1438
a7a0ef3c6858 Added timing printout on VM shutdown.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1435
diff changeset
38 const static int NUM_CPU_REGS = sizeof(CPU_REGS) / sizeof(Register);
1433
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
39 XMMRegister XMM_REGS[] = { xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7, xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15 };
1438
a7a0ef3c6858 Added timing printout on VM shutdown.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1435
diff changeset
40 const static int NUM_XMM_REGS = sizeof(XMM_REGS) / sizeof(XMMRegister);
1433
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
41 const static int NUM_REGS = NUM_CPU_REGS + NUM_XMM_REGS;
1468
e4cd5d2de7e1 Changes to sync with CRI changes.
Doug Simon <doug.simon@oracle.com>
parents: 1465
diff changeset
42 const static jlong NO_REF_MAP = 0x8000000000000000L;
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
43
2891
75a99b4f1c98 Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2890
diff changeset
44 // convert graal register indices (as used in oop maps) to hotspot registers
75a99b4f1c98 Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2890
diff changeset
45 VMReg get_hotspot_reg(jint graal_reg) {
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
46
2891
75a99b4f1c98 Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2890
diff changeset
47 assert(graal_reg >= 0 && graal_reg < NUM_REGS, "invalid register number");
75a99b4f1c98 Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2890
diff changeset
48 if (graal_reg < NUM_CPU_REGS) {
75a99b4f1c98 Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2890
diff changeset
49 return CPU_REGS[graal_reg]->as_VMReg();
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
50 } else {
2891
75a99b4f1c98 Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2890
diff changeset
51 return XMM_REGS[graal_reg - NUM_CPU_REGS]->as_VMReg();
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
52 }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
53 }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
54
1469
52bb06250d35 Converted CiDebugInfo.registerRefMap field from type long to CiBitMap.
Doug Simon <doug.simon@oracle.com>
parents: 1468
diff changeset
55 static bool is_bit_set(oop bit_map, int i) {
1470
ef7761803480 Fixes to get running again after C1X changes to pointer maps and register configuration.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1469
diff changeset
56 const int MapWordBits = 64;
ef7761803480 Fixes to get running again after C1X changes to pointer maps and register configuration.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1469
diff changeset
57 if (i < MapWordBits) {
3028
1305cb3809c1 Performed folder and class name changes in native code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3018
diff changeset
58 jlong low = GraalBitMap::low(bit_map);
2215
999f8086cc4f More changes to make it compile and work on win64.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 2182
diff changeset
59 return (low & (1LL << i)) != 0;
1469
52bb06250d35 Converted CiDebugInfo.registerRefMap field from type long to CiBitMap.
Doug Simon <doug.simon@oracle.com>
parents: 1468
diff changeset
60 } else {
52bb06250d35 Converted CiDebugInfo.registerRefMap field from type long to CiBitMap.
Doug Simon <doug.simon@oracle.com>
parents: 1468
diff changeset
61 jint extra_idx = (i - MapWordBits) / MapWordBits;
3028
1305cb3809c1 Performed folder and class name changes in native code.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3018
diff changeset
62 arrayOop extra = (arrayOop) GraalBitMap::extra(bit_map);
1469
52bb06250d35 Converted CiDebugInfo.registerRefMap field from type long to CiBitMap.
Doug Simon <doug.simon@oracle.com>
parents: 1468
diff changeset
63 assert(extra_idx >= 0 && extra_idx < extra->length(), "unexpected index");
52bb06250d35 Converted CiDebugInfo.registerRefMap field from type long to CiBitMap.
Doug Simon <doug.simon@oracle.com>
parents: 1468
diff changeset
64 jlong word = ((jlong*) extra->base(T_LONG))[extra_idx];
2215
999f8086cc4f More changes to make it compile and work on win64.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 2182
diff changeset
65 return (word & (1LL << (i % MapWordBits))) != 0;
1469
52bb06250d35 Converted CiDebugInfo.registerRefMap field from type long to CiBitMap.
Doug Simon <doug.simon@oracle.com>
parents: 1468
diff changeset
66 }
52bb06250d35 Converted CiDebugInfo.registerRefMap field from type long to CiBitMap.
Doug Simon <doug.simon@oracle.com>
parents: 1468
diff changeset
67 }
52bb06250d35 Converted CiDebugInfo.registerRefMap field from type long to CiBitMap.
Doug Simon <doug.simon@oracle.com>
parents: 1468
diff changeset
68
1432
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
69 // creates a hotspot oop map out of the byte arrays provided by CiDebugInfo
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
70 static OopMap* create_oop_map(jint frame_size, jint parameter_count, oop debug_info) {
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
71 OopMap* map = new OopMap(frame_size, parameter_count);
1469
52bb06250d35 Converted CiDebugInfo.registerRefMap field from type long to CiBitMap.
Doug Simon <doug.simon@oracle.com>
parents: 1468
diff changeset
72 oop register_map = (oop) CiDebugInfo::registerRefMap(debug_info);
1468
e4cd5d2de7e1 Changes to sync with CRI changes.
Doug Simon <doug.simon@oracle.com>
parents: 1465
diff changeset
73 oop frame_map = (oop) CiDebugInfo::frameRefMap(debug_info);
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
74
1469
52bb06250d35 Converted CiDebugInfo.registerRefMap field from type long to CiBitMap.
Doug Simon <doug.simon@oracle.com>
parents: 1468
diff changeset
75 if (register_map != NULL) {
3053
b7f45b37dd43 Fix bug in FrameState handling for LoopBegin, BitMap -> GraalBitMap in some assertions in graalCodeInstaller
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 3028
diff changeset
76 assert(GraalBitMap::size(register_map) == (unsigned) NUM_CPU_REGS, "unexpected register_map length");
1465
2c754f3a2722 Inlining of static final field values. Java mirror instead of VmID. Support for PrintMetrics option.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1462
diff changeset
77 for (jint i = 0; i < NUM_CPU_REGS; i++) {
1469
52bb06250d35 Converted CiDebugInfo.registerRefMap field from type long to CiBitMap.
Doug Simon <doug.simon@oracle.com>
parents: 1468
diff changeset
78 bool is_oop = is_bit_set(register_map, i);
1465
2c754f3a2722 Inlining of static final field values. Java mirror instead of VmID. Support for PrintMetrics option.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1462
diff changeset
79 VMReg reg = get_hotspot_reg(i);
2c754f3a2722 Inlining of static final field values. Java mirror instead of VmID. Support for PrintMetrics option.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1462
diff changeset
80 if (is_oop) {
2c754f3a2722 Inlining of static final field values. Java mirror instead of VmID. Support for PrintMetrics option.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1462
diff changeset
81 assert(OOP_ALLOWED[i], "this register may never be an oop, register map misaligned?");
2c754f3a2722 Inlining of static final field values. Java mirror instead of VmID. Support for PrintMetrics option.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1462
diff changeset
82 map->set_oop(reg);
2c754f3a2722 Inlining of static final field values. Java mirror instead of VmID. Support for PrintMetrics option.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1462
diff changeset
83 } else {
2c754f3a2722 Inlining of static final field values. Java mirror instead of VmID. Support for PrintMetrics option.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1462
diff changeset
84 map->set_value(reg);
2c754f3a2722 Inlining of static final field values. Java mirror instead of VmID. Support for PrintMetrics option.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1462
diff changeset
85 }
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
86 }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
87 }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
88
1433
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
89 if (frame_size > 0) {
3053
b7f45b37dd43 Fix bug in FrameState handling for LoopBegin, BitMap -> GraalBitMap in some assertions in graalCodeInstaller
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 3028
diff changeset
90 assert(GraalBitMap::size(frame_map) == frame_size / HeapWordSize, "unexpected frame_map length");
1433
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
91
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
92 for (jint i = 0; i < frame_size / HeapWordSize; i++) {
1469
52bb06250d35 Converted CiDebugInfo.registerRefMap field from type long to CiBitMap.
Doug Simon <doug.simon@oracle.com>
parents: 1468
diff changeset
93 bool is_oop = is_bit_set(frame_map, i);
1433
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
94 // hotspot stack slots are 4 bytes
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
95 VMReg reg = VMRegImpl::stack2reg(i * 2);
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
96 if (is_oop) {
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
97 map->set_oop(reg);
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
98 } else {
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
99 map->set_value(reg);
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
100 }
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
101 }
1433
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
102 } else {
3053
b7f45b37dd43 Fix bug in FrameState handling for LoopBegin, BitMap -> GraalBitMap in some assertions in graalCodeInstaller
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 3028
diff changeset
103 assert(frame_map == NULL || GraalBitMap::size(frame_map) == 0, "cannot have frame_map for frames with size 0");
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
104 }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
105
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
106 return map;
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
107 }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
108
2891
75a99b4f1c98 Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2890
diff changeset
109 // TODO: finish this - graal doesn't provide any scope values at the moment
3090
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
110 static ScopeValue* get_hotspot_value(oop value, int frame_size, GrowableArray<ScopeValue*>* objects, ScopeValue* &second) {
2938
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
111 second = NULL;
1434
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
112 if (value == CiValue::IllegalValue()) {
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
113 return new LocationValue(Location::new_stk_loc(Location::invalid, 0));
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
114 }
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
115
2891
75a99b4f1c98 Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2890
diff changeset
116 BasicType type = GraalCompiler::kindToBasicType(CiKind::typeChar(CiValue::kind(value)));
1449
8cfe3537a0d3 Pointer verification stub. Two loose oop fixes in C1X C++ part. Logging which methods have been compiled.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1444
diff changeset
117 Location::Type locationType = Location::normal;
8cfe3537a0d3 Pointer verification stub. Two loose oop fixes in C1X C++ part. Logging which methods have been compiled.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1444
diff changeset
118 if (type == T_OBJECT || type == T_ARRAY) locationType = Location::oop;
2938
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
119
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
120 if (value->is_a(CiRegisterValue::klass())) {
1435
20a3896518ac Initial adjustments to make C1X4HotSpot compile and run with latest Maxine version.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1434
diff changeset
121 jint number = CiRegister::number(CiRegisterValue::reg(value));
1434
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
122 if (number < 16) {
2938
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
123 if (type == T_INT || type == T_FLOAT || type == T_SHORT || type == T_CHAR || type == T_BOOLEAN || type == T_BYTE) {
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
124 locationType = Location::int_in_long;
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
125 } else if (type == T_LONG) {
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
126 locationType = Location::lng;
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
127 } else {
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
128 assert(type == T_OBJECT || type == T_ARRAY, "unexpected type in cpu register");
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
129 }
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
130 ScopeValue* value = new LocationValue(Location::new_reg_loc(locationType, as_Register(number)->as_VMReg()));
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
131 if (type == T_LONG) {
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
132 second = value;
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
133 }
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
134 return value;
1434
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
135 } else {
2938
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
136 assert(type == T_FLOAT || type == T_DOUBLE, "only float and double expected in xmm register");
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
137 if (type == T_FLOAT) {
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
138 // this seems weird, but the same value is used in c1_LinearScan
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
139 locationType = Location::normal;
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
140 } else {
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
141 locationType = Location::dbl;
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
142 }
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
143 ScopeValue* value = new LocationValue(Location::new_reg_loc(locationType, as_XMMRegister(number - 16)->as_VMReg()));
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
144 if (type == T_DOUBLE) {
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
145 second = value;
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
146 }
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
147 return value;
1434
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
148 }
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
149 } else if (value->is_a(CiStackSlot::klass())) {
2938
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
150 if (type == T_DOUBLE) {
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
151 locationType = Location::dbl;
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
152 } else if (type == T_LONG) {
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
153 locationType = Location::lng;
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
154 }
1434
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
155 jint index = CiStackSlot::index(value);
2938
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
156 ScopeValue* value;
1434
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
157 if (index >= 0) {
2938
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
158 value = new LocationValue(Location::new_stk_loc(locationType, index * HeapWordSize));
1434
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
159 } else {
2951
0c0e407faa39 another fix to debug info (on-stack parameters), DCE removes unnecessary merges and LoopBegins whose LoopEnd went away
Lukas Stadler <lukas.stadler@jku.at>
parents: 2938
diff changeset
160 value = new LocationValue(Location::new_stk_loc(locationType, -(index * HeapWordSize) + frame_size));
1434
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
161 }
2938
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
162 if (type == T_DOUBLE || type == T_LONG) {
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
163 second = value;
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
164 }
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
165 return value;
1434
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
166 } else if (value->is_a(CiConstant::klass())){
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
167 oop obj = CiConstant::object(value);
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
168 jlong prim = CiConstant::primitive(value);
1476
1f81c0d18c75 Build also release version of VM. Fix towards making SpecJVM2008 run.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1472
diff changeset
169 if (type == T_INT || type == T_FLOAT || type == T_SHORT || type == T_CHAR || type == T_BOOLEAN || type == T_BYTE) {
1434
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
170 return new ConstantIntValue(*(jint*)&prim);
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
171 } else if (type == T_LONG || type == T_DOUBLE) {
2938
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
172 second = new ConstantIntValue(0);
1434
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
173 return new ConstantLongValue(prim);
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
174 } else if (type == T_OBJECT) {
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
175 oop obj = CiConstant::object(value);
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
176 if (obj == NULL) {
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
177 return new ConstantOopWriteValue(NULL);
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
178 } else {
2282
0309d394eb5f Added support for non-null oop values in scope objects (allocating global handle).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2280
diff changeset
179 return new ConstantOopWriteValue(JNIHandles::make_global(obj));
1434
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
180 }
1476
1f81c0d18c75 Build also release version of VM. Fix towards making SpecJVM2008 run.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1472
diff changeset
181 } else if (type == T_ADDRESS) {
1f81c0d18c75 Build also release version of VM. Fix towards making SpecJVM2008 run.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1472
diff changeset
182 return new ConstantLongValue(prim);
1434
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
183 }
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
184 tty->print("%i", type);
3090
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
185 } else if (value->is_a(CiVirtualObject::klass())) {
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
186 oop type = CiVirtualObject::type(value);
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
187 int id = CiVirtualObject::id(value);
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
188 ciKlass* klass = (ciKlass*) CURRENT_ENV->get_object(java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(type)));
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
189 assert(klass->is_instance_klass() || klass->is_array_klass(), "Not supported allocation.");
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
190
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
191 for (jint i = 0; i < objects->length(); i++) {
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
192 ObjectValue* obj = (ObjectValue*) objects->at(i);
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
193 if (obj->id() == id) {
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
194 return obj;
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
195 }
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
196 }
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
197
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
198 ObjectValue* sv = new ObjectValue(id, new ConstantOopWriteValue(klass->constant_encoding()));
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
199
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
200 arrayOop values = (arrayOop) CiVirtualObject::values(value);
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
201 for (jint i = 0; i < values->length(); i++) {
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
202 ((oop*) values->base(T_OBJECT))[i];
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
203 }
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
204
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
205 for (jint i = 0; i < values->length(); i++) {
3133
5aeb62416609 Fixed an issue in the C++ code of the escape analysis (wrongly commented out code).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3091
diff changeset
206 ScopeValue* cur_second = NULL;
5aeb62416609 Fixed an issue in the C++ code of the escape analysis (wrongly commented out code).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3091
diff changeset
207 ScopeValue* value = get_hotspot_value(((oop*) values->base(T_OBJECT))[i], frame_size, objects, cur_second);
5aeb62416609 Fixed an issue in the C++ code of the escape analysis (wrongly commented out code).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3091
diff changeset
208
5aeb62416609 Fixed an issue in the C++ code of the escape analysis (wrongly commented out code).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3091
diff changeset
209 if (cur_second != NULL) {
5aeb62416609 Fixed an issue in the C++ code of the escape analysis (wrongly commented out code).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3091
diff changeset
210 sv->field_values()->append(cur_second);
5aeb62416609 Fixed an issue in the C++ code of the escape analysis (wrongly commented out code).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3091
diff changeset
211 }
3090
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
212 sv->field_values()->append(value);
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
213 }
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
214
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
215 // uint first_ind = spobj->first_index();
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
216 // for (uint i = 0; i < spobj->n_fields(); i++) {
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
217 // Node* fld_node = sfn->in(first_ind+i);
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
218 // (void)FillLocArray(sv->field_values()->length(), sfn, fld_node, sv->field_values(), objs);
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
219 // }
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
220 // scval = sv;
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
221
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
222 objects->append(sv);
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
223 return sv;
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
224 } else {
1434
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
225 value->klass()->print();
1462
1845386f5403 Full GC after bootstrap. Disable IRChecker by default. Disable compiled method logging by default.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1458
diff changeset
226 value->print();
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
227 }
2215
999f8086cc4f More changes to make it compile and work on win64.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 2182
diff changeset
228 ShouldNotReachHere();
999f8086cc4f More changes to make it compile and work on win64.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents: 2182
diff changeset
229 return NULL;
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
230 }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
231
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
232 // constructor used to create a method
3619
5e9645341ec3 support for new RiRuntime features: add code without making it the default for the method, executing Java tasks on the compile thread, communicate nmethod reference to Java code as HotSpotCompiledMethod
Lukas Stadler <lukas.stadler@jku.at>
parents: 3594
diff changeset
233 CodeInstaller::CodeInstaller(Handle target_method, nmethod*& nm, bool install_code) {
3555
22d11b3bc561 Various hacks to be able to install machine code from a Java thread.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3554
diff changeset
234 _env = CURRENT_ENV;
1465
2c754f3a2722 Inlining of static final field values. Java mirror instead of VmID. Support for PrintMetrics option.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1462
diff changeset
235 ciMethod *ciMethodObject = NULL;
2c754f3a2722 Inlining of static final field values. Java mirror instead of VmID. Support for PrintMetrics option.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1462
diff changeset
236 {
3555
22d11b3bc561 Various hacks to be able to install machine code from a Java thread.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3554
diff changeset
237 methodOop method = getMethodFromHotSpotMethod(HotSpotTargetMethod::method(target_method));
22d11b3bc561 Various hacks to be able to install machine code from a Java thread.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3554
diff changeset
238 ciMethodObject = (ciMethod *) _env->get_object(method);
22d11b3bc561 Various hacks to be able to install machine code from a Java thread.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3554
diff changeset
239 _parameter_count = method->size_of_parameters();
22d11b3bc561 Various hacks to be able to install machine code from a Java thread.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3554
diff changeset
240
1465
2c754f3a2722 Inlining of static final field values. Java mirror instead of VmID. Support for PrintMetrics option.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1462
diff changeset
241 No_Safepoint_Verifier no_safepoint;
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
242
1465
2c754f3a2722 Inlining of static final field values. Java mirror instead of VmID. Support for PrintMetrics option.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1462
diff changeset
243 initialize_fields(target_method);
2c754f3a2722 Inlining of static final field values. Java mirror instead of VmID. Support for PrintMetrics option.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1462
diff changeset
244 assert(_hotspot_method != NULL && _name == NULL, "installMethod needs NON-NULL method and NULL name");
2c754f3a2722 Inlining of static final field values. Java mirror instead of VmID. Support for PrintMetrics option.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1462
diff changeset
245 assert(_hotspot_method->is_a(HotSpotMethodResolved::klass()), "installMethod needs a HotSpotMethodResolved");
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
246
1465
2c754f3a2722 Inlining of static final field values. Java mirror instead of VmID. Support for PrintMetrics option.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1462
diff changeset
247 }
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
248
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
249 // (very) conservative estimate: each site needs a relocation
2891
75a99b4f1c98 Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2890
diff changeset
250 //CodeBuffer buffer("temp graal method", _total_size, _sites->length() * relocInfo::length_limit);
3555
22d11b3bc561 Various hacks to be able to install machine code from a Java thread.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3554
diff changeset
251 GraalCompiler::initialize_buffer_blob();
22d11b3bc561 Various hacks to be able to install machine code from a Java thread.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3554
diff changeset
252 CodeBuffer buffer(JavaThread::current()->get_buffer_blob());
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
253 initialize_buffer(buffer);
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
254 process_exception_handlers();
1465
2c754f3a2722 Inlining of static final field values. Java mirror instead of VmID. Support for PrintMetrics option.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1462
diff changeset
255
2c754f3a2722 Inlining of static final field values. Java mirror instead of VmID. Support for PrintMetrics option.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1462
diff changeset
256 int stack_slots = (_frame_size / HeapWordSize) + 2; // conversion to words, need to add two slots for ret address and frame pointer
2c754f3a2722 Inlining of static final field values. Java mirror instead of VmID. Support for PrintMetrics option.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1462
diff changeset
257 ThreadToNativeFromVM t((JavaThread*) Thread::current());
3619
5e9645341ec3 support for new RiRuntime features: add code without making it the default for the method, executing Java tasks on the compile thread, communicate nmethod reference to Java code as HotSpotCompiledMethod
Lukas Stadler <lukas.stadler@jku.at>
parents: 3594
diff changeset
258 nm = _env->register_method(ciMethodObject, -1, &_offsets, _custom_stack_area_offset, &buffer, stack_slots, _debug_recorder->_oopmaps, &_exception_handler_table,
5e9645341ec3 support for new RiRuntime features: add code without making it the default for the method, executing Java tasks on the compile thread, communicate nmethod reference to Java code as HotSpotCompiledMethod
Lukas Stadler <lukas.stadler@jku.at>
parents: 3594
diff changeset
259 &_implicit_exception_table, GraalCompiler::instance(), _env->comp_level(), false, false, install_code);
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
260 }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
261
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
262 // constructor used to create a stub
1938
1aa5b22a7716 Support for custom stack area (needed for deoptimization).
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1937
diff changeset
263 CodeInstaller::CodeInstaller(Handle target_method, jlong& id) {
1465
2c754f3a2722 Inlining of static final field values. Java mirror instead of VmID. Support for PrintMetrics option.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1462
diff changeset
264 No_Safepoint_Verifier no_safepoint;
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
265 _env = CURRENT_ENV;
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
266
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
267 initialize_fields(target_method);
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
268 assert(_hotspot_method == NULL && _name != NULL, "installMethod needs NON-NULL name and NULL method");
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
269
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
270 // (very) conservative estimate: each site needs a relocation
3555
22d11b3bc561 Various hacks to be able to install machine code from a Java thread.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3554
diff changeset
271 GraalCompiler::initialize_buffer_blob();
22d11b3bc561 Various hacks to be able to install machine code from a Java thread.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3554
diff changeset
272 CodeBuffer buffer(JavaThread::current()->get_buffer_blob());
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
273 initialize_buffer(buffer);
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
274
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
275 const char* cname = java_lang_String::as_utf8_string(_name);
1432
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
276 BufferBlob* blob = BufferBlob::create(strdup(cname), &buffer); // this is leaking strings... but only a limited number of stubs will be created
2891
75a99b4f1c98 Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2890
diff changeset
277 IF_TRACE_graal_3 Disassembler::decode((CodeBlob*) blob);
1931
48bbaead8b6c Adjustments after merge with OpenJDK repository.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1484
diff changeset
278 id = VmIds::addStub(blob->code_begin());
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
279 }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
280
1938
1aa5b22a7716 Support for custom stack area (needed for deoptimization).
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1937
diff changeset
281 void CodeInstaller::initialize_fields(Handle target_method) {
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
282 _citarget_method = HotSpotTargetMethod::targetMethod(target_method);
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
283 _hotspot_method = HotSpotTargetMethod::method(target_method);
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
284 _name = HotSpotTargetMethod::name(target_method);
1432
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
285 _sites = (arrayOop) HotSpotTargetMethod::sites(target_method);
2048
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
286 oop assumptions = CiTargetMethod::assumptions(_citarget_method);
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
287 if (assumptions != NULL) {
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
288 _assumptions = (arrayOop) CiAssumptions::list(assumptions);
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
289 } else {
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
290 _assumptions = NULL;
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
291 }
1432
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
292 _exception_handlers = (arrayOop) HotSpotTargetMethod::exceptionHandlers(target_method);
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
293
1432
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
294 _code = (arrayOop) CiTargetMethod::targetCode(_citarget_method);
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
295 _code_size = CiTargetMethod::targetCodeSize(_citarget_method);
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
296 _frame_size = CiTargetMethod::frameSize(_citarget_method);
1938
1aa5b22a7716 Support for custom stack area (needed for deoptimization).
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1937
diff changeset
297 _custom_stack_area_offset = CiTargetMethod::customStackAreaOffset(_citarget_method);
1aa5b22a7716 Support for custom stack area (needed for deoptimization).
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1937
diff changeset
298
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
299
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
300 // (very) conservative estimate: each site needs a constant section entry
2495
c737ee310b39 Small adjustment to assertion and constants size calculation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 2494
diff changeset
301 _constants_size = _sites->length() * (BytesPerLong*2);
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
302 _total_size = align_size_up(_code_size, HeapWordSize) + _constants_size;
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
303
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
304 _next_call_type = MARK_INVOKE_INVALID;
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
305 }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
306
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
307 // perform data and call relocation on the CodeBuffer
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
308 void CodeInstaller::initialize_buffer(CodeBuffer& buffer) {
1931
48bbaead8b6c Adjustments after merge with OpenJDK repository.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1484
diff changeset
309 int locs_buffer_size = _sites->length() * (relocInfo::length_limit + sizeof(relocInfo));
48bbaead8b6c Adjustments after merge with OpenJDK repository.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1484
diff changeset
310 char* locs_buffer = NEW_RESOURCE_ARRAY(char, locs_buffer_size);
48bbaead8b6c Adjustments after merge with OpenJDK repository.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1484
diff changeset
311 buffer.insts()->initialize_shared_locs((relocInfo*)locs_buffer, locs_buffer_size / sizeof(relocInfo));
48bbaead8b6c Adjustments after merge with OpenJDK repository.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1484
diff changeset
312 buffer.initialize_stubs_size(256);
48bbaead8b6c Adjustments after merge with OpenJDK repository.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1484
diff changeset
313 buffer.initialize_consts_size(_constants_size);
48bbaead8b6c Adjustments after merge with OpenJDK repository.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1484
diff changeset
314
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
315 _oop_recorder = new OopRecorder(_env->arena());
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
316 _env->set_oop_recorder(_oop_recorder);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
317 _debug_recorder = new DebugInformationRecorder(_env->oop_recorder());
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
318 _debug_recorder->set_oopmaps(new OopMapSet());
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
319 _dependencies = new Dependencies(_env);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
320
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
321 _env->set_oop_recorder(_oop_recorder);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
322 _env->set_debug_info(_debug_recorder);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
323 _env->set_dependencies(_dependencies);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
324 buffer.initialize_oop_recorder(_oop_recorder);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
325
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
326 _instructions = buffer.insts();
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
327 _constants = buffer.consts();
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
328
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
329 // copy the code into the newly created CodeBuffer
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
330 memcpy(_instructions->start(), _code->base(T_BYTE), _code_size);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
331 _instructions->set_end(_instructions->start() + _code_size);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
332
1432
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
333 oop* sites = (oop*) _sites->base(T_OBJECT);
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
334 for (int i = 0; i < _sites->length(); i++) {
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
335 oop site = sites[i];
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
336 jint pc_offset = CiTargetMethod_Site::pcOffset(site);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
337
3561
bea018622324 Changes to JavaAccess as a result of CRI changes.
Doug Simon <doug.simon@oracle.com>
parents: 3560
diff changeset
338 if (site->is_a(CiTargetMethod_Call::klass())) {
bea018622324 Changes to JavaAccess as a result of CRI changes.
Doug Simon <doug.simon@oracle.com>
parents: 3560
diff changeset
339 TRACE_graal_4("call at %i", pc_offset);
bea018622324 Changes to JavaAccess as a result of CRI changes.
Doug Simon <doug.simon@oracle.com>
parents: 3560
diff changeset
340 site_Call(buffer, pc_offset, site);
bea018622324 Changes to JavaAccess as a result of CRI changes.
Doug Simon <doug.simon@oracle.com>
parents: 3560
diff changeset
341 } else if (site->is_a(CiTargetMethod_Safepoint::klass())) {
2891
75a99b4f1c98 Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2890
diff changeset
342 TRACE_graal_4("safepoint at %i", pc_offset);
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
343 site_Safepoint(buffer, pc_offset, site);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
344 } else if (site->is_a(CiTargetMethod_DataPatch::klass())) {
2891
75a99b4f1c98 Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2890
diff changeset
345 TRACE_graal_4("datapatch at %i", pc_offset);
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
346 site_DataPatch(buffer, pc_offset, site);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
347 } else if (site->is_a(CiTargetMethod_Mark::klass())) {
2891
75a99b4f1c98 Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2890
diff changeset
348 TRACE_graal_4("mark at %i", pc_offset);
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
349 site_Mark(buffer, pc_offset, site);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
350 } else {
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
351 fatal("unexpected Site subclass");
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
352 }
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
353 }
2048
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
354
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
355
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
356 if (_assumptions != NULL) {
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
357 oop* assumptions = (oop*) _assumptions->base(T_OBJECT);
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
358 for (int i = 0; i < _assumptions->length(); ++i) {
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
359 oop assumption = assumptions[i];
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
360 if (assumption != NULL) {
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
361 if (assumption->is_a(CiAssumptions_ConcreteSubtype::klass())) {
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
362 assumption_ConcreteSubtype(assumption);
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
363 } else if (assumption->is_a(CiAssumptions_ConcreteMethod::klass())) {
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
364 assumption_ConcreteMethod(assumption);
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
365 } else {
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
366 fatal("unexpected Assumption subclass");
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
367 }
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
368 }
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
369 }
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
370 }
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
371 }
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
372
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
373 void CodeInstaller::assumption_ConcreteSubtype(oop assumption) {
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
374 oop context_oop = CiAssumptions_ConcreteSubtype::context(assumption);
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
375 oop type_oop = CiAssumptions_ConcreteSubtype::subtype(assumption);
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
376
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
377 ciKlass* context = (ciKlass*) CURRENT_ENV->get_object(java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(context_oop)));
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
378 ciKlass* type = (ciKlass*) CURRENT_ENV->get_object(java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(type_oop)));
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
379
2050
b6d2c238e585 Two fixes for leaf type and leaf method assumptions.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2049
diff changeset
380 _dependencies->assert_leaf_type(type);
b6d2c238e585 Two fixes for leaf type and leaf method assumptions.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2049
diff changeset
381 if (context != type) {
2048
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
382 assert(context->is_abstract(), "");
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
383 ThreadToNativeFromVM trans(JavaThread::current());
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
384 _dependencies->assert_abstract_with_unique_concrete_subtype(context, type);
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
385 }
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
386 }
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
387
177398c6147d Added unique concrete subtype assumption.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2046
diff changeset
388 void CodeInstaller::assumption_ConcreteMethod(oop assumption) {
2049
7e09ea4a8f36 Added leaf method assumptions.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2048
diff changeset
389 oop context_oop = CiAssumptions_ConcreteMethod::context(assumption);
7e09ea4a8f36 Added leaf method assumptions.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2048
diff changeset
390 oop method_oop = CiAssumptions_ConcreteMethod::method(assumption);
3011
f00918f35c7f inlining and runtime interface related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2951
diff changeset
391 methodOop method = getMethodFromHotSpotMethod(method_oop);
f00918f35c7f inlining and runtime interface related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2951
diff changeset
392 methodOop context = getMethodFromHotSpotMethod(context_oop);
2049
7e09ea4a8f36 Added leaf method assumptions.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2048
diff changeset
393
7e09ea4a8f36 Added leaf method assumptions.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2048
diff changeset
394 ciMethod* m = (ciMethod*) CURRENT_ENV->get_object(method);
7e09ea4a8f36 Added leaf method assumptions.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2048
diff changeset
395 ciMethod* c = (ciMethod*) CURRENT_ENV->get_object(context);
7e09ea4a8f36 Added leaf method assumptions.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2048
diff changeset
396 ciKlass* context_klass = c->holder();
2050
b6d2c238e585 Two fixes for leaf type and leaf method assumptions.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2049
diff changeset
397 {
b6d2c238e585 Two fixes for leaf type and leaf method assumptions.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2049
diff changeset
398 ThreadToNativeFromVM trans(JavaThread::current());
b6d2c238e585 Two fixes for leaf type and leaf method assumptions.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2049
diff changeset
399 _dependencies->assert_unique_concrete_method(context_klass, m);
b6d2c238e585 Two fixes for leaf type and leaf method assumptions.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2049
diff changeset
400 }
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
401 }
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
402
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
403 void CodeInstaller::process_exception_handlers() {
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
404 // allocate some arrays for use by the collection code.
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
405 const int num_handlers = 5;
1432
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
406 GrowableArray<intptr_t>* bcis = new GrowableArray<intptr_t> (num_handlers);
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
407 GrowableArray<intptr_t>* scope_depths = new GrowableArray<intptr_t> (num_handlers);
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
408 GrowableArray<intptr_t>* pcos = new GrowableArray<intptr_t> (num_handlers);
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
409
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
410 if (_exception_handlers != NULL) {
1432
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
411 oop* exception_handlers = (oop*) _exception_handlers->base(T_OBJECT);
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
412 for (int i = 0; i < _exception_handlers->length(); i++) {
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
413 jint pc_offset = CiTargetMethod_Site::pcOffset(exception_handlers[i]);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
414 int start = i;
1432
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
415 while ((i + 1) < _exception_handlers->length() && CiTargetMethod_Site::pcOffset(exception_handlers[i + 1]) == pc_offset)
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
416 i++;
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
417
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
418 // empty the arrays
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
419 bcis->trunc_to(0);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
420 scope_depths->trunc_to(0);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
421 pcos->trunc_to(0);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
422
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
423 for (int j = start; j <= i; j++) {
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
424 oop exc = exception_handlers[j];
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
425 jint handler_offset = CiTargetMethod_ExceptionHandler::handlerPos(exc);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
426 jint handler_bci = CiTargetMethod_ExceptionHandler::handlerBci(exc);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
427 jint bci = CiTargetMethod_ExceptionHandler::bci(exc);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
428 jint scope_level = CiTargetMethod_ExceptionHandler::scopeLevel(exc);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
429 Handle handler_type = CiTargetMethod_ExceptionHandler::exceptionType(exc);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
430
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
431 assert(handler_offset != -1, "must have been generated");
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
432
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
433 int e = bcis->find(handler_bci);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
434 if (e >= 0 && scope_depths->at(e) == scope_level) {
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
435 // two different handlers are declared to dispatch to the same
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
436 // catch bci. During parsing we created edges for each
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
437 // handler but we really only need one. The exception handler
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
438 // table will also get unhappy if we try to declare both since
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
439 // it's nonsensical. Just skip this handler.
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
440 continue;
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
441 }
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
442
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
443 bcis->append(handler_bci);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
444 if (handler_bci == -1) {
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
445 // insert a wildcard handler at scope depth 0 so that the
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
446 // exception lookup logic with find it.
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
447 scope_depths->append(0);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
448 } else {
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
449 scope_depths->append(scope_level);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
450 }
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
451 pcos->append(handler_offset);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
452
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
453 // stop processing once we hit a catch any
1432
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
454 // if (handler->is_catch_all()) {
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
455 // assert(i == handlers->length() - 1, "catch all must be last handler");
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
456 // }
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
457
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
458 }
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
459 _exception_handler_table.add_subtable(pc_offset, bcis, scope_depths, pcos);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
460 }
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
461 }
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
462
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
463 }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
464
3090
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
465 void CodeInstaller::record_scope(jint pc_offset, oop code_pos, GrowableArray<ScopeValue*>* objects) {
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
466 oop caller_pos = CiCodePos::caller(code_pos);
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
467 if (caller_pos != NULL) {
3090
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
468 record_scope(pc_offset, caller_pos, objects);
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
469 }
1447
1afbc44ee576 Modified class descriptions in C++ to reflect changes to CiDebugInfo.Frame
Doug Simon <doug.simon@oracle.com>
parents: 1444
diff changeset
470 oop frame = NULL;
2280
a2babfb34c24 CiDebugInfo_Frame changed to CiFrame, pointer fix
Lukas Stadler <lukas.stadler@jku.at>
parents: 2215
diff changeset
471 if (code_pos->klass()->klass_part()->name() == vmSymbols::com_sun_cri_ci_CiFrame()) {
1447
1afbc44ee576 Modified class descriptions in C++ to reflect changes to CiDebugInfo.Frame
Doug Simon <doug.simon@oracle.com>
parents: 1444
diff changeset
472 frame = code_pos;
1434
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
473 }
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
474
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
475 oop hotspot_method = CiCodePos::method(code_pos);
3011
f00918f35c7f inlining and runtime interface related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2951
diff changeset
476 methodOop method = getMethodFromHotSpotMethod(hotspot_method);
1432
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
477 ciMethod *cimethod = (ciMethod *) _env->get_object(method);
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
478 jint bci = CiCodePos::bci(code_pos);
1434
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
479 bool reexecute;
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
480 if (bci == -1) {
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
481 reexecute = false;
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
482 } else {
2182
9569fdf936ff Made merge compile.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 2059
diff changeset
483 Bytecodes::Code code = Bytecodes::java_code_at(method, method->bcp_from(bci));
1434
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
484 reexecute = Interpreter::bytecode_should_reexecute(code);
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
485 }
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
486
2901
d577d07cedec Added time measurement for phases.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2891
diff changeset
487 if (TraceGraal >= 2) {
1937
4853c5cad3aa More deoptmization tracing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1936
diff changeset
488 tty->print_cr("Recording scope pc_offset=%d bci=%d frame=%d", pc_offset, bci, frame);
4853c5cad3aa More deoptmization tracing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1936
diff changeset
489 }
4853c5cad3aa More deoptmization tracing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1936
diff changeset
490
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
491 if (frame != NULL) {
2280
a2babfb34c24 CiDebugInfo_Frame changed to CiFrame, pointer fix
Lukas Stadler <lukas.stadler@jku.at>
parents: 2215
diff changeset
492 jint local_count = CiFrame::numLocals(frame);
a2babfb34c24 CiDebugInfo_Frame changed to CiFrame, pointer fix
Lukas Stadler <lukas.stadler@jku.at>
parents: 2215
diff changeset
493 jint expression_count = CiFrame::numStack(frame);
a2babfb34c24 CiDebugInfo_Frame changed to CiFrame, pointer fix
Lukas Stadler <lukas.stadler@jku.at>
parents: 2215
diff changeset
494 jint monitor_count = CiFrame::numLocks(frame);
a2babfb34c24 CiDebugInfo_Frame changed to CiFrame, pointer fix
Lukas Stadler <lukas.stadler@jku.at>
parents: 2215
diff changeset
495 arrayOop values = (arrayOop) CiFrame::values(frame);
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
496
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
497 assert(local_count + expression_count + monitor_count == values->length(), "unexpected values length");
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
498
1432
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
499 GrowableArray<ScopeValue*>* locals = new GrowableArray<ScopeValue*> ();
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
500 GrowableArray<ScopeValue*>* expressions = new GrowableArray<ScopeValue*> ();
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
501 GrowableArray<MonitorValue*>* monitors = new GrowableArray<MonitorValue*> ();
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
502
2901
d577d07cedec Added time measurement for phases.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2891
diff changeset
503 if (TraceGraal >= 2) {
1936
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1931
diff changeset
504 tty->print_cr("Scope at bci %d with %d values", bci, values->length());
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1931
diff changeset
505 tty->print_cr("%d locals %d expressions, %d monitors", local_count, expression_count, monitor_count);
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1931
diff changeset
506 }
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1931
diff changeset
507
1432
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
508 for (jint i = 0; i < values->length(); i++) {
2938
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
509 ScopeValue* second = NULL;
3090
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
510 ScopeValue* value = get_hotspot_value(((oop*) values->base(T_OBJECT))[i], _frame_size, objects, second);
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
511
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
512 if (i < local_count) {
2938
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
513 if (second != NULL) {
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
514 locals->append(second);
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
515 }
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
516 locals->append(value);
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
517 } else if (i < local_count + expression_count) {
2938
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
518 if (second != NULL) {
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
519 expressions->append(value);
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
520 }
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
521 expressions->append(value);
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
522 } else {
2938
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
523 assert(second == NULL, "monitor cannot occupy two stack slots");
1434
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
524 assert(value->is_location(), "invalid monitor location");
72cfb36c6bb2 * enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1433
diff changeset
525 LocationValue* loc = (LocationValue*)value;
1453
d603bdbec024 Enable monitorenter/monitorexit runtime calls.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1450
diff changeset
526 int monitor_offset = loc->location().stack_offset();
d603bdbec024 Enable monitorenter/monitorexit runtime calls.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1450
diff changeset
527 LocationValue* obj = new LocationValue(Location::new_stk_loc(Location::oop, monitor_offset + BasicObjectLock::obj_offset_in_bytes()));
3568
409ef3a68dc8 re-lock objects whose lock was removed by escape analysis, enable stack walking compilation policy (-XX:CompilationPolicyChoice=1)
Lukas Stadler <lukas.stadler@jku.at>
parents: 3563
diff changeset
528 bool eliminated = value->is_object();
409ef3a68dc8 re-lock objects whose lock was removed by escape analysis, enable stack walking compilation policy (-XX:CompilationPolicyChoice=1)
Lukas Stadler <lukas.stadler@jku.at>
parents: 3563
diff changeset
529 monitors->append(new MonitorValue(obj, Location::new_stk_loc(Location::normal, monitor_offset + BasicObjectLock::lock_offset_in_bytes()), eliminated));
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
530 }
2938
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
531 if (second != NULL) {
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
532 i++;
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
533 assert(i < values->length(), "double-slot value not followed by CiValue.IllegalValue");
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
534 assert(((oop*) values->base(T_OBJECT))[i] == CiValue::IllegalValue(), "double-slot value not followed by CiValue.IllegalValue");
c7783b6773ea fixed graph start frame state
Lukas Stadler <lukas.stadler@jku.at>
parents: 2901
diff changeset
535 }
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
536 }
3090
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
537
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
538 _debug_recorder->dump_object_pool(objects);
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
539
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
540 DebugToken* locals_token = _debug_recorder->create_scope_values(locals);
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
541 DebugToken* expressions_token = _debug_recorder->create_scope_values(expressions);
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
542 DebugToken* monitors_token = _debug_recorder->create_monitor_values(monitors);
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
543
3018
5857923e563c Fixed an issue with frame states in exception dispatch chains (now we are correctly rethrowing the exception immediately at entering the interpreter).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3011
diff changeset
544 bool throw_exception = false;
5857923e563c Fixed an issue with frame states in exception dispatch chains (now we are correctly rethrowing the exception immediately at entering the interpreter).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3011
diff changeset
545 if (CiFrame::rethrowException(frame)) {
5857923e563c Fixed an issue with frame states in exception dispatch chains (now we are correctly rethrowing the exception immediately at entering the interpreter).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3011
diff changeset
546 throw_exception = true;
5857923e563c Fixed an issue with frame states in exception dispatch chains (now we are correctly rethrowing the exception immediately at entering the interpreter).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3011
diff changeset
547 }
5857923e563c Fixed an issue with frame states in exception dispatch chains (now we are correctly rethrowing the exception immediately at entering the interpreter).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3011
diff changeset
548
5857923e563c Fixed an issue with frame states in exception dispatch chains (now we are correctly rethrowing the exception immediately at entering the interpreter).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3011
diff changeset
549 _debug_recorder->describe_scope(pc_offset, cimethod, bci, reexecute, throw_exception, false, false, locals_token, expressions_token, monitors_token);
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
550 } else {
3018
5857923e563c Fixed an issue with frame states in exception dispatch chains (now we are correctly rethrowing the exception immediately at entering the interpreter).
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 3011
diff changeset
551 _debug_recorder->describe_scope(pc_offset, cimethod, bci, reexecute, false, false, false, NULL, NULL, NULL);
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
552 }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
553 }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
554
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
555 void CodeInstaller::site_Safepoint(CodeBuffer& buffer, jint pc_offset, oop site) {
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
556 oop debug_info = CiTargetMethod_Safepoint::debugInfo(site);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
557 assert(debug_info != NULL, "debug info expected");
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
558
1432
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
559 // address instruction = _instructions->start() + pc_offset;
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
560 // jint next_pc_offset = Assembler::locate_next_instruction(instruction) - _instructions->start();
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
561 _debug_recorder->add_safepoint(pc_offset, create_oop_map(_frame_size, _parameter_count, debug_info));
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
562
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
563 oop code_pos = CiDebugInfo::codePos(debug_info);
3090
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
564 record_scope(pc_offset, code_pos, new GrowableArray<ScopeValue*>());
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
565
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
566 _debug_recorder->end_safepoint(pc_offset);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
567 }
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
568
3572
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
569 address CodeInstaller::runtime_call_target_address(oop runtime_call) {
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
570 address target_addr = 0x0;
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
571 if (runtime_call == CiRuntimeCall::Debug()) {
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
572 TRACE_graal_3("CiRuntimeCall::Debug()");
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
573 } else if (runtime_call == CiRuntimeCall::UnwindException()) {
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
574 target_addr = Runtime1::entry_for(Runtime1::graal_unwind_exception_call_id);
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
575 TRACE_graal_3("CiRuntimeCall::UnwindException()");
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
576 } else if (runtime_call == CiRuntimeCall::HandleException()) {
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
577 target_addr = Runtime1::entry_for(Runtime1::graal_handle_exception_id);
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
578 TRACE_graal_3("CiRuntimeCall::HandleException()");
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
579 } else if (runtime_call == CiRuntimeCall::SetDeoptInfo()) {
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
580 target_addr = Runtime1::entry_for(Runtime1::graal_set_deopt_info_id);
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
581 TRACE_graal_3("CiRuntimeCall::SetDeoptInfo()");
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
582 } else if (runtime_call == CiRuntimeCall::CreateNullPointerException()) {
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
583 target_addr = Runtime1::entry_for(Runtime1::graal_create_null_pointer_exception_id);
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
584 TRACE_graal_3("CiRuntimeCall::CreateNullPointerException()");
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
585 } else if (runtime_call == CiRuntimeCall::CreateOutOfBoundsException()) {
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
586 target_addr = Runtime1::entry_for(Runtime1::graal_create_out_of_bounds_exception_id);
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
587 TRACE_graal_3("CiRuntimeCall::CreateOutOfBoundsException()");
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
588 } else if (runtime_call == CiRuntimeCall::JavaTimeMillis()) {
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
589 target_addr = CAST_FROM_FN_PTR(address, os::javaTimeMillis);
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
590 TRACE_graal_3("CiRuntimeCall::JavaTimeMillis()");
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
591 } else if (runtime_call == CiRuntimeCall::JavaTimeNanos()) {
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
592 target_addr = CAST_FROM_FN_PTR(address, os::javaTimeNanos);
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
593 TRACE_graal_3("CiRuntimeCall::JavaTimeNanos()");
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
594 } else if (runtime_call == CiRuntimeCall::ArithmeticFrem()) {
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
595 target_addr = Runtime1::entry_for(Runtime1::graal_arithmetic_frem_id);
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
596 TRACE_graal_3("CiRuntimeCall::ArithmeticFrem()");
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
597 } else if (runtime_call == CiRuntimeCall::ArithmeticDrem()) {
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
598 target_addr = Runtime1::entry_for(Runtime1::graal_arithmetic_drem_id);
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
599 TRACE_graal_3("CiRuntimeCall::ArithmeticDrem()");
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
600 } else if (runtime_call == CiRuntimeCall::ArithmeticSin()) {
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
601 target_addr = CAST_FROM_FN_PTR(address, SharedRuntime::dsin);
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
602 TRACE_graal_3("CiRuntimeCall::ArithmeticSin()");
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
603 } else if (runtime_call == CiRuntimeCall::ArithmeticCos()) {
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
604 target_addr = CAST_FROM_FN_PTR(address, SharedRuntime::dcos);
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
605 TRACE_graal_3("CiRuntimeCall::ArithmeticCos()");
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
606 } else if (runtime_call == CiRuntimeCall::ArithmeticTan()) {
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
607 target_addr = CAST_FROM_FN_PTR(address, SharedRuntime::dtan);
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
608 TRACE_graal_3("CiRuntimeCall::ArithmeticTan()");
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
609 } else if (runtime_call == CiRuntimeCall::RegisterFinalizer()) {
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
610 target_addr = Runtime1::entry_for(Runtime1::register_finalizer_id);
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
611 } else if (runtime_call == CiRuntimeCall::Deoptimize()) {
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
612 target_addr = SharedRuntime::deopt_blob()->uncommon_trap();
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
613 } else {
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
614 runtime_call->print();
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
615 fatal("runtime_call not implemented");
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
616 }
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
617 return target_addr;
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
618 }
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
619
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
620 void CodeInstaller::site_Call(CodeBuffer& buffer, jint pc_offset, oop site) {
3561
bea018622324 Changes to JavaAccess as a result of CRI changes.
Doug Simon <doug.simon@oracle.com>
parents: 3560
diff changeset
621 oop target = CiTargetMethod_Call::target(site);
bea018622324 Changes to JavaAccess as a result of CRI changes.
Doug Simon <doug.simon@oracle.com>
parents: 3560
diff changeset
622 instanceKlass* target_klass = instanceKlass::cast(target->klass());
bea018622324 Changes to JavaAccess as a result of CRI changes.
Doug Simon <doug.simon@oracle.com>
parents: 3560
diff changeset
623
bea018622324 Changes to JavaAccess as a result of CRI changes.
Doug Simon <doug.simon@oracle.com>
parents: 3560
diff changeset
624 oop runtime_call = NULL; // CiRuntimeCall
bea018622324 Changes to JavaAccess as a result of CRI changes.
Doug Simon <doug.simon@oracle.com>
parents: 3560
diff changeset
625 oop hotspot_method = NULL; // RiMethod
bea018622324 Changes to JavaAccess as a result of CRI changes.
Doug Simon <doug.simon@oracle.com>
parents: 3560
diff changeset
626 oop global_stub = NULL;
bea018622324 Changes to JavaAccess as a result of CRI changes.
Doug Simon <doug.simon@oracle.com>
parents: 3560
diff changeset
627
bea018622324 Changes to JavaAccess as a result of CRI changes.
Doug Simon <doug.simon@oracle.com>
parents: 3560
diff changeset
628 if (target_klass->is_subclass_of(SystemDictionary::Long_klass())) {
bea018622324 Changes to JavaAccess as a result of CRI changes.
Doug Simon <doug.simon@oracle.com>
parents: 3560
diff changeset
629 global_stub = target;
bea018622324 Changes to JavaAccess as a result of CRI changes.
Doug Simon <doug.simon@oracle.com>
parents: 3560
diff changeset
630 } else if (target_klass->name() == vmSymbols::com_sun_cri_ci_CiRuntimeCall()) {
bea018622324 Changes to JavaAccess as a result of CRI changes.
Doug Simon <doug.simon@oracle.com>
parents: 3560
diff changeset
631 runtime_call = target;
bea018622324 Changes to JavaAccess as a result of CRI changes.
Doug Simon <doug.simon@oracle.com>
parents: 3560
diff changeset
632 } else {
bea018622324 Changes to JavaAccess as a result of CRI changes.
Doug Simon <doug.simon@oracle.com>
parents: 3560
diff changeset
633 hotspot_method = target;
bea018622324 Changes to JavaAccess as a result of CRI changes.
Doug Simon <doug.simon@oracle.com>
parents: 3560
diff changeset
634 }
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
635
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
636 oop debug_info = CiTargetMethod_Call::debugInfo(site);
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
637
3561
bea018622324 Changes to JavaAccess as a result of CRI changes.
Doug Simon <doug.simon@oracle.com>
parents: 3560
diff changeset
638 assert((runtime_call ? 1 : 0) + (hotspot_method ? 1 : 0) + (global_stub ? 1 : 0) == 1, "Call site needs exactly one type");
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
639
3563
8780fa370aab Support runtime calls to targets that don't fit in a 32-bit immediate: allow to query the maximum offset of a CiRuntimeCall target to determine the required immediate size and patch call sites with a mov/call instruction pair for indirect calls
Peter Hofer <peter.hofer@jku.at>
parents: 3561
diff changeset
640 NativeInstruction* inst = nativeInstruction_at(_instructions->start() + pc_offset);
8780fa370aab Support runtime calls to targets that don't fit in a 32-bit immediate: allow to query the maximum offset of a CiRuntimeCall target to determine the required immediate size and patch call sites with a mov/call instruction pair for indirect calls
Peter Hofer <peter.hofer@jku.at>
parents: 3561
diff changeset
641 jint next_pc_offset = 0x0;
8780fa370aab Support runtime calls to targets that don't fit in a 32-bit immediate: allow to query the maximum offset of a CiRuntimeCall target to determine the required immediate size and patch call sites with a mov/call instruction pair for indirect calls
Peter Hofer <peter.hofer@jku.at>
parents: 3561
diff changeset
642 if (inst->is_call() || inst->is_jump()) {
8780fa370aab Support runtime calls to targets that don't fit in a 32-bit immediate: allow to query the maximum offset of a CiRuntimeCall target to determine the required immediate size and patch call sites with a mov/call instruction pair for indirect calls
Peter Hofer <peter.hofer@jku.at>
parents: 3561
diff changeset
643 assert(NativeCall::instruction_size == (int)NativeJump::instruction_size, "unexpected size");
8780fa370aab Support runtime calls to targets that don't fit in a 32-bit immediate: allow to query the maximum offset of a CiRuntimeCall target to determine the required immediate size and patch call sites with a mov/call instruction pair for indirect calls
Peter Hofer <peter.hofer@jku.at>
parents: 3561
diff changeset
644 next_pc_offset = pc_offset + NativeCall::instruction_size;
8780fa370aab Support runtime calls to targets that don't fit in a 32-bit immediate: allow to query the maximum offset of a CiRuntimeCall target to determine the required immediate size and patch call sites with a mov/call instruction pair for indirect calls
Peter Hofer <peter.hofer@jku.at>
parents: 3561
diff changeset
645 } else if (inst->is_mov_literal64()) {
8780fa370aab Support runtime calls to targets that don't fit in a 32-bit immediate: allow to query the maximum offset of a CiRuntimeCall target to determine the required immediate size and patch call sites with a mov/call instruction pair for indirect calls
Peter Hofer <peter.hofer@jku.at>
parents: 3561
diff changeset
646 // mov+call instruction pair
8780fa370aab Support runtime calls to targets that don't fit in a 32-bit immediate: allow to query the maximum offset of a CiRuntimeCall target to determine the required immediate size and patch call sites with a mov/call instruction pair for indirect calls
Peter Hofer <peter.hofer@jku.at>
parents: 3561
diff changeset
647 next_pc_offset = pc_offset + NativeMovConstReg::instruction_size;
8780fa370aab Support runtime calls to targets that don't fit in a 32-bit immediate: allow to query the maximum offset of a CiRuntimeCall target to determine the required immediate size and patch call sites with a mov/call instruction pair for indirect calls
Peter Hofer <peter.hofer@jku.at>
parents: 3561
diff changeset
648 u_char* call = (u_char*) (_instructions->start() + next_pc_offset);
8780fa370aab Support runtime calls to targets that don't fit in a 32-bit immediate: allow to query the maximum offset of a CiRuntimeCall target to determine the required immediate size and patch call sites with a mov/call instruction pair for indirect calls
Peter Hofer <peter.hofer@jku.at>
parents: 3561
diff changeset
649 assert((call[0] == 0x40 || call[0] == 0x41) && call[1] == 0xFF, "expected call with rex/rexb prefix byte");
8780fa370aab Support runtime calls to targets that don't fit in a 32-bit immediate: allow to query the maximum offset of a CiRuntimeCall target to determine the required immediate size and patch call sites with a mov/call instruction pair for indirect calls
Peter Hofer <peter.hofer@jku.at>
parents: 3561
diff changeset
650 next_pc_offset += 3; /* prefix byte + opcode byte + modrm byte */
8780fa370aab Support runtime calls to targets that don't fit in a 32-bit immediate: allow to query the maximum offset of a CiRuntimeCall target to determine the required immediate size and patch call sites with a mov/call instruction pair for indirect calls
Peter Hofer <peter.hofer@jku.at>
parents: 3561
diff changeset
651 } else {
8780fa370aab Support runtime calls to targets that don't fit in a 32-bit immediate: allow to query the maximum offset of a CiRuntimeCall target to determine the required immediate size and patch call sites with a mov/call instruction pair for indirect calls
Peter Hofer <peter.hofer@jku.at>
parents: 3561
diff changeset
652 runtime_call->print();
8780fa370aab Support runtime calls to targets that don't fit in a 32-bit immediate: allow to query the maximum offset of a CiRuntimeCall target to determine the required immediate size and patch call sites with a mov/call instruction pair for indirect calls
Peter Hofer <peter.hofer@jku.at>
parents: 3561
diff changeset
653 fatal("unsupported type of instruction for call site");
8780fa370aab Support runtime calls to targets that don't fit in a 32-bit immediate: allow to query the maximum offset of a CiRuntimeCall target to determine the required immediate size and patch call sites with a mov/call instruction pair for indirect calls
Peter Hofer <peter.hofer@jku.at>
parents: 3561
diff changeset
654 }
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
655
3619
5e9645341ec3 support for new RiRuntime features: add code without making it the default for the method, executing Java tasks on the compile thread, communicate nmethod reference to Java code as HotSpotCompiledMethod
Lukas Stadler <lukas.stadler@jku.at>
parents: 3594
diff changeset
656 if (target->is_a(SystemDictionary::HotSpotCompiledMethod_klass())) {
5e9645341ec3 support for new RiRuntime features: add code without making it the default for the method, executing Java tasks on the compile thread, communicate nmethod reference to Java code as HotSpotCompiledMethod
Lukas Stadler <lukas.stadler@jku.at>
parents: 3594
diff changeset
657 assert(inst->is_jump(), "jump expected");
5e9645341ec3 support for new RiRuntime features: add code without making it the default for the method, executing Java tasks on the compile thread, communicate nmethod reference to Java code as HotSpotCompiledMethod
Lukas Stadler <lukas.stadler@jku.at>
parents: 3594
diff changeset
658
5e9645341ec3 support for new RiRuntime features: add code without making it the default for the method, executing Java tasks on the compile thread, communicate nmethod reference to Java code as HotSpotCompiledMethod
Lukas Stadler <lukas.stadler@jku.at>
parents: 3594
diff changeset
659 nmethod* nm = (nmethod*) HotSpotCompiledMethod::nmethod(target);
5e9645341ec3 support for new RiRuntime features: add code without making it the default for the method, executing Java tasks on the compile thread, communicate nmethod reference to Java code as HotSpotCompiledMethod
Lukas Stadler <lukas.stadler@jku.at>
parents: 3594
diff changeset
660 nativeJump_at((address)inst)->set_jump_destination(nm->verified_entry_point());
5e9645341ec3 support for new RiRuntime features: add code without making it the default for the method, executing Java tasks on the compile thread, communicate nmethod reference to Java code as HotSpotCompiledMethod
Lukas Stadler <lukas.stadler@jku.at>
parents: 3594
diff changeset
661 _instructions->relocate((address)inst, runtime_call_Relocation::spec(), Assembler::call32_operand);
5e9645341ec3 support for new RiRuntime features: add code without making it the default for the method, executing Java tasks on the compile thread, communicate nmethod reference to Java code as HotSpotCompiledMethod
Lukas Stadler <lukas.stadler@jku.at>
parents: 3594
diff changeset
662
5e9645341ec3 support for new RiRuntime features: add code without making it the default for the method, executing Java tasks on the compile thread, communicate nmethod reference to Java code as HotSpotCompiledMethod
Lukas Stadler <lukas.stadler@jku.at>
parents: 3594
diff changeset
663 return;
5e9645341ec3 support for new RiRuntime features: add code without making it the default for the method, executing Java tasks on the compile thread, communicate nmethod reference to Java code as HotSpotCompiledMethod
Lukas Stadler <lukas.stadler@jku.at>
parents: 3594
diff changeset
664 }
5e9645341ec3 support for new RiRuntime features: add code without making it the default for the method, executing Java tasks on the compile thread, communicate nmethod reference to Java code as HotSpotCompiledMethod
Lukas Stadler <lukas.stadler@jku.at>
parents: 3594
diff changeset
665
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
666 if (debug_info != NULL) {
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
667 _debug_recorder->add_safepoint(next_pc_offset, create_oop_map(_frame_size, _parameter_count, debug_info));
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
668 oop code_pos = CiDebugInfo::codePos(debug_info);
3090
536528f48708 more escape analysis work: debug info
Lukas Stadler <lukas.stadler@jku.at>
parents: 3053
diff changeset
669 record_scope(next_pc_offset, code_pos, new GrowableArray<ScopeValue*>());
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
670 }
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
671
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
672 if (runtime_call != NULL) {
3572
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
673 if (runtime_call != CiRuntimeCall::Debug()) {
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
674 address target_addr = runtime_call_target_address(runtime_call);
3563
8780fa370aab Support runtime calls to targets that don't fit in a 32-bit immediate: allow to query the maximum offset of a CiRuntimeCall target to determine the required immediate size and patch call sites with a mov/call instruction pair for indirect calls
Peter Hofer <peter.hofer@jku.at>
parents: 3561
diff changeset
675
3572
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
676 if (inst->is_call()) {
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
677 // NOTE: for call without a mov, the offset must fit a 32-bit immediate
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
678 // see also VMEntries.getMaxCallTargetOffset()
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
679 NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
680 call->set_destination(target_addr);
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
681 _instructions->relocate(call->instruction_address(), runtime_call_Relocation::spec(), Assembler::call32_operand);
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
682 } else if (inst->is_mov_literal64()) {
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
683 NativeMovConstReg* mov = nativeMovConstReg_at(_instructions->start() + pc_offset);
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
684 mov->set_data((intptr_t) target_addr);
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
685 _instructions->relocate(mov->instruction_address(), runtime_call_Relocation::spec(), Assembler::imm_operand);
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
686 } else {
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
687 runtime_call->print();
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
688 fatal("unknown type of instruction for runtime call");
076a2c9caf71 Factor out runtime call target address determination to avoid redundancy between CodeInstaller::site_Call() and VMEntries.getMaxCallTargetOffset()
Peter Hofer <peter.hofer@jku.at>
parents: 3568
diff changeset
689 }
3563
8780fa370aab Support runtime calls to targets that don't fit in a 32-bit immediate: allow to query the maximum offset of a CiRuntimeCall target to determine the required immediate size and patch call sites with a mov/call instruction pair for indirect calls
Peter Hofer <peter.hofer@jku.at>
parents: 3561
diff changeset
690 }
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
691 } else if (global_stub != NULL) {
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
692 assert(java_lang_boxing_object::is_instance(global_stub, T_LONG), "global_stub needs to be of type Long");
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
693
1433
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
694 if (inst->is_call()) {
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
695 nativeCall_at((address)inst)->set_destination(VmIds::getStub(global_stub));
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
696 } else {
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
697 nativeJump_at((address)inst)->set_jump_destination(VmIds::getStub(global_stub));
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
698 }
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
699 _instructions->relocate((address)inst, runtime_call_Relocation::spec(), Assembler::call32_operand);
2891
75a99b4f1c98 Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2890
diff changeset
700 TRACE_graal_3("relocating (stub) at %016x", inst);
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
701 } else { // method != NULL
1433
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
702 NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
703 assert(hotspot_method != NULL, "unexpected RiMethod");
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
704 assert(debug_info != NULL, "debug info expected");
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
705
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
706 methodOop method = NULL;
3011
f00918f35c7f inlining and runtime interface related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2951
diff changeset
707 // we need to check, this might also be an unresolved method
f00918f35c7f inlining and runtime interface related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2951
diff changeset
708 if (hotspot_method->is_a(HotSpotMethodResolved::klass())) {
f00918f35c7f inlining and runtime interface related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2951
diff changeset
709 method = getMethodFromHotSpotMethod(hotspot_method);
f00918f35c7f inlining and runtime interface related changes:
Lukas Stadler <lukas.stadler@jku.at>
parents: 2951
diff changeset
710 }
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
711
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
712 assert(debug_info != NULL, "debug info expected");
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
713
2891
75a99b4f1c98 Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2890
diff changeset
714 TRACE_graal_3("method call");
1432
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
715 switch (_next_call_type) {
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
716 case MARK_INVOKEVIRTUAL:
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
717 case MARK_INVOKEINTERFACE: {
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
718 assert(method == NULL || !method->is_static(), "cannot call static method with invokeinterface");
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
719
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
720 call->set_destination(SharedRuntime::get_resolve_virtual_call_stub());
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
721 _instructions->relocate(call->instruction_address(), virtual_call_Relocation::spec(_invoke_mark_pc), Assembler::call32_operand);
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
722 break;
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
723 }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
724 case MARK_INVOKESTATIC: {
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
725 assert(method == NULL || method->is_static(), "cannot call non-static method with invokestatic");
3538
e4616e3d207b support for new CiRuntimeCalls CreateNullPointerException and CreateOutOfBoundsException
Lukas Stadler <lukas.stadler@jku.at>
parents: 3133
diff changeset
726
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
727 call->set_destination(SharedRuntime::get_resolve_static_call_stub());
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
728 _instructions->relocate(call->instruction_address(), relocInfo::static_call_type, Assembler::call32_operand);
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
729 break;
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
730 }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
731 case MARK_INVOKESPECIAL: {
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
732 assert(method == NULL || !method->is_static(), "cannot call static method with invokespecial");
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
733
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
734 call->set_destination(SharedRuntime::get_resolve_opt_virtual_call_stub());
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
735 _instructions->relocate(call->instruction_address(), relocInfo::opt_virtual_call_type, Assembler::call32_operand);
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
736 break;
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
737 }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
738 case MARK_INVOKE_INVALID:
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
739 default:
1931
48bbaead8b6c Adjustments after merge with OpenJDK repository.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1484
diff changeset
740 fatal("invalid _next_call_type value");
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
741 break;
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
742 }
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
743 }
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
744 _next_call_type = MARK_INVOKE_INVALID;
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
745 if (debug_info != NULL) {
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
746 _debug_recorder->end_safepoint(next_pc_offset);
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
747 }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
748 }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
749
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
750 void CodeInstaller::site_DataPatch(CodeBuffer& buffer, jint pc_offset, oop site) {
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
751 oop constant = CiTargetMethod_DataPatch::constant(site);
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
752 oop kind = CiConstant::kind(constant);
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
753
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
754 address instruction = _instructions->start() + pc_offset;
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
755
2494
e88293edf07c Fixed an issue with alignment of double/long values in the code buffer. Can now run Scimark again.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 2282
diff changeset
756 char typeChar = CiKind::typeChar(kind);
e88293edf07c Fixed an issue with alignment of double/long values in the code buffer. Can now run Scimark again.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 2282
diff changeset
757 switch (typeChar) {
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
758 case 'z':
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
759 case 'b':
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
760 case 's':
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
761 case 'c':
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
762 case 'i':
1432
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
763 fatal("int-sized values not expected in DataPatch")
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
764 ;
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
765 break;
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
766 case 'f':
3594
af1319bc4fd5 Fixed wrong type char check.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3572
diff changeset
767 case 'j':
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
768 case 'd': {
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
769 address operand = Assembler::locate_operand(instruction, Assembler::disp32_operand);
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
770 address next_instruction = Assembler::locate_next_instruction(instruction);
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
771 // we don't care if this is a long/double/etc., the primitive field contains the right bits
2494
e88293edf07c Fixed an issue with alignment of double/long values in the code buffer. Can now run Scimark again.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 2282
diff changeset
772 int size = _constants->size();
3594
af1319bc4fd5 Fixed wrong type char check.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 3572
diff changeset
773 if (typeChar == 'd' || typeChar == 'j') {
2494
e88293edf07c Fixed an issue with alignment of double/long values in the code buffer. Can now run Scimark again.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 2282
diff changeset
774 size = _constants->align_at_start(size);
e88293edf07c Fixed an issue with alignment of double/long values in the code buffer. Can now run Scimark again.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 2282
diff changeset
775 }
e88293edf07c Fixed an issue with alignment of double/long values in the code buffer. Can now run Scimark again.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 2282
diff changeset
776 address dest = _constants->start() + size;
e88293edf07c Fixed an issue with alignment of double/long values in the code buffer. Can now run Scimark again.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents: 2282
diff changeset
777 _constants->set_end(dest + BytesPerLong);
1432
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
778 *(jlong*) dest = CiConstant::primitive(constant);
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
779
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
780 long disp = dest - next_instruction;
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
781 assert(disp == (jint) disp, "disp doesn't fit in 32 bits");
1432
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
782 *((jint*) operand) = (jint) disp;
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
783
1432
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
784 _instructions->relocate(instruction, section_word_Relocation::spec((address) dest, CodeBuffer::SECT_CONSTS), Assembler::disp32_operand);
2891
75a99b4f1c98 Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2890
diff changeset
785 TRACE_graal_3("relocating (%c) at %016x/%016x with destination at %016x (%d)", typeChar, instruction, operand, dest, size);
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
786 break;
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
787 }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
788 case 'a': {
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
789 address operand = Assembler::locate_operand(instruction, Assembler::imm_operand);
1465
2c754f3a2722 Inlining of static final field values. Java mirror instead of VmID. Support for PrintMetrics option.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1462
diff changeset
790 Handle obj = CiConstant::object(constant);
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
791
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
792 if (obj->is_a(HotSpotTypeResolved::klass())) {
1942
00bc9eaf0e24 Support for -XX:+UseFastLocking flag. Fixed monitor enter XIR template for correct debug info at the runtime call.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1941
diff changeset
793 assert(!obj.is_null(), "");
1941
79d04223b8a5 Added caching for resolved types and resolved fields.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1938
diff changeset
794 *((jobject*) operand) = JNIHandles::make_local(java_lang_Class::as_klassOop(HotSpotTypeResolved::javaMirror(obj)));
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
795 _instructions->relocate(instruction, oop_Relocation::spec_for_immediate(), Assembler::imm_operand);
2891
75a99b4f1c98 Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2890
diff changeset
796 TRACE_graal_3("relocating (HotSpotType) at %016x/%016x", instruction, operand);
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
797 } else {
1465
2c754f3a2722 Inlining of static final field values. Java mirror instead of VmID. Support for PrintMetrics option.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1462
diff changeset
798 jobject value;
1484
6b7001391c97 Fix dummy obj boxed long hack by replacing it with a reliable solution.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1476
diff changeset
799 if (obj() == HotSpotProxy::DUMMY_CONSTANT_OBJ()) {
6b7001391c97 Fix dummy obj boxed long hack by replacing it with a reliable solution.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1476
diff changeset
800 value = (jobject) Universe::non_oop_word();
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
801 } else {
1465
2c754f3a2722 Inlining of static final field values. Java mirror instead of VmID. Support for PrintMetrics option.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1462
diff changeset
802 value = JNIHandles::make_local(obj());
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
803 }
1465
2c754f3a2722 Inlining of static final field values. Java mirror instead of VmID. Support for PrintMetrics option.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1462
diff changeset
804 *((jobject*) operand) = value;
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
805 _instructions->relocate(instruction, oop_Relocation::spec_for_immediate(), Assembler::imm_operand);
2891
75a99b4f1c98 Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents: 2890
diff changeset
806 TRACE_graal_3("relocating (oop constant) at %016x/%016x", instruction, operand);
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
807 }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
808 break;
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
809 }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
810 default:
1931
48bbaead8b6c Adjustments after merge with OpenJDK repository.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1484
diff changeset
811 fatal("unexpected CiKind in DataPatch");
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
812 break;
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
813 }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
814 }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
815
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
816 void CodeInstaller::site_Mark(CodeBuffer& buffer, jint pc_offset, oop site) {
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
817 oop id_obj = CiTargetMethod_Mark::id(site);
1432
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
818 arrayOop references = (arrayOop) CiTargetMethod_Mark::references(site);
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
819
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
820 if (id_obj != NULL) {
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
821 assert(java_lang_boxing_object::is_instance(id_obj, T_INT), "Integer id expected");
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
822 jint id = id_obj->int_field(java_lang_boxing_object::value_offset_in_bytes(T_INT));
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
823
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
824 address instruction = _instructions->start() + pc_offset;
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
825
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
826 switch (id) {
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
827 case MARK_UNVERIFIED_ENTRY:
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
828 _offsets.set_value(CodeOffsets::Entry, pc_offset);
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
829 break;
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
830 case MARK_VERIFIED_ENTRY:
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
831 _offsets.set_value(CodeOffsets::Verified_Entry, pc_offset);
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
832 break;
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
833 case MARK_OSR_ENTRY:
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
834 _offsets.set_value(CodeOffsets::OSR_Entry, pc_offset);
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
835 break;
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
836 case MARK_UNWIND_ENTRY:
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
837 _offsets.set_value(CodeOffsets::UnwindHandler, pc_offset);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
838 break;
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
839 case MARK_EXCEPTION_HANDLER_ENTRY:
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
840 _offsets.set_value(CodeOffsets::Exceptions, pc_offset);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
841 break;
1936
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1931
diff changeset
842 case MARK_DEOPT_HANDLER_ENTRY:
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1931
diff changeset
843 _offsets.set_value(CodeOffsets::Deopt, pc_offset);
8d88c9ac9247 Correct deopt handler entry. New flag -XX:+TraceSignals. More detailed deopt printing.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1931
diff changeset
844 break;
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
845 case MARK_STATIC_CALL_STUB: {
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
846 assert(references->length() == 1, "static call stub needs one reference");
1432
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
847 oop ref = ((oop*) references->base(T_OBJECT))[0];
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
848 address call_pc = _instructions->start() + CiTargetMethod_Site::pcOffset(ref);
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
849 _instructions->relocate(instruction, static_stub_Relocation::spec(call_pc));
1441
f8ab19e5acae Fix oop relocation for static stub calls.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1439
diff changeset
850 _instructions->relocate(instruction, oop_Relocation::spec_for_immediate(), Assembler::imm_operand);
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
851 break;
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
852 }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
853 case MARK_INVOKE_INVALID:
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
854 case MARK_INVOKEINTERFACE:
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
855 case MARK_INVOKESTATIC:
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
856 case MARK_INVOKESPECIAL:
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
857 case MARK_INVOKEVIRTUAL:
1432
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
858 _next_call_type = (MarkId) id;
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
859 _invoke_mark_pc = instruction;
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
860 break;
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
861 case MARK_IMPLICIT_NULL:
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
862 _implicit_exception_table.append(pc_offset, pc_offset);
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
863 break;
3550
aee1479c0a4b Use 2 different marks for NEAR/FAR polling : fixes wrong polling addresse problem after relocation
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 3549
diff changeset
864 case MARK_POLL_NEAR: {
aee1479c0a4b Use 2 different marks for NEAR/FAR polling : fixes wrong polling addresse problem after relocation
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 3549
diff changeset
865 NativeInstruction* ni = nativeInstruction_at(instruction);
aee1479c0a4b Use 2 different marks for NEAR/FAR polling : fixes wrong polling addresse problem after relocation
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 3549
diff changeset
866 int32_t* disp = (int32_t*) Assembler::locate_operand(instruction, Assembler::disp32_operand);
aee1479c0a4b Use 2 different marks for NEAR/FAR polling : fixes wrong polling addresse problem after relocation
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 3549
diff changeset
867 intptr_t new_disp = (intptr_t) (os::get_polling_page() + (SafepointPollOffset % os::vm_page_size())) - (intptr_t) ni;
aee1479c0a4b Use 2 different marks for NEAR/FAR polling : fixes wrong polling addresse problem after relocation
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 3549
diff changeset
868 *disp = (int32_t)new_disp;
aee1479c0a4b Use 2 different marks for NEAR/FAR polling : fixes wrong polling addresse problem after relocation
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 3549
diff changeset
869 }
aee1479c0a4b Use 2 different marks for NEAR/FAR polling : fixes wrong polling addresse problem after relocation
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 3549
diff changeset
870 case MARK_POLL_FAR:
3549
25765a764212 Add support for polling mark in code installer
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 3538
diff changeset
871 _instructions->relocate(instruction, relocInfo::poll_type);
25765a764212 Add support for polling mark in code installer
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 3538
diff changeset
872 break;
3550
aee1479c0a4b Use 2 different marks for NEAR/FAR polling : fixes wrong polling addresse problem after relocation
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 3549
diff changeset
873 case MARK_POLL_RETURN_NEAR: {
aee1479c0a4b Use 2 different marks for NEAR/FAR polling : fixes wrong polling addresse problem after relocation
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 3549
diff changeset
874 NativeInstruction* ni = nativeInstruction_at(instruction);
aee1479c0a4b Use 2 different marks for NEAR/FAR polling : fixes wrong polling addresse problem after relocation
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 3549
diff changeset
875 int32_t* disp = (int32_t*) Assembler::locate_operand(instruction, Assembler::disp32_operand);
aee1479c0a4b Use 2 different marks for NEAR/FAR polling : fixes wrong polling addresse problem after relocation
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 3549
diff changeset
876 intptr_t new_disp = (intptr_t) (os::get_polling_page() + (SafepointPollOffset % os::vm_page_size())) - (intptr_t) ni;
aee1479c0a4b Use 2 different marks for NEAR/FAR polling : fixes wrong polling addresse problem after relocation
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 3549
diff changeset
877 *disp = (int32_t)new_disp;
aee1479c0a4b Use 2 different marks for NEAR/FAR polling : fixes wrong polling addresse problem after relocation
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 3549
diff changeset
878 }
aee1479c0a4b Use 2 different marks for NEAR/FAR polling : fixes wrong polling addresse problem after relocation
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 3549
diff changeset
879 case MARK_POLL_RETURN_FAR:
3549
25765a764212 Add support for polling mark in code installer
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 3538
diff changeset
880 _instructions->relocate(instruction, relocInfo::poll_return_type);
25765a764212 Add support for polling mark in code installer
Gilles Duboscq <gilles.duboscq@oracle.com>
parents: 3538
diff changeset
881 break;
1433
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
882 case MARK_KLASS_PATCHING:
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
883 case MARK_ACCESS_FIELD_PATCHING: {
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
884 unsigned char* byte_count = (unsigned char*) (instruction - 1);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
885 unsigned char* byte_skip = (unsigned char*) (instruction - 2);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
886 unsigned char* being_initialized_entry_offset = (unsigned char*) (instruction - 3);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
887
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
888 assert(*byte_skip == 5, "unexpected byte_skip");
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
889
1433
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
890 assert(references->length() == 2, "MARK_KLASS_PATCHING/MARK_ACCESS_FIELD_PATCHING needs 2 references");
1432
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
891 oop ref1 = ((oop*) references->base(T_OBJECT))[0];
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
892 oop ref2 = ((oop*) references->base(T_OBJECT))[1];
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
893 int i_byte_count = CiTargetMethod_Site::pcOffset(ref2) - CiTargetMethod_Site::pcOffset(ref1);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
894 assert(i_byte_count == (unsigned char)i_byte_count, "invalid offset");
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
895 *byte_count = i_byte_count;
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
896 *being_initialized_entry_offset = *byte_count + *byte_skip;
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
897
1433
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
898 // we need to correct the offset of a field access - it's created with MAX_INT to ensure the correct size, and hotspot expects 0
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
899 if (id == MARK_ACCESS_FIELD_PATCHING) {
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
900 NativeMovRegMem* inst = nativeMovRegMem_at(_instructions->start() + CiTargetMethod_Site::pcOffset(ref1));
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
901 assert(inst->offset() == max_jint, "unexpected offset value");
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
902 inst->set_offset(0);
efba53f86c4f various fixes and enhancements
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1432
diff changeset
903 }
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
904 break;
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
905 }
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
906 case MARK_DUMMY_OOP_RELOCATION: {
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
907 _instructions->relocate(instruction, oop_Relocation::spec_for_immediate(), Assembler::imm_operand);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
908
1432
b61a43cd1255 sourcecode formatting
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1429
diff changeset
909 RelocIterator iter(_instructions, (address) instruction, (address) (instruction + 1));
1429
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
910 relocInfo::change_reloc_info_for_address(&iter, (address) instruction, relocInfo::oop_type, relocInfo::none);
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
911 break;
abc670a709dc * -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents: 1428
diff changeset
912 }
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
913 default:
1931
48bbaead8b6c Adjustments after merge with OpenJDK repository.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents: 1484
diff changeset
914 ShouldNotReachHere();
1428
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
915 break;
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
916 }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
917 }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
918 }
695451afc619 refactoring classes into separate files
Lukas Stadler <lukas.stadler@oracle.com>
parents:
diff changeset
919