Class RegexProfile

java.lang.Object
com.oracle.truffle.regex.RegexProfile

public final class RegexProfile extends Object
This profile is used for tracking statistics about a compiled regular expression, such as the amount of times the expression was executed and the amount of matches that were found. The profiling information is used by TRegex for deciding whether a regular expression should match capture groups in a lazy or eager way.
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Check if the profiling information gathered so far is sufficient for making a decision.
    void
    Increase the number of times the regular expression was executed by one.
    void
    Increase the number of times a match for the regular expression was found by one.
    void
    incProcessedCharacters(int numberOfCharacters)
     
    void
    profileCaptureGroupAccess(int matchLength, int numberOfCharsTraversed)
    Update profile after the execution of a lazy capture groups search DFA.
    void
     
    boolean
    shouldGenerateDFA(int inputLength)
    Decides whether the regular expression was executed often enough or would process enough characters to warrant the costly generation of a fully expanded DFA.
    boolean
    Decides whether the capture groups of the regular expression should be matched in an eager manner.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • RegexProfile

      public RegexProfile()
  • Method Details

    • incCalls

      public void incCalls()
      Increase the number of times the regular expression was executed by one.
    • resetCalls

      public void resetCalls()
    • incMatches

      public void incMatches()
      Increase the number of times a match for the regular expression was found by one.
    • profileCaptureGroupAccess

      public void profileCaptureGroupAccess(int matchLength, int numberOfCharsTraversed)
      Update profile after the execution of a lazy capture groups search DFA.
      Parameters:
      matchLength - the length of capture group 0 of the match.
      numberOfCharsTraversed - the number of characters that were traversed between the initial index (fromIndex) and the end of the match.
      See Also:
    • atEvaluationTripPoint

      public boolean atEvaluationTripPoint()
      Check if the profiling information gathered so far is sufficient for making a decision.
      Returns:
      true if the number of times the regular expression was called is divisible by 90.
    • shouldGenerateDFA

      public boolean shouldGenerateDFA(int inputLength)
      Decides whether the regular expression was executed often enough or would process enough characters to warrant the costly generation of a fully expanded DFA.
    • incProcessedCharacters

      public void incProcessedCharacters(int numberOfCharacters)
    • shouldUseEagerMatching

      public boolean shouldUseEagerMatching()
      Decides whether the capture groups of the regular expression should be matched in an eager manner.
      Returns:
      true if:
      • most searches led to a match
      • the capture groups of most search results were queried
      • the match often covered a big part of the part of the input string that had to be traversed in order to find it.
    • toString

      public String toString()
      Overrides:
      toString in class Object