Changeset 278390 in webkit
- Timestamp:
- Jun 2, 2021, 6:07:45 PM (5 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
b3/B3MoveConstants.cpp (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r278381 r278390 1 2021-06-02 Robin Morisset <rmorisset@apple.com> 2 3 B3MoveConstants should filter directly on Values, and only create ValueKeys when useful 4 https://bugs.webkit.org/show_bug.cgi?id=226420 5 6 Reviewed by Phil Pizlo. 7 8 I did a few runs of JetStream2 to measure results, the time spent in B3MoveConstants goes from 160-180ms to 100-110ms. 9 The total time spent in B3+Air is in the 6 to 8s range, so this is approximately a 1% speedup. 10 11 * b3/B3MoveConstants.cpp: 12 1 13 2021-06-02 Robin Morisset <rmorisset@apple.com> 2 14 -
trunk/Source/JavaScriptCore/b3/B3MoveConstants.cpp
r261755 r278390 52 52 { 53 53 hoistConstants( 54 [&] (const Value Key& key) -> bool {55 return key.opcode() == ConstFloat || key.opcode() == ConstDouble;54 [&] (const Value* value) -> bool { 55 return value->opcode() == ConstFloat || value->opcode() == ConstDouble; 56 56 }); 57 57 … … 59 59 60 60 hoistConstants( 61 [&] (const Value Key& key) -> bool {62 return key.opcode() == Const32 || key.opcode() == Const64 || key.opcode() == ArgumentReg;61 [&] (const Value* value) -> bool { 62 return value->opcode() == Const32 || value->opcode() == Const64 || value->opcode() == ArgumentReg; 63 63 }); 64 64 } … … 76 76 for (Value* value : *block) { 77 77 for (Value*& child : value->children()) { 78 if (!filter(child)) 79 continue; 80 78 81 ValueKey key = child->key(); 79 if (!filter(key))80 continue;81 82 82 auto result = valueForConstant.add(key, child); 83 83 if (result.isNewEntry) { … … 116 116 for (BasicBlock* block : m_proc) { 117 117 for (Value*& value : *block) { 118 if (!filter(value)) 119 continue; 120 118 121 ValueKey key = value->key(); 119 if (!filter(key))120 continue;121 122 122 if (valueForConstant.get(key) == value) 123 123 value = m_proc.add<Value>(Nop, value->origin()); … … 154 154 // haven't inserted it yet. This inserts the constant if necessary. 155 155 auto materialize = [&] (Value* child) { 156 ValueKey key = child->key(); 157 if (!filter(key)) 156 if (!filter(child)) 158 157 return; 159 158 160 159 // If we encounter a fast constant, then it must be canonical, since we already 161 160 // got rid of the non-canonical ones. 162 ASSERT(valueForConstant.get( key) == child);161 ASSERT(valueForConstant.get(child->key()) == child); 163 162 164 163 if (child->owner != block) { … … 176 175 if (MemoryValue* memoryValue = value->as<MemoryValue>()) { 177 176 Value* pointer = memoryValue->lastChild(); 178 if (pointer->hasIntPtr() && filter(pointer ->key())) {177 if (pointer->hasIntPtr() && filter(pointer)) { 179 178 auto desiredOffset = [&] (Value* otherPointer) -> intptr_t { 180 179 // We would turn this: … … 214 213 case Sub: { 215 214 Value* addend = value->child(1); 216 if (!addend->hasInt() || !filter(addend ->key()))215 if (!addend->hasInt() || !filter(addend)) 217 216 break; 218 217 int64_t addendConst = addend->asInt(); … … 262 261 { 263 262 for (Value* value : m_proc.values()) { 263 if (!goesInTable(value)) 264 continue; 264 265 ValueKey key = value->key(); 265 if (goesInTable(key)) 266 m_constTable.add(key, m_constTable.size()); 266 m_constTable.add(key, m_constTable.size()); 267 267 } 268 268 … … 283 283 284 284 Value*& child = value->child(childIndex); 285 if (!goesInTable(child)) 286 continue; 287 285 288 ValueKey key = child->key(); 286 if (!goesInTable(key))287 continue;288 289 289 child = m_insertionSet.insertValue( 290 290 valueIndex, key.materialize(m_proc, value->origin())); … … 299 299 for (unsigned valueIndex = 0; valueIndex < block->size(); ++valueIndex) { 300 300 Value* value = block->at(valueIndex); 301 if (!goesInTable(value)) 302 continue; 303 if (offLimits.contains(value)) 304 continue; 305 301 306 ValueKey key = value->key(); 302 if (!goesInTable(key))303 continue;304 if (offLimits.contains(value))305 continue;306 307 307 auto offset = sizeof(int64_t) * m_constTable.get(key); 308 308 if (!isRepresentableAs<Value::OffsetType>(offset)) … … 322 322 } 323 323 324 bool goesInTable(const ValueKey& key) 325 { 326 return (key.opcode() == ConstDouble && key != doubleZero()) 327 || (key.opcode() == ConstFloat && key != floatZero()); 328 } 329 330 static ValueKey doubleZero() 331 { 332 return ValueKey(ConstDouble, Double, 0.0); 333 } 334 335 static ValueKey floatZero() 336 { 337 return ValueKey(ConstFloat, Float, 0.0); 324 bool goesInTable(const Value* value) 325 { 326 switch (value->opcode()) { 327 case ConstDouble: { 328 double doubleZero = 0.0; 329 return bitwise_cast<uint64_t>(value->asDouble()) != bitwise_cast<uint64_t>(doubleZero); 330 } 331 case ConstFloat: { 332 float floatZero = 0.0; 333 return bitwise_cast<uint32_t>(value->asFloat()) != bitwise_cast<uint32_t>(floatZero); 334 } 335 default: 336 break; 337 } 338 return false; 338 339 } 339 340
Note:
See TracChangeset
for help on using the changeset viewer.