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 827 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 int relative_end = len; | 838 int relative_end = len; |
839 if (n_arguments > 0) { | 839 if (n_arguments > 0) { |
840 Object* arg1 = args[1]; | 840 Object* arg1 = args[1]; |
841 if (arg1->IsSmi()) { | 841 if (arg1->IsSmi()) { |
842 relative_start = Smi::cast(arg1)->value(); | 842 relative_start = Smi::cast(arg1)->value(); |
843 } else if (arg1->IsHeapNumber()) { | 843 } else if (arg1->IsHeapNumber()) { |
844 double start = HeapNumber::cast(arg1)->value(); | 844 double start = HeapNumber::cast(arg1)->value(); |
845 if (start < kMinInt || start > kMaxInt) { | 845 if (start < kMinInt || start > kMaxInt) { |
846 return CallJsBuiltin(isolate, "ArraySlice", args); | 846 return CallJsBuiltin(isolate, "ArraySlice", args); |
847 } | 847 } |
848 relative_start = static_cast<int>(start); | 848 relative_start = std::isnan(start) ? 0 : static_cast<int>(start); |
849 } else if (!arg1->IsUndefined()) { | 849 } else if (!arg1->IsUndefined()) { |
850 return CallJsBuiltin(isolate, "ArraySlice", args); | 850 return CallJsBuiltin(isolate, "ArraySlice", args); |
851 } | 851 } |
852 if (n_arguments > 1) { | 852 if (n_arguments > 1) { |
853 Object* arg2 = args[2]; | 853 Object* arg2 = args[2]; |
854 if (arg2->IsSmi()) { | 854 if (arg2->IsSmi()) { |
855 relative_end = Smi::cast(arg2)->value(); | 855 relative_end = Smi::cast(arg2)->value(); |
856 } else if (arg2->IsHeapNumber()) { | 856 } else if (arg2->IsHeapNumber()) { |
857 double end = HeapNumber::cast(arg2)->value(); | 857 double end = HeapNumber::cast(arg2)->value(); |
858 if (end < kMinInt || end > kMaxInt) { | 858 if (end < kMinInt || end > kMaxInt) { |
859 return CallJsBuiltin(isolate, "ArraySlice", args); | 859 return CallJsBuiltin(isolate, "ArraySlice", args); |
860 } | 860 } |
861 relative_end = static_cast<int>(end); | 861 relative_end = std::isnan(end) ? 0 : static_cast<int>(end); |
862 } else if (!arg2->IsUndefined()) { | 862 } else if (!arg2->IsUndefined()) { |
863 return CallJsBuiltin(isolate, "ArraySlice", args); | 863 return CallJsBuiltin(isolate, "ArraySlice", args); |
864 } | 864 } |
865 } | 865 } |
866 } | 866 } |
867 | 867 |
868 // ECMAScript 232, 3rd Edition, Section 15.4.4.10, step 6. | 868 // ECMAScript 232, 3rd Edition, Section 15.4.4.10, step 6. |
869 int k = (relative_start < 0) ? Max(len + relative_start, 0) | 869 int k = (relative_start < 0) ? Max(len + relative_start, 0) |
870 : Min(relative_start, len); | 870 : Min(relative_start, len); |
871 | 871 |
(...skipping 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1886 return Handle<Code>(code_address); \ | 1886 return Handle<Code>(code_address); \ |
1887 } | 1887 } |
1888 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) | 1888 BUILTIN_LIST_C(DEFINE_BUILTIN_ACCESSOR_C) |
1889 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) | 1889 BUILTIN_LIST_A(DEFINE_BUILTIN_ACCESSOR_A) |
1890 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) | 1890 BUILTIN_LIST_DEBUG_A(DEFINE_BUILTIN_ACCESSOR_A) |
1891 #undef DEFINE_BUILTIN_ACCESSOR_C | 1891 #undef DEFINE_BUILTIN_ACCESSOR_C |
1892 #undef DEFINE_BUILTIN_ACCESSOR_A | 1892 #undef DEFINE_BUILTIN_ACCESSOR_A |
1893 | 1893 |
1894 | 1894 |
1895 } } // namespace v8::internal | 1895 } } // namespace v8::internal |
OLD | NEW |