ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:68506] Seven stacks (and two questions)
@ 2015-03-12 10:15 Jakub Trzebiatowski
  2015-03-12 13:00 ` [ruby-core:68508] " Nobuyoshi Nakada
  0 siblings, 1 reply; 5+ messages in thread
From: Jakub Trzebiatowski @ 2015-03-12 10:15 UTC (permalink / raw
  To: ruby-core

[-- Attachment #1: Type: text/plain, Size: 772 bytes --]

The Ruby Hacking Guide says that Ruby has… seven stacks. Is it an implementation choice (and it could be implemented with one stack), or is there really a need for seven logical stacks? For example, Lua has one stack, and still closures with upvalues are totally possible (it’s like Ruby’s blocks that can reference local variables of their enclosing method, but it works for any function with any upvalues). 

1. Is there any Ruby feature that I’m not aware of, and it justifies the need of seven stacks?

2. When does Ruby generate `getdynamic` YARV opcode? Could you provide me with an example source code? (I really tried to make Ruby generate it. No results.)

---
Jakub Trzebiatowski
Computer science student
Gdańsk University of Technology




[-- Attachment #2: Type: text/html, Size: 1662 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:68508] Re: Seven stacks (and two questions)
  2015-03-12 10:15 [ruby-core:68506] Seven stacks (and two questions) Jakub Trzebiatowski
@ 2015-03-12 13:00 ` Nobuyoshi Nakada
  2015-03-12 20:34   ` [ruby-core:68512] " SASADA Koichi
                     ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Nobuyoshi Nakada @ 2015-03-12 13:00 UTC (permalink / raw
  To: Ruby developers

On 2015/03/12 19:15, Jakub Trzebiatowski wrote:
> The Ruby Hacking Guide says that Ruby has… seven stacks. Is it an
> implementation choice (and it could be implemented with one stack),
> or is there really a need for seven logical stacks? For example, Lua
> has one stack, and still closures with upvalues are totally possible
> (it’s like Ruby’s blocks that can reference local variables of
> their enclosing method, but it works for any function with any
> upvalues).

RHG is a good book, but quite old for the core implementation.

> 2. When does Ruby generate `getdynamic` YARV opcode? Could you
> provide me with an example source code? (I really tried to make Ruby
> generate it. No results.)

No such instruction in YARV.
Do you mean `getlocal`?

-- 
Nobu Nakada

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:68512] Re: Seven stacks (and two questions)
  2015-03-12 13:00 ` [ruby-core:68508] " Nobuyoshi Nakada
@ 2015-03-12 20:34   ` SASADA Koichi
  2015-03-13  3:06   ` [ruby-core:68513] " "Martin J. Dürst"
  2015-03-13  4:52   ` [ruby-core:68514] " Nobuyoshi Nakada
  2 siblings, 0 replies; 5+ messages in thread
From: SASADA Koichi @ 2015-03-12 20:34 UTC (permalink / raw
  To: ruby-core

On 2015/03/12 22:00, Nobuyoshi Nakada wrote:
>> > 2. When does Ruby generate `getdynamic` YARV opcode? Could you
>> > provide me with an example source code? (I really tried to make Ruby
>> > generate it. No results.)
> No such instruction in YARV.
> Do you mean `getlocal`?

Ruby 1.9 has. But it was removed.

-- 
// SASADA Koichi at atdot dot net

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:68513] Re: Seven stacks (and two questions)
  2015-03-12 13:00 ` [ruby-core:68508] " Nobuyoshi Nakada
  2015-03-12 20:34   ` [ruby-core:68512] " SASADA Koichi
@ 2015-03-13  3:06   ` "Martin J. Dürst"
  2015-03-13  4:52   ` [ruby-core:68514] " Nobuyoshi Nakada
  2 siblings, 0 replies; 5+ messages in thread
From: "Martin J. Dürst" @ 2015-03-13  3:06 UTC (permalink / raw
  To: Ruby developers, Jakub Trzebiatowski

Hello Jakub,

On 2015/03/12 22:00, Nobuyoshi Nakada wrote:
> On 2015/03/12 19:15, Jakub Trzebiatowski wrote:
>> The Ruby Hacking Guide says that Ruby has… seven stacks. Is it an
>> implementation choice (and it could be implemented with one stack),
>> or is there really a need for seven logical stacks? For example, Lua
>> has one stack, and still closures with upvalues are totally possible
>> (it’s like Ruby’s blocks that can reference local variables of
>> their enclosing method, but it works for any function with any
>> upvalues).
>
> RHG is a good book, but quite old for the core implementation.

I suggest you look at "Ruby Under a Microscope: An Illustrated Guide to 
Ruby Internals". It's much less detailed than the Ruby Hacking Guide, 
but much more up to date. And as far as I can remember, it talks about 2 
stacks, not seven.

Regards,   Martin.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-core:68514] Re: Seven stacks (and two questions)
  2015-03-12 13:00 ` [ruby-core:68508] " Nobuyoshi Nakada
  2015-03-12 20:34   ` [ruby-core:68512] " SASADA Koichi
  2015-03-13  3:06   ` [ruby-core:68513] " "Martin J. Dürst"
@ 2015-03-13  4:52   ` Nobuyoshi Nakada
  2 siblings, 0 replies; 5+ messages in thread
From: Nobuyoshi Nakada @ 2015-03-13  4:52 UTC (permalink / raw
  To: Ruby developers

On 2015/03/12 22:00, Nobuyoshi Nakada wrote:
> On 2015/03/12 19:15, Jakub Trzebiatowski wrote:
>> The Ruby Hacking Guide says that Ruby has… seven stacks. Is it an
>> implementation choice (and it could be implemented with one stack),
>> or is there really a need for seven logical stacks? For example, Lua
>> has one stack, and still closures with upvalues are totally possible
>> (it’s like Ruby’s blocks that can reference local variables of
>> their enclosing method, but it works for any function with any
>> upvalues).
> 
> RHG is a good book, but quite old for the core implementation.

Perhaps, "stacks" might confuse you, I guess.

They are actually single-linked lists, stored on the machine stack but not separate areas, and called "stacks" as they are used as LIFO.
The reason counting separately is that all infos are not always saved/restored together.

-- 
Nobu Nakada

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2015-03-13  4:46 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-12 10:15 [ruby-core:68506] Seven stacks (and two questions) Jakub Trzebiatowski
2015-03-12 13:00 ` [ruby-core:68508] " Nobuyoshi Nakada
2015-03-12 20:34   ` [ruby-core:68512] " SASADA Koichi
2015-03-13  3:06   ` [ruby-core:68513] " "Martin J. Dürst"
2015-03-13  4:52   ` [ruby-core:68514] " Nobuyoshi Nakada

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 read-only IMAP folder(s) and NNTP newsgroup(s).