Commit 66a9dbe8 authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[cleanup] Tnodify builtins-iterator-gen.cc

Bug: v8:9810
Change-Id: Ie2cba5da240f53f7be7d6aee0426489d972a22a1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1906569Reviewed-by: 's avatarSantiago Aboy Solanes <solanes@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64864}
parent a494bcfc
......@@ -18,29 +18,26 @@ namespace internal {
using IteratorRecord = TorqueStructIteratorRecord;
using compiler::Node;
TNode<Object> IteratorBuiltinsAssembler::GetIteratorMethod(Node* context,
Node* object) {
TNode<Object> IteratorBuiltinsAssembler::GetIteratorMethod(
TNode<Context> context, TNode<Object> object) {
return GetProperty(context, object, factory()->iterator_symbol());
}
IteratorRecord IteratorBuiltinsAssembler::GetIterator(Node* context,
Node* object,
Label* if_exception,
Variable* exception) {
IteratorRecord IteratorBuiltinsAssembler::GetIterator(
SloppyTNode<Context> context, SloppyTNode<Object> object,
Label* if_exception, TVariable<Object>* exception) {
TNode<Object> method = GetIteratorMethod(context, object);
return GetIterator(context, object, method, if_exception, exception);
}
IteratorRecord IteratorBuiltinsAssembler::GetIterator(Node* context,
Node* object,
Node* method,
Label* if_exception,
Variable* exception) {
IteratorRecord IteratorBuiltinsAssembler::GetIterator(
TNode<Context> context, TNode<Object> object, TNode<Object> method,
Label* if_exception, TVariable<Object>* exception) {
GotoIfException(method, if_exception, exception);
Label if_not_callable(this, Label::kDeferred), if_callable(this);
GotoIf(TaggedIsSmi(method), &if_not_callable);
Branch(IsCallable(method), &if_callable, &if_not_callable);
Branch(IsCallable(CAST(method)), &if_callable, &if_not_callable);
BIND(&if_not_callable);
{
......@@ -53,12 +50,12 @@ IteratorRecord IteratorBuiltinsAssembler::GetIterator(Node* context,
BIND(&if_callable);
{
Callable callable = CodeFactory::Call(isolate());
Node* iterator = CallJS(callable, context, method, object);
TNode<Object> iterator = CallJS(callable, context, method, object);
GotoIfException(iterator, if_exception, exception);
Label get_next(this), if_notobject(this, Label::kDeferred);
GotoIf(TaggedIsSmi(iterator), &if_notobject);
Branch(IsJSReceiver(iterator), &get_next, &if_notobject);
Branch(IsJSReceiver(CAST(iterator)), &get_next, &if_notobject);
BIND(&if_notobject);
{
......@@ -81,17 +78,19 @@ IteratorRecord IteratorBuiltinsAssembler::GetIterator(Node* context,
TNode<JSReceiver> IteratorBuiltinsAssembler::IteratorStep(
TNode<Context> context, const IteratorRecord& iterator, Label* if_done,
base::Optional<TNode<Map>> fast_iterator_result_map, Label* if_exception,
Variable* exception) {
TVariable<Object>* exception) {
DCHECK_NOT_NULL(if_done);
// 1. a. Let result be ? Invoke(iterator, "next", « »).
Callable callable = CodeFactory::Call(isolate());
Node* result = CallJS(callable, context, iterator.next, iterator.object);
TNode<Object> result =
CallJS(callable, context, iterator.next, iterator.object);
GotoIfException(result, if_exception, exception);
// 3. If Type(result) is not Object, throw a TypeError exception.
Label if_notobject(this, Label::kDeferred), return_result(this);
GotoIf(TaggedIsSmi(result), &if_notobject);
TNode<Map> result_map = LoadMap(result);
TNode<HeapObject> heap_object_result = CAST(result);
TNode<Map> result_map = LoadMap(heap_object_result);
if (fast_iterator_result_map) {
// Fast iterator result case:
......@@ -102,7 +101,8 @@ TNode<JSReceiver> IteratorBuiltinsAssembler::IteratorStep(
// IteratorComplete
// 2. Return ToBoolean(? Get(iterResult, "done")).
TNode<Object> done = LoadObjectField(result, JSIteratorResult::kDoneOffset);
TNode<Object> done =
LoadObjectField(heap_object_result, JSIteratorResult::kDoneOffset);
BranchIfToBooleanIsTrue(done, if_done, &return_result);
BIND(&if_generic);
......@@ -115,7 +115,8 @@ TNode<JSReceiver> IteratorBuiltinsAssembler::IteratorStep(
// IteratorComplete
// 2. Return ToBoolean(? Get(iterResult, "done")).
TNode<Object> done = GetProperty(context, result, factory()->done_string());
TNode<Object> done =
GetProperty(context, heap_object_result, factory()->done_string());
GotoIfException(done, if_exception, exception);
BranchIfToBooleanIsTrue(done, if_done, &return_result);
}
......@@ -129,13 +130,13 @@ TNode<JSReceiver> IteratorBuiltinsAssembler::IteratorStep(
}
BIND(&return_result);
return CAST(result);
return CAST(heap_object_result);
}
TNode<Object> IteratorBuiltinsAssembler::IteratorValue(
TNode<Context> context, TNode<JSReceiver> result,
base::Optional<TNode<Map>> fast_iterator_result_map, Label* if_exception,
Variable* exception) {
TVariable<Object>* exception) {
Label exit(this);
TVARIABLE(Object, var_value);
if (fast_iterator_result_map) {
......@@ -163,8 +164,8 @@ TNode<Object> IteratorBuiltinsAssembler::IteratorValue(
}
void IteratorBuiltinsAssembler::IteratorCloseOnException(
Node* context, const IteratorRecord& iterator, Label* if_exception,
Variable* exception) {
TNode<Context> context, const IteratorRecord& iterator, Label* if_exception,
TVariable<Object>* exception) {
// 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.
......@@ -183,7 +184,7 @@ void IteratorBuiltinsAssembler::IteratorCloseOnException(
{
// Let innerResult be Call(return, iterator, « »).
// If an exception occurs, the original exception remains bound
Node* inner_result =
TNode<Object> inner_result =
CallJS(CodeFactory::Call(isolate()), context, method, iterator.object);
GotoIfException(inner_result, if_exception, nullptr);
......@@ -193,7 +194,8 @@ void IteratorBuiltinsAssembler::IteratorCloseOnException(
}
void IteratorBuiltinsAssembler::IteratorCloseOnException(
Node* context, const IteratorRecord& iterator, TNode<Object> exception) {
TNode<Context> context, const IteratorRecord& iterator,
TNode<Object> exception) {
Label rethrow(this, Label::kDeferred);
TVARIABLE(Object, exception_variable, exception);
IteratorCloseOnException(context, iterator, &rethrow, &exception_variable);
......@@ -211,9 +213,9 @@ TNode<JSArray> IteratorBuiltinsAssembler::IterableToList(
// 2. Let values be a new empty List.
GrowableFixedArray values(state());
Variable* vars[] = {values.var_array(), values.var_length(),
values.var_capacity()};
Label loop_start(this, 3, vars), done(this);
Label loop_start(
this, {values.var_array(), values.var_length(), values.var_capacity()}),
done(this);
Goto(&loop_start);
// 3. Let next be true.
// 4. Repeat, while next is not false
......@@ -252,9 +254,9 @@ TF_BUILTIN(IterableToFixedArrayForWasm, IteratorBuiltinsAssembler) {
GrowableFixedArray values(state());
Variable* vars[] = {values.var_array(), values.var_length(),
values.var_capacity()};
Label loop_start(this, 3, vars), compare_length(this), done(this);
Label loop_start(
this, {values.var_array(), values.var_length(), values.var_capacity()}),
compare_length(this), done(this);
Goto(&loop_start);
BIND(&loop_start);
{
......@@ -289,8 +291,8 @@ TNode<JSArray> IteratorBuiltinsAssembler::StringListFromIterable(
// 3. Let list be a new empty List.
Variable* vars[] = {list.var_array(), list.var_length(), list.var_capacity()};
Label loop_start(this, 3, vars);
Label loop_start(this,
{list.var_array(), list.var_length(), list.var_capacity()});
Goto(&loop_start);
// 4. Let next be true.
// 5. Repeat, while next is not false
......
......@@ -20,16 +20,18 @@ class IteratorBuiltinsAssembler : public CodeStubAssembler {
using IteratorRecord = TorqueStructIteratorRecord;
// Returns object[Symbol.iterator].
TNode<Object> GetIteratorMethod(Node* context, Node* object);
TNode<Object> GetIteratorMethod(TNode<Context> context, TNode<Object>);
// https://tc39.github.io/ecma262/#sec-getiterator --- never used for
// @@asyncIterator.
IteratorRecord GetIterator(Node* context, Node* object,
IteratorRecord GetIterator(SloppyTNode<Context> context,
SloppyTNode<Object> object,
Label* if_exception = nullptr,
Variable* exception = nullptr);
IteratorRecord GetIterator(Node* context, Node* object, Node* method,
TVariable<Object>* exception = nullptr);
IteratorRecord GetIterator(TNode<Context> context, TNode<Object> object,
TNode<Object> method,
Label* if_exception = nullptr,
Variable* exception = nullptr);
TVariable<Object>* exception = nullptr);
// https://tc39.github.io/ecma262/#sec-iteratorstep
// If the iterator is done, goto {if_done}, otherwise returns an iterator
......@@ -39,7 +41,7 @@ class IteratorBuiltinsAssembler : public CodeStubAssembler {
TNode<JSReceiver> IteratorStep(
TNode<Context> context, const IteratorRecord& iterator, Label* if_done,
base::Optional<TNode<Map>> fast_iterator_result_map = base::nullopt,
Label* if_exception = nullptr, Variable* exception = nullptr);
Label* if_exception = nullptr, TVariable<Object>* exception = nullptr);
TNode<JSReceiver> IteratorStep(
TNode<Context> context, const IteratorRecord& iterator,
......@@ -54,12 +56,15 @@ class IteratorBuiltinsAssembler : public CodeStubAssembler {
TNode<Object> IteratorValue(
TNode<Context> context, TNode<JSReceiver> result,
base::Optional<TNode<Map>> fast_iterator_result_map = base::nullopt,
Label* if_exception = nullptr, Variable* exception = nullptr);
Label* if_exception = nullptr, TVariable<Object>* exception = nullptr);
// https://tc39.github.io/ecma262/#sec-iteratorclose
void IteratorCloseOnException(Node* context, const IteratorRecord& iterator,
Label* if_exception, Variable* exception);
void IteratorCloseOnException(Node* context, const IteratorRecord& iterator,
void IteratorCloseOnException(TNode<Context> context,
const IteratorRecord& iterator,
Label* if_exception,
TVariable<Object>* exception);
void IteratorCloseOnException(TNode<Context> context,
const IteratorRecord& iterator,
TNode<Object> exception);
// #sec-iterabletolist
......
......@@ -1659,7 +1659,7 @@ Node* PromiseBuiltinsAssembler::PerformPromiseAll(
const IteratorRecord& iterator,
const PromiseAllResolvingElementFunction& create_resolve_element_function,
const PromiseAllResolvingElementFunction& create_reject_element_function,
Label* if_exception, Variable* var_exception) {
Label* if_exception, TVariable<Object>* var_exception) {
IteratorBuiltinsAssembler iter_assembler(state());
TNode<NativeContext> native_context = LoadNativeContext(context);
......@@ -1933,7 +1933,7 @@ void PromiseBuiltinsAssembler::Generate_PromiseAll(
const TNode<PromiseCapability> capability = CAST(CallBuiltin(
Builtins::kNewPromiseCapability, context, receiver, debug_event));
VARIABLE(var_exception, MachineRepresentation::kTagged, TheHoleConstant());
TVARIABLE(Object, var_exception, TheHoleConstant());
Label reject_promise(this, &var_exception, Label::kDeferred);
// Let iterator be GetIterator(iterable).
......@@ -2205,7 +2205,7 @@ TF_BUILTIN(PromiseAllSettledRejectElementClosure, PromiseBuiltinsAssembler) {
// Promise.race ( iterable )
TF_BUILTIN(PromiseRace, PromiseBuiltinsAssembler) {
IteratorBuiltinsAssembler iter_assembler(state());
VARIABLE(var_exception, MachineRepresentation::kTagged, TheHoleConstant());
TVARIABLE(Object, var_exception, TheHoleConstant());
Node* const receiver = Parameter(Descriptor::kReceiver);
const TNode<Context> context = CAST(Parameter(Descriptor::kContext));
......
......@@ -133,7 +133,7 @@ class V8_EXPORT_PRIVATE PromiseBuiltinsAssembler : public CodeStubAssembler {
const TorqueStructIteratorRecord& record,
const PromiseAllResolvingElementFunction& create_resolve_element_function,
const PromiseAllResolvingElementFunction& create_reject_element_function,
Label* if_exception, Variable* var_exception);
Label* if_exception, TVariable<Object>* var_exception);
void SetForwardingHandlerIfTrue(Node* context, Node* condition,
const NodeGenerator& object);
......
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