From abecf75096e17ea05f69d5fbd22d2e79f5c21417 Mon Sep 17 00:00:00 2001 From: stepan <stepan.sindelar@oracle.com> Date: Wed, 14 Feb 2018 17:55:44 +0100 Subject: [PATCH] Removing FastRprofmem code that uses deprecated PolyglotEngine (to be updated to newest API) --- .../builtin/fastr/memprof/FastRprofmem.java | 39 +++---------------- .../fastr/memprof/FastRprofmemShow.java | 26 ++++--------- .../fastr/memprof/FastRprofmemSource.java | 19 +++------ 3 files changed, 18 insertions(+), 66 deletions(-) diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/memprof/FastRprofmem.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/memprof/FastRprofmem.java index 4023e75743..802b049011 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/memprof/FastRprofmem.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/memprof/FastRprofmem.java @@ -1,5 +1,5 @@ /* - * 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."); } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/memprof/FastRprofmemShow.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/memprof/FastRprofmemShow.java index b85dfe90a7..9179838da5 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/memprof/FastRprofmemShow.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/memprof/FastRprofmemShow.java @@ -1,5 +1,5 @@ /* - * 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."); } } diff --git a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/memprof/FastRprofmemSource.java b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/memprof/FastRprofmemSource.java index 3c008c7eec..5e3eac7f32 100644 --- a/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/memprof/FastRprofmemSource.java +++ b/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/fastr/memprof/FastRprofmemSource.java @@ -1,5 +1,5 @@ /* - * 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."); } } -- GitLab