[#65451] [ruby-trunk - Feature #10333] [PATCH 3/1] optimize: "yoda literal" == string — ko1@...

Issue #10333 has been updated by Koichi Sasada.

9 messages 2014/10/07

[ruby-core:65575] Re: [ruby-trunk - Feature #10333] [PATCH 3/1] optimize: "yoda literal" == string

From: Eric Wong <normalperson@...>
Date: 2014-10-10 00:55:56 UTC
List: ruby-core #65575
Current patch (named "opt_str_lit" insn):

	http://80x24.org/spew/m/opt-str-lit-v1%40m.txt

One VM instruction now optimizes away object allocation for string
literals in the following cases:

* "lit" % obj
* str << "lit"
* "lit" + str
* str + "lit"
* "lit" * num
* "lit" === obj
* obj === "lit"
* "lit" == str
* str == "lit"
* "lit" != str
* str != "lit"
* hash["lit"]
* hash["lit"] = obj

It is also in the "opt_str_lit" branch of git://bogomips.org/ruby.git

We may rework the current BOP_ redefinition checks via generated code
to make it easier to extend to args of common operations:

* String#{gsub,tr,delete,squeeze,split,unpack})
* Hash#{include?,#key?} ...
* Array#{pack,include?,join} ...

Basically any common operation which takes a string literals.

In This Thread