Skip to content

Commit

Permalink
Make option for maxCompiledByteCodeSize in VMInstance
Browse files Browse the repository at this point in the history
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
  • Loading branch information
ksh8281 authored and clover2123 committed Nov 21, 2023
1 parent fcc35d2 commit e9cec1d
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
10 changes: 10 additions & 0 deletions src/api/EscargotPublic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,16 @@ void VMInstanceRef::executePendingJobFromAnotherThread()
toImpl(this)->executePendingJobFromAnotherThread();
}

size_t VMInstanceRef::maxCompiledByteCodeSize()
{
return toImpl(this)->maxCompiledByteCodeSize();
}

void VMInstanceRef::setMaxCompiledByteCodeSize(size_t s)
{
toImpl(this)->setMaxCompiledByteCodeSize(s);
}

#ifdef ESCARGOT_DEBUGGER

class DebuggerOperationsRef::BreakpointOperations::ObjectStore {
Expand Down
3 changes: 3 additions & 0 deletions src/api/EscargotPublic.h
Original file line number Diff line number Diff line change
Expand Up @@ -721,6 +721,9 @@ class ESCARGOT_EXPORT VMInstanceRef {
bool hasPendingJobFromAnotherThread();
bool waitEventFromAnotherThread(unsigned timeoutInMillisecond = 0); // zero means infinity
void executePendingJobFromAnotherThread();

size_t maxCompiledByteCodeSize();
void setMaxCompiledByteCodeSize(size_t s);
};

class ESCARGOT_EXPORT DebuggerOperationsRef {
Expand Down
2 changes: 1 addition & 1 deletion src/codecache/CodeCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#endif

#ifndef CODE_CACHE_MIN_SOURCE_LENGTH
#define CODE_CACHE_MIN_SOURCE_LENGTH 1024 * 32
#define CODE_CACHE_MIN_SOURCE_LENGTH 1024 * 16
#endif

#ifndef CODE_CACHE_MAX_CACHE_NUM
Expand Down
3 changes: 2 additions & 1 deletion src/runtime/VMInstance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ void vmMarkStartCallback(void* data)
}

auto& currentCodeSizeTotal = self->compiledByteCodeSize();
if (currentCodeSizeTotal > SCRIPT_FUNCTION_OBJECT_BYTECODE_SIZE_MAX || UNLIKELY(self->inIdleMode())) {
if (currentCodeSizeTotal > self->maxCompiledByteCodeSize() || UNLIKELY(self->inIdleMode())) {
currentCodeSizeTotal = std::numeric_limits<size_t>::max();

auto& v = self->compiledByteCodeBlocks();
Expand Down Expand Up @@ -329,6 +329,7 @@ VMInstance::VMInstance(const char* locale, const char* timezone, const char* bas
, m_inIdleMode(false)
, m_didSomePrototypeObjectDefineIndexedProperty(false)
, m_compiledByteCodeSize(0)
, m_maxCompiledByteCodeSize(SCRIPT_FUNCTION_OBJECT_BYTECODE_SIZE_MAX)
#if defined(ENABLE_COMPRESSIBLE_STRING)
, m_lastCompressibleStringsTestTime(0)
, m_compressibleStringsUncomressedBufferSize(0)
Expand Down
11 changes: 11 additions & 0 deletions src/runtime/VMInstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,16 @@ class VMInstance : public gc {
return m_compiledByteCodeSize;
}

size_t maxCompiledByteCodeSize()
{
return m_maxCompiledByteCodeSize;
}

void setMaxCompiledByteCodeSize(size_t s)
{
m_maxCompiledByteCodeSize = s;
}

#if defined(ENABLE_COMPRESSIBLE_STRING)
std::vector<CompressibleString*>& compressibleStrings()
{
Expand Down Expand Up @@ -413,6 +423,7 @@ class VMInstance : public gc {

std::vector<ByteCodeBlock*> m_compiledByteCodeBlocks;
size_t m_compiledByteCodeSize;
size_t m_maxCompiledByteCodeSize;

#if defined(ENABLE_COMPRESSIBLE_STRING)
uint64_t m_lastCompressibleStringsTestTime;
Expand Down

0 comments on commit e9cec1d

Please sign in to comment.