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

Unified Diff: src/interpreter/control-flow-builders.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: Fix bug in jump classification. 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/interpreter/control-flow-builders.h
diff --git a/src/interpreter/control-flow-builders.h b/src/interpreter/control-flow-builders.h
index c9be6dcdc73ef57a59de53f78aaac99b227f80f2..bd3df092e7cddd5af85100cdef448149a6cdeefb 100644
--- a/src/interpreter/control-flow-builders.h
+++ b/src/interpreter/control-flow-builders.h
@@ -44,14 +44,18 @@ class BreakableControlFlowBuilder : public ControlFlowBuilder {
// SetBreakTarget is called.
void Break() { EmitJump(&break_sites_); }
void BreakIfTrue() { EmitJumpIfTrue(&break_sites_); }
+ void BreakIfFalse() { EmitJumpIfFalse(&break_sites_); }
void BreakIfUndefined() { EmitJumpIfUndefined(&break_sites_); }
void BreakIfNull() { EmitJumpIfNull(&break_sites_); }
+
Michael Starzinger 2015/12/16 12:40:12 nit: Stray empty newline.
oth 2015/12/16 14:17:06 Done.
protected:
void EmitJump(ZoneVector<BytecodeLabel>* labels);
void EmitJump(ZoneVector<BytecodeLabel>* labels, int index);
void EmitJumpIfTrue(ZoneVector<BytecodeLabel>* labels);
void EmitJumpIfTrue(ZoneVector<BytecodeLabel>* labels, int index);
+ void EmitJumpIfFalse(ZoneVector<BytecodeLabel>* labels);
+ void EmitJumpIfFalse(ZoneVector<BytecodeLabel>* labels, int index);
void EmitJumpIfUndefined(ZoneVector<BytecodeLabel>* labels);
void EmitJumpIfNull(ZoneVector<BytecodeLabel>* labels);
@@ -64,7 +68,6 @@ class BreakableControlFlowBuilder : public ControlFlowBuilder {
// A class to help with co-ordinating break and continue statements with
// their loop.
-// TODO(oth): add support for TF branch/merge info.
class LoopBuilder final : public BreakableControlFlowBuilder {
public:
explicit LoopBuilder(BytecodeArrayBuilder* builder)
@@ -72,9 +75,12 @@ class LoopBuilder final : public BreakableControlFlowBuilder {
continue_sites_(builder->zone()) {}
~LoopBuilder();
- // This methods should be called by the LoopBuilder owner before
- // destruction to update sites that emit jumps for continue.
- void SetContinueTarget(const BytecodeLabel& continue_target);
+ void LoopHeader() { builder()->Bind(&loop_header_); }
+ void Condition() { builder()->Bind(&condition_); }
+ void Next() { builder()->Bind(&next_); }
+ void JumpToHeader() { builder()->Jump(&loop_header_); }
+ void JumpToHeaderIfTrue() { builder()->JumpIfTrue(&loop_header_); }
+ void LoopEnd();
// This method is called when visiting continue statements in the AST.
// Inserts a jump to a unbound label that is patched when the corresponding
@@ -85,6 +91,13 @@ class LoopBuilder final : public BreakableControlFlowBuilder {
void ContinueIfNull() { EmitJumpIfNull(&continue_sites_); }
private:
+ void SetContinueTarget(const BytecodeLabel& continue_target);
+
+ BytecodeLabel loop_header_;
+ BytecodeLabel condition_;
+ BytecodeLabel next_;
+ BytecodeLabel loop_end_;
+
// Unbound labels that identify jumps for continue statements in the code.
ZoneVector<BytecodeLabel> continue_sites_;
};

Powered by Google App Engine
This is Rietveld 408576698