Commit af177a0c authored by Simon Zünd's avatar Simon Zünd Committed by Commit Bot

[refactoring] Add types to CreateArrayIterator.

This CL also adds types to a user and three builtins that make use
of CreateArrayIterator.

R=petermarshall@chromium.org

Bug: v8:7570
Change-Id: I96b647a9a57e825db717b40ecec2340b0a3d367d
Reviewed-on: https://chromium-review.googlesource.com/1032779
Commit-Queue: Simon Zünd <szuend@google.com>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52904}
parent 285c62b0
...@@ -1531,7 +1531,7 @@ TF_BUILTIN(TypedArrayPrototypeToStringTag, TypedArrayBuiltinsAssembler) { ...@@ -1531,7 +1531,7 @@ TF_BUILTIN(TypedArrayPrototypeToStringTag, TypedArrayBuiltinsAssembler) {
} }
void TypedArrayBuiltinsAssembler::GenerateTypedArrayPrototypeIterationMethod( void TypedArrayBuiltinsAssembler::GenerateTypedArrayPrototypeIterationMethod(
Node* context, Node* receiver, const char* method_name, TNode<Context> context, TNode<Object> receiver, const char* method_name,
IterationKind kind) { IterationKind kind) {
Label throw_bad_receiver(this, Label::kDeferred); Label throw_bad_receiver(this, Label::kDeferred);
...@@ -1539,8 +1539,8 @@ void TypedArrayBuiltinsAssembler::GenerateTypedArrayPrototypeIterationMethod( ...@@ -1539,8 +1539,8 @@ void TypedArrayBuiltinsAssembler::GenerateTypedArrayPrototypeIterationMethod(
GotoIfNot(IsJSTypedArray(CAST(receiver)), &throw_bad_receiver); GotoIfNot(IsJSTypedArray(CAST(receiver)), &throw_bad_receiver);
// Check if the {receiver}'s JSArrayBuffer was neutered. // Check if the {receiver}'s JSArrayBuffer was neutered.
Node* receiver_buffer = TNode<JSArrayBuffer> receiver_buffer = LoadObjectField<JSArrayBuffer>(
LoadObjectField(receiver, JSTypedArray::kBufferOffset); CAST(receiver), JSTypedArray::kBufferOffset);
Label if_receiverisneutered(this, Label::kDeferred); Label if_receiverisneutered(this, Label::kDeferred);
GotoIf(IsDetachedBuffer(receiver_buffer), &if_receiverisneutered); GotoIf(IsDetachedBuffer(receiver_buffer), &if_receiverisneutered);
...@@ -1555,8 +1555,8 @@ void TypedArrayBuiltinsAssembler::GenerateTypedArrayPrototypeIterationMethod( ...@@ -1555,8 +1555,8 @@ void TypedArrayBuiltinsAssembler::GenerateTypedArrayPrototypeIterationMethod(
// ES #sec-%typedarray%.prototype.values // ES #sec-%typedarray%.prototype.values
TF_BUILTIN(TypedArrayPrototypeValues, TypedArrayBuiltinsAssembler) { TF_BUILTIN(TypedArrayPrototypeValues, TypedArrayBuiltinsAssembler) {
Node* context = Parameter(Descriptor::kContext); TNode<Context> context = CAST(Parameter(Descriptor::kContext));
Node* receiver = Parameter(Descriptor::kReceiver); TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
GenerateTypedArrayPrototypeIterationMethod(context, receiver, GenerateTypedArrayPrototypeIterationMethod(context, receiver,
"%TypedArray%.prototype.values()", "%TypedArray%.prototype.values()",
IterationKind::kValues); IterationKind::kValues);
...@@ -1564,8 +1564,8 @@ TF_BUILTIN(TypedArrayPrototypeValues, TypedArrayBuiltinsAssembler) { ...@@ -1564,8 +1564,8 @@ TF_BUILTIN(TypedArrayPrototypeValues, TypedArrayBuiltinsAssembler) {
// ES #sec-%typedarray%.prototype.entries // ES #sec-%typedarray%.prototype.entries
TF_BUILTIN(TypedArrayPrototypeEntries, TypedArrayBuiltinsAssembler) { TF_BUILTIN(TypedArrayPrototypeEntries, TypedArrayBuiltinsAssembler) {
Node* context = Parameter(Descriptor::kContext); TNode<Context> context = CAST(Parameter(Descriptor::kContext));
Node* receiver = Parameter(Descriptor::kReceiver); TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
GenerateTypedArrayPrototypeIterationMethod(context, receiver, GenerateTypedArrayPrototypeIterationMethod(context, receiver,
"%TypedArray%.prototype.entries()", "%TypedArray%.prototype.entries()",
IterationKind::kEntries); IterationKind::kEntries);
...@@ -1573,8 +1573,8 @@ TF_BUILTIN(TypedArrayPrototypeEntries, TypedArrayBuiltinsAssembler) { ...@@ -1573,8 +1573,8 @@ TF_BUILTIN(TypedArrayPrototypeEntries, TypedArrayBuiltinsAssembler) {
// ES #sec-%typedarray%.prototype.keys // ES #sec-%typedarray%.prototype.keys
TF_BUILTIN(TypedArrayPrototypeKeys, TypedArrayBuiltinsAssembler) { TF_BUILTIN(TypedArrayPrototypeKeys, TypedArrayBuiltinsAssembler) {
Node* context = Parameter(Descriptor::kContext); TNode<Context> context = CAST(Parameter(Descriptor::kContext));
Node* receiver = Parameter(Descriptor::kReceiver); TNode<Object> receiver = CAST(Parameter(Descriptor::kReceiver));
GenerateTypedArrayPrototypeIterationMethod( GenerateTypedArrayPrototypeIterationMethod(
context, receiver, "%TypedArray%.prototype.keys()", IterationKind::kKeys); context, receiver, "%TypedArray%.prototype.keys()", IterationKind::kKeys);
} }
......
...@@ -24,7 +24,8 @@ class TypedArrayBuiltinsAssembler : public CodeStubAssembler { ...@@ -24,7 +24,8 @@ class TypedArrayBuiltinsAssembler : public CodeStubAssembler {
void GenerateTypedArrayPrototypeGetter(Node* context, Node* receiver, void GenerateTypedArrayPrototypeGetter(Node* context, Node* receiver,
const char* method_name, const char* method_name,
int object_offset); int object_offset);
void GenerateTypedArrayPrototypeIterationMethod(Node* context, Node* receiver, void GenerateTypedArrayPrototypeIterationMethod(TNode<Context> context,
TNode<Object> receiver,
const char* method_name, const char* method_name,
IterationKind iteration_kind); IterationKind iteration_kind);
......
...@@ -11088,11 +11088,11 @@ Node* CodeStubAssembler::BitwiseOp(Node* left32, Node* right32, ...@@ -11088,11 +11088,11 @@ Node* CodeStubAssembler::BitwiseOp(Node* left32, Node* right32,
} }
// ES #sec-createarrayiterator // ES #sec-createarrayiterator
Node* CodeStubAssembler::CreateArrayIterator(Node* context, Node* object, TNode<JSArrayIterator> CodeStubAssembler::CreateArrayIterator(
IterationKind kind) { TNode<Context> context, TNode<Object> object, IterationKind kind) {
Node* native_context = LoadNativeContext(context); TNode<Context> native_context = LoadNativeContext(context);
Node* iterator_map = LoadContextElement( TNode<Map> iterator_map = CAST(LoadContextElement(
native_context, Context::INITIAL_ARRAY_ITERATOR_MAP_INDEX); native_context, Context::INITIAL_ARRAY_ITERATOR_MAP_INDEX));
Node* iterator = Allocate(JSArrayIterator::kSize); Node* iterator = Allocate(JSArrayIterator::kSize);
StoreMapNoWriteBarrier(iterator, iterator_map); StoreMapNoWriteBarrier(iterator, iterator_map);
StoreObjectFieldRoot(iterator, JSArrayIterator::kPropertiesOrHashOffset, StoreObjectFieldRoot(iterator, JSArrayIterator::kPropertiesOrHashOffset,
...@@ -11106,7 +11106,7 @@ Node* CodeStubAssembler::CreateArrayIterator(Node* context, Node* object, ...@@ -11106,7 +11106,7 @@ Node* CodeStubAssembler::CreateArrayIterator(Node* context, Node* object,
StoreObjectFieldNoWriteBarrier( StoreObjectFieldNoWriteBarrier(
iterator, JSArrayIterator::kKindOffset, iterator, JSArrayIterator::kKindOffset,
SmiConstant(Smi::FromInt(static_cast<int>(kind)))); SmiConstant(Smi::FromInt(static_cast<int>(kind))));
return iterator; return CAST(iterator);
} }
Node* CodeStubAssembler::AllocateJSIteratorResult(Node* context, Node* value, Node* CodeStubAssembler::AllocateJSIteratorResult(Node* context, Node* value,
......
...@@ -1048,7 +1048,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler { ...@@ -1048,7 +1048,9 @@ class V8_EXPORT_PRIVATE CodeStubAssembler : public compiler::CodeAssembler {
AllocationFlags flags = kNone); AllocationFlags flags = kNone);
// Perform CreateArrayIterator (ES #sec-createarrayiterator). // Perform CreateArrayIterator (ES #sec-createarrayiterator).
Node* CreateArrayIterator(Node* context, Node* object, IterationKind mode); TNode<JSArrayIterator> CreateArrayIterator(TNode<Context> context,
TNode<Object> object,
IterationKind mode);
Node* AllocateJSIteratorResult(Node* context, Node* value, Node* done); Node* AllocateJSIteratorResult(Node* context, Node* value, Node* done);
Node* AllocateJSIteratorResultForEntry(Node* context, Node* key, Node* value); Node* AllocateJSIteratorResultForEntry(Node* context, Node* key, Node* value);
......
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