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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 } | 83 } |
84 if (isolate->has_pending_exception()) return isolate->heap()->exception(); | 84 if (isolate->has_pending_exception()) return isolate->heap()->exception(); |
85 // In case of empty handle and no pending exception we have stack overflow. | 85 // In case of empty handle and no pending exception we have stack overflow. |
86 return isolate->StackOverflow(); | 86 return isolate->StackOverflow(); |
87 } | 87 } |
88 | 88 |
89 | 89 |
90 RUNTIME_FUNCTION(Runtime_StringIndexOf) { | 90 RUNTIME_FUNCTION(Runtime_StringIndexOf) { |
91 HandleScope scope(isolate); | 91 HandleScope scope(isolate); |
92 DCHECK(args.length() == 3); | 92 DCHECK(args.length() == 3); |
93 | 93 return String::IndexOf(isolate, args.at<Object>(0), |
94 CONVERT_ARG_HANDLE_CHECKED(String, sub, 0); | 94 args.at<Object>(1), args.at<Object>(2)); |
95 CONVERT_ARG_HANDLE_CHECKED(String, pat, 1); | |
96 CONVERT_ARG_HANDLE_CHECKED(Object, index, 2); | |
97 | |
98 uint32_t start_index = 0; | |
99 if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); | |
100 | |
101 CHECK(start_index <= static_cast<uint32_t>(sub->length())); | |
102 int position = String::IndexOf(isolate, sub, pat, start_index); | |
103 return Smi::FromInt(position); | |
104 } | 95 } |
105 | 96 |
106 RUNTIME_FUNCTION(Runtime_StringLastIndexOf) { | 97 RUNTIME_FUNCTION(Runtime_StringLastIndexOf) { |
107 HandleScope handle_scope(isolate); | 98 HandleScope handle_scope(isolate); |
108 return String::LastIndexOf(isolate, args.at<Object>(0), args.at<Object>(1), | 99 return String::LastIndexOf(isolate, args.at<Object>(0), args.at<Object>(1), |
109 isolate->factory()->undefined_value()); | 100 isolate->factory()->undefined_value()); |
110 } | 101 } |
111 | 102 |
112 RUNTIME_FUNCTION(Runtime_SubString) { | 103 RUNTIME_FUNCTION(Runtime_SubString) { |
113 HandleScope scope(isolate); | 104 HandleScope scope(isolate); |
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 SealHandleScope shs(isolate); | 1037 SealHandleScope shs(isolate); |
1047 DCHECK(args.length() == 2); | 1038 DCHECK(args.length() == 2); |
1048 if (!args[0]->IsString()) return isolate->heap()->undefined_value(); | 1039 if (!args[0]->IsString()) return isolate->heap()->undefined_value(); |
1049 if (!args[1]->IsNumber()) return isolate->heap()->undefined_value(); | 1040 if (!args[1]->IsNumber()) return isolate->heap()->undefined_value(); |
1050 if (std::isinf(args.number_at(1))) return isolate->heap()->nan_value(); | 1041 if (std::isinf(args.number_at(1))) return isolate->heap()->nan_value(); |
1051 return __RT_impl_Runtime_StringCharCodeAtRT(args, isolate); | 1042 return __RT_impl_Runtime_StringCharCodeAtRT(args, isolate); |
1052 } | 1043 } |
1053 | 1044 |
1054 } // namespace internal | 1045 } // namespace internal |
1055 } // namespace v8 | 1046 } // namespace v8 |
OLD | NEW |