Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(464)

Unified Diff: src/hydrogen.cc

Issue 1144393003: Also allocate small typed arrays on heap when initialized from an array-like (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/hydrogen.h ('k') | src/layout-descriptor-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index 809640fb437aa303c39e0d51e087e59b3e210b29..ee051aa24a87c2d9aae5d9b0bb3636fc592fdc77 100644
--- a/src/hydrogen.cc
+++ b/src/hydrogen.cc
@@ -9875,8 +9875,8 @@ HValue* HOptimizedGraphBuilder::BuildAllocateExternalElements(
HValue* HOptimizedGraphBuilder::BuildAllocateFixedTypedArray(
ExternalArrayType array_type, size_t element_size,
- ElementsKind fixed_elements_kind,
- HValue* byte_length, HValue* length) {
+ ElementsKind fixed_elements_kind, HValue* byte_length, HValue* length,
+ bool initialize) {
STATIC_ASSERT(
(FixedTypedArrayBase::kHeaderSize & kObjectAlignmentMask) == 0);
HValue* total_size;
@@ -9915,7 +9915,7 @@ HValue* HOptimizedGraphBuilder::BuildAllocateFixedTypedArray(
HValue* filler = Add<HConstant>(static_cast<int32_t>(0));
- {
+ if (initialize) {
LoopBuilder builder(this, context(), LoopBuilder::kPostIncrement);
HValue* key = builder.BeginBody(
@@ -9938,7 +9938,8 @@ void HOptimizedGraphBuilder::GenerateTypedArrayInitialize(
static const int kBufferArg = 2;
static const int kByteOffsetArg = 3;
static const int kByteLengthArg = 4;
- static const int kArgsLength = 5;
+ static const int kInitializeArg = 5;
+ static const int kArgsLength = 6;
DCHECK(arguments->length() == kArgsLength);
@@ -9987,6 +9988,11 @@ void HOptimizedGraphBuilder::GenerateTypedArrayInitialize(
CHECK_ALIVE(VisitForValue(arguments->at(kByteLengthArg)));
HValue* byte_length = Pop();
+ CHECK(arguments->at(kInitializeArg)->IsLiteral());
+ bool initialize = static_cast<Literal*>(arguments->at(kInitializeArg))
+ ->value()
+ ->BooleanValue();
+
NoObservableSideEffectsScope scope(this);
IfBuilder byte_offset_smi(this);
@@ -10034,9 +10040,9 @@ void HOptimizedGraphBuilder::GenerateTypedArrayInitialize(
AddStoreMapConstant(obj, obj_map);
} else {
DCHECK(is_zero_byte_offset);
- elements = BuildAllocateFixedTypedArray(
- array_type, element_size, fixed_elements_kind,
- byte_length, length);
+ elements = BuildAllocateFixedTypedArray(array_type, element_size,
+ fixed_elements_kind, byte_length,
+ length, initialize);
}
Add<HStoreNamedField>(
obj, HObjectAccess::ForElementsPointer(), elements);
@@ -10050,6 +10056,7 @@ void HOptimizedGraphBuilder::GenerateTypedArrayInitialize(
Push(buffer);
Push(byte_offset);
Push(byte_length);
+ CHECK_ALIVE(VisitForValue(arguments->at(kInitializeArg)));
PushArgumentsFromEnvironment(kArgsLength);
Add<HCallRuntime>(expr->name(), expr->function(), kArgsLength);
}
« no previous file with comments | « src/hydrogen.h ('k') | src/layout-descriptor-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698