Skip to content
Snippets Groups Projects
Commit abecf750 authored by stepan's avatar stepan
Browse files

Removing FastRprofmem code that uses deprecated PolyglotEngine (to be updated to newest API)

parent 82902c4f
No related branches found
No related tags found
No related merge requests found
/*
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2018, 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
......@@ -32,13 +32,9 @@ import static com.oracle.truffle.r.runtime.builtins.RBuiltinKind.PRIMITIVE;
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.interop.TruffleObject;
import com.oracle.truffle.r.runtime.instrument.memprof.MemAllocProfilerInstrument;
import com.oracle.truffle.api.vm.PolyglotEngine;
import com.oracle.truffle.api.vm.PolyglotRuntime.Instrument;
import com.oracle.truffle.r.nodes.builtin.RBuiltinNode;
import com.oracle.truffle.r.runtime.RError;
import com.oracle.truffle.r.runtime.RError.Message;
import com.oracle.truffle.r.runtime.builtins.RBuiltin;
import com.oracle.truffle.r.runtime.context.RContext;
import com.oracle.truffle.r.runtime.data.RNull;
@RBuiltin(name = ".fastr.profmem", visibility = OFF, kind = PRIMITIVE, parameterNames = {"on"}, behavior = IO)
......@@ -62,33 +58,8 @@ public abstract class FastRprofmem extends RBuiltinNode.Arg1 {
@Specialization
@TruffleBoundary
public Object doProfMem(boolean on) {
PolyglotEngine vm = RContext.getInstance().getVM();
if (vm != null) {
Instrument profilerInstr = vm.getRuntime().getInstruments().get(MemAllocProfilerInstrument.ID);
if (profilerInstr != null && profilerInstr.isEnabled() != on) {
profilerInstr.setEnabled(on);
}
} else {
throw error(RError.Message.GENERIC, "No context VM found");
}
return RNull.instance;
}
static MemAllocProfilerPrinter getProfilerPrinter() {
PolyglotEngine vm = RContext.getInstance().getVM();
MemAllocProfilerPrinter profPrinter = null;
if (vm != null) {
Instrument profilerInstr = vm.getRuntime().getInstruments().get(MemAllocProfilerInstrument.ID);
if (profilerInstr != null && profilerInstr.isEnabled()) {
profPrinter = profilerInstr.lookup(MemAllocProfilerPrinter.class);
}
}
if (profPrinter == null) {
profPrinter = new MemAllocProfilerPrinter(System.out);
}
return profPrinter;
public Object doProfMem(@SuppressWarnings("unused") boolean on) {
// TODO: port to new instrumentation API, original code can be found in git history
throw error(Message.GENERIC, ".fastr.profmem is not available.");
}
}
/*
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2018, 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
......@@ -35,6 +35,7 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.interop.TruffleObject;
import com.oracle.truffle.r.nodes.builtin.RBuiltinNode;
import com.oracle.truffle.r.runtime.RError.Message;
import com.oracle.truffle.r.runtime.RRuntime;
import com.oracle.truffle.r.runtime.builtins.RBuiltin;
import com.oracle.truffle.r.runtime.data.RNull;
......@@ -59,27 +60,16 @@ public abstract class FastRprofmemShow extends RBuiltinNode.Arg6 {
}
@Specialization
@SuppressWarnings("unused")
public Object doProfMem(int levels, boolean desc, @SuppressWarnings("unused") RNull n, boolean printParents, String view, TruffleObject snapshot) {
return show(levels, desc, null, printParents, view, snapshot);
// TODO: port to new instrumentation API, original code can be found in git history
throw error(Message.GENERIC, ".fastr.profmem.show is not available.");
}
@Specialization
@SuppressWarnings("unused")
public Object doProfMem(int levels, boolean desc, int entryId, boolean printParents, String view, TruffleObject snapshot) {
return show(levels, desc, entryId, printParents, view, snapshot);
}
@TruffleBoundary
private static Object show(int levels, boolean desc, Integer entryId, boolean printParents, String view, TruffleObject snapshotTO) {
MemAllocProfilerPaths snapshot = MemAllocProfilerPaths.fromTruffleObject(snapshotTO);
return show(levels, desc, entryId, printParents, view, snapshot);
}
private static Object show(int levels, boolean desc, Integer entryId, boolean printParents, String view, MemAllocProfilerPaths snapshot) {
MemAllocProfilerPaths usedSnapshot = snapshot;
if (FastRprofmem.HOTSPOTS_VIEW.equals(view)) {
usedSnapshot = usedSnapshot.toHS();
}
FastRprofmem.getProfilerPrinter().show(usedSnapshot, entryId, levels, desc, printParents);
return RNull.instance;
// TODO: port to new instrumentation API, original code can be found in git history
throw error(Message.GENERIC, ".fastr.profmem.show is not available.");
}
}
/*
* Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2016, 2018, 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
......@@ -33,6 +33,7 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.interop.TruffleObject;
import com.oracle.truffle.r.nodes.builtin.RBuiltinNode;
import com.oracle.truffle.r.runtime.RError.Message;
import com.oracle.truffle.r.runtime.RRuntime;
import com.oracle.truffle.r.runtime.builtins.RBuiltin;
import com.oracle.truffle.r.runtime.data.RNull;
......@@ -55,19 +56,9 @@ public abstract class FastRprofmemSource extends RBuiltinNode.Arg3 {
@Specialization
@TruffleBoundary
@SuppressWarnings("unused")
public Object showSource(int entryId, String view, TruffleObject snapshotTO) {
MemAllocProfilerPaths paths = MemAllocProfilerPaths.fromTruffleObject(snapshotTO);
return showSource(entryId, view, paths);
}
private static Object showSource(int entryId, String view, MemAllocProfilerPaths snap) {
MemAllocProfilerPaths snapshot = snap;
if (FastRprofmem.HOTSPOTS_VIEW.equals(view)) {
snapshot = snapshot.toHS();
}
FastRprofmem.getProfilerPrinter().source(snapshot, entryId);
return RNull.instance;
// TODO: port to new instrumentation API, original code can be found in git history
throw error(Message.GENERIC, ".fastr.profmem.source is not available.");
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment