Tabnine Logo
CompilerDirectives
Code IndexAdd Tabnine to your IDE (free)

How to use
CompilerDirectives
in
com.oracle.truffle.api

Best Java code snippets using com.oracle.truffle.api.CompilerDirectives (Showing top 20 results out of 315)

origin: com.oracle.truffle/truffle-api

/**
 * Creates an exception thrown to enter a slow path.
 *
 * @since 0.8 or earlier
 */
public SlowPathException(String message) {
  super(message);
  CompilerDirectives.transferToInterpreterAndInvalidate();
}
origin: com.oracle.truffle/truffle-api

Env requireEnv() {
  Env localEnv = this.env;
  if (localEnv == null) {
    CompilerDirectives.transferToInterpreter();
    throw new AssertionError(
            "No language context is active on this thread.");
  }
  return localEnv;
}
origin: com.oracle/truffle

@Override
public boolean profile(boolean value) {
  if (value) {
    if (trueCount == 0) {
      CompilerDirectives.transferToInterpreterAndInvalidate();
    }
    if (CompilerDirectives.inInterpreter()) {
      trueCount++;
    }
  } else {
    if (falseCount == 0) {
      CompilerDirectives.transferToInterpreterAndInvalidate();
    }
    if (CompilerDirectives.inInterpreter()) {
      falseCount++;
    }
  }
  return CompilerDirectives.injectBranchProbability((double) trueCount / (double) (trueCount + falseCount), value);
}
origin: org.graalvm.truffle/truffle-api

@Override
public boolean inject(boolean condition) {
  if (CompilerDirectives.inCompiledCode()) {
    return CompilerDirectives.injectBranchProbability(calculateProbability(trueCount, falseCount), condition);
  } else {
    return condition;
  }
}
origin: org.graalvm.tools/profiler

@Override
protected void onEnter(VirtualFrame frame) {
  if (CompilerDirectives.inCompiledCode() && ignoreInlinedRoots && isAttachedToRootTag && !CompilerDirectives.inCompilationRoot()) {
    return;
  }
  doOnEnter();
}
origin: com.oracle.truffle/truffle-debug

@Override
protected void onEnter(VirtualFrame frame) {
  if (CompilerDirectives.inInterpreter()) {
    counter.interpretedInvocations++;
  } else {
    counter.compiledInvocations++;
  }
}
origin: org.graalvm.tools/profiler

private void doOnEnter() {
  StackTraceEntry location = CompilerDirectives.inInterpreter() ? interpretedLocation : (CompilerDirectives.inCompilationRoot() ? compiledLocation : compilationRootLocation);
  if (seenOtherThreads) {
    pushSlow(location);
  } else if (cachedThread == Thread.currentThread()) {
    cachedStack.push(location);
  } else {
    CompilerDirectives.transferToInterpreterAndInvalidate();
    seenOtherThreads = true;
    pushSlow(location);
  }
}
origin: com.oracle.truffle/truffle-api

void leave(Object prev) {
  assert current() == this : "Cannot leave context that is currently not entered. Forgot to enter or leave a context?";
  PolyglotThreadInfo info = getCachedThreadInfo();
  if (CompilerDirectives.injectBranchProbability(CompilerDirectives.LIKELY_PROBABILITY, info.thread == Thread.currentThread())) {
    info.leave();
  } else {
    if (singleThreaded.isValid()) {
      CompilerDirectives.transferToInterpreter();
    }
    leaveThreadChanged();
  }
  SINGLE_CONTEXT_STATE.contextThreadLocal.set(prev);
}
origin: org.graalvm.truffle/truffle-api

/**
 * Returns the size of an array which is needed for storing all the frame slots. (The number may
 * be bigger than the number of slots, if some slots are removed.)
 *
 * @return the size of the frame
 * @since 0.8 or earlier
 */
public int getSize() {
  if (CompilerDirectives.inCompiledCode()) {
    if (!this.version.isValid()) {
      CompilerDirectives.transferToInterpreterAndInvalidate();
    }
  }
  return this.size;
}
origin: org.graalvm.tools/profiler

@Override
protected void onReturnValue(VirtualFrame frame, Object result) {
  if (ignoreInlinedRoots) {
    if (CompilerDirectives.inCompiledCode()) {
      if (isAttachedToRootTag && !CompilerDirectives.inCompilationRoot()) {
        return;
      }
    } else {
      // This is needed to control for the case that an invalidation happened in an
      // inlined root.
      // Than there should be no stack pop until we exit the original compilation
      // root.
      // Not needed if stack overflowed
      final ThreadLocalStack stack = getStack();
      if (!stack.hasStackOverflowed() &&
              stack.top().getInstrumentedNode() != interpretedLocation.getInstrumentedNode()) {
        return;
      }
    }
  }
  if (seenOtherThreads) {
    popSlow(compiledLocation);
  } else if (cachedThread == Thread.currentThread()) {
    cachedStack.pop(compiledLocation);
  } else {
    CompilerDirectives.transferToInterpreterAndInvalidate();
    seenOtherThreads = true;
    popSlow(compiledLocation);
  }
}
origin: sh286/LuaTruffle

@Override
public void executeVoid(VirtualFrame frame) {
  final boolean condition;
  try {
    condition = conditionNode.executeBoolean(frame);
  } catch (UnexpectedResultException e) {
    // TODO
    throw new UnsupportedOperationException(e);
  }
  if (CompilerDirectives.injectBranchProbability(getBranchProbability(), condition)) {
    if (CompilerDirectives.inInterpreter()) {
      thenCount++;
    }
    thenProfile.enter();
    thenPartNode.executeVoid(frame);
  } else {
    if (CompilerDirectives.inInterpreter()) {
      elseCount++;
    }
    elseProfile.enter();
    elsePartNode.executeVoid(frame);
  }
}
origin: com.oracle/truffle

private TruffleOptInstrumentNode(AbstractInstrumentNode nextNode) {
  super(nextNode);
  this.isCompiled = CompilerDirectives.inCompiledCode();
}
origin: com.oracle/truffle

/**
 * Assertion that the corresponding value is reduced to a constant during compilation.
 *
 * @param value the value that must be constant during compilation
 */
public static <T> void compilationConstant(Object value) {
  if (!CompilerDirectives.isCompilationConstant(value)) {
    neverPartOfCompilation("Value is not compilation constant");
  }
}
origin: org.graalvm.tools/profiler

@Override
protected void onEnter(VirtualFrame frame) {
  if (CompilerDirectives.inInterpreter()) {
    payload.countInterpreted++;
  } else {
    payload.countCompiled++;
  }
}
origin: org.graalvm.truffle/truffle-api

void leave(Object prev) {
  assert current() == this : "Cannot leave context that is currently not entered. Forgot to enter or leave a context?";
  PolyglotThreadInfo info = getCachedThreadInfo();
  if (CompilerDirectives.injectBranchProbability(CompilerDirectives.LIKELY_PROBABILITY, info.thread == (TruffleOptions.AOT ? ContextThreadLocal.currentThread() : Thread.currentThread()))) {
    info.leave();
  } else {
    if (singleThreaded.isValid()) {
      CompilerDirectives.transferToInterpreter();
    }
    leaveThreadChanged();
  }
  singleContextState.contextThreadLocal.set(prev);
}
origin: com.oracle.truffle/truffle-api

@Override
public boolean inject(boolean condition) {
  if (CompilerDirectives.inCompiledCode()) {
    return CompilerDirectives.injectBranchProbability(calculateProbability(trueCount, falseCount), condition);
  } else {
    return condition;
  }
}
origin: com.oracle/truffle

public void enter(Node node, VirtualFrame vFrame) {
  if (this.isCompiled != CompilerDirectives.inCompiledCode()) {
    this.isCompiled = CompilerDirectives.inCompiledCode();
    TruffleOptInstrument.this.toolOptListener.notifyIsCompiled(this.isCompiled);
  }
  if (nextInstrumentNode != null) {
    nextInstrumentNode.enter(node, vFrame);
  }
}
origin: com.oracle.truffle/truffle-api

/**
 * Assertion that the corresponding value is reduced to a constant during compilation.
 *
 * @param value the value that must be constant during compilation
 * @since 0.8 or earlier
 */
public static <T> void compilationConstant(Object value) {
  if (!CompilerDirectives.isCompilationConstant(value)) {
    neverPartOfCompilation("Value is not compilation constant");
  }
}
origin: com.oracle.truffle/truffle-api

/**
 * Creates an exception thrown to enter a slow path.
 *
 * @since 0.8 or earlier
 */
public SlowPathException(Throwable cause) {
  super(cause);
  CompilerDirectives.transferToInterpreterAndInvalidate();
}
origin: org.graalvm.truffle/truffle-api

if (value) {
  if (t == 0) {
    CompilerDirectives.transferToInterpreterAndInvalidate();
  if (CompilerDirectives.inInterpreter()) {
    if (t < MAX_VALUE) {
      trueCount = t + 1;
    CompilerDirectives.transferToInterpreterAndInvalidate();
  if (CompilerDirectives.inInterpreter()) {
    if (f < MAX_VALUE) {
      falseCount = f + 1;
if (CompilerDirectives.inInterpreter()) {
  return CompilerDirectives.injectBranchProbability((double) t / (double) sum, value);
com.oracle.truffle.apiCompilerDirectives

Javadoc

Directives that influence the optimizations of the Truffle compiler. All of the operations have no effect when executed in the Truffle interpreter.

Most used methods

  • transferToInterpreterAndInvalidate
    Directive for the compiler to discontinue compilation at this code position and instead insert a tra
  • transferToInterpreter
    Directive for the compiler to discontinue compilation at this code position and instead insert a tra
  • inInterpreter
    Returns a boolean value indicating whether the method is executed in the interpreter.
  • inCompiledCode
    Returns a boolean value indicating whether the method is executed in the compiled code.
  • injectBranchProbability
    Injects a probability for the given condition into the probability information of the immediately su
  • isCompilationConstant
    Returns a boolean indicating whether or not a given value is seen as constant in optimized code. If
  • <init>
  • castExact
    Casts the given object to the exact class represented by clazz. The cast succeeds only if object ==
  • inCompilationRoot
    Returns a boolean value indicating whether the method is executed in the root of a Truffle compilati
  • isPartialEvaluationConstant
    Returns a boolean indicating whether or not a given value is seen as constant during the initial par
  • ensureVirtualized
    Ensures that the given object will be virtual (escape analyzed) at all points that are dominated by
  • ensureVirtualized

Popular in Java

  • Finding current android device location
  • setContentView (Activity)
  • scheduleAtFixedRate (Timer)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • FileNotFoundException (java.io)
    Thrown when a file specified by a program cannot be found.
  • DecimalFormat (java.text)
    A concrete subclass of NumberFormat that formats decimal numbers. It has a variety of features desig
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • JTable (javax.swing)
  • JTextField (javax.swing)
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now