Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ High-performance memory allocator with:
- Stack trace improvements
- Better error reporting for development

5. **Startup Snapshots**
- `heap/Heap.cpp` (`freezeCurrentHeapAsImmortalStartupSnapshot`, `resetPacingAfterSnapshotRestore`), `runtime/VM.cpp` (`didRestoreFromStartupSnapshot`)
- Freezes the live heap as immortal so an embedder can write the process's memory out and resume later launches from it

Comment thread
coderabbitai[bot] marked this conversation as resolved.
### USE_BUN_EVENT_LOOP
Custom event loop implementation for Bun's runtime requirements

Expand Down
1 change: 1 addition & 0 deletions Source/JavaScriptCore/bytecode/BytecodeRewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ void BytecodeRewriter::applyModification()
m_writer.m_instructions.insertVector(insertion.index.bytecodeOffset, insertion.instructions.m_instructions);
}
}
m_writer.didMutateBuffer();
m_insertions.clear();
}

Expand Down
10 changes: 10 additions & 0 deletions Source/JavaScriptCore/bytecode/ExpressionInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,14 @@ std::unique_ptr<ExpressionInfo> ExpressionInfo::createUninitialized(unsigned num
return std::unique_ptr<ExpressionInfo>(new (allocation) ExpressionInfo(numberOfChapters, numberOfEncodedInfo, numberOfEncodedInfoExtensions));
}

std::unique_ptr<ExpressionInfo> ExpressionInfo::createBorrowed(unsigned numberOfChapters, unsigned numberOfEncodedInfo, unsigned numberOfEncodedInfoExtensions, const unsigned* payload)
{
void* allocation = FastMalloc::malloc(sizeof(ExpressionInfo));
auto info = std::unique_ptr<ExpressionInfo>(new (allocation) ExpressionInfo(numberOfChapters, numberOfEncodedInfo, numberOfEncodedInfoExtensions));
info->m_borrowedPayload = const_cast<unsigned*>(payload);
return info;
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

ExpressionInfo::ExpressionInfo(unsigned numberOfChapters, unsigned numberOfEncodedInfo, unsigned numberOfEncodedInfoExtensions)
: m_numberOfChapters(numberOfChapters)
, m_numberOfEncodedInfo(numberOfEncodedInfo)
Expand All @@ -914,6 +922,8 @@ ExpressionInfo::ExpressionInfo(Vector<Chapter>&& chapters, Vector<EncodedInfo>&&

size_t ExpressionInfo::byteSize() const
{
if (m_borrowedPayload) [[unlikely]]
return sizeof(ExpressionInfo); // the payload belongs to the cache mapping, not to this object
return totalSizeInBytes(m_numberOfChapters, m_numberOfEncodedInfo, m_numberOfEncodedInfoExtensions);
}

Expand Down
7 changes: 6 additions & 1 deletion Source/JavaScriptCore/bytecode/ExpressionInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class ExpressionInfo {

Chapter* chapters() const
{
return std::bit_cast<Chapter*>(this + 1);
return std::bit_cast<Chapter*>(payload());
}

EncodedInfo* encodedInfo() const
Expand All @@ -239,10 +239,14 @@ class ExpressionInfo {

unsigned* payload() const
{
if (m_borrowedPayload) [[unlikely]]
return m_borrowedPayload;
return std::bit_cast<unsigned*>(this + 1);
}

static std::unique_ptr<ExpressionInfo> createUninitialized(unsigned numberOfChapters, unsigned numberOfEncodedInfo, unsigned numberOfEncodedInfoExtensions);
// Header-only object whose (immutable) payload lives elsewhere, e.g. inside an mmap'd bytecode cache.
static std::unique_ptr<ExpressionInfo> createBorrowed(unsigned numberOfChapters, unsigned numberOfEncodedInfo, unsigned numberOfEncodedInfoExtensions, const unsigned* payload);
Comment thread
coderabbitai[bot] marked this conversation as resolved.

static constexpr unsigned bitsPerWord = sizeof(unsigned) * CHAR_BIT;

Expand Down Expand Up @@ -323,6 +327,7 @@ class ExpressionInfo {
unsigned m_numberOfChapters;
unsigned m_numberOfEncodedInfo;
unsigned m_numberOfEncodedInfoExtensions;
unsigned* m_borrowedPayload { nullptr };
Comment thread
coderabbitai[bot] marked this conversation as resolved.
// Followed by the following which are allocated but are dynamically sized.
// Chapter chapters[numberOfChapters];
// EncodedInfo encodedInfo[numberOfEncodedInfo + numberOfEncodedInfoExtensions];
Expand Down
Loading
Loading