Commit cb672f4d authored by Michael Achenbach's avatar Michael Achenbach Committed by Commit Bot

Revert "[builtins] Delete unused TypedArrayInitialize intrinsic."

This reverts commit 5c200fa0.

Reason for revert: Breaks compile:
https://build.chromium.org/p/client.v8/builders/V8%20Linux%20-%20builder/builds/23538

Maybe conflicts with a change that just landed.

Original change's description:
> [builtins] Delete unused TypedArrayInitialize intrinsic.
> 
> This CL only deletes code. We dont call these anymore, so they are safe
> to remove.
> 
> BUG=v8:5977
> 
> Change-Id: I59889c3dbb9c2610f3502d582b6c307b1fb4f63b
> Reviewed-on: https://chromium-review.googlesource.com/448517
> Commit-Queue: Peter Marshall <petermarshall@chromium.org>
> Reviewed-by: Benedikt Meurer <bmeurer@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#43543}

TBR=cbruni@chromium.org,petermarshall@chromium.org,bmeurer@chromium.org,v8-reviews@googlegroups.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=v8:5977

Change-Id: Iba1611f4c93d105a4163338b59bda42ea7937443
Reviewed-on: https://chromium-review.googlesource.com/448562Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#43544}
parent 5c200fa0
This diff is collapsed.
......@@ -2170,6 +2170,7 @@ class HOptimizedGraphBuilder : public HGraphBuilder,
F(SubString) \
F(DebugIsActive) \
/* Typed Arrays */ \
F(TypedArrayInitialize) \
F(MaxSmi) \
F(TypedArrayMaxSizeInHeap) \
F(ArrayBufferViewGetByteLength) \
......
......@@ -61,6 +61,84 @@ void Runtime::ArrayIdToTypeAndSize(int arrayId, ExternalArrayType* array_type,
}
}
RUNTIME_FUNCTION(Runtime_TypedArrayInitialize) {
HandleScope scope(isolate);
DCHECK_EQ(6, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0);
CONVERT_SMI_ARG_CHECKED(arrayId, 1);
CONVERT_ARG_HANDLE_CHECKED(Object, maybe_buffer, 2);
CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_offset_object, 3);
CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_length_object, 4);
CONVERT_BOOLEAN_ARG_CHECKED(initialize, 5);
CHECK(arrayId >= Runtime::ARRAY_ID_FIRST &&
arrayId <= Runtime::ARRAY_ID_LAST);
ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization.
size_t element_size = 1; // Bogus initialization.
ElementsKind fixed_elements_kind = INT8_ELEMENTS; // Bogus initialization.
Runtime::ArrayIdToTypeAndSize(arrayId, &array_type, &fixed_elements_kind,
&element_size);
CHECK(holder->map()->elements_kind() == fixed_elements_kind);
size_t byte_offset = 0;
size_t byte_length = 0;
CHECK(TryNumberToSize(*byte_offset_object, &byte_offset));
CHECK(TryNumberToSize(*byte_length_object, &byte_length));
if (maybe_buffer->IsJSArrayBuffer()) {
Handle<JSArrayBuffer> buffer = Handle<JSArrayBuffer>::cast(maybe_buffer);
size_t array_buffer_byte_length = NumberToSize(buffer->byte_length());
CHECK(byte_offset <= array_buffer_byte_length);
CHECK(array_buffer_byte_length - byte_offset >= byte_length);
} else {
CHECK(maybe_buffer->IsNull(isolate));
}
CHECK(byte_length % element_size == 0);
size_t length = byte_length / element_size;
if (length > static_cast<unsigned>(Smi::kMaxValue)) {
THROW_NEW_ERROR_RETURN_FAILURE(
isolate, NewRangeError(MessageTemplate::kInvalidTypedArrayLength));
}
// All checks are done, now we can modify objects.
DCHECK_EQ(v8::ArrayBufferView::kInternalFieldCount,
holder->GetInternalFieldCount());
for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) {
holder->SetInternalField(i, Smi::kZero);
}
Handle<Object> length_obj = isolate->factory()->NewNumberFromSize(length);
holder->set_length(*length_obj);
holder->set_byte_offset(*byte_offset_object);
holder->set_byte_length(*byte_length_object);
if (!maybe_buffer->IsNull(isolate)) {
Handle<JSArrayBuffer> buffer = Handle<JSArrayBuffer>::cast(maybe_buffer);
holder->set_buffer(*buffer);
Handle<FixedTypedArrayBase> elements =
isolate->factory()->NewFixedTypedArrayWithExternalPointer(
static_cast<int>(length), array_type,
static_cast<uint8_t*>(buffer->backing_store()) + byte_offset);
holder->set_elements(*elements);
} else {
Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer();
JSArrayBuffer::Setup(buffer, isolate, true, NULL, byte_length,
SharedFlag::kNotShared);
holder->set_buffer(*buffer);
Handle<FixedTypedArrayBase> elements =
isolate->factory()->NewFixedTypedArray(static_cast<int>(length),
array_type, initialize);
holder->set_elements(*elements);
}
return isolate->heap()->undefined_value();
}
// Initializes a typed array from an array-like object.
// If an array-like object happens to be a typed array of the same type,
// initializes backing store using memove.
......
......@@ -615,6 +615,7 @@ namespace internal {
#define FOR_EACH_INTRINSIC_TYPEDARRAY(F) \
F(ArrayBufferGetByteLength, 1, 1) \
F(ArrayBufferNeuter, 1, 1) \
F(TypedArrayInitialize, 6, 1) \
F(TypedArrayInitializeFromArrayLike, 4, 1) \
F(ArrayBufferViewGetByteLength, 1, 1) \
F(ArrayBufferViewGetByteOffset, 1, 1) \
......
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