diff --git a/common.gypi b/common.gypi index 9ebda1c4654617..3b0bcd6408ed93 100644 --- a/common.gypi +++ b/common.gypi @@ -36,7 +36,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.23', + 'v8_embedder_string': '-node.24', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/src/ast/source-range-ast-visitor.cc b/deps/v8/src/ast/source-range-ast-visitor.cc index 52359d54525a77..ee2c4f58743de3 100644 --- a/deps/v8/src/ast/source-range-ast-visitor.cc +++ b/deps/v8/src/ast/source-range-ast-visitor.cc @@ -99,11 +99,13 @@ void SourceRangeAstVisitor::MaybeRemoveLastContinuationRange( } namespace { -Statement* FindLastNonSyntheticReturn(ZonePtrList* statements) { +Statement* FindLastNonSyntheticStatement(ZonePtrList* statements) { for (int i = statements->length() - 1; i >= 0; --i) { Statement* stmt = statements->at(i); - if (!stmt->IsReturnStatement()) break; - if (stmt->AsReturnStatement()->is_synthetic_async_return()) continue; + if (stmt->IsReturnStatement() && + stmt->AsReturnStatement()->is_synthetic_async_return()) { + continue; + } return stmt; } return nullptr; @@ -114,11 +116,11 @@ void SourceRangeAstVisitor::MaybeRemoveContinuationRangeOfAsyncReturn( TryCatchStatement* try_catch_stmt) { // Detect try-catch inserted by NewTryCatchStatementForAsyncAwait in the // parser (issued for async functions, including async generators), and - // remove the continuation ranges of return statements corresponding to - // returns at function end in the untransformed source. + // remove the continuation range of the last statement, such that the + // range of the enclosing function body is used. if (try_catch_stmt->is_try_catch_for_async()) { Statement* last_non_synthetic = - FindLastNonSyntheticReturn(try_catch_stmt->try_block()->statements()); + FindLastNonSyntheticStatement(try_catch_stmt->try_block()->statements()); if (last_non_synthetic) { MaybeRemoveContinuationRange(last_non_synthetic); } diff --git a/deps/v8/test/mjsunit/code-coverage-block-async.js b/deps/v8/test/mjsunit/code-coverage-block-async.js index 56845aac0127a3..2876816c9510d0 100644 --- a/deps/v8/test/mjsunit/code-coverage-block-async.js +++ b/deps/v8/test/mjsunit/code-coverage-block-async.js @@ -136,4 +136,66 @@ test().then(r => r.bar()); // 0350 {"start":152,"end":253,"count":1}, {"start":362,"end":374,"count":1}]); +TestCoverage( +"https://crbug.com/v8/10628", +` +async function abc() { // 0000 + try { // 0050 + return 'abc'; // 0100 + } finally { // 0150 + console.log('in finally'); // 0200 + } // 0250 +} // 0300 +abc(); // 0350 +%PerformMicrotaskCheckpoint(); // 0400 +`, +[{"start":0,"end":449,"count":1}, + {"start":0,"end":301,"count":1}]); + +TestCoverage( +"try/catch/finally statements async", +` +!async function() { // 0000 + try { nop(); } catch (e) { nop(); } // 0050 + try { nop(); } finally { nop(); } // 0100 + try { // 0150 + try { throw 42; } catch (e) { nop(); }// 0200 + } catch (e) { nop(); } // 0250 + try { // 0300 + try { throw 42; } finally { nop(); } // 0350 + } catch (e) { nop(); } // 0400 + try { // 0450 + throw 42; // 0500 + } catch (e) { // 0550 + nop(); // 0600 + } finally { // 0650 + nop(); // 0700 + } // 0750 +}(); // 0800 +`, +[{"start":0,"end":849,"count":1}, + {"start":1,"end":801,"count":1}, + {"start":67,"end":87,"count":0}, + {"start":254,"end":274,"count":0}] +); + +TestCoverage("try/catch/finally statements with early return async", +` +!async function() { // 0000 + try { throw 42; } catch (e) { return; } // 0050 + nop(); // 0100 +}(); // 0150 +!async function() { // 0200 + try { throw 42; } catch (e) {} // 0250 + finally { return; } // 0300 + nop(); // 0350 +}(); // 0400 +`, +[{"start":0,"end":449,"count":1}, + {"start":1,"end":151,"count":1}, + {"start":91,"end":150,"count":0}, + {"start":201,"end":401,"count":1}, + {"start":321,"end":400,"count":0}] +); + %DebugToggleBlockCoverage(false);