Changeset 38330 in webkit for trunk/JavaScriptCore/VM/CTI.cpp
- Timestamp:
- Nov 12, 2008, 1:34:22 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/VM/CTI.cpp
r38322 r38330 588 588 } 589 589 590 void CTI::compileOpCallSetupArgs(Instruction* instruction )591 { 592 int argCount = instruction[3].u.operand;593 int registerOffset = instruction[4].u.operand;594 595 // ecx holds func 590 void CTI::compileOpCallSetupArgs(Instruction* instruction, bool isConstruct, bool isEval) 591 { 592 int firstArg = instruction[4].u.operand; 593 int argCount = instruction[5].u.operand; 594 int registerOffset = instruction[6].u.operand; 595 596 596 emitPutArg(X86::ecx, 0); 597 597 emitPutArgConstant(registerOffset, 4); 598 598 emitPutArgConstant(argCount, 8); 599 599 emitPutArgConstant(reinterpret_cast<unsigned>(instruction), 12); 600 } 601 602 void CTI::compileOpCallEvalSetupArgs(Instruction* instruction) 603 { 604 int argCount = instruction[3].u.operand; 605 int registerOffset = instruction[4].u.operand; 606 607 // ecx holds func 608 emitPutArg(X86::ecx, 0); 609 emitPutArgConstant(registerOffset, 4); 610 emitPutArgConstant(argCount, 8); 611 emitPutArgConstant(reinterpret_cast<unsigned>(instruction), 12); 612 } 613 614 void CTI::compileOpConstructSetupArgs(Instruction* instruction) 615 { 616 int argCount = instruction[3].u.operand; 617 int registerOffset = instruction[4].u.operand; 618 int proto = instruction[5].u.operand; 619 int thisRegister = instruction[6].u.operand; 620 621 // ecx holds func 622 emitPutArg(X86::ecx, 0); 623 emitPutArgConstant(registerOffset, 4); 624 emitPutArgConstant(argCount, 8); 625 emitGetPutArg(proto, 12, X86::eax); 626 emitPutArgConstant(thisRegister, 16); 627 emitPutArgConstant(reinterpret_cast<unsigned>(instruction), 20); 600 if (isConstruct) { 601 emitGetPutArg(instruction[3].u.operand, 16, X86::eax); 602 emitPutArgConstant(firstArg, 20); 603 } else if (isEval) 604 emitGetPutArg(instruction[3].u.operand, 16, X86::eax); 628 605 } 629 606 … … 632 609 int dst = instruction[1].u.operand; 633 610 int callee = instruction[2].u.operand; 634 int argCount = instruction[3].u.operand; 635 int registerOffset = instruction[4].u.operand; 611 int firstArg = instruction[4].u.operand; 612 int argCount = instruction[5].u.operand; 613 int registerOffset = instruction[6].u.operand; 614 615 // Setup this value as the first argument (does not apply to constructors) 616 if (opcodeID != op_construct) { 617 int thisVal = instruction[3].u.operand; 618 if (thisVal == missingThisObjectMarker()) 619 m_jit.movl_i32m(asInteger(jsNull()), firstArg * sizeof(Register), X86::edi); 620 else { 621 emitGetArg(thisVal, X86::eax); 622 emitPutResult(firstArg); 623 } 624 } 636 625 637 626 // Handle eval … … 639 628 if (opcodeID == op_call_eval) { 640 629 emitGetArg(callee, X86::ecx); 641 compileOpCall EvalSetupArgs(instruction);630 compileOpCallSetupArgs(instruction, false, true); 642 631 643 632 emitCTICall(instruction, i, Machine::cti_op_call_eval); … … 659 648 // In the case of OpConstruct, call out to a cti_ function to create the new object. 660 649 if (opcodeID == op_construct) { 661 int proto = instruction[5].u.operand;662 int thisRegister = instruction[6].u.operand;663 664 650 emitPutArg(X86::ecx, 0); 665 emitGetPutArg( proto, 12, X86::eax);651 emitGetPutArg(instruction[3].u.operand, 16, X86::eax); 666 652 emitCTICall(instruction, i, Machine::cti_op_construct_JSConstruct); 667 emitPutResult( thisRegister);653 emitPutResult(firstArg); 668 654 emitGetArg(callee, X86::ecx); 669 655 } … … 1300 1286 break; 1301 1287 } 1302 case op_call: 1303 case op_call_eval: 1304 case op_construct: { 1288 case op_call: { 1305 1289 compileOpCall(opcodeID, instruction + i, i, callLinkInfoIndex++); 1306 i += (opcodeID == op_construct ? 7 : 5);1290 i += 7; 1307 1291 break; 1308 1292 } … … 1396 1380 emitPutResult(instruction[i + 1].u.operand); 1397 1381 i += 3; 1382 break; 1383 } 1384 case op_construct: { 1385 compileOpCall(opcodeID, instruction + i, i, callLinkInfoIndex++); 1386 i += 7; 1398 1387 break; 1399 1388 } … … 1923 1912 emitPutResult(instruction[i + 1].u.operand); 1924 1913 i += 5; 1914 break; 1915 } 1916 case op_call_eval: { 1917 compileOpCall(opcodeID, instruction + i, i, callLinkInfoIndex++); 1918 i += 7; 1925 1919 break; 1926 1920 } … … 2774 2768 int dst = instruction[i + 1].u.operand; 2775 2769 int callee = instruction[i + 2].u.operand; 2776 int argCount = instruction[i + 3].u.operand; 2777 int registerOffset = instruction[i + 4].u.operand; 2770 int firstArg = instruction[i + 4].u.operand; 2771 int argCount = instruction[i + 5].u.operand; 2772 int registerOffset = instruction[i + 6].u.operand; 2778 2773 2779 2774 m_jit.link(iter->from, m_jit.label()); 2780 2775 2781 2776 // The arguments have been set up on the hot path for op_call_eval 2782 if (opcodeID == op_call) 2783 compileOpCallSetupArgs(instruction + i); 2784 else if (opcodeID == op_construct) 2785 compileOpConstructSetupArgs(instruction + i); 2777 if (opcodeID != op_call_eval) 2778 compileOpCallSetupArgs(instruction + i, (opcodeID == op_construct), false); 2786 2779 2787 2780 // Fast check for JS function. … … 2791 2784 X86Assembler::JmpSrc callLinkFailNotJSFunction = m_jit.emitUnlinkedJne(); 2792 2785 2793 // First, in the ca se of a construct, allocate the new object.2786 // First, in the cale of a construct, allocate the new object. 2794 2787 if (opcodeID == op_construct) { 2795 2788 emitCTICall(instruction, i, Machine::cti_op_construct_JSConstruct); 2796 emitPutResult( registerOffset - RegisterFile::CallFrameHeaderSize - argCount);2789 emitPutResult(firstArg); 2797 2790 emitGetArg(callee, X86::ecx); 2798 2791 } … … 2835 2828 2836 2829 // The arguments have been set up on the hot path for op_call_eval 2837 if (opcodeID == op_call) 2838 compileOpCallSetupArgs(instruction + i); 2839 else if (opcodeID == op_construct) 2840 compileOpConstructSetupArgs(instruction + i); 2830 if (opcodeID != op_call_eval) 2831 compileOpCallSetupArgs(instruction + i, (opcodeID == op_construct), false); 2841 2832 2842 2833 // Check for JSFunctions. … … 2857 2848 m_jit.link(isJSFunction, m_jit.label()); 2858 2849 2859 // First, in the ca se of a construct, allocate the new object.2850 // First, in the cale of a construct, allocate the new object. 2860 2851 if (opcodeID == op_construct) { 2861 2852 emitCTICall(instruction, i, Machine::cti_op_construct_JSConstruct); 2862 emitPutResult( registerOffset - RegisterFile::CallFrameHeaderSize - argCount);2853 emitPutResult(firstArg); 2863 2854 emitGetArg(callee, X86::ecx); 2864 2855 } … … 2905 2896 ++callLinkInfoIndex; 2906 2897 2907 i += (opcodeID == op_construct ? 7 : 5);2898 i += 7; 2908 2899 break; 2909 2900 }
Note:
See TracChangeset
for help on using the changeset viewer.