Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(425)

Side by Side Diff: src/compiler/bytecode-graph-builder.cc

Issue 2521313002: [turbofan] Access merge environment map more efficiently (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/bytecode-graph-builder.h" 5 #include "src/compiler/bytecode-graph-builder.h"
6 6
7 #include "src/ast/ast.h" 7 #include "src/ast/ast.h"
8 #include "src/ast/scopes.h" 8 #include "src/ast/scopes.h"
9 #include "src/compilation-info.h" 9 #include "src/compilation-info.h"
10 #include "src/compiler/bytecode-branch-analysis.h" 10 #include "src/compiler/bytecode-branch-analysis.h"
(...skipping 1878 matching lines...) Expand 10 before | Expand all | Expand 10 after
1889 } 1889 }
1890 1890
1891 void BytecodeGraphBuilder::VisitIllegal() { 1891 void BytecodeGraphBuilder::VisitIllegal() {
1892 // Not emitted in valid bytecode. 1892 // Not emitted in valid bytecode.
1893 UNREACHABLE(); 1893 UNREACHABLE();
1894 } 1894 }
1895 1895
1896 void BytecodeGraphBuilder::VisitNop() {} 1896 void BytecodeGraphBuilder::VisitNop() {}
1897 1897
1898 void BytecodeGraphBuilder::SwitchToMergeEnvironment(int current_offset) { 1898 void BytecodeGraphBuilder::SwitchToMergeEnvironment(int current_offset) {
1899 if (merge_environments_[current_offset] != nullptr) { 1899 auto it = merge_environments_.find(current_offset);
Michael Starzinger 2016/12/01 14:47:48 question: Any reason to use an iterator here and a
Leszek Swirski 2016/12/01 14:52:36 Indeed there is: the find+iterator does not create
Michael Starzinger 2016/12/01 15:00:51 Yes, I would prefer that. Thanks!
Michael Starzinger 2016/12/01 17:00:43 As discussed offline: Either is fine with me. Take
1900 if (it != merge_environments_.end()) {
1900 if (environment() != nullptr) { 1901 if (environment() != nullptr) {
1901 merge_environments_[current_offset]->Merge(environment()); 1902 it->second->Merge(environment());
1902 } 1903 }
1903 set_environment(merge_environments_[current_offset]); 1904 set_environment(it->second);
1904 } 1905 }
1905 } 1906 }
1906 1907
1907 void BytecodeGraphBuilder::BuildLoopHeaderEnvironment(int current_offset) { 1908 void BytecodeGraphBuilder::BuildLoopHeaderEnvironment(int current_offset) {
1908 if (branch_analysis()->backward_branches_target(current_offset)) { 1909 if (branch_analysis()->backward_branches_target(current_offset)) {
1909 // Add loop header and store a copy so we can connect merged back 1910 // Add loop header and store a copy so we can connect merged back
1910 // edge inputs to the loop header. 1911 // edge inputs to the loop header.
1911 merge_environments_[current_offset] = environment()->CopyForLoop(); 1912 merge_environments_[current_offset] = environment()->CopyForLoop();
1912 } 1913 }
1913 } 1914 }
1914 1915
1915 void BytecodeGraphBuilder::MergeIntoSuccessorEnvironment(int target_offset) { 1916 void BytecodeGraphBuilder::MergeIntoSuccessorEnvironment(int target_offset) {
1916 BuildLoopExitsForBranch(target_offset); 1917 BuildLoopExitsForBranch(target_offset);
1917 if (merge_environments_[target_offset] == nullptr) { 1918 Environment*& merge_environment = merge_environments_[target_offset];
1919 if (merge_environment == nullptr) {
1918 // Append merge nodes to the environment. We may merge here with another 1920 // Append merge nodes to the environment. We may merge here with another
1919 // environment. So add a place holder for merge nodes. We may add redundant 1921 // environment. So add a place holder for merge nodes. We may add redundant
1920 // but will be eliminated in a later pass. 1922 // but will be eliminated in a later pass.
1921 // TODO(mstarzinger): Be smarter about this! 1923 // TODO(mstarzinger): Be smarter about this!
1922 NewMerge(); 1924 NewMerge();
1923 merge_environments_[target_offset] = environment(); 1925 merge_environment = environment();
1924 } else { 1926 } else {
1925 merge_environments_[target_offset]->Merge(environment()); 1927 merge_environment->Merge(environment());
1926 } 1928 }
1927 set_environment(nullptr); 1929 set_environment(nullptr);
1928 } 1930 }
1929 1931
1930 void BytecodeGraphBuilder::MergeControlToLeaveFunction(Node* exit) { 1932 void BytecodeGraphBuilder::MergeControlToLeaveFunction(Node* exit) {
1931 exit_controls_.push_back(exit); 1933 exit_controls_.push_back(exit);
1932 set_environment(nullptr); 1934 set_environment(nullptr);
1933 } 1935 }
1934 1936
1935 void BytecodeGraphBuilder::BuildOSRLoopEntryPoint(int current_offset) { 1937 void BytecodeGraphBuilder::BuildOSRLoopEntryPoint(int current_offset) {
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
2231 it->source_position().ScriptOffset(), start_position_.InliningId())); 2233 it->source_position().ScriptOffset(), start_position_.InliningId()));
2232 it->Advance(); 2234 it->Advance();
2233 } else { 2235 } else {
2234 DCHECK_GT(it->code_offset(), offset); 2236 DCHECK_GT(it->code_offset(), offset);
2235 } 2237 }
2236 } 2238 }
2237 2239
2238 } // namespace compiler 2240 } // namespace compiler
2239 } // namespace internal 2241 } // namespace internal
2240 } // namespace v8 2242 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698