diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/FunctionDefinitionNode.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/FunctionDefinitionNode.java index b156a78e614cb529e405d2ea38872080a6773e58..d4d5b08c15b6972b3efd40ee851eb23c78f34e74 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/FunctionDefinitionNode.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/function/FunctionDefinitionNode.java @@ -91,7 +91,7 @@ public final class FunctionDefinitionNode extends RRootNode implements RSyntaxNo * unknown. */ private String description; - private final FunctionUID uuid; + private FunctionUID uuid; private boolean instrumented = false; @Child private FrameSlotNode onExitSlot; @@ -163,9 +163,14 @@ public final class FunctionDefinitionNode extends RRootNode implements RSyntaxNo @Override public RRootNode duplicateWithNewFrameDescriptor() { FrameDescriptor frameDesc = new FrameDescriptor(); + FunctionUID thisUuid = uuid; FrameSlotChangeMonitor.initializeFunctionFrameDescriptor(description != null && !description.isEmpty() ? description : "<function>", frameDesc); - return new FunctionDefinitionNode(getSourceSection(), frameDesc, (BodyNode) body.unwrap().deepCopy(), getFormalArguments(), description, substituteFrame, argPostProcess == null ? null - : argPostProcess.deepCopyUnconditional()); + FunctionDefinitionNode result = new FunctionDefinitionNode(getSourceSection(), frameDesc, (BodyNode) body.unwrap().deepCopy(), getFormalArguments(), description, substituteFrame, + argPostProcess == null ? null + : argPostProcess.deepCopyUnconditional()); + // Instrumentation depends on this copy having same uuid + result.uuid = thisUuid; + return result; } private static boolean containsAnyDispatch(BodyNode body) { diff --git a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/instrument/RInstrument.java b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/instrument/RInstrument.java index eed2ebdcb53017541e152845c71724f6410c8dec..43b772dbf7960d8a1fe3914414f4be6cc1616c7c 100644 --- a/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/instrument/RInstrument.java +++ b/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/instrument/RInstrument.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, 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 @@ -216,8 +216,10 @@ public class RInstrument { public static void registerFunctionDefinition(FunctionDefinitionNode fdn) { FunctionUID uid = fdn.getUID(); FunctionData fd = functionMap.get(uid); - assert fd == null; - functionMap.put(uid, new FunctionData(uid, fdn)); + // Owing to FDN duplication, fdn may be registered multiple times + if (fd == null) { + functionMap.put(uid, new FunctionData(uid, fdn)); + } } public static FunctionIdentification getFunctionIdentification(FunctionUID uid) {