src/share/vm/ci/ciObjectFactory.hpp

Wed, 09 Jun 2010 18:50:45 -0700

author
jrose
date
Wed, 09 Jun 2010 18:50:45 -0700
changeset 1957
136b78722a08
parent 1907
c18cbe5936b8
child 2314
f95d63e2154a
permissions
-rw-r--r--

6939203: JSR 292 needs method handle constants
Summary: Add new CP types CONSTANT_MethodHandle, CONSTANT_MethodType; extend 'ldc' bytecode.
Reviewed-by: twisti, never

duke@435 1 /*
trims@1907 2 * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
duke@435 25 // ciObjectFactory
duke@435 26 //
duke@435 27 // This class handles requests for the creation of new instances
duke@435 28 // of ciObject and its subclasses. It contains a caching mechanism
duke@435 29 // which ensures that for each oop, at most one ciObject is created.
duke@435 30 // This invariant allows efficient implementation of ciObject.
duke@435 31 class ciObjectFactory : public ResourceObj {
duke@435 32 private:
duke@435 33 static volatile bool _initialized;
duke@435 34 static GrowableArray<ciObject*>* _shared_ci_objects;
duke@435 35 static ciSymbol* _shared_ci_symbols[];
duke@435 36 static int _shared_ident_limit;
duke@435 37
duke@435 38 Arena* _arena;
duke@435 39 GrowableArray<ciObject*>* _ci_objects;
duke@435 40 GrowableArray<ciMethod*>* _unloaded_methods;
duke@435 41 GrowableArray<ciKlass*>* _unloaded_klasses;
jrose@1957 42 GrowableArray<ciInstance*>* _unloaded_instances;
duke@435 43 GrowableArray<ciReturnAddress*>* _return_addresses;
duke@435 44 int _next_ident;
duke@435 45
duke@435 46 public:
duke@435 47 struct NonPermObject : public ResourceObj {
duke@435 48 ciObject* _object;
duke@435 49 NonPermObject* _next;
duke@435 50
duke@435 51 inline NonPermObject(NonPermObject* &bucket, oop key, ciObject* object);
duke@435 52 ciObject* object() { return _object; }
duke@435 53 NonPermObject* &next() { return _next; }
duke@435 54 };
duke@435 55 private:
duke@435 56 enum { NON_PERM_BUCKETS = 61 };
duke@435 57 NonPermObject* _non_perm_bucket[NON_PERM_BUCKETS];
duke@435 58 int _non_perm_count;
duke@435 59
duke@435 60 int find(oop key, GrowableArray<ciObject*>* objects);
duke@435 61 bool is_found_at(int index, oop key, GrowableArray<ciObject*>* objects);
duke@435 62 void insert(int index, ciObject* obj, GrowableArray<ciObject*>* objects);
duke@435 63 ciObject* create_new_object(oop o);
duke@435 64 static bool is_equal(NonPermObject* p, oop key) {
duke@435 65 return p->object()->get_oop() == key;
duke@435 66 }
duke@435 67
duke@435 68 NonPermObject* &find_non_perm(oop key);
duke@435 69 void insert_non_perm(NonPermObject* &where, oop key, ciObject* obj);
duke@435 70
duke@435 71 void init_ident_of(ciObject* obj);
duke@435 72
duke@435 73 Arena* arena() { return _arena; }
duke@435 74
duke@435 75 void print_contents_impl();
duke@435 76
jrose@1957 77 ciInstance* get_unloaded_instance(ciInstanceKlass* klass);
jrose@1957 78
duke@435 79 public:
duke@435 80 static bool is_initialized() { return _initialized; }
duke@435 81
duke@435 82 static void initialize();
duke@435 83 void init_shared_objects();
duke@435 84
duke@435 85 ciObjectFactory(Arena* arena, int expected_size);
duke@435 86
duke@435 87
duke@435 88 // Get the ciObject corresponding to some oop.
duke@435 89 ciObject* get(oop key);
duke@435 90
duke@435 91 // Get the ciSymbol corresponding to one of the vmSymbols.
duke@435 92 static ciSymbol* vm_symbol_at(int index);
duke@435 93
duke@435 94 // Get the ciMethod representing an unloaded/unfound method.
duke@435 95 ciMethod* get_unloaded_method(ciInstanceKlass* holder,
duke@435 96 ciSymbol* name,
duke@435 97 ciSymbol* signature);
duke@435 98
duke@435 99 // Get a ciKlass representing an unloaded klass.
duke@435 100 ciKlass* get_unloaded_klass(ciKlass* accessing_klass,
duke@435 101 ciSymbol* name,
duke@435 102 bool create_if_not_found);
duke@435 103
jrose@1957 104 // Get a ciInstance representing an unresolved klass mirror.
jrose@1957 105 ciInstance* get_unloaded_klass_mirror(ciKlass* type);
jrose@1957 106
jrose@1957 107 // Get a ciInstance representing an unresolved method handle constant.
jrose@1957 108 ciInstance* get_unloaded_method_handle_constant(ciKlass* holder,
jrose@1957 109 ciSymbol* name,
jrose@1957 110 ciSymbol* signature,
jrose@1957 111 int ref_kind);
jrose@1957 112
jrose@1957 113 // Get a ciInstance representing an unresolved method type constant.
jrose@1957 114 ciInstance* get_unloaded_method_type_constant(ciSymbol* signature);
jrose@1957 115
duke@435 116
duke@435 117 // Get the ciMethodData representing the methodData for a method
duke@435 118 // with none.
duke@435 119 ciMethodData* get_empty_methodData();
duke@435 120
duke@435 121 ciReturnAddress* get_return_address(int bci);
duke@435 122
duke@435 123 void print_contents();
duke@435 124 void print();
duke@435 125 };

mercurial