Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: src/runtime.cc

Issue 238543004: Remove direct calls to number-related allocators from runtime.cc. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: changed as suggested Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/runtime.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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 if (double_value == 0) double_value = 0;
6913 6902
6914 return isolate->heap()->NumberFromDouble(double_value); 6903 return *isolate->factory()->NewNumber(double_value);
6915 } 6904 }
6916 6905
6917 6906
6918 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSUint32) { 6907 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSUint32) {
6919 SealHandleScope shs(isolate); 6908 HandleScope scope(isolate);
6920 ASSERT(args.length() == 1); 6909 ASSERT(args.length() == 1);
6921 6910
6922 CONVERT_NUMBER_CHECKED(int32_t, number, Uint32, args[0]); 6911 CONVERT_NUMBER_CHECKED(int32_t, number, Uint32, args[0]);
6923 return isolate->heap()->NumberFromUint32(number); 6912 return *isolate->factory()->NewNumberFromUint(number);
6924 } 6913 }
6925 6914
6926 6915
6927 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSInt32) { 6916 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberToJSInt32) {
6928 SealHandleScope shs(isolate); 6917 HandleScope scope(isolate);
6929 ASSERT(args.length() == 1); 6918 ASSERT(args.length() == 1);
6930 6919
6931 CONVERT_DOUBLE_ARG_CHECKED(number, 0); 6920 CONVERT_DOUBLE_ARG_CHECKED(number, 0);
6932 6921 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 } 6922 }
6939 6923
6940 6924
6941 // Converts a Number to a Smi, if possible. Returns NaN if the number is not 6925 // Converts a Number to a Smi, if possible. Returns NaN if the number is not
6942 // a small integer. 6926 // a small integer.
6943 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NumberToSmi) { 6927 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NumberToSmi) {
6944 SealHandleScope shs(isolate); 6928 SealHandleScope shs(isolate);
6945 ASSERT(args.length() == 1); 6929 ASSERT(args.length() == 1);
6946 6930
6947 Object* obj = args[0]; 6931 Object* obj = args[0];
6948 if (obj->IsSmi()) { 6932 if (obj->IsSmi()) {
6949 return obj; 6933 return obj;
6950 } 6934 }
6951 if (obj->IsHeapNumber()) { 6935 if (obj->IsHeapNumber()) {
6952 double value = HeapNumber::cast(obj)->value(); 6936 double value = HeapNumber::cast(obj)->value();
6953 int int_value = FastD2I(value); 6937 int int_value = FastD2I(value);
6954 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) { 6938 if (value == FastI2D(int_value) && Smi::IsValid(int_value)) {
6955 return Smi::FromInt(int_value); 6939 return Smi::FromInt(int_value);
6956 } 6940 }
6957 } 6941 }
6958 return isolate->heap()->nan_value(); 6942 return isolate->heap()->nan_value();
6959 } 6943 }
6960 6944
6961 6945
6962 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_AllocateHeapNumber) { 6946 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_AllocateHeapNumber) {
6963 SealHandleScope shs(isolate); 6947 HandleScope scope(isolate);
6964 ASSERT(args.length() == 0); 6948 ASSERT(args.length() == 0);
6965 return isolate->heap()->AllocateHeapNumber(0); 6949 return *isolate->factory()->NewHeapNumber(0);
6966 } 6950 }
6967 6951
6968 6952
6969 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAdd) { 6953 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAdd) {
6970 SealHandleScope shs(isolate); 6954 HandleScope scope(isolate);
6971 ASSERT(args.length() == 2); 6955 ASSERT(args.length() == 2);
6972 6956
6973 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 6957 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
6974 CONVERT_DOUBLE_ARG_CHECKED(y, 1); 6958 CONVERT_DOUBLE_ARG_CHECKED(y, 1);
6975 return isolate->heap()->NumberFromDouble(x + y); 6959 return *isolate->factory()->NewNumber(x + y);
6976 } 6960 }
6977 6961
6978 6962
6979 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberSub) { 6963 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberSub) {
6980 SealHandleScope shs(isolate); 6964 HandleScope scope(isolate);
6981 ASSERT(args.length() == 2); 6965 ASSERT(args.length() == 2);
6982 6966
6983 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 6967 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
6984 CONVERT_DOUBLE_ARG_CHECKED(y, 1); 6968 CONVERT_DOUBLE_ARG_CHECKED(y, 1);
6985 return isolate->heap()->NumberFromDouble(x - y); 6969 return *isolate->factory()->NewNumber(x - y);
6986 } 6970 }
6987 6971
6988 6972
6989 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMul) { 6973 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMul) {
6990 SealHandleScope shs(isolate); 6974 HandleScope scope(isolate);
6991 ASSERT(args.length() == 2); 6975 ASSERT(args.length() == 2);
6992 6976
6993 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 6977 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
6994 CONVERT_DOUBLE_ARG_CHECKED(y, 1); 6978 CONVERT_DOUBLE_ARG_CHECKED(y, 1);
6995 return isolate->heap()->NumberFromDouble(x * y); 6979 return *isolate->factory()->NewNumber(x * y);
6996 } 6980 }
6997 6981
6998 6982
6999 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberUnaryMinus) { 6983 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberUnaryMinus) {
7000 SealHandleScope shs(isolate); 6984 HandleScope scope(isolate);
7001 ASSERT(args.length() == 1); 6985 ASSERT(args.length() == 1);
7002 6986
7003 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 6987 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7004 return isolate->heap()->NumberFromDouble(-x); 6988 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 } 6989 }
7014 6990
7015 6991
7016 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberDiv) { 6992 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberDiv) {
7017 SealHandleScope shs(isolate); 6993 HandleScope scope(isolate);
7018 ASSERT(args.length() == 2); 6994 ASSERT(args.length() == 2);
7019 6995
7020 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 6996 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7021 CONVERT_DOUBLE_ARG_CHECKED(y, 1); 6997 CONVERT_DOUBLE_ARG_CHECKED(y, 1);
7022 return isolate->heap()->NumberFromDouble(x / y); 6998 return *isolate->factory()->NewNumber(x / y);
7023 } 6999 }
7024 7000
7025 7001
7026 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMod) { 7002 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberMod) {
7027 SealHandleScope shs(isolate); 7003 HandleScope scope(isolate);
7028 ASSERT(args.length() == 2); 7004 ASSERT(args.length() == 2);
7029 7005
7030 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7006 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7031 CONVERT_DOUBLE_ARG_CHECKED(y, 1); 7007 CONVERT_DOUBLE_ARG_CHECKED(y, 1);
7032 7008 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 } 7009 }
7037 7010
7038 7011
7039 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberImul) { 7012 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberImul) {
7040 SealHandleScope shs(isolate); 7013 HandleScope scope(isolate);
7041 ASSERT(args.length() == 2); 7014 ASSERT(args.length() == 2);
7042 7015
7043 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); 7016 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]);
7044 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); 7017 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]);
7045 return isolate->heap()->NumberFromInt32(x * y); 7018 return *isolate->factory()->NewNumberFromInt(x * y);
7046 } 7019 }
7047 7020
7048 7021
7049 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StringAdd) { 7022 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_StringAdd) {
7050 HandleScope scope(isolate); 7023 HandleScope scope(isolate);
7051 ASSERT(args.length() == 2); 7024 ASSERT(args.length() == 2);
7052 CONVERT_ARG_HANDLE_CHECKED(String, str1, 0); 7025 CONVERT_ARG_HANDLE_CHECKED(String, str1, 0);
7053 CONVERT_ARG_HANDLE_CHECKED(String, str2, 1); 7026 CONVERT_ARG_HANDLE_CHECKED(String, str2, 1);
7054 isolate->counters()->string_add_runtime()->Increment(); 7027 isolate->counters()->string_add_runtime()->Increment();
7055 Handle<String> result; 7028 Handle<String> result;
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
7414 array_length, 7387 array_length,
7415 separator, 7388 separator,
7416 Vector<uc16>(result_string->GetChars(), 7389 Vector<uc16>(result_string->GetChars(),
7417 string_length)); 7390 string_length));
7418 return result_string; 7391 return result_string;
7419 } 7392 }
7420 } 7393 }
7421 7394
7422 7395
7423 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberOr) { 7396 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberOr) {
7424 SealHandleScope shs(isolate); 7397 HandleScope scope(isolate);
7425 ASSERT(args.length() == 2); 7398 ASSERT(args.length() == 2);
7426 7399
7427 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); 7400 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]);
7428 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); 7401 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]);
7429 return isolate->heap()->NumberFromInt32(x | y); 7402 return *isolate->factory()->NewNumberFromInt(x | y);
7430 } 7403 }
7431 7404
7432 7405
7433 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAnd) { 7406 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberAnd) {
7434 SealHandleScope shs(isolate); 7407 HandleScope scope(isolate);
7435 ASSERT(args.length() == 2); 7408 ASSERT(args.length() == 2);
7436 7409
7437 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); 7410 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]);
7438 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); 7411 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]);
7439 return isolate->heap()->NumberFromInt32(x & y); 7412 return *isolate->factory()->NewNumberFromInt(x & y);
7440 } 7413 }
7441 7414
7442 7415
7443 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberXor) { 7416 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberXor) {
7444 SealHandleScope shs(isolate); 7417 HandleScope scope(isolate);
7445 ASSERT(args.length() == 2); 7418 ASSERT(args.length() == 2);
7446 7419
7447 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); 7420 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]);
7448 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); 7421 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]);
7449 return isolate->heap()->NumberFromInt32(x ^ y); 7422 return *isolate->factory()->NewNumberFromInt(x ^ y);
7450 } 7423 }
7451 7424
7452 7425
7453 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberShl) { 7426 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberShl) {
7454 SealHandleScope shs(isolate); 7427 HandleScope scope(isolate);
7455 ASSERT(args.length() == 2); 7428 ASSERT(args.length() == 2);
7456 7429
7457 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); 7430 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]);
7458 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); 7431 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]);
7459 return isolate->heap()->NumberFromInt32(x << (y & 0x1f)); 7432 return *isolate->factory()->NewNumberFromInt(x << (y & 0x1f));
7460 } 7433 }
7461 7434
7462 7435
7463 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberShr) { 7436 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberShr) {
7464 SealHandleScope shs(isolate); 7437 HandleScope scope(isolate);
7465 ASSERT(args.length() == 2); 7438 ASSERT(args.length() == 2);
7466 7439
7467 CONVERT_NUMBER_CHECKED(uint32_t, x, Uint32, args[0]); 7440 CONVERT_NUMBER_CHECKED(uint32_t, x, Uint32, args[0]);
7468 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); 7441 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]);
7469 return isolate->heap()->NumberFromUint32(x >> (y & 0x1f)); 7442 return *isolate->factory()->NewNumberFromUint(x >> (y & 0x1f));
7470 } 7443 }
7471 7444
7472 7445
7473 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberSar) { 7446 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberSar) {
7474 SealHandleScope shs(isolate); 7447 HandleScope scope(isolate);
7475 ASSERT(args.length() == 2); 7448 ASSERT(args.length() == 2);
7476 7449
7477 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]); 7450 CONVERT_NUMBER_CHECKED(int32_t, x, Int32, args[0]);
7478 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]); 7451 CONVERT_NUMBER_CHECKED(int32_t, y, Int32, args[1]);
7479 return isolate->heap()->NumberFromInt32(ArithmeticShiftRight(x, y & 0x1f)); 7452 return *isolate->factory()->NewNumberFromInt(
7453 ArithmeticShiftRight(x, y & 0x1f));
7480 } 7454 }
7481 7455
7482 7456
7483 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberEquals) { 7457 RUNTIME_FUNCTION(MaybeObject*, Runtime_NumberEquals) {
7484 SealHandleScope shs(isolate); 7458 SealHandleScope shs(isolate);
7485 ASSERT(args.length() == 2); 7459 ASSERT(args.length() == 2);
7486 7460
7487 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7461 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7488 CONVERT_DOUBLE_ARG_CHECKED(y, 1); 7462 CONVERT_DOUBLE_ARG_CHECKED(y, 1);
7489 if (std::isnan(x)) return Smi::FromInt(NOT_EQUAL); 7463 if (std::isnan(x)) return Smi::FromInt(NOT_EQUAL);
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
7669 result = equal_prefix_result; 7643 result = equal_prefix_result;
7670 } else { 7644 } else {
7671 result = (r < 0) ? Smi::FromInt(LESS) : Smi::FromInt(GREATER); 7645 result = (r < 0) ? Smi::FromInt(LESS) : Smi::FromInt(GREATER);
7672 } 7646 }
7673 return result; 7647 return result;
7674 } 7648 }
7675 7649
7676 7650
7677 #define RUNTIME_UNARY_MATH(Name, name) \ 7651 #define RUNTIME_UNARY_MATH(Name, name) \
7678 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math##Name) { \ 7652 RUNTIME_FUNCTION(MaybeObject*, Runtime_Math##Name) { \
7679 SealHandleScope shs(isolate); \ 7653 HandleScope scope(isolate); \
7680 ASSERT(args.length() == 1); \ 7654 ASSERT(args.length() == 1); \
7681 isolate->counters()->math_##name()->Increment(); \ 7655 isolate->counters()->math_##name()->Increment(); \
7682 CONVERT_DOUBLE_ARG_CHECKED(x, 0); \ 7656 CONVERT_DOUBLE_ARG_CHECKED(x, 0); \
7683 return isolate->heap()->AllocateHeapNumber(std::name(x)); \ 7657 return *isolate->factory()->NewHeapNumber(std::name(x)); \
7684 } 7658 }
7685 7659
7686 RUNTIME_UNARY_MATH(Acos, acos) 7660 RUNTIME_UNARY_MATH(Acos, acos)
7687 RUNTIME_UNARY_MATH(Asin, asin) 7661 RUNTIME_UNARY_MATH(Asin, asin)
7688 RUNTIME_UNARY_MATH(Atan, atan) 7662 RUNTIME_UNARY_MATH(Atan, atan)
7689 RUNTIME_UNARY_MATH(Log, log) 7663 RUNTIME_UNARY_MATH(Log, log)
7690 #undef RUNTIME_UNARY_MATH 7664 #undef RUNTIME_UNARY_MATH
7691 7665
7692 7666
7693 RUNTIME_FUNCTION(MaybeObject*, Runtime_DoubleHi) { 7667 RUNTIME_FUNCTION(MaybeObject*, Runtime_DoubleHi) {
7694 SealHandleScope shs(isolate); 7668 HandleScope scope(isolate);
7695 ASSERT(args.length() == 1); 7669 ASSERT(args.length() == 1);
7696 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7670 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7697 uint64_t integer = double_to_uint64(x); 7671 uint64_t integer = double_to_uint64(x);
7698 integer = (integer >> 32) & 0xFFFFFFFFu; 7672 integer = (integer >> 32) & 0xFFFFFFFFu;
7699 return isolate->heap()->NumberFromDouble(static_cast<int32_t>(integer)); 7673 return *isolate->factory()->NewNumber(static_cast<int32_t>(integer));
7700 } 7674 }
7701 7675
7702 7676
7703 RUNTIME_FUNCTION(MaybeObject*, Runtime_DoubleLo) { 7677 RUNTIME_FUNCTION(MaybeObject*, Runtime_DoubleLo) {
7704 SealHandleScope shs(isolate); 7678 HandleScope scope(isolate);
7705 ASSERT(args.length() == 1); 7679 ASSERT(args.length() == 1);
7706 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7680 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7707 return isolate->heap()->NumberFromDouble( 7681 return *isolate->factory()->NewNumber(
7708 static_cast<int32_t>(double_to_uint64(x) & 0xFFFFFFFFu)); 7682 static_cast<int32_t>(double_to_uint64(x) & 0xFFFFFFFFu));
7709 } 7683 }
7710 7684
7711 7685
7712 RUNTIME_FUNCTION(MaybeObject*, Runtime_ConstructDouble) { 7686 RUNTIME_FUNCTION(MaybeObject*, Runtime_ConstructDouble) {
7713 SealHandleScope shs(isolate); 7687 HandleScope scope(isolate);
7714 ASSERT(args.length() == 2); 7688 ASSERT(args.length() == 2);
7715 CONVERT_NUMBER_CHECKED(uint32_t, hi, Uint32, args[0]); 7689 CONVERT_NUMBER_CHECKED(uint32_t, hi, Uint32, args[0]);
7716 CONVERT_NUMBER_CHECKED(uint32_t, lo, Uint32, args[1]); 7690 CONVERT_NUMBER_CHECKED(uint32_t, lo, Uint32, args[1]);
7717 uint64_t result = (static_cast<uint64_t>(hi) << 32) | lo; 7691 uint64_t result = (static_cast<uint64_t>(hi) << 32) | lo;
7718 return isolate->heap()->AllocateHeapNumber(uint64_to_double(result)); 7692 return *isolate->factory()->NewNumber(uint64_to_double(result));
7719 } 7693 }
7720 7694
7721 7695
7722 static const double kPiDividedBy4 = 0.78539816339744830962; 7696 static const double kPiDividedBy4 = 0.78539816339744830962;
7723 7697
7724 7698
7725 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathAtan2) { 7699 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathAtan2) {
7726 SealHandleScope shs(isolate); 7700 HandleScope scope(isolate);
7727 ASSERT(args.length() == 2); 7701 ASSERT(args.length() == 2);
7728 isolate->counters()->math_atan2()->Increment(); 7702 isolate->counters()->math_atan2()->Increment();
7729 7703
7730 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7704 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7731 CONVERT_DOUBLE_ARG_CHECKED(y, 1); 7705 CONVERT_DOUBLE_ARG_CHECKED(y, 1);
7732 double result; 7706 double result;
7733 if (std::isinf(x) && std::isinf(y)) { 7707 if (std::isinf(x) && std::isinf(y)) {
7734 // Make sure that the result in case of two infinite arguments 7708 // 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 7709 // 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 7710 // by the first argument (x) and the sign of the second argument
7737 // determines the multiplier: one or three. 7711 // determines the multiplier: one or three.
7738 int multiplier = (x < 0) ? -1 : 1; 7712 int multiplier = (x < 0) ? -1 : 1;
7739 if (y < 0) multiplier *= 3; 7713 if (y < 0) multiplier *= 3;
7740 result = multiplier * kPiDividedBy4; 7714 result = multiplier * kPiDividedBy4;
7741 } else { 7715 } else {
7742 result = std::atan2(x, y); 7716 result = std::atan2(x, y);
7743 } 7717 }
7744 return isolate->heap()->AllocateHeapNumber(result); 7718 return *isolate->factory()->NewNumber(result);
7745 } 7719 }
7746 7720
7747 7721
7748 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathExp) { 7722 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathExp) {
7749 SealHandleScope shs(isolate); 7723 HandleScope scope(isolate);
7750 ASSERT(args.length() == 1); 7724 ASSERT(args.length() == 1);
7751 isolate->counters()->math_exp()->Increment(); 7725 isolate->counters()->math_exp()->Increment();
7752 7726
7753 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7727 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7754 lazily_initialize_fast_exp(); 7728 lazily_initialize_fast_exp();
7755 return isolate->heap()->NumberFromDouble(fast_exp(x)); 7729 return *isolate->factory()->NewNumber(fast_exp(x));
7756 } 7730 }
7757 7731
7758 7732
7759 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathFloor) { 7733 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathFloor) {
7760 SealHandleScope shs(isolate); 7734 HandleScope scope(isolate);
7761 ASSERT(args.length() == 1); 7735 ASSERT(args.length() == 1);
7762 isolate->counters()->math_floor()->Increment(); 7736 isolate->counters()->math_floor()->Increment();
7763 7737
7764 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7738 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7765 return isolate->heap()->NumberFromDouble(std::floor(x)); 7739 return *isolate->factory()->NewNumber(std::floor(x));
7766 } 7740 }
7767 7741
7768 7742
7769 // Slow version of Math.pow. We check for fast paths for special cases. 7743 // Slow version of Math.pow. We check for fast paths for special cases.
7770 // Used if SSE2/VFP3 is not available. 7744 // Used if SSE2/VFP3 is not available.
7771 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_MathPowSlow) { 7745 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_MathPowSlow) {
7772 SealHandleScope shs(isolate); 7746 HandleScope scope(isolate);
7773 ASSERT(args.length() == 2); 7747 ASSERT(args.length() == 2);
7774 isolate->counters()->math_pow()->Increment(); 7748 isolate->counters()->math_pow()->Increment();
7775 7749
7776 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7750 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7777 7751
7778 // If the second argument is a smi, it is much faster to call the 7752 // If the second argument is a smi, it is much faster to call the
7779 // custom powi() function than the generic pow(). 7753 // custom powi() function than the generic pow().
7780 if (args[1]->IsSmi()) { 7754 if (args[1]->IsSmi()) {
7781 int y = args.smi_at(1); 7755 int y = args.smi_at(1);
7782 return isolate->heap()->NumberFromDouble(power_double_int(x, y)); 7756 return *isolate->factory()->NewNumber(power_double_int(x, y));
7783 } 7757 }
7784 7758
7785 CONVERT_DOUBLE_ARG_CHECKED(y, 1); 7759 CONVERT_DOUBLE_ARG_CHECKED(y, 1);
7786 double result = power_helper(x, y); 7760 double result = power_helper(x, y);
7787 if (std::isnan(result)) return isolate->heap()->nan_value(); 7761 if (std::isnan(result)) return isolate->heap()->nan_value();
7788 return isolate->heap()->AllocateHeapNumber(result); 7762 return *isolate->factory()->NewNumber(result);
7789 } 7763 }
7790 7764
7791 7765
7792 // Fast version of Math.pow if we know that y is not an integer and y is not 7766 // 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. 7767 // -0.5 or 0.5. Used as slow case from full codegen.
7794 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_MathPow) { 7768 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_MathPow) {
7795 SealHandleScope shs(isolate); 7769 HandleScope scope(isolate);
7796 ASSERT(args.length() == 2); 7770 ASSERT(args.length() == 2);
7797 isolate->counters()->math_pow()->Increment(); 7771 isolate->counters()->math_pow()->Increment();
7798 7772
7799 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7773 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7800 CONVERT_DOUBLE_ARG_CHECKED(y, 1); 7774 CONVERT_DOUBLE_ARG_CHECKED(y, 1);
7801 if (y == 0) { 7775 if (y == 0) {
7802 return Smi::FromInt(1); 7776 return Smi::FromInt(1);
7803 } else { 7777 } else {
7804 double result = power_double_double(x, y); 7778 double result = power_double_double(x, y);
7805 if (std::isnan(result)) return isolate->heap()->nan_value(); 7779 if (std::isnan(result)) return isolate->heap()->nan_value();
7806 return isolate->heap()->AllocateHeapNumber(result); 7780 return *isolate->factory()->NewNumber(result);
7807 } 7781 }
7808 } 7782 }
7809 7783
7810 7784
7811 RUNTIME_FUNCTION(MaybeObject*, Runtime_RoundNumber) { 7785 RUNTIME_FUNCTION(MaybeObject*, Runtime_RoundNumber) {
7812 SealHandleScope shs(isolate); 7786 HandleScope scope(isolate);
7813 ASSERT(args.length() == 1); 7787 ASSERT(args.length() == 1);
7814 isolate->counters()->math_round()->Increment(); 7788 isolate->counters()->math_round()->Increment();
7815 7789
7816 if (!args[0]->IsHeapNumber()) { 7790 if (!args[0]->IsHeapNumber()) {
7817 // Must be smi. Return the argument unchanged for all the other types 7791 // Must be smi. Return the argument unchanged for all the other types
7818 // to make fuzz-natives test happy. 7792 // to make fuzz-natives test happy.
7819 return args[0]; 7793 return args[0];
7820 } 7794 }
7821 7795
7822 HeapNumber* number = reinterpret_cast<HeapNumber*>(args[0]); 7796 HeapNumber* number = reinterpret_cast<HeapNumber*>(args[0]);
(...skipping 17 matching lines...) Expand all
7840 7814
7841 // If the magnitude is big enough, there's no place for fraction part. If we 7815 // 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. 7816 // try to add 0.5 to this number, 1.0 will be added instead.
7843 if (exponent >= 52) { 7817 if (exponent >= 52) {
7844 return number; 7818 return number;
7845 } 7819 }
7846 7820
7847 if (sign && value >= -0.5) return isolate->heap()->minus_zero_value(); 7821 if (sign && value >= -0.5) return isolate->heap()->minus_zero_value();
7848 7822
7849 // Do not call NumberFromDouble() to avoid extra checks. 7823 // Do not call NumberFromDouble() to avoid extra checks.
7850 return isolate->heap()->AllocateHeapNumber(std::floor(value + 0.5)); 7824 return *isolate->factory()->NewNumber(std::floor(value + 0.5));
7851 } 7825 }
7852 7826
7853 7827
7854 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathSqrt) { 7828 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathSqrt) {
7855 SealHandleScope shs(isolate); 7829 HandleScope scope(isolate);
7856 ASSERT(args.length() == 1); 7830 ASSERT(args.length() == 1);
7857 isolate->counters()->math_sqrt()->Increment(); 7831 isolate->counters()->math_sqrt()->Increment();
7858 7832
7859 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7833 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7860 return isolate->heap()->AllocateHeapNumber(fast_sqrt(x)); 7834 return *isolate->factory()->NewNumber(fast_sqrt(x));
7861 } 7835 }
7862 7836
7863 7837
7864 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathFround) { 7838 RUNTIME_FUNCTION(MaybeObject*, Runtime_MathFround) {
7865 SealHandleScope shs(isolate); 7839 HandleScope scope(isolate);
7866 ASSERT(args.length() == 1); 7840 ASSERT(args.length() == 1);
7867 7841
7868 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 7842 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
7869 float xf = static_cast<float>(x); 7843 float xf = static_cast<float>(x);
7870 return isolate->heap()->AllocateHeapNumber(xf); 7844 return *isolate->factory()->NewNumber(xf);
7871 } 7845 }
7872 7846
7873 7847
7874 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) { 7848 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateMakeDay) {
7875 SealHandleScope shs(isolate); 7849 SealHandleScope shs(isolate);
7876 ASSERT(args.length() == 2); 7850 ASSERT(args.length() == 2);
7877 7851
7878 CONVERT_SMI_ARG_CHECKED(year, 0); 7852 CONVERT_SMI_ARG_CHECKED(year, 0);
7879 CONVERT_SMI_ARG_CHECKED(month, 1); 7853 CONVERT_SMI_ARG_CHECKED(month, 1);
7880 7854
7881 return Smi::FromInt(isolate->date_cache()->DaysFromYearMonth(year, month)); 7855 return Smi::FromInt(isolate->date_cache()->DaysFromYearMonth(year, month));
7882 } 7856 }
7883 7857
7884 7858
7885 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateSetValue) { 7859 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateSetValue) {
7886 HandleScope scope(isolate); 7860 HandleScope scope(isolate);
7887 ASSERT(args.length() == 3); 7861 ASSERT(args.length() == 3);
7888 7862
7889 CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 0); 7863 CONVERT_ARG_HANDLE_CHECKED(JSDate, date, 0);
7890 CONVERT_DOUBLE_ARG_CHECKED(time, 1); 7864 CONVERT_DOUBLE_ARG_CHECKED(time, 1);
7891 CONVERT_SMI_ARG_CHECKED(is_utc, 2); 7865 CONVERT_SMI_ARG_CHECKED(is_utc, 2);
7892 7866
7893 DateCache* date_cache = isolate->date_cache(); 7867 DateCache* date_cache = isolate->date_cache();
7894 7868
7895 Object* value = NULL; 7869 Handle<Object> value;;
7896 bool is_value_nan = false; 7870 bool is_value_nan = false;
7897 if (std::isnan(time)) { 7871 if (std::isnan(time)) {
7898 value = isolate->heap()->nan_value(); 7872 value = isolate->factory()->nan_value();
7899 is_value_nan = true; 7873 is_value_nan = true;
7900 } else if (!is_utc && 7874 } else if (!is_utc &&
7901 (time < -DateCache::kMaxTimeBeforeUTCInMs || 7875 (time < -DateCache::kMaxTimeBeforeUTCInMs ||
7902 time > DateCache::kMaxTimeBeforeUTCInMs)) { 7876 time > DateCache::kMaxTimeBeforeUTCInMs)) {
7903 value = isolate->heap()->nan_value(); 7877 value = isolate->factory()->nan_value();
7904 is_value_nan = true; 7878 is_value_nan = true;
7905 } else { 7879 } else {
7906 time = is_utc ? time : date_cache->ToUTC(static_cast<int64_t>(time)); 7880 time = is_utc ? time : date_cache->ToUTC(static_cast<int64_t>(time));
7907 if (time < -DateCache::kMaxTimeInMs || 7881 if (time < -DateCache::kMaxTimeInMs ||
7908 time > DateCache::kMaxTimeInMs) { 7882 time > DateCache::kMaxTimeInMs) {
7909 value = isolate->heap()->nan_value(); 7883 value = isolate->factory()->nan_value();
7910 is_value_nan = true; 7884 is_value_nan = true;
7911 } else { 7885 } else {
7912 MaybeObject* maybe_result = 7886 value = isolate->factory()->NewNumber(DoubleToInteger(time));
7913 isolate->heap()->AllocateHeapNumber(DoubleToInteger(time));
7914 if (!maybe_result->ToObject(&value)) return maybe_result;
7915 } 7887 }
7916 } 7888 }
7917 date->SetValue(value, is_value_nan); 7889 date->SetValue(*value, is_value_nan);
7918 return value; 7890 return *value;
7919 } 7891 }
7920 7892
7921 7893
7922 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewArgumentsFast) { 7894 RUNTIME_FUNCTION(MaybeObject*, RuntimeHidden_NewArgumentsFast) {
7923 HandleScope scope(isolate); 7895 HandleScope scope(isolate);
7924 ASSERT(args.length() == 3); 7896 ASSERT(args.length() == 3);
7925 7897
7926 Handle<JSFunction> callee = args.at<JSFunction>(0); 7898 Handle<JSFunction> callee = args.at<JSFunction>(0);
7927 Object** parameters = reinterpret_cast<Object**>(args[1]); 7899 Object** parameters = reinterpret_cast<Object**>(args[1]);
7928 const int argument_count = Smi::cast(args[2])->value(); 7900 const int argument_count = Smi::cast(args[2])->value();
(...skipping 1646 matching lines...) Expand 10 before | Expand all | Expand 10 after
9575 9547
9576 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugTrace) { 9548 RUNTIME_FUNCTION(MaybeObject*, Runtime_DebugTrace) {
9577 SealHandleScope shs(isolate); 9549 SealHandleScope shs(isolate);
9578 ASSERT(args.length() == 0); 9550 ASSERT(args.length() == 0);
9579 isolate->PrintStack(stdout); 9551 isolate->PrintStack(stdout);
9580 return isolate->heap()->undefined_value(); 9552 return isolate->heap()->undefined_value();
9581 } 9553 }
9582 9554
9583 9555
9584 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateCurrentTime) { 9556 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateCurrentTime) {
9585 SealHandleScope shs(isolate); 9557 HandleScope scope(isolate);
9586 ASSERT(args.length() == 0); 9558 ASSERT(args.length() == 0);
9587 9559
9588 // According to ECMA-262, section 15.9.1, page 117, the precision of 9560 // 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 9561 // the number in a Date object representing a particular instant in
9590 // time is milliseconds. Therefore, we floor the result of getting 9562 // time is milliseconds. Therefore, we floor the result of getting
9591 // the OS time. 9563 // the OS time.
9592 double millis = std::floor(OS::TimeCurrentMillis()); 9564 double millis = std::floor(OS::TimeCurrentMillis());
9593 return isolate->heap()->NumberFromDouble(millis); 9565 return *isolate->factory()->NewNumber(millis);
9594 } 9566 }
9595 9567
9596 9568
9597 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateParseString) { 9569 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateParseString) {
9598 HandleScope scope(isolate); 9570 HandleScope scope(isolate);
9599 ASSERT(args.length() == 2); 9571 ASSERT(args.length() == 2);
9600 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); 9572 CONVERT_ARG_HANDLE_CHECKED(String, str, 0);
9601 CONVERT_ARG_HANDLE_CHECKED(JSArray, output, 1); 9573 CONVERT_ARG_HANDLE_CHECKED(JSArray, output, 1);
9602 9574
9603 JSObject::EnsureCanContainHeapObjectElements(output); 9575 JSObject::EnsureCanContainHeapObjectElements(output);
(...skipping 30 matching lines...) Expand all
9634 ASSERT(args.length() == 1); 9606 ASSERT(args.length() == 1);
9635 9607
9636 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 9608 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
9637 const char* zone = 9609 const char* zone =
9638 isolate->date_cache()->LocalTimezone(static_cast<int64_t>(x)); 9610 isolate->date_cache()->LocalTimezone(static_cast<int64_t>(x));
9639 return isolate->heap()->AllocateStringFromUtf8(CStrVector(zone)); 9611 return isolate->heap()->AllocateStringFromUtf8(CStrVector(zone));
9640 } 9612 }
9641 9613
9642 9614
9643 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateToUTC) { 9615 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateToUTC) {
9644 SealHandleScope shs(isolate); 9616 HandleScope scope(isolate);
9645 ASSERT(args.length() == 1); 9617 ASSERT(args.length() == 1);
9646 9618
9647 CONVERT_DOUBLE_ARG_CHECKED(x, 0); 9619 CONVERT_DOUBLE_ARG_CHECKED(x, 0);
9648 int64_t time = isolate->date_cache()->ToUTC(static_cast<int64_t>(x)); 9620 int64_t time = isolate->date_cache()->ToUTC(static_cast<int64_t>(x));
9649 9621
9650 return isolate->heap()->NumberFromDouble(static_cast<double>(time)); 9622 return *isolate->factory()->NewNumber(static_cast<double>(time));
9651 } 9623 }
9652 9624
9653 9625
9654 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateCacheVersion) { 9626 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateCacheVersion) {
9655 HandleScope hs(isolate); 9627 HandleScope hs(isolate);
9656 ASSERT(args.length() == 0); 9628 ASSERT(args.length() == 0);
9657 if (!isolate->eternal_handles()->Exists(EternalHandles::DATE_CACHE_VERSION)) { 9629 if (!isolate->eternal_handles()->Exists(EternalHandles::DATE_CACHE_VERSION)) {
9658 Handle<FixedArray> date_cache_version = 9630 Handle<FixedArray> date_cache_version =
9659 isolate->factory()->NewFixedArray(1, TENURED); 9631 isolate->factory()->NewFixedArray(1, TENURED);
9660 date_cache_version->set(0, Smi::FromInt(0)); 9632 date_cache_version->set(0, Smi::FromInt(0));
(...skipping 5447 matching lines...) Expand 10 before | Expand all | Expand 10 after
15108 } 15080 }
15109 } 15081 }
15110 15082
15111 15083
15112 void Runtime::OutOfMemory() { 15084 void Runtime::OutOfMemory() {
15113 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true); 15085 Heap::FatalProcessOutOfMemory("CALL_AND_RETRY_LAST", true);
15114 UNREACHABLE(); 15086 UNREACHABLE();
15115 } 15087 }
15116 15088
15117 } } // namespace v8::internal 15089 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698