Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsafe reasoning in ArrayArena #379

Merged
1 commit merged into from
Feb 2, 2021
Merged

Unsafe reasoning in ArrayArena #379

1 commit merged into from
Feb 2, 2021

Conversation

Medowhill
Copy link
Collaborator

@Medowhill Medowhill commented Jan 27, 2021

  • Arena의 unsafe reasoning을 위한 PR입니다.
  • 일단 ArrayPtrMruPtr이 가지고 있는 포인터를 *mut에서 NonNull로 바꾸었습니다.
  • 코드를 보다 보니 Arena 구현에 관련된 질문이 몇 가지 생겼는데 해당 위치에 comment로 달아 두겠습니다.

edited

ArrayArena의 unsafe reasoning을 위한 PR입니다.

  • ArrayPtrMruPtr이 가지고 있는 포인터를 *mut에서 NonNull로 바꾸었습니다.
  • 사용되지 않는 정의인 impl<A: Arena, T: Clone + Deref<Target = A>> Arena for T를 없애고 Arena 트레잇에 Rc를 반환하는 메서드를 추가했습니다.
  • ArrayPtr이 해당 핸들을 만든 ArrayArena가 살아 있는 동안만 살아 있도록 ArrayPtr에 lifetime parameter를 추가했습니다. 이에 따라 Rc에도 lifetime parameter가 추가되었습니다.

MruArena는 이 PR에서 다루지 않습니다.

Copy link
Member

@jeehoonkang jeehoonkang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

전반적으로 좋은 것 같습니다. 제가 이해 안되는 부분(...) 하나만 찍어서 review드립니다.

kernel-rs/src/arena.rs Show resolved Hide resolved
kernel-rs/src/arena.rs Show resolved Hide resolved
kernel-rs/src/arena.rs Show resolved Hide resolved
kernel-rs/src/arena.rs Outdated Show resolved Hide resolved
@Medowhill Medowhill changed the title [WIP] unsafe reasoning in arena Unsafe reasoning in ArrayArena Feb 1, 2021
@Medowhill Medowhill marked this pull request as ready for review February 1, 2021 15:25
@Medowhill Medowhill requested a review from jeehoonkang February 1, 2021 15:25
kernel-rs/src/arena.rs Outdated Show resolved Hide resolved
Copy link
Member

@jeehoonkang jeehoonkang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bors r+

unsafe { (*handle.ptr).refcnt += 1 };
Self::Handle {
// It is safe becuase of the invariant of ArrayPtr.
unsafe { (*handle.ptr.as_ptr()).refcnt += 1 };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아주 사소한건데 ... += 1; 이렇게 가는게 어떨까 합니다

@ghost
Copy link

ghost commented Feb 2, 2021

Build succeeded:

@ghost ghost merged commit 551a6b1 into kaist-cp:riscv Feb 2, 2021
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants