00912d73f1
While parsing top-level code eager functions are skipped just like lazy ones, but also a parse task is created for each. The parse tasks are run by the compiler dispatcher and can be executed either on background thread or in idle time. After parsing of top-level code finishes it waits for all unfinished parser tasks - possibly picking up and executing them on current thread. Afterwards parse task results are stitched together with top-level AST, in case of failures eager functions are treated just like lazy - parsing/compilation is retriggered for them in the runtime and proper errors are generated (performance is not optimized for error case at all). BUG=v8:6093 Change-Id: Ie6508211a04b90becfe44139cce1c8ecec386b6e Reviewed-on: https://chromium-review.googlesource.com/486725 Reviewed-by: Jochen Eisinger <jochen@chromium.org> Reviewed-by: Marja Hölttä <marja@chromium.org> Reviewed-by: Daniel Vogelheim <vogelheim@chromium.org> Commit-Queue: Wiktor Garbacz <wiktorg@google.com> Cr-Commit-Position: refs/heads/master@{#45016}
48 lines
913 B
JavaScript
48 lines
913 B
JavaScript
// Copyright 2017 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: --compiler-dispatcher --use-parse-tasks --use-external-strings
|
|
|
|
(function(a) {
|
|
assertEquals(a, "IIFE");
|
|
})("IIFE");
|
|
|
|
(function(a, ...rest) {
|
|
assertEquals(a, 1);
|
|
assertEquals(rest.length, 2);
|
|
assertEquals(rest[0], 2);
|
|
assertEquals(rest[1], 3);
|
|
})(1,2,3);
|
|
|
|
var outer_var = 42;
|
|
|
|
function lazy_outer() {
|
|
return 42;
|
|
}
|
|
|
|
var eager_outer = (function() { return 42; });
|
|
|
|
(function() {
|
|
assertEquals(outer_var, 42);
|
|
assertEquals(lazy_outer(), 42);
|
|
assertEquals(eager_outer(), 42);
|
|
})();
|
|
|
|
var gen = (function*() {
|
|
yield 1;
|
|
yield 2;
|
|
})();
|
|
|
|
assertEquals(gen.next().value, 1);
|
|
assertEquals(gen.next().value, 2);
|
|
|
|
var result = (function recursive(a=0) {
|
|
if (a == 1) {
|
|
return 42;
|
|
}
|
|
return recursive(1);
|
|
})();
|
|
|
|
assertEquals(result, 42);
|