Skip to content

Commit

Permalink
Merge branch 'feature/neo4jProfiling' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
zakkak committed Jun 21, 2019
2 parents 55f056b + 12490b2 commit bdf8577
Show file tree
Hide file tree
Showing 33 changed files with 917 additions and 476 deletions.
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) 2014, Andrey Rodchenko. All rights reserved.
* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
Expand Down Expand Up @@ -2982,4 +2982,21 @@ public void fptan() {
public void fstp(int i) {
emitx87(0xDD, 0xD8, i);
}

/**
* Reads time-stamp counter into EDX:EAX.
*/
public void rdtsc() {
emitByte(0x0F);
emitByte(0x31);
}

/**
* Reads 64-bit time-stamp counter and IA32_TSC_AUX value into EDX:EAX and ECX.
*/
public void rdtscp() {
emitByte(0x0F);
emitByte(0x01);
emitByte(0xF9);
}
}
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) 2011, 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.oracle.max.vm.ext.c1x;

Expand Down Expand Up @@ -250,6 +248,22 @@ public Value createHIR(GraphBuilder b, RiMethod target, Value[] args, boolean is
}
}

public static class GetTicksIntrinsic implements C1XIntrinsicImpl {
@Override
public Value createHIR(GraphBuilder b, RiMethod target, Value[] args, boolean isStatic, FrameState stateBefore) {
assert args.length == 0;
return b.append(new GetTicks());
}
}

public static class GetCpuIDIntrinsic implements C1XIntrinsicImpl {
@Override
public Value createHIR(GraphBuilder b, RiMethod target, Value[] args, boolean isStatic, FrameState stateBefore) {
assert args.length == 0;
return b.append(new GetCpuID());
}
}

public static void initialize(IntrinsicImpl.Registry registry) {
registry.add(LSB, new BitIntrinsic(LIROpcode.Lsb));
registry.add(MSB, new BitIntrinsic(LIROpcode.Msb));
Expand All @@ -276,5 +290,8 @@ public static void initialize(IntrinsicImpl.Registry registry) {
registry.add(ALLOCA, new AllocaIntrinsic());

registry.add(CMP_BYTECODE, new CompareBytecodeIntrinsic());

registry.add(GET_TICKS, new GetTicksIntrinsic());
registry.add(GET_CPU_ID, new GetCpuIDIntrinsic());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018, 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) 2015, Andrey Rodchenko. All rights reserved.
* Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
Expand Down Expand Up @@ -2132,7 +2132,7 @@ public static void callProfiler(int size, Hub hub, Pointer cell) {
FatalError.check(vmConfig().heapScheme().usesTLAB(), "HeapScheme must use TLAB");
}

if (MaxineVM.profileThatObject()) {
if (MaxineVM.profileThatObject(hub)) {
((HeapSchemeWithTLAB) vmConfig().heapScheme()).profile(size, hub, cell);
}
}
Expand All @@ -2142,7 +2142,7 @@ public static void callProfilerArray(int size, Hub hub, Pointer cell) {
FatalError.check(vmConfig().heapScheme().usesTLAB(), "HeapScheme must use TLAB");
}

if (MaxineVM.profileThatObject()) {
if (MaxineVM.profileThatObject(hub)) {
((HeapSchemeWithTLAB) vmConfig().heapScheme()).profileArray(size, hub, cell);
}
}
Expand Down
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) 2014, Andrey Rodchenko. All rights reserved.
* Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
Expand Down Expand Up @@ -550,7 +550,7 @@ private MaxTargetMethod compileTemplate(RuntimeCompiler bootCompiler, ClassMetho
/**
* List of intrinsic that T1X cannot handle, i.e., methods that call these intrinsics lead to a bailout.
*/
public static final Set<String> unsafeIntrinsicIDs = new HashSet<String>(Arrays.asList(READREG, WRITEREG, IFLATCHBITREAD, SAFEPOINT_POLL, HERE, INFO, BREAKPOINT_TRAP, ALLOCA, MEMBAR));
public static final Set<String> unsafeIntrinsicIDs = new HashSet<String>(Arrays.asList(READREG, WRITEREG, IFLATCHBITREAD, SAFEPOINT_POLL, HERE, INFO, BREAKPOINT_TRAP, ALLOCA, MEMBAR, GET_CPU_ID, GET_TICKS));

@HOSTED_ONLY
private static final Class[] templateIntrinsicClasses = {
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) 2011, 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.oracle.max.vm.ext.t1x;

Expand Down
2 changes: 1 addition & 1 deletion com.oracle.max.vm.native/platform/platform.mk
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ ifeq ($(OS),linux)
LINK_LIB_POSTFIX = -lstdc++ -lc -lm -lpthread -ldl
endif
ifneq ($(ISA),arm)
LINK_LIB_POSTFIX = -lc -lm -lpthread
LINK_LIB_POSTFIX = -lc -lm -lpthread -lnuma
endif
LIB_PREFIX = lib
LIB_SUFFIX = .so
Expand Down
4 changes: 3 additions & 1 deletion com.oracle.max.vm.native/share/log.h
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 @@ -83,6 +83,8 @@ extern void log_flush(void);
#define log_THREADS (log_ALL || 0)
#define log_TELE (log_ALL || 0)
#define log_MMAP (log_ALL || 0)
// log_NUMA_THREADS can be used only on non-ARM architectures
#define log_NUMA_THREADS (!isa_ARM && 0)

#if log_JVMNI
#define jvmni_log_println log_println
Expand Down
19 changes: 18 additions & 1 deletion com.oracle.max.vm.native/substrate/threads.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) 2016, Andrey Rodchenko. All rights reserved.
* Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
Expand Down Expand Up @@ -58,6 +58,19 @@
#define thread_current() (maxve_get_current())
#endif

