Changeset 38322 in webkit for trunk/JavaScriptCore/VM/CTI.cpp
- Timestamp:
- Nov 11, 2008, 4:32:38 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/VM/CTI.cpp
r38306 r38322 588 588 } 589 589 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 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 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 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); 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); 605 628 } 606 629 … … 609 632 int dst = instruction[1].u.operand; 610 633 int callee = instruction[2].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 } 634 int argCount = instruction[3].u.operand; 635 int registerOffset = instruction[4].u.operand; 625 636 626 637 // Handle eval … … 628 639 if (opcodeID == op_call_eval) { 629 640 emitGetArg(callee, X86::ecx); 630 compileOpCall SetupArgs(instruction, false, true);641 compileOpCallEvalSetupArgs(instruction); 631 642 632 643 emitCTICall(instruction, i, Machine::cti_op_call_eval); … … 648 659 // In the case of OpConstruct, call out to a cti_ function to create the new object. 649 660 if (opcodeID == op_construct) { 661 int proto = instruction[5].u.operand; 662 int thisRegister = instruction[6].u.operand; 663 650 664 emitPutArg(X86::ecx, 0); 651 emitGetPutArg( instruction[3].u.operand, 16, X86::eax);665 emitGetPutArg(proto, 12, X86::eax); 652 666 emitCTICall(instruction, i, Machine::cti_op_construct_JSConstruct); 653 emitPutResult( firstArg);667 emitPutResult(thisRegister); 654 668 emitGetArg(callee, X86::ecx); 655 669 } … … 1286 1300 break; 1287 1301 } 1288 case op_call: { 1302 case op_call: 1303 case op_call_eval: 1304 case op_construct: { 1289 1305 compileOpCall(opcodeID, instruction + i, i, callLinkInfoIndex++); 1290 i += 7;1306 i += (opcodeID == op_construct ? 7 : 5); 1291 1307 break; 1292 1308 } … … 1380 1396 emitPutResult(instruction[i + 1].u.operand); 1381 1397 i += 3; 1382 break;1383 }1384 case op_construct: {1385 compileOpCall(opcodeID, instruction + i, i, callLinkInfoIndex++);1386 i += 7;1387 1398 break; 1388 1399 } … … 1912 1923 emitPutResult(instruction[i + 1].u.operand); 1913 1924 i += 5; 1914 break;1915 }1916 case op_call_eval: {1917 compileOpCall(opcodeID, instruction + i, i, callLinkInfoIndex++);1918 i += 7;1919 1925 break; 1920 1926 } … … 2768 2774 int dst = instruction[i + 1].u.operand; 2769 2775 int callee = instruction[i + 2].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; 2776 int argCount = instruction[i + 3].u.operand; 2777 int registerOffset = instruction[i + 4].u.operand; 2773 2778 2774 2779 m_jit.link(iter->from, m_jit.label()); 2775 2780 2776 2781 // The arguments have been set up on the hot path for op_call_eval 2777 if (opcodeID != op_call_eval) 2778 compileOpCallSetupArgs(instruction + i, (opcodeID == op_construct), false); 2782 if (opcodeID == op_call) 2783 compileOpCallSetupArgs(instruction + i); 2784 else if (opcodeID == op_construct) 2785 compileOpConstructSetupArgs(instruction + i); 2779 2786 2780 2787 // Fast check for JS function. … … 2784 2791 X86Assembler::JmpSrc callLinkFailNotJSFunction = m_jit.emitUnlinkedJne(); 2785 2792 2786 // First, in the ca le of a construct, allocate the new object.2793 // First, in the case of a construct, allocate the new object. 2787 2794 if (opcodeID == op_construct) { 2788 2795 emitCTICall(instruction, i, Machine::cti_op_construct_JSConstruct); 2789 emitPutResult( firstArg);2796 emitPutResult(registerOffset - RegisterFile::CallFrameHeaderSize - argCount); 2790 2797 emitGetArg(callee, X86::ecx); 2791 2798 } … … 2828 2835 2829 2836 // The arguments have been set up on the hot path for op_call_eval 2830 if (opcodeID != op_call_eval) 2831 compileOpCallSetupArgs(instruction + i, (opcodeID == op_construct), false); 2837 if (opcodeID == op_call) 2838 compileOpCallSetupArgs(instruction + i); 2839 else if (opcodeID == op_construct) 2840 compileOpConstructSetupArgs(instruction + i); 2832 2841 2833 2842 // Check for JSFunctions. … … 2848 2857 m_jit.link(isJSFunction, m_jit.label()); 2849 2858 2850 // First, in the ca le of a construct, allocate the new object.2859 // First, in the case of a construct, allocate the new object. 2851 2860 if (opcodeID == op_construct) { 2852 2861 emitCTICall(instruction, i, Machine::cti_op_construct_JSConstruct); 2853 emitPutResult( firstArg);2862 emitPutResult(registerOffset - RegisterFile::CallFrameHeaderSize - argCount); 2854 2863 emitGetArg(callee, X86::ecx); 2855 2864 } … … 2896 2905 ++callLinkInfoIndex; 2897 2906 2898 i += 7;2907 i += (opcodeID == op_construct ? 7 : 5); 2899 2908 break; 2900 2909 }
Note:
See TracChangeset
for help on using the changeset viewer.