OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
487 } | 487 } |
488 | 488 |
489 | 489 |
490 // Defined in ic.cc. | 490 // Defined in ic.cc. |
491 Object* CallIC_Miss(Arguments args); | 491 Object* CallIC_Miss(Arguments args); |
492 | 492 |
493 // The generated code does not accept smi keys. | 493 // The generated code does not accept smi keys. |
494 // The generated code falls through if both probes miss. | 494 // The generated code falls through if both probes miss. |
495 static void GenerateMonomorphicCacheProbe(MacroAssembler* masm, | 495 static void GenerateMonomorphicCacheProbe(MacroAssembler* masm, |
496 int argc, | 496 int argc, |
497 Code::Kind kind) { | 497 Code::Kind kind, |
| 498 Code::ExtraICState extra_ic_state) { |
498 // ----------- S t a t e ------------- | 499 // ----------- S t a t e ------------- |
499 // -- a1 : receiver | 500 // -- a1 : receiver |
500 // -- a2 : name | 501 // -- a2 : name |
501 // ----------------------------------- | 502 // ----------------------------------- |
502 Label number, non_number, non_string, boolean, probe, miss; | 503 Label number, non_number, non_string, boolean, probe, miss; |
503 | 504 |
504 // Probe the stub cache. | 505 // Probe the stub cache. |
505 Code::Flags flags = Code::ComputeFlags(kind, | 506 Code::Flags flags = Code::ComputeFlags(kind, |
506 NOT_IN_LOOP, | 507 NOT_IN_LOOP, |
507 MONOMORPHIC, | 508 MONOMORPHIC, |
508 Code::kNoExtraICState, | 509 extra_ic_state, |
509 NORMAL, | 510 NORMAL, |
510 argc); | 511 argc); |
511 Isolate::Current()->stub_cache()->GenerateProbe( | 512 Isolate::Current()->stub_cache()->GenerateProbe( |
512 masm, flags, a1, a2, a3, t0, t1); | 513 masm, flags, a1, a2, a3, t0, t1); |
513 | 514 |
514 // If the stub cache probing failed, the receiver might be a value. | 515 // If the stub cache probing failed, the receiver might be a value. |
515 // For value objects, we use the map of the prototype objects for | 516 // For value objects, we use the map of the prototype objects for |
516 // the corresponding JSValue for the cache and that is what we need | 517 // the corresponding JSValue for the cache and that is what we need |
517 // to probe. | 518 // to probe. |
518 // | 519 // |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 // Search the dictionary - put result in register a1. | 587 // Search the dictionary - put result in register a1. |
587 GenerateDictionaryLoad(masm, &miss, a0, a2, a1, a3, t0); | 588 GenerateDictionaryLoad(masm, &miss, a0, a2, a1, a3, t0); |
588 | 589 |
589 GenerateFunctionTailCall(masm, argc, &miss, t0); | 590 GenerateFunctionTailCall(masm, argc, &miss, t0); |
590 | 591 |
591 // Cache miss: Jump to runtime. | 592 // Cache miss: Jump to runtime. |
592 __ bind(&miss); | 593 __ bind(&miss); |
593 } | 594 } |
594 | 595 |
595 | 596 |
596 static void GenerateCallMiss(MacroAssembler* masm, int argc, IC::UtilityId id) { | 597 static void GenerateCallMiss(MacroAssembler* masm, |
| 598 int argc, |
| 599 IC::UtilityId id, |
| 600 Code::ExtraICState extra_ic_state) { |
597 // ----------- S t a t e ------------- | 601 // ----------- S t a t e ------------- |
598 // -- a2 : name | 602 // -- a2 : name |
599 // -- ra : return address | 603 // -- ra : return address |
600 // ----------------------------------- | 604 // ----------------------------------- |
601 Isolate* isolate = masm->isolate(); | 605 Isolate* isolate = masm->isolate(); |
602 | 606 |
603 if (id == IC::kCallIC_Miss) { | 607 if (id == IC::kCallIC_Miss) { |
604 __ IncrementCounter(isolate->counters()->call_miss(), 1, a3, t0); | 608 __ IncrementCounter(isolate->counters()->call_miss(), 1, a3, t0); |
605 } else { | 609 } else { |
606 __ IncrementCounter(isolate->counters()->keyed_call_miss(), 1, a3, t0); | 610 __ IncrementCounter(isolate->counters()->keyed_call_miss(), 1, a3, t0); |
(...skipping 29 matching lines...) Expand all Loading... |
636 __ Branch(&global, eq, a3, Operand(JS_GLOBAL_OBJECT_TYPE)); | 640 __ Branch(&global, eq, a3, Operand(JS_GLOBAL_OBJECT_TYPE)); |
637 __ Branch(&invoke, ne, a3, Operand(JS_BUILTINS_OBJECT_TYPE)); | 641 __ Branch(&invoke, ne, a3, Operand(JS_BUILTINS_OBJECT_TYPE)); |
638 | 642 |
639 // Patch the receiver on the stack. | 643 // Patch the receiver on the stack. |
640 __ bind(&global); | 644 __ bind(&global); |
641 __ lw(a2, FieldMemOperand(a2, GlobalObject::kGlobalReceiverOffset)); | 645 __ lw(a2, FieldMemOperand(a2, GlobalObject::kGlobalReceiverOffset)); |
642 __ sw(a2, MemOperand(sp, argc * kPointerSize)); | 646 __ sw(a2, MemOperand(sp, argc * kPointerSize)); |
643 __ bind(&invoke); | 647 __ bind(&invoke); |
644 } | 648 } |
645 // Invoke the function. | 649 // Invoke the function. |
| 650 CallKind call_kind = CallICBase::Contextual::decode(extra_ic_state) |
| 651 ? CALL_AS_FUNCTION |
| 652 : CALL_AS_METHOD; |
646 ParameterCount actual(argc); | 653 ParameterCount actual(argc); |
647 __ InvokeFunction(a1, actual, JUMP_FUNCTION); | 654 __ InvokeFunction(a1, |
| 655 actual, |
| 656 JUMP_FUNCTION, |
| 657 NullCallWrapper(), |
| 658 call_kind); |
648 } | 659 } |
649 | 660 |
650 | 661 |
651 void CallIC::GenerateMiss(MacroAssembler* masm, int argc) { | 662 void CallIC::GenerateMiss(MacroAssembler* masm, |
| 663 int argc, |
| 664 Code::ExtraICState extra_ic_state) { |
652 // ----------- S t a t e ------------- | 665 // ----------- S t a t e ------------- |
653 // -- a2 : name | 666 // -- a2 : name |
654 // -- ra : return address | 667 // -- ra : return address |
655 // ----------------------------------- | 668 // ----------------------------------- |
656 | 669 |
657 GenerateCallMiss(masm, argc, IC::kCallIC_Miss); | 670 GenerateCallMiss(masm, argc, IC::kCallIC_Miss, extra_ic_state); |
658 } | 671 } |
659 | 672 |
660 | 673 |
661 void CallIC::GenerateMegamorphic(MacroAssembler* masm, int argc) { | 674 void CallIC::GenerateMegamorphic(MacroAssembler* masm, |
| 675 int argc, |
| 676 Code::ExtraICState extra_ic_state) { |
662 // ----------- S t a t e ------------- | 677 // ----------- S t a t e ------------- |
663 // -- a2 : name | 678 // -- a2 : name |
664 // -- ra : return address | 679 // -- ra : return address |
665 // ----------------------------------- | 680 // ----------------------------------- |
666 | 681 |
667 // Get the receiver of the function from the stack into a1. | 682 // Get the receiver of the function from the stack into a1. |
668 __ lw(a1, MemOperand(sp, argc * kPointerSize)); | 683 __ lw(a1, MemOperand(sp, argc * kPointerSize)); |
669 GenerateMonomorphicCacheProbe(masm, argc, Code::CALL_IC); | 684 GenerateMonomorphicCacheProbe(masm, argc, Code::CALL_IC, extra_ic_state); |
670 GenerateMiss(masm, argc); | 685 GenerateMiss(masm, argc, extra_ic_state); |
671 } | 686 } |
672 | 687 |
673 | 688 |
674 void CallIC::GenerateNormal(MacroAssembler* masm, int argc) { | 689 void CallIC::GenerateNormal(MacroAssembler* masm, int argc) { |
675 // ----------- S t a t e ------------- | 690 // ----------- S t a t e ------------- |
676 // -- a2 : name | 691 // -- a2 : name |
677 // -- ra : return address | 692 // -- ra : return address |
678 // ----------------------------------- | 693 // ----------------------------------- |
679 | 694 |
680 GenerateCallNormal(masm, argc); | 695 GenerateCallNormal(masm, argc); |
681 GenerateMiss(masm, argc); | 696 GenerateMiss(masm, argc, Code::kNoExtraICState); |
682 } | 697 } |
683 | 698 |
684 | 699 |
685 void KeyedCallIC::GenerateMiss(MacroAssembler* masm, int argc) { | 700 void KeyedCallIC::GenerateMiss(MacroAssembler* masm, int argc) { |
686 // ----------- S t a t e ------------- | 701 // ----------- S t a t e ------------- |
687 // -- a2 : name | 702 // -- a2 : name |
688 // -- ra : return address | 703 // -- ra : return address |
689 // ----------------------------------- | 704 // ----------------------------------- |
690 | 705 |
691 GenerateCallMiss(masm, argc, IC::kKeyedCallIC_Miss); | 706 GenerateCallMiss(masm, argc, IC::kKeyedCallIC_Miss, Code::kNoExtraICState); |
692 } | 707 } |
693 | 708 |
694 | 709 |
695 void KeyedCallIC::GenerateMegamorphic(MacroAssembler* masm, int argc) { | 710 void KeyedCallIC::GenerateMegamorphic(MacroAssembler* masm, int argc) { |
696 // ----------- S t a t e ------------- | 711 // ----------- S t a t e ------------- |
697 // -- a2 : name | 712 // -- a2 : name |
698 // -- ra : return address | 713 // -- ra : return address |
699 // ----------------------------------- | 714 // ----------------------------------- |
700 | 715 |
701 // Get the receiver of the function from the stack into a1. | 716 // Get the receiver of the function from the stack into a1. |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 __ lw(a3, FieldMemOperand(a0, HeapObject::kMapOffset)); | 781 __ lw(a3, FieldMemOperand(a0, HeapObject::kMapOffset)); |
767 __ LoadRoot(at, Heap::kHashTableMapRootIndex); | 782 __ LoadRoot(at, Heap::kHashTableMapRootIndex); |
768 __ Branch(&lookup_monomorphic_cache, ne, a3, Operand(at)); | 783 __ Branch(&lookup_monomorphic_cache, ne, a3, Operand(at)); |
769 | 784 |
770 GenerateDictionaryLoad(masm, &slow_load, a0, a2, a1, a3, t0); | 785 GenerateDictionaryLoad(masm, &slow_load, a0, a2, a1, a3, t0); |
771 __ IncrementCounter(counters->keyed_call_generic_lookup_dict(), 1, a0, a3); | 786 __ IncrementCounter(counters->keyed_call_generic_lookup_dict(), 1, a0, a3); |
772 __ jmp(&do_call); | 787 __ jmp(&do_call); |
773 | 788 |
774 __ bind(&lookup_monomorphic_cache); | 789 __ bind(&lookup_monomorphic_cache); |
775 __ IncrementCounter(counters->keyed_call_generic_lookup_cache(), 1, a0, a3); | 790 __ IncrementCounter(counters->keyed_call_generic_lookup_cache(), 1, a0, a3); |
776 GenerateMonomorphicCacheProbe(masm, argc, Code::KEYED_CALL_IC); | 791 GenerateMonomorphicCacheProbe(masm, |
| 792 argc, |
| 793 Code::KEYED_CALL_IC, |
| 794 Code::kNoExtraICState); |
777 // Fall through on miss. | 795 // Fall through on miss. |
778 | 796 |
779 __ bind(&slow_call); | 797 __ bind(&slow_call); |
780 // This branch is taken if: | 798 // This branch is taken if: |
781 // - the receiver requires boxing or access check, | 799 // - the receiver requires boxing or access check, |
782 // - the key is neither smi nor symbol, | 800 // - the key is neither smi nor symbol, |
783 // - the value loaded is not a function, | 801 // - the value loaded is not a function, |
784 // - there is hope that the runtime will create a monomorphic call stub, | 802 // - there is hope that the runtime will create a monomorphic call stub, |
785 // that will get fetched next time. | 803 // that will get fetched next time. |
786 __ IncrementCounter(counters->keyed_call_generic_slow(), 1, a0, a3); | 804 __ IncrementCounter(counters->keyed_call_generic_slow(), 1, a0, a3); |
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1553 Register reg = Register::from_code(Assembler::GetRs(instr_at_patch)); | 1571 Register reg = Register::from_code(Assembler::GetRs(instr_at_patch)); |
1554 patcher.masm()->andi(at, reg, kSmiTagMask); | 1572 patcher.masm()->andi(at, reg, kSmiTagMask); |
1555 patcher.ChangeBranchCondition(eq); | 1573 patcher.ChangeBranchCondition(eq); |
1556 } | 1574 } |
1557 } | 1575 } |
1558 | 1576 |
1559 | 1577 |
1560 } } // namespace v8::internal | 1578 } } // namespace v8::internal |
1561 | 1579 |
1562 #endif // V8_TARGET_ARCH_MIPS | 1580 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |