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 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
874 Handle<Type> right_type = stub->GetRightType(isolate()); | 874 Handle<Type> right_type = stub->GetRightType(isolate()); |
875 Handle<Type> result_type = stub->GetResultType(isolate()); | 875 Handle<Type> result_type = stub->GetResultType(isolate()); |
876 | 876 |
877 ASSERT(!left_type->Is(Type::None()) && !right_type->Is(Type::None()) && | 877 ASSERT(!left_type->Is(Type::None()) && !right_type->Is(Type::None()) && |
878 (stub->HasSideEffects(isolate()) || !result_type->Is(Type::None()))); | 878 (stub->HasSideEffects(isolate()) || !result_type->Is(Type::None()))); |
879 | 879 |
880 HValue* result = NULL; | 880 HValue* result = NULL; |
881 if (stub->operation() == Token::ADD && | 881 if (stub->operation() == Token::ADD && |
882 (left_type->Maybe(Type::String()) || right_type->Maybe(Type::String())) && | 882 (left_type->Maybe(Type::String()) || right_type->Maybe(Type::String())) && |
883 !left_type->Is(Type::String()) && !right_type->Is(Type::String())) { | 883 !left_type->Is(Type::String()) && !right_type->Is(Type::String())) { |
884 // For the generic add stub a fast case for String add is performance | 884 // For the generic add stub a fast case for string addition is performance |
885 // critical. | 885 // critical. |
886 if (left_type->Maybe(Type::String())) { | 886 if (left_type->Maybe(Type::String())) { |
887 IfBuilder left_string(this); | 887 IfBuilder if_leftisstring(this); |
888 left_string.If<HIsStringAndBranch>(left); | 888 if_leftisstring.If<HIsStringAndBranch>(left); |
889 left_string.Then(); | 889 if_leftisstring.Then(); |
890 Push(Add<HStringAdd>(left, right, STRING_ADD_CHECK_RIGHT)); | 890 { |
891 left_string.Else(); | 891 Push(AddInstruction(BuildBinaryOperation( |
892 Push(AddInstruction(BuildBinaryOperation(stub->operation(), | 892 stub->operation(), left, right, |
893 left, right, left_type, right_type, result_type, | 893 handle(Type::String(), isolate()), right_type, |
894 stub->fixed_right_arg(), true))); | 894 result_type, stub->fixed_right_arg(), true))); |
895 left_string.End(); | 895 } |
| 896 if_leftisstring.Else(); |
| 897 { |
| 898 Push(AddInstruction(BuildBinaryOperation( |
| 899 stub->operation(), left, right, |
| 900 left_type, right_type, result_type, |
| 901 stub->fixed_right_arg(), true))); |
| 902 } |
| 903 if_leftisstring.End(); |
896 result = Pop(); | 904 result = Pop(); |
897 } else { | 905 } else { |
898 IfBuilder right_string(this); | 906 IfBuilder if_rightisstring(this); |
899 right_string.If<HIsStringAndBranch>(right); | 907 if_rightisstring.If<HIsStringAndBranch>(right); |
900 right_string.Then(); | 908 if_rightisstring.Then(); |
901 Push(Add<HStringAdd>(left, right, STRING_ADD_CHECK_LEFT)); | 909 { |
902 right_string.Else(); | 910 Push(AddInstruction(BuildBinaryOperation( |
903 Push(AddInstruction(BuildBinaryOperation(stub->operation(), | 911 stub->operation(), left, right, |
904 left, right, left_type, right_type, result_type, | 912 left_type, handle(Type::String(), isolate()), |
905 stub->fixed_right_arg(), true))); | 913 result_type, stub->fixed_right_arg(), true))); |
906 right_string.End(); | 914 } |
| 915 if_rightisstring.Else(); |
| 916 { |
| 917 Push(AddInstruction(BuildBinaryOperation( |
| 918 stub->operation(), left, right, |
| 919 left_type, right_type, result_type, |
| 920 stub->fixed_right_arg(), true))); |
| 921 } |
| 922 if_rightisstring.End(); |
907 result = Pop(); | 923 result = Pop(); |
908 } | 924 } |
909 } else { | 925 } else { |
910 result = AddInstruction(BuildBinaryOperation(stub->operation(), | 926 result = AddInstruction(BuildBinaryOperation( |
911 left, right, left_type, right_type, result_type, | 927 stub->operation(), left, right, |
912 stub->fixed_right_arg(), true)); | 928 left_type, right_type, result_type, |
| 929 stub->fixed_right_arg(), true)); |
913 } | 930 } |
914 | 931 |
915 // If we encounter a generic argument, the number conversion is | 932 // If we encounter a generic argument, the number conversion is |
916 // observable, thus we cannot afford to bail out after the fact. | 933 // observable, thus we cannot afford to bail out after the fact. |
917 if (!stub->HasSideEffects(isolate())) { | 934 if (!stub->HasSideEffects(isolate())) { |
918 if (result_type->Is(Type::Smi())) { | 935 if (result_type->Is(Type::Smi())) { |
919 if (stub->operation() == Token::SHR) { | 936 if (stub->operation() == Token::SHR) { |
920 // TODO(olivf) Replace this by a SmiTagU Instruction. | 937 // TODO(olivf) Replace this by a SmiTagU Instruction. |
921 // 0x40000000: this number would convert to negative when interpreting | 938 // 0x40000000: this number would convert to negative when interpreting |
922 // the register as signed value; | 939 // the register as signed value; |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1242 return js_function; | 1259 return js_function; |
1243 } | 1260 } |
1244 | 1261 |
1245 | 1262 |
1246 Handle<Code> FastNewClosureStub::GenerateCode(Isolate* isolate) { | 1263 Handle<Code> FastNewClosureStub::GenerateCode(Isolate* isolate) { |
1247 return DoGenerateCode(isolate, this); | 1264 return DoGenerateCode(isolate, this); |
1248 } | 1265 } |
1249 | 1266 |
1250 | 1267 |
1251 } } // namespace v8::internal | 1268 } } // namespace v8::internal |
OLD | NEW |