Project

General

Profile

Actions

Feature #13295

closed

[PATCH] compile.c: apply opt_str_freeze to String#-@ (uminus)

Added by normalperson (Eric Wong) over 7 years ago. Updated over 7 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:79971]

Description

The same optimization used for "literal string".freeze
can easily apply to uminus without introducing any
compatibility problems.

I can't think of any problems this would introduce,
but I'll wait a few days for feedback before committing.


Files

Updated by shyouhei (Shyouhei Urabe) over 7 years ago

We looked at this issue in today's developer meeting.

Koichi pointed out that you have to consider redefinition of String#-@. You need to take care about such situation, like we do already for #freeze.

Updated by normalperson (Eric Wong) over 7 years ago

wrote:

We looked at this issue in today's developer meeting.

Koichi pointed out that you have to consider redefinition of
String#-@. You need to take care about such situation, like
we do already for #freeze.

Oops, I already committed r57828 before this message.
opt_str_freeze insn already takes care of redefinition in
insns.def; so extra check for compile.c won't be affected.

Actions #3

Updated by Anonymous over 7 years ago

  • Status changed from Open to Closed

Applied in changeset trunk|r58142.


NEWS: feature number for String#-@ compile-time optimization

[ruby-core:79971] [Feature #13295]

Updated by ko1 (Koichi Sasada) over 7 years ago

On 2017/03/26 15:16, Eric Wong wrote:

Oops, I already committed r57828 before this message.
opt_str_freeze insn already takes care of redefinition in
insns.def; so extra check for compile.c won't be affected.

now it checks only 'freeze' redefinition (*1). I'll fix it before 2.5
release (maybe with new a instruction (*2), which replace existing
opt_str_freeze).

*1:
class String
def -@
p :redef
self
end
end

p -'foo'

*2:
opt_str_freeze "foo"
->
opt_frozen "foo", label # jump if String#freeze or String#-@

are not redefined

putstring "foo"
send "-@"
label:

(or something smarter insn)

--
// SASADA Koichi at atdot dot net

Updated by normalperson (Eric Wong) over 7 years ago

SASADA Koichi wrote:

On 2017/03/26 15:16, Eric Wong wrote:

Oops, I already committed r57828 before this message.
opt_str_freeze insn already takes care of redefinition in
insns.def; so extra check for compile.c won't be affected.

now it checks only 'freeze' redefinition (*1). I'll fix it before 2.5
release (maybe with new a instruction (*2), which replace existing
opt_str_freeze).

You're absolutely right; sorry about that. I will fix simply, for now.

But maybe you can do (*2) later.

Updated by ko1 (Koichi Sasada) over 7 years ago

On 2017/03/27 14:55, Eric Wong wrote:

You're absolutely right; sorry about that. I will fix simply, for now.

Nobody redef them so no problem :p

--
// SASADA Koichi at atdot dot net

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0