Changeset 222384 in webkit for trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
- Timestamp:
- Sep 22, 2017, 5:19:54 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
r222382 r222384 4190 4190 weakStructure(m_graph.registerStructure(globalObject->arrayStructureForIndexingTypeDuringAllocation(ArrayWithContiguous))), 4191 4191 weakStructure(m_graph.registerStructure(globalObject->arrayStructureForIndexingTypeDuringAllocation(ArrayWithDouble))))); 4192 arrayResult = allocateJSArray(resultLength, structure, indexingType, false, false);4192 arrayResult = allocateJSArray(resultLength, resultLength, structure, indexingType, false, false); 4193 4193 } 4194 4194 … … 5115 5115 if (!globalObject->isHavingABadTime() && !hasAnyArrayStorage(m_node->indexingType())) { 5116 5116 unsigned numElements = m_node->numConstants(); 5117 5117 unsigned vectorLengthHint = m_node->vectorLengthHint(); 5118 5119 ASSERT(vectorLengthHint >= numElements); 5118 5120 ArrayValues arrayValues = 5119 allocateUninitializedContiguousJSArray( m_out.constInt32(numElements), structure);5121 allocateUninitializedContiguousJSArray(numElements, vectorLengthHint, structure); 5120 5122 5121 5123 JSValue* data = codeBlock()->constantBuffer(m_node->startConstant()); … … 5156 5158 setJSValue( 5157 5159 allocateJSArray( 5158 publicLength, weakPointer(globalObject->arrayStructureForIndexingTypeDuringAllocation(indexingType)), m_out.constInt32(indexingType)).array);5160 publicLength, publicLength, weakPointer(globalObject->arrayStructureForIndexingTypeDuringAllocation(indexingType)), m_out.constInt32(indexingType)).array); 5159 5161 mutatorFence(); 5160 5162 return; … … 11442 11444 }; 11443 11445 11444 ArrayValues allocateJSArray(LValue publicLength, LValue structure, LValue indexingType, bool shouldInitializeElements = true, bool shouldLargeArraySizeCreateArrayStorage = true)11446 ArrayValues allocateJSArray(LValue publicLength, LValue vectorLength, LValue structure, LValue indexingType, bool shouldInitializeElements = true, bool shouldLargeArraySizeCreateArrayStorage = true) 11445 11447 { 11446 11448 JSGlobalObject* globalObject = m_graph.globalObjectFor(m_node->origin.semantic); … … 11461 11463 11462 11464 LBasicBlock lastNext = m_out.insertNewBlocksBefore(fastCase); 11465 11466 std::optional<unsigned> staticVectorLength; 11467 std::optional<unsigned> staticVectorLengthFromPublicLength; 11468 if (structure->hasIntPtr()) { 11469 if (publicLength->hasInt32()) { 11470 unsigned publicLengthConst = static_cast<unsigned>(publicLength->asInt32()); 11471 if (publicLengthConst <= MAX_STORAGE_VECTOR_LENGTH) { 11472 publicLengthConst = Butterfly::optimalContiguousVectorLength( 11473 bitwise_cast<Structure*>(structure->asIntPtr())->outOfLineCapacity(), publicLengthConst); 11474 staticVectorLengthFromPublicLength = publicLengthConst; 11475 } 11476 11477 } 11478 if (vectorLength->hasInt32()) { 11479 unsigned vectorLengthConst = static_cast<unsigned>(vectorLength->asInt32()); 11480 if (vectorLengthConst <= MAX_STORAGE_VECTOR_LENGTH) { 11481 vectorLengthConst = Butterfly::optimalContiguousVectorLength( 11482 bitwise_cast<Structure*>(structure->asIntPtr())->outOfLineCapacity(), vectorLengthConst); 11483 vectorLength = m_out.constInt32(vectorLengthConst); 11484 staticVectorLength = vectorLengthConst; 11485 } 11486 } 11487 } else { 11488 // We don't compute the optimal vector length for new Array(blah) where blah is not 11489 // statically known, since the compute effort of doing it here is probably not worth it. 11490 } 11463 11491 11464 11492 ValueFromBlock noButterfly = m_out.anchor(m_out.intPtrZero); … … 11473 11501 11474 11502 m_out.appendTo(fastCase, largeCase); 11475 11476 LValue vectorLength = nullptr;11477 if (publicLength->hasInt32() && structure->hasIntPtr()) {11478 unsigned publicLengthConst = static_cast<unsigned>(publicLength->asInt32());11479 if (publicLengthConst <= MAX_STORAGE_VECTOR_LENGTH) {11480 vectorLength = m_out.constInt32(11481 Butterfly::optimalContiguousVectorLength(11482 bitwise_cast<Structure*>(structure->asIntPtr())->outOfLineCapacity(), publicLengthConst));11483 }11484 }11485 11486 if (!vectorLength) {11487 // We don't compute the optimal vector length for new Array(blah) where blah is not11488 // statically known, since the compute effort of doing it here is probably not worth it.11489 vectorLength = publicLength;11490 }11491 11503 11492 11504 LValue payloadSize = … … 11531 11543 11532 11544 VM& vm = this->vm(); 11533 LValue slowResultValue = lazySlowPath( 11534 [=, &vm] (const Vector<Location>& locations) -> RefPtr<LazySlowPath::Generator> { 11535 return createLazyCallGenerator(vm, 11536 operationNewArrayWithSize, locations[0].directGPR(), 11537 locations[1].directGPR(), locations[2].directGPR(), locations[3].directGPR()); 11538 }, 11539 structureValue, publicLength, butterflyValue); 11545 LValue slowResultValue = nullptr; 11546 if (vectorLength == publicLength 11547 || (staticVectorLengthFromPublicLength && staticVectorLength && staticVectorLength.value() == staticVectorLengthFromPublicLength.value())) { 11548 slowResultValue = lazySlowPath( 11549 [=, &vm] (const Vector<Location>& locations) -> RefPtr<LazySlowPath::Generator> { 11550 return createLazyCallGenerator(vm, 11551 operationNewArrayWithSize, locations[0].directGPR(), 11552 locations[1].directGPR(), locations[2].directGPR(), locations[3].directGPR()); 11553 }, 11554 structureValue, publicLength, butterflyValue); 11555 } else { 11556 slowResultValue = lazySlowPath( 11557 [=, &vm] (const Vector<Location>& locations) -> RefPtr<LazySlowPath::Generator> { 11558 return createLazyCallGenerator(vm, 11559 operationNewArrayWithSizeAndHint, locations[0].directGPR(), 11560 locations[1].directGPR(), locations[2].directGPR(), locations[3].directGPR(), locations[4].directGPR()); 11561 }, 11562 structureValue, publicLength, vectorLength, butterflyValue); 11563 } 11564 11540 11565 ValueFromBlock slowResult = m_out.anchor(slowResultValue); 11541 11566 ValueFromBlock slowButterfly = m_out.anchor( … … 11549 11574 } 11550 11575 11551 ArrayValues allocateUninitializedContiguousJSArray (LValue publicLength, RegisteredStructure structure)11576 ArrayValues allocateUninitializedContiguousJSArrayInternal(LValue publicLength, LValue vectorLength, RegisteredStructure structure) 11552 11577 { 11553 11578 bool shouldInitializeElements = false; 11554 11579 bool shouldLargeArraySizeCreateArrayStorage = false; 11555 11580 return allocateJSArray( 11556 publicLength, weakStructure(structure), m_out.constInt32(structure->indexingType()), shouldInitializeElements,11581 publicLength, vectorLength, weakStructure(structure), m_out.constInt32(structure->indexingType()), shouldInitializeElements, 11557 11582 shouldLargeArraySizeCreateArrayStorage); 11583 } 11584 11585 ArrayValues allocateUninitializedContiguousJSArray(LValue publicLength, RegisteredStructure structure) 11586 { 11587 return allocateUninitializedContiguousJSArrayInternal(publicLength, publicLength, structure); 11588 } 11589 11590 ArrayValues allocateUninitializedContiguousJSArray(unsigned publicLength, unsigned vectorLength, RegisteredStructure structure) 11591 { 11592 ASSERT(vectorLength >= publicLength); 11593 return allocateUninitializedContiguousJSArrayInternal(m_out.constInt32(publicLength), m_out.constInt32(vectorLength), structure); 11558 11594 } 11559 11595
Note:
See TracChangeset
for help on using the changeset viewer.