Index: src/runtime/runtime-date.cc |
diff --git a/src/runtime/runtime-date.cc b/src/runtime/runtime-date.cc |
index d2b93f03684e9db5238865f7a55c4e8e85ca94e2..47342f98b1a341bc8f42292fe11cbf7b373819df 100644 |
--- a/src/runtime/runtime-date.cc |
+++ b/src/runtime/runtime-date.cc |
@@ -60,6 +60,19 @@ RUNTIME_FUNCTION(Runtime_DateSetValue) { |
} |
+RUNTIME_FUNCTION(Runtime_ThrowIfNotADate) { |
+ SealHandleScope shs(isolate); |
+ DCHECK_EQ(1, args.length()); |
+ CONVERT_ARG_CHECKED(Object, obj, 0); |
+ if (!obj->IsJSDate()) { |
+ HandleScope scope(isolate); |
+ THROW_NEW_ERROR_RETURN_FAILURE( |
+ isolate, NewTypeError(MessageTemplate::kNotDateObject)); |
+ } |
+ return obj; |
+} |
+ |
+ |
RUNTIME_FUNCTION(Runtime_ThrowNotDateError) { |
HandleScope scope(isolate); |
DCHECK(args.length() == 0); |
@@ -174,17 +187,13 @@ RUNTIME_FUNCTION(Runtime_DateCacheVersion) { |
RUNTIME_FUNCTION(Runtime_DateField) { |
SealHandleScope shs(isolate); |
- DCHECK(args.length() == 2); |
- CONVERT_ARG_CHECKED(Object, obj, 0); |
+ DCHECK_EQ(2, args.length()); |
+ CONVERT_ARG_CHECKED(JSDate, date, 0); |
CONVERT_SMI_ARG_CHECKED(index, 1); |
- if (!obj->IsJSDate()) { |
- HandleScope scope(isolate); |
- THROW_NEW_ERROR_RETURN_FAILURE( |
- isolate, NewTypeError(MessageTemplate::kNotDateObject)); |
- } |
- JSDate* date = JSDate::cast(obj); |
+ DCHECK_LE(0, index); |
if (index == 0) return date->value(); |
return JSDate::GetField(date, Smi::FromInt(index)); |
} |
+ |
} // namespace internal |
} // namespace v8 |