Changeset 89954 in webkit
- Timestamp:
- Jun 28, 2011 1:21:37 PM (13 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r89946 r89954 1 2011-06-28 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Gavin Barraclough. 4 5 Make constant array optimisation less strict about what constitutes a constant 6 https://bugs.webkit.org/show_bug.cgi?id=63554 7 8 Now allow string constants in array literals to actually be considered constant, 9 and so avoid codegen in array literals with strings in them. 10 11 * bytecode/CodeBlock.h: 12 (JSC::CodeBlock::addConstantBuffer): 13 (JSC::CodeBlock::constantBuffer): 14 * bytecompiler/BytecodeGenerator.cpp: 15 (JSC::BytecodeGenerator::addConstantBuffer): 16 (JSC::BytecodeGenerator::addStringConstant): 17 (JSC::BytecodeGenerator::emitNewArray): 18 * bytecompiler/BytecodeGenerator.h: 19 * interpreter/Interpreter.cpp: 20 (JSC::Interpreter::privateExecute): 21 * jit/JITStubs.cpp: 22 (JSC::DEFINE_STUB_FUNCTION): 23 1 24 2011-06-28 Gavin Barraclough <barraclough@apple.com> 2 25 -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.h
r89885 r89954 478 478 RegExp* regexp(int index) const { ASSERT(m_rareData); return m_rareData->m_regexps[index].get(); } 479 479 480 unsigned add ImmediateBuffer(unsigned length)480 unsigned addConstantBuffer(unsigned length) 481 481 { 482 482 createRareDataIfNecessary(); 483 unsigned size = m_rareData->m_ immediateBuffers.size();484 m_rareData->m_ immediateBuffers.append(Vector<JSValue>(length));483 unsigned size = m_rareData->m_constantBuffers.size(); 484 m_rareData->m_constantBuffers.append(Vector<JSValue>(length)); 485 485 return size; 486 486 } 487 487 488 JSValue* immediateBuffer(unsigned index)488 JSValue* constantBuffer(unsigned index) 489 489 { 490 490 ASSERT(m_rareData); 491 return m_rareData->m_ immediateBuffers[index].data();491 return m_rareData->m_constantBuffers[index].data(); 492 492 } 493 493 … … 596 596 597 597 // Buffers used for large array literals 598 Vector<Vector<JSValue> > m_ immediateBuffers;598 Vector<Vector<JSValue> > m_constantBuffers; 599 599 600 600 // Jump Tables -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r89465 r89954 1509 1509 } 1510 1510 1511 unsigned BytecodeGenerator::addImmediateBuffer(unsigned length) 1512 { 1513 return m_codeBlock->addImmediateBuffer(length); 1511 unsigned BytecodeGenerator::addConstantBuffer(unsigned length) 1512 { 1513 return m_codeBlock->addConstantBuffer(length); 1514 } 1515 1516 JSString* BytecodeGenerator::addStringConstant(const Identifier& identifier) 1517 { 1518 JSString*& stringInMap = m_stringMap.add(identifier.impl(), 0).first->second; 1519 if (!stringInMap) { 1520 stringInMap = jsString(globalData(), identifier.ustring()); 1521 addConstantValue(stringInMap); 1522 } 1523 return stringInMap; 1514 1524 } 1515 1525 … … 1519 1529 unsigned checkLength = 0; 1520 1530 #endif 1521 bool had NonNumber= false;1531 bool hadVariableExpression = false; 1522 1532 if (length) { 1523 1533 for (ElementNode* n = elements; n; n = n->next()) { 1524 if (!n->value()->isNumber() ) {1525 had NonNumber= true;1534 if (!n->value()->isNumber() && !n->value()->isString()) { 1535 hadVariableExpression = true; 1526 1536 break; 1527 1537 } … … 1532 1542 #endif 1533 1543 } 1534 if (!had NonNumber) {1544 if (!hadVariableExpression) { 1535 1545 ASSERT(length == checkLength); 1536 unsigned immediateBufferIndex = addImmediateBuffer(length);1537 JSValue* immediateBuffer = m_codeBlock->immediateBuffer(immediateBufferIndex);1546 unsigned constantBufferIndex = addConstantBuffer(length); 1547 JSValue* constantBuffer = m_codeBlock->constantBuffer(constantBufferIndex); 1538 1548 unsigned index = 0; 1539 for (ElementNode* n = elements; index < length; n = n->next()) 1540 immediateBuffer[index++] = jsNumber(static_cast<NumberNode*>(n->value())->value()); 1549 for (ElementNode* n = elements; index < length; n = n->next()) { 1550 if (n->value()->isNumber()) 1551 constantBuffer[index++] = jsNumber(static_cast<NumberNode*>(n->value())->value()); 1552 else { 1553 ASSERT(n->value()->isString()); 1554 constantBuffer[index++] = addStringConstant(static_cast<StringNode*>(n->value())->value()); 1555 } 1556 } 1541 1557 emitOpcode(op_new_array_buffer); 1542 1558 instructions().append(dst->index()); 1543 instructions().append( immediateBufferIndex);1559 instructions().append(constantBufferIndex); 1544 1560 instructions().append(length); 1545 1561 return dst; -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
r89465 r89954 470 470 unsigned addRegExp(RegExp*); 471 471 472 unsigned add ImmediateBuffer(unsigned length);472 unsigned addConstantBuffer(unsigned length); 473 473 474 474 FunctionExecutable* makeFunction(ExecState* exec, FunctionBodyNode* body) … … 481 481 return FunctionExecutable::create(globalData, body->ident(), body->source(), body->usesArguments(), body->parameters(), body->isStrictMode(), body->lineNo(), body->lastLine()); 482 482 } 483 484 JSString* addStringConstant(const Identifier&); 483 485 484 486 void addLineInfo(unsigned lineNo) -
trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
r89465 r89954 1607 1607 Constructs a new Array instance using the original 1608 1608 constructor, and puts the result in register dst. 1609 The array be initialized with the values from immediateBuffer[index]1609 The array be initialized with the values from constantBuffer[index] 1610 1610 */ 1611 1611 int dst = vPC[1].u.operand; 1612 1612 int firstArg = vPC[2].u.operand; 1613 1613 int argCount = vPC[3].u.operand; 1614 ArgList args(codeBlock-> immediateBuffer(firstArg), argCount);1614 ArgList args(codeBlock->constantBufferfirstArg), argCount); 1615 1615 callFrame->uncheckedR(dst) = JSValue(constructArray(callFrame, args)); 1616 1616 -
trunk/Source/JavaScriptCore/jit/JITStubs.cpp
r88873 r89954 2265 2265 STUB_INIT_STACK_FRAME(stackFrame); 2266 2266 2267 ArgList argList(stackFrame.callFrame->codeBlock()-> immediateBuffer(stackFrame.args[0].int32()), stackFrame.args[1].int32());2267 ArgList argList(stackFrame.callFrame->codeBlock()->constantBuffer(stackFrame.args[0].int32()), stackFrame.args[1].int32()); 2268 2268 return constructArray(stackFrame.callFrame, argList); 2269 2269 }
Note: See TracChangeset
for help on using the changeset viewer.