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

Side by Side Diff: src/regexp-macro-assembler.cc

Issue 7477045: Tentative implementation of string slices (hidden under the flag --string-slices). (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Support for RegExp. Removed methods related to truncate. Created 9 years, 4 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
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 ASSERT(previous_index >= 0); 113 ASSERT(previous_index >= 0);
114 ASSERT(previous_index <= subject->length()); 114 ASSERT(previous_index <= subject->length());
115 115
116 // No allocations before calling the regexp, but we can't use 116 // No allocations before calling the regexp, but we can't use
117 // AssertNoAllocation, since regexps might be preempted, and another thread 117 // AssertNoAllocation, since regexps might be preempted, and another thread
118 // might do allocation anyway. 118 // might do allocation anyway.
119 119
120 String* subject_ptr = *subject; 120 String* subject_ptr = *subject;
121 // Character offsets into string. 121 // Character offsets into string.
122 int start_offset = previous_index; 122 int start_offset = previous_index;
123 int end_offset = subject_ptr->length(); 123 int char_length = subject_ptr->length() - start_offset;
124 int slice_offset = 0;
124 125
125 // The string has been flattened, so it it is a cons string it contains the 126 // The string has been flattened, so if it is a cons string it contains the
126 // full string in the first part. 127 // full string in the first part.
127 if (StringShape(subject_ptr).IsCons()) { 128 if (StringShape(subject_ptr).IsCons()) {
128 ASSERT_EQ(0, ConsString::cast(subject_ptr)->second()->length()); 129 ASSERT_EQ(0, ConsString::cast(subject_ptr)->second()->length());
129 subject_ptr = ConsString::cast(subject_ptr)->first(); 130 subject_ptr = ConsString::cast(subject_ptr)->first();
131 } else if (StringShape(subject_ptr).IsSliced()) {
132 SlicedString* slice = SlicedString::cast(subject_ptr);
133 subject_ptr = slice->parent();
134 slice_offset = slice->offset();
135 ASSERT(slice->parent()->IsSeqString());
Vitaly Repeshko 2011/08/12 19:01:00 Should this be here? Looks like we can handle exte
130 } 136 }
131 // Ensure that an underlying string has the same ascii-ness. 137 // Ensure that an underlying string has the same ascii-ness.
132 bool is_ascii = subject_ptr->IsAsciiRepresentation(); 138 bool is_ascii = subject_ptr->IsAsciiRepresentation();
133 ASSERT(subject_ptr->IsExternalString() || subject_ptr->IsSeqString()); 139 ASSERT(subject_ptr->IsExternalString() || subject_ptr->IsSeqString());
134 // String is now either Sequential or External 140 // String is now either Sequential or External
135 int char_size_shift = is_ascii ? 0 : 1; 141 int char_size_shift = is_ascii ? 0 : 1;
136 int char_length = end_offset - start_offset;
137 142
138 const byte* input_start = 143 const byte* input_start =
139 StringCharacterPosition(subject_ptr, start_offset); 144 StringCharacterPosition(subject_ptr, start_offset + slice_offset);
140 int byte_length = char_length << char_size_shift; 145 int byte_length = char_length << char_size_shift;
141 const byte* input_end = input_start + byte_length; 146 const byte* input_end = input_start + byte_length;
142 Result res = Execute(*regexp_code, 147 Result res = Execute(*regexp_code,
143 subject_ptr, 148 *subject,
144 start_offset, 149 start_offset,
145 input_start, 150 input_start,
146 input_end, 151 input_end,
147 offsets_vector, 152 offsets_vector,
148 isolate); 153 isolate);
149 return res; 154 return res;
150 } 155 }
151 156
152 157
153 NativeRegExpMacroAssembler::Result NativeRegExpMacroAssembler::Execute( 158 NativeRegExpMacroAssembler::Result NativeRegExpMacroAssembler::Execute(
154 Code* code, 159 Code* code,
155 String* input, 160 String* input, // This needs to be the unpacked (sliced, cons) string.
156 int start_offset, 161 int start_offset,
157 const byte* input_start, 162 const byte* input_start,
158 const byte* input_end, 163 const byte* input_end,
159 int* output, 164 int* output,
160 Isolate* isolate) { 165 Isolate* isolate) {
161 ASSERT(isolate == Isolate::Current()); 166 ASSERT(isolate == Isolate::Current());
162 // Ensure that the minimum stack has been allocated. 167 // Ensure that the minimum stack has been allocated.
163 RegExpStackScope stack_scope(isolate); 168 RegExpStackScope stack_scope(isolate);
164 Address stack_base = stack_scope.stack()->stack_base(); 169 Address stack_base = stack_scope.stack()->stack_base();
165 170
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 return NULL; 263 return NULL;
259 } 264 }
260 *stack_base = new_stack_base; 265 *stack_base = new_stack_base;
261 intptr_t stack_content_size = old_stack_base - stack_pointer; 266 intptr_t stack_content_size = old_stack_base - stack_pointer;
262 return new_stack_base - stack_content_size; 267 return new_stack_base - stack_content_size;
263 } 268 }
264 269
265 #endif // V8_INTERPRETED_REGEXP 270 #endif // V8_INTERPRETED_REGEXP
266 271
267 } } // namespace v8::internal 272 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698