Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(71)

Delta Between Two Patch Sets: src/pkg/runtime/asm_arm.s

Issue 8056043: code review 8056043: runtime: Implement faster equals for strings and bytes. (Closed)
Left Patch Set: diff -r 7505bf6d8988 https://khr%40golang.org@code.google.com/p/go/ Created 11 years ago
Right Patch Set: diff -r 52e3407d249f https://khr%40golang.org@code.google.com/p/go/ Created 10 years, 12 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/runtime/asm_amd64.s ('k') | src/pkg/runtime/hashmap.c » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 #include "zasm_GOOS_GOARCH.h" 5 #include "zasm_GOOS_GOARCH.h"
6 6
7 // using frame size $-4 means do not save LR on stack. 7 // using frame size $-4 means do not save LR on stack.
8 TEXT _rt0_arm(SB),7,$-4 8 TEXT _rt0_arm(SB),7,$-4
9 MOVW $0xcafebabe, R12 9 MOVW $0xcafebabe, R12
10 10
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 MOVW $0, R0 498 MOVW $0, R0
499 MOVW (R0), R1 499 MOVW (R0), R1
500 TEXT runtime·aeshashstr(SB),7,$-4 500 TEXT runtime·aeshashstr(SB),7,$-4
501 MOVW $0, R0 501 MOVW $0, R0
502 MOVW (R0), R1 502 MOVW (R0), R1
503 503
504 TEXT runtime·memeq(SB),7,$-4 504 TEXT runtime·memeq(SB),7,$-4
505 MOVW a+0(FP), R1 505 MOVW a+0(FP), R1
506 MOVW b+4(FP), R2 506 MOVW b+4(FP), R2
507 MOVW n+8(FP), R3 507 MOVW n+8(FP), R3
508 B runtime·memeqbody(SB)
509
510
511 TEXT bytes·Equal(SB),7,$0
512 MOVW a_len+4(FP), R1
513 MOVW b_len+16(FP), R3
514
515 MOVW $0, R0
516 CMP R1, R3 // unequal lengths are not equal
517 B.NE _eqret
518
519 MOVW a+0(FP), R1
520 MOVW b+12(FP), R2
521
522 BL runtime·memeqbody(SB)
523
524 _eqret:
525 MOVBU R0, ret+24(FP)
526 RET
527
528 // R1 = A
529 // R2 = B
530 // R3 = count
531 TEXT runtime·memeqbody(SB),7,$-4
532 MOVW $1, R0 // default result is equal
533
534 CMP $8, R3 // do small strings directly
535 BLO tail
536
537 // move A up to an aligned position
538 alignloop:
539 AND.S $3, R1, R4
540 BEQ A_aligned
541 MOVBU.P 1(R1), R4
542 MOVBU.P 1(R2), R5
543 SUB $1, R3
544 CMP R4, R5
545 BEQ alignloop
546 MOVW $0, R0
547 RET
548
549 // A is aligned. Check B.
550 A_aligned:
551 AND.S $3, R2, R4
552 BEQ both_aligned
553 SLL $3, R4, R5 // shift amount for low word
554 RSB $32, R5, R6 // shift amount for high word
555 SUB R4, R2, R4 // R4 = B rounded down
556
557 // B is not aligned. Compare the word at A
558 // with the value constructed from the
559 // two words near B.
560 // Note: this code is little-endian specific.
561 // Beware that R9, R10 are reserved for m, g.
562 // R11 can be used by linker.
563 MOVW (R4), R7
564 one_aligned:
565 CMP $4, R3
566 BLO tail
567 MOVW R7>>R5, R12
568 MOVW.W 4(R4), R7
569 ORR R7<<R6, R12
570 MOVW.P 4(R1), R8
571 ADD $4, R2
572 SUB $4, R3
573 CMP R8, R12
574 BEQ one_aligned
575 MOVW $0, R0
576 RET
577
578 // A and B are both aligned, compare word at a time.
579 both_aligned:
580 CMP $4, R3
581 BLO tail
582 MOVW.P 4(R1), R4
583 MOVW.P 4(R2), R5
584 SUB $4, R3
585 CMP R4, R5
586 BEQ both_aligned
587 MOVW $0, R0
588 RET
589
590 tail:
591 ADD R1, R3, R6 508 ADD R1, R3, R6
592 tailloop: 509 » MOVW» $1, R0
510 _next:
593 CMP R1, R6 511 CMP R1, R6
594 RET.EQ 512 RET.EQ
595 MOVBU.P 1(R1), R4 513 MOVBU.P 1(R1), R4
596 MOVBU.P 1(R2), R5 514 MOVBU.P 1(R2), R5
597 CMP R4, R5 515 CMP R4, R5
598 » BEQ» tailloop 516 » BEQ» _next
599 » MOVW» $0, R0 517
600 » RET 518 » MOVW» $0, R0
519 » RET
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b