Skip to content

Commit

Permalink
Merge pull request #9850 from LinHu2016/OpenJ9_0.21
Browse files Browse the repository at this point in the history
(0.21.0) DDR Back compatible for TLH enable/disable change
  • Loading branch information
keithc-ca committed Jun 11, 2020
2 parents aeb7d90 + 5eb0c10 commit 1ff3d37
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2001, 2019 IBM Corp. and others
* Copyright (c) 2001, 2020 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -191,8 +191,11 @@ public GCObjectHeapIterator objectIterator(boolean includeLiveObjects, boolean i
AlgorithmVersion version = AlgorithmVersion.getVersionOf(AlgorithmVersion.GC_OBJECT_HEAP_ITERATOR_ADDRESS_ORDERED_LIST_VERSION);
switch (version.getAlgorithmVersion()) {
// Add case statements for new algorithm versions
default:
case 0:
iterator = new GCObjectHeapIteratorAddressOrderedList_V1(U8Pointer.cast(getLowAddress()), U8Pointer.cast(getWalkableHighAddress()), includeLiveObjects, includeDeadObjects);
break;
default:
iterator = new GCObjectHeapIteratorAddressOrderedList_V2(U8Pointer.cast(getLowAddress()), U8Pointer.cast(getWalkableHighAddress()), includeLiveObjects, includeDeadObjects);
}
} else {
//there is nothing we can walk here (generally means it is either free, uncommitted, or an arraylet leaf)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@

import static com.ibm.j9ddr.vm29.events.EventManager.raiseCorruptDataEvent;

import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
Expand All @@ -31,6 +33,7 @@
import com.ibm.j9ddr.CorruptDataException;
import com.ibm.j9ddr.vm29.j9.ObjectModel;
import com.ibm.j9ddr.vm29.pointer.U8Pointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9ModronThreadLocalHeapPointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9BuildFlags;
import com.ibm.j9ddr.vm29.pointer.generated.J9ObjectPointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9VMThreadPointer;
Expand All @@ -41,6 +44,8 @@

class GCObjectHeapIteratorAddressOrderedList_V1 extends GCObjectHeapIterator
{
private static Method realHeapAllocMethod = null;

protected J9ObjectPointer currentObject;
protected U8Pointer scanPtr;
protected U8Pointer scanPtrTop;
Expand Down Expand Up @@ -75,9 +80,12 @@ protected GCObjectHeapIteratorAddressOrderedList_V1(U8Pointer base, U8Pointer to
excludedRangeList.add(new U8Pointer[] {heapAlloc, heapTop});
} else {
/* Might be an instrumented VM */
U8Pointer realHeapTop = adjustedToRange(vmThread.allocateThreadLocalHeap().realHeapTop(), base, top);
if(realHeapTop.notNull() && isSomethingToAdd(heapAlloc, realHeapTop)) {
excludedRangeList.add(new U8Pointer[] {heapAlloc, realHeapTop});
/* realHeapAlloc = allocateThreadLocalHeap.realHeapAlloc in V1, = heapAlloc in V2 */
U8Pointer realHeapAlloc = adjustedToRange(getRealHeapAlloc(vmThread.allocateThreadLocalHeap(), heapAlloc), base, top);
/* realHeapTop = heapTop in V1, = allocateThreadLocalHeap.realHeapTop in V2 */
U8Pointer realHeapTop = adjustedToRange(getRealHeapTop(vmThread.allocateThreadLocalHeap(), heapTop), base, top);
if(realHeapAlloc.notNull() && realHeapTop.notNull() && isSomethingToAdd(realHeapAlloc, realHeapTop)) {
excludedRangeList.add(new U8Pointer[] {realHeapAlloc, realHeapTop});
}
}
}
Expand All @@ -91,9 +99,10 @@ protected GCObjectHeapIteratorAddressOrderedList_V1(U8Pointer base, U8Pointer to
excludedRangeList.add(new U8Pointer[] {heapAlloc, heapTop});
} else {
/* Might be an instrumented VM */
U8Pointer realHeapTop = adjustedToRange(vmThread.nonZeroAllocateThreadLocalHeap().realHeapTop(), base, top);
if(realHeapTop.notNull() && isSomethingToAdd(heapAlloc, realHeapTop)) {
excludedRangeList.add(new U8Pointer[] {heapAlloc, realHeapTop});
U8Pointer realHeapAlloc = adjustedToRange(getRealHeapAlloc(vmThread.nonZeroAllocateThreadLocalHeap(), heapAlloc), base, top);
U8Pointer realHeapTop = adjustedToRange(getRealHeapTop(vmThread.nonZeroAllocateThreadLocalHeap(), heapTop), base, top);
if(realHeapAlloc.notNull() && realHeapTop.notNull() && isSomethingToAdd(realHeapAlloc, realHeapTop)) {
excludedRangeList.add(new U8Pointer[] {realHeapAlloc, realHeapTop});
}
}
}
Expand Down Expand Up @@ -133,11 +142,43 @@ public int compare(U8Pointer[] o1, U8Pointer[] o2)
return o1[0].compare(o2[0]);
}
});
excludedRanges = new U8Pointer[excludedRangeList.size()][2];
excludedRanges = new U8Pointer[excludedRangeList.size()][];
excludedRangeList.toArray(excludedRanges);
currentExcludedRange = 0;
}


