<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[195836] trunk/Source/JavaScriptCore</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/195836">195836</a></dd>
<dt>Author</dt> <dd>akling@apple.com</dd>
<dt>Date</dt> <dd>2016-01-29 12:37:52 -0800 (Fri, 29 Jan 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Shrink CodeBlock!
&lt;https://webkit.org/b/153640&gt;

Reviewed by Saam Barati.

Shrink CodeBlock by 112 bytes (from 640 to 528) by employing
these sophisticated tricks:

    - Remove members that are not used by anyone.
    - Don't cache both VM* and Heap* in members.
    - Reorder members to minimize struct padding.
    - Use RefCountedArray instead of Vector for arrays that never resize.
    - Put a not-always-present HashMap in a std::unique_ptr.

This increases CodeBlock space efficiency by 20%, as we can now
fit 30 of them in a MarkedBlock, up from 25.)

* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::CodeBlock):
(JSC::CodeBlock::finishCreation):
(JSC::CodeBlock::setNumParameters):
(JSC::CodeBlock::jettison):
(JSC::CodeBlock::noticeIncomingCall):
(JSC::CodeBlock::resultProfileForBytecodeOffset):
* bytecode/CodeBlock.h:
(JSC::CodeBlock::setJITCode):
(JSC::CodeBlock::capabilityLevelState):
(JSC::CodeBlock::codeType):
(JSC::CodeBlock::ensureResultProfile):
(JSC::CodeBlock::heap):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodeCodeBlockcpp">trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodeCodeBlockh">trunk/Source/JavaScriptCore/bytecode/CodeBlock.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (195835 => 195836)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-01-29 20:35:30 UTC (rev 195835)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-01-29 20:37:52 UTC (rev 195836)
</span><span class="lines">@@ -1,3 +1,36 @@
</span><ins>+2016-01-29  Andreas Kling  &lt;akling@apple.com&gt;
+
+        Shrink CodeBlock!
+        &lt;https://webkit.org/b/153640&gt;
+
+        Reviewed by Saam Barati.
+
+        Shrink CodeBlock by 112 bytes (from 640 to 528) by employing
+        these sophisticated tricks:
+
+            - Remove members that are not used by anyone.
+            - Don't cache both VM* and Heap* in members.
+            - Reorder members to minimize struct padding.
+            - Use RefCountedArray instead of Vector for arrays that never resize.
+            - Put a not-always-present HashMap in a std::unique_ptr.
+
+        This increases CodeBlock space efficiency by 20%, as we can now
+        fit 30 of them in a MarkedBlock, up from 25.)
+
+        * bytecode/CodeBlock.cpp:
+        (JSC::CodeBlock::CodeBlock):
+        (JSC::CodeBlock::finishCreation):
+        (JSC::CodeBlock::setNumParameters):
+        (JSC::CodeBlock::jettison):
+        (JSC::CodeBlock::noticeIncomingCall):
+        (JSC::CodeBlock::resultProfileForBytecodeOffset):
+        * bytecode/CodeBlock.h:
+        (JSC::CodeBlock::setJITCode):
+        (JSC::CodeBlock::capabilityLevelState):
+        (JSC::CodeBlock::codeType):
+        (JSC::CodeBlock::ensureResultProfile):
+        (JSC::CodeBlock::heap):
+
</ins><span class="cx"> 2016-01-29  Saam barati  &lt;sbarati@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Exits from exceptions shouldn't jettison code
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeCodeBlockcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp (195835 => 195836)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp        2016-01-29 20:35:30 UTC (rev 195835)
+++ trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp        2016-01-29 20:37:52 UTC (rev 195836)
</span><span class="lines">@@ -1740,13 +1740,18 @@
</span><span class="cx"> CodeBlock::CodeBlock(VM* vm, Structure* structure, CopyParsedBlockTag, CodeBlock&amp; other)
</span><span class="cx">     : JSCell(*vm, structure)
</span><span class="cx">     , m_globalObject(other.m_globalObject)
</span><del>-    , m_heap(other.m_heap)
</del><span class="cx">     , m_numCalleeLocals(other.m_numCalleeLocals)
</span><span class="cx">     , m_numVars(other.m_numVars)
</span><del>-    , m_isConstructor(other.m_isConstructor)
</del><span class="cx">     , m_shouldAlwaysBeInlined(true)
</span><ins>+#if ENABLE(JIT)
+    , m_capabilityLevelState(DFG::CapabilityLevelNotSet)
+#endif
</ins><span class="cx">     , m_didFailFTLCompilation(false)
</span><span class="cx">     , m_hasBeenCompiledWithFTL(false)
</span><ins>+    , m_isConstructor(other.m_isConstructor)
+    , m_isStrictMode(other.m_isStrictMode)
+    , m_needsActivation(other.m_needsActivation)
+    , m_codeType(other.m_codeType)
</ins><span class="cx">     , m_unlinkedCode(*other.m_vm, this, other.m_unlinkedCode.get())
</span><span class="cx">     , m_hasDebuggerStatement(false)
</span><span class="cx">     , m_steppingMode(SteppingModeDisabled)
</span><span class="lines">@@ -1757,12 +1762,10 @@
</span><span class="cx">     , m_thisRegister(other.m_thisRegister)
</span><span class="cx">     , m_scopeRegister(other.m_scopeRegister)
</span><span class="cx">     , m_lexicalEnvironmentRegister(other.m_lexicalEnvironmentRegister)
</span><del>-    , m_isStrictMode(other.m_isStrictMode)
-    , m_needsActivation(other.m_needsActivation)
</del><ins>+    , m_hash(other.m_hash)
</ins><span class="cx">     , m_source(other.m_source)
</span><span class="cx">     , m_sourceOffset(other.m_sourceOffset)
</span><span class="cx">     , m_firstLineColumnOffset(other.m_firstLineColumnOffset)
</span><del>-    , m_codeType(other.m_codeType)
</del><span class="cx">     , m_constantRegisters(other.m_constantRegisters)
</span><span class="cx">     , m_constantsSourceCodeRepresentation(other.m_constantsSourceCodeRepresentation)
</span><span class="cx">     , m_functionDecls(other.m_functionDecls)
</span><span class="lines">@@ -1771,14 +1774,10 @@
</span><span class="cx">     , m_optimizationDelayCounter(0)
</span><span class="cx">     , m_reoptimizationRetryCounter(0)
</span><span class="cx">     , m_creationTime(std::chrono::steady_clock::now())
</span><del>-    , m_hash(other.m_hash)
-#if ENABLE(JIT)
-    , m_capabilityLevelState(DFG::CapabilityLevelNotSet)
-#endif
</del><span class="cx"> {
</span><span class="cx">     m_visitWeaklyHasBeenCalled.store(false, std::memory_order_relaxed);
</span><span class="cx"> 
</span><del>-    ASSERT(m_heap-&gt;isDeferred());
</del><ins>+    ASSERT(heap()-&gt;isDeferred());
</ins><span class="cx">     ASSERT(m_scopeRegister.isLocal());
</span><span class="cx"> 
</span><span class="cx">     setNumParameters(other.numParameters());
</span><span class="lines">@@ -1801,20 +1800,25 @@
</span><span class="cx">         m_rareData-&gt;m_liveCalleeLocalsAtYield = other.m_rareData-&gt;m_liveCalleeLocalsAtYield;
</span><span class="cx">     }
</span><span class="cx">     
</span><del>-    m_heap-&gt;m_codeBlocks.add(this);
</del><ins>+    heap()-&gt;m_codeBlocks.add(this);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> CodeBlock::CodeBlock(VM* vm, Structure* structure, ScriptExecutable* ownerExecutable, UnlinkedCodeBlock* unlinkedCodeBlock,
</span><span class="cx">     JSScope* scope, PassRefPtr&lt;SourceProvider&gt; sourceProvider, unsigned sourceOffset, unsigned firstLineColumnOffset)
</span><span class="cx">     : JSCell(*vm, structure)
</span><span class="cx">     , m_globalObject(scope-&gt;globalObject()-&gt;vm(), this, scope-&gt;globalObject())
</span><del>-    , m_heap(&amp;m_globalObject-&gt;vm().heap)
</del><span class="cx">     , m_numCalleeLocals(unlinkedCodeBlock-&gt;m_numCalleeLocals)
</span><span class="cx">     , m_numVars(unlinkedCodeBlock-&gt;m_numVars)
</span><del>-    , m_isConstructor(unlinkedCodeBlock-&gt;isConstructor())
</del><span class="cx">     , m_shouldAlwaysBeInlined(true)
</span><ins>+#if ENABLE(JIT)
+    , m_capabilityLevelState(DFG::CapabilityLevelNotSet)
+#endif
</ins><span class="cx">     , m_didFailFTLCompilation(false)
</span><span class="cx">     , m_hasBeenCompiledWithFTL(false)
</span><ins>+    , m_isConstructor(unlinkedCodeBlock-&gt;isConstructor())
+    , m_isStrictMode(unlinkedCodeBlock-&gt;isStrictMode())
+    , m_needsActivation(unlinkedCodeBlock-&gt;hasActivationRegister() &amp;&amp; unlinkedCodeBlock-&gt;codeType() == FunctionCode)
+    , m_codeType(unlinkedCodeBlock-&gt;codeType())
</ins><span class="cx">     , m_unlinkedCode(m_globalObject-&gt;vm(), this, unlinkedCodeBlock)
</span><span class="cx">     , m_hasDebuggerStatement(false)
</span><span class="cx">     , m_steppingMode(SteppingModeDisabled)
</span><span class="lines">@@ -1824,23 +1828,17 @@
</span><span class="cx">     , m_thisRegister(unlinkedCodeBlock-&gt;thisRegister())
</span><span class="cx">     , m_scopeRegister(unlinkedCodeBlock-&gt;scopeRegister())
</span><span class="cx">     , m_lexicalEnvironmentRegister(unlinkedCodeBlock-&gt;activationRegister())
</span><del>-    , m_isStrictMode(unlinkedCodeBlock-&gt;isStrictMode())
-    , m_needsActivation(unlinkedCodeBlock-&gt;hasActivationRegister() &amp;&amp; unlinkedCodeBlock-&gt;codeType() == FunctionCode)
</del><span class="cx">     , m_source(sourceProvider)
</span><span class="cx">     , m_sourceOffset(sourceOffset)
</span><span class="cx">     , m_firstLineColumnOffset(firstLineColumnOffset)
</span><del>-    , m_codeType(unlinkedCodeBlock-&gt;codeType())
</del><span class="cx">     , m_osrExitCounter(0)
</span><span class="cx">     , m_optimizationDelayCounter(0)
</span><span class="cx">     , m_reoptimizationRetryCounter(0)
</span><span class="cx">     , m_creationTime(std::chrono::steady_clock::now())
</span><del>-#if ENABLE(JIT)
-    , m_capabilityLevelState(DFG::CapabilityLevelNotSet)
-#endif
</del><span class="cx"> {
</span><span class="cx">     m_visitWeaklyHasBeenCalled.store(false, std::memory_order_relaxed);
</span><span class="cx"> 
</span><del>-    ASSERT(m_heap-&gt;isDeferred());
</del><ins>+    ASSERT(heap()-&gt;isDeferred());
</ins><span class="cx">     ASSERT(m_scopeRegister.isLocal());
</span><span class="cx"> 
</span><span class="cx">     ASSERT(m_source);
</span><span class="lines">@@ -1894,7 +1892,7 @@
</span><span class="cx">         replaceConstant(unlinkedModuleProgramCodeBlock-&gt;moduleEnvironmentSymbolTableConstantRegisterOffset(), clonedSymbolTable);
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    m_functionDecls.resizeToFit(unlinkedCodeBlock-&gt;numberOfFunctionDecls());
</del><ins>+    m_functionDecls = RefCountedArray&lt;WriteBarrier&lt;FunctionExecutable&gt;&gt;(unlinkedCodeBlock-&gt;numberOfFunctionDecls());
</ins><span class="cx">     for (size_t count = unlinkedCodeBlock-&gt;numberOfFunctionDecls(), i = 0; i &lt; count; ++i) {
</span><span class="cx">         UnlinkedFunctionExecutable* unlinkedExecutable = unlinkedCodeBlock-&gt;functionDecl(i);
</span><span class="cx">         if (vm.typeProfiler() || vm.controlFlowProfiler())
</span><span class="lines">@@ -1902,7 +1900,7 @@
</span><span class="cx">         m_functionDecls[i].set(*m_vm, this, unlinkedExecutable-&gt;link(*m_vm, ownerExecutable-&gt;source()));
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    m_functionExprs.resizeToFit(unlinkedCodeBlock-&gt;numberOfFunctionExprs());
</del><ins>+    m_functionExprs = RefCountedArray&lt;WriteBarrier&lt;FunctionExecutable&gt;&gt;(unlinkedCodeBlock-&gt;numberOfFunctionExprs());
</ins><span class="cx">     for (size_t count = unlinkedCodeBlock-&gt;numberOfFunctionExprs(), i = 0; i &lt; count; ++i) {
</span><span class="cx">         UnlinkedFunctionExecutable* unlinkedExecutable = unlinkedCodeBlock-&gt;functionExpr(i);
</span><span class="cx">         if (vm.typeProfiler() || vm.controlFlowProfiler())
</span><span class="lines">@@ -1958,15 +1956,15 @@
</span><span class="cx"> 
</span><span class="cx">     // Allocate metadata buffers for the bytecode
</span><span class="cx">     if (size_t size = unlinkedCodeBlock-&gt;numberOfLLintCallLinkInfos())
</span><del>-        m_llintCallLinkInfos.resizeToFit(size);
</del><ins>+        m_llintCallLinkInfos = RefCountedArray&lt;LLIntCallLinkInfo&gt;(size);
</ins><span class="cx">     if (size_t size = unlinkedCodeBlock-&gt;numberOfArrayProfiles())
</span><span class="cx">         m_arrayProfiles.grow(size);
</span><span class="cx">     if (size_t size = unlinkedCodeBlock-&gt;numberOfArrayAllocationProfiles())
</span><del>-        m_arrayAllocationProfiles.resizeToFit(size);
</del><ins>+        m_arrayAllocationProfiles = RefCountedArray&lt;ArrayAllocationProfile&gt;(size);
</ins><span class="cx">     if (size_t size = unlinkedCodeBlock-&gt;numberOfValueProfiles())
</span><del>-        m_valueProfiles.resizeToFit(size);
</del><ins>+        m_valueProfiles = RefCountedArray&lt;ValueProfile&gt;(size);
</ins><span class="cx">     if (size_t size = unlinkedCodeBlock-&gt;numberOfObjectAllocationProfiles())
</span><del>-        m_objectAllocationProfiles.resizeToFit(size);
</del><ins>+        m_objectAllocationProfiles = RefCountedArray&lt;ObjectAllocationProfile&gt;(size);
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(JIT)
</span><span class="cx">     setCalleeSaveRegisters(RegisterSet::llintBaselineCalleeSaveRegisters());
</span><span class="lines">@@ -2318,45 +2316,44 @@
</span><span class="cx">     if (Options::dumpGeneratedBytecodes())
</span><span class="cx">         dumpBytecode();
</span><span class="cx">     
</span><del>-    m_heap-&gt;m_codeBlocks.add(this);
-    m_heap-&gt;reportExtraMemoryAllocated(m_instructions.size() * sizeof(Instruction));
</del><ins>+    heap()-&gt;m_codeBlocks.add(this);
+    heap()-&gt;reportExtraMemoryAllocated(m_instructions.size() * sizeof(Instruction));
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(WEBASSEMBLY)
</span><span class="cx"> CodeBlock::CodeBlock(VM* vm, Structure* structure, WebAssemblyExecutable* ownerExecutable, JSGlobalObject* globalObject)
</span><span class="cx">     : JSCell(*vm, structure)
</span><span class="cx">     , m_globalObject(globalObject-&gt;vm(), this, globalObject)
</span><del>-    , m_heap(&amp;m_globalObject-&gt;vm().heap)
</del><span class="cx">     , m_numCalleeLocals(0)
</span><span class="cx">     , m_numVars(0)
</span><del>-    , m_isConstructor(false)
</del><span class="cx">     , m_shouldAlwaysBeInlined(false)
</span><ins>+#if ENABLE(JIT)
+    , m_capabilityLevelState(DFG::CannotCompile)
+#endif
</ins><span class="cx">     , m_didFailFTLCompilation(false)
</span><span class="cx">     , m_hasBeenCompiledWithFTL(false)
</span><ins>+    , m_isConstructor(false)
+    , m_isStrictMode(false)
+    , m_needsActivation(false)
+    , m_codeType(FunctionCode)
</ins><span class="cx">     , m_hasDebuggerStatement(false)
</span><span class="cx">     , m_steppingMode(SteppingModeDisabled)
</span><span class="cx">     , m_numBreakpoints(0)
</span><span class="cx">     , m_ownerExecutable(m_globalObject-&gt;vm(), this, ownerExecutable)
</span><span class="cx">     , m_vm(vm)
</span><del>-    , m_isStrictMode(false)
-    , m_needsActivation(false)
-    , m_codeType(FunctionCode)
</del><span class="cx">     , m_osrExitCounter(0)
</span><span class="cx">     , m_optimizationDelayCounter(0)
</span><span class="cx">     , m_reoptimizationRetryCounter(0)
</span><span class="cx">     , m_creationTime(std::chrono::steady_clock::now())
</span><del>-#if ENABLE(JIT)
-    , m_capabilityLevelState(DFG::CannotCompile)
-#endif
</del><span class="cx"> {
</span><del>-    ASSERT(m_heap-&gt;isDeferred());
</del><ins>+    ASSERT(heap()-&gt;isDeferred());
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void CodeBlock::finishCreation(VM&amp; vm, WebAssemblyExecutable*, JSGlobalObject*)
</span><span class="cx"> {
</span><span class="cx">     Base::finishCreation(vm);
</span><span class="cx"> 
</span><del>-    m_heap-&gt;m_codeBlocks.add(this);
</del><ins>+    heap()-&gt;m_codeBlocks.add(this);
</ins><span class="cx"> }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="lines">@@ -2399,7 +2396,7 @@
</span><span class="cx"> {
</span><span class="cx">     m_numParameters = newValue;
</span><span class="cx"> 
</span><del>-    m_argumentValueProfiles.resizeToFit(newValue);
</del><ins>+    m_argumentValueProfiles = RefCountedArray&lt;ValueProfile&gt;(newValue);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void EvalCodeCache::visitAggregate(SlotVisitor&amp; visitor)
</span><span class="lines">@@ -3295,7 +3292,7 @@
</span><span class="cx">     }
</span><span class="cx"> #endif // ENABLE(DFG_JIT)
</span><span class="cx"> 
</span><del>-    DeferGCForAWhile deferGC(*m_heap);
</del><ins>+    DeferGCForAWhile deferGC(*heap());
</ins><span class="cx">     
</span><span class="cx">     // We want to accomplish two things here:
</span><span class="cx">     // 1) Make sure that if this CodeBlock is on the stack right now, then if we return to it
</span><span class="lines">@@ -3421,7 +3418,7 @@
</span><span class="cx">     if (!DFG::mightInlineFunction(this))
</span><span class="cx">         return;
</span><span class="cx"> 
</span><del>-    if (!canInline(m_capabilityLevelState))
</del><ins>+    if (!canInline(capabilityLevelState()))
</ins><span class="cx">         return;
</span><span class="cx">     
</span><span class="cx">     if (!DFG::isSmallEnoughToInlineCodeInto(callerCodeBlock)) {
</span><span class="lines">@@ -3470,12 +3467,12 @@
</span><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx">     
</span><del>-    if (callerCodeBlock-&gt;m_capabilityLevelState == DFG::CapabilityLevelNotSet) {
</del><ins>+    if (callerCodeBlock-&gt;capabilityLevelState() == DFG::CapabilityLevelNotSet) {
</ins><span class="cx">         dataLog(&quot;In call from &quot;, *callerCodeBlock, &quot; &quot;, callerFrame-&gt;codeOrigin(), &quot; to &quot;, *this, &quot;: caller's DFG capability level is not set.\n&quot;);
</span><span class="cx">         CRASH();
</span><span class="cx">     }
</span><span class="cx">     
</span><del>-    if (canCompile(callerCodeBlock-&gt;m_capabilityLevelState))
</del><ins>+    if (canCompile(callerCodeBlock-&gt;capabilityLevelState()))
</ins><span class="cx">         return;
</span><span class="cx">     
</span><span class="cx">     if (Options::verboseCallLink())
</span><span class="lines">@@ -4193,9 +4190,11 @@
</span><span class="cx"> 
</span><span class="cx"> ResultProfile* CodeBlock::resultProfileForBytecodeOffset(int bytecodeOffset)
</span><span class="cx"> {
</span><del>-    auto iterator = m_bytecodeOffsetToResultProfileIndexMap.find(bytecodeOffset);
-    if (iterator == m_bytecodeOffsetToResultProfileIndexMap.end())
</del><ins>+    if (!m_bytecodeOffsetToResultProfileIndexMap)
</ins><span class="cx">         return nullptr;
</span><ins>+    auto iterator = m_bytecodeOffsetToResultProfileIndexMap-&gt;find(bytecodeOffset);
+    if (iterator == m_bytecodeOffsetToResultProfileIndexMap-&gt;end())
+        return nullptr;
</ins><span class="cx">     return &amp;m_resultProfiles[iterator-&gt;value];
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeCodeBlockh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/CodeBlock.h (195835 => 195836)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/CodeBlock.h        2016-01-29 20:35:30 UTC (rev 195835)
+++ trunk/Source/JavaScriptCore/bytecode/CodeBlock.h        2016-01-29 20:37:52 UTC (rev 195836)
</span><span class="lines">@@ -122,7 +122,6 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     WriteBarrier&lt;JSGlobalObject&gt; m_globalObject;
</span><del>-    Heap* m_heap;
</del><span class="cx"> 
</span><span class="cx"> public:
</span><span class="cx">     JS_EXPORT_PRIVATE ~CodeBlock();
</span><span class="lines">@@ -296,8 +295,8 @@
</span><span class="cx">     
</span><span class="cx">     void setJITCode(PassRefPtr&lt;JITCode&gt; code)
</span><span class="cx">     {
</span><del>-        ASSERT(m_heap-&gt;isDeferred());
-        m_heap-&gt;reportExtraMemoryAllocated(code-&gt;size());
</del><ins>+        ASSERT(heap()-&gt;isDeferred());
+        heap()-&gt;reportExtraMemoryAllocated(code-&gt;size());
</ins><span class="cx">         ConcurrentJITLocker locker(m_lock);
</span><span class="cx">         WTF::storeStoreFence(); // This is probably not needed because the lock will also do something similar, but it's good to be paranoid.
</span><span class="cx">         m_jitCode = code;
</span><span class="lines">@@ -323,7 +322,7 @@
</span><span class="cx"> 
</span><span class="cx">     DFG::CapabilityLevel computeCapabilityLevel();
</span><span class="cx">     DFG::CapabilityLevel capabilityLevel();
</span><del>-    DFG::CapabilityLevel capabilityLevelState() { return m_capabilityLevelState; }
</del><ins>+    DFG::CapabilityLevel capabilityLevelState() { return static_cast&lt;DFG::CapabilityLevel&gt;(m_capabilityLevelState); }
</ins><span class="cx"> 
</span><span class="cx">     bool hasOptimizedReplacement(JITCode::JITType typeToReplace);
</span><span class="cx">     bool hasOptimizedReplacement(); // the typeToReplace is my JITType
</span><span class="lines">@@ -377,7 +376,7 @@
</span><span class="cx">     
</span><span class="cx">     CodeType codeType() const
</span><span class="cx">     {
</span><del>-        return m_codeType;
</del><ins>+        return static_cast&lt;CodeType&gt;(m_codeType);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     PutPropertySlot::Context putByIdContext() const
</span><span class="lines">@@ -460,7 +459,9 @@
</span><span class="cx">             m_resultProfiles.append(ResultProfile(bytecodeOffset));
</span><span class="cx">             profile = &amp;m_resultProfiles.last();
</span><span class="cx">             ASSERT(&amp;m_resultProfiles.last() == &amp;m_resultProfiles[m_resultProfiles.size() - 1]);
</span><del>-            m_bytecodeOffsetToResultProfileIndexMap.add(bytecodeOffset, m_resultProfiles.size() - 1);
</del><ins>+            if (!m_bytecodeOffsetToResultProfileIndexMap)
+                m_bytecodeOffsetToResultProfileIndexMap = std::make_unique&lt;BytecodeOffsetToResultProfileIndexMap&gt;();
+            m_bytecodeOffsetToResultProfileIndexMap-&gt;add(bytecodeOffset, m_resultProfiles.size() - 1);
</ins><span class="cx">         }
</span><span class="cx">         return profile;
</span><span class="cx">     }
</span><span class="lines">@@ -610,7 +611,7 @@
</span><span class="cx">         return constantBufferAsVector(index).data();
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    Heap* heap() const { return m_heap; }
</del><ins>+    Heap* heap() const { return &amp;m_vm-&gt;heap; }
</ins><span class="cx">     JSGlobalObject* globalObject() { return m_globalObject.get(); }
</span><span class="cx"> 
</span><span class="cx">     JSGlobalObject* globalObjectFor(CodeOrigin);
</span><span class="lines">@@ -862,10 +863,8 @@
</span><span class="cx">     
</span><span class="cx">     // FIXME: Make these remaining members private.
</span><span class="cx"> 
</span><del>-    int m_numLocalRegistersForCalleeSaves;
</del><span class="cx">     int m_numCalleeLocals;
</span><span class="cx">     int m_numVars;
</span><del>-    bool m_isConstructor : 1;
</del><span class="cx">     
</span><span class="cx">     // This is intentionally public; it's the responsibility of anyone doing any
</span><span class="cx">     // of the following to hold the lock:
</span><span class="lines">@@ -884,12 +883,23 @@
</span><span class="cx">     // without holding any locks, because the GC is guaranteed to wait until any
</span><span class="cx">     // concurrent compilation threads finish what they're doing.
</span><span class="cx">     mutable ConcurrentJITLock m_lock;
</span><del>-    
</del><ins>+
+    Atomic&lt;bool&gt; m_visitWeaklyHasBeenCalled;
+
</ins><span class="cx">     bool m_shouldAlwaysBeInlined; // Not a bitfield because the JIT wants to store to it.
</span><ins>+
+#if ENABLE(JIT)
+    unsigned m_capabilityLevelState : 2; // DFG::CapabilityLevel
+#endif
+
</ins><span class="cx">     bool m_allTransitionsHaveBeenMarked : 1; // Initialized and used on every GC.
</span><del>-    
</del><ins>+
</ins><span class="cx">     bool m_didFailFTLCompilation : 1;
</span><span class="cx">     bool m_hasBeenCompiledWithFTL : 1;
</span><ins>+    bool m_isConstructor : 1;
+    bool m_isStrictMode : 1;
+    bool m_needsActivation : 1;
+    unsigned m_codeType : 2; // CodeType
</ins><span class="cx"> 
</span><span class="cx">     // Internal methods for use by validation code. It would be private if it wasn't
</span><span class="cx">     // for the fact that we use it from anonymous namespaces.
</span><span class="lines">@@ -1030,18 +1040,13 @@
</span><span class="cx">     VirtualRegister m_thisRegister;
</span><span class="cx">     VirtualRegister m_scopeRegister;
</span><span class="cx">     VirtualRegister m_lexicalEnvironmentRegister;
</span><ins>+    mutable CodeBlockHash m_hash;
</ins><span class="cx"> 
</span><del>-    bool m_isStrictMode;
-    bool m_needsActivation;
-
-    Atomic&lt;bool&gt; m_visitWeaklyHasBeenCalled;
-
</del><span class="cx">     RefPtr&lt;SourceProvider&gt; m_source;
</span><span class="cx">     unsigned m_sourceOffset;
</span><span class="cx">     unsigned m_firstLineColumnOffset;
</span><del>-    CodeType m_codeType;
</del><span class="cx"> 
</span><del>-    Vector&lt;LLIntCallLinkInfo&gt; m_llintCallLinkInfos;
</del><ins>+    RefCountedArray&lt;LLIntCallLinkInfo&gt; m_llintCallLinkInfos;
</ins><span class="cx">     SentinelLinkedList&lt;LLIntCallLinkInfo, BasicRawSentinelNode&lt;LLIntCallLinkInfo&gt;&gt; m_incomingLLIntCalls;
</span><span class="cx">     RefPtr&lt;JITCode&gt; m_jitCode;
</span><span class="cx"> #if ENABLE(JIT)
</span><span class="lines">@@ -1059,14 +1064,15 @@
</span><span class="cx">     DFG::ExitProfile m_exitProfile;
</span><span class="cx">     CompressedLazyOperandValueProfileHolder m_lazyOperandValueProfiles;
</span><span class="cx"> #endif
</span><del>-    Vector&lt;ValueProfile&gt; m_argumentValueProfiles;
-    Vector&lt;ValueProfile&gt; m_valueProfiles;
</del><ins>+    RefCountedArray&lt;ValueProfile&gt; m_argumentValueProfiles;
+    RefCountedArray&lt;ValueProfile&gt; m_valueProfiles;
</ins><span class="cx">     SegmentedVector&lt;RareCaseProfile, 8&gt; m_rareCaseProfiles;
</span><span class="cx">     SegmentedVector&lt;ResultProfile, 8&gt; m_resultProfiles;
</span><del>-    HashMap&lt;unsigned, unsigned, IntHash&lt;unsigned&gt;, WTF::UnsignedWithZeroKeyHashTraits&lt;unsigned&gt;&gt; m_bytecodeOffsetToResultProfileIndexMap;
-    Vector&lt;ArrayAllocationProfile&gt; m_arrayAllocationProfiles;
</del><ins>+    typedef HashMap&lt;unsigned, unsigned, IntHash&lt;unsigned&gt;, WTF::UnsignedWithZeroKeyHashTraits&lt;unsigned&gt;&gt; BytecodeOffsetToResultProfileIndexMap;
+    std::unique_ptr&lt;BytecodeOffsetToResultProfileIndexMap&gt; m_bytecodeOffsetToResultProfileIndexMap;
+    RefCountedArray&lt;ArrayAllocationProfile&gt; m_arrayAllocationProfiles;
</ins><span class="cx">     ArrayProfileVector m_arrayProfiles;
</span><del>-    Vector&lt;ObjectAllocationProfile&gt; m_objectAllocationProfiles;
</del><ins>+    RefCountedArray&lt;ObjectAllocationProfile&gt; m_objectAllocationProfiles;
</ins><span class="cx"> 
</span><span class="cx">     // Constant Pool
</span><span class="cx">     COMPILE_ASSERT(sizeof(Register) == sizeof(WriteBarrier&lt;Unknown&gt;), Register_must_be_same_size_as_WriteBarrier_Unknown);
</span><span class="lines">@@ -1074,29 +1080,23 @@
</span><span class="cx">     // it, so we're stuck with it for now.
</span><span class="cx">     Vector&lt;WriteBarrier&lt;Unknown&gt;&gt; m_constantRegisters;
</span><span class="cx">     Vector&lt;SourceCodeRepresentation&gt; m_constantsSourceCodeRepresentation;
</span><del>-    Vector&lt;WriteBarrier&lt;FunctionExecutable&gt;&gt; m_functionDecls;
-    Vector&lt;WriteBarrier&lt;FunctionExecutable&gt;&gt; m_functionExprs;
</del><ins>+    RefCountedArray&lt;WriteBarrier&lt;FunctionExecutable&gt;&gt; m_functionDecls;
+    RefCountedArray&lt;WriteBarrier&lt;FunctionExecutable&gt;&gt; m_functionExprs;
</ins><span class="cx"> 
</span><span class="cx">     WriteBarrier&lt;CodeBlock&gt; m_alternative;
</span><span class="cx">     
</span><span class="cx">     BaselineExecutionCounter m_llintExecuteCounter;
</span><span class="cx"> 
</span><span class="cx">     BaselineExecutionCounter m_jitExecuteCounter;
</span><del>-    int32_t m_totalJITExecutions;
</del><span class="cx">     uint32_t m_osrExitCounter;
</span><span class="cx">     uint16_t m_optimizationDelayCounter;
</span><span class="cx">     uint16_t m_reoptimizationRetryCounter;
</span><span class="cx"> 
</span><span class="cx">     std::chrono::steady_clock::time_point m_creationTime;
</span><span class="cx"> 
</span><del>-    mutable CodeBlockHash m_hash;
-
</del><span class="cx">     std::unique_ptr&lt;BytecodeLivenessAnalysis&gt; m_livenessAnalysis;
</span><span class="cx"> 
</span><span class="cx">     std::unique_ptr&lt;RareData&gt; m_rareData;
</span><del>-#if ENABLE(JIT)
-    DFG::CapabilityLevel m_capabilityLevelState;
-#endif
</del><span class="cx"> 
</span><span class="cx">     UnconditionalFinalizer m_unconditionalFinalizer;
</span><span class="cx">     WeakReferenceHarvester m_weakReferenceHarvester;
</span></span></pre>
</div>
</div>

</body>
</html>