@@ -23,68 +23,52 @@ TNode<Object> IteratorBuiltinsAssembler::GetIteratorMethod(
2323 return GetProperty (context, object, factory ()->iterator_symbol ());
2424}
2525
26- IteratorRecord IteratorBuiltinsAssembler::GetIterator (
27- TNode<Context> context, TNode<Object> object, Label* if_exception,
28- TVariable<Object>* exception) {
26+ IteratorRecord IteratorBuiltinsAssembler::GetIterator (TNode<Context> context,
27+ TNode<Object> object) {
2928 TNode<Object> method = GetIteratorMethod (context, object);
30- return GetIterator (context, object, method, if_exception, exception );
29+ return GetIterator (context, object, method);
3130}
3231
33- IteratorRecord IteratorBuiltinsAssembler::GetIterator (
34- TNode<Context> context, TNode<Object> object, TNode<Object> method,
35- Label* if_exception, TVariable<Object>* exception) {
36- GotoIfException (method, if_exception, exception);
37-
32+ IteratorRecord IteratorBuiltinsAssembler::GetIterator (TNode<Context> context,
33+ TNode<Object> object,
34+ TNode<Object> method) {
3835 Label if_not_callable (this , Label::kDeferred ), if_callable (this );
3936 GotoIf (TaggedIsSmi (method), &if_not_callable);
4037 Branch (IsCallable (CAST (method)), &if_callable, &if_not_callable);
4138
4239 BIND (&if_not_callable);
43- {
44- TNode<Object> ret =
45- CallRuntime (Runtime::kThrowIteratorError , context, object);
46- GotoIfException (ret, if_exception, exception);
47- Unreachable ();
48- }
40+ CallRuntime (Runtime::kThrowIteratorError , context, object);
41+ Unreachable ();
4942
5043 BIND (&if_callable);
5144 {
52- Callable callable = CodeFactory::Call (isolate ());
53- TNode<Object> iterator = CallJS (callable, context, method, object);
54- GotoIfException (iterator, if_exception, exception);
45+ TNode<Object> iterator =
46+ CallJS (CodeFactory::Call (isolate ()), context, method, object);
5547
5648 Label get_next (this ), if_notobject (this , Label::kDeferred );
5749 GotoIf (TaggedIsSmi (iterator), &if_notobject);
5850 Branch (IsJSReceiver (CAST (iterator)), &get_next, &if_notobject);
5951
6052 BIND (&if_notobject);
61- {
62- TNode<Object> ret =
63- CallRuntime (Runtime::kThrowSymbolIteratorInvalid , context);
64- GotoIfException (ret, if_exception, exception);
65- Unreachable ();
66- }
53+ CallRuntime (Runtime::kThrowSymbolIteratorInvalid , context);
54+ Unreachable ();
6755
6856 BIND (&get_next);
69- const TNode<Object> next =
57+ TNode<Object> next =
7058 GetProperty (context, iterator, factory ()->next_string ());
71- GotoIfException (next, if_exception, exception);
72-
7359 return IteratorRecord{TNode<JSReceiver>::UncheckedCast (iterator),
7460 TNode<Object>::UncheckedCast (next)};
7561 }
7662}
7763
7864TNode<JSReceiver> IteratorBuiltinsAssembler::IteratorStep (
7965 TNode<Context> context, const IteratorRecord& iterator, Label* if_done,
80- base::Optional<TNode<Map>> fast_iterator_result_map, Label* if_exception,
81- TVariable<Object>* exception) {
66+ base::Optional<TNode<Map>> fast_iterator_result_map) {
8267 DCHECK_NOT_NULL (if_done);
8368 // 1. a. Let result be ? Invoke(iterator, "next", « »).
8469 Callable callable = CodeFactory::Call (isolate ());
8570 TNode<Object> result =
8671 CallJS (callable, context, iterator.next , iterator.object );
87- GotoIfException (result, if_exception, exception);
8872
8973 // 3. If Type(result) is not Object, throw a TypeError exception.
9074 Label if_notobject (this , Label::kDeferred ), return_result (this );
@@ -117,26 +101,20 @@ TNode<JSReceiver> IteratorBuiltinsAssembler::IteratorStep(
117101 // 2. Return ToBoolean(? Get(iterResult, "done")).
118102 TNode<Object> done =
119103 GetProperty (context, heap_object_result, factory ()->done_string ());
120- GotoIfException (done, if_exception, exception);
121104 BranchIfToBooleanIsTrue (done, if_done, &return_result);
122105 }
123106
124107 BIND (&if_notobject);
125- {
126- TNode<Object> ret =
127- CallRuntime (Runtime::kThrowIteratorResultNotAnObject , context, result);
128- GotoIfException (ret, if_exception, exception);
129- Unreachable ();
130- }
108+ CallRuntime (Runtime::kThrowIteratorResultNotAnObject , context, result);
109+ Unreachable ();
131110
132111 BIND (&return_result);
133112 return CAST (heap_object_result);
134113}
135114
136115TNode<Object> IteratorBuiltinsAssembler::IteratorValue (
137116 TNode<Context> context, TNode<JSReceiver> result,
138- base::Optional<TNode<Map>> fast_iterator_result_map, Label* if_exception,
139- TVariable<Object>* exception) {
117+ base::Optional<TNode<Map>> fast_iterator_result_map) {
140118 Label exit (this );
141119 TVARIABLE (Object, var_value);
142120 if (fast_iterator_result_map) {
@@ -151,13 +129,8 @@ TNode<Object> IteratorBuiltinsAssembler::IteratorValue(
151129 }
152130
153131 // Generic iterator result case:
154- {
155- TNode<Object> value =
156- GetProperty (context, result, factory ()->value_string ());
157- GotoIfException (value, if_exception, exception);
158- var_value = value;
159- Goto (&exit);
160- }
132+ var_value = GetProperty (context, result, factory ()->value_string ());
133+ Goto (&exit);
161134
162135 BIND (&exit);
163136 return var_value.value ();
@@ -174,23 +147,24 @@ void IteratorBuiltinsAssembler::IteratorCloseOnException(
174147 CSA_ASSERT (this , IsJSReceiver (iterator.object ));
175148
176149 // Let return be ? GetMethod(iterator, "return").
177- TNode<Object> method =
178- GetProperty (context, iterator.object , factory ()->return_string ());
179- GotoIfException (method, if_exception, exception);
150+ TNode<Object> method;
151+ {
152+ compiler::ScopedExceptionHandler handler (this , if_exception, exception);
153+ method = GetProperty (context, iterator.object , factory ()->return_string ());
154+ }
180155
181156 // If return is undefined, return Completion(completion).
182157 GotoIf (Word32Or (IsUndefined (method), IsNull (method)), if_exception);
183158
184159 {
185160 // Let innerResult be Call(return, iterator, « »).
186- // If an exception occurs, the original exception remains bound
187- TNode<Object> inner_result =
188- CallJS (CodeFactory::Call (isolate ()), context, method, iterator.object );
189- GotoIfException (inner_result, if_exception, nullptr );
190-
191- // (If completion.[[Type]] is throw) return Completion(completion).
192- Goto (if_exception);
161+ // If an exception occurs, the original exception remains bound.
162+ compiler::ScopedExceptionHandler handler (this , if_exception, nullptr );
163+ CallJS (CodeFactory::Call (isolate ()), context, method, iterator.object );
193164 }
165+
166+ // (If completion.[[Type]] is throw) return Completion(completion).
167+ Goto (if_exception);
194168}
195169
196170void IteratorBuiltinsAssembler::IteratorCloseOnException (
@@ -317,10 +291,13 @@ TNode<JSArray> IteratorBuiltinsAssembler::StringListFromIterable(
317291 {
318292 // 1. Let error be ThrowCompletion(a newly created TypeError object).
319293 TVARIABLE (Object, var_exception);
320- TNode<Object> ret = CallRuntime (
321- Runtime::kThrowTypeError , context,
322- SmiConstant (MessageTemplate::kIterableYieldedNonString ), next_value);
323- GotoIfException (ret, &if_exception, &var_exception);
294+ {
295+ compiler::ScopedExceptionHandler handler (this , &if_exception,
296+ &var_exception);
297+ CallRuntime (Runtime::kThrowTypeError , context,
298+ SmiConstant (MessageTemplate::kIterableYieldedNonString ),
299+ next_value);
300+ }
324301 Unreachable ();
325302
326303 // 2. Return ? IteratorClose(iteratorRecord, error).
0 commit comments