aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-05-28 13:23:29 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-05-28 13:23:29 -0700
commit089bce8828859b4bd7321d205eead96997bc8b08 (patch)
treef3dada22295a055952c81c04c0e7343f20718abe
parentda210d75e886c39ae25b2c31b0823e4832f34832 (diff)
downloadbun-089bce8828859b4bd7321d205eead96997bc8b08.tar.gz
bun-089bce8828859b4bd7321d205eead96997bc8b08.tar.zst
bun-089bce8828859b4bd7321d205eead96997bc8b08.zip
launch.json
Former-commit-id: d44fa1ca928ff69d7073607d6ea0d8dd31511341
-rw-r--r--.vscode/launch.json105
-rw-r--r--Makefile57
-rw-r--r--src/allocators.zig119
-rw-r--r--src/cli.zig6
4 files changed, 260 insertions, 27 deletions
diff --git a/.vscode/launch.json b/.vscode/launch.json
index 7e0c19310..0f2ae0193 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -1,33 +1,44 @@
{
"version": "0.2.0",
"configurations": [
+ // {
+ // "type": "lldb",
+ // "request": "launch",
+ // "name": "Test",
+ // "program": "${workspaceFolder}/zig-out/bin/test",
+ // "preLaunchTask": "test",
+ // "args": ["/usr/local/bin/zig"],
+ // "cwd": "${workspaceFolder}",
+ // "console": "internalConsole"
+ // },
+ {
+ "name": "esbuild",
+ "type": "go",
+ "request": "launch",
+ "mode": "debug",
+ "program": "/Users/jarred/Code/esbuild/cmd/esbuild",
+ "cwd": "/Users/jarred/Code/esdev/src/test/fixtures",
+ "args": ["--bundle", "--outfile=out.esbuild.js", "await.ts"]
+ },
+
{
"type": "lldb",
"request": "launch",
- "name": "Test",
- "program": "${workspaceFolder}/zig-out/bin/test",
- "preLaunchTask": "test",
- "args": ["/usr/local/bin/zig"],
- "cwd": "${workspaceFolder}",
+ "name": "Dev Launch",
+ "program": "${workspaceFolder}/build/debug/macos-x86_64/esdev",
+ "args": ["./await"],
+ "cwd": "${workspaceFolder}/src/test/fixtures",
"console": "internalConsole"
},
// {
// "type": "lldb",
// "request": "launch",
- // "name": "Dev Launch",
+ // "name": "Dev Launch (other)",
// "program": "${workspaceFolder}/build/debug/macos-x86_64/esdev",
- // "preLaunchTask": "build",
- // "args": [
- // "--resolve=disable",
- // "--cwd",
- // "${workspaceFolder}",
- // "/Users/jarredsumner/Code/esdev/src/test/fixtures/exports-bug.js",
- // "-o",
- // "out"
- // ],
- // "cwd": "${workspaceFolder}",
+ // "args": ["./simple.jsx", "--resolve=disable"],
+ // "cwd": "${workspaceFolder}/src/test/fixtures",
// "console": "internalConsole"
- // }
+ // },
// {
// "type": "lldb",
// "request": "launch",
@@ -77,23 +88,67 @@
// "cwd": "${workspaceFolder}",
// "console": "internalConsole"
// }
+ // {
+ // "type": "lldb",
+ // "request": "launch",
+ // "name": "Dev Launch",
+ // "program": "${workspaceFolder}/build/debug/macos-x86_64/esdev",
+ // // "preLaunchTask": "build",
+ // "args": [
+ // "--resolve=dev",
+ // "--cwd",
+ // "./src/api/demo",
+ // "pages/index.jsx",
+ // "-o",
+ // "out",
+ // "--public-url=https://hello.com/",
+ // "--serve"
+ // ],
+ // "cwd": "${workspaceFolder}",
+ // "console": "internalConsole"
+ // }
{
"type": "lldb",
"request": "launch",
- "name": "Dev Launch",
+ "name": "Rome",
+ // "program": "${workspaceFolder}/build/debug/macos-x86_64/esdev",
+ "program": "${workspaceFolder}/build/macos-x86_64/esdev",
+ // "preLaunchTask": "build",
+ "args": [
+ "--resolve=dev",
+ // "--resolve=lazy",
+ "--cwd",
+ "${workspaceFolder}/bench/rome/src",
+ "entry",
+ "--platform=node",
+ // "@romejs/js-analysis/evaluators/modules/ImportCall.ts",
+ "--outdir=${workspaceFolder}/bench/rome/src/out",
+ // "@romejs/cli-diagnostics/banners/success.json",
+ "--public-url=https://hello.com/"
+ ],
+ "cwd": "${workspaceFolder}/bench/rome/src",
+ "console": "internalConsole"
+ },
+ {
+ "type": "lldb",
+ "request": "launch",
+ "name": "Rome Dev",
+ // "program": "${workspaceFolder}/build/debug/macos-x86_64/esdev",
"program": "${workspaceFolder}/build/debug/macos-x86_64/esdev",
// "preLaunchTask": "build",
"args": [
"--resolve=dev",
+ // "--resolve=lazy",
"--cwd",
- "./src/api/demo",
- "pages/index.jsx",
- "-o",
- "out",
- "--public-url=https://hello.com/",
- "--serve"
+ "${workspaceFolder}/bench/rome/src",
+ "entry",
+ "--platform=node",
+ // "@romejs/js-analysis/evaluators/modules/ImportCall.ts",
+ "--outdir=${workspaceFolder}/bench/rome/src/out",
+ // "@romejs/cli-diagnostics/banners/success.json",
+ "--public-url=https://hello.com/"
],
- "cwd": "${workspaceFolder}",
+ "cwd": "${workspaceFolder}/bench/rome/src",
"console": "internalConsole"
}
// {
diff --git a/Makefile b/Makefile
index 6df108be8..da1d853e4 100644
--- a/Makefile
+++ b/Makefile
@@ -32,3 +32,60 @@ speedy-dev-wasm:
speedy-dev-wasi:
zig build -Dtarget=wasm32-wasi
+
+
+ROME_TSCONFIG += {
+ROME_TSCONFIG += \"compilerOptions\": {
+ROME_TSCONFIG += \"sourceMap\": true,
+ROME_TSCONFIG += \"esModuleInterop\": true,
+ROME_TSCONFIG += \"resolveJsonModule\": true,
+ROME_TSCONFIG += \"moduleResolution\": \"node\",
+ROME_TSCONFIG += \"target\": \"es2019\",
+ROME_TSCONFIG += \"module\": \"commonjs\",
+ROME_TSCONFIG += \"baseUrl\": \".\"
+ROME_TSCONFIG += }
+ROME_TSCONFIG += }
+
+github/rome:
+ mkdir -p github/rome
+ cd github/rome && git init && git remote add origin https://github.com/romejs/rome.git
+ cd github/rome && git fetch --depth 1 origin d95a3a7aab90773c9b36d9c82a08c8c4c6b68aa5 && git checkout FETCH_HEAD
+
+# This target provides an easy way to verify that the build is correct. Since
+# Rome is self-hosted, we can just run the bundle to build Rome. This makes sure
+# the bundle doesn't crash when run and is a good test of a non-trivial workload.
+bench/rome-verify: | github/rome
+ mkdir -p bench/rome-verify
+ cp -r github/rome/packages bench/rome-verify/packages
+ cp github/rome/package.json bench/rome-verify/package.json
+
+bench/rome:
+ mkdir -p bench/rome
+ cp -r github/rome/packages bench/rome/src
+ echo "$(ROME_TSCONFIG)" > bench/rome/src/tsconfig.json
+ echo 'import "rome/bin/rome"' > bench/rome/src/entry.ts
+
+ # Patch a cyclic import ordering issue that affects commonjs-style bundlers (webpack and parcel)
+ echo "export { default as createHook } from './api/createHook';" > .temp
+ sed "/createHook/d" bench/rome/src/@romejs/js-compiler/index.ts >> .temp
+ mv .temp bench/rome/src/@romejs/js-compiler/index.ts
+
+ # Replace "import fs = require('fs')" with "const fs = require('fs')" because
+ # the TypeScript compiler strips these statements when targeting "esnext",
+ # which breaks Parcel 2 when scope hoisting is enabled.
+ find bench/rome/src -name '*.ts' -type f -print0 | xargs -L1 -0 sed -i '' 's/import \([A-Za-z0-9_]*\) =/const \1 =/g'
+ find bench/rome/src -name '*.tsx' -type f -print0 | xargs -L1 -0 sed -i '' 's/import \([A-Za-z0-9_]*\) =/const \1 =/g'
+
+ # Get an approximate line count
+ rm -r bench/rome/src/@romejs/js-parser/test-fixtures
+ echo 'Line count:' && (find bench/rome/src -name '*.ts' && find bench/rome/src -name '*.js') | xargs wc -l | tail -n 1
+
+
+bench-rome-speedy: | bench/rome-verify
+ cd bench/rome/src
+ /Users/jarred/Code/esdev/build/macos-x86_64/esdev --outdir=dist ./entry.ts
+
+github-rome:
+ mkdir -p github/rome
+ cd github/rome && git init && git remote add origin https://github.com/romejs/rome.git
+ cd github/rome && git fetch --depth 1 origin d95a3a7aab90773c9b36d9c82a08c8c4c6b68aa5 && git checkout FETCH_HEAD \ No newline at end of file
diff --git a/src/allocators.zig b/src/allocators.zig
index 541eb145d..8ebde9150 100644
--- a/src/allocators.zig
+++ b/src/allocators.zig
@@ -352,6 +352,125 @@ pub fn BSSStringList(comptime count: usize, comptime item_length: usize) type {
};
}
+pub fn TBSSStringList(comptime count: usize, comptime item_length: usize) type {
+ const max_index = count - 1;
+ const ValueType = []const u8;
+
+ return struct {
+ const Allocator = std.mem.Allocator;
+ const Self = @This();
+
+ pub threadlocal var slice_buf: [count][]const u8 = undefined;
+ pub threadlocal var slice_buf_used: u16 = 0;
+ pub threadlocal var backing_buf: [count * item_length]u8 = undefined;
+ pub threadlocal var backing_buf_used: u64 = undefined;
+ pub threadlocal var instance: Self = undefined;
+ pub const ListIndex = packed struct {
+ index: u31,
+ is_overflowing: bool = false,
+ };
+ overflow_list: std.ArrayListUnmanaged(ValueType),
+ allocator: *Allocator,
+
+ pub fn init(allocator: *std.mem.Allocator) *Self {
+ instance = Self{
+ .allocator = allocator,
+ .overflow_list = std.ArrayListUnmanaged(ValueType){},
+ };
+
+ return &instance;
+ }
+
+ pub fn isOverflowing() bool {
+ return slice_buf_used >= @as(u16, count);
+ }
+
+ pub fn at(self: *const Self, index: IndexType) ?ValueType {
+ if (index.index == NotFound.index or index.index == Unassigned.index) return null;
+
+ if (index.is_overflowing) {
+ return &self.overflow_list.items[index.index];
+ } else {
+ return &slice_buf[index.index];
+ }
+ }
+
+ pub fn exists(self: *Self, value: ValueType) bool {
+ return isSliceInBuffer(value, slice_buf);
+ }
+
+ pub fn editableSlice(slice: []const u8) []u8 {
+ return constStrToU8(slice);
+ }
+
+ pub fn append(self: *Self, _value: anytype) ![]const u8 {
+ var value = _value;
+ if (value.len + backing_buf_used < backing_buf.len - 1) {
+ const start = backing_buf_used;
+ backing_buf_used += value.len;
+ std.mem.copy(u8, backing_buf[start..backing_buf_used], _value);
+ value = backing_buf[start..backing_buf_used];
+ } else {
+ value = try self.allocator.dupe(u8, _value);
+ }
+
+ var result = ListIndex{ .index = std.math.maxInt(u31), .is_overflowing = slice_buf_used > max_index };
+
+ if (result.is_overflowing) {
+ result.index = @intCast(u31, self.overflow_list.items.len);
+ } else {
+ result.index = slice_buf_used;
+ slice_buf_used += 1;
+ if (slice_buf_used >= max_index) {
+ self.overflow_list = try @TypeOf(self.overflow_list).initCapacity(self.allocator, count);
+ }
+ }
+
+ if (result.is_overflowing) {
+ if (self.overflow_list.items.len == result.index) {
+ const real_index = self.overflow_list.items.len;
+ try self.overflow_list.append(self.allocator, value);
+ } else {
+ self.overflow_list.items[result.index] = value;
+ }
+
+ return self.overflow_list.items[result.index];
+ } else {
+ slice_buf[result.index] = value;
+
+ return slice_buf[result.index];
+ }
+ }
+
+ pub fn remove(self: *Self, index: ListIndex) void {
+ @compileError("Not implemented yet.");
+ // switch (index) {
+ // Unassigned.index => {
+ // self.index.remove(_key);
+ // },
+ // NotFound.index => {
+ // self.index.remove(_key);
+ // },
+ // 0...max_index => {
+ // if (hasDeinit(ValueType)) {
+ // slice_buf[index].deinit();
+ // }
+ // slice_buf[index] = undefined;
+ // },
+ // else => {
+ // const i = index - count;
+ // if (hasDeinit(ValueType)) {
+ // self.overflow_list.items[i].deinit();
+ // }
+ // self.overflow_list.items[index - count] = undefined;
+ // },
+ // }
+
+ // return index;
+ }
+ };
+}
+
pub fn BSSMap(comptime ValueType: type, comptime count: anytype, store_keys: bool, estimated_key_length: usize) type {
const max_index = count - 1;
const BSSMapType = struct {
diff --git a/src/cli.zig b/src/cli.zig
index 93d473e85..7668fddab 100644
--- a/src/cli.zig
+++ b/src/cli.zig
@@ -387,8 +387,10 @@ pub const Cli = struct {
}
}
- Output.println("Expr count: {d}", .{js_ast.Expr.icount});
- Output.println("Stmt count: {d}", .{js_ast.Stmt.icount});
+ if (isDebug) {
+ Output.println("Expr count: {d}", .{js_ast.Expr.icount});
+ Output.println("Stmt count: {d}", .{js_ast.Stmt.icount});
+ }
if (!did_write) {
for (result.output_files) |file, i| {