Skip to content

Commit

Permalink
deps: backport 3c8195d from V8 upstream
Browse files Browse the repository at this point in the history
Original commit message:
    Fix map constructor to correctly throw.

    We need to throw before rethrowing, otherwise the exception does
    not trigger a debugger event and is not reported if uncaught.

    [email protected], [email protected]

    Bug: v8:7047
    Change-Id: I7ce0253883a21d6059e4e0ed0fc56dc55a0dcba6
    Reviewed-on: https://chromium-review.googlesource.com/758372
    Reviewed-by: Jakob Gruber <[email protected]>
    Reviewed-by: Sathya Gunasekaran <[email protected]>
    Commit-Queue: Yang Guo <[email protected]>
    Cr-Commit-Position: refs/heads/master@{#49237}

Fixes: #17270
PR-URL: #17383
Backport-PR-URL: #16413
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: Yang Guo <[email protected]>
Reviewed-By: Michael Dawson <[email protected]>
  • Loading branch information
MylesBorins authored and gibfahn committed Feb 18, 2018
1 parent 0ee6455 commit 0a064c4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
9 changes: 5 additions & 4 deletions deps/v8/src/builtins/builtins-collections-gen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,11 @@ TF_BUILTIN(MapConstructor, CollectionsBuiltinsAssembler) {

BIND(&if_notobject);
{
Node* const exception = MakeTypeError(
MessageTemplate::kIteratorValueNotAnObject, context, next_value);
var_exception.Bind(exception);
Goto(&if_exception);
Node* ret = CallRuntime(
Runtime::kThrowTypeError, context,
SmiConstant(MessageTemplate::kIteratorValueNotAnObject), next_value);
GotoIfException(ret, &if_exception, &var_exception);
Unreachable();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ paused in throwCaught
uncaught: false
paused in throwUncaught
uncaught: true
paused in throwInPromiseCaught
uncaught: false
paused in promiseUncaught
uncaught: true
paused in throwInMapConstructor
uncaught: true
17 changes: 16 additions & 1 deletion deps/v8/test/inspector/debugger/caught-uncaught-exceptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ let {session, contextGroup, Protocol} = InspectorTest.start("Check that inspecto
contextGroup.addScript(
`function throwCaught() { try { throw new Error(); } catch (_) {} }
function throwUncaught() { throw new Error(); }
function throwInPromiseCaught() {
var reject;
new Promise(function(res, rej) { reject = rej; }).catch(() => {});
reject();
}
function throwInPromiseUncaught() {
new Promise(function promiseUncaught() { throw new Error(); });
}
function throwInMapConstructor() { new Map('a'); }
function schedule(f) { setTimeout(f, 0); }
`);

Expand All @@ -22,4 +31,10 @@ Protocol.Debugger.onPaused(message => {
Protocol.Runtime.evaluate({ "expression": "schedule(throwCaught);" })
.then(() => Protocol.Runtime.evaluate(
{ "expression": "schedule(throwUncaught);" }))
.then(() => InspectorTest.completeTest());
.then(() => Protocol.Runtime.evaluate(
{ "expression": "schedule(throwInPromiseCaught);"}))
.then(() => Protocol.Runtime.evaluate(
{ "expression": "schedule(throwInPromiseUncaught);"}))
.then(() => Protocol.Runtime.evaluate(
{ "expression": "schedule(throwInMapConstructor);"}))
.then(() => InspectorTest.completeTest());

0 comments on commit 0a064c4

Please sign in to comment.