* [ruby-core:119613] [Ruby master Misc#20814] iseq optimizations on constant condition
@ 2024-10-25 11:20 hurricup (Alexandr Evstigneev) via ruby-core
2024-10-25 14:26 ` [ruby-core:119616] " nobu (Nobuyoshi Nakada) via ruby-core
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: hurricup (Alexandr Evstigneev) via ruby-core @ 2024-10-25 11:20 UTC (permalink / raw)
To: ruby-core; +Cc: hurricup (Alexandr Evstigneev)
Issue #20814 has been reported by hurricup (Alexandr Evstigneev).
----------------------------------------
Misc #20814: iseq optimizations on constant condition
https://bugs.ruby-lang.org/issues/20814
* Author: hurricup (Alexandr Evstigneev)
* Status: Open
----------------------------------------
ruby 3.4-preview2 seems optimizes out some stuff when building iseq and this may lead to user unexpected behavior when debugging, because some lines just optimized out.
Example:
```
def foo1
if true
nil
else
1
end
end
```
produces:
```
== disasm: #<ISeq:foo1@/test.rb:1 (1,0)-(7,3)>
0000 putnil ( 3)[LiCa]
0001 leave ( 7)[Re]
```
Two questions:
- is there way to disable such optimizations?
- are there some specs on things that can be optimized.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ruby-core:119616] [Ruby master Misc#20814] iseq optimizations on constant condition
2024-10-25 11:20 [ruby-core:119613] [Ruby master Misc#20814] iseq optimizations on constant condition hurricup (Alexandr Evstigneev) via ruby-core
@ 2024-10-25 14:26 ` nobu (Nobuyoshi Nakada) via ruby-core
2024-10-25 14:27 ` [ruby-core:119617] " nobu (Nobuyoshi Nakada) via ruby-core
2024-10-29 4:40 ` [ruby-core:119635] " hurricup (Alexandr Evstigneev) via ruby-core
2 siblings, 0 replies; 4+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2024-10-25 14:26 UTC (permalink / raw)
To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)
Issue #20814 has been updated by nobu (Nobuyoshi Nakada).
Status changed from Open to Feedback
Because of the dynamic feature of Ruby, the optimization on ISeq is very limited.
For instance, elimination of unreachable branch because of a simple always-true/false condition expression, in your example.
> - is there way to disable such optimizations?
To disable optimizations, see the document of `RubyVM::InstructionSequence.compile_option=`.
https://docs.ruby-lang.org/en/master/RubyVM/InstructionSequence.html#method-c-compile_option-3D
> - are there some specs on things that can be optimized.
We do not provide explicit documentation or specifications regarding optimizations because they are internal features and may change without notice.
----------------------------------------
Misc #20814: iseq optimizations on constant condition
https://bugs.ruby-lang.org/issues/20814#change-110238
* Author: hurricup (Alexandr Evstigneev)
* Status: Feedback
----------------------------------------
ruby 3.4-preview2 seems optimizes out some stuff when building iseq and this may lead to user unexpected behavior when debugging, because some lines just optimized out.
Example:
```
def foo1
if true
nil
else
1
end
end
```
produces:
```
== disasm: #<ISeq:foo1@/test.rb:1 (1,0)-(7,3)>
0000 putnil ( 3)[LiCa]
0001 leave ( 7)[Re]
```
Two questions:
- is there way to disable such optimizations?
- are there some specs on things that can be optimized.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ruby-core:119617] [Ruby master Misc#20814] iseq optimizations on constant condition
2024-10-25 11:20 [ruby-core:119613] [Ruby master Misc#20814] iseq optimizations on constant condition hurricup (Alexandr Evstigneev) via ruby-core
2024-10-25 14:26 ` [ruby-core:119616] " nobu (Nobuyoshi Nakada) via ruby-core
@ 2024-10-25 14:27 ` nobu (Nobuyoshi Nakada) via ruby-core
2024-10-29 4:40 ` [ruby-core:119635] " hurricup (Alexandr Evstigneev) via ruby-core
2 siblings, 0 replies; 4+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2024-10-25 14:27 UTC (permalink / raw)
To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)
Issue #20814 has been updated by nobu (Nobuyoshi Nakada).
Description updated
hurricup (Alexandr Evstigneev) wrote:
> ruby 3.4-preview2 seems optimizes out some stuff when building iseq and this may lead to user unexpected behavior when debugging, because some lines just optimized out.
>
> Example:
> ```
> def foo1
> if true
> nil
> else
> 1
> end
> end
> ```
>
> produces:
> ```
> == disasm: #<ISeq:foo1@/test.rb:1 (1,0)-(7,3)>
> 0000 putnil ( 3)[LiCa]
> 0001 leave ( 7)[Re]
> ```
>
> Two questions:
> - is there way to disable such optimizations?
> - are there some specs on things that can be optimized.
----------------------------------------
Misc #20814: iseq optimizations on constant condition
https://bugs.ruby-lang.org/issues/20814#change-110239
* Author: hurricup (Alexandr Evstigneev)
* Status: Feedback
----------------------------------------
ruby 3.4-preview2 seems optimizes out some stuff when building iseq and this may lead to user unexpected behavior when debugging, because some lines just optimized out.
Example:
```ruby
def foo1
if true
nil
else
1
end
end
```
produces:
```
== disasm: #<ISeq:foo1@/test.rb:1 (1,0)-(7,3)>
0000 putnil ( 3)[LiCa]
0001 leave ( 7)[Re]
```
Two questions:
- is there way to disable such optimizations?
- are there some specs on things that can be optimized.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
* [ruby-core:119635] [Ruby master Misc#20814] iseq optimizations on constant condition
2024-10-25 11:20 [ruby-core:119613] [Ruby master Misc#20814] iseq optimizations on constant condition hurricup (Alexandr Evstigneev) via ruby-core
2024-10-25 14:26 ` [ruby-core:119616] " nobu (Nobuyoshi Nakada) via ruby-core
2024-10-25 14:27 ` [ruby-core:119617] " nobu (Nobuyoshi Nakada) via ruby-core
@ 2024-10-29 4:40 ` hurricup (Alexandr Evstigneev) via ruby-core
2 siblings, 0 replies; 4+ messages in thread
From: hurricup (Alexandr Evstigneev) via ruby-core @ 2024-10-29 4:40 UTC (permalink / raw)
To: ruby-core; +Cc: hurricup (Alexandr Evstigneev)
Issue #20814 has been updated by hurricup (Alexandr Evstigneev).
nobu (Nobuyoshi Nakada) wrote in #note-1:
> To disable optimizations, see the document of `RubyVM::InstructionSequence.compile_option=`.
> https://docs.ruby-lang.org/en/master/RubyVM/InstructionSequence.html#method-c-compile_option-3D
My question is more about the runtime. E.g I want to run a ruby program with optimizations disabled at all. Or load using `rb_load`/`rb_load_protect` while ruby process is already alive with default settings.
----------------------------------------
Misc #20814: iseq optimizations on constant condition
https://bugs.ruby-lang.org/issues/20814#change-110288
* Author: hurricup (Alexandr Evstigneev)
* Status: Feedback
----------------------------------------
ruby 3.4-preview2 seems optimizes out some stuff when building iseq and this may lead to user unexpected behavior when debugging, because some lines just optimized out.
Example:
```ruby
def foo1
if true
nil
else
1
end
end
```
produces:
```
== disasm: #<ISeq:foo1@/test.rb:1 (1,0)-(7,3)>
0000 putnil ( 3)[LiCa]
0001 leave ( 7)[Re]
```
Two questions:
- is there way to disable such optimizations?
- are there some specs on things that can be optimized.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-10-29 4:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-25 11:20 [ruby-core:119613] [Ruby master Misc#20814] iseq optimizations on constant condition hurricup (Alexandr Evstigneev) via ruby-core
2024-10-25 14:26 ` [ruby-core:119616] " nobu (Nobuyoshi Nakada) via ruby-core
2024-10-25 14:27 ` [ruby-core:119617] " nobu (Nobuyoshi Nakada) via ruby-core
2024-10-29 4:40 ` [ruby-core:119635] " hurricup (Alexandr Evstigneev) via ruby-core
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).