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 7551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7562 CONVERT_DOUBLE_ARG_CHECKED(time, 1); | 7562 CONVERT_DOUBLE_ARG_CHECKED(time, 1); |
7563 CONVERT_SMI_ARG_CHECKED(is_utc, 2); | 7563 CONVERT_SMI_ARG_CHECKED(is_utc, 2); |
7564 | 7564 |
7565 DateCache* date_cache = isolate->date_cache(); | 7565 DateCache* date_cache = isolate->date_cache(); |
7566 | 7566 |
7567 Object* value = NULL; | 7567 Object* value = NULL; |
7568 bool is_value_nan = false; | 7568 bool is_value_nan = false; |
7569 if (isnan(time)) { | 7569 if (isnan(time)) { |
7570 value = isolate->heap()->nan_value(); | 7570 value = isolate->heap()->nan_value(); |
7571 is_value_nan = true; | 7571 is_value_nan = true; |
| 7572 } else if (!is_utc && |
| 7573 (time < -DateCache::kMaxTimeBeforeUTCInMs || |
| 7574 time > DateCache::kMaxTimeBeforeUTCInMs)) { |
| 7575 value = isolate->heap()->nan_value(); |
| 7576 is_value_nan = true; |
7572 } else { | 7577 } else { |
7573 time = is_utc ? time : date_cache->ToUTC(time); | 7578 time = is_utc ? time : date_cache->ToUTC(static_cast<int64_t>(time)); |
7574 if (time < -DateCache::kMaxTimeInMs || | 7579 if (time < -DateCache::kMaxTimeInMs || |
7575 time > DateCache::kMaxTimeInMs) { | 7580 time > DateCache::kMaxTimeInMs) { |
7576 value = isolate->heap()->nan_value(); | 7581 value = isolate->heap()->nan_value(); |
7577 is_value_nan = true; | 7582 is_value_nan = true; |
7578 } else { | 7583 } else { |
7579 MaybeObject* maybe_result = | 7584 MaybeObject* maybe_result = |
7580 isolate->heap()->AllocateHeapNumber(DoubleToInteger(time)); | 7585 isolate->heap()->AllocateHeapNumber(DoubleToInteger(time)); |
7581 if (!maybe_result->ToObject(&value)) return maybe_result; | 7586 if (!maybe_result->ToObject(&value)) return maybe_result; |
7582 } | 7587 } |
7583 } | 7588 } |
(...skipping 1468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9052 } | 9057 } |
9053 } | 9058 } |
9054 | 9059 |
9055 | 9060 |
9056 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateLocalTimezone) { | 9061 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateLocalTimezone) { |
9057 NoHandleAllocation ha; | 9062 NoHandleAllocation ha; |
9058 ASSERT(args.length() == 1); | 9063 ASSERT(args.length() == 1); |
9059 | 9064 |
9060 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 9065 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
9061 int64_t time = isolate->date_cache()->EquivalentTime(static_cast<int64_t>(x)); | 9066 int64_t time = isolate->date_cache()->EquivalentTime(static_cast<int64_t>(x)); |
9062 const char* zone = OS::LocalTimezone(time); | 9067 const char* zone = OS::LocalTimezone(static_cast<double>(time)); |
9063 return isolate->heap()->AllocateStringFromUtf8(CStrVector(zone)); | 9068 return isolate->heap()->AllocateStringFromUtf8(CStrVector(zone)); |
9064 } | 9069 } |
9065 | 9070 |
9066 | 9071 |
9067 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateToUTC) { | 9072 RUNTIME_FUNCTION(MaybeObject*, Runtime_DateToUTC) { |
9068 NoHandleAllocation ha; | 9073 NoHandleAllocation ha; |
9069 ASSERT(args.length() == 1); | 9074 ASSERT(args.length() == 1); |
9070 | 9075 |
9071 CONVERT_DOUBLE_ARG_CHECKED(x, 0); | 9076 CONVERT_DOUBLE_ARG_CHECKED(x, 0); |
9072 int64_t time = isolate->date_cache()->ToUTC(static_cast<int64_t>(x)); | 9077 int64_t time = isolate->date_cache()->ToUTC(static_cast<int64_t>(x)); |
9073 | 9078 |
9074 return isolate->heap()->NumberFromDouble(time); | 9079 return isolate->heap()->NumberFromDouble(static_cast<double>(time)); |
9075 } | 9080 } |
9076 | 9081 |
9077 | 9082 |
9078 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalReceiver) { | 9083 RUNTIME_FUNCTION(MaybeObject*, Runtime_GlobalReceiver) { |
9079 ASSERT(args.length() == 1); | 9084 ASSERT(args.length() == 1); |
9080 Object* global = args[0]; | 9085 Object* global = args[0]; |
9081 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); | 9086 if (!global->IsJSGlobalObject()) return isolate->heap()->null_value(); |
9082 return JSGlobalObject::cast(global)->global_receiver(); | 9087 return JSGlobalObject::cast(global)->global_receiver(); |
9083 } | 9088 } |
9084 | 9089 |
(...skipping 4231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13316 // Handle last resort GC and make sure to allow future allocations | 13321 // Handle last resort GC and make sure to allow future allocations |
13317 // to grow the heap without causing GCs (if possible). | 13322 // to grow the heap without causing GCs (if possible). |
13318 isolate->counters()->gc_last_resort_from_js()->Increment(); | 13323 isolate->counters()->gc_last_resort_from_js()->Increment(); |
13319 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, | 13324 isolate->heap()->CollectAllGarbage(Heap::kNoGCFlags, |
13320 "Runtime::PerformGC"); | 13325 "Runtime::PerformGC"); |
13321 } | 13326 } |
13322 } | 13327 } |
13323 | 13328 |
13324 | 13329 |
13325 } } // namespace v8::internal | 13330 } } // namespace v8::internal |
OLD | NEW |