Mercurial > hg > truffle
annotate src/share/vm/graal/graalCompiler.hpp @ 4530:6c6cb7be1324
bugfix
author | Christian Haeubl <christian.haeubl@oracle.com> |
---|---|
date | Wed, 08 Feb 2012 21:13:35 -0800 |
parents | 4e3aaf14cbc6 |
children | 6e7c1fb1980f |
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. |
1410
b30a2cd5e3a2
Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
1406
diff
changeset
|
22 */ |
b30a2cd5e3a2
Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
1406
diff
changeset
|
23 |
2045
9c96c873c42b
Fix includes to match new hotspot mechanism.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1931
diff
changeset
|
24 #include "compiler/abstractCompiler.hpp" |
9c96c873c42b
Fix includes to match new hotspot mechanism.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1931
diff
changeset
|
25 |
2891
75a99b4f1c98
Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2890
diff
changeset
|
26 class GraalCompiler : public AbstractCompiler { |
1406
35069ca331f2
Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff
changeset
|
27 |
1414
e1a275dbc8cd
Executing a+b with C1X on HotSpot ;-) !
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
1413
diff
changeset
|
28 private: |
e1a275dbc8cd
Executing a+b with C1X on HotSpot ;-) !
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
1413
diff
changeset
|
29 |
1429
abc670a709dc
* -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1428
diff
changeset
|
30 bool _initialized; |
abc670a709dc
* -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1428
diff
changeset
|
31 |
2891
75a99b4f1c98
Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2890
diff
changeset
|
32 static GraalCompiler* _instance; |
1414
e1a275dbc8cd
Executing a+b with C1X on HotSpot ;-) !
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
1413
diff
changeset
|
33 |
1406
35069ca331f2
Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff
changeset
|
34 public: |
35069ca331f2
Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff
changeset
|
35 |
2891
75a99b4f1c98
Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2890
diff
changeset
|
36 GraalCompiler(); |
1429
abc670a709dc
* -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1428
diff
changeset
|
37 |
2891
75a99b4f1c98
Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2890
diff
changeset
|
38 static GraalCompiler* instance() { return _instance; } |
1429
abc670a709dc
* -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1428
diff
changeset
|
39 |
1414
e1a275dbc8cd
Executing a+b with C1X on HotSpot ;-) !
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
1413
diff
changeset
|
40 |
2891
75a99b4f1c98
Rebranded C++ part from C1X to Graal.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2890
diff
changeset
|
41 virtual const char* name() { return "G"; } |
1406
35069ca331f2
Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff
changeset
|
42 |
1422
3483ec571caf
* using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1421
diff
changeset
|
43 // Native / OSR not supported |
3483ec571caf
* using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1421
diff
changeset
|
44 virtual bool supports_native() { return false; } |
3483ec571caf
* using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1421
diff
changeset
|
45 virtual bool supports_osr () { return false; } |
3483ec571caf
* using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1421
diff
changeset
|
46 |
3483ec571caf
* using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1421
diff
changeset
|
47 // Pretend to be C1 |
3483ec571caf
* using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1421
diff
changeset
|
48 bool is_c1 () { return true; } |
3483ec571caf
* using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1421
diff
changeset
|
49 bool is_c2 () { return false; } |
1406
35069ca331f2
Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff
changeset
|
50 |
1422
3483ec571caf
* using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1421
diff
changeset
|
51 // Initialization |
3483ec571caf
* using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1421
diff
changeset
|
52 virtual void initialize(); |
3483ec571caf
* using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1421
diff
changeset
|
53 |
3483ec571caf
* using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1421
diff
changeset
|
54 // Compilation entry point for methods |
3483ec571caf
* using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1421
diff
changeset
|
55 virtual void compile_method(ciEnv* env, ciMethod* target, int entry_bci); |
1406
35069ca331f2
Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff
changeset
|
56 |
3651
a31028282e3e
Support blocking compilation.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3650
diff
changeset
|
57 void compile_method(methodHandle target, int entry_bci, jboolean blocking); |
3650
0e8a2a629afb
Pass-by compilation broker.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3649
diff
changeset
|
58 |
1422
3483ec571caf
* using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1421
diff
changeset
|
59 // Print compilation timers and statistics |
3483ec571caf
* using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1421
diff
changeset
|
60 virtual void print_timers(); |
3637
ff6a991c6e3c
Use GraalEnv to look up types.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3619
diff
changeset
|
61 |
3653
6aef50c6d967
Handlize to fix GC issue.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3651
diff
changeset
|
62 static Handle get_RiTypeFromSignature(constantPoolHandle cp, int index, KlassHandle accessor, TRAPS); |
6aef50c6d967
Handlize to fix GC issue.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3651
diff
changeset
|
63 static Handle get_RiType(constantPoolHandle cp, int index, KlassHandle accessor, TRAPS); |
6aef50c6d967
Handlize to fix GC issue.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3651
diff
changeset
|
64 static Handle get_RiType(Symbol* klass_name, TRAPS); |
6aef50c6d967
Handlize to fix GC issue.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3651
diff
changeset
|
65 static Handle get_RiType(KlassHandle klass, TRAPS); |
6aef50c6d967
Handlize to fix GC issue.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3651
diff
changeset
|
66 static Handle get_RiField(int offset, int flags, Symbol* field_name, Handle field_holder, Handle field_type, Bytecodes::Code byteCode, TRAPS); |
1406
35069ca331f2
Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff
changeset
|
67 |
3653
6aef50c6d967
Handlize to fix GC issue.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3651
diff
changeset
|
68 static Handle createHotSpotTypeResolved(KlassHandle klass, Handle name, TRAPS); |
6aef50c6d967
Handlize to fix GC issue.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3651
diff
changeset
|
69 static Handle createHotSpotMethodResolved(methodHandle method, TRAPS); |
4441
4e3aaf14cbc6
fixed graal to hotspot
Christian Haeubl <christian.haeubl@oracle.com>
parents:
4139
diff
changeset
|
70 static Handle createHotSpotMethodData(methodDataHandle method_data, TRAPS); |
1429
abc670a709dc
* -XX:TraceC1X=0...5 controls the native c1x tracing
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1428
diff
changeset
|
71 |
2901
d577d07cedec
Added time measurement for phases.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2891
diff
changeset
|
72 void exit(); |
d577d07cedec
Added time measurement for phases.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2891
diff
changeset
|
73 |
1434
72cfb36c6bb2
* enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1433
diff
changeset
|
74 static BasicType kindToBasicType(jchar ch); |
1931
48bbaead8b6c
Adjustments after merge with OpenJDK repository.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1461
diff
changeset
|
75 |
48bbaead8b6c
Adjustments after merge with OpenJDK repository.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1461
diff
changeset
|
76 static int to_cp_index_u2(int index) { |
3577
96c40b338c1a
Added new method that loads and initializes a class that is referenced by a cp entry.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3565
diff
changeset
|
77 // Tag. |
96c40b338c1a
Added new method that loads and initializes a class that is referenced by a cp entry.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3565
diff
changeset
|
78 return to_index_u2(index) + constantPoolOopDesc::CPCACHE_INDEX_TAG; |
96c40b338c1a
Added new method that loads and initializes a class that is referenced by a cp entry.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3565
diff
changeset
|
79 } |
96c40b338c1a
Added new method that loads and initializes a class that is referenced by a cp entry.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3565
diff
changeset
|
80 |
96c40b338c1a
Added new method that loads and initializes a class that is referenced by a cp entry.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3565
diff
changeset
|
81 static int to_index_u2(int index) { |
1931
48bbaead8b6c
Adjustments after merge with OpenJDK repository.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1461
diff
changeset
|
82 // Swap. |
3577
96c40b338c1a
Added new method that loads and initializes a class that is referenced by a cp entry.
Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
parents:
3565
diff
changeset
|
83 return ((index & 0xFF) << 8) | (index >> 8); |
1931
48bbaead8b6c
Adjustments after merge with OpenJDK repository.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1461
diff
changeset
|
84 } |
48bbaead8b6c
Adjustments after merge with OpenJDK repository.
Thomas Wuerthinger <wuerthinger@ssw.jku.at>
parents:
1461
diff
changeset
|
85 |
3555
22d11b3bc561
Various hacks to be able to install machine code from a Java thread.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
3011
diff
changeset
|
86 static void initialize_buffer_blob(); |
1422
3483ec571caf
* using reflected objects instead of oops
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1421
diff
changeset
|
87 }; |
1406
35069ca331f2
Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff
changeset
|
88 |
1410
b30a2cd5e3a2
Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
1406
diff
changeset
|
89 // Tracing macros |
b30a2cd5e3a2
Added methods to c1x_VMExits.cpp
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
1406
diff
changeset
|
90 |
2901
d577d07cedec
Added time measurement for phases.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2891
diff
changeset
|
91 #define IF_TRACE_graal_1 if (!(TraceGraal >= 1)) ; else |
d577d07cedec
Added time measurement for phases.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2891
diff
changeset
|
92 #define IF_TRACE_graal_2 if (!(TraceGraal >= 2)) ; else |
d577d07cedec
Added time measurement for phases.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2891
diff
changeset
|
93 #define IF_TRACE_graal_3 if (!(TraceGraal >= 3)) ; else |
d577d07cedec
Added time measurement for phases.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2891
diff
changeset
|
94 #define IF_TRACE_graal_4 if (!(TraceGraal >= 4)) ; else |
d577d07cedec
Added time measurement for phases.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2891
diff
changeset
|
95 #define IF_TRACE_graal_5 if (!(TraceGraal >= 5)) ; else |
1406
35069ca331f2
Hooked C1XCompiler class into the system.
Thomas Wuerthinger <thomas.wuerthinger@gmail.com>
parents:
diff
changeset
|
96 |
1434
72cfb36c6bb2
* enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1433
diff
changeset
|
97 // using commas and else to keep one-instruction semantics |
72cfb36c6bb2
* enabled all jtt tests
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1433
diff
changeset
|
98 |
2901
d577d07cedec
Added time measurement for phases.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2891
diff
changeset
|
99 #define TRACE_graal_1 if (!(TraceGraal >= 1 && (tty->print("TraceGraal-1: "), true))) ; else tty->print_cr |
d577d07cedec
Added time measurement for phases.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2891
diff
changeset
|
100 #define TRACE_graal_2 if (!(TraceGraal >= 2 && (tty->print(" TraceGraal-2: "), true))) ; else tty->print_cr |
d577d07cedec
Added time measurement for phases.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2891
diff
changeset
|
101 #define TRACE_graal_3 if (!(TraceGraal >= 3 && (tty->print(" TraceGraal-3: "), true))) ; else tty->print_cr |
d577d07cedec
Added time measurement for phases.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2891
diff
changeset
|
102 #define TRACE_graal_4 if (!(TraceGraal >= 4 && (tty->print(" TraceGraal-4: "), true))) ; else tty->print_cr |
d577d07cedec
Added time measurement for phases.
Thomas Wuerthinger <thomas@wuerthinger.net>
parents:
2891
diff
changeset
|
103 #define TRACE_graal_5 if (!(TraceGraal >= 5 && (tty->print(" TraceGraal-5: "), true))) ; else tty->print_cr |
1423
760213a60e8b
* rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1422
diff
changeset
|
104 |
760213a60e8b
* rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1422
diff
changeset
|
105 |
760213a60e8b
* rewrite of the code installation
Lukas Stadler <lukas.stadler@oracle.com>
parents:
1422
diff
changeset
|
106 |