Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
c8baac57
R
Rust
项目概览
int
/
Rust
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
c8baac57
编写于
7月 12, 2021
作者:
R
Ralf Jung
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove remaining use of Pointer in Allocation API
上级
3a24abd2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
11 addition
and
12 deletion
+11
-12
compiler/rustc_middle/src/mir/interpret/allocation.rs
compiler/rustc_middle/src/mir/interpret/allocation.rs
+9
-10
compiler/rustc_mir/src/interpret/memory.rs
compiler/rustc_mir/src/interpret/memory.rs
+2
-2
未找到文件。
compiler/rustc_middle/src/mir/interpret/allocation.rs
浏览文件 @
c8baac57
...
...
@@ -512,7 +512,7 @@ pub fn no_bytes_init(&self) -> bool {
/// Transferring the initialization mask to other allocations.
impl
<
Tag
,
Extra
>
Allocation
<
Tag
,
Extra
>
{
/// Creates a run-length encoding of the initialization mask.
pub
fn
compress_uninit_range
(
&
self
,
src
:
Pointer
<
Tag
>
,
size
:
Siz
e
)
->
InitMaskCompressed
{
pub
fn
compress_uninit_range
(
&
self
,
range
:
AllocRang
e
)
->
InitMaskCompressed
{
// Since we are copying `size` bytes from `src` to `dest + i * size` (`for i in 0..repeat`),
// a naive initialization mask copying algorithm would repeatedly have to read the initialization mask from
// the source and write it to the destination. Even if we optimized the memory accesses,
...
...
@@ -526,13 +526,13 @@ pub fn compress_uninit_range(&self, src: Pointer<Tag>, size: Size) -> InitMaskCo
// where each element toggles the state.
let
mut
ranges
=
smallvec
::
SmallVec
::
<
[
u64
;
1
]
>
::
new
();
let
initial
=
self
.init_mask
.get
(
src
.offse
t
);
let
initial
=
self
.init_mask
.get
(
range
.star
t
);
let
mut
cur_len
=
1
;
let
mut
cur
=
initial
;
for
i
in
1
..
size
.bytes
()
{
for
i
in
1
..
range
.
size
.bytes
()
{
// FIXME: optimize to bitshift the current uninitialized block's bits and read the top bit.
if
self
.init_mask
.get
(
src
.offse
t
+
Size
::
from_bytes
(
i
))
==
cur
{
if
self
.init_mask
.get
(
range
.star
t
+
Size
::
from_bytes
(
i
))
==
cur
{
cur_len
+=
1
;
}
else
{
ranges
.push
(
cur_len
);
...
...
@@ -550,24 +550,23 @@ pub fn compress_uninit_range(&self, src: Pointer<Tag>, size: Size) -> InitMaskCo
pub
fn
mark_compressed_init_range
(
&
mut
self
,
defined
:
&
InitMaskCompressed
,
dest
:
Pointer
<
Tag
>
,
size
:
Size
,
range
:
AllocRange
,
repeat
:
u64
,
)
{
// An optimization where we can just overwrite an entire range of initialization
// bits if they are going to be uniformly `1` or `0`.
if
defined
.ranges
.len
()
<=
1
{
self
.init_mask
.set_range_inbounds
(
dest
.offse
t
,
dest
.offset
+
size
*
repeat
,
// `Size` operations
range
.star
t
,
range
.start
+
range
.
size
*
repeat
,
// `Size` operations
defined
.initial
,
);
return
;
}
for
mut
j
in
0
..
repeat
{
j
*=
size
.bytes
();
j
+=
dest
.offse
t
.bytes
();
j
*=
range
.
size
.bytes
();
j
+=
range
.star
t
.bytes
();
let
mut
cur
=
defined
.initial
;
for
range
in
&
defined
.ranges
{
let
old_j
=
j
;
...
...
compiler/rustc_mir/src/interpret/memory.rs
浏览文件 @
c8baac57
...
...
@@ -1049,7 +1049,7 @@ pub fn copy_repeatedly(
num_copies
,
);
// Prepare a copy of the initialization mask.
let
compressed
=
src_alloc
.compress_uninit_range
(
src
,
size
);
let
compressed
=
src_alloc
.compress_uninit_range
(
alloc_range
(
src
.offset
,
size
)
);
// This checks relocation edges on the src.
let
src_bytes
=
src_alloc
.get_bytes_with_uninit_and_ptr
(
&
tcx
,
alloc_range
(
src
.offset
,
size
))
...
...
@@ -1110,7 +1110,7 @@ pub fn copy_repeatedly(
}
// now fill in all the "init" data
dest_alloc
.mark_compressed_init_range
(
&
compressed
,
dest
,
size
,
num_copies
);
dest_alloc
.mark_compressed_init_range
(
&
compressed
,
alloc_range
(
dest
.offset
,
size
)
,
num_copies
);
// copy the relocations to the destination
dest_alloc
.mark_relocation_range
(
relocations
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录