Chromium Code Reviews| 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 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 399 uc16 minus, | 399 uc16 minus, |
| 400 uc16 mask, | 400 uc16 mask, |
| 401 Label* on_not_equal) { | 401 Label* on_not_equal) { |
| 402 ASSERT(minus < String::kMaxUC16CharCode); | 402 ASSERT(minus < String::kMaxUC16CharCode); |
| 403 __ lea(eax, Operand(current_character(), -minus)); | 403 __ lea(eax, Operand(current_character(), -minus)); |
| 404 __ and_(eax, mask); | 404 __ and_(eax, mask); |
| 405 __ cmp(eax, c); | 405 __ cmp(eax, c); |
| 406 BranchOrBacktrack(not_equal, on_not_equal); | 406 BranchOrBacktrack(not_equal, on_not_equal); |
| 407 } | 407 } |
| 408 | 408 |
| 409 bool RegExpMacroAssemblerIA32::CheckSpecialCharacterClass(uc16 type, | |
|
Mads Ager (chromium)
2009/01/02 10:51:06
A lot of unnamed constants are used in this code a
| |
| 410 int cp_offset, | |
| 411 bool check_offset, | |
| 412 Label* on_no_match) { | |
| 413 switch (type) { | |
| 414 case 's': | |
| 415 if (mode_ == ASCII) { | |
| 416 if (check_offset) { | |
| 417 LoadCurrentCharacter(cp_offset, on_no_match); | |
| 418 } else { | |
| 419 LoadCurrentCharacterUnchecked(cp_offset, 1); | |
| 420 } | |
| 421 Label success; | |
| 422 __ cmp(current_character(), 0x20); | |
| 423 __ j(equal, &success); | |
| 424 __ sub(Operand(current_character()), Immediate(0x09)); | |
| 425 __ cmp(current_character(), 0x05); | |
| 426 BranchOrBacktrack(above_equal, on_no_match); | |
| 427 __ bind(&success); | |
| 428 return true; | |
| 429 } | |
| 430 return false; | |
| 431 case 'S': | |
| 432 if (check_offset) { | |
| 433 LoadCurrentCharacter(cp_offset, on_no_match, 1); | |
| 434 } else { | |
| 435 LoadCurrentCharacterUnchecked(cp_offset, 1); | |
| 436 } | |
| 437 if (mode_ == ASCII) { | |
| 438 __ cmp(current_character(), 0x20); | |
| 439 BranchOrBacktrack(equal, on_no_match); | |
| 440 __ sub(Operand(current_character()), Immediate(0x09)); | |
| 441 __ cmp(current_character(), 0x05); | |
| 442 BranchOrBacktrack(below, on_no_match); | |
| 443 return true; | |
| 444 } | |
| 445 return false; | |
| 446 case 'd': | |
| 447 if (check_offset) { | |
| 448 LoadCurrentCharacter(cp_offset, on_no_match, 1); | |
| 449 } else { | |
| 450 LoadCurrentCharacterUnchecked(cp_offset, 1); | |
| 451 } | |
| 452 __ sub(Operand(current_character()), Immediate('0')); | |
| 453 __ cmp(current_character(), '9' - '0'); | |
| 454 BranchOrBacktrack(greater_equal, on_no_match); | |
| 455 return true; | |
| 456 case 'D': | |
| 457 if (check_offset) { | |
| 458 LoadCurrentCharacter(cp_offset, on_no_match, 1); | |
| 459 } else { | |
| 460 LoadCurrentCharacterUnchecked(cp_offset, 1); | |
| 461 } | |
| 462 __ sub(Operand(current_character()), Immediate('0')); | |
| 463 __ cmp(current_character(), '9' - '0'); | |
| 464 BranchOrBacktrack(below, on_no_match); | |
| 465 return true; | |
| 466 case '.': { | |
| 467 if (check_offset) { | |
| 468 LoadCurrentCharacter(cp_offset, on_no_match, 1); | |
| 469 } else { | |
| 470 LoadCurrentCharacterUnchecked(cp_offset, 1); | |
| 471 } | |
| 472 __ sub(Operand(current_character()), Immediate(0x0a)); | |
| 473 __ mov(eax, current_character()); | |
| 474 __ and_(current_character(), 0x01); | |
| 475 __ shr(eax, 1); | |
| 476 __ xor_(current_character(), Operand(eax)); | |
| 477 BranchOrBacktrack(equal, on_no_match); | |
| 478 if (mode_ == UC16) { | |
| 479 __ cmp(eax, (0x2028 - 0x0a) >> 1); | |
| 480 BranchOrBacktrack(equal, on_no_match); | |
| 481 } | |
| 482 return true; | |
| 483 } | |
| 484 case '*': | |
| 485 if (check_offset) { | |
| 486 CheckPosition(cp_offset, on_no_match); | |
| 487 } | |
| 488 return true; | |
| 489 // No custom implementation (yet): w, W, s(UC16), S(UC16). | |
| 490 default: | |
| 491 return false; | |
| 492 } | |
| 493 } | |
| 409 | 494 |
| 410 void RegExpMacroAssemblerIA32::DispatchHalfNibbleMap( | 495 void RegExpMacroAssemblerIA32::DispatchHalfNibbleMap( |
| 411 uc16 start, | 496 uc16 start, |
| 412 Label* half_nibble_map, | 497 Label* half_nibble_map, |
| 413 const Vector<Label*>& destinations) { | 498 const Vector<Label*>& destinations) { |
| 414 UNIMPLEMENTED(); | 499 UNIMPLEMENTED(); |
| 415 __ mov(eax, current_character()); | 500 __ mov(eax, current_character()); |
| 416 __ sub(Operand(eax), Immediate(start)); | 501 __ sub(Operand(eax), Immediate(start)); |
| 417 | 502 |
| 418 __ mov(ecx, eax); | 503 __ mov(ecx, eax); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 650 return kIA32Implementation; | 735 return kIA32Implementation; |
| 651 } | 736 } |
| 652 | 737 |
| 653 | 738 |
| 654 void RegExpMacroAssemblerIA32::LoadCurrentCharacter(int cp_offset, | 739 void RegExpMacroAssemblerIA32::LoadCurrentCharacter(int cp_offset, |
| 655 Label* on_end_of_input, | 740 Label* on_end_of_input, |
| 656 bool check_bounds, | 741 bool check_bounds, |
| 657 int characters) { | 742 int characters) { |
| 658 ASSERT(cp_offset >= 0); | 743 ASSERT(cp_offset >= 0); |
| 659 ASSERT(cp_offset < (1<<30)); // Be sane! (And ensure negation works) | 744 ASSERT(cp_offset < (1<<30)); // Be sane! (And ensure negation works) |
| 660 if (check_bounds) { | 745 CheckPosition(cp_offset + characters - 1, on_end_of_input); |
| 661 __ cmp(edi, -(cp_offset + characters) * char_size()); | |
| 662 BranchOrBacktrack(greater, on_end_of_input); | |
| 663 } | |
| 664 LoadCurrentCharacterUnchecked(cp_offset, characters); | 746 LoadCurrentCharacterUnchecked(cp_offset, characters); |
| 665 } | 747 } |
| 666 | 748 |
| 667 | 749 |
| 668 void RegExpMacroAssemblerIA32::PopCurrentPosition() { | 750 void RegExpMacroAssemblerIA32::PopCurrentPosition() { |
| 669 __ pop(edi); | 751 __ pop(edi); |
| 670 } | 752 } |
| 671 | 753 |
| 672 | 754 |
| 673 void RegExpMacroAssemblerIA32::PopRegister(int register_index) { | 755 void RegExpMacroAssemblerIA32::PopRegister(int register_index) { |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 808 Register RegExpMacroAssemblerIA32::current_character() { | 890 Register RegExpMacroAssemblerIA32::current_character() { |
| 809 return edx; | 891 return edx; |
| 810 } | 892 } |
| 811 | 893 |
| 812 | 894 |
| 813 size_t RegExpMacroAssemblerIA32::char_size() { | 895 size_t RegExpMacroAssemblerIA32::char_size() { |
| 814 return static_cast<size_t>(mode_); | 896 return static_cast<size_t>(mode_); |
| 815 } | 897 } |
| 816 | 898 |
| 817 | 899 |
| 900 void RegExpMacroAssemblerIA32::CheckPosition(int cp_offset, | |
| 901 Label* on_outside_input) { | |
| 902 __ cmp(edi, -cp_offset * char_size()); | |
| 903 BranchOrBacktrack(greater_equal, on_outside_input); | |
| 904 } | |
| 905 | |
| 906 | |
| 818 void RegExpMacroAssemblerIA32::BranchOrBacktrack(Condition condition, | 907 void RegExpMacroAssemblerIA32::BranchOrBacktrack(Condition condition, |
| 819 Label* to) { | 908 Label* to) { |
| 820 if (condition < 0) { // No condition | 909 if (condition < 0) { // No condition |
| 821 if (to == NULL) { | 910 if (to == NULL) { |
| 822 Backtrack(); | 911 Backtrack(); |
| 823 return; | 912 return; |
| 824 } | 913 } |
| 825 __ jmp(to); | 914 __ jmp(to); |
| 826 return; | 915 return; |
| 827 } | 916 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 919 | 1008 |
| 920 | 1009 |
| 921 void RegExpMacroAssemblerIA32::LoadConstantBufferAddress(Register reg, | 1010 void RegExpMacroAssemblerIA32::LoadConstantBufferAddress(Register reg, |
| 922 ArraySlice* buffer) { | 1011 ArraySlice* buffer) { |
| 923 __ mov(reg, buffer->array()); | 1012 __ mov(reg, buffer->array()); |
| 924 __ add(Operand(reg), Immediate(buffer->base_offset())); | 1013 __ add(Operand(reg), Immediate(buffer->base_offset())); |
| 925 } | 1014 } |
| 926 | 1015 |
| 927 #undef __ | 1016 #undef __ |
| 928 }} // namespace v8::internal | 1017 }} // namespace v8::internal |
| OLD | NEW |