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

Unified Diff: src/full-codegen.h

Issue 7618007: Simplify handling of exits from with and catch. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 4 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/frames-inl.h ('k') | src/full-codegen.cc » ('j') | src/full-codegen.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « src/frames-inl.h ('k') | src/full-codegen.cc » ('j') | src/full-codegen.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698