Implement optimize send in yjit (#6488)

* Implement optimize send in yjit

This successfully makes all our benchmarks exit way less for optimize send reasons.
It makes some benchmarks faster, but not by as much as I'd like. I think this implementation
works, but there are definitely more optimial arrangements. For example, what if we compiled
send to a jump table? That seems like perhaps the most optimal we could do, but not obvious (to me)
how to implement give our current setup.

Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>

* Attempt at fixing the issues raised by @XrXr

* fix allowlist

* returns 0 instead of nil when not found

* remove comment about encoding exception

* Fix up c changes

* Update assert

Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>

* get rid of unneeded code and fix the flags

* Apply suggestions from code review

Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>

* rename and fix typo

Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
This commit is contained in:
Jimmy Miller 2022-10-11 16:37:05 -04:00 committed by GitHub
parent 913979bede
commit 467992ee35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
Notes: git 2022-10-12 05:37:32 +09:00
Merged-By: maximecb <maximecb@ruby-lang.org>
8 changed files with 262 additions and 17 deletions

View file

@ -1112,6 +1112,28 @@ rb_check_id(volatile VALUE *namep)
return lookup_str_id(name);
}
// Used by yjit for handling .send without throwing exceptions
ID
rb_get_symbol_id(VALUE name)
{
if (STATIC_SYM_P(name)) {
return STATIC_SYM2ID(name);
}
else if (DYNAMIC_SYM_P(name)) {
if (SYMBOL_PINNED_P(name)) {
return RSYMBOL(name)->id;
}
else {
return 0;
}
}
else {
RUBY_ASSERT_ALWAYS(RB_TYPE_P(name, T_STRING));
return lookup_str_id(name);
}
}
VALUE
rb_check_symbol(volatile VALUE *namep)
{