From 877fe7d55036492a897d0928fe43d5df2bc6e2e5 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Wed, 18 Feb 2015 15:07:39 +0100 Subject: Initialize label vector lazily MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When parsing JSON temporary JIT objects are created when resolving each id. Each of these get a list of labels initialized to the size of the codeblock being operated on, which can be very long in some cases. This patch delays the initialization of the label vector, until it is actually used which is easy to figure out since the vector is not exported outside the class. Task-number: QTBUG-44475 Change-Id: I4fdbb7de7e7d953fffed39e38feed066edb6742b Reviewed-by: Michael BrĂ¼ning --- Source/JavaScriptCore/jit/JIT.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Source/JavaScriptCore/jit/JIT.cpp') diff --git a/Source/JavaScriptCore/jit/JIT.cpp b/Source/JavaScriptCore/jit/JIT.cpp index 8e003c782..9b46d8792 100644 --- a/Source/JavaScriptCore/jit/JIT.cpp +++ b/Source/JavaScriptCore/jit/JIT.cpp @@ -74,7 +74,7 @@ JIT::JIT(VM* vm, CodeBlock* codeBlock) : m_interpreter(vm->interpreter) , m_vm(vm) , m_codeBlock(codeBlock) - , m_labels(codeBlock ? codeBlock->numberOfInstructions() : 0) + , m_labels(0) , m_bytecodeOffset((unsigned)-1) , m_propertyAccessInstructionIndex(UINT_MAX) , m_byValInstructionIndex(UINT_MAX) @@ -96,6 +96,7 @@ JIT::JIT(VM* vm, CodeBlock* codeBlock) , m_shouldEmitProfiling(false) #endif { + m_labels.reserveCapacity(codeBlock ? codeBlock->numberOfInstructions() : 0); } #if ENABLE(DFG_JIT) @@ -174,6 +175,7 @@ void JIT::privateCompileMainPass() m_globalResolveInfoIndex = 0; m_callLinkInfoIndex = 0; + m_labels.resize(instructionCount); for (m_bytecodeOffset = 0; m_bytecodeOffset < instructionCount; ) { if (m_disassembler) @@ -694,6 +696,7 @@ JITCode JIT::privateCompile(CodePtr* functionEntryArityCheck, JITCompilationEffo if (patchBuffer.didFailToAllocate()) return JITCode(); + ASSERT(m_labels.size() >= m_codeBlock->instructionCount()); // Translate vPC offsets into addresses in JIT generated code, for switch tables. for (unsigned i = 0; i < m_switches.size(); ++i) { SwitchRecord record = m_switches[i]; -- cgit v1.2.1