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

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

Issue 10750: * Update to RegExp parsing and AST. (Closed)
Patch Set: Addressed review comments 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
« no previous file with comments | « regexp2000/src/regexp-macro-assembler-ia32.h ('k') | regexp2000/test/cctest/test-regexp.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 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 * - return address 55 * - return address
56 * ebp-> - old ebp 56 * ebp-> - old ebp
57 * - register 0 ebp[-4] 57 * - register 0 ebp[-4]
58 * - register 1 ebp[-8] 58 * - register 1 ebp[-8]
59 * - ... 59 * - ...
60 * 60 *
61 * The data before ebp must be placed there by the calling code. 61 * The data before ebp must be placed there by the calling code.
62 */ 62 */
63 63
64 RegExpMacroAssemblerIA32::RegExpMacroAssemblerIA32() 64 RegExpMacroAssemblerIA32::RegExpMacroAssemblerIA32()
65 : masm_(new MacroAssembler(NULL, kRegExpCodeSize)), 65 : masm_(new MacroAssembler(NULL, kRegExpCodeSize)),
66 constants_(kRegExpConstantsSize), 66 constants_(kRegExpConstantsSize),
67 num_registers_(0), 67 num_registers_(0),
68 ignore_case(false) {} 68 ignore_case(false) {}
69 69
70 70
71 RegExpMacroAssemblerIA32::~RegExpMacroAssemblerIA32() { 71 RegExpMacroAssemblerIA32::~RegExpMacroAssemblerIA32() {
72 delete masm_; 72 delete masm_;
73 } 73 }
74 74
75 75
76 #define __ masm_-> 76 #define __ masm_->
77 77
78 void RegExpMacroAssemblerIA32::AdvanceCurrentPosition(int by) { 78 void RegExpMacroAssemblerIA32::AdvanceCurrentPosition(int by) {
(...skipping 22 matching lines...) Expand all
101 void RegExpMacroAssemblerIA32::Bind(Label* label) { 101 void RegExpMacroAssemblerIA32::Bind(Label* label) {
102 __ bind(label); 102 __ bind(label);
103 } 103 }
104 104
105 105
106 void RegExpMacroAssemblerIA32::CheckBitmap(uc16 start, 106 void RegExpMacroAssemblerIA32::CheckBitmap(uc16 start,
107 Label* bitmap, 107 Label* bitmap,
108 Label* on_zero) { 108 Label* on_zero) {
109 ReadCurrentChar(eax); 109 ReadCurrentChar(eax);
110 __ sub(eax, start); 110 __ sub(eax, start);
111 __ cmp(eax, 64); // FIXME: 64 = length_of_bitmap_in_bits. 111 __ cmp(eax, 64); // FIXME: 64 = length_of_bitmap_in_bits.
112 BranchOrBacktrack(greater_equal, on_zero); 112 BranchOrBacktrack(greater_equal, on_zero);
113 __ mov(ebx, eax); 113 __ mov(ebx, eax);
114 __ shr(ebx, 3); 114 __ shr(ebx, 3);
115 // TODO: Where is the bitmap stored? Pass the bitmap as argument instead. 115 // TODO(lrn): Where is the bitmap stored? Pass the bitmap as argument instead.
116 // __ mov(ecx, position_of_bitmap); 116 // __ mov(ecx, position_of_bitmap);
117 __ movzx_b(ebx, Operand(ecx, ebx, times_1, 0)); 117 __ movzx_b(ebx, Operand(ecx, ebx, times_1, 0));
118 __ and_(eax, (1<<3)-1); 118 __ and_(eax, (1<<3)-1);
119 __ bt(ebx, eax); 119 __ bt(ebx, eax);
120 __ j(greater_equal, on_zero); // Aka. jump on carry set. 120 __ j(greater_equal, on_zero); // Aka. jump on carry set.
121 } 121 }
122 122
123 123
124 void RegExpMacroAssemblerIA32::CheckCharacterClass(RegExpCharacterClass *cclass, 124 void RegExpMacroAssemblerIA32::CheckCharacterClass(RegExpCharacterClass *cclass,
125 Label* on_failure) { 125 Label* on_failure) {
(...skipping 11 matching lines...) Expand all
137 } 137 }
138 } 138 }
139 } 139 }
140 int byte_length = str.length() * sizeof(SubjectChar); 140 int byte_length = str.length() * sizeof(SubjectChar);
141 __ mov(ebx, edi); 141 __ mov(ebx, edi);
142 __ add(ebx, byte_length); 142 __ add(ebx, byte_length);
143 __ cmp(ebx, esi); 143 __ cmp(ebx, esi);
144 BranchOrBacktrack(greater_equal, on_failure); 144 BranchOrBacktrack(greater_equal, on_failure);
145 145
146 if (str.length() <= kMaxInlineStringTests || ignore_case()) { 146 if (str.length() <= kMaxInlineStringTests || ignore_case()) {
147 // TODO: make proper loop if str.length is large but ignore_case is true; 147 // TODO(lrn): make loop if str.length is large but ignore_case is true;
148 for(int i = 0; i < str.length(); i++) { 148 for (int i = 0; i < str.length(); i++) {
149 ReadChar(eax, i); 149 ReadChar(eax, i);
150 if (ignore_case()) { 150 if (ignore_case()) {
151 Canonicalize(eax); 151 Canonicalize(eax);
152 } 152 }
153 __ cmp(eax, str[i]); 153 __ cmp(eax, str[i]);
154 BranchOrBacktrack(not_equal, on_failure); 154 BranchOrBacktrack(not_equal, on_failure);
155 } 155 }
156 add(edi, byte_length); 156 add(edi, byte_length);
157 } else { 157 } else {
158 int offset; 158 int offset;
159 ArraySlice<SubjectChar> constant_buffer = 159 ArraySlice<SubjectChar> constant_buffer =
160 constants_.GetBuffer<SubjectChar>(str.length()); 160 constants_.GetBuffer<SubjectChar>(str.length());
161 for (int i = 0; i < str.length(); i++) { 161 for (int i = 0; i < str.length(); i++) {
162 constant_buffer[i] = str[i]; 162 constant_buffer[i] = str[i];
163 } 163 }
164 __ mov(ebx, esi); 164 __ mov(ebx, esi);
165 LoadConstantBufferAddress(esi, constant_buffer); 165 LoadConstantBufferAddress(esi, constant_buffer);
166 __ mov(ecx, str.length()); 166 __ mov(ecx, str.length());
167 if (sizeof(SubjectChar) == 1) { 167 if (sizeof(SubjectChar) == 1) {
168 __ rep_cmpsb(); 168 __ rep_cmpsb();
169 } else { 169 } else {
170 ASSERT(sizeof(SubjectChar)==2); 170 ASSERT(sizeof(SubjectChar) == 2);
171 __ rep_cmpsw(); 171 __ rep_cmpsw();
172 } 172 }
173 __ mov(esi, ebx); 173 __ mov(esi, ebx);
174 BranchOrBacktrack(not_equal, on_failure); 174 BranchOrBacktrack(not_equal, on_failure);
175 } 175 }
176 }; 176 };
177 177
178 178
179 void RegExpMacroAssemblerIA32::CheckCurrentPosition(int register_index, 179 void RegExpMacroAssemblerIA32::CheckCurrentPosition(int register_index,
180 Label* on_equal) { 180 Label* on_equal) {
(...skipping 13 matching lines...) Expand all
194 194
195 Label fallthrough; 195 Label fallthrough;
196 196
197 ReadCurrentChar(eax); 197 ReadCurrentChar(eax);
198 __ sub(eax, start); 198 __ sub(eax, start);
199 __ cmp(eax, 64); // FIXME: 64 = size of map in bytes. Found somehow?? 199 __ cmp(eax, 64); // FIXME: 64 = size of map in bytes. Found somehow??
200 __ j(greater_equal, &fallthrough); 200 __ j(greater_equal, &fallthrough);
201 201
202 __ mov(ebx, eax); 202 __ mov(ebx, eax);
203 __ shr(eax, 2); 203 __ shr(eax, 2);
204 __ movzx_b(eax, Operand(ecx, eax)); // FIXME: ecx holds address of map 204 __ movzx_b(eax, Operand(ecx, eax)); // FIXME: ecx holds address of map
205 Label got_nybble; 205 Label got_nybble;
206 Label high_bits; 206 Label high_bits;
207 __ and_(ebx, 0x03); 207 __ and_(ebx, 0x03);
208 __ shr(eax, ebx); 208 __ shr(eax, ebx);
209 209
210 Label second_bit_set, case_3, case_1; 210 Label second_bit_set, case_3, case_1;
211 __ test(eax, 2); 211 __ test(eax, 2);
212 __ j(not_equal, &second_bit_set); 212 __ j(not_equal, &second_bit_set);
213 __ test(eax, 1); 213 __ test(eax, 1);
214 __ j(not_equal, &case_1); 214 __ j(not_equal, &case_1);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 byte start, 256 byte start,
257 Label* byte_map, 257 Label* byte_map,
258 const Vector<Label*>& destinations) { 258 const Vector<Label*>& destinations) {
259 Label fallthrough; 259 Label fallthrough;
260 ReadCurrentChar(eax); 260 ReadCurrentChar(eax);
261 __ shr(eax, 8); 261 __ shr(eax, 8);
262 __ sub(eax, start); 262 __ sub(eax, start);
263 __ cmp(eax, destinations.length() - start); 263 __ cmp(eax, destinations.length() - start);
264 __ j(greater_equal, &fallthrough); 264 __ j(greater_equal, &fallthrough);
265 265
266 // TODO jumptable: jump to destinations[eax] 266 // TODO(lrn) jumptable: jump to destinations[eax]
267 __ bind(&fallthrough); 267 __ bind(&fallthrough);
268 } 268 }
269 269
270 270
271 void RegExpMacroAssemblerIA32::EmitOrLink(Label* label) { 271 void RegExpMacroAssemblerIA32::EmitOrLink(Label* label) {
272 UNREACHABLE(); // Has no use. 272 UNREACHABLE(); // Has no use.
273 } 273 }
274 274
275 275
276 void RegExpMacroAssemblerIA32::Fail() { 276 void RegExpMacroAssemblerIA32::Fail() {
277 Exit(false); 277 Exit(false);
278 } 278 }
279 279
280 Handle<Object> RegExpMacroAssemblerIA32::GetCode() { 280 Handle<Object> RegExpMacroAssemblerIA32::GetCode() {
281 // something 281 // something
282 return Handle(); 282 return Handle();
283 } 283 }
284 284
285 285
286 void RegExpMacroAssemblerIA32::GoTo(Label &to) { 286 void RegExpMacroAssemblerIA32::GoTo(Label* to) {
287 __ jmp(to); 287 __ jmp(to);
288 } 288 }
289 289
290 290
291 void RegExpMacroAssemblerIA32::IfRegisterGE(int reg, 291 void RegExpMacroAssemblerIA32::IfRegisterGE(int reg,
292 int comparand, 292 int comparand,
293 Label* if_ge) { 293 Label* if_ge) {
294 __ cmp(register_location(reg), comparand); 294 __ cmp(register_location(reg), comparand);
295 BranchOrBacktrack(greater_equal, if_ge); 295 BranchOrBacktrack(greater_equal, if_ge);
296 } 296 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 Label end; 391 Label end;
392 __ cmp(reg, 'a'); 392 __ cmp(reg, 'a');
393 __ j(below, &end); 393 __ j(below, &end);
394 __ cmp(reg, 'z'); 394 __ cmp(reg, 'z');
395 __ j(above, &end); 395 __ j(above, &end);
396 __ sub(reg, 'a' - 'A'); 396 __ sub(reg, 'a' - 'A');
397 __ bind(&end); 397 __ bind(&end);
398 return; 398 return;
399 } 399 }
400 ASSERT(sizeof(SubjectChar) == 2); 400 ASSERT(sizeof(SubjectChar) == 2);
401 // TODO: Use some tables. 401 // TODO(lrn): Use some tables.
402 } 402 }
403 403
404 404
405 void RegExpMacroAssemblerIA32::Exit(bool success) { 405 void RegExpMacroAssemblerIA32::Exit(bool success) {
406 if (success) { 406 if (success) {
407 // Copy captures to output capture array. 407 // Copy captures to output capture array.
408 } 408 }
409 __ leave(); 409 __ leave();
410 __ mov(eax, success ? 1 : 0); 410 __ mov(eax, success ? 1 : 0);
411 __ ret(); 411 __ ret();
412 } 412 }
413 413
414 414
415 void RegExpMacroAssemblerIA32::ReadChar(Register destination, int offset) { 415 void RegExpMacroAssemblerIA32::ReadChar(Register destination, int offset) {
416 if (sizeof(SubjectChar) == 1) { 416 if (sizeof(SubjectChar) == 1) {
417 __ movzx_b(destination, Operand(edi, offset)); 417 __ movzx_b(destination, Operand(edi, offset));
418 return; 418 return;
419 } 419 }
420 ASSERT(sizeof(SubjectChar) == 2); 420 ASSERT(sizeof(SubjectChar) == 2);
421 __ movzx_w(destination, Operand(edi, offset * 2)); 421 __ movzx_w(destination, Operand(edi, offset * 2));
422 } 422 }
423 423
424 424
425 void RegExpMacroAssemblerIA32::ReadCurrentChar(Register destination) { 425 void RegExpMacroAssemblerIA32::ReadCurrentChar(Register destination) {
426 mov(destination, edx); 426 mov(destination, edx);
427 } 427 }
428 428
429 429
430 template <typename T> 430 void RegExpMacroAssemblerIA32::LoadConstantBufferAddress(
431 void LoadConstantBufferAddress(Register reg, ArraySlice<T>& buffer) { 431 Register reg, ArraySlice<T>* buffer) {
432 __ mov(reg, buffer.array()); 432 __ mov(reg, buffer->array());
433 __ add(reg, buffer.base_offset()); 433 __ add(reg, buffer->base_offset());
434 } 434 }
435 435
436 #undef __ 436 #undef __
437 }} 437 }}
OLDNEW
« no previous file with comments | « regexp2000/src/regexp-macro-assembler-ia32.h ('k') | regexp2000/test/cctest/test-regexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698