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

Unified Diff: src/full-codegen/full-codegen.h

Issue 1724753002: [fullcodegen] Implement control flow across do-expressions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Disable verification. Created 4 years, 10 months 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
« no previous file with comments | « src/full-codegen/arm64/full-codegen-arm64.cc ('k') | src/full-codegen/full-codegen.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/full-codegen/full-codegen.h
diff --git a/src/full-codegen/full-codegen.h b/src/full-codegen/full-codegen.h
index 6ab02313bb4ad1c1d34d576e101bd1c1706ba6ea..e811e25cf818abb9f9816fc3a9b3321394aa91ce 100644
--- a/src/full-codegen/full-codegen.h
+++ b/src/full-codegen/full-codegen.h
@@ -108,7 +108,9 @@ class FullCodeGenerator: public AstVisitor {
class NestedStatement BASE_EMBEDDED {
public:
- explicit NestedStatement(FullCodeGenerator* codegen) : codegen_(codegen) {
+ explicit NestedStatement(FullCodeGenerator* codegen)
+ : codegen_(codegen),
+ stack_depth_at_target_(codegen->operand_stack_depth_) {
// Link into codegen's nesting stack.
previous_ = codegen->nesting_stack_;
codegen->nesting_stack_ = this;
@@ -130,18 +132,20 @@ class FullCodeGenerator: public AstVisitor {
// Notify the statement that we are exiting it via break, continue, or
// return and give it a chance to generate cleanup code. Return the
// next outer statement in the nesting stack. We accumulate in
- // *stack_depth the amount to drop the stack and in *context_length the
- // number of context chain links to unwind as we traverse the nesting
- // stack from an exit to its target.
- virtual NestedStatement* Exit(int* stack_depth, int* context_length) {
- return previous_;
- }
+ // {*context_length} the number of context chain links to unwind as we
+ // traverse the nesting stack from an exit to its target.
+ virtual NestedStatement* Exit(int* context_length) { return previous_; }
+
+ // Determine the expected operand stack depth when this statement is being
+ // used as the target of an exit. The caller will drop to this depth.
+ int GetStackDepthAtTarget() { return stack_depth_at_target_; }
protected:
MacroAssembler* masm() { return codegen_->masm(); }
FullCodeGenerator* codegen_;
NestedStatement* previous_;
+ int stack_depth_at_target_;
private:
DISALLOW_COPY_AND_ASSIGN(NestedStatement);
@@ -192,7 +196,7 @@ class FullCodeGenerator: public AstVisitor {
: Breakable(codegen, block) {
}
- NestedStatement* Exit(int* stack_depth, int* context_length) override {
+ NestedStatement* Exit(int* context_length) override {
auto block_scope = statement()->AsBlock()->scope();
if (block_scope != nullptr) {
if (block_scope->ContextLocalCount() > 0) ++(*context_length);
@@ -201,19 +205,6 @@ class FullCodeGenerator: public AstVisitor {
}
};
- // The try block of a try/catch statement.
- class TryCatch : public NestedStatement {
- public:
- static const int kElementCount = TryBlockConstant::kElementCount;
-
- explicit TryCatch(FullCodeGenerator* codegen) : NestedStatement(codegen) {}
-
- NestedStatement* Exit(int* stack_depth, int* context_length) override {
- *stack_depth += kElementCount;
- return previous_;
- }
- };
-
class DeferredCommands {
public:
enum Command { kReturn, kThrow, kBreak, kContinue };
@@ -254,12 +245,10 @@ class FullCodeGenerator: public AstVisitor {
// The try block of a try/finally statement.
class TryFinally : public NestedStatement {
public:
- static const int kElementCount = TryBlockConstant::kElementCount;
-
TryFinally(FullCodeGenerator* codegen, DeferredCommands* commands)
: NestedStatement(codegen), deferred_commands_(commands) {}
- NestedStatement* Exit(int* stack_depth, int* context_length) override;
+ NestedStatement* Exit(int* context_length) override;
bool IsTryFinally() override { return true; }
TryFinally* AsTryFinally() override { return this; }
@@ -270,35 +259,6 @@ class FullCodeGenerator: public AstVisitor {
DeferredCommands* deferred_commands_;
};
- // The finally block of a try/finally statement.
- class Finally : public NestedStatement {
- public:
- static const int kElementCount = 3;
-
- explicit Finally(FullCodeGenerator* codegen) : NestedStatement(codegen) {}
-
- NestedStatement* Exit(int* stack_depth, int* context_length) override {
- *stack_depth += kElementCount;
- return previous_;
- }
- };
-
- // The body of a for/in loop.
- class ForIn : public Iteration {
- public:
- static const int kElementCount = 5;
-
- ForIn(FullCodeGenerator* codegen, ForInStatement* statement)
- : Iteration(codegen, statement) {
- }
-
- NestedStatement* Exit(int* stack_depth, int* context_length) override {
- *stack_depth += kElementCount;
- return previous_;
- }
- };
-
-
// The body of a with or catch.
class WithOrCatch : public NestedStatement {
public:
@@ -306,7 +266,7 @@ class FullCodeGenerator: public AstVisitor {
: NestedStatement(codegen) {
}
- NestedStatement* Exit(int* stack_depth, int* context_length) override {
+ NestedStatement* Exit(int* context_length) override {
++(*context_length);
return previous_;
}
« no previous file with comments | « src/full-codegen/arm64/full-codegen-arm64.cc ('k') | src/full-codegen/full-codegen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698