OLD | NEW |
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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/conversions-inl.h" | 8 #include "src/conversions-inl.h" |
9 #include "src/date.h" | 9 #include "src/date.h" |
10 #include "src/dateparser-inl.h" | 10 #include "src/dateparser-inl.h" |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 millis += Floor(isolate->heap()->synthetic_time()); | 93 millis += Floor(isolate->heap()->synthetic_time()); |
94 } else { | 94 } else { |
95 millis = Floor(base::OS::TimeCurrentMillis()); | 95 millis = Floor(base::OS::TimeCurrentMillis()); |
96 } | 96 } |
97 return *isolate->factory()->NewNumber(millis); | 97 return *isolate->factory()->NewNumber(millis); |
98 } | 98 } |
99 | 99 |
100 | 100 |
101 RUNTIME_FUNCTION(Runtime_DateParseString) { | 101 RUNTIME_FUNCTION(Runtime_DateParseString) { |
102 HandleScope scope(isolate); | 102 HandleScope scope(isolate); |
103 DCHECK(args.length() == 2); | 103 DCHECK_EQ(2, args.length()); |
104 CONVERT_ARG_HANDLE_CHECKED(String, str, 0); | 104 CONVERT_ARG_HANDLE_CHECKED(Object, input, 0); |
105 CONVERT_ARG_HANDLE_CHECKED(JSArray, output, 1); | 105 CONVERT_ARG_HANDLE_CHECKED(JSArray, output, 1); |
106 | 106 |
107 RUNTIME_ASSERT(output->HasFastElements()); | 107 RUNTIME_ASSERT(output->HasFastElements()); |
108 JSObject::EnsureCanContainHeapObjectElements(output); | 108 JSObject::EnsureCanContainHeapObjectElements(output); |
109 RUNTIME_ASSERT(output->HasFastObjectElements()); | 109 RUNTIME_ASSERT(output->HasFastObjectElements()); |
110 Handle<FixedArray> output_array(FixedArray::cast(output->elements())); | 110 Handle<FixedArray> output_array(FixedArray::cast(output->elements())); |
111 RUNTIME_ASSERT(output_array->length() >= DateParser::OUTPUT_SIZE); | 111 RUNTIME_ASSERT(output_array->length() >= DateParser::OUTPUT_SIZE); |
112 | 112 |
| 113 Handle<String> str; |
| 114 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, str, |
| 115 Object::ToString(isolate, input)); |
| 116 |
113 str = String::Flatten(str); | 117 str = String::Flatten(str); |
114 DisallowHeapAllocation no_gc; | 118 DisallowHeapAllocation no_gc; |
115 | 119 |
116 bool result; | 120 bool result; |
117 String::FlatContent str_content = str->GetFlatContent(); | 121 String::FlatContent str_content = str->GetFlatContent(); |
118 if (str_content.IsOneByte()) { | 122 if (str_content.IsOneByte()) { |
119 result = DateParser::Parse(str_content.ToOneByteVector(), *output_array, | 123 result = DateParser::Parse(str_content.ToOneByteVector(), *output_array, |
120 isolate->unicode_cache()); | 124 isolate->unicode_cache()); |
121 } else { | 125 } else { |
122 DCHECK(str_content.IsTwoByte()); | 126 DCHECK(str_content.IsTwoByte()); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 DCHECK_EQ(2, args.length()); | 191 DCHECK_EQ(2, args.length()); |
188 CONVERT_ARG_CHECKED(JSDate, date, 0); | 192 CONVERT_ARG_CHECKED(JSDate, date, 0); |
189 CONVERT_SMI_ARG_CHECKED(index, 1); | 193 CONVERT_SMI_ARG_CHECKED(index, 1); |
190 DCHECK_LE(0, index); | 194 DCHECK_LE(0, index); |
191 if (index == 0) return date->value(); | 195 if (index == 0) return date->value(); |
192 return JSDate::GetField(date, Smi::FromInt(index)); | 196 return JSDate::GetField(date, Smi::FromInt(index)); |
193 } | 197 } |
194 | 198 |
195 } // namespace internal | 199 } // namespace internal |
196 } // namespace v8 | 200 } // namespace v8 |
OLD | NEW |