Commit Graph

46 Commits

Author SHA1 Message Date
erik.corry@gmail.com
03cfc4363b Fix input and output to handle UTF16 surrogate pairs.
Review URL: https://chromiumcodereview.appspot.com/9600009

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11007 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2012-03-12 12:35:28 +00:00
keuchel@chromium.org
410219c8f3 Sync parser and preparser on do-while and return statements.
This CL fixes the preparser to have the same liberal automatic semicolon
insertion behaviour as the parser. In the case of a return statement in
global code we throw a syntax error at runtime rather than an early error
due to compatibility with KJS. However that hack allowed the following
syntactically incorrect program in global code in the parser but not in
the preparser:
  if (false) return else {}
while the slightly saner version with the obligatory semicolon
  if (false) return; else {}
was disallowed in the parser, but the preparser allowed it. This CL also
fixes that issue.

BUG=v8:1856
TEST=cctest/test-parsing.cc

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10201 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-12-07 16:03:29 +00:00
keuchel@chromium.org
e26093f3d8 Make let/const outside of the extended mode early errors (under harmony flag).
The ES.next drafts require that source code that matches the productions for
let and const bindings outside the extended mode trigger early syntax
errors. This CL adapts the parser / preparser accordingly under the harmony
scoping flag.

Summary:
* Harmony scoping flag not set: Old semantics allowing const in classic mode
with function level scope. Const binding in strict mode and let bindings in
classic and strict mode trigger early syntax errors.
* Harmony scoping is set: Use new harmony const and let in
extended mode and old const in classic mode. This is to preserve
compatibility with current web pages that already use
non-standard implementations of const. An early syntax error is
thrown on const in strict mode and on let in classic and strict
mode.

This depends on:
http://codereview.chromium.org/8562002/

TEST=mjsunit/harmony/block-early-errors.js

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10079 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-11-29 06:38:04 +00:00
lrn@chromium.org
ebccde15bc Don't preparse large files to find boundaries of lazy functions.
Instead use the preparser inline to parse only the lazy function
bodies.

This is still disabled for small files.
More measurements are needed to determine if lazy-compiling small
sources is worth it.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10066 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-11-25 09:36:31 +00:00
keuchel@chromium.org
1e9a7267ab Introduce extended mode.
This CL introduces a third mode next to the non-strict
(henceforth called 'classic mode') and 'strict mode'
which is called 'extended mode' as in the current
ES.next specification drafts. The extended mode is based on
the 'strict mode' and adds new functionality to it. This
means that most of the semantics of these two modes
coincide.

The 'extended mode' is entered instead of the 'strict mode'
during parsing when using the 'strict mode' directive
"use strict" and when the the harmony-scoping flag is
active. This should be changed once it is fully specified how the 'extended mode' is entered.

This change introduces a new 3 valued enum LanguageMode
(see globals.h) corresponding to the modes which is mostly
used by the frontend code. This includes the following
components:
* (Pre)Parser
* Compiler
* SharedFunctionInfo, Scope and ScopeInfo
* runtime functions: StoreContextSlot,
  ResolvePossiblyDirectEval, InitializeVarGlobal,
  DeclareGlobals

The old enum StrictModeFlag is still used in the backend
when the distinction between the 'strict mode' and the 'extended mode' does not matter. This includes:
* SetProperty runtime function, Delete builtin
* StoreIC and KeyedStoreIC
* StubCache

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10062 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-11-24 15:17:04 +00:00
lrn@chromium.org
65b9ab93af Merged Scanner and JavaScriptScanner.
JavaScriptScanner had become the only concrete subclass of Scanner, so there
was no longer a need for the distinction.

Also fixed up comments.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9854 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-11-01 07:47:15 +00:00
keuchel@chromium.org
6e767e3f2d Use StrictModeFlag in preparser and preparse data.
Review URL: http://codereview.chromium.org/8396040

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9818 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-10-27 13:08:51 +00:00
keuchel@chromium.org
e8bccc2cb0 Block scoped const variables.
This implements block scoped 'const' declared variables in harmony mode. They
have a temporal dead zone semantics similar to 'let' bindings, i.e. accessing
uninitialized 'const' bindings in throws a ReferenceError.

