summaryrefslogtreecommitdiff
path: root/include/ruby
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2022-08-04 08:18:24 -0700
committerGitHub <noreply@github.com>2022-08-04 11:18:24 -0400
commit7f5f9d19c54d3d5e0c2b2947785d8821b752641d (patch)
treeeed714fcd24a8901cf72cfb2561cc991280ee4d0 /include/ruby
parent8bab09983046351453c7c86c003cfadad3dac01a (diff)
YJIT: Add known_* helpers for Type (#6208)
* YJIT: Add known_* helpers for Type This adds a few helpers to Type which all return Options representing what is known, from a Ruby perspective, about the type. This includes: * known_class_of: If known, the class represented by this type * known_value_type: If known, the T_ value type * known_exact_value: If known, the exact VALUE represented by this type (currently this is only available for true/false/nil) * known_truthy: If known, whether or not this value evaluates as true (not false or nil) The goal of this is to abstract away the specifics of the mappings between types wherever possible from the codegen. For example previously by introducing Type::CString as a more specific version of Type::TString, uses of Type::TString in codegen needed to be updated to check either case. Now by using known_value_type, at least in theory we can introduce new types with minimal (if any) codegen changes. I think rust's Option type allows us to represent this uncertainty fairly well, and should help avoid mistakes, and the matching using this turned out pretty cleanly. * YJIT: Use known_value_type for checktype * YJIT: Use known_value_type for T_STRING check * YJIT: Use known_class_of in guard_known_klass * YJIT: Use known truthyness in jit_rb_obj_not * YJIT: Rename known_class_of => known_class
Notes
Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
Diffstat (limited to 'include/ruby')
0 files changed, 0 insertions, 0 deletions