Skip to content

Commit

Permalink
Merge branch 'feature/objectAccessTracking' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
zakkak committed Dec 3, 2019
2 parents f4a5803 + 5a8208c commit 7721af8
Show file tree
Hide file tree
Showing 34 changed files with 1,556 additions and 755 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ public void initialize() {
// search for the runtime call and register critical methods
for (Method m : RuntimeCalls.class.getDeclaredMethods()) {
int flags = m.getModifiers();
if (Modifier.isStatic(flags) && Modifier.isPublic(flags)) {
final PLATFORM platformAnnotation = m.getAnnotation(PLATFORM.class);
if (Modifier.isStatic(flags) && Modifier.isPublic(flags) && platform().isAcceptedBy(platformAnnotation)) {
new CriticalMethod(RuntimeCalls.class, m.getName(), SignatureDescriptor.create(m.getReturnType(), m.getParameterTypes()));
}
}
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import com.sun.cri.ci.CiTargetMethod.*;
import com.sun.max.annotate.*;
import com.sun.max.unsafe.*;
import com.sun.max.vm.*;
import com.sun.max.vm.actor.member.*;
import com.sun.max.vm.classfile.*;
import com.sun.max.vm.compiler.*;
Expand Down Expand Up @@ -434,6 +435,7 @@ protected void do_tableswitch() {
int casesCodePos = buf.position();
buf.setPosition(pos);
asm.jcc(ConditionFlag.above.negation(), casesCodePos, false);
assert buf.position() - pos == 2;
buf.setPosition(casesCodePos);
do_ProfileSwitchCase(switchProfileIndex, rax);
}
Expand Down Expand Up @@ -545,6 +547,7 @@ protected void do_lookupswitch() {
int matchPos = buf.position();
buf.setPosition(matchTestPos);
asm.jcc(ConditionFlag.equal, matchPos, false);
assert buf.position() - matchTestPos == 2;
buf.setPosition(matchPos);

// Load jump case table entry into rbx and jump to it
Expand Down Expand Up @@ -641,6 +644,7 @@ protected void branchOnConditionWithoutProfile(ConditionFlag cc, int targetBCI,
fallThroughPos = buf.position();
buf.setPosition(jumpNotTakenPos);
asm.jcc(ccNeg, fallThroughPos, false);
assert buf.position() - jumpNotTakenPos == 2;
buf.setPosition(fallThroughPos);
}
}
Expand Down Expand Up @@ -669,8 +673,8 @@ protected void branchOnConditionWithProfileNotTakenTaken(ConditionFlag cc, int t
do_profileNotTakenBranch(bci);
jumpNotTakenPos = buf.position();
placeholderForShortJumpDisp = jumpNotTakenPos + 2;
asm.jmp(placeholderForShortJumpDisp, false);
assert buf.position() - jumpNotTakenPos == 2;
asm.jmp(placeholderForShortJumpDisp, MaxineVM.useNUMAProfiler);
assert buf.position() - jumpNotTakenPos == (MaxineVM.useNUMAProfiler ? 5 : 2);
}

// Start of "taken" code
Expand All @@ -679,6 +683,7 @@ protected void branchOnConditionWithProfileNotTakenTaken(ConditionFlag cc, int t
int notTakenCodePos = buf.position();
buf.setPosition(jumpTakenPos);
asm.jcc(cc, notTakenCodePos, false);
assert buf.position() - jumpTakenPos == 2;
buf.setPosition(notTakenCodePos);
}
do_profileTakenBranch(bci, targetBCI);
Expand All @@ -695,7 +700,8 @@ protected void branchOnConditionWithProfileNotTakenTaken(ConditionFlag cc, int t
if (isConditionalBranch) {
fallThroughPos = buf.position();
buf.setPosition(jumpNotTakenPos);
asm.jmp(fallThroughPos, false);
asm.jmp(fallThroughPos, MaxineVM.useNUMAProfiler);
assert buf.position() - jumpNotTakenPos == (MaxineVM.useNUMAProfiler ? 5 : 2);
buf.setPosition(fallThroughPos);
}

Expand Down Expand Up @@ -735,6 +741,7 @@ protected void branchOnConditionWithProfileTakenNotTaken(ConditionFlag cc, int t
int notTakenCodePos = buf.position();
buf.setPosition(jumpNotTakenPos);
asm.jcc(ccNeg, notTakenCodePos, false);
assert buf.position() - jumpNotTakenPos == 2;
buf.setPosition(notTakenCodePos);
do_profileNotTakenBranch(bci);
}
Expand Down
6 changes: 3 additions & 3 deletions com.oracle.max.vm.native/share/log.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, APT Group, School of Computer Science,
* Copyright (c) 2017, 2019, APT Group, School of Computer Science,
* The University of Manchester. All rights reserved.
* Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
Expand Down Expand Up @@ -75,7 +75,7 @@ void log_lock(void) {
}
}

void allocationProfiler_lock(void) {
void numaProfiler_lock(void) {
int result;
result = mutex_enter_nolog(&allocationProfiler_mutexStruct);
if (result != 0) {
Expand All @@ -90,7 +90,7 @@ void log_unlock(void) {
}
}

void allocationProfiler_unlock(void) {
void numaProfiler_unlock(void) {
int result;
result = mutex_exit_nolog(&allocationProfiler_mutexStruct);
if (result != 0) {
Expand Down
4 changes: 2 additions & 2 deletions com.oracle.max.vm.native/share/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ extern void log_initialize(const char *path);
extern void log_lock(void);
extern void log_unlock(void);

extern void allocationProfiler_lock(void);
extern void allocationProfiler_unlock(void);
extern void numaProfiler_lock(void);
extern void numaProfiler_unlock(void);

extern void log_print_int(int val);
extern void log_print_boolean(char val);
Expand Down
12 changes: 12 additions & 0 deletions com.oracle.max.vm.native/substrate/numa.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,15 @@ int numaNodeOfAddress(jlong address) {
numa_move_pages(0, 1, &ptr, NULL, &status, 0);
return status;
}

int numaConfiguredCPUs() {
return numa_num_configured_cpus();
}

int numaNodeOfCPU(int cpuID) {
return numa_node_of_cpu(cpuID);
}

int numaPageSize() {
return numa_pagesize();
}
11 changes: 10 additions & 1 deletion com.sun.c1x/src/com/sun/c1x/gen/LIRGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import com.sun.cri.xir.CiXirAssembler.XirRegister;
import com.sun.cri.xir.CiXirAssembler.XirTemp;
import com.sun.cri.xir.*;
import com.sun.max.vm.actor.member.*;
import com.sun.max.vm.runtime.FatalError;

/**
Expand Down Expand Up @@ -913,7 +914,15 @@ public void visitLoadField(LoadField x) {
}

XirArgument receiver = toXirArgument(x.object());
XirSnippet snippet = x.isStatic() ? xir.genGetStatic(site(x), receiver, field) : xir.genGetField(site(x), receiver, field);
assert compilation.method instanceof ClassMethodActor;
ClassMethodActor method = (ClassMethodActor) compilation.method;
XirSnippet snippet;
if (method.isTemplate()) {
snippet = x.isStatic() ? xir.genTemplateGetStatic(site(x), receiver, field) :
xir.genTemplateGetField(site(x), receiver, field);
} else {
snippet = x.isStatic() ? xir.genGetStatic(site(x), receiver, field) : xir.genGetField(site(x), receiver, field);
}
emitXir(snippet, x, info, null, true);

if (x.isVolatile()) {
Expand Down
14 changes: 12 additions & 2 deletions com.sun.c1x/src/com/sun/c1x/target/amd64/AMD64LIRAssembler.java
Original file line number Diff line number Diff line change
Expand Up @@ -1895,8 +1895,7 @@ public void emitXirInstructions(LIRXirInstruction xir, XirInstruction[] instruct
masm.repeatMoveWords();
break;

case PointerCAS:

case PointerCAS: {
if ((Boolean) inst.extra && info != null) {
tasm.recordImplicitException(codePos(), info);
}
Expand All @@ -1909,7 +1908,18 @@ public void emitXirInstructions(LIRXirInstruction xir, XirInstruction[] instruct
masm.cmpxchgq(exchangedVal.asRegister(), addr);

break;
}
case IntCAS: {
assert operands[inst.z().index].asRegister().equals(AMD64.rax) : "wrong input z: " + operands[inst.x().index];

CiValue exchangedVal = operands[inst.y().index];
CiValue exchangedAddress = operands[inst.x().index];
CiRegisterValue pointerRegister = assureInRegister(exchangedAddress);
CiAddress addr = new CiAddress(target.wordKind, pointerRegister);
masm.cmpxchgl(exchangedVal.asRegister(), addr);

break;
}
case CallStub: {
XirTemplate stubId = (XirTemplate) inst.extra;
CiRegister result = CiRegister.None;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* Copyright (c) 2019, APT Group, School of Computer Science,
* The University of Manchester. All rights reserved.
* Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand All @@ -15,10 +17,6 @@
* 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 com.sun.c1x.target.amd64;

Expand Down Expand Up @@ -144,6 +142,7 @@ protected XirTemplate buildTemplate(String name, boolean isStub) {
case PointerStoreDisp:
break;
case PointerCAS:
case IntCAS:
if (fixedRAX == null) {
fixedRAX = createRegisterTemp("fixedRAX", target.wordKind, AMD64.rax);
}
Expand All @@ -152,6 +151,7 @@ protected XirTemplate buildTemplate(String name, boolean isStub) {
// z = old value (i.e., the one compared to). Must be in RAX (and so must the result).
currentList.add(new XirInstruction(target.wordKind, XirOp.Mov, fixedRAX, i.z()));
currentList.add(new XirInstruction(i.kind, i.op, i.result, i.x(), i.y(), fixedRAX));
currentList.add(new XirInstruction(target.wordKind, XirOp.Mov, i.result, fixedRAX));
appended = true;
break;
case CallStub:
Expand Down
11 changes: 10 additions & 1 deletion com.sun.cri/src/com/sun/cri/xir/CiXirAssembler.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, APT Group, School of Computer Science,
* Copyright (c) 2017, 2019, APT Group, School of Computer Science,
* The University of Manchester. All rights reserved.
* Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
Expand Down Expand Up @@ -509,6 +509,11 @@ public enum XirOp {
* if it was equal to {@code y}.
*/
PointerCAS,
/**
* Compare value at at address {@code x} with value in {@code y} and store value {@code z} at address {@code x}
* if it was equal to {@code y}.
*/
IntCAS,
/**
* Call the {@link XirTemplate.GlobalFlags#GLOBAL_STUB shared stub} defined by {@code extra} with {@code args} and put the result in {@code r}.
*/
Expand Down Expand Up @@ -722,6 +727,10 @@ public void pcas(CiKind kind, XirOperand result, XirOperand pointer, XirOperand
append(new XirInstruction(kind, null, PointerCAS, result, pointer, newValue, oldValue));
}

public void icas(CiKind kind, XirOperand result, XirOperand pointer, XirOperand newValue, XirOperand oldValue) {
append(new XirInstruction(kind, null, IntCAS, result, pointer, newValue, oldValue));
}

public void jmp(XirLabel l) {
append(new XirInstruction(CiKind.Void, l, Jmp, null));
}
Expand Down
10 changes: 6 additions & 4 deletions com.sun.cri/src/com/sun/cri/xir/RiXirGenerator.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/*
* Copyright (c) 2019, APT Group, School of Computer Science,
* The University of Manchester. All rights reserved.
* Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
Expand All @@ -15,10 +17,6 @@
* 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 com.sun.cri.xir;

Expand Down Expand Up @@ -81,6 +79,10 @@ public interface RiXirGenerator {

XirSnippet genPutStatic(XirSite site, XirArgument staticTuple, RiField field, XirArgument value);

XirSnippet genTemplateGetField(XirSite site, XirArgument receiver, RiField field);

XirSnippet genTemplateGetStatic(XirSite site, XirArgument staticTuple, RiField field);

XirSnippet genNewInstance(XirSite site, RiType type);

XirSnippet genNewArray(XirSite site, XirArgument length, CiKind elementKind, RiType componentType, RiType arrayType);
Expand Down
44 changes: 44 additions & 0 deletions com.sun.max/src/com/sun/max/util/NUMALib.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,53 @@
import com.sun.max.annotate.*;

public class NUMALib {

private int numOfCores;

/**
* This variable holds the value of EFAULT return code.
* This error code is returned by numa_move_pages system call when a page is NOT found.
*
* Not found might mean:
* either the address is out of the dedicated to the process allocated range,
* or the page has not been touched so far, so it has not been placed on a physical NUMA node yet.
*/
public static final int EFAULT = -14;

/**
* This array holds the configuration. The index is the core/cpu id and the value is the numa node of the core/cpu.
*/
private int[] coreToNUMANodeMap;

public NUMALib() {
numOfCores = numaConfiguredCPUs();
assert numOfCores >= Runtime.getRuntime().availableProcessors();

coreToNUMANodeMap = new int[numOfCores];

for (int i = 0; i < numOfCores; i++) {
coreToNUMANodeMap[i] = numaNodeOfCPU(i);
assert coreToNUMANodeMap[i] >= 0 : "Core ID: " + i + " is on NUMA node: " + coreToNUMANodeMap[i];
}
}

@INLINE
public int getNUMANodeOfCPU(int coreId) {
return coreToNUMANodeMap[coreId];
}

@C_FUNCTION
public static native int numalib_available();

@C_FUNCTION
public static native int numaNodeOfAddress(long address);

@C_FUNCTION
public static native int numaConfiguredCPUs();

@C_FUNCTION
public static native int numaNodeOfCPU(int cpuID);

@C_FUNCTION
public static native int numaPageSize();
}

0 comments on commit 7721af8

Please sign in to comment.