[map] 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.

R=gsathya@chromium.org, jgruber@chromium.org

Bug: v8:7047
Change-Id: I7ce0253883a21d6059e4e0ed0fc56dc55a0dcba6
Reviewed-on: https://chromium-review.googlesource.com/758372
Reviewed-by: Jakob Gruber <jgruber@chromium.org>
Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org>
Commit-Queue: Yang Guo <yangguo@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49237}
This commit is contained in:
Yang Guo 2017-11-08 13:06:37 +01:00 committed by Commit Bot
parent 295c9cc643
commit 3c8195d910
3 changed files with 35 additions and 5 deletions

View File

@ -316,10 +316,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();
}
}

View File

@ -3,3 +3,11 @@ 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
paused in throwInAsyncIterator
uncaught: true

View File

@ -7,6 +7,19 @@ 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 throwInAsyncIterator() {
let it = (async function*() {})();
it.next.call({});
}
function schedule(f) { setTimeout(f, 0); }
`);
@ -22,4 +35,12 @@ 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(() => Protocol.Runtime.evaluate(
{ "expression": "schedule(throwInAsyncIterator);"}))
.then(() => InspectorTest.completeTest());