Skip to content

Commit d68ea09

Browse files
committed
[GR-18163] Use MethodEntry Assumptions to track whether CoreMethodAssumptions still hold
PullRequest: truffleruby/4249
2 parents d226c36 + a608e54 commit d68ea09

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+183
-114
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Changes:
2929

3030
Memory Footprint:
3131

32+
* Use inlined core method nodes even when modules are prepended to core classes (#3546, @eregon).
33+
3234
# 24.0.0
3335

3436
New features:

spec/ruby/core/module/prepend_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,26 @@ def foo
7575
foo.call.should == 'm'
7676
end
7777

78+
it "updates the optimized method when a prepended module is updated" do
79+
out = ruby_exe(<<~RUBY)
80+
module M; end
81+
class Integer
82+
prepend M
83+
end
84+
l = -> { 1 + 2 }
85+
p l.call
86+
M.module_eval do
87+
def +(o)
88+
$called = true
89+
super(o)
90+
end
91+
end
92+
p l.call
93+
p $called
94+
RUBY
95+
out.should == "3\n3\ntrue\n"
96+
end
97+
7898
it "updates the method when there is a base included method and the prepended module overrides it" do
7999
base_module = Module.new do
80100
def foo
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
fails:Module#prepend uses only new module when dupping the module
22
fails:Module#prepend prepends a module if it is included in a super class
33
fails:Module#prepend when module already exists in ancestor chain modifies the ancestor chain
4+
slow:Module#prepend updates the optimized method when a prepended module is updated
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
slow:Redefining optimized core methods emits performance warning for redefining core classes methods
22
slow:Prepending a module into a class with optimised methods emits performance warning
3+
slow:Prepending a module into a class with optimised methods keeps the inlined nodes if no optimised method is overridden
4+
slow:Prepending a module into a class with optimised methods emits performance warning if that module overrides an optimised method

spec/truffle/parsing/fixtures/case/with_expression_and_when/with_else_branch.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ ast: |
7878
attributes:
7979
assumptions = [Assumption(valid, name=set_trace_func is not used)]
8080
flags = 0
81-
integerCaseEqualAssumption = Assumption(valid, name=inlined Integer#===)
81+
integerCaseEqualAssumption = Assumption(valid, name=core method is not overridden:)
8282
parameters = RubyCallNodeParameters{methodName='===', descriptor=NoKeywordArgumentsDescriptor, isSplatted=false, ignoreVisibility=true, isVCall=false, isSafeNavigation=false, isAttrAssign=false}
8383
sourceCharIndex = -1
8484
sourceLength = 0
@@ -110,7 +110,7 @@ ast: |
110110
attributes:
111111
assumptions = [Assumption(valid, name=set_trace_func is not used)]
112112
flags = 0
113-
integerCaseEqualAssumption = Assumption(valid, name=inlined Integer#===)
113+
integerCaseEqualAssumption = Assumption(valid, name=core method is not overridden:)
114114
parameters = RubyCallNodeParameters{methodName='===', descriptor=NoKeywordArgumentsDescriptor, isSplatted=false, ignoreVisibility=true, isVCall=false, isSafeNavigation=false, isAttrAssign=false}
115115
sourceCharIndex = -1
116116
sourceLength = 0

spec/truffle/parsing/fixtures/case/with_expression_and_when/with_multiple_values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ ast: |
7878
attributes:
7979
assumptions = [Assumption(valid, name=set_trace_func is not used)]
8080
flags = 0
81-
integerCaseEqualAssumption = Assumption(valid, name=inlined Integer#===)
81+
integerCaseEqualAssumption = Assumption(valid, name=core method is not overridden:)
8282
parameters = RubyCallNodeParameters{methodName='===', descriptor=NoKeywordArgumentsDescriptor, isSplatted=false, ignoreVisibility=true, isVCall=false, isSafeNavigation=false, isAttrAssign=false}
8383
sourceCharIndex = -1
8484
sourceLength = 0
@@ -103,7 +103,7 @@ ast: |
103103
attributes:
104104
assumptions = [Assumption(valid, name=set_trace_func is not used)]
105105
flags = 0
106-
integerCaseEqualAssumption = Assumption(valid, name=inlined Integer#===)
106+
integerCaseEqualAssumption = Assumption(valid, name=core method is not overridden:)
107107
parameters = RubyCallNodeParameters{methodName='===', descriptor=NoKeywordArgumentsDescriptor, isSplatted=false, ignoreVisibility=true, isVCall=false, isSafeNavigation=false, isAttrAssign=false}
108108
sourceCharIndex = -1
109109
sourceLength = 0

spec/truffle/parsing/fixtures/case/with_expression_and_when/with_single_value.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ ast: |
7777
attributes:
7878
assumptions = [Assumption(valid, name=set_trace_func is not used)]
7979
flags = 0
80-
integerCaseEqualAssumption = Assumption(valid, name=inlined Integer#===)
80+
integerCaseEqualAssumption = Assumption(valid, name=core method is not overridden:)
8181
parameters = RubyCallNodeParameters{methodName='===', descriptor=NoKeywordArgumentsDescriptor, isSplatted=false, ignoreVisibility=true, isVCall=false, isSafeNavigation=false, isAttrAssign=false}
8282
sourceCharIndex = -1
8383
sourceLength = 0
@@ -109,7 +109,7 @@ ast: |
109109
attributes:
110110
assumptions = [Assumption(valid, name=set_trace_func is not used)]
111111
flags = 0
112-
integerCaseEqualAssumption = Assumption(valid, name=inlined Integer#===)
112+
integerCaseEqualAssumption = Assumption(valid, name=core method is not overridden:)
113113
parameters = RubyCallNodeParameters{methodName='===', descriptor=NoKeywordArgumentsDescriptor, isSplatted=false, ignoreVisibility=true, isVCall=false, isSafeNavigation=false, isAttrAssign=false}
114114
sourceCharIndex = -1
115115
sourceLength = 0

spec/truffle/parsing/fixtures/case/with_expression_and_when/with_string_literal_in_when_clause.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ ast: |
2020
attributes:
2121
assumptions = [Assumption(valid, name=set_trace_func is not used)]
2222
flags = 0
23-
integerCaseEqualAssumption = Assumption(valid, name=inlined Integer#===)
23+
integerCaseEqualAssumption = Assumption(valid, name=core method is not overridden:)
2424
parameters = RubyCallNodeParameters{methodName='===', descriptor=NoKeywordArgumentsDescriptor, isSplatted=false, ignoreVisibility=true, isVCall=false, isSafeNavigation=false, isAttrAssign=false}
2525
sourceCharIndex = -1
2626
sourceLength = 0

spec/truffle/parsing/fixtures/complex_numbers/with_rational_and_imaginary_parts.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ruby: |
88
ast: |
99
InlinedAddNodeGen
1010
attributes:
11-
assumptions = [Assumption(valid, name=set_trace_func is not used), Assumption(valid, name=inlined Integer#+), Assumption(valid, name=inlined Float#+)]
11+
assumptions = [Assumption(valid, name=set_trace_func is not used), Assumption(valid, name=core method is not overridden:), Assumption(valid, name=core method is not overridden:)]
1212
flags = 1
1313
parameters = RubyCallNodeParameters{methodName='+', descriptor=NoKeywordArgumentsDescriptor, isSplatted=false, ignoreVisibility=false, isVCall=false, isSafeNavigation=false, isAttrAssign=false}
1414
sourceCharIndex = 0

spec/truffle/parsing/fixtures/method_calls/special_cases/method_%.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ruby: |
66
ast: |
77
InlinedModNodeGen
88
attributes:
9-
assumptions = [Assumption(valid, name=set_trace_func is not used), Assumption(valid, name=inlined Integer#%), Assumption(valid, name=inlined Float#%)]
9+
assumptions = [Assumption(valid, name=set_trace_func is not used), Assumption(valid, name=core method is not overridden:), Assumption(valid, name=core method is not overridden:)]
1010
flags = 1
1111
parameters = RubyCallNodeParameters{methodName='%', descriptor=NoKeywordArgumentsDescriptor, isSplatted=false, ignoreVisibility=false, isVCall=false, isSafeNavigation=false, isAttrAssign=false}
1212
sourceCharIndex = 0

0 commit comments

Comments
 (0)