Reviewers: Vyacheslav Egorov, Kasper Lund,

http://codereview.chromium.org/7572019/diff/1001/src/objects.h
File src/objects.h (left):

http://codereview.chromium.org/7572019/diff/1001/src/objects.h#oldcode4920
src/objects.h:4920: static const int kBoundFunction = 9;
Strange that this worked.  I guess we don't really need to distinguish
between BoundFunction and HasDuplicateParameters.

http://codereview.chromium.org/7572019/diff/1001/src/parser.cc
File src/parser.cc (left):

http://codereview.chromium.org/7572019/diff/1001/src/parser.cc#oldcode3634
src/parser.cc:3634: // that case, we don't have a function name (it's
empty).
I loved this comment, but I couldn't find a way to keep it with the
restructured code, mostly because it makes no sense at all.

http://codereview.chromium.org/7572019/diff/1001/src/parser.cc#oldcode3826
src/parser.cc:3826: (function_name->length() > 0),
This is the is_expression flag.  It incorrectly categorized anonymous
function expressions as !is_expression.

http://codereview.chromium.org/7572019/diff/1001/src/parser.h
File src/parser.h (left):

http://codereview.chromium.org/7572019/diff/1001/src/parser.h#oldcode558
src/parser.h:558: NESTED
NESTED was treated the same as EXPRESSION everywhere.

http://codereview.chromium.org/7572019/diff/1001/src/v8natives.js
File src/v8natives.js (right):

http://codereview.chromium.org/7572019/diff/1001/src/v8natives.js#newcode1431
src/v8natives.js:1431: var name =
%FunctionNameShouldPrintAsAnonymous(func)
I elected to expose a predicate instead of making %FunctionGetName
sometimes return "anonymous".

This introduces a behavior change: function mirrors used by the debugger
for "new Function(...)" used to have name "anonymous", now they have the
empty string.

Description:
Fix a bug in scope analysis.

When recompiling code (e.g., when optimizing) we could incorrectly hoist
some function expressions.  This leads to incorrect results or a crash.  The
root cause was that functions were not correctly categorized as expression
or declaration at parse time.

This requires some extra hoops to prevent the print name "anonymous" for
functions created by 'new Function' from establishing a binding.

[email protected],[email protected]
BUG=1583
TEST=regress-1583


Please review this at http://codereview.chromium.org/7572019/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/objects-inl.h
  M src/objects.h
  M src/parser.h
  M src/parser.cc
  M src/runtime.h
  M src/runtime.cc
  M src/v8natives.js
  A test/mjsunit/regress/regress-1583.js


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

Reply via email to