X-Git-Url: https://git.saurik.com/apple/javascriptcore.git/blobdiff_plain/9dae56ea45a0f5f8136a5c93d6f3a7f99399ca73..b80e619319b1def83d1e8b4f84042b661be1be7f:/assembler/AssemblerBuffer.h?ds=sidebyside diff --git a/assembler/AssemblerBuffer.h b/assembler/AssemblerBuffer.h index e1f53d8..e2fb8a1 100644 --- a/assembler/AssemblerBuffer.h +++ b/assembler/AssemblerBuffer.h @@ -26,8 +26,6 @@ #ifndef AssemblerBuffer_h #define AssemblerBuffer_h -#include - #if ENABLE(ASSEMBLER) #include "stdint.h" @@ -95,12 +93,14 @@ namespace JSC { void putIntUnchecked(int value) { + ASSERT(!(m_size > m_capacity - 4)); *reinterpret_cast(&m_buffer[m_size]) = value; m_size += 4; } void putInt64Unchecked(int64_t value) { + ASSERT(!(m_size > m_capacity - 8)); *reinterpret_cast(&m_buffer[m_size]) = value; m_size += 8; } @@ -132,13 +132,24 @@ namespace JSC { if (!result) return 0; + ExecutableAllocator::makeWritable(result, m_size); + return memcpy(result, m_buffer, m_size); } - private: - void grow() + protected: + void append(const char* data, int size) + { + if (m_size > m_capacity - size) + grow(size); + + memcpy(m_buffer + m_size, data, size); + m_size += size; + } + + void grow(int extraCapacity = 0) { - m_capacity += m_capacity / 2; + m_capacity += m_capacity / 2 + extraCapacity; if (m_buffer == m_inlineBuffer) { char* newBuffer = static_cast(fastMalloc(m_capacity));