Mercurial > hg > graal-jvmci-8
comparison src/share/vm/ci/ciObjectFactory.hpp @ 0:a61af66fc99e jdk7-b24
Initial load
author | duke |
---|---|
date | Sat, 01 Dec 2007 00:00:00 +0000 |
parents | |
children | 5571b97fc1ec c18cbe5936b8 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a61af66fc99e |
---|---|
1 /* | |
2 * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
22 * | |
23 */ | |
24 | |
25 // ciObjectFactory | |
26 // | |
27 // This class handles requests for the creation of new instances | |
28 // of ciObject and its subclasses. It contains a caching mechanism | |
29 // which ensures that for each oop, at most one ciObject is created. | |
30 // This invariant allows efficient implementation of ciObject. | |
31 class ciObjectFactory : public ResourceObj { | |
32 private: | |
33 static volatile bool _initialized; | |
34 static GrowableArray<ciObject*>* _shared_ci_objects; | |
35 static ciSymbol* _shared_ci_symbols[]; | |
36 static int _shared_ident_limit; | |
37 | |
38 Arena* _arena; | |
39 GrowableArray<ciObject*>* _ci_objects; | |
40 GrowableArray<ciMethod*>* _unloaded_methods; | |
41 GrowableArray<ciKlass*>* _unloaded_klasses; | |
42 GrowableArray<ciReturnAddress*>* _return_addresses; | |
43 int _next_ident; | |
44 | |
45 public: | |
46 struct NonPermObject : public ResourceObj { | |
47 ciObject* _object; | |
48 NonPermObject* _next; | |
49 | |
50 inline NonPermObject(NonPermObject* &bucket, oop key, ciObject* object); | |
51 ciObject* object() { return _object; } | |
52 NonPermObject* &next() { return _next; } | |
53 }; | |
54 private: | |
55 enum { NON_PERM_BUCKETS = 61 }; | |
56 NonPermObject* _non_perm_bucket[NON_PERM_BUCKETS]; | |
57 int _non_perm_count; | |
58 | |
59 int find(oop key, GrowableArray<ciObject*>* objects); | |
60 bool is_found_at(int index, oop key, GrowableArray<ciObject*>* objects); | |
61 void insert(int index, ciObject* obj, GrowableArray<ciObject*>* objects); | |
62 ciObject* create_new_object(oop o); | |
63 static bool is_equal(NonPermObject* p, oop key) { | |
64 return p->object()->get_oop() == key; | |
65 } | |
66 | |
67 NonPermObject* &find_non_perm(oop key); | |
68 void insert_non_perm(NonPermObject* &where, oop key, ciObject* obj); | |
69 | |
70 void init_ident_of(ciObject* obj); | |
71 | |
72 Arena* arena() { return _arena; } | |
73 | |
74 void print_contents_impl(); | |
75 | |
76 public: | |
77 static bool is_initialized() { return _initialized; } | |
78 | |
79 static void initialize(); | |
80 void init_shared_objects(); | |
81 | |
82 ciObjectFactory(Arena* arena, int expected_size); | |
83 | |
84 | |
85 // Get the ciObject corresponding to some oop. | |
86 ciObject* get(oop key); | |
87 | |
88 // Get the ciSymbol corresponding to one of the vmSymbols. | |
89 static ciSymbol* vm_symbol_at(int index); | |
90 | |
91 // Get the ciMethod representing an unloaded/unfound method. | |
92 ciMethod* get_unloaded_method(ciInstanceKlass* holder, | |
93 ciSymbol* name, | |
94 ciSymbol* signature); | |
95 | |
96 // Get a ciKlass representing an unloaded klass. | |
97 ciKlass* get_unloaded_klass(ciKlass* accessing_klass, | |
98 ciSymbol* name, | |
99 bool create_if_not_found); | |
100 | |
101 | |
102 // Get the ciMethodData representing the methodData for a method | |
103 // with none. | |
104 ciMethodData* get_empty_methodData(); | |
105 | |
106 ciReturnAddress* get_return_address(int bci); | |
107 | |
108 void print_contents(); | |
109 void print(); | |
110 }; |