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

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

Issue 662413002: Move some Runtime:: functions and remove runtime.h as include when unnecessary. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « src/runtime/runtime-proxy.cc ('k') | src/runtime/runtime-scopes.cc » ('j') | 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/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.h"
11 #include "src/runtime/runtime-utils.h" 10 #include "src/runtime/runtime-utils.h"
12 #include "src/runtime/string-builder.h" 11 #include "src/runtime/string-builder.h"
13 #include "src/string-search.h" 12 #include "src/string-search.h"
14 13
15 namespace v8 { 14 namespace v8 {
16 namespace internal { 15 namespace internal {
17 16
18 class CompiledReplacement { 17 class CompiledReplacement {
19 public: 18 public:
20 explicit CompiledReplacement(Zone* zone) 19 explicit CompiledReplacement(Zone* zone)
(...skipping 1066 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 return __RT_impl_Runtime_RegExpExecRT(args, isolate); 1086 return __RT_impl_Runtime_RegExpExecRT(args, isolate);
1088 } 1087 }
1089 1088
1090 1089
1091 RUNTIME_FUNCTION(RuntimeReference_IsRegExp) { 1090 RUNTIME_FUNCTION(RuntimeReference_IsRegExp) {
1092 SealHandleScope shs(isolate); 1091 SealHandleScope shs(isolate);
1093 DCHECK(args.length() == 1); 1092 DCHECK(args.length() == 1);
1094 CONVERT_ARG_CHECKED(Object, obj, 0); 1093 CONVERT_ARG_CHECKED(Object, obj, 0);
1095 return isolate->heap()->ToBoolean(obj->IsJSRegExp()); 1094 return isolate->heap()->ToBoolean(obj->IsJSRegExp());
1096 } 1095 }
1097
1098
1099 // Perform string match of pattern on subject, starting at start index.
1100 // Caller must ensure that 0 <= start_index <= sub->length(),
1101 // and should check that pat->length() + start_index <= sub->length().
1102 int Runtime::StringMatch(Isolate* isolate, Handle<String> sub,
1103 Handle<String> pat, int start_index) {
1104 DCHECK(0 <= start_index);
1105 DCHECK(start_index <= sub->length());
1106
1107 int pattern_length = pat->length();
1108 if (pattern_length == 0) return start_index;
1109
1110 int subject_length = sub->length();
1111 if (start_index + pattern_length > subject_length) return -1;
1112
1113 sub = String::Flatten(sub);
1114 pat = String::Flatten(pat);
1115
1116 DisallowHeapAllocation no_gc; // ensure vectors stay valid
1117 // Extract flattened substrings of cons strings before getting encoding.
1118 String::FlatContent seq_sub = sub->GetFlatContent();
1119 String::FlatContent seq_pat = pat->GetFlatContent();
1120
1121 // dispatch on type of strings
1122 if (seq_pat.IsOneByte()) {
1123 Vector<const uint8_t> pat_vector = seq_pat.ToOneByteVector();
1124 if (seq_sub.IsOneByte()) {
1125 return SearchString(isolate, seq_sub.ToOneByteVector(), pat_vector,
1126 start_index);
1127 }
1128 return SearchString(isolate, seq_sub.ToUC16Vector(), pat_vector,
1129 start_index);
1130 }
1131 Vector<const uc16> pat_vector = seq_pat.ToUC16Vector();
1132 if (seq_sub.IsOneByte()) {
1133 return SearchString(isolate, seq_sub.ToOneByteVector(), pat_vector,
1134 start_index);
1135 }
1136 return SearchString(isolate, seq_sub.ToUC16Vector(), pat_vector, start_index);
1137 }
1138 } 1096 }
1139 } // namespace v8::internal 1097 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/runtime/runtime-proxy.cc ('k') | src/runtime/runtime-scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698