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

Side by Side Diff: src/runtime/runtime-date.cc

Issue 1191283003: [date] Use explicit control flow to replace %_ThrowIfNotADate. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « src/runtime/runtime.h ('k') | src/x64/full-codegen-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/arguments.h" 7 #include "src/arguments.h"
8 #include "src/date.h" 8 #include "src/date.h"
9 #include "src/dateparser-inl.h" 9 #include "src/dateparser-inl.h"
10 #include "src/messages.h" 10 #include "src/messages.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 is_value_nan = true; 53 is_value_nan = true;
54 } else { 54 } else {
55 value = isolate->factory()->NewNumber(DoubleToInteger(time)); 55 value = isolate->factory()->NewNumber(DoubleToInteger(time));
56 } 56 }
57 } 57 }
58 date->SetValue(*value, is_value_nan); 58 date->SetValue(*value, is_value_nan);
59 return *value; 59 return *value;
60 } 60 }
61 61
62 62
63 RUNTIME_FUNCTION(Runtime_ThrowIfNotADate) { 63 RUNTIME_FUNCTION(Runtime_IsDate) {
64 SealHandleScope shs(isolate); 64 SealHandleScope shs(isolate);
65 DCHECK_EQ(1, args.length()); 65 DCHECK_EQ(1, args.length());
66 CONVERT_ARG_CHECKED(Object, obj, 0); 66 CONVERT_ARG_CHECKED(Object, obj, 0);
67 if (!obj->IsJSDate()) { 67 return isolate->heap()->ToBoolean(obj->IsJSDate());
68 HandleScope scope(isolate);
69 THROW_NEW_ERROR_RETURN_FAILURE(
70 isolate, NewTypeError(MessageTemplate::kNotDateObject));
71 }
72 return obj;
73 } 68 }
74 69
75 70
76 RUNTIME_FUNCTION(Runtime_ThrowNotDateError) { 71 RUNTIME_FUNCTION(Runtime_ThrowNotDateError) {
77 HandleScope scope(isolate); 72 HandleScope scope(isolate);
78 DCHECK(args.length() == 0); 73 DCHECK(args.length() == 0);
79 THROW_NEW_ERROR_RETURN_FAILURE(isolate, 74 THROW_NEW_ERROR_RETURN_FAILURE(isolate,
80 NewTypeError(MessageTemplate::kNotDateObject)); 75 NewTypeError(MessageTemplate::kNotDateObject));
81 } 76 }
82 77
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 DCHECK_EQ(2, args.length()); 185 DCHECK_EQ(2, args.length());
191 CONVERT_ARG_CHECKED(JSDate, date, 0); 186 CONVERT_ARG_CHECKED(JSDate, date, 0);
192 CONVERT_SMI_ARG_CHECKED(index, 1); 187 CONVERT_SMI_ARG_CHECKED(index, 1);
193 DCHECK_LE(0, index); 188 DCHECK_LE(0, index);
194 if (index == 0) return date->value(); 189 if (index == 0) return date->value();
195 return JSDate::GetField(date, Smi::FromInt(index)); 190 return JSDate::GetField(date, Smi::FromInt(index));
196 } 191 }
197 192
198 } // namespace internal 193 } // namespace internal
199 } // namespace v8 194 } // namespace v8
OLDNEW
« 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