annotate src/share/vm/interpreter/rewriter.hpp @ 1721:413ad0331a0c

6977924: Changes for 6975078 produce build error with certain gcc versions Summary: The changes introduced for 6975078 assign badHeapOopVal to the _allocation field in the ResourceObj class. In 32 bit linux builds with certain versions of gcc this assignment will be flagged as an error while compiling allocation.cpp. In 32 bit builds the constant value badHeapOopVal (which is cast to an intptr_t) is negative. The _allocation field is typed as an unsigned intptr_t and gcc catches this as an error. Reviewed-by: jcoomes, ysr, phh
author johnc
date Wed, 18 Aug 2010 10:59:06 -0700
parents 083fde3b838e
children f95d63e2154a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1579
jrose
parents: 1552 1565
diff changeset
2 * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1138
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1138
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1138
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 // The Rewriter adds caches to the constant pool and rewrites bytecode indices
a61af66fc99e Initial load
duke
parents:
diff changeset
26 // pointing into the constant pool for better interpreter performance.
a61af66fc99e Initial load
duke
parents:
diff changeset
27
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
28 class Rewriter: public StackObj {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
29 private:
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
30 instanceKlassHandle _klass;
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
31 constantPoolHandle _pool;
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
32 objArrayHandle _methods;
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
33 intArray _cp_map;
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
34 intStack _cp_cache_map;
1660
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
35 bool _have_invoke_dynamic;
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
36
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
37 void init_cp_map(int length) {
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
38 _cp_map.initialize(length, -1);
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
39 // Choose an initial value large enough that we don't get frequent
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
40 // calls to grow().
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
41 _cp_cache_map.initialize(length / 2);
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
42 }
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
43 int cp_entry_to_cp_cache(int i) { assert(has_cp_cache(i), "oob"); return _cp_map[i]; }
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
44 bool has_cp_cache(int i) { return (uint)i < (uint)_cp_map.length() && _cp_map[i] >= 0; }
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
45 int maybe_add_cp_cache_entry(int i) { return has_cp_cache(i) ? _cp_map[i] : add_cp_cache_entry(i); }
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
46 int add_cp_cache_entry(int cp_index) {
1059
389049f3f393 6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents: 844
diff changeset
47 assert((cp_index & _secondary_entry_tag) == 0, "bad tag");
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
48 assert(_cp_map[cp_index] == -1, "not twice on same cp_index");
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
49 int cache_index = _cp_cache_map.append(cp_index);
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
50 _cp_map.at_put(cp_index, cache_index);
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
51 assert(cp_entry_to_cp_cache(cp_index) == cache_index, "");
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
52 return cache_index;
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
53 }
1059
389049f3f393 6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents: 844
diff changeset
54 int add_secondary_cp_cache_entry(int main_cpc_entry) {
389049f3f393 6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents: 844
diff changeset
55 assert(main_cpc_entry < _cp_cache_map.length(), "must be earlier CP cache entry");
389049f3f393 6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents: 844
diff changeset
56 int cache_index = _cp_cache_map.append(main_cpc_entry | _secondary_entry_tag);
389049f3f393 6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents: 844
diff changeset
57 return cache_index;
389049f3f393 6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents: 844
diff changeset
58 }
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
59
1660
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
60 // Access the contents of _cp_cache_map to determine CP cache layout.
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
61 int cp_cache_entry_pool_index(int cache_index) {
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
62 int cp_index = _cp_cache_map[cache_index];
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
63 if ((cp_index & _secondary_entry_tag) != 0)
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
64 return -1;
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
65 else
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
66 return cp_index;
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
67 }
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
68 int cp_cache_secondary_entry_main_index(int cache_index) {
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
69 int cp_index = _cp_cache_map[cache_index];
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
70 if ((cp_index & _secondary_entry_tag) == 0)
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
71 return -1;
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
72 else
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
73 return (cp_index - _secondary_entry_tag);
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
74 }
083fde3b838e 6964498: JSR 292 invokedynamic sites need local bootstrap methods
jrose
parents: 1602
diff changeset
75
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
76 // All the work goes in here:
1138
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1059
diff changeset
77 Rewriter(instanceKlassHandle klass, constantPoolHandle cpool, objArrayHandle methods, TRAPS);
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
78
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
79 void compute_index_maps();
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
80 void make_constant_pool_cache(TRAPS);
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
81 void scan_method(methodOop m);
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
82 methodHandle rewrite_jsrs(methodHandle m, TRAPS);
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
83 void rewrite_Object_init(methodHandle m, TRAPS);
1565
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
84 void rewrite_member_reference(address bcp, int offset);
ab102d5d923e 6939207: refactor constant pool index processing
jrose
parents: 1138
diff changeset
85 void rewrite_invokedynamic(address bcp, int offset);
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1579
diff changeset
86 void maybe_rewrite_ldc(address bcp, int offset, bool is_wide);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 public:
726
be93aad57795 6655646: dynamic languages need dynamically linked call sites
jrose
parents: 0
diff changeset
89 // Driver routine:
0
a61af66fc99e Initial load
duke
parents:
diff changeset
90 static void rewrite(instanceKlassHandle klass, TRAPS);
1138
dd57230ba8fe 6893268: additional dynamic language related optimizations in C2
twisti
parents: 1059
diff changeset
91 static void rewrite(instanceKlassHandle klass, constantPoolHandle cpool, objArrayHandle methods, TRAPS);
1059
389049f3f393 6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents: 844
diff changeset
92
389049f3f393 6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents: 844
diff changeset
93 enum {
389049f3f393 6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents: 844
diff changeset
94 _secondary_entry_tag = nth_bit(30)
389049f3f393 6858164: invokedynamic code needs some cleanup (post-6655638)
jrose
parents: 844
diff changeset
95 };
0
a61af66fc99e Initial load
duke
parents:
diff changeset
96 };