| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 __ movzxbl(rdx, Operand(r9, 0)); | 286 __ movzxbl(rdx, Operand(r9, 0)); |
| 287 __ movzxbl(rax, Operand(r11, 0)); | 287 __ movzxbl(rax, Operand(r11, 0)); |
| 288 // al - input character | 288 // al - input character |
| 289 // dl - capture character | 289 // dl - capture character |
| 290 __ cmpb(rax, rdx); | 290 __ cmpb(rax, rdx); |
| 291 __ j(equal, &loop_increment); | 291 __ j(equal, &loop_increment); |
| 292 | 292 |
| 293 // Mismatch, try case-insensitive match (converting letters to lower-case). | 293 // Mismatch, try case-insensitive match (converting letters to lower-case). |
| 294 // I.e., if or-ing with 0x20 makes values equal and in range 'a'-'z', it's | 294 // I.e., if or-ing with 0x20 makes values equal and in range 'a'-'z', it's |
| 295 // a match. | 295 // a match. |
| 296 __ or_(rax, Immediate(0x20)); // Convert match character to lower-case. | 296 __ orp(rax, Immediate(0x20)); // Convert match character to lower-case. |
| 297 __ or_(rdx, Immediate(0x20)); // Convert capture character to lower-case. | 297 __ orp(rdx, Immediate(0x20)); // Convert capture character to lower-case. |
| 298 __ cmpb(rax, rdx); | 298 __ cmpb(rax, rdx); |
| 299 __ j(not_equal, on_no_match); // Definitely not equal. | 299 __ j(not_equal, on_no_match); // Definitely not equal. |
| 300 __ subb(rax, Immediate('a')); | 300 __ subb(rax, Immediate('a')); |
| 301 __ cmpb(rax, Immediate('z' - 'a')); | 301 __ cmpb(rax, Immediate('z' - 'a')); |
| 302 __ j(below_equal, &loop_increment); // In range 'a'-'z'. | 302 __ j(below_equal, &loop_increment); // In range 'a'-'z'. |
| 303 // Latin-1: Check for values in range [224,254] but not 247. | 303 // Latin-1: Check for values in range [224,254] but not 247. |
| 304 __ subb(rax, Immediate(224 - 'a')); | 304 __ subb(rax, Immediate(224 - 'a')); |
| 305 __ cmpb(rax, Immediate(254 - 224)); | 305 __ cmpb(rax, Immediate(254 - 224)); |
| 306 __ j(above, on_no_match); // Weren't Latin-1 letters. | 306 __ j(above, on_no_match); // Weren't Latin-1 letters. |
| 307 __ cmpb(rax, Immediate(247 - 224)); // Check for 247. | 307 __ cmpb(rax, Immediate(247 - 224)); // Check for 247. |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 } | 455 } |
| 456 | 456 |
| 457 | 457 |
| 458 void RegExpMacroAssemblerX64::CheckCharacterAfterAnd(uint32_t c, | 458 void RegExpMacroAssemblerX64::CheckCharacterAfterAnd(uint32_t c, |
| 459 uint32_t mask, | 459 uint32_t mask, |
| 460 Label* on_equal) { | 460 Label* on_equal) { |
| 461 if (c == 0) { | 461 if (c == 0) { |
| 462 __ testl(current_character(), Immediate(mask)); | 462 __ testl(current_character(), Immediate(mask)); |
| 463 } else { | 463 } else { |
| 464 __ movl(rax, Immediate(mask)); | 464 __ movl(rax, Immediate(mask)); |
| 465 __ and_(rax, current_character()); | 465 __ andp(rax, current_character()); |
| 466 __ cmpl(rax, Immediate(c)); | 466 __ cmpl(rax, Immediate(c)); |
| 467 } | 467 } |
| 468 BranchOrBacktrack(equal, on_equal); | 468 BranchOrBacktrack(equal, on_equal); |
| 469 } | 469 } |
| 470 | 470 |
| 471 | 471 |
| 472 void RegExpMacroAssemblerX64::CheckNotCharacterAfterAnd(uint32_t c, | 472 void RegExpMacroAssemblerX64::CheckNotCharacterAfterAnd(uint32_t c, |
| 473 uint32_t mask, | 473 uint32_t mask, |
| 474 Label* on_not_equal) { | 474 Label* on_not_equal) { |
| 475 if (c == 0) { | 475 if (c == 0) { |
| 476 __ testl(current_character(), Immediate(mask)); | 476 __ testl(current_character(), Immediate(mask)); |
| 477 } else { | 477 } else { |
| 478 __ movl(rax, Immediate(mask)); | 478 __ movl(rax, Immediate(mask)); |
| 479 __ and_(rax, current_character()); | 479 __ andp(rax, current_character()); |
| 480 __ cmpl(rax, Immediate(c)); | 480 __ cmpl(rax, Immediate(c)); |
| 481 } | 481 } |
| 482 BranchOrBacktrack(not_equal, on_not_equal); | 482 BranchOrBacktrack(not_equal, on_not_equal); |
| 483 } | 483 } |
| 484 | 484 |
| 485 | 485 |
| 486 void RegExpMacroAssemblerX64::CheckNotCharacterAfterMinusAnd( | 486 void RegExpMacroAssemblerX64::CheckNotCharacterAfterMinusAnd( |
| 487 uc16 c, | 487 uc16 c, |
| 488 uc16 minus, | 488 uc16 minus, |
| 489 uc16 mask, | 489 uc16 mask, |
| 490 Label* on_not_equal) { | 490 Label* on_not_equal) { |
| 491 ASSERT(minus < String::kMaxUtf16CodeUnit); | 491 ASSERT(minus < String::kMaxUtf16CodeUnit); |
| 492 __ leap(rax, Operand(current_character(), -minus)); | 492 __ leap(rax, Operand(current_character(), -minus)); |
| 493 __ and_(rax, Immediate(mask)); | 493 __ andp(rax, Immediate(mask)); |
| 494 __ cmpl(rax, Immediate(c)); | 494 __ cmpl(rax, Immediate(c)); |
| 495 BranchOrBacktrack(not_equal, on_not_equal); | 495 BranchOrBacktrack(not_equal, on_not_equal); |
| 496 } | 496 } |
| 497 | 497 |
| 498 | 498 |
| 499 void RegExpMacroAssemblerX64::CheckCharacterInRange( | 499 void RegExpMacroAssemblerX64::CheckCharacterInRange( |
| 500 uc16 from, | 500 uc16 from, |
| 501 uc16 to, | 501 uc16 to, |
| 502 Label* on_in_range) { | 502 Label* on_in_range) { |
| 503 __ leal(rax, Operand(current_character(), -from)); | 503 __ leal(rax, Operand(current_character(), -from)); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 516 } | 516 } |
| 517 | 517 |
| 518 | 518 |
| 519 void RegExpMacroAssemblerX64::CheckBitInTable( | 519 void RegExpMacroAssemblerX64::CheckBitInTable( |
| 520 Handle<ByteArray> table, | 520 Handle<ByteArray> table, |
| 521 Label* on_bit_set) { | 521 Label* on_bit_set) { |
| 522 __ Move(rax, table); | 522 __ Move(rax, table); |
| 523 Register index = current_character(); | 523 Register index = current_character(); |
| 524 if (mode_ != ASCII || kTableMask != String::kMaxOneByteCharCode) { | 524 if (mode_ != ASCII || kTableMask != String::kMaxOneByteCharCode) { |
| 525 __ movp(rbx, current_character()); | 525 __ movp(rbx, current_character()); |
| 526 __ and_(rbx, Immediate(kTableMask)); | 526 __ andp(rbx, Immediate(kTableMask)); |
| 527 index = rbx; | 527 index = rbx; |
| 528 } | 528 } |
| 529 __ cmpb(FieldOperand(rax, index, times_1, ByteArray::kHeaderSize), | 529 __ cmpb(FieldOperand(rax, index, times_1, ByteArray::kHeaderSize), |
| 530 Immediate(0)); | 530 Immediate(0)); |
| 531 BranchOrBacktrack(not_equal, on_bit_set); | 531 BranchOrBacktrack(not_equal, on_bit_set); |
| 532 } | 532 } |
| 533 | 533 |
| 534 | 534 |
| 535 bool RegExpMacroAssemblerX64::CheckSpecialCharacterClass(uc16 type, | 535 bool RegExpMacroAssemblerX64::CheckSpecialCharacterClass(uc16 type, |
| 536 Label* on_no_match) { | 536 Label* on_no_match) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 return true; | 568 return true; |
| 569 case 'D': | 569 case 'D': |
| 570 // Match non ASCII-digits | 570 // Match non ASCII-digits |
| 571 __ leap(rax, Operand(current_character(), -'0')); | 571 __ leap(rax, Operand(current_character(), -'0')); |
| 572 __ cmpl(rax, Immediate('9' - '0')); | 572 __ cmpl(rax, Immediate('9' - '0')); |
| 573 BranchOrBacktrack(below_equal, on_no_match); | 573 BranchOrBacktrack(below_equal, on_no_match); |
| 574 return true; | 574 return true; |
| 575 case '.': { | 575 case '.': { |
| 576 // Match non-newlines (not 0x0a('\n'), 0x0d('\r'), 0x2028 and 0x2029) | 576 // Match non-newlines (not 0x0a('\n'), 0x0d('\r'), 0x2028 and 0x2029) |
| 577 __ movl(rax, current_character()); | 577 __ movl(rax, current_character()); |
| 578 __ xor_(rax, Immediate(0x01)); | 578 __ xorp(rax, Immediate(0x01)); |
| 579 // See if current character is '\n'^1 or '\r'^1, i.e., 0x0b or 0x0c | 579 // See if current character is '\n'^1 or '\r'^1, i.e., 0x0b or 0x0c |
| 580 __ subl(rax, Immediate(0x0b)); | 580 __ subl(rax, Immediate(0x0b)); |
| 581 __ cmpl(rax, Immediate(0x0c - 0x0b)); | 581 __ cmpl(rax, Immediate(0x0c - 0x0b)); |
| 582 BranchOrBacktrack(below_equal, on_no_match); | 582 BranchOrBacktrack(below_equal, on_no_match); |
| 583 if (mode_ == UC16) { | 583 if (mode_ == UC16) { |
| 584 // Compare original value to 0x2028 and 0x2029, using the already | 584 // Compare original value to 0x2028 and 0x2029, using the already |
| 585 // computed (current_char ^ 0x01 - 0x0b). I.e., check for | 585 // computed (current_char ^ 0x01 - 0x0b). I.e., check for |
| 586 // 0x201d (0x2028 - 0x0b) or 0x201e. | 586 // 0x201d (0x2028 - 0x0b) or 0x201e. |
| 587 __ subl(rax, Immediate(0x2028 - 0x0b)); | 587 __ subl(rax, Immediate(0x2028 - 0x0b)); |
| 588 __ cmpl(rax, Immediate(0x2029 - 0x2028)); | 588 __ cmpl(rax, Immediate(0x2029 - 0x2028)); |
| 589 BranchOrBacktrack(below_equal, on_no_match); | 589 BranchOrBacktrack(below_equal, on_no_match); |
| 590 } | 590 } |
| 591 return true; | 591 return true; |
| 592 } | 592 } |
| 593 case 'n': { | 593 case 'n': { |
| 594 // Match newlines (0x0a('\n'), 0x0d('\r'), 0x2028 and 0x2029) | 594 // Match newlines (0x0a('\n'), 0x0d('\r'), 0x2028 and 0x2029) |
| 595 __ movl(rax, current_character()); | 595 __ movl(rax, current_character()); |
| 596 __ xor_(rax, Immediate(0x01)); | 596 __ xorp(rax, Immediate(0x01)); |
| 597 // See if current character is '\n'^1 or '\r'^1, i.e., 0x0b or 0x0c | 597 // See if current character is '\n'^1 or '\r'^1, i.e., 0x0b or 0x0c |
| 598 __ subl(rax, Immediate(0x0b)); | 598 __ subl(rax, Immediate(0x0b)); |
| 599 __ cmpl(rax, Immediate(0x0c - 0x0b)); | 599 __ cmpl(rax, Immediate(0x0c - 0x0b)); |
| 600 if (mode_ == ASCII) { | 600 if (mode_ == ASCII) { |
| 601 BranchOrBacktrack(above, on_no_match); | 601 BranchOrBacktrack(above, on_no_match); |
| 602 } else { | 602 } else { |
| 603 Label done; | 603 Label done; |
| 604 BranchOrBacktrack(below_equal, &done); | 604 BranchOrBacktrack(below_equal, &done); |
| 605 // Compare original value to 0x2028 and 0x2029, using the already | 605 // Compare original value to 0x2028 and 0x2029, using the already |
| 606 // computed (current_char ^ 0x01 - 0x0b). I.e., check for | 606 // computed (current_char ^ 0x01 - 0x0b). I.e., check for |
| (...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1439 } | 1439 } |
| 1440 } | 1440 } |
| 1441 | 1441 |
| 1442 #undef __ | 1442 #undef __ |
| 1443 | 1443 |
| 1444 #endif // V8_INTERPRETED_REGEXP | 1444 #endif // V8_INTERPRETED_REGEXP |
| 1445 | 1445 |
| 1446 }} // namespace v8::internal | 1446 }} // namespace v8::internal |
| 1447 | 1447 |
| 1448 #endif // V8_TARGET_ARCH_X64 | 1448 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |