mirror of
https://github.com/oven-sh/bun
synced 2026-03-02 05:21:05 +01:00
Compare commits
2 Commits
jarred/lea
...
jarred/crc
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a83a6702c0 | ||
|
|
768a36a706 |
@@ -1,30 +0,0 @@
|
||||
# Uploads the latest CI workflow to Buildkite.
|
||||
# https://buildkite.com/docs/pipelines/defining-steps
|
||||
#
|
||||
# Changes to this file must be manually edited here:
|
||||
# https://buildkite.com/bun/bun/settings/steps
|
||||
steps:
|
||||
- if: "build.pull_request.repository.fork"
|
||||
block: ":eyes:"
|
||||
prompt: "Did you review the PR?"
|
||||
blocked_state: "running"
|
||||
|
||||
- label: ":pipeline:"
|
||||
command: "buildkite-agent pipeline upload .buildkite/ci.yml"
|
||||
agents:
|
||||
queue: "build-linux"
|
||||
|
||||
- if: "build.branch == 'main' && !build.pull_request.repository.fork"
|
||||
label: ":github:"
|
||||
agents:
|
||||
queue: "test-darwin"
|
||||
depends_on:
|
||||
- "darwin-aarch64-build-bun"
|
||||
- "darwin-x64-build-bun"
|
||||
- "linux-aarch64-build-bun"
|
||||
- "linux-x64-build-bun"
|
||||
- "linux-x64-baseline-build-bun"
|
||||
- "windows-x64-build-bun"
|
||||
- "windows-x64-baseline-build-bun"
|
||||
command:
|
||||
- ".buildkite/scripts/upload-release.sh"
|
||||
@@ -1,63 +0,0 @@
|
||||
## CI
|
||||
|
||||
How does CI work?
|
||||
|
||||
### Building
|
||||
|
||||
Bun is built on macOS, Linux, and Windows. The process is split into the following steps, the first 3 of which are able to run in parallel:
|
||||
|
||||
#### 1. `build-deps`
|
||||
|
||||
Builds the static libaries in `src/deps` and outputs a directory: `build/bun-deps`.
|
||||
|
||||
- on Windows, this runs the script: [`scripts/all-dependencies.ps1`](scripts/all-dependencies.ps1)
|
||||
- on macOS and Linux, this runs the script: [`scripts/all-dependencies.sh`](scripts/all-dependencies.sh)
|
||||
|
||||
#### 2. `build-zig`
|
||||
|
||||
Builds the Zig object file: `build/bun-zig.o`. Since `zig build` supports cross-compiling, this step is run on macOS aarch64 since we have observed it to be the fastest.
|
||||
|
||||
- on macOS and Linux, this runs the script: [`scripts/build-bun-zig.sh`](scripts/build-bun-zig.sh)
|
||||
|
||||
#### 3. `build-cpp`
|
||||
|
||||
Builds the C++ object file: `build/bun-cpp-objects.a`.
|
||||
|
||||
- on Windows, this runs the script: [`scripts/build-bun-cpp.ps1`](scripts/build-bun-cpp.ps1)
|
||||
- on macOS and Linux, this runs the script: [`scripts/build-bun-cpp.sh`](scripts/build-bun-cpp.sh)
|
||||
|
||||
#### 4. `link` / `build-bun`
|
||||
|
||||
After the `build-deps`, `build-zig`, and `build-cpp` steps have completed, this step links the Zig object file and C++ object file into a single binary: `bun-<os>-<arch>.zip`.
|
||||
|
||||
- on Windows, this runs the script: [`scripts/buildkite-link-bun.ps1`](scripts/buildkite-link-bun.ps1)
|
||||
- on macOS and Linux, this runs the script: [`scripts/buildkite-link-bun.sh`](scripts/buildkite-link-bun.sh)
|
||||
|
||||
To speed up the build, thare are two options:
|
||||
|
||||
- `--fast`: This disables the LTO (link-time optimization) step.
|
||||
- without `--fast`: This runs the LTO step, which is the default. The binaries that are release to Github are always built with LTO.
|
||||
|
||||
### Testing
|
||||
|
||||
### FAQ
|
||||
|
||||
> How do I add a new CI agent?
|
||||
|
||||
> How do I add/modify system dependencies?
|
||||
|
||||
> How do I SSH into a CI agent?
|
||||
|
||||
### Known issues
|
||||
|
||||
These are things that we know about, but haven't fixed or optimized yet.
|
||||
|
||||
- There is no `scripts/build-bun-zig.ps1` for Windows.
|
||||
|
||||
- The `build-deps` step does not cache in CI, so it re-builds each time (though it does use ccache). It attempts to check the `BUN_DEPS_CACHE_DIR` environment variable, but for some reason it doesn't work.
|
||||
|
||||
- Windows and Linux machines sometimes take up to 1-2 minutes to start tests. This is because robobun is listening for when the job is scheduled to provision the VM. Instead, it can start provisioning during the link step, or keep a pool of idle VMs around (but it's unclear how more expensive this is).
|
||||
|
||||
- There are a limited number of macOS VMs. This is because they are expensive and manually provisioned, mostly through MacStadium. If wait times are too long we can just provision more, or buy some.
|
||||
|
||||
- To prevent idle machines, robobun periodically checks for idle machines and terminates them. Before doing this, it checks to see if the machine is connected as an agent to Buildkite. However, sometimes the machine picks up a job in-between this time, and the job is terminated.
|
||||
1523
.buildkite/ci.yml
1523
.buildkite/ci.yml
File diff suppressed because it is too large
Load Diff
@@ -1,94 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
function assert_main() {
|
||||
if [[ "$BUILDKITE_PULL_REQUEST_REPO" && "$BUILDKITE_REPO" != "$BUILDKITE_PULL_REQUEST_REPO" ]]; then
|
||||
echo "error: Cannot upload release from a fork"
|
||||
exit 1
|
||||
fi
|
||||
if [ "$BUILDKITE_PULL_REQUEST" != "false" ]; then
|
||||
echo "error: Cannot upload release from a pull request"
|
||||
exit 1
|
||||
fi
|
||||
if [ "$BUILDKITE_BRANCH" != "main" ]; then
|
||||
echo "error: Cannot upload release from a branch other than main"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function assert_buildkite_agent() {
|
||||
if ! command -v buildkite-agent &> /dev/null; then
|
||||
echo "error: Cannot find buildkite-agent, please install it:"
|
||||
echo "https://buildkite.com/docs/agent/v3/install"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function assert_gh() {
|
||||
if ! command -v gh &> /dev/null; then
|
||||
echo "warning: gh is not installed, installing..."
|
||||
if command -v brew &> /dev/null; then
|
||||
brew install gh
|
||||
else
|
||||
echo "error: Cannot install gh, please install it:"
|
||||
echo "https://github.com/cli/cli#installation"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function assert_gh_token() {
|
||||
local token=$(buildkite-agent secret get GITHUB_TOKEN)
|
||||
if [ -z "$token" ]; then
|
||||
echo "error: Cannot find GITHUB_TOKEN secret"
|
||||
echo ""
|
||||
echo "hint: Create a secret named GITHUB_TOKEN with a GitHub access token:"
|
||||
echo "https://buildkite.com/docs/pipelines/buildkite-secrets"
|
||||
exit 1
|
||||
fi
|
||||
export GH_TOKEN="$token"
|
||||
}
|
||||
|
||||
function download_artifact() {
|
||||
local name=$1
|
||||
buildkite-agent artifact download "$name" .
|
||||
if [ ! -f "$name" ]; then
|
||||
echo "error: Cannot find Buildkite artifact: $name"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
function upload_assets() {
|
||||
local tag=$1
|
||||
local files=${@:2}
|
||||
gh release upload "$tag" $files --clobber --repo "$BUILDKITE_REPO"
|
||||
}
|
||||
|
||||
assert_main
|
||||
assert_buildkite_agent
|
||||
assert_gh
|
||||
assert_gh_token
|
||||
|
||||
declare artifacts=(
|
||||
bun-darwin-aarch64.zip
|
||||
bun-darwin-aarch64-profile.zip
|
||||
bun-darwin-x64.zip
|
||||
bun-darwin-x64-profile.zip
|
||||
bun-linux-aarch64.zip
|
||||
bun-linux-aarch64-profile.zip
|
||||
bun-linux-x64.zip
|
||||
bun-linux-x64-profile.zip
|
||||
bun-linux-x64-baseline.zip
|
||||
bun-linux-x64-baseline-profile.zip
|
||||
bun-windows-x64.zip
|
||||
bun-windows-x64-profile.zip
|
||||
bun-windows-x64-baseline.zip
|
||||
bun-windows-x64-baseline-profile.zip
|
||||
)
|
||||
|
||||
for artifact in "${artifacts[@]}"; do
|
||||
download_artifact $artifact
|
||||
done
|
||||
|
||||
upload_assets "canary" "${artifacts[@]}"
|
||||
21
.github/workflows/build-windows.yml
vendored
21
.github/workflows/build-windows.yml
vendored
@@ -36,7 +36,6 @@ env:
|
||||
BUN_GARBAGE_COLLECTOR_LEVEL: 1
|
||||
BUN_FEATURE_FLAG_INTERNAL_FOR_TESTING: 1
|
||||
CI: true
|
||||
USE_LTO: 1
|
||||
|
||||
jobs:
|
||||
build-submodules:
|
||||
@@ -74,11 +73,15 @@ jobs:
|
||||
with:
|
||||
path: bun-deps
|
||||
key: bun-${{ inputs.tag }}-deps-${{ steps.hash.outputs.hash }}
|
||||
- if: ${{ inputs.no-cache || !steps.cache.outputs.cache-hit }}
|
||||
name: Install LLVM
|
||||
uses: KyleMayes/install-llvm-action@8b37482c5a2997a3ab5dbf6561f8109e2eaa7d3b
|
||||
with:
|
||||
version: ${{ env.LLVM_VERSION }}
|
||||
- if: ${{ inputs.no-cache || !steps.cache.outputs.cache-hit }}
|
||||
name: Install Ninja
|
||||
run: |
|
||||
choco install -y ninja
|
||||
choco install -y llvm --version=${{ env.LLVM_VERSION }} --force
|
||||
- if: ${{ inputs.no-cache || !steps.cache.outputs.cache-hit }}
|
||||
name: Clone Submodules
|
||||
run: |
|
||||
@@ -88,7 +91,6 @@ jobs:
|
||||
env:
|
||||
CPU_TARGET: ${{ inputs.cpu }}
|
||||
CCACHE_DIR: ccache
|
||||
USE_LTO: 1
|
||||
run: |
|
||||
.\scripts\env.ps1 ${{ contains(inputs.tag, '-baseline') && '-Baseline' || '' }}
|
||||
choco install -y nasm --version=2.16.01
|
||||
@@ -149,10 +151,13 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Install LLVM
|
||||
uses: KyleMayes/install-llvm-action@8b37482c5a2997a3ab5dbf6561f8109e2eaa7d3b
|
||||
with:
|
||||
version: ${{ env.LLVM_VERSION }}
|
||||
- name: Install Ninja
|
||||
run: |
|
||||
choco install -y ninja
|
||||
choco install -y llvm --version=${{ env.LLVM_VERSION }} --force
|
||||
- name: Setup Bun
|
||||
uses: ./.github/actions/setup-bun
|
||||
with:
|
||||
@@ -174,7 +179,6 @@ jobs:
|
||||
env:
|
||||
CPU_TARGET: ${{ inputs.cpu }}
|
||||
CCACHE_DIR: ccache
|
||||
USE_LTO: 1
|
||||
run: |
|
||||
# $CANARY_REVISION = if (Test-Path build/.canary_revision) { Get-Content build/.canary_revision } else { "0" }
|
||||
$CANARY_REVISION = 0
|
||||
@@ -184,7 +188,6 @@ jobs:
|
||||
cd build
|
||||
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release `
|
||||
-DNO_CODEGEN=1 `
|
||||
-DUSE_LTO=1 `
|
||||
-DNO_CONFIGURE_DEPENDS=1 `
|
||||
"-DCANARY=${CANARY_REVISION}" `
|
||||
-DBUN_CPP_ONLY=1 ${{ contains(inputs.tag, '-baseline') && '-DUSE_BASELINE_BUILD=1' || '' }}
|
||||
@@ -229,10 +232,13 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
submodules: recursive
|
||||
- name: Install LLVM
|
||||
uses: KyleMayes/install-llvm-action@8b37482c5a2997a3ab5dbf6561f8109e2eaa7d3b
|
||||
with:
|
||||
version: ${{ env.LLVM_VERSION }}
|
||||
- name: Install Ninja
|
||||
run: |
|
||||
choco install -y ninja
|
||||
choco install -y llvm --version=${{ env.LLVM_VERSION }} --force
|
||||
- name: Setup Bun
|
||||
uses: ./.github/actions/setup-bun
|
||||
with:
|
||||
@@ -280,7 +286,6 @@ jobs:
|
||||
-DNO_CONFIGURE_DEPENDS=1 `
|
||||
"-DCANARY=${CANARY_REVISION}" `
|
||||
-DBUN_LINK_ONLY=1 `
|
||||
-DUSE_LTO=1 `
|
||||
"-DBUN_DEPS_OUT_DIR=$(Resolve-Path ../bun-deps)" `
|
||||
"-DBUN_CPP_ARCHIVE=$(Resolve-Path ../bun-cpp/bun-cpp-objects.a)" `
|
||||
"-DBUN_ZIG_OBJ_DIR=$(Resolve-Path ../bun-zig)" `
|
||||
|
||||
9
.github/workflows/lint-cpp.yml
vendored
9
.github/workflows/lint-cpp.yml
vendored
@@ -14,11 +14,10 @@ on:
|
||||
type: string
|
||||
description: The workflow ID to download artifacts (skips the build step)
|
||||
pull_request:
|
||||
paths:
|
||||
- ".github/workflows/lint-cpp.yml"
|
||||
- "**/*.cpp"
|
||||
- "src/deps/**/*"
|
||||
- "CMakeLists.txt"
|
||||
paths-ignore:
|
||||
- .vscode/**/*
|
||||
- docs/**/*
|
||||
- examples/**/*
|
||||
|
||||
jobs:
|
||||
lint-cpp:
|
||||
|
||||
89
.github/workflows/on-submodule-update.yml
vendored
89
.github/workflows/on-submodule-update.yml
vendored
@@ -1,89 +0,0 @@
|
||||
name: Comment on updated submodule
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
paths:
|
||||
- "src/generated_versions_list.zig"
|
||||
- ".github/workflows/on-submodule-update.yml"
|
||||
|
||||
jobs:
|
||||
comment:
|
||||
name: Comment
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.repository_owner == 'oven-sh' }}
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: write
|
||||
issues: write
|
||||
steps:
|
||||
- name: Checkout current
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
sparse-checkout: |
|
||||
src
|
||||
- name: Hash generated versions list
|
||||
id: hash
|
||||
run: |
|
||||
echo "hash=$(sha256sum src/generated_versions_list.zig | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
|
||||
- name: Checkout base
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.base_ref }}
|
||||
sparse-checkout: |
|
||||
src
|
||||
- name: Hash base
|
||||
id: base
|
||||
run: |
|
||||
echo "base=$(sha256sum src/generated_versions_list.zig | cut -d ' ' -f 1)" >> $GITHUB_OUTPUT
|
||||
- name: Compare
|
||||
id: compare
|
||||
run: |
|
||||
if [ "${{ steps.hash.outputs.hash }}" != "${{ steps.base.outputs.base }}" ]; then
|
||||
echo "changed=true" >> $GITHUB_OUTPUT
|
||||
else
|
||||
echo "changed=false" >> $GITHUB_OUTPUT
|
||||
fi
|
||||
- name: Find Comment
|
||||
id: comment
|
||||
uses: peter-evans/find-comment@v3
|
||||
with:
|
||||
issue-number: ${{ github.event.pull_request.number }}
|
||||
comment-author: github-actions[bot]
|
||||
body-includes: <!-- generated-comment submodule-updated -->
|
||||
- name: Write Warning Comment
|
||||
uses: peter-evans/create-or-update-comment@v4
|
||||
if: steps.compare.outputs.changed == 'true'
|
||||
with:
|
||||
comment-id: ${{ steps.comment.outputs.comment-id }}
|
||||
issue-number: ${{ github.event.pull_request.number }}
|
||||
edit-mode: replace
|
||||
body: |
|
||||
⚠️ **Warning:** @${{ github.actor }}, this PR has changes to submodule versions.
|
||||
|
||||
If this change was intentional, please ignore this message. If not, please undo changes to submodules and rebase your branch.
|
||||
|
||||
<!-- generated-comment submodule-updated -->
|
||||
- name: Add labels
|
||||
uses: actions-cool/issues-helper@v3
|
||||
if: steps.compare.outputs.changed == 'true'
|
||||
with:
|
||||
actions: "add-labels"
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
issue-number: ${{ github.event.pull_request.number }}
|
||||
labels: "changed-submodules"
|
||||
- name: Remove labels
|
||||
uses: actions-cool/issues-helper@v3
|
||||
if: steps.compare.outputs.changed == 'false'
|
||||
with:
|
||||
actions: "remove-labels"
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
issue-number: ${{ github.event.pull_request.number }}
|
||||
labels: "changed-submodules"
|
||||
- name: Delete outdated comment
|
||||
uses: actions-cool/issues-helper@v3
|
||||
if: steps.compare.outputs.changed == 'false' && steps.comment.outputs.comment-id != ''
|
||||
with:
|
||||
actions: "delete-comment"
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
issue-number: ${{ github.event.pull_request.number }}
|
||||
comment-id: ${{ steps.comment.outputs.comment-id }}
|
||||
8
.vscode/launch.json
generated
vendored
8
.vscode/launch.json
generated
vendored
@@ -445,8 +445,8 @@
|
||||
"request": "launch",
|
||||
"name": "bun test [*] (ci)",
|
||||
"program": "node",
|
||||
"args": ["test/runner.node.mjs"],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"args": ["src/runner.node.mjs"],
|
||||
"cwd": "${workspaceFolder}/packages/bun-internal-test",
|
||||
"console": "internalConsole",
|
||||
},
|
||||
// Windows: bun test [file]
|
||||
@@ -1093,8 +1093,8 @@
|
||||
"request": "launch",
|
||||
"name": "Windows: bun test [*] (ci)",
|
||||
"program": "node",
|
||||
"args": ["test/runner.node.mjs"],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"args": ["src/runner.node.mjs"],
|
||||
"cwd": "${workspaceFolder}/packages/bun-internal-test",
|
||||
"console": "internalConsole",
|
||||
},
|
||||
],
|
||||
|
||||
@@ -2,9 +2,8 @@ cmake_minimum_required(VERSION 3.22)
|
||||
cmake_policy(SET CMP0091 NEW)
|
||||
cmake_policy(SET CMP0067 NEW)
|
||||
|
||||
set(CMAKE_POLICY_DEFAULT_CMP0069 NEW)
|
||||
set(Bun_VERSION "1.1.18")
|
||||
set(WEBKIT_TAG 615e8585f96aa718b0f5158210259b83fe8440ea)
|
||||
set(Bun_VERSION "1.1.17")
|
||||
set(WEBKIT_TAG 5bbfe7e880090b9d0b5feaf3563e85957dd7b10d)
|
||||
|
||||
set(BUN_WORKDIR "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
message(STATUS "Configuring Bun ${Bun_VERSION} in ${BUN_WORKDIR}")
|
||||
@@ -322,11 +321,6 @@ option(USE_STATIC_LIBATOMIC "Statically link libatomic, requires the presence of
|
||||
|
||||
option(USE_LTO "Enable Link-Time Optimization" ${DEFAULT_LTO})
|
||||
|
||||
if(WIN32 AND USE_LTO)
|
||||
set(CMAKE_LINKER_TYPE LLD)
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF)
|
||||
endif()
|
||||
|
||||
option(BUN_TIDY_ONLY "Only run clang-tidy" OFF)
|
||||
option(BUN_TIDY_ONLY_EXTRA " Only run clang-tidy, with extra checks for local development" OFF)
|
||||
|
||||
@@ -620,7 +614,7 @@ set(BUN_DEPS_DIR "${BUN_SRC}/deps")
|
||||
set(BUN_CODEGEN_SRC "${BUN_SRC}/codegen")
|
||||
|
||||
if(NOT BUN_DEPS_OUT_DIR)
|
||||
set(BUN_DEPS_OUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/build/bun-deps")
|
||||
set(BUN_DEPS_OUT_DIR "${BUN_DEPS_DIR}")
|
||||
endif()
|
||||
|
||||
set(BUN_RAW_SOURCES, "")
|
||||
@@ -1083,8 +1077,6 @@ elseif(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
set(LTO_LINK_FLAG "")
|
||||
|
||||
if(USE_LTO)
|
||||
target_compile_options(${bun} PUBLIC -Xclang -emit-llvm-bc)
|
||||
|
||||
# -emit-llvm seems to not be supported or under a different name on Windows.
|
||||
list(APPEND LTO_FLAG "-flto=full")
|
||||
list(APPEND LTO_LINK_FLAG "/LTCG")
|
||||
@@ -1126,7 +1118,7 @@ if(WIN32)
|
||||
set_property(TARGET ${bun} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
|
||||
|
||||
target_compile_options(${bun} PUBLIC "/EHsc" "/GR-")
|
||||
target_link_options(${bun} PUBLIC "/STACK:0x1200000,0x100000" "/DEF:${BUN_SRC}/symbols.def" "/errorlimit:0")
|
||||
target_link_options(${bun} PUBLIC "/STACK:0x1200000,0x100000" "/DEF:${BUN_SRC}/symbols.def")
|
||||
else()
|
||||
target_compile_options(${bun} PUBLIC
|
||||
-fPIC
|
||||
|
||||
2
Makefile
2
Makefile
@@ -129,7 +129,7 @@ SED = $(shell which gsed 2>/dev/null || which sed 2>/dev/null)
|
||||
|
||||
BUN_DIR ?= $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
|
||||
BUN_DEPS_DIR ?= $(shell pwd)/src/deps
|
||||
BUN_DEPS_OUT_DIR ?= $(shell pwd)/build/bun-deps
|
||||
BUN_DEPS_OUT_DIR ?= $(BUN_DEPS_DIR)
|
||||
CPU_COUNT = 2
|
||||
ifeq ($(OS_NAME),darwin)
|
||||
CPU_COUNT = $(shell sysctl -n hw.logicalcpu)
|
||||
|
||||
BIN
bench/bun.lockb
BIN
bench/bun.lockb
Binary file not shown.
@@ -3,7 +3,6 @@
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.16.10",
|
||||
"@babel/preset-react": "^7.16.7",
|
||||
"@babel/standalone": "^7.24.7",
|
||||
"@swc/core": "^1.2.133",
|
||||
"benchmark": "^2.1.4",
|
||||
"braces": "^3.0.2",
|
||||
|
||||
26
bench/snippets/bun-hash.mjs
Normal file
26
bench/snippets/bun-hash.mjs
Normal file
@@ -0,0 +1,26 @@
|
||||
import { bench, group, run } from "./runner.mjs";
|
||||
|
||||
const hashes = ["wyhash", "adler32", "crc32", "cityHash32", "cityHash64", "murmur32v3", "murmur32v2", "murmur64v2"];
|
||||
|
||||
group("hello world", () => {
|
||||
for (const name of hashes) {
|
||||
const fn = Bun.hash[name];
|
||||
|
||||
bench(`${name}`, () => {
|
||||
return fn("hello world");
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
group("hello world (x 1024)", () => {
|
||||
for (const name of hashes) {
|
||||
const fn = Bun.hash[name];
|
||||
|
||||
const repeated = Buffer.alloc("hello world".length * 1024, "hello world").toString();
|
||||
bench(`${name}`, () => {
|
||||
return fn(repeated);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
await run();
|
||||
@@ -1,14 +0,0 @@
|
||||
import { bench, run } from "mitata";
|
||||
import { join } from "path";
|
||||
|
||||
const code = require("fs").readFileSync(
|
||||
process.argv[2] || join(import.meta.dir, "../node_modules/@babel/standalone/babel.min.js"),
|
||||
);
|
||||
|
||||
const transpiler = new Bun.Transpiler({ minify: true });
|
||||
|
||||
bench("transformSync", () => {
|
||||
transpiler.transformSync(code);
|
||||
});
|
||||
|
||||
await run();
|
||||
36
build.zig
36
build.zig
@@ -123,7 +123,7 @@ pub fn getOSGlibCVersion(os: OperatingSystem) ?Version {
|
||||
}
|
||||
|
||||
pub fn build(b: *Build) !void {
|
||||
std.log.info("zig compiler v{s}", .{builtin.zig_version_string});
|
||||
std.debug.print("zig build v{s}\n", .{builtin.zig_version_string});
|
||||
|
||||
b.zig_lib_dir = b.zig_lib_dir orelse b.path("src/deps/zig/lib");
|
||||
|
||||
@@ -288,40 +288,6 @@ pub fn build(b: *Build) !void {
|
||||
}
|
||||
}
|
||||
|
||||
// zig build check-windows
|
||||
{
|
||||
var step = b.step("check-windows", "Check for semantic analysis errors on Windows x64");
|
||||
inline for (.{
|
||||
.{ .os = .windows, .arch = .x86_64 },
|
||||
}) |check| {
|
||||
inline for (.{ .Debug, .ReleaseFast }) |mode| {
|
||||
const check_target = b.resolveTargetQuery(.{
|
||||
.os_tag = OperatingSystem.stdOSTag(check.os),
|
||||
.cpu_arch = check.arch,
|
||||
.os_version_min = getOSVersionMin(check.os),
|
||||
.glibc_version = getOSGlibCVersion(check.os),
|
||||
});
|
||||
|
||||
var options = BunBuildOptions{
|
||||
.target = check_target,
|
||||
.os = check.os,
|
||||
.arch = check_target.result.cpu.arch,
|
||||
.optimize = mode,
|
||||
|
||||
.canary_revision = build_options.canary_revision,
|
||||
.sha = build_options.sha,
|
||||
.tracy_callstack_depth = build_options.tracy_callstack_depth,
|
||||
.version = build_options.version,
|
||||
.reported_nodejs_version = build_options.reported_nodejs_version,
|
||||
.generated_code_dir = build_options.generated_code_dir,
|
||||
};
|
||||
var obj = addBunObject(b, &options);
|
||||
obj.generated_bin = null;
|
||||
step.dependOn(&obj.step);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Running `zig build` with no arguments is almost always a mistake.
|
||||
// TODO: revive this error. cannot right now since ZLS runs zig build without arguments
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ To _containerize_ our application, we define a `Dockerfile`. This file contains
|
||||
```docker#Dockerfile
|
||||
# use the official Bun image
|
||||
# see all versions at https://hub.docker.com/r/oven/bun/tags
|
||||
FROM oven/bun:1 AS base
|
||||
FROM oven/bun:1 as base
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# install dependencies into temp directory
|
||||
|
||||
@@ -13,7 +13,7 @@ console.log(Bun.argv);
|
||||
Running this file with arguments results in the following:
|
||||
|
||||
```sh
|
||||
$ bun run cli.ts --flag1 --flag2 value
|
||||
$ bun run cli.tsx --flag1 --flag2 value
|
||||
[ '/path/to/bun', '/path/to/cli.ts', '--flag1', '--flag2', 'value' ]
|
||||
```
|
||||
|
||||
@@ -47,7 +47,7 @@ console.log(positionals);
|
||||
then it outputs
|
||||
|
||||
```
|
||||
$ bun run cli.ts --flag1 --flag2 value
|
||||
$ bun run cli.tsx --flag1 --flag2 value
|
||||
{
|
||||
flag1: true,
|
||||
flag2: "value",
|
||||
|
||||
@@ -16,7 +16,7 @@ await proc.exited;
|
||||
The second argument accepts a configuration object.
|
||||
|
||||
```ts
|
||||
const proc = Bun.spawn(["echo", "Hello, world!"], {
|
||||
const proc = Bun.spawn("echo", ["Hello, world!"], {
|
||||
cwd: "/tmp",
|
||||
env: { FOO: "bar" },
|
||||
onExit(proc, exitCode, signalCode, error) {
|
||||
|
||||
@@ -13,7 +13,7 @@ jobs:
|
||||
steps:
|
||||
# ...
|
||||
- uses: actions/checkout@v4
|
||||
+ - uses: oven-sh/setup-bun@v2
|
||||
+ - uses: oven-sh/setup-bun@v1
|
||||
|
||||
# run any `bun` or `bunx` command
|
||||
+ - run: bun install
|
||||
@@ -33,7 +33,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# ...
|
||||
- uses: oven-sh/setup-bun@v2
|
||||
- uses: oven-sh/setup-bun@v1
|
||||
+ with:
|
||||
+ bun-version: 1.0.11 # or "latest", "canary", <sha>
|
||||
```
|
||||
|
||||
@@ -52,7 +52,7 @@ Different thresholds can be set for line-level and function-level coverage.
|
||||
```toml
|
||||
[test]
|
||||
# to set different thresholds for lines and functions
|
||||
coverageThreshold = { lines = 0.5, functions = 0.7 }
|
||||
coverageThreshold = { line = 0.5, function = 0.7 }
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
@@ -15,6 +15,8 @@ disable = false
|
||||
disableManifest = false
|
||||
```
|
||||
|
||||
{% /details %}
|
||||
|
||||
## Minimizing re-downloads
|
||||
|
||||
Bun strives to avoid re-downloading packages multiple times. When installing a package, if the cache already contains a version in the range specified by `package.json`, Bun will use the cached package instead of downloading it again.
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
Bun supports loading configuration options from [`.npmrc`](https://docs.npmjs.com/cli/v10/configuring-npm/npmrc) files, allowing you to reuse existing registry/scope configurations.
|
||||
|
||||
{% callout %}
|
||||
|
||||
**NOTE**: We recommend migrating your `.npmrc` file to Bun's [`bunfig.toml`](/docs/runtime/bunfig) format, as it provides more flexible options and can let you configure Bun-specific configuration options.
|
||||
|
||||
{% /callout %}
|
||||
|
||||
# Supported options
|
||||
|
||||
### `registry`: Set the default registry
|
||||
|
||||
The default registry is used to resolve packages, it's default value is `npm`'s official registry (`https://registry.npmjs.org/`).
|
||||
|
||||
To change it, you can set the `registry` option in `.npmrc`:
|
||||
|
||||
```ini
|
||||
registry=http://localhost:4873/
|
||||
```
|
||||
|
||||
The equivalent `bunfig.toml` option is [`install.registry`](/docs/runtime/bunfig#install-registry):
|
||||
|
||||
```toml
|
||||
install.registry = "http://localhost:4873/"
|
||||
```
|
||||
|
||||
### `@<scope>:registry`: Set the registry for a specific scope
|
||||
|
||||
Allows you to set the registry for a specific scope:
|
||||
|
||||
```ini
|
||||
@myorg:registry=http://localhost:4873/
|
||||
```
|
||||
|
||||
The equivalent `bunfig.toml` option is to add a key in [`install.scopes`](/docs/runtime/bunfig#install-registry):
|
||||
|
||||
```toml
|
||||
[install.scopes]
|
||||
myorg = "http://localhost:4873/"
|
||||
```
|
||||
|
||||
### `//<registry_url>/:<key>=<value>`: Confgure options for a specific registry
|
||||
|
||||
Allows you to set options for a specific registry:
|
||||
|
||||
```ini
|
||||
# set an auth token for the registry
|
||||
# ${...} is a placeholder for environment variables
|
||||
//http://localhost:4873/:_authToken=${NPM_TOKEN}
|
||||
|
||||
|
||||
# or you could set a username and password
|
||||
//http://localhost:4873/:username=myusername
|
||||
|
||||
//http://localhost:4873/:_password=${NPM_PASSWORD}
|
||||
```
|
||||
|
||||
The following options are supported:
|
||||
|
||||
- `_authToken`
|
||||
- `username`
|
||||
- `_password`
|
||||
|
||||
The equivalent `bunfig.toml` option is to add a key in [`install.scopes`](/docs/runtime/bunfig#install-registry):
|
||||
|
||||
```toml
|
||||
[install.scopes]
|
||||
myorg = { url = "http://localhost:4873/", username = "myusername", password = "$NPM_PASSWORD" }
|
||||
```
|
||||
@@ -30,6 +30,10 @@ $ docker pull oven/bun
|
||||
$ docker run --rm --init --ulimit memlock=-1:-1 oven/bun
|
||||
```
|
||||
|
||||
```bash#Proto
|
||||
$ proto install bun
|
||||
```
|
||||
|
||||
{% /codetabs %}
|
||||
|
||||
### Windows
|
||||
@@ -142,6 +146,7 @@ $ bun upgrade
|
||||
|
||||
**Scoop users** — To avoid conflicts with Scoop, use `scoop update bun` instead.
|
||||
|
||||
**proto users** - Use `proto install bun --pin` instead.
|
||||
{% /callout %}
|
||||
|
||||
## Canary builds
|
||||
@@ -286,4 +291,8 @@ $ npm uninstall -g bun
|
||||
$ brew uninstall bun
|
||||
```
|
||||
|
||||
```bash#Proto
|
||||
$ proto uninstall bun
|
||||
```
|
||||
|
||||
{% /codetabs %}
|
||||
|
||||
@@ -197,9 +197,6 @@ export default {
|
||||
description:
|
||||
"Patch dependencies in your project to fix bugs or add features without vendoring the entire package.",
|
||||
}),
|
||||
page("install/npmrc", ".npmrc support", {
|
||||
description: "Bun supports loading some configuration options from .npmrc",
|
||||
}),
|
||||
// page("install/utilities", "Utilities", {
|
||||
// description: "Use `bun pm` to introspect your global module cache or project dependency tree.",
|
||||
// }),
|
||||
|
||||
@@ -193,7 +193,7 @@ The table below lists all globals implemented by Node.js and Bun's current compa
|
||||
|
||||
### [`Buffer`](https://nodejs.org/api/buffer.html#class-buffer)
|
||||
|
||||
🟢 Fully implemented.
|
||||
🟡 Incomplete implementation of `base64` and `base64url` encodings.
|
||||
|
||||
### [`ByteLengthQueuingStrategy`](https://developer.mozilla.org/en-US/docs/Web/API/ByteLengthQueuingStrategy)
|
||||
|
||||
|
||||
@@ -182,7 +182,7 @@ pub fn main() anyerror!void {
|
||||
|
||||
try channel.buffer.ensureTotalCapacity(1);
|
||||
|
||||
HTTPThread.init();
|
||||
try HTTPThread.init();
|
||||
|
||||
var ctx = try default_allocator.create(HTTP.HTTPChannelContext);
|
||||
ctx.* = .{
|
||||
|
||||
33
package.json
33
package.json
@@ -5,23 +5,23 @@
|
||||
"./packages/bun-types"
|
||||
],
|
||||
"dependencies": {
|
||||
"@vscode/debugadapter": "^1.65.0",
|
||||
"esbuild": "^0.21.4",
|
||||
"eslint": "^9.4.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"mitata": "^0.1.11",
|
||||
"@vscode/debugadapter": "^1.61.0",
|
||||
"esbuild": "^0.17.15",
|
||||
"eslint": "^8.20.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"mitata": "^0.1.3",
|
||||
"peechy": "0.4.34",
|
||||
"prettier": "^3.2.5",
|
||||
"react": "^18.3.1",
|
||||
"react-dom": "^18.3.1",
|
||||
"source-map-js": "^1.2.0",
|
||||
"typescript": "^5.4.5"
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"source-map-js": "^1.0.2",
|
||||
"typescript": "^5.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/bun": "^1.1.3",
|
||||
"@types/react": "^18.3.3",
|
||||
"@typescript-eslint/eslint-plugin": "^7.11.0",
|
||||
"@typescript-eslint/parser": "^7.11.0"
|
||||
"@types/bun": "^1.1.2",
|
||||
"@types/react": "^18.0.25",
|
||||
"@typescript-eslint/eslint-plugin": "^5.31.0",
|
||||
"@typescript-eslint/parser": "^5.31.0"
|
||||
},
|
||||
"resolutions": {
|
||||
"bun-types": "workspace:packages/bun-types"
|
||||
@@ -34,7 +34,6 @@
|
||||
"build:tidy": "BUN_SILENT=1 cmake --log-level=WARNING . -DZIG_OPTIMIZE=Debug -DUSE_DEBUG_JSC=ON -DBUN_TIDY_ONLY=ON -DCMAKE_BUILD_TYPE=Debug -GNinja -Bbuild-tidy >> ${GITHUB_STEP_SUMMARY:-/dev/stdout} && BUN_SILENT=1 ninja -Cbuild-tidy >> ${GITHUB_STEP_SUMMARY:-/dev/stdout}",
|
||||
"build:tidy-extra": "cmake . -DZIG_OPTIMIZE=Debug -DUSE_DEBUG_JSC=ON -DBUN_TIDY_ONLY_EXTRA=ON -DCMAKE_BUILD_TYPE=Debug -GNinja -Bbuild-tidy && ninja -Cbuild-tidy",
|
||||
"build:release": "cmake . -DCMAKE_BUILD_TYPE=Release -GNinja -Bbuild-release && ninja -Cbuild-release",
|
||||
"build:release:local": "cmake . -DCMAKE_BUILD_TYPE=Release -DWEBKIT_DIR=$(pwd)/src/bun.js/WebKit/WebKitBuild/Release -GNinja -Bbuild-release-local && ninja -Cbuild-release-local",
|
||||
"build:release:with_logs": "cmake . -DCMAKE_BUILD_TYPE=Release -DENABLE_LOGS=true -GNinja -Bbuild-release && ninja -Cbuild-release",
|
||||
"build:debug-zig-release": "cmake . -DCMAKE_BUILD_TYPE=Release -DZIG_OPTIMIZE=Debug -GNinja -Bbuild-debug-zig-release && ninja -Cbuild-debug-zig-release",
|
||||
"build:safe": "cmake . -DZIG_OPTIMIZE=ReleaseSafe -DUSE_DEBUG_JSC=ON -DCMAKE_BUILD_TYPE=Release -GNinja -Bbuild-safe && ninja -Cbuild-safe",
|
||||
@@ -44,12 +43,10 @@
|
||||
"fmt:zig": "zig fmt src/*.zig src/*/*.zig src/*/*/*.zig src/*/*/*/*.zig",
|
||||
"lint": "eslint './**/*.d.ts' --cache",
|
||||
"lint:fix": "eslint './**/*.d.ts' --cache --fix",
|
||||
"test": "node scripts/runner.node.mjs ./build/bun-debug",
|
||||
"test:release": "node scripts/runner.node.mjs ./build-release/bun",
|
||||
"banned": "bun packages/bun-internal-test/src/linter.ts",
|
||||
"test": "node packages/bun-internal-test/src/runner.node.mjs ./build/bun-debug",
|
||||
"test:release": "node packages/bun-internal-test/src/runner.node.mjs ./build-release/bun",
|
||||
"zig-check": ".cache/zig/zig.exe build check --summary new",
|
||||
"zig-check-all": ".cache/zig/zig.exe build check-all --summary new",
|
||||
"zig-check-windows": ".cache/zig/zig.exe build check-windows --summary new",
|
||||
"zig": ".cache/zig/zig.exe "
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,13 +5,9 @@
|
||||
"std.debug.assert": "Use bun.assert instead",
|
||||
"std.debug.dumpStackTrace": "Use bun.handleErrorReturnTrace or bun.crash_handler.dumpStackTrace instead",
|
||||
"std.debug.print": "Don't let this be committed",
|
||||
"std.mem.indexOfAny(": "Use bun.strings.indexOfAny",
|
||||
"std.mem.indexOfAny": "Use bun.strings.indexAny or bun.strings.indexAnyComptime",
|
||||
"undefined != ": "This is by definition Undefined Behavior.",
|
||||
"undefined == ": "This is by definition Undefined Behavior.",
|
||||
"bun.toFD(std.fs.cwd().fd)": "Use bun.FD.cwd()",
|
||||
"std.StringArrayHashMapUnmanaged(": "bun.StringArrayHashMapUnmanaged has a faster `eql`",
|
||||
"std.StringArrayHashMap(": "bun.StringArrayHashMap has a faster `eql`",
|
||||
"std.StringHashMapUnmanaged(": "bun.StringHashMapUnmanaged has a faster `eql`",
|
||||
"std.StringHashMap(": "bun.StringHashMaphas a faster `eql`",
|
||||
"": ""
|
||||
}
|
||||
|
||||
@@ -19,7 +19,9 @@ for (const [banned, suggestion] of Object.entries(BANNED)) {
|
||||
if (banned.length === 0) continue;
|
||||
// Run git grep to find occurrences of std.debug.assert in .zig files
|
||||
// .nothrow() is here since git will exit with non-zero if no matches are found.
|
||||
let stdout = await $`git grep -n -F "${banned}" "src/**.zig" | grep -v -F '//' | grep -v -F bench`.nothrow().text();
|
||||
let stdout = await $`git grep -n -F "${banned}" "src/**/**.zig" | grep -v -F '//' | grep -v -F bench`
|
||||
.nothrow()
|
||||
.text();
|
||||
|
||||
stdout = stdout.trim();
|
||||
if (stdout.length === 0) continue;
|
||||
|
||||
@@ -290,7 +290,7 @@ function formatBody(body?: string, isBase64Encoded?: boolean): string | null {
|
||||
if (!isBase64Encoded) {
|
||||
return body;
|
||||
}
|
||||
return Buffer.from(body, "base64").toString("utf8");
|
||||
return Buffer.from(body).toString("base64");
|
||||
}
|
||||
|
||||
type HttpEventV1 = {
|
||||
|
||||
2
packages/bun-types/bun.d.ts
vendored
2
packages/bun-types/bun.d.ts
vendored
@@ -2968,7 +2968,7 @@ declare module "bun" {
|
||||
* Returns 0 if the versions are equal, 1 if `v1` is greater, or -1 if `v2` is greater.
|
||||
* Throws an error if either version is invalid.
|
||||
*/
|
||||
order(this: void, v1: StringLike, v2: StringLike): -1 | 0 | 1;
|
||||
order(v1: StringLike, v2: StringLike): -1 | 0 | 1;
|
||||
}
|
||||
var semver: Semver;
|
||||
|
||||
|
||||
@@ -42,7 +42,6 @@
|
||||
#define HAS_MSGX
|
||||
#endif
|
||||
|
||||
|
||||
/* We need to emulate sendmmsg, recvmmsg on platform who don't have it */
|
||||
int bsd_sendmmsg(LIBUS_SOCKET_DESCRIPTOR fd, struct udp_sendbuf* sendbuf, int flags) {
|
||||
#if defined(_WIN32)// || defined(__APPLE__)
|
||||
@@ -398,9 +397,7 @@ int bsd_addr_get_port(struct bsd_addr_t *addr) {
|
||||
// called by dispatch_ready_poll
|
||||
LIBUS_SOCKET_DESCRIPTOR bsd_accept_socket(LIBUS_SOCKET_DESCRIPTOR fd, struct bsd_addr_t *addr) {
|
||||
LIBUS_SOCKET_DESCRIPTOR accepted_fd;
|
||||
|
||||
while (1) {
|
||||
addr->len = sizeof(addr->mem);
|
||||
addr->len = sizeof(addr->mem);
|
||||
|
||||
#if defined(SOCK_CLOEXEC) && defined(SOCK_NONBLOCK)
|
||||
// Linux, FreeBSD
|
||||
@@ -408,18 +405,12 @@ LIBUS_SOCKET_DESCRIPTOR bsd_accept_socket(LIBUS_SOCKET_DESCRIPTOR fd, struct bsd
|
||||
#else
|
||||
// Windows, OS X
|
||||
accepted_fd = accept(fd, (struct sockaddr *) addr, &addr->len);
|
||||
|
||||
#endif
|
||||
|
||||
if (UNLIKELY(IS_EINTR(accepted_fd))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/* We cannot rely on addr since it is not initialized if failed */
|
||||
if (accepted_fd == LIBUS_SOCKET_ERROR) {
|
||||
return LIBUS_SOCKET_ERROR;
|
||||
}
|
||||
|
||||
break;
|
||||
/* We cannot rely on addr since it is not initialized if failed */
|
||||
if (accepted_fd == LIBUS_SOCKET_ERROR) {
|
||||
return LIBUS_SOCKET_ERROR;
|
||||
}
|
||||
|
||||
internal_finalize_bsd_addr(addr);
|
||||
@@ -432,22 +423,14 @@ LIBUS_SOCKET_DESCRIPTOR bsd_accept_socket(LIBUS_SOCKET_DESCRIPTOR fd, struct bsd
|
||||
#endif
|
||||
}
|
||||
|
||||
ssize_t bsd_recv(LIBUS_SOCKET_DESCRIPTOR fd, void *buf, int length, int flags) {
|
||||
while (1) {
|
||||
ssize_t ret = recv(fd, buf, length, flags);
|
||||
|
||||
if (UNLIKELY(IS_EINTR(ret))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
int bsd_recv(LIBUS_SOCKET_DESCRIPTOR fd, void *buf, int length, int flags) {
|
||||
return recv(fd, buf, length, flags);
|
||||
}
|
||||
|
||||
#if !defined(_WIN32)
|
||||
#include <sys/uio.h>
|
||||
|
||||
ssize_t bsd_write2(LIBUS_SOCKET_DESCRIPTOR fd, const char *header, int header_length, const char *payload, int payload_length) {
|
||||
int bsd_write2(LIBUS_SOCKET_DESCRIPTOR fd, const char *header, int header_length, const char *payload, int payload_length) {
|
||||
struct iovec chunks[2];
|
||||
|
||||
chunks[0].iov_base = (char *)header;
|
||||
@@ -455,21 +438,13 @@ ssize_t bsd_write2(LIBUS_SOCKET_DESCRIPTOR fd, const char *header, int header_le
|
||||
chunks[1].iov_base = (char *)payload;
|
||||
chunks[1].iov_len = payload_length;
|
||||
|
||||
while (1) {
|
||||
ssize_t written = writev(fd, chunks, 2);
|
||||
|
||||
if (UNLIKELY(IS_EINTR(written))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return written;
|
||||
}
|
||||
return writev(fd, chunks, 2);
|
||||
}
|
||||
#else
|
||||
ssize_t bsd_write2(LIBUS_SOCKET_DESCRIPTOR fd, const char *header, int header_length, const char *payload, int payload_length) {
|
||||
ssize_t written = bsd_send(fd, header, header_length, 0);
|
||||
int bsd_write2(LIBUS_SOCKET_DESCRIPTOR fd, const char *header, int header_length, const char *payload, int payload_length) {
|
||||
int written = bsd_send(fd, header, header_length, 0);
|
||||
if (written == header_length) {
|
||||
ssize_t second_write = bsd_send(fd, payload, payload_length, 0);
|
||||
int second_write = bsd_send(fd, payload, payload_length, 0);
|
||||
if (second_write > 0) {
|
||||
written += second_write;
|
||||
}
|
||||
@@ -478,28 +453,26 @@ ssize_t bsd_write2(LIBUS_SOCKET_DESCRIPTOR fd, const char *header, int header_le
|
||||
}
|
||||
#endif
|
||||
|
||||
ssize_t bsd_send(LIBUS_SOCKET_DESCRIPTOR fd, const char *buf, int length, int msg_more) {
|
||||
while (1) {
|
||||
int bsd_send(LIBUS_SOCKET_DESCRIPTOR fd, const char *buf, int length, int msg_more) {
|
||||
|
||||
// MSG_MORE (Linux), MSG_PARTIAL (Windows), TCP_NOPUSH (BSD)
|
||||
|
||||
#ifndef MSG_NOSIGNAL
|
||||
#define MSG_NOSIGNAL 0
|
||||
#endif
|
||||
|
||||
#ifdef MSG_MORE
|
||||
// for Linux we do not want signals
|
||||
ssize_t rc = send(fd, buf, length, ((msg_more != 0) * MSG_MORE) | MSG_NOSIGNAL | MSG_DONTWAIT);
|
||||
#else
|
||||
// use TCP_NOPUSH
|
||||
ssize_t rc = send(fd, buf, length, MSG_NOSIGNAL | MSG_DONTWAIT);
|
||||
#endif
|
||||
#ifdef MSG_MORE
|
||||
|
||||
if (UNLIKELY(IS_EINTR(rc))) {
|
||||
continue;
|
||||
}
|
||||
// for Linux we do not want signals
|
||||
return send(fd, buf, length, ((msg_more != 0) * MSG_MORE) | MSG_NOSIGNAL | MSG_DONTWAIT);
|
||||
|
||||
return rc;
|
||||
}
|
||||
#else
|
||||
|
||||
// use TCP_NOPUSH
|
||||
|
||||
return send(fd, buf, length, MSG_NOSIGNAL | MSG_DONTWAIT);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
int bsd_would_block() {
|
||||
@@ -510,23 +483,6 @@ int bsd_would_block() {
|
||||
#endif
|
||||
}
|
||||
|
||||
static int us_internal_bind_and_listen(LIBUS_SOCKET_DESCRIPTOR listenFd, struct sockaddr *listenAddr, socklen_t listenAddrLength, int backlog) {
|
||||
int result;
|
||||
do
|
||||
result = bind(listenFd, listenAddr, listenAddrLength);
|
||||
while (IS_EINTR(result));
|
||||
|
||||
if (result == -1) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
do
|
||||
result = listen(listenFd, backlog);
|
||||
while (IS_EINTR(result));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
inline __attribute__((always_inline)) LIBUS_SOCKET_DESCRIPTOR bsd_bind_listen_fd(
|
||||
LIBUS_SOCKET_DESCRIPTOR listenFd,
|
||||
struct addrinfo *listenAddr,
|
||||
@@ -556,7 +512,7 @@ inline __attribute__((always_inline)) LIBUS_SOCKET_DESCRIPTOR bsd_bind_listen_fd
|
||||
setsockopt(listenFd, IPPROTO_IPV6, IPV6_V6ONLY, (void *) &disabled, sizeof(disabled));
|
||||
#endif
|
||||
|
||||
if (us_internal_bind_and_listen(listenFd, listenAddr->ai_addr, (socklen_t) listenAddr->ai_addrlen, 512)) {
|
||||
if (bind(listenFd, listenAddr->ai_addr, (socklen_t) listenAddr->ai_addrlen) || listen(listenFd, 512)) {
|
||||
return LIBUS_SOCKET_ERROR;
|
||||
}
|
||||
|
||||
@@ -734,7 +690,7 @@ static LIBUS_SOCKET_DESCRIPTOR internal_bsd_create_listen_socket_unix(const char
|
||||
unlink(path);
|
||||
#endif
|
||||
|
||||
if (us_internal_bind_and_listen(listenFd, (struct sockaddr *) server_address, (socklen_t) addrlen, 512)) {
|
||||
if (bind(listenFd, (struct sockaddr *)server_address, addrlen) || listen(listenFd, 512)) {
|
||||
#if defined(_WIN32)
|
||||
int shouldSimulateENOENT = WSAGetLastError() == WSAENETDOWN;
|
||||
#endif
|
||||
@@ -969,7 +925,7 @@ static int bsd_do_connect_raw(LIBUS_SOCKET_DESCRIPTOR fd, struct sockaddr *addr,
|
||||
do {
|
||||
errno = 0;
|
||||
r = connect(fd, (struct sockaddr *)addr, namelen);
|
||||
} while (IS_EINTR(r));
|
||||
} while (r == -1 && errno == EINTR);
|
||||
|
||||
// connect() can return -1 with an errno of 0.
|
||||
// the errno is the correct one in that case.
|
||||
|
||||
@@ -109,51 +109,6 @@ struct us_loop_t *us_timer_loop(struct us_timer_t *t) {
|
||||
return internal_cb->loop;
|
||||
}
|
||||
|
||||
|
||||
#if defined(LIBUS_USE_EPOLL)
|
||||
|
||||
#include <sys/syscall.h>
|
||||
static int has_epoll_pwait2 = -1;
|
||||
|
||||
#ifndef SYS_epoll_pwait2
|
||||
// It's consistent on multiple architectures
|
||||
// https://github.com/torvalds/linux/blob/9d1ddab261f3e2af7c384dc02238784ce0cf9f98/include/uapi/asm-generic/unistd.h#L795
|
||||
// https://github.com/google/gvisor/blob/master/test/syscalls/linux/epoll.cc#L48C1-L50C7
|
||||
#define SYS_epoll_pwait2 441
|
||||
#endif
|
||||
|
||||
static ssize_t sys_epoll_pwait2(int epfd, struct epoll_event *events, int maxevents, const struct timespec *timeout, const sigset_t *sigmask, size_t sigsetsize) {
|
||||
return syscall(SYS_epoll_pwait2, epfd, events, maxevents, timeout, sigmask, sigsetsize);
|
||||
}
|
||||
|
||||
static int bun_epoll_pwait2(int epfd, struct epoll_event *events, int maxevents, const struct timespec *timeout) {
|
||||
int ret;
|
||||
if (has_epoll_pwait2 != 0) {
|
||||
do {
|
||||
ret = sys_epoll_pwait2(epfd, events, maxevents, timeout, NULL, 0);
|
||||
} while (IS_EINTR(ret));
|
||||
|
||||
if (LIKELY(ret != -1 || errno != ENOSYS)) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
has_epoll_pwait2 = 0;
|
||||
}
|
||||
|
||||
int timeoutMs = -1;
|
||||
if (timeout) {
|
||||
timeoutMs = timeout->tv_sec * 1000 + timeout->tv_nsec / 1000000;
|
||||
}
|
||||
|
||||
do {
|
||||
ret = epoll_wait(epfd, events, maxevents, timeoutMs);
|
||||
} while (IS_EINTR(ret));
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Loop */
|
||||
struct us_loop_t *us_create_loop(void *hint, void (*wakeup_cb)(struct us_loop_t *loop), void (*pre_cb)(struct us_loop_t *loop), void (*post_cb)(struct us_loop_t *loop), unsigned int ext_size) {
|
||||
struct us_loop_t *loop = (struct us_loop_t *) us_calloc(1, sizeof(struct us_loop_t) + ext_size);
|
||||
@@ -184,11 +139,9 @@ void us_loop_run(struct us_loop_t *loop) {
|
||||
|
||||
/* Fetch ready polls */
|
||||
#ifdef LIBUS_USE_EPOLL
|
||||
loop->num_ready_polls = bun_epoll_pwait2(loop->fd, loop->ready_polls, 1024, NULL);
|
||||
loop->num_ready_polls = epoll_wait(loop->fd, loop->ready_polls, 1024, -1);
|
||||
#else
|
||||
do {
|
||||
loop->num_ready_polls = kevent64(loop->fd, NULL, 0, loop->ready_polls, 1024, 0, NULL);
|
||||
} while (IS_EINTR(loop->num_ready_polls));
|
||||
loop->num_ready_polls = kevent64(loop->fd, NULL, 0, loop->ready_polls, 1024, 0, NULL);
|
||||
#endif
|
||||
|
||||
/* Iterate ready polls, dispatching them by type */
|
||||
@@ -230,6 +183,12 @@ void us_loop_run(struct us_loop_t *loop) {
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(LIBUS_USE_EPOLL)
|
||||
|
||||
// static int has_epoll_pwait2 = 0;
|
||||
// TODO:
|
||||
|
||||
#endif
|
||||
|
||||
void us_loop_run_bun_tick(struct us_loop_t *loop, const struct timespec* timeout) {
|
||||
if (loop->num_polls == 0)
|
||||
@@ -248,12 +207,13 @@ void us_loop_run_bun_tick(struct us_loop_t *loop, const struct timespec* timeout
|
||||
|
||||
/* Fetch ready polls */
|
||||
#ifdef LIBUS_USE_EPOLL
|
||||
|
||||
loop->num_ready_polls = bun_epoll_pwait2(loop->fd, loop->ready_polls, 1024, timeout);
|
||||
int timeoutMs = -1;
|
||||
if (timeout) {
|
||||
timeoutMs = timeout->tv_sec * 1000 + timeout->tv_nsec / 1000000;
|
||||
}
|
||||
loop->num_ready_polls = epoll_wait(loop->fd, loop->ready_polls, 1024, timeoutMs);
|
||||
#else
|
||||
do {
|
||||
loop->num_ready_polls = kevent64(loop->fd, NULL, 0, loop->ready_polls, 1024, 0, timeout);
|
||||
} while (IS_EINTR(loop->num_ready_polls));
|
||||
loop->num_ready_polls = kevent64(loop->fd, NULL, 0, loop->ready_polls, 1024, 0, timeout);
|
||||
#endif
|
||||
|
||||
/* Iterate ready polls, dispatching them by type */
|
||||
@@ -336,10 +296,7 @@ int kqueue_change(int kqfd, int fd, int old_events, int new_events, void *user_d
|
||||
EV_SET64(&change_list[change_length++], fd, EVFILT_WRITE, (new_events & LIBUS_SOCKET_WRITABLE) ? EV_ADD : EV_DELETE, 0, 0, (uint64_t)(void*)user_data, 0, 0);
|
||||
}
|
||||
|
||||
int ret;
|
||||
do {
|
||||
ret = kevent64(kqfd, change_list, change_length, change_list, change_length, KEVENT_FLAG_ERROR_EVENTS, NULL);
|
||||
} while (IS_EINTR(ret));
|
||||
int ret = kevent64(kqfd, change_list, change_length, change_list, change_length, KEVENT_FLAG_ERROR_EVENTS, NULL);
|
||||
|
||||
// ret should be 0 in most cases (not guaranteed when removing async)
|
||||
|
||||
@@ -375,10 +332,7 @@ void us_poll_start(struct us_poll_t *p, struct us_loop_t *loop, int events) {
|
||||
struct epoll_event event;
|
||||
event.events = events;
|
||||
event.data.ptr = p;
|
||||
int ret;
|
||||
do {
|
||||
ret = epoll_ctl(loop->fd, EPOLL_CTL_ADD, p->state.fd, &event);
|
||||
} while (IS_EINTR(ret));
|
||||
epoll_ctl(loop->fd, EPOLL_CTL_ADD, p->state.fd, &event);
|
||||
#else
|
||||
kqueue_change(loop->fd, p->state.fd, 0, events, p);
|
||||
#endif
|
||||
@@ -394,10 +348,7 @@ void us_poll_change(struct us_poll_t *p, struct us_loop_t *loop, int events) {
|
||||
struct epoll_event event;
|
||||
event.events = events;
|
||||
event.data.ptr = p;
|
||||
int rc;
|
||||
do {
|
||||
rc = epoll_ctl(loop->fd, EPOLL_CTL_MOD, p->state.fd, &event);
|
||||
} while (IS_EINTR(rc));
|
||||
epoll_ctl(loop->fd, EPOLL_CTL_MOD, p->state.fd, &event);
|
||||
#else
|
||||
kqueue_change(loop->fd, p->state.fd, old_events, events, p);
|
||||
#endif
|
||||
@@ -411,10 +362,7 @@ void us_poll_stop(struct us_poll_t *p, struct us_loop_t *loop) {
|
||||
int new_events = 0;
|
||||
#ifdef LIBUS_USE_EPOLL
|
||||
struct epoll_event event;
|
||||
int rc;
|
||||
do {
|
||||
rc = epoll_ctl(loop->fd, EPOLL_CTL_DEL, p->state.fd, &event);
|
||||
} while (IS_EINTR(rc));
|
||||
epoll_ctl(loop->fd, EPOLL_CTL_DEL, p->state.fd, &event);
|
||||
#else
|
||||
if (old_events) {
|
||||
kqueue_change(loop->fd, p->state.fd, old_events, new_events, NULL);
|
||||
@@ -425,14 +373,12 @@ void us_poll_stop(struct us_poll_t *p, struct us_loop_t *loop) {
|
||||
us_internal_loop_update_pending_ready_polls(loop, p, 0, old_events, new_events);
|
||||
}
|
||||
|
||||
size_t us_internal_accept_poll_event(struct us_poll_t *p) {
|
||||
unsigned int us_internal_accept_poll_event(struct us_poll_t *p) {
|
||||
#ifdef LIBUS_USE_EPOLL
|
||||
int fd = us_poll_fd(p);
|
||||
uint64_t buf;
|
||||
ssize_t read_length = 0;
|
||||
do {
|
||||
read_length = read(fd, &buf, 8);
|
||||
} while (IS_EINTR(read_length));
|
||||
int read_length = read(fd, &buf, 8);
|
||||
(void)read_length;
|
||||
return buf;
|
||||
#else
|
||||
/* Kqueue has no underlying FD for timers or user events */
|
||||
@@ -521,11 +467,7 @@ void us_timer_close(struct us_timer_t *timer, int fallthrough) {
|
||||
|
||||
struct kevent64_s event;
|
||||
EV_SET64(&event, (uint64_t) (void*) internal_cb, EVFILT_TIMER, EV_DELETE, 0, 0, (uint64_t)internal_cb, 0, 0);
|
||||
int ret;
|
||||
do {
|
||||
ret = kevent64(internal_cb->loop->fd, &event, 1, &event, 1, KEVENT_FLAG_ERROR_EVENTS, NULL);
|
||||
} while (IS_EINTR(ret));
|
||||
|
||||
kevent64(internal_cb->loop->fd, &event, 1, &event, 1, KEVENT_FLAG_ERROR_EVENTS, NULL);
|
||||
|
||||
/* (regular) sockets are the only polls which are not freed immediately */
|
||||
if(fallthrough){
|
||||
@@ -544,11 +486,7 @@ void us_timer_set(struct us_timer_t *t, void (*cb)(struct us_timer_t *t), int ms
|
||||
struct kevent64_s event;
|
||||
uint64_t ptr = (uint64_t)(void*)internal_cb;
|
||||
EV_SET64(&event, ptr, EVFILT_TIMER, EV_ADD | (repeat_ms ? 0 : EV_ONESHOT), 0, ms, (uint64_t)internal_cb, 0, 0);
|
||||
|
||||
int ret;
|
||||
do {
|
||||
ret = kevent64(internal_cb->loop->fd, &event, 1, &event, 1, KEVENT_FLAG_ERROR_EVENTS, NULL);
|
||||
} while (IS_EINTR(ret));
|
||||
kevent64(internal_cb->loop->fd, &event, 1, &event, 1, KEVENT_FLAG_ERROR_EVENTS, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -643,11 +581,7 @@ void us_internal_async_close(struct us_internal_async *a) {
|
||||
struct kevent64_s event;
|
||||
uint64_t ptr = (uint64_t)(void*)internal_cb;
|
||||
EV_SET64(&event, ptr, EVFILT_MACHPORT, EV_DELETE, 0, 0, (uint64_t)(void*)internal_cb, 0,0);
|
||||
|
||||
int ret;
|
||||
do {
|
||||
ret = kevent64(internal_cb->loop->fd, &event, 1, &event, 1, KEVENT_FLAG_ERROR_EVENTS, NULL);
|
||||
} while (IS_EINTR(ret));
|
||||
kevent64(internal_cb->loop->fd, &event, 1, &event, 1, KEVENT_FLAG_ERROR_EVENTS, NULL);
|
||||
|
||||
mach_port_deallocate(mach_task_self(), internal_cb->port);
|
||||
us_free(internal_cb->machport_buf);
|
||||
@@ -675,10 +609,7 @@ void us_internal_async_set(struct us_internal_async *a, void (*cb)(struct us_int
|
||||
event.ext[1] = MACHPORT_BUF_LEN;
|
||||
event.udata = (uint64_t)(void*)internal_cb;
|
||||
|
||||
int ret;
|
||||
do {
|
||||
ret = kevent64(internal_cb->loop->fd, &event, 1, &event, 1, KEVENT_FLAG_ERROR_EVENTS, NULL);
|
||||
} while (IS_EINTR(ret));
|
||||
int ret = kevent64(internal_cb->loop->fd, &event, 1, &event, 1, KEVENT_FLAG_ERROR_EVENTS, NULL);
|
||||
|
||||
if (UNLIKELY(ret == -1)) {
|
||||
abort();
|
||||
|
||||
@@ -125,7 +125,7 @@ int us_poll_events(struct us_poll_t *p) {
|
||||
((p->poll_type & POLL_TYPE_POLLING_OUT) ? LIBUS_SOCKET_WRITABLE : 0);
|
||||
}
|
||||
|
||||
size_t us_internal_accept_poll_event(struct us_poll_t *p) { return 0; }
|
||||
unsigned int us_internal_accept_poll_event(struct us_poll_t *p) { return 0; }
|
||||
|
||||
int us_internal_poll_type(struct us_poll_t *p) { return p->poll_type & POLL_TYPE_KIND_MASK; }
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#ifndef INTERNAL_H
|
||||
#define INTERNAL_H
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
#ifndef __cplusplus
|
||||
#define alignas(x) __declspec(align(x))
|
||||
#endif
|
||||
|
||||
#include <BaseTsd.h>
|
||||
typedef SSIZE_T ssize_t;
|
||||
|
||||
#else
|
||||
#include <stdalign.h>
|
||||
#endif
|
||||
@@ -56,17 +52,6 @@ void us_internal_loop_update_pending_ready_polls(struct us_loop_t *loop,
|
||||
#include "internal/eventing/libuv.h"
|
||||
#endif
|
||||
|
||||
#ifndef LIKELY
|
||||
#define LIKELY(cond) __builtin_expect((_Bool)(cond), 1)
|
||||
#define UNLIKELY(cond) __builtin_expect((_Bool)(cond), 0)
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#define IS_EINTR(rc) (rc == SOCKET_ERROR && WSAGetLastError() == WSAEINTR)
|
||||
#else
|
||||
#define IS_EINTR(rc) (rc == -1 && errno == EINTR)
|
||||
#endif
|
||||
|
||||
/* Poll type and what it polls for */
|
||||
enum {
|
||||
/* Three first bits */
|
||||
@@ -133,7 +118,7 @@ void us_internal_async_set(struct us_internal_async *a,
|
||||
void us_internal_async_wakeup(struct us_internal_async *a);
|
||||
|
||||
/* Eventing related */
|
||||
size_t us_internal_accept_poll_event(struct us_poll_t *p);
|
||||
unsigned int us_internal_accept_poll_event(struct us_poll_t *p);
|
||||
int us_internal_poll_type(struct us_poll_t *p);
|
||||
void us_internal_poll_set_type(struct us_poll_t *p, int poll_type);
|
||||
|
||||
|
||||
@@ -134,9 +134,9 @@ int bsd_addr_get_port(struct bsd_addr_t *addr);
|
||||
// called by dispatch_ready_poll
|
||||
LIBUS_SOCKET_DESCRIPTOR bsd_accept_socket(LIBUS_SOCKET_DESCRIPTOR fd, struct bsd_addr_t *addr);
|
||||
|
||||
ssize_t bsd_recv(LIBUS_SOCKET_DESCRIPTOR fd, void *buf, int length, int flags);
|
||||
ssize_t bsd_send(LIBUS_SOCKET_DESCRIPTOR fd, const char *buf, int length, int msg_more);
|
||||
ssize_t bsd_write2(LIBUS_SOCKET_DESCRIPTOR fd, const char *header, int header_length, const char *payload, int payload_length);
|
||||
int bsd_recv(LIBUS_SOCKET_DESCRIPTOR fd, void *buf, int length, int flags);
|
||||
int bsd_send(LIBUS_SOCKET_DESCRIPTOR fd, const char *buf, int length, int msg_more);
|
||||
int bsd_write2(LIBUS_SOCKET_DESCRIPTOR fd, const char *header, int header_length, const char *payload, int payload_length);
|
||||
int bsd_would_block();
|
||||
|
||||
// return LIBUS_SOCKET_ERROR or the fd that represents listen socket
|
||||
|
||||
9
scripts/all-dependencies.ps1
Executable file → Normal file
9
scripts/all-dependencies.ps1
Executable file → Normal file
@@ -3,14 +3,13 @@ param(
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
. (Join-Path $PSScriptRoot "env.ps1")
|
||||
|
||||
if ($env:CI) {
|
||||
& (Join-Path $PSScriptRoot "update-submodules.ps1")
|
||||
}
|
||||
|
||||
$DidAnything = $false;
|
||||
|
||||
$BUN_BASE_DIR = if ($env:BUN_BASE_DIR) { $env:BUN_BASE_DIR } else { Join-Path $PSScriptRoot '..' }
|
||||
$BUN_DEPS_DIR = if ($env:BUN_DEPS_DIR) { $env:BUN_DEPS_DIR } else { Join-Path $BUN_BASE_DIR 'src\deps' }
|
||||
$BUN_DEPS_OUT_DIR = if ($env:BUN_DEPS_OUT_DIR) { $env:BUN_DEPS_OUT_DIR } else { $BUN_DEPS_DIR }
|
||||
|
||||
function Build-Dependency {
|
||||
param(
|
||||
$Script,
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
set -eo pipefail
|
||||
set -euo pipefail
|
||||
source "$(dirname -- "${BASH_SOURCE[0]}")/env.sh"
|
||||
|
||||
if [[ "$CI" ]]; then
|
||||
$(dirname -- "${BASH_SOURCE[0]}")/update-submodules.sh
|
||||
fi
|
||||
|
||||
FORCE=
|
||||
|
||||
while getopts "f" opt; do
|
||||
@@ -24,35 +19,16 @@ while getopts "f" opt; do
|
||||
done
|
||||
|
||||
BUILT_ANY=0
|
||||
SUBMODULES=
|
||||
CACHE_DIR=
|
||||
CACHE=0
|
||||
if [ -n "$BUN_DEPS_CACHE_DIR" ]; then
|
||||
CACHE_DIR="$BUN_DEPS_CACHE_DIR"
|
||||
CACHE=1
|
||||
SUBMODULES="$(git submodule status)"
|
||||
fi
|
||||
|
||||
dep() {
|
||||
local submodule="$1"
|
||||
local script="$2"
|
||||
CACHE_KEY=
|
||||
if [ "$CACHE" == "1" ]; then
|
||||
CACHE_KEY="$submodule/$(echo "$SUBMODULES" | grep "$submodule" | git hash-object --stdin)"
|
||||
fi
|
||||
local script="$1"
|
||||
if [ -z "$FORCE" ]; then
|
||||
HAS_ALL_DEPS=1
|
||||
shift
|
||||
for lib in "${@:2}"; do
|
||||
for lib in "$@"; do
|
||||
if [ ! -f "$BUN_DEPS_OUT_DIR/$lib" ]; then
|
||||
if [[ "$CACHE" == "1" && -f "$CACHE_DIR/$CACHE_KEY/$lib" ]]; then
|
||||
mkdir -p "$BUN_DEPS_OUT_DIR"
|
||||
cp "$CACHE_DIR/$CACHE_KEY/$lib" "$BUN_DEPS_OUT_DIR/$lib"
|
||||
printf "%s %s - already cached\n" "$script" "$lib"
|
||||
else
|
||||
HAS_ALL_DEPS=0
|
||||
break
|
||||
fi
|
||||
HAS_ALL_DEPS=0
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ "$HAS_ALL_DEPS" == "1" ]; then
|
||||
@@ -65,34 +41,27 @@ dep() {
|
||||
set +e
|
||||
bash "$SCRIPT_DIR/build-$script.sh"
|
||||
EXIT=$?
|
||||
set -e
|
||||
|
||||
if [ "$EXIT" -ne 0 ]; then
|
||||
printf "Failed to build %s\n" "$script"
|
||||
exit "$EXIT"
|
||||
fi
|
||||
|
||||
if [ "$CACHE" == "1" ]; then
|
||||
mkdir -p "$CACHE_DIR/$CACHE_KEY"
|
||||
for lib in "${@:2}"; do
|
||||
cp "$BUN_DEPS_OUT_DIR/$lib" "$CACHE_DIR/$CACHE_KEY/$lib"
|
||||
printf "%s %s - cached\n" "$script" "$lib"
|
||||
done
|
||||
fi
|
||||
set -e
|
||||
|
||||
BUILT_ANY=1
|
||||
}
|
||||
|
||||
dep boringssl boringssl libcrypto.a libssl.a libdecrepit.a
|
||||
dep c-ares cares libcares.a
|
||||
dep libarchive libarchive libarchive.a
|
||||
dep lol-html lolhtml liblolhtml.a
|
||||
dep mimalloc mimalloc-debug libmimalloc-debug.a libmimalloc-debug.o
|
||||
dep mimalloc mimalloc libmimalloc.a libmimalloc.o
|
||||
dep tinycc tinycc libtcc.a
|
||||
dep zlib zlib libz.a
|
||||
dep zstd zstd libzstd.a
|
||||
dep ls-hpack lshpack liblshpack.a
|
||||
dep boringssl libcrypto.a libssl.a libdecrepit.a
|
||||
dep cares libcares.a
|
||||
dep libarchive libarchive.a
|
||||
dep lolhtml liblolhtml.a
|
||||
dep mimalloc-debug libmimalloc-debug.a libmimalloc-debug.o
|
||||
dep mimalloc libmimalloc.a libmimalloc.o
|
||||
dep tinycc libtcc.a
|
||||
dep zlib libz.a
|
||||
dep zstd libzstd.a
|
||||
dep lshpack liblshpack.a
|
||||
|
||||
if [ "$BUILT_ANY" -eq 0 ]; then
|
||||
printf "(run with -f to rebuild)\n"
|
||||
|
||||
0
scripts/build-boringssl.ps1
Executable file → Normal file
0
scripts/build-boringssl.ps1
Executable file → Normal file
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
set -exo pipefail
|
||||
set -euxo pipefail
|
||||
source $(dirname -- "${BASH_SOURCE[0]}")/env.sh
|
||||
|
||||
cd $BUN_DEPS_DIR/boringssl
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
param (
|
||||
[switch] $Baseline = $False,
|
||||
[switch] $Fast = $False
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop' # Setting strict mode, similar to 'set -euo pipefail' in bash
|
||||
|
||||
$Tag = If ($Baseline) { "-Baseline" } Else { "" }
|
||||
$UseBaselineBuild = If ($Baseline) { "ON" } Else { "OFF" }
|
||||
$UseLto = If ($Fast) { "OFF" } Else { "ON" }
|
||||
|
||||
# $CANARY_REVISION = if (Test-Path build/.canary_revision) { Get-Content build/.canary_revision } else { "0" }
|
||||
$CANARY_REVISION = 0
|
||||
.\scripts\env.ps1 $Tag
|
||||
.\scripts\update-submodules.ps1
|
||||
.\scripts\build-libuv.ps1 -CloneOnly $True
|
||||
cd build
|
||||
|
||||
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release `
|
||||
-DNO_CODEGEN=0 `
|
||||
-DNO_CONFIGURE_DEPENDS=1 `
|
||||
"-DUSE_BASELINE_BUILD=${UseBaselineBuild}" `
|
||||
"-DUSE_LTO=${UseLto}" `
|
||||
"-DCANARY=${CANARY_REVISION}" `
|
||||
-DBUN_CPP_ONLY=1 $Flags
|
||||
if ($LASTEXITCODE -ne 0) { throw "CMake configuration failed" }
|
||||
|
||||
.\compile-cpp-only.ps1 -v
|
||||
if ($LASTEXITCODE -ne 0) { throw "C++ compilation failed" }
|
||||
@@ -1,48 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -exo pipefail
|
||||
source $(dirname -- "${BASH_SOURCE[0]}")/env.sh
|
||||
|
||||
export USE_LTO="${USE_LTO:-ON}"
|
||||
case "$(uname -m)" in
|
||||
aarch64|arm64)
|
||||
export CPU_TARGET="${CPU_TARGET:-native}"
|
||||
;;
|
||||
*)
|
||||
export CPU_TARGET="${CPU_TARGET:-haswell}"
|
||||
;;
|
||||
esac
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--fast|--no-lto)
|
||||
export USE_LTO="OFF"
|
||||
shift
|
||||
;;
|
||||
--baseline)
|
||||
export CPU_TARGET="nehalem"
|
||||
shift
|
||||
;;
|
||||
--cpu)
|
||||
export CPU_TARGET="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
*|-*|--*)
|
||||
echo "Unknown option $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
mkdir -p build
|
||||
cd build
|
||||
mkdir -p tmp_modules tmp_functions js codegen
|
||||
cmake .. \
|
||||
-GNinja \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DUSE_LTO=${USE_LTO} \
|
||||
-DCPU_TARGET=${CPU_TARGET} \
|
||||
-DBUN_CPP_ONLY=1 \
|
||||
-DNO_CONFIGURE_DEPENDS=1
|
||||
chmod +x ./compile-cpp-only.sh
|
||||
bash ./compile-cpp-only.sh -v
|
||||
@@ -1,95 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -exo pipefail
|
||||
source $(dirname -- "${BASH_SOURCE[0]}")/env.sh
|
||||
|
||||
cwd=$(pwd)
|
||||
zig=
|
||||
|
||||
if [[ "$CI" ]]; then
|
||||
# Since the zig build depends on files from the zig submodule,
|
||||
# make sure to update the submodule before building.
|
||||
git submodule update --init --recursive --progress --depth=1 --checkout src/deps/zig
|
||||
|
||||
# Also update the correct version of zig in the submodule.
|
||||
$(dirname -- "${BASH_SOURCE[0]}")/download-zig.sh
|
||||
fi
|
||||
|
||||
if [ -f "$cwd/.cache/zig/zig" ]; then
|
||||
zig="$cwd/.cache/zig/zig"
|
||||
else
|
||||
zig=$(which zig)
|
||||
fi
|
||||
|
||||
ZIG_OPTIMIZE="${ZIG_OPTIMIZE:-ReleaseFast}"
|
||||
CANARY="${CANARY:-0}"
|
||||
GIT_SHA="${GIT_SHA:-$(git rev-parse HEAD)}"
|
||||
|
||||
BUILD_MACHINE_ARCH="${BUILD_MACHINE_ARCH:-$(uname -m)}"
|
||||
DOCKER_MACHINE_ARCH=""
|
||||
if [[ "$BUILD_MACHINE_ARCH" == "x86_64" || "$BUILD_MACHINE_ARCH" == "amd64" ]]; then
|
||||
BUILD_MACHINE_ARCH="x86_64"
|
||||
DOCKER_MACHINE_ARCH="amd64"
|
||||
elif [[ "$BUILD_MACHINE_ARCH" == "aarch64" || "$BUILD_MACHINE_ARCH" == "arm64" ]]; then
|
||||
BUILD_MACHINE_ARCH="aarch64"
|
||||
DOCKER_MACHINE_ARCH="arm64"
|
||||
fi
|
||||
|
||||
TARGET_OS="${1:-linux}"
|
||||
TARGET_ARCH="${2:-x64}"
|
||||
TARGET_CPU="${3:-${CPU_TARGET:-native}}"
|
||||
|
||||
BUILDARCH=""
|
||||
if [[ "$TARGET_ARCH" == "x64" || "$TARGET_ARCH" == "x86_64" || "$TARGET_ARCH" == "amd64" ]]; then
|
||||
TARGET_ARCH="x86_64"
|
||||
BUILDARCH="amd64"
|
||||
elif [[ "$TARGET_ARCH" == "aarch64" || "$TARGET_ARCH" == "arm64" ]]; then
|
||||
TARGET_ARCH="aarch64"
|
||||
BUILDARCH="arm64"
|
||||
fi
|
||||
|
||||
TRIPLET=""
|
||||
if [[ "$TARGET_OS" == "linux" ]]; then
|
||||
TRIPLET="$TARGET_ARCH-linux-gnu"
|
||||
elif [[ "$TARGET_OS" == "darwin" ]]; then
|
||||
TRIPLET="$TARGET_ARCH-macos-none"
|
||||
elif [[ "$TARGET_OS" == "windows" ]]; then
|
||||
TRIPLET="$TARGET_ARCH-windows-msvc"
|
||||
fi
|
||||
|
||||
echo "--- Building identifier-cache"
|
||||
$zig run src/js_lexer/identifier_data.zig
|
||||
|
||||
echo "--- Building node-fallbacks"
|
||||
cd src/node-fallbacks
|
||||
bun install --frozen-lockfile
|
||||
bun run build
|
||||
cd "$cwd"
|
||||
|
||||
echo "--- Building codegen"
|
||||
bun install --frozen-lockfile
|
||||
make runtime_js fallback_decoder bun_error
|
||||
|
||||
echo "--- Building modules"
|
||||
mkdir -p build
|
||||
bun run src/codegen/bundle-modules.ts --debug=OFF build
|
||||
|
||||
echo "--- Building zig"
|
||||
cd build
|
||||
cmake .. \
|
||||
-GNinja \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DUSE_LTO=ON \
|
||||
-DZIG_OPTIMIZE="${ZIG_OPTIMIZE}" \
|
||||
-DGIT_SHA="${GIT_SHA}" \
|
||||
-DARCH="${TARGET_ARCH}" \
|
||||
-DBUILDARCH="${BUILDARCH}" \
|
||||
-DCPU_TARGET="${TARGET_CPU}" \
|
||||
-DZIG_TARGET="${TRIPLET}" \
|
||||
-DASSERTIONS="OFF" \
|
||||
-DWEBKIT_DIR="omit" \
|
||||
-DNO_CONFIGURE_DEPENDS=1 \
|
||||
-DNO_CODEGEN=1 \
|
||||
-DBUN_ZIG_OBJ_DIR="$cwd/build" \
|
||||
-DCANARY="$CANARY" \
|
||||
-DZIG_LIB_DIR=src/deps/zig/lib
|
||||
ONLY_ZIG=1 ninja "$cwd/build/bun-zig.o" -v
|
||||
0
scripts/build-cares.ps1
Executable file → Normal file
0
scripts/build-cares.ps1
Executable file → Normal file
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
set -exo pipefail
|
||||
set -euxo pipefail
|
||||
source $(dirname -- "${BASH_SOURCE[0]}")/env.sh
|
||||
|
||||
cd $BUN_DEPS_DIR/c-ares
|
||||
|
||||
0
scripts/build-libarchive.ps1
Executable file → Normal file
0
scripts/build-libarchive.ps1
Executable file → Normal file
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
set -exo pipefail
|
||||
set -euxo pipefail
|
||||
source $(dirname -- "${BASH_SOURCE[0]}")/env.sh
|
||||
|
||||
mkdir -p $BUN_DEPS_OUT_DIR
|
||||
|
||||
0
scripts/build-libuv.ps1
Executable file → Normal file
0
scripts/build-libuv.ps1
Executable file → Normal file
0
scripts/build-lolhtml.ps1
Executable file → Normal file
0
scripts/build-lolhtml.ps1
Executable file → Normal file
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
set -exo pipefail
|
||||
set -euxo pipefail
|
||||
source $(dirname -- "${BASH_SOURCE[0]}")/env.sh
|
||||
|
||||
cd $BUN_DEPS_DIR/lol-html/c-api
|
||||
|
||||
0
scripts/build-lshpack.ps1
Executable file → Normal file
0
scripts/build-lshpack.ps1
Executable file → Normal file
2
scripts/build-lshpack.sh
Executable file → Normal file
2
scripts/build-lshpack.sh
Executable file → Normal file
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
set -exo pipefail
|
||||
set -euxo pipefail
|
||||
source $(dirname -- "${BASH_SOURCE[0]}")/env.sh
|
||||
|
||||
mkdir -p $BUN_DEPS_OUT_DIR
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
set -exo pipefail
|
||||
set -euxo pipefail
|
||||
source "$(dirname -- "${BASH_SOURCE[0]}")/env.sh"
|
||||
|
||||
MIMALLOC_OVERRIDE_FLAG=${MIMALLOC_OVERRIDE_FLAG:-}
|
||||
|
||||
0
scripts/build-mimalloc.ps1
Executable file → Normal file
0
scripts/build-mimalloc.ps1
Executable file → Normal file
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
set -exo pipefail
|
||||
set -euxo pipefail
|
||||
source "$(dirname -- "${BASH_SOURCE[0]}")/env.sh"
|
||||
|
||||
MIMALLOC_OVERRIDE_FLAG=${MIMALLOC_OVERRIDE_FLAG:-}
|
||||
|
||||
2
scripts/build-tinycc.ps1
Executable file → Normal file
2
scripts/build-tinycc.ps1
Executable file → Normal file
@@ -24,7 +24,7 @@ try {
|
||||
|
||||
# TODO: -MT
|
||||
Run clang-cl @($env:CFLAGS -split ' ') libtcc.c -o tcc.obj "-DTCC_TARGET_PE" "-DTCC_TARGET_X86_64" "-O2" "-W2" "-Zi" "-MD" "-GS-" "-c"
|
||||
Run llvm-lib "tcc.obj" "-OUT:tcc.lib"
|
||||
Run lib "tcc.obj" "-OUT:tcc.lib"
|
||||
|
||||
Copy-Item tcc.obj $BUN_DEPS_OUT_DIR/tcc.lib
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
set -exo pipefail
|
||||
set -euxo pipefail
|
||||
source $(dirname -- "${BASH_SOURCE[0]}")/env.sh
|
||||
|
||||
mkdir -p $BUN_DEPS_OUT_DIR
|
||||
|
||||
0
scripts/build-zlib.ps1
Executable file → Normal file
0
scripts/build-zlib.ps1
Executable file → Normal file
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
set -exo pipefail
|
||||
set -euxo pipefail
|
||||
source $(dirname -- "${BASH_SOURCE[0]}")/env.sh
|
||||
|
||||
mkdir -p $BUN_DEPS_OUT_DIR
|
||||
|
||||
0
scripts/build-zstd.ps1
Executable file → Normal file
0
scripts/build-zstd.ps1
Executable file → Normal file
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
set -exo pipefail
|
||||
set -euxo pipefail
|
||||
source $(dirname -- "${BASH_SOURCE[0]}")/env.sh
|
||||
|
||||
mkdir -p $BUN_DEPS_OUT_DIR
|
||||
|
||||
0
scripts/build.ps1
Executable file → Normal file
0
scripts/build.ps1
Executable file → Normal file
@@ -1,59 +0,0 @@
|
||||
param (
|
||||
[switch] $Baseline = $False,
|
||||
[switch] $Fast = $False
|
||||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop' # Setting strict mode, similar to 'set -euo pipefail' in bash
|
||||
|
||||
$Target = If ($Baseline) { "windows-x64-baseline" } Else { "windows-x64" }
|
||||
$Tag = "bun-$Target"
|
||||
$TagSuffix = If ($Baseline) { "-Baseline" } Else { "" }
|
||||
$UseBaselineBuild = If ($Baseline) { "ON" } Else { "OFF" }
|
||||
$UseLto = If ($Fast) { "OFF" } Else { "ON" }
|
||||
|
||||
.\scripts\env.ps1 $TagSuffix
|
||||
|
||||
mkdir -Force build
|
||||
buildkite-agent artifact download "**" build --step "${Target}-build-zig"
|
||||
buildkite-agent artifact download "**" build --step "${Target}-build-cpp"
|
||||
buildkite-agent artifact download "**" build --step "${Target}-build-deps"
|
||||
mv -Force -ErrorAction SilentlyContinue build\build\bun-deps\* build\bun-deps
|
||||
mv -Force -ErrorAction SilentlyContinue build\build\* build
|
||||
|
||||
Set-Location build
|
||||
$CANARY_REVISION = 0
|
||||
cmake .. -G Ninja -DCMAKE_BUILD_TYPE=Release `
|
||||
-DNO_CODEGEN=1 `
|
||||
-DNO_CONFIGURE_DEPENDS=1 `
|
||||
"-DCPU_TARGET=${CPU_TARGET}" `
|
||||
"-DCANARY=${CANARY_REVISION}" `
|
||||
-DBUN_LINK_ONLY=1 `
|
||||
"-DUSE_BASELINE_BUILD=${UseBaselineBuild}" `
|
||||
"-DUSE_LTO=${UseLto}" `
|
||||
"-DBUN_DEPS_OUT_DIR=$(Resolve-Path bun-deps)" `
|
||||
"-DBUN_CPP_ARCHIVE=$(Resolve-Path bun-cpp-objects.a)" `
|
||||
"-DBUN_ZIG_OBJ_DIR=$(Resolve-Path .)" `
|
||||
"$Flags"
|
||||
if ($LASTEXITCODE -ne 0) { throw "CMake configuration failed" }
|
||||
|
||||
ninja -v
|
||||
if ($LASTEXITCODE -ne 0) { throw "Link failed!" }
|
||||
|
||||
ls
|
||||
if ($Fast) {
|
||||
$Tag = "$Tag-nolto"
|
||||
}
|
||||
|
||||
Set-Location ..
|
||||
$Dist = mkdir -Force "${Tag}"
|
||||
cp -r build\bun.exe "$Dist\bun.exe"
|
||||
Compress-Archive -Force "$Dist" "${Dist}.zip"
|
||||
$Dist = "$Dist-profile"
|
||||
MkDir -Force "$Dist"
|
||||
cp -r build\bun.exe "$Dist\bun.exe"
|
||||
cp -r build\bun.pdb "$Dist\bun.pdb"
|
||||
Compress-Archive -Force "$Dist" "$Dist.zip"
|
||||
|
||||
$env:BUN_GARBAGE_COLLECTOR_LEVEL = "1"
|
||||
$env:BUN_FEATURE_FLAG_INTERNAL_FOR_TESTING = "1"
|
||||
.\build\bun.exe --print "JSON.stringify(require('bun:internal-for-testing').crash_handler.getFeatureData())" > .\features.json
|
||||
@@ -1,80 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -exo pipefail
|
||||
source $(dirname -- "${BASH_SOURCE[0]}")/env.sh
|
||||
|
||||
export USE_LTO="${USE_LTO:-ON}"
|
||||
case "$(uname -m)" in
|
||||
aarch64|arm64)
|
||||
export CPU_TARGET="${CPU_TARGET:-native}"
|
||||
;;
|
||||
*)
|
||||
export CPU_TARGET="${CPU_TARGET:-haswell}"
|
||||
;;
|
||||
esac
|
||||
|
||||
export TAG=""
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--tag)
|
||||
export TAG="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
--fast|--no-lto)
|
||||
export USE_LTO="OFF"
|
||||
shift
|
||||
;;
|
||||
--baseline)
|
||||
export CPU_TARGET="nehalem"
|
||||
shift
|
||||
;;
|
||||
--cpu)
|
||||
export CPU_TARGET="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
*|-*|--*)
|
||||
echo "Unknown option $1"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ -z "$TAG" ]]; then
|
||||
echo "--tag <name> is required"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -rf release
|
||||
mkdir -p release
|
||||
buildkite-agent artifact download '**' release --step $TAG-build-deps
|
||||
buildkite-agent artifact download '**' release --step $TAG-build-zig
|
||||
buildkite-agent artifact download '**' release --step $TAG-build-cpp
|
||||
|
||||
cd release
|
||||
cmake .. \
|
||||
-GNinja \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DCPU_TARGET=${CPU_TARGET} \
|
||||
-DUSE_LTO=${USE_LTO} \
|
||||
-DBUN_LINK_ONLY=1 \
|
||||
-DBUN_ZIG_OBJ_DIR="$(pwd)/build" \
|
||||
-DBUN_CPP_ARCHIVE="$(pwd)/build/bun-cpp-objects.a" \
|
||||
-DBUN_DEPS_OUT_DIR="$(pwd)/build/bun-deps" \
|
||||
-DNO_CONFIGURE_DEPENDS=1
|
||||
ninja -v
|
||||
|
||||
if [[ "${USE_LTO}" == "OFF" ]]; then
|
||||
TAG="${TAG}-nolto"
|
||||
fi
|
||||
|
||||
chmod +x bun-profile bun
|
||||
mkdir -p bun-$TAG-profile/ bun-$TAG/
|
||||
mv bun-profile bun-$TAG-profile/bun-profile
|
||||
mv bun bun-$TAG/bun
|
||||
zip -r bun-$TAG-profile.zip bun-$TAG-profile
|
||||
zip -r bun-$TAG.zip bun-$TAG
|
||||
|
||||
cd ..
|
||||
mv release/bun-$TAG.zip bun-$TAG.zip
|
||||
mv release/bun-$TAG-profile.zip bun-$TAG-profile.zip
|
||||
0
scripts/clean-dependencies.ps1
Executable file → Normal file
0
scripts/clean-dependencies.ps1
Executable file → Normal file
0
scripts/download-webkit.ps1
Executable file → Normal file
0
scripts/download-webkit.ps1
Executable file → Normal file
0
scripts/download-webkit.sh
Executable file → Normal file
0
scripts/download-webkit.sh
Executable file → Normal file
2
scripts/download-zig.ps1
Executable file → Normal file
2
scripts/download-zig.ps1
Executable file → Normal file
@@ -23,7 +23,7 @@ try {
|
||||
if (!(Test-Path $TarPath)) {
|
||||
try {
|
||||
Write-Host "-- Downloading Zig"
|
||||
Invoke-RestMethod $Url -OutFile $TarPath
|
||||
Invoke-WebRequest $Url -OutFile $TarPath
|
||||
} catch {
|
||||
Write-Error "Failed to fetch Zig from: $Url"
|
||||
throw $_
|
||||
|
||||
0
scripts/download-zls.ps1
Executable file → Normal file
0
scripts/download-zls.ps1
Executable file → Normal file
45
scripts/env.ps1
Executable file → Normal file
45
scripts/env.ps1
Executable file → Normal file
@@ -20,12 +20,8 @@ if ($env:VSINSTALLDIR -eq $null) {
|
||||
}
|
||||
$vsDir = (& $vswhere -prerelease -latest -property installationPath)
|
||||
if ($vsDir -eq $null) {
|
||||
$vsDir = Get-ChildItem -Path "C:\Program Files\Microsoft Visual Studio\2022" -Directory
|
||||
if ($vsDir -eq $null) {
|
||||
throw "Visual Studio directory not found."
|
||||
}
|
||||
$vsDir = $vsDir.FullName;
|
||||
}
|
||||
throw "Visual Studio directory not found."
|
||||
}
|
||||
Push-Location $vsDir
|
||||
try {
|
||||
Import-Module 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\Microsoft.VisualStudio.DevShell.dll'
|
||||
@@ -45,25 +41,19 @@ $ENV:BUN_DEV_ENV_SET = "Baseline=$Baseline";
|
||||
|
||||
$BUN_BASE_DIR = if ($env:BUN_BASE_DIR) { $env:BUN_BASE_DIR } else { Join-Path $ScriptDir '..' }
|
||||
$BUN_DEPS_DIR = if ($env:BUN_DEPS_DIR) { $env:BUN_DEPS_DIR } else { Join-Path $BUN_BASE_DIR 'src\deps' }
|
||||
$BUN_DEPS_OUT_DIR = if ($env:BUN_DEPS_OUT_DIR) { $env:BUN_DEPS_OUT_DIR } else { Join-Path $BUN_BASE_DIR 'build\bun-deps' }
|
||||
$BUN_DEPS_OUT_DIR = if ($env:BUN_DEPS_OUT_DIR) { $env:BUN_DEPS_OUT_DIR } else { $BUN_DEPS_DIR }
|
||||
|
||||
$CPUS = if ($env:CPUS) { $env:CPUS } else { (Get-CimInstance -Class Win32_Processor).NumberOfCores }
|
||||
|
||||
$CC = "clang-cl"
|
||||
$CXX = "clang-cl"
|
||||
|
||||
$CFLAGS = '/O2 /Zi '
|
||||
# $CFLAGS = '/O2 /Z7 /MT'
|
||||
$CXXFLAGS = '/O2 /Zi '
|
||||
# $CXXFLAGS = '/O2 /Z7 /MT'
|
||||
|
||||
if ($env:USE_LTO -eq "1") {
|
||||
$CXXFLAGS += " -fuse-ld=lld -flto -Xclang -emit-llvm-bc "
|
||||
$CFLAGS += " -fuse-ld=lld -flto -Xclang -emit-llvm-bc "
|
||||
}
|
||||
$CFLAGS = '/O2'
|
||||
# $CFLAGS = '/O2 /MT'
|
||||
$CXXFLAGS = '/O2'
|
||||
# $CXXFLAGS = '/O2 /MT'
|
||||
|
||||
$CPU_NAME = if ($Baseline) { "nehalem" } else { "haswell" };
|
||||
$env:CPU_TARGET = $CPU_NAME
|
||||
|
||||
$CFLAGS += " -march=${CPU_NAME}"
|
||||
$CXXFLAGS += " -march=${CPU_NAME}"
|
||||
@@ -76,15 +66,6 @@ $CMAKE_FLAGS = @(
|
||||
"-DCMAKE_C_FLAGS=$CFLAGS",
|
||||
"-DCMAKE_CXX_FLAGS=$CXXFLAGS"
|
||||
)
|
||||
|
||||
if ($env:USE_LTO -eq "1") {
|
||||
if (Get-Command lld-lib -ErrorAction SilentlyContinue) {
|
||||
$AR = Get-Command lld-lib -ErrorAction SilentlyContinue
|
||||
$env:AR = $AR
|
||||
$CMAKE_FLAGS += "-DCMAKE_AR=$AR"
|
||||
}
|
||||
}
|
||||
|
||||
$env:CC = "clang-cl"
|
||||
$env:CXX = "clang-cl"
|
||||
$env:CFLAGS = $CFLAGS
|
||||
@@ -95,16 +76,6 @@ if ($Baseline) {
|
||||
$CMAKE_FLAGS += "-DUSE_BASELINE_BUILD=ON"
|
||||
}
|
||||
|
||||
if (Get-Command sccache -ErrorAction SilentlyContinue) {
|
||||
# Continue with local compiler if sccache has an error
|
||||
$env:SCCACHE_IGNORE_SERVER_IO_ERROR = "1"
|
||||
|
||||
$CMAKE_FLAGS += "-DCMAKE_C_COMPILER_LAUNCHER=sccache"
|
||||
$CMAKE_FLAGS += "-DCMAKE_CXX_COMPILER_LAUNCHER=sccache"
|
||||
$CMAKE_FLAGS += "-DCMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded"
|
||||
$CMAKE_FLAGS += "-DCMAKE_POLICY_CMP0141=NEW"
|
||||
}
|
||||
|
||||
$null = New-Item -ItemType Directory -Force -Path $BUN_DEPS_OUT_DIR
|
||||
|
||||
function Run() {
|
||||
@@ -128,4 +99,4 @@ function Run() {
|
||||
if ($result -ne 0) {
|
||||
throw "$command $commandArgs exited with code $result."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Hack for Buildkite sometimes not having the right path
|
||||
if [[ "${CI:-}" == "1" || "${CI:-}" == "true" ]]; then
|
||||
if [ -f ~/.bashrc ]; then
|
||||
source ~/.bashrc
|
||||
fi
|
||||
fi
|
||||
|
||||
# this is the environment script for building bun's dependencies
|
||||
# it sets c compiler and flags
|
||||
export SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||
export BUN_BASE_DIR=${BUN_BASE_DIR:-$(cd $SCRIPT_DIR && cd .. && pwd)}
|
||||
export BUN_DEPS_DIR=${BUN_DEPS_DIR:-$BUN_BASE_DIR/src/deps}
|
||||
export BUN_DEPS_OUT_DIR=${BUN_DEPS_OUT_DIR:-$BUN_BASE_DIR/build/bun-deps}
|
||||
export BUN_DEPS_DIR=${BUN_DEPS_DIR:-$BUN_BASE_DIR/src/deps/}
|
||||
export BUN_DEPS_OUT_DIR=${BUN_DEPS_OUT_DIR:-$BUN_BASE_DIR/src/deps/}
|
||||
|
||||
# Silence a perl script warning
|
||||
export LC_CTYPE="en_US.UTF-8"
|
||||
@@ -31,28 +23,20 @@ export CFLAGS='-O3 -fno-exceptions -fvisibility=hidden -fvisibility-inlines-hidd
|
||||
export CXXFLAGS='-O3 -fno-exceptions -fno-rtti -fvisibility=hidden -fvisibility-inlines-hidden -mno-omit-leaf-frame-pointer -fno-omit-frame-pointer'
|
||||
|
||||
export CMAKE_FLAGS=(
|
||||
-DCMAKE_C_COMPILER="${CC}"
|
||||
-DCMAKE_CXX_COMPILER="${CXX}"
|
||||
-DCMAKE_C_FLAGS="$CFLAGS"
|
||||
-DCMAKE_CXX_FLAGS="$CXXFLAGS"
|
||||
-DCMAKE_BUILD_TYPE=Release
|
||||
-DCMAKE_CXX_STANDARD=20
|
||||
-DCMAKE_C_STANDARD=17
|
||||
-DCMAKE_CXX_STANDARD_REQUIRED=ON
|
||||
-DCMAKE_C_STANDARD_REQUIRED=ON
|
||||
-DCMAKE_C_COMPILER="${CC}"
|
||||
-DCMAKE_CXX_COMPILER="${CXX}"
|
||||
-DCMAKE_C_FLAGS="$CFLAGS"
|
||||
-DCMAKE_CXX_FLAGS="$CXXFLAGS"
|
||||
-DCMAKE_BUILD_TYPE=Release
|
||||
-DCMAKE_CXX_STANDARD=20
|
||||
-DCMAKE_C_STANDARD=17
|
||||
-DCMAKE_CXX_STANDARD_REQUIRED=ON
|
||||
-DCMAKE_C_STANDARD_REQUIRED=ON
|
||||
)
|
||||
|
||||
CCACHE=$(which ccache || which sccache || echo "")
|
||||
if [ -f "$CCACHE" ]; then
|
||||
CMAKE_FLAGS+=(
|
||||
-DCMAKE_C_COMPILER_LAUNCHER="$CCACHE"
|
||||
-DCMAKE_CXX_COMPILER_LAUNCHER="$CCACHE"
|
||||
)
|
||||
fi
|
||||
|
||||
if [[ $(uname -s) == 'Linux' ]]; then
|
||||
# Ensure we always use -std=gnu++20 on Linux
|
||||
CMAKE_FLAGS+=(-DCMAKE_CXX_EXTENSIONS=ON)
|
||||
# Ensure we always use -std=gnu++20 on Linux
|
||||
export CMAKE_FLAGS+=(-DCMAKE_CXX_EXTENSIONS=ON)
|
||||
fi
|
||||
|
||||
if [[ $(uname -s) == 'Darwin' ]]; then
|
||||
@@ -68,10 +52,7 @@ mkdir -p $BUN_DEPS_OUT_DIR
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
echo "C Compiler: ${CC}"
|
||||
echo "C++ Compiler: ${CXX}"
|
||||
if [ -n "$CCACHE" ]; then
|
||||
echo "Ccache: ${CCACHE}"
|
||||
fi
|
||||
if [[ $(uname -s) == 'Darwin' ]]; then
|
||||
echo "OSX Deployment Target: ${CMAKE_OSX_DEPLOYMENT_TARGET}"
|
||||
echo "OSX Deployment Target: ${CMAKE_OSX_DEPLOYMENT_TARGET}"
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -1,300 +0,0 @@
|
||||
#! /usr/bin/env node
|
||||
|
||||
import {} from "node:fs/promises";
|
||||
import { spawn, spawnSync } from "node:child_process";
|
||||
import { copyFileSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
||||
import { basename, dirname, join } from "node:path";
|
||||
import { tmpdir } from "node:os";
|
||||
|
||||
const projectPath = dirname(import.meta.dirname);
|
||||
const vendorPath = process.env.BUN_VENDOR_PATH || join(projectPath, "vendor");
|
||||
|
||||
const isWindows = process.platform === "win32";
|
||||
const isMacOS = process.platform === "darwin";
|
||||
const isLinux = process.platform === "linux";
|
||||
|
||||
const spawnSyncTimeout = 1000 * 60;
|
||||
const spawnTimeout = 1000 * 60 * 3;
|
||||
|
||||
async function spawnSafe(command, args, options = {}) {
|
||||
const result = new Promise((resolve, reject) => {
|
||||
let stdout = "";
|
||||
let stderr = "";
|
||||
let subprocess;
|
||||
try {
|
||||
subprocess = spawn(command, args, {
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
timeout: spawnTimeout,
|
||||
...options,
|
||||
});
|
||||
subprocess.on("error", reject);
|
||||
subprocess.on("exit", (exitCode, signalCode) => {
|
||||
if (exitCode !== 0 || signalCode) {
|
||||
const reason = signalCode || `code ${exitCode}`;
|
||||
const cause = stderr || stdout;
|
||||
reject(new Error(`Process exited with ${reason}`, { cause }));
|
||||
} else {
|
||||
resolve({ exitCode, signalCode, stdout, stderr });
|
||||
}
|
||||
});
|
||||
subprocess?.stdout?.on("data", chunk => {
|
||||
process.stdout.write(chunk);
|
||||
stdout += chunk.toString("utf-8");
|
||||
});
|
||||
subprocess?.stderr?.on("data", chunk => {
|
||||
process.stderr.write(chunk);
|
||||
stderr += chunk.toString("utf-8");
|
||||
});
|
||||
} catch (cause) {
|
||||
reject(cause);
|
||||
}
|
||||
});
|
||||
try {
|
||||
return await result;
|
||||
} catch (cause) {
|
||||
if (options.throwOnError === false) {
|
||||
return;
|
||||
}
|
||||
const description = `${command} ${args.join(" ")}`;
|
||||
throw new Error(`Command failed: ${description}`, { cause });
|
||||
}
|
||||
}
|
||||
|
||||
function spawnSyncSafe(command, args, options = {}) {
|
||||
try {
|
||||
const { error, status, signal, stdout, stderr } = spawnSync(command, args, {
|
||||
stdio: ["ignore", "pipe", "pipe"],
|
||||
encoding: "utf-8",
|
||||
timeout: spawnSyncTimeout,
|
||||
...options,
|
||||
});
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
if (signal || status !== 0) {
|
||||
const reason = signal || `code ${status}`;
|
||||
const cause = stderr || stdout;
|
||||
throw new Error(`Process exited with ${reason}`, { cause });
|
||||
}
|
||||
return stdout;
|
||||
} catch (cause) {
|
||||
if (options.throwOnError === false) {
|
||||
return;
|
||||
}
|
||||
const description = `${command} ${args.join(" ")}`;
|
||||
throw new Error(`Command failed: ${description}`, { cause });
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchSafe(url, options = {}) {
|
||||
let response;
|
||||
try {
|
||||
response = await fetch(url, options);
|
||||
if (!response.ok) {
|
||||
const { status, statusText } = response;
|
||||
const body = await response.text();
|
||||
throw new Error(`${status} ${statusText}`, { cause: body });
|
||||
}
|
||||
switch (options.format) {
|
||||
case "json":
|
||||
return await response.json();
|
||||
case "text":
|
||||
return await response.text();
|
||||
case "bytes":
|
||||
return new Uint8Array(await response.arrayBuffer());
|
||||
default:
|
||||
return response;
|
||||
}
|
||||
} catch (cause) {
|
||||
if (options.throwOnError === false) {
|
||||
return response;
|
||||
}
|
||||
throw new Error(`Fetch failed: ${url}`, { cause });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} command
|
||||
* @param {string} [path]
|
||||
* @returns {string | undefined}
|
||||
*/
|
||||
function which(command, path) {
|
||||
const cmd = isWindows ? "where" : "which";
|
||||
const result = spawnSyncSafe(cmd, [command], {
|
||||
throwOnError: false,
|
||||
env: {
|
||||
PATH: path || process.env.PATH,
|
||||
},
|
||||
});
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
if (isWindows) {
|
||||
// On Windows, multiple paths can be returned from `where`.
|
||||
for (const line of result.split("\r\n")) {
|
||||
return line;
|
||||
}
|
||||
}
|
||||
return result.trimEnd();
|
||||
}
|
||||
|
||||
function getZigTarget(os = process.platform, arch = process.arch) {
|
||||
if (arch === "x64") {
|
||||
if (os === "linux") return "linux-x86_64";
|
||||
if (os === "darwin") return "macos-x86_64";
|
||||
if (os === "win32") return "windows-x86_64";
|
||||
}
|
||||
if (arch === "arm64") {
|
||||
if (os === "linux") return "linux-aarch64";
|
||||
if (os === "darwin") return "macos-aarch64";
|
||||
}
|
||||
throw new Error(`Unsupported zig target: os=${os}, arch=${arch}`);
|
||||
}
|
||||
|
||||
function getRecommendedZigVersion() {
|
||||
const scriptPath = join(projectPath, "build.zig");
|
||||
try {
|
||||
const scriptContent = readFileSync(scriptPath, "utf-8");
|
||||
const match = scriptContent.match(/recommended_zig_version = "([^"]+)"/);
|
||||
if (!match) {
|
||||
throw new Error("File does not contain string: 'recommended_zig_version'");
|
||||
}
|
||||
return match[1];
|
||||
} catch (cause) {
|
||||
throw new Error("Failed to find recommended Zig version", { cause });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
async function getLatestZigVersion() {
|
||||
try {
|
||||
const response = await fetchSafe("https://ziglang.org/download/index.json", { format: "json" });
|
||||
const { master } = response;
|
||||
const { version } = master;
|
||||
return version;
|
||||
} catch (cause) {
|
||||
throw new Error("Failed to get latest Zig version", { cause });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} execPath
|
||||
* @returns {string | undefined}
|
||||
*/
|
||||
function getVersion(execPath) {
|
||||
const args = /(?:zig)(?:\.exe)?/i.test(execPath) ? ["version"] : ["--version"];
|
||||
const result = spawnSyncSafe(execPath, args, { throwOnError: false });
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
return result.trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
function getTmpdir() {
|
||||
if (isMacOS && existsSync("/tmp")) {
|
||||
return "/tmp";
|
||||
}
|
||||
return tmpdir();
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string}
|
||||
*/
|
||||
function mkTmpdir() {
|
||||
return mkdtempSync(join(getTmpdir(), "bun-"));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} url
|
||||
* @param {string} [path]
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
async function downloadFile(url, path) {
|
||||
const outPath = path || join(mkTmpdir(), basename(url));
|
||||
const bytes = await fetchSafe(url, { format: "bytes" });
|
||||
mkdirSync(dirname(outPath), { recursive: true });
|
||||
writeFileSync(outPath, bytes);
|
||||
return outPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} tarPath
|
||||
* @param {string} [path]
|
||||
* @returns {Promise<string>}
|
||||
*/
|
||||
async function extractFile(tarPath, path) {
|
||||
const outPath = path || join(mkTmpdir(), basename(tarPath));
|
||||
mkdirSync(outPath, { recursive: true });
|
||||
await spawnSafe("tar", ["-xf", tarPath, "-C", outPath, "--strip-components=1"]);
|
||||
return outPath;
|
||||
}
|
||||
|
||||
const dependencies = [
|
||||
{
|
||||
name: "zig",
|
||||
version: getRecommendedZigVersion(),
|
||||
download: downloadZig,
|
||||
},
|
||||
];
|
||||
|
||||
async function getDependencyPath(name) {
|
||||
let dependency;
|
||||
for (const entry of dependencies) {
|
||||
if (name === entry.name) {
|
||||
dependency = entry;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!dependency) {
|
||||
throw new Error(`Unknown dependency: ${name}`);
|
||||
}
|
||||
const { version, download } = dependency;
|
||||
mkdirSync(vendorPath, { recursive: true });
|
||||
for (const path of readdirSync(vendorPath)) {
|
||||
if (!path.startsWith(name)) {
|
||||
continue;
|
||||
}
|
||||
const dependencyPath = join(vendorPath, path);
|
||||
const dependencyVersion = getVersion(dependencyPath);
|
||||
if (dependencyVersion === version) {
|
||||
return dependencyPath;
|
||||
}
|
||||
}
|
||||
if (!download) {
|
||||
throw new Error(`Dependency not found: ${name}`);
|
||||
}
|
||||
return await download(version);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} [version]
|
||||
*/
|
||||
async function downloadZig(version) {
|
||||
const target = getZigTarget();
|
||||
const expectedVersion = version || getRecommendedZigVersion();
|
||||
const url = `https://ziglang.org/builds/zig-${target}-${expectedVersion}.tar.xz`;
|
||||
const tarPath = await downloadFile(url);
|
||||
const extractedPath = await extractFile(tarPath);
|
||||
const zigPath = join(extractedPath, exePath("zig"));
|
||||
const actualVersion = getVersion(zigPath);
|
||||
const outPath = join(vendorPath, exePath(`zig-${actualVersion}`));
|
||||
mkdirSync(dirname(outPath), { recursive: true });
|
||||
copyFileSync(zigPath, outPath);
|
||||
return outPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} path
|
||||
* @returns {string}
|
||||
*/
|
||||
function exePath(path) {
|
||||
return isWindows ? `${path}.exe` : path;
|
||||
}
|
||||
|
||||
const execPath = await getDependencyPath("zig");
|
||||
console.log(execPath);
|
||||
@@ -2,7 +2,7 @@
|
||||
# this script is the magic script to configure your devenv for making a patch to WebKit
|
||||
# once you are done with the patch you can run this again with --undo
|
||||
# you can also run this with --danger-reset to force reset the submodule (danger)
|
||||
set -exo pipefail
|
||||
set -euo pipefail
|
||||
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
|
||||
0
scripts/internal-test.ps1
Executable file → Normal file
0
scripts/internal-test.ps1
Executable file → Normal file
0
scripts/make-old-js.ps1
Executable file → Normal file
0
scripts/make-old-js.ps1
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
0
scripts/set-webkit-submodule-to-cmake.ps1
Executable file → Normal file
0
scripts/set-webkit-submodule-to-cmake.ps1
Executable file → Normal file
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
set -exo pipefail
|
||||
set -euo pipefail
|
||||
|
||||
cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.."
|
||||
|
||||
|
||||
0
scripts/setup.ps1
Executable file → Normal file
0
scripts/setup.ps1
Executable file → Normal file
@@ -10,5 +10,5 @@ if ! [ "$1" == '--webkit' ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
set -exo pipefail
|
||||
set -euxo pipefail
|
||||
git submodule update --init --recursive --progress --depth=1 --checkout $NAMES
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
set -exo pipefail
|
||||
set -euxo pipefail
|
||||
|
||||
WEBKIT_VERSION=$(grep 'set(WEBKIT_TAG' "CMakeLists.txt" | awk '{print $2}' | cut -f 1 -d ')')
|
||||
WEBKIT_VERSION=$(git rev-parse HEAD:./src/bun.js/WebKit)
|
||||
MIMALLOC_VERSION=$(git rev-parse HEAD:./src/deps/mimalloc)
|
||||
LIBARCHIVE_VERSION=$(git rev-parse HEAD:./src/deps/libarchive)
|
||||
PICOHTTPPARSER_VERSION=$(git rev-parse HEAD:./src/deps/picohttpparser)
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
const std = @import("std");
|
||||
const bun = @import("root").bun;
|
||||
const assert = bun.assert;
|
||||
const assert = @import("root").bun.assert;
|
||||
const mem = std.mem;
|
||||
const Allocator = std.mem.Allocator;
|
||||
|
||||
|
||||
@@ -171,7 +171,18 @@ pub inline fn configureAllocator(_: AllocatorConfiguration) void {
|
||||
// if (!config.long_running) Mimalloc.mi_option_set(Mimalloc.mi_option_reset_delay, 0);
|
||||
}
|
||||
|
||||
pub const panic = Output.panic; // deprecated
|
||||
pub fn panic(comptime fmt: string, args: anytype) noreturn {
|
||||
@setCold(true);
|
||||
if (comptime Environment.isWasm) {
|
||||
Output.printErrorln(fmt, args);
|
||||
Output.flush();
|
||||
@panic(fmt);
|
||||
} else {
|
||||
Output.prettyErrorln(fmt, args);
|
||||
Output.flush();
|
||||
std.debug.panic(fmt, args);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn notimpl() noreturn {
|
||||
@setCold(true);
|
||||
|
||||
@@ -18,7 +18,7 @@ const std = @import("std");
|
||||
const builtin = @import("builtin");
|
||||
const windows = std.os.windows;
|
||||
const testing = std.testing;
|
||||
const assert = (std.debug).assert;
|
||||
const assert = std.debug.assert;
|
||||
const Progress = @This();
|
||||
|
||||
/// `null` if the current node (and its children) should
|
||||
@@ -246,7 +246,7 @@ fn clearWithHeldLock(p: *Progress, end_ptr: *usize) void {
|
||||
end += (std.fmt.bufPrint(p.output_buffer[end..], "\x1b[{d}D", .{p.columns_written}) catch unreachable).len;
|
||||
end += (std.fmt.bufPrint(p.output_buffer[end..], "\x1b[0K", .{}) catch unreachable).len;
|
||||
} else if (builtin.os.tag == .windows) winapi: {
|
||||
assert(p.is_windows_terminal);
|
||||
std.debug.assert(p.is_windows_terminal);
|
||||
|
||||
var info: windows.CONSOLE_SCREEN_BUFFER_INFO = undefined;
|
||||
if (windows.kernel32.GetConsoleScreenBufferInfo(file.handle, &info) != windows.TRUE) {
|
||||
@@ -357,7 +357,7 @@ fn refreshWithHeldLock(self: *Progress) void {
|
||||
|
||||
pub fn log(self: *Progress, comptime format: []const u8, args: anytype) void {
|
||||
const file = self.terminal orelse {
|
||||
(std.debug).print(format, args);
|
||||
std.debug.print(format, args);
|
||||
return;
|
||||
};
|
||||
self.refresh();
|
||||
|
||||
@@ -6,8 +6,7 @@ const mem = std.mem;
|
||||
const math = std.math;
|
||||
const testing = std.testing;
|
||||
|
||||
const bun = @import("root").bun;
|
||||
const assert = bun.assert;
|
||||
const assert = @import("root").bun.assert;
|
||||
|
||||
pub fn AutoHashMap(comptime K: type, comptime V: type, comptime max_load_percentage: comptime_int) type {
|
||||
return HashMap(K, V, std.hash_map.AutoContext(K), max_load_percentage);
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
const std = @import("std");
|
||||
const bun = @import("root").bun;
|
||||
const js_ast = bun.JSAst;
|
||||
|
||||
pub const Reader = struct {
|
||||
const Self = @This();
|
||||
@@ -2732,27 +2731,6 @@ pub const Api = struct {
|
||||
/// token
|
||||
token: []const u8,
|
||||
|
||||
pub fn dupe(this: NpmRegistry, allocator: std.mem.Allocator) NpmRegistry {
|
||||
const buf = allocator.alloc(u8, this.url.len + this.username.len + this.password.len + this.token.len) catch bun.outOfMemory();
|
||||
|
||||
var out: NpmRegistry = .{
|
||||
.url = "",
|
||||
.username = "",
|
||||
.password = "",
|
||||
.token = "",
|
||||
};
|
||||
|
||||
var i: usize = 0;
|
||||
inline for (std.meta.fields(NpmRegistry)) |field| {
|
||||
const field_value = @field(this, field.name);
|
||||
@memcpy(buf[i .. i + field_value.len], field_value);
|
||||
@field(&out, field.name) = buf[i .. i + field_value.len];
|
||||
i += field_value.len;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
pub fn decode(reader: anytype) anyerror!NpmRegistry {
|
||||
var this = std.mem.zeroes(NpmRegistry);
|
||||
|
||||
@@ -2769,101 +2747,14 @@ pub const Api = struct {
|
||||
try writer.writeValue(@TypeOf(this.password), this.password);
|
||||
try writer.writeValue(@TypeOf(this.token), this.token);
|
||||
}
|
||||
|
||||
pub const Parser = struct {
|
||||
log: *bun.logger.Log,
|
||||
source: *const bun.logger.Source,
|
||||
allocator: std.mem.Allocator,
|
||||
|
||||
fn addError(this: *Parser, loc: bun.logger.Loc, comptime text: []const u8) !void {
|
||||
this.log.addError(this.source, loc, text) catch unreachable;
|
||||
return error.ParserError;
|
||||
}
|
||||
|
||||
fn expectString(this: *Parser, expr: js_ast.Expr) !void {
|
||||
switch (expr.data) {
|
||||
.e_string, .e_utf8_string => {},
|
||||
else => {
|
||||
this.log.addErrorFmt(this.source, expr.loc, this.allocator, "expected string but received {}", .{
|
||||
@as(js_ast.Expr.Tag, expr.data),
|
||||
}) catch unreachable;
|
||||
return error.ParserError;
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
pub fn parseRegistryURLString(this: *Parser, str: *js_ast.E.String) !Api.NpmRegistry {
|
||||
return try this.parseRegistryURLStringImpl(str.data);
|
||||
}
|
||||
|
||||
pub fn parseRegistryURLStringImpl(this: *Parser, str: []const u8) !Api.NpmRegistry {
|
||||
const url = bun.URL.parse(str);
|
||||
var registry = std.mem.zeroes(Api.NpmRegistry);
|
||||
|
||||
// Token
|
||||
if (url.username.len == 0 and url.password.len > 0) {
|
||||
registry.token = url.password;
|
||||
registry.url = try std.fmt.allocPrint(this.allocator, "{s}://{}/{s}/", .{ url.displayProtocol(), url.displayHost(), std.mem.trim(u8, url.pathname, "/") });
|
||||
} else if (url.username.len > 0 and url.password.len > 0) {
|
||||
registry.username = url.username;
|
||||
registry.password = url.password;
|
||||
|
||||
registry.url = try std.fmt.allocPrint(this.allocator, "{s}://{}/{s}/", .{ url.displayProtocol(), url.displayHost(), std.mem.trim(u8, url.pathname, "/") });
|
||||
} else {
|
||||
// Do not include a trailing slash. There might be parameters at the end.
|
||||
registry.url = url.href;
|
||||
}
|
||||
|
||||
return registry;
|
||||
}
|
||||
|
||||
fn parseRegistryObject(this: *Parser, obj: *js_ast.E.Object) !Api.NpmRegistry {
|
||||
var registry = std.mem.zeroes(Api.NpmRegistry);
|
||||
|
||||
if (obj.get("url")) |url| {
|
||||
try this.expectString(url);
|
||||
const href = url.asString(this.allocator).?;
|
||||
// Do not include a trailing slash. There might be parameters at the end.
|
||||
registry.url = href;
|
||||
}
|
||||
|
||||
if (obj.get("username")) |username| {
|
||||
try this.expectString(username);
|
||||
registry.username = username.asString(this.allocator).?;
|
||||
}
|
||||
|
||||
if (obj.get("password")) |password| {
|
||||
try this.expectString(password);
|
||||
registry.password = password.asString(this.allocator).?;
|
||||
}
|
||||
|
||||
if (obj.get("token")) |token| {
|
||||
try this.expectString(token);
|
||||
registry.token = token.asString(this.allocator).?;
|
||||
}
|
||||
|
||||
return registry;
|
||||
}
|
||||
|
||||
pub fn parseRegistry(this: *Parser, expr: js_ast.Expr) !Api.NpmRegistry {
|
||||
switch (expr.data) {
|
||||
.e_string => |str| {
|
||||
return this.parseRegistryURLString(str);
|
||||
},
|
||||
.e_object => |obj| {
|
||||
return this.parseRegistryObject(obj);
|
||||
},
|
||||
else => {
|
||||
try this.addError(expr.loc, "Expected registry to be a URL string or an object");
|
||||
return std.mem.zeroes(Api.NpmRegistry);
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
pub const NpmRegistryMap = struct {
|
||||
scopes: bun.StringArrayHashMapUnmanaged(NpmRegistry) = .{},
|
||||
/// scopes
|
||||
scopes: []const []const u8,
|
||||
|
||||
/// registries
|
||||
registries: []const NpmRegistry,
|
||||
|
||||
pub fn decode(reader: anytype) anyerror!NpmRegistryMap {
|
||||
var this = std.mem.zeroes(NpmRegistryMap);
|
||||
@@ -2874,8 +2765,8 @@ pub const Api = struct {
|
||||
}
|
||||
|
||||
pub fn encode(this: *const @This(), writer: anytype) anyerror!void {
|
||||
try writer.writeArray([]const u8, this.scopes.keys());
|
||||
try writer.writeArray(NpmRegistry, this.scopes.values());
|
||||
try writer.writeArray([]const u8, this.scopes);
|
||||
try writer.writeArray(NpmRegistry, this.registries);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
131
src/ast/base.zig
131
src/ast/base.zig
@@ -2,10 +2,27 @@ const std = @import("std");
|
||||
const bun = @import("root").bun;
|
||||
const unicode = std.unicode;
|
||||
|
||||
pub const JavascriptString = []u16;
|
||||
pub fn newJavascriptString(comptime text: []const u8) JavascriptString {
|
||||
return unicode.utf8ToUtf16LeStringLiteral(text);
|
||||
}
|
||||
|
||||
pub const NodeIndex = u32;
|
||||
pub const NodeIndexNone = 4294967293;
|
||||
|
||||
// TODO: figure out if we actually need this
|
||||
// -- original comment --
|
||||
// Files are parsed in parallel for speed. We want to allow each parser to
|
||||
// generate symbol IDs that won't conflict with each other. We also want to be
|
||||
// able to quickly merge symbol tables from all files into one giant symbol
|
||||
// table.
|
||||
//
|
||||
// We can accomplish both goals by giving each symbol ID two parts: a source
|
||||
// index that is unique to the parser goroutine, and an inner index that
|
||||
// increments as the parser generates new symbol IDs. Then a symbol map can
|
||||
// be an array of arrays indexed first by source index, then by inner index.
|
||||
// The maps can be merged quickly by creating a single outer array containing
|
||||
// all inner arrays from all parsed files.
|
||||
|
||||
pub const RefHashCtx = struct {
|
||||
pub fn hash(_: @This(), key: Ref) u32 {
|
||||
@@ -27,6 +44,89 @@ pub const RefCtx = struct {
|
||||
}
|
||||
};
|
||||
|
||||
/// Sets the range of bits starting at `start_bit` upto and excluding `start_bit` + `number_of_bits`
|
||||
/// to be specific, if the range is N bits long, the N lower bits of `value` will be used; if any of
|
||||
/// the other bits in `value` are set to 1, this function will panic.
|
||||
///
|
||||
/// ```zig
|
||||
/// var val: u8 = 0b10000000;
|
||||
/// setBits(&val, 2, 4, 0b00001101);
|
||||
/// try testing.expectEqual(@as(u8, 0b10110100), val);
|
||||
/// ```
|
||||
///
|
||||
/// ## Panics
|
||||
/// This method will panic if the `value` exceeds the bit range of the type of `target`
|
||||
pub fn setBits(
|
||||
comptime TargetType: type,
|
||||
target: TargetType,
|
||||
comptime start_bit: comptime_int,
|
||||
comptime number_of_bits: comptime_int,
|
||||
value: TargetType,
|
||||
) TargetType {
|
||||
const end_bit = start_bit + number_of_bits;
|
||||
|
||||
comptime {
|
||||
if (number_of_bits == 0) @compileError("non-zero number_of_bits must be provided");
|
||||
|
||||
if (@typeInfo(TargetType) == .Int) {
|
||||
if (@typeInfo(TargetType).Int.signedness != .unsigned) {
|
||||
@compileError("requires an unsigned integer, found " ++ @typeName(TargetType));
|
||||
}
|
||||
if (start_bit >= @bitSizeOf(TargetType)) {
|
||||
@compileError("start_bit index is out of bounds of the bit field");
|
||||
}
|
||||
if (end_bit > @bitSizeOf(TargetType)) {
|
||||
@compileError("start_bit + number_of_bits is out of bounds of the bit field");
|
||||
}
|
||||
} else if (@typeInfo(TargetType) == .ComptimeInt) {
|
||||
@compileError("comptime_int is unsupported");
|
||||
} else {
|
||||
@compileError("requires an unsigned integer, found " ++ @typeName(TargetType));
|
||||
}
|
||||
}
|
||||
|
||||
if (comptime std.debug.runtime_safety) {
|
||||
if (getBits(TargetType, value, 0, (end_bit - start_bit)) != value) @panic("value exceeds bit range");
|
||||
}
|
||||
|
||||
const bitmask: TargetType = comptime blk: {
|
||||
var bitmask = ~@as(TargetType, 0);
|
||||
bitmask <<= (@bitSizeOf(TargetType) - end_bit);
|
||||
bitmask >>= (@bitSizeOf(TargetType) - end_bit);
|
||||
bitmask >>= start_bit;
|
||||
bitmask <<= start_bit;
|
||||
break :blk ~bitmask;
|
||||
};
|
||||
|
||||
return (target & bitmask) | (value << start_bit);
|
||||
}
|
||||
|
||||
pub inline fn getBits(comptime TargetType: type, target: anytype, comptime start_bit: comptime_int, comptime number_of_bits: comptime_int) TargetType {
|
||||
comptime {
|
||||
if (number_of_bits == 0) @compileError("non-zero number_of_bits must be provided");
|
||||
|
||||
if (@typeInfo(TargetType) == .Int) {
|
||||
if (@typeInfo(TargetType).Int.signedness != .unsigned) {
|
||||
@compileError("requires an unsigned integer, found " ++ @typeName(TargetType));
|
||||
}
|
||||
if (start_bit >= @bitSizeOf(TargetType)) {
|
||||
@compileError("start_bit index is out of bounds of the bit field");
|
||||
}
|
||||
if (start_bit + number_of_bits > @bitSizeOf(TargetType)) {
|
||||
@compileError("start_bit + number_of_bits is out of bounds of the bit field");
|
||||
}
|
||||
} else if (@typeInfo(TargetType) == .ComptimeInt) {
|
||||
if (target < 0) {
|
||||
@compileError("requires an unsigned integer, found " ++ @typeName(TargetType));
|
||||
}
|
||||
} else {
|
||||
@compileError("requires an unsigned integer, found " ++ @typeName(TargetType));
|
||||
}
|
||||
}
|
||||
|
||||
return @as(TargetType, @truncate(target >> start_bit));
|
||||
}
|
||||
|
||||
/// In some parts of Bun, we have many different IDs pointing to different things.
|
||||
/// It's easy for them to get mixed up, so we use this type to make sure we don't.
|
||||
///
|
||||
@@ -86,19 +186,6 @@ pub const Index = packed struct(u32) {
|
||||
}
|
||||
};
|
||||
|
||||
/// -- original comment from esbuild --
|
||||
///
|
||||
/// Files are parsed in parallel for speed. We want to allow each parser to
|
||||
/// generate symbol IDs that won't conflict with each other. We also want to be
|
||||
/// able to quickly merge symbol tables from all files into one giant symbol
|
||||
/// table.
|
||||
///
|
||||
/// We can accomplish both goals by giving each symbol ID two parts: a source
|
||||
/// index that is unique to the parser goroutine, and an inner index that
|
||||
/// increments as the parser generates new symbol IDs. Then a symbol map can
|
||||
/// be an array of arrays indexed first by source index, then by inner index.
|
||||
/// The maps can be merged quickly by creating a single outer array containing
|
||||
/// all inner arrays from all parsed files.
|
||||
pub const Ref = packed struct(u64) {
|
||||
inner_index: Int = 0,
|
||||
|
||||
@@ -111,9 +198,6 @@ pub const Ref = packed struct(u64) {
|
||||
|
||||
source_index: Int = 0,
|
||||
|
||||
/// Represents a null state without using an extra bit
|
||||
pub const None = Ref{ .inner_index = 0, .source_index = 0, .tag = .invalid };
|
||||
|
||||
pub inline fn isEmpty(this: Ref) bool {
|
||||
return this.asU64() == 0;
|
||||
}
|
||||
@@ -138,7 +222,7 @@ pub const Ref = packed struct(u64) {
|
||||
pub fn format(ref: Ref, comptime _: []const u8, _: std.fmt.FormatOptions, writer: anytype) !void {
|
||||
try std.fmt.format(
|
||||
writer,
|
||||
"Ref[inner={d}, src={d}, .{s}]",
|
||||
"Ref[{d}, {d}, {s}]",
|
||||
.{
|
||||
ref.sourceIndex(),
|
||||
ref.innerIndex(),
|
||||
@@ -151,6 +235,9 @@ pub const Ref = packed struct(u64) {
|
||||
return this.tag != .invalid;
|
||||
}
|
||||
|
||||
// 2 bits of padding for whatever is the parent
|
||||
pub const None = Ref{ .inner_index = 0, .source_index = 0, .tag = .invalid };
|
||||
|
||||
pub inline fn sourceIndex(this: Ref) Int {
|
||||
return this.source_index;
|
||||
}
|
||||
@@ -166,7 +253,10 @@ pub const Ref = packed struct(u64) {
|
||||
pub fn init(inner_index: Int, source_index: usize, is_source_contents_slice: bool) Ref {
|
||||
return .{
|
||||
.inner_index = inner_index,
|
||||
.source_index = @intCast(source_index),
|
||||
|
||||
// if we overflow, we want a panic
|
||||
.source_index = @as(Int, @intCast(source_index)),
|
||||
|
||||
.tag = if (is_source_contents_slice) .source_contents_slice else .allocated_name,
|
||||
};
|
||||
}
|
||||
@@ -188,10 +278,9 @@ pub const Ref = packed struct(u64) {
|
||||
return bun.hash(&@as([8]u8, @bitCast(key.asU64())));
|
||||
}
|
||||
|
||||
pub fn eql(ref: Ref, other: Ref) bool {
|
||||
return ref.asU64() == other.asU64();
|
||||
pub fn eql(ref: Ref, b: Ref) bool {
|
||||
return asU64(ref) == b.asU64();
|
||||
}
|
||||
|
||||
pub inline fn isNull(self: Ref) bool {
|
||||
return self.tag == .invalid;
|
||||
}
|
||||
|
||||
64
src/bench/string-handling.zig
Normal file
64
src/bench/string-handling.zig
Normal file
@@ -0,0 +1,64 @@
|
||||
const strings = bun.strings;
|
||||
const std = @import("std");
|
||||
|
||||
pub fn main() anyerror!void {
|
||||
const args = try std.process.argsAlloc(std.heap.c_allocator);
|
||||
const filepath = args[args.len - 3];
|
||||
const find = args[args.len - 2];
|
||||
const amount = try std.fmt.parseInt(usize, args[args.len - 1], 10);
|
||||
var file = try std.fs.cwd().openFile(filepath, .{ .mode = .read_only });
|
||||
var contents = try file.readToEndAlloc(std.heap.c_allocator, std.math.maxInt(usize));
|
||||
var list = try std.ArrayList(u8).initCapacity(std.heap.c_allocator, contents.len);
|
||||
var duped = list.items.ptr[0..contents.len];
|
||||
{
|
||||
var timer = try std.time.Timer.start();
|
||||
var index: usize = std.math.maxInt(usize);
|
||||
var j: usize = 0;
|
||||
var i: usize = 0;
|
||||
while (j < amount) : (j += 1) {
|
||||
i = 0;
|
||||
strings.copy(duped, contents);
|
||||
}
|
||||
|
||||
if (index == std.math.maxInt(usize)) {
|
||||
std.debug.print("manual [{d} byte file] {s} NOT found in {}\n", .{ contents.len, find, std.fmt.fmtDuration(timer.read()) });
|
||||
} else {
|
||||
std.debug.print("manual [{d} byte file] {s} found at {d} in {}\n", .{ contents.len, find, index, std.fmt.fmtDuration(timer.read()) });
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
var timer = try std.time.Timer.start();
|
||||
var index: usize = std.math.maxInt(usize);
|
||||
var j: usize = 0;
|
||||
var i: usize = 0;
|
||||
while (j < amount) : (j += 1) {
|
||||
i = 0;
|
||||
@memcpy(duped[0..contents.len], contents);
|
||||
}
|
||||
|
||||
if (index == std.math.maxInt(usize)) {
|
||||
std.debug.print("memcpy [{d} byte file] {s} NOT found in {}\n", .{ contents.len, find, std.fmt.fmtDuration(timer.read()) });
|
||||
} else {
|
||||
std.debug.print("memcpy [{d} byte file] {s} found at {d} in {}\n", .{ contents.len, find, index, std.fmt.fmtDuration(timer.read()) });
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
var timer = try std.time.Timer.start();
|
||||
var index: usize = std.math.maxInt(usize);
|
||||
var j: usize = 0;
|
||||
var i: usize = 0;
|
||||
while (j < amount) : (j += 1) {
|
||||
i = 0;
|
||||
list.clearRetainingCapacity();
|
||||
list.appendSliceAssumeCapacity(contents);
|
||||
}
|
||||
|
||||
if (index == std.math.maxInt(usize)) {
|
||||
std.debug.print("ArrayList [{d} byte file] {s} NOT found in {}\n", .{ contents.len, find, std.fmt.fmtDuration(timer.read()) });
|
||||
} else {
|
||||
std.debug.print("ArrayList [{d} byte file] {s} found at {d} in {}\n", .{ contents.len, find, index, std.fmt.fmtDuration(timer.read()) });
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,12 +22,12 @@ pub const BuildMessage = struct {
|
||||
pub fn constructor(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
_: *JSC.CallFrame,
|
||||
) ?*BuildMessage {
|
||||
) callconv(.C) ?*BuildMessage {
|
||||
globalThis.throw("BuildMessage is not constructable", .{});
|
||||
return null;
|
||||
}
|
||||
|
||||
pub fn getNotes(this: *BuildMessage, globalThis: *JSC.JSGlobalObject) JSC.JSValue {
|
||||
pub fn getNotes(this: *BuildMessage, globalThis: *JSC.JSGlobalObject) callconv(.C) JSC.JSValue {
|
||||
const notes: []const logger.Data = this.msg.notes orelse &[_]logger.Data{};
|
||||
const array = JSC.JSValue.createEmptyArray(globalThis, notes.len);
|
||||
for (notes, 0..) |note, i| {
|
||||
@@ -53,7 +53,7 @@ pub const BuildMessage = struct {
|
||||
var str = ZigString.init(text);
|
||||
str.setOutputEncoding();
|
||||
if (str.isUTF8()) {
|
||||
const out = str.toJS(globalThis);
|
||||
const out = str.toValueGC(globalThis);
|
||||
default_allocator.free(text);
|
||||
return out;
|
||||
}
|
||||
@@ -81,7 +81,7 @@ pub const BuildMessage = struct {
|
||||
this: *BuildMessage,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
_: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return this.toStringFn(globalThis);
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ pub const BuildMessage = struct {
|
||||
this: *BuildMessage,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
const args_ = callframe.arguments(1);
|
||||
const args = args_.ptr[0..args_.len];
|
||||
if (args.len > 0) {
|
||||
@@ -110,9 +110,9 @@ pub const BuildMessage = struct {
|
||||
this: *BuildMessage,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
_: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
var object = JSC.JSValue.createEmptyObject(globalThis, 4);
|
||||
object.put(globalThis, ZigString.static("name"), ZigString.init("BuildMessage").toJS(globalThis));
|
||||
object.put(globalThis, ZigString.static("name"), ZigString.init("BuildMessage").toValueGC(globalThis));
|
||||
object.put(globalThis, ZigString.static("position"), this.getPosition(globalThis));
|
||||
object.put(globalThis, ZigString.static("message"), this.getMessage(globalThis));
|
||||
object.put(globalThis, ZigString.static("level"), this.getLevel(globalThis));
|
||||
@@ -126,17 +126,17 @@ pub const BuildMessage = struct {
|
||||
object.put(
|
||||
globalThis,
|
||||
ZigString.static("lineText"),
|
||||
ZigString.init(location.line_text orelse "").toJS(globalThis),
|
||||
ZigString.init(location.line_text orelse "").toValueGC(globalThis),
|
||||
);
|
||||
object.put(
|
||||
globalThis,
|
||||
ZigString.static("file"),
|
||||
ZigString.init(location.file).toJS(globalThis),
|
||||
ZigString.init(location.file).toValueGC(globalThis),
|
||||
);
|
||||
object.put(
|
||||
globalThis,
|
||||
ZigString.static("namespace"),
|
||||
ZigString.init(location.namespace).toJS(globalThis),
|
||||
ZigString.init(location.namespace).toValueGC(globalThis),
|
||||
);
|
||||
object.put(
|
||||
globalThis,
|
||||
@@ -163,7 +163,7 @@ pub const BuildMessage = struct {
|
||||
}
|
||||
|
||||
// https://github.com/oven-sh/bun/issues/2375#issuecomment-2121530202
|
||||
pub fn getColumn(this: *BuildMessage, _: *JSC.JSGlobalObject) JSC.JSValue {
|
||||
pub fn getColumn(this: *BuildMessage, _: *JSC.JSGlobalObject) callconv(.C) JSC.JSValue {
|
||||
if (this.msg.data.location) |location| {
|
||||
return JSC.JSValue.jsNumber(@max(location.column - 1, 0));
|
||||
}
|
||||
@@ -171,7 +171,7 @@ pub const BuildMessage = struct {
|
||||
return JSC.JSValue.jsNumber(@as(i32, 0));
|
||||
}
|
||||
|
||||
pub fn getLine(this: *BuildMessage, _: *JSC.JSGlobalObject) JSC.JSValue {
|
||||
pub fn getLine(this: *BuildMessage, _: *JSC.JSGlobalObject) callconv(.C) JSC.JSValue {
|
||||
if (this.msg.data.location) |location| {
|
||||
return JSC.JSValue.jsNumber(@max(location.line - 1, 0));
|
||||
}
|
||||
@@ -182,25 +182,25 @@ pub const BuildMessage = struct {
|
||||
pub fn getPosition(
|
||||
this: *BuildMessage,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return BuildMessage.generatePositionObject(this.msg, globalThis);
|
||||
}
|
||||
|
||||
pub fn getMessage(
|
||||
this: *BuildMessage,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
) JSC.JSValue {
|
||||
return ZigString.init(this.msg.data.text).toJS(globalThis);
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return ZigString.init(this.msg.data.text).toValueGC(globalThis);
|
||||
}
|
||||
|
||||
pub fn getLevel(
|
||||
this: *BuildMessage,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
) JSC.JSValue {
|
||||
return ZigString.init(this.msg.kind.string()).toJS(globalThis);
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return ZigString.init(this.msg.kind.string()).toValueGC(globalThis);
|
||||
}
|
||||
|
||||
pub fn finalize(this: *BuildMessage) void {
|
||||
pub fn finalize(this: *BuildMessage) callconv(.C) void {
|
||||
this.msg.deinit(bun.default_allocator);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -87,7 +87,7 @@ pub fn messageWithTypeAndLevel(
|
||||
global: *JSGlobalObject,
|
||||
vals: [*]const JSValue,
|
||||
len: usize,
|
||||
) callconv(JSC.conv) void {
|
||||
) callconv(.C) void {
|
||||
if (comptime is_bindgen) {
|
||||
return;
|
||||
}
|
||||
@@ -3191,7 +3191,7 @@ pub fn count(
|
||||
ptr: [*]const u8,
|
||||
// len
|
||||
len: usize,
|
||||
) callconv(JSC.conv) void {
|
||||
) callconv(.C) void {
|
||||
var this = globalThis.bunVM().console;
|
||||
const slice = ptr[0..len];
|
||||
const hash = bun.hash(slice);
|
||||
@@ -3217,7 +3217,7 @@ pub fn countReset(
|
||||
ptr: [*]const u8,
|
||||
// len
|
||||
len: usize,
|
||||
) callconv(JSC.conv) void {
|
||||
) callconv(.C) void {
|
||||
var this = globalThis.bunVM().console;
|
||||
const slice = ptr[0..len];
|
||||
const hash = bun.hash(slice);
|
||||
@@ -3237,7 +3237,7 @@ pub fn time(
|
||||
_: *JSGlobalObject,
|
||||
chars: [*]const u8,
|
||||
len: usize,
|
||||
) callconv(JSC.conv) void {
|
||||
) callconv(.C) void {
|
||||
const id = bun.hash(chars[0..len]);
|
||||
if (!pending_time_logs_loaded) {
|
||||
pending_time_logs = PendingTimers.init(default_allocator);
|
||||
@@ -3257,7 +3257,7 @@ pub fn timeEnd(
|
||||
_: *JSGlobalObject,
|
||||
chars: [*]const u8,
|
||||
len: usize,
|
||||
) callconv(JSC.conv) void {
|
||||
) callconv(.C) void {
|
||||
if (!pending_time_logs_loaded) {
|
||||
return;
|
||||
}
|
||||
@@ -3288,7 +3288,7 @@ pub fn timeLog(
|
||||
// args
|
||||
args: [*]JSValue,
|
||||
args_len: usize,
|
||||
) callconv(JSC.conv) void {
|
||||
) callconv(.C) void {
|
||||
if (!pending_time_logs_loaded) {
|
||||
return;
|
||||
}
|
||||
@@ -3335,7 +3335,7 @@ pub fn profile(
|
||||
_: [*]const u8,
|
||||
// len
|
||||
_: usize,
|
||||
) callconv(JSC.conv) void {}
|
||||
) callconv(.C) void {}
|
||||
pub fn profileEnd(
|
||||
// console
|
||||
_: ConsoleObject.Type,
|
||||
@@ -3345,7 +3345,7 @@ pub fn profileEnd(
|
||||
_: [*]const u8,
|
||||
// len
|
||||
_: usize,
|
||||
) callconv(JSC.conv) void {}
|
||||
) callconv(.C) void {}
|
||||
pub fn takeHeapSnapshot(
|
||||
// console
|
||||
_: ConsoleObject.Type,
|
||||
@@ -3355,7 +3355,7 @@ pub fn takeHeapSnapshot(
|
||||
_: [*]const u8,
|
||||
// len
|
||||
_: usize,
|
||||
) callconv(JSC.conv) void {
|
||||
) callconv(.C) void {
|
||||
// TODO: this does an extra JSONStringify and we don't need it to!
|
||||
var snapshot: [1]JSValue = .{globalThis.generateHeapSnapshot()};
|
||||
ConsoleObject.messageWithTypeAndLevel(undefined, MessageType.Log, MessageLevel.Debug, globalThis, &snapshot, 1);
|
||||
@@ -3367,7 +3367,7 @@ pub fn timeStamp(
|
||||
_: *JSGlobalObject,
|
||||
// args
|
||||
_: *ScriptArguments,
|
||||
) callconv(JSC.conv) void {}
|
||||
) callconv(.C) void {}
|
||||
pub fn record(
|
||||
// console
|
||||
_: ConsoleObject.Type,
|
||||
@@ -3375,7 +3375,7 @@ pub fn record(
|
||||
_: *JSGlobalObject,
|
||||
// args
|
||||
_: *ScriptArguments,
|
||||
) callconv(JSC.conv) void {}
|
||||
) callconv(.C) void {}
|
||||
pub fn recordEnd(
|
||||
// console
|
||||
_: ConsoleObject.Type,
|
||||
@@ -3383,7 +3383,7 @@ pub fn recordEnd(
|
||||
_: *JSGlobalObject,
|
||||
// args
|
||||
_: *ScriptArguments,
|
||||
) callconv(JSC.conv) void {}
|
||||
) callconv(.C) void {}
|
||||
pub fn screenshot(
|
||||
// console
|
||||
_: ConsoleObject.Type,
|
||||
@@ -3391,20 +3391,62 @@ pub fn screenshot(
|
||||
_: *JSGlobalObject,
|
||||
// args
|
||||
_: *ScriptArguments,
|
||||
) callconv(JSC.conv) void {}
|
||||
) callconv(.C) void {}
|
||||
|
||||
pub const Export = shim.exportFunctions(.{
|
||||
.messageWithTypeAndLevel = messageWithTypeAndLevel,
|
||||
.count = count,
|
||||
.countReset = countReset,
|
||||
.time = time,
|
||||
.timeLog = timeLog,
|
||||
.timeEnd = timeEnd,
|
||||
.profile = profile,
|
||||
.profileEnd = profileEnd,
|
||||
.takeHeapSnapshot = takeHeapSnapshot,
|
||||
.timeStamp = timeStamp,
|
||||
.record = record,
|
||||
.recordEnd = recordEnd,
|
||||
.screenshot = screenshot,
|
||||
});
|
||||
|
||||
comptime {
|
||||
@export(messageWithTypeAndLevel, .{ .name = shim.symbolName("messageWithTypeAndLevel") });
|
||||
@export(count, .{ .name = shim.symbolName("count") });
|
||||
@export(countReset, .{ .name = shim.symbolName("countReset") });
|
||||
@export(time, .{ .name = shim.symbolName("time") });
|
||||
@export(timeLog, .{ .name = shim.symbolName("timeLog") });
|
||||
@export(timeEnd, .{ .name = shim.symbolName("timeEnd") });
|
||||
@export(profile, .{ .name = shim.symbolName("profile") });
|
||||
@export(profileEnd, .{ .name = shim.symbolName("profileEnd") });
|
||||
@export(takeHeapSnapshot, .{ .name = shim.symbolName("takeHeapSnapshot") });
|
||||
@export(timeStamp, .{ .name = shim.symbolName("timeStamp") });
|
||||
@export(record, .{ .name = shim.symbolName("record") });
|
||||
@export(recordEnd, .{ .name = shim.symbolName("recordEnd") });
|
||||
@export(screenshot, .{ .name = shim.symbolName("screenshot") });
|
||||
@export(messageWithTypeAndLevel, .{
|
||||
.name = Export[0].symbol_name,
|
||||
});
|
||||
@export(count, .{
|
||||
.name = Export[1].symbol_name,
|
||||
});
|
||||
@export(countReset, .{
|
||||
.name = Export[2].symbol_name,
|
||||
});
|
||||
@export(time, .{
|
||||
.name = Export[3].symbol_name,
|
||||
});
|
||||
@export(timeLog, .{
|
||||
.name = Export[4].symbol_name,
|
||||
});
|
||||
@export(timeEnd, .{
|
||||
.name = Export[5].symbol_name,
|
||||
});
|
||||
@export(profile, .{
|
||||
.name = Export[6].symbol_name,
|
||||
});
|
||||
@export(profileEnd, .{
|
||||
.name = Export[7].symbol_name,
|
||||
});
|
||||
@export(takeHeapSnapshot, .{
|
||||
.name = Export[8].symbol_name,
|
||||
});
|
||||
@export(timeStamp, .{
|
||||
.name = Export[9].symbol_name,
|
||||
});
|
||||
@export(record, .{
|
||||
.name = Export[10].symbol_name,
|
||||
});
|
||||
@export(recordEnd, .{
|
||||
.name = Export[11].symbol_name,
|
||||
});
|
||||
@export(screenshot, .{
|
||||
.name = Export[12].symbol_name,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -21,12 +21,12 @@ pub const ResolveMessage = struct {
|
||||
pub fn constructor(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
_: *JSC.CallFrame,
|
||||
) ?*ResolveMessage {
|
||||
) callconv(.C) ?*ResolveMessage {
|
||||
globalThis.throw("ResolveMessage is not constructable", .{});
|
||||
return null;
|
||||
}
|
||||
|
||||
pub fn getCode(this: *ResolveMessage, globalObject: *JSC.JSGlobalObject) JSC.JSValue {
|
||||
pub fn getCode(this: *ResolveMessage, globalObject: *JSC.JSGlobalObject) callconv(.C) JSC.JSValue {
|
||||
switch (this.msg.metadata) {
|
||||
.resolve => |resolve| {
|
||||
const label: []const u8 = brk: {
|
||||
@@ -49,7 +49,7 @@ pub const ResolveMessage = struct {
|
||||
}
|
||||
|
||||
// https://github.com/oven-sh/bun/issues/2375#issuecomment-2121530202
|
||||
pub fn getColumn(this: *ResolveMessage, _: *JSC.JSGlobalObject) JSC.JSValue {
|
||||
pub fn getColumn(this: *ResolveMessage, _: *JSC.JSGlobalObject) callconv(.C) JSC.JSValue {
|
||||
if (this.msg.data.location) |location| {
|
||||
return JSC.JSValue.jsNumber(@max(location.column - 1, 0));
|
||||
}
|
||||
@@ -57,7 +57,7 @@ pub const ResolveMessage = struct {
|
||||
return JSC.JSValue.jsNumber(@as(i32, 0));
|
||||
}
|
||||
|
||||
pub fn getLine(this: *ResolveMessage, _: *JSC.JSGlobalObject) JSC.JSValue {
|
||||
pub fn getLine(this: *ResolveMessage, _: *JSC.JSGlobalObject) callconv(.C) JSC.JSValue {
|
||||
if (this.msg.data.location) |location| {
|
||||
return JSC.JSValue.jsNumber(@max(location.line - 1, 0));
|
||||
}
|
||||
@@ -98,7 +98,7 @@ pub const ResolveMessage = struct {
|
||||
var str = ZigString.init(text);
|
||||
str.setOutputEncoding();
|
||||
if (str.isUTF8()) {
|
||||
const out = str.toJS(globalThis);
|
||||
const out = str.toValueGC(globalThis);
|
||||
default_allocator.free(text);
|
||||
return out;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ pub const ResolveMessage = struct {
|
||||
this: *ResolveMessage,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
_: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return this.toStringFn(globalThis);
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ pub const ResolveMessage = struct {
|
||||
this: *ResolveMessage,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
const args_ = callframe.arguments(1);
|
||||
const args = args_.ptr[0..args_.len];
|
||||
if (args.len > 0) {
|
||||
@@ -140,9 +140,9 @@ pub const ResolveMessage = struct {
|
||||
this: *ResolveMessage,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
_: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
var object = JSC.JSValue.createEmptyObject(globalThis, 7);
|
||||
object.put(globalThis, ZigString.static("name"), ZigString.init("ResolveMessage").toJS(globalThis));
|
||||
object.put(globalThis, ZigString.static("name"), ZigString.init("ResolveMessage").toValueGC(globalThis));
|
||||
object.put(globalThis, ZigString.static("position"), this.getPosition(globalThis));
|
||||
object.put(globalThis, ZigString.static("message"), this.getMessage(globalThis));
|
||||
object.put(globalThis, ZigString.static("level"), this.getLevel(globalThis));
|
||||
@@ -170,44 +170,44 @@ pub const ResolveMessage = struct {
|
||||
pub fn getPosition(
|
||||
this: *ResolveMessage,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return JSC.BuildMessage.generatePositionObject(this.msg, globalThis);
|
||||
}
|
||||
|
||||
pub fn getMessage(
|
||||
this: *ResolveMessage,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
) JSC.JSValue {
|
||||
return ZigString.init(this.msg.data.text).toJS(globalThis);
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return ZigString.init(this.msg.data.text).toValueGC(globalThis);
|
||||
}
|
||||
|
||||
pub fn getLevel(
|
||||
this: *ResolveMessage,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
) JSC.JSValue {
|
||||
return ZigString.init(this.msg.kind.string()).toJS(globalThis);
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return ZigString.init(this.msg.kind.string()).toValueGC(globalThis);
|
||||
}
|
||||
|
||||
pub fn getSpecifier(
|
||||
this: *ResolveMessage,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
) JSC.JSValue {
|
||||
return ZigString.init(this.msg.metadata.resolve.specifier.slice(this.msg.data.text)).toJS(globalThis);
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return ZigString.init(this.msg.metadata.resolve.specifier.slice(this.msg.data.text)).toValueGC(globalThis);
|
||||
}
|
||||
|
||||
pub fn getImportKind(
|
||||
this: *ResolveMessage,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
) JSC.JSValue {
|
||||
return ZigString.init(this.msg.metadata.resolve.import_kind.label()).toJS(globalThis);
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return ZigString.init(this.msg.metadata.resolve.import_kind.label()).toValueGC(globalThis);
|
||||
}
|
||||
|
||||
pub fn getReferrer(
|
||||
this: *ResolveMessage,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
if (this.referrer) |referrer| {
|
||||
return ZigString.init(referrer.text).toJS(globalThis);
|
||||
return ZigString.init(referrer.text).toValueGC(globalThis);
|
||||
} else {
|
||||
return JSC.JSValue.jsNull();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
/// ** Update the version number when any breaking changes are made to the cache format or to the JS parser **
|
||||
/// Version 3: "Infinity" becomes "1/0".
|
||||
/// Version 4: TypeScript enums are properly handled + more constant folding
|
||||
const expected_version = 4;
|
||||
// ** Update the version number when any breaking changes are made to the cache format or to the JS parser **
|
||||
// Version 2 -> 3: "Infinity" becomes "1/0".
|
||||
const expected_version = 3;
|
||||
|
||||
const bun = @import("root").bun;
|
||||
const std = @import("std");
|
||||
@@ -204,7 +203,7 @@ pub const RuntimeTranspilerCache = struct {
|
||||
if (comptime bun.Environment.allow_assert) {
|
||||
var metadata_stream2 = std.io.fixedBufferStream(metadata_buf[0..Metadata.size]);
|
||||
var metadata2 = Metadata{};
|
||||
metadata2.decode(metadata_stream2.reader()) catch |err| bun.Output.panic("Metadata did not roundtrip encode -> decode successfully: {s}", .{@errorName(err)});
|
||||
metadata2.decode(metadata_stream2.reader()) catch |err| bun.Output.panic("Metadata did not rountrip encode -> decode successfully: {s}", .{@errorName(err)});
|
||||
bun.assert(std.meta.eql(metadata, metadata2));
|
||||
}
|
||||
|
||||
|
||||
Submodule src/bun.js/WebKit updated: 615e8585f9...64d04ec1a6
@@ -1,4 +1,3 @@
|
||||
const conv = std.builtin.CallingConvention.Unspecified;
|
||||
/// How to add a new function or property to the Bun global
|
||||
///
|
||||
/// - Add a callback or property to the below struct
|
||||
@@ -9,69 +8,69 @@ const conv = std.builtin.CallingConvention.Unspecified;
|
||||
/// - Run "make dev"
|
||||
pub const BunObject = struct {
|
||||
// --- Callbacks ---
|
||||
pub const allocUnsafe = toJSCallback(Bun.allocUnsafe);
|
||||
pub const build = toJSCallback(Bun.JSBundler.buildFn);
|
||||
pub const connect = toJSCallback(JSC.wrapStaticMethod(JSC.API.Listener, "connect", false));
|
||||
pub const deflateSync = toJSCallback(JSC.wrapStaticMethod(JSZlib, "deflateSync", true));
|
||||
pub const file = toJSCallback(WebCore.Blob.constructBunFile);
|
||||
pub const gc = toJSCallback(Bun.runGC);
|
||||
pub const generateHeapSnapshot = toJSCallback(Bun.generateHeapSnapshot);
|
||||
pub const gunzipSync = toJSCallback(JSC.wrapStaticMethod(JSZlib, "gunzipSync", true));
|
||||
pub const gzipSync = toJSCallback(JSC.wrapStaticMethod(JSZlib, "gzipSync", true));
|
||||
pub const indexOfLine = toJSCallback(Bun.indexOfLine);
|
||||
pub const inflateSync = toJSCallback(JSC.wrapStaticMethod(JSZlib, "inflateSync", true));
|
||||
pub const jest = toJSCallback(@import("../test/jest.zig").Jest.call);
|
||||
pub const listen = toJSCallback(JSC.wrapStaticMethod(JSC.API.Listener, "listen", false));
|
||||
pub const udpSocket = toJSCallback(JSC.wrapStaticMethod(JSC.API.UDPSocket, "udpSocket", false));
|
||||
pub const mmap = toJSCallback(Bun.mmapFile);
|
||||
pub const nanoseconds = toJSCallback(Bun.nanoseconds);
|
||||
pub const openInEditor = toJSCallback(Bun.openInEditor);
|
||||
pub const registerMacro = toJSCallback(Bun.registerMacro);
|
||||
pub const resolve = toJSCallback(Bun.resolve);
|
||||
pub const resolveSync = toJSCallback(Bun.resolveSync);
|
||||
pub const serve = toJSCallback(Bun.serve);
|
||||
pub const sha = toJSCallback(JSC.wrapStaticMethod(Crypto.SHA512_256, "hash_", true));
|
||||
pub const shrink = toJSCallback(Bun.shrink);
|
||||
pub const sleepSync = toJSCallback(Bun.sleepSync);
|
||||
pub const spawn = toJSCallback(JSC.wrapStaticMethod(JSC.Subprocess, "spawn", false));
|
||||
pub const spawnSync = toJSCallback(JSC.wrapStaticMethod(JSC.Subprocess, "spawnSync", false));
|
||||
pub const which = toJSCallback(Bun.which);
|
||||
pub const write = toJSCallback(JSC.WebCore.Blob.writeFile);
|
||||
pub const stringWidth = toJSCallback(Bun.stringWidth);
|
||||
pub const braces = toJSCallback(Bun.braces);
|
||||
pub const shellEscape = toJSCallback(Bun.shellEscape);
|
||||
pub const createParsedShellScript = toJSCallback(bun.shell.ParsedShellScript.createParsedShellScript);
|
||||
pub const createShellInterpreter = toJSCallback(bun.shell.Interpreter.createShellInterpreter);
|
||||
pub const allocUnsafe = Bun.allocUnsafe;
|
||||
pub const build = Bun.JSBundler.buildFn;
|
||||
pub const connect = JSC.wrapStaticMethod(JSC.API.Listener, "connect", false);
|
||||
pub const deflateSync = JSC.wrapStaticMethod(JSZlib, "deflateSync", true);
|
||||
pub const file = WebCore.Blob.constructBunFile;
|
||||
pub const gc = Bun.runGC;
|
||||
pub const generateHeapSnapshot = Bun.generateHeapSnapshot;
|
||||
pub const gunzipSync = JSC.wrapStaticMethod(JSZlib, "gunzipSync", true);
|
||||
pub const gzipSync = JSC.wrapStaticMethod(JSZlib, "gzipSync", true);
|
||||
pub const indexOfLine = Bun.indexOfLine;
|
||||
pub const inflateSync = JSC.wrapStaticMethod(JSZlib, "inflateSync", true);
|
||||
pub const jest = @import("../test/jest.zig").Jest.call;
|
||||
pub const listen = JSC.wrapStaticMethod(JSC.API.Listener, "listen", false);
|
||||
pub const udpSocket = JSC.wrapStaticMethod(JSC.API.UDPSocket, "udpSocket", false);
|
||||
pub const mmap = Bun.mmapFile;
|
||||
pub const nanoseconds = Bun.nanoseconds;
|
||||
pub const openInEditor = Bun.openInEditor;
|
||||
pub const registerMacro = Bun.registerMacro;
|
||||
pub const resolve = Bun.resolve;
|
||||
pub const resolveSync = Bun.resolveSync;
|
||||
pub const serve = Bun.serve;
|
||||
pub const sha = JSC.wrapStaticMethod(Crypto.SHA512_256, "hash_", true);
|
||||
pub const shrink = Bun.shrink;
|
||||
pub const sleepSync = Bun.sleepSync;
|
||||
pub const spawn = JSC.wrapStaticMethod(JSC.Subprocess, "spawn", false);
|
||||
pub const spawnSync = JSC.wrapStaticMethod(JSC.Subprocess, "spawnSync", false);
|
||||
pub const which = Bun.which;
|
||||
pub const write = JSC.WebCore.Blob.writeFile;
|
||||
pub const stringWidth = Bun.stringWidth;
|
||||
pub const braces = Bun.braces;
|
||||
pub const shellEscape = Bun.shellEscape;
|
||||
pub const createParsedShellScript = bun.shell.ParsedShellScript.createParsedShellScript;
|
||||
pub const createShellInterpreter = bun.shell.Interpreter.createShellInterpreter;
|
||||
// --- Callbacks ---
|
||||
|
||||
// --- Getters ---
|
||||
pub const CryptoHasher = toJSGetter(Crypto.CryptoHasher.getter);
|
||||
pub const FFI = toJSGetter(Bun.FFIObject.getter);
|
||||
pub const FileSystemRouter = toJSGetter(Bun.getFileSystemRouter);
|
||||
pub const MD4 = toJSGetter(Crypto.MD4.getter);
|
||||
pub const MD5 = toJSGetter(Crypto.MD5.getter);
|
||||
pub const SHA1 = toJSGetter(Crypto.SHA1.getter);
|
||||
pub const SHA224 = toJSGetter(Crypto.SHA224.getter);
|
||||
pub const SHA256 = toJSGetter(Crypto.SHA256.getter);
|
||||
pub const SHA384 = toJSGetter(Crypto.SHA384.getter);
|
||||
pub const SHA512 = toJSGetter(Crypto.SHA512.getter);
|
||||
pub const SHA512_256 = toJSGetter(Crypto.SHA512_256.getter);
|
||||
pub const TOML = toJSGetter(Bun.getTOMLObject);
|
||||
pub const Glob = toJSGetter(Bun.getGlobConstructor);
|
||||
pub const Transpiler = toJSGetter(Bun.getTranspilerConstructor);
|
||||
pub const argv = toJSGetter(Bun.getArgv);
|
||||
pub const assetPrefix = toJSGetter(Bun.getAssetPrefix);
|
||||
pub const cwd = toJSGetter(Bun.getCWD);
|
||||
pub const enableANSIColors = toJSGetter(Bun.enableANSIColors);
|
||||
pub const hash = toJSGetter(Bun.getHashObject);
|
||||
pub const inspect = toJSGetter(Bun.getInspect);
|
||||
pub const main = toJSGetter(Bun.getMain);
|
||||
pub const origin = toJSGetter(Bun.getOrigin);
|
||||
pub const stderr = toJSGetter(Bun.getStderr);
|
||||
pub const stdin = toJSGetter(Bun.getStdin);
|
||||
pub const stdout = toJSGetter(Bun.getStdout);
|
||||
pub const unsafe = toJSGetter(Bun.getUnsafe);
|
||||
pub const semver = toJSGetter(Bun.getSemver);
|
||||
pub const CryptoHasher = Crypto.CryptoHasher.getter;
|
||||
pub const FFI = Bun.FFIObject.getter;
|
||||
pub const FileSystemRouter = Bun.getFileSystemRouter;
|
||||
pub const MD4 = Crypto.MD4.getter;
|
||||
pub const MD5 = Crypto.MD5.getter;
|
||||
pub const SHA1 = Crypto.SHA1.getter;
|
||||
pub const SHA224 = Crypto.SHA224.getter;
|
||||
pub const SHA256 = Crypto.SHA256.getter;
|
||||
pub const SHA384 = Crypto.SHA384.getter;
|
||||
pub const SHA512 = Crypto.SHA512.getter;
|
||||
pub const SHA512_256 = Crypto.SHA512_256.getter;
|
||||
pub const TOML = Bun.getTOMLObject;
|
||||
pub const Glob = Bun.getGlobConstructor;
|
||||
pub const Transpiler = Bun.getTranspilerConstructor;
|
||||
pub const argv = Bun.getArgv;
|
||||
pub const assetPrefix = Bun.getAssetPrefix;
|
||||
pub const cwd = Bun.getCWD;
|
||||
pub const enableANSIColors = Bun.enableANSIColors;
|
||||
pub const hash = Bun.getHashObject;
|
||||
pub const inspect = Bun.getInspect;
|
||||
pub const main = Bun.getMain;
|
||||
pub const origin = Bun.getOrigin;
|
||||
pub const stderr = Bun.getStderr;
|
||||
pub const stdin = Bun.getStdin;
|
||||
pub const stdout = Bun.getStdout;
|
||||
pub const unsafe = Bun.getUnsafe;
|
||||
pub const semver = Bun.getSemver;
|
||||
// --- Getters ---
|
||||
|
||||
fn getterName(comptime baseName: anytype) [:0]const u8 {
|
||||
@@ -82,18 +81,6 @@ pub const BunObject = struct {
|
||||
return "BunObject_callback_" ++ baseName;
|
||||
}
|
||||
|
||||
const toJSCallback = JSC.toJSHostFunction;
|
||||
|
||||
const LazyPropertyCallback = fn (*JSC.JSGlobalObject, *JSC.JSObject) callconv(JSC.conv) JSC.JSValue;
|
||||
|
||||
fn toJSGetter(comptime getter: anytype) LazyPropertyCallback {
|
||||
return struct {
|
||||
pub fn callback(this: *JSC.JSGlobalObject, object: *JSC.JSObject) callconv(JSC.conv) JSC.JSValue {
|
||||
return @call(.always_inline, getter, .{ this, object });
|
||||
}
|
||||
}.callback;
|
||||
}
|
||||
|
||||
pub fn exportAll() void {
|
||||
if (!@inComptime()) {
|
||||
@compileError("Must be comptime");
|
||||
@@ -316,7 +303,7 @@ const ShellTask = struct {
|
||||
pub fn shell(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
const Interpreter = @import("../../shell/interpreter.zig").Interpreter;
|
||||
|
||||
// var allocator = globalThis.bunVM().allocator;
|
||||
@@ -408,7 +395,7 @@ pub fn shell(
|
||||
pub fn shellEscape(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
const arguments = callframe.arguments(1);
|
||||
if (arguments.len < 1) {
|
||||
globalThis.throw("shell escape expected at least 1 argument", .{});
|
||||
@@ -452,7 +439,7 @@ pub fn shellEscape(
|
||||
pub fn braces(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
const arguments_ = callframe.arguments(2);
|
||||
var arguments = JSC.Node.ArgumentsSlice.init(globalThis.bunVM(), arguments_.slice());
|
||||
defer arguments.deinit();
|
||||
@@ -559,7 +546,7 @@ pub fn braces(
|
||||
pub fn which(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
const arguments_ = callframe.arguments(2);
|
||||
var path_buf: bun.PathBuffer = undefined;
|
||||
var arguments = JSC.Node.ArgumentsSlice.init(globalThis.bunVM(), arguments_.slice());
|
||||
@@ -621,7 +608,7 @@ pub fn which(
|
||||
cwd_str.slice(),
|
||||
bin_str.slice(),
|
||||
)) |bin_path| {
|
||||
return ZigString.init(bin_path).withEncoding().toJS(globalThis);
|
||||
return ZigString.init(bin_path).withEncoding().toValueGC(globalThis);
|
||||
}
|
||||
|
||||
return JSC.JSValue.jsNull();
|
||||
@@ -630,7 +617,7 @@ pub fn which(
|
||||
pub fn inspect(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
const arguments = callframe.arguments(4).slice();
|
||||
if (arguments.len == 0)
|
||||
return bun.String.empty.toJS(globalThis);
|
||||
@@ -735,13 +722,13 @@ pub fn inspect(
|
||||
// we are going to always clone to keep things simple for now
|
||||
// the common case here will be stack-allocated, so it should be fine
|
||||
var out = ZigString.init(array.toOwnedSliceLeaky()).withEncoding();
|
||||
const ret = out.toJS(globalThis);
|
||||
const ret = out.toValueGC(globalThis);
|
||||
array.deinit();
|
||||
return ret;
|
||||
}
|
||||
|
||||
pub fn getInspect(globalObject: *JSC.JSGlobalObject, _: *JSC.JSObject) JSC.JSValue {
|
||||
const fun = JSC.createCallback(globalObject, ZigString.static("inspect"), 2, inspect);
|
||||
pub fn getInspect(globalObject: *JSC.JSGlobalObject, _: *JSC.JSObject) callconv(.C) JSC.JSValue {
|
||||
const fun = JSC.createCallback(globalObject, ZigString.static("inspect"), 2, &inspect);
|
||||
var str = ZigString.init("nodejs.util.inspect.custom");
|
||||
fun.put(globalObject, ZigString.static("custom"), JSC.JSValue.symbolFor(globalObject, &str));
|
||||
return fun;
|
||||
@@ -750,7 +737,7 @@ pub fn getInspect(globalObject: *JSC.JSGlobalObject, _: *JSC.JSObject) JSC.JSVal
|
||||
pub fn registerMacro(
|
||||
globalObject: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
const arguments_ = callframe.arguments(2);
|
||||
const arguments = arguments_.slice();
|
||||
if (arguments.len != 2 or !arguments[0].isNumber()) {
|
||||
@@ -783,21 +770,21 @@ pub fn registerMacro(
|
||||
pub fn getCWD(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
_: *JSC.JSObject,
|
||||
) JSC.JSValue {
|
||||
return ZigString.init(VirtualMachine.get().bundler.fs.top_level_dir).toJS(globalThis);
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return ZigString.init(VirtualMachine.get().bundler.fs.top_level_dir).toValueGC(globalThis);
|
||||
}
|
||||
|
||||
pub fn getOrigin(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
_: *JSC.JSObject,
|
||||
) JSC.JSValue {
|
||||
return ZigString.init(VirtualMachine.get().origin.origin).toJS(globalThis);
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return ZigString.init(VirtualMachine.get().origin.origin).toValueGC(globalThis);
|
||||
}
|
||||
|
||||
pub fn getStdin(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
_: *JSC.JSObject,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
var rare_data = globalThis.bunVM().rareData();
|
||||
var store = rare_data.stdin();
|
||||
store.ref();
|
||||
@@ -811,7 +798,7 @@ pub fn getStdin(
|
||||
pub fn getStderr(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
_: *JSC.JSObject,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
var rare_data = globalThis.bunVM().rareData();
|
||||
var store = rare_data.stderr();
|
||||
store.ref();
|
||||
@@ -825,7 +812,7 @@ pub fn getStderr(
|
||||
pub fn getStdout(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
_: *JSC.JSObject,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
var rare_data = globalThis.bunVM().rareData();
|
||||
var store = rare_data.stdout();
|
||||
store.ref();
|
||||
@@ -839,14 +826,14 @@ pub fn getStdout(
|
||||
pub fn enableANSIColors(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
_: *JSC.JSObject,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
_ = globalThis;
|
||||
return JSValue.jsBoolean(Output.enable_ansi_colors);
|
||||
}
|
||||
pub fn getMain(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
_: *JSC.JSObject,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
const vm = globalThis.bunVM();
|
||||
|
||||
// Attempt to use the resolved filesystem path
|
||||
@@ -893,20 +880,20 @@ pub fn getMain(
|
||||
return vm.main_resolved_path.toJS(globalThis);
|
||||
}
|
||||
|
||||
return ZigString.init(vm.main).toJS(globalThis);
|
||||
return ZigString.init(vm.main).toValueGC(globalThis);
|
||||
}
|
||||
|
||||
pub fn getAssetPrefix(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
_: *JSC.JSObject,
|
||||
) JSC.JSValue {
|
||||
return ZigString.init(VirtualMachine.get().bundler.options.routes.asset_prefix_path).toJS(globalThis);
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return ZigString.init(VirtualMachine.get().bundler.options.routes.asset_prefix_path).toValueGC(globalThis);
|
||||
}
|
||||
|
||||
pub fn getArgv(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
_: *JSC.JSObject,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return JSC.Node.Process.getArgv(globalThis);
|
||||
}
|
||||
|
||||
@@ -914,7 +901,7 @@ const Editor = @import("../../open.zig").Editor;
|
||||
pub fn openInEditor(
|
||||
globalThis: js.JSContextRef,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSValue {
|
||||
) callconv(.C) JSValue {
|
||||
var edit = &VirtualMachine.get().rareData().editor_context;
|
||||
const args = callframe.arguments(4);
|
||||
var arguments = JSC.Node.ArgumentsSlice.init(globalThis.bunVM(), args.slice());
|
||||
@@ -1032,7 +1019,7 @@ pub fn getPublicPathWithAssetPrefix(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn sleepSync(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) JSC.JSValue {
|
||||
pub fn sleepSync(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue {
|
||||
const arguments = callframe.arguments(1);
|
||||
|
||||
// Expect at least one argument. We allow more than one but ignore them; this
|
||||
@@ -1060,16 +1047,16 @@ pub fn sleepSync(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) J
|
||||
return .undefined;
|
||||
}
|
||||
|
||||
pub fn generateHeapSnapshot(globalObject: *JSC.JSGlobalObject, _: *JSC.CallFrame) JSC.JSValue {
|
||||
pub fn generateHeapSnapshot(globalObject: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue {
|
||||
return globalObject.generateHeapSnapshot();
|
||||
}
|
||||
|
||||
pub fn runGC(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) JSC.JSValue {
|
||||
pub fn runGC(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue {
|
||||
const arguments_ = callframe.arguments(1);
|
||||
const arguments = arguments_.slice();
|
||||
return globalObject.bunVM().garbageCollect(arguments.len > 0 and arguments[0].isBoolean() and arguments[0].toBoolean());
|
||||
}
|
||||
pub fn shrink(globalObject: *JSC.JSGlobalObject, _: *JSC.CallFrame) JSC.JSValue {
|
||||
pub fn shrink(globalObject: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue {
|
||||
globalObject.vm().shrinkFootprint();
|
||||
return .undefined;
|
||||
}
|
||||
@@ -1180,13 +1167,13 @@ fn doResolveWithArgs(
|
||||
return null;
|
||||
};
|
||||
|
||||
return ZigString.initUTF8(arraylist.items).toJS(ctx);
|
||||
return ZigString.initUTF8(arraylist.items).toValueGC(ctx);
|
||||
}
|
||||
|
||||
return errorable.result.value.toJS(ctx);
|
||||
}
|
||||
|
||||
pub fn resolveSync(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) JSC.JSValue {
|
||||
pub fn resolveSync(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue {
|
||||
var exception_ = [1]JSC.JSValueRef{null};
|
||||
const exception = &exception_;
|
||||
const arguments = callframe.arguments(3);
|
||||
@@ -1199,7 +1186,7 @@ pub fn resolveSync(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame)
|
||||
return result orelse .zero;
|
||||
}
|
||||
|
||||
pub fn resolve(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) JSC.JSValue {
|
||||
pub fn resolve(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue {
|
||||
var exception_ = [1]JSC.JSValueRef{null};
|
||||
const exception = &exception_;
|
||||
const arguments = callframe.arguments(3);
|
||||
@@ -1279,7 +1266,7 @@ export fn Bun__resolveSyncWithSource(
|
||||
};
|
||||
}
|
||||
|
||||
pub fn getPublicPathJS(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) JSC.JSValue {
|
||||
pub fn getPublicPathJS(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue {
|
||||
const arguments = callframe.arguments(1).slice();
|
||||
if (arguments.len < 1) {
|
||||
return bun.String.empty.toJS(globalObject);
|
||||
@@ -1292,12 +1279,12 @@ pub fn getPublicPathJS(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFr
|
||||
var writer = stream.writer();
|
||||
getPublicPath(to.slice(), VirtualMachine.get().origin, @TypeOf(&writer), &writer);
|
||||
|
||||
return ZigString.init(stream.buffer[0..stream.pos]).toJS(globalObject);
|
||||
return ZigString.init(stream.buffer[0..stream.pos]).toValueGC(globalObject);
|
||||
}
|
||||
|
||||
extern fn dump_zone_malloc_stats() void;
|
||||
|
||||
fn dump_mimalloc(globalObject: *JSC.JSGlobalObject, _: *JSC.CallFrame) JSC.JSValue {
|
||||
export fn dump_mimalloc(globalObject: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSC.JSValue {
|
||||
globalObject.bunVM().arena.dumpStats();
|
||||
if (comptime bun.is_heap_breakdown_enabled) {
|
||||
dump_zone_malloc_stats();
|
||||
@@ -1305,7 +1292,7 @@ fn dump_mimalloc(globalObject: *JSC.JSGlobalObject, _: *JSC.CallFrame) JSC.JSVal
|
||||
return .undefined;
|
||||
}
|
||||
|
||||
pub fn indexOfLine(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) JSC.JSValue {
|
||||
pub fn indexOfLine(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue {
|
||||
const arguments_ = callframe.arguments(2);
|
||||
const arguments = arguments_.slice();
|
||||
if (arguments.len == 0) {
|
||||
@@ -2171,7 +2158,7 @@ pub const Crypto = struct {
|
||||
const error_code = std.fmt.allocPrint(bun.default_allocator, "PASSWORD_{}", .{PascalToUpperUnderscoreCaseFormatter{ .input = @errorName(this.err) }}) catch bun.outOfMemory();
|
||||
defer bun.default_allocator.free(error_code);
|
||||
const instance = globalObject.createErrorInstance("Password hashing failed with error \"{s}\"", .{@errorName(this.err)});
|
||||
instance.put(globalObject, ZigString.static("code"), JSC.ZigString.init(error_code).toJS(globalObject));
|
||||
instance.put(globalObject, ZigString.static("code"), JSC.ZigString.init(error_code).toValueGC(globalObject));
|
||||
return instance;
|
||||
}
|
||||
};
|
||||
@@ -2188,7 +2175,7 @@ pub const Crypto = struct {
|
||||
promise.reject(global, error_instance);
|
||||
},
|
||||
.hash => |value| {
|
||||
const js_string = JSC.ZigString.init(value).toJS(global);
|
||||
const js_string = JSC.ZigString.init(value).toValueGC(global);
|
||||
bun.default_allocator.destroy(this);
|
||||
promise.resolve(global, js_string);
|
||||
},
|
||||
@@ -2250,7 +2237,7 @@ pub const Crypto = struct {
|
||||
return .zero;
|
||||
},
|
||||
.hash => |h| {
|
||||
return JSC.ZigString.init(h).toJS(globalObject);
|
||||
return JSC.ZigString.init(h).toValueGC(globalObject);
|
||||
},
|
||||
}
|
||||
|
||||
@@ -2318,10 +2305,10 @@ pub const Crypto = struct {
|
||||
}
|
||||
|
||||
// Once we have bindings generator, this should be replaced with a generated function
|
||||
pub fn JSPasswordObject__hash(
|
||||
pub export fn JSPasswordObject__hash(
|
||||
globalObject: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
const arguments_ = callframe.arguments(2);
|
||||
const arguments = arguments_.ptr[0..arguments_.len];
|
||||
|
||||
@@ -2352,10 +2339,10 @@ pub const Crypto = struct {
|
||||
}
|
||||
|
||||
// Once we have bindings generator, this should be replaced with a generated function
|
||||
pub fn JSPasswordObject__hashSync(
|
||||
pub export fn JSPasswordObject__hashSync(
|
||||
globalObject: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
const arguments_ = callframe.arguments(2);
|
||||
const arguments = arguments_.ptr[0..arguments_.len];
|
||||
|
||||
@@ -2413,7 +2400,7 @@ pub const Crypto = struct {
|
||||
const error_code = std.fmt.allocPrint(bun.default_allocator, "PASSWORD{}", .{PascalToUpperUnderscoreCaseFormatter{ .input = @errorName(this.err) }}) catch bun.outOfMemory();
|
||||
defer bun.default_allocator.free(error_code);
|
||||
const instance = globalObject.createErrorInstance("Password verification failed with error \"{s}\"", .{@errorName(this.err)});
|
||||
instance.put(globalObject, ZigString.static("code"), JSC.ZigString.init(error_code).toJS(globalObject));
|
||||
instance.put(globalObject, ZigString.static("code"), JSC.ZigString.init(error_code).toValueGC(globalObject));
|
||||
return instance;
|
||||
}
|
||||
};
|
||||
@@ -2477,10 +2464,10 @@ pub const Crypto = struct {
|
||||
};
|
||||
|
||||
// Once we have bindings generator, this should be replaced with a generated function
|
||||
pub fn JSPasswordObject__verify(
|
||||
pub export fn JSPasswordObject__verify(
|
||||
globalObject: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
const arguments_ = callframe.arguments(3);
|
||||
const arguments = arguments_.ptr[0..arguments_.len];
|
||||
|
||||
@@ -2530,10 +2517,10 @@ pub const Crypto = struct {
|
||||
}
|
||||
|
||||
// Once we have bindings generator, this should be replaced with a generated function
|
||||
pub fn JSPasswordObject__verifySync(
|
||||
pub export fn JSPasswordObject__verifySync(
|
||||
globalObject: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
const arguments_ = callframe.arguments(3);
|
||||
const arguments = arguments_.ptr[0..arguments_.len];
|
||||
|
||||
@@ -2599,7 +2586,7 @@ pub const Crypto = struct {
|
||||
pub fn getByteLength(
|
||||
this: *CryptoHasher,
|
||||
_: *JSC.JSGlobalObject,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return JSC.JSValue.jsNumber(switch (this.*) {
|
||||
.evp => |*inner| inner.size(),
|
||||
.zig => |*inner| inner.digest_length,
|
||||
@@ -2609,9 +2596,9 @@ pub const Crypto = struct {
|
||||
pub fn getAlgorithm(
|
||||
this: *CryptoHasher,
|
||||
globalObject: *JSC.JSGlobalObject,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return switch (this.*) {
|
||||
inline else => |*inner| ZigString.fromUTF8(bun.asByteSlice(@tagName(inner.algorithm))).toJS(globalObject),
|
||||
inline else => |*inner| ZigString.fromUTF8(bun.asByteSlice(@tagName(inner.algorithm))).toValueGC(globalObject),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2619,7 +2606,7 @@ pub const Crypto = struct {
|
||||
globalThis_: *JSC.JSGlobalObject,
|
||||
_: JSValue,
|
||||
_: JSValue,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
var values = EVP.Algorithm.names.values;
|
||||
return JSC.JSValue.createStringArray(globalThis_, &values, values.len, true);
|
||||
}
|
||||
@@ -2721,7 +2708,7 @@ pub const Crypto = struct {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn constructor(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) ?*CryptoHasher {
|
||||
pub fn constructor(globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) ?*CryptoHasher {
|
||||
const arguments = callframe.arguments(2);
|
||||
if (arguments.len == 0) {
|
||||
globalThis.throwInvalidArguments("Expected an algorithm name as an argument", .{});
|
||||
@@ -2753,11 +2740,11 @@ pub const Crypto = struct {
|
||||
pub fn getter(
|
||||
globalObject: *JSC.JSGlobalObject,
|
||||
_: *JSC.JSObject,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return CryptoHasher.getConstructor(globalObject);
|
||||
}
|
||||
|
||||
pub fn update(this: *CryptoHasher, globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) JSC.JSValue {
|
||||
pub fn update(this: *CryptoHasher, globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue {
|
||||
const thisValue = callframe.this();
|
||||
const arguments = callframe.arguments(2);
|
||||
const input = arguments.ptr[0];
|
||||
@@ -2796,7 +2783,7 @@ pub const Crypto = struct {
|
||||
this: *CryptoHasher,
|
||||
globalObject: *JSC.JSGlobalObject,
|
||||
_: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
var new: CryptoHasher = undefined;
|
||||
switch (this.*) {
|
||||
.evp => |*inner| {
|
||||
@@ -2875,7 +2862,7 @@ pub const Crypto = struct {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn finalize(this: *CryptoHasher) void {
|
||||
pub fn finalize(this: *CryptoHasher) callconv(.C) void {
|
||||
switch (this.*) {
|
||||
.evp => |*inner| {
|
||||
// https://github.com/oven-sh/bun/issues/3250
|
||||
@@ -2972,7 +2959,7 @@ pub const Crypto = struct {
|
||||
}
|
||||
}
|
||||
|
||||
fn constructor(algorithm: ZigString) ?*CryptoHasher {
|
||||
fn constructor(algorithm: ZigString) callconv(.C) ?*CryptoHasher {
|
||||
inline for (algo_map) |item| {
|
||||
if (bun.strings.eqlComptime(algorithm.slice(), item[0])) {
|
||||
return CryptoHasher.new(.{ .zig = .{
|
||||
@@ -3041,7 +3028,7 @@ pub const Crypto = struct {
|
||||
pub fn getByteLength(
|
||||
_: *@This(),
|
||||
_: *JSC.JSGlobalObject,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return JSC.JSValue.jsNumber(@as(u16, Hasher.digest));
|
||||
}
|
||||
|
||||
@@ -3049,7 +3036,7 @@ pub const Crypto = struct {
|
||||
_: *JSC.JSGlobalObject,
|
||||
_: JSValue,
|
||||
_: JSValue,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return JSC.JSValue.jsNumber(@as(u16, Hasher.digest));
|
||||
}
|
||||
|
||||
@@ -3136,7 +3123,7 @@ pub const Crypto = struct {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn constructor(_: *JSC.JSGlobalObject, _: *JSC.CallFrame) ?*@This() {
|
||||
pub fn constructor(_: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) ?*@This() {
|
||||
const this = bun.default_allocator.create(@This()) catch return null;
|
||||
|
||||
this.* = .{ .hashing = Hasher.init() };
|
||||
@@ -3146,11 +3133,11 @@ pub const Crypto = struct {
|
||||
pub fn getter(
|
||||
globalObject: *JSC.JSGlobalObject,
|
||||
_: *JSC.JSObject,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return ThisHasher.getConstructor(globalObject);
|
||||
}
|
||||
|
||||
pub fn update(this: *@This(), globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) JSC.JSValue {
|
||||
pub fn update(this: *@This(), globalThis: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue {
|
||||
const thisValue = callframe.this();
|
||||
const input = callframe.argument(0);
|
||||
const buffer = JSC.Node.BlobOrStringOrBuffer.fromJS(globalThis, globalThis.bunVM().allocator, input) orelse {
|
||||
@@ -3237,7 +3224,7 @@ pub const Crypto = struct {
|
||||
return encoding.encodeWithSize(globalThis, Hasher.digest, output_digest_slice);
|
||||
}
|
||||
|
||||
pub fn finalize(this: *@This()) void {
|
||||
pub fn finalize(this: *@This()) callconv(.C) void {
|
||||
VirtualMachine.get().allocator.destroy(this);
|
||||
}
|
||||
};
|
||||
@@ -3256,7 +3243,7 @@ pub const Crypto = struct {
|
||||
pub fn nanoseconds(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
_: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
const ns = globalThis.bunVM().origin_timer.read();
|
||||
return JSC.JSValue.jsNumberFromUint64(ns);
|
||||
}
|
||||
@@ -3264,7 +3251,7 @@ pub fn nanoseconds(
|
||||
pub fn serve(
|
||||
globalObject: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
const arguments = callframe.arguments(2).slice();
|
||||
var config: JSC.API.ServerConfig = brk: {
|
||||
var exception_ = [1]JSC.JSValueRef{null};
|
||||
@@ -3425,13 +3412,13 @@ pub export fn Bun__escapeHTML16(globalObject: *JSC.JSGlobalObject, input_value:
|
||||
assert(len > 0);
|
||||
const input_slice = ptr[0..len];
|
||||
const escaped = strings.escapeHTMLForUTF16Input(globalObject.bunVM().allocator, input_slice) catch {
|
||||
globalObject.vm().throwError(globalObject, ZigString.init("Out of memory").toJS(globalObject));
|
||||
globalObject.vm().throwError(globalObject, ZigString.init("Out of memory").toValue(globalObject));
|
||||
return JSC.JSValue.jsUndefined();
|
||||
};
|
||||
|
||||
switch (escaped) {
|
||||
.static => |val| {
|
||||
return ZigString.init(val).toJS(globalObject);
|
||||
return ZigString.init(val).toValue(globalObject);
|
||||
},
|
||||
.original => return input_value,
|
||||
.allocated => |escaped_html| {
|
||||
@@ -3471,13 +3458,13 @@ pub export fn Bun__escapeHTML8(globalObject: *JSC.JSGlobalObject, input_value: J
|
||||
const allocator = if (input_slice.len <= 32) stack_allocator.get() else stack_allocator.fallback_allocator;
|
||||
|
||||
const escaped = strings.escapeHTMLForLatin1Input(allocator, input_slice) catch {
|
||||
globalObject.vm().throwError(globalObject, ZigString.init("Out of memory").toJS(globalObject));
|
||||
globalObject.vm().throwError(globalObject, ZigString.init("Out of memory").toValue(globalObject));
|
||||
return JSC.JSValue.jsUndefined();
|
||||
};
|
||||
|
||||
switch (escaped) {
|
||||
.static => |val| {
|
||||
return ZigString.init(val).toJS(globalObject);
|
||||
return ZigString.init(val).toValue(globalObject);
|
||||
},
|
||||
.original => return input_value,
|
||||
.allocated => |escaped_html| {
|
||||
@@ -3516,7 +3503,7 @@ comptime {
|
||||
pub fn allocUnsafe(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
const arguments = callframe.arguments(1);
|
||||
const size = arguments.ptr[0];
|
||||
if (!size.isUInt32AsAnyInt()) {
|
||||
@@ -3530,7 +3517,7 @@ pub fn allocUnsafe(
|
||||
pub fn mmapFile(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
if (comptime Environment.isWindows) {
|
||||
globalThis.throwTODO("mmapFile is not supported on Windows");
|
||||
return JSC.JSValue.zero;
|
||||
@@ -3609,33 +3596,32 @@ pub fn mmapFile(
|
||||
pub fn getTranspilerConstructor(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
_: *JSC.JSObject,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return JSC.API.JSTranspiler.getConstructor(globalThis);
|
||||
}
|
||||
|
||||
pub fn getFileSystemRouter(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
_: *JSC.JSObject,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return JSC.API.FileSystemRouter.getConstructor(globalThis);
|
||||
}
|
||||
|
||||
pub fn getHashObject(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
_: *JSC.JSObject,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return HashObject.create(globalThis);
|
||||
}
|
||||
|
||||
const HashObject = struct {
|
||||
pub const wyhash = hashWrap(std.hash.Wyhash);
|
||||
pub const adler32 = hashWrap(std.hash.Adler32);
|
||||
pub const crc32 = hashWrap(std.hash.Crc32);
|
||||
pub const cityHash32 = hashWrap(std.hash.CityHash32);
|
||||
pub const cityHash64 = hashWrap(std.hash.CityHash64);
|
||||
pub const murmur32v2 = hashWrap(std.hash.murmur.Murmur2_32);
|
||||
pub const murmur32v3 = hashWrap(std.hash.murmur.Murmur3_32);
|
||||
pub const murmur64v2 = hashWrap(std.hash.murmur.Murmur2_64);
|
||||
pub const wyhash = hashWrap(std.hash.Wyhash).hash;
|
||||
pub const adler32 = hashWrap(bun.zlib.Adler32).hash;
|
||||
pub const crc32 = hashWrap(bun.zlib.Crc32).hash;
|
||||
pub const cityHash32 = hashWrap(std.hash.CityHash32).hash;
|
||||
pub const cityHash64 = hashWrap(std.hash.CityHash64).hash;
|
||||
pub const murmur32v2 = hashWrap(std.hash.murmur.Murmur2_32).hash;
|
||||
pub const murmur32v3 = hashWrap(std.hash.murmur.Murmur3_32).hash;
|
||||
pub const murmur64v2 = hashWrap(std.hash.murmur.Murmur2_64).hash;
|
||||
|
||||
pub fn create(globalThis: *JSC.JSGlobalObject) JSC.JSValue {
|
||||
const function = JSC.createCallback(globalThis, ZigString.static("hash"), 1, &wyhash);
|
||||
@@ -3654,7 +3640,7 @@ const HashObject = struct {
|
||||
globalThis,
|
||||
ZigString.static(name),
|
||||
1,
|
||||
@field(HashObject, name),
|
||||
&@field(HashObject, name),
|
||||
);
|
||||
function.put(globalThis, comptime ZigString.static(name), value);
|
||||
}
|
||||
@@ -3662,13 +3648,13 @@ const HashObject = struct {
|
||||
return function;
|
||||
}
|
||||
|
||||
fn hashWrap(comptime Hasher_: anytype) JSC.JSHostFunctionType {
|
||||
fn hashWrap(comptime Hasher_: anytype) type {
|
||||
return struct {
|
||||
const Hasher = Hasher_;
|
||||
pub fn hash(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) callconv(JSC.conv) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
const arguments = callframe.arguments(2).slice();
|
||||
var args = JSC.Node.ArgumentsSlice.init(globalThis.bunVM(), arguments);
|
||||
defer args.deinit();
|
||||
@@ -3739,35 +3725,35 @@ const HashObject = struct {
|
||||
return JSC.JSValue.fromUInt64NoTruncate(globalThis, value);
|
||||
}
|
||||
}
|
||||
}.hash;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
pub fn getTOMLObject(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
_: *JSC.JSObject,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return TOMLObject.create(globalThis);
|
||||
}
|
||||
|
||||
pub fn getGlobConstructor(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
_: *JSC.JSObject,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return JSC.API.Glob.getConstructor(globalThis);
|
||||
}
|
||||
|
||||
pub fn getSemver(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
_: *JSC.JSObject,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return SemverObject.create(globalThis);
|
||||
}
|
||||
|
||||
pub fn getUnsafe(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
_: *JSC.JSObject,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return UnsafeObject.create(globalThis);
|
||||
}
|
||||
|
||||
@@ -3775,9 +3761,9 @@ const UnsafeObject = struct {
|
||||
pub fn create(globalThis: *JSC.JSGlobalObject) JSC.JSValue {
|
||||
const object = JSValue.createEmptyObject(globalThis, 3);
|
||||
const fields = comptime .{
|
||||
.gcAggressionLevel = gcAggressionLevel,
|
||||
.arrayBufferToString = arrayBufferToString,
|
||||
.mimallocDump = dump_mimalloc,
|
||||
.gcAggressionLevel = &gcAggressionLevel,
|
||||
.arrayBufferToString = &arrayBufferToString,
|
||||
.mimallocDump = &dump_mimalloc,
|
||||
};
|
||||
inline for (comptime std.meta.fieldNames(@TypeOf(fields))) |name| {
|
||||
object.put(
|
||||
@@ -3792,7 +3778,7 @@ const UnsafeObject = struct {
|
||||
pub fn gcAggressionLevel(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
const ret = JSValue.jsNumber(@as(i32, @intFromEnum(globalThis.bunVM().aggressive_garbage_collection)));
|
||||
const value = callframe.arguments(1).ptr[0];
|
||||
|
||||
@@ -3810,7 +3796,7 @@ const UnsafeObject = struct {
|
||||
pub fn arrayBufferToString(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
const args = callframe.arguments(2).slice();
|
||||
if (args.len < 1 or !args[0].isCell() or !args[0].jsType().isTypedArray()) {
|
||||
globalThis.throwInvalidArguments("Expected an ArrayBuffer", .{});
|
||||
@@ -3824,10 +3810,10 @@ const UnsafeObject = struct {
|
||||
zig_str._unsafe_ptr_do_not_use = @as([*]const u8, @ptrCast(@alignCast(array_buffer.ptr)));
|
||||
zig_str.len = array_buffer.len;
|
||||
zig_str.markUTF16();
|
||||
return zig_str.toJS(globalThis);
|
||||
return zig_str.toValueGC(globalThis);
|
||||
},
|
||||
else => {
|
||||
return ZigString.init(array_buffer.slice()).toJS(globalThis);
|
||||
return ZigString.init(array_buffer.slice()).toValueGC(globalThis);
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -3845,7 +3831,7 @@ const TOMLObject = struct {
|
||||
globalThis,
|
||||
ZigString.static("parse"),
|
||||
1,
|
||||
parse,
|
||||
&parse,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -3855,7 +3841,7 @@ const TOMLObject = struct {
|
||||
pub fn parse(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
var arena = bun.ArenaAllocator.init(globalThis.allocator());
|
||||
const allocator = arena.allocator();
|
||||
defer arena.deinit();
|
||||
@@ -3880,7 +3866,7 @@ const TOMLObject = struct {
|
||||
return .zero;
|
||||
};
|
||||
var writer = js_printer.BufferPrinter.init(buffer_writer);
|
||||
_ = js_printer.printJSON(*js_printer.BufferPrinter, &writer, parse_result, &source, .{}) catch {
|
||||
_ = js_printer.printJSON(*js_printer.BufferPrinter, &writer, parse_result, &source) catch {
|
||||
globalThis.throwValue(log.toJS(globalThis, default_allocator, "Failed to print toml"));
|
||||
return .zero;
|
||||
};
|
||||
@@ -3924,7 +3910,7 @@ pub const FFIObject = struct {
|
||||
}
|
||||
}
|
||||
|
||||
pub const dom_call = JSC.DOMCall("FFI", @This(), "ptr", JSC.DOMEffect.forRead(.TypedArrayProperties));
|
||||
pub const dom_call = JSC.DOMCall("FFI", @This(), "ptr", f64, JSC.DOMEffect.forRead(.TypedArrayProperties));
|
||||
|
||||
pub fn toJS(globalObject: *JSC.JSGlobalObject) JSC.JSValue {
|
||||
const object = JSC.JSValue.createEmptyObject(globalObject, comptime std.meta.fieldNames(@TypeOf(fields)).len + 2);
|
||||
@@ -3944,18 +3930,18 @@ pub const FFIObject = struct {
|
||||
|
||||
pub const Reader = struct {
|
||||
pub const DOMCalls = .{
|
||||
.u8 = JSC.DOMCall("Reader", @This(), "u8", JSC.DOMEffect.forRead(.World)),
|
||||
.u16 = JSC.DOMCall("Reader", @This(), "u16", JSC.DOMEffect.forRead(.World)),
|
||||
.u32 = JSC.DOMCall("Reader", @This(), "u32", JSC.DOMEffect.forRead(.World)),
|
||||
.ptr = JSC.DOMCall("Reader", @This(), "ptr", JSC.DOMEffect.forRead(.World)),
|
||||
.i8 = JSC.DOMCall("Reader", @This(), "i8", JSC.DOMEffect.forRead(.World)),
|
||||
.i16 = JSC.DOMCall("Reader", @This(), "i16", JSC.DOMEffect.forRead(.World)),
|
||||
.i32 = JSC.DOMCall("Reader", @This(), "i32", JSC.DOMEffect.forRead(.World)),
|
||||
.i64 = JSC.DOMCall("Reader", @This(), "i64", JSC.DOMEffect.forRead(.World)),
|
||||
.u64 = JSC.DOMCall("Reader", @This(), "u64", JSC.DOMEffect.forRead(.World)),
|
||||
.intptr = JSC.DOMCall("Reader", @This(), "intptr", JSC.DOMEffect.forRead(.World)),
|
||||
.f32 = JSC.DOMCall("Reader", @This(), "f32", JSC.DOMEffect.forRead(.World)),
|
||||
.f64 = JSC.DOMCall("Reader", @This(), "f64", JSC.DOMEffect.forRead(.World)),
|
||||
.u8 = JSC.DOMCall("Reader", @This(), "u8", i32, JSC.DOMEffect.forRead(.World)),
|
||||
.u16 = JSC.DOMCall("Reader", @This(), "u16", i32, JSC.DOMEffect.forRead(.World)),
|
||||
.u32 = JSC.DOMCall("Reader", @This(), "u32", i32, JSC.DOMEffect.forRead(.World)),
|
||||
.ptr = JSC.DOMCall("Reader", @This(), "ptr", i52, JSC.DOMEffect.forRead(.World)),
|
||||
.i8 = JSC.DOMCall("Reader", @This(), "i8", i32, JSC.DOMEffect.forRead(.World)),
|
||||
.i16 = JSC.DOMCall("Reader", @This(), "i16", i32, JSC.DOMEffect.forRead(.World)),
|
||||
.i32 = JSC.DOMCall("Reader", @This(), "i32", i32, JSC.DOMEffect.forRead(.World)),
|
||||
.i64 = JSC.DOMCall("Reader", @This(), "i64", i64, JSC.DOMEffect.forRead(.World)),
|
||||
.u64 = JSC.DOMCall("Reader", @This(), "u64", u64, JSC.DOMEffect.forRead(.World)),
|
||||
.intptr = JSC.DOMCall("Reader", @This(), "intptr", i52, JSC.DOMEffect.forRead(.World)),
|
||||
.f32 = JSC.DOMCall("Reader", @This(), "f32", f64, JSC.DOMEffect.forRead(.World)),
|
||||
.f64 = JSC.DOMCall("Reader", @This(), "f64", f64, JSC.DOMEffect.forRead(.World)),
|
||||
};
|
||||
|
||||
pub fn toJS(globalThis: *JSC.JSGlobalObject) JSC.JSValue {
|
||||
@@ -4134,7 +4120,7 @@ pub const FFIObject = struct {
|
||||
_: *anyopaque,
|
||||
raw_addr: i64,
|
||||
offset: i32,
|
||||
) callconv(JSC.conv) JSValue {
|
||||
) callconv(.C) JSValue {
|
||||
const addr = @as(usize, @intCast(raw_addr)) + @as(usize, @intCast(offset));
|
||||
const value = @as(*align(1) u8, @ptrFromInt(addr)).*;
|
||||
return JSValue.jsNumber(value);
|
||||
@@ -4144,7 +4130,7 @@ pub const FFIObject = struct {
|
||||
_: *anyopaque,
|
||||
raw_addr: i64,
|
||||
offset: i32,
|
||||
) callconv(JSC.conv) JSValue {
|
||||
) callconv(.C) JSValue {
|
||||
const addr = @as(usize, @intCast(raw_addr)) + @as(usize, @intCast(offset));
|
||||
const value = @as(*align(1) u16, @ptrFromInt(addr)).*;
|
||||
return JSValue.jsNumber(value);
|
||||
@@ -4154,7 +4140,7 @@ pub const FFIObject = struct {
|
||||
_: *anyopaque,
|
||||
raw_addr: i64,
|
||||
offset: i32,
|
||||
) callconv(JSC.conv) JSValue {
|
||||
) callconv(.C) JSValue {
|
||||
const addr = @as(usize, @intCast(raw_addr)) + @as(usize, @intCast(offset));
|
||||
const value = @as(*align(1) u32, @ptrFromInt(addr)).*;
|
||||
return JSValue.jsNumber(value);
|
||||
@@ -4164,7 +4150,7 @@ pub const FFIObject = struct {
|
||||
_: *anyopaque,
|
||||
raw_addr: i64,
|
||||
offset: i32,
|
||||
) callconv(JSC.conv) JSValue {
|
||||
) callconv(.C) JSValue {
|
||||
const addr = @as(usize, @intCast(raw_addr)) + @as(usize, @intCast(offset));
|
||||
const value = @as(*align(1) u64, @ptrFromInt(addr)).*;
|
||||
return JSValue.jsNumber(value);
|
||||
@@ -4174,7 +4160,7 @@ pub const FFIObject = struct {
|
||||
_: *anyopaque,
|
||||
raw_addr: i64,
|
||||
offset: i32,
|
||||
) callconv(JSC.conv) JSValue {
|
||||
) callconv(.C) JSValue {
|
||||
const addr = @as(usize, @intCast(raw_addr)) + @as(usize, @intCast(offset));
|
||||
const value = @as(*align(1) i8, @ptrFromInt(addr)).*;
|
||||
return JSValue.jsNumber(value);
|
||||
@@ -4184,7 +4170,7 @@ pub const FFIObject = struct {
|
||||
_: *anyopaque,
|
||||
raw_addr: i64,
|
||||
offset: i32,
|
||||
) callconv(JSC.conv) JSValue {
|
||||
) callconv(.C) JSValue {
|
||||
const addr = @as(usize, @intCast(raw_addr)) + @as(usize, @intCast(offset));
|
||||
const value = @as(*align(1) i16, @ptrFromInt(addr)).*;
|
||||
return JSValue.jsNumber(value);
|
||||
@@ -4194,7 +4180,7 @@ pub const FFIObject = struct {
|
||||
_: *anyopaque,
|
||||
raw_addr: i64,
|
||||
offset: i32,
|
||||
) callconv(JSC.conv) JSValue {
|
||||
) callconv(.C) JSValue {
|
||||
const addr = @as(usize, @intCast(raw_addr)) + @as(usize, @intCast(offset));
|
||||
const value = @as(*align(1) i32, @ptrFromInt(addr)).*;
|
||||
return JSValue.jsNumber(value);
|
||||
@@ -4204,7 +4190,7 @@ pub const FFIObject = struct {
|
||||
_: *anyopaque,
|
||||
raw_addr: i64,
|
||||
offset: i32,
|
||||
) callconv(JSC.conv) JSValue {
|
||||
) callconv(.C) JSValue {
|
||||
const addr = @as(usize, @intCast(raw_addr)) + @as(usize, @intCast(offset));
|
||||
const value = @as(*align(1) i64, @ptrFromInt(addr)).*;
|
||||
return JSValue.jsNumber(value);
|
||||
@@ -4215,7 +4201,7 @@ pub const FFIObject = struct {
|
||||
_: *anyopaque,
|
||||
raw_addr: i64,
|
||||
offset: i32,
|
||||
) callconv(JSC.conv) JSValue {
|
||||
) callconv(.C) JSValue {
|
||||
const addr = @as(usize, @intCast(raw_addr)) + @as(usize, @intCast(offset));
|
||||
const value = @as(*align(1) f32, @ptrFromInt(addr)).*;
|
||||
return JSValue.jsNumber(value);
|
||||
@@ -4226,7 +4212,7 @@ pub const FFIObject = struct {
|
||||
_: *anyopaque,
|
||||
raw_addr: i64,
|
||||
offset: i32,
|
||||
) callconv(JSC.conv) JSValue {
|
||||
) callconv(.C) JSValue {
|
||||
const addr = @as(usize, @intCast(raw_addr)) + @as(usize, @intCast(offset));
|
||||
const value = @as(*align(1) f64, @ptrFromInt(addr)).*;
|
||||
return JSValue.jsNumber(value);
|
||||
@@ -4237,7 +4223,7 @@ pub const FFIObject = struct {
|
||||
_: *anyopaque,
|
||||
raw_addr: i64,
|
||||
offset: i32,
|
||||
) callconv(JSC.conv) JSValue {
|
||||
) callconv(.C) JSValue {
|
||||
const addr = @as(usize, @intCast(raw_addr)) + @as(usize, @intCast(offset));
|
||||
const value = @as(*align(1) u64, @ptrFromInt(addr)).*;
|
||||
return JSValue.fromUInt64NoTruncate(global, value);
|
||||
@@ -4248,7 +4234,7 @@ pub const FFIObject = struct {
|
||||
_: *anyopaque,
|
||||
raw_addr: i64,
|
||||
offset: i32,
|
||||
) callconv(JSC.conv) JSValue {
|
||||
) callconv(.C) JSValue {
|
||||
const addr = @as(usize, @intCast(raw_addr)) + @as(usize, @intCast(offset));
|
||||
const value = @as(*align(1) i64, @ptrFromInt(addr)).*;
|
||||
return JSValue.fromInt64NoTruncate(global, value);
|
||||
@@ -4271,7 +4257,7 @@ pub const FFIObject = struct {
|
||||
_: *JSGlobalObject,
|
||||
_: *anyopaque,
|
||||
array: *JSC.JSUint8Array,
|
||||
) callconv(JSC.conv) JSValue {
|
||||
) callconv(.C) JSValue {
|
||||
return JSValue.fromPtrAddress(@intFromPtr(array.ptr()));
|
||||
}
|
||||
|
||||
@@ -4531,12 +4517,12 @@ pub const FFIObject = struct {
|
||||
pub fn getter(
|
||||
globalObject: *JSC.JSGlobalObject,
|
||||
_: *JSC.JSObject,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return FFIObject.toJS(globalObject);
|
||||
}
|
||||
};
|
||||
|
||||
fn stringWidth(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) JSC.JSValue {
|
||||
fn stringWidth(globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSC.JSValue {
|
||||
const arguments = callframe.arguments(2).slice();
|
||||
const value = if (arguments.len > 0) arguments[0] else JSC.JSValue.jsUndefined();
|
||||
const options_object = if (arguments.len > 1) arguments[1] else JSC.JSValue.jsUndefined();
|
||||
@@ -4768,7 +4754,7 @@ pub const JSZlib = struct {
|
||||
pub usingnamespace @import("./bun/subprocess.zig");
|
||||
|
||||
const InternalTestingAPIs = struct {
|
||||
pub fn BunInternalFunction__syntaxHighlighter(globalThis: *JSGlobalObject, callframe: *JSC.CallFrame) JSValue {
|
||||
pub fn BunInternalFunction__syntaxHighlighter(globalThis: *JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSValue {
|
||||
const args = callframe.arguments(1);
|
||||
if (args.len < 1) {
|
||||
globalThis.throwNotEnoughArguments("code", 1, 0);
|
||||
|
||||
@@ -565,7 +565,7 @@ pub const JSBundler = struct {
|
||||
pub fn buildFn(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
const arguments = callframe.arguments(1);
|
||||
return build(globalThis, arguments.slice());
|
||||
}
|
||||
@@ -1081,7 +1081,7 @@ pub const BuildArtifact = struct {
|
||||
this: *BuildArtifact,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return @call(bun.callmod_inline, Blob.getText, .{ &this.blob, globalThis, callframe });
|
||||
}
|
||||
|
||||
@@ -1089,27 +1089,27 @@ pub const BuildArtifact = struct {
|
||||
this: *BuildArtifact,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return @call(bun.callmod_inline, Blob.getJSON, .{ &this.blob, globalThis, callframe });
|
||||
}
|
||||
pub fn getArrayBuffer(
|
||||
this: *BuildArtifact,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSValue {
|
||||
) callconv(.C) JSValue {
|
||||
return @call(bun.callmod_inline, Blob.getArrayBuffer, .{ &this.blob, globalThis, callframe });
|
||||
}
|
||||
pub fn getSlice(
|
||||
this: *BuildArtifact,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
return @call(bun.callmod_inline, Blob.getSlice, .{ &this.blob, globalThis, callframe });
|
||||
}
|
||||
pub fn getType(
|
||||
this: *BuildArtifact,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
) JSValue {
|
||||
) callconv(.C) JSValue {
|
||||
return @call(bun.callmod_inline, Blob.getType, .{ &this.blob, globalThis });
|
||||
}
|
||||
|
||||
@@ -1117,7 +1117,7 @@ pub const BuildArtifact = struct {
|
||||
this: *BuildArtifact,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSValue {
|
||||
) callconv(.C) JSValue {
|
||||
return @call(bun.callmod_inline, Blob.getStream, .{
|
||||
&this.blob,
|
||||
globalThis,
|
||||
@@ -1128,39 +1128,39 @@ pub const BuildArtifact = struct {
|
||||
pub fn getPath(
|
||||
this: *BuildArtifact,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
) JSValue {
|
||||
return ZigString.fromUTF8(this.path).toJS(globalThis);
|
||||
) callconv(.C) JSValue {
|
||||
return ZigString.fromUTF8(this.path).toValueGC(globalThis);
|
||||
}
|
||||
|
||||
pub fn getLoader(
|
||||
this: *BuildArtifact,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
) JSValue {
|
||||
return ZigString.fromUTF8(@tagName(this.loader)).toJS(globalThis);
|
||||
) callconv(.C) JSValue {
|
||||
return ZigString.fromUTF8(@tagName(this.loader)).toValueGC(globalThis);
|
||||
}
|
||||
|
||||
pub fn getHash(
|
||||
this: *BuildArtifact,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
) JSValue {
|
||||
) callconv(.C) JSValue {
|
||||
var buf: [512]u8 = undefined;
|
||||
const out = std.fmt.bufPrint(&buf, "{any}", .{options.PathTemplate.hashFormatter(this.hash)}) catch @panic("Unexpected");
|
||||
return ZigString.init(out).toJS(globalThis);
|
||||
return ZigString.init(out).toValueGC(globalThis);
|
||||
}
|
||||
|
||||
pub fn getSize(this: *BuildArtifact, globalObject: *JSC.JSGlobalObject) JSValue {
|
||||
pub fn getSize(this: *BuildArtifact, globalObject: *JSC.JSGlobalObject) callconv(.C) JSValue {
|
||||
return @call(bun.callmod_inline, Blob.getSize, .{ &this.blob, globalObject });
|
||||
}
|
||||
|
||||
pub fn getMimeType(this: *BuildArtifact, globalObject: *JSC.JSGlobalObject) JSValue {
|
||||
pub fn getMimeType(this: *BuildArtifact, globalObject: *JSC.JSGlobalObject) callconv(.C) JSValue {
|
||||
return @call(bun.callmod_inline, Blob.getType, .{ &this.blob, globalObject });
|
||||
}
|
||||
|
||||
pub fn getOutputKind(this: *BuildArtifact, globalObject: *JSC.JSGlobalObject) JSValue {
|
||||
return ZigString.init(@tagName(this.output_kind)).toJS(globalObject);
|
||||
pub fn getOutputKind(this: *BuildArtifact, globalObject: *JSC.JSGlobalObject) callconv(.C) JSValue {
|
||||
return ZigString.init(@tagName(this.output_kind)).toValueGC(globalObject);
|
||||
}
|
||||
|
||||
pub fn getSourceMap(this: *BuildArtifact, _: *JSC.JSGlobalObject) JSValue {
|
||||
pub fn getSourceMap(this: *BuildArtifact, _: *JSC.JSGlobalObject) callconv(.C) JSValue {
|
||||
if (this.sourcemap.get()) |value| {
|
||||
return value;
|
||||
}
|
||||
|
||||
@@ -743,7 +743,7 @@ fn transformOptionsFromJSC(globalObject: JSC.C.JSContextRef, temp_allocator: std
|
||||
pub fn constructor(
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) ?*Transpiler {
|
||||
) callconv(.C) ?*Transpiler {
|
||||
var temp = bun.ArenaAllocator.init(getAllocator(globalThis));
|
||||
const arguments = callframe.arguments(3);
|
||||
var args = JSC.Node.ArgumentsSlice.init(
|
||||
@@ -907,7 +907,7 @@ pub fn scan(
|
||||
this: *Transpiler,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
JSC.markBinding(@src());
|
||||
const arguments = callframe.arguments(3);
|
||||
var args = JSC.Node.ArgumentsSlice.init(globalThis.bunVM(), arguments.slice());
|
||||
@@ -1005,7 +1005,7 @@ pub fn transform(
|
||||
this: *Transpiler,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
JSC.markBinding(@src());
|
||||
var exception_ref = [_]JSC.C.JSValueRef{null};
|
||||
const exception: JSC.C.ExceptionRef = &exception_ref;
|
||||
@@ -1061,7 +1061,7 @@ pub fn transformSync(
|
||||
this: *Transpiler,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
JSC.markBinding(@src());
|
||||
var exception_value = [_]JSC.C.JSValueRef{null};
|
||||
const exception: JSC.C.ExceptionRef = &exception_value;
|
||||
@@ -1191,7 +1191,7 @@ pub fn transformSync(
|
||||
var out = JSC.ZigString.init(buffer_writer.written);
|
||||
out.setOutputEncoding();
|
||||
|
||||
return out.toJS(globalThis);
|
||||
return out.toValueGC(globalThis);
|
||||
}
|
||||
|
||||
fn namedExportsToJS(global: *JSGlobalObject, named_exports: *JSAst.Ast.NamedExports) JSC.JSValue {
|
||||
@@ -1234,8 +1234,8 @@ fn namedImportsToJS(
|
||||
if (record.is_internal) continue;
|
||||
|
||||
array.ensureStillAlive();
|
||||
const path = JSC.ZigString.init(record.path.text).toJS(global);
|
||||
const kind = JSC.ZigString.init(record.kind.label()).toJS(global);
|
||||
const path = JSC.ZigString.init(record.path.text).toValueGC(global);
|
||||
const kind = JSC.ZigString.init(record.kind.label()).toValueGC(global);
|
||||
array.putIndex(global, @as(u32, @truncate(i)), JSC.JSValue.createObject2(global, path_label, kind_label, path, kind));
|
||||
}
|
||||
|
||||
@@ -1246,7 +1246,7 @@ pub fn scanImports(
|
||||
this: *Transpiler,
|
||||
globalThis: *JSC.JSGlobalObject,
|
||||
callframe: *JSC.CallFrame,
|
||||
) JSC.JSValue {
|
||||
) callconv(.C) JSC.JSValue {
|
||||
const arguments = callframe.arguments(2);
|
||||
var exception_val = [_]JSC.C.JSValueRef{null};
|
||||
const exception: JSC.C.ExceptionRef = &exception_val;
|
||||
|
||||
@@ -550,7 +550,7 @@ pub const TimerObject = struct {
|
||||
return .{ timer, timer_js };
|
||||
}
|
||||
|
||||
pub fn doRef(this: *TimerObject, _: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) JSValue {
|
||||
pub fn doRef(this: *TimerObject, _: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSValue {
|
||||
const this_value = callframe.this();
|
||||
this_value.ensureStillAlive();
|
||||
|
||||
@@ -564,7 +564,7 @@ pub const TimerObject = struct {
|
||||
return this_value;
|
||||
}
|
||||
|
||||
pub fn doRefresh(this: *TimerObject, globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) JSValue {
|
||||
pub fn doRefresh(this: *TimerObject, globalObject: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSValue {
|
||||
const this_value = callframe.this();
|
||||
|
||||
// setImmediate does not support refreshing and we do not support refreshing after cleanup
|
||||
@@ -578,7 +578,7 @@ pub const TimerObject = struct {
|
||||
return this_value;
|
||||
}
|
||||
|
||||
pub fn doUnref(this: *TimerObject, _: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) JSValue {
|
||||
pub fn doUnref(this: *TimerObject, _: *JSC.JSGlobalObject, callframe: *JSC.CallFrame) callconv(.C) JSValue {
|
||||
const this_value = callframe.this();
|
||||
this_value.ensureStillAlive();
|
||||
|
||||
@@ -643,10 +643,10 @@ pub const TimerObject = struct {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn hasRef(this: *TimerObject, _: *JSC.JSGlobalObject, _: *JSC.CallFrame) JSValue {
|
||||
pub fn hasRef(this: *TimerObject, _: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSValue {
|
||||
return JSValue.jsBoolean(this.is_keeping_event_loop_alive);
|
||||
}
|
||||
pub fn toPrimitive(this: *TimerObject, _: *JSC.JSGlobalObject, _: *JSC.CallFrame) JSValue {
|
||||
pub fn toPrimitive(this: *TimerObject, _: *JSC.JSGlobalObject, _: *JSC.CallFrame) callconv(.C) JSValue {
|
||||
if (!this.has_accessed_primitive) {
|
||||
this.has_accessed_primitive = true;
|
||||
const vm = VirtualMachine.get();
|
||||
@@ -655,7 +655,7 @@ pub const TimerObject = struct {
|
||||
return JSValue.jsNumber(this.id);
|
||||
}
|
||||
|
||||
pub fn finalize(this: *TimerObject) void {
|
||||
pub fn finalize(this: *TimerObject) callconv(.C) void {
|
||||
this.strong_this.deinit();
|
||||
this.deref();
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user