• Iain Ireland's avatar
    [regexp] Upstream small changes · a2b17a72
    Iain Ireland authored
    This is a grab-bag of small compatibility fixes to make it easier to
    import irregexp into SpiderMonkey. For changes where the commit
    message was longer than the change itself, it didn't seem worth
    opening a separate review.
    
    [regexp] Use uc16 in FilterOneByte
    
    SpiderMonkey uses char16_t instead of uint16_t for its two-byte
    strings. (This matches ICU. It looks like V8 considered making the
    same change, but decided against it: see
    https://bugs.chromium.org/p/v8/issues/detail?id=6487.) Fortunately,
    irregexp is careful about only using uc16, so SpiderMonkey can just
    define uc16 = char16_t and *almost* everything works out. This patch
    fixes the single place in irregexp where that is not true.
    
    [regexp] Remove unreachable return
    
    The return statement at the end of
    RegExpParser::ParseClassCharacterEscape is unreachable, because every
    branch of the switch returns. This triggered static analysis errors in
    SpiderMonkey.
    
    [regexp] Remove trivial assertion
    
    The assertion in BytecodeSequenceNode::ArgumentMapping cannot fail,
    because size_t is an unsigned type. This triggered static analysis
    warnings in SpiderMonkey.
    
    [regexp] Make RegExpStack constructor public
    
    In V8, the RegExpStack's private constructor is called from Isolate,
    which is a friend class. In SpiderMonkey, we use a wrapper around new
    to control where memory is allocated, so we need the RegExpStack
    constructor to be visible outside of Isolate.
    
    [regexp] Refactor Isolate::IncreaseTotalRegexpCodeGenerated
    
    The call-site of Isolate::IncreaseTotalRegexpCodeGenerated is the only
    place inside irregexp where HeapObject::Size is called. SpiderMonkey's
    heap-allocated objects live in arenas, and don't have a standardized
    way of finding the size. In this particular case it would be safe to
    hardcode a size of 0, but leaving HeapObject::Size undefined will
    ensure that SpiderMonkey doesn't silently do the wrong thing if
    somebody in V8 adds a new, more meaningful call to HeapObject::Size.
    
    R=jgruber@chromium.org
    
    Bug: v8:10303
    Change-Id: I5b81e1a261fec8c85a63f71f34cd12d68f638334
    Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2090191
    Commit-Queue: Jakob Gruber <jgruber@chromium.org>
    Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#66676}
    a2b17a72
regexp-parser.cc 65.8 KB