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
Branches
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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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; ...@@ -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.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.interop.TruffleObject; 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.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.builtins.RBuiltin;
import com.oracle.truffle.r.runtime.context.RContext;
import com.oracle.truffle.r.runtime.data.RNull; import com.oracle.truffle.r.runtime.data.RNull;
@RBuiltin(name = ".fastr.profmem", visibility = OFF, kind = PRIMITIVE, parameterNames = {"on"}, behavior = IO) @RBuiltin(name = ".fastr.profmem", visibility = OFF, kind = PRIMITIVE, parameterNames = {"on"}, behavior = IO)
...@@ -62,33 +58,8 @@ public abstract class FastRprofmem extends RBuiltinNode.Arg1 { ...@@ -62,33 +58,8 @@ public abstract class FastRprofmem extends RBuiltinNode.Arg1 {
@Specialization @Specialization
@TruffleBoundary @TruffleBoundary
public Object doProfMem(boolean on) { public Object doProfMem(@SuppressWarnings("unused") boolean on) {
PolyglotEngine vm = RContext.getInstance().getVM(); // TODO: port to new instrumentation API, original code can be found in git history
if (vm != null) { throw error(Message.GENERIC, ".fastr.profmem is not available.");
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;
} }
} }
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -35,6 +35,7 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; ...@@ -35,6 +35,7 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.api.interop.TruffleObject;
import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; 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.RRuntime;
import com.oracle.truffle.r.runtime.builtins.RBuiltin; import com.oracle.truffle.r.runtime.builtins.RBuiltin;
import com.oracle.truffle.r.runtime.data.RNull; import com.oracle.truffle.r.runtime.data.RNull;
...@@ -59,27 +60,16 @@ public abstract class FastRprofmemShow extends RBuiltinNode.Arg6 { ...@@ -59,27 +60,16 @@ public abstract class FastRprofmemShow extends RBuiltinNode.Arg6 {
} }
@Specialization @Specialization
@SuppressWarnings("unused")
public Object doProfMem(int levels, boolean desc, @SuppressWarnings("unused") RNull n, boolean printParents, String view, TruffleObject snapshot) { 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 @Specialization
@SuppressWarnings("unused")
public Object doProfMem(int levels, boolean desc, int entryId, boolean printParents, String view, TruffleObject snapshot) { public Object doProfMem(int levels, boolean desc, int entryId, boolean printParents, String view, TruffleObject snapshot) {
return show(levels, desc, entryId, 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.");
@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;
} }
} }
/* /*
* 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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -33,6 +33,7 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary; ...@@ -33,6 +33,7 @@ import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Specialization; import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.interop.TruffleObject; import com.oracle.truffle.api.interop.TruffleObject;
import com.oracle.truffle.r.nodes.builtin.RBuiltinNode; 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.RRuntime;
import com.oracle.truffle.r.runtime.builtins.RBuiltin; import com.oracle.truffle.r.runtime.builtins.RBuiltin;
import com.oracle.truffle.r.runtime.data.RNull; import com.oracle.truffle.r.runtime.data.RNull;
...@@ -55,19 +56,9 @@ public abstract class FastRprofmemSource extends RBuiltinNode.Arg3 { ...@@ -55,19 +56,9 @@ public abstract class FastRprofmemSource extends RBuiltinNode.Arg3 {
@Specialization @Specialization
@TruffleBoundary @TruffleBoundary
@SuppressWarnings("unused")
public Object showSource(int entryId, String view, TruffleObject snapshotTO) { public Object showSource(int entryId, String view, TruffleObject snapshotTO) {
MemAllocProfilerPaths paths = MemAllocProfilerPaths.fromTruffleObject(snapshotTO); // TODO: port to new instrumentation API, original code can be found in git history
return showSource(entryId, view, paths); throw error(Message.GENERIC, ".fastr.profmem.source is not available.");
}
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;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment