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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/jsregexp-inl.h" | 8 #include "src/jsregexp-inl.h" |
9 #include "src/jsregexp.h" | 9 #include "src/jsregexp.h" |
10 #include "src/runtime/runtime-utils.h" | 10 #include "src/runtime/runtime-utils.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 const int kRecursionLimit = 0x1000; | 114 const int kRecursionLimit = 0x1000; |
115 bool found = false; | 115 bool found = false; |
116 Handle<String> result; | 116 Handle<String> result; |
117 if (StringReplaceOneCharWithString(isolate, subject, search, replace, &found, | 117 if (StringReplaceOneCharWithString(isolate, subject, search, replace, &found, |
118 kRecursionLimit).ToHandle(&result)) { | 118 kRecursionLimit).ToHandle(&result)) { |
119 return *result; | 119 return *result; |
120 } | 120 } |
121 if (isolate->has_pending_exception()) return isolate->heap()->exception(); | 121 if (isolate->has_pending_exception()) return isolate->heap()->exception(); |
122 | 122 |
123 subject = String::Flatten(subject); | 123 subject = String::Flatten(subject); |
124 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 124 if (StringReplaceOneCharWithString(isolate, subject, search, replace, &found, |
125 isolate, result, | 125 kRecursionLimit).ToHandle(&result)) { |
126 StringReplaceOneCharWithString(isolate, subject, search, replace, &found, | 126 return *result; |
127 kRecursionLimit)); | 127 } |
128 return *result; | 128 if (isolate->has_pending_exception()) return isolate->heap()->exception(); |
| 129 // In case of empty handle and no pending exception we have stack overflow. |
| 130 return isolate->StackOverflow(); |
129 } | 131 } |
130 | 132 |
131 | 133 |
132 RUNTIME_FUNCTION(Runtime_StringIndexOf) { | 134 RUNTIME_FUNCTION(Runtime_StringIndexOf) { |
133 HandleScope scope(isolate); | 135 HandleScope scope(isolate); |
134 DCHECK(args.length() == 3); | 136 DCHECK(args.length() == 3); |
135 | 137 |
136 CONVERT_ARG_HANDLE_CHECKED(String, sub, 0); | 138 CONVERT_ARG_HANDLE_CHECKED(String, sub, 0); |
137 CONVERT_ARG_HANDLE_CHECKED(String, pat, 1); | 139 CONVERT_ARG_HANDLE_CHECKED(String, pat, 1); |
138 CONVERT_ARG_HANDLE_CHECKED(Object, index, 2); | 140 CONVERT_ARG_HANDLE_CHECKED(Object, index, 2); |
(...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1344 | 1346 |
1345 | 1347 |
1346 RUNTIME_FUNCTION(Runtime_StringGetLength) { | 1348 RUNTIME_FUNCTION(Runtime_StringGetLength) { |
1347 HandleScope scope(isolate); | 1349 HandleScope scope(isolate); |
1348 DCHECK(args.length() == 1); | 1350 DCHECK(args.length() == 1); |
1349 CONVERT_ARG_HANDLE_CHECKED(String, s, 0); | 1351 CONVERT_ARG_HANDLE_CHECKED(String, s, 0); |
1350 return Smi::FromInt(s->length()); | 1352 return Smi::FromInt(s->length()); |
1351 } | 1353 } |
1352 } // namespace internal | 1354 } // namespace internal |
1353 } // namespace v8 | 1355 } // namespace v8 |
OLD | NEW |