Reviewers: arv,
Description:
Fix uses of eval() with non-string arguments under nosnap/--use-strict
When running without a snapshot, the GlobalEval function gets lazy compiled.
By the time we compile it, its name is "eval", which causes the parser to
choke (functions named "eval" aren't allowed in strict mode!).
As a workaround, check if the function we're parsing is GlobalEval, and
if so replace the name with the empty string during parsing.
This lets us pass an additional 18 test262 tests.
BUG=v8:4198
LOG=n
Please review this at https://codereview.chromium.org/1227093005/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+7, -21 lines):
M src/parser.cc
M test/test262-es6/test262-es6.status
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index
753391193bf03667a685a24161b83e53ca3ecbda..77241f54c8e29ba7f1106d9e315a665a12756fb3
100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -1140,6 +1140,13 @@ FunctionLiteral* Parser::ParseLazy(Isolate* isolate,
ParseInfo* info,
DCHECK(target_stack_ == NULL);
Handle<String> name(String::cast(shared_info->name()));
+
+ // If we're lazy-compiling 'eval' itself, blank out its name to avoid
+ // spurious "Unexpected eval in strict mode" errors.
+ if (*shared_info ==
isolate->native_context()->global_eval_fun()->shared()) {
+ name = isolate->factory()->empty_string();
+ }
+
DCHECK(ast_value_factory());
fni_ = new (zone()) FuncNameInferrer(ast_value_factory(), zone());
const AstRawString* raw_name = ast_value_factory()->GetString(name);
Index: test/test262-es6/test262-es6.status
diff --git a/test/test262-es6/test262-es6.status
b/test/test262-es6/test262-es6.status
index
65ded6d3f5430de45ecffe7228cafa7582eca106..0b0dc750a6ed01f3bb59c61d9be7980df1545626
100644
--- a/test/test262-es6/test262-es6.status
+++ b/test/test262-es6/test262-es6.status
@@ -713,27 +713,6 @@
'intl402/13.2.1_5': [PASS, FAIL],
'intl402/13.3.0_7': [PASS, FAIL],
- # These tests fail in nosnap in strict mode
- # https://code.google.com/p/v8/issues/detail?id=4198
- 'built-ins/String/S15.5.1.1_A1_T6': [PASS, FAIL_OK],
- 'built-ins/eval/S15.1.2.1_A1.1_T1': [PASS, FAIL_OK],
- 'built-ins/eval/S15.1.2.1_A1.1_T2': [PASS, FAIL_OK],
- 'built-ins/eval/S15.1.2.1_A4.3': [PASS, FAIL_OK],
- 'built-ins/eval/S15.1.2.1_A4.4': [PASS, FAIL_OK],
- 'language/eval-code/10.4.2-1-1': [PASS, FAIL_OK],
- 'language/eval-code/10.4.2-1-2': [PASS, FAIL_OK],
- 'language/eval-code/10.4.2-1-3': [PASS, FAIL_OK],
- 'language/eval-code/10.4.2-1-5': [PASS, FAIL_OK],
- 'language/eval-code/S10.4.2.1_A1': [PASS, FAIL_OK],
- 'language/function-code/10.4.3-1-19-s': [PASS, FAIL_OK],
- 'language/function-code/10.4.3-1-19gs': [PASS, FAIL_OK],
- 'language/function-code/10.4.3-1-20-s': [PASS, FAIL_OK],
- 'language/function-code/10.4.3-1-20gs': [PASS, FAIL_OK],
- 'language/statements/variable/12.2.1-10-s': [PASS, FAIL_OK],
- 'language/statements/variable/12.2.1-20-s': [PASS, FAIL_OK],
- 'language/statements/variable/12.2.1-21-s': [PASS, FAIL_OK],
- 'language/statements/variable/12.2.1-9-s': [PASS, FAIL_OK],
-
##################### DELIBERATE INCOMPATIBILITIES #####################
'built-ins/Math/exp/S15.8.2.8_A6': [PASS, FAIL_OK], # Math.exp (less
precise with --fast-math)
--
--
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.