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

Unified Diff: src/compiler/bytecode-branch-analysis.h

Issue 1502243002: [Interpreter] Local flow control in the bytecode graph builder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 5 years 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 side-by-side diff with in-line comments
Download patch
Index: src/compiler/bytecode-branch-analysis.h
diff --git a/src/compiler/bytecode-branch-analysis.h b/src/compiler/bytecode-branch-analysis.h
new file mode 100644
index 0000000000000000000000000000000000000000..b035a752ff388f435b34e69b8bdf695b5614325b
--- /dev/null
+++ b/src/compiler/bytecode-branch-analysis.h
@@ -0,0 +1,74 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef V8_COMPILER_BYTECODE_BRANCH_ANALYSIS_H_
+#define V8_COMPILER_BYTECODE_BRANCH_ANALYSIS_H_
+
+#include "src/bit-vector.h"
+#include "src/compiler.h"
+#include "src/zone-containers.h"
+
+namespace v8 {
+namespace internal {
+namespace compiler {
+
+class BytecodeBranchInfo;
+
+class BytecodeBranchAnalysis BASE_EMBEDDED {
rmcilroy 2015/12/15 17:35:43 A comment on what the class does would be good
oth 2015/12/15 22:42:17 Done.
+ public:
+ BytecodeBranchAnalysis(Handle<BytecodeArray> bytecode_array, Zone* zone)
+ : branch_infos_(zone),
+ bytecode_array_(bytecode_array),
+ reachable_(bytecode_array->length(), zone),
+ zone_(zone) {}
+
+ void Analyze();
rmcilroy 2015/12/15 17:35:43 Comment?
oth 2015/12/15 22:42:17 Done.
+
+ // Offsets of bytecodes having a backward branch to the bytecode at |offset|.
+ const ZoneVector<int>* BackwardBranchesTargetting(int offset) const;
+
+ // Offsets of bytecodes having a foreward branch to the bytecode at |offset|.
rmcilroy 2015/12/15 17:35:43 /s/foreward/forward
oth 2015/12/15 22:42:17 Done.
+ const ZoneVector<int>* ForwardBranchesTargetting(int offset) const;
+
+ // Returns true if the bytecode at |offset| is reachable.
+ bool is_reachable(int offset) const { return reachable_.Contains(offset); }
+
+ // Returns true if there are any forward branches to the bytecode at
+ // |offset|.
+ bool forward_branches_target(int offset) const {
+ const ZoneVector<int>* sites = ForwardBranchesTargetting(offset);
+ return sites != nullptr && sites->size() > 0;
+ }
+
+ // Returns true if there are any backward branches to the bytecode
+ // at |offset|.
+ bool backward_branches_target(int offset) const {
+ const ZoneVector<int>* sites = BackwardBranchesTargetting(offset);
+ return sites != nullptr && sites->size() > 0;
+ }
+
+ // Returns true if the bytecode at |offset| is the last backwards branch to
+ // |branch_target|.
+ bool IsLastBackwardBranchTo(int branch_target, int offset) const;
+
+ private:
+ void AddBranch(int origin_offset, int target_offset);
+
+ Zone* zone() const { return zone_; }
+ Handle<BytecodeArray> bytecode_array() const { return bytecode_array_; }
+
+ ZoneMap<int, BytecodeBranchInfo*> branch_infos_;
+ Handle<BytecodeArray> bytecode_array_;
+ BitVector reachable_;
+ Zone* zone_;
+
+ DISALLOW_COPY_AND_ASSIGN(BytecodeBranchAnalysis);
+};
+
+
+} // namespace compiler
+} // namespace internal
+} // namespace v8
+
+#endif // V8_COMPILER_BYTECODE_BRANCH_ANALYSIS_H_

Powered by Google App Engine
This is Rietveld 408576698