authorgravatar for benjamin.feng@glassdoor.comBenjamin Feng <benjamin.feng@glassdoor.com> 2019-12-05 19:31:49-06:00
committergravatar for benjamin.feng@glassdoor.comBenjamin Feng <benjamin.feng@glassdoor.com> 2019-12-05 19:31:49-06:00
logf2b0dbea748ecc927a9c2482dbb1dad8843cf9f8
treec458fc86bf6e34a52a9adf24993d583635c67bed
parent694616adb549fc0dc2d7416e120e17992087e75c

Resolve tests to work with or skip WasmPageAllocator


1 files changed, 6 insertions(+), 5 deletions(-)

lib/std/heap.zig+6-5
...@@ -794,8 +794,10 @@ test "PageAllocator" {...@@ -794,8 +794,10 @@ test "PageAllocator" {
794 const allocator = page_allocator;794 const allocator = page_allocator;
795 try testAllocator(allocator);795 try testAllocator(allocator);
796 try testAllocatorAligned(allocator, 16);796 try testAllocatorAligned(allocator, 16);
797 try testAllocatorLargeAlignment(allocator);797 if (!std.Target.current.isWasm()) {
798 try testAllocatorAlignedShrink(allocator);798 try testAllocatorLargeAlignment(allocator);
799 try testAllocatorAlignedShrink(allocator);
800 }
799801
800 if (builtin.os == .windows) {802 if (builtin.os == .windows) {
801 // Trying really large alignment. As mentionned in the implementation,803 // Trying really large alignment. As mentionned in the implementation,
...@@ -832,7 +834,7 @@ test "ArenaAllocator" {...@@ -832,7 +834,7 @@ test "ArenaAllocator" {
832 try testAllocatorAlignedShrink(&arena_allocator.allocator);834 try testAllocatorAlignedShrink(&arena_allocator.allocator);
833}835}
834836
835var test_fixed_buffer_allocator_memory: [80000 * @sizeOf(u64)]u8 = undefined;837var test_fixed_buffer_allocator_memory: [800000 * @sizeOf(u64)]u8 = undefined;
836test "FixedBufferAllocator" {838test "FixedBufferAllocator" {
837 var fixed_buffer_allocator = FixedBufferAllocator.init(test_fixed_buffer_allocator_memory[0..]);839 var fixed_buffer_allocator = FixedBufferAllocator.init(test_fixed_buffer_allocator_memory[0..]);
838840
...@@ -955,8 +957,7 @@ fn testAllocatorAligned(allocator: *mem.Allocator, comptime alignment: u29) !voi...@@ -955,8 +957,7 @@ fn testAllocatorAligned(allocator: *mem.Allocator, comptime alignment: u29) !voi
955fn testAllocatorLargeAlignment(allocator: *mem.Allocator) mem.Allocator.Error!void {957fn testAllocatorLargeAlignment(allocator: *mem.Allocator) mem.Allocator.Error!void {
956 //Maybe a platform's page_size is actually the same as or958 //Maybe a platform's page_size is actually the same as or
957 // very near usize?959 // very near usize?
958 //if (mem.page_size << 2 > maxInt(usize)) return;960 if (mem.page_size << 2 > maxInt(usize)) return;
959 if (mem.page_size << 2 > 32768) return;
960961
961 const USizeShift = @IntType(false, std.math.log2(usize.bit_count));962 const USizeShift = @IntType(false, std.math.log2(usize.bit_count));
962 const large_align = @as(u29, mem.page_size << 2);963 const large_align = @as(u29, mem.page_size << 2);