-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vm_getivar: store the common ancestor shape in the inline cache
This is a continuation of the `rb_shape_get_iv_index_with_hint` patch. Now we return the common ancestor id to `vm_get_ivar`, and it uses it as the new cache key. This helps the IC stay stable instead of flip flopping.
- Loading branch information
Showing
4 changed files
with
110 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
prelude: | | ||
IVARS = 60 | ||
class Record | ||
def initialize(offset = false) | ||
@offset = 1 if offset | ||
@first = 0 | ||
IVARS.times do |i| | ||
instance_variable_set("@ivar_#{i}", i) | ||
end | ||
end | ||
def first | ||
@first | ||
end | ||
def lazy_set | ||
@lazy_set ||= 123 | ||
end | ||
def undef | ||
@undef | ||
end | ||
end | ||
Record.new # Need one alloc to right size | ||
BASE = Record.new | ||
LAZY = Record.new | ||
LAZY.lazy_set | ||
class Miss < Record | ||
@first = 0 | ||
IVARS.times do |i| | ||
instance_variable_set("@i_#{i}", i) | ||
end | ||
end | ||
Miss.new # Need one alloc to right size | ||
MISS = Miss.new | ||
DIVERGENT = Record.new(true) | ||
benchmark: | ||
vm_ivar_stable_shape: | | ||
BASE.first | ||
BASE.first | ||
BASE.first | ||
BASE.first | ||
BASE.first | ||
BASE.first | ||
vm_ivar_memoize_unstable_shape: | | ||
BASE.first | ||
LAZY.first | ||
BASE.first | ||
LAZY.first | ||
BASE.first | ||
LAZY.first | ||
vm_ivar_memoize_unstable_shape_miss: | | ||
BASE.first | ||
MISS.first | ||
BASE.first | ||
MISS.first | ||
BASE.first | ||
MISS.first | ||
vm_ivar_unstable_undef: | | ||
BASE.undef | ||
LAZY.undef | ||
BASE.undef | ||
LAZY.undef | ||
BASE.undef | ||
LAZY.undef | ||
vm_ivar_divergent_shape: | | ||
BASE.first | ||
DIVERGENT.first | ||
BASE.first | ||
DIVERGENT.first | ||
BASE.first | ||
DIVERGENT.first | ||
vm_ivar_divergent_shape_imbalanced: | | ||
BASE.first | ||
DIVERGENT.first | ||
DIVERGENT.first | ||
DIVERGENT.first | ||
DIVERGENT.first | ||
DIVERGENT.first |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters