| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   130  |   130  | 
|   131  |   131  | 
|   132 RUNTIME_FUNCTION(Runtime_StringIndexOf) { |   132 RUNTIME_FUNCTION(Runtime_StringIndexOf) { | 
|   133   HandleScope scope(isolate); |   133   HandleScope scope(isolate); | 
|   134   DCHECK(args.length() == 3); |   134   DCHECK(args.length() == 3); | 
|   135  |   135  | 
|   136   CONVERT_ARG_HANDLE_CHECKED(String, sub, 0); |   136   CONVERT_ARG_HANDLE_CHECKED(String, sub, 0); | 
|   137   CONVERT_ARG_HANDLE_CHECKED(String, pat, 1); |   137   CONVERT_ARG_HANDLE_CHECKED(String, pat, 1); | 
|   138   CONVERT_ARG_HANDLE_CHECKED(Object, index, 2); |   138   CONVERT_ARG_HANDLE_CHECKED(Object, index, 2); | 
|   139  |   139  | 
|   140   uint32_t start_index; |   140   uint32_t start_index = 0; | 
|   141   if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); |   141   if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); | 
|   142  |   142  | 
|   143   RUNTIME_ASSERT(start_index <= static_cast<uint32_t>(sub->length())); |   143   RUNTIME_ASSERT(start_index <= static_cast<uint32_t>(sub->length())); | 
|   144   int position = StringMatch(isolate, sub, pat, start_index); |   144   int position = StringMatch(isolate, sub, pat, start_index); | 
|   145   return Smi::FromInt(position); |   145   return Smi::FromInt(position); | 
|   146 } |   146 } | 
|   147  |   147  | 
|   148  |   148  | 
|   149 template <typename schar, typename pchar> |   149 template <typename schar, typename pchar> | 
|   150 static int StringMatchBackwards(Vector<const schar> subject, |   150 static int StringMatchBackwards(Vector<const schar> subject, | 
| (...skipping 30 matching lines...) Expand all  Loading... | 
|   181  |   181  | 
|   182  |   182  | 
|   183 RUNTIME_FUNCTION(Runtime_StringLastIndexOf) { |   183 RUNTIME_FUNCTION(Runtime_StringLastIndexOf) { | 
|   184   HandleScope scope(isolate); |   184   HandleScope scope(isolate); | 
|   185   DCHECK(args.length() == 3); |   185   DCHECK(args.length() == 3); | 
|   186  |   186  | 
|   187   CONVERT_ARG_HANDLE_CHECKED(String, sub, 0); |   187   CONVERT_ARG_HANDLE_CHECKED(String, sub, 0); | 
|   188   CONVERT_ARG_HANDLE_CHECKED(String, pat, 1); |   188   CONVERT_ARG_HANDLE_CHECKED(String, pat, 1); | 
|   189   CONVERT_ARG_HANDLE_CHECKED(Object, index, 2); |   189   CONVERT_ARG_HANDLE_CHECKED(Object, index, 2); | 
|   190  |   190  | 
|   191   uint32_t start_index; |   191   uint32_t start_index = 0; | 
|   192   if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); |   192   if (!index->ToArrayIndex(&start_index)) return Smi::FromInt(-1); | 
|   193  |   193  | 
|   194   uint32_t pat_length = pat->length(); |   194   uint32_t pat_length = pat->length(); | 
|   195   uint32_t sub_length = sub->length(); |   195   uint32_t sub_length = sub->length(); | 
|   196  |   196  | 
|   197   if (start_index + pat_length > sub_length) { |   197   if (start_index + pat_length > sub_length) { | 
|   198     start_index = sub_length - pat_length; |   198     start_index = sub_length - pat_length; | 
|   199   } |   199   } | 
|   200  |   200  | 
|   201   if (pat_length == 0) { |   201   if (pat_length == 0) { | 
| (...skipping 1142 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  1344  |  1344  | 
|  1345  |  1345  | 
|  1346 RUNTIME_FUNCTION(Runtime_StringGetLength) { |  1346 RUNTIME_FUNCTION(Runtime_StringGetLength) { | 
|  1347   HandleScope scope(isolate); |  1347   HandleScope scope(isolate); | 
|  1348   DCHECK(args.length() == 1); |  1348   DCHECK(args.length() == 1); | 
|  1349   CONVERT_ARG_HANDLE_CHECKED(String, s, 0); |  1349   CONVERT_ARG_HANDLE_CHECKED(String, s, 0); | 
|  1350   return Smi::FromInt(s->length()); |  1350   return Smi::FromInt(s->length()); | 
|  1351 } |  1351 } | 
|  1352 }  // namespace internal |  1352 }  // namespace internal | 
|  1353 }  // namespace v8 |  1353 }  // namespace v8 | 
| OLD | NEW |