Changeset 88841 in webkit
- Timestamp:
- Jun 14, 2011 12:10:20 PM (13 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r88833 r88841 1 2011-06-14 Oliver Hunt <oliver@apple.com> 2 3 Reviewed by Gavin Barraclough. 4 5 Constant array literals result in unnecessarily large amounts of code 6 https://bugs.webkit.org/show_bug.cgi?id=62658 7 8 Add a new version of op_new_array that simply copies values from a buffer 9 we hang off of the CodeBlock, rather than generating code to place each 10 entry into the registerfile, and then copying it from the registerfile into 11 the array. This is a slight improvement on some sunspider tests, but no 12 measurable overall change. That's okay though as our goal was to reduce 13 code size without hurting performance. 14 15 * bytecode/CodeBlock.cpp: 16 (JSC::CodeBlock::dump): 17 * bytecode/CodeBlock.h: 18 (JSC::CodeBlock::addImmediateBuffer): 19 (JSC::CodeBlock::immediateBuffer): 20 * bytecode/Opcode.h: 21 * bytecompiler/BytecodeGenerator.cpp: 22 (JSC::BytecodeGenerator::addImmediateBuffer): 23 (JSC::BytecodeGenerator::emitNewArray): 24 * bytecompiler/BytecodeGenerator.h: 25 * bytecompiler/NodesCodegen.cpp: 26 (JSC::ArrayNode::emitBytecode): 27 * interpreter/Interpreter.cpp: 28 (JSC::Interpreter::privateExecute): 29 * jit/JIT.cpp: 30 (JSC::JIT::privateCompileMainPass): 31 * jit/JIT.h: 32 * jit/JITOpcodes.cpp: 33 (JSC::JIT::emit_op_new_array): 34 (JSC::JIT::emit_op_new_array_buffer): 35 * jit/JITOpcodes32_64.cpp: 36 * jit/JITStubs.cpp: 37 (JSC::DEFINE_STUB_FUNCTION): 38 * jit/JITStubs.h: 39 1 40 2011-06-14 Stephanie Lewis <slewis@apple.com> 2 41 -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.cpp
r88821 r88841 531 531 break; 532 532 } 533 case op_new_array_buffer: { 534 int dst = (++it)->u.operand; 535 int argv = (++it)->u.operand; 536 int argc = (++it)->u.operand; 537 printf("[%4d] new_array_buffer %s, %d, %d\n", location, registerName(exec, dst).data(), argv, argc); 538 break; 539 } 533 540 case op_new_regexp: { 534 541 int r0 = (++it)->u.operand; -
trunk/Source/JavaScriptCore/bytecode/CodeBlock.h
r87359 r88841 457 457 RegExp* regexp(int index) const { ASSERT(m_rareData); return m_rareData->m_regexps[index].get(); } 458 458 459 unsigned addImmediateBuffer(unsigned length) 460 { 461 createRareDataIfNecessary(); 462 unsigned size = m_rareData->m_immediateBuffers.size(); 463 m_rareData->m_immediateBuffers.append(Vector<JSValue>(length)); 464 return size; 465 } 466 467 JSValue* immediateBuffer(unsigned index) 468 { 469 ASSERT(m_rareData); 470 return m_rareData->m_immediateBuffers[index].data(); 471 } 472 459 473 JSGlobalObject* globalObject() { return m_globalObject.get(); } 460 474 … … 560 574 Vector<WriteBarrier<RegExp> > m_regexps; 561 575 576 // Buffers used for large array literals 577 Vector<Vector<JSValue> > m_immediateBuffers; 578 562 579 // Jump Tables 563 580 Vector<SimpleJumpTable> m_immediateSwitchJumpTables; -
trunk/Source/JavaScriptCore/bytecode/Opcode.h
r81380 r88841 50 50 macro(op_new_object, 2) \ 51 51 macro(op_new_array, 4) \ 52 macro(op_new_array_buffer, 4) \ 52 53 macro(op_new_regexp, 3) \ 53 54 macro(op_mov, 3) \ -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.cpp
r87359 r88841 1542 1542 } 1543 1543 1544 RegisterID* BytecodeGenerator::emitNewArray(RegisterID* dst, ElementNode* elements) 1545 { 1544 unsigned BytecodeGenerator::addImmediateBuffer(unsigned length) 1545 { 1546 return m_codeBlock->addImmediateBuffer(length); 1547 } 1548 1549 RegisterID* BytecodeGenerator::emitNewArray(RegisterID* dst, ElementNode* elements, unsigned length) 1550 { 1551 #if !ASSERT_DISABLED 1552 unsigned checkLength = 0; 1553 #endif 1554 bool hadNonNumber = false; 1555 for (ElementNode* n = elements; n; n = n->next()) { 1556 #if !ASSERT_DISABLED 1557 checkLength++; 1558 #endif 1559 if (!n->value()->isNumber()) { 1560 hadNonNumber = true; 1561 break; 1562 } 1563 } 1564 if (!hadNonNumber) { 1565 ASSERT(length == checkLength); 1566 unsigned immediateBufferIndex = addImmediateBuffer(length); 1567 JSValue* immediateBuffer = m_codeBlock->immediateBuffer(immediateBufferIndex); 1568 unsigned index = 0; 1569 for (ElementNode* n = elements; n; n = n->next()) 1570 immediateBuffer[index++] = jsNumber(static_cast<NumberNode*>(n->value())->value()); 1571 emitOpcode(op_new_array_buffer); 1572 instructions().append(dst->index()); 1573 instructions().append(immediateBufferIndex); 1574 instructions().append(length); 1575 return dst; 1576 } 1577 1546 1578 Vector<RefPtr<RegisterID>, 16> argv; 1547 1579 for (ElementNode* n = elements; n; n = n->next()) { -
trunk/Source/JavaScriptCore/bytecompiler/BytecodeGenerator.h
r87346 r88841 286 286 287 287 RegisterID* emitNewObject(RegisterID* dst); 288 RegisterID* emitNewArray(RegisterID* dst, ElementNode* ); // stops at first elision288 RegisterID* emitNewArray(RegisterID* dst, ElementNode*, unsigned length); // stops at first elision 289 289 290 290 RegisterID* emitNewFunction(RegisterID* dst, FunctionBodyNode* body); … … 478 478 unsigned addRegExp(RegExp*); 479 479 480 unsigned addImmediateBuffer(unsigned length); 481 480 482 FunctionExecutable* makeFunction(ExecState* exec, FunctionBodyNode* body) 481 483 { -
trunk/Source/JavaScriptCore/bytecompiler/NodesCodegen.cpp
r87445 r88841 172 172 173 173 if (!firstPutElement && !m_elision) 174 return generator.emitNewArray(generator.finalDestination(dst), m_element );175 176 RefPtr<RegisterID> array = generator.emitNewArray(generator.tempDestination(dst), m_element );174 return generator.emitNewArray(generator.finalDestination(dst), m_element, length); 175 176 RefPtr<RegisterID> array = generator.emitNewArray(generator.tempDestination(dst), m_element, length); 177 177 178 178 for (ElementNode* n = firstPutElement; n; n = n->next()) { -
trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
r87586 r88841 1552 1552 callFrame->uncheckedR(dst) = JSValue(constructArray(callFrame, args)); 1553 1553 1554 vPC += OPCODE_LENGTH(op_new_array); 1555 NEXT_INSTRUCTION(); 1556 } 1557 DEFINE_OPCODE(op_new_array_buffer) { 1558 /* new_array_buffer dst(r) index(n) argCount(n) 1559 1560 Constructs a new Array instance using the original 1561 constructor, and puts the result in register dst. 1562 The array be initialized with the values from immediateBuffer[index] 1563 */ 1564 int dst = vPC[1].u.operand; 1565 int firstArg = vPC[2].u.operand; 1566 int argCount = vPC[3].u.operand; 1567 ArgList args(codeBlock->immediateBuffer(firstArg), argCount); 1568 callFrame->uncheckedR(dst) = JSValue(constructArray(callFrame, args)); 1569 1554 1570 vPC += OPCODE_LENGTH(op_new_array); 1555 1571 NEXT_INSTRUCTION(); -
trunk/Source/JavaScriptCore/jit/JIT.cpp
r88604 r88841 273 273 DEFINE_OP(op_neq_null) 274 274 DEFINE_OP(op_new_array) 275 DEFINE_OP(op_new_array_buffer) 275 276 DEFINE_OP(op_new_func) 276 277 DEFINE_OP(op_new_func_exp) -
trunk/Source/JavaScriptCore/jit/JIT.h
r88604 r88841 779 779 void emit_op_neq_null(Instruction*); 780 780 void emit_op_new_array(Instruction*); 781 void emit_op_new_array_buffer(Instruction*); 781 782 void emit_op_new_func(Instruction*); 782 783 void emit_op_new_func_exp(Instruction*); -
trunk/Source/JavaScriptCore/jit/JITOpcodes.cpp
r88604 r88841 580 580 } 581 581 582 void JIT::emit_op_new_array(Instruction* currentInstruction)583 {584 JITStubCall stubCall(this, cti_op_new_array);585 stubCall.addArgument(Imm32(currentInstruction[2].u.operand));586 stubCall.addArgument(Imm32(currentInstruction[3].u.operand));587 stubCall.call(currentInstruction[1].u.operand);588 }589 590 582 void JIT::emit_op_resolve(Instruction* currentInstruction) 591 583 { … … 1735 1727 } 1736 1728 1729 void JIT::emit_op_new_array(Instruction* currentInstruction) 1730 { 1731 JITStubCall stubCall(this, cti_op_new_array); 1732 stubCall.addArgument(Imm32(currentInstruction[2].u.operand)); 1733 stubCall.addArgument(Imm32(currentInstruction[3].u.operand)); 1734 stubCall.call(currentInstruction[1].u.operand); 1735 } 1736 1737 void JIT::emit_op_new_array_buffer(Instruction* currentInstruction) 1738 { 1739 JITStubCall stubCall(this, cti_op_new_array_buffer); 1740 stubCall.addArgument(Imm32(currentInstruction[2].u.operand)); 1741 stubCall.addArgument(Imm32(currentInstruction[3].u.operand)); 1742 stubCall.call(currentInstruction[1].u.operand); 1743 } 1744 1737 1745 } // namespace JSC 1738 1746 -
trunk/Source/JavaScriptCore/jit/JITOpcodes32_64.cpp
r88604 r88841 734 734 } 735 735 736 void JIT::emit_op_new_array(Instruction* currentInstruction)737 {738 JITStubCall stubCall(this, cti_op_new_array);739 stubCall.addArgument(Imm32(currentInstruction[2].u.operand));740 stubCall.addArgument(Imm32(currentInstruction[3].u.operand));741 stubCall.call(currentInstruction[1].u.operand);742 }743 744 736 void JIT::emit_op_resolve(Instruction* currentInstruction) 745 737 { -
trunk/Source/JavaScriptCore/jit/JITStubs.cpp
r88604 r88841 2258 2258 2259 2259 ArgList argList(&stackFrame.callFrame->registers()[stackFrame.args[0].int32()], stackFrame.args[1].int32()); 2260 return constructArray(stackFrame.callFrame, argList); 2261 } 2262 2263 DEFINE_STUB_FUNCTION(JSObject*, op_new_array_buffer) 2264 { 2265 STUB_INIT_STACK_FRAME(stackFrame); 2266 2267 ArgList argList(stackFrame.callFrame->codeBlock()->immediateBuffer(stackFrame.args[0].int32()), stackFrame.args[1].int32()); 2260 2268 return constructArray(stackFrame.callFrame, argList); 2261 2269 } -
trunk/Source/JavaScriptCore/jit/JITStubs.h
r87345 r88841 381 381 EncodedJSValue JIT_STUB cti_to_object(STUB_ARGS_DECLARATION); 382 382 JSObject* JIT_STUB cti_op_new_array(STUB_ARGS_DECLARATION); 383 JSObject* JIT_STUB cti_op_new_array_buffer(STUB_ARGS_DECLARATION); 383 384 JSObject* JIT_STUB cti_op_new_func(STUB_ARGS_DECLARATION); 384 385 JSObject* JIT_STUB cti_op_new_func_exp(STUB_ARGS_DECLARATION);
Note: See TracChangeset
for help on using the changeset viewer.