As for 'let' bindings, the semantics of 'const' bindings in global scope is not
correctly implemented yet. Furthermore assignments to 'const's are silently
ignored. Another CL will introduce treatment of those assignments as early
errors.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9764 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-10-25 08:33:08 +00:00
lrn@chromium.org
2bbf3bbee7 Make native syntax an early error in the preparser.
Previously the preparser always accepted natives syntax and let the
real parser throw the syntax error. In ES5, it should be an early error,
so the preparser must catch the error.
The perparser library does not expose parsing for natives syntax, it's
only used internally.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9660 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-10-17 12:45:52 +00:00
keuchel@chromium.org
6f4e70a1dc Let bound iteration variables in for-loops
TEST=mjsunit/harmony/block-for.js

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9658 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-10-17 12:19:06 +00:00
keuchel@chromium.org
f93c69308f Disallow function declarations in statement positions in harmony mode.
Review URL: http://codereview.chromium.org/8306025

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9657 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-10-17 11:59:08 +00:00
rossberg@chromium.org
1abf3ed0a4 Introduce collective --harmony flag.
Shorten --harmony-block-scoping to --harmony-scoping.

R=keuchel@chromium.org
BUG=
TEST=

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9589 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-10-12 12:23:06 +00:00
keuchel@chromium.org
ad9290a6ae Disallow strict mode FutureReservedWords as break/continue labels in strict mode
TEST=preparser/strict-identifiers.pyt

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9404 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-09-22 16:38:28 +00:00
keuchel@chromium.org
41eb990afe Fix pre-parsing function declarations.
The preparser has been out of sync with the parser. As a reminder, we have the
following grammer for harmony mode

 Block ::
   { SourceElement* }
 SourceElement ::
   Statement
   FunctionDeclaration
   LetDeclaration

instead of

 Block ::
   { Statement* }
 SourceElement ::
   Statement
   FunctionDeclaration

The extension to allow FunctionDeclarations in statement positions in
non-strict code is still active.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9363 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-09-21 12:27:07 +00:00
lrn@chromium.org
c1dc429c02 Fix bug in collector.
Small cleanups in preparser.

TEST=cctest/test-utils/SequenceCollectorRegression

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9197 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-09-08 13:44:11 +00:00
lrn@chromium.org
689f3cb314 Rename scanner.* to scanner-character-streams.*. and scanner-base.* to scanner.*
R=lrn@chromium.org

Signed-off-by: Thiago Farina <tfarina@chromium.org>

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9195 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-09-08 13:06:44 +00:00
lrn@chromium.org
81e7f597b0 Reintroduce duplicate identifier detection in preparser.
Duplicate identifier detection must be an early syntax error in strict code,
so errors in otherwise lazily compiled functions must be caught in the
preparser.

Originally introduced in r8541 and reverted in r8542.
Now really compiles on Windows.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9172 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-09-07 12:39:53 +00:00
keuchel@chromium.org
c6c504f8b6 Parse harmony let declarations.
Implementation of the harmony block scoped let bindings as proposed here:
http://wiki.ecmascript.org/doku.php?id=harmony:block_scoped_bindings

Changes to the syntax are explained there. They are active under the
harmony_block_scoping_ flag in the parser.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8944 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-08-16 14:24:12 +00:00
mikhail.naganov@gmail.com
58824435d1 Pick the namespace alias 'i' from v8.h.
These files already include v8.h so they don't need to define the
namespace alias again.

Signed-off-by: Thiago Farina <tfarina@chromium.org>

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8919 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-08-12 09:49:55 +00:00
lrn@chromium.org
57b7a67dba Revert preparser duplicate detection.
Doesn't work on Windows yet.
Crashes some layout-tests.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8542 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-07-06 09:15:10 +00:00
lrn@chromium.org
57760b8275 Make preparser detect duplicate parameters and object literal properties.
This is a fix and reapply of r8516 with some comments addressed and more
tests added.
The difference from r8516 is that canonicalization of number literals is
no performed using the same methods as in v8, to avoid false positives/negatives
when detecting duplicates.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8541 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-07-06 08:32:48 +00:00
lrn@chromium.org
877d6198e5 Extract string->double and double->string conversions for use in the preparser.
Review URL: http://codereview.chromium.org/7308004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8534 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-07-05 11:54:11 +00:00
lrn@chromium.org
4f1e60cc75 Revert r8516.
Revision 8516 contained a temporary hack that doesn't work on Windows.

TBR: ricow

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8519 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-07-01 15:44:21 +00:00
lrn@chromium.org
b6779044c9 Add duplicate parameter detection to preparser.
Add tests for duplicate properties of object initialisers to preparser.

TEST=preparser

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8517 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-07-01 13:46:52 +00:00
keuchel@chromium.org
ab3d4cf7b8 Proper handling of future reserved words in strict and normal mode.
BUG=86442
TEST=mjsunit/keywords-and-reserved_words.js

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8421 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-06-24 14:59:51 +00:00
lrn@chromium.org
12c3e7799c Make multi-line comments not count when checking whether --> is first on a line.
A multi-line comment containing a newline is considered a line-terminator for
other purposes, but a "-->" following such a comment is considered as being
on the same line as the text preceeding the multi-line comment.
This behavior matches JSC matching Firefox.

