Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: src/runtime/runtime-strings.cc

Issue 2350963004: [builtins] Move StringIndexOf to a C++ builtin. (Closed)
Patch Set: Fix formatting errors Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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), args.at<Object>(1),
94 CONVERT_ARG_HANDLE_CHECKED(String, sub, 0); 94 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
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
OLDNEW
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698