const mem = @import("std").mem; const builtin = @import("std").builtin; const std = @import("std"); const mimalloc = @import("./allocators/mimalloc.zig"); const FeatureFlags = @import("./feature_flags.zig"); const Environment = @import("./env.zig"); fn mimalloc_free( _: *anyopaque, buf: []u8, buf_align: u8, _: usize, ) void { // mi_free_size internally just asserts the size // so it's faster if we don't pass that value through // but its good to have that assertion if (comptime Environment.allow_assert) { assert(mimalloc.mi_is_in_heap_region(buf.ptr)); if (mimalloc.canUseAlignedAlloc(buf.len, buf_align)) mimalloc.mi_free_size_aligned(buf.ptr, buf.len, buf_align) else mimalloc.mi_free_size(buf.ptr, buf.len); } else { mimalloc.mi_free(buf.ptr); } } const c = struct { pub const malloc_size = mimalloc.mi_malloc_size; pub const malloc_usable_size = mimalloc.mi_malloc_usable_size; pub const malloc = struct { pub inline fn malloc_wrapped(size: usize) ?*anyopaque { if (comptime FeatureFlags.log_allocations) std.debug.print("Malloc: {d}\n", .{size}); return mimalloc.mi_malloc(size); } }.malloc_wrapped; pub inline fn free(ptr: anytype) void { if (comptime Environment.allow_assert) { assert(mimalloc.mi_is_in_heap_region(ptr)); } mimalloc.mi_free(ptr); } pub const posix_memalign = struct { pub inline fn mi_posix_memalign(p: [*c]?*anyopaque, alignment: usize, size: usize) c_int { if (comptime FeatureFlags.log_allocations) std.debug.print("Posix_memalign: {d}\n", .{std.mem.alignForward(size, alignment)}); return mimalloc.mi_posix_memalign(p, alignment, size); } }.mi_posix_memalign; }; const Allocator = mem.Allocator; const assert = std.debug.assert; const CAllocator = struct { const malloc_size = c.malloc_size; pub const supports_posix_memalign = true; fn alignedAlloc(len: usize, alignment: usize) ?[*]u8 { if (comptime FeatureFlags.log_allocations) std.debug.print("Malloc: {d}\n", .{len}); var ptr: ?*anyopaque = if (mimalloc.canUseAlignedAlloc(len, alignment)) mimalloc.mi_malloc_aligned(len, alignment) else mimalloc.mi_malloc(len); if (comptime Environment.allow_assert) { const usable = mimalloc.mi_malloc_usable_size(ptr); if (usable < len) { std.debug.panic("mimalloc: allocated size is too small: {d} < {d}", .{ usable, len }); } } return @as(?[*]u8, @ptrCast(ptr)); } fn alignedAllocSize(ptr: [*]u8) usize { return CAllocator.malloc_size(ptr); } fn alloc(_: *anyopaque, len: usize, log2_align: u8, _: usize) ?[*]u8 { if (comptime FeatureFlags.alignment_tweak) { return alignedAlloc(len, log2_align); } const alignment = @as(usize, 1) << @as(Allocator.Log2Align, @intCast(log2_align)); return alignedAlloc(len, alignment); } fn resize(_: *anyopaque, buf: []u8, _: u8, new_len: usize, _: usize) bool { if (new_len <= buf.len) { return true; } const full_len = alignedAllocSize(buf.ptr); if (new_len <= full_len) { return true; } return false; } const free = mimalloc_free; }; pub const c_allocator = Allocator{ .ptr = undefined, .vtable = &c_allocator_vtable, }; const c_allocator_vtable = Allocator.VTable{ .alloc = &CAllocator.alloc, .resize = &CAllocator.resize, .free = &CAllocator.free, }; const ZAllocator = struct { const malloc_size = c.malloc_size; pub const supports_posix_memalign = true; fn alignedAlloc(len: usize, alignment: usize) ?[*]u8 { if (comptime FeatureFlags.log_allocations) std.debug.print("Malloc: {d}\n", .{len}); var ptr = if (mimalloc.canUseAlignedAlloc(len, alignment)) mimalloc.mi_zalloc_aligned(len, alignment) else mimalloc.mi_zalloc(len); if (comptime Environment.allow_assert) { const usable = mimalloc.mi_malloc_usable_size(ptr); if (usable < len) { std.debug.panic("mimalloc: allocated size is too small: {d} < {d}", .{ usable, len }); } } return @as(?[*]u8, @ptrCast(ptr)); } fn alignedAllocSize(ptr: [*]u8) usize { return CAllocator.malloc_size(ptr); } fn alloc(_: *anyopaque, len: usize, ptr_align: u8, _: usize) ?[*]u8 { return alignedAlloc(len, ptr_align); } fn resize(_: *anyopaque, buf: []u8, _: u8, new_len: usize, _: usize) bool { if (new_len <= buf.len) { return true; } const full_len = alignedAllocSize(buf.ptr); if (new_len <= full_len) { return true; } return false; } const free = mimalloc_free; }; pub const z_allocator = Allocator{ .ptr = undefined, .vtable = &z_allocator_vtable, }; const z_allocator_vtable = Allocator.VTable{ .alloc = &ZAllocator.alloc, .resize = &ZAllocator.resize, .free = &ZAllocator.free, }; const HugeAllocator = struct { fn alloc( _: *anyopaque, len: usize, alignment: u29, len_align: u29, return_address: usize, ) error{OutOfMemory}![]u8 { _ = return_address; assert(len > 0); assert(std.math.isPowerOfTwo(alignment)); var slice = std.os.mmap( null, len, std.os.PROT.READ | std.os.PROT.WRITE, std.os.MAP.ANONYMOUS | std.os.MAP.PRIVATE, -1, 0, ) catch return error.OutOfMemory; _ = len_align; return slice; } fn resize( _: *anyopaque, _: []u8, _: u29, _: usize, _: u29, _: usize, ) ?usize { return null; } fn free( _: *anyopaque, buf: []u8, _: u29, _: usize, ) void { std.os.munmap(@alignCast(buf)); } }; pub const huge_allocator = Allocator{ .ptr = undefined, .vtable = &huge_allocator_vtable, }; const huge_allocator_vtable = Allocator.VTable{ .alloc = HugeAllocator.alloc, .resize = HugeAllocator.resize, .free = HugeAllocator.free, }; pub const huge_threshold = 1024 * 256; const AutoSizeAllocator = struct { fn alloc( _: *anyopaque, len: usize, alignment: u29, len_align: u29, return_address: usize, ) error{OutOfMemory}![]u8 { _ = len_align; if (len >= huge_threshold) { return huge_allocator.rawAlloc( len, alignment, return_address, ) orelse return error.OutOfMemory; } return c_allocator.rawAlloc( len, alignment, return_address, ) orelse return error.OutOfMemory; } fn resize( _: *anyopaque, _: []u8, _: u29, _: usize, _: u29, _: usize, ) ?usize { return null; } fn free( _: *anyopaque, buf: []u8, a: u29, b: usize, ) void { if (buf.len >= huge_threshold) { return huge_allocator.rawFree( buf, a, b, ); } return c_allocator.rawFree( buf, a, b, ); } }; pub const auto_allocator = Allocator{ .ptr = undefined, .vtable = &auto_allocator_vtable, }; const auto_allocator_vtable = Allocator.VTable{ .alloc = AutoSizeAllocator.alloc, .resize = AutoSizeAllocator.resize, .free = AutoSizeAllocator.free, }; eat/foreign-keys'>feat/foreign-keys Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/packages/astro/test/fixtures/astro-client-only/src (unfollow)
AgeCommit message (Collapse)AuthorFilesLines
2022-06-30Ci: improve times, reduce delay (#3780)Gravatar Fred K. Schott 1-14/+10
* improve CI times * improve CI times
2022-06-30await error reporter (#3779)Gravatar Fred K. Schott 2-10/+25
2022-06-30[ci] formatGravatar natemoo-re 14-99/+95
2022-06-30MDX support (#3706)Gravatar Nate Moore 63-57/+1153
* feat: first pass at MDX support * fix: move built-in JSX renderer to come first * chore: remove jsx example * chore: update lockfile * chore: cleanup example * fix: missing deps * refactor: move component render logic to `renderPage` * chore: update HMR script * chore: update MDX example * refactor: prefer unshit * refactor: remove TODO comment * fix: remove duplicate identifier * refactor: cleanup mdx entrypoint * fix: better html handling * fix: add tsconfig to mdx package * chore: update lockfile * fix: do not sort plugins unless mdx is enabled * chore: update compiler * fix(hmr): maybe render head for non-Astro pages * fix: set initial pageExtensions * refactor: cleanup addPageExtension * refactor: remove addPageExtensions from types * refactor: expose HookParameters type * fix: only default to astro for MDX * test: pick up jsx support in test fixtures * refactor: simplify mdx entrypoint * test: add basic MDX tests * test(e2e): add mdx + framework tests * chore: update lockfile * test(e2e): fix preact mdx e2e test * fix(mdx): disable .md support * test(e2e): fix vue-component test missing mdx * test(e2e): fix solid component needing import * fix: allow `client:only="solid"` as an alias to `solid-js` * chore: move to with-mdx example * chore: update MDX readme * chore: update example readme * chore: bump astro version * chore: update lockfile * Update mod.d.ts * feat: support `export const components` in MDX pages * chore: update mdx example * fix: update jsx-runtime with better slot support * refactor: remove object style support * chore: cleanup package exports * chore: add todo comment * refactor: improve isPage function, move to utils * refactor: dry up manual HMR updates * chore: add dev tests for MDX * chore: prefer set to array * chore: add changesets * fix(hmr): flip public/private route Co-authored-by: Nate Moore <nate@astro.build>
2022-06-30Fix integration name (`prefetch` instead of `lit`) (#3778)Gravatar hippotastic 2-1/+6
2022-06-30[ci] update lockfile (#3771)Gravatar Fred K. Bot 1-114/+112
Co-authored-by: FredKSchott <FredKSchott@users.noreply.github.com>
2022-06-30Integration Docs Next Steps (#3677)Gravatar Dan Jutan 11-314/+666
* sitemap readme skeleton + first sections * Revert "sitemap readme skeleton + first sections" This reverts commit cc55b312b6dc95522645002806d63f32c33d1956. * sitemap readme skeleton + first sections * remove canonicalURL option from sitemap * add customPages option to readme * sitemap examples * partytown * deno run command * reference deno example * node readme * netlify & vercel readmes * note that telemetry is installed * telemetry is *enabled*, not installed * Update packages/integrations/vercel/README.md Co-authored-by: Chris Swithinbank <swithinbank@gmail.com> * Update packages/integrations/vercel/README.md Co-authored-by: Chris Swithinbank <swithinbank@gmail.com> * readme -> README * Update packages/integrations/deno/readme.md Co-authored-by: Chris Swithinbank <swithinbank@gmail.com> * Update packages/integrations/deno/readme.md Co-authored-by: Chris Swithinbank <swithinbank@gmail.com> * qualify they * Update packages/integrations/sitemap/README.md Co-authored-by: Chris Swithinbank <swithinbank@gmail.com> * Uppercase README names * Update packages/integrations/partytown/README.md Co-authored-by: Chris Swithinbank <swithinbank@gmail.com> * imports -> import typo * update changeset Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
2022-06-30[ci] formatGravatar tony-sull 1-2/+2
2022-06-30refactor to provide better cli error handling (#3768)Gravatar Fred K. Schott 2-43/+37
2022-06-30[ci] release (#3772)@astrojs/preact@0.3.1Gravatar Fred K. Bot 12-22/+23
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-06-30Added Cloudflare adapter to README.md (#3773)Gravatar Isaac McFadyen 1-0/+1
2022-06-30[ci] formatGravatar hippotastic 1-5/+4
2022-06-30Fix "Invalid hook call" warning (#3769)Gravatar hippotastic 2-9/+79
* Fix "Invalid hook call" warning * Fix eslint warnings * Apply code review suggestions
2022-06-29[ci] release (#3759)astro@1.0.0-beta.59@astrojs/telemetry@0.2.2@astrojs/preact@0.3.0Gravatar Fred K. Bot 42-121/+117
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-06-29[ci] formatGravatar FredKSchott 8-35/+36
2022-06-29manual lockfile update (#3751)Gravatar Fred K. Schott 3-2659/+2871
* lockfile update * update lockfile gen script * Update index.ts
2022-06-29add error event to telemetry (#3750)Gravatar Fred K. Schott 16-85/+270