summaryrefslogtreecommitdiff
path: root/deps/v8/src/interpreter/control-flow-builders.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/interpreter/control-flow-builders.h')
-rw-r--r--deps/v8/src/interpreter/control-flow-builders.h104
1 files changed, 51 insertions, 53 deletions
diff --git a/deps/v8/src/interpreter/control-flow-builders.h b/deps/v8/src/interpreter/control-flow-builders.h
index e4d376b9b2..5cd9b5bc99 100644
--- a/deps/v8/src/interpreter/control-flow-builders.h
+++ b/deps/v8/src/interpreter/control-flow-builders.h
@@ -7,6 +7,7 @@
#include "src/interpreter/bytecode-array-builder.h"
+#include "src/interpreter/bytecode-label.h"
#include "src/zone-containers.h"
namespace v8 {
@@ -31,37 +32,33 @@ class ControlFlowBuilder BASE_EMBEDDED {
class BreakableControlFlowBuilder : public ControlFlowBuilder {
public:
explicit BreakableControlFlowBuilder(BytecodeArrayBuilder* builder)
- : ControlFlowBuilder(builder),
- break_sites_(builder->zone()) {}
+ : ControlFlowBuilder(builder), break_labels_(builder->zone()) {}
virtual ~BreakableControlFlowBuilder();
// This method should be called by the control flow owner before
// destruction to update sites that emit jumps for break.
- void SetBreakTarget(const BytecodeLabel& break_target);
+ void BindBreakTarget();
// This method is called when visiting break statements in the AST.
- // Inserts a jump to a unbound label that is patched when the corresponding
- // 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_); }
+ // Inserts a jump to an unbound label that is patched when the corresponding
+ // BindBreakTarget is called.
+ void Break() { EmitJump(&break_labels_); }
+ void BreakIfTrue() { EmitJumpIfTrue(&break_labels_); }
+ void BreakIfFalse() { EmitJumpIfFalse(&break_labels_); }
+ void BreakIfUndefined() { EmitJumpIfUndefined(&break_labels_); }
+ void BreakIfNull() { EmitJumpIfNull(&break_labels_); }
- 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);
+ BytecodeLabels* break_labels() { return &break_labels_; }
- void BindLabels(const BytecodeLabel& target, ZoneVector<BytecodeLabel>* site);
+ protected:
+ void EmitJump(BytecodeLabels* labels);
+ void EmitJumpIfTrue(BytecodeLabels* labels);
+ void EmitJumpIfFalse(BytecodeLabels* labels);
+ void EmitJumpIfUndefined(BytecodeLabels* labels);
+ void EmitJumpIfNull(BytecodeLabels* labels);
// Unbound labels that identify jumps for break statements in the code.
- ZoneVector<BytecodeLabel> break_sites_;
+ BytecodeLabels break_labels_;
};
@@ -84,34 +81,34 @@ class LoopBuilder final : public BreakableControlFlowBuilder {
public:
explicit LoopBuilder(BytecodeArrayBuilder* builder)
: BreakableControlFlowBuilder(builder),
- continue_sites_(builder->zone()) {}
+ continue_labels_(builder->zone()),
+ header_labels_(builder->zone()) {}
~LoopBuilder();
- void LoopHeader();
- void Condition() { builder()->Bind(&condition_); }
- void Next() { builder()->Bind(&next_); }
- void JumpToHeader() { builder()->Jump(&loop_header_); }
- void JumpToHeaderIfTrue() { builder()->JumpIfTrue(&loop_header_); }
+ void LoopHeader(ZoneVector<BytecodeLabel>* additional_labels);
+ void JumpToHeader();
+ void JumpToHeaderIfTrue();
+ void BindContinueTarget();
void EndLoop();
// This method is called when visiting continue statements in the AST.
- // Inserts a jump to a unbound label that is patched when the corresponding
- // SetContinueTarget is called.
- void Continue() { EmitJump(&continue_sites_); }
- void ContinueIfTrue() { EmitJumpIfTrue(&continue_sites_); }
- void ContinueIfUndefined() { EmitJumpIfUndefined(&continue_sites_); }
- void ContinueIfNull() { EmitJumpIfNull(&continue_sites_); }
+ // Inserts a jump to an unbound label that is patched when BindContinueTarget
+ // is called.
+ void Continue() { EmitJump(&continue_labels_); }
+ void ContinueIfTrue() { EmitJumpIfTrue(&continue_labels_); }
+ void ContinueIfUndefined() { EmitJumpIfUndefined(&continue_labels_); }
+ void ContinueIfNull() { EmitJumpIfNull(&continue_labels_); }
- private:
- void SetContinueTarget(const BytecodeLabel& continue_target);
+ BytecodeLabels* header_labels() { return &header_labels_; }
+ BytecodeLabels* continue_labels() { return &continue_labels_; }
+ private:
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_;
+ // Unbound labels that identify jumps for continue statements in the code and
+ // jumps from checking the loop condition to the header for do-while loops.
+ BytecodeLabels continue_labels_;
+ BytecodeLabels header_labels_;
};
@@ -132,12 +129,12 @@ class SwitchBuilder final : public BreakableControlFlowBuilder {
// This method is called when visiting case comparison operation for |index|.
// Inserts a JumpIfTrue to a unbound label that is patched when the
// corresponding SetCaseTarget is called.
- void Case(int index) { EmitJumpIfTrue(&case_sites_, index); }
+ void Case(int index) { builder()->JumpIfTrue(&case_sites_.at(index)); }
// This method is called when all cases comparisons have been emitted if there
// is a default case statement. Inserts a Jump to a unbound label that is
// patched when the corresponding SetCaseTarget is called.
- void DefaultAt(int index) { EmitJump(&case_sites_, index); }
+ void DefaultAt(int index) { builder()->Jump(&case_sites_.at(index)); }
private:
// Unbound labels that identify jumps for case statements in the code.
@@ -148,8 +145,11 @@ class SwitchBuilder final : public BreakableControlFlowBuilder {
// A class to help with co-ordinating control flow in try-catch statements.
class TryCatchBuilder final : public ControlFlowBuilder {
public:
- explicit TryCatchBuilder(BytecodeArrayBuilder* builder)
- : ControlFlowBuilder(builder), handler_id_(builder->NewHandlerEntry()) {}
+ explicit TryCatchBuilder(BytecodeArrayBuilder* builder,
+ HandlerTable::CatchPrediction catch_prediction)
+ : ControlFlowBuilder(builder),
+ handler_id_(builder->NewHandlerEntry()),
+ catch_prediction_(catch_prediction) {}
void BeginTry(Register context);
void EndTry();
@@ -157,6 +157,7 @@ class TryCatchBuilder final : public ControlFlowBuilder {
private:
int handler_id_;
+ HandlerTable::CatchPrediction catch_prediction_;
BytecodeLabel handler_;
BytecodeLabel exit_;
};
@@ -165,11 +166,12 @@ class TryCatchBuilder final : public ControlFlowBuilder {
// A class to help with co-ordinating control flow in try-finally statements.
class TryFinallyBuilder final : public ControlFlowBuilder {
public:
- explicit TryFinallyBuilder(BytecodeArrayBuilder* builder, bool will_catch)
+ explicit TryFinallyBuilder(BytecodeArrayBuilder* builder,
+ HandlerTable::CatchPrediction catch_prediction)
: ControlFlowBuilder(builder),
handler_id_(builder->NewHandlerEntry()),
- finalization_sites_(builder->zone()),
- will_catch_(will_catch) {}
+ catch_prediction_(catch_prediction),
+ finalization_sites_(builder->zone()) {}
void BeginTry(Register context);
void LeaveTry();
@@ -180,15 +182,11 @@ class TryFinallyBuilder final : public ControlFlowBuilder {
private:
int handler_id_;
+ HandlerTable::CatchPrediction catch_prediction_;
BytecodeLabel handler_;
// Unbound labels that identify jumps to the finally block in the code.
- ZoneVector<BytecodeLabel> finalization_sites_;
-
- // Conservative prediction of whether exceptions thrown into the handler for
- // this finally block will be caught. Note that such a prediction depends on
- // whether this try-finally is nested inside a surrounding try-catch.
- bool will_catch_;
+ BytecodeLabels finalization_sites_;
};
} // namespace interpreter