Changeset 34497 in webkit
- Timestamp:
- Jun 11, 2008 12:48:15 PM (16 years ago)
- Location:
- trunk/JavaScriptCore
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/ChangeLog
r34496 r34497 1 2008-06-11 Cameron Zwarich <cwzwarich@uwaterloo.ca> 2 3 Reviewed by Darin. 4 5 Bug 19457: Create fused opcodes for tests and conditional jumps 6 <https://bugs.webkit.org/show_bug.cgi?id=19457> 7 8 Add a new jless instruction, and modify the code generator to emit it 9 instead of the pair (less, jtrue). 10 11 Gives a 3.6% improvement on SunSpider. 12 13 * VM/CodeBlock.cpp: 14 (KJS::CodeBlock::dump): 15 * VM/CodeGenerator.cpp: 16 (KJS::CodeGenerator::CodeGenerator): 17 (KJS::CodeGenerator::emitOpcode): 18 (KJS::CodeGenerator::retrieveLastBinaryOp): 19 (KJS::CodeGenerator::rewindBinaryOp): 20 (KJS::CodeGenerator::emitJump): 21 (KJS::CodeGenerator::emitJumpIfTrue): 22 (KJS::CodeGenerator::emitJumpIfFalse): 23 (KJS::CodeGenerator::emitMove): 24 (KJS::CodeGenerator::emitNot): 25 (KJS::CodeGenerator::emitEqual): 26 (KJS::CodeGenerator::emitNotEqual): 27 (KJS::CodeGenerator::emitStrictEqual): 28 (KJS::CodeGenerator::emitNotStrictEqual): 29 (KJS::CodeGenerator::emitLess): 30 (KJS::CodeGenerator::emitLessEq): 31 (KJS::CodeGenerator::emitPreInc): 32 (KJS::CodeGenerator::emitPreDec): 33 (KJS::CodeGenerator::emitPostInc): 34 (KJS::CodeGenerator::emitPostDec): 35 (KJS::CodeGenerator::emitToJSNumber): 36 (KJS::CodeGenerator::emitNegate): 37 (KJS::CodeGenerator::emitAdd): 38 (KJS::CodeGenerator::emitMul): 39 (KJS::CodeGenerator::emitDiv): 40 (KJS::CodeGenerator::emitMod): 41 (KJS::CodeGenerator::emitSub): 42 (KJS::CodeGenerator::emitLeftShift): 43 (KJS::CodeGenerator::emitRightShift): 44 (KJS::CodeGenerator::emitUnsignedRightShift): 45 (KJS::CodeGenerator::emitBitAnd): 46 (KJS::CodeGenerator::emitBitXOr): 47 (KJS::CodeGenerator::emitBitOr): 48 (KJS::CodeGenerator::emitBitNot): 49 (KJS::CodeGenerator::emitInstanceOf): 50 (KJS::CodeGenerator::emitTypeOf): 51 (KJS::CodeGenerator::emitIn): 52 (KJS::CodeGenerator::emitLoad): 53 (KJS::CodeGenerator::emitNewObject): 54 (KJS::CodeGenerator::emitNewArray): 55 (KJS::CodeGenerator::emitResolve): 56 (KJS::CodeGenerator::emitGetScopedVar): 57 (KJS::CodeGenerator::emitPutScopedVar): 58 (KJS::CodeGenerator::emitResolveBase): 59 (KJS::CodeGenerator::emitResolveWithBase): 60 (KJS::CodeGenerator::emitResolveFunction): 61 (KJS::CodeGenerator::emitGetById): 62 (KJS::CodeGenerator::emitPutById): 63 (KJS::CodeGenerator::emitPutGetter): 64 (KJS::CodeGenerator::emitPutSetter): 65 (KJS::CodeGenerator::emitDeleteById): 66 (KJS::CodeGenerator::emitGetByVal): 67 (KJS::CodeGenerator::emitPutByVal): 68 (KJS::CodeGenerator::emitDeleteByVal): 69 (KJS::CodeGenerator::emitPutByIndex): 70 (KJS::CodeGenerator::emitNewFunction): 71 (KJS::CodeGenerator::emitNewRegExp): 72 (KJS::CodeGenerator::emitNewFunctionExpression): 73 (KJS::CodeGenerator::emitCall): 74 (KJS::CodeGenerator::emitReturn): 75 (KJS::CodeGenerator::emitEnd): 76 (KJS::CodeGenerator::emitConstruct): 77 (KJS::CodeGenerator::emitPushScope): 78 (KJS::CodeGenerator::emitPopScope): 79 (KJS::CodeGenerator::emitDebugHook): 80 (KJS::CodeGenerator::emitComplexJumpScopes): 81 (KJS::CodeGenerator::emitJumpScopes): 82 (KJS::CodeGenerator::emitNextPropertyName): 83 (KJS::CodeGenerator::emitGetPropertyNames): 84 (KJS::CodeGenerator::emitCatch): 85 (KJS::CodeGenerator::emitThrow): 86 (KJS::CodeGenerator::emitNewError): 87 (KJS::CodeGenerator::emitJumpSubroutine): 88 (KJS::CodeGenerator::emitSubroutineReturn): 89 * VM/CodeGenerator.h: 90 * VM/Machine.cpp: 91 (KJS::Machine::privateExecute): 92 * VM/Opcode.cpp: 93 (KJS::): 94 * VM/Opcode.h: 95 1 96 2008-06-11 Darin Adler <darin@apple.com> 2 97 -
trunk/JavaScriptCore/VM/CodeBlock.cpp
r34372 r34497 468 468 break; 469 469 } 470 case op_jless: { 471 int r0 = (++it)->u.operand; 472 int r1 = (++it)->u.operand; 473 int offset = (++it)->u.operand; 474 printf("[%4d] jless\t\t %s, %s, %d(->%d)\n", location, registerName(r0).c_str(), registerName(r1).c_str(), offset, jumpTarget(begin, it, offset)); 475 break; 476 } 470 477 case op_new_func: { 471 478 int r0 = (++it)->u.operand; -
trunk/JavaScriptCore/VM/CodeGenerator.cpp
r34412 r34497 181 181 , m_nextVar(-1) 182 182 , m_propertyNames(&scopeChain.globalObject()->globalExec()->propertyNames()) 183 , m_lastOpcodeID(op_end) 183 184 { 184 185 // Global code can inherit previously defined symbols. … … 239 240 , m_nextVar(-1) 240 241 , m_propertyNames(&scopeChain.globalObject()->globalExec()->propertyNames()) 242 , m_lastOpcodeID(op_end) 241 243 { 242 244 const Node::FunctionStack& functionStack = functionBody->functionStack(); … … 286 288 , m_nextVar(-1) 287 289 , m_propertyNames(&scopeChain.globalObject()->globalExec()->propertyNames()) 290 , m_lastOpcodeID(op_end) 288 291 { 289 292 m_codeBlock->numVars = 1; // Allocate space for "this" … … 384 387 } 385 388 389 void CodeGenerator::emitOpcode(OpcodeID opcodeID) 390 { 391 instructions().append(machine().getOpcode(opcodeID)); 392 m_lastOpcodeID = opcodeID; 393 } 394 395 void CodeGenerator::retrieveLastBinaryOp(int& dstIndex, int& src1Index, int& src2Index) 396 { 397 ASSERT(instructions().size() >= 4); 398 size_t size = instructions().size(); 399 dstIndex = instructions().at(size - 3).u.operand; 400 src1Index = instructions().at(size - 2).u.operand; 401 src2Index = instructions().at(size - 1).u.operand; 402 } 403 404 void CodeGenerator::rewindBinaryOp() 405 { 406 ASSERT(instructions().size() >= 4); 407 instructions().shrink(instructions().size() - 4); 408 } 409 386 410 PassRefPtr<LabelID> CodeGenerator::emitJump(LabelID* target) 387 411 { 388 instructions().append(machine().getOpcode(op_jmp));412 emitOpcode(op_jmp); 389 413 instructions().append(target->offsetFrom(instructions().size())); 390 414 return target; … … 393 417 PassRefPtr<LabelID> CodeGenerator::emitJumpIfTrue(RegisterID* cond, LabelID* target) 394 418 { 395 instructions().append(machine().getOpcode(op_jtrue)); 419 if (m_lastOpcodeID == op_less) { 420 int dstIndex; 421 int src1Index; 422 int src2Index; 423 424 retrieveLastBinaryOp(dstIndex, src1Index, src2Index); 425 426 if (cond->index() == dstIndex) { 427 rewindBinaryOp(); 428 emitOpcode(op_jless); 429 instructions().append(src1Index); 430 instructions().append(src2Index); 431 instructions().append(target->offsetFrom(instructions().size())); 432 return target; 433 } 434 } 435 436 emitOpcode(op_jtrue); 396 437 instructions().append(cond->index()); 397 438 instructions().append(target->offsetFrom(instructions().size())); … … 401 442 PassRefPtr<LabelID> CodeGenerator::emitJumpIfFalse(RegisterID* cond, LabelID* target) 402 443 { 403 instructions().append(machine().getOpcode(op_jfalse));444 emitOpcode(op_jfalse); 404 445 instructions().append(cond->index()); 405 446 instructions().append(target->offsetFrom(instructions().size())); … … 451 492 RegisterID* CodeGenerator::emitMove(RegisterID* dst, RegisterID* src) 452 493 { 453 instructions().append(machine().getOpcode(op_mov));494 emitOpcode(op_mov); 454 495 instructions().append(dst->index()); 455 496 instructions().append(src->index()); … … 459 500 RegisterID* CodeGenerator::emitNot(RegisterID* dst, RegisterID* src) 460 501 { 461 instructions().append(machine().getOpcode(op_not));502 emitOpcode(op_not); 462 503 instructions().append(dst->index()); 463 504 instructions().append(src->index()); … … 467 508 RegisterID* CodeGenerator::emitEqual(RegisterID* dst, RegisterID* src1, RegisterID* src2) 468 509 { 469 instructions().append(machine().getOpcode(op_eq));510 emitOpcode(op_eq); 470 511 instructions().append(dst->index()); 471 512 instructions().append(src1->index()); … … 476 517 RegisterID* CodeGenerator::emitNotEqual(RegisterID* dst, RegisterID* src1, RegisterID* src2) 477 518 { 478 instructions().append(machine().getOpcode(op_neq));519 emitOpcode(op_neq); 479 520 instructions().append(dst->index()); 480 521 instructions().append(src1->index()); … … 485 526 RegisterID* CodeGenerator::emitStrictEqual(RegisterID* dst, RegisterID* src1, RegisterID* src2) 486 527 { 487 instructions().append(machine().getOpcode(op_stricteq));528 emitOpcode(op_stricteq); 488 529 instructions().append(dst->index()); 489 530 instructions().append(src1->index()); … … 494 535 RegisterID* CodeGenerator::emitNotStrictEqual(RegisterID* dst, RegisterID* src1, RegisterID* src2) 495 536 { 496 instructions().append(machine().getOpcode(op_nstricteq));537 emitOpcode(op_nstricteq); 497 538 instructions().append(dst->index()); 498 539 instructions().append(src1->index()); … … 503 544 RegisterID* CodeGenerator::emitLess(RegisterID* dst, RegisterID* src1, RegisterID* src2) 504 545 { 505 instructions().append(machine().getOpcode(op_less));546 emitOpcode(op_less); 506 547 instructions().append(dst->index()); 507 548 instructions().append(src1->index()); … … 512 553 RegisterID* CodeGenerator::emitLessEq(RegisterID* dst, RegisterID* src1, RegisterID* src2) 513 554 { 514 instructions().append(machine().getOpcode(op_lesseq));555 emitOpcode(op_lesseq); 515 556 instructions().append(dst->index()); 516 557 instructions().append(src1->index()); … … 521 562 RegisterID* CodeGenerator::emitPreInc(RegisterID* srcDst) 522 563 { 523 instructions().append(machine().getOpcode(op_pre_inc));564 emitOpcode(op_pre_inc); 524 565 instructions().append(srcDst->index()); 525 566 return srcDst; … … 528 569 RegisterID* CodeGenerator::emitPreDec(RegisterID* srcDst) 529 570 { 530 instructions().append(machine().getOpcode(op_pre_dec));571 emitOpcode(op_pre_dec); 531 572 instructions().append(srcDst->index()); 532 573 return srcDst; … … 535 576 RegisterID* CodeGenerator::emitPostInc(RegisterID* dst, RegisterID* srcDst) 536 577 { 537 instructions().append(machine().getOpcode(op_post_inc));578 emitOpcode(op_post_inc); 538 579 instructions().append(dst->index()); 539 580 instructions().append(srcDst->index()); … … 543 584 RegisterID* CodeGenerator::emitPostDec(RegisterID* dst, RegisterID* srcDst) 544 585 { 545 instructions().append(machine().getOpcode(op_post_dec));586 emitOpcode(op_post_dec); 546 587 instructions().append(dst->index()); 547 588 instructions().append(srcDst->index()); … … 551 592 RegisterID* CodeGenerator::emitToJSNumber(RegisterID* dst, RegisterID* src) 552 593 { 553 instructions().append(machine().getOpcode(op_to_jsnumber));594 emitOpcode(op_to_jsnumber); 554 595 instructions().append(dst->index()); 555 596 instructions().append(src->index()); … … 559 600 RegisterID* CodeGenerator::emitNegate(RegisterID* dst, RegisterID* src) 560 601 { 561 instructions().append(machine().getOpcode(op_negate));602 emitOpcode(op_negate); 562 603 instructions().append(dst->index()); 563 604 instructions().append(src->index()); … … 567 608 RegisterID* CodeGenerator::emitAdd(RegisterID* dst, RegisterID* src1, RegisterID* src2) 568 609 { 569 instructions().append(machine().getOpcode(op_add));610 emitOpcode(op_add); 570 611 instructions().append(dst->index()); 571 612 instructions().append(src1->index()); … … 576 617 RegisterID* CodeGenerator::emitMul(RegisterID* dst, RegisterID* src1, RegisterID* src2) 577 618 { 578 instructions().append(machine().getOpcode(op_mul));619 emitOpcode(op_mul); 579 620 instructions().append(dst->index()); 580 621 instructions().append(src1->index()); … … 585 626 RegisterID* CodeGenerator::emitDiv(RegisterID* dst, RegisterID* dividend, RegisterID* divisor) 586 627 { 587 instructions().append(machine().getOpcode(op_div));628 emitOpcode(op_div); 588 629 instructions().append(dst->index()); 589 630 instructions().append(dividend->index()); … … 594 635 RegisterID* CodeGenerator::emitMod(RegisterID* dst, RegisterID* dividend, RegisterID* divisor) 595 636 { 596 instructions().append(machine().getOpcode(op_mod));637 emitOpcode(op_mod); 597 638 instructions().append(dst->index()); 598 639 instructions().append(dividend->index()); … … 603 644 RegisterID* CodeGenerator::emitSub(RegisterID* dst, RegisterID* src1, RegisterID* src2) 604 645 { 605 instructions().append(machine().getOpcode(op_sub));646 emitOpcode(op_sub); 606 647 instructions().append(dst->index()); 607 648 instructions().append(src1->index()); … … 612 653 RegisterID* CodeGenerator::emitLeftShift(RegisterID* dst, RegisterID* val, RegisterID* shift) 613 654 { 614 instructions().append(machine().getOpcode(op_lshift));655 emitOpcode(op_lshift); 615 656 instructions().append(dst->index()); 616 657 instructions().append(val->index()); … … 621 662 RegisterID* CodeGenerator::emitRightShift(RegisterID* dst, RegisterID* val, RegisterID* shift) 622 663 { 623 instructions().append(machine().getOpcode(op_rshift));664 emitOpcode(op_rshift); 624 665 instructions().append(dst->index()); 625 666 instructions().append(val->index()); … … 630 671 RegisterID* CodeGenerator::emitUnsignedRightShift(RegisterID* dst, RegisterID* val, RegisterID* shift) 631 672 { 632 instructions().append(machine().getOpcode(op_urshift));673 emitOpcode(op_urshift); 633 674 instructions().append(dst->index()); 634 675 instructions().append(val->index()); … … 639 680 RegisterID* CodeGenerator::emitBitAnd(RegisterID* dst, RegisterID* src1, RegisterID* src2) 640 681 { 641 instructions().append(machine().getOpcode(op_bitand));682 emitOpcode(op_bitand); 642 683 instructions().append(dst->index()); 643 684 instructions().append(src1->index()); … … 648 689 RegisterID* CodeGenerator::emitBitXOr(RegisterID* dst, RegisterID* src1, RegisterID* src2) 649 690 { 650 instructions().append(machine().getOpcode(op_bitxor));691 emitOpcode(op_bitxor); 651 692 instructions().append(dst->index()); 652 693 instructions().append(src1->index()); … … 657 698 RegisterID* CodeGenerator::emitBitOr(RegisterID* dst, RegisterID* src1, RegisterID* src2) 658 699 { 659 instructions().append(machine().getOpcode(op_bitor));700 emitOpcode(op_bitor); 660 701 instructions().append(dst->index()); 661 702 instructions().append(src1->index()); … … 666 707 RegisterID* CodeGenerator::emitBitNot(RegisterID* dst, RegisterID* src) 667 708 { 668 instructions().append(machine().getOpcode(op_bitnot));709 emitOpcode(op_bitnot); 669 710 instructions().append(dst->index()); 670 711 instructions().append(src->index()); … … 674 715 RegisterID* CodeGenerator::emitInstanceOf(RegisterID* dst, RegisterID* value, RegisterID* base) 675 716 { 676 instructions().append(machine().getOpcode(op_instanceof));717 emitOpcode(op_instanceof); 677 718 instructions().append(dst->index()); 678 719 instructions().append(value->index()); … … 683 724 RegisterID* CodeGenerator::emitTypeOf(RegisterID* dst, RegisterID* src) 684 725 { 685 instructions().append(machine().getOpcode(op_typeof));726 emitOpcode(op_typeof); 686 727 instructions().append(dst->index()); 687 728 instructions().append(src->index()); … … 691 732 RegisterID* CodeGenerator::emitIn(RegisterID* dst, RegisterID* property, RegisterID* base) 692 733 { 693 instructions().append(machine().getOpcode(op_in));734 emitOpcode(op_in); 694 735 instructions().append(dst->index()); 695 736 instructions().append(property->index()); … … 700 741 RegisterID* CodeGenerator::emitLoad(RegisterID* dst, bool b) 701 742 { 702 instructions().append(machine().getOpcode(op_load));743 emitOpcode(op_load); 703 744 instructions().append(dst->index()); 704 745 instructions().append(addConstant(jsBoolean(b))); … … 708 749 RegisterID* CodeGenerator::emitLoad(RegisterID* dst, double d) 709 750 { 710 instructions().append(machine().getOpcode(op_load));751 emitOpcode(op_load); 711 752 instructions().append(dst->index()); 712 753 instructions().append(addConstant(jsNumber(d))); … … 716 757 RegisterID* CodeGenerator::emitLoad(RegisterID* dst, JSValue* v) 717 758 { 718 instructions().append(machine().getOpcode(op_load));759 emitOpcode(op_load); 719 760 instructions().append(dst->index()); 720 761 instructions().append(addConstant(v)); … … 724 765 RegisterID* CodeGenerator::emitNewObject(RegisterID* dst) 725 766 { 726 instructions().append(machine().getOpcode(op_new_object));767 emitOpcode(op_new_object); 727 768 instructions().append(dst->index()); 728 769 return dst; … … 731 772 RegisterID* CodeGenerator::emitNewArray(RegisterID* dst) 732 773 { 733 instructions().append(machine().getOpcode(op_new_array));774 emitOpcode(op_new_array); 734 775 instructions().append(dst->index()); 735 776 return dst; … … 778 819 if (!findScopedProperty(property, index, depth)) { 779 820 // We can't optimise at all :-( 780 instructions().append(machine().getOpcode(op_resolve));821 emitOpcode(op_resolve); 781 822 instructions().append(dst->index()); 782 823 instructions().append(addConstant(property)); … … 787 828 // In this case we are at least able to drop a few scope chains from the 788 829 // lookup chain, although we still need to hash from then on. 789 instructions().append(machine().getOpcode(op_resolve_skip));830 emitOpcode(op_resolve_skip); 790 831 instructions().append(dst->index()); 791 832 instructions().append(addConstant(property)); … … 800 841 RegisterID* CodeGenerator::emitGetScopedVar(RegisterID* dst, size_t depth, int index) 801 842 { 802 instructions().append(machine().getOpcode(op_get_scoped_var));843 emitOpcode(op_get_scoped_var); 803 844 instructions().append(dst->index()); 804 845 instructions().append(index); … … 809 850 RegisterID* CodeGenerator::emitPutScopedVar(size_t depth, int index, RegisterID* value) 810 851 { 811 instructions().append(machine().getOpcode(op_put_scoped_var));852 emitOpcode(op_put_scoped_var); 812 853 instructions().append(index); 813 854 instructions().append(depth); … … 818 859 RegisterID* CodeGenerator::emitResolveBase(RegisterID* dst, const Identifier& property) 819 860 { 820 instructions().append(machine().getOpcode(op_resolve_base));861 emitOpcode(op_resolve_base); 821 862 instructions().append(dst->index()); 822 863 instructions().append(addConstant(property)); … … 826 867 RegisterID* CodeGenerator::emitResolveWithBase(RegisterID* baseDst, RegisterID* propDst, const Identifier& property) 827 868 { 828 instructions().append(machine().getOpcode(op_resolve_with_base));869 emitOpcode(op_resolve_with_base); 829 870 instructions().append(baseDst->index()); 830 871 instructions().append(propDst->index()); … … 835 876 RegisterID* CodeGenerator::emitResolveFunction(RegisterID* baseDst, RegisterID* funcDst, const Identifier& property) 836 877 { 837 instructions().append(machine().getOpcode(op_resolve_func));878 emitOpcode(op_resolve_func); 838 879 instructions().append(baseDst->index()); 839 880 instructions().append(funcDst->index()); … … 844 885 RegisterID* CodeGenerator::emitGetById(RegisterID* dst, RegisterID* base, const Identifier& property) 845 886 { 846 instructions().append(machine().getOpcode(op_get_by_id));887 emitOpcode(op_get_by_id); 847 888 instructions().append(dst->index()); 848 889 instructions().append(base->index()); … … 853 894 RegisterID* CodeGenerator::emitPutById(RegisterID* base, const Identifier& property, RegisterID* value) 854 895 { 855 instructions().append(machine().getOpcode(op_put_by_id));896 emitOpcode(op_put_by_id); 856 897 instructions().append(base->index()); 857 898 instructions().append(addConstant(property)); … … 862 903 RegisterID* CodeGenerator::emitPutGetter(RegisterID* base, const Identifier& property, RegisterID* value) 863 904 { 864 instructions().append(machine().getOpcode(op_put_getter));905 emitOpcode(op_put_getter); 865 906 instructions().append(base->index()); 866 907 instructions().append(addConstant(property)); … … 871 912 RegisterID* CodeGenerator::emitPutSetter(RegisterID* base, const Identifier& property, RegisterID* value) 872 913 { 873 instructions().append(machine().getOpcode(op_put_setter));914 emitOpcode(op_put_setter); 874 915 instructions().append(base->index()); 875 916 instructions().append(addConstant(property)); … … 880 921 RegisterID* CodeGenerator::emitDeleteById(RegisterID* dst, RegisterID* base, const Identifier& property) 881 922 { 882 instructions().append(machine().getOpcode(op_del_by_id));923 emitOpcode(op_del_by_id); 883 924 instructions().append(dst->index()); 884 925 instructions().append(base->index()); … … 889 930 RegisterID* CodeGenerator::emitGetByVal(RegisterID* dst, RegisterID* base, RegisterID* property) 890 931 { 891 instructions().append(machine().getOpcode(op_get_by_val));932 emitOpcode(op_get_by_val); 892 933 instructions().append(dst->index()); 893 934 instructions().append(base->index()); … … 898 939 RegisterID* CodeGenerator::emitPutByVal(RegisterID* base, RegisterID* property, RegisterID* value) 899 940 { 900 instructions().append(machine().getOpcode(op_put_by_val));941 emitOpcode(op_put_by_val); 901 942 instructions().append(base->index()); 902 943 instructions().append(property->index()); … … 907 948 RegisterID* CodeGenerator::emitDeleteByVal(RegisterID* dst, RegisterID* base, RegisterID* property) 908 949 { 909 instructions().append(machine().getOpcode(op_del_by_val));950 emitOpcode(op_del_by_val); 910 951 instructions().append(dst->index()); 911 952 instructions().append(base->index()); … … 916 957 RegisterID* CodeGenerator::emitPutByIndex(RegisterID* base, unsigned index, RegisterID* value) 917 958 { 918 instructions().append(machine().getOpcode(op_put_by_index));959 emitOpcode(op_put_by_index); 919 960 instructions().append(base->index()); 920 961 instructions().append(index); … … 925 966 RegisterID* CodeGenerator::emitNewFunction(RegisterID* r0, FuncDeclNode* n) 926 967 { 927 instructions().append(machine().getOpcode(op_new_func));968 emitOpcode(op_new_func); 928 969 instructions().append(r0->index()); 929 970 instructions().append(addConstant(n)); … … 933 974 RegisterID* CodeGenerator::emitNewRegExp(RegisterID* dst, RegExp* regExp) 934 975 { 935 instructions().append(machine().getOpcode(op_new_regexp));976 emitOpcode(op_new_regexp); 936 977 instructions().append(dst->index()); 937 978 instructions().append(addRegExp(regExp)); … … 942 983 RegisterID* CodeGenerator::emitNewFunctionExpression(RegisterID* r0, FuncExprNode* n) 943 984 { 944 instructions().append(machine().getOpcode(op_new_func_exp));985 emitOpcode(op_new_func_exp); 945 986 instructions().append(r0->index()); 946 987 instructions().append(addConstant(n)); … … 978 1019 } 979 1020 980 instructions().append(machine().getOpcode(opcodeID));1021 emitOpcode(opcodeID); 981 1022 instructions().append(dst->index()); 982 1023 instructions().append(func->index()); … … 989 1030 RegisterID* CodeGenerator::emitReturn(RegisterID* r0) 990 1031 { 991 instructions().append(machine().getOpcode(op_ret));1032 emitOpcode(op_ret); 992 1033 instructions().append(r0->index()); 993 1034 return r0; … … 996 1037 RegisterID* CodeGenerator::emitEnd(RegisterID* dst) 997 1038 { 998 instructions().append(machine().getOpcode(op_end));1039 emitOpcode(op_end); 999 1040 instructions().append(dst->index()); 1000 1041 return dst; … … 1016 1057 } 1017 1058 1018 instructions().append(machine().getOpcode(op_construct));1059 emitOpcode(op_construct); 1019 1060 instructions().append(dst->index()); 1020 1061 instructions().append(func->index()); … … 1027 1068 { 1028 1069 m_codeBlock->needsFullScopeChain = true; 1029 instructions().append(machine().getOpcode(op_push_scope));1070 emitOpcode(op_push_scope); 1030 1071 instructions().append(scope->index()); 1031 1072 … … 1042 1083 ASSERT(!m_scopeContextStack.last().isFinallyBlock); 1043 1084 1044 instructions().append(machine().getOpcode(op_pop_scope));1085 emitOpcode(op_pop_scope); 1045 1086 1046 1087 m_scopeContextStack.removeLast(); … … 1052 1093 if (!m_shouldEmitDebugHooks) 1053 1094 return; 1054 instructions().append(machine().getOpcode(op_debug));1095 emitOpcode(op_debug); 1055 1096 instructions().append(debugHookID); 1056 1097 instructions().append(firstLine); … … 1153 1194 // We need to remove a number of dynamic scopes to get to the next 1154 1195 // finally block 1155 instructions().append(machine().getOpcode(op_jmp_scopes));1196 emitOpcode(op_jmp_scopes); 1156 1197 instructions().append(nNormalScopes); 1157 1198 … … 1194 1235 return emitComplexJumpScopes(target, &m_scopeContextStack.last(), &m_scopeContextStack.last() - scopeDelta); 1195 1236 1196 instructions().append(machine().getOpcode(op_jmp_scopes));1237 emitOpcode(op_jmp_scopes); 1197 1238 instructions().append(scopeDelta); 1198 1239 instructions().append(target->offsetFrom(instructions().size())); … … 1202 1243 RegisterID* CodeGenerator::emitNextPropertyName(RegisterID* dst, RegisterID* iter, LabelID* target) 1203 1244 { 1204 instructions().append(machine().getOpcode(op_next_pname));1245 emitOpcode(op_next_pname); 1205 1246 instructions().append(dst->index()); 1206 1247 instructions().append(iter->index()); … … 1211 1252 RegisterID* CodeGenerator::emitGetPropertyNames(RegisterID* dst, RegisterID* base) 1212 1253 { 1213 instructions().append(machine().getOpcode(op_get_pnames));1254 emitOpcode(op_get_pnames); 1214 1255 instructions().append(dst->index()); 1215 1256 instructions().append(base->index()); … … 1221 1262 HandlerInfo info = { start->offsetFrom(0), end->offsetFrom(0), instructions().size(), m_dynamicScopeDepth }; 1222 1263 exceptionHandlers().append(info); 1223 instructions().append(machine().getOpcode(op_catch));1264 emitOpcode(op_catch); 1224 1265 instructions().append(targetRegister->index()); 1225 1266 return targetRegister; … … 1228 1269 void CodeGenerator::emitThrow(RegisterID* exception) 1229 1270 { 1230 instructions().append(machine().getOpcode(op_throw));1271 emitOpcode(op_throw); 1231 1272 instructions().append(exception->index()); 1232 1273 } … … 1234 1275 RegisterID* CodeGenerator::emitNewError(RegisterID* dst, ErrorType type, JSValue* message) 1235 1276 { 1236 instructions().append(machine().getOpcode(op_new_error));1277 emitOpcode(op_new_error); 1237 1278 instructions().append(dst->index()); 1238 1279 instructions().append(static_cast<int>(type)); … … 1243 1284 PassRefPtr<LabelID> CodeGenerator::emitJumpSubroutine(RegisterID* retAddrDst, LabelID* finally) 1244 1285 { 1245 instructions().append(machine().getOpcode(op_jsr));1286 emitOpcode(op_jsr); 1246 1287 instructions().append(retAddrDst->index()); 1247 1288 instructions().append(finally->offsetFrom(instructions().size())); … … 1251 1292 void CodeGenerator::emitSubroutineReturn(RegisterID* retAddrSrc) 1252 1293 { 1253 instructions().append(machine().getOpcode(op_sret));1294 emitOpcode(op_sret); 1254 1295 instructions().append(retAddrSrc->index()); 1255 1296 } -
trunk/JavaScriptCore/VM/CodeGenerator.h
r34412 r34497 294 294 295 295 private: 296 void emitOpcode(OpcodeID); 297 void retrieveLastBinaryOp(int& dstIndex, int& src1Index, int& src2Index); 298 void rewindBinaryOp(); 299 296 300 PassRefPtr<LabelID> emitComplexJumpScopes(LabelID* target, ControlFlowContext* topScope, ControlFlowContext* bottomScope); 297 301 struct JSValueHashTraits : HashTraits<JSValue*> { … … 374 378 const CommonIdentifiers* m_propertyNames; 375 379 380 OpcodeID m_lastOpcodeID; 381 376 382 #ifndef NDEBUG 377 383 static bool s_dumpsGeneratedCode; -
trunk/JavaScriptCore/VM/Machine.cpp
r34457 r34497 1913 1913 NEXT_OPCODE; 1914 1914 } 1915 BEGIN_OPCODE(op_jless) { 1916 /* jless src1(r) src2(r) target(offset) 1917 1918 Checks whether register src1 is less than register src2, as 1919 with the ECMAScript '<' operator, and then jumps to offset 1920 target from the current instruction, if and only if the 1921 result of the comparison is true. 1922 */ 1923 JSValue* src1 = r[(++vPC)->u.operand].u.jsValue; 1924 JSValue* src2 = r[(++vPC)->u.operand].u.jsValue; 1925 int target = (++vPC)->u.operand; 1926 1927 bool result = jsLess(exec, src1, src2); 1928 VM_CHECK_EXCEPTION(); 1929 1930 if (result) { 1931 vPC += target; 1932 NEXT_OPCODE; 1933 } 1934 1935 ++vPC; 1936 NEXT_OPCODE; 1937 } 1915 1938 BEGIN_OPCODE(op_new_func) { 1916 1939 /* new_func dst(r) func(f) -
trunk/JavaScriptCore/VM/Opcode.cpp
r34411 r34497 104 104 "jtrue", 105 105 "jfalse", 106 "jless", 106 107 "jmp_scopes", 107 108 -
trunk/JavaScriptCore/VM/Opcode.h
r34411 r34497 96 96 macro(op_jtrue) \ 97 97 macro(op_jfalse) \ 98 macro(op_jless) \ 98 99 macro(op_jmp_scopes) \ 99 100 \
Note: See TracChangeset
for help on using the changeset viewer.