Merge
This commit is contained in:
commit
754d67857b
.hgtags-top-repo
corba
hotspot
.hgtags
agent
make
src/share/classes/sun/jvm/hotspot
gc_implementation/g1
gc_interface
memory
oops
tools
make
src
os/posix/launcher
share/vm
gc_implementation
concurrentMarkSweep
g1
collectionSetChooser.cppcollectionSetChooser.hppconcurrentMark.cppconcurrentMark.hppg1CollectedHeap.cppg1CollectedHeap.hppg1CollectorPolicy.cppg1CollectorPolicy.hppg1MarkSweep.cppg1MonitoringSupport.cppg1MonitoringSupport.hppg1OopClosures.hppg1RemSet.cppg1_globals.hppheapRegion.cppheapRegion.hppheapRegionRemSet.cppheapRegionRemSet.hppheapRegionSeq.hppsatbQueue.cppvmStructs_g1.hpp
parallelScavenge
psMarkSweep.cpppsParallelCompact.cpppsPromotionLAB.cpppsPromotionLAB.hpppsPromotionManager.cpppsScavenge.cpp
shared
memory
genCollectedHeap.cppreferencePolicy.cppreferencePolicy.hppreferenceProcessor.cppreferenceProcessor.hpp
runtime
services
utilities
jaxp
jaxws
jdk
.hgtags
make
com/sun/org/apache/xml
common
java
javax
org/ietf/jgss
sun/security/other
src/share/classes/com/sun
jndi/ldap
org/apache/xml/internal/security
Init.java
algorithms
c14n
encryption
AgreementMethod.javaEncryptionMethod.javaEncryptionProperties.javaEncryptionProperty.javaReference.javaReferenceList.javaXMLCipher.java
keys
signature
@ -130,3 +130,4 @@ b910aac18c772b823b1f7da03e2c6528725cc6de jdk8-b05
|
||||
28cf2aec4dd7c3c75efc1c15078522467c781a6d jdk8-b06
|
||||
0db7ae9f2b1017124c779bccd016c976928859a0 jdk8-b07
|
||||
fb1bc13260d76447e269e843859eb593fe2a8ab2 jdk8-b08
|
||||
8adb70647b5af5273dfe6a540f07be667cd50216 jdk8-b09
|
||||
|
@ -130,3 +130,4 @@ cc1b599b986a37cb57de4584c5e58169766ca535 jdk8-b05
|
||||
45c43dde7ba7f176333a51a98f086275478836fa jdk8-b06
|
||||
3d61f0856f349e2163bf98146465dab3b7437f63 jdk8-b07
|
||||
0d52b1c87aa8fdea7fdc9c4126ea58f95ca6b351 jdk8-b08
|
||||
a891732c1a83082177ff7a4cf1506068d9cc0a47 jdk8-b09
|
||||
|
@ -181,7 +181,7 @@ c149193c768b8b7233da4c3a3fdc0756b975848e jdk7-b143
|
||||
dce7d24674f4d0bed00de24f00119057fdce7cfb jdk8-b05
|
||||
0db80d8e77fccddf5e6fa49963226b54ac7d0f62 jdk8-b06
|
||||
3f0cf875af83f55ec5e1a5cea80455315f9322a2 jdk8-b07
|
||||
3a2fb61165dfc72e6de2adab1f2649a408f5e577 hs22-b01
|
||||
0cc8a70952c368e06de2adab1f2649a408f5e577 hs22-b01
|
||||
7c29742c41b44fb0cd5a13c7ac8834f3f2ca649e hs22-b02
|
||||
3a2fb61165dfc72e398179a2796d740c8da5b8c0 hs22-b03
|
||||
ce9bde819dcba4a5d2822229d9183e69c74326ca hs22-b04
|
||||
@ -189,3 +189,5 @@ ce9bde819dcba4a5d2822229d9183e69c74326ca hs22-b04
|
||||
650d15d8f37255d3b805aa00c5bd1c30984b203d hs22-b06
|
||||
da883b9e6d3788057f9577e72712998ed82c9b7e hs23-b01
|
||||
49ed7eacfd16616166ff066493143889741097af jdk8-b08
|
||||
7c20d272643f47195478708eff593a9cce40fec4 jdk8-b09
|
||||
e4f412d2b75d2c797acff965aa2c420e3d358f09 hs23-b02
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2000, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -84,6 +84,7 @@ sun.jvm.hotspot.debugger.windbg.ia64 \
|
||||
sun.jvm.hotspot.debugger.windbg.x86 \
|
||||
sun.jvm.hotspot.debugger.x86 \
|
||||
sun.jvm.hotspot.gc_implementation \
|
||||
sun.jvm.hotspot.gc_implementation.g1 \
|
||||
sun.jvm.hotspot.gc_implementation.parallelScavenge \
|
||||
sun.jvm.hotspot.gc_implementation.shared \
|
||||
sun.jvm.hotspot.gc_interface \
|
||||
@ -176,6 +177,9 @@ sun/jvm/hotspot/debugger/windbg/*.java \
|
||||
sun/jvm/hotspot/debugger/windbg/ia64/*.java \
|
||||
sun/jvm/hotspot/debugger/windbg/x86/*.java \
|
||||
sun/jvm/hotspot/debugger/x86/*.java \
|
||||
sun/jvm/hotspot/gc_implementation/g1/*.java \
|
||||
sun/jvm/hotspot/gc_implementation/parallelScavenge/*.java \
|
||||
sun/jvm/hotspot/gc_implementation/shared/*.java \
|
||||
sun/jvm/hotspot/interpreter/*.java \
|
||||
sun/jvm/hotspot/jdi/*.java \
|
||||
sun/jvm/hotspot/livejvm/*.java \
|
||||
|
116
hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/G1CollectedHeap.java
Normal file
116
hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/G1CollectedHeap.java
Normal file
@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.gc_implementation.g1;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
|
||||
import sun.jvm.hotspot.debugger.Address;
|
||||
import sun.jvm.hotspot.gc_interface.CollectedHeapName;
|
||||
import sun.jvm.hotspot.memory.MemRegion;
|
||||
import sun.jvm.hotspot.memory.SharedHeap;
|
||||
import sun.jvm.hotspot.memory.SpaceClosure;
|
||||
import sun.jvm.hotspot.runtime.VM;
|
||||
import sun.jvm.hotspot.runtime.VMObjectFactory;
|
||||
import sun.jvm.hotspot.types.AddressField;
|
||||
import sun.jvm.hotspot.types.CIntegerField;
|
||||
import sun.jvm.hotspot.types.Type;
|
||||
import sun.jvm.hotspot.types.TypeDataBase;
|
||||
|
||||
// Mirror class for G1CollectedHeap.
|
||||
|
||||
public class G1CollectedHeap extends SharedHeap {
|
||||
// HeapRegionSeq _seq;
|
||||
static private long hrsFieldOffset;
|
||||
// MemRegion _g1_committed;
|
||||
static private long g1CommittedFieldOffset;
|
||||
// size_t _summary_bytes_used;
|
||||
static private CIntegerField summaryBytesUsedField;
|
||||
// G1MonitoringSupport* _g1mm
|
||||
static private AddressField g1mmField;
|
||||
|
||||
static {
|
||||
VM.registerVMInitializedObserver(new Observer() {
|
||||
public void update(Observable o, Object data) {
|
||||
initialize(VM.getVM().getTypeDataBase());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static private synchronized void initialize(TypeDataBase db) {
|
||||
Type type = db.lookupType("G1CollectedHeap");
|
||||
|
||||
hrsFieldOffset = type.getField("_hrs").getOffset();
|
||||
g1CommittedFieldOffset = type.getField("_g1_committed").getOffset();
|
||||
summaryBytesUsedField = type.getCIntegerField("_summary_bytes_used");
|
||||
g1mmField = type.getAddressField("_g1mm");
|
||||
}
|
||||
|
||||
public long capacity() {
|
||||
Address g1CommittedAddr = addr.addOffsetTo(g1CommittedFieldOffset);
|
||||
MemRegion g1_committed = new MemRegion(g1CommittedAddr);
|
||||
return g1_committed.byteSize();
|
||||
}
|
||||
|
||||
public long used() {
|
||||
return summaryBytesUsedField.getValue(addr);
|
||||
}
|
||||
|
||||
public long n_regions() {
|
||||
return hrs().length();
|
||||
}
|
||||
|
||||
private HeapRegionSeq hrs() {
|
||||
Address hrsAddr = addr.addOffsetTo(hrsFieldOffset);
|
||||
return (HeapRegionSeq) VMObjectFactory.newObject(HeapRegionSeq.class,
|
||||
hrsAddr);
|
||||
}
|
||||
|
||||
public G1MonitoringSupport g1mm() {
|
||||
Address g1mmAddr = g1mmField.getValue(addr);
|
||||
return (G1MonitoringSupport) VMObjectFactory.newObject(G1MonitoringSupport.class, g1mmAddr);
|
||||
}
|
||||
|
||||
private Iterator<HeapRegion> heapRegionIterator() {
|
||||
return hrs().heapRegionIterator();
|
||||
}
|
||||
|
||||
public void heapRegionIterate(SpaceClosure scl) {
|
||||
Iterator<HeapRegion> iter = heapRegionIterator();
|
||||
while (iter.hasNext()) {
|
||||
HeapRegion hr = iter.next();
|
||||
scl.doSpace(hr);
|
||||
}
|
||||
}
|
||||
|
||||
public CollectedHeapName kind() {
|
||||
return CollectedHeapName.G1_COLLECTED_HEAP;
|
||||
}
|
||||
|
||||
public G1CollectedHeap(Address addr) {
|
||||
super(addr);
|
||||
}
|
||||
}
|
99
hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/G1MonitoringSupport.java
Normal file
99
hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/G1MonitoringSupport.java
Normal file
@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.gc_implementation.g1;
|
||||
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
|
||||
import sun.jvm.hotspot.debugger.Address;
|
||||
import sun.jvm.hotspot.runtime.VM;
|
||||
import sun.jvm.hotspot.runtime.VMObject;
|
||||
import sun.jvm.hotspot.types.CIntegerField;
|
||||
import sun.jvm.hotspot.types.Type;
|
||||
import sun.jvm.hotspot.types.TypeDataBase;
|
||||
|
||||
// Mirror class for G1MonitoringSupport.
|
||||
|
||||
public class G1MonitoringSupport extends VMObject {
|
||||
// size_t _eden_committed;
|
||||
static private CIntegerField edenCommittedField;
|
||||
// size_t _eden_used;
|
||||
static private CIntegerField edenUsedField;
|
||||
// size_t _survivor_committed;
|
||||
static private CIntegerField survivorCommittedField;
|
||||
// size_t _survivor_used;
|
||||
static private CIntegerField survivorUsedField;
|
||||
// size_t _old_committed;
|
||||
static private CIntegerField oldCommittedField;
|
||||
// size_t _old_used;
|
||||
static private CIntegerField oldUsedField;
|
||||
|
||||
static {
|
||||
VM.registerVMInitializedObserver(new Observer() {
|
||||
public void update(Observable o, Object data) {
|
||||
initialize(VM.getVM().getTypeDataBase());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static private synchronized void initialize(TypeDataBase db) {
|
||||
Type type = db.lookupType("G1MonitoringSupport");
|
||||
|
||||
edenCommittedField = type.getCIntegerField("_eden_committed");
|
||||
edenUsedField = type.getCIntegerField("_eden_used");
|
||||
survivorCommittedField = type.getCIntegerField("_survivor_committed");
|
||||
survivorUsedField = type.getCIntegerField("_survivor_used");
|
||||
oldCommittedField = type.getCIntegerField("_old_committed");
|
||||
oldUsedField = type.getCIntegerField("_old_used");
|
||||
}
|
||||
|
||||
public long edenCommitted() {
|
||||
return edenCommittedField.getValue(addr);
|
||||
}
|
||||
|
||||
public long edenUsed() {
|
||||
return edenUsedField.getValue(addr);
|
||||
}
|
||||
|
||||
public long survivorCommitted() {
|
||||
return survivorCommittedField.getValue(addr);
|
||||
}
|
||||
|
||||
public long survivorUsed() {
|
||||
return survivorUsedField.getValue(addr);
|
||||
}
|
||||
|
||||
public long oldCommitted() {
|
||||
return oldCommittedField.getValue(addr);
|
||||
}
|
||||
|
||||
public long oldUsed() {
|
||||
return oldUsedField.getValue(addr);
|
||||
}
|
||||
|
||||
public G1MonitoringSupport(Address addr) {
|
||||
super(addr);
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.gc_implementation.g1;
|
||||
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
|
||||
import sun.jvm.hotspot.debugger.Address;
|
||||
import sun.jvm.hotspot.memory.ContiguousSpace;
|
||||
import sun.jvm.hotspot.runtime.VM;
|
||||
import sun.jvm.hotspot.types.CIntegerField;
|
||||
import sun.jvm.hotspot.types.Type;
|
||||
import sun.jvm.hotspot.types.TypeDataBase;
|
||||
|
||||
// Mirror class for HeapRegion. Currently we don't actually include
|
||||
// any of its fields but only iterate over it (which we get "for free"
|
||||
// as HeapRegion ultimately inherits from ContiguousSpace).
|
||||
|
||||
public class HeapRegion extends ContiguousSpace {
|
||||
// static int GrainBytes;
|
||||
static private CIntegerField grainBytesField;
|
||||
|
||||
static {
|
||||
VM.registerVMInitializedObserver(new Observer() {
|
||||
public void update(Observable o, Object data) {
|
||||
initialize(VM.getVM().getTypeDataBase());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static private synchronized void initialize(TypeDataBase db) {
|
||||
Type type = db.lookupType("HeapRegion");
|
||||
|
||||
grainBytesField = type.getCIntegerField("GrainBytes");
|
||||
}
|
||||
|
||||
static public long grainBytes() {
|
||||
return grainBytesField.getValue();
|
||||
}
|
||||
|
||||
public HeapRegion(Address addr) {
|
||||
super(addr);
|
||||
}
|
||||
}
|
102
hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/HeapRegionSeq.java
Normal file
102
hotspot/agent/src/share/classes/sun/jvm/hotspot/gc_implementation/g1/HeapRegionSeq.java
Normal file
@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
package sun.jvm.hotspot.gc_implementation.g1;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
|
||||
import sun.jvm.hotspot.debugger.Address;
|
||||
import sun.jvm.hotspot.runtime.VM;
|
||||
import sun.jvm.hotspot.runtime.VMObject;
|
||||
import sun.jvm.hotspot.runtime.VMObjectFactory;
|
||||
import sun.jvm.hotspot.types.AddressField;
|
||||
import sun.jvm.hotspot.types.CIntegerField;
|
||||
import sun.jvm.hotspot.types.Type;
|
||||
import sun.jvm.hotspot.types.TypeDataBase;
|
||||
|
||||
// Mirror class for HeapRegionSeq. It's essentially an index -> HeapRegion map.
|
||||
|
||||
public class HeapRegionSeq extends VMObject {
|
||||
// HeapRegion** _regions;
|
||||
static private AddressField regionsField;
|
||||
// size_t _length;
|
||||
static private CIntegerField lengthField;
|
||||
|
||||
static {
|
||||
VM.registerVMInitializedObserver(new Observer() {
|
||||
public void update(Observable o, Object data) {
|
||||
initialize(VM.getVM().getTypeDataBase());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static private synchronized void initialize(TypeDataBase db) {
|
||||
Type type = db.lookupType("HeapRegionSeq");
|
||||
|
||||
regionsField = type.getAddressField("_regions");
|
||||
lengthField = type.getCIntegerField("_length");
|
||||
}
|
||||
|
||||
private HeapRegion at(long index) {
|
||||
Address arrayAddr = regionsField.getValue(addr);
|
||||
// Offset of &_region[index]
|
||||
long offset = index * VM.getVM().getAddressSize();
|
||||
Address regionAddr = arrayAddr.getAddressAt(offset);
|
||||
return (HeapRegion) VMObjectFactory.newObject(HeapRegion.class,
|
||||
regionAddr);
|
||||
}
|
||||
|
||||
public long length() {
|
||||
return lengthField.getValue(addr);
|
||||
}
|
||||
|
||||
private class HeapRegionIterator implements Iterator<HeapRegion> {
|
||||
private long index;
|
||||
private long length;
|
||||
|
||||
@Override
|
||||
public boolean hasNext() { return index < length; }
|
||||
|
||||
@Override
|
||||
public HeapRegion next() { return at(index++); }
|
||||
|
||||
@Override
|
||||
public void remove() { /* not supported */ }
|
||||
|
||||
HeapRegionIterator(Address addr) {
|
||||
index = 0;
|
||||
length = length();
|
||||
}
|
||||
}
|
||||
|
||||
public Iterator<HeapRegion> heapRegionIterator() {
|
||||
return new HeapRegionIterator(addr);
|
||||
}
|
||||
|
||||
public HeapRegionSeq(Address addr) {
|
||||
super(addr);
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -34,6 +34,7 @@ public class CollectedHeapName {
|
||||
public static final CollectedHeapName ABSTRACT = new CollectedHeapName("abstract");
|
||||
public static final CollectedHeapName SHARED_HEAP = new CollectedHeapName("SharedHeap");
|
||||
public static final CollectedHeapName GEN_COLLECTED_HEAP = new CollectedHeapName("GenCollectedHeap");
|
||||
public static final CollectedHeapName G1_COLLECTED_HEAP = new CollectedHeapName("G1CollectedHeap");
|
||||
public static final CollectedHeapName PARALLEL_SCAVENGE_HEAP = new CollectedHeapName("ParallelScavengeHeap");
|
||||
|
||||
public String toString() {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -28,6 +28,7 @@ import java.io.*;
|
||||
import java.util.*;
|
||||
import sun.jvm.hotspot.debugger.*;
|
||||
import sun.jvm.hotspot.gc_interface.*;
|
||||
import sun.jvm.hotspot.gc_implementation.g1.G1CollectedHeap;
|
||||
import sun.jvm.hotspot.gc_implementation.parallelScavenge.*;
|
||||
import sun.jvm.hotspot.oops.*;
|
||||
import sun.jvm.hotspot.types.*;
|
||||
@ -72,6 +73,7 @@ public class Universe {
|
||||
heapConstructor = new VirtualConstructor(db);
|
||||
heapConstructor.addMapping("GenCollectedHeap", GenCollectedHeap.class);
|
||||
heapConstructor.addMapping("ParallelScavengeHeap", ParallelScavengeHeap.class);
|
||||
heapConstructor.addMapping("G1CollectedHeap", G1CollectedHeap.class);
|
||||
|
||||
mainThreadGroupField = type.getOopField("_main_thread_group");
|
||||
systemThreadGroupField = type.getOopField("_system_thread_group");
|
||||
|
@ -33,6 +33,7 @@ import java.util.*;
|
||||
|
||||
import sun.jvm.hotspot.debugger.*;
|
||||
import sun.jvm.hotspot.gc_interface.*;
|
||||
import sun.jvm.hotspot.gc_implementation.g1.*;
|
||||
import sun.jvm.hotspot.gc_implementation.parallelScavenge.*;
|
||||
import sun.jvm.hotspot.memory.*;
|
||||
import sun.jvm.hotspot.runtime.*;
|
||||
@ -514,9 +515,16 @@ public class ObjectHeap {
|
||||
|
||||
private void addPermGenLiveRegions(List output, CollectedHeap heap) {
|
||||
LiveRegionsCollector lrc = new LiveRegionsCollector(output);
|
||||
if (heap instanceof GenCollectedHeap) {
|
||||
GenCollectedHeap genHeap = (GenCollectedHeap) heap;
|
||||
Generation gen = genHeap.permGen();
|
||||
if (heap instanceof SharedHeap) {
|
||||
if (Assert.ASSERTS_ENABLED) {
|
||||
Assert.that(heap instanceof GenCollectedHeap ||
|
||||
heap instanceof G1CollectedHeap,
|
||||
"Expecting GenCollectedHeap or G1CollectedHeap, " +
|
||||
"but got " + heap.getClass().getName());
|
||||
}
|
||||
// Handles both GenCollectedHeap and G1CollectedHeap
|
||||
SharedHeap sharedHeap = (SharedHeap) heap;
|
||||
Generation gen = sharedHeap.permGen();
|
||||
gen.spaceIterate(lrc, true);
|
||||
} else if (heap instanceof ParallelScavengeHeap) {
|
||||
ParallelScavengeHeap psh = (ParallelScavengeHeap) heap;
|
||||
@ -524,8 +532,9 @@ public class ObjectHeap {
|
||||
addLiveRegions(permGen.objectSpace().getLiveRegions(), output);
|
||||
} else {
|
||||
if (Assert.ASSERTS_ENABLED) {
|
||||
Assert.that(false, "Expecting GenCollectedHeap or ParallelScavengeHeap, but got " +
|
||||
heap.getClass().getName());
|
||||
Assert.that(false,
|
||||
"Expecting SharedHeap or ParallelScavengeHeap, " +
|
||||
"but got " + heap.getClass().getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -588,10 +597,14 @@ public class ObjectHeap {
|
||||
addLiveRegions(youngGen.fromSpace().getLiveRegions(), liveRegions);
|
||||
PSOldGen oldGen = psh.oldGen();
|
||||
addLiveRegions(oldGen.objectSpace().getLiveRegions(), liveRegions);
|
||||
} else if (heap instanceof G1CollectedHeap) {
|
||||
G1CollectedHeap g1h = (G1CollectedHeap) heap;
|
||||
g1h.heapRegionIterate(lrc);
|
||||
} else {
|
||||
if (Assert.ASSERTS_ENABLED) {
|
||||
Assert.that(false, "Expecting GenCollectedHeap or ParallelScavengeHeap, but got " +
|
||||
heap.getClass().getName());
|
||||
Assert.that(false, "Expecting GenCollectedHeap, G1CollectedHeap, " +
|
||||
"or ParallelScavengeHeap, but got " +
|
||||
heap.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,11 +26,11 @@ package sun.jvm.hotspot.tools;
|
||||
|
||||
import java.util.*;
|
||||
import sun.jvm.hotspot.gc_interface.*;
|
||||
import sun.jvm.hotspot.gc_implementation.g1.*;
|
||||
import sun.jvm.hotspot.gc_implementation.parallelScavenge.*;
|
||||
import sun.jvm.hotspot.gc_implementation.shared.*;
|
||||
import sun.jvm.hotspot.memory.*;
|
||||
import sun.jvm.hotspot.runtime.*;
|
||||
import sun.jvm.hotspot.tools.*;
|
||||
|
||||
public class HeapSummary extends Tool {
|
||||
|
||||
@ -70,32 +70,45 @@ public class HeapSummary extends Tool {
|
||||
System.out.println();
|
||||
System.out.println("Heap Usage:");
|
||||
|
||||
if (heap instanceof GenCollectedHeap) {
|
||||
GenCollectedHeap genHeap = (GenCollectedHeap) heap;
|
||||
for (int n = 0; n < genHeap.nGens(); n++) {
|
||||
Generation gen = genHeap.getGen(n);
|
||||
if (gen instanceof sun.jvm.hotspot.memory.DefNewGeneration) {
|
||||
System.out.println("New Generation (Eden + 1 Survivor Space):");
|
||||
printGen(gen);
|
||||
if (heap instanceof SharedHeap) {
|
||||
SharedHeap sharedHeap = (SharedHeap) heap;
|
||||
if (sharedHeap instanceof GenCollectedHeap) {
|
||||
GenCollectedHeap genHeap = (GenCollectedHeap) sharedHeap;
|
||||
for (int n = 0; n < genHeap.nGens(); n++) {
|
||||
Generation gen = genHeap.getGen(n);
|
||||
if (gen instanceof sun.jvm.hotspot.memory.DefNewGeneration) {
|
||||
System.out.println("New Generation (Eden + 1 Survivor Space):");
|
||||
printGen(gen);
|
||||
|
||||
ContiguousSpace eden = ((DefNewGeneration)gen).eden();
|
||||
System.out.println("Eden Space:");
|
||||
printSpace(eden);
|
||||
ContiguousSpace eden = ((DefNewGeneration)gen).eden();
|
||||
System.out.println("Eden Space:");
|
||||
printSpace(eden);
|
||||
|
||||
ContiguousSpace from = ((DefNewGeneration)gen).from();
|
||||
System.out.println("From Space:");
|
||||
printSpace(from);
|
||||
ContiguousSpace from = ((DefNewGeneration)gen).from();
|
||||
System.out.println("From Space:");
|
||||
printSpace(from);
|
||||
|
||||
ContiguousSpace to = ((DefNewGeneration)gen).to();
|
||||
System.out.println("To Space:");
|
||||
printSpace(to);
|
||||
} else {
|
||||
System.out.println(gen.name() + ":");
|
||||
printGen(gen);
|
||||
ContiguousSpace to = ((DefNewGeneration)gen).to();
|
||||
System.out.println("To Space:");
|
||||
printSpace(to);
|
||||
} else {
|
||||
System.out.println(gen.name() + ":");
|
||||
printGen(gen);
|
||||
}
|
||||
}
|
||||
} else if (sharedHeap instanceof G1CollectedHeap) {
|
||||
G1CollectedHeap g1h = (G1CollectedHeap) sharedHeap;
|
||||
G1MonitoringSupport g1mm = g1h.g1mm();
|
||||
System.out.println("G1 Young Generation");
|
||||
printG1Space("Eden Space:", g1mm.edenUsed(), g1mm.edenCommitted());
|
||||
printG1Space("From Space:", g1mm.survivorUsed(), g1mm.survivorCommitted());
|
||||
printG1Space("To Space:", 0, 0);
|
||||
printG1Space("G1 Old Generation", g1mm.oldUsed(), g1mm.oldCommitted());
|
||||
} else {
|
||||
throw new RuntimeException("unknown SharedHeap type : " + heap.getClass());
|
||||
}
|
||||
// Perm generation
|
||||
Generation permGen = genHeap.permGen();
|
||||
// Perm generation shared by the above
|
||||
Generation permGen = sharedHeap.permGen();
|
||||
System.out.println("Perm Generation:");
|
||||
printGen(permGen);
|
||||
} else if (heap instanceof ParallelScavengeHeap) {
|
||||
@ -119,7 +132,7 @@ public class HeapSummary extends Tool {
|
||||
printValMB("free = ", permFree);
|
||||
System.out.println(alignment + (double)permGen.used() * 100.0 / permGen.capacity() + "% used");
|
||||
} else {
|
||||
throw new RuntimeException("unknown heap type : " + heap.getClass());
|
||||
throw new RuntimeException("unknown CollectedHeap type : " + heap.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
@ -151,6 +164,14 @@ public class HeapSummary extends Tool {
|
||||
return;
|
||||
}
|
||||
|
||||
l = getFlagValue("UseG1GC", flagMap);
|
||||
if (l == 1L) {
|
||||
System.out.print("Garbage-First (G1) GC ");
|
||||
l = getFlagValue("ParallelGCThreads", flagMap);
|
||||
System.out.println("with " + l + " thread(s)");
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println("Mark Sweep Compact GC");
|
||||
}
|
||||
|
||||
@ -191,6 +212,16 @@ public class HeapSummary extends Tool {
|
||||
System.out.println(alignment + (double)space.used() * 100.0 / space.capacity() + "% used");
|
||||
}
|
||||
|
||||
private void printG1Space(String spaceName, long used, long capacity) {
|
||||
long free = capacity - used;
|
||||
System.out.println(spaceName);
|
||||
printValMB("capacity = ", capacity);
|
||||
printValMB("used = ", used);
|
||||
printValMB("free = ", free);
|
||||
double occPerc = (capacity > 0) ? (double) used * 100.0 / capacity : 0.0;
|
||||
System.out.println(alignment + occPerc + "% used");
|
||||
}
|
||||
|
||||
private static final double FACTOR = 1024*1024;
|
||||
private void printValMB(String title, long value) {
|
||||
if (value < 0) {
|
||||
|
@ -35,7 +35,7 @@ HOTSPOT_VM_COPYRIGHT=Copyright 2011
|
||||
|
||||
HS_MAJOR_VER=23
|
||||
HS_MINOR_VER=0
|
||||
HS_BUILD_NUMBER=01
|
||||
HS_BUILD_NUMBER=02
|
||||
|
||||
JDK_MAJOR_VER=1
|
||||
JDK_MINOR_VER=8
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -82,6 +82,7 @@ $(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windbg/amd64/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windbg/ia64/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/windbg/x86/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/debugger/x86/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/gc_implementation/g1/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/gc_implementation/parallelScavenge/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/gc_implementation/shared/*.java \
|
||||
$(AGENT_SRC_DIR)/sun/jvm/hotspot/gc_interface/*.java \
|
||||
|
@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -69,8 +69,8 @@ EMACS=emacs
|
||||
#
|
||||
|
||||
# Make sure the paths are fully specified, i.e. they must begin with /.
|
||||
SCRIPT=$(cd $(dirname $0) && pwd)/$(basename $0)
|
||||
RUNDIR=$(pwd)
|
||||
REL_MYDIR=`dirname $0`
|
||||
MYDIR=`cd $REL_MYDIR && pwd`
|
||||
|
||||
# Look whether the user wants to run inside gdb
|
||||
case "$1" in
|
||||
@ -95,12 +95,9 @@ case "$1" in
|
||||
;;
|
||||
esac
|
||||
|
||||
# Find out the absolute path to this script
|
||||
MYDIR=$(cd $(dirname $SCRIPT) && pwd)
|
||||
|
||||
JDK=
|
||||
if [ "${ALT_JAVA_HOME}" = "" ]; then
|
||||
source ${MYDIR}/jdkpath.sh
|
||||
. ${MYDIR}/jdkpath.sh
|
||||
else
|
||||
JDK=${ALT_JAVA_HOME%%/jre};
|
||||
fi
|
||||
@ -119,9 +116,6 @@ JRE=$JDK/jre
|
||||
JAVA_HOME=$JDK
|
||||
ARCH=@@LIBARCH@@
|
||||
|
||||
# Find out the absolute path to this script
|
||||
MYDIR=$(cd $(dirname $SCRIPT) && pwd)
|
||||
|
||||
SBP=${MYDIR}:${JRE}/lib/${ARCH}
|
||||
|
||||
# Set up a suitable LD_LIBRARY_PATH
|
||||
@ -146,7 +140,7 @@ if [ ! -x $LAUNCHER ] ; then
|
||||
fi
|
||||
|
||||
GDBSRCDIR=$MYDIR
|
||||
BASEDIR=$(cd $MYDIR/../../.. && pwd)
|
||||
BASEDIR=`cd $MYDIR/../../.. && pwd`
|
||||
|
||||
init_gdb() {
|
||||
# Create a gdb script in case we should run inside gdb
|
||||
@ -179,7 +173,7 @@ case "$MODE" in
|
||||
init_gdb
|
||||
# First find out what emacs version we're using, so that we can
|
||||
# use the new pretty GDB mode if emacs -version >= 22.1
|
||||
case $($EMACS -version 2> /dev/null) in
|
||||
case `$EMACS -version 2> /dev/null` in
|
||||
*GNU\ Emacs\ 2[23]*)
|
||||
emacs_gud_cmd="gdba"
|
||||
emacs_gud_args="--annotate=3"
|
||||
|
@ -2004,7 +2004,7 @@ void CMSCollector::do_compaction_work(bool clear_all_soft_refs) {
|
||||
ReferenceProcessorMTDiscoveryMutator rp_mut_discovery(ref_processor(), false);
|
||||
|
||||
ref_processor()->set_enqueuing_is_done(false);
|
||||
ref_processor()->enable_discovery();
|
||||
ref_processor()->enable_discovery(false /*verify_disabled*/, false /*check_no_refs*/);
|
||||
ref_processor()->setup_policy(clear_all_soft_refs);
|
||||
// If an asynchronous collection finishes, the _modUnionTable is
|
||||
// all clear. If we are assuming the collection from an asynchronous
|
||||
@ -3490,8 +3490,8 @@ void CMSCollector::checkpointRootsInitial(bool asynch) {
|
||||
MutexLockerEx x(bitMapLock(),
|
||||
Mutex::_no_safepoint_check_flag);
|
||||
checkpointRootsInitialWork(asynch);
|
||||
rp->verify_no_references_recorded();
|
||||
rp->enable_discovery(); // enable ("weak") refs discovery
|
||||
// enable ("weak") refs discovery
|
||||
rp->enable_discovery(true /*verify_disabled*/, true /*check_no_refs*/);
|
||||
_collectorState = Marking;
|
||||
} else {
|
||||
// (Weak) Refs discovery: this is controlled from genCollectedHeap::do_collection
|
||||
@ -3503,7 +3503,8 @@ void CMSCollector::checkpointRootsInitial(bool asynch) {
|
||||
"ref discovery for this generation kind");
|
||||
// already have locks
|
||||
checkpointRootsInitialWork(asynch);
|
||||
rp->enable_discovery(); // now enable ("weak") refs discovery
|
||||
// now enable ("weak") refs discovery
|
||||
rp->enable_discovery(true /*verify_disabled*/, false /*verify_no_refs*/);
|
||||
_collectorState = Marking;
|
||||
}
|
||||
SpecializationStats::print();
|
||||
|
@ -118,30 +118,6 @@ HeapRegion *CSetChooserCache::remove_first() {
|
||||
}
|
||||
}
|
||||
|
||||
// this is a bit expensive... but we expect that it should not be called
|
||||
// to often.
|
||||
void CSetChooserCache::remove(HeapRegion *hr) {
|
||||
assert(_occupancy > 0, "cache should not be empty");
|
||||
assert(hr->sort_index() < -1, "should already be in the cache");
|
||||
int index = get_index(hr->sort_index());
|
||||
assert(_cache[index] == hr, "index should be correct");
|
||||
int next_index = trim_index(index + 1);
|
||||
int last_index = trim_index(_first + _occupancy - 1);
|
||||
while (index != last_index) {
|
||||
assert(_cache[next_index] != NULL, "should not be null");
|
||||
_cache[index] = _cache[next_index];
|
||||
_cache[index]->set_sort_index(get_sort_index(index));
|
||||
|
||||
index = next_index;
|
||||
next_index = trim_index(next_index+1);
|
||||
}
|
||||
assert(index == last_index, "should have reached the last one");
|
||||
_cache[index] = NULL;
|
||||
hr->set_sort_index(-1);
|
||||
--_occupancy;
|
||||
assert(verify(), "cache should be consistent");
|
||||
}
|
||||
|
||||
static inline int orderRegions(HeapRegion* hr1, HeapRegion* hr2) {
|
||||
if (hr1 == NULL) {
|
||||
if (hr2 == NULL) return 0;
|
||||
@ -197,43 +173,34 @@ bool CollectionSetChooser::verify() {
|
||||
HeapRegion *prev = NULL;
|
||||
while (index < _numMarkedRegions) {
|
||||
HeapRegion *curr = _markedRegions.at(index++);
|
||||
if (curr != NULL) {
|
||||
int si = curr->sort_index();
|
||||
guarantee(!curr->is_young(), "should not be young!");
|
||||
guarantee(si > -1 && si == (index-1), "sort index invariant");
|
||||
if (prev != NULL) {
|
||||
guarantee(orderRegions(prev, curr) != 1, "regions should be sorted");
|
||||
}
|
||||
prev = curr;
|
||||
guarantee(curr != NULL, "Regions in _markedRegions array cannot be NULL");
|
||||
int si = curr->sort_index();
|
||||
guarantee(!curr->is_young(), "should not be young!");
|
||||
guarantee(si > -1 && si == (index-1), "sort index invariant");
|
||||
if (prev != NULL) {
|
||||
guarantee(orderRegions(prev, curr) != 1, "regions should be sorted");
|
||||
}
|
||||
prev = curr;
|
||||
}
|
||||
return _cache.verify();
|
||||
}
|
||||
#endif
|
||||
|
||||
bool
|
||||
CollectionSetChooser::addRegionToCache() {
|
||||
assert(!_cache.is_full(), "cache should not be full");
|
||||
|
||||
HeapRegion *hr = NULL;
|
||||
while (hr == NULL && _curMarkedIndex < _numMarkedRegions) {
|
||||
hr = _markedRegions.at(_curMarkedIndex++);
|
||||
}
|
||||
if (hr == NULL)
|
||||
return false;
|
||||
assert(!hr->is_young(), "should not be young!");
|
||||
assert(hr->sort_index() == _curMarkedIndex-1, "sort_index invariant");
|
||||
_markedRegions.at_put(hr->sort_index(), NULL);
|
||||
_cache.insert(hr);
|
||||
assert(!_cache.is_empty(), "cache should not be empty");
|
||||
assert(verify(), "cache should be consistent");
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
CollectionSetChooser::fillCache() {
|
||||
while (!_cache.is_full() && addRegionToCache()) {
|
||||
while (!_cache.is_full() && (_curMarkedIndex < _numMarkedRegions)) {
|
||||
HeapRegion* hr = _markedRegions.at(_curMarkedIndex);
|
||||
assert(hr != NULL,
|
||||
err_msg("Unexpected NULL hr in _markedRegions at index %d",
|
||||
_curMarkedIndex));
|
||||
_curMarkedIndex += 1;
|
||||
assert(!hr->is_young(), "should not be young!");
|
||||
assert(hr->sort_index() == _curMarkedIndex-1, "sort_index invariant");
|
||||
_markedRegions.at_put(hr->sort_index(), NULL);
|
||||
_cache.insert(hr);
|
||||
assert(!_cache.is_empty(), "cache should not be empty");
|
||||
}
|
||||
assert(verify(), "cache should be consistent");
|
||||
}
|
||||
|
||||
void
|
||||
@ -334,20 +301,6 @@ CollectionSetChooser::updateAfterFullCollection() {
|
||||
clearMarkedHeapRegions();
|
||||
}
|
||||
|
||||
void CollectionSetChooser::removeRegion(HeapRegion *hr) {
|
||||
int si = hr->sort_index();
|
||||
assert(si == -1 || hr->is_marked(), "Sort index not valid.");
|
||||
if (si > -1) {
|
||||
assert(_markedRegions.at(si) == hr, "Sort index not valid." );
|
||||
_markedRegions.at_put(si, NULL);
|
||||
} else if (si < -1) {
|
||||
assert(_cache.region_in_cache(hr), "should be in the cache");
|
||||
_cache.remove(hr);
|
||||
assert(hr->sort_index() == -1, "sort index invariant");
|
||||
}
|
||||
hr->set_sort_index(-1);
|
||||
}
|
||||
|
||||
// if time_remaining < 0.0, then this method should try to return
|
||||
// a region, whether it fits within the remaining time or not
|
||||
HeapRegion*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -29,6 +29,26 @@
|
||||
#include "utilities/growableArray.hpp"
|
||||
|
||||
// We need to sort heap regions by collection desirability.
|
||||
// This sorting is currently done in two "stages". An initial sort is
|
||||
// done following a cleanup pause as soon as all of the marked but
|
||||
// non-empty regions have been identified and the completely empty
|
||||
// ones reclaimed.
|
||||
// This gives us a global sort on a GC efficiency metric
|
||||
// based on predictive data available at that time. However,
|
||||
// any of these regions that are collected will only be collected
|
||||
// during a future GC pause, by which time it is possible that newer
|
||||
// data might allow us to revise and/or refine the earlier
|
||||
// pause predictions, leading to changes in expected gc efficiency
|
||||
// order. To somewhat mitigate this obsolescence, more so in the
|
||||
// case of regions towards the end of the list, which will be
|
||||
// picked later, these pre-sorted regions from the _markedRegions
|
||||
// array are not used as is, but a small prefix thereof is
|
||||
// insertion-sorted again into a small cache, based on more
|
||||
// recent remembered set information. Regions are then drawn
|
||||
// from this cache to construct the collection set at each
|
||||
// incremental GC.
|
||||
// This scheme and/or its implementation may be subject to
|
||||
// revision in the future.
|
||||
|
||||
class CSetChooserCache VALUE_OBJ_CLASS_SPEC {
|
||||
private:
|
||||
@ -37,8 +57,8 @@ private:
|
||||
} PrivateConstants;
|
||||
|
||||
HeapRegion* _cache[CacheLength];
|
||||
int _occupancy; // number of region in cache
|
||||
int _first; // "first" region in the cache
|
||||
int _occupancy; // number of regions in cache
|
||||
int _first; // (index of) "first" region in the cache
|
||||
|
||||
// adding CacheLength to deal with negative values
|
||||
inline int trim_index(int index) {
|
||||
@ -62,7 +82,6 @@ public:
|
||||
void clear(void);
|
||||
void insert(HeapRegion *hr);
|
||||
HeapRegion *remove_first(void);
|
||||
void remove (HeapRegion *hr);
|
||||
inline HeapRegion *get_first(void) {
|
||||
return _cache[_first];
|
||||
}
|
||||
@ -102,7 +121,6 @@ public:
|
||||
|
||||
void sortMarkedHeapRegions();
|
||||
void fillCache();
|
||||
bool addRegionToCache(void);
|
||||
void addMarkedHeapRegion(HeapRegion *hr);
|
||||
|
||||
// Must be called before calls to getParMarkedHeapRegionChunk.
|
||||
@ -122,9 +140,6 @@ public:
|
||||
|
||||
void updateAfterFullCollection();
|
||||
|
||||
// Ensure that "hr" is not a member of the marked region array or the cache
|
||||
void removeRegion(HeapRegion* hr);
|
||||
|
||||
bool unmarked_age_1_returned_as_new() { return _unmarked_age_1_returned_as_new; }
|
||||
|
||||
// Returns true if the used portion of "_markedRegions" is properly
|
||||
|
@ -818,10 +818,10 @@ void ConcurrentMark::checkpointRootsInitialPost() {
|
||||
NoteStartOfMarkHRClosure startcl;
|
||||
g1h->heap_region_iterate(&startcl);
|
||||
|
||||
// Start weak-reference discovery.
|
||||
ReferenceProcessor* rp = g1h->ref_processor();
|
||||
rp->verify_no_references_recorded();
|
||||
rp->enable_discovery(); // enable ("weak") refs discovery
|
||||
// Start Concurrent Marking weak-reference discovery.
|
||||
ReferenceProcessor* rp = g1h->ref_processor_cm();
|
||||
// enable ("weak") refs discovery
|
||||
rp->enable_discovery(true /*verify_disabled*/, true /*verify_no_refs*/);
|
||||
rp->setup_policy(false); // snapshot the soft ref policy to be used in this cycle
|
||||
|
||||
SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set();
|
||||
@ -1133,6 +1133,7 @@ void ConcurrentMark::checkpointRootsFinal(bool clear_all_soft_refs) {
|
||||
// world is stopped at this checkpoint
|
||||
assert(SafepointSynchronize::is_at_safepoint(),
|
||||
"world should be stopped");
|
||||
|
||||
G1CollectedHeap* g1h = G1CollectedHeap::heap();
|
||||
|
||||
// If a full collection has happened, we shouldn't do this.
|
||||
@ -1837,6 +1838,10 @@ void ConcurrentMark::cleanup() {
|
||||
size_t cleaned_up_bytes = start_used_bytes - g1h->used();
|
||||
g1p->decrease_known_garbage_bytes(cleaned_up_bytes);
|
||||
|
||||
// Clean up will have freed any regions completely full of garbage.
|
||||
// Update the soft reference policy with the new heap occupancy.
|
||||
Universe::update_heap_info_at_gc();
|
||||
|
||||
// We need to make this be a "collection" so any collection pause that
|
||||
// races with it goes around and waits for completeCleanup to finish.
|
||||
g1h->increment_total_collections();
|
||||
@ -2072,8 +2077,10 @@ class G1CMParDrainMarkingStackClosure: public VoidClosure {
|
||||
}
|
||||
};
|
||||
|
||||
// Implementation of AbstractRefProcTaskExecutor for G1
|
||||
class G1RefProcTaskExecutor: public AbstractRefProcTaskExecutor {
|
||||
// Implementation of AbstractRefProcTaskExecutor for parallel
|
||||
// reference processing at the end of G1 concurrent marking
|
||||
|
||||
class G1CMRefProcTaskExecutor: public AbstractRefProcTaskExecutor {
|
||||
private:
|
||||
G1CollectedHeap* _g1h;
|
||||
ConcurrentMark* _cm;
|
||||
@ -2082,7 +2089,7 @@ private:
|
||||
int _active_workers;
|
||||
|
||||
public:
|
||||
G1RefProcTaskExecutor(G1CollectedHeap* g1h,
|
||||
G1CMRefProcTaskExecutor(G1CollectedHeap* g1h,
|
||||
ConcurrentMark* cm,
|
||||
CMBitMap* bitmap,
|
||||
WorkGang* workers,
|
||||
@ -2096,7 +2103,7 @@ public:
|
||||
virtual void execute(EnqueueTask& task);
|
||||
};
|
||||
|
||||
class G1RefProcTaskProxy: public AbstractGangTask {
|
||||
class G1CMRefProcTaskProxy: public AbstractGangTask {
|
||||
typedef AbstractRefProcTaskExecutor::ProcessTask ProcessTask;
|
||||
ProcessTask& _proc_task;
|
||||
G1CollectedHeap* _g1h;
|
||||
@ -2104,7 +2111,7 @@ class G1RefProcTaskProxy: public AbstractGangTask {
|
||||
CMBitMap* _bitmap;
|
||||
|
||||
public:
|
||||
G1RefProcTaskProxy(ProcessTask& proc_task,
|
||||
G1CMRefProcTaskProxy(ProcessTask& proc_task,
|
||||
G1CollectedHeap* g1h,
|
||||
ConcurrentMark* cm,
|
||||
CMBitMap* bitmap) :
|
||||
@ -2122,10 +2129,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
void G1RefProcTaskExecutor::execute(ProcessTask& proc_task) {
|
||||
void G1CMRefProcTaskExecutor::execute(ProcessTask& proc_task) {
|
||||
assert(_workers != NULL, "Need parallel worker threads.");
|
||||
|
||||
G1RefProcTaskProxy proc_task_proxy(proc_task, _g1h, _cm, _bitmap);
|
||||
G1CMRefProcTaskProxy proc_task_proxy(proc_task, _g1h, _cm, _bitmap);
|
||||
|
||||
// We need to reset the phase for each task execution so that
|
||||
// the termination protocol of CMTask::do_marking_step works.
|
||||
@ -2135,12 +2142,12 @@ void G1RefProcTaskExecutor::execute(ProcessTask& proc_task) {
|
||||
_g1h->set_par_threads(0);
|
||||
}
|
||||
|
||||
class G1RefEnqueueTaskProxy: public AbstractGangTask {
|
||||
class G1CMRefEnqueueTaskProxy: public AbstractGangTask {
|
||||
typedef AbstractRefProcTaskExecutor::EnqueueTask EnqueueTask;
|
||||
EnqueueTask& _enq_task;
|
||||
|
||||
public:
|
||||
G1RefEnqueueTaskProxy(EnqueueTask& enq_task) :
|
||||
G1CMRefEnqueueTaskProxy(EnqueueTask& enq_task) :
|
||||
AbstractGangTask("Enqueue reference objects in parallel"),
|
||||
_enq_task(enq_task)
|
||||
{ }
|
||||
@ -2150,10 +2157,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
void G1RefProcTaskExecutor::execute(EnqueueTask& enq_task) {
|
||||
void G1CMRefProcTaskExecutor::execute(EnqueueTask& enq_task) {
|
||||
assert(_workers != NULL, "Need parallel worker threads.");
|
||||
|
||||
G1RefEnqueueTaskProxy enq_task_proxy(enq_task);
|
||||
G1CMRefEnqueueTaskProxy enq_task_proxy(enq_task);
|
||||
|
||||
_g1h->set_par_threads(_active_workers);
|
||||
_workers->run_task(&enq_task_proxy);
|
||||
@ -2163,71 +2170,84 @@ void G1RefProcTaskExecutor::execute(EnqueueTask& enq_task) {
|
||||
void ConcurrentMark::weakRefsWork(bool clear_all_soft_refs) {
|
||||
ResourceMark rm;
|
||||
HandleMark hm;
|
||||
G1CollectedHeap* g1h = G1CollectedHeap::heap();
|
||||
ReferenceProcessor* rp = g1h->ref_processor();
|
||||
|
||||
// See the comment in G1CollectedHeap::ref_processing_init()
|
||||
// about how reference processing currently works in G1.
|
||||
G1CollectedHeap* g1h = G1CollectedHeap::heap();
|
||||
|
||||
// Process weak references.
|
||||
rp->setup_policy(clear_all_soft_refs);
|
||||
assert(_markStack.isEmpty(), "mark stack should be empty");
|
||||
// Is alive closure.
|
||||
G1CMIsAliveClosure g1_is_alive(g1h);
|
||||
|
||||
G1CMIsAliveClosure g1_is_alive(g1h);
|
||||
G1CMKeepAliveClosure g1_keep_alive(g1h, this, nextMarkBitMap());
|
||||
G1CMDrainMarkingStackClosure
|
||||
g1_drain_mark_stack(nextMarkBitMap(), &_markStack, &g1_keep_alive);
|
||||
// We use the work gang from the G1CollectedHeap and we utilize all
|
||||
// the worker threads.
|
||||
int active_workers = g1h->workers() ? g1h->workers()->total_workers() : 1;
|
||||
active_workers = MAX2(MIN2(active_workers, (int)_max_task_num), 1);
|
||||
// Inner scope to exclude the cleaning of the string and symbol
|
||||
// tables from the displayed time.
|
||||
{
|
||||
bool verbose = PrintGC && PrintGCDetails;
|
||||
if (verbose) {
|
||||
gclog_or_tty->put(' ');
|
||||
}
|
||||
TraceTime t("GC ref-proc", verbose, false, gclog_or_tty);
|
||||
|
||||
G1RefProcTaskExecutor par_task_executor(g1h, this, nextMarkBitMap(),
|
||||
g1h->workers(), active_workers);
|
||||
ReferenceProcessor* rp = g1h->ref_processor_cm();
|
||||
|
||||
// See the comment in G1CollectedHeap::ref_processing_init()
|
||||
// about how reference processing currently works in G1.
|
||||
|
||||
if (rp->processing_is_mt()) {
|
||||
// Set the degree of MT here. If the discovery is done MT, there
|
||||
// may have been a different number of threads doing the discovery
|
||||
// and a different number of discovered lists may have Ref objects.
|
||||
// That is OK as long as the Reference lists are balanced (see
|
||||
// balance_all_queues() and balance_queues()).
|
||||
rp->set_active_mt_degree(active_workers);
|
||||
// Process weak references.
|
||||
rp->setup_policy(clear_all_soft_refs);
|
||||
assert(_markStack.isEmpty(), "mark stack should be empty");
|
||||
|
||||
rp->process_discovered_references(&g1_is_alive,
|
||||
G1CMKeepAliveClosure g1_keep_alive(g1h, this, nextMarkBitMap());
|
||||
G1CMDrainMarkingStackClosure
|
||||
g1_drain_mark_stack(nextMarkBitMap(), &_markStack, &g1_keep_alive);
|
||||
|
||||
// We use the work gang from the G1CollectedHeap and we utilize all
|
||||
// the worker threads.
|
||||
int active_workers = g1h->workers() ? g1h->workers()->total_workers() : 1;
|
||||
active_workers = MAX2(MIN2(active_workers, (int)_max_task_num), 1);
|
||||
|
||||
G1CMRefProcTaskExecutor par_task_executor(g1h, this, nextMarkBitMap(),
|
||||
g1h->workers(), active_workers);
|
||||
|
||||
if (rp->processing_is_mt()) {
|
||||
// Set the degree of MT here. If the discovery is done MT, there
|
||||
// may have been a different number of threads doing the discovery
|
||||
// and a different number of discovered lists may have Ref objects.
|
||||
// That is OK as long as the Reference lists are balanced (see
|
||||
// balance_all_queues() and balance_queues()).
|
||||
rp->set_active_mt_degree(active_workers);
|
||||
|
||||
rp->process_discovered_references(&g1_is_alive,
|
||||
&g1_keep_alive,
|
||||
&g1_drain_mark_stack,
|
||||
&par_task_executor);
|
||||
|
||||
// The work routines of the parallel keep_alive and drain_marking_stack
|
||||
// will set the has_overflown flag if we overflow the global marking
|
||||
// stack.
|
||||
} else {
|
||||
rp->process_discovered_references(&g1_is_alive,
|
||||
&g1_keep_alive,
|
||||
&g1_drain_mark_stack,
|
||||
NULL);
|
||||
// The work routines of the parallel keep_alive and drain_marking_stack
|
||||
// will set the has_overflown flag if we overflow the global marking
|
||||
// stack.
|
||||
} else {
|
||||
rp->process_discovered_references(&g1_is_alive,
|
||||
&g1_keep_alive,
|
||||
&g1_drain_mark_stack,
|
||||
NULL);
|
||||
}
|
||||
|
||||
assert(_markStack.overflow() || _markStack.isEmpty(),
|
||||
"mark stack should be empty (unless it overflowed)");
|
||||
if (_markStack.overflow()) {
|
||||
// Should have been done already when we tried to push an
|
||||
// entry on to the global mark stack. But let's do it again.
|
||||
set_has_overflown();
|
||||
}
|
||||
|
||||
if (rp->processing_is_mt()) {
|
||||
assert(rp->num_q() == active_workers, "why not");
|
||||
rp->enqueue_discovered_references(&par_task_executor);
|
||||
} else {
|
||||
rp->enqueue_discovered_references();
|
||||
}
|
||||
|
||||
rp->verify_no_references_recorded();
|
||||
assert(!rp->discovery_enabled(), "Post condition");
|
||||
}
|
||||
|
||||
assert(_markStack.overflow() || _markStack.isEmpty(),
|
||||
"mark stack should be empty (unless it overflowed)");
|
||||
if (_markStack.overflow()) {
|
||||
// Should have been done already when we tried to push an
|
||||
// entry on to the global mark stack. But let's do it again.
|
||||
set_has_overflown();
|
||||
}
|
||||
|
||||
if (rp->processing_is_mt()) {
|
||||
assert(rp->num_q() == active_workers, "why not");
|
||||
rp->enqueue_discovered_references(&par_task_executor);
|
||||
} else {
|
||||
rp->enqueue_discovered_references();
|
||||
}
|
||||
|
||||
rp->verify_no_references_recorded();
|
||||
assert(!rp->discovery_enabled(), "should have been disabled");
|
||||
|
||||
// Now clean up stale oops in StringTable
|
||||
StringTable::unlink(&g1_is_alive);
|
||||
// Clean up unreferenced symbols in symbol table.
|
||||
@ -3329,7 +3349,7 @@ G1CMOopClosure::G1CMOopClosure(G1CollectedHeap* g1h,
|
||||
assert(_ref_processor == NULL, "should be initialized to NULL");
|
||||
|
||||
if (G1UseConcMarkReferenceProcessing) {
|
||||
_ref_processor = g1h->ref_processor();
|
||||
_ref_processor = g1h->ref_processor_cm();
|
||||
assert(_ref_processor != NULL, "should not be NULL");
|
||||
}
|
||||
}
|
||||
@ -4564,6 +4584,15 @@ G1PrintRegionLivenessInfoClosure(outputStream* out, const char* phase_name)
|
||||
G1PPRL_DOUBLE_H_FORMAT,
|
||||
"type", "address-range",
|
||||
"used", "prev-live", "next-live", "gc-eff");
|
||||
_out->print_cr(G1PPRL_LINE_PREFIX
|
||||
G1PPRL_TYPE_H_FORMAT
|
||||
G1PPRL_ADDR_BASE_H_FORMAT
|
||||
G1PPRL_BYTE_H_FORMAT
|
||||
G1PPRL_BYTE_H_FORMAT
|
||||
G1PPRL_BYTE_H_FORMAT
|
||||
G1PPRL_DOUBLE_H_FORMAT,
|
||||
"", "",
|
||||
"(bytes)", "(bytes)", "(bytes)", "(bytes/ms)");
|
||||
}
|
||||
|
||||
// It takes as a parameter a reference to one of the _hum_* fields, it
|
||||
@ -4575,7 +4604,7 @@ size_t G1PrintRegionLivenessInfoClosure::get_hum_bytes(size_t* hum_bytes) {
|
||||
// The > 0 check is to deal with the prev and next live bytes which
|
||||
// could be 0.
|
||||
if (*hum_bytes > 0) {
|
||||
bytes = MIN2((size_t) HeapRegion::GrainBytes, *hum_bytes);
|
||||
bytes = MIN2(HeapRegion::GrainBytes, *hum_bytes);
|
||||
*hum_bytes -= bytes;
|
||||
}
|
||||
return bytes;
|
||||
|
@ -366,8 +366,8 @@ class ConcurrentMark: public CHeapObj {
|
||||
friend class CMConcurrentMarkingTask;
|
||||
friend class G1ParNoteEndTask;
|
||||
friend class CalcLiveObjectsClosure;
|
||||
friend class G1RefProcTaskProxy;
|
||||
friend class G1RefProcTaskExecutor;
|
||||
friend class G1CMRefProcTaskProxy;
|
||||
friend class G1CMRefProcTaskExecutor;
|
||||
friend class G1CMParKeepAliveAndDrainClosure;
|
||||
friend class G1CMParDrainMarkingStackClosure;
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -155,6 +155,19 @@ public:
|
||||
: G1AllocRegion("Mutator Alloc Region", false /* bot_updates */) { }
|
||||
};
|
||||
|
||||
// The G1 STW is alive closure.
|
||||
// An instance is embedded into the G1CH and used as the
|
||||
// (optional) _is_alive_non_header closure in the STW
|
||||
// reference processor. It is also extensively used during
|
||||
// refence processing during STW evacuation pauses.
|
||||
class G1STWIsAliveClosure: public BoolObjectClosure {
|
||||
G1CollectedHeap* _g1;
|
||||
public:
|
||||
G1STWIsAliveClosure(G1CollectedHeap* g1) : _g1(g1) {}
|
||||
void do_object(oop p) { assert(false, "Do not call."); }
|
||||
bool do_object_b(oop p);
|
||||
};
|
||||
|
||||
class SurvivorGCAllocRegion : public G1AllocRegion {
|
||||
protected:
|
||||
virtual HeapRegion* allocate_new_region(size_t word_size, bool force);
|
||||
@ -174,6 +187,7 @@ public:
|
||||
};
|
||||
|
||||
class RefineCardTableEntryClosure;
|
||||
|
||||
class G1CollectedHeap : public SharedHeap {
|
||||
friend class VM_G1CollectForAllocation;
|
||||
friend class VM_GenCollectForPermanentAllocation;
|
||||
@ -573,9 +587,20 @@ protected:
|
||||
// allocated block, or else "NULL".
|
||||
HeapWord* expand_and_allocate(size_t word_size);
|
||||
|
||||
// Process any reference objects discovered during
|
||||
// an incremental evacuation pause.
|
||||
void process_discovered_references();
|
||||
|
||||
// Enqueue any remaining discovered references
|
||||
// after processing.
|
||||
void enqueue_discovered_references();
|
||||
|
||||
public:
|
||||
|
||||
G1MonitoringSupport* g1mm() { return _g1mm; }
|
||||
G1MonitoringSupport* g1mm() {
|
||||
assert(_g1mm != NULL, "should have been initialized");
|
||||
return _g1mm;
|
||||
}
|
||||
|
||||
// Expand the garbage-first heap by at least the given size (in bytes!).
|
||||
// Returns true if the heap was expanded by the requested amount;
|
||||
@ -822,17 +847,87 @@ protected:
|
||||
void finalize_for_evac_failure();
|
||||
|
||||
// An attempt to evacuate "obj" has failed; take necessary steps.
|
||||
oop handle_evacuation_failure_par(OopsInHeapRegionClosure* cl, oop obj);
|
||||
oop handle_evacuation_failure_par(OopsInHeapRegionClosure* cl, oop obj,
|
||||
bool should_mark_root);
|
||||
void handle_evacuation_failure_common(oop obj, markOop m);
|
||||
|
||||
// Instance of the concurrent mark is_alive closure for embedding
|
||||
// into the reference processor as the is_alive_non_header. This
|
||||
// prevents unnecessary additions to the discovered lists during
|
||||
// concurrent discovery.
|
||||
G1CMIsAliveClosure _is_alive_closure;
|
||||
// ("Weak") Reference processing support.
|
||||
//
|
||||
// G1 has 2 instances of the referece processor class. One
|
||||
// (_ref_processor_cm) handles reference object discovery
|
||||
// and subsequent processing during concurrent marking cycles.
|
||||
//
|
||||
// The other (_ref_processor_stw) handles reference object
|
||||
// discovery and processing during full GCs and incremental
|
||||
// evacuation pauses.
|
||||
//
|
||||
// During an incremental pause, reference discovery will be
|
||||
// temporarily disabled for _ref_processor_cm and will be
|
||||
// enabled for _ref_processor_stw. At the end of the evacuation
|
||||
// pause references discovered by _ref_processor_stw will be
|
||||
// processed and discovery will be disabled. The previous
|
||||
// setting for reference object discovery for _ref_processor_cm
|
||||
// will be re-instated.
|
||||
//
|
||||
// At the start of marking:
|
||||
// * Discovery by the CM ref processor is verified to be inactive
|
||||
// and it's discovered lists are empty.
|
||||
// * Discovery by the CM ref processor is then enabled.
|
||||
//
|
||||
// At the end of marking:
|
||||
// * Any references on the CM ref processor's discovered
|
||||
// lists are processed (possibly MT).
|
||||
//
|
||||
// At the start of full GC we:
|
||||
// * Disable discovery by the CM ref processor and
|
||||
// empty CM ref processor's discovered lists
|
||||
// (without processing any entries).
|
||||
// * Verify that the STW ref processor is inactive and it's
|
||||
// discovered lists are empty.
|
||||
// * Temporarily set STW ref processor discovery as single threaded.
|
||||
// * Temporarily clear the STW ref processor's _is_alive_non_header
|
||||
// field.
|
||||
// * Finally enable discovery by the STW ref processor.
|
||||
//
|
||||
// The STW ref processor is used to record any discovered
|
||||
// references during the full GC.
|
||||
//
|
||||
// At the end of a full GC we:
|
||||
// * Enqueue any reference objects discovered by the STW ref processor
|
||||
// that have non-live referents. This has the side-effect of
|
||||
// making the STW ref processor inactive by disabling discovery.
|
||||
// * Verify that the CM ref processor is still inactive
|
||||
// and no references have been placed on it's discovered
|
||||
// lists (also checked as a precondition during initial marking).
|
||||
|
||||
// ("Weak") Reference processing support
|
||||
ReferenceProcessor* _ref_processor;
|
||||
// The (stw) reference processor...
|
||||
ReferenceProcessor* _ref_processor_stw;
|
||||
|
||||
// During reference object discovery, the _is_alive_non_header
|
||||
// closure (if non-null) is applied to the referent object to
|
||||
// determine whether the referent is live. If so then the
|
||||
// reference object does not need to be 'discovered' and can
|
||||
// be treated as a regular oop. This has the benefit of reducing
|
||||
// the number of 'discovered' reference objects that need to
|
||||
// be processed.
|
||||
//
|
||||
// Instance of the is_alive closure for embedding into the
|
||||
// STW reference processor as the _is_alive_non_header field.
|
||||
// Supplying a value for the _is_alive_non_header field is
|
||||
// optional but doing so prevents unnecessary additions to
|
||||
// the discovered lists during reference discovery.
|
||||
G1STWIsAliveClosure _is_alive_closure_stw;
|
||||
|
||||
// The (concurrent marking) reference processor...
|
||||
ReferenceProcessor* _ref_processor_cm;
|
||||
|
||||
// Instance of the concurrent mark is_alive closure for embedding
|
||||
// into the Concurrent Marking reference processor as the
|
||||
// _is_alive_non_header field. Supplying a value for the
|
||||
// _is_alive_non_header field is optional but doing so prevents
|
||||
// unnecessary additions to the discovered lists during reference
|
||||
// discovery.
|
||||
G1CMIsAliveClosure _is_alive_closure_cm;
|
||||
|
||||
enum G1H_process_strong_roots_tasks {
|
||||
G1H_PS_mark_stack_oops_do,
|
||||
@ -873,6 +968,7 @@ public:
|
||||
// specified by the policy object.
|
||||
jint initialize();
|
||||
|
||||
// Initialize weak reference processing.
|
||||
virtual void ref_processing_init();
|
||||
|
||||
void set_par_threads(int t) {
|
||||
@ -924,8 +1020,13 @@ public:
|
||||
// The shared block offset table array.
|
||||
G1BlockOffsetSharedArray* bot_shared() const { return _bot_shared; }
|
||||
|
||||
// Reference Processing accessor
|
||||
ReferenceProcessor* ref_processor() { return _ref_processor; }
|
||||
// Reference Processing accessors
|
||||
|
||||
// The STW reference processor....
|
||||
ReferenceProcessor* ref_processor_stw() const { return _ref_processor_stw; }
|
||||
|
||||
// The Concurent Marking reference processor...
|
||||
ReferenceProcessor* ref_processor_cm() const { return _ref_processor_cm; }
|
||||
|
||||
virtual size_t capacity() const;
|
||||
virtual size_t used() const;
|
||||
@ -1236,12 +1337,7 @@ public:
|
||||
// storage in the heap comes from a young region or not.
|
||||
// See ReduceInitialCardMarks.
|
||||
virtual bool can_elide_tlab_store_barriers() const {
|
||||
// 6920090: Temporarily disabled, because of lingering
|
||||
// instabilities related to RICM with G1. In the
|
||||
// interim, the option ReduceInitialCardMarksForG1
|
||||
// below is left solely as a debugging device at least
|
||||
// until 6920109 fixes the instabilities.
|
||||
return ReduceInitialCardMarksForG1;
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool card_mark_must_follow_store() const {
|
||||
@ -1265,8 +1361,6 @@ public:
|
||||
// update logging post-barrier, we don't maintain remembered set
|
||||
// information for young gen objects.
|
||||
virtual bool can_elide_initializing_store_barrier(oop new_obj) {
|
||||
// Re 6920090, 6920109 above.
|
||||
assert(ReduceInitialCardMarksForG1, "Else cannot be here");
|
||||
return is_in_young(new_obj);
|
||||
}
|
||||
|
||||
|
@ -152,8 +152,12 @@ G1CollectorPolicy::G1CollectorPolicy() :
|
||||
|
||||
_summary(new Summary()),
|
||||
|
||||
#ifndef PRODUCT
|
||||
_cur_clear_ct_time_ms(0.0),
|
||||
|
||||
_cur_ref_proc_time_ms(0.0),
|
||||
_cur_ref_enq_time_ms(0.0),
|
||||
|
||||
#ifndef PRODUCT
|
||||
_min_clear_cc_time_ms(-1.0),
|
||||
_max_clear_cc_time_ms(-1.0),
|
||||
_cur_clear_cc_time_ms(0.0),
|
||||
@ -294,10 +298,10 @@ G1CollectorPolicy::G1CollectorPolicy() :
|
||||
}
|
||||
|
||||
// Verify PLAB sizes
|
||||
const uint region_size = HeapRegion::GrainWords;
|
||||
const size_t region_size = HeapRegion::GrainWords;
|
||||
if (YoungPLABSize > region_size || OldPLABSize > region_size) {
|
||||
char buffer[128];
|
||||
jio_snprintf(buffer, sizeof(buffer), "%sPLABSize should be at most %u",
|
||||
jio_snprintf(buffer, sizeof(buffer), "%sPLABSize should be at most "SIZE_FORMAT,
|
||||
OldPLABSize > region_size ? "Old" : "Young", region_size);
|
||||
vm_exit_during_initialization(buffer);
|
||||
}
|
||||
@ -459,15 +463,16 @@ void G1CollectorPolicy::initialize_flags() {
|
||||
// ParallelScavengeHeap::initialize()). We might change this in the
|
||||
// future, but it's a good start.
|
||||
class G1YoungGenSizer : public TwoGenerationCollectorPolicy {
|
||||
private:
|
||||
size_t size_to_region_num(size_t byte_size) {
|
||||
return MAX2((size_t) 1, byte_size / HeapRegion::GrainBytes);
|
||||
}
|
||||
|
||||
public:
|
||||
G1YoungGenSizer() {
|
||||
initialize_flags();
|
||||
initialize_size_info();
|
||||
}
|
||||
size_t size_to_region_num(size_t byte_size) {
|
||||
return MAX2((size_t) 1, byte_size / HeapRegion::GrainBytes);
|
||||
}
|
||||
size_t min_young_region_num() {
|
||||
return size_to_region_num(_min_gen0_size);
|
||||
}
|
||||
@ -501,11 +506,10 @@ void G1CollectorPolicy::init() {
|
||||
|
||||
if (FLAG_IS_CMDLINE(NewRatio)) {
|
||||
if (FLAG_IS_CMDLINE(NewSize) || FLAG_IS_CMDLINE(MaxNewSize)) {
|
||||
gclog_or_tty->print_cr("-XX:NewSize and -XX:MaxNewSize overrides -XX:NewRatio");
|
||||
warning("-XX:NewSize and -XX:MaxNewSize override -XX:NewRatio");
|
||||
} else {
|
||||
// Treat NewRatio as a fixed size that is only recalculated when the heap size changes
|
||||
size_t heap_regions = sizer.size_to_region_num(_g1->n_regions());
|
||||
update_young_list_size_using_newratio(heap_regions);
|
||||
update_young_list_size_using_newratio(_g1->n_regions());
|
||||
_using_new_ratio_calculations = true;
|
||||
}
|
||||
}
|
||||
@ -1479,6 +1483,8 @@ void G1CollectorPolicy::record_collection_pause_end() {
|
||||
#endif
|
||||
print_stats(1, "Other", other_time_ms);
|
||||
print_stats(2, "Choose CSet", _recorded_young_cset_choice_time_ms);
|
||||
print_stats(2, "Ref Proc", _cur_ref_proc_time_ms);
|
||||
print_stats(2, "Ref Enq", _cur_ref_enq_time_ms);
|
||||
|
||||
for (int i = 0; i < _aux_num; ++i) {
|
||||
if (_cur_aux_times_set[i]) {
|
||||
@ -1519,11 +1525,17 @@ void G1CollectorPolicy::record_collection_pause_end() {
|
||||
}
|
||||
|
||||
if (_last_full_young_gc) {
|
||||
ergo_verbose2(ErgoPartiallyYoungGCs,
|
||||
"start partially-young GCs",
|
||||
ergo_format_byte_perc("known garbage"),
|
||||
_known_garbage_bytes, _known_garbage_ratio * 100.0);
|
||||
set_full_young_gcs(false);
|
||||
if (!last_pause_included_initial_mark) {
|
||||
ergo_verbose2(ErgoPartiallyYoungGCs,
|
||||
"start partially-young GCs",
|
||||
ergo_format_byte_perc("known garbage"),
|
||||
_known_garbage_bytes, _known_garbage_ratio * 100.0);
|
||||
set_full_young_gcs(false);
|
||||
} else {
|
||||
ergo_verbose0(ErgoPartiallyYoungGCs,
|
||||
"do not start partially-young GCs",
|
||||
ergo_format_reason("concurrent cycle is about to start"));
|
||||
}
|
||||
_last_full_young_gc = false;
|
||||
}
|
||||
|
||||
@ -2485,6 +2497,13 @@ G1CollectorPolicy::decide_on_conc_mark_initiation() {
|
||||
// initiate a new cycle.
|
||||
|
||||
set_during_initial_mark_pause();
|
||||
// We do not allow non-full young GCs during marking.
|
||||
if (!full_young_gcs()) {
|
||||
set_full_young_gcs(true);
|
||||
ergo_verbose0(ErgoPartiallyYoungGCs,
|
||||
"end partially-young GCs",
|
||||
ergo_format_reason("concurrent cycle is about to start"));
|
||||
}
|
||||
|
||||
// And we can now clear initiate_conc_mark_if_possible() as
|
||||
// we've already acted on it.
|
||||
|
@ -119,6 +119,8 @@ protected:
|
||||
double _cur_satb_drain_time_ms;
|
||||
double _cur_clear_ct_time_ms;
|
||||
bool _satb_drain_time_set;
|
||||
double _cur_ref_proc_time_ms;
|
||||
double _cur_ref_enq_time_ms;
|
||||
|
||||
#ifndef PRODUCT
|
||||
// Card Table Count Cache stats
|
||||
@ -986,6 +988,14 @@ public:
|
||||
_cur_aux_times_ms[i] += ms;
|
||||
}
|
||||
|
||||
void record_ref_proc_time(double ms) {
|
||||
_cur_ref_proc_time_ms = ms;
|
||||
}
|
||||
|
||||
void record_ref_enq_time(double ms) {
|
||||
_cur_ref_enq_time_ms = ms;
|
||||
}
|
||||
|
||||
#ifndef PRODUCT
|
||||
void record_cc_clear_time(double ms) {
|
||||
if (_min_clear_cc_time_ms < 0.0 || ms <= _min_clear_cc_time_ms)
|
||||
@ -1139,6 +1149,10 @@ public:
|
||||
return young_list_length < young_list_max_length;
|
||||
}
|
||||
|
||||
size_t young_list_max_length() {
|
||||
return _young_list_max_length;
|
||||
}
|
||||
|
||||
void update_region_num(bool young);
|
||||
|
||||
bool full_young_gcs() {
|
||||
|
@ -62,6 +62,8 @@ void G1MarkSweep::invoke_at_safepoint(ReferenceProcessor* rp,
|
||||
// hook up weak ref data so it can be used during Mark-Sweep
|
||||
assert(GenMarkSweep::ref_processor() == NULL, "no stomping");
|
||||
assert(rp != NULL, "should be non-NULL");
|
||||
assert(rp == G1CollectedHeap::heap()->ref_processor_stw(), "Precondition");
|
||||
|
||||
GenMarkSweep::_ref_processor = rp;
|
||||
rp->setup_policy(clear_all_softrefs);
|
||||
|
||||
@ -139,6 +141,8 @@ void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading,
|
||||
|
||||
// Process reference objects found during marking
|
||||
ReferenceProcessor* rp = GenMarkSweep::ref_processor();
|
||||
assert(rp == G1CollectedHeap::heap()->ref_processor_stw(), "Sanity");
|
||||
|
||||
rp->setup_policy(clear_all_softrefs);
|
||||
rp->process_discovered_references(&GenMarkSweep::is_alive,
|
||||
&GenMarkSweep::keep_alive,
|
||||
@ -166,7 +170,6 @@ void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading,
|
||||
GenMarkSweep::follow_mdo_weak_refs();
|
||||
assert(GenMarkSweep::_marking_stack.is_empty(), "just drained");
|
||||
|
||||
|
||||
// Visit interned string tables and delete unmarked oops
|
||||
StringTable::unlink(&GenMarkSweep::is_alive);
|
||||
// Clean up unreferenced symbols in symbol table.
|
||||
@ -346,7 +349,8 @@ void G1MarkSweep::mark_sweep_phase3() {
|
||||
NULL, // do not touch code cache here
|
||||
&GenMarkSweep::adjust_pointer_closure);
|
||||
|
||||
g1h->ref_processor()->weak_oops_do(&GenMarkSweep::adjust_root_pointer_closure);
|
||||
assert(GenMarkSweep::ref_processor() == g1h->ref_processor_stw(), "Sanity");
|
||||
g1h->ref_processor_stw()->weak_oops_do(&GenMarkSweep::adjust_root_pointer_closure);
|
||||
|
||||
// Now adjust pointers in remaining weak roots. (All of which should
|
||||
// have been cleared if they pointed to non-surviving objects.)
|
||||
|
@ -27,19 +27,69 @@
|
||||
#include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
|
||||
#include "gc_implementation/g1/g1CollectorPolicy.hpp"
|
||||
|
||||
G1MonitoringSupport::G1MonitoringSupport(G1CollectedHeap* g1h,
|
||||
VirtualSpace* g1_storage_addr) :
|
||||
G1GenerationCounters::G1GenerationCounters(G1MonitoringSupport* g1mm,
|
||||
const char* name,
|
||||
int ordinal, int spaces,
|
||||
size_t min_capacity,
|
||||
size_t max_capacity,
|
||||
size_t curr_capacity)
|
||||
: GenerationCounters(name, ordinal, spaces, min_capacity,
|
||||
max_capacity, curr_capacity), _g1mm(g1mm) { }
|
||||
|
||||
// We pad the capacity three times given that the young generation
|
||||
// contains three spaces (eden and two survivors).
|
||||
G1YoungGenerationCounters::G1YoungGenerationCounters(G1MonitoringSupport* g1mm,
|
||||
const char* name)
|
||||
: G1GenerationCounters(g1mm, name, 0 /* ordinal */, 3 /* spaces */,
|
||||
G1MonitoringSupport::pad_capacity(0, 3) /* min_capacity */,
|
||||
G1MonitoringSupport::pad_capacity(g1mm->young_gen_max(), 3),
|
||||
G1MonitoringSupport::pad_capacity(0, 3) /* curr_capacity */) {
|
||||
update_all();
|
||||
}
|
||||
|
||||
G1OldGenerationCounters::G1OldGenerationCounters(G1MonitoringSupport* g1mm,
|
||||
const char* name)
|
||||
: G1GenerationCounters(g1mm, name, 1 /* ordinal */, 1 /* spaces */,
|
||||
G1MonitoringSupport::pad_capacity(0) /* min_capacity */,
|
||||
G1MonitoringSupport::pad_capacity(g1mm->old_gen_max()),
|
||||
G1MonitoringSupport::pad_capacity(0) /* curr_capacity */) {
|
||||
update_all();
|
||||
}
|
||||
|
||||
void G1YoungGenerationCounters::update_all() {
|
||||
size_t committed =
|
||||
G1MonitoringSupport::pad_capacity(_g1mm->young_gen_committed(), 3);
|
||||
_current_size->set_value(committed);
|
||||
}
|
||||
|
||||
void G1OldGenerationCounters::update_all() {
|
||||
size_t committed =
|
||||
G1MonitoringSupport::pad_capacity(_g1mm->old_gen_committed());
|
||||
_current_size->set_value(committed);
|
||||
}
|
||||
|
||||
G1MonitoringSupport::G1MonitoringSupport(G1CollectedHeap* g1h) :
|
||||
_g1h(g1h),
|
||||
_incremental_collection_counters(NULL),
|
||||
_full_collection_counters(NULL),
|
||||
_non_young_collection_counters(NULL),
|
||||
_old_collection_counters(NULL),
|
||||
_old_space_counters(NULL),
|
||||
_young_collection_counters(NULL),
|
||||
_eden_counters(NULL),
|
||||
_from_counters(NULL),
|
||||
_to_counters(NULL),
|
||||
_g1_storage_addr(g1_storage_addr)
|
||||
{
|
||||
|
||||
_overall_reserved(0),
|
||||
_overall_committed(0), _overall_used(0),
|
||||
_young_region_num(0),
|
||||
_young_gen_committed(0),
|
||||
_eden_committed(0), _eden_used(0),
|
||||
_survivor_committed(0), _survivor_used(0),
|
||||
_old_committed(0), _old_used(0) {
|
||||
|
||||
_overall_reserved = g1h->max_capacity();
|
||||
recalculate_sizes();
|
||||
|
||||
// Counters for GC collections
|
||||
//
|
||||
// name "collector.0". In a generational collector this would be the
|
||||
@ -69,110 +119,147 @@ G1MonitoringSupport::G1MonitoringSupport(G1CollectedHeap* g1h,
|
||||
// generational GC terms. The "1, 1" parameters are for
|
||||
// the n-th generation (=1) with 1 space.
|
||||
// Counters are created from minCapacity, maxCapacity, and capacity
|
||||
_non_young_collection_counters =
|
||||
new GenerationCounters("whole heap", 1, 1, _g1_storage_addr);
|
||||
_old_collection_counters = new G1OldGenerationCounters(this, "old");
|
||||
|
||||
// name "generation.1.space.0"
|
||||
// Counters are created from maxCapacity, capacity, initCapacity,
|
||||
// and used.
|
||||
_old_space_counters = new HSpaceCounters("space", 0,
|
||||
_g1h->max_capacity(), _g1h->capacity(), _non_young_collection_counters);
|
||||
_old_space_counters = new HSpaceCounters("space", 0 /* ordinal */,
|
||||
pad_capacity(overall_reserved()) /* max_capacity */,
|
||||
pad_capacity(old_space_committed()) /* init_capacity */,
|
||||
_old_collection_counters);
|
||||
|
||||
// Young collection set
|
||||
// name "generation.0". This is logically the young generation.
|
||||
// The "0, 3" are paremeters for the n-th genertaion (=0) with 3 spaces.
|
||||
// See _non_young_collection_counters for additional counters
|
||||
_young_collection_counters = new GenerationCounters("young", 0, 3, NULL);
|
||||
// See _old_collection_counters for additional counters
|
||||
_young_collection_counters = new G1YoungGenerationCounters(this, "young");
|
||||
|
||||
// Replace "max_heap_byte_size() with maximum young gen size for
|
||||
// g1Collectedheap
|
||||
// name "generation.0.space.0"
|
||||
// See _old_space_counters for additional counters
|
||||
_eden_counters = new HSpaceCounters("eden", 0,
|
||||
_g1h->max_capacity(), eden_space_committed(),
|
||||
_eden_counters = new HSpaceCounters("eden", 0 /* ordinal */,
|
||||
pad_capacity(overall_reserved()) /* max_capacity */,
|
||||
pad_capacity(eden_space_committed()) /* init_capacity */,
|
||||
_young_collection_counters);
|
||||
|
||||
// name "generation.0.space.1"
|
||||
// See _old_space_counters for additional counters
|
||||
// Set the arguments to indicate that this survivor space is not used.
|
||||
_from_counters = new HSpaceCounters("s0", 1, (long) 0, (long) 0,
|
||||
_from_counters = new HSpaceCounters("s0", 1 /* ordinal */,
|
||||
pad_capacity(0) /* max_capacity */,
|
||||
pad_capacity(0) /* init_capacity */,
|
||||
_young_collection_counters);
|
||||
// Given that this survivor space is not used, we update it here
|
||||
// once to reflect that its used space is 0 so that we don't have to
|
||||
// worry about updating it again later.
|
||||
_from_counters->update_used(0);
|
||||
|
||||
// name "generation.0.space.2"
|
||||
// See _old_space_counters for additional counters
|
||||
_to_counters = new HSpaceCounters("s1", 2,
|
||||
_g1h->max_capacity(),
|
||||
survivor_space_committed(),
|
||||
_to_counters = new HSpaceCounters("s1", 2 /* ordinal */,
|
||||
pad_capacity(overall_reserved()) /* max_capacity */,
|
||||
pad_capacity(survivor_space_committed()) /* init_capacity */,
|
||||
_young_collection_counters);
|
||||
}
|
||||
|
||||
size_t G1MonitoringSupport::overall_committed() {
|
||||
return g1h()->capacity();
|
||||
void G1MonitoringSupport::recalculate_sizes() {
|
||||
G1CollectedHeap* g1 = g1h();
|
||||
|
||||
// Recalculate all the sizes from scratch. We assume that this is
|
||||
// called at a point where no concurrent updates to the various
|
||||
// values we read here are possible (i.e., at a STW phase at the end
|
||||
// of a GC).
|
||||
|
||||
size_t young_list_length = g1->young_list()->length();
|
||||
size_t survivor_list_length = g1->g1_policy()->recorded_survivor_regions();
|
||||
assert(young_list_length >= survivor_list_length, "invariant");
|
||||
size_t eden_list_length = young_list_length - survivor_list_length;
|
||||
// Max length includes any potential extensions to the young gen
|
||||
// we'll do when the GC locker is active.
|
||||
size_t young_list_max_length = g1->g1_policy()->young_list_max_length();
|
||||
assert(young_list_max_length >= survivor_list_length, "invariant");
|
||||
size_t eden_list_max_length = young_list_max_length - survivor_list_length;
|
||||
|
||||
_overall_used = g1->used_unlocked();
|
||||
_eden_used = eden_list_length * HeapRegion::GrainBytes;
|
||||
_survivor_used = survivor_list_length * HeapRegion::GrainBytes;
|
||||
_young_region_num = young_list_length;
|
||||
_old_used = subtract_up_to_zero(_overall_used, _eden_used + _survivor_used);
|
||||
|
||||
// First calculate the committed sizes that can be calculated independently.
|
||||
_survivor_committed = _survivor_used;
|
||||
_old_committed = HeapRegion::align_up_to_region_byte_size(_old_used);
|
||||
|
||||
// Next, start with the overall committed size.
|
||||
_overall_committed = g1->capacity();
|
||||
size_t committed = _overall_committed;
|
||||
|
||||
// Remove the committed size we have calculated so far (for the
|
||||
// survivor and old space).
|
||||
assert(committed >= (_survivor_committed + _old_committed), "sanity");
|
||||
committed -= _survivor_committed + _old_committed;
|
||||
|
||||
// Next, calculate and remove the committed size for the eden.
|
||||
_eden_committed = eden_list_max_length * HeapRegion::GrainBytes;
|
||||
// Somewhat defensive: be robust in case there are inaccuracies in
|
||||
// the calculations
|
||||
_eden_committed = MIN2(_eden_committed, committed);
|
||||
committed -= _eden_committed;
|
||||
|
||||
// Finally, give the rest to the old space...
|
||||
_old_committed += committed;
|
||||
// ..and calculate the young gen committed.
|
||||
_young_gen_committed = _eden_committed + _survivor_committed;
|
||||
|
||||
assert(_overall_committed ==
|
||||
(_eden_committed + _survivor_committed + _old_committed),
|
||||
"the committed sizes should add up");
|
||||
// Somewhat defensive: cap the eden used size to make sure it
|
||||
// never exceeds the committed size.
|
||||
_eden_used = MIN2(_eden_used, _eden_committed);
|
||||
// _survivor_committed and _old_committed are calculated in terms of
|
||||
// the corresponding _*_used value, so the next two conditions
|
||||
// should hold.
|
||||
assert(_survivor_used <= _survivor_committed, "post-condition");
|
||||
assert(_old_used <= _old_committed, "post-condition");
|
||||
}
|
||||
|
||||
size_t G1MonitoringSupport::overall_used() {
|
||||
return g1h()->used_unlocked();
|
||||
void G1MonitoringSupport::recalculate_eden_size() {
|
||||
G1CollectedHeap* g1 = g1h();
|
||||
|
||||
// When a new eden region is allocated, only the eden_used size is
|
||||
// affected (since we have recalculated everything else at the last GC).
|
||||
|
||||
size_t young_region_num = g1h()->young_list()->length();
|
||||
if (young_region_num > _young_region_num) {
|
||||
size_t diff = young_region_num - _young_region_num;
|
||||
_eden_used += diff * HeapRegion::GrainBytes;
|
||||
// Somewhat defensive: cap the eden used size to make sure it
|
||||
// never exceeds the committed size.
|
||||
_eden_used = MIN2(_eden_used, _eden_committed);
|
||||
_young_region_num = young_region_num;
|
||||
}
|
||||
}
|
||||
|
||||
size_t G1MonitoringSupport::eden_space_committed() {
|
||||
return MAX2(eden_space_used(), (size_t) HeapRegion::GrainBytes);
|
||||
}
|
||||
|
||||
size_t G1MonitoringSupport::eden_space_used() {
|
||||
size_t young_list_length = g1h()->young_list()->length();
|
||||
size_t eden_used = young_list_length * HeapRegion::GrainBytes;
|
||||
size_t survivor_used = survivor_space_used();
|
||||
eden_used = subtract_up_to_zero(eden_used, survivor_used);
|
||||
return eden_used;
|
||||
}
|
||||
|
||||
size_t G1MonitoringSupport::survivor_space_committed() {
|
||||
return MAX2(survivor_space_used(),
|
||||
(size_t) HeapRegion::GrainBytes);
|
||||
}
|
||||
|
||||
size_t G1MonitoringSupport::survivor_space_used() {
|
||||
size_t survivor_num = g1h()->g1_policy()->recorded_survivor_regions();
|
||||
size_t survivor_used = survivor_num * HeapRegion::GrainBytes;
|
||||
return survivor_used;
|
||||
}
|
||||
|
||||
size_t G1MonitoringSupport::old_space_committed() {
|
||||
size_t committed = overall_committed();
|
||||
size_t eden_committed = eden_space_committed();
|
||||
size_t survivor_committed = survivor_space_committed();
|
||||
committed = subtract_up_to_zero(committed, eden_committed);
|
||||
committed = subtract_up_to_zero(committed, survivor_committed);
|
||||
committed = MAX2(committed, (size_t) HeapRegion::GrainBytes);
|
||||
return committed;
|
||||
}
|
||||
|
||||
// See the comment near the top of g1MonitoringSupport.hpp for
|
||||
// an explanation of these calculations for "used" and "capacity".
|
||||
size_t G1MonitoringSupport::old_space_used() {
|
||||
size_t used = overall_used();
|
||||
size_t eden_used = eden_space_used();
|
||||
size_t survivor_used = survivor_space_used();
|
||||
used = subtract_up_to_zero(used, eden_used);
|
||||
used = subtract_up_to_zero(used, survivor_used);
|
||||
return used;
|
||||
}
|
||||
|
||||
void G1MonitoringSupport::update_counters() {
|
||||
void G1MonitoringSupport::update_sizes() {
|
||||
recalculate_sizes();
|
||||
if (UsePerfData) {
|
||||
eden_counters()->update_capacity(eden_space_committed());
|
||||
eden_counters()->update_capacity(pad_capacity(eden_space_committed()));
|
||||
eden_counters()->update_used(eden_space_used());
|
||||
to_counters()->update_capacity(survivor_space_committed());
|
||||
// only the to survivor space (s1) is active, so we don't need to
|
||||
// update the counteres for the from survivor space (s0)
|
||||
to_counters()->update_capacity(pad_capacity(survivor_space_committed()));
|
||||
to_counters()->update_used(survivor_space_used());
|
||||
old_space_counters()->update_capacity(old_space_committed());
|
||||
old_space_counters()->update_capacity(pad_capacity(old_space_committed()));
|
||||
old_space_counters()->update_used(old_space_used());
|
||||
non_young_collection_counters()->update_all();
|
||||
old_collection_counters()->update_all();
|
||||
young_collection_counters()->update_all();
|
||||
}
|
||||
}
|
||||
|
||||
void G1MonitoringSupport::update_eden_counters() {
|
||||
void G1MonitoringSupport::update_eden_size() {
|
||||
recalculate_eden_size();
|
||||
if (UsePerfData) {
|
||||
eden_counters()->update_capacity(eden_space_committed());
|
||||
eden_counters()->update_used(eden_space_used());
|
||||
}
|
||||
}
|
||||
|
@ -28,101 +28,95 @@
|
||||
#include "gc_implementation/shared/hSpaceCounters.hpp"
|
||||
|
||||
class G1CollectedHeap;
|
||||
class G1SpaceMonitoringSupport;
|
||||
|
||||
// Class for monitoring logical spaces in G1.
|
||||
// G1 defines a set of regions as a young
|
||||
// collection (analogous to a young generation).
|
||||
// The young collection is a logical generation
|
||||
// with no fixed chunk (see space.hpp) reflecting
|
||||
// the address space for the generation. In addition
|
||||
// to the young collection there is its complement
|
||||
// the non-young collection that is simply the regions
|
||||
// not in the young collection. The non-young collection
|
||||
// is treated here as a logical old generation only
|
||||
// because the monitoring tools expect a generational
|
||||
// heap. The monitoring tools expect that a Space
|
||||
// (see space.hpp) exists that describe the
|
||||
// address space of young collection and non-young
|
||||
// collection and such a view is provided here.
|
||||
// Class for monitoring logical spaces in G1. It provides data for
|
||||
// both G1's jstat counters as well as G1's memory pools.
|
||||
//
|
||||
// This class provides interfaces to access
|
||||
// the value of variables for the young collection
|
||||
// that include the "capacity" and "used" of the
|
||||
// young collection along with constant values
|
||||
// for the minimum and maximum capacities for
|
||||
// the logical spaces. Similarly for the non-young
|
||||
// collection.
|
||||
// G1 splits the heap into heap regions and each heap region belongs
|
||||
// to one of the following categories:
|
||||
//
|
||||
// Also provided are counters for G1 concurrent collections
|
||||
// and stop-the-world full heap collecitons.
|
||||
// * eden : regions that have been allocated since the last GC
|
||||
// * survivors : regions with objects that survived the last few GCs
|
||||
// * old : long-lived non-humongous regions
|
||||
// * humongous : humongous regions
|
||||
// * free : free regions
|
||||
//
|
||||
// Below is a description of how "used" and "capactiy"
|
||||
// (or committed) is calculated for the logical spaces.
|
||||
// The combination of eden and survivor regions form the equivalent of
|
||||
// the young generation in the other GCs. The combination of old and
|
||||
// humongous regions form the equivalent of the old generation in the
|
||||
// other GCs. Free regions do not have a good equivalent in the other
|
||||
// GCs given that they can be allocated as any of the other region types.
|
||||
//
|
||||
// 1) The used space calculation for a pool is not necessarily
|
||||
// independent of the others. We can easily get from G1 the overall
|
||||
// used space in the entire heap, the number of regions in the young
|
||||
// generation (includes both eden and survivors), and the number of
|
||||
// survivor regions. So, from that we calculate:
|
||||
// The monitoring tools expect the heap to contain a number of
|
||||
// generations (young, old, perm) and each generation to contain a
|
||||
// number of spaces (young: eden, survivors, old). Given that G1 does
|
||||
// not maintain those spaces physically (e.g., the set of
|
||||
// non-contiguous eden regions can be considered as a "logical"
|
||||
// space), we'll provide the illusion that those generations and
|
||||
// spaces exist. In reality, each generation and space refers to a set
|
||||
// of heap regions that are potentially non-contiguous.
|
||||
//
|
||||
// survivor_used = survivor_num * region_size
|
||||
// eden_used = young_region_num * region_size - survivor_used
|
||||
// old_gen_used = overall_used - eden_used - survivor_used
|
||||
// This class provides interfaces to access the min, current, and max
|
||||
// capacity and current occupancy for each of G1's logical spaces and
|
||||
// generations we expose to the monitoring tools. Also provided are
|
||||
// counters for G1 concurrent collections and stop-the-world full heap
|
||||
// collections.
|
||||
//
|
||||
// Note that survivor_used and eden_used are upper bounds. To get the
|
||||
// actual value we would have to iterate over the regions and add up
|
||||
// ->used(). But that'd be expensive. So, we'll accept some lack of
|
||||
// accuracy for those two. But, we have to be careful when calculating
|
||||
// old_gen_used, in case we subtract from overall_used more then the
|
||||
// actual number and our result goes negative.
|
||||
// Below is a description of how the various sizes are calculated.
|
||||
//
|
||||
// 2) Calculating the used space is straightforward, as described
|
||||
// above. However, how do we calculate the committed space, given that
|
||||
// we allocate space for the eden, survivor, and old gen out of the
|
||||
// same pool of regions? One way to do this is to use the used value
|
||||
// as also the committed value for the eden and survivor spaces and
|
||||
// then calculate the old gen committed space as follows:
|
||||
// * Current Capacity
|
||||
//
|
||||
// old_gen_committed = overall_committed - eden_committed - survivor_committed
|
||||
// - heap_capacity = current heap capacity (e.g., current committed size)
|
||||
// - young_gen_capacity = current max young gen target capacity
|
||||
// (i.e., young gen target capacity + max allowed expansion capacity)
|
||||
// - survivor_capacity = current survivor region capacity
|
||||
// - eden_capacity = young_gen_capacity - survivor_capacity
|
||||
// - old_capacity = heap_capacity - young_gen_capacity
|
||||
//
|
||||
// Maybe a better way to do that would be to calculate used for eden
|
||||
// and survivor as a sum of ->used() over their regions and then
|
||||
// calculate committed as region_num * region_size (i.e., what we use
|
||||
// to calculate the used space now). This is something to consider
|
||||
// in the future.
|
||||
// What we do in the above is to distribute the free regions among
|
||||
// eden_capacity and old_capacity.
|
||||
//
|
||||
// 3) Another decision that is again not straightforward is what is
|
||||
// the max size that each memory pool can grow to. One way to do this
|
||||
// would be to use the committed size for the max for the eden and
|
||||
// survivors and calculate the old gen max as follows (basically, it's
|
||||
// a similar pattern to what we use for the committed space, as
|
||||
// described above):
|
||||
// * Occupancy
|
||||
//
|
||||
// old_gen_max = overall_max - eden_max - survivor_max
|
||||
// - young_gen_used = current young region capacity
|
||||
// - survivor_used = survivor_capacity
|
||||
// - eden_used = young_gen_used - survivor_used
|
||||
// - old_used = overall_used - young_gen_used
|
||||
//
|
||||
// Unfortunately, the above makes the max of each pool fluctuate over
|
||||
// time and, even though this is allowed according to the spec, it
|
||||
// broke several assumptions in the M&M framework (there were cases
|
||||
// where used would reach a value greater than max). So, for max we
|
||||
// use -1, which means "undefined" according to the spec.
|
||||
// Unfortunately, we currently only keep track of the number of
|
||||
// currently allocated young and survivor regions + the overall used
|
||||
// bytes in the heap, so the above can be a little inaccurate.
|
||||
//
|
||||
// 4) Now, there is a very subtle issue with all the above. The
|
||||
// framework will call get_memory_usage() on the three pools
|
||||
// asynchronously. As a result, each call might get a different value
|
||||
// for, say, survivor_num which will yield inconsistent values for
|
||||
// eden_used, survivor_used, and old_gen_used (as survivor_num is used
|
||||
// in the calculation of all three). This would normally be
|
||||
// ok. However, it's possible that this might cause the sum of
|
||||
// eden_used, survivor_used, and old_gen_used to go over the max heap
|
||||
// size and this seems to sometimes cause JConsole (and maybe other
|
||||
// clients) to get confused. There's not a really an easy / clean
|
||||
// solution to this problem, due to the asynchrounous nature of the
|
||||
// framework.
|
||||
// * Min Capacity
|
||||
//
|
||||
// We set this to 0 for all spaces. We could consider setting the old
|
||||
// min capacity to the min capacity of the heap (see 7078465).
|
||||
//
|
||||
// * Max Capacity
|
||||
//
|
||||
// For jstat, we set the max capacity of all spaces to heap_capacity,
|
||||
// given that we don't always have a reasonably upper bound on how big
|
||||
// each space can grow. For the memory pools, we actually make the max
|
||||
// capacity undefined. We could consider setting the old max capacity
|
||||
// to the max capacity of the heap (see 7078465).
|
||||
//
|
||||
// If we had more accurate occupancy / capacity information per
|
||||
// region set the above calculations would be greatly simplified and
|
||||
// be made more accurate.
|
||||
//
|
||||
// We update all the above synchronously and we store the results in
|
||||
// fields so that we just read said fields when needed. A subtle point
|
||||
// is that all the above sizes need to be recalculated when the old
|
||||
// gen changes capacity (after a GC or after a humongous allocation)
|
||||
// but only the eden occupancy changes when a new eden region is
|
||||
// allocated. So, in the latter case we have minimal recalcuation to
|
||||
// do which is important as we want to keep the eden region allocation
|
||||
// path as low-overhead as possible.
|
||||
|
||||
class G1MonitoringSupport : public CHeapObj {
|
||||
friend class VMStructs;
|
||||
|
||||
G1CollectedHeap* _g1h;
|
||||
VirtualSpace* _g1_storage_addr;
|
||||
|
||||
// jstat performance counters
|
||||
// incremental collections both fully and partially young
|
||||
@ -133,9 +127,9 @@ class G1MonitoringSupport : public CHeapObj {
|
||||
// _from_counters, and _to_counters are associated with
|
||||
// this "generational" counter.
|
||||
GenerationCounters* _young_collection_counters;
|
||||
// non-young collection set counters. The _old_space_counters
|
||||
// old collection set counters. The _old_space_counters
|
||||
// below are associated with this "generational" counter.
|
||||
GenerationCounters* _non_young_collection_counters;
|
||||
GenerationCounters* _old_collection_counters;
|
||||
// Counters for the capacity and used for
|
||||
// the whole heap
|
||||
HSpaceCounters* _old_space_counters;
|
||||
@ -145,6 +139,27 @@ class G1MonitoringSupport : public CHeapObj {
|
||||
HSpaceCounters* _from_counters;
|
||||
HSpaceCounters* _to_counters;
|
||||
|
||||
// When it's appropriate to recalculate the various sizes (at the
|
||||
// end of a GC, when a new eden region is allocated, etc.) we store
|
||||
// them here so that we can easily report them when needed and not
|
||||
// have to recalculate them every time.
|
||||
|
||||
size_t _overall_reserved;
|
||||
size_t _overall_committed;
|
||||
size_t _overall_used;
|
||||
|
||||
size_t _young_region_num;
|
||||
size_t _young_gen_committed;
|
||||
size_t _eden_committed;
|
||||
size_t _eden_used;
|
||||
size_t _survivor_committed;
|
||||
size_t _survivor_used;
|
||||
|
||||
size_t _old_committed;
|
||||
size_t _old_used;
|
||||
|
||||
G1CollectedHeap* g1h() { return _g1h; }
|
||||
|
||||
// It returns x - y if x > y, 0 otherwise.
|
||||
// As described in the comment above, some of the inputs to the
|
||||
// calculations we have to do are obtained concurrently and hence
|
||||
@ -160,15 +175,35 @@ class G1MonitoringSupport : public CHeapObj {
|
||||
}
|
||||
}
|
||||
|
||||
// Recalculate all the sizes.
|
||||
void recalculate_sizes();
|
||||
// Recalculate only what's necessary when a new eden region is allocated.
|
||||
void recalculate_eden_size();
|
||||
|
||||
public:
|
||||
G1MonitoringSupport(G1CollectedHeap* g1h, VirtualSpace* g1_storage_addr);
|
||||
G1MonitoringSupport(G1CollectedHeap* g1h);
|
||||
|
||||
G1CollectedHeap* g1h() { return _g1h; }
|
||||
VirtualSpace* g1_storage_addr() { return _g1_storage_addr; }
|
||||
// Unfortunately, the jstat tool assumes that no space has 0
|
||||
// capacity. In our case, given that each space is logical, it's
|
||||
// possible that no regions will be allocated to it, hence to have 0
|
||||
// capacity (e.g., if there are no survivor regions, the survivor
|
||||
// space has 0 capacity). The way we deal with this is to always pad
|
||||
// each capacity value we report to jstat by a very small amount to
|
||||
// make sure that it's never zero. Given that we sometimes have to
|
||||
// report a capacity of a generation that contains several spaces
|
||||
// (e.g., young gen includes one eden, two survivor spaces), the
|
||||
// mult parameter is provided in order to adding the appropriate
|
||||
// padding multiple times so that the capacities add up correctly.
|
||||
static size_t pad_capacity(size_t size_bytes, size_t mult = 1) {
|
||||
return size_bytes + MinObjAlignmentInBytes * mult;
|
||||
}
|
||||
|
||||
// Performance Counter accessors
|
||||
void update_counters();
|
||||
void update_eden_counters();
|
||||
// Recalculate all the sizes from scratch and update all the jstat
|
||||
// counters accordingly.
|
||||
void update_sizes();
|
||||
// Recalculate only what's necessary when a new eden region is
|
||||
// allocated and update any jstat counters that need to be updated.
|
||||
void update_eden_size();
|
||||
|
||||
CollectorCounters* incremental_collection_counters() {
|
||||
return _incremental_collection_counters;
|
||||
@ -176,8 +211,11 @@ class G1MonitoringSupport : public CHeapObj {
|
||||
CollectorCounters* full_collection_counters() {
|
||||
return _full_collection_counters;
|
||||
}
|
||||
GenerationCounters* non_young_collection_counters() {
|
||||
return _non_young_collection_counters;
|
||||
GenerationCounters* young_collection_counters() {
|
||||
return _young_collection_counters;
|
||||
}
|
||||
GenerationCounters* old_collection_counters() {
|
||||
return _old_collection_counters;
|
||||
}
|
||||
HSpaceCounters* old_space_counters() { return _old_space_counters; }
|
||||
HSpaceCounters* eden_counters() { return _eden_counters; }
|
||||
@ -187,17 +225,45 @@ class G1MonitoringSupport : public CHeapObj {
|
||||
// Monitoring support used by
|
||||
// MemoryService
|
||||
// jstat counters
|
||||
size_t overall_committed();
|
||||
size_t overall_used();
|
||||
|
||||
size_t eden_space_committed();
|
||||
size_t eden_space_used();
|
||||
size_t overall_reserved() { return _overall_reserved; }
|
||||
size_t overall_committed() { return _overall_committed; }
|
||||
size_t overall_used() { return _overall_used; }
|
||||
|
||||
size_t survivor_space_committed();
|
||||
size_t survivor_space_used();
|
||||
size_t young_gen_committed() { return _young_gen_committed; }
|
||||
size_t young_gen_max() { return overall_reserved(); }
|
||||
size_t eden_space_committed() { return _eden_committed; }
|
||||
size_t eden_space_used() { return _eden_used; }
|
||||
size_t survivor_space_committed() { return _survivor_committed; }
|
||||
size_t survivor_space_used() { return _survivor_used; }
|
||||
|
||||
size_t old_space_committed();
|
||||
size_t old_space_used();
|
||||
size_t old_gen_committed() { return old_space_committed(); }
|
||||
size_t old_gen_max() { return overall_reserved(); }
|
||||
size_t old_space_committed() { return _old_committed; }
|
||||
size_t old_space_used() { return _old_used; }
|
||||
};
|
||||
|
||||
class G1GenerationCounters: public GenerationCounters {
|
||||
protected:
|
||||
G1MonitoringSupport* _g1mm;
|
||||
|
||||
public:
|
||||
G1GenerationCounters(G1MonitoringSupport* g1mm,
|
||||
const char* name, int ordinal, int spaces,
|
||||
size_t min_capacity, size_t max_capacity,
|
||||
size_t curr_capacity);
|
||||
};
|
||||
|
||||
class G1YoungGenerationCounters: public G1GenerationCounters {
|
||||
public:
|
||||
G1YoungGenerationCounters(G1MonitoringSupport* g1mm, const char* name);
|
||||
virtual void update_all();
|
||||
};
|
||||
|
||||
class G1OldGenerationCounters: public G1GenerationCounters {
|
||||
public:
|
||||
G1OldGenerationCounters(G1MonitoringSupport* g1mm, const char* name);
|
||||
virtual void update_all();
|
||||
};
|
||||
|
||||
#endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1MONITORINGSUPPORT_HPP
|
||||
|
@ -34,6 +34,7 @@ class CMBitMap;
|
||||
class CMMarkStack;
|
||||
class G1ParScanThreadState;
|
||||
class CMTask;
|
||||
class ReferenceProcessor;
|
||||
|
||||
// A class that scans oops in a given heap region (much as OopsInGenClosure
|
||||
// scans oops in a generation.)
|
||||
@ -59,8 +60,10 @@ public:
|
||||
|
||||
class G1ParPushHeapRSClosure : public G1ParClosureSuper {
|
||||
public:
|
||||
G1ParPushHeapRSClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) :
|
||||
G1ParPushHeapRSClosure(G1CollectedHeap* g1,
|
||||
G1ParScanThreadState* par_scan_state):
|
||||
G1ParClosureSuper(g1, par_scan_state) { }
|
||||
|
||||
template <class T> void do_oop_nv(T* p);
|
||||
virtual void do_oop(oop* p) { do_oop_nv(p); }
|
||||
virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
|
||||
@ -68,8 +71,13 @@ public:
|
||||
|
||||
class G1ParScanClosure : public G1ParClosureSuper {
|
||||
public:
|
||||
G1ParScanClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) :
|
||||
G1ParClosureSuper(g1, par_scan_state) { }
|
||||
G1ParScanClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state, ReferenceProcessor* rp) :
|
||||
G1ParClosureSuper(g1, par_scan_state)
|
||||
{
|
||||
assert(_ref_processor == NULL, "sanity");
|
||||
_ref_processor = rp;
|
||||
}
|
||||
|
||||
template <class T> void do_oop_nv(T* p);
|
||||
virtual void do_oop(oop* p) { do_oop_nv(p); }
|
||||
virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
|
||||
@ -92,9 +100,18 @@ template <class T> inline oop clear_partial_array_mask(T* ref) {
|
||||
|
||||
class G1ParScanPartialArrayClosure : public G1ParClosureSuper {
|
||||
G1ParScanClosure _scanner;
|
||||
|
||||
public:
|
||||
G1ParScanPartialArrayClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) :
|
||||
G1ParClosureSuper(g1, par_scan_state), _scanner(g1, par_scan_state) { }
|
||||
G1ParScanPartialArrayClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state, ReferenceProcessor* rp) :
|
||||
G1ParClosureSuper(g1, par_scan_state), _scanner(g1, par_scan_state, rp)
|
||||
{
|
||||
assert(_ref_processor == NULL, "sanity");
|
||||
}
|
||||
|
||||
G1ParScanClosure* scanner() {
|
||||
return &_scanner;
|
||||
}
|
||||
|
||||
template <class T> void do_oop_nv(T* p);
|
||||
virtual void do_oop(oop* p) { do_oop_nv(p); }
|
||||
virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
|
||||
@ -105,7 +122,8 @@ class G1ParCopyHelper : public G1ParClosureSuper {
|
||||
G1ParScanClosure *_scanner;
|
||||
protected:
|
||||
template <class T> void mark_object(T* p);
|
||||
oop copy_to_survivor_space(oop obj, bool should_mark_copy);
|
||||
oop copy_to_survivor_space(oop obj, bool should_mark_root,
|
||||
bool should_mark_copy);
|
||||
public:
|
||||
G1ParCopyHelper(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state,
|
||||
G1ParScanClosure *scanner) :
|
||||
@ -116,10 +134,20 @@ template<bool do_gen_barrier, G1Barrier barrier,
|
||||
bool do_mark_object>
|
||||
class G1ParCopyClosure : public G1ParCopyHelper {
|
||||
G1ParScanClosure _scanner;
|
||||
|
||||
template <class T> void do_oop_work(T* p);
|
||||
|
||||
public:
|
||||
G1ParCopyClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state) :
|
||||
_scanner(g1, par_scan_state), G1ParCopyHelper(g1, par_scan_state, &_scanner) { }
|
||||
G1ParCopyClosure(G1CollectedHeap* g1, G1ParScanThreadState* par_scan_state,
|
||||
ReferenceProcessor* rp) :
|
||||
_scanner(g1, par_scan_state, rp),
|
||||
G1ParCopyHelper(g1, par_scan_state, &_scanner)
|
||||
{
|
||||
assert(_ref_processor == NULL, "sanity");
|
||||
}
|
||||
|
||||
G1ParScanClosure* scanner() { return &_scanner; }
|
||||
|
||||
template <class T> void do_oop_nv(T* p) {
|
||||
do_oop_work(p);
|
||||
}
|
||||
@ -129,21 +157,25 @@ public:
|
||||
|
||||
typedef G1ParCopyClosure<false, G1BarrierNone, false> G1ParScanExtRootClosure;
|
||||
typedef G1ParCopyClosure<true, G1BarrierNone, false> G1ParScanPermClosure;
|
||||
typedef G1ParCopyClosure<false, G1BarrierRS, false> G1ParScanHeapRSClosure;
|
||||
|
||||
typedef G1ParCopyClosure<false, G1BarrierNone, true> G1ParScanAndMarkExtRootClosure;
|
||||
typedef G1ParCopyClosure<true, G1BarrierNone, true> G1ParScanAndMarkPermClosure;
|
||||
typedef G1ParCopyClosure<false, G1BarrierRS, true> G1ParScanAndMarkHeapRSClosure;
|
||||
|
||||
// This is the only case when we set skip_cset_test. Basically, this
|
||||
// closure is (should?) only be called directly while we're draining
|
||||
// the overflow and task queues. In that case we know that the
|
||||
// reference in question points into the collection set, otherwise we
|
||||
// would not have pushed it on the queue. The following is defined in
|
||||
// g1_specialized_oop_closures.hpp.
|
||||
// typedef G1ParCopyClosure<false, G1BarrierEvac, false, true> G1ParScanHeapEvacClosure;
|
||||
// We need a separate closure to handle references during evacuation
|
||||
// failure processing, as we cannot asume that the reference already
|
||||
// points into the collection set (like G1ParScanHeapEvacClosure does).
|
||||
// The following closure types are no longer used but are retained
|
||||
// for historical reasons:
|
||||
// typedef G1ParCopyClosure<false, G1BarrierRS, false> G1ParScanHeapRSClosure;
|
||||
// typedef G1ParCopyClosure<false, G1BarrierRS, true> G1ParScanAndMarkHeapRSClosure;
|
||||
|
||||
// The following closure type is defined in g1_specialized_oop_closures.hpp:
|
||||
//
|
||||
// typedef G1ParCopyClosure<false, G1BarrierEvac, false> G1ParScanHeapEvacClosure;
|
||||
|
||||
// We use a separate closure to handle references during evacuation
|
||||
// failure processing.
|
||||
// We could have used another instance of G1ParScanHeapEvacClosure
|
||||
// (since that closure no longer assumes that the references it
|
||||
// handles point into the collection set).
|
||||
|
||||
typedef G1ParCopyClosure<false, G1BarrierEvac, false> G1ParScanHeapEvacFailureClosure;
|
||||
|
||||
class FilterIntoCSClosure: public OopClosure {
|
||||
@ -152,9 +184,10 @@ class FilterIntoCSClosure: public OopClosure {
|
||||
DirtyCardToOopClosure* _dcto_cl;
|
||||
public:
|
||||
FilterIntoCSClosure( DirtyCardToOopClosure* dcto_cl,
|
||||
G1CollectedHeap* g1, OopClosure* oc) :
|
||||
_dcto_cl(dcto_cl), _g1(g1), _oc(oc)
|
||||
{}
|
||||
G1CollectedHeap* g1,
|
||||
OopClosure* oc) :
|
||||
_dcto_cl(dcto_cl), _g1(g1), _oc(oc) { }
|
||||
|
||||
template <class T> void do_oop_nv(T* p);
|
||||
virtual void do_oop(oop* p) { do_oop_nv(p); }
|
||||
virtual void do_oop(narrowOop* p) { do_oop_nv(p); }
|
||||
|
@ -234,6 +234,7 @@ void G1RemSet::scanRS(OopsInHeapRegionClosure* oc, int worker_i) {
|
||||
HeapRegion *startRegion = calculateStartRegion(worker_i);
|
||||
|
||||
ScanRSClosure scanRScl(oc, worker_i);
|
||||
|
||||
_g1->collection_set_iterate_from(startRegion, &scanRScl);
|
||||
scanRScl.set_try_claimed();
|
||||
_g1->collection_set_iterate_from(startRegion, &scanRScl);
|
||||
@ -283,6 +284,7 @@ void G1RemSet::updateRS(DirtyCardQueue* into_cset_dcq, int worker_i) {
|
||||
double start = os::elapsedTime();
|
||||
// Apply the given closure to all remaining log entries.
|
||||
RefineRecordRefsIntoCSCardTableEntryClosure into_cset_update_rs_cl(_g1, into_cset_dcq);
|
||||
|
||||
_g1->iterate_dirty_card_closure(&into_cset_update_rs_cl, into_cset_dcq, false, worker_i);
|
||||
|
||||
// Now there should be no dirty cards.
|
||||
|
@ -290,10 +290,6 @@
|
||||
"each evacuation pause in order to artificially fill up the " \
|
||||
"heap and stress the marking implementation.") \
|
||||
\
|
||||
develop(bool, ReduceInitialCardMarksForG1, false, \
|
||||
"When ReduceInitialCardMarks is true, this flag setting " \
|
||||
" controls whether G1 allows the RICM optimization") \
|
||||
\
|
||||
develop(bool, G1ExitOnExpansionFailure, false, \
|
||||
"Raise a fatal VM exit out of memory failure in the event " \
|
||||
" that heap expansion fails due to running out of swap.") \
|
||||
|
@ -33,11 +33,11 @@
|
||||
#include "memory/iterator.hpp"
|
||||
#include "oops/oop.inline.hpp"
|
||||
|
||||
int HeapRegion::LogOfHRGrainBytes = 0;
|
||||
int HeapRegion::LogOfHRGrainWords = 0;
|
||||
int HeapRegion::GrainBytes = 0;
|
||||
int HeapRegion::GrainWords = 0;
|
||||
int HeapRegion::CardsPerRegion = 0;
|
||||
int HeapRegion::LogOfHRGrainBytes = 0;
|
||||
int HeapRegion::LogOfHRGrainWords = 0;
|
||||
size_t HeapRegion::GrainBytes = 0;
|
||||
size_t HeapRegion::GrainWords = 0;
|
||||
size_t HeapRegion::CardsPerRegion = 0;
|
||||
|
||||
HeapRegionDCTOC::HeapRegionDCTOC(G1CollectedHeap* g1,
|
||||
HeapRegion* hr, OopClosure* cl,
|
||||
@ -45,7 +45,7 @@ HeapRegionDCTOC::HeapRegionDCTOC(G1CollectedHeap* g1,
|
||||
FilterKind fk) :
|
||||
ContiguousSpaceDCTOC(hr, cl, precision, NULL),
|
||||
_hr(hr), _fk(fk), _g1(g1)
|
||||
{}
|
||||
{ }
|
||||
|
||||
FilterOutOfRegionClosure::FilterOutOfRegionClosure(HeapRegion* r,
|
||||
OopClosure* oc) :
|
||||
@ -210,15 +210,17 @@ void HeapRegionDCTOC::walk_mem_region_with_cl(MemRegion mr,
|
||||
HeapWord* top,
|
||||
OopClosure* cl) {
|
||||
G1CollectedHeap* g1h = _g1;
|
||||
|
||||
int oop_size;
|
||||
OopClosure* cl2 = NULL;
|
||||
|
||||
OopClosure* cl2 = cl;
|
||||
FilterIntoCSClosure intoCSFilt(this, g1h, cl);
|
||||
FilterOutOfRegionClosure outOfRegionFilt(_hr, cl);
|
||||
|
||||
switch (_fk) {
|
||||
case NoFilterKind: cl2 = cl; break;
|
||||
case IntoCSFilterKind: cl2 = &intoCSFilt; break;
|
||||
case OutOfRegionFilterKind: cl2 = &outOfRegionFilt; break;
|
||||
default: ShouldNotReachHere();
|
||||
}
|
||||
|
||||
// Start filtering what we add to the remembered set. If the object is
|
||||
@ -239,16 +241,19 @@ void HeapRegionDCTOC::walk_mem_region_with_cl(MemRegion mr,
|
||||
case NoFilterKind:
|
||||
bottom = walk_mem_region_loop(cl, g1h, _hr, bottom, top);
|
||||
break;
|
||||
|
||||
case IntoCSFilterKind: {
|
||||
FilterIntoCSClosure filt(this, g1h, cl);
|
||||
bottom = walk_mem_region_loop(&filt, g1h, _hr, bottom, top);
|
||||
break;
|
||||
}
|
||||
|
||||
case OutOfRegionFilterKind: {
|
||||
FilterOutOfRegionClosure filt(_hr, cl);
|
||||
bottom = walk_mem_region_loop(&filt, g1h, _hr, bottom, top);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
ShouldNotReachHere();
|
||||
}
|
||||
@ -317,11 +322,11 @@ void HeapRegion::setup_heap_region_size(uintx min_heap_size) {
|
||||
guarantee(GrainBytes == 0, "we should only set it once");
|
||||
// The cast to int is safe, given that we've bounded region_size by
|
||||
// MIN_REGION_SIZE and MAX_REGION_SIZE.
|
||||
GrainBytes = (int) region_size;
|
||||
GrainBytes = (size_t)region_size;
|
||||
|
||||
guarantee(GrainWords == 0, "we should only set it once");
|
||||
GrainWords = GrainBytes >> LogHeapWordSize;
|
||||
guarantee(1 << LogOfHRGrainWords == GrainWords, "sanity");
|
||||
guarantee((size_t)(1 << LogOfHRGrainWords) == GrainWords, "sanity");
|
||||
|
||||
guarantee(CardsPerRegion == 0, "we should only set it once");
|
||||
CardsPerRegion = GrainBytes >> CardTableModRefBS::card_shift;
|
||||
@ -374,8 +379,7 @@ void HeapRegion::hr_clear(bool par, bool clear_space) {
|
||||
|
||||
void HeapRegion::par_clear() {
|
||||
assert(used() == 0, "the region should have been already cleared");
|
||||
assert(capacity() == (size_t) HeapRegion::GrainBytes,
|
||||
"should be back to normal");
|
||||
assert(capacity() == HeapRegion::GrainBytes, "should be back to normal");
|
||||
HeapRegionRemSet* hrrs = rem_set();
|
||||
hrrs->clear();
|
||||
CardTableModRefBS* ct_bs =
|
||||
@ -431,7 +435,7 @@ void HeapRegion::set_notHumongous() {
|
||||
assert(end() == _orig_end, "sanity");
|
||||
}
|
||||
|
||||
assert(capacity() == (size_t) HeapRegion::GrainBytes, "pre-condition");
|
||||
assert(capacity() == HeapRegion::GrainBytes, "pre-condition");
|
||||
_humongous_type = NotHumongous;
|
||||
_humongous_start_region = NULL;
|
||||
}
|
||||
@ -483,12 +487,13 @@ HeapRegion::
|
||||
HeapRegion(size_t hrs_index, G1BlockOffsetSharedArray* sharedOffsetArray,
|
||||
MemRegion mr, bool is_zeroed)
|
||||
: G1OffsetTableContigSpace(sharedOffsetArray, mr, is_zeroed),
|
||||
_next_fk(HeapRegionDCTOC::NoFilterKind), _hrs_index(hrs_index),
|
||||
_hrs_index(hrs_index),
|
||||
_humongous_type(NotHumongous), _humongous_start_region(NULL),
|
||||
_in_collection_set(false),
|
||||
_next_in_special_set(NULL), _orig_end(NULL),
|
||||
_claimed(InitialClaimValue), _evacuation_failed(false),
|
||||
_prev_marked_bytes(0), _next_marked_bytes(0), _sort_index(-1),
|
||||
_gc_efficiency(0.0),
|
||||
_young_type(NotYoung), _next_young_region(NULL),
|
||||
_next_dirty_cards_region(NULL), _next(NULL), _pending_removal(false),
|
||||
#ifdef ASSERT
|
||||
|
@ -118,7 +118,6 @@ public:
|
||||
FilterKind fk);
|
||||
};
|
||||
|
||||
|
||||
// The complicating factor is that BlockOffsetTable diverged
|
||||
// significantly, and we need functionality that is only in the G1 version.
|
||||
// So I copied that code, which led to an alternate G1 version of
|
||||
@ -223,10 +222,6 @@ class HeapRegion: public G1OffsetTableContigSpace {
|
||||
ContinuesHumongous
|
||||
};
|
||||
|
||||
// The next filter kind that should be used for a "new_dcto_cl" call with
|
||||
// the "traditional" signature.
|
||||
HeapRegionDCTOC::FilterKind _next_fk;
|
||||
|
||||
// Requires that the region "mr" be dense with objects, and begin and end
|
||||
// with an object.
|
||||
void oops_in_mr_iterate(MemRegion mr, OopClosure* cl);
|
||||
@ -351,16 +346,17 @@ class HeapRegion: public G1OffsetTableContigSpace {
|
||||
G1BlockOffsetSharedArray* sharedOffsetArray,
|
||||
MemRegion mr, bool is_zeroed);
|
||||
|
||||
static int LogOfHRGrainBytes;
|
||||
static int LogOfHRGrainWords;
|
||||
// The normal type of these should be size_t. However, they used to
|
||||
// be members of an enum before and they are assumed by the
|
||||
// compilers to be ints. To avoid going and fixing all their uses,
|
||||
// I'm declaring them as ints. I'm not anticipating heap region
|
||||
// sizes to reach anywhere near 2g, so using an int here is safe.
|
||||
static int GrainBytes;
|
||||
static int GrainWords;
|
||||
static int CardsPerRegion;
|
||||
static int LogOfHRGrainBytes;
|
||||
static int LogOfHRGrainWords;
|
||||
|
||||
static size_t GrainBytes;
|
||||
static size_t GrainWords;
|
||||
static size_t CardsPerRegion;
|
||||
|
||||
static size_t align_up_to_region_byte_size(size_t sz) {
|
||||
return (sz + (size_t) GrainBytes - 1) &
|
||||
~((1 << (size_t) LogOfHRGrainBytes) - 1);
|
||||
}
|
||||
|
||||
// It sets up the heap region size (GrainBytes / GrainWords), as
|
||||
// well as other related fields that are based on the heap region
|
||||
@ -573,40 +569,14 @@ class HeapRegion: public G1OffsetTableContigSpace {
|
||||
// allocated in the current region before the last call to "save_mark".
|
||||
void oop_before_save_marks_iterate(OopClosure* cl);
|
||||
|
||||
// This call determines the "filter kind" argument that will be used for
|
||||
// the next call to "new_dcto_cl" on this region with the "traditional"
|
||||
// signature (i.e., the call below.) The default, in the absence of a
|
||||
// preceding call to this method, is "NoFilterKind", and a call to this
|
||||
// method is necessary for each such call, or else it reverts to the
|
||||
// default.
|
||||
// (This is really ugly, but all other methods I could think of changed a
|
||||
// lot of main-line code for G1.)
|
||||
void set_next_filter_kind(HeapRegionDCTOC::FilterKind nfk) {
|
||||
_next_fk = nfk;
|
||||
}
|
||||
|
||||
DirtyCardToOopClosure*
|
||||
new_dcto_closure(OopClosure* cl,
|
||||
CardTableModRefBS::PrecisionStyle precision,
|
||||
HeapRegionDCTOC::FilterKind fk);
|
||||
|
||||
#if WHASSUP
|
||||
DirtyCardToOopClosure*
|
||||
new_dcto_closure(OopClosure* cl,
|
||||
CardTableModRefBS::PrecisionStyle precision,
|
||||
HeapWord* boundary) {
|
||||
assert(boundary == NULL, "This arg doesn't make sense here.");
|
||||
DirtyCardToOopClosure* res = new_dcto_closure(cl, precision, _next_fk);
|
||||
_next_fk = HeapRegionDCTOC::NoFilterKind;
|
||||
return res;
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// Note the start or end of marking. This tells the heap region
|
||||
// that the collector is about to start or has finished (concurrently)
|
||||
// marking the heap.
|
||||
//
|
||||
|
||||
// Note the start of a marking phase. Record the
|
||||
// start of the unmarked area of the region here.
|
||||
|
@ -148,7 +148,7 @@ protected:
|
||||
CardIdx_t from_card = (CardIdx_t)
|
||||
hw_offset >> (CardTableModRefBS::card_shift - LogHeapWordSize);
|
||||
|
||||
assert(0 <= from_card && from_card < HeapRegion::CardsPerRegion,
|
||||
assert(0 <= from_card && (size_t)from_card < HeapRegion::CardsPerRegion,
|
||||
"Must be in range.");
|
||||
add_card_work(from_card, par);
|
||||
}
|
||||
@ -639,7 +639,7 @@ void OtherRegionsTable::add_reference(OopOrNarrowOopStar from, int tid) {
|
||||
uintptr_t(from_hr->bottom())
|
||||
>> CardTableModRefBS::card_shift;
|
||||
CardIdx_t card_index = from_card - from_hr_bot_card_index;
|
||||
assert(0 <= card_index && card_index < HeapRegion::CardsPerRegion,
|
||||
assert(0 <= card_index && (size_t)card_index < HeapRegion::CardsPerRegion,
|
||||
"Must be in range.");
|
||||
if (G1HRRSUseSparseTable &&
|
||||
_sparse_table.add_card(from_hrs_ind, card_index)) {
|
||||
@ -1066,7 +1066,7 @@ bool OtherRegionsTable::contains_reference_locked(OopOrNarrowOopStar from) const
|
||||
uintptr_t(hr->bottom()) >> CardTableModRefBS::card_shift;
|
||||
assert(from_card >= hr_bot_card_index, "Inv");
|
||||
CardIdx_t card_index = from_card - hr_bot_card_index;
|
||||
assert(0 <= card_index && card_index < HeapRegion::CardsPerRegion,
|
||||
assert(0 <= card_index && (size_t)card_index < HeapRegion::CardsPerRegion,
|
||||
"Must be in range.");
|
||||
return _sparse_table.contains_card(hr_ind, card_index);
|
||||
}
|
||||
@ -1191,7 +1191,7 @@ void HeapRegionRemSetIterator::initialize(const HeapRegionRemSet* hrrs) {
|
||||
_is = Sparse;
|
||||
// Set these values so that we increment to the first region.
|
||||
_coarse_cur_region_index = -1;
|
||||
_coarse_cur_region_cur_card = (HeapRegion::CardsPerRegion-1);;
|
||||
_coarse_cur_region_cur_card = (HeapRegion::CardsPerRegion-1);
|
||||
|
||||
_cur_region_cur_card = 0;
|
||||
|
||||
@ -1270,7 +1270,7 @@ bool HeapRegionRemSetIterator::fine_has_next(size_t& card_index) {
|
||||
bool HeapRegionRemSetIterator::fine_has_next() {
|
||||
return
|
||||
_fine_cur_prt != NULL &&
|
||||
_cur_region_cur_card < (size_t) HeapRegion::CardsPerRegion;
|
||||
_cur_region_cur_card < HeapRegion::CardsPerRegion;
|
||||
}
|
||||
|
||||
bool HeapRegionRemSetIterator::has_next(size_t& card_index) {
|
||||
|
@ -395,8 +395,8 @@ class HeapRegionRemSetIterator : public CHeapObj {
|
||||
// Coarse table iteration fields:
|
||||
|
||||
// Current region index;
|
||||
int _coarse_cur_region_index;
|
||||
int _coarse_cur_region_cur_card;
|
||||
int _coarse_cur_region_index;
|
||||
size_t _coarse_cur_region_cur_card;
|
||||
|
||||
bool coarse_has_next(size_t& card_index);
|
||||
|
||||
|
@ -56,6 +56,7 @@ class FreeRegionList;
|
||||
// and maintain that: _length <= _allocated_length <= _max_length
|
||||
|
||||
class HeapRegionSeq: public CHeapObj {
|
||||
friend class VMStructs;
|
||||
|
||||
// The array that holds the HeapRegions.
|
||||
HeapRegion** _regions;
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "memory/sharedHeap.hpp"
|
||||
#include "runtime/mutexLocker.hpp"
|
||||
#include "runtime/thread.hpp"
|
||||
#include "runtime/vmThread.hpp"
|
||||
|
||||
// This method removes entries from an SATB buffer that will not be
|
||||
// useful to the concurrent marking threads. An entry is removed if it
|
||||
@ -252,9 +253,18 @@ void SATBMarkQueueSet::par_iterate_closure_all_threads(int worker) {
|
||||
t->satb_mark_queue().apply_closure(_par_closures[worker]);
|
||||
}
|
||||
}
|
||||
// We'll have worker 0 do this one.
|
||||
if (worker == 0) {
|
||||
shared_satb_queue()->apply_closure(_par_closures[0]);
|
||||
|
||||
// We also need to claim the VMThread so that its parity is updated
|
||||
// otherwise the next call to Thread::possibly_parallel_oops_do inside
|
||||
// a StrongRootsScope might skip the VMThread because it has a stale
|
||||
// parity that matches the parity set by the StrongRootsScope
|
||||
//
|
||||
// Whichever worker succeeds in claiming the VMThread gets to do
|
||||
// the shared queue.
|
||||
|
||||
VMThread* vmt = VMThread::vm_thread();
|
||||
if (vmt->claim_oops_do(true, parity)) {
|
||||
shared_satb_queue()->apply_closure(_par_closures[worker]);
|
||||
}
|
||||
}
|
||||
|
||||
|
65
hotspot/src/share/vm/gc_implementation/g1/vmStructs_g1.hpp
Normal file
65
hotspot/src/share/vm/gc_implementation/g1/vmStructs_g1.hpp
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_VMSTRUCTS_G1_HPP
|
||||
#define SHARE_VM_GC_IMPLEMENTATION_G1_VMSTRUCTS_G1_HPP
|
||||
|
||||
#include "gc_implementation/g1/heapRegion.hpp"
|
||||
#include "gc_implementation/g1/heapRegionSeq.inline.hpp"
|
||||
#include "gc_implementation/g1/g1CollectedHeap.inline.hpp"
|
||||
|
||||
#define VM_STRUCTS_G1(nonstatic_field, static_field) \
|
||||
\
|
||||
static_field(HeapRegion, GrainBytes, size_t) \
|
||||
\
|
||||
nonstatic_field(HeapRegionSeq, _regions, HeapRegion**) \
|
||||
nonstatic_field(HeapRegionSeq, _length, size_t) \
|
||||
\
|
||||
nonstatic_field(G1CollectedHeap, _hrs, HeapRegionSeq) \
|
||||
nonstatic_field(G1CollectedHeap, _g1_committed, MemRegion) \
|
||||
nonstatic_field(G1CollectedHeap, _summary_bytes_used, size_t) \
|
||||
nonstatic_field(G1CollectedHeap, _g1mm, G1MonitoringSupport*) \
|
||||
\
|
||||
nonstatic_field(G1MonitoringSupport, _eden_committed, size_t) \
|
||||
nonstatic_field(G1MonitoringSupport, _eden_used, size_t) \
|
||||
nonstatic_field(G1MonitoringSupport, _survivor_committed, size_t) \
|
||||
nonstatic_field(G1MonitoringSupport, _survivor_used, size_t) \
|
||||
nonstatic_field(G1MonitoringSupport, _old_committed, size_t) \
|
||||
nonstatic_field(G1MonitoringSupport, _old_used, size_t) \
|
||||
|
||||
|
||||
#define VM_TYPES_G1(declare_type, declare_toplevel_type) \
|
||||
\
|
||||
declare_type(G1CollectedHeap, SharedHeap) \
|
||||
\
|
||||
declare_type(HeapRegion, ContiguousSpace) \
|
||||
declare_toplevel_type(HeapRegionSeq) \
|
||||
declare_toplevel_type(G1MonitoringSupport) \
|
||||
\
|
||||
declare_toplevel_type(G1CollectedHeap*) \
|
||||
declare_toplevel_type(HeapRegion*) \
|
||||
declare_toplevel_type(G1MonitoringSupport*) \
|
||||
|
||||
|
||||
#endif // SHARE_VM_GC_IMPLEMENTATION_G1_VMSTRUCTS_G1_HPP
|
@ -198,10 +198,9 @@ void PSMarkSweep::invoke_no_policy(bool clear_all_softrefs) {
|
||||
|
||||
allocate_stacks();
|
||||
|
||||
NOT_PRODUCT(ref_processor()->verify_no_references_recorded());
|
||||
COMPILER2_PRESENT(DerivedPointerTable::clear());
|
||||
|
||||
ref_processor()->enable_discovery();
|
||||
ref_processor()->enable_discovery(true /*verify_disabled*/, true /*verify_no_refs*/);
|
||||
ref_processor()->setup_policy(clear_all_softrefs);
|
||||
|
||||
mark_sweep_phase1(clear_all_softrefs);
|
||||
|
@ -2069,10 +2069,9 @@ void PSParallelCompact::invoke_no_policy(bool maximum_heap_compaction) {
|
||||
CodeCache::gc_prologue();
|
||||
Threads::gc_prologue();
|
||||
|
||||
NOT_PRODUCT(ref_processor()->verify_no_references_recorded());
|
||||
COMPILER2_PRESENT(DerivedPointerTable::clear());
|
||||
|
||||
ref_processor()->enable_discovery();
|
||||
ref_processor()->enable_discovery(true /*verify_disabled*/, true /*verify_no_refs*/);
|
||||
ref_processor()->setup_policy(maximum_heap_compaction);
|
||||
|
||||
bool marked_for_unloading = false;
|
||||
|
@ -102,17 +102,15 @@ void PSPromotionLAB::flush() {
|
||||
_state = flushed;
|
||||
}
|
||||
|
||||
bool PSPromotionLAB::unallocate_object(oop obj) {
|
||||
bool PSPromotionLAB::unallocate_object(HeapWord* obj, size_t obj_size) {
|
||||
assert(Universe::heap()->is_in(obj), "Object outside heap");
|
||||
|
||||
if (contains(obj)) {
|
||||
HeapWord* object_end = (HeapWord*)obj + obj->size();
|
||||
assert(object_end <= top(), "Object crosses promotion LAB boundary");
|
||||
HeapWord* object_end = obj + obj_size;
|
||||
assert(object_end == top(), "Not matching last allocation");
|
||||
|
||||
if (object_end == top()) {
|
||||
set_top((HeapWord*)obj);
|
||||
return true;
|
||||
}
|
||||
set_top(obj);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@ -73,7 +73,7 @@ class PSPromotionLAB : public CHeapObj {
|
||||
|
||||
bool is_flushed() { return _state == flushed; }
|
||||
|
||||
bool unallocate_object(oop obj);
|
||||
bool unallocate_object(HeapWord* obj, size_t obj_size);
|
||||
|
||||
// Returns a subregion containing all objects in this space.
|
||||
MemRegion used_region() { return MemRegion(bottom(), top()); }
|
||||
|
@ -380,10 +380,10 @@ oop PSPromotionManager::copy_to_survivor_space(oop o) {
|
||||
// deallocate it, so we have to test. If the deallocation fails,
|
||||
// overwrite with a filler object.
|
||||
if (new_obj_is_tenured) {
|
||||
if (!_old_lab.unallocate_object(new_obj)) {
|
||||
if (!_old_lab.unallocate_object((HeapWord*) new_obj, new_obj_size)) {
|
||||
CollectedHeap::fill_with_object((HeapWord*) new_obj, new_obj_size);
|
||||
}
|
||||
} else if (!_young_lab.unallocate_object(new_obj)) {
|
||||
} else if (!_young_lab.unallocate_object((HeapWord*) new_obj, new_obj_size)) {
|
||||
CollectedHeap::fill_with_object((HeapWord*) new_obj, new_obj_size);
|
||||
}
|
||||
|
||||
|
@ -350,10 +350,9 @@ bool PSScavenge::invoke_no_policy() {
|
||||
}
|
||||
save_to_space_top_before_gc();
|
||||
|
||||
NOT_PRODUCT(reference_processor()->verify_no_references_recorded());
|
||||
COMPILER2_PRESENT(DerivedPointerTable::clear());
|
||||
|
||||
reference_processor()->enable_discovery();
|
||||
reference_processor()->enable_discovery(true /*verify_disabled*/, true /*verify_no_refs*/);
|
||||
reference_processor()->setup_policy(false);
|
||||
|
||||
// We track how much was promoted to the next generation for
|
||||
|
@ -26,14 +26,10 @@
|
||||
#include "gc_implementation/shared/generationCounters.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
|
||||
|
||||
GenerationCounters::GenerationCounters(const char* name,
|
||||
int ordinal, int spaces,
|
||||
VirtualSpace* v):
|
||||
_virtual_space(v) {
|
||||
|
||||
void GenerationCounters::initialize(const char* name, int ordinal, int spaces,
|
||||
size_t min_capacity, size_t max_capacity,
|
||||
size_t curr_capacity) {
|
||||
if (UsePerfData) {
|
||||
|
||||
EXCEPTION_MARK;
|
||||
ResourceMark rm;
|
||||
|
||||
@ -51,18 +47,37 @@ GenerationCounters::GenerationCounters(const char* name,
|
||||
|
||||
cname = PerfDataManager::counter_name(_name_space, "minCapacity");
|
||||
PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_Bytes,
|
||||
_virtual_space == NULL ? 0 :
|
||||
_virtual_space->committed_size(), CHECK);
|
||||
min_capacity, CHECK);
|
||||
|
||||
cname = PerfDataManager::counter_name(_name_space, "maxCapacity");
|
||||
PerfDataManager::create_constant(SUN_GC, cname, PerfData::U_Bytes,
|
||||
_virtual_space == NULL ? 0 :
|
||||
_virtual_space->reserved_size(), CHECK);
|
||||
max_capacity, CHECK);
|
||||
|
||||
cname = PerfDataManager::counter_name(_name_space, "capacity");
|
||||
_current_size = PerfDataManager::create_variable(SUN_GC, cname,
|
||||
PerfData::U_Bytes,
|
||||
_virtual_space == NULL ? 0 :
|
||||
_virtual_space->committed_size(), CHECK);
|
||||
_current_size =
|
||||
PerfDataManager::create_variable(SUN_GC, cname, PerfData::U_Bytes,
|
||||
curr_capacity, CHECK);
|
||||
}
|
||||
}
|
||||
|
||||
GenerationCounters::GenerationCounters(const char* name,
|
||||
int ordinal, int spaces,
|
||||
VirtualSpace* v)
|
||||
: _virtual_space(v) {
|
||||
assert(v != NULL, "don't call this constructor if v == NULL");
|
||||
initialize(name, ordinal, spaces,
|
||||
v->committed_size(), v->reserved_size(), v->committed_size());
|
||||
}
|
||||
|
||||
GenerationCounters::GenerationCounters(const char* name,
|
||||
int ordinal, int spaces,
|
||||
size_t min_capacity, size_t max_capacity,
|
||||
size_t curr_capacity)
|
||||
: _virtual_space(NULL) {
|
||||
initialize(name, ordinal, spaces, min_capacity, max_capacity, curr_capacity);
|
||||
}
|
||||
|
||||
void GenerationCounters::update_all() {
|
||||
assert(_virtual_space != NULL, "otherwise, override this method");
|
||||
_current_size->set_value(_virtual_space->committed_size());
|
||||
}
|
||||
|
@ -34,6 +34,11 @@
|
||||
class GenerationCounters: public CHeapObj {
|
||||
friend class VMStructs;
|
||||
|
||||
private:
|
||||
void initialize(const char* name, int ordinal, int spaces,
|
||||
size_t min_capacity, size_t max_capacity,
|
||||
size_t curr_capacity);
|
||||
|
||||
protected:
|
||||
PerfVariable* _current_size;
|
||||
VirtualSpace* _virtual_space;
|
||||
@ -48,11 +53,18 @@ class GenerationCounters: public CHeapObj {
|
||||
char* _name_space;
|
||||
|
||||
// This constructor is only meant for use with the PSGenerationCounters
|
||||
// constructor. The need for such an constructor should be eliminated
|
||||
// constructor. The need for such an constructor should be eliminated
|
||||
// when VirtualSpace and PSVirtualSpace are unified.
|
||||
GenerationCounters() : _name_space(NULL), _current_size(NULL), _virtual_space(NULL) {}
|
||||
public:
|
||||
GenerationCounters()
|
||||
: _name_space(NULL), _current_size(NULL), _virtual_space(NULL) {}
|
||||
|
||||
// This constructor is used for subclasses that do not have a space
|
||||
// associated with them (e.g, in G1).
|
||||
GenerationCounters(const char* name, int ordinal, int spaces,
|
||||
size_t min_capacity, size_t max_capacity,
|
||||
size_t curr_capacity);
|
||||
|
||||
public:
|
||||
GenerationCounters(const char* name, int ordinal, int spaces,
|
||||
VirtualSpace* v);
|
||||
|
||||
@ -60,10 +72,7 @@ class GenerationCounters: public CHeapObj {
|
||||
if (_name_space != NULL) FREE_C_HEAP_ARRAY(char, _name_space);
|
||||
}
|
||||
|
||||
virtual void update_all() {
|
||||
_current_size->set_value(_virtual_space == NULL ? 0 :
|
||||
_virtual_space->committed_size());
|
||||
}
|
||||
virtual void update_all();
|
||||
|
||||
const char* name_space() const { return _name_space; }
|
||||
|
||||
|
@ -599,8 +599,7 @@ void GenCollectedHeap::do_collection(bool full,
|
||||
// atomic wrt other collectors in this configuration, we
|
||||
// are guaranteed to have empty discovered ref lists.
|
||||
if (rp->discovery_is_atomic()) {
|
||||
rp->verify_no_references_recorded();
|
||||
rp->enable_discovery();
|
||||
rp->enable_discovery(true /*verify_disabled*/, true /*verify_no_refs*/);
|
||||
rp->setup_policy(do_clear_all_soft_refs);
|
||||
} else {
|
||||
// collect() below will enable discovery as appropriate
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -41,8 +41,9 @@ void LRUCurrentHeapPolicy::setup() {
|
||||
|
||||
// The oop passed in is the SoftReference object, and not
|
||||
// the object the SoftReference points to.
|
||||
bool LRUCurrentHeapPolicy::should_clear_reference(oop p) {
|
||||
jlong interval = java_lang_ref_SoftReference::clock() - java_lang_ref_SoftReference::timestamp(p);
|
||||
bool LRUCurrentHeapPolicy::should_clear_reference(oop p,
|
||||
jlong timestamp_clock) {
|
||||
jlong interval = timestamp_clock - java_lang_ref_SoftReference::timestamp(p);
|
||||
assert(interval >= 0, "Sanity check");
|
||||
|
||||
// The interval will be zero if the ref was accessed since the last scavenge/gc.
|
||||
@ -71,8 +72,9 @@ void LRUMaxHeapPolicy::setup() {
|
||||
|
||||
// The oop passed in is the SoftReference object, and not
|
||||
// the object the SoftReference points to.
|
||||
bool LRUMaxHeapPolicy::should_clear_reference(oop p) {
|
||||
jlong interval = java_lang_ref_SoftReference::clock() - java_lang_ref_SoftReference::timestamp(p);
|
||||
bool LRUMaxHeapPolicy::should_clear_reference(oop p,
|
||||
jlong timestamp_clock) {
|
||||
jlong interval = timestamp_clock - java_lang_ref_SoftReference::timestamp(p);
|
||||
assert(interval >= 0, "Sanity check");
|
||||
|
||||
// The interval will be zero if the ref was accessed since the last scavenge/gc.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -31,19 +31,27 @@
|
||||
|
||||
class ReferencePolicy : public CHeapObj {
|
||||
public:
|
||||
virtual bool should_clear_reference(oop p) { ShouldNotReachHere(); return true; }
|
||||
virtual bool should_clear_reference(oop p, jlong timestamp_clock) {
|
||||
ShouldNotReachHere();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Capture state (of-the-VM) information needed to evaluate the policy
|
||||
virtual void setup() { /* do nothing */ }
|
||||
};
|
||||
|
||||
class NeverClearPolicy : public ReferencePolicy {
|
||||
public:
|
||||
bool should_clear_reference(oop p) { return false; }
|
||||
virtual bool should_clear_reference(oop p, jlong timestamp_clock) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
class AlwaysClearPolicy : public ReferencePolicy {
|
||||
public:
|
||||
bool should_clear_reference(oop p) { return true; }
|
||||
virtual bool should_clear_reference(oop p, jlong timestamp_clock) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
class LRUCurrentHeapPolicy : public ReferencePolicy {
|
||||
@ -55,7 +63,7 @@ class LRUCurrentHeapPolicy : public ReferencePolicy {
|
||||
|
||||
// Capture state (of-the-VM) information needed to evaluate the policy
|
||||
void setup();
|
||||
bool should_clear_reference(oop p);
|
||||
virtual bool should_clear_reference(oop p, jlong timestamp_clock);
|
||||
};
|
||||
|
||||
class LRUMaxHeapPolicy : public ReferencePolicy {
|
||||
@ -67,7 +75,7 @@ class LRUMaxHeapPolicy : public ReferencePolicy {
|
||||
|
||||
// Capture state (of-the-VM) information needed to evaluate the policy
|
||||
void setup();
|
||||
bool should_clear_reference(oop p);
|
||||
virtual bool should_clear_reference(oop p, jlong timestamp_clock);
|
||||
};
|
||||
|
||||
#endif // SHARE_VM_MEMORY_REFERENCEPOLICY_HPP
|
||||
|
@ -35,49 +35,20 @@
|
||||
|
||||
ReferencePolicy* ReferenceProcessor::_always_clear_soft_ref_policy = NULL;
|
||||
ReferencePolicy* ReferenceProcessor::_default_soft_ref_policy = NULL;
|
||||
const int subclasses_of_ref = REF_PHANTOM - REF_OTHER;
|
||||
bool ReferenceProcessor::_pending_list_uses_discovered_field = false;
|
||||
|
||||
// List of discovered references.
|
||||
class DiscoveredList {
|
||||
public:
|
||||
DiscoveredList() : _len(0), _compressed_head(0), _oop_head(NULL) { }
|
||||
oop head() const {
|
||||
return UseCompressedOops ? oopDesc::decode_heap_oop(_compressed_head) :
|
||||
_oop_head;
|
||||
}
|
||||
HeapWord* adr_head() {
|
||||
return UseCompressedOops ? (HeapWord*)&_compressed_head :
|
||||
(HeapWord*)&_oop_head;
|
||||
}
|
||||
void set_head(oop o) {
|
||||
if (UseCompressedOops) {
|
||||
// Must compress the head ptr.
|
||||
_compressed_head = oopDesc::encode_heap_oop(o);
|
||||
} else {
|
||||
_oop_head = o;
|
||||
}
|
||||
}
|
||||
bool empty() const { return head() == NULL; }
|
||||
size_t length() { return _len; }
|
||||
void set_length(size_t len) { _len = len; }
|
||||
void inc_length(size_t inc) { _len += inc; assert(_len > 0, "Error"); }
|
||||
void dec_length(size_t dec) { _len -= dec; }
|
||||
private:
|
||||
// Set value depending on UseCompressedOops. This could be a template class
|
||||
// but then we have to fix all the instantiations and declarations that use this class.
|
||||
oop _oop_head;
|
||||
narrowOop _compressed_head;
|
||||
size_t _len;
|
||||
};
|
||||
jlong ReferenceProcessor::_soft_ref_timestamp_clock = 0;
|
||||
|
||||
void referenceProcessor_init() {
|
||||
ReferenceProcessor::init_statics();
|
||||
}
|
||||
|
||||
void ReferenceProcessor::init_statics() {
|
||||
// Initialize the master soft ref clock.
|
||||
java_lang_ref_SoftReference::set_clock(os::javaTimeMillis());
|
||||
jlong now = os::javaTimeMillis();
|
||||
|
||||
// Initialize the soft ref timestamp clock.
|
||||
_soft_ref_timestamp_clock = now;
|
||||
// Also update the soft ref clock in j.l.r.SoftReference
|
||||
java_lang_ref_SoftReference::set_clock(_soft_ref_timestamp_clock);
|
||||
|
||||
_always_clear_soft_ref_policy = new AlwaysClearPolicy();
|
||||
_default_soft_ref_policy = new COMPILER2_PRESENT(LRUMaxHeapPolicy())
|
||||
@ -91,6 +62,28 @@ void ReferenceProcessor::init_statics() {
|
||||
_pending_list_uses_discovered_field = JDK_Version::current().pending_list_uses_discovered_field();
|
||||
}
|
||||
|
||||
void ReferenceProcessor::enable_discovery(bool verify_disabled, bool check_no_refs) {
|
||||
#ifdef ASSERT
|
||||
// Verify that we're not currently discovering refs
|
||||
assert(!verify_disabled || !_discovering_refs, "nested call?");
|
||||
|
||||
if (check_no_refs) {
|
||||
// Verify that the discovered lists are empty
|
||||
verify_no_references_recorded();
|
||||
}
|
||||
#endif // ASSERT
|
||||
|
||||
// Someone could have modified the value of the static
|
||||
// field in the j.l.r.SoftReference class that holds the
|
||||
// soft reference timestamp clock using reflection or
|
||||
// Unsafe between GCs. Unconditionally update the static
|
||||
// field in ReferenceProcessor here so that we use the new
|
||||
// value during reference discovery.
|
||||
|
||||
_soft_ref_timestamp_clock = java_lang_ref_SoftReference::clock();
|
||||
_discovering_refs = true;
|
||||
}
|
||||
|
||||
ReferenceProcessor::ReferenceProcessor(MemRegion span,
|
||||
bool mt_processing,
|
||||
int mt_processing_degree,
|
||||
@ -112,7 +105,8 @@ ReferenceProcessor::ReferenceProcessor(MemRegion span,
|
||||
_discovery_is_mt = mt_discovery;
|
||||
_num_q = MAX2(1, mt_processing_degree);
|
||||
_max_num_q = MAX2(_num_q, mt_discovery_degree);
|
||||
_discoveredSoftRefs = NEW_C_HEAP_ARRAY(DiscoveredList, _max_num_q * subclasses_of_ref);
|
||||
_discoveredSoftRefs = NEW_C_HEAP_ARRAY(DiscoveredList,
|
||||
_max_num_q * number_of_subclasses_of_ref());
|
||||
if (_discoveredSoftRefs == NULL) {
|
||||
vm_exit_during_initialization("Could not allocated RefProc Array");
|
||||
}
|
||||
@ -120,7 +114,7 @@ ReferenceProcessor::ReferenceProcessor(MemRegion span,
|
||||
_discoveredFinalRefs = &_discoveredWeakRefs[_max_num_q];
|
||||
_discoveredPhantomRefs = &_discoveredFinalRefs[_max_num_q];
|
||||
// Initialized all entries to NULL
|
||||
for (int i = 0; i < _max_num_q * subclasses_of_ref; i++) {
|
||||
for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) {
|
||||
_discoveredSoftRefs[i].set_head(NULL);
|
||||
_discoveredSoftRefs[i].set_length(0);
|
||||
}
|
||||
@ -134,19 +128,15 @@ ReferenceProcessor::ReferenceProcessor(MemRegion span,
|
||||
#ifndef PRODUCT
|
||||
void ReferenceProcessor::verify_no_references_recorded() {
|
||||
guarantee(!_discovering_refs, "Discovering refs?");
|
||||
for (int i = 0; i < _max_num_q * subclasses_of_ref; i++) {
|
||||
guarantee(_discoveredSoftRefs[i].empty(),
|
||||
for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) {
|
||||
guarantee(_discoveredSoftRefs[i].is_empty(),
|
||||
"Found non-empty discovered list");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void ReferenceProcessor::weak_oops_do(OopClosure* f) {
|
||||
// Should this instead be
|
||||
// for (int i = 0; i < subclasses_of_ref; i++_ {
|
||||
// for (int j = 0; j < _num_q; j++) {
|
||||
// int index = i * _max_num_q + j;
|
||||
for (int i = 0; i < _max_num_q * subclasses_of_ref; i++) {
|
||||
for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) {
|
||||
if (UseCompressedOops) {
|
||||
f->do_oop((narrowOop*)_discoveredSoftRefs[i].adr_head());
|
||||
} else {
|
||||
@ -159,17 +149,21 @@ void ReferenceProcessor::update_soft_ref_master_clock() {
|
||||
// Update (advance) the soft ref master clock field. This must be done
|
||||
// after processing the soft ref list.
|
||||
jlong now = os::javaTimeMillis();
|
||||
jlong clock = java_lang_ref_SoftReference::clock();
|
||||
jlong soft_ref_clock = java_lang_ref_SoftReference::clock();
|
||||
assert(soft_ref_clock == _soft_ref_timestamp_clock, "soft ref clocks out of sync");
|
||||
|
||||
NOT_PRODUCT(
|
||||
if (now < clock) {
|
||||
warning("time warp: %d to %d", clock, now);
|
||||
if (now < _soft_ref_timestamp_clock) {
|
||||
warning("time warp: "INT64_FORMAT" to "INT64_FORMAT,
|
||||
_soft_ref_timestamp_clock, now);
|
||||
}
|
||||
)
|
||||
// In product mode, protect ourselves from system time being adjusted
|
||||
// externally and going backward; see note in the implementation of
|
||||
// GenCollectedHeap::time_since_last_gc() for the right way to fix
|
||||
// this uniformly throughout the VM; see bug-id 4741166. XXX
|
||||
if (now > clock) {
|
||||
if (now > _soft_ref_timestamp_clock) {
|
||||
_soft_ref_timestamp_clock = now;
|
||||
java_lang_ref_SoftReference::set_clock(now);
|
||||
}
|
||||
// Else leave clock stalled at its old value until time progresses
|
||||
@ -187,6 +181,16 @@ void ReferenceProcessor::process_discovered_references(
|
||||
// Stop treating discovered references specially.
|
||||
disable_discovery();
|
||||
|
||||
// If discovery was concurrent, someone could have modified
|
||||
// the value of the static field in the j.l.r.SoftReference
|
||||
// class that holds the soft reference timestamp clock using
|
||||
// reflection or Unsafe between when discovery was enabled and
|
||||
// now. Unconditionally update the static field in ReferenceProcessor
|
||||
// here so that we use the new value during processing of the
|
||||
// discovered soft refs.
|
||||
|
||||
_soft_ref_timestamp_clock = java_lang_ref_SoftReference::clock();
|
||||
|
||||
bool trace_time = PrintGCDetails && PrintReferenceGC;
|
||||
// Soft references
|
||||
{
|
||||
@ -404,7 +408,7 @@ public:
|
||||
// allocated and are indexed into.
|
||||
assert(_n_queues == (int) _ref_processor.max_num_q(), "Different number not expected");
|
||||
for (int j = 0;
|
||||
j < subclasses_of_ref;
|
||||
j < ReferenceProcessor::number_of_subclasses_of_ref();
|
||||
j++, index += _n_queues) {
|
||||
_ref_processor.enqueue_discovered_reflist(
|
||||
_refs_lists[index], _pending_list_addr);
|
||||
@ -424,7 +428,7 @@ void ReferenceProcessor::enqueue_discovered_reflists(HeapWord* pending_list_addr
|
||||
task_executor->execute(tsk);
|
||||
} else {
|
||||
// Serial code: call the parent class's implementation
|
||||
for (int i = 0; i < _max_num_q * subclasses_of_ref; i++) {
|
||||
for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) {
|
||||
enqueue_discovered_reflist(_discoveredSoftRefs[i], pending_list_addr);
|
||||
_discoveredSoftRefs[i].set_head(NULL);
|
||||
_discoveredSoftRefs[i].set_length(0);
|
||||
@ -432,119 +436,7 @@ void ReferenceProcessor::enqueue_discovered_reflists(HeapWord* pending_list_addr
|
||||
}
|
||||
}
|
||||
|
||||
// Iterator for the list of discovered references.
|
||||
class DiscoveredListIterator {
|
||||
public:
|
||||
inline DiscoveredListIterator(DiscoveredList& refs_list,
|
||||
OopClosure* keep_alive,
|
||||
BoolObjectClosure* is_alive);
|
||||
|
||||
// End Of List.
|
||||
inline bool has_next() const { return _ref != NULL; }
|
||||
|
||||
// Get oop to the Reference object.
|
||||
inline oop obj() const { return _ref; }
|
||||
|
||||
// Get oop to the referent object.
|
||||
inline oop referent() const { return _referent; }
|
||||
|
||||
// Returns true if referent is alive.
|
||||
inline bool is_referent_alive() const;
|
||||
|
||||
// Loads data for the current reference.
|
||||
// The "allow_null_referent" argument tells us to allow for the possibility
|
||||
// of a NULL referent in the discovered Reference object. This typically
|
||||
// happens in the case of concurrent collectors that may have done the
|
||||
// discovery concurrently, or interleaved, with mutator execution.
|
||||
inline void load_ptrs(DEBUG_ONLY(bool allow_null_referent));
|
||||
|
||||
// Move to the next discovered reference.
|
||||
inline void next();
|
||||
|
||||
// Remove the current reference from the list
|
||||
inline void remove();
|
||||
|
||||
// Make the Reference object active again.
|
||||
inline void make_active() { java_lang_ref_Reference::set_next(_ref, NULL); }
|
||||
|
||||
// Make the referent alive.
|
||||
inline void make_referent_alive() {
|
||||
if (UseCompressedOops) {
|
||||
_keep_alive->do_oop((narrowOop*)_referent_addr);
|
||||
} else {
|
||||
_keep_alive->do_oop((oop*)_referent_addr);
|
||||
}
|
||||
}
|
||||
|
||||
// Update the discovered field.
|
||||
inline void update_discovered() {
|
||||
// First _prev_next ref actually points into DiscoveredList (gross).
|
||||
if (UseCompressedOops) {
|
||||
if (!oopDesc::is_null(*(narrowOop*)_prev_next)) {
|
||||
_keep_alive->do_oop((narrowOop*)_prev_next);
|
||||
}
|
||||
} else {
|
||||
if (!oopDesc::is_null(*(oop*)_prev_next)) {
|
||||
_keep_alive->do_oop((oop*)_prev_next);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NULL out referent pointer.
|
||||
inline void clear_referent() { oop_store_raw(_referent_addr, NULL); }
|
||||
|
||||
// Statistics
|
||||
NOT_PRODUCT(
|
||||
inline size_t processed() const { return _processed; }
|
||||
inline size_t removed() const { return _removed; }
|
||||
)
|
||||
|
||||
inline void move_to_next();
|
||||
|
||||
private:
|
||||
DiscoveredList& _refs_list;
|
||||
HeapWord* _prev_next;
|
||||
oop _prev;
|
||||
oop _ref;
|
||||
HeapWord* _discovered_addr;
|
||||
oop _next;
|
||||
HeapWord* _referent_addr;
|
||||
oop _referent;
|
||||
OopClosure* _keep_alive;
|
||||
BoolObjectClosure* _is_alive;
|
||||
DEBUG_ONLY(
|
||||
oop _first_seen; // cyclic linked list check
|
||||
)
|
||||
NOT_PRODUCT(
|
||||
size_t _processed;
|
||||
size_t _removed;
|
||||
)
|
||||
};
|
||||
|
||||
inline DiscoveredListIterator::DiscoveredListIterator(DiscoveredList& refs_list,
|
||||
OopClosure* keep_alive,
|
||||
BoolObjectClosure* is_alive)
|
||||
: _refs_list(refs_list),
|
||||
_prev_next(refs_list.adr_head()),
|
||||
_prev(NULL),
|
||||
_ref(refs_list.head()),
|
||||
#ifdef ASSERT
|
||||
_first_seen(refs_list.head()),
|
||||
#endif
|
||||
#ifndef PRODUCT
|
||||
_processed(0),
|
||||
_removed(0),
|
||||
#endif
|
||||
_next(NULL),
|
||||
_keep_alive(keep_alive),
|
||||
_is_alive(is_alive)
|
||||
{ }
|
||||
|
||||
inline bool DiscoveredListIterator::is_referent_alive() const {
|
||||
return _is_alive->do_object_b(_referent);
|
||||
}
|
||||
|
||||
inline void DiscoveredListIterator::load_ptrs(DEBUG_ONLY(bool allow_null_referent)) {
|
||||
void DiscoveredListIterator::load_ptrs(DEBUG_ONLY(bool allow_null_referent)) {
|
||||
_discovered_addr = java_lang_ref_Reference::discovered_addr(_ref);
|
||||
oop discovered = java_lang_ref_Reference::discovered(_ref);
|
||||
assert(_discovered_addr && discovered->is_oop_or_null(),
|
||||
@ -560,13 +452,7 @@ inline void DiscoveredListIterator::load_ptrs(DEBUG_ONLY(bool allow_null_referen
|
||||
"bad referent");
|
||||
}
|
||||
|
||||
inline void DiscoveredListIterator::next() {
|
||||
_prev_next = _discovered_addr;
|
||||
_prev = _ref;
|
||||
move_to_next();
|
||||
}
|
||||
|
||||
inline void DiscoveredListIterator::remove() {
|
||||
void DiscoveredListIterator::remove() {
|
||||
assert(_ref->is_oop(), "Dropping a bad reference");
|
||||
oop_store_raw(_discovered_addr, NULL);
|
||||
|
||||
@ -592,15 +478,29 @@ inline void DiscoveredListIterator::remove() {
|
||||
_refs_list.dec_length(1);
|
||||
}
|
||||
|
||||
inline void DiscoveredListIterator::move_to_next() {
|
||||
if (_ref == _next) {
|
||||
// End of the list.
|
||||
_ref = NULL;
|
||||
// Make the Reference object active again.
|
||||
void DiscoveredListIterator::make_active() {
|
||||
// For G1 we don't want to use set_next - it
|
||||
// will dirty the card for the next field of
|
||||
// the reference object and will fail
|
||||
// CT verification.
|
||||
if (UseG1GC) {
|
||||
BarrierSet* bs = oopDesc::bs();
|
||||
HeapWord* next_addr = java_lang_ref_Reference::next_addr(_ref);
|
||||
|
||||
if (UseCompressedOops) {
|
||||
bs->write_ref_field_pre((narrowOop*)next_addr, NULL);
|
||||
} else {
|
||||
bs->write_ref_field_pre((oop*)next_addr, NULL);
|
||||
}
|
||||
java_lang_ref_Reference::set_next_raw(_ref, NULL);
|
||||
} else {
|
||||
_ref = _next;
|
||||
java_lang_ref_Reference::set_next(_ref, NULL);
|
||||
}
|
||||
assert(_ref != _first_seen, "cyclic ref_list found");
|
||||
NOT_PRODUCT(_processed++);
|
||||
}
|
||||
|
||||
void DiscoveredListIterator::clear_referent() {
|
||||
oop_store_raw(_referent_addr, NULL);
|
||||
}
|
||||
|
||||
// NOTE: process_phase*() are largely similar, and at a high level
|
||||
@ -627,7 +527,8 @@ ReferenceProcessor::process_phase1(DiscoveredList& refs_list,
|
||||
while (iter.has_next()) {
|
||||
iter.load_ptrs(DEBUG_ONLY(!discovery_is_atomic() /* allow_null_referent */));
|
||||
bool referent_is_dead = (iter.referent() != NULL) && !iter.is_referent_alive();
|
||||
if (referent_is_dead && !policy->should_clear_reference(iter.obj())) {
|
||||
if (referent_is_dead &&
|
||||
!policy->should_clear_reference(iter.obj(), _soft_ref_timestamp_clock)) {
|
||||
if (TraceReferenceGC) {
|
||||
gclog_or_tty->print_cr("Dropping reference (" INTPTR_FORMAT ": %s" ") by policy",
|
||||
iter.obj(), iter.obj()->blueprint()->internal_name());
|
||||
@ -786,10 +687,9 @@ ReferenceProcessor::abandon_partial_discovered_list(DiscoveredList& refs_list) {
|
||||
|
||||
void ReferenceProcessor::abandon_partial_discovery() {
|
||||
// loop over the lists
|
||||
for (int i = 0; i < _max_num_q * subclasses_of_ref; i++) {
|
||||
for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) {
|
||||
if (TraceReferenceGC && PrintGCDetails && ((i % _max_num_q) == 0)) {
|
||||
gclog_or_tty->print_cr("\nAbandoning %s discovered list",
|
||||
list_name(i));
|
||||
gclog_or_tty->print_cr("\nAbandoning %s discovered list", list_name(i));
|
||||
}
|
||||
abandon_partial_discovered_list(_discoveredSoftRefs[i]);
|
||||
}
|
||||
@ -858,6 +758,14 @@ private:
|
||||
bool _clear_referent;
|
||||
};
|
||||
|
||||
void ReferenceProcessor::set_discovered(oop ref, oop value) {
|
||||
if (_discovered_list_needs_barrier) {
|
||||
java_lang_ref_Reference::set_discovered(ref, value);
|
||||
} else {
|
||||
java_lang_ref_Reference::set_discovered_raw(ref, value);
|
||||
}
|
||||
}
|
||||
|
||||
// Balances reference queues.
|
||||
// Move entries from all queues[0, 1, ..., _max_num_q-1] to
|
||||
// queues[0, 1, ..., _num_q-1] because only the first _num_q
|
||||
@ -915,9 +823,9 @@ void ReferenceProcessor::balance_queues(DiscoveredList ref_lists[])
|
||||
// Add the chain to the to list.
|
||||
if (ref_lists[to_idx].head() == NULL) {
|
||||
// to list is empty. Make a loop at the end.
|
||||
java_lang_ref_Reference::set_discovered(move_tail, move_tail);
|
||||
set_discovered(move_tail, move_tail);
|
||||
} else {
|
||||
java_lang_ref_Reference::set_discovered(move_tail, ref_lists[to_idx].head());
|
||||
set_discovered(move_tail, ref_lists[to_idx].head());
|
||||
}
|
||||
ref_lists[to_idx].set_head(move_head);
|
||||
ref_lists[to_idx].inc_length(refs_to_move);
|
||||
@ -1038,11 +946,7 @@ ReferenceProcessor::process_discovered_reflist(
|
||||
|
||||
void ReferenceProcessor::clean_up_discovered_references() {
|
||||
// loop over the lists
|
||||
// Should this instead be
|
||||
// for (int i = 0; i < subclasses_of_ref; i++_ {
|
||||
// for (int j = 0; j < _num_q; j++) {
|
||||
// int index = i * _max_num_q + j;
|
||||
for (int i = 0; i < _max_num_q * subclasses_of_ref; i++) {
|
||||
for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) {
|
||||
if (TraceReferenceGC && PrintGCDetails && ((i % _max_num_q) == 0)) {
|
||||
gclog_or_tty->print_cr(
|
||||
"\nScrubbing %s discovered list of Null referents",
|
||||
@ -1255,11 +1159,13 @@ bool ReferenceProcessor::discover_reference(oop obj, ReferenceType rt) {
|
||||
// time-stamp policies advance the soft-ref clock only
|
||||
// at a major collection cycle, this is always currently
|
||||
// accurate.
|
||||
if (!_current_soft_ref_policy->should_clear_reference(obj)) {
|
||||
if (!_current_soft_ref_policy->should_clear_reference(obj, _soft_ref_timestamp_clock)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
ResourceMark rm; // Needed for tracing.
|
||||
|
||||
HeapWord* const discovered_addr = java_lang_ref_Reference::discovered_addr(obj);
|
||||
const oop discovered = java_lang_ref_Reference::discovered(obj);
|
||||
assert(discovered->is_oop_or_null(), "bad discovered field");
|
||||
@ -1472,7 +1378,9 @@ ReferenceProcessor::preclean_discovered_reflist(DiscoveredList& refs_list,
|
||||
}
|
||||
|
||||
const char* ReferenceProcessor::list_name(int i) {
|
||||
assert(i >= 0 && i <= _max_num_q * subclasses_of_ref, "Out of bounds index");
|
||||
assert(i >= 0 && i <= _max_num_q * number_of_subclasses_of_ref(),
|
||||
"Out of bounds index");
|
||||
|
||||
int j = i / _max_num_q;
|
||||
switch (j) {
|
||||
case 0: return "SoftRef";
|
||||
@ -1493,7 +1401,7 @@ void ReferenceProcessor::verify_ok_to_handle_reflists() {
|
||||
#ifndef PRODUCT
|
||||
void ReferenceProcessor::clear_discovered_references() {
|
||||
guarantee(!_discovering_refs, "Discovering refs?");
|
||||
for (int i = 0; i < _max_num_q * subclasses_of_ref; i++) {
|
||||
for (int i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) {
|
||||
clear_discovered_references(_discoveredSoftRefs[i]);
|
||||
}
|
||||
}
|
||||
|
@ -48,18 +48,177 @@
|
||||
// forward references
|
||||
class ReferencePolicy;
|
||||
class AbstractRefProcTaskExecutor;
|
||||
class DiscoveredList;
|
||||
|
||||
// List of discovered references.
|
||||
class DiscoveredList {
|
||||
public:
|
||||
DiscoveredList() : _len(0), _compressed_head(0), _oop_head(NULL) { }
|
||||
oop head() const {
|
||||
return UseCompressedOops ? oopDesc::decode_heap_oop(_compressed_head) :
|
||||
_oop_head;
|
||||
}
|
||||
HeapWord* adr_head() {
|
||||
return UseCompressedOops ? (HeapWord*)&_compressed_head :
|
||||
(HeapWord*)&_oop_head;
|
||||
}
|
||||
void set_head(oop o) {
|
||||
if (UseCompressedOops) {
|
||||
// Must compress the head ptr.
|
||||
_compressed_head = oopDesc::encode_heap_oop(o);
|
||||
} else {
|
||||
_oop_head = o;
|
||||
}
|
||||
}
|
||||
bool is_empty() const { return head() == NULL; }
|
||||
size_t length() { return _len; }
|
||||
void set_length(size_t len) { _len = len; }
|
||||
void inc_length(size_t inc) { _len += inc; assert(_len > 0, "Error"); }
|
||||
void dec_length(size_t dec) { _len -= dec; }
|
||||
private:
|
||||
// Set value depending on UseCompressedOops. This could be a template class
|
||||
// but then we have to fix all the instantiations and declarations that use this class.
|
||||
oop _oop_head;
|
||||
narrowOop _compressed_head;
|
||||
size_t _len;
|
||||
};
|
||||
|
||||
// Iterator for the list of discovered references.
|
||||
class DiscoveredListIterator {
|
||||
private:
|
||||
DiscoveredList& _refs_list;
|
||||
HeapWord* _prev_next;
|
||||
oop _prev;
|
||||
oop _ref;
|
||||
HeapWord* _discovered_addr;
|
||||
oop _next;
|
||||
HeapWord* _referent_addr;
|
||||
oop _referent;
|
||||
OopClosure* _keep_alive;
|
||||
BoolObjectClosure* _is_alive;
|
||||
|
||||
DEBUG_ONLY(
|
||||
oop _first_seen; // cyclic linked list check
|
||||
)
|
||||
|
||||
NOT_PRODUCT(
|
||||
size_t _processed;
|
||||
size_t _removed;
|
||||
)
|
||||
|
||||
public:
|
||||
inline DiscoveredListIterator(DiscoveredList& refs_list,
|
||||
OopClosure* keep_alive,
|
||||
BoolObjectClosure* is_alive):
|
||||
_refs_list(refs_list),
|
||||
_prev_next(refs_list.adr_head()),
|
||||
_prev(NULL),
|
||||
_ref(refs_list.head()),
|
||||
#ifdef ASSERT
|
||||
_first_seen(refs_list.head()),
|
||||
#endif
|
||||
#ifndef PRODUCT
|
||||
_processed(0),
|
||||
_removed(0),
|
||||
#endif
|
||||
_next(NULL),
|
||||
_keep_alive(keep_alive),
|
||||
_is_alive(is_alive)
|
||||
{ }
|
||||
|
||||
// End Of List.
|
||||
inline bool has_next() const { return _ref != NULL; }
|
||||
|
||||
// Get oop to the Reference object.
|
||||
inline oop obj() const { return _ref; }
|
||||
|
||||
// Get oop to the referent object.
|
||||
inline oop referent() const { return _referent; }
|
||||
|
||||
// Returns true if referent is alive.
|
||||
inline bool is_referent_alive() const {
|
||||
return _is_alive->do_object_b(_referent);
|
||||
}
|
||||
|
||||
// Loads data for the current reference.
|
||||
// The "allow_null_referent" argument tells us to allow for the possibility
|
||||
// of a NULL referent in the discovered Reference object. This typically
|
||||
// happens in the case of concurrent collectors that may have done the
|
||||
// discovery concurrently, or interleaved, with mutator execution.
|
||||
void load_ptrs(DEBUG_ONLY(bool allow_null_referent));
|
||||
|
||||
// Move to the next discovered reference.
|
||||
inline void next() {
|
||||
_prev_next = _discovered_addr;
|
||||
_prev = _ref;
|
||||
move_to_next();
|
||||
}
|
||||
|
||||
// Remove the current reference from the list
|
||||
void remove();
|
||||
|
||||
// Make the Reference object active again.
|
||||
void make_active();
|
||||
|
||||
// Make the referent alive.
|
||||
inline void make_referent_alive() {
|
||||
if (UseCompressedOops) {
|
||||
_keep_alive->do_oop((narrowOop*)_referent_addr);
|
||||
} else {
|
||||
_keep_alive->do_oop((oop*)_referent_addr);
|
||||
}
|
||||
}
|
||||
|
||||
// Update the discovered field.
|
||||
inline void update_discovered() {
|
||||
// First _prev_next ref actually points into DiscoveredList (gross).
|
||||
if (UseCompressedOops) {
|
||||
if (!oopDesc::is_null(*(narrowOop*)_prev_next)) {
|
||||
_keep_alive->do_oop((narrowOop*)_prev_next);
|
||||
}
|
||||
} else {
|
||||
if (!oopDesc::is_null(*(oop*)_prev_next)) {
|
||||
_keep_alive->do_oop((oop*)_prev_next);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NULL out referent pointer.
|
||||
void clear_referent();
|
||||
|
||||
// Statistics
|
||||
NOT_PRODUCT(
|
||||
inline size_t processed() const { return _processed; }
|
||||
inline size_t removed() const { return _removed; }
|
||||
)
|
||||
|
||||
inline void move_to_next() {
|
||||
if (_ref == _next) {
|
||||
// End of the list.
|
||||
_ref = NULL;
|
||||
} else {
|
||||
_ref = _next;
|
||||
}
|
||||
assert(_ref != _first_seen, "cyclic ref_list found");
|
||||
NOT_PRODUCT(_processed++);
|
||||
}
|
||||
};
|
||||
|
||||
class ReferenceProcessor : public CHeapObj {
|
||||
protected:
|
||||
// Compatibility with pre-4965777 JDK's
|
||||
static bool _pending_list_uses_discovered_field;
|
||||
MemRegion _span; // (right-open) interval of heap
|
||||
// subject to wkref discovery
|
||||
bool _discovering_refs; // true when discovery enabled
|
||||
bool _discovery_is_atomic; // if discovery is atomic wrt
|
||||
// other collectors in configuration
|
||||
bool _discovery_is_mt; // true if reference discovery is MT.
|
||||
|
||||
// The SoftReference master timestamp clock
|
||||
static jlong _soft_ref_timestamp_clock;
|
||||
|
||||
MemRegion _span; // (right-open) interval of heap
|
||||
// subject to wkref discovery
|
||||
|
||||
bool _discovering_refs; // true when discovery enabled
|
||||
bool _discovery_is_atomic; // if discovery is atomic wrt
|
||||
// other collectors in configuration
|
||||
bool _discovery_is_mt; // true if reference discovery is MT.
|
||||
|
||||
// If true, setting "next" field of a discovered refs list requires
|
||||
// write barrier(s). (Must be true if used in a collector in which
|
||||
// elements of a discovered list may be moved during discovery: for
|
||||
@ -67,18 +226,19 @@ class ReferenceProcessor : public CHeapObj {
|
||||
// long-term concurrent marking phase that does weak reference
|
||||
// discovery.)
|
||||
bool _discovered_list_needs_barrier;
|
||||
BarrierSet* _bs; // Cached copy of BarrierSet.
|
||||
bool _enqueuing_is_done; // true if all weak references enqueued
|
||||
bool _processing_is_mt; // true during phases when
|
||||
// reference processing is MT.
|
||||
int _next_id; // round-robin mod _num_q counter in
|
||||
// support of work distribution
|
||||
|
||||
// For collectors that do not keep GC marking information
|
||||
BarrierSet* _bs; // Cached copy of BarrierSet.
|
||||
bool _enqueuing_is_done; // true if all weak references enqueued
|
||||
bool _processing_is_mt; // true during phases when
|
||||
// reference processing is MT.
|
||||
int _next_id; // round-robin mod _num_q counter in
|
||||
// support of work distribution
|
||||
|
||||
// For collectors that do not keep GC liveness information
|
||||
// in the object header, this field holds a closure that
|
||||
// helps the reference processor determine the reachability
|
||||
// of an oop (the field is currently initialized to NULL for
|
||||
// all collectors but the CMS collector).
|
||||
// of an oop. It is currently initialized to NULL for all
|
||||
// collectors except for CMS and G1.
|
||||
BoolObjectClosure* _is_alive_non_header;
|
||||
|
||||
// Soft ref clearing policies
|
||||
@ -102,10 +262,13 @@ class ReferenceProcessor : public CHeapObj {
|
||||
DiscoveredList* _discoveredPhantomRefs;
|
||||
|
||||
public:
|
||||
int num_q() { return _num_q; }
|
||||
int max_num_q() { return _max_num_q; }
|
||||
void set_active_mt_degree(int v) { _num_q = v; }
|
||||
DiscoveredList* discovered_soft_refs() { return _discoveredSoftRefs; }
|
||||
static int number_of_subclasses_of_ref() { return (REF_PHANTOM - REF_OTHER); }
|
||||
|
||||
int num_q() { return _num_q; }
|
||||
int max_num_q() { return _max_num_q; }
|
||||
void set_active_mt_degree(int v) { _num_q = v; }
|
||||
DiscoveredList* discovered_soft_refs() { return _discoveredSoftRefs; }
|
||||
|
||||
ReferencePolicy* setup_policy(bool always_clear) {
|
||||
_current_soft_ref_policy = always_clear ?
|
||||
_always_clear_soft_ref_policy : _default_soft_ref_policy;
|
||||
@ -205,6 +368,11 @@ class ReferenceProcessor : public CHeapObj {
|
||||
void enqueue_discovered_reflists(HeapWord* pending_list_addr, AbstractRefProcTaskExecutor* task_executor);
|
||||
|
||||
protected:
|
||||
// Set the 'discovered' field of the given reference to
|
||||
// the given value - emitting barriers depending upon
|
||||
// the value of _discovered_list_needs_barrier.
|
||||
void set_discovered(oop ref, oop value);
|
||||
|
||||
// "Preclean" the given discovered reference list
|
||||
// by removing references with strongly reachable referents.
|
||||
// Currently used in support of CMS only.
|
||||
@ -290,7 +458,7 @@ class ReferenceProcessor : public CHeapObj {
|
||||
void set_span(MemRegion span) { _span = span; }
|
||||
|
||||
// start and stop weak ref discovery
|
||||
void enable_discovery() { _discovering_refs = true; }
|
||||
void enable_discovery(bool verify_disabled, bool check_no_refs);
|
||||
void disable_discovery() { _discovering_refs = false; }
|
||||
bool discovery_enabled() { return _discovering_refs; }
|
||||
|
||||
@ -365,7 +533,7 @@ class NoRefDiscovery: StackObj {
|
||||
|
||||
~NoRefDiscovery() {
|
||||
if (_was_discovering_refs) {
|
||||
_rp->enable_discovery();
|
||||
_rp->enable_discovery(true /*verify_disabled*/, false /*check_no_refs*/);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -753,8 +753,9 @@ bool Thread::claim_oops_do_par_case(int strong_roots_parity) {
|
||||
jint thread_parity = _oops_do_parity;
|
||||
if (thread_parity != strong_roots_parity) {
|
||||
jint res = Atomic::cmpxchg(strong_roots_parity, &_oops_do_parity, thread_parity);
|
||||
if (res == thread_parity) return true;
|
||||
else {
|
||||
if (res == thread_parity) {
|
||||
return true;
|
||||
} else {
|
||||
guarantee(res == strong_roots_parity, "Or else what?");
|
||||
assert(SharedHeap::heap()->n_par_threads() > 0,
|
||||
"Should only fail when parallel.");
|
||||
@ -3909,8 +3910,9 @@ void Threads::possibly_parallel_oops_do(OopClosure* f, CodeBlobClosure* cf) {
|
||||
}
|
||||
}
|
||||
VMThread* vmt = VMThread::vm_thread();
|
||||
if (vmt->claim_oops_do(is_par, cp))
|
||||
if (vmt->claim_oops_do(is_par, cp)) {
|
||||
vmt->oops_do(f, cf);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef SERIALGC
|
||||
|
@ -182,6 +182,7 @@
|
||||
#include "gc_implementation/parallelScavenge/psVirtualspace.hpp"
|
||||
#include "gc_implementation/parallelScavenge/psYoungGen.hpp"
|
||||
#include "gc_implementation/parallelScavenge/vmStructs_parallelgc.hpp"
|
||||
#include "gc_implementation/g1/vmStructs_g1.hpp"
|
||||
#endif
|
||||
#ifdef COMPILER2
|
||||
#include "opto/addnode.hpp"
|
||||
@ -2878,6 +2879,9 @@ VMStructEntry VMStructs::localHotSpotVMStructs[] = {
|
||||
VM_STRUCTS_CMS(GENERATE_NONSTATIC_VM_STRUCT_ENTRY, \
|
||||
GENERATE_NONSTATIC_VM_STRUCT_ENTRY, \
|
||||
GENERATE_STATIC_VM_STRUCT_ENTRY)
|
||||
|
||||
VM_STRUCTS_G1(GENERATE_NONSTATIC_VM_STRUCT_ENTRY, \
|
||||
GENERATE_STATIC_VM_STRUCT_ENTRY)
|
||||
#endif // SERIALGC
|
||||
|
||||
VM_STRUCTS_CPU(GENERATE_NONSTATIC_VM_STRUCT_ENTRY, \
|
||||
@ -2921,6 +2925,9 @@ VMTypeEntry VMStructs::localHotSpotVMTypes[] = {
|
||||
GENERATE_TOPLEVEL_VM_TYPE_ENTRY)
|
||||
|
||||
VM_TYPES_PARNEW(GENERATE_VM_TYPE_ENTRY)
|
||||
|
||||
VM_TYPES_G1(GENERATE_VM_TYPE_ENTRY,
|
||||
GENERATE_TOPLEVEL_VM_TYPE_ENTRY)
|
||||
#endif // SERIALGC
|
||||
|
||||
VM_TYPES_CPU(GENERATE_VM_TYPE_ENTRY,
|
||||
@ -3020,6 +3027,9 @@ VMStructs::init() {
|
||||
VM_STRUCTS_CMS(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
|
||||
CHECK_VOLATILE_NONSTATIC_VM_STRUCT_ENTRY,
|
||||
CHECK_STATIC_VM_STRUCT_ENTRY);
|
||||
|
||||
VM_STRUCTS_G1(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
|
||||
CHECK_STATIC_VM_STRUCT_ENTRY);
|
||||
#endif // SERIALGC
|
||||
|
||||
VM_STRUCTS_CPU(CHECK_NONSTATIC_VM_STRUCT_ENTRY,
|
||||
@ -3060,6 +3070,9 @@ VMStructs::init() {
|
||||
CHECK_SINGLE_ARG_VM_TYPE_NO_OP);
|
||||
|
||||
VM_TYPES_PARNEW(CHECK_VM_TYPE_ENTRY)
|
||||
|
||||
VM_TYPES_G1(CHECK_VM_TYPE_ENTRY,
|
||||
CHECK_SINGLE_ARG_VM_TYPE_NO_OP);
|
||||
#endif // SERIALGC
|
||||
|
||||
VM_TYPES_CPU(CHECK_VM_TYPE_ENTRY,
|
||||
@ -3125,6 +3138,8 @@ VMStructs::init() {
|
||||
debug_only(VM_STRUCTS_CMS(ENSURE_FIELD_TYPE_PRESENT, \
|
||||
ENSURE_FIELD_TYPE_PRESENT, \
|
||||
ENSURE_FIELD_TYPE_PRESENT));
|
||||
debug_only(VM_STRUCTS_G1(ENSURE_FIELD_TYPE_PRESENT, \
|
||||
ENSURE_FIELD_TYPE_PRESENT));
|
||||
#endif // SERIALGC
|
||||
debug_only(VM_STRUCTS_CPU(ENSURE_FIELD_TYPE_PRESENT, \
|
||||
ENSURE_FIELD_TYPE_PRESENT, \
|
||||
|
@ -32,71 +32,44 @@
|
||||
G1MemoryPoolSuper::G1MemoryPoolSuper(G1CollectedHeap* g1h,
|
||||
const char* name,
|
||||
size_t init_size,
|
||||
size_t max_size,
|
||||
bool support_usage_threshold) :
|
||||
_g1h(g1h), CollectedMemoryPool(name,
|
||||
MemoryPool::Heap,
|
||||
init_size,
|
||||
undefined_max(),
|
||||
support_usage_threshold) {
|
||||
_g1mm(g1h->g1mm()), CollectedMemoryPool(name,
|
||||
MemoryPool::Heap,
|
||||
init_size,
|
||||
max_size,
|
||||
support_usage_threshold) {
|
||||
assert(UseG1GC, "sanity");
|
||||
}
|
||||
|
||||
// See the comment at the top of g1MemoryPool.hpp
|
||||
size_t G1MemoryPoolSuper::eden_space_committed(G1CollectedHeap* g1h) {
|
||||
return MAX2(eden_space_used(g1h), (size_t) HeapRegion::GrainBytes);
|
||||
}
|
||||
|
||||
// See the comment at the top of g1MemoryPool.hpp
|
||||
size_t G1MemoryPoolSuper::eden_space_used(G1CollectedHeap* g1h) {
|
||||
return g1h->g1mm()->eden_space_used();
|
||||
}
|
||||
|
||||
// See the comment at the top of g1MemoryPool.hpp
|
||||
size_t G1MemoryPoolSuper::survivor_space_committed(G1CollectedHeap* g1h) {
|
||||
return g1h->g1mm()->survivor_space_committed();
|
||||
}
|
||||
|
||||
// See the comment at the top of g1MemoryPool.hpp
|
||||
size_t G1MemoryPoolSuper::survivor_space_used(G1CollectedHeap* g1h) {
|
||||
return g1h->g1mm()->survivor_space_used();
|
||||
}
|
||||
|
||||
// See the comment at the top of g1MemoryPool.hpp
|
||||
size_t G1MemoryPoolSuper::old_space_committed(G1CollectedHeap* g1h) {
|
||||
return g1h->g1mm()->old_space_committed();
|
||||
}
|
||||
|
||||
// See the comment at the top of g1MemoryPool.hpp
|
||||
size_t G1MemoryPoolSuper::old_space_used(G1CollectedHeap* g1h) {
|
||||
return g1h->g1mm()->old_space_used();
|
||||
}
|
||||
|
||||
G1EdenPool::G1EdenPool(G1CollectedHeap* g1h) :
|
||||
G1MemoryPoolSuper(g1h,
|
||||
"G1 Eden",
|
||||
eden_space_committed(g1h), /* init_size */
|
||||
"G1 Eden Space",
|
||||
g1h->g1mm()->eden_space_committed(), /* init_size */
|
||||
_undefined_max,
|
||||
false /* support_usage_threshold */) { }
|
||||
|
||||
MemoryUsage G1EdenPool::get_memory_usage() {
|
||||
size_t initial_sz = initial_size();
|
||||
size_t max_sz = max_size();
|
||||
size_t used = used_in_bytes();
|
||||
size_t committed = eden_space_committed(_g1h);
|
||||
size_t committed = _g1mm->eden_space_committed();
|
||||
|
||||
return MemoryUsage(initial_sz, used, committed, max_sz);
|
||||
}
|
||||
|
||||
G1SurvivorPool::G1SurvivorPool(G1CollectedHeap* g1h) :
|
||||
G1MemoryPoolSuper(g1h,
|
||||
"G1 Survivor",
|
||||
survivor_space_committed(g1h), /* init_size */
|
||||
"G1 Survivor Space",
|
||||
g1h->g1mm()->survivor_space_committed(), /* init_size */
|
||||
_undefined_max,
|
||||
false /* support_usage_threshold */) { }
|
||||
|
||||
MemoryUsage G1SurvivorPool::get_memory_usage() {
|
||||
size_t initial_sz = initial_size();
|
||||
size_t max_sz = max_size();
|
||||
size_t used = used_in_bytes();
|
||||
size_t committed = survivor_space_committed(_g1h);
|
||||
size_t committed = _g1mm->survivor_space_committed();
|
||||
|
||||
return MemoryUsage(initial_sz, used, committed, max_sz);
|
||||
}
|
||||
@ -104,14 +77,15 @@ MemoryUsage G1SurvivorPool::get_memory_usage() {
|
||||
G1OldGenPool::G1OldGenPool(G1CollectedHeap* g1h) :
|
||||
G1MemoryPoolSuper(g1h,
|
||||
"G1 Old Gen",
|
||||
old_space_committed(g1h), /* init_size */
|
||||
g1h->g1mm()->old_space_committed(), /* init_size */
|
||||
_undefined_max,
|
||||
true /* support_usage_threshold */) { }
|
||||
|
||||
MemoryUsage G1OldGenPool::get_memory_usage() {
|
||||
size_t initial_sz = initial_size();
|
||||
size_t max_sz = max_size();
|
||||
size_t used = used_in_bytes();
|
||||
size_t committed = old_space_committed(_g1h);
|
||||
size_t committed = _g1mm->old_space_committed();
|
||||
|
||||
return MemoryUsage(initial_sz, used, committed, max_sz);
|
||||
}
|
||||
|
@ -26,12 +26,11 @@
|
||||
#define SHARE_VM_SERVICES_G1MEMORYPOOL_HPP
|
||||
|
||||
#ifndef SERIALGC
|
||||
#include "gc_implementation/g1/g1MonitoringSupport.hpp"
|
||||
#include "services/memoryPool.hpp"
|
||||
#include "services/memoryUsage.hpp"
|
||||
#endif
|
||||
|
||||
class G1CollectedHeap;
|
||||
|
||||
// This file contains the three classes that represent the memory
|
||||
// pools of the G1 spaces: G1EdenPool, G1SurvivorPool, and
|
||||
// G1OldGenPool. In G1, unlike our other GCs, we do not have a
|
||||
@ -50,37 +49,19 @@ class G1CollectedHeap;
|
||||
// on this model.
|
||||
//
|
||||
|
||||
|
||||
// This class is shared by the three G1 memory pool classes
|
||||
// (G1EdenPool, G1SurvivorPool, G1OldGenPool). Given that the way we
|
||||
// calculate used / committed bytes for these three pools is related
|
||||
// (see comment above), we put the calculations in this class so that
|
||||
// we can easily share them among the subclasses.
|
||||
// (G1EdenPool, G1SurvivorPool, G1OldGenPool).
|
||||
class G1MemoryPoolSuper : public CollectedMemoryPool {
|
||||
protected:
|
||||
G1CollectedHeap* _g1h;
|
||||
const static size_t _undefined_max = (size_t) -1;
|
||||
G1MonitoringSupport* _g1mm;
|
||||
|
||||
// Would only be called from subclasses.
|
||||
G1MemoryPoolSuper(G1CollectedHeap* g1h,
|
||||
const char* name,
|
||||
size_t init_size,
|
||||
size_t max_size,
|
||||
bool support_usage_threshold);
|
||||
|
||||
// The reason why all the code is in static methods is so that it
|
||||
// can be safely called from the constructors of the subclasses.
|
||||
|
||||
static size_t undefined_max() {
|
||||
return (size_t) -1;
|
||||
}
|
||||
|
||||
static size_t eden_space_committed(G1CollectedHeap* g1h);
|
||||
static size_t eden_space_used(G1CollectedHeap* g1h);
|
||||
|
||||
static size_t survivor_space_committed(G1CollectedHeap* g1h);
|
||||
static size_t survivor_space_used(G1CollectedHeap* g1h);
|
||||
|
||||
static size_t old_space_committed(G1CollectedHeap* g1h);
|
||||
static size_t old_space_used(G1CollectedHeap* g1h);
|
||||
};
|
||||
|
||||
// Memory pool that represents the G1 eden.
|
||||
@ -89,10 +70,10 @@ public:
|
||||
G1EdenPool(G1CollectedHeap* g1h);
|
||||
|
||||
size_t used_in_bytes() {
|
||||
return eden_space_used(_g1h);
|
||||
return _g1mm->eden_space_used();
|
||||
}
|
||||
size_t max_size() const {
|
||||
return undefined_max();
|
||||
return _undefined_max;
|
||||
}
|
||||
MemoryUsage get_memory_usage();
|
||||
};
|
||||
@ -103,10 +84,10 @@ public:
|
||||
G1SurvivorPool(G1CollectedHeap* g1h);
|
||||
|
||||
size_t used_in_bytes() {
|
||||
return survivor_space_used(_g1h);
|
||||
return _g1mm->survivor_space_used();
|
||||
}
|
||||
size_t max_size() const {
|
||||
return undefined_max();
|
||||
return _undefined_max;
|
||||
}
|
||||
MemoryUsage get_memory_usage();
|
||||
};
|
||||
@ -117,10 +98,10 @@ public:
|
||||
G1OldGenPool(G1CollectedHeap* g1h);
|
||||
|
||||
size_t used_in_bytes() {
|
||||
return old_space_used(_g1h);
|
||||
return _g1mm->old_space_used();
|
||||
}
|
||||
size_t max_size() const {
|
||||
return undefined_max();
|
||||
return _undefined_max;
|
||||
}
|
||||
MemoryUsage get_memory_usage();
|
||||
};
|
||||
|
@ -54,16 +54,18 @@ static int test_even_odd_comparator(int a, int b) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int test_stdlib_comparator(const void* a, const void* b) {
|
||||
int ai = *(int*)a;
|
||||
int bi = *(int*)b;
|
||||
if (ai == bi) {
|
||||
return 0;
|
||||
extern "C" {
|
||||
static int test_stdlib_comparator(const void* a, const void* b) {
|
||||
int ai = *(int*)a;
|
||||
int bi = *(int*)b;
|
||||
if (ai == bi) {
|
||||
return 0;
|
||||
}
|
||||
if (ai < bi) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
if (ai < bi) {
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void QuickSort::print_array(const char* prefix, int* array, int length) {
|
||||
@ -92,7 +94,6 @@ bool QuickSort::sort_and_compare(int* arrayToSort, int* expectedResult, int leng
|
||||
}
|
||||
|
||||
bool QuickSort::test_quick_sort() {
|
||||
#if 0
|
||||
tty->print_cr("test_quick_sort\n");
|
||||
{
|
||||
int* test_array = NULL;
|
||||
@ -213,7 +214,6 @@ bool QuickSort::test_quick_sort() {
|
||||
delete[] test_array;
|
||||
delete[] expected_array;
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -130,3 +130,4 @@ ff0a3d78e7a22743eabbaa71e9d17b2f094ddf62 jdk8-b05
|
||||
d7b8192e7277c49b9c702f4c4fd99bd83ba947ea jdk8-b06
|
||||
c114306576dcc1cb871a48058b41bf7d87ce882a jdk8-b07
|
||||
de4794dd69c48b08029d158a972993ff9d5627df jdk8-b08
|
||||
93554324c014282571aeeb48552ad00d3fedb089 jdk8-b09
|
||||
|
@ -130,3 +130,4 @@ d13b1f877bb5ed8dceb2f7ec10365d1db5f70b2d jdk7-b147
|
||||
acffff22a9465005e8eb206224fae9f2ea4fd469 jdk8-b06
|
||||
134b0debf7b04fe6e317394b04b8e7a4a0181b1b jdk8-b07
|
||||
1c9d4f59acf8f71477473c170239b43b2c9dee24 jdk8-b08
|
||||
70172e57cf29efe271b068987eefb601c2a77780 jdk8-b09
|
||||
|
@ -130,3 +130,4 @@ fc569517f3cf242f90ce3503b743eb5553938946 jdk8-b04
|
||||
bdb870cc269ef8b221d17a217be89092400b59d2 jdk8-b06
|
||||
19f0a3db863cc491affc78b48c4a81a6679b2433 jdk8-b07
|
||||
1c023bcd0c5a01ac07bc7eea728aafbb0d8991e9 jdk8-b08
|
||||
f1ec21b8142168ff40f3278d2f6b5fe4bd5f3b26 jdk8-b09
|
||||
|
@ -30,6 +30,8 @@
|
||||
BUILDDIR = ../../../../..
|
||||
PACKAGE = com.sun.org.apache.xml
|
||||
PRODUCT = xml
|
||||
JAVAC_MAX_WARNINGS = true
|
||||
JAVAC_WARNINGS_FATAL = true
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
#
|
||||
|
@ -373,6 +373,7 @@ endif
|
||||
override LIBPOSIX4 =
|
||||
override LIBSOCKET =
|
||||
override LIBNSL =
|
||||
override LIBSCF =
|
||||
override LIBTHREAD =
|
||||
override MOOT_PRIORITIES = true
|
||||
override NO_INTERRUPTIBLE_IO = true
|
||||
|
@ -711,6 +711,9 @@ LIBSOCKET = -lsocket
|
||||
# Network Services library
|
||||
LIBNSL = -lnsl
|
||||
|
||||
# service configuration facility library
|
||||
LIBSCF = -lscf
|
||||
|
||||
# GLOBAL_KPIC: If set means all libraries are PIC, position independent code
|
||||
# EXCEPT for select compiles
|
||||
# If a .o file is compiled non-PIC then it should be forced
|
||||
|
@ -208,7 +208,7 @@ OTHER_LDLIBS += $(JVMLIB) -libpath:$(OBJDIR)/../../../fdlibm/$(OBJDIRNAME) fdlib
|
||||
-libpath:$(OBJDIR)/../../../verify/$(OBJDIRNAME) verify.lib \
|
||||
shell32.lib delayimp.lib /DELAYLOAD:shell32.dll
|
||||
else
|
||||
OTHER_LDLIBS += $(JVMLIB) -lverify $(LIBSOCKET) $(LIBNSL) -ldl \
|
||||
OTHER_LDLIBS += $(JVMLIB) -lverify $(LIBSOCKET) $(LIBNSL) $(LIBSCF) -ldl \
|
||||
-L$(OBJDIR)/../../../fdlibm/$(OBJDIRNAME) -lfdlibm.$(ARCH)
|
||||
endif
|
||||
|
||||
|
@ -26,8 +26,8 @@
|
||||
BUILDDIR = ../..
|
||||
PACKAGE = java.security
|
||||
PRODUCT = sun
|
||||
JAVAC_MAX_WARNINGS = false
|
||||
JAVAC_LINT_OPTIONS = -Xlint:all,-deprecation
|
||||
JAVAC_MAX_WARNINGS = true
|
||||
JAVAC_LINT_OPTIONS = -Xlint:all
|
||||
JAVAC_WARNINGS_FATAL = true
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
BUILDDIR = ..
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
SUBDIRS = others
|
||||
SUBDIRS = others security
|
||||
|
||||
SUBDIRS_management = management
|
||||
|
||||
|
@ -38,10 +38,6 @@ AUTO_FILES_JAVA_DIRS = \
|
||||
com/sun/naming/internal \
|
||||
javax/net \
|
||||
javax/script \
|
||||
javax/security/auth \
|
||||
javax/security/cert \
|
||||
javax/security/sasl \
|
||||
javax/smartcardio \
|
||||
javax/tools \
|
||||
javax/xml
|
||||
|
||||
|
49
jdk/make/javax/security/Makefile
Normal file
49
jdk/make/javax/security/Makefile
Normal file
@ -0,0 +1,49 @@
|
||||
#
|
||||
# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 only, as
|
||||
# published by the Free Software Foundation. Oracle designates this
|
||||
# particular file as subject to the "Classpath" exception as provided
|
||||
# by Oracle in the LICENSE file that accompanied this code.
|
||||
#
|
||||
# This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
# version 2 for more details (a copy is included in the LICENSE file that
|
||||
# accompanied this code).
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License version
|
||||
# 2 along with this work; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
#
|
||||
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
# or visit www.oracle.com if you need additional information or have any
|
||||
# questions.
|
||||
#
|
||||
|
||||
#
|
||||
# Makefile for building javax (security classes)
|
||||
#
|
||||
|
||||
BUILDDIR = ../..
|
||||
JAVAC_MAX_WARNINGS = true
|
||||
JAVAC_WARNINGS_FATAL = true
|
||||
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
#
|
||||
# Files to compile
|
||||
#
|
||||
AUTO_FILES_JAVA_DIRS = \
|
||||
javax/security/auth \
|
||||
javax/security/cert \
|
||||
javax/security/sasl \
|
||||
javax/smartcardio
|
||||
|
||||
#
|
||||
# Rules
|
||||
#
|
||||
include $(BUILDDIR)/common/Classes.gmk
|
||||
|
@ -26,6 +26,8 @@
|
||||
BUILDDIR = ../../..
|
||||
PACKAGE = org.ietf.jgss
|
||||
PRODUCT = sun
|
||||
JAVAC_MAX_WARNINGS = true
|
||||
JAVAC_WARNINGS_FATAL = true
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
||||
#
|
||||
|
@ -26,7 +26,7 @@
|
||||
BUILDDIR = ../../..
|
||||
PACKAGE = sun.security.other
|
||||
PRODUCT = sun
|
||||
JAVAC_MAX_WARNINGS=false
|
||||
JAVAC_MAX_WARNINGS=true
|
||||
JAVAC_LINT_OPTIONS=-Xlint:all,-deprecation
|
||||
JAVAC_WARNINGS_FATAL=true
|
||||
include $(BUILDDIR)/common/Defs.gmk
|
||||
|
@ -32,6 +32,7 @@ import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.net.Socket;
|
||||
import javax.net.ssl.SSLSocket;
|
||||
|
||||
import javax.naming.CommunicationException;
|
||||
import javax.naming.ServiceUnavailableException;
|
||||
@ -361,6 +362,19 @@ public final class Connection implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
// For LDAP connect timeouts on LDAP over SSL connections must treat
|
||||
// the SSL handshake following socket connection as part of the timeout.
|
||||
// So explicitly set a socket read timeout, trigger the SSL handshake,
|
||||
// then reset the timeout.
|
||||
if (connectTimeout > 0 && socket instanceof SSLSocket) {
|
||||
SSLSocket sslSocket = (SSLSocket) socket;
|
||||
int socketTimeout = sslSocket.getSoTimeout();
|
||||
|
||||
sslSocket.setSoTimeout(connectTimeout); // reuse full timeout value
|
||||
sslSocket.startHandshake();
|
||||
sslSocket.setSoTimeout(socketTimeout);
|
||||
}
|
||||
|
||||
return socket;
|
||||
}
|
||||
|
||||
|
@ -115,9 +115,9 @@ public final class Init {
|
||||
// provider mechanism instead if implementing their own
|
||||
// transform or canonicalization algorithms.
|
||||
// InputStream is = Class.forName("com.sun.org.apache.xml.internal.security.Init").getResourceAsStream("resource/config.xml");
|
||||
InputStream is = (InputStream) AccessController.doPrivileged(
|
||||
new PrivilegedAction() {
|
||||
public Object run() {
|
||||
InputStream is = AccessController.doPrivileged(
|
||||
new PrivilegedAction<InputStream>() {
|
||||
public InputStream run() {
|
||||
// String cfile = System.getProperty
|
||||
// ("com.sun.org.apache.xml.internal.security.resource.config");
|
||||
return getClass().getResourceAsStream
|
||||
|
@ -45,9 +45,9 @@ public class JCEMapper {
|
||||
|
||||
|
||||
|
||||
private static Map uriToJCEName;
|
||||
private static Map<String, String> uriToJCEName;
|
||||
|
||||
private static Map algorithmsMap;
|
||||
private static Map<String, Algorithm> algorithmsMap;
|
||||
|
||||
private static String providerName = null;
|
||||
/**
|
||||
@ -63,8 +63,8 @@ public class JCEMapper {
|
||||
|
||||
static void loadAlgorithms( Element algorithmsEl) {
|
||||
Element[] algorithms = XMLUtils.selectNodes(algorithmsEl.getFirstChild(),Init.CONF_NS,"Algorithm");
|
||||
uriToJCEName = new HashMap( algorithms.length * 2);
|
||||
algorithmsMap = new HashMap( algorithms.length * 2);
|
||||
uriToJCEName = new HashMap<String, String>( algorithms.length * 2);
|
||||
algorithmsMap = new HashMap<String, Algorithm>( algorithms.length * 2);
|
||||
for (int i = 0 ;i < algorithms.length ;i ++) {
|
||||
Element el = algorithms[i];
|
||||
String id = el.getAttribute("URI");
|
||||
@ -76,7 +76,7 @@ public class JCEMapper {
|
||||
}
|
||||
|
||||
static Algorithm getAlgorithmMapping(String algoURI) {
|
||||
return ((Algorithm)algorithmsMap.get(algoURI));
|
||||
return algorithmsMap.get(algoURI);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -90,7 +90,7 @@ public class JCEMapper {
|
||||
if (log.isLoggable(java.util.logging.Level.FINE))
|
||||
log.log(java.util.logging.Level.FINE, "Request for URI " + AlgorithmURI);
|
||||
|
||||
String jceName = (String) uriToJCEName.get(AlgorithmURI);
|
||||
String jceName = uriToJCEName.get(AlgorithmURI);
|
||||
return jceName;
|
||||
}
|
||||
|
||||
@ -106,7 +106,7 @@ public class JCEMapper {
|
||||
if (log.isLoggable(java.util.logging.Level.FINE))
|
||||
log.log(java.util.logging.Level.FINE, "Request for URI " + AlgorithmURI);
|
||||
|
||||
return ((Algorithm) algorithmsMap.get(AlgorithmURI)).algorithmClass;
|
||||
return (algorithmsMap.get(AlgorithmURI)).algorithmClass;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -116,7 +116,7 @@ public class JCEMapper {
|
||||
* @return The length of the key used in the alogrithm
|
||||
*/
|
||||
public static int getKeyLengthFromURI(String AlgorithmURI) {
|
||||
return Integer.parseInt(((Algorithm) algorithmsMap.get(AlgorithmURI)).keyLength);
|
||||
return Integer.parseInt((algorithmsMap.get(AlgorithmURI)).keyLength);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -128,7 +128,7 @@ public class JCEMapper {
|
||||
*/
|
||||
public static String getJCEKeyAlgorithmFromURI(String AlgorithmURI) {
|
||||
|
||||
return ((Algorithm) algorithmsMap.get(AlgorithmURI)).requiredKey;
|
||||
return (algorithmsMap.get(AlgorithmURI)).requiredKey;
|
||||
|
||||
}
|
||||
|
||||
|
@ -71,9 +71,10 @@ public class MessageDigestAlgorithm extends Algorithm {
|
||||
this.algorithm = messageDigest;
|
||||
}
|
||||
|
||||
static ThreadLocal instances=new ThreadLocal() {
|
||||
protected Object initialValue() {
|
||||
return new HashMap();
|
||||
static ThreadLocal<Map<String, MessageDigest>> instances=new
|
||||
ThreadLocal<Map<String, MessageDigest>>() {
|
||||
protected Map<String, MessageDigest> initialValue() {
|
||||
return new HashMap<String, MessageDigest>();
|
||||
};
|
||||
};
|
||||
|
||||
@ -92,7 +93,7 @@ public class MessageDigestAlgorithm extends Algorithm {
|
||||
}
|
||||
|
||||
private static MessageDigest getDigestInstance(String algorithmURI) throws XMLSignatureException {
|
||||
MessageDigest result=(MessageDigest) ((Map)instances.get()).get(algorithmURI);
|
||||
MessageDigest result= instances.get().get(algorithmURI);
|
||||
if (result!=null)
|
||||
return result;
|
||||
String algorithmID = JCEMapper.translateURItoJCEID(algorithmURI);
|
||||
@ -121,7 +122,7 @@ private static MessageDigest getDigestInstance(String algorithmURI) throws XMLSi
|
||||
|
||||
throw new XMLSignatureException("algorithms.NoSuchAlgorithm", exArgs);
|
||||
}
|
||||
((Map)instances.get()).put(algorithmURI, md);
|
||||
instances.get().put(algorithmURI, md);
|
||||
return md;
|
||||
}
|
||||
|
||||
|
53
jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java
53
jdk/src/share/classes/com/sun/org/apache/xml/internal/security/algorithms/SignatureAlgorithm.java
@ -51,28 +51,28 @@ public class SignatureAlgorithm extends Algorithm {
|
||||
static boolean _alreadyInitialized = false;
|
||||
|
||||
/** All available algorithm classes are registered here */
|
||||
static HashMap _algorithmHash = null;
|
||||
static Map<String, Class<? extends SignatureAlgorithmSpi>> _algorithmHash = null;
|
||||
|
||||
static ThreadLocal instancesSigning=new ThreadLocal() {
|
||||
protected Object initialValue() {
|
||||
return new HashMap();
|
||||
static ThreadLocal<Map<String, SignatureAlgorithmSpi>> instancesSigning=new ThreadLocal<Map<String, SignatureAlgorithmSpi>>() {
|
||||
protected Map<String, SignatureAlgorithmSpi> initialValue() {
|
||||
return new HashMap<String, SignatureAlgorithmSpi>();
|
||||
};
|
||||
};
|
||||
|
||||
static ThreadLocal instancesVerify=new ThreadLocal() {
|
||||
protected Object initialValue() {
|
||||
return new HashMap();
|
||||
static ThreadLocal<Map<String, SignatureAlgorithmSpi>> instancesVerify=new ThreadLocal<Map<String, SignatureAlgorithmSpi>>() {
|
||||
protected Map<String, SignatureAlgorithmSpi> initialValue() {
|
||||
return new HashMap<String, SignatureAlgorithmSpi>();
|
||||
};
|
||||
};
|
||||
|
||||
static ThreadLocal keysSigning=new ThreadLocal() {
|
||||
protected Object initialValue() {
|
||||
return new HashMap();
|
||||
static ThreadLocal<Map<String, Key>> keysSigning=new ThreadLocal<Map<String, Key>>() {
|
||||
protected Map<String, Key> initialValue() {
|
||||
return new HashMap<String, Key>();
|
||||
};
|
||||
};
|
||||
static ThreadLocal keysVerify=new ThreadLocal() {
|
||||
protected Object initialValue() {
|
||||
return new HashMap();
|
||||
static ThreadLocal<Map<String, Key>> keysVerify=new ThreadLocal<Map<String, Key>>() {
|
||||
protected Map<String, Key> initialValue() {
|
||||
return new HashMap<String, Key>();
|
||||
};
|
||||
};
|
||||
// boolean isForSigning=false;
|
||||
@ -105,34 +105,34 @@ public class SignatureAlgorithm extends Algorithm {
|
||||
.engineGetContextFromElement(this._constructionElement);
|
||||
}
|
||||
private static SignatureAlgorithmSpi getInstanceForSigning(String algorithmURI) throws XMLSignatureException {
|
||||
SignatureAlgorithmSpi result=(SignatureAlgorithmSpi) ((Map)instancesSigning.get()).get(algorithmURI);
|
||||
SignatureAlgorithmSpi result= instancesSigning.get().get(algorithmURI);
|
||||
if (result!=null) {
|
||||
result.reset();
|
||||
return result;
|
||||
}
|
||||
result=buildSigner(algorithmURI, result);
|
||||
((Map)instancesSigning.get()).put(algorithmURI,result);
|
||||
instancesSigning.get().put(algorithmURI,result);
|
||||
return result;
|
||||
}
|
||||
private static SignatureAlgorithmSpi getInstanceForVerify(String algorithmURI) throws XMLSignatureException {
|
||||
SignatureAlgorithmSpi result=(SignatureAlgorithmSpi) ((Map)instancesVerify.get()).get(algorithmURI);
|
||||
SignatureAlgorithmSpi result= instancesVerify.get().get(algorithmURI);
|
||||
if (result!=null) {
|
||||
result.reset();
|
||||
return result;
|
||||
}
|
||||
result=buildSigner(algorithmURI, result);
|
||||
((Map)instancesVerify.get()).put(algorithmURI,result);
|
||||
instancesVerify.get().put(algorithmURI,result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static SignatureAlgorithmSpi buildSigner(String algorithmURI, SignatureAlgorithmSpi result) throws XMLSignatureException {
|
||||
try {
|
||||
Class implementingClass =
|
||||
Class<? extends SignatureAlgorithmSpi> implementingClass =
|
||||
SignatureAlgorithm.getImplementingClass(algorithmURI);
|
||||
if (log.isLoggable(java.util.logging.Level.FINE))
|
||||
log.log(java.util.logging.Level.FINE, "Create URI \"" + algorithmURI + "\" class \""
|
||||
+ implementingClass + "\"");
|
||||
result=(SignatureAlgorithmSpi) implementingClass.newInstance();
|
||||
result= implementingClass.newInstance();
|
||||
return result;
|
||||
} catch (IllegalAccessException ex) {
|
||||
Object exArgs[] = { algorithmURI, ex.getMessage() };
|
||||
@ -270,7 +270,7 @@ public class SignatureAlgorithm extends Algorithm {
|
||||
*/
|
||||
public void initSign(Key signingKey) throws XMLSignatureException {
|
||||
initializeAlgorithm(true);
|
||||
Map map=(Map)keysSigning.get();
|
||||
Map<String, Key> map=keysSigning.get();
|
||||
if (map.get(this.algorithmURI)==signingKey) {
|
||||
return;
|
||||
}
|
||||
@ -329,7 +329,7 @@ public class SignatureAlgorithm extends Algorithm {
|
||||
*/
|
||||
public void initVerify(Key verificationKey) throws XMLSignatureException {
|
||||
initializeAlgorithm(false);
|
||||
Map map=(Map)keysVerify.get();
|
||||
Map<String, Key> map=keysVerify.get();
|
||||
if (map.get(this.algorithmURI)==verificationKey) {
|
||||
return;
|
||||
}
|
||||
@ -375,7 +375,7 @@ public class SignatureAlgorithm extends Algorithm {
|
||||
log.log(java.util.logging.Level.FINE, "Init() called");
|
||||
|
||||
if (!SignatureAlgorithm._alreadyInitialized) {
|
||||
SignatureAlgorithm._algorithmHash = new HashMap(10);
|
||||
SignatureAlgorithm._algorithmHash = new HashMap<String, Class<? extends SignatureAlgorithmSpi>>(10);
|
||||
SignatureAlgorithm._alreadyInitialized = true;
|
||||
}
|
||||
}
|
||||
@ -388,6 +388,7 @@ public class SignatureAlgorithm extends Algorithm {
|
||||
* @throws AlgorithmAlreadyRegisteredException if specified algorithmURI is already registered
|
||||
* @throws XMLSignatureException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void register(String algorithmURI, String implementingClass)
|
||||
throws AlgorithmAlreadyRegisteredException,XMLSignatureException {
|
||||
|
||||
@ -396,7 +397,7 @@ public class SignatureAlgorithm extends Algorithm {
|
||||
log.log(java.util.logging.Level.FINE, "Try to register " + algorithmURI + " " + implementingClass);
|
||||
|
||||
// are we already registered?
|
||||
Class registeredClassClass =
|
||||
Class<? extends SignatureAlgorithmSpi> registeredClassClass =
|
||||
SignatureAlgorithm.getImplementingClass(algorithmURI);
|
||||
if (registeredClassClass!=null) {
|
||||
String registeredClass = registeredClassClass.getName();
|
||||
@ -409,7 +410,7 @@ public class SignatureAlgorithm extends Algorithm {
|
||||
}
|
||||
}
|
||||
try {
|
||||
SignatureAlgorithm._algorithmHash.put(algorithmURI, Class.forName(implementingClass));
|
||||
SignatureAlgorithm._algorithmHash.put(algorithmURI, (Class <? extends SignatureAlgorithmSpi>)Class.forName(implementingClass));
|
||||
} catch (ClassNotFoundException ex) {
|
||||
Object exArgs[] = { algorithmURI, ex.getMessage() };
|
||||
|
||||
@ -431,13 +432,13 @@ public class SignatureAlgorithm extends Algorithm {
|
||||
* @param URI
|
||||
* @return the class that implements the URI
|
||||
*/
|
||||
private static Class getImplementingClass(String URI) {
|
||||
private static Class<? extends SignatureAlgorithmSpi> getImplementingClass(String URI) {
|
||||
|
||||
if (SignatureAlgorithm._algorithmHash == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (Class) SignatureAlgorithm._algorithmHash.get(URI);
|
||||
return SignatureAlgorithm._algorithmHash.get(URI);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,6 +28,7 @@ import java.util.Set;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.xpath.XPath;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.exceptions.AlgorithmAlreadyRegisteredException;
|
||||
import org.w3c.dom.Document;
|
||||
@ -83,7 +84,7 @@ public class Canonicalizer {
|
||||
ALGO_ID_C14N11_OMIT_COMMENTS + "#WithComments";
|
||||
|
||||
static boolean _alreadyInitialized = false;
|
||||
static Map _canonicalizerHash = null;
|
||||
static Map<String,Class<? extends CanonicalizerSpi>> _canonicalizerHash = null;
|
||||
|
||||
protected CanonicalizerSpi canonicalizerSpi = null;
|
||||
|
||||
@ -94,7 +95,7 @@ public class Canonicalizer {
|
||||
public static void init() {
|
||||
|
||||
if (!Canonicalizer._alreadyInitialized) {
|
||||
Canonicalizer._canonicalizerHash = new HashMap(10);
|
||||
Canonicalizer._canonicalizerHash = new HashMap<String, Class<? extends CanonicalizerSpi>>(10);
|
||||
Canonicalizer._alreadyInitialized = true;
|
||||
}
|
||||
}
|
||||
@ -109,10 +110,11 @@ public class Canonicalizer {
|
||||
throws InvalidCanonicalizerException {
|
||||
|
||||
try {
|
||||
Class implementingClass = getImplementingClass(algorithmURI);
|
||||
Class<? extends CanonicalizerSpi> implementingClass =
|
||||
getImplementingClass(algorithmURI);
|
||||
|
||||
this.canonicalizerSpi =
|
||||
(CanonicalizerSpi) implementingClass.newInstance();
|
||||
implementingClass.newInstance();
|
||||
this.canonicalizerSpi.reset=true;
|
||||
} catch (Exception e) {
|
||||
Object exArgs[] = { algorithmURI };
|
||||
@ -144,11 +146,12 @@ public class Canonicalizer {
|
||||
* @param implementingClass
|
||||
* @throws AlgorithmAlreadyRegisteredException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static void register(String algorithmURI, String implementingClass)
|
||||
throws AlgorithmAlreadyRegisteredException {
|
||||
|
||||
// check whether URI is already registered
|
||||
Class registeredClass = getImplementingClass(algorithmURI);
|
||||
Class<? extends CanonicalizerSpi> registeredClass = getImplementingClass(algorithmURI);
|
||||
|
||||
if (registeredClass != null) {
|
||||
Object exArgs[] = { algorithmURI, registeredClass };
|
||||
@ -158,7 +161,7 @@ public class Canonicalizer {
|
||||
}
|
||||
|
||||
try {
|
||||
_canonicalizerHash.put(algorithmURI, Class.forName(implementingClass));
|
||||
_canonicalizerHash.put(algorithmURI, (Class<? extends CanonicalizerSpi>) Class.forName(implementingClass));
|
||||
} catch (ClassNotFoundException e) {
|
||||
throw new RuntimeException("c14n class not found");
|
||||
}
|
||||
@ -304,7 +307,7 @@ public class Canonicalizer {
|
||||
* @return the result of the c14n.
|
||||
* @throws CanonicalizationException
|
||||
*/
|
||||
public byte[] canonicalizeXPathNodeSet(Set xpathNodeSet)
|
||||
public byte[] canonicalizeXPathNodeSet(Set<Node> xpathNodeSet)
|
||||
throws CanonicalizationException {
|
||||
return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet);
|
||||
}
|
||||
@ -317,7 +320,7 @@ public class Canonicalizer {
|
||||
* @return the result of the c14n.
|
||||
* @throws CanonicalizationException
|
||||
*/
|
||||
public byte[] canonicalizeXPathNodeSet(Set xpathNodeSet,
|
||||
public byte[] canonicalizeXPathNodeSet(Set<Node> xpathNodeSet,
|
||||
String inclusiveNamespaces) throws CanonicalizationException {
|
||||
return this.canonicalizerSpi.engineCanonicalizeXPathNodeSet(xpathNodeSet,
|
||||
inclusiveNamespaces);
|
||||
@ -347,8 +350,8 @@ public class Canonicalizer {
|
||||
* @param URI
|
||||
* @return the name of the class that implements the given URI
|
||||
*/
|
||||
private static Class getImplementingClass(String URI) {
|
||||
return (Class) _canonicalizerHash.get(URI);
|
||||
private static Class<? extends CanonicalizerSpi> getImplementingClass(String URI) {
|
||||
return _canonicalizerHash.get(URI);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -28,6 +28,7 @@ import java.util.Set;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.xpath.XPath;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
|
||||
import org.w3c.dom.Document;
|
||||
@ -151,7 +152,7 @@ public abstract class CanonicalizerSpi {
|
||||
* @return the c14n bytes
|
||||
* @throws CanonicalizationException
|
||||
*/
|
||||
public abstract byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet)
|
||||
public abstract byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet)
|
||||
throws CanonicalizationException;
|
||||
|
||||
/**
|
||||
@ -162,7 +163,7 @@ public abstract class CanonicalizerSpi {
|
||||
* @return the c14n bytes
|
||||
* @throws CanonicalizationException
|
||||
*/
|
||||
public abstract byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet, String inclusiveNamespaces)
|
||||
public abstract byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet, String inclusiveNamespaces)
|
||||
throws CanonicalizationException;
|
||||
|
||||
/**
|
||||
|
@ -41,7 +41,7 @@ import java.util.Comparator;
|
||||
*
|
||||
* @author Christian Geuer-Pollmann
|
||||
*/
|
||||
public class AttrCompare implements Comparator, Serializable {
|
||||
public class AttrCompare implements Comparator<Attr>, Serializable {
|
||||
|
||||
private final static long serialVersionUID = -7113259629930576230L;
|
||||
private final static int ATTR0_BEFORE_ATTR1 = -1;
|
||||
@ -62,16 +62,14 @@ public class AttrCompare implements Comparator, Serializable {
|
||||
* key (an empty namespace URI is lexicographically least).
|
||||
* </UL>
|
||||
*
|
||||
* @param obj0 casted Attr
|
||||
* @param obj1 casted Attr
|
||||
* @param attr0
|
||||
* @param attr1
|
||||
* @return returns a negative integer, zero, or a positive integer as
|
||||
* obj0 is less than, equal to, or greater than obj1
|
||||
*
|
||||
*/
|
||||
public int compare(Object obj0, Object obj1) {
|
||||
public int compare(Attr attr0, Attr attr1) {
|
||||
|
||||
Attr attr0 = (Attr) obj0;
|
||||
Attr attr1 = (Attr) obj1;
|
||||
String namespaceURI0 = attr0.getNamespaceURI();
|
||||
String namespaceURI1 = attr1.getNamespaceURI();
|
||||
|
||||
|
@ -25,6 +25,7 @@ import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@ -33,6 +34,7 @@ import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.xpath.XPath;
|
||||
import org.w3c.dom.Attr;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
@ -59,7 +61,7 @@ import com.sun.org.apache.xml.internal.security.utils.XMLUtils;
|
||||
*/
|
||||
public abstract class Canonicalizer11 extends CanonicalizerBase {
|
||||
boolean firstCall = true;
|
||||
final SortedSet result = new TreeSet(COMPARE);
|
||||
final SortedSet<Attr> result = new TreeSet<Attr>(COMPARE);
|
||||
static final String XMLNS_URI = Constants.NamespaceSpecNS;
|
||||
static final String XML_LANG_URI = Constants.XML_LANG_SPACE_SpecNS;
|
||||
|
||||
@ -72,9 +74,9 @@ public abstract class Canonicalizer11 extends CanonicalizerBase {
|
||||
static class XmlsStackElement {
|
||||
int level;
|
||||
boolean rendered = false;
|
||||
List nodes = new ArrayList();
|
||||
List<Attr> nodes = new ArrayList<Attr>();
|
||||
};
|
||||
List levels = new ArrayList();
|
||||
List<XmlsStackElement> levels = new ArrayList<XmlsStackElement>();
|
||||
void push(int level) {
|
||||
currentLevel = level;
|
||||
if (currentLevel == -1)
|
||||
@ -86,7 +88,7 @@ public abstract class Canonicalizer11 extends CanonicalizerBase {
|
||||
lastlevel = 0;
|
||||
return;
|
||||
}
|
||||
lastlevel=((XmlsStackElement)levels.get(levels.size()-1)).level;
|
||||
lastlevel=(levels.get(levels.size()-1)).level;
|
||||
}
|
||||
}
|
||||
void addXmlnsAttr(Attr n) {
|
||||
@ -98,7 +100,7 @@ public abstract class Canonicalizer11 extends CanonicalizerBase {
|
||||
}
|
||||
cur.nodes.add(n);
|
||||
}
|
||||
void getXmlnsAttr(Collection col) {
|
||||
void getXmlnsAttr(Collection<Attr> col) {
|
||||
if (cur == null) {
|
||||
cur = new XmlsStackElement();
|
||||
cur.level = currentLevel;
|
||||
@ -111,7 +113,7 @@ public abstract class Canonicalizer11 extends CanonicalizerBase {
|
||||
if (size == -1) {
|
||||
parentRendered = true;
|
||||
} else {
|
||||
e = (XmlsStackElement) levels.get(size);
|
||||
e = levels.get(size);
|
||||
if (e.rendered && e.level+1 == currentLevel)
|
||||
parentRendered = true;
|
||||
}
|
||||
@ -121,17 +123,17 @@ public abstract class Canonicalizer11 extends CanonicalizerBase {
|
||||
return;
|
||||
}
|
||||
|
||||
Map loa = new HashMap();
|
||||
List baseAttrs = new ArrayList();
|
||||
Map<String, Attr> loa = new HashMap<String, Attr>();
|
||||
List<Attr> baseAttrs = new ArrayList<Attr>();
|
||||
boolean successiveOmitted = true;
|
||||
for (;size>=0;size--) {
|
||||
e = (XmlsStackElement) levels.get(size);
|
||||
e = levels.get(size);
|
||||
if (e.rendered) {
|
||||
successiveOmitted = false;
|
||||
}
|
||||
Iterator it = e.nodes.iterator();
|
||||
Iterator<Attr> it = e.nodes.iterator();
|
||||
while (it.hasNext() && successiveOmitted) {
|
||||
Attr n = (Attr) it.next();
|
||||
Attr n = it.next();
|
||||
if (n.getLocalName().equals("base")) {
|
||||
if (!e.rendered) {
|
||||
baseAttrs.add(n);
|
||||
@ -141,11 +143,11 @@ public abstract class Canonicalizer11 extends CanonicalizerBase {
|
||||
}
|
||||
}
|
||||
if (!baseAttrs.isEmpty()) {
|
||||
Iterator it = cur.nodes.iterator();
|
||||
Iterator<Attr> it = cur.nodes.iterator();
|
||||
String base = null;
|
||||
Attr baseAttr = null;
|
||||
while (it.hasNext()) {
|
||||
Attr n = (Attr) it.next();
|
||||
Attr n = it.next();
|
||||
if (n.getLocalName().equals("base")) {
|
||||
base = n.getValue();
|
||||
baseAttr = n;
|
||||
@ -154,7 +156,7 @@ public abstract class Canonicalizer11 extends CanonicalizerBase {
|
||||
}
|
||||
it = baseAttrs.iterator();
|
||||
while (it.hasNext()) {
|
||||
Attr n = (Attr) it.next();
|
||||
Attr n = it.next();
|
||||
if (base == null) {
|
||||
base = n.getValue();
|
||||
baseAttr = n;
|
||||
@ -202,13 +204,13 @@ public abstract class Canonicalizer11 extends CanonicalizerBase {
|
||||
* @return the Attr[]s to be outputted
|
||||
* @throws CanonicalizationException
|
||||
*/
|
||||
Iterator handleAttributesSubtree(Element E, NameSpaceSymbTable ns)
|
||||
Iterator<Attr> handleAttributesSubtree(Element E, NameSpaceSymbTable ns)
|
||||
throws CanonicalizationException {
|
||||
if (!E.hasAttributes() && !firstCall) {
|
||||
return null;
|
||||
}
|
||||
// result will contain the attrs which have to be outputted
|
||||
final SortedSet result = this.result;
|
||||
final SortedSet<Attr> result = this.result;
|
||||
result.clear();
|
||||
NamedNodeMap attrs = E.getAttributes();
|
||||
int attrsLength = attrs.getLength();
|
||||
@ -236,7 +238,7 @@ public abstract class Canonicalizer11 extends CanonicalizerBase {
|
||||
|
||||
if (n != null) {
|
||||
// Render the ns definition
|
||||
result.add(n);
|
||||
result.add((Attr)n);
|
||||
if (C14nHelper.namespaceIsRelative(N)) {
|
||||
Object exArgs[] = {E.getTagName(), NName, N.getNodeValue()};
|
||||
throw new CanonicalizationException(
|
||||
@ -251,13 +253,15 @@ public abstract class Canonicalizer11 extends CanonicalizerBase {
|
||||
// to the output.
|
||||
ns.getUnrenderedNodes(result);
|
||||
// output the attributes in the xml namespace.
|
||||
xmlattrStack.getXmlnsAttr(result);
|
||||
xmlattrStack.getXmlnsAttr(getSortedSetAsCollection(result));
|
||||
firstCall = false;
|
||||
}
|
||||
|
||||
return result.iterator();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the Attr[]s to be outputted for the given element.
|
||||
* <br>
|
||||
@ -271,7 +275,7 @@ public abstract class Canonicalizer11 extends CanonicalizerBase {
|
||||
* @return the Attr[]s to be outputted
|
||||
* @throws CanonicalizationException
|
||||
*/
|
||||
Iterator handleAttributes(Element E, NameSpaceSymbTable ns)
|
||||
Iterator<Attr> handleAttributes(Element E, NameSpaceSymbTable ns)
|
||||
throws CanonicalizationException {
|
||||
// result will contain the attrs which have to be output
|
||||
xmlattrStack.push(ns.getLevel());
|
||||
@ -283,11 +287,11 @@ public abstract class Canonicalizer11 extends CanonicalizerBase {
|
||||
attrsLength = attrs.getLength();
|
||||
}
|
||||
|
||||
SortedSet result = this.result;
|
||||
SortedSet<Attr> result = this.result;
|
||||
result.clear();
|
||||
|
||||
for (int i = 0; i < attrsLength; i++) {
|
||||
Attr N = (Attr) attrs.item(i);
|
||||
Attr N = (Attr)attrs.item(i);
|
||||
String NUri = N.getNamespaceURI();
|
||||
|
||||
if (XMLNS_URI != NUri) {
|
||||
@ -332,7 +336,7 @@ public abstract class Canonicalizer11 extends CanonicalizerBase {
|
||||
// (NName, NValue, N, isRealVisible);
|
||||
Node n = ns.addMappingAndRender(NName, NValue, N);
|
||||
if (n != null) {
|
||||
result.add(n);
|
||||
result.add((Attr)n);
|
||||
if (C14nHelper.namespaceIsRelative(N)) {
|
||||
Object exArgs[] =
|
||||
{ E.getTagName(), NName, N.getNodeValue() };
|
||||
@ -362,7 +366,7 @@ public abstract class Canonicalizer11 extends CanonicalizerBase {
|
||||
}
|
||||
// output the xmlns def if needed.
|
||||
if (n != null) {
|
||||
result.add(n);
|
||||
result.add((Attr)n);
|
||||
}
|
||||
// Float all xml:* attributes of the unselected parent elements to
|
||||
// this one. addXmlAttributes(E,result);
|
||||
@ -381,7 +385,7 @@ public abstract class Canonicalizer11 extends CanonicalizerBase {
|
||||
* @return none it always fails
|
||||
* @throws CanonicalizationException always
|
||||
*/
|
||||
public byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet,
|
||||
public byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet,
|
||||
String inclusiveNamespaces) throws CanonicalizationException {
|
||||
throw new CanonicalizationException(
|
||||
"c14n.Canonicalizer.UnsupportedOperation");
|
||||
|
@ -57,7 +57,7 @@ import org.xml.sax.SAXException;
|
||||
*/
|
||||
public abstract class Canonicalizer20010315 extends CanonicalizerBase {
|
||||
boolean firstCall=true;
|
||||
final SortedSet result= new TreeSet(COMPARE);
|
||||
final SortedSet<Attr> result= new TreeSet<Attr>(COMPARE);
|
||||
static final String XMLNS_URI=Constants.NamespaceSpecNS;
|
||||
static final String XML_LANG_URI=Constants.XML_LANG_SPACE_SpecNS;
|
||||
static class XmlAttrStack {
|
||||
@ -67,9 +67,9 @@ public abstract class Canonicalizer20010315 extends CanonicalizerBase {
|
||||
static class XmlsStackElement {
|
||||
int level;
|
||||
boolean rendered=false;
|
||||
List nodes=new ArrayList();
|
||||
List<Attr> nodes=new ArrayList<Attr>();
|
||||
};
|
||||
List levels=new ArrayList();
|
||||
List<XmlsStackElement> levels=new ArrayList<XmlsStackElement>();
|
||||
void push(int level) {
|
||||
currentLevel=level;
|
||||
if (currentLevel==-1)
|
||||
@ -81,7 +81,7 @@ public abstract class Canonicalizer20010315 extends CanonicalizerBase {
|
||||
lastlevel=0;
|
||||
return;
|
||||
}
|
||||
lastlevel=((XmlsStackElement)levels.get(levels.size()-1)).level;
|
||||
lastlevel=(levels.get(levels.size()-1)).level;
|
||||
}
|
||||
}
|
||||
void addXmlnsAttr(Attr n) {
|
||||
@ -93,7 +93,7 @@ public abstract class Canonicalizer20010315 extends CanonicalizerBase {
|
||||
}
|
||||
cur.nodes.add(n);
|
||||
}
|
||||
void getXmlnsAttr(Collection col) {
|
||||
void getXmlnsAttr(Collection<Attr> col) {
|
||||
int size=levels.size()-1;
|
||||
if (cur==null) {
|
||||
cur=new XmlsStackElement();
|
||||
@ -106,7 +106,7 @@ public abstract class Canonicalizer20010315 extends CanonicalizerBase {
|
||||
if (size==-1) {
|
||||
parentRendered=true;
|
||||
} else {
|
||||
e=(XmlsStackElement)levels.get(size);
|
||||
e=levels.get(size);
|
||||
if (e.rendered && e.level+1==currentLevel)
|
||||
parentRendered=true;
|
||||
|
||||
@ -117,12 +117,12 @@ public abstract class Canonicalizer20010315 extends CanonicalizerBase {
|
||||
return;
|
||||
}
|
||||
|
||||
Map loa = new HashMap();
|
||||
Map<String,Attr> loa = new HashMap<String,Attr>();
|
||||
for (;size>=0;size--) {
|
||||
e=(XmlsStackElement)levels.get(size);
|
||||
Iterator it=e.nodes.iterator();
|
||||
e=levels.get(size);
|
||||
Iterator<Attr> it=e.nodes.iterator();
|
||||
while (it.hasNext()) {
|
||||
Attr n=(Attr)it.next();
|
||||
Attr n=it.next();
|
||||
if (!loa.containsKey(n.getName()))
|
||||
loa.put(n.getName(),n);
|
||||
}
|
||||
@ -161,13 +161,13 @@ public abstract class Canonicalizer20010315 extends CanonicalizerBase {
|
||||
* @return the Attr[]s to be outputted
|
||||
* @throws CanonicalizationException
|
||||
*/
|
||||
Iterator handleAttributesSubtree(Element E, NameSpaceSymbTable ns )
|
||||
Iterator<Attr> handleAttributesSubtree(Element E, NameSpaceSymbTable ns )
|
||||
throws CanonicalizationException {
|
||||
if (!E.hasAttributes() && !firstCall) {
|
||||
return null;
|
||||
}
|
||||
// result will contain the attrs which have to be outputted
|
||||
final SortedSet result = this.result;
|
||||
final SortedSet<Attr> result = this.result;
|
||||
result.clear();
|
||||
NamedNodeMap attrs = E.getAttributes();
|
||||
int attrsLength = attrs.getLength();
|
||||
@ -194,7 +194,7 @@ public abstract class Canonicalizer20010315 extends CanonicalizerBase {
|
||||
|
||||
if (n!=null) {
|
||||
//Render the ns definition
|
||||
result.add(n);
|
||||
result.add((Attr)n);
|
||||
if (C14nHelper.namespaceIsRelative(N)) {
|
||||
Object exArgs[] = { E.getTagName(), NName, N.getNodeValue() };
|
||||
throw new CanonicalizationException(
|
||||
@ -206,7 +206,7 @@ public abstract class Canonicalizer20010315 extends CanonicalizerBase {
|
||||
if (firstCall) {
|
||||
//It is the first node of the subtree
|
||||
//Obtain all the namespaces defined in the parents, and added to the output.
|
||||
ns.getUnrenderedNodes(result);
|
||||
ns.getUnrenderedNodes(getSortedSetAsCollection(result));
|
||||
//output the attributes in the xml namespace.
|
||||
xmlattrStack.getXmlnsAttr(result);
|
||||
firstCall=false;
|
||||
@ -227,7 +227,7 @@ public abstract class Canonicalizer20010315 extends CanonicalizerBase {
|
||||
* @return the Attr[]s to be outputted
|
||||
* @throws CanonicalizationException
|
||||
*/
|
||||
Iterator handleAttributes(Element E, NameSpaceSymbTable ns ) throws CanonicalizationException {
|
||||
Iterator<Attr> handleAttributes(Element E, NameSpaceSymbTable ns ) throws CanonicalizationException {
|
||||
// result will contain the attrs which have to be outputted
|
||||
xmlattrStack.push(ns.getLevel());
|
||||
boolean isRealVisible=isVisibleDO(E,ns.getLevel())==1;
|
||||
@ -239,7 +239,7 @@ public abstract class Canonicalizer20010315 extends CanonicalizerBase {
|
||||
}
|
||||
|
||||
|
||||
SortedSet result = this.result;
|
||||
SortedSet<Attr> result = this.result;
|
||||
result.clear();
|
||||
|
||||
for (int i = 0; i < attrsLength; i++) {
|
||||
@ -277,7 +277,7 @@ public abstract class Canonicalizer20010315 extends CanonicalizerBase {
|
||||
//Node n=ns.addMappingAndRenderXNodeSet(NName,NValue,N,isRealVisible);
|
||||
Node n=ns.addMappingAndRender(NName,NValue,N);
|
||||
if (n!=null) {
|
||||
result.add(n);
|
||||
result.add((Attr)n);
|
||||
if (C14nHelper.namespaceIsRelative(N)) {
|
||||
Object exArgs[] = { E.getTagName(), NName, N.getNodeValue() };
|
||||
throw new CanonicalizationException(
|
||||
@ -306,12 +306,12 @@ public abstract class Canonicalizer20010315 extends CanonicalizerBase {
|
||||
}
|
||||
//output the xmlns def if needed.
|
||||
if (n!=null) {
|
||||
result.add(n);
|
||||
result.add((Attr)n);
|
||||
}
|
||||
//Float all xml:* attributes of the unselected parent elements to this one.
|
||||
//addXmlAttributes(E,result);
|
||||
xmlattrStack.getXmlnsAttr(result);
|
||||
ns.getUnrenderedNodes(result);
|
||||
ns.getUnrenderedNodes(getSortedSetAsCollection(result));
|
||||
|
||||
}
|
||||
|
||||
@ -325,7 +325,7 @@ public abstract class Canonicalizer20010315 extends CanonicalizerBase {
|
||||
* @return none it always fails
|
||||
* @throws CanonicalizationException always
|
||||
*/
|
||||
public byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet, String inclusiveNamespaces)
|
||||
public byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet, String inclusiveNamespaces)
|
||||
throws CanonicalizationException {
|
||||
|
||||
/** $todo$ well, should we throw UnsupportedOperationException ? */
|
||||
|
@ -61,9 +61,9 @@ public abstract class Canonicalizer20010315Excl extends CanonicalizerBase {
|
||||
* This Set contains the names (Strings like "xmlns" or "xmlns:foo") of
|
||||
* the inclusive namespaces.
|
||||
*/
|
||||
TreeSet _inclusiveNSSet = new TreeSet();
|
||||
TreeSet<String> _inclusiveNSSet = new TreeSet<String>();
|
||||
static final String XMLNS_URI=Constants.NamespaceSpecNS;
|
||||
final SortedSet result = new TreeSet(COMPARE);
|
||||
final SortedSet<Attr> result = new TreeSet<Attr>(COMPARE);
|
||||
/**
|
||||
* Constructor Canonicalizer20010315Excl
|
||||
*
|
||||
@ -106,8 +106,7 @@ public abstract class Canonicalizer20010315Excl extends CanonicalizerBase {
|
||||
*/
|
||||
public byte[] engineCanonicalizeSubTree(Node rootNode,
|
||||
String inclusiveNamespaces,Node excl) throws CanonicalizationException {
|
||||
this._inclusiveNSSet = (TreeSet)InclusiveNamespaces
|
||||
.prefixStr2Set(inclusiveNamespaces);
|
||||
this._inclusiveNSSet = getInclusiveNameSpace(inclusiveNamespaces);
|
||||
return super.engineCanonicalizeSubTree(rootNode,excl);
|
||||
}
|
||||
/**
|
||||
@ -117,10 +116,10 @@ public abstract class Canonicalizer20010315Excl extends CanonicalizerBase {
|
||||
* @return the rootNode c14n.
|
||||
* @throws CanonicalizationException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public byte[] engineCanonicalize(XMLSignatureInput rootNode,
|
||||
String inclusiveNamespaces) throws CanonicalizationException {
|
||||
this._inclusiveNSSet = (TreeSet)InclusiveNamespaces
|
||||
.prefixStr2Set(inclusiveNamespaces);
|
||||
this._inclusiveNSSet = getInclusiveNameSpace(inclusiveNamespaces);
|
||||
return super.engineCanonicalize(rootNode);
|
||||
}
|
||||
|
||||
@ -130,12 +129,12 @@ public abstract class Canonicalizer20010315Excl extends CanonicalizerBase {
|
||||
* @param E
|
||||
* @throws CanonicalizationException
|
||||
*/
|
||||
Iterator handleAttributesSubtree(Element E,NameSpaceSymbTable ns)
|
||||
Iterator<Attr> handleAttributesSubtree(Element E,NameSpaceSymbTable ns)
|
||||
throws CanonicalizationException {
|
||||
// System.out.println("During the traversal, I encountered " +
|
||||
// XMLUtils.getXPath(E));
|
||||
// result will contain the attrs which have to be outputted
|
||||
SortedSet result = this.result;
|
||||
SortedSet<Attr> result = this.result;
|
||||
result.clear();
|
||||
NamedNodeMap attrs=null;
|
||||
|
||||
@ -145,7 +144,7 @@ public abstract class Canonicalizer20010315Excl extends CanonicalizerBase {
|
||||
attrsLength = attrs.getLength();
|
||||
}
|
||||
//The prefix visibly utilized(in the attribute or in the name) in the element
|
||||
SortedSet visiblyUtilized =(SortedSet) _inclusiveNSSet.clone();
|
||||
SortedSet<String> visiblyUtilized = getNSSetClone();
|
||||
|
||||
for (int i = 0; i < attrsLength; i++) {
|
||||
Attr N = (Attr) attrs.item(i);
|
||||
@ -187,9 +186,9 @@ public abstract class Canonicalizer20010315Excl extends CanonicalizerBase {
|
||||
visiblyUtilized.add(prefix);
|
||||
|
||||
//This can be optimezed by I don't have time
|
||||
Iterator it=visiblyUtilized.iterator();
|
||||
Iterator<String> it=visiblyUtilized.iterator();
|
||||
while (it.hasNext()) {
|
||||
String s=(String)it.next();
|
||||
String s=it.next();
|
||||
Attr key=ns.getMapping(s);
|
||||
if (key==null) {
|
||||
continue;
|
||||
@ -207,25 +206,35 @@ public abstract class Canonicalizer20010315Excl extends CanonicalizerBase {
|
||||
* @param inclusiveNamespaces
|
||||
* @throws CanonicalizationException
|
||||
*/
|
||||
public byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet,
|
||||
public byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet,
|
||||
String inclusiveNamespaces) throws CanonicalizationException {
|
||||
|
||||
|
||||
this._inclusiveNSSet = (TreeSet)InclusiveNamespaces
|
||||
.prefixStr2Set(inclusiveNamespaces);
|
||||
this._inclusiveNSSet = getInclusiveNameSpace(inclusiveNamespaces);
|
||||
return super.engineCanonicalizeXPathNodeSet(xpathNodeSet);
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private TreeSet<String> getInclusiveNameSpace(String inclusiveNameSpaces) {
|
||||
return (TreeSet<String>)InclusiveNamespaces.prefixStr2Set(inclusiveNameSpaces);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private SortedSet<String> getNSSetClone() {
|
||||
return (SortedSet<String>) this._inclusiveNSSet.clone();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
* @param E
|
||||
* @throws CanonicalizationException
|
||||
*/
|
||||
final Iterator handleAttributes(Element E, NameSpaceSymbTable ns)
|
||||
final Iterator<Attr> handleAttributes(Element E, NameSpaceSymbTable ns)
|
||||
throws CanonicalizationException {
|
||||
// result will contain the attrs which have to be outputted
|
||||
SortedSet result = this.result;
|
||||
SortedSet<Attr> result = this.result;
|
||||
result.clear();
|
||||
NamedNodeMap attrs = null;
|
||||
int attrsLength = 0;
|
||||
@ -234,11 +243,11 @@ public abstract class Canonicalizer20010315Excl extends CanonicalizerBase {
|
||||
attrsLength = attrs.getLength();
|
||||
}
|
||||
//The prefix visibly utilized(in the attribute or in the name) in the element
|
||||
Set visiblyUtilized =null;
|
||||
Set<String> visiblyUtilized =null;
|
||||
//It's the output selected.
|
||||
boolean isOutputElement=isVisibleDO(E,ns.getLevel())==1;
|
||||
if (isOutputElement) {
|
||||
visiblyUtilized = (Set) this._inclusiveNSSet.clone();
|
||||
visiblyUtilized = getNSSetClone();
|
||||
}
|
||||
|
||||
for (int i = 0; i < attrsLength; i++) {
|
||||
@ -272,7 +281,7 @@ public abstract class Canonicalizer20010315Excl extends CanonicalizerBase {
|
||||
if (!isOutputElement && isVisible(N) && _inclusiveNSSet.contains(NName) && !ns.removeMappingIfRender(NName)) {
|
||||
Node n=ns.addMappingAndRender(NName,NNodeValue,N);
|
||||
if (n!=null) {
|
||||
result.add(n);
|
||||
result.add((Attr)n);
|
||||
if (C14nHelper.namespaceIsRelative(N)) {
|
||||
Object exArgs[] = { E.getTagName(), NName, N.getNodeValue() };
|
||||
throw new CanonicalizationException(
|
||||
@ -315,9 +324,9 @@ public abstract class Canonicalizer20010315Excl extends CanonicalizerBase {
|
||||
}
|
||||
//This can be optimezed by I don't have time
|
||||
//visiblyUtilized.addAll(this._inclusiveNSSet);
|
||||
Iterator it=visiblyUtilized.iterator();
|
||||
Iterator<String> it=visiblyUtilized.iterator();
|
||||
while (it.hasNext()) {
|
||||
String s=(String)it.next();
|
||||
String s=it.next();
|
||||
Attr key=ns.getMapping(s);
|
||||
if (key==null) {
|
||||
continue;
|
||||
|
@ -33,9 +33,12 @@ import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.xpath.XPath;
|
||||
|
||||
import com.sun.org.apache.xml.internal.security.c14n.CanonicalizationException;
|
||||
import com.sun.org.apache.xml.internal.security.c14n.CanonicalizerSpi;
|
||||
@ -94,10 +97,10 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|
||||
}
|
||||
}
|
||||
|
||||
List nodeFilter;
|
||||
List<NodeFilter> nodeFilter;
|
||||
|
||||
boolean _includeComments;
|
||||
Set _xpathNodeSet = null;
|
||||
Set<Node> _xpathNodeSet = null;
|
||||
/**
|
||||
* The node to be skiped/excluded from the DOM tree
|
||||
* in subtree canonicalizations.
|
||||
@ -130,7 +133,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|
||||
* @param xpathNodeSet
|
||||
* @throws CanonicalizationException
|
||||
*/
|
||||
public byte[] engineCanonicalizeXPathNodeSet(Set xpathNodeSet)
|
||||
public byte[] engineCanonicalizeXPathNodeSet(Set<Node> xpathNodeSet)
|
||||
throws CanonicalizationException {
|
||||
this._xpathNodeSet = xpathNodeSet;
|
||||
return engineCanonicalizeXPathNodeSetInternal(XMLUtils.getOwnerDocument(this._xpathNodeSet));
|
||||
@ -251,7 +254,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|
||||
final OutputStream writer=this._writer;
|
||||
final Node excludeNode=this._excludeNode;
|
||||
final boolean includeComments=this._includeComments;
|
||||
Map cache=new HashMap();
|
||||
Map<String, byte[]> cache=new HashMap<String, byte[]>();
|
||||
do {
|
||||
switch (currentNode.getNodeType()) {
|
||||
|
||||
@ -298,11 +301,11 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|
||||
String name=currentElement.getTagName();
|
||||
UtfHelpper.writeByte(name,writer,cache);
|
||||
|
||||
Iterator attrs = this.handleAttributesSubtree(currentElement,ns);
|
||||
Iterator<Attr> attrs = this.handleAttributesSubtree(currentElement,ns);
|
||||
if (attrs!=null) {
|
||||
//we output all Attrs which are available
|
||||
while (attrs.hasNext()) {
|
||||
Attr attr = (Attr) attrs.next();
|
||||
Attr attr = attrs.next();
|
||||
outputAttrToWriter(attr.getNodeName(),attr.getNodeValue(), writer,cache);
|
||||
}
|
||||
}
|
||||
@ -394,7 +397,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|
||||
Node parentNode=null;
|
||||
OutputStream writer=this._writer;
|
||||
int documentLevel=NODE_BEFORE_DOCUMENT_ELEMENT;
|
||||
Map cache=new HashMap();
|
||||
Map<String, byte[]> cache=new HashMap<String,byte[]>();
|
||||
do {
|
||||
switch (currentNode.getNodeType()) {
|
||||
|
||||
@ -464,11 +467,11 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|
||||
ns.push();
|
||||
}
|
||||
|
||||
Iterator attrs = handleAttributes(currentElement,ns);
|
||||
Iterator<Attr> attrs = handleAttributes(currentElement,ns);
|
||||
if (attrs!=null) {
|
||||
//we output all Attrs which are available
|
||||
while (attrs.hasNext()) {
|
||||
Attr attr = (Attr) attrs.next();
|
||||
Attr attr = attrs.next();
|
||||
outputAttrToWriter(attr.getNodeName(),attr.getNodeValue(), writer,cache);
|
||||
}
|
||||
}
|
||||
@ -522,9 +525,9 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|
||||
}
|
||||
int isVisibleDO(Node currentNode,int level) {
|
||||
if (nodeFilter!=null) {
|
||||
Iterator it=nodeFilter.iterator();
|
||||
Iterator<NodeFilter> it=nodeFilter.iterator();
|
||||
while (it.hasNext()) {
|
||||
int i=((NodeFilter)it.next()).isNodeIncludeDO(currentNode,level);
|
||||
int i=(it.next()).isNodeIncludeDO(currentNode,level);
|
||||
if (i!=1)
|
||||
return i;
|
||||
}
|
||||
@ -535,9 +538,9 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|
||||
}
|
||||
int isVisibleInt(Node currentNode) {
|
||||
if (nodeFilter!=null) {
|
||||
Iterator it=nodeFilter.iterator();
|
||||
Iterator<NodeFilter> it=nodeFilter.iterator();
|
||||
while (it.hasNext()) {
|
||||
int i=((NodeFilter)it.next()).isNodeInclude(currentNode);
|
||||
int i=(it.next()).isNodeInclude(currentNode);
|
||||
if (i!=1)
|
||||
return i;
|
||||
}
|
||||
@ -549,9 +552,9 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|
||||
|
||||
boolean isVisible(Node currentNode) {
|
||||
if (nodeFilter!=null) {
|
||||
Iterator it=nodeFilter.iterator();
|
||||
Iterator<NodeFilter> it=nodeFilter.iterator();
|
||||
while (it.hasNext()) {
|
||||
if (((NodeFilter)it.next()).isNodeInclude(currentNode)!=1)
|
||||
if ((it.next()).isNodeInclude(currentNode)!=1)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -589,7 +592,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|
||||
* @param ns
|
||||
*/
|
||||
final void getParentNameSpaces(Element el,NameSpaceSymbTable ns) {
|
||||
List parents=new ArrayList(10);
|
||||
List<Element> parents=new ArrayList<Element>(10);
|
||||
Node n1=el.getParentNode();
|
||||
if (!(n1 instanceof Element)) {
|
||||
return;
|
||||
@ -605,9 +608,9 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|
||||
parent=(Element)n;
|
||||
}
|
||||
//Visit them in reverse order.
|
||||
ListIterator it=parents.listIterator(parents.size());
|
||||
ListIterator<Element> it=parents.listIterator(parents.size());
|
||||
while (it.hasPrevious()) {
|
||||
Element ele=(Element)it.previous();
|
||||
Element ele=it.previous();
|
||||
handleParent(ele, ns);
|
||||
}
|
||||
Attr nsprefix;
|
||||
@ -624,7 +627,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|
||||
* @return the attributes nodes to output.
|
||||
* @throws CanonicalizationException
|
||||
*/
|
||||
abstract Iterator handleAttributes(Element E, NameSpaceSymbTable ns )
|
||||
abstract Iterator<Attr> handleAttributes(Element E, NameSpaceSymbTable ns )
|
||||
throws CanonicalizationException;
|
||||
|
||||
/**
|
||||
@ -635,7 +638,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|
||||
* @return the attributes nodes to output.
|
||||
* @throws CanonicalizationException
|
||||
*/
|
||||
abstract Iterator handleAttributesSubtree(Element E, NameSpaceSymbTable ns)
|
||||
abstract Iterator<Attr> handleAttributesSubtree(Element E, NameSpaceSymbTable ns)
|
||||
throws CanonicalizationException;
|
||||
|
||||
abstract void circumventBugIfNeeded(XMLSignatureInput input) throws CanonicalizationException, ParserConfigurationException, IOException, SAXException;
|
||||
@ -660,7 +663,7 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|
||||
* @throws IOException
|
||||
*/
|
||||
static final void outputAttrToWriter(final String name, final String value, final OutputStream writer,
|
||||
final Map cache) throws IOException {
|
||||
final Map<String, byte[]> cache) throws IOException {
|
||||
writer.write(' ');
|
||||
UtfHelpper.writeByte(name,writer,cache);
|
||||
writer.write(equalsStr);
|
||||
@ -841,4 +844,10 @@ public abstract class CanonicalizerBase extends CanonicalizerSpi {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Collection<Attr> getSortedSetAsCollection(SortedSet<Attr> result) {
|
||||
return (Collection<Attr>)(Collection)result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public class NameSpaceSymbTable {
|
||||
/**The level of nameSpaces (for Inclusive visibility).*/
|
||||
int nameSpaces=0;
|
||||
/**The stacks for removing the definitions when doing pop.*/
|
||||
List level;
|
||||
List<SymbMap> level;
|
||||
boolean cloned=true;
|
||||
static final String XMLNS="xmlns";
|
||||
final static SymbMap initialMap=new SymbMap();
|
||||
@ -57,7 +57,7 @@ public class NameSpaceSymbTable {
|
||||
* Default constractor
|
||||
**/
|
||||
public NameSpaceSymbTable() {
|
||||
level = new ArrayList(10);
|
||||
level = new ArrayList<SymbMap>(10);
|
||||
//Insert the default binding for xmlns.
|
||||
symb=(SymbMap) initialMap.clone();
|
||||
}
|
||||
@ -67,11 +67,11 @@ public class NameSpaceSymbTable {
|
||||
* For Inclusive rendering
|
||||
* @param result the list where to fill the unrendered xmlns definitions.
|
||||
**/
|
||||
public void getUnrenderedNodes(Collection result) {
|
||||
public void getUnrenderedNodes(Collection<Attr> result) {
|
||||
//List result=new ArrayList();
|
||||
Iterator it=symb.entrySet().iterator();
|
||||
Iterator<NameSpaceSymbEntry> it=symb.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
NameSpaceSymbEntry n=(NameSpaceSymbEntry)(it.next());
|
||||
NameSpaceSymbEntry n= it.next();
|
||||
//put them rendered?
|
||||
if ((!n.rendered) && (n.n!=null)) {
|
||||
n=(NameSpaceSymbEntry) n.clone();
|
||||
@ -339,8 +339,8 @@ class SymbMap implements Cloneable {
|
||||
}
|
||||
}
|
||||
|
||||
List entrySet() {
|
||||
List a=new ArrayList();
|
||||
List<NameSpaceSymbEntry> entrySet() {
|
||||
List<NameSpaceSymbEntry> a=new ArrayList<NameSpaceSymbEntry>();
|
||||
for (int i=0;i<entries.length;i++) {
|
||||
if ((entries[i]!=null) && !("".equals(entries[i].uri))) {
|
||||
a.add(entries[i]);
|
||||
|
4
jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/UtfHelpper.java
4
jdk/src/share/classes/com/sun/org/apache/xml/internal/security/c14n/implementations/UtfHelpper.java
@ -6,8 +6,8 @@ import java.util.Map;
|
||||
|
||||
public class UtfHelpper {
|
||||
|
||||
final static void writeByte(final String str,final OutputStream out,Map cache) throws IOException {
|
||||
byte []result=(byte[]) cache.get(str);
|
||||
final static void writeByte(final String str,final OutputStream out,Map<String,byte[]> cache) throws IOException {
|
||||
byte []result= cache.get(str);
|
||||
if (result==null) {
|
||||
result=getStringInUtf8(str);
|
||||
cache.put(str,result);
|
||||
|
@ -95,7 +95,7 @@ public interface AgreementMethod {
|
||||
* Returns aditional information regarding the <code>AgreementMethod</code>.
|
||||
* @return
|
||||
*/
|
||||
Iterator getAgreementMethodInformation();
|
||||
Iterator<Element> getAgreementMethodInformation();
|
||||
|
||||
/**
|
||||
* Adds additional <code>AgreementMethod</code> information.
|
||||
|
@ -89,7 +89,7 @@ public interface EncryptionMethod {
|
||||
* @return an <code>Iterator</code> over all the additional infomation
|
||||
* about the <code>EncryptionMethod</code>.
|
||||
*/
|
||||
Iterator getEncryptionMethodInformation();
|
||||
Iterator<Element> getEncryptionMethodInformation();
|
||||
|
||||
/**
|
||||
* Adds encryption method information.
|
||||
|
2
jdk/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/EncryptionProperties.java
2
jdk/src/share/classes/com/sun/org/apache/xml/internal/security/encryption/EncryptionProperties.java
@ -67,7 +67,7 @@ public interface EncryptionProperties {
|
||||
*
|
||||
* @return an <code>Iterator</code> over all the encryption properties.
|
||||
*/
|
||||
Iterator getEncryptionProperties();
|
||||
Iterator<EncryptionProperty> getEncryptionProperties();
|
||||
|
||||
/**
|
||||
* Adds an <code>EncryptionProperty</code>.
|
||||
|
@ -101,7 +101,7 @@ public interface EncryptionProperty {
|
||||
* @return an <code>Iterator</code> over all the addiitonal encryption
|
||||
* information contained in this class.
|
||||
*/
|
||||
Iterator getEncryptionInformation();
|
||||
Iterator<Element> getEncryptionInformation();
|
||||
|
||||
/**
|
||||
* Adds encryption information.
|
||||
|
@ -74,7 +74,7 @@ public interface Reference {
|
||||
*
|
||||
* @return child elements.
|
||||
*/
|
||||
Iterator getElementRetrievalInformation();
|
||||
Iterator<Element> getElementRetrievalInformation();
|
||||
|
||||
/**
|
||||
* Adds retrieval information.
|
||||
|
@ -87,7 +87,7 @@ public interface ReferenceList {
|
||||
*
|
||||
* @return Iterator.
|
||||
*/
|
||||
public Iterator getReferences();
|
||||
public Iterator<Reference> getReferences();
|
||||
|
||||
/**
|
||||
* <code>DataReference</code> factory method. Returns a
|
||||
|
@ -2772,7 +2772,7 @@ public class XMLCipher {
|
||||
// </complexType>
|
||||
private class AgreementMethodImpl implements AgreementMethod {
|
||||
private byte[] kaNonce = null;
|
||||
private List agreementMethodInformation = null;
|
||||
private List<Element> agreementMethodInformation = null;
|
||||
private KeyInfo originatorKeyInfo = null;
|
||||
private KeyInfo recipientKeyInfo = null;
|
||||
private String algorithmURI = null;
|
||||
@ -2781,7 +2781,7 @@ public class XMLCipher {
|
||||
* @param algorithm
|
||||
*/
|
||||
public AgreementMethodImpl(String algorithm) {
|
||||
agreementMethodInformation = new LinkedList();
|
||||
agreementMethodInformation = new LinkedList<Element>();
|
||||
URI tmpAlgorithm = null;
|
||||
try {
|
||||
tmpAlgorithm = new URI(algorithm);
|
||||
@ -2802,7 +2802,7 @@ public class XMLCipher {
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public Iterator getAgreementMethodInformation() {
|
||||
public Iterator<Element> getAgreementMethodInformation() {
|
||||
return (agreementMethodInformation.iterator());
|
||||
}
|
||||
|
||||
@ -2879,9 +2879,9 @@ public class XMLCipher {
|
||||
_contextDocument.createTextNode(new String(kaNonce)));
|
||||
}
|
||||
if (!agreementMethodInformation.isEmpty()) {
|
||||
Iterator itr = agreementMethodInformation.iterator();
|
||||
Iterator<Element> itr = agreementMethodInformation.iterator();
|
||||
while (itr.hasNext()) {
|
||||
result.appendChild((Element) itr.next());
|
||||
result.appendChild(itr.next());
|
||||
}
|
||||
}
|
||||
if (null != originatorKeyInfo) {
|
||||
@ -3486,7 +3486,7 @@ public class XMLCipher {
|
||||
private String algorithm = null;
|
||||
private int keySize = Integer.MIN_VALUE;
|
||||
private byte[] oaepParams = null;
|
||||
private List encryptionMethodInformation = null;
|
||||
private List<Element> encryptionMethodInformation = null;
|
||||
/**
|
||||
*
|
||||
* @param algorithm
|
||||
@ -3499,7 +3499,7 @@ public class XMLCipher {
|
||||
// complain
|
||||
}
|
||||
this.algorithm = tmpAlgorithm.toString();
|
||||
encryptionMethodInformation = new LinkedList();
|
||||
encryptionMethodInformation = new LinkedList<Element>();
|
||||
}
|
||||
/** @inheritDoc */
|
||||
public String getAlgorithm() {
|
||||
@ -3522,7 +3522,7 @@ public class XMLCipher {
|
||||
oaepParams = params;
|
||||
}
|
||||
/** @inheritDoc */
|
||||
public Iterator getEncryptionMethodInformation() {
|
||||
public Iterator<Element> getEncryptionMethodInformation() {
|
||||
return (encryptionMethodInformation.iterator());
|
||||
}
|
||||
/** @inheritDoc */
|
||||
@ -3565,8 +3565,8 @@ public class XMLCipher {
|
||||
new String(oaepParams))));
|
||||
}
|
||||
if (!encryptionMethodInformation.isEmpty()) {
|
||||
Iterator itr = encryptionMethodInformation.iterator();
|
||||
result.appendChild((Element) itr.next());
|
||||
Iterator<Element> itr = encryptionMethodInformation.iterator();
|
||||
result.appendChild(itr.next());
|
||||
}
|
||||
|
||||
return (result);
|
||||
@ -3582,13 +3582,13 @@ public class XMLCipher {
|
||||
// </complexType>
|
||||
private class EncryptionPropertiesImpl implements EncryptionProperties {
|
||||
private String id = null;
|
||||
private List encryptionProperties = null;
|
||||
private List<EncryptionProperty> encryptionProperties = null;
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public EncryptionPropertiesImpl() {
|
||||
encryptionProperties = new LinkedList();
|
||||
encryptionProperties = new LinkedList<EncryptionProperty>();
|
||||
}
|
||||
/** @inheritDoc */
|
||||
public String getId() {
|
||||
@ -3599,7 +3599,7 @@ public class XMLCipher {
|
||||
this.id = id;
|
||||
}
|
||||
/** @inheritDoc */
|
||||
public Iterator getEncryptionProperties() {
|
||||
public Iterator<EncryptionProperty> getEncryptionProperties() {
|
||||
return (encryptionProperties.iterator());
|
||||
}
|
||||
/** @inheritDoc */
|
||||
@ -3625,7 +3625,7 @@ public class XMLCipher {
|
||||
if (null != id) {
|
||||
result.setAttributeNS(null, EncryptionConstants._ATT_ID, id);
|
||||
}
|
||||
Iterator itr = getEncryptionProperties();
|
||||
Iterator<EncryptionProperty> itr = getEncryptionProperties();
|
||||
while (itr.hasNext()) {
|
||||
result.appendChild(((EncryptionPropertyImpl)
|
||||
itr.next()).toElement());
|
||||
@ -3647,15 +3647,15 @@ public class XMLCipher {
|
||||
private class EncryptionPropertyImpl implements EncryptionProperty {
|
||||
private String target = null;
|
||||
private String id = null;
|
||||
private HashMap attributeMap = new HashMap();
|
||||
private List encryptionInformation = null;
|
||||
private HashMap<String,String> attributeMap = new HashMap<String,String>();
|
||||
private List<Element> encryptionInformation = null;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public EncryptionPropertyImpl() {
|
||||
encryptionInformation = new LinkedList();
|
||||
encryptionInformation = new LinkedList<Element>();
|
||||
}
|
||||
/** @inheritDoc */
|
||||
public String getTarget() {
|
||||
@ -3692,14 +3692,14 @@ public class XMLCipher {
|
||||
}
|
||||
/** @inheritDoc */
|
||||
public String getAttribute(String attribute) {
|
||||
return (String) attributeMap.get(attribute);
|
||||
return attributeMap.get(attribute);
|
||||
}
|
||||
/** @inheritDoc */
|
||||
public void setAttribute(String attribute, String value) {
|
||||
attributeMap.put(attribute, value);
|
||||
}
|
||||
/** @inheritDoc */
|
||||
public Iterator getEncryptionInformation() {
|
||||
public Iterator<Element> getEncryptionInformation() {
|
||||
return (encryptionInformation.iterator());
|
||||
}
|
||||
/** @inheritDoc */
|
||||
@ -3821,8 +3821,8 @@ public class XMLCipher {
|
||||
// </complexType>
|
||||
//</element>
|
||||
private class ReferenceListImpl implements ReferenceList {
|
||||
private Class sentry;
|
||||
private List references;
|
||||
private Class<?> sentry;
|
||||
private List<Reference> references;
|
||||
/**
|
||||
*
|
||||
* @param type
|
||||
@ -3835,7 +3835,7 @@ public class XMLCipher {
|
||||
} else {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
references = new LinkedList();
|
||||
references = new LinkedList<Reference>();
|
||||
}
|
||||
/** @inheritDoc */
|
||||
public void add(Reference reference) {
|
||||
@ -3860,7 +3860,7 @@ public class XMLCipher {
|
||||
return (references.isEmpty());
|
||||
}
|
||||
/** @inheritDoc */
|
||||
public Iterator getReferences() {
|
||||
public Iterator<Reference> getReferences() {
|
||||
return (references.iterator());
|
||||
}
|
||||
|
||||
@ -3869,9 +3869,9 @@ public class XMLCipher {
|
||||
_contextDocument,
|
||||
EncryptionConstants.EncryptionSpecNS,
|
||||
EncryptionConstants._TAG_REFERENCELIST);
|
||||
Iterator eachReference = references.iterator();
|
||||
Iterator<Reference> eachReference = references.iterator();
|
||||
while (eachReference.hasNext()) {
|
||||
Reference reference = (Reference) eachReference.next();
|
||||
Reference reference = eachReference.next();
|
||||
result.appendChild(
|
||||
((ReferenceImpl) reference).toElement());
|
||||
}
|
||||
@ -3894,18 +3894,18 @@ public class XMLCipher {
|
||||
*/
|
||||
private abstract class ReferenceImpl implements Reference {
|
||||
private String uri;
|
||||
private List referenceInformation;
|
||||
private List<Element> referenceInformation;
|
||||
|
||||
ReferenceImpl(String _uri) {
|
||||
this.uri = _uri;
|
||||
referenceInformation = new LinkedList();
|
||||
referenceInformation = new LinkedList<Element>();
|
||||
}
|
||||
/** @inheritDoc */
|
||||
public String getURI() {
|
||||
return (uri);
|
||||
}
|
||||
/** @inheritDoc */
|
||||
public Iterator getElementRetrievalInformation() {
|
||||
public Iterator<Element> getElementRetrievalInformation() {
|
||||
return (referenceInformation.iterator());
|
||||
}
|
||||
/** @inheritDoc */
|
||||
|
@ -97,12 +97,12 @@ public class KeyInfo extends SignatureElementProxy {
|
||||
/** {@link java.util.logging} logging facility */
|
||||
static java.util.logging.Logger log =
|
||||
java.util.logging.Logger.getLogger(KeyInfo.class.getName());
|
||||
List x509Datas=null;
|
||||
List encryptedKeys=null;
|
||||
List<X509Data> x509Datas=null;
|
||||
List<EncryptedKey> encryptedKeys=null;
|
||||
|
||||
static final List nullList;
|
||||
static final List<StorageResolver> nullList;
|
||||
static {
|
||||
List list = new ArrayList();
|
||||
List<StorageResolver> list = new ArrayList<StorageResolver>(1);
|
||||
list.add(null);
|
||||
nullList = Collections.unmodifiableList(list);
|
||||
}
|
||||
@ -297,7 +297,7 @@ public class KeyInfo extends SignatureElementProxy {
|
||||
*/
|
||||
public void add(X509Data x509data) {
|
||||
if (x509Datas==null)
|
||||
x509Datas=new ArrayList();
|
||||
x509Datas=new ArrayList<X509Data>();
|
||||
x509Datas.add(x509data);
|
||||
this._constructionElement.appendChild(x509data.getElement());
|
||||
XMLUtils.addReturnToElement(this._constructionElement);
|
||||
@ -313,7 +313,7 @@ public class KeyInfo extends SignatureElementProxy {
|
||||
public void add(EncryptedKey encryptedKey)
|
||||
throws XMLEncryptionException {
|
||||
if (encryptedKeys==null)
|
||||
encryptedKeys=new ArrayList();
|
||||
encryptedKeys=new ArrayList<EncryptedKey>();
|
||||
encryptedKeys.add(encryptedKey);
|
||||
XMLCipher cipher = XMLCipher.getInstance();
|
||||
this._constructionElement.appendChild(cipher.martial(encryptedKey));
|
||||
@ -541,7 +541,7 @@ public class KeyInfo extends SignatureElementProxy {
|
||||
*/
|
||||
public X509Data itemX509Data(int i) throws XMLSecurityException {
|
||||
if (x509Datas!=null) {
|
||||
return (X509Data) x509Datas.get(i);
|
||||
return x509Datas.get(i);
|
||||
}
|
||||
Element e = XMLUtils.selectDsNode(this._constructionElement.getFirstChild(),
|
||||
Constants._TAG_X509DATA,i);
|
||||
@ -562,7 +562,7 @@ public class KeyInfo extends SignatureElementProxy {
|
||||
|
||||
public EncryptedKey itemEncryptedKey(int i) throws XMLSecurityException {
|
||||
if (encryptedKeys!=null) {
|
||||
return (EncryptedKey) encryptedKeys.get(i);
|
||||
return encryptedKeys.get(i);
|
||||
}
|
||||
Element e =
|
||||
XMLUtils.selectXencNode(this._constructionElement.getFirstChild(),
|
||||
@ -728,16 +728,16 @@ public class KeyInfo extends SignatureElementProxy {
|
||||
PublicKey getPublicKeyFromStaticResolvers() throws KeyResolverException {
|
||||
int length=KeyResolver.length();
|
||||
int storageLength=this._storageResolvers.size();
|
||||
Iterator it= KeyResolver.iterator();
|
||||
Iterator<KeyResolverSpi> it= KeyResolver.iterator();
|
||||
for (int i = 0; i < length; i++) {
|
||||
KeyResolverSpi keyResolver = (KeyResolverSpi) it.next();
|
||||
KeyResolverSpi keyResolver = it.next();
|
||||
Node currentChild=this._constructionElement.getFirstChild();
|
||||
String uri= this.getBaseURI();
|
||||
while (currentChild!=null) {
|
||||
if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
|
||||
for (int k = 0; k < storageLength; k++) {
|
||||
StorageResolver storage =
|
||||
(StorageResolver) this._storageResolvers.get(k);
|
||||
this._storageResolvers.get(k);
|
||||
|
||||
PublicKey pk =
|
||||
keyResolver.engineLookupAndResolvePublicKey((Element) currentChild,
|
||||
@ -776,7 +776,7 @@ public class KeyInfo extends SignatureElementProxy {
|
||||
if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
|
||||
for (int k = 0; k < storageLength; k++) {
|
||||
StorageResolver storage =
|
||||
(StorageResolver) this._storageResolvers.get(k);
|
||||
this._storageResolvers.get(k);
|
||||
PublicKey pk = keyResolver
|
||||
.engineLookupAndResolvePublicKey((Element) currentChild, uri, storage);
|
||||
|
||||
@ -845,9 +845,9 @@ public class KeyInfo extends SignatureElementProxy {
|
||||
String uri=this.getBaseURI();
|
||||
int length= KeyResolver.length();
|
||||
int storageLength=this._storageResolvers.size();
|
||||
Iterator it = KeyResolver.iterator();
|
||||
Iterator<KeyResolverSpi> it = KeyResolver.iterator();
|
||||
for (int i = 0; i <length; i++) {
|
||||
KeyResolverSpi keyResolver = (KeyResolverSpi) it.next();
|
||||
KeyResolverSpi keyResolver = it.next();
|
||||
X509Certificate cert= applyCurrentResolver(uri, storageLength, keyResolver);
|
||||
if (cert!=null) {
|
||||
KeyResolver.hit(it);
|
||||
@ -863,7 +863,7 @@ public class KeyInfo extends SignatureElementProxy {
|
||||
if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
|
||||
for (int k = 0; k < storageLength; k++) {
|
||||
StorageResolver storage =
|
||||
(StorageResolver) this._storageResolvers.get(k);
|
||||
this._storageResolvers.get(k);
|
||||
|
||||
X509Certificate cert = keyResolver
|
||||
.engineLookupResolveX509Certificate((Element) currentChild, uri,
|
||||
@ -944,9 +944,9 @@ public class KeyInfo extends SignatureElementProxy {
|
||||
SecretKey getSecretKeyFromStaticResolvers() throws KeyResolverException {
|
||||
final int length=KeyResolver.length();
|
||||
int storageLength=this._storageResolvers.size();
|
||||
Iterator it = KeyResolver.iterator();
|
||||
Iterator<KeyResolverSpi> it = KeyResolver.iterator();
|
||||
for (int i = 0; i < length; i++) {
|
||||
KeyResolverSpi keyResolver = (KeyResolverSpi) it.next();
|
||||
KeyResolverSpi keyResolver = it.next();
|
||||
|
||||
Node currentChild=this._constructionElement.getFirstChild();
|
||||
String uri=this.getBaseURI();
|
||||
@ -954,7 +954,7 @@ public class KeyInfo extends SignatureElementProxy {
|
||||
if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
|
||||
for (int k = 0; k < storageLength; k++) {
|
||||
StorageResolver storage =
|
||||
(StorageResolver) this._storageResolvers.get(k);
|
||||
this._storageResolvers.get(k);
|
||||
|
||||
SecretKey sk =
|
||||
keyResolver.engineLookupAndResolveSecretKey((Element) currentChild,
|
||||
@ -992,7 +992,7 @@ public class KeyInfo extends SignatureElementProxy {
|
||||
if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
|
||||
for (int k = 0; k < storageLength; k++) {
|
||||
StorageResolver storage =
|
||||
(StorageResolver) this._storageResolvers.get(k);
|
||||
this._storageResolvers.get(k);
|
||||
|
||||
SecretKey sk = keyResolver
|
||||
.engineLookupAndResolveSecretKey((Element) currentChild, uri, storage);
|
||||
@ -1012,7 +1012,7 @@ public class KeyInfo extends SignatureElementProxy {
|
||||
/**
|
||||
* Stores the individual (per-KeyInfo) {@link KeyResolver}s
|
||||
*/
|
||||
List _internalKeyResolvers = null;
|
||||
List<KeyResolverSpi> _internalKeyResolvers = null;
|
||||
|
||||
/**
|
||||
* This method is used to add a custom {@link KeyResolverSpi} to a KeyInfo
|
||||
@ -1022,7 +1022,7 @@ public class KeyInfo extends SignatureElementProxy {
|
||||
*/
|
||||
public void registerInternalKeyResolver(KeyResolverSpi realKeyResolver) {
|
||||
if (_internalKeyResolvers==null) {
|
||||
_internalKeyResolvers=new ArrayList();
|
||||
_internalKeyResolvers=new ArrayList<KeyResolverSpi>();
|
||||
}
|
||||
this._internalKeyResolvers.add(realKeyResolver);
|
||||
}
|
||||
@ -1044,11 +1044,11 @@ public class KeyInfo extends SignatureElementProxy {
|
||||
* @return the KeyResolverSpi for the index.
|
||||
*/
|
||||
KeyResolverSpi itemInternalKeyResolver(int i) {
|
||||
return (KeyResolverSpi) this._internalKeyResolvers.get(i);
|
||||
return this._internalKeyResolvers.get(i);
|
||||
}
|
||||
|
||||
/** Field _storageResolvers */
|
||||
List _storageResolvers = nullList;
|
||||
List<StorageResolver> _storageResolvers = nullList;
|
||||
|
||||
/**
|
||||
* Method addStorageResolver
|
||||
@ -1057,7 +1057,7 @@ public class KeyInfo extends SignatureElementProxy {
|
||||
*/
|
||||
public void addStorageResolver(StorageResolver storageResolver) {
|
||||
if (_storageResolvers == nullList ){
|
||||
_storageResolvers=new ArrayList();
|
||||
_storageResolvers=new ArrayList<StorageResolver>();
|
||||
}
|
||||
this._storageResolvers.add(storageResolver);
|
||||
|
||||
|
@ -52,7 +52,7 @@ public class KeyResolver {
|
||||
static boolean _alreadyInitialized = false;
|
||||
|
||||
/** Field _resolverVector */
|
||||
static List _resolverVector = null;
|
||||
static List<KeyResolver> _resolverVector = null;
|
||||
|
||||
/** Field _resolverSpi */
|
||||
protected KeyResolverSpi _resolverSpi = null;
|
||||
@ -85,12 +85,12 @@ public class KeyResolver {
|
||||
return KeyResolver._resolverVector.size();
|
||||
}
|
||||
|
||||
public static void hit(Iterator hintI) {
|
||||
public static void hit(Iterator<KeyResolverSpi> hintI) {
|
||||
ResolverIterator hint = (ResolverIterator) hintI;
|
||||
int i = hint.i;
|
||||
if (i!=1 && hint.res ==_resolverVector) {
|
||||
List resolverVector=(List)((ArrayList)_resolverVector).clone();
|
||||
Object ob=resolverVector.remove(i-1);
|
||||
List<KeyResolver> resolverVector=getResolverVectorClone();
|
||||
KeyResolver ob=resolverVector.remove(i-1);
|
||||
resolverVector.add(0,ob);
|
||||
_resolverVector=resolverVector;
|
||||
} else {
|
||||
@ -113,12 +113,9 @@ public class KeyResolver {
|
||||
throws KeyResolverException {
|
||||
|
||||
// use the old vector to not be hit by updates
|
||||
List resolverVector = KeyResolver._resolverVector;
|
||||
for (int i = 0; i < resolverVector.size(); i++) {
|
||||
KeyResolver resolver=
|
||||
(KeyResolver) resolverVector.get(i);
|
||||
|
||||
if (resolver==null) {
|
||||
List<KeyResolver> resolverVector = KeyResolver._resolverVector;
|
||||
for (KeyResolver resolver : resolverVector) {
|
||||
if (resolver==null) {
|
||||
Object exArgs[] = {
|
||||
(((element != null)
|
||||
&& (element.getNodeType() == Node.ELEMENT_NODE))
|
||||
@ -157,10 +154,8 @@ public class KeyResolver {
|
||||
Element element, String BaseURI, StorageResolver storage)
|
||||
throws KeyResolverException {
|
||||
|
||||
List resolverVector = KeyResolver._resolverVector;
|
||||
for (int i = 0; i < resolverVector.size(); i++) {
|
||||
KeyResolver resolver=
|
||||
(KeyResolver) resolverVector.get(i);
|
||||
List<KeyResolver> resolverVector = KeyResolver._resolverVector;
|
||||
for (KeyResolver resolver : resolverVector) {
|
||||
|
||||
if (resolver==null) {
|
||||
Object exArgs[] = {
|
||||
@ -176,11 +171,11 @@ public class KeyResolver {
|
||||
|
||||
PublicKey cert=resolver.resolvePublicKey(element, BaseURI, storage);
|
||||
if (cert!=null) {
|
||||
if (i!=0 && resolverVector==_resolverVector) {
|
||||
if (resolverVector.indexOf(resolver)!=0 && resolverVector==_resolverVector) {
|
||||
//update resolver.
|
||||
resolverVector=(List)((ArrayList)_resolverVector).clone();
|
||||
Object ob=resolverVector.remove(i);
|
||||
resolverVector.add(0,ob);
|
||||
resolverVector=getResolverVectorClone();
|
||||
resolverVector.remove(resolver);
|
||||
resolverVector.add(0,resolver);
|
||||
_resolverVector=resolverVector;
|
||||
}
|
||||
return cert;
|
||||
@ -195,13 +190,19 @@ public class KeyResolver {
|
||||
throw new KeyResolverException("utils.resolver.noClass", exArgs);
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static List<KeyResolver> getResolverVectorClone() {
|
||||
return (List<KeyResolver>)((ArrayList<KeyResolver>)_resolverVector).clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* The init() function is called by com.sun.org.apache.xml.internal.security.Init.init()
|
||||
*/
|
||||
public static void init() {
|
||||
|
||||
if (!KeyResolver._alreadyInitialized) {
|
||||
KeyResolver._resolverVector = new ArrayList(10);
|
||||
KeyResolver._resolverVector = new ArrayList<KeyResolver>(10);
|
||||
_alreadyInitialized = true;
|
||||
}
|
||||
}
|
||||
@ -230,8 +231,8 @@ public class KeyResolver {
|
||||
*
|
||||
* @param className
|
||||
*/
|
||||
public static void registerAtStart(String className) {
|
||||
KeyResolver._resolverVector.add(0, className);
|
||||
public static void registerAtStart(String className) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
|
||||
register(className);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -322,11 +323,11 @@ public class KeyResolver {
|
||||
return this._resolverSpi.getClass().getName();
|
||||
}
|
||||
|
||||
static class ResolverIterator implements Iterator {
|
||||
List res;
|
||||
Iterator it;
|
||||
static class ResolverIterator implements Iterator<KeyResolverSpi> {
|
||||
List<KeyResolver> res;
|
||||
Iterator<KeyResolver> it;
|
||||
int i;
|
||||
public ResolverIterator(List list) {
|
||||
public ResolverIterator(List<KeyResolver> list) {
|
||||
res = list;
|
||||
it = res.iterator();
|
||||
}
|
||||
@ -335,9 +336,9 @@ public class KeyResolver {
|
||||
return it.hasNext();
|
||||
}
|
||||
|
||||
public Object next() {
|
||||
public KeyResolverSpi next() {
|
||||
i++;
|
||||
KeyResolver resolver = (KeyResolver) it.next();
|
||||
KeyResolver resolver = it.next();
|
||||
if (resolver==null) {
|
||||
throw new RuntimeException("utils.resolver.noClass");
|
||||
}
|
||||
@ -351,7 +352,7 @@ public class KeyResolver {
|
||||
}
|
||||
|
||||
};
|
||||
public static Iterator iterator() {
|
||||
public static Iterator<KeyResolverSpi> iterator() {
|
||||
return new ResolverIterator(_resolverVector);
|
||||
}
|
||||
}
|
||||
|
8
jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolverSpi.java
8
jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/keyresolver/KeyResolverSpi.java
@ -32,7 +32,7 @@ import org.w3c.dom.Element;
|
||||
/**
|
||||
* This class is abstract class for a child KeyInfo Elemnet.
|
||||
*
|
||||
* If you want the your KeyResolver, at firstly you must extand this class, and register
|
||||
* If you want your KeyResolver, at first you must extend this class, and register
|
||||
* as following in config.xml
|
||||
* <PRE>
|
||||
* <KeyResolver URI="http://www.w3.org/2000/09/xmldsig#KeyValue"
|
||||
@ -177,7 +177,7 @@ public abstract class KeyResolverSpi {
|
||||
}
|
||||
|
||||
/** Field _properties */
|
||||
protected java.util.Map _properties = null;
|
||||
protected java.util.Map<String,String> _properties = null;
|
||||
|
||||
protected boolean globalResolver=false;
|
||||
|
||||
@ -189,7 +189,7 @@ public abstract class KeyResolverSpi {
|
||||
*/
|
||||
public void engineSetProperty(String key, String value) {
|
||||
if (_properties==null)
|
||||
_properties=new HashMap();
|
||||
_properties=new HashMap<String,String>();
|
||||
this._properties.put(key, value);
|
||||
}
|
||||
|
||||
@ -203,7 +203,7 @@ public abstract class KeyResolverSpi {
|
||||
if (_properties==null)
|
||||
return null;
|
||||
|
||||
return (String) this._properties.get(key);
|
||||
return this._properties.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -278,18 +278,18 @@ public class RetrievalMethodResolver extends KeyResolverSpi {
|
||||
return null;
|
||||
}
|
||||
|
||||
static Element getDocumentElement(Set set) {
|
||||
Iterator it=set.iterator();
|
||||
static Element getDocumentElement(Set<Node> set) {
|
||||
Iterator<Node> it=set.iterator();
|
||||
Element e=null;
|
||||
while (it.hasNext()) {
|
||||
Node currentNode=(Node)it.next();
|
||||
Node currentNode=it.next();
|
||||
if (currentNode instanceof Element) {
|
||||
e=(Element)currentNode;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
List parents=new ArrayList(10);
|
||||
List<Element> parents=new ArrayList<Element>(10);
|
||||
|
||||
//Obtain all the parents of the elemnt
|
||||
do {
|
||||
@ -301,10 +301,10 @@ public class RetrievalMethodResolver extends KeyResolverSpi {
|
||||
e=(Element)n;
|
||||
} while (e!=null);
|
||||
//Visit them in reverse order.
|
||||
ListIterator it2=parents.listIterator(parents.size()-1);
|
||||
ListIterator<Element> it2=parents.listIterator(parents.size()-1);
|
||||
Element ele=null;
|
||||
while (it2.hasPrevious()) {
|
||||
ele=(Element)it2.previous();
|
||||
ele=it2.previous();
|
||||
if (set.contains(ele)) {
|
||||
return ele;
|
||||
}
|
||||
|
@ -42,10 +42,10 @@ public class StorageResolver {
|
||||
java.util.logging.Logger.getLogger(StorageResolver.class.getName());
|
||||
|
||||
/** Field _storageResolvers */
|
||||
List _storageResolvers = null;
|
||||
List<Object> _storageResolvers = null;
|
||||
|
||||
/** Field _iterator */
|
||||
Iterator _iterator = null;
|
||||
Iterator<Object> _iterator = null;
|
||||
|
||||
/**
|
||||
* Constructor StorageResolver
|
||||
@ -69,7 +69,7 @@ public class StorageResolver {
|
||||
*/
|
||||
public void add(StorageResolverSpi resolver) {
|
||||
if (_storageResolvers==null)
|
||||
_storageResolvers=new ArrayList();
|
||||
_storageResolvers=new ArrayList<Object>();
|
||||
this._storageResolvers.add(resolver);
|
||||
|
||||
this._iterator = null;
|
||||
@ -121,11 +121,11 @@ public class StorageResolver {
|
||||
* @return the iterator for the resolvers.
|
||||
*
|
||||
*/
|
||||
public Iterator getIterator() {
|
||||
public Iterator<Object> getIterator() {
|
||||
|
||||
if (this._iterator == null) {
|
||||
if (_storageResolvers==null)
|
||||
_storageResolvers=new ArrayList();
|
||||
_storageResolvers=new ArrayList<Object>();
|
||||
this._iterator = new StorageResolverIterator(this._storageResolvers.iterator());
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ public class StorageResolver {
|
||||
|
||||
if (this._iterator == null) {
|
||||
if (_storageResolvers==null)
|
||||
_storageResolvers=new ArrayList();
|
||||
_storageResolvers=new ArrayList<Object>();
|
||||
this._iterator = new StorageResolverIterator(this._storageResolvers.iterator());
|
||||
}
|
||||
|
||||
@ -163,17 +163,17 @@ public class StorageResolver {
|
||||
* @author $Author: mullan $
|
||||
* @version $Revision: 1.5 $
|
||||
*/
|
||||
static class StorageResolverIterator implements Iterator {
|
||||
static class StorageResolverIterator implements Iterator<Object> {
|
||||
|
||||
/** Field _resolvers */
|
||||
Iterator _resolvers = null;
|
||||
Iterator<Object> _resolvers = null;
|
||||
|
||||
/**
|
||||
* Constructor FilesystemIterator
|
||||
*
|
||||
* @param resolvers
|
||||
*/
|
||||
public StorageResolverIterator(Iterator resolvers) {
|
||||
public StorageResolverIterator(Iterator<Object> resolvers) {
|
||||
this._resolvers = resolvers;
|
||||
}
|
||||
|
||||
|
2
jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolverSpi.java
2
jdk/src/share/classes/com/sun/org/apache/xml/internal/security/keys/storage/StorageResolverSpi.java
@ -36,5 +36,5 @@ public abstract class StorageResolverSpi {
|
||||
*
|
||||
* @return the iterator for the storage
|
||||
*/
|
||||
public abstract Iterator getIterator();
|
||||
public abstract Iterator<?> getIterator();
|
||||
}
|
||||
|
@ -54,10 +54,10 @@ public class CertsInFilesystemDirectoryResolver extends StorageResolverSpi {
|
||||
String _merlinsCertificatesDir = null;
|
||||
|
||||
/** Field _certs */
|
||||
private List _certs = new ArrayList();
|
||||
private List<X509Certificate> _certs = new ArrayList<X509Certificate>();
|
||||
|
||||
/** Field _iterator */
|
||||
Iterator _iterator = null;
|
||||
Iterator<X509Certificate> _iterator = null;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -83,7 +83,7 @@ public class CertsInFilesystemDirectoryResolver extends StorageResolverSpi {
|
||||
private void readCertsFromHarddrive() throws StorageResolverException {
|
||||
|
||||
File certDir = new File(this._merlinsCertificatesDir);
|
||||
ArrayList al = new ArrayList();
|
||||
ArrayList<String> al = new ArrayList<String>();
|
||||
String[] names = certDir.list();
|
||||
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
@ -108,7 +108,7 @@ public class CertsInFilesystemDirectoryResolver extends StorageResolverSpi {
|
||||
|
||||
for (int i = 0; i < al.size(); i++) {
|
||||
String filename = certDir.getAbsolutePath() + File.separator
|
||||
+ (String) al.get(i);
|
||||
+ al.get(i);
|
||||
File file = new File(filename);
|
||||
boolean added = false;
|
||||
String dn = null;
|
||||
@ -146,7 +146,7 @@ public class CertsInFilesystemDirectoryResolver extends StorageResolverSpi {
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public Iterator getIterator() {
|
||||
public Iterator<X509Certificate> getIterator() {
|
||||
return this._iterator;
|
||||
}
|
||||
|
||||
@ -156,10 +156,10 @@ public class CertsInFilesystemDirectoryResolver extends StorageResolverSpi {
|
||||
* @author $Author: mullan $
|
||||
* @version $Revision: 1.5 $
|
||||
*/
|
||||
private static class FilesystemIterator implements Iterator {
|
||||
private static class FilesystemIterator implements Iterator<X509Certificate> {
|
||||
|
||||
/** Field _certs */
|
||||
List _certs = null;
|
||||
List<X509Certificate> _certs = null;
|
||||
|
||||
/** Field _i */
|
||||
int _i;
|
||||
@ -169,7 +169,7 @@ public class CertsInFilesystemDirectoryResolver extends StorageResolverSpi {
|
||||
*
|
||||
* @param certs
|
||||
*/
|
||||
public FilesystemIterator(List certs) {
|
||||
public FilesystemIterator(List<X509Certificate> certs) {
|
||||
this._certs = certs;
|
||||
this._i = 0;
|
||||
}
|
||||
@ -180,7 +180,7 @@ public class CertsInFilesystemDirectoryResolver extends StorageResolverSpi {
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public Object next() {
|
||||
public X509Certificate next() {
|
||||
return this._certs.get(this._i++);
|
||||
}
|
||||
|
||||
@ -206,8 +206,8 @@ public class CertsInFilesystemDirectoryResolver extends StorageResolverSpi {
|
||||
new CertsInFilesystemDirectoryResolver(
|
||||
"data/ie/baltimore/merlin-examples/merlin-xmldsig-eighteen/certs");
|
||||
|
||||
for (Iterator i = krs.getIterator(); i.hasNext(); ) {
|
||||
X509Certificate cert = (X509Certificate) i.next();
|
||||
for (Iterator<X509Certificate> i = krs.getIterator(); i.hasNext(); ) {
|
||||
X509Certificate cert = i.next();
|
||||
byte[] ski =
|
||||
com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509SKI
|
||||
.getSKIBytesFromCert(cert);
|
||||
|
@ -42,7 +42,7 @@ public class KeyStoreResolver extends StorageResolverSpi {
|
||||
KeyStore _keyStore = null;
|
||||
|
||||
/** Field _iterator */
|
||||
Iterator _iterator = null;
|
||||
Iterator<X509Certificate> _iterator = null;
|
||||
|
||||
/**
|
||||
* Constructor KeyStoreResolver
|
||||
@ -56,7 +56,7 @@ public class KeyStoreResolver extends StorageResolverSpi {
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public Iterator getIterator() {
|
||||
public Iterator<X509Certificate> getIterator() {
|
||||
return this._iterator;
|
||||
}
|
||||
|
||||
@ -66,13 +66,13 @@ public class KeyStoreResolver extends StorageResolverSpi {
|
||||
* @author $Author: mullan $
|
||||
* @version $Revision: 1.5 $
|
||||
*/
|
||||
static class KeyStoreIterator implements Iterator {
|
||||
static class KeyStoreIterator implements Iterator<X509Certificate> {
|
||||
|
||||
/** Field _keyStore */
|
||||
KeyStore _keyStore = null;
|
||||
|
||||
/** Field _aliases */
|
||||
Enumeration _aliases = null;
|
||||
Enumeration<String> _aliases = null;
|
||||
|
||||
/**
|
||||
* Constructor KeyStoreIterator
|
||||
@ -97,12 +97,13 @@ public class KeyStoreResolver extends StorageResolverSpi {
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public Object next() {
|
||||
@SuppressWarnings("unchecked")
|
||||
public X509Certificate next() {
|
||||
|
||||
String alias = (String) this._aliases.nextElement();
|
||||
String alias = this._aliases.nextElement();
|
||||
|
||||
try {
|
||||
return this._keyStore.getCertificate(alias);
|
||||
return (X509Certificate)this._keyStore.getCertificate(alias);
|
||||
} catch (KeyStoreException ex) {
|
||||
return null;
|
||||
}
|
||||
@ -135,8 +136,8 @@ public class KeyStoreResolver extends StorageResolverSpi {
|
||||
|
||||
KeyStoreResolver krs = new KeyStoreResolver(ks);
|
||||
|
||||
for (Iterator i = krs.getIterator(); i.hasNext(); ) {
|
||||
X509Certificate cert = (X509Certificate) i.next();
|
||||
for (Iterator<X509Certificate> i = krs.getIterator(); i.hasNext(); ) {
|
||||
X509Certificate cert = i.next();
|
||||
byte[] ski =
|
||||
com.sun.org.apache.xml.internal.security.keys.content.x509.XMLX509SKI
|
||||
.getSKIBytesFromCert(cert);
|
||||
|
@ -38,7 +38,7 @@ public class SingleCertificateResolver extends StorageResolverSpi {
|
||||
X509Certificate _certificate = null;
|
||||
|
||||
/** Field _iterator */
|
||||
Iterator _iterator = null;
|
||||
Iterator<X509Certificate> _iterator = null;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -51,7 +51,7 @@ public class SingleCertificateResolver extends StorageResolverSpi {
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public Iterator getIterator() {
|
||||
public Iterator<X509Certificate> getIterator() {
|
||||
return this._iterator;
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ public class SingleCertificateResolver extends StorageResolverSpi {
|
||||
* @author $Author: mullan $
|
||||
* @version $Revision: 1.5 $
|
||||
*/
|
||||
static class InternalIterator implements Iterator {
|
||||
static class InternalIterator implements Iterator<X509Certificate> {
|
||||
|
||||
/** Field _alreadyReturned */
|
||||
boolean _alreadyReturned = false;
|
||||
@ -84,7 +84,7 @@ public class SingleCertificateResolver extends StorageResolverSpi {
|
||||
}
|
||||
|
||||
/** @inheritDoc */
|
||||
public Object next() {
|
||||
public X509Certificate next() {
|
||||
|
||||
this._alreadyReturned = true;
|
||||
|
||||
|
@ -28,6 +28,7 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
@ -62,17 +63,17 @@ public class Manifest extends SignatureElementProxy {
|
||||
java.util.logging.Logger.getLogger(Manifest.class.getName());
|
||||
|
||||
/** Field _references */
|
||||
List _references;
|
||||
List<Reference> _references;
|
||||
Element[] _referencesEl;
|
||||
|
||||
/** Field verificationResults[] */
|
||||
private boolean verificationResults[] = null;
|
||||
|
||||
/** Field _resolverProperties */
|
||||
HashMap _resolverProperties = null;
|
||||
Map<String,String> _resolverProperties = null;
|
||||
|
||||
/** Field _perManifestResolvers */
|
||||
List _perManifestResolvers = null;
|
||||
List<ResourceResolver> _perManifestResolvers = null;
|
||||
|
||||
/**
|
||||
* Consturts {@link Manifest}
|
||||
@ -85,7 +86,7 @@ public class Manifest extends SignatureElementProxy {
|
||||
|
||||
XMLUtils.addReturnToElement(this._constructionElement);
|
||||
|
||||
this._references = new ArrayList();
|
||||
this._references = new ArrayList<Reference>();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -117,7 +118,7 @@ public class Manifest extends SignatureElementProxy {
|
||||
}
|
||||
|
||||
// create Vector
|
||||
this._references = new ArrayList(le);
|
||||
this._references = new ArrayList<Reference>(le);
|
||||
|
||||
for (int i = 0; i < le; i++) {
|
||||
this._references.add(null);
|
||||
@ -175,7 +176,7 @@ public class Manifest extends SignatureElementProxy {
|
||||
for (int i = 0; i < this.getLength(); i++) {
|
||||
|
||||
// update the cached Reference object, the Element content is automatically updated
|
||||
Reference currentRef = (Reference) this._references.get(i);
|
||||
Reference currentRef = this._references.get(i);
|
||||
|
||||
currentRef.generateDigestValue();
|
||||
}
|
||||
@ -208,7 +209,7 @@ public class Manifest extends SignatureElementProxy {
|
||||
this._references.set(i, ref);
|
||||
}
|
||||
|
||||
return (Reference) this._references.get(i);
|
||||
return this._references.get(i);
|
||||
|
||||
}
|
||||
|
||||
@ -323,12 +324,12 @@ public class Manifest extends SignatureElementProxy {
|
||||
try {
|
||||
XMLSignatureInput signedManifestNodes =
|
||||
currentRef.dereferenceURIandPerformTransforms(null);
|
||||
Set nl = signedManifestNodes.getNodeSet();
|
||||
Set<Node> nl = signedManifestNodes.getNodeSet();
|
||||
Manifest referencedManifest = null;
|
||||
Iterator nlIterator = nl.iterator();
|
||||
Iterator<Node> nlIterator = nl.iterator();
|
||||
|
||||
findManifest: while (nlIterator.hasNext()) {
|
||||
Node n = (Node) nlIterator.next();
|
||||
Node n = nlIterator.next();
|
||||
|
||||
if ((n.getNodeType() == Node.ELEMENT_NODE) && ((Element) n)
|
||||
.getNamespaceURI()
|
||||
@ -449,7 +450,7 @@ public class Manifest extends SignatureElementProxy {
|
||||
return;
|
||||
}
|
||||
if (_perManifestResolvers==null)
|
||||
_perManifestResolvers = new ArrayList();
|
||||
_perManifestResolvers = new ArrayList<ResourceResolver>();
|
||||
this._perManifestResolvers.add(resolver);
|
||||
|
||||
}
|
||||
@ -465,7 +466,7 @@ public class Manifest extends SignatureElementProxy {
|
||||
return;
|
||||
}
|
||||
if (_perManifestResolvers==null)
|
||||
_perManifestResolvers = new ArrayList();
|
||||
_perManifestResolvers = new ArrayList<ResourceResolver>();
|
||||
this._perManifestResolvers.add(new ResourceResolver(resolverSpi));
|
||||
|
||||
}
|
||||
@ -479,7 +480,7 @@ public class Manifest extends SignatureElementProxy {
|
||||
*/
|
||||
public void setResolverProperty(String key, String value) {
|
||||
if (_resolverProperties==null) {
|
||||
_resolverProperties=new HashMap(10);
|
||||
_resolverProperties=new HashMap<String, String>(10);
|
||||
}
|
||||
this._resolverProperties.put(key, value);
|
||||
}
|
||||
@ -491,7 +492,7 @@ public class Manifest extends SignatureElementProxy {
|
||||
* @return the value
|
||||
*/
|
||||
public String getResolverProperty(String key) {
|
||||
return (String) this._resolverProperties.get(key);
|
||||
return this._resolverProperties.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -436,6 +436,7 @@ private Element digestValueElement;
|
||||
*
|
||||
* @deprecated use getContentsBeforeTransformation
|
||||
*/
|
||||
@Deprecated
|
||||
public XMLSignatureInput getTransformsInput() throws ReferenceNotInitializedException
|
||||
{
|
||||
XMLSignatureInput input=getContentsBeforeTransformation();
|
||||
@ -557,7 +558,7 @@ private Element digestValueElement;
|
||||
|
||||
try {
|
||||
XMLSignatureInput nodes = this.getNodesetBeforeFirstCanonicalization();
|
||||
Set inclusiveNamespaces = new HashSet();
|
||||
Set<String> inclusiveNamespaces = new HashSet<String>();
|
||||
|
||||
{
|
||||
Transforms transforms = this.getTransforms();
|
||||
@ -710,7 +711,7 @@ private Element digestValueElement;
|
||||
XMLSignatureInput output=this.dereferenceURIandPerformTransforms(os);
|
||||
// if signing and c14n11 property == true explicitly add
|
||||
// C14N11 transform if needed
|
||||
if (this.useC14N11 && !validating &&
|
||||
if (Reference.useC14N11 && !validating &&
|
||||
!output.isOutputStreamSet() && !output.isOctetStream()) {
|
||||
if (transforms == null) {
|
||||
transforms = new Transforms(this._doc);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user