Chromium Code Reviews| Index: src/full-codegen.h |
| diff --git a/src/full-codegen.h b/src/full-codegen.h |
| index 9bd6e5e4dc873f4cb5479cc291eae24dc2b1b1be..ee913b77d2b8ac1909e4645e135d20831e5ff0f4 100644 |
| --- a/src/full-codegen.h |
| +++ b/src/full-codegen.h |
| @@ -148,17 +148,15 @@ class FullCodeGenerator: public AstVisitor { |
| // elements left on top of the surrounding statement's stack. |
| // The generated code must preserve the result register (which |
| // contains the value in case of a return). |
|
Vyacheslav Egorov (Chromium)
2011/08/11 11:21:55
Comment is out of date. Please update.
Kevin Millikin (Chromium)
2011/08/11 15:22:20
Done.
|
| - virtual int Exit(int stack_depth) { |
| + virtual NestedStatement* Exit(int* stack_depth, int* context_length) { |
| // Default implementation for the case where there is |
| // nothing to clean up. |
| - return stack_depth; |
| + return previous_; |
| } |
| - NestedStatement* outer() { return previous_; } |
| protected: |
| MacroAssembler* masm() { return codegen_->masm(); } |
| - private: |
| FullCodeGenerator* codegen_; |
| NestedStatement* previous_; |
| DISALLOW_COPY_AND_ASSIGN(NestedStatement); |
| @@ -207,7 +205,7 @@ class FullCodeGenerator: public AstVisitor { |
| virtual ~TryCatch() {} |
| virtual TryCatch* AsTryCatch() { return this; } |
| Label* catch_entry() { return catch_entry_; } |
| - virtual int Exit(int stack_depth); |
| + virtual NestedStatement* Exit(int* stack_depth, int* context_length); |
| private: |
| Label* catch_entry_; |
| DISALLOW_COPY_AND_ASSIGN(TryCatch); |
| @@ -221,7 +219,7 @@ class FullCodeGenerator: public AstVisitor { |
| virtual ~TryFinally() {} |
| virtual TryFinally* AsTryFinally() { return this; } |
| Label* finally_entry() { return finally_entry_; } |
| - virtual int Exit(int stack_depth); |
| + virtual NestedStatement* Exit(int* stack_depth, int* context_length); |
| private: |
| Label* finally_entry_; |
| DISALLOW_COPY_AND_ASSIGN(TryFinally); |
| @@ -235,8 +233,9 @@ class FullCodeGenerator: public AstVisitor { |
| explicit Finally(FullCodeGenerator* codegen) : NestedStatement(codegen) { } |
| virtual ~Finally() {} |
| virtual Finally* AsFinally() { return this; } |
| - virtual int Exit(int stack_depth) { |
| - return stack_depth + kFinallyStackElementCount; |
| + virtual NestedStatement* Exit(int* stack_depth, int* context_length) { |
| + *stack_depth += kFinallyStackElementCount; |
| + return previous_; |
| } |
| private: |
| // Number of extra stack slots occupied during a finally block. |
| @@ -254,14 +253,32 @@ class FullCodeGenerator: public AstVisitor { |
| : Iteration(codegen, statement) { } |
| virtual ~ForIn() {} |
| virtual ForIn* AsForIn() { return this; } |
| - virtual int Exit(int stack_depth) { |
| - return stack_depth + kForInStackElementCount; |
| + virtual NestedStatement* Exit(int* stack_depth, int* context_length) { |
| + *stack_depth += kForInStackElementCount; |
| + return previous_; |
| } |
| private: |
| static const int kForInStackElementCount = 5; |
| DISALLOW_COPY_AND_ASSIGN(ForIn); |
| }; |
| + |
| + // A WithOrCatch represents being inside the body of a with or catch |
| + // statement. Exiting the body needs to remove a link from the context |
| + // chain. |
| + class WithOrCatch : public NestedStatement { |
| + public: |
| + explicit WithOrCatch(FullCodeGenerator* codegen) |
| + : NestedStatement(codegen) { |
| + } |
| + virtual ~WithOrCatch() {} |
| + |
| + virtual NestedStatement* Exit(int* stack_depth, int* context_length) { |
| + ++(*context_length); |
| + return previous_; |
| + } |
| + }; |
| + |
| // The forward bailout stack keeps track of the expressions that can |
| // bail out to just before the control flow is split in a child |
| // node. The stack elements are linked together through the parent |