#[non_exhaustive]pub enum Fast {
Show 24 variants
Concat,
ConcatN,
IntRem,
NumPow,
IntShl,
IntShr,
ScalarXor,
LooseEq,
LooseNe,
StrictEq,
StrictNe,
Lt,
Le,
Gt,
Ge,
IntSpaceship,
NumIdentity,
IntBitNot,
ToInt,
ToFloat,
ToStr,
ToBool,
ToArray,
StrOffset,
}Expand description
A guarded fast path: the operand kinds where an LSB sequence computes exactly the intrinsic’s result, tested at run time; outside that domain the intrinsic’s host function is called with the same operands.
Each variant states its domain (where the inline code runs) and what
it computes there. The domains are chosen so that the inline result is
PHP 8’s (Mox’s) result; a host function bound to the same intrinsic must
agree with the fast path on its domain, and is free everywhere else.
Kinds are LSB dynamic kinds (§2.2): nil, bool, int (i64), float
(f64), str (bytes), map.
§Examples
use bcgen_lang::{Arity, Fast};
assert_eq!(Fast::LooseEq.arity(), Arity::exact(2));
assert_eq!(Fast::ConcatN.arity(), Arity::at_least(0));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Concat
Domain: both str. Result: the byte concatenation.
ConcatN
Domain: every operand str (any count, none included). Result: the
byte concatenation in order ("" for none), one str_concat_n.
IntRem
Domain: both int. Result: the truncated remainder (the sign follows
the dividend; MIN % -1 is 0); a zero divisor raises DivByZero
(E0002) at the intrinsic.
NumPow
Domain: both numbers (int or float). Result: dpow with
overflow = promote: an exact int power when it fits, else the
nearest float; a negative integer exponent gives the float
power; floats by the family’s ls_pow.
IntShl
Domain: both int. Result: shl with shift = saturate (an amount
of 64 or more gives 0; a negative amount raises ShiftOutOfRange,
E0003).
IntShr
Domain: both int. Result: arithmetic shr with shift = saturate
(64 or more gives 0, or -1 for a negative value; a negative amount
raises ShiftOutOfRange).
ScalarXor
Domain: both in nil, bool, int, float. Result: the exclusive
or of their truthiness (nil, false, 0, ±0.0 are false; NaN is
true), a bool.
LooseEq
Domain: the same kind in nil, bool, int, float (equality by
value; IEEE for floats, so NaN equals nothing and -0.0 == 0.0), or
two str with equal bytes (true). A bool.
LooseNe
The negation of LooseEq, on the same domain.
StrictEq
Domain: both in nil, bool, int, float, str. Result: true
exactly when the kinds are equal and the values are (floats by IEEE,
strings by bytes). A bool.
StrictNe
The negation of StrictEq, on the same domain.
Lt
Domain: two ints or two floats. Result: a < b (false with NaN).
Le
Domain: two ints or two floats. Result: a <= b.
Gt
Domain: two ints or two floats. Result: a > b.
Ge
Domain: two ints or two floats. Result: a >= b.
IntSpaceship
Domain: two ints. Result: -1, 0, or 1 as an int.
NumIdentity
Domain: an int or a float. Result: the operand.
IntBitNot
Domain: an int. Result: its bitwise complement.
ToInt
Domain: int (itself), bool (0 or 1), nil (0), and float by
PHP 7/8’s zend_dval_to_lval on 64-bit platforms: truncated toward
zero when in [-2^63, 2^63), NaN and infinities 0, and any other
finite value taken modulo 2^64 into the signed range (1e19 is
-8446744073709551616, -1e19 is 8446744073709551616). An int.
ToFloat
Domain: float (itself), int (the nearest float, ties to even),
bool (0.0 or 1.0), nil (0.0). A float.
ToStr
Domain: str. Result: the operand.
ToBool
Domain: nil, bool, int, float. Result: the truthiness, a
bool.
ToArray
Domain: map. Result: the operand.
StrOffset
Domain: a str and an int offset i with -len <= i < len.
Result: the one-byte string at i (counted from the end when
negative), PHP 7.1+’s $s[i]. Out-of-range offsets and every other
operand kind go to the host function (PHP: a warning and "", or a
TypeError for an offset that is not an integer).