#if log_NUMA_THREADS
# include <numa.h>
void log_numa_thread(int threadId){

// NUMA-aware thread tracking in behalf of Allocation Profiler
int cpu = sched_getcpu();
int numaNode;
numaNode = numa_node_of_cpu(cpu);

log_println("(Run) Thread %d, CPU %d, Numa Node %d", threadId, cpu, numaNode);
}
#endif

/**
* The native mutex associated with VmThreadMap.THREAD_LOCK.
*/
Expand Down Expand Up @@ -220,6 +233,10 @@ void *thread_run(void *arg) {
jint id = tla_load(jint, etla, ID);
Address nativeThread = (Address) thread_current();

#if log_NUMA_THREADS
log_numa_thread(id);
#endif

#if log_THREADS
log_println("thread_run: BEGIN t=%p", nativeThread);
#endif
Expand Down
15 changes: 12 additions & 3 deletions com.sun.c1x/src/com/sun/c1x/gen/LIRGenerator.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018, 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 @@ -56,8 +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.classfile.constant.ClassMethodRefConstant;
import com.sun.max.vm.classfile.constant.ConstantPool;
import com.sun.max.vm.runtime.FatalError;

/**
* This class traverses the HIR instructions and generates LIR instructions from them.
Expand Down Expand Up @@ -701,6 +700,16 @@ public void visitBreakpointTrap(BreakpointTrap i) {
lir.breakpoint();
}

@Override
public void visitGetTicks(GetTicks i) {
throw FatalError.unimplemented("LIRGenerator.visitGetTicks");
}

@Override
public void visitGetCpuID(GetCpuID i) {
throw FatalError.unimplemented("LIRGenerator.visitGetCpuID");
}

protected CiAddress getAddressForPointerOp(PointerOp x, CiKind kind, CiValue pointer) {
if (x.displacement() == null) {
// address is [pointer + offset]
Expand Down
4 changes: 3 additions & 1 deletion com.sun.c1x/src/com/sun/c1x/ir/DefaultValueVisitor.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018, 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) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
Expand Down Expand Up @@ -105,4 +105,6 @@ protected void visit(Value value) {
@Override public void visitUnsafePutRaw(UnsafePutRaw i) { visit(i); }
@Override public void visitUnsignedCompareOp(UnsignedCompareOp i) { visit(i); }
@Override public void visitIfBit(IfBit i) { visit(i); }
@Override public void visitGetTicks(GetTicks i) { visit(i); }
@Override public void visitGetCpuID(GetCpuID i) { visit(i); }
}
44 changes: 44 additions & 0 deletions com.sun.c1x/src/com/sun/c1x/ir/GetCpuID.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2019, APT Group, School of Computer Science,
* The University of Manchester. 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
* 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.
*/
package com.sun.c1x.ir;

import com.oracle.max.criutils.LogStream;
import com.sun.cri.ci.CiKind;

public final class GetCpuID extends Instruction {

/**
* Creates a {@link GetCpuID} instance.
*/
public GetCpuID() {
super(CiKind.Int);
}

@Override
public void accept(ValueVisitor v) {
v.visitGetCpuID(this);
}

@Override
public void print(LogStream out) {
out.print("getCpuID");
}
}
44 changes: 44 additions & 0 deletions com.sun.c1x/src/com/sun/c1x/ir/GetTicks.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2019, APT Group, School of Computer Science,
* The University of Manchester. 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
* 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.
*/
package com.sun.c1x.ir;

import com.oracle.max.criutils.LogStream;
import com.sun.cri.ci.CiKind;

public final class GetTicks extends Instruction {

/**
* Creates a {@link GetTicks} instance.
*/
public GetTicks() {
super(CiKind.Long);
}

@Override
public void accept(ValueVisitor v) {
v.visitGetTicks(this);
}

@Override
public void print(LogStream out) {
out.print("getTicks");
}
}
4 changes: 3 additions & 1 deletion com.sun.c1x/src/com/sun/c1x/ir/ValueVisitor.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017-2018, 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, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
Expand Down Expand Up @@ -95,4 +95,6 @@ public abstract class ValueVisitor {
public abstract void visitUnsafePutRaw(UnsafePutRaw i);
public abstract void visitUnsignedCompareOp(UnsignedCompareOp i);
public abstract void visitIfBit(IfBit i);
public abstract void visitGetTicks(GetTicks i);
public abstract void visitGetCpuID(GetCpuID i);
}
12 changes: 11 additions & 1 deletion com.sun.c1x/src/com/sun/c1x/lir/LIRAssembler.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, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
Expand Down Expand Up @@ -317,6 +317,12 @@ public void emitOp0(LIROp0 op) {
case Breakpoint:
emitBreakpoint();
break;
case GetTicks:
emitGetTicks(op.result());
break;
case GetCpuID:
emitGetCpuID(op.result());
break;
default:
throw Util.shouldNotReachHere();
}
Expand Down Expand Up @@ -476,6 +482,10 @@ public DebugMethodWriter getDebugMethodWriter() {

protected abstract void emitPause();

protected abstract void emitGetTicks(CiValue result);

protected abstract void emitGetCpuID(CiValue result);

protected abstract void emitStackAllocate(StackBlock src, CiValue dst);

protected abstract void emitReturn(CiValue inOpr);
Expand Down

0 comments on commit bdf8577

Please sign in to comment.