]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - assembler/AssemblerBuffer.h
JavaScriptCore-721.26.tar.gz
[apple/javascriptcore.git] / assembler / AssemblerBuffer.h
index e1f53d8247ced129843fdaf533a62f2b1cede2e7..e2fb8a1cc68d019c0ed4305e9e5c0b3611bafd69 100644 (file)
@@ -26,8 +26,6 @@
 #ifndef AssemblerBuffer_h
 #define AssemblerBuffer_h
 
 #ifndef AssemblerBuffer_h
 #define AssemblerBuffer_h
 
-#include <wtf/Platform.h>
-
 #if ENABLE(ASSEMBLER)
 
 #include "stdint.h"
 #if ENABLE(ASSEMBLER)
 
 #include "stdint.h"
@@ -95,12 +93,14 @@ namespace JSC {
 
         void putIntUnchecked(int value)
         {
 
         void putIntUnchecked(int value)
         {
+            ASSERT(!(m_size > m_capacity - 4));
             *reinterpret_cast<int*>(&m_buffer[m_size]) = value;
             m_size += 4;
         }
 
         void putInt64Unchecked(int64_t value)
         {
             *reinterpret_cast<int*>(&m_buffer[m_size]) = value;
             m_size += 4;
         }
 
         void putInt64Unchecked(int64_t value)
         {
+            ASSERT(!(m_size > m_capacity - 8));
             *reinterpret_cast<int64_t*>(&m_buffer[m_size]) = value;
             m_size += 8;
         }
             *reinterpret_cast<int64_t*>(&m_buffer[m_size]) = value;
             m_size += 8;
         }
@@ -132,13 +132,24 @@ namespace JSC {
             if (!result)
                 return 0;
 
             if (!result)
                 return 0;
 
+            ExecutableAllocator::makeWritable(result, m_size);
+
             return memcpy(result, m_buffer, 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<char*>(fastMalloc(m_capacity));
 
             if (m_buffer == m_inlineBuffer) {
                 char* newBuffer = static_cast<char*>(fastMalloc(m_capacity));