OLD | NEW |
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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 __ shr(ebx, 3); | 147 __ shr(ebx, 3); |
148 // TODO(lrn): Where is the bitmap stored? Pass the bitmap as argument instead. | 148 // TODO(lrn): Where is the bitmap stored? Pass the bitmap as argument instead. |
149 // __ mov(ecx, position_of_bitmap); | 149 // __ mov(ecx, position_of_bitmap); |
150 __ movzx_b(ebx, Operand(ecx, ebx, times_1, 0)); | 150 __ movzx_b(ebx, Operand(ecx, ebx, times_1, 0)); |
151 __ and_(eax, (1<<3)-1); | 151 __ and_(eax, (1<<3)-1); |
152 __ bt(Operand(ebx), eax); | 152 __ bt(Operand(ebx), eax); |
153 BranchOrBacktrack(carry, on_zero); | 153 BranchOrBacktrack(carry, on_zero); |
154 } | 154 } |
155 | 155 |
156 | 156 |
157 void RegExpMacroAssemblerIA32::CheckCharacter(uc16 c, Label* on_equal) { | 157 void RegExpMacroAssemblerIA32::CheckCharacter(uint32_t c, Label* on_equal) { |
158 __ cmp(current_character(), c); | 158 __ cmp(current_character(), c); |
159 BranchOrBacktrack(equal, on_equal); | 159 BranchOrBacktrack(equal, on_equal); |
160 } | 160 } |
161 | 161 |
162 | 162 |
163 void RegExpMacroAssemblerIA32::CheckCharacterGT(uc16 limit, Label* on_greater) { | 163 void RegExpMacroAssemblerIA32::CheckCharacterGT(uc16 limit, Label* on_greater) { |
164 __ cmp(current_character(), limit); | 164 __ cmp(current_character(), limit); |
165 BranchOrBacktrack(greater, on_greater); | 165 BranchOrBacktrack(greater, on_greater); |
166 } | 166 } |
167 | 167 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 | 358 |
359 void RegExpMacroAssemblerIA32::CheckNotRegistersEqual(int reg1, | 359 void RegExpMacroAssemblerIA32::CheckNotRegistersEqual(int reg1, |
360 int reg2, | 360 int reg2, |
361 Label* on_not_equal) { | 361 Label* on_not_equal) { |
362 __ mov(eax, register_location(reg1)); | 362 __ mov(eax, register_location(reg1)); |
363 __ cmp(eax, register_location(reg2)); | 363 __ cmp(eax, register_location(reg2)); |
364 BranchOrBacktrack(not_equal, on_not_equal); | 364 BranchOrBacktrack(not_equal, on_not_equal); |
365 } | 365 } |
366 | 366 |
367 | 367 |
368 void RegExpMacroAssemblerIA32::CheckNotCharacter(uc16 c, Label* on_not_equal) { | 368 void RegExpMacroAssemblerIA32::CheckNotCharacter(uint32_t c, |
| 369 Label* on_not_equal) { |
369 __ cmp(current_character(), c); | 370 __ cmp(current_character(), c); |
370 BranchOrBacktrack(not_equal, on_not_equal); | 371 BranchOrBacktrack(not_equal, on_not_equal); |
371 } | 372 } |
372 | 373 |
373 | 374 |
374 void RegExpMacroAssemblerIA32::CheckNotCharacterAfterOr(uc16 c, | 375 void RegExpMacroAssemblerIA32::CheckCharacterAfterAnd(uint32_t c, |
375 uc16 mask, | 376 uint32_t mask, |
376 Label* on_not_equal) { | 377 Label* on_equal) { |
377 __ mov(eax, current_character()); | 378 __ mov(eax, current_character()); |
378 __ or_(eax, mask); | 379 __ and_(eax, mask); |
| 380 __ cmp(eax, c); |
| 381 BranchOrBacktrack(equal, on_equal); |
| 382 } |
| 383 |
| 384 |
| 385 void RegExpMacroAssemblerIA32::CheckNotCharacterAfterAnd(uint32_t c, |
| 386 uint32_t mask, |
| 387 Label* on_not_equal) { |
| 388 __ mov(eax, current_character()); |
| 389 __ and_(eax, mask); |
379 __ cmp(eax, c); | 390 __ cmp(eax, c); |
380 BranchOrBacktrack(not_equal, on_not_equal); | 391 BranchOrBacktrack(not_equal, on_not_equal); |
381 } | 392 } |
382 | 393 |
383 | 394 |
384 void RegExpMacroAssemblerIA32::CheckNotCharacterAfterMinusOr( | 395 void RegExpMacroAssemblerIA32::CheckNotCharacterAfterMinusAnd( |
385 uc16 c, | 396 uc16 c, |
| 397 uc16 minus, |
386 uc16 mask, | 398 uc16 mask, |
387 Label* on_not_equal) { | 399 Label* on_not_equal) { |
388 __ lea(eax, Operand(current_character(), -mask)); | 400 ASSERT(minus < String::kMaxUC16CharCode); |
389 __ or_(eax, mask); | 401 __ lea(eax, Operand(current_character(), -minus)); |
| 402 __ and_(eax, mask); |
390 __ cmp(eax, c); | 403 __ cmp(eax, c); |
391 BranchOrBacktrack(not_equal, on_not_equal); | 404 BranchOrBacktrack(not_equal, on_not_equal); |
392 } | 405 } |
393 | 406 |
394 | 407 |
395 void RegExpMacroAssemblerIA32::DispatchHalfNibbleMap( | 408 void RegExpMacroAssemblerIA32::DispatchHalfNibbleMap( |
396 uc16 start, | 409 uc16 start, |
397 Label* half_nibble_map, | 410 Label* half_nibble_map, |
398 const Vector<Label*>& destinations) { | 411 const Vector<Label*>& destinations) { |
399 UNIMPLEMENTED(); | 412 UNIMPLEMENTED(); |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
509 Label init_loop; | 522 Label init_loop; |
510 __ bind(&init_loop); | 523 __ bind(&init_loop); |
511 __ mov(Operand(ebp, ecx, times_4, +0), eax); | 524 __ mov(Operand(ebp, ecx, times_4, +0), eax); |
512 __ inc(ecx); | 525 __ inc(ecx); |
513 __ j(not_equal, &init_loop); | 526 __ j(not_equal, &init_loop); |
514 } | 527 } |
515 // Load previous char as initial value of current-character. | 528 // Load previous char as initial value of current-character. |
516 Label at_start; | 529 Label at_start; |
517 __ cmp(Operand(ebp, kAtStart), Immediate(0)); | 530 __ cmp(Operand(ebp, kAtStart), Immediate(0)); |
518 __ j(not_equal, &at_start); | 531 __ j(not_equal, &at_start); |
519 LoadCurrentCharacterUnchecked(-1); // Load previous char. | 532 LoadCurrentCharacterUnchecked(-1, 1); // Load previous char. |
520 __ jmp(&start_label_); | 533 __ jmp(&start_label_); |
521 __ bind(&at_start); | 534 __ bind(&at_start); |
522 __ mov(current_character(), '\n'); | 535 __ mov(current_character(), '\n'); |
523 __ jmp(&start_label_); | 536 __ jmp(&start_label_); |
524 | 537 |
525 | 538 |
526 // Exit code: | 539 // Exit code: |
527 if (success_label_.is_linked()) { | 540 if (success_label_.is_linked()) { |
528 // Success | 541 // Success |
529 __ bind(&success_label_); | 542 __ bind(&success_label_); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 } | 637 } |
625 | 638 |
626 | 639 |
627 RegExpMacroAssembler::IrregexpImplementation | 640 RegExpMacroAssembler::IrregexpImplementation |
628 RegExpMacroAssemblerIA32::Implementation() { | 641 RegExpMacroAssemblerIA32::Implementation() { |
629 return kIA32Implementation; | 642 return kIA32Implementation; |
630 } | 643 } |
631 | 644 |
632 | 645 |
633 void RegExpMacroAssemblerIA32::LoadCurrentCharacter(int cp_offset, | 646 void RegExpMacroAssemblerIA32::LoadCurrentCharacter(int cp_offset, |
634 Label* on_end_of_input) { | 647 Label* on_end_of_input, |
| 648 bool check_bounds, |
| 649 int characters) { |
635 ASSERT(cp_offset >= 0); | 650 ASSERT(cp_offset >= 0); |
636 ASSERT(cp_offset < (1<<30)); // Be sane! (And ensure negation works) | 651 ASSERT(cp_offset < (1<<30)); // Be sane! (And ensure negation works) |
637 __ cmp(edi, -cp_offset * char_size()); | 652 if (check_bounds) { |
638 BranchOrBacktrack(greater_equal, on_end_of_input); | 653 __ cmp(edi, -(cp_offset + characters) * char_size()); |
639 LoadCurrentCharacterUnchecked(cp_offset); | 654 BranchOrBacktrack(greater, on_end_of_input); |
| 655 } |
| 656 LoadCurrentCharacterUnchecked(cp_offset, characters); |
640 } | 657 } |
641 | 658 |
642 | 659 |
643 void RegExpMacroAssemblerIA32::PopCurrentPosition() { | 660 void RegExpMacroAssemblerIA32::PopCurrentPosition() { |
644 __ pop(edi); | 661 __ pop(edi); |
645 } | 662 } |
646 | 663 |
647 | 664 |
648 void RegExpMacroAssemblerIA32::PopRegister(int register_index) { | 665 void RegExpMacroAssemblerIA32::PopRegister(int register_index) { |
649 __ pop(register_location(register_index)); | 666 __ pop(register_location(register_index)); |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
864 __ mov(Operand(eax), Immediate(reinterpret_cast<int32_t>(function_address))); | 881 __ mov(Operand(eax), Immediate(reinterpret_cast<int32_t>(function_address))); |
865 __ call(Operand(eax)); | 882 __ call(Operand(eax)); |
866 if (OS::ActivationFrameAlignment() != 0) { | 883 if (OS::ActivationFrameAlignment() != 0) { |
867 __ mov(esp, Operand(esp, num_arguments * kPointerSize)); | 884 __ mov(esp, Operand(esp, num_arguments * kPointerSize)); |
868 } else { | 885 } else { |
869 __ add(Operand(esp), Immediate(num_arguments * sizeof(int32_t))); | 886 __ add(Operand(esp), Immediate(num_arguments * sizeof(int32_t))); |
870 } | 887 } |
871 } | 888 } |
872 | 889 |
873 | 890 |
874 void RegExpMacroAssemblerIA32::LoadCurrentCharacterUnchecked(int cp_offset) { | 891 void RegExpMacroAssemblerIA32::LoadCurrentCharacterUnchecked(int cp_offset, |
| 892 int characters) { |
875 if (mode_ == ASCII) { | 893 if (mode_ == ASCII) { |
876 __ movzx_b(current_character(), Operand(esi, edi, times_1, cp_offset)); | 894 if (characters == 4) { |
| 895 __ mov(current_character(), Operand(esi, edi, times_1, cp_offset)); |
| 896 } else if (characters == 2) { |
| 897 __ movzx_w(current_character(), Operand(esi, edi, times_1, cp_offset)); |
| 898 } else { |
| 899 ASSERT(characters == 1); |
| 900 __ movzx_b(current_character(), Operand(esi, edi, times_1, cp_offset)); |
| 901 } |
877 } else { | 902 } else { |
878 ASSERT(mode_ == UC16); | 903 ASSERT(mode_ == UC16); |
879 __ movzx_w(current_character(), | 904 if (characters == 2) { |
880 Operand(esi, edi, times_1, cp_offset * sizeof(uc16))); | 905 __ mov(current_character(), |
| 906 Operand(esi, edi, times_1, cp_offset * sizeof(uc16))); |
| 907 } else { |
| 908 ASSERT(characters == 1); |
| 909 __ movzx_w(current_character(), |
| 910 Operand(esi, edi, times_1, cp_offset * sizeof(uc16))); |
| 911 } |
881 } | 912 } |
882 } | 913 } |
883 | 914 |
884 | 915 |
885 void RegExpMacroAssemblerIA32::LoadConstantBufferAddress(Register reg, | 916 void RegExpMacroAssemblerIA32::LoadConstantBufferAddress(Register reg, |
886 ArraySlice* buffer) { | 917 ArraySlice* buffer) { |
887 __ mov(reg, buffer->array()); | 918 __ mov(reg, buffer->array()); |
888 __ add(Operand(reg), Immediate(buffer->base_offset())); | 919 __ add(Operand(reg), Immediate(buffer->base_offset())); |
889 } | 920 } |
890 | 921 |
891 #undef __ | 922 #undef __ |
892 }} // namespace v8::internal | 923 }} // namespace v8::internal |
OLD | NEW |