aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred SUmner <jarred@jarredsumner.com> 2023-01-26 04:45:24 -0800
committerGravatar Jarred SUmner <jarred@jarredsumner.com> 2023-01-26 04:45:24 -0800
commit2c23d8736f463ee097b03212559ee2c25c6e5ee6 (patch)
tree9e1ce98203ac9e4c86c4147f8741879d146a4679
parentf14032e4b41a53c13263c8e3caa9c058955baae7 (diff)
downloadbun-2c23d8736f463ee097b03212559ee2c25c6e5ee6.tar.gz
bun-2c23d8736f463ee097b03212559ee2c25c6e5ee6.tar.zst
bun-2c23d8736f463ee097b03212559ee2c25c6e5ee6.zip
valgrind
-rw-r--r--Makefile11
-rw-r--r--src/install/lockfile.zig9
-rw-r--r--src/install/semver.zig16
3 files changed, 23 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index daa70959d..2dddbed6d 100644
--- a/Makefile
+++ b/Makefile
@@ -1391,10 +1391,19 @@ bindings: $(DEBUG_OBJ_DIR) $(DEBUG_OBJ_FILES) $(DEBUG_WEBCORE_OBJ_FILES) $(DEBUG
.PHONY: jsc-bindings-mac
jsc-bindings-mac: bindings
+# lInux only
+MIMALLOC_VALGRIND_ENABLED_FLAG =
+
+ifeq ($(OS_NAME),linux)
+ MIMALLOC_VALGRIND_ENABLED_FLAG = -DMI_VALGRIND=ON
+endif
+
+
+.PHONY: mimalloc-debug
mimalloc-debug:
rm -rf $(BUN_DEPS_DIR)/mimalloc/CMakeCache* $(BUN_DEPS_DIR)/mimalloc/CMakeFiles
cd $(BUN_DEPS_DIR)/mimalloc; make clean || echo ""; \
- CFLAGS="$(CFLAGS)" cmake $(CMAKE_FLAGS_WITHOUT_RELEASE) ${MIMALLOC_OVERRIDE_FLAG} \
+ CFLAGS="$(CFLAGS)" cmake $(CMAKE_FLAGS_WITHOUT_RELEASE) ${MIMALLOC_OVERRIDE_FLAG} ${MIMALLOC_VALGRIND_ENABLED_FLAG} \
-DCMAKE_BUILD_TYPE=Debug \
-DMI_DEBUG_FULL=1 \
-DMI_SKIP_COLLECT_ON_EXIT=1 \
diff --git a/src/install/lockfile.zig b/src/install/lockfile.zig
index 74c467cb8..c8033c049 100644
--- a/src/install/lockfile.zig
+++ b/src/install/lockfile.zig
@@ -1583,12 +1583,11 @@ pub fn getOrPutID(this: *Lockfile, id: PackageID, name_hash: PackageNameHash) !v
switch (index.*) {
.PackageID => |single_| {
var ids = try this.allocator.alloc(PackageID, 8);
+ std.mem.set(PackageID, ids, invalid_package_id - 1);
+
ids[0] = single_;
ids[1] = id;
this.unique_packages.unset(single_);
- for (ids[2..7]) |_, i| {
- ids[i + 2] = invalid_package_id - 1;
- }
// stage1 compiler doesn't like this
ids[7] = invalid_package_id;
@@ -1598,7 +1597,7 @@ pub fn getOrPutID(this: *Lockfile, id: PackageID, name_hash: PackageNameHash) !v
};
},
.PackageIDMultiple => |ids_| {
- var ids = std.mem.span(ids_);
+ var ids = bun.sliceTo(ids_, invalid_package_id - 1);
for (ids) |id2, i| {
if (id2 == invalid_package_id - 1) {
ids[i] = id;
@@ -1607,6 +1606,8 @@ pub fn getOrPutID(this: *Lockfile, id: PackageID, name_hash: PackageNameHash) !v
}
var new_ids = try this.allocator.alloc(PackageID, ids.len + 8);
+ std.mem.set(PackageID, new_ids, invalid_package_id - 1);
+
defer this.allocator.free(ids);
for (ids) |id2, i| {
new_ids[i] = id2;
diff --git a/src/install/semver.zig b/src/install/semver.zig
index 656027227..c4d9b5b5f 100644
--- a/src/install/semver.zig
+++ b/src/install/semver.zig
@@ -44,14 +44,14 @@ pub const String = extern struct {
};
}
- pub inline fn assertDefined(this: *const String) void {
- if (comptime !Environment.allow_assert)
- return;
-
- if (this.isUndefined()) {
- @breakpoint();
- @panic("String is undefined");
- }
+ pub inline fn assertDefined(_: *const String) void {
+ // if (comptime !Environment.allow_assert)
+ // return;
+
+ // if (this.isUndefined()) {
+ // @breakpoint();
+ // @panic("String is undefined");
+ // }
}
pub inline fn init(