Chromium Code Reviews| 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 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 835 : graph()->GetConstantUndefined(); | 835 : graph()->GetConstantUndefined(); |
| 836 } | 836 } |
| 837 | 837 |
| 838 | 838 |
| 839 Handle<Code> CompareNilICStub::GenerateCode(Isolate* isolate) { | 839 Handle<Code> CompareNilICStub::GenerateCode(Isolate* isolate) { |
| 840 return DoGenerateCode(isolate, this); | 840 return DoGenerateCode(isolate, this); |
| 841 } | 841 } |
| 842 | 842 |
| 843 | 843 |
| 844 template <> | 844 template <> |
| 845 HValue* CodeStubGraphBuilder<BinaryOpStub>::BuildCodeInitializedStub() { | |
| 846 BinaryOpStub* stub = casted_stub(); | |
| 847 HValue* left = GetParameter(0); | |
| 848 HValue* right = GetParameter(1); | |
| 849 | |
| 850 Handle<Type> left_type = stub->GetLeftType(isolate()); | |
| 851 Handle<Type> right_type = stub->GetRightType(isolate()); | |
| 852 Handle<Type> result_type = stub->GetResultType(isolate()); | |
| 853 | |
| 854 ASSERT(!left_type->Is(Type::None()) && !right_type->Is(Type::None()) && | |
| 855 (stub->HasSideEffects(isolate()) || !result_type->Is(Type::None()))); | |
| 856 | |
| 857 HValue* res = NULL; | |
|
Michael Starzinger
2013/09/27 08:36:11
nit: s/res/result/
| |
| 858 if (stub->operation() == Token::ADD && | |
| 859 (left_type->Maybe(Type::String()) || right_type->Maybe(Type::String())) && | |
| 860 !left_type->Is(Type::String()) && !right_type->Is(Type::String())) { | |
| 861 // For the generic add stub a fast case for String add is performance | |
| 862 // critical. | |
| 863 if (left_type->Maybe(Type::String())) { | |
| 864 IfBuilder left_string(this); | |
| 865 left_string.IfNot<HIsSmiAndBranch>(left); | |
| 866 left_string.AndIf<HIsStringAndBranch>(left); | |
| 867 left_string.Then(); | |
| 868 Push(Add<HStringAdd>(left, right, STRING_ADD_CHECK_RIGHT)); | |
| 869 left_string.Else(); | |
| 870 Push(AddInstruction(BuildBinaryOperation(stub->operation(), | |
| 871 left, right, left_type, right_type, result_type, | |
| 872 stub->fixed_right_arg(), true))); | |
| 873 left_string.End(); | |
| 874 res = Pop(); | |
| 875 } else { | |
| 876 IfBuilder right_string(this); | |
| 877 right_string.IfNot<HIsSmiAndBranch>(right); | |
| 878 right_string.AndIf<HIsStringAndBranch>(right); | |
| 879 right_string.Then(); | |
| 880 Push(Add<HStringAdd>(left, right, STRING_ADD_CHECK_LEFT)); | |
| 881 right_string.Else(); | |
| 882 Push(AddInstruction(BuildBinaryOperation(stub->operation(), | |
| 883 left, right, left_type, right_type, result_type, | |
| 884 stub->fixed_right_arg(), true))); | |
| 885 right_string.End(); | |
| 886 res = Pop(); | |
| 887 } | |
| 888 } else { | |
| 889 res = AddInstruction(BuildBinaryOperation(stub->operation(), | |
| 890 left, right, left_type, right_type, result_type, | |
| 891 stub->fixed_right_arg(), true)); | |
| 892 } | |
| 893 | |
| 894 // If we encounter a generic argument, the number conversion is | |
| 895 // observable, thus we cannot afford to bail out after the fact. | |
| 896 if (!stub->HasSideEffects(isolate())) { | |
| 897 if (result_type->Is(Type::Smi())) { | |
| 898 if (stub->operation() == Token::SHR) { | |
| 899 // TODO(olivf) Replace this by a SmiTagU Instruction. | |
| 900 // 0x40000000: this number would convert to negative when interpreting | |
| 901 // the register as signed value; | |
| 902 IfBuilder if_of(this); | |
| 903 if_of.IfNot<HCompareNumericAndBranch>(res, | |
| 904 Add<HConstant>(static_cast<int>(0x40000000)), Token::EQ_STRICT); | |
| 905 if_of.Then(); | |
| 906 if_of.ElseDeopt("UInt->Smi oveflow"); | |
| 907 if_of.End(); | |
| 908 } | |
| 909 } | |
| 910 res = EnforceNumberType(res, result_type); | |
| 911 } | |
| 912 | |
| 913 // Reuse the double box if we are allowed to (i.e. chained binops). | |
| 914 if (stub->CanReuseDoubleBox()) { | |
| 915 HValue* reuse = (stub->mode() == OVERWRITE_LEFT) ? left : right; | |
| 916 IfBuilder if_heap_number(this); | |
| 917 if_heap_number.IfNot<HIsSmiAndBranch>(reuse); | |
| 918 if_heap_number.Then(); | |
| 919 HValue* res_val = Add<HForceRepresentation>(res, Representation::Double()); | |
| 920 HObjectAccess access = HObjectAccess::ForHeapNumberValue(); | |
| 921 Add<HStoreNamedField>(reuse, access, res_val); | |
| 922 Push(reuse); | |
| 923 if_heap_number.Else(); | |
| 924 Push(res); | |
| 925 if_heap_number.End(); | |
| 926 res = Pop(); | |
| 927 } | |
| 928 | |
| 929 return res; | |
| 930 } | |
| 931 | |
| 932 | |
| 933 Handle<Code> BinaryOpStub::GenerateCode(Isolate* isolate) { | |
| 934 return DoGenerateCode(isolate, this); | |
| 935 } | |
| 936 | |
| 937 | |
| 938 template <> | |
| 845 HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() { | 939 HValue* CodeStubGraphBuilder<ToBooleanStub>::BuildCodeInitializedStub() { |
| 846 ToBooleanStub* stub = casted_stub(); | 940 ToBooleanStub* stub = casted_stub(); |
| 847 | 941 |
| 848 IfBuilder if_true(this); | 942 IfBuilder if_true(this); |
| 849 if_true.If<HBranch>(GetParameter(0), stub->GetTypes()); | 943 if_true.If<HBranch>(GetParameter(0), stub->GetTypes()); |
| 850 if_true.Then(); | 944 if_true.Then(); |
| 851 if_true.Return(graph()->GetConstant1()); | 945 if_true.Return(graph()->GetConstant1()); |
| 852 if_true.Else(); | 946 if_true.Else(); |
| 853 if_true.End(); | 947 if_true.End(); |
| 854 return graph()->GetConstant0(); | 948 return graph()->GetConstant0(); |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1127 return js_function; | 1221 return js_function; |
| 1128 } | 1222 } |
| 1129 | 1223 |
| 1130 | 1224 |
| 1131 Handle<Code> FastNewClosureStub::GenerateCode(Isolate* isolate) { | 1225 Handle<Code> FastNewClosureStub::GenerateCode(Isolate* isolate) { |
| 1132 return DoGenerateCode(isolate, this); | 1226 return DoGenerateCode(isolate, this); |
| 1133 } | 1227 } |
| 1134 | 1228 |
| 1135 | 1229 |
| 1136 } } // namespace v8::internal | 1230 } } // namespace v8::internal |
| OLD | NEW |