Slide 109
Slide 109 text
VM_ENV_DATA_SIZE ϝιουͷม܈ ϝιουͷҾ
local table size: 4
0 1 2 3 4 6
5
slot index
var4 -> slot[3]
var3 -> slot[4]
var2 -> slot[5]
var1 -> slot[6]
call info argc: 2
- ྫͷ varN (N ࣗવ, N>0) ʮVM_ENV_DATA_SIZE + local table size - (N - 1)ʯͰٻΊΒΕ·͢ɻͭ·Γ var1 ʮVM_ENV_DATA_SIZE(3) + local table size(4) - N(1)ʯͰ slot[6] ʹ֨ೲ͞ΕΔ͜ͱ͕Θ͔Γ·͢ɻ
- ϝιουʹ͢Ҿఆٛ͞ΕͨҾͷॱংͱٯͰ slot index ʹඥ͚Δඞཁ͕͋Γ·͢
- opcode ͷ [gs]etlocal(?:_WC[01]|) ͜ΕʹैͬͯΛऔΔΑ͏ʹͳ͍ͬͯ·͢
- 3 ൪͔ΒελʔτͳͷɼRubyVM ʹඞཁͳใΛຒΊࠐΜͰ͍ΔͨΊͬΆ͍ʢʁʣʢVM_ENV_DATA_INDEX_ME_CREF, VM_ENV_DATA_INDEX_SPECVAL, VM_ENV_DATA_INDEX_FLAGSʣ
- Ҿ͕͋Δ߹ϝιουݺͼग़͠ͷલʹ༧Ί slot ʹΛೖΕͯϝιουݺͼग़͠Λߦ͏ඞཁ͕͋Γ·͢ɻྫͰ var1 slot[6], var2 slot[5] ʹ༧ΊΛೖΕ͓ͯ͘ඞཁ͕͋Γ·͢ɻ
ͳ͓ɼvar3 var4 ෦ͷ໋ྩγʔέϯεʹ͓͍ͯ setlocal ͕ݺͼग़͞ΕΔͷͰɼ༧ΊΛೖΕ͓ͯ͘ඞཁ͋Γ·ͤΜɻ
(࣮ͷώϯτ: https://github.com/m3m0r7/rubyvm-on-php/blob/0.3.2.2/src/VM/Core/Runtime/Executor/CallBlockHelper.php#L121 )