mirror of
https://github.com/fluencelabs/assemblyscript
synced 2025-06-23 03:31:44 +00:00
Rename memory instructions; Rework constant handling (#177)
* Rename memory instructions as proposed by the bulk-memory-operations spec. * Rename memory manager functions to memory.* as well * Remove automatic inlining of constant globals (Binaryen does this now) * Improve 'const' enum compatibility * Improve module-level export generation * Enable the inline decorator for constant variables * Add ERROR, WARNING and INFO macros that emit a user-defined diagnostic * Reintroduce builtin decorator so these can appear anywhere in stdlib again * Inline isNaN and isFinite by default * Make an interface around gc.* similar to memory.* * Emit an error when trying to inline a mutable variable * Slim down CI stages * Add a more convenient tracing utility for debugging * Implement some prequesites for an eventual bundled GC
This commit is contained in:
@ -176,10 +176,10 @@ function update_max_ptr(new_value: usize): i32 {
|
||||
// if (brk(new_value)) {
|
||||
// return 0;
|
||||
// }
|
||||
let oldPages = <u32>current_memory();
|
||||
let newPages = <u32>(((new_value + 0xffff) & ~0xffff) >> 16);
|
||||
let oldPages = <i32>memory.size();
|
||||
let newPages = <i32>(((new_value + 0xffff) & ~0xffff) >>> 16);
|
||||
assert(newPages > oldPages);
|
||||
if (grow_memory(newPages - oldPages) < 0) {
|
||||
if (memory.grow(newPages - oldPages) < 0) {
|
||||
return 0;
|
||||
}
|
||||
// max_ptr = new_value;
|
||||
@ -338,8 +338,9 @@ function lower_bucket_limit(bucket: usize): u32 {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@global
|
||||
export function allocate_memory(request: usize): usize {
|
||||
// Memory allocator interface
|
||||
|
||||
@global export function __memory_allocate(request: usize): usize {
|
||||
var original_bucket: usize, bucket: usize;
|
||||
|
||||
/*
|
||||
@ -357,7 +358,7 @@ export function allocate_memory(request: usize): usize {
|
||||
if (base_ptr == 0) {
|
||||
// base_ptr = max_ptr = (uint8_t *)sbrk(0);
|
||||
base_ptr = (NODE_IS_SPLIT_END + 7) & ~7; // must be aligned
|
||||
max_ptr = <usize>current_memory() << 16; // must grow first
|
||||
max_ptr = <usize>memory.size() << 16; // must grow first
|
||||
bucket_limit = BUCKET_COUNT - 1;
|
||||
if (!update_max_ptr(base_ptr + List.SIZE)) {
|
||||
return 0;
|
||||
@ -473,8 +474,7 @@ export function allocate_memory(request: usize): usize {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@global
|
||||
export function free_memory(ptr: usize): void {
|
||||
@global export function __memory_free(ptr: usize): void {
|
||||
var bucket: usize, i: usize;
|
||||
|
||||
/*
|
||||
@ -538,8 +538,3 @@ export function free_memory(ptr: usize): void {
|
||||
*/
|
||||
list_push(buckets$get(bucket), changetype<List>(ptr_for_node(i, bucket)));
|
||||
}
|
||||
|
||||
@global
|
||||
export function reset_memory(): void {
|
||||
unreachable();
|
||||
}
|
||||
|
Reference in New Issue
Block a user