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 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 : graph()->GetConstantUndefined(); | 887 : graph()->GetConstantUndefined(); |
888 } | 888 } |
889 | 889 |
890 | 890 |
891 Handle<Code> CompareNilICStub::GenerateCode(Isolate* isolate) { | 891 Handle<Code> CompareNilICStub::GenerateCode(Isolate* isolate) { |
892 return DoGenerateCode(isolate, this); | 892 return DoGenerateCode(isolate, this); |
893 } | 893 } |
894 | 894 |
895 | 895 |
896 template <> | 896 template <> |
897 HValue* CodeStubGraphBuilder<BinaryOpStub>::BuildCodeInitializedStub() { | 897 HValue* CodeStubGraphBuilder<BinaryOpICStub>::BuildCodeInitializedStub() { |
898 BinaryOpStub* stub = casted_stub(); | 898 BinaryOpIC::State state = casted_stub()->state(); |
899 HValue* left = GetParameter(0); | |
900 HValue* right = GetParameter(1); | |
901 | 899 |
902 Handle<Type> left_type = stub->GetLeftType(isolate()); | 900 HValue* left = GetParameter(BinaryOpICStub::kLeft); |
903 Handle<Type> right_type = stub->GetRightType(isolate()); | 901 HValue* right = GetParameter(BinaryOpICStub::kRight); |
904 Handle<Type> result_type = stub->GetResultType(isolate()); | 902 |
| 903 Handle<Type> left_type = state.GetLeftType(isolate()); |
| 904 Handle<Type> right_type = state.GetRightType(isolate()); |
| 905 Handle<Type> result_type = state.GetResultType(isolate()); |
905 | 906 |
906 ASSERT(!left_type->Is(Type::None()) && !right_type->Is(Type::None()) && | 907 ASSERT(!left_type->Is(Type::None()) && !right_type->Is(Type::None()) && |
907 (stub->HasSideEffects(isolate()) || !result_type->Is(Type::None()))); | 908 (state.HasSideEffects() || !result_type->Is(Type::None()))); |
908 | 909 |
909 HValue* result = NULL; | 910 HValue* result = NULL; |
910 if (stub->operation() == Token::ADD && | 911 if (state.op() == Token::ADD && |
911 (left_type->Maybe(Type::String()) || right_type->Maybe(Type::String())) && | 912 (left_type->Maybe(Type::String()) || right_type->Maybe(Type::String())) && |
912 !left_type->Is(Type::String()) && !right_type->Is(Type::String())) { | 913 !left_type->Is(Type::String()) && !right_type->Is(Type::String())) { |
913 // For the generic add stub a fast case for string addition is performance | 914 // For the generic add stub a fast case for string addition is performance |
914 // critical. | 915 // critical. |
915 if (left_type->Maybe(Type::String())) { | 916 if (left_type->Maybe(Type::String())) { |
916 IfBuilder if_leftisstring(this); | 917 IfBuilder if_leftisstring(this); |
917 if_leftisstring.If<HIsStringAndBranch>(left); | 918 if_leftisstring.If<HIsStringAndBranch>(left); |
918 if_leftisstring.Then(); | 919 if_leftisstring.Then(); |
919 { | 920 { |
920 Push(BuildBinaryOperation( | 921 Push(BuildBinaryOperation( |
921 stub->operation(), left, right, | 922 state.op(), left, right, |
922 handle(Type::String(), isolate()), right_type, | 923 handle(Type::String(), isolate()), right_type, |
923 result_type, stub->fixed_right_arg())); | 924 result_type, state.fixed_right_arg())); |
924 } | 925 } |
925 if_leftisstring.Else(); | 926 if_leftisstring.Else(); |
926 { | 927 { |
927 Push(BuildBinaryOperation( | 928 Push(BuildBinaryOperation( |
928 stub->operation(), left, right, | 929 state.op(), left, right, |
929 left_type, right_type, result_type, | 930 left_type, right_type, result_type, |
930 stub->fixed_right_arg())); | 931 state.fixed_right_arg())); |
931 } | 932 } |
932 if_leftisstring.End(); | 933 if_leftisstring.End(); |
933 result = Pop(); | 934 result = Pop(); |
934 } else { | 935 } else { |
935 IfBuilder if_rightisstring(this); | 936 IfBuilder if_rightisstring(this); |
936 if_rightisstring.If<HIsStringAndBranch>(right); | 937 if_rightisstring.If<HIsStringAndBranch>(right); |
937 if_rightisstring.Then(); | 938 if_rightisstring.Then(); |
938 { | 939 { |
939 Push(BuildBinaryOperation( | 940 Push(BuildBinaryOperation( |
940 stub->operation(), left, right, | 941 state.op(), left, right, |
941 left_type, handle(Type::String(), isolate()), | 942 left_type, handle(Type::String(), isolate()), |
942 result_type, stub->fixed_right_arg())); | 943 result_type, state.fixed_right_arg())); |
943 } | 944 } |
944 if_rightisstring.Else(); | 945 if_rightisstring.Else(); |
945 { | 946 { |
946 Push(BuildBinaryOperation( | 947 Push(BuildBinaryOperation( |
947 stub->operation(), left, right, | 948 state.op(), left, right, |
948 left_type, right_type, result_type, | 949 left_type, right_type, result_type, |
949 stub->fixed_right_arg())); | 950 state.fixed_right_arg())); |
950 } | 951 } |
951 if_rightisstring.End(); | 952 if_rightisstring.End(); |
952 result = Pop(); | 953 result = Pop(); |
953 } | 954 } |
954 } else { | 955 } else { |
955 result = BuildBinaryOperation( | 956 result = BuildBinaryOperation( |
956 stub->operation(), left, right, | 957 state.op(), left, right, |
957 left_type, right_type, result_type, | 958 left_type, right_type, result_type, |
958 stub->fixed_right_arg()); | 959 state.fixed_right_arg()); |
959 } | 960 } |
960 | 961 |
961 // If we encounter a generic argument, the number conversion is | 962 // If we encounter a generic argument, the number conversion is |
962 // observable, thus we cannot afford to bail out after the fact. | 963 // observable, thus we cannot afford to bail out after the fact. |
963 if (!stub->HasSideEffects(isolate())) { | 964 if (!state.HasSideEffects()) { |
964 if (result_type->Is(Type::Smi())) { | 965 if (result_type->Is(Type::Smi())) { |
965 if (stub->operation() == Token::SHR) { | 966 if (state.op() == Token::SHR) { |
966 // TODO(olivf) Replace this by a SmiTagU Instruction. | 967 // TODO(olivf) Replace this by a SmiTagU Instruction. |
967 // 0x40000000: this number would convert to negative when interpreting | 968 // 0x40000000: this number would convert to negative when interpreting |
968 // the register as signed value; | 969 // the register as signed value; |
969 IfBuilder if_of(this); | 970 IfBuilder if_of(this); |
970 if_of.IfNot<HCompareNumericAndBranch>(result, | 971 if_of.IfNot<HCompareNumericAndBranch>(result, |
971 Add<HConstant>(static_cast<int>(SmiValuesAre32Bits() | 972 Add<HConstant>(static_cast<int>(SmiValuesAre32Bits() |
972 ? 0x80000000 : 0x40000000)), Token::EQ_STRICT); | 973 ? 0x80000000 : 0x40000000)), Token::EQ_STRICT); |
973 if_of.Then(); | 974 if_of.Then(); |
974 if_of.ElseDeopt("UInt->Smi oveflow"); | 975 if_of.ElseDeopt("UInt->Smi oveflow"); |
975 if_of.End(); | 976 if_of.End(); |
976 } | 977 } |
977 } | 978 } |
978 result = EnforceNumberType(result, result_type); | 979 result = EnforceNumberType(result, result_type); |
979 } | 980 } |
980 | 981 |
981 // Reuse the double box of one of the operands if we are allowed to (i.e. | 982 // Reuse the double box of one of the operands if we are allowed to (i.e. |
982 // chained binops). | 983 // chained binops). |
983 if (stub->CanReuseDoubleBox()) { | 984 if (state.CanReuseDoubleBox()) { |
984 HValue* operand = (stub->mode() == OVERWRITE_LEFT) ? left : right; | 985 HValue* operand = (state.mode() == OVERWRITE_LEFT) ? left : right; |
985 IfBuilder if_heap_number(this); | 986 IfBuilder if_heap_number(this); |
986 if_heap_number.IfNot<HIsSmiAndBranch>(operand); | 987 if_heap_number.IfNot<HIsSmiAndBranch>(operand); |
987 if_heap_number.Then(); | 988 if_heap_number.Then(); |
988 Add<HStoreNamedField>(operand, HObjectAccess::ForHeapNumberValue(), result); | 989 Add<HStoreNamedField>(operand, HObjectAccess::ForHeapNumberValue(), result); |
989 Push(operand); | 990 Push(operand); |
990 if_heap_number.Else(); | 991 if_heap_number.Else(); |
991 Push(result); | 992 Push(result); |
992 if_heap_number.End(); | 993 if_heap_number.End(); |
993 result = Pop(); | 994 result = Pop(); |
994 } | 995 } |
995 | 996 |
996 return result; | 997 return result; |
997 } | 998 } |
998 | 999 |
999 | 1000 |
1000 Handle<Code> BinaryOpStub::GenerateCode(Isolate* isolate) { | 1001 Handle<Code> BinaryOpICStub::GenerateCode(Isolate* isolate) { |
1001 return DoGenerateCode(isolate, this); | 1002 return DoGenerateCode(isolate, this); |
1002 } | 1003 } |
1003 | 1004 |
1004 | 1005 |
1005 template <> | 1006 template <> |
1006 HValue* CodeStubGraphBuilder<NewStringAddStub>::BuildCodeInitializedStub() { | 1007 HValue* CodeStubGraphBuilder<NewStringAddStub>::BuildCodeInitializedStub() { |
1007 NewStringAddStub* stub = casted_stub(); | 1008 NewStringAddStub* stub = casted_stub(); |
1008 StringAddFlags flags = stub->flags(); | 1009 StringAddFlags flags = stub->flags(); |
1009 PretenureFlag pretenure_flag = stub->pretenure_flag(); | 1010 PretenureFlag pretenure_flag = stub->pretenure_flag(); |
1010 | 1011 |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1328 return BuildUncheckedDictionaryElementLoad(receiver, key); | 1329 return BuildUncheckedDictionaryElementLoad(receiver, key); |
1329 } | 1330 } |
1330 | 1331 |
1331 | 1332 |
1332 Handle<Code> KeyedLoadDictionaryElementStub::GenerateCode(Isolate* isolate) { | 1333 Handle<Code> KeyedLoadDictionaryElementStub::GenerateCode(Isolate* isolate) { |
1333 return DoGenerateCode(isolate, this); | 1334 return DoGenerateCode(isolate, this); |
1334 } | 1335 } |
1335 | 1336 |
1336 | 1337 |
1337 } } // namespace v8::internal | 1338 } } // namespace v8::internal |
OLD | NEW |