blocksInPreOrder and blocksInPostOrder should reserve the right capacity for their...
authorrmorisset@apple.com <rmorisset@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Mar 2019 17:42:42 +0000 (17:42 +0000)
committerrmorisset@apple.com <rmorisset@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 12 Mar 2019 17:42:42 +0000 (17:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=195595

Reviewed by Saam Barati.

Also change BlockList from being Vector<BasicBlock*, 5> to Vector<BasicBlock*>

* dfg/DFGBasicBlock.h:
* dfg/DFGGraph.cpp:
(JSC::DFG::Graph::blocksInPreOrder):
(JSC::DFG::Graph::blocksInPostOrder):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@242802 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/dfg/DFGBasicBlock.h
Source/JavaScriptCore/dfg/DFGGraph.cpp

index 42dfc6e..e7795e4 100644 (file)
@@ -1,3 +1,17 @@
+2019-03-12  Robin Morisset  <rmorisset@apple.com>
+
+        blocksInPreOrder and blocksInPostOrder should reserve the right capacity for their result vector
+        https://bugs.webkit.org/show_bug.cgi?id=195595
+
+        Reviewed by Saam Barati.
+
+        Also change BlockList from being Vector<BasicBlock*, 5> to Vector<BasicBlock*>
+
+        * dfg/DFGBasicBlock.h:
+        * dfg/DFGGraph.cpp:
+        (JSC::DFG::Graph::blocksInPreOrder):
+        (JSC::DFG::Graph::blocksInPostOrder):
+
 2019-03-11  Ross Kirsling  <ross.kirsling@sony.com>
 
         Add Optional to Forward.h.
index 1b93343..4c58c9c 100644 (file)
@@ -257,7 +257,7 @@ private:
     BlockNodeList m_nodes;
 };
 
-typedef Vector<BasicBlock*, 5> BlockList;
+typedef Vector<BasicBlock*> BlockList;
     
 static inline unsigned getBytecodeBeginForBlock(BasicBlock** basicBlock)
 {
index 5a60afb..78f3863 100644 (file)
@@ -888,6 +888,7 @@ void Graph::substituteGetLocal(BasicBlock& block, unsigned startIndexInBlock, Va
 BlockList Graph::blocksInPreOrder()
 {
     BlockList result;
+    result.reserveInitialCapacity(m_blocks.size());
     BlockWorklist worklist;
     for (BasicBlock* entrypoint : m_roots)
         worklist.push(entrypoint);
@@ -926,6 +927,7 @@ BlockList Graph::blocksInPreOrder()
 BlockList Graph::blocksInPostOrder(bool isSafeToValidate)
 {
     BlockList result;
+    result.reserveInitialCapacity(m_blocks.size());
     PostOrderBlockWorklist worklist;
     for (BasicBlock* entrypoint : m_roots)
         worklist.push(entrypoint);