TEST=cctest/test-parsing/ScanHTMLEndComments

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8351 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-06-21 13:34:16 +00:00
lrn@chromium.org
480ec43c4e Make "native" not a keyword.
We now only recognize "native function" when it occurs in extension scripts
(parsing with a non-NULL extension), and only if there is no line-terminator
between "native" and "function" (so that it would otherwise be a Syntax Error).
Preparsing never recognizes native functions, which is acceptable since we
never preparse extension scripts (because we don't allow lazy functions
anyway).

BUG=v8:1097

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8326 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-06-20 10:20:57 +00:00
ager@chromium.org
626cdffaef Fix Array.prototype.{reduce,reduceRight} to pass undefined as receiver for strict mode callbacks.
Propagate strict mode information from pre-parser to parser for lazily compiled functions.

R=lrn@chromium.org
BUG=v8:1436
TEST=mjsunit/regress/regress-1436.js

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8227 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-06-09 09:05:15 +00:00
lrn@chromium.org
b97da90453 Add tests for function statements in strict mode.
Small fixes.
Added test for const declaration in strict mode.

TEST=preparser/strict-function-statement

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8041 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-05-24 14:02:59 +00:00
lrn@chromium.org
b253dd8927 Create template system for strict-mode tests.
This makes it possible to get total coverage without creating thousands
of individual test files.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7985 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-05-23 10:35:30 +00:00
lrn@chromium.org
eea59292e6 Avoid conflict between method and type name.
Make builder happy.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7954 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-05-19 09:22:32 +00:00
lrn@chromium.org
7db97de8e0 Added preparser strict-mode tests.
Now tests for use of eval, arguments, reserved words and with statement.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7951 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-05-19 09:01:46 +00:00
lrn@chromium.org
1a169aa3f0 Strict mode detection in preparser.
Handle octal escapes in everything but RegExps.
Extend preparser test suite to test whether the preparser reports
exceptions to throw.

TEST=preparser/*

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7804 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-05-06 11:41:15 +00:00
lrn@chromium.org
385e4deff5 Make the preparser standalone library and process build in debug mode.
It should now be possible to build the preparser using 'scons preparser' in both release and debug modes.
Remove v8.h include from scanner-base.h and other files.
Remove NativeAllocationChecker and all of its kind.
Moved Isolate::PreallocatedStorage* to isolate.cc

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7413 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-03-29 13:06:48 +00:00
vitalyr@chromium.org
7976ca2cbc Merge isolates to bleeding_edge.
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7271 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-03-18 20:35:07 +00:00
vitalyr@chromium.org
76e226f832 Revert r7268: it borked the history.
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7269 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-03-18 19:41:05 +00:00
vitalyr@chromium.org
6ff7fdebd3 Merge isolates to bleeding_edge.
Review URL: http://codereview.chromium.org/6685088

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7268 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-03-18 18:49:56 +00:00
kmillikin@chromium.org
2662624988 Refactor inlined functions to avoid using subgraphs.
Function inlining no longer uses subgraphs.  We detect inlining in an
effect context and avoid materializing a return value earlier than we
did before.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@7080 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-03-07 15:42:23 +00:00
peterhal@chromium.org
39957aa741 Issue 117 - strict mode and future reserved words
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6653 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-02-04 18:36:37 +00:00
lrn@chromium.org
3800b24f69 Don't lazily compile functions that are immediately receded by '('.
We heuristically expect those functions to be called immediately.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6309 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-01-14 10:50:13 +00:00
lrn@chromium.org
351f80adee Fix compile-problem in (currently) unused stand-alone preparser function.
Allow object initializers to define getters using string and number literals.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6150 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2011-01-04 12:07:16 +00:00
lrn@chromium.org
c9928c0595 Change scanner buffers to not use utf-8.
Make preparser keep its symbol text itself instead of relying on the scanner.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@6115 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-12-22 20:14:19 +00:00
lrn@chromium.org
b55add7e20 Optimized scanner to avoid virtual calls for every character read.
Review URL: http://codereview.chromium.org/5545006

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5935 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-12-07 14:03:59 +00:00
ager@chromium.org
d175df0ad4 Fix windows build.
TBR=lrn
Review URL: http://codereview.chromium.org/5367007

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5904 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-11-29 16:38:05 +00:00
lrn@chromium.org
84f2f5ee90 Preparser extracted into separate files that can be compiled to a library.
No scons target yet.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5899 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-11-29 13:24:37 +00:00
lrn@chromium.org
dc390d0e1f Untemplated preparser.h and made it depend on virtual types.
Extracted preparse-data specification and logging classes.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5877 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2010-11-23 11:46:36 +00:00