Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
ruby
提交
ccb7a4b9
R
ruby
项目概览
张重言
/
ruby
通知
3
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
ruby
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
ccb7a4b9
编写于
6月 15, 2020
作者:
N
Nobuyoshi Nakada
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Replaced accessors of `Struct` with `invokebuiltin`
上级
b06d7c55
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
45 addition
and
30 deletion
+45
-30
common.mk
common.mk
+1
-0
compile.c
compile.c
+8
-9
struct.c
struct.c
+36
-7
vm_insnhelper.c
vm_insnhelper.c
+0
-14
未找到文件。
common.mk
浏览文件 @
ccb7a4b9
...
@@ -13168,6 +13168,7 @@ struct.$(OBJEXT): {$(VPATH)}backward/2/r_cast.h
...
@@ -13168,6 +13168,7 @@ struct.$(OBJEXT): {$(VPATH)}backward/2/r_cast.h
struct.$(OBJEXT): {$(VPATH)}backward/2/rmodule.h
struct.$(OBJEXT): {$(VPATH)}backward/2/rmodule.h
struct.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
struct.$(OBJEXT): {$(VPATH)}backward/2/stdalign.h
struct.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
struct.$(OBJEXT): {$(VPATH)}backward/2/stdarg.h
struct.$(OBJEXT): {$(VPATH)}builtin.h
struct.$(OBJEXT): {$(VPATH)}config.h
struct.$(OBJEXT): {$(VPATH)}config.h
struct.$(OBJEXT): {$(VPATH)}defines.h
struct.$(OBJEXT): {$(VPATH)}defines.h
struct.$(OBJEXT): {$(VPATH)}encoding.h
struct.$(OBJEXT): {$(VPATH)}encoding.h
...
...
compile.c
浏览文件 @
ccb7a4b9
...
@@ -9681,19 +9681,19 @@ caller_location(VALUE *path, VALUE *realpath)
...
@@ -9681,19 +9681,19 @@ caller_location(VALUE *path, VALUE *realpath)
typedef
struct
{
typedef
struct
{
VALUE
arg
;
VALUE
arg
;
rb_insn_func_t
func
;
VALUE
func
;
int
line
;
int
line
;
}
accessor_args
;
}
accessor_args
;
static
const
rb_iseq_t
*
static
const
rb_iseq_t
*
method_for_self
(
VALUE
name
,
VALUE
arg
,
rb_insn_func_t
func
,
method_for_self
(
VALUE
name
,
VALUE
arg
,
const
struct
rb_builtin_function
*
func
,
void
(
*
build
)(
rb_iseq_t
*
,
LINK_ANCHOR
*
,
const
void
*
))
void
(
*
build
)(
rb_iseq_t
*
,
LINK_ANCHOR
*
,
const
void
*
))
{
{
VALUE
path
,
realpath
;
VALUE
path
,
realpath
;
accessor_args
acc
;
accessor_args
acc
;
acc
.
arg
=
arg
;
acc
.
arg
=
arg
;
acc
.
func
=
func
;
acc
.
func
=
(
VALUE
)
func
;
acc
.
line
=
caller_location
(
&
path
,
&
realpath
);
acc
.
line
=
caller_location
(
&
path
,
&
realpath
);
struct
rb_iseq_new_with_callback_callback_func
*
ifunc
=
struct
rb_iseq_new_with_callback_callback_func
*
ifunc
=
rb_iseq_new_with_callback_new_callback
(
build
,
&
acc
);
rb_iseq_new_with_callback_new_callback
(
build
,
&
acc
);
...
@@ -9714,7 +9714,7 @@ for_self_aref(rb_iseq_t *iseq, LINK_ANCHOR *ret, const void *a)
...
@@ -9714,7 +9714,7 @@ for_self_aref(rb_iseq_t *iseq, LINK_ANCHOR *ret, const void *a)
body
->
param
.
size
=
0
;
body
->
param
.
size
=
0
;
ADD_INSN1
(
ret
,
line
,
putobject
,
args
->
arg
);
ADD_INSN1
(
ret
,
line
,
putobject
,
args
->
arg
);
ADD_INSN1
(
ret
,
line
,
opt_call_c_function
,
(
VALUE
)
args
->
func
);
ADD_INSN1
(
ret
,
line
,
invokebuiltin
,
args
->
func
);
}
}
static
void
static
void
...
@@ -9731,24 +9731,23 @@ for_self_aset(rb_iseq_t *iseq, LINK_ANCHOR *ret, const void *a)
...
@@ -9731,24 +9731,23 @@ for_self_aset(rb_iseq_t *iseq, LINK_ANCHOR *ret, const void *a)
ADD_GETLOCAL
(
ret
,
line
,
numberof
(
vars
)
-
1
,
0
);
ADD_GETLOCAL
(
ret
,
line
,
numberof
(
vars
)
-
1
,
0
);
ADD_INSN1
(
ret
,
line
,
putobject
,
args
->
arg
);
ADD_INSN1
(
ret
,
line
,
putobject
,
args
->
arg
);
ADD_INSN1
(
ret
,
line
,
opt_call_c_function
,
(
VALUE
)
args
->
func
);
ADD_INSN1
(
ret
,
line
,
invokebuiltin
,
args
->
func
);
ADD_INSN
(
ret
,
line
,
pop
);
}
}
/*
/*
* func (index) -> (value)
* func (index) -> (value)
*/
*/
const
rb_iseq_t
*
const
rb_iseq_t
*
rb_method_for_self_aref
(
VALUE
name
,
VALUE
arg
,
rb_insn_func_t
func
)
rb_method_for_self_aref
(
VALUE
name
,
VALUE
arg
,
const
struct
rb_builtin_function
*
func
)
{
{
return
method_for_self
(
name
,
arg
,
func
,
for_self_aref
);
return
method_for_self
(
name
,
arg
,
func
,
for_self_aref
);
}
}
/*
/*
* func (index, value) -> (
index,
value)
* func (index, value) -> (value)
*/
*/
const
rb_iseq_t
*
const
rb_iseq_t
*
rb_method_for_self_aset
(
VALUE
name
,
VALUE
arg
,
rb_insn_func_t
func
)
rb_method_for_self_aset
(
VALUE
name
,
VALUE
arg
,
const
struct
rb_builtin_function
*
func
)
{
{
return
method_for_self
(
name
,
arg
,
func
,
for_self_aset
);
return
method_for_self
(
name
,
arg
,
func
,
for_self_aset
);
}
}
...
...
struct.c
浏览文件 @
ccb7a4b9
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
#include "internal/symbol.h"
#include "internal/symbol.h"
#include "transient_heap.h"
#include "transient_heap.h"
#include "vm_core.h"
#include "vm_core.h"
#include "builtin.h"
/* only for struct[:field] access */
/* only for struct[:field] access */
enum
{
enum
{
...
@@ -27,8 +28,8 @@ enum {
...
@@ -27,8 +28,8 @@ enum {
AREF_HASH_THRESHOLD
=
10
AREF_HASH_THRESHOLD
=
10
};
};
const
rb_iseq_t
*
rb_method_for_self_aref
(
VALUE
name
,
VALUE
arg
,
rb_insn_func_t
func
);
const
rb_iseq_t
*
rb_method_for_self_aref
(
VALUE
name
,
VALUE
arg
,
const
struct
rb_builtin_function
*
func
);
const
rb_iseq_t
*
rb_method_for_self_aset
(
VALUE
name
,
VALUE
arg
,
rb_insn_func_t
func
);
const
rb_iseq_t
*
rb_method_for_self_aset
(
VALUE
name
,
VALUE
arg
,
const
struct
rb_builtin_function
*
func
);
VALUE
rb_cStruct
;
VALUE
rb_cStruct
;
static
ID
id_members
,
id_back_members
,
id_keyword_init
;
static
ID
id_members
,
id_back_members
,
id_keyword_init
;
...
@@ -288,11 +289,41 @@ new_struct(VALUE name, VALUE super)
...
@@ -288,11 +289,41 @@ new_struct(VALUE name, VALUE super)
return
rb_define_class_id_under
(
super
,
id
,
super
);
return
rb_define_class_id_under
(
super
,
id
,
super
);
}
}
NORETURN
(
static
void
invalid_struct_pos
(
VALUE
s
,
VALUE
idx
));
static
inline
long
struct_pos_num
(
VALUE
s
,
VALUE
idx
)
{
long
i
=
NUM2INT
(
idx
);
if
(
i
<
0
||
i
>=
RSTRUCT_LEN
(
s
))
invalid_struct_pos
(
s
,
idx
);
return
i
;
}
static
VALUE
opt_struct_aref
(
rb_execution_context_t
*
ec
,
VALUE
self
,
VALUE
idx
)
{
long
i
=
struct_pos_num
(
self
,
idx
);
return
RSTRUCT_GET
(
self
,
i
);
}
static
VALUE
opt_struct_aset
(
rb_execution_context_t
*
ec
,
VALUE
self
,
VALUE
val
,
VALUE
idx
)
{
long
i
=
struct_pos_num
(
self
,
idx
);
rb_struct_modify
(
self
);
RSTRUCT_SET
(
self
,
i
,
val
);
return
val
;
}
static
const
struct
rb_builtin_function
struct_aref_builtin
=
RB_BUILTIN_FUNCTION
(
0
,
struct_aref
,
opt_struct_aref
,
1
);
static
const
struct
rb_builtin_function
struct_aset_builtin
=
RB_BUILTIN_FUNCTION
(
1
,
struct_aref
,
opt_struct_aset
,
2
);
static
void
static
void
define_aref_method
(
VALUE
nstr
,
VALUE
name
,
VALUE
off
)
define_aref_method
(
VALUE
nstr
,
VALUE
name
,
VALUE
off
)
{
{
rb_control_frame_t
*
FUNC_FASTCALL
(
rb_vm_opt_struct_aref
)(
rb_execution_context_t
*
,
rb_control_frame_t
*
);
const
rb_iseq_t
*
iseq
=
rb_method_for_self_aref
(
name
,
off
,
&
struct_aref_builtin
);
const
rb_iseq_t
*
iseq
=
rb_method_for_self_aref
(
name
,
off
,
rb_vm_opt_struct_aref
);
rb_add_method_iseq
(
nstr
,
SYM2ID
(
name
),
iseq
,
NULL
,
METHOD_VISI_PUBLIC
);
rb_add_method_iseq
(
nstr
,
SYM2ID
(
name
),
iseq
,
NULL
,
METHOD_VISI_PUBLIC
);
}
}
...
@@ -300,8 +331,7 @@ define_aref_method(VALUE nstr, VALUE name, VALUE off)
...
@@ -300,8 +331,7 @@ define_aref_method(VALUE nstr, VALUE name, VALUE off)
static
void
static
void
define_aset_method
(
VALUE
nstr
,
VALUE
name
,
VALUE
off
)
define_aset_method
(
VALUE
nstr
,
VALUE
name
,
VALUE
off
)
{
{
rb_control_frame_t
*
FUNC_FASTCALL
(
rb_vm_opt_struct_aset
)(
rb_execution_context_t
*
,
rb_control_frame_t
*
);
const
rb_iseq_t
*
iseq
=
rb_method_for_self_aset
(
name
,
off
,
&
struct_aset_builtin
);
const
rb_iseq_t
*
iseq
=
rb_method_for_self_aset
(
name
,
off
,
rb_vm_opt_struct_aset
);
rb_add_method_iseq
(
nstr
,
SYM2ID
(
name
),
iseq
,
NULL
,
METHOD_VISI_PUBLIC
);
rb_add_method_iseq
(
nstr
,
SYM2ID
(
name
),
iseq
,
NULL
,
METHOD_VISI_PUBLIC
);
}
}
...
@@ -1023,7 +1053,6 @@ rb_struct_pos(VALUE s, VALUE *name)
...
@@ -1023,7 +1053,6 @@ rb_struct_pos(VALUE s, VALUE *name)
}
}
}
}
NORETURN
(
static
void
invalid_struct_pos
(
VALUE
s
,
VALUE
idx
));
static
void
static
void
invalid_struct_pos
(
VALUE
s
,
VALUE
idx
)
invalid_struct_pos
(
VALUE
s
,
VALUE
idx
)
{
{
...
...
vm_insnhelper.c
浏览文件 @
ccb7a4b9
...
@@ -3621,20 +3621,6 @@ vm_once_clear(VALUE data)
...
@@ -3621,20 +3621,6 @@ vm_once_clear(VALUE data)
return
Qnil
;
return
Qnil
;
}
}
rb_control_frame_t
*
FUNC_FASTCALL
(
rb_vm_opt_struct_aref
)(
rb_execution_context_t
*
ec
,
rb_control_frame_t
*
reg_cfp
)
{
TOPN
(
0
)
=
rb_struct_aref
(
GET_SELF
(),
TOPN
(
0
));
return
reg_cfp
;
}
rb_control_frame_t
*
FUNC_FASTCALL
(
rb_vm_opt_struct_aset
)(
rb_execution_context_t
*
ec
,
rb_control_frame_t
*
reg_cfp
)
{
rb_struct_aset
(
GET_SELF
(),
TOPN
(
0
),
TOPN
(
1
));
return
reg_cfp
;
}
/* defined insn */
/* defined insn */
static
enum
defined_type
static
enum
defined_type
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录