File tree 1 file changed +4
-14
lines changed
1 file changed +4
-14
lines changed Original file line number Diff line number Diff line change @@ -4,25 +4,15 @@ use core::cell::UnsafeCell;
4
4
use units:: Pages ;
5
5
6
6
extern "C" {
7
- #[ link_name = "llvm.wasm.current.memory.i32" ]
8
- fn current_memory ( ) -> usize ;
9
-
10
- // TODO: this intrinsic actually returns the previous limit, but LLVM
11
- // doesn't expose that right now. When we upgrade LLVM stop using
12
- // `current_memory` above. Also handle `-1` as an allocation failure.
13
7
#[ link_name = "llvm.wasm.grow.memory.i32" ]
14
- fn grow_memory ( pages : usize ) ;
15
- }
16
-
17
- unsafe fn get_base_pointer ( ) -> * mut u8 {
18
- ( current_memory ( ) * PAGE_SIZE . 0 ) as _
8
+ fn grow_memory ( pages : usize ) -> i32 ;
19
9
}
20
10
21
11
pub ( crate ) unsafe fn alloc_pages ( n : Pages ) -> * mut u8 {
22
- let ptr = get_base_pointer ( ) ;
12
+ let ptr = grow_memory ( n. 0 ) ;
13
+ extra_assert ! ( ptr != -1 ) ;
14
+ let ptr = ( ptr as usize * PAGE_SIZE . 0 ) as _ ;
23
15
assert_is_word_aligned ( ptr) ;
24
- extra_assert ! ( !ptr. is_null( ) ) ;
25
- grow_memory ( n. 0 ) ;
26
16
ptr
27
17
}
28
18
You can’t perform that action at this time.
0 commit comments