Mon, 12 Aug 2019 18:30:40 +0300
8223147: JFR Backport
8199712: Flight Recorder
8203346: JFR: Inconsistent signature of jfr_add_string_constant
8195817: JFR.stop should require name of recording
8195818: JFR.start should increase autogenerated name by one
8195819: Remove recording=x from jcmd JFR.check output
8203921: JFR thread sampling is missing fixes from JDK-8194552
8203929: Limit amount of data for JFR.dump
8203664: JFR start failure after AppCDS archive created with JFR StartFlightRecording
8003209: JFR events for network utilization
8207392: [PPC64] Implement JFR profiling
8202835: jfr/event/os/TestSystemProcess.java fails on missing events
Summary: Backport JFR from JDK11. Initial integration
Reviewed-by: neugens
1 /*
2 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
25 #ifndef SHARE_VM_CI_CIOBJECTFACTORY_HPP
26 #define SHARE_VM_CI_CIOBJECTFACTORY_HPP
28 #include "ci/ciClassList.hpp"
29 #include "ci/ciObject.hpp"
30 #include "utilities/growableArray.hpp"
32 // ciObjectFactory
33 //
34 // This class handles requests for the creation of new instances
35 // of ciObject and its subclasses. It contains a caching mechanism
36 // which ensures that for each oop, at most one ciObject is created.
37 // This invariant allows efficient implementation of ciObject.
38 class ciObjectFactory : public ResourceObj {
39 friend class VMStructs;
40 friend class ciEnv;
42 private:
43 static volatile bool _initialized;
44 static GrowableArray<ciMetadata*>* _shared_ci_metadata;
45 static ciSymbol* _shared_ci_symbols[];
46 static int _shared_ident_limit;
48 Arena* _arena;
49 GrowableArray<ciMetadata*>* _ci_metadata;
50 GrowableArray<ciMethod*>* _unloaded_methods;
51 GrowableArray<ciKlass*>* _unloaded_klasses;
52 GrowableArray<ciInstance*>* _unloaded_instances;
53 GrowableArray<ciReturnAddress*>* _return_addresses;
54 GrowableArray<ciSymbol*>* _symbols; // keep list of symbols created
55 int _next_ident;
57 public:
58 struct NonPermObject : public ResourceObj {
59 ciObject* _object;
60 NonPermObject* _next;
62 inline NonPermObject(NonPermObject* &bucket, oop key, ciObject* object);
63 ciObject* object() { return _object; }
64 NonPermObject* &next() { return _next; }
65 };
66 private:
67 enum { NON_PERM_BUCKETS = 61 };
68 NonPermObject* _non_perm_bucket[NON_PERM_BUCKETS];
69 int _non_perm_count;
71 int find(Metadata* key, GrowableArray<ciMetadata*>* objects);
72 bool is_found_at(int index, Metadata* key, GrowableArray<ciMetadata*>* objects);
73 void insert(int index, ciMetadata* obj, GrowableArray<ciMetadata*>* objects);
75 ciObject* create_new_object(oop o);
76 ciMetadata* create_new_metadata(Metadata* o);
78 void ensure_metadata_alive(ciMetadata* m);
80 static bool is_equal(NonPermObject* p, oop key) {
81 return p->object()->get_oop() == key;
82 }
84 NonPermObject* &find_non_perm(oop key);
85 void insert_non_perm(NonPermObject* &where, oop key, ciObject* obj);
87 void init_ident_of(ciBaseObject* obj);
89 Arena* arena() { return _arena; }
91 void print_contents_impl();
93 ciInstance* get_unloaded_instance(ciInstanceKlass* klass);
95 public:
96 static bool is_initialized() { return _initialized; }
98 static void initialize();
99 void init_shared_objects();
100 void remove_symbols();
102 ciObjectFactory(Arena* arena, int expected_size);
104 // Get the ciObject corresponding to some oop.
105 ciObject* get(oop key);
106 ciMetadata* get_metadata(Metadata* key);
107 ciSymbol* get_symbol(Symbol* key);
109 // Get the ciSymbol corresponding to one of the vmSymbols.
110 static ciSymbol* vm_symbol_at(int index);
112 // Get the ciMethod representing an unloaded/unfound method.
113 ciMethod* get_unloaded_method(ciInstanceKlass* holder,
114 ciSymbol* name,
115 ciSymbol* signature,
116 ciInstanceKlass* accessor);
118 // Get a ciKlass representing an unloaded klass.
119 ciKlass* get_unloaded_klass(ciKlass* accessing_klass,
120 ciSymbol* name,
121 bool create_if_not_found);
123 // Get a ciInstance representing an unresolved klass mirror.
124 ciInstance* get_unloaded_klass_mirror(ciKlass* type);
126 // Get a ciInstance representing an unresolved method handle constant.
127 ciInstance* get_unloaded_method_handle_constant(ciKlass* holder,
128 ciSymbol* name,
129 ciSymbol* signature,
130 int ref_kind);
132 // Get a ciInstance representing an unresolved method type constant.
133 ciInstance* get_unloaded_method_type_constant(ciSymbol* signature);
136 ciInstance* get_unloaded_object_constant();
138 // Get the ciMethodData representing the methodData for a method
139 // with none.
140 ciMethodData* get_empty_methodData();
142 ciReturnAddress* get_return_address(int bci);
144 GrowableArray<ciMetadata*>* get_ci_metadata() const { return _ci_metadata; }
145 // RedefineClasses support
146 void metadata_do(void f(Metadata*));
148 void print_contents();
149 void print();
150 };
152 #endif // SHARE_VM_CI_CIOBJECTFACTORY_HPP