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) 1998, 2010, 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_ADLC_DICT2_HPP
26 #define SHARE_VM_ADLC_DICT2_HPP
28 // Dictionaries - An Abstract Data Type
31 class Dict;
33 // These dictionaries define a key-value mapping. They can be inserted to,
34 // searched or deleted from. They grow and shrink as needed. The key is a
35 // pointer to something (or anything which can be stored in a pointer). A
36 // key comparison routine determines if two keys are equal or not. A hash
37 // function can be provided; if it's not provided the key itself is used
38 // instead. A nice string hash function is included.
39 typedef int (*CmpKey)(const void *key1, const void *key2);
40 typedef int (*Hash)(const void *key);
41 typedef void (*PrintKeyOrValue)(const void *key_or_value);
42 typedef void (*FuncDict)(const void *key, const void *val, Dict *d);
44 class Dict { // Dictionary structure
45 private:
46 class Arena *_arena; // Where to draw storage from
47 class bucket *_bin; // Hash table is array of buckets
48 int _size; // Size (# of slots) in hash table
49 int _cnt; // Number of key-value pairs in hash table
50 const Hash _hash; // Hashing function
51 const CmpKey _cmp; // Key comparison function
52 void doubhash( void ); // Double hash table size
54 public:
55 friend class DictI; // Friendly iterator function
57 // cmp is a key comparision routine. hash is a routine to hash a key.
58 Dict( CmpKey cmp, Hash hash );
59 Dict( CmpKey cmp, Hash hash, Arena *arena );
60 void init();
61 ~Dict();
63 Dict( const Dict & ); // Deep-copy guts
64 Dict &operator =( const Dict & );
66 // Zap to empty; ready for re-use
67 void Clear();
69 // Return # of key-value pairs in dict
70 int Size(void) const { return _cnt; }
72 // Insert inserts the given key-value pair into the dictionary. The prior
73 // value of the key is returned; NULL if the key was not previously defined.
74 const void *Insert(const void *key, const void *val); // A new key-value
75 const void *Delete(void *key); // Delete & return old
77 // Find finds the value of a given key; or NULL if not found.
78 // The dictionary is NOT changed.
79 const void *operator [](const void *key) const; // Do a lookup
81 // == compares two dictionaries; they must have the same keys (their keys
82 // must match using CmpKey) and they must have the same values (pointer
83 // comparison). If so 1 is returned, if not 0 is returned.
84 int operator ==(const Dict &d) const; // Compare dictionaries for equal
86 // Print out the dictionary contents as key-value pairs
87 void print();
88 void print(PrintKeyOrValue print_key, PrintKeyOrValue print_value);
89 };
91 // Hashing functions
92 int hashstr(const void *s); // Nice string hash
93 // Slimey cheap hash function; no guaranteed performance. Better than the
94 // default for pointers, especially on MS-DOS machines.
95 int hashptr(const void *key);
96 // Slimey cheap hash function; no guaranteed performance.
97 int hashkey(const void *key);
99 // Key comparators
100 int cmpstr(const void *k1, const void *k2);
101 // Slimey cheap key comparator.
102 int cmpkey(const void *key1, const void *key2);
104 //------------------------------Iteration--------------------------------------
105 // The class of dictionary iterators. Fails in the presences of modifications
106 // to the dictionary during iteration (including searches).
107 // Usage: for( DictI i(dict); i.test(); ++i ) { body = i.key; body = i.value;}
108 class DictI {
109 private:
110 const Dict *_d; // Dictionary being iterated over
111 int _i; // Counter over the bins
112 int _j; // Counter inside each bin
113 public:
114 const void *_key, *_value; // Easy access to the key-value pair
115 DictI( const Dict *d ) {reset(d);}; // Create a new iterator
116 void reset( const Dict *dict ); // Reset existing iterator
117 void operator ++(void); // Increment iterator
118 int test(void) { return _i<_d->_size;} // Test for end of iteration
119 };
121 #endif // SHARE_VM_ADLC_DICT2_HPP