Skip to content

Commit 544e635

Browse files
committed
Bump version.
1 parent a92cfbc commit 544e635

File tree

4 files changed

+44
-48
lines changed

4 files changed

+44
-48
lines changed

Cargo.lock

+4-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "ruruby"
3-
version = "0.3.1"
3+
version = "0.4.1"
44
authors = ["monochrome <[email protected]>"]
55
edition = "2018"
66
license-file = "LICENSE"
@@ -28,7 +28,7 @@ divrem = "1.0.0"
2828
fxhash = "0.2.1"
2929
chrono = "0.4.15"
3030
terminal_size = "0.1.16"
31-
console = "0.14.0"
31+
console = "0.15.0"
3232
dirs = "4.0.0"
3333
smallvec = "1.5.0"
3434
arraystring = "0.3.0"

src/vm/executor/frame.rs

+14-32
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,6 @@
11
use super::*;
22
use std::ops::IndexMut;
33

4-
//
5-
// Stack handling
6-
//
7-
// before frame preparation
8-
//
9-
// lfp cfp sp
10-
// v v <------ new local frame -----> v
11-
// +------+------+--+------+------+------+------+------+------+--------+------+------+--+------+------+------------------------
12-
// | a0 | a1 |..| an | self | flg1 | cfp2 | mfp1 | pc2 | .... | b0 | b1 |..| bn | self |
13-
// +------+------+--+------+------+------+------+------+------+--------+------+------+--+------+------+------------------------
14-
// <------- local frame --------> <-- control frame ->
15-
//
16-
//
17-
// after frame preparation
18-
//
19-
// lfp1 cfp1 lfp cfp sp
20-
// v v v v v
21-
// +------+------+--+------+------+------+------+------+------+--------+------+------+--+------+------+------+------+------+------+---
22-
// | a0 | a1 |..| an | self | flg1 | cfp2 | mfp1 | pc2 | .... | b0 | b1 |..| bn | self | flg | cfp1 | mfp | pc1 |
23-
// +------+------+--+------+------+------+------+------+------+--------+------+------+--+------+------+------+------+------+------+---
24-
// <------- local frame --------> <------- control frame -------
25-
//
26-
// after execution
27-
//
28-
// lfp cfp sp
29-
// v v v
30-
// +------+------+--+------+------+------+------+------+------+--------+-------------------------------------------------------
31-
// | a0 | a1 |..| an | self | flg1 | cfp2 | mfp1 | pc2 | .... |
32-
// +------+------+--+------+------+------+------+------+------+--------+-------------------------------------------------------
33-
//
34-
354
pub const CFP_OFFSET: usize = 0;
365
pub const LFP_OFFSET: usize = 1;
376
pub const FLAG_OFFSET: usize = 2;
@@ -44,7 +13,7 @@ pub const BLK_OFFSET: usize = 8;
4413
pub const NATIVE_FRAME_LEN: usize = 3;
4514
pub const RUBY_FRAME_LEN: usize = 9;
4615

47-
/// Control frame.
16+
/// Control frame on the RubyStack.
4817
#[derive(Debug, Clone, Copy, PartialEq)]
4918
pub struct Frame(pub usize);
5019

@@ -241,6 +210,13 @@ impl ControlFrame {
241210
}
242211
}
243212

213+
///
214+
/// Dynamic frame
215+
///
216+
/// Wrapped raw pointer which points to a control frame on the stack or heap.
217+
/// You can obtain or alter various information like cfp, lfp, and the number of local variables
218+
/// in the frame through `DynamicFrame`.
219+
///
244220
#[derive(Debug, Clone, Copy, PartialEq)]
245221
pub struct DynamicFrame(*mut Value);
246222

@@ -300,6 +276,12 @@ impl DynamicFrame {
300276
}
301277
}
302278

279+
///
280+
/// Local frame
281+
///
282+
/// Wrapped raw pointer which points to a local variables area on the stack or heap.
283+
/// You can handle local variables of the frame.
284+
///
303285
#[derive(Debug, Clone, Copy, PartialEq)]
304286
pub struct LocalFrame(pub(super) *mut Value);
305287

src/vm/executor/stack_frame.md

+24-4
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,40 @@
11
# structure of stack frame
22

3+
This document describes a structure of stack frames.
4+
5+
## Ruby method/block
6+
37
lfp cfp sp
48
v v v
59
--+------+------+--+------+------+--+------+------+------+------+------+------+------+------+------+------+------+-----
6-
| a0 | a1 |..| an | l0 |..| ln | self | flag |precfp| mfp | dfp | pc | ctx | iseq | lfp | blok |
10+
| a0 | a1 |..| an | l0 |..| ln | self |precfp| lfp | flg | mfp | dfp | pc | heap | iseq | blok |
711
--+------+------+--+------+------+--+------+------+------+------+------+------+------+------+------+------+------+-----
812
<------------ local frame -------------> <------------------------- control frame --------------------------->
913

1014
- a0..an: arguments
1115
- l0..ln: local variables
1216
- self: self value
13-
- flag: various infomation of current context.
14-
- precfp: cfp of previous frame (always on the stack)
17+
- precfp: cfp of the previous frame (always on the stack)
18+
- lfp: local frame pointer (on the stack or heap)
19+
- flg: various infomation of current context.
1520
- mfp: method frame pointer (on the stack or heap)
1621
- dfp: outer frame pointer (on the stack or heap)
1722
- pc: current program counter (on iseq)
23+
- heap: if this frame has been moved to heap, this field points to the heap frame.
1824
- iseq: reference to a bytecode (instruction sequence)
19-
- lfp: local frame pointer (on the stack or heap)
2025
- block: a block which passed to current context by caller frame.
26+
27+
## native method frame
28+
29+
lfp cfp sp
30+
v v v
31+
--+------+------+--+------+------+------+------+------+-----
32+
| a0 | a1 |..| an | self |precfp| lfp | flg |
33+
--+------+------+--+------+------+------+------+------+-----
34+
<---- local frame ----> <----- control frame ----->
35+
36+
- a0..an: arguments
37+
- self: self value
38+
- precfp: cfp of the previous frame (always on the stack)
39+
- lfp: local frame pointer (on the stack or heap)
40+
- flg: various infomation of current context.

0 commit comments

Comments
 (0)