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

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

Issue 11228: * No failures on our own tests.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/regexp2000/
Patch Set: Created 12 years, 1 month 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 void RegExpMacroAssemblerRe2k::Fail() { 116 void RegExpMacroAssemblerRe2k::Fail() {
117 assembler_->Fail(); 117 assembler_->Fail();
118 } 118 }
119 119
120 120
121 void RegExpMacroAssemblerRe2k::AdvanceCurrentPosition(int by) { 121 void RegExpMacroAssemblerRe2k::AdvanceCurrentPosition(int by) {
122 assembler_->AdvanceCP(by); 122 assembler_->AdvanceCP(by);
123 } 123 }
124 124
125 125
126 static void TwoWayCharacterClass(
127 Re2kAssembler* assembler,
128 RegExpCharacterClass* char_class,
129 Label* on_match,
130 Label* on_mismatch) {
131 ZoneList<CharacterRange>* ranges = char_class->ranges();
132 int range_count = ranges->length();
133 if (!char_class->is_negated()) {
134 for (int i = 0; i < range_count; i++) {
135 CharacterRange& range = ranges->at(i);
136 assembler->CheckRange(range.from(), range.to(), on_match);
137 }
138 if (on_mismatch == NULL) {
139 assembler->PopBacktrack();
140 } else {
141 assembler->GoTo(on_mismatch);
142 }
143 } else { // range is negated.
144 if (range_count == 0) {
145 assembler->GoTo(on_match);
146 } else {
147 CharacterRange& previous = ranges->at(0);
148 if (previous.from() > 0) {
149 assembler->CheckRange(0, previous.from() - 1, on_match);
150 }
151 for (int i = 1; i < range_count; i++) {
152 CharacterRange& range = ranges->at(i);
153 if (previous.to() < range.from() - 1) {
154 assembler->CheckRange(previous.to() + 1, range.from() - 1, on_match);
155 }
156 previous = range;
157 }
158 if (previous.to() < 65535) {
159 assembler->CheckRange(previous.to() + 1, 65535, on_match);
160 }
161 }
162 }
163 }
164
165
166 void RegExpMacroAssemblerRe2k::CheckCurrentPosition( 126 void RegExpMacroAssemblerRe2k::CheckCurrentPosition(
167 int register_index, 127 int register_index,
168 Label* on_equal) { 128 Label* on_equal) {
169 // TODO(erikcorry): Implement. 129 // TODO(erikcorry): Implement.
170 UNREACHABLE(); 130 UNREACHABLE();
171 } 131 }
172 132
173 133
174 void RegExpMacroAssemblerRe2k::CheckCharacterClass( 134 void RegExpMacroAssemblerRe2k::LoadCurrentCharacter(int cp_offset,
175 RegExpCharacterClass* char_class, 135 Label* on_failure) {
176 int cp_offset,
177 Label* on_failure) {
178 assembler_->LoadCurrentChar(cp_offset, on_failure); 136 assembler_->LoadCurrentChar(cp_offset, on_failure);
179 if (!char_class->is_negated() && 137 }
180 char_class->ranges()->length() == 1 && 138
181 on_failure != NULL) { 139
182 // This is the simple case where the char class has one range and we want to 140 void RegExpMacroAssemblerRe2k::CheckCharacterLT(uc16 limit,
183 // fall through if it matches. 141 Label* on_less) {
184 CharacterRange& range = char_class->ranges()->at(0); 142 assembler_->CheckCharacterLT(limit, on_less);
185 assembler_->CheckNotRange(range.from(), range.to(), on_failure); 143 }
186 } else { 144
187 Label on_success; 145
188 TwoWayCharacterClass(assembler_, char_class, &on_success, on_failure); 146 void RegExpMacroAssemblerRe2k::CheckCharacterGT(uc16 limit,
189 assembler_->Bind(&on_success); 147 Label* on_greater) {
190 } 148 assembler_->CheckCharacterGT(limit, on_greater);
191 } 149 }
192 150
193 151
194 void RegExpMacroAssemblerRe2k::CheckBitmap(uc16 start, 152 void RegExpMacroAssemblerRe2k::CheckBitmap(uc16 start,
195 Label* bitmap, 153 Label* bitmap,
196 Label* on_zero) { 154 Label* on_zero) {
197 assembler_->LookupMap1(start, bitmap, on_zero); 155 assembler_->LookupMap1(start, bitmap, on_zero);
198 } 156 }
199 157
200 158
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 } 206 }
249 207
250 208
251 Handle<Object> RegExpMacroAssemblerRe2k::GetCode() { 209 Handle<Object> RegExpMacroAssemblerRe2k::GetCode() {
252 Handle<ByteArray> array = Factory::NewByteArray(assembler_->length()); 210 Handle<ByteArray> array = Factory::NewByteArray(assembler_->length());
253 assembler_->Copy(array->GetDataStartAddress()); 211 assembler_->Copy(array->GetDataStartAddress());
254 return array; 212 return array;
255 } 213 }
256 214
257 } } // namespace v8::internal 215 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698