annotate src/share/vm/ci/ciObjectFactory.hpp @ 1602:136b78722a08

6939203: JSR 292 needs method handle constants Summary: Add new CP types CONSTANT_MethodHandle, CONSTANT_MethodType; extend 'ldc' bytecode. Reviewed-by: twisti, never
author jrose
date Wed, 09 Jun 2010 18:50:45 -0700
parents c18cbe5936b8
children 2d26b0046e0d f95d63e2154a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
2 * Copyright (c) 1999, 2007, 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: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
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: 0
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 // ciObjectFactory
a61af66fc99e Initial load
duke
parents:
diff changeset
26 //
a61af66fc99e Initial load
duke
parents:
diff changeset
27 // This class handles requests for the creation of new instances
a61af66fc99e Initial load
duke
parents:
diff changeset
28 // of ciObject and its subclasses. It contains a caching mechanism
a61af66fc99e Initial load
duke
parents:
diff changeset
29 // which ensures that for each oop, at most one ciObject is created.
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // This invariant allows efficient implementation of ciObject.
a61af66fc99e Initial load
duke
parents:
diff changeset
31 class ciObjectFactory : public ResourceObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
32 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
33 static volatile bool _initialized;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 static GrowableArray<ciObject*>* _shared_ci_objects;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 static ciSymbol* _shared_ci_symbols[];
a61af66fc99e Initial load
duke
parents:
diff changeset
36 static int _shared_ident_limit;
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 Arena* _arena;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 GrowableArray<ciObject*>* _ci_objects;
a61af66fc99e Initial load
duke
parents:
diff changeset
40 GrowableArray<ciMethod*>* _unloaded_methods;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 GrowableArray<ciKlass*>* _unloaded_klasses;
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
42 GrowableArray<ciInstance*>* _unloaded_instances;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
43 GrowableArray<ciReturnAddress*>* _return_addresses;
a61af66fc99e Initial load
duke
parents:
diff changeset
44 int _next_ident;
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
47 struct NonPermObject : public ResourceObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
48 ciObject* _object;
a61af66fc99e Initial load
duke
parents:
diff changeset
49 NonPermObject* _next;
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 inline NonPermObject(NonPermObject* &bucket, oop key, ciObject* object);
a61af66fc99e Initial load
duke
parents:
diff changeset
52 ciObject* object() { return _object; }
a61af66fc99e Initial load
duke
parents:
diff changeset
53 NonPermObject* &next() { return _next; }
a61af66fc99e Initial load
duke
parents:
diff changeset
54 };
a61af66fc99e Initial load
duke
parents:
diff changeset
55 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
56 enum { NON_PERM_BUCKETS = 61 };
a61af66fc99e Initial load
duke
parents:
diff changeset
57 NonPermObject* _non_perm_bucket[NON_PERM_BUCKETS];
a61af66fc99e Initial load
duke
parents:
diff changeset
58 int _non_perm_count;
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 int find(oop key, GrowableArray<ciObject*>* objects);
a61af66fc99e Initial load
duke
parents:
diff changeset
61 bool is_found_at(int index, oop key, GrowableArray<ciObject*>* objects);
a61af66fc99e Initial load
duke
parents:
diff changeset
62 void insert(int index, ciObject* obj, GrowableArray<ciObject*>* objects);
a61af66fc99e Initial load
duke
parents:
diff changeset
63 ciObject* create_new_object(oop o);
a61af66fc99e Initial load
duke
parents:
diff changeset
64 static bool is_equal(NonPermObject* p, oop key) {
a61af66fc99e Initial load
duke
parents:
diff changeset
65 return p->object()->get_oop() == key;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 }
a61af66fc99e Initial load
duke
parents:
diff changeset
67
a61af66fc99e Initial load
duke
parents:
diff changeset
68 NonPermObject* &find_non_perm(oop key);
a61af66fc99e Initial load
duke
parents:
diff changeset
69 void insert_non_perm(NonPermObject* &where, oop key, ciObject* obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
70
a61af66fc99e Initial load
duke
parents:
diff changeset
71 void init_ident_of(ciObject* obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 Arena* arena() { return _arena; }
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 void print_contents_impl();
a61af66fc99e Initial load
duke
parents:
diff changeset
76
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
77 ciInstance* get_unloaded_instance(ciInstanceKlass* klass);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
78
0
a61af66fc99e Initial load
duke
parents:
diff changeset
79 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
80 static bool is_initialized() { return _initialized; }
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 static void initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
83 void init_shared_objects();
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 ciObjectFactory(Arena* arena, int expected_size);
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // Get the ciObject corresponding to some oop.
a61af66fc99e Initial load
duke
parents:
diff changeset
89 ciObject* get(oop key);
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // Get the ciSymbol corresponding to one of the vmSymbols.
a61af66fc99e Initial load
duke
parents:
diff changeset
92 static ciSymbol* vm_symbol_at(int index);
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 // Get the ciMethod representing an unloaded/unfound method.
a61af66fc99e Initial load
duke
parents:
diff changeset
95 ciMethod* get_unloaded_method(ciInstanceKlass* holder,
a61af66fc99e Initial load
duke
parents:
diff changeset
96 ciSymbol* name,
a61af66fc99e Initial load
duke
parents:
diff changeset
97 ciSymbol* signature);
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // Get a ciKlass representing an unloaded klass.
a61af66fc99e Initial load
duke
parents:
diff changeset
100 ciKlass* get_unloaded_klass(ciKlass* accessing_klass,
a61af66fc99e Initial load
duke
parents:
diff changeset
101 ciSymbol* name,
a61af66fc99e Initial load
duke
parents:
diff changeset
102 bool create_if_not_found);
a61af66fc99e Initial load
duke
parents:
diff changeset
103
1602
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
104 // Get a ciInstance representing an unresolved klass mirror.
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
105 ciInstance* get_unloaded_klass_mirror(ciKlass* type);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
106
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
107 // Get a ciInstance representing an unresolved method handle constant.
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
108 ciInstance* get_unloaded_method_handle_constant(ciKlass* holder,
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
109 ciSymbol* name,
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
110 ciSymbol* signature,
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
111 int ref_kind);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
112
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
113 // Get a ciInstance representing an unresolved method type constant.
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
114 ciInstance* get_unloaded_method_type_constant(ciSymbol* signature);
136b78722a08 6939203: JSR 292 needs method handle constants
jrose
parents: 1552
diff changeset
115
0
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // Get the ciMethodData representing the methodData for a method
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // with none.
a61af66fc99e Initial load
duke
parents:
diff changeset
119 ciMethodData* get_empty_methodData();
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 ciReturnAddress* get_return_address(int bci);
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 void print_contents();
a61af66fc99e Initial load
duke
parents:
diff changeset
124 void print();
a61af66fc99e Initial load
duke
parents:
diff changeset
125 };