aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/ZigSourceProvider.cpp
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-07-04 08:42:29 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-07-04 08:42:29 -0700
commitcf5939c425ac72fef23448d0dcd68ae0aa59ef73 (patch)
tree14043a0c10db5530179fcd2c9ea1bba0d3ad91cc /src/bun.js/bindings/ZigSourceProvider.cpp
parentbbcc08dbb44dd28f7141e6f50a7cb5edfb8b4987 (diff)
downloadbun-cf5939c425ac72fef23448d0dcd68ae0aa59ef73.tar.gz
bun-cf5939c425ac72fef23448d0dcd68ae0aa59ef73.tar.zst
bun-cf5939c425ac72fef23448d0dcd68ae0aa59ef73.zip
[jsc] Make JSC own the memory for source code strings
Diffstat (limited to 'src/bun.js/bindings/ZigSourceProvider.cpp')
-rw-r--r--src/bun.js/bindings/ZigSourceProvider.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/bun.js/bindings/ZigSourceProvider.cpp b/src/bun.js/bindings/ZigSourceProvider.cpp
index 4e426b449..c2959a8fa 100644
--- a/src/bun.js/bindings/ZigSourceProvider.cpp
+++ b/src/bun.js/bindings/ZigSourceProvider.cpp
@@ -36,13 +36,23 @@ Ref<SourceProvider> SourceProvider::create(ResolvedSource resolvedSource)
JSC::SourceProviderSourceType sourceType = JSC::SourceProviderSourceType::Module;
+ // JSC owns the memory
+ if (resolvedSource.hash == 1) {
+ Ref<WTF::StringImpl> stringImpl_ = WTF::StringImpl::create(resolvedSource.source_code.ptr, resolvedSource.source_code.len);
+ return adoptRef(*new SourceProvider(
+ resolvedSource, WTFMove(stringImpl_),
+ JSC::SourceOrigin(WTF::URL::fileURLWithFileSystemPath(toString(resolvedSource.source_url))),
+ toStringNotConst(resolvedSource.source_url), TextPosition(),
+ sourceType));
+ }
+
if (allocator) {
Ref<WTF::ExternalStringImpl> stringImpl_ = WTF::ExternalStringImpl::create(
resolvedSource.source_code.ptr, resolvedSource.source_code.len,
allocator,
RefString__free);
return adoptRef(*new SourceProvider(
- resolvedSource, stringImpl_,
+ resolvedSource, WTFMove(stringImpl_),
JSC::SourceOrigin(WTF::URL::fileURLWithFileSystemPath(toString(resolvedSource.source_url))),
toStringNotConst(resolvedSource.source_url), TextPosition(),
sourceType));
@@ -50,7 +60,7 @@ Ref<SourceProvider> SourceProvider::create(ResolvedSource resolvedSource)
Ref<WTF::ExternalStringImpl> stringImpl_ = WTF::ExternalStringImpl::createStatic(
resolvedSource.source_code.ptr, resolvedSource.source_code.len);
return adoptRef(*new SourceProvider(
- resolvedSource, stringImpl_,
+ resolvedSource, WTFMove(stringImpl_),
JSC::SourceOrigin(WTF::URL::fileURLWithFileSystemPath(toString(resolvedSource.source_url))),
toStringNotConst(resolvedSource.source_url), TextPosition(),
sourceType));
f2dfc408f3f96e6e745e36d5d1d80?s=13&d=retro' width='13' height='13' alt='Gravatar' /> Ashcon Partovi 2-5/+5 2023-10-16fix(jest): fix toStrictEqual on same URLs (#6528)Gravatar João Alisson 2-13/+16 2023-10-16Fix `toHaveBeenCalled` having wrong error signatureGravatar Ashcon Partovi 1-2/+2 2023-10-16Fix formattingGravatar Ashcon Partovi 1-2/+1 2023-10-16Add `reusePort` to `Bun.serve` typesGravatar Ashcon Partovi 1-0/+9 2023-10-16Fix `request.url` having incorrect portGravatar Ashcon Partovi 4-1/+92 2023-10-16Remove uWebSockets header from Bun.serve responsesGravatar Ashcon Partovi 1-6/+6 2023-10-16Rename some testsGravatar Ashcon Partovi 3-0/+0 2023-10-16Fix #6467Gravatar Ashcon Partovi 2-3/+10 2023-10-16Update InternalModuleRegistryConstants.hGravatar Dylan Conway 1-3/+3 2023-10-16Development -> Contributing (#6538)Gravatar Colin McDonnell 2-1/+1 2023-10-14fix(net/tls) fix pg hang on end + hanging on query (#6487)Gravatar Ciro Spaciari 3-8/+36 2023-10-13fix installing dependencies that match workspace versions (#6494)Gravatar Dylan Conway 4-2/+64 2023-10-13fix lockfile struct padding (#6495)Gravatar Dylan Conway 3-3/+18