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

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

Issue 559913002: Rename ascii to one-byte where applicable. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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/assembler.h" 7 #include "src/assembler.h"
8 #include "src/ast.h" 8 #include "src/ast.h"
9 #include "src/regexp-macro-assembler.h" 9 #include "src/regexp-macro-assembler.h"
10 #include "src/regexp-stack.h" 10 #include "src/regexp-stack.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 const byte* NativeRegExpMacroAssembler::StringCharacterPosition( 51 const byte* NativeRegExpMacroAssembler::StringCharacterPosition(
52 String* subject, 52 String* subject,
53 int start_index) { 53 int start_index) {
54 // Not just flat, but ultra flat. 54 // Not just flat, but ultra flat.
55 DCHECK(subject->IsExternalString() || subject->IsSeqString()); 55 DCHECK(subject->IsExternalString() || subject->IsSeqString());
56 DCHECK(start_index >= 0); 56 DCHECK(start_index >= 0);
57 DCHECK(start_index <= subject->length()); 57 DCHECK(start_index <= subject->length());
58 if (subject->IsOneByteRepresentation()) { 58 if (subject->IsOneByteRepresentation()) {
59 const byte* address; 59 const byte* address;
60 if (StringShape(subject).IsExternal()) { 60 if (StringShape(subject).IsExternal()) {
61 const uint8_t* data = ExternalAsciiString::cast(subject)->GetChars(); 61 const uint8_t* data = ExternalOneByteString::cast(subject)->GetChars();
62 address = reinterpret_cast<const byte*>(data); 62 address = reinterpret_cast<const byte*>(data);
63 } else { 63 } else {
64 DCHECK(subject->IsSeqOneByteString()); 64 DCHECK(subject->IsSeqOneByteString());
65 const uint8_t* data = SeqOneByteString::cast(subject)->GetChars(); 65 const uint8_t* data = SeqOneByteString::cast(subject)->GetChars();
66 address = reinterpret_cast<const byte*>(data); 66 address = reinterpret_cast<const byte*>(data);
67 } 67 }
68 return address + start_index; 68 return address + start_index;
69 } 69 }
70 const uc16* data; 70 const uc16* data;
71 if (StringShape(subject).IsExternal()) { 71 if (StringShape(subject).IsExternal()) {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // The string has been flattened, so if it is a cons string it contains the 103 // The string has been flattened, so if it is a cons string it contains the
104 // full string in the first part. 104 // full string in the first part.
105 if (StringShape(subject_ptr).IsCons()) { 105 if (StringShape(subject_ptr).IsCons()) {
106 DCHECK_EQ(0, ConsString::cast(subject_ptr)->second()->length()); 106 DCHECK_EQ(0, ConsString::cast(subject_ptr)->second()->length());
107 subject_ptr = ConsString::cast(subject_ptr)->first(); 107 subject_ptr = ConsString::cast(subject_ptr)->first();
108 } else if (StringShape(subject_ptr).IsSliced()) { 108 } else if (StringShape(subject_ptr).IsSliced()) {
109 SlicedString* slice = SlicedString::cast(subject_ptr); 109 SlicedString* slice = SlicedString::cast(subject_ptr);
110 subject_ptr = slice->parent(); 110 subject_ptr = slice->parent();
111 slice_offset = slice->offset(); 111 slice_offset = slice->offset();
112 } 112 }
113 // Ensure that an underlying string has the same ASCII-ness. 113 // Ensure that an underlying string has the same representation.
114 bool is_ascii = subject_ptr->IsOneByteRepresentation(); 114 bool is_one_byte = subject_ptr->IsOneByteRepresentation();
115 DCHECK(subject_ptr->IsExternalString() || subject_ptr->IsSeqString()); 115 DCHECK(subject_ptr->IsExternalString() || subject_ptr->IsSeqString());
116 // String is now either Sequential or External 116 // String is now either Sequential or External
117 int char_size_shift = is_ascii ? 0 : 1; 117 int char_size_shift = is_one_byte ? 0 : 1;
118 118
119 const byte* input_start = 119 const byte* input_start =
120 StringCharacterPosition(subject_ptr, start_offset + slice_offset); 120 StringCharacterPosition(subject_ptr, start_offset + slice_offset);
121 int byte_length = char_length << char_size_shift; 121 int byte_length = char_length << char_size_shift;
122 const byte* input_end = input_start + byte_length; 122 const byte* input_end = input_start + byte_length;
123 Result res = Execute(*regexp_code, 123 Result res = Execute(*regexp_code,
124 *subject, 124 *subject,
125 start_offset, 125 start_offset,
126 input_start, 126 input_start,
127 input_end, 127 input_end,
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 return NULL; 258 return NULL;
259 } 259 }
260 *stack_base = new_stack_base; 260 *stack_base = new_stack_base;
261 intptr_t stack_content_size = old_stack_base - stack_pointer; 261 intptr_t stack_content_size = old_stack_base - stack_pointer;
262 return new_stack_base - stack_content_size; 262 return new_stack_base - stack_content_size;
263 } 263 }
264 264
265 #endif // V8_INTERPRETED_REGEXP 265 #endif // V8_INTERPRETED_REGEXP
266 266
267 } } // namespace v8::internal 267 } } // namespace v8::internal
OLDNEW
« src/jsregexp.cc ('K') | « src/regexp-macro-assembler.h ('k') | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698