Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
37428927
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
37428927
编写于
10月 20, 2018
作者:
B
bjorn3
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use `read_local_of_frame` in `eval_place_to_op`
Also make `layout_of_local` accept any `Frame`
上级
7d406c91
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
23 addition
and
31 deletion
+23
-31
src/librustc_mir/interpret/eval_context.rs
src/librustc_mir/interpret/eval_context.rs
+4
-8
src/librustc_mir/interpret/operand.rs
src/librustc_mir/interpret/operand.rs
+14
-18
src/librustc_mir/interpret/place.rs
src/librustc_mir/interpret/place.rs
+3
-3
src/librustc_mir/interpret/terminator.rs
src/librustc_mir/interpret/terminator.rs
+2
-2
未找到文件。
src/librustc_mir/interpret/eval_context.rs
浏览文件 @
37428927
...
...
@@ -324,14 +324,11 @@ pub fn monomorphize<T: TypeFoldable<'tcx> + Subst<'tcx>>(
pub
fn
layout_of_local
(
&
self
,
frame
:
usize
,
frame
:
&
Frame
<
'mir
,
'tcx
,
M
::
PointerTag
>
,
local
:
mir
::
Local
)
->
EvalResult
<
'tcx
,
TyLayout
<
'tcx
>>
{
let
local_ty
=
self
.stack
[
frame
]
.mir.local_decls
[
local
]
.ty
;
let
local_ty
=
self
.monomorphize
(
local_ty
,
self
.stack
[
frame
]
.instance.substs
);
let
local_ty
=
frame
.mir.local_decls
[
local
]
.ty
;
let
local_ty
=
self
.monomorphize
(
local_ty
,
frame
.instance.substs
);
self
.layout_of
(
local_ty
)
}
...
...
@@ -579,7 +576,7 @@ pub fn storage_live(
assert
!
(
local
!=
mir
::
RETURN_PLACE
,
"Cannot make return place live"
);
trace!
(
"{:?} is now live"
,
local
);
let
layout
=
self
.layout_of_local
(
self
.
cur_
frame
(),
local
)
?
;
let
layout
=
self
.layout_of_local
(
self
.frame
(),
local
)
?
;
let
init
=
LocalValue
::
Live
(
self
.uninit_operand
(
layout
)
?
);
// StorageLive *always* kills the value that's currently stored
Ok
(
mem
::
replace
(
&
mut
self
.frame_mut
()
.locals
[
local
],
init
))
...
...
@@ -733,4 +730,3 @@ pub fn truncate(&self, value: u128, ty: TyLayout<'_>) -> u128 {
truncate
(
value
,
ty
.size
)
}
}
src/librustc_mir/interpret/operand.rs
浏览文件 @
37428927
...
...
@@ -571,6 +571,19 @@ pub fn operand_projection(
})
}
/// This is used by [priroda](https://github.com/oli-obk/priroda) to get an OpTy from a local
pub
fn
read_local_of_frame
(
&
self
,
frame
:
&
super
::
Frame
<
'mir
,
'tcx
,
M
::
PointerTag
>
,
local
:
mir
::
Local
,
layout
:
Option
<
TyLayout
<
'tcx
>>
,
)
->
EvalResult
<
'tcx
,
OpTy
<
'tcx
,
M
::
PointerTag
>>
{
let
op
=
*
frame
.locals
[
local
]
.access
()
?
;
let
layout
=
from_known_layout
(
layout
,
||
self
.layout_of_local
(
frame
,
local
))
?
;
Ok
(
OpTy
{
op
,
layout
})
}
// Evaluate a place with the goal of reading from it. This lets us sometimes
// avoid allocations. If you already know the layout, you can pass it in
// to avoid looking it up again.
...
...
@@ -582,12 +595,7 @@ fn eval_place_to_op(
use
rustc
::
mir
::
Place
::
*
;
let
op
=
match
*
mir_place
{
Local
(
mir
::
RETURN_PLACE
)
=>
return
err!
(
ReadFromReturnPointer
),
Local
(
local
)
=>
{
let
op
=
*
self
.frame
()
.locals
[
local
]
.access
()
?
;
let
layout
=
from_known_layout
(
layout
,
||
self
.layout_of_local
(
self
.cur_frame
(),
local
))
?
;
OpTy
{
op
,
layout
}
},
Local
(
local
)
=>
self
.read_local_of_frame
(
self
.frame
(),
local
,
layout
)
?
,
Projection
(
ref
proj
)
=>
{
let
op
=
self
.eval_place_to_op
(
&
proj
.base
,
None
)
?
;
...
...
@@ -772,16 +780,4 @@ pub fn read_discriminant(
})
}
/// This is used by [priroda](https://github.com/oli-obk/priroda) to get an OpTy from a local
pub
fn
read_local_of_frame
(
&
self
,
frame
:
&
super
::
Frame
<
'mir
,
'tcx
>
,
local
:
mir
::
Local
)
->
EvalResult
<
'tcx
,
OpTy
<
'tcx
>>
{
let
op
=
*
frame
.locals
[
local
]
.access
()
?
;
let
local_ty
=
frame
.mir.local_decls
[
local
]
.ty
;
let
local_ty
=
self
.monomorphize
(
local_ty
,
frame
.instance.substs
);
let
layout
=
self
.layout_of
(
local_ty
)
?
;
Ok
(
OpTy
{
op
,
layout
})
}
}
src/librustc_mir/interpret/place.rs
浏览文件 @
37428927
...
...
@@ -588,7 +588,7 @@ pub fn eval_place(
// their layout on return.
PlaceTy
{
place
:
*
return_place
,
layout
:
self
.layout_of_local
(
self
.
cur_
frame
(),
mir
::
RETURN_PLACE
)
?
,
layout
:
self
.layout_of_local
(
self
.frame
(),
mir
::
RETURN_PLACE
)
?
,
},
None
=>
return
err!
(
InvalidNullPointerUsage
),
},
...
...
@@ -597,7 +597,7 @@ pub fn eval_place(
frame
:
self
.cur_frame
(),
local
,
},
layout
:
self
.layout_of_local
(
self
.
cur_
frame
(),
local
)
?
,
layout
:
self
.layout_of_local
(
self
.frame
(),
local
)
?
,
},
Projection
(
ref
proj
)
=>
{
...
...
@@ -856,7 +856,7 @@ pub fn force_allocation(
// We need the layout of the local. We can NOT use the layout we got,
// that might e.g. be an inner field of a struct with `Scalar` layout,
// that has different alignment than the outer field.
let
local_layout
=
self
.layout_of_local
(
frame
,
local
)
?
;
let
local_layout
=
self
.layout_of_local
(
&
self
.stack
[
frame
]
,
local
)
?
;
let
ptr
=
self
.allocate
(
local_layout
,
MemoryKind
::
Stack
)
?
;
// We don't have to validate as we can assume the local
// was already valid for its type.
...
...
src/librustc_mir/interpret/terminator.rs
浏览文件 @
37428927
...
...
@@ -310,7 +310,7 @@ fn eval_fn_call(
mir
.spread_arg
,
mir
.args_iter
()
.map
(|
local
|
(
local
,
self
.layout_of_local
(
self
.
cur_
frame
(),
local
)
.unwrap
()
.ty
)
(
local
,
self
.layout_of_local
(
self
.frame
(),
local
)
.unwrap
()
.ty
)
)
.collect
::
<
Vec
<
_
>>
()
);
...
...
@@ -380,7 +380,7 @@ fn eval_fn_call(
}
}
else
{
let
callee_layout
=
self
.layout_of_local
(
self
.
cur_
frame
(),
mir
::
RETURN_PLACE
)
?
;
self
.layout_of_local
(
self
.frame
(),
mir
::
RETURN_PLACE
)
?
;
if
!
callee_layout
.abi
.is_uninhabited
()
{
return
err!
(
FunctionRetMismatch
(
self
.tcx.types.never
,
callee_layout
.ty
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录