|
|
@@ -28,19 +28,23 @@
|
|
|
// func emitLiteral(dst, lit []byte) int
|
|
|
//
|
|
|
// All local variables fit into registers. The register allocation:
|
|
|
-// - AX return value
|
|
|
+// - AX len(lit)
|
|
|
// - BX n
|
|
|
-// - CX len(lit)
|
|
|
-// - SI &lit[0]
|
|
|
+// - DX return value
|
|
|
// - DI &dst[i]
|
|
|
+// - R10 &lit[0]
|
|
|
//
|
|
|
// The 24 bytes of stack space is to call runtime·memmove.
|
|
|
+//
|
|
|
+// The unusual register allocation of local variables, such as R10 for the
|
|
|
+// source pointer, matches the allocation used at the call site in encodeBlock,
|
|
|
+// which makes it easier to manually inline this function.
|
|
|
TEXT ·emitLiteral(SB), NOSPLIT, $24-56
|
|
|
MOVQ dst_base+0(FP), DI
|
|
|
- MOVQ lit_base+24(FP), SI
|
|
|
- MOVQ lit_len+32(FP), CX
|
|
|
- MOVQ CX, AX
|
|
|
- MOVL CX, BX
|
|
|
+ MOVQ lit_base+24(FP), R10
|
|
|
+ MOVQ lit_len+32(FP), AX
|
|
|
+ MOVQ AX, DX
|
|
|
+ MOVL AX, BX
|
|
|
SUBL $1, BX
|
|
|
|
|
|
CMPL BX, $60
|
|
|
@@ -52,32 +56,32 @@ threeBytes:
|
|
|
MOVB $0xf4, 0(DI)
|
|
|
MOVW BX, 1(DI)
|
|
|
ADDQ $3, DI
|
|
|
- ADDQ $3, AX
|
|
|
+ ADDQ $3, DX
|
|
|
JMP emitLiteralEnd
|
|
|
|
|
|
twoBytes:
|
|
|
MOVB $0xf0, 0(DI)
|
|
|
MOVB BX, 1(DI)
|
|
|
ADDQ $2, DI
|
|
|
- ADDQ $2, AX
|
|
|
+ ADDQ $2, DX
|
|
|
JMP emitLiteralEnd
|
|
|
|
|
|
oneByte:
|
|
|
SHLB $2, BX
|
|
|
MOVB BX, 0(DI)
|
|
|
ADDQ $1, DI
|
|
|
- ADDQ $1, AX
|
|
|
+ ADDQ $1, DX
|
|
|
|
|
|
emitLiteralEnd:
|
|
|
- MOVQ AX, ret+48(FP)
|
|
|
+ MOVQ DX, ret+48(FP)
|
|
|
|
|
|
// copy(dst[i:], lit)
|
|
|
//
|
|
|
// This means calling runtime·memmove(&dst[i], &lit[0], len(lit)), so we push
|
|
|
- // DI, SI and CX as arguments.
|
|
|
+ // DI, R10 and AX as arguments.
|
|
|
MOVQ DI, 0(SP)
|
|
|
- MOVQ SI, 8(SP)
|
|
|
- MOVQ CX, 16(SP)
|
|
|
+ MOVQ R10, 8(SP)
|
|
|
+ MOVQ AX, 16(SP)
|
|
|
CALL runtime·memmove(SB)
|
|
|
RET
|
|
|
|
|
|
@@ -91,9 +95,9 @@ emitLiteralEnd:
|
|
|
// - DI &dst[i]
|
|
|
// - R11 offset
|
|
|
//
|
|
|
-// The unusual register allocation of AX and R11 for local variables matches
|
|
|
-// the allocation used at the call site in encodeBlock, which makes it easier
|
|
|
-// to manually inline this function.
|
|
|
+// The unusual register allocation of local variables, such as R11 for the
|
|
|
+// offset, matches the allocation used at the call site in encodeBlock, which
|
|
|
+// makes it easier to manually inline this function.
|
|
|
TEXT ·emitCopy(SB), NOSPLIT, $0-48
|
|
|
MOVQ dst_base+0(FP), DI
|
|
|
MOVQ DI, SI
|