summaryrefslogtreecommitdiff
path: root/yjit/src/cruby.rs
diff options
context:
space:
mode:
authorNoah Gibbs <noah.gibbs@shopify.com>2022-05-21 00:39:37 +0100
committerGitHub <noreply@github.com>2022-05-20 19:39:37 -0400
commit50bad7159a8e1f9846f37421c941f6fa8f087591 (patch)
treea4dce74f53c7e909733f01ebc90d770506365d1f /yjit/src/cruby.rs
parenta97fbc108bd23e669a27356be83c1a515d469af0 (diff)
Special-case jit_guard_known_class for strings. This can remove (#5920)
runtime guard-checks for String#to_s, making some blocks too short to invalidate later. Add NOPs in those cases to reserve space.
Notes
Notes: Merged-By: maximecb <maximecb@ruby-lang.org>
Diffstat (limited to 'yjit/src/cruby.rs')
-rw-r--r--yjit/src/cruby.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/yjit/src/cruby.rs b/yjit/src/cruby.rs
index 0afbd6451b..20091bf77a 100644
--- a/yjit/src/cruby.rs
+++ b/yjit/src/cruby.rs
@@ -461,6 +461,11 @@ impl VALUE {
self == Qnil
}
+ /// Returns true or false depending whether the value is a string
+ pub fn string_p(self) -> bool {
+ unsafe { CLASS_OF(self) == rb_cString }
+ }
+
/// Read the flags bits from the RBasic object, then return a Ruby type enum (e.g. RUBY_T_ARRAY)
pub fn builtin_type(self) -> ruby_value_type {
assert!(!self.special_const_p());