Good idea, because it gets rid of the already_compiled accessor.

On Mon, Mar 9, 2009 at 3:36 PM, Kasper Lund <[email protected]> wrote:

> LGTM. You could move the !already_compiled assertion to the
> mark_as_compiled function, but I guess that's a matter of taste.
>
> On Mon, Mar 9, 2009 at 3:34 PM,  <[email protected]> wrote:
> > Reviewers: Kasper Lund,
> >
> > Description:
> > Assert in debug mode that we do not try to compile a function literal
> > more than once.
> >
> >
> > Please review this at http://codereview.chromium.org/39339
> >
> > SVN Base: http://v8.googlecode.com/svn/branches/bleeding_edge/
> >
> > Affected files:
> >  M     src/ast.h
> >  M     src/codegen.cc
> >
> >
> > Index: src/ast.h
> > ===================================================================
> > --- src/ast.h   (revision 1452)
> > +++ src/ast.h   (working copy)
> > @@ -1197,6 +1197,9 @@
> >         is_expression_(is_expression),
> >         loop_nesting_(0),
> >         function_token_position_(RelocInfo::kNoPosition) {
> > +#ifdef DEBUG
> > +    already_compiled_ = false;
> > +#endif
> >   }
> >
> >   virtual void Accept(AstVisitor* v);
> > @@ -1223,6 +1226,11 @@
> >   bool loop_nesting() const { return loop_nesting_; }
> >   void set_loop_nesting(int nesting) { loop_nesting_ = nesting; }
> >
> > +#ifdef DEBUG
> > +  bool already_compiled() const { return already_compiled_; }
> > +  void mark_as_compiled() { already_compiled_ = true; }
> > +#endif
> > +
> >  private:
> >   Handle<String> name_;
> >   Scope* scope_;
> > @@ -1236,6 +1244,9 @@
> >   bool is_expression_;
> >   int loop_nesting_;
> >   int function_token_position_;
> > +#ifdef DEBUG
> > +  bool already_compiled_;
> > +#endif
> >  };
> >
> >
> > Index: src/codegen.cc
> > ===================================================================
> > --- src/codegen.cc      (revision 1452)
> > +++ src/codegen.cc      (working copy)
> > @@ -237,6 +237,13 @@
> >
> >
> >  Handle<JSFunction> CodeGenerator::BuildBoilerplate(FunctionLiteral*
> node) {
> > +#ifdef DEBUG
> > +  // We should not try to compile the same function literal more than
> > +  // once.
> > +  ASSERT(!node->already_compiled());
> > +  node->mark_as_compiled();
> > +#endif
> > +
> >   // Determine if the function can be lazily compiled. This is
> >   // necessary to allow some of our builtin JS files to be lazily
> >   // compiled. These builtins cannot be handled lazily by the parser,
> >
> >
> >
>

--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to