| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 : graph()->GetConstantUndefined(); | 805 : graph()->GetConstantUndefined(); |
| 806 } | 806 } |
| 807 | 807 |
| 808 | 808 |
| 809 Handle<Code> CompareNilICStub::GenerateCode(Isolate* isolate) { | 809 Handle<Code> CompareNilICStub::GenerateCode(Isolate* isolate) { |
| 810 return DoGenerateCode(isolate, this); | 810 return DoGenerateCode(isolate, this); |
| 811 } | 811 } |
| 812 | 812 |
| 813 | 813 |
| 814 template <> | 814 template <> |
| 815 HValue* CodeStubGraphBuilder<BinaryOpStub>::BuildCodeInitializedStub() { |
| 816 BinaryOpStub* stub = casted_stub(); |
| 817 HValue* left = GetParameter(0); |
| 818 HValue* right = GetParameter(1); |
| 819 |
| 820 Handle<Type> left_type = stub->GetLeftType(isolate()); |
| 821 Handle<Type> right_type = stub->GetRightType(isolate()); |
| 822 Handle<Type> result_type = stub->GetResultType(isolate()); |
| 823 |
| 824 HValue* res = NULL; |
| 825 if (stub->operation() == Token::ADD && |
| 826 (left_type->Maybe(Type::String()) || right_type->Maybe(Type::String())) && |
| 827 !left_type->Is(Type::String()) && !right_type->Is(Type::String())) { |
| 828 // For the generic add stub a fast case for String add is performance |
| 829 // critical. |
| 830 if (left_type->Maybe(Type::String())) { |
| 831 IfBuilder left_string(this); |
| 832 left_string.IfNot<HIsSmiAndBranch>(left); |
| 833 left_string.AndIf<HIsStringAndBranch>(left); |
| 834 left_string.Then(); |
| 835 Push(Add<HStringAdd>(left, right, STRING_ADD_CHECK_RIGHT)); |
| 836 left_string.Else(); |
| 837 Push(AddInstruction(BuildBinaryOperation(stub->operation(), |
| 838 left, right, left_type, right_type, result_type, |
| 839 stub->fixed_right_arg(), context()))); |
| 840 left_string.End(); |
| 841 res = Pop(); |
| 842 } else { |
| 843 IfBuilder right_string(this); |
| 844 right_string.IfNot<HIsSmiAndBranch>(right); |
| 845 right_string.AndIf<HIsStringAndBranch>(right); |
| 846 right_string.Then(); |
| 847 Push(Add<HStringAdd>(left, right, STRING_ADD_CHECK_LEFT)); |
| 848 right_string.Else(); |
| 849 Push(AddInstruction(BuildBinaryOperation(stub->operation(), |
| 850 left, right, left_type, right_type, result_type, |
| 851 stub->fixed_right_arg(), context()))); |
| 852 right_string.End(); |
| 853 res = Pop(); |
| 854 } |
| 855 } else { |
| 856 res = AddInstruction(BuildBinaryOperation(stub->operation(), |
| 857 left, right, left_type, right_type, result_type, |
| 858 stub->fixed_right_arg(), context())); |
| 859 } |
| 860 |
| 861 // If we encounter a generic argument, the number conversion is |
| 862 // observable, thus we cannot afford to bail out after the fact. |
| 863 if (!stub->HasSideEffects(isolate())) { |
| 864 if (result_type->Is(Type::Smi())) { |
| 865 if (stub->operation() == Token::SHR) { |
| 866 // TODO(olivf) Replace this by a SmiTagU Instruction. |
| 867 // 0x40000000: this number would convert to negative when interpreting |
| 868 // the register as signed value; |
| 869 IfBuilder if_of(this); |
| 870 if_of.IfNot<HCompareNumericAndBranch>(res, |
| 871 Add<HConstant>(static_cast<int>(0x40000000)), Token::EQ_STRICT); |
| 872 if_of.Then(); |
| 873 if_of.ElseDeopt("UInt->Smi oveflow"); |
| 874 if_of.End(); |
| 875 } |
| 876 } |
| 877 res = EnforceNumberType(res, result_type); |
| 878 } |
| 879 |
| 880 return res; |
| 881 } |
| 882 |
| 883 |
| 884 Handle<Code> BinaryOpStub::GenerateCode(Isolate* isolate) { |
| 885 return DoGenerateCode(isolate, this); |
| 886 } |
| 887 |
| 888 |
| 889 template <> |
| 815 HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() { | 890 HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() { |
| 816 ToBooleanStub* stub = casted_stub(); | 891 ToBooleanStub* stub = casted_stub(); |
| 817 | 892 |
| 818 IfBuilder if_true(this); | 893 IfBuilder if_true(this); |
| 819 if_true.If<HBranch>(GetParameter(0), stub->GetTypes()); | 894 if_true.If<HBranch>(GetParameter(0), stub->GetTypes()); |
| 820 if_true.Then(); | 895 if_true.Then(); |
| 821 if_true.Return(graph()->GetConstant1()); | 896 if_true.Return(graph()->GetConstant1()); |
| 822 if_true.Else(); | 897 if_true.Else(); |
| 823 if_true.End(); | 898 if_true.End(); |
| 824 return graph()->GetConstant0(); | 899 return graph()->GetConstant0(); |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1097 return js_function; | 1172 return js_function; |
| 1098 } | 1173 } |
| 1099 | 1174 |
| 1100 | 1175 |
| 1101 Handle<Code> FastNewClosureStub::GenerateCode(Isolate* isolate) { | 1176 Handle<Code> FastNewClosureStub::GenerateCode(Isolate* isolate) { |
| 1102 return DoGenerateCode(isolate, this); | 1177 return DoGenerateCode(isolate, this); |
| 1103 } | 1178 } |
| 1104 | 1179 |
| 1105 | 1180 |
| 1106 } } // namespace v8::internal | 1181 } } // namespace v8::internal |
| OLD | NEW |