Reviewers: wingo, rossberg, Sven Panne, mstarzinger, Dmitry Lomov (chromium),

Message:
On 2014/07/23 13:26:06, Sven Panne wrote:
LGTM, http://wowhead.com has been resurrected by this patch, I'll land it for
you.

https://codereview.chromium.org/410873004/diff/1/src/preparser.h
File src/preparser.h (right):

https://codereview.chromium.org/410873004/diff/1/src/preparser.h#newcode683
src/preparser.h:683: bool IsThis() const { return (code_ & kThisExpression) ==
kThisExpression; }
On 2014/07/23 12:54:55, wingo wrote:
> Since the kThisExpression et al are just bitflags I would write "return
code_
&
> kThisExpression" instead, without the ==.  That's just me though.  Looks
good
to
> this non-owner, please pass on to an owner.

For consistency, I would leave it as it is. All this bit-fiddling has to be
abstracted, anyway. Using one enum for different purposes without any
abstraction is not nice...

Agreed, while making the fix I was thinking that it would be nice to use the
BitField template from "src/utils.h"... anyway, the idea was to have this fix
applied ASAP, so let's leave cleanups for another day.

Thanks for landing this CL for me.

Description:
Fix checks to bit flags of PreParserExpression

This fixes checks on the "code_" member of PreParserExpression, in order
to make methods IsThis(), IsThisProperty(), IsProperty(), IsCall() and
IsValidReferenceExpression() work correctly.

BUG=v8:3456
LOG=
[email protected]

Committed: https://code.google.com/p/v8/source/detail?r=22562

Please review this at https://codereview.chromium.org/410873004/

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

Affected files (+23, -7 lines):
  M src/preparser.h
  A test/mjsunit/regress-3456.js


Index: src/preparser.h
diff --git a/src/preparser.h b/src/preparser.h
index 1ea2a2284a7b49382ba3f3ec957600c21cb361a2..1c1e1c4520d0e3cad95a6f2cbb3afdec963d02a7 100644
--- a/src/preparser.h
+++ b/src/preparser.h
@@ -676,21 +676,24 @@ class PreParserExpression {
     return (code_ & kTypeMask) == kTypeStringLiteral;
   }

-  bool IsUseStrictLiteral() {
+  bool IsUseStrictLiteral() const {
     return (code_ & kUseStrictString) == kUseStrictString;
   }

-  bool IsThis() { return code_ == kThisExpression; }
+ bool IsThis() const { return (code_ & kThisExpression) == kThisExpression; }

-  bool IsThisProperty() { return code_ == kThisPropertyExpression; }
+  bool IsThisProperty() const {
+    return (code_ & kThisPropertyExpression) == kThisPropertyExpression;
+  }

-  bool IsProperty() {
- return code_ == kPropertyExpression || code_ == kThisPropertyExpression;
+  bool IsProperty() const {
+    return (code_ & kPropertyExpression) == kPropertyExpression ||
+           (code_ & kThisPropertyExpression) == kThisPropertyExpression;
   }

-  bool IsCall() { return code_ == kCallExpression; }
+ bool IsCall() const { return (code_ & kCallExpression) == kCallExpression; }

-  bool IsValidReferenceExpression() {
+  bool IsValidReferenceExpression() const {
     return IsIdentifier() || IsProperty();
   }

Index: test/mjsunit/regress-3456.js
diff --git a/test/mjsunit/regress-3456.js b/test/mjsunit/regress-3456.js
new file mode 100644
index 0000000000000000000000000000000000000000..498953b80736b5d497bc06840711feda8528ec50
--- /dev/null
+++ b/test/mjsunit/regress-3456.js
@@ -0,0 +1,13 @@
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --min-preparse-length 1
+
+// Arrow function parsing (commit r22366) changed the flags stored in
+// PreParserExpression, and IsValidReferenceExpression() would return
+// false for certain valid expressions. This case is the minimum amount
+// of code needed to validate that IsValidReferenceExpression() works
+// properly. If it does not, a ReferenceError is thrown during parsing.
+
+function f() { ++(this.foo) }


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to