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

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

Issue 1167813003: [date] Refactor the %_DateField intrinsic to be optimizable. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comments. Created 5 years, 7 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/x64/full-codegen-x64.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 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
« no previous file with comments | « src/runtime/runtime.h ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698