Commit 74e754a3 authored by peterwmwong's avatar peterwmwong Committed by Commit Bot

[typedarray] Fix perf of TA.set with different type

Removes the overhead of Zone allocating temporary space
that only slightly improved performance of the overlap
(less common) case.

Bug: chromium:808360
Change-Id: Ic92f20f15decb12b916ee23267debd9adc785ee0
Reviewed-on: https://chromium-review.googlesource.com/904462Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Commit-Queue: Peter Wong <peter.wm.wong@gmail.com>
Cr-Commit-Position: refs/heads/master@{#51119}
parent 9d43ee80
......@@ -12,7 +12,6 @@
#include "src/messages.h"
#include "src/objects-inl.h"
#include "src/utils.h"
#include "src/zone/zone.h"
// Each concrete ElementsAccessor can handle exactly one ElementsKind,
// several abstract ElementsAccessor classes are used to allow sharing
......@@ -3298,15 +3297,15 @@ class TypedElementsAccessor
std::memmove(dest_data + offset * element_size, source_data,
length * element_size);
} else {
Isolate* isolate = source->GetIsolate();
Zone zone(isolate->allocator(), ZONE_NAME);
std::unique_ptr<uint8_t[]> cloned_source_elements;
// If the typedarrays are overlapped, clone the source.
if (dest_data + dest_byte_length > source_data &&
source_data + source_byte_length > dest_data) {
uint8_t* temp_data = zone.NewArray<uint8_t>(source_byte_length);
std::memcpy(temp_data, source_data, source_byte_length);
source_data = temp_data;
cloned_source_elements.reset(new uint8_t[source_byte_length]);
std::memcpy(cloned_source_elements.get(), source_data,
source_byte_length);
source_data = cloned_source_elements.get();
}
switch (source->GetElementsKind()) {
......
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