summaryrefslogtreecommitdiff
path: root/yjit/src/codegen.rs
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2022-07-11 10:09:39 -0400
committerPeter Zhu <peter@peterzhu.ca>2022-07-15 09:21:07 -0400
commit7424ea184f9d67c1c7f3ee97494ed3bd1aa60833 (patch)
tree822838e39d81cd2785c970cb45a86854823af6fe /yjit/src/codegen.rs
parent7fda741f6e67b809b08423f0d4e903c078da2eed (diff)
Implement Objects on VWA
This commit implements Objects on Variable Width Allocation. This allows Objects with more ivars to be embedded (i.e. contents directly follow the object header) which improves performance through better cache locality.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/6117
Diffstat (limited to 'yjit/src/codegen.rs')
-rw-r--r--yjit/src/codegen.rs21
1 files changed, 14 insertions, 7 deletions
diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs
index 84f4ff4897..9cd69cd340 100644
--- a/yjit/src/codegen.rs
+++ b/yjit/src/codegen.rs
@@ -1966,9 +1966,17 @@ fn gen_get_ivar(
ctx.stack_pop(1);
}
+ if USE_RVARGC != 0 {
+ // Check that the ivar table is big enough
+ // Check that the slot is inside the ivar table (num_slots > index)
+ let num_slots = mem_opnd(32, REG0, ROBJECT_OFFSET_NUMIV);
+ cmp(cb, num_slots, uimm_opnd(ivar_index as u64));
+ jle_ptr(cb, counted_exit!(ocb, side_exit, getivar_idx_out_of_range));
+ }
+
// Compile time self is embedded and the ivar index lands within the object
let test_result = unsafe { FL_TEST_RAW(comptime_receiver, VALUE(ROBJECT_EMBED.as_usize())) != VALUE(0) };
- if test_result && ivar_index < (ROBJECT_EMBED_LEN_MAX.as_usize()) {
+ if test_result {
// See ROBJECT_IVPTR() from include/ruby/internal/core/robject.h
// Guard that self is embedded
@@ -1988,7 +1996,7 @@ fn gen_get_ivar(
);
// Load the variable
- let offs = RUBY_OFFSET_ROBJECT_AS_ARY + (ivar_index * SIZEOF_VALUE) as i32;
+ let offs = ROBJECT_OFFSET_AS_ARY + (ivar_index * SIZEOF_VALUE) as i32;
let ivar_opnd = mem_opnd(64, REG0, offs);
mov(cb, REG1, ivar_opnd);
@@ -2019,17 +2027,16 @@ fn gen_get_ivar(
side_exit,
);
- // Check that the extended table is big enough
- if ivar_index > (ROBJECT_EMBED_LEN_MAX.as_usize()) {
+ if USE_RVARGC == 0 {
+ // Check that the extended table is big enough
// Check that the slot is inside the extended table (num_slots > index)
- let num_slots = mem_opnd(32, REG0, RUBY_OFFSET_ROBJECT_AS_HEAP_NUMIV);
-
+ let num_slots = mem_opnd(32, REG0, ROBJECT_OFFSET_NUMIV);
cmp(cb, num_slots, uimm_opnd(ivar_index as u64));
jle_ptr(cb, counted_exit!(ocb, side_exit, getivar_idx_out_of_range));
}
// Get a pointer to the extended table
- let tbl_opnd = mem_opnd(64, REG0, RUBY_OFFSET_ROBJECT_AS_HEAP_IVPTR);
+ let tbl_opnd = mem_opnd(64, REG0, ROBJECT_OFFSET_AS_HEAP_IVPTR);
mov(cb, REG0, tbl_opnd);
// Read the ivar from the extended table