Project

General

Profile

Actions

Feature #10328

open

[PATCH] make OPT_SUPPORT_JOKE a proper VM option

Added by normalperson (Eric Wong) about 10 years ago. Updated 8 months ago.

Status:
Assigned
Target version:
-
[ruby-core:65419]

Description

This is not a joke :)

I worry about executable size with things like [Feature #10326],
and I noticed unused instructions are emitted even with jokes disabled

This reduces executable size slightly on x86-64-linux:

text | data | bss | dec | hex | filename
--------+-------+--------+---------+--------+------------
2782156 | 22400 | 71880 | 2876436 | 2be414 | ruby.before
2781420 | 22400 | 71880 | 2875700 | 2be134 | ruby.after

Pretty trivial so I'll commit in a day or two.


 compile.c           | 4 ++--
 eval.c              | 2 +-
 iseq.h              | 2 +-
 tool/instruction.rb | 9 ++++++---
 vm_opts.h           | 2 +-
 5 files changed, 11 insertions(+), 8 deletions(-)

Files

Updated by ko1 (Koichi Sasada) about 10 years ago

or remove them?

Updated by normalperson (Eric Wong) about 10 years ago

wrote:

or remove them?

Sure, even better.
Anybody have objections to removing joke VM options?
Ruby 2.2 can officially become a SERIOUS VM :)

Updated by ko1 (Koichi Sasada) about 10 years ago

BTW, we provide "bitblt" and "answer" insturctions as a official (joke) instructions without enabling SUPPORT_JOKE flag.
People can use them by assembling YARV codes (with some tricks) manually.

With your measurement, we paid 736 bytes for this kind of humor.
Personally, I hope that Ruby can understand humor.
736 byte is not expensive for me.

However, I also agree Ruby is now a serious language.

Updated by nobu (Nobuyoshi Nakada) about 10 years ago

  • Description updated (diff)

Updated by normalperson (Eric Wong) about 7 years ago

wrote:

BTW, we provide "bitblt" and "answer" insturctions as a official (joke) instructions without enabling SUPPORT_JOKE flag.
People can use them by assembling YARV codes (with some tricks) manually.

OK, since we remove "trace" instruction which breaks ISeq
compatibility anyways; I think we can remove "bitblt" and
"answer" to make the VM smaller.

With your measurement, we paid 736 bytes for this kind of humor.
Personally, I hope that Ruby can understand humor.
736 byte is not expensive for me.

However, I also agree Ruby is now a serious language.

Every byte counts to me; that's 12 cache lines on most CPUs.

Updated by mame (Yusuke Endoh) almost 7 years ago

A patch to remove joke instructions when SUPPORT_JOKE is false:

diff --git a/tool/instruction.rb b/tool/instruction.rb
index 3354933da9..e917826ffe 100755
--- a/tool/instruction.rb
+++ b/tool/instruction.rb
@@ -885,6 +885,7 @@ def make_footer_undefs insn
 
     def make_header insn
       label = insn.trace ? '' : "start_of_#{insn.name}:;"
+      commit "#ifdef SUPPORT_JOKE" if insn.comm[:c] == "joke"
       commit "INSN_ENTRY(#{insn.name}){#{label}"
       make_header_prepare_stack insn
       commit "{"
@@ -911,6 +912,7 @@ def make_footer insn
         make_footer_undefs insn
       end
       commit "  END_INSN(#{insn.name});}}}"
+      commit "#endif /* SUPPORT_JOKE */" if insn.comm[:c] == "joke"
     end
 
     def make_insn_def insn

I'm neutral to the SUPPORT_JOKE feature. I don't care 736 bytes if the feature is funny enough. But I'm unsure if the feature is funny enough.

Updated by normalperson (Eric Wong) almost 7 years ago

I prefer we remove the code from the VM to make it easier-to-read
(I have a short attention span)

My most recent patch
https://80x24.org/spew/20171115070108.3264-1-e@80x24.org/raw
removes 120 lines. Many of those lines are inside #if blocks,
and I find having #if/#ifdefs inside function bodies to be confusing.

Actions #9

Updated by naruse (Yui NARUSE) almost 7 years ago

  • Target version deleted (2.2.0)
Actions #10

Updated by hsbt (Hiroshi SHIBATA) 8 months ago

  • Status changed from Open to Assigned
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0