author | iklam |
Wed, 07 Nov 2018 19:40:27 -0800 | |
changeset 52514 | f4e3900c8d08 |
permissions | -rw-r--r-- |
52514
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
1 |
/* |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
2 |
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
4 |
* |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
8 |
* |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
13 |
* accompanied this code). |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
14 |
* |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
18 |
* |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
21 |
* questions. |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
22 |
* |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
23 |
*/ |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
24 |
|
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
25 |
package sun.jvm.hotspot.memory; |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
26 |
|
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
27 |
import java.util.*; |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
28 |
import sun.jvm.hotspot.debugger.*; |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
29 |
import sun.jvm.hotspot.runtime.*; |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
30 |
import sun.jvm.hotspot.types.*; |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
31 |
|
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
32 |
public class MetaspaceObj { |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
33 |
private static Address sharedMetaspaceBaseAddr; |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
34 |
private static Address sharedMetaspaceTopAddr; |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
35 |
|
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
36 |
static { |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
37 |
VM.registerVMInitializedObserver(new Observer() { |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
38 |
public void update(Observable o, Object data) { |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
39 |
initialize(VM.getVM().getTypeDataBase()); |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
40 |
} |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
41 |
}); |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
42 |
} |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
43 |
|
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
44 |
private static synchronized void initialize(TypeDataBase db) { |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
45 |
Type type = db.lookupType("MetaspaceObj"); |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
46 |
sharedMetaspaceBaseAddr = type.getAddressField("_shared_metaspace_base").getStaticFieldAddress(); |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
47 |
sharedMetaspaceTopAddr = type.getAddressField("_shared_metaspace_top").getStaticFieldAddress(); |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
48 |
} |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
49 |
|
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
50 |
public static boolean isShared(Address addr) { |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
51 |
Address base = sharedMetaspaceBaseAddr.getAddressAt(0); |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
52 |
Address top = sharedMetaspaceTopAddr. getAddressAt(0); |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
53 |
|
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
54 |
return base.lessThanOrEqual(addr) && addr.lessThan(top); |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
55 |
} |
f4e3900c8d08
8213346: Re-implement shared dictionary using CompactHashtable
iklam
parents:
diff
changeset
|
56 |
} |