[ast] Simplify assignment of OSR entry ids.
R=verwaest@chromium.org Change-Id: I39921052ddf0934f1a626f3e1e458280475ae265 Reviewed-on: https://chromium-review.googlesource.com/539515 Reviewed-by: Toon Verwaest <verwaest@chromium.org> Commit-Queue: Michael Starzinger <mstarzinger@chromium.org> Cr-Commit-Position: refs/heads/master@{#46083}
This commit is contained in:
parent
7e192a91b8
commit
9c38b8ae04
@ -50,9 +50,9 @@ class AstNumberingVisitor final : public AstVisitor<AstNumberingVisitor> {
|
||||
void VisitArguments(ZoneList<Expression*>* arguments);
|
||||
void VisitLiteralProperty(LiteralProperty* property);
|
||||
|
||||
int ReserveIdRange(int n) {
|
||||
int ReserveId() {
|
||||
int tmp = next_id_;
|
||||
next_id_ += n;
|
||||
next_id_ += 1;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
@ -335,7 +335,7 @@ void AstNumberingVisitor::VisitWithStatement(WithStatement* node) {
|
||||
void AstNumberingVisitor::VisitDoWhileStatement(DoWhileStatement* node) {
|
||||
IncrementNodeCount();
|
||||
DisableSelfOptimization();
|
||||
node->set_base_id(ReserveIdRange(DoWhileStatement::num_ids()));
|
||||
node->set_osr_id(ReserveId());
|
||||
node->set_first_suspend_id(suspend_count_);
|
||||
Visit(node->body());
|
||||
Visit(node->cond());
|
||||
@ -346,7 +346,7 @@ void AstNumberingVisitor::VisitDoWhileStatement(DoWhileStatement* node) {
|
||||
void AstNumberingVisitor::VisitWhileStatement(WhileStatement* node) {
|
||||
IncrementNodeCount();
|
||||
DisableSelfOptimization();
|
||||
node->set_base_id(ReserveIdRange(WhileStatement::num_ids()));
|
||||
node->set_osr_id(ReserveId());
|
||||
node->set_first_suspend_id(suspend_count_);
|
||||
Visit(node->cond());
|
||||
Visit(node->body());
|
||||
@ -461,7 +461,7 @@ void AstNumberingVisitor::VisitImportCallExpression(
|
||||
void AstNumberingVisitor::VisitForInStatement(ForInStatement* node) {
|
||||
IncrementNodeCount();
|
||||
DisableSelfOptimization();
|
||||
node->set_base_id(ReserveIdRange(ForInStatement::num_ids()));
|
||||
node->set_osr_id(ReserveId());
|
||||
Visit(node->enumerable()); // Not part of loop.
|
||||
node->set_first_suspend_id(suspend_count_);
|
||||
Visit(node->each());
|
||||
@ -474,7 +474,7 @@ void AstNumberingVisitor::VisitForInStatement(ForInStatement* node) {
|
||||
void AstNumberingVisitor::VisitForOfStatement(ForOfStatement* node) {
|
||||
IncrementNodeCount();
|
||||
DisableFullCodegenAndCrankshaft(kForOfStatement);
|
||||
node->set_base_id(ReserveIdRange(ForOfStatement::num_ids()));
|
||||
node->set_osr_id(ReserveId());
|
||||
Visit(node->assign_iterator()); // Not part of loop.
|
||||
node->set_first_suspend_id(suspend_count_);
|
||||
Visit(node->next_result());
|
||||
@ -524,7 +524,7 @@ void AstNumberingVisitor::VisitCaseClause(CaseClause* node) {
|
||||
void AstNumberingVisitor::VisitForStatement(ForStatement* node) {
|
||||
IncrementNodeCount();
|
||||
DisableSelfOptimization();
|
||||
node->set_base_id(ReserveIdRange(ForStatement::num_ids()));
|
||||
node->set_osr_id(ReserveId());
|
||||
if (node->init() != NULL) Visit(node->init()); // Not part of loop.
|
||||
node->set_first_suspend_id(suspend_count_);
|
||||
if (node->cond() != NULL) Visit(node->cond());
|
||||
|
@ -390,7 +390,6 @@ class BreakableStatement : public Statement {
|
||||
DCHECK(labels == NULL || labels->length() > 0);
|
||||
bit_field_ |= BreakableTypeField::encode(breakable_type);
|
||||
}
|
||||
static int parent_num_ids() { return 0; }
|
||||
|
||||
static const uint8_t kNextBitFieldIndex = BreakableTypeField::kNext;
|
||||
};
|
||||
@ -517,9 +516,11 @@ class IterationStatement : public BreakableStatement {
|
||||
first_suspend_id_ = first_suspend_id;
|
||||
}
|
||||
|
||||
void set_base_id(int id) { base_id_ = id; }
|
||||
static int num_ids() { return parent_num_ids() + 1; }
|
||||
BailoutId OsrEntryId() const { return BailoutId(local_id(0)); }
|
||||
void set_osr_id(int id) { osr_id_ = BailoutId(id); }
|
||||
BailoutId OsrEntryId() const {
|
||||
DCHECK(!osr_id_.IsNone());
|
||||
return osr_id_;
|
||||
}
|
||||
|
||||
// Code generation
|
||||
Label* continue_target() { return &continue_target_; }
|
||||
@ -528,11 +529,10 @@ class IterationStatement : public BreakableStatement {
|
||||
IterationStatement(ZoneList<const AstRawString*>* labels, int pos,
|
||||
NodeType type)
|
||||
: BreakableStatement(labels, TARGET_FOR_ANONYMOUS, pos, type),
|
||||
base_id_(BailoutId::None().ToInt()),
|
||||
osr_id_(BailoutId::None()),
|
||||
body_(NULL),
|
||||
suspend_count_(0),
|
||||
first_suspend_id_(0) {}
|
||||
static int parent_num_ids() { return 0; }
|
||||
void Initialize(Statement* body, const SourceRange& body_range = {}) {
|
||||
body_ = body;
|
||||
body_range_ = body_range;
|
||||
@ -542,13 +542,7 @@ class IterationStatement : public BreakableStatement {
|
||||
BreakableStatement::kNextBitFieldIndex;
|
||||
|
||||
private:
|
||||
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
|
||||
int base_id() const {
|
||||
DCHECK(!BailoutId(base_id_).IsNone());
|
||||
return base_id_;
|
||||
}
|
||||
|
||||
int base_id_;
|
||||
BailoutId osr_id_;
|
||||
Statement* body_;
|
||||
SourceRange body_range_;
|
||||
Label continue_target_;
|
||||
|
Loading…
Reference in New Issue
Block a user