Changeset 222382 in webkit for trunk/Source/JavaScriptCore
- Timestamp:
- Sep 22, 2017, 3:25:58 AM (8 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r222380 r222382 1 2017-09-22 Commit Queue <[email protected]> 2 3 Unreviewed, rolling out r222380. 4 https://bugs.webkit.org/show_bug.cgi?id=177352 5 6 Octane/box2d shows 8% regression (Requested by yusukesuzuki on 7 #webkit). 8 9 Reverted changeset: 10 11 "[DFG][FTL] Profile array vector length for array allocation" 12 https://bugs.webkit.org/show_bug.cgi?id=177051 13 http://trac.webkit.org/changeset/222380 14 1 15 2017-09-21 Yusuke Suzuki <[email protected]> 2 16 -
trunk/Source/JavaScriptCore/bytecode/ArrayAllocationProfile.cpp
r222380 r222382 31 31 namespace JSC { 32 32 33 void ArrayAllocationProfile::update Profile()33 void ArrayAllocationProfile::updateIndexingType() 34 34 { 35 35 // This is awkwardly racy but totally sound even when executed concurrently. The … … 50 50 if (!lastArray) 51 51 return; 52 if (LIKELY(Options::useArrayAllocationProfiling())) {52 if (LIKELY(Options::useArrayAllocationProfiling())) 53 53 m_currentIndexingType = leastUpperBoundOfIndexingTypes(m_currentIndexingType, lastArray->indexingType()); 54 m_largestSeenVectorLength = std::min(std::max(m_largestSeenVectorLength, lastArray->getVectorLength()), BASE_CONTIGUOUS_VECTOR_LEN_MAX); 55 } 56 m_lastArray = nullptr; 54 m_lastArray = 0; 57 55 } 58 56 -
trunk/Source/JavaScriptCore/bytecode/ArrayAllocationProfile.h
r222380 r222382 33 33 class ArrayAllocationProfile { 34 34 public: 35 ArrayAllocationProfile() 36 : m_currentIndexingType(ArrayWithUndecided) 37 , m_lastArray(0) 38 { 39 } 40 35 41 IndexingType selectIndexingType() 36 42 { 37 43 JSArray* lastArray = m_lastArray; 38 44 if (lastArray && UNLIKELY(lastArray->indexingType() != m_currentIndexingType)) 39 update Profile();45 updateIndexingType(); 40 46 return m_currentIndexingType; 41 }42 43 // vector length hint becomes [0, BASE_CONTIGUOUS_VECTOR_LEN_MAX].44 unsigned vectorLengthHint()45 {46 JSArray* lastArray = m_lastArray;47 if (lastArray && (m_largestSeenVectorLength != BASE_CONTIGUOUS_VECTOR_LEN_MAX) && UNLIKELY(lastArray->getVectorLength() > m_largestSeenVectorLength))48 updateProfile();49 return m_largestSeenVectorLength;50 47 } 51 48 … … 56 53 } 57 54 58 JS_EXPORT_PRIVATE void update Profile();55 JS_EXPORT_PRIVATE void updateIndexingType(); 59 56 60 57 static IndexingType selectIndexingTypeFor(ArrayAllocationProfile* profile) … … 74 71 private: 75 72 76 IndexingType m_currentIndexingType { ArrayWithUndecided }; 77 unsigned m_largestSeenVectorLength { 0 }; 78 JSArray* m_lastArray { nullptr }; 73 IndexingType m_currentIndexingType; 74 JSArray* m_lastArray; 79 75 }; 80 76 -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp
r222380 r222382 2569 2569 // Don't count these either, for similar reasons. 2570 2570 for (unsigned i = m_arrayAllocationProfiles.size(); i--;) 2571 m_arrayAllocationProfiles[i].update Profile();2571 m_arrayAllocationProfiles[i].updateIndexingType(); 2572 2572 } 2573 2573 -
trunk/Source/JavaScriptCore/dfg/DFGByteCodeParser.cpp
r222380 r222382 4400 4400 data.numConstants = numConstants; 4401 4401 data.indexingType = profile->selectIndexingType(); 4402 data.vectorLengthHint = std::max<unsigned>(profile->vectorLengthHint(), numConstants);4403 4402 4404 4403 // If this statement has never executed, we'll have the wrong indexing type in the profile. … … 4410 4409 } 4411 4410 4412 m_graph.m_newArrayBufferData.append( WTFMove(data));4411 m_graph.m_newArrayBufferData.append(data); 4413 4412 set(VirtualRegister(currentInstruction[1].u.operand), addToGraph(NewArrayBuffer, OpInfo(&m_graph.m_newArrayBufferData.last()))); 4414 4413 NEXT_OPCODE(op_new_array_buffer); -
trunk/Source/JavaScriptCore/dfg/DFGGraph.cpp
r222380 r222382 322 322 out.print(anotherComma, pointerDumpInContext(freeze(m_codeBlock->constantBuffer(node->startConstant())[i]), context)); 323 323 out.print("]"); 324 out.print(comma, "vectorLengthHint = ", node->vectorLengthHint());325 324 } 326 325 if (node->hasLazyJSValue()) -
trunk/Source/JavaScriptCore/dfg/DFGNode.h
r222380 r222382 100 100 unsigned startConstant; 101 101 unsigned numConstants; 102 unsigned vectorLengthHint;103 102 IndexingType indexingType; 104 103 }; … … 1116 1115 { 1117 1116 return newArrayBufferData()->numConstants; 1118 }1119 1120 unsigned vectorLengthHint()1121 {1122 return newArrayBufferData()->vectorLengthHint;1123 1117 } 1124 1118 -
trunk/Source/JavaScriptCore/dfg/DFGOperations.cpp
r222380 r222382 1312 1312 } 1313 1313 1314 char* JIT_OPERATION operationNewArrayWithSizeAndHint(ExecState* exec, Structure* arrayStructure, int32_t size, int32_t vectorLengthHint, Butterfly* butterfly)1315 {1316 VM& vm = exec->vm();1317 NativeCallFrameTracer tracer(&vm, exec);1318 auto scope = DECLARE_THROW_SCOPE(vm);1319 1320 if (UNLIKELY(size < 0))1321 return bitwise_cast<char*>(throwException(exec, scope, createRangeError(exec, ASCIILiteral("Array size is not a small enough positive integer."))));1322 1323 JSArray* result;1324 if (butterfly)1325 result = JSArray::createWithButterfly(vm, nullptr, arrayStructure, butterfly);1326 else {1327 result = JSArray::tryCreate(vm, arrayStructure, size, vectorLengthHint);1328 ASSERT(result);1329 }1330 return bitwise_cast<char*>(result);1331 }1332 1333 1314 char* JIT_OPERATION operationNewArrayBuffer(ExecState* exec, Structure* arrayStructure, size_t start, size_t size) 1334 1315 { -
trunk/Source/JavaScriptCore/dfg/DFGOperations.h
r222380 r222382 82 82 char* JIT_OPERATION operationNewEmptyArray(ExecState*, Structure*) WTF_INTERNAL; 83 83 char* JIT_OPERATION operationNewArrayWithSize(ExecState*, Structure*, int32_t, Butterfly*) WTF_INTERNAL; 84 char* JIT_OPERATION operationNewArrayWithSizeAndHint(ExecState*, Structure*, int32_t, int32_t, Butterfly*) WTF_INTERNAL;85 84 char* JIT_OPERATION operationNewInt8ArrayWithSize(ExecState*, Structure*, int32_t, char*) WTF_INTERNAL; 86 85 char* JIT_OPERATION operationNewInt8ArrayWithOneArgument(ExecState*, Structure*, EncodedJSValue) WTF_INTERNAL; -
trunk/Source/JavaScriptCore/dfg/DFGSpeculativeJIT64.cpp
r222380 r222382 4239 4239 if (!globalObject->isHavingABadTime() && !hasAnyArrayStorage(indexingType)) { 4240 4240 unsigned numElements = node->numConstants(); 4241 unsigned vectorLengthHint = node->vectorLengthHint();4242 ASSERT(vectorLengthHint >= numElements);4243 4241 4244 4242 GPRTemporary result(this); … … 4248 4246 GPRReg storageGPR = storage.gpr(); 4249 4247 4250 emitAllocateRawObject(resultGPR, m_jit.graph().registerStructure(globalObject->arrayStructureForIndexingTypeDuringAllocation(indexingType)), storageGPR, numElements, vectorLengthHint);4248 emitAllocateRawObject(resultGPR, m_jit.graph().registerStructure(globalObject->arrayStructureForIndexingTypeDuringAllocation(indexingType)), storageGPR, numElements, numElements); 4251 4249 4252 4250 DFG_ASSERT(m_jit.graph(), node, indexingType & IsArray); -
trunk/Source/JavaScriptCore/ftl/FTLLowerDFGToB3.cpp
r222380 r222382 4190 4190 weakStructure(m_graph.registerStructure(globalObject->arrayStructureForIndexingTypeDuringAllocation(ArrayWithContiguous))), 4191 4191 weakStructure(m_graph.registerStructure(globalObject->arrayStructureForIndexingTypeDuringAllocation(ArrayWithDouble))))); 4192 arrayResult = allocateJSArray(resultLength, resultLength,structure, indexingType, false, false);4192 arrayResult = allocateJSArray(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 unsigned vectorLengthHint = m_node->vectorLengthHint(); 5118 5119 ASSERT(vectorLengthHint >= numElements); 5117 5120 5118 ArrayValues arrayValues = 5121 allocateUninitializedContiguousJSArray( numElements, vectorLengthHint, structure);5119 allocateUninitializedContiguousJSArray(m_out.constInt32(numElements), structure); 5122 5120 5123 5121 JSValue* data = codeBlock()->constantBuffer(m_node->startConstant()); … … 5158 5156 setJSValue( 5159 5157 allocateJSArray( 5160 publicLength, publicLength,weakPointer(globalObject->arrayStructureForIndexingTypeDuringAllocation(indexingType)), m_out.constInt32(indexingType)).array);5158 publicLength, weakPointer(globalObject->arrayStructureForIndexingTypeDuringAllocation(indexingType)), m_out.constInt32(indexingType)).array); 5161 5159 mutatorFence(); 5162 5160 return; … … 11444 11442 }; 11445 11443 11446 ArrayValues allocateJSArray(LValue publicLength, LValue vectorLength, LValuestructure, LValue indexingType, bool shouldInitializeElements = true, bool shouldLargeArraySizeCreateArrayStorage = true)11444 ArrayValues allocateJSArray(LValue publicLength, LValue structure, LValue indexingType, bool shouldInitializeElements = true, bool shouldLargeArraySizeCreateArrayStorage = true) 11447 11445 { 11448 11446 JSGlobalObject* globalObject = m_graph.globalObjectFor(m_node->origin.semantic); … … 11463 11461 11464 11462 LBasicBlock lastNext = m_out.insertNewBlocksBefore(fastCase); 11465 11466 if (vectorLength->hasInt32() && structure->hasIntPtr()) {11467 unsigned vectorLengthConst = static_cast<unsigned>(vectorLength->asInt32());11468 if (vectorLengthConst <= MAX_STORAGE_VECTOR_LENGTH) {11469 vectorLength = m_out.constInt32(11470 Butterfly::optimalContiguousVectorLength(11471 bitwise_cast<Structure*>(structure->asIntPtr())->outOfLineCapacity(), vectorLengthConst));11472 }11473 } else {11474 // We don't compute the optimal vector length for new Array(blah) where blah is not11475 // statically known, since the compute effort of doing it here is probably not worth it.11476 }11477 11463 11478 11464 ValueFromBlock noButterfly = m_out.anchor(m_out.intPtrZero); … … 11487 11473 11488 11474 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 not 11488 // statically known, since the compute effort of doing it here is probably not worth it. 11489 vectorLength = publicLength; 11490 } 11489 11491 11490 11492 LValue payloadSize = … … 11532 11534 [=, &vm] (const Vector<Location>& locations) -> RefPtr<LazySlowPath::Generator> { 11533 11535 return createLazyCallGenerator(vm, 11534 operationNewArrayWithSize AndHint, locations[0].directGPR(),11535 locations[1].directGPR(), locations[2].directGPR(), locations[3].directGPR() , locations[4].directGPR());11536 operationNewArrayWithSize, locations[0].directGPR(), 11537 locations[1].directGPR(), locations[2].directGPR(), locations[3].directGPR()); 11536 11538 }, 11537 structureValue, publicLength, vectorLength,butterflyValue);11539 structureValue, publicLength, butterflyValue); 11538 11540 ValueFromBlock slowResult = m_out.anchor(slowResultValue); 11539 11541 ValueFromBlock slowButterfly = m_out.anchor( … … 11547 11549 } 11548 11550 11549 ArrayValues allocateUninitializedContiguousJSArray Internal(LValue publicLength, LValue vectorLength, RegisteredStructure structure)11551 ArrayValues allocateUninitializedContiguousJSArray(LValue publicLength, RegisteredStructure structure) 11550 11552 { 11551 11553 bool shouldInitializeElements = false; 11552 11554 bool shouldLargeArraySizeCreateArrayStorage = false; 11553 11555 return allocateJSArray( 11554 publicLength, vectorLength,weakStructure(structure), m_out.constInt32(structure->indexingType()), shouldInitializeElements,11556 publicLength, weakStructure(structure), m_out.constInt32(structure->indexingType()), shouldInitializeElements, 11555 11557 shouldLargeArraySizeCreateArrayStorage); 11556 }11557 11558 ArrayValues allocateUninitializedContiguousJSArray(LValue publicLength, RegisteredStructure structure)11559 {11560 return allocateUninitializedContiguousJSArrayInternal(publicLength, publicLength, structure);11561 }11562 11563 ArrayValues allocateUninitializedContiguousJSArray(unsigned publicLength, unsigned vectorLength, RegisteredStructure structure)11564 {11565 ASSERT(vectorLength >= publicLength);11566 return allocateUninitializedContiguousJSArrayInternal(m_out.constInt32(publicLength), m_out.constInt32(vectorLength), structure);11567 11558 } 11568 11559 -
trunk/Source/JavaScriptCore/runtime/ArrayConventions.h
r222380 r222382 78 78 #define BASE_CONTIGUOUS_VECTOR_LEN 3U 79 79 #define BASE_CONTIGUOUS_VECTOR_LEN_EMPTY 5U 80 #define BASE_CONTIGUOUS_VECTOR_LEN_MIN 3U81 #define BASE_CONTIGUOUS_VECTOR_LEN_MAX 25U82 80 #define BASE_ARRAY_STORAGE_VECTOR_LEN 4U 83 81 -
trunk/Source/JavaScriptCore/runtime/JSArray.h
r222380 r222382 55 55 public: 56 56 static JSArray* tryCreate(VM&, Structure*, unsigned initialLength = 0); 57 static JSArray* tryCreate(VM&, Structure*, unsigned initialLength, unsigned vectorLengthHint);58 57 static JSArray* create(VM&, Structure*, unsigned initialLength = 0); 59 58 static JSArray* createWithButterfly(VM&, GCDeferralContext*, Structure*, Butterfly*); … … 217 216 VM&, JSCell* intendedOwner, unsigned initialLength); 218 217 219 inline JSArray* JSArray::tryCreate(VM& vm, Structure* structure, unsigned initialLength, unsigned vectorLengthHint) 220 { 221 ASSERT(vectorLengthHint >= initialLength); 218 inline JSArray* JSArray::tryCreate(VM& vm, Structure* structure, unsigned initialLength) 219 { 222 220 unsigned outOfLineStorage = structure->outOfLineCapacity(); 223 221 … … 231 229 || hasContiguous(indexingType)); 232 230 233 if (UNLIKELY( vectorLengthHint> MAX_STORAGE_VECTOR_LENGTH))231 if (UNLIKELY(initialLength > MAX_STORAGE_VECTOR_LENGTH)) 234 232 return nullptr; 235 233 236 unsigned vectorLength = Butterfly::optimalContiguousVectorLength(structure, vectorLengthHint);234 unsigned vectorLength = Butterfly::optimalContiguousVectorLength(structure, initialLength); 237 235 void* temp = vm.jsValueGigacageAuxiliarySpace.tryAllocate(nullptr, Butterfly::totalSize(0, outOfLineStorage, true, vectorLength * sizeof(EncodedJSValue))); 238 236 if (!temp) … … 259 257 } 260 258 261 inline JSArray* JSArray::tryCreate(VM& vm, Structure* structure, unsigned initialLength)262 {263 return tryCreate(vm, structure, initialLength, initialLength);264 }265 266 259 inline JSArray* JSArray::create(VM& vm, Structure* structure, unsigned initialLength) 267 260 {
Note:
See TracChangeset
for help on using the changeset viewer.