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 1389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1400 #define DATA_VIEW_GETTER(TypeName, Type, Converter) \ | 1400 #define DATA_VIEW_GETTER(TypeName, Type, Converter) \ |
1401 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewGet##TypeName) { \ | 1401 RUNTIME_FUNCTION(MaybeObject*, Runtime_DataViewGet##TypeName) { \ |
1402 HandleScope scope(isolate); \ | 1402 HandleScope scope(isolate); \ |
1403 ASSERT(args.length() == 3); \ | 1403 ASSERT(args.length() == 3); \ |
1404 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); \ | 1404 CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); \ |
1405 CONVERT_ARG_HANDLE_CHECKED(Object, offset, 1); \ | 1405 CONVERT_ARG_HANDLE_CHECKED(Object, offset, 1); \ |
1406 CONVERT_BOOLEAN_ARG_CHECKED(is_little_endian, 2); \ | 1406 CONVERT_BOOLEAN_ARG_CHECKED(is_little_endian, 2); \ |
1407 Type result; \ | 1407 Type result; \ |
1408 if (DataViewGetValue( \ | 1408 if (DataViewGetValue( \ |
1409 isolate, holder, offset, is_little_endian, &result)) { \ | 1409 isolate, holder, offset, is_little_endian, &result)) { \ |
1410 return isolate->heap()->Converter(result); \ | 1410 return *isolate->factory()->Converter(result); \ |
1411 } else { \ | 1411 } else { \ |
1412 return isolate->Throw(*isolate->factory()->NewRangeError( \ | 1412 return isolate->Throw(*isolate->factory()->NewRangeError( \ |
1413 "invalid_data_view_accessor_offset", \ | 1413 "invalid_data_view_accessor_offset", \ |
1414 HandleVector<Object>(NULL, 0))); \ | 1414 HandleVector<Object>(NULL, 0))); \ |
1415 } \ | 1415 } \ |
1416 } | 1416 } |
1417 | 1417 |
1418 DATA_VIEW_GETTER(Uint8, uint8_t, NumberFromUint32) | 1418 DATA_VIEW_GETTER(Uint8, uint8_t, NewNumberFromUint) |
1419 DATA_VIEW_GETTER(Int8, int8_t, NumberFromInt32) | 1419 DATA_VIEW_GETTER(Int8, int8_t, NewNumberFromInt) |
1420 DATA_VIEW_GETTER(Uint16, uint16_t, NumberFromUint32) | 1420 DATA_VIEW_GETTER(Uint16, uint16_t, NewNumberFromUint) |
1421 DATA_VIEW_GETTER(Int16, int16_t, NumberFromInt32) | 1421 DATA_VIEW_GETTER(Int16, int16_t, NewNumberFromInt) |
1422 DATA_VIEW_GETTER(Uint32, uint32_t, NumberFromUint32) | 1422 DATA_VIEW_GETTER(Uint32, uint32_t, NewNumberFromUint) |
1423 DATA_VIEW_GETTER(Int32, int32_t, NumberFromInt32) | 1423 DATA_VIEW_GETTER(Int32, int32_t, NewNumberFromInt) |
1424 DATA_VIEW_GETTER(Float32, float, NumberFromDouble) | 1424 DATA_VIEW_GETTER(Float32, float, NewNumber) |
1425 DATA_VIEW_GETTER(Float64, double, NumberFromDouble) | 1425 DATA_VIEW_GETTER(Float64, double, NewNumber) |
1426 | 1426 |
1427 #undef DATA_VIEW_GETTER | 1427 #undef DATA_VIEW_GETTER |
1428 | 1428 |
1429 | 1429 |
1430 template <typename T> | 1430 template <typename T> |
1431 static T DataViewConvertValue(double value); | 1431 static T DataViewConvertValue(double value); |
1432 | 1432 |
1433 | 1433 |
1434 template <> | 1434 template <> |
1435 int8_t DataViewConvertValue<int8_t>(double value) { | 1435 int8_t DataViewConvertValue<int8_t>(double value) { |
(...skipping 5418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6854 | 6854 |
6855 | 6855 |
6856 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) { | 6856 bool Runtime::IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch) { |
6857 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; | 6857 unibrow::uchar chars[unibrow::ToUppercase::kMaxWidth]; |
6858 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars); | 6858 int char_length = runtime_state->to_upper_mapping()->get(ch, 0, chars); |
6859 return char_length == 0; | 6859 return char_length == 0; |
6860 } | 6860 } |
6861 | 6861 |
6862 | 6862 |
6863 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NumberToString) { | 6863 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NumberToString) { |
6864 SealHandleScope shs(isolate); | 6864 HandleScope scope(isolate); |
6865 ASSERT(args.length() == 1); | 6865 ASSERT(args.length() == 1); |
6866 | 6866 |
6867 Object* number = args[0]; | 6867 Handle<Object> number = args.at<Object>(0); |
6868 RUNTIME_ASSERT(number->IsNumber()); | 6868 RUNTIME_ASSERT(number->IsNumber()); |
6869 | 6869 |
6870 return isolate->heap()->NumberToString(number); | 6870 return *isolate->factory()->NumberToString(number); |
6871 } | 6871 } |
6872 | 6872 |
6873 | 6873 |
6874 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NumberToStringSkipCache) { | 6874 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NumberToStringSkipCache) { |
6875 SealHandleScope shs(isolate); | 6875 HandleScope scope(isolate); |
6876 ASSERT(args.length() == 1); | 6876 ASSERT(args.length() == 1); |
6877 | 6877 |
6878 Object* number = args[0]; | 6878 Handle<Object> number = args.at<Object>(0); |
6879 RUNTIME_ASSERT(number->IsNumber()); | 6879 RUNTIME_ASSERT(number->IsNumber()); |
6880 | 6880 |
6881 return isolate->heap()->NumberToString(number, false); | 6881 return *isolate->factory()->NumberToString(number, false); |
6882 } | 6882 } |
6883 | 6883 |
6884 | 6884 |
6885 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToInteger) { | 6885 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToInteger) { |
6886 SealHandleScope shs(isolate); | 6886 HandleScope scope(isolate); |
6887 ASSERT(args.length() == 1); | 6887 ASSERT(args.length() == 1); |
6888 | 6888 |
6889 CONVERT_DOUBLE_ARG_CHECKED(number, 0); | 6889 CONVERT_DOUBLE_ARG_CHECKED(number, 0); |
6890 | 6890 return *isolate->factory()->NewNumber(DoubleToInteger(number)); |
6891 // We do not include 0 so that we don't have to treat +0 / -0 cases. | |
6892 if (number > 0 && number <= Smi::kMaxValue) { | |
6893 return Smi::FromInt(static_cast<int>(number)); | |
6894 } | |
6895 return isolate->heap()->NumberFromDouble(DoubleToInteger(number)); | |
6896 } | 6891 } |
6897 | 6892 |
6898 | 6893 |
6899 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToIntegerMapMinusZero) { | 6894 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToIntegerMapMinusZero) { |
6900 SealHandleScope shs(isolate); | 6895 HandleScope scope(isolate); |
6901 ASSERT(args.length() == 1); | 6896 ASSERT(args.length() == 1); |
6902 | 6897 |
6903 CONVERT_DOUBLE_ARG_CHECKED(number, 0); | 6898 CONVERT_DOUBLE_ARG_CHECKED(number, 0); |
6904 | |
6905 // We do not include 0 so that we don't have to treat +0 / -0 cases. | |
6906 if (number > 0 && number <= Smi::kMaxValue) { | |
6907 return Smi::FromInt(static_cast<int>(number)); | |
6908 } | |
6909 | |
Dmitry Lomov (no reviews)
2014/04/15 11:13:06
Let's not have behavioral changes in handlificatio
Yang
2014/04/15 11:14:28
Done.
| |
6910 double double_value = DoubleToInteger(number); | 6899 double double_value = DoubleToInteger(number); |
6911 // Map both -0 and +0 to +0. | 6900 // Map both -0 and +0 to +0. |
6912 if (double_value == 0) double_value = 0; | 6901 return *isolate->factory()->NewNumber(double_value + 0); |
6913 | |
6914 return isolate->heap()->NumberFromDouble(double_value); | |
6915 } | 6902 } |
6916 | 6903 |
6917 | 6904 |
6918 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSUint32) { | 6905 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSUint32) { |
6919 SealHandleScope shs(isolate); | 6906 HandleScope scope(isolate); |
6920 ASSERT(args.length() == 1); | 6907 ASSERT(args.length() == 1); |
6921 | 6908 |
6922 CONVERT_NUMBER_CHECKED(int32_t, number, Uint32, args[0]); | 6909 CONVERT_NUMBER_CHECKED(int32_t, number, Uint32, args[0]); |
6923 return isolate->heap()->NumberFromUint32(number); | 6910 return *isolate->factory()->NewNumberFromUint(number); |
6924 } | 6911 } |
6925 | 6912 |
6926 | 6913 |
6927 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSInt32) { | 6914 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSInt32) { |
6928 SealHandleScope shs(isolate); | 6915 HandleScope scope(isolate); |
6929 ASSERT(args.length() == 1); | 6916 ASSERT(args.length() == 1); |
6930 | 6917 |
6931 CONVERT_DOUBLE_ARG_CHECKED(number, 0); | 6918 CONVERT_DOUBLE_ARG_CHECKED(number, 0); |
6932 | 6919 return *isolate->factory()->NewNumberFromInt(DoubleToInt32(number)); |
6933 // We do not include 0 so that we don't have to treat +0 / -0 cases. | |
6934 if (number > 0 && number <= Smi::kMaxValue) { | |
6935 return Smi::FromInt(static_cast<int>(number)); | |
6936 } | |
6937 return isolate->heap()->NumberFromInt32(DoubleToInt32(number)); | |
6938 } | 6920 } |
6939 | 6921 |
6940 | 6922 |
6941 // Converts a Number to a Smi, if possible. Returns NaN if the number is not | 6923 // Converts a Number to a Smi, if possible. Returns NaN if the number is not |
6942 // a small integer. | 6924 // a small integer. |
6943 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NumberToSmi) { | 6925 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NumberToSmi) { |
6944 SealHandleScope shs(isolate); | 6926 SealHandleScope shs(isolate); |
6945 ASSERT(args.length() == 1); | 6927 ASSERT(args.length() == 1); |
6946 | 6928 |
6947 Object* obj = args[0]; | 6929 Object* obj = args[0]; |
6948 if (obj->IsSmi()) { | 6930 if (obj->IsSmi()) { |
6949 return obj; | 6931 return obj; |
6950 } | 6932 } |
6951 if (obj->IsHeapNumber()) { | 6933 if (obj->IsHeapNumber()) { |
6952 double value = HeapNumber::cast(obj)->value(); | 6934 double value = HeapNumber::cast(obj)->value(); |
6953 int int_value = FastD2I(value); | 6935 int int_value = FastD2I(value); |
6954 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { | 6936 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { |
6955 return Smi::FromInt(int_value); | 6937 return Smi::FromInt(int_value); |
6956 } | 6938 } |
6957 } | 6939 } |
6958 return isolate->heap()->nan_value(); | 6940 return isolate->heap()->nan_value(); |
6959 } | 6941 } |
6960 | 6942 |
6961 | 6943 |
6962 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_AllocateHeapNumber) { | 6944 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_AllocateHeapNumber) { |
6963 SealHandleScope shs(isolate); | 6945 HandleScope scope(isolate); |
6964 ASSERT(args.length() == 0); | 6946 ASSERT(args.length() == 0); |
6965 return isolate->heap()->AllocateHeapNumber(0); | 6947 return *isolate->factory()->NewHeapNumber(0); |
6966 } | 6948 } |
6967 | 6949 |
6968 | 6950 |
6969 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAdd) { | 6951 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAdd) { |
6970 SealHandleScope shs(isolate); | 6952 HandleScope scope(isolate); |
6971 ASSERT(args.length() == 2); | 6953 ASSERT(args.length() == 2); |
6972 | 6954 |
6973 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6955 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
6974 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6956 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
6975 return isolate->heap()->NumberFromDouble(x + y); | 6957 return *isolate->factory()->NewNumber(x + y); |
6976 } | 6958 } |
6977 | 6959 |
6978 | 6960 |
6979 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberSub) { | 6961 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberSub) { |
6980 SealHandleScope shs(isolate); | 6962 HandleScope scope(isolate); |
6981 ASSERT(args.length() == 2); | 6963 ASSERT(args.length() == 2); |
6982 | 6964 |
6983 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6965 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
6984 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6966 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
6985 return isolate->heap()->NumberFromDouble(x - y); | 6967 return *isolate->factory()->NewNumber(x - y); |
6986 } | 6968 } |
6987 | 6969 |
6988 | 6970 |
6989 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMul) { | 6971 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMul) { |
6990 SealHandleScope shs(isolate); | 6972 HandleScope scope(isolate); |
6991 ASSERT(args.length() == 2); | 6973 ASSERT(args.length() == 2); |
6992 | 6974 |
6993 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6975 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
6994 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6976 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
6995 return isolate->heap()->NumberFromDouble(x * y); | 6977 return *isolate->factory()->NewNumber(x * y); |
6996 } | 6978 } |
6997 | 6979 |
6998 | 6980 |
6999 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberUnaryMinus) { | 6981 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberUnaryMinus) { |
7000 SealHandleScope shs(isolate); | 6982 HandleScope scope(isolate); |
7001 ASSERT(args.length() == 1); | 6983 ASSERT(args.length() == 1); |
7002 | 6984 |
7003 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6985 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7004 return isolate->heap()->NumberFromDouble(-x); | 6986 return *isolate->factory()->NewNumber(-x); |
7005 } | |
7006 | |
7007 | |
7008 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAlloc) { | |
7009 SealHandleScope shs(isolate); | |
7010 ASSERT(args.length() == 0); | |
7011 | |
7012 return isolate->heap()->NumberFromDouble(9876543210.0); | |
7013 } | 6987 } |
7014 | 6988 |
7015 | 6989 |
7016 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberDiv) { | 6990 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberDiv) { |
7017 SealHandleScope shs(isolate); | 6991 HandleScope scope(isolate); |
7018 ASSERT(args.length() == 2); | 6992 ASSERT(args.length() == 2); |
7019 | 6993 |
7020 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 6994 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7021 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 6995 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
7022 return isolate->heap()->NumberFromDouble(x / y); | 6996 return *isolate->factory()->NewNumber(x / y); |
7023 } | 6997 } |
7024 | 6998 |
7025 | 6999 |
7026 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMod) { | 7000 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMod) { |
7027 SealHandleScope shs(isolate); | 7001 HandleScope scope(isolate); |
7028 ASSERT(args.length() == 2); | 7002 ASSERT(args.length() == 2); |
7029 | 7003 |
7030 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7004 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7031 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7005 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
7032 | 7006 return *isolate->factory()->NewNumber(modulo(x, y)); |
7033 x = modulo(x, y); | |
7034 // NumberFromDouble may return a Smi instead of a Number object | |
7035 return isolate->heap()->NumberFromDouble(x); | |
7036 } | 7007 } |
7037 | 7008 |
7038 | 7009 |
7039 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberImul) { | 7010 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberImul) { |
7040 SealHandleScope shs(isolate); | 7011 HandleScope scope(isolate); |
7041 ASSERT(args.length() == 2); | 7012 ASSERT(args.length() == 2); |
7042 | 7013 |
7043 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 7014 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
7044 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 7015 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
7045 return isolate->heap()->NumberFromInt32(x * y); | 7016 return *isolate->factory()->NewNumberFromInt(x * y); |
7046 } | 7017 } |
7047 | 7018 |
7048 | 7019 |
7049 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StringAdd) { | 7020 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StringAdd) { |
7050 HandleScope scope(isolate); | 7021 HandleScope scope(isolate); |
7051 ASSERT(args.length() == 2); | 7022 ASSERT(args.length() == 2); |
7052 CONVERT_ARG_HANDLE_CHECKED(String, str1, 0); | 7023 CONVERT_ARG_HANDLE_CHECKED(String, str1, 0); |
7053 CONVERT_ARG_HANDLE_CHECKED(String, str2, 1); | 7024 CONVERT_ARG_HANDLE_CHECKED(String, str2, 1); |
7054 isolate->counters()->string_add_runtime()->Increment(); | 7025 isolate->counters()->string_add_runtime()->Increment(); |
7055 Handle<String> result; | 7026 Handle<String> result; |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7414 array_length, | 7385 array_length, |
7415 separator, | 7386 separator, |
7416 Vector<uc16>(result_string->GetChars(), | 7387 Vector<uc16>(result_string->GetChars(), |
7417 string_length)); | 7388 string_length)); |
7418 return result_string; | 7389 return result_string; |
7419 } | 7390 } |
7420 } | 7391 } |
7421 | 7392 |
7422 | 7393 |
7423 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberOr) { | 7394 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberOr) { |
7424 SealHandleScope shs(isolate); | 7395 HandleScope scope(isolate); |
7425 ASSERT(args.length() == 2); | 7396 ASSERT(args.length() == 2); |
7426 | 7397 |
7427 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 7398 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
7428 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 7399 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
7429 return isolate->heap()->NumberFromInt32(x | y); | 7400 return *isolate->factory()->NewNumberFromInt(x | y); |
7430 } | 7401 } |
7431 | 7402 |
7432 | 7403 |
7433 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAnd) { | 7404 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAnd) { |
7434 SealHandleScope shs(isolate); | 7405 HandleScope scope(isolate); |
7435 ASSERT(args.length() == 2); | 7406 ASSERT(args.length() == 2); |
7436 | 7407 |
7437 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 7408 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
7438 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 7409 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
7439 return isolate->heap()->NumberFromInt32(x & y); | 7410 return *isolate->factory()->NewNumberFromInt(x & y); |
7440 } | 7411 } |
7441 | 7412 |
7442 | 7413 |
7443 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberXor) { | 7414 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberXor) { |
7444 SealHandleScope shs(isolate); | 7415 HandleScope scope(isolate); |
7445 ASSERT(args.length() == 2); | 7416 ASSERT(args.length() == 2); |
7446 | 7417 |
7447 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 7418 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
7448 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 7419 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
7449 return isolate->heap()->NumberFromInt32(x ^ y); | 7420 return *isolate->factory()->NewNumberFromInt(x ^ y); |
7450 } | 7421 } |
7451 | 7422 |
7452 | 7423 |
7453 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberShl) { | 7424 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberShl) { |
7454 SealHandleScope shs(isolate); | 7425 HandleScope scope(isolate); |
7455 ASSERT(args.length() == 2); | 7426 ASSERT(args.length() == 2); |
7456 | 7427 |
7457 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 7428 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
7458 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 7429 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
7459 return isolate->heap()->NumberFromInt32(x << (y & 0x1f)); | 7430 return *isolate->factory()->NewNumberFromInt(x << (y & 0x1f)); |
7460 } | 7431 } |
7461 | 7432 |
7462 | 7433 |
7463 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberShr) { | 7434 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberShr) { |
7464 SealHandleScope shs(isolate); | 7435 HandleScope scope(isolate); |
7465 ASSERT(args.length() == 2); | 7436 ASSERT(args.length() == 2); |
7466 | 7437 |
7467 CONVERT_NUMBER_CHECKED(uint32_t, x, Uint32, args[0]); | 7438 CONVERT_NUMBER_CHECKED(uint32_t, x, Uint32, args[0]); |
7468 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 7439 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
7469 return isolate->heap()->NumberFromUint32(x >> (y & 0x1f)); | 7440 return *isolate->factory()->NewNumberFromUint(x >> (y & 0x1f)); |
7470 } | 7441 } |
7471 | 7442 |
7472 | 7443 |
7473 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberSar) { | 7444 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberSar) { |
7474 SealHandleScope shs(isolate); | 7445 HandleScope scope(isolate); |
7475 ASSERT(args.length() == 2); | 7446 ASSERT(args.length() == 2); |
7476 | 7447 |
7477 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); | 7448 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); |
7478 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); | 7449 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); |
7479 return isolate->heap()->NumberFromInt32(ArithmeticShiftRight(x, y & 0x1f)); | 7450 return *isolate->factory()->NewNumberFromInt( |
7451 ArithmeticShiftRight(x, y & 0x1f)); | |
7480 } | 7452 } |
7481 | 7453 |
7482 | 7454 |
7483 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberEquals) { | 7455 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberEquals) { |
7484 SealHandleScope shs(isolate); | 7456 SealHandleScope shs(isolate); |
7485 ASSERT(args.length() == 2); | 7457 ASSERT(args.length() == 2); |
7486 | 7458 |
7487 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7459 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7488 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7460 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
7489 if (std::isnan(x)) return Smi::FromInt(NOT_EQUAL); | 7461 if (std::isnan(x)) return Smi::FromInt(NOT_EQUAL); |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7669 result = equal_prefix_result; | 7641 result = equal_prefix_result; |
7670 } else { | 7642 } else { |
7671 result = (r < 0) ? Smi::FromInt(LESS) : Smi::FromInt(GREATER); | 7643 result = (r < 0) ? Smi::FromInt(LESS) : Smi::FromInt(GREATER); |
7672 } | 7644 } |
7673 return result; | 7645 return result; |
7674 } | 7646 } |
7675 | 7647 |
7676 | 7648 |
7677 #define RUNTIME_UNARY_MATH(Name, name) \ | 7649 #define RUNTIME_UNARY_MATH(Name, name) \ |
7678 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math##Name) { \ | 7650 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math##Name) { \ |
7679 SealHandleScope shs(isolate); \ | 7651 HandleScope scope(isolate); \ |
7680 ASSERT(args.length() == 1); \ | 7652 ASSERT(args.length() == 1); \ |
7681 isolate->counters()->math_##name()->Increment(); \ | 7653 isolate->counters()->math_##name()->Increment(); \ |
7682 CONVERT_DOUBLE_ARG_CHECKED(x, 0); \ | 7654 CONVERT_DOUBLE_ARG_CHECKED(x, 0); \ |
7683 return isolate->heap()->AllocateHeapNumber(std::name(x)); \ | 7655 return *isolate->factory()->NewHeapNumber(std::name(x)); \ |
7684 } | 7656 } |
7685 | 7657 |
7686 RUNTIME_UNARY_MATH(Acos, acos) | 7658 RUNTIME_UNARY_MATH(Acos, acos) |
7687 RUNTIME_UNARY_MATH(Asin, asin) | 7659 RUNTIME_UNARY_MATH(Asin, asin) |
7688 RUNTIME_UNARY_MATH(Atan, atan) | 7660 RUNTIME_UNARY_MATH(Atan, atan) |
7689 RUNTIME_UNARY_MATH(Log, log) | 7661 RUNTIME_UNARY_MATH(Log, log) |
7690 #undef RUNTIME_UNARY_MATH | 7662 #undef RUNTIME_UNARY_MATH |
7691 | 7663 |
7692 | 7664 |
7693 RUNTIME_FUNCTION(MaybeObject*, Runtime_DoubleHi) { | 7665 RUNTIME_FUNCTION(MaybeObject*, Runtime_DoubleHi) { |
7694 SealHandleScope shs(isolate); | 7666 HandleScope scope(isolate); |
7695 ASSERT(args.length() == 1); | 7667 ASSERT(args.length() == 1); |
7696 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7668 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7697 uint64_t integer = double_to_uint64(x); | 7669 uint64_t integer = double_to_uint64(x); |
7698 integer = (integer >> 32) & 0xFFFFFFFFu; | 7670 integer = (integer >> 32) & 0xFFFFFFFFu; |
7699 return isolate->heap()->NumberFromDouble(static_cast<int32_t>(integer)); | 7671 return *isolate->factory()->NewNumber(static_cast<int32_t>(integer)); |
7700 } | 7672 } |
7701 | 7673 |
7702 | 7674 |
7703 RUNTIME_FUNCTION(MaybeObject*, Runtime_DoubleLo) { | 7675 RUNTIME_FUNCTION(MaybeObject*, Runtime_DoubleLo) { |
7704 SealHandleScope shs(isolate); | 7676 HandleScope scope(isolate); |
7705 ASSERT(args.length() == 1); | 7677 ASSERT(args.length() == 1); |
7706 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7678 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7707 return isolate->heap()->NumberFromDouble( | 7679 return *isolate->factory()->NewNumber( |
7708 static_cast<int32_t>(double_to_uint64(x) & 0xFFFFFFFFu)); | 7680 static_cast<int32_t>(double_to_uint64(x) & 0xFFFFFFFFu)); |
7709 } | 7681 } |
7710 | 7682 |
7711 | 7683 |
7712 RUNTIME_FUNCTION(MaybeObject*, Runtime_ConstructDouble) { | 7684 RUNTIME_FUNCTION(MaybeObject*, Runtime_ConstructDouble) { |
7713 SealHandleScope shs(isolate); | 7685 HandleScope scope(isolate); |
7714 ASSERT(args.length() == 2); | 7686 ASSERT(args.length() == 2); |
7715 CONVERT_NUMBER_CHECKED(uint32_t, hi, Uint32, args[0]); | 7687 CONVERT_NUMBER_CHECKED(uint32_t, hi, Uint32, args[0]); |
7716 CONVERT_NUMBER_CHECKED(uint32_t, lo, Uint32, args[1]); | 7688 CONVERT_NUMBER_CHECKED(uint32_t, lo, Uint32, args[1]); |
7717 uint64_t result = (static_cast<uint64_t>(hi) << 32) | lo; | 7689 uint64_t result = (static_cast<uint64_t>(hi) << 32) | lo; |
7718 return isolate->heap()->AllocateHeapNumber(uint64_to_double(result)); | 7690 return *isolate->factory()->NewNumber(uint64_to_double(result)); |
7719 } | 7691 } |
7720 | 7692 |
7721 | 7693 |
7722 static const double kPiDividedBy4 = 0.78539816339744830962; | 7694 static const double kPiDividedBy4 = 0.78539816339744830962; |
7723 | 7695 |
7724 | 7696 |
7725 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathAtan2) { | 7697 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathAtan2) { |
7726 SealHandleScope shs(isolate); | 7698 HandleScope scope(isolate); |
7727 ASSERT(args.length() == 2); | 7699 ASSERT(args.length() == 2); |
7728 isolate->counters()->math_atan2()->Increment(); | 7700 isolate->counters()->math_atan2()->Increment(); |
7729 | 7701 |
7730 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7702 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7731 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7703 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
7732 double result; | 7704 double result; |
7733 if (std::isinf(x) && std::isinf(y)) { | 7705 if (std::isinf(x) && std::isinf(y)) { |
7734 // Make sure that the result in case of two infinite arguments | 7706 // Make sure that the result in case of two infinite arguments |
7735 // is a multiple of Pi / 4. The sign of the result is determined | 7707 // is a multiple of Pi / 4. The sign of the result is determined |
7736 // by the first argument (x) and the sign of the second argument | 7708 // by the first argument (x) and the sign of the second argument |
7737 // determines the multiplier: one or three. | 7709 // determines the multiplier: one or three. |
7738 int multiplier = (x < 0) ? -1 : 1; | 7710 int multiplier = (x < 0) ? -1 : 1; |
7739 if (y < 0) multiplier *= 3; | 7711 if (y < 0) multiplier *= 3; |
7740 result = multiplier * kPiDividedBy4; | 7712 result = multiplier * kPiDividedBy4; |
7741 } else { | 7713 } else { |
7742 result = std::atan2(x, y); | 7714 result = std::atan2(x, y); |
7743 } | 7715 } |
7744 return isolate->heap()->AllocateHeapNumber(result); | 7716 return *isolate->factory()->NewNumber(result); |
7745 } | 7717 } |
7746 | 7718 |
7747 | 7719 |
7748 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathExp) { | 7720 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathExp) { |
7749 SealHandleScope shs(isolate); | 7721 HandleScope scope(isolate); |
7750 ASSERT(args.length() == 1); | 7722 ASSERT(args.length() == 1); |
7751 isolate->counters()->math_exp()->Increment(); | 7723 isolate->counters()->math_exp()->Increment(); |
7752 | 7724 |
7753 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7725 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7754 lazily_initialize_fast_exp(); | 7726 lazily_initialize_fast_exp(); |
7755 return isolate->heap()->NumberFromDouble(fast_exp(x)); | 7727 return *isolate->factory()->NewNumber(fast_exp(x)); |
7756 } | 7728 } |
7757 | 7729 |
7758 | 7730 |
7759 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathFloor) { | 7731 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathFloor) { |
7760 SealHandleScope shs(isolate); | 7732 HandleScope scope(isolate); |
7761 ASSERT(args.length() == 1); | 7733 ASSERT(args.length() == 1); |
7762 isolate->counters()->math_floor()->Increment(); | 7734 isolate->counters()->math_floor()->Increment(); |
7763 | 7735 |
7764 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7736 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7765 return isolate->heap()->NumberFromDouble(std::floor(x)); | 7737 return *isolate->factory()->NewNumber(std::floor(x)); |
7766 } | 7738 } |
7767 | 7739 |
7768 | 7740 |
7769 // Slow version of Math.pow. We check for fast paths for special cases. | 7741 // Slow version of Math.pow. We check for fast paths for special cases. |
7770 // Used if SSE2/VFP3 is not available. | 7742 // Used if SSE2/VFP3 is not available. |
7771 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_MathPowSlow) { | 7743 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_MathPowSlow) { |
7772 SealHandleScope shs(isolate); | 7744 HandleScope scope(isolate); |
7773 ASSERT(args.length() == 2); | 7745 ASSERT(args.length() == 2); |
7774 isolate->counters()->math_pow()->Increment(); | 7746 isolate->counters()->math_pow()->Increment(); |
7775 | 7747 |
7776 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7748 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7777 | 7749 |
7778 // If the second argument is a smi, it is much faster to call the | 7750 // If the second argument is a smi, it is much faster to call the |
7779 // custom powi() function than the generic pow(). | 7751 // custom powi() function than the generic pow(). |
7780 if (args[1]->IsSmi()) { | 7752 if (args[1]->IsSmi()) { |
7781 int y = args.smi_at(1); | 7753 int y = args.smi_at(1); |
7782 return isolate->heap()->NumberFromDouble(power_double_int(x, y)); | 7754 return *isolate->factory()->NewNumber(power_double_int(x, y)); |
7783 } | 7755 } |
7784 | 7756 |
7785 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7757 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
7786 double result = power_helper(x, y); | 7758 double result = power_helper(x, y); |
7787 if (std::isnan(result)) return isolate->heap()->nan_value(); | 7759 if (std::isnan(result)) return isolate->heap()->nan_value(); |
7788 return isolate->heap()->AllocateHeapNumber(result); | 7760 return *isolate->factory()->NewNumber(result); |
7789 } | 7761 } |
7790 | 7762 |
7791 | 7763 |
7792 // Fast version of Math.pow if we know that y is not an integer and y is not | 7764 // Fast version of Math.pow if we know that y is not an integer and y is not |
7793 // -0.5 or 0.5. Used as slow case from full codegen. | 7765 // -0.5 or 0.5. Used as slow case from full codegen. |
7794 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_MathPow) { | 7766 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_MathPow) { |
7795 SealHandleScope shs(isolate); | 7767 HandleScope scope(isolate); |
7796 ASSERT(args.length() == 2); | 7768 ASSERT(args.length() == 2); |
7797 isolate->counters()->math_pow()->Increment(); | 7769 isolate->counters()->math_pow()->Increment(); |
7798 | 7770 |
7799 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7771 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7800 CONVERT_DOUBLE_ARG_CHECKED(y, 1); | 7772 CONVERT_DOUBLE_ARG_CHECKED(y, 1); |
7801 if (y == 0) { | 7773 if (y == 0) { |
7802 return Smi::FromInt(1); | 7774 return Smi::FromInt(1); |
7803 } else { | 7775 } else { |
7804 double result = power_double_double(x, y); | 7776 double result = power_double_double(x, y); |
7805 if (std::isnan(result)) return isolate->heap()->nan_value(); | 7777 if (std::isnan(result)) return isolate->heap()->nan_value(); |
7806 return isolate->heap()->AllocateHeapNumber(result); | 7778 return *isolate->factory()->NewNumber(result); |
7807 } | 7779 } |
7808 } | 7780 } |
7809 | 7781 |
7810 | 7782 |
7811 RUNTIME_FUNCTION(MaybeObject*, Runtime_RoundNumber) { | 7783 RUNTIME_FUNCTION(MaybeObject*, Runtime_RoundNumber) { |
7812 SealHandleScope shs(isolate); | 7784 HandleScope scope(isolate); |
7813 ASSERT(args.length() == 1); | 7785 ASSERT(args.length() == 1); |
7814 isolate->counters()->math_round()->Increment(); | 7786 isolate->counters()->math_round()->Increment(); |
7815 | 7787 |
7816 if (!args[0]->IsHeapNumber()) { | 7788 if (!args[0]->IsHeapNumber()) { |
7817 // Must be smi. Return the argument unchanged for all the other types | 7789 // Must be smi. Return the argument unchanged for all the other types |
7818 // to make fuzz-natives test happy. | 7790 // to make fuzz-natives test happy. |
7819 return args[0]; | 7791 return args[0]; |
7820 } | 7792 } |
7821 | 7793 |
7822 HeapNumber* number = reinterpret_cast<HeapNumber*>(args[0]); | 7794 HeapNumber* number = reinterpret_cast<HeapNumber*>(args[0]); |
(...skipping 17 matching lines...) Expand all Loading... | |
7840 | 7812 |
7841 // If the magnitude is big enough, there's no place for fraction part. If we | 7813 // If the magnitude is big enough, there's no place for fraction part. If we |
7842 // try to add 0.5 to this number, 1.0 will be added instead. | 7814 // try to add 0.5 to this number, 1.0 will be added instead. |
7843 if (exponent >= 52) { | 7815 if (exponent >= 52) { |
7844 return number; | 7816 return number; |
7845 } | 7817 } |
7846 | 7818 |
7847 if (sign && value >= -0.5) return isolate->heap()->minus_zero_value(); | 7819 if (sign && value >= -0.5) return isolate->heap()->minus_zero_value(); |
7848 | 7820 |
7849 // Do not call NumberFromDouble() to avoid extra checks. | 7821 // Do not call NumberFromDouble() to avoid extra checks. |
7850 return isolate->heap()->AllocateHeapNumber(std::floor(value + 0.5)); | 7822 return *isolate->factory()->NewNumber(std::floor(value + 0.5)); |
7851 } | 7823 } |
7852 | 7824 |
7853 | 7825 |
7854 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathSqrt) { | 7826 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathSqrt) { |
7855 SealHandleScope shs(isolate); | 7827 HandleScope scope(isolate); |
7856 ASSERT(args.length() == 1); | 7828 ASSERT(args.length() == 1); |
7857 isolate->counters()->math_sqrt()->Increment(); | 7829 isolate->counters()->math_sqrt()->Increment(); |
7858 | 7830 |
7859 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7831 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7860 return isolate->heap()->AllocateHeapNumber(fast_sqrt(x)); | 7832 return *isolate->factory()->NewNumber(fast_sqrt(x)); |
7861 } | 7833 } |
7862 | 7834 |
7863 | 7835 |
7864 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathFround) { | 7836 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathFround) { |
7865 SealHandleScope shs(isolate); | 7837 HandleScope scope(isolate); |
7866 ASSERT(args.length() == 1); | 7838 ASSERT(args.length() == 1); |
7867 | 7839 |
7868 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 7840 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
7869 float xf = static_cast<float>(x); | 7841 float xf = static_cast<float>(x); |
7870 return isolate->heap()->AllocateHeapNumber(xf); | 7842 return *isolate->factory()->NewNumber(xf); |
7871 } | 7843 } |
7872 | 7844 |
7873 | 7845 |
7874 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) { | 7846 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) { |
7875 SealHandleScope shs(isolate); | 7847 SealHandleScope shs(isolate); |
7876 ASSERT(args.length() == 2); | 7848 ASSERT(args.length() == 2); |
7877 | 7849 |
7878 CONVERT_SMI_ARG_CHECKED(year, 0); | 7850 CONVERT_SMI_ARG_CHECKED(year, 0); |
7879 CONVERT_SMI_ARG_CHECKED(month, 1); | 7851 CONVERT_SMI_ARG_CHECKED(month, 1); |
7880 | 7852 |
7881 return Smi::FromInt(isolate->date_cache()->DaysFromYearMonth(year, month)); | 7853 return Smi::FromInt(isolate->date_cache()->DaysFromYearMonth(year, month)); |
7882 } | 7854 } |
7883 | 7855 |
7884 | 7856 |
7885 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateSetValue) { | 7857 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateSetValue) { |
7886 HandleScope scope(isolate); | 7858 HandleScope scope(isolate); |
7887 ASSERT(args.length() == 3); | 7859 ASSERT(args.length() == 3); |
7888 | 7860 |
7889 CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 0); | 7861 CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 0); |
7890 CONVERT_DOUBLE_ARG_CHECKED(time, 1); | 7862 CONVERT_DOUBLE_ARG_CHECKED(time, 1); |
7891 CONVERT_SMI_ARG_CHECKED(is_utc, 2); | 7863 CONVERT_SMI_ARG_CHECKED(is_utc, 2); |
7892 | 7864 |
7893 DateCache* date_cache = isolate->date_cache(); | 7865 DateCache* date_cache = isolate->date_cache(); |
7894 | 7866 |
7895 Object* value = NULL; | 7867 Handle<Object> value;; |
7896 bool is_value_nan = false; | 7868 bool is_value_nan = false; |
7897 if (std::isnan(time)) { | 7869 if (std::isnan(time)) { |
7898 value = isolate->heap()->nan_value(); | 7870 value = isolate->factory()->nan_value(); |
7899 is_value_nan = true; | 7871 is_value_nan = true; |
7900 } else if (!is_utc && | 7872 } else if (!is_utc && |
7901 (time < -DateCache::kMaxTimeBeforeUTCInMs || | 7873 (time < -DateCache::kMaxTimeBeforeUTCInMs || |
7902 time > DateCache::kMaxTimeBeforeUTCInMs)) { | 7874 time > DateCache::kMaxTimeBeforeUTCInMs)) { |
7903 value = isolate->heap()->nan_value(); | 7875 value = isolate->factory()->nan_value(); |
7904 is_value_nan = true; | 7876 is_value_nan = true; |
7905 } else { | 7877 } else { |
7906 time = is_utc ? time : date_cache->ToUTC(static_cast<int64_t>(time)); | 7878 time = is_utc ? time : date_cache->ToUTC(static_cast<int64_t>(time)); |
7907 if (time < -DateCache::kMaxTimeInMs || | 7879 if (time < -DateCache::kMaxTimeInMs || |
7908 time > DateCache::kMaxTimeInMs) { | 7880 time > DateCache::kMaxTimeInMs) { |
7909 value = isolate->heap()->nan_value(); | 7881 value = isolate->factory()->nan_value(); |
7910 is_value_nan = true; | 7882 is_value_nan = true; |
7911 } else { | 7883 } else { |
7912 MaybeObject* maybe_result = | 7884 value = isolate->factory()->NewNumber(DoubleToInteger(time)); |
7913 isolate->heap()->AllocateHeapNumber(DoubleToInteger(time)); | |
7914 if (!maybe_result->ToObject(&value)) return maybe_result; | |
7915 } | 7885 } |
7916 } | 7886 } |
7917 date->SetValue(value, is_value_nan); | 7887 date->SetValue(*value, is_value_nan); |
7918 return value; | 7888 return *value; |
7919 } | 7889 } |
7920 | 7890 |
7921 | 7891 |
7922 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewArgumentsFast) { | 7892 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewArgumentsFast) { |
7923 HandleScope scope(isolate); | 7893 HandleScope scope(isolate); |
7924 ASSERT(args.length() == 3); | 7894 ASSERT(args.length() == 3); |
7925 | 7895 |
7926 Handle<JSFunction> callee = args.at<JSFunction>(0); | 7896 Handle<JSFunction> callee = args.at<JSFunction>(0); |
7927 Object** parameters = reinterpret_cast<Object**>(args[1]); | 7897 Object** parameters = reinterpret_cast<Object**>(args[1]); |
7928 const int argument_count = Smi::cast(args[2])->value(); | 7898 const int argument_count = Smi::cast(args[2])->value(); |
(...skipping 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9575 | 9545 |
9576 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugTrace) { | 9546 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugTrace) { |
9577 SealHandleScope shs(isolate); | 9547 SealHandleScope shs(isolate); |
9578 ASSERT(args.length() == 0); | 9548 ASSERT(args.length() == 0); |
9579 isolate->PrintStack(stdout); | 9549 isolate->PrintStack(stdout); |
9580 return isolate->heap()->undefined_value(); | 9550 return isolate->heap()->undefined_value(); |
9581 } | 9551 } |
9582 | 9552 |
9583 | 9553 |
9584 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateCurrentTime) { | 9554 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateCurrentTime) { |
9585 SealHandleScope shs(isolate); | 9555 HandleScope scope(isolate); |
9586 ASSERT(args.length() == 0); | 9556 ASSERT(args.length() == 0); |
9587 | 9557 |
9588 // According to ECMA-262, section 15.9.1, page 117, the precision of | 9558 // According to ECMA-262, section 15.9.1, page 117, the precision of |
9589 // the number in a Date object representing a particular instant in | 9559 // the number in a Date object representing a particular instant in |
9590 // time is milliseconds. Therefore, we floor the result of getting | 9560 // time is milliseconds. Therefore, we floor the result of getting |
9591 // the OS time. | 9561 // the OS time. |
9592 double millis = std::floor(OS::TimeCurrentMillis()); | 9562 double millis = std::floor(OS::TimeCurrentMillis()); |
9593 return isolate->heap()->NumberFromDouble(millis); | 9563 return *isolate->factory()->NewNumber(millis); |
9594 } | 9564 } |
9595 | 9565 |
9596 | 9566 |
9597 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateParseString) { | 9567 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateParseString) { |
9598 HandleScope scope(isolate); | 9568 HandleScope scope(isolate); |
9599 ASSERT(args.length() == 2); | 9569 ASSERT(args.length() == 2); |
9600 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); | 9570 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); |
9601 CONVERT_ARG_HANDLE_CHECKED(JSArray, output, 1); | 9571 CONVERT_ARG_HANDLE_CHECKED(JSArray, output, 1); |
9602 | 9572 |
9603 JSObject::EnsureCanContainHeapObjectElements(output); | 9573 JSObject::EnsureCanContainHeapObjectElements(output); |
(...skipping 30 matching lines...) Expand all Loading... | |
9634 ASSERT(args.length() == 1); | 9604 ASSERT(args.length() == 1); |
9635 | 9605 |
9636 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 9606 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
9637 const char* zone = | 9607 const char* zone = |
9638 isolate->date_cache()->LocalTimezone(static_cast<int64_t>(x)); | 9608 isolate->date_cache()->LocalTimezone(static_cast<int64_t>(x)); |
9639 return isolate->heap()->AllocateStringFromUtf8(CStrVector(zone)); | 9609 return isolate->heap()->AllocateStringFromUtf8(CStrVector(zone)); |
9640 } | 9610 } |
9641 | 9611 |
9642 | 9612 |
9643 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateToUTC) { | 9613 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateToUTC) { |
9644 SealHandleScope shs(isolate); | 9614 HandleScope scope(isolate); |
9645 ASSERT(args.length() == 1); | 9615 ASSERT(args.length() == 1); |
9646 | 9616 |
9647 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 9617 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
9648 int64_t time = isolate->date_cache()->ToUTC(static_cast<int64_t>(x)); | 9618 int64_t time = isolate->date_cache()->ToUTC(static_cast<int64_t>(x)); |
9649 | 9619 |
9650 return isolate->heap()->NumberFromDouble(static_cast<double>(time)); | 9620 return *isolate->factory()->NewNumber(static_cast<double>(time)); |
9651 } | 9621 } |
9652 | 9622 |
9653 | 9623 |
9654 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateCacheVersion) { | 9624 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateCacheVersion) { |
9655 HandleScope hs(isolate); | 9625 HandleScope hs(isolate); |
9656 ASSERT(args.length() == 0); | 9626 ASSERT(args.length() == 0); |
9657 if (!isolate->eternal_handles()->Exists(EternalHandles::DATE_CACHE_VERSION)) { | 9627 if (!isolate->eternal_handles()->Exists(EternalHandles::DATE_CACHE_VERSION)) { |
9658 Handle<FixedArray> date_cache_version = | 9628 Handle<FixedArray> date_cache_version = |
9659 isolate->factory()->NewFixedArray(1, TENURED); | 9629 isolate->factory()->NewFixedArray(1, TENURED); |
9660 date_cache_version->set(0, Smi::FromInt(0)); | 9630 date_cache_version->set(0, Smi::FromInt(0)); |
(...skipping 5447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
15108 } | 15078 } |
15109 } | 15079 } |
15110 | 15080 |
15111 | 15081 |
15112 void Runtime::OutOfMemory() { | 15082 void Runtime::OutOfMemory() { |
15113 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); | 15083 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); |
15114 UNREACHABLE(); | 15084 UNREACHABLE(); |
15115 } | 15085 } |
15116 | 15086 |
15117 } } // namespace v8::internal | 15087 } } // namespace v8::internal |
OLD | NEW |