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 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
607 safepoint.DefinePointerSlot(pointer->index()); | 607 safepoint.DefinePointerSlot(pointer->index()); |
608 } else if (pointer->IsRegister()) { | 608 } else if (pointer->IsRegister()) { |
609 safepoint.DefinePointerRegister(ToRegister(pointer)); | 609 safepoint.DefinePointerRegister(ToRegister(pointer)); |
610 } | 610 } |
611 } | 611 } |
612 // Register cp always contains a pointer to the context. | 612 // Register cp always contains a pointer to the context. |
613 safepoint.DefinePointerRegister(cp); | 613 safepoint.DefinePointerRegister(cp); |
614 } | 614 } |
615 | 615 |
616 | 616 |
617 void LCodeGen::RecordSafepointWithRegistersAndDoubles( | |
618 LPointerMap* pointers, | |
619 int arguments, | |
620 int deoptimization_index) { | |
621 const ZoneList<LOperand*>* operands = pointers->operands(); | |
622 Safepoint safepoint = | |
623 safepoints_.DefineSafepointWithRegistersAndDoubles( | |
624 masm(), arguments, deoptimization_index); | |
625 for (int i = 0; i < operands->length(); i++) { | |
626 LOperand* pointer = operands->at(i); | |
627 if (pointer->IsStackSlot()) { | |
628 safepoint.DefinePointerSlot(pointer->index()); | |
629 } else if (pointer->IsRegister()) { | |
630 safepoint.DefinePointerRegister(ToRegister(pointer)); | |
631 } | |
632 } | |
633 // Register cp always contains a pointer to the context. | |
634 safepoint.DefinePointerRegister(cp); | |
635 } | |
636 | |
637 | |
617 void LCodeGen::RecordPosition(int position) { | 638 void LCodeGen::RecordPosition(int position) { |
618 if (!FLAG_debug_info || position == RelocInfo::kNoPosition) return; | 639 if (!FLAG_debug_info || position == RelocInfo::kNoPosition) return; |
619 masm()->positions_recorder()->RecordPosition(position); | 640 masm()->positions_recorder()->RecordPosition(position); |
620 } | 641 } |
621 | 642 |
622 | 643 |
623 void LCodeGen::DoLabel(LLabel* label) { | 644 void LCodeGen::DoLabel(LLabel* label) { |
624 if (label->is_loop_header()) { | 645 if (label->is_loop_header()) { |
625 Comment(";;; B%d - LOOP entry", label->block_id()); | 646 Comment(";;; B%d - LOOP entry", label->block_id()); |
626 } else { | 647 } else { |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
825 // Nothing to do. | 846 // Nothing to do. |
826 } | 847 } |
827 | 848 |
828 | 849 |
829 void LCodeGen::DoModI(LModI* instr) { | 850 void LCodeGen::DoModI(LModI* instr) { |
830 Abort("DoModI unimplemented."); | 851 Abort("DoModI unimplemented."); |
831 } | 852 } |
832 | 853 |
833 | 854 |
834 void LCodeGen::DoDivI(LDivI* instr) { | 855 void LCodeGen::DoDivI(LDivI* instr) { |
835 Abort("DoDivI unimplemented."); | 856 class DeferredDivI: public LDeferredCode { |
857 public: | |
858 DeferredDivI(LCodeGen* codegen, LDivI* instr) | |
859 : LDeferredCode(codegen), instr_(instr) { } | |
860 virtual void Generate() { codegen()->DoDeferredDivI(instr_); } | |
861 private: | |
862 LDivI* instr_; | |
863 }; | |
864 | |
865 const Register left = ToRegister(instr->left()); | |
866 const Register right = ToRegister(instr->right()); | |
867 const Register scratch = scratch0(); | |
868 const Register result = ToRegister(instr->result()); | |
869 | |
870 // Check for x / 0. | |
871 if (instr->hydrogen()->CheckFlag(HValue::kCanBeDivByZero)) { | |
872 __ tst(right, right); | |
873 DeoptimizeIf(eq, instr->environment()); | |
874 } | |
875 | |
876 // Check for (0 / -x) that will produce negative zero. | |
877 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | |
878 Label left_not_zero; | |
879 __ tst(left, Operand(left)); | |
880 __ b(ne, &left_not_zero); | |
881 __ tst(right, Operand(right)); | |
882 DeoptimizeIf(mi, instr->environment()); | |
883 __ bind(&left_not_zero); | |
884 } | |
885 | |
886 // Check for (-kMinInt / -1). | |
887 if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) { | |
888 Label left_not_min_int; | |
889 __ cmp(left, Operand(kMinInt)); | |
890 __ b(ne, &left_not_min_int); | |
891 __ cmp(right, Operand(-1)); | |
892 DeoptimizeIf(eq, instr->environment()); | |
893 __ bind(&left_not_min_int); | |
894 } | |
895 | |
896 Label done, deoptimize; | |
897 // Test for a few common cases first. | |
898 __ cmp(right, Operand(1)); | |
899 __ mov(result, left, LeaveCC, eq); | |
900 __ b(eq, &done); | |
901 | |
902 __ cmp(right, Operand(2)); | |
903 __ tst(left, Operand(1), eq); | |
904 __ mov(result, Operand(left, ASR, 1), LeaveCC, eq); | |
905 __ b(eq, &done); | |
906 | |
907 __ cmp(right, Operand(4)); | |
908 __ tst(left, Operand(3), eq); | |
909 __ mov(result, Operand(left, ASR, 2), LeaveCC, eq); | |
910 __ b(eq, &done); | |
911 | |
912 // Call the generic stub. The numbers in r0 and r1 have | |
913 // to be tagged to Smis. If that is not possible, deoptimize. | |
914 DeferredDivI* deferred = new DeferredDivI(this, instr); | |
915 | |
916 __ TrySmiTag(left, &deoptimize, scratch); | |
917 __ TrySmiTag(right, &deoptimize, scratch); | |
918 | |
919 __ b(al, deferred->entry()); | |
920 __ bind(deferred->exit()); | |
921 | |
922 // If the result in r0 is a Smi, untag it, else deoptimize. | |
923 __ BranchOnNotSmi(result, &deoptimize); | |
924 __ SmiUntag(result); | |
925 __ b(&done); | |
926 | |
927 __ bind(&deoptimize); | |
928 DeoptimizeIf(al, instr->environment()); | |
929 __ bind(&done); | |
836 } | 930 } |
837 | 931 |
838 | 932 |
933 void LCodeGen::DoDeferredDivI(LDivI* instr) { | |
934 Register left = ToRegister(instr->left()); | |
935 Register right = ToRegister(instr->right()); | |
936 | |
937 __ PushSafepointRegistersAndDoubles(); | |
938 GenericBinaryOpStub stub(Token::DIV, OVERWRITE_LEFT, left, right); | |
939 __ CallStub(&stub); | |
940 RecordSafepointWithRegisters(instr->pointer_map(), | |
941 0, | |
942 Safepoint::kNoDeoptimizationIndex); | |
943 __ str(r0, MemOperand(sp, DwVfpRegister::kNumAllocatableRegisters * | |
Søren Thygesen Gjesse
2011/01/13 15:38:29
I think this deserves at least a comment. On http:
| |
944 kDoubleSize)); | |
945 __ PopSafepointRegistersAndDoubles(); | |
946 } | |
947 | |
948 | |
839 void LCodeGen::DoMulI(LMulI* instr) { | 949 void LCodeGen::DoMulI(LMulI* instr) { |
840 Register scratch = scratch0(); | 950 Register scratch = scratch0(); |
841 Register left = ToRegister(instr->left()); | 951 Register left = ToRegister(instr->left()); |
842 Register right = EmitLoadRegister(instr->right(), scratch); | 952 Register right = EmitLoadRegister(instr->right(), scratch); |
843 | 953 |
844 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero) && | 954 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero) && |
845 !instr->right()->IsConstantOperand()) { | 955 !instr->right()->IsConstantOperand()) { |
846 __ orr(ToRegister(instr->temp()), left, right); | 956 __ orr(ToRegister(instr->temp()), left, right); |
847 } | 957 } |
848 | 958 |
(...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2503 DeoptimizeIf(ne, instr->environment()); | 2613 DeoptimizeIf(ne, instr->environment()); |
2504 } | 2614 } |
2505 | 2615 |
2506 | 2616 |
2507 void LCodeGen::LoadPrototype(Register result, | 2617 void LCodeGen::LoadPrototype(Register result, |
2508 Handle<JSObject> prototype) { | 2618 Handle<JSObject> prototype) { |
2509 if (Heap::InNewSpace(*prototype)) { | 2619 if (Heap::InNewSpace(*prototype)) { |
2510 Handle<JSGlobalPropertyCell> cell = | 2620 Handle<JSGlobalPropertyCell> cell = |
2511 Factory::NewJSGlobalPropertyCell(prototype); | 2621 Factory::NewJSGlobalPropertyCell(prototype); |
2512 __ mov(result, Operand(cell)); | 2622 __ mov(result, Operand(cell)); |
2513 __ ldr(result, FieldMemOperand(result, JSGlobalPropertyCell::kValueOffset)); | |
Søren Thygesen Gjesse
2011/01/13 15:38:29
Accidental edit?
| |
2514 } else { | 2623 } else { |
2515 __ mov(result, Operand(prototype)); | 2624 __ mov(result, Operand(prototype)); |
2516 } | 2625 } |
2517 } | 2626 } |
2518 | 2627 |
2519 | 2628 |
2520 void LCodeGen::DoCheckPrototypeMaps(LCheckPrototypeMaps* instr) { | 2629 void LCodeGen::DoCheckPrototypeMaps(LCheckPrototypeMaps* instr) { |
2521 Register temp1 = ToRegister(instr->temp1()); | 2630 Register temp1 = ToRegister(instr->temp1()); |
2522 Register temp2 = ToRegister(instr->temp2()); | 2631 Register temp2 = ToRegister(instr->temp2()); |
2523 | 2632 |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2830 | 2939 |
2831 | 2940 |
2832 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { | 2941 void LCodeGen::DoOsrEntry(LOsrEntry* instr) { |
2833 Abort("DoOsrEntry unimplemented."); | 2942 Abort("DoOsrEntry unimplemented."); |
2834 } | 2943 } |
2835 | 2944 |
2836 | 2945 |
2837 #undef __ | 2946 #undef __ |
2838 | 2947 |
2839 } } // namespace v8::internal | 2948 } } // namespace v8::internal |
OLD | NEW |