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

Unified 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: Some more suggested changes. 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 side-by-side diff with in-line comments
Download patch
Index: src/regexp-macro-assembler.cc
diff --git a/src/regexp-macro-assembler.cc b/src/regexp-macro-assembler.cc
index 55782431bec353820f868b71b94b4d4cb0a661e6..f91ea9348f124a44f5f9d31bc868831f7299a526 100644
--- a/src/regexp-macro-assembler.cc
+++ b/src/regexp-macro-assembler.cc
@@ -120,27 +120,31 @@ NativeRegExpMacroAssembler::Result NativeRegExpMacroAssembler::Match(
String* subject_ptr = *subject;
// Character offsets into string.
int start_offset = previous_index;
- int end_offset = subject_ptr->length();
+ int char_length = subject_ptr->length() - start_offset;
+ int slice_offset = 0;
- // The string has been flattened, so it it is a cons string it contains the
+ // The string has been flattened, so if it is a cons string it contains the
// full string in the first part.
if (StringShape(subject_ptr).IsCons()) {
ASSERT_EQ(0, ConsString::cast(subject_ptr)->second()->length());
subject_ptr = ConsString::cast(subject_ptr)->first();
+ } else if (StringShape(subject_ptr).IsSliced()) {
+ SlicedString* slice = SlicedString::cast(subject_ptr);
+ subject_ptr = slice->parent();
+ slice_offset = slice->offset();
}
// Ensure that an underlying string has the same ascii-ness.
bool is_ascii = subject_ptr->IsAsciiRepresentation();
ASSERT(subject_ptr->IsExternalString() || subject_ptr->IsSeqString());
// String is now either Sequential or External
int char_size_shift = is_ascii ? 0 : 1;
- int char_length = end_offset - start_offset;
const byte* input_start =
- StringCharacterPosition(subject_ptr, start_offset);
+ StringCharacterPosition(subject_ptr, start_offset + slice_offset);
int byte_length = char_length << char_size_shift;
const byte* input_end = input_start + byte_length;
Result res = Execute(*regexp_code,
- subject_ptr,
+ *subject,
start_offset,
input_start,
input_end,
@@ -152,7 +156,7 @@ NativeRegExpMacroAssembler::Result NativeRegExpMacroAssembler::Match(
NativeRegExpMacroAssembler::Result NativeRegExpMacroAssembler::Execute(
Code* code,
- String* input,
+ String* input, // This needs to be the unpacked (sliced, cons) string.
int start_offset,
const byte* input_start,
const byte* input_end,
« src/ia32/code-stubs-ia32.cc ('K') | « src/objects-visiting.cc ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698