Assert in debug mode that we do not try to compile a function literal

more than once.

Review URL: http://codereview.chromium.org/39339

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1456 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent eb816ae5
...@@ -1197,6 +1197,9 @@ class FunctionLiteral: public Expression { ...@@ -1197,6 +1197,9 @@ class FunctionLiteral: public Expression {
is_expression_(is_expression), is_expression_(is_expression),
loop_nesting_(0), loop_nesting_(0),
function_token_position_(RelocInfo::kNoPosition) { function_token_position_(RelocInfo::kNoPosition) {
#ifdef DEBUG
already_compiled_ = false;
#endif
} }
virtual void Accept(AstVisitor* v); virtual void Accept(AstVisitor* v);
...@@ -1223,6 +1226,13 @@ class FunctionLiteral: public Expression { ...@@ -1223,6 +1226,13 @@ class FunctionLiteral: public Expression {
bool loop_nesting() const { return loop_nesting_; } bool loop_nesting() const { return loop_nesting_; }
void set_loop_nesting(int nesting) { loop_nesting_ = nesting; } void set_loop_nesting(int nesting) { loop_nesting_ = nesting; }
#ifdef DEBUG
void mark_as_compiled() {
ASSERT(!already_compiled_);
already_compiled_ = true;
}
#endif
private: private:
Handle<String> name_; Handle<String> name_;
Scope* scope_; Scope* scope_;
...@@ -1236,6 +1246,9 @@ class FunctionLiteral: public Expression { ...@@ -1236,6 +1246,9 @@ class FunctionLiteral: public Expression {
bool is_expression_; bool is_expression_;
int loop_nesting_; int loop_nesting_;
int function_token_position_; int function_token_position_;
#ifdef DEBUG
bool already_compiled_;
#endif
}; };
......
...@@ -237,6 +237,12 @@ static Handle<Code> ComputeLazyCompile(int argc) { ...@@ -237,6 +237,12 @@ static Handle<Code> ComputeLazyCompile(int argc) {
Handle<JSFunction> CodeGenerator::BuildBoilerplate(FunctionLiteral* node) { Handle<JSFunction> CodeGenerator::BuildBoilerplate(FunctionLiteral* node) {
#ifdef DEBUG
// We should not try to compile the same function literal more than
// once.
node->mark_as_compiled();
#endif
// Determine if the function can be lazily compiled. This is // Determine if the function can be lazily compiled. This is
// necessary to allow some of our builtin JS files to be lazily // necessary to allow some of our builtin JS files to be lazily
// compiled. These builtins cannot be handled lazily by the parser, // compiled. These builtins cannot be handled lazily by the parser,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment