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/regexp/jsregexp-inl.h" | 8 #include "src/regexp/jsregexp-inl.h" |
9 #include "src/string-builder.h" | 9 #include "src/string-builder.h" |
10 #include "src/string-search.h" | 10 #include "src/string-search.h" |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 return *isolate->factory()->NewSubString(string, start, end); | 306 return *isolate->factory()->NewSubString(string, start, end); |
307 } | 307 } |
308 | 308 |
309 | 309 |
310 RUNTIME_FUNCTION(Runtime_StringAdd) { | 310 RUNTIME_FUNCTION(Runtime_StringAdd) { |
311 HandleScope scope(isolate); | 311 HandleScope scope(isolate); |
312 DCHECK(args.length() == 2); | 312 DCHECK(args.length() == 2); |
313 CONVERT_ARG_HANDLE_CHECKED(String, str1, 0); | 313 CONVERT_ARG_HANDLE_CHECKED(String, str1, 0); |
314 CONVERT_ARG_HANDLE_CHECKED(String, str2, 1); | 314 CONVERT_ARG_HANDLE_CHECKED(String, str2, 1); |
315 isolate->counters()->string_add_runtime()->Increment(); | 315 isolate->counters()->string_add_runtime()->Increment(); |
316 Handle<String> result; | 316 RETURN_RESULT_OR_FAILURE(isolate, |
317 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 317 isolate->factory()->NewConsString(str1, str2)); |
318 isolate, result, isolate->factory()->NewConsString(str1, str2)); | |
319 return *result; | |
320 } | 318 } |
321 | 319 |
322 | 320 |
323 RUNTIME_FUNCTION(Runtime_InternalizeString) { | 321 RUNTIME_FUNCTION(Runtime_InternalizeString) { |
324 HandleScope handles(isolate); | 322 HandleScope handles(isolate); |
325 RUNTIME_ASSERT(args.length() == 1); | 323 RUNTIME_ASSERT(args.length() == 1); |
326 CONVERT_ARG_HANDLE_CHECKED(String, string, 0); | 324 CONVERT_ARG_HANDLE_CHECKED(String, string, 0); |
327 return *isolate->factory()->InternalizeString(string); | 325 return *isolate->factory()->InternalizeString(string); |
328 } | 326 } |
329 | 327 |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1133 return *SeqString::Truncate(string, new_length); | 1131 return *SeqString::Truncate(string, new_length); |
1134 } | 1132 } |
1135 | 1133 |
1136 | 1134 |
1137 RUNTIME_FUNCTION(Runtime_NewString) { | 1135 RUNTIME_FUNCTION(Runtime_NewString) { |
1138 HandleScope scope(isolate); | 1136 HandleScope scope(isolate); |
1139 DCHECK(args.length() == 2); | 1137 DCHECK(args.length() == 2); |
1140 CONVERT_INT32_ARG_CHECKED(length, 0); | 1138 CONVERT_INT32_ARG_CHECKED(length, 0); |
1141 CONVERT_BOOLEAN_ARG_CHECKED(is_one_byte, 1); | 1139 CONVERT_BOOLEAN_ARG_CHECKED(is_one_byte, 1); |
1142 if (length == 0) return isolate->heap()->empty_string(); | 1140 if (length == 0) return isolate->heap()->empty_string(); |
1143 Handle<String> result; | |
1144 if (is_one_byte) { | 1141 if (is_one_byte) { |
1145 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1142 RETURN_RESULT_OR_FAILURE(isolate, |
1146 isolate, result, isolate->factory()->NewRawOneByteString(length)); | 1143 isolate->factory()->NewRawOneByteString(length)); |
1147 } else { | 1144 } else { |
1148 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1145 RETURN_RESULT_OR_FAILURE(isolate, |
1149 isolate, result, isolate->factory()->NewRawTwoByteString(length)); | 1146 isolate->factory()->NewRawTwoByteString(length)); |
1150 } | 1147 } |
1151 return *result; | |
1152 } | 1148 } |
1153 | 1149 |
1154 | 1150 |
1155 RUNTIME_FUNCTION(Runtime_StringLessThan) { | 1151 RUNTIME_FUNCTION(Runtime_StringLessThan) { |
1156 HandleScope handle_scope(isolate); | 1152 HandleScope handle_scope(isolate); |
1157 DCHECK_EQ(2, args.length()); | 1153 DCHECK_EQ(2, args.length()); |
1158 CONVERT_ARG_HANDLE_CHECKED(String, x, 0); | 1154 CONVERT_ARG_HANDLE_CHECKED(String, x, 0); |
1159 CONVERT_ARG_HANDLE_CHECKED(String, y, 1); | 1155 CONVERT_ARG_HANDLE_CHECKED(String, y, 1); |
1160 switch (String::Compare(x, y)) { | 1156 switch (String::Compare(x, y)) { |
1161 case ComparisonResult::kLessThan: | 1157 case ComparisonResult::kLessThan: |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1323 SealHandleScope shs(isolate); | 1319 SealHandleScope shs(isolate); |
1324 DCHECK(args.length() == 2); | 1320 DCHECK(args.length() == 2); |
1325 if (!args[0]->IsString()) return isolate->heap()->undefined_value(); | 1321 if (!args[0]->IsString()) return isolate->heap()->undefined_value(); |
1326 if (!args[1]->IsNumber()) return isolate->heap()->undefined_value(); | 1322 if (!args[1]->IsNumber()) return isolate->heap()->undefined_value(); |
1327 if (std::isinf(args.number_at(1))) return isolate->heap()->nan_value(); | 1323 if (std::isinf(args.number_at(1))) return isolate->heap()->nan_value(); |
1328 return __RT_impl_Runtime_StringCharCodeAtRT(args, isolate); | 1324 return __RT_impl_Runtime_StringCharCodeAtRT(args, isolate); |
1329 } | 1325 } |
1330 | 1326 |
1331 } // namespace internal | 1327 } // namespace internal |
1332 } // namespace v8 | 1328 } // namespace v8 |
OLD | NEW |