protected U8Pointer getRealHeapTop(J9ModronThreadLocalHeapPointer threadLocalHeap, U8Pointer heapTop) throws CorruptDataException
{
return heapTop;
}

protected U8Pointer getRealHeapAlloc(J9ModronThreadLocalHeapPointer threadLocalHeap, U8Pointer heapAlloc) throws CorruptDataException
{
Exception exception;
try {
if (null == realHeapAllocMethod) {
realHeapAllocMethod = threadLocalHeap.getClass().getMethod("realHeapAlloc");
}
return (U8Pointer) realHeapAllocMethod.invoke(threadLocalHeap);
} catch (NoSuchMethodException | IllegalAccessException | IllegalArgumentException e) {
exception = e;
} catch (InvocationTargetException e1) {
Throwable cause = e1.getCause();
if (cause instanceof CorruptDataException) {
throw (CorruptDataException)cause;
} else if (cause instanceof RuntimeException) {
throw (RuntimeException)cause;
} else if (cause instanceof Error) {
throw (Error)cause;
}
exception = e1;
}

/* unexpected exception using reflection */
CorruptDataException cd = new CorruptDataException(exception.toString(), exception);
throw cd;
}

private U8Pointer adjustedToRange(U8Pointer ptr, U8Pointer base, U8Pointer top)
{
U8Pointer result = ptr;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*******************************************************************************
* Copyright (c) 1991, 2020 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
* or the Apache License, Version 2.0 which accompanies this distribution and
* is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* This Source Code may also be made available under the following
* Secondary Licenses when the conditions for such availability set
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
* General Public License, version 2 with the GNU Classpath
* Exception [1] and GNU General Public License, version 2 with the
* OpenJDK Assembly Exception [2].
*
* [1] https://www.gnu.org/software/classpath/license.html
* [2] http://openjdk.java.net/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/
package com.ibm.j9ddr.vm29.j9.gc;

import com.ibm.j9ddr.CorruptDataException;
import com.ibm.j9ddr.vm29.pointer.U8Pointer;
import com.ibm.j9ddr.vm29.pointer.generated.J9ModronThreadLocalHeapPointer;

import java.util.ArrayList;

class GCObjectHeapIteratorAddressOrderedList_V2 extends GCObjectHeapIteratorAddressOrderedList_V1 {

protected GCObjectHeapIteratorAddressOrderedList_V2(U8Pointer base, U8Pointer top, boolean includeLiveObjects, boolean includeDeadObjects) throws CorruptDataException
{
super(base, top, includeLiveObjects, includeDeadObjects);
}

@Override
protected U8Pointer getRealHeapTop(J9ModronThreadLocalHeapPointer threadLocalHeap, U8Pointer heapTop) throws CorruptDataException
{
return threadLocalHeap.realHeapTop();
}

@Override
protected U8Pointer getRealHeapAlloc(J9ModronThreadLocalHeapPointer threadLocalHeap, U8Pointer heapAlloc) throws CorruptDataException
{
return heapAlloc;
}
}
2 changes: 2 additions & 0 deletions runtime/ddr/algorithm_versions.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#define VM_HASHTABLE_VERSION 1
#define ALG_VM_J9CLASS_VERSION 1
#define ALG_GC_OBJECT_HEAP_ITERATOR_SEGREGATED_ORDERED_LIST_VERSION 1
#define ALG_GC_OBJECT_HEAP_ITERATOR_ADDRESS_ORDERED_LIST_VERSION 1
#define J9_OBJECT_FIELD_OFFSET_ITERATOR_VERSION 1
#define VM_STACK_GROW_VERSION 1
#define ALG_ROM_HELP_VERSION 1
Expand All @@ -52,6 +53,7 @@ J9DDRConstantTableBegin(DDRAlgorithmVersions)
J9DDRConstantTableEntryWithValue("ALG_GC_ARRAYLET_OBJECT_MODEL_VERSION", ALG_GC_ARRAYLET_OBJECT_MODEL_VERSION)
J9DDRConstantTableEntryWithValue("VM_HASHTABLE_VERSION", VM_HASHTABLE_VERSION)
J9DDRConstantTableEntryWithValue("ALG_VM_J9CLASS_VERSION", ALG_VM_J9CLASS_VERSION)
J9DDRConstantTableEntryWithValue("ALG_GC_OBJECT_HEAP_ITERATOR_ADDRESS_ORDERED_LIST_VERSION", ALG_GC_OBJECT_HEAP_ITERATOR_ADDRESS_ORDERED_LIST_VERSION)
J9DDRConstantTableEntryWithValue("ALG_GC_OBJECT_HEAP_ITERATOR_SEGREGATED_ORDERED_LIST_VERSION", ALG_GC_OBJECT_HEAP_ITERATOR_SEGREGATED_ORDERED_LIST_VERSION)
J9DDRConstantTableEntryWithValue("J9_OBJECT_FIELD_OFFSET_ITERATOR_VERSION", J9_OBJECT_FIELD_OFFSET_ITERATOR_VERSION)
J9DDRConstantTableEntryWithValue("VM_STACK_GROW_VERSION", VM_STACK_GROW_VERSION)
Expand Down

0 comments on commit 1ff3d37

Please sign in to comment.