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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 CONVERT_SMI_ARG_CHECKED(from_number, 1); | 291 CONVERT_SMI_ARG_CHECKED(from_number, 1); |
292 CONVERT_SMI_ARG_CHECKED(to_number, 2); | 292 CONVERT_SMI_ARG_CHECKED(to_number, 2); |
293 start = from_number; | 293 start = from_number; |
294 end = to_number; | 294 end = to_number; |
295 } else { | 295 } else { |
296 CONVERT_DOUBLE_ARG_CHECKED(from_number, 1); | 296 CONVERT_DOUBLE_ARG_CHECKED(from_number, 1); |
297 CONVERT_DOUBLE_ARG_CHECKED(to_number, 2); | 297 CONVERT_DOUBLE_ARG_CHECKED(to_number, 2); |
298 start = FastD2IChecked(from_number); | 298 start = FastD2IChecked(from_number); |
299 end = FastD2IChecked(to_number); | 299 end = FastD2IChecked(to_number); |
300 } | 300 } |
301 RUNTIME_ASSERT(end >= start); | 301 // The following condition is intentionally robust because the SubStringStub |
302 RUNTIME_ASSERT(start >= 0); | 302 // delegates here and we test this in cctest/test-strings/RobustSubStringStub. |
303 RUNTIME_ASSERT(end <= string->length()); | 303 if (end < start || start < 0 || end > string->length()) { |
| 304 return isolate->ThrowIllegalOperation(); |
| 305 } |
304 isolate->counters()->sub_string_runtime()->Increment(); | 306 isolate->counters()->sub_string_runtime()->Increment(); |
305 | 307 |
306 return *isolate->factory()->NewSubString(string, start, end); | 308 return *isolate->factory()->NewSubString(string, start, end); |
307 } | 309 } |
308 | 310 |
309 | 311 |
310 RUNTIME_FUNCTION(Runtime_StringAdd) { | 312 RUNTIME_FUNCTION(Runtime_StringAdd) { |
311 HandleScope scope(isolate); | 313 HandleScope scope(isolate); |
312 DCHECK(args.length() == 2); | 314 DCHECK(args.length() == 2); |
313 CONVERT_ARG_HANDLE_CHECKED(String, str1, 0); | 315 CONVERT_ARG_HANDLE_CHECKED(String, str1, 0); |
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 SealHandleScope shs(isolate); | 1208 SealHandleScope shs(isolate); |
1207 DCHECK(args.length() == 2); | 1209 DCHECK(args.length() == 2); |
1208 if (!args[0]->IsString()) return isolate->heap()->undefined_value(); | 1210 if (!args[0]->IsString()) return isolate->heap()->undefined_value(); |
1209 if (!args[1]->IsNumber()) return isolate->heap()->undefined_value(); | 1211 if (!args[1]->IsNumber()) return isolate->heap()->undefined_value(); |
1210 if (std::isinf(args.number_at(1))) return isolate->heap()->nan_value(); | 1212 if (std::isinf(args.number_at(1))) return isolate->heap()->nan_value(); |
1211 return __RT_impl_Runtime_StringCharCodeAtRT(args, isolate); | 1213 return __RT_impl_Runtime_StringCharCodeAtRT(args, isolate); |
1212 } | 1214 } |
1213 | 1215 |
1214 } // namespace internal | 1216 } // namespace internal |
1215 } // namespace v8 | 1217 } // namespace v8 |
OLD | NEW |