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

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

Issue 18587: Eliminate the code that handles fallback to JSCRE. The only way to get... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 10 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
« src/regexp-macro-assembler.h ('K') | « src/regexp-macro-assembler.h ('k') | no next file » | 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 if (l->is_linked()) { 77 if (l->is_linked()) {
78 pos = l->pos(); 78 pos = l->pos();
79 } 79 }
80 l->link_to(pc_); 80 l->link_to(pc_);
81 Emit32(pos); 81 Emit32(pos);
82 } 82 }
83 } 83 }
84 84
85 85
86 void RegExpMacroAssemblerIrregexp::PopRegister(int register_index) { 86 void RegExpMacroAssemblerIrregexp::PopRegister(int register_index) {
87 ASSERT(register_index >= 0);
88 ASSERT(register_index <= kMaxRegister);
87 Emit(BC_POP_REGISTER, register_index); 89 Emit(BC_POP_REGISTER, register_index);
88 } 90 }
89 91
90 92
91 void RegExpMacroAssemblerIrregexp::PushRegister( 93 void RegExpMacroAssemblerIrregexp::PushRegister(
92 int register_index, 94 int register_index,
93 StackCheckFlag check_stack_limit) { 95 StackCheckFlag check_stack_limit) {
94 ASSERT(register_index >= 0); 96 ASSERT(register_index >= 0);
97 ASSERT(register_index <= kMaxRegister);
95 Emit(BC_PUSH_REGISTER, register_index); 98 Emit(BC_PUSH_REGISTER, register_index);
96 } 99 }
97 100
98 101
99 void RegExpMacroAssemblerIrregexp::WriteCurrentPositionToRegister( 102 void RegExpMacroAssemblerIrregexp::WriteCurrentPositionToRegister(
100 int register_index, int cp_offset) { 103 int register_index, int cp_offset) {
101 ASSERT(register_index >= 0); 104 ASSERT(register_index >= 0);
105 ASSERT(register_index <= kMaxRegister);
102 Emit(BC_SET_REGISTER_TO_CP, register_index); 106 Emit(BC_SET_REGISTER_TO_CP, register_index);
103 Emit32(cp_offset); // Current position offset. 107 Emit32(cp_offset); // Current position offset.
104 } 108 }
105 109
106 110
107 void RegExpMacroAssemblerIrregexp::ClearRegister(int reg) { 111 void RegExpMacroAssemblerIrregexp::ClearRegister(int reg) {
108 SetRegister(reg, -1); 112 SetRegister(reg, -1);
109 } 113 }
110 114
111 115
112 void RegExpMacroAssemblerIrregexp::ReadCurrentPositionFromRegister( 116 void RegExpMacroAssemblerIrregexp::ReadCurrentPositionFromRegister(
113 int register_index) { 117 int register_index) {
114 ASSERT(register_index >= 0); 118 ASSERT(register_index >= 0);
119 ASSERT(register_index <= kMaxRegister);
115 Emit(BC_SET_CP_TO_REGISTER, register_index); 120 Emit(BC_SET_CP_TO_REGISTER, register_index);
116 } 121 }
117 122
118 123
119 void RegExpMacroAssemblerIrregexp::WriteStackPointerToRegister( 124 void RegExpMacroAssemblerIrregexp::WriteStackPointerToRegister(
120 int register_index) { 125 int register_index) {
121 ASSERT(register_index >= 0); 126 ASSERT(register_index >= 0);
127 ASSERT(register_index <= kMaxRegister);
122 Emit(BC_SET_REGISTER_TO_SP, register_index); 128 Emit(BC_SET_REGISTER_TO_SP, register_index);
123 } 129 }
124 130
125 131
126 void RegExpMacroAssemblerIrregexp::ReadStackPointerFromRegister( 132 void RegExpMacroAssemblerIrregexp::ReadStackPointerFromRegister(
127 int register_index) { 133 int register_index) {
128 ASSERT(register_index >= 0); 134 ASSERT(register_index >= 0);
135 ASSERT(register_index <= kMaxRegister);
129 Emit(BC_SET_SP_TO_REGISTER, register_index); 136 Emit(BC_SET_SP_TO_REGISTER, register_index);
130 } 137 }
131 138
132 139
133 void RegExpMacroAssemblerIrregexp::SetRegister(int register_index, int to) { 140 void RegExpMacroAssemblerIrregexp::SetRegister(int register_index, int to) {
134 ASSERT(register_index >= 0); 141 ASSERT(register_index >= 0);
142 ASSERT(register_index <= kMaxRegister);
135 Emit(BC_SET_REGISTER, register_index); 143 Emit(BC_SET_REGISTER, register_index);
136 Emit32(to); 144 Emit32(to);
137 } 145 }
138 146
139 147
140 void RegExpMacroAssemblerIrregexp::AdvanceRegister(int register_index, int by) { 148 void RegExpMacroAssemblerIrregexp::AdvanceRegister(int register_index, int by) {
141 ASSERT(register_index >= 0); 149 ASSERT(register_index >= 0);
150 ASSERT(register_index <= kMaxRegister);
142 Emit(BC_ADVANCE_REGISTER, register_index); 151 Emit(BC_ADVANCE_REGISTER, register_index);
143 Emit32(by); 152 Emit32(by);
144 } 153 }
145 154
146 155
147 void RegExpMacroAssemblerIrregexp::PopCurrentPosition() { 156 void RegExpMacroAssemblerIrregexp::PopCurrentPosition() {
148 Emit(BC_POP_CP, 0); 157 Emit(BC_POP_CP, 0);
149 } 158 }
150 159
151 160
(...skipping 23 matching lines...) Expand all
175 Emit(BC_SUCCEED, 0); 184 Emit(BC_SUCCEED, 0);
176 } 185 }
177 186
178 187
179 void RegExpMacroAssemblerIrregexp::Fail() { 188 void RegExpMacroAssemblerIrregexp::Fail() {
180 Emit(BC_FAIL, 0); 189 Emit(BC_FAIL, 0);
181 } 190 }
182 191
183 192
184 void RegExpMacroAssemblerIrregexp::AdvanceCurrentPosition(int by) { 193 void RegExpMacroAssemblerIrregexp::AdvanceCurrentPosition(int by) {
194 ASSERT(by >= kMinCPOffset);
195 ASSERT(by <= kMaxCPOffset);
185 Emit(BC_ADVANCE_CP, by); 196 Emit(BC_ADVANCE_CP, by);
186 } 197 }
187 198
188 199
189 void RegExpMacroAssemblerIrregexp::CheckGreedyLoop( 200 void RegExpMacroAssemblerIrregexp::CheckGreedyLoop(
190 Label* on_tos_equals_current_position) { 201 Label* on_tos_equals_current_position) {
191 Emit(BC_CHECK_GREEDY, 0); 202 Emit(BC_CHECK_GREEDY, 0);
192 EmitOrLink(on_tos_equals_current_position); 203 EmitOrLink(on_tos_equals_current_position);
193 } 204 }
194 205
195 206
196 void RegExpMacroAssemblerIrregexp::LoadCurrentCharacter(int cp_offset, 207 void RegExpMacroAssemblerIrregexp::LoadCurrentCharacter(int cp_offset,
197 Label* on_failure, 208 Label* on_failure,
198 bool check_bounds, 209 bool check_bounds,
199 int characters) { 210 int characters) {
211 ASSERT(cp_offset >= kMinCPOffset);
212 ASSERT(cp_offset <= kMaxCPOffset);
200 int bytecode; 213 int bytecode;
201 if (check_bounds) { 214 if (check_bounds) {
202 if (characters == 4) { 215 if (characters == 4) {
203 bytecode = BC_LOAD_4_CURRENT_CHARS; 216 bytecode = BC_LOAD_4_CURRENT_CHARS;
204 } else if (characters == 2) { 217 } else if (characters == 2) {
205 bytecode = BC_LOAD_2_CURRENT_CHARS; 218 bytecode = BC_LOAD_2_CURRENT_CHARS;
206 } else { 219 } else {
207 ASSERT(characters == 1); 220 ASSERT(characters == 1);
208 bytecode = BC_LOAD_CURRENT_CHAR; 221 bytecode = BC_LOAD_CURRENT_CHAR;
209 } 222 }
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 Label* on_not_equal) { 321 Label* on_not_equal) {
309 Emit(BC_MINUS_AND_CHECK_NOT_CHAR, c); 322 Emit(BC_MINUS_AND_CHECK_NOT_CHAR, c);
310 Emit16(minus); 323 Emit16(minus);
311 Emit16(mask); 324 Emit16(mask);
312 EmitOrLink(on_not_equal); 325 EmitOrLink(on_not_equal);
313 } 326 }
314 327
315 328
316 void RegExpMacroAssemblerIrregexp::CheckNotBackReference(int start_reg, 329 void RegExpMacroAssemblerIrregexp::CheckNotBackReference(int start_reg,
317 Label* on_not_equal) { 330 Label* on_not_equal) {
331 ASSERT(start_reg >= 0);
332 ASSERT(start_reg <= kMaxRegister);
318 Emit(BC_CHECK_NOT_BACK_REF, start_reg); 333 Emit(BC_CHECK_NOT_BACK_REF, start_reg);
319 EmitOrLink(on_not_equal); 334 EmitOrLink(on_not_equal);
320 } 335 }
321 336
322 337
323 void RegExpMacroAssemblerIrregexp::CheckNotBackReferenceIgnoreCase( 338 void RegExpMacroAssemblerIrregexp::CheckNotBackReferenceIgnoreCase(
324 int start_reg, 339 int start_reg,
325 Label* on_not_equal) { 340 Label* on_not_equal) {
341 ASSERT(start_reg >= 0);
342 ASSERT(start_reg <= kMaxRegister);
326 Emit(BC_CHECK_NOT_BACK_REF_NO_CASE, start_reg); 343 Emit(BC_CHECK_NOT_BACK_REF_NO_CASE, start_reg);
327 EmitOrLink(on_not_equal); 344 EmitOrLink(on_not_equal);
328 } 345 }
329 346
330 347
331 void RegExpMacroAssemblerIrregexp::CheckNotRegistersEqual(int reg1, 348 void RegExpMacroAssemblerIrregexp::CheckNotRegistersEqual(int reg1,
332 int reg2, 349 int reg2,
333 Label* on_not_equal) { 350 Label* on_not_equal) {
351 ASSERT(reg1 >= 0);
352 ASSERT(reg1 <= kMaxRegister);
334 Emit(BC_CHECK_NOT_REGS_EQUAL, reg1); 353 Emit(BC_CHECK_NOT_REGS_EQUAL, reg1);
335 Emit32(reg2); 354 Emit32(reg2);
336 EmitOrLink(on_not_equal); 355 EmitOrLink(on_not_equal);
337 } 356 }
338 357
339 358
340 void RegExpMacroAssemblerIrregexp::CheckBitmap(uc16 start, 359 void RegExpMacroAssemblerIrregexp::CheckBitmap(uc16 start,
341 Label* bitmap, 360 Label* bitmap,
342 Label* on_zero) { 361 Label* on_zero) {
343 UNIMPLEMENTED(); 362 UNIMPLEMENTED();
(...skipping 22 matching lines...) Expand all
366 const Vector<Label*>& table) { 385 const Vector<Label*>& table) {
367 UNIMPLEMENTED(); 386 UNIMPLEMENTED();
368 } 387 }
369 388
370 389
371 void RegExpMacroAssemblerIrregexp::CheckCharacters( 390 void RegExpMacroAssemblerIrregexp::CheckCharacters(
372 Vector<const uc16> str, 391 Vector<const uc16> str,
373 int cp_offset, 392 int cp_offset,
374 Label* on_failure, 393 Label* on_failure,
375 bool check_end_of_string) { 394 bool check_end_of_string) {
395 ASSERT(cp_offset >= kMinCPOffset);
396 ASSERT(cp_offset + str.length() - 1 <= kMaxCPOffset);
376 // It is vital that this loop is backwards due to the unchecked character 397 // It is vital that this loop is backwards due to the unchecked character
377 // load below. 398 // load below.
378 for (int i = str.length() - 1; i >= 0; i--) { 399 for (int i = str.length() - 1; i >= 0; i--) {
379 if (check_end_of_string && i == str.length() - 1) { 400 if (check_end_of_string && i == str.length() - 1) {
380 Emit(BC_LOAD_CURRENT_CHAR, cp_offset + i); 401 Emit(BC_LOAD_CURRENT_CHAR, cp_offset + i);
381 EmitOrLink(on_failure); 402 EmitOrLink(on_failure);
382 } else { 403 } else {
383 Emit(BC_LOAD_CURRENT_CHAR_UNCHECKED, cp_offset + i); 404 Emit(BC_LOAD_CURRENT_CHAR_UNCHECKED, cp_offset + i);
384 } 405 }
385 Emit(BC_CHECK_NOT_CHAR, str[i]); 406 Emit(BC_CHECK_NOT_CHAR, str[i]);
386 EmitOrLink(on_failure); 407 EmitOrLink(on_failure);
387 } 408 }
388 } 409 }
389 410
390 411
391 void RegExpMacroAssemblerIrregexp::IfRegisterLT(int register_index, 412 void RegExpMacroAssemblerIrregexp::IfRegisterLT(int register_index,
392 int comparand, 413 int comparand,
393 Label* on_less_than) { 414 Label* on_less_than) {
394 ASSERT(comparand >= 0 && comparand <= 65535); 415 ASSERT(register_index >= 0);
416 ASSERT(register_index <= kMaxRegister);
395 Emit(BC_CHECK_REGISTER_LT, register_index); 417 Emit(BC_CHECK_REGISTER_LT, register_index);
396 Emit32(comparand); 418 Emit32(comparand);
397 EmitOrLink(on_less_than); 419 EmitOrLink(on_less_than);
398 } 420 }
399 421
400 422
401 void RegExpMacroAssemblerIrregexp::IfRegisterGE(int register_index, 423 void RegExpMacroAssemblerIrregexp::IfRegisterGE(int register_index,
402 int comparand, 424 int comparand,
403 Label* on_greater_or_equal) { 425 Label* on_greater_or_equal) {
404 ASSERT(comparand >= 0 && comparand <= 65535); 426 ASSERT(register_index >= 0);
427 ASSERT(register_index <= kMaxRegister);
405 Emit(BC_CHECK_REGISTER_GE, register_index); 428 Emit(BC_CHECK_REGISTER_GE, register_index);
406 Emit32(comparand); 429 Emit32(comparand);
407 EmitOrLink(on_greater_or_equal); 430 EmitOrLink(on_greater_or_equal);
408 } 431 }
409 432
410 433
411 void RegExpMacroAssemblerIrregexp::IfRegisterEqPos(int register_index, 434 void RegExpMacroAssemblerIrregexp::IfRegisterEqPos(int register_index,
412 Label* on_eq) { 435 Label* on_eq) {
436 ASSERT(register_index >= 0);
437 ASSERT(register_index <= kMaxRegister);
413 Emit(BC_CHECK_REGISTER_EQ_POS, register_index); 438 Emit(BC_CHECK_REGISTER_EQ_POS, register_index);
414 EmitOrLink(on_eq); 439 EmitOrLink(on_eq);
415 } 440 }
416 441
417 442
418 Handle<Object> RegExpMacroAssemblerIrregexp::GetCode(Handle<String> source) { 443 Handle<Object> RegExpMacroAssemblerIrregexp::GetCode(Handle<String> source) {
419 Bind(&backtrack_); 444 Bind(&backtrack_);
420 Emit(BC_POP_BT, 0); 445 Emit(BC_POP_BT, 0);
421 Handle<ByteArray> array = Factory::NewByteArray(length()); 446 Handle<ByteArray> array = Factory::NewByteArray(length());
422 Copy(array->GetDataStartAddress()); 447 Copy(array->GetDataStartAddress());
(...skipping 17 matching lines...) Expand all
440 buffer_ = Vector<byte>::New(old_buffer.length() * 2); 465 buffer_ = Vector<byte>::New(old_buffer.length() * 2);
441 own_buffer_ = true; 466 own_buffer_ = true;
442 memcpy(buffer_.start(), old_buffer.start(), old_buffer.length()); 467 memcpy(buffer_.start(), old_buffer.start(), old_buffer.length());
443 if (old_buffer_was_our_own) { 468 if (old_buffer_was_our_own) {
444 old_buffer.Dispose(); 469 old_buffer.Dispose();
445 } 470 }
446 } 471 }
447 472
448 473
449 } } // namespace v8::internal 474 } } // namespace v8::internal
OLDNEW
« src/regexp-macro-assembler.h ('K') | « src/regexp-macro-assembler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698