Commit e6e301d5 authored by Daniel Clifford's avatar Daniel Clifford Committed by Commit Bot

Fix IteratorCloseOnException Torque interface

It sould take an exception argument to ensure the proper re-throw
semantics.

Change-Id: I36caba1a80c0d3f59c18dce5a58a0c1f0100657d
Reviewed-on: https://chromium-review.googlesource.com/c/1328803
Commit-Queue: Daniel Clifford <danno@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#57401}
parent d0049fb7
......@@ -2065,7 +2065,7 @@ TF_BUILTIN(ArrayFrom, ArrayPopulatorAssembler) {
// Close the iterator, rethrowing either the passed exception or
// exceptions thrown during the close.
iterator_assembler.IteratorCloseOnException(context, iterator_record,
&var_exception);
var_exception.value());
}
}
......
......@@ -340,7 +340,7 @@ void BaseCollectionsAssembler::AddConstructorEntriesFromIterable(
BIND(&if_exception);
{
iterator_assembler.IteratorCloseOnException(context, iterator,
&var_exception);
var_exception.value());
}
BIND(&exit);
}
......
......@@ -167,8 +167,7 @@ void IteratorBuiltinsAssembler::IteratorCloseOnException(
// Perform ES #sec-iteratorclose when an exception occurs. This simpler
// algorithm does not include redundant steps which are never reachable from
// the spec IteratorClose algorithm.
DCHECK((if_exception != nullptr && exception != nullptr) ||
IsExceptionHandlerActive());
DCHECK((if_exception != nullptr && exception != nullptr));
CSA_ASSERT(this, IsNotTheHole(exception->value()));
CSA_ASSERT(this, IsJSReceiver(iterator.object));
......@@ -193,12 +192,13 @@ void IteratorBuiltinsAssembler::IteratorCloseOnException(
}
void IteratorBuiltinsAssembler::IteratorCloseOnException(
Node* context, const IteratorRecord& iterator, Variable* exception) {
Node* context, const IteratorRecord& iterator, TNode<Object> exception) {
Label rethrow(this, Label::kDeferred);
IteratorCloseOnException(context, iterator, &rethrow, exception);
TVARIABLE(Object, exception_variable, exception);
IteratorCloseOnException(context, iterator, &rethrow, &exception_variable);
BIND(&rethrow);
CallRuntime(Runtime::kReThrow, context, exception->value());
CallRuntime(Runtime::kReThrow, context, exception);
Unreachable();
}
......
......@@ -61,11 +61,11 @@ class IteratorBuiltinsAssembler : public CodeStubAssembler {
void IteratorCloseOnException(
Node* context,
const BaseBuiltinsFromDSLAssembler::IteratorRecord& iterator,
Label* if_exception = nullptr, Variable* exception = nullptr);
Label* if_exception, Variable* exception);
void IteratorCloseOnException(
Node* context,
const BaseBuiltinsFromDSLAssembler::IteratorRecord& iterator,
Variable* exception);
TNode<Object> exception);
// #sec-iterabletolist
// Build a JSArray by iterating over {iterable} using {iterator_fn},
......
......@@ -21,7 +21,7 @@ module iterator {
implicit context: Context)(Object, Map): Object;
extern macro IteratorBuiltinsAssembler::IteratorCloseOnException(
implicit context: Context)(IteratorRecord);
implicit context: Context)(IteratorRecord, Object): never;
extern macro IteratorBuiltinsAssembler::IterableToList(
implicit context: Context)(Object, Object): JSArray;
......
......@@ -662,9 +662,9 @@ module test {
const t5: Object = iterator::IteratorValue(t4);
const t6: Object = iterator::IteratorValue(t4, map);
iterator::IteratorCloseOnException(t2);
const t7: JSArray = iterator::IterableToList(t1, t1);
iterator::IteratorCloseOnException(t2, t5);
}
label Fail {}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment