Merge V8 5.3.332.45. DO NOT MERGE
Test: Manual
FPIIM-449
Change-Id: Id3254828b068abdea3cb10442e0172a8c9a98e03
(cherry picked from commit 13e2dadd00298019ed862f2b2fc5068bba730bcf)
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index 36f7293..ab1fc76 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -1509,7 +1509,8 @@
kAllowHarmonyRestrictiveDeclarations,
kAllowHarmonyExponentiationOperator,
kAllowHarmonyForIn,
- kAllowHarmonyAsyncAwait
+ kAllowHarmonyAsyncAwait,
+ kAllowHarmonyRestrictiveGenerators,
};
enum ParserSyncTestResult {
@@ -1532,6 +1533,8 @@
parser->set_allow_harmony_for_in(flags.Contains(kAllowHarmonyForIn));
parser->set_allow_harmony_async_await(
flags.Contains(kAllowHarmonyAsyncAwait));
+ parser->set_allow_harmony_restrictive_generators(
+ flags.Contains(kAllowHarmonyRestrictiveGenerators));
}
@@ -3566,10 +3569,8 @@
CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback);
CompileRun("\"use asm\";\n"
"var foo = 1;\n"
- "\"use asm\";\n" // Only the first one counts.
"function bar() { \"use asm\"; var baz = 1; }");
- // Optimizing will double-count because the source is parsed twice.
- CHECK_EQ(i::FLAG_always_opt ? 4 : 2, use_counts[v8::Isolate::kUseAsm]);
+ CHECK_LT(0, use_counts[v8::Isolate::kUseAsm]);
}
@@ -7503,6 +7504,9 @@
"var O = { async 'method'() { await 1; } }",
"var O = { async 0() { await 1; } }",
"async function await() {}",
+
+ "var asyncFn = async({ foo = 1 }) => foo;",
+ "var asyncFn = async({ foo = 1 } = {}) => foo;",
NULL
};
// clang-format on
@@ -7639,6 +7643,35 @@
"var O = { async method() { function await() {} } }",
"async function foo() { function await() {} }",
+ // Henrique Ferreiro's bug (tm)
+ "(async function foo() { } foo => 1)",
+ "(async function foo() { } () => 1)",
+ "(async function foo() { } => 1)",
+ "(async function() { } foo => 1)",
+ "(async function() { } () => 1)",
+ "(async function() { } => 1)",
+ "(async.foo => 1)",
+ "(async.foo foo => 1)",
+ "(async.foo () => 1)",
+ "(async().foo => 1)",
+ "(async().foo foo => 1)",
+ "(async().foo () => 1)",
+ "(async['foo'] => 1)",
+ "(async['foo'] foo => 1)",
+ "(async['foo'] () => 1)",
+ "(async()['foo'] => 1)",
+ "(async()['foo'] foo => 1)",
+ "(async()['foo'] () => 1)",
+ "(async`foo` => 1)",
+ "(async`foo` foo => 1)",
+ "(async`foo` () => 1)",
+ "(async`foo`.bar => 1)",
+ "(async`foo`.bar foo => 1)",
+ "(async`foo`.bar () => 1)",
+
+ // v8:5148 assert that errors are still thrown for calls that may have been
+ // async functions
+ "async({ foo = 1 })",
NULL
};
@@ -7660,6 +7693,22 @@
NULL
};
+
+ const char* formal_parameters_data[] = {
+ "var f = async({ await }) => 1;",
+ "var f = async({ await = 1 }) => 1;",
+ "var f = async({ await } = {}) => 1;",
+ "var f = async({ await = 1 } = {}) => 1;",
+ "var f = async([await]) => 1;",
+ "var f = async([await] = []) => 1;",
+ "var f = async([await = 1]) => 1;",
+ "var f = async([await = 1] = []) => 1;",
+ "var f = async(...await) => 1;",
+ "var f = async(await) => 1;",
+ "var f = async(await = 1) => 1;",
+ "var f = async(...[await]) => 1;",
+ NULL
+ };
// clang-format on
static const ParserFlag always_flags[] = {kAllowHarmonyAsyncAwait};
@@ -7667,6 +7716,9 @@
arraysize(always_flags));
RunParserSyncTest(strict_context_data, strict_error_data, kError, NULL, 0,
always_flags, arraysize(always_flags));
+
+ RunParserSyncTest(context_data, formal_parameters_data, kError, NULL, 0,
+ always_flags, arraysize(always_flags));
}
TEST(AsyncAwaitModule) {
@@ -7731,3 +7783,60 @@
RunParserSyncTest(context_data, error_data, kError, nullptr, 0, always_flags,
arraysize(always_flags));
}
+
+TEST(NoDuplicateGeneratorsInBlock) {
+ const char* block_context_data[][2] = {
+ {"'use strict'; {", "}"},
+ {"{", "}"},
+ {"(function() { {", "} })()"},
+ {"(function() {'use strict'; {", "} })()"},
+ {NULL, NULL}};
+ const char* top_level_context_data[][2] = {
+ {"'use strict';", ""},
+ {"", ""},
+ {"(function() {", "})()"},
+ {"(function() {'use strict';", "})()"},
+ {NULL, NULL}};
+ const char* error_data[] = {"function* x() {} function* x() {}",
+ "function x() {} function* x() {}",
+ "function* x() {} function x() {}", NULL};
+ static const ParserFlag always_flags[] = {kAllowHarmonyRestrictiveGenerators};
+ // The preparser doesn't enforce the restriction, so turn it off.
+ bool test_preparser = false;
+ RunParserSyncTest(block_context_data, error_data, kError, NULL, 0,
+ always_flags, arraysize(always_flags), NULL, 0, false,
+ test_preparser);
+ RunParserSyncTest(top_level_context_data, error_data, kSuccess, NULL, 0,
+ always_flags, arraysize(always_flags));
+}
+
+TEST(NoDuplicateAsyncFunctionInBlock) {
+ const char* block_context_data[][2] = {
+ {"'use strict'; {", "}"},
+ {"{", "}"},
+ {"(function() { {", "} })()"},
+ {"(function() {'use strict'; {", "} })()"},
+ {NULL, NULL}};
+ const char* top_level_context_data[][2] = {
+ {"'use strict';", ""},
+ {"", ""},
+ {"(function() {", "})()"},
+ {"(function() {'use strict';", "})()"},
+ {NULL, NULL}};
+ const char* error_data[] = {"async function x() {} async function x() {}",
+ "function x() {} async function x() {}",
+ "async function x() {} function x() {}",
+ "function* x() {} async function x() {}",
+ "function* x() {} async function x() {}",
+ "async function x() {} function* x() {}",
+ "function* x() {} async function x() {}",
+ NULL};
+ static const ParserFlag always_flags[] = {kAllowHarmonyAsyncAwait};
+ // The preparser doesn't enforce the restriction, so turn it off.
+ bool test_preparser = false;
+ RunParserSyncTest(block_context_data, error_data, kError, NULL, 0,
+ always_flags, arraysize(always_flags), NULL, 0, false,
+ test_preparser);
+ RunParserSyncTest(top_level_context_data, error_data, kSuccess, NULL, 0,
+ always_flags, arraysize(always_flags));
+}