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

Unified Diff: src/runtime/runtime-date.cc

Issue 1556333002: [runtime] Migrate several Date builtins to C++. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comments Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | src/runtime/runtime-i18n.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime/runtime-date.cc
diff --git a/src/runtime/runtime-date.cc b/src/runtime/runtime-date.cc
index 7d929d0d79ef025e1ff66b9fbb671d73a3ed8c47..8d9bd70dfb1e1f783a0977fd41b095e361e690d9 100644
--- a/src/runtime/runtime-date.cc
+++ b/src/runtime/runtime-date.cc
@@ -7,7 +7,6 @@
#include "src/arguments.h"
#include "src/conversions-inl.h"
#include "src/date.h"
-#include "src/dateparser-inl.h"
#include "src/factory.h"
#include "src/isolate-inl.h"
#include "src/messages.h"
@@ -79,58 +78,8 @@ RUNTIME_FUNCTION(Runtime_ThrowNotDateError) {
RUNTIME_FUNCTION(Runtime_DateCurrentTime) {
HandleScope scope(isolate);
- DCHECK(args.length() == 0);
- if (FLAG_log_timer_events || FLAG_prof_cpp) LOG(isolate, CurrentTimeEvent());
-
- // According to ECMA-262, section 15.9.1, page 117, the precision of
- // the number in a Date object representing a particular instant in
- // time is milliseconds. Therefore, we floor the result of getting
- // the OS time.
- double millis;
- if (FLAG_verify_predictable) {
- millis = Floor(isolate->heap()->MonotonicallyIncreasingTimeInMs());
- } else {
- millis = Floor(base::OS::TimeCurrentMillis());
- }
- return *isolate->factory()->NewNumber(millis);
-}
-
-
-RUNTIME_FUNCTION(Runtime_DateParseString) {
- HandleScope scope(isolate);
- DCHECK_EQ(2, args.length());
- CONVERT_ARG_HANDLE_CHECKED(Object, input, 0);
- CONVERT_ARG_HANDLE_CHECKED(JSArray, output, 1);
-
- RUNTIME_ASSERT(output->HasFastElements());
- JSObject::EnsureCanContainHeapObjectElements(output);
- RUNTIME_ASSERT(output->HasFastObjectElements());
- Handle<FixedArray> output_array(FixedArray::cast(output->elements()));
- RUNTIME_ASSERT(output_array->length() >= DateParser::OUTPUT_SIZE);
-
- Handle<String> str;
- ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, str,
- Object::ToString(isolate, input));
-
- str = String::Flatten(str);
- DisallowHeapAllocation no_gc;
-
- bool result;
- String::FlatContent str_content = str->GetFlatContent();
- if (str_content.IsOneByte()) {
- result = DateParser::Parse(str_content.ToOneByteVector(), *output_array,
- isolate->unicode_cache());
- } else {
- DCHECK(str_content.IsTwoByte());
- result = DateParser::Parse(str_content.ToUC16Vector(), *output_array,
- isolate->unicode_cache());
- }
-
- if (result) {
- return *output;
- } else {
- return isolate->heap()->null_value();
- }
+ DCHECK_EQ(0, args.length());
+ return *isolate->factory()->NewNumber(JSDate::CurrentTimeValue(isolate));
}
@@ -149,19 +98,6 @@ RUNTIME_FUNCTION(Runtime_DateLocalTimezone) {
}
-RUNTIME_FUNCTION(Runtime_DateToUTC) {
- HandleScope scope(isolate);
- DCHECK(args.length() == 1);
-
- CONVERT_DOUBLE_ARG_CHECKED(x, 0);
- RUNTIME_ASSERT(x >= -DateCache::kMaxTimeBeforeUTCInMs &&
- x <= DateCache::kMaxTimeBeforeUTCInMs);
- int64_t time = isolate->date_cache()->ToUTC(static_cast<int64_t>(x));
-
- return *isolate->factory()->NewNumber(static_cast<double>(time));
-}
-
-
RUNTIME_FUNCTION(Runtime_DateCacheVersion) {
HandleScope hs(isolate);
DCHECK(args.length() == 0);
« no previous file with comments | « src/runtime/runtime.h ('k') | src/runtime/runtime-i18n.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698