Skip to content
Snippets Groups Projects
Commit 9c8446e1 authored by Christian Humer's avatar Christian Humer
Browse files

Add always on BranchProfile for special cases where isVisited needs to be queried.

parent f663e648
Branches
No related tags found
No related merge requests found
......@@ -64,7 +64,7 @@ final class CachedExtractVectorNode extends CachedVectorNode {
* Profile if any metadata was applied at any point in time. This is useful extract primitive
* values from the result in case no metadata was ever applied.
*/
private final BranchProfile metadataApplied = BranchProfile.create();
private final AlwaysOnBranchProfile metadataApplied = AlwaysOnBranchProfile.create();
public CachedExtractVectorNode(ElementAccessMode mode, RTypedValue vector, Object[] positions, RTypedValue exact, RTypedValue dropDimensions, boolean recursive) {
super(mode, vector, positions, recursive);
......
......@@ -32,8 +32,7 @@ import com.oracle.truffle.api.profiles.BranchProfile;
import com.oracle.truffle.api.profiles.ConditionProfile;
import com.oracle.truffle.api.profiles.ValueProfile;
import com.oracle.truffle.api.profiles.LoopConditionProfile;
import com.oracle.truffle.r.nodes.profile.IntValueProfile;
import com.oracle.truffle.r.nodes.profile.VectorLengthProfile;
import com.oracle.truffle.r.nodes.profile.*;
import com.oracle.truffle.r.runtime.RInternalError;
import com.oracle.truffle.r.runtime.RRuntime;
import com.oracle.truffle.r.runtime.RType;
......@@ -209,7 +208,7 @@ abstract class WriteIndexedVectorNode extends Node {
protected int doLogicalPosition(RAbstractVector left, Object leftStore, int leftBase, int leftLength, Object targetDimensions, int targetDimension, //
Object[] positions, RAbstractLogicalVector position, int positionOffset, int positionLength, //
RTypedValue right, Object rightStore, int rightBase, int rightLength, boolean parentNA, //
@Cached("create()") BranchProfile wasTrue, @Cached("create()") BranchProfile outOfBounds, //
@Cached("create()") BranchProfile wasTrue, @Cached("create()") AlwaysOnBranchProfile outOfBounds, //
@Cached("createCountingProfile()") LoopConditionProfile profile) {
positionNACheck.enable(!skipNA && !position.isComplete());
......
/*
* Copyright (c) 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
* 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.
*
* 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.truffle.r.nodes.profile;
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.CompilerDirectives.CompilationFinal;
import com.oracle.truffle.api.profiles.*;
/**
* {@link BranchProfile} implementation that is always enabled independent of the runtime. Useful if
* whether or not a profile is {@link AlwaysOnBranchProfile#isVisited() visited} needs to be
* queried.
*
* @see AlwaysOnBranchProfile#enter()
*/
public final class AlwaysOnBranchProfile {
@CompilationFinal private boolean visited;
AlwaysOnBranchProfile() {
}
/**
* Call when an unlikely branch is entered.
*/
public void enter() {
if (!visited) {
CompilerDirectives.transferToInterpreterAndInvalidate();
visited = true;
}
}
public boolean isVisited() {
return visited;
}
/**
* Call to create a new instance of a branch profile.
*/
public static AlwaysOnBranchProfile create() {
return new AlwaysOnBranchProfile();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment