text
stringlengths
1
1.05M
; A279078: Maximum starting value of X such that repeated replacement of X with X-ceiling(X/8) requires n steps to reach 0. ; 0,1,2,3,4,5,6,7,9,11,13,15,18,21,25,29,34,39,45,52,60,69,79,91,105,121,139,159,182,209,239,274,314,359,411,470,538,615,703,804,919,1051,1202,1374,1571,1796,2053,2347,2683,3067,3506,4007,4580,5235,5983,6838 mov $2,$0 lpb $2,1 mov $3,$1 add $3,1 lpb $3,1 add $1,1 sub $3,1 trn $3,6 lpe sub $2,1 lpe
/* MIT License Copyright (c) 2021 Kento Oki Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #pragma once #include <windows.h> #include <winternl.h> #define STATUS_SUCCESS ((NTSTATUS)0x00000000L) // PEPROCESS is too bug to define here typedef PVOID PEPROCESS; // KPROCESS is too bug to define here typedef PVOID PKPROCESS; typedef LARGE_INTEGER PHYSICAL_ADDRESS; using PsLookupProcessByProcessId = NTSTATUS( __fastcall* )( HANDLE, PEPROCESS* ); using MmGetPhysicalAddress = PHYSICAL_ADDRESS( __fastcall* )( PVOID );
; TEST ; a = 0x06 ; b = 0x02 ; c = 0x01 ; d = 0x05 ; l = 0xFF ; h = 0xFE ; [0xFEFF] = 0x03 ; [0xFEFE] = 0x04 lda [0xFEFF] sw [0xFFFC], l sw [0xFFFD], h push 0x06 pop a push 0x01 push 0x02 pop b pop c push 0x03 push 0x04 push 0x05 pop d halt
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r13 push %r8 push %rax push %rbx push %rcx push %rdi push %rsi lea addresses_normal_ht+0x1c9d8, %rsi lea addresses_normal_ht+0xa1d8, %rdi nop nop nop sub %rax, %rax mov $45, %rcx rep movsb nop nop nop nop and %r10, %r10 lea addresses_WT_ht+0x11290, %r8 add $42426, %rbx mov $0x6162636465666768, %r10 movq %r10, (%r8) nop nop nop nop sub %rax, %rax lea addresses_UC_ht+0xb1d8, %rsi lea addresses_WT_ht+0x151d8, %rdi sub %rbx, %rbx mov $22, %rcx rep movsw nop nop xor %rax, %rax lea addresses_WT_ht+0x1a078, %rsi lea addresses_A_ht+0x7ae, %rdi nop nop nop and $3775, %rax mov $9, %rcx rep movsl and $21676, %rbx lea addresses_WT_ht+0x25d8, %r8 nop nop nop nop dec %rdi movb $0x61, (%r8) nop nop nop nop sub %rdi, %rdi lea addresses_WC_ht+0x5f58, %rsi lea addresses_WC_ht+0x161d8, %rdi nop add $11870, %r13 mov $94, %rcx rep movsl nop dec %r13 lea addresses_D_ht+0x10ab8, %rcx nop nop nop nop cmp %rsi, %rsi mov (%rcx), %di and $50224, %r8 lea addresses_D_ht+0x1c258, %r10 nop nop nop nop xor %rbx, %rbx vmovups (%r10), %ymm3 vextracti128 $0, %ymm3, %xmm3 vpextrq $1, %xmm3, %rsi add $26030, %r10 lea addresses_WC_ht+0x1e818, %r10 sub $36500, %rdi movups (%r10), %xmm2 vpextrq $0, %xmm2, %rbx nop nop nop nop nop dec %rbx lea addresses_WC_ht+0x10918, %r10 nop nop nop nop nop and $20911, %r13 movb $0x61, (%r10) cmp $45295, %rcx lea addresses_WC_ht+0x12878, %rcx dec %r8 mov $0x6162636465666768, %rsi movq %rsi, %xmm0 movups %xmm0, (%rcx) add $1003, %rax lea addresses_A_ht+0x11c58, %rsi lea addresses_UC_ht+0x14ef, %rdi nop sub $59554, %r13 mov $85, %rcx rep movsb nop nop nop nop nop inc %r10 lea addresses_UC_ht+0x6d68, %r8 nop nop nop cmp $46244, %rdi mov (%r8), %r13w nop add %r13, %r13 lea addresses_D_ht+0x173d8, %rbx nop and $33000, %rdi movups (%rbx), %xmm4 vpextrq $0, %xmm4, %rax nop nop nop nop add $56879, %r8 pop %rsi pop %rdi pop %rcx pop %rbx pop %rax pop %r8 pop %r13 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r13 push %r14 push %rbx push %rcx push %rdi push %rsi // Store lea addresses_PSE+0x19be4, %rbx nop nop nop nop nop add $30679, %rcx movw $0x5152, (%rbx) nop sub %rdi, %rdi // Load lea addresses_A+0xc1d8, %rsi nop xor $11438, %rdi mov (%rsi), %ebx nop nop nop nop nop inc %rsi // Load lea addresses_UC+0x19f34, %rsi nop nop nop and %r13, %r13 mov (%rsi), %r10w nop xor %rdi, %rdi // Load lea addresses_PSE+0x1f3a9, %rdi nop nop nop nop inc %r14 mov (%rdi), %bx inc %r14 // Load lea addresses_UC+0x15c34, %rcx cmp %r10, %r10 movups (%rcx), %xmm0 vpextrq $0, %xmm0, %r13 nop add $15398, %r13 // REPMOV lea addresses_A+0x1b848, %rsi lea addresses_WT+0x1e558, %rdi clflush (%rsi) nop and $39042, %r12 mov $79, %rcx rep movsw xor $59801, %rsi // REPMOV lea addresses_RW+0xdef7, %rsi lea addresses_UC+0xf1d8, %rdi nop nop cmp $40413, %r13 mov $46, %rcx rep movsb nop xor %r12, %r12 // Store lea addresses_normal+0x17008, %r13 nop nop add %rbx, %rbx mov $0x5152535455565758, %r14 movq %r14, %xmm3 movups %xmm3, (%r13) nop nop nop nop add %rsi, %rsi // Store lea addresses_A+0xc1d8, %r13 xor %r10, %r10 movb $0x51, (%r13) nop nop add $12896, %r14 // Store lea addresses_A+0xdad8, %rcx nop nop nop nop nop xor %r12, %r12 movl $0x51525354, (%rcx) nop nop nop nop add $1861, %r13 // Store lea addresses_WT+0xe9d8, %r13 nop nop nop cmp $5447, %r12 movb $0x51, (%r13) inc %rcx // Faulty Load lea addresses_A+0xc1d8, %rcx xor $37456, %r13 mov (%rcx), %r14d lea oracles, %rbx and $0xff, %r14 shlq $12, %r14 mov (%rbx,%r14,1), %r14 pop %rsi pop %rdi pop %rcx pop %rbx pop %r14 pop %r13 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'src': {'type': 'addresses_A', 'same': False, 'size': 8, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_PSE', 'same': False, 'size': 2, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_A', 'same': True, 'size': 4, 'congruent': 0, 'NT': True, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC', 'same': False, 'size': 2, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_PSE', 'same': False, 'size': 2, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_UC', 'same': False, 'size': 16, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_A', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_WT', 'congruent': 7, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_RW', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_UC', 'congruent': 11, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_normal', 'same': False, 'size': 16, 'congruent': 3, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_A', 'same': True, 'size': 1, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_A', 'same': False, 'size': 4, 'congruent': 6, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_WT', 'same': False, 'size': 1, 'congruent': 10, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} [Faulty Load] {'src': {'type': 'addresses_A', 'same': True, 'size': 4, 'congruent': 0, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'type': 'addresses_normal_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_WT_ht', 'same': False, 'size': 8, 'congruent': 2, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_UC_ht', 'congruent': 11, 'same': True}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 7, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_WT_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 1, 'same': False}, 'OP': 'REPM'} {'dst': {'type': 'addresses_WT_ht', 'same': True, 'size': 1, 'congruent': 10, 'NT': True, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_WC_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 8, 'same': True}, 'OP': 'REPM'} {'src': {'type': 'addresses_D_ht', 'same': True, 'size': 2, 'congruent': 4, 'NT': False, 'AVXalign': True}, 'OP': 'LOAD'} {'src': {'type': 'addresses_D_ht', 'same': False, 'size': 32, 'congruent': 7, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'src': {'type': 'addresses_WC_ht', 'same': False, 'size': 16, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 1, 'congruent': 6, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'dst': {'type': 'addresses_WC_ht', 'same': False, 'size': 16, 'congruent': 4, 'NT': False, 'AVXalign': False}, 'OP': 'STOR'} {'src': {'type': 'addresses_A_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 0, 'same': False}, 'OP': 'REPM'} {'src': {'type': 'addresses_UC_ht', 'same': False, 'size': 2, 'congruent': 4, 'NT': True, 'AVXalign': True}, 'OP': 'LOAD'} {'src': {'type': 'addresses_D_ht', 'same': False, 'size': 16, 'congruent': 9, 'NT': False, 'AVXalign': False}, 'OP': 'LOAD'} {'51': 21829} 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 51 */
; A185906: Weight array of A000007 (which has only one nonzero term and whose second accumulation array is the multiplication table for the positive integers), by antidiagonals. ; 1,-1,-1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 mov $2,$0 sub $0,3 mov $5,$2 mov $2,$0 lpb $2 mov $1,1 mov $3,$5 add $5,1 lpb $5 sub $1,1 sub $5,$3 lpe mov $0,$1 cmp $2,$4 sub $2,1 lpe mov $1,$0
; DV3 QPC Floppy Disk Hold / Release controller  1998 Tony Tebby section dv3 xdef fd_hold xdef fd_release include 'dev8_dv3_keys' include 'dev8_dv3_fd_keys' include 'dev8_keys_sys' include 'dev8_keys_err' include 'dev8_mac_assert' ;+++ ; This routine is called to take the disk controller ; ; d0 cr p preserved if OK ; d7 c p drive ID / number ; a3 c p linkage block ; a4 c p drive definition ; ; status return 0, err.nc, err.mchk ;--- fd_hold bset #7,sys_stiu(a6) ; take the sector transfer buffer bne.s fdh_nc move.b fdl_apnd(a3),fdl_actm(a3) ; ... reactivate when we've done cmp.b d0,d0 fdh_rts rts fdh_nc moveq #err.nc,d0 rts ;+++ ; This routine is called to release the disk controller ; ; d0 c p ; d7 c p drive ID / number ; a3 c p linkage block ; a4 c p drive definition ; ; status return accoding to d0 ;--- fd_release bclr #7,sys_stiu(a6) ; relase the sector transfer buffer tst.l d0 rts end
; DRAW OR SPRITE 1 BYTE DEFINITION ROTATED, ON LEFT BORDER ; 01.2006 aralbrec, Sprite Pack v3.0 ; sinclair spectrum version INCLUDE "config_private.inc" SECTION code_clib SECTION code_temp_sp1 PUBLIC _SP1_DRAW_OR1LB EXTERN _SP1_DRAW_OR1NR EXTERN SP1RETSPRDRAW ; following data segment copied into struct sp1_cs ld hl,0 nop ld de,0 call _SP1_DRAW_OR1LB ; following draw code called by way of SP1UpdateNow ; ; a = hor rot table ; bc = graphic disp ; hl = graphic def ptr ; de = left graphic def ptr ; ; 32 + 94*4 - 6 + 10 = 412 cycles _SP1_DRAW_OR1LB: cp SP1V_ROTTBL/256 jp z, _SP1_DRAW_OR1NR add hl,bc ld d,a ; d = shift table ; hl = sprite def (graph only) _SP1Or1LBRotate: ; 0 ld bc,(SP1V_PIXELBUFFER+0) ld e,(hl) inc hl ld a,(de) or c ld (SP1V_PIXELBUFFER+0),a ld e,(hl) inc hl ld a,(de) or b ld (SP1V_PIXELBUFFER+1),a ; 1 ld bc,(SP1V_PIXELBUFFER+2) ld e,(hl) inc hl ld a,(de) or c ld (SP1V_PIXELBUFFER+2),a ld e,(hl) inc hl ld a,(de) or b ld (SP1V_PIXELBUFFER+3),a ; 2 ld bc,(SP1V_PIXELBUFFER+4) ld e,(hl) inc hl ld a,(de) or c ld (SP1V_PIXELBUFFER+4),a ld e,(hl) inc hl ld a,(de) or b ld (SP1V_PIXELBUFFER+5),a ; 3 ld bc,(SP1V_PIXELBUFFER+6) ld e,(hl) inc hl ld a,(de) or c ld (SP1V_PIXELBUFFER+6),a ld e,(hl) ld a,(de) or b ld (SP1V_PIXELBUFFER+7),a jp SP1RETSPRDRAW
; A066406: a(n) = 2^n*(3^n-3). ; 0,24,192,1248,7680,46464,279552,1678848,10076160,60463104,362790912,2176770048,13060669440,78364114944,470184886272,2821109710848,16926659051520,101559955881984,609359738437632,3656158436917248,21936950634086400 mov $1,3 pow $1,$0 mov $2,$0 lpb $2 mul $1,2 sub $1,1 sub $2,1 lpe div $1,4 mul $1,24
/** BSD-3-Clause Copyright 2019 Alliance for Sustainable Energy, LLC Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met : 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER, CONTRIBUTORS, UNITED STATES GOVERNMENT OR UNITED STATES DEPARTMENT OF ENERGY, NOR ANY OF THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <cmath> #include <functional> #include "lib_battery.h" /* Define Thermal Model */ void thermal_t::initialize() { if (params->cap_vs_temp.nrows() < 2 || params->cap_vs_temp.ncols() != 2) { throw std::runtime_error("thermal_t: capacity vs temperature matrix must have two columns and at least two rows"); } size_t n = params->cap_vs_temp.nrows(); for (int i = 0; i < (int) n; i++) { params->cap_vs_temp(i, 0); } state = std::make_shared<thermal_state>(); if (params->option == thermal_params::SCHEDULE) state->T_room = params->T_room_schedule[0]; else state->T_room = params->T_room_init; state->T_batt = state->T_room; state->T_batt_prev = state->T_room; state->heat_dissipated = 0; state->q_relative_thermal = 100; dt_sec = params->dt_hour * 3600; } thermal_t::thermal_t(double dt_hour, double mass, double surface_area, double R, double Cp, double h, const util::matrix_t<double> &c_vs_t, std::vector<double> T_room_C) { params = std::shared_ptr<thermal_params>(new thermal_params({dt_hour, mass, surface_area, Cp, h, R, c_vs_t})); params->option = thermal_params::SCHEDULE; params->T_room_schedule = std::move(T_room_C); initialize(); state->T_room = params->T_room_schedule[0]; } thermal_t::thermal_t(double dt_hour, double mass, double surface_area, double R, double Cp, double h, const util::matrix_t<double> &c_vs_t, double T_room_C) { params = std::shared_ptr<thermal_params>(new thermal_params({dt_hour, mass, surface_area, Cp, h, R, c_vs_t})); params->option = thermal_params::VALUE; params->T_room_init = T_room_C; initialize(); } thermal_t::thermal_t(std::shared_ptr<thermal_params> p) { params = std::move(p); initialize(); } thermal_t::thermal_t(const thermal_t &rhs) { params = std::make_shared<thermal_params>(*rhs.params); state = std::make_shared<thermal_state>(*rhs.state); dt_sec = rhs.dt_sec; } thermal_t &thermal_t::operator=(const thermal_t &rhs) { if (this != &rhs) { *params = *rhs.params; dt_sec = rhs.dt_sec; *state = *rhs.state; } return *this; } thermal_t *thermal_t::clone() { return new thermal_t(*this); } void thermal_t::replace_battery(size_t lifetimeIndex) { if (params->option == thermal_params::VALUE) state->T_batt = params->T_room_schedule[lifetimeIndex % params->T_room_schedule.size()]; else state->T_batt = state->T_room; state->heat_dissipated = 0; state->T_batt_prev = state->T_room; state->q_relative_thermal = 100.; } void thermal_t::calc_capacity() { double percent = util::linterp_col(params->cap_vs_temp, 0, state->T_batt, 1); if (std::isnan(percent) || percent < 0 || percent > 100) { percent = 100; // log.add("Unable to determine capacity adjustment for temperature, ignoring"); } state->q_relative_thermal = percent; } // battery temperature is the average temp during the time step void thermal_t::updateTemperature(double I, size_t lifetimeIndex) { if (params->option == thermal_params::SCHEDULE) { state->T_room = params->T_room_schedule[lifetimeIndex % params->T_room_schedule.size()]; } // the battery temp is the average temp over that step, starting with temp from end of last timestep double T_steady_state = I * I * params->resistance / (params->surface_area * params->h) + state->T_room; double diffusion = exp(-params->surface_area * params->h * dt_sec / params->mass / params->Cp); double coeff_avg = params->mass * params->Cp / params->surface_area / params->h / dt_sec; state->T_batt = (state->T_batt_prev - T_steady_state) * coeff_avg * (1 - diffusion) + T_steady_state; state->heat_dissipated = (state->T_batt - state->T_room) * params->surface_area * params->h / 1000.; // update temp for use in next timestep state->T_batt_prev = (state->T_batt_prev - T_steady_state) * diffusion + T_steady_state; calc_capacity(); } double thermal_t::capacity_percent() { return state->q_relative_thermal; } double thermal_t::T_battery() { return state->T_batt; } thermal_state thermal_t::get_state() { return *state; } thermal_params thermal_t::get_params() { return *params; } /* Define Losses */ void losses_t::initialize() { state = std::make_shared<losses_state>(); state->loss_kw = 0; if (params->loss_choice == losses_params::MONTHLY) { if (params->monthly_charge_loss.size() == 1) { params->monthly_charge_loss = std::vector<double>(12, params->monthly_charge_loss[0]); } else if (params->monthly_charge_loss.size() != 12){ goto fail; } if (params->monthly_discharge_loss.size() == 1) { params->monthly_discharge_loss = std::vector<double>(12, params->monthly_discharge_loss[0]); } else if (params->monthly_discharge_loss.size() != 12) { goto fail; } if (params->monthly_idle_loss.size() == 1) { params->monthly_idle_loss = std::vector<double>(12, params->monthly_idle_loss[0]); } else if (params->monthly_idle_loss.size() != 12) { goto fail; } return; fail: throw std::runtime_error("losses_t error: loss arrays length must be 1 or 12 for monthly input mode"); } else if (params->loss_choice == losses_params::SCHEDULE) { if (params->schedule_loss.empty()) { throw std::runtime_error("losses_t error: loss length must be greater than 0 for schedule mode"); } } } losses_t::losses_t(const std::vector<double>& monthly_charge, const std::vector<double>& monthly_discharge, const std::vector<double>& monthly_idle) { params = std::make_shared<losses_params>(); params->loss_choice = losses_params::MONTHLY; params->monthly_charge_loss = monthly_charge; params->monthly_discharge_loss = monthly_discharge; params->monthly_idle_loss = monthly_idle; initialize(); } losses_t::losses_t(const std::vector<double>& schedule_loss) { params = std::make_shared<losses_params>(); params->loss_choice = losses_params::SCHEDULE; params->schedule_loss = schedule_loss; initialize(); } losses_t::losses_t(std::shared_ptr<losses_params> p) { params = std::move(p); initialize(); } losses_t::losses_t(const losses_t& rhs) { params = std::make_shared<losses_params>(*rhs.params); state = std::make_shared<losses_state>(*rhs.state); } losses_t &losses_t::operator=(const losses_t& rhs) { if (this != &rhs) { *params = *rhs.params; *state = *rhs.state; } return *this; } void losses_t::run_losses(size_t lifetimeIndex, double dtHour, double charge_operation) { size_t indexYearOne = util::yearOneIndex(dtHour, lifetimeIndex); auto hourOfYear = (size_t) std::floor(indexYearOne * dtHour); size_t monthIndex = util::month_of((double) (hourOfYear)) - 1; // update system losses depending on user input if (params->loss_choice == losses_params::MONTHLY) { if (charge_operation == capacity_state::CHARGE) state->loss_kw = params->monthly_charge_loss[monthIndex]; if (charge_operation == capacity_state::DISCHARGE) state->loss_kw = params->monthly_discharge_loss[monthIndex]; if (charge_operation == capacity_state::NO_CHARGE) state->loss_kw = params->monthly_idle_loss[monthIndex]; } else if (params->loss_choice == losses_params::SCHEDULE) { state->loss_kw = params->schedule_loss[lifetimeIndex % params->schedule_loss.size()]; } } double losses_t::getLoss() { return state->loss_kw; } losses_state losses_t::get_state() { return *state; } losses_params losses_t::get_params() {return *params; } /* Define Battery */ battery_state::battery_state(): battery_state(std::make_shared<capacity_state>(), std::make_shared<voltage_state>(), std::make_shared<thermal_state>(), std::make_shared<lifetime_state>(), std::make_shared<losses_state>()) { } battery_state::battery_state(const std::shared_ptr<capacity_state> &cap, const std::shared_ptr<voltage_state> &vol, const std::shared_ptr<thermal_state> &therm, const std::shared_ptr<lifetime_state> &life, const std::shared_ptr<losses_state> &loss) { last_idx = 0; V = 0; P = 0; Q = 0; Q_max = 0; I = 0; I_dischargeable = 0; I_chargeable = 0; P_dischargeable = 0; P_chargeable = 0; capacity = cap; voltage = vol; thermal = therm; lifetime = life; losses = loss; replacement = std::make_shared<replacement_state>(); } battery_state::battery_state(const battery_state& rhs) { operator=(rhs); } battery_state &battery_state::operator=(const battery_state &rhs) { if (this != &rhs) { last_idx = rhs.last_idx; V = rhs.V; P = rhs.P; Q = rhs.Q; Q_max = rhs.Q_max; I = rhs.I; I_dischargeable = rhs.I_dischargeable; I_chargeable = rhs.I_chargeable; P_dischargeable = rhs.P_dischargeable; P_chargeable = rhs.P_chargeable; if (capacity) *capacity = *rhs.capacity; else capacity = std::make_shared<capacity_state>(*rhs.capacity); if (voltage) *voltage = *rhs.voltage; else voltage = std::make_shared<voltage_state>(*rhs.voltage); if (thermal) *thermal = *rhs.thermal; else thermal = std::make_shared<thermal_state>(*rhs.thermal); if (lifetime) *lifetime = *rhs.lifetime; else lifetime = std::make_shared<lifetime_state>(*rhs.lifetime); if (losses) *losses = *rhs.losses; else losses = std::make_shared<losses_state>(*rhs.losses); if (replacement) *replacement = *rhs.replacement; else replacement = std::make_shared<replacement_state>(*rhs.replacement); } return *this; } battery_params::battery_params(): battery_params(std::make_shared<capacity_params>(), std::make_shared<voltage_params>(), std::make_shared<thermal_params>(), std::make_shared<lifetime_params>(), std::make_shared<losses_params>()) { } battery_params::battery_params(const std::shared_ptr<capacity_params> &cap, const std::shared_ptr<voltage_params> &vol, const std::shared_ptr<thermal_params> &therm, const std::shared_ptr<lifetime_params> &life, const std::shared_ptr<losses_params> &loss) { chem = -1; dt_hour = 0.; nominal_energy = 0; nominal_voltage = 0; capacity = cap; voltage = vol; thermal = therm; lifetime = life; losses = loss; replacement = std::make_shared<replacement_params>(); } battery_params::battery_params(const battery_params& rhs) { operator=(rhs); } battery_params &battery_params::operator=(const battery_params &rhs) { if (this != &rhs) { chem = rhs.chem; dt_hour = rhs.dt_hour; nominal_voltage = rhs.nominal_voltage; nominal_energy = rhs.nominal_energy; if (capacity) *capacity = *rhs.capacity; else capacity = std::make_shared<capacity_params>(*rhs.capacity); if (voltage) *voltage = *rhs.voltage; else voltage = std::make_shared<voltage_params>(*rhs.voltage); if (thermal) *thermal = *rhs.thermal; else thermal = std::make_shared<thermal_params>(*rhs.thermal); if (lifetime) *lifetime = *rhs.lifetime; else lifetime = std::make_shared<lifetime_params>(*rhs.lifetime); if (losses) *losses = *rhs.losses; else losses = std::make_shared<losses_params>(*rhs.losses); if (replacement) *replacement = *rhs.replacement; else replacement = std::make_shared<replacement_params>(*rhs.replacement); } return *this; } void battery_t::initialize() { // capacity if (params->chem == battery_params::LEAD_ACID) { capacity = std::unique_ptr<capacity_t>(new capacity_kibam_t(params->capacity)); } else { capacity = std::unique_ptr<capacity_t>(new capacity_lithium_ion_t(params->capacity)); } // voltage if (params->voltage->voltage_choice == voltage_params::TABLE || params->chem == battery_params::IRON_FLOW) { voltage = std::unique_ptr<voltage_t>(new voltage_table_t(params->voltage)); } else if (params->chem == battery_params::LEAD_ACID || params->chem == battery_params::LITHIUM_ION) { voltage = std::unique_ptr<voltage_t>(new voltage_dynamic_t(params->voltage)); } else if (params->chem == battery_params::VANADIUM_REDOX) { voltage = std::unique_ptr<voltage_t>(new voltage_vanadium_redox_t(params->voltage)); } // lifetime lifetime = std::unique_ptr<lifetime_t>(new lifetime_t(params->lifetime)); // thermal thermal = std::unique_ptr<thermal_t>(new thermal_t(params->thermal)); // losses losses = std::unique_ptr<losses_t>(new losses_t(params->losses)); state = std::make_shared<battery_state>(capacity->state, voltage->state, thermal->state, lifetime->state, losses->state); } battery_t::battery_t(double dt_hr, int chem, capacity_t *capacity_model, voltage_t *voltage_model, lifetime_t *lifetime_model, thermal_t *thermal_model, losses_t *losses_model) { capacity = std::unique_ptr<capacity_t>(capacity_model); voltage = std::unique_ptr<voltage_t>(voltage_model); lifetime = std::unique_ptr<lifetime_t>(lifetime_model); thermal = std::unique_ptr<thermal_t>(thermal_model); losses = std::unique_ptr<losses_t>(losses_model); state = std::make_shared<battery_state>(capacity->state, voltage->state, thermal->state, lifetime->state, losses->state); params = std::make_shared<battery_params>(capacity->params, voltage->params, thermal->params, lifetime->params, losses->params); params->dt_hour = dt_hr; params->chem = chem; params->nominal_voltage = params->voltage->Vnom_default * params->voltage->num_cells_series; params->nominal_energy = params->nominal_voltage * params->voltage->num_strings * params->voltage->dynamic.Qfull * 1e-3; // initial conditions voltage->set_initial_SOC(capacity->state->SOC); } battery_t::battery_t(std::shared_ptr<battery_params> p): params(std::move(p)) { initialize(); // initial conditions voltage->set_initial_SOC(capacity->state->SOC); } battery_t::battery_t(const battery_t &rhs) { params = std::make_shared<battery_params>(); operator=(rhs); } battery_t &battery_t::operator=(const battery_t& rhs) { if (this != &rhs) { *params = *rhs.params; capacity = std::unique_ptr<capacity_t>(rhs.capacity->clone()); voltage = std::unique_ptr<voltage_t>(rhs.voltage->clone()); thermal = std::unique_ptr<thermal_t>(new thermal_t(*rhs.thermal)); lifetime = std::unique_ptr<lifetime_t>(new lifetime_t(*rhs.lifetime)); losses = std::unique_ptr<losses_t>(new losses_t(*rhs.losses)); state = std::make_shared<battery_state>(capacity->state, voltage->state, thermal->state, lifetime->state, losses->state); *state->replacement = *rhs.state->replacement; state->last_idx = rhs.state->last_idx; state->Q = rhs.state->Q; state->Q_max = rhs.state->Q_max; state->I = rhs.state->I; state->P = rhs.state->P; state->P_chargeable = rhs.state->P_chargeable; state->P_dischargeable = rhs.state->P_dischargeable; state->V = rhs.state->V; } return *this; } void battery_t::setupReplacements(double capacity_percent) { params->replacement = std::make_shared<replacement_params>(); params->replacement->replacement_option = replacement_params::CAPACITY_PERCENT; params->replacement->replacement_capacity = capacity_percent; } void battery_t::setupReplacements(std::vector<double> replacement_percents) { params->replacement = std::make_shared<replacement_params>(); params->replacement->replacement_option = replacement_params::SCHEDULE; params->replacement->replacement_schedule_percent = std::move(replacement_percents); } double battery_t::calculate_current_for_power_kw(double &P_kw) { if (P_kw == 0.) return 0.; double current; if (P_kw < 0) { double max_P = calculate_max_charge_kw(&current); if (max_P > P_kw) { P_kw = max_P; return current; } } else { double max_P = calculate_max_discharge_kw(&current); if (max_P < P_kw) { P_kw = max_P; return current; } } return voltage->calculate_current_for_target_w(P_kw * 1000., capacity->q0(), fmin(capacity->qmax(), capacity->qmax_thermal()), thermal->T_battery()); } double battery_t::calculate_voltage_for_current(double I) { // TODO: add looping when this function will actually be used... doesn't work that well atm double qmax = fmin(capacity->qmax(), capacity->qmax_thermal()); return voltage->calculate_voltage_for_current(I, charge_total(), qmax, thermal->T_battery()); } double battery_t::calculate_max_charge_kw(double *max_current_A) { thermal_state thermal_initial = thermal->get_state(); double q = capacity->q0(); double SOC_ratio = capacity->params->maximum_SOC * 0.01; double qmax = charge_maximum() * SOC_ratio; double power_W = 0; double current = 0; size_t its = 0; while (fabs(power_W - voltage->calculate_max_charge_w(q, qmax, thermal->T_battery(), &current)) > tolerance && its++ < 10) { power_W = voltage->calculate_max_charge_w(q, qmax, thermal->T_battery(), &current); thermal->updateTemperature(current, state->last_idx + 1); qmax = capacity->qmax() * thermal->capacity_percent() * 0.01 * SOC_ratio; } if (max_current_A) *max_current_A = current; *thermal->state = thermal_initial; return power_W / 1000.; } double battery_t::calculate_max_discharge_kw(double *max_current_A) { thermal_state thermal_initial = thermal->get_state(); double q = capacity->q0(); double SOC_ratio = (1. - capacity->params->minimum_SOC * 0.01); double qmax = charge_maximum() * SOC_ratio; double power_W = 0; double current = 0; size_t its = 0; while (fabs(power_W - voltage->calculate_max_discharge_w(q, qmax, thermal->T_battery(), &current)) > tolerance && its++ < 10) { power_W = voltage->calculate_max_discharge_w(q, qmax, thermal->T_battery(), &current); thermal->updateTemperature(current, state->last_idx + 1); qmax = capacity->qmax() * thermal->capacity_percent() * 0.01 * SOC_ratio; } if (max_current_A) *max_current_A = current; *thermal->state = thermal_initial; return power_W / 1000.; } double battery_t::run(size_t lifetimeIndex, double &I) { // Temperature affects capacity, but capacity model can reduce current, which reduces temperature, need to iterate double I_initial = I; size_t iterate_count = 0; capacity_state capacity_initial = capacity->get_state(); thermal_state thermal_initial = thermal->get_state(); while (iterate_count < 5) { runThermalModel(I, lifetimeIndex); runCapacityModel(I); if (fabs(I - I_initial) / fabs(I_initial) > tolerance) { *thermal->state = thermal_initial; *capacity->state = capacity_initial; I_initial = I; iterate_count++; } else { break; } } runVoltageModel(); runLifetimeModel(lifetimeIndex); runLossesModel(lifetimeIndex); update_state(I); return state->P; } void battery_t::runCurrent(double I) { run(++state->last_idx, I); } void battery_t::runPower(double P) { double I = calculate_current_for_power_kw(P); run(++state->last_idx, I); } void battery_t::runThermalModel(double I, size_t lifetimeIndex) { thermal->updateTemperature(I, lifetimeIndex); } double battery_t::estimateCycleDamage() { return lifetime->estimateCycleDamage(); } void battery_t::runCapacityModel(double &I) { // Don't update max capacity if the battery is idle if (fabs(I) > tolerance) { // Need to first update capacity model to ensure temperature accounted for capacity->updateCapacityForThermal(thermal->capacity_percent()); } capacity->updateCapacity(I, params->dt_hour); } void battery_t::runVoltageModel() { voltage->updateVoltage(capacity->q0(), capacity->qmax(), capacity->I(), thermal->T_battery(), params->dt_hour); } void battery_t::runLifetimeModel(size_t lifetimeIndex) { lifetime->runLifetimeModels(lifetimeIndex, capacity->chargeChanged(), 100. - capacity->SOC_prev(), 100. - capacity->SOC(), thermal->T_battery()); capacity->updateCapacityForLifetime(lifetime->capacity_percent()); } void battery_t::runLossesModel(size_t idx) { if (idx > state->last_idx || idx == 0) { losses->run_losses(idx, params->dt_hour, capacity->charge_operation()); state->last_idx = idx; } } void battery_t::runReplacement(size_t year, size_t hour, size_t step) { if (year == 0 && hour == 0) return; if (params->replacement->replacement_option == replacement_params::OPTIONS::NONE) return; bool replace = false; double percent = 0; if (params->replacement->replacement_option == replacement_params::OPTIONS::SCHEDULE) { if (year < params->replacement->replacement_schedule_percent.size()) { percent = params->replacement->replacement_schedule_percent[year]; if (percent > 0 && hour == 0 && step == 0) { replace = true; } } } else if (params->replacement->replacement_option == replacement_params::OPTIONS::CAPACITY_PERCENT) { if ((lifetime->capacity_percent() - tolerance) <= params->replacement->replacement_capacity) { replace = true; percent = 100.; } } if (replace) { state->replacement->n_replacements++; state->replacement->indices_replaced.push_back(util::lifetimeIndex(year, hour, step, (size_t) (1 / params->dt_hour))); lifetime->replaceBattery(percent); capacity->replace_battery(percent); thermal->replace_battery(year); } } void battery_t::resetReplacement() { state->replacement->n_replacements = 0; } double battery_t::getNumReplacementYear() { return state->replacement->n_replacements; } double battery_t::getReplacementPercent() { if (params->replacement->replacement_option == params->replacement->CAPACITY_PERCENT) { return (params->replacement->replacement_capacity / 100.0); } return 0.0; } void battery_t::changeSOCLimits(double min, double max) { capacity->change_SOC_limits(min, max); } double battery_t::charge_needed(double SOC_max) { double charge_needed = capacity->qmax_thermal() * SOC_max * 0.01 - capacity->q0(); if (charge_needed > 0) return charge_needed; else return 0.; } double battery_t::energy_to_fill(double SOC_max) { double battery_voltage = this->V_nominal(); // [V] double charge_needed_to_fill = this->charge_needed(SOC_max); // [Ah] - qmax - q0 return (charge_needed_to_fill * battery_voltage) * util::watt_to_kilowatt; // [kWh] } double battery_t::energy_nominal() { return V_nominal() * capacity->qmax() * util::watt_to_kilowatt; } double battery_t::energy_max(double SOC_max, double SOC_min) { return V()* charge_maximum_lifetime() * (SOC_max - SOC_min) * 0.01 * util::watt_to_kilowatt; } double battery_t::energy_available(double SOC_min) { return V() * charge_maximum_lifetime() * (SOC() - SOC_min) * 0.01 * util::watt_to_kilowatt; } double battery_t::power_to_fill(double SOC_max) { // in one time step return (this->energy_to_fill(SOC_max) / params->dt_hour); } double battery_t::charge_total() { return capacity->q0(); } double battery_t::charge_maximum() { return fmin(capacity->qmax(), capacity->qmax_thermal()); } double battery_t::charge_maximum_lifetime() { return capacity->qmax(); } double battery_t::charge_maximum_thermal() { return capacity->qmax_thermal(); } double battery_t::V() { return voltage->battery_voltage(); } double battery_t::V_nominal() { return voltage->battery_voltage_nominal(); } double battery_t::SOC() { return capacity->SOC(); } double battery_t::I() { return capacity->I(); } double battery_t::calculate_loss(double power, size_t lifetimeIndex) { size_t indexYearOne = util::yearOneIndex(params->dt_hour, lifetimeIndex); auto hourOfYear = (size_t)std::floor(indexYearOne * params->dt_hour); size_t monthIndex = (size_t) util::month_of((double)(hourOfYear)) - 1; if (params->losses->loss_choice == losses_params::MONTHLY) { if (power > 0) { return params->losses->monthly_discharge_loss[monthIndex]; } else if (power < 0) { return params->losses->monthly_charge_loss[monthIndex]; } else { return params->losses->monthly_idle_loss[monthIndex]; } } else if (params->losses->loss_choice == losses_params::SCHEDULE) { return params->losses->schedule_loss[lifetimeIndex % params->losses->schedule_loss.size()]; } } double battery_t::getLoss() { return losses->getLoss(); } battery_state battery_t::get_state() { return *state; } battery_params battery_t::get_params() { return *params; } void battery_t::set_state(const battery_state& tmp_state) { *state = tmp_state; } void battery_t::update_state(double I) { state->I = I; state->Q = capacity->q0(); state->Q_max = capacity->qmax(); state->V = voltage->battery_voltage(); state->P_dischargeable = calculate_max_discharge_kw(&state->I_dischargeable); state->P_chargeable = calculate_max_charge_kw(&state->I_chargeable); state->P = I * voltage->battery_voltage() * util::watt_to_kilowatt; }
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1991 -- All Rights Reserved PROJECT: PC GEOS MODULE: GeoCalc FILE: documentManip.asm AUTHOR: Gene Anderson, Feb 12, 1991 ROUTINES: Name Description ---- ----------- REVISION HISTORY: Name Date Description ---- ---- ----------- Gene 2/12/91 Initial revision DESCRIPTION: This file contains routines to implement $Id: documentManip.asm,v 1.1 97/04/04 15:47:59 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DocumentPrint segment resource COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GeoCalcDocumentVerifyPrintRequest %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Verify we can print with the current parameters CALLED BY: MSG_PRINT_VERIFY_PRINT_REQUEST PASS: *ds:si - instance data ds:di - *ds:si es - seg addr of GeoCalcDocumentClass ax - the message cx:dx - OD of PrintControlClass object to reply to RETURN: none DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 8/17/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GeoCalcDocumentVerifyPrintRequest method dynamic GeoCalcDocumentClass, MSG_PRINT_VERIFY_PRINT_REQUEST pushdw cxdx ; ; Make sure the print range is valid ; push si mov bx, ds:[di].GCDI_spreadsheet mov si, offset ContentSpreadsheet ;^lbx:si <- OD of our ssheet call GetPrintRangeCommon pop si jc returnError ; ; Make sure the options are OK ; call GetPrintOptionsCommon ;ax <- SpreadsheetPrintFlags tst ax ;any flags specified? jz nothingToPrint ; ; Success! ; mov cx, TRUE ;cx <- continue print job returnFlag: ; ; Tell the PrintControl if it was OK or not ; popdw bxsi ;^lbx:si <- OD of print control mov ax, MSG_PRINT_CONTROL_VERIFY_COMPLETED mov di, mask MF_FIXUP_DS call ObjMessage ret ; ; The user specified nothing to print -- bitch and moan ; nothingToPrint: call GetSpreadsheetFile ;bx <- file handle mov si, offset nothingToPrintMessage jmp short moan ; ; The user specified an invalid print range. Put up an error ; message so the user will know that printing will not commence. ; returnError: call GetSpreadsheetFile mov si, offset invalidPrintRangeMessage moan:: call DocumentMessage clr cx ;cx <- don't print -- error jmp returnFlag GeoCalcDocumentVerifyPrintRequest endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GeoCalcDocumentStartPrinting %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Print the document CALLED BY: MSG_PRINT_START_PRINTING PASS: *ds:si - instance data es - seg addr of GeoCalcDocumentClass ax - the method cx:dx - OD to sent MSG_PRINTING_COMPLETED to bp - handle of GString RETURN: nothing DESTROYED: bx, si, di, ds, es (method handler) PSEUDO CODE/STRATEGY: A document is a collection of pages which have the following characteristics: Header <- one call to spreadsheet Body <- one call to spreadsheet Column Titles Row Titles Spreadsheet Footer <- one call to spreadsheet DrawGrid - Draw the grid around the cells DrawHeader - Draw the header at the top of every page DrawFooter - Draw the footer at the bottom of every page DrawColumnTitles- Draw titles at the top of each column on every page. DrawRowTitles - Draw titles to the left of each row on every page. Sideways - Rotate the output 90 degrees ScaleToFit - Scale the entire document to fit on a single page. CenterVertically- Center output vertically on the page CenterHorizontally- Center output vertically on the page Continuous Printing: Continuous printing turns the spreadsheet into one enormous document. The idea is that the spooler will parcel the document into the most appropriate form for the printer. If we are printing in portrait mode that means that the document will be printed as a set of vertical bands where the bottom of one printed page runs into the top of the next. This happens to be just what we want. If we are printing in landscape mode it means that the document will be printed as a set of horizontal bands where the right edge of one printed page runs into the left edge of the next. This is exactly what we want. Since the range is considered one large document there is a single header and a single footer. Scale To Fit: Scale to fit implies that the entire body of the document will fit on a single page. To do this we assume "continuous" printing in order to generate the giant document. We then apply appropriate scaling when we go to draw the body. KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- eca 2/12/91 Initial version jcw 4/29/91 Actually made it print :-) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GeoCalcPrintParams struct ; ; SpreadsheetDrawParams structure that we set up and then use for ; drawing the body. ; GCPP_sdp SpreadsheetDrawParams ; ; The next few entries are initialized and then are only referenced. ; The pairs (Area/Range) must be kept in order. ; GCPP_headerArea RectDWord ; Area reserved for header GCPP_headerRange CellRange ; Limit for the header GCPP_footerArea RectDWord ; Area reserved for footer GCPP_footerRange CellRange ; Limit for the footer GCPP_bodyArea RectDWord ; Area reserved for body GCPP_bodyRange CellRange ; Limit for the body GCPP_topLeft CellReference ; The current top-left area ; used by the body. ; ; These represent the total page area and the area spanned by the ; entire spreadsheet range. ; GCPP_pageRect RectDWord ; Area of the printed page GCPP_rangeRect RectDWord ; Area of the spreadsheet range ; ; This is the PrintControl object. ; GCPP_pc optr ; OD of the PrintControl ; ; Handle of associated document file ; GCPP_file hptr ; ; The current page which we pass to the PrintControl as we print. ; GCPP_page word ; Current page ; ; This is the position for the next note on the current page. ; GCPP_notePos word ; Y-position on the page ; ; OD of the GrObj for this document ; GCPP_grobj optr ;OD of the GrObj align word GeoCalcPrintParams ends CheckHack <offset GCPP_sdp eq 0> GeoCalcDocumentStartPrinting method dynamic GeoCalcDocumentClass, MSG_PRINT_START_PRINTING ; ; Now the document size is set up correctly. ; We can now start printing... ; mov di, bp ;di <- handle of GState sub sp, size GeoCalcPrintParams mov bp, sp ;ss:bp <- frame ptr ; ; Save the OD of the PrintControl object ; movdw ss:[bp].GCPP_pc, cxdx ; ; Get the OD of the GrObj for later ; if _CHARTS push si call GetGrObjBodyOD movdw ss:[bp].GCPP_grobj, bxsi pop si endif ; ; Get other fun stuff ; call GetSpreadsheetFile mov ss:[bp].GCPP_file, bx ; ; Get the Spreadsheet OD for this document. ; call GetDocSpreadsheet ; ; At this point: ; ^lbx:si - OD of spreadsheet object ; ss:bp - ptr to GeoCalcPrintParams ; di - handle of GState to draw with ; call InitPrintParameters ; Initialize the stack frame jc afterPrint ; Branch if error call CalcNumberOfPages ; ax <- # of pages push es GetResourceSegmentNS dgroup, es ; es = dgroup mov es:totalPageCount, ax ; Set the # of pages call InitPrintParameters ; Reinitialize stuff. mov ax, ss:[bp].GCPP_page ; Save the current page number EC < call ECCheckESDGroup > mov es:currentPage, ax ; Set the current page here too pop es call PrintPagesAndNotes ; Print the spreadsheet and notes ; ax <- # of pages printed clc ; Signal: no error afterPrint: mov bx, cx ; ^lbx:si <- PrintControl object mov si, dx ; ; Carry set here on error. ; mov cx, ss:[bp].GCPP_file ; cx <- file handle ; ; Clean up stack while preserving carry ; lea sp, ss:[bp][(size GeoCalcPrintParams)] jc errorPrinting ; Branch on error ; ; All done... Signal the SPC that we're finished. ; mov ax, MSG_PRINT_CONTROL_PRINTING_COMPLETED mov di, mask MF_CALL call ObjMessage ; Tell PrintControl that we're done quit: push es mov di, bx ; save bx value GetResourceSegmentNS dgroup, es, TRASH_BX mov bx, di ; restore bx value EC < call ECCheckESDGroup > mov es:currentPage, 0 ; Reset the current page mov es:totalPageCount, DEFAULT_TOTAL_PAGE_COUNT pop es ret errorPrinting: ; ; There was some sort of error. We need to cancel the job. ; cx = File handle ; push cx ; Save file handle mov ax, MSG_PRINT_CONTROL_PRINTING_CANCELLED mov di, mask MF_CALL call ObjMessage ; Tell PrintControl that we're done pop bx ; bx <- file handle ; ; Tell the user that some error was encountered and that the print ; job was aborted. ; ; bx = File handle ; mov si, offset PrintHdrFtrTooLargeMessage call DocumentMessage ; Display the message jmp quit GeoCalcDocumentStartPrinting endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PrintPagesAndNotes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Print the pages and the notes CALLED BY: GeoCalcDocumentStartPrinting() PASS: di = GState to draw with ss:bp = Pointer to GeoCalcPrintParams ^lbx:si = OD of the spreadsheet ^lcx:dx = OD of the spool print control RETURN: ax = # of pages printed DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 6/11/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ PrintPagesAndNotes proc near uses es .enter ; ; set es = dgroup ; GetResourceSegmentNS dgroup, es ; es = dgroup ; di = gstate to draw with ; ^lbx:si = OD of spreadsheet ; ^lcx:dx = OD of spool print control ; ss:bp = pointer to GeoCalcPrintParams ; ; ; See if we're printing cell notes only. If so, don't bother ; looping through the pages, because we'll loop forever since ; nothing is being printed each time we call PrintNextPage so ; SPF_DONE will never be set. ; test ss:[bp].GCPP_sdp.SDP_printFlags, mask SPF_PRINT_DOCUMENT or \ mask SPF_PRINT_GRAPHICS jz printingDone ; ; Loop and print each page ; printLoop: call PrintNextPage ; Print another page... inc ss:[bp].GCPP_page ; Update page number EC < call ECCheckESDGroup > inc es:currentPage ; Update page number here too mov al, PEC_FORM_FEED call GrNewPage ; Move to next page test ss:[bp].GCPP_sdp.SDP_printFlags, mask SPF_DONE jz printLoop ; Loop to print another page ; ; We've printed the spreadsheet -- add in cell notes if requested ; printingDone: call PrintNotes ; Print the notes now mov ax, ss:[bp].GCPP_page ; ax <- next page to print dec ax ; Return # of pages printed .leave ret PrintPagesAndNotes endp if ERROR_CHECK ECCheckESDGroup proc near uses ax, bx, es .enter pushf mov ax, es GetResourceSegmentNS dgroup, es, TRASH_BX mov bx, es cmp ax, bx ERROR_NE -1 popf .leave ret ECCheckESDGroup endp endif COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CalcNumberOfPages %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Calculate the number of pages CALLED BY: GeoCalcDocumentStartPrinting() PASS: ss:bp = Pointer to GeoCalcPrintParams ^lbx:si = Pointer to Spreadsheet instance ^lcx:dx = PrintControl object di = GState RETURN: ax = # of pages DESTROYED: none PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 6/11/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ CalcNumberOfPages proc near uses bx, cx, dx, si, di .enter ; ; Set print flags so that we'll skip the drawing. ; push ss:[bp].GCPP_sdp.SDP_gstate ; Save old gstate push ss:[bp].GCPP_sdp.SDP_printFlags ; Save old flags ornf ss:[bp].GCPP_sdp.SDP_printFlags, mask SPF_SKIP_DRAW ; ; Now create a gstate with no window. ; clr di ; di <- Window handle (none) call GrCreateState ; di <- gstate with no window mov ss:[bp].GCPP_sdp.SDP_gstate, di ; Save new gstate mov ss:[bp].GCPP_page, 1 ; Initialize # of pages call PrintPagesAndNotes ; ax <- # of pages printed pop ss:[bp].GCPP_sdp.SDP_printFlags ; Restore old flags pop ss:[bp].GCPP_sdp.SDP_gstate ; Restore old gstate ; ; Now tell the PrintControl about it ; push ax, bp movdw bxsi, cxdx ;^lbx:si <- OD of PrintControl mov dx, ax ;dx <- # of pages mov cx, 1 ;cx <- start page mov ax, MSG_PRINT_CONTROL_SET_TOTAL_PAGE_RANGE mov di, mask MF_CALL ;di <- MessageFlags call ObjMessage pop ax, bp .leave ret CalcNumberOfPages endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% InitPrintParameters %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Initialize the SpreadsheetDrawParams. CALLED BY: GeoCalcDocumentStartPrinting() PASS: ^lcx:dx = OD of PrintControl object ^lbx:si = OD of Spreadsheet di = GState to draw with ss:bp = Pointer to the GeoCalcPrintParams ds = Block owned by the process RETURN: carry set on error ss:bp - GeoCalcPrintParams GCPP_sdp.SDP_printFlags GCPP_topLeft - start of range to print GCPP_bodyRange - range to print DESTROYED: nothing PSEUDO CODE/STRATEGY: Get the range from PrintRange Save the gstate Initialize the flags Get the user options Figure the different areas... KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 4/26/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ InitPrintParameters proc near uses ax, cx, es, di .enter ; ; For some error-checking, we wipe out the the stack frame in ; case something valid looking was there. ; EC < push ax, cx, es, di ;> EC < mov al, 0xcc ;al <- byte to store > EC < lea di, ss:[bp].GCPP_sdp ;> EC < segmov es, ss ;es:di <- ptr to area> EC < mov cx, (size SpreadsheetDrawParams) > EC < rep stosb ;biff me jesus> EC < pop ax, cx, es, di ;> call GetPrintOptions call GetPrintRange ; Get the range to print mov ss:[bp].GCPP_sdp.SDP_gstate, di ; Save the gstate ; ; We check for sideways printing specially because we actually ; need to communicate the users desire for sideways printing to ; the SPC directly. ; call CheckSideways ; Check for sideways printing call GetHeaderRange ; Get the range for the header call GetFooterRange ; Get the range for the footer call FigureAreas ; Figure the assorted areas jc quit ; Quit if no space for data ; ; Copy the top-left point of the range into the top-left of the ; next area to draw. ; mov ax, ss:[bp].GCPP_bodyRange.CR_start.CR_row mov ss:[bp].GCPP_topLeft.CR_row, ax mov ax, ss:[bp].GCPP_bodyRange.CR_start.CR_column mov ss:[bp].GCPP_topLeft.CR_column, ax ; carry already clear quit: .leave ret InitPrintParameters endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GetPrintOptions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get the options for printing CALLED BY: InitPrintParameters() PASS: ss:bp - ptr to GeoCalcPrintParams GCPP_file - handle of file RETURN: GCPP_sdp.SDP_printFlags - SpreadsheetPrintFlags GCPP_page - starting page # DESTROYED: none PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 8/18/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GetPrintOptions proc near uses ax, bx, cx, dx, es, di, si .enter ; ; Get the print options saved with the document ; mov bx, ss:[bp].GCPP_file call DBLockMap mov di, es:[di] ;es:di <- ptr to map mov ax, es:[di].CMB_pageSetup.CPSD_flags mov ss:[bp].GCPP_sdp.SDP_printFlags, ax mov ax, es:[di].CMB_pageSetup.CPSD_startPage mov ss:[bp].GCPP_page, ax call DBUnlock ; ; Also get the users options for what they want printed ; call GetPrintOptionsCommon ornf ss:[bp].GCPP_sdp.SDP_printFlags, ax .leave ret GetPrintOptions endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GetPrintOptionsCommon %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get the users print options for what should be printed CALLED BY: GetPrintOptions(), GeoCalcDocumentVerifyPrintRequest() PASS: ds - fixupable segment RETURN: ax - SpreadsheetPrintFlags: SPF_PRINT_DOCUMENT SPF_PRINT_GRAPHICS SPF_PRINT_NOTES DESTROYED: cx, dx, di PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 1/21/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GetPrintOptionsCommon proc near uses bx, bp, si .enter GetResourceHandleNS GCPrintOptionsGroup, bx mov si, offset GCPrintOptionsGroup mov ax, MSG_GEN_BOOLEAN_GROUP_GET_SELECTED_BOOLEANS mov di, mask MF_CALL or mask MF_FIXUP_DS call ObjMessage .leave ret GetPrintOptionsCommon endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GetPrintRange %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get the range to print CALLED BY: InitPrintParameters PASS: ss:bp = Pointer to GeoCalcPrintParams ^lbx:si = OD of Spreadsheet RETURN: ss:bp.GCPP_bodyRange - set DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 4/26/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GetPrintRange proc near uses ax, cx, dx, di .enter call GetPrintRangeCommon ; ; This should never fail, since we verified it earlier ; EC < ERROR_C FAILED_ASSERTION_IN_PRINTING ;> mov ss:[bp].GCPP_bodyRange.CR_start.CR_row, ax mov ss:[bp].GCPP_bodyRange.CR_start.CR_column, cx mov ss:[bp].GCPP_bodyRange.CR_end.CR_row, dx mov ss:[bp].GCPP_bodyRange.CR_end.CR_column, di .leave ret GetPrintRange endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GetPrintRangeCommon %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get print range from Print DB. CALLED BY: GetPrintRange(), GeoCalcDocumentVerifyPrintRequest() PASS: ^lbx:si - OD of spreadsheet RETURN: carry - set if error else: (ax,cx), (dx,di) - CellRange DESTROYED: none PSEUDO CODE/STRATEGY: * Find out what the user wants to print (i.e. entire spreadsheet, displayed cells, or selected cells) * Get the range based on the above option KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 8/18/92 Initial version clee 10/6/94 Jedi version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GetPrintRangeCommon proc near uses bp .enter sub sp, (size SpreadsheetFormatParseRangeParams) mov bp, sp ; ; Get the text for the print range ; push bx, si GetResourceHandleNS GCPrintRange, bx mov si, offset GCPrintRange CheckHack <(offset SFPRP_text) eq 0> mov dx, ss ;dx:bp <- ptr to buffer mov ax, MSG_VIS_TEXT_GET_ALL_PTR mov di, mask MF_FIXUP_DS or mask MF_CALL call ObjMessage pop bx, si ; ; Ask our spreadsheet if it is OK ; mov ax, MSG_SPREADSHEET_PARSE_RANGE_REFERENCE mov di, mask MF_FIXUP_DS or mask MF_CALL call ObjMessage ; ; Load registers as if it were OK... ; mov ax, ss:[bp].SFPRP_range.CR_start.CR_row mov cx, ss:[bp].SFPRP_range.CR_start.CR_column mov dx, ss:[bp].SFPRP_range.CR_end.CR_row mov di, ss:[bp].SFPRP_range.CR_end.CR_column ; ; Clean up stack, and preserve carry ; lea sp, ss:[bp][(size SpreadsheetFormatParseRangeParams)] .leave ret GetPrintRangeCommon endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CheckSideways %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Check to see if the user wants stuff printed sideways CALLED BY: InitPrintParameters PASS: ^lcx:dx = OD of PrintControl object ss:bp = Pointer to GeoCalcPrintParams RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 4/26/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ CheckSideways proc near uses ax, bx, cx, dx, bp, di, si .enter mov ax, mask PCA_FORCE_ROTATION ; Assume sideways printing test ss:[bp].GCPP_sdp.SDP_printFlags, mask SPF_PRINT_SIDEWAYS jnz gotBits ; Branch if sideways clr ax ; Portrait printing gotBits: mov bx, cx ; ^lbx:si <- OD of SPC mov si, dx push ax ; Save bits... mov ax, MSG_PRINT_CONTROL_GET_ATTRS mov di, mask MF_CALL call ObjMessage ; cx <- PrintControlAttrs pop ax ; Restore bits andnf cx, not mask PCA_FORCE_ROTATION ornf cx, ax ; Set bit if appropriate mov ax, MSG_PRINT_CONTROL_SET_ATTRS mov di, mask MF_CALL call ObjMessage .leave ret CheckSideways endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GetHeaderRange %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get the range that the header occupies CALLED BY: InitPrintParameters PASS: ss:bp = Pointer to GeoCalcPrintParams ^lbx:si = Spreadsheet instance RETURN: GCPP_headerRange DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 5/ 9/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GetHeaderRange proc near uses ax, di .enter ; ; Assume no header ; mov ss:[bp].GCPP_headerRange.CR_start.CR_row, -1 test ss:[bp].GCPP_sdp.SDP_printFlags, mask SPF_PRINT_HEADER jz quit mov ax, MSG_SPREADSHEET_GET_HEADER_RANGE lea di, ss:[bp].GCPP_headerRange call GetHeaderFooterRange quit: .leave ret GetHeaderRange endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GetHeaderFooterRange %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get a range from the spreadsheet CALLED BY: GetHeaderRange, GetFooterRange PASS: ^lbx:si = Spreadsheet instance ss:di = Pointer to CellRange to fill in ax = Method to send to the spreadsheet RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 5/ 9/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GetHeaderFooterRange proc near uses ax, cx, dx, bp .enter push di ; Save pointer to rectangle mov di, mask MF_CALL ; Call the spreadsheet call ObjMessage ; ax/cx = top/left ; dx/bp = bottom/right pop di ; Restore pointer to rectangle mov ss:[di].R_top, ax ; Save the rectangle mov ss:[di].R_left, cx mov ss:[di].R_bottom, dx mov ss:[di].R_right, bp .leave ret GetHeaderFooterRange endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GetFooterRange %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get the range that the footer occupies CALLED BY: InitPrintParameters PASS: ss:bp = Pointer to GeoCalcPrintParams ^lbx:si = Spreadsheet instance RETURN: GCPP_footerRange DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 5/ 9/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GetFooterRange proc near uses ax, di .enter ; ; Assume no footer ; mov ss:[bp].GCPP_footerRange.CR_start.CR_row, -1 test ss:[bp].GCPP_sdp.SDP_printFlags, mask SPF_PRINT_FOOTER jz quit mov ax, MSG_SPREADSHEET_GET_FOOTER_RANGE lea di, ss:[bp].GCPP_footerRange call GetHeaderFooterRange quit: .leave ret GetFooterRange endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FigureAreas %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Figure out all the different areas we are going to fill. CALLED BY: InitPrintParameters PASS: ss:bp = Pointer to GeoCalcPrintParams ^lbx:si = OD of Spreadsheet ^lcx:dx = OD of SpoolPrintControl RETURN: The areas filled in. carry set if there is no room for the body because the header and footer are too large. DESTROYED: nothing PSEUDO CODE/STRATEGY: These can just be gotten. pageRect rangeRect These need to be calculated. headerArea footerArea bodyArea KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 4/29/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FigureAreas proc near uses ax, bx, cx, dx, di, si, bp .enter push bx, si ; Save OD of spreadsheet ; ; Get the dimensions and the margins for the current document. ; call GetDocDimensionsAndMargins ; ; ax = Left margin ; di = Top margin ; cx = Width of printable area ; dx = Height of printable area ; ; ^lbx:si = Spool print control ; ; call SetPageRectAndMargin ; Save the page-rectangle pop bx, si ; Restore OD of spreadsheet ; ; Now that we've gotten the page rectangle, we compute the the size ; of the range rectangle. ; ^lbx:si = OD of Spreadsheet ; push bp ; Save frame ptr mov dx, ss ; dx:cx <- ptr to RectDWord lea cx, ss:[bp].GCPP_rangeRect lea bp, ss:[bp].GCPP_bodyRange ; dx:bp <- ptr to range mov ax, MSG_SPREADSHEET_GET_RANGE_BOUNDS mov di, mask MF_CALL call ObjMessage pop bp ; Restore frame ptr ; ; In some cases it is convenient to make the page-rectangle be the ; same as the range-rectangle (plus header/footer space). ; We do this if we are NOT doing scale-to-fit, and if we are doing ; continuous printing. ; test ss:[bp].GCPP_sdp.SDP_printFlags, mask SPF_SCALE_TO_FIT jnz pageNotRange test ss:[bp].GCPP_sdp.SDP_printFlags, mask SPF_CONTINUOUS jz pageNotRange ; ; We are not doing scale-to-fit and we are continuous printing. ; We want to consider the page rectangle to be as large as it needs ; to be to hold the entire range. ; call SetPageToRange pageNotRange: ; ; Now we compute the other values. ; call FigureHeaderArea call FigureFooterArea call FigureBodyArea .leave ret FigureAreas endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GetDocDimensionsAndMargins %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get the dimensions and margins for the document. CALLED BY: FigureAreas PASS: ^lcx:dx = SpoolPrintControl object ss:bp = GeoCalcPrintParams RETURN: ^lbx:si = SpoolPrintControl object ax = Left margin di = Top margin cx = Width of the printable area dx = Height of the printable area DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 8/28/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GetDocDimensionsAndMargins proc near uses bp .enter mov bx, cx mov si, dx sub sp, (size PageSizeReport) mov dx, ss mov bp, sp ; dx:bp = PageSizeReport mov ax, MSG_PRINT_CONTROL_CALC_DOC_DIMENSIONS mov di, mask MF_CALL call ObjMessage ; dx:bp = filled PageSizeReport mov ax, ss:[bp].PSR_margins.PCMP_left mov di, ss:[bp].PSR_margins.PCMP_top mov cx, ss:[bp].PSR_width.low mov dx, ss:[bp].PSR_height.low add sp, (size PageSizeReport) .leave ret GetDocDimensionsAndMargins endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetPageRectAndMargin %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Setup the GCPP_pageRect field of the GeoCalcPrintParams CALLED BY: FigureAreas PASS: ss:bp = GeoCalcPrintParams cx = Page width dx = Page height ax = Left margin di = Top margin RETURN: nothing DESTROYED: cx, dx PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 8/28/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetPageRectAndMargin proc near mov ss:[bp].GCPP_pageRect.RD_bottom.low, dx mov ss:[bp].GCPP_pageRect.RD_right.low, cx ; ; Zero out all the high words, etc ; clr cx mov ss:[bp].GCPP_pageRect.RD_top.low, cx mov ss:[bp].GCPP_pageRect.RD_left.low, cx mov ss:[bp].GCPP_pageRect.RD_top.high, cx mov ss:[bp].GCPP_pageRect.RD_left.high, cx mov ss:[bp].GCPP_pageRect.RD_bottom.high, cx mov ss:[bp].GCPP_pageRect.RD_right.high, cx ; ; Save the enforced printer margins. (x = ax, y = di) ; mov ss:[bp].GCPP_sdp.SDP_margins.P_x, ax mov ss:[bp].GCPP_sdp.SDP_margins.P_y, di ret SetPageRectAndMargin endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetPageToRange %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set the page rectangle to be the range rectangle plus some space for header and footer and the row/column headers CALLED BY: FigureAreas PASS: ss:bp = Pointer to GeoCalcPrintParams ^lbx:si = Spreadsheet instance RETURN: GCPP_pageRect set, doc-size set in the SpoolPrintControl DESTROYED: nothing PSEUDO CODE/STRATEGY: Adjust rangeHeight to include the header and footer height We want to set the pageRect to: top/left = 0,0 bottom = max( pageHeight, rangeHeight ) right = max( pageRight, rangeRight ) KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 4/29/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetPageToRange proc near uses ax, bx, cx, dx, di, si, bp .enter ; ; Add the header and footer in to the rangeHeight. ; call GetHeaderHeight ; dx:ax <- header height movdw dicx, dxax ; di:cx <- header height call GetFooterHeight ; dx:ax <- footer height adddw dxax, dicx ; dx:ax <- total height adddw ss:[bp].GCPP_rangeRect.RD_bottom, dxax ; ; Add space for row/column headers if we're printing them ; test ss:[bp].GCPP_sdp.SDP_printFlags, mask SPF_PRINT_ROW_COLUMN_TITLES jz skipTitles adddw ss:[bp].GCPP_rangeRect.RD_right, SPREADSHEET_RULER_WIDTH adddw ss:[bp].GCPP_rangeRect.RD_bottom, SPREADSHEET_RULER_HEIGHT skipTitles: ; ; Load up: ; ax.bx = rangeHeight ; cx.dx = pageHeight ; movdw axbx, ss:[bp].GCPP_rangeRect.RD_bottom subdw axbx, ss:[bp].GCPP_rangeRect.RD_top movdw cxdx, ss:[bp].GCPP_pageRect.RD_bottom subdw cxdx, ss:[bp].GCPP_pageRect.RD_top ; ; Get ax.bx = max( rangeHeight, pageHeight ) ; cmpdw axbx, cxdx jae gotMaxHeight movdw axbx, cxdx gotMaxHeight: ; ; ax.bx = max( rangeHeight, pageHeight ) ; movdw ss:[bp].GCPP_pageRect.RD_bottom, axbx ; ; Now do the same thing for the width ; Load up: ; ax.bx = rangeWidth ; cx.dx = pageWidth ; movdw axbx, ss:[bp].GCPP_rangeRect.RD_right subdw axbx, ss:[bp].GCPP_rangeRect.RD_left movdw cxdx, ss:[bp].GCPP_pageRect.RD_right subdw cxdx, ss:[bp].GCPP_pageRect.RD_left ; ; Get ax.bx = max( rangeWidth, pageWidth ) ; cmpdw axbx, cxdx jae gotMaxWidth movdw axbx, cxdx gotMaxWidth: ; ; ax.bx = max( rangeWidth, pageWidth ) ; movdw ss:[bp].GCPP_pageRect.RD_right, axbx ; ; Zero the top/left. ; clr ax mov ss:[bp].GCPP_pageRect.RD_top.low, ax mov ss:[bp].GCPP_pageRect.RD_top.high, ax mov ss:[bp].GCPP_pageRect.RD_left.low, ax mov ss:[bp].GCPP_pageRect.RD_left.high, ax ; ; We need to inform the SPC that the document size is different now. ; push bp clr ax mov dx, ss:[bp].GCPP_sdp.SDP_margins.P_y shl dx, 1 ; Margins on both sides adddw axdx, ss:[bp].GCPP_pageRect.RD_bottom pushdw axdx clr ax mov cx, ss:[bp].GCPP_sdp.SDP_margins.P_x shl cx, 1 ; Margins on both sides adddw axcx, ss:[bp].GCPP_pageRect.RD_right pushdw axcx CheckHack <(size PCDocSizeParams) eq 8> mov bx, ss:[bp].GCPP_pc.handle mov si, ss:[bp].GCPP_pc.offset mov ax, MSG_PRINT_CONTROL_SET_EXTENDED_DOC_SIZE mov dx, ss mov bp, sp ;ss:bp <- ptr to params mov di, mask MF_CALL call ObjMessage add sp, (size PCDocSizeParams) ; clean up stack pop bp .leave ret SetPageToRange endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FigureHeaderArea %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Figure out the area we'll need for the header. CALLED BY: InitPrintParameters PASS: ss:bp = Pointer to GeoCalcPrintParams ^lbx:si = Instance ptr RETURN: GCPP_headerArea set DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 4/29/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FigureHeaderArea proc near uses ax, dx, di .enter ; ; Assume there is no header. Create an empty area. ; ; Header occupies the top of the paper rectangle. ; push si ; Save instance chunk lea si, ss:[bp].GCPP_pageRect lea di, ss:[bp].GCPP_headerArea call CopyDocRect pop si ; Restore instance chunk call GetHeaderHeight ; dx:ax <- header height ; ; dx:ax - height of the header. ; bottom = top + height ; adddw dxax, ss:[bp].GCPP_headerArea.RD_top movdw ss:[bp].GCPP_headerArea.RD_bottom, dxax .leave ret FigureHeaderArea endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FigureFooterArea %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Figure out the area needed by the footer. CALLED BY: InitPrintParameters PASS: ss:bp = Pointer to GeoCalcPrintParams ^lbx:si = Instance ptr RETURN: GCPP_footerArea set DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 4/29/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FigureFooterArea proc near uses ax, bx, cx, dx .enter ; ; Assume there is no footer. Create an empty area. ; ; Footer occupies the bottom of the paper rectangle. ; push si ; Save instance chunk lea si, ss:[bp].GCPP_pageRect lea di, ss:[bp].GCPP_footerArea call CopyDocRect pop si ; Restore instance chunk call GetFooterHeight ; dx:ax <- footer height ; ; dx:ax - height of the footer. ; top = bottom - height ; movdw cxbx, ss:[bp].GCPP_footerArea.RD_bottom subdw cxbx, dxax ;cx:bx <- new top for header movdw ss:[bp].GCPP_footerArea.RD_top, cxbx .leave ret FigureFooterArea endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% FigureBodyArea %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Figure out the area left for the body. CALLED BY: InitPrintParameters PASS: ss:bp = Pointer to GeoCalcPrintParams RETURN: carry set if there's no room for the body GCPP_bodyArea set DESTROYED: nothing PSEUDO CODE/STRATEGY: The body area is *always*: body.left = page.left body.right = page.right body.top = header.bottom body.bottom= footer.top KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 4/29/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ FigureBodyArea proc near uses ax, di, si .enter ; ; First copy the left/right edges ; lea si, ss:[bp].GCPP_pageRect lea di, ss:[bp].GCPP_bodyArea call CopyDocRect ; ; Now copy the top/bottom edges ; mov ax, ss:[bp].GCPP_headerArea.RD_bottom.low mov ss:[bp].GCPP_bodyArea.RD_top.low, ax mov ax, ss:[bp].GCPP_headerArea.RD_bottom.high mov ss:[bp].GCPP_bodyArea.RD_top.high, ax mov ax, ss:[bp].GCPP_footerArea.RD_top.low mov ss:[bp].GCPP_bodyArea.RD_bottom.low, ax mov ax, ss:[bp].GCPP_footerArea.RD_top.high mov ss:[bp].GCPP_bodyArea.RD_bottom.high, ax ; ; Check for header bottom below footer top. ; mov ax, ss:[bp].GCPP_headerArea.RD_bottom.high cmp ax, ss:[bp].GCPP_footerArea.RD_top.high ja errorNoBody jb quitNoError mov ax, ss:[bp].GCPP_headerArea.RD_bottom.low cmp ax, ss:[bp].GCPP_footerArea.RD_top.low jae errorNoBody quitNoError: clc ; signal: no error quit: .leave ret errorNoBody: stc ; signal: no space for the body jmp quit FigureBodyArea endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PrintNextPage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Print another page of the spreadsheet CALLED BY: GeoCalcDocumentStartPrinting() PASS: ^lcx:dx = OD of SpoolPrintControl object ^lbx:si = OD of Spreadsheet ss:bp = GeoCalcPrintParams RETURN: SDP_printFlags with the SPF_DONE bit set if we should stop printing. DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 4/26/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ PrintNextPage proc near uses ax, cx, dx, di .enter ; ; Signal SPC that we're printing a page. ; call SignalPrintingPage ; Signal SPC that we're printing ; ; ss:bp = GeoCalcPrintParams ; ^lbx:si = Spreadsheet instance ; call DrawHeader ; Draw whatever header we have. call DrawFooter ; Draw whatever footer we have. ; ; NOTE: we clear the SPF_DONE flag because the header/footer ; printing may have set it. If this routine is being called, ; we quite obviously aren't be done yet. ; andnf ss:[bp].GCPP_sdp.SDP_printFlags, not (mask SPF_DONE) call DrawBody ; Draw the body .leave ret PrintNextPage endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SignalPrintingPage %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Signal the SpoolPrintControl that we're printing a page. CALLED BY: PrintNextPage, PrintNotes PASS: ss:bp.GCPP_spc set ss:bp.GCPP_page = Page number RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 5/24/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SignalPrintingPage proc near uses ax, bx, cx, dx, si, di, bp .enter test ss:[bp].GCPP_sdp.SDP_printFlags, mask SPF_SKIP_DRAW jnz quit mov bx, ss:[bp].GCPP_pc.handle mov si, ss:[bp].GCPP_pc.chunk mov cx, PCPT_PAGE ; PCProgressType => CX mov dx, ss:[bp].GCPP_page ; page number => DX mov ax, MSG_PRINT_CONTROL_REPORT_PROGRESS mov di, mask MF_CALL call ObjMessage ; Tell user we're printing a page quit: .leave ret SignalPrintingPage endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DrawHeader %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Draw the header... CALLED BY: PrintNextPage PASS: ^lbx:si = Spreadsheet object ss:bp = GeoCalcPrintParams RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 4/26/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ HDR_FTR_FLAGS_TO_CLEAR = not (mask SPF_PRINT_GRID or \ mask SPF_SCALE_TO_FIT or \ mask SPF_PRINT_ROW_COLUMN_TITLES or \ mask SPF_CENTER_VERTICALLY or \ mask SPF_CENTER_HORIZONTALLY) DrawHeader proc near uses ax, cx, dx, di .enter mov ax, mask SPF_PRINT_HEADER ; Check for header OK mov cx, HDR_FTR_FLAGS_TO_CLEAR ; Flags to clear before draw lea dx, ss:[bp].GCPP_headerArea ; Area/Range to draw lea di, ss:[bp].GCPP_headerRange ; Top/left call DrawSpreadsheetRange ; Draw it .leave ret DrawHeader endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DrawFooter %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Draw the footer... CALLED BY: PrintNextPage PASS: ^lbx:si = Spreadsheet object ss:bp = GeoCalcPrintParams RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 4/26/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DrawFooter proc near uses ax, cx, dx, di .enter mov ax, mask SPF_PRINT_FOOTER ; Check for footer OK mov cx, HDR_FTR_FLAGS_TO_CLEAR ; Flags to clear before draw lea dx, ss:[bp].GCPP_footerArea ; Area/Range to draw lea di, ss:[bp].GCPP_footerRange ; Top/left call DrawSpreadsheetRange ; Draw it .leave ret DrawFooter endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DrawBody %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Draw the body... CALLED BY: PrintNextPage PASS: ^lbx:si = Spreadsheet instance ss:bp = GeoCalcPrintParams RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 4/26/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ BODY_FLAGS_TO_CLEAR = not (mask SPF_PRINT_HEADER or \ mask SPF_PRINT_FOOTER) DrawBody proc near uses ax, cx, dx, di .enter ; ; Setup and draw the area. ; mov ax, -1 ; Always draw mov cx, BODY_FLAGS_TO_CLEAR lea dx, ss:[bp].GCPP_bodyArea ; Area/Range to draw lea di, ss:[bp].GCPP_topLeft ; Top/left call DrawSpreadsheetRange ; Draw it ; ; Save the top-left that was returned. ; mov ax, ss:[bp].GCPP_sdp.SDP_topLeft.CR_column mov ss:[bp].GCPP_topLeft.CR_column, ax mov ax, ss:[bp].GCPP_sdp.SDP_topLeft.CR_row mov ss:[bp].GCPP_topLeft.CR_row, ax .leave ret DrawBody endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DrawSpreadsheetRange %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Draw a range of the spreadsheet CALLED BY: DrawHeader, DrawFooter PASS: ^lbx:si = Spreadsheet instance ss:bp = GeoCalcPrintParams ax = Flag to check to decide if we want to draw = -1 to ALWAYS draw cx = Flags to preserve before drawing (ie. !cleared) ss:dx = Pointer to combination of stuff to draw: Area (RectDWord) Range (CellRange) ss:di = Pointer to top/left top copy RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: if ax != -1 then if flags & ax == 0 then quit endif endif Copy area and rectangle Copy top-left Save flags Clear flags Draw the range Restore flags KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 5/ 6/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DrawSpreadsheetRange proc near uses ax, cx, dx, di, es .enter ; ; Check the flags to see if we want to draw anything at all. ; cmp ax, -1 ; Check for always draw je drawRange test ss:[bp].GCPP_sdp.SDP_printFlags, ax LONG jz quit ; Branch if we don't want to drawRange: ; ; We want to draw. ; ^lbx:si = Instance ptr ; ss:bp = GeoCalcPrintParams ; cx = Flags to clear (zero if none) ; ss:dx = Pointer to Area/CellRange to copy ; ss:di = Pointer to top/left CellReference ; push cx, ds, si ; Save flags and instance ptr ; ; Copy the area to draw to and the range to draw. ; push di ; Save pointer to top/left segmov ds, ss, si ; ds:si <- ptr to source mov si, dx segmov es, ss, di ; es:di <- ptr to dest lea di, ss:[bp].GCPP_sdp.SDP_drawArea mov cx, (size RectDWord + size CellRange)/(size word) rep movsw ; Copy the area and limit pop si ; ds:si <- source of top/left ; ; Copy the top/left point to use. ; lea di, ss:[bp].GCPP_sdp.SDP_topLeft ; es:di <- ptr to top/left mov cx, (size CellReference)/(size word) rep movsw ; Copy me jesus pop cx, ds, si ; Restore flags and instance ptr ; ; Make sure there's something to draw... ; cmp ss:[bp].GCPP_sdp.SDP_topLeft.CR_row, -1 je quit ; ; Clear flags, saving any if need be. ; push ss:[bp].GCPP_sdp.SDP_printFlags ; Save the old flags andnf ss:[bp].GCPP_sdp.SDP_printFlags, cx ; Clear the flags ; ; If we're printing graphics but not printing the spreadsheet, ; tell spreadsheet to skip the draw but still return stuff ; test ss:[bp].GCPP_sdp.SDP_printFlags, mask SPF_PRINT_DOCUMENT jnz doPrint ;branch if printing normally test ss:[bp].GCPP_sdp.SDP_printFlags, mask SPF_PRINT_GRAPHICS jz skipPrint ;branch if no graphics or ssheet ornf ss:[bp].GCPP_sdp.SDP_printFlags, mask SPF_SKIP_DRAW doPrint: ; ; Draw the area: ; Area, Range, flags are all set ; On stack: ; Old flags, if we cleared any bits ; ^lbx:si= Spreadsheet instance ; ss:bp = GeoCalcPrintParams ; CheckHack <(offset GCPP_sdp) eq 0> push cx, bp ; Save flags to clear, frame mov ax, MSG_SPREADSHEET_DRAW_RANGE mov di, mask MF_CALL call ObjMessage pop cx, bp ; Restore flags to clear, frame ; ; We can't just restore the flags, we need to preserve the "done" flag ; skipPrint: mov ax, ss:[bp].GCPP_sdp.SDP_printFlags ; ax <- current flag pop ss:[bp].GCPP_sdp.SDP_printFlags ; Pop flags andnf ax, mask SPF_DONE ; ax <- done flag ornf ss:[bp].GCPP_sdp.SDP_printFlags, ax ; ; If we're drawing graphics, tell the GrObj to draw something, too ; call DrawGraphicsLayer quit: .leave ret DrawSpreadsheetRange endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CopyDocRect %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Copy one document rectangle to another CALLED BY: Utility PASS: ss:si = Source RectDWord ss:di = Dest RectDWord RETURN: Dest <- Source DESTROYED: di, si PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 4/29/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ CopyDocRect proc near uses cx, ds, es .enter segmov es, ss, cx ; es:di <- dest mov ds, cx ; ds:si <- source mov cx, size RectDWord ; cx <- size rep movsb ; Copy the rectangle .leave ret CopyDocRect endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GetHeaderHeight %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get the height of the header CALLED BY: SetPageToRange PASS: ^lbx:si = OD of spreadsheet object ss:bp = GeoCalcPrintParams RETURN: dx:ax = Height of the header DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 4/29/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GetHeaderHeight proc near uses cx, bp .enter mov ax, ss:[bp].GCPP_headerRange.CR_start.CR_row mov cx, ss:[bp].GCPP_headerRange.CR_start.CR_column mov dx, ss:[bp].GCPP_headerRange.CR_end.CR_row mov bp, ss:[bp].GCPP_headerRange.CR_end.CR_column call GetRangeHeight ; ax <- height of the range .leave ret GetHeaderHeight endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GetRangeHeight %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get the height of a range CALLED BY: GetHeaderHeight, GetFooterHeight PASS: ax/cx = Row/Column of top-left of the range dx/bp = Row/Column of bottom-right of the range ^lbx:si = OD of spreadsheet object RETURN: dx:ax = Height of the range DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 5/ 6/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GetRangeHeight proc near uses cx, bp, di .enter ; ; ax/cx = Row/Column of top-left of spreadsheet ; dx/bp = Row/Column of bottom-right of spreadsheet ; cmp ax, -1 ; Check for no header je noHeader ; Branch if none ; ; The header exists. We need to get the extent... ; push bp, dx, cx, ax ; Push CellRange mov dx, ss mov bp, sp ; dx:bp <- ptr to the CellRange sub sp, size RectDWord ; Make space for result mov cx, sp ; dx:cx <- ptr to RectDWord push cx ; Save ptr to the result mov ax, MSG_SPREADSHEET_GET_RANGE_BOUNDS mov di, mask MF_CALL call ObjMessage pop bp ; ss:bp <- ptr to the result mov ax, ss:[bp].RD_bottom.low sub ax, ss:[bp].RD_top.low mov dx, ss:[bp].RD_bottom.high sbb dx, ss:[bp].RD_top.high ; ; Fixup the stack before leaving. ; add sp, size RectDWord + size CellRange quit: .leave ret noHeader: clr ax, dx ; No header height jmp quit GetRangeHeight endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% GetFooterHeight %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Get the height of the footer CALLED BY: SetPageToRange PASS: ^lbx:si = OD of spreadsheet object ss:bp = GeoCalcPrintParams RETURN: dx:ax = Height of the footer DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 4/29/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ GetFooterHeight proc near uses cx, bp .enter mov ax, ss:[bp].GCPP_footerRange.CR_start.CR_row mov cx, ss:[bp].GCPP_footerRange.CR_start.CR_column mov dx, ss:[bp].GCPP_footerRange.CR_end.CR_row mov bp, ss:[bp].GCPP_footerRange.CR_end.CR_column call GetRangeHeight ; ax <- height of the range .leave ret GetFooterHeight endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PrintNotes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Print the notes associated with a document CALLED BY: GeoCalcDocumentStartPrinting() PASS: ^lcx:dx = OD of SpoolPrintControl object ^lbx:si = OD of Spreadsheet ss:bp = GeoCalcPrintParams RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: nOnThisPage = 0 SpreadsheetRangeEnum(): if (row/column is in bodyRange) then if (nOnThisPage == 0) then SignalPrintingPage() DrawHeader() endif if (nOnThisPage == 0 or note fits) then DrawNote() nOnThisPage++ else DrawFooter() GrNewPage() nOnThisPage = 0 endif endif KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 5/24/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ PrintNotes proc near uses ax, cx, dx, di .enter test ss:[bp].GCPP_sdp.SDP_printFlags, mask SPF_PRINT_NOTES jz quit ; Quit if not printing notes ; ; Set the page size to be the paper size. Set the document size ; to the the paper size minus margins. Refigure the header, footer, ; and body areas. ; call SetNotePageAndDocSize ; Set the page/doc size ; ; Initialize GCPP_notePos for the first note. ; mov ax, ss:[bp].GCPP_bodyArea.RD_top.low mov ss:[bp].GCPP_notePos, ax ; ; Set up the parameters for MSG_SPREADSHEET_RANGE_ENUM_DATA. ; push bp ; Save frame ptr mov cx, SEGMENT_CS ; cx:dx <- callback routine mov dx, offset cs:PrintNotesCallback mov ax, MSG_SPREADSHEET_NOTES_ENUM mov di, mask MF_CALL ; Call spreadsheet to do enum call ObjMessage pop bp ; Restore frame ptr ; ; See if we ended right on the end of a page. ; mov ax, ss:[bp].GCPP_notePos cmp ax, ss:[bp].GCPP_bodyArea.RD_top.low je quit ; Branch if we finished a page ; ; We didn't stop right at the end of a page. Draw the missing footer. ; call DrawFooter ; Otherwise draw the footer inc ss:[bp].GCPP_page ; Next page to draw inc ss:currentPage ; Do a new page at the end of every notes page. mov di, ss:[bp].GCPP_sdp.SDP_gstate ; di <- gstate handle mov al, PEC_FORM_FEED call GrNewPage ; Draw a new page quit: .leave ret PrintNotes endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SetNotePageAndDocSize %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Set the page and document size for printing notes. CALLED BY: PrintNotes PASS: ^lcx:dx = SpoolPrintControl object ^lbx:si = Spreadsheet object ss:bp = GeoCalcPrintParams RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: Set the page size to the paper size Set the document size Recalc the header/footer area Recalc the body area KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 5/24/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ SetNotePageAndDocSize proc near ; ; Clear the scale-to-fit and continuous printing flags. ; andnf ss:[bp].GCPP_sdp.SDP_printFlags, not (mask SPF_SCALE_TO_FIT or \ mask SPF_CONTINUOUS) call FigureAreas ; Compute the areas... ret SetNotePageAndDocSize endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PrintNotesCallback %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Callback for printing notes. CALLED BY: PrintNotes via MSG_SPREADSHEET_NOTES_ENUM PASS: ss:bp = Pointer to GeoCalcPrintParams ax = Row of cell cx = Column of cell *es:di = Pointer to notes text ^ldx:si = Spreadsheet object RETURN: carry set to abort enum DESTROYED: dx PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 5/24/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ; ; Number of points of padding to place between each note. ; NOTE_PADDING = 4 PrintNotesCallback proc far uses ax, bx, di, bp .enter mov bx, dx ; ^lbx:si <- Spreadsheet OD ; ; Copy the text into the text object. ; call CopyNoteIntoTextObject ; ; Position the note on the page. ; call PositionNote ; ; Check for first note on the page (y pos = body-area top) ; mov dx, ss:[bp].GCPP_bodyArea.RD_top.low cmp dx, ss:[bp].GCPP_notePos jne notFirstNote ; Branch if not at top ; ; We're at the start of a new page... ; call SignalPrintingPage ; Signal we're drawing another if (0) ; We now do new page at the end of the page. We did a new page at the ; end of the last document page. So we don't need to do it before the ; first note page. - Joon (6/21/95) ; ; There's a little work to do here. There are several ways we can get ; here and we need to distinguish between them: ; 1) We have finished drawing the document and are drawing notes ; 2) We didn't draw a document and this is the first note page ; 3) We didn't draw a document and this is not the first note page ; ; In (1) and (3) we want to generate a form-feed with GrNewPage(). ; In (2) we don't want to generate the form-feed. ; ; We actually only need to check the page number. Anything other than ; "1" and we want to generate the form-feed. ; cmp ss:[bp].GCPP_page, 1 ; Check for first page je skipNewPage ; Branch if first page push ax, di ; Save cell ptr mov di, ss:[bp].GCPP_sdp.SDP_gstate ; di <- gstate handle mov al, PEC_FORM_FEED call GrNewPage ; Draw a new page pop ax, di ; Restore cell ptr skipNewPage: endif ; if (0) call DrawHeader ; Draw the header call CheckNoteFits ; Force calculation of height jmp drawANote ; Branch to draw first note notFirstNote: ; ; Not the first note, make sure it fits. ; call CheckNoteFits ; Check for note fitting jc endOfPage ; Branch if it doesn't drawANote: ; ; The note fits or is the first note on the page. ; ; dx = position for next note. ; test ss:[bp].GCPP_sdp.SDP_printFlags, mask SPF_SKIP_DRAW jnz skipDraw ; branch if calculating call DrawOneNote ; Draw the note skipDraw: add dx, NOTE_PADDING mov ss:[bp].GCPP_notePos, dx ; Set position for next object quit: clc ; Process next cell... .leave ret endOfPage: ; ; We've reached the last note that can fit on the page. ; call DrawFooter ; Draw the footer mov ax, ss:[bp].GCPP_bodyArea.RD_top.low mov ss:[bp].GCPP_notePos, ax ; Initialize the next note pos inc ss:[bp].GCPP_page ; Change page number inc ss:currentPage ; Change page number here too ; Do a new page at the end of every notes page. mov di, ss:[bp].GCPP_sdp.SDP_gstate ; di <- gstate handle mov al, PEC_FORM_FEED call GrNewPage ; Draw a new page jmp quit ; Branch, we're done PrintNotesCallback endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CopyNoteIntoTextObject %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Copy the text of the note into the text object. CALLED BY: PrintNotesCallback PASS: ^lbx:si = Spreadsheet object *es:di = Text of the note ax = Row cx = Column RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: Format the string "Cell RR:CC\t" into the text object. Append the text of the note. KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 5/24/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ CopyNoteIntoTextObject proc near uses ax, bx, cx, dx, di, si, bp .enter mov dx, es ; dx:bp <- ptr to the text mov bp, es:[di] clr cx ; It's null terminated GetResourceHandleNS PrintTextObject, bx mov si, offset PrintTextObject mov ax, MSG_VIS_TEXT_REPLACE_ALL_PTR mov di, mask MF_CALL call ObjMessage .leave ret CopyNoteIntoTextObject endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PositionNote %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Position the note on the page. CALLED BY: PrintNotesCallback PASS: ss:bp = Pointer to GeoCalcPrintParams RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 5/24/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ ; ; The notes are inset on the page to allow room for a string of the form ; "XX:#####" which is the cell whose note we are printing. ; ; A bit of testing has shown that 1 inch is enough space for this given ; the font and pointsize we're using. ; NOTES_TEXT_MARGIN = 54 PositionNote proc near uses ax, bx, cx, dx, di, si, bp .enter ; ; Now move the object to the right spot. ; GetResourceHandleNS PrintTextObject, bx mov si, offset PrintTextObject mov cx, ss:[bp].GCPP_bodyArea.RD_left.low add cx, ss:[bp].GCPP_sdp.SDP_margins.P_x add cx, NOTES_TEXT_MARGIN mov dx, ss:[bp].GCPP_notePos add dx, ss:[bp].GCPP_sdp.SDP_margins.P_y mov ax, MSG_VIS_SET_POSITION mov di, mask MF_CALL call ObjMessage .leave ret PositionNote endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CheckNoteFits %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Check to see if a note will fit between the notePos and the bottom of the body area. CALLED BY: PrintNotesCallback PASS: *es:di = Pointer to the cell data ss:bp = GeoCalcPrintParams ds:si = Spreadsheet instance RETURN: carry set if the note doesn't fit dx = Position for next note DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 5/24/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ CheckNoteFits proc near uses ax, bx, cx, di, si .enter ; ; cx <- width of object ; dx <- Flag to say "force calculation" ; mov cx, ss:[bp].GCPP_bodyArea.RD_right.low sub cx, ss:[bp].GCPP_bodyArea.RD_left.low sub cx, NOTES_TEXT_MARGIN GetResourceHandleNS PrintTextObject, bx mov si, offset PrintTextObject ; ^lbx:si <- text object push bp ; Save frame ptr push cx ; Save width clr dx mov ax, MSG_VIS_TEXT_CALC_HEIGHT mov di, mask MF_CALL call ObjMessage ; dx <- height of text pop cx ; Restore width ; ; cx = Width for text object ; dx = Height for text object ; push dx ; Save height mov ax, MSG_VIS_SET_SIZE mov di, mask MF_CALL call ObjMessage ; Resize the text object mov ax, MSG_VIS_NOTIFY_GEOMETRY_VALID mov di, mask MF_CALL call ObjMessage ; Geometry has changed... pop dx ; Restore height pop bp ; Restore frame ptr add dx, ss:[bp].GCPP_notePos ; dx <- bottom of note cmp dx, ss:[bp].GCPP_bodyArea.RD_bottom.low ja doesNotFit clc ; Signal: note fits quit: .leave ret doesNotFit: stc ; Signal: doesn't fit jmp quit CheckNoteFits endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DrawOneNote %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Draw a single note CALLED BY: PrintNotesCallback PASS: ss:bp = GeoCalcPrintParams ^lbx:si = Spreadsheet instance ax = Row of the cell cx = Column of the cell RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jcw 5/24/91 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DrawOneNote proc near class SpreadsheetClass uses ax, bx, cx, dx, di, si, bp, ds, es .enter ; ; Allocate a stack frame and call the spreadsheet object to format ; the cell. ; sub sp, MAX_RANGE_REF_SIZE mov di, sp segmov es, ss ;es:di <- ptr to buffer call ParserFormatCellReference mov bx, di ; ; ss:bx = formatted text ; ss:bp = GeoCalcPrintParams ; mov di, ss:[bp].GCPP_sdp.SDP_gstate ; di <- gstate handle mov cx, NOTES_FONT ; cx <- font mov dx, NOTES_PTSIZE ; dx.ah <- size clr ah call GrSetFont mov al, mask TS_UNDERLINE ; Set underline mov ah, TextStyle ; Clear everything else call GrSetTextStyle ; ; Now draw the text for the cell reference ; ; ss:bx = formatted text ; ss:bp = GeoCalcPrintParams ; di = GState handle (gstate is already set up) ; segmov ds, ss, si ; ds <- segment addr of the text lea si, ss:[bx].SFPRP_text ; si <- offset of the text mov ax, ss:[bp].GCPP_bodyArea.RD_left.low add ax, ss:[bp].GCPP_sdp.SDP_margins.P_x mov bx, ss:[bp].GCPP_notePos ; ax/bx <- position for draw add bx, ss:[bp].GCPP_sdp.SDP_margins.P_y clr cx ; cx <- NULL terminated text call GrDrawText ; ; Now draw the text object which contains the note. ; mov bp, di ; bp <- gstate for drawing GetResourceHandleNS PrintTextObject, bx mov si, offset PrintTextObject mov cl, mask DF_EXPOSED or mask DF_PRINT mov ax, MSG_VIS_DRAW mov di, mask MF_CALL call ObjMessage ; ; Restore stack frame before leaving. ; add sp, MAX_RANGE_REF_SIZE .leave ret DrawOneNote endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% DrawGraphicsLayer %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Draw the graphics layer for GeoCalc, if requested CALLED BY: DrawSpreadsheetRange() PASS: ss:bp - GeoCalcPrintParams RETURN: none DESTROYED: ax, cx, dx, di PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- gene 1/12/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ DrawGraphicsLayer proc near uses bx, si .enter CheckHack <(offset GCPP_sdp) eq 0> ; ; Should we bother? If we aren't printing graphics, or if we ; aren't actually drawing (ie. just calculating the number of ; pages), then exit ; test ss:[bp].GCPP_sdp.SDP_printFlags, mask SPF_PRINT_GRAPHICS LONG jz quit ;branch if not drawing graphics test ss:[bp].GCPP_sdp.SDP_printFlags, mask SPF_SKIP_DRAW LONG jnz quit ;branch if not printing ; ; Translate and scale to match what the spreadsheet did ; for centering and scale-to-fit. ; mov di, ss:[bp].SDP_gstate ;di <- handle of GState call GrSaveState movdw dxcx, ss:[bp].SDP_translation.PD_x movdw bxax, ss:[bp].SDP_translation.PD_y call GrApplyTranslationDWord movwwf dxcx, ss:[bp].SDP_scale movwwf bxax, dxcx call GrApplyScale ; ; Translate for any titles ; movdw dxcx, ss:[bp].SDP_titleTrans.PD_x movdw bxax, ss:[bp].SDP_titleTrans.PD_y call GrApplyTranslationDWord ; ; Since we're translating to the area printed, our clip ; rectangle goes from (0,0) now. ; movdw bxcx, ss:[bp].SDP_rangeArea.RD_right subdw bxcx, ss:[bp].SDP_rangeArea.RD_left jnz noClip ;branch if too large movdw axdx, ss:[bp].SDP_rangeArea.RD_bottom subdw axdx, ss:[bp].SDP_rangeArea.RD_top jnz noClip ;branch if too large ; ; If we're going scale-to-fit or continous printing, there's ; a decent chance that the area to clip to will be larger ; than the graphics system can handle. If this is the case, ; we simply punt on clipping. ; cmp cx, MAX_COORD/5 ;x too large? jae noClip ;branch if too large cmp dx, MAX_COORD/5 ;y too large? jae noClip ;branch if too large clr ax, bx ;(ax,bx,cx,dx) <- Rectangle mov si, PCT_REPLACE call GrSetClipRect noClip: ; ; Translate to the actual area that was printed ; movdw dxcx, ss:[bp].SDP_rangeArea.RD_left movdw bxax, ss:[bp].SDP_rangeArea.RD_top negdw dxcx negdw bxax call GrApplyTranslationDWord ; ; Tell yon grobj to draw itself ; push bp, di mov ax, MSG_VIS_DRAW movdw bxsi, ss:[bp].GCPP_grobj ;^lbx:si <- OD of grobj mov bp, di ;bp <- handle of GState mov cl, mask DF_PRINT ;cl <- DrawFlags mov di, mask MF_CALL or mask MF_FIXUP_DS call ObjMessage pop bp, di ; ; Clean up ; call GrRestoreState quit: .leave ret DrawGraphicsLayer endp DocumentPrint ends
; A157736: a(n) = 388962*n^2 - 347508*n + 77617. ; 119071,938449,2535751,4910977,8064127,11995201,16704199,22191121,28455967,35498737,43319431,51918049,61294591,71449057,82381447,94091761,106579999,119846161,133890247,148712257,164312191,180690049,197845831,215779537,234491167,253980721,274248199,295293601,317116927,339718177,363097351,387254449,412189471,437902417,464393287,491662081,519708799,548533441,578136007,608516497,639674911,671611249,704325511,737817697,772087807,807135841,842961799,879565681,916947487,955107217,994044871,1033760449 seq $0,157735 ; 18522n - 8274. pow $0,2 sub $0,105021504 div $0,777924 mul $0,882 add $0,119071
; CALLER LINKAGE FOR FUNCTION POINTERS SECTION code_clib PUBLIC vz_brick PUBLIC _vz_brick EXTERN asm_vz_brick .vz_brick ._vz_brick pop hl pop bc pop de push de push bc push hl jp asm_vz_brick
%define BE(a) ( ((((a)>>24)&0xFF) << 0) + ((((a)>>16)&0xFF) << 8) + ((((a)>>8)&0xFF) << 16) + ((((a)>>0)&0xFF) << 24)) ftyp_start: dd BE(ftyp_end - ftyp_start) dd "ftyp" db 0x6D, 0x69, 0x66, 0x31 ; major_brand(32) ('mif1') db 0x00, 0x00, 0x00, 0x00 ; minor_version(32) db 0x6D, 0x69, 0x66, 0x31 ; compatible_brand(32) ('mif1') db 0x61, 0x76, 0x63, 0x69 ; compatible_brand(32) ('avci') db 0x6D, 0x69, 0x61, 0x66 ; compatible_brand(32) ('miaf') ftyp_end: meta_start: dd BE(meta_end - meta_start) dd "meta" db 0x00 ; version(8) db 0x00, 0x00, 0x00 ; flags(24) hdlr_start: dd BE(hdlr_end - hdlr_start) dd "hdlr" db 0x00 ; version(8) db 0x00, 0x00, 0x00 ; flags(24) db 0x00, 0x00, 0x00, 0x00 ; pre_defined(32) db 0x70, 0x69, 0x63, 0x74 ; handler_type(32) ('pict') db 0x00, 0x00, 0x00, 0x00 ; reserved1(32) db 0x00, 0x00, 0x00, 0x00 ; reserved2(32) db 0x00, 0x00, 0x00, 0x00 ; reserved3(32) db 0x47 ; name(8) ('G') db 0x50 ; name(8) ('P') db 0x41 ; name(8) ('A') db 0x43 ; name(8) ('C') db 0x20 ; name(8) (' ') db 0x70 ; name(8) ('p') db 0x69 ; name(8) ('i') db 0x63 ; name(8) ('c') db 0x74 ; name(8) ('t') db 0x20 ; name(8) (' ') db 0x48 ; name(8) ('H') db 0x61 ; name(8) ('a') db 0x6E ; name(8) ('n') db 0x64 ; name(8) ('d') db 0x6C ; name(8) ('l') db 0x65 ; name(8) ('e') db 0x72 ; name(8) ('r') db 0x00 ; name(8) hdlr_end: pitm_start: dd BE(pitm_end - pitm_start) dd "pitm" db 0x00 ; version(8) db 0x00, 0x00, 0x00 ; flags(24) db 0x00, 0x01 ; item_ID(16) pitm_end: iloc_start: dd BE(iloc_end - iloc_start) dd "iloc" db 0x00 ; version(8) db 0x00, 0x00, 0x00 ; flags(24) db 0x04 ; offset_size(4) length_size(4) db 0x40 ; base_offset_size(4) ('@') reserved1(4) ('@') db 0x00, 0x07 ; item_count(16) db 0x00, 0x01 ; item_ID(16) db 0x00, 0x00 ; data_reference_index(16) dd BE(mdat1_start - ftyp_start + 8) ; base_offset(32) db 0x00, 0x01 ; extent_count(16) ; extent_offset(0) db 0x00, 0x00, 0x00, 0x08 ; extent_length(32) db 0x00, 0x02 ; item_ID(16) db 0x00, 0x00 ; data_reference_index(16) dd BE(mdat2_start - ftyp_start + 8) ; base_offset(32) db 0x00, 0x01 ; extent_count(16) ; extent_offset(0) db 0x00, 0x00, 0x00, 0x0A ; extent_length(32) db 0x00, 0x03 ; item_ID(16) db 0x00, 0x00 ; data_reference_index(16) dd BE(mdat2_start - ftyp_start + 8) ; base_offset(32) db 0x00, 0x01 ; extent_count(16) ; extent_offset(0) db 0x00, 0x00, 0x00, 0x0A ; extent_length(32) db 0x00, 0x04 ; item_ID(16) db 0x00, 0x00 ; data_reference_index(16) dd BE(mdat2_start - ftyp_start + 8) ; base_offset(32) db 0x00, 0x01 ; extent_count(16) ; extent_offset(0) db 0x00, 0x00, 0x00, 0x0A ; extent_length(32) db 0x00, 0x05 ; item_ID(16) db 0x00, 0x00 ; data_reference_index(16) dd BE(mdat2_start - ftyp_start + 8) ; base_offset(32) db 0x00, 0x01 ; extent_count(16) ; extent_offset(0) db 0x00, 0x00, 0x00, 0x0A ; extent_length(32) db 0x00, 0x06 ; item_ID(16) db 0x00, 0x00 ; data_reference_index(16) dd BE(mdat2_start - ftyp_start + 8) ; base_offset(32) db 0x00, 0x01 ; extent_count(16) ; extent_offset(0) db 0x00, 0x00, 0x00, 0x0A ; extent_length(32) db 0x00, 0x07 ; item_ID(16) db 0x00, 0x00 ; data_reference_index(16) dd BE(mdat2_start - ftyp_start + 8) ; base_offset(32) db 0x00, 0x01 ; extent_count(16) ; extent_offset(0) db 0x00, 0x00, 0x00, 0x0A ; extent_length(32) iloc_end: iinf_start: dd BE(iinf_end - iinf_start) dd "iinf" db 0x00 ; version(8) db 0x00, 0x00, 0x00 ; flags(24) db 0x00, 0x07 ; entry_count(16) infe_start: dd BE(infe_end - infe_start) dd "infe" db 0x02 ; version(8) db 0x00, 0x00, 0x00 ; flags(24) db 0x00, 0x01 ; item_ID(16) db 0x00, 0x00 ; item_protection_index(16) db 0x67, 0x72, 0x69, 0x64 ; item_type(32) ('grid') db 0x00 ; item_name(8) infe_end: infe2_start: dd BE(infe2_end - infe2_start) dd "infe" db 0x02 ; version(8) db 0x00, 0x00, 0x00 ; flags(24) db 0x00, 0x02 ; item_ID(16) db 0x00, 0x00 ; item_protection_index(16) db 0x61, 0x76, 0x30, 0x31 ; item_type(32) ('av01') db 0x49 ; item_name(8) ('I') db 0x6D ; item_name(8) ('m') db 0x61 ; item_name(8) ('a') db 0x67 ; item_name(8) ('g') db 0x65 ; item_name(8) ('e') db 0x00 ; item_name(8) infe2_end: infe3_start: dd BE(infe3_end - infe3_start) dd "infe" db 0x02 ; version(8) db 0x00, 0x00, 0x00 ; flags(24) db 0x00, 0x03 ; item_ID(16) db 0x00, 0x00 ; item_protection_index(16) db 0x61, 0x76, 0x30, 0x31 ; item_type(32) ('av01') db 0x49 ; item_name(8) ('I') db 0x6D ; item_name(8) ('m') db 0x61 ; item_name(8) ('a') db 0x67 ; item_name(8) ('g') db 0x65 ; item_name(8) ('e') db 0x00 ; item_name(8) infe3_end: infe4_start: dd BE(infe4_end - infe4_start) dd "infe" db 0x02 ; version(8) db 0x00, 0x00, 0x00 ; flags(24) db 0x00, 0x04 ; item_ID(16) db 0x00, 0x00 ; item_protection_index(16) db 0x61, 0x76, 0x30, 0x31 ; item_type(32) ('av01') db 0x49 ; item_name(8) ('I') db 0x6D ; item_name(8) ('m') db 0x61 ; item_name(8) ('a') db 0x67 ; item_name(8) ('g') db 0x65 ; item_name(8) ('e') db 0x00 ; item_name(8) infe4_end: infe5_start: dd BE(infe5_end - infe5_start) dd "infe" db 0x02 ; version(8) db 0x00, 0x00, 0x00 ; flags(24) db 0x00, 0x05 ; item_ID(16) db 0x00, 0x00 ; item_protection_index(16) db 0x61, 0x76, 0x30, 0x31 ; item_type(32) ('av01') db 0x49 ; item_name(8) ('I') db 0x6D ; item_name(8) ('m') db 0x61 ; item_name(8) ('a') db 0x67 ; item_name(8) ('g') db 0x65 ; item_name(8) ('e') db 0x00 ; item_name(8) infe5_end: infe6_start: dd BE(infe6_end - infe6_start) dd "infe" db 0x02 ; version(8) db 0x00, 0x00, 0x00 ; flags(24) db 0x00, 0x06 ; item_ID(16) db 0x00, 0x00 ; item_protection_index(16) db 0x61, 0x76, 0x30, 0x31 ; item_type(32) ('av01') db 0x49 ; item_name(8) ('I') db 0x6D ; item_name(8) ('m') db 0x61 ; item_name(8) ('a') db 0x67 ; item_name(8) ('g') db 0x65 ; item_name(8) ('e') db 0x00 ; item_name(8) infe6_end: infe7_start: dd BE(infe7_end - infe7_start) dd "infe" db 0x02 ; version(8) db 0x00, 0x00, 0x00 ; flags(24) db 0x00, 0x07 ; item_ID(16) db 0x00, 0x00 ; item_protection_index(16) db 0x61, 0x76, 0x30, 0x31 ; item_type(32) ('av01') db 0x49 ; item_name(8) ('I') db 0x6D ; item_name(8) ('m') db 0x61 ; item_name(8) ('a') db 0x67 ; item_name(8) ('g') db 0x65 ; item_name(8) ('e') db 0x00 ; item_name(8) infe7_end: iinf_end: iref_start: dd BE(iref_end - iref_start) dd "iref" db 0x00 ; version(8) db 0x00, 0x00, 0x00 ; flags(24) db 0x00, 0x00, 0x00, 0x18 ; box_size(32) db 0x64, 0x69, 0x6D, 0x67 ; box_type(32) ('dimg') db 0x00, 0x01 ; from_item_ID(16) db 0x00, 0x06 ; reference_count(16) db 0x00, 0x02 ; to_item_ID(16) db 0x00, 0x03 ; to_item_ID(16) db 0x00, 0x04 ; to_item_ID(16) db 0x00, 0x05 ; to_item_ID(16) db 0x00, 0x06 ; to_item_ID(16) db 0x00, 0x07 ; to_item_ID(16) iref_end: iprp_start: dd BE(iprp_end - iprp_start) dd "iprp" ipco_start: dd BE(ipco_end - ipco_start) dd "ipco" ispe_start: dd BE(ispe_end - ispe_start) dd "ispe" db 0x00 ; version(8) db 0x00, 0x00, 0x00 ; flags(24) db 0x00, 0x00, 0x00, 0xC0 ; image_width(32) db 0x00, 0x00, 0x00, 0x80 ; image_height(32) ispe_end: clap_start: dd BE(clap_end - clap_start) dd "clap" db 0x00, 0x00, 0x00, 0x80 ; cleanApertureWidthN(32) db 0x00, 0x00, 0x00, 0x01 ; cleanApertureWidthD(32) db 0x00, 0x00, 0x00, 0x20 ; cleanApertureHeightN(32) db 0x00, 0x00, 0x00, 0x01 ; cleanApertureHeightD(32) db 0x00, 0x00, 0x00, 0x00 ; horizOffN(32) db 0x00, 0x00, 0x00, 0x01 ; horizOffD(32) db 0x00, 0x00, 0x00, 0x00 ; vertOffN(32) db 0x00, 0x00, 0x00, 0x01 ; vertOffD(32) clap_end: ispe2_start: dd BE(ispe2_end - ispe2_start) dd "ispe" db 0x00 ; version(8) db 0x00, 0x00, 0x00 ; flags(24) db 0x00, 0x00, 0x00, 0x40 ; image_width(32) db 0x00, 0x00, 0x00, 0x40 ; image_height(32) ispe2_end: pasp_start: dd BE(pasp_end - pasp_start) dd "pasp" db 0x00, 0x00, 0x00, 0x01 ; hSpacing(32) db 0x00, 0x00, 0x00, 0x01 ; vSpacing(32) pasp_end: av1C_start: dd BE(av1C_end - av1C_start) dd "av1C" db 0x81 ; marker(1) version(7) db 0x20 ; seq_profile(3) (' ') seq_level_idx_0(5) (' ') db 0x00 ; seq_tier_0(1) high_bitdepth(1) twelve_bit(1) monochrome(1) chroma_subsampling_x(1) chroma_subsampling_y(1) chroma_sample_position(2) db 0x00 ; reserved(3) initial_presentation_delay_present(1) reserved(4) ; configOBUs(0) av1C_end: pixi_start: dd BE(pixi_end - pixi_start) dd "pixi" db 0x00 ; (8) db 0x00 ; (8) db 0x00 ; (8) db 0x00 ; (8) db 0x03 ; (8) db 0x08 ; (8) db 0x08 ; (8) db 0x08 ; (8) pixi_end: ipco_end: ipma_start: dd BE(ipma_end - ipma_start) dd "ipma" db 0x00 ; version(8) db 0x00, 0x00, 0x00 ; flags(24) db 0x00, 0x00, 0x00, 0x07 ; entry_count(32) db 0x00, 0x01 ; item_ID(16) db 0x02 ; association_count(8) db 0x01 ; essential(1) property_index(7) db 0x86 ; essential(1) property_index(7) db 0x00, 0x02 ; item_ID(16) db 0x05 ; association_count(8) db 0x82 ; essential(1) property_index(7) db 0x03 ; essential(1) property_index(7) db 0x04 ; essential(1) property_index(7) db 0x85 ; essential(1) property_index(7) db 0x86 ; essential(1) property_index(7) db 0x00, 0x03 ; item_ID(16) db 0x05 ; association_count(8) db 0x82 ; essential(1) property_index(7) db 0x03 ; essential(1) property_index(7) db 0x04 ; essential(1) property_index(7) db 0x85 ; essential(1) property_index(7) db 0x86 ; essential(1) property_index(7) db 0x00, 0x04 ; item_ID(16) db 0x05 ; association_count(8) db 0x82 ; essential(1) property_index(7) db 0x03 ; essential(1) property_index(7) db 0x04 ; essential(1) property_index(7) db 0x85 ; essential(1) property_index(7) db 0x86 ; essential(1) property_index(7) db 0x00, 0x05 ; item_ID(16) db 0x05 ; association_count(8) db 0x82 ; essential(1) property_index(7) db 0x03 ; essential(1) property_index(7) db 0x04 ; essential(1) property_index(7) db 0x85 ; essential(1) property_index(7) db 0x86 ; essential(1) property_index(7) db 0x00, 0x06 ; item_ID(16) db 0x05 ; association_count(8) db 0x82 ; essential(1) property_index(7) db 0x03 ; essential(1) property_index(7) db 0x04 ; essential(1) property_index(7) db 0x85 ; essential(1) property_index(7) db 0x86 ; essential(1) property_index(7) db 0x00, 0x07 ; item_ID(16) db 0x05 ; association_count(8) db 0x82 ; essential(1) property_index(7) db 0x03 ; essential(1) property_index(7) db 0x04 ; essential(1) property_index(7) db 0x85 ; essential(1) property_index(7) db 0x86 ; essential(1) property_index(7) ipma_end: iprp_end: meta_end: free_start: dd BE(free_end - free_start) dd "free" db 0x49 ; (8) ('I') db 0x73 ; (8) ('s') db 0x6F ; (8) ('o') db 0x4D ; (8) ('M') db 0x65 ; (8) ('e') db 0x64 ; (8) ('d') db 0x69 ; (8) ('i') db 0x61 ; (8) ('a') db 0x20 ; (8) (' ') db 0x46 ; (8) ('F') db 0x69 ; (8) ('i') db 0x6C ; (8) ('l') db 0x65 ; (8) ('e') db 0x20 ; (8) (' ') db 0x50 ; (8) ('P') db 0x72 ; (8) ('r') db 0x6F ; (8) ('o') db 0x64 ; (8) ('d') db 0x75 ; (8) ('u') db 0x63 ; (8) ('c') db 0x65 ; (8) ('e') db 0x64 ; (8) ('d') db 0x20 ; (8) (' ') db 0x77 ; (8) ('w') db 0x69 ; (8) ('i') db 0x74 ; (8) ('t') db 0x68 ; (8) ('h') db 0x20 ; (8) (' ') db 0x47 ; (8) ('G') db 0x50 ; (8) ('P') db 0x41 ; (8) ('A') db 0x43 ; (8) ('C') db 0x20 ; (8) (' ') db 0x31 ; (8) ('1') db 0x2E ; (8) ('.') db 0x31 ; (8) ('1') db 0x2E ; (8) ('.') db 0x30 ; (8) ('0') db 0x2D ; (8) ('-') db 0x44 ; (8) ('D') db 0x45 ; (8) ('E') db 0x56 ; (8) ('V') db 0x2D ; (8) ('-') db 0x72 ; (8) ('r') db 0x65 ; (8) ('e') db 0x76 ; (8) ('v') db 0x33 ; (8) ('3') db 0x31 ; (8) ('1') db 0x34 ; (8) ('4') db 0x2D ; (8) ('-') db 0x67 ; (8) ('g') db 0x65 ; (8) ('e') db 0x62 ; (8) ('b') db 0x34 ; (8) ('4') db 0x31 ; (8) ('1') db 0x64 ; (8) ('d') db 0x32 ; (8) ('2') db 0x61 ; (8) ('a') db 0x32 ; (8) ('2') db 0x35 ; (8) ('5') db 0x2D ; (8) ('-') db 0x69 ; (8) ('i') db 0x6D ; (8) ('m') db 0x61 ; (8) ('a') db 0x67 ; (8) ('g') db 0x65 ; (8) ('e') db 0x5F ; (8) ('_') db 0x6F ; (8) ('o') db 0x76 ; (8) ('v') db 0x65 ; (8) ('e') db 0x72 ; (8) ('r') db 0x6C ; (8) ('l') db 0x61 ; (8) ('a') db 0x79 ; (8) ('y') db 0x00 ; (8) free_end: ; dimg mdat1_start: dd BE(mdat1_end - mdat1_start) dd "mdat" db 0x00 ; derivation version db 0x00 ; dimg flags db 0x01 ; dimg rows_minus_one db 0x02 ; dimg columns_minus_one db 0x00, 0x00 ; dimg output_width db 0x00, 0x00 ; dimg output_height mdat1_end: ; av1 mdat2_start: dd BE(mdat2_end - mdat2_start) dd "mdat" db 0x0A ; (8) 0000 1010 db 0x06 ; (8) db 0x38 ; (8) 0011 1000 db 0x1D ; (8) 0001 1101 db 0xF0 ; (8) 1111 0000 db 0x20 ; (8) 0010 0000 db 0x00 ; (8) 0000 0000 db 0x20 ; (8) 0010 ;0 color config db 0x32 ; (8) ('2') ; sync frame db 0x00 ; (8) mdat2_end: ; vim: syntax=nasm
; Assembly for testdata-bytecode.bas ; compiled with mcbasic ; Equates for MC-10 MICROCOLOR BASIC 1.0 ; ; Direct page equates DP_LNUM .equ $E2 ; current line in BASIC DP_TABW .equ $E4 ; current tab width on console DP_LPOS .equ $E6 ; current line position on console DP_LWID .equ $E7 ; current line width of console ; ; Memory equates M_KBUF .equ $4231 ; keystrobe buffer (8 bytes) M_PMSK .equ $423C ; pixel mask for SET, RESET and POINT M_IKEY .equ $427F ; key code for INKEY$ M_CRSR .equ $4280 ; cursor location M_LBUF .equ $42B2 ; line input buffer (130 chars) M_MSTR .equ $4334 ; buffer for small string moves M_CODE .equ $4346 ; start of program space ; ; ROM equates R_BKMSG .equ $E1C1 ; 'BREAK' string location R_ERROR .equ $E238 ; generate error and restore direct mode R_BREAK .equ $E266 ; generate break and restore direct mode R_RESET .equ $E3EE ; setup stack and disable CONT R_SPACE .equ $E7B9 ; emit " " to console R_QUEST .equ $E7BC ; emit "?" to console R_REDO .equ $E7C1 ; emit "?REDO" to console R_EXTRA .equ $E8AB ; emit "?EXTRA IGNORED" to console R_DMODE .equ $F7AA ; display OK prompt and restore direct mode R_KPOLL .equ $F879 ; if key is down, do KEYIN, else set Z CCR flag R_KEYIN .equ $F883 ; poll key for key-down transition set Z otherwise R_PUTC .equ $F9C9 ; write ACCA to console R_MKTAB .equ $FA7B ; setup tabs for console R_GETLN .equ $FAA4 ; get line, returning with X pointing to M_BUF-1 R_SETPX .equ $FB44 ; write pixel character to X R_CLRPX .equ $FB59 ; clear pixel character in X R_MSKPX .equ $FB7C ; get pixel screen location X and mask in R_PMSK R_CLSN .equ $FBC4 ; clear screen with color code in ACCB R_CLS .equ $FBD4 ; clear screen with space character R_SOUND .equ $FFAB ; play sound with pitch in ACCA and duration in ACCB R_MCXID .equ $FFDA ; ID location for MCX BASIC ; direct page registers .org $80 strtcnt .block 1 strbuf .block 2 strend .block 2 strfree .block 2 strstop .block 2 dataptr .block 2 inptptr .block 2 redoptr .block 2 letptr .block 2 .org $a3 r1 .block 5 rend rvseed .block 2 curinst .block 2 nxtinst .block 2 tmp1 .block 2 tmp2 .block 2 tmp3 .block 2 tmp4 .block 2 tmp5 .block 2 argv .block 10 .org M_CODE .module mdmain ldx #program stx nxtinst mainloop ldx nxtinst stx curinst ldab ,x ldx #catalog abx abx ldx ,x jsr 0,x bra mainloop program .byte bytecode_progbegin .byte bytecode_clear LINE_10 LLAST ; END .byte bytecode_progend ; Library Catalog bytecode_clear .equ 0 bytecode_progbegin .equ 1 bytecode_progend .equ 2 catalog .word clear .word progbegin .word progend .module mdbcode noargs ldx curinst inx stx nxtinst rts extend ldx curinst inx ldab ,x inx stx nxtinst ldx #symtbl abx abx ldx ,x rts getaddr ldd curinst addd #3 std nxtinst ldx curinst ldx 1,x rts getbyte ldx curinst inx ldab ,x inx stx nxtinst rts getword ldx curinst inx ldd ,x inx inx stx nxtinst rts extbyte ldd curinst addd #3 std nxtinst ldx curinst ldab 2,x pshb ldab 1,x ldx #symtbl abx abx ldx ,x pulb rts extword ldd curinst addd #4 std nxtinst ldx curinst ldd 2,x pshb ldab 1,x ldx #symtbl abx abx ldx ,x pulb rts byteext ldd curinst addd #3 std nxtinst ldx curinst ldab 1,x pshb ldab 2,x ldx #symtbl abx abx ldx ,x pulb rts wordext ldd curinst addd #4 std nxtinst ldx curinst ldd 1,x pshb ldab 3,x ldx #symtbl abx abx ldx ,x pulb rts immstr ldx curinst inx ldab ,x inx pshx abx stx nxtinst pulx rts .module mdprint print _loop ldaa ,x jsr R_PUTC inx decb bne _loop rts clear ; numCalls = 1 .module modclear jsr noargs clra ldx #bss bra _start _again staa ,x inx _start cpx #bes bne _again stx strbuf stx strend inx inx stx strfree ldx #$8FFF stx strstop ldx #startdata stx dataptr rts progbegin ; numCalls = 1 .module modprogbegin jsr noargs ldx R_MCXID cpx #'h'*256+'C' bne _mcbasic pulx clrb pshb pshb pshb stab strtcnt jmp ,x _reqmsg .text "?MICROCOLOR BASIC ROM REQUIRED" _mcbasic ldx #_reqmsg ldab #30 jsr print pulx rts progend ; numCalls = 1 .module modprogend jsr noargs pulx pula pula pula jsr R_RESET jmp R_DMODE NF_ERROR .equ 0 RG_ERROR .equ 4 OD_ERROR .equ 6 FC_ERROR .equ 8 OV_ERROR .equ 10 OM_ERROR .equ 12 BS_ERROR .equ 16 DD_ERROR .equ 18 LS_ERROR .equ 28 error jmp R_ERROR ; data table startdata .byte $00, $00, $02, $4c, $cd ; 2.3 .byte $00, $00, $04, $b3, $33 ; 4.7 .byte $00, $00, $2c, $00, $00 ; 44 .byte $ff, $ff, $e0, $cc, $cd ; -31.2 enddata ; Bytecode symbol lookup table symtbl ; block started by symbol bss ; Numeric Variables ; String Variables ; Numeric Arrays ; String Arrays ; block ended by symbol bes .end
CGASpade8 label byte word C_BLACK Bitmap <67,41,BMC_PACKBITS,BMF_MONO> db 0xf8, 0x00 db 0xf8, 0x00 db 0x08, 0x0f, 0xe0, 0x02, 0x00, 0x00, 0x08, 0x00, 0x10, 0x00 db 0x08, 0x18, 0x30, 0x0f, 0x80, 0x00, 0x3e, 0x00, 0x7c, 0x00 db 0x08, 0x18, 0x30, 0x3f, 0xe0, 0x00, 0xff, 0x80, 0xfe, 0x00 db 0x08, 0x0f, 0xe0, 0xff, 0xf8, 0x03, 0xff, 0xe1, 0xff, 0x00 db 0x08, 0x18, 0x31, 0xff, 0xfc, 0x07, 0xff, 0xf1, 0xff, 0x00 db 0x08, 0x18, 0x31, 0xff, 0xfc, 0x07, 0xff, 0xf0, 0xd6, 0x00 db 0x08, 0x0f, 0xe0, 0xf7, 0x78, 0x03, 0xdd, 0xe0, 0x38, 0x00 db 0x05, 0x00, 0x00, 0x0f, 0x80, 0x40, 0x3e, 0xfe, 0x00 db 0xfe, 0x00, 0x01, 0x01, 0xf0, 0xfd, 0x00 db 0xfe, 0x00, 0x01, 0x07, 0xfc, 0xfd, 0x00 db 0xfe, 0x00, 0x01, 0x1f, 0xff, 0xfd, 0x00 db 0xfe, 0x00, 0x02, 0x3f, 0xff, 0x80, 0xfe, 0x00 db 0xfe, 0x00, 0x02, 0x3f, 0xff, 0x80, 0xfe, 0x00 db 0xfe, 0x00, 0x01, 0x1e, 0xef, 0xfd, 0x00 db 0x05, 0x00, 0x00, 0x02, 0x01, 0xf0, 0x08, 0xfe, 0x00 db 0x05, 0x00, 0x00, 0x0f, 0x80, 0x00, 0x3e, 0xfe, 0x00 db 0x08, 0x00, 0x00, 0x3f, 0xe0, 0x00, 0xff, 0x80, 0x00, 0x00 db 0x08, 0x00, 0x00, 0xff, 0xf8, 0x03, 0xff, 0xe0, 0x00, 0x00 db 0x08, 0x00, 0x01, 0xff, 0xfc, 0x07, 0xff, 0xf0, 0x00, 0x00 db 0x08, 0x00, 0x01, 0xff, 0xfc, 0x07, 0xff, 0xf0, 0x00, 0x00 db 0x08, 0x00, 0x00, 0xf7, 0x78, 0x03, 0xdd, 0xe0, 0x00, 0x00 db 0x05, 0x00, 0x00, 0x0f, 0x80, 0x00, 0x3e, 0xfe, 0x00 db 0xfe, 0x00, 0x01, 0x01, 0xf0, 0xfd, 0x00 db 0xfe, 0x00, 0x01, 0x1e, 0xef, 0xfd, 0x00 db 0xfe, 0x00, 0x02, 0x3f, 0xff, 0x80, 0xfe, 0x00 db 0xfe, 0x00, 0x02, 0x3f, 0xff, 0x80, 0xfe, 0x00 db 0xfe, 0x00, 0x01, 0x1f, 0xff, 0xfd, 0x00 db 0xfe, 0x00, 0x01, 0x07, 0xfc, 0xfd, 0x00 db 0xfe, 0x00, 0x01, 0x01, 0xf0, 0xfd, 0x00 db 0x05, 0x00, 0x00, 0x0f, 0x80, 0x40, 0x3e, 0xfe, 0x00 db 0x08, 0x03, 0x80, 0xf7, 0x78, 0x03, 0xdd, 0xe0, 0xfe, 0x00 db 0x08, 0x0d, 0x61, 0xff, 0xfc, 0x07, 0xff, 0xf1, 0x83, 0x00 db 0x08, 0x1f, 0xf1, 0xff, 0xfc, 0x07, 0xff, 0xf1, 0x83, 0x00 db 0x08, 0x1f, 0xf0, 0xff, 0xf8, 0x03, 0xff, 0xe0, 0xfe, 0x00 db 0x08, 0x0f, 0xe0, 0x3f, 0xe0, 0x00, 0xff, 0x81, 0x83, 0x00 db 0x08, 0x07, 0xc0, 0x0f, 0x80, 0x00, 0x3e, 0x01, 0x83, 0x00 db 0x08, 0x01, 0x00, 0x02, 0x00, 0x00, 0x08, 0x00, 0xfe, 0x00 db 0xf8, 0x00 db 0xf8, 0x00
; ************************************************************************************************ ; ************************************************************************************************ ; ; Name: x16io.asm ; Purpose: Input/Output x16 ; Created: 28th February 2021 ; Reviewed: 7th March 2021 ; Author: Paul Robson (paul@robsons.org.uk) ; ; ************************************************************************************************ ; ************************************************************************************************ MaxLineInputSize = 240 .section storage bufferCount: ; chars in buffer .fill 0 bufferStorage: ; input buffer. .fill MaxLineInputSize nextSyncTick: ; time of next sync tick, if zero not initialised. .fill 0 .send storage .section code ; ************************************************************************************************ ; ; Control Handler ; ; ************************************************************************************************ IOControlHandler: ;; <controlhandler> cmp #0 bne _CHExit lda #15 ; switch to upper/lower case mode jsr IOPrintChar lda #2 ; green on black and clear screen jsr IOInk lda #0 sta nextSyncTick jsr IOPaper jsr IOClearScreen _CHExit: rts ; ************************************************************************************************ ; ; Clear Screen/Home Cursor ; ; ************************************************************************************************ IOClearScreen: ;; <clear> pha lda #147 ; char code $93 clears screen jsr IOPrintChar pla rts ; ************************************************************************************************ ; ; Print CR/LF ; ; ************************************************************************************************ IONewLine: ;; <crlf> pha lda #13 jsr IOPrintChar pla rts ; ************************************************************************************************ ; ; Print Tab ; ; ************************************************************************************************ IOTab: ;; <tab> pha lda #32 jsr IOPrintChar pla rts ; ************************************************************************************************ ; ; Print A (ASCII for listing, errors) ; ; ************************************************************************************************ IOPrintAscii: ;; <printascii> ; ************************************************************************************************ ; ; Print A ; ; ************************************************************************************************ IOPrintChar: ;; <print> tax ; save in X so we can save Y .pshy txa cmp #8 ; make BS (8) onto CHR$(14) which is the bne _IOPCNotBS ; Commodore/X16 backspace code. lda #$14 _IOPCNotBS: jsr KNLPrintChar ; CBM OS Call. .puly rts ; ************************************************************************************************ ; ; Check key is pressed/in kbd buffer, returns key if so 0 otherwise ; Only keys outside 32..127 are 0 (no key) 8 (backspace) 13 (return) ; (INKEY) ; ; ************************************************************************************************ IOInkey: ;; <inkey> .pshy ; read key with XY protected jsr KNLCheckKeyboarBuffer sta tempShort .puly lda tempShort ; no key pressed. beq _IOIExit cmp #13 ; allow CR (13) beq _IOIExit cmp #$14 ; backspace code ($14) returns 8. beq _IOIBackspace cmp #32 ; no other control allowed. bcc IOInkey bcs _IOIExit _IOIBackspace: lda #8 ; return chr(8) _IOIExit: rts ; ************************************************************************************************ ; ; Set Ink Colour (BBC Micro colour scheme) ; ; ************************************************************************************************ IOInk: ;; <ink> pha and #7 ; 8 primaries tax lda _IOColourTable,x ; look up CBM code and print it. jsr IOPrintChar pla rts _IOColourTable: .byte $90 ; 0 Black .byte $96 ; 1 Red .byte $1E ; 2 Green .byte $9E ; 3 Yellow .byte $9A ; 4 Blue .byte $9C ; 5 Magenta .byte $9F ; 6 Cyan .byte $05 ; 7 White ; ************************************************************************************************ ; ; Set Paper Colour (BBC Micro colour scheme) ; ; ************************************************************************************************ IOPaper: ;; <paper> pha pha lda #1 ; 1 swaps fgr/bgr, so we swap them, set fgr jsr IOPrintChar ; and then swap them again. pla jsr IOInk lda #1 jsr IOPrintChar pla rts ; ************************************************************************************************* ; ; Set Cursor to (A,Y) ; ; ************************************************************************************************ IOLocate: ;; <locate> pha lda #$13 ; home cursor code jsr IOPrintChar lda #$11 ; print Y x $11 (down) jsr _IOLoc2 .puly ; horizontal pos in A now lda #$1D ; print Y x $1D (right) _IOLoc2: cpy #0 beq _IOLocExit jsr IOPrintChar dey bne _IOLoc2 _IOLocExit: rts ; ************************************************************************************************* ; ; Input Line, return buffer pointer in temp0 ; ; ************************************************************************************************* IOInput: ;; <inputline> lda #0 sta bufferCount _IOILoop: jsr KNLInputLine cmp #13 beq _IOIExit ldx bufferCount cpx #MaxLineInputSize beq _IOILoop inc bufferCount sta bufferStorage+1,x jmp _IOILoop _IOIExit: set16 temp0,bufferCount rts .send code ; ************************************************************************************************ ; ; Changes and Updates ; ; ************************************************************************************************ ; ; Date Notes ; ==== ===== ; 07-Mar-21 Pre code read v0.01 ; ; ************************************************************************************************
<% from pwnlib.shellcraft import common %> <% from socket import htons %> <%page args="port=None"/> <%docstring> Args: port (defaults to any port) Finds a socket, which is connected to the specified port. Leaves socket in ESI. </%docstring> <% findpeer = common.label("findpeer") looplabel = common.label("loop") %> ${findpeer}: push -1 push SYS_socketcall_getpeername mov ebp, esp pop ebx pop esi ${looplabel}: push SYS_socketcall pop eax inc esi lea ecx, [esp-32] push 4 pushad int 0x80 % if port == None: test eax, eax popad pop edx jnz ${looplabel} % else: popad pop edx shr eax, 16 cmp ax, ${htons(int(port))} jne ${looplabel} %endif
.include "myTiny13.h" ; this program counts decimal two 7seg-display from 99 to 00 !!! ; in counts every 0,10009 second ;irq Vector .org 0x0000 rjmp OnReset .org 0x0003 rjmp TimerOVF .org 0x0010 TimerOVF: ; Countdown on every overflow push B ; 2 clocks dec A ; 1 clock ldi B,50 ; B=255-205: prescale makes counter half full -> overflow ca every 1/10 sec ; ldi B,128 ; B=128: prescale makes counter half full -> overflow every 1/16 sec out TCNT0,B pop B reti .org 0x0030 OnReset: ;initial values ; X8421 if X=1 then 10er Digit is on! ldi A,0b00011111 out DDRB,A ldi A,0b00000010 ; timer auf clock/8 e.g. on 16kHz: tick every 1/2048 sec -> overflow every 1/8 sec out TCCR0B,A ldi A,0b00000010 ; enable timer-overfl IRQ out TIMSK0,A sei ; IRQ allow ldi A,0x99 out PORTB,A MainLoop: rcall Ato2digi rjmp MainLoop ;subroutine show A on the 2 7seg Display ++++++++++++++++++++++ Ato2digi: push B push C Doit: mov B,A ; B := A cpi B,0xFF ; 255 -1 ? breq SetFull mov C,B ; load "decimal" into C LSR C LSR C LSR C LSR C ; C := C/16 -> move 10er Digit to 1er Digit push C sbr C,0b00010000 ; 10er = set bit4 out PORTB,C pop C LSL C LSL C LSL C LSL C ; C := C*16 -> lost the 1er potence! sub B,C cpi B,0xF breq SetNo0F cbr B,0b00010000 ; 1er = clear bit4 out PORTB,B pop C pop B ret SetNo0F: subi A,6 ; BCD code to make hex to decimal rjmp Doit SetFull: ldi A,0x99 rjmp Doit
object_const_def ; object_event constants const PLAYERSHOUSE2F_CONSOLE const PLAYERSHOUSE2F_DOLL_1 const PLAYERSHOUSE2F_DOLL_2 const PLAYERSHOUSE2F_BIG_DOLL PlayersHouse2F_MapScripts: db 0 ; scene scripts db 2 ; callbacks callback MAPCALLBACK_NEWMAP, .InitializeRoom callback MAPCALLBACK_TILES, .SetSpawn ; unused .Null: end .InitializeRoom: special ToggleDecorationsVisibility setevent EVENT_TEMPORARY_UNTIL_MAP_RELOAD_8 return .SetSpawn: special ToggleMaptileDecorations return db 0, 0, 0 ; filler Doll1Script: describedecoration DECODESC_LEFT_DOLL Doll2Script: describedecoration DECODESC_RIGHT_DOLL BigDollScript: describedecoration DECODESC_BIG_DOLL GameConsoleScript: describedecoration DECODESC_CONSOLE PlayersHousePosterScript: conditional_event EVENT_PLAYERS_ROOM_POSTER, .Script .Script: describedecoration DECODESC_POSTER PlayersHouseRadioScript: checkevent EVENT_GOT_A_POKEMON_FROM_ELM iftrue .NormalRadio checkevent EVENT_LISTENED_TO_INITIAL_RADIO iftrue .AbbreviatedRadio playmusic MUSIC_POKEMON_TALK opentext writetext PlayersRadioText1 pause 45 writetext PlayersRadioText2 pause 45 writetext PlayersRadioText3 pause 45 musicfadeout MUSIC_NEW_BARK_TOWN, 16 writetext PlayersRadioText4 pause 45 closetext setevent EVENT_LISTENED_TO_INITIAL_RADIO end .NormalRadio: jumpstd radio1 .AbbreviatedRadio: opentext writetext PlayersRadioText4 pause 45 closetext end PlayersHouseBookshelfScript: jumpstd picturebookshelf PlayersHousePCScript: opentext special PlayersHousePC iftrue .Warp closetext end .Warp: warp NONE, 0, 0 end PlayersRadioText1: text "PROF.OAK'S #MON" line "TALK! Please tune" cont "in next time!" done PlayersRadioText2: text "#MON CHANNEL!" done PlayersRadioText3: text "This is DJ MARY," line "your co-host!" done PlayersRadioText4: text "#MON!" line "#MON CHANNEL…" done PlayersHouse2F_MapEvents: db 0, 0 ; filler db 1 ; warp events warp_event 7, 0, PLAYERS_HOUSE_1F, 3 db 0 ; coord events db 4 ; bg events bg_event 2, 1, BGEVENT_UP, PlayersHousePCScript bg_event 3, 1, BGEVENT_READ, PlayersHouseRadioScript bg_event 5, 1, BGEVENT_READ, PlayersHouseBookshelfScript bg_event 6, 0, BGEVENT_IFSET, PlayersHousePosterScript db 4 ; object events object_event 4, 2, SPRITE_CONSOLE, SPRITEMOVEDATA_STILL, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, GameConsoleScript, EVENT_PLAYERS_HOUSE_2F_CONSOLE object_event 4, 4, SPRITE_DOLL_1, SPRITEMOVEDATA_STILL, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, Doll1Script, EVENT_PLAYERS_HOUSE_2F_DOLL_1 object_event 5, 4, SPRITE_DOLL_2, SPRITEMOVEDATA_STILL, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, Doll2Script, EVENT_PLAYERS_HOUSE_2F_DOLL_2 object_event 0, 1, SPRITE_BIG_DOLL, SPRITEMOVEDATA_BIGDOLL, 0, 0, -1, -1, 0, OBJECTTYPE_SCRIPT, 0, BigDollScript, EVENT_PLAYERS_HOUSE_2F_BIG_DOLL
// Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "base/task/sequence_manager/work_queue_sets.h" #include <stddef.h> #include <memory> #include "base/bind.h" #include "base/memory/ptr_util.h" #include "base/task/sequence_manager/enqueue_order.h" #include "base/task/sequence_manager/fence.h" #include "base/task/sequence_manager/task_order.h" #include "base/task/sequence_manager/work_queue.h" #include "base/time/time.h" #include "testing/gmock/include/gmock/gmock.h" #include "third_party/abseil-cpp/absl/types/optional.h" namespace base { namespace sequence_manager { class TimeDomain; namespace internal { namespace { class MockObserver : public WorkQueueSets::Observer { MOCK_METHOD1(WorkQueueSetBecameEmpty, void(size_t set_index)); MOCK_METHOD1(WorkQueueSetBecameNonEmpty, void(size_t set_index)); }; } // namespace class WorkQueueSetsTest : public testing::Test { public: void SetUp() override { work_queue_sets_ = std::make_unique<WorkQueueSets>( "test", &mock_observer_, SequenceManager::Settings()); } void TearDown() override { for (std::unique_ptr<WorkQueue>& work_queue : work_queues_) { if (work_queue->work_queue_sets()) work_queue_sets_->RemoveQueue(work_queue.get()); } } protected: WorkQueue* NewTaskQueue( const char* queue_name, WorkQueue::QueueType queue_type = WorkQueue::QueueType::kImmediate) { WorkQueue* queue = new WorkQueue(nullptr, "test", queue_type); work_queues_.push_back(WrapUnique(queue)); work_queue_sets_->AddQueue(queue, TaskQueue::kControlPriority); return queue; } Task FakeTaskWithEnqueueOrder(int enqueue_order) { Task fake_task(PostedTask(nullptr, BindOnce([] {}), FROM_HERE), EnqueueOrder(), EnqueueOrder::FromIntForTesting(enqueue_order)); return fake_task; } Task FakeNonNestableTaskWithEnqueueOrder(int enqueue_order) { Task fake_task(PostedTask(nullptr, BindOnce([] {}), FROM_HERE), EnqueueOrder(), EnqueueOrder::FromIntForTesting(enqueue_order)); fake_task.nestable = Nestable::kNonNestable; return fake_task; } Task FakeTaskWithTaskOrder(TaskOrder task_order) { Task fake_task(PostedTask(nullptr, BindOnce([] {}), FROM_HERE, task_order.delayed_run_time(), subtle::DelayPolicy::kFlexibleNoSooner), EnqueueOrder::FromIntForTesting(task_order.sequence_num()), task_order.enqueue_order()); return fake_task; } WorkQueue* GetOldestQueueInSet(int set) const { if (auto queue_and_task_order = work_queue_sets_->GetOldestQueueAndTaskOrderInSet(set)) { return queue_and_task_order->queue; } return nullptr; } MockObserver mock_observer_; std::vector<std::unique_ptr<WorkQueue>> work_queues_; std::unique_ptr<WorkQueueSets> work_queue_sets_; }; TEST_F(WorkQueueSetsTest, ChangeSetIndex) { WorkQueue* work_queue = NewTaskQueue("queue"); size_t set = TaskQueue::kNormalPriority; work_queue_sets_->ChangeSetIndex(work_queue, set); EXPECT_EQ(set, work_queue->work_queue_set_index()); } TEST_F(WorkQueueSetsTest, GetOldestQueueAndTaskOrderInSet_QueueEmpty) { WorkQueue* work_queue = NewTaskQueue("queue"); size_t set = TaskQueue::kNormalPriority; work_queue_sets_->ChangeSetIndex(work_queue, set); EXPECT_FALSE(work_queue_sets_->GetOldestQueueAndTaskOrderInSet(set)); } TEST_F(WorkQueueSetsTest, OnTaskPushedToEmptyQueue) { WorkQueue* work_queue = NewTaskQueue("queue"); size_t set = TaskQueue::kNormalPriority; work_queue_sets_->ChangeSetIndex(work_queue, set); EXPECT_FALSE(work_queue_sets_->GetOldestQueueAndTaskOrderInSet(set)); // Calls OnTaskPushedToEmptyQueue. work_queue->Push(FakeTaskWithEnqueueOrder(10)); EXPECT_EQ(work_queue, GetOldestQueueInSet(set)); } TEST_F(WorkQueueSetsTest, GetOldestQueueAndTaskOrderInSet_SingleTaskInSet) { WorkQueue* work_queue = NewTaskQueue("queue"); work_queue->Push(FakeTaskWithEnqueueOrder(10)); size_t set = 1; work_queue_sets_->ChangeSetIndex(work_queue, set); EXPECT_EQ(work_queue, GetOldestQueueInSet(set)); } TEST_F(WorkQueueSetsTest, GetOldestQueueAndTaskOrderInSet_TaskOrder) { WorkQueue* work_queue = NewTaskQueue("queue"); work_queue->Push(FakeTaskWithEnqueueOrder(10)); size_t set = 1; work_queue_sets_->ChangeSetIndex(work_queue, set); absl::optional<WorkQueueAndTaskOrder> work_queue_and_task_order = work_queue_sets_->GetOldestQueueAndTaskOrderInSet(set); ASSERT_TRUE(work_queue_and_task_order); EXPECT_EQ(work_queue, work_queue_and_task_order->queue); EXPECT_EQ(10u, work_queue_and_task_order->order.enqueue_order()); } TEST_F(WorkQueueSetsTest, GetOldestQueueAndTaskOrderInSet_MultipleAgesInSet) { WorkQueue* queue1 = NewTaskQueue("queue1"); WorkQueue* queue2 = NewTaskQueue("queue2"); WorkQueue* queue3 = NewTaskQueue("queue2"); queue1->Push(FakeTaskWithEnqueueOrder(6)); queue2->Push(FakeTaskWithEnqueueOrder(5)); queue3->Push(FakeTaskWithEnqueueOrder(4)); size_t set = 2; work_queue_sets_->ChangeSetIndex(queue1, set); work_queue_sets_->ChangeSetIndex(queue2, set); work_queue_sets_->ChangeSetIndex(queue3, set); absl::optional<WorkQueueAndTaskOrder> queue_and_order = work_queue_sets_->GetOldestQueueAndTaskOrderInSet(set); ASSERT_TRUE(queue_and_order); EXPECT_EQ(queue3, queue_and_order->queue); EXPECT_EQ(EnqueueOrder::FromIntForTesting(4), queue_and_order->order.enqueue_order()); } TEST_F(WorkQueueSetsTest, OnQueuesFrontTaskChanged) { WorkQueue* queue1 = NewTaskQueue("queue1"); WorkQueue* queue2 = NewTaskQueue("queue2"); WorkQueue* queue3 = NewTaskQueue("queue3"); queue1->Push(FakeTaskWithEnqueueOrder(6)); queue2->Push(FakeTaskWithEnqueueOrder(5)); queue3->Push(FakeTaskWithEnqueueOrder(4)); size_t set = 4; work_queue_sets_->ChangeSetIndex(queue1, set); work_queue_sets_->ChangeSetIndex(queue2, set); work_queue_sets_->ChangeSetIndex(queue3, set); EXPECT_EQ(queue3, GetOldestQueueInSet(set)); // Make |queue1| now have a task with the lowest enqueue order. *const_cast<Task*>(queue1->GetFrontTask()) = FakeTaskWithEnqueueOrder(1); work_queue_sets_->OnQueuesFrontTaskChanged(queue1); EXPECT_EQ(queue1, GetOldestQueueInSet(set)); } TEST_F(WorkQueueSetsTest, OnQueuesFrontTaskChanged_OldestQueueBecomesEmpty) { WorkQueue* queue1 = NewTaskQueue("queue1"); WorkQueue* queue2 = NewTaskQueue("queue2"); WorkQueue* queue3 = NewTaskQueue("queue3"); queue1->Push(FakeTaskWithEnqueueOrder(6)); queue2->Push(FakeTaskWithEnqueueOrder(5)); queue3->Push(FakeTaskWithEnqueueOrder(4)); size_t set = 4; work_queue_sets_->ChangeSetIndex(queue1, set); work_queue_sets_->ChangeSetIndex(queue2, set); work_queue_sets_->ChangeSetIndex(queue3, set); EXPECT_EQ(queue3, GetOldestQueueInSet(set)); queue3->PopTaskForTesting(); work_queue_sets_->OnQueuesFrontTaskChanged(queue3); EXPECT_EQ(queue2, GetOldestQueueInSet(set)); } TEST_F(WorkQueueSetsTest, OnQueuesFrontTaskChanged_YoungestQueueBecomesEmpty) { WorkQueue* queue1 = NewTaskQueue("queue1"); WorkQueue* queue2 = NewTaskQueue("queue2"); WorkQueue* queue3 = NewTaskQueue("queue3"); queue1->Push(FakeTaskWithEnqueueOrder(6)); queue2->Push(FakeTaskWithEnqueueOrder(5)); queue3->Push(FakeTaskWithEnqueueOrder(4)); size_t set = 4; work_queue_sets_->ChangeSetIndex(queue1, set); work_queue_sets_->ChangeSetIndex(queue2, set); work_queue_sets_->ChangeSetIndex(queue3, set); EXPECT_EQ(queue3, GetOldestQueueInSet(set)); queue1->PopTaskForTesting(); work_queue_sets_->OnQueuesFrontTaskChanged(queue1); EXPECT_EQ(queue3, GetOldestQueueInSet(set)); } TEST_F(WorkQueueSetsTest, OnPopMinQueueInSet) { WorkQueue* queue1 = NewTaskQueue("queue1"); WorkQueue* queue2 = NewTaskQueue("queue2"); WorkQueue* queue3 = NewTaskQueue("queue3"); queue1->Push(FakeTaskWithEnqueueOrder(6)); queue2->Push(FakeTaskWithEnqueueOrder(1)); queue2->Push(FakeTaskWithEnqueueOrder(3)); queue3->Push(FakeTaskWithEnqueueOrder(4)); size_t set = 3; work_queue_sets_->ChangeSetIndex(queue1, set); work_queue_sets_->ChangeSetIndex(queue2, set); work_queue_sets_->ChangeSetIndex(queue3, set); EXPECT_EQ(queue2, GetOldestQueueInSet(set)); queue2->PopTaskForTesting(); work_queue_sets_->OnPopMinQueueInSet(queue2); EXPECT_EQ(queue2, GetOldestQueueInSet(set)); } TEST_F(WorkQueueSetsTest, OnPopMinQueueInSet_QueueBecomesEmpty) { WorkQueue* queue1 = NewTaskQueue("queue1"); WorkQueue* queue2 = NewTaskQueue("queue2"); WorkQueue* queue3 = NewTaskQueue("queue3"); queue1->Push(FakeTaskWithEnqueueOrder(6)); queue2->Push(FakeTaskWithEnqueueOrder(5)); queue3->Push(FakeTaskWithEnqueueOrder(4)); size_t set = 4; work_queue_sets_->ChangeSetIndex(queue1, set); work_queue_sets_->ChangeSetIndex(queue2, set); work_queue_sets_->ChangeSetIndex(queue3, set); EXPECT_EQ(queue3, GetOldestQueueInSet(set)); queue3->PopTaskForTesting(); work_queue_sets_->OnPopMinQueueInSet(queue3); EXPECT_EQ(queue2, GetOldestQueueInSet(set)); } TEST_F(WorkQueueSetsTest, GetOldestQueueAndTaskOrderInSet_MultipleAgesInSetIntegerRollover) { WorkQueue* queue1 = NewTaskQueue("queue1"); WorkQueue* queue2 = NewTaskQueue("queue2"); WorkQueue* queue3 = NewTaskQueue("queue3"); queue1->Push(FakeTaskWithEnqueueOrder(0x7ffffff1)); queue2->Push(FakeTaskWithEnqueueOrder(0x7ffffff0)); queue3->Push(FakeTaskWithEnqueueOrder(-0x7ffffff1)); size_t set = 1; work_queue_sets_->ChangeSetIndex(queue1, set); work_queue_sets_->ChangeSetIndex(queue2, set); work_queue_sets_->ChangeSetIndex(queue3, set); EXPECT_EQ(queue2, GetOldestQueueInSet(set)); } TEST_F(WorkQueueSetsTest, GetOldestQueueAndTaskOrderInSet_MultipleAgesInSet_RemoveQueue) { WorkQueue* queue1 = NewTaskQueue("queue1"); WorkQueue* queue2 = NewTaskQueue("queue2"); WorkQueue* queue3 = NewTaskQueue("queue3"); queue1->Push(FakeTaskWithEnqueueOrder(6)); queue2->Push(FakeTaskWithEnqueueOrder(5)); queue3->Push(FakeTaskWithEnqueueOrder(4)); size_t set = 1; work_queue_sets_->ChangeSetIndex(queue1, set); work_queue_sets_->ChangeSetIndex(queue2, set); work_queue_sets_->ChangeSetIndex(queue3, set); work_queue_sets_->RemoveQueue(queue3); EXPECT_EQ(queue2, GetOldestQueueInSet(set)); } TEST_F(WorkQueueSetsTest, ChangeSetIndex_Complex) { WorkQueue* queue1 = NewTaskQueue("queue1"); WorkQueue* queue2 = NewTaskQueue("queue2"); WorkQueue* queue3 = NewTaskQueue("queue3"); WorkQueue* queue4 = NewTaskQueue("queue4"); queue1->Push(FakeTaskWithEnqueueOrder(6)); queue2->Push(FakeTaskWithEnqueueOrder(5)); queue3->Push(FakeTaskWithEnqueueOrder(4)); queue4->Push(FakeTaskWithEnqueueOrder(3)); size_t set1 = 1; size_t set2 = 2; work_queue_sets_->ChangeSetIndex(queue1, set1); work_queue_sets_->ChangeSetIndex(queue2, set1); work_queue_sets_->ChangeSetIndex(queue3, set2); work_queue_sets_->ChangeSetIndex(queue4, set2); EXPECT_EQ(queue2, GetOldestQueueInSet(set1)); EXPECT_EQ(queue4, GetOldestQueueInSet(set2)); work_queue_sets_->ChangeSetIndex(queue4, set1); EXPECT_EQ(queue4, GetOldestQueueInSet(set1)); EXPECT_EQ(queue3, GetOldestQueueInSet(set2)); } TEST_F(WorkQueueSetsTest, IsSetEmpty_NoWork) { size_t set = 2; EXPECT_TRUE(work_queue_sets_->IsSetEmpty(set)); WorkQueue* work_queue = NewTaskQueue("queue"); work_queue_sets_->ChangeSetIndex(work_queue, set); EXPECT_TRUE(work_queue_sets_->IsSetEmpty(set)); } TEST_F(WorkQueueSetsTest, IsSetEmpty_Work) { size_t set = 2; EXPECT_TRUE(work_queue_sets_->IsSetEmpty(set)); WorkQueue* work_queue = NewTaskQueue("queue"); work_queue->Push(FakeTaskWithEnqueueOrder(1)); work_queue_sets_->ChangeSetIndex(work_queue, set); EXPECT_FALSE(work_queue_sets_->IsSetEmpty(set)); work_queue->PopTaskForTesting(); work_queue_sets_->OnPopMinQueueInSet(work_queue); EXPECT_TRUE(work_queue_sets_->IsSetEmpty(set)); } TEST_F(WorkQueueSetsTest, BlockQueuesByFence) { WorkQueue* queue1 = NewTaskQueue("queue1"); WorkQueue* queue2 = NewTaskQueue("queue2"); queue1->Push(FakeTaskWithEnqueueOrder(6)); queue2->Push(FakeTaskWithEnqueueOrder(7)); queue1->Push(FakeTaskWithEnqueueOrder(8)); queue2->Push(FakeTaskWithEnqueueOrder(9)); size_t set = TaskQueue::kControlPriority; EXPECT_EQ(queue1, GetOldestQueueInSet(set)); queue1->InsertFence(Fence::BlockingFence()); EXPECT_EQ(queue2, GetOldestQueueInSet(set)); } TEST_F(WorkQueueSetsTest, PushNonNestableTaskToFront) { WorkQueue* queue1 = NewTaskQueue("queue1"); WorkQueue* queue2 = NewTaskQueue("queue2"); WorkQueue* queue3 = NewTaskQueue("queue3"); queue1->Push(FakeTaskWithEnqueueOrder(6)); queue2->Push(FakeTaskWithEnqueueOrder(5)); queue3->Push(FakeTaskWithEnqueueOrder(4)); size_t set = 4; work_queue_sets_->ChangeSetIndex(queue1, set); work_queue_sets_->ChangeSetIndex(queue2, set); work_queue_sets_->ChangeSetIndex(queue3, set); EXPECT_EQ(queue3, GetOldestQueueInSet(set)); queue1->PushNonNestableTaskToFront(FakeNonNestableTaskWithEnqueueOrder(2)); EXPECT_EQ(queue1, GetOldestQueueInSet(set)); } TEST_F(WorkQueueSetsTest, CollectSkippedOverLowerPriorityTasks) { WorkQueue* queue1 = NewTaskQueue("queue1"); WorkQueue* queue2 = NewTaskQueue("queue2"); WorkQueue* queue3 = NewTaskQueue("queue3"); work_queue_sets_->ChangeSetIndex(queue1, 3); work_queue_sets_->ChangeSetIndex(queue2, 2); work_queue_sets_->ChangeSetIndex(queue3, 1); queue1->Push(FakeTaskWithEnqueueOrder(1)); queue1->Push(FakeTaskWithEnqueueOrder(2)); queue2->Push(FakeTaskWithEnqueueOrder(3)); queue3->Push(FakeTaskWithEnqueueOrder(4)); queue3->Push(FakeTaskWithEnqueueOrder(5)); queue2->Push(FakeTaskWithEnqueueOrder(6)); queue1->Push(FakeTaskWithEnqueueOrder(7)); std::vector<const Task*> result; work_queue_sets_->CollectSkippedOverLowerPriorityTasks(queue3, &result); ASSERT_EQ(3u, result.size()); EXPECT_EQ(3u, result[0]->enqueue_order()); // The order here isn't important. EXPECT_EQ(1u, result[1]->enqueue_order()); EXPECT_EQ(2u, result[2]->enqueue_order()); } TEST_F(WorkQueueSetsTest, CompareDelayedTasksWithSameEnqueueOrder) { constexpr int kNumQueues = 3; WorkQueue* queues[kNumQueues] = { NewTaskQueue("queue0", WorkQueue::QueueType::kDelayed), NewTaskQueue("queue1", WorkQueue::QueueType::kDelayed), NewTaskQueue("queue2", WorkQueue::QueueType::kDelayed), }; const EnqueueOrder kEnqueueOrder = EnqueueOrder::FromIntForTesting(5); TaskOrder task_orders[kNumQueues] = { TaskOrder::CreateForTesting(kEnqueueOrder, TimeTicks() + Seconds(1), /*sequence_num=*/4), TaskOrder::CreateForTesting(kEnqueueOrder, TimeTicks() + Seconds(2), /*sequence_num=*/3), TaskOrder::CreateForTesting(kEnqueueOrder, TimeTicks() + Seconds(3), /*sequence_num=*/2), }; constexpr size_t kSet = TaskQueue::kNormalPriority; for (int i = 0; i < kNumQueues; i++) { queues[i]->Push(FakeTaskWithTaskOrder(task_orders[i])); work_queue_sets_->ChangeSetIndex(queues[i], kSet); } for (auto* queue : queues) { EXPECT_EQ(queue, GetOldestQueueInSet(kSet)); queue->PopTaskForTesting(); work_queue_sets_->OnQueuesFrontTaskChanged(queue); } } TEST_F(WorkQueueSetsTest, CompareDelayedTasksWithSameEnqueueOrderAndRunTime) { constexpr int kNumQueues = 3; WorkQueue* queues[kNumQueues] = { NewTaskQueue("queue0", WorkQueue::QueueType::kDelayed), NewTaskQueue("queue1", WorkQueue::QueueType::kDelayed), NewTaskQueue("queue2", WorkQueue::QueueType::kDelayed), }; const EnqueueOrder kEnqueueOrder = EnqueueOrder::FromIntForTesting(5); constexpr TimeTicks delayed_run_time = TimeTicks() + Seconds(1); TaskOrder task_orders[kNumQueues] = { TaskOrder::CreateForTesting(kEnqueueOrder, delayed_run_time, /*sequence_num=*/2), TaskOrder::CreateForTesting(kEnqueueOrder, delayed_run_time, /*sequence_num=*/3), TaskOrder::CreateForTesting(kEnqueueOrder, delayed_run_time, /*sequence_num=*/4), }; constexpr size_t kSet = TaskQueue::kNormalPriority; for (int i = 0; i < kNumQueues; i++) { queues[i]->Push(FakeTaskWithTaskOrder(task_orders[i])); work_queue_sets_->ChangeSetIndex(queues[i], kSet); } for (auto* queue : queues) { EXPECT_EQ(queue, GetOldestQueueInSet(kSet)); queue->PopTaskForTesting(); work_queue_sets_->OnQueuesFrontTaskChanged(queue); } } TEST_F(WorkQueueSetsTest, CompareDelayedAndImmediateTasks) { constexpr int kNumQueues = 5; WorkQueue* queues[kNumQueues] = { NewTaskQueue("queue0", WorkQueue::QueueType::kImmediate), NewTaskQueue("queue1", WorkQueue::QueueType::kDelayed), NewTaskQueue("queue2", WorkQueue::QueueType::kDelayed), NewTaskQueue("queue3", WorkQueue::QueueType::kDelayed), NewTaskQueue("queue4", WorkQueue::QueueType::kImmediate), }; // TaskOrders in increasing order. TaskOrder task_orders[kNumQueues] = { // Immediate. TaskOrder::CreateForTesting(EnqueueOrder::FromIntForTesting(10), TimeTicks(), /*sequence_num=*/6), // Delayed. TaskOrder::CreateForTesting(EnqueueOrder::FromIntForTesting(11), TimeTicks() + Seconds(1), /*sequence_num=*/5), // Delayed, with the same enqueue order as the previous task. TaskOrder::CreateForTesting(EnqueueOrder::FromIntForTesting(11), TimeTicks() + Seconds(2), /*sequence_num=*/4), // Delayed, with the same delayed run time as the previous task but queued // in a subsequent wake-up. TaskOrder::CreateForTesting(EnqueueOrder::FromIntForTesting(12), TimeTicks() + Seconds(2), /*sequence_num=*/3), // Immediate. TaskOrder::CreateForTesting(EnqueueOrder::FromIntForTesting(13), TimeTicks(), /*sequence_num=*/2), }; constexpr size_t kSet = TaskQueue::kNormalPriority; for (int i = kNumQueues - 1; i >= 0; i--) { queues[i]->Push(FakeTaskWithTaskOrder(task_orders[i])); work_queue_sets_->ChangeSetIndex(queues[i], kSet); } for (auto* queue : queues) { EXPECT_EQ(queue, GetOldestQueueInSet(kSet)); queue->PopTaskForTesting(); work_queue_sets_->OnQueuesFrontTaskChanged(queue); } } } // namespace internal } // namespace sequence_manager } // namespace base
; A081272: Downward vertical of triangular spiral in A051682. ; 1,25,85,181,313,481,685,925,1201,1513,1861,2245,2665,3121,3613,4141,4705,5305,5941,6613,7321,8065,8845,9661,10513,11401,12325,13285,14281,15313,16381,17485,18625,19801,21013,22261,23545,24865,26221,27613,29041,30505,32005,33541,35113,36721,38365,40045,41761,43513,45301,47125,48985,50881,52813,54781,56785,58825,60901,63013,65161,67345,69565,71821,74113,76441,78805,81205,83641,86113,88621,91165,93745,96361,99013,101701,104425,107185,109981,112813,115681,118585,121525,124501,127513,130561,133645,136765,139921,143113,146341,149605,152905,156241,159613,163021,166465,169945,173461,177013,180601,184225,187885,191581,195313,199081,202885,206725,210601,214513,218461,222445,226465,230521,234613,238741,242905,247105,251341,255613,259921,264265,268645,273061,277513,282001,286525,291085,295681,300313,304981,309685,314425,319201,324013,328861,333745,338665,343621,348613,353641,358705,363805,368941,374113,379321,384565,389845,395161,400513,405901,411325,416785,422281,427813,433381,438985,444625,450301,456013,461761,467545,473365,479221,485113,491041,497005,503005,509041,515113,521221,527365,533545,539761,546013,552301,558625,564985,571381,577813,584281,590785,597325,603901,610513,617161,623845,630565,637321,644113,650941,657805,664705,671641,678613,685621,692665,699745,706861,714013,721201,728425,735685,742981,750313,757681,765085,772525,780001,787513,795061,802645,810265,817921,825613,833341,841105,848905,856741,864613,872521,880465,888445,896461,904513,912601,920725,928885,937081,945313,953581,961885,970225,978601,987013,995461,1003945,1012465,1021021,1029613,1038241,1046905,1055605,1064341,1073113,1081921,1090765,1099645,1108561,1117513 mov $1,18 mul $1,$0 add $1,6 mul $1,$0 add $1,1
; A324050: Numbers satisfying Korselt's criterion: squarefree numbers n such that for every prime divisor p of n, p-1 divides n-1. ; 1,2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523 mov $3,$0 trn $0,1 seq $0,6005 ; The odd prime numbers together with 1. mov $6,$3 mov $7,2 lpb $7,$6 max $0,2 trn $7,3 lpe
; A016103: Expansion of 1/((1-4x)(1-5x)(1-6x)). ; Submitted by Jon Maiga ; 1,15,151,1275,9751,70035,481951,3216795,20991751,134667555,852639151,5343198315,33212784151,205111785075,1260114546751,7708980203835,46999640806951,285743822630595,1733261544204751,10493837185241355,63435462223140151,382979366943812115,2309726761873773151,13917683741041318875,83802999770218023751,504303611141065537635,3033254233044807571951,18236706243659426644395,109606213746503503857751,658567452132131894815155,3956056713979850334081151,23759604901500415257825915,142673970943853131523202151 mov $1,1 mov $2,1 mov $3,2 lpb $0 sub $0,1 mul $1,5 mul $3,6 add $3,$2 add $3,2 add $1,$3 mul $2,4 add $2,1 sub $1,$2 lpe mov $0,$1
; A103685: Consider the morphism 1->{1,2}, 2->{1,3}, 3->{1}; a(n) is the total number of '3' after n substitutions. ; 0,0,1,5,17,51,147,419,1191,3383,9607,27279,77455,219919,624415,1772895,5033759,14292287,40579903,115217983,327136895,928835455,2637230207,7487852799,21260161279,60363694335,171389837823,486624896511,1381667623423,3922950583295 lpb $0 sub $0,1 add $4,1 add $2,$4 add $1,$2 add $3,$4 add $4,$3 mov $3,$1 lpe sub $1,$2
//////////////////////////////////////////////////////////////////// // INFORMATION ///////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// /* this file contains utility functions that operate on objects and meshes */ //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// // INCLUDES //////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// #include "utility.h" #include "..\..\..\..\Dark Basic Pro SDK\Shared\Core\globstruct.h" //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// // FUNCTIONS /////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// #ifdef DARKSDK_COMPILE sObject* GetObject ( int iID ); #endif //lee - 130206 - //extern GlobStruct* g_pGlobal; extern GlobStruct* g_pGlobForTerrain; sObject* GetObjectData ( int iObject ) { // returns a pointer to the object, first we need to load // the basic 3D DLL, then we can use a function pointer and // get the address of the "GetObject" function, then this // function is called and gives us a pointer to the object // type defintion for the function pointer typedef sObject* ( *GetObjectPFN ) ( int ); // variable declarations, handle to DLL and function pointer HMODULE hDLL = NULL; GetObjectPFN GetObjectEx = NULL; #ifndef DARKSDK_COMPILE // load the basic 3D DLL //hDLL = LoadLibrary ( "DBProBasic3DDebug.dll" ); // check we were able to load the DLL //if ( !hDLL ) // return NULL; // get the function address //GetObjectEx = ( GetObjectPFN ) GetProcAddress ( hDLL, "?GetObjectA@@YAPAUsObject@@H@Z" ); GetObjectEx = ( GetObjectPFN ) GetProcAddress ( g_pGlobForTerrain->g_Basic3D, "?GetObjectA@@YAPAUsObject@@H@Z" ); // check the function pointer is valid //if ( !GetObject ) // return NULL; #else GetObjectEx = GetObject; #endif // get pointer to the object sObject* pObject = GetObjectEx ( iObject ); //FreeLibrary ( hDLL ); return pObject; } bool GetFVFValueOffsetMapEx ( DWORD dwFVF, sOffsetMap* psOffsetMap ) { // get the offset map for the given flexible vertex format // check the offset map pointer is valid SAFE_MEMORY ( psOffsetMap ); // variable declarations int iOffset = 0; // offset int iPosition = 0; // position DWORD dwFVFSize = D3DXGetFVFVertexSize ( dwFVF ); // get fvf size DWORD dwTexCount = 0; // texture count // clear the offset map memset ( psOffsetMap, 0, sizeof ( sOffsetMap ) ); // check for x, y, z if ( dwFVF & D3DFVF_XYZ ) { psOffsetMap->dwX = iOffset + 0; psOffsetMap->dwY = iOffset + 1; psOffsetMap->dwZ = iOffset + 2; iOffset += 3; } // check for x, y, z, rhw if ( dwFVF & D3DFVF_XYZRHW ) { psOffsetMap->dwRWH = iOffset + 0; iOffset += 1; } // check for normals if ( dwFVF & D3DFVF_NORMAL ) { psOffsetMap->dwNX = iOffset + 0; psOffsetMap->dwNY = iOffset + 1; psOffsetMap->dwNZ = iOffset + 2; iOffset += 3; } // check for point size if ( dwFVF & D3DFVF_PSIZE ) { psOffsetMap->dwPointSize = iOffset + 0; iOffset += 1; } // diffuse if ( dwFVF & D3DFVF_DIFFUSE ) { psOffsetMap->dwDiffuse = iOffset + 0; iOffset += 1; } // and specular if ( dwFVF & D3DFVF_SPECULAR ) { psOffsetMap->dwSpecular = iOffset + 0; iOffset += 1; } // finally texture coordinates if ( dwFVF & D3DFVF_TEX1 ) { psOffsetMap->dwTU [ 0 ] = iOffset + 0; psOffsetMap->dwTV [ 0 ] = iOffset + 1; iOffset += 2; } // calculate byte offset psOffsetMap->dwByteSize = sizeof ( DWORD ) * iOffset; // store number of offsets psOffsetMap->dwSize = iOffset; // check if matches byte size of actual FVF if ( dwFVFSize != psOffsetMap->dwByteSize ) return false; return true; } /* bool GetFVFValueOffsetMapEx ( DWORD dwFVF, sOffsetMap* psOffsetMap ) { // get the offset map for the given flexible vertex format // check the offset map pointer is valid SAFE_MEMORY ( psOffsetMap ); // variable declarations int iOffset = 0; // offset int iPosition = 0; // position DWORD dwFVFSize = D3DXGetFVFVertexSize ( dwFVF ); // get fvf size DWORD dwTexCount = 0; // texture count // clear the offset map memset ( psOffsetMap, 0, sizeof ( sOffsetMap ) ); // check for x, y, z if ( dwFVF & D3DFVF_XYZ ) { psOffsetMap->dwX = iOffset + 0; psOffsetMap->dwY = iOffset + 1; psOffsetMap->dwZ = iOffset + 2; iOffset += 3; } // check for x, y, z, rhw if ( dwFVF & D3DFVF_XYZRHW ) { psOffsetMap->dwRWH = iOffset + 0; iOffset += 1; } // check for normals if ( dwFVF & D3DFVF_NORMAL ) { psOffsetMap->dwNX = iOffset + 0; psOffsetMap->dwNY = iOffset + 1; psOffsetMap->dwNZ = iOffset + 2; iOffset += 3; } // check for point size if ( dwFVF & D3DFVF_PSIZE ) { psOffsetMap->dwPointSize = iOffset + 0; iOffset += 1; } // diffuse if ( dwFVF & D3DFVF_DIFFUSE ) { psOffsetMap->dwDiffuse = iOffset + 0; iOffset += 1; } // and specular if ( dwFVF & D3DFVF_SPECULAR ) { psOffsetMap->dwSpecular = iOffset + 0; iOffset += 1; } // finally texture coordinates if ( dwFVF & D3DFVF_TEX1 ) { psOffsetMap->dwTU [ 0 ] = iOffset + 0; psOffsetMap->dwTV [ 0 ] = iOffset + 1; iOffset += 2; } // calculate byte offset psOffsetMap->dwByteSize = sizeof ( DWORD ) * iOffset; // store number of offsets psOffsetMap->dwSize = iOffset; // check if matches byte size of actual FVF if ( dwFVFSize != psOffsetMap->dwByteSize ) return false; return true; } */ bool SetupVertex ( DWORD dwFVF, BYTE* pVertex, int iOffset, float x, float y, float z, float nx, float ny, float nz, float tu, float tv, float tu1, float tv1, DWORD dwDiffuse ) { // setup a standard vertex // check the memory pointer is valid SAFE_MEMORY ( pVertex ); // get the offset map sOffsetMap offsetMap; GetFVFValueOffsetMapEx ( dwFVF, &offsetMap ); // check we have position data if ( dwFVF & D3DFVF_XYZ ) { *( ( float* ) pVertex + offsetMap.dwX + ( offsetMap.dwSize * iOffset ) ) = x; *( ( float* ) pVertex + offsetMap.dwY + ( offsetMap.dwSize * iOffset ) ) = y; *( ( float* ) pVertex + offsetMap.dwZ + ( offsetMap.dwSize * iOffset ) ) = z; } // check we have normals if ( dwFVF & D3DFVF_NORMAL ) { *( ( float* ) pVertex + offsetMap.dwNX + ( offsetMap.dwSize * iOffset ) ) = nx; *( ( float* ) pVertex + offsetMap.dwNY + ( offsetMap.dwSize * iOffset ) ) = ny; *( ( float* ) pVertex + offsetMap.dwNZ + ( offsetMap.dwSize * iOffset ) ) = nz; } // check that we have texture coordinates if ( dwFVF & D3DFVF_TEX1 ) { *( ( float* ) pVertex + offsetMap.dwTU [ 0 ] + ( offsetMap.dwSize * iOffset ) ) = tu; *( ( float* ) pVertex + offsetMap.dwTV [ 0 ] + ( offsetMap.dwSize * iOffset ) ) = tv; } if ( dwFVF & D3DFVF_TEX2 ) { *( ( float* ) pVertex + offsetMap.dwTU [ 0 ] + ( offsetMap.dwSize * iOffset ) ) = tu; *( ( float* ) pVertex + offsetMap.dwTV [ 0 ] + ( offsetMap.dwSize * iOffset ) ) = tv; *( ( float* ) pVertex + offsetMap.dwTU [ 1 ] + ( offsetMap.dwSize * iOffset ) ) = tu1; *( ( float* ) pVertex + offsetMap.dwTV [ 1 ] + ( offsetMap.dwSize * iOffset ) ) = tv1; } // check that we have texture coordinates if ( dwFVF & D3DFVF_DIFFUSE ) { //( ( DWORD* ) pVertex + offsetMap.dwDiffuse = dwDiffuse; *( ( DWORD* ) pVertex + offsetMap.dwDiffuse + ( offsetMap.dwSize * iOffset ) ) = dwDiffuse; } return true; } //////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
; A011872: [ n(n-1)/19 ]. ; 0,0,0,0,0,1,1,2,2,3,4,5,6,8,9,11,12,14,16,18,20,22,24,26,29,31,34,36,39,42,45,48,52,55,59,62,66,70,74,78,82,86,90,95,99,104,108,113,118,123,128,134,139,145,150,156,162,168,174,180,186,192,199,205,212,218,225,232 mov $1,$0 pow $0,2 sub $0,$1 div $0,19
cmpq %rdi, %rsi decq %rsi incq %rax je L1 jl L2 jmp L3 movl (%rdi,%rax,4), %edi retq xchgq %rax, %rcx xorq %rax, %rax
; A047464: Numbers that are congruent to {0, 2, 4} mod 8. ; 0,2,4,8,10,12,16,18,20,24,26,28,32,34,36,40,42,44,48,50,52,56,58,60,64,66,68,72,74,76,80,82,84,88,90,92,96,98,100,104,106,108,112,114,116,120,122,124,128,130,132,136,138,140,144,146,148,152,154,156 mov $1,$0 div $0,3 add $1,$0 mul $1,2
_usertests: file format elf32-i386 Disassembly of section .text: 00000000 <main>: return randstate; } int main(int argc, char *argv[]) { 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp 7: ff 71 fc pushl -0x4(%ecx) a: 55 push %ebp b: 89 e5 mov %esp,%ebp d: 51 push %ecx e: 83 ec 0c sub $0xc,%esp printf(1, "usertests starting\n"); 11: 68 36 4d 00 00 push $0x4d36 16: 6a 01 push $0x1 18: e8 d3 39 00 00 call 39f0 <printf> if(open("usertests.ran", 0) >= 0){ 1d: 59 pop %ecx 1e: 58 pop %eax 1f: 6a 00 push $0x0 21: 68 4a 4d 00 00 push $0x4d4a 26: e8 b7 38 00 00 call 38e2 <open> 2b: 83 c4 10 add $0x10,%esp 2e: 85 c0 test %eax,%eax 30: 78 13 js 45 <main+0x45> printf(1, "already ran user tests -- rebuild fs.img\n"); 32: 52 push %edx 33: 52 push %edx 34: 68 b4 54 00 00 push $0x54b4 39: 6a 01 push $0x1 3b: e8 b0 39 00 00 call 39f0 <printf> exit(); 40: e8 5d 38 00 00 call 38a2 <exit> } close(open("usertests.ran", O_CREATE)); 45: 50 push %eax 46: 50 push %eax 47: 68 00 02 00 00 push $0x200 4c: 68 4a 4d 00 00 push $0x4d4a 51: e8 8c 38 00 00 call 38e2 <open> 56: 89 04 24 mov %eax,(%esp) 59: e8 6c 38 00 00 call 38ca <close> argptest(); 5e: e8 5d 35 00 00 call 35c0 <argptest> createdelete(); 63: e8 a8 11 00 00 call 1210 <createdelete> linkunlink(); 68: e8 63 1a 00 00 call 1ad0 <linkunlink> concreate(); 6d: e8 5e 17 00 00 call 17d0 <concreate> fourfiles(); 72: e8 99 0f 00 00 call 1010 <fourfiles> sharedfd(); 77: e8 d4 0d 00 00 call e50 <sharedfd> bigargtest(); 7c: e8 ff 31 00 00 call 3280 <bigargtest> bigwrite(); 81: e8 6a 23 00 00 call 23f0 <bigwrite> bigargtest(); 86: e8 f5 31 00 00 call 3280 <bigargtest> bsstest(); 8b: e8 70 31 00 00 call 3200 <bsstest> sbrktest(); 90: e8 9b 2c 00 00 call 2d30 <sbrktest> validatetest(); 95: e8 b6 30 00 00 call 3150 <validatetest> opentest(); 9a: e8 51 03 00 00 call 3f0 <opentest> writetest(); 9f: e8 dc 03 00 00 call 480 <writetest> writetest1(); a4: e8 b7 05 00 00 call 660 <writetest1> createtest(); a9: e8 82 07 00 00 call 830 <createtest> openiputtest(); ae: e8 3d 02 00 00 call 2f0 <openiputtest> exitiputtest(); b3: e8 48 01 00 00 call 200 <exitiputtest> iputtest(); b8: e8 63 00 00 00 call 120 <iputtest> mem(); bd: e8 be 0c 00 00 call d80 <mem> pipe1(); c2: e8 49 09 00 00 call a10 <pipe1> preempt(); c7: e8 e4 0a 00 00 call bb0 <preempt> exitwait(); cc: e8 1f 0c 00 00 call cf0 <exitwait> rmdot(); d1: e8 0a 27 00 00 call 27e0 <rmdot> fourteen(); d6: e8 c5 25 00 00 call 26a0 <fourteen> bigfile(); db: e8 f0 23 00 00 call 24d0 <bigfile> subdir(); e0: e8 2b 1c 00 00 call 1d10 <subdir> linktest(); e5: e8 d6 14 00 00 call 15c0 <linktest> unlinkread(); ea: e8 41 13 00 00 call 1430 <unlinkread> dirfile(); ef: e8 6c 28 00 00 call 2960 <dirfile> iref(); f4: e8 67 2a 00 00 call 2b60 <iref> forktest(); f9: e8 82 2b 00 00 call 2c80 <forktest> bigdir(); // slow fe: e8 dd 1a 00 00 call 1be0 <bigdir> uio(); 103: e8 48 34 00 00 call 3550 <uio> exectest(); 108: e8 b3 08 00 00 call 9c0 <exectest> exit(); 10d: e8 90 37 00 00 call 38a2 <exit> 112: 66 90 xchg %ax,%ax 114: 66 90 xchg %ax,%ax 116: 66 90 xchg %ax,%ax 118: 66 90 xchg %ax,%ax 11a: 66 90 xchg %ax,%ax 11c: 66 90 xchg %ax,%ax 11e: 66 90 xchg %ax,%ax 00000120 <iputtest>: { 120: 55 push %ebp 121: 89 e5 mov %esp,%ebp 123: 83 ec 10 sub $0x10,%esp printf(stdout, "iput test\n"); 126: 68 dc 3d 00 00 push $0x3ddc 12b: ff 35 f8 5d 00 00 pushl 0x5df8 131: e8 ba 38 00 00 call 39f0 <printf> if(mkdir("iputdir") < 0){ 136: c7 04 24 6f 3d 00 00 movl $0x3d6f,(%esp) 13d: e8 c8 37 00 00 call 390a <mkdir> 142: 83 c4 10 add $0x10,%esp 145: 85 c0 test %eax,%eax 147: 78 58 js 1a1 <iputtest+0x81> if(chdir("iputdir") < 0){ 149: 83 ec 0c sub $0xc,%esp 14c: 68 6f 3d 00 00 push $0x3d6f 151: e8 bc 37 00 00 call 3912 <chdir> 156: 83 c4 10 add $0x10,%esp 159: 85 c0 test %eax,%eax 15b: 0f 88 85 00 00 00 js 1e6 <iputtest+0xc6> if(unlink("../iputdir") < 0){ 161: 83 ec 0c sub $0xc,%esp 164: 68 6c 3d 00 00 push $0x3d6c 169: e8 84 37 00 00 call 38f2 <unlink> 16e: 83 c4 10 add $0x10,%esp 171: 85 c0 test %eax,%eax 173: 78 5a js 1cf <iputtest+0xaf> if(chdir("/") < 0){ 175: 83 ec 0c sub $0xc,%esp 178: 68 91 3d 00 00 push $0x3d91 17d: e8 90 37 00 00 call 3912 <chdir> 182: 83 c4 10 add $0x10,%esp 185: 85 c0 test %eax,%eax 187: 78 2f js 1b8 <iputtest+0x98> printf(stdout, "iput test ok\n"); 189: 83 ec 08 sub $0x8,%esp 18c: 68 14 3e 00 00 push $0x3e14 191: ff 35 f8 5d 00 00 pushl 0x5df8 197: e8 54 38 00 00 call 39f0 <printf> } 19c: 83 c4 10 add $0x10,%esp 19f: c9 leave 1a0: c3 ret printf(stdout, "mkdir failed\n"); 1a1: 50 push %eax 1a2: 50 push %eax 1a3: 68 48 3d 00 00 push $0x3d48 1a8: ff 35 f8 5d 00 00 pushl 0x5df8 1ae: e8 3d 38 00 00 call 39f0 <printf> exit(); 1b3: e8 ea 36 00 00 call 38a2 <exit> printf(stdout, "chdir / failed\n"); 1b8: 50 push %eax 1b9: 50 push %eax 1ba: 68 93 3d 00 00 push $0x3d93 1bf: ff 35 f8 5d 00 00 pushl 0x5df8 1c5: e8 26 38 00 00 call 39f0 <printf> exit(); 1ca: e8 d3 36 00 00 call 38a2 <exit> printf(stdout, "unlink ../iputdir failed\n"); 1cf: 52 push %edx 1d0: 52 push %edx 1d1: 68 77 3d 00 00 push $0x3d77 1d6: ff 35 f8 5d 00 00 pushl 0x5df8 1dc: e8 0f 38 00 00 call 39f0 <printf> exit(); 1e1: e8 bc 36 00 00 call 38a2 <exit> printf(stdout, "chdir iputdir failed\n"); 1e6: 51 push %ecx 1e7: 51 push %ecx 1e8: 68 56 3d 00 00 push $0x3d56 1ed: ff 35 f8 5d 00 00 pushl 0x5df8 1f3: e8 f8 37 00 00 call 39f0 <printf> exit(); 1f8: e8 a5 36 00 00 call 38a2 <exit> 1fd: 8d 76 00 lea 0x0(%esi),%esi 00000200 <exitiputtest>: { 200: 55 push %ebp 201: 89 e5 mov %esp,%ebp 203: 83 ec 10 sub $0x10,%esp printf(stdout, "exitiput test\n"); 206: 68 a3 3d 00 00 push $0x3da3 20b: ff 35 f8 5d 00 00 pushl 0x5df8 211: e8 da 37 00 00 call 39f0 <printf> pid = fork(); 216: e8 7f 36 00 00 call 389a <fork> if(pid < 0){ 21b: 83 c4 10 add $0x10,%esp 21e: 85 c0 test %eax,%eax 220: 0f 88 82 00 00 00 js 2a8 <exitiputtest+0xa8> if(pid == 0){ 226: 75 48 jne 270 <exitiputtest+0x70> if(mkdir("iputdir") < 0){ 228: 83 ec 0c sub $0xc,%esp 22b: 68 6f 3d 00 00 push $0x3d6f 230: e8 d5 36 00 00 call 390a <mkdir> 235: 83 c4 10 add $0x10,%esp 238: 85 c0 test %eax,%eax 23a: 0f 88 96 00 00 00 js 2d6 <exitiputtest+0xd6> if(chdir("iputdir") < 0){ 240: 83 ec 0c sub $0xc,%esp 243: 68 6f 3d 00 00 push $0x3d6f 248: e8 c5 36 00 00 call 3912 <chdir> 24d: 83 c4 10 add $0x10,%esp 250: 85 c0 test %eax,%eax 252: 78 6b js 2bf <exitiputtest+0xbf> if(unlink("../iputdir") < 0){ 254: 83 ec 0c sub $0xc,%esp 257: 68 6c 3d 00 00 push $0x3d6c 25c: e8 91 36 00 00 call 38f2 <unlink> 261: 83 c4 10 add $0x10,%esp 264: 85 c0 test %eax,%eax 266: 78 28 js 290 <exitiputtest+0x90> exit(); 268: e8 35 36 00 00 call 38a2 <exit> 26d: 8d 76 00 lea 0x0(%esi),%esi wait(); 270: e8 35 36 00 00 call 38aa <wait> printf(stdout, "exitiput test ok\n"); 275: 83 ec 08 sub $0x8,%esp 278: 68 c6 3d 00 00 push $0x3dc6 27d: ff 35 f8 5d 00 00 pushl 0x5df8 283: e8 68 37 00 00 call 39f0 <printf> } 288: 83 c4 10 add $0x10,%esp 28b: c9 leave 28c: c3 ret 28d: 8d 76 00 lea 0x0(%esi),%esi printf(stdout, "unlink ../iputdir failed\n"); 290: 83 ec 08 sub $0x8,%esp 293: 68 77 3d 00 00 push $0x3d77 298: ff 35 f8 5d 00 00 pushl 0x5df8 29e: e8 4d 37 00 00 call 39f0 <printf> exit(); 2a3: e8 fa 35 00 00 call 38a2 <exit> printf(stdout, "fork failed\n"); 2a8: 51 push %ecx 2a9: 51 push %ecx 2aa: 68 89 4c 00 00 push $0x4c89 2af: ff 35 f8 5d 00 00 pushl 0x5df8 2b5: e8 36 37 00 00 call 39f0 <printf> exit(); 2ba: e8 e3 35 00 00 call 38a2 <exit> printf(stdout, "child chdir failed\n"); 2bf: 50 push %eax 2c0: 50 push %eax 2c1: 68 b2 3d 00 00 push $0x3db2 2c6: ff 35 f8 5d 00 00 pushl 0x5df8 2cc: e8 1f 37 00 00 call 39f0 <printf> exit(); 2d1: e8 cc 35 00 00 call 38a2 <exit> printf(stdout, "mkdir failed\n"); 2d6: 52 push %edx 2d7: 52 push %edx 2d8: 68 48 3d 00 00 push $0x3d48 2dd: ff 35 f8 5d 00 00 pushl 0x5df8 2e3: e8 08 37 00 00 call 39f0 <printf> exit(); 2e8: e8 b5 35 00 00 call 38a2 <exit> 2ed: 8d 76 00 lea 0x0(%esi),%esi 000002f0 <openiputtest>: { 2f0: 55 push %ebp 2f1: 89 e5 mov %esp,%ebp 2f3: 83 ec 10 sub $0x10,%esp printf(stdout, "openiput test\n"); 2f6: 68 d8 3d 00 00 push $0x3dd8 2fb: ff 35 f8 5d 00 00 pushl 0x5df8 301: e8 ea 36 00 00 call 39f0 <printf> if(mkdir("oidir") < 0){ 306: c7 04 24 e7 3d 00 00 movl $0x3de7,(%esp) 30d: e8 f8 35 00 00 call 390a <mkdir> 312: 83 c4 10 add $0x10,%esp 315: 85 c0 test %eax,%eax 317: 0f 88 88 00 00 00 js 3a5 <openiputtest+0xb5> pid = fork(); 31d: e8 78 35 00 00 call 389a <fork> if(pid < 0){ 322: 85 c0 test %eax,%eax 324: 0f 88 92 00 00 00 js 3bc <openiputtest+0xcc> if(pid == 0){ 32a: 75 34 jne 360 <openiputtest+0x70> int fd = open("oidir", O_RDWR); 32c: 83 ec 08 sub $0x8,%esp 32f: 6a 02 push $0x2 331: 68 e7 3d 00 00 push $0x3de7 336: e8 a7 35 00 00 call 38e2 <open> if(fd >= 0){ 33b: 83 c4 10 add $0x10,%esp 33e: 85 c0 test %eax,%eax 340: 78 5e js 3a0 <openiputtest+0xb0> printf(stdout, "open directory for write succeeded\n"); 342: 83 ec 08 sub $0x8,%esp 345: 68 6c 4d 00 00 push $0x4d6c 34a: ff 35 f8 5d 00 00 pushl 0x5df8 350: e8 9b 36 00 00 call 39f0 <printf> exit(); 355: e8 48 35 00 00 call 38a2 <exit> 35a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi sleep(1); 360: 83 ec 0c sub $0xc,%esp 363: 6a 01 push $0x1 365: e8 c8 35 00 00 call 3932 <sleep> if(unlink("oidir") != 0){ 36a: c7 04 24 e7 3d 00 00 movl $0x3de7,(%esp) 371: e8 7c 35 00 00 call 38f2 <unlink> 376: 83 c4 10 add $0x10,%esp 379: 85 c0 test %eax,%eax 37b: 75 56 jne 3d3 <openiputtest+0xe3> wait(); 37d: e8 28 35 00 00 call 38aa <wait> printf(stdout, "openiput test ok\n"); 382: 83 ec 08 sub $0x8,%esp 385: 68 10 3e 00 00 push $0x3e10 38a: ff 35 f8 5d 00 00 pushl 0x5df8 390: e8 5b 36 00 00 call 39f0 <printf> 395: 83 c4 10 add $0x10,%esp } 398: c9 leave 399: c3 ret 39a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi exit(); 3a0: e8 fd 34 00 00 call 38a2 <exit> printf(stdout, "mkdir oidir failed\n"); 3a5: 51 push %ecx 3a6: 51 push %ecx 3a7: 68 ed 3d 00 00 push $0x3ded 3ac: ff 35 f8 5d 00 00 pushl 0x5df8 3b2: e8 39 36 00 00 call 39f0 <printf> exit(); 3b7: e8 e6 34 00 00 call 38a2 <exit> printf(stdout, "fork failed\n"); 3bc: 52 push %edx 3bd: 52 push %edx 3be: 68 89 4c 00 00 push $0x4c89 3c3: ff 35 f8 5d 00 00 pushl 0x5df8 3c9: e8 22 36 00 00 call 39f0 <printf> exit(); 3ce: e8 cf 34 00 00 call 38a2 <exit> printf(stdout, "unlink failed\n"); 3d3: 50 push %eax 3d4: 50 push %eax 3d5: 68 01 3e 00 00 push $0x3e01 3da: ff 35 f8 5d 00 00 pushl 0x5df8 3e0: e8 0b 36 00 00 call 39f0 <printf> exit(); 3e5: e8 b8 34 00 00 call 38a2 <exit> 3ea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 000003f0 <opentest>: { 3f0: 55 push %ebp 3f1: 89 e5 mov %esp,%ebp 3f3: 83 ec 10 sub $0x10,%esp printf(stdout, "open test\n"); 3f6: 68 22 3e 00 00 push $0x3e22 3fb: ff 35 f8 5d 00 00 pushl 0x5df8 401: e8 ea 35 00 00 call 39f0 <printf> fd = open("echo", 0); 406: 58 pop %eax 407: 5a pop %edx 408: 6a 00 push $0x0 40a: 68 2d 3e 00 00 push $0x3e2d 40f: e8 ce 34 00 00 call 38e2 <open> if(fd < 0){ 414: 83 c4 10 add $0x10,%esp 417: 85 c0 test %eax,%eax 419: 78 36 js 451 <opentest+0x61> close(fd); 41b: 83 ec 0c sub $0xc,%esp 41e: 50 push %eax 41f: e8 a6 34 00 00 call 38ca <close> fd = open("doesnotexist", 0); 424: 5a pop %edx 425: 59 pop %ecx 426: 6a 00 push $0x0 428: 68 45 3e 00 00 push $0x3e45 42d: e8 b0 34 00 00 call 38e2 <open> if(fd >= 0){ 432: 83 c4 10 add $0x10,%esp 435: 85 c0 test %eax,%eax 437: 79 2f jns 468 <opentest+0x78> printf(stdout, "open test ok\n"); 439: 83 ec 08 sub $0x8,%esp 43c: 68 70 3e 00 00 push $0x3e70 441: ff 35 f8 5d 00 00 pushl 0x5df8 447: e8 a4 35 00 00 call 39f0 <printf> } 44c: 83 c4 10 add $0x10,%esp 44f: c9 leave 450: c3 ret printf(stdout, "open echo failed!\n"); 451: 50 push %eax 452: 50 push %eax 453: 68 32 3e 00 00 push $0x3e32 458: ff 35 f8 5d 00 00 pushl 0x5df8 45e: e8 8d 35 00 00 call 39f0 <printf> exit(); 463: e8 3a 34 00 00 call 38a2 <exit> printf(stdout, "open doesnotexist succeeded!\n"); 468: 50 push %eax 469: 50 push %eax 46a: 68 52 3e 00 00 push $0x3e52 46f: ff 35 f8 5d 00 00 pushl 0x5df8 475: e8 76 35 00 00 call 39f0 <printf> exit(); 47a: e8 23 34 00 00 call 38a2 <exit> 47f: 90 nop 00000480 <writetest>: { 480: 55 push %ebp 481: 89 e5 mov %esp,%ebp 483: 56 push %esi 484: 53 push %ebx printf(stdout, "small file test\n"); 485: 83 ec 08 sub $0x8,%esp 488: 68 7e 3e 00 00 push $0x3e7e 48d: ff 35 f8 5d 00 00 pushl 0x5df8 493: e8 58 35 00 00 call 39f0 <printf> fd = open("small", O_CREATE|O_RDWR); 498: 58 pop %eax 499: 5a pop %edx 49a: 68 02 02 00 00 push $0x202 49f: 68 8f 3e 00 00 push $0x3e8f 4a4: e8 39 34 00 00 call 38e2 <open> if(fd >= 0){ 4a9: 83 c4 10 add $0x10,%esp 4ac: 85 c0 test %eax,%eax 4ae: 0f 88 88 01 00 00 js 63c <writetest+0x1bc> printf(stdout, "creat small succeeded; ok\n"); 4b4: 83 ec 08 sub $0x8,%esp 4b7: 89 c6 mov %eax,%esi for(i = 0; i < 100; i++){ 4b9: 31 db xor %ebx,%ebx printf(stdout, "creat small succeeded; ok\n"); 4bb: 68 95 3e 00 00 push $0x3e95 4c0: ff 35 f8 5d 00 00 pushl 0x5df8 4c6: e8 25 35 00 00 call 39f0 <printf> 4cb: 83 c4 10 add $0x10,%esp 4ce: 66 90 xchg %ax,%ax if(write(fd, "aaaaaaaaaa", 10) != 10){ 4d0: 83 ec 04 sub $0x4,%esp 4d3: 6a 0a push $0xa 4d5: 68 cc 3e 00 00 push $0x3ecc 4da: 56 push %esi 4db: e8 e2 33 00 00 call 38c2 <write> 4e0: 83 c4 10 add $0x10,%esp 4e3: 83 f8 0a cmp $0xa,%eax 4e6: 0f 85 d9 00 00 00 jne 5c5 <writetest+0x145> if(write(fd, "bbbbbbbbbb", 10) != 10){ 4ec: 83 ec 04 sub $0x4,%esp 4ef: 6a 0a push $0xa 4f1: 68 d7 3e 00 00 push $0x3ed7 4f6: 56 push %esi 4f7: e8 c6 33 00 00 call 38c2 <write> 4fc: 83 c4 10 add $0x10,%esp 4ff: 83 f8 0a cmp $0xa,%eax 502: 0f 85 d6 00 00 00 jne 5de <writetest+0x15e> for(i = 0; i < 100; i++){ 508: 83 c3 01 add $0x1,%ebx 50b: 83 fb 64 cmp $0x64,%ebx 50e: 75 c0 jne 4d0 <writetest+0x50> printf(stdout, "writes ok\n"); 510: 83 ec 08 sub $0x8,%esp 513: 68 e2 3e 00 00 push $0x3ee2 518: ff 35 f8 5d 00 00 pushl 0x5df8 51e: e8 cd 34 00 00 call 39f0 <printf> close(fd); 523: 89 34 24 mov %esi,(%esp) 526: e8 9f 33 00 00 call 38ca <close> fd = open("small", O_RDONLY); 52b: 5b pop %ebx 52c: 5e pop %esi 52d: 6a 00 push $0x0 52f: 68 8f 3e 00 00 push $0x3e8f 534: e8 a9 33 00 00 call 38e2 <open> if(fd >= 0){ 539: 83 c4 10 add $0x10,%esp 53c: 85 c0 test %eax,%eax fd = open("small", O_RDONLY); 53e: 89 c3 mov %eax,%ebx if(fd >= 0){ 540: 0f 88 b1 00 00 00 js 5f7 <writetest+0x177> printf(stdout, "open small succeeded ok\n"); 546: 83 ec 08 sub $0x8,%esp 549: 68 ed 3e 00 00 push $0x3eed 54e: ff 35 f8 5d 00 00 pushl 0x5df8 554: e8 97 34 00 00 call 39f0 <printf> i = read(fd, buf, 2000); 559: 83 c4 0c add $0xc,%esp 55c: 68 d0 07 00 00 push $0x7d0 561: 68 e0 85 00 00 push $0x85e0 566: 53 push %ebx 567: e8 4e 33 00 00 call 38ba <read> if(i == 2000){ 56c: 83 c4 10 add $0x10,%esp 56f: 3d d0 07 00 00 cmp $0x7d0,%eax 574: 0f 85 94 00 00 00 jne 60e <writetest+0x18e> printf(stdout, "read succeeded ok\n"); 57a: 83 ec 08 sub $0x8,%esp 57d: 68 21 3f 00 00 push $0x3f21 582: ff 35 f8 5d 00 00 pushl 0x5df8 588: e8 63 34 00 00 call 39f0 <printf> close(fd); 58d: 89 1c 24 mov %ebx,(%esp) 590: e8 35 33 00 00 call 38ca <close> if(unlink("small") < 0){ 595: c7 04 24 8f 3e 00 00 movl $0x3e8f,(%esp) 59c: e8 51 33 00 00 call 38f2 <unlink> 5a1: 83 c4 10 add $0x10,%esp 5a4: 85 c0 test %eax,%eax 5a6: 78 7d js 625 <writetest+0x1a5> printf(stdout, "small file test ok\n"); 5a8: 83 ec 08 sub $0x8,%esp 5ab: 68 49 3f 00 00 push $0x3f49 5b0: ff 35 f8 5d 00 00 pushl 0x5df8 5b6: e8 35 34 00 00 call 39f0 <printf> } 5bb: 83 c4 10 add $0x10,%esp 5be: 8d 65 f8 lea -0x8(%ebp),%esp 5c1: 5b pop %ebx 5c2: 5e pop %esi 5c3: 5d pop %ebp 5c4: c3 ret printf(stdout, "error: write aa %d new file failed\n", i); 5c5: 83 ec 04 sub $0x4,%esp 5c8: 53 push %ebx 5c9: 68 90 4d 00 00 push $0x4d90 5ce: ff 35 f8 5d 00 00 pushl 0x5df8 5d4: e8 17 34 00 00 call 39f0 <printf> exit(); 5d9: e8 c4 32 00 00 call 38a2 <exit> printf(stdout, "error: write bb %d new file failed\n", i); 5de: 83 ec 04 sub $0x4,%esp 5e1: 53 push %ebx 5e2: 68 b4 4d 00 00 push $0x4db4 5e7: ff 35 f8 5d 00 00 pushl 0x5df8 5ed: e8 fe 33 00 00 call 39f0 <printf> exit(); 5f2: e8 ab 32 00 00 call 38a2 <exit> printf(stdout, "error: open small failed!\n"); 5f7: 51 push %ecx 5f8: 51 push %ecx 5f9: 68 06 3f 00 00 push $0x3f06 5fe: ff 35 f8 5d 00 00 pushl 0x5df8 604: e8 e7 33 00 00 call 39f0 <printf> exit(); 609: e8 94 32 00 00 call 38a2 <exit> printf(stdout, "read failed\n"); 60e: 52 push %edx 60f: 52 push %edx 610: 68 4d 42 00 00 push $0x424d 615: ff 35 f8 5d 00 00 pushl 0x5df8 61b: e8 d0 33 00 00 call 39f0 <printf> exit(); 620: e8 7d 32 00 00 call 38a2 <exit> printf(stdout, "unlink small failed\n"); 625: 50 push %eax 626: 50 push %eax 627: 68 34 3f 00 00 push $0x3f34 62c: ff 35 f8 5d 00 00 pushl 0x5df8 632: e8 b9 33 00 00 call 39f0 <printf> exit(); 637: e8 66 32 00 00 call 38a2 <exit> printf(stdout, "error: creat small failed!\n"); 63c: 50 push %eax 63d: 50 push %eax 63e: 68 b0 3e 00 00 push $0x3eb0 643: ff 35 f8 5d 00 00 pushl 0x5df8 649: e8 a2 33 00 00 call 39f0 <printf> exit(); 64e: e8 4f 32 00 00 call 38a2 <exit> 653: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 659: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000660 <writetest1>: { 660: 55 push %ebp 661: 89 e5 mov %esp,%ebp 663: 56 push %esi 664: 53 push %ebx printf(stdout, "big files test\n"); 665: 83 ec 08 sub $0x8,%esp 668: 68 5d 3f 00 00 push $0x3f5d 66d: ff 35 f8 5d 00 00 pushl 0x5df8 673: e8 78 33 00 00 call 39f0 <printf> fd = open("big", O_CREATE|O_RDWR); 678: 58 pop %eax 679: 5a pop %edx 67a: 68 02 02 00 00 push $0x202 67f: 68 d7 3f 00 00 push $0x3fd7 684: e8 59 32 00 00 call 38e2 <open> if(fd < 0){ 689: 83 c4 10 add $0x10,%esp 68c: 85 c0 test %eax,%eax 68e: 0f 88 61 01 00 00 js 7f5 <writetest1+0x195> 694: 89 c6 mov %eax,%esi for(i = 0; i < MAXFILE; i++){ 696: 31 db xor %ebx,%ebx 698: 90 nop 699: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(write(fd, buf, 512) != 512){ 6a0: 83 ec 04 sub $0x4,%esp ((int*)buf)[0] = i; 6a3: 89 1d e0 85 00 00 mov %ebx,0x85e0 if(write(fd, buf, 512) != 512){ 6a9: 68 00 02 00 00 push $0x200 6ae: 68 e0 85 00 00 push $0x85e0 6b3: 56 push %esi 6b4: e8 09 32 00 00 call 38c2 <write> 6b9: 83 c4 10 add $0x10,%esp 6bc: 3d 00 02 00 00 cmp $0x200,%eax 6c1: 0f 85 b3 00 00 00 jne 77a <writetest1+0x11a> for(i = 0; i < MAXFILE; i++){ 6c7: 83 c3 01 add $0x1,%ebx 6ca: 81 fb 8c 00 00 00 cmp $0x8c,%ebx 6d0: 75 ce jne 6a0 <writetest1+0x40> close(fd); 6d2: 83 ec 0c sub $0xc,%esp 6d5: 56 push %esi 6d6: e8 ef 31 00 00 call 38ca <close> fd = open("big", O_RDONLY); 6db: 5b pop %ebx 6dc: 5e pop %esi 6dd: 6a 00 push $0x0 6df: 68 d7 3f 00 00 push $0x3fd7 6e4: e8 f9 31 00 00 call 38e2 <open> if(fd < 0){ 6e9: 83 c4 10 add $0x10,%esp 6ec: 85 c0 test %eax,%eax fd = open("big", O_RDONLY); 6ee: 89 c6 mov %eax,%esi if(fd < 0){ 6f0: 0f 88 e8 00 00 00 js 7de <writetest1+0x17e> n = 0; 6f6: 31 db xor %ebx,%ebx 6f8: eb 1d jmp 717 <writetest1+0xb7> 6fa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi } else if(i != 512){ 700: 3d 00 02 00 00 cmp $0x200,%eax 705: 0f 85 9f 00 00 00 jne 7aa <writetest1+0x14a> if(((int*)buf)[0] != n){ 70b: a1 e0 85 00 00 mov 0x85e0,%eax 710: 39 d8 cmp %ebx,%eax 712: 75 7f jne 793 <writetest1+0x133> n++; 714: 83 c3 01 add $0x1,%ebx i = read(fd, buf, 512); 717: 83 ec 04 sub $0x4,%esp 71a: 68 00 02 00 00 push $0x200 71f: 68 e0 85 00 00 push $0x85e0 724: 56 push %esi 725: e8 90 31 00 00 call 38ba <read> if(i == 0){ 72a: 83 c4 10 add $0x10,%esp 72d: 85 c0 test %eax,%eax 72f: 75 cf jne 700 <writetest1+0xa0> if(n == MAXFILE - 1){ 731: 81 fb 8b 00 00 00 cmp $0x8b,%ebx 737: 0f 84 86 00 00 00 je 7c3 <writetest1+0x163> close(fd); 73d: 83 ec 0c sub $0xc,%esp 740: 56 push %esi 741: e8 84 31 00 00 call 38ca <close> if(unlink("big") < 0){ 746: c7 04 24 d7 3f 00 00 movl $0x3fd7,(%esp) 74d: e8 a0 31 00 00 call 38f2 <unlink> 752: 83 c4 10 add $0x10,%esp 755: 85 c0 test %eax,%eax 757: 0f 88 af 00 00 00 js 80c <writetest1+0x1ac> printf(stdout, "big files ok\n"); 75d: 83 ec 08 sub $0x8,%esp 760: 68 fe 3f 00 00 push $0x3ffe 765: ff 35 f8 5d 00 00 pushl 0x5df8 76b: e8 80 32 00 00 call 39f0 <printf> } 770: 83 c4 10 add $0x10,%esp 773: 8d 65 f8 lea -0x8(%ebp),%esp 776: 5b pop %ebx 777: 5e pop %esi 778: 5d pop %ebp 779: c3 ret printf(stdout, "error: write big file failed\n", i); 77a: 83 ec 04 sub $0x4,%esp 77d: 53 push %ebx 77e: 68 87 3f 00 00 push $0x3f87 783: ff 35 f8 5d 00 00 pushl 0x5df8 789: e8 62 32 00 00 call 39f0 <printf> exit(); 78e: e8 0f 31 00 00 call 38a2 <exit> printf(stdout, "read content of block %d is %d\n", 793: 50 push %eax 794: 53 push %ebx 795: 68 d8 4d 00 00 push $0x4dd8 79a: ff 35 f8 5d 00 00 pushl 0x5df8 7a0: e8 4b 32 00 00 call 39f0 <printf> exit(); 7a5: e8 f8 30 00 00 call 38a2 <exit> printf(stdout, "read failed %d\n", i); 7aa: 83 ec 04 sub $0x4,%esp 7ad: 50 push %eax 7ae: 68 db 3f 00 00 push $0x3fdb 7b3: ff 35 f8 5d 00 00 pushl 0x5df8 7b9: e8 32 32 00 00 call 39f0 <printf> exit(); 7be: e8 df 30 00 00 call 38a2 <exit> printf(stdout, "read only %d blocks from big", n); 7c3: 52 push %edx 7c4: 68 8b 00 00 00 push $0x8b 7c9: 68 be 3f 00 00 push $0x3fbe 7ce: ff 35 f8 5d 00 00 pushl 0x5df8 7d4: e8 17 32 00 00 call 39f0 <printf> exit(); 7d9: e8 c4 30 00 00 call 38a2 <exit> printf(stdout, "error: open big failed!\n"); 7de: 51 push %ecx 7df: 51 push %ecx 7e0: 68 a5 3f 00 00 push $0x3fa5 7e5: ff 35 f8 5d 00 00 pushl 0x5df8 7eb: e8 00 32 00 00 call 39f0 <printf> exit(); 7f0: e8 ad 30 00 00 call 38a2 <exit> printf(stdout, "error: creat big failed!\n"); 7f5: 50 push %eax 7f6: 50 push %eax 7f7: 68 6d 3f 00 00 push $0x3f6d 7fc: ff 35 f8 5d 00 00 pushl 0x5df8 802: e8 e9 31 00 00 call 39f0 <printf> exit(); 807: e8 96 30 00 00 call 38a2 <exit> printf(stdout, "unlink big failed\n"); 80c: 50 push %eax 80d: 50 push %eax 80e: 68 eb 3f 00 00 push $0x3feb 813: ff 35 f8 5d 00 00 pushl 0x5df8 819: e8 d2 31 00 00 call 39f0 <printf> exit(); 81e: e8 7f 30 00 00 call 38a2 <exit> 823: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 829: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000830 <createtest>: { 830: 55 push %ebp 831: 89 e5 mov %esp,%ebp 833: 53 push %ebx name[2] = '\0'; 834: bb 30 00 00 00 mov $0x30,%ebx { 839: 83 ec 0c sub $0xc,%esp printf(stdout, "many creates, followed by unlink test\n"); 83c: 68 f8 4d 00 00 push $0x4df8 841: ff 35 f8 5d 00 00 pushl 0x5df8 847: e8 a4 31 00 00 call 39f0 <printf> name[0] = 'a'; 84c: c6 05 e0 a5 00 00 61 movb $0x61,0xa5e0 name[2] = '\0'; 853: c6 05 e2 a5 00 00 00 movb $0x0,0xa5e2 85a: 83 c4 10 add $0x10,%esp 85d: 8d 76 00 lea 0x0(%esi),%esi fd = open(name, O_CREATE|O_RDWR); 860: 83 ec 08 sub $0x8,%esp name[1] = '0' + i; 863: 88 1d e1 a5 00 00 mov %bl,0xa5e1 869: 83 c3 01 add $0x1,%ebx fd = open(name, O_CREATE|O_RDWR); 86c: 68 02 02 00 00 push $0x202 871: 68 e0 a5 00 00 push $0xa5e0 876: e8 67 30 00 00 call 38e2 <open> close(fd); 87b: 89 04 24 mov %eax,(%esp) 87e: e8 47 30 00 00 call 38ca <close> for(i = 0; i < 52; i++){ 883: 83 c4 10 add $0x10,%esp 886: 80 fb 64 cmp $0x64,%bl 889: 75 d5 jne 860 <createtest+0x30> name[0] = 'a'; 88b: c6 05 e0 a5 00 00 61 movb $0x61,0xa5e0 name[2] = '\0'; 892: c6 05 e2 a5 00 00 00 movb $0x0,0xa5e2 899: bb 30 00 00 00 mov $0x30,%ebx 89e: 66 90 xchg %ax,%ax unlink(name); 8a0: 83 ec 0c sub $0xc,%esp name[1] = '0' + i; 8a3: 88 1d e1 a5 00 00 mov %bl,0xa5e1 8a9: 83 c3 01 add $0x1,%ebx unlink(name); 8ac: 68 e0 a5 00 00 push $0xa5e0 8b1: e8 3c 30 00 00 call 38f2 <unlink> for(i = 0; i < 52; i++){ 8b6: 83 c4 10 add $0x10,%esp 8b9: 80 fb 64 cmp $0x64,%bl 8bc: 75 e2 jne 8a0 <createtest+0x70> printf(stdout, "many creates, followed by unlink; ok\n"); 8be: 83 ec 08 sub $0x8,%esp 8c1: 68 20 4e 00 00 push $0x4e20 8c6: ff 35 f8 5d 00 00 pushl 0x5df8 8cc: e8 1f 31 00 00 call 39f0 <printf> } 8d1: 83 c4 10 add $0x10,%esp 8d4: 8b 5d fc mov -0x4(%ebp),%ebx 8d7: c9 leave 8d8: c3 ret 8d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 000008e0 <dirtest>: { 8e0: 55 push %ebp 8e1: 89 e5 mov %esp,%ebp 8e3: 83 ec 10 sub $0x10,%esp printf(stdout, "mkdir test\n"); 8e6: 68 0c 40 00 00 push $0x400c 8eb: ff 35 f8 5d 00 00 pushl 0x5df8 8f1: e8 fa 30 00 00 call 39f0 <printf> if(mkdir("dir0") < 0){ 8f6: c7 04 24 18 40 00 00 movl $0x4018,(%esp) 8fd: e8 08 30 00 00 call 390a <mkdir> 902: 83 c4 10 add $0x10,%esp 905: 85 c0 test %eax,%eax 907: 78 58 js 961 <dirtest+0x81> if(chdir("dir0") < 0){ 909: 83 ec 0c sub $0xc,%esp 90c: 68 18 40 00 00 push $0x4018 911: e8 fc 2f 00 00 call 3912 <chdir> 916: 83 c4 10 add $0x10,%esp 919: 85 c0 test %eax,%eax 91b: 0f 88 85 00 00 00 js 9a6 <dirtest+0xc6> if(chdir("..") < 0){ 921: 83 ec 0c sub $0xc,%esp 924: 68 bd 45 00 00 push $0x45bd 929: e8 e4 2f 00 00 call 3912 <chdir> 92e: 83 c4 10 add $0x10,%esp 931: 85 c0 test %eax,%eax 933: 78 5a js 98f <dirtest+0xaf> if(unlink("dir0") < 0){ 935: 83 ec 0c sub $0xc,%esp 938: 68 18 40 00 00 push $0x4018 93d: e8 b0 2f 00 00 call 38f2 <unlink> 942: 83 c4 10 add $0x10,%esp 945: 85 c0 test %eax,%eax 947: 78 2f js 978 <dirtest+0x98> printf(stdout, "mkdir test ok\n"); 949: 83 ec 08 sub $0x8,%esp 94c: 68 55 40 00 00 push $0x4055 951: ff 35 f8 5d 00 00 pushl 0x5df8 957: e8 94 30 00 00 call 39f0 <printf> } 95c: 83 c4 10 add $0x10,%esp 95f: c9 leave 960: c3 ret printf(stdout, "mkdir failed\n"); 961: 50 push %eax 962: 50 push %eax 963: 68 48 3d 00 00 push $0x3d48 968: ff 35 f8 5d 00 00 pushl 0x5df8 96e: e8 7d 30 00 00 call 39f0 <printf> exit(); 973: e8 2a 2f 00 00 call 38a2 <exit> printf(stdout, "unlink dir0 failed\n"); 978: 50 push %eax 979: 50 push %eax 97a: 68 41 40 00 00 push $0x4041 97f: ff 35 f8 5d 00 00 pushl 0x5df8 985: e8 66 30 00 00 call 39f0 <printf> exit(); 98a: e8 13 2f 00 00 call 38a2 <exit> printf(stdout, "chdir .. failed\n"); 98f: 52 push %edx 990: 52 push %edx 991: 68 30 40 00 00 push $0x4030 996: ff 35 f8 5d 00 00 pushl 0x5df8 99c: e8 4f 30 00 00 call 39f0 <printf> exit(); 9a1: e8 fc 2e 00 00 call 38a2 <exit> printf(stdout, "chdir dir0 failed\n"); 9a6: 51 push %ecx 9a7: 51 push %ecx 9a8: 68 1d 40 00 00 push $0x401d 9ad: ff 35 f8 5d 00 00 pushl 0x5df8 9b3: e8 38 30 00 00 call 39f0 <printf> exit(); 9b8: e8 e5 2e 00 00 call 38a2 <exit> 9bd: 8d 76 00 lea 0x0(%esi),%esi 000009c0 <exectest>: { 9c0: 55 push %ebp 9c1: 89 e5 mov %esp,%ebp 9c3: 83 ec 10 sub $0x10,%esp printf(stdout, "exec test\n"); 9c6: 68 64 40 00 00 push $0x4064 9cb: ff 35 f8 5d 00 00 pushl 0x5df8 9d1: e8 1a 30 00 00 call 39f0 <printf> if(exec("echo", echoargv) < 0){ 9d6: 5a pop %edx 9d7: 59 pop %ecx 9d8: 68 fc 5d 00 00 push $0x5dfc 9dd: 68 2d 3e 00 00 push $0x3e2d 9e2: e8 f3 2e 00 00 call 38da <exec> 9e7: 83 c4 10 add $0x10,%esp 9ea: 85 c0 test %eax,%eax 9ec: 78 02 js 9f0 <exectest+0x30> } 9ee: c9 leave 9ef: c3 ret printf(stdout, "exec echo failed\n"); 9f0: 50 push %eax 9f1: 50 push %eax 9f2: 68 6f 40 00 00 push $0x406f 9f7: ff 35 f8 5d 00 00 pushl 0x5df8 9fd: e8 ee 2f 00 00 call 39f0 <printf> exit(); a02: e8 9b 2e 00 00 call 38a2 <exit> a07: 89 f6 mov %esi,%esi a09: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000a10 <pipe1>: { a10: 55 push %ebp a11: 89 e5 mov %esp,%ebp a13: 57 push %edi a14: 56 push %esi a15: 53 push %ebx if(pipe(fds) != 0){ a16: 8d 45 e0 lea -0x20(%ebp),%eax { a19: 83 ec 38 sub $0x38,%esp if(pipe(fds) != 0){ a1c: 50 push %eax a1d: e8 90 2e 00 00 call 38b2 <pipe> a22: 83 c4 10 add $0x10,%esp a25: 85 c0 test %eax,%eax a27: 0f 85 3e 01 00 00 jne b6b <pipe1+0x15b> a2d: 89 c3 mov %eax,%ebx pid = fork(); a2f: e8 66 2e 00 00 call 389a <fork> if(pid == 0){ a34: 83 f8 00 cmp $0x0,%eax a37: 0f 84 84 00 00 00 je ac1 <pipe1+0xb1> } else if(pid > 0){ a3d: 0f 8e 3b 01 00 00 jle b7e <pipe1+0x16e> close(fds[1]); a43: 83 ec 0c sub $0xc,%esp a46: ff 75 e4 pushl -0x1c(%ebp) cc = 1; a49: bf 01 00 00 00 mov $0x1,%edi close(fds[1]); a4e: e8 77 2e 00 00 call 38ca <close> while((n = read(fds[0], buf, cc)) > 0){ a53: 83 c4 10 add $0x10,%esp total = 0; a56: c7 45 d4 00 00 00 00 movl $0x0,-0x2c(%ebp) while((n = read(fds[0], buf, cc)) > 0){ a5d: 83 ec 04 sub $0x4,%esp a60: 57 push %edi a61: 68 e0 85 00 00 push $0x85e0 a66: ff 75 e0 pushl -0x20(%ebp) a69: e8 4c 2e 00 00 call 38ba <read> a6e: 83 c4 10 add $0x10,%esp a71: 85 c0 test %eax,%eax a73: 0f 8e ab 00 00 00 jle b24 <pipe1+0x114> if((buf[i] & 0xff) != (seq++ & 0xff)){ a79: 89 d9 mov %ebx,%ecx a7b: 8d 34 18 lea (%eax,%ebx,1),%esi a7e: f7 d9 neg %ecx a80: 38 9c 0b e0 85 00 00 cmp %bl,0x85e0(%ebx,%ecx,1) a87: 8d 53 01 lea 0x1(%ebx),%edx a8a: 75 1b jne aa7 <pipe1+0x97> for(i = 0; i < n; i++){ a8c: 39 f2 cmp %esi,%edx a8e: 89 d3 mov %edx,%ebx a90: 75 ee jne a80 <pipe1+0x70> cc = cc * 2; a92: 01 ff add %edi,%edi total += n; a94: 01 45 d4 add %eax,-0x2c(%ebp) a97: b8 00 20 00 00 mov $0x2000,%eax a9c: 81 ff 00 20 00 00 cmp $0x2000,%edi aa2: 0f 4f f8 cmovg %eax,%edi aa5: eb b6 jmp a5d <pipe1+0x4d> printf(1, "pipe1 oops 2\n"); aa7: 83 ec 08 sub $0x8,%esp aaa: 68 9e 40 00 00 push $0x409e aaf: 6a 01 push $0x1 ab1: e8 3a 2f 00 00 call 39f0 <printf> return; ab6: 83 c4 10 add $0x10,%esp } ab9: 8d 65 f4 lea -0xc(%ebp),%esp abc: 5b pop %ebx abd: 5e pop %esi abe: 5f pop %edi abf: 5d pop %ebp ac0: c3 ret close(fds[0]); ac1: 83 ec 0c sub $0xc,%esp ac4: ff 75 e0 pushl -0x20(%ebp) ac7: 31 db xor %ebx,%ebx ac9: be 09 04 00 00 mov $0x409,%esi ace: e8 f7 2d 00 00 call 38ca <close> ad3: 83 c4 10 add $0x10,%esp ad6: 89 d8 mov %ebx,%eax ad8: 89 f2 mov %esi,%edx ada: f7 d8 neg %eax adc: 29 da sub %ebx,%edx ade: 66 90 xchg %ax,%ax buf[i] = seq++; ae0: 88 84 03 e0 85 00 00 mov %al,0x85e0(%ebx,%eax,1) ae7: 83 c0 01 add $0x1,%eax for(i = 0; i < 1033; i++) aea: 39 d0 cmp %edx,%eax aec: 75 f2 jne ae0 <pipe1+0xd0> if(write(fds[1], buf, 1033) != 1033){ aee: 83 ec 04 sub $0x4,%esp af1: 68 09 04 00 00 push $0x409 af6: 68 e0 85 00 00 push $0x85e0 afb: ff 75 e4 pushl -0x1c(%ebp) afe: e8 bf 2d 00 00 call 38c2 <write> b03: 83 c4 10 add $0x10,%esp b06: 3d 09 04 00 00 cmp $0x409,%eax b0b: 0f 85 80 00 00 00 jne b91 <pipe1+0x181> b11: 81 eb 09 04 00 00 sub $0x409,%ebx for(n = 0; n < 5; n++){ b17: 81 fb d3 eb ff ff cmp $0xffffebd3,%ebx b1d: 75 b7 jne ad6 <pipe1+0xc6> exit(); b1f: e8 7e 2d 00 00 call 38a2 <exit> if(total != 5 * 1033){ b24: 81 7d d4 2d 14 00 00 cmpl $0x142d,-0x2c(%ebp) b2b: 75 29 jne b56 <pipe1+0x146> close(fds[0]); b2d: 83 ec 0c sub $0xc,%esp b30: ff 75 e0 pushl -0x20(%ebp) b33: e8 92 2d 00 00 call 38ca <close> wait(); b38: e8 6d 2d 00 00 call 38aa <wait> printf(1, "pipe1 ok\n"); b3d: 5a pop %edx b3e: 59 pop %ecx b3f: 68 c3 40 00 00 push $0x40c3 b44: 6a 01 push $0x1 b46: e8 a5 2e 00 00 call 39f0 <printf> b4b: 83 c4 10 add $0x10,%esp } b4e: 8d 65 f4 lea -0xc(%ebp),%esp b51: 5b pop %ebx b52: 5e pop %esi b53: 5f pop %edi b54: 5d pop %ebp b55: c3 ret printf(1, "pipe1 oops 3 total %d\n", total); b56: 53 push %ebx b57: ff 75 d4 pushl -0x2c(%ebp) b5a: 68 ac 40 00 00 push $0x40ac b5f: 6a 01 push $0x1 b61: e8 8a 2e 00 00 call 39f0 <printf> exit(); b66: e8 37 2d 00 00 call 38a2 <exit> printf(1, "pipe() failed\n"); b6b: 57 push %edi b6c: 57 push %edi b6d: 68 81 40 00 00 push $0x4081 b72: 6a 01 push $0x1 b74: e8 77 2e 00 00 call 39f0 <printf> exit(); b79: e8 24 2d 00 00 call 38a2 <exit> printf(1, "fork() failed\n"); b7e: 50 push %eax b7f: 50 push %eax b80: 68 cd 40 00 00 push $0x40cd b85: 6a 01 push $0x1 b87: e8 64 2e 00 00 call 39f0 <printf> exit(); b8c: e8 11 2d 00 00 call 38a2 <exit> printf(1, "pipe1 oops 1\n"); b91: 56 push %esi b92: 56 push %esi b93: 68 90 40 00 00 push $0x4090 b98: 6a 01 push $0x1 b9a: e8 51 2e 00 00 call 39f0 <printf> exit(); b9f: e8 fe 2c 00 00 call 38a2 <exit> ba4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi baa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000bb0 <preempt>: { bb0: 55 push %ebp bb1: 89 e5 mov %esp,%ebp bb3: 57 push %edi bb4: 56 push %esi bb5: 53 push %ebx bb6: 83 ec 24 sub $0x24,%esp printf(1, "preempt: "); bb9: 68 dc 40 00 00 push $0x40dc bbe: 6a 01 push $0x1 bc0: e8 2b 2e 00 00 call 39f0 <printf> pid1 = fork(); bc5: e8 d0 2c 00 00 call 389a <fork> if(pid1 == 0) bca: 83 c4 10 add $0x10,%esp bcd: 85 c0 test %eax,%eax bcf: 75 02 jne bd3 <preempt+0x23> bd1: eb fe jmp bd1 <preempt+0x21> bd3: 89 c7 mov %eax,%edi pid2 = fork(); bd5: e8 c0 2c 00 00 call 389a <fork> if(pid2 == 0) bda: 85 c0 test %eax,%eax pid2 = fork(); bdc: 89 c6 mov %eax,%esi if(pid2 == 0) bde: 75 02 jne be2 <preempt+0x32> be0: eb fe jmp be0 <preempt+0x30> pipe(pfds); be2: 8d 45 e0 lea -0x20(%ebp),%eax be5: 83 ec 0c sub $0xc,%esp be8: 50 push %eax be9: e8 c4 2c 00 00 call 38b2 <pipe> pid3 = fork(); bee: e8 a7 2c 00 00 call 389a <fork> if(pid3 == 0){ bf3: 83 c4 10 add $0x10,%esp bf6: 85 c0 test %eax,%eax pid3 = fork(); bf8: 89 c3 mov %eax,%ebx if(pid3 == 0){ bfa: 75 46 jne c42 <preempt+0x92> close(pfds[0]); bfc: 83 ec 0c sub $0xc,%esp bff: ff 75 e0 pushl -0x20(%ebp) c02: e8 c3 2c 00 00 call 38ca <close> if(write(pfds[1], "x", 1) != 1) c07: 83 c4 0c add $0xc,%esp c0a: 6a 01 push $0x1 c0c: 68 a1 46 00 00 push $0x46a1 c11: ff 75 e4 pushl -0x1c(%ebp) c14: e8 a9 2c 00 00 call 38c2 <write> c19: 83 c4 10 add $0x10,%esp c1c: 83 e8 01 sub $0x1,%eax c1f: 74 11 je c32 <preempt+0x82> printf(1, "preempt write error"); c21: 50 push %eax c22: 50 push %eax c23: 68 e6 40 00 00 push $0x40e6 c28: 6a 01 push $0x1 c2a: e8 c1 2d 00 00 call 39f0 <printf> c2f: 83 c4 10 add $0x10,%esp close(pfds[1]); c32: 83 ec 0c sub $0xc,%esp c35: ff 75 e4 pushl -0x1c(%ebp) c38: e8 8d 2c 00 00 call 38ca <close> c3d: 83 c4 10 add $0x10,%esp c40: eb fe jmp c40 <preempt+0x90> close(pfds[1]); c42: 83 ec 0c sub $0xc,%esp c45: ff 75 e4 pushl -0x1c(%ebp) c48: e8 7d 2c 00 00 call 38ca <close> if(read(pfds[0], buf, sizeof(buf)) != 1){ c4d: 83 c4 0c add $0xc,%esp c50: 68 00 20 00 00 push $0x2000 c55: 68 e0 85 00 00 push $0x85e0 c5a: ff 75 e0 pushl -0x20(%ebp) c5d: e8 58 2c 00 00 call 38ba <read> c62: 83 c4 10 add $0x10,%esp c65: 83 e8 01 sub $0x1,%eax c68: 74 19 je c83 <preempt+0xd3> printf(1, "preempt read error"); c6a: 50 push %eax c6b: 50 push %eax c6c: 68 fa 40 00 00 push $0x40fa c71: 6a 01 push $0x1 c73: e8 78 2d 00 00 call 39f0 <printf> return; c78: 83 c4 10 add $0x10,%esp } c7b: 8d 65 f4 lea -0xc(%ebp),%esp c7e: 5b pop %ebx c7f: 5e pop %esi c80: 5f pop %edi c81: 5d pop %ebp c82: c3 ret close(pfds[0]); c83: 83 ec 0c sub $0xc,%esp c86: ff 75 e0 pushl -0x20(%ebp) c89: e8 3c 2c 00 00 call 38ca <close> printf(1, "kill... "); c8e: 58 pop %eax c8f: 5a pop %edx c90: 68 0d 41 00 00 push $0x410d c95: 6a 01 push $0x1 c97: e8 54 2d 00 00 call 39f0 <printf> kill(pid1); c9c: 89 3c 24 mov %edi,(%esp) c9f: e8 2e 2c 00 00 call 38d2 <kill> kill(pid2); ca4: 89 34 24 mov %esi,(%esp) ca7: e8 26 2c 00 00 call 38d2 <kill> kill(pid3); cac: 89 1c 24 mov %ebx,(%esp) caf: e8 1e 2c 00 00 call 38d2 <kill> printf(1, "wait... "); cb4: 59 pop %ecx cb5: 5b pop %ebx cb6: 68 16 41 00 00 push $0x4116 cbb: 6a 01 push $0x1 cbd: e8 2e 2d 00 00 call 39f0 <printf> wait(); cc2: e8 e3 2b 00 00 call 38aa <wait> wait(); cc7: e8 de 2b 00 00 call 38aa <wait> wait(); ccc: e8 d9 2b 00 00 call 38aa <wait> printf(1, "preempt ok\n"); cd1: 5e pop %esi cd2: 5f pop %edi cd3: 68 1f 41 00 00 push $0x411f cd8: 6a 01 push $0x1 cda: e8 11 2d 00 00 call 39f0 <printf> cdf: 83 c4 10 add $0x10,%esp ce2: eb 97 jmp c7b <preempt+0xcb> ce4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi cea: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000cf0 <exitwait>: { cf0: 55 push %ebp cf1: 89 e5 mov %esp,%ebp cf3: 56 push %esi cf4: be 64 00 00 00 mov $0x64,%esi cf9: 53 push %ebx cfa: eb 14 jmp d10 <exitwait+0x20> cfc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(pid){ d00: 74 6f je d71 <exitwait+0x81> if(wait() != pid){ d02: e8 a3 2b 00 00 call 38aa <wait> d07: 39 d8 cmp %ebx,%eax d09: 75 2d jne d38 <exitwait+0x48> for(i = 0; i < 100; i++){ d0b: 83 ee 01 sub $0x1,%esi d0e: 74 48 je d58 <exitwait+0x68> pid = fork(); d10: e8 85 2b 00 00 call 389a <fork> if(pid < 0){ d15: 85 c0 test %eax,%eax pid = fork(); d17: 89 c3 mov %eax,%ebx if(pid < 0){ d19: 79 e5 jns d00 <exitwait+0x10> printf(1, "fork failed\n"); d1b: 83 ec 08 sub $0x8,%esp d1e: 68 89 4c 00 00 push $0x4c89 d23: 6a 01 push $0x1 d25: e8 c6 2c 00 00 call 39f0 <printf> return; d2a: 83 c4 10 add $0x10,%esp } d2d: 8d 65 f8 lea -0x8(%ebp),%esp d30: 5b pop %ebx d31: 5e pop %esi d32: 5d pop %ebp d33: c3 ret d34: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi printf(1, "wait wrong pid\n"); d38: 83 ec 08 sub $0x8,%esp d3b: 68 2b 41 00 00 push $0x412b d40: 6a 01 push $0x1 d42: e8 a9 2c 00 00 call 39f0 <printf> return; d47: 83 c4 10 add $0x10,%esp } d4a: 8d 65 f8 lea -0x8(%ebp),%esp d4d: 5b pop %ebx d4e: 5e pop %esi d4f: 5d pop %ebp d50: c3 ret d51: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi printf(1, "exitwait ok\n"); d58: 83 ec 08 sub $0x8,%esp d5b: 68 3b 41 00 00 push $0x413b d60: 6a 01 push $0x1 d62: e8 89 2c 00 00 call 39f0 <printf> d67: 83 c4 10 add $0x10,%esp } d6a: 8d 65 f8 lea -0x8(%ebp),%esp d6d: 5b pop %ebx d6e: 5e pop %esi d6f: 5d pop %ebp d70: c3 ret exit(); d71: e8 2c 2b 00 00 call 38a2 <exit> d76: 8d 76 00 lea 0x0(%esi),%esi d79: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000d80 <mem>: { d80: 55 push %ebp d81: 89 e5 mov %esp,%ebp d83: 57 push %edi d84: 56 push %esi d85: 53 push %ebx d86: 31 db xor %ebx,%ebx d88: 83 ec 14 sub $0x14,%esp printf(1, "mem test\n"); d8b: 68 48 41 00 00 push $0x4148 d90: 6a 01 push $0x1 d92: e8 59 2c 00 00 call 39f0 <printf> ppid = getpid(); d97: e8 86 2b 00 00 call 3922 <getpid> d9c: 89 c6 mov %eax,%esi if((pid = fork()) == 0){ d9e: e8 f7 2a 00 00 call 389a <fork> da3: 83 c4 10 add $0x10,%esp da6: 85 c0 test %eax,%eax da8: 74 0a je db4 <mem+0x34> daa: e9 89 00 00 00 jmp e38 <mem+0xb8> daf: 90 nop *(char**)m2 = m1; db0: 89 18 mov %ebx,(%eax) db2: 89 c3 mov %eax,%ebx while((m2 = malloc(10001)) != 0){ db4: 83 ec 0c sub $0xc,%esp db7: 68 11 27 00 00 push $0x2711 dbc: e8 8f 2e 00 00 call 3c50 <malloc> dc1: 83 c4 10 add $0x10,%esp dc4: 85 c0 test %eax,%eax dc6: 75 e8 jne db0 <mem+0x30> while(m1){ dc8: 85 db test %ebx,%ebx dca: 74 18 je de4 <mem+0x64> dcc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi m2 = *(char**)m1; dd0: 8b 3b mov (%ebx),%edi free(m1); dd2: 83 ec 0c sub $0xc,%esp dd5: 53 push %ebx dd6: 89 fb mov %edi,%ebx dd8: e8 e3 2d 00 00 call 3bc0 <free> while(m1){ ddd: 83 c4 10 add $0x10,%esp de0: 85 db test %ebx,%ebx de2: 75 ec jne dd0 <mem+0x50> m1 = malloc(1024*20); de4: 83 ec 0c sub $0xc,%esp de7: 68 00 50 00 00 push $0x5000 dec: e8 5f 2e 00 00 call 3c50 <malloc> if(m1 == 0){ df1: 83 c4 10 add $0x10,%esp df4: 85 c0 test %eax,%eax df6: 74 20 je e18 <mem+0x98> free(m1); df8: 83 ec 0c sub $0xc,%esp dfb: 50 push %eax dfc: e8 bf 2d 00 00 call 3bc0 <free> printf(1, "mem ok\n"); e01: 58 pop %eax e02: 5a pop %edx e03: 68 6c 41 00 00 push $0x416c e08: 6a 01 push $0x1 e0a: e8 e1 2b 00 00 call 39f0 <printf> exit(); e0f: e8 8e 2a 00 00 call 38a2 <exit> e14: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi printf(1, "couldn't allocate mem?!!\n"); e18: 83 ec 08 sub $0x8,%esp e1b: 68 52 41 00 00 push $0x4152 e20: 6a 01 push $0x1 e22: e8 c9 2b 00 00 call 39f0 <printf> kill(ppid); e27: 89 34 24 mov %esi,(%esp) e2a: e8 a3 2a 00 00 call 38d2 <kill> exit(); e2f: e8 6e 2a 00 00 call 38a2 <exit> e34: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } e38: 8d 65 f4 lea -0xc(%ebp),%esp e3b: 5b pop %ebx e3c: 5e pop %esi e3d: 5f pop %edi e3e: 5d pop %ebp wait(); e3f: e9 66 2a 00 00 jmp 38aa <wait> e44: 8d b6 00 00 00 00 lea 0x0(%esi),%esi e4a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000e50 <sharedfd>: { e50: 55 push %ebp e51: 89 e5 mov %esp,%ebp e53: 57 push %edi e54: 56 push %esi e55: 53 push %ebx e56: 83 ec 34 sub $0x34,%esp printf(1, "sharedfd test\n"); e59: 68 74 41 00 00 push $0x4174 e5e: 6a 01 push $0x1 e60: e8 8b 2b 00 00 call 39f0 <printf> unlink("sharedfd"); e65: c7 04 24 83 41 00 00 movl $0x4183,(%esp) e6c: e8 81 2a 00 00 call 38f2 <unlink> fd = open("sharedfd", O_CREATE|O_RDWR); e71: 59 pop %ecx e72: 5b pop %ebx e73: 68 02 02 00 00 push $0x202 e78: 68 83 41 00 00 push $0x4183 e7d: e8 60 2a 00 00 call 38e2 <open> if(fd < 0){ e82: 83 c4 10 add $0x10,%esp e85: 85 c0 test %eax,%eax e87: 0f 88 33 01 00 00 js fc0 <sharedfd+0x170> e8d: 89 c6 mov %eax,%esi memset(buf, pid==0?'c':'p', sizeof(buf)); e8f: bb e8 03 00 00 mov $0x3e8,%ebx pid = fork(); e94: e8 01 2a 00 00 call 389a <fork> memset(buf, pid==0?'c':'p', sizeof(buf)); e99: 83 f8 01 cmp $0x1,%eax pid = fork(); e9c: 89 c7 mov %eax,%edi memset(buf, pid==0?'c':'p', sizeof(buf)); e9e: 19 c0 sbb %eax,%eax ea0: 83 ec 04 sub $0x4,%esp ea3: 83 e0 f3 and $0xfffffff3,%eax ea6: 6a 0a push $0xa ea8: 83 c0 70 add $0x70,%eax eab: 50 push %eax eac: 8d 45 de lea -0x22(%ebp),%eax eaf: 50 push %eax eb0: e8 4b 28 00 00 call 3700 <memset> eb5: 83 c4 10 add $0x10,%esp eb8: eb 0b jmp ec5 <sharedfd+0x75> eba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi for(i = 0; i < 1000; i++){ ec0: 83 eb 01 sub $0x1,%ebx ec3: 74 29 je eee <sharedfd+0x9e> if(write(fd, buf, sizeof(buf)) != sizeof(buf)){ ec5: 8d 45 de lea -0x22(%ebp),%eax ec8: 83 ec 04 sub $0x4,%esp ecb: 6a 0a push $0xa ecd: 50 push %eax ece: 56 push %esi ecf: e8 ee 29 00 00 call 38c2 <write> ed4: 83 c4 10 add $0x10,%esp ed7: 83 f8 0a cmp $0xa,%eax eda: 74 e4 je ec0 <sharedfd+0x70> printf(1, "fstests: write sharedfd failed\n"); edc: 83 ec 08 sub $0x8,%esp edf: 68 74 4e 00 00 push $0x4e74 ee4: 6a 01 push $0x1 ee6: e8 05 2b 00 00 call 39f0 <printf> break; eeb: 83 c4 10 add $0x10,%esp if(pid == 0) eee: 85 ff test %edi,%edi ef0: 0f 84 fe 00 00 00 je ff4 <sharedfd+0x1a4> wait(); ef6: e8 af 29 00 00 call 38aa <wait> close(fd); efb: 83 ec 0c sub $0xc,%esp nc = np = 0; efe: 31 db xor %ebx,%ebx f00: 31 ff xor %edi,%edi close(fd); f02: 56 push %esi f03: 8d 75 e8 lea -0x18(%ebp),%esi f06: e8 bf 29 00 00 call 38ca <close> fd = open("sharedfd", 0); f0b: 58 pop %eax f0c: 5a pop %edx f0d: 6a 00 push $0x0 f0f: 68 83 41 00 00 push $0x4183 f14: e8 c9 29 00 00 call 38e2 <open> if(fd < 0){ f19: 83 c4 10 add $0x10,%esp f1c: 85 c0 test %eax,%eax fd = open("sharedfd", 0); f1e: 89 45 d4 mov %eax,-0x2c(%ebp) if(fd < 0){ f21: 0f 88 b3 00 00 00 js fda <sharedfd+0x18a> f27: 89 f8 mov %edi,%eax f29: 89 df mov %ebx,%edi f2b: 89 c3 mov %eax,%ebx f2d: 8d 76 00 lea 0x0(%esi),%esi while((n = read(fd, buf, sizeof(buf))) > 0){ f30: 8d 45 de lea -0x22(%ebp),%eax f33: 83 ec 04 sub $0x4,%esp f36: 6a 0a push $0xa f38: 50 push %eax f39: ff 75 d4 pushl -0x2c(%ebp) f3c: e8 79 29 00 00 call 38ba <read> f41: 83 c4 10 add $0x10,%esp f44: 85 c0 test %eax,%eax f46: 7e 28 jle f70 <sharedfd+0x120> f48: 8d 45 de lea -0x22(%ebp),%eax f4b: eb 15 jmp f62 <sharedfd+0x112> f4d: 8d 76 00 lea 0x0(%esi),%esi np++; f50: 80 fa 70 cmp $0x70,%dl f53: 0f 94 c2 sete %dl f56: 0f b6 d2 movzbl %dl,%edx f59: 01 d7 add %edx,%edi f5b: 83 c0 01 add $0x1,%eax for(i = 0; i < sizeof(buf); i++){ f5e: 39 f0 cmp %esi,%eax f60: 74 ce je f30 <sharedfd+0xe0> if(buf[i] == 'c') f62: 0f b6 10 movzbl (%eax),%edx f65: 80 fa 63 cmp $0x63,%dl f68: 75 e6 jne f50 <sharedfd+0x100> nc++; f6a: 83 c3 01 add $0x1,%ebx f6d: eb ec jmp f5b <sharedfd+0x10b> f6f: 90 nop close(fd); f70: 83 ec 0c sub $0xc,%esp f73: 89 d8 mov %ebx,%eax f75: ff 75 d4 pushl -0x2c(%ebp) f78: 89 fb mov %edi,%ebx f7a: 89 c7 mov %eax,%edi f7c: e8 49 29 00 00 call 38ca <close> unlink("sharedfd"); f81: c7 04 24 83 41 00 00 movl $0x4183,(%esp) f88: e8 65 29 00 00 call 38f2 <unlink> if(nc == 10000 && np == 10000){ f8d: 83 c4 10 add $0x10,%esp f90: 81 ff 10 27 00 00 cmp $0x2710,%edi f96: 75 61 jne ff9 <sharedfd+0x1a9> f98: 81 fb 10 27 00 00 cmp $0x2710,%ebx f9e: 75 59 jne ff9 <sharedfd+0x1a9> printf(1, "sharedfd ok\n"); fa0: 83 ec 08 sub $0x8,%esp fa3: 68 8c 41 00 00 push $0x418c fa8: 6a 01 push $0x1 faa: e8 41 2a 00 00 call 39f0 <printf> faf: 83 c4 10 add $0x10,%esp } fb2: 8d 65 f4 lea -0xc(%ebp),%esp fb5: 5b pop %ebx fb6: 5e pop %esi fb7: 5f pop %edi fb8: 5d pop %ebp fb9: c3 ret fba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi printf(1, "fstests: cannot open sharedfd for writing"); fc0: 83 ec 08 sub $0x8,%esp fc3: 68 48 4e 00 00 push $0x4e48 fc8: 6a 01 push $0x1 fca: e8 21 2a 00 00 call 39f0 <printf> return; fcf: 83 c4 10 add $0x10,%esp } fd2: 8d 65 f4 lea -0xc(%ebp),%esp fd5: 5b pop %ebx fd6: 5e pop %esi fd7: 5f pop %edi fd8: 5d pop %ebp fd9: c3 ret printf(1, "fstests: cannot open sharedfd for reading\n"); fda: 83 ec 08 sub $0x8,%esp fdd: 68 94 4e 00 00 push $0x4e94 fe2: 6a 01 push $0x1 fe4: e8 07 2a 00 00 call 39f0 <printf> return; fe9: 83 c4 10 add $0x10,%esp } fec: 8d 65 f4 lea -0xc(%ebp),%esp fef: 5b pop %ebx ff0: 5e pop %esi ff1: 5f pop %edi ff2: 5d pop %ebp ff3: c3 ret exit(); ff4: e8 a9 28 00 00 call 38a2 <exit> printf(1, "sharedfd oops %d %d\n", nc, np); ff9: 53 push %ebx ffa: 57 push %edi ffb: 68 99 41 00 00 push $0x4199 1000: 6a 01 push $0x1 1002: e8 e9 29 00 00 call 39f0 <printf> exit(); 1007: e8 96 28 00 00 call 38a2 <exit> 100c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00001010 <fourfiles>: { 1010: 55 push %ebp 1011: 89 e5 mov %esp,%ebp 1013: 57 push %edi 1014: 56 push %esi 1015: 53 push %ebx printf(1, "fourfiles test\n"); 1016: be ae 41 00 00 mov $0x41ae,%esi for(pi = 0; pi < 4; pi++){ 101b: 31 db xor %ebx,%ebx { 101d: 83 ec 34 sub $0x34,%esp char *names[] = { "f0", "f1", "f2", "f3" }; 1020: c7 45 d8 ae 41 00 00 movl $0x41ae,-0x28(%ebp) 1027: c7 45 dc f7 42 00 00 movl $0x42f7,-0x24(%ebp) printf(1, "fourfiles test\n"); 102e: 68 b4 41 00 00 push $0x41b4 1033: 6a 01 push $0x1 char *names[] = { "f0", "f1", "f2", "f3" }; 1035: c7 45 e0 fb 42 00 00 movl $0x42fb,-0x20(%ebp) 103c: c7 45 e4 b1 41 00 00 movl $0x41b1,-0x1c(%ebp) printf(1, "fourfiles test\n"); 1043: e8 a8 29 00 00 call 39f0 <printf> 1048: 83 c4 10 add $0x10,%esp unlink(fname); 104b: 83 ec 0c sub $0xc,%esp 104e: 56 push %esi 104f: e8 9e 28 00 00 call 38f2 <unlink> pid = fork(); 1054: e8 41 28 00 00 call 389a <fork> if(pid < 0){ 1059: 83 c4 10 add $0x10,%esp 105c: 85 c0 test %eax,%eax 105e: 0f 88 68 01 00 00 js 11cc <fourfiles+0x1bc> if(pid == 0){ 1064: 0f 84 df 00 00 00 je 1149 <fourfiles+0x139> for(pi = 0; pi < 4; pi++){ 106a: 83 c3 01 add $0x1,%ebx 106d: 83 fb 04 cmp $0x4,%ebx 1070: 74 06 je 1078 <fourfiles+0x68> 1072: 8b 74 9d d8 mov -0x28(%ebp,%ebx,4),%esi 1076: eb d3 jmp 104b <fourfiles+0x3b> wait(); 1078: e8 2d 28 00 00 call 38aa <wait> for(i = 0; i < 2; i++){ 107d: 31 ff xor %edi,%edi wait(); 107f: e8 26 28 00 00 call 38aa <wait> 1084: e8 21 28 00 00 call 38aa <wait> 1089: e8 1c 28 00 00 call 38aa <wait> 108e: c7 45 d0 ae 41 00 00 movl $0x41ae,-0x30(%ebp) fd = open(fname, 0); 1095: 83 ec 08 sub $0x8,%esp total = 0; 1098: 31 db xor %ebx,%ebx fd = open(fname, 0); 109a: 6a 00 push $0x0 109c: ff 75 d0 pushl -0x30(%ebp) 109f: e8 3e 28 00 00 call 38e2 <open> while((n = read(fd, buf, sizeof(buf))) > 0){ 10a4: 83 c4 10 add $0x10,%esp fd = open(fname, 0); 10a7: 89 45 d4 mov %eax,-0x2c(%ebp) 10aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi while((n = read(fd, buf, sizeof(buf))) > 0){ 10b0: 83 ec 04 sub $0x4,%esp 10b3: 68 00 20 00 00 push $0x2000 10b8: 68 e0 85 00 00 push $0x85e0 10bd: ff 75 d4 pushl -0x2c(%ebp) 10c0: e8 f5 27 00 00 call 38ba <read> 10c5: 83 c4 10 add $0x10,%esp 10c8: 85 c0 test %eax,%eax 10ca: 7e 26 jle 10f2 <fourfiles+0xe2> for(j = 0; j < n; j++){ 10cc: 31 d2 xor %edx,%edx 10ce: 66 90 xchg %ax,%ax if(buf[j] != '0'+i){ 10d0: 0f be b2 e0 85 00 00 movsbl 0x85e0(%edx),%esi 10d7: 83 ff 01 cmp $0x1,%edi 10da: 19 c9 sbb %ecx,%ecx 10dc: 83 c1 31 add $0x31,%ecx 10df: 39 ce cmp %ecx,%esi 10e1: 0f 85 be 00 00 00 jne 11a5 <fourfiles+0x195> for(j = 0; j < n; j++){ 10e7: 83 c2 01 add $0x1,%edx 10ea: 39 d0 cmp %edx,%eax 10ec: 75 e2 jne 10d0 <fourfiles+0xc0> total += n; 10ee: 01 c3 add %eax,%ebx 10f0: eb be jmp 10b0 <fourfiles+0xa0> close(fd); 10f2: 83 ec 0c sub $0xc,%esp 10f5: ff 75 d4 pushl -0x2c(%ebp) 10f8: e8 cd 27 00 00 call 38ca <close> if(total != 12*500){ 10fd: 83 c4 10 add $0x10,%esp 1100: 81 fb 70 17 00 00 cmp $0x1770,%ebx 1106: 0f 85 d3 00 00 00 jne 11df <fourfiles+0x1cf> unlink(fname); 110c: 83 ec 0c sub $0xc,%esp 110f: ff 75 d0 pushl -0x30(%ebp) 1112: e8 db 27 00 00 call 38f2 <unlink> for(i = 0; i < 2; i++){ 1117: 83 c4 10 add $0x10,%esp 111a: 83 ff 01 cmp $0x1,%edi 111d: 75 1a jne 1139 <fourfiles+0x129> printf(1, "fourfiles ok\n"); 111f: 83 ec 08 sub $0x8,%esp 1122: 68 f2 41 00 00 push $0x41f2 1127: 6a 01 push $0x1 1129: e8 c2 28 00 00 call 39f0 <printf> } 112e: 83 c4 10 add $0x10,%esp 1131: 8d 65 f4 lea -0xc(%ebp),%esp 1134: 5b pop %ebx 1135: 5e pop %esi 1136: 5f pop %edi 1137: 5d pop %ebp 1138: c3 ret 1139: 8b 45 dc mov -0x24(%ebp),%eax 113c: bf 01 00 00 00 mov $0x1,%edi 1141: 89 45 d0 mov %eax,-0x30(%ebp) 1144: e9 4c ff ff ff jmp 1095 <fourfiles+0x85> fd = open(fname, O_CREATE | O_RDWR); 1149: 83 ec 08 sub $0x8,%esp 114c: 68 02 02 00 00 push $0x202 1151: 56 push %esi 1152: e8 8b 27 00 00 call 38e2 <open> if(fd < 0){ 1157: 83 c4 10 add $0x10,%esp 115a: 85 c0 test %eax,%eax fd = open(fname, O_CREATE | O_RDWR); 115c: 89 c6 mov %eax,%esi if(fd < 0){ 115e: 78 59 js 11b9 <fourfiles+0x1a9> memset(buf, '0'+pi, 512); 1160: 83 ec 04 sub $0x4,%esp 1163: 83 c3 30 add $0x30,%ebx 1166: 68 00 02 00 00 push $0x200 116b: 53 push %ebx 116c: bb 0c 00 00 00 mov $0xc,%ebx 1171: 68 e0 85 00 00 push $0x85e0 1176: e8 85 25 00 00 call 3700 <memset> 117b: 83 c4 10 add $0x10,%esp if((n = write(fd, buf, 500)) != 500){ 117e: 83 ec 04 sub $0x4,%esp 1181: 68 f4 01 00 00 push $0x1f4 1186: 68 e0 85 00 00 push $0x85e0 118b: 56 push %esi 118c: e8 31 27 00 00 call 38c2 <write> 1191: 83 c4 10 add $0x10,%esp 1194: 3d f4 01 00 00 cmp $0x1f4,%eax 1199: 75 57 jne 11f2 <fourfiles+0x1e2> for(i = 0; i < 12; i++){ 119b: 83 eb 01 sub $0x1,%ebx 119e: 75 de jne 117e <fourfiles+0x16e> exit(); 11a0: e8 fd 26 00 00 call 38a2 <exit> printf(1, "wrong char\n"); 11a5: 83 ec 08 sub $0x8,%esp 11a8: 68 d5 41 00 00 push $0x41d5 11ad: 6a 01 push $0x1 11af: e8 3c 28 00 00 call 39f0 <printf> exit(); 11b4: e8 e9 26 00 00 call 38a2 <exit> printf(1, "create failed\n"); 11b9: 51 push %ecx 11ba: 51 push %ecx 11bb: 68 4f 44 00 00 push $0x444f 11c0: 6a 01 push $0x1 11c2: e8 29 28 00 00 call 39f0 <printf> exit(); 11c7: e8 d6 26 00 00 call 38a2 <exit> printf(1, "fork failed\n"); 11cc: 53 push %ebx 11cd: 53 push %ebx 11ce: 68 89 4c 00 00 push $0x4c89 11d3: 6a 01 push $0x1 11d5: e8 16 28 00 00 call 39f0 <printf> exit(); 11da: e8 c3 26 00 00 call 38a2 <exit> printf(1, "wrong length %d\n", total); 11df: 50 push %eax 11e0: 53 push %ebx 11e1: 68 e1 41 00 00 push $0x41e1 11e6: 6a 01 push $0x1 11e8: e8 03 28 00 00 call 39f0 <printf> exit(); 11ed: e8 b0 26 00 00 call 38a2 <exit> printf(1, "write failed %d\n", n); 11f2: 52 push %edx 11f3: 50 push %eax 11f4: 68 c4 41 00 00 push $0x41c4 11f9: 6a 01 push $0x1 11fb: e8 f0 27 00 00 call 39f0 <printf> exit(); 1200: e8 9d 26 00 00 call 38a2 <exit> 1205: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 1209: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00001210 <createdelete>: { 1210: 55 push %ebp 1211: 89 e5 mov %esp,%ebp 1213: 57 push %edi 1214: 56 push %esi 1215: 53 push %ebx for(pi = 0; pi < 4; pi++){ 1216: 31 db xor %ebx,%ebx { 1218: 83 ec 44 sub $0x44,%esp printf(1, "createdelete test\n"); 121b: 68 00 42 00 00 push $0x4200 1220: 6a 01 push $0x1 1222: e8 c9 27 00 00 call 39f0 <printf> 1227: 83 c4 10 add $0x10,%esp pid = fork(); 122a: e8 6b 26 00 00 call 389a <fork> if(pid < 0){ 122f: 85 c0 test %eax,%eax 1231: 0f 88 be 01 00 00 js 13f5 <createdelete+0x1e5> if(pid == 0){ 1237: 0f 84 0b 01 00 00 je 1348 <createdelete+0x138> for(pi = 0; pi < 4; pi++){ 123d: 83 c3 01 add $0x1,%ebx 1240: 83 fb 04 cmp $0x4,%ebx 1243: 75 e5 jne 122a <createdelete+0x1a> 1245: 8d 7d c8 lea -0x38(%ebp),%edi name[0] = name[1] = name[2] = 0; 1248: be ff ff ff ff mov $0xffffffff,%esi wait(); 124d: e8 58 26 00 00 call 38aa <wait> 1252: e8 53 26 00 00 call 38aa <wait> 1257: e8 4e 26 00 00 call 38aa <wait> 125c: e8 49 26 00 00 call 38aa <wait> name[0] = name[1] = name[2] = 0; 1261: c6 45 ca 00 movb $0x0,-0x36(%ebp) 1265: 8d 76 00 lea 0x0(%esi),%esi 1268: 8d 46 31 lea 0x31(%esi),%eax 126b: 88 45 c7 mov %al,-0x39(%ebp) 126e: 8d 46 01 lea 0x1(%esi),%eax 1271: 83 f8 09 cmp $0x9,%eax 1274: 89 45 c0 mov %eax,-0x40(%ebp) 1277: 0f 9f c3 setg %bl 127a: 85 c0 test %eax,%eax 127c: 0f 94 c0 sete %al 127f: 09 c3 or %eax,%ebx 1281: 88 5d c6 mov %bl,-0x3a(%ebp) name[2] = '\0'; 1284: bb 70 00 00 00 mov $0x70,%ebx name[1] = '0' + i; 1289: 0f b6 45 c7 movzbl -0x39(%ebp),%eax fd = open(name, 0); 128d: 83 ec 08 sub $0x8,%esp name[0] = 'p' + pi; 1290: 88 5d c8 mov %bl,-0x38(%ebp) fd = open(name, 0); 1293: 6a 00 push $0x0 1295: 57 push %edi name[1] = '0' + i; 1296: 88 45 c9 mov %al,-0x37(%ebp) fd = open(name, 0); 1299: e8 44 26 00 00 call 38e2 <open> if((i == 0 || i >= N/2) && fd < 0){ 129e: 83 c4 10 add $0x10,%esp 12a1: 80 7d c6 00 cmpb $0x0,-0x3a(%ebp) 12a5: 0f 84 85 00 00 00 je 1330 <createdelete+0x120> 12ab: 85 c0 test %eax,%eax 12ad: 0f 88 1a 01 00 00 js 13cd <createdelete+0x1bd> } else if((i >= 1 && i < N/2) && fd >= 0){ 12b3: 83 fe 08 cmp $0x8,%esi 12b6: 0f 86 54 01 00 00 jbe 1410 <createdelete+0x200> close(fd); 12bc: 83 ec 0c sub $0xc,%esp 12bf: 50 push %eax 12c0: e8 05 26 00 00 call 38ca <close> 12c5: 83 c4 10 add $0x10,%esp 12c8: 83 c3 01 add $0x1,%ebx for(pi = 0; pi < 4; pi++){ 12cb: 80 fb 74 cmp $0x74,%bl 12ce: 75 b9 jne 1289 <createdelete+0x79> 12d0: 8b 75 c0 mov -0x40(%ebp),%esi for(i = 0; i < N; i++){ 12d3: 83 fe 13 cmp $0x13,%esi 12d6: 75 90 jne 1268 <createdelete+0x58> 12d8: be 70 00 00 00 mov $0x70,%esi 12dd: 8d 76 00 lea 0x0(%esi),%esi 12e0: 8d 46 c0 lea -0x40(%esi),%eax name[0] = name[1] = name[2] = 0; 12e3: bb 04 00 00 00 mov $0x4,%ebx 12e8: 88 45 c7 mov %al,-0x39(%ebp) name[0] = 'p' + i; 12eb: 89 f0 mov %esi,%eax unlink(name); 12ed: 83 ec 0c sub $0xc,%esp name[0] = 'p' + i; 12f0: 88 45 c8 mov %al,-0x38(%ebp) name[1] = '0' + i; 12f3: 0f b6 45 c7 movzbl -0x39(%ebp),%eax unlink(name); 12f7: 57 push %edi name[1] = '0' + i; 12f8: 88 45 c9 mov %al,-0x37(%ebp) unlink(name); 12fb: e8 f2 25 00 00 call 38f2 <unlink> for(pi = 0; pi < 4; pi++){ 1300: 83 c4 10 add $0x10,%esp 1303: 83 eb 01 sub $0x1,%ebx 1306: 75 e3 jne 12eb <createdelete+0xdb> 1308: 83 c6 01 add $0x1,%esi for(i = 0; i < N; i++){ 130b: 89 f0 mov %esi,%eax 130d: 3c 84 cmp $0x84,%al 130f: 75 cf jne 12e0 <createdelete+0xd0> printf(1, "createdelete ok\n"); 1311: 83 ec 08 sub $0x8,%esp 1314: 68 13 42 00 00 push $0x4213 1319: 6a 01 push $0x1 131b: e8 d0 26 00 00 call 39f0 <printf> } 1320: 8d 65 f4 lea -0xc(%ebp),%esp 1323: 5b pop %ebx 1324: 5e pop %esi 1325: 5f pop %edi 1326: 5d pop %ebp 1327: c3 ret 1328: 90 nop 1329: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi } else if((i >= 1 && i < N/2) && fd >= 0){ 1330: 83 fe 08 cmp $0x8,%esi 1333: 0f 86 cf 00 00 00 jbe 1408 <createdelete+0x1f8> if(fd >= 0) 1339: 85 c0 test %eax,%eax 133b: 78 8b js 12c8 <createdelete+0xb8> 133d: e9 7a ff ff ff jmp 12bc <createdelete+0xac> 1342: 8d b6 00 00 00 00 lea 0x0(%esi),%esi name[0] = 'p' + pi; 1348: 83 c3 70 add $0x70,%ebx name[2] = '\0'; 134b: c6 45 ca 00 movb $0x0,-0x36(%ebp) 134f: 8d 7d c8 lea -0x38(%ebp),%edi name[0] = 'p' + pi; 1352: 88 5d c8 mov %bl,-0x38(%ebp) name[2] = '\0'; 1355: 31 db xor %ebx,%ebx 1357: eb 0f jmp 1368 <createdelete+0x158> 1359: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi for(i = 0; i < N; i++){ 1360: 83 fb 13 cmp $0x13,%ebx 1363: 74 63 je 13c8 <createdelete+0x1b8> 1365: 83 c3 01 add $0x1,%ebx fd = open(name, O_CREATE | O_RDWR); 1368: 83 ec 08 sub $0x8,%esp name[1] = '0' + i; 136b: 8d 43 30 lea 0x30(%ebx),%eax fd = open(name, O_CREATE | O_RDWR); 136e: 68 02 02 00 00 push $0x202 1373: 57 push %edi name[1] = '0' + i; 1374: 88 45 c9 mov %al,-0x37(%ebp) fd = open(name, O_CREATE | O_RDWR); 1377: e8 66 25 00 00 call 38e2 <open> if(fd < 0){ 137c: 83 c4 10 add $0x10,%esp 137f: 85 c0 test %eax,%eax 1381: 78 5f js 13e2 <createdelete+0x1d2> close(fd); 1383: 83 ec 0c sub $0xc,%esp 1386: 50 push %eax 1387: e8 3e 25 00 00 call 38ca <close> if(i > 0 && (i % 2 ) == 0){ 138c: 83 c4 10 add $0x10,%esp 138f: 85 db test %ebx,%ebx 1391: 74 d2 je 1365 <createdelete+0x155> 1393: f6 c3 01 test $0x1,%bl 1396: 75 c8 jne 1360 <createdelete+0x150> if(unlink(name) < 0){ 1398: 83 ec 0c sub $0xc,%esp name[1] = '0' + (i / 2); 139b: 89 d8 mov %ebx,%eax 139d: d1 f8 sar %eax if(unlink(name) < 0){ 139f: 57 push %edi name[1] = '0' + (i / 2); 13a0: 83 c0 30 add $0x30,%eax 13a3: 88 45 c9 mov %al,-0x37(%ebp) if(unlink(name) < 0){ 13a6: e8 47 25 00 00 call 38f2 <unlink> 13ab: 83 c4 10 add $0x10,%esp 13ae: 85 c0 test %eax,%eax 13b0: 79 ae jns 1360 <createdelete+0x150> printf(1, "unlink failed\n"); 13b2: 52 push %edx 13b3: 52 push %edx 13b4: 68 01 3e 00 00 push $0x3e01 13b9: 6a 01 push $0x1 13bb: e8 30 26 00 00 call 39f0 <printf> exit(); 13c0: e8 dd 24 00 00 call 38a2 <exit> 13c5: 8d 76 00 lea 0x0(%esi),%esi exit(); 13c8: e8 d5 24 00 00 call 38a2 <exit> printf(1, "oops createdelete %s didn't exist\n", name); 13cd: 83 ec 04 sub $0x4,%esp 13d0: 57 push %edi 13d1: 68 c0 4e 00 00 push $0x4ec0 13d6: 6a 01 push $0x1 13d8: e8 13 26 00 00 call 39f0 <printf> exit(); 13dd: e8 c0 24 00 00 call 38a2 <exit> printf(1, "create failed\n"); 13e2: 51 push %ecx 13e3: 51 push %ecx 13e4: 68 4f 44 00 00 push $0x444f 13e9: 6a 01 push $0x1 13eb: e8 00 26 00 00 call 39f0 <printf> exit(); 13f0: e8 ad 24 00 00 call 38a2 <exit> printf(1, "fork failed\n"); 13f5: 53 push %ebx 13f6: 53 push %ebx 13f7: 68 89 4c 00 00 push $0x4c89 13fc: 6a 01 push $0x1 13fe: e8 ed 25 00 00 call 39f0 <printf> exit(); 1403: e8 9a 24 00 00 call 38a2 <exit> } else if((i >= 1 && i < N/2) && fd >= 0){ 1408: 85 c0 test %eax,%eax 140a: 0f 88 b8 fe ff ff js 12c8 <createdelete+0xb8> printf(1, "oops createdelete %s did exist\n", name); 1410: 50 push %eax 1411: 57 push %edi 1412: 68 e4 4e 00 00 push $0x4ee4 1417: 6a 01 push $0x1 1419: e8 d2 25 00 00 call 39f0 <printf> exit(); 141e: e8 7f 24 00 00 call 38a2 <exit> 1423: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 1429: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00001430 <unlinkread>: { 1430: 55 push %ebp 1431: 89 e5 mov %esp,%ebp 1433: 56 push %esi 1434: 53 push %ebx printf(1, "unlinkread test\n"); 1435: 83 ec 08 sub $0x8,%esp 1438: 68 24 42 00 00 push $0x4224 143d: 6a 01 push $0x1 143f: e8 ac 25 00 00 call 39f0 <printf> fd = open("unlinkread", O_CREATE | O_RDWR); 1444: 5b pop %ebx 1445: 5e pop %esi 1446: 68 02 02 00 00 push $0x202 144b: 68 35 42 00 00 push $0x4235 1450: e8 8d 24 00 00 call 38e2 <open> if(fd < 0){ 1455: 83 c4 10 add $0x10,%esp 1458: 85 c0 test %eax,%eax 145a: 0f 88 e6 00 00 00 js 1546 <unlinkread+0x116> write(fd, "hello", 5); 1460: 83 ec 04 sub $0x4,%esp 1463: 89 c3 mov %eax,%ebx 1465: 6a 05 push $0x5 1467: 68 5a 42 00 00 push $0x425a 146c: 50 push %eax 146d: e8 50 24 00 00 call 38c2 <write> close(fd); 1472: 89 1c 24 mov %ebx,(%esp) 1475: e8 50 24 00 00 call 38ca <close> fd = open("unlinkread", O_RDWR); 147a: 58 pop %eax 147b: 5a pop %edx 147c: 6a 02 push $0x2 147e: 68 35 42 00 00 push $0x4235 1483: e8 5a 24 00 00 call 38e2 <open> if(fd < 0){ 1488: 83 c4 10 add $0x10,%esp 148b: 85 c0 test %eax,%eax fd = open("unlinkread", O_RDWR); 148d: 89 c3 mov %eax,%ebx if(fd < 0){ 148f: 0f 88 10 01 00 00 js 15a5 <unlinkread+0x175> if(unlink("unlinkread") != 0){ 1495: 83 ec 0c sub $0xc,%esp 1498: 68 35 42 00 00 push $0x4235 149d: e8 50 24 00 00 call 38f2 <unlink> 14a2: 83 c4 10 add $0x10,%esp 14a5: 85 c0 test %eax,%eax 14a7: 0f 85 e5 00 00 00 jne 1592 <unlinkread+0x162> fd1 = open("unlinkread", O_CREATE | O_RDWR); 14ad: 83 ec 08 sub $0x8,%esp 14b0: 68 02 02 00 00 push $0x202 14b5: 68 35 42 00 00 push $0x4235 14ba: e8 23 24 00 00 call 38e2 <open> write(fd1, "yyy", 3); 14bf: 83 c4 0c add $0xc,%esp fd1 = open("unlinkread", O_CREATE | O_RDWR); 14c2: 89 c6 mov %eax,%esi write(fd1, "yyy", 3); 14c4: 6a 03 push $0x3 14c6: 68 92 42 00 00 push $0x4292 14cb: 50 push %eax 14cc: e8 f1 23 00 00 call 38c2 <write> close(fd1); 14d1: 89 34 24 mov %esi,(%esp) 14d4: e8 f1 23 00 00 call 38ca <close> if(read(fd, buf, sizeof(buf)) != 5){ 14d9: 83 c4 0c add $0xc,%esp 14dc: 68 00 20 00 00 push $0x2000 14e1: 68 e0 85 00 00 push $0x85e0 14e6: 53 push %ebx 14e7: e8 ce 23 00 00 call 38ba <read> 14ec: 83 c4 10 add $0x10,%esp 14ef: 83 f8 05 cmp $0x5,%eax 14f2: 0f 85 87 00 00 00 jne 157f <unlinkread+0x14f> if(buf[0] != 'h'){ 14f8: 80 3d e0 85 00 00 68 cmpb $0x68,0x85e0 14ff: 75 6b jne 156c <unlinkread+0x13c> if(write(fd, buf, 10) != 10){ 1501: 83 ec 04 sub $0x4,%esp 1504: 6a 0a push $0xa 1506: 68 e0 85 00 00 push $0x85e0 150b: 53 push %ebx 150c: e8 b1 23 00 00 call 38c2 <write> 1511: 83 c4 10 add $0x10,%esp 1514: 83 f8 0a cmp $0xa,%eax 1517: 75 40 jne 1559 <unlinkread+0x129> close(fd); 1519: 83 ec 0c sub $0xc,%esp 151c: 53 push %ebx 151d: e8 a8 23 00 00 call 38ca <close> unlink("unlinkread"); 1522: c7 04 24 35 42 00 00 movl $0x4235,(%esp) 1529: e8 c4 23 00 00 call 38f2 <unlink> printf(1, "unlinkread ok\n"); 152e: 58 pop %eax 152f: 5a pop %edx 1530: 68 dd 42 00 00 push $0x42dd 1535: 6a 01 push $0x1 1537: e8 b4 24 00 00 call 39f0 <printf> } 153c: 83 c4 10 add $0x10,%esp 153f: 8d 65 f8 lea -0x8(%ebp),%esp 1542: 5b pop %ebx 1543: 5e pop %esi 1544: 5d pop %ebp 1545: c3 ret printf(1, "create unlinkread failed\n"); 1546: 51 push %ecx 1547: 51 push %ecx 1548: 68 40 42 00 00 push $0x4240 154d: 6a 01 push $0x1 154f: e8 9c 24 00 00 call 39f0 <printf> exit(); 1554: e8 49 23 00 00 call 38a2 <exit> printf(1, "unlinkread write failed\n"); 1559: 51 push %ecx 155a: 51 push %ecx 155b: 68 c4 42 00 00 push $0x42c4 1560: 6a 01 push $0x1 1562: e8 89 24 00 00 call 39f0 <printf> exit(); 1567: e8 36 23 00 00 call 38a2 <exit> printf(1, "unlinkread wrong data\n"); 156c: 53 push %ebx 156d: 53 push %ebx 156e: 68 ad 42 00 00 push $0x42ad 1573: 6a 01 push $0x1 1575: e8 76 24 00 00 call 39f0 <printf> exit(); 157a: e8 23 23 00 00 call 38a2 <exit> printf(1, "unlinkread read failed"); 157f: 56 push %esi 1580: 56 push %esi 1581: 68 96 42 00 00 push $0x4296 1586: 6a 01 push $0x1 1588: e8 63 24 00 00 call 39f0 <printf> exit(); 158d: e8 10 23 00 00 call 38a2 <exit> printf(1, "unlink unlinkread failed\n"); 1592: 50 push %eax 1593: 50 push %eax 1594: 68 78 42 00 00 push $0x4278 1599: 6a 01 push $0x1 159b: e8 50 24 00 00 call 39f0 <printf> exit(); 15a0: e8 fd 22 00 00 call 38a2 <exit> printf(1, "open unlinkread failed\n"); 15a5: 50 push %eax 15a6: 50 push %eax 15a7: 68 60 42 00 00 push $0x4260 15ac: 6a 01 push $0x1 15ae: e8 3d 24 00 00 call 39f0 <printf> exit(); 15b3: e8 ea 22 00 00 call 38a2 <exit> 15b8: 90 nop 15b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 000015c0 <linktest>: { 15c0: 55 push %ebp 15c1: 89 e5 mov %esp,%ebp 15c3: 53 push %ebx 15c4: 83 ec 0c sub $0xc,%esp printf(1, "linktest\n"); 15c7: 68 ec 42 00 00 push $0x42ec 15cc: 6a 01 push $0x1 15ce: e8 1d 24 00 00 call 39f0 <printf> unlink("lf1"); 15d3: c7 04 24 f6 42 00 00 movl $0x42f6,(%esp) 15da: e8 13 23 00 00 call 38f2 <unlink> unlink("lf2"); 15df: c7 04 24 fa 42 00 00 movl $0x42fa,(%esp) 15e6: e8 07 23 00 00 call 38f2 <unlink> fd = open("lf1", O_CREATE|O_RDWR); 15eb: 58 pop %eax 15ec: 5a pop %edx 15ed: 68 02 02 00 00 push $0x202 15f2: 68 f6 42 00 00 push $0x42f6 15f7: e8 e6 22 00 00 call 38e2 <open> if(fd < 0){ 15fc: 83 c4 10 add $0x10,%esp 15ff: 85 c0 test %eax,%eax 1601: 0f 88 1e 01 00 00 js 1725 <linktest+0x165> if(write(fd, "hello", 5) != 5){ 1607: 83 ec 04 sub $0x4,%esp 160a: 89 c3 mov %eax,%ebx 160c: 6a 05 push $0x5 160e: 68 5a 42 00 00 push $0x425a 1613: 50 push %eax 1614: e8 a9 22 00 00 call 38c2 <write> 1619: 83 c4 10 add $0x10,%esp 161c: 83 f8 05 cmp $0x5,%eax 161f: 0f 85 98 01 00 00 jne 17bd <linktest+0x1fd> close(fd); 1625: 83 ec 0c sub $0xc,%esp 1628: 53 push %ebx 1629: e8 9c 22 00 00 call 38ca <close> if(link("lf1", "lf2") < 0){ 162e: 5b pop %ebx 162f: 58 pop %eax 1630: 68 fa 42 00 00 push $0x42fa 1635: 68 f6 42 00 00 push $0x42f6 163a: e8 c3 22 00 00 call 3902 <link> 163f: 83 c4 10 add $0x10,%esp 1642: 85 c0 test %eax,%eax 1644: 0f 88 60 01 00 00 js 17aa <linktest+0x1ea> unlink("lf1"); 164a: 83 ec 0c sub $0xc,%esp 164d: 68 f6 42 00 00 push $0x42f6 1652: e8 9b 22 00 00 call 38f2 <unlink> if(open("lf1", 0) >= 0){ 1657: 58 pop %eax 1658: 5a pop %edx 1659: 6a 00 push $0x0 165b: 68 f6 42 00 00 push $0x42f6 1660: e8 7d 22 00 00 call 38e2 <open> 1665: 83 c4 10 add $0x10,%esp 1668: 85 c0 test %eax,%eax 166a: 0f 89 27 01 00 00 jns 1797 <linktest+0x1d7> fd = open("lf2", 0); 1670: 83 ec 08 sub $0x8,%esp 1673: 6a 00 push $0x0 1675: 68 fa 42 00 00 push $0x42fa 167a: e8 63 22 00 00 call 38e2 <open> if(fd < 0){ 167f: 83 c4 10 add $0x10,%esp 1682: 85 c0 test %eax,%eax fd = open("lf2", 0); 1684: 89 c3 mov %eax,%ebx if(fd < 0){ 1686: 0f 88 f8 00 00 00 js 1784 <linktest+0x1c4> if(read(fd, buf, sizeof(buf)) != 5){ 168c: 83 ec 04 sub $0x4,%esp 168f: 68 00 20 00 00 push $0x2000 1694: 68 e0 85 00 00 push $0x85e0 1699: 50 push %eax 169a: e8 1b 22 00 00 call 38ba <read> 169f: 83 c4 10 add $0x10,%esp 16a2: 83 f8 05 cmp $0x5,%eax 16a5: 0f 85 c6 00 00 00 jne 1771 <linktest+0x1b1> close(fd); 16ab: 83 ec 0c sub $0xc,%esp 16ae: 53 push %ebx 16af: e8 16 22 00 00 call 38ca <close> if(link("lf2", "lf2") >= 0){ 16b4: 58 pop %eax 16b5: 5a pop %edx 16b6: 68 fa 42 00 00 push $0x42fa 16bb: 68 fa 42 00 00 push $0x42fa 16c0: e8 3d 22 00 00 call 3902 <link> 16c5: 83 c4 10 add $0x10,%esp 16c8: 85 c0 test %eax,%eax 16ca: 0f 89 8e 00 00 00 jns 175e <linktest+0x19e> unlink("lf2"); 16d0: 83 ec 0c sub $0xc,%esp 16d3: 68 fa 42 00 00 push $0x42fa 16d8: e8 15 22 00 00 call 38f2 <unlink> if(link("lf2", "lf1") >= 0){ 16dd: 59 pop %ecx 16de: 5b pop %ebx 16df: 68 f6 42 00 00 push $0x42f6 16e4: 68 fa 42 00 00 push $0x42fa 16e9: e8 14 22 00 00 call 3902 <link> 16ee: 83 c4 10 add $0x10,%esp 16f1: 85 c0 test %eax,%eax 16f3: 79 56 jns 174b <linktest+0x18b> if(link(".", "lf1") >= 0){ 16f5: 83 ec 08 sub $0x8,%esp 16f8: 68 f6 42 00 00 push $0x42f6 16fd: 68 be 45 00 00 push $0x45be 1702: e8 fb 21 00 00 call 3902 <link> 1707: 83 c4 10 add $0x10,%esp 170a: 85 c0 test %eax,%eax 170c: 79 2a jns 1738 <linktest+0x178> printf(1, "linktest ok\n"); 170e: 83 ec 08 sub $0x8,%esp 1711: 68 94 43 00 00 push $0x4394 1716: 6a 01 push $0x1 1718: e8 d3 22 00 00 call 39f0 <printf> } 171d: 83 c4 10 add $0x10,%esp 1720: 8b 5d fc mov -0x4(%ebp),%ebx 1723: c9 leave 1724: c3 ret printf(1, "create lf1 failed\n"); 1725: 50 push %eax 1726: 50 push %eax 1727: 68 fe 42 00 00 push $0x42fe 172c: 6a 01 push $0x1 172e: e8 bd 22 00 00 call 39f0 <printf> exit(); 1733: e8 6a 21 00 00 call 38a2 <exit> printf(1, "link . lf1 succeeded! oops\n"); 1738: 50 push %eax 1739: 50 push %eax 173a: 68 78 43 00 00 push $0x4378 173f: 6a 01 push $0x1 1741: e8 aa 22 00 00 call 39f0 <printf> exit(); 1746: e8 57 21 00 00 call 38a2 <exit> printf(1, "link non-existant succeeded! oops\n"); 174b: 52 push %edx 174c: 52 push %edx 174d: 68 2c 4f 00 00 push $0x4f2c 1752: 6a 01 push $0x1 1754: e8 97 22 00 00 call 39f0 <printf> exit(); 1759: e8 44 21 00 00 call 38a2 <exit> printf(1, "link lf2 lf2 succeeded! oops\n"); 175e: 50 push %eax 175f: 50 push %eax 1760: 68 5a 43 00 00 push $0x435a 1765: 6a 01 push $0x1 1767: e8 84 22 00 00 call 39f0 <printf> exit(); 176c: e8 31 21 00 00 call 38a2 <exit> printf(1, "read lf2 failed\n"); 1771: 51 push %ecx 1772: 51 push %ecx 1773: 68 49 43 00 00 push $0x4349 1778: 6a 01 push $0x1 177a: e8 71 22 00 00 call 39f0 <printf> exit(); 177f: e8 1e 21 00 00 call 38a2 <exit> printf(1, "open lf2 failed\n"); 1784: 53 push %ebx 1785: 53 push %ebx 1786: 68 38 43 00 00 push $0x4338 178b: 6a 01 push $0x1 178d: e8 5e 22 00 00 call 39f0 <printf> exit(); 1792: e8 0b 21 00 00 call 38a2 <exit> printf(1, "unlinked lf1 but it is still there!\n"); 1797: 50 push %eax 1798: 50 push %eax 1799: 68 04 4f 00 00 push $0x4f04 179e: 6a 01 push $0x1 17a0: e8 4b 22 00 00 call 39f0 <printf> exit(); 17a5: e8 f8 20 00 00 call 38a2 <exit> printf(1, "link lf1 lf2 failed\n"); 17aa: 51 push %ecx 17ab: 51 push %ecx 17ac: 68 23 43 00 00 push $0x4323 17b1: 6a 01 push $0x1 17b3: e8 38 22 00 00 call 39f0 <printf> exit(); 17b8: e8 e5 20 00 00 call 38a2 <exit> printf(1, "write lf1 failed\n"); 17bd: 50 push %eax 17be: 50 push %eax 17bf: 68 11 43 00 00 push $0x4311 17c4: 6a 01 push $0x1 17c6: e8 25 22 00 00 call 39f0 <printf> exit(); 17cb: e8 d2 20 00 00 call 38a2 <exit> 000017d0 <concreate>: { 17d0: 55 push %ebp 17d1: 89 e5 mov %esp,%ebp 17d3: 57 push %edi 17d4: 56 push %esi 17d5: 53 push %ebx for(i = 0; i < 40; i++){ 17d6: 31 f6 xor %esi,%esi 17d8: 8d 5d ad lea -0x53(%ebp),%ebx if(pid && (i % 3) == 1){ 17db: bf ab aa aa aa mov $0xaaaaaaab,%edi { 17e0: 83 ec 64 sub $0x64,%esp printf(1, "concreate test\n"); 17e3: 68 a1 43 00 00 push $0x43a1 17e8: 6a 01 push $0x1 17ea: e8 01 22 00 00 call 39f0 <printf> file[0] = 'C'; 17ef: c6 45 ad 43 movb $0x43,-0x53(%ebp) file[2] = '\0'; 17f3: c6 45 af 00 movb $0x0,-0x51(%ebp) 17f7: 83 c4 10 add $0x10,%esp 17fa: eb 4c jmp 1848 <concreate+0x78> 17fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(pid && (i % 3) == 1){ 1800: 89 f0 mov %esi,%eax 1802: 89 f1 mov %esi,%ecx 1804: f7 e7 mul %edi 1806: d1 ea shr %edx 1808: 8d 04 52 lea (%edx,%edx,2),%eax 180b: 29 c1 sub %eax,%ecx 180d: 83 f9 01 cmp $0x1,%ecx 1810: 0f 84 ba 00 00 00 je 18d0 <concreate+0x100> fd = open(file, O_CREATE | O_RDWR); 1816: 83 ec 08 sub $0x8,%esp 1819: 68 02 02 00 00 push $0x202 181e: 53 push %ebx 181f: e8 be 20 00 00 call 38e2 <open> if(fd < 0){ 1824: 83 c4 10 add $0x10,%esp 1827: 85 c0 test %eax,%eax 1829: 78 67 js 1892 <concreate+0xc2> close(fd); 182b: 83 ec 0c sub $0xc,%esp for(i = 0; i < 40; i++){ 182e: 83 c6 01 add $0x1,%esi close(fd); 1831: 50 push %eax 1832: e8 93 20 00 00 call 38ca <close> 1837: 83 c4 10 add $0x10,%esp wait(); 183a: e8 6b 20 00 00 call 38aa <wait> for(i = 0; i < 40; i++){ 183f: 83 fe 28 cmp $0x28,%esi 1842: 0f 84 aa 00 00 00 je 18f2 <concreate+0x122> unlink(file); 1848: 83 ec 0c sub $0xc,%esp file[1] = '0' + i; 184b: 8d 46 30 lea 0x30(%esi),%eax unlink(file); 184e: 53 push %ebx file[1] = '0' + i; 184f: 88 45 ae mov %al,-0x52(%ebp) unlink(file); 1852: e8 9b 20 00 00 call 38f2 <unlink> pid = fork(); 1857: e8 3e 20 00 00 call 389a <fork> if(pid && (i % 3) == 1){ 185c: 83 c4 10 add $0x10,%esp 185f: 85 c0 test %eax,%eax 1861: 75 9d jne 1800 <concreate+0x30> } else if(pid == 0 && (i % 5) == 1){ 1863: 89 f0 mov %esi,%eax 1865: ba cd cc cc cc mov $0xcccccccd,%edx 186a: f7 e2 mul %edx 186c: c1 ea 02 shr $0x2,%edx 186f: 8d 04 92 lea (%edx,%edx,4),%eax 1872: 29 c6 sub %eax,%esi 1874: 83 fe 01 cmp $0x1,%esi 1877: 74 37 je 18b0 <concreate+0xe0> fd = open(file, O_CREATE | O_RDWR); 1879: 83 ec 08 sub $0x8,%esp 187c: 68 02 02 00 00 push $0x202 1881: 53 push %ebx 1882: e8 5b 20 00 00 call 38e2 <open> if(fd < 0){ 1887: 83 c4 10 add $0x10,%esp 188a: 85 c0 test %eax,%eax 188c: 0f 89 28 02 00 00 jns 1aba <concreate+0x2ea> printf(1, "concreate create %s failed\n", file); 1892: 83 ec 04 sub $0x4,%esp 1895: 53 push %ebx 1896: 68 b4 43 00 00 push $0x43b4 189b: 6a 01 push $0x1 189d: e8 4e 21 00 00 call 39f0 <printf> exit(); 18a2: e8 fb 1f 00 00 call 38a2 <exit> 18a7: 89 f6 mov %esi,%esi 18a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi link("C0", file); 18b0: 83 ec 08 sub $0x8,%esp 18b3: 53 push %ebx 18b4: 68 b1 43 00 00 push $0x43b1 18b9: e8 44 20 00 00 call 3902 <link> 18be: 83 c4 10 add $0x10,%esp exit(); 18c1: e8 dc 1f 00 00 call 38a2 <exit> 18c6: 8d 76 00 lea 0x0(%esi),%esi 18c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi link("C0", file); 18d0: 83 ec 08 sub $0x8,%esp for(i = 0; i < 40; i++){ 18d3: 83 c6 01 add $0x1,%esi link("C0", file); 18d6: 53 push %ebx 18d7: 68 b1 43 00 00 push $0x43b1 18dc: e8 21 20 00 00 call 3902 <link> 18e1: 83 c4 10 add $0x10,%esp wait(); 18e4: e8 c1 1f 00 00 call 38aa <wait> for(i = 0; i < 40; i++){ 18e9: 83 fe 28 cmp $0x28,%esi 18ec: 0f 85 56 ff ff ff jne 1848 <concreate+0x78> memset(fa, 0, sizeof(fa)); 18f2: 8d 45 c0 lea -0x40(%ebp),%eax 18f5: 83 ec 04 sub $0x4,%esp 18f8: 6a 28 push $0x28 18fa: 6a 00 push $0x0 18fc: 50 push %eax 18fd: e8 fe 1d 00 00 call 3700 <memset> fd = open(".", 0); 1902: 5f pop %edi 1903: 58 pop %eax 1904: 6a 00 push $0x0 1906: 68 be 45 00 00 push $0x45be 190b: 8d 7d b0 lea -0x50(%ebp),%edi 190e: e8 cf 1f 00 00 call 38e2 <open> while(read(fd, &de, sizeof(de)) > 0){ 1913: 83 c4 10 add $0x10,%esp fd = open(".", 0); 1916: 89 c6 mov %eax,%esi n = 0; 1918: c7 45 a4 00 00 00 00 movl $0x0,-0x5c(%ebp) 191f: 90 nop while(read(fd, &de, sizeof(de)) > 0){ 1920: 83 ec 04 sub $0x4,%esp 1923: 6a 10 push $0x10 1925: 57 push %edi 1926: 56 push %esi 1927: e8 8e 1f 00 00 call 38ba <read> 192c: 83 c4 10 add $0x10,%esp 192f: 85 c0 test %eax,%eax 1931: 7e 3d jle 1970 <concreate+0x1a0> if(de.inum == 0) 1933: 66 83 7d b0 00 cmpw $0x0,-0x50(%ebp) 1938: 74 e6 je 1920 <concreate+0x150> if(de.name[0] == 'C' && de.name[2] == '\0'){ 193a: 80 7d b2 43 cmpb $0x43,-0x4e(%ebp) 193e: 75 e0 jne 1920 <concreate+0x150> 1940: 80 7d b4 00 cmpb $0x0,-0x4c(%ebp) 1944: 75 da jne 1920 <concreate+0x150> i = de.name[1] - '0'; 1946: 0f be 45 b3 movsbl -0x4d(%ebp),%eax 194a: 83 e8 30 sub $0x30,%eax if(i < 0 || i >= sizeof(fa)){ 194d: 83 f8 27 cmp $0x27,%eax 1950: 0f 87 4e 01 00 00 ja 1aa4 <concreate+0x2d4> if(fa[i]){ 1956: 80 7c 05 c0 00 cmpb $0x0,-0x40(%ebp,%eax,1) 195b: 0f 85 2d 01 00 00 jne 1a8e <concreate+0x2be> fa[i] = 1; 1961: c6 44 05 c0 01 movb $0x1,-0x40(%ebp,%eax,1) n++; 1966: 83 45 a4 01 addl $0x1,-0x5c(%ebp) 196a: eb b4 jmp 1920 <concreate+0x150> 196c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi close(fd); 1970: 83 ec 0c sub $0xc,%esp 1973: 56 push %esi 1974: e8 51 1f 00 00 call 38ca <close> if(n != 40){ 1979: 83 c4 10 add $0x10,%esp 197c: 83 7d a4 28 cmpl $0x28,-0x5c(%ebp) 1980: 0f 85 f5 00 00 00 jne 1a7b <concreate+0x2ab> for(i = 0; i < 40; i++){ 1986: 31 f6 xor %esi,%esi 1988: eb 48 jmp 19d2 <concreate+0x202> 198a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi ((i % 3) == 1 && pid != 0)){ 1990: 85 ff test %edi,%edi 1992: 74 05 je 1999 <concreate+0x1c9> 1994: 83 fa 01 cmp $0x1,%edx 1997: 74 64 je 19fd <concreate+0x22d> unlink(file); 1999: 83 ec 0c sub $0xc,%esp 199c: 53 push %ebx 199d: e8 50 1f 00 00 call 38f2 <unlink> unlink(file); 19a2: 89 1c 24 mov %ebx,(%esp) 19a5: e8 48 1f 00 00 call 38f2 <unlink> unlink(file); 19aa: 89 1c 24 mov %ebx,(%esp) 19ad: e8 40 1f 00 00 call 38f2 <unlink> unlink(file); 19b2: 89 1c 24 mov %ebx,(%esp) 19b5: e8 38 1f 00 00 call 38f2 <unlink> 19ba: 83 c4 10 add $0x10,%esp if(pid == 0) 19bd: 85 ff test %edi,%edi 19bf: 0f 84 fc fe ff ff je 18c1 <concreate+0xf1> for(i = 0; i < 40; i++){ 19c5: 83 c6 01 add $0x1,%esi wait(); 19c8: e8 dd 1e 00 00 call 38aa <wait> for(i = 0; i < 40; i++){ 19cd: 83 fe 28 cmp $0x28,%esi 19d0: 74 7e je 1a50 <concreate+0x280> file[1] = '0' + i; 19d2: 8d 46 30 lea 0x30(%esi),%eax 19d5: 88 45 ae mov %al,-0x52(%ebp) pid = fork(); 19d8: e8 bd 1e 00 00 call 389a <fork> if(pid < 0){ 19dd: 85 c0 test %eax,%eax pid = fork(); 19df: 89 c7 mov %eax,%edi if(pid < 0){ 19e1: 0f 88 80 00 00 00 js 1a67 <concreate+0x297> if(((i % 3) == 0 && pid == 0) || 19e7: b8 ab aa aa aa mov $0xaaaaaaab,%eax 19ec: f7 e6 mul %esi 19ee: d1 ea shr %edx 19f0: 8d 04 52 lea (%edx,%edx,2),%eax 19f3: 89 f2 mov %esi,%edx 19f5: 29 c2 sub %eax,%edx 19f7: 89 d0 mov %edx,%eax 19f9: 09 f8 or %edi,%eax 19fb: 75 93 jne 1990 <concreate+0x1c0> close(open(file, 0)); 19fd: 83 ec 08 sub $0x8,%esp 1a00: 6a 00 push $0x0 1a02: 53 push %ebx 1a03: e8 da 1e 00 00 call 38e2 <open> 1a08: 89 04 24 mov %eax,(%esp) 1a0b: e8 ba 1e 00 00 call 38ca <close> close(open(file, 0)); 1a10: 58 pop %eax 1a11: 5a pop %edx 1a12: 6a 00 push $0x0 1a14: 53 push %ebx 1a15: e8 c8 1e 00 00 call 38e2 <open> 1a1a: 89 04 24 mov %eax,(%esp) 1a1d: e8 a8 1e 00 00 call 38ca <close> close(open(file, 0)); 1a22: 59 pop %ecx 1a23: 58 pop %eax 1a24: 6a 00 push $0x0 1a26: 53 push %ebx 1a27: e8 b6 1e 00 00 call 38e2 <open> 1a2c: 89 04 24 mov %eax,(%esp) 1a2f: e8 96 1e 00 00 call 38ca <close> close(open(file, 0)); 1a34: 58 pop %eax 1a35: 5a pop %edx 1a36: 6a 00 push $0x0 1a38: 53 push %ebx 1a39: e8 a4 1e 00 00 call 38e2 <open> 1a3e: 89 04 24 mov %eax,(%esp) 1a41: e8 84 1e 00 00 call 38ca <close> 1a46: 83 c4 10 add $0x10,%esp 1a49: e9 6f ff ff ff jmp 19bd <concreate+0x1ed> 1a4e: 66 90 xchg %ax,%ax printf(1, "concreate ok\n"); 1a50: 83 ec 08 sub $0x8,%esp 1a53: 68 06 44 00 00 push $0x4406 1a58: 6a 01 push $0x1 1a5a: e8 91 1f 00 00 call 39f0 <printf> } 1a5f: 8d 65 f4 lea -0xc(%ebp),%esp 1a62: 5b pop %ebx 1a63: 5e pop %esi 1a64: 5f pop %edi 1a65: 5d pop %ebp 1a66: c3 ret printf(1, "fork failed\n"); 1a67: 83 ec 08 sub $0x8,%esp 1a6a: 68 89 4c 00 00 push $0x4c89 1a6f: 6a 01 push $0x1 1a71: e8 7a 1f 00 00 call 39f0 <printf> exit(); 1a76: e8 27 1e 00 00 call 38a2 <exit> printf(1, "concreate not enough files in directory listing\n"); 1a7b: 51 push %ecx 1a7c: 51 push %ecx 1a7d: 68 50 4f 00 00 push $0x4f50 1a82: 6a 01 push $0x1 1a84: e8 67 1f 00 00 call 39f0 <printf> exit(); 1a89: e8 14 1e 00 00 call 38a2 <exit> printf(1, "concreate duplicate file %s\n", de.name); 1a8e: 8d 45 b2 lea -0x4e(%ebp),%eax 1a91: 53 push %ebx 1a92: 50 push %eax 1a93: 68 e9 43 00 00 push $0x43e9 1a98: 6a 01 push $0x1 1a9a: e8 51 1f 00 00 call 39f0 <printf> exit(); 1a9f: e8 fe 1d 00 00 call 38a2 <exit> printf(1, "concreate weird file %s\n", de.name); 1aa4: 8d 45 b2 lea -0x4e(%ebp),%eax 1aa7: 56 push %esi 1aa8: 50 push %eax 1aa9: 68 d0 43 00 00 push $0x43d0 1aae: 6a 01 push $0x1 1ab0: e8 3b 1f 00 00 call 39f0 <printf> exit(); 1ab5: e8 e8 1d 00 00 call 38a2 <exit> close(fd); 1aba: 83 ec 0c sub $0xc,%esp 1abd: 50 push %eax 1abe: e8 07 1e 00 00 call 38ca <close> 1ac3: 83 c4 10 add $0x10,%esp 1ac6: e9 f6 fd ff ff jmp 18c1 <concreate+0xf1> 1acb: 90 nop 1acc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00001ad0 <linkunlink>: { 1ad0: 55 push %ebp 1ad1: 89 e5 mov %esp,%ebp 1ad3: 57 push %edi 1ad4: 56 push %esi 1ad5: 53 push %ebx 1ad6: 83 ec 24 sub $0x24,%esp printf(1, "linkunlink test\n"); 1ad9: 68 14 44 00 00 push $0x4414 1ade: 6a 01 push $0x1 1ae0: e8 0b 1f 00 00 call 39f0 <printf> unlink("x"); 1ae5: c7 04 24 a1 46 00 00 movl $0x46a1,(%esp) 1aec: e8 01 1e 00 00 call 38f2 <unlink> pid = fork(); 1af1: e8 a4 1d 00 00 call 389a <fork> if(pid < 0){ 1af6: 83 c4 10 add $0x10,%esp 1af9: 85 c0 test %eax,%eax pid = fork(); 1afb: 89 45 e4 mov %eax,-0x1c(%ebp) if(pid < 0){ 1afe: 0f 88 b6 00 00 00 js 1bba <linkunlink+0xea> unsigned int x = (pid ? 1 : 97); 1b04: 83 7d e4 01 cmpl $0x1,-0x1c(%ebp) 1b08: bb 64 00 00 00 mov $0x64,%ebx if((x % 3) == 0){ 1b0d: be ab aa aa aa mov $0xaaaaaaab,%esi unsigned int x = (pid ? 1 : 97); 1b12: 19 ff sbb %edi,%edi 1b14: 83 e7 60 and $0x60,%edi 1b17: 83 c7 01 add $0x1,%edi 1b1a: eb 1e jmp 1b3a <linkunlink+0x6a> 1b1c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } else if((x % 3) == 1){ 1b20: 83 fa 01 cmp $0x1,%edx 1b23: 74 7b je 1ba0 <linkunlink+0xd0> unlink("x"); 1b25: 83 ec 0c sub $0xc,%esp 1b28: 68 a1 46 00 00 push $0x46a1 1b2d: e8 c0 1d 00 00 call 38f2 <unlink> 1b32: 83 c4 10 add $0x10,%esp for(i = 0; i < 100; i++){ 1b35: 83 eb 01 sub $0x1,%ebx 1b38: 74 3d je 1b77 <linkunlink+0xa7> x = x * 1103515245 + 12345; 1b3a: 69 cf 6d 4e c6 41 imul $0x41c64e6d,%edi,%ecx 1b40: 8d b9 39 30 00 00 lea 0x3039(%ecx),%edi if((x % 3) == 0){ 1b46: 89 f8 mov %edi,%eax 1b48: f7 e6 mul %esi 1b4a: d1 ea shr %edx 1b4c: 8d 04 52 lea (%edx,%edx,2),%eax 1b4f: 89 fa mov %edi,%edx 1b51: 29 c2 sub %eax,%edx 1b53: 75 cb jne 1b20 <linkunlink+0x50> close(open("x", O_RDWR | O_CREATE)); 1b55: 83 ec 08 sub $0x8,%esp 1b58: 68 02 02 00 00 push $0x202 1b5d: 68 a1 46 00 00 push $0x46a1 1b62: e8 7b 1d 00 00 call 38e2 <open> 1b67: 89 04 24 mov %eax,(%esp) 1b6a: e8 5b 1d 00 00 call 38ca <close> 1b6f: 83 c4 10 add $0x10,%esp for(i = 0; i < 100; i++){ 1b72: 83 eb 01 sub $0x1,%ebx 1b75: 75 c3 jne 1b3a <linkunlink+0x6a> if(pid) 1b77: 8b 45 e4 mov -0x1c(%ebp),%eax 1b7a: 85 c0 test %eax,%eax 1b7c: 74 4f je 1bcd <linkunlink+0xfd> wait(); 1b7e: e8 27 1d 00 00 call 38aa <wait> printf(1, "linkunlink ok\n"); 1b83: 83 ec 08 sub $0x8,%esp 1b86: 68 29 44 00 00 push $0x4429 1b8b: 6a 01 push $0x1 1b8d: e8 5e 1e 00 00 call 39f0 <printf> } 1b92: 8d 65 f4 lea -0xc(%ebp),%esp 1b95: 5b pop %ebx 1b96: 5e pop %esi 1b97: 5f pop %edi 1b98: 5d pop %ebp 1b99: c3 ret 1b9a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi link("cat", "x"); 1ba0: 83 ec 08 sub $0x8,%esp 1ba3: 68 a1 46 00 00 push $0x46a1 1ba8: 68 25 44 00 00 push $0x4425 1bad: e8 50 1d 00 00 call 3902 <link> 1bb2: 83 c4 10 add $0x10,%esp 1bb5: e9 7b ff ff ff jmp 1b35 <linkunlink+0x65> printf(1, "fork failed\n"); 1bba: 52 push %edx 1bbb: 52 push %edx 1bbc: 68 89 4c 00 00 push $0x4c89 1bc1: 6a 01 push $0x1 1bc3: e8 28 1e 00 00 call 39f0 <printf> exit(); 1bc8: e8 d5 1c 00 00 call 38a2 <exit> exit(); 1bcd: e8 d0 1c 00 00 call 38a2 <exit> 1bd2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 1bd9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00001be0 <bigdir>: { 1be0: 55 push %ebp 1be1: 89 e5 mov %esp,%ebp 1be3: 57 push %edi 1be4: 56 push %esi 1be5: 53 push %ebx 1be6: 83 ec 24 sub $0x24,%esp printf(1, "bigdir test\n"); 1be9: 68 38 44 00 00 push $0x4438 1bee: 6a 01 push $0x1 1bf0: e8 fb 1d 00 00 call 39f0 <printf> unlink("bd"); 1bf5: c7 04 24 45 44 00 00 movl $0x4445,(%esp) 1bfc: e8 f1 1c 00 00 call 38f2 <unlink> fd = open("bd", O_CREATE); 1c01: 5a pop %edx 1c02: 59 pop %ecx 1c03: 68 00 02 00 00 push $0x200 1c08: 68 45 44 00 00 push $0x4445 1c0d: e8 d0 1c 00 00 call 38e2 <open> if(fd < 0){ 1c12: 83 c4 10 add $0x10,%esp 1c15: 85 c0 test %eax,%eax 1c17: 0f 88 de 00 00 00 js 1cfb <bigdir+0x11b> close(fd); 1c1d: 83 ec 0c sub $0xc,%esp 1c20: 8d 7d de lea -0x22(%ebp),%edi for(i = 0; i < 500; i++){ 1c23: 31 f6 xor %esi,%esi close(fd); 1c25: 50 push %eax 1c26: e8 9f 1c 00 00 call 38ca <close> 1c2b: 83 c4 10 add $0x10,%esp 1c2e: 66 90 xchg %ax,%ax name[1] = '0' + (i / 64); 1c30: 89 f0 mov %esi,%eax if(link("bd", name) != 0){ 1c32: 83 ec 08 sub $0x8,%esp name[0] = 'x'; 1c35: c6 45 de 78 movb $0x78,-0x22(%ebp) name[1] = '0' + (i / 64); 1c39: c1 f8 06 sar $0x6,%eax if(link("bd", name) != 0){ 1c3c: 57 push %edi 1c3d: 68 45 44 00 00 push $0x4445 name[1] = '0' + (i / 64); 1c42: 83 c0 30 add $0x30,%eax name[3] = '\0'; 1c45: c6 45 e1 00 movb $0x0,-0x1f(%ebp) name[1] = '0' + (i / 64); 1c49: 88 45 df mov %al,-0x21(%ebp) name[2] = '0' + (i % 64); 1c4c: 89 f0 mov %esi,%eax 1c4e: 83 e0 3f and $0x3f,%eax 1c51: 83 c0 30 add $0x30,%eax 1c54: 88 45 e0 mov %al,-0x20(%ebp) if(link("bd", name) != 0){ 1c57: e8 a6 1c 00 00 call 3902 <link> 1c5c: 83 c4 10 add $0x10,%esp 1c5f: 85 c0 test %eax,%eax 1c61: 89 c3 mov %eax,%ebx 1c63: 75 6e jne 1cd3 <bigdir+0xf3> for(i = 0; i < 500; i++){ 1c65: 83 c6 01 add $0x1,%esi 1c68: 81 fe f4 01 00 00 cmp $0x1f4,%esi 1c6e: 75 c0 jne 1c30 <bigdir+0x50> unlink("bd"); 1c70: 83 ec 0c sub $0xc,%esp 1c73: 68 45 44 00 00 push $0x4445 1c78: e8 75 1c 00 00 call 38f2 <unlink> 1c7d: 83 c4 10 add $0x10,%esp name[1] = '0' + (i / 64); 1c80: 89 d8 mov %ebx,%eax if(unlink(name) != 0){ 1c82: 83 ec 0c sub $0xc,%esp name[0] = 'x'; 1c85: c6 45 de 78 movb $0x78,-0x22(%ebp) name[1] = '0' + (i / 64); 1c89: c1 f8 06 sar $0x6,%eax if(unlink(name) != 0){ 1c8c: 57 push %edi name[3] = '\0'; 1c8d: c6 45 e1 00 movb $0x0,-0x1f(%ebp) name[1] = '0' + (i / 64); 1c91: 83 c0 30 add $0x30,%eax 1c94: 88 45 df mov %al,-0x21(%ebp) name[2] = '0' + (i % 64); 1c97: 89 d8 mov %ebx,%eax 1c99: 83 e0 3f and $0x3f,%eax 1c9c: 83 c0 30 add $0x30,%eax 1c9f: 88 45 e0 mov %al,-0x20(%ebp) if(unlink(name) != 0){ 1ca2: e8 4b 1c 00 00 call 38f2 <unlink> 1ca7: 83 c4 10 add $0x10,%esp 1caa: 85 c0 test %eax,%eax 1cac: 75 39 jne 1ce7 <bigdir+0x107> for(i = 0; i < 500; i++){ 1cae: 83 c3 01 add $0x1,%ebx 1cb1: 81 fb f4 01 00 00 cmp $0x1f4,%ebx 1cb7: 75 c7 jne 1c80 <bigdir+0xa0> printf(1, "bigdir ok\n"); 1cb9: 83 ec 08 sub $0x8,%esp 1cbc: 68 87 44 00 00 push $0x4487 1cc1: 6a 01 push $0x1 1cc3: e8 28 1d 00 00 call 39f0 <printf> } 1cc8: 83 c4 10 add $0x10,%esp 1ccb: 8d 65 f4 lea -0xc(%ebp),%esp 1cce: 5b pop %ebx 1ccf: 5e pop %esi 1cd0: 5f pop %edi 1cd1: 5d pop %ebp 1cd2: c3 ret printf(1, "bigdir link failed\n"); 1cd3: 83 ec 08 sub $0x8,%esp 1cd6: 68 5e 44 00 00 push $0x445e 1cdb: 6a 01 push $0x1 1cdd: e8 0e 1d 00 00 call 39f0 <printf> exit(); 1ce2: e8 bb 1b 00 00 call 38a2 <exit> printf(1, "bigdir unlink failed"); 1ce7: 83 ec 08 sub $0x8,%esp 1cea: 68 72 44 00 00 push $0x4472 1cef: 6a 01 push $0x1 1cf1: e8 fa 1c 00 00 call 39f0 <printf> exit(); 1cf6: e8 a7 1b 00 00 call 38a2 <exit> printf(1, "bigdir create failed\n"); 1cfb: 50 push %eax 1cfc: 50 push %eax 1cfd: 68 48 44 00 00 push $0x4448 1d02: 6a 01 push $0x1 1d04: e8 e7 1c 00 00 call 39f0 <printf> exit(); 1d09: e8 94 1b 00 00 call 38a2 <exit> 1d0e: 66 90 xchg %ax,%ax 00001d10 <subdir>: { 1d10: 55 push %ebp 1d11: 89 e5 mov %esp,%ebp 1d13: 53 push %ebx 1d14: 83 ec 0c sub $0xc,%esp printf(1, "subdir test\n"); 1d17: 68 92 44 00 00 push $0x4492 1d1c: 6a 01 push $0x1 1d1e: e8 cd 1c 00 00 call 39f0 <printf> unlink("ff"); 1d23: c7 04 24 1b 45 00 00 movl $0x451b,(%esp) 1d2a: e8 c3 1b 00 00 call 38f2 <unlink> if(mkdir("dd") != 0){ 1d2f: c7 04 24 b8 45 00 00 movl $0x45b8,(%esp) 1d36: e8 cf 1b 00 00 call 390a <mkdir> 1d3b: 83 c4 10 add $0x10,%esp 1d3e: 85 c0 test %eax,%eax 1d40: 0f 85 b3 05 00 00 jne 22f9 <subdir+0x5e9> fd = open("dd/ff", O_CREATE | O_RDWR); 1d46: 83 ec 08 sub $0x8,%esp 1d49: 68 02 02 00 00 push $0x202 1d4e: 68 f1 44 00 00 push $0x44f1 1d53: e8 8a 1b 00 00 call 38e2 <open> if(fd < 0){ 1d58: 83 c4 10 add $0x10,%esp 1d5b: 85 c0 test %eax,%eax fd = open("dd/ff", O_CREATE | O_RDWR); 1d5d: 89 c3 mov %eax,%ebx if(fd < 0){ 1d5f: 0f 88 81 05 00 00 js 22e6 <subdir+0x5d6> write(fd, "ff", 2); 1d65: 83 ec 04 sub $0x4,%esp 1d68: 6a 02 push $0x2 1d6a: 68 1b 45 00 00 push $0x451b 1d6f: 50 push %eax 1d70: e8 4d 1b 00 00 call 38c2 <write> close(fd); 1d75: 89 1c 24 mov %ebx,(%esp) 1d78: e8 4d 1b 00 00 call 38ca <close> if(unlink("dd") >= 0){ 1d7d: c7 04 24 b8 45 00 00 movl $0x45b8,(%esp) 1d84: e8 69 1b 00 00 call 38f2 <unlink> 1d89: 83 c4 10 add $0x10,%esp 1d8c: 85 c0 test %eax,%eax 1d8e: 0f 89 3f 05 00 00 jns 22d3 <subdir+0x5c3> if(mkdir("/dd/dd") != 0){ 1d94: 83 ec 0c sub $0xc,%esp 1d97: 68 cc 44 00 00 push $0x44cc 1d9c: e8 69 1b 00 00 call 390a <mkdir> 1da1: 83 c4 10 add $0x10,%esp 1da4: 85 c0 test %eax,%eax 1da6: 0f 85 14 05 00 00 jne 22c0 <subdir+0x5b0> fd = open("dd/dd/ff", O_CREATE | O_RDWR); 1dac: 83 ec 08 sub $0x8,%esp 1daf: 68 02 02 00 00 push $0x202 1db4: 68 ee 44 00 00 push $0x44ee 1db9: e8 24 1b 00 00 call 38e2 <open> if(fd < 0){ 1dbe: 83 c4 10 add $0x10,%esp 1dc1: 85 c0 test %eax,%eax fd = open("dd/dd/ff", O_CREATE | O_RDWR); 1dc3: 89 c3 mov %eax,%ebx if(fd < 0){ 1dc5: 0f 88 24 04 00 00 js 21ef <subdir+0x4df> write(fd, "FF", 2); 1dcb: 83 ec 04 sub $0x4,%esp 1dce: 6a 02 push $0x2 1dd0: 68 0f 45 00 00 push $0x450f 1dd5: 50 push %eax 1dd6: e8 e7 1a 00 00 call 38c2 <write> close(fd); 1ddb: 89 1c 24 mov %ebx,(%esp) 1dde: e8 e7 1a 00 00 call 38ca <close> fd = open("dd/dd/../ff", 0); 1de3: 58 pop %eax 1de4: 5a pop %edx 1de5: 6a 00 push $0x0 1de7: 68 12 45 00 00 push $0x4512 1dec: e8 f1 1a 00 00 call 38e2 <open> if(fd < 0){ 1df1: 83 c4 10 add $0x10,%esp 1df4: 85 c0 test %eax,%eax fd = open("dd/dd/../ff", 0); 1df6: 89 c3 mov %eax,%ebx if(fd < 0){ 1df8: 0f 88 de 03 00 00 js 21dc <subdir+0x4cc> cc = read(fd, buf, sizeof(buf)); 1dfe: 83 ec 04 sub $0x4,%esp 1e01: 68 00 20 00 00 push $0x2000 1e06: 68 e0 85 00 00 push $0x85e0 1e0b: 50 push %eax 1e0c: e8 a9 1a 00 00 call 38ba <read> if(cc != 2 || buf[0] != 'f'){ 1e11: 83 c4 10 add $0x10,%esp 1e14: 83 f8 02 cmp $0x2,%eax 1e17: 0f 85 3a 03 00 00 jne 2157 <subdir+0x447> 1e1d: 80 3d e0 85 00 00 66 cmpb $0x66,0x85e0 1e24: 0f 85 2d 03 00 00 jne 2157 <subdir+0x447> close(fd); 1e2a: 83 ec 0c sub $0xc,%esp 1e2d: 53 push %ebx 1e2e: e8 97 1a 00 00 call 38ca <close> if(link("dd/dd/ff", "dd/dd/ffff") != 0){ 1e33: 5b pop %ebx 1e34: 58 pop %eax 1e35: 68 52 45 00 00 push $0x4552 1e3a: 68 ee 44 00 00 push $0x44ee 1e3f: e8 be 1a 00 00 call 3902 <link> 1e44: 83 c4 10 add $0x10,%esp 1e47: 85 c0 test %eax,%eax 1e49: 0f 85 c6 03 00 00 jne 2215 <subdir+0x505> if(unlink("dd/dd/ff") != 0){ 1e4f: 83 ec 0c sub $0xc,%esp 1e52: 68 ee 44 00 00 push $0x44ee 1e57: e8 96 1a 00 00 call 38f2 <unlink> 1e5c: 83 c4 10 add $0x10,%esp 1e5f: 85 c0 test %eax,%eax 1e61: 0f 85 16 03 00 00 jne 217d <subdir+0x46d> if(open("dd/dd/ff", O_RDONLY) >= 0){ 1e67: 83 ec 08 sub $0x8,%esp 1e6a: 6a 00 push $0x0 1e6c: 68 ee 44 00 00 push $0x44ee 1e71: e8 6c 1a 00 00 call 38e2 <open> 1e76: 83 c4 10 add $0x10,%esp 1e79: 85 c0 test %eax,%eax 1e7b: 0f 89 2c 04 00 00 jns 22ad <subdir+0x59d> if(chdir("dd") != 0){ 1e81: 83 ec 0c sub $0xc,%esp 1e84: 68 b8 45 00 00 push $0x45b8 1e89: e8 84 1a 00 00 call 3912 <chdir> 1e8e: 83 c4 10 add $0x10,%esp 1e91: 85 c0 test %eax,%eax 1e93: 0f 85 01 04 00 00 jne 229a <subdir+0x58a> if(chdir("dd/../../dd") != 0){ 1e99: 83 ec 0c sub $0xc,%esp 1e9c: 68 86 45 00 00 push $0x4586 1ea1: e8 6c 1a 00 00 call 3912 <chdir> 1ea6: 83 c4 10 add $0x10,%esp 1ea9: 85 c0 test %eax,%eax 1eab: 0f 85 b9 02 00 00 jne 216a <subdir+0x45a> if(chdir("dd/../../../dd") != 0){ 1eb1: 83 ec 0c sub $0xc,%esp 1eb4: 68 ac 45 00 00 push $0x45ac 1eb9: e8 54 1a 00 00 call 3912 <chdir> 1ebe: 83 c4 10 add $0x10,%esp 1ec1: 85 c0 test %eax,%eax 1ec3: 0f 85 a1 02 00 00 jne 216a <subdir+0x45a> if(chdir("./..") != 0){ 1ec9: 83 ec 0c sub $0xc,%esp 1ecc: 68 bb 45 00 00 push $0x45bb 1ed1: e8 3c 1a 00 00 call 3912 <chdir> 1ed6: 83 c4 10 add $0x10,%esp 1ed9: 85 c0 test %eax,%eax 1edb: 0f 85 21 03 00 00 jne 2202 <subdir+0x4f2> fd = open("dd/dd/ffff", 0); 1ee1: 83 ec 08 sub $0x8,%esp 1ee4: 6a 00 push $0x0 1ee6: 68 52 45 00 00 push $0x4552 1eeb: e8 f2 19 00 00 call 38e2 <open> if(fd < 0){ 1ef0: 83 c4 10 add $0x10,%esp 1ef3: 85 c0 test %eax,%eax fd = open("dd/dd/ffff", 0); 1ef5: 89 c3 mov %eax,%ebx if(fd < 0){ 1ef7: 0f 88 e0 04 00 00 js 23dd <subdir+0x6cd> if(read(fd, buf, sizeof(buf)) != 2){ 1efd: 83 ec 04 sub $0x4,%esp 1f00: 68 00 20 00 00 push $0x2000 1f05: 68 e0 85 00 00 push $0x85e0 1f0a: 50 push %eax 1f0b: e8 aa 19 00 00 call 38ba <read> 1f10: 83 c4 10 add $0x10,%esp 1f13: 83 f8 02 cmp $0x2,%eax 1f16: 0f 85 ae 04 00 00 jne 23ca <subdir+0x6ba> close(fd); 1f1c: 83 ec 0c sub $0xc,%esp 1f1f: 53 push %ebx 1f20: e8 a5 19 00 00 call 38ca <close> if(open("dd/dd/ff", O_RDONLY) >= 0){ 1f25: 59 pop %ecx 1f26: 5b pop %ebx 1f27: 6a 00 push $0x0 1f29: 68 ee 44 00 00 push $0x44ee 1f2e: e8 af 19 00 00 call 38e2 <open> 1f33: 83 c4 10 add $0x10,%esp 1f36: 85 c0 test %eax,%eax 1f38: 0f 89 65 02 00 00 jns 21a3 <subdir+0x493> if(open("dd/ff/ff", O_CREATE|O_RDWR) >= 0){ 1f3e: 83 ec 08 sub $0x8,%esp 1f41: 68 02 02 00 00 push $0x202 1f46: 68 06 46 00 00 push $0x4606 1f4b: e8 92 19 00 00 call 38e2 <open> 1f50: 83 c4 10 add $0x10,%esp 1f53: 85 c0 test %eax,%eax 1f55: 0f 89 35 02 00 00 jns 2190 <subdir+0x480> if(open("dd/xx/ff", O_CREATE|O_RDWR) >= 0){ 1f5b: 83 ec 08 sub $0x8,%esp 1f5e: 68 02 02 00 00 push $0x202 1f63: 68 2b 46 00 00 push $0x462b 1f68: e8 75 19 00 00 call 38e2 <open> 1f6d: 83 c4 10 add $0x10,%esp 1f70: 85 c0 test %eax,%eax 1f72: 0f 89 0f 03 00 00 jns 2287 <subdir+0x577> if(open("dd", O_CREATE) >= 0){ 1f78: 83 ec 08 sub $0x8,%esp 1f7b: 68 00 02 00 00 push $0x200 1f80: 68 b8 45 00 00 push $0x45b8 1f85: e8 58 19 00 00 call 38e2 <open> 1f8a: 83 c4 10 add $0x10,%esp 1f8d: 85 c0 test %eax,%eax 1f8f: 0f 89 df 02 00 00 jns 2274 <subdir+0x564> if(open("dd", O_RDWR) >= 0){ 1f95: 83 ec 08 sub $0x8,%esp 1f98: 6a 02 push $0x2 1f9a: 68 b8 45 00 00 push $0x45b8 1f9f: e8 3e 19 00 00 call 38e2 <open> 1fa4: 83 c4 10 add $0x10,%esp 1fa7: 85 c0 test %eax,%eax 1fa9: 0f 89 b2 02 00 00 jns 2261 <subdir+0x551> if(open("dd", O_WRONLY) >= 0){ 1faf: 83 ec 08 sub $0x8,%esp 1fb2: 6a 01 push $0x1 1fb4: 68 b8 45 00 00 push $0x45b8 1fb9: e8 24 19 00 00 call 38e2 <open> 1fbe: 83 c4 10 add $0x10,%esp 1fc1: 85 c0 test %eax,%eax 1fc3: 0f 89 85 02 00 00 jns 224e <subdir+0x53e> if(link("dd/ff/ff", "dd/dd/xx") == 0){ 1fc9: 83 ec 08 sub $0x8,%esp 1fcc: 68 9a 46 00 00 push $0x469a 1fd1: 68 06 46 00 00 push $0x4606 1fd6: e8 27 19 00 00 call 3902 <link> 1fdb: 83 c4 10 add $0x10,%esp 1fde: 85 c0 test %eax,%eax 1fe0: 0f 84 55 02 00 00 je 223b <subdir+0x52b> if(link("dd/xx/ff", "dd/dd/xx") == 0){ 1fe6: 83 ec 08 sub $0x8,%esp 1fe9: 68 9a 46 00 00 push $0x469a 1fee: 68 2b 46 00 00 push $0x462b 1ff3: e8 0a 19 00 00 call 3902 <link> 1ff8: 83 c4 10 add $0x10,%esp 1ffb: 85 c0 test %eax,%eax 1ffd: 0f 84 25 02 00 00 je 2228 <subdir+0x518> if(link("dd/ff", "dd/dd/ffff") == 0){ 2003: 83 ec 08 sub $0x8,%esp 2006: 68 52 45 00 00 push $0x4552 200b: 68 f1 44 00 00 push $0x44f1 2010: e8 ed 18 00 00 call 3902 <link> 2015: 83 c4 10 add $0x10,%esp 2018: 85 c0 test %eax,%eax 201a: 0f 84 a9 01 00 00 je 21c9 <subdir+0x4b9> if(mkdir("dd/ff/ff") == 0){ 2020: 83 ec 0c sub $0xc,%esp 2023: 68 06 46 00 00 push $0x4606 2028: e8 dd 18 00 00 call 390a <mkdir> 202d: 83 c4 10 add $0x10,%esp 2030: 85 c0 test %eax,%eax 2032: 0f 84 7e 01 00 00 je 21b6 <subdir+0x4a6> if(mkdir("dd/xx/ff") == 0){ 2038: 83 ec 0c sub $0xc,%esp 203b: 68 2b 46 00 00 push $0x462b 2040: e8 c5 18 00 00 call 390a <mkdir> 2045: 83 c4 10 add $0x10,%esp 2048: 85 c0 test %eax,%eax 204a: 0f 84 67 03 00 00 je 23b7 <subdir+0x6a7> if(mkdir("dd/dd/ffff") == 0){ 2050: 83 ec 0c sub $0xc,%esp 2053: 68 52 45 00 00 push $0x4552 2058: e8 ad 18 00 00 call 390a <mkdir> 205d: 83 c4 10 add $0x10,%esp 2060: 85 c0 test %eax,%eax 2062: 0f 84 3c 03 00 00 je 23a4 <subdir+0x694> if(unlink("dd/xx/ff") == 0){ 2068: 83 ec 0c sub $0xc,%esp 206b: 68 2b 46 00 00 push $0x462b 2070: e8 7d 18 00 00 call 38f2 <unlink> 2075: 83 c4 10 add $0x10,%esp 2078: 85 c0 test %eax,%eax 207a: 0f 84 11 03 00 00 je 2391 <subdir+0x681> if(unlink("dd/ff/ff") == 0){ 2080: 83 ec 0c sub $0xc,%esp 2083: 68 06 46 00 00 push $0x4606 2088: e8 65 18 00 00 call 38f2 <unlink> 208d: 83 c4 10 add $0x10,%esp 2090: 85 c0 test %eax,%eax 2092: 0f 84 e6 02 00 00 je 237e <subdir+0x66e> if(chdir("dd/ff") == 0){ 2098: 83 ec 0c sub $0xc,%esp 209b: 68 f1 44 00 00 push $0x44f1 20a0: e8 6d 18 00 00 call 3912 <chdir> 20a5: 83 c4 10 add $0x10,%esp 20a8: 85 c0 test %eax,%eax 20aa: 0f 84 bb 02 00 00 je 236b <subdir+0x65b> if(chdir("dd/xx") == 0){ 20b0: 83 ec 0c sub $0xc,%esp 20b3: 68 9d 46 00 00 push $0x469d 20b8: e8 55 18 00 00 call 3912 <chdir> 20bd: 83 c4 10 add $0x10,%esp 20c0: 85 c0 test %eax,%eax 20c2: 0f 84 90 02 00 00 je 2358 <subdir+0x648> if(unlink("dd/dd/ffff") != 0){ 20c8: 83 ec 0c sub $0xc,%esp 20cb: 68 52 45 00 00 push $0x4552 20d0: e8 1d 18 00 00 call 38f2 <unlink> 20d5: 83 c4 10 add $0x10,%esp 20d8: 85 c0 test %eax,%eax 20da: 0f 85 9d 00 00 00 jne 217d <subdir+0x46d> if(unlink("dd/ff") != 0){ 20e0: 83 ec 0c sub $0xc,%esp 20e3: 68 f1 44 00 00 push $0x44f1 20e8: e8 05 18 00 00 call 38f2 <unlink> 20ed: 83 c4 10 add $0x10,%esp 20f0: 85 c0 test %eax,%eax 20f2: 0f 85 4d 02 00 00 jne 2345 <subdir+0x635> if(unlink("dd") == 0){ 20f8: 83 ec 0c sub $0xc,%esp 20fb: 68 b8 45 00 00 push $0x45b8 2100: e8 ed 17 00 00 call 38f2 <unlink> 2105: 83 c4 10 add $0x10,%esp 2108: 85 c0 test %eax,%eax 210a: 0f 84 22 02 00 00 je 2332 <subdir+0x622> if(unlink("dd/dd") < 0){ 2110: 83 ec 0c sub $0xc,%esp 2113: 68 cd 44 00 00 push $0x44cd 2118: e8 d5 17 00 00 call 38f2 <unlink> 211d: 83 c4 10 add $0x10,%esp 2120: 85 c0 test %eax,%eax 2122: 0f 88 f7 01 00 00 js 231f <subdir+0x60f> if(unlink("dd") < 0){ 2128: 83 ec 0c sub $0xc,%esp 212b: 68 b8 45 00 00 push $0x45b8 2130: e8 bd 17 00 00 call 38f2 <unlink> 2135: 83 c4 10 add $0x10,%esp 2138: 85 c0 test %eax,%eax 213a: 0f 88 cc 01 00 00 js 230c <subdir+0x5fc> printf(1, "subdir ok\n"); 2140: 83 ec 08 sub $0x8,%esp 2143: 68 9a 47 00 00 push $0x479a 2148: 6a 01 push $0x1 214a: e8 a1 18 00 00 call 39f0 <printf> } 214f: 83 c4 10 add $0x10,%esp 2152: 8b 5d fc mov -0x4(%ebp),%ebx 2155: c9 leave 2156: c3 ret printf(1, "dd/dd/../ff wrong content\n"); 2157: 50 push %eax 2158: 50 push %eax 2159: 68 37 45 00 00 push $0x4537 215e: 6a 01 push $0x1 2160: e8 8b 18 00 00 call 39f0 <printf> exit(); 2165: e8 38 17 00 00 call 38a2 <exit> printf(1, "chdir dd/../../dd failed\n"); 216a: 50 push %eax 216b: 50 push %eax 216c: 68 92 45 00 00 push $0x4592 2171: 6a 01 push $0x1 2173: e8 78 18 00 00 call 39f0 <printf> exit(); 2178: e8 25 17 00 00 call 38a2 <exit> printf(1, "unlink dd/dd/ff failed\n"); 217d: 52 push %edx 217e: 52 push %edx 217f: 68 5d 45 00 00 push $0x455d 2184: 6a 01 push $0x1 2186: e8 65 18 00 00 call 39f0 <printf> exit(); 218b: e8 12 17 00 00 call 38a2 <exit> printf(1, "create dd/ff/ff succeeded!\n"); 2190: 50 push %eax 2191: 50 push %eax 2192: 68 0f 46 00 00 push $0x460f 2197: 6a 01 push $0x1 2199: e8 52 18 00 00 call 39f0 <printf> exit(); 219e: e8 ff 16 00 00 call 38a2 <exit> printf(1, "open (unlinked) dd/dd/ff succeeded!\n"); 21a3: 52 push %edx 21a4: 52 push %edx 21a5: 68 f4 4f 00 00 push $0x4ff4 21aa: 6a 01 push $0x1 21ac: e8 3f 18 00 00 call 39f0 <printf> exit(); 21b1: e8 ec 16 00 00 call 38a2 <exit> printf(1, "mkdir dd/ff/ff succeeded!\n"); 21b6: 52 push %edx 21b7: 52 push %edx 21b8: 68 a3 46 00 00 push $0x46a3 21bd: 6a 01 push $0x1 21bf: e8 2c 18 00 00 call 39f0 <printf> exit(); 21c4: e8 d9 16 00 00 call 38a2 <exit> printf(1, "link dd/ff dd/dd/ffff succeeded!\n"); 21c9: 51 push %ecx 21ca: 51 push %ecx 21cb: 68 64 50 00 00 push $0x5064 21d0: 6a 01 push $0x1 21d2: e8 19 18 00 00 call 39f0 <printf> exit(); 21d7: e8 c6 16 00 00 call 38a2 <exit> printf(1, "open dd/dd/../ff failed\n"); 21dc: 50 push %eax 21dd: 50 push %eax 21de: 68 1e 45 00 00 push $0x451e 21e3: 6a 01 push $0x1 21e5: e8 06 18 00 00 call 39f0 <printf> exit(); 21ea: e8 b3 16 00 00 call 38a2 <exit> printf(1, "create dd/dd/ff failed\n"); 21ef: 51 push %ecx 21f0: 51 push %ecx 21f1: 68 f7 44 00 00 push $0x44f7 21f6: 6a 01 push $0x1 21f8: e8 f3 17 00 00 call 39f0 <printf> exit(); 21fd: e8 a0 16 00 00 call 38a2 <exit> printf(1, "chdir ./.. failed\n"); 2202: 50 push %eax 2203: 50 push %eax 2204: 68 c0 45 00 00 push $0x45c0 2209: 6a 01 push $0x1 220b: e8 e0 17 00 00 call 39f0 <printf> exit(); 2210: e8 8d 16 00 00 call 38a2 <exit> printf(1, "link dd/dd/ff dd/dd/ffff failed\n"); 2215: 51 push %ecx 2216: 51 push %ecx 2217: 68 ac 4f 00 00 push $0x4fac 221c: 6a 01 push $0x1 221e: e8 cd 17 00 00 call 39f0 <printf> exit(); 2223: e8 7a 16 00 00 call 38a2 <exit> printf(1, "link dd/xx/ff dd/dd/xx succeeded!\n"); 2228: 53 push %ebx 2229: 53 push %ebx 222a: 68 40 50 00 00 push $0x5040 222f: 6a 01 push $0x1 2231: e8 ba 17 00 00 call 39f0 <printf> exit(); 2236: e8 67 16 00 00 call 38a2 <exit> printf(1, "link dd/ff/ff dd/dd/xx succeeded!\n"); 223b: 50 push %eax 223c: 50 push %eax 223d: 68 1c 50 00 00 push $0x501c 2242: 6a 01 push $0x1 2244: e8 a7 17 00 00 call 39f0 <printf> exit(); 2249: e8 54 16 00 00 call 38a2 <exit> printf(1, "open dd wronly succeeded!\n"); 224e: 50 push %eax 224f: 50 push %eax 2250: 68 7f 46 00 00 push $0x467f 2255: 6a 01 push $0x1 2257: e8 94 17 00 00 call 39f0 <printf> exit(); 225c: e8 41 16 00 00 call 38a2 <exit> printf(1, "open dd rdwr succeeded!\n"); 2261: 50 push %eax 2262: 50 push %eax 2263: 68 66 46 00 00 push $0x4666 2268: 6a 01 push $0x1 226a: e8 81 17 00 00 call 39f0 <printf> exit(); 226f: e8 2e 16 00 00 call 38a2 <exit> printf(1, "create dd succeeded!\n"); 2274: 50 push %eax 2275: 50 push %eax 2276: 68 50 46 00 00 push $0x4650 227b: 6a 01 push $0x1 227d: e8 6e 17 00 00 call 39f0 <printf> exit(); 2282: e8 1b 16 00 00 call 38a2 <exit> printf(1, "create dd/xx/ff succeeded!\n"); 2287: 50 push %eax 2288: 50 push %eax 2289: 68 34 46 00 00 push $0x4634 228e: 6a 01 push $0x1 2290: e8 5b 17 00 00 call 39f0 <printf> exit(); 2295: e8 08 16 00 00 call 38a2 <exit> printf(1, "chdir dd failed\n"); 229a: 50 push %eax 229b: 50 push %eax 229c: 68 75 45 00 00 push $0x4575 22a1: 6a 01 push $0x1 22a3: e8 48 17 00 00 call 39f0 <printf> exit(); 22a8: e8 f5 15 00 00 call 38a2 <exit> printf(1, "open (unlinked) dd/dd/ff succeeded\n"); 22ad: 50 push %eax 22ae: 50 push %eax 22af: 68 d0 4f 00 00 push $0x4fd0 22b4: 6a 01 push $0x1 22b6: e8 35 17 00 00 call 39f0 <printf> exit(); 22bb: e8 e2 15 00 00 call 38a2 <exit> printf(1, "subdir mkdir dd/dd failed\n"); 22c0: 53 push %ebx 22c1: 53 push %ebx 22c2: 68 d3 44 00 00 push $0x44d3 22c7: 6a 01 push $0x1 22c9: e8 22 17 00 00 call 39f0 <printf> exit(); 22ce: e8 cf 15 00 00 call 38a2 <exit> printf(1, "unlink dd (non-empty dir) succeeded!\n"); 22d3: 50 push %eax 22d4: 50 push %eax 22d5: 68 84 4f 00 00 push $0x4f84 22da: 6a 01 push $0x1 22dc: e8 0f 17 00 00 call 39f0 <printf> exit(); 22e1: e8 bc 15 00 00 call 38a2 <exit> printf(1, "create dd/ff failed\n"); 22e6: 50 push %eax 22e7: 50 push %eax 22e8: 68 b7 44 00 00 push $0x44b7 22ed: 6a 01 push $0x1 22ef: e8 fc 16 00 00 call 39f0 <printf> exit(); 22f4: e8 a9 15 00 00 call 38a2 <exit> printf(1, "subdir mkdir dd failed\n"); 22f9: 50 push %eax 22fa: 50 push %eax 22fb: 68 9f 44 00 00 push $0x449f 2300: 6a 01 push $0x1 2302: e8 e9 16 00 00 call 39f0 <printf> exit(); 2307: e8 96 15 00 00 call 38a2 <exit> printf(1, "unlink dd failed\n"); 230c: 50 push %eax 230d: 50 push %eax 230e: 68 88 47 00 00 push $0x4788 2313: 6a 01 push $0x1 2315: e8 d6 16 00 00 call 39f0 <printf> exit(); 231a: e8 83 15 00 00 call 38a2 <exit> printf(1, "unlink dd/dd failed\n"); 231f: 52 push %edx 2320: 52 push %edx 2321: 68 73 47 00 00 push $0x4773 2326: 6a 01 push $0x1 2328: e8 c3 16 00 00 call 39f0 <printf> exit(); 232d: e8 70 15 00 00 call 38a2 <exit> printf(1, "unlink non-empty dd succeeded!\n"); 2332: 51 push %ecx 2333: 51 push %ecx 2334: 68 88 50 00 00 push $0x5088 2339: 6a 01 push $0x1 233b: e8 b0 16 00 00 call 39f0 <printf> exit(); 2340: e8 5d 15 00 00 call 38a2 <exit> printf(1, "unlink dd/ff failed\n"); 2345: 53 push %ebx 2346: 53 push %ebx 2347: 68 5e 47 00 00 push $0x475e 234c: 6a 01 push $0x1 234e: e8 9d 16 00 00 call 39f0 <printf> exit(); 2353: e8 4a 15 00 00 call 38a2 <exit> printf(1, "chdir dd/xx succeeded!\n"); 2358: 50 push %eax 2359: 50 push %eax 235a: 68 46 47 00 00 push $0x4746 235f: 6a 01 push $0x1 2361: e8 8a 16 00 00 call 39f0 <printf> exit(); 2366: e8 37 15 00 00 call 38a2 <exit> printf(1, "chdir dd/ff succeeded!\n"); 236b: 50 push %eax 236c: 50 push %eax 236d: 68 2e 47 00 00 push $0x472e 2372: 6a 01 push $0x1 2374: e8 77 16 00 00 call 39f0 <printf> exit(); 2379: e8 24 15 00 00 call 38a2 <exit> printf(1, "unlink dd/ff/ff succeeded!\n"); 237e: 50 push %eax 237f: 50 push %eax 2380: 68 12 47 00 00 push $0x4712 2385: 6a 01 push $0x1 2387: e8 64 16 00 00 call 39f0 <printf> exit(); 238c: e8 11 15 00 00 call 38a2 <exit> printf(1, "unlink dd/xx/ff succeeded!\n"); 2391: 50 push %eax 2392: 50 push %eax 2393: 68 f6 46 00 00 push $0x46f6 2398: 6a 01 push $0x1 239a: e8 51 16 00 00 call 39f0 <printf> exit(); 239f: e8 fe 14 00 00 call 38a2 <exit> printf(1, "mkdir dd/dd/ffff succeeded!\n"); 23a4: 50 push %eax 23a5: 50 push %eax 23a6: 68 d9 46 00 00 push $0x46d9 23ab: 6a 01 push $0x1 23ad: e8 3e 16 00 00 call 39f0 <printf> exit(); 23b2: e8 eb 14 00 00 call 38a2 <exit> printf(1, "mkdir dd/xx/ff succeeded!\n"); 23b7: 50 push %eax 23b8: 50 push %eax 23b9: 68 be 46 00 00 push $0x46be 23be: 6a 01 push $0x1 23c0: e8 2b 16 00 00 call 39f0 <printf> exit(); 23c5: e8 d8 14 00 00 call 38a2 <exit> printf(1, "read dd/dd/ffff wrong len\n"); 23ca: 50 push %eax 23cb: 50 push %eax 23cc: 68 eb 45 00 00 push $0x45eb 23d1: 6a 01 push $0x1 23d3: e8 18 16 00 00 call 39f0 <printf> exit(); 23d8: e8 c5 14 00 00 call 38a2 <exit> printf(1, "open dd/dd/ffff failed\n"); 23dd: 50 push %eax 23de: 50 push %eax 23df: 68 d3 45 00 00 push $0x45d3 23e4: 6a 01 push $0x1 23e6: e8 05 16 00 00 call 39f0 <printf> exit(); 23eb: e8 b2 14 00 00 call 38a2 <exit> 000023f0 <bigwrite>: { 23f0: 55 push %ebp 23f1: 89 e5 mov %esp,%ebp 23f3: 56 push %esi 23f4: 53 push %ebx for(sz = 499; sz < 12*512; sz += 471){ 23f5: bb f3 01 00 00 mov $0x1f3,%ebx printf(1, "bigwrite test\n"); 23fa: 83 ec 08 sub $0x8,%esp 23fd: 68 a5 47 00 00 push $0x47a5 2402: 6a 01 push $0x1 2404: e8 e7 15 00 00 call 39f0 <printf> unlink("bigwrite"); 2409: c7 04 24 b4 47 00 00 movl $0x47b4,(%esp) 2410: e8 dd 14 00 00 call 38f2 <unlink> 2415: 83 c4 10 add $0x10,%esp 2418: 90 nop 2419: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi fd = open("bigwrite", O_CREATE | O_RDWR); 2420: 83 ec 08 sub $0x8,%esp 2423: 68 02 02 00 00 push $0x202 2428: 68 b4 47 00 00 push $0x47b4 242d: e8 b0 14 00 00 call 38e2 <open> if(fd < 0){ 2432: 83 c4 10 add $0x10,%esp 2435: 85 c0 test %eax,%eax fd = open("bigwrite", O_CREATE | O_RDWR); 2437: 89 c6 mov %eax,%esi if(fd < 0){ 2439: 78 7e js 24b9 <bigwrite+0xc9> int cc = write(fd, buf, sz); 243b: 83 ec 04 sub $0x4,%esp 243e: 53 push %ebx 243f: 68 e0 85 00 00 push $0x85e0 2444: 50 push %eax 2445: e8 78 14 00 00 call 38c2 <write> if(cc != sz){ 244a: 83 c4 10 add $0x10,%esp 244d: 39 d8 cmp %ebx,%eax 244f: 75 55 jne 24a6 <bigwrite+0xb6> int cc = write(fd, buf, sz); 2451: 83 ec 04 sub $0x4,%esp 2454: 53 push %ebx 2455: 68 e0 85 00 00 push $0x85e0 245a: 56 push %esi 245b: e8 62 14 00 00 call 38c2 <write> if(cc != sz){ 2460: 83 c4 10 add $0x10,%esp 2463: 39 d8 cmp %ebx,%eax 2465: 75 3f jne 24a6 <bigwrite+0xb6> close(fd); 2467: 83 ec 0c sub $0xc,%esp for(sz = 499; sz < 12*512; sz += 471){ 246a: 81 c3 d7 01 00 00 add $0x1d7,%ebx close(fd); 2470: 56 push %esi 2471: e8 54 14 00 00 call 38ca <close> unlink("bigwrite"); 2476: c7 04 24 b4 47 00 00 movl $0x47b4,(%esp) 247d: e8 70 14 00 00 call 38f2 <unlink> for(sz = 499; sz < 12*512; sz += 471){ 2482: 83 c4 10 add $0x10,%esp 2485: 81 fb 07 18 00 00 cmp $0x1807,%ebx 248b: 75 93 jne 2420 <bigwrite+0x30> printf(1, "bigwrite ok\n"); 248d: 83 ec 08 sub $0x8,%esp 2490: 68 e7 47 00 00 push $0x47e7 2495: 6a 01 push $0x1 2497: e8 54 15 00 00 call 39f0 <printf> } 249c: 83 c4 10 add $0x10,%esp 249f: 8d 65 f8 lea -0x8(%ebp),%esp 24a2: 5b pop %ebx 24a3: 5e pop %esi 24a4: 5d pop %ebp 24a5: c3 ret printf(1, "write(%d) ret %d\n", sz, cc); 24a6: 50 push %eax 24a7: 53 push %ebx 24a8: 68 d5 47 00 00 push $0x47d5 24ad: 6a 01 push $0x1 24af: e8 3c 15 00 00 call 39f0 <printf> exit(); 24b4: e8 e9 13 00 00 call 38a2 <exit> printf(1, "cannot create bigwrite\n"); 24b9: 83 ec 08 sub $0x8,%esp 24bc: 68 bd 47 00 00 push $0x47bd 24c1: 6a 01 push $0x1 24c3: e8 28 15 00 00 call 39f0 <printf> exit(); 24c8: e8 d5 13 00 00 call 38a2 <exit> 24cd: 8d 76 00 lea 0x0(%esi),%esi 000024d0 <bigfile>: { 24d0: 55 push %ebp 24d1: 89 e5 mov %esp,%ebp 24d3: 57 push %edi 24d4: 56 push %esi 24d5: 53 push %ebx 24d6: 83 ec 14 sub $0x14,%esp printf(1, "bigfile test\n"); 24d9: 68 f4 47 00 00 push $0x47f4 24de: 6a 01 push $0x1 24e0: e8 0b 15 00 00 call 39f0 <printf> unlink("bigfile"); 24e5: c7 04 24 10 48 00 00 movl $0x4810,(%esp) 24ec: e8 01 14 00 00 call 38f2 <unlink> fd = open("bigfile", O_CREATE | O_RDWR); 24f1: 58 pop %eax 24f2: 5a pop %edx 24f3: 68 02 02 00 00 push $0x202 24f8: 68 10 48 00 00 push $0x4810 24fd: e8 e0 13 00 00 call 38e2 <open> if(fd < 0){ 2502: 83 c4 10 add $0x10,%esp 2505: 85 c0 test %eax,%eax 2507: 0f 88 5e 01 00 00 js 266b <bigfile+0x19b> 250d: 89 c6 mov %eax,%esi for(i = 0; i < 20; i++){ 250f: 31 db xor %ebx,%ebx 2511: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi memset(buf, i, 600); 2518: 83 ec 04 sub $0x4,%esp 251b: 68 58 02 00 00 push $0x258 2520: 53 push %ebx 2521: 68 e0 85 00 00 push $0x85e0 2526: e8 d5 11 00 00 call 3700 <memset> if(write(fd, buf, 600) != 600){ 252b: 83 c4 0c add $0xc,%esp 252e: 68 58 02 00 00 push $0x258 2533: 68 e0 85 00 00 push $0x85e0 2538: 56 push %esi 2539: e8 84 13 00 00 call 38c2 <write> 253e: 83 c4 10 add $0x10,%esp 2541: 3d 58 02 00 00 cmp $0x258,%eax 2546: 0f 85 f8 00 00 00 jne 2644 <bigfile+0x174> for(i = 0; i < 20; i++){ 254c: 83 c3 01 add $0x1,%ebx 254f: 83 fb 14 cmp $0x14,%ebx 2552: 75 c4 jne 2518 <bigfile+0x48> close(fd); 2554: 83 ec 0c sub $0xc,%esp 2557: 56 push %esi 2558: e8 6d 13 00 00 call 38ca <close> fd = open("bigfile", 0); 255d: 5e pop %esi 255e: 5f pop %edi 255f: 6a 00 push $0x0 2561: 68 10 48 00 00 push $0x4810 2566: e8 77 13 00 00 call 38e2 <open> if(fd < 0){ 256b: 83 c4 10 add $0x10,%esp 256e: 85 c0 test %eax,%eax fd = open("bigfile", 0); 2570: 89 c6 mov %eax,%esi if(fd < 0){ 2572: 0f 88 e0 00 00 00 js 2658 <bigfile+0x188> total = 0; 2578: 31 db xor %ebx,%ebx for(i = 0; ; i++){ 257a: 31 ff xor %edi,%edi 257c: eb 30 jmp 25ae <bigfile+0xde> 257e: 66 90 xchg %ax,%ax if(cc != 300){ 2580: 3d 2c 01 00 00 cmp $0x12c,%eax 2585: 0f 85 91 00 00 00 jne 261c <bigfile+0x14c> if(buf[0] != i/2 || buf[299] != i/2){ 258b: 0f be 05 e0 85 00 00 movsbl 0x85e0,%eax 2592: 89 fa mov %edi,%edx 2594: d1 fa sar %edx 2596: 39 d0 cmp %edx,%eax 2598: 75 6e jne 2608 <bigfile+0x138> 259a: 0f be 15 0b 87 00 00 movsbl 0x870b,%edx 25a1: 39 d0 cmp %edx,%eax 25a3: 75 63 jne 2608 <bigfile+0x138> total += cc; 25a5: 81 c3 2c 01 00 00 add $0x12c,%ebx for(i = 0; ; i++){ 25ab: 83 c7 01 add $0x1,%edi cc = read(fd, buf, 300); 25ae: 83 ec 04 sub $0x4,%esp 25b1: 68 2c 01 00 00 push $0x12c 25b6: 68 e0 85 00 00 push $0x85e0 25bb: 56 push %esi 25bc: e8 f9 12 00 00 call 38ba <read> if(cc < 0){ 25c1: 83 c4 10 add $0x10,%esp 25c4: 85 c0 test %eax,%eax 25c6: 78 68 js 2630 <bigfile+0x160> if(cc == 0) 25c8: 75 b6 jne 2580 <bigfile+0xb0> close(fd); 25ca: 83 ec 0c sub $0xc,%esp 25cd: 56 push %esi 25ce: e8 f7 12 00 00 call 38ca <close> if(total != 20*600){ 25d3: 83 c4 10 add $0x10,%esp 25d6: 81 fb e0 2e 00 00 cmp $0x2ee0,%ebx 25dc: 0f 85 9c 00 00 00 jne 267e <bigfile+0x1ae> unlink("bigfile"); 25e2: 83 ec 0c sub $0xc,%esp 25e5: 68 10 48 00 00 push $0x4810 25ea: e8 03 13 00 00 call 38f2 <unlink> printf(1, "bigfile test ok\n"); 25ef: 58 pop %eax 25f0: 5a pop %edx 25f1: 68 9f 48 00 00 push $0x489f 25f6: 6a 01 push $0x1 25f8: e8 f3 13 00 00 call 39f0 <printf> } 25fd: 83 c4 10 add $0x10,%esp 2600: 8d 65 f4 lea -0xc(%ebp),%esp 2603: 5b pop %ebx 2604: 5e pop %esi 2605: 5f pop %edi 2606: 5d pop %ebp 2607: c3 ret printf(1, "read bigfile wrong data\n"); 2608: 83 ec 08 sub $0x8,%esp 260b: 68 6c 48 00 00 push $0x486c 2610: 6a 01 push $0x1 2612: e8 d9 13 00 00 call 39f0 <printf> exit(); 2617: e8 86 12 00 00 call 38a2 <exit> printf(1, "short read bigfile\n"); 261c: 83 ec 08 sub $0x8,%esp 261f: 68 58 48 00 00 push $0x4858 2624: 6a 01 push $0x1 2626: e8 c5 13 00 00 call 39f0 <printf> exit(); 262b: e8 72 12 00 00 call 38a2 <exit> printf(1, "read bigfile failed\n"); 2630: 83 ec 08 sub $0x8,%esp 2633: 68 43 48 00 00 push $0x4843 2638: 6a 01 push $0x1 263a: e8 b1 13 00 00 call 39f0 <printf> exit(); 263f: e8 5e 12 00 00 call 38a2 <exit> printf(1, "write bigfile failed\n"); 2644: 83 ec 08 sub $0x8,%esp 2647: 68 18 48 00 00 push $0x4818 264c: 6a 01 push $0x1 264e: e8 9d 13 00 00 call 39f0 <printf> exit(); 2653: e8 4a 12 00 00 call 38a2 <exit> printf(1, "cannot open bigfile\n"); 2658: 53 push %ebx 2659: 53 push %ebx 265a: 68 2e 48 00 00 push $0x482e 265f: 6a 01 push $0x1 2661: e8 8a 13 00 00 call 39f0 <printf> exit(); 2666: e8 37 12 00 00 call 38a2 <exit> printf(1, "cannot create bigfile"); 266b: 50 push %eax 266c: 50 push %eax 266d: 68 02 48 00 00 push $0x4802 2672: 6a 01 push $0x1 2674: e8 77 13 00 00 call 39f0 <printf> exit(); 2679: e8 24 12 00 00 call 38a2 <exit> printf(1, "read bigfile wrong total\n"); 267e: 51 push %ecx 267f: 51 push %ecx 2680: 68 85 48 00 00 push $0x4885 2685: 6a 01 push $0x1 2687: e8 64 13 00 00 call 39f0 <printf> exit(); 268c: e8 11 12 00 00 call 38a2 <exit> 2691: eb 0d jmp 26a0 <fourteen> 2693: 90 nop 2694: 90 nop 2695: 90 nop 2696: 90 nop 2697: 90 nop 2698: 90 nop 2699: 90 nop 269a: 90 nop 269b: 90 nop 269c: 90 nop 269d: 90 nop 269e: 90 nop 269f: 90 nop 000026a0 <fourteen>: { 26a0: 55 push %ebp 26a1: 89 e5 mov %esp,%ebp 26a3: 83 ec 10 sub $0x10,%esp printf(1, "fourteen test\n"); 26a6: 68 b0 48 00 00 push $0x48b0 26ab: 6a 01 push $0x1 26ad: e8 3e 13 00 00 call 39f0 <printf> if(mkdir("12345678901234") != 0){ 26b2: c7 04 24 eb 48 00 00 movl $0x48eb,(%esp) 26b9: e8 4c 12 00 00 call 390a <mkdir> 26be: 83 c4 10 add $0x10,%esp 26c1: 85 c0 test %eax,%eax 26c3: 0f 85 97 00 00 00 jne 2760 <fourteen+0xc0> if(mkdir("12345678901234/123456789012345") != 0){ 26c9: 83 ec 0c sub $0xc,%esp 26cc: 68 a8 50 00 00 push $0x50a8 26d1: e8 34 12 00 00 call 390a <mkdir> 26d6: 83 c4 10 add $0x10,%esp 26d9: 85 c0 test %eax,%eax 26db: 0f 85 de 00 00 00 jne 27bf <fourteen+0x11f> fd = open("123456789012345/123456789012345/123456789012345", O_CREATE); 26e1: 83 ec 08 sub $0x8,%esp 26e4: 68 00 02 00 00 push $0x200 26e9: 68 f8 50 00 00 push $0x50f8 26ee: e8 ef 11 00 00 call 38e2 <open> if(fd < 0){ 26f3: 83 c4 10 add $0x10,%esp 26f6: 85 c0 test %eax,%eax 26f8: 0f 88 ae 00 00 00 js 27ac <fourteen+0x10c> close(fd); 26fe: 83 ec 0c sub $0xc,%esp 2701: 50 push %eax 2702: e8 c3 11 00 00 call 38ca <close> fd = open("12345678901234/12345678901234/12345678901234", 0); 2707: 58 pop %eax 2708: 5a pop %edx 2709: 6a 00 push $0x0 270b: 68 68 51 00 00 push $0x5168 2710: e8 cd 11 00 00 call 38e2 <open> if(fd < 0){ 2715: 83 c4 10 add $0x10,%esp 2718: 85 c0 test %eax,%eax 271a: 78 7d js 2799 <fourteen+0xf9> close(fd); 271c: 83 ec 0c sub $0xc,%esp 271f: 50 push %eax 2720: e8 a5 11 00 00 call 38ca <close> if(mkdir("12345678901234/12345678901234") == 0){ 2725: c7 04 24 dc 48 00 00 movl $0x48dc,(%esp) 272c: e8 d9 11 00 00 call 390a <mkdir> 2731: 83 c4 10 add $0x10,%esp 2734: 85 c0 test %eax,%eax 2736: 74 4e je 2786 <fourteen+0xe6> if(mkdir("123456789012345/12345678901234") == 0){ 2738: 83 ec 0c sub $0xc,%esp 273b: 68 04 52 00 00 push $0x5204 2740: e8 c5 11 00 00 call 390a <mkdir> 2745: 83 c4 10 add $0x10,%esp 2748: 85 c0 test %eax,%eax 274a: 74 27 je 2773 <fourteen+0xd3> printf(1, "fourteen ok\n"); 274c: 83 ec 08 sub $0x8,%esp 274f: 68 fa 48 00 00 push $0x48fa 2754: 6a 01 push $0x1 2756: e8 95 12 00 00 call 39f0 <printf> } 275b: 83 c4 10 add $0x10,%esp 275e: c9 leave 275f: c3 ret printf(1, "mkdir 12345678901234 failed\n"); 2760: 50 push %eax 2761: 50 push %eax 2762: 68 bf 48 00 00 push $0x48bf 2767: 6a 01 push $0x1 2769: e8 82 12 00 00 call 39f0 <printf> exit(); 276e: e8 2f 11 00 00 call 38a2 <exit> printf(1, "mkdir 12345678901234/123456789012345 succeeded!\n"); 2773: 50 push %eax 2774: 50 push %eax 2775: 68 24 52 00 00 push $0x5224 277a: 6a 01 push $0x1 277c: e8 6f 12 00 00 call 39f0 <printf> exit(); 2781: e8 1c 11 00 00 call 38a2 <exit> printf(1, "mkdir 12345678901234/12345678901234 succeeded!\n"); 2786: 52 push %edx 2787: 52 push %edx 2788: 68 d4 51 00 00 push $0x51d4 278d: 6a 01 push $0x1 278f: e8 5c 12 00 00 call 39f0 <printf> exit(); 2794: e8 09 11 00 00 call 38a2 <exit> printf(1, "open 12345678901234/12345678901234/12345678901234 failed\n"); 2799: 51 push %ecx 279a: 51 push %ecx 279b: 68 98 51 00 00 push $0x5198 27a0: 6a 01 push $0x1 27a2: e8 49 12 00 00 call 39f0 <printf> exit(); 27a7: e8 f6 10 00 00 call 38a2 <exit> printf(1, "create 123456789012345/123456789012345/123456789012345 failed\n"); 27ac: 51 push %ecx 27ad: 51 push %ecx 27ae: 68 28 51 00 00 push $0x5128 27b3: 6a 01 push $0x1 27b5: e8 36 12 00 00 call 39f0 <printf> exit(); 27ba: e8 e3 10 00 00 call 38a2 <exit> printf(1, "mkdir 12345678901234/123456789012345 failed\n"); 27bf: 50 push %eax 27c0: 50 push %eax 27c1: 68 c8 50 00 00 push $0x50c8 27c6: 6a 01 push $0x1 27c8: e8 23 12 00 00 call 39f0 <printf> exit(); 27cd: e8 d0 10 00 00 call 38a2 <exit> 27d2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 27d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000027e0 <rmdot>: { 27e0: 55 push %ebp 27e1: 89 e5 mov %esp,%ebp 27e3: 83 ec 10 sub $0x10,%esp printf(1, "rmdot test\n"); 27e6: 68 07 49 00 00 push $0x4907 27eb: 6a 01 push $0x1 27ed: e8 fe 11 00 00 call 39f0 <printf> if(mkdir("dots") != 0){ 27f2: c7 04 24 13 49 00 00 movl $0x4913,(%esp) 27f9: e8 0c 11 00 00 call 390a <mkdir> 27fe: 83 c4 10 add $0x10,%esp 2801: 85 c0 test %eax,%eax 2803: 0f 85 b0 00 00 00 jne 28b9 <rmdot+0xd9> if(chdir("dots") != 0){ 2809: 83 ec 0c sub $0xc,%esp 280c: 68 13 49 00 00 push $0x4913 2811: e8 fc 10 00 00 call 3912 <chdir> 2816: 83 c4 10 add $0x10,%esp 2819: 85 c0 test %eax,%eax 281b: 0f 85 1d 01 00 00 jne 293e <rmdot+0x15e> if(unlink(".") == 0){ 2821: 83 ec 0c sub $0xc,%esp 2824: 68 be 45 00 00 push $0x45be 2829: e8 c4 10 00 00 call 38f2 <unlink> 282e: 83 c4 10 add $0x10,%esp 2831: 85 c0 test %eax,%eax 2833: 0f 84 f2 00 00 00 je 292b <rmdot+0x14b> if(unlink("..") == 0){ 2839: 83 ec 0c sub $0xc,%esp 283c: 68 bd 45 00 00 push $0x45bd 2841: e8 ac 10 00 00 call 38f2 <unlink> 2846: 83 c4 10 add $0x10,%esp 2849: 85 c0 test %eax,%eax 284b: 0f 84 c7 00 00 00 je 2918 <rmdot+0x138> if(chdir("/") != 0){ 2851: 83 ec 0c sub $0xc,%esp 2854: 68 91 3d 00 00 push $0x3d91 2859: e8 b4 10 00 00 call 3912 <chdir> 285e: 83 c4 10 add $0x10,%esp 2861: 85 c0 test %eax,%eax 2863: 0f 85 9c 00 00 00 jne 2905 <rmdot+0x125> if(unlink("dots/.") == 0){ 2869: 83 ec 0c sub $0xc,%esp 286c: 68 5b 49 00 00 push $0x495b 2871: e8 7c 10 00 00 call 38f2 <unlink> 2876: 83 c4 10 add $0x10,%esp 2879: 85 c0 test %eax,%eax 287b: 74 75 je 28f2 <rmdot+0x112> if(unlink("dots/..") == 0){ 287d: 83 ec 0c sub $0xc,%esp 2880: 68 79 49 00 00 push $0x4979 2885: e8 68 10 00 00 call 38f2 <unlink> 288a: 83 c4 10 add $0x10,%esp 288d: 85 c0 test %eax,%eax 288f: 74 4e je 28df <rmdot+0xff> if(unlink("dots") != 0){ 2891: 83 ec 0c sub $0xc,%esp 2894: 68 13 49 00 00 push $0x4913 2899: e8 54 10 00 00 call 38f2 <unlink> 289e: 83 c4 10 add $0x10,%esp 28a1: 85 c0 test %eax,%eax 28a3: 75 27 jne 28cc <rmdot+0xec> printf(1, "rmdot ok\n"); 28a5: 83 ec 08 sub $0x8,%esp 28a8: 68 ae 49 00 00 push $0x49ae 28ad: 6a 01 push $0x1 28af: e8 3c 11 00 00 call 39f0 <printf> } 28b4: 83 c4 10 add $0x10,%esp 28b7: c9 leave 28b8: c3 ret printf(1, "mkdir dots failed\n"); 28b9: 50 push %eax 28ba: 50 push %eax 28bb: 68 18 49 00 00 push $0x4918 28c0: 6a 01 push $0x1 28c2: e8 29 11 00 00 call 39f0 <printf> exit(); 28c7: e8 d6 0f 00 00 call 38a2 <exit> printf(1, "unlink dots failed!\n"); 28cc: 50 push %eax 28cd: 50 push %eax 28ce: 68 99 49 00 00 push $0x4999 28d3: 6a 01 push $0x1 28d5: e8 16 11 00 00 call 39f0 <printf> exit(); 28da: e8 c3 0f 00 00 call 38a2 <exit> printf(1, "unlink dots/.. worked!\n"); 28df: 52 push %edx 28e0: 52 push %edx 28e1: 68 81 49 00 00 push $0x4981 28e6: 6a 01 push $0x1 28e8: e8 03 11 00 00 call 39f0 <printf> exit(); 28ed: e8 b0 0f 00 00 call 38a2 <exit> printf(1, "unlink dots/. worked!\n"); 28f2: 51 push %ecx 28f3: 51 push %ecx 28f4: 68 62 49 00 00 push $0x4962 28f9: 6a 01 push $0x1 28fb: e8 f0 10 00 00 call 39f0 <printf> exit(); 2900: e8 9d 0f 00 00 call 38a2 <exit> printf(1, "chdir / failed\n"); 2905: 50 push %eax 2906: 50 push %eax 2907: 68 93 3d 00 00 push $0x3d93 290c: 6a 01 push $0x1 290e: e8 dd 10 00 00 call 39f0 <printf> exit(); 2913: e8 8a 0f 00 00 call 38a2 <exit> printf(1, "rm .. worked!\n"); 2918: 50 push %eax 2919: 50 push %eax 291a: 68 4c 49 00 00 push $0x494c 291f: 6a 01 push $0x1 2921: e8 ca 10 00 00 call 39f0 <printf> exit(); 2926: e8 77 0f 00 00 call 38a2 <exit> printf(1, "rm . worked!\n"); 292b: 50 push %eax 292c: 50 push %eax 292d: 68 3e 49 00 00 push $0x493e 2932: 6a 01 push $0x1 2934: e8 b7 10 00 00 call 39f0 <printf> exit(); 2939: e8 64 0f 00 00 call 38a2 <exit> printf(1, "chdir dots failed\n"); 293e: 50 push %eax 293f: 50 push %eax 2940: 68 2b 49 00 00 push $0x492b 2945: 6a 01 push $0x1 2947: e8 a4 10 00 00 call 39f0 <printf> exit(); 294c: e8 51 0f 00 00 call 38a2 <exit> 2951: eb 0d jmp 2960 <dirfile> 2953: 90 nop 2954: 90 nop 2955: 90 nop 2956: 90 nop 2957: 90 nop 2958: 90 nop 2959: 90 nop 295a: 90 nop 295b: 90 nop 295c: 90 nop 295d: 90 nop 295e: 90 nop 295f: 90 nop 00002960 <dirfile>: { 2960: 55 push %ebp 2961: 89 e5 mov %esp,%ebp 2963: 53 push %ebx 2964: 83 ec 0c sub $0xc,%esp printf(1, "dir vs file\n"); 2967: 68 b8 49 00 00 push $0x49b8 296c: 6a 01 push $0x1 296e: e8 7d 10 00 00 call 39f0 <printf> fd = open("dirfile", O_CREATE); 2973: 59 pop %ecx 2974: 5b pop %ebx 2975: 68 00 02 00 00 push $0x200 297a: 68 c5 49 00 00 push $0x49c5 297f: e8 5e 0f 00 00 call 38e2 <open> if(fd < 0){ 2984: 83 c4 10 add $0x10,%esp 2987: 85 c0 test %eax,%eax 2989: 0f 88 43 01 00 00 js 2ad2 <dirfile+0x172> close(fd); 298f: 83 ec 0c sub $0xc,%esp 2992: 50 push %eax 2993: e8 32 0f 00 00 call 38ca <close> if(chdir("dirfile") == 0){ 2998: c7 04 24 c5 49 00 00 movl $0x49c5,(%esp) 299f: e8 6e 0f 00 00 call 3912 <chdir> 29a4: 83 c4 10 add $0x10,%esp 29a7: 85 c0 test %eax,%eax 29a9: 0f 84 10 01 00 00 je 2abf <dirfile+0x15f> fd = open("dirfile/xx", 0); 29af: 83 ec 08 sub $0x8,%esp 29b2: 6a 00 push $0x0 29b4: 68 fe 49 00 00 push $0x49fe 29b9: e8 24 0f 00 00 call 38e2 <open> if(fd >= 0){ 29be: 83 c4 10 add $0x10,%esp 29c1: 85 c0 test %eax,%eax 29c3: 0f 89 e3 00 00 00 jns 2aac <dirfile+0x14c> fd = open("dirfile/xx", O_CREATE); 29c9: 83 ec 08 sub $0x8,%esp 29cc: 68 00 02 00 00 push $0x200 29d1: 68 fe 49 00 00 push $0x49fe 29d6: e8 07 0f 00 00 call 38e2 <open> if(fd >= 0){ 29db: 83 c4 10 add $0x10,%esp 29de: 85 c0 test %eax,%eax 29e0: 0f 89 c6 00 00 00 jns 2aac <dirfile+0x14c> if(mkdir("dirfile/xx") == 0){ 29e6: 83 ec 0c sub $0xc,%esp 29e9: 68 fe 49 00 00 push $0x49fe 29ee: e8 17 0f 00 00 call 390a <mkdir> 29f3: 83 c4 10 add $0x10,%esp 29f6: 85 c0 test %eax,%eax 29f8: 0f 84 46 01 00 00 je 2b44 <dirfile+0x1e4> if(unlink("dirfile/xx") == 0){ 29fe: 83 ec 0c sub $0xc,%esp 2a01: 68 fe 49 00 00 push $0x49fe 2a06: e8 e7 0e 00 00 call 38f2 <unlink> 2a0b: 83 c4 10 add $0x10,%esp 2a0e: 85 c0 test %eax,%eax 2a10: 0f 84 1b 01 00 00 je 2b31 <dirfile+0x1d1> if(link("README", "dirfile/xx") == 0){ 2a16: 83 ec 08 sub $0x8,%esp 2a19: 68 fe 49 00 00 push $0x49fe 2a1e: 68 62 4a 00 00 push $0x4a62 2a23: e8 da 0e 00 00 call 3902 <link> 2a28: 83 c4 10 add $0x10,%esp 2a2b: 85 c0 test %eax,%eax 2a2d: 0f 84 eb 00 00 00 je 2b1e <dirfile+0x1be> if(unlink("dirfile") != 0){ 2a33: 83 ec 0c sub $0xc,%esp 2a36: 68 c5 49 00 00 push $0x49c5 2a3b: e8 b2 0e 00 00 call 38f2 <unlink> 2a40: 83 c4 10 add $0x10,%esp 2a43: 85 c0 test %eax,%eax 2a45: 0f 85 c0 00 00 00 jne 2b0b <dirfile+0x1ab> fd = open(".", O_RDWR); 2a4b: 83 ec 08 sub $0x8,%esp 2a4e: 6a 02 push $0x2 2a50: 68 be 45 00 00 push $0x45be 2a55: e8 88 0e 00 00 call 38e2 <open> if(fd >= 0){ 2a5a: 83 c4 10 add $0x10,%esp 2a5d: 85 c0 test %eax,%eax 2a5f: 0f 89 93 00 00 00 jns 2af8 <dirfile+0x198> fd = open(".", 0); 2a65: 83 ec 08 sub $0x8,%esp 2a68: 6a 00 push $0x0 2a6a: 68 be 45 00 00 push $0x45be 2a6f: e8 6e 0e 00 00 call 38e2 <open> if(write(fd, "x", 1) > 0){ 2a74: 83 c4 0c add $0xc,%esp fd = open(".", 0); 2a77: 89 c3 mov %eax,%ebx if(write(fd, "x", 1) > 0){ 2a79: 6a 01 push $0x1 2a7b: 68 a1 46 00 00 push $0x46a1 2a80: 50 push %eax 2a81: e8 3c 0e 00 00 call 38c2 <write> 2a86: 83 c4 10 add $0x10,%esp 2a89: 85 c0 test %eax,%eax 2a8b: 7f 58 jg 2ae5 <dirfile+0x185> close(fd); 2a8d: 83 ec 0c sub $0xc,%esp 2a90: 53 push %ebx 2a91: e8 34 0e 00 00 call 38ca <close> printf(1, "dir vs file OK\n"); 2a96: 58 pop %eax 2a97: 5a pop %edx 2a98: 68 95 4a 00 00 push $0x4a95 2a9d: 6a 01 push $0x1 2a9f: e8 4c 0f 00 00 call 39f0 <printf> } 2aa4: 83 c4 10 add $0x10,%esp 2aa7: 8b 5d fc mov -0x4(%ebp),%ebx 2aaa: c9 leave 2aab: c3 ret printf(1, "create dirfile/xx succeeded!\n"); 2aac: 50 push %eax 2aad: 50 push %eax 2aae: 68 09 4a 00 00 push $0x4a09 2ab3: 6a 01 push $0x1 2ab5: e8 36 0f 00 00 call 39f0 <printf> exit(); 2aba: e8 e3 0d 00 00 call 38a2 <exit> printf(1, "chdir dirfile succeeded!\n"); 2abf: 50 push %eax 2ac0: 50 push %eax 2ac1: 68 e4 49 00 00 push $0x49e4 2ac6: 6a 01 push $0x1 2ac8: e8 23 0f 00 00 call 39f0 <printf> exit(); 2acd: e8 d0 0d 00 00 call 38a2 <exit> printf(1, "create dirfile failed\n"); 2ad2: 52 push %edx 2ad3: 52 push %edx 2ad4: 68 cd 49 00 00 push $0x49cd 2ad9: 6a 01 push $0x1 2adb: e8 10 0f 00 00 call 39f0 <printf> exit(); 2ae0: e8 bd 0d 00 00 call 38a2 <exit> printf(1, "write . succeeded!\n"); 2ae5: 51 push %ecx 2ae6: 51 push %ecx 2ae7: 68 81 4a 00 00 push $0x4a81 2aec: 6a 01 push $0x1 2aee: e8 fd 0e 00 00 call 39f0 <printf> exit(); 2af3: e8 aa 0d 00 00 call 38a2 <exit> printf(1, "open . for writing succeeded!\n"); 2af8: 53 push %ebx 2af9: 53 push %ebx 2afa: 68 78 52 00 00 push $0x5278 2aff: 6a 01 push $0x1 2b01: e8 ea 0e 00 00 call 39f0 <printf> exit(); 2b06: e8 97 0d 00 00 call 38a2 <exit> printf(1, "unlink dirfile failed!\n"); 2b0b: 50 push %eax 2b0c: 50 push %eax 2b0d: 68 69 4a 00 00 push $0x4a69 2b12: 6a 01 push $0x1 2b14: e8 d7 0e 00 00 call 39f0 <printf> exit(); 2b19: e8 84 0d 00 00 call 38a2 <exit> printf(1, "link to dirfile/xx succeeded!\n"); 2b1e: 50 push %eax 2b1f: 50 push %eax 2b20: 68 58 52 00 00 push $0x5258 2b25: 6a 01 push $0x1 2b27: e8 c4 0e 00 00 call 39f0 <printf> exit(); 2b2c: e8 71 0d 00 00 call 38a2 <exit> printf(1, "unlink dirfile/xx succeeded!\n"); 2b31: 50 push %eax 2b32: 50 push %eax 2b33: 68 44 4a 00 00 push $0x4a44 2b38: 6a 01 push $0x1 2b3a: e8 b1 0e 00 00 call 39f0 <printf> exit(); 2b3f: e8 5e 0d 00 00 call 38a2 <exit> printf(1, "mkdir dirfile/xx succeeded!\n"); 2b44: 50 push %eax 2b45: 50 push %eax 2b46: 68 27 4a 00 00 push $0x4a27 2b4b: 6a 01 push $0x1 2b4d: e8 9e 0e 00 00 call 39f0 <printf> exit(); 2b52: e8 4b 0d 00 00 call 38a2 <exit> 2b57: 89 f6 mov %esi,%esi 2b59: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00002b60 <iref>: { 2b60: 55 push %ebp 2b61: 89 e5 mov %esp,%ebp 2b63: 53 push %ebx printf(1, "empty file name\n"); 2b64: bb 33 00 00 00 mov $0x33,%ebx { 2b69: 83 ec 0c sub $0xc,%esp printf(1, "empty file name\n"); 2b6c: 68 a5 4a 00 00 push $0x4aa5 2b71: 6a 01 push $0x1 2b73: e8 78 0e 00 00 call 39f0 <printf> 2b78: 83 c4 10 add $0x10,%esp 2b7b: 90 nop 2b7c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(mkdir("irefd") != 0){ 2b80: 83 ec 0c sub $0xc,%esp 2b83: 68 b6 4a 00 00 push $0x4ab6 2b88: e8 7d 0d 00 00 call 390a <mkdir> 2b8d: 83 c4 10 add $0x10,%esp 2b90: 85 c0 test %eax,%eax 2b92: 0f 85 bb 00 00 00 jne 2c53 <iref+0xf3> if(chdir("irefd") != 0){ 2b98: 83 ec 0c sub $0xc,%esp 2b9b: 68 b6 4a 00 00 push $0x4ab6 2ba0: e8 6d 0d 00 00 call 3912 <chdir> 2ba5: 83 c4 10 add $0x10,%esp 2ba8: 85 c0 test %eax,%eax 2baa: 0f 85 b7 00 00 00 jne 2c67 <iref+0x107> mkdir(""); 2bb0: 83 ec 0c sub $0xc,%esp 2bb3: 68 6b 41 00 00 push $0x416b 2bb8: e8 4d 0d 00 00 call 390a <mkdir> link("README", ""); 2bbd: 59 pop %ecx 2bbe: 58 pop %eax 2bbf: 68 6b 41 00 00 push $0x416b 2bc4: 68 62 4a 00 00 push $0x4a62 2bc9: e8 34 0d 00 00 call 3902 <link> fd = open("", O_CREATE); 2bce: 58 pop %eax 2bcf: 5a pop %edx 2bd0: 68 00 02 00 00 push $0x200 2bd5: 68 6b 41 00 00 push $0x416b 2bda: e8 03 0d 00 00 call 38e2 <open> if(fd >= 0) 2bdf: 83 c4 10 add $0x10,%esp 2be2: 85 c0 test %eax,%eax 2be4: 78 0c js 2bf2 <iref+0x92> close(fd); 2be6: 83 ec 0c sub $0xc,%esp 2be9: 50 push %eax 2bea: e8 db 0c 00 00 call 38ca <close> 2bef: 83 c4 10 add $0x10,%esp fd = open("xx", O_CREATE); 2bf2: 83 ec 08 sub $0x8,%esp 2bf5: 68 00 02 00 00 push $0x200 2bfa: 68 a0 46 00 00 push $0x46a0 2bff: e8 de 0c 00 00 call 38e2 <open> if(fd >= 0) 2c04: 83 c4 10 add $0x10,%esp 2c07: 85 c0 test %eax,%eax 2c09: 78 0c js 2c17 <iref+0xb7> close(fd); 2c0b: 83 ec 0c sub $0xc,%esp 2c0e: 50 push %eax 2c0f: e8 b6 0c 00 00 call 38ca <close> 2c14: 83 c4 10 add $0x10,%esp unlink("xx"); 2c17: 83 ec 0c sub $0xc,%esp 2c1a: 68 a0 46 00 00 push $0x46a0 2c1f: e8 ce 0c 00 00 call 38f2 <unlink> for(i = 0; i < 50 + 1; i++){ 2c24: 83 c4 10 add $0x10,%esp 2c27: 83 eb 01 sub $0x1,%ebx 2c2a: 0f 85 50 ff ff ff jne 2b80 <iref+0x20> chdir("/"); 2c30: 83 ec 0c sub $0xc,%esp 2c33: 68 91 3d 00 00 push $0x3d91 2c38: e8 d5 0c 00 00 call 3912 <chdir> printf(1, "empty file name OK\n"); 2c3d: 58 pop %eax 2c3e: 5a pop %edx 2c3f: 68 e4 4a 00 00 push $0x4ae4 2c44: 6a 01 push $0x1 2c46: e8 a5 0d 00 00 call 39f0 <printf> } 2c4b: 83 c4 10 add $0x10,%esp 2c4e: 8b 5d fc mov -0x4(%ebp),%ebx 2c51: c9 leave 2c52: c3 ret printf(1, "mkdir irefd failed\n"); 2c53: 83 ec 08 sub $0x8,%esp 2c56: 68 bc 4a 00 00 push $0x4abc 2c5b: 6a 01 push $0x1 2c5d: e8 8e 0d 00 00 call 39f0 <printf> exit(); 2c62: e8 3b 0c 00 00 call 38a2 <exit> printf(1, "chdir irefd failed\n"); 2c67: 83 ec 08 sub $0x8,%esp 2c6a: 68 d0 4a 00 00 push $0x4ad0 2c6f: 6a 01 push $0x1 2c71: e8 7a 0d 00 00 call 39f0 <printf> exit(); 2c76: e8 27 0c 00 00 call 38a2 <exit> 2c7b: 90 nop 2c7c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00002c80 <forktest>: { 2c80: 55 push %ebp 2c81: 89 e5 mov %esp,%ebp 2c83: 53 push %ebx for(n=0; n<1000; n++){ 2c84: 31 db xor %ebx,%ebx { 2c86: 83 ec 0c sub $0xc,%esp printf(1, "fork test\n"); 2c89: 68 f8 4a 00 00 push $0x4af8 2c8e: 6a 01 push $0x1 2c90: e8 5b 0d 00 00 call 39f0 <printf> 2c95: 83 c4 10 add $0x10,%esp 2c98: eb 13 jmp 2cad <forktest+0x2d> 2c9a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(pid == 0) 2ca0: 74 62 je 2d04 <forktest+0x84> for(n=0; n<1000; n++){ 2ca2: 83 c3 01 add $0x1,%ebx 2ca5: 81 fb e8 03 00 00 cmp $0x3e8,%ebx 2cab: 74 43 je 2cf0 <forktest+0x70> pid = fork(); 2cad: e8 e8 0b 00 00 call 389a <fork> if(pid < 0) 2cb2: 85 c0 test %eax,%eax 2cb4: 79 ea jns 2ca0 <forktest+0x20> for(; n > 0; n--){ 2cb6: 85 db test %ebx,%ebx 2cb8: 74 14 je 2cce <forktest+0x4e> 2cba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(wait() < 0){ 2cc0: e8 e5 0b 00 00 call 38aa <wait> 2cc5: 85 c0 test %eax,%eax 2cc7: 78 40 js 2d09 <forktest+0x89> for(; n > 0; n--){ 2cc9: 83 eb 01 sub $0x1,%ebx 2ccc: 75 f2 jne 2cc0 <forktest+0x40> if(wait() != -1){ 2cce: e8 d7 0b 00 00 call 38aa <wait> 2cd3: 83 f8 ff cmp $0xffffffff,%eax 2cd6: 75 45 jne 2d1d <forktest+0x9d> printf(1, "fork test OK\n"); 2cd8: 83 ec 08 sub $0x8,%esp 2cdb: 68 2a 4b 00 00 push $0x4b2a 2ce0: 6a 01 push $0x1 2ce2: e8 09 0d 00 00 call 39f0 <printf> } 2ce7: 8b 5d fc mov -0x4(%ebp),%ebx 2cea: c9 leave 2ceb: c3 ret 2cec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi printf(1, "fork claimed to work 1000 times!\n"); 2cf0: 83 ec 08 sub $0x8,%esp 2cf3: 68 98 52 00 00 push $0x5298 2cf8: 6a 01 push $0x1 2cfa: e8 f1 0c 00 00 call 39f0 <printf> exit(); 2cff: e8 9e 0b 00 00 call 38a2 <exit> exit(); 2d04: e8 99 0b 00 00 call 38a2 <exit> printf(1, "wait stopped early\n"); 2d09: 83 ec 08 sub $0x8,%esp 2d0c: 68 03 4b 00 00 push $0x4b03 2d11: 6a 01 push $0x1 2d13: e8 d8 0c 00 00 call 39f0 <printf> exit(); 2d18: e8 85 0b 00 00 call 38a2 <exit> printf(1, "wait got too many\n"); 2d1d: 50 push %eax 2d1e: 50 push %eax 2d1f: 68 17 4b 00 00 push $0x4b17 2d24: 6a 01 push $0x1 2d26: e8 c5 0c 00 00 call 39f0 <printf> exit(); 2d2b: e8 72 0b 00 00 call 38a2 <exit> 00002d30 <sbrktest>: { 2d30: 55 push %ebp 2d31: 89 e5 mov %esp,%ebp 2d33: 57 push %edi 2d34: 56 push %esi 2d35: 53 push %ebx for(i = 0; i < 5000; i++){ 2d36: 31 ff xor %edi,%edi { 2d38: 83 ec 64 sub $0x64,%esp printf(stdout, "sbrk test\n"); 2d3b: 68 38 4b 00 00 push $0x4b38 2d40: ff 35 f8 5d 00 00 pushl 0x5df8 2d46: e8 a5 0c 00 00 call 39f0 <printf> oldbrk = sbrk(0); 2d4b: c7 04 24 00 00 00 00 movl $0x0,(%esp) 2d52: e8 d3 0b 00 00 call 392a <sbrk> a = sbrk(0); 2d57: c7 04 24 00 00 00 00 movl $0x0,(%esp) oldbrk = sbrk(0); 2d5e: 89 c3 mov %eax,%ebx a = sbrk(0); 2d60: e8 c5 0b 00 00 call 392a <sbrk> 2d65: 83 c4 10 add $0x10,%esp 2d68: 89 c6 mov %eax,%esi 2d6a: eb 06 jmp 2d72 <sbrktest+0x42> 2d6c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi a = b + 1; 2d70: 89 c6 mov %eax,%esi b = sbrk(1); 2d72: 83 ec 0c sub $0xc,%esp 2d75: 6a 01 push $0x1 2d77: e8 ae 0b 00 00 call 392a <sbrk> if(b != a){ 2d7c: 83 c4 10 add $0x10,%esp 2d7f: 39 f0 cmp %esi,%eax 2d81: 0f 85 62 02 00 00 jne 2fe9 <sbrktest+0x2b9> for(i = 0; i < 5000; i++){ 2d87: 83 c7 01 add $0x1,%edi *b = 1; 2d8a: c6 06 01 movb $0x1,(%esi) a = b + 1; 2d8d: 8d 46 01 lea 0x1(%esi),%eax for(i = 0; i < 5000; i++){ 2d90: 81 ff 88 13 00 00 cmp $0x1388,%edi 2d96: 75 d8 jne 2d70 <sbrktest+0x40> pid = fork(); 2d98: e8 fd 0a 00 00 call 389a <fork> if(pid < 0){ 2d9d: 85 c0 test %eax,%eax pid = fork(); 2d9f: 89 c7 mov %eax,%edi if(pid < 0){ 2da1: 0f 88 82 03 00 00 js 3129 <sbrktest+0x3f9> c = sbrk(1); 2da7: 83 ec 0c sub $0xc,%esp if(c != a + 1){ 2daa: 83 c6 02 add $0x2,%esi c = sbrk(1); 2dad: 6a 01 push $0x1 2daf: e8 76 0b 00 00 call 392a <sbrk> c = sbrk(1); 2db4: c7 04 24 01 00 00 00 movl $0x1,(%esp) 2dbb: e8 6a 0b 00 00 call 392a <sbrk> if(c != a + 1){ 2dc0: 83 c4 10 add $0x10,%esp 2dc3: 39 f0 cmp %esi,%eax 2dc5: 0f 85 47 03 00 00 jne 3112 <sbrktest+0x3e2> if(pid == 0) 2dcb: 85 ff test %edi,%edi 2dcd: 0f 84 3a 03 00 00 je 310d <sbrktest+0x3dd> wait(); 2dd3: e8 d2 0a 00 00 call 38aa <wait> a = sbrk(0); 2dd8: 83 ec 0c sub $0xc,%esp 2ddb: 6a 00 push $0x0 2ddd: e8 48 0b 00 00 call 392a <sbrk> 2de2: 89 c6 mov %eax,%esi amt = (BIG) - (uint)a; 2de4: b8 00 00 40 06 mov $0x6400000,%eax 2de9: 29 f0 sub %esi,%eax p = sbrk(amt); 2deb: 89 04 24 mov %eax,(%esp) 2dee: e8 37 0b 00 00 call 392a <sbrk> if (p != a) { 2df3: 83 c4 10 add $0x10,%esp 2df6: 39 c6 cmp %eax,%esi 2df8: 0f 85 f8 02 00 00 jne 30f6 <sbrktest+0x3c6> a = sbrk(0); 2dfe: 83 ec 0c sub $0xc,%esp *lastaddr = 99; 2e01: c6 05 ff ff 3f 06 63 movb $0x63,0x63fffff a = sbrk(0); 2e08: 6a 00 push $0x0 2e0a: e8 1b 0b 00 00 call 392a <sbrk> c = sbrk(-4096); 2e0f: c7 04 24 00 f0 ff ff movl $0xfffff000,(%esp) a = sbrk(0); 2e16: 89 c6 mov %eax,%esi c = sbrk(-4096); 2e18: e8 0d 0b 00 00 call 392a <sbrk> if(c == (char*)0xffffffff){ 2e1d: 83 c4 10 add $0x10,%esp 2e20: 83 f8 ff cmp $0xffffffff,%eax 2e23: 0f 84 b6 02 00 00 je 30df <sbrktest+0x3af> c = sbrk(0); 2e29: 83 ec 0c sub $0xc,%esp 2e2c: 6a 00 push $0x0 2e2e: e8 f7 0a 00 00 call 392a <sbrk> if(c != a - 4096){ 2e33: 8d 96 00 f0 ff ff lea -0x1000(%esi),%edx 2e39: 83 c4 10 add $0x10,%esp 2e3c: 39 d0 cmp %edx,%eax 2e3e: 0f 85 84 02 00 00 jne 30c8 <sbrktest+0x398> a = sbrk(0); 2e44: 83 ec 0c sub $0xc,%esp 2e47: 6a 00 push $0x0 2e49: e8 dc 0a 00 00 call 392a <sbrk> 2e4e: 89 c6 mov %eax,%esi c = sbrk(4096); 2e50: c7 04 24 00 10 00 00 movl $0x1000,(%esp) 2e57: e8 ce 0a 00 00 call 392a <sbrk> if(c != a || sbrk(0) != a + 4096){ 2e5c: 83 c4 10 add $0x10,%esp 2e5f: 39 c6 cmp %eax,%esi c = sbrk(4096); 2e61: 89 c7 mov %eax,%edi if(c != a || sbrk(0) != a + 4096){ 2e63: 0f 85 48 02 00 00 jne 30b1 <sbrktest+0x381> 2e69: 83 ec 0c sub $0xc,%esp 2e6c: 6a 00 push $0x0 2e6e: e8 b7 0a 00 00 call 392a <sbrk> 2e73: 8d 96 00 10 00 00 lea 0x1000(%esi),%edx 2e79: 83 c4 10 add $0x10,%esp 2e7c: 39 d0 cmp %edx,%eax 2e7e: 0f 85 2d 02 00 00 jne 30b1 <sbrktest+0x381> if(*lastaddr == 99){ 2e84: 80 3d ff ff 3f 06 63 cmpb $0x63,0x63fffff 2e8b: 0f 84 09 02 00 00 je 309a <sbrktest+0x36a> a = sbrk(0); 2e91: 83 ec 0c sub $0xc,%esp 2e94: 6a 00 push $0x0 2e96: e8 8f 0a 00 00 call 392a <sbrk> c = sbrk(-(sbrk(0) - oldbrk)); 2e9b: c7 04 24 00 00 00 00 movl $0x0,(%esp) a = sbrk(0); 2ea2: 89 c6 mov %eax,%esi c = sbrk(-(sbrk(0) - oldbrk)); 2ea4: e8 81 0a 00 00 call 392a <sbrk> 2ea9: 89 d9 mov %ebx,%ecx 2eab: 29 c1 sub %eax,%ecx 2ead: 89 0c 24 mov %ecx,(%esp) 2eb0: e8 75 0a 00 00 call 392a <sbrk> if(c != a){ 2eb5: 83 c4 10 add $0x10,%esp 2eb8: 39 c6 cmp %eax,%esi 2eba: 0f 85 c3 01 00 00 jne 3083 <sbrktest+0x353> for(a = (char*)(KERNBASE); a < (char*) (KERNBASE+2000000); a += 50000){ 2ec0: be 00 00 00 80 mov $0x80000000,%esi ppid = getpid(); 2ec5: e8 58 0a 00 00 call 3922 <getpid> 2eca: 89 c7 mov %eax,%edi pid = fork(); 2ecc: e8 c9 09 00 00 call 389a <fork> if(pid < 0){ 2ed1: 85 c0 test %eax,%eax 2ed3: 0f 88 93 01 00 00 js 306c <sbrktest+0x33c> if(pid == 0){ 2ed9: 0f 84 6b 01 00 00 je 304a <sbrktest+0x31a> for(a = (char*)(KERNBASE); a < (char*) (KERNBASE+2000000); a += 50000){ 2edf: 81 c6 50 c3 00 00 add $0xc350,%esi wait(); 2ee5: e8 c0 09 00 00 call 38aa <wait> for(a = (char*)(KERNBASE); a < (char*) (KERNBASE+2000000); a += 50000){ 2eea: 81 fe 80 84 1e 80 cmp $0x801e8480,%esi 2ef0: 75 d3 jne 2ec5 <sbrktest+0x195> if(pipe(fds) != 0){ 2ef2: 8d 45 b8 lea -0x48(%ebp),%eax 2ef5: 83 ec 0c sub $0xc,%esp 2ef8: 50 push %eax 2ef9: e8 b4 09 00 00 call 38b2 <pipe> 2efe: 83 c4 10 add $0x10,%esp 2f01: 85 c0 test %eax,%eax 2f03: 0f 85 2e 01 00 00 jne 3037 <sbrktest+0x307> 2f09: 8d 7d c0 lea -0x40(%ebp),%edi 2f0c: 89 fe mov %edi,%esi 2f0e: eb 23 jmp 2f33 <sbrktest+0x203> if(pids[i] != -1) 2f10: 83 f8 ff cmp $0xffffffff,%eax 2f13: 74 14 je 2f29 <sbrktest+0x1f9> read(fds[0], &scratch, 1); 2f15: 8d 45 b7 lea -0x49(%ebp),%eax 2f18: 83 ec 04 sub $0x4,%esp 2f1b: 6a 01 push $0x1 2f1d: 50 push %eax 2f1e: ff 75 b8 pushl -0x48(%ebp) 2f21: e8 94 09 00 00 call 38ba <read> 2f26: 83 c4 10 add $0x10,%esp for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){ 2f29: 8d 45 e8 lea -0x18(%ebp),%eax 2f2c: 83 c6 04 add $0x4,%esi 2f2f: 39 c6 cmp %eax,%esi 2f31: 74 4f je 2f82 <sbrktest+0x252> if((pids[i] = fork()) == 0){ 2f33: e8 62 09 00 00 call 389a <fork> 2f38: 85 c0 test %eax,%eax 2f3a: 89 06 mov %eax,(%esi) 2f3c: 75 d2 jne 2f10 <sbrktest+0x1e0> sbrk(BIG - (uint)sbrk(0)); 2f3e: 83 ec 0c sub $0xc,%esp 2f41: 6a 00 push $0x0 2f43: e8 e2 09 00 00 call 392a <sbrk> 2f48: ba 00 00 40 06 mov $0x6400000,%edx 2f4d: 29 c2 sub %eax,%edx 2f4f: 89 14 24 mov %edx,(%esp) 2f52: e8 d3 09 00 00 call 392a <sbrk> write(fds[1], "x", 1); 2f57: 83 c4 0c add $0xc,%esp 2f5a: 6a 01 push $0x1 2f5c: 68 a1 46 00 00 push $0x46a1 2f61: ff 75 bc pushl -0x44(%ebp) 2f64: e8 59 09 00 00 call 38c2 <write> 2f69: 83 c4 10 add $0x10,%esp 2f6c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(;;) sleep(1000); 2f70: 83 ec 0c sub $0xc,%esp 2f73: 68 e8 03 00 00 push $0x3e8 2f78: e8 b5 09 00 00 call 3932 <sleep> 2f7d: 83 c4 10 add $0x10,%esp 2f80: eb ee jmp 2f70 <sbrktest+0x240> c = sbrk(4096); 2f82: 83 ec 0c sub $0xc,%esp 2f85: 68 00 10 00 00 push $0x1000 2f8a: e8 9b 09 00 00 call 392a <sbrk> 2f8f: 83 c4 10 add $0x10,%esp 2f92: 89 45 a4 mov %eax,-0x5c(%ebp) if(pids[i] == -1) 2f95: 8b 07 mov (%edi),%eax 2f97: 83 f8 ff cmp $0xffffffff,%eax 2f9a: 74 11 je 2fad <sbrktest+0x27d> kill(pids[i]); 2f9c: 83 ec 0c sub $0xc,%esp 2f9f: 50 push %eax 2fa0: e8 2d 09 00 00 call 38d2 <kill> wait(); 2fa5: e8 00 09 00 00 call 38aa <wait> 2faa: 83 c4 10 add $0x10,%esp 2fad: 83 c7 04 add $0x4,%edi for(i = 0; i < sizeof(pids)/sizeof(pids[0]); i++){ 2fb0: 39 fe cmp %edi,%esi 2fb2: 75 e1 jne 2f95 <sbrktest+0x265> if(c == (char*)0xffffffff){ 2fb4: 83 7d a4 ff cmpl $0xffffffff,-0x5c(%ebp) 2fb8: 74 66 je 3020 <sbrktest+0x2f0> if(sbrk(0) > oldbrk) 2fba: 83 ec 0c sub $0xc,%esp 2fbd: 6a 00 push $0x0 2fbf: e8 66 09 00 00 call 392a <sbrk> 2fc4: 83 c4 10 add $0x10,%esp 2fc7: 39 d8 cmp %ebx,%eax 2fc9: 77 3c ja 3007 <sbrktest+0x2d7> printf(stdout, "sbrk test OK\n"); 2fcb: 83 ec 08 sub $0x8,%esp 2fce: 68 e0 4b 00 00 push $0x4be0 2fd3: ff 35 f8 5d 00 00 pushl 0x5df8 2fd9: e8 12 0a 00 00 call 39f0 <printf> } 2fde: 83 c4 10 add $0x10,%esp 2fe1: 8d 65 f4 lea -0xc(%ebp),%esp 2fe4: 5b pop %ebx 2fe5: 5e pop %esi 2fe6: 5f pop %edi 2fe7: 5d pop %ebp 2fe8: c3 ret printf(stdout, "sbrk test failed %d %x %x\n", i, a, b); 2fe9: 83 ec 0c sub $0xc,%esp 2fec: 50 push %eax 2fed: 56 push %esi 2fee: 57 push %edi 2fef: 68 43 4b 00 00 push $0x4b43 2ff4: ff 35 f8 5d 00 00 pushl 0x5df8 2ffa: e8 f1 09 00 00 call 39f0 <printf> exit(); 2fff: 83 c4 20 add $0x20,%esp 3002: e8 9b 08 00 00 call 38a2 <exit> sbrk(-(sbrk(0) - oldbrk)); 3007: 83 ec 0c sub $0xc,%esp 300a: 6a 00 push $0x0 300c: e8 19 09 00 00 call 392a <sbrk> 3011: 29 c3 sub %eax,%ebx 3013: 89 1c 24 mov %ebx,(%esp) 3016: e8 0f 09 00 00 call 392a <sbrk> 301b: 83 c4 10 add $0x10,%esp 301e: eb ab jmp 2fcb <sbrktest+0x29b> printf(stdout, "failed sbrk leaked memory\n"); 3020: 50 push %eax 3021: 50 push %eax 3022: 68 c5 4b 00 00 push $0x4bc5 3027: ff 35 f8 5d 00 00 pushl 0x5df8 302d: e8 be 09 00 00 call 39f0 <printf> exit(); 3032: e8 6b 08 00 00 call 38a2 <exit> printf(1, "pipe() failed\n"); 3037: 52 push %edx 3038: 52 push %edx 3039: 68 81 40 00 00 push $0x4081 303e: 6a 01 push $0x1 3040: e8 ab 09 00 00 call 39f0 <printf> exit(); 3045: e8 58 08 00 00 call 38a2 <exit> printf(stdout, "oops could read %x = %x\n", a, *a); 304a: 0f be 06 movsbl (%esi),%eax 304d: 50 push %eax 304e: 56 push %esi 304f: 68 ac 4b 00 00 push $0x4bac 3054: ff 35 f8 5d 00 00 pushl 0x5df8 305a: e8 91 09 00 00 call 39f0 <printf> kill(ppid); 305f: 89 3c 24 mov %edi,(%esp) 3062: e8 6b 08 00 00 call 38d2 <kill> exit(); 3067: e8 36 08 00 00 call 38a2 <exit> printf(stdout, "fork failed\n"); 306c: 51 push %ecx 306d: 51 push %ecx 306e: 68 89 4c 00 00 push $0x4c89 3073: ff 35 f8 5d 00 00 pushl 0x5df8 3079: e8 72 09 00 00 call 39f0 <printf> exit(); 307e: e8 1f 08 00 00 call 38a2 <exit> printf(stdout, "sbrk downsize failed, a %x c %x\n", a, c); 3083: 50 push %eax 3084: 56 push %esi 3085: 68 8c 53 00 00 push $0x538c 308a: ff 35 f8 5d 00 00 pushl 0x5df8 3090: e8 5b 09 00 00 call 39f0 <printf> exit(); 3095: e8 08 08 00 00 call 38a2 <exit> printf(stdout, "sbrk de-allocation didn't really deallocate\n"); 309a: 53 push %ebx 309b: 53 push %ebx 309c: 68 5c 53 00 00 push $0x535c 30a1: ff 35 f8 5d 00 00 pushl 0x5df8 30a7: e8 44 09 00 00 call 39f0 <printf> exit(); 30ac: e8 f1 07 00 00 call 38a2 <exit> printf(stdout, "sbrk re-allocation failed, a %x c %x\n", a, c); 30b1: 57 push %edi 30b2: 56 push %esi 30b3: 68 34 53 00 00 push $0x5334 30b8: ff 35 f8 5d 00 00 pushl 0x5df8 30be: e8 2d 09 00 00 call 39f0 <printf> exit(); 30c3: e8 da 07 00 00 call 38a2 <exit> printf(stdout, "sbrk deallocation produced wrong address, a %x c %x\n", a, c); 30c8: 50 push %eax 30c9: 56 push %esi 30ca: 68 fc 52 00 00 push $0x52fc 30cf: ff 35 f8 5d 00 00 pushl 0x5df8 30d5: e8 16 09 00 00 call 39f0 <printf> exit(); 30da: e8 c3 07 00 00 call 38a2 <exit> printf(stdout, "sbrk could not deallocate\n"); 30df: 56 push %esi 30e0: 56 push %esi 30e1: 68 91 4b 00 00 push $0x4b91 30e6: ff 35 f8 5d 00 00 pushl 0x5df8 30ec: e8 ff 08 00 00 call 39f0 <printf> exit(); 30f1: e8 ac 07 00 00 call 38a2 <exit> printf(stdout, "sbrk test failed to grow big address space; enough phys mem?\n"); 30f6: 57 push %edi 30f7: 57 push %edi 30f8: 68 bc 52 00 00 push $0x52bc 30fd: ff 35 f8 5d 00 00 pushl 0x5df8 3103: e8 e8 08 00 00 call 39f0 <printf> exit(); 3108: e8 95 07 00 00 call 38a2 <exit> exit(); 310d: e8 90 07 00 00 call 38a2 <exit> printf(stdout, "sbrk test failed post-fork\n"); 3112: 50 push %eax 3113: 50 push %eax 3114: 68 75 4b 00 00 push $0x4b75 3119: ff 35 f8 5d 00 00 pushl 0x5df8 311f: e8 cc 08 00 00 call 39f0 <printf> exit(); 3124: e8 79 07 00 00 call 38a2 <exit> printf(stdout, "sbrk test fork failed\n"); 3129: 50 push %eax 312a: 50 push %eax 312b: 68 5e 4b 00 00 push $0x4b5e 3130: ff 35 f8 5d 00 00 pushl 0x5df8 3136: e8 b5 08 00 00 call 39f0 <printf> exit(); 313b: e8 62 07 00 00 call 38a2 <exit> 00003140 <validateint>: { 3140: 55 push %ebp 3141: 89 e5 mov %esp,%ebp } 3143: 5d pop %ebp 3144: c3 ret 3145: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 3149: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00003150 <validatetest>: { 3150: 55 push %ebp 3151: 89 e5 mov %esp,%ebp 3153: 56 push %esi 3154: 53 push %ebx for(p = 0; p <= (uint)hi; p += 4096){ 3155: 31 db xor %ebx,%ebx printf(stdout, "validate test\n"); 3157: 83 ec 08 sub $0x8,%esp 315a: 68 ee 4b 00 00 push $0x4bee 315f: ff 35 f8 5d 00 00 pushl 0x5df8 3165: e8 86 08 00 00 call 39f0 <printf> 316a: 83 c4 10 add $0x10,%esp 316d: 8d 76 00 lea 0x0(%esi),%esi if((pid = fork()) == 0){ 3170: e8 25 07 00 00 call 389a <fork> 3175: 85 c0 test %eax,%eax 3177: 89 c6 mov %eax,%esi 3179: 74 63 je 31de <validatetest+0x8e> sleep(0); 317b: 83 ec 0c sub $0xc,%esp 317e: 6a 00 push $0x0 3180: e8 ad 07 00 00 call 3932 <sleep> sleep(0); 3185: c7 04 24 00 00 00 00 movl $0x0,(%esp) 318c: e8 a1 07 00 00 call 3932 <sleep> kill(pid); 3191: 89 34 24 mov %esi,(%esp) 3194: e8 39 07 00 00 call 38d2 <kill> wait(); 3199: e8 0c 07 00 00 call 38aa <wait> if(link("nosuchfile", (char*)p) != -1){ 319e: 58 pop %eax 319f: 5a pop %edx 31a0: 53 push %ebx 31a1: 68 fd 4b 00 00 push $0x4bfd 31a6: e8 57 07 00 00 call 3902 <link> 31ab: 83 c4 10 add $0x10,%esp 31ae: 83 f8 ff cmp $0xffffffff,%eax 31b1: 75 30 jne 31e3 <validatetest+0x93> for(p = 0; p <= (uint)hi; p += 4096){ 31b3: 81 c3 00 10 00 00 add $0x1000,%ebx 31b9: 81 fb 00 40 11 00 cmp $0x114000,%ebx 31bf: 75 af jne 3170 <validatetest+0x20> printf(stdout, "validate ok\n"); 31c1: 83 ec 08 sub $0x8,%esp 31c4: 68 21 4c 00 00 push $0x4c21 31c9: ff 35 f8 5d 00 00 pushl 0x5df8 31cf: e8 1c 08 00 00 call 39f0 <printf> } 31d4: 83 c4 10 add $0x10,%esp 31d7: 8d 65 f8 lea -0x8(%ebp),%esp 31da: 5b pop %ebx 31db: 5e pop %esi 31dc: 5d pop %ebp 31dd: c3 ret exit(); 31de: e8 bf 06 00 00 call 38a2 <exit> printf(stdout, "link should not succeed\n"); 31e3: 83 ec 08 sub $0x8,%esp 31e6: 68 08 4c 00 00 push $0x4c08 31eb: ff 35 f8 5d 00 00 pushl 0x5df8 31f1: e8 fa 07 00 00 call 39f0 <printf> exit(); 31f6: e8 a7 06 00 00 call 38a2 <exit> 31fb: 90 nop 31fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00003200 <bsstest>: { 3200: 55 push %ebp 3201: 89 e5 mov %esp,%ebp 3203: 83 ec 10 sub $0x10,%esp printf(stdout, "bss test\n"); 3206: 68 2e 4c 00 00 push $0x4c2e 320b: ff 35 f8 5d 00 00 pushl 0x5df8 3211: e8 da 07 00 00 call 39f0 <printf> if(uninit[i] != '\0'){ 3216: 83 c4 10 add $0x10,%esp 3219: 80 3d c0 5e 00 00 00 cmpb $0x0,0x5ec0 3220: 75 39 jne 325b <bsstest+0x5b> for(i = 0; i < sizeof(uninit); i++){ 3222: b8 01 00 00 00 mov $0x1,%eax 3227: 89 f6 mov %esi,%esi 3229: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi if(uninit[i] != '\0'){ 3230: 80 b8 c0 5e 00 00 00 cmpb $0x0,0x5ec0(%eax) 3237: 75 22 jne 325b <bsstest+0x5b> for(i = 0; i < sizeof(uninit); i++){ 3239: 83 c0 01 add $0x1,%eax 323c: 3d 10 27 00 00 cmp $0x2710,%eax 3241: 75 ed jne 3230 <bsstest+0x30> printf(stdout, "bss test ok\n"); 3243: 83 ec 08 sub $0x8,%esp 3246: 68 49 4c 00 00 push $0x4c49 324b: ff 35 f8 5d 00 00 pushl 0x5df8 3251: e8 9a 07 00 00 call 39f0 <printf> } 3256: 83 c4 10 add $0x10,%esp 3259: c9 leave 325a: c3 ret printf(stdout, "bss test failed\n"); 325b: 83 ec 08 sub $0x8,%esp 325e: 68 38 4c 00 00 push $0x4c38 3263: ff 35 f8 5d 00 00 pushl 0x5df8 3269: e8 82 07 00 00 call 39f0 <printf> exit(); 326e: e8 2f 06 00 00 call 38a2 <exit> 3273: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 3279: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00003280 <bigargtest>: { 3280: 55 push %ebp 3281: 89 e5 mov %esp,%ebp 3283: 83 ec 14 sub $0x14,%esp unlink("bigarg-ok"); 3286: 68 56 4c 00 00 push $0x4c56 328b: e8 62 06 00 00 call 38f2 <unlink> pid = fork(); 3290: e8 05 06 00 00 call 389a <fork> if(pid == 0){ 3295: 83 c4 10 add $0x10,%esp 3298: 85 c0 test %eax,%eax 329a: 74 3f je 32db <bigargtest+0x5b> } else if(pid < 0){ 329c: 0f 88 c2 00 00 00 js 3364 <bigargtest+0xe4> wait(); 32a2: e8 03 06 00 00 call 38aa <wait> fd = open("bigarg-ok", 0); 32a7: 83 ec 08 sub $0x8,%esp 32aa: 6a 00 push $0x0 32ac: 68 56 4c 00 00 push $0x4c56 32b1: e8 2c 06 00 00 call 38e2 <open> if(fd < 0){ 32b6: 83 c4 10 add $0x10,%esp 32b9: 85 c0 test %eax,%eax 32bb: 0f 88 8c 00 00 00 js 334d <bigargtest+0xcd> close(fd); 32c1: 83 ec 0c sub $0xc,%esp 32c4: 50 push %eax 32c5: e8 00 06 00 00 call 38ca <close> unlink("bigarg-ok"); 32ca: c7 04 24 56 4c 00 00 movl $0x4c56,(%esp) 32d1: e8 1c 06 00 00 call 38f2 <unlink> } 32d6: 83 c4 10 add $0x10,%esp 32d9: c9 leave 32da: c3 ret 32db: b8 20 5e 00 00 mov $0x5e20,%eax args[i] = "bigargs test: failed\n "; 32e0: c7 00 b0 53 00 00 movl $0x53b0,(%eax) 32e6: 83 c0 04 add $0x4,%eax for(i = 0; i < MAXARG-1; i++) 32e9: 3d 9c 5e 00 00 cmp $0x5e9c,%eax 32ee: 75 f0 jne 32e0 <bigargtest+0x60> printf(stdout, "bigarg test\n"); 32f0: 51 push %ecx 32f1: 51 push %ecx 32f2: 68 60 4c 00 00 push $0x4c60 32f7: ff 35 f8 5d 00 00 pushl 0x5df8 args[MAXARG-1] = 0; 32fd: c7 05 9c 5e 00 00 00 movl $0x0,0x5e9c 3304: 00 00 00 printf(stdout, "bigarg test\n"); 3307: e8 e4 06 00 00 call 39f0 <printf> exec("echo", args); 330c: 58 pop %eax 330d: 5a pop %edx 330e: 68 20 5e 00 00 push $0x5e20 3313: 68 2d 3e 00 00 push $0x3e2d 3318: e8 bd 05 00 00 call 38da <exec> printf(stdout, "bigarg test ok\n"); 331d: 59 pop %ecx 331e: 58 pop %eax 331f: 68 6d 4c 00 00 push $0x4c6d 3324: ff 35 f8 5d 00 00 pushl 0x5df8 332a: e8 c1 06 00 00 call 39f0 <printf> fd = open("bigarg-ok", O_CREATE); 332f: 58 pop %eax 3330: 5a pop %edx 3331: 68 00 02 00 00 push $0x200 3336: 68 56 4c 00 00 push $0x4c56 333b: e8 a2 05 00 00 call 38e2 <open> close(fd); 3340: 89 04 24 mov %eax,(%esp) 3343: e8 82 05 00 00 call 38ca <close> exit(); 3348: e8 55 05 00 00 call 38a2 <exit> printf(stdout, "bigarg test failed!\n"); 334d: 50 push %eax 334e: 50 push %eax 334f: 68 96 4c 00 00 push $0x4c96 3354: ff 35 f8 5d 00 00 pushl 0x5df8 335a: e8 91 06 00 00 call 39f0 <printf> exit(); 335f: e8 3e 05 00 00 call 38a2 <exit> printf(stdout, "bigargtest: fork failed\n"); 3364: 52 push %edx 3365: 52 push %edx 3366: 68 7d 4c 00 00 push $0x4c7d 336b: ff 35 f8 5d 00 00 pushl 0x5df8 3371: e8 7a 06 00 00 call 39f0 <printf> exit(); 3376: e8 27 05 00 00 call 38a2 <exit> 337b: 90 nop 337c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00003380 <fsfull>: { 3380: 55 push %ebp 3381: 89 e5 mov %esp,%ebp 3383: 57 push %edi 3384: 56 push %esi 3385: 53 push %ebx for(nfiles = 0; ; nfiles++){ 3386: 31 db xor %ebx,%ebx { 3388: 83 ec 54 sub $0x54,%esp printf(1, "fsfull test\n"); 338b: 68 ab 4c 00 00 push $0x4cab 3390: 6a 01 push $0x1 3392: e8 59 06 00 00 call 39f0 <printf> 3397: 83 c4 10 add $0x10,%esp 339a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi name[1] = '0' + nfiles / 1000; 33a0: b8 d3 4d 62 10 mov $0x10624dd3,%eax name[3] = '0' + (nfiles % 100) / 10; 33a5: b9 cd cc cc cc mov $0xcccccccd,%ecx printf(1, "writing %s\n", name); 33aa: 83 ec 04 sub $0x4,%esp name[1] = '0' + nfiles / 1000; 33ad: f7 e3 mul %ebx name[0] = 'f'; 33af: c6 45 a8 66 movb $0x66,-0x58(%ebp) name[5] = '\0'; 33b3: c6 45 ad 00 movb $0x0,-0x53(%ebp) name[1] = '0' + nfiles / 1000; 33b7: c1 ea 06 shr $0x6,%edx 33ba: 8d 42 30 lea 0x30(%edx),%eax name[2] = '0' + (nfiles % 1000) / 100; 33bd: 69 d2 e8 03 00 00 imul $0x3e8,%edx,%edx name[1] = '0' + nfiles / 1000; 33c3: 88 45 a9 mov %al,-0x57(%ebp) name[2] = '0' + (nfiles % 1000) / 100; 33c6: 89 d8 mov %ebx,%eax 33c8: 29 d0 sub %edx,%eax 33ca: 89 c2 mov %eax,%edx 33cc: b8 1f 85 eb 51 mov $0x51eb851f,%eax 33d1: f7 e2 mul %edx name[3] = '0' + (nfiles % 100) / 10; 33d3: b8 1f 85 eb 51 mov $0x51eb851f,%eax name[2] = '0' + (nfiles % 1000) / 100; 33d8: c1 ea 05 shr $0x5,%edx 33db: 83 c2 30 add $0x30,%edx 33de: 88 55 aa mov %dl,-0x56(%ebp) name[3] = '0' + (nfiles % 100) / 10; 33e1: f7 e3 mul %ebx 33e3: 89 d8 mov %ebx,%eax 33e5: c1 ea 05 shr $0x5,%edx 33e8: 6b d2 64 imul $0x64,%edx,%edx 33eb: 29 d0 sub %edx,%eax 33ed: f7 e1 mul %ecx name[4] = '0' + (nfiles % 10); 33ef: 89 d8 mov %ebx,%eax name[3] = '0' + (nfiles % 100) / 10; 33f1: c1 ea 03 shr $0x3,%edx 33f4: 83 c2 30 add $0x30,%edx 33f7: 88 55 ab mov %dl,-0x55(%ebp) name[4] = '0' + (nfiles % 10); 33fa: f7 e1 mul %ecx 33fc: 89 d9 mov %ebx,%ecx 33fe: c1 ea 03 shr $0x3,%edx 3401: 8d 04 92 lea (%edx,%edx,4),%eax 3404: 01 c0 add %eax,%eax 3406: 29 c1 sub %eax,%ecx 3408: 89 c8 mov %ecx,%eax 340a: 83 c0 30 add $0x30,%eax 340d: 88 45 ac mov %al,-0x54(%ebp) printf(1, "writing %s\n", name); 3410: 8d 45 a8 lea -0x58(%ebp),%eax 3413: 50 push %eax 3414: 68 b8 4c 00 00 push $0x4cb8 3419: 6a 01 push $0x1 341b: e8 d0 05 00 00 call 39f0 <printf> int fd = open(name, O_CREATE|O_RDWR); 3420: 58 pop %eax 3421: 8d 45 a8 lea -0x58(%ebp),%eax 3424: 5a pop %edx 3425: 68 02 02 00 00 push $0x202 342a: 50 push %eax 342b: e8 b2 04 00 00 call 38e2 <open> if(fd < 0){ 3430: 83 c4 10 add $0x10,%esp 3433: 85 c0 test %eax,%eax int fd = open(name, O_CREATE|O_RDWR); 3435: 89 c7 mov %eax,%edi if(fd < 0){ 3437: 78 57 js 3490 <fsfull+0x110> int total = 0; 3439: 31 f6 xor %esi,%esi 343b: eb 05 jmp 3442 <fsfull+0xc2> 343d: 8d 76 00 lea 0x0(%esi),%esi total += cc; 3440: 01 c6 add %eax,%esi int cc = write(fd, buf, 512); 3442: 83 ec 04 sub $0x4,%esp 3445: 68 00 02 00 00 push $0x200 344a: 68 e0 85 00 00 push $0x85e0 344f: 57 push %edi 3450: e8 6d 04 00 00 call 38c2 <write> if(cc < 512) 3455: 83 c4 10 add $0x10,%esp 3458: 3d ff 01 00 00 cmp $0x1ff,%eax 345d: 7f e1 jg 3440 <fsfull+0xc0> printf(1, "wrote %d bytes\n", total); 345f: 83 ec 04 sub $0x4,%esp 3462: 56 push %esi 3463: 68 d4 4c 00 00 push $0x4cd4 3468: 6a 01 push $0x1 346a: e8 81 05 00 00 call 39f0 <printf> close(fd); 346f: 89 3c 24 mov %edi,(%esp) 3472: e8 53 04 00 00 call 38ca <close> if(total == 0) 3477: 83 c4 10 add $0x10,%esp 347a: 85 f6 test %esi,%esi 347c: 74 28 je 34a6 <fsfull+0x126> for(nfiles = 0; ; nfiles++){ 347e: 83 c3 01 add $0x1,%ebx 3481: e9 1a ff ff ff jmp 33a0 <fsfull+0x20> 3486: 8d 76 00 lea 0x0(%esi),%esi 3489: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi printf(1, "open %s failed\n", name); 3490: 8d 45 a8 lea -0x58(%ebp),%eax 3493: 83 ec 04 sub $0x4,%esp 3496: 50 push %eax 3497: 68 c4 4c 00 00 push $0x4cc4 349c: 6a 01 push $0x1 349e: e8 4d 05 00 00 call 39f0 <printf> break; 34a3: 83 c4 10 add $0x10,%esp name[1] = '0' + nfiles / 1000; 34a6: bf d3 4d 62 10 mov $0x10624dd3,%edi name[2] = '0' + (nfiles % 1000) / 100; 34ab: be 1f 85 eb 51 mov $0x51eb851f,%esi name[1] = '0' + nfiles / 1000; 34b0: 89 d8 mov %ebx,%eax name[3] = '0' + (nfiles % 100) / 10; 34b2: b9 cd cc cc cc mov $0xcccccccd,%ecx unlink(name); 34b7: 83 ec 0c sub $0xc,%esp name[1] = '0' + nfiles / 1000; 34ba: f7 e7 mul %edi name[0] = 'f'; 34bc: c6 45 a8 66 movb $0x66,-0x58(%ebp) name[5] = '\0'; 34c0: c6 45 ad 00 movb $0x0,-0x53(%ebp) name[1] = '0' + nfiles / 1000; 34c4: c1 ea 06 shr $0x6,%edx 34c7: 8d 42 30 lea 0x30(%edx),%eax name[2] = '0' + (nfiles % 1000) / 100; 34ca: 69 d2 e8 03 00 00 imul $0x3e8,%edx,%edx name[1] = '0' + nfiles / 1000; 34d0: 88 45 a9 mov %al,-0x57(%ebp) name[2] = '0' + (nfiles % 1000) / 100; 34d3: 89 d8 mov %ebx,%eax 34d5: 29 d0 sub %edx,%eax 34d7: f7 e6 mul %esi name[3] = '0' + (nfiles % 100) / 10; 34d9: 89 d8 mov %ebx,%eax name[2] = '0' + (nfiles % 1000) / 100; 34db: c1 ea 05 shr $0x5,%edx 34de: 83 c2 30 add $0x30,%edx 34e1: 88 55 aa mov %dl,-0x56(%ebp) name[3] = '0' + (nfiles % 100) / 10; 34e4: f7 e6 mul %esi 34e6: 89 d8 mov %ebx,%eax 34e8: c1 ea 05 shr $0x5,%edx 34eb: 6b d2 64 imul $0x64,%edx,%edx 34ee: 29 d0 sub %edx,%eax 34f0: f7 e1 mul %ecx name[4] = '0' + (nfiles % 10); 34f2: 89 d8 mov %ebx,%eax name[3] = '0' + (nfiles % 100) / 10; 34f4: c1 ea 03 shr $0x3,%edx 34f7: 83 c2 30 add $0x30,%edx 34fa: 88 55 ab mov %dl,-0x55(%ebp) name[4] = '0' + (nfiles % 10); 34fd: f7 e1 mul %ecx 34ff: 89 d9 mov %ebx,%ecx nfiles--; 3501: 83 eb 01 sub $0x1,%ebx name[4] = '0' + (nfiles % 10); 3504: c1 ea 03 shr $0x3,%edx 3507: 8d 04 92 lea (%edx,%edx,4),%eax 350a: 01 c0 add %eax,%eax 350c: 29 c1 sub %eax,%ecx 350e: 89 c8 mov %ecx,%eax 3510: 83 c0 30 add $0x30,%eax 3513: 88 45 ac mov %al,-0x54(%ebp) unlink(name); 3516: 8d 45 a8 lea -0x58(%ebp),%eax 3519: 50 push %eax 351a: e8 d3 03 00 00 call 38f2 <unlink> while(nfiles >= 0){ 351f: 83 c4 10 add $0x10,%esp 3522: 83 fb ff cmp $0xffffffff,%ebx 3525: 75 89 jne 34b0 <fsfull+0x130> printf(1, "fsfull test finished\n"); 3527: 83 ec 08 sub $0x8,%esp 352a: 68 e4 4c 00 00 push $0x4ce4 352f: 6a 01 push $0x1 3531: e8 ba 04 00 00 call 39f0 <printf> } 3536: 83 c4 10 add $0x10,%esp 3539: 8d 65 f4 lea -0xc(%ebp),%esp 353c: 5b pop %ebx 353d: 5e pop %esi 353e: 5f pop %edi 353f: 5d pop %ebp 3540: c3 ret 3541: eb 0d jmp 3550 <uio> 3543: 90 nop 3544: 90 nop 3545: 90 nop 3546: 90 nop 3547: 90 nop 3548: 90 nop 3549: 90 nop 354a: 90 nop 354b: 90 nop 354c: 90 nop 354d: 90 nop 354e: 90 nop 354f: 90 nop 00003550 <uio>: { 3550: 55 push %ebp 3551: 89 e5 mov %esp,%ebp 3553: 83 ec 10 sub $0x10,%esp printf(1, "uio test\n"); 3556: 68 fa 4c 00 00 push $0x4cfa 355b: 6a 01 push $0x1 355d: e8 8e 04 00 00 call 39f0 <printf> pid = fork(); 3562: e8 33 03 00 00 call 389a <fork> if(pid == 0){ 3567: 83 c4 10 add $0x10,%esp 356a: 85 c0 test %eax,%eax 356c: 74 1b je 3589 <uio+0x39> } else if(pid < 0){ 356e: 78 3d js 35ad <uio+0x5d> wait(); 3570: e8 35 03 00 00 call 38aa <wait> printf(1, "uio test done\n"); 3575: 83 ec 08 sub $0x8,%esp 3578: 68 04 4d 00 00 push $0x4d04 357d: 6a 01 push $0x1 357f: e8 6c 04 00 00 call 39f0 <printf> } 3584: 83 c4 10 add $0x10,%esp 3587: c9 leave 3588: c3 ret asm volatile("outb %0,%1"::"a"(val), "d" (port)); 3589: b8 09 00 00 00 mov $0x9,%eax 358e: ba 70 00 00 00 mov $0x70,%edx 3593: ee out %al,(%dx) asm volatile("inb %1,%0" : "=a" (val) : "d" (port)); 3594: ba 71 00 00 00 mov $0x71,%edx 3599: ec in (%dx),%al printf(1, "uio: uio succeeded; test FAILED\n"); 359a: 52 push %edx 359b: 52 push %edx 359c: 68 90 54 00 00 push $0x5490 35a1: 6a 01 push $0x1 35a3: e8 48 04 00 00 call 39f0 <printf> exit(); 35a8: e8 f5 02 00 00 call 38a2 <exit> printf (1, "fork failed\n"); 35ad: 50 push %eax 35ae: 50 push %eax 35af: 68 89 4c 00 00 push $0x4c89 35b4: 6a 01 push $0x1 35b6: e8 35 04 00 00 call 39f0 <printf> exit(); 35bb: e8 e2 02 00 00 call 38a2 <exit> 000035c0 <argptest>: { 35c0: 55 push %ebp 35c1: 89 e5 mov %esp,%ebp 35c3: 53 push %ebx 35c4: 83 ec 0c sub $0xc,%esp fd = open("init", O_RDONLY); 35c7: 6a 00 push $0x0 35c9: 68 13 4d 00 00 push $0x4d13 35ce: e8 0f 03 00 00 call 38e2 <open> if (fd < 0) { 35d3: 83 c4 10 add $0x10,%esp 35d6: 85 c0 test %eax,%eax 35d8: 78 39 js 3613 <argptest+0x53> read(fd, sbrk(0) - 1, -1); 35da: 83 ec 0c sub $0xc,%esp 35dd: 89 c3 mov %eax,%ebx 35df: 6a 00 push $0x0 35e1: e8 44 03 00 00 call 392a <sbrk> 35e6: 83 c4 0c add $0xc,%esp 35e9: 83 e8 01 sub $0x1,%eax 35ec: 6a ff push $0xffffffff 35ee: 50 push %eax 35ef: 53 push %ebx 35f0: e8 c5 02 00 00 call 38ba <read> close(fd); 35f5: 89 1c 24 mov %ebx,(%esp) 35f8: e8 cd 02 00 00 call 38ca <close> printf(1, "arg test passed\n"); 35fd: 58 pop %eax 35fe: 5a pop %edx 35ff: 68 25 4d 00 00 push $0x4d25 3604: 6a 01 push $0x1 3606: e8 e5 03 00 00 call 39f0 <printf> } 360b: 83 c4 10 add $0x10,%esp 360e: 8b 5d fc mov -0x4(%ebp),%ebx 3611: c9 leave 3612: c3 ret printf(2, "open failed\n"); 3613: 51 push %ecx 3614: 51 push %ecx 3615: 68 18 4d 00 00 push $0x4d18 361a: 6a 02 push $0x2 361c: e8 cf 03 00 00 call 39f0 <printf> exit(); 3621: e8 7c 02 00 00 call 38a2 <exit> 3626: 8d 76 00 lea 0x0(%esi),%esi 3629: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00003630 <rand>: randstate = randstate * 1664525 + 1013904223; 3630: 69 05 f4 5d 00 00 0d imul $0x19660d,0x5df4,%eax 3637: 66 19 00 { 363a: 55 push %ebp 363b: 89 e5 mov %esp,%ebp } 363d: 5d pop %ebp randstate = randstate * 1664525 + 1013904223; 363e: 05 5f f3 6e 3c add $0x3c6ef35f,%eax 3643: a3 f4 5d 00 00 mov %eax,0x5df4 } 3648: c3 ret 3649: 66 90 xchg %ax,%ax 364b: 66 90 xchg %ax,%ax 364d: 66 90 xchg %ax,%ax 364f: 90 nop 00003650 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { 3650: 55 push %ebp 3651: 89 e5 mov %esp,%ebp 3653: 53 push %ebx 3654: 8b 45 08 mov 0x8(%ebp),%eax 3657: 8b 4d 0c mov 0xc(%ebp),%ecx char *os; os = s; while((*s++ = *t++) != 0) 365a: 89 c2 mov %eax,%edx 365c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 3660: 83 c1 01 add $0x1,%ecx 3663: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 3667: 83 c2 01 add $0x1,%edx 366a: 84 db test %bl,%bl 366c: 88 5a ff mov %bl,-0x1(%edx) 366f: 75 ef jne 3660 <strcpy+0x10> ; return os; } 3671: 5b pop %ebx 3672: 5d pop %ebp 3673: c3 ret 3674: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 367a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00003680 <strcmp>: int strcmp(const char *p, const char *q) { 3680: 55 push %ebp 3681: 89 e5 mov %esp,%ebp 3683: 53 push %ebx 3684: 8b 55 08 mov 0x8(%ebp),%edx 3687: 8b 4d 0c mov 0xc(%ebp),%ecx while(*p && *p == *q) 368a: 0f b6 02 movzbl (%edx),%eax 368d: 0f b6 19 movzbl (%ecx),%ebx 3690: 84 c0 test %al,%al 3692: 75 1c jne 36b0 <strcmp+0x30> 3694: eb 2a jmp 36c0 <strcmp+0x40> 3696: 8d 76 00 lea 0x0(%esi),%esi 3699: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi p++, q++; 36a0: 83 c2 01 add $0x1,%edx while(*p && *p == *q) 36a3: 0f b6 02 movzbl (%edx),%eax p++, q++; 36a6: 83 c1 01 add $0x1,%ecx 36a9: 0f b6 19 movzbl (%ecx),%ebx while(*p && *p == *q) 36ac: 84 c0 test %al,%al 36ae: 74 10 je 36c0 <strcmp+0x40> 36b0: 38 d8 cmp %bl,%al 36b2: 74 ec je 36a0 <strcmp+0x20> return (uchar)*p - (uchar)*q; 36b4: 29 d8 sub %ebx,%eax } 36b6: 5b pop %ebx 36b7: 5d pop %ebp 36b8: c3 ret 36b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 36c0: 31 c0 xor %eax,%eax return (uchar)*p - (uchar)*q; 36c2: 29 d8 sub %ebx,%eax } 36c4: 5b pop %ebx 36c5: 5d pop %ebp 36c6: c3 ret 36c7: 89 f6 mov %esi,%esi 36c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000036d0 <strlen>: uint strlen(const char *s) { 36d0: 55 push %ebp 36d1: 89 e5 mov %esp,%ebp 36d3: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) 36d6: 80 39 00 cmpb $0x0,(%ecx) 36d9: 74 15 je 36f0 <strlen+0x20> 36db: 31 d2 xor %edx,%edx 36dd: 8d 76 00 lea 0x0(%esi),%esi 36e0: 83 c2 01 add $0x1,%edx 36e3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) 36e7: 89 d0 mov %edx,%eax 36e9: 75 f5 jne 36e0 <strlen+0x10> ; return n; } 36eb: 5d pop %ebp 36ec: c3 ret 36ed: 8d 76 00 lea 0x0(%esi),%esi for(n = 0; s[n]; n++) 36f0: 31 c0 xor %eax,%eax } 36f2: 5d pop %ebp 36f3: c3 ret 36f4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 36fa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00003700 <memset>: void* memset(void *dst, int c, uint n) { 3700: 55 push %ebp 3701: 89 e5 mov %esp,%ebp 3703: 57 push %edi 3704: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 3707: 8b 4d 10 mov 0x10(%ebp),%ecx 370a: 8b 45 0c mov 0xc(%ebp),%eax 370d: 89 d7 mov %edx,%edi 370f: fc cld 3710: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 3712: 89 d0 mov %edx,%eax 3714: 5f pop %edi 3715: 5d pop %ebp 3716: c3 ret 3717: 89 f6 mov %esi,%esi 3719: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00003720 <strchr>: char* strchr(const char *s, char c) { 3720: 55 push %ebp 3721: 89 e5 mov %esp,%ebp 3723: 53 push %ebx 3724: 8b 45 08 mov 0x8(%ebp),%eax 3727: 8b 5d 0c mov 0xc(%ebp),%ebx for(; *s; s++) 372a: 0f b6 10 movzbl (%eax),%edx 372d: 84 d2 test %dl,%dl 372f: 74 1d je 374e <strchr+0x2e> if(*s == c) 3731: 38 d3 cmp %dl,%bl 3733: 89 d9 mov %ebx,%ecx 3735: 75 0d jne 3744 <strchr+0x24> 3737: eb 17 jmp 3750 <strchr+0x30> 3739: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 3740: 38 ca cmp %cl,%dl 3742: 74 0c je 3750 <strchr+0x30> for(; *s; s++) 3744: 83 c0 01 add $0x1,%eax 3747: 0f b6 10 movzbl (%eax),%edx 374a: 84 d2 test %dl,%dl 374c: 75 f2 jne 3740 <strchr+0x20> return (char*)s; return 0; 374e: 31 c0 xor %eax,%eax } 3750: 5b pop %ebx 3751: 5d pop %ebp 3752: c3 ret 3753: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 3759: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00003760 <gets>: char* gets(char *buf, int max) { 3760: 55 push %ebp 3761: 89 e5 mov %esp,%ebp 3763: 57 push %edi 3764: 56 push %esi 3765: 53 push %ebx int i, cc; char c; for(i=0; i+1 < max; ){ 3766: 31 f6 xor %esi,%esi 3768: 89 f3 mov %esi,%ebx { 376a: 83 ec 1c sub $0x1c,%esp 376d: 8b 7d 08 mov 0x8(%ebp),%edi for(i=0; i+1 < max; ){ 3770: eb 2f jmp 37a1 <gets+0x41> 3772: 8d b6 00 00 00 00 lea 0x0(%esi),%esi cc = read(0, &c, 1); 3778: 8d 45 e7 lea -0x19(%ebp),%eax 377b: 83 ec 04 sub $0x4,%esp 377e: 6a 01 push $0x1 3780: 50 push %eax 3781: 6a 00 push $0x0 3783: e8 32 01 00 00 call 38ba <read> if(cc < 1) 3788: 83 c4 10 add $0x10,%esp 378b: 85 c0 test %eax,%eax 378d: 7e 1c jle 37ab <gets+0x4b> break; buf[i++] = c; 378f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 3793: 83 c7 01 add $0x1,%edi 3796: 88 47 ff mov %al,-0x1(%edi) if(c == '\n' || c == '\r') 3799: 3c 0a cmp $0xa,%al 379b: 74 23 je 37c0 <gets+0x60> 379d: 3c 0d cmp $0xd,%al 379f: 74 1f je 37c0 <gets+0x60> for(i=0; i+1 < max; ){ 37a1: 83 c3 01 add $0x1,%ebx 37a4: 3b 5d 0c cmp 0xc(%ebp),%ebx 37a7: 89 fe mov %edi,%esi 37a9: 7c cd jl 3778 <gets+0x18> 37ab: 89 f3 mov %esi,%ebx break; } buf[i] = '\0'; return buf; } 37ad: 8b 45 08 mov 0x8(%ebp),%eax buf[i] = '\0'; 37b0: c6 03 00 movb $0x0,(%ebx) } 37b3: 8d 65 f4 lea -0xc(%ebp),%esp 37b6: 5b pop %ebx 37b7: 5e pop %esi 37b8: 5f pop %edi 37b9: 5d pop %ebp 37ba: c3 ret 37bb: 90 nop 37bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 37c0: 8b 75 08 mov 0x8(%ebp),%esi 37c3: 8b 45 08 mov 0x8(%ebp),%eax 37c6: 01 de add %ebx,%esi 37c8: 89 f3 mov %esi,%ebx buf[i] = '\0'; 37ca: c6 03 00 movb $0x0,(%ebx) } 37cd: 8d 65 f4 lea -0xc(%ebp),%esp 37d0: 5b pop %ebx 37d1: 5e pop %esi 37d2: 5f pop %edi 37d3: 5d pop %ebp 37d4: c3 ret 37d5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 37d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000037e0 <stat>: int stat(const char *n, struct stat *st) { 37e0: 55 push %ebp 37e1: 89 e5 mov %esp,%ebp 37e3: 56 push %esi 37e4: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 37e5: 83 ec 08 sub $0x8,%esp 37e8: 6a 00 push $0x0 37ea: ff 75 08 pushl 0x8(%ebp) 37ed: e8 f0 00 00 00 call 38e2 <open> if(fd < 0) 37f2: 83 c4 10 add $0x10,%esp 37f5: 85 c0 test %eax,%eax 37f7: 78 27 js 3820 <stat+0x40> return -1; r = fstat(fd, st); 37f9: 83 ec 08 sub $0x8,%esp 37fc: ff 75 0c pushl 0xc(%ebp) 37ff: 89 c3 mov %eax,%ebx 3801: 50 push %eax 3802: e8 f3 00 00 00 call 38fa <fstat> close(fd); 3807: 89 1c 24 mov %ebx,(%esp) r = fstat(fd, st); 380a: 89 c6 mov %eax,%esi close(fd); 380c: e8 b9 00 00 00 call 38ca <close> return r; 3811: 83 c4 10 add $0x10,%esp } 3814: 8d 65 f8 lea -0x8(%ebp),%esp 3817: 89 f0 mov %esi,%eax 3819: 5b pop %ebx 381a: 5e pop %esi 381b: 5d pop %ebp 381c: c3 ret 381d: 8d 76 00 lea 0x0(%esi),%esi return -1; 3820: be ff ff ff ff mov $0xffffffff,%esi 3825: eb ed jmp 3814 <stat+0x34> 3827: 89 f6 mov %esi,%esi 3829: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00003830 <atoi>: int atoi(const char *s) { 3830: 55 push %ebp 3831: 89 e5 mov %esp,%ebp 3833: 53 push %ebx 3834: 8b 4d 08 mov 0x8(%ebp),%ecx int n; n = 0; while('0' <= *s && *s <= '9') 3837: 0f be 11 movsbl (%ecx),%edx 383a: 8d 42 d0 lea -0x30(%edx),%eax 383d: 3c 09 cmp $0x9,%al n = 0; 383f: b8 00 00 00 00 mov $0x0,%eax while('0' <= *s && *s <= '9') 3844: 77 1f ja 3865 <atoi+0x35> 3846: 8d 76 00 lea 0x0(%esi),%esi 3849: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi n = n*10 + *s++ - '0'; 3850: 8d 04 80 lea (%eax,%eax,4),%eax 3853: 83 c1 01 add $0x1,%ecx 3856: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax while('0' <= *s && *s <= '9') 385a: 0f be 11 movsbl (%ecx),%edx 385d: 8d 5a d0 lea -0x30(%edx),%ebx 3860: 80 fb 09 cmp $0x9,%bl 3863: 76 eb jbe 3850 <atoi+0x20> return n; } 3865: 5b pop %ebx 3866: 5d pop %ebp 3867: c3 ret 3868: 90 nop 3869: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00003870 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 3870: 55 push %ebp 3871: 89 e5 mov %esp,%ebp 3873: 56 push %esi 3874: 53 push %ebx 3875: 8b 5d 10 mov 0x10(%ebp),%ebx 3878: 8b 45 08 mov 0x8(%ebp),%eax 387b: 8b 75 0c mov 0xc(%ebp),%esi char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 387e: 85 db test %ebx,%ebx 3880: 7e 14 jle 3896 <memmove+0x26> 3882: 31 d2 xor %edx,%edx 3884: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 3888: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 388c: 88 0c 10 mov %cl,(%eax,%edx,1) 388f: 83 c2 01 add $0x1,%edx while(n-- > 0) 3892: 39 d3 cmp %edx,%ebx 3894: 75 f2 jne 3888 <memmove+0x18> return vdst; } 3896: 5b pop %ebx 3897: 5e pop %esi 3898: 5d pop %ebp 3899: c3 ret 0000389a <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 389a: b8 01 00 00 00 mov $0x1,%eax 389f: cd 40 int $0x40 38a1: c3 ret 000038a2 <exit>: SYSCALL(exit) 38a2: b8 02 00 00 00 mov $0x2,%eax 38a7: cd 40 int $0x40 38a9: c3 ret 000038aa <wait>: SYSCALL(wait) 38aa: b8 03 00 00 00 mov $0x3,%eax 38af: cd 40 int $0x40 38b1: c3 ret 000038b2 <pipe>: SYSCALL(pipe) 38b2: b8 04 00 00 00 mov $0x4,%eax 38b7: cd 40 int $0x40 38b9: c3 ret 000038ba <read>: SYSCALL(read) 38ba: b8 05 00 00 00 mov $0x5,%eax 38bf: cd 40 int $0x40 38c1: c3 ret 000038c2 <write>: SYSCALL(write) 38c2: b8 10 00 00 00 mov $0x10,%eax 38c7: cd 40 int $0x40 38c9: c3 ret 000038ca <close>: SYSCALL(close) 38ca: b8 15 00 00 00 mov $0x15,%eax 38cf: cd 40 int $0x40 38d1: c3 ret 000038d2 <kill>: SYSCALL(kill) 38d2: b8 06 00 00 00 mov $0x6,%eax 38d7: cd 40 int $0x40 38d9: c3 ret 000038da <exec>: SYSCALL(exec) 38da: b8 07 00 00 00 mov $0x7,%eax 38df: cd 40 int $0x40 38e1: c3 ret 000038e2 <open>: SYSCALL(open) 38e2: b8 0f 00 00 00 mov $0xf,%eax 38e7: cd 40 int $0x40 38e9: c3 ret 000038ea <mknod>: SYSCALL(mknod) 38ea: b8 11 00 00 00 mov $0x11,%eax 38ef: cd 40 int $0x40 38f1: c3 ret 000038f2 <unlink>: SYSCALL(unlink) 38f2: b8 12 00 00 00 mov $0x12,%eax 38f7: cd 40 int $0x40 38f9: c3 ret 000038fa <fstat>: SYSCALL(fstat) 38fa: b8 08 00 00 00 mov $0x8,%eax 38ff: cd 40 int $0x40 3901: c3 ret 00003902 <link>: SYSCALL(link) 3902: b8 13 00 00 00 mov $0x13,%eax 3907: cd 40 int $0x40 3909: c3 ret 0000390a <mkdir>: SYSCALL(mkdir) 390a: b8 14 00 00 00 mov $0x14,%eax 390f: cd 40 int $0x40 3911: c3 ret 00003912 <chdir>: SYSCALL(chdir) 3912: b8 09 00 00 00 mov $0x9,%eax 3917: cd 40 int $0x40 3919: c3 ret 0000391a <dup>: SYSCALL(dup) 391a: b8 0a 00 00 00 mov $0xa,%eax 391f: cd 40 int $0x40 3921: c3 ret 00003922 <getpid>: SYSCALL(getpid) 3922: b8 0b 00 00 00 mov $0xb,%eax 3927: cd 40 int $0x40 3929: c3 ret 0000392a <sbrk>: SYSCALL(sbrk) 392a: b8 0c 00 00 00 mov $0xc,%eax 392f: cd 40 int $0x40 3931: c3 ret 00003932 <sleep>: SYSCALL(sleep) 3932: b8 0d 00 00 00 mov $0xd,%eax 3937: cd 40 int $0x40 3939: c3 ret 0000393a <uptime>: SYSCALL(uptime) 393a: b8 0e 00 00 00 mov $0xe,%eax 393f: cd 40 int $0x40 3941: c3 ret 00003942 <chngpr>: SYSCALL(chngpr) 3942: b8 16 00 00 00 mov $0x16,%eax 3947: cd 40 int $0x40 3949: c3 ret 394a: 66 90 xchg %ax,%ax 394c: 66 90 xchg %ax,%ax 394e: 66 90 xchg %ax,%ax 00003950 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 3950: 55 push %ebp 3951: 89 e5 mov %esp,%ebp 3953: 57 push %edi 3954: 56 push %esi 3955: 53 push %ebx 3956: 83 ec 3c sub $0x3c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 3959: 85 d2 test %edx,%edx { 395b: 89 45 c0 mov %eax,-0x40(%ebp) neg = 1; x = -xx; 395e: 89 d0 mov %edx,%eax if(sgn && xx < 0){ 3960: 79 76 jns 39d8 <printint+0x88> 3962: f6 45 08 01 testb $0x1,0x8(%ebp) 3966: 74 70 je 39d8 <printint+0x88> x = -xx; 3968: f7 d8 neg %eax neg = 1; 396a: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) } else { x = xx; } i = 0; 3971: 31 f6 xor %esi,%esi 3973: 8d 5d d7 lea -0x29(%ebp),%ebx 3976: eb 0a jmp 3982 <printint+0x32> 3978: 90 nop 3979: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi do{ buf[i++] = digits[x % base]; 3980: 89 fe mov %edi,%esi 3982: 31 d2 xor %edx,%edx 3984: 8d 7e 01 lea 0x1(%esi),%edi 3987: f7 f1 div %ecx 3989: 0f b6 92 e8 54 00 00 movzbl 0x54e8(%edx),%edx }while((x /= base) != 0); 3990: 85 c0 test %eax,%eax buf[i++] = digits[x % base]; 3992: 88 14 3b mov %dl,(%ebx,%edi,1) }while((x /= base) != 0); 3995: 75 e9 jne 3980 <printint+0x30> if(neg) 3997: 8b 45 c4 mov -0x3c(%ebp),%eax 399a: 85 c0 test %eax,%eax 399c: 74 08 je 39a6 <printint+0x56> buf[i++] = '-'; 399e: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1) 39a3: 8d 7e 02 lea 0x2(%esi),%edi 39a6: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi 39aa: 8b 7d c0 mov -0x40(%ebp),%edi 39ad: 8d 76 00 lea 0x0(%esi),%esi 39b0: 0f b6 06 movzbl (%esi),%eax write(fd, &c, 1); 39b3: 83 ec 04 sub $0x4,%esp 39b6: 83 ee 01 sub $0x1,%esi 39b9: 6a 01 push $0x1 39bb: 53 push %ebx 39bc: 57 push %edi 39bd: 88 45 d7 mov %al,-0x29(%ebp) 39c0: e8 fd fe ff ff call 38c2 <write> while(--i >= 0) 39c5: 83 c4 10 add $0x10,%esp 39c8: 39 de cmp %ebx,%esi 39ca: 75 e4 jne 39b0 <printint+0x60> putc(fd, buf[i]); } 39cc: 8d 65 f4 lea -0xc(%ebp),%esp 39cf: 5b pop %ebx 39d0: 5e pop %esi 39d1: 5f pop %edi 39d2: 5d pop %ebp 39d3: c3 ret 39d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; 39d8: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 39df: eb 90 jmp 3971 <printint+0x21> 39e1: eb 0d jmp 39f0 <printf> 39e3: 90 nop 39e4: 90 nop 39e5: 90 nop 39e6: 90 nop 39e7: 90 nop 39e8: 90 nop 39e9: 90 nop 39ea: 90 nop 39eb: 90 nop 39ec: 90 nop 39ed: 90 nop 39ee: 90 nop 39ef: 90 nop 000039f0 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 39f0: 55 push %ebp 39f1: 89 e5 mov %esp,%ebp 39f3: 57 push %edi 39f4: 56 push %esi 39f5: 53 push %ebx 39f6: 83 ec 2c sub $0x2c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 39f9: 8b 75 0c mov 0xc(%ebp),%esi 39fc: 0f b6 1e movzbl (%esi),%ebx 39ff: 84 db test %bl,%bl 3a01: 0f 84 b3 00 00 00 je 3aba <printf+0xca> ap = (uint*)(void*)&fmt + 1; 3a07: 8d 45 10 lea 0x10(%ebp),%eax 3a0a: 83 c6 01 add $0x1,%esi state = 0; 3a0d: 31 ff xor %edi,%edi ap = (uint*)(void*)&fmt + 1; 3a0f: 89 45 d4 mov %eax,-0x2c(%ebp) 3a12: eb 2f jmp 3a43 <printf+0x53> 3a14: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 3a18: 83 f8 25 cmp $0x25,%eax 3a1b: 0f 84 a7 00 00 00 je 3ac8 <printf+0xd8> write(fd, &c, 1); 3a21: 8d 45 e2 lea -0x1e(%ebp),%eax 3a24: 83 ec 04 sub $0x4,%esp 3a27: 88 5d e2 mov %bl,-0x1e(%ebp) 3a2a: 6a 01 push $0x1 3a2c: 50 push %eax 3a2d: ff 75 08 pushl 0x8(%ebp) 3a30: e8 8d fe ff ff call 38c2 <write> 3a35: 83 c4 10 add $0x10,%esp 3a38: 83 c6 01 add $0x1,%esi for(i = 0; fmt[i]; i++){ 3a3b: 0f b6 5e ff movzbl -0x1(%esi),%ebx 3a3f: 84 db test %bl,%bl 3a41: 74 77 je 3aba <printf+0xca> if(state == 0){ 3a43: 85 ff test %edi,%edi c = fmt[i] & 0xff; 3a45: 0f be cb movsbl %bl,%ecx 3a48: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 3a4b: 74 cb je 3a18 <printf+0x28> state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 3a4d: 83 ff 25 cmp $0x25,%edi 3a50: 75 e6 jne 3a38 <printf+0x48> if(c == 'd'){ 3a52: 83 f8 64 cmp $0x64,%eax 3a55: 0f 84 05 01 00 00 je 3b60 <printf+0x170> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 3a5b: 81 e1 f7 00 00 00 and $0xf7,%ecx 3a61: 83 f9 70 cmp $0x70,%ecx 3a64: 74 72 je 3ad8 <printf+0xe8> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 3a66: 83 f8 73 cmp $0x73,%eax 3a69: 0f 84 99 00 00 00 je 3b08 <printf+0x118> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 3a6f: 83 f8 63 cmp $0x63,%eax 3a72: 0f 84 08 01 00 00 je 3b80 <printf+0x190> putc(fd, *ap); ap++; } else if(c == '%'){ 3a78: 83 f8 25 cmp $0x25,%eax 3a7b: 0f 84 ef 00 00 00 je 3b70 <printf+0x180> write(fd, &c, 1); 3a81: 8d 45 e7 lea -0x19(%ebp),%eax 3a84: 83 ec 04 sub $0x4,%esp 3a87: c6 45 e7 25 movb $0x25,-0x19(%ebp) 3a8b: 6a 01 push $0x1 3a8d: 50 push %eax 3a8e: ff 75 08 pushl 0x8(%ebp) 3a91: e8 2c fe ff ff call 38c2 <write> 3a96: 83 c4 0c add $0xc,%esp 3a99: 8d 45 e6 lea -0x1a(%ebp),%eax 3a9c: 88 5d e6 mov %bl,-0x1a(%ebp) 3a9f: 6a 01 push $0x1 3aa1: 50 push %eax 3aa2: ff 75 08 pushl 0x8(%ebp) 3aa5: 83 c6 01 add $0x1,%esi } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 3aa8: 31 ff xor %edi,%edi write(fd, &c, 1); 3aaa: e8 13 fe ff ff call 38c2 <write> for(i = 0; fmt[i]; i++){ 3aaf: 0f b6 5e ff movzbl -0x1(%esi),%ebx write(fd, &c, 1); 3ab3: 83 c4 10 add $0x10,%esp for(i = 0; fmt[i]; i++){ 3ab6: 84 db test %bl,%bl 3ab8: 75 89 jne 3a43 <printf+0x53> } } } 3aba: 8d 65 f4 lea -0xc(%ebp),%esp 3abd: 5b pop %ebx 3abe: 5e pop %esi 3abf: 5f pop %edi 3ac0: 5d pop %ebp 3ac1: c3 ret 3ac2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi state = '%'; 3ac8: bf 25 00 00 00 mov $0x25,%edi 3acd: e9 66 ff ff ff jmp 3a38 <printf+0x48> 3ad2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi printint(fd, *ap, 16, 0); 3ad8: 83 ec 0c sub $0xc,%esp 3adb: b9 10 00 00 00 mov $0x10,%ecx 3ae0: 6a 00 push $0x0 3ae2: 8b 7d d4 mov -0x2c(%ebp),%edi 3ae5: 8b 45 08 mov 0x8(%ebp),%eax 3ae8: 8b 17 mov (%edi),%edx 3aea: e8 61 fe ff ff call 3950 <printint> ap++; 3aef: 89 f8 mov %edi,%eax 3af1: 83 c4 10 add $0x10,%esp state = 0; 3af4: 31 ff xor %edi,%edi ap++; 3af6: 83 c0 04 add $0x4,%eax 3af9: 89 45 d4 mov %eax,-0x2c(%ebp) 3afc: e9 37 ff ff ff jmp 3a38 <printf+0x48> 3b01: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi s = (char*)*ap; 3b08: 8b 45 d4 mov -0x2c(%ebp),%eax 3b0b: 8b 08 mov (%eax),%ecx ap++; 3b0d: 83 c0 04 add $0x4,%eax 3b10: 89 45 d4 mov %eax,-0x2c(%ebp) if(s == 0) 3b13: 85 c9 test %ecx,%ecx 3b15: 0f 84 8e 00 00 00 je 3ba9 <printf+0x1b9> while(*s != 0){ 3b1b: 0f b6 01 movzbl (%ecx),%eax state = 0; 3b1e: 31 ff xor %edi,%edi s = (char*)*ap; 3b20: 89 cb mov %ecx,%ebx while(*s != 0){ 3b22: 84 c0 test %al,%al 3b24: 0f 84 0e ff ff ff je 3a38 <printf+0x48> 3b2a: 89 75 d0 mov %esi,-0x30(%ebp) 3b2d: 89 de mov %ebx,%esi 3b2f: 8b 5d 08 mov 0x8(%ebp),%ebx 3b32: 8d 7d e3 lea -0x1d(%ebp),%edi 3b35: 8d 76 00 lea 0x0(%esi),%esi write(fd, &c, 1); 3b38: 83 ec 04 sub $0x4,%esp s++; 3b3b: 83 c6 01 add $0x1,%esi 3b3e: 88 45 e3 mov %al,-0x1d(%ebp) write(fd, &c, 1); 3b41: 6a 01 push $0x1 3b43: 57 push %edi 3b44: 53 push %ebx 3b45: e8 78 fd ff ff call 38c2 <write> while(*s != 0){ 3b4a: 0f b6 06 movzbl (%esi),%eax 3b4d: 83 c4 10 add $0x10,%esp 3b50: 84 c0 test %al,%al 3b52: 75 e4 jne 3b38 <printf+0x148> 3b54: 8b 75 d0 mov -0x30(%ebp),%esi state = 0; 3b57: 31 ff xor %edi,%edi 3b59: e9 da fe ff ff jmp 3a38 <printf+0x48> 3b5e: 66 90 xchg %ax,%ax printint(fd, *ap, 10, 1); 3b60: 83 ec 0c sub $0xc,%esp 3b63: b9 0a 00 00 00 mov $0xa,%ecx 3b68: 6a 01 push $0x1 3b6a: e9 73 ff ff ff jmp 3ae2 <printf+0xf2> 3b6f: 90 nop write(fd, &c, 1); 3b70: 83 ec 04 sub $0x4,%esp 3b73: 88 5d e5 mov %bl,-0x1b(%ebp) 3b76: 8d 45 e5 lea -0x1b(%ebp),%eax 3b79: 6a 01 push $0x1 3b7b: e9 21 ff ff ff jmp 3aa1 <printf+0xb1> putc(fd, *ap); 3b80: 8b 7d d4 mov -0x2c(%ebp),%edi write(fd, &c, 1); 3b83: 83 ec 04 sub $0x4,%esp putc(fd, *ap); 3b86: 8b 07 mov (%edi),%eax write(fd, &c, 1); 3b88: 6a 01 push $0x1 ap++; 3b8a: 83 c7 04 add $0x4,%edi putc(fd, *ap); 3b8d: 88 45 e4 mov %al,-0x1c(%ebp) write(fd, &c, 1); 3b90: 8d 45 e4 lea -0x1c(%ebp),%eax 3b93: 50 push %eax 3b94: ff 75 08 pushl 0x8(%ebp) 3b97: e8 26 fd ff ff call 38c2 <write> ap++; 3b9c: 89 7d d4 mov %edi,-0x2c(%ebp) 3b9f: 83 c4 10 add $0x10,%esp state = 0; 3ba2: 31 ff xor %edi,%edi 3ba4: e9 8f fe ff ff jmp 3a38 <printf+0x48> s = "(null)"; 3ba9: bb e0 54 00 00 mov $0x54e0,%ebx while(*s != 0){ 3bae: b8 28 00 00 00 mov $0x28,%eax 3bb3: e9 72 ff ff ff jmp 3b2a <printf+0x13a> 3bb8: 66 90 xchg %ax,%ax 3bba: 66 90 xchg %ax,%ax 3bbc: 66 90 xchg %ax,%ax 3bbe: 66 90 xchg %ax,%ax 00003bc0 <free>: static Header base; static Header *freep; void free(void *ap) { 3bc0: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 3bc1: a1 a0 5e 00 00 mov 0x5ea0,%eax { 3bc6: 89 e5 mov %esp,%ebp 3bc8: 57 push %edi 3bc9: 56 push %esi 3bca: 53 push %ebx 3bcb: 8b 5d 08 mov 0x8(%ebp),%ebx bp = (Header*)ap - 1; 3bce: 8d 4b f8 lea -0x8(%ebx),%ecx 3bd1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 3bd8: 39 c8 cmp %ecx,%eax 3bda: 8b 10 mov (%eax),%edx 3bdc: 73 32 jae 3c10 <free+0x50> 3bde: 39 d1 cmp %edx,%ecx 3be0: 72 04 jb 3be6 <free+0x26> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 3be2: 39 d0 cmp %edx,%eax 3be4: 72 32 jb 3c18 <free+0x58> break; if(bp + bp->s.size == p->s.ptr){ 3be6: 8b 73 fc mov -0x4(%ebx),%esi 3be9: 8d 3c f1 lea (%ecx,%esi,8),%edi 3bec: 39 fa cmp %edi,%edx 3bee: 74 30 je 3c20 <free+0x60> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 3bf0: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 3bf3: 8b 50 04 mov 0x4(%eax),%edx 3bf6: 8d 34 d0 lea (%eax,%edx,8),%esi 3bf9: 39 f1 cmp %esi,%ecx 3bfb: 74 3a je 3c37 <free+0x77> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 3bfd: 89 08 mov %ecx,(%eax) freep = p; 3bff: a3 a0 5e 00 00 mov %eax,0x5ea0 } 3c04: 5b pop %ebx 3c05: 5e pop %esi 3c06: 5f pop %edi 3c07: 5d pop %ebp 3c08: c3 ret 3c09: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 3c10: 39 d0 cmp %edx,%eax 3c12: 72 04 jb 3c18 <free+0x58> 3c14: 39 d1 cmp %edx,%ecx 3c16: 72 ce jb 3be6 <free+0x26> { 3c18: 89 d0 mov %edx,%eax 3c1a: eb bc jmp 3bd8 <free+0x18> 3c1c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi bp->s.size += p->s.ptr->s.size; 3c20: 03 72 04 add 0x4(%edx),%esi 3c23: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 3c26: 8b 10 mov (%eax),%edx 3c28: 8b 12 mov (%edx),%edx 3c2a: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 3c2d: 8b 50 04 mov 0x4(%eax),%edx 3c30: 8d 34 d0 lea (%eax,%edx,8),%esi 3c33: 39 f1 cmp %esi,%ecx 3c35: 75 c6 jne 3bfd <free+0x3d> p->s.size += bp->s.size; 3c37: 03 53 fc add -0x4(%ebx),%edx freep = p; 3c3a: a3 a0 5e 00 00 mov %eax,0x5ea0 p->s.size += bp->s.size; 3c3f: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 3c42: 8b 53 f8 mov -0x8(%ebx),%edx 3c45: 89 10 mov %edx,(%eax) } 3c47: 5b pop %ebx 3c48: 5e pop %esi 3c49: 5f pop %edi 3c4a: 5d pop %ebp 3c4b: c3 ret 3c4c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00003c50 <malloc>: return freep; } void* malloc(uint nbytes) { 3c50: 55 push %ebp 3c51: 89 e5 mov %esp,%ebp 3c53: 57 push %edi 3c54: 56 push %esi 3c55: 53 push %ebx 3c56: 83 ec 0c sub $0xc,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 3c59: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 3c5c: 8b 15 a0 5e 00 00 mov 0x5ea0,%edx nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 3c62: 8d 78 07 lea 0x7(%eax),%edi 3c65: c1 ef 03 shr $0x3,%edi 3c68: 83 c7 01 add $0x1,%edi if((prevp = freep) == 0){ 3c6b: 85 d2 test %edx,%edx 3c6d: 0f 84 9d 00 00 00 je 3d10 <malloc+0xc0> 3c73: 8b 02 mov (%edx),%eax 3c75: 8b 48 04 mov 0x4(%eax),%ecx base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ 3c78: 39 cf cmp %ecx,%edi 3c7a: 76 6c jbe 3ce8 <malloc+0x98> 3c7c: 81 ff 00 10 00 00 cmp $0x1000,%edi 3c82: bb 00 10 00 00 mov $0x1000,%ebx 3c87: 0f 43 df cmovae %edi,%ebx p = sbrk(nu * sizeof(Header)); 3c8a: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi 3c91: eb 0e jmp 3ca1 <malloc+0x51> 3c93: 90 nop 3c94: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 3c98: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 3c9a: 8b 48 04 mov 0x4(%eax),%ecx 3c9d: 39 f9 cmp %edi,%ecx 3c9f: 73 47 jae 3ce8 <malloc+0x98> p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 3ca1: 39 05 a0 5e 00 00 cmp %eax,0x5ea0 3ca7: 89 c2 mov %eax,%edx 3ca9: 75 ed jne 3c98 <malloc+0x48> p = sbrk(nu * sizeof(Header)); 3cab: 83 ec 0c sub $0xc,%esp 3cae: 56 push %esi 3caf: e8 76 fc ff ff call 392a <sbrk> if(p == (char*)-1) 3cb4: 83 c4 10 add $0x10,%esp 3cb7: 83 f8 ff cmp $0xffffffff,%eax 3cba: 74 1c je 3cd8 <malloc+0x88> hp->s.size = nu; 3cbc: 89 58 04 mov %ebx,0x4(%eax) free((void*)(hp + 1)); 3cbf: 83 ec 0c sub $0xc,%esp 3cc2: 83 c0 08 add $0x8,%eax 3cc5: 50 push %eax 3cc6: e8 f5 fe ff ff call 3bc0 <free> return freep; 3ccb: 8b 15 a0 5e 00 00 mov 0x5ea0,%edx if((p = morecore(nunits)) == 0) 3cd1: 83 c4 10 add $0x10,%esp 3cd4: 85 d2 test %edx,%edx 3cd6: 75 c0 jne 3c98 <malloc+0x48> return 0; } } 3cd8: 8d 65 f4 lea -0xc(%ebp),%esp return 0; 3cdb: 31 c0 xor %eax,%eax } 3cdd: 5b pop %ebx 3cde: 5e pop %esi 3cdf: 5f pop %edi 3ce0: 5d pop %ebp 3ce1: c3 ret 3ce2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(p->s.size == nunits) 3ce8: 39 cf cmp %ecx,%edi 3cea: 74 54 je 3d40 <malloc+0xf0> p->s.size -= nunits; 3cec: 29 f9 sub %edi,%ecx 3cee: 89 48 04 mov %ecx,0x4(%eax) p += p->s.size; 3cf1: 8d 04 c8 lea (%eax,%ecx,8),%eax p->s.size = nunits; 3cf4: 89 78 04 mov %edi,0x4(%eax) freep = prevp; 3cf7: 89 15 a0 5e 00 00 mov %edx,0x5ea0 } 3cfd: 8d 65 f4 lea -0xc(%ebp),%esp return (void*)(p + 1); 3d00: 83 c0 08 add $0x8,%eax } 3d03: 5b pop %ebx 3d04: 5e pop %esi 3d05: 5f pop %edi 3d06: 5d pop %ebp 3d07: c3 ret 3d08: 90 nop 3d09: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi base.s.ptr = freep = prevp = &base; 3d10: c7 05 a0 5e 00 00 a4 movl $0x5ea4,0x5ea0 3d17: 5e 00 00 3d1a: c7 05 a4 5e 00 00 a4 movl $0x5ea4,0x5ea4 3d21: 5e 00 00 base.s.size = 0; 3d24: b8 a4 5e 00 00 mov $0x5ea4,%eax 3d29: c7 05 a8 5e 00 00 00 movl $0x0,0x5ea8 3d30: 00 00 00 3d33: e9 44 ff ff ff jmp 3c7c <malloc+0x2c> 3d38: 90 nop 3d39: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi prevp->s.ptr = p->s.ptr; 3d40: 8b 08 mov (%eax),%ecx 3d42: 89 0a mov %ecx,(%edx) 3d44: eb b1 jmp 3cf7 <malloc+0xa7>
START: LI R0 0X80 SLL R0 R0 0X00 LI R1 0X10 SW R0 R1 0X00 NOP FOREVER: NOP B FOREVER NOP NOP
.disk [filename = "spacelib2.d64", name="SPACELIB2", id="2021"] { [name="--------------", type="rel" ], [name="SPACELIB2 DEMO", type="prg", segments="Default"], [name="--------------", type="rel" ], } // enables various debug readouts & functionality // #define DEBUG #import "player.asm" // setting to true speeds up irq handling by disabling kernal & default handlers .const quick_irq = true // colour of background + border lines .const floor_colour = sl.gfx.dark_grey .const outside_colour = sl.gfx.grey .const hall_begin_line = 100 .const hall_end_line = 200 irq_hall_begin: sl_interrupts_irq_handler_begin(quick_irq) sl_gfx_set_border_colour(floor_colour) sl_interrupts_raster_set_trigger_line(hall_end_line, irq_hall_end, quick_irq) sl_interrupts_irq_handler_end(quick_irq) irq_hall_end: sl_interrupts_irq_handler_begin(quick_irq) sl_gfx_set_border_colour(outside_colour) sl_interrupts_raster_set_trigger_line(hall_begin_line, irq_hall_begin, quick_irq) sl_interrupts_irq_handler_end(quick_irq) entry_point: .if (quick_irq) { // yeet kernal & basic sl_bank_disable_kernal() } sl_interrupts_raster_init(hall_begin_line, irq_hall_begin, quick_irq) // set colours & clear screen sl_gfx_set_border_colour(outside_colour) sl_gfx_set_background_colour(floor_colour) sl_gfx_fill(colour_base, sl.gfx.white) sl_gfx_fill(screen_base, ' ') // init sprites sl_sprite_multicolour_enable_all(true) sl_sprite_multicolour_set_colours(sl.gfx.green, sl.gfx.blue) jsr player.init sl_sprite_enable_all(true) main_loop: sl_gfx_wait_for_raster(250) jsr player.update sl_sprite_anim_update() jmp main_loop
// Copyright 2021 Dhiraj Wishal // SPDX-License-Identifier: Apache-2.0 #pragma once #include "Graphics/Objects/Asset.hpp" #include "GraphicsCore/Shader.hpp" namespace Flint { /** * Flint smart shader compiler. */ class SmartShaderCompiler { using TIOAttribute = std::pair<ShaderAttribute, uint32>; using TResource = std::pair<ShaderResourceType, uint32>; public: SmartShaderCompiler() = default; /** * Add a given input attribute type. * * @param type The attribute type. * @param location The location in the shader layout. */ void AddInput(const InputAttributeType type, const uint32 location); /** * Add a given output attribute type. * * @param type The attribute type. * @param location The location in the shader layout. */ void AddOutput(const InputAttributeType type, const uint32 location); /** * Add a uniform to the shader. * * @param type The shader type. * @param setIndex The set index of the uniform. * @param binding The resource binding. */ void AddUniform(const ShaderResourceType type, const uint32 setIndex, const uint32 binding); /** * Compile the shader. * This should be done after enabling and submitting all the settings. */ void Compile(); private: std::vector<TIOAttribute> mInputAttributes = {}; std::vector<TIOAttribute> mOutputAttributes = {}; std::unordered_map<uint32, std::vector<TResource>> mResourceSetMap = {}; }; }
; Copyright © 2018, VideoLAN and dav1d authors ; Copyright © 2018, Two Orioles, LLC ; All rights reserved. ; ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions are met: ; ; 1. Redistributions of source code must retain the above copyright notice, this ; list of conditions and the following disclaimer. ; ; 2. Redistributions in binary form must reproduce the above copyright notice, ; this list of conditions and the following disclaimer in the documentation ; and/or other materials provided with the distribution. ; ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ; ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE ; DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ; ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. %include "ext/x86/x86inc.asm" %if ARCH_X86_64 SECTION_RODATA 64 %macro SMOOTH_WEIGHT_TABLE 1-* %rep %0 db %1-128, 127-%1 %rotate 1 %endrep %endmacro ; sm_weights[], but modified to precalculate x and 256-x with offsets to ; enable efficient use of pmaddubsw (which requires signed values) smooth_weights: SMOOTH_WEIGHT_TABLE \ 0, 0, 255, 128, 255, 149, 85, 64, \ 255, 197, 146, 105, 73, 50, 37, 32, \ 255, 225, 196, 170, 145, 123, 102, 84, \ 68, 54, 43, 33, 26, 20, 17, 16, \ 255, 240, 225, 210, 196, 182, 169, 157, \ 145, 133, 122, 111, 101, 92, 83, 74, \ 66, 59, 52, 45, 39, 34, 29, 25, \ 21, 17, 14, 12, 10, 9, 8, 8, \ 255, 248, 240, 233, 225, 218, 210, 203, \ 196, 189, 182, 176, 169, 163, 156, 150, \ 144, 138, 133, 127, 121, 116, 111, 106, \ 101, 96, 91, 86, 82, 77, 73, 69, \ 65, 61, 57, 54, 50, 47, 44, 41, \ 38, 35, 32, 29, 27, 25, 22, 20, \ 18, 16, 15, 13, 12, 10, 9, 8, \ 7, 6, 6, 5, 5, 4, 4, 4 pb_1to32: db 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 db 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32 pb_32to1: db 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17 pb_16to1: db 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 z_filter_wh: db 7, 7, 11, 11, 15, 15, 19, 19, 19, 23, 23, 23, 31, 31, 31, 39 db 39, 39, 47, 47, 47, 63, 63, 63, 79, 79, 79, -1 z_filter_k: db 0, 16, 0, 16, 0, 20, 0, 20, 8, 16, 8, 16 db 32, 16, 32, 16, 24, 20, 24, 20, 16, 16, 16, 16 db 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 8, 0 z_filter_s: db 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7 db 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15 db 15, 15, 15, 15, 15, 15, 15, 15 ; should be in one cache line pb_128: times 4 db 128 ; those are just placed here for alignment. pb_36_m4: times 2 db 36, -4 z3_shuf: db 8, 7, 7, 6, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 0 z_filter_t0: db 55,127, 39,127, 39,127, 7, 15, 31, 7, 15, 31, 0, 3, 31, 0 z_filter_t1: db 39, 63, 19, 47, 19, 47, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0 z_upsample1: db 1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 7, 6, 8, 7 z_upsample2: db 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 8, 8, 8 z2_upsample: db 7, 6, 15, 14, 5, 4, 13, 12, 3, 2, 11, 10, 1, 0, 9, 8 z1_shuf_w4: db 0, 1, 1, 2, 2, 3, 3, 4, 8, 9, 9, 10, 10, 11, 11, 12 z2_shuf_h2: db 3, 2, 7, 6, 11, 10, 15, 14, 2, 1, 6, 5, 10, 9, 14, 13 z2_shuf_h4: db 7, 6, 15, 14, 6, 5, 14, 13, 5, 4, 13, 12, 4, 3, 12, 11 z3_shuf_w4: db 4, 3, 3, 2, 2, 1, 1, 0, 12, 11, 11, 10, 10, 9, 9, 8 z_transpose4: db 0, 4, 8, 12, 1, 5, 9, 13, 2, 6, 10, 14, 3, 7, 11, 15 z_base_inc: dw 0*64, 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64 dw 16*64, 17*64, 18*64, 19*64, 20*64, 21*64, 22*64, 23*64 z2_base_inc: dw 1*64, 2*64, 3*64, 4*64, 5*64, 6*64, 7*64, 8*64 dw 9*64, 10*64, 11*64, 12*64, 13*64, 14*64, 15*64, 16*64 z2_ymul: dw 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 z2_y_shuf_h4: db 90, 90, 90, 90, 14, 14, 14, 14, 27, 27, 27, 27, 31, 31, 31, 31 ; 2, 6, 3, 7 db 32, 32, 32, 32, 12, 12, 12, 12, 1, 0, 1, 0, 5, -1, -1, -1 ; 0, 4, 1, 5 ; vpermd indices in bits 4..6 of filter_shuf1: 0, 2, 6, 4, 1, 3, 7, 5 filter_shuf1: db 10, 4, 10, 4, 37, 6, 5, 6,103, 9, 7, 9, 72, -1, 8, -1 db 16, 4, 0, 4, 53, 6, 5, 6,119, 11, 7, 11, 95, -1, 15, -1 filter_shuf2: db 3, 4, 3, 4, 5, 6, 5, 6, 7, 2, 7, 2, 1, -1, 1, -1 filter_shuf3: db 3, 4, 3, 4, 5, 6, 5, 6, 7, 11, 7, 11; 15, -1, 15, -1 pb_127_m127: times 2 db 127, -127 ipred_v_shuf: db 0, 1, 0, 1, 4, 5, 4, 5, 8, 9, 8, 9, 12, 13, 12, 13 db 2, 3, 2, 3, 6, 7, 6, 7, 10, 11, 10, 11, 14, 15, 14, 15 ipred_h_shuf: db 7, 7, 7, 7, 3, 3, 3, 3, 5, 5, 5, 5, 1, 1, 1, 1 db 6, 6, 6, 6, 2, 2, 2, 2, 4, 4, 4, 4; 0, 0, 0, 0 pw_64: times 2 dw 64 cfl_ac_444_w16_pad1_shuffle: db 0, -1, 1, -1, 2, -1, 3, -1, 4, -1, 5, -1, 6, -1 times 9 db 7, -1 cfl_ac_w16_pad_shuffle: ; w=16, w_pad=1 db 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 ; w=8, w_pad=1 as well as second half of previous one cfl_ac_w8_pad1_shuffle: db 0, 1, 2, 3, 4, 5 times 5 db 6, 7 ; w=16,w_pad=2 db 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 times 8 db 14, 15 ; w=16,w_pad=3 db 0, 1, 2, 3, 4, 5 times 13 db 6, 7 pb_15to0: db 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 %define pb_0to15 cfl_ac_w16_pad_shuffle %define pb_1 (ipred_h_shuf+12) %define pb_2 (ipred_h_shuf+20) %define pb_3 (ipred_h_shuf+ 4) %define pb_4 (ipred_h_shuf+24) %define pb_5 (ipred_h_shuf+ 8) %define pb_7 (ipred_h_shuf+ 0) %define pb_8 (z_upsample2 +12) %define pb_12 (z2_y_shuf_h4+20) %define pb_14 (z2_y_shuf_h4+ 4) %define pb_15 (z_filter_s +32) %define pb_27 (z2_y_shuf_h4+ 8) %define pb_31 (z2_y_shuf_h4+12) %define pb_32 (z2_y_shuf_h4+16) %define pb_90 (z2_y_shuf_h4+ 0) %define pw_1 (z2_y_shuf_h4+24) %define pw_8 (z_filter_k +32) pw_62: times 2 dw 62 pw_128: times 2 dw 128 pw_255: times 2 dw 255 pw_512: times 2 dw 512 %macro JMP_TABLE 3-* %xdefine %1_%2_table (%%table - 2*4) %xdefine %%base mangle(private_prefix %+ _%1_%2) %%table: %rep %0 - 2 dd %%base %+ .%3 - (%%table - 2*4) %rotate 1 %endrep %endmacro %define ipred_dc_splat_avx2_table (ipred_dc_avx2_table + 10*4) %define ipred_cfl_splat_avx2_table (ipred_cfl_avx2_table + 8*4) JMP_TABLE ipred_smooth, avx2, w4, w8, w16, w32, w64 JMP_TABLE ipred_smooth_v, avx2, w4, w8, w16, w32, w64 JMP_TABLE ipred_smooth_h, avx2, w4, w8, w16, w32, w64 JMP_TABLE ipred_paeth, avx2, w4, w8, w16, w32, w64 JMP_TABLE ipred_filter, avx2, w4, w8, w16, w32 JMP_TABLE ipred_dc, avx2, h4, h8, h16, h32, h64, w4, w8, w16, w32, w64, \ s4-10*4, s8-10*4, s16-10*4, s32-10*4, s64-10*4 JMP_TABLE ipred_dc_left, avx2, h4, h8, h16, h32, h64 JMP_TABLE ipred_h, avx2, w4, w8, w16, w32, w64 JMP_TABLE ipred_z1, avx2, w4, w8, w16, w32, w64 JMP_TABLE ipred_z2, avx2, w4, w8, w16, w32, w64 JMP_TABLE ipred_z3, avx2, h4, h8, h16, h32, h64 JMP_TABLE ipred_cfl, avx2, h4, h8, h16, h32, w4, w8, w16, w32, \ s4-8*4, s8-8*4, s16-8*4, s32-8*4 JMP_TABLE ipred_cfl_left, avx2, h4, h8, h16, h32 JMP_TABLE ipred_cfl_ac_420, avx2, w16_pad1, w16_pad2, w16_pad3 JMP_TABLE ipred_cfl_ac_422, avx2, w16_pad1, w16_pad2, w16_pad3 JMP_TABLE ipred_cfl_ac_444, avx2, w32_pad1, w32_pad2, w32_pad3, w4, w8, w16, w32 JMP_TABLE pal_pred, avx2, w4, w8, w16, w32, w64 cextern dr_intra_derivative cextern filter_intra_taps SECTION .text INIT_YMM avx2 cglobal ipred_dc_top, 3, 7, 6, dst, stride, tl, w, h lea r5, [ipred_dc_left_avx2_table] tzcnt wd, wm inc tlq movu m0, [tlq] movifnidn hd, hm mov r6d, 0x8000 shrx r6d, r6d, wd movd xm3, r6d movsxd r6, [r5+wq*4] pcmpeqd m2, m2 pmaddubsw m0, m2 add r6, r5 add r5, ipred_dc_splat_avx2_table-ipred_dc_left_avx2_table movsxd wq, [r5+wq*4] add wq, r5 jmp r6 cglobal ipred_dc_left, 3, 7, 6, dst, stride, tl, w, h, stride3 mov hd, hm ; zero upper half tzcnt r6d, hd sub tlq, hq tzcnt wd, wm movu m0, [tlq] mov r5d, 0x8000 shrx r5d, r5d, r6d movd xm3, r5d lea r5, [ipred_dc_left_avx2_table] movsxd r6, [r5+r6*4] pcmpeqd m2, m2 pmaddubsw m0, m2 add r6, r5 add r5, ipred_dc_splat_avx2_table-ipred_dc_left_avx2_table movsxd wq, [r5+wq*4] add wq, r5 jmp r6 .h64: movu m1, [tlq+32] ; unaligned when jumping here from dc_top pmaddubsw m1, m2 paddw m0, m1 .h32: vextracti128 xm1, m0, 1 paddw xm0, xm1 .h16: punpckhqdq xm1, xm0, xm0 paddw xm0, xm1 .h8: psrlq xm1, xm0, 32 paddw xm0, xm1 .h4: pmaddwd xm0, xm2 pmulhrsw xm0, xm3 lea stride3q, [strideq*3] vpbroadcastb m0, xm0 mova m1, m0 jmp wq cglobal ipred_dc, 3, 7, 6, dst, stride, tl, w, h, stride3 movifnidn hd, hm movifnidn wd, wm tzcnt r6d, hd lea r5d, [wq+hq] movd xm4, r5d tzcnt r5d, r5d movd xm5, r5d lea r5, [ipred_dc_avx2_table] tzcnt wd, wd movsxd r6, [r5+r6*4] movsxd wq, [r5+wq*4+5*4] pcmpeqd m3, m3 psrlw xm4, 1 add r6, r5 add wq, r5 lea stride3q, [strideq*3] jmp r6 .h4: movd xm0, [tlq-4] pmaddubsw xm0, xm3 jmp wq .w4: movd xm1, [tlq+1] pmaddubsw xm1, xm3 psubw xm0, xm4 paddw xm0, xm1 pmaddwd xm0, xm3 cmp hd, 4 jg .w4_mul psrlw xm0, 3 jmp .w4_end .w4_mul: punpckhqdq xm1, xm0, xm0 lea r2d, [hq*2] mov r6d, 0x55563334 paddw xm0, xm1 shrx r6d, r6d, r2d psrlq xm1, xm0, 32 paddw xm0, xm1 movd xm1, r6d psrlw xm0, 2 pmulhuw xm0, xm1 .w4_end: vpbroadcastb xm0, xm0 .s4: movd [dstq+strideq*0], xm0 movd [dstq+strideq*1], xm0 movd [dstq+strideq*2], xm0 movd [dstq+stride3q ], xm0 lea dstq, [dstq+strideq*4] sub hd, 4 jg .s4 RET ALIGN function_align .h8: movq xm0, [tlq-8] pmaddubsw xm0, xm3 jmp wq .w8: movq xm1, [tlq+1] vextracti128 xm2, m0, 1 pmaddubsw xm1, xm3 psubw xm0, xm4 paddw xm0, xm2 punpckhqdq xm2, xm0, xm0 paddw xm0, xm2 paddw xm0, xm1 psrlq xm1, xm0, 32 paddw xm0, xm1 pmaddwd xm0, xm3 psrlw xm0, xm5 cmp hd, 8 je .w8_end mov r6d, 0x5556 mov r2d, 0x3334 cmp hd, 32 cmove r6d, r2d movd xm1, r6d pmulhuw xm0, xm1 .w8_end: vpbroadcastb xm0, xm0 .s8: movq [dstq+strideq*0], xm0 movq [dstq+strideq*1], xm0 movq [dstq+strideq*2], xm0 movq [dstq+stride3q ], xm0 lea dstq, [dstq+strideq*4] sub hd, 4 jg .s8 RET ALIGN function_align .h16: mova xm0, [tlq-16] pmaddubsw xm0, xm3 jmp wq .w16: movu xm1, [tlq+1] vextracti128 xm2, m0, 1 pmaddubsw xm1, xm3 psubw xm0, xm4 paddw xm0, xm2 paddw xm0, xm1 punpckhqdq xm1, xm0, xm0 paddw xm0, xm1 psrlq xm1, xm0, 32 paddw xm0, xm1 pmaddwd xm0, xm3 psrlw xm0, xm5 cmp hd, 16 je .w16_end mov r6d, 0x5556 mov r2d, 0x3334 test hb, 8|32 cmovz r6d, r2d movd xm1, r6d pmulhuw xm0, xm1 .w16_end: vpbroadcastb xm0, xm0 .s16: mova [dstq+strideq*0], xm0 mova [dstq+strideq*1], xm0 mova [dstq+strideq*2], xm0 mova [dstq+stride3q ], xm0 lea dstq, [dstq+strideq*4] sub hd, 4 jg .s16 RET ALIGN function_align .h32: mova m0, [tlq-32] pmaddubsw m0, m3 jmp wq .w32: movu m1, [tlq+1] pmaddubsw m1, m3 paddw m0, m1 vextracti128 xm1, m0, 1 psubw xm0, xm4 paddw xm0, xm1 punpckhqdq xm1, xm0, xm0 paddw xm0, xm1 psrlq xm1, xm0, 32 paddw xm0, xm1 pmaddwd xm0, xm3 psrlw xm0, xm5 cmp hd, 32 je .w32_end lea r2d, [hq*2] mov r6d, 0x33345556 shrx r6d, r6d, r2d movd xm1, r6d pmulhuw xm0, xm1 .w32_end: vpbroadcastb m0, xm0 .s32: mova [dstq+strideq*0], m0 mova [dstq+strideq*1], m0 mova [dstq+strideq*2], m0 mova [dstq+stride3q ], m0 lea dstq, [dstq+strideq*4] sub hd, 4 jg .s32 RET ALIGN function_align .h64: mova m0, [tlq-64] mova m1, [tlq-32] pmaddubsw m0, m3 pmaddubsw m1, m3 paddw m0, m1 jmp wq .w64: movu m1, [tlq+ 1] movu m2, [tlq+33] pmaddubsw m1, m3 pmaddubsw m2, m3 paddw m0, m1 paddw m0, m2 vextracti128 xm1, m0, 1 psubw xm0, xm4 paddw xm0, xm1 punpckhqdq xm1, xm0, xm0 paddw xm0, xm1 psrlq xm1, xm0, 32 paddw xm0, xm1 pmaddwd xm0, xm3 psrlw xm0, xm5 cmp hd, 64 je .w64_end mov r6d, 0x33345556 shrx r6d, r6d, hd movd xm1, r6d pmulhuw xm0, xm1 .w64_end: vpbroadcastb m0, xm0 mova m1, m0 .s64: mova [dstq+strideq*0+32*0], m0 mova [dstq+strideq*0+32*1], m1 mova [dstq+strideq*1+32*0], m0 mova [dstq+strideq*1+32*1], m1 mova [dstq+strideq*2+32*0], m0 mova [dstq+strideq*2+32*1], m1 mova [dstq+stride3q +32*0], m0 mova [dstq+stride3q +32*1], m1 lea dstq, [dstq+strideq*4] sub hd, 4 jg .s64 RET cglobal ipred_dc_128, 2, 7, 6, dst, stride, tl, w, h, stride3 lea r5, [ipred_dc_splat_avx2_table] tzcnt wd, wm movifnidn hd, hm movsxd wq, [r5+wq*4] vpbroadcastd m0, [r5-ipred_dc_splat_avx2_table+pb_128] mova m1, m0 add wq, r5 lea stride3q, [strideq*3] jmp wq cglobal ipred_v, 3, 7, 6, dst, stride, tl, w, h, stride3 lea r5, [ipred_dc_splat_avx2_table] tzcnt wd, wm movu m0, [tlq+ 1] movu m1, [tlq+33] movifnidn hd, hm movsxd wq, [r5+wq*4] add wq, r5 lea stride3q, [strideq*3] jmp wq %macro IPRED_H 2 ; w, store_type vpbroadcastb m0, [tlq-1] vpbroadcastb m1, [tlq-2] vpbroadcastb m2, [tlq-3] sub tlq, 4 vpbroadcastb m3, [tlq+0] mov%2 [dstq+strideq*0], m0 mov%2 [dstq+strideq*1], m1 mov%2 [dstq+strideq*2], m2 mov%2 [dstq+stride3q ], m3 lea dstq, [dstq+strideq*4] sub hd, 4 jg .w%1 RET ALIGN function_align %endmacro INIT_XMM avx2 cglobal ipred_h, 3, 6, 4, dst, stride, tl, w, h, stride3 lea r5, [ipred_h_avx2_table] tzcnt wd, wm movifnidn hd, hm movsxd wq, [r5+wq*4] add wq, r5 lea stride3q, [strideq*3] jmp wq .w4: IPRED_H 4, d .w8: IPRED_H 8, q .w16: IPRED_H 16, a INIT_YMM avx2 .w32: IPRED_H 32, a .w64: vpbroadcastb m0, [tlq-1] vpbroadcastb m1, [tlq-2] vpbroadcastb m2, [tlq-3] sub tlq, 4 vpbroadcastb m3, [tlq+0] mova [dstq+strideq*0+32*0], m0 mova [dstq+strideq*0+32*1], m0 mova [dstq+strideq*1+32*0], m1 mova [dstq+strideq*1+32*1], m1 mova [dstq+strideq*2+32*0], m2 mova [dstq+strideq*2+32*1], m2 mova [dstq+stride3q +32*0], m3 mova [dstq+stride3q +32*1], m3 lea dstq, [dstq+strideq*4] sub hd, 4 jg .w64 RET %macro PAETH 2 ; top, ldiff pavgb m1, m%1, m3 ; Calculating tldiff normally requires pxor m0, m%1, m3 ; 10-bit intermediates, but we can do it pand m0, m4 ; in 8-bit with some tricks which avoids psubusb m2, m5, m1 ; having to unpack everything to 16-bit. psubb m1, m0 psubusb m1, m5 por m1, m2 paddusb m1, m1 por m1, m0 ; min(tldiff, 255) psubusb m2, m5, m3 psubusb m0, m3, m5 por m2, m0 ; tdiff pminub m2, m%2 pcmpeqb m0, m%2, m2 ; ldiff <= tdiff vpblendvb m0, m%1, m3, m0 pminub m1, m2 pcmpeqb m1, m2 ; ldiff <= tldiff || tdiff <= tldiff vpblendvb m0, m5, m0, m1 %endmacro cglobal ipred_paeth, 3, 6, 9, dst, stride, tl, w, h %define base r5-ipred_paeth_avx2_table lea r5, [ipred_paeth_avx2_table] tzcnt wd, wm vpbroadcastb m5, [tlq] ; topleft movifnidn hd, hm movsxd wq, [r5+wq*4] vpbroadcastd m4, [base+pb_1] add wq, r5 jmp wq .w4: vpbroadcastd m6, [tlq+1] ; top mova m8, [base+ipred_h_shuf] lea r3, [strideq*3] psubusb m7, m5, m6 psubusb m0, m6, m5 por m7, m0 ; ldiff .w4_loop: sub tlq, 8 vpbroadcastq m3, [tlq] pshufb m3, m8 ; left PAETH 6, 7 vextracti128 xm1, m0, 1 movd [dstq+strideq*0], xm0 movd [dstq+strideq*1], xm1 pextrd [dstq+strideq*2], xm0, 2 pextrd [dstq+r3 ], xm1, 2 cmp hd, 4 je .ret lea dstq, [dstq+strideq*4] pextrd [dstq+strideq*0], xm0, 1 pextrd [dstq+strideq*1], xm1, 1 pextrd [dstq+strideq*2], xm0, 3 pextrd [dstq+r3 ], xm1, 3 lea dstq, [dstq+strideq*4] sub hd, 8 jg .w4_loop .ret: RET ALIGN function_align .w8: vpbroadcastq m6, [tlq+1] mova m8, [base+ipred_h_shuf] lea r3, [strideq*3] psubusb m7, m5, m6 psubusb m0, m6, m5 por m7, m0 .w8_loop: sub tlq, 4 vpbroadcastd m3, [tlq] pshufb m3, m8 PAETH 6, 7 vextracti128 xm1, m0, 1 movq [dstq+strideq*0], xm0 movq [dstq+strideq*1], xm1 movhps [dstq+strideq*2], xm0 movhps [dstq+r3 ], xm1 lea dstq, [dstq+strideq*4] sub hd, 4 jg .w8_loop RET ALIGN function_align .w16: vbroadcasti128 m6, [tlq+1] mova xm8, xm4 ; lower half = 1, upper half = 0 psubusb m7, m5, m6 psubusb m0, m6, m5 por m7, m0 .w16_loop: sub tlq, 2 vpbroadcastd m3, [tlq] pshufb m3, m8 PAETH 6, 7 mova [dstq+strideq*0], xm0 vextracti128 [dstq+strideq*1], m0, 1 lea dstq, [dstq+strideq*2] sub hd, 2 jg .w16_loop RET ALIGN function_align .w32: movu m6, [tlq+1] psubusb m7, m5, m6 psubusb m0, m6, m5 por m7, m0 .w32_loop: dec tlq vpbroadcastb m3, [tlq] PAETH 6, 7 mova [dstq], m0 add dstq, strideq dec hd jg .w32_loop RET ALIGN function_align .w64: movu m6, [tlq+ 1] movu m7, [tlq+33] %if WIN64 movaps r4m, xmm9 %endif psubusb m8, m5, m6 psubusb m0, m6, m5 psubusb m9, m5, m7 psubusb m1, m7, m5 por m8, m0 por m9, m1 .w64_loop: dec tlq vpbroadcastb m3, [tlq] PAETH 6, 8 mova [dstq+32*0], m0 PAETH 7, 9 mova [dstq+32*1], m0 add dstq, strideq dec hd jg .w64_loop %if WIN64 movaps xmm9, r4m %endif RET %macro SMOOTH 6 ; src[1-2], mul[1-2], add[1-2] ; w * a = (w - 128) * a + 128 * a ; (256 - w) * b = (127 - w) * b + 129 * b pmaddubsw m0, m%3, m%1 pmaddubsw m1, m%4, m%2 paddw m0, m%5 paddw m1, m%6 psrlw m0, 8 psrlw m1, 8 packuswb m0, m1 %endmacro cglobal ipred_smooth_v, 3, 7, 0, dst, stride, tl, w, h, weights %define base r6-ipred_smooth_v_avx2_table lea r6, [ipred_smooth_v_avx2_table] tzcnt wd, wm mov hd, hm movsxd wq, [r6+wq*4] vpbroadcastd m0, [base+pb_127_m127] vpbroadcastd m1, [base+pw_128] lea weightsq, [base+smooth_weights+hq*4] neg hq vpbroadcastb m5, [tlq+hq] ; bottom add wq, r6 jmp wq .w4: vpbroadcastd m2, [tlq+1] punpcklbw m2, m5 ; top, bottom mova m5, [base+ipred_v_shuf] lea r3, [strideq*3] punpckldq m4, m5, m5 punpckhdq m5, m5 pmaddubsw m3, m2, m0 paddw m1, m2 ; 1 * top + 256 * bottom + 128, overflow is ok paddw m3, m1 ; 128 * top + 129 * bottom + 128 .w4_loop: vbroadcasti128 m1, [weightsq+hq*2] pshufb m0, m1, m4 pshufb m1, m5 SMOOTH 0, 1, 2, 2, 3, 3 vextracti128 xm1, m0, 1 movd [dstq+strideq*0], xm0 movd [dstq+strideq*1], xm1 pextrd [dstq+strideq*2], xm0, 1 pextrd [dstq+r3 ], xm1, 1 cmp hd, -4 je .ret lea dstq, [dstq+strideq*4] pextrd [dstq+strideq*0], xm0, 2 pextrd [dstq+strideq*1], xm1, 2 pextrd [dstq+strideq*2], xm0, 3 pextrd [dstq+r3 ], xm1, 3 lea dstq, [dstq+strideq*4] add hq, 8 jl .w4_loop .ret: RET ALIGN function_align .w8: vpbroadcastq m2, [tlq+1] punpcklbw m2, m5 mova m5, [base+ipred_v_shuf] lea r3, [strideq*3] pshufd m4, m5, q0000 pshufd m5, m5, q1111 pmaddubsw m3, m2, m0 paddw m1, m2 paddw m3, m1 .w8_loop: vpbroadcastq m1, [weightsq+hq*2] pshufb m0, m1, m4 pshufb m1, m5 SMOOTH 0, 1, 2, 2, 3, 3 vextracti128 xm1, m0, 1 movq [dstq+strideq*0], xm0 movq [dstq+strideq*1], xm1 movhps [dstq+strideq*2], xm0 movhps [dstq+r3 ], xm1 lea dstq, [dstq+strideq*4] add hq, 4 jl .w8_loop RET ALIGN function_align .w16: WIN64_SPILL_XMM 7 vbroadcasti128 m3, [tlq+1] mova m6, [base+ipred_v_shuf] punpcklbw m2, m3, m5 punpckhbw m3, m5 pmaddubsw m4, m2, m0 pmaddubsw m5, m3, m0 paddw m0, m1, m2 paddw m1, m3 paddw m4, m0 paddw m5, m1 .w16_loop: vpbroadcastd m1, [weightsq+hq*2] pshufb m1, m6 SMOOTH 1, 1, 2, 3, 4, 5 mova [dstq+strideq*0], xm0 vextracti128 [dstq+strideq*1], m0, 1 lea dstq, [dstq+strideq*2] add hq, 2 jl .w16_loop RET ALIGN function_align .w32: %assign stack_offset stack_offset - stack_size_padded WIN64_SPILL_XMM 6 movu m3, [tlq+1] punpcklbw m2, m3, m5 punpckhbw m3, m5 pmaddubsw m4, m2, m0 pmaddubsw m5, m3, m0 paddw m0, m1, m2 paddw m1, m3 paddw m4, m0 paddw m5, m1 .w32_loop: vpbroadcastw m1, [weightsq+hq*2] SMOOTH 1, 1, 2, 3, 4, 5 mova [dstq], m0 add dstq, strideq inc hq jl .w32_loop RET ALIGN function_align .w64: WIN64_SPILL_XMM 11 movu m4, [tlq+ 1] movu m8, [tlq+33] punpcklbw m3, m4, m5 punpckhbw m4, m5 punpcklbw m7, m8, m5 punpckhbw m8, m5 pmaddubsw m5, m3, m0 pmaddubsw m6, m4, m0 pmaddubsw m9, m7, m0 pmaddubsw m10, m8, m0 paddw m2, m1, m3 paddw m5, m2 paddw m2, m1, m4 paddw m6, m2 paddw m0, m1, m7 paddw m9, m0 paddw m1, m8 paddw m10, m1 .w64_loop: vpbroadcastw m2, [weightsq+hq*2] SMOOTH 2, 2, 3, 4, 5, 6 mova [dstq+32*0], m0 SMOOTH 2, 2, 7, 8, 9, 10 mova [dstq+32*1], m0 add dstq, strideq inc hq jl .w64_loop RET %macro SETUP_STACK_FRAME 3 ; stack_size, regs_used, xmm_regs_used %assign stack_offset 0 %assign stack_size_padded 0 %assign regs_used %2 %xdefine rstk rsp SETUP_STACK_POINTER %1 %if regs_used != %2 && WIN64 PUSH r%2 %endif ALLOC_STACK %1, %3 %endmacro cglobal ipred_smooth_h, 3, 7, 0, dst, stride, tl, w, h %define base r6-ipred_smooth_h_avx2_table lea r6, [ipred_smooth_h_avx2_table] mov wd, wm vpbroadcastb m3, [tlq+wq] ; right tzcnt wd, wd mov hd, hm movsxd wq, [r6+wq*4] vpbroadcastd m4, [base+pb_127_m127] vpbroadcastd m5, [base+pw_128] add wq, r6 jmp wq .w4: WIN64_SPILL_XMM 8 vpbroadcastq m6, [base+smooth_weights+4*2] mova m7, [base+ipred_h_shuf] sub tlq, 8 sub tlq, hq lea r3, [strideq*3] .w4_loop: vpbroadcastq m2, [tlq+hq] pshufb m2, m7 punpcklbw m1, m2, m3 ; left, right punpckhbw m2, m3 pmaddubsw m0, m1, m4 ; 127 * left - 127 * right paddw m0, m1 ; 128 * left + 129 * right pmaddubsw m1, m6 paddw m1, m5 paddw m0, m1 pmaddubsw m1, m2, m4 paddw m1, m2 pmaddubsw m2, m6 paddw m2, m5 paddw m1, m2 psrlw m0, 8 psrlw m1, 8 packuswb m0, m1 vextracti128 xm1, m0, 1 movd [dstq+strideq*0], xm0 movd [dstq+strideq*1], xm1 pextrd [dstq+strideq*2], xm0, 2 pextrd [dstq+r3 ], xm1, 2 cmp hd, 4 je .ret lea dstq, [dstq+strideq*4] pextrd [dstq+strideq*0], xm0, 1 pextrd [dstq+strideq*1], xm1, 1 pextrd [dstq+strideq*2], xm0, 3 pextrd [dstq+r3 ], xm1, 3 lea dstq, [dstq+strideq*4] sub hd, 8 jg .w4_loop .ret: RET ALIGN function_align .w8: %assign stack_offset stack_offset - stack_size_padded WIN64_SPILL_XMM 8 vbroadcasti128 m6, [base+smooth_weights+8*2] mova m7, [base+ipred_h_shuf] sub tlq, 4 lea r3, [strideq*3] sub tlq, hq .w8_loop: vpbroadcastd m2, [tlq+hq] pshufb m2, m7 punpcklbw m1, m2, m3 punpckhbw m2, m3 pmaddubsw m0, m1, m4 paddw m0, m1 pmaddubsw m1, m6 paddw m1, m5 paddw m0, m1 pmaddubsw m1, m2, m4 paddw m1, m2 pmaddubsw m2, m6 paddw m2, m5 paddw m1, m2 psrlw m0, 8 psrlw m1, 8 packuswb m0, m1 vextracti128 xm1, m0, 1 movq [dstq+strideq*0], xm0 movq [dstq+strideq*1], xm1 movhps [dstq+strideq*2], xm0 movhps [dstq+r3 ], xm1 lea dstq, [dstq+strideq*4] sub hd, 4 jg .w8_loop RET ALIGN function_align .w16: SETUP_STACK_FRAME 32*4, 7, 8 lea r3, [rsp+64*2-4] call .prep ; only worthwhile for for w16 and above sub tlq, 2 vpbroadcastd xm6, [base+pb_1] mova xm7, [base+ipred_v_shuf+16] vinserti128 m7, [base+ipred_v_shuf+ 0], 1 vbroadcasti128 m4, [base+smooth_weights+16*2] vbroadcasti128 m5, [base+smooth_weights+16*3] .w16_loop: vpbroadcastd m1, [tlq+hq] vpbroadcastd m2, [r3+hq*2] pshufb m1, m6 punpcklbw m1, m3 pshufb m2, m7 SMOOTH 4, 5, 1, 1, 2, 2 mova [dstq+strideq*0], xm0 vextracti128 [dstq+strideq*1], m0, 1 lea dstq, [dstq+strideq*2] sub hd, 2 jg .w16_loop RET ALIGN function_align .w32: SETUP_STACK_FRAME 32*4, 7, 6 lea r3, [rsp+64*2-2] call .prep dec tlq mova xm4, [base+smooth_weights+16*4] vinserti128 m4, [base+smooth_weights+16*6], 1 mova xm5, [base+smooth_weights+16*5] vinserti128 m5, [base+smooth_weights+16*7], 1 .w32_loop: vpbroadcastb m1, [tlq+hq] punpcklbw m1, m3 vpbroadcastw m2, [r3+hq*2] SMOOTH 4, 5, 1, 1, 2, 2 mova [dstq], m0 add dstq, strideq dec hd jg .w32_loop RET ALIGN function_align .w64: SETUP_STACK_FRAME 32*4, 7, 9 lea r3, [rsp+64*2-2] call .prep add r6, smooth_weights+16*15-ipred_smooth_h_avx2_table dec tlq mova xm5, [r6-16*7] vinserti128 m5, [r6-16*5], 1 mova xm6, [r6-16*6] vinserti128 m6, [r6-16*4], 1 mova xm7, [r6-16*3] vinserti128 m7, [r6-16*1], 1 mova xm8, [r6-16*2] vinserti128 m8, [r6-16*0], 1 .w64_loop: vpbroadcastb m2, [tlq+hq] punpcklbw m2, m3 vpbroadcastw m4, [r3+hq*2] SMOOTH 5, 6, 2, 2, 4, 4 mova [dstq+32*0], m0 SMOOTH 7, 8, 2, 2, 4, 4 mova [dstq+32*1], m0 add dstq, strideq dec hd jg .w64_loop RET ALIGN function_align .prep: vpermq m2, [tlq-32*1], q3120 punpckhbw m1, m2, m3 punpcklbw m2, m3 pmaddubsw m0, m1, m4 ; 127 * left - 127 * right paddw m1, m5 ; 1 * left + 256 * right + 128 paddw m0, m1 ; 128 * left + 129 * right + 128 pmaddubsw m1, m2, m4 paddw m2, m5 paddw m1, m2 vpermq m2, [tlq-32*2], q3120 mova [rsp+gprsize+32*3], m0 mova [rsp+gprsize+32*2], m1 punpckhbw m1, m2, m3 punpcklbw m2, m3 pmaddubsw m0, m1, m4 paddw m1, m5 paddw m0, m1 pmaddubsw m1, m2, m4 paddw m2, m5 paddw m1, m2 mova [rsp+gprsize+32*1], m0 mova [rsp+gprsize+32*0], m1 sub r3, hq sub tlq, hq sub r3, hq ret %macro SMOOTH_2D_END 6 ; src[1-2], mul[1-2], add[1-2] pmaddubsw m0, m%3, m%1 pmaddubsw m1, m%4, m%2 %ifnum %5 paddw m0, m%5 %else paddw m0, %5 %endif %ifnum %6 paddw m1, m%6 %else paddw m1, %6 %endif pavgw m0, m2 pavgw m1, m3 psrlw m0, 8 psrlw m1, 8 packuswb m0, m1 %endmacro cglobal ipred_smooth, 3, 7, 0, dst, stride, tl, w, h, v_weights %define base r6-ipred_smooth_avx2_table lea r6, [ipred_smooth_avx2_table] mov wd, wm vpbroadcastb m4, [tlq+wq] ; right tzcnt wd, wd mov hd, hm mov r5, tlq sub r5, hq movsxd wq, [r6+wq*4] vpbroadcastd m5, [base+pb_127_m127] vpbroadcastb m0, [r5] ; bottom vpbroadcastd m3, [base+pw_255] add wq, r6 lea v_weightsq, [base+smooth_weights+hq*2] jmp wq .w4: WIN64_SPILL_XMM 12 mova m10, [base+ipred_h_shuf] vpbroadcastq m11, [base+smooth_weights+4*2] mova m7, [base+ipred_v_shuf] vpbroadcastd m8, [tlq+1] sub tlq, 8 lea r3, [strideq*3] sub tlq, hq punpcklbw m8, m0 ; top, bottom pshufd m6, m7, q2200 pshufd m7, m7, q3311 pmaddubsw m9, m8, m5 paddw m3, m8 ; 1 * top + 255 * bottom + 255 paddw m9, m3 ; 128 * top + 129 * bottom + 255 .w4_loop: vpbroadcastq m1, [tlq+hq] pshufb m1, m10 punpcklbw m0, m1, m4 ; left, right punpckhbw m1, m4 pmaddubsw m2, m0, m5 ; 127 * left - 127 * right pmaddubsw m3, m1, m5 paddw m2, m0 ; 128 * left + 129 * right paddw m3, m1 pmaddubsw m0, m11 pmaddubsw m1, m11 paddw m2, m0 paddw m3, m1 vbroadcasti128 m1, [v_weightsq] add v_weightsq, 16 pshufb m0, m1, m6 pshufb m1, m7 SMOOTH_2D_END 0, 1, 8, 8, 9, 9 vextracti128 xm1, m0, 1 movd [dstq+strideq*0], xm0 movd [dstq+strideq*1], xm1 pextrd [dstq+strideq*2], xm0, 2 pextrd [dstq+r3 ], xm1, 2 cmp hd, 4 je .ret lea dstq, [dstq+strideq*4] pextrd [dstq+strideq*0], xm0, 1 pextrd [dstq+strideq*1], xm1, 1 pextrd [dstq+strideq*2], xm0, 3 pextrd [dstq+r3 ], xm1, 3 lea dstq, [dstq+strideq*4] sub hd, 8 jg .w4_loop .ret: RET ALIGN function_align .w8: %assign stack_offset stack_offset - stack_size_padded WIN64_SPILL_XMM 12 mova m10, [base+ipred_h_shuf] vbroadcasti128 m11, [base+smooth_weights+8*2] mova m7, [base+ipred_v_shuf] vpbroadcastq m8, [tlq+1] sub tlq, 4 lea r3, [strideq*3] sub tlq, hq punpcklbw m8, m0 pshufd m6, m7, q0000 pshufd m7, m7, q1111 pmaddubsw m9, m8, m5 paddw m3, m8 paddw m9, m3 .w8_loop: vpbroadcastd m1, [tlq+hq] pshufb m1, m10 punpcklbw m0, m1, m4 punpckhbw m1, m4 pmaddubsw m2, m0, m5 pmaddubsw m3, m1, m5 paddw m2, m0 paddw m3, m1 pmaddubsw m0, m11 pmaddubsw m1, m11 paddw m2, m0 paddw m3, m1 vpbroadcastq m1, [v_weightsq] add v_weightsq, 8 pshufb m0, m1, m6 pshufb m1, m7 SMOOTH_2D_END 0, 1, 8, 8, 9, 9 vextracti128 xm1, m0, 1 movq [dstq+strideq*0], xm0 movq [dstq+strideq*1], xm1 movhps [dstq+strideq*2], xm0 movhps [dstq+r3 ], xm1 lea dstq, [dstq+strideq*4] sub hd, 4 jg .w8_loop RET ALIGN function_align .w16: SETUP_STACK_FRAME 32*4, 7, 14 vbroadcasti128 m11, [tlq+1] lea r3, [rsp+64*2-4] punpcklbw m10, m11, m0 ; top, bottom punpckhbw m11, m0 call .prep_v sub tlq, 2 pmaddubsw m12, m10, m5 pmaddubsw m13, m11, m5 vpbroadcastd xm5, [base+pb_1] mova m9, [base+ipred_v_shuf] vbroadcasti128 m6, [base+smooth_weights+16*2] vbroadcasti128 m7, [base+smooth_weights+16*3] vpermq m8, m9, q1032 paddw m0, m10, m3 paddw m3, m11 paddw m12, m0 paddw m13, m3 .w16_loop: vpbroadcastd m3, [tlq+hq] vpbroadcastd m0, [r3+hq*2] vpbroadcastd m1, [v_weightsq] add v_weightsq, 4 pshufb m3, m5 punpcklbw m3, m4 ; left, right pmaddubsw m2, m3, m6 pmaddubsw m3, m7 pshufb m0, m8 pshufb m1, m9 paddw m2, m0 paddw m3, m0 SMOOTH_2D_END 1, 1, 10, 11, 12, 13 mova [dstq+strideq*0], xm0 vextracti128 [dstq+strideq*1], m0, 1 lea dstq, [dstq+strideq*2] sub hd, 2 jg .w16_loop RET ALIGN function_align .w32: SETUP_STACK_FRAME 32*4, 7, 11 movu m8, [tlq+1] lea r3, [rsp+64*2-2] punpcklbw m7, m8, m0 punpckhbw m8, m0 call .prep_v dec tlq pmaddubsw m9, m7, m5 pmaddubsw m10, m8, m5 mova xm5, [base+smooth_weights+16*4] vinserti128 m5, [base+smooth_weights+16*6], 1 mova xm6, [base+smooth_weights+16*5] vinserti128 m6, [base+smooth_weights+16*7], 1 paddw m0, m7, m3 paddw m3, m8 paddw m9, m0 paddw m10, m3 .w32_loop: vpbroadcastb m3, [tlq+hq] punpcklbw m3, m4 vpbroadcastw m0, [r3+hq*2] vpbroadcastw m1, [v_weightsq] add v_weightsq, 2 pmaddubsw m2, m3, m5 pmaddubsw m3, m6 paddw m2, m0 paddw m3, m0 SMOOTH_2D_END 1, 1, 7, 8, 9, 10 mova [dstq], m0 add dstq, strideq dec hd jg .w32_loop RET ALIGN function_align .w64: SETUP_STACK_FRAME 32*8, 7, 16 movu m13, [tlq+1 ] movu m15, [tlq+33] add r6, smooth_weights+16*15-ipred_smooth_avx2_table lea r3, [rsp+64*2-2] punpcklbw m12, m13, m0 punpckhbw m13, m0 punpcklbw m14, m15, m0 punpckhbw m15, m0 call .prep_v dec tlq pmaddubsw m0, m12, m5 pmaddubsw m1, m13, m5 pmaddubsw m2, m14, m5 pmaddubsw m5, m15, m5 mova xm8, [r6-16*7] vinserti128 m8, [r6-16*5], 1 mova xm9, [r6-16*6] vinserti128 m9, [r6-16*4], 1 mova xm10, [r6-16*3] vinserti128 m10, [r6-16*1], 1 mova xm11, [r6-16*2] vinserti128 m11, [r6-16*0], 1 lea r6, [rsp+32*4] paddw m0, m3 paddw m1, m3 paddw m2, m3 paddw m3, m5 paddw m0, m12 paddw m1, m13 paddw m2, m14 paddw m3, m15 mova [r6+32*0], m0 mova [r6+32*1], m1 mova [r6+32*2], m2 mova [r6+32*3], m3 .w64_loop: vpbroadcastb m5, [tlq+hq] punpcklbw m5, m4 vpbroadcastw m6, [r3+hq*2] vpbroadcastw m7, [v_weightsq] add v_weightsq, 2 pmaddubsw m2, m5, m8 pmaddubsw m3, m5, m9 paddw m2, m6 paddw m3, m6 SMOOTH_2D_END 7, 7, 12, 13, [r6+32*0], [r6+32*1] mova [dstq+32*0], m0 pmaddubsw m2, m5, m10 pmaddubsw m3, m5, m11 paddw m2, m6 paddw m3, m6 SMOOTH_2D_END 7, 7, 14, 15, [r6+32*2], [r6+32*3] mova [dstq+32*1], m0 add dstq, strideq dec hd jg .w64_loop RET ALIGN function_align .prep_v: vpermq m2, [tlq-32*1], q3120 punpckhbw m1, m2, m4 punpcklbw m2, m4 pmaddubsw m0, m1, m5 ; 127 * left - 127 * right paddw m0, m1 ; 128 * left + 129 * right pmaddubsw m1, m2, m5 paddw m1, m2 vpermq m2, [tlq-32*2], q3120 mova [rsp+gprsize+32*3], m0 mova [rsp+gprsize+32*2], m1 punpckhbw m1, m2, m4 punpcklbw m2, m4 pmaddubsw m0, m1, m5 paddw m0, m1 pmaddubsw m1, m2, m5 paddw m1, m2 mova [rsp+gprsize+32*1], m0 mova [rsp+gprsize+32*0], m1 sub r3, hq sub tlq, hq sub r3, hq ret cglobal ipred_z1, 3, 8, 0, dst, stride, tl, w, h, angle, dx, maxbase %assign org_stack_offset stack_offset lea r6, [ipred_z1_avx2_table] tzcnt wd, wm movifnidn angled, anglem movifnidn hd, hm lea r7, [dr_intra_derivative] inc tlq movsxd wq, [r6+wq*4] add wq, r6 mov dxd, angled and dxd, 0x7e add angled, 165 ; ~90 movzx dxd, word [r7+dxq] xor angled, 0x4ff ; d = 90 - angle vpbroadcastd m3, [pw_512] vpbroadcastd m4, [pw_62] vpbroadcastd m5, [pw_64] jmp wq .w4: cmp angleb, 40 jae .w4_no_upsample lea r3d, [angleq-1024] sar r3d, 7 add r3d, hd jg .w4_no_upsample ; !enable_intra_edge_filter || h > 8 || (h == 8 && is_sm) ALLOC_STACK -32, 8 mova xm1, [tlq-1] pshufb xm0, xm1, [z_upsample1] pshufb xm1, [z_upsample2] vpbroadcastd xm2, [pb_36_m4] ; upshifted by 2 to be able to reuse add dxd, dxd ; pw_512 (which is already in m3) pmaddubsw xm0, xm2 ; for rounding instead of pw_2048 pextrd [rsp+16], xm1, 3 ; top[max_base_x] pmaddubsw xm1, xm2 movd xm7, dxd mov r3d, dxd ; xpos vpbroadcastw m7, xm7 paddw xm1, xm0 movq xm0, [tlq] pmulhrsw xm1, xm3 pslldq m6, m7, 8 paddw xm2, xm7, xm7 lea r2, [strideq*3] paddw m6, m7 packuswb xm1, xm1 paddw m6, m2 ; xpos2 xpos3 xpos0 xpos1 punpcklbw xm0, xm1 psllw m7, 2 mova [rsp], xm0 .w4_upsample_loop: lea r5d, [r3+dxq] shr r3d, 6 ; base0 vpbroadcastq m1, [rsp+r3] lea r3d, [r5+dxq] shr r5d, 6 ; base1 vpbroadcastq m2, [rsp+r5] lea r5d, [r3+dxq] shr r3d, 6 ; base2 movq xm0, [rsp+r3] lea r3d, [r5+dxq] shr r5d, 6 ; base3 movhps xm0, [rsp+r5] vpblendd m1, m2, 0xc0 pand m2, m4, m6 ; frac vpblendd m0, m1, 0xf0 psubw m1, m5, m2 ; 64-frac psllw m2, 8 por m1, m2 ; 64-frac, frac pmaddubsw m0, m1 paddw m6, m7 ; xpos += dx pmulhrsw m0, m3 packuswb m0, m0 vextracti128 xm1, m0, 1 movd [dstq+strideq*2], xm0 pextrd [dstq+r2 ], xm0, 1 movd [dstq+strideq*0], xm1 pextrd [dstq+strideq*1], xm1, 1 lea dstq, [dstq+strideq*4] sub hd, 4 jg .w4_upsample_loop RET ALIGN function_align .filter_strength: ; w4/w8/w16 ; The C version uses a lot of branches, but we can do all the comparisons ; in parallel and use popcnt to get the final filter strength value. %define base r3-z_filter_t0 lea r3, [z_filter_t0] movd xm0, maxbased movd xm2, angled shr angled, 8 ; is_sm << 1 vpbroadcastb m0, xm0 vpbroadcastb m2, xm2 pcmpeqb m1, m0, [base+z_filter_wh] pand m1, m2 mova xm2, [r3+angleq*8] ; upper ymm half zero in both cases pcmpgtb m1, m2 pmovmskb r5d, m1 popcnt r5d, r5d ; sets ZF which can be used by caller ret .w4_no_upsample: %assign stack_offset org_stack_offset ALLOC_STACK -16, 11 mov maxbased, 7 test angled, 0x400 ; !enable_intra_edge_filter jnz .w4_main lea maxbased, [hq+3] call .filter_strength mov maxbased, 7 jz .w4_main ; filter_strength == 0 vpbroadcastd m7, [base+pb_8] vbroadcasti128 m2, [tlq-1] pminub m1, m7, [base+z_filter_s] vpbroadcastd m8, [base+z_filter_k-4+r5*4+12*0] pminub m7, [base+z_filter_s+8] vpbroadcastd m9, [base+z_filter_k-4+r5*4+12*1] vpbroadcastd m10, [base+z_filter_k-4+r5*4+12*2] pshufb m0, m2, m1 shufps m1, m7, q2121 pmaddubsw m0, m8 pshufb m1, m2, m1 pmaddubsw m1, m9 pshufb m2, m7 pmaddubsw m2, m10 paddw m0, m1 paddw m0, m2 pmulhrsw m0, m3 mov r3d, 9 mov tlq, rsp cmp hd, 4 cmovne maxbased, r3d vextracti128 xm1, m0, 1 packuswb xm0, xm1 mova [tlq], xm0 .w4_main: movd xm6, dxd vpbroadcastq m0, [z_base_inc] ; base_inc << 6 vpbroadcastb m7, [tlq+maxbaseq] shl maxbased, 6 vpbroadcastw m6, xm6 mov r3d, dxd ; xpos movd xm9, maxbased vpbroadcastw m9, xm9 vbroadcasti128 m8, [z1_shuf_w4] psrlw m7, 8 ; top[max_base_x] paddw m10, m6, m6 psubw m9, m0 ; max_base_x vpblendd m6, m10, 0xcc mova xm0, xm10 paddw m6, m0 ; xpos2 xpos3 xpos0 xpos1 paddw m10, m10 .w4_loop: lea r5d, [r3+dxq] shr r3d, 6 ; base0 vpbroadcastq m1, [tlq+r3] lea r3d, [r5+dxq] shr r5d, 6 ; base1 vpbroadcastq m2, [tlq+r5] lea r5d, [r3+dxq] shr r3d, 6 ; base2 movq xm0, [tlq+r3] lea r3d, [r5+dxq] shr r5d, 6 ; base3 movhps xm0, [tlq+r5] vpblendd m1, m2, 0xc0 pand m2, m4, m6 ; frac vpblendd m0, m1, 0xf0 psubw m1, m5, m2 ; 64-frac psllw m2, 8 pshufb m0, m8 por m1, m2 ; 64-frac, frac pmaddubsw m0, m1 pcmpgtw m1, m9, m6 ; base < max_base_x pmulhrsw m0, m3 paddw m6, m10 ; xpos += dx lea r5, [dstq+strideq*2] vpblendvb m0, m7, m0, m1 packuswb m0, m0 vextracti128 xm1, m0, 1 movd [r5 +strideq*0], xm0 pextrd [r5 +strideq*1], xm0, 1 movd [dstq+strideq*0], xm1 pextrd [dstq+strideq*1], xm1, 1 sub hd, 4 jz .w4_end lea dstq, [dstq+strideq*4] cmp r3d, maxbased jb .w4_loop packuswb xm7, xm7 lea r6, [strideq*3] .w4_end_loop: movd [dstq+strideq*0], xm7 movd [dstq+strideq*1], xm7 movd [dstq+strideq*2], xm7 movd [dstq+r6 ], xm7 lea dstq, [dstq+strideq*4] sub hd, 4 jg .w4_end_loop .w4_end: RET ALIGN function_align .w8: lea r3d, [angleq+216] mov r3b, hb cmp r3d, 8 ja .w8_no_upsample ; !enable_intra_edge_filter || is_sm || d >= 40 || h > 8 %assign stack_offset org_stack_offset ALLOC_STACK -32, 8 movu xm2, [z_filter_s+6] mova xm0, [tlq-1] movd xm6, hd vinserti128 m0, [tlq+7], 1 vpbroadcastb xm6, xm6 vbroadcasti128 m1, [z_upsample1] pminub xm6, xm2 vpbroadcastd m7, [pb_36_m4] vinserti128 m2, xm6, 1 add dxd, dxd pshufb m1, m0, m1 pshufb m2, m0, m2 movd xm6, dxd pmaddubsw m1, m7 pmaddubsw m2, m7 vpbroadcastw m6, xm6 mov r3d, dxd psrldq m0, 1 lea r2, [strideq*3] paddw m7, m6, m6 paddw m1, m2 vpblendd m6, m7, 0xf0 pmulhrsw m1, m3 pslldq m2, m7, 8 paddw m7, m7 paddw m6, m2 packuswb m1, m1 punpcklbw m0, m1 mova [rsp], m0 .w8_upsample_loop: lea r5d, [r3+dxq] shr r3d, 6 ; base0 movu xm0, [rsp+r3] lea r3d, [r5+dxq] shr r5d, 6 ; base1 vinserti128 m0, [rsp+r5], 1 lea r5d, [r3+dxq] shr r3d, 6 ; base2 pand m1, m4, m6 psubw m2, m5, m1 psllw m1, 8 por m2, m1 punpcklqdq m1, m2, m2 ; frac0 frac1 pmaddubsw m0, m1 movu xm1, [rsp+r3] lea r3d, [r5+dxq] shr r5d, 6 ; base3 vinserti128 m1, [rsp+r5], 1 punpckhqdq m2, m2 ; frac2 frac3 pmaddubsw m1, m2 pmulhrsw m0, m3 paddw m6, m7 pmulhrsw m1, m3 packuswb m0, m1 vextracti128 xm1, m0, 1 movq [dstq+strideq*0], xm0 movhps [dstq+strideq*2], xm0 movq [dstq+strideq*1], xm1 movhps [dstq+r2 ], xm1 lea dstq, [dstq+strideq*4] sub hd, 4 jg .w8_upsample_loop RET .w8_no_intra_edge_filter: and maxbased, 7 or maxbased, 8 ; imin(h+7, 15) jmp .w8_main .w8_no_upsample: %assign stack_offset org_stack_offset ALLOC_STACK -32, 10 lea maxbased, [hq+7] test angled, 0x400 jnz .w8_no_intra_edge_filter call .filter_strength jz .w8_main ; filter_strength == 0 movu xm2, [tlq] pminub xm1, xm0, [base+z_filter_s+14] vinserti128 m2, [tlq-1], 1 vinserti128 m1, [base+z_filter_s+ 0], 1 vpbroadcastd m7, [base+z_filter_k-4+r5*4+12*0] pminub xm0, [base+z_filter_s+22] vinserti128 m0, [base+z_filter_s+ 8], 1 pshufb m6, m2, m1 pmaddubsw m6, m7 vpbroadcastd m7, [base+z_filter_k-4+r5*4+12*1] movzx r3d, byte [tlq+15] shufps m1, m0, q2121 pshufb m1, m2, m1 pmaddubsw m1, m7 paddw m1, m6 sub r5d, 3 jnz .w8_3tap ; filter_strength == 3 uses a 5-tap filter instead of a 3-tap one, ; which also results in an awkward edge case where out[w*2] is ; slightly different from out[max_base_x] when h > w. vpbroadcastd m7, [z_filter_k+4*8] movzx r2d, byte [tlq+14] pshufb m2, m0 pmaddubsw m2, m7 sub r2d, r3d lea r2d, [r2+r3*8+4] shr r2d, 3 ; (tlq[w*2-2] + tlq[w*2-1]*7 + 4) >> 3 mov [rsp+16], r2b paddw m1, m2 .w8_3tap: pmulhrsw m1, m3 sar r5d, 1 mov tlq, rsp add r5d, 17 ; w*2 + (filter_strength == 3) cmp hd, 16 cmovns maxbased, r5d mov [tlq+r5], r3b vextracti128 xm0, m1, 1 packuswb xm0, xm1 mova [tlq], xm0 .w8_main: movd xm2, dxd vbroadcasti128 m0, [z_base_inc] vpbroadcastw m2, xm2 vpbroadcastb m7, [tlq+maxbaseq] shl maxbased, 6 movd xm9, maxbased vbroadcasti128 m8, [z_filter_s+2] vpbroadcastw m9, xm9 psrlw m7, 8 psubw m9, m0 mov r3d, dxd paddw m6, m2, m2 vpblendd m2, m6, 0xf0 .w8_loop: lea r5d, [r3+dxq] shr r3d, 6 pand m0, m4, m2 psubw m1, m5, m0 psllw m0, 8 por m1, m0 movu xm0, [tlq+r3] lea r3d, [r5+dxq] shr r5d, 6 ; base1 vinserti128 m0, [tlq+r5], 1 pshufb m0, m8 pmaddubsw m0, m1 pcmpgtw m1, m9, m2 paddw m2, m6 pmulhrsw m0, m3 vpblendvb m0, m7, m0, m1 vextracti128 xm1, m0, 1 packuswb xm0, xm1 movq [dstq+strideq*0], xm0 movhps [dstq+strideq*1], xm0 sub hd, 2 jz .w8_end lea dstq, [dstq+strideq*2] cmp r3d, maxbased jb .w8_loop packuswb xm7, xm7 .w8_end_loop: movq [dstq+strideq*0], xm7 movq [dstq+strideq*1], xm7 lea dstq, [dstq+strideq*2] sub hd, 2 jg .w8_end_loop .w8_end: RET .w16_no_intra_edge_filter: and maxbased, 15 or maxbased, 16 ; imin(h+15, 31) jmp .w16_main ALIGN function_align .w16: %assign stack_offset org_stack_offset ALLOC_STACK -64, 12 lea maxbased, [hq+15] test angled, 0x400 jnz .w16_no_intra_edge_filter call .filter_strength jz .w16_main ; filter_strength == 0 vpbroadcastd m1, [base+pb_12] vbroadcasti128 m6, [base+z_filter_s+8] vinserti128 m2, m6, [base+z_filter_s], 0 vinserti128 m6, [base+z_filter_s+16], 1 mova xm10, [tlq-1] vinserti128 m10, [tlq+3], 1 vpbroadcastd m9, [base+z_filter_k-4+r5*4+12*0] vbroadcasti128 m7, [base+z_filter_s+14] vinserti128 m8, m7, [base+z_filter_s+6], 0 vinserti128 m7, [base+z_filter_s+22], 1 psubw m0, m1 movu xm11, [tlq+12] vinserti128 m11, [tlq+16], 1 pminub m8, m0 pminub m7, m0 pshufb m0, m10, m2 shufps m2, m6, q2121 pmaddubsw m0, m9 pshufb m1, m11, m8 shufps m8, m7, q2121 pmaddubsw m1, m9 vpbroadcastd m9, [base+z_filter_k-4+r5*4+12*1] movzx r3d, byte [tlq+31] pshufb m2, m10, m2 pmaddubsw m2, m9 pshufb m8, m11, m8 pmaddubsw m8, m9 paddw m0, m2 paddw m1, m8 sub r5d, 3 jnz .w16_3tap vpbroadcastd m9, [z_filter_k+4*8] movzx r2d, byte [tlq+30] pshufb m10, m6 pmaddubsw m10, m9 pshufb m11, m7 pmaddubsw m11, m9 sub r2d, r3d lea r2d, [r2+r3*8+4] shr r2d, 3 mov [rsp+32], r2b paddw m0, m10 paddw m1, m11 .w16_3tap: pmulhrsw m0, m3 pmulhrsw m1, m3 sar r5d, 1 mov tlq, rsp add r5d, 33 cmp hd, 32 cmovns maxbased, r5d mov [tlq+r5], r3b packuswb m0, m1 vpermq m0, m0, q3120 mova [tlq], m0 .w16_main: movd xm6, dxd vbroadcasti128 m0, [z_base_inc] vpbroadcastb m7, [tlq+maxbaseq] shl maxbased, 6 vpbroadcastw m6, xm6 movd xm9, maxbased vbroadcasti128 m8, [z_filter_s+2] vpbroadcastw m9, xm9 mov r3d, dxd psubw m9, m0 paddw m11, m6, m6 psubw m10, m9, m3 ; 64*8 vpblendd m6, m11, 0xf0 .w16_loop: lea r5d, [r3+dxq] shr r3d, 6 ; base0 pand m1, m4, m6 psubw m2, m5, m1 psllw m1, 8 por m2, m1 movu xm0, [tlq+r3+0] movu xm1, [tlq+r3+8] lea r3d, [r5+dxq] shr r5d, 6 ; base1 vinserti128 m0, [tlq+r5+0], 1 vinserti128 m1, [tlq+r5+8], 1 pshufb m0, m8 pshufb m1, m8 pmaddubsw m0, m2 pmaddubsw m1, m2 pmulhrsw m0, m3 pmulhrsw m1, m3 packuswb m0, m1 pcmpgtw m1, m9, m6 pcmpgtw m2, m10, m6 packsswb m1, m2 paddw m6, m11 vpblendvb m0, m7, m0, m1 mova [dstq+strideq*0], xm0 vextracti128 [dstq+strideq*1], m0, 1 sub hd, 2 jz .w16_end lea dstq, [dstq+strideq*2] cmp r3d, maxbased jb .w16_loop .w16_end_loop: mova [dstq+strideq*0], xm7 mova [dstq+strideq*1], xm7 lea dstq, [dstq+strideq*2] sub hd, 2 jg .w16_end_loop .w16_end: RET ALIGN function_align .w32: %assign stack_offset org_stack_offset ALLOC_STACK -96, 15 lea r3d, [hq+31] mov maxbased, 63 cmp hd, 32 cmovs maxbased, r3d test angled, 0x400 ; !enable_intra_edge_filter jnz .w32_main vbroadcasti128 m0, [pb_0to15] sub r3d, 29 ; h+2 movu xm13, [tlq+29] ; 32-39 movd xm1, r3d movu xm14, [tlq+37] ; 40-47 sub r3d, 8 ; h-6 vinserti128 m14, [tlq+51], 1 ; 56-63 vpbroadcastb xm1, xm1 mova xm11, [tlq- 1] ; 0- 7 vinserti128 m11, [tlq+13], 1 ; 16-23 movd xm2, r3d movu xm12, [tlq+ 5] ; 8-15 vinserti128 m12, [tlq+19], 1 ; 24-31 pminub xm1, xm0 ; clip 32x8 mova m7, [z_filter_s+0] pshufb xm13, xm1 vpbroadcastd m1, [pb_12] vpbroadcastb xm2, xm2 vinserti128 m13, [tlq+43], 1 ; 48-55 vinserti128 m8, m7, [z_filter_s+4], 1 vpblendd m2, m1, 0xf0 vinserti128 m7, [z_filter_s+12], 0 pminub m2, m0 ; clip 32x16 and 32x(32|64) vpbroadcastd m9, [z_filter_k+4*2+12*0] pshufb m14, m2 pshufb m0, m11, m8 shufps m8, m7, q1021 pmaddubsw m0, m9 pshufb m2, m12, m8 pmaddubsw m2, m9 pshufb m1, m13, m8 pmaddubsw m1, m9 pshufb m6, m14, m8 pmaddubsw m6, m9 vpbroadcastd m9, [z_filter_k+4*2+12*1] pshufb m10, m11, m8 shufps m8, m7, q2121 pmaddubsw m10, m9 paddw m0, m10 pshufb m10, m12, m8 pmaddubsw m10, m9 paddw m2, m10 pshufb m10, m13, m8 pmaddubsw m10, m9 paddw m1, m10 pshufb m10, m14, m8 pmaddubsw m10, m9 paddw m6, m10 vpbroadcastd m9, [z_filter_k+4*2+12*2] pshufb m11, m8 pmaddubsw m11, m9 pshufb m12, m7 pmaddubsw m12, m9 movzx r3d, byte [tlq+63] movzx r2d, byte [tlq+62] paddw m0, m11 paddw m2, m12 pshufb m13, m7 pmaddubsw m13, m9 pshufb m14, m7 pmaddubsw m14, m9 paddw m1, m13 paddw m6, m14 sub r2d, r3d lea r2d, [r2+r3*8+4] ; edge case for 32x64 pmulhrsw m0, m3 pmulhrsw m2, m3 pmulhrsw m1, m3 pmulhrsw m6, m3 shr r2d, 3 mov [rsp+64], r2b mov tlq, rsp mov [tlq+65], r3b mov r3d, 65 cmp hd, 64 cmove maxbased, r3d packuswb m0, m2 packuswb m1, m6 mova [tlq+ 0], m0 mova [tlq+32], m1 .w32_main: movd xm6, dxd vpbroadcastb m7, [tlq+maxbaseq] shl maxbased, 6 vpbroadcastw m6, xm6 movd xm9, maxbased vbroadcasti128 m8, [z_filter_s+2] vpbroadcastw m9, xm9 mov r5d, dxd psubw m9, [z_base_inc] mova m11, m6 psubw m10, m9, m3 ; 64*8 .w32_loop: mov r3d, r5d shr r3d, 6 pand m1, m4, m6 psubw m2, m5, m1 psllw m1, 8 por m2, m1 movu m0, [tlq+r3+0] movu m1, [tlq+r3+8] add r5d, dxd pshufb m0, m8 pshufb m1, m8 pmaddubsw m0, m2 pmaddubsw m1, m2 pmulhrsw m0, m3 pmulhrsw m1, m3 packuswb m0, m1 pcmpgtw m1, m9, m6 pcmpgtw m2, m10, m6 packsswb m1, m2 paddw m6, m11 vpblendvb m0, m7, m0, m1 mova [dstq], m0 dec hd jz .w32_end add dstq, strideq cmp r5d, maxbased jb .w32_loop test hb, 1 jz .w32_end_loop mova [dstq], m7 add dstq, strideq dec hd jz .w32_end .w32_end_loop: mova [dstq+strideq*0], m7 mova [dstq+strideq*1], m7 lea dstq, [dstq+strideq*2] sub hd, 2 jg .w32_end_loop .w32_end: RET ALIGN function_align .w64: %assign stack_offset org_stack_offset ALLOC_STACK -128, 16 lea maxbased, [hq+63] test angled, 0x400 ; !enable_intra_edge_filter jnz .w64_main mova xm11, [tlq- 1] ; 0- 7 vinserti128 m11, [tlq+13], 1 ; 16-23 movu xm12, [tlq+ 5] ; 8-15 vinserti128 m12, [tlq+19], 1 ; 24-31 mova m7, [z_filter_s+0] vinserti128 m8, m7, [z_filter_s+4], 1 vinserti128 m7, [z_filter_s+12], 0 vpbroadcastd m9, [z_filter_k+4*2+12*0] movu xm13, [tlq+29] ; 32-39 vinserti128 m13, [tlq+43], 1 ; 48-55 movu xm14, [tlq+37] ; 40-47 vinserti128 m14, [tlq+51], 1 ; 56-63 pshufb m0, m11, m8 shufps m8, m7, q1021 pmaddubsw m0, m9 pshufb m2, m12, m8 pmaddubsw m2, m9 pshufb m1, m13, m8 pmaddubsw m1, m9 pshufb m6, m14, m8 pmaddubsw m6, m9 vpbroadcastd m9, [z_filter_k+4*2+12*1] pshufb m10, m11, m8 shufps m15, m8, m7, q2121 pmaddubsw m10, m9 paddw m0, m10 pshufb m10, m12, m15 pmaddubsw m10, m9 paddw m2, m10 pshufb m10, m13, m15 pmaddubsw m10, m9 paddw m1, m10 pshufb m10, m14, m15 pmaddubsw m10, m9 paddw m6, m10 vpbroadcastd m10, [z_filter_k+4*2+12*2] pshufb m11, m15 pmaddubsw m11, m10 pshufb m12, m7 pmaddubsw m12, m10 pshufb m13, m7 pmaddubsw m13, m10 pshufb m14, m7 pmaddubsw m14, m10 paddw m0, m11 paddw m2, m12 paddw m1, m13 paddw m6, m14 movu xm11, [tlq+ 61] ; 64- 71 vinserti128 m11, [tlq+ 75], 1 ; 80- 87 movu xm12, [tlq+ 69] ; 72- 79 vinserti128 m12, [tlq+ 83], 1 ; 88- 95 movu xm13, [tlq+ 93] ; 96-103 vinserti128 m13, [tlq+107], 1 ; 112-119 movu xm14, [tlq+101] ; 104-111 vinserti128 m14, [tlq+115], 1 ; 120-127 pmulhrsw m0, m3 pmulhrsw m2, m3 pmulhrsw m1, m3 pmulhrsw m6, m3 lea r3d, [hq-20] mov tlq, rsp packuswb m0, m2 packuswb m1, m6 vpbroadcastd xm2, [pb_14] vbroadcasti128 m6, [pb_0to15] mova [tlq+32*0], m0 mova [tlq+32*1], m1 movd xm0, r3d vpbroadcastd m1, [pb_12] vpbroadcastb m0, xm0 paddb m0, m2 pminub m0, m6 ; clip 64x16 and 64x32 pshufb m12, m0 pminub m1, m6 ; clip 64x64 pshufb m14, m1 pshufb m0, m11, m7 pmaddubsw m0, m10 pshufb m2, m12, m7 pmaddubsw m2, m10 pshufb m1, m13, m7 pmaddubsw m1, m10 pshufb m6, m14, m7 pmaddubsw m6, m10 pshufb m7, m11, m15 pmaddubsw m7, m9 pshufb m10, m12, m15 pmaddubsw m10, m9 paddw m0, m7 pshufb m7, m13, m15 pmaddubsw m7, m9 paddw m2, m10 pshufb m10, m14, m15 pmaddubsw m10, m9 paddw m1, m7 paddw m6, m10 vpbroadcastd m9, [z_filter_k+4*2+12*0] pshufb m11, m8 pmaddubsw m11, m9 pshufb m12, m8 pmaddubsw m12, m9 pshufb m13, m8 pmaddubsw m13, m9 pshufb m14, m8 pmaddubsw m14, m9 paddw m0, m11 paddw m2, m12 paddw m1, m13 paddw m6, m14 pmulhrsw m0, m3 pmulhrsw m2, m3 pmulhrsw m1, m3 pmulhrsw m6, m3 packuswb m0, m2 packuswb m1, m6 mova [tlq+32*2], m0 mova [tlq+32*3], m1 .w64_main: movd xm12, dxd vpbroadcastb m7, [tlq+maxbaseq] lea r3d, [dxq-64] shl maxbased, 6 vpbroadcastw m12, xm12 sub r3d, maxbased vbroadcasti128 m8, [z_filter_s+2] movd xm6, r3d mov r5d, dxd mova m10, [pb_1to32] vpbroadcastd m11, [pb_32] vpbroadcastw m6, xm6 .w64_loop: mov r3d, r5d shr r3d, 6 movu m0, [tlq+r3+ 0] movu m1, [tlq+r3+ 8] pand m2, m4, m6 psubw m9, m5, m2 psllw m2, 8 por m9, m2 pshufb m0, m8 pshufb m1, m8 pmaddubsw m0, m9 pmaddubsw m1, m9 psraw m2, m6, 6 pmulhrsw m0, m3 pmulhrsw m1, m3 packsswb m2, m2 paddb m2, m10 packuswb m0, m1 vpblendvb m0, m7, m0, m2 mova [dstq+ 0], m0 movu m0, [tlq+r3+32] movu m1, [tlq+r3+40] add r5d, dxd pshufb m0, m8 pshufb m1, m8 pmaddubsw m0, m9 pmaddubsw m1, m9 paddb m2, m11 pmulhrsw m0, m3 pmulhrsw m1, m3 paddw m6, m12 packuswb m0, m1 vpblendvb m0, m7, m0, m2 mova [dstq+32], m0 dec hd jz .w64_end add dstq, strideq cmp r5d, maxbased jb .w64_loop .w64_end_loop: mova [dstq+ 0], m7 mova [dstq+32], m7 add dstq, strideq dec hd jg .w64_end_loop .w64_end: RET cglobal ipred_z2, 3, 10, 16, 224, dst, stride, tl, w, h, angle, dx, dy %define base r9-z_filter_t0 lea r9, [ipred_z2_avx2_table] tzcnt wd, wm movifnidn angled, anglem movifnidn hd, hm lea dxq, [dr_intra_derivative-90] movsxd wq, [r9+wq*4] movzx dyd, angleb xor angled, 0x400 mov r8, dxq sub dxq, dyq add wq, r9 add r9, z_filter_t0-ipred_z2_avx2_table mova m2, [tlq-64] mova m0, [tlq-32] mova m1, [tlq] and dyd, ~1 and dxq, ~1 movzx dyd, word [r8+dyq] ; angle - 90 movzx dxd, word [dxq+270] ; 180 - angle vpbroadcastd m13, [base+pw_512] vpbroadcastd m14, [base+pw_62] vpbroadcastd m15, [base+pw_64] mova [rsp+ 0], m2 mova [rsp+32], m0 mova [rsp+64], m1 neg dxd neg dyd jmp wq .w4: vpbroadcastq m6, [base+z2_base_inc] ; base_inc << 6 vbroadcasti128 m10, [base+z1_shuf_w4] vbroadcasti128 m11, [base+z2_shuf_h4] lea r2d, [dxq+(65<<6)] ; xpos movd xm5, dyd mov r8d, (63-4)<<6 mov dyq, -4 pshuflw xm5, xm5, q0000 pmullw xm5, [base+z2_ymul] test angled, 0x400 jnz .w4_main ; !enable_intra_edge_filter lea r3d, [hq+2] add angled, 1022 shl r3d, 6 test r3d, angled jnz .w4_no_upsample_above ; angle >= 130 || h > 8 || (is_sm && h == 8) vpbroadcastd xm3, [base+pb_4] call .upsample_above sub angled, 1075 ; angle - 53 lea r3d, [hq+3] xor angled, 0x7f ; 180 - angle call .filter_strength jmp .w4_filter_left ALIGN function_align .filter_strength: movd xm8, r3d mov r3d, angled movd xm7, angled vpbroadcastb m8, xm8 shr r3d, 8 ; is_sm << 1 vpbroadcastb m7, xm7 pcmpeqb m8, [base+z_filter_wh] mova xm9, [r9+r3*8] pand m0, m8, m7 pcmpgtb m0, m9 pmovmskb r3d, m0 popcnt r3d, r3d ret ALIGN function_align .upsample_above: ; w4/w8 pshufb xm2, xm1, [base+z_upsample1-2] pminub xm3, [base+z_filter_s+4] vpbroadcastd xm4, [base+pb_36_m4] vbroadcasti128 m10, [base+pb_0to15] pshufb xm3, xm1, xm3 pmaddubsw xm2, xm4 pmaddubsw xm3, xm4 lea r2d, [r2+dxq+(1<<6)] add dxd, dxd paddw xm2, xm3 pmulhrsw xm2, xm13 sub r8d, 3<<6 paddw m6, m6 packuswb xm2, xm2 punpcklbw xm1, xm2 mova [rsp+gprsize+64], xm1 ret ALIGN function_align .upsample_left: ; h4/h8 mov r3d, hd and r3d, 4 movd xm2, [rsp+gprsize+64] movddup xm0, [rsp+gprsize+56] movd xm1, r3d palignr xm2, xm0, 1 vpbroadcastb xm1, xm1 pshufb xm2, [base+z_filter_s+18] vpbroadcastd xm3, [base+pb_36_m4] pmaxub xm1, [base+z_upsample1-2] pshufb xm1, xm0, xm1 pmaddubsw xm2, xm3 pmaddubsw xm1, xm3 paddw xm5, xm5 add dyq, dyq paddw xm1, xm2 pmulhrsw xm1, xm13 vbroadcasti128 m11, [base+z2_upsample] paddw xm5, xm15 packuswb xm1, xm1 punpcklbw xm0, xm1 mova [rsp+gprsize+48], xm0 ret .w4_no_upsample_above: lea r3d, [hq+3] sub angled, 1112 ; angle - 90 call .filter_strength jz .w4_no_filter_above vpbroadcastd xm2, [base+pb_4] pminub xm2, [base+z_filter_s] vpbroadcastd xm0, [base+z_filter_k-4+r3*4+12*0] vpbroadcastd xm4, [base+z_filter_k-4+r3*4+12*1] pshufb xm3, xm1, xm2 ; 00 01 12 23 pshufd xm2, xm2, q0321 pmaddubsw xm0, xm3, xm0 pshufb xm2, xm1, xm2 ; 12 23 34 44 pmaddubsw xm2, xm4 vpbroadcastd xm4, [base+z_filter_k-4+r3*4+12*2] punpckhqdq xm3, xm3 ; 34 44 44 44 pmaddubsw xm3, xm4 movd xm4, r6m ; max_width pminsw xm4, xm15 vpbroadcastb xm4, xm4 paddw xm0, xm2 paddw xm0, xm3 pmulhrsw xm0, xm13 psubb xm4, [base+pb_1to32] psrlq xm1, 8 packuswb xm0, xm0 vpblendvb xm0, xm1, xm4 movd [rsp+65], xm0 .w4_no_filter_above: lea r3d, [hq+2] add angled, 973 ; angle + 883 shl r3d, 6 test r3d, angled jz .w4_upsample_left ; angle <= 140 || h > 8 || (is_sm && h == 8) vpbroadcastd xm0, [base+pb_90] psubb xm0, xm7 ; 180 - angle pand xm0, xm8 ; reuse from previous filter_strength call pcmpgtb xm0, xm9 pmovmskb r3d, xm0 popcnt r3d, r3d .w4_filter_left: jz .w4_main mov r5d, 10 cmp hd, 16 movu xm2, [rsp+49] vinserti128 m2, [rsp+43], 1 cmovs r5d, hd xor r5d, 15 ; h == 16 ? 5 : 15 - h movd xm0, r5d vbroadcasti128 m1, [base+z_filter_s+12] vbroadcasti128 m4, [base+z_filter_s+16] vinserti128 m3, m1, [z_filter_s+8], 1 ; 56 67 78 89 9a ab bc cd 55 55 56 67 78 89 9a ab vpblendd m1, m4, 0x0f ; 78 89 9a ab bc cd de ef 56 67 78 89 9a ab bc cd vinserti128 m4, [base+z_filter_s+20], 0 ; 9a ab bc cd de ef ff ff 78 89 9a ab bc cd de ef vpbroadcastb m0, xm0 pmaxub m0, m3 vpbroadcastd m3, [base+z_filter_k-4+r3*4+12*0] pshufb m0, m2, m0 pmaddubsw m0, m3 vpbroadcastd m3, [base+z_filter_k-4+r3*4+12*1] pshufb m1, m2, m1 pmaddubsw m1, m3 vpbroadcastd m3, [base+z_filter_k-4+r3*4+12*2] pshufb m2, m4 pmaddubsw m2, m3 movd xm4, r7m ; max_height pminsw xm4, xm15 vpbroadcastb xm4, xm4 psubb xm4, [base+pb_16to1] paddw m1, m0 paddw m1, m2 pmulhrsw m1, m13 vextracti128 xm0, m1, 1 packuswb xm0, xm1 vpblendvb xm0, [rsp+48], xm4 mova [rsp+48], xm0 jmp .w4_main .w4_upsample_left: call .upsample_left .w4_main: movd xm0, dxd mova m12, [base+z2_y_shuf_h4] lea r5, [rsp+56] ; left-7 vpbroadcastw m0, xm0 lea r9, [strideq*3] psraw xm1, xm5, 6 pand xm5, xm14 ; frac_y pxor xm2, xm2 paddw m7, m0, m0 psubw xm4, xm2, xm1 ; base_y vpblendd m0, m7, 0xcc mova xm1, xm7 punpcklwd xm4, xm2 paddw m0, m1 ; xpos2 xpos3 xpos0 xpos1 psubw xm1, xm15, xm5 ; 64-frac_y psllw xm5, 8 paddw m7, m7 paddw m6, m0 por xm5, xm1 ; 64-frac_y, frac_y vpbroadcastq m5, xm5 .w4_loop: lea r3d, [r2+dxq] shr r2d, 6 ; base_x0 vpbroadcastq m1, [rsp+r2] lea r2d, [r3+dxq] shr r3d, 6 ; base_x1 vpbroadcastq m2, [rsp+r3] lea r3d, [r2+dxq] shr r2d, 6 ; base_x2 movq xm0, [rsp+r2] lea r2d, [r3+dxq] shr r3d, 6 ; base_x3 movhps xm0, [rsp+r3] vpblendd m1, m2, 0xc0 pand m2, m14, m6 ; frac_x vpblendd m0, m1, 0xf0 psubw m1, m15, m2 ; 64-frac_x psllw m2, 8 pshufb m0, m10 por m1, m2 ; 64-frac_x, frac_x pmaddubsw m0, m1 cmp r3d, 64 jge .w4_toponly mova m1, m7 ; arbitrary negative value vpgatherdq m3, [r5+xm4], m1 pshufb m1, m3, m11 vpermd m1, m12, m1 pmaddubsw m1, m5 psraw m2, m6, 15 ; base_x < topleft vpblendvb m0, m1, m2 .w4_toponly: pmulhrsw m0, m13 paddw m6, m7 ; xpos += dx add r5, dyq packuswb m0, m0 vextracti128 xm1, m0, 1 movd [dstq+strideq*2], xm0 pextrd [dstq+r9 ], xm0, 1 movd [dstq+strideq*0], xm1 pextrd [dstq+strideq*1], xm1, 1 sub hd, 4 jz .w4_end lea dstq, [dstq+strideq*4] cmp r2d, r8d jge .w4_loop .w4_leftonly_loop: mova m1, m7 vpgatherdq m2, [r5+xm4], m1 add r5, dyq pshufb m0, m2, m11 vpermd m0, m12, m0 pmaddubsw m0, m5 pmulhrsw m0, m13 packuswb m0, m0 vextracti128 xm1, m0, 1 movd [dstq+strideq*2], xm0 pextrd [dstq+r9 ], xm0, 1 movd [dstq+strideq*0], xm1 pextrd [dstq+strideq*1], xm1, 1 lea dstq, [dstq+strideq*4] sub hd, 4 jg .w4_leftonly_loop .w4_end: RET .w8: vbroadcasti128 m6, [base+z2_base_inc] ; base_inc << 6 movd xm5, dyd vbroadcasti128 m10, [base+z_filter_s+2] vbroadcasti128 m11, [base+z2_shuf_h4] lea r2d, [dxq+(65<<6)] ; xpos vpbroadcastw xm5, xm5 mov r8d, (63-8)<<6 mov dyq, -4 pmullw xm5, [base+z2_ymul] test angled, 0x400 jnz .w8_main lea r3d, [angleq+126] mov r3b, hb cmp r3d, 8 ja .w8_no_upsample_above ; angle >= 130 || h > 8 || is_sm vpbroadcastd xm3, [base+pb_8] movhps [rsp+80], xm1 call .upsample_above sub angled, 53 ; angle - 53 lea r3d, [hq+7] xor angled, 0x7f ; 180 - angle call .filter_strength jmp .w8_filter_left .w8_no_upsample_above: lea r3d, [hq+7] sub angled, 90 ; angle - 90 call .filter_strength jz .w8_no_filter_above vpbroadcastd xm3, [base+pb_8] pminub xm3, [base+z_filter_s+8] vpbroadcastd xm0, [base+z_filter_k-4+r3*4+12*0] vpbroadcastd xm4, [base+z_filter_k-4+r3*4+12*1] pshufb xm2, xm1, [base+z_filter_s] ; 00 01 12 23 34 45 56 67 pmaddubsw xm0, xm2, xm0 pshufb xm3, xm1, xm3 ; 34 45 56 67 78 88 88 88 shufps xm2, xm3, q2121 ; 12 23 34 45 56 67 78 88 pmaddubsw xm2, xm4 vpbroadcastd xm4, [base+z_filter_k-4+r3*4+12*2] pmaddubsw xm3, xm4 movd xm4, r6m ; max_width pminuw xm4, xm15 vpbroadcastb xm4, xm4 paddw xm0, xm2 paddw xm0, xm3 pmulhrsw xm0, xm13 psubb xm4, [base+pb_1to32] psrldq xm1, 1 packuswb xm0, xm0 vpblendvb xm0, xm1, xm4 movq [rsp+65], xm0 .w8_no_filter_above: lea r3d, [angleq-51] mov r3b, hb cmp r3d, 8 jbe .w8_upsample_left ; angle > 140 && h <= 8 && !is_sm vpbroadcastd m0, [base+pb_90] psubb m0, m7 pand m0, m8 pcmpgtb m0, m9 pmovmskb r3d, m0 popcnt r3d, r3d .w8_filter_left: jz .w8_main vpbroadcastd m7, [base+z_filter_k-4+r3*4+12*0] vpbroadcastd m8, [base+z_filter_k-4+r3*4+12*1] vpbroadcastd m9, [base+z_filter_k-4+r3*4+12*2] cmp hd, 32 jne .w8_filter_left_h16 movu xm2, [rsp+27] vinserti128 m2, [rsp+35], 1 vpbroadcastd xm0, [base+pb_5] vbroadcasti128 m3, [base+z_filter_s+ 8] vbroadcasti128 m1, [base+z_filter_s+12] vbroadcasti128 m4, [base+z_filter_s+16] pmaxub m3, m0 pshufb m3, m2, m3 pmaddubsw m3, m7 pshufb m1, m2, m1 pmaddubsw m1, m8 pshufb m2, m4 pmaddubsw m2, m9 paddw m3, m1 paddw m3, m2 pmulhrsw m3, m13 jmp .w8_filter_left_top16 .w8_filter_left_h16: mov r5d, 10 cmp hd, 16 cmovs r5d, hd xor r5d, 15 ; h == 16 ? 5 : 15 - h movd xm0, r5d vpbroadcastb m0, xm0 .w8_filter_left_top16: vbroadcasti128 m1, [base+z_filter_s+12] vinserti128 m2, m1, [base+z_filter_s+8], 1 ; 56 67 78 89 9a ab bc cd 55 55 56 67 78 89 9a ab vbroadcasti128 m4, [base+z_filter_s+16] vpblendd m1, m4, 0x0f ; 78 89 9a ab bc cd de ef 56 67 78 89 9a ab bc cd vinserti128 m4, [base+z_filter_s+20], 0 ; 9a ab bc cd de ef ff ff 78 89 9a ab bc cd de ef pmaxub m0, m2 movu xm2, [rsp+49] vinserti128 m2, [rsp+43], 1 pshufb m0, m2, m0 pmaddubsw m0, m7 movd xm7, r7m ; max_height pshufb m1, m2, m1 pmaddubsw m1, m8 pshufb m2, m4 pmaddubsw m2, m9 pminsw xm7, xm15 paddw m1, m0 vpbroadcastb m7, xm7 paddw m1, m2 pmulhrsw m1, m13 psubb m7, [base+pb_32to1] packuswb m3, m1 vpermq m3, m3, q1320 vpblendvb m3, [rsp+32], m7 mova [rsp+32], m3 jmp .w8_main .w8_upsample_left: call .upsample_left .w8_main: movd xm3, dxd lea r5, [rsp+56] ; left-7 pshufd xm1, xm5, q3120 pand xm5, xm14 vpbroadcastw m3, xm3 pxor xm0, xm0 psubw xm2, xm15, xm5 psraw xm1, 6 lea r9, [strideq*3] paddw m7, m3, m3 psubw xm9, xm0, xm1 ; base_y psllw xm5, 8 punpcklwd xm8, xm9, xm0 ; base_y 0, 1, 4, 5 vpblendd m3, m7, 0xf0 ; xpos0 xpos1 por xm5, xm2 ; 64-frac_y, frac_y punpckhwd xm9, xm0 ; base_y 2, 3, 6, 7 paddw m6, m3 vinserti128 m12, m5, xm5, 1 .w8_loop: lea r3d, [r2+dxq] shr r2d, 6 ; base_x0 movu xm0, [rsp+r2] lea r2d, [r3+dxq] shr r3d, 6 ; base_x1 vinserti128 m0, [rsp+r3], 1 lea r3d, [r2+dxq] shr r2d, 6 ; base_x2 movu xm1, [rsp+r2] lea r2d, [r3+dxq] shr r3d, 6 ; base_x3 vinserti128 m1, [rsp+r3], 1 pand m2, m14, m6 paddsw m4, m6, m7 psubw m5, m15, m2 psllw m2, 8 pshufb m0, m10 por m2, m5 pmaddubsw m0, m2 pand m2, m14, m4 psubw m5, m15, m2 psllw m2, 8 pshufb m1, m10 por m2, m5 pmaddubsw m1, m2 cmp r3d, 64 jge .w8_toponly mova m5, m7 vpgatherdq m3, [r5+xm9], m7 mova m7, m5 vpgatherdq m2, [r5+xm8], m5 pshufb m3, m11 pshufb m2, m11 punpckldq m5, m2, m3 ; a0 b0 c0 d0 a1 b1 c1 d1 e0 f0 g0 h0 e1 f1 g1 h1 punpckhdq m2, m3 ; a2 b2 c2 d2 a3 b3 c3 d3 e2 f2 g2 h2 e3 f3 g3 h3 vpermq m5, m5, q3120 ; y0 y1 vpermq m2, m2, q3120 ; y2 y3 pmaddubsw m5, m12 pmaddubsw m2, m12 psraw m6, 15 ; base_x < topleft vpblendvb m0, m5, m6 psraw m3, m4, 15 vpblendvb m1, m2, m3 .w8_toponly: pmulhrsw m0, m13 pmulhrsw m1, m13 paddw m6, m4, m7 ; xpos += dx add r5, dyq packuswb m0, m1 vextracti128 xm1, m0, 1 movq [dstq+strideq*0], xm0 movhps [dstq+strideq*2], xm0 movq [dstq+strideq*1], xm1 movhps [dstq+r9 ], xm1 sub hd, 4 jz .w8_end lea dstq, [dstq+strideq*4] cmp r2d, r8d jge .w8_loop .w8_leftonly_loop: mova m0, m7 vpgatherdq m5, [r5+xm9], m7 mova m7, m0 vpgatherdq m3, [r5+xm8], m0 add r5, dyq pshufb m2, m5, m11 pshufb m1, m3, m11 punpckldq m0, m1, m2 punpckhdq m1, m2 vpermq m0, m0, q3120 vpermq m1, m1, q3120 pmaddubsw m0, m12 pmaddubsw m1, m12 pmulhrsw m0, m13 pmulhrsw m1, m13 packuswb m0, m1 vextracti128 xm1, m0, 1 movq [dstq+strideq*0], xm0 movhps [dstq+strideq*2], xm0 movq [dstq+strideq*1], xm1 movhps [dstq+r9 ], xm1 lea dstq, [dstq+strideq*4] sub hd, 4 jg .w8_leftonly_loop .w8_end: RET .w16: mov r8d, hd test angled, 0x400 jnz .w16_main lea r3d, [hq+15] sub angled, 90 call .filter_strength jz .w16_no_filter_above vbroadcasti128 m6, [tlq+1] mova xm2, [base+z_filter_s] vinserti128 m2, [base+z_filter_s+14], 1 ; 00 01 12 23 34 45 56 67 67 78 89 9a ab bc cd de movu xm3, [base+z_filter_s+8] vinserti128 m3, [base+z_filter_s+22], 1 ; 34 45 56 67 78 89 9a ab ab bc cd de ef ff ff ff vpblendd m1, m6, 0xf0 vpbroadcastd m0, [base+z_filter_k-4+r3*4+12*0] vpbroadcastd m4, [base+z_filter_k-4+r3*4+12*1] vpbroadcastd m5, [base+z_filter_k-4+r3*4+12*2] pshufb m2, m1, m2 pshufb m1, m3 pmaddubsw m0, m2, m0 shufps m2, m1, q2121 ; 12 23 34 45 56 67 78 89 89 9a ab bc cd de ef ff pmaddubsw m2, m4 pmaddubsw m1, m5 movd xm4, r6m ; max_width pminsw xm4, xm15 vpbroadcastb xm4, xm4 paddw m0, m2 paddw m0, m1 pmulhrsw m0, m13 psubb xm4, [base+pb_1to32] vextracti128 xm2, m0, 1 packuswb xm0, xm2 vpblendvb xm0, xm6, xm4 movu [rsp+65], xm0 .w16_no_filter_above: vpbroadcastd m0, [base+pb_90] psubb m0, m7 pand m0, m8 pcmpgtb m0, m9 pmovmskb r3d, m0 popcnt r3d, r3d jz .w16_main vpbroadcastd m7, [base+z_filter_k-4+r3*4+12*0] vpbroadcastd m8, [base+z_filter_k-4+r3*4+12*1] vpbroadcastd m9, [base+z_filter_k-4+r3*4+12*2] .w16_filter_left: movd xm6, r7m ; max_height pminsw xm6, xm15 vpbroadcastb m6, xm6 cmp hd, 32 jl .w16_filter_left_h16 vpbroadcastd xm0, [base+pb_5] vbroadcasti128 m10, [base+z_filter_s+ 8] vbroadcasti128 m11, [base+z_filter_s+12] vbroadcasti128 m12, [base+z_filter_s+16] je .w16_filter_left_h32 movu m3, [tlq-69] movu m5, [tlq-61] pmaxub m1, m10, m0 pshufb m1, m3, m1 pmaddubsw m1, m7 pshufb m2, m3, m11 pmaddubsw m2, m8 pshufb m3, m12 pmaddubsw m3, m9 paddw m1, m2 pshufb m2, m5, m10 pmaddubsw m2, m7 pshufb m4, m5, m11 pmaddubsw m4, m8 pshufb m5, m12 pmaddubsw m5, m9 paddw m1, m3 vpbroadcastd m3, [base+pb_32] paddb m3, [base+pb_32to1] paddw m2, m4 paddw m2, m5 pmulhrsw m1, m13 pmulhrsw m2, m13 psubb m3, m6, m3 packuswb m1, m2 vpblendvb m1, [tlq-64], m3 mova [rsp], m1 jmp .w16_filter_left_top32 .w16_filter_left_h32: pmaxub m10, m0 .w16_filter_left_top32: movu xm2, [tlq-37] vinserti128 m2, [tlq-29], 1 pshufb m3, m2, m10 pshufb m1, m2, m11 pshufb m2, m12 pmaddubsw m3, m7 pmaddubsw m1, m8 pmaddubsw m2, m9 paddw m3, m1 paddw m3, m2 pmulhrsw m3, m13 jmp .w16_filter_left_top16 .w16_filter_left_h16: mov r5d, 10 cmp hd, 16 cmovs r5d, hd xor r5d, 15 ; h == 16 ? 5 : 15 - h movd xm0, r5d vpbroadcastb m0, xm0 .w16_filter_left_top16: movu xm2, [tlq-15] vinserti128 m2, [tlq-21], 1 vbroadcasti128 m1, [base+z_filter_s+12] vbroadcasti128 m4, [base+z_filter_s+16] vinserti128 m5, m1, [base+z_filter_s+8], 1 ; 56 67 78 89 9a ab bc cd 34 45 56 67 78 89 9a ab vpblendd m1, m4, 0x0f ; 78 89 9a ab bc cd de ef 56 67 78 89 9a ab bc cd vinserti128 m4, [base+z_filter_s+20], 0 ; 9a ab bc cd de ef ff ff 78 89 9a ab bc cd de ef pmaxub m0, m5 pshufb m0, m2, m0 pmaddubsw m0, m7 pshufb m1, m2, m1 pmaddubsw m1, m8 pshufb m2, m4 pmaddubsw m2, m9 psubb m6, [base+pb_32to1] paddw m1, m0 paddw m1, m2 pmulhrsw m1, m13 packuswb m3, m1 vpermq m3, m3, q1320 vpblendvb m3, [tlq-32], m6 mova [rsp+32], m3 .w16_main: movd xm1, dyd vbroadcasti128 m10, [base+z_filter_s+2] movd xm7, dxd vbroadcasti128 m11, [base+z2_shuf_h2] vpbroadcastw m1, xm1 vpbroadcastw m7, xm7 mov r7, dstq pmullw m0, m1, [base+z2_ymul] psllw xm1, 4 paddw m6, m7, [base+z2_base_inc] lea r9d, [dxq+(65<<6)] ; xpos movd [rsp+156], xm1 .w16_loop0: mov r2d, r9d mova [rsp+160], m0 lea r5, [rsp+60] ; left-3 mova [rsp+192], m6 pxor m1, m1 psraw m2, m0, 6 pand m0, m14 psubw m9, m1, m2 ; base_y psubw m12, m15, m0 punpcklwd m8, m9, m1 ; base_y 0, 1, 2, 3, 8, 9, 10, 11 psllw m0, 8 punpckhwd m9, m1 ; base_y 4, 5, 6, 7, 12, 13, 14, 15 por m12, m0 ; 64-frac_y, frac_y .w16_loop: lea r3d, [r2+dxq] shr r2d, 6 ; base_x0 movu xm0, [rsp+r2] vinserti128 m0, [rsp+r2+8], 1 lea r2d, [r3+dxq] shr r3d, 6 ; base_x1 movu xm1, [rsp+r3] vinserti128 m1, [rsp+r3+8], 1 pand m2, m14, m6 paddsw m5, m6, m7 psubw m3, m15, m2 psllw m2, 8 pshufb m0, m10 por m2, m3 pmaddubsw m0, m2 pand m2, m14, m5 psubw m3, m15, m2 psllw m2, 8 pshufb m1, m10 por m2, m3 pmaddubsw m1, m2 cmp r3d, 64 jge .w16_toponly punpckhwd m2, m5, m5 ; mask out unnecessary loads vpgatherdd m4, [r5+m9], m2 punpcklwd m2, m5, m5 vpgatherdd m3, [r5+m8], m2 pshufb m4, m11 ; e0 f0 g0 h0 e1 f1 g1 h1 m0 n0 o0 p0 m1 n1 o1 p1 pshufb m3, m11 ; a0 b0 c0 d0 a1 b1 c1 d1 i0 j0 k0 l0 i1 j1 k1 l1 punpcklqdq m2, m3, m4 ; y0 punpckhqdq m3, m4 ; y1 pmaddubsw m2, m12 pmaddubsw m3, m12 psraw m6, 15 ; base_x < topleft vpblendvb m0, m2, m6 psraw m6, m5, 15 vpblendvb m1, m3, m6 .w16_toponly: pmulhrsw m0, m13 pmulhrsw m1, m13 paddw m6, m5, m7 ; xpos += dx sub r5, 2 packuswb m0, m1 vpermq m0, m0, q3120 mova [dstq+strideq*0], xm0 vextracti128 [dstq+strideq*1], m0, 1 sub hd, 2 jz .w16_end lea dstq, [dstq+strideq*2] cmp r2d, (63-16)<<6 jge .w16_loop .w16_leftonly_loop: mova m0, m7 vpgatherdd m4, [r5+m9], m7 mova m7, m0 vpgatherdd m3, [r5+m8], m0 sub r5, 2 pshufb m2, m4, m11 pshufb m1, m3, m11 punpcklqdq m0, m1, m2 punpckhqdq m1, m2 pmaddubsw m0, m12 pmaddubsw m1, m12 pmulhrsw m0, m13 pmulhrsw m1, m13 packuswb m0, m1 vpermq m0, m0, q3120 mova [dstq+strideq*0], xm0 vextracti128 [dstq+strideq*1], m0, 1 lea dstq, [dstq+strideq*2] sub hd, 2 jg .w16_leftonly_loop .w16_end: sub r8d, 1<<8 jl .w16_ret vpbroadcastd m0, [rsp+156] paddw m0, [rsp+160] ; base_y += 16*dy paddw m6, m13, [rsp+192] add r7, 16 add r9d, 16<<6 movzx hd, r8b mov dstq, r7 paddw m6, m13 ; base_x += 16*64 jmp .w16_loop0 .w16_ret: RET .w32: mova m2, [tlq+32] lea r8d, [hq+(1<<8)] mova [rsp+96], m2 test angled, 0x400 jnz .w16_main vpbroadcastd m7, [base+z_filter_k+4*2+12*0] vpbroadcastd m8, [base+z_filter_k+4*2+12*1] vpbroadcastd m9, [base+z_filter_k+4*2+12*2] mova xm5, [base+z_filter_s] vinserti128 m5, [base+z_filter_s+10], 1 ; 00 01 12 23 34 45 56 67 45 56 67 78 89 9a ab bc vinserti128 m1, [tlq+11], 1 movu xm6, [base+z_filter_s+12] vinserti128 m6, [base+z_filter_s+22], 1 ; 56 67 78 89 9a ab bc cd ab bc cd de ef ff ff ff movu xm3, [tlq+ 6] vinserti128 m3, [tlq+17], 1 movd xm0, r6m ; max_width pminsw xm0, xm15 vpbroadcastb m10, xm0 .w32_filter_above: pshufb m0, m1, m5 shufps m4, m5, m6, q1021 ; 12 23 34 45 56 67 78 89 67 78 89 9a ab bc cd de pmaddubsw m0, m7 pshufb m2, m1, m4 shufps m5, m6, q2132 ; 34 45 56 67 78 89 9a ab 89 9a ab bc cd de ef ff pmaddubsw m2, m8 pshufb m1, m5 pmaddubsw m1, m9 paddw m0, m2 paddw m0, m1 pshufb m1, m3, m4 pmaddubsw m1, m7 pshufb m2, m3, m5 pmaddubsw m2, m8 pshufb m3, m6 pmaddubsw m3, m9 paddw m1, m2 paddw m1, m3 pmulhrsw m0, m13 pmulhrsw m1, m13 psubb m10, [base+pb_1to32] packuswb m0, m1 vpblendvb m0, [tlq+1], m10 movu [rsp+65], m0 jmp .w16_filter_left .w64: mova m2, [tlq+32] mov r3d, [tlq+64] lea r8d, [hq+(3<<8)] mova [rsp+ 96], m2 mov [rsp+128], r3d test angled, 0x400 jnz .w16_main vpbroadcastd m7, [base+z_filter_k+4*2+12*0] vpbroadcastd m8, [base+z_filter_k+4*2+12*1] vpbroadcastd m9, [base+z_filter_k+4*2+12*2] movu xm6, [base+z_filter_s+ 4] vinserti128 m6, [base+z_filter_s+10], 1 ; 12 23 34 45 56 67 78 89 45 56 67 78 89 9a ab bc movu xm3, [tlq+30] vinserti128 m3, [tlq+43], 1 movu xm5, [base+z_filter_s+16] vinserti128 m5, [base+z_filter_s+22], 1 ; 78 89 9a ab bc cd de ef ab bc cd de ef ff ff ff pshufb m0, m3, m6 shufps m4, m6, m5, q1021 ; 34 45 56 67 78 89 9a ab 67 78 89 9a ab bc cd de pmaddubsw m0, m7 pshufb m2, m3, m4 shufps m6, m5, q2132 ; 56 67 78 89 9a ab bc cd 89 9a ab bc cd de ef ff pmaddubsw m2, m8 pshufb m3, m6 pmaddubsw m3, m9 paddw m0, m2 paddw m0, m3 movu xm2, [tlq+36] vinserti128 m2, [tlq+49], 1 pshufb m4, m2, m4 pmaddubsw m4, m7 pshufb m3, m2, m6 pmaddubsw m3, m8 pshufb m2, m5 pmaddubsw m2, m9 movd xm5, r6m ; max_width pminsw xm5, xm15 vpbroadcastb m10, xm5 paddw m3, m4 paddw m2, m3 vpbroadcastd m3, [base+pb_32] pmulhrsw m0, m13 pmulhrsw m2, m13 mova xm5, [base+z_filter_s] vinserti128 m5, [base+z_filter_s+6], 1 psubb m3, m10, m3 psubb m3, [base+pb_1to32] vinserti128 m1, [tlq+13], 1 packuswb m0, m2 vpblendvb m0, [tlq+33], m3 movu xm3, [tlq+ 6] vinserti128 m3, [tlq+19], 1 movu [rsp+97], m0 jmp .w32_filter_above cglobal ipred_z3, 4, 9, 0, dst, stride, tl, w, h, angle, dy, org_w, maxbase %assign org_stack_offset stack_offset lea r6, [ipred_z3_avx2_table] tzcnt hd, hm movifnidn angled, anglem lea r7, [dr_intra_derivative+45*2-1] dec tlq movsxd hq, [r6+hq*4] sub angled, 180 add hq, r6 mov dyd, angled neg dyd xor angled, 0x400 or dyq, ~0x7e movzx dyd, word [r7+dyq] vpbroadcastd m3, [pw_512] vpbroadcastd m4, [pw_62] vpbroadcastd m5, [pw_64] mov org_wd, wd jmp hq .h4: lea r7, [strideq*3] cmp angleb, 40 jae .h4_no_upsample lea r4d, [angleq-1024] sar r4d, 7 add r4d, wd jg .h4_no_upsample ; !enable_intra_edge_filter || w > 8 || (w == 8 && is_sm) ALLOC_STACK -32, 9 movu xm8, [tlq-7] pshufb xm0, xm8, [z_upsample1-4] vpbroadcastb xm2, xm8 pshufb xm1, xm8, [z_filter_s+2] mova [rsp+16], xm2 ; top[max_base_y] vpbroadcastd xm2, [pb_36_m4] add dyd, dyd pmaddubsw xm0, xm2 pmaddubsw xm1, xm2 movd xm7, dyd mov r2d, dyd vpbroadcastw m7, xm7 paddw xm1, xm0 pmulhrsw xm1, xm3 pslldq m6, m7, 8 paddw xm2, xm7, xm7 paddw m6, m7 packuswb xm1, xm1 paddw m6, m2 punpcklbw xm1, xm8 mova xm8, [z_transpose4] psllw m7, 2 pshufb xm1, [pb_15to0] mova [rsp], xm1 .h4_upsample_loop: lea r4d, [r2+dyq] shr r2d, 6 vpbroadcastq m1, [rsp+r2] lea r2d, [r4+dyq] shr r4d, 6 vpbroadcastq m2, [rsp+r4] lea r4d, [r2+dyq] shr r2d, 6 movq xm0, [rsp+r2] lea r2d, [r4+dyq] shr r4d, 6 movhps xm0, [rsp+r4] vpblendd m1, m2, 0xc0 pand m2, m4, m6 vpblendd m0, m1, 0xf0 psubw m1, m5, m2 psllw m2, 8 por m1, m2 pmaddubsw m0, m1 paddw m6, m7 pmulhrsw m0, m3 vextracti128 xm1, m0, 1 packuswb xm1, xm0 pshufb xm1, xm8 movd [dstq+strideq*0], xm1 pextrd [dstq+strideq*1], xm1, 1 pextrd [dstq+strideq*2], xm1, 2 pextrd [dstq+r7 ], xm1, 3 add dstq, 4 sub wd, 4 jg .h4_upsample_loop RET ALIGN function_align .filter_strength: ; h4/h8/h16 %define base r4-z_filter_t0 lea r4, [z_filter_t0] movd xm0, maxbased movd xm2, angled shr angled, 8 ; is_sm << 1 vpbroadcastb m0, xm0 vpbroadcastb m2, xm2 pcmpeqb m1, m0, [base+z_filter_wh] pand m1, m2 mova xm2, [r4+angleq*8] pcmpgtb m1, m2 pmovmskb r5d, m1 popcnt r5d, r5d ret .h4_no_upsample: %assign stack_offset org_stack_offset ALLOC_STACK -16, 12 mov maxbased, 7 test angled, 0x400 ; !enable_intra_edge_filter jnz .h4_main lea maxbased, [wq+3] call .filter_strength mov maxbased, 7 jz .h4_main ; filter_strength == 0 vpbroadcastd m7, [base+pb_7] vbroadcasti128 m2, [tlq-14] pmaxub m1, m7, [base+z_filter_s-4] vpbroadcastd m8, [base+z_filter_k-4+r5*4+12*0] pmaxub m7, [base+z_filter_s+4] vpbroadcastd m9, [base+z_filter_k-4+r5*4+12*1] vpbroadcastd m10, [base+z_filter_k-4+r5*4+12*2] pshufb m0, m2, m1 shufps m1, m7, q2121 pmaddubsw m0, m8 pshufb m1, m2, m1 pmaddubsw m1, m9 pshufb m2, m7 pmaddubsw m2, m10 paddw m0, m1 paddw m0, m2 pmulhrsw m0, m3 mov r4d, 9 lea tlq, [rsp+15] cmp wd, 4 cmovne maxbased, r4d vextracti128 xm1, m0, 1 packuswb xm0, xm1 mova [rsp], xm0 .h4_main: movd xm6, dyd vpbroadcastq m0, [z_base_inc] ; base_inc << 6 mov r4, tlq sub tlq, 4 neg dyq vpbroadcastw m6, xm6 sub r4, maxbaseq shl maxbased, 6 vpbroadcastb m7, [r4] lea r4, [dyq+63] ; ypos movd xm9, maxbased not maxbased vbroadcasti128 m8, [z3_shuf_w4] add maxbased, 64 vpbroadcastw m9, xm9 psrlw m7, 8 ; top[max_base_y] paddw m10, m6, m6 psubw m9, m0 ; max_base_y vpblendd m6, m10, 0xcc mova xm0, xm10 paddw m6, m0 ; ypos2 ypos3 ypos0 ypos1 paddw m10, m10 mova xm11, [z_transpose4] .h4_loop: lea r5, [r4+dyq] sar r4, 6 ; base0 vpbroadcastq m1, [tlq+r4] lea r4, [r5+dyq] sar r5, 6 ; base1 vpbroadcastq m2, [tlq+r5] lea r5, [r4+dyq] sar r4, 6 ; base2 movq xm0, [tlq+r4] lea r4, [r5+dyq] sar r5, 6 ; base3 movhps xm0, [tlq+r5] vpblendd m1, m2, 0xc0 pand m2, m4, m6 ; frac vpblendd m0, m1, 0xf0 psubw m1, m5, m2 ; 64-frac psllw m2, 8 pshufb m0, m8 por m1, m2 ; 64-frac, frac pmaddubsw m0, m1 pcmpgtw m1, m9, m6 ; base < max_base_y pmulhrsw m0, m3 paddw m6, m10 ; ypos += dy vpblendvb m0, m7, m0, m1 vextracti128 xm1, m0, 1 packuswb xm1, xm0 pshufb xm1, xm11 ; transpose movd [dstq+strideq*0], xm1 pextrd [dstq+strideq*1], xm1, 1 pextrd [dstq+strideq*2], xm1, 2 pextrd [dstq+r7 ], xm1, 3 sub wd, 4 jz .h4_end add dstq, 4 cmp r4d, maxbased jg .h4_loop packuswb xm7, xm7 .h4_end_loop: movd [dstq+strideq*0], xm7 movd [dstq+strideq*1], xm7 movd [dstq+strideq*2], xm7 movd [dstq+r7 ], xm7 add dstq, 4 sub wd, 4 jg .h4_end_loop .h4_end: RET ALIGN function_align .h8: lea r4d, [angleq+216] mov r4b, wb cmp r4d, 8 ja .h8_no_upsample ; !enable_intra_edge_filter || is_sm || d >= 40 || w > 8 %assign stack_offset org_stack_offset ALLOC_STACK -32, 8 and r4d, 4 mova xm0, [tlq-15] vinserti128 m0, [tlq- 9], 1 movd xm1, r4d movu xm2, [z_filter_s+2] vinserti128 m2, [z_filter_s+6], 1 vpbroadcastb xm1, xm1 ; w & 4 vpbroadcastd m7, [pb_36_m4] pmaxub xm1, [z_upsample1-4] ; clip 4x8 vinserti128 m1, [z_upsample1], 1 add dyd, dyd pshufb m1, m0, m1 pshufb m2, m0, m2 vinserti128 m0, [tlq-7], 1 movd xm6, dyd pmaddubsw m1, m7 pmaddubsw m2, m7 vpbroadcastw m6, xm6 mov r2d, dyd lea r5, [strideq*3] paddw m7, m6, m6 paddw m1, m2 vpblendd m6, m7, 0xf0 pmulhrsw m1, m3 pslldq m2, m7, 8 paddw m7, m7 paddw m6, m2 vbroadcasti128 m2, [pb_15to0] packuswb m1, m1 punpcklbw m1, m0 pshufb m1, m2 vextracti128 [rsp+ 0], m1, 1 mova [rsp+16], xm1 .h8_upsample_loop: lea r4d, [r2+dyq] shr r2d, 6 ; base0 movu xm0, [rsp+r2] lea r2d, [r4+dyq] shr r4d, 6 ; base1 vinserti128 m0, [rsp+r4], 1 lea r4d, [r2+dyq] shr r2d, 6 ; base2 pand m1, m4, m6 psubw m2, m5, m1 psllw m1, 8 por m2, m1 punpcklqdq m1, m2, m2 ; frac0 frac1 pmaddubsw m0, m1 movu xm1, [rsp+r2] lea r2d, [r4+dyq] shr r4d, 6 ; base3 vinserti128 m1, [rsp+r4], 1 punpckhqdq m2, m2 ; frac2 frac3 pmaddubsw m1, m2 pmulhrsw m0, m3 paddw m6, m7 pmulhrsw m1, m3 lea r4, [dstq+strideq*4] psllw m1, 8 por m0, m1 vextracti128 xm1, m0, 1 punpcklbw xm2, xm0, xm1 punpckhbw xm0, xm1 movd [dstq+strideq*0], xm2 pextrd [dstq+strideq*1], xm2, 1 pextrd [dstq+strideq*2], xm2, 2 pextrd [dstq+r5 ], xm2, 3 movd [r4 +strideq*0], xm0 pextrd [r4 +strideq*1], xm0, 1 pextrd [r4 +strideq*2], xm0, 2 pextrd [r4 +r5 ], xm0, 3 add dstq, 4 sub wd, 4 jg .h8_upsample_loop RET .h8_no_intra_edge_filter: and maxbased, 7 or maxbased, 8 ; imin(w+7, 15) jmp .h8_main .h8_no_upsample: %assign stack_offset org_stack_offset ALLOC_STACK -32, 10 lea maxbased, [wq+7] test angled, 0x400 jnz .h8_no_intra_edge_filter call .filter_strength jz .h8_main ; filter_strength == 0 vpbroadcastd xm6, [base+pb_15] pcmpeqb xm1, xm1 psubusb xm6, xm0 psubb xm6, xm1 ; w == 4 ? 5 : 1 movu xm2, [tlq-16] pmaxub xm1, xm6, [base+z_filter_s] vinserti128 m2, [tlq-14], 1 vinserti128 m1, [base+z_filter_s+12], 1 vpbroadcastd m7, [base+z_filter_k-4+r5*4+12*0] pmaxub xm6, [base+z_filter_s+ 8] vinserti128 m6, [base+z_filter_s+20], 1 pshufb m0, m2, m1 pmaddubsw m0, m7 vpbroadcastd m7, [base+z_filter_k-4+r5*4+12*1] movzx r4d, byte [tlq-15] shufps m1, m6, q2121 pshufb m1, m2, m1 pmaddubsw m1, m7 paddw m0, m1 sub r5d, 3 jnz .h8_3tap vpbroadcastd m7, [z_filter_k+4*8] movzx r2d, byte [tlq-14] pshufb m2, m6 pmaddubsw m2, m7 sub r2d, r4d lea r2d, [r2+r4*8+4] shr r2d, 3 mov [rsp+15], r2b paddw m0, m2 .h8_3tap: pmulhrsw m0, m3 sar r5d, 1 lea tlq, [rsp+31] add r5d, 17 cmp wd, 16 cmovns maxbased, r5d neg r5 mov [tlq+r5], r4b vextracti128 xm1, m0, 1 packuswb xm0, xm1 mova [tlq-15], xm0 .h8_main: movd xm2, dyd vbroadcasti128 m0, [z_base_inc] mov r4, tlq sub tlq, 8 neg dyq vpbroadcastw m2, xm2 sub r4, maxbaseq shl maxbased, 6 vpbroadcastb m7, [r4] lea r4, [dyq+63] movd xm9, maxbased not maxbased vbroadcasti128 m8, [z3_shuf] add maxbased, 64 vpbroadcastw m9, xm9 psrlw m7, 8 psubw m9, m0 paddw m6, m2, m2 vpblendd m2, m6, 0x0f .h8_loop: lea r5, [r4+dyq] sar r4, 6 pand m0, m4, m2 psubw m1, m5, m0 psllw m0, 8 por m1, m0 vbroadcasti128 m0, [tlq+r4] lea r4, [r5+dyq] sar r5, 6 vinserti128 m0, [tlq+r5], 0 sub rsp, 8*2 pshufb m0, m8 pmaddubsw m0, m1 pcmpgtw m1, m9, m2 paddw m2, m6 pmulhrsw m0, m3 vpblendvb m0, m7, m0, m1 vextracti128 xm1, m0, 1 psllw xm0, 8 por xm0, xm1 ; interleave rows (partial transpose) mova [rsp], xm0 sub wd, 2 jz .h8_transpose cmp r4d, maxbased jg .h8_loop packuswb xm0, xm7, xm7 .h8_end_loop: sub rsp, 8*2 mova [rsp], xm0 sub wd, 2 jg .h8_end_loop .h8_transpose: mova xm2, [rsp+16*1] sub org_wd, 8 lea r2, [strideq*3] lea r6, [dstq+org_wq] cmovns dstq, r6 punpcklwd xm1, xm2, xm0 punpckhwd xm2, xm0 lea r6, [dstq+strideq*4] jge .h8_w8 add rsp, 16*2 movd [dstq+strideq*0], xm1 pextrd [dstq+strideq*1], xm1, 1 pextrd [dstq+strideq*2], xm1, 2 pextrd [dstq+r2 ], xm1, 3 movd [r6 +strideq*0], xm2 pextrd [r6 +strideq*1], xm2, 1 pextrd [r6 +strideq*2], xm2, 2 pextrd [r6 +r2 ], xm2, 3 jmp .h8_end .h8_w8_loop: mova xm0, [rsp+16*0] mova xm2, [rsp+16*1] punpcklwd xm1, xm2, xm0 punpckhwd xm2, xm0 .h8_w8: ; w8/w16/w32 mova xm0, [rsp+16*2] mova xm4, [rsp+16*3] add rsp, 16*4 punpcklwd xm3, xm4, xm0 punpckhwd xm4, xm0 punpckldq xm0, xm3, xm1 punpckhdq xm3, xm1 punpckldq xm1, xm4, xm2 punpckhdq xm4, xm2 movq [dstq+strideq*0], xm0 movhps [dstq+strideq*1], xm0 movq [dstq+strideq*2], xm3 movhps [dstq+r2 ], xm3 movq [r6 +strideq*0], xm1 movhps [r6 +strideq*1], xm1 movq [r6 +strideq*2], xm4 movhps [r6 +r2 ], xm4 sub dstq, 8 sub r6, 8 sub org_wd, 8 jge .h8_w8_loop .h8_end: RET .h16_no_intra_edge_filter: and maxbased, 15 or maxbased, 16 ; imin(w+15, 31) jmp .h16_main ALIGN function_align .h16: %assign stack_offset org_stack_offset ALLOC_STACK -64, 12 lea maxbased, [wq+15] test angled, 0x400 jnz .h16_no_intra_edge_filter call .filter_strength jz .h16_main ; filter_strength == 0 vpbroadcastd m11, [base+pb_27] vpbroadcastd m1, [base+pb_1] vbroadcasti128 m6, [base+z_filter_s+12] vinserti128 m2, m6, [base+z_filter_s+4], 0 vinserti128 m6, [base+z_filter_s+20], 1 movu xm10, [tlq-18] vinserti128 m10, [tlq-14], 1 vpbroadcastd m9, [base+z_filter_k-4+r5*4+12*0] vbroadcasti128 m7, [base+z_filter_s+8] vinserti128 m8, m7, [base+z_filter_s+0], 0 vinserti128 m7, [base+z_filter_s+16], 1 psubusb m11, m0 por m1, m11 movu xm11, [tlq-32] vinserti128 m11, [tlq-28], 1 pmaxub m8, m1 pmaxub m7, m1 pshufb m0, m10, m2 shufps m2, m6, q2121 pmaddubsw m0, m9 pshufb m1, m11, m8 shufps m8, m7, q2121 pmaddubsw m1, m9 vpbroadcastd m9, [base+z_filter_k-4+r5*4+12*1] movzx r4d, byte [tlq-31] pshufb m2, m10, m2 pmaddubsw m2, m9 pshufb m8, m11, m8 pmaddubsw m8, m9 paddw m0, m2 paddw m1, m8 sub r5d, 3 jnz .h16_3tap vpbroadcastd m9, [z_filter_k+4*8] movzx r2d, byte [tlq-30] pshufb m10, m6 pmaddubsw m10, m9 pshufb m11, m7 pmaddubsw m11, m9 sub r2d, r4d lea r2d, [r2+r4*8+4] shr r2d, 3 mov [rsp+31], r2b paddw m0, m10 paddw m1, m11 .h16_3tap: pmulhrsw m0, m3 pmulhrsw m1, m3 sar r5d, 1 lea tlq, [rsp+63] add r5d, 33 cmp wd, 32 cmovns maxbased, r5d neg r5 mov [tlq+r5], r4b packuswb m0, m1 vpermq m0, m0, q2031 mova [tlq-31], m0 .h16_main: movd xm6, dyd vbroadcasti128 m0, [z_base_inc] mov r4, tlq sub tlq, 8 neg dyq vpbroadcastw m6, xm6 sub r4, maxbaseq shl maxbased, 6 vpbroadcastb m7, [r4] lea r4, [dyq+63] movd xm9, maxbased not maxbased vbroadcasti128 m8, [z3_shuf] add maxbased, 64 vpbroadcastw m9, xm9 psubw m9, m0 paddw m11, m6, m6 psubw m10, m9, m3 ; 64*8 vpblendd m6, m11, 0xf0 .h16_loop: lea r5, [r4+dyq] sar r4, 6 pand m1, m4, m6 psubw m2, m5, m1 psllw m1, 8 por m2, m1 movu xm0, [tlq+r4-0] movu xm1, [tlq+r4-8] lea r4, [r5+dyq] sar r5, 6 vinserti128 m0, [tlq+r5-0], 1 vinserti128 m1, [tlq+r5-8], 1 sub rsp, 32 pshufb m0, m8 pshufb m1, m8 pmaddubsw m0, m2 pmaddubsw m1, m2 pmulhrsw m0, m3 pmulhrsw m1, m3 packuswb m0, m1 pcmpgtw m1, m9, m6 pcmpgtw m2, m10, m6 packsswb m1, m2 paddw m6, m11 vpblendvb m0, m7, m0, m1 vpermq m0, m0, q3120 mova [rsp], m0 sub wd, 2 jz .h16_transpose cmp r4d, maxbased jg .h16_loop mova m0, m7 .h16_end_loop: sub rsp, 32 mova [rsp], m7 sub wd, 2 jg .h16_end_loop .h16_transpose: mova m2, [rsp+32*1] sub org_wd, 8 lea r2, [strideq*3] lea r6, [dstq+org_wq] cmovns dstq, r6 punpcklbw m1, m2, m0 punpckhbw m2, m0 lea r3, [strideq*5] punpcklbw m0, m1, m2 punpckhbw m1, m2 lea r4, [strideq+r2*2] ; stride*7 jge .h16_w8 add rsp, 32*2 movd [dstq+strideq*0], xm0 pextrd [dstq+strideq*1], xm0, 1 pextrd [dstq+strideq*2], xm0, 2 pextrd [dstq+r2 ], xm0, 3 vextracti128 xm0, m0, 1 movd [dstq+strideq*4], xm1 pextrd [dstq+r3 ], xm1, 1 pextrd [dstq+r2*2 ], xm1, 2 pextrd [dstq+r4 ], xm1, 3 lea dstq, [dstq+strideq*8] vextracti128 xm1, m1, 1 movd [dstq+strideq*0], xm0 pextrd [dstq+strideq*1], xm0, 1 pextrd [dstq+strideq*2], xm0, 2 pextrd [dstq+r2 ], xm0, 3 movd [dstq+strideq*4], xm1 pextrd [dstq+r3 ], xm1, 1 pextrd [dstq+r2*2 ], xm1, 2 pextrd [dstq+r4 ], xm1, 3 jmp .h16_end .h16_w8_loop: mova m0, [rsp+32*0] mova m2, [rsp+32*1] punpcklbw m1, m2, m0 punpckhbw m2, m0 punpcklbw m0, m1, m2 punpckhbw m1, m2 .h16_w8: mova m2, [rsp+32*2] mova m4, [rsp+32*3] lea r6, [dstq+strideq*8] add rsp, 32*4 punpcklbw m3, m4, m2 punpckhbw m4, m2 punpcklbw m2, m3, m4 punpckhbw m3, m4 punpckldq m4, m2, m0 punpckhdq m2, m0 punpckldq m0, m3, m1 punpckhdq m3, m1 movq [dstq+strideq*0], xm4 movhps [dstq+strideq*1], xm4 vextracti128 xm4, m4, 1 movq [dstq+strideq*2], xm2 movhps [dstq+r2 ], xm2 vextracti128 xm2, m2, 1 movq [dstq+strideq*4], xm0 movhps [dstq+r3 ], xm0 vextracti128 xm0, m0, 1 movq [dstq+r2*2 ], xm3 movhps [dstq+r4 ], xm3 vextracti128 xm3, m3, 1 movq [r6+strideq*0], xm4 movhps [r6+strideq*1], xm4 movq [r6+strideq*2], xm2 movhps [r6+r2 ], xm2 movq [r6+strideq*4], xm0 movhps [r6+r3 ], xm0 movq [r6+r2*2 ], xm3 movhps [r6+r4 ], xm3 sub dstq, 8 sub org_wd, 8 jge .h16_w8_loop .h16_end: RET ALIGN function_align .h32: %assign stack_offset org_stack_offset ALLOC_STACK -96, 15 lea maxbased, [wq+31] and maxbased, 31 or maxbased, 32 ; imin(w+31, 63) test angled, 0x400 ; !enable_intra_edge_filter jnz .h32_main vbroadcasti128 m0, [pb_0to15] mov r4d, 21 mov r5d, 3 movu xm11, [tlq-66] ; 56-63 vinserti128 m11, [tlq-52], 1 ; 40-47 sub r4d, wd ; 21-w cmovns r5d, r4d movu xm12, [tlq-58] ; 48-55 vinserti128 m12, [tlq-44], 1 ; 32-39 sub r4d, 8 ; 13-w movd xm1, r5d movu xm13, [tlq-34] ; 24-31 vinserti128 m13, [tlq-20], 1 ; 8-15 movd xm2, r4d vpbroadcastb m1, xm1 movu xm14, [tlq-28] ; 16-23 vinserti128 m14, [tlq-14], 1 ; 0- 7 vpbroadcastb m2, xm2 pmaxsb m1, m0 ; clip 16x32 and (32|64)x32 movu m7, [z_filter_s+4] pshufb m11, m1 vinserti128 m8, m7, [z_filter_s+8], 1 vinserti128 m7, [z_filter_s+16], 0 pmaxsb m2, m0 ; clip 8x32 vpbroadcastd m9, [z_filter_k+4*2+12*0] pshufb m12, m2 pshufb m0, m11, m8 pmaddubsw m0, m9 pshufb m2, m12, m8 pmaddubsw m2, m9 pshufb m1, m13, m8 pmaddubsw m1, m9 shufps m8, m7, q1021 pshufb m6, m14, m8 pmaddubsw m6, m9 vpbroadcastd m9, [z_filter_k+4*2+12*1] pshufb m10, m11, m8 pmaddubsw m10, m9 paddw m0, m10 pshufb m10, m12, m8 pmaddubsw m10, m9 paddw m2, m10 pshufb m10, m13, m8 pmaddubsw m10, m9 shufps m8, m7, q2121 paddw m1, m10 pshufb m10, m14, m8 pmaddubsw m10, m9 paddw m6, m10 vpbroadcastd m9, [z_filter_k+4*2+12*2] pshufb m11, m8 pmaddubsw m11, m9 pshufb m12, m8 pmaddubsw m12, m9 movzx r4d, byte [tlq-63] movzx r2d, byte [tlq-62] paddw m0, m11 paddw m2, m12 pshufb m13, m8 pmaddubsw m13, m9 pshufb m14, m7 pmaddubsw m14, m9 paddw m1, m13 paddw m6, m14 sub r2d, r4d lea r2d, [r2+r4*8+4] ; edge case for 64x32 pmulhrsw m0, m3 pmulhrsw m2, m3 pmulhrsw m1, m3 pmulhrsw m6, m3 shr r2d, 3 mov [rsp+31], r2b lea tlq, [rsp+95] mov [tlq-65], r4b mov r4d, 65 cmp wd, 64 cmove maxbased, r4d packuswb m0, m2 packuswb m1, m6 mova [tlq-63], m0 mova [tlq-31], m1 .h32_main: movd xm6, dyd mov r4, tlq sub tlq, 8 neg dyq vpbroadcastw m6, xm6 sub r4, maxbaseq shl maxbased, 6 vpbroadcastb m7, [r4] lea r4, [dyq+63] movd xm9, maxbased not maxbased vbroadcasti128 m8, [z3_shuf] add maxbased, 64 vpbroadcastw m9, xm9 psubw m9, [z_base_inc] mova m11, m6 psubw m10, m9, m3 ; 64*8 .h32_loop: mov r5, r4 sar r5, 6 pand m1, m4, m6 psubw m2, m5, m1 psllw m1, 8 por m2, m1 movu xm0, [tlq+r5- 0] vinserti128 m0, [tlq+r5-16], 1 movu xm1, [tlq+r5- 8] vinserti128 m1, [tlq+r5-24], 1 sub rsp, 32 add r4, dyq pshufb m0, m8 pshufb m1, m8 pmaddubsw m0, m2 pmaddubsw m1, m2 pmulhrsw m0, m3 pmulhrsw m1, m3 packuswb m0, m1 pcmpgtw m1, m9, m6 pcmpgtw m2, m10, m6 packsswb m1, m2 paddw m6, m11 vpblendvb m0, m7, m0, m1 mova [rsp], m0 dec wd jz .h32_transpose cmp r4d, maxbased jg .h32_loop .h32_end_loop: sub rsp, 32 mova [rsp], m7 dec wd jg .h32_end_loop .h32_transpose: lea dstq, [dstq+org_wq-8] lea r2, [strideq*3] lea r3, [strideq*5] lea r4, [strideq+r2*2] ; stride*7 .h32_w8_loop: mova m7, [rsp+32*0] mova m6, [rsp+32*1] mova m5, [rsp+32*2] mova m4, [rsp+32*3] mova m3, [rsp+32*4] mova m2, [rsp+32*5] mova m1, [rsp+32*6] mova m0, [rsp+32*7] lea r6, [dstq+strideq*8] add rsp, 32*8 punpcklbw m8, m0, m1 punpckhbw m0, m1 punpcklbw m1, m2, m3 punpckhbw m2, m3 punpcklbw m3, m4, m5 punpckhbw m4, m5 punpcklbw m5, m6, m7 punpckhbw m6, m7 punpcklwd m7, m8, m1 punpckhwd m8, m1 punpcklwd m1, m0, m2 punpckhwd m0, m2 punpcklwd m2, m3, m5 punpckhwd m3, m5 punpcklwd m5, m4, m6 punpckhwd m4, m6 punpckldq m6, m7, m2 punpckhdq m7, m2 punpckldq m2, m8, m3 punpckhdq m8, m3 punpckldq m3, m1, m5 punpckhdq m1, m5 punpckldq m5, m0, m4 punpckhdq m0, m4 movq [dstq+strideq*0], xm6 movhps [dstq+strideq*1], xm6 vextracti128 xm6, m6, 1 movq [dstq+strideq*2], xm7 movhps [dstq+r2 ], xm7 vextracti128 xm7, m7, 1 movq [dstq+strideq*4], xm2 movhps [dstq+r3 ], xm2 vextracti128 xm2, m2, 1 movq [dstq+r2*2 ], xm8 movhps [dstq+r4 ], xm8 vextracti128 xm8, m8, 1 movq [r6+strideq*0], xm3 movhps [r6+strideq*1], xm3 vextracti128 xm3, m3, 1 movq [r6+strideq*2], xm1 movhps [r6+r2 ], xm1 vextracti128 xm1, m1, 1 movq [r6+strideq*4], xm5 movhps [r6+r3 ], xm5 vextracti128 xm5, m5, 1 movq [r6+r2*2 ], xm0 movhps [r6+r4 ], xm0 lea r6, [r6+strideq*8] vextracti128 xm0, m0, 1 movq [r6+strideq*0], xm6 movhps [r6+strideq*1], xm6 movq [r6+strideq*2], xm7 movhps [r6+r2 ], xm7 movq [r6+strideq*4], xm2 movhps [r6+r3 ], xm2 movq [r6+r2*2 ], xm8 movhps [r6+r4 ], xm8 lea r6, [r6+strideq*8] movq [r6+strideq*0], xm3 movhps [r6+strideq*1], xm3 movq [r6+strideq*2], xm1 movhps [r6+r2 ], xm1 movq [r6+strideq*4], xm5 movhps [r6+r3 ], xm5 movq [r6+r2*2 ], xm0 movhps [r6+r4 ], xm0 sub dstq, 8 sub org_wd, 8 jg .h32_w8_loop RET ALIGN function_align .h64: %assign stack_offset org_stack_offset ALLOC_STACK -128, 16 lea maxbased, [wq+63] test angled, 0x400 ; !enable_intra_edge_filter jnz .h64_main mov r4d, 21 vpbroadcastb xm11, [tlq-127] vpblendd xm11, [tlq-130], 0x0e ; 120-127 sub r4d, wd ; 21-w mov r5d, 3 vinserti128 m11, [tlq-116], 1 ; 104-111 movu m7, [z_filter_s+4] cmp wd, 32 cmove r4d, r5d vinserti128 m8, m7, [z_filter_s+8], 1 vbroadcasti128 m6, [pb_0to15] movd xm1, r4d vpbroadcastd m9, [z_filter_k+4*2+12*0] movu xm12, [tlq-122] ; 112-119 vinserti128 m12, [tlq-108], 1 ; 96-103 vpbroadcastb m1, xm1 movu xm13, [tlq- 98] ; 88- 95 vinserti128 m13, [tlq- 84], 1 ; 72- 79 movu xm14, [tlq- 90] ; 80- 87 vinserti128 m14, [tlq- 76], 1 ; 64- 71 vinserti128 m7, [z_filter_s+16], 0 pshufb m0, m11, m8 pmaddubsw m0, m9 pshufb m2, m12, m8 pmaddubsw m2, m9 pmaxsb m1, m6 ; clip (16|32)x64 pshufb m13, m1 pshufb m1, m13, m8 pmaddubsw m1, m9 pshufb m6, m14, m8 pmaddubsw m6, m9 vpbroadcastd m9, [z_filter_k+4*2+12*1] shufps m15, m8, m7, q1021 pshufb m10, m11, m15 pmaddubsw m10, m9 paddw m0, m10 pshufb m10, m12, m15 pmaddubsw m10, m9 paddw m2, m10 pshufb m10, m13, m15 pmaddubsw m10, m9 paddw m1, m10 pshufb m10, m14, m15 pmaddubsw m10, m9 paddw m6, m10 vpbroadcastd m9, [z_filter_k+4*2+12*2] shufps m10, m8, m7, q2132 pshufb m11, m10 pmaddubsw m11, m9 pshufb m12, m10 pmaddubsw m12, m9 pshufb m13, m10 pmaddubsw m13, m9 pshufb m14, m10 pmaddubsw m14, m9 paddw m0, m11 paddw m2, m12 paddw m1, m13 paddw m6, m14 movu xm11, [tlq-66] ; 56-63 vinserti128 m11, [tlq-52], 1 ; 40-47 movu xm12, [tlq-58] ; 48-55 vinserti128 m12, [tlq-44], 1 ; 32-39 movu xm13, [tlq-34] ; 24-31 vinserti128 m13, [tlq-20], 1 ; 8-15 movu xm14, [tlq-28] ; 16-23 vinserti128 m14, [tlq-14], 1 ; 0- 7 pmulhrsw m0, m3 pmulhrsw m2, m3 pmulhrsw m1, m3 pmulhrsw m6, m3 lea tlq, [rsp+127] packuswb m0, m2 packuswb m1, m6 mova [tlq-127], m0 mova [tlq- 95], m1 pshufb m0, m11, m10 pmaddubsw m0, m9 pshufb m2, m12, m10 pmaddubsw m2, m9 pshufb m1, m13, m10 pmaddubsw m1, m9 pshufb m6, m14, m7 pmaddubsw m6, m9 vpbroadcastd m9, [z_filter_k+4*2+12*1] pshufb m7, m11, m15 pmaddubsw m7, m9 paddw m0, m7 pshufb m7, m12, m15 pmaddubsw m7, m9 paddw m2, m7 pshufb m7, m13, m15 pmaddubsw m7, m9 paddw m1, m7 pshufb m7, m14, m10 pmaddubsw m7, m9 paddw m6, m7 vpbroadcastd m9, [z_filter_k+4*2+12*0] pshufb m11, m8 pmaddubsw m11, m9 pshufb m12, m8 pmaddubsw m12, m9 pshufb m13, m8 pmaddubsw m13, m9 pshufb m14, m15 pmaddubsw m14, m9 paddw m0, m11 paddw m2, m12 paddw m1, m13 paddw m6, m14 pmulhrsw m0, m3 pmulhrsw m2, m3 pmulhrsw m1, m3 pmulhrsw m6, m3 packuswb m0, m2 packuswb m1, m6 mova [tlq-63], m0 mova [tlq-31], m1 .h64_main: movd xm12, dyd neg maxbaseq vbroadcasti128 m8, [z3_shuf] vpbroadcastb m7, [tlq+maxbaseq] shl maxbased, 6 vpbroadcastw m12, xm12 lea r5d, [dyq+maxbaseq-64] neg dyq or maxbased, 63 lea r4, [dyq+63] movd xm6, r5d mova xm10, [pb_1to32+16] vinserti128 m10, [pb_1to32], 1 vpbroadcastd m11, [pb_32] vpbroadcastw m6, xm6 .h64_loop: mov r5, r4 sar r5, 6 movu m0, [tlq+r5-24] movu m1, [tlq+r5-32] pand m2, m4, m6 psubw m9, m5, m2 psllw m2, 8 por m9, m2 pshufb m0, m8 pshufb m1, m8 pmaddubsw m0, m9 pmaddubsw m1, m9 psraw m2, m6, 6 sub rsp, 64 pmulhrsw m0, m3 pmulhrsw m1, m3 packsswb m2, m2 paddb m2, m10 packuswb m0, m1 vpblendvb m0, m7, m0, m2 mova [rsp+32], m0 movu m0, [tlq+r5-56] movu m1, [tlq+r5-64] add r4, dyq pshufb m0, m8 pshufb m1, m8 pmaddubsw m0, m9 pmaddubsw m1, m9 paddb m2, m11 pmulhrsw m0, m3 pmulhrsw m1, m3 paddw m6, m12 packuswb m0, m1 vpblendvb m0, m7, m0, m2 mova [rsp], m0 dec wd jz .h64_transpose cmp r4d, maxbased jg .h64_loop .h64_end_loop: sub rsp, 64 mova [rsp+32], m7 mova [rsp+ 0], m7 dec wd jg .h64_end_loop .h64_transpose: lea r2, [strideq*3] lea r3, [strideq*5] imul r5, strideq, -8 lea dstq, [dstq+org_wq-16] lea r4, [strideq+r2*2] ; stride*7 .h64_transpose_loop0: lea r6, [rsp+16*3] .h64_transpose_loop: mova xm0, [r6+64*15] vinserti128 m0, [r6+64* 7], 1 mova xm1, [r6+64*14] vinserti128 m1, [r6+64* 6], 1 mova xm2, [r6+64*13] vinserti128 m2, [r6+64* 5], 1 mova xm3, [r6+64*12] vinserti128 m3, [r6+64* 4], 1 mova xm4, [r6+64*11] vinserti128 m4, [r6+64* 3], 1 mova xm5, [r6+64*10] vinserti128 m5, [r6+64* 2], 1 mova xm6, [r6+64* 9] vinserti128 m6, [r6+64* 1], 1 mova xm7, [r6+64* 8] vinserti128 m7, [r6+64* 0], 1 sub r6, 16 punpcklbw m8, m0, m1 punpckhbw m0, m1 punpcklbw m1, m2, m3 punpckhbw m2, m3 punpcklbw m3, m4, m5 punpckhbw m4, m5 punpcklbw m5, m6, m7 punpckhbw m6, m7 punpcklwd m7, m8, m1 punpckhwd m8, m1 punpcklwd m1, m0, m2 punpckhwd m0, m2 punpcklwd m2, m3, m5 punpckhwd m3, m5 punpcklwd m5, m4, m6 punpckhwd m4, m6 punpckldq m6, m7, m2 punpckhdq m7, m2 punpckldq m2, m8, m3 punpckhdq m8, m3 punpckldq m3, m1, m5 punpckhdq m1, m5 punpckldq m5, m0, m4 punpckhdq m0, m4 vpermq m6, m6, q3120 vpermq m7, m7, q3120 vpermq m2, m2, q3120 vpermq m8, m8, q3120 vpermq m3, m3, q3120 vpermq m1, m1, q3120 vpermq m5, m5, q3120 vpermq m0, m0, q3120 mova [dstq+strideq*0], xm6 vextracti128 [dstq+strideq*1], m6, 1 mova [dstq+strideq*2], xm7 vextracti128 [dstq+r2 ], m7, 1 mova [dstq+strideq*4], xm2 vextracti128 [dstq+r3 ], m2, 1 mova [dstq+r2*2 ], xm8 vextracti128 [dstq+r4 ], m8, 1 sub dstq, r5 mova [dstq+strideq*0], xm3 vextracti128 [dstq+strideq*1], m3, 1 mova [dstq+strideq*2], xm1 vextracti128 [dstq+r2 ], m1, 1 mova [dstq+strideq*4], xm5 vextracti128 [dstq+r3 ], m5, 1 mova [dstq+r2*2 ], xm0 vextracti128 [dstq+r4 ], m0, 1 sub dstq, r5 cmp r6, rsp jae .h64_transpose_loop add rsp, 64*16 lea dstq, [dstq+r5*8-16] sub org_wd, 16 jg .h64_transpose_loop0 .h64_end: RET %macro FILTER_XMM 4 ; dst, src, tmp, shuf %ifnum %4 pshufb xm%2, xm%4 %else pshufb xm%2, %4 %endif pshufd xm%1, xm%2, q0000 ; p0 p1 pmaddubsw xm%1, xm2 pshufd xm%3, xm%2, q1111 ; p2 p3 pmaddubsw xm%3, xm3 paddw xm%1, xm1 paddw xm%1, xm%3 pshufd xm%3, xm%2, q2222 ; p4 p5 pmaddubsw xm%3, xm4 paddw xm%1, xm%3 pshufd xm%3, xm%2, q3333 ; p6 __ pmaddubsw xm%3, xm5 paddw xm%1, xm%3 psraw xm%1, 4 packuswb xm%1, xm%1 %endmacro %macro FILTER_YMM 4 ; dst, src, tmp, shuf pshufb m%2, m%4 pshufd m%1, m%2, q0000 pmaddubsw m%1, m2 pshufd m%3, m%2, q1111 pmaddubsw m%3, m3 paddw m%1, m1 paddw m%1, m%3 pshufd m%3, m%2, q2222 pmaddubsw m%3, m4 paddw m%1, m%3 pshufd m%3, m%2, q3333 pmaddubsw m%3, m5 paddw m%1, m%3 psraw m%1, 4 vpermq m%3, m%1, q1032 packuswb m%1, m%3 %endmacro ; The ipred_filter SIMD processes 4x2 blocks in the following order which ; increases parallelism compared to doing things row by row. One redundant ; block is calculated for w8 and w16, two for w32. ; w4 w8 w16 w32 ; 1 1 2 1 2 3 5 1 2 3 5 b c d f ; 2 2 3 2 4 5 7 2 4 5 7 c e f h ; 3 3 4 4 6 7 9 4 6 7 9 e g h j ; ___ 4 ___ 4 5 ___ 6 8 9 a ___ 6 8 9 a g i j k ___ ; 5 8 8 i cglobal ipred_filter, 3, 7, 0, dst, stride, tl, w, h, filter %define base r6-ipred_filter_avx2_table lea r6, [filter_intra_taps] tzcnt wd, wm %ifidn filterd, filterm movzx filterd, filterb %else movzx filterd, byte filterm %endif shl filterd, 6 add filterq, r6 lea r6, [ipred_filter_avx2_table] movq xm0, [tlq-3] ; _ 6 5 0 1 2 3 4 movsxd wq, [r6+wq*4] vpbroadcastd m1, [base+pw_8] vbroadcasti128 m2, [filterq+16*0] vbroadcasti128 m3, [filterq+16*1] vbroadcasti128 m4, [filterq+16*2] vbroadcasti128 m5, [filterq+16*3] add wq, r6 mov hd, hm jmp wq .w4: WIN64_SPILL_XMM 9 mova xm8, [base+filter_shuf2] sub tlq, 3 sub tlq, hq jmp .w4_loop_start .w4_loop: pinsrd xm0, xm6, [tlq+hq], 0 lea dstq, [dstq+strideq*2] .w4_loop_start: FILTER_XMM 6, 0, 7, 8 movd [dstq+strideq*0], xm6 pextrd [dstq+strideq*1], xm6, 1 sub hd, 2 jg .w4_loop RET ALIGN function_align .w8: %assign stack_offset stack_offset - stack_size_padded WIN64_SPILL_XMM 10 mova m8, [base+filter_shuf1] FILTER_XMM 7, 0, 6, [base+filter_shuf2] vpbroadcastd m0, [tlq+4] vpbroadcastd m6, [tlq+5] sub tlq, 4 sub tlq, hq vpbroadcastq m7, xm7 vpblendd m7, m6, 0x20 .w8_loop: vpbroadcastd xm6, [tlq+hq] palignr m6, m0, 12 vpblendd m0, m6, m7, 0xeb ; _ _ _ _ 1 2 3 4 6 5 0 _ _ _ _ _ ; 0 _ _ _ 1 2 3 4 _ _ _ 5 _ _ _ 6 mova xm6, xm7 call .main vpblendd xm6, xm7, 0x0c pshufd xm6, xm6, q3120 movq [dstq+strideq*0], xm6 movhps [dstq+strideq*1], xm6 lea dstq, [dstq+strideq*2] sub hd, 2 jg .w8_loop RET ALIGN function_align .w16: %if WIN64 %assign stack_offset stack_offset - stack_size_padded %assign xmm_regs_used 15 %assign stack_size_padded 0x98 SUB rsp, stack_size_padded %endif sub hd, 2 TAIL_CALL .w16_main, 0 .w16_main: %if WIN64 movaps [rsp+0xa8], xmm6 movaps [rsp+0xb8], xmm7 movaps [rsp+0x28], xmm8 movaps [rsp+0x38], xmm9 movaps [rsp+0x48], xmm10 movaps [rsp+0x58], xmm11 movaps [rsp+0x68], xmm12 movaps [rsp+0x78], xmm13 movaps [rsp+0x88], xmm14 %endif FILTER_XMM 12, 0, 7, [base+filter_shuf2] vpbroadcastd m0, [tlq+5] vpblendd m0, [tlq-12], 0x14 mova m8, [base+filter_shuf1] vpbroadcastq m7, xm12 vpblendd m0, m7, 0xc2 ; _ _ _ _ 1 2 3 4 6 5 0 _ _ _ _ _ ; 0 _ _ _ 1 2 3 4 _ _ _ 5 _ _ _ 6 call .main ; c0 d0 a1 b1 a1 b1 c0 d0 movlps xm9, xm7, [tlq+5] ; _ _ _ 0 1 2 3 4 _ _ _ 5 _ _ _ 6 vinserti128 m14, m8, [base+filter_shuf3], 0 vpblendd xm12, xm7, 0x0c ; a0 b0 a1 b1 FILTER_XMM 6, 9, 10, 14 vpbroadcastq m6, xm6 ; a2 b2 __ __ __ __ a2 b2 vpbroadcastd m9, [tlq+13] vpbroadcastd m10, [tlq+12] psrld m11, m8, 4 vpblendd m6, m9, 0x20 ; top sub tlq, 6 sub tlq, hq .w16_loop: vpbroadcastd xm9, [tlq+hq] palignr m9, m0, 12 vpblendd m0, m9, m7, 0xe2 ; _ _ _ _ 1 2 3 4 6 5 0 _ _ _ _ _ ; 0 _ _ _ 1 2 3 4 _ _ _ 5 _ _ _ 6 mova xm13, xm7 call .main ; e0 f0 c1 d1 c1 d1 e0 f0 vpblendd m9, m12, m10, 0xf0 vpblendd m12, m6, 0xc0 pshufd m9, m9, q3333 vpblendd m9, m6, 0xee vpblendd m10, m9, m7, 0x0c ; _ _ _ 0 1 2 3 4 _ _ _ 5 _ _ _ 6 ; 0 _ _ _ 1 2 3 4 _ _ _ 5 _ _ _ 6 FILTER_YMM 6, 10, 9, 14 ; c2 d2 a3 b3 a3 b3 c2 d2 vpblendd m12, m6, 0x30 ; a0 b0 a1 b1 a3 b3 a2 b2 vpermd m9, m11, m12 ; a0 a1 a2 a3 b0 b1 b2 b3 vpblendd xm12, xm13, xm7, 0x0c ; c0 d0 c1 d1 mova [dstq+strideq*0], xm9 vextracti128 [dstq+strideq*1], m9, 1 lea dstq, [dstq+strideq*2] sub hd, 2 jg .w16_loop vpblendd xm7, xm6, xm10, 0x04 ; _ _ _ 5 _ _ _ 6 0 _ _ _ 1 2 3 4 pshufd xm7, xm7, q1032 ; 0 _ _ _ 1 2 3 4 _ _ _ 5 _ _ _ 6 FILTER_XMM 0, 7, 9, [base+filter_shuf1+16] vpblendd xm6, xm0, 0x0c ; c2 d2 c3 d3 shufps xm0, xm12, xm6, q2020 ; c0 c1 c2 c3 shufps xm6, xm12, xm6, q3131 ; d0 d1 d2 d3 mova [dstq+strideq*0], xm0 mova [dstq+strideq*1], xm6 ret ALIGN function_align .w32: sub rsp, stack_size_padded sub hd, 2 lea r3, [dstq+16] lea r5d, [hq-2] call .w16_main add tlq, r5 mov dstq, r3 lea r3, [strideq-4] lea r4, [r3+strideq*2] movq xm0, [tlq+21] pinsrd xm0, [dstq-4], 2 pinsrd xm0, [dstq+r3*1], 3 FILTER_XMM 12, 0, 7, 14 ; a0 b0 a0 b0 movq xm7, [dstq+r3*2] pinsrd xm7, [dstq+r4], 2 palignr xm7, xm0, 12 ; 0 _ _ _ _ _ _ _ _ _ _ 5 _ _ _ 6 vpbroadcastd m0, [tlq+28] vpbroadcastd m9, [tlq+29] vbroadcasti128 m8, [base+filter_shuf1+16] vpblendd m0, m9, 0x20 vpblendd m0, m7, 0x0f vpbroadcastq m7, xm12 vpblendd m0, m7, 0xc2 ; 0 _ _ _ 1 2 3 4 _ _ _ 5 _ _ _ 6 call .main ; c0 d0 a1 b1 a1 b1 c0 d0 add r3, 2 lea r4, [r4+strideq*2] movlps xm9, xm7, [tlq+29] ; _ _ _ 0 1 2 3 4 _ _ _ 5 _ _ _ 6 vpblendd xm12, xm7, 0x0c ; a0 b0 a1 b1 FILTER_XMM 6, 9, 10, 14 vpbroadcastq m6, xm6 ; a2 b2 __ __ __ __ a2 b2 vpbroadcastd m9, [tlq+37] vpbroadcastd m10, [tlq+36] vpblendd m6, m9, 0x20 ; top .w32_loop: movq xm9, [dstq+r3*4] pinsrd xm9, [dstq+r4], 2 .w32_loop_last: palignr m9, m0, 12 vpblendd m0, m9, m7, 0xe2 ; 0 _ _ _ 1 2 3 4 _ _ _ 5 _ _ _ 6 mova xm13, xm7 ; c0 d0 call .main ; e0 f0 c1 d1 c1 d1 e0 f0 vpblendd m9, m12, m10, 0xf0 vpblendd m12, m6, 0xc0 pshufd m9, m9, q3333 vpblendd m9, m6, 0xee vpblendd m10, m9, m7, 0x0c ; _ _ _ 0 1 2 3 4 _ _ _ 5 _ _ _ 6 ; 0 _ _ _ 1 2 3 4 _ _ _ 5 _ _ _ 6 FILTER_YMM 6, 10, 9, 14 ; c2 d2 a3 b3 a3 b3 c2 d2 vpblendd m12, m6, 0x30 ; a0 b0 a1 b1 a3 b3 a2 b2 vpermd m9, m11, m12 ; a0 a1 a2 a3 b0 b1 b2 b3 vpblendd xm12, xm13, xm7, 0x0c ; c0 d0 c1 d1 mova [dstq+strideq*0], xm9 vextracti128 [dstq+strideq*1], m9, 1 lea dstq, [dstq+strideq*2] sub r5d, 2 jg .w32_loop jz .w32_loop_last vpblendd xm7, xm6, xm10, 0x04 ; _ _ _ 5 _ _ _ 6 0 _ _ _ 1 2 3 4 pshufd xm7, xm7, q1032 ; 0 _ _ _ 1 2 3 4 _ _ _ 5 _ _ _ 6 FILTER_XMM 0, 7, 9, [base+filter_shuf1+16] vpblendd xm6, xm0, 0x0c ; c2 d2 c3 d3 shufps xm0, xm12, xm6, q2020 ; c0 c1 c2 c3 shufps xm6, xm12, xm6, q3131 ; d0 d1 d2 d3 mova [dstq+strideq*0], xm0 mova [dstq+strideq*1], xm6 RET ALIGN function_align .main: FILTER_YMM 7, 0, 9, 8 ret %if WIN64 DECLARE_REG_TMP 5 %else DECLARE_REG_TMP 7 %endif %macro IPRED_CFL 1 ; ac in, unpacked pixels out psignw m3, m%1, m1 pabsw m%1, m%1 pmulhrsw m%1, m2 psignw m%1, m3 paddw m%1, m0 %endmacro cglobal ipred_cfl_top, 3, 7, 6, dst, stride, tl, w, h, ac, alpha lea t0, [ipred_cfl_left_avx2_table] tzcnt wd, wm inc tlq movu m0, [tlq] movifnidn hd, hm mov r6d, 0x8000 shrx r6d, r6d, wd movd xm3, r6d movsxd r6, [t0+wq*4] pcmpeqd m2, m2 pmaddubsw m0, m2 add r6, t0 add t0, ipred_cfl_splat_avx2_table-ipred_cfl_left_avx2_table movsxd wq, [t0+wq*4] add wq, t0 movifnidn acq, acmp jmp r6 cglobal ipred_cfl_left, 3, 7, 6, dst, stride, tl, w, h, ac, alpha mov hd, hm ; zero upper half tzcnt r6d, hd sub tlq, hq tzcnt wd, wm movu m0, [tlq] mov t0d, 0x8000 shrx t0d, t0d, r6d movd xm3, t0d lea t0, [ipred_cfl_left_avx2_table] movsxd r6, [t0+r6*4] pcmpeqd m2, m2 pmaddubsw m0, m2 add r6, t0 add t0, ipred_cfl_splat_avx2_table-ipred_cfl_left_avx2_table movsxd wq, [t0+wq*4] add wq, t0 movifnidn acq, acmp jmp r6 .h32: vextracti128 xm1, m0, 1 paddw xm0, xm1 .h16: punpckhqdq xm1, xm0, xm0 paddw xm0, xm1 .h8: psrlq xm1, xm0, 32 paddw xm0, xm1 .h4: pmaddwd xm0, xm2 pmulhrsw xm0, xm3 vpbroadcastw m0, xm0 jmp wq cglobal ipred_cfl, 3, 7, 6, dst, stride, tl, w, h, ac, alpha movifnidn hd, hm movifnidn wd, wm tzcnt r6d, hd lea t0d, [wq+hq] movd xm4, t0d tzcnt t0d, t0d movd xm5, t0d lea t0, [ipred_cfl_avx2_table] tzcnt wd, wd movsxd r6, [t0+r6*4] movsxd wq, [t0+wq*4+4*4] pcmpeqd m3, m3 psrlw xm4, 1 add r6, t0 add wq, t0 movifnidn acq, acmp jmp r6 .h4: movd xm0, [tlq-4] pmaddubsw xm0, xm3 jmp wq .w4: movd xm1, [tlq+1] pmaddubsw xm1, xm3 psubw xm0, xm4 paddw xm0, xm1 pmaddwd xm0, xm3 cmp hd, 4 jg .w4_mul psrlw xm0, 3 jmp .w4_end .w4_mul: punpckhqdq xm1, xm0, xm0 lea r2d, [hq*2] mov r6d, 0x55563334 paddw xm0, xm1 shrx r6d, r6d, r2d psrlq xm1, xm0, 32 paddw xm0, xm1 movd xm1, r6d psrlw xm0, 2 pmulhuw xm0, xm1 .w4_end: vpbroadcastw m0, xm0 .s4: vpbroadcastw m1, alpham lea r6, [strideq*3] pabsw m2, m1 psllw m2, 9 .s4_loop: mova m4, [acq] IPRED_CFL 4 packuswb m4, m4 vextracti128 xm5, m4, 1 movd [dstq+strideq*0], xm4 pextrd [dstq+strideq*1], xm4, 1 movd [dstq+strideq*2], xm5 pextrd [dstq+r6 ], xm5, 1 lea dstq, [dstq+strideq*4] add acq, 32 sub hd, 4 jg .s4_loop RET ALIGN function_align .h8: movq xm0, [tlq-8] pmaddubsw xm0, xm3 jmp wq .w8: movq xm1, [tlq+1] vextracti128 xm2, m0, 1 pmaddubsw xm1, xm3 psubw xm0, xm4 paddw xm0, xm2 punpckhqdq xm2, xm0, xm0 paddw xm0, xm2 paddw xm0, xm1 psrlq xm1, xm0, 32 paddw xm0, xm1 pmaddwd xm0, xm3 psrlw xm0, xm5 cmp hd, 8 je .w8_end mov r6d, 0x5556 mov r2d, 0x3334 cmp hd, 32 cmove r6d, r2d movd xm1, r6d pmulhuw xm0, xm1 .w8_end: vpbroadcastw m0, xm0 .s8: vpbroadcastw m1, alpham lea r6, [strideq*3] pabsw m2, m1 psllw m2, 9 .s8_loop: mova m4, [acq] mova m5, [acq+32] IPRED_CFL 4 IPRED_CFL 5 packuswb m4, m5 vextracti128 xm5, m4, 1 movq [dstq+strideq*0], xm4 movq [dstq+strideq*1], xm5 movhps [dstq+strideq*2], xm4 movhps [dstq+r6 ], xm5 lea dstq, [dstq+strideq*4] add acq, 64 sub hd, 4 jg .s8_loop RET ALIGN function_align .h16: mova xm0, [tlq-16] pmaddubsw xm0, xm3 jmp wq .w16: movu xm1, [tlq+1] vextracti128 xm2, m0, 1 pmaddubsw xm1, xm3 psubw xm0, xm4 paddw xm0, xm2 paddw xm0, xm1 punpckhqdq xm1, xm0, xm0 paddw xm0, xm1 psrlq xm1, xm0, 32 paddw xm0, xm1 pmaddwd xm0, xm3 psrlw xm0, xm5 cmp hd, 16 je .w16_end mov r6d, 0x5556 mov r2d, 0x3334 test hb, 8|32 cmovz r6d, r2d movd xm1, r6d pmulhuw xm0, xm1 .w16_end: vpbroadcastw m0, xm0 .s16: vpbroadcastw m1, alpham pabsw m2, m1 psllw m2, 9 .s16_loop: mova m4, [acq] mova m5, [acq+32] IPRED_CFL 4 IPRED_CFL 5 packuswb m4, m5 vpermq m4, m4, q3120 mova [dstq+strideq*0], xm4 vextracti128 [dstq+strideq*1], m4, 1 lea dstq, [dstq+strideq*2] add acq, 64 sub hd, 2 jg .s16_loop RET ALIGN function_align .h32: mova m0, [tlq-32] pmaddubsw m0, m3 jmp wq .w32: movu m1, [tlq+1] pmaddubsw m1, m3 paddw m0, m1 vextracti128 xm1, m0, 1 psubw xm0, xm4 paddw xm0, xm1 punpckhqdq xm1, xm0, xm0 paddw xm0, xm1 psrlq xm1, xm0, 32 paddw xm0, xm1 pmaddwd xm0, xm3 psrlw xm0, xm5 cmp hd, 32 je .w32_end lea r2d, [hq*2] mov r6d, 0x33345556 shrx r6d, r6d, r2d movd xm1, r6d pmulhuw xm0, xm1 .w32_end: vpbroadcastw m0, xm0 .s32: vpbroadcastw m1, alpham pabsw m2, m1 psllw m2, 9 .s32_loop: mova m4, [acq] mova m5, [acq+32] IPRED_CFL 4 IPRED_CFL 5 packuswb m4, m5 vpermq m4, m4, q3120 mova [dstq], m4 add dstq, strideq add acq, 64 dec hd jg .s32_loop RET cglobal ipred_cfl_128, 3, 7, 6, dst, stride, tl, w, h, ac, alpha lea t0, [ipred_cfl_splat_avx2_table] tzcnt wd, wm movifnidn hd, hm movsxd wq, [t0+wq*4] vpbroadcastd m0, [t0-ipred_cfl_splat_avx2_table+pw_128] add wq, t0 movifnidn acq, acmp jmp wq cglobal ipred_cfl_ac_420, 4, 9, 5, ac, y, stride, wpad, hpad, w, h, sz, ac_bak movifnidn hpadd, hpadm movifnidn wd, wm mov hd, hm mov szd, wd mov ac_bakq, acq imul szd, hd shl hpadd, 2 sub hd, hpadd vpbroadcastd m2, [pb_2] pxor m4, m4 cmp wd, 8 jg .w16 je .w8 ; fall-through DEFINE_ARGS ac, y, stride, wpad, hpad, stride3, h, sz, ac_bak .w4: lea stride3q, [strideq*3] .w4_loop: movq xm0, [yq] movq xm1, [yq+strideq] movhps xm0, [yq+strideq*2] movhps xm1, [yq+stride3q] pmaddubsw xm0, xm2 pmaddubsw xm1, xm2 paddw xm0, xm1 mova [acq], xm0 paddw xm4, xm0 lea yq, [yq+strideq*4] add acq, 16 sub hd, 2 jg .w4_loop test hpadd, hpadd jz .calc_avg vpermq m0, m0, q1111 .w4_hpad_loop: mova [acq], m0 paddw m4, m0 add acq, 32 sub hpadd, 4 jg .w4_hpad_loop jmp .calc_avg .w8: lea stride3q, [strideq*3] test wpadd, wpadd jnz .w8_wpad .w8_loop: mova xm0, [yq] mova xm1, [yq+strideq] vinserti128 m0, [yq+strideq*2], 1 vinserti128 m1, [yq+stride3q], 1 pmaddubsw m0, m2 pmaddubsw m1, m2 paddw m0, m1 mova [acq], m0 paddw m4, m0 lea yq, [yq+strideq*4] add acq, 32 sub hd, 2 jg .w8_loop test hpadd, hpadd jz .calc_avg jmp .w8_hpad .w8_wpad: vbroadcasti128 m3, [cfl_ac_w8_pad1_shuffle] .w8_wpad_loop: movq xm0, [yq] movq xm1, [yq+strideq] vinserti128 m0, [yq+strideq*2], 1 vinserti128 m1, [yq+stride3q], 1 pmaddubsw m0, m2 pmaddubsw m1, m2 paddw m0, m1 pshufb m0, m3 mova [acq], m0 paddw m4, m0 lea yq, [yq+strideq*4] add acq, 32 sub hd, 2 jg .w8_wpad_loop test hpadd, hpadd jz .calc_avg .w8_hpad: vpermq m0, m0, q3232 .w8_hpad_loop: mova [acq], m0 paddw m4, m0 add acq, 32 sub hpadd, 2 jg .w8_hpad_loop jmp .calc_avg .w16: test wpadd, wpadd jnz .w16_wpad .w16_loop: mova m0, [yq] mova m1, [yq+strideq] pmaddubsw m0, m2 pmaddubsw m1, m2 paddw m0, m1 mova [acq], m0 paddw m4, m0 lea yq, [yq+strideq*2] add acq, 32 dec hd jg .w16_loop test hpadd, hpadd jz .calc_avg jmp .w16_hpad_loop .w16_wpad: DEFINE_ARGS ac, y, stride, wpad, hpad, iptr, h, sz, ac_bak lea iptrq, [ipred_cfl_ac_420_avx2_table] shl wpadd, 2 mova m3, [iptrq+cfl_ac_w16_pad_shuffle- \ ipred_cfl_ac_420_avx2_table+wpadq*8-32] movsxd wpadq, [iptrq+wpadq+4] add iptrq, wpadq jmp iptrq .w16_pad3: vpbroadcastq m0, [yq] vpbroadcastq m1, [yq+strideq] jmp .w16_wpad_end .w16_pad2: vbroadcasti128 m0, [yq] vbroadcasti128 m1, [yq+strideq] jmp .w16_wpad_end .w16_pad1: mova m0, [yq] mova m1, [yq+strideq] ; fall-through .w16_wpad_end: pmaddubsw m0, m2 pmaddubsw m1, m2 paddw m0, m1 pshufb m0, m3 mova [acq], m0 paddw m4, m0 lea yq, [yq+strideq*2] add acq, 32 dec hd jz .w16_wpad_done jmp iptrq .w16_wpad_done: test hpadd, hpadd jz .calc_avg .w16_hpad_loop: mova [acq], m0 paddw m4, m0 add acq, 32 dec hpadd jg .w16_hpad_loop ; fall-through .calc_avg: vpbroadcastd m2, [pw_1] pmaddwd m0, m4, m2 vextracti128 xm1, m0, 1 tzcnt r1d, szd paddd xm0, xm1 movd xm2, r1d movd xm3, szd punpckhqdq xm1, xm0, xm0 paddd xm0, xm1 psrad xm3, 1 psrlq xm1, xm0, 32 paddd xm0, xm3 paddd xm0, xm1 psrad xm0, xm2 vpbroadcastw m0, xm0 .sub_loop: mova m1, [ac_bakq] psubw m1, m0 mova [ac_bakq], m1 add ac_bakq, 32 sub szd, 16 jg .sub_loop RET cglobal ipred_cfl_ac_422, 4, 9, 6, ac, y, stride, wpad, hpad, w, h, sz, ac_bak movifnidn hpadd, hpadm movifnidn wd, wm mov hd, hm mov szd, wd mov ac_bakq, acq imul szd, hd shl hpadd, 2 sub hd, hpadd vpbroadcastd m2, [pb_4] pxor m4, m4 pxor m5, m5 cmp wd, 8 jg .w16 je .w8 ; fall-through DEFINE_ARGS ac, y, stride, wpad, hpad, stride3, h, sz, ac_bak .w4: lea stride3q, [strideq*3] .w4_loop: movq xm1, [yq] movhps xm1, [yq+strideq] movq xm0, [yq+strideq*2] movhps xm0, [yq+stride3q] pmaddubsw xm0, xm2 pmaddubsw xm1, xm2 mova [acq], xm1 mova [acq+16], xm0 paddw xm4, xm0 paddw xm5, xm1 lea yq, [yq+strideq*4] add acq, 32 sub hd, 4 jg .w4_loop test hpadd, hpadd jz .calc_avg vpermq m0, m0, q1111 .w4_hpad_loop: mova [acq], m0 paddw m4, m0 add acq, 32 sub hpadd, 4 jg .w4_hpad_loop jmp .calc_avg .w8: lea stride3q, [strideq*3] test wpadd, wpadd jnz .w8_wpad .w8_loop: mova xm1, [yq] vinserti128 m1, [yq+strideq], 1 mova xm0, [yq+strideq*2] vinserti128 m0, [yq+stride3q], 1 pmaddubsw m0, m2 pmaddubsw m1, m2 mova [acq], m1 mova [acq+32], m0 paddw m4, m0 paddw m5, m1 lea yq, [yq+strideq*4] add acq, 64 sub hd, 4 jg .w8_loop test hpadd, hpadd jz .calc_avg jmp .w8_hpad .w8_wpad: vbroadcasti128 m3, [cfl_ac_w8_pad1_shuffle] .w8_wpad_loop: movq xm1, [yq] vinserti128 m1, [yq+strideq], 1 movq xm0, [yq+strideq*2] vinserti128 m0, [yq+stride3q], 1 pmaddubsw m0, m2 pmaddubsw m1, m2 pshufb m0, m3 pshufb m1, m3 mova [acq], m1 mova [acq+32], m0 paddw m4, m0 paddw m5, m1 lea yq, [yq+strideq*4] add acq, 64 sub hd, 4 jg .w8_wpad_loop test hpadd, hpadd jz .calc_avg .w8_hpad: vpermq m0, m0, q3232 .w8_hpad_loop: mova [acq], m0 paddw m4, m0 add acq, 32 sub hpadd, 2 jg .w8_hpad_loop jmp .calc_avg .w16: test wpadd, wpadd jnz .w16_wpad .w16_loop: mova m1, [yq] mova m0, [yq+strideq] pmaddubsw m0, m2 pmaddubsw m1, m2 mova [acq], m1 mova [acq+32], m0 paddw m4, m0 paddw m5, m1 lea yq, [yq+strideq*2] add acq, 64 sub hd, 2 jg .w16_loop test hpadd, hpadd jz .calc_avg jmp .w16_hpad_loop .w16_wpad: DEFINE_ARGS ac, y, stride, wpad, hpad, iptr, h, sz, ac_bak lea iptrq, [ipred_cfl_ac_422_avx2_table] shl wpadd, 2 mova m3, [iptrq+cfl_ac_w16_pad_shuffle- \ ipred_cfl_ac_422_avx2_table+wpadq*8-32] movsxd wpadq, [iptrq+wpadq+4] add iptrq, wpadq jmp iptrq .w16_pad3: vpbroadcastq m1, [yq] vpbroadcastq m0, [yq+strideq] jmp .w16_wpad_end .w16_pad2: vbroadcasti128 m1, [yq] vbroadcasti128 m0, [yq+strideq] jmp .w16_wpad_end .w16_pad1: mova m1, [yq] mova m0, [yq+strideq] ; fall-through .w16_wpad_end: pmaddubsw m0, m2 pmaddubsw m1, m2 pshufb m0, m3 pshufb m1, m3 mova [acq], m1 mova [acq+32], m0 paddw m4, m0 paddw m5, m1 lea yq, [yq+strideq*2] add acq, 64 sub hd, 2 jz .w16_wpad_done jmp iptrq .w16_wpad_done: test hpadd, hpadd jz .calc_avg .w16_hpad_loop: mova [acq], m0 mova [acq+32], m0 paddw m4, m0 paddw m5, m0 add acq, 64 sub hpadd, 2 jg .w16_hpad_loop ; fall-through .calc_avg: vpbroadcastd m2, [pw_1] pmaddwd m5, m5, m2 pmaddwd m0, m4, m2 paddd m0, m5 vextracti128 xm1, m0, 1 tzcnt r1d, szd paddd xm0, xm1 movd xm2, r1d movd xm3, szd punpckhqdq xm1, xm0, xm0 paddd xm0, xm1 psrad xm3, 1 psrlq xm1, xm0, 32 paddd xm0, xm3 paddd xm0, xm1 psrad xm0, xm2 vpbroadcastw m0, xm0 .sub_loop: mova m1, [ac_bakq] psubw m1, m0 mova [ac_bakq], m1 add ac_bakq, 32 sub szd, 16 jg .sub_loop RET cglobal ipred_cfl_ac_444, 4, 9, 6, ac, y, stride, wpad, hpad, w, h, sz, ac_bak movifnidn hpadd, hpadm movifnidn wd, wm mov hd, hm mov szd, wd imul szd, hd shl hpadd, 2 sub hd, hpadd pxor m4, m4 vpbroadcastd m5, [pw_1] tzcnt r8d, wd lea r5, [ipred_cfl_ac_444_avx2_table] movsxd r8, [r5+r8*4+12] add r5, r8 DEFINE_ARGS ac, y, stride, wpad, hpad, stride3, h, sz, ac_bak mov ac_bakq, acq jmp r5 .w4: lea stride3q, [strideq*3] pxor xm2, xm2 .w4_loop: movd xm1, [yq] movd xm0, [yq+strideq*2] pinsrd xm1, [yq+strideq], 1 pinsrd xm0, [yq+stride3q], 1 punpcklbw xm1, xm2 punpcklbw xm0, xm2 psllw xm1, 3 psllw xm0, 3 mova [acq], xm1 mova [acq+16], xm0 paddw xm1, xm0 paddw xm4, xm1 lea yq, [yq+strideq*4] add acq, 32 sub hd, 4 jg .w4_loop test hpadd, hpadd jz .calc_avg_mul pshufd xm0, xm0, q3232 paddw xm1, xm0, xm0 .w4_hpad_loop: mova [acq], xm0 mova [acq+16], xm0 paddw xm4, xm1 add acq, 32 sub hpadd, 4 jg .w4_hpad_loop jmp .calc_avg_mul .w8: lea stride3q, [strideq*3] pxor m2, m2 .w8_loop: movq xm1, [yq] movq xm0, [yq+strideq*2] vinserti128 m1, [yq+strideq], 1 vinserti128 m0, [yq+stride3q], 1 punpcklbw m1, m2 punpcklbw m0, m2 psllw m1, 3 psllw m0, 3 mova [acq], m1 mova [acq+32], m0 paddw m1, m0 paddw m4, m1 lea yq, [yq+strideq*4] add acq, 64 sub hd, 4 jg .w8_loop test hpadd, hpadd jz .calc_avg_mul vpermq m0, m0, q3232 paddw m1, m0, m0 .w8_hpad_loop: mova [acq], m0 mova [acq+32], m0 paddw m4, m1 add acq, 64 sub hpadd, 4 jg .w8_hpad_loop jmp .calc_avg_mul .w16: test wpadd, wpadd jnz .w16_wpad .w16_loop: pmovzxbw m1, [yq] pmovzxbw m0, [yq+strideq] psllw m1, 3 psllw m0, 3 mova [acq], m1 mova [acq+32], m0 paddw m1, m0 pmaddwd m1, m5 paddd m4, m1 lea yq, [yq+strideq*2] add acq, 64 sub hd, 2 jg .w16_loop test hpadd, hpadd jz .calc_avg jmp .w16_hpad .w16_wpad: mova m3, [cfl_ac_444_w16_pad1_shuffle] .w16_wpad_loop: vpbroadcastq m1, [yq] vpbroadcastq m0, [yq+strideq] pshufb m1, m3 pshufb m0, m3 psllw m1, 3 psllw m0, 3 mova [acq], m1 mova [acq+32], m0 paddw m1, m0 pmaddwd m1, m5 paddd m4, m1 lea yq, [yq+strideq*2] add acq, 64 sub hd, 2 jg .w16_wpad_loop test hpadd, hpadd jz .calc_avg .w16_hpad: paddw m1, m0, m0 pmaddwd m1, m5 .w16_hpad_loop: mova [acq], m0 mova [acq+32], m0 paddd m4, m1 add acq, 64 sub hpadd, 2 jg .w16_hpad_loop jmp .calc_avg .w32: test wpadd, wpadd jnz .w32_wpad .w32_loop: pmovzxbw m1, [yq] pmovzxbw m0, [yq+16] psllw m1, 3 psllw m0, 3 mova [acq], m1 mova [acq+32], m0 paddw m2, m1, m0 pmaddwd m2, m5 paddd m4, m2 add yq, strideq add acq, 64 dec hd jg .w32_loop test hpadd, hpadd jz .calc_avg jmp .w32_hpad_loop .w32_wpad: DEFINE_ARGS ac, y, stride, wpad, hpad, iptr, h, sz, ac_bak lea iptrq, [ipred_cfl_ac_444_avx2_table] add wpadd, wpadd mova m3, [iptrq+cfl_ac_444_w16_pad1_shuffle-ipred_cfl_ac_444_avx2_table] movsxd wpadq, [iptrq+wpadq+4] add iptrq, wpadq jmp iptrq .w32_pad3: vpbroadcastq m1, [yq] pshufb m1, m3 vpermq m0, m1, q3232 jmp .w32_wpad_end .w32_pad2: pmovzxbw m1, [yq] pshufhw m0, m1, q3333 vpermq m0, m0, q3333 jmp .w32_wpad_end .w32_pad1: pmovzxbw m1, [yq] vpbroadcastq m0, [yq+16] pshufb m0, m3 ; fall-through .w32_wpad_end: psllw m1, 3 psllw m0, 3 mova [acq], m1 mova [acq+32], m0 paddw m2, m1, m0 pmaddwd m2, m5 paddd m4, m2 add yq, strideq add acq, 64 dec hd jz .w32_wpad_done jmp iptrq .w32_wpad_done: test hpadd, hpadd jz .calc_avg .w32_hpad_loop: mova [acq], m1 mova [acq+32], m0 paddd m4, m2 add acq, 64 dec hpadd jg .w32_hpad_loop jmp .calc_avg .calc_avg_mul: pmaddwd m4, m5 .calc_avg: vextracti128 xm1, m4, 1 tzcnt r1d, szd paddd xm0, xm4, xm1 movd xm2, r1d movd xm3, szd punpckhqdq xm1, xm0, xm0 paddd xm0, xm1 psrad xm3, 1 psrlq xm1, xm0, 32 paddd xm0, xm3 paddd xm0, xm1 psrad xm0, xm2 vpbroadcastw m0, xm0 .sub_loop: mova m1, [ac_bakq] psubw m1, m0 mova [ac_bakq], m1 add ac_bakq, 32 sub szd, 16 jg .sub_loop RET cglobal pal_pred, 4, 6, 5, dst, stride, pal, idx, w, h vbroadcasti128 m4, [palq] lea r2, [pal_pred_avx2_table] tzcnt wd, wm movifnidn hd, hm movsxd wq, [r2+wq*4] packuswb m4, m4 add wq, r2 lea r2, [strideq*3] jmp wq .w4: pshufb xm0, xm4, [idxq] add idxq, 16 movd [dstq+strideq*0], xm0 pextrd [dstq+strideq*1], xm0, 1 pextrd [dstq+strideq*2], xm0, 2 pextrd [dstq+r2 ], xm0, 3 lea dstq, [dstq+strideq*4] sub hd, 4 jg .w4 RET ALIGN function_align .w8: pshufb xm0, xm4, [idxq+16*0] pshufb xm1, xm4, [idxq+16*1] add idxq, 16*2 movq [dstq+strideq*0], xm0 movhps [dstq+strideq*1], xm0 movq [dstq+strideq*2], xm1 movhps [dstq+r2 ], xm1 lea dstq, [dstq+strideq*4] sub hd, 4 jg .w8 RET ALIGN function_align .w16: pshufb m0, m4, [idxq+32*0] pshufb m1, m4, [idxq+32*1] add idxq, 32*2 mova [dstq+strideq*0], xm0 vextracti128 [dstq+strideq*1], m0, 1 mova [dstq+strideq*2], xm1 vextracti128 [dstq+r2 ], m1, 1 lea dstq, [dstq+strideq*4] sub hd, 4 jg .w16 RET ALIGN function_align .w32: pshufb m0, m4, [idxq+32*0] pshufb m1, m4, [idxq+32*1] pshufb m2, m4, [idxq+32*2] pshufb m3, m4, [idxq+32*3] add idxq, 32*4 mova [dstq+strideq*0], m0 mova [dstq+strideq*1], m1 mova [dstq+strideq*2], m2 mova [dstq+r2 ], m3 lea dstq, [dstq+strideq*4] sub hd, 4 jg .w32 RET ALIGN function_align .w64: pshufb m0, m4, [idxq+32*0] pshufb m1, m4, [idxq+32*1] pshufb m2, m4, [idxq+32*2] pshufb m3, m4, [idxq+32*3] add idxq, 32*4 mova [dstq+strideq*0+32*0], m0 mova [dstq+strideq*0+32*1], m1 mova [dstq+strideq*1+32*0], m2 mova [dstq+strideq*1+32*1], m3 lea dstq, [dstq+strideq*2] sub hd, 2 jg .w64 RET %endif
Code Segment assume CS:Code, DS:Data, SS:Stack Start: MOV AX, Code MOV DS, AX mov ax,3 int 10h XOR DX, DX XOR BX, BX MOV CX, 20 MOV AH, 2 MOV DL, 8 SIDES: PUSH DX INT 10h MOV DL, "x" INT 21h POP DX PUSH DX ADD DL, BL INT 10h MOV DL, "x" INT 21h POP DX INC DH INC BL LOOP SIDES MOV CX, BX INC CX BASE: PUSH DX INT 10h MOV DL,"x" INT 21h POP DX INC DL loop BASE MOV DH, 12 MOV DL, 12 INT 10h END_OF_PROGRAM: mov ax, 4c00h int 21h Code Ends Data Segment Data Ends Stack Segment Stack Ends End Start
/* *********************************************************************************************************************** * * Copyright (c) 2015-2021 Advanced Micro Devices, Inc. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * **********************************************************************************************************************/ #include "core/cmdStream.h" #include "core/platform.h" #include "core/g_palPlatformSettings.h" #include "core/hw/gfxip/colorBlendState.h" #include "core/hw/gfxip/computePipeline.h" #include "core/hw/gfxip/depthStencilState.h" #include "core/hw/gfxip/graphicsPipeline.h" #include "core/hw/gfxip/gfxCmdBuffer.h" #include "core/hw/gfxip/gfxDevice.h" #include "core/hw/gfxip/indirectCmdGenerator.h" #include "core/hw/gfxip/msaaState.h" #include "core/hw/gfxip/rpm/rpmUtil.h" #include "core/hw/gfxip/rpm/rsrcProcMgr.h" #include "core/hw/gfxip/universalCmdBuffer.h" #include "palAutoBuffer.h" #include "palColorBlendState.h" #include "palColorTargetView.h" #include "palDepthStencilState.h" #include "palDepthStencilView.h" #include "palFormatInfo.h" #include "palMsaaState.h" #include "palInlineFuncs.h" #include <float.h> #include <math.h> using namespace Util; namespace Pal { static void PreComputeColorClearSync(ICmdBuffer* pCmdBuffer, const IImage* pImage, const SubresRange& subres, ImageLayout layout); static void PostComputeColorClearSync(ICmdBuffer* pCmdBuffer, const IImage* pImage, const SubresRange& subres, ImageLayout layout); // ===================================================================================================================== // Note that this constructor is invoked before settings have been committed. RsrcProcMgr::RsrcProcMgr( GfxDevice* pDevice) : m_pBlendDisableState(nullptr), m_pColorBlendState(nullptr), m_pDepthDisableState(nullptr), m_pDepthClearState(nullptr), m_pStencilClearState(nullptr), m_pDepthStencilClearState(nullptr), m_pDepthExpandState(nullptr), m_pDepthResummarizeState(nullptr), m_pDepthResolveState(nullptr), m_pStencilResolveState(nullptr), m_pDepthStencilResolveState(nullptr), m_pDevice(pDevice), m_srdAlignment(0) { memset(&m_pMsaaState[0], 0, sizeof(m_pMsaaState)); memset(&m_pComputePipelines[0], 0, sizeof(m_pComputePipelines)); memset(&m_pGraphicsPipelines[0], 0, sizeof(m_pGraphicsPipelines)); } // ===================================================================================================================== RsrcProcMgr::~RsrcProcMgr() { // These objects must be destroyed in Cleanup(). for (uint32 idx = 0; idx < static_cast<uint32>(RpmComputePipeline::Count); ++idx) { PAL_ASSERT(m_pComputePipelines[idx] == nullptr); } for (uint32 idx = 0; idx < RpmGfxPipelineCount; ++idx) { PAL_ASSERT(m_pGraphicsPipelines[idx] == nullptr); } for (uint32 sampleIdx = 0; sampleIdx <= MaxLog2AaSamples; ++sampleIdx) { for (uint32 fragmentIdx = 0; fragmentIdx <= MaxLog2AaFragments; ++fragmentIdx) { PAL_ASSERT(m_pMsaaState[sampleIdx][fragmentIdx] == nullptr); } } PAL_ASSERT(m_pBlendDisableState == nullptr); PAL_ASSERT(m_pColorBlendState == nullptr); PAL_ASSERT(m_pDepthDisableState == nullptr); PAL_ASSERT(m_pDepthClearState == nullptr); PAL_ASSERT(m_pStencilClearState == nullptr); PAL_ASSERT(m_pDepthStencilClearState == nullptr); PAL_ASSERT(m_pDepthExpandState == nullptr); PAL_ASSERT(m_pDepthResummarizeState == nullptr); PAL_ASSERT(m_pDepthResolveState == nullptr); PAL_ASSERT(m_pStencilResolveState == nullptr); } // ===================================================================================================================== // This must clean up all internal GPU memory allocations and all objects created after EarlyInit. Note that EarlyInit // is called when the platform creates the device objects so the work it does must be preserved if we are to reuse // this object. void RsrcProcMgr::Cleanup() { // Destroy all compute pipeline objects. for (uint32 idx = 0; idx < static_cast<uint32>(RpmComputePipeline::Count); ++idx) { if (m_pComputePipelines[idx] != nullptr) { m_pComputePipelines[idx]->DestroyInternal(); m_pComputePipelines[idx] = nullptr; } } // Destroy all graphics pipeline objects. for (uint32 idx = 0; idx < RpmGfxPipelineCount; ++idx) { if (m_pGraphicsPipelines[idx] != nullptr) { m_pGraphicsPipelines[idx]->DestroyInternal(); m_pGraphicsPipelines[idx] = nullptr; } } m_pDevice->DestroyColorBlendStateInternal(m_pBlendDisableState); m_pBlendDisableState = nullptr; m_pDevice->DestroyColorBlendStateInternal(m_pColorBlendState); m_pColorBlendState = nullptr; DepthStencilState**const ppDepthStates[] = { &m_pDepthDisableState, &m_pDepthClearState, &m_pStencilClearState, &m_pDepthStencilClearState, &m_pDepthExpandState, &m_pDepthResummarizeState, &m_pDepthResolveState, &m_pStencilResolveState, &m_pDepthStencilResolveState, }; for (uint32 idx = 0; idx < ArrayLen(ppDepthStates); ++idx) { m_pDevice->DestroyDepthStencilStateInternal(*ppDepthStates[idx]); (*ppDepthStates[idx]) = nullptr; } for (uint32 sampleIdx = 0; sampleIdx <= MaxLog2AaSamples; ++sampleIdx) { for (uint32 fragmentIdx = 0; fragmentIdx <= MaxLog2AaFragments; ++fragmentIdx) { m_pDevice->DestroyMsaaStateInternal(m_pMsaaState[sampleIdx][fragmentIdx]); m_pMsaaState[sampleIdx][fragmentIdx] = nullptr; } } } // ===================================================================================================================== // Performs early initialization of this object; this occurs when the device owning is created. Result RsrcProcMgr::EarlyInit() { const GpuChipProperties& chipProps = m_pDevice->Parent()->ChipProperties(); m_srdAlignment = Max(chipProps.srdSizes.bufferView, chipProps.srdSizes.fmaskView, chipProps.srdSizes.imageView, chipProps.srdSizes.sampler); // Round up to the size of a DWORD. m_srdAlignment = Util::NumBytesToNumDwords(m_srdAlignment); return Result::Success; } // ===================================================================================================================== // Performs any late-stage initialization that can only be done after settings have been committed. Result RsrcProcMgr::LateInit() { Result result = Result::Success; if (m_pDevice->Parent()->GetPublicSettings()->disableResourceProcessingManager == false) { result = CreateRpmComputePipelines(m_pDevice, m_pComputePipelines); if (result == Result::Success) { result = CreateRpmGraphicsPipelines(m_pDevice, m_pGraphicsPipelines); } if (result == Result::Success) { result = CreateCommonStateObjects(); } } return result; } // ===================================================================================================================== // Builds commands to copy one or more regions from one GPU memory location to another with a compute shader. void RsrcProcMgr::CopyMemoryCs( GfxCmdBuffer* pCmdBuffer, const GpuMemory& srcGpuMemory, const GpuMemory& dstGpuMemory, uint32 regionCount, const MemoryCopyRegion* pRegions ) const { constexpr uint32 NumGpuMemory = 2; // source & destination. constexpr gpusize CopySizeLimit = 16777216; // 16 MB. bool p2pBltInfoRequired = m_pDevice->Parent()->IsP2pBltWaRequired(dstGpuMemory); uint32 newRegionCount = 0; if (p2pBltInfoRequired) { m_pDevice->P2pBltWaModifyRegionListMemory(dstGpuMemory, regionCount, pRegions, &newRegionCount, nullptr, nullptr); } AutoBuffer<MemoryCopyRegion, 32, Platform> newRegions(newRegionCount, m_pDevice->GetPlatform()); AutoBuffer<gpusize, 32, Platform> chunkAddrs(newRegionCount, m_pDevice->GetPlatform()); if (p2pBltInfoRequired) { if ((newRegions.Capacity() >= newRegionCount) && (chunkAddrs.Capacity() >= newRegionCount)) { m_pDevice->P2pBltWaModifyRegionListMemory(dstGpuMemory, regionCount, pRegions, &newRegionCount, &newRegions[0], &chunkAddrs[0]); regionCount = newRegionCount; pRegions = &newRegions[0]; pCmdBuffer->P2pBltWaCopyBegin(&dstGpuMemory, regionCount, &chunkAddrs[0]); } else { pCmdBuffer->NotifyAllocFailure(); p2pBltInfoRequired = false; } } // Save current command buffer state. pCmdBuffer->CmdSaveComputeState(ComputeStatePipelineAndUserData); // Local to local copy prefers wide format copy for better performance. Copy to/from nonlocal heap // with wide format may result in worse performance. const bool preferWideFormatCopy = (srcGpuMemory.IsLocalPreferred() && dstGpuMemory.IsLocalPreferred()); // Now begin processing the list of copy regions. for (uint32 idx = 0; idx < regionCount; ++idx) { if (p2pBltInfoRequired) { pCmdBuffer->P2pBltWaCopyNextRegion(chunkAddrs[idx]); } const gpusize srcOffset = pRegions[idx].srcOffset; const gpusize dstOffset = pRegions[idx].dstOffset; const gpusize copySize = pRegions[idx].copySize; for(gpusize copyOffset = 0; copyOffset < copySize; copyOffset += CopySizeLimit) { const uint32 copySectionSize = static_cast<uint32>(Min(CopySizeLimit, copySize - copyOffset)); // Create an embedded user-data table and bind it to user data. We need buffer views for the source and // destination. uint32* pSrdTable = RpmUtil::CreateAndBindEmbeddedUserData(pCmdBuffer, SrdDwordAlignment() * NumGpuMemory, SrdDwordAlignment(), PipelineBindPoint::Compute, 0); // Populate the table with raw buffer views, by convention the destination is placed before the source. BufferViewInfo rawBufferView = {}; RpmUtil::BuildRawBufferViewInfo(&rawBufferView, dstGpuMemory, dstOffset + copyOffset, copySectionSize); m_pDevice->Parent()->CreateUntypedBufferViewSrds(1, &rawBufferView, pSrdTable); pSrdTable += SrdDwordAlignment(); RpmUtil::BuildRawBufferViewInfo(&rawBufferView, srcGpuMemory, srcOffset + copyOffset, copySectionSize); m_pDevice->Parent()->CreateUntypedBufferViewSrds(1, &rawBufferView, pSrdTable); const uint32 regionUserData[3] = { 0, 0, copySectionSize }; pCmdBuffer->CmdSetUserData(PipelineBindPoint::Compute, 1, 3, regionUserData); // Get the pipeline object and number of thread groups. const ComputePipeline* pPipeline = nullptr; uint32 numThreadGroups = 0; constexpr uint32 DqwordSize = 4 * sizeof(uint32); if (preferWideFormatCopy && IsPow2Aligned(srcOffset + copyOffset, DqwordSize) && IsPow2Aligned(dstOffset + copyOffset, DqwordSize) && IsPow2Aligned(copySectionSize, DqwordSize)) { // Offsets and copySectionSize are DQWORD aligned so we can use the DQWORD copy pipeline. pPipeline = GetPipeline(RpmComputePipeline::CopyBufferDqword); numThreadGroups = RpmUtil::MinThreadGroups(copySectionSize / DqwordSize, pPipeline->ThreadsPerGroup()); } else if (IsPow2Aligned(srcOffset + copyOffset, sizeof(uint32)) && IsPow2Aligned(dstOffset + copyOffset, sizeof(uint32)) && IsPow2Aligned(copySectionSize, sizeof(uint32))) { // Offsets and copySectionSize are DWORD aligned so we can use the DWORD copy pipeline. pPipeline = GetPipeline(RpmComputePipeline::CopyBufferDword); numThreadGroups = RpmUtil::MinThreadGroups(copySectionSize / sizeof(uint32), pPipeline->ThreadsPerGroup()); } else { // Offsets and copySectionSize are not all DWORD aligned so we have to use the byte copy pipeline. pPipeline = GetPipeline(RpmComputePipeline::CopyBufferByte); numThreadGroups = RpmUtil::MinThreadGroups(copySectionSize, pPipeline->ThreadsPerGroup()); } // Bind pipeline and dispatch. pCmdBuffer->CmdBindPipeline({ PipelineBindPoint::Compute, pPipeline, InternalApiPsoHash, }); pCmdBuffer->CmdDispatch(numThreadGroups, 1, 1); } } if (p2pBltInfoRequired) { pCmdBuffer->P2pBltWaCopyEnd(); } // Restore command buffer state. pCmdBuffer->CmdRestoreComputeState(ComputeStatePipelineAndUserData); } // ===================================================================================================================== // Default implementation of getting the engine to use for image-to-image copies. ImageCopyEngine RsrcProcMgr::GetImageToImageCopyEngine( const GfxCmdBuffer* pCmdBuffer, const Image& srcImage, const Image& dstImage, uint32 regionCount, const ImageCopyRegion* pRegions, uint32 copyFlags ) const { const auto& srcInfo = srcImage.GetImageCreateInfo(); const auto& dstInfo = dstImage.GetImageCreateInfo(); const ImageType srcImageType = srcInfo.imageType; const ImageType dstImageType = dstInfo.imageType; const bool bothColor = ((srcImage.IsDepthStencilTarget() == false) && (dstImage.IsDepthStencilTarget() == false) && (Formats::IsDepthStencilOnly(srcInfo.swizzledFormat.format) == false) && (Formats::IsDepthStencilOnly(dstInfo.swizzledFormat.format) == false)); const bool isCompressed = (Formats::IsBlockCompressed(srcInfo.swizzledFormat.format) || Formats::IsBlockCompressed(dstInfo.swizzledFormat.format)); const bool isYuv = (Formats::IsYuv(srcInfo.swizzledFormat.format) || Formats::IsYuv(dstInfo.swizzledFormat.format)); const bool p2pBltWa = m_pDevice->Parent()->ChipProperties().p2pBltWaInfo.required && dstImage.GetBoundGpuMemory().Memory()->AccessesPeerMemory(); const bool isSrgbWithFormatConversion = (Formats::IsSrgb(dstInfo.swizzledFormat.format) && TestAnyFlagSet(copyFlags, CopyFormatConversion)); const bool isMacroPixelPackedRgbOnly = (Formats::IsMacroPixelPackedRgbOnly(srcInfo.swizzledFormat.format) || Formats::IsMacroPixelPackedRgbOnly(dstInfo.swizzledFormat.format)); ImageCopyEngine engineType = ImageCopyEngine::Compute; // We need to decide between the graphics copy path and the compute copy path. The graphics path only supports // single-sampled non-compressed, non-YUV , non-MacroPixelPackedRgbOnly 2D or 2D color images for now. if ((Image::PreferGraphicsCopy && pCmdBuffer->IsGraphicsSupported()) && (p2pBltWa == false) && (dstImage.IsDepthStencilTarget() || ((srcImageType != ImageType::Tex1d) && (dstImageType != ImageType::Tex1d) && (dstInfo.samples == 1) && (isCompressed == false) && (isYuv == false) && (isMacroPixelPackedRgbOnly == false) && (bothColor == true) && (isSrgbWithFormatConversion == false)))) { engineType = ImageCopyEngine::Graphics; } #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 603 // Scissor-enabled blit for OGLP is only supported on graphics path. PAL_ASSERT((engineType == ImageCopyEngine::Graphics) || (TestAnyFlagSet(copyFlags, CopyEnableScissorTest) == false)); #endif return engineType; } // ===================================================================================================================== // Builds commands to copy one or more regions from one image to another. void RsrcProcMgr::CmdCopyImage( GfxCmdBuffer* pCmdBuffer, const Image& srcImage, ImageLayout srcImageLayout, const Image& dstImage, ImageLayout dstImageLayout, uint32 regionCount, const ImageCopyRegion* pRegions, const Rect* pScissorRect, uint32 flags ) const { const auto& srcInfo = srcImage.GetImageCreateInfo(); const auto& dstInfo = dstImage.GetImageCreateInfo(); // MSAA source and destination images must have the same number of samples. PAL_ASSERT(srcInfo.samples == dstInfo.samples); const ImageCopyEngine copyEngine = GetImageToImageCopyEngine(pCmdBuffer, srcImage, dstImage, regionCount, pRegions, flags); if (copyEngine == ImageCopyEngine::Graphics) { if (dstImage.IsDepthStencilTarget()) { CopyDepthStencilImageGraphics(pCmdBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions, pScissorRect, flags); } else { CopyColorImageGraphics(pCmdBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions, pScissorRect, flags); } } else { AutoBuffer<ImageFixupRegion, 32, Platform> fixupRegions(regionCount, m_pDevice->GetPlatform()); if (fixupRegions.Capacity() >= regionCount) { for (uint32 i = 0; i < regionCount; i++) { fixupRegions[i].subres = pRegions[i].dstSubres; fixupRegions[i].offset = pRegions[i].dstOffset; fixupRegions[i].extent = pRegions[i].extent; fixupRegions[i].numSlices = pRegions[i].numSlices; } FixupMetadataForComputeDst(pCmdBuffer, dstImage, dstImageLayout, regionCount, &fixupRegions[0], true); CopyImageCompute(pCmdBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions, flags); FixupMetadataForComputeDst(pCmdBuffer, dstImage, dstImageLayout, regionCount, &fixupRegions[0], false); if (((Formats::IsBlockCompressed(srcInfo.swizzledFormat.format) || Formats::IsMacroPixelPackedRgbOnly(srcInfo.swizzledFormat.format)) && (srcInfo.mipLevels > 1)) || ((Formats::IsBlockCompressed(dstInfo.swizzledFormat.format) || Formats::IsMacroPixelPackedRgbOnly(dstInfo.swizzledFormat.format)) && (dstInfo.mipLevels > 1))) { // Insert a generic barrier to prevent write-after-write hazard between CS copy and per-pixel copy BarrierInfo barrier = {}; barrier.waitPoint = HwPipePreCs; barrier.reason = Developer::BarrierReasonUnknown; constexpr HwPipePoint PostCs = HwPipePostCs; barrier.pipePointWaitCount = 1; barrier.pPipePoints = &PostCs; BarrierTransition transition = {}; transition.srcCacheMask = CoherShader; transition.dstCacheMask = CoherShader; barrier.pTransitions = &transition; pCmdBuffer->CmdBarrier(barrier); for (uint32 regionIdx = 0; regionIdx < regionCount; regionIdx++) { HwlImageToImageMissingPixelCopy(pCmdBuffer, srcImage, dstImage, pRegions[regionIdx]); } } } else { pCmdBuffer->NotifyAllocFailure(); } } if (copyEngine == ImageCopyEngine::ComputeVrsDirty) { // This copy destroyed the VRS data associated with the destination image. Mark it as dirty so the // next draw re-issues the VRS copy. pCmdBuffer->DirtyVrsDepthImage(&dstImage); } } // ===================================================================================================================== // Builds commands to copy one or more regions from one image to another using a graphics pipeline. // This path only supports copies between single-sampled non-compressed 2D, 2D color, and 3D images for now. void RsrcProcMgr::CopyColorImageGraphics( GfxCmdBuffer* pCmdBuffer, const Image& srcImage, ImageLayout srcImageLayout, const Image& dstImage, ImageLayout dstImageLayout, uint32 regionCount, const ImageCopyRegion* pRegions, const Rect* pScissorRect, uint32 flags ) const { PAL_ASSERT(pCmdBuffer->IsGraphicsSupported()); // Don't expect GFX Blts on Nested unless targets not inherited. PAL_ASSERT((pCmdBuffer->IsNested() == false) || (static_cast<UniversalCmdBuffer*>( pCmdBuffer)->GetGraphicsState().inheritedState.stateFlags.targetViewState == 0)); // Get some useful information about the image. const auto& dstCreateInfo = dstImage.GetImageCreateInfo(); const auto& srcCreateInfo = srcImage.GetImageCreateInfo(); const auto& device = *m_pDevice->Parent(); Pal::CmdStream*const pStream = pCmdBuffer->GetCmdStreamByEngine(CmdBufferEngineSupport::Graphics); PAL_ASSERT(pStream != nullptr); const StencilRefMaskParams stencilRefMasks = { 0xFF, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0x01, 0xFF }; ViewportParams viewportInfo = { }; viewportInfo.count = 1; viewportInfo.viewports[0].origin = PointOrigin::UpperLeft; viewportInfo.viewports[0].minDepth = 0.f; viewportInfo.viewports[0].maxDepth = 1.f; viewportInfo.horzClipRatio = FLT_MAX; viewportInfo.horzDiscardRatio = 1.0f; viewportInfo.vertClipRatio = FLT_MAX; viewportInfo.vertDiscardRatio = 1.0f; viewportInfo.depthRange = DepthRange::ZeroToOne; ScissorRectParams scissorInfo = { }; scissorInfo.count = 1; const ColorTargetViewInternalCreateInfo colorViewInfoInternal = { }; ColorTargetViewCreateInfo colorViewInfo = { }; colorViewInfo.imageInfo.pImage = &dstImage; colorViewInfo.imageInfo.arraySize = 1; if (dstCreateInfo.imageType == ImageType::Tex3d) { colorViewInfo.zRange.extent = 1; colorViewInfo.flags.zRangeValid = true; } BindTargetParams bindTargetsInfo = { }; bindTargetsInfo.colorTargets[0].imageLayout = dstImageLayout; bindTargetsInfo.colorTargets[0].pColorTargetView = nullptr; // Save current command buffer state. pCmdBuffer->PushGraphicsState(); BindCommonGraphicsState(pCmdBuffer); pCmdBuffer->CmdBindColorBlendState(m_pBlendDisableState); pCmdBuffer->CmdBindDepthStencilState(m_pDepthDisableState); pCmdBuffer->CmdBindMsaaState(GetMsaaState(dstCreateInfo.samples, dstCreateInfo.fragments)); pCmdBuffer->CmdSetStencilRefMasks(stencilRefMasks); SubresRange viewRange = { }; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 viewRange.startSubres = srcImage.GetBaseSubResource(); #else viewRange.numPlanes = 1; #endif viewRange.numMips = srcCreateInfo.mipLevels; // Use the depth of base subresource as the number of array slices since 3D image is viewed as 2D array // later. Src image view is set up as a whole rather than per mip-level, using base subresource's depth // to cover the MAX_SLICE of all mip-level. viewRange.numSlices = (srcCreateInfo.imageType == ImageType::Tex3d) ? srcCreateInfo.extent.depth : srcCreateInfo.arraySize; // Keep track of the previous graphics pipeline to reduce the pipeline switching overhead. const GraphicsPipeline* pPreviousPipeline = nullptr; // Accumulate the restore mask for each region copied. uint32 restoreMask = 0; // Each region needs to be copied individually. for (uint32 region = 0; region < regionCount; ++region) { // Multiply all x-dimension values in our region by the texel scale. ImageCopyRegion copyRegion = pRegions[region]; // Determine which image formats to use for the copy. SwizzledFormat dstFormat = { }; SwizzledFormat srcFormat = { }; uint32 texelScale = 1; bool singleSubres = false; GetCopyImageFormats(srcImage, srcImageLayout, dstImage, dstImageLayout, copyRegion, flags, &srcFormat, &dstFormat, &texelScale, &singleSubres); // Update the color target view format with the destination format. colorViewInfo.swizzledFormat = dstFormat; // Only switch to the appropriate graphics pipeline if it differs from the previous region's pipeline. const GraphicsPipeline*const pPipeline = GetGfxPipelineByTargetIndexAndFormat(Copy_32ABGR, 0, dstFormat); if (pPreviousPipeline != pPipeline) { pCmdBuffer->CmdBindPipeline({ PipelineBindPoint::Graphics, pPipeline, InternalApiPsoHash, }); pCmdBuffer->CmdOverwriteRbPlusFormatForBlits(dstFormat, 0); pPreviousPipeline = pPipeline; } if (singleSubres == false) { // We'll setup both 2D and 3D src images as a 2D view. // // Is it legal for the shader to view 3D images as 2D? ImageViewInfo imageView = {}; RpmUtil::BuildImageViewInfo(&imageView, srcImage, viewRange, srcFormat, srcImageLayout, device.TexOptLevel()); // Create an embedded SRD table and bind it to user data 4 for pixel work. uint32* pSrdTable = RpmUtil::CreateAndBindEmbeddedUserData(pCmdBuffer, SrdDwordAlignment(), SrdDwordAlignment(), PipelineBindPoint::Graphics, 4); // Populate the table with an image view of the source image. device.CreateImageViewSrds(1, &imageView, pSrdTable); } // Give the gfxip layer a chance to optimize the hardware before we start copying. const uint32 bitsPerPixel = Formats::BitsPerPixel(dstFormat.format); restoreMask |= HwlBeginGraphicsCopy(pCmdBuffer, pPipeline, dstImage, bitsPerPixel); // When copying from 3D to 3D, the number of slices should be 1. When copying from // 1D to 1D or 2D to 2D, depth should be 1. Therefore when the src image type is identical // to the dst image type, either the depth or the number of slices should be equal to 1. PAL_ASSERT((srcCreateInfo.imageType != dstCreateInfo.imageType) || (copyRegion.numSlices == 1) || (copyRegion.extent.depth == 1)); // When copying from 2D to 3D or 3D to 2D, the number of slices should match the depth. PAL_ASSERT((srcCreateInfo.imageType == dstCreateInfo.imageType) || ((((srcCreateInfo.imageType == ImageType::Tex3d) && (dstCreateInfo.imageType == ImageType::Tex2d)) || ((srcCreateInfo.imageType == ImageType::Tex2d) && (dstCreateInfo.imageType == ImageType::Tex3d))) && (copyRegion.numSlices == copyRegion.extent.depth))); copyRegion.srcOffset.x *= texelScale; copyRegion.dstOffset.x *= texelScale; copyRegion.extent.width *= texelScale; // Setup the viewport and scissor to restrict rendering to the destination region being copied. viewportInfo.viewports[0].originX = static_cast<float>(copyRegion.dstOffset.x); viewportInfo.viewports[0].originY = static_cast<float>(copyRegion.dstOffset.y); viewportInfo.viewports[0].width = static_cast<float>(copyRegion.extent.width); viewportInfo.viewports[0].height = static_cast<float>(copyRegion.extent.height); #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 603 if (TestAnyFlagSet(flags, CopyEnableScissorTest)) { scissorInfo.scissors[0].offset.x = pScissorRect->offset.x; scissorInfo.scissors[0].offset.y = pScissorRect->offset.y; scissorInfo.scissors[0].extent.width = pScissorRect->extent.width; scissorInfo.scissors[0].extent.height = pScissorRect->extent.height; } else #endif { scissorInfo.scissors[0].offset.x = copyRegion.dstOffset.x; scissorInfo.scissors[0].offset.y = copyRegion.dstOffset.y; scissorInfo.scissors[0].extent.width = copyRegion.extent.width; scissorInfo.scissors[0].extent.height = copyRegion.extent.height; } pCmdBuffer->CmdSetViewports(viewportInfo); pCmdBuffer->CmdSetScissorRects(scissorInfo); const float texcoordVs[4] = { static_cast<float>(copyRegion.srcOffset.x), static_cast<float>(copyRegion.srcOffset.y), static_cast<float>(copyRegion.srcOffset.x + copyRegion.extent.width), static_cast<float>(copyRegion.srcOffset.y + copyRegion.extent.height) }; const uint32* pUserDataVs = reinterpret_cast<const uint32*>(&texcoordVs); pCmdBuffer->CmdSetUserData(PipelineBindPoint::Graphics, 0, 4, pUserDataVs); // Copy may happen between the layers of a 2d image and the slices of a 3d image. const uint32 numSlices = Max(copyRegion.numSlices, copyRegion.extent.depth); // Each slice is copied individually, we can optimize this into fewer draw calls if it becomes a // performance bottleneck, but for now this is simpler. for (uint32 sliceOffset = 0; sliceOffset < numSlices; ++sliceOffset) { const uint32 srcSlice = ((srcCreateInfo.imageType == ImageType::Tex3d) ? copyRegion.srcOffset.z + sliceOffset : copyRegion.srcSubres.arraySlice + sliceOffset); if (singleSubres) { const bool singleArrayAccess = (srcCreateInfo.imageType != ImageType::Tex3d); const bool singlezRangeAccess = (srcCreateInfo.imageType == ImageType::Tex3d) && HwlNeedSinglezRangeAccess(); #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 642 viewRange.numPlanes = 1; #endif viewRange.numMips = 1; viewRange.numSlices = 1; viewRange.startSubres = copyRegion.srcSubres; if (singleArrayAccess) { viewRange.startSubres.arraySlice += sliceOffset; } ImageViewInfo imageView = {}; RpmUtil::BuildImageViewInfo(&imageView, srcImage, viewRange, srcFormat, srcImageLayout, device.TexOptLevel()); if (singlezRangeAccess) { imageView.zRange.offset = srcSlice; imageView.zRange.extent = 1; imageView.flags.zRangeValid = 1; } // Create an embedded SRD table and bind it to user data 4 for pixel work. uint32* pSrdTable = RpmUtil::CreateAndBindEmbeddedUserData(pCmdBuffer, SrdDwordAlignment(), SrdDwordAlignment(), PipelineBindPoint::Graphics, 4); // Populate the table with an image view of the source image. device.CreateImageViewSrds(1, &imageView, pSrdTable); const uint32 userDataPs[2] = { (singleArrayAccess || singlezRangeAccess) ? 0 : sliceOffset, 0 }; pCmdBuffer->CmdSetUserData(PipelineBindPoint::Graphics, 5, 2, &userDataPs[0]); } else { const uint32 userDataPs[2] = { srcSlice, copyRegion.srcSubres.mipLevel }; pCmdBuffer->CmdSetUserData(PipelineBindPoint::Graphics, 5, 2, &userDataPs[0]); } colorViewInfo.imageInfo.baseSubRes = copyRegion.dstSubres; if (dstCreateInfo.imageType == ImageType::Tex3d) { colorViewInfo.zRange.offset = copyRegion.dstOffset.z + sliceOffset; } else { colorViewInfo.imageInfo.baseSubRes.arraySlice = copyRegion.dstSubres.arraySlice + sliceOffset; } // Create and bind a color-target view for this slice. LinearAllocatorAuto<VirtualLinearAllocator> sliceAlloc(pCmdBuffer->Allocator(), false); IColorTargetView* pColorView = nullptr; void* pColorViewMem = PAL_MALLOC(m_pDevice->GetColorTargetViewSize(nullptr), &sliceAlloc, AllocInternalTemp); if (pColorViewMem == nullptr) { pCmdBuffer->NotifyAllocFailure(); } else { // Since our color target view can only bind 1 slice at a time, we have to issue a separate draw for // each slice in extent.z. We can keep the same src image view since we pass the explicit slice to // read from in user data, but we'll need to create a new color target view each time. Result result = m_pDevice->CreateColorTargetView(colorViewInfo, colorViewInfoInternal, pColorViewMem, &pColorView); PAL_ASSERT(result == Result::Success); bindTargetsInfo.colorTargets[0].pColorTargetView = pColorView; bindTargetsInfo.colorTargetCount = 1; pCmdBuffer->CmdBindTargets(bindTargetsInfo); // Draw a fullscreen quad. pCmdBuffer->CmdDraw(0, 3, 0, 1, 0); // Unbind the color-target view. bindTargetsInfo.colorTargetCount = 0; pCmdBuffer->CmdBindTargets(bindTargetsInfo); PAL_SAFE_FREE(pColorViewMem, &sliceAlloc); } } } // Call back to the gfxip layer so it can restore any state it modified previously. HwlEndGraphicsCopy(pStream, restoreMask); // Restore original command buffer state. pCmdBuffer->PopGraphicsState(); } // ===================================================================================================================== // Copies multisampled depth-stencil images using a graphics pipeline. void RsrcProcMgr::CopyDepthStencilImageGraphics( GfxCmdBuffer* pCmdBuffer, const Image& srcImage, ImageLayout srcImageLayout, const Image& dstImage, ImageLayout dstImageLayout, uint32 regionCount, const ImageCopyRegion* pRegions, const Rect* pScissorRect, uint32 flags ) const { PAL_ASSERT(pCmdBuffer->IsGraphicsSupported()); // Don't expect GFX Blts on Nested unless targets not inherited. PAL_ASSERT((pCmdBuffer->IsNested() == false) || (static_cast<UniversalCmdBuffer*>( pCmdBuffer)->GetGraphicsState().inheritedState.stateFlags.targetViewState == 0)); const auto& device = *m_pDevice->Parent(); const auto& texOptLevel = device.TexOptLevel(); const auto& dstCreateInfo = dstImage.GetImageCreateInfo(); const auto& srcCreateInfo = srcImage.GetImageCreateInfo(); const StencilRefMaskParams stencilRefMasks = { 0xFF, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0x01, 0xFF, }; // Initialize some structures we will need later on. ViewportParams viewportInfo = { }; viewportInfo.count = 1; viewportInfo.viewports[0].minDepth = 0.f; viewportInfo.viewports[0].maxDepth = 1.f; viewportInfo.viewports[0].origin = PointOrigin::UpperLeft; viewportInfo.horzClipRatio = FLT_MAX; viewportInfo.horzDiscardRatio = 1.0f; viewportInfo.vertClipRatio = FLT_MAX; viewportInfo.vertDiscardRatio = 1.0f; viewportInfo.depthRange = DepthRange::ZeroToOne; ScissorRectParams scissorInfo = { }; scissorInfo.count = 1; const DepthStencilViewInternalCreateInfo noDepthViewInfoInternal = { }; DepthStencilViewCreateInfo depthViewInfo = { }; depthViewInfo.pImage = &dstImage; depthViewInfo.arraySize = 1; // Save current command buffer state and bind graphics state which is common for all regions. pCmdBuffer->PushGraphicsState(); BindCommonGraphicsState(pCmdBuffer); pCmdBuffer->CmdBindMsaaState(GetMsaaState(dstCreateInfo.samples, dstCreateInfo.fragments)); pCmdBuffer->CmdSetStencilRefMasks(stencilRefMasks); RpmUtil::WriteVsZOut(pCmdBuffer, 1.0f); // Setup the viewport and scissor to restrict rendering to the destination region being copied. viewportInfo.viewports[0].originX = static_cast<float>(pRegions[0].dstOffset.x); viewportInfo.viewports[0].originY = static_cast<float>(pRegions[0].dstOffset.y); viewportInfo.viewports[0].width = static_cast<float>(pRegions[0].extent.width); viewportInfo.viewports[0].height = static_cast<float>(pRegions[0].extent.height); #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 603 if (TestAnyFlagSet(flags, CopyEnableScissorTest)) { scissorInfo.scissors[0].offset.x = pScissorRect->offset.x; scissorInfo.scissors[0].offset.y = pScissorRect->offset.y; scissorInfo.scissors[0].extent.width = pScissorRect->extent.width; scissorInfo.scissors[0].extent.height = pScissorRect->extent.height; } else #endif { scissorInfo.scissors[0].offset.x = pRegions[0].dstOffset.x; scissorInfo.scissors[0].offset.y = pRegions[0].dstOffset.y; scissorInfo.scissors[0].extent.width = pRegions[0].extent.width; scissorInfo.scissors[0].extent.height = pRegions[0].extent.height; } // The shader will calculate src coordinates by adding a delta to the dst coordinates. The user data should // contain those deltas which are (srcOffset-dstOffset) for X & Y. const int32 xOffset = (pRegions[0].srcOffset.x - pRegions[0].dstOffset.x); const int32 yOffset = (pRegions[0].srcOffset.y - pRegions[0].dstOffset.y); const uint32 userData[2] = { reinterpret_cast<const uint32&>(xOffset), reinterpret_cast<const uint32&>(yOffset) }; pCmdBuffer->CmdSetViewports(viewportInfo); pCmdBuffer->CmdSetScissorRects(scissorInfo); pCmdBuffer->CmdSetUserData(PipelineBindPoint::Graphics, 2, 2, userData); // To improve performance, input src coordinates to VS, avoid using screen position in PS. const float texcoordVs[4] = { static_cast<float>(pRegions[0].srcOffset.x), static_cast<float>(pRegions[0].srcOffset.y), static_cast<float>(pRegions[0].srcOffset.x + pRegions[0].extent.width), static_cast<float>(pRegions[0].srcOffset.y + pRegions[0].extent.height) }; const uint32* pUserDataVs = reinterpret_cast<const uint32*>(&texcoordVs); pCmdBuffer->CmdSetUserData(PipelineBindPoint::Graphics, 6, 4, pUserDataVs); AutoBuffer<bool, 16, Platform> isRangeProcessed(regionCount, m_pDevice->GetPlatform()); PAL_ASSERT(isRangeProcessed.Capacity() >= regionCount); // Notify the command buffer that the AutoBuffer allocation has failed. if (isRangeProcessed.Capacity() < regionCount) { pCmdBuffer->NotifyAllocFailure(); } else { memset(&isRangeProcessed[0], false, isRangeProcessed.SizeBytes()); // Now issue fast or slow clears to all ranges, grouping identical depth/stencil pairs if possible. for (uint32 idx = 0; idx < regionCount; idx++) { // Same sanity checks of the region planes. #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 const bool isDepth = (pRegions[idx].dstSubres.aspect == ImageAspect::Depth); #else const bool isDepth = dstImage.IsDepthPlane(pRegions[idx].dstSubres.plane); #endif bool isDepthStencil = false; BindTargetParams bindTargetsInfo = {}; // It's possible that SRC may be not a depth/stencil resource and it's created with X32_UINT from // R32_TYPELESS, use DST's format to setup SRC format correctly. const ChNumFormat depthFormat = dstImage.GetImageCreateInfo().swizzledFormat.format; bindTargetsInfo.depthTarget.depthLayout = dstImageLayout; // No need to clear a range twice. if (isRangeProcessed[idx]) { continue; } uint32 secondSurface = 0; // Search the range list to see if there is a matching range which span the other plane. for (uint32 forwardIdx = idx + 1; forwardIdx < regionCount; ++forwardIdx) { // TODO: there is unknown corruption issue if grouping depth and stencil copy together for mipmap // image, disallow merging copy for mipmap image as a temp fix. if ((dstCreateInfo.mipLevels == 1) && #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 (pRegions[forwardIdx].srcSubres.aspect != pRegions[idx].srcSubres.aspect) && (pRegions[forwardIdx].dstSubres.aspect != pRegions[idx].dstSubres.aspect) && #else (pRegions[forwardIdx].srcSubres.plane != pRegions[idx].srcSubres.plane) && (pRegions[forwardIdx].dstSubres.plane != pRegions[idx].dstSubres.plane) && #endif (pRegions[forwardIdx].srcSubres.mipLevel == pRegions[idx].srcSubres.mipLevel) && (pRegions[forwardIdx].dstSubres.mipLevel == pRegions[idx].dstSubres.mipLevel) && (pRegions[forwardIdx].srcSubres.arraySlice == pRegions[idx].srcSubres.arraySlice) && (pRegions[forwardIdx].dstSubres.arraySlice == pRegions[idx].dstSubres.arraySlice) && (pRegions[forwardIdx].extent.depth == pRegions[idx].extent.depth) && (pRegions[forwardIdx].extent.height == pRegions[idx].extent.height) && (pRegions[forwardIdx].extent.width == pRegions[idx].extent.width) && (pRegions[forwardIdx].numSlices == pRegions[idx].numSlices)) { // We found a matching range for the other plane, clear them both at once. isDepthStencil = true; isRangeProcessed[forwardIdx] = true; secondSurface = forwardIdx; break; } } pCmdBuffer->CmdBindPipeline({ PipelineBindPoint::Graphics, GetCopyDepthStencilPipeline( isDepth, isDepthStencil, srcImage.GetImageCreateInfo().samples), InternalApiPsoHash, }); // Determine which format we should use to view the source image. SwizzledFormat srcFormat = { ChNumFormat::Undefined, { ChannelSwizzle::X, ChannelSwizzle::Zero, ChannelSwizzle::Zero, ChannelSwizzle::One }, }; if (isDepthStencil) { // We should only be in the depth stencil case when we have a depth stencil format PAL_ASSERT((depthFormat == ChNumFormat::D32_Float_S8_Uint) || (depthFormat == ChNumFormat::D16_Unorm_S8_Uint)); if (depthFormat == ChNumFormat::D32_Float_S8_Uint) { srcFormat.format = ChNumFormat::X32_Float; } else { srcFormat.format = ChNumFormat::X16_Unorm; } pCmdBuffer->CmdBindDepthStencilState(m_pDepthStencilResolveState); } else if (isDepth) { if ((depthFormat == ChNumFormat::D32_Float_S8_Uint) || (depthFormat == ChNumFormat::X32_Float)) { srcFormat.format = ChNumFormat::X32_Float; } else { srcFormat.format = ChNumFormat::X16_Unorm; } pCmdBuffer->CmdBindDepthStencilState(m_pDepthResolveState); } else { srcFormat.format = ChNumFormat::X8_Uint; pCmdBuffer->CmdBindDepthStencilState(m_pStencilResolveState); } for (uint32 slice = 0; slice < pRegions[idx].numSlices; ++slice) { LinearAllocatorAuto<VirtualLinearAllocator> sliceAlloc(pCmdBuffer->Allocator(), false); // Create an embedded user-data table and bind it to user data 1. We need an image view for each plane. const uint32 numSrds = isDepthStencil ? 2 : 1; uint32* pSrdTable = RpmUtil::CreateAndBindEmbeddedUserData(pCmdBuffer, SrdDwordAlignment() * numSrds, SrdDwordAlignment(), PipelineBindPoint::Graphics, 1); if (isDepthStencil) { // Populate the table with an image view of the source image. ImageViewInfo imageView[2] = {}; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 SubresRange viewRange = { pRegions[idx].srcSubres, 1, 1 }; #else SubresRange viewRange = { pRegions[idx].srcSubres, 1, 1, 1 }; #endif viewRange.startSubres.arraySlice += slice; RpmUtil::BuildImageViewInfo(&imageView[0], srcImage, viewRange, srcFormat, srcImageLayout, texOptLevel); constexpr SwizzledFormat StencilSrcFormat = { ChNumFormat::X8_Uint, { ChannelSwizzle::X, ChannelSwizzle::Zero, ChannelSwizzle::Zero, ChannelSwizzle::One }, }; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 viewRange = { pRegions[secondSurface].srcSubres, 1, 1 }; #else viewRange = { pRegions[secondSurface].srcSubres, 1, 1, 1 }; #endif viewRange.startSubres.arraySlice += slice; RpmUtil::BuildImageViewInfo(&imageView[1], srcImage, viewRange, StencilSrcFormat, srcImageLayout, texOptLevel); device.CreateImageViewSrds(2, &imageView[0], pSrdTable); } else { // Populate the table with an image view of the source image. ImageViewInfo imageView = {}; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 SubresRange viewRange = { pRegions[idx].srcSubres, 1, 1 }; #else SubresRange viewRange = { pRegions[idx].srcSubres, 1, 1, 1 }; #endif viewRange.startSubres.arraySlice += slice; RpmUtil::BuildImageViewInfo(&imageView, srcImage, viewRange, srcFormat, srcImageLayout, texOptLevel); device.CreateImageViewSrds(1, &imageView, pSrdTable); } // Create and bind a depth stencil view of the destination region. depthViewInfo.baseArraySlice = pRegions[idx].dstSubres.arraySlice + slice; depthViewInfo.mipLevel = pRegions[idx].dstSubres.mipLevel; void* pDepthStencilViewMem = PAL_MALLOC(m_pDevice->GetDepthStencilViewSize(nullptr), &sliceAlloc, AllocInternalTemp); if (pDepthStencilViewMem == nullptr) { pCmdBuffer->NotifyAllocFailure(); } else { IDepthStencilView* pDepthView = nullptr; Result result = m_pDevice->CreateDepthStencilView(depthViewInfo, noDepthViewInfoInternal, pDepthStencilViewMem, &pDepthView); PAL_ASSERT(result == Result::Success); bindTargetsInfo.depthTarget.pDepthStencilView = pDepthView; pCmdBuffer->CmdBindTargets(bindTargetsInfo); // Draw a fullscreen quad. pCmdBuffer->CmdDraw(0, 3, 0, 1, 0); // Unbind the depth view and destroy it. bindTargetsInfo.depthTarget.pDepthStencilView = nullptr; pCmdBuffer->CmdBindTargets(bindTargetsInfo); PAL_SAFE_FREE(pDepthStencilViewMem, &sliceAlloc); } } // End for each slice. } // End for each region } // Restore original command buffer state. pCmdBuffer->PopGraphicsState(); } // ===================================================================================================================== // Builds commands to copy one or more regions from one image to another using a compute shader. // The caller should assert that the source and destination images have the same image types and sample counts. void RsrcProcMgr::CopyImageCompute( GfxCmdBuffer* pCmdBuffer, const Image& srcImage, ImageLayout srcImageLayout, const Image& dstImage, ImageLayout dstImageLayout, uint32 regionCount, const ImageCopyRegion* pRegions, uint32 flags ) const { #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 603 PAL_ASSERT(TestAnyFlagSet(flags, CopyEnableScissorTest) == false); #endif const auto& device = *m_pDevice->Parent(); const auto& dstCreateInfo = dstImage.GetImageCreateInfo(); const auto& srcCreateInfo = srcImage.GetImageCreateInfo(); const bool isCompressed = (Formats::IsBlockCompressed(srcCreateInfo.swizzledFormat.format) || Formats::IsBlockCompressed(dstCreateInfo.swizzledFormat.format)); const bool useMipInSrd = CopyImageUseMipLevelInSrd(isCompressed); const GfxImage* pSrcGfxImage = srcImage.GetGfxImage(); const ImageType imageType = pSrcGfxImage->GetOverrideImageType(); const bool isEqaaSrc = (srcCreateInfo.samples != srcCreateInfo.fragments); bool isFmaskCopy = false; bool isFmaskCopyOptimized = false; // Get the appropriate pipeline object. const ComputePipeline* pPipeline = nullptr; // The Fmask accelerated copy should be used in all non-EQAA cases where Fmask is enabled. There is no use case // Fmask accelerated EQAA copy and it would require several new shaders. It can be implemented at a future // point if required. if (pSrcGfxImage->HasFmaskData() && isEqaaSrc) { PAL_NOT_IMPLEMENTED(); } if (pSrcGfxImage->HasFmaskData() && (isEqaaSrc == false)) { PAL_ASSERT(srcCreateInfo.fragments > 1); PAL_ASSERT((srcImage.IsDepthStencilTarget() == false) && (dstImage.IsDepthStencilTarget() == false)); // Optimized image copies require a call to HwlFixupCopyDstImageMetaData... // Verify that any "update" operation performed is legal for the source and dest images. if (HwlUseOptimizedImageCopy(srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions)) { pPipeline = GetPipeline(RpmComputePipeline::MsaaFmaskCopyImageOptimized); isFmaskCopyOptimized = true; } else { pPipeline = GetPipeline(RpmComputePipeline::MsaaFmaskCopyImage); } isFmaskCopy = true; } else { switch (srcCreateInfo.fragments) { case 2: pPipeline = GetPipeline(RpmComputePipeline::CopyImage2dms2x); break; case 4: pPipeline = GetPipeline(RpmComputePipeline::CopyImage2dms4x); break; case 8: pPipeline = GetPipeline(RpmComputePipeline::CopyImage2dms8x); break; default: if (useMipInSrd) { pPipeline = GetPipeline(RpmComputePipeline::CopyImage2d); } else { pPipeline = GetPipeline(RpmComputePipeline::CopyImage2dShaderMipLevel); } break; } } const bool isSrgbDst = (Formats::IsSrgb(dstCreateInfo.swizzledFormat.format) && (Formats::IsSrgb(srcCreateInfo.swizzledFormat.format) == false)); // If the destination format is srgb and we will be doing format conversion copy then we need to use the pipeline // that will properly perform gamma correction. Note: If both src and dst are srgb then we'll do a raw copy and so // no need to change pipelines in that case. if (isSrgbDst && TestAnyFlagSet(flags, CopyFormatConversion)) { pPipeline = GetPipeline(RpmComputePipeline::CopyImageGammaCorrect2d); } // Get number of threads per groups in each dimension, we will need this data later. uint32 threadsPerGroup[3] = {}; pPipeline->ThreadsPerGroupXyz(&threadsPerGroup[0], &threadsPerGroup[1], &threadsPerGroup[2]); bool p2pBltInfoRequired = m_pDevice->Parent()->IsP2pBltWaRequired(*dstImage.GetBoundGpuMemory().Memory()); uint32 newRegionCount = 0; if (p2pBltInfoRequired) { m_pDevice->P2pBltWaModifyRegionListImage(srcImage, dstImage, regionCount, pRegions, &newRegionCount, nullptr, nullptr); } AutoBuffer<ImageCopyRegion, 32, Platform> newRegions(newRegionCount, m_pDevice->GetPlatform()); AutoBuffer<gpusize, 32, Platform> chunkAddrs(newRegionCount, m_pDevice->GetPlatform()); if (p2pBltInfoRequired) { if ((newRegions.Capacity() >= newRegionCount) && (chunkAddrs.Capacity() >= newRegionCount)) { m_pDevice->P2pBltWaModifyRegionListImage(srcImage, dstImage, regionCount, pRegions, &newRegionCount, &newRegions[0], &chunkAddrs[0]); regionCount = newRegionCount; pRegions = &newRegions[0]; pCmdBuffer->P2pBltWaCopyBegin(dstImage.GetBoundGpuMemory().Memory(), regionCount, &chunkAddrs[0]); } else { pCmdBuffer->NotifyAllocFailure(); p2pBltInfoRequired = false; } } // Save current command buffer state and bind the pipeline. pCmdBuffer->CmdSaveComputeState(ComputeStatePipelineAndUserData); pCmdBuffer->CmdBindPipeline({ PipelineBindPoint::Compute, pPipeline, InternalApiPsoHash, }); // Now begin processing the list of copy regions. for (uint32 idx = 0; idx < regionCount; ++idx) { ImageCopyRegion copyRegion = pRegions[idx]; // When copying from 3D to 3D, the number of slices should be 1. When copying from // 1D to 1D or 2D to 2D, depth should be 1. Therefore when the src image type is identical // to the dst image type, either the depth or the number of slices should be equal to 1. PAL_ASSERT((srcCreateInfo.imageType != dstCreateInfo.imageType) || (copyRegion.numSlices == 1) || (copyRegion.extent.depth == 1)); #if PAL_ENABLE_PRINTS_ASSERTS // When copying from 2D to 3D or 3D to 2D, the number of slices should match the depth. if (((srcCreateInfo.imageType == ImageType::Tex3d) && (dstCreateInfo.imageType == ImageType::Tex2d)) || ((srcCreateInfo.imageType == ImageType::Tex2d) && (dstCreateInfo.imageType == ImageType::Tex3d))) { PAL_ASSERT(copyRegion.numSlices == copyRegion.extent.depth); } #endif if (p2pBltInfoRequired) { pCmdBuffer->P2pBltWaCopyNextRegion(chunkAddrs[idx]); } // Setup image formats per-region. This is different than the graphics path because the compute path must be // able to copy depth-stencil images. SwizzledFormat dstFormat = {}; SwizzledFormat srcFormat = {}; uint32 texelScale = 1; bool singleSubres = false; GetCopyImageFormats(srcImage, srcImageLayout, dstImage, dstImageLayout, copyRegion, flags, &srcFormat, &dstFormat, &texelScale, &singleSubres); // The hardware can't handle UAV stores using SRGB num format. The resolve shaders already contain a // linear-to-gamma conversion, but in order for that to work the output UAV's num format must be patched to be // simple unorm. if (Formats::IsSrgb(dstFormat.format)) { dstFormat.format = Formats::ConvertToUnorm(dstFormat.format); PAL_ASSERT(Formats::IsUndefined(dstFormat.format) == false); } // Multiply all x-dimension values in our region by the texel scale. copyRegion.srcOffset.x *= texelScale; copyRegion.dstOffset.x *= texelScale; copyRegion.extent.width *= texelScale; RpmUtil::CopyImageInfo copyImageInfo = {}; copyImageInfo.srcOffset = copyRegion.srcOffset; copyImageInfo.dstOffset = copyRegion.dstOffset; copyImageInfo.numSamples = dstCreateInfo.samples; copyImageInfo.packedMipData.srcMipLevel = copyRegion.srcSubres.mipLevel; copyImageInfo.packedMipData.dstMipLevel = copyRegion.dstSubres.mipLevel; copyImageInfo.copyRegion.width = copyRegion.extent.width; copyImageInfo.copyRegion.height = copyRegion.extent.height; // Create an embedded user-data table and bind it to user data 0. We need image views for the src and dst // subresources, as well as some inline constants for the copy offsets and extents. const uint8 numSlots = isFmaskCopy ? 3 : 2; uint32* pUserData = RpmUtil::CreateAndBindEmbeddedUserData(pCmdBuffer, (SrdDwordAlignment() * numSlots + RpmUtil::CopyImageInfoDwords), SrdDwordAlignment(), PipelineBindPoint::Compute, 0); // When we treat 3D images as 2D arrays each z-slice must be treated as an array slice. const uint32 numSlices = (imageType == ImageType::Tex3d) ? copyRegion.extent.depth : copyRegion.numSlices; ImageViewInfo imageView[2] = {}; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 SubresRange viewRange = { copyRegion.dstSubres, 1, numSlices }; #else SubresRange viewRange = { copyRegion.dstSubres, 1, 1, numSlices }; #endif PAL_ASSERT(TestAnyFlagSet(dstImageLayout.usages, LayoutShaderWrite | LayoutCopyDst) == true); RpmUtil::BuildImageViewInfo(&imageView[0], dstImage, viewRange, dstFormat, dstImageLayout, device.TexOptLevel()); viewRange.startSubres = copyRegion.srcSubres; RpmUtil::BuildImageViewInfo(&imageView[1], srcImage, viewRange, srcFormat, srcImageLayout, device.TexOptLevel()); // The shader treats all images as 2D arrays which means we need to override the view type to 2D. We also used // to do this for 3D images but that caused test failures when the images used mipmaps because the HW expected // the "numSlices" to be constant for all mip levels (rather than halving at each mip as z-slices do). // // Is it legal for the shader to view 1D and 3D images as 2D? if (imageType == ImageType::Tex1d) { imageView[0].viewType = ImageViewType::Tex2d; imageView[1].viewType = ImageViewType::Tex2d; } if (useMipInSrd == false) { // The miplevel as specified in the shader instruction is actually an offset from the mip-level // as specified in the SRD. imageView[0].subresRange.startSubres.mipLevel = 0; // dst imageView[1].subresRange.startSubres.mipLevel = 0; // src // The mip-level from the instruction is also clamped to the "last level" as specified in the SRD. imageView[0].subresRange.numMips = copyRegion.dstSubres.mipLevel + viewRange.numMips; imageView[1].subresRange.numMips = copyRegion.srcSubres.mipLevel + viewRange.numMips; } PAL_ASSERT(singleSubres == false); // Turn our image views into HW SRDs here device.CreateImageViewSrds(2, &imageView[0], pUserData); pUserData += SrdDwordAlignment() * 2; if (isFmaskCopy) { // If this is an Fmask-accelerated Copy, create an image view of the source Image's Fmask surface. FmaskViewInfo fmaskView = {}; fmaskView.pImage = &srcImage; fmaskView.baseArraySlice = copyRegion.srcSubres.arraySlice; fmaskView.arraySize = copyRegion.numSlices; m_pDevice->Parent()->CreateFmaskViewSrds(1, &fmaskView, pUserData); pUserData += SrdDwordAlignment(); } // Copy the copy parameters into the embedded user-data space memcpy(pUserData, &copyImageInfo, sizeof(copyImageInfo)); // Execute the dispatch, we need one thread per texel. pCmdBuffer->CmdDispatch(RpmUtil::MinThreadGroups(copyRegion.extent.width, threadsPerGroup[0]), RpmUtil::MinThreadGroups(copyRegion.extent.height, threadsPerGroup[1]), RpmUtil::MinThreadGroups(numSlices, threadsPerGroup[2])); } if (p2pBltInfoRequired) { pCmdBuffer->P2pBltWaCopyEnd(); } pCmdBuffer->CmdRestoreComputeState(ComputeStatePipelineAndUserData); if (isFmaskCopyOptimized #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 562 || (dstImage.GetImageCreateInfo().flags.fullCopyDstOnly != 0) #endif ) { // If this is MSAA copy optimized we might have to update destination image meta data. // If image is created with fullCopyDstOnly=1, there will be no expand when transition to "LayoutCopyDst"; if // the copy isn't compressed copy, need fix up dst metadata to uncompressed state. const Pal::Image* pSrcImage = isFmaskCopyOptimized ? &srcImage : nullptr; AutoBuffer<ImageFixupRegion, 32, Platform> fixupRegions(regionCount, m_pDevice->GetPlatform()); if (fixupRegions.Capacity() >= regionCount) { for (uint32 i = 0; i < regionCount; i++) { fixupRegions[i].subres = pRegions[i].dstSubres; fixupRegions[i].offset = pRegions[i].dstOffset; fixupRegions[i].extent = pRegions[i].extent; fixupRegions[i].numSlices = pRegions[i].numSlices; } HwlFixupCopyDstImageMetaData(pCmdBuffer, pSrcImage, dstImage, dstImageLayout, &fixupRegions[0], regionCount, isFmaskCopyOptimized); } else { pCmdBuffer->NotifyAllocFailure(); } } } // ===================================================================================================================== // Picks a source format and a destination format for an image-to-image copy. template <typename CopyRegion> void RsrcProcMgr::GetCopyImageFormats( const Image& srcImage, ImageLayout srcImageLayout, const Image& dstImage, ImageLayout dstImageLayout, const CopyRegion& copyRegion, uint32 copyFlags, SwizzledFormat* pSrcFormat, // [out] Read from the source image using this format. SwizzledFormat* pDstFormat, // [out] Read from the destination image using this format. uint32* pTexelScale, // [out] Each texel requires this many raw format texels in the X dimension. bool* pSingleSubres // [out] Format requires that you access each subres independantly. ) const { const auto& device = *m_pDevice->Parent(); const auto& srcCreateInfo = srcImage.GetImageCreateInfo(); const auto& dstCreateInfo = dstImage.GetImageCreateInfo(); // Begin with each subresource's native format. SwizzledFormat srcFormat = srcImage.SubresourceInfo(copyRegion.srcSubres)->format; SwizzledFormat dstFormat = dstImage.SubresourceInfo(copyRegion.dstSubres)->format; const bool isSrcFormatReplaceable = srcImage.GetGfxImage()->IsFormatReplaceable(copyRegion.srcSubres, srcImageLayout, false); const bool isDstFormatReplaceable = dstImage.GetGfxImage()->IsFormatReplaceable(copyRegion.dstSubres, dstImageLayout, true); const bool chFmtsMatch = Formats::ShareChFmt(srcFormat.format, dstFormat.format); const bool formatsMatch = (srcFormat.format == dstFormat.format) && (srcFormat.swizzle.swizzleValue == dstFormat.swizzle.swizzleValue); const bool isMmFormatUsed = (Formats::IsMmFormat(srcFormat.format) || Formats::IsMmFormat(dstFormat.format)); // Both formats must have the same pixel size. PAL_ASSERT(Formats::BitsPerPixel(srcFormat.format) == Formats::BitsPerPixel(dstFormat.format)); // Initialize the texel scale to 1, it will be modified later if necessary. *pTexelScale = 1; // First, determine if we must follow conversion copy rules. if (TestAnyFlagSet(copyFlags, CopyFormatConversion) && device.SupportsFormatConversionSrc(srcFormat.format, srcCreateInfo.tiling) && device.SupportsFormatConversionDst(dstFormat.format, dstCreateInfo.tiling)) { // Eventhough we're supposed to do a conversion copy, it will be faster if we can get away with a raw copy. // It will be safe to do a raw copy if the formats match and the target subresources support format replacement. if (formatsMatch && isSrcFormatReplaceable && isDstFormatReplaceable) { srcFormat = RpmUtil::GetRawFormat(srcFormat.format, pTexelScale, pSingleSubres); dstFormat = srcFormat; } } else { // We will be doing some sort of raw copy. // // Our copy shaders and hardware treat sRGB and UNORM nearly identically, the only difference being that the // hardware modifies sRGB data when reading it and can't write it, which will make it hard to do a raw copy. // We can avoid that problem by simply forcing sRGB to UNORM. if (Formats::IsSrgb(srcFormat.format)) { srcFormat.format = Formats::ConvertToUnorm(srcFormat.format); } if (Formats::IsSrgb(dstFormat.format)) { dstFormat.format = Formats::ConvertToUnorm(dstFormat.format); } // Due to hardware-specific compression modes, some image subresources might not support format replacement. // Note that the code above can force sRGB to UNORM even if format replacement is not supported because sRGB // values use the same bit representation as UNORM values, they just use a different color space. if (isSrcFormatReplaceable && isDstFormatReplaceable) { // We should do a raw copy that respects channel swizzling if the flag is set and the channel formats // don't match. The process is simple: keep the channel formats and try to find a single numeric format // that fits both of them. bool foundSwizzleFormats = false; if (TestAnyFlagSet(copyFlags, CopyRawSwizzle) && (chFmtsMatch == false)) { typedef ChNumFormat(PAL_STDCALL *FormatConversion)(ChNumFormat); constexpr uint32 NumNumericFormats = 3; constexpr FormatConversion FormatConversionFuncs[NumNumericFormats] = { &Formats::ConvertToUint, &Formats::ConvertToUnorm, &Formats::ConvertToFloat, }; for (uint32 idx = 0; idx < NumNumericFormats; ++idx) { ChNumFormat tempSrcFmt = srcFormat.format; ChNumFormat tempDstFmt = dstFormat.format; tempSrcFmt = FormatConversionFuncs[idx](tempSrcFmt); tempDstFmt = FormatConversionFuncs[idx](tempDstFmt); if ((Formats::IsUndefined(tempSrcFmt) == false) && (Formats::IsUndefined(tempDstFmt) == false) && device.SupportsCopy(tempSrcFmt, srcCreateInfo.tiling) && device.SupportsCopy(tempDstFmt, dstCreateInfo.tiling)) { foundSwizzleFormats = true; srcFormat.format = tempSrcFmt; dstFormat.format = tempDstFmt; break; } } } // If we either didn't try to find swizzling formats or weren't able to do so, execute a true raw copy. if (foundSwizzleFormats == false) { srcFormat = RpmUtil::GetRawFormat(srcFormat.format, pTexelScale, pSingleSubres); dstFormat = srcFormat; } } // If one format is deemed "not replaceable" that means it may possibly be compressed. However, // if it is compressed, it doesn't necessarily mean it's not replaceable. If we don't do a replacement, // copying from one format to another may cause corruption, so we will arbitrarily choose to replace // the source if the channels within the format match and it is not an MM format. MM formats cannot be // replaced or HW will convert the data to the format's black or white which is different for MM formats. else if ((isSrcFormatReplaceable && (isDstFormatReplaceable == false)) || (chFmtsMatch && (isMmFormatUsed == false))) { // We can replace the source format but not the destination format. This means that we must interpret // the source subresource using the destination numeric format. We should keep the original source // channel format if a swizzle copy was requested and is possible. srcFormat.format = Formats::ConvertToDstNumFmt(srcFormat.format, dstFormat.format); if ((TestAnyFlagSet(copyFlags, CopyRawSwizzle) == false) || (device.SupportsCopy(srcFormat.format, srcCreateInfo.tiling) == false)) { srcFormat = dstFormat; } } else if ((isSrcFormatReplaceable == false) && isDstFormatReplaceable) { // We can replace the destination format but not the source format. This means that we must interpret // the destination subresource using the source numeric format. We should keep the original destination // channel format if a swizzle copy was requested and is possible. dstFormat.format = Formats::ConvertToDstNumFmt(dstFormat.format, srcFormat.format); if ((TestAnyFlagSet(copyFlags, CopyRawSwizzle) == false) || (device.SupportsCopy(dstFormat.format, dstCreateInfo.tiling) == false)) { dstFormat = srcFormat; } } else { // We can't replace either format, both formats must match. Or the channels must match in the case of // an MM copy. PAL_ASSERT(formatsMatch || (chFmtsMatch && isMmFormatUsed)); } } // We've settled on a pair of formats, make sure that we can actually use them. PAL_ASSERT(device.SupportsImageRead(srcFormat.format, srcCreateInfo.tiling)); // We have specific code to handle srgb destination by treating it as unorm and handling gamma correction // manually. So it's ok to ignore SRGB for this assert. PAL_ASSERT(Formats::IsSrgb(dstFormat.format) || (device.SupportsImageWrite(dstFormat.format, dstCreateInfo.tiling))); *pSrcFormat = srcFormat; *pDstFormat = dstFormat; } // ===================================================================================================================== // Builds commands to copy one or more regions from a GPU memory location to an image. void RsrcProcMgr::CmdCopyMemoryToImage( GfxCmdBuffer* pCmdBuffer, const GpuMemory& srcGpuMemory, const Image& dstImage, ImageLayout dstImageLayout, uint32 regionCount, const MemoryImageCopyRegion* pRegions, bool includePadding ) const { // Select the appropriate pipeline for this copy based on the destination image's properties. const auto& createInfo = dstImage.GetImageCreateInfo(); const ComputePipeline* pPipeline = nullptr; switch (dstImage.GetGfxImage()->GetOverrideImageType()) { case ImageType::Tex1d: pPipeline = GetPipeline(RpmComputePipeline::CopyMemToImg1d); break; case ImageType::Tex2d: switch (createInfo.fragments) { case 2: pPipeline = GetPipeline(RpmComputePipeline::CopyMemToImg2dms2x); break; case 4: pPipeline = GetPipeline(RpmComputePipeline::CopyMemToImg2dms4x); break; case 8: pPipeline = GetPipeline(RpmComputePipeline::CopyMemToImg2dms8x); break; default: pPipeline = GetPipeline(RpmComputePipeline::CopyMemToImg2d); break; } break; default: pPipeline = GetPipeline(RpmComputePipeline::CopyMemToImg3d); break; } // Note that we must call this helper function before and after our compute blit to fix up our image's metadata // if the copy isn't compatible with our layout's metadata compression level. AutoBuffer<ImageFixupRegion, 32, Platform> fixupRegions(regionCount, m_pDevice->GetPlatform()); if (fixupRegions.Capacity() >= regionCount) { for (uint32 i = 0; i < regionCount; i++) { fixupRegions[i].subres = pRegions[i].imageSubres; fixupRegions[i].offset = pRegions[i].imageOffset; fixupRegions[i].extent = pRegions[i].imageExtent; fixupRegions[i].numSlices = pRegions[i].numSlices; } FixupMetadataForComputeDst(pCmdBuffer, dstImage, dstImageLayout, regionCount, &fixupRegions[0], true); CopyBetweenMemoryAndImage(pCmdBuffer, pPipeline, srcGpuMemory, dstImage, dstImageLayout, true, false, regionCount, pRegions, includePadding); FixupMetadataForComputeDst(pCmdBuffer, dstImage, dstImageLayout, regionCount, &fixupRegions[0], false); #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 562 // If image is created with fullCopyDstOnly=1, there will be no expand when transition to "LayoutCopyDst"; if // the copy isn't compressed copy, need fix up dst metadata to uncompressed state. if (dstImage.GetImageCreateInfo().flags.fullCopyDstOnly != 0) { HwlFixupCopyDstImageMetaData(pCmdBuffer, nullptr, dstImage, dstImageLayout, &fixupRegions[0], regionCount, false); } #endif } else { pCmdBuffer->NotifyAllocFailure(); } } // ===================================================================================================================== // Builds commands to copy one or more regions from an image to a GPU memory location. void RsrcProcMgr::CmdCopyImageToMemory( GfxCmdBuffer* pCmdBuffer, const Image& srcImage, ImageLayout srcImageLayout, const GpuMemory& dstGpuMemory, uint32 regionCount, const MemoryImageCopyRegion* pRegions, bool includePadding ) const { // Select the appropriate pipeline for this copy based on the source image's properties. const auto& createInfo = srcImage.GetImageCreateInfo(); const bool isEqaaSrc = (createInfo.samples != createInfo.fragments); const GfxImage* pGfxImage = srcImage.GetGfxImage(); const ComputePipeline* pPipeline = nullptr; bool isFmaskCopy = false; switch (pGfxImage->GetOverrideImageType()) { case ImageType::Tex1d: pPipeline = GetPipeline(RpmComputePipeline::CopyImgToMem1d); break; case ImageType::Tex2d: // The Fmask accelerated copy should be used in all non-EQAA cases where Fmask is enabled. There is no use case // Fmask accelerated EQAA copy and it would require several new shaders. It can be implemented at a future // point if required. if (pGfxImage->HasFmaskData() && isEqaaSrc) { PAL_NOT_IMPLEMENTED(); } if (pGfxImage->HasFmaskData() && (isEqaaSrc == false)) { PAL_ASSERT((srcImage.IsDepthStencilTarget() == false) && (createInfo.fragments > 1)); pPipeline = GetPipeline(RpmComputePipeline::MsaaFmaskCopyImgToMem); isFmaskCopy = true; } else { switch (createInfo.fragments) { case 2: pPipeline = GetPipeline(RpmComputePipeline::CopyImgToMem2dms2x); break; case 4: pPipeline = GetPipeline(RpmComputePipeline::CopyImgToMem2dms4x); break; case 8: pPipeline = GetPipeline(RpmComputePipeline::CopyImgToMem2dms8x); break; default: pPipeline = GetPipeline(RpmComputePipeline::CopyImgToMem2d); break; } } break; default: pPipeline = GetPipeline(RpmComputePipeline::CopyImgToMem3d); break; } CopyBetweenMemoryAndImage(pCmdBuffer, pPipeline, dstGpuMemory, srcImage, srcImageLayout, false, isFmaskCopy, regionCount, pRegions, includePadding); } // ===================================================================================================================== // Builds commands to copy one or more regions between an image and a GPU memory location. Which object is the source // and which object is the destination is determined by the given pipeline. This works because the image <-> memory // pipelines all have the same input layouts. void RsrcProcMgr::CopyBetweenMemoryAndImage( GfxCmdBuffer* pCmdBuffer, const ComputePipeline* pPipeline, const GpuMemory& gpuMemory, const Image& image, ImageLayout imageLayout, bool isImageDst, bool isFmaskCopy, uint32 regionCount, const MemoryImageCopyRegion* pRegions, bool includePadding ) const { const auto& imgCreateInfo = image.GetImageCreateInfo(); const auto& device = *m_pDevice->Parent(); const auto& settings = device.Settings(); const bool is3d = (imgCreateInfo.imageType == ImageType::Tex3d); // Get number of threads per groups in each dimension, we will need this data later. uint32 threadsPerGroup[3] = {}; pPipeline->ThreadsPerGroupXyz(&threadsPerGroup[0], &threadsPerGroup[1], &threadsPerGroup[2]); bool p2pBltInfoRequired = m_pDevice->Parent()->IsP2pBltWaRequired(isImageDst ? *image.GetBoundGpuMemory().Memory() : gpuMemory); uint32 newRegionCount = 0; if (p2pBltInfoRequired) { if (isImageDst) { m_pDevice->P2pBltWaModifyRegionListMemoryToImage(gpuMemory, image, regionCount, pRegions, &newRegionCount, nullptr, nullptr); } else { m_pDevice->P2pBltWaModifyRegionListImageToMemory(image, gpuMemory, regionCount, pRegions, &newRegionCount, nullptr, nullptr); } } AutoBuffer<MemoryImageCopyRegion, 32, Platform> newRegions(newRegionCount, m_pDevice->GetPlatform()); AutoBuffer<gpusize, 32, Platform> chunkAddrs(newRegionCount, m_pDevice->GetPlatform()); if (p2pBltInfoRequired) { if ((newRegions.Capacity() >= newRegionCount) && (chunkAddrs.Capacity() >= newRegionCount)) { if (isImageDst) { m_pDevice->P2pBltWaModifyRegionListMemoryToImage(gpuMemory, image, regionCount, pRegions, &newRegionCount, &newRegions[0], &chunkAddrs[0]); } else { m_pDevice->P2pBltWaModifyRegionListImageToMemory(image, gpuMemory, regionCount, pRegions, &newRegionCount, &newRegions[0], &chunkAddrs[0]); } regionCount = newRegionCount; pRegions = &newRegions[0]; const GpuMemory* pDstGpuMemory = isImageDst ? image.GetBoundGpuMemory().Memory() : &gpuMemory; pCmdBuffer->P2pBltWaCopyBegin(pDstGpuMemory, regionCount, &chunkAddrs[0]); } else { pCmdBuffer->NotifyAllocFailure(); p2pBltInfoRequired = false; } } // Save current command buffer state and bind the pipeline. pCmdBuffer->CmdSaveComputeState(ComputeStatePipelineAndUserData); pCmdBuffer->CmdBindPipeline({ PipelineBindPoint::Compute, pPipeline, InternalApiPsoHash, }); // Now begin processing the list of copy regions. for (uint32 idx = 0; idx < regionCount; ++idx) { MemoryImageCopyRegion copyRegion = pRegions[idx]; // 3D images can't have slices and non-3D images shouldn't specify depth > 1 so we expect at least one // of them to be set to 1. PAL_ASSERT((copyRegion.numSlices == 1) || (copyRegion.imageExtent.depth == 1)); if (p2pBltInfoRequired) { pCmdBuffer->P2pBltWaCopyNextRegion(chunkAddrs[idx]); } // It will be faster to use a raw format, but we must stick with the base format if replacement isn't an option. SwizzledFormat viewFormat = image.SubresourceInfo(copyRegion.imageSubres)->format; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 583 if (Formats::IsUndefined(copyRegion.swizzledFormat.format) == false) { viewFormat = copyRegion.swizzledFormat; } #endif const ImageTiling srcTiling = (isImageDst) ? ImageTiling::Linear : imgCreateInfo.tiling; // Our copy shaders and hardware treat sRGB and UNORM nearly identically, the only difference being that the // hardware modifies sRGB data when reading it and can't write it, which will make it hard to do a raw copy. // We can avoid that problem by simply forcing sRGB to UNORM. if (Formats::IsSrgb(viewFormat.format)) { viewFormat.format = Formats::ConvertToUnorm(viewFormat.format); PAL_ASSERT(Formats::IsUndefined(viewFormat.format) == false); } bool singleSubres = false; if (image.GetGfxImage()->IsFormatReplaceable(copyRegion.imageSubres, imageLayout, isImageDst) || (m_pDevice->Parent()->SupportsMemoryViewRead(viewFormat.format, srcTiling) == false)) { uint32 texelScale = 1; uint32 pixelsPerBlock = 1; if (m_pDevice->IsImageFormatOverrideNeeded(imgCreateInfo, &viewFormat.format, &pixelsPerBlock)) { copyRegion.imageOffset.x /= pixelsPerBlock; copyRegion.imageExtent.width /= pixelsPerBlock; } else { viewFormat = RpmUtil::GetRawFormat(viewFormat.format, &texelScale, &singleSubres); copyRegion.imageOffset.x *= texelScale; copyRegion.imageExtent.width *= texelScale; } // If the format is not supported by the buffer SRD (checked with SupportsMemoryViewRead() above) // and the compression state check above (i.e., IsFormatReplaceable()) returns false, the // format is still replaced but a corruption may occur. The corruption can occur if the format // replacement results in a change in the color channel width and the resource is compressed. // This should not trigger because DoesImageSupportCopyCompression() limits the LayoutCopyDst // compressed usage in InitLayoutStateMasks(). PAL_ASSERT(image.GetGfxImage()->IsFormatReplaceable(copyRegion.imageSubres, imageLayout, isImageDst) == true); } // Make sure our view format supports reads and writes. PAL_ASSERT(device.SupportsImageWrite(viewFormat.format, imgCreateInfo.tiling) && device.SupportsImageRead(viewFormat.format, imgCreateInfo.tiling)); // The row and depth pitches need to be expressed in terms of view format texels. const uint32 viewBpp = Formats::BytesPerPixel(viewFormat.format); const uint32 rowPitch = static_cast<uint32>(copyRegion.gpuMemoryRowPitch / viewBpp); const uint32 depthPitch = static_cast<uint32>(copyRegion.gpuMemoryDepthPitch / viewBpp); // Generally the pipeline expects the user data to be arranged as follows for each dispatch: // Img X offset, Img Y offset, Img Z offset (3D), row pitch // Copy width, Copy height, Copy depth, slice pitch uint32 copyData[8] = { static_cast<uint32>(copyRegion.imageOffset.x), static_cast<uint32>(copyRegion.imageOffset.y), static_cast<uint32>(copyRegion.imageOffset.z), rowPitch, copyRegion.imageExtent.width, copyRegion.imageExtent.height, copyRegion.imageExtent.depth, depthPitch }; // For fmask accelerated copy, the pipeline expects the user data to be arranged as below, // Img X offset, Img Y offset, samples, row pitch // Copy width, Copy height, Copy depth, slice pitch if (isFmaskCopy) { // Img Z offset doesn't make sense for msaa image; store numSamples instead. copyData[2] = imgCreateInfo.samples; } const uint32 firstMipLevel = copyRegion.imageSubres.mipLevel; const uint32 lastArraySlice = copyRegion.imageSubres.arraySlice + copyRegion.numSlices - 1; // If single subres is requested for the format, iterate slice-by-slice and mip-by-mip. if (singleSubres) { copyRegion.numSlices = 1; } if (isImageDst) { PAL_ASSERT(TestAnyFlagSet(imageLayout.usages, LayoutShaderWrite | LayoutCopyDst) == true); } const Extent3d bufferBox = { copyRegion.imageExtent.width, copyRegion.imageExtent.height, is3d ? copyRegion.imageExtent.depth : copyRegion.numSlices }; BufferViewInfo bufferView = {}; bufferView.gpuAddr = gpuMemory.Desc().gpuVirtAddr + copyRegion.gpuMemoryOffset; bufferView.swizzledFormat = viewFormat; bufferView.stride = viewBpp; bufferView.range = ComputeTypedBufferRange(bufferBox, viewBpp * imgCreateInfo.fragments, copyRegion.gpuMemoryRowPitch, copyRegion.gpuMemoryDepthPitch); #if PAL_CLIENT_INTERFACE_MAJOR_VERSION>= 558 bufferView.flags.bypassMallRead = TestAnyFlagSet(settings.rpmViewsBypassMall, Gfx10RpmViewsBypassMallOnRead); bufferView.flags.bypassMallWrite = TestAnyFlagSet(settings.rpmViewsBypassMall, Gfx10RpmViewsBypassMallOnWrite); #endif for (; copyRegion.imageSubres.arraySlice <= lastArraySlice; copyRegion.imageSubres.arraySlice += copyRegion.numSlices) { copyRegion.imageSubres.mipLevel = firstMipLevel; // Create an embedded user-data table to contain the Image SRD's and the copy data constants. // It will be bound to entry 0. const uint32 DataDwords = NumBytesToNumDwords(sizeof(copyData)); uint32* pUserData = RpmUtil::CreateAndBindEmbeddedUserData(pCmdBuffer, SrdDwordAlignment() * 2 + DataDwords, SrdDwordAlignment(), PipelineBindPoint::Compute, 0); device.CreateTypedBufferViewSrds(1, &bufferView, pUserData); pUserData += SrdDwordAlignment(); #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 const SubresRange viewRange = { copyRegion.imageSubres, 1, copyRegion.numSlices }; #else const SubresRange viewRange = { copyRegion.imageSubres, 1, 1, copyRegion.numSlices }; #endif ImageViewInfo imageView = {}; RpmUtil::BuildImageViewInfo(&imageView, image, viewRange, viewFormat, imageLayout, device.TexOptLevel()); imageView.flags.includePadding = includePadding; device.CreateImageViewSrds(1, &imageView, pUserData); pUserData += SrdDwordAlignment(); if (isFmaskCopy) { // If this is an Fmask-accelerated Copy, create an image view of the source Image's Fmask surface. FmaskViewInfo fmaskView = {}; fmaskView.pImage = &image; fmaskView.baseArraySlice = copyRegion.imageSubres.arraySlice; fmaskView.arraySize = copyRegion.numSlices; m_pDevice->Parent()->CreateFmaskViewSrds(1, &fmaskView, pUserData); pUserData += SrdDwordAlignment(); } // Copy the copy data into the embedded user data memory. memcpy(pUserData, &copyData[0], sizeof(copyData)); // Execute the dispatch, we need one thread per texel. pCmdBuffer->CmdDispatch(RpmUtil::MinThreadGroups(bufferBox.width, threadsPerGroup[0]), RpmUtil::MinThreadGroups(bufferBox.height, threadsPerGroup[1]), RpmUtil::MinThreadGroups(bufferBox.depth, threadsPerGroup[2])); // Offset the buffer view to the next iteration's starting slice. bufferView.gpuAddr += copyRegion.gpuMemoryDepthPitch; } } if (p2pBltInfoRequired) { pCmdBuffer->P2pBltWaCopyEnd(); } // Restore command buffer state. pCmdBuffer->CmdRestoreComputeState(ComputeStatePipelineAndUserData); } // ===================================================================================================================== // Builds commands to copy multiple regions directly (without format conversion) from one typed buffer to another. void RsrcProcMgr::CmdCopyTypedBuffer( GfxCmdBuffer* pCmdBuffer, const GpuMemory& srcGpuMemory, const GpuMemory& dstGpuMemory, uint32 regionCount, const TypedBufferCopyRegion* pRegions ) const { const auto& device = *m_pDevice->Parent(); const auto& settings = device.Settings(); // Save current command buffer state. pCmdBuffer->CmdSaveComputeState(ComputeStatePipelineAndUserData); // We may have to bind a new pipeline for each region, we can optimize out redundant binds by tracking the previous // pipeline and only updating the pipeline binding when it must change. const ComputePipeline* pPipeline = nullptr; const ComputePipeline* pPrevPipeline = nullptr; uint32 threadsPerGroup[3] = {}; // Now begin processing the list of copy regions. for (uint32 idx = 0; idx < regionCount; ++idx) { const TypedBufferInfo& srcInfo = pRegions[idx].srcBuffer; const TypedBufferInfo& dstInfo = pRegions[idx].dstBuffer; // Both buffers must have the same pixel size. PAL_ASSERT(Formats::BitsPerPixel(srcInfo.swizzledFormat.format) == Formats::BitsPerPixel(dstInfo.swizzledFormat.format)); // Pick a raw format for the copy. uint32 texelScale = 1; const SwizzledFormat rawFormat = RpmUtil::GetRawFormat(srcInfo.swizzledFormat.format, &texelScale, nullptr); // Multiply 'texelScale' into our extent to make sure we dispatch enough threads to copy the whole region. const Extent3d copyExtent = { pRegions[idx].extent.width * texelScale, pRegions[idx].extent.height, pRegions[idx].extent.depth }; // The row and depth pitches need to be expressed in terms of raw format texels. const uint32 rawBpp = Formats::BytesPerPixel(rawFormat.format); const uint32 dstRowPitch = static_cast<uint32>(dstInfo.rowPitch / rawBpp); const uint32 dstDepthPitch = static_cast<uint32>(dstInfo.depthPitch / rawBpp); const uint32 srcRowPitch = static_cast<uint32>(srcInfo.rowPitch / rawBpp); const uint32 srcDepthPitch = static_cast<uint32>(srcInfo.depthPitch / rawBpp); // Get the appropriate pipeline and user data based on the copy extents. uint32 userData[7] = {}; uint32 numUserData = 0; if (copyExtent.depth > 1) { pPipeline = GetPipeline(RpmComputePipeline::CopyTypedBuffer3d); userData[0] = dstRowPitch; userData[1] = dstDepthPitch; userData[2] = srcRowPitch; userData[3] = srcDepthPitch; userData[4] = copyExtent.width; userData[5] = copyExtent.height; userData[6] = copyExtent.depth; numUserData = 7; } else if (copyExtent.height > 1) { pPipeline = GetPipeline(RpmComputePipeline::CopyTypedBuffer2d); userData[0] = dstRowPitch; userData[1] = srcRowPitch; userData[2] = copyExtent.width; userData[3] = copyExtent.height; numUserData = 4; } else { pPipeline = GetPipeline(RpmComputePipeline::CopyTypedBuffer1d); userData[0] = copyExtent.width; numUserData = 1; } PAL_ASSERT(pPipeline != nullptr); // Change pipeline bindings if necessary. if (pPrevPipeline != pPipeline) { pPrevPipeline = pPipeline; pPipeline->ThreadsPerGroupXyz(&threadsPerGroup[0], &threadsPerGroup[1], &threadsPerGroup[2]); pCmdBuffer->CmdBindPipeline({ PipelineBindPoint::Compute, pPipeline, InternalApiPsoHash, }); } // Create an embedded user-data table and bind it to user data 0. We need buffer views for the src and dst // subresources, as well as some inline constants for our inline constant user data. uint32* pUserDataTable = RpmUtil::CreateAndBindEmbeddedUserData(pCmdBuffer, SrdDwordAlignment() * 2 + numUserData, SrdDwordAlignment(), PipelineBindPoint::Compute, 0); BufferViewInfo bufferView = {}; bufferView.gpuAddr = dstGpuMemory.Desc().gpuVirtAddr + dstInfo.offset; bufferView.range = ComputeTypedBufferRange(copyExtent, rawBpp, dstInfo.rowPitch, dstInfo.depthPitch); bufferView.stride = rawBpp; bufferView.swizzledFormat = rawFormat; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION>= 558 bufferView.flags.bypassMallRead = TestAnyFlagSet(settings.rpmViewsBypassMall, Gfx10RpmViewsBypassMallOnRead); bufferView.flags.bypassMallWrite = TestAnyFlagSet(settings.rpmViewsBypassMall, Gfx10RpmViewsBypassMallOnWrite); #endif device.CreateTypedBufferViewSrds(1, &bufferView, pUserDataTable); pUserDataTable += SrdDwordAlignment(); bufferView.gpuAddr = srcGpuMemory.Desc().gpuVirtAddr + srcInfo.offset; bufferView.range = ComputeTypedBufferRange(copyExtent, rawBpp, srcInfo.rowPitch, srcInfo.depthPitch); device.CreateTypedBufferViewSrds(1, &bufferView, pUserDataTable); pUserDataTable += SrdDwordAlignment(); // Copy the copy parameters into the embedded user-data space. memcpy(pUserDataTable, userData, numUserData * sizeof(uint32)); // Execute the dispatch, we need one thread per texel. pCmdBuffer->CmdDispatch(RpmUtil::MinThreadGroups(copyExtent.width, threadsPerGroup[0]), RpmUtil::MinThreadGroups(copyExtent.height, threadsPerGroup[1]), RpmUtil::MinThreadGroups(copyExtent.depth, threadsPerGroup[2])); } pCmdBuffer->CmdRestoreComputeState(ComputeStatePipelineAndUserData); } // ===================================================================================================================== bool RsrcProcMgr::ScaledCopyImageUseGraphics( GfxCmdBuffer* pCmdBuffer, const ScaledCopyInfo& copyInfo) const { const auto& srcInfo = copyInfo.pSrcImage->GetImageCreateInfo(); const auto& dstInfo = copyInfo.pDstImage->GetImageCreateInfo(); const auto* pDstImage = static_cast<const Image*>(copyInfo.pDstImage); const ImageType srcImageType = srcInfo.imageType; const ImageType dstImageType = dstInfo.imageType; const bool isDepth = ((srcInfo.usageFlags.depthStencil != 0) || (dstInfo.usageFlags.depthStencil != 0) || Formats::IsDepthStencilOnly(srcInfo.swizzledFormat.format) || Formats::IsDepthStencilOnly(dstInfo.swizzledFormat.format)); const bool isCompressed = (Formats::IsBlockCompressed(srcInfo.swizzledFormat.format) || Formats::IsBlockCompressed(dstInfo.swizzledFormat.format)); const bool isYuv = (Formats::IsYuv(srcInfo.swizzledFormat.format) || Formats::IsYuv(dstInfo.swizzledFormat.format)); const bool p2pBltWa = m_pDevice->Parent()->ChipProperties().p2pBltWaInfo.required && pDstImage->GetBoundGpuMemory().Memory()->AccessesPeerMemory(); const bool preferGraphicsCopy = Image::PreferGraphicsCopy && (PreferComputeForNonLocalDestCopy(*pDstImage) == false); // We need to decide between the graphics copy path and the compute copy path. The graphics path only supports // single-sampled non-compressed, non-YUV 2D or 2D color images for now. const bool useGraphicsCopy = ((preferGraphicsCopy && pCmdBuffer->IsGraphicsSupported()) && ((srcImageType != ImageType::Tex1d) && (dstImageType != ImageType::Tex1d) && (isCompressed == false) && (isYuv == false) && (isDepth == false) && (p2pBltWa == false))); #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 603 // Scissor-enabled blit for OGLP is only supported on graphics path. PAL_ASSERT(useGraphicsCopy || (copyInfo.flags.scissorTest == 0)); #endif return useGraphicsCopy; } // ===================================================================================================================== void RsrcProcMgr::CmdScaledCopyImage( GfxCmdBuffer* pCmdBuffer, const ScaledCopyInfo& copyInfo) const { const bool useGraphicsCopy = ScaledCopyImageUseGraphics(pCmdBuffer, copyInfo); if (useGraphicsCopy) { // Save current command buffer state. pCmdBuffer->PushGraphicsState(); ScaledCopyImageGraphics(pCmdBuffer, copyInfo); // Restore original command buffer state. pCmdBuffer->PopGraphicsState(); } else { // Note that we must call this helper function before and after our compute blit to fix up our image's // metadata if the copy isn't compatible with our layout's metadata compression level. const Image& dstImage = *static_cast<const Image*>(copyInfo.pDstImage); AutoBuffer<ImageFixupRegion, 32, Platform> fixupRegions(copyInfo.regionCount, m_pDevice->GetPlatform()); if (fixupRegions.Capacity() >= copyInfo.regionCount) { for (uint32 i = 0; i < copyInfo.regionCount; i++) { fixupRegions[i].subres = copyInfo.pRegions[i].dstSubres; fixupRegions[i].offset = copyInfo.pRegions[i].dstOffset; fixupRegions[i].extent.width = Math::Absu(copyInfo.pRegions[i].dstExtent.width); fixupRegions[i].extent.height = Math::Absu(copyInfo.pRegions[i].dstExtent.height); fixupRegions[i].extent.depth = Math::Absu(copyInfo.pRegions[i].dstExtent.depth); fixupRegions[i].numSlices = copyInfo.pRegions[i].numSlices; } FixupMetadataForComputeDst(pCmdBuffer, dstImage, copyInfo.dstImageLayout, copyInfo.regionCount, &fixupRegions[0], true); // Save current command buffer state and bind the pipeline. pCmdBuffer->CmdSaveComputeState(ComputeStatePipelineAndUserData); ScaledCopyImageCompute(pCmdBuffer, copyInfo); pCmdBuffer->CmdRestoreComputeState(ComputeStatePipelineAndUserData); FixupMetadataForComputeDst(pCmdBuffer, dstImage, copyInfo.dstImageLayout, copyInfo.regionCount, &fixupRegions[0], false); #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 562 // If image is created with fullCopyDstOnly=1, there will be no expand when transition to // "LayoutCopyDst"; if the copy isn't compressed copy, need fix up dst metadata to uncompressed state. if (copyInfo.pDstImage->GetImageCreateInfo().flags.fullCopyDstOnly != 0) { HwlFixupCopyDstImageMetaData(pCmdBuffer, nullptr, dstImage, copyInfo.dstImageLayout, &fixupRegions[0], copyInfo.regionCount, false); } #endif } else { pCmdBuffer->NotifyAllocFailure(); } } } // ===================================================================================================================== void RsrcProcMgr::CmdGenerateMipmaps( GfxCmdBuffer* pCmdBuffer, const GenMipmapsInfo& genInfo) const { // The range cannot start at mip zero and cannot extend past the last mip level. PAL_ASSERT((genInfo.range.startSubres.mipLevel >= 1) && ((genInfo.range.startSubres.mipLevel + genInfo.range.numMips) <= genInfo.pImage->GetImageCreateInfo().mipLevels)); if (m_pDevice->Parent()->Settings().mipGenUseFastPath && (genInfo.pImage->GetImageCreateInfo().imageType == ImageType::Tex2d)) { // Use compute shader-based path that can generate up to 12 mipmaps/array slice per pass. GenerateMipmapsFast(pCmdBuffer, genInfo); } else { // Use multi-pass scaled copy image-based path. GenerateMipmapsSlow(pCmdBuffer, genInfo); } } // ===================================================================================================================== void RsrcProcMgr::GenerateMipmapsFast( GfxCmdBuffer* pCmdBuffer, const GenMipmapsInfo& genInfo ) const { const auto& device = *m_pDevice->Parent(); const auto& settings = device.Settings(); const auto& image = *static_cast<const Image*>(genInfo.pImage); const auto& imageInfo = image.GetImageCreateInfo(); // The shader can only generate up to 12 mips in one pass. constexpr uint32 MaxNumMips = 12; const ComputePipeline*const pPipeline = (settings.useFp16GenMips == false) ? GetPipeline(RpmComputePipeline::GenerateMipmaps) : GetPipeline(RpmComputePipeline::GenerateMipmapsLowp); // Save current command buffer state and bind the pipeline. pCmdBuffer->CmdSaveComputeState(ComputeStatePipelineAndUserData); pCmdBuffer->CmdBindPipeline({ PipelineBindPoint::Compute, pPipeline, InternalApiPsoHash, }); BarrierInfo barrier = { }; barrier.waitPoint = HwPipePreCs; constexpr HwPipePoint PostCs = HwPipePostCs; barrier.pipePointWaitCount = 1; barrier.pPipePoints = &PostCs; // If we need to generate more than MaxNumMips mip levels, then we will need to issue multiple dispatches with // internal barriers in between, because the src mip of a subsequent pass is the last dst mip of the previous pass. // Note that we don't need any barriers between per-array slice dispatches. BarrierTransition transition = { }; transition.srcCacheMask = CoherShader; transition.dstCacheMask = CoherShader; // We will specify the base subresource later on. transition.imageInfo.pImage = genInfo.pImage; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 642 transition.imageInfo.subresRange.numPlanes = 1; #endif transition.imageInfo.subresRange.numMips = 1; transition.imageInfo.subresRange.numSlices = genInfo.range.numSlices; transition.imageInfo.oldLayout = genInfo.genMipLayout; transition.imageInfo.newLayout = genInfo.genMipLayout; barrier.transitionCount = 1; barrier.pTransitions = &transition; barrier.reason = Developer::BarrierReasonUnknown; uint32 samplerType = 0; // 0 = linearSampler, 1 = pointSampler if ((genInfo.filter.magnification == Pal::XyFilterLinear) && (genInfo.filter.minification == Pal::XyFilterLinear)) { PAL_ASSERT(genInfo.filter.mipFilter == Pal::MipFilterNone); samplerType = 0; } else if ((genInfo.filter.magnification == Pal::XyFilterPoint) && (genInfo.filter.minification == Pal::XyFilterPoint)) { PAL_ASSERT(genInfo.filter.mipFilter == Pal::MipFilterNone); samplerType = 1; } else { PAL_NOT_IMPLEMENTED(); } SubresId srcSubres = genInfo.range.startSubres; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 642 for (; srcSubres.plane < (genInfo.range.startSubres.plane + genInfo.range.numPlanes); srcSubres.plane++) #endif { srcSubres.mipLevel = genInfo.range.startSubres.mipLevel - 1; srcSubres.arraySlice = genInfo.range.startSubres.arraySlice; for (uint32 start = 0; start < genInfo.range.numMips; start += MaxNumMips, srcSubres.mipLevel += MaxNumMips) { const uint32 numMipsToGenerate = Min((genInfo.range.numMips - start), MaxNumMips); // The shader can only handle one array slice per pass. for (uint32 slice = 0; slice < genInfo.range.numSlices; ++slice, ++srcSubres.arraySlice) { const SubResourceInfo& subresInfo = *image.SubresourceInfo(srcSubres); const SwizzledFormat srcFormat = (genInfo.swizzledFormat.format != ChNumFormat::Undefined) ? genInfo.swizzledFormat : subresInfo.format; SwizzledFormat dstFormat = srcFormat; const uint32 numWorkGroupsPerDim[] = { RpmUtil::MinThreadGroups(subresInfo.extentTexels.width, 64), RpmUtil::MinThreadGroups(subresInfo.extentTexels.height, 64), 1 }; const float invInputDims[] = { (1.0f / subresInfo.extentTexels.width), (1.0f / subresInfo.extentTexels.height), }; // Bind inline constants to user data 0+. const uint32 copyData[] = { numMipsToGenerate, // numMips (numWorkGroupsPerDim[0] * numWorkGroupsPerDim[1] * numWorkGroupsPerDim[2]), reinterpret_cast<const uint32&>(invInputDims[0]), reinterpret_cast<const uint32&>(invInputDims[1]), samplerType, }; const uint32 copyDataDwords = Util::NumBytesToNumDwords(sizeof(copyData)); pCmdBuffer->CmdSetUserData(PipelineBindPoint::Compute, 0, copyDataDwords, &copyData[0]); // Create an embedded user-data table and bind it. We need an image view and a sampler for the src // subresource, image views for MaxNumMips dst subresources, and a buffer SRD pointing to the atomic // counter. constexpr uint8 NumSlots = 2 + MaxNumMips + 1; uint32* pUserData = RpmUtil::CreateAndBindEmbeddedUserData(pCmdBuffer, SrdDwordAlignment() * NumSlots, SrdDwordAlignment(), PipelineBindPoint::Compute, copyDataDwords); // The hardware can't handle UAV stores using sRGB num format. The resolve shaders already contain a // linear-to-gamma conversion, but in order for that to work the output UAV's num format must be // patched to be simple UNORM. if (Formats::IsSrgb(dstFormat.format)) { dstFormat.format = Formats::ConvertToUnorm(dstFormat.format); PAL_ASSERT(Formats::IsUndefined(dstFormat.format) == false); PAL_NOT_IMPLEMENTED_MSG( "Gamma correction for sRGB image writes is not yet implemented in the mipgen shader."); } #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 SubresRange viewRange = { srcSubres, 1, 1 }; #else SubresRange viewRange = { srcSubres, 1, 1, 1 }; #endif ImageViewInfo srcImageView = { }; RpmUtil::BuildImageViewInfo(&srcImageView, image, viewRange, srcFormat, genInfo.baseMipLayout, device.TexOptLevel()); device.CreateImageViewSrds(1, &srcImageView, pUserData); pUserData += SrdDwordAlignment(); SamplerInfo samplerInfo = { }; samplerInfo.filter = genInfo.filter; samplerInfo.addressU = TexAddressMode::Clamp; samplerInfo.addressV = TexAddressMode::Clamp; samplerInfo.addressW = TexAddressMode::Clamp; samplerInfo.compareFunc = CompareFunc::Always; device.CreateSamplerSrds(1, &samplerInfo, pUserData); pUserData += SrdDwordAlignment(); ImageViewInfo dstImageView[MaxNumMips] = { }; for (uint32 mip = 0; mip < MaxNumMips; ++mip) { if (mip < numMipsToGenerate) { ++viewRange.startSubres.mipLevel; } RpmUtil::BuildImageViewInfo(&dstImageView[mip], image, viewRange, dstFormat, genInfo.genMipLayout, device.TexOptLevel()); } device.CreateImageViewSrds(MaxNumMips, &dstImageView[0], pUserData); pUserData += (SrdDwordAlignment() * MaxNumMips); // Allocate scratch memory for the global atomic counter and initialize it to 0. const gpusize counterVa = pCmdBuffer->AllocateGpuScratchMem(1, Util::NumBytesToNumDwords(128)); pCmdBuffer->CmdWriteImmediate(HwPipePoint::HwPipeTop, 0, ImmediateDataWidth::ImmediateData32Bit, counterVa); BufferViewInfo bufferView = { }; bufferView.gpuAddr = counterVa; bufferView.stride = 0; bufferView.range = sizeof(uint32); bufferView.swizzledFormat = UndefinedSwizzledFormat; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION>= 558 bufferView.flags.bypassMallRead = TestAnyFlagSet(settings.rpmViewsBypassMall, Gfx10RpmViewsBypassMallOnRead); bufferView.flags.bypassMallWrite = TestAnyFlagSet(settings.rpmViewsBypassMall, Gfx10RpmViewsBypassMallOnWrite); #endif device.CreateUntypedBufferViewSrds(1, &bufferView, pUserData); // Execute the dispatch. pCmdBuffer->CmdDispatch(numWorkGroupsPerDim[0], numWorkGroupsPerDim[1], numWorkGroupsPerDim[2]); } srcSubres.arraySlice = genInfo.range.startSubres.arraySlice; if ((start + MaxNumMips) < genInfo.range.numMips) { // If we need to do additional dispatches to handle more mip levels, issue a barrier between each pass. transition.imageInfo.subresRange.startSubres = srcSubres; transition.imageInfo.subresRange.startSubres.mipLevel = (start + numMipsToGenerate); pCmdBuffer->CmdBarrier(barrier); } } } pCmdBuffer->CmdRestoreComputeState(ComputeStatePipelineAndUserData); } // ===================================================================================================================== void RsrcProcMgr::GenerateMipmapsSlow( GfxCmdBuffer* pCmdBuffer, const GenMipmapsInfo& genInfo ) const { const Pal::Image* pImage = static_cast<const Pal::Image*>(genInfo.pImage); const ImageCreateInfo& createInfo = pImage->GetImageCreateInfo(); // We will use scaled image copies to generate each mip. Most of the copy state is identical but we must adjust the // copy region for each generated subresource. ImageScaledCopyRegion region = {}; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 region.srcSubres.aspect = genInfo.range.startSubres.aspect; #endif region.srcSubres.arraySlice = genInfo.range.startSubres.arraySlice; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 region.dstSubres.aspect = genInfo.range.startSubres.aspect; #endif region.dstSubres.arraySlice = genInfo.range.startSubres.arraySlice; region.numSlices = genInfo.range.numSlices; region.swizzledFormat = genInfo.swizzledFormat; ScaledCopyInfo copyInfo = {}; copyInfo.pSrcImage = pImage; copyInfo.srcImageLayout = genInfo.baseMipLayout; copyInfo.pDstImage = pImage; copyInfo.dstImageLayout = genInfo.genMipLayout; copyInfo.regionCount = 1; copyInfo.pRegions = &region; copyInfo.filter = genInfo.filter; copyInfo.rotation = ImageRotation::Ccw0; const bool useGraphicsCopy = ScaledCopyImageUseGraphics(pCmdBuffer, copyInfo); // We need an internal barrier between each mip-level's scaled copy because the destination of the prior copy is // the source of the next copy. Note that we can't use CoherCopy here because we optimize it away in the barrier // code but that optimization requires that we pop all state before calling CmdBarrier. That's very slow so instead // we use implementation dependent cache masks. BarrierTransition transition = {}; transition.srcCacheMask = useGraphicsCopy ? CoherColorTarget : CoherShader; transition.dstCacheMask = CoherShader; // We will specify the base subresource later on. transition.imageInfo.pImage = pImage; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 642 transition.imageInfo.subresRange.numPlanes = 1; #endif transition.imageInfo.subresRange.numMips = 1; transition.imageInfo.subresRange.numSlices = genInfo.range.numSlices; transition.imageInfo.oldLayout = genInfo.genMipLayout; transition.imageInfo.newLayout = genInfo.genMipLayout; const HwPipePoint postBlt = useGraphicsCopy ? HwPipeBottom : HwPipePostCs; BarrierInfo barrier = {}; barrier.waitPoint = HwPipePostIndexFetch; barrier.pipePointWaitCount = 1; barrier.pPipePoints = &postBlt; barrier.transitionCount = 1; barrier.pTransitions = &transition; // Save current command buffer state. if (useGraphicsCopy) { pCmdBuffer->PushGraphicsState(); } else { pCmdBuffer->CmdSaveComputeState(ComputeStatePipelineAndUserData); } // Issue one CmdScaledCopyImage for each mip, and plane in the generation range. const uint32 lastMip = genInfo.range.startSubres.mipLevel + genInfo.range.numMips - 1; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 642 for (uint32 plane = genInfo.range.startSubres.plane; plane < (genInfo.range.startSubres.plane + genInfo.range.numPlanes); plane++) #endif { #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 642 region.srcSubres.plane = plane; region.dstSubres.plane = plane; #endif uint32 destMip = genInfo.range.startSubres.mipLevel; while (destMip <= lastMip) { region.srcSubres.mipLevel = destMip - 1; region.dstSubres.mipLevel = destMip; // We want to generate all texels in the target subresource so copy the full extent from the first array // slice in the current source and destination mips. const SubResourceInfo& srcSubresInfo = *pImage->SubresourceInfo(region.srcSubres); const SubResourceInfo& dstSubresInfo = *pImage->SubresourceInfo(region.dstSubres); region.srcExtent.width = srcSubresInfo.extentTexels.width; region.srcExtent.height = srcSubresInfo.extentTexels.height; region.srcExtent.depth = srcSubresInfo.extentTexels.depth; region.dstExtent.width = dstSubresInfo.extentTexels.width; region.dstExtent.height = dstSubresInfo.extentTexels.height; region.dstExtent.depth = dstSubresInfo.extentTexels.depth; if (useGraphicsCopy) { ScaledCopyImageGraphics(pCmdBuffer, copyInfo); } else { ScaledCopyImageCompute(pCmdBuffer, copyInfo); } // If we're going to loop again... if (++destMip <= lastMip) { // Update the copy's source layout. copyInfo.srcImageLayout = genInfo.genMipLayout; // Issue the barrier between this iteration's writes and the next iteration's reads. transition.imageInfo.subresRange.startSubres = region.dstSubres; pCmdBuffer->CmdBarrier(barrier); } } } // Restore original command buffer state. if (useGraphicsCopy) { pCmdBuffer->PopGraphicsState(); } else { pCmdBuffer->CmdRestoreComputeState(ComputeStatePipelineAndUserData); } } // ===================================================================================================================== void RsrcProcMgr::ScaledCopyImageGraphics( GfxCmdBuffer* pCmdBuffer, const ScaledCopyInfo& copyInfo) const { PAL_ASSERT(pCmdBuffer->IsGraphicsSupported()); // Don't expect GFX Blts on Nested unless targets not inherited. PAL_ASSERT((pCmdBuffer->IsNested() == false) || (static_cast<UniversalCmdBuffer*>( pCmdBuffer)->GetGraphicsState().inheritedState.stateFlags.targetViewState == 0)); // Get some useful information about the image. const auto* pSrcImage = static_cast<const Image*>(copyInfo.pSrcImage); const auto* pDstImage = static_cast<const Image*>(copyInfo.pDstImage); ImageLayout srcImageLayout = copyInfo.srcImageLayout; ImageLayout dstImageLayout = copyInfo.dstImageLayout; uint32 regionCount = copyInfo.regionCount; const ImageScaledCopyRegion* pRegions = copyInfo.pRegions; const auto& dstCreateInfo = pDstImage->GetImageCreateInfo(); const auto& srcCreateInfo = pSrcImage->GetImageCreateInfo(); const auto& device = *m_pDevice->Parent(); const bool isTex3d = (srcCreateInfo.imageType == ImageType::Tex3d) ? 1 : 0; Pal::CmdStream*const pStream = pCmdBuffer->GetCmdStreamByEngine(CmdBufferEngineSupport::Graphics); PAL_ASSERT(pStream != nullptr); const StencilRefMaskParams stencilRefMasks = { 0xFF, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0x01, 0xFF }; ViewportParams viewportInfo = {}; viewportInfo.count = 1; viewportInfo.viewports[0].origin = PointOrigin::UpperLeft; viewportInfo.viewports[0].minDepth = 0.f; viewportInfo.viewports[0].maxDepth = 1.f; viewportInfo.horzClipRatio = FLT_MAX; viewportInfo.horzDiscardRatio = 1.0f; viewportInfo.vertClipRatio = FLT_MAX; viewportInfo.vertDiscardRatio = 1.0f; viewportInfo.depthRange = DepthRange::ZeroToOne; ScissorRectParams scissorInfo = {}; scissorInfo.count = 1; const ColorTargetViewInternalCreateInfo colorViewInfoInternal = {}; ColorTargetViewCreateInfo colorViewInfo = {}; colorViewInfo.imageInfo.pImage = copyInfo.pDstImage; colorViewInfo.imageInfo.arraySize = 1; if (dstCreateInfo.imageType == ImageType::Tex3d) { colorViewInfo.zRange.extent = 1; colorViewInfo.flags.zRangeValid = true; } BindTargetParams bindTargetsInfo = {}; bindTargetsInfo.colorTargets[0].imageLayout = dstImageLayout; bindTargetsInfo.colorTargets[0].pColorTargetView = nullptr; #if PAL_ENABLE_PRINTS_ASSERTS PAL_ASSERT(static_cast<const UniversalCmdBuffer*>(pCmdBuffer)->IsGraphicsStatePushed()); #endif BindCommonGraphicsState(pCmdBuffer); pCmdBuffer->CmdBindDepthStencilState(m_pDepthDisableState); pCmdBuffer->CmdBindMsaaState(GetMsaaState(dstCreateInfo.samples, dstCreateInfo.fragments)); pCmdBuffer->CmdSetStencilRefMasks(stencilRefMasks); if (copyInfo.flags.srcAlpha) { pCmdBuffer->CmdBindColorBlendState(m_pColorBlendState); } else { pCmdBuffer->CmdBindColorBlendState(m_pBlendDisableState); } // Keep track of the previous graphics pipeline to reduce the pipeline switching overhead. const GraphicsPipeline* pPreviousPipeline = nullptr; // Accumulate the restore mask for each region copied. uint32 restoreMask = 0; uint32 colorKey[4] = {0}; uint32 alphaDiffMul = 0; float threshold = 0.0f; uint32 colorKeyEnableMask = 0; if (copyInfo.flags.srcColorKey) { colorKeyEnableMask = 1; } else if (copyInfo.flags.dstColorKey) { colorKeyEnableMask = 2; } if (colorKeyEnableMask > 0) { const bool srcColorKey = (colorKeyEnableMask == 1); PAL_ASSERT(copyInfo.pColorKey != nullptr); PAL_ASSERT(srcCreateInfo.imageType == ImageType::Tex2d); PAL_ASSERT(dstCreateInfo.imageType == ImageType::Tex2d); PAL_ASSERT(srcCreateInfo.samples <= 1); PAL_ASSERT(dstCreateInfo.samples <= 1); memcpy(&colorKey[0], &copyInfo.pColorKey->u32Color[0], sizeof(colorKey)); // Convert uint color key to float representation SwizzledFormat format = srcColorKey ? srcCreateInfo.swizzledFormat : dstCreateInfo.swizzledFormat; RpmUtil::ConvertClearColorToNativeFormat(format, format, colorKey); // Only GenerateMips uses swizzledFormat in regions, color key is not available in this case. PAL_ASSERT(Formats::IsUndefined(copyInfo.pRegions[0].swizzledFormat.format)); // Set constant to respect or ignore alpha channel color diff constexpr uint32 FloatOne = 0x3f800000; alphaDiffMul = Formats::HasUnusedAlpha(format) ? 0 : FloatOne; // Compute the threshold for comparing 2 float value const uint32 bitCount = Formats::MaxComponentBitCount(format.format); threshold = static_cast<float>(pow(2, -2.0f * bitCount) - pow(2, -2.0f * bitCount - 24.0f)); } // Each region needs to be copied individually. for (uint32 region = 0; region < regionCount; ++region) { // Multiply all x-dimension values in our region by the texel scale. ImageScaledCopyRegion copyRegion = pRegions[region]; // Calculate the absolute value of dstExtent, which will get fed to the shader. const int32 dstExtentW = #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 607 (copyInfo.flags.coordsInFloat != 0) ? static_cast<int32>(copyRegion.dstExtentFloat.width + 0.5f) : #endif copyRegion.dstExtent.width; const int32 dstExtentH = #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 607 (copyInfo.flags.coordsInFloat != 0) ? static_cast<int32>(copyRegion.dstExtentFloat.height + 0.5f) : #endif copyRegion.dstExtent.height; const int32 dstExtentD = #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 607 (copyInfo.flags.coordsInFloat != 0) ? static_cast<int32>(copyRegion.dstExtentFloat.depth + 0.5f) : #endif copyRegion.dstExtent.depth; const uint32 absDstExtentW = Math::Absu(dstExtentW); const uint32 absDstExtentH = Math::Absu(dstExtentH); const uint32 absDstExtentD = Math::Absu(dstExtentD); if ((absDstExtentW > 0) && (absDstExtentH > 0) && (absDstExtentD > 0)) { // A negative extent means that we should do a reverse the copy. // We want to always use the absolute value of dstExtent. // If dstExtent is negative in one dimension, then we negate srcExtent in that dimension, // and we adjust the offsets as well. #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 607 if (copyInfo.flags.coordsInFloat != 0) { if (copyRegion.dstExtentFloat.width < 0) { copyRegion.dstOffsetFloat.x = copyRegion.dstOffsetFloat.x + copyRegion.dstExtentFloat.width; copyRegion.srcOffsetFloat.x = copyRegion.srcOffsetFloat.x + copyRegion.srcExtentFloat.width; copyRegion.srcExtentFloat.width = -copyRegion.srcExtentFloat.width; copyRegion.dstExtentFloat.width = -copyRegion.dstExtentFloat.width; } if (copyRegion.dstExtentFloat.height < 0) { copyRegion.dstOffsetFloat.y = copyRegion.dstOffsetFloat.y + copyRegion.dstExtentFloat.height; copyRegion.srcOffsetFloat.y = copyRegion.srcOffsetFloat.y + copyRegion.srcExtentFloat.height; copyRegion.srcExtentFloat.height = -copyRegion.srcExtentFloat.height; copyRegion.dstExtentFloat.height = -copyRegion.dstExtentFloat.height; } if (copyRegion.dstExtentFloat.depth < 0) { copyRegion.dstOffsetFloat.z = copyRegion.dstOffsetFloat.z + copyRegion.dstExtentFloat.depth; copyRegion.srcOffsetFloat.z = copyRegion.srcOffsetFloat.z + copyRegion.srcExtentFloat.depth; copyRegion.srcExtentFloat.depth = -copyRegion.srcExtentFloat.depth; copyRegion.dstExtentFloat.depth = -copyRegion.dstExtentFloat.depth; } } else #endif { if (copyRegion.dstExtent.width < 0) { copyRegion.dstOffset.x = copyRegion.dstOffset.x + copyRegion.dstExtent.width; copyRegion.srcOffset.x = copyRegion.srcOffset.x + copyRegion.srcExtent.width; copyRegion.srcExtent.width = -copyRegion.srcExtent.width; copyRegion.dstExtent.width = -copyRegion.dstExtent.width; } if (copyRegion.dstExtent.height < 0) { copyRegion.dstOffset.y = copyRegion.dstOffset.y + copyRegion.dstExtent.height; copyRegion.srcOffset.y = copyRegion.srcOffset.y + copyRegion.srcExtent.height; copyRegion.srcExtent.height = -copyRegion.srcExtent.height; copyRegion.dstExtent.height = -copyRegion.dstExtent.height; } if (copyRegion.dstExtent.depth < 0) { copyRegion.dstOffset.z = copyRegion.dstOffset.z + copyRegion.dstExtent.depth; copyRegion.srcOffset.z = copyRegion.srcOffset.z + copyRegion.srcExtent.depth; copyRegion.srcExtent.depth = -copyRegion.srcExtent.depth; copyRegion.dstExtent.depth = -copyRegion.dstExtent.depth; } } // The shader expects the region data to be arranged as follows for each dispatch: // Src Normalized Left, Src Normalized Top,Src Normalized Right, SrcNormalized Bottom. const Extent3d& srcExtent = pSrcImage->SubresourceInfo(copyRegion.srcSubres)->extentTexels; float srcLeft = 0; float srcTop = 0; float srcRight = 0; float srcBottom = 0; float dstLeft = 0; float dstTop = 0; float dstRight = 0; float dstBottom = 0; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 607 if (copyInfo.flags.coordsInFloat != 0) { srcLeft = copyRegion.srcOffsetFloat.x / srcExtent.width; srcTop = copyRegion.srcOffsetFloat.y / srcExtent.height; srcRight = (copyRegion.srcOffsetFloat.x + copyRegion.srcExtentFloat.width) / srcExtent.width; srcBottom = (copyRegion.srcOffsetFloat.y + copyRegion.srcExtentFloat.height) / srcExtent.height; dstLeft = copyRegion.dstOffsetFloat.x; dstTop = copyRegion.dstOffsetFloat.y; dstRight = copyRegion.dstOffsetFloat.x + copyRegion.dstExtentFloat.width; dstBottom = copyRegion.dstOffsetFloat.y + copyRegion.dstExtentFloat.height; } else #endif { srcLeft = (1.f * copyRegion.srcOffset.x) / srcExtent.width; srcTop = (1.f * copyRegion.srcOffset.y) / srcExtent.height; srcRight = (1.f * (copyRegion.srcOffset.x + copyRegion.srcExtent.width)) / srcExtent.width; srcBottom = (1.f * (copyRegion.srcOffset.y + copyRegion.srcExtent.height)) / srcExtent.height; dstLeft = 1.f * copyRegion.dstOffset.x; dstTop = 1.f * copyRegion.dstOffset.y; dstRight = 1.f * (copyRegion.dstOffset.x + copyRegion.dstExtent.width); dstBottom = 1.f * (copyRegion.dstOffset.y + copyRegion.dstExtent.height); } PAL_ASSERT((srcLeft >= 0.0f) && (srcLeft <= 1.0f) && (srcTop >= 0.0f) && (srcTop <= 1.0f) && (srcRight >= 0.0f) && (srcRight <= 1.0f) && (srcBottom >= 0.0f) && (srcBottom <= 1.0f)); // RotationParams contains the parameters to rotate 2d texture cooridnates. // Given 2d texture coordinates (u, v), we use following equations to compute rotated coordinates (u', v'): // u' = RotationParams[0] * u + RotationParams[1] * v + RotationParams[4] // v' = RotationParams[2] * u + RotationParams[3] * v + RotationParams[5] constexpr float RotationParams[static_cast<uint32>(ImageRotation::Count)][6] = { { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f}, { 0.0f, -1.0f, 1.0f, 0.0f, 1.0f, 0.0f}, {-1.0f, 0.0f, 0.0f, -1.0f, 1.0f, 1.0f}, { 0.0f, 1.0f, -1.0f, 0.0f, 0.0f, 1.0f}, }; const uint32 rotationIndex = static_cast<const uint32>(copyInfo.rotation); const uint32 texcoordVs[4] = { reinterpret_cast<const uint32&>(dstLeft), reinterpret_cast<const uint32&>(dstTop), reinterpret_cast<const uint32&>(dstRight), reinterpret_cast<const uint32&>(dstBottom), }; const uint32 userData[10] = { reinterpret_cast<const uint32&>(srcLeft), reinterpret_cast<const uint32&>(srcTop), reinterpret_cast<const uint32&>(srcRight), reinterpret_cast<const uint32&>(srcBottom), reinterpret_cast<const uint32&>(RotationParams[rotationIndex][0]), reinterpret_cast<const uint32&>(RotationParams[rotationIndex][1]), reinterpret_cast<const uint32&>(RotationParams[rotationIndex][2]), reinterpret_cast<const uint32&>(RotationParams[rotationIndex][3]), reinterpret_cast<const uint32&>(RotationParams[rotationIndex][4]), reinterpret_cast<const uint32&>(RotationParams[rotationIndex][5]), }; if (isTex3d == true) { pCmdBuffer->CmdSetUserData(PipelineBindPoint::Graphics, 1, 4, &userData[0]); } else { pCmdBuffer->CmdSetUserData(PipelineBindPoint::Graphics, 1, 4, &texcoordVs[0]); pCmdBuffer->CmdSetUserData(PipelineBindPoint::Graphics, 5, 10, &userData[0]); } } // Determine which image formats to use for the copy. SwizzledFormat srcFormat = pSrcImage->SubresourceInfo(copyRegion.srcSubres)->format; SwizzledFormat dstFormat = pDstImage->SubresourceInfo(copyRegion.dstSubres)->format; if (Formats::IsUndefined(copyRegion.swizzledFormat.format) == false) { srcFormat = copyRegion.swizzledFormat; dstFormat = copyRegion.swizzledFormat; } #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 626 // Non-SRGB can be treated as SRGB when copying to non-srgb image if (copyInfo.flags.dstAsSrgb) { dstFormat.format = Formats::ConvertToSrgb(dstFormat.format); PAL_ASSERT(Formats::IsUndefined(dstFormat.format) == false); } #endif // Update the color target view format with the destination format. colorViewInfo.swizzledFormat = dstFormat; const GraphicsPipeline* pPipeline = nullptr; if (srcCreateInfo.imageType == ImageType::Tex2d) { if (colorKeyEnableMask) { // There is no UINT/SINT formats in DX9 and only legacy formats <= 32 bpp can be used in color key blit. const uint32 bpp = Formats::BytesPerPixel(srcFormat.format); PAL_ASSERT(bpp <= 32); pPipeline = GetGfxPipeline(ScaledCopyImageColorKey); } else { pPipeline = GetGfxPipelineByTargetIndexAndFormat(ScaledCopy2d_32ABGR, 0, dstFormat); } } else { pPipeline = GetGfxPipelineByTargetIndexAndFormat(ScaledCopy3d_32ABGR, 0, dstFormat); } // Only switch to the appropriate graphics pipeline if it differs from the previous region's pipeline. if (pPreviousPipeline != pPipeline) { pCmdBuffer->CmdBindPipeline({ PipelineBindPoint::Graphics, pPipeline, InternalApiPsoHash, }); pCmdBuffer->CmdOverwriteRbPlusFormatForBlits(dstFormat, 0); pPreviousPipeline = pPipeline; } uint32 sizeInDwords; constexpr uint32 ColorKeyDataDwords = 7; if (colorKeyEnableMask) { // Create an embedded SRD table and bind it to user data 0. We need image views and // a sampler for the src and dest subresource, as well as some inline constants for src and dest // color key for 2d texture copy. Only need image view and a sampler for the src subresource // as not support color key for 3d texture copy. sizeInDwords = SrdDwordAlignment() * 3 + ColorKeyDataDwords; } else { // If color Key is not enabled, the ps shader don't need to allocate memory for copydata. sizeInDwords = SrdDwordAlignment() * 2; } uint32* pSrdTable = RpmUtil::CreateAndBindEmbeddedUserData(pCmdBuffer, sizeInDwords, SrdDwordAlignment(), PipelineBindPoint::Graphics, 0); #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 626 // Follow up the compute path of scaled copy that SRGB can be treated as UNORM // when copying from SRGB -> XX. if (copyInfo.flags.srcSrgbAsUnorm) { srcFormat.format = Formats::ConvertToUnorm(srcFormat.format); } #endif ImageViewInfo imageView[2] = {}; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 SubresRange viewRange = { copyRegion.srcSubres, 1, copyRegion.numSlices }; #else SubresRange viewRange = { copyRegion.srcSubres, 1, 1, copyRegion.numSlices }; #endif RpmUtil::BuildImageViewInfo(&imageView[0], *pSrcImage, viewRange, srcFormat, srcImageLayout, device.TexOptLevel()); if (colorKeyEnableMask) { // Note that this is a read-only view of the destination. viewRange.startSubres = copyRegion.dstSubres; RpmUtil::BuildImageViewInfo(&imageView[1], *pDstImage, viewRange, dstFormat, dstImageLayout, device.TexOptLevel()); PAL_ASSERT(imageView[1].viewType == ImageViewType::Tex2d); } // Populate the table with image views of the source and dest image for 2d texture. // Only populate the table with an image view of the source image for 3d texutre. const uint32 imageCount = colorKeyEnableMask ? 2 : 1; device.CreateImageViewSrds(imageCount, &imageView[0], pSrdTable); pSrdTable += SrdDwordAlignment() * imageCount; SamplerInfo samplerInfo = {}; samplerInfo.filter = copyInfo.filter; samplerInfo.addressU = TexAddressMode::Clamp; samplerInfo.addressV = TexAddressMode::Clamp; samplerInfo.addressW = TexAddressMode::Clamp; samplerInfo.compareFunc = CompareFunc::Always; device.CreateSamplerSrds(1, &samplerInfo, pSrdTable); pSrdTable += SrdDwordAlignment(); // Copy the copy parameters into the embedded user-data space for 2d texture copy. if (colorKeyEnableMask) { PAL_ASSERT(isTex3d == false); uint32 copyData[ColorKeyDataDwords] = { colorKeyEnableMask, alphaDiffMul, Util::Math::FloatToBits(threshold), colorKey[0], colorKey[1], colorKey[2], colorKey[3], }; memcpy(pSrdTable, &copyData[0], sizeof(copyData)); } // Give the gfxip layer a chance to optimize the hardware before we start copying. const uint32 bitsPerPixel = Formats::BitsPerPixel(dstFormat.format); restoreMask |= HwlBeginGraphicsCopy(pCmdBuffer, pPipeline, *pDstImage, bitsPerPixel); // When copying from 3D to 3D, the number of slices should be 1. When copying from // 1D to 1D or 2D to 2D, depth should be 1. Therefore when the src image type is identical // to the dst image type, either the depth or the number of slices should be equal to 1. PAL_ASSERT((srcCreateInfo.imageType != dstCreateInfo.imageType) || (copyRegion.numSlices == 1) || (copyRegion.srcExtent.depth == 1)); // When copying from 2D to 3D or 3D to 2D, the number of slices should match the depth. PAL_ASSERT((srcCreateInfo.imageType == dstCreateInfo.imageType) || ((((srcCreateInfo.imageType == ImageType::Tex3d) && (dstCreateInfo.imageType == ImageType::Tex2d)) || ((srcCreateInfo.imageType == ImageType::Tex2d) && (dstCreateInfo.imageType == ImageType::Tex3d))) && (copyRegion.numSlices == static_cast<uint32>(copyRegion.dstExtent.depth)))); // Setup the viewport and scissor to restrict rendering to the destination region being copied. #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 607 if (copyInfo.flags.coordsInFloat != 0) { viewportInfo.viewports[0].originX = copyRegion.dstOffsetFloat.x; viewportInfo.viewports[0].originY = copyRegion.dstOffsetFloat.y; viewportInfo.viewports[0].width = copyRegion.dstExtentFloat.width; viewportInfo.viewports[0].height = copyRegion.dstExtentFloat.height; } else #endif { viewportInfo.viewports[0].originX = static_cast<float>(copyRegion.dstOffset.x); viewportInfo.viewports[0].originY = static_cast<float>(copyRegion.dstOffset.y); viewportInfo.viewports[0].width = static_cast<float>(copyRegion.dstExtent.width); viewportInfo.viewports[0].height = static_cast<float>(copyRegion.dstExtent.height); } #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 603 if (copyInfo.flags.scissorTest != 0) { scissorInfo.scissors[0].offset.x = copyInfo.pScissorRect->offset.x; scissorInfo.scissors[0].offset.y = copyInfo.pScissorRect->offset.y; scissorInfo.scissors[0].extent.width = copyInfo.pScissorRect->extent.width; scissorInfo.scissors[0].extent.height = copyInfo.pScissorRect->extent.height; } else #endif { #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 607 if (copyInfo.flags.coordsInFloat != 0) { scissorInfo.scissors[0].offset.x = static_cast<int32>(copyRegion.dstOffsetFloat.x + 0.5f); scissorInfo.scissors[0].offset.y = static_cast<int32>(copyRegion.dstOffsetFloat.y + 0.5f); scissorInfo.scissors[0].extent.width = static_cast<int32>(copyRegion.dstExtentFloat.width + 0.5f); scissorInfo.scissors[0].extent.height = static_cast<int32>(copyRegion.dstExtentFloat.height + 0.5f); } else #endif { scissorInfo.scissors[0].offset.x = copyRegion.dstOffset.x; scissorInfo.scissors[0].offset.y = copyRegion.dstOffset.y; scissorInfo.scissors[0].extent.width = copyRegion.dstExtent.width; scissorInfo.scissors[0].extent.height = copyRegion.dstExtent.height; } } pCmdBuffer->CmdSetViewports(viewportInfo); pCmdBuffer->CmdSetScissorRects(scissorInfo); // Copy may happen between the layers of a 2d image and the slices of a 3d image. const uint32 numSlices = Max(copyRegion.numSlices, absDstExtentD); // Each slice is copied individually, we can optimize this into fewer draw calls if it becomes a // performance bottleneck, but for now this is simpler. for (uint32 sliceOffset = 0; sliceOffset < numSlices; ++sliceOffset) { const Extent3d& srcExtent = pSrcImage->SubresourceInfo(copyRegion.srcSubres)->extentTexels; const float src3dSliceNom = ((static_cast<float>(copyRegion.srcExtent.depth) / numSlices) * (static_cast<float>(sliceOffset) + 0.5f)) + static_cast<float>(copyRegion.srcOffset.z); const float src3dSlice = src3dSliceNom / srcExtent.depth; const float src2dSlice = static_cast<const float>(sliceOffset); const uint32 srcSlice = isTex3d ? reinterpret_cast<const uint32&>(src3dSlice) : reinterpret_cast<const uint32&>(src2dSlice); const uint32 userData[1] = { srcSlice }; if (isTex3d == true) { pCmdBuffer->CmdSetUserData(PipelineBindPoint::Graphics, 5, 1, &userData[0]); } else { pCmdBuffer->CmdSetUserData(PipelineBindPoint::Graphics, 15, 1, &userData[0]); } colorViewInfo.imageInfo.baseSubRes = copyRegion.dstSubres; if (dstCreateInfo.imageType == ImageType::Tex3d) { colorViewInfo.zRange.offset = copyRegion.dstOffset.z + sliceOffset; } else { colorViewInfo.imageInfo.baseSubRes.arraySlice = copyRegion.dstSubres.arraySlice + sliceOffset; } // Create and bind a color-target view for this slice. LinearAllocatorAuto<VirtualLinearAllocator> sliceAlloc(pCmdBuffer->Allocator(), false); IColorTargetView* pColorView = nullptr; void* pColorViewMem = PAL_MALLOC(m_pDevice->GetColorTargetViewSize(nullptr), &sliceAlloc, AllocInternalTemp); if (pColorViewMem == nullptr) { pCmdBuffer->NotifyAllocFailure(); } else { // Since our color target view can only bind 1 slice at a time, we have to issue a separate draw for // each slice in extent.z. We can keep the same src image view since we pass the explicit slice to // read from in user data, but we'll need to create a new color target view each time. Result result = m_pDevice->CreateColorTargetView(colorViewInfo, colorViewInfoInternal, pColorViewMem, &pColorView); PAL_ASSERT(result == Result::Success); bindTargetsInfo.colorTargets[0].pColorTargetView = pColorView; bindTargetsInfo.colorTargetCount = 1; pCmdBuffer->CmdBindTargets(bindTargetsInfo); // Draw a fullscreen quad. pCmdBuffer->CmdDraw(0, 3, 0, 1, 0); // Unbind the color-target view. bindTargetsInfo.colorTargetCount = 0; pCmdBuffer->CmdBindTargets(bindTargetsInfo); PAL_SAFE_FREE(pColorViewMem, &sliceAlloc); } } } // Call back to the gfxip layer so it can restore any state it modified previously. HwlEndGraphicsCopy(pStream, restoreMask); } // ===================================================================================================================== void RsrcProcMgr::ScaledCopyImageCompute( GfxCmdBuffer* pCmdBuffer, const ScaledCopyInfo& copyInfo) const { #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 603 PAL_ASSERT(copyInfo.flags.scissorTest == 0); #endif #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 607 PAL_ASSERT(copyInfo.flags.coordsInFloat == 0); #endif const auto& device = *m_pDevice->Parent(); const auto* pSrcImage = static_cast<const Image*>(copyInfo.pSrcImage); const auto* pSrcGfxImage = pSrcImage->GetGfxImage(); const auto* pDstImage = static_cast<const Image*>(copyInfo.pDstImage); const auto* pDstGfxImage = pDstImage->GetGfxImage(); const auto& srcInfo = pSrcImage->GetImageCreateInfo(); const auto& dstInfo = pDstImage->GetImageCreateInfo(); const bool imageTypeMatch = (pSrcGfxImage->GetOverrideImageType() == pDstGfxImage->GetOverrideImageType()); const bool is3d = (imageTypeMatch && (pSrcGfxImage->GetOverrideImageType() == ImageType::Tex3d)); bool isFmaskCopy = false; // Get the appropriate pipeline object. const ComputePipeline* pPipeline = nullptr; if (is3d) { pPipeline = GetPipeline(RpmComputePipeline::ScaledCopyImage3d); } else { const bool isDepth = (pSrcImage->IsDepthStencilTarget() || pDstImage->IsDepthStencilTarget()); if ((srcInfo.samples > 1) && (isDepth == false)) { // EQAA images or MSAA images with FMask disabled are unsupported for scaled copy. There is no use case for // EQAA and it would require several new shaders. It can be implemented if needed at a future point. PAL_ASSERT((srcInfo.samples == srcInfo.fragments) && (pSrcGfxImage->HasFmaskData() == true)); pPipeline = GetPipeline(RpmComputePipeline::MsaaFmaskScaledCopy); isFmaskCopy = true; } else { pPipeline = GetPipeline(RpmComputePipeline::ScaledCopyImage2d); } } // Get number of threads per groups in each dimension, we will need this data later. uint32 threadsPerGroup[3] = {0}; pPipeline->ThreadsPerGroupXyz(&threadsPerGroup[0], &threadsPerGroup[1], &threadsPerGroup[2]); PAL_ASSERT(pCmdBuffer->IsComputeStateSaved()); pCmdBuffer->CmdBindPipeline({ PipelineBindPoint::Compute, pPipeline, InternalApiPsoHash, }); uint32 colorKey[4] = {0}; uint32 alphaDiffMul = 0; float threshold = 0.0f; uint32 colorKeyEnableMask = 0; uint32 alphaBlendEnableMask = 0; if (copyInfo.flags.srcColorKey) { colorKeyEnableMask = 1; } else if (copyInfo.flags.dstColorKey) { colorKeyEnableMask = 2; } else if (copyInfo.flags.srcAlpha) { alphaBlendEnableMask = 4; } if (colorKeyEnableMask > 0) { const bool srcColorKey = (colorKeyEnableMask == 1); PAL_ASSERT(copyInfo.pColorKey != nullptr); PAL_ASSERT(srcInfo.imageType == ImageType::Tex2d); PAL_ASSERT(dstInfo.imageType == ImageType::Tex2d); PAL_ASSERT(srcInfo.samples <= 1); PAL_ASSERT(dstInfo.samples <= 1); PAL_ASSERT(pPipeline == GetPipeline(RpmComputePipeline::ScaledCopyImage2d)); memcpy(&colorKey[0], &copyInfo.pColorKey->u32Color[0], sizeof(colorKey)); // Convert uint color key to float representation SwizzledFormat format = srcColorKey ? srcInfo.swizzledFormat : dstInfo.swizzledFormat; RpmUtil::ConvertClearColorToNativeFormat(format, format, colorKey); // Only GenerateMips uses swizzledFormat in regions, color key is not available in this case. PAL_ASSERT(Formats::IsUndefined(copyInfo.pRegions[0].swizzledFormat.format)); // Set constant to respect or ignore alpha channel color diff constexpr uint32 FloatOne = 0x3f800000; alphaDiffMul = Formats::HasUnusedAlpha(format) ? 0 : FloatOne; // Compute the threshold for comparing 2 float value const uint32 bitCount = Formats::MaxComponentBitCount(format.format); threshold = static_cast<float>(pow(2, -2.0f * bitCount) - pow(2, -2.0f * bitCount - 24.0f)); } // Now begin processing the list of copy regions. for (uint32 idx = 0; idx < copyInfo.regionCount; ++idx) { ImageScaledCopyRegion copyRegion = copyInfo.pRegions[idx]; // Calculate the absolute value of dstExtent, which will get fed to the shader. const uint32 dstExtentW = Math::Absu(copyRegion.dstExtent.width); const uint32 dstExtentH = Math::Absu(copyRegion.dstExtent.height); const uint32 dstExtentD = Math::Absu(copyRegion.dstExtent.depth); if ((dstExtentW > 0) && (dstExtentH > 0) && (dstExtentD > 0)) { // A negative extent means that we should do a reverse the copy. // We want to always use the absolute value of dstExtent. // otherwise the compute shader can't handle it. If dstExtent is negative in one // dimension, then we negate srcExtent in that dimension, and we adjust the offsets // as well. if (copyRegion.dstExtent.width < 0) { copyRegion.dstOffset.x = copyRegion.dstOffset.x + copyRegion.dstExtent.width; copyRegion.srcOffset.x = copyRegion.srcOffset.x + copyRegion.srcExtent.width; copyRegion.srcExtent.width = -copyRegion.srcExtent.width; } if (copyRegion.dstExtent.height < 0) { copyRegion.dstOffset.y = copyRegion.dstOffset.y + copyRegion.dstExtent.height; copyRegion.srcOffset.y = copyRegion.srcOffset.y + copyRegion.srcExtent.height; copyRegion.srcExtent.height = -copyRegion.srcExtent.height; } if (copyRegion.dstExtent.depth < 0) { copyRegion.dstOffset.z = copyRegion.dstOffset.z + copyRegion.dstExtent.depth; copyRegion.srcOffset.z = copyRegion.srcOffset.z + copyRegion.srcExtent.depth; copyRegion.srcExtent.depth = -copyRegion.srcExtent.depth; } // The shader expects the region data to be arranged as follows for each dispatch: // Src Normalized Left, Src Normalized Top, Src Normalized Start-Z (3D) or slice (1D/2D), extent width // Dst Pixel X offset, Dst Pixel Y offset, Dst Z offset (3D) or slice (1D/2D), extent height // Src Normalized Right, SrcNormalized Bottom, Src Normalized End-Z (3D), extent depth // For 3D blts, the source Z-values are normalized as the X and Y values are for 1D, 2D, and 3D. const Extent3d& srcExtent = pSrcImage->SubresourceInfo(copyRegion.srcSubres)->extentTexels; const float srcLeft = (1.f * copyRegion.srcOffset.x) / srcExtent.width; const float srcTop = (1.f * copyRegion.srcOffset.y) / srcExtent.height; const float srcSlice = (1.f * copyRegion.srcOffset.z) / srcExtent.depth; const float srcRight = (1.f * (copyRegion.srcOffset.x + copyRegion.srcExtent.width)) / srcExtent.width; const float srcBottom = (1.f * (copyRegion.srcOffset.y + copyRegion.srcExtent.height)) / srcExtent.height; const float srcDepth = (1.f * (copyRegion.srcOffset.z + copyRegion.srcExtent.depth)) / srcExtent.depth; PAL_ASSERT((srcLeft >= 0.0f) && (srcLeft <= 1.0f) && (srcTop >= 0.0f) && (srcTop <= 1.0f) && (srcSlice >= 0.0f) && (srcSlice <= 1.0f) && (srcRight >= 0.0f) && (srcRight <= 1.0f) && (srcBottom >= 0.0f) && (srcBottom <= 1.0f) && (srcDepth >= 0.0f) && (srcDepth <= 1.0f)); SwizzledFormat dstFormat = pDstImage->SubresourceInfo(copyRegion.dstSubres)->format; SwizzledFormat srcFormat = pSrcImage->SubresourceInfo(copyRegion.srcSubres)->format; if (Formats::IsUndefined(copyRegion.swizzledFormat.format) == false) { srcFormat = copyRegion.swizzledFormat; dstFormat = copyRegion.swizzledFormat; } const uint32 zfilter = copyInfo.filter.zFilter; const uint32 magfilter = copyInfo.filter.magnification; const uint32 minfilter = copyInfo.filter.minification; float zOffset = 0.0f; if (zfilter == ZFilterNone) { if ((magfilter != XyFilterPoint) || (minfilter != XyFilterPoint)) { zOffset = 0.5f; } } else if (zfilter != ZFilterPoint) { zOffset = 0.5f; } // RotationParams contains the parameters to rotate 2d texture cooridnates. // Given 2d texture coordinates (u, v), we use following equations to compute rotated coordinates (u', v'): // u' = RotationParams[0] * u + RotationParams[1] * v + RotationParams[4] // v' = RotationParams[2] * u + RotationParams[3] * v + RotationParams[5] constexpr float RotationParams[static_cast<uint32>(ImageRotation::Count)][6] = { { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f}, { 0.0f, -1.0f, 1.0f, 0.0f, 1.0f, 0.0f}, {-1.0f, 0.0f, 0.0f, -1.0f, 1.0f, 1.0f}, { 0.0f, 1.0f, -1.0f, 0.0f, 0.0f, 1.0f}, }; const uint32 rotationIndex = static_cast<const uint32>(copyInfo.rotation); #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 626 // Enable gamma conversion when dstFormat is Srgb or copyInfo.flags.dstAsSrgb const uint32 enableGammaConversion = (Formats::IsSrgb(dstFormat.format) || copyInfo.flags.dstAsSrgb) ? 1 : 0; #else // Enable gamma conversion when dstFormat is Srgb, but only if srcFormat is not Srgb-as-Unorm. // Because the Srgb-as-Unorm sample is still gamma compressed and therefore no additional // conversion before shader export is needed. const uint32 enableGammaConversion = (Formats::IsSrgb(dstFormat.format) && (copyInfo.flags.srcSrgbAsUnorm == 0)) ? 1 : 0; #endif const uint32 copyData[] = { reinterpret_cast<const uint32&>(srcLeft), reinterpret_cast<const uint32&>(srcTop), static_cast<uint32>(copyRegion.srcOffset.z), dstExtentW, static_cast<uint32>(copyRegion.dstOffset.x), static_cast<uint32>(copyRegion.dstOffset.y), static_cast<uint32>(copyRegion.dstOffset.z), dstExtentH, reinterpret_cast<const uint32&>(srcRight), reinterpret_cast<const uint32&>(srcBottom), reinterpret_cast<const uint32&>(srcDepth), dstExtentD, enableGammaConversion, reinterpret_cast<const uint32&>(zOffset), srcInfo.samples, (colorKeyEnableMask | alphaBlendEnableMask), reinterpret_cast<const uint32&>(RotationParams[rotationIndex][0]), reinterpret_cast<const uint32&>(RotationParams[rotationIndex][1]), reinterpret_cast<const uint32&>(RotationParams[rotationIndex][2]), reinterpret_cast<const uint32&>(RotationParams[rotationIndex][3]), reinterpret_cast<const uint32&>(RotationParams[rotationIndex][4]), reinterpret_cast<const uint32&>(RotationParams[rotationIndex][5]), alphaDiffMul, Util::Math::FloatToBits(threshold), colorKey[0], colorKey[1], colorKey[2], colorKey[3], }; // Create an embedded user-data table and bind it to user data 0. We need image views for the src and dst // subresources, a sampler for the src subresource, as well as some inline constants for the copy offsets // and extents. const uint32 DataDwords = NumBytesToNumDwords(sizeof(copyData)); const uint8 numSlots = isFmaskCopy ? 4 : 3; uint32* pUserData = RpmUtil::CreateAndBindEmbeddedUserData( pCmdBuffer, SrdDwordAlignment() * numSlots + DataDwords, SrdDwordAlignment(), PipelineBindPoint::Compute, 0); // The hardware can't handle UAV stores using SRGB num format. The resolve shaders already contain a // linear-to-gamma conversion, but in order for that to work the output UAV's num format must be patched to // be simple unorm. if (Formats::IsSrgb(dstFormat.format)) { dstFormat.format = Formats::ConvertToUnorm(dstFormat.format); PAL_ASSERT(Formats::IsUndefined(dstFormat.format) == false); } #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 626 if (copyInfo.flags.srcSrgbAsUnorm) { srcFormat.format = Formats::ConvertToUnorm(srcFormat.format); } #endif ImageViewInfo imageView[2] = {}; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 SubresRange viewRange = { copyRegion.dstSubres, 1, copyRegion.numSlices }; #else SubresRange viewRange = { copyRegion.dstSubres, 1, 1, copyRegion.numSlices }; #endif PAL_ASSERT(TestAnyFlagSet(copyInfo.dstImageLayout.usages, LayoutShaderWrite | LayoutCopyDst) == true); RpmUtil::BuildImageViewInfo(&imageView[0], *pDstImage, viewRange, dstFormat, copyInfo.dstImageLayout, device.TexOptLevel()); viewRange.startSubres = copyRegion.srcSubres; RpmUtil::BuildImageViewInfo(&imageView[1], *pSrcImage, viewRange, srcFormat, copyInfo.srcImageLayout, device.TexOptLevel()); if (is3d == false) { imageView[0].viewType = ImageViewType::Tex2d; imageView[1].viewType = ImageViewType::Tex2d; } device.CreateImageViewSrds(2, &imageView[0], pUserData); pUserData += SrdDwordAlignment() * 2; if (isFmaskCopy) { // If this is an Fmask-accelerated Copy, create an image view of the source Image's Fmask surface. FmaskViewInfo fmaskView = {}; fmaskView.pImage = pSrcImage; fmaskView.baseArraySlice = copyRegion.srcSubres.arraySlice; fmaskView.arraySize = copyRegion.numSlices; m_pDevice->Parent()->CreateFmaskViewSrds(1, &fmaskView, pUserData); pUserData += SrdDwordAlignment(); } SamplerInfo samplerInfo = {}; samplerInfo.filter = copyInfo.filter; samplerInfo.addressU = TexAddressMode::Clamp; samplerInfo.addressV = TexAddressMode::Clamp; samplerInfo.addressW = TexAddressMode::Clamp; samplerInfo.compareFunc = CompareFunc::Always; device.CreateSamplerSrds(1, &samplerInfo, pUserData); pUserData += SrdDwordAlignment(); // Copy the copy parameters into the embedded user-data space memcpy(pUserData, &copyData[0], sizeof(copyData)); const uint32 zGroups = is3d ? dstExtentD : copyRegion.numSlices; // Execute the dispatch, we need one thread per texel. pCmdBuffer->CmdDispatch(RpmUtil::MinThreadGroups(dstExtentW, threadsPerGroup[0]), RpmUtil::MinThreadGroups(dstExtentH, threadsPerGroup[1]), RpmUtil::MinThreadGroups(zGroups, threadsPerGroup[2])); } } if (CopyDstBoundStencilNeedsWa(pCmdBuffer, *pDstImage)) { for (uint32 regionIdx = 0; regionIdx < copyInfo.regionCount; regionIdx++) { #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 if (copyInfo.pRegions[regionIdx].dstSubres.aspect == ImageAspect::Stencil) #else if (pDstImage->IsStencilPlane(copyInfo.pRegions[regionIdx].dstSubres.plane)) #endif { // Mark the VRS dest image as dirty to force an update of Htile on the next draw. pCmdBuffer->DirtyVrsDepthImage(pDstImage); // No need to loop through all the regions; they all affect the same image. break; } } } } // ===================================================================================================================== // Builds commands to perform an out-of-place conversion between a YUV and an RGB image. void RsrcProcMgr::CmdColorSpaceConversionCopy( GfxCmdBuffer* pCmdBuffer, const Image& srcImage, ImageLayout srcImageLayout, const Image& dstImage, ImageLayout dstImageLayout, uint32 regionCount, const ColorSpaceConversionRegion* pRegions, TexFilter filter, const ColorSpaceConversionTable& cscTable ) const { const auto& srcImageInfo = srcImage.GetImageCreateInfo(); const auto& dstImageInfo = dstImage.GetImageCreateInfo(); PAL_ASSERT((srcImageInfo.imageType == ImageType::Tex2d) && (dstImageInfo.imageType == ImageType::Tex2d)); const bool srcIsYuv = Formats::IsYuv(srcImageInfo.swizzledFormat.format); const bool dstIsYuv = Formats::IsYuv(dstImageInfo.swizzledFormat.format); SamplerInfo samplerInfo = { }; samplerInfo.filter = filter; samplerInfo.addressU = TexAddressMode::Clamp; samplerInfo.addressV = TexAddressMode::Clamp; samplerInfo.addressW = TexAddressMode::Clamp; samplerInfo.compareFunc = CompareFunc::Always; if ((dstIsYuv == false) && srcIsYuv) { ConvertYuvToRgb(pCmdBuffer, srcImage, dstImage, regionCount, pRegions, samplerInfo, cscTable); } else if ((srcIsYuv == false) && dstIsYuv) { ConvertRgbToYuv(pCmdBuffer, srcImage, dstImage, regionCount, pRegions, samplerInfo, cscTable); } else { PAL_ASSERT_ALWAYS(); } } // ===================================================================================================================== // Builds commands to execute a color-space-conversion copy from a YUV source to an RGB destination. void RsrcProcMgr::ConvertYuvToRgb( GfxCmdBuffer* pCmdBuffer, const Image& srcImage, const Image& dstImage, uint32 regionCount, const ColorSpaceConversionRegion* pRegions, const SamplerInfo& sampler, const ColorSpaceConversionTable& cscTable ) const { const auto& device = *m_pDevice->Parent(); const auto& srcImageInfo = srcImage.GetImageCreateInfo(); const auto& dstImageInfo = dstImage.GetImageCreateInfo(); // Build YUV to RGB color-space-conversion table constant buffer. RpmUtil::YuvRgbConversionInfo copyInfo = { }; memcpy(copyInfo.cscTable, &cscTable, sizeof(cscTable)); const RpmUtil::ColorSpaceConversionInfo& cscInfo = RpmUtil::CscInfoTable[static_cast<uint32>(srcImageInfo.swizzledFormat.format) - static_cast<uint32>(ChNumFormat::AYUV)]; // NOTE: Each of the YUV --> RGB conversion shaders expects the following user-data layout: // o RGB destination Image // o YUV source Image's Y plane (or YCbCr plane for RGB --> YUV-packed conversions) // o YUV source Image's Cb or CbCr plane (unused for RGB --> YUV-packed conversions) // o YUV source Image's Cr plane (unused unless converting between YV12 and RGB) // o Image sampler for scaled copies // o Copy Info constant buffer // o Color-space Conversion Table constant buffer constexpr uint32 MaxImageSrds = 4; constexpr uint32 MaxTotalSrds = (MaxImageSrds + 1); const uint32 viewCount = (cscInfo.pipelineYuvToRgb == RpmComputePipeline::YuvToRgb) ? MaxImageSrds : (MaxImageSrds - 1); ImageViewInfo viewInfo[MaxImageSrds] = { }; // Override the RGB image format to skip gamma-correction if it is required. SwizzledFormat dstFormat = dstImageInfo.swizzledFormat; if (Formats::IsSrgb(dstFormat.format)) { dstFormat.format = Formats::ConvertToUnorm(dstFormat.format); } const ComputePipeline*const pPipeline = GetPipeline(cscInfo.pipelineYuvToRgb); uint32 threadsPerGroup[3] = { }; pPipeline->ThreadsPerGroupXyz(&threadsPerGroup[0], &threadsPerGroup[1], &threadsPerGroup[2]); pCmdBuffer->CmdSaveComputeState(ComputeStateFlags::ComputeStatePipelineAndUserData); pCmdBuffer->CmdBindPipeline({ PipelineBindPoint::Compute, pPipeline, InternalApiPsoHash, }); for (uint32 idx = 0; idx < regionCount; ++idx) { ColorSpaceConversionRegion region = pRegions[idx]; if ((region.dstExtent.width == 0) || (region.dstExtent.height == 0)) { continue; // Skip empty regions. } #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 const SubresRange dstRange = { region.rgbSubres, 1, region.sliceCount }; #else const SubresRange dstRange = { region.rgbSubres, 1, 1, region.sliceCount }; #endif RpmUtil::BuildImageViewInfo(&viewInfo[0], dstImage, dstRange, dstFormat, RpmUtil::DefaultRpmLayoutShaderWrite, device.TexOptLevel()); for (uint32 view = 1; view < viewCount; ++view) { const auto& cscViewInfo = cscInfo.viewInfoYuvToRgb[view - 1]; SwizzledFormat imageViewInfoFormat = cscViewInfo.swizzledFormat; const SubresRange srcRange = #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 { { cscViewInfo.aspect, 0, region.yuvStartSlice }, 1, region.sliceCount }; #else { { cscViewInfo.plane, 0, region.yuvStartSlice }, 1, 1, region.sliceCount }; #endif // Try to use MM formats for YUV planes RpmUtil::SwapForMMFormat(srcImage.GetDevice(), &imageViewInfoFormat); RpmUtil::BuildImageViewInfo(&viewInfo[view], srcImage, srcRange, imageViewInfoFormat, RpmUtil::DefaultRpmLayoutRead, device.TexOptLevel()); } // Calculate the absolute value of dstExtent, which will get fed to the shader. copyInfo.dstExtent.width = Math::Absu(region.dstExtent.width); copyInfo.dstExtent.height = Math::Absu(region.dstExtent.height); copyInfo.dstOffset.x = region.dstOffset.x; copyInfo.dstOffset.y = region.dstOffset.y; // A negative extent means that we should reverse the copy direction. We want to always use the absolute // value of dstExtent, otherwise the compute shader can't handle it. If dstExtent is negative in one // dimension, then we negate srcExtent in that dimension, and we adjust the offsets as well. if (region.dstExtent.width < 0) { copyInfo.dstOffset.x = (region.dstOffset.x + region.dstExtent.width); region.srcOffset.x = (region.srcOffset.x + region.srcExtent.width); region.srcExtent.width = -region.srcExtent.width; } if (region.dstExtent.height < 0) { copyInfo.dstOffset.y = (region.dstOffset.y + region.dstExtent.height); region.srcOffset.y = (region.srcOffset.y + region.srcExtent.height); region.srcExtent.height = -region.srcExtent.height; } // The shaders expect the source copy region to be specified in normalized texture coordinates. const Extent3d& srcExtent = srcImage.SubresourceInfo(0)->extentTexels; copyInfo.srcLeft = (static_cast<float>(region.srcOffset.x) / srcExtent.width); copyInfo.srcTop = (static_cast<float>(region.srcOffset.y) / srcExtent.height); copyInfo.srcRight = (static_cast<float>(region.srcOffset.x + region.srcExtent.width) / srcExtent.width); copyInfo.srcBottom = (static_cast<float>(region.srcOffset.y + region.srcExtent.height) / srcExtent.height); PAL_ASSERT((copyInfo.srcLeft >= 0.0f) && (copyInfo.srcLeft <= 1.0f) && (copyInfo.srcTop >= 0.0f) && (copyInfo.srcTop <= 1.0f) && (copyInfo.srcRight >= 0.0f) && (copyInfo.srcRight <= 1.0f) && (copyInfo.srcBottom >= 0.0f) && (copyInfo.srcBottom <= 1.0f)); // Each conversion shader requires: // o Four image SRD's: one for the RGB image, one each for the Y, U and V "planes" of the YUV image // o One sampler SRD // o Inline constant space for copyInfo const uint32 sizeInDwords = (SrdDwordAlignment() * MaxTotalSrds) + RpmUtil::YuvRgbConversionInfoDwords; uint32* pUserData = RpmUtil::CreateAndBindEmbeddedUserData(pCmdBuffer, sizeInDwords, SrdDwordAlignment(), PipelineBindPoint::Compute, 0); device.CreateImageViewSrds(viewCount, &viewInfo[0], pUserData); pUserData += (SrdDwordAlignment() * MaxImageSrds); device.CreateSamplerSrds(1, &sampler, pUserData); pUserData += SrdDwordAlignment(); memcpy(pUserData, &copyInfo, sizeof(copyInfo)); // Finally, issue the dispatch. The shaders need one thread per texel. pCmdBuffer->CmdDispatch(RpmUtil::MinThreadGroups(copyInfo.dstExtent.width, threadsPerGroup[0]), RpmUtil::MinThreadGroups(copyInfo.dstExtent.height, threadsPerGroup[1]), RpmUtil::MinThreadGroups(region.sliceCount, threadsPerGroup[2])); } // End loop over regions pCmdBuffer->CmdRestoreComputeState(ComputeStateFlags::ComputeStatePipelineAndUserData); } // ===================================================================================================================== // Builds commands to execute a color-space-conversion copy from a RGB source to an YUV destination. void RsrcProcMgr::ConvertRgbToYuv( GfxCmdBuffer* pCmdBuffer, const Image& srcImage, const Image& dstImage, uint32 regionCount, const ColorSpaceConversionRegion* pRegions, const SamplerInfo& sampler, const ColorSpaceConversionTable& cscTable ) const { const auto& device = *m_pDevice->Parent(); const auto& srcImageInfo = srcImage.GetImageCreateInfo(); const auto& dstImageInfo = dstImage.GetImageCreateInfo(); const RpmUtil::ColorSpaceConversionInfo& cscInfo = RpmUtil::CscInfoTable[static_cast<uint32>(dstImageInfo.swizzledFormat.format) - static_cast<uint32>(ChNumFormat::AYUV)]; // NOTE: Each of the RGB --> YUV conversion shaders expects the following user-data layout: // o RGB source Image // o YUV destination Image plane // o Image sampler for scaled copies // o Copy Info constant buffer // o Color-space Conversion Table constant buffer // // The conversion is done in multiple passes for YUV planar destinations, one pass per plane. This is done so that // the planes can sample the source Image at different rates (because planes often have differing dimensions). const uint32 passCount = static_cast<uint32>(dstImage.GetImageInfo().numPlanes); const ComputePipeline*const pPipeline = GetPipeline(cscInfo.pipelineRgbToYuv); uint32 threadsPerGroup[3] = { }; pPipeline->ThreadsPerGroupXyz(&threadsPerGroup[0], &threadsPerGroup[1], &threadsPerGroup[2]); pCmdBuffer->CmdSaveComputeState(ComputeStateFlags::ComputeStatePipelineAndUserData); pCmdBuffer->CmdBindPipeline({ PipelineBindPoint::Compute, pPipeline, InternalApiPsoHash, }); for (uint32 idx = 0; idx < regionCount; ++idx) { ColorSpaceConversionRegion region = pRegions[idx]; if ((region.dstExtent.width == 0) || (region.dstExtent.height == 0)) { continue; // Skip empty regions. } constexpr uint32 MaxImageSrds = 2; constexpr uint32 MaxTotalSrds = (MaxImageSrds + 1); ImageViewInfo viewInfo[MaxImageSrds] = { }; // Override the RGB image format to skip degamma. SwizzledFormat srcFormat = srcImageInfo.swizzledFormat; if (Formats::IsSrgb(srcFormat.format)) { srcFormat.format = Formats::ConvertToUnorm(srcFormat.format); } #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 const SubresRange srcRange = { region.rgbSubres, 1, region.sliceCount }; #else const SubresRange srcRange = { region.rgbSubres, 1, 1, region.sliceCount }; #endif RpmUtil::BuildImageViewInfo(&viewInfo[0], srcImage, srcRange, srcFormat, RpmUtil::DefaultRpmLayoutRead, device.TexOptLevel()); RpmUtil::RgbYuvConversionInfo copyInfo = { }; // Calculate the absolute value of dstExtent, which will get fed to the shader. const Extent2d dstExtent = { Math::Absu(region.dstExtent.width), Math::Absu(region.dstExtent.height) }; Offset2d dstOffset = region.dstOffset; // A negative extent means that we should reverse the copy direction. We want to always use the absolute // value of dstExtent, otherwise the compute shader can't handle it. If dstExtent is negative in one // dimension, then we negate srcExtent in that dimension, and we adjust the offsets as well. if (region.dstExtent.width < 0) { dstOffset.x = (region.dstOffset.x + region.dstExtent.width); region.srcOffset.x = (region.srcOffset.x + region.srcExtent.width); region.srcExtent.width = -region.srcExtent.width; } if (region.dstExtent.height < 0) { dstOffset.y = (region.dstOffset.y + region.dstExtent.height); region.srcOffset.y = (region.srcOffset.y + region.srcExtent.height); region.srcExtent.height = -region.srcExtent.height; } // The shaders expect the source copy region to be specified in normalized texture coordinates. const Extent3d& srcExtent = srcImage.SubresourceInfo(0)->extentTexels; copyInfo.srcLeft = (static_cast<float>(region.srcOffset.x) / srcExtent.width); copyInfo.srcTop = (static_cast<float>(region.srcOffset.y) / srcExtent.height); copyInfo.srcRight = (static_cast<float>(region.srcOffset.x + region.srcExtent.width) / srcExtent.width); copyInfo.srcBottom = (static_cast<float>(region.srcOffset.y + region.srcExtent.height) / srcExtent.height); // Writing to macro-pixel YUV destinations requires the distance between the two source pixels which form // the destination macro-pixel (in normalized texture coordinates). copyInfo.srcWidthEpsilon = (1.f / srcExtent.width); PAL_ASSERT((copyInfo.srcLeft >= 0.0f) && (copyInfo.srcLeft <= 1.0f) && (copyInfo.srcTop >= 0.0f) && (copyInfo.srcTop <= 1.0f) && (copyInfo.srcRight >= 0.0f) && (copyInfo.srcRight <= 1.0f) && (copyInfo.srcBottom >= 0.0f) && (copyInfo.srcBottom <= 1.0f)); if (cscInfo.pipelineRgbToYuv == RpmComputePipeline::RgbToYuvPacked) { // The YUY2 and YVY2 formats have the packing of components in a macro-pixel reversed compared to the // UYVY and VYUY formats. copyInfo.reversePacking = ((dstImageInfo.swizzledFormat.format == ChNumFormat::YUY2) || (dstImageInfo.swizzledFormat.format == ChNumFormat::YVY2)); } // Perform one conversion pass per plane of the YUV destination. for (uint32 pass = 0; pass < passCount; ++pass) { const auto& cscViewInfo = cscInfo.viewInfoRgbToYuv[pass]; SwizzledFormat imageViewInfoFormat = cscViewInfo.swizzledFormat; const SubresRange dstRange = #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 { { cscViewInfo.aspect, 0, region.yuvStartSlice }, 1, region.sliceCount }; #else { { cscViewInfo.plane, 0, region.yuvStartSlice }, 1, 1, region.sliceCount }; #endif // Try to use MM formats for YUV planes RpmUtil::SwapForMMFormat(dstImage.GetDevice(), &imageViewInfoFormat); RpmUtil::BuildImageViewInfo(&viewInfo[1], dstImage, dstRange, imageViewInfoFormat, RpmUtil::DefaultRpmLayoutShaderWrite, device.TexOptLevel()); // Build RGB to YUV color-space-conversion table constant buffer. RpmUtil::SetupRgbToYuvCscTable(dstImageInfo.swizzledFormat.format, pass, cscTable, &copyInfo); // The destination offset and extent need to be adjusted to account for differences in the dimensions of // the YUV image's planes. #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 Extent3d log2Ratio = Formats::Log2SubsamplingRatio(dstImageInfo.swizzledFormat.format, cscViewInfo.aspect); #else Extent3d log2Ratio = Formats::Log2SubsamplingRatio(dstImageInfo.swizzledFormat.format, cscViewInfo.plane); #endif if (cscInfo.pipelineRgbToYuv == RpmComputePipeline::RgbToYuvPacked) { // For YUV formats which are macro-pixel packed, we run a special shader which outputs two pixels // (one macro-pxiel) per thread. Therefore, we must adjust the destination region accordingly, even // though the planar subsampling ratio would normally be treated as 1:1. log2Ratio.width = 1; log2Ratio.height = 0; } copyInfo.dstOffset.x = (dstOffset.x >> log2Ratio.width); copyInfo.dstOffset.y = (dstOffset.y >> log2Ratio.height); copyInfo.dstExtent.width = (dstExtent.width >> log2Ratio.width); copyInfo.dstExtent.height = (dstExtent.height >> log2Ratio.height); // Each codec(Mpeg-1, Mpeg-2) requires the specific chroma subsampling location. copyInfo.sampleLocX = cscViewInfo.sampleLocX; copyInfo.sampleLocY = cscViewInfo.sampleLocY; // Each conversion shader requires: // o Two image SRD's: one for the RGB image, one for the YUV image // o One sampler SRD // o Inline constant space for copyInfo const uint32 sizeInDwords = (SrdDwordAlignment() * MaxTotalSrds) + RpmUtil::YuvRgbConversionInfoDwords; uint32* pUserData = RpmUtil::CreateAndBindEmbeddedUserData(pCmdBuffer, sizeInDwords, SrdDwordAlignment(), PipelineBindPoint::Compute, 0); device.CreateImageViewSrds(MaxImageSrds, &viewInfo[0], pUserData); pUserData += (SrdDwordAlignment() * MaxImageSrds); device.CreateSamplerSrds(1, &sampler, pUserData); pUserData += SrdDwordAlignment(); memcpy(pUserData, &copyInfo, sizeof(copyInfo)); // Finally, issue the dispatch. The shaders need one thread per texel. pCmdBuffer->CmdDispatch(RpmUtil::MinThreadGroups(copyInfo.dstExtent.width, threadsPerGroup[0]), RpmUtil::MinThreadGroups(copyInfo.dstExtent.height, threadsPerGroup[1]), RpmUtil::MinThreadGroups(region.sliceCount, threadsPerGroup[2])); } // End loop over per-plane passes } // End loop over regions pCmdBuffer->CmdRestoreComputeState(ComputeStateFlags::ComputeStatePipelineAndUserData); } // ===================================================================================================================== // Builds commands to fill every DWORD of the memory object with 'data' between dstOffset and (dstOffset + fillSize). // The offset and fill size must be DWORD aligned. void RsrcProcMgr::CmdFillMemory( GfxCmdBuffer* pCmdBuffer, bool saveRestoreComputeState, const GpuMemory& dstGpuMemory, gpusize dstOffset, gpusize fillSize, uint32 data ) const { PAL_ASSERT(IsPow2Aligned(dstOffset, sizeof(uint32))); PAL_ASSERT(IsPow2Aligned(fillSize, sizeof(uint32))); constexpr gpusize FillSizeLimit = 268435456; // 256MB const auto& settings = m_pDevice->Parent()->Settings(); if (saveRestoreComputeState) { // Save the command buffer's state. pCmdBuffer->CmdSaveComputeState(ComputeStatePipelineAndUserData); } for (gpusize fillOffset = 0; fillOffset < fillSize; fillOffset += FillSizeLimit) { const uint32 numDwords = static_cast<uint32>(Min(FillSizeLimit, (fillSize - fillOffset)) / sizeof(uint32)); // ((FillSizeLimit % 4) == 0) as the value stands now, ensuring fillSize is 4xOptimized too. If we change it // to something that doesn't satisfy this condition we would need to check ((fillSize - fillOffset) % 4) too. const bool is4xOptimized = ((numDwords % 4) == 0); const ComputePipeline* pPipeline = nullptr; if (is4xOptimized) { // This fill memory can be optimized to use the 4xDWORD pipeline. pPipeline = GetPipeline(RpmComputePipeline::FillMem4xDword); } else { // Use the fill memory DWORD pipeline since this call expects everything to be DWORD-aligned. pPipeline = GetPipeline(RpmComputePipeline::FillMemDword); } pCmdBuffer->CmdBindPipeline({ PipelineBindPoint::Compute, pPipeline, InternalApiPsoHash, }); uint32 srd[4] = { }; PAL_ASSERT(m_pDevice->Parent()->ChipProperties().srdSizes.bufferView == sizeof(srd)); BufferViewInfo dstBufferView = {}; dstBufferView.gpuAddr = dstGpuMemory.Desc().gpuVirtAddr + dstOffset + fillOffset; dstBufferView.range = numDwords * sizeof(uint32); dstBufferView.stride = (is4xOptimized) ? (sizeof(uint32) * 4) : sizeof(uint32); if (is4xOptimized) { dstBufferView.swizzledFormat.format = ChNumFormat::X32Y32Z32W32_Uint; dstBufferView.swizzledFormat.swizzle = { ChannelSwizzle::X, ChannelSwizzle::Y, ChannelSwizzle::Z, ChannelSwizzle::W }; } else { dstBufferView.swizzledFormat.format = ChNumFormat::X32_Uint; dstBufferView.swizzledFormat.swizzle = { ChannelSwizzle::X, ChannelSwizzle::Zero, ChannelSwizzle::Zero, ChannelSwizzle::One }; } #if PAL_CLIENT_INTERFACE_MAJOR_VERSION>= 558 dstBufferView.flags.bypassMallRead = TestAnyFlagSet(settings.rpmViewsBypassMall, Gfx10RpmViewsBypassMallOnRead); dstBufferView.flags.bypassMallWrite = TestAnyFlagSet(settings.rpmViewsBypassMall, Gfx10RpmViewsBypassMallOnWrite); #endif m_pDevice->Parent()->CreateTypedBufferViewSrds(1, &dstBufferView, &srd[0]); pCmdBuffer->CmdSetUserData(PipelineBindPoint::Compute, 0, 4, &srd[0]); pCmdBuffer->CmdSetUserData(PipelineBindPoint::Compute, 4, 1, &data); // Issue a dispatch with one thread per DWORD. const uint32 minThreads = (is4xOptimized) ? (numDwords / 4) : numDwords; const uint32 threadGroups = RpmUtil::MinThreadGroups(minThreads, pPipeline->ThreadsPerGroup()); pCmdBuffer->CmdDispatch(threadGroups, 1, 1); } if (saveRestoreComputeState) { // Restore the command buffer's state. pCmdBuffer->CmdRestoreComputeState(ComputeStatePipelineAndUserData); } } // ===================================================================================================================== // Builds commands to clear the specified ranges of the current depth stencil attachment views to the specified values. void RsrcProcMgr::CmdClearBoundDepthStencilTargets( GfxCmdBuffer* pCmdBuffer, float depth, uint8 stencil, uint8 stencilWriteMask, uint32 samples, uint32 fragments, DepthStencilSelectFlags flag, uint32 regionCount, const ClearBoundTargetRegion* pClearRegions ) const { PAL_ASSERT(regionCount > 0); StencilRefMaskParams stencilRefMasks = { }; stencilRefMasks.flags.u8All = 0xFF; stencilRefMasks.frontRef = stencil; stencilRefMasks.frontReadMask = 0xFF; stencilRefMasks.frontWriteMask = stencilWriteMask; stencilRefMasks.backRef = stencil; stencilRefMasks.backReadMask = 0xFF; stencilRefMasks.backWriteMask = stencilWriteMask; ViewportParams viewportInfo = { }; viewportInfo.count = 1; viewportInfo.viewports[0].originX = 0; viewportInfo.viewports[0].originY = 0; viewportInfo.viewports[0].minDepth = 0.f; viewportInfo.viewports[0].maxDepth = 1.f; viewportInfo.viewports[0].origin = PointOrigin::UpperLeft; viewportInfo.horzClipRatio = FLT_MAX; viewportInfo.horzDiscardRatio = 1.0f; viewportInfo.vertClipRatio = FLT_MAX; viewportInfo.vertDiscardRatio = 1.0f; viewportInfo.depthRange = DepthRange::ZeroToOne; ScissorRectParams scissorInfo = { }; scissorInfo.count = 1; scissorInfo.scissors[0].offset.x = 0; scissorInfo.scissors[0].offset.y = 0; // Save current command buffer state and bind graphics state which is common for all mipmap levels. pCmdBuffer->PushGraphicsState(); pCmdBuffer->CmdBindPipeline({ PipelineBindPoint::Graphics, GetGfxPipeline(DepthSlowDraw), InternalApiPsoHash, }); BindCommonGraphicsState(pCmdBuffer); pCmdBuffer->CmdBindMsaaState(GetMsaaState(samples, fragments)); pCmdBuffer->CmdSetStencilRefMasks(stencilRefMasks); if ((flag.depth != 0) && (flag.stencil != 0)) { pCmdBuffer->CmdBindDepthStencilState(m_pDepthStencilClearState); } else if (flag.depth != 0) { pCmdBuffer->CmdBindDepthStencilState(m_pDepthClearState); } else if (flag.stencil != 0) { pCmdBuffer->CmdBindDepthStencilState(m_pStencilClearState); } // All mip levels share the same depth export value, so only need to do it once. RpmUtil::WriteVsZOut(pCmdBuffer, depth); for (uint32 scissorIndex = 0; scissorIndex < regionCount; ++scissorIndex) { // Note: we should clear the same range of slices for depth and/or stencil attachment. If this // requirement needs to be relaxed, we need to separate the draws for depth clear and stencil clear. RpmUtil::WriteVsFirstSliceOffset(pCmdBuffer, pClearRegions[scissorIndex].startSlice); viewportInfo.viewports[0].originX = static_cast<float>(pClearRegions[scissorIndex].rect.offset.x); viewportInfo.viewports[0].originY = static_cast<float>(pClearRegions[scissorIndex].rect.offset.y); viewportInfo.viewports[0].width = static_cast<float>(pClearRegions[scissorIndex].rect.extent.width); viewportInfo.viewports[0].height = static_cast<float>(pClearRegions[scissorIndex].rect.extent.height); pCmdBuffer->CmdSetViewports(viewportInfo); scissorInfo.scissors[0].offset.x = pClearRegions[scissorIndex].rect.offset.x; scissorInfo.scissors[0].offset.y = pClearRegions[scissorIndex].rect.offset.y; scissorInfo.scissors[0].extent.width = pClearRegions[scissorIndex].rect.extent.width; scissorInfo.scissors[0].extent.height = pClearRegions[scissorIndex].rect.extent.height; pCmdBuffer->CmdSetScissorRects(scissorInfo); // Draw numSlices fullscreen instanced quads. pCmdBuffer->CmdDraw(0, 3, 0, pClearRegions[scissorIndex].numSlices, 0); } // Restore original command buffer state and destroy the depth/stencil state. pCmdBuffer->PopGraphicsState(); } // ===================================================================================================================== // Builds commands to clear the specified ranges of a depth/stencil image to the specified values. void RsrcProcMgr::CmdClearDepthStencil( GfxCmdBuffer* pCmdBuffer, const Image& dstImage, ImageLayout depthLayout, ImageLayout stencilLayout, float depth, uint8 stencil, uint8 stencilWriteMask, uint32 rangeCount, const SubresRange* pRanges, uint32 rectCount, const Rect* pRects, uint32 flags ) const { const GfxImage& gfxImage = *dstImage.GetGfxImage(); const bool hasRects = (rectCount > 0); const auto& createInfo = dstImage.GetImageCreateInfo(); PAL_ASSERT((hasRects == false) || (pRects != nullptr)); // Clear groups of ranges on "this group is fast clearable = true/false" boundaries uint32 rangesCleared = 0; // Convert the Rects to Boxes. We use an AutoBuffer instead of the virtual linear allocator because // we may need to allocate more boxes than will fit in the fixed virtual space. AutoBuffer<Box, 16, Platform> boxes(rectCount, m_pDevice->GetPlatform()); // Notify the command buffer if AutoBuffer allocation has failed. if (boxes.Capacity() < rectCount) { pCmdBuffer->NotifyAllocFailure(); } else { for (uint32 i = 0; i < rectCount; i++) { boxes[i].offset.x = pRects[i].offset.x; boxes[i].offset.y = pRects[i].offset.y; boxes[i].offset.z = 0; boxes[i].extent.width = pRects[i].extent.width; boxes[i].extent.height = pRects[i].extent.height; boxes[i].extent.depth = 1; } const bool clearRectCoversWholeImage = ((hasRects == false) || ((rectCount == 1) && (pRects[0].offset.x == 0) && (pRects[0].offset.y == 0) && (createInfo.extent.width == pRects[0].extent.width) && (createInfo.extent.height == pRects[0].extent.height))); while (rangesCleared < rangeCount) { const uint32 groupBegin = rangesCleared; // Note that fast clears don't support sub-rect clears so we skip them if we have any boxes. Further, // we only can store one fast clear color per mip level, and therefore can only support fast clears // when a range covers all slices. const bool groupFastClearable = (clearRectCoversWholeImage && gfxImage.IsFastDepthStencilClearSupported( depthLayout, stencilLayout, depth, stencil, stencilWriteMask, pRanges[groupBegin])); // Find as many other ranges that also support/don't support fast clearing so that they can be grouped // together into a single clear operation. uint32 groupEnd = groupBegin + 1; while ((groupEnd < rangeCount) && ((clearRectCoversWholeImage && gfxImage.IsFastDepthStencilClearSupported(depthLayout, stencilLayout, depth, stencil, stencilWriteMask, pRanges[groupEnd])) == groupFastClearable)) { ++groupEnd; } // Either fast clear or slow clear this group of ranges. rangesCleared = groupEnd; const uint32 clearRangeCount = groupEnd - groupBegin; // NOTE: end equals one past the last range in group. HwlDepthStencilClear(pCmdBuffer, gfxImage, depthLayout, stencilLayout, depth, stencil, stencilWriteMask, clearRangeCount, &pRanges[groupBegin], groupFastClearable, TestAnyFlagSet(flags, DsClearAutoSync), rectCount, &boxes[0]); } } } // ===================================================================================================================== // Builds commands to clear the existing color attachment in the command buffer to the given color data. void RsrcProcMgr::CmdClearBoundColorTargets( GfxCmdBuffer* pCmdBuffer, uint32 colorTargetCount, const BoundColorTarget* pBoundColorTargets, uint32 regionCount, const ClearBoundTargetRegion* pClearRegions ) const { // for attachment, clear region comes from boxes. So regionCount has to be valid PAL_ASSERT(regionCount > 0); ViewportParams viewportInfo = { }; viewportInfo.count = 1; viewportInfo.viewports[0].originX = 0; viewportInfo.viewports[0].originY = 0; viewportInfo.viewports[0].minDepth = 0.f; viewportInfo.viewports[0].maxDepth = 1.f; viewportInfo.viewports[0].origin = PointOrigin::UpperLeft; viewportInfo.horzClipRatio = FLT_MAX; viewportInfo.horzDiscardRatio = 1.0f; viewportInfo.vertClipRatio = FLT_MAX; viewportInfo.vertDiscardRatio = 1.0f; viewportInfo.depthRange = DepthRange::ZeroToOne; ScissorRectParams scissorInfo = { }; scissorInfo.count = 1; // Save current command buffer state and bind graphics state which is common for all mipmap levels. pCmdBuffer->PushGraphicsState(); BindCommonGraphicsState(pCmdBuffer); pCmdBuffer->CmdBindColorBlendState(m_pBlendDisableState); pCmdBuffer->CmdBindDepthStencilState(m_pDepthDisableState); for (uint32 colorIndex = 0; colorIndex < colorTargetCount; ++colorIndex) { uint32 convertedColor[4] = {0}; if (pBoundColorTargets[colorIndex].clearValue.type == ClearColorType::Float) { Formats::ConvertColor(pBoundColorTargets[colorIndex].swizzledFormat, &pBoundColorTargets[colorIndex].clearValue.f32Color[0], &convertedColor[0]); } else { memcpy(&convertedColor[0], &pBoundColorTargets[colorIndex].clearValue.u32Color[0], sizeof(convertedColor)); } // Get the correct slow clear state based on the view format. pCmdBuffer->CmdBindPipeline({ PipelineBindPoint::Graphics, GetGfxPipelineByTargetIndexAndFormat( SlowColorClear0_32ABGR, pBoundColorTargets[colorIndex].targetIndex, pBoundColorTargets[colorIndex].swizzledFormat), InternalApiPsoHash, }); pCmdBuffer->CmdOverwriteRbPlusFormatForBlits(pBoundColorTargets[colorIndex].swizzledFormat, pBoundColorTargets[colorIndex].targetIndex); pCmdBuffer->CmdBindMsaaState(GetMsaaState(pBoundColorTargets[colorIndex].samples, pBoundColorTargets[colorIndex].fragments)); RpmUtil::WriteVsZOut(pCmdBuffer, 1.0f); RpmUtil::ConvertClearColorToNativeFormat(pBoundColorTargets[colorIndex].swizzledFormat, pBoundColorTargets[colorIndex].swizzledFormat, &convertedColor[0]); pCmdBuffer->CmdSetUserData(PipelineBindPoint::Graphics, RpmPsClearFirstUserData, 4, &convertedColor[0]); for (uint32 scissorIndex = 0; scissorIndex < regionCount; ++scissorIndex) { RpmUtil::WriteVsFirstSliceOffset(pCmdBuffer, pClearRegions[scissorIndex].startSlice); viewportInfo.viewports[0].originX = static_cast<float>(pClearRegions[scissorIndex].rect.offset.x); viewportInfo.viewports[0].originY = static_cast<float>(pClearRegions[scissorIndex].rect.offset.y); viewportInfo.viewports[0].width = static_cast<float>(pClearRegions[scissorIndex].rect.extent.width); viewportInfo.viewports[0].height = static_cast<float>(pClearRegions[scissorIndex].rect.extent.height); pCmdBuffer->CmdSetViewports(viewportInfo); // Create a scissor state for this mipmap level, slice, and current scissor. scissorInfo.scissors[0].offset.x = pClearRegions[scissorIndex].rect.offset.x; scissorInfo.scissors[0].offset.y = pClearRegions[scissorIndex].rect.offset.y; scissorInfo.scissors[0].extent.width = pClearRegions[scissorIndex].rect.extent.width; scissorInfo.scissors[0].extent.height = pClearRegions[scissorIndex].rect.extent.height; pCmdBuffer->CmdSetScissorRects(scissorInfo); // Draw numSlices fullscreen instanced quads. pCmdBuffer->CmdDraw(0, 3, 0, pClearRegions[scissorIndex].numSlices, 0); } } // Restore original command buffer state. pCmdBuffer->PopGraphicsState(); } // ===================================================================================================================== // Builds commands to clear the specified ranges of an image to the given color data. void RsrcProcMgr::CmdClearColorImage( GfxCmdBuffer* pCmdBuffer, const Image& dstImage, ImageLayout dstImageLayout, const ClearColor& color, uint32 rangeCount, const SubresRange* pRanges, uint32 boxCount, const Box* pBoxes, uint32 flags ) const { Pal::GfxImage* pGfxImage = dstImage.GetGfxImage(); const auto& createInfo = dstImage.GetImageCreateInfo(); const SubResourceInfo*const pStartSubRes = dstImage.SubresourceInfo(pRanges[0].startSubres); const bool hasBoxes = (boxCount > 0); const bool clearBoxCoversWholeImage = ((hasBoxes == false) || ((boxCount == 1) && (pBoxes[0].offset.x == 0) && (pBoxes[0].offset.y == 0) && (pBoxes[0].offset.z == 0) && (createInfo.extent.width == pBoxes[0].extent.width) && (createInfo.extent.height == pBoxes[0].extent.height) && (createInfo.extent.depth == pBoxes[0].extent.depth))); bool needPreComputeSync = TestAnyFlagSet(flags, ColorClearAutoSync); bool needPostComputeSync = false; for (uint32 rangeIdx = 0; rangeIdx < rangeCount; ++rangeIdx) { #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 642 PAL_ASSERT(pRanges[rangeIdx].numPlanes == 1); #endif SubresRange minSlowClearRange = {}; const auto* pSlowClearRange = &minSlowClearRange; const auto& clearRange = pRanges[rangeIdx]; ClearMethod slowClearMethod = Image::DefaultSlowClearMethod; uint32 convertedColor[4] = { 0 }; if (color.type == ClearColorType::Float) { const SwizzledFormat& baseFormat = dstImage.SubresourceInfo(clearRange.startSubres)->format; Formats::ConvertColor(baseFormat, &color.f32Color[0], &convertedColor[0]); } else { memcpy(&convertedColor[0], &color.u32Color[0], sizeof(convertedColor)); } // Note that fast clears don't support sub-rect clears so we skip them if we have any boxes. Futher, we only // can store one fast clear color per mip level, and therefore can only support fast clears when a range covers // all slices. #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 592 // Fast clear is only usable when all channels of the color are being written. if ((color.disabledChannelMask == 0) && clearBoxCoversWholeImage && #else if (clearBoxCoversWholeImage && #endif pGfxImage->IsFastColorClearSupported(pCmdBuffer, dstImageLayout, &convertedColor[0], clearRange)) { // Assume that all portions of the original range can be fast cleared. SubresRange fastClearRange = clearRange; // Assume that no portion of the original range needs to be slow cleared. minSlowClearRange.startSubres = clearRange.startSubres; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 642 minSlowClearRange.numPlanes = clearRange.numPlanes; #endif minSlowClearRange.numSlices = clearRange.numSlices; minSlowClearRange.numMips = 0; for (uint32 mipIdx = 0; mipIdx < clearRange.numMips; ++mipIdx) { #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 const SubresId subres = { clearRange.startSubres.aspect, #else const SubresId subres = { clearRange.startSubres.plane, #endif clearRange.startSubres.mipLevel + mipIdx, 0 }; const ClearMethod clearMethod = dstImage.SubresourceInfo(subres)->clearMethod; if (clearMethod != ClearMethod::Fast) { fastClearRange.numMips = mipIdx; minSlowClearRange.startSubres.mipLevel = subres.mipLevel; minSlowClearRange.numMips = clearRange.numMips - mipIdx; slowClearMethod = clearMethod; break; } } if (fastClearRange.numMips != 0) { if (needPreComputeSync) { PreComputeColorClearSync(pCmdBuffer, &dstImage, pRanges[rangeIdx], dstImageLayout); needPostComputeSync = true; } // Hand off to the HWL to perform the fast-clear. PAL_ASSERT(dstImage.IsRenderTarget()); HwlFastColorClear(pCmdBuffer, *pGfxImage, &convertedColor[0], fastClearRange); } } else { // Since fast clears aren't available, the slow-clear range is everything the caller asked for. pSlowClearRange = &clearRange; } // If we couldn't fast clear every range, then we need to slow clear whatever is left over. if (pSlowClearRange->numMips != 0) { const SwizzledFormat& baseFormat = dstImage.SubresourceInfo(pSlowClearRange->startSubres)->format; const bool is3dBoxClear = hasBoxes && (createInfo.imageType == ImageType::Tex3d); uint32 texelScale = 1; const SwizzledFormat rawFormat = RpmUtil::GetRawFormat(baseFormat.format, &texelScale, nullptr); // Not surprisingly, a slow graphics clears requires a command buffer that supports graphics operations if (pCmdBuffer->IsGraphicsSupported() && // Force clears of scaled formats to the compute engine (texelScale == 1) && (slowClearMethod == ClearMethod::NormalGraphics)) { SlowClearGraphics(pCmdBuffer, dstImage, dstImageLayout, &color, *pSlowClearRange, boxCount, pBoxes); } else { if (needPreComputeSync) { PreComputeColorClearSync(pCmdBuffer, &dstImage, pRanges[rangeIdx], dstImageLayout); needPostComputeSync = true; } // Raw format clears are ok on the compute engine because these won't affect the state of DCC memory. SlowClearCompute(pCmdBuffer, dstImage, dstImageLayout, baseFormat, &color, *pSlowClearRange, boxCount, pBoxes); } } if (needPostComputeSync) { PostComputeColorClearSync(pCmdBuffer, &dstImage, pRanges[rangeIdx], dstImageLayout); needPostComputeSync = false; } } } // ===================================================================================================================== // Builds commands to slow clear a range of an image to the given raw color data using a pixel shader. Note that this // function can only clear color planes. void RsrcProcMgr::SlowClearGraphics( GfxCmdBuffer* pCmdBuffer, const Image& dstImage, ImageLayout dstImageLayout, const ClearColor* pColor, const SubresRange& clearRange, uint32 boxCount, const Box* pBoxes ) const { // Graphics slow clears only work on color planes. #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 PAL_ASSERT((clearRange.startSubres.aspect != ImageAspect::Depth) && (clearRange.startSubres.aspect != ImageAspect::Stencil)); #else PAL_ASSERT(dstImage.IsDepthStencilTarget() == false); #endif const auto& createInfo = dstImage.GetImageCreateInfo(); SubresId subresId = clearRange.startSubres; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 642 for (; subresId.plane < (clearRange.startSubres.plane + clearRange.numPlanes); subresId.plane++) #endif { // Get some useful information about the image. #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 592 bool rawFmtOk = dstImage.GetGfxImage()->IsFormatReplaceable(subresId, dstImageLayout, true, pColor->disabledChannelMask); #else bool rawFmtOk = dstImage.GetGfxImage()->IsFormatReplaceable(subresId, dstImageLayout, true); #endif // Query the format of the image and determine which format to use for the color target view. If rawFmtOk is // set the caller has allowed us to use a slightly more efficient raw format. const SwizzledFormat baseFormat = dstImage.SubresourceInfo(subresId)->format; SwizzledFormat viewFormat = (rawFmtOk ? RpmUtil::GetRawFormat(baseFormat.format, nullptr, nullptr) : baseFormat); uint32 xRightShift = 0; uint32 vpRightShift = 0; // For packed YUV image use X32_Uint instead of X16_Uint to fill with YUYV. if ((viewFormat.format == ChNumFormat::X16_Uint) && Formats::IsYuvPacked(baseFormat.format)) { viewFormat.format = ChNumFormat::X32_Uint; viewFormat.swizzle = { ChannelSwizzle::X, ChannelSwizzle::Zero, ChannelSwizzle::Zero, ChannelSwizzle::One }; rawFmtOk = false; // If clear color type isn't Yuv then the client is responsible for offset/extent adjustments. xRightShift = (pColor->type == ClearColorType::Yuv) ? 1 : 0; // The viewport should always be adjusted regardless the clear color type, (however, since this is just clear, // all pixels are the same and the scissor rect will clamp the rendering area, the result is still correct // without this adjustment). vpRightShift = 1; } ViewportParams viewportInfo = { }; viewportInfo.count = 1; viewportInfo.viewports[0].originX = 0; viewportInfo.viewports[0].originY = 0; viewportInfo.viewports[0].minDepth = 0.f; viewportInfo.viewports[0].maxDepth = 1.f; viewportInfo.viewports[0].origin = PointOrigin::UpperLeft; viewportInfo.horzClipRatio = FLT_MAX; viewportInfo.horzDiscardRatio = 1.0f; viewportInfo.vertClipRatio = FLT_MAX; viewportInfo.vertDiscardRatio = 1.0f; viewportInfo.depthRange = DepthRange::ZeroToOne; const bool is3dImage = (createInfo.imageType == ImageType::Tex3d); ColorTargetViewCreateInfo colorViewInfo = { }; colorViewInfo.swizzledFormat = viewFormat; colorViewInfo.imageInfo.pImage = &dstImage; colorViewInfo.imageInfo.arraySize = (is3dImage ? 1 : clearRange.numSlices); #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 colorViewInfo.imageInfo.baseSubRes.aspect = subresId.aspect; #else colorViewInfo.imageInfo.baseSubRes.plane = subresId.plane; #endif colorViewInfo.imageInfo.baseSubRes.arraySlice = subresId.arraySlice; BindTargetParams bindTargetsInfo = { }; bindTargetsInfo.colorTargets[0].imageLayout = dstImageLayout; bindTargetsInfo.colorTargets[0].pColorTargetView = nullptr; // Save current command buffer state and bind graphics state which is common for all mipmap levels. pCmdBuffer->PushGraphicsState(); pCmdBuffer->CmdBindPipeline({ PipelineBindPoint::Graphics, GetGfxPipelineByTargetIndexAndFormat(SlowColorClear0_32ABGR, 0, viewFormat), InternalApiPsoHash, }); BindCommonGraphicsState(pCmdBuffer); #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 592 if (pColor->disabledChannelMask != 0) { // Overwrite CbTargetMask for different writeMasks. pCmdBuffer->CmdOverrideColorWriteMaskForBlits(pColor->disabledChannelMask); } #endif pCmdBuffer->CmdOverwriteRbPlusFormatForBlits(viewFormat, 0); pCmdBuffer->CmdBindColorBlendState(m_pBlendDisableState); pCmdBuffer->CmdBindDepthStencilState(m_pDepthDisableState); pCmdBuffer->CmdBindMsaaState(GetMsaaState(createInfo.samples, createInfo.fragments)); RpmUtil::WriteVsZOut(pCmdBuffer, 1.0f); RpmUtil::WriteVsFirstSliceOffset(pCmdBuffer, 0); uint32 packedColor[4] = {0}; if (pColor->type == ClearColorType::Yuv) { // If clear color type is Yuv, the image format should used to determine the clear color swizzling and packing // for planar YUV formats since the baseFormat is subresource's format which is not a YUV format. // NOTE: if clear color type is Uint, the client is responsible for: // 1. packing and swizzling clear color for packed YUV formats (e.g. packing in YUYV order for YUY2). // 2. passing correct clear color for this plane for planar YUV formats (e.g. two uint32s for U and V if // current plane is CbCr). const SwizzledFormat imgFormat = createInfo.swizzledFormat; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 Formats::ConvertYuvColor(imgFormat, subresId.aspect, &pColor->u32Color[0], &packedColor[0]); #else Formats::ConvertYuvColor(imgFormat, subresId.plane, &pColor->u32Color[0], &packedColor[0]); #endif } else { uint32 convertedColor[4] = {0}; if (pColor->type == ClearColorType::Float) { Formats::ConvertColor(baseFormat, &pColor->f32Color[0], &convertedColor[0]); } else { memcpy(&convertedColor[0], &pColor->u32Color[0], sizeof(convertedColor)); } RpmUtil::ConvertClearColorToNativeFormat(baseFormat, viewFormat, &convertedColor[0]); // If we can clear with raw format replacement which is more efficient, swizzle it into the order // required and then pack it. if (rawFmtOk) { uint32 swizzledColor[4] = {0}; Formats::SwizzleColor(baseFormat, &convertedColor[0], &swizzledColor[0]); Formats::PackRawClearColor(baseFormat, &swizzledColor[0], &packedColor[0]); } else { memcpy(&packedColor[0], &convertedColor[0], sizeof(packedColor)); } } pCmdBuffer->CmdSetUserData(PipelineBindPoint::Graphics, RpmPsClearFirstUserData, 4, &packedColor[0]); // Each mipmap needs to be cleared individually. const uint32 lastMip = (subresId.mipLevel + clearRange.numMips - 1); // Boxes are only meaningful if we're clearing a single mip. PAL_ASSERT((boxCount == 0) || ((pBoxes != nullptr) && (clearRange.numMips == 1))); for (uint32 mip = subresId.mipLevel; mip <= lastMip; ++mip) { #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 const SubresId mipSubres = { subresId.aspect, mip, 0 }; #else const SubresId mipSubres = { subresId.plane, mip, 0 }; #endif const auto& subResInfo = *dstImage.SubresourceInfo(mipSubres); // All slices of the same mipmap level can re-use the same viewport state. viewportInfo.viewports[0].width = static_cast<float>(subResInfo.extentTexels.width >> vpRightShift); viewportInfo.viewports[0].height = static_cast<float>(subResInfo.extentTexels.height); pCmdBuffer->CmdSetViewports(viewportInfo); colorViewInfo.imageInfo.baseSubRes.mipLevel = mip; SlowClearGraphicsOneMip(pCmdBuffer, dstImage, mipSubres, boxCount, pBoxes, &colorViewInfo, &bindTargetsInfo, xRightShift); } // Restore original command buffer state. pCmdBuffer->PopGraphicsState(); } } // ===================================================================================================================== // Builds commands to slow clear a range of an image for a given mip level. void RsrcProcMgr::SlowClearGraphicsOneMip( GfxCmdBuffer* pCmdBuffer, const Image& dstImage, const SubresId& mipSubres, uint32 boxCount, const Box* pBoxes, ColorTargetViewCreateInfo* pColorViewInfo, BindTargetParams* pBindTargetsInfo, uint32 xRightShift ) const { PAL_ASSERT(pCmdBuffer->IsGraphicsSupported()); // Don't expect GFX Blts on Nested unless targets not inherited. PAL_ASSERT((pCmdBuffer->IsNested() == false) || (static_cast<UniversalCmdBuffer*>( pCmdBuffer)->GetGraphicsState().inheritedState.stateFlags.targetViewState == 0)); const auto& createInfo = dstImage.GetImageCreateInfo(); const bool is3dImage = (createInfo.imageType == ImageType::Tex3d); ColorTargetViewInternalCreateInfo colorViewInfoInternal = {}; const auto& subResInfo = *dstImage.SubresourceInfo(mipSubres); // If rects were specified, then we'll create scissors to match the rects and do a Draw for each one. Otherwise // we'll use the full image scissor and a single draw. const bool hasBoxes = (boxCount > 0); const uint32 scissorCount = hasBoxes ? boxCount : 1; if (is3dImage == false) { LinearAllocatorAuto<VirtualLinearAllocator> sliceAlloc(pCmdBuffer->Allocator(), false); // Create and bind a color-target view for this mipmap level and slice. IColorTargetView* pColorView = nullptr; void* pColorViewMem = PAL_MALLOC(m_pDevice->GetColorTargetViewSize(nullptr), &sliceAlloc, AllocInternalTemp); if (pColorViewMem == nullptr) { pCmdBuffer->NotifyAllocFailure(); } else { Result result = m_pDevice->CreateColorTargetView(*pColorViewInfo, colorViewInfoInternal, pColorViewMem, &pColorView); PAL_ASSERT(result == Result::Success); pBindTargetsInfo->colorTargets[0].pColorTargetView = pColorView; pBindTargetsInfo->colorTargetCount = 1; pCmdBuffer->CmdBindTargets(*pBindTargetsInfo); for (uint32 i = 0; i < scissorCount; i++) { ClearImageOneBox(pCmdBuffer, subResInfo, &pBoxes[i], hasBoxes, xRightShift, pColorViewInfo->imageInfo.arraySize); } // Unbind the color-target view and destroy it. pBindTargetsInfo->colorTargetCount = 0; pCmdBuffer->CmdBindTargets(*pBindTargetsInfo); PAL_SAFE_FREE(pColorViewMem, &sliceAlloc); } } else { // For 3d image, the start and end slice is based on the z offset and depth extend of the boxes. // The slices must be specified using the zRange because the imageInfo "slice" refers to image subresources. pColorViewInfo->flags.zRangeValid = 1; for (uint32 i = 0; i < scissorCount; i++) { LinearAllocatorAuto<VirtualLinearAllocator> sliceAlloc(pCmdBuffer->Allocator(), false); // Create and bind a color-target view for this mipmap level and z offset. IColorTargetView* pColorView = nullptr; void* pColorViewMem = PAL_MALLOC(m_pDevice->GetColorTargetViewSize(nullptr), &sliceAlloc, AllocInternalTemp); if (pColorViewMem == nullptr) { pCmdBuffer->NotifyAllocFailure(); } else { const Box* pBox = hasBoxes ? &pBoxes[i] : nullptr; const uint32 maxDepth = subResInfo.extentTexels.depth; pColorViewInfo->zRange.extent = hasBoxes ? pBox->extent.depth : maxDepth; pColorViewInfo->zRange.offset = hasBoxes ? pBox->offset.z : 0; PAL_ASSERT((hasBoxes == false) || (pBox->extent.depth <= maxDepth)); Result result = m_pDevice->CreateColorTargetView(*pColorViewInfo, colorViewInfoInternal, pColorViewMem, &pColorView); PAL_ASSERT(result == Result::Success); pBindTargetsInfo->colorTargets[0].pColorTargetView = pColorView; pBindTargetsInfo->colorTargetCount = 1; pCmdBuffer->CmdBindTargets(*pBindTargetsInfo); ClearImageOneBox(pCmdBuffer, subResInfo, pBox, hasBoxes, xRightShift, pColorViewInfo->zRange.extent); // Unbind the color-target view and destroy it. pBindTargetsInfo->colorTargetCount = 0; pCmdBuffer->CmdBindTargets(*pBindTargetsInfo); PAL_SAFE_FREE(pColorViewMem, &sliceAlloc); } } } } // ===================================================================================================================== // Builds commands to clear a range of an image for a given box. void RsrcProcMgr::ClearImageOneBox( GfxCmdBuffer* pCmdBuffer, const SubResourceInfo& subResInfo, const Box* pBox, bool hasBoxes, uint32 xRightShift, uint32 numInstances ) const { // Create a scissor state for this mipmap level, slice, and current scissor. ScissorRectParams scissorInfo = {}; scissorInfo.count = 1; if (hasBoxes) { scissorInfo.scissors[0].offset.x = pBox->offset.x >> xRightShift; scissorInfo.scissors[0].offset.y = pBox->offset.y; scissorInfo.scissors[0].extent.width = pBox->extent.width >> xRightShift; scissorInfo.scissors[0].extent.height = pBox->extent.height; } else { scissorInfo.scissors[0].extent.width = subResInfo.extentTexels.width >> xRightShift; scissorInfo.scissors[0].extent.height = subResInfo.extentTexels.height; } pCmdBuffer->CmdSetScissorRects(scissorInfo); // Draw a fullscreen quad. pCmdBuffer->CmdDraw(0, 3, 0, numInstances, 0); } // ===================================================================================================================== // Builds commands to slow clear a range of an image to the given raw color data using a compute shader. void RsrcProcMgr::SlowClearCompute( GfxCmdBuffer* pCmdBuffer, const Image& dstImage, ImageLayout dstImageLayout, SwizzledFormat dstFormat, const ClearColor* pColor, const SubresRange& clearRange, uint32 boxCount, const Box* pBoxes ) const { #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 642 PAL_ASSERT(clearRange.numPlanes == 1); #endif // If the image isn't in a layout that allows format replacement this clear path won't work. PAL_ASSERT(dstImage.GetGfxImage()->IsFormatReplaceable(clearRange.startSubres, dstImageLayout, true)); // Get some useful information about the image. const auto& createInfo = dstImage.GetImageCreateInfo(); const ImageType imageType = dstImage.GetGfxImage()->GetOverrideImageType(); uint32 texelScale = 1; uint32 texelShift = 0; bool singleSubRes = false; bool rawFmtOk = dstImage.GetGfxImage()->IsFormatReplaceable(clearRange.startSubres, dstImageLayout, true); const auto& subresInfo = *dstImage.SubresourceInfo(clearRange.startSubres); const SwizzledFormat baseFormat = subresInfo.format; SwizzledFormat viewFormat = rawFmtOk ? RpmUtil::GetRawFormat(dstFormat.format, &texelScale, &singleSubRes) : baseFormat; // For packed YUV image use X32_Uint instead of X16_Uint to fill with YUYV. if ((viewFormat.format == ChNumFormat::X16_Uint) && Formats::IsYuvPacked(dstFormat.format)) { viewFormat.format = ChNumFormat::X32_Uint; viewFormat.swizzle = { ChannelSwizzle::X, ChannelSwizzle::Zero, ChannelSwizzle::Zero, ChannelSwizzle::One }; rawFmtOk = false; // The extent and offset need to be adjusted to 1/2 size. texelShift = (pColor->type == ClearColorType::Yuv) ? 1 : 0; } // These are the only two supported texel scales PAL_ASSERT((texelScale == 1) || (texelScale == 3)); // Get the appropriate pipeline. auto pipelineEnum = RpmComputePipeline::Count; switch (imageType) { case ImageType::Tex1d: pipelineEnum = ((texelScale == 1) ? RpmComputePipeline::ClearImage1d : RpmComputePipeline::ClearImage1dTexelScale); break; case ImageType::Tex2d: pipelineEnum = ((texelScale == 1) ? RpmComputePipeline::ClearImage2d : RpmComputePipeline::ClearImage2dTexelScale); break; default: pipelineEnum = ((texelScale == 1) ? RpmComputePipeline::ClearImage3d : RpmComputePipeline::ClearImage3dTexelScale); break; } const ComputePipeline* pPipeline = GetPipeline(pipelineEnum); // Get number of threads per group in each dimension. uint32 threadsPerGroup[3] = {0}; pPipeline->ThreadsPerGroupXyz(&threadsPerGroup[0], &threadsPerGroup[1], &threadsPerGroup[2]); // Save current command buffer state and bind the pipeline. pCmdBuffer->CmdSaveComputeState(ComputeStatePipelineAndUserData); pCmdBuffer->CmdBindPipeline({ PipelineBindPoint::Compute, pPipeline, InternalApiPsoHash, }); // Pack the clear color into the raw format and write it to user data 2-5. uint32 packedColor[4] = {0}; uint32 convertedColor[4] = {0}; if (pColor->type == ClearColorType::Yuv) { // If clear color type is Yuv, the image format should used to determine the clear color swizzling and packing // for planar YUV formats since the baseFormat is subresource's format which is not a YUV format. // NOTE: if clear color type is Uint, the client is responsible for: // 1. packing and swizzling clear color for packed YUV formats (e.g. packing in YUYV order for YUY2) // 2. passing correct clear color for this plane for planar YUV formats (e.g. two uint32s for U and V if // current plane is CbCr). const SwizzledFormat imgFormat = createInfo.swizzledFormat; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 Formats::ConvertYuvColor(imgFormat, clearRange.startSubres.aspect, &pColor->u32Color[0], &packedColor[0]); #else Formats::ConvertYuvColor(imgFormat, clearRange.startSubres.plane, &pColor->u32Color[0], &packedColor[0]); #endif } else { if (pColor->type == ClearColorType::Float) { Formats::ConvertColor(dstFormat, &pColor->f32Color[0], &convertedColor[0]); } else { memcpy(&convertedColor[0], &pColor->u32Color[0], sizeof(convertedColor)); } uint32 swizzledColor[4] = {0}; Formats::SwizzleColor(dstFormat, &convertedColor[0], &swizzledColor[0]); Formats::PackRawClearColor(dstFormat, &swizzledColor[0], &packedColor[0]); } // Split the clear range into sections with constant mip/array levels and loop over them. #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 SubresRange singleMipRange = { clearRange.startSubres, 1, clearRange.numSlices }; #else SubresRange singleMipRange = { clearRange.startSubres, 1, 1, clearRange.numSlices }; #endif const uint32 firstMipLevel = clearRange.startSubres.mipLevel; const uint32 lastMipLevel = clearRange.startSubres.mipLevel + clearRange.numMips - 1; const uint32 lastArraySlice = clearRange.startSubres.arraySlice + clearRange.numSlices - 1; // If single subres is requested for the format, iterate slice-by-slice and mip-by-mip. if (singleSubRes) { singleMipRange.numSlices = 1; } // We will do a dispatch for every box. If no boxes are specified then we will do a single full image dispatch. const bool hasBoxes = (boxCount > 0); const uint32 dispatchCount = hasBoxes ? boxCount : 1; // Boxes are only meaningful if we're clearing a single mip. PAL_ASSERT((hasBoxes == false) || ((pBoxes != nullptr) && (clearRange.numMips == 1))); // The user data will contain: // [ 0 : 3] Clear color // [ 4 : 10] Offset and extent uint32 userData[11] = { packedColor[0], packedColor[1], packedColor[2], packedColor[3], 0, 0, 0, 0, 0, 0, 0 }; const auto& device = *m_pDevice->Parent(); for (; singleMipRange.startSubres.arraySlice <= lastArraySlice; singleMipRange.startSubres.arraySlice += singleMipRange.numSlices) { singleMipRange.startSubres.mipLevel = firstMipLevel; for (; singleMipRange.startSubres.mipLevel <= lastMipLevel; ++singleMipRange.startSubres.mipLevel) { const auto& subResInfo = *dstImage.SubresourceInfo(singleMipRange.startSubres); // Create an embedded SRD table and bind it to user data 0. We only need a single image view. // Populate the table with an image view and the embedded user data. The view should cover this // mip's clear range and use a raw format. const uint32 DataDwords = NumBytesToNumDwords(sizeof(userData)); ImageViewInfo imageView = {}; PAL_ASSERT(TestAnyFlagSet(dstImageLayout.usages, LayoutShaderWrite | LayoutCopyDst) == true); RpmUtil::BuildImageViewInfo(&imageView, dstImage, singleMipRange, viewFormat, dstImageLayout, device.TexOptLevel()); // The default clear box is the entire subresource. This will be changed per-dispatch if boxes are enabled. Extent3d clearExtent = subResInfo.extentTexels; Offset3d clearOffset = {}; for (uint32 i = 0; i < dispatchCount; i++) { uint32* pSrdTable = RpmUtil::CreateAndBindEmbeddedUserData( pCmdBuffer, SrdDwordAlignment() + DataDwords, SrdDwordAlignment(), PipelineBindPoint::Compute, 0); device.CreateImageViewSrds(1, &imageView, pSrdTable); pSrdTable += SrdDwordAlignment(); if (hasBoxes) { clearExtent = pBoxes[i].extent; clearOffset = pBoxes[i].offset; } if (texelShift != 0) { clearExtent.width >>= texelShift; clearOffset.x >>= texelShift; } // Compute the minimum number of threads to dispatch. Note that only 2D images can have multiple // samples and 3D images cannot have multiple slices. uint32 minThreads[3] = { clearExtent.width, 1, 1, }; switch (imageType) { case ImageType::Tex1d: // For 1d the shader expects the x offset, an unused dword, then the clear width. // ClearImage1D:dcl_num_thread_per_group 64, 1, 1, Y and Z direction threads are 1 userData[4] = clearOffset.x; userData[6] = clearExtent.width; // 1D images can only have a single-sample, but they can have multiple slices. minThreads[2] = singleMipRange.numSlices; break; case ImageType::Tex2d: minThreads[1] = clearExtent.height; minThreads[2] = singleMipRange.numSlices * createInfo.samples; // For 2d the shader expects x offset, y offset, clear width then clear height. userData[4] = clearOffset.x; userData[5] = clearOffset.y; userData[6] = clearExtent.width; userData[7] = clearExtent.height; break; default: // 3d image minThreads[1] = clearExtent.height; minThreads[2] = clearExtent.depth; // For 3d the shader expects x, y z offsets, an unused dword then the width, height and depth. userData[4] = clearOffset.x; userData[5] = clearOffset.y; userData[6] = clearOffset.z; userData[8] = clearExtent.width; userData[9] = clearExtent.height; userData[10] = clearExtent.depth; break; } // Copy the user-data values into the descriptor table memory. memcpy(pSrdTable, &userData[0], sizeof(userData)); // Execute the dispatch. pCmdBuffer->CmdDispatch(RpmUtil::MinThreadGroups(minThreads[0], threadsPerGroup[0]), RpmUtil::MinThreadGroups(minThreads[1], threadsPerGroup[1]), RpmUtil::MinThreadGroups(minThreads[2], threadsPerGroup[2])); } } } // Restore original command buffer state. pCmdBuffer->CmdRestoreComputeState(ComputeStatePipelineAndUserData); } // ===================================================================================================================== // Builds commands to clear the contents of the buffer view (or the given ranges) to the given clear color. // The simplest way to implement this is to decode the SRD's view info and reuse CmdClearColorBuffer. void RsrcProcMgr::CmdClearBufferView( GfxCmdBuffer* pCmdBuffer, const IGpuMemory& dstGpuMemory, const ClearColor& color, const void* pBufferViewSrd, uint32 rangeCount, const Range* pRanges ) const { // Decode the buffer SRD. BufferViewInfo viewInfo = {}; HwlDecodeBufferViewSrd(pBufferViewSrd, &viewInfo); // We need the offset and extent of the buffer wrt. the dstGpuMemory in units of texels. const uint32 viewStride = Formats::BytesPerPixel(viewInfo.swizzledFormat.format); const uint32 viewOffset = static_cast<uint32>(viewInfo.gpuAddr - dstGpuMemory.Desc().gpuVirtAddr); const uint32 viewExtent = static_cast<uint32>(viewInfo.range); // The view's offset and extent must be multiples of the view's texel stride. PAL_ASSERT((viewOffset % viewStride == 0) && (viewExtent % viewStride == 0)); const uint32 offset = viewOffset / viewStride; const uint32 extent = viewExtent / viewStride; CmdClearColorBuffer(pCmdBuffer, dstGpuMemory, color, viewInfo.swizzledFormat, offset, extent, rangeCount, pRanges); } // ===================================================================================================================== // Builds commands to clear the contents of the buffer (or the given ranges) to the given clear color. void RsrcProcMgr::CmdClearColorBuffer( GfxCmdBuffer* pCmdBuffer, const IGpuMemory& dstGpuMemory, const ClearColor& color, SwizzledFormat bufferFormat, uint32 bufferOffset, uint32 bufferExtent, uint32 rangeCount, const Range* pRanges ) const { const auto& settings = m_pDevice->Parent()->Settings(); ClearColor clearColor = color; uint32 convertedColor[4] = {0}; if (clearColor.type == ClearColorType::Float) { Formats::ConvertColor(bufferFormat, &clearColor.f32Color[0], &convertedColor[0]); } else { memcpy(&convertedColor[0], &clearColor.u32Color[0], sizeof(convertedColor)); } // Pack the clear color into the form it is expected to take in memory. constexpr uint32 PackedColorDwords = 4; uint32 packedColor[PackedColorDwords] = {0}; Formats::PackRawClearColor(bufferFormat, &convertedColor[0], &packedColor[0]); // This is the raw format that we will be writing. uint32 texelScale = 0; const SwizzledFormat rawFormat = RpmUtil::GetRawFormat(bufferFormat.format, &texelScale, nullptr); const uint32 bpp = Formats::BytesPerPixel(rawFormat.format); // Get the appropriate pipeline. const auto*const pPipeline = GetPipeline(RpmComputePipeline::ClearBuffer); const uint32 threadsPerGroup = pPipeline->ThreadsPerGroup(); // Save current command buffer state and bind the pipeline. pCmdBuffer->CmdSaveComputeState(ComputeStatePipelineAndUserData); pCmdBuffer->CmdBindPipeline({ PipelineBindPoint::Compute, pPipeline, InternalApiPsoHash, }); // some formats (notably RGB32) require multiple passes, e.g. we cannot write 12b texels (see RpmUtil::GetRawFormat) // for all other formats this loop will run a single iteration for (uint32 channel = 0; channel < texelScale; channel++) { // Build an SRD we can use to write to any texel within the buffer using our raw format. BufferViewInfo dstViewInfo = {}; dstViewInfo.gpuAddr = dstGpuMemory.Desc().gpuVirtAddr + (texelScale == 1 ? bpp : 1) * (bufferOffset) + channel * bpp; dstViewInfo.range = bpp * texelScale * bufferExtent; dstViewInfo.stride = bpp * texelScale; dstViewInfo.swizzledFormat = texelScale == 1 ? rawFormat : UndefinedSwizzledFormat; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION>= 558 dstViewInfo.flags.bypassMallRead = TestAnyFlagSet(settings.rpmViewsBypassMall, Gfx10RpmViewsBypassMallOnRead); dstViewInfo.flags.bypassMallWrite = TestAnyFlagSet(settings.rpmViewsBypassMall, Gfx10RpmViewsBypassMallOnWrite); #endif uint32 dstSrd[4] = {0}; PAL_ASSERT(m_pDevice->Parent()->ChipProperties().srdSizes.bufferView == sizeof(dstSrd)); if (texelScale == 1) { m_pDevice->Parent()->CreateTypedBufferViewSrds(1, &dstViewInfo, dstSrd); } else { // we have to use non-standard stride, which is incompatible with TypedBufferViewSrd contract m_pDevice->Parent()->CreateUntypedBufferViewSrds(1, &dstViewInfo, dstSrd); } // We will do a dispatch for every range. If no ranges are specified then we will do a single full buffer dispatch. const Range defaultRange = { 0, bufferExtent }; const bool hasRanges = (rangeCount > 0); const uint32 dispatchCount = hasRanges ? rangeCount : 1; const Range* pDispatchRanges = hasRanges ? pRanges : &defaultRange; for (uint32 i = 0; i < dispatchCount; i++) { // Create an embedded SRD table and bind it to user data 0-1. We only need a single buffer view. // Populate the table with a buffer view and the necessary embedded user data (clear color, offset, and extent). constexpr uint32 DataDwords = PackedColorDwords + 2; uint32* pSrdTable = RpmUtil::CreateAndBindEmbeddedUserData(pCmdBuffer, SrdDwordAlignment() + DataDwords, SrdDwordAlignment(), PipelineBindPoint::Compute, 0); // Copy in the raw buffer view. memcpy(pSrdTable, dstSrd, sizeof(dstSrd)); pSrdTable += SrdDwordAlignment(); // Copy in the packed clear color. memcpy(pSrdTable, packedColor + channel, sizeof(packedColor) - channel * sizeof(uint32)); pSrdTable += PackedColorDwords; // The final two entries in the table are the range offset and range extent. pSrdTable[0] = pDispatchRanges[i].offset; pSrdTable[1] = pDispatchRanges[i].extent; // Verify that the range is contained within the view. PAL_ASSERT((pDispatchRanges[i].offset >= 0) && (pDispatchRanges[i].offset + pDispatchRanges[i].extent <= bufferExtent)); // Execute the dispatch. const uint32 numThreadGroups = RpmUtil::MinThreadGroups(pDispatchRanges[i].extent, threadsPerGroup); pCmdBuffer->CmdDispatch(numThreadGroups, 1, 1); } } // Restore original command buffer state. pCmdBuffer->CmdRestoreComputeState(ComputeStatePipelineAndUserData); } // ===================================================================================================================== // Builds commands to clear the contents of the image view (or the given boxes) to the given clear color. // Given that the destination image is in a shader writeable layout we must do this clear using a compute slow clear. // The simplest way to implement this is to decode the SRD's format and range and reuse SlowClearCompute. void RsrcProcMgr::CmdClearImageView( GfxCmdBuffer* pCmdBuffer, const Image& dstImage, ImageLayout dstImageLayout, const ClearColor& color, const void* pImageViewSrd, uint32 rectCount, const Rect* pRects ) const { // Get the SRD's format and subresource range. SwizzledFormat srdFormat = {}; SubresRange srdRange = {}; HwlDecodeImageViewSrd(pImageViewSrd, dstImage, &srdFormat, &srdRange); ClearColor clearColor = color; const auto& createInfo = dstImage.GetImageCreateInfo(); if (rectCount != 0) { Box* pBoxes = PAL_NEW_ARRAY(Box, rectCount, m_pDevice->GetPlatform(), AllocObject); if (pBoxes != nullptr) { for (uint32 i = 0; i < rectCount; i++) { pBoxes[i].offset.x = pRects[i].offset.x; pBoxes[i].offset.y = pRects[i].offset.y; pBoxes[i].offset.z = srdRange.startSubres.arraySlice; pBoxes[i].extent.width = pRects[i].extent.width; pBoxes[i].extent.height = pRects[i].extent.height; pBoxes[i].extent.depth = srdRange.numSlices; } SlowClearCompute(pCmdBuffer, dstImage, dstImageLayout, srdFormat, &clearColor, srdRange, rectCount, pBoxes); PAL_DELETE_ARRAY(pBoxes, m_pDevice->GetPlatform()); } else { // Memory allocation failed. PAL_ASSERT_ALWAYS(); } } else { SlowClearCompute(pCmdBuffer, dstImage, dstImageLayout, srdFormat, &clearColor, srdRange, rectCount, nullptr); } } // ===================================================================================================================== // Expand DCC/Fmask/HTile and sync before resolve image. void RsrcProcMgr::LateExpandResolveSrc( GfxCmdBuffer* pCmdBuffer, const Image& srcImage, ImageLayout srcImageLayout, const ImageResolveRegion* pRegions, uint32 regionCount, ResolveMethod method ) const { const ImageLayoutUsageFlags shaderUsage = (method.shaderCsFmask ? Pal::LayoutShaderFmaskBasedRead : Pal::LayoutShaderRead); if (((method.shaderCsFmask != 0) || (method.shaderCs != 0)) && (TestAnyFlagSet(srcImageLayout.usages, shaderUsage) == false)) { BarrierTransition transition = { }; transition.imageInfo.pImage = &srcImage; transition.imageInfo.oldLayout.usages = srcImageLayout.usages; transition.imageInfo.oldLayout.engines = srcImageLayout.engines; transition.imageInfo.newLayout.usages = srcImageLayout.usages | shaderUsage; transition.imageInfo.newLayout.engines = srcImageLayout.engines; transition.srcCacheMask = Pal::CoherResolve; transition.dstCacheMask = Pal::CoherShader; LateExpandResolveSrcHelper(pCmdBuffer, pRegions, regionCount, transition, HwPipePreBlt); } } // ===================================================================================================================== // Inserts a barrier after a compute resolve for a color image. Returns the image to the ResolveSrc layout after the // internal compute shader runs. void RsrcProcMgr::FixupLateExpandResolveSrc( GfxCmdBuffer* pCmdBuffer, const Image& srcImage, ImageLayout srcImageLayout, const ImageResolveRegion* pRegions, uint32 regionCount, ResolveMethod method ) const { const ImageLayoutUsageFlags shaderUsage = (method.shaderCsFmask ? Pal::LayoutShaderFmaskBasedRead : Pal::LayoutShaderRead); if (((method.shaderCsFmask != 0) || (method.shaderCs != 0)) && (TestAnyFlagSet(srcImageLayout.usages, shaderUsage) == false)) { BarrierTransition transition = { }; transition.imageInfo.pImage = &srcImage; transition.imageInfo.oldLayout.usages = srcImageLayout.usages | shaderUsage; transition.imageInfo.oldLayout.engines = srcImageLayout.engines; transition.imageInfo.newLayout.usages = srcImageLayout.usages; transition.imageInfo.newLayout.engines = srcImageLayout.engines; transition.srcCacheMask = Pal::CoherShader; transition.dstCacheMask = Pal::CoherResolve; LateExpandResolveSrcHelper(pCmdBuffer, pRegions, regionCount, transition, HwPipePostBlt); } } // ===================================================================================================================== // Helper function for setting up a barrier used before and after a compute shader resolve. void RsrcProcMgr::LateExpandResolveSrcHelper( GfxCmdBuffer* pCmdBuffer, const ImageResolveRegion* pRegions, uint32 regionCount, const BarrierTransition& transition, HwPipePoint waitPoint ) const { const Image& image = *static_cast<const Image*>(transition.imageInfo.pImage); AutoBuffer<BarrierTransition, 32, Platform> transitions(regionCount, m_pDevice->GetPlatform()); if (transitions.Capacity() >= regionCount) { for (uint32 i = 0; i < regionCount; i++) { #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 transitions[i].imageInfo.subresRange.startSubres.aspect = pRegions[i].srcAspect; #else transitions[i].imageInfo.subresRange.startSubres.plane = pRegions[i].srcPlane; #endif transitions[i].imageInfo.subresRange.startSubres.arraySlice = pRegions[i].srcSlice; transitions[i].imageInfo.subresRange.startSubres.mipLevel = 0; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 642 transitions[i].imageInfo.subresRange.numPlanes = 1; #endif transitions[i].imageInfo.subresRange.numMips = 1; transitions[i].imageInfo.subresRange.numSlices = pRegions[i].numSlices; transitions[i].imageInfo.pImage = &image; transitions[i].imageInfo.oldLayout = transition.imageInfo.oldLayout; transitions[i].imageInfo.newLayout = transition.imageInfo.newLayout; transitions[i].imageInfo.pQuadSamplePattern = pRegions[i].pQuadSamplePattern; transitions[i].srcCacheMask = transition.srcCacheMask; transitions[i].dstCacheMask = transition.dstCacheMask; PAL_ASSERT((image.GetImageCreateInfo().flags.sampleLocsAlwaysKnown != 0) == (pRegions[i].pQuadSamplePattern != nullptr)); } BarrierInfo barrierInfo = { }; barrierInfo.pTransitions = &transitions[0]; barrierInfo.transitionCount = regionCount; barrierInfo.waitPoint = waitPoint; barrierInfo.reason = Developer::BarrierReasonUnknown; const HwPipePoint releasePipePoint = Pal::HwPipeBottom; barrierInfo.pipePointWaitCount = 1; barrierInfo.pPipePoints = &releasePipePoint; pCmdBuffer->CmdBarrier(barrierInfo); } else { pCmdBuffer->NotifyAllocFailure(); } } // ===================================================================================================================== // This must be called before and after each compute copy. The pre-copy call will insert any required metadata // decompresses and the post-copy call will fixup any metadata that needs updating. In practice these barriers are // required in cases where we treat CopyDst as compressed but RPM can't actually write compressed data directly from // the compute shader. void RsrcProcMgr::FixupMetadataForComputeDst( GfxCmdBuffer* pCmdBuffer, const Image& dstImage, ImageLayout dstImageLayout, uint32 regionCount, const ImageFixupRegion* pRegions, bool beforeCopy ) const { const GfxImage* pGfxImage = dstImage.GetGfxImage(); // TODO: unify all RPM metadata fixup here; currently only depth image is handled. if (pGfxImage->HasHtileData()) { // TODO: there is suspected Hiz issue on gfx10 comrpessed depth write. Suggested temporary workaround is // to attach layout with LayoutUncompressed, which always triggers depth expand before copy and depth // resummarize after copy. const bool enableCompressedDepthWriteTempWa = IsGfx10(*m_pDevice->Parent()); // If enable temp workaround for comrpessed depth write, always need barriers for before and after copy. bool needBarrier = enableCompressedDepthWriteTempWa; for (uint32 i = 0; (needBarrier == false) && (i < regionCount); i++) { needBarrier = pGfxImage->ShaderWriteIncompatibleWithLayout(pRegions[i].subres, dstImageLayout); } if (needBarrier) { AutoBuffer<BarrierTransition, 32, Platform> transitions(regionCount, m_pDevice->GetPlatform()); if (transitions.Capacity() >= regionCount) { const uint32 shaderWriteLayout = (enableCompressedDepthWriteTempWa ? (LayoutShaderWrite | LayoutUncompressed) : LayoutShaderWrite); for (uint32 i = 0; i < regionCount; i++) { transitions[i].imageInfo.pImage = &dstImage; transitions[i].imageInfo.subresRange.startSubres = pRegions[i].subres; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 642 transitions[i].imageInfo.subresRange.numPlanes = 1; #endif transitions[i].imageInfo.subresRange.numMips = 1; transitions[i].imageInfo.subresRange.numSlices = pRegions[i].numSlices; transitions[i].imageInfo.oldLayout = dstImageLayout; transitions[i].imageInfo.newLayout = dstImageLayout; transitions[i].imageInfo.pQuadSamplePattern = nullptr; // The first barrier must prepare the image for shader writes, perhaps by decompressing metadata. // The second barrier is required to undo those changes, perhaps by resummarizing the metadata. if (beforeCopy) { // Can optimize depth expand to lighter Barrier with UninitializedTarget for full subres copy. const SubResourceInfo* pSubresInfo = dstImage.SubresourceInfo(pRegions[i].subres); const bool fullSubresCopy = ((pRegions[i].offset.x == 0) && (pRegions[i].offset.y == 0) && (pRegions[i].offset.z == 0) && (pRegions[i].extent.width >= pSubresInfo->extentElements.width) && (pRegions[i].extent.height >= pSubresInfo->extentElements.height) && (pRegions[i].extent.depth >= pSubresInfo->extentElements.depth)); if (fullSubresCopy) { transitions[i].imageInfo.oldLayout.usages = LayoutUninitializedTarget; } transitions[i].imageInfo.newLayout.usages |= shaderWriteLayout; transitions[i].srcCacheMask = CoherCopy; transitions[i].dstCacheMask = CoherShader; } else // After copy { transitions[i].imageInfo.oldLayout.usages |= shaderWriteLayout; transitions[i].srcCacheMask = CoherShader; transitions[i].dstCacheMask = CoherCopy; } } // Operations like resummarizes might read the blit's output so we can't optimize the wait point. BarrierInfo barrierInfo = {}; barrierInfo.pTransitions = &transitions[0]; barrierInfo.transitionCount = regionCount; barrierInfo.waitPoint = HwPipePreBlt; const HwPipePoint releasePipePoint = beforeCopy ? HwPipeBottom : HwPipePostCs; barrierInfo.pipePointWaitCount = 1; barrierInfo.pPipePoints = &releasePipePoint; pCmdBuffer->CmdBarrier(barrierInfo); } else { pCmdBuffer->NotifyAllocFailure(); } } } } // ===================================================================================================================== // Resolves a multisampled source Image into the single-sampled destination Image using the Image's resolve method. void RsrcProcMgr::CmdResolveImage( GfxCmdBuffer* pCmdBuffer, const Image& srcImage, ImageLayout srcImageLayout, const Image& dstImage, ImageLayout dstImageLayout, ResolveMode resolveMode, uint32 regionCount, const ImageResolveRegion* pRegions, uint32 flags ) const { const ResolveMethod srcMethod = srcImage.GetImageInfo().resolveMethod; const ResolveMethod dstMethod = dstImage.GetImageInfo().resolveMethod; if (pCmdBuffer->GetEngineType() == EngineTypeCompute) { PAL_ASSERT((srcMethod.shaderCsFmask == 1) || (srcMethod.shaderCs == 1)); ResolveImageCompute(pCmdBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, resolveMode, regionCount, pRegions, srcMethod, flags); HwlFixupResolveDstImage(pCmdBuffer, *dstImage.GetGfxImage(), dstImageLayout, pRegions, regionCount, true); } else { if ((srcMethod.fixedFunc == 1) && HwlCanDoFixedFuncResolve(srcImage, dstImage, resolveMode, regionCount, pRegions)) { PAL_ASSERT(resolveMode == ResolveMode::Average); // this only support color resolves. ResolveImageFixedFunc(pCmdBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions, flags); HwlFixupResolveDstImage(pCmdBuffer, *dstImage.GetGfxImage(), dstImageLayout, pRegions, regionCount, false); } else if ((srcMethod.depthStencilCopy == 1) && (dstMethod.depthStencilCopy == 1) && (resolveMode == ResolveMode::Average) && HwlCanDoDepthStencilCopyResolve(srcImage, dstImage, regionCount, pRegions)) { ResolveImageDepthStencilCopy(pCmdBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions, flags); HwlHtileCopyAndFixUp(pCmdBuffer, srcImage, dstImage, dstImageLayout, regionCount, pRegions, false); } else if (dstMethod.shaderPs && (resolveMode == ResolveMode::Average)) { // this only supports Depth/Stencil resolves. ResolveImageGraphics(pCmdBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, regionCount, pRegions, flags); } else if (pCmdBuffer->IsComputeSupported() && ((srcMethod.shaderCsFmask == 1) || (srcMethod.shaderCs == 1))) { ResolveImageCompute(pCmdBuffer, srcImage, srcImageLayout, dstImage, dstImageLayout, resolveMode, regionCount, pRegions, srcMethod, flags); HwlFixupResolveDstImage(pCmdBuffer, *dstImage.GetGfxImage(), dstImageLayout, pRegions, regionCount, true); } else { PAL_NOT_IMPLEMENTED(); } } } // ===================================================================================================================== // Executes a compute shader which generates a PM4 command buffer which can later be executed. If the number of indirect // commands being generated will not fit into a single command-stream chunk, this will issue multiple dispatches, one // for each command chunk to generate. void RsrcProcMgr::CmdGenerateIndirectCmds( const GenerateInfo& genInfo, CmdStreamChunk** ppChunkLists[], uint32 NumChunkLists, uint32* pNumGenChunks ) const { const auto& settings = m_pDevice->Parent()->Settings(); const gpusize argsGpuAddr = genInfo.argsGpuAddr; const gpusize countGpuAddr = genInfo.countGpuAddr; const Pipeline* pPipeline = genInfo.pPipeline; const IndirectCmdGenerator& generator = genInfo.generator; GfxCmdBuffer* pCmdBuffer = genInfo.pCmdBuffer; uint32 indexBufSize = genInfo.indexBufSize; uint32 maximumCount = genInfo.maximumCount; const ComputePipeline* pGenerationPipeline = GetCmdGenerationPipeline(generator, *pCmdBuffer); uint32 threadsPerGroup[3] = { }; pGenerationPipeline->ThreadsPerGroupXyz(&threadsPerGroup[0], &threadsPerGroup[1], &threadsPerGroup[2]); pCmdBuffer->CmdSaveComputeState(ComputeStatePipelineAndUserData); pCmdBuffer->CmdBindPipeline({ PipelineBindPoint::Compute, pGenerationPipeline, InternalApiPsoHash, }); // The command-generation pipelines expect the following descriptor-table layout for the resources which are the // same for each command-stream chunk being generated: // + Raw-buffer SRD for the indirect argument data (4 DW) // + Structured-buffer SRD for the command parameter data (4 DW) // + Typed buffer SRD for the user-data entry mapping table for each shader stage (4 DW) // + Structured-buffer SRD for the pipeline signature (4 DW) // + Structured-buffer SRD for the second pipeline signature (4 DW) // + Constant buffer SRD for the command-generator properties (4 DW) // + Constant buffer SRD for the properties of the ExecuteIndirect() invocation (4 DW) // + GPU address of the memory containing the count of commands to generate (2 DW) // + Issue THREAD_TRACE_MARKER after draw or dispatch (1 DW) // + Task Shader Enabled flag (1 DW) constexpr uint32 SrdDwords = 4; PAL_ASSERT(m_pDevice->Parent()->ChipProperties().srdSizes.bufferView == (sizeof(uint32) * SrdDwords)); const bool taskShaderEnabled = ((generator.Type() == GeneratorType::DispatchMesh) && (static_cast<const GraphicsPipeline*>(pPipeline)->HasTaskShader())); // The generation pipelines expect the descriptor table's GPU address to be written to user-data #0-1. gpusize tableGpuAddr = 0uLL; uint32* pTableMem = pCmdBuffer->CmdAllocateEmbeddedData(((7 * SrdDwords) + 4), 1, &tableGpuAddr); PAL_ASSERT(pTableMem != nullptr); pCmdBuffer->CmdSetUserData(PipelineBindPoint::Compute, 0, 2, reinterpret_cast<uint32*>(&tableGpuAddr)); // Raw-buffer SRD for the indirect-argument data: BufferViewInfo viewInfo = { }; viewInfo.gpuAddr = argsGpuAddr; viewInfo.swizzledFormat = UndefinedSwizzledFormat; viewInfo.range = (generator.Properties().argBufStride * maximumCount); viewInfo.stride = 1; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION>= 558 viewInfo.flags.bypassMallRead = TestAnyFlagSet(settings.rpmViewsBypassMall, Gfx10RpmViewsBypassMallOnRead); viewInfo.flags.bypassMallWrite = TestAnyFlagSet(settings.rpmViewsBypassMall, Gfx10RpmViewsBypassMallOnWrite); #endif m_pDevice->Parent()->CreateUntypedBufferViewSrds(1, &viewInfo, pTableMem); pTableMem += SrdDwords; // Structured-buffer SRD for the command parameter data: generator.PopulateParameterBuffer(pCmdBuffer, pPipeline, pTableMem); pTableMem += SrdDwords; // Typed-buffer SRD for the user-data entry mappings: generator.PopulateUserDataMappingBuffer(pCmdBuffer, pPipeline, pTableMem); pTableMem += SrdDwords; // Structured buffer SRD for the pipeline signature: generator.PopulateSignatureBuffer(pCmdBuffer, pPipeline, pTableMem); if (generator.Type() == GeneratorType::DispatchMesh) { // In the case of DispatchMesh, PopulateSignatureBuffer will allocate an additional SRD hence the increment. pTableMem += SrdDwords; } pTableMem += SrdDwords; // Constant buffer SRD for the command-generator properties: generator.PopulatePropertyBuffer(pCmdBuffer, pPipeline, pTableMem); pTableMem += SrdDwords; // Constant buffer SRD for the properties of the ExecuteIndirect() invocation: generator.PopulateInvocationBuffer(pCmdBuffer, pPipeline, taskShaderEnabled, argsGpuAddr, maximumCount, indexBufSize, pTableMem); pTableMem += SrdDwords; // GPU address of the memory containing the actual command count to generate: memcpy(pTableMem, &countGpuAddr, sizeof(countGpuAddr)); pTableMem += 2; const auto& platformSettings = m_pDevice->Parent()->GetPlatform()->PlatformSettings(); const bool sqttEnabled = ((platformSettings.gpuProfilerMode > GpuProfilerCounterAndTimingOnly) && Util::TestAnyFlagSet(platformSettings.gpuProfilerConfig.traceModeMask, GpuProfilerTraceSqtt)); const bool issueSqttMarkerEvent = (sqttEnabled | m_pDevice->Parent()->GetPlatform()->IsDevDriverProfilingEnabled()); // Flag to decide whether to issue THREAD_TRACE_MARKER following generated draw/dispatch commands. pTableMem[0] = issueSqttMarkerEvent; pTableMem[1] = taskShaderEnabled; uint32 commandIdOffset = 0; while (commandIdOffset < maximumCount) { // Obtain a command-stream chunk for generating commands into. This also sets-up the padding requirements // for the chunk and determines the number of commands which will safely fit. We'll need to build a raw- // buffer SRD so the shader can access the command buffer as a UAV. ChunkOutput output[2] = {}; const uint32 numChunks = (taskShaderEnabled) ? 2 : 1; pCmdBuffer->GetChunkForCmdGeneration(generator, *pPipeline, (maximumCount - commandIdOffset), numChunks, output); ChunkOutput& mainChunk = output[0]; ppChunkLists[0][*pNumGenChunks] = mainChunk.pChunk; // The command generation pipeline also expects the following descriptor-table layout for the resources // which change between each command-stream chunk being generated: // + Raw buffer UAV SRD for the command-stream chunk to generate (4 DW) // + Raw buffer UAV SRD for the embedded data segment to use for the spill table (4 DW) // + Command ID offset for the current command-stream-chunk (1 DW) // + Low half of the GPU virtual address of the spill table's embedded data segment (1 DW) // The generation pipelines expect the descriptor table's GPU address to be written to user-data #2-3. pTableMem = pCmdBuffer->CmdAllocateEmbeddedData(((2 * SrdDwords) + 2), 1, &tableGpuAddr); PAL_ASSERT(pTableMem != nullptr); pCmdBuffer->CmdSetUserData(PipelineBindPoint::Compute, 2, 2, reinterpret_cast<uint32*>(&tableGpuAddr)); // UAV buffer SRD for the command-stream-chunk to generate: viewInfo.gpuAddr = mainChunk.pChunk->GpuVirtAddr(); viewInfo.swizzledFormat = UndefinedSwizzledFormat; viewInfo.range = (mainChunk.commandsInChunk * generator.CmdBufStride(pPipeline)); viewInfo.stride = 1; m_pDevice->Parent()->CreateUntypedBufferViewSrds(1, &viewInfo, pTableMem); pTableMem += SrdDwords; // UAV buffer SRD for the embedded-data spill table: if (mainChunk.embeddedDataSize != 0) { viewInfo.gpuAddr = mainChunk.embeddedDataAddr; viewInfo.swizzledFormat = UndefinedSwizzledFormat; viewInfo.range = (sizeof(uint32) * mainChunk.embeddedDataSize); viewInfo.stride = 1; m_pDevice->Parent()->CreateUntypedBufferViewSrds(1, &viewInfo, pTableMem); } else { // If we're not using the embedded-data spill table, we still need to clear the srd to 0. // This prevents hangs on older hardware caused by the shader attempting to read an invalid srd. memset(pTableMem, 0, (sizeof(uint32) * SrdDwords)); } pTableMem += SrdDwords; // Command ID offset for the current command stream-chunk pTableMem[0] = commandIdOffset; // Low portion of the spill table's GPU virtual address pTableMem[1] = LowPart(mainChunk.embeddedDataAddr); // The command generation pipeline also expects the following descriptor-table layout for the resources // which change between each command-stream chunk being generated: // + Raw buffer UAV SRD for the command-stream chunk to generate (4 DW) // + Raw buffer UAV SRD for the embedded data segment to use for the spill table (4 DW) if (taskShaderEnabled) { ChunkOutput& taskChunk = output[1]; ppChunkLists[1][*pNumGenChunks] = taskChunk.pChunk; // This assert validates that the following dispatch contains equivalent commands for both the DE and ACE // engines for this DispatchMesh pipeline. PAL_ASSERT(taskChunk.commandsInChunk == mainChunk.commandsInChunk); pTableMem = pCmdBuffer->CmdAllocateEmbeddedData((2 * SrdDwords), 1, &tableGpuAddr); PAL_ASSERT(pTableMem != nullptr); pCmdBuffer->CmdSetUserData(PipelineBindPoint::Compute, 4, 2, reinterpret_cast<uint32*>(&tableGpuAddr)); // UAV buffer SRD for the command-stream-chunk to generate: viewInfo.gpuAddr = taskChunk.pChunk->GpuVirtAddr(); viewInfo.swizzledFormat = UndefinedSwizzledFormat; viewInfo.range = (taskChunk.commandsInChunk * generator.CmdBufStride(pPipeline)); viewInfo.stride = 1; m_pDevice->Parent()->CreateUntypedBufferViewSrds(1, &viewInfo, pTableMem); pTableMem += SrdDwords; // UAV buffer SRD for the embedded-data spill table: viewInfo.gpuAddr = taskChunk.embeddedDataAddr; viewInfo.swizzledFormat = UndefinedSwizzledFormat; viewInfo.range = (sizeof(uint32) * taskChunk.embeddedDataSize); viewInfo.stride = 1; m_pDevice->Parent()->CreateUntypedBufferViewSrds(1, &viewInfo, pTableMem); pTableMem += SrdDwords; } pCmdBuffer->CmdDispatch(RpmUtil::MinThreadGroups(generator.ParameterCount(), threadsPerGroup[0]), RpmUtil::MinThreadGroups(mainChunk.commandsInChunk, threadsPerGroup[1]), 1); (*pNumGenChunks)++; commandIdOffset += mainChunk.commandsInChunk; } pCmdBuffer->CmdRestoreComputeState(ComputeStatePipelineAndUserData); } // ===================================================================================================================== // Resolves a multisampled depth-stencil source Image into the single-sampled destination Image using a pixel shader. void RsrcProcMgr::ResolveImageGraphics( GfxCmdBuffer* pCmdBuffer, const Image& srcImage, ImageLayout srcImageLayout, const Image& dstImage, ImageLayout dstImageLayout, uint32 regionCount, const ImageResolveRegion* pRegions, uint32 flags ) const { PAL_ASSERT(pCmdBuffer->IsGraphicsSupported()); // Don't expect GFX Blts on Nested unless targets not inherited. PAL_ASSERT((pCmdBuffer->IsNested() == false) || (static_cast<UniversalCmdBuffer*>( pCmdBuffer)->GetGraphicsState().inheritedState.stateFlags.targetViewState == 0)); const auto& device = *m_pDevice->Parent(); const auto& dstCreateInfo = dstImage.GetImageCreateInfo(); const auto& srcCreateInfo = srcImage.GetImageCreateInfo(); const auto& srcImageInfo = srcImage.GetImageInfo(); LateExpandResolveSrc(pCmdBuffer, srcImage, srcImageLayout, pRegions, regionCount, srcImageInfo.resolveMethod); // This path only works on depth-stencil images. PAL_ASSERT((srcCreateInfo.usageFlags.depthStencil && dstCreateInfo.usageFlags.depthStencil) || (Formats::IsDepthStencilOnly(srcCreateInfo.swizzledFormat.format) && Formats::IsDepthStencilOnly(dstCreateInfo.swizzledFormat.format))); const StencilRefMaskParams stencilRefMasks = { 0xFF, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0x01, 0xFF, }; // Initialize some structures we will need later on. ViewportParams viewportInfo = { }; viewportInfo.count = 1; viewportInfo.viewports[0].minDepth = 0.f; viewportInfo.viewports[0].maxDepth = 1.f; viewportInfo.viewports[0].origin = PointOrigin::UpperLeft; viewportInfo.horzClipRatio = FLT_MAX; viewportInfo.horzDiscardRatio = 1.0f; viewportInfo.vertClipRatio = FLT_MAX; viewportInfo.vertDiscardRatio = 1.0f; viewportInfo.depthRange = DepthRange::ZeroToOne; ScissorRectParams scissorInfo = { }; scissorInfo.count = 1; const DepthStencilViewInternalCreateInfo noDepthViewInfoInternal = { }; DepthStencilViewCreateInfo depthViewInfo = { }; depthViewInfo.pImage = &dstImage; depthViewInfo.arraySize = 1; // Save current command buffer state and bind graphics state which is common for all regions. pCmdBuffer->PushGraphicsState(); BindCommonGraphicsState(pCmdBuffer); pCmdBuffer->CmdBindMsaaState(GetMsaaState(dstCreateInfo.samples, dstCreateInfo.fragments)); pCmdBuffer->CmdSetStencilRefMasks(stencilRefMasks); // Put ImageResolveInvertY value in user data 0 used by VS. pCmdBuffer->CmdSetUserData(PipelineBindPoint::Graphics, 0, 1, &flags); // Determine which format we should use to view the source image. The initial value is the stencil format. SwizzledFormat srcFormat = { ChNumFormat::Undefined, { ChannelSwizzle::X, ChannelSwizzle::Zero, ChannelSwizzle::Zero, ChannelSwizzle::One }, }; // Each region needs to be resolved individually. for (uint32 idx = 0; idx < regionCount; ++idx) { // Same sanity checks of the region planes. #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 const bool isDepth = (pRegions[idx].dstAspect == ImageAspect::Depth); PAL_ASSERT(((pRegions[idx].srcAspect == ImageAspect::Depth) || (pRegions[idx].srcAspect == ImageAspect::Stencil)) && (pRegions[idx].srcAspect == pRegions[idx].dstAspect)); #else const bool isDepth = dstImage.IsDepthPlane(pRegions[idx].dstPlane); PAL_ASSERT((srcImage.IsDepthPlane(pRegions[idx].srcPlane) || srcImage.IsStencilPlane(pRegions[idx].srcPlane)) && (pRegions[idx].srcPlane == pRegions[idx].dstPlane)); #endif // This path can't reinterpret the resolve format. const SubresId dstStartSubres = { #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 pRegions[idx].dstAspect, #else pRegions[idx].dstPlane, #endif pRegions[idx].dstMipLevel, pRegions[idx].dstSlice }; PAL_ASSERT(Formats::IsUndefined(pRegions[idx].swizzledFormat.format) || (dstImage.SubresourceInfo(dstStartSubres)->format.format == pRegions[idx].swizzledFormat.format)); BindTargetParams bindTargetsInfo = { }; if (isDepth) { if ((srcCreateInfo.swizzledFormat.format == ChNumFormat::D32_Float_S8_Uint) || Formats::ShareChFmt(srcCreateInfo.swizzledFormat.format, ChNumFormat::X32_Float)) { srcFormat.format = ChNumFormat::X32_Float; } else { srcFormat.format = ChNumFormat::X16_Unorm; } bindTargetsInfo.depthTarget.depthLayout = dstImageLayout; pCmdBuffer->CmdBindPipeline({ PipelineBindPoint::Graphics, GetGfxPipeline(ResolveDepth), InternalApiPsoHash, }); pCmdBuffer->CmdBindDepthStencilState(m_pDepthResolveState); } else { srcFormat.format = ChNumFormat::X8_Uint; bindTargetsInfo.depthTarget.stencilLayout = dstImageLayout; pCmdBuffer->CmdBindPipeline({ PipelineBindPoint::Graphics, GetGfxPipeline(ResolveStencil), InternalApiPsoHash, }); pCmdBuffer->CmdBindDepthStencilState(m_pStencilResolveState); } // Setup the viewport and scissor to restrict rendering to the destination region being copied. viewportInfo.viewports[0].originX = static_cast<float>(pRegions[idx].dstOffset.x); viewportInfo.viewports[0].originY = static_cast<float>(pRegions[idx].dstOffset.y); viewportInfo.viewports[0].width = static_cast<float>(pRegions[idx].extent.width); viewportInfo.viewports[0].height = static_cast<float>(pRegions[idx].extent.height); scissorInfo.scissors[0].offset.x = pRegions[idx].dstOffset.x; scissorInfo.scissors[0].offset.y = pRegions[idx].dstOffset.y; scissorInfo.scissors[0].extent.width = pRegions[idx].extent.width; scissorInfo.scissors[0].extent.height = pRegions[idx].extent.height; // The shader will calculate src coordinates by adding a delta to the dst coordinates. The user data should // contain those deltas which are (srcOffset-dstOffset) for X & Y. const int32 xOffset = (pRegions[idx].srcOffset.x - pRegions[idx].dstOffset.x); const int32 yOffset = (pRegions[idx].srcOffset.y - pRegions[idx].dstOffset.y); const uint32 userData[3] = { reinterpret_cast<const uint32&>(xOffset), reinterpret_cast<const uint32&>(yOffset), }; pCmdBuffer->CmdSetViewports(viewportInfo); pCmdBuffer->CmdSetScissorRects(scissorInfo); pCmdBuffer->CmdSetUserData(PipelineBindPoint::Graphics, 2, 2, userData); for (uint32 slice = 0; slice < pRegions[idx].numSlices; ++slice) { LinearAllocatorAuto<VirtualLinearAllocator> sliceAlloc(pCmdBuffer->Allocator(), false); #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 const SubresId srcSubres = { pRegions[idx].srcAspect, 0, pRegions[idx].srcSlice + slice }; const SubresId dstSubres = { pRegions[idx].dstAspect, pRegions[idx].dstMipLevel, pRegions[idx].dstSlice + slice }; #else const SubresId srcSubres = { pRegions[idx].srcPlane, 0, pRegions[idx].srcSlice + slice }; const SubresId dstSubres = { pRegions[idx].dstPlane, pRegions[idx].dstMipLevel, pRegions[idx].dstSlice + slice }; #endif // Create an embedded user-data table and bind it to user data 1. We only need one image view. uint32* pSrdTable = RpmUtil::CreateAndBindEmbeddedUserData(pCmdBuffer, SrdDwordAlignment(), SrdDwordAlignment(), PipelineBindPoint::Graphics, 1); // Populate the table with an image view of the source image. ImageViewInfo imageView = { }; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 const SubresRange viewRange = { srcSubres, 1, 1 }; #else const SubresRange viewRange = { srcSubres, 1, 1, 1 }; #endif RpmUtil::BuildImageViewInfo(&imageView, srcImage, viewRange, srcFormat, srcImageLayout, device.TexOptLevel()); device.CreateImageViewSrds(1, &imageView, pSrdTable); // Create and bind a depth stencil view of the destination region. depthViewInfo.baseArraySlice = dstSubres.arraySlice; depthViewInfo.mipLevel = dstSubres.mipLevel; void* pDepthStencilViewMem = PAL_MALLOC(m_pDevice->GetDepthStencilViewSize(nullptr), &sliceAlloc, AllocInternalTemp); if (pDepthStencilViewMem == nullptr) { pCmdBuffer->NotifyAllocFailure(); } else { IDepthStencilView* pDepthView = nullptr; Result result = m_pDevice->CreateDepthStencilView(depthViewInfo, noDepthViewInfoInternal, pDepthStencilViewMem, &pDepthView); PAL_ASSERT(result == Result::Success); bindTargetsInfo.depthTarget.pDepthStencilView = pDepthView; pCmdBuffer->CmdBindTargets(bindTargetsInfo); // Draw a fullscreen quad. pCmdBuffer->CmdDraw(0, 3, 0, 1, 0); // Unbind the depth view and destroy it. bindTargetsInfo.depthTarget.pDepthStencilView = nullptr; pCmdBuffer->CmdBindTargets(bindTargetsInfo); PAL_SAFE_FREE(pDepthStencilViewMem, &sliceAlloc); } } // End for each slice. } // End for each region. // Restore original command buffer state. pCmdBuffer->PopGraphicsState(); FixupLateExpandResolveSrc(pCmdBuffer, srcImage, srcImageLayout, pRegions, regionCount, srcImageInfo.resolveMethod); } // ===================================================================================================================== // Resolves a multisampled source Image into the single-sampled destination Image using a compute shader. void RsrcProcMgr::ResolveImageCompute( GfxCmdBuffer* pCmdBuffer, const Image& srcImage, ImageLayout srcImageLayout, const Image& dstImage, ImageLayout dstImageLayout, ResolveMode resolveMode, uint32 regionCount, const ImageResolveRegion* pRegions, ResolveMethod method, uint32 flags ) const { const auto& device = *m_pDevice->Parent(); LateExpandResolveSrc(pCmdBuffer, srcImage, srcImageLayout, pRegions, regionCount, method); // Save the command buffer's state. pCmdBuffer->CmdSaveComputeState(ComputeStatePipelineAndUserData); // Basic resolves need one slot per region per image, FMask resolves need a third slot for the source Image's FMask. const bool isCsFmask = (method.shaderCsFmask == 1); const uint32 numSlots = isCsFmask ? 3 : 2; // Execute the Resolve for each region in the specified list. for (uint32 idx = 0; idx < regionCount; ++idx) { // Select a Resolve shader based on the source Image's sample-count and resolve method. const ComputePipeline*const pPipeline = GetCsResolvePipeline(srcImage, #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 pRegions[idx].srcAspect, #else pRegions[idx].srcPlane, #endif resolveMode, method); uint32 threadsPerGroup[3] = {}; pPipeline->ThreadsPerGroupXyz(&threadsPerGroup[0], &threadsPerGroup[1], &threadsPerGroup[2]); // Bind the pipeline. pCmdBuffer->CmdBindPipeline({ PipelineBindPoint::Compute, pPipeline, InternalApiPsoHash, }); // Set both subresources to the first slice of the required mip level #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 const SubresId srcSubres = { pRegions[idx].srcAspect, 0, pRegions[idx].srcSlice }; const SubresId dstSubres = { pRegions[idx].dstAspect, pRegions[idx].dstMipLevel, pRegions[idx].dstSlice }; #else const SubresId srcSubres = { pRegions[idx].srcPlane, 0, pRegions[idx].srcSlice }; const SubresId dstSubres = { pRegions[idx].dstPlane, pRegions[idx].dstMipLevel, pRegions[idx].dstSlice }; #endif SwizzledFormat srcFormat = srcImage.SubresourceInfo(srcSubres)->format; SwizzledFormat dstFormat = dstImage.SubresourceInfo(dstSubres)->format; // Override the formats with the caller's "reinterpret" format. if ((Formats::IsUndefined(pRegions[idx].swizzledFormat.format) == false) && (Formats::IsUndefined(pRegions[idx].swizzledFormat.format) == false)) { // We require that the channel formats match. PAL_ASSERT(Formats::ShareChFmt(srcFormat.format, pRegions[idx].swizzledFormat.format)); PAL_ASSERT(Formats::ShareChFmt(dstFormat.format, pRegions[idx].swizzledFormat.format)); // If the specified format exactly matches the image formats the resolve will always work. Otherwise, the // images must support format replacement. PAL_ASSERT(Formats::HaveSameNumFmt(srcFormat.format, pRegions[idx].swizzledFormat.format) || srcImage.GetGfxImage()->IsFormatReplaceable(srcSubres, srcImageLayout, false)); PAL_ASSERT(Formats::HaveSameNumFmt(dstFormat.format, pRegions[idx].swizzledFormat.format) || dstImage.GetGfxImage()->IsFormatReplaceable(dstSubres, dstImageLayout, true)); srcFormat.format = pRegions[idx].swizzledFormat.format; dstFormat.format = pRegions[idx].swizzledFormat.format; } // Store the necessary region independent user data values in slots 1-4. Shader expects the following layout: // 1 - Num Samples // 2 - Gamma correction option (1 if the destination format is SRGB, 0 otherwise) // 3 - Copy sample 0 (single sample) flag. (1 for integer formats, 0 otherwise). For DS images this flag // is 1 if resolve mode is set as average. // 4 - Y-invert const uint32 imageData[4] = { srcImage.GetImageCreateInfo().samples, Formats::IsSrgb(dstFormat.format), #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 ((pRegions[idx].srcAspect == ImageAspect::Stencil) ? (resolveMode == ResolveMode::Average) : (Formats::IsSint(srcFormat.format) || Formats::IsUint(srcFormat.format))), #else (srcImage.IsStencilPlane(pRegions[idx].srcPlane) ? (resolveMode == ResolveMode::Average) : (Formats::IsSint(srcFormat.format) || Formats::IsUint(srcFormat.format))), #endif TestAnyFlagSet(flags, ImageResolveInvertY), }; pCmdBuffer->CmdSetUserData(PipelineBindPoint::Compute, 1, 4, &imageData[0]); // The hardware can't handle UAV stores using SRGB num format. The resolve shaders already contain a // linear-to-gamma conversion, but in order for that to work the output UAV's num format must be patched to be // simple unorm. if (Formats::IsSrgb(dstFormat.format)) { dstFormat.format = Formats::ConvertToUnorm(dstFormat.format); } // The shader expects the following layout for the embedded user-data constants. // Src Offset X, Src Y offset, Resolve width, Resolve height // Dst Offset X, Dst Y offset const uint32 regionData[6] = { static_cast<uint32>(pRegions[idx].srcOffset.x), static_cast<uint32>(pRegions[idx].srcOffset.y), pRegions[idx].extent.width, pRegions[idx].extent.height, static_cast<uint32>(pRegions[idx].dstOffset.x), static_cast<uint32>(pRegions[idx].dstOffset.y) }; // Create an embedded user-data table and bind it to user data 0. We need image views for the src and dst // subresources, as well as some inline constants for the resolve offsets and extents. const uint32 DataDwords = NumBytesToNumDwords(sizeof(regionData)); uint32* pUserData = RpmUtil::CreateAndBindEmbeddedUserData(pCmdBuffer, SrdDwordAlignment() * numSlots + DataDwords, SrdDwordAlignment(), PipelineBindPoint::Compute, 0); ImageViewInfo imageView[2] = {}; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 SubresRange viewRange = { dstSubres, 1, pRegions[idx].numSlices }; #else SubresRange viewRange = { dstSubres, 1, 1, pRegions[idx].numSlices }; #endif PAL_ASSERT(TestAnyFlagSet(dstImageLayout.usages, LayoutResolveDst) == true); // ResolveDst doesn't imply ShaderWrite, but it's safe because it's always uncompressed ImageLayout dstLayoutCompute = dstImageLayout; dstLayoutCompute.usages |= LayoutShaderWrite; // Destination image is at the beginning of pUserData. RpmUtil::BuildImageViewInfo(&imageView[0], dstImage, viewRange, dstFormat, dstLayoutCompute, device.TexOptLevel()); viewRange.startSubres = srcSubres; RpmUtil::BuildImageViewInfo(&imageView[1], srcImage, viewRange, srcFormat, srcImageLayout, device.TexOptLevel()); device.CreateImageViewSrds(2, &imageView[0], pUserData); pUserData += SrdDwordAlignment() * 2; if (isCsFmask) { // If this is an Fmask-accelerated Resolve, create a third image view of the source Image's Fmask surface. FmaskViewInfo fmaskView = {}; fmaskView.pImage = &srcImage; fmaskView.baseArraySlice = pRegions[idx].srcSlice; fmaskView.arraySize = pRegions[idx].numSlices; m_pDevice->Parent()->CreateFmaskViewSrds(1, &fmaskView, pUserData); pUserData += SrdDwordAlignment(); } // Copy the user-data values into the descriptor table memory memcpy(pUserData, &regionData[0], sizeof(regionData)); // Execute the dispatch. Resolves can only be done on 2D images so the Z dimension of the dispatch is always 1. pCmdBuffer->CmdDispatch(RpmUtil::MinThreadGroups(pRegions[idx].extent.width, threadsPerGroup[0]), RpmUtil::MinThreadGroups(pRegions[idx].extent.height, threadsPerGroup[1]), RpmUtil::MinThreadGroups(pRegions[idx].numSlices, threadsPerGroup[2])); } // Restore the command buffer's state. pCmdBuffer->CmdRestoreComputeState(ComputeStatePipelineAndUserData); if (dstImage.GetGfxImage()->HasHtileData()) { bool performedResummarizeHtileCompute = false; for (uint32 i = 0; i < regionCount; ++i) { const ImageResolveRegion& curRegion = pRegions[i]; SubresRange subresRange = {}; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 subresRange.startSubres.aspect = curRegion.dstAspect; #else subresRange.startSubres.plane = curRegion.dstPlane; #endif subresRange.startSubres.mipLevel = curRegion.dstMipLevel; subresRange.startSubres.arraySlice = curRegion.dstSlice; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 642 subresRange.numPlanes = 1; #endif subresRange.numMips = 1; subresRange.numSlices = curRegion.numSlices; HwlResummarizeHtileCompute(pCmdBuffer, *dstImage.GetGfxImage(), subresRange); performedResummarizeHtileCompute = true; } // Add the barrier if a ResummarizeHtileCompute was performed. if (performedResummarizeHtileCompute) { // There is a potential problem here because the htile is shared between // the depth and stencil planes, but the APIs manage the state of those // planes independently. At this point in the code, we know the depth // plane must be in a state that supports being a resolve destination, // but the stencil plane may still be in a state that supports stencil // target rendering. Since we are modifying HTILE asynchronously with // respect to the DB and through a different data path than the DB, we // need to ensure our CS won't overlap with subsequent stencil rendering // and that our HTILE updates are immediately visible to the DB. BarrierInfo hiZExpandBarrier = {}; hiZExpandBarrier.waitPoint = HwPipePreCs; constexpr HwPipePoint PostCs = HwPipePostCs; hiZExpandBarrier.pipePointWaitCount = 1; hiZExpandBarrier.pPipePoints = &PostCs; BarrierTransition transition = {}; transition.srcCacheMask = CoherShader; transition.dstCacheMask = CoherShader | CoherDepthStencilTarget; hiZExpandBarrier.pTransitions = &transition; pCmdBuffer->CmdBarrier(hiZExpandBarrier); } } FixupLateExpandResolveSrc(pCmdBuffer, srcImage, srcImageLayout, pRegions, regionCount, method); } // ===================================================================================================================== // Selects a compute Resolve pipeline based on the properties of the given Image and resolve method. const ComputePipeline* RsrcProcMgr::GetCsResolvePipeline( const Image& srcImage, #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 ImageAspect aspect, #else uint32 plane, #endif ResolveMode mode, ResolveMethod method ) const { const ComputePipeline* pPipeline = nullptr; const auto& createInfo = srcImage.GetImageCreateInfo(); #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 const bool isStencil = (aspect == ImageAspect::Stencil); #else const bool isStencil = srcImage.IsStencilPlane(plane); #endif // If the sample and fragment counts are different then this must be an EQAA resolve. if (createInfo.samples != createInfo.fragments) { PAL_ASSERT(method.shaderCsFmask == 1); switch (createInfo.fragments) { case 1: pPipeline = GetPipeline(RpmComputePipeline::MsaaFmaskResolve1xEqaa); break; case 2: switch (mode) { case ResolveMode::Average: pPipeline = GetPipeline(RpmComputePipeline::MsaaFmaskResolve2xEqaa); break; case ResolveMode::Minimum: pPipeline = GetPipeline(RpmComputePipeline::MsaaFmaskResolve2xEqaaMin); break; case ResolveMode::Maximum: pPipeline = GetPipeline(RpmComputePipeline::MsaaFmaskResolve2xEqaaMax); break; default: pPipeline = GetPipeline(RpmComputePipeline::MsaaFmaskResolve2xEqaa); PAL_NEVER_CALLED(); break; } break; case 4: switch (mode) { case ResolveMode::Average: pPipeline = GetPipeline(RpmComputePipeline::MsaaFmaskResolve4xEqaa); break; case ResolveMode::Minimum: pPipeline = GetPipeline(RpmComputePipeline::MsaaFmaskResolve4xEqaaMin); break; case ResolveMode::Maximum: pPipeline = GetPipeline(RpmComputePipeline::MsaaFmaskResolve4xEqaaMax); break; default: pPipeline = GetPipeline(RpmComputePipeline::MsaaFmaskResolve4xEqaa); PAL_NEVER_CALLED(); break; } break; case 8: switch (mode) { case ResolveMode::Average: pPipeline = GetPipeline(RpmComputePipeline::MsaaFmaskResolve8xEqaa); break; case ResolveMode::Minimum: pPipeline = GetPipeline(RpmComputePipeline::MsaaFmaskResolve8xEqaaMin); break; case ResolveMode::Maximum: pPipeline = GetPipeline(RpmComputePipeline::MsaaFmaskResolve8xEqaaMax); break; default: pPipeline = GetPipeline(RpmComputePipeline::MsaaFmaskResolve8xEqaa); PAL_NEVER_CALLED(); break; } break; default: PAL_NEVER_CALLED(); break; } } else if ((method.shaderCs == 1) && (method.shaderCsFmask == 0)) { // A regular MSAA color image resolve shader is used for DS resolve as well. By setting the // "copy sample zero" flag to 1, we force the shader to simply copy the first sample (sample 0). switch (createInfo.samples) { case 2: switch (mode) { case ResolveMode::Average: pPipeline = GetPipeline(RpmComputePipeline::MsaaResolve2x); break; case ResolveMode::Minimum: pPipeline = isStencil ? GetPipeline(RpmComputePipeline::MsaaResolveStencil2xMin) : GetPipeline(RpmComputePipeline::MsaaResolve2xMin); break; case ResolveMode::Maximum: pPipeline = isStencil ? GetPipeline(RpmComputePipeline::MsaaResolveStencil2xMax) : GetPipeline(RpmComputePipeline::MsaaResolve2xMax); break; default: pPipeline = GetPipeline(RpmComputePipeline::MsaaResolve2x); PAL_NEVER_CALLED(); break; } break; case 4: switch (mode) { case ResolveMode::Average: pPipeline = GetPipeline(RpmComputePipeline::MsaaResolve4x); break; case ResolveMode::Minimum: pPipeline = isStencil ? GetPipeline(RpmComputePipeline::MsaaResolveStencil4xMin) : GetPipeline(RpmComputePipeline::MsaaResolve4xMin); break; case ResolveMode::Maximum: pPipeline = isStencil ? GetPipeline(RpmComputePipeline::MsaaResolveStencil4xMax) : GetPipeline(RpmComputePipeline::MsaaResolve4xMax); break; default: pPipeline = GetPipeline(RpmComputePipeline::MsaaResolve4x); PAL_NEVER_CALLED(); break; } break; case 8: switch (mode) { case ResolveMode::Average: pPipeline = GetPipeline(RpmComputePipeline::MsaaResolve8x); break; case ResolveMode::Minimum: pPipeline = isStencil ? GetPipeline(RpmComputePipeline::MsaaResolveStencil8xMin) : GetPipeline(RpmComputePipeline::MsaaResolve8xMin); break; case ResolveMode::Maximum: pPipeline = isStencil ? GetPipeline(RpmComputePipeline::MsaaResolveStencil8xMax) : GetPipeline(RpmComputePipeline::MsaaResolve8xMax); break; default: pPipeline = GetPipeline(RpmComputePipeline::MsaaResolve8x); PAL_NEVER_CALLED(); break; } break; default: PAL_NEVER_CALLED(); break; } } else { switch (createInfo.samples) { case 2: switch (mode) { case ResolveMode::Average: pPipeline = GetPipeline(RpmComputePipeline::MsaaFmaskResolve2x); break; case ResolveMode::Minimum: pPipeline = GetPipeline(RpmComputePipeline::MsaaFmaskResolve2xMin); break; case ResolveMode::Maximum: pPipeline = GetPipeline(RpmComputePipeline::MsaaFmaskResolve2xMax); break; default: pPipeline = GetPipeline(RpmComputePipeline::MsaaFmaskResolve2x); PAL_NEVER_CALLED(); break; } break; case 4: switch (mode) { case ResolveMode::Average: pPipeline = GetPipeline(RpmComputePipeline::MsaaFmaskResolve4x); break; case ResolveMode::Minimum: pPipeline = GetPipeline(RpmComputePipeline::MsaaFmaskResolve4xMin); break; case ResolveMode::Maximum: pPipeline = GetPipeline(RpmComputePipeline::MsaaFmaskResolve4xMax); break; default: pPipeline = GetPipeline(RpmComputePipeline::MsaaFmaskResolve4x); PAL_NEVER_CALLED(); break; } break; case 8: switch (mode) { case ResolveMode::Average: pPipeline = GetPipeline(RpmComputePipeline::MsaaFmaskResolve8x); break; case ResolveMode::Minimum: pPipeline = GetPipeline(RpmComputePipeline::MsaaFmaskResolve8xMin); break; case ResolveMode::Maximum: pPipeline = GetPipeline(RpmComputePipeline::MsaaFmaskResolve8xMax); break; default: pPipeline = GetPipeline(RpmComputePipeline::MsaaFmaskResolve8x); PAL_NEVER_CALLED(); break; } break; default: PAL_NEVER_CALLED(); break; } } PAL_ASSERT(pPipeline != nullptr); return pPipeline; } // ===================================================================================================================== // Performs a depth/stencil expand (decompress) on the provided image. bool RsrcProcMgr::ExpandDepthStencil( GfxCmdBuffer* pCmdBuffer, const Image& image, const IMsaaState* pMsaaState, const MsaaQuadSamplePattern* pQuadSamplePattern, const SubresRange& range ) const { #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 642 PAL_ASSERT(range.numPlanes == 1); #endif PAL_ASSERT(image.IsDepthStencilTarget()); PAL_ASSERT(pCmdBuffer->IsGraphicsSupported()); // Don't expect GFX Blts on Nested unless targets not inherited. PAL_ASSERT((pCmdBuffer->IsNested() == false) || (static_cast<UniversalCmdBuffer*>( pCmdBuffer)->GetGraphicsState().inheritedState.stateFlags.targetViewState == 0)); const StencilRefMaskParams stencilRefMasks = { 0xFF, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0x01, 0xFF }; ViewportParams viewportInfo = { }; viewportInfo.count = 1; viewportInfo.viewports[0].originX = 0; viewportInfo.viewports[0].originY = 0; viewportInfo.viewports[0].minDepth = 0.f; viewportInfo.viewports[0].maxDepth = 1.f; viewportInfo.viewports[0].origin = PointOrigin::UpperLeft; viewportInfo.horzClipRatio = FLT_MAX; viewportInfo.horzDiscardRatio = 1.0f; viewportInfo.vertClipRatio = FLT_MAX; viewportInfo.vertDiscardRatio = 1.0f; viewportInfo.depthRange = DepthRange::ZeroToOne; ScissorRectParams scissorInfo = { }; scissorInfo.count = 1; scissorInfo.scissors[0].offset.x = 0; scissorInfo.scissors[0].offset.y = 0; DepthStencilViewInternalCreateInfo depthViewInfoInternal = { }; depthViewInfoInternal.flags.isExpand = 1; DepthStencilViewCreateInfo depthViewInfo = { }; depthViewInfo.pImage = &image; depthViewInfo.arraySize = 1; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 if (range.startSubres.aspect == ImageAspect::Depth) #else if (image.IsDepthPlane(range.startSubres.plane)) #endif { depthViewInfo.flags.readOnlyStencil = 1; } else { depthViewInfo.flags.readOnlyDepth = 1; } BindTargetParams bindTargetsInfo = { }; bindTargetsInfo.depthTarget.pDepthStencilView = nullptr; bindTargetsInfo.depthTarget.depthLayout.usages = LayoutDepthStencilTarget; bindTargetsInfo.depthTarget.depthLayout.engines = LayoutUniversalEngine; bindTargetsInfo.depthTarget.stencilLayout.usages = LayoutDepthStencilTarget; bindTargetsInfo.depthTarget.stencilLayout.engines = LayoutUniversalEngine; // Save current command buffer state and bind graphics state which is common for all subresources. pCmdBuffer->PushGraphicsState(); pCmdBuffer->CmdBindPipeline({ PipelineBindPoint::Graphics, GetGfxPipeline(DepthExpand), InternalApiPsoHash, }); BindCommonGraphicsState(pCmdBuffer); pCmdBuffer->CmdBindDepthStencilState(m_pDepthExpandState); pCmdBuffer->CmdBindMsaaState(pMsaaState); if (pQuadSamplePattern != nullptr) { pCmdBuffer->CmdSetMsaaQuadSamplePattern(image.GetImageCreateInfo().samples, *pQuadSamplePattern); } pCmdBuffer->CmdSetStencilRefMasks(stencilRefMasks); RpmUtil::WriteVsZOut(pCmdBuffer, 1.0f); const uint32 lastMip = (range.startSubres.mipLevel + range.numMips - 1); const uint32 lastSlice = (range.startSubres.arraySlice + range.numSlices - 1); for (depthViewInfo.mipLevel = range.startSubres.mipLevel; depthViewInfo.mipLevel <= lastMip; ++depthViewInfo.mipLevel) { if (image.GetGfxImage()->CanMipSupportMetaData(depthViewInfo.mipLevel)) { LinearAllocatorAuto<VirtualLinearAllocator> mipAlloc(pCmdBuffer->Allocator(), false); #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 const SubresId mipSubres = { range.startSubres.aspect, depthViewInfo.mipLevel, 0 }; #else const SubresId mipSubres = { range.startSubres.plane, depthViewInfo.mipLevel, 0 }; #endif const auto& subResInfo = *image.SubresourceInfo(mipSubres); // All slices of the same mipmap level can re-use the same viewport/scissor state. viewportInfo.viewports[0].width = static_cast<float>(subResInfo.extentTexels.width); viewportInfo.viewports[0].height = static_cast<float>(subResInfo.extentTexels.height); scissorInfo.scissors[0].extent.width = subResInfo.extentTexels.width; scissorInfo.scissors[0].extent.height = subResInfo.extentTexels.height; pCmdBuffer->CmdSetViewports(viewportInfo); pCmdBuffer->CmdSetScissorRects(scissorInfo); for (depthViewInfo.baseArraySlice = range.startSubres.arraySlice; depthViewInfo.baseArraySlice <= lastSlice; ++depthViewInfo.baseArraySlice) { LinearAllocatorAuto<VirtualLinearAllocator> sliceAlloc(pCmdBuffer->Allocator(), false); // Create and bind a depth stencil view of the current subresource. IDepthStencilView* pDepthView = nullptr; void* pDepthViewMem = PAL_MALLOC(m_pDevice->GetDepthStencilViewSize(nullptr), &sliceAlloc, AllocInternalTemp); if (pDepthViewMem == nullptr) { pCmdBuffer->NotifyAllocFailure(); } else { Result result = m_pDevice->CreateDepthStencilView(depthViewInfo, depthViewInfoInternal, pDepthViewMem, &pDepthView); PAL_ASSERT(result == Result::Success); bindTargetsInfo.depthTarget.pDepthStencilView = pDepthView; pCmdBuffer->CmdBindTargets(bindTargetsInfo); // Draw a fullscreen quad. pCmdBuffer->CmdDraw(0, 3, 0, 1, 0); PAL_SAFE_FREE(pDepthViewMem, &sliceAlloc); // Unbind the depth view and destroy it. bindTargetsInfo.depthTarget.pDepthStencilView = nullptr; pCmdBuffer->CmdBindTargets(bindTargetsInfo); } } } } // Restore command buffer state. pCmdBuffer->PopGraphicsState(); // Compute path was not used return false; } // ===================================================================================================================== // Performs a depth/stencil resummarization on the provided image. This operation recalculates the HiZ range in the // htile based on the z-buffer values. void RsrcProcMgr::ResummarizeDepthStencil( GfxCmdBuffer* pCmdBuffer, const Image& image, ImageLayout imageLayout, const IMsaaState* pMsaaState, const MsaaQuadSamplePattern* pQuadSamplePattern, const SubresRange& range ) const { #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 642 PAL_ASSERT(range.numPlanes == 1); #endif PAL_ASSERT(image.IsDepthStencilTarget()); PAL_ASSERT(pCmdBuffer->IsGraphicsSupported()); // Don't expect GFX Blts on Nested unless targets not inherited. PAL_ASSERT((pCmdBuffer->IsNested() == false) || (static_cast<UniversalCmdBuffer*>( pCmdBuffer)->GetGraphicsState().inheritedState.stateFlags.targetViewState == 0)); const StencilRefMaskParams stencilRefMasks = { 0xFF, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0x01, 0xFF }; ViewportParams viewportInfo = { }; viewportInfo.count = 1; viewportInfo.viewports[0].originX = 0; viewportInfo.viewports[0].originY = 0; viewportInfo.viewports[0].minDepth = 0.f; viewportInfo.viewports[0].maxDepth = 1.f; viewportInfo.viewports[0].origin = PointOrigin::UpperLeft; viewportInfo.horzClipRatio = FLT_MAX; viewportInfo.horzDiscardRatio = 1.0f; viewportInfo.vertClipRatio = FLT_MAX; viewportInfo.vertDiscardRatio = 1.0f; viewportInfo.depthRange = DepthRange::ZeroToOne; ScissorRectParams scissorInfo = { }; scissorInfo.count = 1; scissorInfo.scissors[0].offset.x = 0; scissorInfo.scissors[0].offset.y = 0; const DepthStencilViewInternalCreateInfo depthViewInfoInternal = { }; DepthStencilViewCreateInfo depthViewInfo = { }; depthViewInfo.pImage = &image; depthViewInfo.arraySize = 1; depthViewInfo.flags.resummarizeHiZ = 1; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 if (range.startSubres.aspect == ImageAspect::Depth) #else if (image.IsDepthPlane(range.startSubres.plane)) #endif { depthViewInfo.flags.readOnlyStencil = 1; } else { depthViewInfo.flags.readOnlyDepth = 1; } BindTargetParams bindTargetsInfo = {}; bindTargetsInfo.depthTarget.pDepthStencilView = nullptr; bindTargetsInfo.depthTarget.depthLayout = imageLayout; bindTargetsInfo.depthTarget.stencilLayout = imageLayout; // Save current command buffer state and bind graphics state which is common for all subresources. pCmdBuffer->PushGraphicsState(); pCmdBuffer->CmdBindPipeline({ PipelineBindPoint::Graphics, GetGfxPipeline(DepthResummarize), InternalApiPsoHash, }); BindCommonGraphicsState(pCmdBuffer); pCmdBuffer->CmdBindDepthStencilState(m_pDepthResummarizeState); pCmdBuffer->CmdBindMsaaState(pMsaaState); if (pQuadSamplePattern != nullptr) { pCmdBuffer->CmdSetMsaaQuadSamplePattern(image.GetImageCreateInfo().samples, *pQuadSamplePattern); } pCmdBuffer->CmdSetStencilRefMasks(stencilRefMasks); RpmUtil::WriteVsZOut(pCmdBuffer, 1.0f); const uint32 lastMip = range.startSubres.mipLevel + range.numMips - 1; const uint32 lastSlice = range.startSubres.arraySlice + range.numSlices - 1; for (depthViewInfo.mipLevel = range.startSubres.mipLevel; depthViewInfo.mipLevel <= lastMip; ++depthViewInfo.mipLevel) { if (image.GetGfxImage()->CanMipSupportMetaData(depthViewInfo.mipLevel)) { LinearAllocatorAuto<VirtualLinearAllocator> mipAlloc(pCmdBuffer->Allocator(), false); #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 const SubresId mipSubres = { range.startSubres.aspect, depthViewInfo.mipLevel, 0 }; #else const SubresId mipSubres = { range.startSubres.plane, depthViewInfo.mipLevel, 0 }; #endif const auto& subResInfo = *image.SubresourceInfo(mipSubres); // All slices of the same mipmap level can re-use the same viewport/scissor state. viewportInfo.viewports[0].width = static_cast<float>(subResInfo.extentTexels.width); viewportInfo.viewports[0].height = static_cast<float>(subResInfo.extentTexels.height); scissorInfo.scissors[0].extent.width = subResInfo.extentTexels.width; scissorInfo.scissors[0].extent.height = subResInfo.extentTexels.height; pCmdBuffer->CmdSetViewports(viewportInfo); pCmdBuffer->CmdSetScissorRects(scissorInfo); for (depthViewInfo.baseArraySlice = range.startSubres.arraySlice; depthViewInfo.baseArraySlice <= lastSlice; ++depthViewInfo.baseArraySlice) { LinearAllocatorAuto<VirtualLinearAllocator> sliceAlloc(pCmdBuffer->Allocator(), false); // Create and bind a depth stencil view of the current subresource. IDepthStencilView* pDepthView = nullptr; void* pDepthViewMem = PAL_MALLOC(m_pDevice->GetDepthStencilViewSize(nullptr), &sliceAlloc, AllocInternalTemp); if (pDepthViewMem == nullptr) { pCmdBuffer->NotifyAllocFailure(); } else { Result result = m_pDevice->CreateDepthStencilView(depthViewInfo, depthViewInfoInternal, pDepthViewMem, &pDepthView); PAL_ASSERT(result == Result::Success); bindTargetsInfo.depthTarget.pDepthStencilView = pDepthView; pCmdBuffer->CmdBindTargets(bindTargetsInfo); // Draw a fullscreen quad. pCmdBuffer->CmdDraw(0, 3, 0, 1, 0); PAL_SAFE_FREE(pDepthViewMem, &sliceAlloc); // Unbind the depth view and destroy it. bindTargetsInfo.depthTarget.pDepthStencilView = nullptr; pCmdBuffer->CmdBindTargets(bindTargetsInfo); } } } } // Restore command buffer state. pCmdBuffer->PopGraphicsState(); } // ===================================================================================================================== // Executes a generic color blit which acts upon the specified color Image. If mipCondDwordsAddr is non-zero, it is the // GPU virtual address of an array of conditional DWORDs, one for each mip level in the image. RPM will use these // DWORDs to conditionally execute this blit on a per-mip basis. void RsrcProcMgr::GenericColorBlit( GfxCmdBuffer* pCmdBuffer, const Image& dstImage, const SubresRange& range, const IMsaaState& msaaState, const MsaaQuadSamplePattern* pQuadSamplePattern, RpmGfxPipeline pipeline, const GpuMemory* pGpuMemory, gpusize metaDataOffset ) const { #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 642 PAL_ASSERT(range.numPlanes == 1); #endif PAL_ASSERT(dstImage.IsRenderTarget()); PAL_ASSERT(pCmdBuffer->IsGraphicsSupported()); // Don't expect GFX Blts on Nested unless targets not inherited. PAL_ASSERT((pCmdBuffer->IsNested() == false) || (static_cast<UniversalCmdBuffer*>( pCmdBuffer)->GetGraphicsState().inheritedState.stateFlags.targetViewState == 0)); const auto& imageCreateInfo = dstImage.GetImageCreateInfo(); const bool is3dImage = (imageCreateInfo.imageType == ImageType::Tex3d); const bool isDecompress = ((pipeline == RpmGfxPipeline::DccDecompress) || (pipeline == RpmGfxPipeline::FastClearElim) || (pipeline == RpmGfxPipeline::FmaskDecompress)); ViewportParams viewportInfo = { }; viewportInfo.count = 1; viewportInfo.viewports[0].originX = 0; viewportInfo.viewports[0].originY = 0; viewportInfo.viewports[0].minDepth = 0.f; viewportInfo.viewports[0].maxDepth = 1.f; viewportInfo.viewports[0].origin = PointOrigin::UpperLeft; viewportInfo.horzClipRatio = FLT_MAX; viewportInfo.horzDiscardRatio = 1.0f; viewportInfo.vertClipRatio = FLT_MAX; viewportInfo.vertDiscardRatio = 1.0f; viewportInfo.depthRange = DepthRange::ZeroToOne; ScissorRectParams scissorInfo; scissorInfo.count = 1; scissorInfo.scissors[0].offset.x = 0; scissorInfo.scissors[0].offset.y = 0; ColorTargetViewInternalCreateInfo colorViewInfoInternal = { }; colorViewInfoInternal.flags.dccDecompress = (pipeline == RpmGfxPipeline::DccDecompress); colorViewInfoInternal.flags.fastClearElim = (pipeline == RpmGfxPipeline::FastClearElim); colorViewInfoInternal.flags.fmaskDecompress = (pipeline == RpmGfxPipeline::FmaskDecompress); ColorTargetViewCreateInfo colorViewInfo = { }; colorViewInfo.swizzledFormat = imageCreateInfo.swizzledFormat; colorViewInfo.imageInfo.pImage = &dstImage; colorViewInfo.imageInfo.arraySize = 1; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 colorViewInfo.imageInfo.baseSubRes.aspect = range.startSubres.aspect; #else colorViewInfo.imageInfo.baseSubRes.plane = range.startSubres.plane; #endif if (is3dImage) { colorViewInfo.zRange.extent = 1; colorViewInfo.flags.zRangeValid = 1; } BindTargetParams bindTargetsInfo = { }; bindTargetsInfo.colorTargets[0].pColorTargetView = nullptr; bindTargetsInfo.colorTargets[0].imageLayout.usages = LayoutColorTarget; bindTargetsInfo.colorTargets[0].imageLayout.engines = LayoutUniversalEngine; bindTargetsInfo.depthTarget.pDepthStencilView = nullptr; bindTargetsInfo.depthTarget.depthLayout.usages = LayoutDepthStencilTarget; bindTargetsInfo.depthTarget.depthLayout.engines = LayoutUniversalEngine; bindTargetsInfo.depthTarget.stencilLayout.usages = LayoutDepthStencilTarget; bindTargetsInfo.depthTarget.stencilLayout.engines = LayoutUniversalEngine; const StencilRefMaskParams stencilRefMasks = { 0xFF, 0xFF, 0xFF, 0x01, 0xFF, 0xFF, 0xFF, 0x01, 0xFF }; // Save current command buffer state and bind graphics state which is common for all mipmap levels. pCmdBuffer->PushGraphicsState(); pCmdBuffer->CmdBindPipeline({ PipelineBindPoint::Graphics, GetGfxPipeline(pipeline), InternalApiPsoHash, }); BindCommonGraphicsState(pCmdBuffer); SwizzledFormat swizzledFormat = {}; swizzledFormat.format = ChNumFormat::X8Y8Z8W8_Unorm; swizzledFormat.swizzle = { ChannelSwizzle::X, ChannelSwizzle::Y, ChannelSwizzle::Z, ChannelSwizzle::W }; pCmdBuffer->CmdOverwriteRbPlusFormatForBlits(swizzledFormat, 0); pCmdBuffer->CmdBindColorBlendState(m_pBlendDisableState); pCmdBuffer->CmdBindDepthStencilState(m_pDepthDisableState); pCmdBuffer->CmdBindMsaaState(&msaaState); if (pQuadSamplePattern != nullptr) { pCmdBuffer->CmdSetMsaaQuadSamplePattern(dstImage.GetImageCreateInfo().samples, *pQuadSamplePattern); } pCmdBuffer->CmdSetStencilRefMasks(stencilRefMasks); RpmUtil::WriteVsZOut(pCmdBuffer, 1.0f); const uint32 lastMip = (range.startSubres.mipLevel + range.numMips - 1); gpusize mipCondDwordsOffset = metaDataOffset; bool needDisablePredication = false; for (uint32 mip = range.startSubres.mipLevel; mip <= lastMip; ++mip) { // If this is a decompress operation of some sort, then don't bother continuing unless this // subresource supports expansion. if ((isDecompress == false) || (dstImage.GetGfxImage()->CanMipSupportMetaData(mip))) { // Use predication to skip this operation based on the image's conditional dwords. // We can only perform this optimization if the client is not currently using predication. if ((pCmdBuffer->GetGfxCmdBufState().flags.clientPredicate == 0) && (pGpuMemory != nullptr)) { // Set/Enable predication pCmdBuffer->CmdSetPredication(nullptr, 0, pGpuMemory, mipCondDwordsOffset, PredicateType::Boolean64, true, false, false); mipCondDwordsOffset += PredicationAlign; // Advance to the next mip's conditional meta-data. needDisablePredication = true; } #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 const SubresId mipSubres = { range.startSubres.aspect, mip, 0 }; #else const SubresId mipSubres = { range.startSubres.plane, mip, 0 }; #endif const auto& subResInfo = *dstImage.SubresourceInfo(mipSubres); // All slices of the same mipmap level can re-use the same viewport & scissor states. viewportInfo.viewports[0].width = static_cast<float>(subResInfo.extentTexels.width); viewportInfo.viewports[0].height = static_cast<float>(subResInfo.extentTexels.height); scissorInfo.scissors[0].extent.width = subResInfo.extentTexels.width; scissorInfo.scissors[0].extent.height = subResInfo.extentTexels.height; pCmdBuffer->CmdSetViewports(viewportInfo); pCmdBuffer->CmdSetScissorRects(scissorInfo); // We need to draw each array slice individually because we cannot select which array slice to render to // without a Geometry Shader. If this is a 3D Image, we need to include all slices for this mipmap level. const uint32 baseSlice = (is3dImage ? 0 : range.startSubres.arraySlice); const uint32 numSlices = (is3dImage ? subResInfo.extentTexels.depth : range.numSlices); const uint32 lastSlice = baseSlice + numSlices - 1; for (uint32 arraySlice = baseSlice; arraySlice <= lastSlice; ++arraySlice) { LinearAllocatorAuto<VirtualLinearAllocator> sliceAlloc(pCmdBuffer->Allocator(), false); // Create and bind a color-target view for this mipmap level and slice. IColorTargetView* pColorView = nullptr; void* pColorViewMem = PAL_MALLOC(m_pDevice->GetColorTargetViewSize(nullptr), &sliceAlloc, AllocInternalTemp); if (pColorViewMem == nullptr) { pCmdBuffer->NotifyAllocFailure(); } else { if (is3dImage) { colorViewInfo.zRange.offset = arraySlice; } else { colorViewInfo.imageInfo.baseSubRes.arraySlice = arraySlice; } colorViewInfo.imageInfo.baseSubRes.mipLevel = mip; Result result = m_pDevice->CreateColorTargetView(colorViewInfo, colorViewInfoInternal, pColorViewMem, &pColorView); PAL_ASSERT(result == Result::Success); bindTargetsInfo.colorTargets[0].pColorTargetView = pColorView; bindTargetsInfo.colorTargetCount = 1; pCmdBuffer->CmdBindTargets(bindTargetsInfo); // Draw a fullscreen quad. pCmdBuffer->CmdDraw(0, 3, 0, 1, 0); // Unbind the color-target view and destroy it. bindTargetsInfo.colorTargetCount = 0; pCmdBuffer->CmdBindTargets(bindTargetsInfo); PAL_SAFE_FREE(pColorViewMem, &sliceAlloc); } } // End for each array slice. } } // End for each mip level. if (needDisablePredication) { // Disable predication pCmdBuffer->CmdSetPredication(nullptr, 0, nullptr, 0, static_cast<PredicateType>(0), false, false, false); } // Restore original command buffer state. pCmdBuffer->PopGraphicsState(); } // ===================================================================================================================== // Executes a CB fixed function resolve. void RsrcProcMgr::ResolveImageFixedFunc( GfxCmdBuffer* pCmdBuffer, const Image& srcImage, ImageLayout srcImageLayout, const Image& dstImage, ImageLayout dstImageLayout, uint32 regionCount, const ImageResolveRegion* pRegions, uint32 flags ) const { PAL_ASSERT(pCmdBuffer->IsGraphicsSupported()); // Don't expect GFX Blts on Nested unless targets not inherited. PAL_ASSERT((pCmdBuffer->IsNested() == false) || (static_cast<UniversalCmdBuffer*>( pCmdBuffer)->GetGraphicsState().inheritedState.stateFlags.targetViewState == 0)); const auto& srcCreateInfo = srcImage.GetImageCreateInfo(); const auto& dstCreateInfo = dstImage.GetImageCreateInfo(); ViewportParams viewportInfo = { }; viewportInfo.count = 1; viewportInfo.viewports[0].minDepth = 0.f; viewportInfo.viewports[0].maxDepth = 1.f; viewportInfo.viewports[0].origin = PointOrigin::UpperLeft; viewportInfo.horzClipRatio = FLT_MAX; viewportInfo.horzDiscardRatio = 1.0f; viewportInfo.vertClipRatio = FLT_MAX; viewportInfo.vertDiscardRatio = 1.0f; viewportInfo.depthRange = DepthRange::ZeroToOne; ScissorRectParams scissorInfo = { }; scissorInfo.count = 1; const ColorTargetViewInternalCreateInfo colorViewInfoInternal = { }; ColorTargetViewCreateInfo srcColorViewInfo = { }; srcColorViewInfo.imageInfo.pImage = &srcImage; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 srcColorViewInfo.imageInfo.baseSubRes.aspect = ImageAspect::Color; #endif srcColorViewInfo.imageInfo.arraySize = 1; ColorTargetViewCreateInfo dstColorViewInfo = { }; dstColorViewInfo.imageInfo.pImage = &dstImage; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 dstColorViewInfo.imageInfo.baseSubRes.aspect = ImageAspect::Color; #endif dstColorViewInfo.imageInfo.arraySize = 1; BindTargetParams bindTargetsInfo = {}; bindTargetsInfo.colorTargetCount = 2; bindTargetsInfo.colorTargets[0].pColorTargetView = nullptr; bindTargetsInfo.colorTargets[0].imageLayout.usages = LayoutColorTarget; bindTargetsInfo.colorTargets[0].imageLayout.engines = LayoutUniversalEngine; bindTargetsInfo.colorTargets[1].pColorTargetView = nullptr; bindTargetsInfo.colorTargets[1].imageLayout.usages = LayoutColorTarget; bindTargetsInfo.colorTargets[1].imageLayout.engines = LayoutUniversalEngine; // Save current command buffer state and bind graphics state which is common for all regions. pCmdBuffer->PushGraphicsState(); BindCommonGraphicsState(pCmdBuffer); pCmdBuffer->CmdBindMsaaState(GetMsaaState(srcCreateInfo.samples, srcCreateInfo.fragments)); pCmdBuffer->CmdBindColorBlendState(m_pBlendDisableState); pCmdBuffer->CmdBindDepthStencilState(m_pDepthDisableState); const GraphicsPipeline* pPipelinePrevious = nullptr; const GraphicsPipeline* pPipelineByImageFormat = GetGfxPipelineByTargetIndexAndFormat(ResolveFixedFunc_32ABGR, 0, srcCreateInfo.swizzledFormat); // Put ImageResolveInvertY value in user data 0 used by VS. pCmdBuffer->CmdSetUserData(PipelineBindPoint::Graphics, 0, 1, &flags); // Each region needs to be resolved individually. for (uint32 idx = 0; idx < regionCount; ++idx) { LinearAllocatorAuto<VirtualLinearAllocator> regionAlloc(pCmdBuffer->Allocator(), false); srcColorViewInfo.swizzledFormat = srcCreateInfo.swizzledFormat; dstColorViewInfo.swizzledFormat = dstCreateInfo.swizzledFormat; dstColorViewInfo.imageInfo.baseSubRes.mipLevel = pRegions[idx].dstMipLevel; // Override the formats with the caller's "reinterpret" format: if (Formats::IsUndefined(pRegions[idx].swizzledFormat.format) == false) { // We require that the channel formats match. PAL_ASSERT(Formats::ShareChFmt(srcColorViewInfo.swizzledFormat.format, pRegions[idx].swizzledFormat.format)); PAL_ASSERT(Formats::ShareChFmt(dstColorViewInfo.swizzledFormat.format, pRegions[idx].swizzledFormat.format)); #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 const SubresId srcSubres = { pRegions[idx].srcAspect, 0, pRegions[idx].srcSlice }; const SubresId dstSubres = { pRegions[idx].dstAspect, pRegions[idx].dstMipLevel, pRegions[idx].dstSlice }; #else const SubresId srcSubres = { pRegions[idx].srcPlane, 0, pRegions[idx].srcSlice }; const SubresId dstSubres = { pRegions[idx].dstPlane, pRegions[idx].dstMipLevel, pRegions[idx].dstSlice }; #endif // If the specified format exactly matches the image formats the resolve will always work. Otherwise, the // images must support format replacement. PAL_ASSERT(Formats::HaveSameNumFmt(srcColorViewInfo.swizzledFormat.format, pRegions[idx].swizzledFormat.format) || srcImage.GetGfxImage()->IsFormatReplaceable(srcSubres, srcImageLayout, false)); PAL_ASSERT(Formats::HaveSameNumFmt(dstColorViewInfo.swizzledFormat.format, pRegions[idx].swizzledFormat.format) || dstImage.GetGfxImage()->IsFormatReplaceable(dstSubres, dstImageLayout, true)); srcColorViewInfo.swizzledFormat.format = pRegions[idx].swizzledFormat.format; dstColorViewInfo.swizzledFormat.format = pRegions[idx].swizzledFormat.format; } // Setup the viewport and scissor to restrict rendering to the destination region being copied. viewportInfo.viewports[0].originX = static_cast<float>(pRegions[idx].dstOffset.x); viewportInfo.viewports[0].originY = static_cast<float>(pRegions[idx].dstOffset.y); viewportInfo.viewports[0].width = static_cast<float>(pRegions[idx].extent.width); viewportInfo.viewports[0].height = static_cast<float>(pRegions[idx].extent.height); scissorInfo.scissors[0].offset.x = pRegions[idx].dstOffset.x; scissorInfo.scissors[0].offset.y = pRegions[idx].dstOffset.y; scissorInfo.scissors[0].extent.width = pRegions[idx].extent.width; scissorInfo.scissors[0].extent.height = pRegions[idx].extent.height; const GraphicsPipeline* pPipeline = Formats::IsUndefined(pRegions[idx].swizzledFormat.format) ? pPipelineByImageFormat : GetGfxPipelineByTargetIndexAndFormat(ResolveFixedFunc_32ABGR, 0, pRegions[idx].swizzledFormat); if (pPipelinePrevious != pPipeline) { pPipelinePrevious = pPipeline; pCmdBuffer->CmdBindPipeline({ PipelineBindPoint::Graphics, pPipeline, InternalApiPsoHash, }); } pCmdBuffer->CmdSetViewports(viewportInfo); pCmdBuffer->CmdSetScissorRects(scissorInfo); for (uint32 slice = 0; slice < pRegions[idx].numSlices; ++slice) { srcColorViewInfo.imageInfo.baseSubRes.arraySlice = (pRegions[idx].srcSlice + slice); dstColorViewInfo.imageInfo.baseSubRes.arraySlice = (pRegions[idx].dstSlice + slice); LinearAllocatorAuto<VirtualLinearAllocator> sliceAlloc(pCmdBuffer->Allocator(), false); IColorTargetView* pSrcColorView = nullptr; IColorTargetView* pDstColorView = nullptr; void* pSrcColorViewMem = PAL_MALLOC(m_pDevice->GetColorTargetViewSize(nullptr), &sliceAlloc, AllocInternalTemp); void* pDstColorViewMem = PAL_MALLOC(m_pDevice->GetColorTargetViewSize(nullptr), &sliceAlloc, AllocInternalTemp); if ((pDstColorViewMem == nullptr) || (pSrcColorViewMem == nullptr)) { pCmdBuffer->NotifyAllocFailure(); } else { Result result = m_pDevice->CreateColorTargetView(srcColorViewInfo, colorViewInfoInternal, pSrcColorViewMem, &pSrcColorView); PAL_ASSERT(result == Result::Success); if (result == Result::Success) { result = m_pDevice->CreateColorTargetView(dstColorViewInfo, colorViewInfoInternal, pDstColorViewMem, &pDstColorView); PAL_ASSERT(result == Result::Success); } if (result == Result::Success) { bindTargetsInfo.colorTargets[0].pColorTargetView = pSrcColorView; bindTargetsInfo.colorTargets[1].pColorTargetView = pDstColorView; bindTargetsInfo.colorTargetCount = 2; pCmdBuffer->CmdBindTargets(bindTargetsInfo); // Draw a fullscreen quad. pCmdBuffer->CmdDraw(0, 3, 0, 1, 0); // Unbind the color-target view and destroy it. bindTargetsInfo.colorTargetCount = 0; pCmdBuffer->CmdBindTargets(bindTargetsInfo); } } PAL_SAFE_FREE(pSrcColorViewMem, &sliceAlloc); PAL_SAFE_FREE(pDstColorViewMem, &sliceAlloc); } // End for each slice. } // End for each region. // Restore original command buffer state. pCmdBuffer->PopGraphicsState(); } // ===================================================================================================================== // Executes a image resolve by performing fixed-func depth copy or stencil copy void RsrcProcMgr::ResolveImageDepthStencilCopy( GfxCmdBuffer* pCmdBuffer, const Image& srcImage, ImageLayout srcImageLayout, const Image& dstImage, ImageLayout dstImageLayout, uint32 regionCount, const ImageResolveRegion* pRegions, uint32 flags) const { PAL_ASSERT(srcImage.IsDepthStencilTarget() && dstImage.IsDepthStencilTarget()); PAL_ASSERT(pCmdBuffer->IsGraphicsSupported()); // Don't expect GFX Blts on Nested unless targets not inherited. PAL_ASSERT((pCmdBuffer->IsNested() == false) || (static_cast<UniversalCmdBuffer*>( pCmdBuffer)->GetGraphicsState().inheritedState.stateFlags.targetViewState == 0)); const auto& srcCreateInfo = srcImage.GetImageCreateInfo(); const auto& dstCreateInfo = dstImage.GetImageCreateInfo(); ViewportParams viewportInfo = {}; viewportInfo.count = 1; viewportInfo.viewports[0].minDepth = 0.f; viewportInfo.viewports[0].maxDepth = 1.f; viewportInfo.viewports[0].origin = PointOrigin::UpperLeft; viewportInfo.horzClipRatio = FLT_MAX; viewportInfo.horzDiscardRatio = 1.0f; viewportInfo.vertClipRatio = FLT_MAX; viewportInfo.vertDiscardRatio = 1.0f; viewportInfo.depthRange = DepthRange::ZeroToOne; ScissorRectParams scissorInfo = {}; scissorInfo.count = 1; DepthStencilViewCreateInfo srcDepthViewInfo = {}; srcDepthViewInfo.pImage = &srcImage; srcDepthViewInfo.arraySize = 1; srcDepthViewInfo.flags.readOnlyDepth = 1; srcDepthViewInfo.flags.readOnlyStencil = 1; ColorTargetViewCreateInfo dstColorViewInfo = {}; dstColorViewInfo.imageInfo.pImage = &dstImage; dstColorViewInfo.imageInfo.arraySize = 1; BindTargetParams bindTargetsInfo = {}; bindTargetsInfo.colorTargetCount = 1; bindTargetsInfo.colorTargets[0].pColorTargetView = nullptr; bindTargetsInfo.colorTargets[0].imageLayout.usages = LayoutColorTarget; bindTargetsInfo.colorTargets[0].imageLayout.engines = LayoutUniversalEngine; bindTargetsInfo.depthTarget.depthLayout.usages = LayoutDepthStencilTarget; bindTargetsInfo.depthTarget.depthLayout.engines = LayoutUniversalEngine; // Save current command buffer state and bind graphics state which is common for all regions. pCmdBuffer->PushGraphicsState(); BindCommonGraphicsState(pCmdBuffer); pCmdBuffer->CmdBindMsaaState(GetMsaaState(1u, 1u)); pCmdBuffer->CmdBindColorBlendState(m_pBlendDisableState); pCmdBuffer->CmdBindDepthStencilState(m_pDepthDisableState); // Put ImageResolveInvertY value in user data 0 used by VS. pCmdBuffer->CmdSetUserData(PipelineBindPoint::Graphics, 0, 1, &flags); // Each region needs to be resolved individually. for (uint32 idx = 0; idx < regionCount; ++idx) { LinearAllocatorAuto<VirtualLinearAllocator> regionAlloc(pCmdBuffer->Allocator(), false); dstColorViewInfo.imageInfo.baseSubRes.mipLevel = pRegions[idx].dstMipLevel; // Setup the viewport and scissor to restrict rendering to the destination region being copied. // srcOffset and dstOffset have to be exactly same PAL_ASSERT((pRegions[idx].srcOffset.x == pRegions[idx].dstOffset.x) && (pRegions[idx].srcOffset.y == pRegions[idx].dstOffset.y)); viewportInfo.viewports[0].originX = static_cast<float>(pRegions[idx].srcOffset.x); viewportInfo.viewports[0].originY = static_cast<float>(pRegions[idx].srcOffset.y); viewportInfo.viewports[0].width = static_cast<float>(pRegions[idx].extent.width); viewportInfo.viewports[0].height = static_cast<float>(pRegions[idx].extent.height); scissorInfo.scissors[0].offset.x = pRegions[idx].srcOffset.x; scissorInfo.scissors[0].offset.y = pRegions[idx].srcOffset.y; scissorInfo.scissors[0].extent.width = pRegions[idx].extent.width; scissorInfo.scissors[0].extent.height = pRegions[idx].extent.height; pCmdBuffer->CmdSetViewports(viewportInfo); pCmdBuffer->CmdSetScissorRects(scissorInfo); if (srcCreateInfo.flags.sampleLocsAlwaysKnown != 0) { PAL_ASSERT(pRegions[idx].pQuadSamplePattern != nullptr); pCmdBuffer->CmdSetMsaaQuadSamplePattern(srcCreateInfo.samples, *pRegions[idx].pQuadSamplePattern); } else { PAL_ASSERT(pRegions[idx].pQuadSamplePattern == nullptr); } for (uint32 slice = 0; slice < pRegions[idx].numSlices; ++slice) { DepthStencilViewInternalCreateInfo depthViewInfoInternal = {}; ColorTargetViewInternalCreateInfo colorViewInfoInternal = {}; colorViewInfoInternal.flags.depthStencilCopy = 1; srcDepthViewInfo.baseArraySlice = (pRegions[idx].srcSlice + slice); dstColorViewInfo.imageInfo.baseSubRes.arraySlice = (pRegions[idx].dstSlice + slice); LinearAllocatorAuto<VirtualLinearAllocator> sliceAlloc(pCmdBuffer->Allocator(), false); IDepthStencilView* pSrcDepthView = nullptr; IColorTargetView* pDstColorView = nullptr; void* pSrcDepthViewMem = PAL_MALLOC(m_pDevice->GetDepthStencilViewSize(nullptr), &sliceAlloc, AllocInternalTemp); void* pDstColorViewMem = PAL_MALLOC(m_pDevice->GetColorTargetViewSize(nullptr), &sliceAlloc, AllocInternalTemp); if ((pDstColorViewMem == nullptr) || (pSrcDepthViewMem == nullptr)) { pCmdBuffer->NotifyAllocFailure(); } else { #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 PAL_ASSERT(pRegions[idx].srcAspect == pRegions[idx].dstAspect); dstColorViewInfo.imageInfo.baseSubRes.aspect = pRegions[idx].srcAspect; #else PAL_ASSERT(pRegions[idx].srcPlane == pRegions[idx].dstPlane); dstColorViewInfo.imageInfo.baseSubRes.plane = pRegions[idx].srcPlane; #endif SubresId dstSubresId = {}; dstSubresId.mipLevel = pRegions[idx].dstMipLevel; dstSubresId.arraySlice = (pRegions[idx].dstSlice + slice); #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 dstSubresId.aspect = pRegions[idx].dstAspect; #else dstSubresId.plane = pRegions[idx].dstPlane; #endif dstColorViewInfo.swizzledFormat.format = dstImage.SubresourceInfo(dstSubresId)->format.format; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 if (pRegions[idx].dstAspect == ImageAspect::Depth) #else if (dstImage.IsDepthPlane(pRegions[idx].dstPlane)) #endif { depthViewInfoInternal.flags.isDepthCopy = 1; dstColorViewInfo.swizzledFormat.swizzle = {ChannelSwizzle::X, ChannelSwizzle::Zero, ChannelSwizzle::Zero, ChannelSwizzle::One}; pCmdBuffer->CmdBindPipeline({ PipelineBindPoint::Graphics, GetGfxPipeline(ResolveDepthCopy), InternalApiPsoHash, }); } #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 else if (pRegions[idx].dstAspect == ImageAspect::Stencil) #else else if (dstImage.IsStencilPlane(pRegions[idx].dstPlane)) #endif { // Fixed-func stencil copies stencil value from db to g chanenl of cb. // Swizzle the stencil plance to 0X00. depthViewInfoInternal.flags.isStencilCopy = 1; dstColorViewInfo.swizzledFormat.swizzle = { ChannelSwizzle::Zero, ChannelSwizzle::X, ChannelSwizzle::Zero, ChannelSwizzle::One }; pCmdBuffer->CmdBindPipeline({ PipelineBindPoint::Graphics, GetGfxPipeline(ResolveStencilCopy), InternalApiPsoHash, }); } else { PAL_ASSERT_ALWAYS(); } Result result = m_pDevice->CreateDepthStencilView(srcDepthViewInfo, depthViewInfoInternal, pSrcDepthViewMem, &pSrcDepthView); PAL_ASSERT(result == Result::Success); if (result == Result::Success) { result = m_pDevice->CreateColorTargetView(dstColorViewInfo, colorViewInfoInternal, pDstColorViewMem, &pDstColorView); PAL_ASSERT(result == Result::Success); } if (result == Result::Success) { bindTargetsInfo.colorTargetCount = 1; bindTargetsInfo.colorTargets[0].pColorTargetView = pDstColorView; bindTargetsInfo.depthTarget.pDepthStencilView = pSrcDepthView; pCmdBuffer->CmdBindTargets(bindTargetsInfo); // Draw a fullscreen quad. pCmdBuffer->CmdDraw(0, 3, 0, 1, 0); // Unbind the color-target and depth-stencil target view and destroy them. bindTargetsInfo.colorTargetCount = 0; bindTargetsInfo.depthTarget.pDepthStencilView = nullptr; pCmdBuffer->CmdBindTargets(bindTargetsInfo); } } PAL_SAFE_FREE(pSrcDepthViewMem, &sliceAlloc); PAL_SAFE_FREE(pDstColorViewMem, &sliceAlloc); } // End for each slice. } // End for each region. // Restore original command buffer state. pCmdBuffer->PopGraphicsState(); } // ===================================================================================================================== // Selects the appropriate Depth Stencil copy pipeline based on usage and samples const GraphicsPipeline* RsrcProcMgr::GetCopyDepthStencilPipeline( bool isDepth, bool isDepthStencil, uint32 numSamples ) const { RpmGfxPipeline pipelineType; if (isDepthStencil) { pipelineType = (numSamples > 1) ? CopyMsaaDepthStencil : CopyDepthStencil; } else { if (isDepth) { pipelineType = (numSamples > 1) ? CopyMsaaDepth : CopyDepth; } else { pipelineType = (numSamples > 1) ? CopyMsaaStencil : CopyStencil; } } return GetGfxPipeline(pipelineType); } // ===================================================================================================================== // Retrieves a pre-created MSAA state object that represents the requested number of samples. const MsaaState* RsrcProcMgr::GetMsaaState( uint32 samples, uint32 fragments ) const { const uint32 log2SampleRate = Log2(samples); const uint32 log2FragmentRate = Log2(fragments); PAL_ASSERT(log2SampleRate <= MaxLog2AaSamples); PAL_ASSERT(log2FragmentRate <= MaxLog2AaFragments); return m_pMsaaState[log2SampleRate][log2FragmentRate]; } // ===================================================================================================================== // Create a number of common state objects used by the various RPM-owned GFX pipelines Result RsrcProcMgr::CreateCommonStateObjects() { // Setup a "default" depth/stencil state with depth testing: Depth writes and stencil writes all disabled. DepthStencilStateCreateInfo depthStencilInfo = { }; depthStencilInfo.depthFunc = CompareFunc::Always; depthStencilInfo.front.stencilFailOp = StencilOp::Keep; depthStencilInfo.front.stencilPassOp = StencilOp::Keep; depthStencilInfo.front.stencilDepthFailOp = StencilOp::Keep; depthStencilInfo.front.stencilFunc = CompareFunc::Always; depthStencilInfo.back = depthStencilInfo.front; depthStencilInfo.depthEnable = false; depthStencilInfo.depthWriteEnable = false; depthStencilInfo.stencilEnable = false; Result result = m_pDevice->CreateDepthStencilStateInternal(depthStencilInfo, &m_pDepthDisableState, AllocInternal); if (result == Result::Success) { // Setup depth/stencil state with depth testing disabled, depth writes enabled and stencil writes enabled. // This is used for depth and stencil expands. depthStencilInfo.depthFunc = CompareFunc::Always; depthStencilInfo.front.stencilFailOp = StencilOp::Keep; depthStencilInfo.front.stencilPassOp = StencilOp::Keep; depthStencilInfo.front.stencilDepthFailOp = StencilOp::Keep; depthStencilInfo.front.stencilFunc = CompareFunc::Always; depthStencilInfo.back = depthStencilInfo.front; depthStencilInfo.depthEnable = false; depthStencilInfo.depthWriteEnable = true; depthStencilInfo.stencilEnable = true; result = m_pDevice->CreateDepthStencilStateInternal(depthStencilInfo, &m_pDepthExpandState, AllocInternal); } if (result == Result::Success) { // Setup depth/stencil state with depth testing disabled and depth/stencil writes disabled // This is used for depth and stencil resummarization. depthStencilInfo.depthFunc = CompareFunc::Always; depthStencilInfo.front.stencilFailOp = StencilOp::Keep; depthStencilInfo.front.stencilPassOp = StencilOp::Keep; depthStencilInfo.front.stencilDepthFailOp = StencilOp::Keep; depthStencilInfo.front.stencilFunc = CompareFunc::Always; depthStencilInfo.back = depthStencilInfo.front; depthStencilInfo.depthEnable = false; depthStencilInfo.depthWriteEnable = false; depthStencilInfo.stencilEnable = false; result = m_pDevice->CreateDepthStencilStateInternal(depthStencilInfo, &m_pDepthResummarizeState, AllocInternal); } // Setup the depth/stencil state for depth and stencil resolves using the graphics engine. if (result == Result::Success) { depthStencilInfo.depthEnable = true; depthStencilInfo.depthFunc = CompareFunc::Always; depthStencilInfo.front.stencilFunc = CompareFunc::Always; // State object for depth resolves: depthStencilInfo.front.stencilFailOp = StencilOp::Keep; depthStencilInfo.front.stencilPassOp = StencilOp::Keep; depthStencilInfo.front.stencilDepthFailOp = StencilOp::Keep; depthStencilInfo.back = depthStencilInfo.front; depthStencilInfo.depthWriteEnable = true; depthStencilInfo.stencilEnable = false; result = m_pDevice->CreateDepthStencilStateInternal(depthStencilInfo, &m_pDepthResolveState, AllocInternal); if (result == Result::Success) { // State object for stencil resolves: depthStencilInfo.front.stencilFailOp = StencilOp::Replace; depthStencilInfo.front.stencilPassOp = StencilOp::Replace; depthStencilInfo.front.stencilDepthFailOp = StencilOp::Replace; depthStencilInfo.back = depthStencilInfo.front; depthStencilInfo.depthWriteEnable = true; depthStencilInfo.stencilEnable = true; result = m_pDevice->CreateDepthStencilStateInternal(depthStencilInfo, &m_pDepthStencilResolveState, AllocInternal); } if (result == Result::Success) { // State object for stencil resolves: depthStencilInfo.front.stencilFailOp = StencilOp::Replace; depthStencilInfo.front.stencilPassOp = StencilOp::Replace; depthStencilInfo.front.stencilDepthFailOp = StencilOp::Replace; depthStencilInfo.back = depthStencilInfo.front; depthStencilInfo.depthWriteEnable = false; depthStencilInfo.stencilEnable = true; result = m_pDevice->CreateDepthStencilStateInternal(depthStencilInfo, &m_pStencilResolveState, AllocInternal); } } // Setup the depth/stencil states for clearing depth and/or stencil. if (result == Result::Success) { depthStencilInfo.depthFunc = CompareFunc::Always; depthStencilInfo.front.stencilFunc = CompareFunc::Always; depthStencilInfo.front.stencilFailOp = StencilOp::Replace; depthStencilInfo.front.stencilPassOp = StencilOp::Replace; depthStencilInfo.front.stencilDepthFailOp = StencilOp::Replace; depthStencilInfo.back = depthStencilInfo.front; depthStencilInfo.depthBoundsEnable = false; depthStencilInfo.depthWriteEnable = true; depthStencilInfo.depthEnable = true; depthStencilInfo.stencilEnable = true; result = m_pDevice->CreateDepthStencilStateInternal(depthStencilInfo, &m_pDepthStencilClearState, AllocInternal); if (result == Result::Success) { depthStencilInfo.depthEnable = true; depthStencilInfo.stencilEnable = false; result = m_pDevice->CreateDepthStencilStateInternal(depthStencilInfo, &m_pDepthClearState, AllocInternal); } if (result == Result::Success) { depthStencilInfo.depthEnable = false; depthStencilInfo.stencilEnable = true; result = m_pDevice->CreateDepthStencilStateInternal(depthStencilInfo, &m_pStencilClearState, AllocInternal); } } if (result == Result::Success) { // Set up a "default" color blend state which disables all blending. ColorBlendStateCreateInfo blendInfo = { }; for (uint32 idx = 0; idx < MaxColorTargets; ++idx) { blendInfo.targets[idx].srcBlendColor = Blend::One; blendInfo.targets[idx].srcBlendAlpha = Blend::One; blendInfo.targets[idx].dstBlendColor = Blend::Zero; blendInfo.targets[idx].dstBlendAlpha = Blend::Zero; blendInfo.targets[idx].blendFuncColor = BlendFunc::Add; blendInfo.targets[idx].blendFuncAlpha = BlendFunc::Add; } result = m_pDevice->CreateColorBlendStateInternal(blendInfo, &m_pBlendDisableState, AllocInternal); } if (result == Result::Success) { // Set up a color blend state which enable rt0 blending. ColorBlendStateCreateInfo blendInfo = { }; blendInfo.targets[0].blendEnable = 1; blendInfo.targets[0].srcBlendColor = Blend::SrcColor; blendInfo.targets[0].srcBlendAlpha = Blend::SrcAlpha; blendInfo.targets[0].dstBlendColor = Blend::DstColor; blendInfo.targets[0].dstBlendAlpha = Blend::OneMinusSrcAlpha; blendInfo.targets[0].blendFuncColor = BlendFunc::Add; blendInfo.targets[0].blendFuncAlpha = BlendFunc::Add; result = m_pDevice->CreateColorBlendStateInternal(blendInfo, &m_pColorBlendState, AllocInternal); } // Create all MSAA state objects. MsaaStateCreateInfo msaaInfo = { }; msaaInfo.sampleMask = USHRT_MAX; for (uint32 log2Samples = 0; ((log2Samples <= MaxLog2AaSamples) && (result == Result::Success)); ++log2Samples) { const uint32 coverageSamples = (1 << log2Samples); msaaInfo.coverageSamples = coverageSamples; msaaInfo.alphaToCoverageSamples = coverageSamples; for (uint32 log2Fragments = 0; ((log2Fragments <= MaxLog2AaFragments) && (result == Result::Success)); ++log2Fragments) { const uint32 fragments = (1 << log2Fragments); // The following parameters should never be higher than the max number of msaa fragments (usually 8). const uint32 maxFragments = m_pDevice->Parent()->ChipProperties().imageProperties.maxMsaaFragments; const uint32 clampedSamples = Min(fragments, maxFragments); msaaInfo.exposedSamples = clampedSamples; msaaInfo.pixelShaderSamples = clampedSamples; msaaInfo.depthStencilSamples = clampedSamples; msaaInfo.shaderExportMaskSamples = clampedSamples; msaaInfo.sampleClusters = clampedSamples; result = m_pDevice->CreateMsaaStateInternal( msaaInfo, &m_pMsaaState[log2Samples][log2Fragments], AllocInternal); } } return result; } #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 // ===================================================================================================================== // Returns true if the supplied aspect / mip-level supports meta-data texture fetches. If the supplied aspect is // invalid for the image, then fetches are not supported. bool RsrcProcMgr::GetMetaDataTexFetchSupport( const Image* pImage, ImageAspect aspect, uint32 mipLevel) { const SubresId subres = { aspect, mipLevel, 0 }; // The SubresourceInfo() function will assert and possibly do bad things (at least return a pointer to a different // subresource than intended) if the aspect isn't valid, so check that first. return (pImage->IsAspectValid(aspect) && pImage->SubresourceInfo(subres)->flags.supportMetaDataTexFetch); } #endif // ===================================================================================================================== // Returns the size of a typed buffer that contains a 3D block of elements with the given size and pitches. // This is useful for mapping a sub-cube of a linear image into a linear buffer. gpusize RsrcProcMgr::ComputeTypedBufferRange( const Extent3d& extent, uint32 elementSize, // The size of each element in bytes. gpusize rowPitch, // The number of bytes between successive rows. gpusize depthPitch) // The number of bytes between successive depth slices. { // This function will underflow if the extents aren't fully defined. PAL_ASSERT((extent.width > 0) && (extent.height > 0) && (extent.depth > 0)); // Traversing the buffer from the "top left" to "bottom right" covers (depth - 1) full depth slices, (height - 1) // full rows, and (width) elements in the final partial row. return (((extent.depth - 1) * depthPitch) + ((extent.height - 1) * rowPitch) + (extent.width * elementSize)); } // ===================================================================================================================== // Inserts barrier needed before issuing a compute clear when the target image is currently bound as a color target. // Only necessary when the client specifies the ColorClearAutoSync flag for a color clear. static void PreComputeColorClearSync( ICmdBuffer* pCmdBuffer, const IImage* pImage, const SubresRange& subres, ImageLayout layout) { BarrierInfo preBarrier = { }; preBarrier.waitPoint = HwPipePreCs; constexpr HwPipePoint Eop = HwPipeBottom; preBarrier.pipePointWaitCount = 1; preBarrier.pPipePoints = &Eop; BarrierTransition transition = { }; transition.srcCacheMask = CoherColorTarget; transition.dstCacheMask = CoherShader; transition.imageInfo.pImage = pImage; transition.imageInfo.subresRange = subres; transition.imageInfo.oldLayout = layout; transition.imageInfo.newLayout = layout; preBarrier.transitionCount = 1; preBarrier.pTransitions = &transition; preBarrier.reason = Developer::BarrierReasonPreComputeColorClear; pCmdBuffer->CmdBarrier(preBarrier); } // ===================================================================================================================== // Inserts barrier needed after issuing a compute clear when the target image will be immediately re-bound as a // color target. Only necessary when the client specifies the ColorClearAutoSync flag for a color clear. static void PostComputeColorClearSync( ICmdBuffer* pCmdBuffer, const IImage* pImage, const SubresRange& subres, ImageLayout layout) { BarrierInfo postBarrier = { }; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 577 postBarrier.waitPoint = HwPipePreRasterization; #else postBarrier.waitPoint = HwPipePreColorTarget; #endif constexpr HwPipePoint PostCs = HwPipePostCs; postBarrier.pipePointWaitCount = 1; postBarrier.pPipePoints = &PostCs; BarrierTransition transition = { }; transition.srcCacheMask = CoherShader; transition.dstCacheMask = CoherColorTarget; transition.imageInfo.pImage = pImage; transition.imageInfo.subresRange = subres; transition.imageInfo.oldLayout = layout; transition.imageInfo.newLayout = layout; postBarrier.transitionCount = 1; postBarrier.pTransitions = &transition; postBarrier.reason = Developer::BarrierReasonPostComputeColorClear; pCmdBuffer->CmdBarrier(postBarrier); } // ===================================================================================================================== // Inserts barrier needed before issuing a compute clear when the target image is currently bound as a depth/stencil // target. Only necessary when the client specifies the DsClearAutoSync flag for a depth/stencil clear. void PreComputeDepthStencilClearSync( ICmdBuffer* pCmdBuffer, const GfxImage& gfxImage, const SubresRange& subres, ImageLayout layout) { #if PAL_CLIENT_INTERFACE_MAJOR_VERSION >= 642 PAL_ASSERT(subres.numPlanes == 1); #endif BarrierInfo preBarrier = { }; preBarrier.waitPoint = HwPipePreCs; const IImage* pImage = gfxImage.Parent(); preBarrier.rangeCheckedTargetWaitCount = 1; preBarrier.ppTargets = &pImage; BarrierTransition transition = { }; transition.srcCacheMask = CoherDepthStencilTarget; transition.dstCacheMask = CoherShader; transition.imageInfo.pImage = pImage; transition.imageInfo.subresRange = subres; transition.imageInfo.oldLayout = layout; transition.imageInfo.newLayout = layout; preBarrier.transitionCount = 1; preBarrier.pTransitions = &transition; preBarrier.reason = Developer::BarrierReasonPreComputeDepthStencilClear; pCmdBuffer->CmdBarrier(preBarrier); } // ===================================================================================================================== // Inserts barrier needed after issuing a compute clear when the target image will be immediately re-bound as a // depth/stencil target. Only necessary when the client specifies the DsClearAutoSync flag for a depth/stencil clear. void PostComputeDepthStencilClearSync( ICmdBuffer* pCmdBuffer, const GfxImage& gfxImage, const SubresRange& subres, ImageLayout layout) { BarrierInfo postBarrier = { }; postBarrier.waitPoint = HwPipePreRasterization; const IImage* pImage = gfxImage.Parent(); constexpr HwPipePoint PostCs = HwPipePostCs; postBarrier.pipePointWaitCount = 1; postBarrier.pPipePoints = &PostCs; BarrierTransition transition = { }; transition.srcCacheMask = CoherShader; transition.dstCacheMask = CoherDepthStencilTarget; transition.imageInfo.pImage = pImage; transition.imageInfo.subresRange = subres; transition.imageInfo.oldLayout = layout; transition.imageInfo.newLayout = layout; postBarrier.transitionCount = 1; postBarrier.pTransitions = &transition; postBarrier.reason = Developer::BarrierReasonPostComputeDepthStencilClear; pCmdBuffer->CmdBarrier(postBarrier); } // ===================================================================================================================== // Returns a pointer to the compute pipeline used to decompress the supplied image. const ComputePipeline* RsrcProcMgr::GetComputeMaskRamExpandPipeline( const Image& image ) const { const auto& createInfo = image.GetImageCreateInfo(); const auto pipelineEnum = ((createInfo.samples == 1) ? RpmComputePipeline::ExpandMaskRam : (createInfo.samples == 2) ? RpmComputePipeline::ExpandMaskRamMs2x : (createInfo.samples == 4) ? RpmComputePipeline::ExpandMaskRamMs4x : (createInfo.samples == 8) ? RpmComputePipeline::ExpandMaskRamMs8x : RpmComputePipeline::ExpandMaskRam); const ComputePipeline* pPipeline = GetPipeline(pipelineEnum); PAL_ASSERT(pPipeline != nullptr); return pPipeline; } // ===================================================================================================================== // Binds common graphics state. void RsrcProcMgr::BindCommonGraphicsState( GfxCmdBuffer* pCmdBuffer ) const { const InputAssemblyStateParams inputAssemblyState = { PrimitiveTopology::RectList }; const DepthBiasParams depthBias = { 0.0f, 0.0f, 0.0f }; const PointLineRasterStateParams pointLineRasterState = { 1.0f, 1.0f }; const TriangleRasterStateParams triangleRasterState = { FillMode::Solid, // frontface fillMode FillMode::Solid, // backface fillMode CullMode::_None, // cullMode FaceOrientation::Cw, // frontFace ProvokingVertex::First // provokingVertex }; GlobalScissorParams scissorParams = { }; scissorParams.scissorRegion.extent.width = MaxScissorExtent; scissorParams.scissorRegion.extent.height = MaxScissorExtent; pCmdBuffer->CmdSetInputAssemblyState(inputAssemblyState); pCmdBuffer->CmdSetDepthBiasState(depthBias); pCmdBuffer->CmdSetPointLineRasterState(pointLineRasterState); pCmdBuffer->CmdSetTriangleRasterState(triangleRasterState); pCmdBuffer->CmdSetClipRects(DefaultClipRectsRule, 0, nullptr); pCmdBuffer->CmdSetGlobalScissor(scissorParams); // Setup register state to put VRS into 1x1 mode (i.e., essentially off). VrsCenterState centerState = {}; VrsRateParams rateParams = {}; rateParams.shadingRate = VrsShadingRate::_1x1; rateParams.combinerState[static_cast<uint32>(VrsCombinerStage::ProvokingVertex)] = VrsCombiner::Passthrough; rateParams.combinerState[static_cast<uint32>(VrsCombinerStage::Primitive)] = VrsCombiner::Passthrough; rateParams.combinerState[static_cast<uint32>(VrsCombinerStage::Image)] = VrsCombiner::Passthrough; rateParams.combinerState[static_cast<uint32>(VrsCombinerStage::PsIterSamples)] = VrsCombiner::Min; pCmdBuffer->CmdSetPerDrawVrsRate(rateParams); pCmdBuffer->CmdSetVrsCenterState(centerState); // Might not have a bound depth buffer here, so don't provide a source image either so the draw-time validator // doesn't do an insane amount of work. pCmdBuffer->CmdBindSampleRateImage(nullptr); } // ===================================================================================================================== // Returns a pointer to the compute pipeline used for fast-clearing hTile data that is laid out in a linear fashion. const ComputePipeline* RsrcProcMgr::GetLinearHtileClearPipeline( bool expClearEnable, bool tileStencilDisabled, uint32 hTileMask ) const { // Determine which pipeline to use for this clear. const ComputePipeline* pPipeline = nullptr; if (expClearEnable) { // If Exp/Clear is enabled, fast clears require using a special Exp/Clear shader. One such shader exists for // depth/stencil Images and for depth-only Images. if (tileStencilDisabled == false) { pPipeline = GetPipeline(RpmComputePipeline::FastDepthStExpClear); } else { pPipeline = GetPipeline(RpmComputePipeline::FastDepthExpClear); } } else if (hTileMask == UINT_MAX) { // If the HTile mask has all bits set, we can use the standard ClearHtile path. // Set the pipeline to null so we don't attempt to use it. pPipeline = nullptr; } else { // Otherwise use the depth clear read-write shader. pPipeline = GetPipeline(RpmComputePipeline::FastDepthClear); } return pPipeline; } /// BltMonitorDesc defines a parametrized model for monitors supported by the Desktop Composition interface. struct BltMonitorDesc { uint32 numPixels; // Number of pixels packed into a single word bool isColorType; // True if color monitor, False for monochrome bool isSplitType; // True if the packed pixels are not adjacent (on screen) float scalingParams[4]; // scaling parameters which is used to convert from float to 10-bit uints float grayScalingMap[12]; // Luminance constants which convert color to monochrome uint32 packParams[24]; // parametrized packing layout }; /// PackPixelConstant describes a set of constants which will be passed to PackedPixelComposite shader. /// c0 desktop sampling scale/offset for left/first pixel /// c1 desktop sampling scale/offset for right/third pixel /// c2 shader flow control parameters /// c3-c5 color to grayscale conversion matrix /// c6-c7 left pixel pack parameters /// c8-c9 middle pixel pack parameters /// c10-c11 right pixel packing parameters /// c12 scaling parameters which is used to convert from float to 10-bit unsigned integers /// c13 region.width*1.0, region.height*1.0, region.width, region.height struct PackPixelConstant { uint32 aluConstant0[4]; uint32 aluConstant1[4]; uint32 aluConstant2[4]; uint32 aluConstant3[4]; uint32 aluConstant4[4]; uint32 aluConstant5[4]; uint32 aluConstant6[4]; uint32 aluConstant7[4]; uint32 aluConstant8[4]; uint32 aluConstant9[4]; uint32 aluConstant10[4]; uint32 aluConstant11[4]; uint32 aluConstant12[4]; uint32 aluConstant13[4]; }; static const BltMonitorDesc Desc_NotPacked = { 1, // Number of packed pixels true, // isColorType ? (predicate) false, // isSplitType ? (predicate) 255.0f, 1/255.0f, 0, 0, // pixel precision (2^N-1, 1/(2^N-1)) 1.0f, 0.0f, 0.0f, 0.0f, // grayScaling 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, }; static const BltMonitorDesc Desc_SplitG70B54_R70B10 = { 2, // Number of packed pixels false, // isColorType ? (predicate) true, // isSplitType ? (predicate) 1023.0f, 1/1023.0f, 0, 0, // pixel precision (2^N-1, 1/(2^N-1)) 0.2126f, 0.7152f, 0.0722f, 0.0f, // grayScaling 0.2126f, 0.7152f, 0.0722f, 0.0f, 0.2126f, 0.7152f, 0.0722f, 0.0f, 0x00, 0xff, 0x00, 2, // Most significant bits for the first pixel 0x00, 0x00, 0x30, 4, // Least significant bits for the first pixel 0xff, 0x00, 0x00, 2, // Most significant bits for the second pixel 0x00, 0x00, 0x03, 0 // Least significant bits for the second pixel }; static const BltMonitorDesc Desc_SplitB70G10_R70G76 = { 2, // Number of packed pixels false, // isColorType ? (predicate) true, // isSplitType ? (predicate) 1023.0f, 1/1023.0f, 0, 0, // pixel precision (2^N-1, 1/(2^N-1)) 0.2126f, 0.7152f, 0.0722f, 0.0f, // grayScaling 0.2126f, 0.7152f, 0.0722f, 0.0f, 0.2126f, 0.7152f, 0.0722f, 0.0f, 0x00, 0x00, 0xff, 2, // Most significant bits for the first pixel 0x00, 0x03, 0x00, 0, // Least significant bits for the first pixel 0xff, 0x00, 0x00, 2, // Most significant bits for the second pixel 0x00, 0xc0, 0x00, 6 // Least significant bits for the second pixel }; static const BltMonitorDesc Desc_G70B54_R70B10 = { 2, // Number of packed pixels false, // isColorType ? (predicate) false, // isSplitType ? (predicate) 1023.0f, 1/1023.0f, 0, 0, // pixel precision (2^N-1, 1/(2^N-1)) 0.2126f, 0.7152f, 0.0722f, 0.0f, // grayScaling 0.2126f, 0.7152f, 0.0722f, 0.0f, 0.2126f, 0.7152f, 0.0722f, 0.0f, 0x00, 0xff, 0x00, 2, // Most significant bits for the first pixel 0x00, 0x00, 0x30, 4, // Least significant bits for the first pixel 0xff, 0x00, 0x00, 2, // Most significant bits for the second pixel 0x00, 0x00, 0x03, 0 // Least significant bits for the second pixel }; static const BltMonitorDesc Desc_B70R32_G70R76 = { 2, // Number of packed pixels false, // isColorType ? (predicate) false, // isSplitType ? (predicate) 1023.0f, 1/1023.0f, 0, 0, // pixel precision (2^N-1, 1/(2^N-1)) 0x00, 0x00, 0xff, 2, // Most significant bits for the first pixel 0x0c, 0x00, 0x00, 2, // Least significant bits for the first pixel 0x00, 0xff, 0x00, 2, // Most significant bits for the second pixel 0xc0, 0x00, 0x00, 6 // Least significant bits for the second pixel }; static const BltMonitorDesc Desc_B70R30_G70R74 = { 2, // Number of packed pixels false, // isColorType ? (predicate) false, // isSplitType ? (predicate) 4095.0f, 1/4095.0f, 0, 0, // pixel precision (2^N-1, 1/(2^N-1)) 0.2126f, 0.7152f, 0.0722f, 0.0f, // grayScaling 0.2126f, 0.7152f, 0.0722f, 0.0f, 0.2126f, 0.7152f, 0.0722f, 0.0f, 0x00, 0x00, 0xff, 4, // Most significant bits for the first pixel 0x0f, 0x00, 0x00, 0, // Least significant bits for the first pixel 0x00, 0xff, 0x00, 4, // Most significant bits for the second pixel 0xf0, 0x00, 0x00, 4 // Least significant bits for the second pixel }; static const BltMonitorDesc Desc_B70_G70_R70 = { 3, // Number of packed pixels false, // isColorType ? (predicate) false, // isSplitType ? (predicate) 255.0f, 1/255.0f, 0, 0, // pixel precision (2^N-1, 1/(2^N-1)) 0.2126f, 0.7152f, 0.0722f, 0.0f, // grayScaling 0.2126f, 0.7152f, 0.0722f, 0.0f, 0.2126f, 0.7152f, 0.0722f, 0.0f, 0x00, 0x00, 0xff, 0, // Most significant bits for the first pixel 0x00, 0x00, 0x00, 0, // Least significant bits for the first pixel 0x00, 0xff, 0x00, 0, // Most significant bits for the second pixel 0x00, 0x00, 0x00, 0, // Least significant bits for the second pixel 0xff, 0x00, 0x00, 0, // Most significant bits for the third pixel 0x00, 0x00, 0x00, 0 // Least significant bits for the third pixel }; static const BltMonitorDesc Desc_R70G76 = { 1, // Number of packed pixels false, // isColorType ? (predicate) false, // isSplitType ? (predicate) 1023.0f, 1/1023.0f, 0, 0, // pixel precision (2^N-1, 1/(2^N-1)) 0.2126f, 0.7152f, 0.0722f, 0.0f, // grayScaling 0.2126f, 0.7152f, 0.0722f, 0.0f, 0.2126f, 0.7152f, 0.0722f, 0.0f, 0xff, 0x00, 0x00, 2, // Most significant bits for the first pixel 0x00, 0xc0, 0x00, 6 // Least significant bits for the first pixel }; static const BltMonitorDesc Desc_G70B54 = { 1, // Number of packed pixels false, // isColorType ? (predicate) false, // isSplitType ? (predicate) 1023.0f, 1/1023.0f, 0, 0, // pixel precision (2^N-1, 1/(2^N-1)) 0.2126f, 0.7152f, 0.0722f, 0.0f, // grayScaling 0.2126f, 0.7152f, 0.0722f, 0.0f, 0.2126f, 0.7152f, 0.0722f, 0.0f, 0x00, 0xff, 0x00, 2, // Most significant bits for the first pixel 0x00, 0x00, 0x30, 4 // Least significant bits for the first pixel }; static const BltMonitorDesc Desc_Native = { 1, // Number of packed pixels true, // isColorType ? (predicate) false, // isSplitType ? (predicate) 1023.0f, 1/1023.0f, 0.0f, 0.0f, // pixel precision (2^N-1, 1/(2^N-1)) 1.0f, 0.0f, 0.0f, 0.0f, // grayScaling 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, }; // ===================================================================================================================== // Return pointer to parametrized monitor description given the specified (input) packed pixel type. static const BltMonitorDesc* GetMonitorDesc( PackedPixelType packedPixelType) // packed pixel type { const BltMonitorDesc* pDesc = nullptr; switch (packedPixelType) { case PackedPixelType::NotPacked: pDesc = &Desc_NotPacked; break; case PackedPixelType::SplitG70B54_R70B10: pDesc = &Desc_SplitG70B54_R70B10; break; case PackedPixelType::SplitB70G10_R70G76: pDesc = &Desc_SplitB70G10_R70G76; break; case PackedPixelType::G70B54_R70B10: pDesc = &Desc_G70B54_R70B10; break; case PackedPixelType::B70R32_G70R76: pDesc = &Desc_B70R32_G70R76; break; case PackedPixelType::B70R30_G70R74: pDesc = &Desc_B70R30_G70R74; break; case PackedPixelType::B70_G70_R70: pDesc = &Desc_B70_G70_R70; break; case PackedPixelType::R70G76: pDesc = &Desc_R70G76; break; case PackedPixelType::G70B54: pDesc = &Desc_G70B54; break; case PackedPixelType::Native: pDesc = &Desc_Native; break; default: break; } return pDesc; } // ===================================================================================================================== // return packed pixel constant scaling and offset constant based on packed pixel state static const void ProcessPackPixelCopyConstants( const BltMonitorDesc& monDesc, uint32 packFactor, const ImageCopyRegion& regions, float* pAluConstants) { float leftOffset; float rightOffset; float scale; scale = (monDesc.isSplitType)? 0.5f : 1.0f; if (monDesc.isSplitType) { leftOffset = 0.5f * regions.srcOffset.x; rightOffset = 0.5f; } else { const float pixelWidth = 1.0f / static_cast<float>(regions.extent.width * monDesc.numPixels); const float offset = (packFactor == 2) ? (pixelWidth / 2.0f) : pixelWidth; leftOffset = -offset; rightOffset = offset; } // c13 -> region.width*1.0, region.height*1.0, region.width, region.height pAluConstants[52] = 1.0f * regions.extent.width; pAluConstants[53] = 1.0f * regions.extent.height; pAluConstants[0] = scale; pAluConstants[1] = 1.0f; pAluConstants[2] = leftOffset; pAluConstants[3] = 0.0f; pAluConstants[4] = scale; pAluConstants[5] = 1.0f; pAluConstants[6] = rightOffset; pAluConstants[7] = 0.0f; } // ===================================================================================================================== // Builds commands to copy from rendered surface to an internal surface with packing 2/3 pixels to 1 R8G8B8A8 pixel. void RsrcProcMgr::CopyImageToPackedPixelImage( GfxCmdBuffer* pCmdBuffer, const Image& srcImage, const Image& dstImage, uint32 regionCount, const ImageCopyRegion* pRegions, Pal::PackedPixelType packPixelType ) const { const auto& device = *m_pDevice->Parent(); const auto& dstCreateInfo = dstImage.GetImageCreateInfo(); const auto& srcCreateInfo = srcImage.GetImageCreateInfo(); const bool isCompressed = (Formats::IsBlockCompressed(srcCreateInfo.swizzledFormat.format) || Formats::IsBlockCompressed(dstCreateInfo.swizzledFormat.format)); const bool useMipInSrd = CopyImageUseMipLevelInSrd(isCompressed); const BltMonitorDesc* pMonDesc = GetMonitorDesc(packPixelType); // Get the appropriate pipeline object. const ComputePipeline* pPipeline = GetPipeline(RpmComputePipeline::PackedPixelComposite); // Get number of threads per groups in each dimension, we will need this data later. uint32 threadsPerGroup[3] = {}; pPipeline->ThreadsPerGroupXyz(&threadsPerGroup[0], &threadsPerGroup[1], &threadsPerGroup[2]); // Save current command buffer state and bind the pipeline. pCmdBuffer->CmdSaveComputeState(ComputeStatePipelineAndUserData); pCmdBuffer->CmdBindPipeline({ PipelineBindPoint::Compute, pPipeline, InternalApiPsoHash, }); // ALU constants assignment PackPixelConstant constantData = {}; const uint32 aluConstantSize = sizeof(constantData.aluConstant0); constexpr uint32 DataDwords = (sizeof(constantData) / sizeof(uint32)); // c2 shader flow control constantData.aluConstant2[0] = pMonDesc->isColorType; constantData.aluConstant2[1] = ((pMonDesc->numPixels > 1) ? 1 : 0); constantData.aluConstant2[2] = ((pMonDesc->numPixels != 2) ? 1 : 0); constantData.aluConstant2[3] = pMonDesc->isSplitType; // c3 - c5 color -> color gray matrix memcpy(&constantData.aluConstant3[0], &pMonDesc->grayScalingMap[0], aluConstantSize); memcpy(&constantData.aluConstant4[0], &pMonDesc->grayScalingMap[4], aluConstantSize); memcpy(&constantData.aluConstant5[0], &pMonDesc->grayScalingMap[8], aluConstantSize); if (pMonDesc->isColorType == 0) { // c6 - c7 left pixel pack parameters (rmask, gmask, bmask, shift) // c8 - c9 mid pixel pack parameters // c10 - c11 right pixel pack parameters if (pMonDesc->numPixels == 1) { memcpy(&constantData.aluConstant8[0], &pMonDesc->packParams[0], aluConstantSize); memcpy(&constantData.aluConstant9[0], &pMonDesc->packParams[4], aluConstantSize); } else if (pMonDesc->numPixels == 2) { memcpy(&constantData.aluConstant6[0], &pMonDesc->packParams[0], aluConstantSize); memcpy(&constantData.aluConstant7[0], &pMonDesc->packParams[4], aluConstantSize); memcpy(&constantData.aluConstant10[0], &pMonDesc->packParams[8], aluConstantSize); memcpy(&constantData.aluConstant11[0], &pMonDesc->packParams[12], aluConstantSize); } else if (pMonDesc->numPixels == 3) { memcpy(&constantData.aluConstant6[0], &pMonDesc->packParams[0], aluConstantSize); memcpy(&constantData.aluConstant7[0], &pMonDesc->packParams[4], aluConstantSize); memcpy(&constantData.aluConstant8[0], &pMonDesc->packParams[8], aluConstantSize); memcpy(&constantData.aluConstant9[0], &pMonDesc->packParams[12], aluConstantSize); memcpy(&constantData.aluConstant10[0], &pMonDesc->packParams[16], aluConstantSize); memcpy(&constantData.aluConstant11[0], &pMonDesc->packParams[20], aluConstantSize); } else { PAL_ASSERT_ALWAYS(); } } // c12 pixel scaling (2^N-1, 1/(2^N-1), unused, unused) memcpy(&constantData.aluConstant12[0], &pMonDesc->scalingParams[0], sizeof(pMonDesc->scalingParams[0]) * 4); // Now begin processing the list of copy regions. for (uint32 idx = 0; idx < regionCount; ++idx) { const ImageCopyRegion& region = pRegions[idx]; PAL_ASSERT((region.numSlices == 1) || (region.extent.depth == 1)); SwizzledFormat srcFormat = srcImage.SubresourceInfo(region.srcSubres)->format; SwizzledFormat dstFormat = dstImage.SubresourceInfo(region.dstSubres)->format; // set up c0/c1 sample scaling and offset ProcessPackPixelCopyConstants(*pMonDesc, pMonDesc->numPixels, region, reinterpret_cast<float*>(&constantData.aluConstant0[0])); // c13 -> region.width*1.0, region.height*1.0, region.width, region.height constantData.aluConstant13[2] = region.dstOffset.x + region.extent.width; constantData.aluConstant13[3] = region.dstOffset.y + region.extent.height; // there are 2 resources and 1 sampler const uint8 rsNum = 3; uint32* pUserData = RpmUtil::CreateAndBindEmbeddedUserData(pCmdBuffer, SrdDwordAlignment() * rsNum + DataDwords, SrdDwordAlignment(), PipelineBindPoint::Compute, 0); ImageViewInfo imageView[2] = {}; #if PAL_CLIENT_INTERFACE_MAJOR_VERSION < 642 SubresRange viewRange = { region.dstSubres, 1, 1}; #else SubresRange viewRange = { region.dstSubres, 1, 1, 1 }; #endif RpmUtil::BuildImageViewInfo(&imageView[0], dstImage, viewRange, dstFormat, RpmUtil::DefaultRpmLayoutShaderWrite, Pal::ImageTexOptLevel::Default); viewRange.startSubres = region.srcSubres; RpmUtil::BuildImageViewInfo(&imageView[1], srcImage, viewRange, srcFormat, RpmUtil::DefaultRpmLayoutRead, Pal::ImageTexOptLevel::Default); if (useMipInSrd == false) { // The miplevel as specified in the shader instruction is actually an offset from the mip-level // as specified in the SRD. imageView[0].subresRange.startSubres.mipLevel = 0; // dst imageView[1].subresRange.startSubres.mipLevel = 0; // src // The mip-level from the instruction is also clamped to the "last level" as specified in the SRD. imageView[0].subresRange.numMips = region.dstSubres.mipLevel + viewRange.numMips; imageView[1].subresRange.numMips = region.srcSubres.mipLevel + viewRange.numMips; } // Turn our image views into HW SRDs here device.CreateImageViewSrds(2, &imageView[0], pUserData); pUserData += SrdDwordAlignment() * 2; Pal::SamplerInfo samplerInfo = {}; samplerInfo.filter.magnification = Pal::XyFilterPoint; samplerInfo.filter.minification = Pal::XyFilterPoint; samplerInfo.filter.mipFilter = Pal::MipFilterNone; samplerInfo.addressU = Pal::TexAddressMode::Clamp; samplerInfo.addressV = Pal::TexAddressMode::Clamp; samplerInfo.addressW = Pal::TexAddressMode::Clamp; device.CreateSamplerSrds(1, &samplerInfo, pUserData); pUserData += SrdDwordAlignment(); // Copy the copy parameters into the embedded user-data space memcpy(pUserData, &constantData, sizeof(constantData)); // Execute the dispatch, we need one thread per texel. pCmdBuffer->CmdDispatch(RpmUtil::MinThreadGroups(region.extent.width, threadsPerGroup[0]), RpmUtil::MinThreadGroups(region.extent.height, threadsPerGroup[1]), RpmUtil::MinThreadGroups(1, threadsPerGroup[2])); } pCmdBuffer->CmdRestoreComputeState(ComputeStatePipelineAndUserData); } // ===================================================================================================================== void RsrcProcMgr::CmdGfxDccToDisplayDcc( GfxCmdBuffer* pCmdBuffer, const IImage& image ) const { HwlGfxDccToDisplayDcc(pCmdBuffer, static_cast<const Pal::Image&>(image)); } // ===================================================================================================================== // Put displayDCC memory itself back into a "fully decompressed" state. void RsrcProcMgr::CmdDisplayDccFixUp( GfxCmdBuffer* pCmdBuffer, const IImage& image ) const { InitDisplayDcc(pCmdBuffer, static_cast<const Pal::Image&>(image)); } } // Pal
; A049643: Number of fractions in Farey series of order n. ; 0,2,3,5,7,11,13,19,23,29,33,43,47,59,65,73,81,97,103,121,129,141,151,173,181,201,213,231,243,271,279,309,325,345,361,385,397,433,451,475,491,531,543,585,605,629,651,697,713,755,775,807,831,883,901,941,965,1001,1029,1087,1103,1163,1193,1229,1261,1309,1329,1395,1427,1471,1495,1565,1589,1661,1697,1737,1773,1833,1857,1935,1967,2021,2061,2143,2167,2231,2273,2329,2369,2457,2481,2553,2597,2657,2703,2775,2807,2903,2945,3005 mov $1,3 mov $3,1 lpb $0 sub $0,1 mov $2,$0 max $2,0 seq $2,10 ; Euler totient function phi(n): count numbers <= n and prime to n. add $1,$2 lpe add $1,$2 add $1,2 mul $3,2 add $1,$3 sub $1,7 mov $0,$1
; A124867: Numbers that are the sum of 3 distinct primes. ; 10,12,14,15,16,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81 add $0,2 mov $2,6 div $2,$0 add $0,4 sub $0,$2 add $0,7 mov $1,$0
#ifdef USE_CUDA #include <cuda_runtime_api.h> #include <openpose/gpu/cuda.hpp> #endif #include <openpose/core/enumClasses.hpp> #include <openpose/utilities/fastMath.hpp> #include <openpose/pose/poseExtractorNet.hpp> namespace op { bool heatMapTypesHas(const std::vector<HeatMapType>& heatMapTypes, const HeatMapType heatMapType) { try { for (auto heatMapTypeVector : heatMapTypes) if (heatMapTypeVector == heatMapType) return true; return false; } catch (const std::exception& e) { error(e.what(), __LINE__, __FUNCTION__, __FILE__); return false; } } int getNumberHeatMapChannels(const std::vector<HeatMapType>& heatMapTypes, const PoseModel poseModel) { try { auto numberHeatMapChannels = 0; if (heatMapTypesHas(heatMapTypes, HeatMapType::Parts)) numberHeatMapChannels += getPoseNumberBodyParts(poseModel); if (heatMapTypesHas(heatMapTypes, HeatMapType::Background)) numberHeatMapChannels += 1; if (heatMapTypesHas(heatMapTypes, HeatMapType::PAFs)) numberHeatMapChannels += (int)getPosePartPairs(poseModel).size(); return numberHeatMapChannels; } catch (const std::exception& e) { error(e.what(), __LINE__, __FUNCTION__, __FILE__); return 0; } } PoseExtractorNet::PoseExtractorNet(const PoseModel poseModel, const std::vector<HeatMapType>& heatMapTypes, const ScaleMode heatMapScaleMode, const bool addPartCandidates, const bool maximizePositives) : mPoseModel{poseModel}, mNetOutputSize{0,0}, mHeatMapTypes{heatMapTypes}, mHeatMapScaleMode{heatMapScaleMode}, mAddPartCandidates{addPartCandidates} { try { // Error check if (mHeatMapScaleMode != ScaleMode::ZeroToOne && mHeatMapScaleMode != ScaleMode::PlusMinusOne && mHeatMapScaleMode != ScaleMode::UnsignedChar && mHeatMapScaleMode != ScaleMode::NoScale) error("The ScaleMode heatMapScaleMode must be ZeroToOne, PlusMinusOne, UnsignedChar, or NoScale.", __LINE__, __FUNCTION__, __FILE__); // Properties - Init to 0 for (auto& property : mProperties) property = 0.; // Properties - Fill default values mProperties[(int)PoseProperty::NMSThreshold] = getPoseDefaultNmsThreshold(mPoseModel, maximizePositives); mProperties[(int)PoseProperty::ConnectInterMinAboveThreshold] = getPoseDefaultConnectInterMinAboveThreshold(maximizePositives); mProperties[(int)PoseProperty::ConnectInterThreshold] = getPoseDefaultConnectInterThreshold( mPoseModel, maximizePositives); mProperties[(int)PoseProperty::ConnectMinSubsetCnt] = getPoseDefaultMinSubsetCnt(maximizePositives); mProperties[(int)PoseProperty::ConnectMinSubsetScore] = getPoseDefaultConnectMinSubsetScore( maximizePositives); } catch (const std::exception& e) { error(e.what(), __LINE__, __FUNCTION__, __FILE__); } } PoseExtractorNet::~PoseExtractorNet() { } void PoseExtractorNet::initializationOnThread() { try { // Get thread id mThreadId = {std::this_thread::get_id()}; // Deep net initialization netInitializationOnThread(); } catch (const std::exception& e) { error(e.what(), __LINE__, __FUNCTION__, __FILE__); } } Array<float> PoseExtractorNet::getHeatMapsCopy() const { try { checkThread(); Array<float> heatMaps; if (!mHeatMapTypes.empty()) { #ifdef USE_CUDA cudaCheck(__LINE__, __FUNCTION__, __FILE__); #endif // Get heatmaps size const auto heatMapSize = getHeatMapSize(); // Allocate memory const auto numberHeatMapChannels = getNumberHeatMapChannels(mHeatMapTypes, mPoseModel); heatMaps.reset({numberHeatMapChannels, heatMapSize[2], heatMapSize[3]}); // Copy memory const auto channelOffset = heatMaps.getVolume(1, 2); const auto volumeBodyParts = getPoseNumberBodyParts(mPoseModel) * channelOffset; const auto volumePAFs = getPosePartPairs(mPoseModel).size() * channelOffset; auto totalOffset = 0u; // Body parts if (heatMapTypesHas(mHeatMapTypes, HeatMapType::Parts)) { #ifdef USE_CUDA cudaMemcpy(heatMaps.getPtr(), getHeatMapGpuConstPtr(), volumeBodyParts * sizeof(float), cudaMemcpyDeviceToHost); #else const auto* heatMapCpuPtr = getHeatMapCpuConstPtr(); std::copy(heatMapCpuPtr, heatMapCpuPtr+volumeBodyParts, heatMaps.getPtr()); #endif if (mHeatMapScaleMode != ScaleMode::NoScale) { // Change from [0,1] to [-1,1] if (mHeatMapScaleMode == ScaleMode::PlusMinusOne) for (auto i = 0u ; i < volumeBodyParts ; i++) heatMaps[i] = fastTruncate(heatMaps[i]) * 2.f - 1.f; // [0, 255] else if (mHeatMapScaleMode == ScaleMode::UnsignedChar) for (auto i = 0u ; i < volumeBodyParts ; i++) heatMaps[i] = (float)intRound(fastTruncate(heatMaps[i]) * 255.f); // Avoid values outside original range else for (auto i = 0u ; i < volumeBodyParts ; i++) heatMaps[i] = fastTruncate(heatMaps[i]); } totalOffset += (unsigned int)volumeBodyParts; } // Background if (heatMapTypesHas(mHeatMapTypes, HeatMapType::Background)) { auto* heatMapsPtr = heatMaps.getPtr() + totalOffset; #ifdef USE_CUDA cudaMemcpy(heatMapsPtr, getHeatMapGpuConstPtr() + volumeBodyParts, channelOffset * sizeof(float), cudaMemcpyDeviceToHost); #else const auto* heatMapCpuPtr = getHeatMapCpuConstPtr(); std::copy(heatMapCpuPtr + volumeBodyParts, heatMapCpuPtr + volumeBodyParts + channelOffset, heatMapsPtr); #endif if (mHeatMapScaleMode != ScaleMode::NoScale) { // Change from [0,1] to [-1,1] if (mHeatMapScaleMode == ScaleMode::PlusMinusOne) for (auto i = 0u ; i < channelOffset ; i++) heatMapsPtr[i] = fastTruncate(heatMapsPtr[i]) * 2.f - 1.f; // [0, 255] else if (mHeatMapScaleMode == ScaleMode::UnsignedChar) for (auto i = 0u ; i < channelOffset ; i++) heatMapsPtr[i] = (float)intRound(fastTruncate(heatMapsPtr[i]) * 255.f); // Avoid values outside original range else for (auto i = 0u ; i < channelOffset ; i++) heatMapsPtr[i] = fastTruncate(heatMapsPtr[i]); } totalOffset += (unsigned int)channelOffset; } // PAFs if (heatMapTypesHas(mHeatMapTypes, HeatMapType::PAFs)) { auto* heatMapsPtr = heatMaps.getPtr() + totalOffset; #ifdef USE_CUDA cudaMemcpy(heatMapsPtr, getHeatMapGpuConstPtr() + volumeBodyParts + channelOffset, volumePAFs * sizeof(float), cudaMemcpyDeviceToHost); #else const auto* heatMapCpuPtr = getHeatMapCpuConstPtr(); std::copy(heatMapCpuPtr + volumeBodyParts + channelOffset, heatMapCpuPtr + volumeBodyParts + channelOffset + volumePAFs, heatMapsPtr); #endif if (mHeatMapScaleMode != ScaleMode::NoScale) { // Change from [-1,1] to [0,1]. Note that PAFs are in [-1,1] if (mHeatMapScaleMode == ScaleMode::ZeroToOne) for (auto i = 0u ; i < volumePAFs ; i++) heatMapsPtr[i] = fastTruncate(heatMapsPtr[i], -1.f) * 0.5f + 0.5f; // [0, 255] else if (mHeatMapScaleMode == ScaleMode::UnsignedChar) for (auto i = 0u ; i < volumePAFs ; i++) heatMapsPtr[i] = (float)intRound( fastTruncate(heatMapsPtr[i], -1.f) * 128.5f + 128.5f ); // Avoid values outside original range else for (auto i = 0u ; i < volumePAFs ; i++) heatMapsPtr[i] = fastTruncate(heatMapsPtr[i], -1.f); } totalOffset += (unsigned int)volumePAFs; } // Copy all at once // cudaMemcpy(heatMaps.getPtr(), getHeatMapGpuConstPtr(), heatMaps.getVolume() * sizeof(float), // cudaMemcpyDeviceToHost); } #ifdef USE_CUDA cudaCheck(__LINE__, __FUNCTION__, __FILE__); #endif return heatMaps; } catch (const std::exception& e) { error(e.what(), __LINE__, __FUNCTION__, __FILE__); return Array<float>{}; } } std::vector<std::vector<std::array<float,3>>> PoseExtractorNet::getCandidatesCopy() const { try { // Sanity check checkThread(); // Initialization std::vector<std::vector<std::array<float,3>>> candidates; // Fill candidates if (mAddPartCandidates) { const auto numberBodyParts = getPoseNumberBodyParts(mPoseModel); candidates.resize(numberBodyParts); const auto peaksArea = (POSE_MAX_PEOPLE+1) * 3; // Memory copy const auto* candidatesCpuPtr = getCandidatesCpuConstPtr(); for (auto part = 0u ; part < numberBodyParts ; part++) { const auto numberPartCandidates = intRound(candidatesCpuPtr[part*peaksArea]); candidates[part].resize(numberPartCandidates); const auto* partCandidatesPtr = &candidatesCpuPtr[part*peaksArea+3]; for (auto candidate = 0 ; candidate < numberPartCandidates ; candidate++) candidates[part][candidate] = {partCandidatesPtr[3*candidate] * mScaleNetToOutput, partCandidatesPtr[3*candidate+1] * mScaleNetToOutput, partCandidatesPtr[3*candidate+2]}; } } // Return return candidates; } catch (const std::exception& e) { error(e.what(), __LINE__, __FUNCTION__, __FILE__); return std::vector<std::vector<std::array<float,3>>>{}; } } Array<float> PoseExtractorNet::getPoseKeypoints() const { try { checkThread(); return mPoseKeypoints; } catch (const std::exception& e) { error(e.what(), __LINE__, __FUNCTION__, __FILE__); return Array<float>{}; } } Array<float> PoseExtractorNet::getPoseScores() const { try { checkThread(); return mPoseScores; } catch (const std::exception& e) { error(e.what(), __LINE__, __FUNCTION__, __FILE__); return Array<float>{}; } } float PoseExtractorNet::getScaleNetToOutput() const { try { checkThread(); return mScaleNetToOutput; } catch (const std::exception& e) { error(e.what(), __LINE__, __FUNCTION__, __FILE__); return 0.; } } double PoseExtractorNet::get(const PoseProperty property) const { try { return mProperties.at((int)property); } catch (const std::exception& e) { error(e.what(), __LINE__, __FUNCTION__, __FILE__); return 0.; } } void PoseExtractorNet::set(const PoseProperty property, const double value) { try { auto& propertyElement = mProperties.at((int)property); log("Property " + std::to_string((int)property) + " set from " + std::to_string(propertyElement) + " to " + std::to_string(value), Priority::High); propertyElement = {value}; } catch (const std::exception& e) { error(e.what(), __LINE__, __FUNCTION__, __FILE__); } } void PoseExtractorNet::increase(const PoseProperty property, const double value) { try { set(property, get(property) + value); } catch (const std::exception& e) { error(e.what(), __LINE__, __FUNCTION__, __FILE__); } } void PoseExtractorNet::clear() { try { mPoseKeypoints.reset(); mPoseScores.reset(); } catch (const std::exception& e) { error(e.what(), __LINE__, __FUNCTION__, __FILE__); } } void PoseExtractorNet::checkThread() const { try { if (mThreadId != std::this_thread::get_id()) error("The CPU/GPU pointer data cannot be accessed from a different thread.", __LINE__, __FUNCTION__, __FILE__); } catch (const std::exception& e) { error(e.what(), __LINE__, __FUNCTION__, __FILE__); } } }
/* Copyright 2013 Adobe Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ /**************************************************************************************************/ #include <cassert> #include <iostream> #include <adobe/cmath.hpp> #include <adobe/algorithm.hpp> /**************************************************************************************************/ int main() { bool result(true); // test that the types are visible: std::cout << "adobe::float_t(10.5f) ==" << adobe::float_t(10.5f) << std::endl; std::cout << "adobe::double_t(10.5) ==" << adobe::double_t(10.5) << std::endl; // round will round halfway point towards zero. const std::size_t test_cases(8); const double table[] = {1.0, 1.2, 1.5, 1.8, -1.0, -1.2, -1.5, -1.8}; const float tablef[] = {1.0f, 1.2f, 1.5f, 1.8f, -1.0f, -1.2f, -1.5f, -1.8f}; assert(sizeof(table) / sizeof(double) == test_cases); assert(sizeof(tablef) / sizeof(float) == test_cases); double result_table[test_cases]; float result_tablef[test_cases]; long result_tablel[test_cases]; { const double round_result[] = {1.0, 1.0, 2.0, 2.0, -1.0, -1.0, -2.0, -2.0}; adobe::transform(table, &result_table[0], (double (*)(double))(&adobe::round)); result &= adobe::equal(result_table, round_result); } { const long round_result[] = {1L, 1L, 2L, 2L, -1L, -1L, -2L, -2L}; adobe::transform(table, &result_tablel[0], (long (*)(double))(&adobe::lround)); result &= adobe::equal(result_tablel, round_result); } { const double round_result[] = {1.0, 1.0, 1.0, 1.0, -1.0, -1.0, -1.0, -1.0}; adobe::transform(table, &result_table[0], (double (*)(double))(&adobe::trunc)); result &= adobe::equal(result_table, round_result); } { const double round_result[] = {1.0, 1.0, 2.0, 2.0, -1.0, -1.0, -1.0, -2.0}; adobe::transform(table, &result_table[0], (double (*)(double))(&adobe::round_half_up)); result &= adobe::equal(result_table, round_result); } { const long round_result[] = {1L, 1L, 2L, 2L, -1L, -1L, -1L, -2L}; adobe::transform(table, &result_tablel[0], (long (*)(double))(&adobe::lround_half_up)); result &= adobe::equal(result_tablel, round_result); } { const float round_result[] = {1.0f, 1.0f, 2.0f, 2.0f, -1.0f, -1.0f, -2.0f, -2.0f}; adobe::transform(tablef, &result_tablef[0], (float (*)(float))(&adobe::round)); result &= adobe::equal(result_tablef, round_result); } { const long round_result[] = {1L, 1L, 2L, 2L, -1L, -1L, -2L, -2L}; adobe::transform(tablef, &result_tablel[0], (long (*)(float))(&adobe::lround)); result &= adobe::equal(result_tablel, round_result); } { const float round_result[] = {1.0f, 1.0f, 1.0f, 1.0f, -1.0f, -1.0f, -1.0f, -1.0f}; adobe::transform(tablef, &result_tablef[0], (float (*)(float))(&adobe::trunc)); result &= adobe::equal(result_tablef, round_result); } { const float round_result[] = {1.0f, 1.0f, 2.0f, 2.0f, -1.0f, -1.0f, -1.0f, -2.0f}; adobe::transform(tablef, &result_tablef[0], (float (*)(float))(&adobe::round_half_up)); result &= adobe::equal(result_tablef, round_result); } { const long round_result[] = {1L, 1L, 2L, 2L, -1L, -1L, -1L, -2L}; adobe::transform(tablef, &result_tablel[0], (long (*)(float))(&adobe::lround_half_up)); result &= adobe::equal(result_tablel, round_result); } return result ? 0 : 1; }
; The Windozz Project ; Copyright (C) 2018-2019 by the Windozz authors. bits 64 section .text ; void handle_exception(int number, uint64_t code, uint64_t rip) extern handle_exception extern lapic_eoi global int0_handler global int1_handler global int2_handler global int3_handler global int4_handler global int5_handler global int6_handler global int7_handler global int8_handler global int9_handler global int10_handler global int11_handler global int12_handler global int13_handler global int14_handler global int15_handler global int16_handler global int17_handler global int18_handler global int19_handler global int20_handler global int21_handler global int22_handler global int23_handler global int24_handler global int25_handler global int26_handler global int27_handler global int28_handler global int29_handler global int30_handler global int31_handler %macro pushaq 0 push rax push rbx push rcx push rdx push rsi push rdi push rbp push r8 push r9 push r10 push r11 push r12 push r13 push r14 push r15 %endmacro %macro popaq 0 pop r15 pop r14 pop r13 pop r12 pop r11 pop r10 pop r9 pop r8 pop rbp pop rdi pop rsi pop rdx pop rcx pop rbx pop rax %endmacro %macro exception 1 pushaq mov rdi, %1 mov rsi, 0 mov rdx, [rsp+120] ; rip call handle_exception popaq iretq %endmacro %macro exception_code 1 pushaq mov rdi, %1 mov rsi, [rsp+120] ; error code mov rdx, [rsp+128] ; rip call handle_exception popaq add rsp, 8 iretq %endmacro int0_handler: exception 0 int1_handler: exception 1 int2_handler: exception 2 int3_handler: exception 3 int4_handler: exception 4 int5_handler: exception 5 int6_handler: exception 6 int7_handler: exception 7 int8_handler: exception_code 8 int9_handler: exception 9 int10_handler: exception_code 10 int11_handler: exception_code 11 int12_handler: exception_code 12 int13_handler: exception_code 13 int14_handler: exception_code 14 int15_handler: exception 15 int16_handler: exception 16 int17_handler: exception_code 17 int18_handler: exception 18 int19_handler: exception 19 int20_handler: exception 20 int21_handler: exception 21 int22_handler: exception 22 int23_handler: exception 23 int24_handler: exception 24 int25_handler: exception 25 int26_handler: exception 26 int27_handler: exception 27 int28_handler: exception 28 int29_handler: exception 29 int30_handler: exception_code 30 int31_handler: exception 31 global pic0_spurious_stub pic0_spurious_stub: pushaq extern pic0_spurious call pic0_spurious popaq iretq global pic1_spurious_stub pic1_spurious_stub: pushaq extern pic1_spurious call pic1_spurious popaq iretq global lapic_spurious_stub lapic_spurious_stub: pushaq extern lapic_spurious call lapic_spurious popaq iretq global timer_irq_stub timer_irq_stub: pushaq mov r15, state mov [r15+0], rax mov [r15+8], rbx mov [r15+16], rcx mov [r15+24], rdx mov [r15+32], rsi mov [r15+40], rdi mov [r15+48], rbp mov [r15+56], r8 mov [r15+64], r9 mov [r15+72], r10 mov [r15+80], r11 mov [r15+88], r12 mov [r15+96], r13 mov [r15+104], r14 mov rax, [rsp] ; r15 mov [r15+112], rax mov rax, [rsp+120] ; rip mov [r15+120], rax mov rax, [rsp+128] ; cs mov [r15+144], rax add rax, 8 ; ds mov [r15+152], rax mov rax, [rsp+136] ; rflags mov [r15+136], rax mov rax, [rsp+144] ; rsp mov [r15+128], rax mov rdi, state extern timer_irq call timer_irq call lapic_eoi popaq iretq global acpi_sci_stub acpi_sci_stub: pushaq extern acpi_sci call acpi_sci call lapic_eoi popaq iretq section .data align 16 state: .rax dq 0 .rbx dq 0 .rcx dq 0 .rdx dq 0 .rsi dq 0 .rdi dq 0 .rbp dq 0 .r8 dq 0 .r9 dq 0 .r10 dq 0 .r11 dq 0 .r12 dq 0 .r13 dq 0 .r14 dq 0 .r15 dq 0 .rip dq 0 ; 120 .rsp dq 0 ; 128 .rflags dq 0 ; 136 .cs dq 0 ; 144 .ds dq 0 ; 152
/** @file A brief file description @section license License Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /*************************** -*- Mod: C++ -*- ****************************** SSLSNIConfig.cc Created On : 05/02/2017 Description: SNI based Configuration in ATS ****************************************************************************/ #include "P_SSLSNI.h" #include "tscore/Diags.h" #include "tscore/SimpleTokenizer.h" #include "P_SSLConfig.h" #include "tscore/ink_memory.h" #include "tscpp/util/TextView.h" #include "tscore/I_Layout.h" #include <sstream> #include <pcre.h> static ConfigUpdateHandler<SNIConfig> *sniConfigUpdate; static constexpr int OVECSIZE{30}; const NextHopProperty * SNIConfigParams::getPropertyConfig(const std::string &servername) const { const NextHopProperty *nps = nullptr; for (auto &&item : next_hop_list) { if (pcre_exec(item.match, nullptr, servername.c_str(), servername.length(), 0, 0, nullptr, 0) >= 0) { // Found a match nps = &item.prop; break; } } return nps; } void SNIConfigParams::loadSNIConfig() { for (auto &item : Y_sni.items) { auto ai = sni_action_list.emplace(sni_action_list.end()); ai->setGlobName(item.fqdn); Debug("ssl", "name: %s", item.fqdn.data()); // set SNI based actions to be called in the ssl_servername_only callback if (item.offer_h2.has_value()) { ai->actions.push_back(std::make_unique<ControlH2>(item.offer_h2.value())); } if (item.verify_client_level != 255) { ai->actions.push_back(std::make_unique<VerifyClient>(item.verify_client_level, item.verify_client_ca_certs.release())); } if (item.host_sni_policy != 255) { ai->actions.push_back(std::make_unique<HostSniPolicy>(item.host_sni_policy)); } if (!item.protocol_unset) { ai->actions.push_back(std::make_unique<TLSValidProtocols>(item.protocol_mask)); } if (item.tunnel_destination.length() > 0) { ai->actions.push_back(std::make_unique<TunnelDestination>(item.tunnel_destination, item.tunnel_decrypt, item.tls_upstream)); } ai->actions.push_back(std::make_unique<SNI_IpAllow>(item.ip_allow, item.fqdn)); // set the next hop properties auto nps = next_hop_list.emplace(next_hop_list.end()); SSLConfig::scoped_config params; // Load if we have at least specified the client certificate if (!item.client_cert.empty()) { nps->prop.client_cert_file = Layout::get()->relative_to(params->clientCertPathOnly, item.client_cert.data()); if (!item.client_key.empty()) { nps->prop.client_key_file = Layout::get()->relative_to(params->clientKeyPathOnly, item.client_key.data()); } params->getCTX(nps->prop.client_cert_file.c_str(), nps->prop.client_key_file.empty() ? nullptr : nps->prop.client_key_file.c_str(), params->clientCACertFilename, params->clientCACertPath); } nps->setGlobName(item.fqdn); nps->prop.verifyServerPolicy = item.verify_server_policy; nps->prop.verifyServerProperties = item.verify_server_properties; nps->prop.tls_upstream = item.tls_upstream; } // end for } int SNIConfig::configid = 0; /*definition of member functions of SNIConfigParams*/ SNIConfigParams::SNIConfigParams() {} std::pair<const actionVector *, ActionItem::Context> SNIConfigParams::get(const std::string &servername) const { int ovector[OVECSIZE]; ActionItem::Context context; for (const auto &retval : sni_action_list) { int length = servername.length(); if (retval.match == nullptr && length == 0) { return {&retval.actions, context}; } else if (auto offset = pcre_exec(retval.match, nullptr, servername.c_str(), length, 0, 0, ovector, OVECSIZE); offset >= 0) { if (offset == 1) { // first pair identify the portion of the subject string matched by the entire pattern if (ovector[0] == 0 && ovector[1] == length) { // full match return {&retval.actions, context}; } else { continue; } } // If contains groups if (offset == 0) { // reset to max if too many. offset = OVECSIZE / 3; } const char *psubStrMatchStr = nullptr; std::vector<std::string> groups; for (int strnum = 1; strnum < offset; strnum++) { pcre_get_substring(servername.c_str(), ovector, offset, strnum, &(psubStrMatchStr)); groups.emplace_back(psubStrMatchStr); } context._fqdn_wildcard_captured_groups = std::move(groups); if (psubStrMatchStr) { pcre_free_substring(psubStrMatchStr); } return {&retval.actions, context}; } } return {nullptr, context}; } int SNIConfigParams::Initialize() { sni_filename = ats_stringdup(RecConfigReadConfigPath("proxy.config.ssl.servername.filename")); Note("%s loading ...", sni_filename); struct stat sbuf; if (stat(sni_filename, &sbuf) == -1 && errno == ENOENT) { Note("%s failed to load", sni_filename); Warning("Loading SNI configuration - filename: %s doesn't exist", sni_filename); return 1; } ts::Errata zret = Y_sni.loader(sni_filename); if (!zret.isOK()) { std::stringstream errMsg; errMsg << zret; Error("%s failed to load: %s", sni_filename, errMsg.str().c_str()); return 1; } loadSNIConfig(); Note("%s finished loading", sni_filename); return 0; } SNIConfigParams::~SNIConfigParams() { // sni_action_list and next_hop_list should cleanup with the params object } /*definition of member functions of SNIConfig*/ void SNIConfig::startup() { sniConfigUpdate = new ConfigUpdateHandler<SNIConfig>(); sniConfigUpdate->attach("proxy.config.ssl.servername.filename"); reconfigure(); } void SNIConfig::reconfigure() { SNIConfigParams *params = new SNIConfigParams; params->Initialize(); configid = configProcessor.set(configid, params); } SNIConfigParams * SNIConfig::acquire() { return (SNIConfigParams *)configProcessor.get(configid); } void SNIConfig::release(SNIConfigParams *params) { configProcessor.release(configid, params); } // See if any of the client-side actions would trigger for this combination of servername and // client IP // host_sni_policy is an in/out paramter. It starts with the global policy from the records.config // setting proxy.config.http.host_sni_policy and is possibly overridden if the sni policy // contains a host_sni_policy entry bool SNIConfig::TestClientAction(const char *servername, const IpEndpoint &ep, int &host_sni_policy) { bool retval = false; SNIConfig::scoped_config params; const auto &actions = params->get(servername); if (actions.first) { for (auto &&item : *actions.first) { retval |= item->TestClientSNIAction(servername, ep, host_sni_policy); } } return retval; }
INCLUDE "clib_cfg.asm" SECTION code_math PUBLIC l_divs_16_16x16, l0_divs_16_16x16 ; compute: hl = hl / de, de = hl % de ; alters : af, bc, de, hl ; alternate entry (l_divs_16_16x16 - 1) ; exchanges de,hl ; alternate entry (l0_divs_16_16x16) ; skips divide by zero check IF __CLIB_OPT_IMATH <= 50 EXTERN l_small_divs_16_16x16, l0_small_divs_16_16x16 defc l_divs_16_16x16 = l_small_divs_16_16x16 defc l0_divs_16_16x16 = l0_small_divs_16_16x16 ENDIF IF __CLIB_OPT_IMATH > 50 EXTERN l_fast_divs_16_16x16, l0_fast_divs_16_16x16 defc l_divs_16_16x16 = l_fast_divs_16_16x16 defc l0_divs_16_16x16 = l0_fast_divs_16_16x16 ENDIF
; ; ; ; This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. ; ; Copyright 2007-2019 Broadcom Inc. All rights reserved. ; ; This is the default 5673 program for the Guenevere (BCM95695P24SX). ; ; To start it, use the following commands from BCM, ; where unit 0 is the 5670 and units 3 and 4 are the 5673s: ; ; 0:led load guenevere5670.hex ; 0:led auto on ; 3:led load guenevere5673.hex ; 3:led auto on ; 4:led load guenevere5673.hex ; 4:led auto on ; *:led start ; ; The 3 programs should be started all at once so that blinking ; is in sync across the 5673s. ; ; The Guenevere has 3 columns of 4 LEDs each as shown below: ; ; 5670 Unit 0 5673 Unit 3 5673 Unit 4 ; ------------- ------------- -------------- ; L04 E1 E1 ; A04 R1 R1 ; L05 T1 T1 ; A05 L1 L1 ; ; This program runs on each 5673 and controls only the rightmost ; two columns of LEDs. The guenevere5670 program runs on 5670. ; ; There is one bit per LED with the following colors: ; ZERO Green ; ONE Black ; ; The bits are shifted out in the following order: ; E1, R1, T1, L1 ; ; Current implementation: ; E1 reflects port 1 xe link enable ; R1 reflects port 1 xe receive activity ; T1 reflects port 1 xe transmit activity ; L1 reflects port 1 xe link up ; L04 reflects port 4 higig (External Higig 0) link up ; A04 reflects port 4 higig (External Higig 0) receive/transmit activity ; L05 reflects port 5 higig (External Higig 1) link up ; A05 reflects port 5 higig (External Higig 1) receive/transmit activity ; ; TICKS EQU 1 SECOND_TICKS EQU (30*TICKS) TGIG_BLINK_TICKS EQU (SECOND_TICKS/10) ld b,TGIG_BLINK_COUNT inc (b) ld a,(b) cmp a,TGIG_BLINK_TICKS jc up ld (b),0 up: port 0 call put send 4 put: pushst LINKEN tinv pack ld a,(TGIG_BLINK_COUNT) cmp a,TGIG_BLINK_TICKS/2 jc led_on led_off: pushst ONE pack pushst ONE pack jmp led_link led_on: pushst RX tinv pack pushst TX tinv pack led_link: pushst LINKUP tinv pack ret ; ; Symbolic names for the bits of the port status fields ; RX equ 0x0 ; received packet TX equ 0x1 ; transmitted packet COLL equ 0x2 ; collision indicator SPEED_C equ 0x3 ; 100 Mbps SPEED_M equ 0x4 ; 1000 Mbps DUPLEX equ 0x5 ; half/full duplex FLOW equ 0x6 ; flow control capable LINKUP equ 0x7 ; link down/up status LINKEN equ 0x8 ; link disabled/enabled status ZERO equ 0xE ; always 0 ONE equ 0xF ; always 1 PORTDATA equ 0x80 ; Size 2 bytes TGIG_BLINK_COUNT equ 0xc0
;; Licensed to the .NET Foundation under one or more agreements. ;; The .NET Foundation licenses this file to you under the MIT license. ;; See the LICENSE file in the project root for more information. include AsmMacros.inc PROBE_SAVE_FLAGS_EVERYTHING equ DEFAULT_FRAME_SAVE_FLAGS + PTFF_SAVE_ALL_SCRATCH PROBE_SAVE_FLAGS_RAX_IS_GCREF equ DEFAULT_FRAME_SAVE_FLAGS + PTFF_SAVE_RAX + PTFF_RAX_IS_GCREF ;; ;; See PUSH_COOP_PINVOKE_FRAME, this macro is very similar, but also saves RAX and accepts the register ;; bitmask in RCX ;; ;; On entry: ;; - BITMASK: bitmask describing pushes, may be volatile register or constant value ;; - RAX: managed function return value, may be an object or byref ;; - preserved regs: need to stay preserved, may contain objects or byrefs ;; - extraStack bytes of stack have already been allocated ;; ;; INVARIANTS ;; - The macro assumes it is called from a prolog, prior to a frame pointer being setup. ;; - All preserved registers remain unchanged from their values in managed code. ;; PUSH_PROBE_FRAME macro threadReg, trashReg, extraStack, BITMASK push_vol_reg rax ; save RAX, it might contain an objectref lea trashReg, [rsp + 10h + extraStack] push_vol_reg trashReg ; save caller's RSP push_nonvol_reg r15 ; save preserved registers push_nonvol_reg r14 ; .. push_nonvol_reg r13 ; .. push_nonvol_reg r12 ; .. push_nonvol_reg rdi ; .. push_nonvol_reg rsi ; .. push_nonvol_reg rbx ; .. push_vol_reg BITMASK ; save the register bitmask passed in by caller push_vol_reg threadReg ; Thread * (unused by stackwalker) push_nonvol_reg rbp ; save caller's RBP mov trashReg, [rsp + 12*8 + extraStack] ; Find the return address push_vol_reg trashReg ; save m_RIP lea trashReg, [rsp + 0] ; trashReg == address of frame ;; allocate scratch space and any required alignment alloc_stack 20h + 10h + (extraStack AND (10h-1)) ;; save xmm0 in case it's being used as a return value movdqa [rsp + 20h], xmm0 ; link the frame into the Thread mov [threadReg + OFFSETOF__Thread__m_pHackPInvokeTunnel], trashReg endm ;; ;; Remove the frame from a previous call to PUSH_PROBE_FRAME from the top of the stack and restore preserved ;; registers and return value to their values from before the probe was called (while also updating any ;; object refs or byrefs). ;; ;; NOTE: does NOT deallocate the 'extraStack' portion of the stack, the user of this macro must do that. ;; POP_PROBE_FRAME macro extraStack movdqa xmm0, [rsp + 20h] add rsp, 20h + 10h + (extraStack AND (10h-1)) + 8 pop rbp pop rax ; discard Thread* pop rax ; discard BITMASK pop rbx pop rsi pop rdi pop r12 pop r13 pop r14 pop r15 pop rax ; discard caller RSP pop rax endm ;; ;; Macro to clear the hijack state. This is safe to do because the suspension code will not Unhijack this ;; thread if it finds it at an IP that isn't managed code. ;; ;; Register state on entry: ;; RDX: thread pointer ;; ;; Register state on exit: ;; RCX: trashed ;; ClearHijackState macro xor ecx, ecx mov [rdx + OFFSETOF__Thread__m_ppvHijackedReturnAddressLocation], rcx mov [rdx + OFFSETOF__Thread__m_pvHijackedReturnAddress], rcx endm ;; ;; The prolog for all GC suspension hijacks (normal and stress). Fixes up the hijacked return address, and ;; clears the hijack state. ;; ;; Register state on entry: ;; All registers correct for return to the original return address. ;; ;; Register state on exit: ;; RCX: trashed ;; RDX: thread pointer ;; FixupHijackedCallstack macro ;; rdx <- GetThread(), TRASHES rcx INLINE_GETTHREAD rdx, rcx ;; ;; Fix the stack by pushing the original return address ;; mov rcx, [rdx + OFFSETOF__Thread__m_pvHijackedReturnAddress] push rcx ClearHijackState endm ;; ;; Set the Thread state and wait for a GC to complete. ;; ;; Register state on entry: ;; RBX: thread pointer ;; ;; Register state on exit: ;; RBX: thread pointer ;; All other registers trashed ;; EXTERN RhpWaitForGCNoAbort : PROC WaitForGCCompletion macro test dword ptr [rbx + OFFSETOF__Thread__m_ThreadStateFlags], TSF_SuppressGcStress + TSF_DoNotTriggerGc jnz @F mov rcx, [rbx + OFFSETOF__Thread__m_pHackPInvokeTunnel] call RhpWaitForGCNoAbort @@: endm EXTERN RhpPInvokeExceptionGuard : PROC ;; ;; ;; ;; GC Probe Hijack targets ;; ;; NESTED_ENTRY RhpGcProbeHijackScalar, _TEXT, RhpPInvokeExceptionGuard END_PROLOGUE FixupHijackedCallstack mov ecx, DEFAULT_FRAME_SAVE_FLAGS jmp RhpGcProbe NESTED_END RhpGcProbeHijackScalar, _TEXT NESTED_ENTRY RhpGcProbeHijackObject, _TEXT, RhpPInvokeExceptionGuard END_PROLOGUE FixupHijackedCallstack mov ecx, DEFAULT_FRAME_SAVE_FLAGS + PTFF_SAVE_RAX + PTFF_RAX_IS_GCREF jmp RhpGcProbe NESTED_END RhpGcProbeHijackObject, _TEXT NESTED_ENTRY RhpGcProbeHijackByref, _TEXT, RhpPInvokeExceptionGuard END_PROLOGUE FixupHijackedCallstack mov ecx, DEFAULT_FRAME_SAVE_FLAGS + PTFF_SAVE_RAX + PTFF_RAX_IS_BYREF jmp RhpGcProbe NESTED_END RhpGcProbeHijackByref, _TEXT ifdef FEATURE_GC_STRESS ;; ;; ;; GC Stress Hijack targets ;; ;; LEAF_ENTRY RhpGcStressHijackScalar, _TEXT FixupHijackedCallstack mov ecx, DEFAULT_FRAME_SAVE_FLAGS jmp RhpGcStressProbe LEAF_END RhpGcStressHijackScalar, _TEXT LEAF_ENTRY RhpGcStressHijackObject, _TEXT FixupHijackedCallstack mov ecx, DEFAULT_FRAME_SAVE_FLAGS + PTFF_SAVE_RAX + PTFF_RAX_IS_GCREF jmp RhpGcStressProbe LEAF_END RhpGcStressHijackObject, _TEXT LEAF_ENTRY RhpGcStressHijackByref, _TEXT FixupHijackedCallstack mov ecx, DEFAULT_FRAME_SAVE_FLAGS + PTFF_SAVE_RAX + PTFF_RAX_IS_BYREF jmp RhpGcStressProbe LEAF_END RhpGcStressHijackByref, _TEXT ;; ;; Worker for our GC stress probes. Do not call directly!! ;; Instead, go through RhpGcStressHijack{Scalar|Object|Byref}. ;; This worker performs the GC Stress work and returns to the original return address. ;; ;; Register state on entry: ;; RDX: thread pointer ;; RCX: register bitmask ;; ;; Register state on exit: ;; Scratch registers, except for RAX, have been trashed ;; All other registers restored as they were when the hijack was first reached. ;; NESTED_ENTRY RhpGcStressProbe, _TEXT PUSH_PROBE_FRAME rdx, rax, 0, rcx END_PROLOGUE call REDHAWKGCINTERFACE__STRESSGC POP_PROBE_FRAME 0 ret NESTED_END RhpGcStressProbe, _TEXT endif ;; FEATURE_GC_STRESS EXTERN RhpThrowHwEx : PROC NESTED_ENTRY RhpGcProbe, _TEXT test [RhpTrapThreads], TrapThreadsFlags_TrapThreads jnz @f ret @@: PUSH_PROBE_FRAME rdx, rax, 0, rcx END_PROLOGUE mov rbx, rdx WaitForGCCompletion mov rax, [rbx + OFFSETOF__Thread__m_pHackPInvokeTunnel] test dword ptr [rax + OFFSETOF__PInvokeTransitionFrame__m_Flags], PTFF_THREAD_ABORT jnz Abort POP_PROBE_FRAME 0 ret Abort: POP_PROBE_FRAME 0 mov rcx, STATUS_REDHAWK_THREAD_ABORT pop rdx ;; return address as exception RIP jmp RhpThrowHwEx ;; Throw the ThreadAbortException as a special kind of hardware exception NESTED_END RhpGcProbe, _TEXT LEAF_ENTRY RhpGcPoll, _TEXT ; ; loop hijacking is used instead ; int 3 LEAF_END RhpGcPoll, _TEXT LEAF_ENTRY RhpGcPollStress, _TEXT ; ; loop hijacking is used instead ; int 3 LEAF_END RhpGcPollStress, _TEXT ifdef FEATURE_GC_STRESS ;; PAL_LIMITED_CONTEXT, 6 xmm regs to save, 2 scratch regs to save, plus 20h bytes for scratch space RhpHijackForGcStress_FrameSize equ SIZEOF__PAL_LIMITED_CONTEXT + 6*10h + 2*8h + 20h ; ----------------------------------------------------------------------------------------------------------- ; RhpHijackForGcStress ; ; Called at the beginning of the epilog when a method is bound with /gcstress ; ; N.B. -- Leaf frames may not have aligned the stack or reserved any scratch space on the stack. Also, in ; order to have a resonable stacktrace in the debugger, we must use the .pushframe unwind directive. ; ; N.B. #2 -- The "EH jump epilog" codegen depends on rcx/rdx being preserved across this call. We currently ; will trash R8-R11, but we can do better, if necessary. ; NESTED_ENTRY RhpHijackForGcStress, _TEXT lea r10, [rsp+8] ;; save the original RSP (prior to call) mov r11, [rsp] ;; get the return address ;; Align the stack and rsp, -16 ;; Push the expected "machine frame" for the unwinder to see. All that it looks at is the RSP and ;; RIP, so we push zero for the others. xor r8, r8 push r8 ;; just aligning the stack push r8 ;; SS push r10 ;; original RSP push r8 ;; EFLAGS push r8 ;; CS push r11 ;; return address ; Tell the unwinder that the frame is there now .pushframe alloc_stack RhpHijackForGcStress_FrameSize END_PROLOGUE ;; Save xmm scratch regs -- this is probably overkill, only the return value reg is ;; likely to be interesting at this point, but it's a bit ambiguous. movdqa [rsp + 20h + 0*10h], xmm0 movdqa [rsp + 20h + 1*10h], xmm1 movdqa [rsp + 20h + 2*10h], xmm2 movdqa [rsp + 20h + 3*10h], xmm3 movdqa [rsp + 20h + 4*10h], xmm4 movdqa [rsp + 20h + 5*10h], xmm5 mov [rsp + 20h + 6*10h + 0*8h], rcx mov [rsp + 20h + 6*10h + 1*8h], rdx ;; ;; Setup a PAL_LIMITED_CONTEXT that looks like what you'd get if you had suspended this thread at the ;; IP after the call to this helper. ;; ;; This is very likely overkill since the calculation of the return address should only need RSP and ;; RBP, but this is test code, so I'm not too worried about efficiency. ;; mov [rsp + 20h + 6*10h + 2*8h + OFFSETOF__PAL_LIMITED_CONTEXT__IP], r11 ; rip at callsite mov [rsp + 20h + 6*10h + 2*8h + OFFSETOF__PAL_LIMITED_CONTEXT__Rsp], r10 ; rsp at callsite mov [rsp + 20h + 6*10h + 2*8h + OFFSETOF__PAL_LIMITED_CONTEXT__Rbp], rbp mov [rsp + 20h + 6*10h + 2*8h + OFFSETOF__PAL_LIMITED_CONTEXT__Rdi], rdi mov [rsp + 20h + 6*10h + 2*8h + OFFSETOF__PAL_LIMITED_CONTEXT__Rsi], rsi mov [rsp + 20h + 6*10h + 2*8h + OFFSETOF__PAL_LIMITED_CONTEXT__Rax], rax mov [rsp + 20h + 6*10h + 2*8h + OFFSETOF__PAL_LIMITED_CONTEXT__Rbx], rbx mov [rsp + 20h + 6*10h + 2*8h + OFFSETOF__PAL_LIMITED_CONTEXT__R12], r12 mov [rsp + 20h + 6*10h + 2*8h + OFFSETOF__PAL_LIMITED_CONTEXT__R13], r13 mov [rsp + 20h + 6*10h + 2*8h + OFFSETOF__PAL_LIMITED_CONTEXT__R14], r14 mov [rsp + 20h + 6*10h + 2*8h + OFFSETOF__PAL_LIMITED_CONTEXT__R15], r15 lea rcx, [rsp + 20h + 6*10h + 2*8h] ;; address of PAL_LIMITED_CONTEXT call THREAD__HIJACKFORGCSTRESS ;; Note: we only restore the scratch registers here. No GC has occured, so restoring ;; the callee saved ones is unnecessary. mov rax, [rsp + 20h + 6*10h + 2*8h + OFFSETOF__PAL_LIMITED_CONTEXT__Rax] mov rcx, [rsp + 20h + 6*10h + 0*8h] mov rdx, [rsp + 20h + 6*10h + 1*8h] ;; Restore xmm scratch regs movdqa xmm0, [rsp + 20h + 0*10h] movdqa xmm1, [rsp + 20h + 1*10h] movdqa xmm2, [rsp + 20h + 2*10h] movdqa xmm3, [rsp + 20h + 3*10h] movdqa xmm4, [rsp + 20h + 4*10h] movdqa xmm5, [rsp + 20h + 5*10h] ;; epilog mov r10, [rsp + 20h + 6*10h + 2*8h + OFFSETOF__PAL_LIMITED_CONTEXT__Rsp] lea rsp, [r10 - 8] ;; adjust RSP to point back at the return address ret NESTED_END RhpHijackForGcStress, _TEXT endif ;; FEATURE_GC_STRESS ;; ;; The following functions are _jumped_ to when we need to transfer control from one method to another for EH ;; dispatch. These are needed to properly coordinate with the GC hijacking logic. We are essentially replacing ;; the return from the throwing method with a jump to the handler in the caller, but we need to be aware of ;; any return address hijack that may be in place for GC suspension. These routines use a quick test of the ;; return address against a specific GC hijack routine, and then fixup the stack pointer to what it would be ;; after a real return from the throwing method. Then, if we are not hijacked we can simply jump to the ;; handler in the caller. ;; ;; If we are hijacked, then we jump to a routine that will unhijack appropriatley and wait for the GC to ;; complete. There are also variants for GC stress. ;; ;; Note that at this point we are eiher hijacked or we are not, and this will not change until we return to ;; managed code. It is an invariant of the system that a thread will only attempt to hijack or unhijack ;; another thread while the target thread is suspended in managed code, and this is _not_ managed code. ;; ;; Register state on entry: ;; RAX: pointer to this function (i.e., trash) ;; RCX: reference to the exception object. ;; RDX: handler address we want to jump to. ;; RBX, RSI, RDI, RBP, and R12-R15 are all already correct for return to the caller. ;; The stack still contains the return address. ;; ;; Register state on exit: ;; RSP: what it would be after a complete return to the caler. ;; RDX: TRASHED ;; RTU_EH_JUMP_HELPER macro funcName, hijackFuncName, isStress, stressFuncName LEAF_ENTRY funcName, _TEXT lea rax, [hijackFuncName] cmp [rsp], rax je RhpGCProbeForEHJump IF isStress EQ 1 lea rax, [stressFuncName] cmp [rsp], rax je RhpGCStressProbeForEHJump ENDIF ;; We are not hijacked, so we can return to the handler. ;; We return to keep the call/return prediction balanced. mov [rsp], rdx ; Update the return address ret LEAF_END funcName, _TEXT endm ;; We need an instance of the helper for each possible hijack function. The binder has enough ;; information to determine which one we need to use for any function. RTU_EH_JUMP_HELPER RhpEHJumpScalar, RhpGcProbeHijackScalar, 0, 0 RTU_EH_JUMP_HELPER RhpEHJumpObject, RhpGcProbeHijackObject, 0, 0 RTU_EH_JUMP_HELPER RhpEHJumpByref, RhpGcProbeHijackByref, 0, 0 ifdef FEATURE_GC_STRESS RTU_EH_JUMP_HELPER RhpEHJumpScalarGCStress, RhpGcProbeHijackScalar, 1, RhpGcStressHijackScalar RTU_EH_JUMP_HELPER RhpEHJumpObjectGCStress, RhpGcProbeHijackObject, 1, RhpGcStressHijackObject RTU_EH_JUMP_HELPER RhpEHJumpByrefGCStress, RhpGcProbeHijackByref, 1, RhpGcStressHijackByref endif ;; ;; Macro to setup our frame and adjust the location of the EH object reference for EH jump probe funcs. ;; ;; Register state on entry: ;; RAX: scratch ;; RCX: reference to the exception object. ;; RDX: handler address we want to jump to. ;; RBX, RSI, RDI, RBP, and R12-R15 are all already correct for return to the caller. ;; The stack is as if we are just about to returned from the call ;; ;; Register state on exit: ;; RAX: reference to the exception object ;; RCX: scratch ;; RDX: thread pointer ;; EHJumpProbeProlog_extraStack = 1*8 EHJumpProbeProlog macro push_nonvol_reg rdx ; save the handler address so we can jump to it later mov rax, rcx ; move the ex object reference into rax so we can report it ;; rdx <- GetThread(), TRASHES rcx INLINE_GETTHREAD rdx, rcx ;; Fix the stack by patching the original return address mov rcx, [rdx + OFFSETOF__Thread__m_pvHijackedReturnAddress] mov [rsp + EHJumpProbeProlog_extraStack], rcx ClearHijackState ; TRASHES r10 PUSH_PROBE_FRAME rdx, r10, EHJumpProbeProlog_extraStack, PROBE_SAVE_FLAGS_RAX_IS_GCREF END_PROLOGUE endm ;; ;; Macro to re-adjust the location of the EH object reference, cleanup the frame, and make the ;; final jump to the handler for EH jump probe funcs. ;; ;; Register state on entry: ;; RAX: reference to the exception object ;; RCX: scratch ;; RDX: scratch ;; ;; Register state on exit: ;; RSP: correct for return to the caller ;; RCX: reference to the exception object ;; RDX: trashed ;; EHJumpProbeEpilog macro POP_PROBE_FRAME EHJumpProbeProlog_extraStack mov rcx, rax ; Put the EX obj ref back into rcx for the handler. pop rax ; Recover the handler address. mov [rsp], rax ; Update the return address ret endm ;; ;; We are hijacked for a normal GC (not GC stress), so we need to unhijcak and wait for the GC to complete. ;; ;; Register state on entry: ;; RAX: scratch ;; RCX: reference to the exception object. ;; RDX: handler address we want to jump to. ;; RBX, RSI, RDI, RBP, and R12-R15 are all already correct for return to the caller. ;; The stack is as if we have tail called to this function (rsp points to return address). ;; ;; Register state on exit: ;; RSP: correct for return to the caller ;; RBP: previous ebp frame ;; RCX: reference to the exception object ;; NESTED_ENTRY RhpGCProbeForEHJump, _TEXT EHJumpProbeProlog ifdef _DEBUG ;; ;; If we get here, then we have been hijacked for a real GC, and our SyncState must ;; reflect that we've been requested to synchronize. test [RhpTrapThreads], TrapThreadsFlags_TrapThreads jnz @F call RhDebugBreak @@: endif ;; _DEBUG mov rbx, rdx WaitForGCCompletion EHJumpProbeEpilog NESTED_END RhpGCProbeForEHJump, _TEXT ifdef FEATURE_GC_STRESS ;; ;; We are hijacked for GC Stress (not a normal GC) so we need to invoke the GC stress helper. ;; ;; Register state on entry: ;; RAX: scratch ;; RCX: reference to the exception object. ;; RDX: handler address we want to jump to. ;; RBX, RSI, RDI, RBP, and R12-R15 are all already correct for return to the caller. ;; The stack is as if we have tail called to this function (rsp points to return address). ;; ;; Register state on exit: ;; RSP: correct for return to the caller ;; RBP: previous ebp frame ;; RCX: reference to the exception object ;; NESTED_ENTRY RhpGCStressProbeForEHJump, _TEXT EHJumpProbeProlog call REDHAWKGCINTERFACE__STRESSGC EHJumpProbeEpilog NESTED_END RhpGCStressProbeForEHJump, _TEXT g_pTheRuntimeInstance equ ?g_pTheRuntimeInstance@@3PEAVRuntimeInstance@@EA EXTERN g_pTheRuntimeInstance : QWORD RuntimeInstance__ShouldHijackLoopForGcStress equ ?ShouldHijackLoopForGcStress@RuntimeInstance@@QEAA_N_K@Z EXTERN RuntimeInstance__ShouldHijackLoopForGcStress : PROC endif ;; FEATURE_GC_STRESS EXTERN RecoverLoopHijackTarget : PROC EXTERN g_fGcStressStarted : DWORD EXTERN g_fHasFastFxsave : BYTE FXSAVE_SIZE equ 512 ;; Trap a loop to GC. ;; Set up the P/Invoke transition frame with the original loop target as the safe point. ;; All registers, both volatile and non-volatile, are preserved. ;; Input: ModuleHeader, chunk starting index and chunk sub-index which are used to get the original loop target ;; The function is not called but jumped directly NESTED_ENTRY RhpLoopHijack, _TEXT sizeof_OutgoingScratchSpace equ 20h sizeof_PInvokeFrame equ OFFSETOF__PInvokeTransitionFrame__m_PreservedRegs + 15*8 sizeof_XmmAlignPad equ 8 sizeof_XmmSave equ FXSAVE_SIZE sizeof_MachineFrame equ 6*8 sizeof_ThunkPushedArgs equ 4*8 ;; eflags, ModuleHeader *, chunk starting index, chunk sub-index sizeof_FixedFrame equ sizeof_OutgoingScratchSpace + sizeof_PInvokeFrame + sizeof_XmmAlignPad + sizeof_XmmSave + sizeof_MachineFrame ;; On the stack on entry: ;; [rsp ] -> ModuleHeader * ;; [rsp + 8] -> chunk starting index ;; [rsp + 10] -> chunk sub-index (0-256) BEWARE: this has been sign-extended, but it is unsigned ;; save eflags before we trash them pushfq ;; What we want to get to: ;; ;; [rsp ] -> outgoing scratch area ;; ;; [rsp + 20] -> m_RIP -------| ;; [rsp + 28] -> m_FramePointer | ;; [rsp + 30] -> m_pThread | ;; [rsp + 38] -> m_Flags / m_dwAlignPad2 | ;; [rsp + 40] -> rbx save | ;; [rsp + 48] -> rsi save | ;; [rsp + 50] -> rdi save | ;; [rsp + 58] -> r12 save | ;; [rsp + 60] -> r13 save | ;; [rsp + 68] -> r14 save | PInvokeTransitionFrame ;; [rsp + 70] -> r15 save | ;; [rsp + 78] -> rsp save | ;; [rsp + 80] -> rax save | ;; [rsp + 88] -> rcx save | ;; [rsp + 90] -> rdx save | ;; [rsp + 98] -> r8 save | ;; [rsp + a0] -> r9 save | ;; [rsp + a8] -> r10 save | ;; [rsp + b0] -> r11 save -------| ;; ;; [rsp + b8] -> [XmmAlignPad] ;; ;; [rsp + c0] -> FXSAVE area ;; ;; [rsp +2c0] | RIP | ;; [rsp +2c8] | CS | ;; [rsp +2d0] | EFLAGS | <-- 'machine frame' ;; [rsp +2d8] | RSP | ;; [rsp +2e0] | SS | ;; [rsp +2e8] | padding | ;; ;; [rsp +2f0] [optional stack alignment] ;; ;; [PSP - 20] -> eflags save ;; [PSP - 18] -> ModuleHeader * ;; [PSP - 10] -> chunk starting index ;; [PSP - 8] -> chunk sub-index (0-256) BEWARE: this has been sign-extended, but it is unsigned ;; [PSP] -> caller's frame test rsp, 0Fh jz AlreadyAligned sub rsp, sizeof_XmmAlignPad + sizeof_XmmSave + sizeof_MachineFrame + 8 ; +8 to align RSP push r11 ; save incoming R11 into save location lea r11, [rsp + 8 + sizeof_XmmAlignPad + sizeof_XmmSave + sizeof_MachineFrame + 8 + sizeof_ThunkPushedArgs] jmp PspCalculated AlreadyAligned: sub rsp, sizeof_XmmAlignPad + sizeof_XmmSave + sizeof_MachineFrame push r11 ; save incoming R11 into save location lea r11, [rsp + 8 + sizeof_XmmAlignPad + sizeof_XmmSave + sizeof_MachineFrame + sizeof_ThunkPushedArgs] PspCalculated: push r10 ; save incoming R10 into save location xor r10d, r10d ;; ;; Populate the 'machine frame' in the diagram above. We have only pushed up to the 'r10 save', so we have not ;; yet pushed 0xA8 bytes of that diagram. ;; ;; [rsp + {offset-in-target-frame-layout-diagram} - {as-yet-unpushed-stack-size}] mov [rsp + 2c0h - 0a8h], r10 ; init RIP to zero mov [rsp + 2c8h - 0a8h], r10 ; init CS to zero mov [rsp + 2d0h - 0a8h], r10 ; init EFLAGS to zero mov [rsp + 2d8h - 0a8h], r11 ; save PSP in the 'machine frame' mov [rsp + 2e0h - 0a8h], r10 ; init SS to zero .pushframe .allocstack sizeof_XmmAlignPad + sizeof_XmmSave + 2*8 ;; only 2 of the regs from the PInvokeTransitionFrame are on the stack push_vol_reg r9 push_vol_reg r8 push_vol_reg rdx push_vol_reg rcx push_vol_reg rax push_vol_reg r11 ; PSP gets saved into the PInvokeTransitionFrame push_nonvol_reg r15 push_nonvol_reg r14 push_nonvol_reg r13 push_nonvol_reg r12 push_nonvol_reg rdi push_nonvol_reg rsi push_nonvol_reg rbx push_vol_reg PROBE_SAVE_FLAGS_EVERYTHING ; m_Flags / m_dwAlignPad2 ;; rdx <- GetThread(), TRASHES rcx INLINE_GETTHREAD rdx, rcx push_vol_reg rdx ; m_pThread push_nonvol_reg rbp ; m_FramePointer push_vol_reg r10 ; m_RIP alloc_stack sizeof_OutgoingScratchSpace END_PROLOGUE mov rbx, r11 ; put PSP into RBX mov rsi, rdx ; put Thread* into RSI ; RBX is PSP ; RSI is Thread* fxsave [rsp + 0c0h] cmp [g_fHasFastFxsave], 0 ; fast fxsave won't save the xmm registers, so we must do it jz DontSaveXmmAgain ;; 0C0h -> offset of FXSAVE area ;; 0A0h -> offset of xmm0 save area within the FXSAVE area movdqa [rsp + 0c0h + 0a0h + 0*10h], xmm0 movdqa [rsp + 0c0h + 0a0h + 1*10h], xmm1 movdqa [rsp + 0c0h + 0a0h + 2*10h], xmm2 movdqa [rsp + 0c0h + 0a0h + 3*10h], xmm3 movdqa [rsp + 0c0h + 0a0h + 4*10h], xmm4 movdqa [rsp + 0c0h + 0a0h + 5*10h], xmm5 movdqa [rsp + 0c0h + 0a0h + 6*10h], xmm6 movdqa [rsp + 0c0h + 0a0h + 7*10h], xmm7 movdqa [rsp + 0c0h + 0a0h + 8*10h], xmm8 movdqa [rsp + 0c0h + 0a0h + 9*10h], xmm9 movdqa [rsp + 0c0h + 0a0h + 10*10h], xmm10 movdqa [rsp + 0c0h + 0a0h + 11*10h], xmm11 movdqa [rsp + 0c0h + 0a0h + 12*10h], xmm12 movdqa [rsp + 0c0h + 0a0h + 13*10h], xmm13 movdqa [rsp + 0c0h + 0a0h + 14*10h], xmm14 movdqa [rsp + 0c0h + 0a0h + 15*10h], xmm15 DontSaveXmmAgain: xor ecx, ecx ; Combine the two indexes mov cl, [r11 - 8h] ; ... add ecx, [r11 - 10h] ; ... mov rdx, [r11 - 18h] ; Load the ModuleHeader* ;; RCX contains full index now ;; RDX contains the ModuleHeader* call RecoverLoopHijackTarget mov [rsp + 2c0h], rax ; save original target address into 'machine frame' mov [rsp + 20h], rax ; save original target address into PInvokeTransitionFrame mov [rbx - 8], rax ; store original target address for our 'return' ; Early out if GC stress is currently suppressed. Do this after we have computed the real address to ; return to but before we link the transition frame onto m_pHackPInvokeTunnel (because hitting this ; condition implies we're running restricted callouts during a GC itself and we could end up ; overwriting a co-op frame set by the code that caused the GC in the first place, e.g. a GC.Collect ; call). test dword ptr [rsi + OFFSETOF__Thread__m_ThreadStateFlags], TSF_SuppressGcStress + TSF_DoNotTriggerGc jnz DoneWaitingForGc ; link the frame into the Thread lea rcx, [rsp + sizeof_OutgoingScratchSpace] ; rcx <- PInvokeTransitionFrame* mov [rsi + OFFSETOF__Thread__m_pHackPInvokeTunnel], rcx ;; ;; Unhijack this thread, if necessary. ;; INLINE_THREAD_UNHIJACK rsi, rax, rcx ;; trashes RAX, RCX ifdef FEATURE_GC_STRESS xor eax, eax cmp [g_fGcStressStarted], eax jz @F mov rdx, [rsp + 2c0h] mov rcx, [g_pTheRuntimeInstance] call RuntimeInstance__ShouldHijackLoopForGcStress cmp al, 0 je @F call REDHAWKGCINTERFACE__STRESSGC @@: endif ;; FEATURE_GC_STRESS lea rcx, [rsp + sizeof_OutgoingScratchSpace] ; calculate PInvokeTransitionFrame pointer call RhpWaitForGCNoAbort DoneWaitingForGc: ;; Prepare for our return by stashing a scratch register where we can pop it just before returning mov rcx, [rsp + 88h] ; get RCX save value mov [rbx - 10h], rcx ; store RCX save value into location for popping mov rcx, rbx ; RCX <- PSP fxrstor [rsp + 0c0h] cmp [g_fHasFastFxsave], 0 jz DontRestoreXmmAgain movdqa xmm0 , [rsp + 0c0h + 0a0h + 0*10h] movdqa xmm1 , [rsp + 0c0h + 0a0h + 1*10h] movdqa xmm2 , [rsp + 0c0h + 0a0h + 2*10h] movdqa xmm3 , [rsp + 0c0h + 0a0h + 3*10h] movdqa xmm4 , [rsp + 0c0h + 0a0h + 4*10h] movdqa xmm5 , [rsp + 0c0h + 0a0h + 5*10h] movdqa xmm6 , [rsp + 0c0h + 0a0h + 6*10h] movdqa xmm7 , [rsp + 0c0h + 0a0h + 7*10h] movdqa xmm8 , [rsp + 0c0h + 0a0h + 8*10h] movdqa xmm9 , [rsp + 0c0h + 0a0h + 9*10h] movdqa xmm10, [rsp + 0c0h + 0a0h + 10*10h] movdqa xmm11, [rsp + 0c0h + 0a0h + 11*10h] movdqa xmm12, [rsp + 0c0h + 0a0h + 12*10h] movdqa xmm13, [rsp + 0c0h + 0a0h + 13*10h] movdqa xmm14, [rsp + 0c0h + 0a0h + 14*10h] movdqa xmm15, [rsp + 0c0h + 0a0h + 15*10h] DontRestoreXmmAgain: add rsp, sizeof_OutgoingScratchSpace mov eax, [rsp + OFFSETOF__PInvokeTransitionFrame__m_Flags] test eax, PTFF_THREAD_ABORT pop rax ; m_RIP pop rbp ; m_FramePointer pop rax ; m_pThread pop rax ; m_Flags / m_dwAlign2 pop rbx pop rsi pop rdi pop r12 pop r13 pop r14 pop r15 pop rax ; RSP pop rax ; RAX save pop rdx ; RCX save (intentionally discarding it) pop rdx pop r8 pop r9 pop r10 pop r11 ;; RCX is PSP at this point and the stack looks like this: ;; [PSP - 20] -> eflags save ;; [PSP - 18] -> ModuleHeader * ;; [PSP - 10] -> rcx save ;; [PSP - 8] -> return address ;; [PSP] -> caller's frame ;; ;; The final step is to restore eflags, rcx, and return back to the loop target location. lea rsp, [rcx - 20h] jz @f ;; result of the test instruction before the pops above popfq ;; restore flags pop rcx ;; discard ModuleHeader* pop rcx ;; restore rcx mov rcx, STATUS_REDHAWK_THREAD_ABORT pop rdx ;; return address as exception RIP jmp RhpThrowHwEx ;; Throw the ThreadAbortException as a special kind of hardware exception @@: popfq ;; restore flags pop rcx ;; discard ModuleHeader* pop rcx ;; restore rcx ret NESTED_END RhpLoopHijack, _TEXT ;; Trap to GC. ;; Set up the P/Invoke transition frame with the return address as the safe point. ;; All registers, both volatile and non-volatile, are preserved. ;; The function should be called not jumped because it's expecting the return address NESTED_ENTRY RhpTrapToGC, _TEXT sizeof_OutgoingScratchSpace equ 20h sizeof_PInvokeFrame equ OFFSETOF__PInvokeTransitionFrame__m_PreservedRegs + 15*8 sizeof_XmmAlignPad equ 8 sizeof_XmmSave equ FXSAVE_SIZE sizeof_MachineFrame equ 6*8 sizeof_InitialPushedArgs equ 2*8 ;; eflags, return value sizeof_FixedFrame equ sizeof_OutgoingScratchSpace + sizeof_PInvokeFrame + sizeof_XmmAlignPad + sizeof_XmmSave + sizeof_MachineFrame ;; On the stack on entry: ;; [rsp ] -> Return address ;; save eflags before we trash them pushfq ;; What we want to get to: ;; ;; [rsp ] -> outgoing scratch area ;; ;; [rsp + 20] -> m_RIP -------| ;; [rsp + 28] -> m_FramePointer | ;; [rsp + 30] -> m_pThread | ;; [rsp + 38] -> m_Flags / m_dwAlignPad2 | ;; [rsp + 40] -> rbx save | ;; [rsp + 48] -> rsi save | ;; [rsp + 50] -> rdi save | ;; [rsp + 58] -> r12 save | ;; [rsp + 60] -> r13 save | ;; [rsp + 68] -> r14 save | PInvokeTransitionFrame ;; [rsp + 70] -> r15 save | ;; [rsp + 78] -> rsp save | ;; [rsp + 80] -> rax save | ;; [rsp + 88] -> rcx save | ;; [rsp + 90] -> rdx save | ;; [rsp + 98] -> r8 save | ;; [rsp + a0] -> r9 save | ;; [rsp + a8] -> r10 save | ;; [rsp + b0] -> r11 save -------| ;; ;; [rsp + b8] -> [XmmAlignPad] ;; ;; [rsp + c0] -> FXSAVE area ;; ;; [rsp +2c0] | RIP | ;; [rsp +2c8] | CS | ;; [rsp +2d0] | EFLAGS | <-- 'machine frame' ;; [rsp +2d8] | RSP | ;; [rsp +2e0] | SS | ;; [rsp +2e8] | padding | ;; ;; [rsp +2f0] [PSP] ;; [rsp +2f8] [optional stack alignment] ;; ;; [PSP - 10] -> eflags save ;; [PSP - 8] -> Return address ;; [PSP] -> caller's frame test rsp, 0Fh jz AlreadyAligned sub rsp, sizeof_XmmAlignPad + sizeof_XmmSave + sizeof_MachineFrame + 8 ; +8 to save PSP, push r11 ; save incoming R11 into save location lea r11, [rsp + 8 + sizeof_XmmAlignPad + sizeof_XmmSave + sizeof_MachineFrame + 8 + sizeof_InitialPushedArgs] jmp PspCalculated AlreadyAligned: sub rsp, sizeof_XmmAlignPad + sizeof_XmmSave + sizeof_MachineFrame + 16 ; +8 to save RSP, +8 to re-align PSP, push r11 ; save incoming R11 into save location lea r11, [rsp + 8 + sizeof_XmmAlignPad + sizeof_XmmSave + sizeof_MachineFrame + 16 + sizeof_InitialPushedArgs] PspCalculated: push r10 ; save incoming R10 into save location xor r10d, r10d ;; ;; Populate the 'machine frame' in the diagram above. We have only pushed up to the 'r10 save', so we have not ;; yet pushed 0xA8 bytes of that diagram. ;; ;; [rsp + {offset-in-target-frame-layout-diagram} - {as-yet-unpushed-stack-size}] mov [rsp + 2c0h - 0a8h], r10 ; init RIP to zero mov [rsp + 2c8h - 0a8h], r10 ; init CS to zero mov [rsp + 2d0h - 0a8h], r10 ; init EFLAGS to zero mov [rsp + 2d8h - 0a8h], r11 ; save PSP in the 'machine frame' mov [rsp + 2e0h - 0a8h], r10 ; init SS to zero mov [rsp + 2f0h - 0a8h], r11 ; save PSP .pushframe .allocstack sizeof_XmmAlignPad + sizeof_XmmSave + 2*8 ;; only 2 of the regs from the PInvokeTransitionFrame are on the stack push_vol_reg r9 push_vol_reg r8 push_vol_reg rdx push_vol_reg rcx push_vol_reg rax push_vol_reg r11 ; PSP gets saved into the PInvokeTransitionFrame push_nonvol_reg r15 push_nonvol_reg r14 push_nonvol_reg r13 push_nonvol_reg r12 push_nonvol_reg rdi push_nonvol_reg rsi push_nonvol_reg rbx push_vol_reg PROBE_SAVE_FLAGS_EVERYTHING ; m_Flags / m_dwAlignPad2 ;; rdx <- GetThread(), TRASHES rcx INLINE_GETTHREAD rdx, rcx push_vol_reg rdx ; m_pThread push_nonvol_reg rbp ; m_FramePointer push_vol_reg r10 ; m_RIP alloc_stack sizeof_OutgoingScratchSpace END_PROLOGUE mov rbx, r11 ; put PSP into RBX mov rsi, rdx ; put Thread* into RSI ; RBX is PSP ; RSI is Thread* fxsave [rsp + 0c0h] cmp [g_fHasFastFxsave], 0 ; fast fxsave won't save the xmm registers, so we must do it jz DontSaveXmmAgain ;; 0C0h -> offset of FXSAVE area ;; 0A0h -> offset of xmm0 save area within the FXSAVE area movdqa [rsp + 0c0h + 0a0h + 0*10h], xmm0 movdqa [rsp + 0c0h + 0a0h + 1*10h], xmm1 movdqa [rsp + 0c0h + 0a0h + 2*10h], xmm2 movdqa [rsp + 0c0h + 0a0h + 3*10h], xmm3 movdqa [rsp + 0c0h + 0a0h + 4*10h], xmm4 movdqa [rsp + 0c0h + 0a0h + 5*10h], xmm5 movdqa [rsp + 0c0h + 0a0h + 6*10h], xmm6 movdqa [rsp + 0c0h + 0a0h + 7*10h], xmm7 movdqa [rsp + 0c0h + 0a0h + 8*10h], xmm8 movdqa [rsp + 0c0h + 0a0h + 9*10h], xmm9 movdqa [rsp + 0c0h + 0a0h + 10*10h], xmm10 movdqa [rsp + 0c0h + 0a0h + 11*10h], xmm11 movdqa [rsp + 0c0h + 0a0h + 12*10h], xmm12 movdqa [rsp + 0c0h + 0a0h + 13*10h], xmm13 movdqa [rsp + 0c0h + 0a0h + 14*10h], xmm14 movdqa [rsp + 0c0h + 0a0h + 15*10h], xmm15 DontSaveXmmAgain: mov rax, [rbx - 8] mov [rsp + 2c0h], rax ; save return address into 'machine frame' mov [rsp + 20h], rax ; save return address into PInvokeTransitionFrame ; Early out if GC stress is currently suppressed. Do this after we have computed the real address to ; return to but before we link the transition frame onto m_pHackPInvokeTunnel (because hitting this ; condition implies we're running restricted callouts during a GC itself and we could end up ; overwriting a co-op frame set by the code that caused the GC in the first place, e.g. a GC.Collect ; call). test dword ptr [rsi + OFFSETOF__Thread__m_ThreadStateFlags], TSF_SuppressGcStress + TSF_DoNotTriggerGc jnz DoneWaitingForGc ; link the frame into the Thread lea rcx, [rsp + sizeof_OutgoingScratchSpace] ; rcx <- PInvokeTransitionFrame* mov [rsi + OFFSETOF__Thread__m_pHackPInvokeTunnel], rcx ;; ;; Unhijack this thread, if necessary. ;; INLINE_THREAD_UNHIJACK rsi, rax, rcx ;; trashes RAX, RCX ifdef FEATURE_GC_STRESS xor eax, eax cmp [g_fGcStressStarted], eax jz @F mov rdx, [rsp + 2c0h] mov rcx, [g_pTheRuntimeInstance] call RuntimeInstance__ShouldHijackLoopForGcStress cmp al, 0 je @F call REDHAWKGCINTERFACE__STRESSGC @@: endif ;; FEATURE_GC_STRESS lea rcx, [rsp + sizeof_OutgoingScratchSpace] ; calculate PInvokeTransitionFrame pointer call RhpWaitForGCNoAbort DoneWaitingForGc: fxrstor [rsp + 0c0h] cmp [g_fHasFastFxsave], 0 jz DontRestoreXmmAgain movdqa xmm0 , [rsp + 0c0h + 0a0h + 0*10h] movdqa xmm1 , [rsp + 0c0h + 0a0h + 1*10h] movdqa xmm2 , [rsp + 0c0h + 0a0h + 2*10h] movdqa xmm3 , [rsp + 0c0h + 0a0h + 3*10h] movdqa xmm4 , [rsp + 0c0h + 0a0h + 4*10h] movdqa xmm5 , [rsp + 0c0h + 0a0h + 5*10h] movdqa xmm6 , [rsp + 0c0h + 0a0h + 6*10h] movdqa xmm7 , [rsp + 0c0h + 0a0h + 7*10h] movdqa xmm8 , [rsp + 0c0h + 0a0h + 8*10h] movdqa xmm9 , [rsp + 0c0h + 0a0h + 9*10h] movdqa xmm10, [rsp + 0c0h + 0a0h + 10*10h] movdqa xmm11, [rsp + 0c0h + 0a0h + 11*10h] movdqa xmm12, [rsp + 0c0h + 0a0h + 12*10h] movdqa xmm13, [rsp + 0c0h + 0a0h + 13*10h] movdqa xmm14, [rsp + 0c0h + 0a0h + 14*10h] movdqa xmm15, [rsp + 0c0h + 0a0h + 15*10h] DontRestoreXmmAgain: add rsp, sizeof_OutgoingScratchSpace mov eax, [rsp + OFFSETOF__PInvokeTransitionFrame__m_Flags] test eax, PTFF_THREAD_ABORT pop rax ; m_RIP pop rbp ; m_FramePointer pop rax ; m_pThread pop rax ; m_Flags / m_dwAlign2 pop rbx pop rsi pop rdi pop r12 pop r13 pop r14 pop r15 pop rax ; RSP pop rax ; RAX save pop rcx pop rdx pop r8 pop r9 pop r10 pop r11 ;; restore PSP ;; 2F0h -> offset of the PSP area ;; 0B8h -> offset of the end of the integer register area which is already popped mov rsp, [rsp + 2f0h - 0b8h] ;; RSP is PSP at this point and the stack looks like this: ;; [PSP - 10] -> eflags save ;; [PSP - 8] -> return address ;; [PSP] -> caller's frame ;; ;; The final step is to restore eflags and return lea rsp, [rsp - 10h] jz @f ;; result of the test instruction before the pops above popfq ;; restore flags mov rcx, STATUS_REDHAWK_THREAD_ABORT pop rdx ;; return address as exception RIP jmp RhpThrowHwEx ;; Throw the ThreadAbortException as a special kind of hardware exception @@: popfq ;; restore flags ret NESTED_END RhpTrapToGC, _TEXT ifdef FEATURE_GC_STRESS ;; ;; INVARIANT: Don't trash the argument registers, the binder codegen depends on this. ;; LEAF_ENTRY RhpSuppressGcStress, _TEXT INLINE_GETTHREAD rax, r10 lock or dword ptr [rax + OFFSETOF__Thread__m_ThreadStateFlags], TSF_SuppressGcStress ret LEAF_END RhpSuppressGcStress, _TEXT endif ;; FEATURE_GC_STRESS end
; A226570: Sum_{k=1..n} (k+1)! mod n ; 0,0,2,0,2,2,4,0,8,2,10,8,8,4,2,8,11,8,7,12,11,10,19,8,12,8,8,4,15,2,0,24,32,28,32,8,3,26,8,32,2,32,14,32,17,42,16,8,46,12,11,8,11,8,32,32,26,44,26,32,20,0,53,24,47,32,63,28,65,32,66,8,53,40,62,64,32,8,18,72,62,2,25,32,62,14,44,32,74,62,60,88,62,16,7,56,78,46,98,12 add $0,1 mov $2,$0 lpb $0 add $3,1 mul $3,$0 sub $0,1 mov $1,$3 mod $3,$2 lpe sub $1,1 mov $0,$1
;ADC 0848 CHECK RUN CODE ;08/07/2008 :: 23:00 HRS :::::::: LAST UPDATED : 09/07/2008 ;ASTER ;PIN CONFIG: PORT 1 : DB0 ---- DB7 ADC ; PORT 3 : OUTPUT LEDS ; PORT 2 : CONTROL PINS :::: P2.0- INTR(BAR) ; P2.1- WR(BAR) ; P2.2- CS(BAR) ; P2.3- RD(BAR) :::: ;PROGRAM RUN -SUCCESS ON ADC0848CCN ORG 0000H SJMP 0030H ORG 0030H START: MOV P1,#00H MOV P2,#0AH MOV P3,#00H MOV P1,#08H ; SINGLE ENDED CHANNEL 1 :: 0000 1000 ACALL WRITE ; START CONVERSION ;WAIT: NOP ; JB P2.0,WAIT ACALL READY ; CHECK IF CONVERSION IS DONE :: INTR BAR IS LOW ACALL READ ; READ DB0 TO DB7 AND PLACE IN R0 MOV P3,R0 ; OUTPUT DIGITAL CONVERSION ACALL DELAY STOP: SJMP START WRITE: SETB P2.3 CLR P2.2 ; CLEAR CS BAR SETB P2.1 ; SET WR BAR NOP CLR P2.1 ; CLEAR WR BAR NOP NOP NOP SETB P2.1 ; RISING EDGE ON WR BAR RET READY: SETB P2.1 CLR P2.2 SETB P2.3 SETB P3.7 ; WATCH BITS SETB P3.6 WAIT: JB P2.0,WAIT ; WAIT TILL INTR BAR IS LOW CLR P3.7 CLR P3.6 NOP RET READ: SETB P2.1 CLR P2.2 ; CS BAR LOW CLR P2.3 ; RD BAR LOW NOP NOP MOV P1,#0FFH ;CONFIGURE PORT FOR INPUT::: DONT FORGET THIS MOV R0,P1 NOP NOP RET DELAY: MOV R7,#08H MOV R6,#0FFH MOV R5,#0FFH DJNZ R5,$ DJNZ R6,$-2 DJNZ R7,$-4 RET END
; ------------------------------------------------------------------ ; MichalOS Ascii Test ; ------------------------------------------------------------------ BITS 16 %INCLUDE "osdev.inc" ORG 100h start: mov byte [0082h], 1 mov ah, 9 mov al, 0 mov bh, 0 mov bl, 0Fh mov cx, 1 mov dl, 0 mov dh, 0 .loop: call os_move_cursor int 10h inc al inc dl cmp dl, 16 jne .loop mov dl, 0 inc dh cmp dh, 16 jne .loop call os_wait_for_key ret
; A164545: a(n) = 4*a(n-1) + 4*a(n-2) for n > 1; a(0) = 1, a(1) = 8. ; 1,8,36,176,848,4096,19776,95488,461056,2226176,10748928,51900416,250597376,1209991168,5842354176,28209381376,136206942208,657665294336,3175488946176,15332616962048,74032423632896,357460162379776,1725970344050688,8333722025721856,40238769479090176,194289966019248128,938114941993353216,4529619632050405376,21870938296175034368,105602231712901758976,509892680036307173376,2461979646996835729408,11887489308132571611136,57397875820517629362176,277141460514600803893248,1338157345340473733021696,6461195223420298147659776,31197410275043087522725888,150634421993853542681542656,727327329075586520817074176,3511847004277760253994467328,16956697333413387099246166016,81874177350764589412962533376,395323498736711906048834797568,1908790704349905981847189323776,9216456812346471551584096485376,44500990066785510133725143236608,214869787516527926741236958887936,1037483110333253747499848408498176,5009411591399126696964341469544448,24187578806929521777856759512170496,116787961593314593899284403926859776,563902161600976462708564653756121088 add $0,1 seq $0,189743 ; a(1)=4, a(2)=4, a(n)=4*a(n-1) + 4*a(n-2) div $0,4
; A076568: Greatest prime divisor of 5n+10 (sum of five successive integers). ; 5,5,5,5,7,5,5,5,11,5,13,7,5,5,17,5,19,5,7,11,23,5,5,13,5,7,29,5,31,5,11,17,7,5,37,19,13,5,41,7,43,11,5,23,47,5,7,5,17,13,53,5,11,7,19,29,59,5,61,31,7,5,13,11,67,17,23,7,71,5,73,37,5,19,11,13,79,5,5,41,83,7 add $0,2 seq $0,6530 ; Gpf(n): greatest prime dividing n, for n >= 2; a(1)=1. trn $0,5 add $0,5
.include "defaults_request.asm" table_file_jp equ "exe6-utf8.tbl" table_file_en equ "bn6-utf8.tbl" game_code_len equ 3 game_code equ 0x4252354A // BR5J game_code_2 equ 0x42523545 // BR5E game_code_3 equ 0x42523550 // BR5P card_type equ 4 card_id equ 9 card_no equ "009" card_sub equ "Request Event Card 009" card_sub_x equ 32 card_name_jp_full equ "実験だ!" card_name_jp_game equ "じっけんだ!" card_name_en_full equ "An Experiment!" card_name_en_game equ "An Experiment!" card_desc_len equ 1 card_desc_1 equ "An Experiment!" card_desc_2 equ "" card_desc_3 equ ""
; / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / ; / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / ; / / / / ; / / Copyright 2021 (c) Navegos QA - optimized library / / ; / / / / ; / / Licensed under the Apache License, Version 2.0 (the "License"); / / ; / / you may not use this file except in compliance with the License. / / ; / / You may obtain a copy of the License at / / ; / / / / ; / / http://www.apache.org/licenses/LICENSE-2.0 / / ; / / / / ; / / Unless required by applicable law or agreed to in writing, software / / ; / / distributed under the License is distributed on an "AS IS" BASIS, / / ; / / WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. / / ; / / See the License for the specific language governing permissions and / / ; / / limitations under the License. / / ; / / / / ; / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / ; / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / option casemap:none include macrolib.inc include uXasm.inc ifndef __MIC__ .xmm option arch:sse option evex:0 alignstackfieldproc .data? .data .const _m128ishufepi64jmptable label size_t isize_t _m128ishufepi64_0, _m128ishufepi64_1, _m128ishufepi64_2, _m128ishufepi64_3 _m128ishufepi32jmptable label size_t isize_t _m128ishufepi32_0, _m128ishufepi32_1, _m128ishufepi32_2, _m128ishufepi32_3, _m128ishufepi32_4 isize_t _m128ishufepi32_5, _m128ishufepi32_6, _m128ishufepi32_7, _m128ishufepi32_8, _m128ishufepi32_9 isize_t _m128ishufepi32_10, _m128ishufepi32_11, _m128ishufepi32_12, _m128ishufepi32_13, _m128ishufepi32_14 isize_t _m128ishufepi32_15, _m128ishufepi32_16, _m128ishufepi32_17, _m128ishufepi32_18, _m128ishufepi32_19 isize_t _m128ishufepi32_20, _m128ishufepi32_21, _m128ishufepi32_22, _m128ishufepi32_23, _m128ishufepi32_24 isize_t _m128ishufepi32_25, _m128ishufepi32_26, _m128ishufepi32_27, _m128ishufepi32_28, _m128ishufepi32_29 isize_t _m128ishufepi32_30, _m128ishufepi32_31, _m128ishufepi32_32, _m128ishufepi32_33, _m128ishufepi32_34 isize_t _m128ishufepi32_35, _m128ishufepi32_36, _m128ishufepi32_37, _m128ishufepi32_38, _m128ishufepi32_39 isize_t _m128ishufepi32_40, _m128ishufepi32_41, _m128ishufepi32_42, _m128ishufepi32_43, _m128ishufepi32_44 isize_t _m128ishufepi32_45, _m128ishufepi32_46, _m128ishufepi32_47, _m128ishufepi32_48, _m128ishufepi32_49 isize_t _m128ishufepi32_50, _m128ishufepi32_51, _m128ishufepi32_52, _m128ishufepi32_53, _m128ishufepi32_54 isize_t _m128ishufepi32_55, _m128ishufepi32_56, _m128ishufepi32_57, _m128ishufepi32_58, _m128ishufepi32_59 isize_t _m128ishufepi32_60, _m128ishufepi32_61, _m128ishufepi32_62, _m128ishufepi32_63, _m128ishufepi32_64 isize_t _m128ishufepi32_65, _m128ishufepi32_66, _m128ishufepi32_67, _m128ishufepi32_68, _m128ishufepi32_69 isize_t _m128ishufepi32_70, _m128ishufepi32_71, _m128ishufepi32_72, _m128ishufepi32_73, _m128ishufepi32_74 isize_t _m128ishufepi32_75, _m128ishufepi32_76, _m128ishufepi32_77, _m128ishufepi32_78, _m128ishufepi32_79 isize_t _m128ishufepi32_80, _m128ishufepi32_81, _m128ishufepi32_82, _m128ishufepi32_83, _m128ishufepi32_84 isize_t _m128ishufepi32_85, _m128ishufepi32_86, _m128ishufepi32_87, _m128ishufepi32_88, _m128ishufepi32_89 isize_t _m128ishufepi32_90, _m128ishufepi32_91, _m128ishufepi32_92, _m128ishufepi32_93, _m128ishufepi32_94 isize_t _m128ishufepi32_95, _m128ishufepi32_96, _m128ishufepi32_97, _m128ishufepi32_98, _m128ishufepi32_99 isize_t _m128ishufepi32_100, _m128ishufepi32_101, _m128ishufepi32_102, _m128ishufepi32_103, _m128ishufepi32_104 isize_t _m128ishufepi32_105, _m128ishufepi32_106, _m128ishufepi32_107, _m128ishufepi32_108, _m128ishufepi32_109 isize_t _m128ishufepi32_110, _m128ishufepi32_111, _m128ishufepi32_112, _m128ishufepi32_113, _m128ishufepi32_114 isize_t _m128ishufepi32_115, _m128ishufepi32_116, _m128ishufepi32_117, _m128ishufepi32_118, _m128ishufepi32_119 isize_t _m128ishufepi32_120, _m128ishufepi32_121, _m128ishufepi32_122, _m128ishufepi32_123, _m128ishufepi32_124 isize_t _m128ishufepi32_125, _m128ishufepi32_126, _m128ishufepi32_127, _m128ishufepi32_128, _m128ishufepi32_129 isize_t _m128ishufepi32_130, _m128ishufepi32_131, _m128ishufepi32_132, _m128ishufepi32_133, _m128ishufepi32_134 isize_t _m128ishufepi32_135, _m128ishufepi32_136, _m128ishufepi32_137, _m128ishufepi32_138, _m128ishufepi32_139 isize_t _m128ishufepi32_140, _m128ishufepi32_141, _m128ishufepi32_142, _m128ishufepi32_143, _m128ishufepi32_144 isize_t _m128ishufepi32_145, _m128ishufepi32_146, _m128ishufepi32_147, _m128ishufepi32_148, _m128ishufepi32_149 isize_t _m128ishufepi32_150, _m128ishufepi32_151, _m128ishufepi32_152, _m128ishufepi32_153, _m128ishufepi32_154 isize_t _m128ishufepi32_155, _m128ishufepi32_156, _m128ishufepi32_157, _m128ishufepi32_158, _m128ishufepi32_159 isize_t _m128ishufepi32_160, _m128ishufepi32_161, _m128ishufepi32_162, _m128ishufepi32_163, _m128ishufepi32_164 isize_t _m128ishufepi32_165, _m128ishufepi32_166, _m128ishufepi32_167, _m128ishufepi32_168, _m128ishufepi32_169 isize_t _m128ishufepi32_170, _m128ishufepi32_171, _m128ishufepi32_172, _m128ishufepi32_173, _m128ishufepi32_174 isize_t _m128ishufepi32_175, _m128ishufepi32_176, _m128ishufepi32_177, _m128ishufepi32_178, _m128ishufepi32_179 isize_t _m128ishufepi32_180, _m128ishufepi32_181, _m128ishufepi32_182, _m128ishufepi32_183, _m128ishufepi32_184 isize_t _m128ishufepi32_185, _m128ishufepi32_186, _m128ishufepi32_187, _m128ishufepi32_188, _m128ishufepi32_189 isize_t _m128ishufepi32_190, _m128ishufepi32_191, _m128ishufepi32_192, _m128ishufepi32_193, _m128ishufepi32_194 isize_t _m128ishufepi32_195, _m128ishufepi32_196, _m128ishufepi32_197, _m128ishufepi32_198, _m128ishufepi32_199 isize_t _m128ishufepi32_200, _m128ishufepi32_201, _m128ishufepi32_202, _m128ishufepi32_203, _m128ishufepi32_204 isize_t _m128ishufepi32_205, _m128ishufepi32_206, _m128ishufepi32_207, _m128ishufepi32_208, _m128ishufepi32_209 isize_t _m128ishufepi32_210, _m128ishufepi32_211, _m128ishufepi32_212, _m128ishufepi32_213, _m128ishufepi32_214 isize_t _m128ishufepi32_215, _m128ishufepi32_216, _m128ishufepi32_217, _m128ishufepi32_218, _m128ishufepi32_219 isize_t _m128ishufepi32_220, _m128ishufepi32_221, _m128ishufepi32_222, _m128ishufepi32_223, _m128ishufepi32_224 isize_t _m128ishufepi32_225, _m128ishufepi32_226, _m128ishufepi32_227, _m128ishufepi32_228, _m128ishufepi32_229 isize_t _m128ishufepi32_230, _m128ishufepi32_231, _m128ishufepi32_232, _m128ishufepi32_233, _m128ishufepi32_234 isize_t _m128ishufepi32_235, _m128ishufepi32_236, _m128ishufepi32_237, _m128ishufepi32_238, _m128ishufepi32_239 isize_t _m128ishufepi32_240, _m128ishufepi32_241, _m128ishufepi32_242, _m128ishufepi32_243, _m128ishufepi32_244 isize_t _m128ishufepi32_245, _m128ishufepi32_246, _m128ishufepi32_247, _m128ishufepi32_248, _m128ishufepi32_249 isize_t _m128ishufepi32_250, _m128ishufepi32_251, _m128ishufepi32_252, _m128ishufepi32_253, _m128ishufepi32_254 isize_t _m128ishufepi32_255 _m128ishufhiepi16jmptable label size_t isize_t _m128ishufhiepi16_0, _m128ishufhiepi16_1, _m128ishufhiepi16_2, _m128ishufhiepi16_3, _m128ishufhiepi16_4 isize_t _m128ishufhiepi16_5, _m128ishufhiepi16_6, _m128ishufhiepi16_7, _m128ishufhiepi16_8, _m128ishufhiepi16_9 isize_t _m128ishufhiepi16_10, _m128ishufhiepi16_11, _m128ishufhiepi16_12, _m128ishufhiepi16_13, _m128ishufhiepi16_14 isize_t _m128ishufhiepi16_15, _m128ishufhiepi16_16, _m128ishufhiepi16_17, _m128ishufhiepi16_18, _m128ishufhiepi16_19 isize_t _m128ishufhiepi16_20, _m128ishufhiepi16_21, _m128ishufhiepi16_22, _m128ishufhiepi16_23, _m128ishufhiepi16_24 isize_t _m128ishufhiepi16_25, _m128ishufhiepi16_26, _m128ishufhiepi16_27, _m128ishufhiepi16_28, _m128ishufhiepi16_29 isize_t _m128ishufhiepi16_30, _m128ishufhiepi16_31, _m128ishufhiepi16_32, _m128ishufhiepi16_33, _m128ishufhiepi16_34 isize_t _m128ishufhiepi16_35, _m128ishufhiepi16_36, _m128ishufhiepi16_37, _m128ishufhiepi16_38, _m128ishufhiepi16_39 isize_t _m128ishufhiepi16_40, _m128ishufhiepi16_41, _m128ishufhiepi16_42, _m128ishufhiepi16_43, _m128ishufhiepi16_44 isize_t _m128ishufhiepi16_45, _m128ishufhiepi16_46, _m128ishufhiepi16_47, _m128ishufhiepi16_48, _m128ishufhiepi16_49 isize_t _m128ishufhiepi16_50, _m128ishufhiepi16_51, _m128ishufhiepi16_52, _m128ishufhiepi16_53, _m128ishufhiepi16_54 isize_t _m128ishufhiepi16_55, _m128ishufhiepi16_56, _m128ishufhiepi16_57, _m128ishufhiepi16_58, _m128ishufhiepi16_59 isize_t _m128ishufhiepi16_60, _m128ishufhiepi16_61, _m128ishufhiepi16_62, _m128ishufhiepi16_63, _m128ishufhiepi16_64 isize_t _m128ishufhiepi16_65, _m128ishufhiepi16_66, _m128ishufhiepi16_67, _m128ishufhiepi16_68, _m128ishufhiepi16_69 isize_t _m128ishufhiepi16_70, _m128ishufhiepi16_71, _m128ishufhiepi16_72, _m128ishufhiepi16_73, _m128ishufhiepi16_74 isize_t _m128ishufhiepi16_75, _m128ishufhiepi16_76, _m128ishufhiepi16_77, _m128ishufhiepi16_78, _m128ishufhiepi16_79 isize_t _m128ishufhiepi16_80, _m128ishufhiepi16_81, _m128ishufhiepi16_82, _m128ishufhiepi16_83, _m128ishufhiepi16_84 isize_t _m128ishufhiepi16_85, _m128ishufhiepi16_86, _m128ishufhiepi16_87, _m128ishufhiepi16_88, _m128ishufhiepi16_89 isize_t _m128ishufhiepi16_90, _m128ishufhiepi16_91, _m128ishufhiepi16_92, _m128ishufhiepi16_93, _m128ishufhiepi16_94 isize_t _m128ishufhiepi16_95, _m128ishufhiepi16_96, _m128ishufhiepi16_97, _m128ishufhiepi16_98, _m128ishufhiepi16_99 isize_t _m128ishufhiepi16_100, _m128ishufhiepi16_101, _m128ishufhiepi16_102, _m128ishufhiepi16_103, _m128ishufhiepi16_104 isize_t _m128ishufhiepi16_105, _m128ishufhiepi16_106, _m128ishufhiepi16_107, _m128ishufhiepi16_108, _m128ishufhiepi16_109 isize_t _m128ishufhiepi16_110, _m128ishufhiepi16_111, _m128ishufhiepi16_112, _m128ishufhiepi16_113, _m128ishufhiepi16_114 isize_t _m128ishufhiepi16_115, _m128ishufhiepi16_116, _m128ishufhiepi16_117, _m128ishufhiepi16_118, _m128ishufhiepi16_119 isize_t _m128ishufhiepi16_120, _m128ishufhiepi16_121, _m128ishufhiepi16_122, _m128ishufhiepi16_123, _m128ishufhiepi16_124 isize_t _m128ishufhiepi16_125, _m128ishufhiepi16_126, _m128ishufhiepi16_127, _m128ishufhiepi16_128, _m128ishufhiepi16_129 isize_t _m128ishufhiepi16_130, _m128ishufhiepi16_131, _m128ishufhiepi16_132, _m128ishufhiepi16_133, _m128ishufhiepi16_134 isize_t _m128ishufhiepi16_135, _m128ishufhiepi16_136, _m128ishufhiepi16_137, _m128ishufhiepi16_138, _m128ishufhiepi16_139 isize_t _m128ishufhiepi16_140, _m128ishufhiepi16_141, _m128ishufhiepi16_142, _m128ishufhiepi16_143, _m128ishufhiepi16_144 isize_t _m128ishufhiepi16_145, _m128ishufhiepi16_146, _m128ishufhiepi16_147, _m128ishufhiepi16_148, _m128ishufhiepi16_149 isize_t _m128ishufhiepi16_150, _m128ishufhiepi16_151, _m128ishufhiepi16_152, _m128ishufhiepi16_153, _m128ishufhiepi16_154 isize_t _m128ishufhiepi16_155, _m128ishufhiepi16_156, _m128ishufhiepi16_157, _m128ishufhiepi16_158, _m128ishufhiepi16_159 isize_t _m128ishufhiepi16_160, _m128ishufhiepi16_161, _m128ishufhiepi16_162, _m128ishufhiepi16_163, _m128ishufhiepi16_164 isize_t _m128ishufhiepi16_165, _m128ishufhiepi16_166, _m128ishufhiepi16_167, _m128ishufhiepi16_168, _m128ishufhiepi16_169 isize_t _m128ishufhiepi16_170, _m128ishufhiepi16_171, _m128ishufhiepi16_172, _m128ishufhiepi16_173, _m128ishufhiepi16_174 isize_t _m128ishufhiepi16_175, _m128ishufhiepi16_176, _m128ishufhiepi16_177, _m128ishufhiepi16_178, _m128ishufhiepi16_179 isize_t _m128ishufhiepi16_180, _m128ishufhiepi16_181, _m128ishufhiepi16_182, _m128ishufhiepi16_183, _m128ishufhiepi16_184 isize_t _m128ishufhiepi16_185, _m128ishufhiepi16_186, _m128ishufhiepi16_187, _m128ishufhiepi16_188, _m128ishufhiepi16_189 isize_t _m128ishufhiepi16_190, _m128ishufhiepi16_191, _m128ishufhiepi16_192, _m128ishufhiepi16_193, _m128ishufhiepi16_194 isize_t _m128ishufhiepi16_195, _m128ishufhiepi16_196, _m128ishufhiepi16_197, _m128ishufhiepi16_198, _m128ishufhiepi16_199 isize_t _m128ishufhiepi16_200, _m128ishufhiepi16_201, _m128ishufhiepi16_202, _m128ishufhiepi16_203, _m128ishufhiepi16_204 isize_t _m128ishufhiepi16_205, _m128ishufhiepi16_206, _m128ishufhiepi16_207, _m128ishufhiepi16_208, _m128ishufhiepi16_209 isize_t _m128ishufhiepi16_210, _m128ishufhiepi16_211, _m128ishufhiepi16_212, _m128ishufhiepi16_213, _m128ishufhiepi16_214 isize_t _m128ishufhiepi16_215, _m128ishufhiepi16_216, _m128ishufhiepi16_217, _m128ishufhiepi16_218, _m128ishufhiepi16_219 isize_t _m128ishufhiepi16_220, _m128ishufhiepi16_221, _m128ishufhiepi16_222, _m128ishufhiepi16_223, _m128ishufhiepi16_224 isize_t _m128ishufhiepi16_225, _m128ishufhiepi16_226, _m128ishufhiepi16_227, _m128ishufhiepi16_228, _m128ishufhiepi16_229 isize_t _m128ishufhiepi16_230, _m128ishufhiepi16_231, _m128ishufhiepi16_232, _m128ishufhiepi16_233, _m128ishufhiepi16_234 isize_t _m128ishufhiepi16_235, _m128ishufhiepi16_236, _m128ishufhiepi16_237, _m128ishufhiepi16_238, _m128ishufhiepi16_239 isize_t _m128ishufhiepi16_240, _m128ishufhiepi16_241, _m128ishufhiepi16_242, _m128ishufhiepi16_243, _m128ishufhiepi16_244 isize_t _m128ishufhiepi16_245, _m128ishufhiepi16_246, _m128ishufhiepi16_247, _m128ishufhiepi16_248, _m128ishufhiepi16_249 isize_t _m128ishufhiepi16_250, _m128ishufhiepi16_251, _m128ishufhiepi16_252, _m128ishufhiepi16_253, _m128ishufhiepi16_254 isize_t _m128ishufhiepi16_255 _m128ishufloepi16jmptable label size_t isize_t _m128ishufloepi16_0, _m128ishufloepi16_1, _m128ishufloepi16_2, _m128ishufloepi16_3, _m128ishufloepi16_4 isize_t _m128ishufloepi16_5, _m128ishufloepi16_6, _m128ishufloepi16_7, _m128ishufloepi16_8, _m128ishufloepi16_9 isize_t _m128ishufloepi16_10, _m128ishufloepi16_11, _m128ishufloepi16_12, _m128ishufloepi16_13, _m128ishufloepi16_14 isize_t _m128ishufloepi16_15, _m128ishufloepi16_16, _m128ishufloepi16_17, _m128ishufloepi16_18, _m128ishufloepi16_19 isize_t _m128ishufloepi16_20, _m128ishufloepi16_21, _m128ishufloepi16_22, _m128ishufloepi16_23, _m128ishufloepi16_24 isize_t _m128ishufloepi16_25, _m128ishufloepi16_26, _m128ishufloepi16_27, _m128ishufloepi16_28, _m128ishufloepi16_29 isize_t _m128ishufloepi16_30, _m128ishufloepi16_31, _m128ishufloepi16_32, _m128ishufloepi16_33, _m128ishufloepi16_34 isize_t _m128ishufloepi16_35, _m128ishufloepi16_36, _m128ishufloepi16_37, _m128ishufloepi16_38, _m128ishufloepi16_39 isize_t _m128ishufloepi16_40, _m128ishufloepi16_41, _m128ishufloepi16_42, _m128ishufloepi16_43, _m128ishufloepi16_44 isize_t _m128ishufloepi16_45, _m128ishufloepi16_46, _m128ishufloepi16_47, _m128ishufloepi16_48, _m128ishufloepi16_49 isize_t _m128ishufloepi16_50, _m128ishufloepi16_51, _m128ishufloepi16_52, _m128ishufloepi16_53, _m128ishufloepi16_54 isize_t _m128ishufloepi16_55, _m128ishufloepi16_56, _m128ishufloepi16_57, _m128ishufloepi16_58, _m128ishufloepi16_59 isize_t _m128ishufloepi16_60, _m128ishufloepi16_61, _m128ishufloepi16_62, _m128ishufloepi16_63, _m128ishufloepi16_64 isize_t _m128ishufloepi16_65, _m128ishufloepi16_66, _m128ishufloepi16_67, _m128ishufloepi16_68, _m128ishufloepi16_69 isize_t _m128ishufloepi16_70, _m128ishufloepi16_71, _m128ishufloepi16_72, _m128ishufloepi16_73, _m128ishufloepi16_74 isize_t _m128ishufloepi16_75, _m128ishufloepi16_76, _m128ishufloepi16_77, _m128ishufloepi16_78, _m128ishufloepi16_79 isize_t _m128ishufloepi16_80, _m128ishufloepi16_81, _m128ishufloepi16_82, _m128ishufloepi16_83, _m128ishufloepi16_84 isize_t _m128ishufloepi16_85, _m128ishufloepi16_86, _m128ishufloepi16_87, _m128ishufloepi16_88, _m128ishufloepi16_89 isize_t _m128ishufloepi16_90, _m128ishufloepi16_91, _m128ishufloepi16_92, _m128ishufloepi16_93, _m128ishufloepi16_94 isize_t _m128ishufloepi16_95, _m128ishufloepi16_96, _m128ishufloepi16_97, _m128ishufloepi16_98, _m128ishufloepi16_99 isize_t _m128ishufloepi16_100, _m128ishufloepi16_101, _m128ishufloepi16_102, _m128ishufloepi16_103, _m128ishufloepi16_104 isize_t _m128ishufloepi16_105, _m128ishufloepi16_106, _m128ishufloepi16_107, _m128ishufloepi16_108, _m128ishufloepi16_109 isize_t _m128ishufloepi16_110, _m128ishufloepi16_111, _m128ishufloepi16_112, _m128ishufloepi16_113, _m128ishufloepi16_114 isize_t _m128ishufloepi16_115, _m128ishufloepi16_116, _m128ishufloepi16_117, _m128ishufloepi16_118, _m128ishufloepi16_119 isize_t _m128ishufloepi16_120, _m128ishufloepi16_121, _m128ishufloepi16_122, _m128ishufloepi16_123, _m128ishufloepi16_124 isize_t _m128ishufloepi16_125, _m128ishufloepi16_126, _m128ishufloepi16_127, _m128ishufloepi16_128, _m128ishufloepi16_129 isize_t _m128ishufloepi16_130, _m128ishufloepi16_131, _m128ishufloepi16_132, _m128ishufloepi16_133, _m128ishufloepi16_134 isize_t _m128ishufloepi16_135, _m128ishufloepi16_136, _m128ishufloepi16_137, _m128ishufloepi16_138, _m128ishufloepi16_139 isize_t _m128ishufloepi16_140, _m128ishufloepi16_141, _m128ishufloepi16_142, _m128ishufloepi16_143, _m128ishufloepi16_144 isize_t _m128ishufloepi16_145, _m128ishufloepi16_146, _m128ishufloepi16_147, _m128ishufloepi16_148, _m128ishufloepi16_149 isize_t _m128ishufloepi16_150, _m128ishufloepi16_151, _m128ishufloepi16_152, _m128ishufloepi16_153, _m128ishufloepi16_154 isize_t _m128ishufloepi16_155, _m128ishufloepi16_156, _m128ishufloepi16_157, _m128ishufloepi16_158, _m128ishufloepi16_159 isize_t _m128ishufloepi16_160, _m128ishufloepi16_161, _m128ishufloepi16_162, _m128ishufloepi16_163, _m128ishufloepi16_164 isize_t _m128ishufloepi16_165, _m128ishufloepi16_166, _m128ishufloepi16_167, _m128ishufloepi16_168, _m128ishufloepi16_169 isize_t _m128ishufloepi16_170, _m128ishufloepi16_171, _m128ishufloepi16_172, _m128ishufloepi16_173, _m128ishufloepi16_174 isize_t _m128ishufloepi16_175, _m128ishufloepi16_176, _m128ishufloepi16_177, _m128ishufloepi16_178, _m128ishufloepi16_179 isize_t _m128ishufloepi16_180, _m128ishufloepi16_181, _m128ishufloepi16_182, _m128ishufloepi16_183, _m128ishufloepi16_184 isize_t _m128ishufloepi16_185, _m128ishufloepi16_186, _m128ishufloepi16_187, _m128ishufloepi16_188, _m128ishufloepi16_189 isize_t _m128ishufloepi16_190, _m128ishufloepi16_191, _m128ishufloepi16_192, _m128ishufloepi16_193, _m128ishufloepi16_194 isize_t _m128ishufloepi16_195, _m128ishufloepi16_196, _m128ishufloepi16_197, _m128ishufloepi16_198, _m128ishufloepi16_199 isize_t _m128ishufloepi16_200, _m128ishufloepi16_201, _m128ishufloepi16_202, _m128ishufloepi16_203, _m128ishufloepi16_204 isize_t _m128ishufloepi16_205, _m128ishufloepi16_206, _m128ishufloepi16_207, _m128ishufloepi16_208, _m128ishufloepi16_209 isize_t _m128ishufloepi16_210, _m128ishufloepi16_211, _m128ishufloepi16_212, _m128ishufloepi16_213, _m128ishufloepi16_214 isize_t _m128ishufloepi16_215, _m128ishufloepi16_216, _m128ishufloepi16_217, _m128ishufloepi16_218, _m128ishufloepi16_219 isize_t _m128ishufloepi16_220, _m128ishufloepi16_221, _m128ishufloepi16_222, _m128ishufloepi16_223, _m128ishufloepi16_224 isize_t _m128ishufloepi16_225, _m128ishufloepi16_226, _m128ishufloepi16_227, _m128ishufloepi16_228, _m128ishufloepi16_229 isize_t _m128ishufloepi16_230, _m128ishufloepi16_231, _m128ishufloepi16_232, _m128ishufloepi16_233, _m128ishufloepi16_234 isize_t _m128ishufloepi16_235, _m128ishufloepi16_236, _m128ishufloepi16_237, _m128ishufloepi16_238, _m128ishufloepi16_239 isize_t _m128ishufloepi16_240, _m128ishufloepi16_241, _m128ishufloepi16_242, _m128ishufloepi16_243, _m128ishufloepi16_244 isize_t _m128ishufloepi16_245, _m128ishufloepi16_246, _m128ishufloepi16_247, _m128ishufloepi16_248, _m128ishufloepi16_249 isize_t _m128ishufloepi16_250, _m128ishufloepi16_251, _m128ishufloepi16_252, _m128ishufloepi16_253, _m128ishufloepi16_254 isize_t _m128ishufloepi16_255 .code callconvopt alignxmmfieldproc procstart _uX_mm_shuffle_epi64_00, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, shuffler4(0,1,0,1) ret procend procstart _uX_mm_shuffle_epi64_01, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, shuffler4(2,3,0,1) ret procend procstart _uX_mm_shuffle_epi64_10, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, shuffler4(0,1,2,3) ret procend procstart _uX_mm_shuffle_epi64_11, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, shuffler4(2,3,2,3) ret procend procstart _uX_mm_shuffle_epi64, callconv, xmmword, < >, < >, Inxmm_A:xmmword, Inint_Imm:dword push rbase() .if((rp1() < 0) || (rp1() > 3)) jmp _m128ishufepi64_end .endif ifdef __X32__ movzx rbase(), byte ptr [rp1()] jmp dword ptr [_m128ishufepi64jmptable+rbase()*size_t_size] else lea rbase(), qword ptr [_m128ishufepi64jmptable] mov rbase(), qword ptr [rbase()+rp1()*size_t_size] jmp rbx endif _m128ishufepi64_0 label size_t pshufd xmm0, xmm0, shuffler4(0,1,0,1) jmp _m128ishufepi64_end _m128ishufepi64_1 label size_t pshufd xmm0, xmm0, shuffler4(0,1,2,3) jmp _m128ishufepi64_end _m128ishufepi64_2 label size_t pshufd xmm0, xmm0, shuffler4(2,3,0,1) jmp _m128ishufepi64_end _m128ishufepi64_3 label size_t pshufd xmm0, xmm0, shuffler4(2,3,2,3) ;jmp _m128ishufepi64_end _m128ishufepi64_end: pop rbase() ret procend procstart _uX_mm_shuffle_epi32_0000, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 0 ret procend procstart _uX_mm_shuffle_epi32_0001, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 1 ret procend procstart _uX_mm_shuffle_epi32_0002, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 2 ret procend procstart _uX_mm_shuffle_epi32_0003, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 3 ret procend procstart _uX_mm_shuffle_epi32_0010, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 4 ret procend procstart _uX_mm_shuffle_epi32_0011, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 5 ret procend procstart _uX_mm_shuffle_epi32_0012, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 6 ret procend procstart _uX_mm_shuffle_epi32_0013, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 7 ret procend procstart _uX_mm_shuffle_epi32_0020, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 8 ret procend procstart _uX_mm_shuffle_epi32_0021, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 9 ret procend procstart _uX_mm_shuffle_epi32_0022, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 10 ret procend procstart _uX_mm_shuffle_epi32_0023, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 11 ret procend procstart _uX_mm_shuffle_epi32_0030, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 12 ret procend procstart _uX_mm_shuffle_epi32_0031, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 13 ret procend procstart _uX_mm_shuffle_epi32_0032, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 14 ret procend procstart _uX_mm_shuffle_epi32_0033, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 15 ret procend procstart _uX_mm_shuffle_epi32_0100, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 16 ret procend procstart _uX_mm_shuffle_epi32_0101, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 17 ret procend procstart _uX_mm_shuffle_epi32_0102, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 18 ret procend procstart _uX_mm_shuffle_epi32_0103, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 19 ret procend procstart _uX_mm_shuffle_epi32_0110, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 20 ret procend procstart _uX_mm_shuffle_epi32_0111, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 21 ret procend procstart _uX_mm_shuffle_epi32_0112, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 22 ret procend procstart _uX_mm_shuffle_epi32_0113, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 23 ret procend procstart _uX_mm_shuffle_epi32_0120, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 24 ret procend procstart _uX_mm_shuffle_epi32_0121, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 25 ret procend procstart _uX_mm_shuffle_epi32_0122, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 26 ret procend procstart _uX_mm_shuffle_epi32_0123, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 27 ret procend procstart _uX_mm_shuffle_epi32_0130, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 28 ret procend procstart _uX_mm_shuffle_epi32_0131, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 29 ret procend procstart _uX_mm_shuffle_epi32_0132, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 30 ret procend procstart _uX_mm_shuffle_epi32_0133, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 31 ret procend procstart _uX_mm_shuffle_epi32_0200, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 32 ret procend procstart _uX_mm_shuffle_epi32_0201, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 33 ret procend procstart _uX_mm_shuffle_epi32_0202, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 34 ret procend procstart _uX_mm_shuffle_epi32_0203, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 35 ret procend procstart _uX_mm_shuffle_epi32_0210, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 36 ret procend procstart _uX_mm_shuffle_epi32_0211, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 37 ret procend procstart _uX_mm_shuffle_epi32_0212, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 38 ret procend procstart _uX_mm_shuffle_epi32_0213, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 39 ret procend procstart _uX_mm_shuffle_epi32_0220, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 40 ret procend procstart _uX_mm_shuffle_epi32_0221, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 41 ret procend procstart _uX_mm_shuffle_epi32_0222, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 42 ret procend procstart _uX_mm_shuffle_epi32_0223, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 43 ret procend procstart _uX_mm_shuffle_epi32_0230, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 44 ret procend procstart _uX_mm_shuffle_epi32_0231, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 45 ret procend procstart _uX_mm_shuffle_epi32_0232, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 46 ret procend procstart _uX_mm_shuffle_epi32_0233, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 47 ret procend procstart _uX_mm_shuffle_epi32_0300, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 48 ret procend procstart _uX_mm_shuffle_epi32_0301, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 49 ret procend procstart _uX_mm_shuffle_epi32_0302, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 50 ret procend procstart _uX_mm_shuffle_epi32_0303, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 51 ret procend procstart _uX_mm_shuffle_epi32_0310, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 52 ret procend procstart _uX_mm_shuffle_epi32_0311, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 53 ret procend procstart _uX_mm_shuffle_epi32_0312, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 54 ret procend procstart _uX_mm_shuffle_epi32_0313, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 55 ret procend procstart _uX_mm_shuffle_epi32_0320, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 56 ret procend procstart _uX_mm_shuffle_epi32_0321, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 57 ret procend procstart _uX_mm_shuffle_epi32_0322, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 58 ret procend procstart _uX_mm_shuffle_epi32_0323, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 59 ret procend procstart _uX_mm_shuffle_epi32_0330, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 60 ret procend procstart _uX_mm_shuffle_epi32_0331, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 61 ret procend procstart _uX_mm_shuffle_epi32_0332, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 62 ret procend procstart _uX_mm_shuffle_epi32_0333, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 63 ret procend procstart _uX_mm_shuffle_epi32_1000, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 64 ret procend procstart _uX_mm_shuffle_epi32_1001, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 65 ret procend procstart _uX_mm_shuffle_epi32_1002, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 66 ret procend procstart _uX_mm_shuffle_epi32_1003, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 67 ret procend procstart _uX_mm_shuffle_epi32_1010, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 68 ret procend procstart _uX_mm_shuffle_epi32_1011, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 69 ret procend procstart _uX_mm_shuffle_epi32_1012, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 70 ret procend procstart _uX_mm_shuffle_epi32_1013, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 71 ret procend procstart _uX_mm_shuffle_epi32_1020, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 72 ret procend procstart _uX_mm_shuffle_epi32_1021, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 73 ret procend procstart _uX_mm_shuffle_epi32_1022, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 74 ret procend procstart _uX_mm_shuffle_epi32_1023, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 75 ret procend procstart _uX_mm_shuffle_epi32_1030, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 76 ret procend procstart _uX_mm_shuffle_epi32_1031, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 77 ret procend procstart _uX_mm_shuffle_epi32_1032, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 78 ret procend procstart _uX_mm_shuffle_epi32_1033, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 79 ret procend procstart _uX_mm_shuffle_epi32_1100, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 80 ret procend procstart _uX_mm_shuffle_epi32_1101, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 81 ret procend procstart _uX_mm_shuffle_epi32_1102, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 82 ret procend procstart _uX_mm_shuffle_epi32_1103, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 83 ret procend procstart _uX_mm_shuffle_epi32_1110, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 84 ret procend procstart _uX_mm_shuffle_epi32_1111, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 85 ret procend procstart _uX_mm_shuffle_epi32_1112, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 86 ret procend procstart _uX_mm_shuffle_epi32_1113, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 87 ret procend procstart _uX_mm_shuffle_epi32_1120, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 88 ret procend procstart _uX_mm_shuffle_epi32_1121, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 89 ret procend procstart _uX_mm_shuffle_epi32_1122, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 90 ret procend procstart _uX_mm_shuffle_epi32_1123, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 91 ret procend procstart _uX_mm_shuffle_epi32_1130, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 92 ret procend procstart _uX_mm_shuffle_epi32_1131, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 93 ret procend procstart _uX_mm_shuffle_epi32_1132, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 94 ret procend procstart _uX_mm_shuffle_epi32_1133, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 95 ret procend procstart _uX_mm_shuffle_epi32_1200, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 96 ret procend procstart _uX_mm_shuffle_epi32_1201, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 97 ret procend procstart _uX_mm_shuffle_epi32_1202, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 98 ret procend procstart _uX_mm_shuffle_epi32_1203, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 99 ret procend procstart _uX_mm_shuffle_epi32_1210, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 100 ret procend procstart _uX_mm_shuffle_epi32_1211, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 101 ret procend procstart _uX_mm_shuffle_epi32_1212, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 102 ret procend procstart _uX_mm_shuffle_epi32_1213, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 103 ret procend procstart _uX_mm_shuffle_epi32_1220, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 104 ret procend procstart _uX_mm_shuffle_epi32_1221, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 105 ret procend procstart _uX_mm_shuffle_epi32_1222, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 106 ret procend procstart _uX_mm_shuffle_epi32_1223, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 107 ret procend procstart _uX_mm_shuffle_epi32_1230, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 108 ret procend procstart _uX_mm_shuffle_epi32_1231, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 109 ret procend procstart _uX_mm_shuffle_epi32_1232, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 110 ret procend procstart _uX_mm_shuffle_epi32_1233, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 111 ret procend procstart _uX_mm_shuffle_epi32_1300, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 112 ret procend procstart _uX_mm_shuffle_epi32_1301, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 113 ret procend procstart _uX_mm_shuffle_epi32_1302, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 114 ret procend procstart _uX_mm_shuffle_epi32_1303, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 115 ret procend procstart _uX_mm_shuffle_epi32_1310, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 116 ret procend procstart _uX_mm_shuffle_epi32_1311, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 117 ret procend procstart _uX_mm_shuffle_epi32_1312, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 118 ret procend procstart _uX_mm_shuffle_epi32_1313, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 119 ret procend procstart _uX_mm_shuffle_epi32_1320, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 120 ret procend procstart _uX_mm_shuffle_epi32_1321, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 121 ret procend procstart _uX_mm_shuffle_epi32_1322, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 122 ret procend procstart _uX_mm_shuffle_epi32_1323, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 123 ret procend procstart _uX_mm_shuffle_epi32_1330, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 124 ret procend procstart _uX_mm_shuffle_epi32_1331, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 125 ret procend procstart _uX_mm_shuffle_epi32_1332, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 126 ret procend procstart _uX_mm_shuffle_epi32_1333, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 127 ret procend procstart _uX_mm_shuffle_epi32_2000, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 128 ret procend procstart _uX_mm_shuffle_epi32_2001, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 129 ret procend procstart _uX_mm_shuffle_epi32_2002, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 130 ret procend procstart _uX_mm_shuffle_epi32_2003, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 131 ret procend procstart _uX_mm_shuffle_epi32_2010, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 132 ret procend procstart _uX_mm_shuffle_epi32_2011, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 133 ret procend procstart _uX_mm_shuffle_epi32_2012, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 134 ret procend procstart _uX_mm_shuffle_epi32_2013, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 135 ret procend procstart _uX_mm_shuffle_epi32_2020, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 136 ret procend procstart _uX_mm_shuffle_epi32_2021, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 137 ret procend procstart _uX_mm_shuffle_epi32_2022, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 138 ret procend procstart _uX_mm_shuffle_epi32_2023, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 139 ret procend procstart _uX_mm_shuffle_epi32_2030, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 140 ret procend procstart _uX_mm_shuffle_epi32_2031, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 141 ret procend procstart _uX_mm_shuffle_epi32_2032, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 142 ret procend procstart _uX_mm_shuffle_epi32_2033, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 143 ret procend procstart _uX_mm_shuffle_epi32_2100, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 144 ret procend procstart _uX_mm_shuffle_epi32_2101, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 145 ret procend procstart _uX_mm_shuffle_epi32_2102, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 146 ret procend procstart _uX_mm_shuffle_epi32_2103, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 147 ret procend procstart _uX_mm_shuffle_epi32_2110, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 148 ret procend procstart _uX_mm_shuffle_epi32_2111, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 149 ret procend procstart _uX_mm_shuffle_epi32_2112, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 150 ret procend procstart _uX_mm_shuffle_epi32_2113, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 151 ret procend procstart _uX_mm_shuffle_epi32_2120, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 152 ret procend procstart _uX_mm_shuffle_epi32_2121, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 153 ret procend procstart _uX_mm_shuffle_epi32_2122, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 154 ret procend procstart _uX_mm_shuffle_epi32_2123, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 155 ret procend procstart _uX_mm_shuffle_epi32_2130, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 156 ret procend procstart _uX_mm_shuffle_epi32_2131, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 157 ret procend procstart _uX_mm_shuffle_epi32_2132, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 158 ret procend procstart _uX_mm_shuffle_epi32_2133, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 159 ret procend procstart _uX_mm_shuffle_epi32_2200, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 160 ret procend procstart _uX_mm_shuffle_epi32_2201, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 161 ret procend procstart _uX_mm_shuffle_epi32_2202, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 162 ret procend procstart _uX_mm_shuffle_epi32_2203, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 163 ret procend procstart _uX_mm_shuffle_epi32_2210, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 164 ret procend procstart _uX_mm_shuffle_epi32_2211, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 165 ret procend procstart _uX_mm_shuffle_epi32_2212, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 166 ret procend procstart _uX_mm_shuffle_epi32_2213, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 167 ret procend procstart _uX_mm_shuffle_epi32_2220, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 168 ret procend procstart _uX_mm_shuffle_epi32_2221, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 169 ret procend procstart _uX_mm_shuffle_epi32_2222, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 170 ret procend procstart _uX_mm_shuffle_epi32_2223, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 171 ret procend procstart _uX_mm_shuffle_epi32_2230, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 172 ret procend procstart _uX_mm_shuffle_epi32_2231, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 173 ret procend procstart _uX_mm_shuffle_epi32_2232, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 174 ret procend procstart _uX_mm_shuffle_epi32_2233, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 175 ret procend procstart _uX_mm_shuffle_epi32_2300, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 176 ret procend procstart _uX_mm_shuffle_epi32_2301, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 177 ret procend procstart _uX_mm_shuffle_epi32_2302, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 178 ret procend procstart _uX_mm_shuffle_epi32_2303, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 179 ret procend procstart _uX_mm_shuffle_epi32_2310, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 180 ret procend procstart _uX_mm_shuffle_epi32_2311, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 181 ret procend procstart _uX_mm_shuffle_epi32_2312, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 182 ret procend procstart _uX_mm_shuffle_epi32_2313, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 183 ret procend procstart _uX_mm_shuffle_epi32_2320, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 184 ret procend procstart _uX_mm_shuffle_epi32_2321, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 185 ret procend procstart _uX_mm_shuffle_epi32_2322, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 186 ret procend procstart _uX_mm_shuffle_epi32_2323, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 187 ret procend procstart _uX_mm_shuffle_epi32_2330, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 188 ret procend procstart _uX_mm_shuffle_epi32_2331, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 189 ret procend procstart _uX_mm_shuffle_epi32_2332, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 190 ret procend procstart _uX_mm_shuffle_epi32_2333, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 191 ret procend procstart _uX_mm_shuffle_epi32_3000, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 192 ret procend procstart _uX_mm_shuffle_epi32_3001, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 193 ret procend procstart _uX_mm_shuffle_epi32_3002, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 194 ret procend procstart _uX_mm_shuffle_epi32_3003, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 195 ret procend procstart _uX_mm_shuffle_epi32_3010, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 196 ret procend procstart _uX_mm_shuffle_epi32_3011, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 197 ret procend procstart _uX_mm_shuffle_epi32_3012, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 198 ret procend procstart _uX_mm_shuffle_epi32_3013, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 199 ret procend procstart _uX_mm_shuffle_epi32_3020, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 200 ret procend procstart _uX_mm_shuffle_epi32_3021, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 201 ret procend procstart _uX_mm_shuffle_epi32_3022, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 202 ret procend procstart _uX_mm_shuffle_epi32_3023, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 203 ret procend procstart _uX_mm_shuffle_epi32_3030, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 204 ret procend procstart _uX_mm_shuffle_epi32_3031, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 205 ret procend procstart _uX_mm_shuffle_epi32_3032, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 206 ret procend procstart _uX_mm_shuffle_epi32_3033, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 207 ret procend procstart _uX_mm_shuffle_epi32_3100, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 208 ret procend procstart _uX_mm_shuffle_epi32_3101, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 209 ret procend procstart _uX_mm_shuffle_epi32_3102, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 210 ret procend procstart _uX_mm_shuffle_epi32_3103, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 211 ret procend procstart _uX_mm_shuffle_epi32_3110, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 212 ret procend procstart _uX_mm_shuffle_epi32_3111, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 213 ret procend procstart _uX_mm_shuffle_epi32_3112, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 214 ret procend procstart _uX_mm_shuffle_epi32_3113, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 215 ret procend procstart _uX_mm_shuffle_epi32_3120, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 216 ret procend procstart _uX_mm_shuffle_epi32_3121, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 217 ret procend procstart _uX_mm_shuffle_epi32_3122, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 218 ret procend procstart _uX_mm_shuffle_epi32_3123, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 219 ret procend procstart _uX_mm_shuffle_epi32_3130, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 220 ret procend procstart _uX_mm_shuffle_epi32_3131, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 221 ret procend procstart _uX_mm_shuffle_epi32_3132, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 222 ret procend procstart _uX_mm_shuffle_epi32_3133, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 223 ret procend procstart _uX_mm_shuffle_epi32_3200, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 224 ret procend procstart _uX_mm_shuffle_epi32_3201, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 225 ret procend procstart _uX_mm_shuffle_epi32_3202, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 226 ret procend procstart _uX_mm_shuffle_epi32_3203, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 227 ret procend procstart _uX_mm_shuffle_epi32_3210, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 228 ret procend procstart _uX_mm_shuffle_epi32_3211, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 229 ret procend procstart _uX_mm_shuffle_epi32_3212, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 230 ret procend procstart _uX_mm_shuffle_epi32_3213, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 231 ret procend procstart _uX_mm_shuffle_epi32_3220, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 232 ret procend procstart _uX_mm_shuffle_epi32_3221, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 233 ret procend procstart _uX_mm_shuffle_epi32_3222, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 234 ret procend procstart _uX_mm_shuffle_epi32_3223, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 235 ret procend procstart _uX_mm_shuffle_epi32_3230, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 236 ret procend procstart _uX_mm_shuffle_epi32_3231, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 237 ret procend procstart _uX_mm_shuffle_epi32_3232, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 238 ret procend procstart _uX_mm_shuffle_epi32_3233, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 239 ret procend procstart _uX_mm_shuffle_epi32_3300, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 240 ret procend procstart _uX_mm_shuffle_epi32_3301, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 241 ret procend procstart _uX_mm_shuffle_epi32_3302, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 242 ret procend procstart _uX_mm_shuffle_epi32_3303, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 243 ret procend procstart _uX_mm_shuffle_epi32_3310, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 244 ret procend procstart _uX_mm_shuffle_epi32_3311, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 245 ret procend procstart _uX_mm_shuffle_epi32_3312, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 246 ret procend procstart _uX_mm_shuffle_epi32_3313, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 247 ret procend procstart _uX_mm_shuffle_epi32_3320, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 248 ret procend procstart _uX_mm_shuffle_epi32_3321, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 249 ret procend procstart _uX_mm_shuffle_epi32_3322, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 250 ret procend procstart _uX_mm_shuffle_epi32_3323, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 251 ret procend procstart _uX_mm_shuffle_epi32_3330, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 252 ret procend procstart _uX_mm_shuffle_epi32_3331, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 253 ret procend procstart _uX_mm_shuffle_epi32_3332, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 254 ret procend procstart _uX_mm_shuffle_epi32_3333, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufd xmm0, xmm0, 255 ret procend procstart _uX_mm_shuffle_epi32, callconv, xmmword, < >, < >, Inxmm_A:xmmword, Inint_Imm:dword push rbase() .if((rp1() < 0) || (rp1() > 255)) jmp _m128ishufepi32_end .endif ifdef __X32__ movzx rbase(), byte ptr [rp1()] jmp dword ptr [_m128ishufepi32jmptable+rbase()*size_t_size] else lea rbase(), qword ptr [_m128ishufepi32jmptable] mov rbase(), qword ptr [rbase()+rp1()*size_t_size] jmp rbx endif _m128ishufepi32_0 label size_t pshufd xmm0, xmm0, 0 jmp _m128ishufepi32_end _m128ishufepi32_1 label size_t pshufd xmm0, xmm0, 1 jmp _m128ishufepi32_end _m128ishufepi32_2 label size_t pshufd xmm0, xmm0, 2 jmp _m128ishufepi32_end _m128ishufepi32_3 label size_t pshufd xmm0, xmm0, 3 jmp _m128ishufepi32_end _m128ishufepi32_4 label size_t pshufd xmm0, xmm0, 4 jmp _m128ishufepi32_end _m128ishufepi32_5 label size_t pshufd xmm0, xmm0, 5 jmp _m128ishufepi32_end _m128ishufepi32_6 label size_t pshufd xmm0, xmm0, 6 jmp _m128ishufepi32_end _m128ishufepi32_7 label size_t pshufd xmm0, xmm0, 7 jmp _m128ishufepi32_end _m128ishufepi32_8 label size_t pshufd xmm0, xmm0, 8 jmp _m128ishufepi32_end _m128ishufepi32_9 label size_t pshufd xmm0, xmm0, 9 jmp _m128ishufepi32_end _m128ishufepi32_10 label size_t pshufd xmm0, xmm0, 10 jmp _m128ishufepi32_end _m128ishufepi32_11 label size_t pshufd xmm0, xmm0, 11 jmp _m128ishufepi32_end _m128ishufepi32_12 label size_t pshufd xmm0, xmm0, 12 jmp _m128ishufepi32_end _m128ishufepi32_13 label size_t pshufd xmm0, xmm0, 13 jmp _m128ishufepi32_end _m128ishufepi32_14 label size_t pshufd xmm0, xmm0, 14 jmp _m128ishufepi32_end _m128ishufepi32_15 label size_t pshufd xmm0, xmm0, 15 jmp _m128ishufepi32_end _m128ishufepi32_16 label size_t pshufd xmm0, xmm0, 16 jmp _m128ishufepi32_end _m128ishufepi32_17 label size_t pshufd xmm0, xmm0, 17 jmp _m128ishufepi32_end _m128ishufepi32_18 label size_t pshufd xmm0, xmm0, 18 jmp _m128ishufepi32_end _m128ishufepi32_19 label size_t pshufd xmm0, xmm0, 19 jmp _m128ishufepi32_end _m128ishufepi32_20 label size_t pshufd xmm0, xmm0, 20 jmp _m128ishufepi32_end _m128ishufepi32_21 label size_t pshufd xmm0, xmm0, 21 jmp _m128ishufepi32_end _m128ishufepi32_22 label size_t pshufd xmm0, xmm0, 22 jmp _m128ishufepi32_end _m128ishufepi32_23 label size_t pshufd xmm0, xmm0, 23 jmp _m128ishufepi32_end _m128ishufepi32_24 label size_t pshufd xmm0, xmm0, 24 jmp _m128ishufepi32_end _m128ishufepi32_25 label size_t pshufd xmm0, xmm0, 25 jmp _m128ishufepi32_end _m128ishufepi32_26 label size_t pshufd xmm0, xmm0, 26 jmp _m128ishufepi32_end _m128ishufepi32_27 label size_t pshufd xmm0, xmm0, 27 jmp _m128ishufepi32_end _m128ishufepi32_28 label size_t pshufd xmm0, xmm0, 28 jmp _m128ishufepi32_end _m128ishufepi32_29 label size_t pshufd xmm0, xmm0, 29 jmp _m128ishufepi32_end _m128ishufepi32_30 label size_t pshufd xmm0, xmm0, 30 jmp _m128ishufepi32_end _m128ishufepi32_31 label size_t pshufd xmm0, xmm0, 31 jmp _m128ishufepi32_end _m128ishufepi32_32 label size_t pshufd xmm0, xmm0, 32 jmp _m128ishufepi32_end _m128ishufepi32_33 label size_t pshufd xmm0, xmm0, 33 jmp _m128ishufepi32_end _m128ishufepi32_34 label size_t pshufd xmm0, xmm0, 34 jmp _m128ishufepi32_end _m128ishufepi32_35 label size_t pshufd xmm0, xmm0, 35 jmp _m128ishufepi32_end _m128ishufepi32_36 label size_t pshufd xmm0, xmm0, 36 jmp _m128ishufepi32_end _m128ishufepi32_37 label size_t pshufd xmm0, xmm0, 37 jmp _m128ishufepi32_end _m128ishufepi32_38 label size_t pshufd xmm0, xmm0, 38 jmp _m128ishufepi32_end _m128ishufepi32_39 label size_t pshufd xmm0, xmm0, 39 jmp _m128ishufepi32_end _m128ishufepi32_40 label size_t pshufd xmm0, xmm0, 40 jmp _m128ishufepi32_end _m128ishufepi32_41 label size_t pshufd xmm0, xmm0, 41 jmp _m128ishufepi32_end _m128ishufepi32_42 label size_t pshufd xmm0, xmm0, 42 jmp _m128ishufepi32_end _m128ishufepi32_43 label size_t pshufd xmm0, xmm0, 43 jmp _m128ishufepi32_end _m128ishufepi32_44 label size_t pshufd xmm0, xmm0, 44 jmp _m128ishufepi32_end _m128ishufepi32_45 label size_t pshufd xmm0, xmm0, 45 jmp _m128ishufepi32_end _m128ishufepi32_46 label size_t pshufd xmm0, xmm0, 46 jmp _m128ishufepi32_end _m128ishufepi32_47 label size_t pshufd xmm0, xmm0, 47 jmp _m128ishufepi32_end _m128ishufepi32_48 label size_t pshufd xmm0, xmm0, 48 jmp _m128ishufepi32_end _m128ishufepi32_49 label size_t pshufd xmm0, xmm0, 49 jmp _m128ishufepi32_end _m128ishufepi32_50 label size_t pshufd xmm0, xmm0, 50 jmp _m128ishufepi32_end _m128ishufepi32_51 label size_t pshufd xmm0, xmm0, 51 jmp _m128ishufepi32_end _m128ishufepi32_52 label size_t pshufd xmm0, xmm0, 52 jmp _m128ishufepi32_end _m128ishufepi32_53 label size_t pshufd xmm0, xmm0, 53 jmp _m128ishufepi32_end _m128ishufepi32_54 label size_t pshufd xmm0, xmm0, 54 jmp _m128ishufepi32_end _m128ishufepi32_55 label size_t pshufd xmm0, xmm0, 55 jmp _m128ishufepi32_end _m128ishufepi32_56 label size_t pshufd xmm0, xmm0, 56 jmp _m128ishufepi32_end _m128ishufepi32_57 label size_t pshufd xmm0, xmm0, 57 jmp _m128ishufepi32_end _m128ishufepi32_58 label size_t pshufd xmm0, xmm0, 58 jmp _m128ishufepi32_end _m128ishufepi32_59 label size_t pshufd xmm0, xmm0, 59 jmp _m128ishufepi32_end _m128ishufepi32_60 label size_t pshufd xmm0, xmm0, 60 jmp _m128ishufepi32_end _m128ishufepi32_61 label size_t pshufd xmm0, xmm0, 61 jmp _m128ishufepi32_end _m128ishufepi32_62 label size_t pshufd xmm0, xmm0, 62 jmp _m128ishufepi32_end _m128ishufepi32_63 label size_t pshufd xmm0, xmm0, 63 jmp _m128ishufepi32_end _m128ishufepi32_64 label size_t pshufd xmm0, xmm0, 64 jmp _m128ishufepi32_end _m128ishufepi32_65 label size_t pshufd xmm0, xmm0, 65 jmp _m128ishufepi32_end _m128ishufepi32_66 label size_t pshufd xmm0, xmm0, 66 jmp _m128ishufepi32_end _m128ishufepi32_67 label size_t pshufd xmm0, xmm0, 67 jmp _m128ishufepi32_end _m128ishufepi32_68 label size_t pshufd xmm0, xmm0, 68 jmp _m128ishufepi32_end _m128ishufepi32_69 label size_t pshufd xmm0, xmm0, 69 jmp _m128ishufepi32_end _m128ishufepi32_70 label size_t pshufd xmm0, xmm0, 70 jmp _m128ishufepi32_end _m128ishufepi32_71 label size_t pshufd xmm0, xmm0, 71 jmp _m128ishufepi32_end _m128ishufepi32_72 label size_t pshufd xmm0, xmm0, 72 jmp _m128ishufepi32_end _m128ishufepi32_73 label size_t pshufd xmm0, xmm0, 73 jmp _m128ishufepi32_end _m128ishufepi32_74 label size_t pshufd xmm0, xmm0, 74 jmp _m128ishufepi32_end _m128ishufepi32_75 label size_t pshufd xmm0, xmm0, 75 jmp _m128ishufepi32_end _m128ishufepi32_76 label size_t pshufd xmm0, xmm0, 76 jmp _m128ishufepi32_end _m128ishufepi32_77 label size_t pshufd xmm0, xmm0, 77 jmp _m128ishufepi32_end _m128ishufepi32_78 label size_t pshufd xmm0, xmm0, 78 jmp _m128ishufepi32_end _m128ishufepi32_79 label size_t pshufd xmm0, xmm0, 79 jmp _m128ishufepi32_end _m128ishufepi32_80 label size_t pshufd xmm0, xmm0, 80 jmp _m128ishufepi32_end _m128ishufepi32_81 label size_t pshufd xmm0, xmm0, 81 jmp _m128ishufepi32_end _m128ishufepi32_82 label size_t pshufd xmm0, xmm0, 82 jmp _m128ishufepi32_end _m128ishufepi32_83 label size_t pshufd xmm0, xmm0, 83 jmp _m128ishufepi32_end _m128ishufepi32_84 label size_t pshufd xmm0, xmm0, 84 jmp _m128ishufepi32_end _m128ishufepi32_85 label size_t pshufd xmm0, xmm0, 85 jmp _m128ishufepi32_end _m128ishufepi32_86 label size_t pshufd xmm0, xmm0, 86 jmp _m128ishufepi32_end _m128ishufepi32_87 label size_t pshufd xmm0, xmm0, 87 jmp _m128ishufepi32_end _m128ishufepi32_88 label size_t pshufd xmm0, xmm0, 88 jmp _m128ishufepi32_end _m128ishufepi32_89 label size_t pshufd xmm0, xmm0, 89 jmp _m128ishufepi32_end _m128ishufepi32_90 label size_t pshufd xmm0, xmm0, 90 jmp _m128ishufepi32_end _m128ishufepi32_91 label size_t pshufd xmm0, xmm0, 91 jmp _m128ishufepi32_end _m128ishufepi32_92 label size_t pshufd xmm0, xmm0, 92 jmp _m128ishufepi32_end _m128ishufepi32_93 label size_t pshufd xmm0, xmm0, 93 jmp _m128ishufepi32_end _m128ishufepi32_94 label size_t pshufd xmm0, xmm0, 94 jmp _m128ishufepi32_end _m128ishufepi32_95 label size_t pshufd xmm0, xmm0, 95 jmp _m128ishufepi32_end _m128ishufepi32_96 label size_t pshufd xmm0, xmm0, 96 jmp _m128ishufepi32_end _m128ishufepi32_97 label size_t pshufd xmm0, xmm0, 97 jmp _m128ishufepi32_end _m128ishufepi32_98 label size_t pshufd xmm0, xmm0, 98 jmp _m128ishufepi32_end _m128ishufepi32_99 label size_t pshufd xmm0, xmm0, 99 jmp _m128ishufepi32_end _m128ishufepi32_100 label size_t pshufd xmm0, xmm0, 100 jmp _m128ishufepi32_end _m128ishufepi32_101 label size_t pshufd xmm0, xmm0, 101 jmp _m128ishufepi32_end _m128ishufepi32_102 label size_t pshufd xmm0, xmm0, 102 jmp _m128ishufepi32_end _m128ishufepi32_103 label size_t pshufd xmm0, xmm0, 103 jmp _m128ishufepi32_end _m128ishufepi32_104 label size_t pshufd xmm0, xmm0, 104 jmp _m128ishufepi32_end _m128ishufepi32_105 label size_t pshufd xmm0, xmm0, 105 jmp _m128ishufepi32_end _m128ishufepi32_106 label size_t pshufd xmm0, xmm0, 106 jmp _m128ishufepi32_end _m128ishufepi32_107 label size_t pshufd xmm0, xmm0, 107 jmp _m128ishufepi32_end _m128ishufepi32_108 label size_t pshufd xmm0, xmm0, 108 jmp _m128ishufepi32_end _m128ishufepi32_109 label size_t pshufd xmm0, xmm0, 109 jmp _m128ishufepi32_end _m128ishufepi32_110 label size_t pshufd xmm0, xmm0, 110 jmp _m128ishufepi32_end _m128ishufepi32_111 label size_t pshufd xmm0, xmm0, 111 jmp _m128ishufepi32_end _m128ishufepi32_112 label size_t pshufd xmm0, xmm0, 112 jmp _m128ishufepi32_end _m128ishufepi32_113 label size_t pshufd xmm0, xmm0, 113 jmp _m128ishufepi32_end _m128ishufepi32_114 label size_t pshufd xmm0, xmm0, 114 jmp _m128ishufepi32_end _m128ishufepi32_115 label size_t pshufd xmm0, xmm0, 115 jmp _m128ishufepi32_end _m128ishufepi32_116 label size_t pshufd xmm0, xmm0, 116 jmp _m128ishufepi32_end _m128ishufepi32_117 label size_t pshufd xmm0, xmm0, 117 jmp _m128ishufepi32_end _m128ishufepi32_118 label size_t pshufd xmm0, xmm0, 118 jmp _m128ishufepi32_end _m128ishufepi32_119 label size_t pshufd xmm0, xmm0, 119 jmp _m128ishufepi32_end _m128ishufepi32_120 label size_t pshufd xmm0, xmm0, 120 jmp _m128ishufepi32_end _m128ishufepi32_121 label size_t pshufd xmm0, xmm0, 121 jmp _m128ishufepi32_end _m128ishufepi32_122 label size_t pshufd xmm0, xmm0, 122 jmp _m128ishufepi32_end _m128ishufepi32_123 label size_t pshufd xmm0, xmm0, 123 jmp _m128ishufepi32_end _m128ishufepi32_124 label size_t pshufd xmm0, xmm0, 124 jmp _m128ishufepi32_end _m128ishufepi32_125 label size_t pshufd xmm0, xmm0, 125 jmp _m128ishufepi32_end _m128ishufepi32_126 label size_t pshufd xmm0, xmm0, 126 jmp _m128ishufepi32_end _m128ishufepi32_127 label size_t pshufd xmm0, xmm0, 127 jmp _m128ishufepi32_end _m128ishufepi32_128 label size_t pshufd xmm0, xmm0, 128 jmp _m128ishufepi32_end _m128ishufepi32_129 label size_t pshufd xmm0, xmm0, 129 jmp _m128ishufepi32_end _m128ishufepi32_130 label size_t pshufd xmm0, xmm0, 130 jmp _m128ishufepi32_end _m128ishufepi32_131 label size_t pshufd xmm0, xmm0, 131 jmp _m128ishufepi32_end _m128ishufepi32_132 label size_t pshufd xmm0, xmm0, 132 jmp _m128ishufepi32_end _m128ishufepi32_133 label size_t pshufd xmm0, xmm0, 133 jmp _m128ishufepi32_end _m128ishufepi32_134 label size_t pshufd xmm0, xmm0, 134 jmp _m128ishufepi32_end _m128ishufepi32_135 label size_t pshufd xmm0, xmm0, 135 jmp _m128ishufepi32_end _m128ishufepi32_136 label size_t pshufd xmm0, xmm0, 136 jmp _m128ishufepi32_end _m128ishufepi32_137 label size_t pshufd xmm0, xmm0, 137 jmp _m128ishufepi32_end _m128ishufepi32_138 label size_t pshufd xmm0, xmm0, 138 jmp _m128ishufepi32_end _m128ishufepi32_139 label size_t pshufd xmm0, xmm0, 139 jmp _m128ishufepi32_end _m128ishufepi32_140 label size_t pshufd xmm0, xmm0, 140 jmp _m128ishufepi32_end _m128ishufepi32_141 label size_t pshufd xmm0, xmm0, 141 jmp _m128ishufepi32_end _m128ishufepi32_142 label size_t pshufd xmm0, xmm0, 142 jmp _m128ishufepi32_end _m128ishufepi32_143 label size_t pshufd xmm0, xmm0, 143 jmp _m128ishufepi32_end _m128ishufepi32_144 label size_t pshufd xmm0, xmm0, 144 jmp _m128ishufepi32_end _m128ishufepi32_145 label size_t pshufd xmm0, xmm0, 145 jmp _m128ishufepi32_end _m128ishufepi32_146 label size_t pshufd xmm0, xmm0, 146 jmp _m128ishufepi32_end _m128ishufepi32_147 label size_t pshufd xmm0, xmm0, 147 jmp _m128ishufepi32_end _m128ishufepi32_148 label size_t pshufd xmm0, xmm0, 148 jmp _m128ishufepi32_end _m128ishufepi32_149 label size_t pshufd xmm0, xmm0, 149 jmp _m128ishufepi32_end _m128ishufepi32_150 label size_t pshufd xmm0, xmm0, 150 jmp _m128ishufepi32_end _m128ishufepi32_151 label size_t pshufd xmm0, xmm0, 151 jmp _m128ishufepi32_end _m128ishufepi32_152 label size_t pshufd xmm0, xmm0, 152 jmp _m128ishufepi32_end _m128ishufepi32_153 label size_t pshufd xmm0, xmm0, 153 jmp _m128ishufepi32_end _m128ishufepi32_154 label size_t pshufd xmm0, xmm0, 154 jmp _m128ishufepi32_end _m128ishufepi32_155 label size_t pshufd xmm0, xmm0, 155 jmp _m128ishufepi32_end _m128ishufepi32_156 label size_t pshufd xmm0, xmm0, 156 jmp _m128ishufepi32_end _m128ishufepi32_157 label size_t pshufd xmm0, xmm0, 157 jmp _m128ishufepi32_end _m128ishufepi32_158 label size_t pshufd xmm0, xmm0, 158 jmp _m128ishufepi32_end _m128ishufepi32_159 label size_t pshufd xmm0, xmm0, 159 jmp _m128ishufepi32_end _m128ishufepi32_160 label size_t pshufd xmm0, xmm0, 160 jmp _m128ishufepi32_end _m128ishufepi32_161 label size_t pshufd xmm0, xmm0, 161 jmp _m128ishufepi32_end _m128ishufepi32_162 label size_t pshufd xmm0, xmm0, 162 jmp _m128ishufepi32_end _m128ishufepi32_163 label size_t pshufd xmm0, xmm0, 163 jmp _m128ishufepi32_end _m128ishufepi32_164 label size_t pshufd xmm0, xmm0, 164 jmp _m128ishufepi32_end _m128ishufepi32_165 label size_t pshufd xmm0, xmm0, 165 jmp _m128ishufepi32_end _m128ishufepi32_166 label size_t pshufd xmm0, xmm0, 166 jmp _m128ishufepi32_end _m128ishufepi32_167 label size_t pshufd xmm0, xmm0, 167 jmp _m128ishufepi32_end _m128ishufepi32_168 label size_t pshufd xmm0, xmm0, 168 jmp _m128ishufepi32_end _m128ishufepi32_169 label size_t pshufd xmm0, xmm0, 169 jmp _m128ishufepi32_end _m128ishufepi32_170 label size_t pshufd xmm0, xmm0, 170 jmp _m128ishufepi32_end _m128ishufepi32_171 label size_t pshufd xmm0, xmm0, 171 jmp _m128ishufepi32_end _m128ishufepi32_172 label size_t pshufd xmm0, xmm0, 172 jmp _m128ishufepi32_end _m128ishufepi32_173 label size_t pshufd xmm0, xmm0, 173 jmp _m128ishufepi32_end _m128ishufepi32_174 label size_t pshufd xmm0, xmm0, 174 jmp _m128ishufepi32_end _m128ishufepi32_175 label size_t pshufd xmm0, xmm0, 175 jmp _m128ishufepi32_end _m128ishufepi32_176 label size_t pshufd xmm0, xmm0, 176 jmp _m128ishufepi32_end _m128ishufepi32_177 label size_t pshufd xmm0, xmm0, 177 jmp _m128ishufepi32_end _m128ishufepi32_178 label size_t pshufd xmm0, xmm0, 178 jmp _m128ishufepi32_end _m128ishufepi32_179 label size_t pshufd xmm0, xmm0, 179 jmp _m128ishufepi32_end _m128ishufepi32_180 label size_t pshufd xmm0, xmm0, 180 jmp _m128ishufepi32_end _m128ishufepi32_181 label size_t pshufd xmm0, xmm0, 181 jmp _m128ishufepi32_end _m128ishufepi32_182 label size_t pshufd xmm0, xmm0, 182 jmp _m128ishufepi32_end _m128ishufepi32_183 label size_t pshufd xmm0, xmm0, 183 jmp _m128ishufepi32_end _m128ishufepi32_184 label size_t pshufd xmm0, xmm0, 184 jmp _m128ishufepi32_end _m128ishufepi32_185 label size_t pshufd xmm0, xmm0, 185 jmp _m128ishufepi32_end _m128ishufepi32_186 label size_t pshufd xmm0, xmm0, 186 jmp _m128ishufepi32_end _m128ishufepi32_187 label size_t pshufd xmm0, xmm0, 187 jmp _m128ishufepi32_end _m128ishufepi32_188 label size_t pshufd xmm0, xmm0, 188 jmp _m128ishufepi32_end _m128ishufepi32_189 label size_t pshufd xmm0, xmm0, 189 jmp _m128ishufepi32_end _m128ishufepi32_190 label size_t pshufd xmm0, xmm0, 190 jmp _m128ishufepi32_end _m128ishufepi32_191 label size_t pshufd xmm0, xmm0, 191 jmp _m128ishufepi32_end _m128ishufepi32_192 label size_t pshufd xmm0, xmm0, 192 jmp _m128ishufepi32_end _m128ishufepi32_193 label size_t pshufd xmm0, xmm0, 193 jmp _m128ishufepi32_end _m128ishufepi32_194 label size_t pshufd xmm0, xmm0, 194 jmp _m128ishufepi32_end _m128ishufepi32_195 label size_t pshufd xmm0, xmm0, 195 jmp _m128ishufepi32_end _m128ishufepi32_196 label size_t pshufd xmm0, xmm0, 196 jmp _m128ishufepi32_end _m128ishufepi32_197 label size_t pshufd xmm0, xmm0, 197 jmp _m128ishufepi32_end _m128ishufepi32_198 label size_t pshufd xmm0, xmm0, 198 jmp _m128ishufepi32_end _m128ishufepi32_199 label size_t pshufd xmm0, xmm0, 199 jmp _m128ishufepi32_end _m128ishufepi32_200 label size_t pshufd xmm0, xmm0, 200 jmp _m128ishufepi32_end _m128ishufepi32_201 label size_t pshufd xmm0, xmm0, 201 jmp _m128ishufepi32_end _m128ishufepi32_202 label size_t pshufd xmm0, xmm0, 202 jmp _m128ishufepi32_end _m128ishufepi32_203 label size_t pshufd xmm0, xmm0, 203 jmp _m128ishufepi32_end _m128ishufepi32_204 label size_t pshufd xmm0, xmm0, 204 jmp _m128ishufepi32_end _m128ishufepi32_205 label size_t pshufd xmm0, xmm0, 205 jmp _m128ishufepi32_end _m128ishufepi32_206 label size_t pshufd xmm0, xmm0, 206 jmp _m128ishufepi32_end _m128ishufepi32_207 label size_t pshufd xmm0, xmm0, 207 jmp _m128ishufepi32_end _m128ishufepi32_208 label size_t pshufd xmm0, xmm0, 208 jmp _m128ishufepi32_end _m128ishufepi32_209 label size_t pshufd xmm0, xmm0, 209 jmp _m128ishufepi32_end _m128ishufepi32_210 label size_t pshufd xmm0, xmm0, 210 jmp _m128ishufepi32_end _m128ishufepi32_211 label size_t pshufd xmm0, xmm0, 211 jmp _m128ishufepi32_end _m128ishufepi32_212 label size_t pshufd xmm0, xmm0, 212 jmp _m128ishufepi32_end _m128ishufepi32_213 label size_t pshufd xmm0, xmm0, 213 jmp _m128ishufepi32_end _m128ishufepi32_214 label size_t pshufd xmm0, xmm0, 214 jmp _m128ishufepi32_end _m128ishufepi32_215 label size_t pshufd xmm0, xmm0, 215 jmp _m128ishufepi32_end _m128ishufepi32_216 label size_t pshufd xmm0, xmm0, 216 jmp _m128ishufepi32_end _m128ishufepi32_217 label size_t pshufd xmm0, xmm0, 217 jmp _m128ishufepi32_end _m128ishufepi32_218 label size_t pshufd xmm0, xmm0, 218 jmp _m128ishufepi32_end _m128ishufepi32_219 label size_t pshufd xmm0, xmm0, 219 jmp _m128ishufepi32_end _m128ishufepi32_220 label size_t pshufd xmm0, xmm0, 220 jmp _m128ishufepi32_end _m128ishufepi32_221 label size_t pshufd xmm0, xmm0, 221 jmp _m128ishufepi32_end _m128ishufepi32_222 label size_t pshufd xmm0, xmm0, 222 jmp _m128ishufepi32_end _m128ishufepi32_223 label size_t pshufd xmm0, xmm0, 223 jmp _m128ishufepi32_end _m128ishufepi32_224 label size_t pshufd xmm0, xmm0, 224 jmp _m128ishufepi32_end _m128ishufepi32_225 label size_t pshufd xmm0, xmm0, 225 jmp _m128ishufepi32_end _m128ishufepi32_226 label size_t pshufd xmm0, xmm0, 226 jmp _m128ishufepi32_end _m128ishufepi32_227 label size_t pshufd xmm0, xmm0, 227 jmp _m128ishufepi32_end _m128ishufepi32_228 label size_t pshufd xmm0, xmm0, 228 jmp _m128ishufepi32_end _m128ishufepi32_229 label size_t pshufd xmm0, xmm0, 229 jmp _m128ishufepi32_end _m128ishufepi32_230 label size_t pshufd xmm0, xmm0, 230 jmp _m128ishufepi32_end _m128ishufepi32_231 label size_t pshufd xmm0, xmm0, 231 jmp _m128ishufepi32_end _m128ishufepi32_232 label size_t pshufd xmm0, xmm0, 232 jmp _m128ishufepi32_end _m128ishufepi32_233 label size_t pshufd xmm0, xmm0, 233 jmp _m128ishufepi32_end _m128ishufepi32_234 label size_t pshufd xmm0, xmm0, 234 jmp _m128ishufepi32_end _m128ishufepi32_235 label size_t pshufd xmm0, xmm0, 235 jmp _m128ishufepi32_end _m128ishufepi32_236 label size_t pshufd xmm0, xmm0, 236 jmp _m128ishufepi32_end _m128ishufepi32_237 label size_t pshufd xmm0, xmm0, 237 jmp _m128ishufepi32_end _m128ishufepi32_238 label size_t pshufd xmm0, xmm0, 238 jmp _m128ishufepi32_end _m128ishufepi32_239 label size_t pshufd xmm0, xmm0, 239 jmp _m128ishufepi32_end _m128ishufepi32_240 label size_t pshufd xmm0, xmm0, 240 jmp _m128ishufepi32_end _m128ishufepi32_241 label size_t pshufd xmm0, xmm0, 241 jmp _m128ishufepi32_end _m128ishufepi32_242 label size_t pshufd xmm0, xmm0, 242 jmp _m128ishufepi32_end _m128ishufepi32_243 label size_t pshufd xmm0, xmm0, 243 jmp _m128ishufepi32_end _m128ishufepi32_244 label size_t pshufd xmm0, xmm0, 244 jmp _m128ishufepi32_end _m128ishufepi32_245 label size_t pshufd xmm0, xmm0, 245 jmp _m128ishufepi32_end _m128ishufepi32_246 label size_t pshufd xmm0, xmm0, 246 jmp _m128ishufepi32_end _m128ishufepi32_247 label size_t pshufd xmm0, xmm0, 247 jmp _m128ishufepi32_end _m128ishufepi32_248 label size_t pshufd xmm0, xmm0, 248 jmp _m128ishufepi32_end _m128ishufepi32_249 label size_t pshufd xmm0, xmm0, 249 jmp _m128ishufepi32_end _m128ishufepi32_250 label size_t pshufd xmm0, xmm0, 250 jmp _m128ishufepi32_end _m128ishufepi32_251 label size_t pshufd xmm0, xmm0, 251 jmp _m128ishufepi32_end _m128ishufepi32_252 label size_t pshufd xmm0, xmm0, 252 jmp _m128ishufepi32_end _m128ishufepi32_253 label size_t pshufd xmm0, xmm0, 253 jmp _m128ishufepi32_end _m128ishufepi32_254 label size_t pshufd xmm0, xmm0, 254 jmp _m128ishufepi32_end _m128ishufepi32_255 label size_t pshufd xmm0, xmm0, 255 ;jmp _m128ishufepi32_end _m128ishufepi32_end: pop rbase() ret procend procstart _uX_mm_shufflehi_epi16_0000, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 0 ret procend procstart _uX_mm_shufflehi_epi16_0001, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 1 ret procend procstart _uX_mm_shufflehi_epi16_0002, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 2 ret procend procstart _uX_mm_shufflehi_epi16_0003, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 3 ret procend procstart _uX_mm_shufflehi_epi16_0010, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 4 ret procend procstart _uX_mm_shufflehi_epi16_0011, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 5 ret procend procstart _uX_mm_shufflehi_epi16_0012, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 6 ret procend procstart _uX_mm_shufflehi_epi16_0013, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 7 ret procend procstart _uX_mm_shufflehi_epi16_0020, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 8 ret procend procstart _uX_mm_shufflehi_epi16_0021, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 9 ret procend procstart _uX_mm_shufflehi_epi16_0022, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 10 ret procend procstart _uX_mm_shufflehi_epi16_0023, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 11 ret procend procstart _uX_mm_shufflehi_epi16_0030, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 12 ret procend procstart _uX_mm_shufflehi_epi16_0031, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 13 ret procend procstart _uX_mm_shufflehi_epi16_0032, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 14 ret procend procstart _uX_mm_shufflehi_epi16_0033, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 15 ret procend procstart _uX_mm_shufflehi_epi16_0100, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 16 ret procend procstart _uX_mm_shufflehi_epi16_0101, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 17 ret procend procstart _uX_mm_shufflehi_epi16_0102, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 18 ret procend procstart _uX_mm_shufflehi_epi16_0103, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 19 ret procend procstart _uX_mm_shufflehi_epi16_0110, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 20 ret procend procstart _uX_mm_shufflehi_epi16_0111, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 21 ret procend procstart _uX_mm_shufflehi_epi16_0112, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 22 ret procend procstart _uX_mm_shufflehi_epi16_0113, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 23 ret procend procstart _uX_mm_shufflehi_epi16_0120, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 24 ret procend procstart _uX_mm_shufflehi_epi16_0121, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 25 ret procend procstart _uX_mm_shufflehi_epi16_0122, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 26 ret procend procstart _uX_mm_shufflehi_epi16_0123, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 27 ret procend procstart _uX_mm_shufflehi_epi16_0130, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 28 ret procend procstart _uX_mm_shufflehi_epi16_0131, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 29 ret procend procstart _uX_mm_shufflehi_epi16_0132, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 30 ret procend procstart _uX_mm_shufflehi_epi16_0133, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 31 ret procend procstart _uX_mm_shufflehi_epi16_0200, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 32 ret procend procstart _uX_mm_shufflehi_epi16_0201, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 33 ret procend procstart _uX_mm_shufflehi_epi16_0202, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 34 ret procend procstart _uX_mm_shufflehi_epi16_0203, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 35 ret procend procstart _uX_mm_shufflehi_epi16_0210, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 36 ret procend procstart _uX_mm_shufflehi_epi16_0211, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 37 ret procend procstart _uX_mm_shufflehi_epi16_0212, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 38 ret procend procstart _uX_mm_shufflehi_epi16_0213, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 39 ret procend procstart _uX_mm_shufflehi_epi16_0220, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 40 ret procend procstart _uX_mm_shufflehi_epi16_0221, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 41 ret procend procstart _uX_mm_shufflehi_epi16_0222, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 42 ret procend procstart _uX_mm_shufflehi_epi16_0223, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 43 ret procend procstart _uX_mm_shufflehi_epi16_0230, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 44 ret procend procstart _uX_mm_shufflehi_epi16_0231, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 45 ret procend procstart _uX_mm_shufflehi_epi16_0232, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 46 ret procend procstart _uX_mm_shufflehi_epi16_0233, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 47 ret procend procstart _uX_mm_shufflehi_epi16_0300, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 48 ret procend procstart _uX_mm_shufflehi_epi16_0301, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 49 ret procend procstart _uX_mm_shufflehi_epi16_0302, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 50 ret procend procstart _uX_mm_shufflehi_epi16_0303, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 51 ret procend procstart _uX_mm_shufflehi_epi16_0310, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 52 ret procend procstart _uX_mm_shufflehi_epi16_0311, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 53 ret procend procstart _uX_mm_shufflehi_epi16_0312, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 54 ret procend procstart _uX_mm_shufflehi_epi16_0313, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 55 ret procend procstart _uX_mm_shufflehi_epi16_0320, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 56 ret procend procstart _uX_mm_shufflehi_epi16_0321, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 57 ret procend procstart _uX_mm_shufflehi_epi16_0322, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 58 ret procend procstart _uX_mm_shufflehi_epi16_0323, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 59 ret procend procstart _uX_mm_shufflehi_epi16_0330, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 60 ret procend procstart _uX_mm_shufflehi_epi16_0331, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 61 ret procend procstart _uX_mm_shufflehi_epi16_0332, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 62 ret procend procstart _uX_mm_shufflehi_epi16_0333, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 63 ret procend procstart _uX_mm_shufflehi_epi16_1000, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 64 ret procend procstart _uX_mm_shufflehi_epi16_1001, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 65 ret procend procstart _uX_mm_shufflehi_epi16_1002, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 66 ret procend procstart _uX_mm_shufflehi_epi16_1003, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 67 ret procend procstart _uX_mm_shufflehi_epi16_1010, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 68 ret procend procstart _uX_mm_shufflehi_epi16_1011, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 69 ret procend procstart _uX_mm_shufflehi_epi16_1012, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 70 ret procend procstart _uX_mm_shufflehi_epi16_1013, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 71 ret procend procstart _uX_mm_shufflehi_epi16_1020, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 72 ret procend procstart _uX_mm_shufflehi_epi16_1021, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 73 ret procend procstart _uX_mm_shufflehi_epi16_1022, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 74 ret procend procstart _uX_mm_shufflehi_epi16_1023, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 75 ret procend procstart _uX_mm_shufflehi_epi16_1030, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 76 ret procend procstart _uX_mm_shufflehi_epi16_1031, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 77 ret procend procstart _uX_mm_shufflehi_epi16_1032, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 78 ret procend procstart _uX_mm_shufflehi_epi16_1033, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 79 ret procend procstart _uX_mm_shufflehi_epi16_1100, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 80 ret procend procstart _uX_mm_shufflehi_epi16_1101, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 81 ret procend procstart _uX_mm_shufflehi_epi16_1102, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 82 ret procend procstart _uX_mm_shufflehi_epi16_1103, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 83 ret procend procstart _uX_mm_shufflehi_epi16_1110, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 84 ret procend procstart _uX_mm_shufflehi_epi16_1111, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 85 ret procend procstart _uX_mm_shufflehi_epi16_1112, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 86 ret procend procstart _uX_mm_shufflehi_epi16_1113, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 87 ret procend procstart _uX_mm_shufflehi_epi16_1120, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 88 ret procend procstart _uX_mm_shufflehi_epi16_1121, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 89 ret procend procstart _uX_mm_shufflehi_epi16_1122, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 90 ret procend procstart _uX_mm_shufflehi_epi16_1123, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 91 ret procend procstart _uX_mm_shufflehi_epi16_1130, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 92 ret procend procstart _uX_mm_shufflehi_epi16_1131, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 93 ret procend procstart _uX_mm_shufflehi_epi16_1132, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 94 ret procend procstart _uX_mm_shufflehi_epi16_1133, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 95 ret procend procstart _uX_mm_shufflehi_epi16_1200, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 96 ret procend procstart _uX_mm_shufflehi_epi16_1201, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 97 ret procend procstart _uX_mm_shufflehi_epi16_1202, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 98 ret procend procstart _uX_mm_shufflehi_epi16_1203, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 99 ret procend procstart _uX_mm_shufflehi_epi16_1210, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 100 ret procend procstart _uX_mm_shufflehi_epi16_1211, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 101 ret procend procstart _uX_mm_shufflehi_epi16_1212, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 102 ret procend procstart _uX_mm_shufflehi_epi16_1213, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 103 ret procend procstart _uX_mm_shufflehi_epi16_1220, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 104 ret procend procstart _uX_mm_shufflehi_epi16_1221, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 105 ret procend procstart _uX_mm_shufflehi_epi16_1222, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 106 ret procend procstart _uX_mm_shufflehi_epi16_1223, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 107 ret procend procstart _uX_mm_shufflehi_epi16_1230, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 108 ret procend procstart _uX_mm_shufflehi_epi16_1231, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 109 ret procend procstart _uX_mm_shufflehi_epi16_1232, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 110 ret procend procstart _uX_mm_shufflehi_epi16_1233, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 111 ret procend procstart _uX_mm_shufflehi_epi16_1300, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 112 ret procend procstart _uX_mm_shufflehi_epi16_1301, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 113 ret procend procstart _uX_mm_shufflehi_epi16_1302, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 114 ret procend procstart _uX_mm_shufflehi_epi16_1303, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 115 ret procend procstart _uX_mm_shufflehi_epi16_1310, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 116 ret procend procstart _uX_mm_shufflehi_epi16_1311, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 117 ret procend procstart _uX_mm_shufflehi_epi16_1312, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 118 ret procend procstart _uX_mm_shufflehi_epi16_1313, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 119 ret procend procstart _uX_mm_shufflehi_epi16_1320, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 120 ret procend procstart _uX_mm_shufflehi_epi16_1321, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 121 ret procend procstart _uX_mm_shufflehi_epi16_1322, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 122 ret procend procstart _uX_mm_shufflehi_epi16_1323, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 123 ret procend procstart _uX_mm_shufflehi_epi16_1330, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 124 ret procend procstart _uX_mm_shufflehi_epi16_1331, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 125 ret procend procstart _uX_mm_shufflehi_epi16_1332, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 126 ret procend procstart _uX_mm_shufflehi_epi16_1333, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 127 ret procend procstart _uX_mm_shufflehi_epi16_2000, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 128 ret procend procstart _uX_mm_shufflehi_epi16_2001, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 129 ret procend procstart _uX_mm_shufflehi_epi16_2002, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 130 ret procend procstart _uX_mm_shufflehi_epi16_2003, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 131 ret procend procstart _uX_mm_shufflehi_epi16_2010, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 132 ret procend procstart _uX_mm_shufflehi_epi16_2011, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 133 ret procend procstart _uX_mm_shufflehi_epi16_2012, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 134 ret procend procstart _uX_mm_shufflehi_epi16_2013, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 135 ret procend procstart _uX_mm_shufflehi_epi16_2020, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 136 ret procend procstart _uX_mm_shufflehi_epi16_2021, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 137 ret procend procstart _uX_mm_shufflehi_epi16_2022, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 138 ret procend procstart _uX_mm_shufflehi_epi16_2023, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 139 ret procend procstart _uX_mm_shufflehi_epi16_2030, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 140 ret procend procstart _uX_mm_shufflehi_epi16_2031, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 141 ret procend procstart _uX_mm_shufflehi_epi16_2032, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 142 ret procend procstart _uX_mm_shufflehi_epi16_2033, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 143 ret procend procstart _uX_mm_shufflehi_epi16_2100, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 144 ret procend procstart _uX_mm_shufflehi_epi16_2101, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 145 ret procend procstart _uX_mm_shufflehi_epi16_2102, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 146 ret procend procstart _uX_mm_shufflehi_epi16_2103, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 147 ret procend procstart _uX_mm_shufflehi_epi16_2110, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 148 ret procend procstart _uX_mm_shufflehi_epi16_2111, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 149 ret procend procstart _uX_mm_shufflehi_epi16_2112, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 150 ret procend procstart _uX_mm_shufflehi_epi16_2113, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 151 ret procend procstart _uX_mm_shufflehi_epi16_2120, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 152 ret procend procstart _uX_mm_shufflehi_epi16_2121, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 153 ret procend procstart _uX_mm_shufflehi_epi16_2122, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 154 ret procend procstart _uX_mm_shufflehi_epi16_2123, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 155 ret procend procstart _uX_mm_shufflehi_epi16_2130, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 156 ret procend procstart _uX_mm_shufflehi_epi16_2131, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 157 ret procend procstart _uX_mm_shufflehi_epi16_2132, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 158 ret procend procstart _uX_mm_shufflehi_epi16_2133, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 159 ret procend procstart _uX_mm_shufflehi_epi16_2200, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 160 ret procend procstart _uX_mm_shufflehi_epi16_2201, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 161 ret procend procstart _uX_mm_shufflehi_epi16_2202, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 162 ret procend procstart _uX_mm_shufflehi_epi16_2203, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 163 ret procend procstart _uX_mm_shufflehi_epi16_2210, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 164 ret procend procstart _uX_mm_shufflehi_epi16_2211, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 165 ret procend procstart _uX_mm_shufflehi_epi16_2212, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 166 ret procend procstart _uX_mm_shufflehi_epi16_2213, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 167 ret procend procstart _uX_mm_shufflehi_epi16_2220, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 168 ret procend procstart _uX_mm_shufflehi_epi16_2221, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 169 ret procend procstart _uX_mm_shufflehi_epi16_2222, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 170 ret procend procstart _uX_mm_shufflehi_epi16_2223, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 171 ret procend procstart _uX_mm_shufflehi_epi16_2230, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 172 ret procend procstart _uX_mm_shufflehi_epi16_2231, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 173 ret procend procstart _uX_mm_shufflehi_epi16_2232, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 174 ret procend procstart _uX_mm_shufflehi_epi16_2233, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 175 ret procend procstart _uX_mm_shufflehi_epi16_2300, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 176 ret procend procstart _uX_mm_shufflehi_epi16_2301, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 177 ret procend procstart _uX_mm_shufflehi_epi16_2302, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 178 ret procend procstart _uX_mm_shufflehi_epi16_2303, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 179 ret procend procstart _uX_mm_shufflehi_epi16_2310, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 180 ret procend procstart _uX_mm_shufflehi_epi16_2311, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 181 ret procend procstart _uX_mm_shufflehi_epi16_2312, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 182 ret procend procstart _uX_mm_shufflehi_epi16_2313, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 183 ret procend procstart _uX_mm_shufflehi_epi16_2320, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 184 ret procend procstart _uX_mm_shufflehi_epi16_2321, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 185 ret procend procstart _uX_mm_shufflehi_epi16_2322, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 186 ret procend procstart _uX_mm_shufflehi_epi16_2323, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 187 ret procend procstart _uX_mm_shufflehi_epi16_2330, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 188 ret procend procstart _uX_mm_shufflehi_epi16_2331, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 189 ret procend procstart _uX_mm_shufflehi_epi16_2332, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 190 ret procend procstart _uX_mm_shufflehi_epi16_2333, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 191 ret procend procstart _uX_mm_shufflehi_epi16_3000, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 192 ret procend procstart _uX_mm_shufflehi_epi16_3001, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 193 ret procend procstart _uX_mm_shufflehi_epi16_3002, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 194 ret procend procstart _uX_mm_shufflehi_epi16_3003, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 195 ret procend procstart _uX_mm_shufflehi_epi16_3010, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 196 ret procend procstart _uX_mm_shufflehi_epi16_3011, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 197 ret procend procstart _uX_mm_shufflehi_epi16_3012, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 198 ret procend procstart _uX_mm_shufflehi_epi16_3013, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 199 ret procend procstart _uX_mm_shufflehi_epi16_3020, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 200 ret procend procstart _uX_mm_shufflehi_epi16_3021, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 201 ret procend procstart _uX_mm_shufflehi_epi16_3022, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 202 ret procend procstart _uX_mm_shufflehi_epi16_3023, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 203 ret procend procstart _uX_mm_shufflehi_epi16_3030, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 204 ret procend procstart _uX_mm_shufflehi_epi16_3031, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 205 ret procend procstart _uX_mm_shufflehi_epi16_3032, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 206 ret procend procstart _uX_mm_shufflehi_epi16_3033, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 207 ret procend procstart _uX_mm_shufflehi_epi16_3100, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 208 ret procend procstart _uX_mm_shufflehi_epi16_3101, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 209 ret procend procstart _uX_mm_shufflehi_epi16_3102, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 210 ret procend procstart _uX_mm_shufflehi_epi16_3103, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 211 ret procend procstart _uX_mm_shufflehi_epi16_3110, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 212 ret procend procstart _uX_mm_shufflehi_epi16_3111, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 213 ret procend procstart _uX_mm_shufflehi_epi16_3112, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 214 ret procend procstart _uX_mm_shufflehi_epi16_3113, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 215 ret procend procstart _uX_mm_shufflehi_epi16_3120, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 216 ret procend procstart _uX_mm_shufflehi_epi16_3121, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 217 ret procend procstart _uX_mm_shufflehi_epi16_3122, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 218 ret procend procstart _uX_mm_shufflehi_epi16_3123, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 219 ret procend procstart _uX_mm_shufflehi_epi16_3130, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 220 ret procend procstart _uX_mm_shufflehi_epi16_3131, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 221 ret procend procstart _uX_mm_shufflehi_epi16_3132, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 222 ret procend procstart _uX_mm_shufflehi_epi16_3133, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 223 ret procend procstart _uX_mm_shufflehi_epi16_3200, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 224 ret procend procstart _uX_mm_shufflehi_epi16_3201, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 225 ret procend procstart _uX_mm_shufflehi_epi16_3202, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 226 ret procend procstart _uX_mm_shufflehi_epi16_3203, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 227 ret procend procstart _uX_mm_shufflehi_epi16_3210, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 228 ret procend procstart _uX_mm_shufflehi_epi16_3211, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 229 ret procend procstart _uX_mm_shufflehi_epi16_3212, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 230 ret procend procstart _uX_mm_shufflehi_epi16_3213, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 231 ret procend procstart _uX_mm_shufflehi_epi16_3220, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 232 ret procend procstart _uX_mm_shufflehi_epi16_3221, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 233 ret procend procstart _uX_mm_shufflehi_epi16_3222, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 234 ret procend procstart _uX_mm_shufflehi_epi16_3223, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 235 ret procend procstart _uX_mm_shufflehi_epi16_3230, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 236 ret procend procstart _uX_mm_shufflehi_epi16_3231, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 237 ret procend procstart _uX_mm_shufflehi_epi16_3232, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 238 ret procend procstart _uX_mm_shufflehi_epi16_3233, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 239 ret procend procstart _uX_mm_shufflehi_epi16_3300, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 240 ret procend procstart _uX_mm_shufflehi_epi16_3301, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 241 ret procend procstart _uX_mm_shufflehi_epi16_3302, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 242 ret procend procstart _uX_mm_shufflehi_epi16_3303, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 243 ret procend procstart _uX_mm_shufflehi_epi16_3310, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 244 ret procend procstart _uX_mm_shufflehi_epi16_3311, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 245 ret procend procstart _uX_mm_shufflehi_epi16_3312, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 246 ret procend procstart _uX_mm_shufflehi_epi16_3313, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 247 ret procend procstart _uX_mm_shufflehi_epi16_3320, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 248 ret procend procstart _uX_mm_shufflehi_epi16_3321, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 249 ret procend procstart _uX_mm_shufflehi_epi16_3322, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 250 ret procend procstart _uX_mm_shufflehi_epi16_3323, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 251 ret procend procstart _uX_mm_shufflehi_epi16_3330, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 252 ret procend procstart _uX_mm_shufflehi_epi16_3331, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 253 ret procend procstart _uX_mm_shufflehi_epi16_3332, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 254 ret procend procstart _uX_mm_shufflehi_epi16_3333, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshufhw xmm0, xmm0, 255 ret procend procstart _uX_mm_shufflehi_epi16, callconv, xmmword, < >, < >, Inxmm_A:xmmword, Inint_Imm:dword push rbase() .if((rp1() < 0) || (rp1() > 255)) jmp _m128ishufhiepi16_end .endif ifdef __X32__ movzx rbase(), byte ptr [rp1()] jmp dword ptr [_m128ishufhiepi16jmptable+rbase()*size_t_size] else lea rbase(), qword ptr [_m128ishufhiepi16jmptable] mov rbase(), qword ptr [rbase()+rp1()*size_t_size] jmp rbx endif _m128ishufhiepi16_0 label size_t pshufhw xmm0, xmm0, 0 jmp _m128ishufhiepi16_end _m128ishufhiepi16_1 label size_t pshufhw xmm0, xmm0, 1 jmp _m128ishufhiepi16_end _m128ishufhiepi16_2 label size_t pshufhw xmm0, xmm0, 2 jmp _m128ishufhiepi16_end _m128ishufhiepi16_3 label size_t pshufhw xmm0, xmm0, 3 jmp _m128ishufhiepi16_end _m128ishufhiepi16_4 label size_t pshufhw xmm0, xmm0, 4 jmp _m128ishufhiepi16_end _m128ishufhiepi16_5 label size_t pshufhw xmm0, xmm0, 5 jmp _m128ishufhiepi16_end _m128ishufhiepi16_6 label size_t pshufhw xmm0, xmm0, 6 jmp _m128ishufhiepi16_end _m128ishufhiepi16_7 label size_t pshufhw xmm0, xmm0, 7 jmp _m128ishufhiepi16_end _m128ishufhiepi16_8 label size_t pshufhw xmm0, xmm0, 8 jmp _m128ishufhiepi16_end _m128ishufhiepi16_9 label size_t pshufhw xmm0, xmm0, 9 jmp _m128ishufhiepi16_end _m128ishufhiepi16_10 label size_t pshufhw xmm0, xmm0, 10 jmp _m128ishufhiepi16_end _m128ishufhiepi16_11 label size_t pshufhw xmm0, xmm0, 11 jmp _m128ishufhiepi16_end _m128ishufhiepi16_12 label size_t pshufhw xmm0, xmm0, 12 jmp _m128ishufhiepi16_end _m128ishufhiepi16_13 label size_t pshufhw xmm0, xmm0, 13 jmp _m128ishufhiepi16_end _m128ishufhiepi16_14 label size_t pshufhw xmm0, xmm0, 14 jmp _m128ishufhiepi16_end _m128ishufhiepi16_15 label size_t pshufhw xmm0, xmm0, 15 jmp _m128ishufhiepi16_end _m128ishufhiepi16_16 label size_t pshufhw xmm0, xmm0, 16 jmp _m128ishufhiepi16_end _m128ishufhiepi16_17 label size_t pshufhw xmm0, xmm0, 17 jmp _m128ishufhiepi16_end _m128ishufhiepi16_18 label size_t pshufhw xmm0, xmm0, 18 jmp _m128ishufhiepi16_end _m128ishufhiepi16_19 label size_t pshufhw xmm0, xmm0, 19 jmp _m128ishufhiepi16_end _m128ishufhiepi16_20 label size_t pshufhw xmm0, xmm0, 20 jmp _m128ishufhiepi16_end _m128ishufhiepi16_21 label size_t pshufhw xmm0, xmm0, 21 jmp _m128ishufhiepi16_end _m128ishufhiepi16_22 label size_t pshufhw xmm0, xmm0, 22 jmp _m128ishufhiepi16_end _m128ishufhiepi16_23 label size_t pshufhw xmm0, xmm0, 23 jmp _m128ishufhiepi16_end _m128ishufhiepi16_24 label size_t pshufhw xmm0, xmm0, 24 jmp _m128ishufhiepi16_end _m128ishufhiepi16_25 label size_t pshufhw xmm0, xmm0, 25 jmp _m128ishufhiepi16_end _m128ishufhiepi16_26 label size_t pshufhw xmm0, xmm0, 26 jmp _m128ishufhiepi16_end _m128ishufhiepi16_27 label size_t pshufhw xmm0, xmm0, 27 jmp _m128ishufhiepi16_end _m128ishufhiepi16_28 label size_t pshufhw xmm0, xmm0, 28 jmp _m128ishufhiepi16_end _m128ishufhiepi16_29 label size_t pshufhw xmm0, xmm0, 29 jmp _m128ishufhiepi16_end _m128ishufhiepi16_30 label size_t pshufhw xmm0, xmm0, 30 jmp _m128ishufhiepi16_end _m128ishufhiepi16_31 label size_t pshufhw xmm0, xmm0, 31 jmp _m128ishufhiepi16_end _m128ishufhiepi16_32 label size_t pshufhw xmm0, xmm0, 32 jmp _m128ishufhiepi16_end _m128ishufhiepi16_33 label size_t pshufhw xmm0, xmm0, 33 jmp _m128ishufhiepi16_end _m128ishufhiepi16_34 label size_t pshufhw xmm0, xmm0, 34 jmp _m128ishufhiepi16_end _m128ishufhiepi16_35 label size_t pshufhw xmm0, xmm0, 35 jmp _m128ishufhiepi16_end _m128ishufhiepi16_36 label size_t pshufhw xmm0, xmm0, 36 jmp _m128ishufhiepi16_end _m128ishufhiepi16_37 label size_t pshufhw xmm0, xmm0, 37 jmp _m128ishufhiepi16_end _m128ishufhiepi16_38 label size_t pshufhw xmm0, xmm0, 38 jmp _m128ishufhiepi16_end _m128ishufhiepi16_39 label size_t pshufhw xmm0, xmm0, 39 jmp _m128ishufhiepi16_end _m128ishufhiepi16_40 label size_t pshufhw xmm0, xmm0, 40 jmp _m128ishufhiepi16_end _m128ishufhiepi16_41 label size_t pshufhw xmm0, xmm0, 41 jmp _m128ishufhiepi16_end _m128ishufhiepi16_42 label size_t pshufhw xmm0, xmm0, 42 jmp _m128ishufhiepi16_end _m128ishufhiepi16_43 label size_t pshufhw xmm0, xmm0, 43 jmp _m128ishufhiepi16_end _m128ishufhiepi16_44 label size_t pshufhw xmm0, xmm0, 44 jmp _m128ishufhiepi16_end _m128ishufhiepi16_45 label size_t pshufhw xmm0, xmm0, 45 jmp _m128ishufhiepi16_end _m128ishufhiepi16_46 label size_t pshufhw xmm0, xmm0, 46 jmp _m128ishufhiepi16_end _m128ishufhiepi16_47 label size_t pshufhw xmm0, xmm0, 47 jmp _m128ishufhiepi16_end _m128ishufhiepi16_48 label size_t pshufhw xmm0, xmm0, 48 jmp _m128ishufhiepi16_end _m128ishufhiepi16_49 label size_t pshufhw xmm0, xmm0, 49 jmp _m128ishufhiepi16_end _m128ishufhiepi16_50 label size_t pshufhw xmm0, xmm0, 50 jmp _m128ishufhiepi16_end _m128ishufhiepi16_51 label size_t pshufhw xmm0, xmm0, 51 jmp _m128ishufhiepi16_end _m128ishufhiepi16_52 label size_t pshufhw xmm0, xmm0, 52 jmp _m128ishufhiepi16_end _m128ishufhiepi16_53 label size_t pshufhw xmm0, xmm0, 53 jmp _m128ishufhiepi16_end _m128ishufhiepi16_54 label size_t pshufhw xmm0, xmm0, 54 jmp _m128ishufhiepi16_end _m128ishufhiepi16_55 label size_t pshufhw xmm0, xmm0, 55 jmp _m128ishufhiepi16_end _m128ishufhiepi16_56 label size_t pshufhw xmm0, xmm0, 56 jmp _m128ishufhiepi16_end _m128ishufhiepi16_57 label size_t pshufhw xmm0, xmm0, 57 jmp _m128ishufhiepi16_end _m128ishufhiepi16_58 label size_t pshufhw xmm0, xmm0, 58 jmp _m128ishufhiepi16_end _m128ishufhiepi16_59 label size_t pshufhw xmm0, xmm0, 59 jmp _m128ishufhiepi16_end _m128ishufhiepi16_60 label size_t pshufhw xmm0, xmm0, 60 jmp _m128ishufhiepi16_end _m128ishufhiepi16_61 label size_t pshufhw xmm0, xmm0, 61 jmp _m128ishufhiepi16_end _m128ishufhiepi16_62 label size_t pshufhw xmm0, xmm0, 62 jmp _m128ishufhiepi16_end _m128ishufhiepi16_63 label size_t pshufhw xmm0, xmm0, 63 jmp _m128ishufhiepi16_end _m128ishufhiepi16_64 label size_t pshufhw xmm0, xmm0, 64 jmp _m128ishufhiepi16_end _m128ishufhiepi16_65 label size_t pshufhw xmm0, xmm0, 65 jmp _m128ishufhiepi16_end _m128ishufhiepi16_66 label size_t pshufhw xmm0, xmm0, 66 jmp _m128ishufhiepi16_end _m128ishufhiepi16_67 label size_t pshufhw xmm0, xmm0, 67 jmp _m128ishufhiepi16_end _m128ishufhiepi16_68 label size_t pshufhw xmm0, xmm0, 68 jmp _m128ishufhiepi16_end _m128ishufhiepi16_69 label size_t pshufhw xmm0, xmm0, 69 jmp _m128ishufhiepi16_end _m128ishufhiepi16_70 label size_t pshufhw xmm0, xmm0, 70 jmp _m128ishufhiepi16_end _m128ishufhiepi16_71 label size_t pshufhw xmm0, xmm0, 71 jmp _m128ishufhiepi16_end _m128ishufhiepi16_72 label size_t pshufhw xmm0, xmm0, 72 jmp _m128ishufhiepi16_end _m128ishufhiepi16_73 label size_t pshufhw xmm0, xmm0, 73 jmp _m128ishufhiepi16_end _m128ishufhiepi16_74 label size_t pshufhw xmm0, xmm0, 74 jmp _m128ishufhiepi16_end _m128ishufhiepi16_75 label size_t pshufhw xmm0, xmm0, 75 jmp _m128ishufhiepi16_end _m128ishufhiepi16_76 label size_t pshufhw xmm0, xmm0, 76 jmp _m128ishufhiepi16_end _m128ishufhiepi16_77 label size_t pshufhw xmm0, xmm0, 77 jmp _m128ishufhiepi16_end _m128ishufhiepi16_78 label size_t pshufhw xmm0, xmm0, 78 jmp _m128ishufhiepi16_end _m128ishufhiepi16_79 label size_t pshufhw xmm0, xmm0, 79 jmp _m128ishufhiepi16_end _m128ishufhiepi16_80 label size_t pshufhw xmm0, xmm0, 80 jmp _m128ishufhiepi16_end _m128ishufhiepi16_81 label size_t pshufhw xmm0, xmm0, 81 jmp _m128ishufhiepi16_end _m128ishufhiepi16_82 label size_t pshufhw xmm0, xmm0, 82 jmp _m128ishufhiepi16_end _m128ishufhiepi16_83 label size_t pshufhw xmm0, xmm0, 83 jmp _m128ishufhiepi16_end _m128ishufhiepi16_84 label size_t pshufhw xmm0, xmm0, 84 jmp _m128ishufhiepi16_end _m128ishufhiepi16_85 label size_t pshufhw xmm0, xmm0, 85 jmp _m128ishufhiepi16_end _m128ishufhiepi16_86 label size_t pshufhw xmm0, xmm0, 86 jmp _m128ishufhiepi16_end _m128ishufhiepi16_87 label size_t pshufhw xmm0, xmm0, 87 jmp _m128ishufhiepi16_end _m128ishufhiepi16_88 label size_t pshufhw xmm0, xmm0, 88 jmp _m128ishufhiepi16_end _m128ishufhiepi16_89 label size_t pshufhw xmm0, xmm0, 89 jmp _m128ishufhiepi16_end _m128ishufhiepi16_90 label size_t pshufhw xmm0, xmm0, 90 jmp _m128ishufhiepi16_end _m128ishufhiepi16_91 label size_t pshufhw xmm0, xmm0, 91 jmp _m128ishufhiepi16_end _m128ishufhiepi16_92 label size_t pshufhw xmm0, xmm0, 92 jmp _m128ishufhiepi16_end _m128ishufhiepi16_93 label size_t pshufhw xmm0, xmm0, 93 jmp _m128ishufhiepi16_end _m128ishufhiepi16_94 label size_t pshufhw xmm0, xmm0, 94 jmp _m128ishufhiepi16_end _m128ishufhiepi16_95 label size_t pshufhw xmm0, xmm0, 95 jmp _m128ishufhiepi16_end _m128ishufhiepi16_96 label size_t pshufhw xmm0, xmm0, 96 jmp _m128ishufhiepi16_end _m128ishufhiepi16_97 label size_t pshufhw xmm0, xmm0, 97 jmp _m128ishufhiepi16_end _m128ishufhiepi16_98 label size_t pshufhw xmm0, xmm0, 98 jmp _m128ishufhiepi16_end _m128ishufhiepi16_99 label size_t pshufhw xmm0, xmm0, 99 jmp _m128ishufhiepi16_end _m128ishufhiepi16_100 label size_t pshufhw xmm0, xmm0, 100 jmp _m128ishufhiepi16_end _m128ishufhiepi16_101 label size_t pshufhw xmm0, xmm0, 101 jmp _m128ishufhiepi16_end _m128ishufhiepi16_102 label size_t pshufhw xmm0, xmm0, 102 jmp _m128ishufhiepi16_end _m128ishufhiepi16_103 label size_t pshufhw xmm0, xmm0, 103 jmp _m128ishufhiepi16_end _m128ishufhiepi16_104 label size_t pshufhw xmm0, xmm0, 104 jmp _m128ishufhiepi16_end _m128ishufhiepi16_105 label size_t pshufhw xmm0, xmm0, 105 jmp _m128ishufhiepi16_end _m128ishufhiepi16_106 label size_t pshufhw xmm0, xmm0, 106 jmp _m128ishufhiepi16_end _m128ishufhiepi16_107 label size_t pshufhw xmm0, xmm0, 107 jmp _m128ishufhiepi16_end _m128ishufhiepi16_108 label size_t pshufhw xmm0, xmm0, 108 jmp _m128ishufhiepi16_end _m128ishufhiepi16_109 label size_t pshufhw xmm0, xmm0, 109 jmp _m128ishufhiepi16_end _m128ishufhiepi16_110 label size_t pshufhw xmm0, xmm0, 110 jmp _m128ishufhiepi16_end _m128ishufhiepi16_111 label size_t pshufhw xmm0, xmm0, 111 jmp _m128ishufhiepi16_end _m128ishufhiepi16_112 label size_t pshufhw xmm0, xmm0, 112 jmp _m128ishufhiepi16_end _m128ishufhiepi16_113 label size_t pshufhw xmm0, xmm0, 113 jmp _m128ishufhiepi16_end _m128ishufhiepi16_114 label size_t pshufhw xmm0, xmm0, 114 jmp _m128ishufhiepi16_end _m128ishufhiepi16_115 label size_t pshufhw xmm0, xmm0, 115 jmp _m128ishufhiepi16_end _m128ishufhiepi16_116 label size_t pshufhw xmm0, xmm0, 116 jmp _m128ishufhiepi16_end _m128ishufhiepi16_117 label size_t pshufhw xmm0, xmm0, 117 jmp _m128ishufhiepi16_end _m128ishufhiepi16_118 label size_t pshufhw xmm0, xmm0, 118 jmp _m128ishufhiepi16_end _m128ishufhiepi16_119 label size_t pshufhw xmm0, xmm0, 119 jmp _m128ishufhiepi16_end _m128ishufhiepi16_120 label size_t pshufhw xmm0, xmm0, 120 jmp _m128ishufhiepi16_end _m128ishufhiepi16_121 label size_t pshufhw xmm0, xmm0, 121 jmp _m128ishufhiepi16_end _m128ishufhiepi16_122 label size_t pshufhw xmm0, xmm0, 122 jmp _m128ishufhiepi16_end _m128ishufhiepi16_123 label size_t pshufhw xmm0, xmm0, 123 jmp _m128ishufhiepi16_end _m128ishufhiepi16_124 label size_t pshufhw xmm0, xmm0, 124 jmp _m128ishufhiepi16_end _m128ishufhiepi16_125 label size_t pshufhw xmm0, xmm0, 125 jmp _m128ishufhiepi16_end _m128ishufhiepi16_126 label size_t pshufhw xmm0, xmm0, 126 jmp _m128ishufhiepi16_end _m128ishufhiepi16_127 label size_t pshufhw xmm0, xmm0, 127 jmp _m128ishufhiepi16_end _m128ishufhiepi16_128 label size_t pshufhw xmm0, xmm0, 128 jmp _m128ishufhiepi16_end _m128ishufhiepi16_129 label size_t pshufhw xmm0, xmm0, 129 jmp _m128ishufhiepi16_end _m128ishufhiepi16_130 label size_t pshufhw xmm0, xmm0, 130 jmp _m128ishufhiepi16_end _m128ishufhiepi16_131 label size_t pshufhw xmm0, xmm0, 131 jmp _m128ishufhiepi16_end _m128ishufhiepi16_132 label size_t pshufhw xmm0, xmm0, 132 jmp _m128ishufhiepi16_end _m128ishufhiepi16_133 label size_t pshufhw xmm0, xmm0, 133 jmp _m128ishufhiepi16_end _m128ishufhiepi16_134 label size_t pshufhw xmm0, xmm0, 134 jmp _m128ishufhiepi16_end _m128ishufhiepi16_135 label size_t pshufhw xmm0, xmm0, 135 jmp _m128ishufhiepi16_end _m128ishufhiepi16_136 label size_t pshufhw xmm0, xmm0, 136 jmp _m128ishufhiepi16_end _m128ishufhiepi16_137 label size_t pshufhw xmm0, xmm0, 137 jmp _m128ishufhiepi16_end _m128ishufhiepi16_138 label size_t pshufhw xmm0, xmm0, 138 jmp _m128ishufhiepi16_end _m128ishufhiepi16_139 label size_t pshufhw xmm0, xmm0, 139 jmp _m128ishufhiepi16_end _m128ishufhiepi16_140 label size_t pshufhw xmm0, xmm0, 140 jmp _m128ishufhiepi16_end _m128ishufhiepi16_141 label size_t pshufhw xmm0, xmm0, 141 jmp _m128ishufhiepi16_end _m128ishufhiepi16_142 label size_t pshufhw xmm0, xmm0, 142 jmp _m128ishufhiepi16_end _m128ishufhiepi16_143 label size_t pshufhw xmm0, xmm0, 143 jmp _m128ishufhiepi16_end _m128ishufhiepi16_144 label size_t pshufhw xmm0, xmm0, 144 jmp _m128ishufhiepi16_end _m128ishufhiepi16_145 label size_t pshufhw xmm0, xmm0, 145 jmp _m128ishufhiepi16_end _m128ishufhiepi16_146 label size_t pshufhw xmm0, xmm0, 146 jmp _m128ishufhiepi16_end _m128ishufhiepi16_147 label size_t pshufhw xmm0, xmm0, 147 jmp _m128ishufhiepi16_end _m128ishufhiepi16_148 label size_t pshufhw xmm0, xmm0, 148 jmp _m128ishufhiepi16_end _m128ishufhiepi16_149 label size_t pshufhw xmm0, xmm0, 149 jmp _m128ishufhiepi16_end _m128ishufhiepi16_150 label size_t pshufhw xmm0, xmm0, 150 jmp _m128ishufhiepi16_end _m128ishufhiepi16_151 label size_t pshufhw xmm0, xmm0, 151 jmp _m128ishufhiepi16_end _m128ishufhiepi16_152 label size_t pshufhw xmm0, xmm0, 152 jmp _m128ishufhiepi16_end _m128ishufhiepi16_153 label size_t pshufhw xmm0, xmm0, 153 jmp _m128ishufhiepi16_end _m128ishufhiepi16_154 label size_t pshufhw xmm0, xmm0, 154 jmp _m128ishufhiepi16_end _m128ishufhiepi16_155 label size_t pshufhw xmm0, xmm0, 155 jmp _m128ishufhiepi16_end _m128ishufhiepi16_156 label size_t pshufhw xmm0, xmm0, 156 jmp _m128ishufhiepi16_end _m128ishufhiepi16_157 label size_t pshufhw xmm0, xmm0, 157 jmp _m128ishufhiepi16_end _m128ishufhiepi16_158 label size_t pshufhw xmm0, xmm0, 158 jmp _m128ishufhiepi16_end _m128ishufhiepi16_159 label size_t pshufhw xmm0, xmm0, 159 jmp _m128ishufhiepi16_end _m128ishufhiepi16_160 label size_t pshufhw xmm0, xmm0, 160 jmp _m128ishufhiepi16_end _m128ishufhiepi16_161 label size_t pshufhw xmm0, xmm0, 161 jmp _m128ishufhiepi16_end _m128ishufhiepi16_162 label size_t pshufhw xmm0, xmm0, 162 jmp _m128ishufhiepi16_end _m128ishufhiepi16_163 label size_t pshufhw xmm0, xmm0, 163 jmp _m128ishufhiepi16_end _m128ishufhiepi16_164 label size_t pshufhw xmm0, xmm0, 164 jmp _m128ishufhiepi16_end _m128ishufhiepi16_165 label size_t pshufhw xmm0, xmm0, 165 jmp _m128ishufhiepi16_end _m128ishufhiepi16_166 label size_t pshufhw xmm0, xmm0, 166 jmp _m128ishufhiepi16_end _m128ishufhiepi16_167 label size_t pshufhw xmm0, xmm0, 167 jmp _m128ishufhiepi16_end _m128ishufhiepi16_168 label size_t pshufhw xmm0, xmm0, 168 jmp _m128ishufhiepi16_end _m128ishufhiepi16_169 label size_t pshufhw xmm0, xmm0, 169 jmp _m128ishufhiepi16_end _m128ishufhiepi16_170 label size_t pshufhw xmm0, xmm0, 170 jmp _m128ishufhiepi16_end _m128ishufhiepi16_171 label size_t pshufhw xmm0, xmm0, 171 jmp _m128ishufhiepi16_end _m128ishufhiepi16_172 label size_t pshufhw xmm0, xmm0, 172 jmp _m128ishufhiepi16_end _m128ishufhiepi16_173 label size_t pshufhw xmm0, xmm0, 173 jmp _m128ishufhiepi16_end _m128ishufhiepi16_174 label size_t pshufhw xmm0, xmm0, 174 jmp _m128ishufhiepi16_end _m128ishufhiepi16_175 label size_t pshufhw xmm0, xmm0, 175 jmp _m128ishufhiepi16_end _m128ishufhiepi16_176 label size_t pshufhw xmm0, xmm0, 176 jmp _m128ishufhiepi16_end _m128ishufhiepi16_177 label size_t pshufhw xmm0, xmm0, 177 jmp _m128ishufhiepi16_end _m128ishufhiepi16_178 label size_t pshufhw xmm0, xmm0, 178 jmp _m128ishufhiepi16_end _m128ishufhiepi16_179 label size_t pshufhw xmm0, xmm0, 179 jmp _m128ishufhiepi16_end _m128ishufhiepi16_180 label size_t pshufhw xmm0, xmm0, 180 jmp _m128ishufhiepi16_end _m128ishufhiepi16_181 label size_t pshufhw xmm0, xmm0, 181 jmp _m128ishufhiepi16_end _m128ishufhiepi16_182 label size_t pshufhw xmm0, xmm0, 182 jmp _m128ishufhiepi16_end _m128ishufhiepi16_183 label size_t pshufhw xmm0, xmm0, 183 jmp _m128ishufhiepi16_end _m128ishufhiepi16_184 label size_t pshufhw xmm0, xmm0, 184 jmp _m128ishufhiepi16_end _m128ishufhiepi16_185 label size_t pshufhw xmm0, xmm0, 185 jmp _m128ishufhiepi16_end _m128ishufhiepi16_186 label size_t pshufhw xmm0, xmm0, 186 jmp _m128ishufhiepi16_end _m128ishufhiepi16_187 label size_t pshufhw xmm0, xmm0, 187 jmp _m128ishufhiepi16_end _m128ishufhiepi16_188 label size_t pshufhw xmm0, xmm0, 188 jmp _m128ishufhiepi16_end _m128ishufhiepi16_189 label size_t pshufhw xmm0, xmm0, 189 jmp _m128ishufhiepi16_end _m128ishufhiepi16_190 label size_t pshufhw xmm0, xmm0, 190 jmp _m128ishufhiepi16_end _m128ishufhiepi16_191 label size_t pshufhw xmm0, xmm0, 191 jmp _m128ishufhiepi16_end _m128ishufhiepi16_192 label size_t pshufhw xmm0, xmm0, 192 jmp _m128ishufhiepi16_end _m128ishufhiepi16_193 label size_t pshufhw xmm0, xmm0, 193 jmp _m128ishufhiepi16_end _m128ishufhiepi16_194 label size_t pshufhw xmm0, xmm0, 194 jmp _m128ishufhiepi16_end _m128ishufhiepi16_195 label size_t pshufhw xmm0, xmm0, 195 jmp _m128ishufhiepi16_end _m128ishufhiepi16_196 label size_t pshufhw xmm0, xmm0, 196 jmp _m128ishufhiepi16_end _m128ishufhiepi16_197 label size_t pshufhw xmm0, xmm0, 197 jmp _m128ishufhiepi16_end _m128ishufhiepi16_198 label size_t pshufhw xmm0, xmm0, 198 jmp _m128ishufhiepi16_end _m128ishufhiepi16_199 label size_t pshufhw xmm0, xmm0, 199 jmp _m128ishufhiepi16_end _m128ishufhiepi16_200 label size_t pshufhw xmm0, xmm0, 200 jmp _m128ishufhiepi16_end _m128ishufhiepi16_201 label size_t pshufhw xmm0, xmm0, 201 jmp _m128ishufhiepi16_end _m128ishufhiepi16_202 label size_t pshufhw xmm0, xmm0, 202 jmp _m128ishufhiepi16_end _m128ishufhiepi16_203 label size_t pshufhw xmm0, xmm0, 203 jmp _m128ishufhiepi16_end _m128ishufhiepi16_204 label size_t pshufhw xmm0, xmm0, 204 jmp _m128ishufhiepi16_end _m128ishufhiepi16_205 label size_t pshufhw xmm0, xmm0, 205 jmp _m128ishufhiepi16_end _m128ishufhiepi16_206 label size_t pshufhw xmm0, xmm0, 206 jmp _m128ishufhiepi16_end _m128ishufhiepi16_207 label size_t pshufhw xmm0, xmm0, 207 jmp _m128ishufhiepi16_end _m128ishufhiepi16_208 label size_t pshufhw xmm0, xmm0, 208 jmp _m128ishufhiepi16_end _m128ishufhiepi16_209 label size_t pshufhw xmm0, xmm0, 209 jmp _m128ishufhiepi16_end _m128ishufhiepi16_210 label size_t pshufhw xmm0, xmm0, 210 jmp _m128ishufhiepi16_end _m128ishufhiepi16_211 label size_t pshufhw xmm0, xmm0, 211 jmp _m128ishufhiepi16_end _m128ishufhiepi16_212 label size_t pshufhw xmm0, xmm0, 212 jmp _m128ishufhiepi16_end _m128ishufhiepi16_213 label size_t pshufhw xmm0, xmm0, 213 jmp _m128ishufhiepi16_end _m128ishufhiepi16_214 label size_t pshufhw xmm0, xmm0, 214 jmp _m128ishufhiepi16_end _m128ishufhiepi16_215 label size_t pshufhw xmm0, xmm0, 215 jmp _m128ishufhiepi16_end _m128ishufhiepi16_216 label size_t pshufhw xmm0, xmm0, 216 jmp _m128ishufhiepi16_end _m128ishufhiepi16_217 label size_t pshufhw xmm0, xmm0, 217 jmp _m128ishufhiepi16_end _m128ishufhiepi16_218 label size_t pshufhw xmm0, xmm0, 218 jmp _m128ishufhiepi16_end _m128ishufhiepi16_219 label size_t pshufhw xmm0, xmm0, 219 jmp _m128ishufhiepi16_end _m128ishufhiepi16_220 label size_t pshufhw xmm0, xmm0, 220 jmp _m128ishufhiepi16_end _m128ishufhiepi16_221 label size_t pshufhw xmm0, xmm0, 221 jmp _m128ishufhiepi16_end _m128ishufhiepi16_222 label size_t pshufhw xmm0, xmm0, 222 jmp _m128ishufhiepi16_end _m128ishufhiepi16_223 label size_t pshufhw xmm0, xmm0, 223 jmp _m128ishufhiepi16_end _m128ishufhiepi16_224 label size_t pshufhw xmm0, xmm0, 224 jmp _m128ishufhiepi16_end _m128ishufhiepi16_225 label size_t pshufhw xmm0, xmm0, 225 jmp _m128ishufhiepi16_end _m128ishufhiepi16_226 label size_t pshufhw xmm0, xmm0, 226 jmp _m128ishufhiepi16_end _m128ishufhiepi16_227 label size_t pshufhw xmm0, xmm0, 227 jmp _m128ishufhiepi16_end _m128ishufhiepi16_228 label size_t pshufhw xmm0, xmm0, 228 jmp _m128ishufhiepi16_end _m128ishufhiepi16_229 label size_t pshufhw xmm0, xmm0, 229 jmp _m128ishufhiepi16_end _m128ishufhiepi16_230 label size_t pshufhw xmm0, xmm0, 230 jmp _m128ishufhiepi16_end _m128ishufhiepi16_231 label size_t pshufhw xmm0, xmm0, 231 jmp _m128ishufhiepi16_end _m128ishufhiepi16_232 label size_t pshufhw xmm0, xmm0, 232 jmp _m128ishufhiepi16_end _m128ishufhiepi16_233 label size_t pshufhw xmm0, xmm0, 233 jmp _m128ishufhiepi16_end _m128ishufhiepi16_234 label size_t pshufhw xmm0, xmm0, 234 jmp _m128ishufhiepi16_end _m128ishufhiepi16_235 label size_t pshufhw xmm0, xmm0, 235 jmp _m128ishufhiepi16_end _m128ishufhiepi16_236 label size_t pshufhw xmm0, xmm0, 236 jmp _m128ishufhiepi16_end _m128ishufhiepi16_237 label size_t pshufhw xmm0, xmm0, 237 jmp _m128ishufhiepi16_end _m128ishufhiepi16_238 label size_t pshufhw xmm0, xmm0, 238 jmp _m128ishufhiepi16_end _m128ishufhiepi16_239 label size_t pshufhw xmm0, xmm0, 239 jmp _m128ishufhiepi16_end _m128ishufhiepi16_240 label size_t pshufhw xmm0, xmm0, 240 jmp _m128ishufhiepi16_end _m128ishufhiepi16_241 label size_t pshufhw xmm0, xmm0, 241 jmp _m128ishufhiepi16_end _m128ishufhiepi16_242 label size_t pshufhw xmm0, xmm0, 242 jmp _m128ishufhiepi16_end _m128ishufhiepi16_243 label size_t pshufhw xmm0, xmm0, 243 jmp _m128ishufhiepi16_end _m128ishufhiepi16_244 label size_t pshufhw xmm0, xmm0, 244 jmp _m128ishufhiepi16_end _m128ishufhiepi16_245 label size_t pshufhw xmm0, xmm0, 245 jmp _m128ishufhiepi16_end _m128ishufhiepi16_246 label size_t pshufhw xmm0, xmm0, 246 jmp _m128ishufhiepi16_end _m128ishufhiepi16_247 label size_t pshufhw xmm0, xmm0, 247 jmp _m128ishufhiepi16_end _m128ishufhiepi16_248 label size_t pshufhw xmm0, xmm0, 248 jmp _m128ishufhiepi16_end _m128ishufhiepi16_249 label size_t pshufhw xmm0, xmm0, 249 jmp _m128ishufhiepi16_end _m128ishufhiepi16_250 label size_t pshufhw xmm0, xmm0, 250 jmp _m128ishufhiepi16_end _m128ishufhiepi16_251 label size_t pshufhw xmm0, xmm0, 251 jmp _m128ishufhiepi16_end _m128ishufhiepi16_252 label size_t pshufhw xmm0, xmm0, 252 jmp _m128ishufhiepi16_end _m128ishufhiepi16_253 label size_t pshufhw xmm0, xmm0, 253 jmp _m128ishufhiepi16_end _m128ishufhiepi16_254 label size_t pshufhw xmm0, xmm0, 254 jmp _m128ishufhiepi16_end _m128ishufhiepi16_255 label size_t pshufhw xmm0, xmm0, 255 ;jmp _m128ishufhiepi16_end _m128ishufhiepi16_end: pop rbase() ret procend procstart _uX_mm_shufflelo_epi16_0000, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 0 ret procend procstart _uX_mm_shufflelo_epi16_0001, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 1 ret procend procstart _uX_mm_shufflelo_epi16_0002, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 2 ret procend procstart _uX_mm_shufflelo_epi16_0003, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 3 ret procend procstart _uX_mm_shufflelo_epi16_0010, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 4 ret procend procstart _uX_mm_shufflelo_epi16_0011, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 5 ret procend procstart _uX_mm_shufflelo_epi16_0012, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 6 ret procend procstart _uX_mm_shufflelo_epi16_0013, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 7 ret procend procstart _uX_mm_shufflelo_epi16_0020, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 8 ret procend procstart _uX_mm_shufflelo_epi16_0021, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 9 ret procend procstart _uX_mm_shufflelo_epi16_0022, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 10 ret procend procstart _uX_mm_shufflelo_epi16_0023, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 11 ret procend procstart _uX_mm_shufflelo_epi16_0030, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 12 ret procend procstart _uX_mm_shufflelo_epi16_0031, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 13 ret procend procstart _uX_mm_shufflelo_epi16_0032, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 14 ret procend procstart _uX_mm_shufflelo_epi16_0033, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 15 ret procend procstart _uX_mm_shufflelo_epi16_0100, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 16 ret procend procstart _uX_mm_shufflelo_epi16_0101, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 17 ret procend procstart _uX_mm_shufflelo_epi16_0102, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 18 ret procend procstart _uX_mm_shufflelo_epi16_0103, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 19 ret procend procstart _uX_mm_shufflelo_epi16_0110, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 20 ret procend procstart _uX_mm_shufflelo_epi16_0111, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 21 ret procend procstart _uX_mm_shufflelo_epi16_0112, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 22 ret procend procstart _uX_mm_shufflelo_epi16_0113, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 23 ret procend procstart _uX_mm_shufflelo_epi16_0120, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 24 ret procend procstart _uX_mm_shufflelo_epi16_0121, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 25 ret procend procstart _uX_mm_shufflelo_epi16_0122, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 26 ret procend procstart _uX_mm_shufflelo_epi16_0123, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 27 ret procend procstart _uX_mm_shufflelo_epi16_0130, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 28 ret procend procstart _uX_mm_shufflelo_epi16_0131, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 29 ret procend procstart _uX_mm_shufflelo_epi16_0132, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 30 ret procend procstart _uX_mm_shufflelo_epi16_0133, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 31 ret procend procstart _uX_mm_shufflelo_epi16_0200, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 32 ret procend procstart _uX_mm_shufflelo_epi16_0201, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 33 ret procend procstart _uX_mm_shufflelo_epi16_0202, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 34 ret procend procstart _uX_mm_shufflelo_epi16_0203, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 35 ret procend procstart _uX_mm_shufflelo_epi16_0210, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 36 ret procend procstart _uX_mm_shufflelo_epi16_0211, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 37 ret procend procstart _uX_mm_shufflelo_epi16_0212, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 38 ret procend procstart _uX_mm_shufflelo_epi16_0213, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 39 ret procend procstart _uX_mm_shufflelo_epi16_0220, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 40 ret procend procstart _uX_mm_shufflelo_epi16_0221, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 41 ret procend procstart _uX_mm_shufflelo_epi16_0222, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 42 ret procend procstart _uX_mm_shufflelo_epi16_0223, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 43 ret procend procstart _uX_mm_shufflelo_epi16_0230, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 44 ret procend procstart _uX_mm_shufflelo_epi16_0231, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 45 ret procend procstart _uX_mm_shufflelo_epi16_0232, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 46 ret procend procstart _uX_mm_shufflelo_epi16_0233, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 47 ret procend procstart _uX_mm_shufflelo_epi16_0300, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 48 ret procend procstart _uX_mm_shufflelo_epi16_0301, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 49 ret procend procstart _uX_mm_shufflelo_epi16_0302, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 50 ret procend procstart _uX_mm_shufflelo_epi16_0303, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 51 ret procend procstart _uX_mm_shufflelo_epi16_0310, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 52 ret procend procstart _uX_mm_shufflelo_epi16_0311, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 53 ret procend procstart _uX_mm_shufflelo_epi16_0312, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 54 ret procend procstart _uX_mm_shufflelo_epi16_0313, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 55 ret procend procstart _uX_mm_shufflelo_epi16_0320, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 56 ret procend procstart _uX_mm_shufflelo_epi16_0321, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 57 ret procend procstart _uX_mm_shufflelo_epi16_0322, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 58 ret procend procstart _uX_mm_shufflelo_epi16_0323, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 59 ret procend procstart _uX_mm_shufflelo_epi16_0330, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 60 ret procend procstart _uX_mm_shufflelo_epi16_0331, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 61 ret procend procstart _uX_mm_shufflelo_epi16_0332, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 62 ret procend procstart _uX_mm_shufflelo_epi16_0333, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 63 ret procend procstart _uX_mm_shufflelo_epi16_1000, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 64 ret procend procstart _uX_mm_shufflelo_epi16_1001, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 65 ret procend procstart _uX_mm_shufflelo_epi16_1002, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 66 ret procend procstart _uX_mm_shufflelo_epi16_1003, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 67 ret procend procstart _uX_mm_shufflelo_epi16_1010, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 68 ret procend procstart _uX_mm_shufflelo_epi16_1011, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 69 ret procend procstart _uX_mm_shufflelo_epi16_1012, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 70 ret procend procstart _uX_mm_shufflelo_epi16_1013, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 71 ret procend procstart _uX_mm_shufflelo_epi16_1020, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 72 ret procend procstart _uX_mm_shufflelo_epi16_1021, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 73 ret procend procstart _uX_mm_shufflelo_epi16_1022, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 74 ret procend procstart _uX_mm_shufflelo_epi16_1023, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 75 ret procend procstart _uX_mm_shufflelo_epi16_1030, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 76 ret procend procstart _uX_mm_shufflelo_epi16_1031, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 77 ret procend procstart _uX_mm_shufflelo_epi16_1032, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 78 ret procend procstart _uX_mm_shufflelo_epi16_1033, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 79 ret procend procstart _uX_mm_shufflelo_epi16_1100, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 80 ret procend procstart _uX_mm_shufflelo_epi16_1101, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 81 ret procend procstart _uX_mm_shufflelo_epi16_1102, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 82 ret procend procstart _uX_mm_shufflelo_epi16_1103, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 83 ret procend procstart _uX_mm_shufflelo_epi16_1110, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 84 ret procend procstart _uX_mm_shufflelo_epi16_1111, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 85 ret procend procstart _uX_mm_shufflelo_epi16_1112, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 86 ret procend procstart _uX_mm_shufflelo_epi16_1113, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 87 ret procend procstart _uX_mm_shufflelo_epi16_1120, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 88 ret procend procstart _uX_mm_shufflelo_epi16_1121, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 89 ret procend procstart _uX_mm_shufflelo_epi16_1122, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 90 ret procend procstart _uX_mm_shufflelo_epi16_1123, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 91 ret procend procstart _uX_mm_shufflelo_epi16_1130, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 92 ret procend procstart _uX_mm_shufflelo_epi16_1131, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 93 ret procend procstart _uX_mm_shufflelo_epi16_1132, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 94 ret procend procstart _uX_mm_shufflelo_epi16_1133, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 95 ret procend procstart _uX_mm_shufflelo_epi16_1200, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 96 ret procend procstart _uX_mm_shufflelo_epi16_1201, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 97 ret procend procstart _uX_mm_shufflelo_epi16_1202, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 98 ret procend procstart _uX_mm_shufflelo_epi16_1203, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 99 ret procend procstart _uX_mm_shufflelo_epi16_1210, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 100 ret procend procstart _uX_mm_shufflelo_epi16_1211, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 101 ret procend procstart _uX_mm_shufflelo_epi16_1212, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 102 ret procend procstart _uX_mm_shufflelo_epi16_1213, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 103 ret procend procstart _uX_mm_shufflelo_epi16_1220, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 104 ret procend procstart _uX_mm_shufflelo_epi16_1221, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 105 ret procend procstart _uX_mm_shufflelo_epi16_1222, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 106 ret procend procstart _uX_mm_shufflelo_epi16_1223, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 107 ret procend procstart _uX_mm_shufflelo_epi16_1230, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 108 ret procend procstart _uX_mm_shufflelo_epi16_1231, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 109 ret procend procstart _uX_mm_shufflelo_epi16_1232, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 110 ret procend procstart _uX_mm_shufflelo_epi16_1233, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 111 ret procend procstart _uX_mm_shufflelo_epi16_1300, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 112 ret procend procstart _uX_mm_shufflelo_epi16_1301, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 113 ret procend procstart _uX_mm_shufflelo_epi16_1302, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 114 ret procend procstart _uX_mm_shufflelo_epi16_1303, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 115 ret procend procstart _uX_mm_shufflelo_epi16_1310, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 116 ret procend procstart _uX_mm_shufflelo_epi16_1311, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 117 ret procend procstart _uX_mm_shufflelo_epi16_1312, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 118 ret procend procstart _uX_mm_shufflelo_epi16_1313, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 119 ret procend procstart _uX_mm_shufflelo_epi16_1320, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 120 ret procend procstart _uX_mm_shufflelo_epi16_1321, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 121 ret procend procstart _uX_mm_shufflelo_epi16_1322, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 122 ret procend procstart _uX_mm_shufflelo_epi16_1323, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 123 ret procend procstart _uX_mm_shufflelo_epi16_1330, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 124 ret procend procstart _uX_mm_shufflelo_epi16_1331, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 125 ret procend procstart _uX_mm_shufflelo_epi16_1332, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 126 ret procend procstart _uX_mm_shufflelo_epi16_1333, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 127 ret procend procstart _uX_mm_shufflelo_epi16_2000, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 128 ret procend procstart _uX_mm_shufflelo_epi16_2001, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 129 ret procend procstart _uX_mm_shufflelo_epi16_2002, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 130 ret procend procstart _uX_mm_shufflelo_epi16_2003, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 131 ret procend procstart _uX_mm_shufflelo_epi16_2010, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 132 ret procend procstart _uX_mm_shufflelo_epi16_2011, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 133 ret procend procstart _uX_mm_shufflelo_epi16_2012, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 134 ret procend procstart _uX_mm_shufflelo_epi16_2013, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 135 ret procend procstart _uX_mm_shufflelo_epi16_2020, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 136 ret procend procstart _uX_mm_shufflelo_epi16_2021, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 137 ret procend procstart _uX_mm_shufflelo_epi16_2022, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 138 ret procend procstart _uX_mm_shufflelo_epi16_2023, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 139 ret procend procstart _uX_mm_shufflelo_epi16_2030, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 140 ret procend procstart _uX_mm_shufflelo_epi16_2031, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 141 ret procend procstart _uX_mm_shufflelo_epi16_2032, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 142 ret procend procstart _uX_mm_shufflelo_epi16_2033, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 143 ret procend procstart _uX_mm_shufflelo_epi16_2100, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 144 ret procend procstart _uX_mm_shufflelo_epi16_2101, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 145 ret procend procstart _uX_mm_shufflelo_epi16_2102, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 146 ret procend procstart _uX_mm_shufflelo_epi16_2103, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 147 ret procend procstart _uX_mm_shufflelo_epi16_2110, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 148 ret procend procstart _uX_mm_shufflelo_epi16_2111, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 149 ret procend procstart _uX_mm_shufflelo_epi16_2112, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 150 ret procend procstart _uX_mm_shufflelo_epi16_2113, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 151 ret procend procstart _uX_mm_shufflelo_epi16_2120, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 152 ret procend procstart _uX_mm_shufflelo_epi16_2121, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 153 ret procend procstart _uX_mm_shufflelo_epi16_2122, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 154 ret procend procstart _uX_mm_shufflelo_epi16_2123, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 155 ret procend procstart _uX_mm_shufflelo_epi16_2130, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 156 ret procend procstart _uX_mm_shufflelo_epi16_2131, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 157 ret procend procstart _uX_mm_shufflelo_epi16_2132, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 158 ret procend procstart _uX_mm_shufflelo_epi16_2133, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 159 ret procend procstart _uX_mm_shufflelo_epi16_2200, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 160 ret procend procstart _uX_mm_shufflelo_epi16_2201, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 161 ret procend procstart _uX_mm_shufflelo_epi16_2202, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 162 ret procend procstart _uX_mm_shufflelo_epi16_2203, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 163 ret procend procstart _uX_mm_shufflelo_epi16_2210, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 164 ret procend procstart _uX_mm_shufflelo_epi16_2211, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 165 ret procend procstart _uX_mm_shufflelo_epi16_2212, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 166 ret procend procstart _uX_mm_shufflelo_epi16_2213, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 167 ret procend procstart _uX_mm_shufflelo_epi16_2220, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 168 ret procend procstart _uX_mm_shufflelo_epi16_2221, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 169 ret procend procstart _uX_mm_shufflelo_epi16_2222, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 170 ret procend procstart _uX_mm_shufflelo_epi16_2223, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 171 ret procend procstart _uX_mm_shufflelo_epi16_2230, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 172 ret procend procstart _uX_mm_shufflelo_epi16_2231, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 173 ret procend procstart _uX_mm_shufflelo_epi16_2232, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 174 ret procend procstart _uX_mm_shufflelo_epi16_2233, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 175 ret procend procstart _uX_mm_shufflelo_epi16_2300, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 176 ret procend procstart _uX_mm_shufflelo_epi16_2301, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 177 ret procend procstart _uX_mm_shufflelo_epi16_2302, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 178 ret procend procstart _uX_mm_shufflelo_epi16_2303, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 179 ret procend procstart _uX_mm_shufflelo_epi16_2310, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 180 ret procend procstart _uX_mm_shufflelo_epi16_2311, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 181 ret procend procstart _uX_mm_shufflelo_epi16_2312, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 182 ret procend procstart _uX_mm_shufflelo_epi16_2313, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 183 ret procend procstart _uX_mm_shufflelo_epi16_2320, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 184 ret procend procstart _uX_mm_shufflelo_epi16_2321, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 185 ret procend procstart _uX_mm_shufflelo_epi16_2322, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 186 ret procend procstart _uX_mm_shufflelo_epi16_2323, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 187 ret procend procstart _uX_mm_shufflelo_epi16_2330, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 188 ret procend procstart _uX_mm_shufflelo_epi16_2331, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 189 ret procend procstart _uX_mm_shufflelo_epi16_2332, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 190 ret procend procstart _uX_mm_shufflelo_epi16_2333, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 191 ret procend procstart _uX_mm_shufflelo_epi16_3000, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 192 ret procend procstart _uX_mm_shufflelo_epi16_3001, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 193 ret procend procstart _uX_mm_shufflelo_epi16_3002, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 194 ret procend procstart _uX_mm_shufflelo_epi16_3003, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 195 ret procend procstart _uX_mm_shufflelo_epi16_3010, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 196 ret procend procstart _uX_mm_shufflelo_epi16_3011, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 197 ret procend procstart _uX_mm_shufflelo_epi16_3012, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 198 ret procend procstart _uX_mm_shufflelo_epi16_3013, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 199 ret procend procstart _uX_mm_shufflelo_epi16_3020, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 200 ret procend procstart _uX_mm_shufflelo_epi16_3021, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 201 ret procend procstart _uX_mm_shufflelo_epi16_3022, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 202 ret procend procstart _uX_mm_shufflelo_epi16_3023, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 203 ret procend procstart _uX_mm_shufflelo_epi16_3030, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 204 ret procend procstart _uX_mm_shufflelo_epi16_3031, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 205 ret procend procstart _uX_mm_shufflelo_epi16_3032, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 206 ret procend procstart _uX_mm_shufflelo_epi16_3033, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 207 ret procend procstart _uX_mm_shufflelo_epi16_3100, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 208 ret procend procstart _uX_mm_shufflelo_epi16_3101, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 209 ret procend procstart _uX_mm_shufflelo_epi16_3102, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 210 ret procend procstart _uX_mm_shufflelo_epi16_3103, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 211 ret procend procstart _uX_mm_shufflelo_epi16_3110, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 212 ret procend procstart _uX_mm_shufflelo_epi16_3111, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 213 ret procend procstart _uX_mm_shufflelo_epi16_3112, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 214 ret procend procstart _uX_mm_shufflelo_epi16_3113, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 215 ret procend procstart _uX_mm_shufflelo_epi16_3120, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 216 ret procend procstart _uX_mm_shufflelo_epi16_3121, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 217 ret procend procstart _uX_mm_shufflelo_epi16_3122, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 218 ret procend procstart _uX_mm_shufflelo_epi16_3123, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 219 ret procend procstart _uX_mm_shufflelo_epi16_3130, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 220 ret procend procstart _uX_mm_shufflelo_epi16_3131, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 221 ret procend procstart _uX_mm_shufflelo_epi16_3132, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 222 ret procend procstart _uX_mm_shufflelo_epi16_3133, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 223 ret procend procstart _uX_mm_shufflelo_epi16_3200, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 224 ret procend procstart _uX_mm_shufflelo_epi16_3201, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 225 ret procend procstart _uX_mm_shufflelo_epi16_3202, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 226 ret procend procstart _uX_mm_shufflelo_epi16_3203, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 227 ret procend procstart _uX_mm_shufflelo_epi16_3210, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 228 ret procend procstart _uX_mm_shufflelo_epi16_3211, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 229 ret procend procstart _uX_mm_shufflelo_epi16_3212, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 230 ret procend procstart _uX_mm_shufflelo_epi16_3213, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 231 ret procend procstart _uX_mm_shufflelo_epi16_3220, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 232 ret procend procstart _uX_mm_shufflelo_epi16_3221, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 233 ret procend procstart _uX_mm_shufflelo_epi16_3222, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 234 ret procend procstart _uX_mm_shufflelo_epi16_3223, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 235 ret procend procstart _uX_mm_shufflelo_epi16_3230, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 236 ret procend procstart _uX_mm_shufflelo_epi16_3231, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 237 ret procend procstart _uX_mm_shufflelo_epi16_3232, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 238 ret procend procstart _uX_mm_shufflelo_epi16_3233, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 239 ret procend procstart _uX_mm_shufflelo_epi16_3300, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 240 ret procend procstart _uX_mm_shufflelo_epi16_3301, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 241 ret procend procstart _uX_mm_shufflelo_epi16_3302, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 242 ret procend procstart _uX_mm_shufflelo_epi16_3303, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 243 ret procend procstart _uX_mm_shufflelo_epi16_3310, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 244 ret procend procstart _uX_mm_shufflelo_epi16_3311, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 245 ret procend procstart _uX_mm_shufflelo_epi16_3312, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 246 ret procend procstart _uX_mm_shufflelo_epi16_3313, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 247 ret procend procstart _uX_mm_shufflelo_epi16_3320, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 248 ret procend procstart _uX_mm_shufflelo_epi16_3321, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 249 ret procend procstart _uX_mm_shufflelo_epi16_3322, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 250 ret procend procstart _uX_mm_shufflelo_epi16_3323, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 251 ret procend procstart _uX_mm_shufflelo_epi16_3330, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 252 ret procend procstart _uX_mm_shufflelo_epi16_3331, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 253 ret procend procstart _uX_mm_shufflelo_epi16_3332, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 254 ret procend procstart _uX_mm_shufflelo_epi16_3333, callconv, xmmword, < >, < >, Inxmm_A:xmmword pshuflw xmm0, xmm0, 255 ret procend procstart _uX_mm_shufflelo_epi16, callconv, xmmword, < >, < >, Inxmm_A:xmmword, Inint_Imm:dword push rbase() .if((rp1() < 0) || (rp1() > 255)) jmp _m128ishufloepi16_end .endif ifdef __X32__ movzx rbase(), byte ptr [rp1()] jmp dword ptr [_m128ishufloepi16jmptable+rbase()*size_t_size] else lea rbase(), qword ptr [_m128ishufloepi16jmptable] mov rbase(), qword ptr [rbase()+rp1()*size_t_size] jmp rbx endif _m128ishufloepi16_0 label size_t pshuflw xmm0, xmm0, 0 jmp _m128ishufloepi16_end _m128ishufloepi16_1 label size_t pshuflw xmm0, xmm0, 1 jmp _m128ishufloepi16_end _m128ishufloepi16_2 label size_t pshuflw xmm0, xmm0, 2 jmp _m128ishufloepi16_end _m128ishufloepi16_3 label size_t pshuflw xmm0, xmm0, 3 jmp _m128ishufloepi16_end _m128ishufloepi16_4 label size_t pshuflw xmm0, xmm0, 4 jmp _m128ishufloepi16_end _m128ishufloepi16_5 label size_t pshuflw xmm0, xmm0, 5 jmp _m128ishufloepi16_end _m128ishufloepi16_6 label size_t pshuflw xmm0, xmm0, 6 jmp _m128ishufloepi16_end _m128ishufloepi16_7 label size_t pshuflw xmm0, xmm0, 7 jmp _m128ishufloepi16_end _m128ishufloepi16_8 label size_t pshuflw xmm0, xmm0, 8 jmp _m128ishufloepi16_end _m128ishufloepi16_9 label size_t pshuflw xmm0, xmm0, 9 jmp _m128ishufloepi16_end _m128ishufloepi16_10 label size_t pshuflw xmm0, xmm0, 10 jmp _m128ishufloepi16_end _m128ishufloepi16_11 label size_t pshuflw xmm0, xmm0, 11 jmp _m128ishufloepi16_end _m128ishufloepi16_12 label size_t pshuflw xmm0, xmm0, 12 jmp _m128ishufloepi16_end _m128ishufloepi16_13 label size_t pshuflw xmm0, xmm0, 13 jmp _m128ishufloepi16_end _m128ishufloepi16_14 label size_t pshuflw xmm0, xmm0, 14 jmp _m128ishufloepi16_end _m128ishufloepi16_15 label size_t pshuflw xmm0, xmm0, 15 jmp _m128ishufloepi16_end _m128ishufloepi16_16 label size_t pshuflw xmm0, xmm0, 16 jmp _m128ishufloepi16_end _m128ishufloepi16_17 label size_t pshuflw xmm0, xmm0, 17 jmp _m128ishufloepi16_end _m128ishufloepi16_18 label size_t pshuflw xmm0, xmm0, 18 jmp _m128ishufloepi16_end _m128ishufloepi16_19 label size_t pshuflw xmm0, xmm0, 19 jmp _m128ishufloepi16_end _m128ishufloepi16_20 label size_t pshuflw xmm0, xmm0, 20 jmp _m128ishufloepi16_end _m128ishufloepi16_21 label size_t pshuflw xmm0, xmm0, 21 jmp _m128ishufloepi16_end _m128ishufloepi16_22 label size_t pshuflw xmm0, xmm0, 22 jmp _m128ishufloepi16_end _m128ishufloepi16_23 label size_t pshuflw xmm0, xmm0, 23 jmp _m128ishufloepi16_end _m128ishufloepi16_24 label size_t pshuflw xmm0, xmm0, 24 jmp _m128ishufloepi16_end _m128ishufloepi16_25 label size_t pshuflw xmm0, xmm0, 25 jmp _m128ishufloepi16_end _m128ishufloepi16_26 label size_t pshuflw xmm0, xmm0, 26 jmp _m128ishufloepi16_end _m128ishufloepi16_27 label size_t pshuflw xmm0, xmm0, 27 jmp _m128ishufloepi16_end _m128ishufloepi16_28 label size_t pshuflw xmm0, xmm0, 28 jmp _m128ishufloepi16_end _m128ishufloepi16_29 label size_t pshuflw xmm0, xmm0, 29 jmp _m128ishufloepi16_end _m128ishufloepi16_30 label size_t pshuflw xmm0, xmm0, 30 jmp _m128ishufloepi16_end _m128ishufloepi16_31 label size_t pshuflw xmm0, xmm0, 31 jmp _m128ishufloepi16_end _m128ishufloepi16_32 label size_t pshuflw xmm0, xmm0, 32 jmp _m128ishufloepi16_end _m128ishufloepi16_33 label size_t pshuflw xmm0, xmm0, 33 jmp _m128ishufloepi16_end _m128ishufloepi16_34 label size_t pshuflw xmm0, xmm0, 34 jmp _m128ishufloepi16_end _m128ishufloepi16_35 label size_t pshuflw xmm0, xmm0, 35 jmp _m128ishufloepi16_end _m128ishufloepi16_36 label size_t pshuflw xmm0, xmm0, 36 jmp _m128ishufloepi16_end _m128ishufloepi16_37 label size_t pshuflw xmm0, xmm0, 37 jmp _m128ishufloepi16_end _m128ishufloepi16_38 label size_t pshuflw xmm0, xmm0, 38 jmp _m128ishufloepi16_end _m128ishufloepi16_39 label size_t pshuflw xmm0, xmm0, 39 jmp _m128ishufloepi16_end _m128ishufloepi16_40 label size_t pshuflw xmm0, xmm0, 40 jmp _m128ishufloepi16_end _m128ishufloepi16_41 label size_t pshuflw xmm0, xmm0, 41 jmp _m128ishufloepi16_end _m128ishufloepi16_42 label size_t pshuflw xmm0, xmm0, 42 jmp _m128ishufloepi16_end _m128ishufloepi16_43 label size_t pshuflw xmm0, xmm0, 43 jmp _m128ishufloepi16_end _m128ishufloepi16_44 label size_t pshuflw xmm0, xmm0, 44 jmp _m128ishufloepi16_end _m128ishufloepi16_45 label size_t pshuflw xmm0, xmm0, 45 jmp _m128ishufloepi16_end _m128ishufloepi16_46 label size_t pshuflw xmm0, xmm0, 46 jmp _m128ishufloepi16_end _m128ishufloepi16_47 label size_t pshuflw xmm0, xmm0, 47 jmp _m128ishufloepi16_end _m128ishufloepi16_48 label size_t pshuflw xmm0, xmm0, 48 jmp _m128ishufloepi16_end _m128ishufloepi16_49 label size_t pshuflw xmm0, xmm0, 49 jmp _m128ishufloepi16_end _m128ishufloepi16_50 label size_t pshuflw xmm0, xmm0, 50 jmp _m128ishufloepi16_end _m128ishufloepi16_51 label size_t pshuflw xmm0, xmm0, 51 jmp _m128ishufloepi16_end _m128ishufloepi16_52 label size_t pshuflw xmm0, xmm0, 52 jmp _m128ishufloepi16_end _m128ishufloepi16_53 label size_t pshuflw xmm0, xmm0, 53 jmp _m128ishufloepi16_end _m128ishufloepi16_54 label size_t pshuflw xmm0, xmm0, 54 jmp _m128ishufloepi16_end _m128ishufloepi16_55 label size_t pshuflw xmm0, xmm0, 55 jmp _m128ishufloepi16_end _m128ishufloepi16_56 label size_t pshuflw xmm0, xmm0, 56 jmp _m128ishufloepi16_end _m128ishufloepi16_57 label size_t pshuflw xmm0, xmm0, 57 jmp _m128ishufloepi16_end _m128ishufloepi16_58 label size_t pshuflw xmm0, xmm0, 58 jmp _m128ishufloepi16_end _m128ishufloepi16_59 label size_t pshuflw xmm0, xmm0, 59 jmp _m128ishufloepi16_end _m128ishufloepi16_60 label size_t pshuflw xmm0, xmm0, 60 jmp _m128ishufloepi16_end _m128ishufloepi16_61 label size_t pshuflw xmm0, xmm0, 61 jmp _m128ishufloepi16_end _m128ishufloepi16_62 label size_t pshuflw xmm0, xmm0, 62 jmp _m128ishufloepi16_end _m128ishufloepi16_63 label size_t pshuflw xmm0, xmm0, 63 jmp _m128ishufloepi16_end _m128ishufloepi16_64 label size_t pshuflw xmm0, xmm0, 64 jmp _m128ishufloepi16_end _m128ishufloepi16_65 label size_t pshuflw xmm0, xmm0, 65 jmp _m128ishufloepi16_end _m128ishufloepi16_66 label size_t pshuflw xmm0, xmm0, 66 jmp _m128ishufloepi16_end _m128ishufloepi16_67 label size_t pshuflw xmm0, xmm0, 67 jmp _m128ishufloepi16_end _m128ishufloepi16_68 label size_t pshuflw xmm0, xmm0, 68 jmp _m128ishufloepi16_end _m128ishufloepi16_69 label size_t pshuflw xmm0, xmm0, 69 jmp _m128ishufloepi16_end _m128ishufloepi16_70 label size_t pshuflw xmm0, xmm0, 70 jmp _m128ishufloepi16_end _m128ishufloepi16_71 label size_t pshuflw xmm0, xmm0, 71 jmp _m128ishufloepi16_end _m128ishufloepi16_72 label size_t pshuflw xmm0, xmm0, 72 jmp _m128ishufloepi16_end _m128ishufloepi16_73 label size_t pshuflw xmm0, xmm0, 73 jmp _m128ishufloepi16_end _m128ishufloepi16_74 label size_t pshuflw xmm0, xmm0, 74 jmp _m128ishufloepi16_end _m128ishufloepi16_75 label size_t pshuflw xmm0, xmm0, 75 jmp _m128ishufloepi16_end _m128ishufloepi16_76 label size_t pshuflw xmm0, xmm0, 76 jmp _m128ishufloepi16_end _m128ishufloepi16_77 label size_t pshuflw xmm0, xmm0, 77 jmp _m128ishufloepi16_end _m128ishufloepi16_78 label size_t pshuflw xmm0, xmm0, 78 jmp _m128ishufloepi16_end _m128ishufloepi16_79 label size_t pshuflw xmm0, xmm0, 79 jmp _m128ishufloepi16_end _m128ishufloepi16_80 label size_t pshuflw xmm0, xmm0, 80 jmp _m128ishufloepi16_end _m128ishufloepi16_81 label size_t pshuflw xmm0, xmm0, 81 jmp _m128ishufloepi16_end _m128ishufloepi16_82 label size_t pshuflw xmm0, xmm0, 82 jmp _m128ishufloepi16_end _m128ishufloepi16_83 label size_t pshuflw xmm0, xmm0, 83 jmp _m128ishufloepi16_end _m128ishufloepi16_84 label size_t pshuflw xmm0, xmm0, 84 jmp _m128ishufloepi16_end _m128ishufloepi16_85 label size_t pshuflw xmm0, xmm0, 85 jmp _m128ishufloepi16_end _m128ishufloepi16_86 label size_t pshuflw xmm0, xmm0, 86 jmp _m128ishufloepi16_end _m128ishufloepi16_87 label size_t pshuflw xmm0, xmm0, 87 jmp _m128ishufloepi16_end _m128ishufloepi16_88 label size_t pshuflw xmm0, xmm0, 88 jmp _m128ishufloepi16_end _m128ishufloepi16_89 label size_t pshuflw xmm0, xmm0, 89 jmp _m128ishufloepi16_end _m128ishufloepi16_90 label size_t pshuflw xmm0, xmm0, 90 jmp _m128ishufloepi16_end _m128ishufloepi16_91 label size_t pshuflw xmm0, xmm0, 91 jmp _m128ishufloepi16_end _m128ishufloepi16_92 label size_t pshuflw xmm0, xmm0, 92 jmp _m128ishufloepi16_end _m128ishufloepi16_93 label size_t pshuflw xmm0, xmm0, 93 jmp _m128ishufloepi16_end _m128ishufloepi16_94 label size_t pshuflw xmm0, xmm0, 94 jmp _m128ishufloepi16_end _m128ishufloepi16_95 label size_t pshuflw xmm0, xmm0, 95 jmp _m128ishufloepi16_end _m128ishufloepi16_96 label size_t pshuflw xmm0, xmm0, 96 jmp _m128ishufloepi16_end _m128ishufloepi16_97 label size_t pshuflw xmm0, xmm0, 97 jmp _m128ishufloepi16_end _m128ishufloepi16_98 label size_t pshuflw xmm0, xmm0, 98 jmp _m128ishufloepi16_end _m128ishufloepi16_99 label size_t pshuflw xmm0, xmm0, 99 jmp _m128ishufloepi16_end _m128ishufloepi16_100 label size_t pshuflw xmm0, xmm0, 100 jmp _m128ishufloepi16_end _m128ishufloepi16_101 label size_t pshuflw xmm0, xmm0, 101 jmp _m128ishufloepi16_end _m128ishufloepi16_102 label size_t pshuflw xmm0, xmm0, 102 jmp _m128ishufloepi16_end _m128ishufloepi16_103 label size_t pshuflw xmm0, xmm0, 103 jmp _m128ishufloepi16_end _m128ishufloepi16_104 label size_t pshuflw xmm0, xmm0, 104 jmp _m128ishufloepi16_end _m128ishufloepi16_105 label size_t pshuflw xmm0, xmm0, 105 jmp _m128ishufloepi16_end _m128ishufloepi16_106 label size_t pshuflw xmm0, xmm0, 106 jmp _m128ishufloepi16_end _m128ishufloepi16_107 label size_t pshuflw xmm0, xmm0, 107 jmp _m128ishufloepi16_end _m128ishufloepi16_108 label size_t pshuflw xmm0, xmm0, 108 jmp _m128ishufloepi16_end _m128ishufloepi16_109 label size_t pshuflw xmm0, xmm0, 109 jmp _m128ishufloepi16_end _m128ishufloepi16_110 label size_t pshuflw xmm0, xmm0, 110 jmp _m128ishufloepi16_end _m128ishufloepi16_111 label size_t pshuflw xmm0, xmm0, 111 jmp _m128ishufloepi16_end _m128ishufloepi16_112 label size_t pshuflw xmm0, xmm0, 112 jmp _m128ishufloepi16_end _m128ishufloepi16_113 label size_t pshuflw xmm0, xmm0, 113 jmp _m128ishufloepi16_end _m128ishufloepi16_114 label size_t pshuflw xmm0, xmm0, 114 jmp _m128ishufloepi16_end _m128ishufloepi16_115 label size_t pshuflw xmm0, xmm0, 115 jmp _m128ishufloepi16_end _m128ishufloepi16_116 label size_t pshuflw xmm0, xmm0, 116 jmp _m128ishufloepi16_end _m128ishufloepi16_117 label size_t pshuflw xmm0, xmm0, 117 jmp _m128ishufloepi16_end _m128ishufloepi16_118 label size_t pshuflw xmm0, xmm0, 118 jmp _m128ishufloepi16_end _m128ishufloepi16_119 label size_t pshuflw xmm0, xmm0, 119 jmp _m128ishufloepi16_end _m128ishufloepi16_120 label size_t pshuflw xmm0, xmm0, 120 jmp _m128ishufloepi16_end _m128ishufloepi16_121 label size_t pshuflw xmm0, xmm0, 121 jmp _m128ishufloepi16_end _m128ishufloepi16_122 label size_t pshuflw xmm0, xmm0, 122 jmp _m128ishufloepi16_end _m128ishufloepi16_123 label size_t pshuflw xmm0, xmm0, 123 jmp _m128ishufloepi16_end _m128ishufloepi16_124 label size_t pshuflw xmm0, xmm0, 124 jmp _m128ishufloepi16_end _m128ishufloepi16_125 label size_t pshuflw xmm0, xmm0, 125 jmp _m128ishufloepi16_end _m128ishufloepi16_126 label size_t pshuflw xmm0, xmm0, 126 jmp _m128ishufloepi16_end _m128ishufloepi16_127 label size_t pshuflw xmm0, xmm0, 127 jmp _m128ishufloepi16_end _m128ishufloepi16_128 label size_t pshuflw xmm0, xmm0, 128 jmp _m128ishufloepi16_end _m128ishufloepi16_129 label size_t pshuflw xmm0, xmm0, 129 jmp _m128ishufloepi16_end _m128ishufloepi16_130 label size_t pshuflw xmm0, xmm0, 130 jmp _m128ishufloepi16_end _m128ishufloepi16_131 label size_t pshuflw xmm0, xmm0, 131 jmp _m128ishufloepi16_end _m128ishufloepi16_132 label size_t pshuflw xmm0, xmm0, 132 jmp _m128ishufloepi16_end _m128ishufloepi16_133 label size_t pshuflw xmm0, xmm0, 133 jmp _m128ishufloepi16_end _m128ishufloepi16_134 label size_t pshuflw xmm0, xmm0, 134 jmp _m128ishufloepi16_end _m128ishufloepi16_135 label size_t pshuflw xmm0, xmm0, 135 jmp _m128ishufloepi16_end _m128ishufloepi16_136 label size_t pshuflw xmm0, xmm0, 136 jmp _m128ishufloepi16_end _m128ishufloepi16_137 label size_t pshuflw xmm0, xmm0, 137 jmp _m128ishufloepi16_end _m128ishufloepi16_138 label size_t pshuflw xmm0, xmm0, 138 jmp _m128ishufloepi16_end _m128ishufloepi16_139 label size_t pshuflw xmm0, xmm0, 139 jmp _m128ishufloepi16_end _m128ishufloepi16_140 label size_t pshuflw xmm0, xmm0, 140 jmp _m128ishufloepi16_end _m128ishufloepi16_141 label size_t pshuflw xmm0, xmm0, 141 jmp _m128ishufloepi16_end _m128ishufloepi16_142 label size_t pshuflw xmm0, xmm0, 142 jmp _m128ishufloepi16_end _m128ishufloepi16_143 label size_t pshuflw xmm0, xmm0, 143 jmp _m128ishufloepi16_end _m128ishufloepi16_144 label size_t pshuflw xmm0, xmm0, 144 jmp _m128ishufloepi16_end _m128ishufloepi16_145 label size_t pshuflw xmm0, xmm0, 145 jmp _m128ishufloepi16_end _m128ishufloepi16_146 label size_t pshuflw xmm0, xmm0, 146 jmp _m128ishufloepi16_end _m128ishufloepi16_147 label size_t pshuflw xmm0, xmm0, 147 jmp _m128ishufloepi16_end _m128ishufloepi16_148 label size_t pshuflw xmm0, xmm0, 148 jmp _m128ishufloepi16_end _m128ishufloepi16_149 label size_t pshuflw xmm0, xmm0, 149 jmp _m128ishufloepi16_end _m128ishufloepi16_150 label size_t pshuflw xmm0, xmm0, 150 jmp _m128ishufloepi16_end _m128ishufloepi16_151 label size_t pshuflw xmm0, xmm0, 151 jmp _m128ishufloepi16_end _m128ishufloepi16_152 label size_t pshuflw xmm0, xmm0, 152 jmp _m128ishufloepi16_end _m128ishufloepi16_153 label size_t pshuflw xmm0, xmm0, 153 jmp _m128ishufloepi16_end _m128ishufloepi16_154 label size_t pshuflw xmm0, xmm0, 154 jmp _m128ishufloepi16_end _m128ishufloepi16_155 label size_t pshuflw xmm0, xmm0, 155 jmp _m128ishufloepi16_end _m128ishufloepi16_156 label size_t pshuflw xmm0, xmm0, 156 jmp _m128ishufloepi16_end _m128ishufloepi16_157 label size_t pshuflw xmm0, xmm0, 157 jmp _m128ishufloepi16_end _m128ishufloepi16_158 label size_t pshuflw xmm0, xmm0, 158 jmp _m128ishufloepi16_end _m128ishufloepi16_159 label size_t pshuflw xmm0, xmm0, 159 jmp _m128ishufloepi16_end _m128ishufloepi16_160 label size_t pshuflw xmm0, xmm0, 160 jmp _m128ishufloepi16_end _m128ishufloepi16_161 label size_t pshuflw xmm0, xmm0, 161 jmp _m128ishufloepi16_end _m128ishufloepi16_162 label size_t pshuflw xmm0, xmm0, 162 jmp _m128ishufloepi16_end _m128ishufloepi16_163 label size_t pshuflw xmm0, xmm0, 163 jmp _m128ishufloepi16_end _m128ishufloepi16_164 label size_t pshuflw xmm0, xmm0, 164 jmp _m128ishufloepi16_end _m128ishufloepi16_165 label size_t pshuflw xmm0, xmm0, 165 jmp _m128ishufloepi16_end _m128ishufloepi16_166 label size_t pshuflw xmm0, xmm0, 166 jmp _m128ishufloepi16_end _m128ishufloepi16_167 label size_t pshuflw xmm0, xmm0, 167 jmp _m128ishufloepi16_end _m128ishufloepi16_168 label size_t pshuflw xmm0, xmm0, 168 jmp _m128ishufloepi16_end _m128ishufloepi16_169 label size_t pshuflw xmm0, xmm0, 169 jmp _m128ishufloepi16_end _m128ishufloepi16_170 label size_t pshuflw xmm0, xmm0, 170 jmp _m128ishufloepi16_end _m128ishufloepi16_171 label size_t pshuflw xmm0, xmm0, 171 jmp _m128ishufloepi16_end _m128ishufloepi16_172 label size_t pshuflw xmm0, xmm0, 172 jmp _m128ishufloepi16_end _m128ishufloepi16_173 label size_t pshuflw xmm0, xmm0, 173 jmp _m128ishufloepi16_end _m128ishufloepi16_174 label size_t pshuflw xmm0, xmm0, 174 jmp _m128ishufloepi16_end _m128ishufloepi16_175 label size_t pshuflw xmm0, xmm0, 175 jmp _m128ishufloepi16_end _m128ishufloepi16_176 label size_t pshuflw xmm0, xmm0, 176 jmp _m128ishufloepi16_end _m128ishufloepi16_177 label size_t pshuflw xmm0, xmm0, 177 jmp _m128ishufloepi16_end _m128ishufloepi16_178 label size_t pshuflw xmm0, xmm0, 178 jmp _m128ishufloepi16_end _m128ishufloepi16_179 label size_t pshuflw xmm0, xmm0, 179 jmp _m128ishufloepi16_end _m128ishufloepi16_180 label size_t pshuflw xmm0, xmm0, 180 jmp _m128ishufloepi16_end _m128ishufloepi16_181 label size_t pshuflw xmm0, xmm0, 181 jmp _m128ishufloepi16_end _m128ishufloepi16_182 label size_t pshuflw xmm0, xmm0, 182 jmp _m128ishufloepi16_end _m128ishufloepi16_183 label size_t pshuflw xmm0, xmm0, 183 jmp _m128ishufloepi16_end _m128ishufloepi16_184 label size_t pshuflw xmm0, xmm0, 184 jmp _m128ishufloepi16_end _m128ishufloepi16_185 label size_t pshuflw xmm0, xmm0, 185 jmp _m128ishufloepi16_end _m128ishufloepi16_186 label size_t pshuflw xmm0, xmm0, 186 jmp _m128ishufloepi16_end _m128ishufloepi16_187 label size_t pshuflw xmm0, xmm0, 187 jmp _m128ishufloepi16_end _m128ishufloepi16_188 label size_t pshuflw xmm0, xmm0, 188 jmp _m128ishufloepi16_end _m128ishufloepi16_189 label size_t pshuflw xmm0, xmm0, 189 jmp _m128ishufloepi16_end _m128ishufloepi16_190 label size_t pshuflw xmm0, xmm0, 190 jmp _m128ishufloepi16_end _m128ishufloepi16_191 label size_t pshuflw xmm0, xmm0, 191 jmp _m128ishufloepi16_end _m128ishufloepi16_192 label size_t pshuflw xmm0, xmm0, 192 jmp _m128ishufloepi16_end _m128ishufloepi16_193 label size_t pshuflw xmm0, xmm0, 193 jmp _m128ishufloepi16_end _m128ishufloepi16_194 label size_t pshuflw xmm0, xmm0, 194 jmp _m128ishufloepi16_end _m128ishufloepi16_195 label size_t pshuflw xmm0, xmm0, 195 jmp _m128ishufloepi16_end _m128ishufloepi16_196 label size_t pshuflw xmm0, xmm0, 196 jmp _m128ishufloepi16_end _m128ishufloepi16_197 label size_t pshuflw xmm0, xmm0, 197 jmp _m128ishufloepi16_end _m128ishufloepi16_198 label size_t pshuflw xmm0, xmm0, 198 jmp _m128ishufloepi16_end _m128ishufloepi16_199 label size_t pshuflw xmm0, xmm0, 199 jmp _m128ishufloepi16_end _m128ishufloepi16_200 label size_t pshuflw xmm0, xmm0, 200 jmp _m128ishufloepi16_end _m128ishufloepi16_201 label size_t pshuflw xmm0, xmm0, 201 jmp _m128ishufloepi16_end _m128ishufloepi16_202 label size_t pshuflw xmm0, xmm0, 202 jmp _m128ishufloepi16_end _m128ishufloepi16_203 label size_t pshuflw xmm0, xmm0, 203 jmp _m128ishufloepi16_end _m128ishufloepi16_204 label size_t pshuflw xmm0, xmm0, 204 jmp _m128ishufloepi16_end _m128ishufloepi16_205 label size_t pshuflw xmm0, xmm0, 205 jmp _m128ishufloepi16_end _m128ishufloepi16_206 label size_t pshuflw xmm0, xmm0, 206 jmp _m128ishufloepi16_end _m128ishufloepi16_207 label size_t pshuflw xmm0, xmm0, 207 jmp _m128ishufloepi16_end _m128ishufloepi16_208 label size_t pshuflw xmm0, xmm0, 208 jmp _m128ishufloepi16_end _m128ishufloepi16_209 label size_t pshuflw xmm0, xmm0, 209 jmp _m128ishufloepi16_end _m128ishufloepi16_210 label size_t pshuflw xmm0, xmm0, 210 jmp _m128ishufloepi16_end _m128ishufloepi16_211 label size_t pshuflw xmm0, xmm0, 211 jmp _m128ishufloepi16_end _m128ishufloepi16_212 label size_t pshuflw xmm0, xmm0, 212 jmp _m128ishufloepi16_end _m128ishufloepi16_213 label size_t pshuflw xmm0, xmm0, 213 jmp _m128ishufloepi16_end _m128ishufloepi16_214 label size_t pshuflw xmm0, xmm0, 214 jmp _m128ishufloepi16_end _m128ishufloepi16_215 label size_t pshuflw xmm0, xmm0, 215 jmp _m128ishufloepi16_end _m128ishufloepi16_216 label size_t pshuflw xmm0, xmm0, 216 jmp _m128ishufloepi16_end _m128ishufloepi16_217 label size_t pshuflw xmm0, xmm0, 217 jmp _m128ishufloepi16_end _m128ishufloepi16_218 label size_t pshuflw xmm0, xmm0, 218 jmp _m128ishufloepi16_end _m128ishufloepi16_219 label size_t pshuflw xmm0, xmm0, 219 jmp _m128ishufloepi16_end _m128ishufloepi16_220 label size_t pshuflw xmm0, xmm0, 220 jmp _m128ishufloepi16_end _m128ishufloepi16_221 label size_t pshuflw xmm0, xmm0, 221 jmp _m128ishufloepi16_end _m128ishufloepi16_222 label size_t pshuflw xmm0, xmm0, 222 jmp _m128ishufloepi16_end _m128ishufloepi16_223 label size_t pshuflw xmm0, xmm0, 223 jmp _m128ishufloepi16_end _m128ishufloepi16_224 label size_t pshuflw xmm0, xmm0, 224 jmp _m128ishufloepi16_end _m128ishufloepi16_225 label size_t pshuflw xmm0, xmm0, 225 jmp _m128ishufloepi16_end _m128ishufloepi16_226 label size_t pshuflw xmm0, xmm0, 226 jmp _m128ishufloepi16_end _m128ishufloepi16_227 label size_t pshuflw xmm0, xmm0, 227 jmp _m128ishufloepi16_end _m128ishufloepi16_228 label size_t pshuflw xmm0, xmm0, 228 jmp _m128ishufloepi16_end _m128ishufloepi16_229 label size_t pshuflw xmm0, xmm0, 229 jmp _m128ishufloepi16_end _m128ishufloepi16_230 label size_t pshuflw xmm0, xmm0, 230 jmp _m128ishufloepi16_end _m128ishufloepi16_231 label size_t pshuflw xmm0, xmm0, 231 jmp _m128ishufloepi16_end _m128ishufloepi16_232 label size_t pshuflw xmm0, xmm0, 232 jmp _m128ishufloepi16_end _m128ishufloepi16_233 label size_t pshuflw xmm0, xmm0, 233 jmp _m128ishufloepi16_end _m128ishufloepi16_234 label size_t pshuflw xmm0, xmm0, 234 jmp _m128ishufloepi16_end _m128ishufloepi16_235 label size_t pshuflw xmm0, xmm0, 235 jmp _m128ishufloepi16_end _m128ishufloepi16_236 label size_t pshuflw xmm0, xmm0, 236 jmp _m128ishufloepi16_end _m128ishufloepi16_237 label size_t pshuflw xmm0, xmm0, 237 jmp _m128ishufloepi16_end _m128ishufloepi16_238 label size_t pshuflw xmm0, xmm0, 238 jmp _m128ishufloepi16_end _m128ishufloepi16_239 label size_t pshuflw xmm0, xmm0, 239 jmp _m128ishufloepi16_end _m128ishufloepi16_240 label size_t pshuflw xmm0, xmm0, 240 jmp _m128ishufloepi16_end _m128ishufloepi16_241 label size_t pshuflw xmm0, xmm0, 241 jmp _m128ishufloepi16_end _m128ishufloepi16_242 label size_t pshuflw xmm0, xmm0, 242 jmp _m128ishufloepi16_end _m128ishufloepi16_243 label size_t pshuflw xmm0, xmm0, 243 jmp _m128ishufloepi16_end _m128ishufloepi16_244 label size_t pshuflw xmm0, xmm0, 244 jmp _m128ishufloepi16_end _m128ishufloepi16_245 label size_t pshuflw xmm0, xmm0, 245 jmp _m128ishufloepi16_end _m128ishufloepi16_246 label size_t pshuflw xmm0, xmm0, 246 jmp _m128ishufloepi16_end _m128ishufloepi16_247 label size_t pshuflw xmm0, xmm0, 247 jmp _m128ishufloepi16_end _m128ishufloepi16_248 label size_t pshuflw xmm0, xmm0, 248 jmp _m128ishufloepi16_end _m128ishufloepi16_249 label size_t pshuflw xmm0, xmm0, 249 jmp _m128ishufloepi16_end _m128ishufloepi16_250 label size_t pshuflw xmm0, xmm0, 250 jmp _m128ishufloepi16_end _m128ishufloepi16_251 label size_t pshuflw xmm0, xmm0, 251 jmp _m128ishufloepi16_end _m128ishufloepi16_252 label size_t pshuflw xmm0, xmm0, 252 jmp _m128ishufloepi16_end _m128ishufloepi16_253 label size_t pshuflw xmm0, xmm0, 253 jmp _m128ishufloepi16_end _m128ishufloepi16_254 label size_t pshuflw xmm0, xmm0, 254 jmp _m128ishufloepi16_end _m128ishufloepi16_255 label size_t pshuflw xmm0, xmm0, 255 ;jmp _m128ishufloepi16_end _m128ishufloepi16_end: pop rbase() ret procend endif ;__MIC__ end
; Make a little list... v0.02  Apr 1988 J.R.Oakley QJUMP section gen_util include 'dev8_keys_err' include 'dev8_keys_chunk' include 'dev8_keys_chp' xref gu_achpj xref gu_rchp xdef gu_adlis xdef gu_mklis xdef gu_prlis xdef gu_rtlis ;+++ ; Add to list make by GU_MKLIS ; ; Registers: ; Entry Exit ; D0.w entry length (if a1=0) error code ; D1 number of entries ; D2 modified only by generating code ; A0 entry generating code ; A1 pointer to list pointer to list ; A2/A3 modified only by generating code ; ; status return standard ;--- gu_adlis mklreg reg d3-d7/a0/a1/a4/a5 frame equ $04 stk_ownr equ $00 stk_a1 equ $1c move.l a1,d1 ; any list? beq.s gu_mklis ; ... no start from scratch movem.l mklreg,-(sp) move.l chp_ownr-chp.len(a1),-(sp) ; owner of this list move.w chk_entl(a1),d0 ; entry length move.w chk_totl(a1),d3 ; total so far gal_loop move.l d1,a5 ; next chunk move.l chk_next(a5),d1 bne.s gal_loop move.w chk_nent(a5),d4 ; entries in this chunk mulu d0,d4 lea chk.hdrl(a5,d4.l),a1 ; position of next bit move.w chk_maxe(a5),d5 sub.w chk_nent(a5),d5 ; entries so far bra.s gml_cont ; and continue ;+++ ; General list making routine. Given an entry size and a routine to ; create an entry, a linked list of "chunks" with a number of entries ; is created. The chunk format is: ; ; long next chunk ; word max entries in this chunk ; word actual entries in this chunk ; word entry length (first chunk, but actually in all chunks) ; word total number of entries (first chunk) ; ; Registers: ; Entry Exit ; D0.w entry length error code ; D1 number of entries ; D2 modified only by generating code ; A0 entry generating code ; A1 pointer to list ; A2/A3 modified only by generating code ; ; The entry generating code should adhere to the following rules: ; ; Registers: ; Entry Exit ; D0 error or ERR.EOF if no more ; D1/D2 unused by this routine used as required ; D3 entry number (0..n) preserved ; A1 space for entry preserved ; A2/A3 unused by this routine used as required ;--- gu_mklis sub.l a1,a1 ; no list to start with movem.l mklreg,-(sp) move.l #-1,-(sp) ; list owned by me! lea stk_a1-chk_next(sp),a5 ; where to put first chunk pointer moveq #0,d3 ; no entries so far moveq #0,d5 gml_cont moveq #$10,d7 ; sixteen entries per chunk move.w d0,d4 mulu d7,d0 ; chunk size is this addq.l #chk.hdrl/2,d0 ; plus space for header addq.l #chk.hdrl/2,d0 move.l d0,d6 ; keep that move.l a0,a4 ; keep code pointer tst.w d5 beq.s gml_nxtc gml_loop jsr (a4) ; get next entry bne.s gml_chke ; not OK, finished or error addq.w #1,d3 ; one more entry addq.w #1,chk_nent(a5) ; one more entry in this chunk add.w d4,a1 ; next entry subq.w #1,d5 ; is there one? bne.s gml_loop ; yes, fill it in gml_nxtc move.l d6,d0 ; no, get this much space move.l stk_ownr(sp),a0 ; for the list owner jsr gu_achpj(pc) bne.s gml_chke ; ...oops move.l a0,chk_next(a5) ; link new to the last one (if any) exg a0,a5 ; new becomes current move.w d7,chk_maxe(a5) ; max entries this chunk move.w d7,d5 move.w d4,chk_entl(a5) ; length of entry lea chk.hdrl(a5),a1 ; first entry bra.s gml_loop ; fill it in gml_chke move.l stk_a1(sp),a1 ; start of list cmp.l #err.eof,d0 ; just EOF? bne.s gml_exrm ; no, remove chunks tst.w chk_nent(a5) ; is this chunk used? bne.s gml_exok ; yes clr.l chk_next(a0) ; no, clear last link pointer move.l a5,a0 ; and return last chunk jsr gu_rchp(pc) gml_exok move.w d3,d1 ; return total number of entries move.w d1,chk_totl(a1) moveq #0,d0 gml_exit addq.l #frame,sp movem.l (sp)+,mklreg tst.l d0 rts gml_exrm bsr.s gu_rtlis ; remove any current list bra.s gml_exit ; and exit ;+++ ; Return a general list, as made with gu_MKLIS, to the heap. ; ; Registers: ; Entry Exit ; D0 zero ; A1 pointer to first chunk zero ;--- gu_rtlis rtlreg reg d0/a0 movem.l rtlreg,-(sp) bra.s grl_eloop grl_loop move.l chk_next(a1),a1 ; yes, get next move.l d0,a0 jsr gu_rchp(pc) ; return this one grl_eloop move.l a1,d0 ; see if there is one bne.s grl_loop grl_exit movem.l (sp)+,rtlreg rts ;+++ ; Process a general list, as made with gu_MKLIS. ; ; Registers: ; Entry Exit ; D0 error code ; A0 processing code preserved ; A1 list to process (first chunk) preserved ; ; The processing code should adhere to the following rules: ; ; Registers: ; Entry Exit ; D0 error code ; D1-D3 unused by this routine used as required ; A1 entry to process preserved ; A2-A4 unused by this routine used as required ;--- gu_prlis prlreg reg d4-d6/a1/a5 movem.l prlreg,-(sp) move.l a1,d5 ; and start chunk beq.s gpl_exok move.w chk_entl(a1),d4 ; keep entry length bra.s gpl_nxtc gpl_loop jsr (a0) ; process this entry bne.s gpl_exit ; ...oops add.w d4,a1 ; next entry subq.w #1,d6 ; more entries? bne.s gpl_loop ; yes * move.l chk_next(a5),d5 ; next chunk gpl_nxtc beq.s gpl_exok ; no more, exit move.l d5,a5 ; point to chunk lea chk.hdrl(a5),a1 ; point to first entry move.w chk_nent(a5),d6 ; this many entries bgt.s gpl_loop * gpl_exok moveq #0,d0 gpl_exit movem.l (sp)+,prlreg rts * end
; A167032: a(n) = 20*a(n-1) - 64*a(n-2) + 2 for n > 1; a(0) = 1, a(1) = 21. ; Submitted by Jon Maiga ; 1,21,358,5818,93450,1496650,23952202,383258442,6132227914,98116017994,1569857773386,25117730316106,401883708825418,6430139436277578,102882231360724810,1646115703292731210,26337851258768236362,421405620164629929802,6742489922731431468874,107879838764092313870154,1726077420227034663395146,27617238723638785180213066,441875819578245485146971978,7070013113252027451405803338,113120209812032837978709860170,1809923356992527002684225789770,28958773711880438423047084744522 mov $1,5 mov $2,1 lpb $0 sub $0,1 mul $2,16 add $2,$1 mul $1,4 add $1,2 lpe mov $0,$2
; ; Copyright (c) 2010 The WebM project authors. All Rights Reserved. ; ; Use of this source code is governed by a BSD-style license ; that can be found in the LICENSE file in the root of the source ; tree. An additional intellectual property rights grant can be found ; in the file PATENTS. All contributing project authors may ; be found in the AUTHORS file in the root of the source tree. ; %include "vpx_ports/x86_abi_support.asm" ;void copy_mem8x8_mmx( ; unsigned char *src, ; int src_stride, ; unsigned char *dst, ; int dst_stride ; ) global sym(vp8_copy_mem8x8_mmx) PRIVATE sym(vp8_copy_mem8x8_mmx): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 4 push rsi push rdi ; end prolog mov rsi, arg(0) ;src; movq mm0, [rsi] movsxd rax, dword ptr arg(1) ;src_stride; mov rdi, arg(2) ;dst; movq mm1, [rsi+rax] movq mm2, [rsi+rax*2] movsxd rcx, dword ptr arg(3) ;dst_stride lea rsi, [rsi+rax*2] movq [rdi], mm0 add rsi, rax movq [rdi+rcx], mm1 movq [rdi+rcx*2], mm2 lea rdi, [rdi+rcx*2] movq mm3, [rsi] add rdi, rcx movq mm4, [rsi+rax] movq mm5, [rsi+rax*2] movq [rdi], mm3 lea rsi, [rsi+rax*2] movq [rdi+rcx], mm4 movq [rdi+rcx*2], mm5 lea rdi, [rdi+rcx*2] movq mm0, [rsi+rax] movq mm1, [rsi+rax*2] movq [rdi+rcx], mm0 movq [rdi+rcx*2],mm1 ; begin epilog pop rdi pop rsi UNSHADOW_ARGS pop rbp ret ;void copy_mem8x4_mmx( ; unsigned char *src, ; int src_stride, ; unsigned char *dst, ; int dst_stride ; ) global sym(vp8_copy_mem8x4_mmx) PRIVATE sym(vp8_copy_mem8x4_mmx): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 4 push rsi push rdi ; end prolog mov rsi, arg(0) ;src; movq mm0, [rsi] movsxd rax, dword ptr arg(1) ;src_stride; mov rdi, arg(2) ;dst; movq mm1, [rsi+rax] movq mm2, [rsi+rax*2] movsxd rcx, dword ptr arg(3) ;dst_stride lea rsi, [rsi+rax*2] movq [rdi], mm0 movq [rdi+rcx], mm1 movq [rdi+rcx*2], mm2 lea rdi, [rdi+rcx*2] movq mm3, [rsi+rax] movq [rdi+rcx], mm3 ; begin epilog pop rdi pop rsi UNSHADOW_ARGS pop rbp ret ;void copy_mem16x16_mmx( ; unsigned char *src, ; int src_stride, ; unsigned char *dst, ; int dst_stride ; ) global sym(vp8_copy_mem16x16_mmx) PRIVATE sym(vp8_copy_mem16x16_mmx): push rbp mov rbp, rsp SHADOW_ARGS_TO_STACK 4 push rsi push rdi ; end prolog mov rsi, arg(0) ;src; movsxd rax, dword ptr arg(1) ;src_stride; mov rdi, arg(2) ;dst; movsxd rcx, dword ptr arg(3) ;dst_stride movq mm0, [rsi] movq mm3, [rsi+8]; movq mm1, [rsi+rax] movq mm4, [rsi+rax+8] movq mm2, [rsi+rax*2] movq mm5, [rsi+rax*2+8] lea rsi, [rsi+rax*2] add rsi, rax movq [rdi], mm0 movq [rdi+8], mm3 movq [rdi+rcx], mm1 movq [rdi+rcx+8], mm4 movq [rdi+rcx*2], mm2 movq [rdi+rcx*2+8], mm5 lea rdi, [rdi+rcx*2] add rdi, rcx movq mm0, [rsi] movq mm3, [rsi+8]; movq mm1, [rsi+rax] movq mm4, [rsi+rax+8] movq mm2, [rsi+rax*2] movq mm5, [rsi+rax*2+8] lea rsi, [rsi+rax*2] add rsi, rax movq [rdi], mm0 movq [rdi+8], mm3 movq [rdi+rcx], mm1 movq [rdi+rcx+8], mm4 movq [rdi+rcx*2], mm2 movq [rdi+rcx*2+8], mm5 lea rdi, [rdi+rcx*2] add rdi, rcx movq mm0, [rsi] movq mm3, [rsi+8]; movq mm1, [rsi+rax] movq mm4, [rsi+rax+8] movq mm2, [rsi+rax*2] movq mm5, [rsi+rax*2+8] lea rsi, [rsi+rax*2] add rsi, rax movq [rdi], mm0 movq [rdi+8], mm3 movq [rdi+rcx], mm1 movq [rdi+rcx+8], mm4 movq [rdi+rcx*2], mm2 movq [rdi+rcx*2+8], mm5 lea rdi, [rdi+rcx*2] add rdi, rcx movq mm0, [rsi] movq mm3, [rsi+8]; movq mm1, [rsi+rax] movq mm4, [rsi+rax+8] movq mm2, [rsi+rax*2] movq mm5, [rsi+rax*2+8] lea rsi, [rsi+rax*2] add rsi, rax movq [rdi], mm0 movq [rdi+8], mm3 movq [rdi+rcx], mm1 movq [rdi+rcx+8], mm4 movq [rdi+rcx*2], mm2 movq [rdi+rcx*2+8], mm5 lea rdi, [rdi+rcx*2] add rdi, rcx movq mm0, [rsi] movq mm3, [rsi+8]; movq mm1, [rsi+rax] movq mm4, [rsi+rax+8] movq mm2, [rsi+rax*2] movq mm5, [rsi+rax*2+8] lea rsi, [rsi+rax*2] add rsi, rax movq [rdi], mm0 movq [rdi+8], mm3 movq [rdi+rcx], mm1 movq [rdi+rcx+8], mm4 movq [rdi+rcx*2], mm2 movq [rdi+rcx*2+8], mm5 lea rdi, [rdi+rcx*2] add rdi, rcx movq mm0, [rsi] movq mm3, [rsi+8]; movq [rdi], mm0 movq [rdi+8], mm3 ; begin epilog pop rdi pop rsi UNSHADOW_ARGS pop rbp ret
// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/extensions/sandboxed_unpacker.h" #include <set> #include "base/base64.h" #include "base/bind.h" #include "base/file_util.h" #include "base/file_util_proxy.h" #include "base/json/json_string_value_serializer.h" #include "base/memory/scoped_handle.h" #include "base/message_loop.h" #include "base/metrics/histogram.h" #include "base/path_service.h" #include "base/utf_string_conversions.h" // TODO(viettrungluu): delete me. #include "chrome/browser/extensions/crx_file.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/common/chrome_paths.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/chrome_utility_messages.h" #include "chrome/common/extensions/extension_manifest_constants.h" #include "chrome/common/extensions/extension_file_util.h" #include "chrome/common/extensions/extension_l10n_util.h" #include "chrome/common/extensions/unpacker.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/utility_process_host.h" #include "crypto/signature_verifier.h" #include "grit/generated_resources.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/base/l10n/l10n_util.h" #include "ui/gfx/codec/png_codec.h" using content::BrowserThread; using content::UtilityProcessHost; // The following macro makes histograms that record the length of paths // in this file much easier to read. // Windows has a short max path length. If the path length to a // file being unpacked from a CRX exceeds the max length, we might // fail to install. To see if this is happening, see how long the // path to the temp unpack directory is. See crbug.com/69693 . #define PATH_LENGTH_HISTOGRAM(name, path) \ UMA_HISTOGRAM_CUSTOM_COUNTS(name, path.value().length(), 0, 500, 100) // Record a rate (kB per second) at which extensions are unpacked. // Range from 1kB/s to 100mB/s. #define UNPACK_RATE_HISTOGRAM(name, rate) \ UMA_HISTOGRAM_CUSTOM_COUNTS(name, rate, 1, 100000, 100); namespace { void RecordSuccessfulUnpackTimeHistograms( const FilePath& crx_path, const base::TimeDelta unpack_time) { const int64 kBytesPerKb = 1024; const int64 kBytesPerMb = 1024 * 1024; UMA_HISTOGRAM_TIMES("Extensions.SandboxUnpackSuccessTime", unpack_time); // To get a sense of how CRX size impacts unpack time, record unpack // time for several increments of CRX size. int64 crx_file_size; if (!file_util::GetFileSize(crx_path, &crx_file_size)) { UMA_HISTOGRAM_COUNTS("Extensions.SandboxUnpackSuccessCantGetCrxSize", 1); return; } // Cast is safe as long as the number of bytes in the CRX is less than // 2^31 * 2^10. int crx_file_size_kb = static_cast<int>(crx_file_size / kBytesPerKb); UMA_HISTOGRAM_COUNTS( "Extensions.SandboxUnpackSuccessCrxSize", crx_file_size_kb); // We have time in seconds and file size in bytes. We want the rate bytes are // unpacked in kB/s. double file_size_kb = static_cast<double>(crx_file_size) / static_cast<double>(kBytesPerKb); int unpack_rate_kb_per_s = static_cast<int>(file_size_kb / unpack_time.InSecondsF()); UNPACK_RATE_HISTOGRAM("Extensions.SandboxUnpackRate", unpack_rate_kb_per_s); if (crx_file_size < 50.0 * kBytesPerKb) { UNPACK_RATE_HISTOGRAM( "Extensions.SandboxUnpackRateUnder50kB", unpack_rate_kb_per_s); } else if (crx_file_size < 1 * kBytesPerMb) { UNPACK_RATE_HISTOGRAM( "Extensions.SandboxUnpackRate50kBTo1mB", unpack_rate_kb_per_s); } else if (crx_file_size < 2 * kBytesPerMb) { UNPACK_RATE_HISTOGRAM( "Extensions.SandboxUnpackRate1To2mB", unpack_rate_kb_per_s); } else if (crx_file_size < 5 * kBytesPerMb) { UNPACK_RATE_HISTOGRAM( "Extensions.SandboxUnpackRate2To5mB", unpack_rate_kb_per_s); } else if (crx_file_size < 10 * kBytesPerMb) { UNPACK_RATE_HISTOGRAM( "Extensions.SandboxUnpackRate5To10mB", unpack_rate_kb_per_s); } else { UNPACK_RATE_HISTOGRAM( "Extensions.SandboxUnpackRateOver10mB", unpack_rate_kb_per_s); } } // Work horse for FindWritableTempLocation. Creates a temp file in the folder // and uses NormalizeFilePath to check if the path is junction free. bool VerifyJunctionFreeLocation(FilePath* temp_dir) { if (temp_dir->empty()) return false; FilePath temp_file; if (!file_util::CreateTemporaryFileInDir(*temp_dir, &temp_file)) { LOG(ERROR) << temp_dir->value() << " is not writable"; return false; } // NormalizeFilePath requires a non-empty file, so write some data. // If you change the exit points of this function please make sure all // exit points delete this temp file! file_util::WriteFile(temp_file, ".", 1); FilePath normalized_temp_file; bool normalized = file_util::NormalizeFilePath(temp_file, &normalized_temp_file); if (!normalized) { // If |temp_file| contains a link, the sandbox will block al file system // operations, and the install will fail. LOG(ERROR) << temp_dir->value() << " seem to be on remote drive."; } else { *temp_dir = normalized_temp_file.DirName(); } // Clean up the temp file. file_util::Delete(temp_file, false); return normalized; } // This function tries to find a location for unpacking the extension archive // that is writable and does not lie on a shared drive so that the sandboxed // unpacking process can write there. If no such location exists we can not // proceed and should fail. // The result will be written to |temp_dir|. The function will write to this // parameter even if it returns false. bool FindWritableTempLocation(FilePath* temp_dir) { PathService::Get(base::DIR_TEMP, temp_dir); if (VerifyJunctionFreeLocation(temp_dir)) return true; *temp_dir = extension_file_util::GetUserDataTempDir(); if (VerifyJunctionFreeLocation(temp_dir)) return true; // Neither paths is link free chances are good installation will fail. LOG(ERROR) << "Both the %TEMP% folder and the profile seem to be on " << "remote drives or read-only. Installation can not complete!"; return false; } } // namespace namespace extensions { SandboxedUnpacker::SandboxedUnpacker( const FilePath& crx_path, bool run_out_of_process, Extension::Location location, int creation_flags, SandboxedUnpackerClient* client) : crx_path_(crx_path), thread_identifier_(BrowserThread::ID_COUNT), run_out_of_process_(run_out_of_process), client_(client), got_response_(false), location_(location), creation_flags_(creation_flags) { } bool SandboxedUnpacker::CreateTempDirectory() { CHECK(BrowserThread::GetCurrentThreadIdentifier(&thread_identifier_)); FilePath temp_dir; if (!FindWritableTempLocation(&temp_dir)) { ReportFailure( COULD_NOT_GET_TEMP_DIRECTORY, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_INSTALL_ERROR, ASCIIToUTF16("COULD_NOT_GET_TEMP_DIRECTORY"))); return false; } if (!temp_dir_.CreateUniqueTempDirUnderPath(temp_dir)) { ReportFailure( COULD_NOT_CREATE_TEMP_DIRECTORY, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_INSTALL_ERROR, ASCIIToUTF16("COULD_NOT_CREATE_TEMP_DIRECTORY"))); return false; } return true; } void SandboxedUnpacker::Start() { // We assume that we are started on the thread that the client wants us to do // file IO on. CHECK(BrowserThread::GetCurrentThreadIdentifier(&thread_identifier_)); unpack_start_time_ = base::TimeTicks::Now(); PATH_LENGTH_HISTOGRAM("Extensions.SandboxUnpackInitialCrxPathLength", crx_path_); if (!CreateTempDirectory()) return; // ReportFailure() already called. // Initialize the path that will eventually contain the unpacked extension. extension_root_ = temp_dir_.path().AppendASCII( extension_filenames::kTempExtensionName); PATH_LENGTH_HISTOGRAM("Extensions.SandboxUnpackUnpackedCrxPathLength", extension_root_); // Extract the public key and validate the package. if (!ValidateSignature()) return; // ValidateSignature() already reported the error. // Copy the crx file into our working directory. FilePath temp_crx_path = temp_dir_.path().Append(crx_path_.BaseName()); PATH_LENGTH_HISTOGRAM("Extensions.SandboxUnpackTempCrxPathLength", temp_crx_path); if (!file_util::CopyFile(crx_path_, temp_crx_path)) { // Failed to copy extension file to temporary directory. ReportFailure( FAILED_TO_COPY_EXTENSION_FILE_TO_TEMP_DIRECTORY, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_INSTALL_ERROR, ASCIIToUTF16("FAILED_TO_COPY_EXTENSION_FILE_TO_TEMP_DIRECTORY"))); return; } // If we are supposed to use a subprocess, kick off the subprocess. // // TODO(asargent) we shouldn't need to do this branch here - instead // UtilityProcessHost should handle it for us. (http://crbug.com/19192) bool use_utility_process = run_out_of_process_ && !CommandLine::ForCurrentProcess()->HasSwitch(switches::kSingleProcess); if (use_utility_process) { // The utility process will have access to the directory passed to // SandboxedUnpacker. That directory should not contain a symlink or NTFS // reparse point. When the path is used, following the link/reparse point // will cause file system access outside the sandbox path, and the sandbox // will deny the operation. FilePath link_free_crx_path; if (!file_util::NormalizeFilePath(temp_crx_path, &link_free_crx_path)) { LOG(ERROR) << "Could not get the normalized path of " << temp_crx_path.value(); ReportFailure( COULD_NOT_GET_SANDBOX_FRIENDLY_PATH, l10n_util::GetStringUTF16(IDS_EXTENSION_UNPACK_FAILED)); return; } PATH_LENGTH_HISTOGRAM("Extensions.SandboxUnpackLinkFreeCrxPathLength", link_free_crx_path); BrowserThread::PostTask( BrowserThread::IO, FROM_HERE, base::Bind( &SandboxedUnpacker::StartProcessOnIOThread, this, link_free_crx_path)); } else { // Otherwise, unpack the extension in this process. Unpacker unpacker(temp_crx_path, extension_id_, location_, creation_flags_); if (unpacker.Run() && unpacker.DumpImagesToFile() && unpacker.DumpMessageCatalogsToFile()) { OnUnpackExtensionSucceeded(*unpacker.parsed_manifest()); } else { OnUnpackExtensionFailed(unpacker.error_message()); } } } SandboxedUnpacker::~SandboxedUnpacker() { base::FileUtilProxy::Delete( BrowserThread::GetMessageLoopProxyForThread(thread_identifier_), temp_dir_.Take(), true, base::FileUtilProxy::StatusCallback()); } bool SandboxedUnpacker::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(SandboxedUnpacker, message) IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_UnpackExtension_Succeeded, OnUnpackExtensionSucceeded) IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_UnpackExtension_Failed, OnUnpackExtensionFailed) IPC_MESSAGE_UNHANDLED(handled = false) IPC_END_MESSAGE_MAP() return handled; } void SandboxedUnpacker::OnProcessCrashed(int exit_code) { // Don't report crashes if they happen after we got a response. if (got_response_) return; // Utility process crashed while trying to install. ReportFailure( UTILITY_PROCESS_CRASHED_WHILE_TRYING_TO_INSTALL, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_INSTALL_ERROR, ASCIIToUTF16("UTILITY_PROCESS_CRASHED_WHILE_TRYING_TO_INSTALL"))); } void SandboxedUnpacker::StartProcessOnIOThread(const FilePath& temp_crx_path) { UtilityProcessHost* host = UtilityProcessHost::Create( this, thread_identifier_); // Grant the subprocess access to the entire subdir the extension file is // in, so that it can unpack to that dir. host->SetExposedDir(temp_crx_path.DirName()); host->Send( new ChromeUtilityMsg_UnpackExtension( temp_crx_path, extension_id_, location_, creation_flags_)); } void SandboxedUnpacker::OnUnpackExtensionSucceeded( const DictionaryValue& manifest) { // Skip check for unittests. if (thread_identifier_ != BrowserThread::ID_COUNT) CHECK(BrowserThread::CurrentlyOn(thread_identifier_)); got_response_ = true; scoped_ptr<DictionaryValue> final_manifest(RewriteManifestFile(manifest)); if (!final_manifest.get()) return; // Create an extension object that refers to the temporary location the // extension was unpacked to. We use this until the extension is finally // installed. For example, the install UI shows images from inside the // extension. // Localize manifest now, so confirm UI gets correct extension name. // TODO(rdevlin.cronin): Continue removing std::string errors and replacing // with string16 std::string utf8_error; if (!extension_l10n_util::LocalizeExtension(extension_root_, final_manifest.get(), &utf8_error)) { ReportFailure( COULD_NOT_LOCALIZE_EXTENSION, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_ERROR_MESSAGE, UTF8ToUTF16(utf8_error))); return; } extension_ = Extension::Create( extension_root_, location_, *final_manifest, Extension::REQUIRE_KEY | creation_flags_, &utf8_error); if (!extension_.get()) { ReportFailure( INVALID_MANIFEST, ASCIIToUTF16("Manifest is invalid: " + utf8_error)); return; } if (!RewriteImageFiles()) return; if (!RewriteCatalogFiles()) return; ReportSuccess(manifest); } void SandboxedUnpacker::OnUnpackExtensionFailed(const string16& error) { CHECK(BrowserThread::CurrentlyOn(thread_identifier_)); got_response_ = true; ReportFailure( UNPACKER_CLIENT_FAILED, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_ERROR_MESSAGE, error)); } bool SandboxedUnpacker::ValidateSignature() { ScopedStdioHandle file(file_util::OpenFile(crx_path_, "rb")); if (!file.get()) { // Could not open crx file for reading. #if defined (OS_WIN) // On windows, get the error code. uint32 error_code = ::GetLastError(); // TODO(skerner): Use this histogram to understand why so many // windows users hit this error. crbug.com/69693 // Windows errors are unit32s, but all of likely errors are in // [1, 1000]. See winerror.h for the meaning of specific values. // Clip errors outside the expected range to a single extra value. // If there are errors in that extra bucket, we will know to expand // the range. const uint32 kMaxErrorToSend = 1001; error_code = std::min(error_code, kMaxErrorToSend); UMA_HISTOGRAM_ENUMERATION("Extensions.ErrorCodeFromCrxOpen", error_code, kMaxErrorToSend); #endif ReportFailure( CRX_FILE_NOT_READABLE, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_ERROR_CODE, ASCIIToUTF16("CRX_FILE_NOT_READABLE"))); return false; } // Read and verify the header. // TODO(erikkay): Yuck. I'm not a big fan of this kind of code, but it // appears that we don't have any endian/alignment aware serialization // code in the code base. So for now, this assumes that we're running // on a little endian machine with 4 byte alignment. CrxFile::Header header; size_t len = fread(&header, 1, sizeof(header), file.get()); if (len < sizeof(header)) { // Invalid crx header ReportFailure( CRX_HEADER_INVALID, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_ERROR_CODE, ASCIIToUTF16("CRX_HEADER_INVALID"))); return false; } CrxFile::Error error; scoped_ptr<CrxFile> crx(CrxFile::Parse(header, &error)); if (!crx.get()) { switch (error) { case CrxFile::kWrongMagic: ReportFailure( CRX_MAGIC_NUMBER_INVALID, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_ERROR_CODE, ASCIIToUTF16("CRX_MAGIC_NUMBER_INVALID"))); break; case CrxFile::kInvalidVersion: // Bad version numer ReportFailure( CRX_VERSION_NUMBER_INVALID, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_ERROR_CODE, ASCIIToUTF16("CRX_VERSION_NUMBER_INVALID"))); break; case CrxFile::kInvalidKeyTooLarge: case CrxFile::kInvalidSignatureTooLarge: // Excessively large key or signature ReportFailure( CRX_EXCESSIVELY_LARGE_KEY_OR_SIGNATURE, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_ERROR_CODE, ASCIIToUTF16("CRX_EXCESSIVELY_LARGE_KEY_OR_SIGNATURE"))); break; case CrxFile::kInvalidKeyTooSmall: // Key length is zero ReportFailure( CRX_ZERO_KEY_LENGTH, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_ERROR_CODE, ASCIIToUTF16("CRX_ZERO_KEY_LENGTH"))); break; case CrxFile::kInvalidSignatureTooSmall: // Signature length is zero ReportFailure( CRX_ZERO_SIGNATURE_LENGTH, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_ERROR_CODE, ASCIIToUTF16("CRX_ZERO_SIGNATURE_LENGTH"))); break; } return false; } std::vector<uint8> key; key.resize(header.key_size); len = fread(&key.front(), sizeof(uint8), header.key_size, file.get()); if (len < header.key_size) { // Invalid public key ReportFailure( CRX_PUBLIC_KEY_INVALID, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_ERROR_CODE, ASCIIToUTF16("CRX_PUBLIC_KEY_INVALID"))); return false; } std::vector<uint8> signature; signature.resize(header.signature_size); len = fread(&signature.front(), sizeof(uint8), header.signature_size, file.get()); if (len < header.signature_size) { // Invalid signature ReportFailure( CRX_SIGNATURE_INVALID, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_ERROR_CODE, ASCIIToUTF16("CRX_SIGNATURE_INVALID"))); return false; } crypto::SignatureVerifier verifier; if (!verifier.VerifyInit(extension_misc::kSignatureAlgorithm, sizeof(extension_misc::kSignatureAlgorithm), &signature.front(), signature.size(), &key.front(), key.size())) { // Signature verification initialization failed. This is most likely // caused by a public key in the wrong format (should encode algorithm). ReportFailure( CRX_SIGNATURE_VERIFICATION_INITIALIZATION_FAILED, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_ERROR_CODE, ASCIIToUTF16("CRX_SIGNATURE_VERIFICATION_INITIALIZATION_FAILED"))); return false; } unsigned char buf[1 << 12]; while ((len = fread(buf, 1, sizeof(buf), file.get())) > 0) verifier.VerifyUpdate(buf, len); if (!verifier.VerifyFinal()) { // Signature verification failed ReportFailure( CRX_SIGNATURE_VERIFICATION_FAILED, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_ERROR_CODE, ASCIIToUTF16("CRX_SIGNATURE_VERIFICATION_FAILED"))); return false; } std::string public_key = std::string(reinterpret_cast<char*>(&key.front()), key.size()); base::Base64Encode(public_key, &public_key_); if (!Extension::GenerateId(public_key, &extension_id_)) return false; return true; } void SandboxedUnpacker::ReportFailure(FailureReason reason, const string16& error) { UMA_HISTOGRAM_ENUMERATION("Extensions.SandboxUnpackFailureReason", reason, NUM_FAILURE_REASONS); UMA_HISTOGRAM_TIMES("Extensions.SandboxUnpackFailureTime", base::TimeTicks::Now() - unpack_start_time_); client_->OnUnpackFailure(error); } void SandboxedUnpacker::ReportSuccess( const DictionaryValue& original_manifest) { UMA_HISTOGRAM_COUNTS("Extensions.SandboxUnpackSuccess", 1); RecordSuccessfulUnpackTimeHistograms( crx_path_, base::TimeTicks::Now() - unpack_start_time_); // Client takes ownership of temporary directory and extension. client_->OnUnpackSuccess(temp_dir_.Take(), extension_root_, &original_manifest, extension_); extension_ = NULL; } DictionaryValue* SandboxedUnpacker::RewriteManifestFile( const DictionaryValue& manifest) { // Add the public key extracted earlier to the parsed manifest and overwrite // the original manifest. We do this to ensure the manifest doesn't contain an // exploitable bug that could be used to compromise the browser. scoped_ptr<DictionaryValue> final_manifest(manifest.DeepCopy()); final_manifest->SetString(extension_manifest_keys::kPublicKey, public_key_); std::string manifest_json; JSONStringValueSerializer serializer(&manifest_json); serializer.set_pretty_print(true); if (!serializer.Serialize(*final_manifest)) { // Error serializing manifest.json. ReportFailure( ERROR_SERIALIZING_MANIFEST_JSON, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_INSTALL_ERROR, ASCIIToUTF16("ERROR_SERIALIZING_MANIFEST_JSON"))); return NULL; } FilePath manifest_path = extension_root_.Append(Extension::kManifestFilename); if (!file_util::WriteFile(manifest_path, manifest_json.data(), manifest_json.size())) { // Error saving manifest.json. ReportFailure( ERROR_SAVING_MANIFEST_JSON, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_INSTALL_ERROR, ASCIIToUTF16("ERROR_SAVING_MANIFEST_JSON"))); return NULL; } return final_manifest.release(); } bool SandboxedUnpacker::RewriteImageFiles() { Unpacker::DecodedImages images; if (!Unpacker::ReadImagesFromFile(temp_dir_.path(), &images)) { // Couldn't read image data from disk. ReportFailure( COULD_NOT_READ_IMAGE_DATA_FROM_DISK, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_INSTALL_ERROR, ASCIIToUTF16("COULD_NOT_READ_IMAGE_DATA_FROM_DISK"))); return false; } // Delete any images that may be used by the browser. We're going to write // out our own versions of the parsed images, and we want to make sure the // originals are gone for good. std::set<FilePath> image_paths = extension_->GetBrowserImages(); if (image_paths.size() != images.size()) { // Decoded images don't match what's in the manifest. ReportFailure( DECODED_IMAGES_DO_NOT_MATCH_THE_MANIFEST, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_INSTALL_ERROR, ASCIIToUTF16("DECODED_IMAGES_DO_NOT_MATCH_THE_MANIFEST"))); return false; } for (std::set<FilePath>::iterator it = image_paths.begin(); it != image_paths.end(); ++it) { FilePath path = *it; if (path.IsAbsolute() || path.ReferencesParent()) { // Invalid path for browser image. ReportFailure( INVALID_PATH_FOR_BROWSER_IMAGE, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_INSTALL_ERROR, ASCIIToUTF16("INVALID_PATH_FOR_BROWSER_IMAGE"))); return false; } if (!file_util::Delete(extension_root_.Append(path), false)) { // Error removing old image file. ReportFailure( ERROR_REMOVING_OLD_IMAGE_FILE, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_INSTALL_ERROR, ASCIIToUTF16("ERROR_REMOVING_OLD_IMAGE_FILE"))); return false; } } // Write our parsed images back to disk as well. for (size_t i = 0; i < images.size(); ++i) { const SkBitmap& image = images[i].a; FilePath path_suffix = images[i].b; if (path_suffix.IsAbsolute() || path_suffix.ReferencesParent()) { // Invalid path for bitmap image. ReportFailure( INVALID_PATH_FOR_BITMAP_IMAGE, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_INSTALL_ERROR, ASCIIToUTF16("INVALID_PATH_FOR_BITMAP_IMAGE"))); return false; } FilePath path = extension_root_.Append(path_suffix); std::vector<unsigned char> image_data; // TODO(mpcomplete): It's lame that we're encoding all images as PNG, even // though they may originally be .jpg, etc. Figure something out. // http://code.google.com/p/chromium/issues/detail?id=12459 if (!gfx::PNGCodec::EncodeBGRASkBitmap(image, false, &image_data)) { // Error re-encoding theme image. ReportFailure( ERROR_RE_ENCODING_THEME_IMAGE, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_INSTALL_ERROR, ASCIIToUTF16("ERROR_RE_ENCODING_THEME_IMAGE"))); return false; } // Note: we're overwriting existing files that the utility process wrote, // so we can be sure the directory exists. const char* image_data_ptr = reinterpret_cast<const char*>(&image_data[0]); if (!file_util::WriteFile(path, image_data_ptr, image_data.size())) { // Error saving theme image. ReportFailure( ERROR_SAVING_THEME_IMAGE, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_INSTALL_ERROR, ASCIIToUTF16("ERROR_SAVING_THEME_IMAGE"))); return false; } } return true; } bool SandboxedUnpacker::RewriteCatalogFiles() { DictionaryValue catalogs; if (!Unpacker::ReadMessageCatalogsFromFile(temp_dir_.path(), &catalogs)) { // Could not read catalog data from disk. ReportFailure( COULD_NOT_READ_CATALOG_DATA_FROM_DISK, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_INSTALL_ERROR, ASCIIToUTF16("COULD_NOT_READ_CATALOG_DATA_FROM_DISK"))); return false; } // Write our parsed catalogs back to disk. for (DictionaryValue::key_iterator key_it = catalogs.begin_keys(); key_it != catalogs.end_keys(); ++key_it) { DictionaryValue* catalog; if (!catalogs.GetDictionaryWithoutPathExpansion(*key_it, &catalog)) { // Invalid catalog data. ReportFailure( INVALID_CATALOG_DATA, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_INSTALL_ERROR, ASCIIToUTF16("INVALID_CATALOG_DATA"))); return false; } // TODO(viettrungluu): Fix the |FilePath::FromWStringHack(UTF8ToWide())| // hack and remove the corresponding #include. FilePath relative_path = FilePath::FromWStringHack(UTF8ToWide(*key_it)); relative_path = relative_path.Append(Extension::kMessagesFilename); if (relative_path.IsAbsolute() || relative_path.ReferencesParent()) { // Invalid path for catalog. ReportFailure( INVALID_PATH_FOR_CATALOG, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_INSTALL_ERROR, ASCIIToUTF16("INVALID_PATH_FOR_CATALOG"))); return false; } FilePath path = extension_root_.Append(relative_path); std::string catalog_json; JSONStringValueSerializer serializer(&catalog_json); serializer.set_pretty_print(true); if (!serializer.Serialize(*catalog)) { // Error serializing catalog. ReportFailure( ERROR_SERIALIZING_CATALOG, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_INSTALL_ERROR, ASCIIToUTF16("ERROR_SERIALIZING_CATALOG"))); return false; } // Note: we're overwriting existing files that the utility process read, // so we can be sure the directory exists. if (!file_util::WriteFile(path, catalog_json.c_str(), catalog_json.size())) { // Error saving catalog. ReportFailure( ERROR_SAVING_CATALOG, l10n_util::GetStringFUTF16( IDS_EXTENSION_PACKAGE_INSTALL_ERROR, ASCIIToUTF16("ERROR_SAVING_CATALOG"))); return false; } } return true; } } // namespace extensions
; ; Close a file by the BASIC driver ; NOTE: We don't set a drive number, here ; ; Stefano - 5/7/2006 ; ; int close(int handle) ; ; $Id: close.asm,v 1.4 2007/06/28 20:16:20 stefano Exp $ XLIB close LIB zxhandl LIB zx_setint LIB zx_goto ; BASIC variable names for numeric values .svar defb 'S',0 .close pop hl pop bc push bc push hl ld a,c cp 3 jr z,islpt ld hl,svar push hl ; BASIC variable S push bc ; file handle (stream #) call zx_setint pop de pop hl ld hl,zxhandl xor a add hl,de ld (hl),a ; free flag for handle ; note: here we could prevent the "special" ; stream numbers from being closed ld hl,7550 ; BASIC routine for "close" .goto_basic call zx_goto ld hl,0 ret ; If we had stream #3 then jump here.. it is a printer device .islpt ld bc,7750 ; BASIC routine for "close printer device" jr goto_basic
/* UniformFairKernelSize.cpp Li-Yi Wei 06/09/2009 */ #include "UniformFairKernelSize.hpp" #include "Math.hpp" UniformFairKernelSize::UniformFairKernelSize(const vector<float> & domain_size, const vector<int> & num_samples_per_class) : UniformKernelSize(domain_size, num_samples_per_class) { // nothing else to do } float UniformFairKernelSize::GetSize(const Sample & sample, const vector<int> & source_classes) const { if(source_classes.size() != _num_samples.size()) { return 0; } int partial_sum = 0; for(unsigned int i = 0; i < source_classes.size(); i++) { partial_sum += (source_classes[i] > 0)*_num_samples[i]; } return (partial_sum > 0 ? Math::ComputeMaxMinDistance(_domain_size.size(), partial_sum/_domain_volume)*0.5 : 0); // return (partial_sum > 0 ? Math::HyperSphereRadius(_domain_size.size(), _domain_volume/partial_sum) : 0); } float UniformFairKernelSize::GetSize(const Sample & sample, const int class_id0, const int class_id1) const { int partial_sum = 0; if((0 <= class_id0) && (class_id0 < _num_samples.size())) { partial_sum += _num_samples[class_id0]; } if((0 <= class_id1) && (class_id1 < _num_samples.size()) && (class_id1 != class_id0)) { partial_sum += _num_samples[class_id1]; } return (partial_sum > 0 ? Math::ComputeMaxMinDistance(_domain_size.size(), partial_sum/_domain_volume)*0.5 : 0); }
/* This file contains the interrupt table for the ADSP-21020 */ /* When the C program exits either by returning from main() or by an */ /* explicit or implicit call to exit(), control will transfer to the */ /* label ___lib_prog_term. Currently, the ___lib_prog_term label is */ /* defined at the end of the reset vector as an IDLE instruction. */ /* If your application needs to perform some operation AFTER the C */ /* program has finished executing, remove the ___lib_prog_term label */ /* from the runtime header, and place it at the beginning of your */ /* code. */ .GLOBAL ___lib_prog_term; /*Termination address */ .SEGMENT/PM seg_rth; /*Runtime header segment*/ NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP; /*Reserved interrupt */ ___lib_RSTI: CALL ___lib_setup_hardware; /*Reset Interrupt */ CALL ___lib_setup_processor; CALL ___lib_setup_environment; JUMP _main (DB); /*Begin user progam */ NOP;NOP; ___lib_prog_term: IDLE; JUMP ___lib_prog_term; /*Stay at idle */ NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP; /*Reserved interrupt */ /* Interrupt vector for status stack/loop stack overflow or PC stack full: */ ___lib_SOVFI: JUMP ___lib_int_cntrl (DB); /*Jump to dispatcher */ BIT CLR MODE1 0x1000; /*Disable interrupts */ BIT SET MODE2 0x00080000; /*Freeze cache */ NOP;NOP;NOP;NOP;NOP; /*Pad to next vector */ /* Interrupt vector for high priority timer interrupt: */ ___lib_TMZOI: JUMP ___lib_int_cntrl (DB); /*Jump to dispatcher */ BIT CLR MODE1 0x1000; /*Disable interrupts */ BIT SET MODE2 0x00080000; /*Freeze cache */ NOP;NOP;NOP;NOP;NOP; /*Pad to next vector */ /* Interrupt vector for external interrupts:*/ .global ___lib_IRQ3I; ___lib_IRQ3I: idle; BIT CLR MODE1 0x1000; /*Disable interrupts */ nop; /* BIT SET MODE2 0x00080000; Freeze cache */ NOP;NOP;NOP;NOP;NOP; /*Pad to next vector */ ___lib_IRQ2I: JUMP ___lib_int_cntrl (DB); /*Jump to dispatcher */ BIT CLR MODE1 0x1000; /*Disable interrupts */ BIT SET MODE2 0x00080000; /*Freeze cache */ NOP;NOP;NOP;NOP;NOP; /*Pad to next vector */ ___lib_IRQ1I: JUMP ___lib_int_cntrl (DB); /*Jump to dispatcher */ BIT CLR MODE1 0x1000; /*Disable interrupts */ BIT SET MODE2 0x00080000; /*Freeze cache */ NOP;NOP;NOP;NOP;NOP; /*Pad to next vector */ ___lib_IRQ0I: JUMP ___lib_int_cntrl (DB); /*Jump to dispatcher */ BIT CLR MODE1 0x1000; /*Disable interrupts */ BIT SET MODE2 0x00080000; /*Freeze cache */ NOP;NOP;NOP;NOP;NOP; /*Pad to next vector */ NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP; /*Reserved interrupt */ NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP; /*Reserved interrupt */ /* Interrupt vector for DAG1 buffer 7 circular buffer overflow */ ___lib_CB7I: JUMP ___lib_int_cntrl (DB); /*Jump to dispatcher */ BIT CLR MODE1 0x1000; /*Disable interrupts */ BIT SET MODE2 0x00080000; /*Freeze cache */ NOP;NOP;NOP;NOP;NOP; /*Pad to next vector */ /* Interrupt vector for DAG2 buffer 15 circular buffer overflow */ ___lib_CB15I: JUMP ___lib_int_cntrl (DB); /*Jump to dispatcher */ BIT CLR MODE1 0x1000; /*Disable interrupts */ BIT SET MODE2 0x00080000; /*Freeze cache */ NOP;NOP;NOP;NOP;NOP; /*Pad to next vector */ NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP; /*Reserved interrupt */ /* Interrupt vector for lower priority timer interrupt */ ___lib_TMZI: JUMP ___lib_int_cntrl (DB); /*Jump to dispatcher */ BIT CLR MODE1 0x1000; /*Disable interrupts */ BIT SET MODE2 0x00080000; /*Freeze cache */ NOP;NOP;NOP;NOP;NOP; /*Pad to next vector */ /* Interrupt vector for fixed point overflow interrupt */ ___lib_FIXI: JUMP ___lib_int_cntrl (DB); /*Jump to dispatcher */ BIT CLR MODE1 0x1000; /*Disable interrupts */ BIT SET MODE2 0x00080000; /*Freeze cache */ NOP;NOP;NOP;NOP;NOP; /*Pad to next vector */ /* Interrupt vector for floating point overflow interrupt */ ___lib_FLTOI: JUMP ___lib_int_cntrl (DB); /*Jump to dispatcher */ BIT CLR MODE1 0x1000; /*Disable interrupts */ BIT SET MODE2 0x00080000; /*Freeze cache */ NOP;NOP;NOP;NOP;NOP; /*Pad to next vector */ /* Interrupt vector for floating point underflow interrupt */ ___lib_FLTUI: JUMP ___lib_int_cntrl (DB); /*Jump to dispatcher */ BIT CLR MODE1 0x1000; /*Disable interrupts */ BIT SET MODE2 0x00080000; /*Freeze cache */ NOP;NOP;NOP;NOP;NOP; /*Pad to next vector */ /* Interrupt vector for floating point invalid operation interrupt */ ___lib_FLTII: JUMP ___lib_int_cntrl (DB); /*Jump to dispatcher */ BIT CLR MODE1 0x1000; /*Disable interrupts */ BIT SET MODE2 0x00080000; /*Freeze cache */ NOP;NOP;NOP;NOP;NOP; /*Pad to next vector */ NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP; /*Reserved interrupt */ NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP; /*Reserved interrupt */ NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP; /*Reserved interrupt */ NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP; /*Reserved interrupt */ NOP;NOP;NOP;NOP;NOP;NOP;NOP;NOP; /*Reserved interrupt */ /* Interrupt vectors for user interrupts 0 - 7 */ ___lib_USR0I: JUMP ___lib_int_cntrl (DB); /*Jump to dispatcher */ BIT CLR MODE1 0x1000; /*Disable interrupts */ nop; /* DO NOT Freeze cache */ NOP;NOP;NOP;NOP;NOP; /*Pad to next vector */ ___lib_USR1I: JUMP ___lib_int_cntrl (DB); /*Jump to dispatcher */ BIT CLR MODE1 0x1000; /*Disable interrupts */ BIT SET MODE2 0x00080000; /*Freeze cache */ NOP;NOP;NOP;NOP;NOP; /*Pad to next vector */ ___lib_USR2I: JUMP ___lib_int_cntrl (DB); /*Jump to dispatcher */ BIT CLR MODE1 0x1000; /*Disable interrupts */ BIT SET MODE2 0x00080000; /*Freeze cache */ NOP;NOP;NOP;NOP;NOP; /*Pad to next vector */ ___lib_USR3I: JUMP ___lib_int_cntrl (DB); /*Jump to dispatcher */ BIT CLR MODE1 0x1000; /*Disable interrupts */ BIT SET MODE2 0x00080000; /*Freeze cache */ NOP;NOP;NOP;NOP;NOP; /*Pad to next vector */ ___lib_USR4I: JUMP ___lib_int_cntrl (DB); /*Jump to dispatcher */ BIT CLR MODE1 0x1000; /*Disable interrupts */ BIT SET MODE2 0x00080000; /*Freeze cache */ NOP;NOP;NOP;NOP;NOP; /*Pad to next vector */ ___lib_USR5I: JUMP ___lib_int_cntrl (DB); /*Jump to dispatcher */ BIT CLR MODE1 0x1000; /*Disable interrupts */ BIT SET MODE2 0x00080000; /*Freeze cache */ NOP;NOP;NOP;NOP;NOP; /*Pad to next vector */ ___lib_USR6I: JUMP ___lib_int_cntrl (DB); /*Jump to dispatcher */ BIT CLR MODE1 0x1000; /*Disable interrupts */ BIT SET MODE2 0x00080000; /*Freeze cache */ NOP;NOP;NOP;NOP;NOP; /*Pad to next vector */ ___lib_USR7I: JUMP ___lib_int_cntrl (DB); /*Jump to dispatcher */ BIT CLR MODE1 0x1000; /*Disable interrupts */ BIT SET MODE2 0x00080000; /*Freeze cache */ NOP;NOP;NOP;NOP;NOP; /*Pad to next vector */ .ENDSEG;
#include "dot_cython_omp_.h" #ifdef USE_OPENMP #include "omp.h" #endif int get_omp_max_threads_cpp() { #ifdef USE_OPENMP return ::omp_get_max_threads(); #else return 0; #endif } double vector_ddot_openmp(const double *p1, const double *p2, int size, int nthreads) { if (nthreads <= 0) nthreads = ::omp_get_max_threads(); double sum = 0; #ifdef USE_OPENMP #pragma omp parallel for reduction(+ : sum) num_threads(nthreads) #endif for (int i = 0; i < size; ++i) sum += (p1[i] * p2[i]); return sum; } double vector_ddot_product_pointer16(const double *p1, const double *p2) { // Branching optimization must be done in a separate function. double sum = 0; sum += *(p1++) * *(p2++); sum += *(p1++) * *(p2++); sum += *(p1++) * *(p2++); sum += *(p1++) * *(p2++); sum += *(p1++) * *(p2++); sum += *(p1++) * *(p2++); sum += *(p1++) * *(p2++); sum += *(p1++) * *(p2++); sum += *(p1++) * *(p2++); sum += *(p1++) * *(p2++); sum += *(p1++) * *(p2++); sum += *(p1++) * *(p2++); sum += *(p1++) * *(p2++); sum += *(p1++) * *(p2++); sum += *(p1++) * *(p2++); sum += *(p1++) * *(p2++); return sum; } double vector_ddot_openmp_16(const double *p1, const double *p2, int size, int nthreads) { if (nthreads <= 0) nthreads = ::omp_get_max_threads(); double sum = 0; if (size >= 16) { int size_ = size / 16; #ifdef USE_OPENMP #pragma omp parallel for reduction(+ : sum) num_threads(nthreads) #endif for(int i=0; i < size_; ++i) sum += vector_ddot_product_pointer16(&p1[i*16], &p2[i*16]); } int mod = size % 16; size -= mod; p1 += size; p2 += size; for(; mod > 0; ++p1, ++p2, --mod) sum += *p1 * *p2; return sum; }
; Perform BCD subtraction on two 32-bit numbers. ; 45218907H - 37829156H .MODEL TINY .486 .CODE .STARTUP ; initialize registers MOV EBX, 37829156H ; BH = 91H BL = 56H MOV EDX, 45218907H ; DH = 89H DL = 07H ; perform SUBtraction SUB DL, BL ; DL = 07H - 56H = B1H ; perform Decimal Adjust after Subtraction MOV AL, DL ; AL = B1H DAS ; AL = 51H C = 1 ; store result in ECX(CL) MOV CL, AL ; CL = 51H ECX = 00000051H ; perform SuBtraction with Borrow SBB DH, BH ; DH = 89H - 91H - 1 = F7H C = 1 ; perform Decimal Adjust after Subtraction MOV AL, DH ; AL = F7H DAS ; AL = 97H C = 1 ; store result in ECX(CH) MOV CH, AL ; CH = 97H ECX = 00009751H ; swap EBX, EDX, ECX to perform calculation on higher bits BSWAP EBX ; EBX = 56918237H BH = 82H BL = 37H BSWAP EDX ; EDX = B1F72145H DH = 21H DL = 45H BSWAP ECX ; ECX = 51970000H ; perform SuBtraction with Borrow SBB DH, BH ; DH = 21H - 82H - 1 = 9EH C = 1 ; perform Decimal Adjust after Subtraction MOV AL, DH ; AL = 9EH DAS ; AL = (9|3)8H C = 1 ; store result in ECX(CH) MOV CH, AL ; CH = (9|3)8H ECX = 5197(9|3)800H ; perform SuBtraction with Borrow SBB DL, BL ; DL = 45H - 37H - 1 = 0DH C = 0 ; perform Decimal Adjust after Subtraction MOV AL, DL ; AL = 0DH DAS ; AL = 07H C = 0 ; store result in ECX(CL) MOV CL, AL ; CL = 07H ECX = 5197(9|3)807H ; swap ECX to get final result BSWAP ECX ; ECX = 07(9|3)89751H .EXIT END
; A051462: Molien series for group G_{1,2}^{8} of order 1536. ; 1,4,11,25,48,83,133,200,287,397,532,695,889,1116,1379,1681,2024,2411,2845,3328,3863,4453,5100,5807,6577,7412,8315,9289,10336,11459,12661,13944,15311,16765,18308,19943,21673,23500,25427,27457,29592,31835,34189,36656,39239,41941,44764,47711,50785,53988,57323,60793,64400,68147,72037,76072,80255,84589,89076,93719,98521,103484,108611,113905,119368,125003,130813,136800,142967,149317,155852,162575,169489,176596,183899,191401,199104,207011,215125,223448,231983,240733,249700,258887,268297,277932,287795,297889,308216,318779,329581,340624,351911,363445,375228,387263,399553,412100,424907,437977,451312,464915,478789,492936,507359,522061,537044,552311,567865,583708,599843,616273,633000,650027,667357,684992,702935,721189,739756,758639,777841,797364,817211,837385,857888,878723,899893,921400,943247,965437,987972,1010855,1034089,1057676,1081619,1105921,1130584,1155611,1181005,1206768,1232903,1259413,1286300,1313567,1341217,1369252,1397675,1426489,1455696,1485299,1515301,1545704,1576511,1607725,1639348,1671383,1703833,1736700,1769987,1803697,1837832,1872395,1907389,1942816,1978679,2014981,2051724,2088911,2126545,2164628,2203163,2242153,2281600,2321507,2361877,2402712,2444015,2485789,2528036,2570759,2613961,2657644,2701811,2746465,2791608,2837243,2883373,2930000,2977127,3024757,3072892,3121535,3170689,3220356,3270539,3321241,3372464,3424211,3476485,3529288,3582623,3636493,3690900,3745847,3801337,3857372,3913955,3971089,4028776,4087019,4145821,4205184,4265111,4325605,4386668,4448303,4510513,4573300,4636667,4700617,4765152,4830275,4895989,4962296,5029199,5096701,5164804,5233511,5302825,5372748,5443283,5514433,5586200,5658587,5731597,5805232,5879495,5954389,6029916,6106079,6182881,6260324,6338411,6417145,6496528,6576563,6657253,6738600,6820607,6903277 mov $4,$0 mul $0,2 mov $3,$0 lpb $3,1 mov $2,$3 lpb $2,1 sub $2,1 add $1,$2 lpe sub $3,3 lpe lpb $4,1 add $1,2 sub $4,1 lpe add $1,1
_grep: file format elf32-i386 Disassembly of section .text: 00000000 <main>: } } int main(int argc, char *argv[]) { 0: 8d 4c 24 04 lea 0x4(%esp),%ecx 4: 83 e4 f0 and $0xfffffff0,%esp 7: ff 71 fc pushl -0x4(%ecx) a: 55 push %ebp b: 89 e5 mov %esp,%ebp d: 57 push %edi e: 56 push %esi f: 53 push %ebx 10: 51 push %ecx 11: 83 ec 18 sub $0x18,%esp 14: 8b 39 mov (%ecx),%edi 16: 8b 59 04 mov 0x4(%ecx),%ebx int fd, i; char *pattern; if(argc <= 1){ 19: 83 ff 01 cmp $0x1,%edi 1c: 7e 7c jle 9a <main+0x9a> printf(2, "usage: grep pattern [file ...]\n"); exit(); } pattern = argv[1]; 1e: 8b 43 04 mov 0x4(%ebx),%eax 21: 83 c3 08 add $0x8,%ebx if(argc <= 2){ 24: 83 ff 02 cmp $0x2,%edi grep(pattern, 0); exit(); } for(i = 2; i < argc; i++){ 27: be 02 00 00 00 mov $0x2,%esi pattern = argv[1]; 2c: 89 45 e0 mov %eax,-0x20(%ebp) if(argc <= 2){ 2f: 74 46 je 77 <main+0x77> 31: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if((fd = open(argv[i], 0)) < 0){ 38: 83 ec 08 sub $0x8,%esp 3b: 6a 00 push $0x0 3d: ff 33 pushl (%ebx) 3f: e8 7e 05 00 00 call 5c2 <open> 44: 83 c4 10 add $0x10,%esp 47: 85 c0 test %eax,%eax 49: 78 3b js 86 <main+0x86> printf(1, "grep: cannot open %s\n", argv[i]); exit(); } grep(pattern, fd); 4b: 83 ec 08 sub $0x8,%esp 4e: 89 45 e4 mov %eax,-0x1c(%ebp) for(i = 2; i < argc; i++){ 51: 83 c6 01 add $0x1,%esi grep(pattern, fd); 54: 50 push %eax 55: ff 75 e0 pushl -0x20(%ebp) 58: 83 c3 04 add $0x4,%ebx 5b: e8 d0 01 00 00 call 230 <grep> close(fd); 60: 8b 45 e4 mov -0x1c(%ebp),%eax 63: 89 04 24 mov %eax,(%esp) 66: e8 3f 05 00 00 call 5aa <close> for(i = 2; i < argc; i++){ 6b: 83 c4 10 add $0x10,%esp 6e: 39 f7 cmp %esi,%edi 70: 7f c6 jg 38 <main+0x38> } exit(); 72: e8 0b 05 00 00 call 582 <exit> grep(pattern, 0); 77: 52 push %edx 78: 52 push %edx 79: 6a 00 push $0x0 7b: 50 push %eax 7c: e8 af 01 00 00 call 230 <grep> exit(); 81: e8 fc 04 00 00 call 582 <exit> printf(1, "grep: cannot open %s\n", argv[i]); 86: 50 push %eax 87: ff 33 pushl (%ebx) 89: 68 48 0a 00 00 push $0xa48 8e: 6a 01 push $0x1 90: e8 3b 06 00 00 call 6d0 <printf> exit(); 95: e8 e8 04 00 00 call 582 <exit> printf(2, "usage: grep pattern [file ...]\n"); 9a: 51 push %ecx 9b: 51 push %ecx 9c: 68 28 0a 00 00 push $0xa28 a1: 6a 02 push $0x2 a3: e8 28 06 00 00 call 6d0 <printf> exit(); a8: e8 d5 04 00 00 call 582 <exit> ad: 66 90 xchg %ax,%ax af: 90 nop 000000b0 <matchstar>: return 0; } // matchstar: search for c*re at beginning of text int matchstar(int c, char *re, char *text) { b0: 55 push %ebp b1: 89 e5 mov %esp,%ebp b3: 57 push %edi b4: 56 push %esi b5: 53 push %ebx b6: 83 ec 0c sub $0xc,%esp b9: 8b 5d 08 mov 0x8(%ebp),%ebx bc: 8b 75 0c mov 0xc(%ebp),%esi bf: 8b 7d 10 mov 0x10(%ebp),%edi c2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi do{ // a * matches zero or more instances if(matchhere(re, text)) c8: 83 ec 08 sub $0x8,%esp cb: 57 push %edi cc: 56 push %esi cd: e8 3e 00 00 00 call 110 <matchhere> d2: 83 c4 10 add $0x10,%esp d5: 85 c0 test %eax,%eax d7: 75 1f jne f8 <matchstar+0x48> return 1; }while(*text!='\0' && (*text++==c || c=='.')); d9: 0f be 17 movsbl (%edi),%edx dc: 84 d2 test %dl,%dl de: 74 0c je ec <matchstar+0x3c> e0: 83 c7 01 add $0x1,%edi e3: 39 da cmp %ebx,%edx e5: 74 e1 je c8 <matchstar+0x18> e7: 83 fb 2e cmp $0x2e,%ebx ea: 74 dc je c8 <matchstar+0x18> return 0; } ec: 8d 65 f4 lea -0xc(%ebp),%esp ef: 5b pop %ebx f0: 5e pop %esi f1: 5f pop %edi f2: 5d pop %ebp f3: c3 ret f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi f8: 8d 65 f4 lea -0xc(%ebp),%esp return 1; fb: b8 01 00 00 00 mov $0x1,%eax } 100: 5b pop %ebx 101: 5e pop %esi 102: 5f pop %edi 103: 5d pop %ebp 104: c3 ret 105: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 109: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000110 <matchhere>: { 110: 55 push %ebp 111: 89 e5 mov %esp,%ebp 113: 57 push %edi 114: 56 push %esi 115: 53 push %ebx 116: 83 ec 0c sub $0xc,%esp if(re[0] == '\0') 119: 8b 45 08 mov 0x8(%ebp),%eax { 11c: 8b 7d 0c mov 0xc(%ebp),%edi if(re[0] == '\0') 11f: 0f b6 08 movzbl (%eax),%ecx 122: 84 c9 test %cl,%cl 124: 74 67 je 18d <matchhere+0x7d> if(re[1] == '*') 126: 0f be 40 01 movsbl 0x1(%eax),%eax 12a: 3c 2a cmp $0x2a,%al 12c: 74 6c je 19a <matchhere+0x8a> if(re[0] == '$' && re[1] == '\0') 12e: 80 f9 24 cmp $0x24,%cl 131: 0f b6 1f movzbl (%edi),%ebx 134: 75 08 jne 13e <matchhere+0x2e> 136: 84 c0 test %al,%al 138: 0f 84 81 00 00 00 je 1bf <matchhere+0xaf> if(*text!='\0' && (re[0]=='.' || re[0]==*text)) 13e: 84 db test %bl,%bl 140: 74 09 je 14b <matchhere+0x3b> 142: 38 d9 cmp %bl,%cl 144: 74 3c je 182 <matchhere+0x72> 146: 80 f9 2e cmp $0x2e,%cl 149: 74 37 je 182 <matchhere+0x72> } 14b: 8d 65 f4 lea -0xc(%ebp),%esp return 0; 14e: 31 c0 xor %eax,%eax } 150: 5b pop %ebx 151: 5e pop %esi 152: 5f pop %edi 153: 5d pop %ebp 154: c3 ret 155: 8d 76 00 lea 0x0(%esi),%esi if(re[1] == '*') 158: 8b 75 08 mov 0x8(%ebp),%esi 15b: 0f b6 4e 01 movzbl 0x1(%esi),%ecx 15f: 80 f9 2a cmp $0x2a,%cl 162: 74 3b je 19f <matchhere+0x8f> if(re[0] == '$' && re[1] == '\0') 164: 3c 24 cmp $0x24,%al 166: 75 04 jne 16c <matchhere+0x5c> 168: 84 c9 test %cl,%cl 16a: 74 4f je 1bb <matchhere+0xab> if(*text!='\0' && (re[0]=='.' || re[0]==*text)) 16c: 0f b6 33 movzbl (%ebx),%esi 16f: 89 f2 mov %esi,%edx 171: 84 d2 test %dl,%dl 173: 74 d6 je 14b <matchhere+0x3b> 175: 3c 2e cmp $0x2e,%al 177: 89 df mov %ebx,%edi 179: 74 04 je 17f <matchhere+0x6f> 17b: 38 c2 cmp %al,%dl 17d: 75 cc jne 14b <matchhere+0x3b> 17f: 0f be c1 movsbl %cl,%eax return matchhere(re+1, text+1); 182: 83 45 08 01 addl $0x1,0x8(%ebp) if(re[0] == '\0') 186: 84 c0 test %al,%al return matchhere(re+1, text+1); 188: 8d 5f 01 lea 0x1(%edi),%ebx if(re[0] == '\0') 18b: 75 cb jne 158 <matchhere+0x48> return 1; 18d: b8 01 00 00 00 mov $0x1,%eax } 192: 8d 65 f4 lea -0xc(%ebp),%esp 195: 5b pop %ebx 196: 5e pop %esi 197: 5f pop %edi 198: 5d pop %ebp 199: c3 ret if(re[1] == '*') 19a: 89 fb mov %edi,%ebx 19c: 0f be c1 movsbl %cl,%eax return matchstar(re[0], re+2, text); 19f: 8b 7d 08 mov 0x8(%ebp),%edi 1a2: 83 ec 04 sub $0x4,%esp 1a5: 53 push %ebx 1a6: 8d 57 02 lea 0x2(%edi),%edx 1a9: 52 push %edx 1aa: 50 push %eax 1ab: e8 00 ff ff ff call b0 <matchstar> 1b0: 83 c4 10 add $0x10,%esp } 1b3: 8d 65 f4 lea -0xc(%ebp),%esp 1b6: 5b pop %ebx 1b7: 5e pop %esi 1b8: 5f pop %edi 1b9: 5d pop %ebp 1ba: c3 ret 1bb: 0f b6 5f 01 movzbl 0x1(%edi),%ebx return *text == '\0'; 1bf: 31 c0 xor %eax,%eax 1c1: 84 db test %bl,%bl 1c3: 0f 94 c0 sete %al 1c6: eb ca jmp 192 <matchhere+0x82> 1c8: 90 nop 1c9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 000001d0 <match>: { 1d0: 55 push %ebp 1d1: 89 e5 mov %esp,%ebp 1d3: 56 push %esi 1d4: 53 push %ebx 1d5: 8b 75 08 mov 0x8(%ebp),%esi 1d8: 8b 5d 0c mov 0xc(%ebp),%ebx if(re[0] == '^') 1db: 80 3e 5e cmpb $0x5e,(%esi) 1de: 75 11 jne 1f1 <match+0x21> 1e0: eb 2e jmp 210 <match+0x40> 1e2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi }while(*text++ != '\0'); 1e8: 83 c3 01 add $0x1,%ebx 1eb: 80 7b ff 00 cmpb $0x0,-0x1(%ebx) 1ef: 74 16 je 207 <match+0x37> if(matchhere(re, text)) 1f1: 83 ec 08 sub $0x8,%esp 1f4: 53 push %ebx 1f5: 56 push %esi 1f6: e8 15 ff ff ff call 110 <matchhere> 1fb: 83 c4 10 add $0x10,%esp 1fe: 85 c0 test %eax,%eax 200: 74 e6 je 1e8 <match+0x18> return 1; 202: b8 01 00 00 00 mov $0x1,%eax } 207: 8d 65 f8 lea -0x8(%ebp),%esp 20a: 5b pop %ebx 20b: 5e pop %esi 20c: 5d pop %ebp 20d: c3 ret 20e: 66 90 xchg %ax,%ax return matchhere(re+1, text); 210: 83 c6 01 add $0x1,%esi 213: 89 75 08 mov %esi,0x8(%ebp) } 216: 8d 65 f8 lea -0x8(%ebp),%esp 219: 5b pop %ebx 21a: 5e pop %esi 21b: 5d pop %ebp return matchhere(re+1, text); 21c: e9 ef fe ff ff jmp 110 <matchhere> 221: eb 0d jmp 230 <grep> 223: 90 nop 224: 90 nop 225: 90 nop 226: 90 nop 227: 90 nop 228: 90 nop 229: 90 nop 22a: 90 nop 22b: 90 nop 22c: 90 nop 22d: 90 nop 22e: 90 nop 22f: 90 nop 00000230 <grep>: { 230: 55 push %ebp 231: 89 e5 mov %esp,%ebp 233: 57 push %edi 234: 56 push %esi 235: 53 push %ebx m = 0; 236: 31 f6 xor %esi,%esi { 238: 83 ec 1c sub $0x1c,%esp 23b: 90 nop 23c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi while((n = read(fd, buf+m, sizeof(buf)-m-1)) > 0){ 240: b8 ff 03 00 00 mov $0x3ff,%eax 245: 83 ec 04 sub $0x4,%esp 248: 29 f0 sub %esi,%eax 24a: 50 push %eax 24b: 8d 86 20 0e 00 00 lea 0xe20(%esi),%eax 251: 50 push %eax 252: ff 75 0c pushl 0xc(%ebp) 255: e8 40 03 00 00 call 59a <read> 25a: 83 c4 10 add $0x10,%esp 25d: 85 c0 test %eax,%eax 25f: 0f 8e bb 00 00 00 jle 320 <grep+0xf0> m += n; 265: 01 c6 add %eax,%esi p = buf; 267: bb 20 0e 00 00 mov $0xe20,%ebx buf[m] = '\0'; 26c: c6 86 20 0e 00 00 00 movb $0x0,0xe20(%esi) 273: 89 75 e4 mov %esi,-0x1c(%ebp) 276: 8d 76 00 lea 0x0(%esi),%esi 279: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi while((q = strchr(p, '\n')) != 0){ 280: 83 ec 08 sub $0x8,%esp 283: 6a 0a push $0xa 285: 53 push %ebx 286: e8 75 01 00 00 call 400 <strchr> 28b: 83 c4 10 add $0x10,%esp 28e: 85 c0 test %eax,%eax 290: 89 c6 mov %eax,%esi 292: 74 44 je 2d8 <grep+0xa8> if(match(pattern, p)){ 294: 83 ec 08 sub $0x8,%esp *q = 0; 297: c6 06 00 movb $0x0,(%esi) 29a: 8d 7e 01 lea 0x1(%esi),%edi if(match(pattern, p)){ 29d: 53 push %ebx 29e: ff 75 08 pushl 0x8(%ebp) 2a1: e8 2a ff ff ff call 1d0 <match> 2a6: 83 c4 10 add $0x10,%esp 2a9: 85 c0 test %eax,%eax 2ab: 75 0b jne 2b8 <grep+0x88> p = q+1; 2ad: 89 fb mov %edi,%ebx 2af: eb cf jmp 280 <grep+0x50> 2b1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi write(1, p, q+1 - p); 2b8: 89 f8 mov %edi,%eax 2ba: 83 ec 04 sub $0x4,%esp *q = '\n'; 2bd: c6 06 0a movb $0xa,(%esi) write(1, p, q+1 - p); 2c0: 29 d8 sub %ebx,%eax 2c2: 50 push %eax 2c3: 53 push %ebx p = q+1; 2c4: 89 fb mov %edi,%ebx write(1, p, q+1 - p); 2c6: 6a 01 push $0x1 2c8: e8 d5 02 00 00 call 5a2 <write> 2cd: 83 c4 10 add $0x10,%esp 2d0: eb ae jmp 280 <grep+0x50> 2d2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(p == buf) 2d8: 81 fb 20 0e 00 00 cmp $0xe20,%ebx 2de: 8b 75 e4 mov -0x1c(%ebp),%esi 2e1: 74 2d je 310 <grep+0xe0> if(m > 0){ 2e3: 85 f6 test %esi,%esi 2e5: 0f 8e 55 ff ff ff jle 240 <grep+0x10> m -= p - buf; 2eb: 89 d8 mov %ebx,%eax memmove(buf, p, m); 2ed: 83 ec 04 sub $0x4,%esp m -= p - buf; 2f0: 2d 20 0e 00 00 sub $0xe20,%eax 2f5: 29 c6 sub %eax,%esi memmove(buf, p, m); 2f7: 56 push %esi 2f8: 53 push %ebx 2f9: 68 20 0e 00 00 push $0xe20 2fe: e8 4d 02 00 00 call 550 <memmove> 303: 83 c4 10 add $0x10,%esp 306: e9 35 ff ff ff jmp 240 <grep+0x10> 30b: 90 nop 30c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi m = 0; 310: 31 f6 xor %esi,%esi 312: e9 29 ff ff ff jmp 240 <grep+0x10> 317: 89 f6 mov %esi,%esi 319: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi } 320: 8d 65 f4 lea -0xc(%ebp),%esp 323: 5b pop %ebx 324: 5e pop %esi 325: 5f pop %edi 326: 5d pop %ebp 327: c3 ret 328: 66 90 xchg %ax,%ax 32a: 66 90 xchg %ax,%ax 32c: 66 90 xchg %ax,%ax 32e: 66 90 xchg %ax,%ax 00000330 <strcpy>: #include "user.h" #include "x86.h" char* strcpy(char *s, const char *t) { 330: 55 push %ebp 331: 89 e5 mov %esp,%ebp 333: 53 push %ebx 334: 8b 45 08 mov 0x8(%ebp),%eax 337: 8b 4d 0c mov 0xc(%ebp),%ecx char *os; os = s; while((*s++ = *t++) != 0) 33a: 89 c2 mov %eax,%edx 33c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 340: 83 c1 01 add $0x1,%ecx 343: 0f b6 59 ff movzbl -0x1(%ecx),%ebx 347: 83 c2 01 add $0x1,%edx 34a: 84 db test %bl,%bl 34c: 88 5a ff mov %bl,-0x1(%edx) 34f: 75 ef jne 340 <strcpy+0x10> ; return os; } 351: 5b pop %ebx 352: 5d pop %ebp 353: c3 ret 354: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 35a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 00000360 <strcmp>: int strcmp(const char *p, const char *q) { 360: 55 push %ebp 361: 89 e5 mov %esp,%ebp 363: 53 push %ebx 364: 8b 55 08 mov 0x8(%ebp),%edx 367: 8b 4d 0c mov 0xc(%ebp),%ecx while(*p && *p == *q) 36a: 0f b6 02 movzbl (%edx),%eax 36d: 0f b6 19 movzbl (%ecx),%ebx 370: 84 c0 test %al,%al 372: 75 1c jne 390 <strcmp+0x30> 374: eb 2a jmp 3a0 <strcmp+0x40> 376: 8d 76 00 lea 0x0(%esi),%esi 379: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi p++, q++; 380: 83 c2 01 add $0x1,%edx while(*p && *p == *q) 383: 0f b6 02 movzbl (%edx),%eax p++, q++; 386: 83 c1 01 add $0x1,%ecx 389: 0f b6 19 movzbl (%ecx),%ebx while(*p && *p == *q) 38c: 84 c0 test %al,%al 38e: 74 10 je 3a0 <strcmp+0x40> 390: 38 d8 cmp %bl,%al 392: 74 ec je 380 <strcmp+0x20> return (uchar)*p - (uchar)*q; 394: 29 d8 sub %ebx,%eax } 396: 5b pop %ebx 397: 5d pop %ebp 398: c3 ret 399: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 3a0: 31 c0 xor %eax,%eax return (uchar)*p - (uchar)*q; 3a2: 29 d8 sub %ebx,%eax } 3a4: 5b pop %ebx 3a5: 5d pop %ebp 3a6: c3 ret 3a7: 89 f6 mov %esi,%esi 3a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000003b0 <strlen>: uint strlen(const char *s) { 3b0: 55 push %ebp 3b1: 89 e5 mov %esp,%ebp 3b3: 8b 4d 08 mov 0x8(%ebp),%ecx int n; for(n = 0; s[n]; n++) 3b6: 80 39 00 cmpb $0x0,(%ecx) 3b9: 74 15 je 3d0 <strlen+0x20> 3bb: 31 d2 xor %edx,%edx 3bd: 8d 76 00 lea 0x0(%esi),%esi 3c0: 83 c2 01 add $0x1,%edx 3c3: 80 3c 11 00 cmpb $0x0,(%ecx,%edx,1) 3c7: 89 d0 mov %edx,%eax 3c9: 75 f5 jne 3c0 <strlen+0x10> ; return n; } 3cb: 5d pop %ebp 3cc: c3 ret 3cd: 8d 76 00 lea 0x0(%esi),%esi for(n = 0; s[n]; n++) 3d0: 31 c0 xor %eax,%eax } 3d2: 5d pop %ebp 3d3: c3 ret 3d4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 3da: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 000003e0 <memset>: void* memset(void *dst, int c, uint n) { 3e0: 55 push %ebp 3e1: 89 e5 mov %esp,%ebp 3e3: 57 push %edi 3e4: 8b 55 08 mov 0x8(%ebp),%edx } static inline void stosb(void *addr, int data, int cnt) { asm volatile("cld; rep stosb" : 3e7: 8b 4d 10 mov 0x10(%ebp),%ecx 3ea: 8b 45 0c mov 0xc(%ebp),%eax 3ed: 89 d7 mov %edx,%edi 3ef: fc cld 3f0: f3 aa rep stos %al,%es:(%edi) stosb(dst, c, n); return dst; } 3f2: 89 d0 mov %edx,%eax 3f4: 5f pop %edi 3f5: 5d pop %ebp 3f6: c3 ret 3f7: 89 f6 mov %esi,%esi 3f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000400 <strchr>: char* strchr(const char *s, char c) { 400: 55 push %ebp 401: 89 e5 mov %esp,%ebp 403: 53 push %ebx 404: 8b 45 08 mov 0x8(%ebp),%eax 407: 8b 5d 0c mov 0xc(%ebp),%ebx for(; *s; s++) 40a: 0f b6 10 movzbl (%eax),%edx 40d: 84 d2 test %dl,%dl 40f: 74 1d je 42e <strchr+0x2e> if(*s == c) 411: 38 d3 cmp %dl,%bl 413: 89 d9 mov %ebx,%ecx 415: 75 0d jne 424 <strchr+0x24> 417: eb 17 jmp 430 <strchr+0x30> 419: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 420: 38 ca cmp %cl,%dl 422: 74 0c je 430 <strchr+0x30> for(; *s; s++) 424: 83 c0 01 add $0x1,%eax 427: 0f b6 10 movzbl (%eax),%edx 42a: 84 d2 test %dl,%dl 42c: 75 f2 jne 420 <strchr+0x20> return (char*)s; return 0; 42e: 31 c0 xor %eax,%eax } 430: 5b pop %ebx 431: 5d pop %ebp 432: c3 ret 433: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 439: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000440 <gets>: char* gets(char *buf, int max) { 440: 55 push %ebp 441: 89 e5 mov %esp,%ebp 443: 57 push %edi 444: 56 push %esi 445: 53 push %ebx int i, cc; char c; for(i=0; i+1 < max; ){ 446: 31 f6 xor %esi,%esi 448: 89 f3 mov %esi,%ebx { 44a: 83 ec 1c sub $0x1c,%esp 44d: 8b 7d 08 mov 0x8(%ebp),%edi for(i=0; i+1 < max; ){ 450: eb 2f jmp 481 <gets+0x41> 452: 8d b6 00 00 00 00 lea 0x0(%esi),%esi cc = read(0, &c, 1); 458: 8d 45 e7 lea -0x19(%ebp),%eax 45b: 83 ec 04 sub $0x4,%esp 45e: 6a 01 push $0x1 460: 50 push %eax 461: 6a 00 push $0x0 463: e8 32 01 00 00 call 59a <read> if(cc < 1) 468: 83 c4 10 add $0x10,%esp 46b: 85 c0 test %eax,%eax 46d: 7e 1c jle 48b <gets+0x4b> break; buf[i++] = c; 46f: 0f b6 45 e7 movzbl -0x19(%ebp),%eax 473: 83 c7 01 add $0x1,%edi 476: 88 47 ff mov %al,-0x1(%edi) if(c == '\n' || c == '\r') 479: 3c 0a cmp $0xa,%al 47b: 74 23 je 4a0 <gets+0x60> 47d: 3c 0d cmp $0xd,%al 47f: 74 1f je 4a0 <gets+0x60> for(i=0; i+1 < max; ){ 481: 83 c3 01 add $0x1,%ebx 484: 3b 5d 0c cmp 0xc(%ebp),%ebx 487: 89 fe mov %edi,%esi 489: 7c cd jl 458 <gets+0x18> 48b: 89 f3 mov %esi,%ebx break; } buf[i] = '\0'; return buf; } 48d: 8b 45 08 mov 0x8(%ebp),%eax buf[i] = '\0'; 490: c6 03 00 movb $0x0,(%ebx) } 493: 8d 65 f4 lea -0xc(%ebp),%esp 496: 5b pop %ebx 497: 5e pop %esi 498: 5f pop %edi 499: 5d pop %ebp 49a: c3 ret 49b: 90 nop 49c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 4a0: 8b 75 08 mov 0x8(%ebp),%esi 4a3: 8b 45 08 mov 0x8(%ebp),%eax 4a6: 01 de add %ebx,%esi 4a8: 89 f3 mov %esi,%ebx buf[i] = '\0'; 4aa: c6 03 00 movb $0x0,(%ebx) } 4ad: 8d 65 f4 lea -0xc(%ebp),%esp 4b0: 5b pop %ebx 4b1: 5e pop %esi 4b2: 5f pop %edi 4b3: 5d pop %ebp 4b4: c3 ret 4b5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 4b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 000004c0 <stat>: int stat(const char *n, struct stat *st) { 4c0: 55 push %ebp 4c1: 89 e5 mov %esp,%ebp 4c3: 56 push %esi 4c4: 53 push %ebx int fd; int r; fd = open(n, O_RDONLY); 4c5: 83 ec 08 sub $0x8,%esp 4c8: 6a 00 push $0x0 4ca: ff 75 08 pushl 0x8(%ebp) 4cd: e8 f0 00 00 00 call 5c2 <open> if(fd < 0) 4d2: 83 c4 10 add $0x10,%esp 4d5: 85 c0 test %eax,%eax 4d7: 78 27 js 500 <stat+0x40> return -1; r = fstat(fd, st); 4d9: 83 ec 08 sub $0x8,%esp 4dc: ff 75 0c pushl 0xc(%ebp) 4df: 89 c3 mov %eax,%ebx 4e1: 50 push %eax 4e2: e8 f3 00 00 00 call 5da <fstat> close(fd); 4e7: 89 1c 24 mov %ebx,(%esp) r = fstat(fd, st); 4ea: 89 c6 mov %eax,%esi close(fd); 4ec: e8 b9 00 00 00 call 5aa <close> return r; 4f1: 83 c4 10 add $0x10,%esp } 4f4: 8d 65 f8 lea -0x8(%ebp),%esp 4f7: 89 f0 mov %esi,%eax 4f9: 5b pop %ebx 4fa: 5e pop %esi 4fb: 5d pop %ebp 4fc: c3 ret 4fd: 8d 76 00 lea 0x0(%esi),%esi return -1; 500: be ff ff ff ff mov $0xffffffff,%esi 505: eb ed jmp 4f4 <stat+0x34> 507: 89 f6 mov %esi,%esi 509: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 00000510 <atoi>: int atoi(const char *s) { 510: 55 push %ebp 511: 89 e5 mov %esp,%ebp 513: 53 push %ebx 514: 8b 4d 08 mov 0x8(%ebp),%ecx int n; n = 0; while('0' <= *s && *s <= '9') 517: 0f be 11 movsbl (%ecx),%edx 51a: 8d 42 d0 lea -0x30(%edx),%eax 51d: 3c 09 cmp $0x9,%al n = 0; 51f: b8 00 00 00 00 mov $0x0,%eax while('0' <= *s && *s <= '9') 524: 77 1f ja 545 <atoi+0x35> 526: 8d 76 00 lea 0x0(%esi),%esi 529: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi n = n*10 + *s++ - '0'; 530: 8d 04 80 lea (%eax,%eax,4),%eax 533: 83 c1 01 add $0x1,%ecx 536: 8d 44 42 d0 lea -0x30(%edx,%eax,2),%eax while('0' <= *s && *s <= '9') 53a: 0f be 11 movsbl (%ecx),%edx 53d: 8d 5a d0 lea -0x30(%edx),%ebx 540: 80 fb 09 cmp $0x9,%bl 543: 76 eb jbe 530 <atoi+0x20> return n; } 545: 5b pop %ebx 546: 5d pop %ebp 547: c3 ret 548: 90 nop 549: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 00000550 <memmove>: void* memmove(void *vdst, const void *vsrc, int n) { 550: 55 push %ebp 551: 89 e5 mov %esp,%ebp 553: 56 push %esi 554: 53 push %ebx 555: 8b 5d 10 mov 0x10(%ebp),%ebx 558: 8b 45 08 mov 0x8(%ebp),%eax 55b: 8b 75 0c mov 0xc(%ebp),%esi char *dst; const char *src; dst = vdst; src = vsrc; while(n-- > 0) 55e: 85 db test %ebx,%ebx 560: 7e 14 jle 576 <memmove+0x26> 562: 31 d2 xor %edx,%edx 564: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *dst++ = *src++; 568: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 56c: 88 0c 10 mov %cl,(%eax,%edx,1) 56f: 83 c2 01 add $0x1,%edx while(n-- > 0) 572: 39 d3 cmp %edx,%ebx 574: 75 f2 jne 568 <memmove+0x18> return vdst; } 576: 5b pop %ebx 577: 5e pop %esi 578: 5d pop %ebp 579: c3 ret 0000057a <fork>: name: \ movl $SYS_ ## name, %eax; \ int $T_SYSCALL; \ ret SYSCALL(fork) 57a: b8 01 00 00 00 mov $0x1,%eax 57f: cd 40 int $0x40 581: c3 ret 00000582 <exit>: SYSCALL(exit) 582: b8 02 00 00 00 mov $0x2,%eax 587: cd 40 int $0x40 589: c3 ret 0000058a <wait>: SYSCALL(wait) 58a: b8 03 00 00 00 mov $0x3,%eax 58f: cd 40 int $0x40 591: c3 ret 00000592 <pipe>: SYSCALL(pipe) 592: b8 04 00 00 00 mov $0x4,%eax 597: cd 40 int $0x40 599: c3 ret 0000059a <read>: SYSCALL(read) 59a: b8 05 00 00 00 mov $0x5,%eax 59f: cd 40 int $0x40 5a1: c3 ret 000005a2 <write>: SYSCALL(write) 5a2: b8 10 00 00 00 mov $0x10,%eax 5a7: cd 40 int $0x40 5a9: c3 ret 000005aa <close>: SYSCALL(close) 5aa: b8 15 00 00 00 mov $0x15,%eax 5af: cd 40 int $0x40 5b1: c3 ret 000005b2 <kill>: SYSCALL(kill) 5b2: b8 06 00 00 00 mov $0x6,%eax 5b7: cd 40 int $0x40 5b9: c3 ret 000005ba <exec>: SYSCALL(exec) 5ba: b8 07 00 00 00 mov $0x7,%eax 5bf: cd 40 int $0x40 5c1: c3 ret 000005c2 <open>: SYSCALL(open) 5c2: b8 0f 00 00 00 mov $0xf,%eax 5c7: cd 40 int $0x40 5c9: c3 ret 000005ca <mknod>: SYSCALL(mknod) 5ca: b8 11 00 00 00 mov $0x11,%eax 5cf: cd 40 int $0x40 5d1: c3 ret 000005d2 <unlink>: SYSCALL(unlink) 5d2: b8 12 00 00 00 mov $0x12,%eax 5d7: cd 40 int $0x40 5d9: c3 ret 000005da <fstat>: SYSCALL(fstat) 5da: b8 08 00 00 00 mov $0x8,%eax 5df: cd 40 int $0x40 5e1: c3 ret 000005e2 <link>: SYSCALL(link) 5e2: b8 13 00 00 00 mov $0x13,%eax 5e7: cd 40 int $0x40 5e9: c3 ret 000005ea <mkdir>: SYSCALL(mkdir) 5ea: b8 14 00 00 00 mov $0x14,%eax 5ef: cd 40 int $0x40 5f1: c3 ret 000005f2 <chdir>: SYSCALL(chdir) 5f2: b8 09 00 00 00 mov $0x9,%eax 5f7: cd 40 int $0x40 5f9: c3 ret 000005fa <dup>: SYSCALL(dup) 5fa: b8 0a 00 00 00 mov $0xa,%eax 5ff: cd 40 int $0x40 601: c3 ret 00000602 <getpid>: SYSCALL(getpid) 602: b8 0b 00 00 00 mov $0xb,%eax 607: cd 40 int $0x40 609: c3 ret 0000060a <sbrk>: SYSCALL(sbrk) 60a: b8 0c 00 00 00 mov $0xc,%eax 60f: cd 40 int $0x40 611: c3 ret 00000612 <sleep>: SYSCALL(sleep) 612: b8 0d 00 00 00 mov $0xd,%eax 617: cd 40 int $0x40 619: c3 ret 0000061a <uptime>: SYSCALL(uptime) 61a: b8 0e 00 00 00 mov $0xe,%eax 61f: cd 40 int $0x40 621: c3 ret 622: 66 90 xchg %ax,%ax 624: 66 90 xchg %ax,%ax 626: 66 90 xchg %ax,%ax 628: 66 90 xchg %ax,%ax 62a: 66 90 xchg %ax,%ax 62c: 66 90 xchg %ax,%ax 62e: 66 90 xchg %ax,%ax 00000630 <printint>: write(fd, &c, 1); } static void printint(int fd, int xx, int base, int sgn) { 630: 55 push %ebp 631: 89 e5 mov %esp,%ebp 633: 57 push %edi 634: 56 push %esi 635: 53 push %ebx 636: 83 ec 3c sub $0x3c,%esp char buf[16]; int i, neg; uint x; neg = 0; if(sgn && xx < 0){ 639: 85 d2 test %edx,%edx { 63b: 89 45 c0 mov %eax,-0x40(%ebp) neg = 1; x = -xx; 63e: 89 d0 mov %edx,%eax if(sgn && xx < 0){ 640: 79 76 jns 6b8 <printint+0x88> 642: f6 45 08 01 testb $0x1,0x8(%ebp) 646: 74 70 je 6b8 <printint+0x88> x = -xx; 648: f7 d8 neg %eax neg = 1; 64a: c7 45 c4 01 00 00 00 movl $0x1,-0x3c(%ebp) } else { x = xx; } i = 0; 651: 31 f6 xor %esi,%esi 653: 8d 5d d7 lea -0x29(%ebp),%ebx 656: eb 0a jmp 662 <printint+0x32> 658: 90 nop 659: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi do{ buf[i++] = digits[x % base]; 660: 89 fe mov %edi,%esi 662: 31 d2 xor %edx,%edx 664: 8d 7e 01 lea 0x1(%esi),%edi 667: f7 f1 div %ecx 669: 0f b6 92 68 0a 00 00 movzbl 0xa68(%edx),%edx }while((x /= base) != 0); 670: 85 c0 test %eax,%eax buf[i++] = digits[x % base]; 672: 88 14 3b mov %dl,(%ebx,%edi,1) }while((x /= base) != 0); 675: 75 e9 jne 660 <printint+0x30> if(neg) 677: 8b 45 c4 mov -0x3c(%ebp),%eax 67a: 85 c0 test %eax,%eax 67c: 74 08 je 686 <printint+0x56> buf[i++] = '-'; 67e: c6 44 3d d8 2d movb $0x2d,-0x28(%ebp,%edi,1) 683: 8d 7e 02 lea 0x2(%esi),%edi 686: 8d 74 3d d7 lea -0x29(%ebp,%edi,1),%esi 68a: 8b 7d c0 mov -0x40(%ebp),%edi 68d: 8d 76 00 lea 0x0(%esi),%esi 690: 0f b6 06 movzbl (%esi),%eax write(fd, &c, 1); 693: 83 ec 04 sub $0x4,%esp 696: 83 ee 01 sub $0x1,%esi 699: 6a 01 push $0x1 69b: 53 push %ebx 69c: 57 push %edi 69d: 88 45 d7 mov %al,-0x29(%ebp) 6a0: e8 fd fe ff ff call 5a2 <write> while(--i >= 0) 6a5: 83 c4 10 add $0x10,%esp 6a8: 39 de cmp %ebx,%esi 6aa: 75 e4 jne 690 <printint+0x60> putc(fd, buf[i]); } 6ac: 8d 65 f4 lea -0xc(%ebp),%esp 6af: 5b pop %ebx 6b0: 5e pop %esi 6b1: 5f pop %edi 6b2: 5d pop %ebp 6b3: c3 ret 6b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi neg = 0; 6b8: c7 45 c4 00 00 00 00 movl $0x0,-0x3c(%ebp) 6bf: eb 90 jmp 651 <printint+0x21> 6c1: eb 0d jmp 6d0 <printf> 6c3: 90 nop 6c4: 90 nop 6c5: 90 nop 6c6: 90 nop 6c7: 90 nop 6c8: 90 nop 6c9: 90 nop 6ca: 90 nop 6cb: 90 nop 6cc: 90 nop 6cd: 90 nop 6ce: 90 nop 6cf: 90 nop 000006d0 <printf>: // Print to the given fd. Only understands %d, %x, %p, %s. void printf(int fd, const char *fmt, ...) { 6d0: 55 push %ebp 6d1: 89 e5 mov %esp,%ebp 6d3: 57 push %edi 6d4: 56 push %esi 6d5: 53 push %ebx 6d6: 83 ec 2c sub $0x2c,%esp int c, i, state; uint *ap; state = 0; ap = (uint*)(void*)&fmt + 1; for(i = 0; fmt[i]; i++){ 6d9: 8b 75 0c mov 0xc(%ebp),%esi 6dc: 0f b6 1e movzbl (%esi),%ebx 6df: 84 db test %bl,%bl 6e1: 0f 84 b3 00 00 00 je 79a <printf+0xca> ap = (uint*)(void*)&fmt + 1; 6e7: 8d 45 10 lea 0x10(%ebp),%eax 6ea: 83 c6 01 add $0x1,%esi state = 0; 6ed: 31 ff xor %edi,%edi ap = (uint*)(void*)&fmt + 1; 6ef: 89 45 d4 mov %eax,-0x2c(%ebp) 6f2: eb 2f jmp 723 <printf+0x53> 6f4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi c = fmt[i] & 0xff; if(state == 0){ if(c == '%'){ 6f8: 83 f8 25 cmp $0x25,%eax 6fb: 0f 84 a7 00 00 00 je 7a8 <printf+0xd8> write(fd, &c, 1); 701: 8d 45 e2 lea -0x1e(%ebp),%eax 704: 83 ec 04 sub $0x4,%esp 707: 88 5d e2 mov %bl,-0x1e(%ebp) 70a: 6a 01 push $0x1 70c: 50 push %eax 70d: ff 75 08 pushl 0x8(%ebp) 710: e8 8d fe ff ff call 5a2 <write> 715: 83 c4 10 add $0x10,%esp 718: 83 c6 01 add $0x1,%esi for(i = 0; fmt[i]; i++){ 71b: 0f b6 5e ff movzbl -0x1(%esi),%ebx 71f: 84 db test %bl,%bl 721: 74 77 je 79a <printf+0xca> if(state == 0){ 723: 85 ff test %edi,%edi c = fmt[i] & 0xff; 725: 0f be cb movsbl %bl,%ecx 728: 0f b6 c3 movzbl %bl,%eax if(state == 0){ 72b: 74 cb je 6f8 <printf+0x28> state = '%'; } else { putc(fd, c); } } else if(state == '%'){ 72d: 83 ff 25 cmp $0x25,%edi 730: 75 e6 jne 718 <printf+0x48> if(c == 'd'){ 732: 83 f8 64 cmp $0x64,%eax 735: 0f 84 05 01 00 00 je 840 <printf+0x170> printint(fd, *ap, 10, 1); ap++; } else if(c == 'x' || c == 'p'){ 73b: 81 e1 f7 00 00 00 and $0xf7,%ecx 741: 83 f9 70 cmp $0x70,%ecx 744: 74 72 je 7b8 <printf+0xe8> printint(fd, *ap, 16, 0); ap++; } else if(c == 's'){ 746: 83 f8 73 cmp $0x73,%eax 749: 0f 84 99 00 00 00 je 7e8 <printf+0x118> s = "(null)"; while(*s != 0){ putc(fd, *s); s++; } } else if(c == 'c'){ 74f: 83 f8 63 cmp $0x63,%eax 752: 0f 84 08 01 00 00 je 860 <printf+0x190> putc(fd, *ap); ap++; } else if(c == '%'){ 758: 83 f8 25 cmp $0x25,%eax 75b: 0f 84 ef 00 00 00 je 850 <printf+0x180> write(fd, &c, 1); 761: 8d 45 e7 lea -0x19(%ebp),%eax 764: 83 ec 04 sub $0x4,%esp 767: c6 45 e7 25 movb $0x25,-0x19(%ebp) 76b: 6a 01 push $0x1 76d: 50 push %eax 76e: ff 75 08 pushl 0x8(%ebp) 771: e8 2c fe ff ff call 5a2 <write> 776: 83 c4 0c add $0xc,%esp 779: 8d 45 e6 lea -0x1a(%ebp),%eax 77c: 88 5d e6 mov %bl,-0x1a(%ebp) 77f: 6a 01 push $0x1 781: 50 push %eax 782: ff 75 08 pushl 0x8(%ebp) 785: 83 c6 01 add $0x1,%esi } else { // Unknown % sequence. Print it to draw attention. putc(fd, '%'); putc(fd, c); } state = 0; 788: 31 ff xor %edi,%edi write(fd, &c, 1); 78a: e8 13 fe ff ff call 5a2 <write> for(i = 0; fmt[i]; i++){ 78f: 0f b6 5e ff movzbl -0x1(%esi),%ebx write(fd, &c, 1); 793: 83 c4 10 add $0x10,%esp for(i = 0; fmt[i]; i++){ 796: 84 db test %bl,%bl 798: 75 89 jne 723 <printf+0x53> } } } 79a: 8d 65 f4 lea -0xc(%ebp),%esp 79d: 5b pop %ebx 79e: 5e pop %esi 79f: 5f pop %edi 7a0: 5d pop %ebp 7a1: c3 ret 7a2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi state = '%'; 7a8: bf 25 00 00 00 mov $0x25,%edi 7ad: e9 66 ff ff ff jmp 718 <printf+0x48> 7b2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi printint(fd, *ap, 16, 0); 7b8: 83 ec 0c sub $0xc,%esp 7bb: b9 10 00 00 00 mov $0x10,%ecx 7c0: 6a 00 push $0x0 7c2: 8b 7d d4 mov -0x2c(%ebp),%edi 7c5: 8b 45 08 mov 0x8(%ebp),%eax 7c8: 8b 17 mov (%edi),%edx 7ca: e8 61 fe ff ff call 630 <printint> ap++; 7cf: 89 f8 mov %edi,%eax 7d1: 83 c4 10 add $0x10,%esp state = 0; 7d4: 31 ff xor %edi,%edi ap++; 7d6: 83 c0 04 add $0x4,%eax 7d9: 89 45 d4 mov %eax,-0x2c(%ebp) 7dc: e9 37 ff ff ff jmp 718 <printf+0x48> 7e1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi s = (char*)*ap; 7e8: 8b 45 d4 mov -0x2c(%ebp),%eax 7eb: 8b 08 mov (%eax),%ecx ap++; 7ed: 83 c0 04 add $0x4,%eax 7f0: 89 45 d4 mov %eax,-0x2c(%ebp) if(s == 0) 7f3: 85 c9 test %ecx,%ecx 7f5: 0f 84 8e 00 00 00 je 889 <printf+0x1b9> while(*s != 0){ 7fb: 0f b6 01 movzbl (%ecx),%eax state = 0; 7fe: 31 ff xor %edi,%edi s = (char*)*ap; 800: 89 cb mov %ecx,%ebx while(*s != 0){ 802: 84 c0 test %al,%al 804: 0f 84 0e ff ff ff je 718 <printf+0x48> 80a: 89 75 d0 mov %esi,-0x30(%ebp) 80d: 89 de mov %ebx,%esi 80f: 8b 5d 08 mov 0x8(%ebp),%ebx 812: 8d 7d e3 lea -0x1d(%ebp),%edi 815: 8d 76 00 lea 0x0(%esi),%esi write(fd, &c, 1); 818: 83 ec 04 sub $0x4,%esp s++; 81b: 83 c6 01 add $0x1,%esi 81e: 88 45 e3 mov %al,-0x1d(%ebp) write(fd, &c, 1); 821: 6a 01 push $0x1 823: 57 push %edi 824: 53 push %ebx 825: e8 78 fd ff ff call 5a2 <write> while(*s != 0){ 82a: 0f b6 06 movzbl (%esi),%eax 82d: 83 c4 10 add $0x10,%esp 830: 84 c0 test %al,%al 832: 75 e4 jne 818 <printf+0x148> 834: 8b 75 d0 mov -0x30(%ebp),%esi state = 0; 837: 31 ff xor %edi,%edi 839: e9 da fe ff ff jmp 718 <printf+0x48> 83e: 66 90 xchg %ax,%ax printint(fd, *ap, 10, 1); 840: 83 ec 0c sub $0xc,%esp 843: b9 0a 00 00 00 mov $0xa,%ecx 848: 6a 01 push $0x1 84a: e9 73 ff ff ff jmp 7c2 <printf+0xf2> 84f: 90 nop write(fd, &c, 1); 850: 83 ec 04 sub $0x4,%esp 853: 88 5d e5 mov %bl,-0x1b(%ebp) 856: 8d 45 e5 lea -0x1b(%ebp),%eax 859: 6a 01 push $0x1 85b: e9 21 ff ff ff jmp 781 <printf+0xb1> putc(fd, *ap); 860: 8b 7d d4 mov -0x2c(%ebp),%edi write(fd, &c, 1); 863: 83 ec 04 sub $0x4,%esp putc(fd, *ap); 866: 8b 07 mov (%edi),%eax write(fd, &c, 1); 868: 6a 01 push $0x1 ap++; 86a: 83 c7 04 add $0x4,%edi putc(fd, *ap); 86d: 88 45 e4 mov %al,-0x1c(%ebp) write(fd, &c, 1); 870: 8d 45 e4 lea -0x1c(%ebp),%eax 873: 50 push %eax 874: ff 75 08 pushl 0x8(%ebp) 877: e8 26 fd ff ff call 5a2 <write> ap++; 87c: 89 7d d4 mov %edi,-0x2c(%ebp) 87f: 83 c4 10 add $0x10,%esp state = 0; 882: 31 ff xor %edi,%edi 884: e9 8f fe ff ff jmp 718 <printf+0x48> s = "(null)"; 889: bb 5e 0a 00 00 mov $0xa5e,%ebx while(*s != 0){ 88e: b8 28 00 00 00 mov $0x28,%eax 893: e9 72 ff ff ff jmp 80a <printf+0x13a> 898: 66 90 xchg %ax,%ax 89a: 66 90 xchg %ax,%ax 89c: 66 90 xchg %ax,%ax 89e: 66 90 xchg %ax,%ax 000008a0 <free>: static Header base; static Header *freep; void free(void *ap) { 8a0: 55 push %ebp Header *bp, *p; bp = (Header*)ap - 1; for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 8a1: a1 00 0e 00 00 mov 0xe00,%eax { 8a6: 89 e5 mov %esp,%ebp 8a8: 57 push %edi 8a9: 56 push %esi 8aa: 53 push %ebx 8ab: 8b 5d 08 mov 0x8(%ebp),%ebx bp = (Header*)ap - 1; 8ae: 8d 4b f8 lea -0x8(%ebx),%ecx 8b1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi for(p = freep; !(bp > p && bp < p->s.ptr); p = p->s.ptr) 8b8: 39 c8 cmp %ecx,%eax 8ba: 8b 10 mov (%eax),%edx 8bc: 73 32 jae 8f0 <free+0x50> 8be: 39 d1 cmp %edx,%ecx 8c0: 72 04 jb 8c6 <free+0x26> if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 8c2: 39 d0 cmp %edx,%eax 8c4: 72 32 jb 8f8 <free+0x58> break; if(bp + bp->s.size == p->s.ptr){ 8c6: 8b 73 fc mov -0x4(%ebx),%esi 8c9: 8d 3c f1 lea (%ecx,%esi,8),%edi 8cc: 39 fa cmp %edi,%edx 8ce: 74 30 je 900 <free+0x60> bp->s.size += p->s.ptr->s.size; bp->s.ptr = p->s.ptr->s.ptr; } else bp->s.ptr = p->s.ptr; 8d0: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 8d3: 8b 50 04 mov 0x4(%eax),%edx 8d6: 8d 34 d0 lea (%eax,%edx,8),%esi 8d9: 39 f1 cmp %esi,%ecx 8db: 74 3a je 917 <free+0x77> p->s.size += bp->s.size; p->s.ptr = bp->s.ptr; } else p->s.ptr = bp; 8dd: 89 08 mov %ecx,(%eax) freep = p; 8df: a3 00 0e 00 00 mov %eax,0xe00 } 8e4: 5b pop %ebx 8e5: 5e pop %esi 8e6: 5f pop %edi 8e7: 5d pop %ebp 8e8: c3 ret 8e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(p >= p->s.ptr && (bp > p || bp < p->s.ptr)) 8f0: 39 d0 cmp %edx,%eax 8f2: 72 04 jb 8f8 <free+0x58> 8f4: 39 d1 cmp %edx,%ecx 8f6: 72 ce jb 8c6 <free+0x26> { 8f8: 89 d0 mov %edx,%eax 8fa: eb bc jmp 8b8 <free+0x18> 8fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi bp->s.size += p->s.ptr->s.size; 900: 03 72 04 add 0x4(%edx),%esi 903: 89 73 fc mov %esi,-0x4(%ebx) bp->s.ptr = p->s.ptr->s.ptr; 906: 8b 10 mov (%eax),%edx 908: 8b 12 mov (%edx),%edx 90a: 89 53 f8 mov %edx,-0x8(%ebx) if(p + p->s.size == bp){ 90d: 8b 50 04 mov 0x4(%eax),%edx 910: 8d 34 d0 lea (%eax,%edx,8),%esi 913: 39 f1 cmp %esi,%ecx 915: 75 c6 jne 8dd <free+0x3d> p->s.size += bp->s.size; 917: 03 53 fc add -0x4(%ebx),%edx freep = p; 91a: a3 00 0e 00 00 mov %eax,0xe00 p->s.size += bp->s.size; 91f: 89 50 04 mov %edx,0x4(%eax) p->s.ptr = bp->s.ptr; 922: 8b 53 f8 mov -0x8(%ebx),%edx 925: 89 10 mov %edx,(%eax) } 927: 5b pop %ebx 928: 5e pop %esi 929: 5f pop %edi 92a: 5d pop %ebp 92b: c3 ret 92c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 00000930 <malloc>: return freep; } void* malloc(uint nbytes) { 930: 55 push %ebp 931: 89 e5 mov %esp,%ebp 933: 57 push %edi 934: 56 push %esi 935: 53 push %ebx 936: 83 ec 0c sub $0xc,%esp Header *p, *prevp; uint nunits; nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 939: 8b 45 08 mov 0x8(%ebp),%eax if((prevp = freep) == 0){ 93c: 8b 15 00 0e 00 00 mov 0xe00,%edx nunits = (nbytes + sizeof(Header) - 1)/sizeof(Header) + 1; 942: 8d 78 07 lea 0x7(%eax),%edi 945: c1 ef 03 shr $0x3,%edi 948: 83 c7 01 add $0x1,%edi if((prevp = freep) == 0){ 94b: 85 d2 test %edx,%edx 94d: 0f 84 9d 00 00 00 je 9f0 <malloc+0xc0> 953: 8b 02 mov (%edx),%eax 955: 8b 48 04 mov 0x4(%eax),%ecx base.s.ptr = freep = prevp = &base; base.s.size = 0; } for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ if(p->s.size >= nunits){ 958: 39 cf cmp %ecx,%edi 95a: 76 6c jbe 9c8 <malloc+0x98> 95c: 81 ff 00 10 00 00 cmp $0x1000,%edi 962: bb 00 10 00 00 mov $0x1000,%ebx 967: 0f 43 df cmovae %edi,%ebx p = sbrk(nu * sizeof(Header)); 96a: 8d 34 dd 00 00 00 00 lea 0x0(,%ebx,8),%esi 971: eb 0e jmp 981 <malloc+0x51> 973: 90 nop 974: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(p = prevp->s.ptr; ; prevp = p, p = p->s.ptr){ 978: 8b 02 mov (%edx),%eax if(p->s.size >= nunits){ 97a: 8b 48 04 mov 0x4(%eax),%ecx 97d: 39 f9 cmp %edi,%ecx 97f: 73 47 jae 9c8 <malloc+0x98> p->s.size = nunits; } freep = prevp; return (void*)(p + 1); } if(p == freep) 981: 39 05 00 0e 00 00 cmp %eax,0xe00 987: 89 c2 mov %eax,%edx 989: 75 ed jne 978 <malloc+0x48> p = sbrk(nu * sizeof(Header)); 98b: 83 ec 0c sub $0xc,%esp 98e: 56 push %esi 98f: e8 76 fc ff ff call 60a <sbrk> if(p == (char*)-1) 994: 83 c4 10 add $0x10,%esp 997: 83 f8 ff cmp $0xffffffff,%eax 99a: 74 1c je 9b8 <malloc+0x88> hp->s.size = nu; 99c: 89 58 04 mov %ebx,0x4(%eax) free((void*)(hp + 1)); 99f: 83 ec 0c sub $0xc,%esp 9a2: 83 c0 08 add $0x8,%eax 9a5: 50 push %eax 9a6: e8 f5 fe ff ff call 8a0 <free> return freep; 9ab: 8b 15 00 0e 00 00 mov 0xe00,%edx if((p = morecore(nunits)) == 0) 9b1: 83 c4 10 add $0x10,%esp 9b4: 85 d2 test %edx,%edx 9b6: 75 c0 jne 978 <malloc+0x48> return 0; } } 9b8: 8d 65 f4 lea -0xc(%ebp),%esp return 0; 9bb: 31 c0 xor %eax,%eax } 9bd: 5b pop %ebx 9be: 5e pop %esi 9bf: 5f pop %edi 9c0: 5d pop %ebp 9c1: c3 ret 9c2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(p->s.size == nunits) 9c8: 39 cf cmp %ecx,%edi 9ca: 74 54 je a20 <malloc+0xf0> p->s.size -= nunits; 9cc: 29 f9 sub %edi,%ecx 9ce: 89 48 04 mov %ecx,0x4(%eax) p += p->s.size; 9d1: 8d 04 c8 lea (%eax,%ecx,8),%eax p->s.size = nunits; 9d4: 89 78 04 mov %edi,0x4(%eax) freep = prevp; 9d7: 89 15 00 0e 00 00 mov %edx,0xe00 } 9dd: 8d 65 f4 lea -0xc(%ebp),%esp return (void*)(p + 1); 9e0: 83 c0 08 add $0x8,%eax } 9e3: 5b pop %ebx 9e4: 5e pop %esi 9e5: 5f pop %edi 9e6: 5d pop %ebp 9e7: c3 ret 9e8: 90 nop 9e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi base.s.ptr = freep = prevp = &base; 9f0: c7 05 00 0e 00 00 04 movl $0xe04,0xe00 9f7: 0e 00 00 9fa: c7 05 04 0e 00 00 04 movl $0xe04,0xe04 a01: 0e 00 00 base.s.size = 0; a04: b8 04 0e 00 00 mov $0xe04,%eax a09: c7 05 08 0e 00 00 00 movl $0x0,0xe08 a10: 00 00 00 a13: e9 44 ff ff ff jmp 95c <malloc+0x2c> a18: 90 nop a19: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi prevp->s.ptr = p->s.ptr; a20: 8b 08 mov (%eax),%ecx a22: 89 0a mov %ecx,(%edx) a24: eb b1 jmp 9d7 <malloc+0xa7>
include "include/hUGE.inc" SECTION "Song Data", ROMX ryukenden:: db 6 dw order_cnt dw order1, order2, order3, order4 dw duty_instruments, wave_instruments, noise_instruments dw routines dw waves order_cnt: db 24 order1: dw P0,P0,P0,P0,P12,P14,P0,P0,P0,P0,P12,P14 order2: dw P1,P1,P8,P8,P13,P15,P1,P1,P8,P8,P13,P15 order3: dw P2,P4,P4,P4,P11,P16,P17,P17,P17,P17,P11,P16 order4: dw P3,P6,P6,P6,P6,P6,P18,P3,P6,P6,P6,P6 P0: dn B_4,1,$000 dn B_4,1,$C03 dn E_5,1,$000 dn E_5,1,$C03 dn B_4,1,$000 dn B_4,1,$C03 dn G_5,1,$000 dn G_5,1,$C03 dn E_5,1,$000 dn E_5,1,$C03 dn F#5,1,$000 dn F#5,1,$C03 dn D_5,1,$000 dn D_5,1,$C03 dn A_4,1,$000 dn A_4,1,$C03 dn C#5,1,$000 dn C#5,1,$C03 dn E_5,1,$000 dn E_5,1,$C03 dn C#5,1,$000 dn C#5,1,$C03 dn B_4,1,$000 dn B_4,1,$C03 dn D#5,1,$000 dn D#5,1,$C03 dn F#5,1,$000 dn F#5,1,$C03 dn D#5,1,$000 dn D#5,1,$C03 dn ___,0,$000 dn ___,0,$000 dn B_4,1,$000 dn B_4,1,$C03 dn E_5,1,$000 dn E_5,1,$C03 dn B_4,1,$000 dn B_4,1,$C03 dn G_5,1,$000 dn G_5,1,$C03 dn E_5,1,$000 dn E_5,1,$C03 dn F#5,1,$000 dn F#5,1,$C03 dn D_5,1,$000 dn D_5,1,$C03 dn A_4,1,$000 dn A_4,1,$C03 dn C#5,1,$000 dn C#5,1,$C03 dn E_5,1,$000 dn E_5,1,$C03 dn C#5,1,$000 dn C#5,1,$C03 dn B_4,1,$000 dn B_4,1,$C03 dn D#5,1,$000 dn D#5,1,$C03 dn F#5,1,$000 dn F#5,1,$C03 dn D#5,1,$000 dn D#5,1,$C03 dn ___,0,$000 dn ___,0,$000 P1: dn ___,0,$E00 dn ___,0,$000 dn ___,0,$000 dn B_4,1,$C07 dn B_4,1,$C02 dn E_5,1,$C07 dn E_5,1,$C02 dn B_4,1,$C07 dn B_4,1,$C02 dn G_5,1,$C07 dn G_5,1,$C02 dn E_5,1,$C07 dn E_5,1,$C02 dn F#5,1,$C07 dn F#5,1,$C02 dn D_5,1,$C07 dn D_5,1,$C02 dn A_4,1,$C07 dn A_4,1,$C02 dn C#5,1,$C07 dn C#5,1,$C02 dn E_5,1,$C07 dn E_5,1,$C02 dn C#5,1,$C07 dn C#5,1,$C02 dn B_4,1,$C07 dn B_4,1,$C02 dn D#5,1,$C07 dn D#5,1,$C02 dn F#5,1,$C07 dn F#5,1,$C02 dn D#5,1,$C07 dn D#5,1,$C02 dn ___,0,$C07 dn ___,0,$C02 dn B_4,1,$C07 dn B_4,1,$C02 dn E_5,1,$C07 dn E_5,1,$C02 dn B_4,1,$C07 dn B_4,1,$C02 dn G_5,1,$C07 dn G_5,1,$C02 dn E_5,1,$C07 dn E_5,1,$C02 dn F#5,1,$C07 dn F#5,1,$C02 dn D_5,1,$C07 dn D_5,1,$C02 dn A_4,1,$C07 dn A_4,1,$C02 dn C#5,1,$C07 dn C#5,1,$C02 dn E_5,1,$C07 dn E_5,1,$C02 dn C#5,1,$C07 dn C#5,1,$C02 dn B_4,1,$C07 dn B_4,1,$C02 dn D#5,1,$C07 dn D#5,1,$C02 dn F#5,1,$C07 dn F#5,1,$C02 dn D#5,1,$C07 P2: dn ___,0,$E00 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 P3: dn ___,0,$8ED dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn A#6,1,$000 dn ___,0,$E00 dn ___,0,$000 dn A#6,1,$000 dn A#6,1,$000 dn G#6,2,$000 dn ___,0,$E00 P4: dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn A_3,5,$000 dn ___,0,$C08 dn A_3,5,$000 dn ___,0,$C08 dn A_3,5,$000 dn ___,0,$C08 dn A_3,5,$000 dn ___,0,$C08 dn B_3,5,$000 dn ___,0,$C08 dn B_3,5,$000 dn ___,0,$C08 dn B_3,5,$000 dn ___,0,$C08 dn B_3,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn A_3,5,$000 dn ___,0,$C08 dn A_3,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn A_4,5,$000 dn ___,0,$C08 dn D#4,5,$000 dn ___,0,$C08 dn B_3,5,$000 dn ___,0,$C08 dn F#4,5,$000 dn ___,0,$C08 dn B_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 P6: dn C_8,4,$000 dn F#7,5,$000 dn G#6,3,$000 dn ___,0,$000 dn C_8,4,$000 dn F#7,5,$000 dn G#5,2,$000 dn ___,0,$000 dn C_8,4,$000 dn F#7,5,$000 dn G#6,3,$000 dn ___,0,$000 dn C_8,4,$000 dn F#7,5,$000 dn G#5,2,$000 dn ___,0,$000 dn C_8,4,$000 dn F#7,5,$000 dn G#6,3,$000 dn ___,0,$000 dn C_8,4,$000 dn F#7,5,$000 dn G#5,2,$000 dn ___,0,$000 dn C_8,4,$000 dn F#7,5,$000 dn G#6,3,$000 dn ___,0,$000 dn C_8,4,$000 dn F#7,5,$000 dn G#5,2,$000 dn ___,0,$000 dn C_8,4,$000 dn F#7,5,$000 dn G#6,3,$000 dn ___,0,$000 dn C_8,4,$000 dn F#7,5,$000 dn G#5,2,$000 dn ___,0,$000 dn C_8,4,$000 dn F#7,5,$000 dn G#6,3,$000 dn ___,0,$000 dn C_8,4,$000 dn F#7,5,$000 dn G#5,2,$000 dn ___,0,$000 dn C_8,4,$000 dn F#7,5,$000 dn G#6,3,$000 dn ___,0,$000 dn C_8,4,$000 dn F#7,5,$000 dn G#5,2,$000 dn ___,0,$000 dn C_8,4,$000 dn F#7,5,$000 dn G#6,3,$000 dn ___,0,$000 dn C_8,4,$000 dn F#7,5,$000 dn G#5,2,$000 dn ___,0,$000 P8: dn E_6,9,$07C dn ___,0,$E00 dn B_5,9,$8FF dn ___,0,$E00 dn ___,0,$000 dn ___,0,$000 dn B_5,9,$000 dn ___,0,$E00 dn ___,0,$000 dn ___,0,$000 dn B_5,9,$000 dn ___,0,$E00 dn E_6,9,$000 dn ___,0,$E00 dn ___,0,$000 dn ___,0,$000 dn A_5,9,$07C dn ___,0,$E00 dn E_6,9,$000 dn ___,0,$E00 dn C#6,9,$000 dn ___,0,$E00 dn B_5,9,$07C dn ___,0,$E00 dn ___,0,$000 dn ___,0,$000 dn A_5,9,$000 dn ___,0,$E00 dn B_5,9,$000 dn ___,0,$E00 dn ___,0,$000 dn ___,0,$000 dn E_6,9,$07C dn ___,0,$E00 dn B_5,9,$000 dn ___,0,$E00 dn ___,0,$000 dn ___,0,$000 dn B_5,9,$000 dn ___,0,$E00 dn ___,0,$000 dn ___,0,$000 dn B_5,9,$000 dn ___,0,$E00 dn E_6,9,$000 dn ___,0,$E00 dn ___,0,$000 dn ___,0,$000 dn A_5,9,$07C dn ___,0,$E00 dn E_6,9,$000 dn ___,0,$E00 dn D#6,9,$000 dn ___,0,$E00 dn B_5,9,$07C dn ___,0,$E00 dn ___,0,$000 dn ___,0,$000 dn D#6,9,$000 dn ___,0,$E00 dn B_5,9,$000 dn ___,0,$E00 dn ___,0,$000 dn ___,0,$000 P11: dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn D#4,5,$000 dn ___,0,$C08 dn D#4,5,$000 dn ___,0,$C08 dn D#4,5,$000 dn ___,0,$C08 dn D#4,5,$000 dn ___,0,$C08 dn B_3,5,$000 dn ___,0,$C08 dn B_3,5,$000 dn ___,0,$C08 dn B_3,5,$000 dn ___,0,$C08 dn B_3,5,$000 dn ___,0,$C08 dn G_3,5,$000 dn ___,0,$C08 dn G_3,5,$000 dn ___,0,$C08 dn G_3,5,$000 dn ___,0,$C08 dn G_3,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn D#4,5,$000 dn ___,0,$C08 dn D#4,5,$000 dn ___,0,$C08 dn D#4,5,$000 dn ___,0,$C08 dn D#4,5,$000 dn ___,0,$C08 dn B_3,5,$000 dn ___,0,$C08 dn B_3,5,$000 dn ___,0,$C08 dn B_3,5,$000 dn ___,0,$C08 dn B_3,5,$000 dn ___,0,$C08 dn G_3,5,$000 dn ___,0,$C08 dn G_3,5,$000 dn ___,0,$C08 dn G_3,5,$000 dn ___,0,$C08 dn G_3,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 P12: dn B_4,12,$000 dn E_5,12,$000 dn D#4,12,$000 dn A_4,12,$000 dn D#5,12,$000 dn F#5,12,$000 dn D#5,12,$000 dn B_4,12,$000 dn F#4,12,$000 dn D#4,12,$000 dn B_3,12,$000 dn D#4,12,$000 dn F#4,12,$000 dn B_4,12,$000 dn G_4,12,$000 dn E_4,12,$000 dn G_4,12,$000 dn B_4,12,$000 dn F#5,12,$000 dn E_5,12,$000 dn B_4,12,$000 dn G_4,12,$000 dn B_4,12,$000 dn E_5,12,$000 dn E_5,12,$000 dn G_5,12,$000 dn G_5,12,$000 dn B_5,12,$000 dn B_5,12,$000 dn E_6,12,$000 dn E_4,12,$000 dn G_4,12,$000 dn B_4,12,$000 dn E_5,12,$000 dn D#4,12,$000 dn A_4,12,$000 dn D#5,12,$000 dn F#5,12,$000 dn D#5,12,$000 dn B_4,12,$000 dn F#4,12,$000 dn D#4,12,$000 dn B_3,12,$000 dn D#4,12,$000 dn F#4,12,$000 dn B_4,12,$000 dn G_4,12,$000 dn E_4,12,$000 dn G_4,12,$000 dn B_4,12,$000 dn F#5,12,$000 dn E_5,12,$000 dn B_4,12,$000 dn G_4,12,$000 dn B_4,12,$000 dn E_5,12,$000 dn E_5,12,$000 dn G_5,12,$000 dn G_5,12,$000 dn B_5,12,$000 dn B_5,12,$000 dn E_6,12,$000 dn E_4,12,$000 dn G_4,12,$000 P13: dn ___,0,$8ED dn E_4,12,$C07 dn G_4,12,$C07 dn B_4,12,$C07 dn E_5,12,$C07 dn D#4,12,$C07 dn A_4,12,$C07 dn D#5,12,$C07 dn F#5,12,$C07 dn D#5,12,$C07 dn B_4,12,$C07 dn F#4,12,$C07 dn D#4,12,$C07 dn B_3,12,$C07 dn D#4,12,$C07 dn F#4,12,$C07 dn B_4,12,$C07 dn G_4,12,$C07 dn E_4,12,$C07 dn G_4,12,$C07 dn B_4,12,$C07 dn F#5,12,$C07 dn E_5,12,$C07 dn B_4,12,$C07 dn G_4,12,$C07 dn B_4,12,$C07 dn E_5,12,$C07 dn E_5,12,$C07 dn G_5,12,$C07 dn G_5,12,$C07 dn ___,0,$E00 dn ___,0,$000 dn ___,0,$8ED dn E_4,12,$C07 dn G_4,12,$C07 dn B_4,12,$C07 dn E_5,12,$C07 dn D#4,12,$C07 dn A_4,12,$C07 dn D#5,12,$C07 dn F#5,12,$C07 dn D#5,12,$C07 dn B_4,12,$C07 dn F#4,12,$C07 dn D#4,12,$C07 dn B_3,12,$C07 dn D#4,12,$C07 dn F#4,12,$C07 dn B_4,12,$C07 dn G_4,12,$C07 dn E_4,12,$C07 dn G_4,12,$C07 dn B_4,12,$C07 dn F#5,12,$C07 dn E_5,12,$C07 dn B_4,12,$C07 dn G_4,12,$C07 dn B_4,12,$C07 dn E_5,12,$C07 dn E_5,12,$C07 dn G_5,12,$C07 dn G_5,12,$C07 dn ___,0,$E00 dn ___,0,$000 P14: dn B_4,12,$000 dn E_5,12,$000 dn D#4,12,$000 dn A_4,12,$000 dn D#5,12,$000 dn F#5,12,$000 dn D#5,12,$000 dn B_4,12,$000 dn F#4,12,$000 dn D#4,12,$000 dn B_3,12,$000 dn D#4,12,$000 dn F#4,12,$000 dn B_4,12,$000 dn G_4,12,$000 dn E_4,12,$000 dn G_4,12,$000 dn B_4,12,$000 dn F#5,12,$000 dn E_5,12,$000 dn B_4,12,$000 dn G_4,12,$000 dn B_4,12,$000 dn E_5,12,$000 dn E_5,12,$000 dn G_5,12,$000 dn G_5,12,$000 dn B_5,12,$000 dn B_5,12,$000 dn E_6,12,$000 dn E_4,12,$000 dn G_4,12,$000 dn B_4,12,$000 dn E_5,12,$000 dn D#4,12,$000 dn A_4,12,$000 dn D#5,12,$000 dn F#5,12,$000 dn D#5,12,$000 dn B_4,12,$000 dn F#4,12,$000 dn D#4,12,$000 dn B_3,12,$000 dn D#4,12,$000 dn F#4,12,$000 dn B_4,12,$000 dn G_4,12,$000 dn E_4,12,$000 dn G_4,12,$000 dn B_4,12,$000 dn F#5,12,$000 dn E_5,12,$000 dn B_4,12,$000 dn G_4,12,$000 dn B_4,12,$000 dn E_5,12,$000 dn E_5,12,$000 dn B_4,12,$000 dn B_4,12,$000 dn G_4,12,$000 dn G_4,12,$000 dn E_4,12,$000 dn ___,0,$000 dn ___,0,$E00 P15: dn ___,0,$8ED dn E_4,12,$C07 dn G_4,12,$C07 dn B_4,12,$C07 dn E_5,12,$C07 dn D#4,12,$C07 dn A_4,12,$C07 dn D#5,12,$C07 dn F#5,12,$C07 dn D#5,12,$C07 dn B_4,12,$C07 dn F#4,12,$C07 dn D#4,12,$C07 dn B_3,12,$C07 dn D#4,12,$C07 dn F#4,12,$C07 dn B_4,12,$C07 dn G_4,12,$C07 dn E_4,12,$C07 dn G_4,12,$C07 dn B_4,12,$C07 dn F#5,12,$C07 dn E_5,12,$C07 dn B_4,12,$C07 dn G_4,12,$C07 dn B_4,12,$C07 dn E_5,12,$C07 dn E_5,12,$C07 dn G_5,12,$C07 dn G_5,12,$C07 dn ___,0,$E00 dn ___,0,$000 dn ___,0,$8ED dn E_4,12,$C07 dn G_4,12,$C07 dn B_4,12,$C07 dn E_5,12,$C07 dn D#4,12,$C07 dn A_4,12,$C07 dn D#5,12,$C07 dn F#5,12,$C07 dn D#5,12,$C07 dn B_4,12,$C07 dn F#4,12,$C07 dn D#4,12,$C07 dn B_3,12,$C07 dn D#4,12,$C07 dn F#4,12,$C07 dn B_4,12,$C07 dn G_4,12,$C07 dn E_4,12,$C07 dn G_4,12,$C07 dn B_4,12,$C07 dn F#5,12,$C07 dn E_5,12,$C07 dn B_4,12,$C07 dn G_4,12,$C07 dn B_4,12,$C07 dn E_5,12,$C07 dn E_5,12,$C07 dn B_4,12,$C07 dn B_4,12,$C07 dn ___,0,$000 dn ___,0,$E00 P16: dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn D#4,5,$000 dn ___,0,$C08 dn D#4,5,$000 dn ___,0,$C08 dn D#4,5,$000 dn ___,0,$C08 dn D#4,5,$000 dn ___,0,$C08 dn B_3,5,$000 dn ___,0,$C08 dn B_3,5,$000 dn ___,0,$C08 dn B_3,5,$000 dn ___,0,$C08 dn B_3,5,$000 dn ___,0,$C08 dn G_3,5,$000 dn ___,0,$C08 dn G_3,5,$000 dn ___,0,$C08 dn G_3,5,$000 dn ___,0,$C08 dn G_3,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn D#4,5,$000 dn ___,0,$C08 dn D#4,5,$000 dn ___,0,$C08 dn D#4,5,$000 dn ___,0,$C08 dn D#4,5,$000 dn ___,0,$C08 dn B_3,5,$000 dn ___,0,$C08 dn B_3,5,$000 dn ___,0,$C08 dn B_3,5,$000 dn ___,0,$C08 dn B_3,5,$000 dn ___,0,$C08 dn G_3,5,$E04 dn B_3,5,$E04 dn G_3,5,$E04 dn E_4,5,$E04 dn B_3,5,$E04 dn E_4,5,$E04 dn B_3,5,$E04 dn G_4,5,$E04 dn E_4,5,$000 dn ___,0,$C08 P17: dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn E_4,5,$000 dn ___,0,$C08 dn G_4,5,$000 dn ___,0,$C08 dn ___,0,$C06 dn ___,0,$C04 dn ___,0,$C02 dn ___,0,$C00 dn G_4,5,$000 dn ___,0,$C08 dn A_4,5,$000 dn ___,0,$C08 dn ___,0,$C06 dn ___,0,$C04 dn ___,0,$C02 dn ___,0,$C00 dn A_4,5,$000 dn ___,0,$C08 dn B_4,5,$000 dn ___,0,$C08 dn ___,0,$000 dn B_4,5,$000 dn ___,0,$C08 dn ___,0,$000 dn B_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn E_4,5,$000 dn ___,0,$C08 dn G_4,5,$000 dn ___,0,$C08 dn ___,0,$C06 dn ___,0,$C04 dn ___,0,$C02 dn ___,0,$C00 dn G_4,5,$000 dn ___,0,$C08 dn A_4,5,$000 dn ___,0,$C08 dn ___,0,$C06 dn ___,0,$C04 dn ___,0,$C02 dn ___,0,$C00 dn A_4,5,$000 dn ___,0,$C08 dn B_4,5,$000 dn ___,0,$C08 dn ___,0,$000 dn B_4,5,$000 dn ___,0,$C08 dn ___,0,$000 dn B_4,5,$000 dn ___,0,$C08 dn E_4,5,$000 dn ___,0,$C08 P18: dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 dn ___,0,$000 duty_instruments: itSquareinst1: db 8,128,240,128 itSquareinst2: db 8,64,240,128 itSquareinst3: db 8,128,240,128 itSquareinst4: db 8,192,240,128 itSquareinst5: db 8,0,241,128 itSquareinst6: db 8,64,241,128 itSquareinst7: db 8,128,241,128 itSquareinst8: db 8,192,241,128 itSquareinst9: db 8,192,240,128 itSquareinst10: db 8,128,240,128 itSquareinst11: db 8,128,240,128 itSquareinst12: db 8,128,241,128 itSquareinst13: db 8,128,240,128 itSquareinst14: db 8,128,240,128 itSquareinst15: db 8,128,240,128 wave_instruments: itWaveinst1: db 0,32,0,128 itWaveinst2: db 0,32,1,128 itWaveinst3: db 0,32,2,128 itWaveinst4: db 0,32,3,128 itWaveinst5: db 0,32,4,128 itWaveinst6: db 0,32,5,128 itWaveinst7: db 0,32,6,128 itWaveinst8: db 0,32,7,128 itWaveinst9: db 0,32,8,128 itWaveinst10: db 0,32,9,128 itWaveinst11: db 0,32,10,128 itWaveinst12: db 0,32,11,128 itWaveinst13: db 0,32,12,128 itWaveinst14: db 0,32,13,128 itWaveinst15: db 0,32,14,128 noise_instruments: itNoiseinst1: db 241,30,-5,-3,1,2,1,4 itNoiseinst2: db 241,0,14,5,2,-2,-4,4 itNoiseinst3: db 241,0,-14,9,10,10,10,10 itNoiseinst4: db 161,0,0,0,0,0,0,0 itNoiseinst5: db 65,0,0,0,0,0,0,0 itNoiseinst6: db 240,0,0,0,0,0,0,0 itNoiseinst7: db 240,0,0,0,0,0,0,0 itNoiseinst8: db 240,0,0,0,0,0,0,0 itNoiseinst9: db 240,0,0,0,0,0,0,0 itNoiseinst10: db 240,0,0,0,0,0,0,0 itNoiseinst11: db 240,0,0,0,0,0,0,0 itNoiseinst12: db 240,0,0,0,0,0,0,0 itNoiseinst13: db 240,0,0,0,0,0,0,0 itNoiseinst14: db 240,0,0,0,0,0,0,0 itNoiseinst15: db 240,0,0,0,0,0,0,0 routines: __hUGE_Routine_0: __end_hUGE_Routine_0: ret __hUGE_Routine_1: __end_hUGE_Routine_1: ret __hUGE_Routine_2: __end_hUGE_Routine_2: ret __hUGE_Routine_3: __end_hUGE_Routine_3: ret __hUGE_Routine_4: __end_hUGE_Routine_4: ret __hUGE_Routine_5: __end_hUGE_Routine_5: ret __hUGE_Routine_6: __end_hUGE_Routine_6: ret __hUGE_Routine_7: __end_hUGE_Routine_7: ret __hUGE_Routine_8: __end_hUGE_Routine_8: ret __hUGE_Routine_9: __end_hUGE_Routine_9: ret __hUGE_Routine_10: __end_hUGE_Routine_10: ret __hUGE_Routine_11: __end_hUGE_Routine_11: ret __hUGE_Routine_12: __end_hUGE_Routine_12: ret __hUGE_Routine_13: __end_hUGE_Routine_13: ret __hUGE_Routine_14: __end_hUGE_Routine_14: ret __hUGE_Routine_15: __end_hUGE_Routine_15: ret waves: wave0: db 0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255 wave1: db 0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255 wave2: db 0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255 wave3: db 0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255 wave4: db 0,1,18,35,52,69,86,103,120,137,154,171,188,205,222,239 wave5: db 254,220,186,152,118,84,50,16,18,52,86,120,154,188,222,255 wave6: db 122,205,219,117,33,19,104,189,220,151,65,1,71,156,221,184 wave7: db 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15 wave8: db 254,252,250,248,246,244,242,240,242,244,246,248,250,252,254,255 wave9: db 238,221,204,187,169,136,118,101,68,50,17,0,0,0,0,0 wave10: db 132,17,97,237,87,71,90,173,206,163,23,121,221,32,3,71 wave11: db 197,125,122,123,227,83,25,229,152,226,81,189,185,1,22,221 wave12: db 157,59,28,129,99,51,105,235,235,68,124,113,123,155,42,234 wave13: db 165,153,117,225,59,33,234,137,116,54,151,113,179,217,162,179 wave14: db 93,49,59,139,172,2,149,222,24,108,116,58,216,218,194,51 wave15: db 212,116,28,212,106,161,211,136,83,209,75,153,160,94,73,58
;; encoding: utf-8 ;; ff3_sound_driver.asm ;; ;; re-implementation of the sound driver. ;; ;; version: ;; 0.1.0 ;;================================================================================================= __FF3_SOUND_DRIVER_INCLUDED__ VERIFY_PC_TO_PATCH_END field.get_eligibility_flags ;==================================================================================================
mov ah, 0x0e ; attempt 3 ; Add the BIOS starting offset 0x7c00 to the memory address of the X ; and then dereference the contents of that pointer. ; We need the help of a different register 'bx' because 'mov al, [ax]' is illegal. mov al, "3" int 0x10 mov bx, the_secret add bx, 0x7c00 mov al, [bx] int 0x10 jmp $ ; infinite loop the_secret: ; ASCII code 0x58 ('X') is stored just before the zero-padding. ; On this code that is at byte 0x2d (check it out using 'xxd file.bin') db "X" ; zero padding and magic bios number times 510-($-$$) db 0 dw 0xaa55
# Calculates the N number of Fibonacci Sequence # $a0 = Fibonacci Number (N) # int fib(int n): return n < 2 ? n : fib(n-1) + fib(n-2) main: li $a0, 7 # N = 10 jal fib j exit fib: addi $sp, $sp, -8 # Space for two words sw $ra, 4($sp) # Store $ra on the stack move $v0, $a0 # Here, the return value is N($a0) slti $t0, $a0, 2 bne $t0, $zero, fibrt # Goes to return if N < 2 sw $a0, 0($sp) # Save a copy of N addi $a0, $a0, -1 # N-1 jal fib # fib(N-1) # When this line is reached, fib(N-1) is stored in $v0 lw $a0, 0($sp) sw $v0, 0($sp) # Store fib(N-1) on the stack addi $a0, $a0, -2 # N-2 jal fib # fib(N-2) # When this line is reached, fib(N-2) is stored in $v0 lw $v1, 0($sp) # Load fib(N-1) add $v0, $v0, $v1 # fib(N-1)+fib(N-2) fibrt: lw $ra, 4($sp) # Restore $ra addi $sp, $sp, 8 # Restore $sp jr $ra # Go back to caller exit: nop
;;;;;;;;;;;;;;;; ; test branching ;;;;;;;;;;;;;;;; ; required for execution on the NES .org $8000 ;;;;;;;;;;;;;;;; ; test JMP (indirect) ;;;;;;;;;;;;;;;; LDX #$00 ; reset registers LDA #$11 ; low byte of target address STA $0050 LDA #$80 ; high byte of target address STA $0051 JMP ($0050) ; jump to address specified at $0050 ($8012) LDX #$01 ; set X=1 (this shouldn't execute) ;;; this is offset $0011 in PRG ;;; NOP ; perform assertions: ; x = 0x0 ;;;;;;;;;;;;;;;; ; test JMP ;;;;;;;;;;;;;;;; LDA #$00 ; reset registers LDX #$00 JMP skip1 ; skip next instruction LDX #$01 ; set X register (this shouldn't execute) skip1: LDA #$01 ; a = 1 NOP ; perform assertions: ; a = 0x01 ; x = 0x00 ;;;;;;;;;;;;;;;; ; test JSR ;;;;;;;;;;;;;;;; LDX #$05 ; set x JSR subroutine ; jump to subroutine INX ; increment X JMP end_jsr_test subroutine: INX ; increment X RTS ; return LDX #$00 ; reset X (shouldn't execute) end_jsr_test: NOP ; perform assertions: ; x = 0x07 ;;;;;;;;;;;;;;;; ; test BEQ, BNE ;;;;;;;;;;;;;;;; LDX #$00 ; reset X LDY #$00 ; reset Y LDA #$00 ; set a=0 (sets zero flag) BNE not_equal ; this should not branch BEQ equal ; this should branch equal: LDX #$01 ; set x=1 JMP equ_part_2 ; skip the not_equal section not_equal: ; this should not be reached LDX #$02 ; set x=2 (should not execute) equ_part_2: LDA #$01 ; set a=1 (clears zero flag) BEQ equal_2 ; this should not branch BNE not_equal_2 ; this should branch equal_2: ; this shouldn't be reached LDY #$01 ; set y=1 JMP equ_end ; skip the not_equal_2 section not_equal_2: LDY #$02 ; set y=2 equ_end: NOP ; perform assertions: ; x = 1 ; y = 2 ;;;;;;;;;;;;;;;; ; test BCC, BCS ;;;;;;;;;;;;;;;; LDX #$00 ; reset X LDY #$00 ; reset Y SEC ; set carry flag BCC no_carry ; this should not branch BCS carry ; this should branch carry: LDX #$01 ; set x=1 JMP carry_part_2 ; skip the no_carry section no_carry: ; this should not be reached LDX #$02 ; set x=2 carry_part_2: CLC ; clear carry flag BCS carry_2 ; this should not branch BCC no_carry_2 ; this should branch carry_2: ; this should not be reached LDY #$01 ; set y=1 JMP carry_end ; skip the no_carry_2 section no_carry_2: LDY #$02 ; set y=2 carry_end: NOP ; perform assertions: ; x = 1 ; y = 2 ;;;;;;;;;;;;;;;; ; test BPL, BMI ;;;;;;;;;;;;;;;; LDX #$00 ; reset X LDY #$00 ; reset Y LDA #$01 ; set a to be positive (clears negative flag) BMI minus ; this should not branch BPL plus ; this should branch plus: LDX #$01 ; set x=1 JMP sign_part_2 ; skip the minus section minus: ; this should not be reached LDX #$02 ; set x=2 sign_part_2: LDA #$80 ; set a to be negative (sets negative flag) BPL plus_2 ; this should not branch BMI minus_2 ; this should branch plus_2: ; this should not be reached LDY #$01 ; set y=1 JMP sign_end ; skip the no_carry_2 section minus_2: LDY #$02 ; set y=2 sign_end: NOP ; perform assertions: ; x = 1 ; y = 2 ; we rely on the test supervisor to set the overflow ; flag here to avoid relying on arithmetic instructions ;;;;;;;;;;;;;;;; ; test BVS, BVC ;;;;;;;;;;;;;;;; LDX #$00 ; reset X LDY #$00 ; reset Y BVC no_overflow ; this should not branch BVS overflow ; this should branch overflow: LDX #$01 ; set x=1 JMP overflow_part_2 ; skip the no_carry section no_overflow: ; this should not be reached LDX #$02 ; set x=2 overflow_part_2: CLV ; clear overflow flag BVS overflow_2 ; this should not branch BVC no_overflow_2 ; this should branch overflow_2: ; this should not be reached LDY #$01 ; set y=1 JMP overflow_end ; skip the no_overflow_2 section no_overflow_2: LDY #$02 ; set y=2 overflow_end: NOP ; perform assertions: ; x = 1 ; y = 2
; ; Sprite Rendering Routine ; original code by Patrick Davidson (TI 85) ; modified by Stefano Bodrato - Jan 2001 ; ; Sept 2003 - Stefano: Fixed bug for sprites wider than 8. ; ; Much More Generic version ; Uses plotpixel, respixel and xorpixel ; ; ; $Id: putsprite2.asm,v 1.8 2016-07-02 09:01:35 dom Exp $ ; SECTION code_clib PUBLIC putsprite PUBLIC _putsprite EXTERN swapgfxbk EXTERN __graphics_end EXTERN plotpixel EXTERN respixel EXTERN xorpixel ; __gfx_coords: h,l (vert-horz) ; sprite: (ix) .putsprite ._putsprite call swapgfxbk ld hl,2 add hl,sp ld e,(hl) inc hl ld d,(hl) ;sprite address push ix push de pop ix inc hl ld e,(hl) inc hl inc hl ld d,(hl) ; x and y __gfx_coords inc hl inc hl ld a,(hl) ; and/or/xor mode ld h,d ld l,e cp 166 ; and(hl) opcode jr z,doand cp 182 ; or(hl) opcode jp z,door ; 182 - or ; 174 - xor .doxor ld a,(ix+0) ; Width ld b,(ix+1) ; Height .oloopx push bc ;Save # of rows push af ;ld b,a ;Load width ld b,0 ; Better, start from zero !! ld c,(ix+2) ;Load one line of image .iloopx sla c ;Test leftmost pixel jr nc,noplotx ;See if a plot is needed pop af push af push hl ;push bc ; this should be done by the called routine push de ld a,h add a,b ld h,a call xorpixel pop de ;pop bc pop hl .noplotx inc b ; witdh counter pop af push af cp b ; end of row ? jr nz,noblkx inc ix ld c,(ix+2) ;Load next byte of image jr noblockx .noblkx ld a,b ; next byte in row ? ;dec a and a jr z,iloopx and 7 jr nz,iloopx .blockx inc ix ld c,(ix+2) ;Load next byte of image jr iloopx .noblockx inc l pop af pop bc ;Restore data djnz oloopx ;pop ix jp __graphics_end .doand ld a,(ix+0) ; Width ld b,(ix+1) ; Height .oloopa push bc ;Save # of rows push af ;ld b,a ;Load width ld b,0 ; Better, start from zero !! ld c,(ix+2) ;Load one line of image .iloopa sla c ;Test leftmost pixel jr nc,noplota ;See if a plot is needed pop af push af push hl ;push bc ; this should be done by the called routine push de ld a,h add a,b ld h,a call respixel pop de ;pop bc pop hl .noplota inc b ; witdh counter pop af push af cp b ; end of row ? jr nz,noblka inc ix ld c,(ix+2) ;Load next byte of image jr noblocka .noblka ld a,b ; next byte in row ? ;dec a and a jr z,iloopa and 7 jr nz,iloopa .blocka inc ix ld c,(ix+2) ;Load next byte of image jr iloopa .noblocka inc l pop af pop bc ;Restore data djnz oloopa ;pop ix jp __graphics_end .door ld a,(ix+0) ; Width ld b,(ix+1) ; Height .oloopo push bc ;Save # of rows push af ;ld b,a ;Load width ld b,0 ; Better, start from zero !! ld c,(ix+2) ;Load one line of image .iloopo sla c ;Test leftmost pixel jr nc,noploto ;See if a plot is needed pop af push af push hl ;push bc ; this should be done by the called routine push de ld a,h add a,b ld h,a call plotpixel pop de ;pop bc pop hl .noploto inc b ; witdh counter pop af push af cp b ; end of row ? jr nz,noblko inc ix ld c,(ix+2) ;Load next byte of image jr noblocko .noblko ld a,b ; next byte in row ? ;dec a and a jr z,iloopo and 7 jr nz,iloopo .blocko inc ix ld c,(ix+2) ;Load next byte of image jr iloopo .noblocko ;djnz iloopo inc l pop af pop bc ;Restore data djnz oloopo ;pop ix jp __graphics_end
.global s_prepare_buffers s_prepare_buffers: ret .global s_faulty_load s_faulty_load: push %r14 push %r8 push %rax push %rbp push %rcx push %rsi // Faulty Load lea addresses_WT+0x18f5a, %r8 nop nop nop inc %rcx movups (%r8), %xmm3 vpextrq $0, %xmm3, %rbp lea oracles, %r8 and $0xff, %rbp shlq $12, %rbp mov (%r8,%rbp,1), %rbp pop %rsi pop %rcx pop %rbp pop %rax pop %r8 pop %r14 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'size': 4, 'NT': False, 'type': 'addresses_WT', 'same': False, 'AVXalign': False, 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'size': 16, 'NT': False, 'type': 'addresses_WT', 'same': True, 'AVXalign': False, 'congruent': 0}} <gen_prepare_buffer> {'00': 21829} 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 */
; A167498: a(n) = 6+32*n^2+8*n*(7+8*n^2)/3. ; 6,78,342,926,1958,3566,5878,9022,13126,18318,24726,32478,41702,52526,65078,79486,95878,114382,135126,158238,183846,212078,243062,276926,313798,353806,397078,443742,493926,547758,605366,666878,732422,802126,876118,954526,1037478,1125102,1217526,1314878,1417286,1524878,1637782,1756126,1880038,2009646,2145078,2286462,2433926,2587598,2747606,2914078,3087142,3266926,3453558,3647166,3847878,4055822,4271126,4493918,4724326,4962478,5208502,5462526,5724678,5995086,6273878,6561182,6857126,7161838,7475446,7798078,8129862,8470926,8821398,9181406,9551078,9930542,10319926,10719358,11128966,11548878,11979222,12420126,12871718,13334126,13807478,14291902,14787526,15294478,15812886,16342878,16884582,17438126,18003638,18581246,19171078,19773262,20387926,21015198,21655206,22308078,22973942,23652926,24345158,25050766,25769878,26502622,27249126,28009518,28783926,29572478,30375302,31192526,32024278,32870686,33731878,34607982,35499126,36405438,37327046,38264078,39216662,40184926,41168998,42169006,43185078,44217342,45265926,46330958,47412566,48510878,49626022,50758126,51907318,53073726,54257478,55458702,56677526,57914078,59168486,60440878,61731382,63040126,64367238,65712846,67077078,68460062,69861926,71282798,72722806,74182078,75660742,77158926,78676758,80214366,81771878,83349422,84947126,86565118,88203526,89862478,91542102,93242526,94963878,96706286,98469878,100254782,102061126,103889038,105738646,107610078,109503462,111418926,113356598,115316606,117299078,119304142,121331926,123382558,125456166,127552878,129672822,131816126,133982918,136173326,138387478,140625502,142887526,145173678,147484086,149818878,152178182,154562126,156970838,159404446,161863078,164346862,166855926,169390398,171950406,174536078,177147542,179784926,182448358,185137966,187853878,190596222,193365126,196160718,198983126,201832478,204708902,207612526,210543478,213501886,216487878,219501582,222543126,225612638,228710246,231836078,234990262,238172926,241384198,244624206,247893078,251190942,254517926,257874158,261259766,264674878,268119622,271594126,275098518,278632926,282197478,285792302,289417526,293073278,296759686,300476878,304224982,308004126,311814438,315656046,319529078,323433662,327369926,331337998 mov $1,1 add $1,$0 add $1,$0 pow $1,3 add $1,$0 div $1,3 mul $1,8 add $1,6
.data inp1: .asciiz "Enter first integer: " inp2: .asciiz "Enter second intger: " out: .asciiz "Product is: " .text .globl main .ent main main: # print input message 1 li $v0, 4 la $a0, inp1 syscall # get int input li $v0, 5 syscall move $t0, $v0 # print input message 2 li $v0, 4 la $a0, inp2 syscall # get int input li $v0, 5 syscall move $t1, $v0 #calculations mult $t0, $t1 #result mflo $s0 mfhi $s1 add $s0, $s0, $s1 # print output li $v0, 4 la $a0, out syscall li $v0, 1 move $a0, $s0 syscall jr $ra .end main
// **************************************************************************** // // CEchoGals_power.cpp // // Power management functions for the CEchoGals driver class. // Set editor tabs to 3 for your viewing pleasure. // // ---------------------------------------------------------------------------- // // This file is part of Echo Digital Audio's generic driver library. // Copyright Echo Digital Audio Corporation (c) 1998 - 2005 // All rights reserved // www.echoaudio.com // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // **************************************************************************** #include "CEchoGals.h" //=========================================================================== // // Tell the hardware to go into a low-power state - the converters are // shut off and the DSP powers down. // //=========================================================================== ECHOSTATUS CEchoGals::GoComatose() { // // Pass the call through to the DSP comm object // return GetDspCommObject()->GoComatose(); } // GoComatose //=========================================================================== // // Tell the hardware to wake up - go back to the full-power state // // You can call WakeUp() if you just want to be sure // that the firmware is loaded OK // //=========================================================================== ECHOSTATUS CEchoGals::WakeUp() { // // Load the firmware // ECHOSTATUS Status; CDspCommObject *pDCO = GetDspCommObject(); Status = pDCO->LoadFirmware(); return Status; } // WakeUp
// Fill out your copyright notice in the Description page of Project Settings. #include "BattleTankReprise.h" #include "TankAIController.h" #include "TankAimingComponent.h" #include "tank.h" void ATankAIController::OnTankDeath() { APawn* Tank = GetPawn(); if (!Tank) { return; } UE_LOG(LogTemp, Warning, TEXT("AI Tank died")); Tank->DetachFromControllerPendingDestroy(); } void ATankAIController::SetPawn(APawn* InPawn) { Super::SetPawn(InPawn); if (InPawn) { ATank* PossessedTank = Cast<ATank>(InPawn); if (!ensure(PossessedTank)) { return; } //subscribe our local method to the tank's death event PossessedTank->OnDeath.AddUniqueDynamic(this, &ATankAIController::OnTankDeath); } } void ATankAIController::Tick(float DeltaSeconds) { Super::Tick(DeltaSeconds); APawn* Tank = GetPawn(); if (!Tank) { return; } AimAtPlayerTank(); EFiringStatus FiringStatus = Tank->FindComponentByClass<UTankAimingComponent>()->GetFiringState(); if (FiringStatus == EFiringStatus::Ready) { Tank->FindComponentByClass<UTankAimingComponent>()->Fire(); } MoveToActor(GetWorld()->GetFirstPlayerController()->GetPawn(), AcceptanceRadius);//TODO check radius is in cm } void ATankAIController::AimAtPlayerTank() { UTankAimingComponent* TankAimingComponent = GetPawn()->FindComponentByClass<UTankAimingComponent>(); if (!ensure(TankAimingComponent)) { return; } APawn* Tank = GetWorld()->GetFirstPlayerController()->GetPawn(); if (!Tank) { return; //probably dead } TankAimingComponent->AimAt(Tank->GetActorLocation()); }
; 0 - POP that 0 leaw $SP, %A movw (%A), %A decw %A movw (%A), %D leaw $THAT, %A movw (%A), %S leaw $0, %A addw %S, %A, %A movw %D, (%A) leaw $SP, %A movw (%A), %A decw %A movw %A, %S leaw $SP, %A movw %S, (%A) ; 1 - POP that 1 leaw $SP, %A movw (%A), %A decw %A movw (%A), %D leaw $THAT, %A movw (%A), %S leaw $1, %A addw %S, %A, %A movw %D, (%A) leaw $SP, %A movw (%A), %A decw %A movw %A, %S leaw $SP, %A movw %S, (%A) ; 2 - POP that 2 leaw $SP, %A movw (%A), %A decw %A movw (%A), %D leaw $THAT, %A movw (%A), %S leaw $2, %A addw %S, %A, %A movw %D, (%A) leaw $SP, %A movw (%A), %A decw %A movw %A, %S leaw $SP, %A movw %S, (%A) ; End
; A044382: Numbers n such that string 5,0 occurs in the base 10 representation of n but not of n-1. ; Submitted by Jamie Morken(s3) ; 50,150,250,350,450,500,550,650,750,850,950,1050,1150,1250,1350,1450,1500,1550,1650,1750,1850,1950,2050,2150,2250,2350,2450,2500,2550,2650,2750,2850,2950,3050,3150,3250,3350,3450,3500 add $0,1 mul $0,10 mov $1,$0 add $0,6 div $0,11 sub $1,6 div $1,11 add $1,3 add $0,$1 sub $0,3 mul $0,50
/**************************************************************************** ** ** Copyright (C) 2015 The Qt Company Ltd. ** Contact: http://www.qt.io/licensing/ ** ** This file is part of the examples of the Qt Toolkit. ** ** $QT_BEGIN_LICENSE:BSD$ ** You may use this file under the terms of the BSD license as follows: ** ** "Redistribution and use in source and binary forms, with or without ** modification, are permitted provided that the following conditions are ** met: ** * Redistributions of source code must retain the above copyright ** notice, this list of conditions and the following disclaimer. ** * Redistributions in binary form must reproduce the above copyright ** notice, this list of conditions and the following disclaimer in ** the documentation and/or other materials provided with the ** distribution. ** * Neither the name of The Qt Company Ltd nor the names of its ** contributors may be used to endorse or promote products derived ** from this software without specific prior written permission. ** ** ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." ** ** $QT_END_LICENSE$ ** ****************************************************************************/ #include <QRasterWindow> #include <QPainter> #include <QGuiApplication> #include <QMatrix4x4> #include <QTimer> static QPainterPath painterPathForTriangle() { static const QPointF bottomLeft(-1.0, -1.0); static const QPointF top(0.0, 1.0); static const QPointF bottomRight(1.0, -1.0); QPainterPath path(bottomLeft); path.lineTo(top); path.lineTo(bottomRight); path.closeSubpath(); return path; } class PaintedWindow : public QRasterWindow { Q_OBJECT public: PaintedWindow() { m_view.lookAt(QVector3D(3,1,1), QVector3D(0,0,0), QVector3D(0,1,0)); m_timer.setInterval(16); connect(&m_timer, SIGNAL(timeout()), this, SLOT(update())); m_timer.start(); } protected: void paintEvent(QPaintEvent *) { QPainter p(this); p.fillRect(QRect(0,0,width(),height()),Qt::gray); p.setWorldTransform(m_window_matrix.toTransform()); QMatrix4x4 mvp = m_projection * m_view * m_model; p.setTransform(mvp.toTransform(), true); p.fillPath(painterPathForTriangle(), m_brush); m_model.rotate(1, 0, 1, 0); } void resizeEvent(QResizeEvent *) { m_window_matrix = QTransform(); m_window_matrix.translate(width() / 2.0, height() / 2.0); m_window_matrix.scale(width() / 2.0, -height() / 2.0); m_projection.setToIdentity(); m_projection.perspective(45.f, qreal(width()) / qreal(height()), 0.1f, 100.f); QLinearGradient gradient(QPointF(-1,-1), QPointF(1,1)); gradient.setColorAt(0, Qt::red); gradient.setColorAt(1, Qt::green); m_brush = QBrush(gradient); } private: QMatrix4x4 m_window_matrix; QMatrix4x4 m_projection; QMatrix4x4 m_view; QMatrix4x4 m_model; QBrush m_brush; QTimer m_timer; }; int main (int argc, char **argv) { QGuiApplication app(argc, argv); PaintedWindow window; window.create(); window.show(); return app.exec(); } #include "main.moc"
; A127228: a(n)= numerator of ((n + 4)! - (n - 4)!)/(n!). ; 40319,362879,1814399,6652799,19958399,51891839,121080959,259459199,518918399,980179199,1764322559,3047466239,5079110399,8204716799,12893126399,19769460479,29654190719,43609103999,62990927999 add $0,8 bin $0,8 sub $0,1 mul $0,40320 add $0,40319
; A267442: Middle column of the "Rule 129" elementary cellular automaton starting with a single ON (black) cell. ; 1,0,1,0,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 mov $1,2 mov $2,7142 lpb $1,1 mov $1,3 lpb $0,1 mul $1,$0 div $0,2 gcd $1,$2 lpe lpe sub $1,1
/********************************************************************************************************************* * @file startup_XMC4300.S * @brief CMSIS Core Device Startup File for Infineon XMC4300 Device Series * @version V1.1 * @date 05 Jan 2016 * * @cond ********************************************************************************************************************* * Copyright (c) 2015-2020, Infineon Technologies AG * All rights reserved. * * Boost Software License - Version 1.0 - August 17th, 2003 * * Permission is hereby granted, free of charge, to any person or organization * obtaining a copy of the software and accompanying documentation covered by * this license (the "Software") to use, reproduce, display, distribute, * execute, and transmit the Software, and to prepare derivative works of the * Software, and to permit third-parties to whom the Software is furnished to * do so, all subject to the following: * * The copyright notices in the Software and this entire statement, including * the above license grant, this restriction and the following disclaimer, * must be included in all copies of the Software, in whole or in part, and * all derivative works of the Software, unless such copies or derivative * works are solely in the form of machine-executable object code generated by * a source language processor. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * * To improve the quality of the software, users are encouraged to share * modifications, enhancements or bug fixes with Infineon Technologies AG * at XMCSupport@infineon.com. ********************************************************************************************************************* * **************************** Change history ******************************** * V1.0,Nov, 19, 2015 JFT: Initial version * V1.1,Jan, 05, 2016 JFT: Fix .reset section attributes * * @endcond */ /* ===========START : MACRO DEFINITION MACRO DEFINITION ================== */ .macro Entry Handler .long \Handler .endm .macro Insert_ExceptionHandler Handler_Func .weak \Handler_Func .thumb_set \Handler_Func, Default_Handler .endm /* =============END : MACRO DEFINITION MACRO DEFINITION ================== */ /* ================== START OF VECTOR TABLE DEFINITION ====================== */ /* Vector Table - This gets programed into VTOR register by onchip BootROM */ .syntax unified .eabi_attribute Tag_ABI_align_preserved, 1 .section reset, "ax", %progbits .align 2 .globl __Vectors .type __Vectors, %object __Vectors: .long Image$$ARM_LIB_STACK$$ZI$$Limit /* Top of Stack */ .long Reset_Handler /* Reset Handler */ Entry NMI_Handler /* NMI Handler */ Entry HardFault_Handler /* Hard Fault Handler */ Entry MemManage_Handler /* MPU Fault Handler */ Entry BusFault_Handler /* Bus Fault Handler */ Entry UsageFault_Handler /* Usage Fault Handler */ .long 0 /* Reserved */ .long 0 /* Reserved */ .long 0 /* Reserved */ .long 0 /* Reserved */ Entry SVC_Handler /* SVCall Handler */ Entry DebugMon_Handler /* Debug Monitor Handler */ .long 0 /* Reserved */ Entry PendSV_Handler /* PendSV Handler */ Entry SysTick_Handler /* SysTick Handler */ /* Interrupt Handlers for Service Requests (SR) from XMC4300 Peripherals */ Entry SCU_0_IRQHandler /* Handler name for SR SCU_0 */ Entry ERU0_0_IRQHandler /* Handler name for SR ERU0_0 */ Entry ERU0_1_IRQHandler /* Handler name for SR ERU0_1 */ Entry ERU0_2_IRQHandler /* Handler name for SR ERU0_2 */ Entry ERU0_3_IRQHandler /* Handler name for SR ERU0_3 */ Entry ERU1_0_IRQHandler /* Handler name for SR ERU1_0 */ Entry ERU1_1_IRQHandler /* Handler name for SR ERU1_1 */ Entry ERU1_2_IRQHandler /* Handler name for SR ERU1_2 */ Entry ERU1_3_IRQHandler /* Handler name for SR ERU1_3 */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ Entry PMU0_0_IRQHandler /* Handler name for SR PMU0_0 */ .long 0 /* Not Available */ Entry VADC0_C0_0_IRQHandler /* Handler name for SR VADC0_C0_0 */ Entry VADC0_C0_1_IRQHandler /* Handler name for SR VADC0_C0_1 */ Entry VADC0_C0_2_IRQHandler /* Handler name for SR VADC0_C0_1 */ Entry VADC0_C0_3_IRQHandler /* Handler name for SR VADC0_C0_3 */ Entry VADC0_G0_0_IRQHandler /* Handler name for SR VADC0_G0_0 */ Entry VADC0_G0_1_IRQHandler /* Handler name for SR VADC0_G0_1 */ Entry VADC0_G0_2_IRQHandler /* Handler name for SR VADC0_G0_2 */ Entry VADC0_G0_3_IRQHandler /* Handler name for SR VADC0_G0_3 */ Entry VADC0_G1_0_IRQHandler /* Handler name for SR VADC0_G1_0 */ Entry VADC0_G1_1_IRQHandler /* Handler name for SR VADC0_G1_1 */ Entry VADC0_G1_2_IRQHandler /* Handler name for SR VADC0_G1_2 */ Entry VADC0_G1_3_IRQHandler /* Handler name for SR VADC0_G1_3 */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ Entry DAC0_0_IRQHandler /* Handler name for SR DAC0_0 */ Entry DAC0_1_IRQHandler /* Handler name for SR DAC0_0 */ Entry CCU40_0_IRQHandler /* Handler name for SR CCU40_0 */ Entry CCU40_1_IRQHandler /* Handler name for SR CCU40_1 */ Entry CCU40_2_IRQHandler /* Handler name for SR CCU40_2 */ Entry CCU40_3_IRQHandler /* Handler name for SR CCU40_3 */ Entry CCU41_0_IRQHandler /* Handler name for SR CCU41_0 */ Entry CCU41_1_IRQHandler /* Handler name for SR CCU41_1 */ Entry CCU41_2_IRQHandler /* Handler name for SR CCU41_2 */ Entry CCU41_3_IRQHandler /* Handler name for SR CCU41_3 */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ Entry CCU80_0_IRQHandler /* Handler name for SR CCU80_0 */ Entry CCU80_1_IRQHandler /* Handler name for SR CCU80_1 */ Entry CCU80_2_IRQHandler /* Handler name for SR CCU80_2 */ Entry CCU80_3_IRQHandler /* Handler name for SR CCU80_3 */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ Entry CAN0_0_IRQHandler /* Handler name for SR CAN0_0 */ Entry CAN0_1_IRQHandler /* Handler name for SR CAN0_1 */ Entry CAN0_2_IRQHandler /* Handler name for SR CAN0_2 */ Entry CAN0_3_IRQHandler /* Handler name for SR CAN0_3 */ Entry CAN0_4_IRQHandler /* Handler name for SR CAN0_4 */ Entry CAN0_5_IRQHandler /* Handler name for SR CAN0_5 */ Entry CAN0_6_IRQHandler /* Handler name for SR CAN0_6 */ Entry CAN0_7_IRQHandler /* Handler name for SR CAN0_7 */ Entry USIC0_0_IRQHandler /* Handler name for SR USIC0_0 */ Entry USIC0_1_IRQHandler /* Handler name for SR USIC0_1 */ Entry USIC0_2_IRQHandler /* Handler name for SR USIC0_2 */ Entry USIC0_3_IRQHandler /* Handler name for SR USIC0_3 */ Entry USIC0_4_IRQHandler /* Handler name for SR USIC0_4 */ Entry USIC0_5_IRQHandler /* Handler name for SR USIC0_5 */ Entry USIC1_0_IRQHandler /* Handler name for SR USIC1_0 */ Entry USIC1_1_IRQHandler /* Handler name for SR USIC1_1 */ Entry USIC1_2_IRQHandler /* Handler name for SR USIC1_2 */ Entry USIC1_3_IRQHandler /* Handler name for SR USIC1_3 */ Entry USIC1_4_IRQHandler /* Handler name for SR USIC1_4 */ Entry USIC1_5_IRQHandler /* Handler name for SR USIC1_5 */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ .long 0 /* Not Available */ Entry LEDTS0_0_IRQHandler /* Handler name for SR LEDTS0_0 */ .long 0 /* Not Available */ Entry FCE0_0_IRQHandler /* Handler name for SR FCE0_0 */ Entry GPDMA0_0_IRQHandler /* Handler name for SR GPDMA0_0 */ Entry SDMMC0_0_IRQHandler /* Handler name for SR SDMMC0_0 */ Entry USB0_0_IRQHandler /* Handler name for SR USB0_0 */ Entry ETH0_0_IRQHandler /* Handler name for SR ETH0_0 */ Entry ECAT0_0_IRQHandler /* Handler name for SR ECAT0_0 */ .long 0 /* Not Available */ .long 0 /* Not Available */ .size __Vectors, . - __Vectors /* ================== END OF VECTOR TABLE DEFINITION ======================= */ /* ================== START OF VECTOR ROUTINES ============================= */ .align 1 .thumb /* Reset Handler */ .thumb_func .globl Reset_Handler .type Reset_Handler, %function Reset_Handler: ldr sp,=Image$$ARM_LIB_STACK$$ZI$$Limit #ifndef __SKIP_SYSTEM_INIT ldr r0, =SystemInit blx r0 #endif ldr r0, =__main blx r0 .pool .size Reset_Handler,.-Reset_Handler /* ======================================================================== */ /* ========== START OF EXCEPTION HANDLER DEFINITION ======================== */ /* Default exception Handlers - Users may override this default functionality by defining handlers of the same name in their C code */ .align 1 .thumb_func .weak Default_Handler .type Default_Handler, %function Default_Handler: b . .size Default_Handler, . - Default_Handler Insert_ExceptionHandler NMI_Handler Insert_ExceptionHandler HardFault_Handler Insert_ExceptionHandler MemManage_Handler Insert_ExceptionHandler BusFault_Handler Insert_ExceptionHandler UsageFault_Handler Insert_ExceptionHandler SVC_Handler Insert_ExceptionHandler DebugMon_Handler Insert_ExceptionHandler PendSV_Handler Insert_ExceptionHandler SysTick_Handler Insert_ExceptionHandler SCU_0_IRQHandler Insert_ExceptionHandler ERU0_0_IRQHandler Insert_ExceptionHandler ERU0_1_IRQHandler Insert_ExceptionHandler ERU0_2_IRQHandler Insert_ExceptionHandler ERU0_3_IRQHandler Insert_ExceptionHandler ERU1_0_IRQHandler Insert_ExceptionHandler ERU1_1_IRQHandler Insert_ExceptionHandler ERU1_2_IRQHandler Insert_ExceptionHandler ERU1_3_IRQHandler Insert_ExceptionHandler PMU0_0_IRQHandler Insert_ExceptionHandler VADC0_C0_0_IRQHandler Insert_ExceptionHandler VADC0_C0_1_IRQHandler Insert_ExceptionHandler VADC0_C0_2_IRQHandler Insert_ExceptionHandler VADC0_C0_3_IRQHandler Insert_ExceptionHandler VADC0_G0_0_IRQHandler Insert_ExceptionHandler VADC0_G0_1_IRQHandler Insert_ExceptionHandler VADC0_G0_2_IRQHandler Insert_ExceptionHandler VADC0_G0_3_IRQHandler Insert_ExceptionHandler VADC0_G1_0_IRQHandler Insert_ExceptionHandler VADC0_G1_1_IRQHandler Insert_ExceptionHandler VADC0_G1_2_IRQHandler Insert_ExceptionHandler VADC0_G1_3_IRQHandler Insert_ExceptionHandler DAC0_0_IRQHandler Insert_ExceptionHandler DAC0_1_IRQHandler Insert_ExceptionHandler CCU40_0_IRQHandler Insert_ExceptionHandler CCU40_1_IRQHandler Insert_ExceptionHandler CCU40_2_IRQHandler Insert_ExceptionHandler CCU40_3_IRQHandler Insert_ExceptionHandler CCU41_0_IRQHandler Insert_ExceptionHandler CCU41_1_IRQHandler Insert_ExceptionHandler CCU41_2_IRQHandler Insert_ExceptionHandler CCU41_3_IRQHandler Insert_ExceptionHandler CCU80_0_IRQHandler Insert_ExceptionHandler CCU80_1_IRQHandler Insert_ExceptionHandler CCU80_2_IRQHandler Insert_ExceptionHandler CCU80_3_IRQHandler Insert_ExceptionHandler CAN0_0_IRQHandler Insert_ExceptionHandler CAN0_1_IRQHandler Insert_ExceptionHandler CAN0_2_IRQHandler Insert_ExceptionHandler CAN0_3_IRQHandler Insert_ExceptionHandler CAN0_4_IRQHandler Insert_ExceptionHandler CAN0_5_IRQHandler Insert_ExceptionHandler CAN0_6_IRQHandler Insert_ExceptionHandler CAN0_7_IRQHandler Insert_ExceptionHandler USIC0_0_IRQHandler Insert_ExceptionHandler USIC0_1_IRQHandler Insert_ExceptionHandler USIC0_2_IRQHandler Insert_ExceptionHandler USIC0_3_IRQHandler Insert_ExceptionHandler USIC0_4_IRQHandler Insert_ExceptionHandler USIC0_5_IRQHandler Insert_ExceptionHandler USIC1_0_IRQHandler Insert_ExceptionHandler USIC1_1_IRQHandler Insert_ExceptionHandler USIC1_2_IRQHandler Insert_ExceptionHandler USIC1_3_IRQHandler Insert_ExceptionHandler USIC1_4_IRQHandler Insert_ExceptionHandler USIC1_5_IRQHandler Insert_ExceptionHandler LEDTS0_0_IRQHandler Insert_ExceptionHandler FCE0_0_IRQHandler Insert_ExceptionHandler GPDMA0_0_IRQHandler Insert_ExceptionHandler SDMMC0_0_IRQHandler Insert_ExceptionHandler USB0_0_IRQHandler Insert_ExceptionHandler ETH0_0_IRQHandler Insert_ExceptionHandler ECAT0_0_IRQHandler /* ============= END OF INTERRUPT HANDLER DEFINITION ====================== */ .end
// Copyright 2012 the V8 project authors. All rights reserved. // Redistribution and use in source and binary forms, with or without // modification, are permitted provided that the following conditions are // met: // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. // * Redistributions in binary form must reproduce the above // copyright notice, this list of conditions and the following // disclaimer in the documentation and/or other materials provided // with the distribution. // * Neither the name of Google Inc. nor the names of its // contributors may be used to endorse or promote products derived // from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "v8.h" #include "accessors.h" #include "api.h" #include "bootstrapper.h" #include "codegen.h" #include "compilation-cache.h" #include "debug.h" #include "deoptimizer.h" #include "global-handles.h" #include "heap-profiler.h" #include "incremental-marking.h" #include "liveobjectlist-inl.h" #include "mark-compact.h" #include "natives.h" #include "objects-visiting.h" #include "objects-visiting-inl.h" #include "runtime-profiler.h" #include "scopeinfo.h" #include "snapshot.h" #include "store-buffer.h" #include "v8threads.h" #include "vm-state-inl.h" #if V8_TARGET_ARCH_ARM && !V8_INTERPRETED_REGEXP #include "regexp-macro-assembler.h" #include "arm/regexp-macro-assembler-arm.h" #endif #if V8_TARGET_ARCH_MIPS && !V8_INTERPRETED_REGEXP #include "regexp-macro-assembler.h" #include "mips/regexp-macro-assembler-mips.h" #endif namespace v8 { namespace internal { static Mutex* gc_initializer_mutex = OS::CreateMutex(); Heap::Heap() : isolate_(NULL), // semispace_size_ should be a power of 2 and old_generation_size_ should be // a multiple of Page::kPageSize. #if defined(ANDROID) #define LUMP_OF_MEMORY (128 * KB) code_range_size_(0), #elif defined(V8_TARGET_ARCH_X64) #define LUMP_OF_MEMORY (2 * MB) code_range_size_(512*MB), #else #define LUMP_OF_MEMORY MB code_range_size_(0), #endif reserved_semispace_size_(8 * Max(LUMP_OF_MEMORY, Page::kPageSize)), max_semispace_size_(8 * Max(LUMP_OF_MEMORY, Page::kPageSize)), initial_semispace_size_(Page::kPageSize), max_old_generation_size_(700ul * LUMP_OF_MEMORY), max_executable_size_(128l * LUMP_OF_MEMORY), // Variables set based on semispace_size_ and old_generation_size_ in // ConfigureHeap (survived_since_last_expansion_, external_allocation_limit_) // Will be 4 * reserved_semispace_size_ to ensure that young // generation can be aligned to its size. survived_since_last_expansion_(0), sweep_generation_(0), always_allocate_scope_depth_(0), linear_allocation_scope_depth_(0), contexts_disposed_(0), scan_on_scavenge_pages_(0), new_space_(this), old_pointer_space_(NULL), old_data_space_(NULL), code_space_(NULL), map_space_(NULL), cell_space_(NULL), lo_space_(NULL), gc_state_(NOT_IN_GC), gc_post_processing_depth_(0), ms_count_(0), gc_count_(0), unflattened_strings_length_(0), #ifdef DEBUG allocation_allowed_(true), allocation_timeout_(0), disallow_allocation_failure_(false), debug_utils_(NULL), #endif // DEBUG new_space_high_promotion_mode_active_(false), old_gen_promotion_limit_(kMinimumPromotionLimit), old_gen_allocation_limit_(kMinimumAllocationLimit), old_gen_limit_factor_(1), size_of_old_gen_at_last_old_space_gc_(0), external_allocation_limit_(0), amount_of_external_allocated_memory_(0), amount_of_external_allocated_memory_at_last_global_gc_(0), old_gen_exhausted_(false), store_buffer_rebuilder_(store_buffer()), hidden_symbol_(NULL), global_gc_prologue_callback_(NULL), global_gc_epilogue_callback_(NULL), gc_safe_size_of_old_object_(NULL), total_regexp_code_generated_(0), tracer_(NULL), young_survivors_after_last_gc_(0), high_survival_rate_period_length_(0), survival_rate_(0), previous_survival_rate_trend_(Heap::STABLE), survival_rate_trend_(Heap::STABLE), max_gc_pause_(0), max_alive_after_gc_(0), min_in_mutator_(kMaxInt), alive_after_last_gc_(0), last_gc_end_timestamp_(0.0), store_buffer_(this), marking_(this), incremental_marking_(this), number_idle_notifications_(0), last_idle_notification_gc_count_(0), last_idle_notification_gc_count_init_(false), idle_notification_will_schedule_next_gc_(false), mark_sweeps_since_idle_round_started_(0), ms_count_at_last_idle_notification_(0), gc_count_at_last_idle_gc_(0), scavenges_since_last_idle_round_(kIdleScavengeThreshold), promotion_queue_(this), configured_(false), chunks_queued_for_free_(NULL) { // Allow build-time customization of the max semispace size. Building // V8 with snapshots and a non-default max semispace size is much // easier if you can define it as part of the build environment. #if defined(V8_MAX_SEMISPACE_SIZE) max_semispace_size_ = reserved_semispace_size_ = V8_MAX_SEMISPACE_SIZE; #endif intptr_t max_virtual = OS::MaxVirtualMemory(); if (max_virtual > 0) { if (code_range_size_ > 0) { // Reserve no more than 1/8 of the memory for the code range. code_range_size_ = Min(code_range_size_, max_virtual >> 3); } } memset(roots_, 0, sizeof(roots_[0]) * kRootListLength); global_contexts_list_ = NULL; mark_compact_collector_.heap_ = this; external_string_table_.heap_ = this; } intptr_t Heap::Capacity() { if (!HasBeenSetUp()) return 0; return new_space_.Capacity() + old_pointer_space_->Capacity() + old_data_space_->Capacity() + code_space_->Capacity() + map_space_->Capacity() + cell_space_->Capacity(); } intptr_t Heap::CommittedMemory() { if (!HasBeenSetUp()) return 0; return new_space_.CommittedMemory() + old_pointer_space_->CommittedMemory() + old_data_space_->CommittedMemory() + code_space_->CommittedMemory() + map_space_->CommittedMemory() + cell_space_->CommittedMemory() + lo_space_->Size(); } intptr_t Heap::CommittedMemoryExecutable() { if (!HasBeenSetUp()) return 0; return isolate()->memory_allocator()->SizeExecutable(); } intptr_t Heap::Available() { if (!HasBeenSetUp()) return 0; return new_space_.Available() + old_pointer_space_->Available() + old_data_space_->Available() + code_space_->Available() + map_space_->Available() + cell_space_->Available(); } bool Heap::HasBeenSetUp() { return old_pointer_space_ != NULL && old_data_space_ != NULL && code_space_ != NULL && map_space_ != NULL && cell_space_ != NULL && lo_space_ != NULL; } int Heap::GcSafeSizeOfOldObject(HeapObject* object) { if (IntrusiveMarking::IsMarked(object)) { return IntrusiveMarking::SizeOfMarkedObject(object); } return object->SizeFromMap(object->map()); } GarbageCollector Heap::SelectGarbageCollector(AllocationSpace space) { // Is global GC requested? if (space != NEW_SPACE || FLAG_gc_global) { isolate_->counters()->gc_compactor_caused_by_request()->Increment(); return MARK_COMPACTOR; } // Is enough data promoted to justify a global GC? if (OldGenerationPromotionLimitReached()) { isolate_->counters()->gc_compactor_caused_by_promoted_data()->Increment(); return MARK_COMPACTOR; } // Have allocation in OLD and LO failed? if (old_gen_exhausted_) { isolate_->counters()-> gc_compactor_caused_by_oldspace_exhaustion()->Increment(); return MARK_COMPACTOR; } // Is there enough space left in OLD to guarantee that a scavenge can // succeed? // // Note that MemoryAllocator->MaxAvailable() undercounts the memory available // for object promotion. It counts only the bytes that the memory // allocator has not yet allocated from the OS and assigned to any space, // and does not count available bytes already in the old space or code // space. Undercounting is safe---we may get an unrequested full GC when // a scavenge would have succeeded. if (isolate_->memory_allocator()->MaxAvailable() <= new_space_.Size()) { isolate_->counters()-> gc_compactor_caused_by_oldspace_exhaustion()->Increment(); return MARK_COMPACTOR; } // Default return SCAVENGER; } // TODO(1238405): Combine the infrastructure for --heap-stats and // --log-gc to avoid the complicated preprocessor and flag testing. void Heap::ReportStatisticsBeforeGC() { // Heap::ReportHeapStatistics will also log NewSpace statistics when // compiled --log-gc is set. The following logic is used to avoid // double logging. #ifdef DEBUG if (FLAG_heap_stats || FLAG_log_gc) new_space_.CollectStatistics(); if (FLAG_heap_stats) { ReportHeapStatistics("Before GC"); } else if (FLAG_log_gc) { new_space_.ReportStatistics(); } if (FLAG_heap_stats || FLAG_log_gc) new_space_.ClearHistograms(); #else if (FLAG_log_gc) { new_space_.CollectStatistics(); new_space_.ReportStatistics(); new_space_.ClearHistograms(); } #endif // DEBUG } void Heap::PrintShortHeapStatistics() { if (!FLAG_trace_gc_verbose) return; PrintF("Memory allocator, used: %8" V8_PTR_PREFIX "d" ", available: %8" V8_PTR_PREFIX "d\n", isolate_->memory_allocator()->Size(), isolate_->memory_allocator()->Available()); PrintF("New space, used: %8" V8_PTR_PREFIX "d" ", available: %8" V8_PTR_PREFIX "d\n", Heap::new_space_.Size(), new_space_.Available()); PrintF("Old pointers, used: %8" V8_PTR_PREFIX "d" ", available: %8" V8_PTR_PREFIX "d" ", waste: %8" V8_PTR_PREFIX "d\n", old_pointer_space_->Size(), old_pointer_space_->Available(), old_pointer_space_->Waste()); PrintF("Old data space, used: %8" V8_PTR_PREFIX "d" ", available: %8" V8_PTR_PREFIX "d" ", waste: %8" V8_PTR_PREFIX "d\n", old_data_space_->Size(), old_data_space_->Available(), old_data_space_->Waste()); PrintF("Code space, used: %8" V8_PTR_PREFIX "d" ", available: %8" V8_PTR_PREFIX "d" ", waste: %8" V8_PTR_PREFIX "d\n", code_space_->Size(), code_space_->Available(), code_space_->Waste()); PrintF("Map space, used: %8" V8_PTR_PREFIX "d" ", available: %8" V8_PTR_PREFIX "d" ", waste: %8" V8_PTR_PREFIX "d\n", map_space_->Size(), map_space_->Available(), map_space_->Waste()); PrintF("Cell space, used: %8" V8_PTR_PREFIX "d" ", available: %8" V8_PTR_PREFIX "d" ", waste: %8" V8_PTR_PREFIX "d\n", cell_space_->Size(), cell_space_->Available(), cell_space_->Waste()); PrintF("Large object space, used: %8" V8_PTR_PREFIX "d" ", available: %8" V8_PTR_PREFIX "d\n", lo_space_->Size(), lo_space_->Available()); } // TODO(1238405): Combine the infrastructure for --heap-stats and // --log-gc to avoid the complicated preprocessor and flag testing. void Heap::ReportStatisticsAfterGC() { // Similar to the before GC, we use some complicated logic to ensure that // NewSpace statistics are logged exactly once when --log-gc is turned on. #if defined(DEBUG) if (FLAG_heap_stats) { new_space_.CollectStatistics(); ReportHeapStatistics("After GC"); } else if (FLAG_log_gc) { new_space_.ReportStatistics(); } #else if (FLAG_log_gc) new_space_.ReportStatistics(); #endif // DEBUG } void Heap::GarbageCollectionPrologue() { isolate_->transcendental_cache()->Clear(); ClearJSFunctionResultCaches(); gc_count_++; unflattened_strings_length_ = 0; #ifdef DEBUG ASSERT(allocation_allowed_ && gc_state_ == NOT_IN_GC); allow_allocation(false); if (FLAG_verify_heap) { Verify(); } if (FLAG_gc_verbose) Print(); #endif // DEBUG #if defined(DEBUG) ReportStatisticsBeforeGC(); #endif // DEBUG LiveObjectList::GCPrologue(); store_buffer()->GCPrologue(); } intptr_t Heap::SizeOfObjects() { intptr_t total = 0; AllSpaces spaces; for (Space* space = spaces.next(); space != NULL; space = spaces.next()) { total += space->SizeOfObjects(); } return total; } void Heap::GarbageCollectionEpilogue() { store_buffer()->GCEpilogue(); LiveObjectList::GCEpilogue(); #ifdef DEBUG allow_allocation(true); ZapFromSpace(); if (FLAG_verify_heap) { Verify(); } if (FLAG_print_global_handles) isolate_->global_handles()->Print(); if (FLAG_print_handles) PrintHandles(); if (FLAG_gc_verbose) Print(); if (FLAG_code_stats) ReportCodeStatistics("After GC"); #endif isolate_->counters()->alive_after_last_gc()->Set( static_cast<int>(SizeOfObjects())); isolate_->counters()->symbol_table_capacity()->Set( symbol_table()->Capacity()); isolate_->counters()->number_of_symbols()->Set( symbol_table()->NumberOfElements()); #if defined(DEBUG) ReportStatisticsAfterGC(); #endif // DEBUG #ifdef ENABLE_DEBUGGER_SUPPORT isolate_->debug()->AfterGarbageCollection(); #endif // ENABLE_DEBUGGER_SUPPORT } void Heap::CollectAllGarbage(int flags) { // Since we are ignoring the return value, the exact choice of space does // not matter, so long as we do not specify NEW_SPACE, which would not // cause a full GC. mark_compact_collector_.SetFlags(flags); CollectGarbage(OLD_POINTER_SPACE); mark_compact_collector_.SetFlags(kNoGCFlags); } void Heap::CollectAllAvailableGarbage() { // Since we are ignoring the return value, the exact choice of space does // not matter, so long as we do not specify NEW_SPACE, which would not // cause a full GC. // Major GC would invoke weak handle callbacks on weakly reachable // handles, but won't collect weakly reachable objects until next // major GC. Therefore if we collect aggressively and weak handle callback // has been invoked, we rerun major GC to release objects which become // garbage. // Note: as weak callbacks can execute arbitrary code, we cannot // hope that eventually there will be no weak callbacks invocations. // Therefore stop recollecting after several attempts. mark_compact_collector()->SetFlags(kMakeHeapIterableMask); isolate_->compilation_cache()->Clear(); const int kMaxNumberOfAttempts = 7; for (int attempt = 0; attempt < kMaxNumberOfAttempts; attempt++) { if (!CollectGarbage(OLD_POINTER_SPACE, MARK_COMPACTOR)) { break; } } mark_compact_collector()->SetFlags(kNoGCFlags); new_space_.Shrink(); UncommitFromSpace(); Shrink(); incremental_marking()->UncommitMarkingDeque(); } bool Heap::CollectGarbage(AllocationSpace space, GarbageCollector collector) { // The VM is in the GC state until exiting this function. VMState state(isolate_, GC); #ifdef DEBUG // Reset the allocation timeout to the GC interval, but make sure to // allow at least a few allocations after a collection. The reason // for this is that we have a lot of allocation sequences and we // assume that a garbage collection will allow the subsequent // allocation attempts to go through. allocation_timeout_ = Max(6, FLAG_gc_interval); #endif if (collector == SCAVENGER && !incremental_marking()->IsStopped()) { if (FLAG_trace_incremental_marking) { PrintF("[IncrementalMarking] Scavenge during marking.\n"); } } if (collector == MARK_COMPACTOR && !mark_compact_collector()->PreciseSweepingRequired() && !incremental_marking()->IsStopped() && !incremental_marking()->should_hurry() && FLAG_incremental_marking_steps) { if (FLAG_trace_incremental_marking) { PrintF("[IncrementalMarking] Delaying MarkSweep.\n"); } collector = SCAVENGER; } bool next_gc_likely_to_collect_more = false; { GCTracer tracer(this); GarbageCollectionPrologue(); // The GC count was incremented in the prologue. Tell the tracer about // it. tracer.set_gc_count(gc_count_); // Tell the tracer which collector we've selected. tracer.set_collector(collector); HistogramTimer* rate = (collector == SCAVENGER) ? isolate_->counters()->gc_scavenger() : isolate_->counters()->gc_compactor(); rate->Start(); next_gc_likely_to_collect_more = PerformGarbageCollection(collector, &tracer); rate->Stop(); GarbageCollectionEpilogue(); } ASSERT(collector == SCAVENGER || incremental_marking()->IsStopped()); if (incremental_marking()->IsStopped()) { if (incremental_marking()->WorthActivating() && NextGCIsLikelyToBeFull()) { incremental_marking()->Start(); } } return next_gc_likely_to_collect_more; } void Heap::PerformScavenge() { GCTracer tracer(this); if (incremental_marking()->IsStopped()) { PerformGarbageCollection(SCAVENGER, &tracer); } else { PerformGarbageCollection(MARK_COMPACTOR, &tracer); } } #ifdef DEBUG // Helper class for verifying the symbol table. class SymbolTableVerifier : public ObjectVisitor { public: void VisitPointers(Object** start, Object** end) { // Visit all HeapObject pointers in [start, end). for (Object** p = start; p < end; p++) { if ((*p)->IsHeapObject()) { // Check that the symbol is actually a symbol. ASSERT((*p)->IsTheHole() || (*p)->IsUndefined() || (*p)->IsSymbol()); } } } }; #endif // DEBUG static void VerifySymbolTable() { #ifdef DEBUG SymbolTableVerifier verifier; HEAP->symbol_table()->IterateElements(&verifier); #endif // DEBUG } void Heap::ReserveSpace( int new_space_size, int pointer_space_size, int data_space_size, int code_space_size, int map_space_size, int cell_space_size, int large_object_size) { NewSpace* new_space = Heap::new_space(); PagedSpace* old_pointer_space = Heap::old_pointer_space(); PagedSpace* old_data_space = Heap::old_data_space(); PagedSpace* code_space = Heap::code_space(); PagedSpace* map_space = Heap::map_space(); PagedSpace* cell_space = Heap::cell_space(); LargeObjectSpace* lo_space = Heap::lo_space(); bool gc_performed = true; while (gc_performed) { gc_performed = false; if (!new_space->ReserveSpace(new_space_size)) { Heap::CollectGarbage(NEW_SPACE); gc_performed = true; } if (!old_pointer_space->ReserveSpace(pointer_space_size)) { Heap::CollectGarbage(OLD_POINTER_SPACE); gc_performed = true; } if (!(old_data_space->ReserveSpace(data_space_size))) { Heap::CollectGarbage(OLD_DATA_SPACE); gc_performed = true; } if (!(code_space->ReserveSpace(code_space_size))) { Heap::CollectGarbage(CODE_SPACE); gc_performed = true; } if (!(map_space->ReserveSpace(map_space_size))) { Heap::CollectGarbage(MAP_SPACE); gc_performed = true; } if (!(cell_space->ReserveSpace(cell_space_size))) { Heap::CollectGarbage(CELL_SPACE); gc_performed = true; } // We add a slack-factor of 2 in order to have space for a series of // large-object allocations that are only just larger than the page size. large_object_size *= 2; // The ReserveSpace method on the large object space checks how much // we can expand the old generation. This includes expansion caused by // allocation in the other spaces. large_object_size += cell_space_size + map_space_size + code_space_size + data_space_size + pointer_space_size; if (!(lo_space->ReserveSpace(large_object_size))) { Heap::CollectGarbage(LO_SPACE); gc_performed = true; } } } void Heap::EnsureFromSpaceIsCommitted() { if (new_space_.CommitFromSpaceIfNeeded()) return; // Committing memory to from space failed. // Try shrinking and try again. Shrink(); if (new_space_.CommitFromSpaceIfNeeded()) return; // Committing memory to from space failed again. // Memory is exhausted and we will die. V8::FatalProcessOutOfMemory("Committing semi space failed."); } void Heap::ClearJSFunctionResultCaches() { if (isolate_->bootstrapper()->IsActive()) return; Object* context = global_contexts_list_; while (!context->IsUndefined()) { // Get the caches for this context. GC can happen when the context // is not fully initialized, so the caches can be undefined. Object* caches_or_undefined = Context::cast(context)->get(Context::JSFUNCTION_RESULT_CACHES_INDEX); if (!caches_or_undefined->IsUndefined()) { FixedArray* caches = FixedArray::cast(caches_or_undefined); // Clear the caches: int length = caches->length(); for (int i = 0; i < length; i++) { JSFunctionResultCache::cast(caches->get(i))->Clear(); } } // Get the next context: context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK); } } void Heap::ClearNormalizedMapCaches() { if (isolate_->bootstrapper()->IsActive() && !incremental_marking()->IsMarking()) { return; } Object* context = global_contexts_list_; while (!context->IsUndefined()) { // GC can happen when the context is not fully initialized, // so the cache can be undefined. Object* cache = Context::cast(context)->get(Context::NORMALIZED_MAP_CACHE_INDEX); if (!cache->IsUndefined()) { NormalizedMapCache::cast(cache)->Clear(); } context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK); } } void Heap::UpdateSurvivalRateTrend(int start_new_space_size) { double survival_rate = (static_cast<double>(young_survivors_after_last_gc_) * 100) / start_new_space_size; if (survival_rate > kYoungSurvivalRateThreshold) { high_survival_rate_period_length_++; } else { high_survival_rate_period_length_ = 0; } double survival_rate_diff = survival_rate_ - survival_rate; if (survival_rate_diff > kYoungSurvivalRateAllowedDeviation) { set_survival_rate_trend(DECREASING); } else if (survival_rate_diff < -kYoungSurvivalRateAllowedDeviation) { set_survival_rate_trend(INCREASING); } else { set_survival_rate_trend(STABLE); } survival_rate_ = survival_rate; } bool Heap::PerformGarbageCollection(GarbageCollector collector, GCTracer* tracer) { bool next_gc_likely_to_collect_more = false; if (collector != SCAVENGER) { PROFILE(isolate_, CodeMovingGCEvent()); } if (FLAG_verify_heap) { VerifySymbolTable(); } if (collector == MARK_COMPACTOR && global_gc_prologue_callback_) { ASSERT(!allocation_allowed_); GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL); global_gc_prologue_callback_(); } GCType gc_type = collector == MARK_COMPACTOR ? kGCTypeMarkSweepCompact : kGCTypeScavenge; for (int i = 0; i < gc_prologue_callbacks_.length(); ++i) { if (gc_type & gc_prologue_callbacks_[i].gc_type) { gc_prologue_callbacks_[i].callback(gc_type, kNoGCCallbackFlags); } } EnsureFromSpaceIsCommitted(); int start_new_space_size = Heap::new_space()->SizeAsInt(); if (IsHighSurvivalRate()) { // We speed up the incremental marker if it is running so that it // does not fall behind the rate of promotion, which would cause a // constantly growing old space. incremental_marking()->NotifyOfHighPromotionRate(); } if (collector == MARK_COMPACTOR) { // Perform mark-sweep with optional compaction. MarkCompact(tracer); sweep_generation_++; bool high_survival_rate_during_scavenges = IsHighSurvivalRate() && IsStableOrIncreasingSurvivalTrend(); UpdateSurvivalRateTrend(start_new_space_size); if (!new_space_high_promotion_mode_active_ && new_space_.Capacity() == new_space_.MaximumCapacity() && IsStableOrIncreasingSurvivalTrend() && IsHighSurvivalRate()) { // Stable high survival rates even though young generation is at // maximum capacity indicates that most objects will be promoted. // To decrease scavenger pauses and final mark-sweep pauses, we // have to limit maximal capacity of the young generation. new_space_high_promotion_mode_active_ = true; if (FLAG_trace_gc) { PrintF("Limited new space size due to high promotion rate: %d MB\n", new_space_.InitialCapacity() / MB); } } else if (new_space_high_promotion_mode_active_ && IsDecreasingSurvivalTrend() && !IsHighSurvivalRate()) { // Decreasing low survival rates might indicate that the above high // promotion mode is over and we should allow the young generation // to grow again. new_space_high_promotion_mode_active_ = false; if (FLAG_trace_gc) { PrintF("Unlimited new space size due to low promotion rate: %d MB\n", new_space_.MaximumCapacity() / MB); } } size_of_old_gen_at_last_old_space_gc_ = PromotedSpaceSize(); if (high_survival_rate_during_scavenges && IsStableOrIncreasingSurvivalTrend()) { // Stable high survival rates of young objects both during partial and // full collection indicate that mutator is either building or modifying // a structure with a long lifetime. // In this case we aggressively raise old generation memory limits to // postpone subsequent mark-sweep collection and thus trade memory // space for the mutation speed. old_gen_limit_factor_ = 2; } else { old_gen_limit_factor_ = 1; } old_gen_promotion_limit_ = OldGenPromotionLimit(size_of_old_gen_at_last_old_space_gc_); old_gen_allocation_limit_ = OldGenAllocationLimit(size_of_old_gen_at_last_old_space_gc_); old_gen_exhausted_ = false; } else { tracer_ = tracer; Scavenge(); tracer_ = NULL; UpdateSurvivalRateTrend(start_new_space_size); } if (new_space_high_promotion_mode_active_ && new_space_.Capacity() > new_space_.InitialCapacity()) { new_space_.Shrink(); } isolate_->counters()->objs_since_last_young()->Set(0); gc_post_processing_depth_++; { DisableAssertNoAllocation allow_allocation; GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL); next_gc_likely_to_collect_more = isolate_->global_handles()->PostGarbageCollectionProcessing(collector); } gc_post_processing_depth_--; // Update relocatables. Relocatable::PostGarbageCollectionProcessing(); if (collector == MARK_COMPACTOR) { // Register the amount of external allocated memory. amount_of_external_allocated_memory_at_last_global_gc_ = amount_of_external_allocated_memory_; } GCCallbackFlags callback_flags = kNoGCCallbackFlags; for (int i = 0; i < gc_epilogue_callbacks_.length(); ++i) { if (gc_type & gc_epilogue_callbacks_[i].gc_type) { gc_epilogue_callbacks_[i].callback(gc_type, callback_flags); } } if (collector == MARK_COMPACTOR && global_gc_epilogue_callback_) { ASSERT(!allocation_allowed_); GCTracer::Scope scope(tracer, GCTracer::Scope::EXTERNAL); global_gc_epilogue_callback_(); } if (FLAG_verify_heap) { VerifySymbolTable(); } return next_gc_likely_to_collect_more; } void Heap::MarkCompact(GCTracer* tracer) { gc_state_ = MARK_COMPACT; LOG(isolate_, ResourceEvent("markcompact", "begin")); mark_compact_collector_.Prepare(tracer); ms_count_++; tracer->set_full_gc_count(ms_count_); MarkCompactPrologue(); mark_compact_collector_.CollectGarbage(); LOG(isolate_, ResourceEvent("markcompact", "end")); gc_state_ = NOT_IN_GC; isolate_->counters()->objs_since_last_full()->Set(0); contexts_disposed_ = 0; isolate_->set_context_exit_happened(false); } void Heap::MarkCompactPrologue() { // At any old GC clear the keyed lookup cache to enable collection of unused // maps. isolate_->keyed_lookup_cache()->Clear(); isolate_->context_slot_cache()->Clear(); isolate_->descriptor_lookup_cache()->Clear(); StringSplitCache::Clear(string_split_cache()); isolate_->compilation_cache()->MarkCompactPrologue(); CompletelyClearInstanceofCache(); // TODO(1605) select heuristic for flushing NumberString cache with // FlushNumberStringCache if (FLAG_cleanup_code_caches_at_gc) { polymorphic_code_cache()->set_cache(undefined_value()); } ClearNormalizedMapCaches(); } Object* Heap::FindCodeObject(Address a) { return isolate()->inner_pointer_to_code_cache()-> GcSafeFindCodeForInnerPointer(a); } // Helper class for copying HeapObjects class ScavengeVisitor: public ObjectVisitor { public: explicit ScavengeVisitor(Heap* heap) : heap_(heap) {} void VisitPointer(Object** p) { ScavengePointer(p); } void VisitPointers(Object** start, Object** end) { // Copy all HeapObject pointers in [start, end) for (Object** p = start; p < end; p++) ScavengePointer(p); } private: void ScavengePointer(Object** p) { Object* object = *p; if (!heap_->InNewSpace(object)) return; Heap::ScavengeObject(reinterpret_cast<HeapObject**>(p), reinterpret_cast<HeapObject*>(object)); } Heap* heap_; }; #ifdef DEBUG // Visitor class to verify pointers in code or data space do not point into // new space. class VerifyNonPointerSpacePointersVisitor: public ObjectVisitor { public: void VisitPointers(Object** start, Object**end) { for (Object** current = start; current < end; current++) { if ((*current)->IsHeapObject()) { ASSERT(!HEAP->InNewSpace(HeapObject::cast(*current))); } } } }; static void VerifyNonPointerSpacePointers() { // Verify that there are no pointers to new space in spaces where we // do not expect them. VerifyNonPointerSpacePointersVisitor v; HeapObjectIterator code_it(HEAP->code_space()); for (HeapObject* object = code_it.Next(); object != NULL; object = code_it.Next()) object->Iterate(&v); // The old data space was normally swept conservatively so that the iterator // doesn't work, so we normally skip the next bit. if (!HEAP->old_data_space()->was_swept_conservatively()) { HeapObjectIterator data_it(HEAP->old_data_space()); for (HeapObject* object = data_it.Next(); object != NULL; object = data_it.Next()) object->Iterate(&v); } } #endif void Heap::CheckNewSpaceExpansionCriteria() { if (new_space_.Capacity() < new_space_.MaximumCapacity() && survived_since_last_expansion_ > new_space_.Capacity() && !new_space_high_promotion_mode_active_) { // Grow the size of new space if there is room to grow, enough data // has survived scavenge since the last expansion and we are not in // high promotion mode. new_space_.Grow(); survived_since_last_expansion_ = 0; } } static bool IsUnscavengedHeapObject(Heap* heap, Object** p) { return heap->InNewSpace(*p) && !HeapObject::cast(*p)->map_word().IsForwardingAddress(); } void Heap::ScavengeStoreBufferCallback( Heap* heap, MemoryChunk* page, StoreBufferEvent event) { heap->store_buffer_rebuilder_.Callback(page, event); } void StoreBufferRebuilder::Callback(MemoryChunk* page, StoreBufferEvent event) { if (event == kStoreBufferStartScanningPagesEvent) { start_of_current_page_ = NULL; current_page_ = NULL; } else if (event == kStoreBufferScanningPageEvent) { if (current_page_ != NULL) { // If this page already overflowed the store buffer during this iteration. if (current_page_->scan_on_scavenge()) { // Then we should wipe out the entries that have been added for it. store_buffer_->SetTop(start_of_current_page_); } else if (store_buffer_->Top() - start_of_current_page_ >= (store_buffer_->Limit() - store_buffer_->Top()) >> 2) { // Did we find too many pointers in the previous page? The heuristic is // that no page can take more then 1/5 the remaining slots in the store // buffer. current_page_->set_scan_on_scavenge(true); store_buffer_->SetTop(start_of_current_page_); } else { // In this case the page we scanned took a reasonable number of slots in // the store buffer. It has now been rehabilitated and is no longer // marked scan_on_scavenge. ASSERT(!current_page_->scan_on_scavenge()); } } start_of_current_page_ = store_buffer_->Top(); current_page_ = page; } else if (event == kStoreBufferFullEvent) { // The current page overflowed the store buffer again. Wipe out its entries // in the store buffer and mark it scan-on-scavenge again. This may happen // several times while scanning. if (current_page_ == NULL) { // Store Buffer overflowed while scanning promoted objects. These are not // in any particular page, though they are likely to be clustered by the // allocation routines. store_buffer_->EnsureSpace(StoreBuffer::kStoreBufferSize); } else { // Store Buffer overflowed while scanning a particular old space page for // pointers to new space. ASSERT(current_page_ == page); ASSERT(page != NULL); current_page_->set_scan_on_scavenge(true); ASSERT(start_of_current_page_ != store_buffer_->Top()); store_buffer_->SetTop(start_of_current_page_); } } else { UNREACHABLE(); } } void PromotionQueue::Initialize() { // Assumes that a NewSpacePage exactly fits a number of promotion queue // entries (where each is a pair of intptr_t). This allows us to simplify // the test fpr when to switch pages. ASSERT((Page::kPageSize - MemoryChunk::kBodyOffset) % (2 * kPointerSize) == 0); limit_ = reinterpret_cast<intptr_t*>(heap_->new_space()->ToSpaceStart()); front_ = rear_ = reinterpret_cast<intptr_t*>(heap_->new_space()->ToSpaceEnd()); emergency_stack_ = NULL; guard_ = false; } void PromotionQueue::RelocateQueueHead() { ASSERT(emergency_stack_ == NULL); Page* p = Page::FromAllocationTop(reinterpret_cast<Address>(rear_)); intptr_t* head_start = rear_; intptr_t* head_end = Min(front_, reinterpret_cast<intptr_t*>(p->body_limit())); int entries_count = static_cast<int>(head_end - head_start) / kEntrySizeInWords; emergency_stack_ = new List<Entry>(2 * entries_count); while (head_start != head_end) { int size = static_cast<int>(*(head_start++)); HeapObject* obj = reinterpret_cast<HeapObject*>(*(head_start++)); emergency_stack_->Add(Entry(obj, size)); } rear_ = head_end; } void Heap::Scavenge() { #ifdef DEBUG if (FLAG_verify_heap) VerifyNonPointerSpacePointers(); #endif gc_state_ = SCAVENGE; // Implements Cheney's copying algorithm LOG(isolate_, ResourceEvent("scavenge", "begin")); // Clear descriptor cache. isolate_->descriptor_lookup_cache()->Clear(); // Used for updating survived_since_last_expansion_ at function end. intptr_t survived_watermark = PromotedSpaceSize(); CheckNewSpaceExpansionCriteria(); SelectScavengingVisitorsTable(); incremental_marking()->PrepareForScavenge(); AdvanceSweepers(static_cast<int>(new_space_.Size())); // Flip the semispaces. After flipping, to space is empty, from space has // live objects. new_space_.Flip(); new_space_.ResetAllocationInfo(); // We need to sweep newly copied objects which can be either in the // to space or promoted to the old generation. For to-space // objects, we treat the bottom of the to space as a queue. Newly // copied and unswept objects lie between a 'front' mark and the // allocation pointer. // // Promoted objects can go into various old-generation spaces, and // can be allocated internally in the spaces (from the free list). // We treat the top of the to space as a queue of addresses of // promoted objects. The addresses of newly promoted and unswept // objects lie between a 'front' mark and a 'rear' mark that is // updated as a side effect of promoting an object. // // There is guaranteed to be enough room at the top of the to space // for the addresses of promoted objects: every object promoted // frees up its size in bytes from the top of the new space, and // objects are at least one pointer in size. Address new_space_front = new_space_.ToSpaceStart(); promotion_queue_.Initialize(); #ifdef DEBUG store_buffer()->Clean(); #endif ScavengeVisitor scavenge_visitor(this); // Copy roots. IterateRoots(&scavenge_visitor, VISIT_ALL_IN_SCAVENGE); // Copy objects reachable from the old generation. { StoreBufferRebuildScope scope(this, store_buffer(), &ScavengeStoreBufferCallback); store_buffer()->IteratePointersToNewSpace(&ScavengeObject); } // Copy objects reachable from cells by scavenging cell values directly. HeapObjectIterator cell_iterator(cell_space_); for (HeapObject* cell = cell_iterator.Next(); cell != NULL; cell = cell_iterator.Next()) { if (cell->IsJSGlobalPropertyCell()) { Address value_address = reinterpret_cast<Address>(cell) + (JSGlobalPropertyCell::kValueOffset - kHeapObjectTag); scavenge_visitor.VisitPointer(reinterpret_cast<Object**>(value_address)); } } // Scavenge object reachable from the global contexts list directly. scavenge_visitor.VisitPointer(BitCast<Object**>(&global_contexts_list_)); new_space_front = DoScavenge(&scavenge_visitor, new_space_front); isolate_->global_handles()->IdentifyNewSpaceWeakIndependentHandles( &IsUnscavengedHeapObject); isolate_->global_handles()->IterateNewSpaceWeakIndependentRoots( &scavenge_visitor); new_space_front = DoScavenge(&scavenge_visitor, new_space_front); UpdateNewSpaceReferencesInExternalStringTable( &UpdateNewSpaceReferenceInExternalStringTableEntry); promotion_queue_.Destroy(); LiveObjectList::UpdateReferencesForScavengeGC(); isolate()->runtime_profiler()->UpdateSamplesAfterScavenge(); incremental_marking()->UpdateMarkingDequeAfterScavenge(); ASSERT(new_space_front == new_space_.top()); // Set age mark. new_space_.set_age_mark(new_space_.top()); new_space_.LowerInlineAllocationLimit( new_space_.inline_allocation_limit_step()); // Update how much has survived scavenge. IncrementYoungSurvivorsCounter(static_cast<int>( (PromotedSpaceSize() - survived_watermark) + new_space_.Size())); LOG(isolate_, ResourceEvent("scavenge", "end")); gc_state_ = NOT_IN_GC; scavenges_since_last_idle_round_++; } String* Heap::UpdateNewSpaceReferenceInExternalStringTableEntry(Heap* heap, Object** p) { MapWord first_word = HeapObject::cast(*p)->map_word(); if (!first_word.IsForwardingAddress()) { // Unreachable external string can be finalized. heap->FinalizeExternalString(String::cast(*p)); return NULL; } // String is still reachable. return String::cast(first_word.ToForwardingAddress()); } void Heap::UpdateNewSpaceReferencesInExternalStringTable( ExternalStringTableUpdaterCallback updater_func) { if (FLAG_verify_heap) { external_string_table_.Verify(); } if (external_string_table_.new_space_strings_.is_empty()) return; Object** start = &external_string_table_.new_space_strings_[0]; Object** end = start + external_string_table_.new_space_strings_.length(); Object** last = start; for (Object** p = start; p < end; ++p) { ASSERT(InFromSpace(*p)); String* target = updater_func(this, p); if (target == NULL) continue; ASSERT(target->IsExternalString()); if (InNewSpace(target)) { // String is still in new space. Update the table entry. *last = target; ++last; } else { // String got promoted. Move it to the old string list. external_string_table_.AddOldString(target); } } ASSERT(last <= end); external_string_table_.ShrinkNewStrings(static_cast<int>(last - start)); } void Heap::UpdateReferencesInExternalStringTable( ExternalStringTableUpdaterCallback updater_func) { // Update old space string references. if (external_string_table_.old_space_strings_.length() > 0) { Object** start = &external_string_table_.old_space_strings_[0]; Object** end = start + external_string_table_.old_space_strings_.length(); for (Object** p = start; p < end; ++p) *p = updater_func(this, p); } UpdateNewSpaceReferencesInExternalStringTable(updater_func); } static Object* ProcessFunctionWeakReferences(Heap* heap, Object* function, WeakObjectRetainer* retainer) { Object* undefined = heap->undefined_value(); Object* head = undefined; JSFunction* tail = NULL; Object* candidate = function; while (candidate != undefined) { // Check whether to keep the candidate in the list. JSFunction* candidate_function = reinterpret_cast<JSFunction*>(candidate); Object* retain = retainer->RetainAs(candidate); if (retain != NULL) { if (head == undefined) { // First element in the list. head = retain; } else { // Subsequent elements in the list. ASSERT(tail != NULL); tail->set_next_function_link(retain); } // Retained function is new tail. candidate_function = reinterpret_cast<JSFunction*>(retain); tail = candidate_function; ASSERT(retain->IsUndefined() || retain->IsJSFunction()); if (retain == undefined) break; } // Move to next element in the list. candidate = candidate_function->next_function_link(); } // Terminate the list if there is one or more elements. if (tail != NULL) { tail->set_next_function_link(undefined); } return head; } void Heap::ProcessWeakReferences(WeakObjectRetainer* retainer) { Object* undefined = undefined_value(); Object* head = undefined; Context* tail = NULL; Object* candidate = global_contexts_list_; while (candidate != undefined) { // Check whether to keep the candidate in the list. Context* candidate_context = reinterpret_cast<Context*>(candidate); Object* retain = retainer->RetainAs(candidate); if (retain != NULL) { if (head == undefined) { // First element in the list. head = retain; } else { // Subsequent elements in the list. ASSERT(tail != NULL); tail->set_unchecked(this, Context::NEXT_CONTEXT_LINK, retain, UPDATE_WRITE_BARRIER); } // Retained context is new tail. candidate_context = reinterpret_cast<Context*>(retain); tail = candidate_context; if (retain == undefined) break; // Process the weak list of optimized functions for the context. Object* function_list_head = ProcessFunctionWeakReferences( this, candidate_context->get(Context::OPTIMIZED_FUNCTIONS_LIST), retainer); candidate_context->set_unchecked(this, Context::OPTIMIZED_FUNCTIONS_LIST, function_list_head, UPDATE_WRITE_BARRIER); } // Move to next element in the list. candidate = candidate_context->get(Context::NEXT_CONTEXT_LINK); } // Terminate the list if there is one or more elements. if (tail != NULL) { tail->set_unchecked(this, Context::NEXT_CONTEXT_LINK, Heap::undefined_value(), UPDATE_WRITE_BARRIER); } // Update the head of the list of contexts. global_contexts_list_ = head; } void Heap::VisitExternalResources(v8::ExternalResourceVisitor* visitor) { AssertNoAllocation no_allocation; class VisitorAdapter : public ObjectVisitor { public: explicit VisitorAdapter(v8::ExternalResourceVisitor* visitor) : visitor_(visitor) {} virtual void VisitPointers(Object** start, Object** end) { for (Object** p = start; p < end; p++) { if ((*p)->IsExternalString()) { visitor_->VisitExternalString(Utils::ToLocal( Handle<String>(String::cast(*p)))); } } } private: v8::ExternalResourceVisitor* visitor_; } visitor_adapter(visitor); external_string_table_.Iterate(&visitor_adapter); } class NewSpaceScavenger : public StaticNewSpaceVisitor<NewSpaceScavenger> { public: static inline void VisitPointer(Heap* heap, Object** p) { Object* object = *p; if (!heap->InNewSpace(object)) return; Heap::ScavengeObject(reinterpret_cast<HeapObject**>(p), reinterpret_cast<HeapObject*>(object)); } }; Address Heap::DoScavenge(ObjectVisitor* scavenge_visitor, Address new_space_front) { do { SemiSpace::AssertValidRange(new_space_front, new_space_.top()); // The addresses new_space_front and new_space_.top() define a // queue of unprocessed copied objects. Process them until the // queue is empty. while (new_space_front != new_space_.top()) { if (!NewSpacePage::IsAtEnd(new_space_front)) { HeapObject* object = HeapObject::FromAddress(new_space_front); new_space_front += NewSpaceScavenger::IterateBody(object->map(), object); } else { new_space_front = NewSpacePage::FromLimit(new_space_front)->next_page()->body(); } } // Promote and process all the to-be-promoted objects. { StoreBufferRebuildScope scope(this, store_buffer(), &ScavengeStoreBufferCallback); while (!promotion_queue()->is_empty()) { HeapObject* target; int size; promotion_queue()->remove(&target, &size); // Promoted object might be already partially visited // during old space pointer iteration. Thus we search specificly // for pointers to from semispace instead of looking for pointers // to new space. ASSERT(!target->IsMap()); IterateAndMarkPointersToFromSpace(target->address(), target->address() + size, &ScavengeObject); } } // Take another spin if there are now unswept objects in new space // (there are currently no more unswept promoted objects). } while (new_space_front != new_space_.top()); return new_space_front; } enum LoggingAndProfiling { LOGGING_AND_PROFILING_ENABLED, LOGGING_AND_PROFILING_DISABLED }; enum MarksHandling { TRANSFER_MARKS, IGNORE_MARKS }; template<MarksHandling marks_handling, LoggingAndProfiling logging_and_profiling_mode> class ScavengingVisitor : public StaticVisitorBase { public: static void Initialize() { table_.Register(kVisitSeqAsciiString, &EvacuateSeqAsciiString); table_.Register(kVisitSeqTwoByteString, &EvacuateSeqTwoByteString); table_.Register(kVisitShortcutCandidate, &EvacuateShortcutCandidate); table_.Register(kVisitByteArray, &EvacuateByteArray); table_.Register(kVisitFixedArray, &EvacuateFixedArray); table_.Register(kVisitFixedDoubleArray, &EvacuateFixedDoubleArray); table_.Register(kVisitGlobalContext, &ObjectEvacuationStrategy<POINTER_OBJECT>:: template VisitSpecialized<Context::kSize>); table_.Register(kVisitConsString, &ObjectEvacuationStrategy<POINTER_OBJECT>:: template VisitSpecialized<ConsString::kSize>); table_.Register(kVisitSlicedString, &ObjectEvacuationStrategy<POINTER_OBJECT>:: template VisitSpecialized<SlicedString::kSize>); table_.Register(kVisitSharedFunctionInfo, &ObjectEvacuationStrategy<POINTER_OBJECT>:: template VisitSpecialized<SharedFunctionInfo::kSize>); table_.Register(kVisitJSWeakMap, &ObjectEvacuationStrategy<POINTER_OBJECT>:: Visit); table_.Register(kVisitJSRegExp, &ObjectEvacuationStrategy<POINTER_OBJECT>:: Visit); if (marks_handling == IGNORE_MARKS) { table_.Register(kVisitJSFunction, &ObjectEvacuationStrategy<POINTER_OBJECT>:: template VisitSpecialized<JSFunction::kSize>); } else { table_.Register(kVisitJSFunction, &EvacuateJSFunction); } table_.RegisterSpecializations<ObjectEvacuationStrategy<DATA_OBJECT>, kVisitDataObject, kVisitDataObjectGeneric>(); table_.RegisterSpecializations<ObjectEvacuationStrategy<POINTER_OBJECT>, kVisitJSObject, kVisitJSObjectGeneric>(); table_.RegisterSpecializations<ObjectEvacuationStrategy<POINTER_OBJECT>, kVisitStruct, kVisitStructGeneric>(); } static VisitorDispatchTable<ScavengingCallback>* GetTable() { return &table_; } private: enum ObjectContents { DATA_OBJECT, POINTER_OBJECT }; enum SizeRestriction { SMALL, UNKNOWN_SIZE }; static void RecordCopiedObject(Heap* heap, HeapObject* obj) { bool should_record = false; #ifdef DEBUG should_record = FLAG_heap_stats; #endif should_record = should_record || FLAG_log_gc; if (should_record) { if (heap->new_space()->Contains(obj)) { heap->new_space()->RecordAllocation(obj); } else { heap->new_space()->RecordPromotion(obj); } } } // Helper function used by CopyObject to copy a source object to an // allocated target object and update the forwarding pointer in the source // object. Returns the target object. INLINE(static void MigrateObject(Heap* heap, HeapObject* source, HeapObject* target, int size)) { // Copy the content of source to target. heap->CopyBlock(target->address(), source->address(), size); // Set the forwarding address. source->set_map_word(MapWord::FromForwardingAddress(target)); if (logging_and_profiling_mode == LOGGING_AND_PROFILING_ENABLED) { // Update NewSpace stats if necessary. RecordCopiedObject(heap, target); HEAP_PROFILE(heap, ObjectMoveEvent(source->address(), target->address())); Isolate* isolate = heap->isolate(); if (isolate->logger()->is_logging() || CpuProfiler::is_profiling(isolate)) { if (target->IsSharedFunctionInfo()) { PROFILE(isolate, SharedFunctionInfoMoveEvent( source->address(), target->address())); } } } if (marks_handling == TRANSFER_MARKS) { if (Marking::TransferColor(source, target)) { MemoryChunk::IncrementLiveBytesFromGC(target->address(), size); } } } template<ObjectContents object_contents, SizeRestriction size_restriction> static inline void EvacuateObject(Map* map, HeapObject** slot, HeapObject* object, int object_size) { SLOW_ASSERT((size_restriction != SMALL) || (object_size <= Page::kMaxHeapObjectSize)); SLOW_ASSERT(object->Size() == object_size); Heap* heap = map->GetHeap(); if (heap->ShouldBePromoted(object->address(), object_size)) { MaybeObject* maybe_result; if ((size_restriction != SMALL) && (object_size > Page::kMaxHeapObjectSize)) { maybe_result = heap->lo_space()->AllocateRaw(object_size, NOT_EXECUTABLE); } else { if (object_contents == DATA_OBJECT) { maybe_result = heap->old_data_space()->AllocateRaw(object_size); } else { maybe_result = heap->old_pointer_space()->AllocateRaw(object_size); } } Object* result = NULL; // Initialization to please compiler. if (maybe_result->ToObject(&result)) { HeapObject* target = HeapObject::cast(result); // Order is important: slot might be inside of the target if target // was allocated over a dead object and slot comes from the store // buffer. *slot = target; MigrateObject(heap, object, target, object_size); if (object_contents == POINTER_OBJECT) { heap->promotion_queue()->insert(target, object_size); } heap->tracer()->increment_promoted_objects_size(object_size); return; } } MaybeObject* allocation = heap->new_space()->AllocateRaw(object_size); heap->promotion_queue()->SetNewLimit(heap->new_space()->top()); Object* result = allocation->ToObjectUnchecked(); HeapObject* target = HeapObject::cast(result); // Order is important: slot might be inside of the target if target // was allocated over a dead object and slot comes from the store // buffer. *slot = target; MigrateObject(heap, object, target, object_size); return; } static inline void EvacuateJSFunction(Map* map, HeapObject** slot, HeapObject* object) { ObjectEvacuationStrategy<POINTER_OBJECT>:: template VisitSpecialized<JSFunction::kSize>(map, slot, object); HeapObject* target = *slot; MarkBit mark_bit = Marking::MarkBitFrom(target); if (Marking::IsBlack(mark_bit)) { // This object is black and it might not be rescanned by marker. // We should explicitly record code entry slot for compaction because // promotion queue processing (IterateAndMarkPointersToFromSpace) will // miss it as it is not HeapObject-tagged. Address code_entry_slot = target->address() + JSFunction::kCodeEntryOffset; Code* code = Code::cast(Code::GetObjectFromEntryAddress(code_entry_slot)); map->GetHeap()->mark_compact_collector()-> RecordCodeEntrySlot(code_entry_slot, code); } } static inline void EvacuateFixedArray(Map* map, HeapObject** slot, HeapObject* object) { int object_size = FixedArray::BodyDescriptor::SizeOf(map, object); EvacuateObject<POINTER_OBJECT, UNKNOWN_SIZE>(map, slot, object, object_size); } static inline void EvacuateFixedDoubleArray(Map* map, HeapObject** slot, HeapObject* object) { int length = reinterpret_cast<FixedDoubleArray*>(object)->length(); int object_size = FixedDoubleArray::SizeFor(length); EvacuateObject<DATA_OBJECT, UNKNOWN_SIZE>(map, slot, object, object_size); } static inline void EvacuateByteArray(Map* map, HeapObject** slot, HeapObject* object) { int object_size = reinterpret_cast<ByteArray*>(object)->ByteArraySize(); EvacuateObject<DATA_OBJECT, UNKNOWN_SIZE>(map, slot, object, object_size); } static inline void EvacuateSeqAsciiString(Map* map, HeapObject** slot, HeapObject* object) { int object_size = SeqAsciiString::cast(object)-> SeqAsciiStringSize(map->instance_type()); EvacuateObject<DATA_OBJECT, UNKNOWN_SIZE>(map, slot, object, object_size); } static inline void EvacuateSeqTwoByteString(Map* map, HeapObject** slot, HeapObject* object) { int object_size = SeqTwoByteString::cast(object)-> SeqTwoByteStringSize(map->instance_type()); EvacuateObject<DATA_OBJECT, UNKNOWN_SIZE>(map, slot, object, object_size); } static inline bool IsShortcutCandidate(int type) { return ((type & kShortcutTypeMask) == kShortcutTypeTag); } static inline void EvacuateShortcutCandidate(Map* map, HeapObject** slot, HeapObject* object) { ASSERT(IsShortcutCandidate(map->instance_type())); Heap* heap = map->GetHeap(); if (marks_handling == IGNORE_MARKS && ConsString::cast(object)->unchecked_second() == heap->empty_string()) { HeapObject* first = HeapObject::cast(ConsString::cast(object)->unchecked_first()); *slot = first; if (!heap->InNewSpace(first)) { object->set_map_word(MapWord::FromForwardingAddress(first)); return; } MapWord first_word = first->map_word(); if (first_word.IsForwardingAddress()) { HeapObject* target = first_word.ToForwardingAddress(); *slot = target; object->set_map_word(MapWord::FromForwardingAddress(target)); return; } heap->DoScavengeObject(first->map(), slot, first); object->set_map_word(MapWord::FromForwardingAddress(*slot)); return; } int object_size = ConsString::kSize; EvacuateObject<POINTER_OBJECT, SMALL>(map, slot, object, object_size); } template<ObjectContents object_contents> class ObjectEvacuationStrategy { public: template<int object_size> static inline void VisitSpecialized(Map* map, HeapObject** slot, HeapObject* object) { EvacuateObject<object_contents, SMALL>(map, slot, object, object_size); } static inline void Visit(Map* map, HeapObject** slot, HeapObject* object) { int object_size = map->instance_size(); EvacuateObject<object_contents, SMALL>(map, slot, object, object_size); } }; static VisitorDispatchTable<ScavengingCallback> table_; }; template<MarksHandling marks_handling, LoggingAndProfiling logging_and_profiling_mode> VisitorDispatchTable<ScavengingCallback> ScavengingVisitor<marks_handling, logging_and_profiling_mode>::table_; static void InitializeScavengingVisitorsTables() { ScavengingVisitor<TRANSFER_MARKS, LOGGING_AND_PROFILING_DISABLED>::Initialize(); ScavengingVisitor<IGNORE_MARKS, LOGGING_AND_PROFILING_DISABLED>::Initialize(); ScavengingVisitor<TRANSFER_MARKS, LOGGING_AND_PROFILING_ENABLED>::Initialize(); ScavengingVisitor<IGNORE_MARKS, LOGGING_AND_PROFILING_ENABLED>::Initialize(); } void Heap::SelectScavengingVisitorsTable() { bool logging_and_profiling = isolate()->logger()->is_logging() || CpuProfiler::is_profiling(isolate()) || (isolate()->heap_profiler() != NULL && isolate()->heap_profiler()->is_profiling()); if (!incremental_marking()->IsMarking()) { if (!logging_and_profiling) { scavenging_visitors_table_.CopyFrom( ScavengingVisitor<IGNORE_MARKS, LOGGING_AND_PROFILING_DISABLED>::GetTable()); } else { scavenging_visitors_table_.CopyFrom( ScavengingVisitor<IGNORE_MARKS, LOGGING_AND_PROFILING_ENABLED>::GetTable()); } } else { if (!logging_and_profiling) { scavenging_visitors_table_.CopyFrom( ScavengingVisitor<TRANSFER_MARKS, LOGGING_AND_PROFILING_DISABLED>::GetTable()); } else { scavenging_visitors_table_.CopyFrom( ScavengingVisitor<TRANSFER_MARKS, LOGGING_AND_PROFILING_ENABLED>::GetTable()); } if (incremental_marking()->IsCompacting()) { // When compacting forbid short-circuiting of cons-strings. // Scavenging code relies on the fact that new space object // can't be evacuated into evacuation candidate but // short-circuiting violates this assumption. scavenging_visitors_table_.Register( StaticVisitorBase::kVisitShortcutCandidate, scavenging_visitors_table_.GetVisitorById( StaticVisitorBase::kVisitConsString)); } } } void Heap::ScavengeObjectSlow(HeapObject** p, HeapObject* object) { SLOW_ASSERT(HEAP->InFromSpace(object)); MapWord first_word = object->map_word(); SLOW_ASSERT(!first_word.IsForwardingAddress()); Map* map = first_word.ToMap(); map->GetHeap()->DoScavengeObject(map, p, object); } MaybeObject* Heap::AllocatePartialMap(InstanceType instance_type, int instance_size) { Object* result; { MaybeObject* maybe_result = AllocateRawMap(); if (!maybe_result->ToObject(&result)) return maybe_result; } // Map::cast cannot be used due to uninitialized map field. reinterpret_cast<Map*>(result)->set_map(raw_unchecked_meta_map()); reinterpret_cast<Map*>(result)->set_instance_type(instance_type); reinterpret_cast<Map*>(result)->set_instance_size(instance_size); reinterpret_cast<Map*>(result)->set_visitor_id( StaticVisitorBase::GetVisitorId(instance_type, instance_size)); reinterpret_cast<Map*>(result)->set_inobject_properties(0); reinterpret_cast<Map*>(result)->set_pre_allocated_property_fields(0); reinterpret_cast<Map*>(result)->set_unused_property_fields(0); reinterpret_cast<Map*>(result)->set_bit_field(0); reinterpret_cast<Map*>(result)->set_bit_field2(0); return result; } MaybeObject* Heap::AllocateMap(InstanceType instance_type, int instance_size, ElementsKind elements_kind) { Object* result; { MaybeObject* maybe_result = AllocateRawMap(); if (!maybe_result->ToObject(&result)) return maybe_result; } Map* map = reinterpret_cast<Map*>(result); map->set_map_no_write_barrier(meta_map()); map->set_instance_type(instance_type); map->set_visitor_id( StaticVisitorBase::GetVisitorId(instance_type, instance_size)); map->set_prototype(null_value(), SKIP_WRITE_BARRIER); map->set_constructor(null_value(), SKIP_WRITE_BARRIER); map->set_instance_size(instance_size); map->set_inobject_properties(0); map->set_pre_allocated_property_fields(0); map->init_instance_descriptors(); map->set_code_cache(empty_fixed_array(), SKIP_WRITE_BARRIER); map->set_prototype_transitions(empty_fixed_array(), SKIP_WRITE_BARRIER); map->set_unused_property_fields(0); map->set_bit_field(0); map->set_bit_field2(1 << Map::kIsExtensible); map->set_elements_kind(elements_kind); // If the map object is aligned fill the padding area with Smi 0 objects. if (Map::kPadStart < Map::kSize) { memset(reinterpret_cast<byte*>(map) + Map::kPadStart - kHeapObjectTag, 0, Map::kSize - Map::kPadStart); } return map; } MaybeObject* Heap::AllocateCodeCache() { Object* result; { MaybeObject* maybe_result = AllocateStruct(CODE_CACHE_TYPE); if (!maybe_result->ToObject(&result)) return maybe_result; } CodeCache* code_cache = CodeCache::cast(result); code_cache->set_default_cache(empty_fixed_array(), SKIP_WRITE_BARRIER); code_cache->set_normal_type_cache(undefined_value(), SKIP_WRITE_BARRIER); return code_cache; } MaybeObject* Heap::AllocatePolymorphicCodeCache() { return AllocateStruct(POLYMORPHIC_CODE_CACHE_TYPE); } MaybeObject* Heap::AllocateAccessorPair() { Object* result; { MaybeObject* maybe_result = AllocateStruct(ACCESSOR_PAIR_TYPE); if (!maybe_result->ToObject(&result)) return maybe_result; } AccessorPair* accessors = AccessorPair::cast(result); // Later we will have to distinguish between undefined and the hole... // accessors->set_getter(the_hole_value(), SKIP_WRITE_BARRIER); // accessors->set_setter(the_hole_value(), SKIP_WRITE_BARRIER); return accessors; } const Heap::StringTypeTable Heap::string_type_table[] = { #define STRING_TYPE_ELEMENT(type, size, name, camel_name) \ {type, size, k##camel_name##MapRootIndex}, STRING_TYPE_LIST(STRING_TYPE_ELEMENT) #undef STRING_TYPE_ELEMENT }; const Heap::ConstantSymbolTable Heap::constant_symbol_table[] = { #define CONSTANT_SYMBOL_ELEMENT(name, contents) \ {contents, k##name##RootIndex}, SYMBOL_LIST(CONSTANT_SYMBOL_ELEMENT) #undef CONSTANT_SYMBOL_ELEMENT }; const Heap::StructTable Heap::struct_table[] = { #define STRUCT_TABLE_ELEMENT(NAME, Name, name) \ { NAME##_TYPE, Name::kSize, k##Name##MapRootIndex }, STRUCT_LIST(STRUCT_TABLE_ELEMENT) #undef STRUCT_TABLE_ELEMENT }; bool Heap::CreateInitialMaps() { Object* obj; { MaybeObject* maybe_obj = AllocatePartialMap(MAP_TYPE, Map::kSize); if (!maybe_obj->ToObject(&obj)) return false; } // Map::cast cannot be used due to uninitialized map field. Map* new_meta_map = reinterpret_cast<Map*>(obj); set_meta_map(new_meta_map); new_meta_map->set_map(new_meta_map); { MaybeObject* maybe_obj = AllocatePartialMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); if (!maybe_obj->ToObject(&obj)) return false; } set_fixed_array_map(Map::cast(obj)); { MaybeObject* maybe_obj = AllocatePartialMap(ODDBALL_TYPE, Oddball::kSize); if (!maybe_obj->ToObject(&obj)) return false; } set_oddball_map(Map::cast(obj)); // Allocate the empty array. { MaybeObject* maybe_obj = AllocateEmptyFixedArray(); if (!maybe_obj->ToObject(&obj)) return false; } set_empty_fixed_array(FixedArray::cast(obj)); { MaybeObject* maybe_obj = Allocate(oddball_map(), OLD_POINTER_SPACE); if (!maybe_obj->ToObject(&obj)) return false; } set_null_value(Oddball::cast(obj)); Oddball::cast(obj)->set_kind(Oddball::kNull); { MaybeObject* maybe_obj = Allocate(oddball_map(), OLD_POINTER_SPACE); if (!maybe_obj->ToObject(&obj)) return false; } set_undefined_value(Oddball::cast(obj)); Oddball::cast(obj)->set_kind(Oddball::kUndefined); ASSERT(!InNewSpace(undefined_value())); // Allocate the empty descriptor array. { MaybeObject* maybe_obj = AllocateEmptyFixedArray(); if (!maybe_obj->ToObject(&obj)) return false; } set_empty_descriptor_array(DescriptorArray::cast(obj)); // Fix the instance_descriptors for the existing maps. meta_map()->init_instance_descriptors(); meta_map()->set_code_cache(empty_fixed_array()); meta_map()->set_prototype_transitions(empty_fixed_array()); fixed_array_map()->init_instance_descriptors(); fixed_array_map()->set_code_cache(empty_fixed_array()); fixed_array_map()->set_prototype_transitions(empty_fixed_array()); oddball_map()->init_instance_descriptors(); oddball_map()->set_code_cache(empty_fixed_array()); oddball_map()->set_prototype_transitions(empty_fixed_array()); // Fix prototype object for existing maps. meta_map()->set_prototype(null_value()); meta_map()->set_constructor(null_value()); fixed_array_map()->set_prototype(null_value()); fixed_array_map()->set_constructor(null_value()); oddball_map()->set_prototype(null_value()); oddball_map()->set_constructor(null_value()); { MaybeObject* maybe_obj = AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); if (!maybe_obj->ToObject(&obj)) return false; } set_fixed_cow_array_map(Map::cast(obj)); ASSERT(fixed_array_map() != fixed_cow_array_map()); { MaybeObject* maybe_obj = AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); if (!maybe_obj->ToObject(&obj)) return false; } set_scope_info_map(Map::cast(obj)); { MaybeObject* maybe_obj = AllocateMap(HEAP_NUMBER_TYPE, HeapNumber::kSize); if (!maybe_obj->ToObject(&obj)) return false; } set_heap_number_map(Map::cast(obj)); { MaybeObject* maybe_obj = AllocateMap(FOREIGN_TYPE, Foreign::kSize); if (!maybe_obj->ToObject(&obj)) return false; } set_foreign_map(Map::cast(obj)); for (unsigned i = 0; i < ARRAY_SIZE(string_type_table); i++) { const StringTypeTable& entry = string_type_table[i]; { MaybeObject* maybe_obj = AllocateMap(entry.type, entry.size); if (!maybe_obj->ToObject(&obj)) return false; } roots_[entry.index] = Map::cast(obj); } { MaybeObject* maybe_obj = AllocateMap(STRING_TYPE, kVariableSizeSentinel); if (!maybe_obj->ToObject(&obj)) return false; } set_undetectable_string_map(Map::cast(obj)); Map::cast(obj)->set_is_undetectable(); { MaybeObject* maybe_obj = AllocateMap(ASCII_STRING_TYPE, kVariableSizeSentinel); if (!maybe_obj->ToObject(&obj)) return false; } set_undetectable_ascii_string_map(Map::cast(obj)); Map::cast(obj)->set_is_undetectable(); { MaybeObject* maybe_obj = AllocateMap(FIXED_DOUBLE_ARRAY_TYPE, kVariableSizeSentinel); if (!maybe_obj->ToObject(&obj)) return false; } set_fixed_double_array_map(Map::cast(obj)); { MaybeObject* maybe_obj = AllocateMap(BYTE_ARRAY_TYPE, kVariableSizeSentinel); if (!maybe_obj->ToObject(&obj)) return false; } set_byte_array_map(Map::cast(obj)); { MaybeObject* maybe_obj = AllocateMap(FREE_SPACE_TYPE, kVariableSizeSentinel); if (!maybe_obj->ToObject(&obj)) return false; } set_free_space_map(Map::cast(obj)); { MaybeObject* maybe_obj = AllocateByteArray(0, TENURED); if (!maybe_obj->ToObject(&obj)) return false; } set_empty_byte_array(ByteArray::cast(obj)); { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_PIXEL_ARRAY_TYPE, ExternalArray::kAlignedSize); if (!maybe_obj->ToObject(&obj)) return false; } set_external_pixel_array_map(Map::cast(obj)); { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_BYTE_ARRAY_TYPE, ExternalArray::kAlignedSize); if (!maybe_obj->ToObject(&obj)) return false; } set_external_byte_array_map(Map::cast(obj)); { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE, ExternalArray::kAlignedSize); if (!maybe_obj->ToObject(&obj)) return false; } set_external_unsigned_byte_array_map(Map::cast(obj)); { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_SHORT_ARRAY_TYPE, ExternalArray::kAlignedSize); if (!maybe_obj->ToObject(&obj)) return false; } set_external_short_array_map(Map::cast(obj)); { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE, ExternalArray::kAlignedSize); if (!maybe_obj->ToObject(&obj)) return false; } set_external_unsigned_short_array_map(Map::cast(obj)); { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_INT_ARRAY_TYPE, ExternalArray::kAlignedSize); if (!maybe_obj->ToObject(&obj)) return false; } set_external_int_array_map(Map::cast(obj)); { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_UNSIGNED_INT_ARRAY_TYPE, ExternalArray::kAlignedSize); if (!maybe_obj->ToObject(&obj)) return false; } set_external_unsigned_int_array_map(Map::cast(obj)); { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_FLOAT_ARRAY_TYPE, ExternalArray::kAlignedSize); if (!maybe_obj->ToObject(&obj)) return false; } set_external_float_array_map(Map::cast(obj)); { MaybeObject* maybe_obj = AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); if (!maybe_obj->ToObject(&obj)) return false; } set_non_strict_arguments_elements_map(Map::cast(obj)); { MaybeObject* maybe_obj = AllocateMap(EXTERNAL_DOUBLE_ARRAY_TYPE, ExternalArray::kAlignedSize); if (!maybe_obj->ToObject(&obj)) return false; } set_external_double_array_map(Map::cast(obj)); { MaybeObject* maybe_obj = AllocateMap(CODE_TYPE, kVariableSizeSentinel); if (!maybe_obj->ToObject(&obj)) return false; } set_code_map(Map::cast(obj)); { MaybeObject* maybe_obj = AllocateMap(JS_GLOBAL_PROPERTY_CELL_TYPE, JSGlobalPropertyCell::kSize); if (!maybe_obj->ToObject(&obj)) return false; } set_global_property_cell_map(Map::cast(obj)); { MaybeObject* maybe_obj = AllocateMap(FILLER_TYPE, kPointerSize); if (!maybe_obj->ToObject(&obj)) return false; } set_one_pointer_filler_map(Map::cast(obj)); { MaybeObject* maybe_obj = AllocateMap(FILLER_TYPE, 2 * kPointerSize); if (!maybe_obj->ToObject(&obj)) return false; } set_two_pointer_filler_map(Map::cast(obj)); for (unsigned i = 0; i < ARRAY_SIZE(struct_table); i++) { const StructTable& entry = struct_table[i]; { MaybeObject* maybe_obj = AllocateMap(entry.type, entry.size); if (!maybe_obj->ToObject(&obj)) return false; } roots_[entry.index] = Map::cast(obj); } { MaybeObject* maybe_obj = AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); if (!maybe_obj->ToObject(&obj)) return false; } set_hash_table_map(Map::cast(obj)); { MaybeObject* maybe_obj = AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); if (!maybe_obj->ToObject(&obj)) return false; } set_function_context_map(Map::cast(obj)); { MaybeObject* maybe_obj = AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); if (!maybe_obj->ToObject(&obj)) return false; } set_catch_context_map(Map::cast(obj)); { MaybeObject* maybe_obj = AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); if (!maybe_obj->ToObject(&obj)) return false; } set_with_context_map(Map::cast(obj)); { MaybeObject* maybe_obj = AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); if (!maybe_obj->ToObject(&obj)) return false; } set_block_context_map(Map::cast(obj)); { MaybeObject* maybe_obj = AllocateMap(FIXED_ARRAY_TYPE, kVariableSizeSentinel); if (!maybe_obj->ToObject(&obj)) return false; } Map* global_context_map = Map::cast(obj); global_context_map->set_visitor_id(StaticVisitorBase::kVisitGlobalContext); set_global_context_map(global_context_map); { MaybeObject* maybe_obj = AllocateMap(SHARED_FUNCTION_INFO_TYPE, SharedFunctionInfo::kAlignedSize); if (!maybe_obj->ToObject(&obj)) return false; } set_shared_function_info_map(Map::cast(obj)); { MaybeObject* maybe_obj = AllocateMap(JS_MESSAGE_OBJECT_TYPE, JSMessageObject::kSize); if (!maybe_obj->ToObject(&obj)) return false; } set_message_object_map(Map::cast(obj)); ASSERT(!InNewSpace(empty_fixed_array())); return true; } MaybeObject* Heap::AllocateHeapNumber(double value, PretenureFlag pretenure) { // Statically ensure that it is safe to allocate heap numbers in paged // spaces. STATIC_ASSERT(HeapNumber::kSize <= Page::kMaxHeapObjectSize); AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; Object* result; { MaybeObject* maybe_result = AllocateRaw(HeapNumber::kSize, space, OLD_DATA_SPACE); if (!maybe_result->ToObject(&result)) return maybe_result; } HeapObject::cast(result)->set_map_no_write_barrier(heap_number_map()); HeapNumber::cast(result)->set_value(value); return result; } MaybeObject* Heap::AllocateHeapNumber(double value) { // Use general version, if we're forced to always allocate. if (always_allocate()) return AllocateHeapNumber(value, TENURED); // This version of AllocateHeapNumber is optimized for // allocation in new space. STATIC_ASSERT(HeapNumber::kSize <= Page::kMaxHeapObjectSize); ASSERT(allocation_allowed_ && gc_state_ == NOT_IN_GC); Object* result; { MaybeObject* maybe_result = new_space_.AllocateRaw(HeapNumber::kSize); if (!maybe_result->ToObject(&result)) return maybe_result; } HeapObject::cast(result)->set_map_no_write_barrier(heap_number_map()); HeapNumber::cast(result)->set_value(value); return result; } MaybeObject* Heap::AllocateJSGlobalPropertyCell(Object* value) { Object* result; { MaybeObject* maybe_result = AllocateRawCell(); if (!maybe_result->ToObject(&result)) return maybe_result; } HeapObject::cast(result)->set_map_no_write_barrier( global_property_cell_map()); JSGlobalPropertyCell::cast(result)->set_value(value); return result; } MaybeObject* Heap::CreateOddball(const char* to_string, Object* to_number, byte kind) { Object* result; { MaybeObject* maybe_result = Allocate(oddball_map(), OLD_POINTER_SPACE); if (!maybe_result->ToObject(&result)) return maybe_result; } return Oddball::cast(result)->Initialize(to_string, to_number, kind); } bool Heap::CreateApiObjects() { Object* obj; { MaybeObject* maybe_obj = AllocateMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); if (!maybe_obj->ToObject(&obj)) return false; } // Don't use Smi-only elements optimizations for objects with the neander // map. There are too many cases where element values are set directly with a // bottleneck to trap the Smi-only -> fast elements transition, and there // appears to be no benefit for optimize this case. Map* new_neander_map = Map::cast(obj); new_neander_map->set_elements_kind(FAST_ELEMENTS); set_neander_map(new_neander_map); { MaybeObject* maybe_obj = AllocateJSObjectFromMap(neander_map()); if (!maybe_obj->ToObject(&obj)) return false; } Object* elements; { MaybeObject* maybe_elements = AllocateFixedArray(2); if (!maybe_elements->ToObject(&elements)) return false; } FixedArray::cast(elements)->set(0, Smi::FromInt(0)); JSObject::cast(obj)->set_elements(FixedArray::cast(elements)); set_message_listeners(JSObject::cast(obj)); return true; } void Heap::CreateJSEntryStub() { JSEntryStub stub; set_js_entry_code(*stub.GetCode()); } void Heap::CreateJSConstructEntryStub() { JSConstructEntryStub stub; set_js_construct_entry_code(*stub.GetCode()); } void Heap::CreateFixedStubs() { // Here we create roots for fixed stubs. They are needed at GC // for cooking and uncooking (check out frames.cc). // The eliminates the need for doing dictionary lookup in the // stub cache for these stubs. HandleScope scope; // gcc-4.4 has problem generating correct code of following snippet: // { JSEntryStub stub; // js_entry_code_ = *stub.GetCode(); // } // { JSConstructEntryStub stub; // js_construct_entry_code_ = *stub.GetCode(); // } // To workaround the problem, make separate functions without inlining. Heap::CreateJSEntryStub(); Heap::CreateJSConstructEntryStub(); // Create stubs that should be there, so we don't unexpectedly have to // create them if we need them during the creation of another stub. // Stub creation mixes raw pointers and handles in an unsafe manner so // we cannot create stubs while we are creating stubs. CodeStub::GenerateStubsAheadOfTime(); } bool Heap::CreateInitialObjects() { Object* obj; // The -0 value must be set before NumberFromDouble works. { MaybeObject* maybe_obj = AllocateHeapNumber(-0.0, TENURED); if (!maybe_obj->ToObject(&obj)) return false; } set_minus_zero_value(HeapNumber::cast(obj)); ASSERT(signbit(minus_zero_value()->Number()) != 0); { MaybeObject* maybe_obj = AllocateHeapNumber(OS::nan_value(), TENURED); if (!maybe_obj->ToObject(&obj)) return false; } set_nan_value(HeapNumber::cast(obj)); { MaybeObject* maybe_obj = AllocateHeapNumber(V8_INFINITY, TENURED); if (!maybe_obj->ToObject(&obj)) return false; } set_infinity_value(HeapNumber::cast(obj)); // The hole has not been created yet, but we want to put something // predictable in the gaps in the symbol table, so lets make that Smi zero. set_the_hole_value(reinterpret_cast<Oddball*>(Smi::FromInt(0))); // Allocate initial symbol table. { MaybeObject* maybe_obj = SymbolTable::Allocate(kInitialSymbolTableSize); if (!maybe_obj->ToObject(&obj)) return false; } // Don't use set_symbol_table() due to asserts. roots_[kSymbolTableRootIndex] = obj; // Finish initializing oddballs after creating symboltable. { MaybeObject* maybe_obj = undefined_value()->Initialize("undefined", nan_value(), Oddball::kUndefined); if (!maybe_obj->ToObject(&obj)) return false; } // Initialize the null_value. { MaybeObject* maybe_obj = null_value()->Initialize("null", Smi::FromInt(0), Oddball::kNull); if (!maybe_obj->ToObject(&obj)) return false; } { MaybeObject* maybe_obj = CreateOddball("true", Smi::FromInt(1), Oddball::kTrue); if (!maybe_obj->ToObject(&obj)) return false; } set_true_value(Oddball::cast(obj)); { MaybeObject* maybe_obj = CreateOddball("false", Smi::FromInt(0), Oddball::kFalse); if (!maybe_obj->ToObject(&obj)) return false; } set_false_value(Oddball::cast(obj)); { MaybeObject* maybe_obj = CreateOddball("hole", Smi::FromInt(-1), Oddball::kTheHole); if (!maybe_obj->ToObject(&obj)) return false; } set_the_hole_value(Oddball::cast(obj)); { MaybeObject* maybe_obj = CreateOddball("arguments_marker", Smi::FromInt(-2), Oddball::kArgumentMarker); if (!maybe_obj->ToObject(&obj)) return false; } set_arguments_marker(Oddball::cast(obj)); { MaybeObject* maybe_obj = CreateOddball("no_interceptor_result_sentinel", Smi::FromInt(-3), Oddball::kOther); if (!maybe_obj->ToObject(&obj)) return false; } set_no_interceptor_result_sentinel(obj); { MaybeObject* maybe_obj = CreateOddball("termination_exception", Smi::FromInt(-4), Oddball::kOther); if (!maybe_obj->ToObject(&obj)) return false; } set_termination_exception(obj); { MaybeObject* maybe_obj = CreateOddball("frame_alignment_marker", Smi::FromInt(-5), Oddball::kOther); if (!maybe_obj->ToObject(&obj)) return false; } set_frame_alignment_marker(Oddball::cast(obj)); STATIC_ASSERT(Oddball::kLeastHiddenOddballNumber == -5); // Allocate the empty string. { MaybeObject* maybe_obj = AllocateRawAsciiString(0, TENURED); if (!maybe_obj->ToObject(&obj)) return false; } set_empty_string(String::cast(obj)); for (unsigned i = 0; i < ARRAY_SIZE(constant_symbol_table); i++) { { MaybeObject* maybe_obj = LookupAsciiSymbol(constant_symbol_table[i].contents); if (!maybe_obj->ToObject(&obj)) return false; } roots_[constant_symbol_table[i].index] = String::cast(obj); } // Allocate the hidden symbol which is used to identify the hidden properties // in JSObjects. The hash code has a special value so that it will not match // the empty string when searching for the property. It cannot be part of the // loop above because it needs to be allocated manually with the special // hash code in place. The hash code for the hidden_symbol is zero to ensure // that it will always be at the first entry in property descriptors. { MaybeObject* maybe_obj = AllocateSymbol(CStrVector(""), 0, String::kZeroHash); if (!maybe_obj->ToObject(&obj)) return false; } hidden_symbol_ = String::cast(obj); // Allocate the foreign for __proto__. { MaybeObject* maybe_obj = AllocateForeign((Address) &Accessors::ObjectPrototype); if (!maybe_obj->ToObject(&obj)) return false; } set_prototype_accessors(Foreign::cast(obj)); // Allocate the code_stubs dictionary. The initial size is set to avoid // expanding the dictionary during bootstrapping. { MaybeObject* maybe_obj = UnseededNumberDictionary::Allocate(128); if (!maybe_obj->ToObject(&obj)) return false; } set_code_stubs(UnseededNumberDictionary::cast(obj)); // Allocate the non_monomorphic_cache used in stub-cache.cc. The initial size // is set to avoid expanding the dictionary during bootstrapping. { MaybeObject* maybe_obj = UnseededNumberDictionary::Allocate(64); if (!maybe_obj->ToObject(&obj)) return false; } set_non_monomorphic_cache(UnseededNumberDictionary::cast(obj)); { MaybeObject* maybe_obj = AllocatePolymorphicCodeCache(); if (!maybe_obj->ToObject(&obj)) return false; } set_polymorphic_code_cache(PolymorphicCodeCache::cast(obj)); set_instanceof_cache_function(Smi::FromInt(0)); set_instanceof_cache_map(Smi::FromInt(0)); set_instanceof_cache_answer(Smi::FromInt(0)); CreateFixedStubs(); // Allocate the dictionary of intrinsic function names. { MaybeObject* maybe_obj = StringDictionary::Allocate(Runtime::kNumFunctions); if (!maybe_obj->ToObject(&obj)) return false; } { MaybeObject* maybe_obj = Runtime::InitializeIntrinsicFunctionNames(this, obj); if (!maybe_obj->ToObject(&obj)) return false; } set_intrinsic_function_names(StringDictionary::cast(obj)); if (InitializeNumberStringCache()->IsFailure()) return false; // Allocate cache for single character ASCII strings. { MaybeObject* maybe_obj = AllocateFixedArray(String::kMaxAsciiCharCode + 1, TENURED); if (!maybe_obj->ToObject(&obj)) return false; } set_single_character_string_cache(FixedArray::cast(obj)); // Allocate cache for string split. { MaybeObject* maybe_obj = AllocateFixedArray(StringSplitCache::kStringSplitCacheSize, TENURED); if (!maybe_obj->ToObject(&obj)) return false; } set_string_split_cache(FixedArray::cast(obj)); // Allocate cache for external strings pointing to native source code. { MaybeObject* maybe_obj = AllocateFixedArray(Natives::GetBuiltinsCount()); if (!maybe_obj->ToObject(&obj)) return false; } set_natives_source_cache(FixedArray::cast(obj)); // Handling of script id generation is in FACTORY->NewScript. set_last_script_id(undefined_value()); // Initialize keyed lookup cache. isolate_->keyed_lookup_cache()->Clear(); // Initialize context slot cache. isolate_->context_slot_cache()->Clear(); // Initialize descriptor cache. isolate_->descriptor_lookup_cache()->Clear(); // Initialize compilation cache. isolate_->compilation_cache()->Clear(); return true; } Object* StringSplitCache::Lookup( FixedArray* cache, String* string, String* pattern) { if (!string->IsSymbol() || !pattern->IsSymbol()) return Smi::FromInt(0); uint32_t hash = string->Hash(); uint32_t index = ((hash & (kStringSplitCacheSize - 1)) & ~(kArrayEntriesPerCacheEntry - 1)); if (cache->get(index + kStringOffset) == string && cache->get(index + kPatternOffset) == pattern) { return cache->get(index + kArrayOffset); } index = ((index + kArrayEntriesPerCacheEntry) & (kStringSplitCacheSize - 1)); if (cache->get(index + kStringOffset) == string && cache->get(index + kPatternOffset) == pattern) { return cache->get(index + kArrayOffset); } return Smi::FromInt(0); } void StringSplitCache::Enter(Heap* heap, FixedArray* cache, String* string, String* pattern, FixedArray* array) { if (!string->IsSymbol() || !pattern->IsSymbol()) return; uint32_t hash = string->Hash(); uint32_t index = ((hash & (kStringSplitCacheSize - 1)) & ~(kArrayEntriesPerCacheEntry - 1)); if (cache->get(index + kStringOffset) == Smi::FromInt(0)) { cache->set(index + kStringOffset, string); cache->set(index + kPatternOffset, pattern); cache->set(index + kArrayOffset, array); } else { uint32_t index2 = ((index + kArrayEntriesPerCacheEntry) & (kStringSplitCacheSize - 1)); if (cache->get(index2 + kStringOffset) == Smi::FromInt(0)) { cache->set(index2 + kStringOffset, string); cache->set(index2 + kPatternOffset, pattern); cache->set(index2 + kArrayOffset, array); } else { cache->set(index2 + kStringOffset, Smi::FromInt(0)); cache->set(index2 + kPatternOffset, Smi::FromInt(0)); cache->set(index2 + kArrayOffset, Smi::FromInt(0)); cache->set(index + kStringOffset, string); cache->set(index + kPatternOffset, pattern); cache->set(index + kArrayOffset, array); } } if (array->length() < 100) { // Limit how many new symbols we want to make. for (int i = 0; i < array->length(); i++) { String* str = String::cast(array->get(i)); Object* symbol; MaybeObject* maybe_symbol = heap->LookupSymbol(str); if (maybe_symbol->ToObject(&symbol)) { array->set(i, symbol); } } } array->set_map_no_write_barrier(heap->fixed_cow_array_map()); } void StringSplitCache::Clear(FixedArray* cache) { for (int i = 0; i < kStringSplitCacheSize; i++) { cache->set(i, Smi::FromInt(0)); } } MaybeObject* Heap::InitializeNumberStringCache() { // Compute the size of the number string cache based on the max heap size. // max_semispace_size_ == 512 KB => number_string_cache_size = 32. // max_semispace_size_ == 8 MB => number_string_cache_size = 16KB. int number_string_cache_size = max_semispace_size_ / 512; number_string_cache_size = Max(32, Min(16*KB, number_string_cache_size)); Object* obj; MaybeObject* maybe_obj = AllocateFixedArray(number_string_cache_size * 2, TENURED); if (maybe_obj->ToObject(&obj)) set_number_string_cache(FixedArray::cast(obj)); return maybe_obj; } void Heap::FlushNumberStringCache() { // Flush the number to string cache. int len = number_string_cache()->length(); for (int i = 0; i < len; i++) { number_string_cache()->set_undefined(this, i); } } static inline int double_get_hash(double d) { DoubleRepresentation rep(d); return static_cast<int>(rep.bits) ^ static_cast<int>(rep.bits >> 32); } static inline int smi_get_hash(Smi* smi) { return smi->value(); } Object* Heap::GetNumberStringCache(Object* number) { int hash; int mask = (number_string_cache()->length() >> 1) - 1; if (number->IsSmi()) { hash = smi_get_hash(Smi::cast(number)) & mask; } else { hash = double_get_hash(number->Number()) & mask; } Object* key = number_string_cache()->get(hash * 2); if (key == number) { return String::cast(number_string_cache()->get(hash * 2 + 1)); } else if (key->IsHeapNumber() && number->IsHeapNumber() && key->Number() == number->Number()) { return String::cast(number_string_cache()->get(hash * 2 + 1)); } return undefined_value(); } void Heap::SetNumberStringCache(Object* number, String* string) { int hash; int mask = (number_string_cache()->length() >> 1) - 1; if (number->IsSmi()) { hash = smi_get_hash(Smi::cast(number)) & mask; number_string_cache()->set(hash * 2, Smi::cast(number)); } else { hash = double_get_hash(number->Number()) & mask; number_string_cache()->set(hash * 2, number); } number_string_cache()->set(hash * 2 + 1, string); } MaybeObject* Heap::NumberToString(Object* number, bool check_number_string_cache) { isolate_->counters()->number_to_string_runtime()->Increment(); if (check_number_string_cache) { Object* cached = GetNumberStringCache(number); if (cached != undefined_value()) { return cached; } } char arr[100]; Vector<char> buffer(arr, ARRAY_SIZE(arr)); const char* str; if (number->IsSmi()) { int num = Smi::cast(number)->value(); str = IntToCString(num, buffer); } else { double num = HeapNumber::cast(number)->value(); str = DoubleToCString(num, buffer); } Object* js_string; MaybeObject* maybe_js_string = AllocateStringFromAscii(CStrVector(str)); if (maybe_js_string->ToObject(&js_string)) { SetNumberStringCache(number, String::cast(js_string)); } return maybe_js_string; } MaybeObject* Heap::Uint32ToString(uint32_t value, bool check_number_string_cache) { Object* number; MaybeObject* maybe = NumberFromUint32(value); if (!maybe->To<Object>(&number)) return maybe; return NumberToString(number, check_number_string_cache); } Map* Heap::MapForExternalArrayType(ExternalArrayType array_type) { return Map::cast(roots_[RootIndexForExternalArrayType(array_type)]); } Heap::RootListIndex Heap::RootIndexForExternalArrayType( ExternalArrayType array_type) { switch (array_type) { case kExternalByteArray: return kExternalByteArrayMapRootIndex; case kExternalUnsignedByteArray: return kExternalUnsignedByteArrayMapRootIndex; case kExternalShortArray: return kExternalShortArrayMapRootIndex; case kExternalUnsignedShortArray: return kExternalUnsignedShortArrayMapRootIndex; case kExternalIntArray: return kExternalIntArrayMapRootIndex; case kExternalUnsignedIntArray: return kExternalUnsignedIntArrayMapRootIndex; case kExternalFloatArray: return kExternalFloatArrayMapRootIndex; case kExternalDoubleArray: return kExternalDoubleArrayMapRootIndex; case kExternalPixelArray: return kExternalPixelArrayMapRootIndex; default: UNREACHABLE(); return kUndefinedValueRootIndex; } } MaybeObject* Heap::NumberFromDouble(double value, PretenureFlag pretenure) { // We need to distinguish the minus zero value and this cannot be // done after conversion to int. Doing this by comparing bit // patterns is faster than using fpclassify() et al. static const DoubleRepresentation minus_zero(-0.0); DoubleRepresentation rep(value); if (rep.bits == minus_zero.bits) { return AllocateHeapNumber(-0.0, pretenure); } int int_value = FastD2I(value); if (value == int_value && Smi::IsValid(int_value)) { return Smi::FromInt(int_value); } // Materialize the value in the heap. return AllocateHeapNumber(value, pretenure); } MaybeObject* Heap::AllocateForeign(Address address, PretenureFlag pretenure) { // Statically ensure that it is safe to allocate foreigns in paged spaces. STATIC_ASSERT(Foreign::kSize <= Page::kMaxHeapObjectSize); AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; Foreign* result; MaybeObject* maybe_result = Allocate(foreign_map(), space); if (!maybe_result->To(&result)) return maybe_result; result->set_foreign_address(address); return result; } MaybeObject* Heap::AllocateSharedFunctionInfo(Object* name) { SharedFunctionInfo* share; MaybeObject* maybe = Allocate(shared_function_info_map(), OLD_POINTER_SPACE); if (!maybe->To<SharedFunctionInfo>(&share)) return maybe; // Set pointer fields. share->set_name(name); Code* illegal = isolate_->builtins()->builtin(Builtins::kIllegal); share->set_code(illegal); share->set_scope_info(ScopeInfo::Empty()); Code* construct_stub = isolate_->builtins()->builtin(Builtins::kJSConstructStubGeneric); share->set_construct_stub(construct_stub); share->set_instance_class_name(Object_symbol()); share->set_function_data(undefined_value(), SKIP_WRITE_BARRIER); share->set_script(undefined_value(), SKIP_WRITE_BARRIER); share->set_debug_info(undefined_value(), SKIP_WRITE_BARRIER); share->set_inferred_name(empty_string(), SKIP_WRITE_BARRIER); share->set_initial_map(undefined_value(), SKIP_WRITE_BARRIER); share->set_this_property_assignments(undefined_value(), SKIP_WRITE_BARRIER); share->set_deopt_counter(Smi::FromInt(FLAG_deopt_every_n_times)); // Set integer fields (smi or int, depending on the architecture). share->set_length(0); share->set_formal_parameter_count(0); share->set_expected_nof_properties(0); share->set_num_literals(0); share->set_start_position_and_type(0); share->set_end_position(0); share->set_function_token_position(0); // All compiler hints default to false or 0. share->set_compiler_hints(0); share->set_this_property_assignments_count(0); share->set_opt_count(0); return share; } MaybeObject* Heap::AllocateJSMessageObject(String* type, JSArray* arguments, int start_position, int end_position, Object* script, Object* stack_trace, Object* stack_frames) { Object* result; { MaybeObject* maybe_result = Allocate(message_object_map(), NEW_SPACE); if (!maybe_result->ToObject(&result)) return maybe_result; } JSMessageObject* message = JSMessageObject::cast(result); message->set_properties(Heap::empty_fixed_array(), SKIP_WRITE_BARRIER); message->set_elements(Heap::empty_fixed_array(), SKIP_WRITE_BARRIER); message->set_type(type); message->set_arguments(arguments); message->set_start_position(start_position); message->set_end_position(end_position); message->set_script(script); message->set_stack_trace(stack_trace); message->set_stack_frames(stack_frames); return result; } // Returns true for a character in a range. Both limits are inclusive. static inline bool Between(uint32_t character, uint32_t from, uint32_t to) { // This makes uses of the the unsigned wraparound. return character - from <= to - from; } MUST_USE_RESULT static inline MaybeObject* MakeOrFindTwoCharacterString( Heap* heap, uint32_t c1, uint32_t c2) { String* symbol; // Numeric strings have a different hash algorithm not known by // LookupTwoCharsSymbolIfExists, so we skip this step for such strings. if ((!Between(c1, '0', '9') || !Between(c2, '0', '9')) && heap->symbol_table()->LookupTwoCharsSymbolIfExists(c1, c2, &symbol)) { return symbol; // Now we know the length is 2, we might as well make use of that fact // when building the new string. } else if ((c1 | c2) <= String::kMaxAsciiCharCodeU) { // We can do this ASSERT(IsPowerOf2(String::kMaxAsciiCharCodeU + 1)); // because of this. Object* result; { MaybeObject* maybe_result = heap->AllocateRawAsciiString(2); if (!maybe_result->ToObject(&result)) return maybe_result; } char* dest = SeqAsciiString::cast(result)->GetChars(); dest[0] = c1; dest[1] = c2; return result; } else { Object* result; { MaybeObject* maybe_result = heap->AllocateRawTwoByteString(2); if (!maybe_result->ToObject(&result)) return maybe_result; } uc16* dest = SeqTwoByteString::cast(result)->GetChars(); dest[0] = c1; dest[1] = c2; return result; } } MaybeObject* Heap::AllocateConsString(String* first, String* second) { int first_length = first->length(); if (first_length == 0) { return second; } int second_length = second->length(); if (second_length == 0) { return first; } int length = first_length + second_length; // Optimization for 2-byte strings often used as keys in a decompression // dictionary. Check whether we already have the string in the symbol // table to prevent creation of many unneccesary strings. if (length == 2) { unsigned c1 = first->Get(0); unsigned c2 = second->Get(0); return MakeOrFindTwoCharacterString(this, c1, c2); } bool first_is_ascii = first->IsAsciiRepresentation(); bool second_is_ascii = second->IsAsciiRepresentation(); bool is_ascii = first_is_ascii && second_is_ascii; // Make sure that an out of memory exception is thrown if the length // of the new cons string is too large. if (length > String::kMaxLength || length < 0) { isolate()->context()->mark_out_of_memory(); return Failure::OutOfMemoryException(); } bool is_ascii_data_in_two_byte_string = false; if (!is_ascii) { // At least one of the strings uses two-byte representation so we // can't use the fast case code for short ASCII strings below, but // we can try to save memory if all chars actually fit in ASCII. is_ascii_data_in_two_byte_string = first->HasOnlyAsciiChars() && second->HasOnlyAsciiChars(); if (is_ascii_data_in_two_byte_string) { isolate_->counters()->string_add_runtime_ext_to_ascii()->Increment(); } } // If the resulting string is small make a flat string. if (length < ConsString::kMinLength) { // Note that neither of the two inputs can be a slice because: STATIC_ASSERT(ConsString::kMinLength <= SlicedString::kMinLength); ASSERT(first->IsFlat()); ASSERT(second->IsFlat()); if (is_ascii) { Object* result; { MaybeObject* maybe_result = AllocateRawAsciiString(length); if (!maybe_result->ToObject(&result)) return maybe_result; } // Copy the characters into the new object. char* dest = SeqAsciiString::cast(result)->GetChars(); // Copy first part. const char* src; if (first->IsExternalString()) { src = ExternalAsciiString::cast(first)->GetChars(); } else { src = SeqAsciiString::cast(first)->GetChars(); } for (int i = 0; i < first_length; i++) *dest++ = src[i]; // Copy second part. if (second->IsExternalString()) { src = ExternalAsciiString::cast(second)->GetChars(); } else { src = SeqAsciiString::cast(second)->GetChars(); } for (int i = 0; i < second_length; i++) *dest++ = src[i]; return result; } else { if (is_ascii_data_in_two_byte_string) { Object* result; { MaybeObject* maybe_result = AllocateRawAsciiString(length); if (!maybe_result->ToObject(&result)) return maybe_result; } // Copy the characters into the new object. char* dest = SeqAsciiString::cast(result)->GetChars(); String::WriteToFlat(first, dest, 0, first_length); String::WriteToFlat(second, dest + first_length, 0, second_length); isolate_->counters()->string_add_runtime_ext_to_ascii()->Increment(); return result; } Object* result; { MaybeObject* maybe_result = AllocateRawTwoByteString(length); if (!maybe_result->ToObject(&result)) return maybe_result; } // Copy the characters into the new object. uc16* dest = SeqTwoByteString::cast(result)->GetChars(); String::WriteToFlat(first, dest, 0, first_length); String::WriteToFlat(second, dest + first_length, 0, second_length); return result; } } Map* map = (is_ascii || is_ascii_data_in_two_byte_string) ? cons_ascii_string_map() : cons_string_map(); Object* result; { MaybeObject* maybe_result = Allocate(map, NEW_SPACE); if (!maybe_result->ToObject(&result)) return maybe_result; } AssertNoAllocation no_gc; ConsString* cons_string = ConsString::cast(result); WriteBarrierMode mode = cons_string->GetWriteBarrierMode(no_gc); cons_string->set_length(length); cons_string->set_hash_field(String::kEmptyHashField); cons_string->set_first(first, mode); cons_string->set_second(second, mode); return result; } MaybeObject* Heap::AllocateSubString(String* buffer, int start, int end, PretenureFlag pretenure) { int length = end - start; if (length <= 0) { return empty_string(); } else if (length == 1) { return LookupSingleCharacterStringFromCode(buffer->Get(start)); } else if (length == 2) { // Optimization for 2-byte strings often used as keys in a decompression // dictionary. Check whether we already have the string in the symbol // table to prevent creation of many unneccesary strings. unsigned c1 = buffer->Get(start); unsigned c2 = buffer->Get(start + 1); return MakeOrFindTwoCharacterString(this, c1, c2); } // Make an attempt to flatten the buffer to reduce access time. buffer = buffer->TryFlattenGetString(); if (!FLAG_string_slices || !buffer->IsFlat() || length < SlicedString::kMinLength || pretenure == TENURED) { Object* result; // WriteToFlat takes care of the case when an indirect string has a // different encoding from its underlying string. These encodings may // differ because of externalization. bool is_ascii = buffer->IsAsciiRepresentation(); { MaybeObject* maybe_result = is_ascii ? AllocateRawAsciiString(length, pretenure) : AllocateRawTwoByteString(length, pretenure); if (!maybe_result->ToObject(&result)) return maybe_result; } String* string_result = String::cast(result); // Copy the characters into the new object. if (is_ascii) { ASSERT(string_result->IsAsciiRepresentation()); char* dest = SeqAsciiString::cast(string_result)->GetChars(); String::WriteToFlat(buffer, dest, start, end); } else { ASSERT(string_result->IsTwoByteRepresentation()); uc16* dest = SeqTwoByteString::cast(string_result)->GetChars(); String::WriteToFlat(buffer, dest, start, end); } return result; } ASSERT(buffer->IsFlat()); #if DEBUG if (FLAG_verify_heap) { buffer->StringVerify(); } #endif Object* result; // When slicing an indirect string we use its encoding for a newly created // slice and don't check the encoding of the underlying string. This is safe // even if the encodings are different because of externalization. If an // indirect ASCII string is pointing to a two-byte string, the two-byte char // codes of the underlying string must still fit into ASCII (because // externalization must not change char codes). { Map* map = buffer->IsAsciiRepresentation() ? sliced_ascii_string_map() : sliced_string_map(); MaybeObject* maybe_result = Allocate(map, NEW_SPACE); if (!maybe_result->ToObject(&result)) return maybe_result; } AssertNoAllocation no_gc; SlicedString* sliced_string = SlicedString::cast(result); sliced_string->set_length(length); sliced_string->set_hash_field(String::kEmptyHashField); if (buffer->IsConsString()) { ConsString* cons = ConsString::cast(buffer); ASSERT(cons->second()->length() == 0); sliced_string->set_parent(cons->first()); sliced_string->set_offset(start); } else if (buffer->IsSlicedString()) { // Prevent nesting sliced strings. SlicedString* parent_slice = SlicedString::cast(buffer); sliced_string->set_parent(parent_slice->parent()); sliced_string->set_offset(start + parent_slice->offset()); } else { sliced_string->set_parent(buffer); sliced_string->set_offset(start); } ASSERT(sliced_string->parent()->IsSeqString() || sliced_string->parent()->IsExternalString()); return result; } MaybeObject* Heap::AllocateExternalStringFromAscii( const ExternalAsciiString::Resource* resource) { size_t length = resource->length(); if (length > static_cast<size_t>(String::kMaxLength)) { isolate()->context()->mark_out_of_memory(); return Failure::OutOfMemoryException(); } Map* map = external_ascii_string_map(); Object* result; { MaybeObject* maybe_result = Allocate(map, NEW_SPACE); if (!maybe_result->ToObject(&result)) return maybe_result; } ExternalAsciiString* external_string = ExternalAsciiString::cast(result); external_string->set_length(static_cast<int>(length)); external_string->set_hash_field(String::kEmptyHashField); external_string->set_resource(resource); return result; } MaybeObject* Heap::AllocateExternalStringFromTwoByte( const ExternalTwoByteString::Resource* resource) { size_t length = resource->length(); if (length > static_cast<size_t>(String::kMaxLength)) { isolate()->context()->mark_out_of_memory(); return Failure::OutOfMemoryException(); } // For small strings we check whether the resource contains only // ASCII characters. If yes, we use a different string map. static const size_t kAsciiCheckLengthLimit = 32; bool is_ascii = length <= kAsciiCheckLengthLimit && String::IsAscii(resource->data(), static_cast<int>(length)); Map* map = is_ascii ? external_string_with_ascii_data_map() : external_string_map(); Object* result; { MaybeObject* maybe_result = Allocate(map, NEW_SPACE); if (!maybe_result->ToObject(&result)) return maybe_result; } ExternalTwoByteString* external_string = ExternalTwoByteString::cast(result); external_string->set_length(static_cast<int>(length)); external_string->set_hash_field(String::kEmptyHashField); external_string->set_resource(resource); return result; } MaybeObject* Heap::LookupSingleCharacterStringFromCode(uint16_t code) { if (code <= String::kMaxAsciiCharCode) { Object* value = single_character_string_cache()->get(code); if (value != undefined_value()) return value; char buffer[1]; buffer[0] = static_cast<char>(code); Object* result; MaybeObject* maybe_result = LookupSymbol(Vector<const char>(buffer, 1)); if (!maybe_result->ToObject(&result)) return maybe_result; single_character_string_cache()->set(code, result); return result; } Object* result; { MaybeObject* maybe_result = AllocateRawTwoByteString(1); if (!maybe_result->ToObject(&result)) return maybe_result; } String* answer = String::cast(result); answer->Set(0, code); return answer; } MaybeObject* Heap::AllocateByteArray(int length, PretenureFlag pretenure) { if (length < 0 || length > ByteArray::kMaxLength) { return Failure::OutOfMemoryException(); } if (pretenure == NOT_TENURED) { return AllocateByteArray(length); } int size = ByteArray::SizeFor(length); Object* result; { MaybeObject* maybe_result = (size <= MaxObjectSizeInPagedSpace()) ? old_data_space_->AllocateRaw(size) : lo_space_->AllocateRaw(size, NOT_EXECUTABLE); if (!maybe_result->ToObject(&result)) return maybe_result; } reinterpret_cast<ByteArray*>(result)->set_map_no_write_barrier( byte_array_map()); reinterpret_cast<ByteArray*>(result)->set_length(length); return result; } MaybeObject* Heap::AllocateByteArray(int length) { if (length < 0 || length > ByteArray::kMaxLength) { return Failure::OutOfMemoryException(); } int size = ByteArray::SizeFor(length); AllocationSpace space = (size > MaxObjectSizeInPagedSpace()) ? LO_SPACE : NEW_SPACE; Object* result; { MaybeObject* maybe_result = AllocateRaw(size, space, OLD_DATA_SPACE); if (!maybe_result->ToObject(&result)) return maybe_result; } reinterpret_cast<ByteArray*>(result)->set_map_no_write_barrier( byte_array_map()); reinterpret_cast<ByteArray*>(result)->set_length(length); return result; } void Heap::CreateFillerObjectAt(Address addr, int size) { if (size == 0) return; HeapObject* filler = HeapObject::FromAddress(addr); if (size == kPointerSize) { filler->set_map_no_write_barrier(one_pointer_filler_map()); } else if (size == 2 * kPointerSize) { filler->set_map_no_write_barrier(two_pointer_filler_map()); } else { filler->set_map_no_write_barrier(free_space_map()); FreeSpace::cast(filler)->set_size(size); } } MaybeObject* Heap::AllocateExternalArray(int length, ExternalArrayType array_type, void* external_pointer, PretenureFlag pretenure) { AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; Object* result; { MaybeObject* maybe_result = AllocateRaw(ExternalArray::kAlignedSize, space, OLD_DATA_SPACE); if (!maybe_result->ToObject(&result)) return maybe_result; } reinterpret_cast<ExternalArray*>(result)->set_map_no_write_barrier( MapForExternalArrayType(array_type)); reinterpret_cast<ExternalArray*>(result)->set_length(length); reinterpret_cast<ExternalArray*>(result)->set_external_pointer( external_pointer); return result; } MaybeObject* Heap::CreateCode(const CodeDesc& desc, Code::Flags flags, Handle<Object> self_reference, bool immovable) { // Allocate ByteArray before the Code object, so that we do not risk // leaving uninitialized Code object (and breaking the heap). ByteArray* reloc_info; MaybeObject* maybe_reloc_info = AllocateByteArray(desc.reloc_size, TENURED); if (!maybe_reloc_info->To(&reloc_info)) return maybe_reloc_info; // Compute size. int body_size = RoundUp(desc.instr_size, kObjectAlignment); int obj_size = Code::SizeFor(body_size); ASSERT(IsAligned(static_cast<intptr_t>(obj_size), kCodeAlignment)); MaybeObject* maybe_result; // Large code objects and code objects which should stay at a fixed address // are allocated in large object space. if (obj_size > MaxObjectSizeInPagedSpace() || immovable) { maybe_result = lo_space_->AllocateRaw(obj_size, EXECUTABLE); } else { maybe_result = code_space_->AllocateRaw(obj_size); } Object* result; if (!maybe_result->ToObject(&result)) return maybe_result; // Initialize the object HeapObject::cast(result)->set_map_no_write_barrier(code_map()); Code* code = Code::cast(result); ASSERT(!isolate_->code_range()->exists() || isolate_->code_range()->contains(code->address())); code->set_instruction_size(desc.instr_size); code->set_relocation_info(reloc_info); code->set_flags(flags); if (code->is_call_stub() || code->is_keyed_call_stub()) { code->set_check_type(RECEIVER_MAP_CHECK); } code->set_deoptimization_data(empty_fixed_array(), SKIP_WRITE_BARRIER); code->set_handler_table(empty_fixed_array(), SKIP_WRITE_BARRIER); code->set_next_code_flushing_candidate(undefined_value()); // Allow self references to created code object by patching the handle to // point to the newly allocated Code object. if (!self_reference.is_null()) { *(self_reference.location()) = code; } // Migrate generated code. // The generated code can contain Object** values (typically from handles) // that are dereferenced during the copy to point directly to the actual heap // objects. These pointers can include references to the code object itself, // through the self_reference parameter. code->CopyFrom(desc); #ifdef DEBUG if (FLAG_verify_heap) { code->Verify(); } #endif return code; } MaybeObject* Heap::CopyCode(Code* code) { // Allocate an object the same size as the code object. int obj_size = code->Size(); MaybeObject* maybe_result; if (obj_size > MaxObjectSizeInPagedSpace()) { maybe_result = lo_space_->AllocateRaw(obj_size, EXECUTABLE); } else { maybe_result = code_space_->AllocateRaw(obj_size); } Object* result; if (!maybe_result->ToObject(&result)) return maybe_result; // Copy code object. Address old_addr = code->address(); Address new_addr = reinterpret_cast<HeapObject*>(result)->address(); CopyBlock(new_addr, old_addr, obj_size); // Relocate the copy. Code* new_code = Code::cast(result); ASSERT(!isolate_->code_range()->exists() || isolate_->code_range()->contains(code->address())); new_code->Relocate(new_addr - old_addr); return new_code; } MaybeObject* Heap::CopyCode(Code* code, Vector<byte> reloc_info) { // Allocate ByteArray before the Code object, so that we do not risk // leaving uninitialized Code object (and breaking the heap). Object* reloc_info_array; { MaybeObject* maybe_reloc_info_array = AllocateByteArray(reloc_info.length(), TENURED); if (!maybe_reloc_info_array->ToObject(&reloc_info_array)) { return maybe_reloc_info_array; } } int new_body_size = RoundUp(code->instruction_size(), kObjectAlignment); int new_obj_size = Code::SizeFor(new_body_size); Address old_addr = code->address(); size_t relocation_offset = static_cast<size_t>(code->instruction_end() - old_addr); MaybeObject* maybe_result; if (new_obj_size > MaxObjectSizeInPagedSpace()) { maybe_result = lo_space_->AllocateRaw(new_obj_size, EXECUTABLE); } else { maybe_result = code_space_->AllocateRaw(new_obj_size); } Object* result; if (!maybe_result->ToObject(&result)) return maybe_result; // Copy code object. Address new_addr = reinterpret_cast<HeapObject*>(result)->address(); // Copy header and instructions. memcpy(new_addr, old_addr, relocation_offset); Code* new_code = Code::cast(result); new_code->set_relocation_info(ByteArray::cast(reloc_info_array)); // Copy patched rinfo. memcpy(new_code->relocation_start(), reloc_info.start(), reloc_info.length()); // Relocate the copy. ASSERT(!isolate_->code_range()->exists() || isolate_->code_range()->contains(code->address())); new_code->Relocate(new_addr - old_addr); #ifdef DEBUG if (FLAG_verify_heap) { code->Verify(); } #endif return new_code; } MaybeObject* Heap::Allocate(Map* map, AllocationSpace space) { ASSERT(gc_state_ == NOT_IN_GC); ASSERT(map->instance_type() != MAP_TYPE); // If allocation failures are disallowed, we may allocate in a different // space when new space is full and the object is not a large object. AllocationSpace retry_space = (space != NEW_SPACE) ? space : TargetSpaceId(map->instance_type()); Object* result; { MaybeObject* maybe_result = AllocateRaw(map->instance_size(), space, retry_space); if (!maybe_result->ToObject(&result)) return maybe_result; } // No need for write barrier since object is white and map is in old space. HeapObject::cast(result)->set_map_no_write_barrier(map); return result; } void Heap::InitializeFunction(JSFunction* function, SharedFunctionInfo* shared, Object* prototype) { ASSERT(!prototype->IsMap()); function->initialize_properties(); function->initialize_elements(); function->set_shared(shared); function->set_code(shared->code()); function->set_prototype_or_initial_map(prototype); function->set_context(undefined_value()); function->set_literals_or_bindings(empty_fixed_array()); function->set_next_function_link(undefined_value()); } MaybeObject* Heap::AllocateFunctionPrototype(JSFunction* function) { // Allocate the prototype. Make sure to use the object function // from the function's context, since the function can be from a // different context. JSFunction* object_function = function->context()->global_context()->object_function(); // Each function prototype gets a copy of the object function map. // This avoid unwanted sharing of maps between prototypes of different // constructors. Map* new_map; ASSERT(object_function->has_initial_map()); { MaybeObject* maybe_map = object_function->initial_map()->CopyDropTransitions(); if (!maybe_map->To<Map>(&new_map)) return maybe_map; } Object* prototype; { MaybeObject* maybe_prototype = AllocateJSObjectFromMap(new_map); if (!maybe_prototype->ToObject(&prototype)) return maybe_prototype; } // When creating the prototype for the function we must set its // constructor to the function. Object* result; { MaybeObject* maybe_result = JSObject::cast(prototype)->SetLocalPropertyIgnoreAttributes( constructor_symbol(), function, DONT_ENUM); if (!maybe_result->ToObject(&result)) return maybe_result; } return prototype; } MaybeObject* Heap::AllocateFunction(Map* function_map, SharedFunctionInfo* shared, Object* prototype, PretenureFlag pretenure) { AllocationSpace space = (pretenure == TENURED) ? OLD_POINTER_SPACE : NEW_SPACE; Object* result; { MaybeObject* maybe_result = Allocate(function_map, space); if (!maybe_result->ToObject(&result)) return maybe_result; } InitializeFunction(JSFunction::cast(result), shared, prototype); return result; } MaybeObject* Heap::AllocateArgumentsObject(Object* callee, int length) { // To get fast allocation and map sharing for arguments objects we // allocate them based on an arguments boilerplate. JSObject* boilerplate; int arguments_object_size; bool strict_mode_callee = callee->IsJSFunction() && !JSFunction::cast(callee)->shared()->is_classic_mode(); if (strict_mode_callee) { boilerplate = isolate()->context()->global_context()-> strict_mode_arguments_boilerplate(); arguments_object_size = kArgumentsObjectSizeStrict; } else { boilerplate = isolate()->context()->global_context()->arguments_boilerplate(); arguments_object_size = kArgumentsObjectSize; } // This calls Copy directly rather than using Heap::AllocateRaw so we // duplicate the check here. ASSERT(allocation_allowed_ && gc_state_ == NOT_IN_GC); // Check that the size of the boilerplate matches our // expectations. The ArgumentsAccessStub::GenerateNewObject relies // on the size being a known constant. ASSERT(arguments_object_size == boilerplate->map()->instance_size()); // Do the allocation. Object* result; { MaybeObject* maybe_result = AllocateRaw(arguments_object_size, NEW_SPACE, OLD_POINTER_SPACE); if (!maybe_result->ToObject(&result)) return maybe_result; } // Copy the content. The arguments boilerplate doesn't have any // fields that point to new space so it's safe to skip the write // barrier here. CopyBlock(HeapObject::cast(result)->address(), boilerplate->address(), JSObject::kHeaderSize); // Set the length property. JSObject::cast(result)->InObjectPropertyAtPut(kArgumentsLengthIndex, Smi::FromInt(length), SKIP_WRITE_BARRIER); // Set the callee property for non-strict mode arguments object only. if (!strict_mode_callee) { JSObject::cast(result)->InObjectPropertyAtPut(kArgumentsCalleeIndex, callee); } // Check the state of the object ASSERT(JSObject::cast(result)->HasFastProperties()); ASSERT(JSObject::cast(result)->HasFastElements()); return result; } static bool HasDuplicates(DescriptorArray* descriptors) { int count = descriptors->number_of_descriptors(); if (count > 1) { String* prev_key = descriptors->GetKey(0); for (int i = 1; i != count; i++) { String* current_key = descriptors->GetKey(i); if (prev_key == current_key) return true; prev_key = current_key; } } return false; } MaybeObject* Heap::AllocateInitialMap(JSFunction* fun) { ASSERT(!fun->has_initial_map()); // First create a new map with the size and number of in-object properties // suggested by the function. int instance_size = fun->shared()->CalculateInstanceSize(); int in_object_properties = fun->shared()->CalculateInObjectProperties(); Object* map_obj; { MaybeObject* maybe_map_obj = AllocateMap(JS_OBJECT_TYPE, instance_size); if (!maybe_map_obj->ToObject(&map_obj)) return maybe_map_obj; } // Fetch or allocate prototype. Object* prototype; if (fun->has_instance_prototype()) { prototype = fun->instance_prototype(); } else { { MaybeObject* maybe_prototype = AllocateFunctionPrototype(fun); if (!maybe_prototype->ToObject(&prototype)) return maybe_prototype; } } Map* map = Map::cast(map_obj); map->set_inobject_properties(in_object_properties); map->set_unused_property_fields(in_object_properties); map->set_prototype(prototype); ASSERT(map->has_fast_elements()); // If the function has only simple this property assignments add // field descriptors for these to the initial map as the object // cannot be constructed without having these properties. Guard by // the inline_new flag so we only change the map if we generate a // specialized construct stub. ASSERT(in_object_properties <= Map::kMaxPreAllocatedPropertyFields); if (fun->shared()->CanGenerateInlineConstructor(prototype)) { int count = fun->shared()->this_property_assignments_count(); if (count > in_object_properties) { // Inline constructor can only handle inobject properties. fun->shared()->ForbidInlineConstructor(); } else { DescriptorArray* descriptors; { MaybeObject* maybe_descriptors_obj = DescriptorArray::Allocate(count); if (!maybe_descriptors_obj->To<DescriptorArray>(&descriptors)) { return maybe_descriptors_obj; } } DescriptorArray::WhitenessWitness witness(descriptors); for (int i = 0; i < count; i++) { String* name = fun->shared()->GetThisPropertyAssignmentName(i); ASSERT(name->IsSymbol()); FieldDescriptor field(name, i, NONE); field.SetEnumerationIndex(i); descriptors->Set(i, &field, witness); } descriptors->SetNextEnumerationIndex(count); descriptors->SortUnchecked(witness); // The descriptors may contain duplicates because the compiler does not // guarantee the uniqueness of property names (it would have required // quadratic time). Once the descriptors are sorted we can check for // duplicates in linear time. if (HasDuplicates(descriptors)) { fun->shared()->ForbidInlineConstructor(); } else { map->set_instance_descriptors(descriptors); map->set_pre_allocated_property_fields(count); map->set_unused_property_fields(in_object_properties - count); } } } fun->shared()->StartInobjectSlackTracking(map); return map; } void Heap::InitializeJSObjectFromMap(JSObject* obj, FixedArray* properties, Map* map) { obj->set_properties(properties); obj->initialize_elements(); // TODO(1240798): Initialize the object's body using valid initial values // according to the object's initial map. For example, if the map's // instance type is JS_ARRAY_TYPE, the length field should be initialized // to a number (e.g. Smi::FromInt(0)) and the elements initialized to a // fixed array (e.g. Heap::empty_fixed_array()). Currently, the object // verification code has to cope with (temporarily) invalid objects. See // for example, JSArray::JSArrayVerify). Object* filler; // We cannot always fill with one_pointer_filler_map because objects // created from API functions expect their internal fields to be initialized // with undefined_value. // Pre-allocated fields need to be initialized with undefined_value as well // so that object accesses before the constructor completes (e.g. in the // debugger) will not cause a crash. if (map->constructor()->IsJSFunction() && JSFunction::cast(map->constructor())->shared()-> IsInobjectSlackTrackingInProgress()) { // We might want to shrink the object later. ASSERT(obj->GetInternalFieldCount() == 0); filler = Heap::one_pointer_filler_map(); } else { filler = Heap::undefined_value(); } obj->InitializeBody(map, Heap::undefined_value(), filler); } MaybeObject* Heap::AllocateJSObjectFromMap(Map* map, PretenureFlag pretenure) { // JSFunctions should be allocated using AllocateFunction to be // properly initialized. ASSERT(map->instance_type() != JS_FUNCTION_TYPE); // Both types of global objects should be allocated using // AllocateGlobalObject to be properly initialized. ASSERT(map->instance_type() != JS_GLOBAL_OBJECT_TYPE); ASSERT(map->instance_type() != JS_BUILTINS_OBJECT_TYPE); // Allocate the backing storage for the properties. int prop_size = map->pre_allocated_property_fields() + map->unused_property_fields() - map->inobject_properties(); ASSERT(prop_size >= 0); Object* properties; { MaybeObject* maybe_properties = AllocateFixedArray(prop_size, pretenure); if (!maybe_properties->ToObject(&properties)) return maybe_properties; } // Allocate the JSObject. AllocationSpace space = (pretenure == TENURED) ? OLD_POINTER_SPACE : NEW_SPACE; if (map->instance_size() > MaxObjectSizeInPagedSpace()) space = LO_SPACE; Object* obj; { MaybeObject* maybe_obj = Allocate(map, space); if (!maybe_obj->ToObject(&obj)) return maybe_obj; } // Initialize the JSObject. InitializeJSObjectFromMap(JSObject::cast(obj), FixedArray::cast(properties), map); ASSERT(JSObject::cast(obj)->HasFastSmiOnlyElements() || JSObject::cast(obj)->HasFastElements()); return obj; } MaybeObject* Heap::AllocateJSObject(JSFunction* constructor, PretenureFlag pretenure) { // Allocate the initial map if absent. if (!constructor->has_initial_map()) { Object* initial_map; { MaybeObject* maybe_initial_map = AllocateInitialMap(constructor); if (!maybe_initial_map->ToObject(&initial_map)) return maybe_initial_map; } constructor->set_initial_map(Map::cast(initial_map)); Map::cast(initial_map)->set_constructor(constructor); } // Allocate the object based on the constructors initial map. MaybeObject* result = AllocateJSObjectFromMap(constructor->initial_map(), pretenure); #ifdef DEBUG // Make sure result is NOT a global object if valid. Object* non_failure; ASSERT(!result->ToObject(&non_failure) || !non_failure->IsGlobalObject()); #endif return result; } MaybeObject* Heap::AllocateJSProxy(Object* handler, Object* prototype) { // Allocate map. // TODO(rossberg): Once we optimize proxies, think about a scheme to share // maps. Will probably depend on the identity of the handler object, too. Map* map; MaybeObject* maybe_map_obj = AllocateMap(JS_PROXY_TYPE, JSProxy::kSize); if (!maybe_map_obj->To<Map>(&map)) return maybe_map_obj; map->set_prototype(prototype); // Allocate the proxy object. JSProxy* result; MaybeObject* maybe_result = Allocate(map, NEW_SPACE); if (!maybe_result->To<JSProxy>(&result)) return maybe_result; result->InitializeBody(map->instance_size(), Smi::FromInt(0)); result->set_handler(handler); result->set_hash(undefined_value(), SKIP_WRITE_BARRIER); return result; } MaybeObject* Heap::AllocateJSFunctionProxy(Object* handler, Object* call_trap, Object* construct_trap, Object* prototype) { // Allocate map. // TODO(rossberg): Once we optimize proxies, think about a scheme to share // maps. Will probably depend on the identity of the handler object, too. Map* map; MaybeObject* maybe_map_obj = AllocateMap(JS_FUNCTION_PROXY_TYPE, JSFunctionProxy::kSize); if (!maybe_map_obj->To<Map>(&map)) return maybe_map_obj; map->set_prototype(prototype); // Allocate the proxy object. JSFunctionProxy* result; MaybeObject* maybe_result = Allocate(map, NEW_SPACE); if (!maybe_result->To<JSFunctionProxy>(&result)) return maybe_result; result->InitializeBody(map->instance_size(), Smi::FromInt(0)); result->set_handler(handler); result->set_hash(undefined_value(), SKIP_WRITE_BARRIER); result->set_call_trap(call_trap); result->set_construct_trap(construct_trap); return result; } MaybeObject* Heap::AllocateGlobalObject(JSFunction* constructor) { ASSERT(constructor->has_initial_map()); Map* map = constructor->initial_map(); // Make sure no field properties are described in the initial map. // This guarantees us that normalizing the properties does not // require us to change property values to JSGlobalPropertyCells. ASSERT(map->NextFreePropertyIndex() == 0); // Make sure we don't have a ton of pre-allocated slots in the // global objects. They will be unused once we normalize the object. ASSERT(map->unused_property_fields() == 0); ASSERT(map->inobject_properties() == 0); // Initial size of the backing store to avoid resize of the storage during // bootstrapping. The size differs between the JS global object ad the // builtins object. int initial_size = map->instance_type() == JS_GLOBAL_OBJECT_TYPE ? 64 : 512; // Allocate a dictionary object for backing storage. Object* obj; { MaybeObject* maybe_obj = StringDictionary::Allocate( map->NumberOfDescribedProperties() * 2 + initial_size); if (!maybe_obj->ToObject(&obj)) return maybe_obj; } StringDictionary* dictionary = StringDictionary::cast(obj); // The global object might be created from an object template with accessors. // Fill these accessors into the dictionary. DescriptorArray* descs = map->instance_descriptors(); for (int i = 0; i < descs->number_of_descriptors(); i++) { PropertyDetails details(descs->GetDetails(i)); ASSERT(details.type() == CALLBACKS); // Only accessors are expected. PropertyDetails d = PropertyDetails(details.attributes(), CALLBACKS, details.index()); Object* value = descs->GetCallbacksObject(i); { MaybeObject* maybe_value = AllocateJSGlobalPropertyCell(value); if (!maybe_value->ToObject(&value)) return maybe_value; } Object* result; { MaybeObject* maybe_result = dictionary->Add(descs->GetKey(i), value, d); if (!maybe_result->ToObject(&result)) return maybe_result; } dictionary = StringDictionary::cast(result); } // Allocate the global object and initialize it with the backing store. { MaybeObject* maybe_obj = Allocate(map, OLD_POINTER_SPACE); if (!maybe_obj->ToObject(&obj)) return maybe_obj; } JSObject* global = JSObject::cast(obj); InitializeJSObjectFromMap(global, dictionary, map); // Create a new map for the global object. { MaybeObject* maybe_obj = map->CopyDropDescriptors(); if (!maybe_obj->ToObject(&obj)) return maybe_obj; } Map* new_map = Map::cast(obj); // Set up the global object as a normalized object. global->set_map(new_map); global->map()->clear_instance_descriptors(); global->set_properties(dictionary); // Make sure result is a global object with properties in dictionary. ASSERT(global->IsGlobalObject()); ASSERT(!global->HasFastProperties()); return global; } MaybeObject* Heap::CopyJSObject(JSObject* source) { // Never used to copy functions. If functions need to be copied we // have to be careful to clear the literals array. SLOW_ASSERT(!source->IsJSFunction()); // Make the clone. Map* map = source->map(); int object_size = map->instance_size(); Object* clone; WriteBarrierMode wb_mode = UPDATE_WRITE_BARRIER; // If we're forced to always allocate, we use the general allocation // functions which may leave us with an object in old space. if (always_allocate()) { { MaybeObject* maybe_clone = AllocateRaw(object_size, NEW_SPACE, OLD_POINTER_SPACE); if (!maybe_clone->ToObject(&clone)) return maybe_clone; } Address clone_address = HeapObject::cast(clone)->address(); CopyBlock(clone_address, source->address(), object_size); // Update write barrier for all fields that lie beyond the header. RecordWrites(clone_address, JSObject::kHeaderSize, (object_size - JSObject::kHeaderSize) / kPointerSize); } else { wb_mode = SKIP_WRITE_BARRIER; { MaybeObject* maybe_clone = new_space_.AllocateRaw(object_size); if (!maybe_clone->ToObject(&clone)) return maybe_clone; } SLOW_ASSERT(InNewSpace(clone)); // Since we know the clone is allocated in new space, we can copy // the contents without worrying about updating the write barrier. CopyBlock(HeapObject::cast(clone)->address(), source->address(), object_size); } SLOW_ASSERT( JSObject::cast(clone)->GetElementsKind() == source->GetElementsKind()); FixedArrayBase* elements = FixedArrayBase::cast(source->elements()); FixedArray* properties = FixedArray::cast(source->properties()); // Update elements if necessary. if (elements->length() > 0) { Object* elem; { MaybeObject* maybe_elem; if (elements->map() == fixed_cow_array_map()) { maybe_elem = FixedArray::cast(elements); } else if (source->HasFastDoubleElements()) { maybe_elem = CopyFixedDoubleArray(FixedDoubleArray::cast(elements)); } else { maybe_elem = CopyFixedArray(FixedArray::cast(elements)); } if (!maybe_elem->ToObject(&elem)) return maybe_elem; } JSObject::cast(clone)->set_elements(FixedArrayBase::cast(elem), wb_mode); } // Update properties if necessary. if (properties->length() > 0) { Object* prop; { MaybeObject* maybe_prop = CopyFixedArray(properties); if (!maybe_prop->ToObject(&prop)) return maybe_prop; } JSObject::cast(clone)->set_properties(FixedArray::cast(prop), wb_mode); } // Return the new clone. return clone; } MaybeObject* Heap::ReinitializeJSReceiver( JSReceiver* object, InstanceType type, int size) { ASSERT(type >= FIRST_JS_OBJECT_TYPE); // Allocate fresh map. // TODO(rossberg): Once we optimize proxies, cache these maps. Map* map; MaybeObject* maybe = AllocateMap(type, size); if (!maybe->To<Map>(&map)) return maybe; // Check that the receiver has at least the size of the fresh object. int size_difference = object->map()->instance_size() - map->instance_size(); ASSERT(size_difference >= 0); map->set_prototype(object->map()->prototype()); // Allocate the backing storage for the properties. int prop_size = map->unused_property_fields() - map->inobject_properties(); Object* properties; maybe = AllocateFixedArray(prop_size, TENURED); if (!maybe->ToObject(&properties)) return maybe; // Functions require some allocation, which might fail here. SharedFunctionInfo* shared = NULL; if (type == JS_FUNCTION_TYPE) { String* name; maybe = LookupAsciiSymbol("<freezing call trap>"); if (!maybe->To<String>(&name)) return maybe; maybe = AllocateSharedFunctionInfo(name); if (!maybe->To<SharedFunctionInfo>(&shared)) return maybe; } // Because of possible retries of this function after failure, // we must NOT fail after this point, where we have changed the type! // Reset the map for the object. object->set_map(map); JSObject* jsobj = JSObject::cast(object); // Reinitialize the object from the constructor map. InitializeJSObjectFromMap(jsobj, FixedArray::cast(properties), map); // Functions require some minimal initialization. if (type == JS_FUNCTION_TYPE) { map->set_function_with_prototype(true); InitializeFunction(JSFunction::cast(object), shared, the_hole_value()); JSFunction::cast(object)->set_context( isolate()->context()->global_context()); } // Put in filler if the new object is smaller than the old. if (size_difference > 0) { CreateFillerObjectAt( object->address() + map->instance_size(), size_difference); } return object; } MaybeObject* Heap::ReinitializeJSGlobalProxy(JSFunction* constructor, JSGlobalProxy* object) { ASSERT(constructor->has_initial_map()); Map* map = constructor->initial_map(); // Check that the already allocated object has the same size and type as // objects allocated using the constructor. ASSERT(map->instance_size() == object->map()->instance_size()); ASSERT(map->instance_type() == object->map()->instance_type()); // Allocate the backing storage for the properties. int prop_size = map->unused_property_fields() - map->inobject_properties(); Object* properties; { MaybeObject* maybe_properties = AllocateFixedArray(prop_size, TENURED); if (!maybe_properties->ToObject(&properties)) return maybe_properties; } // Reset the map for the object. object->set_map(constructor->initial_map()); // Reinitialize the object from the constructor map. InitializeJSObjectFromMap(object, FixedArray::cast(properties), map); return object; } MaybeObject* Heap::AllocateStringFromAscii(Vector<const char> string, PretenureFlag pretenure) { if (string.length() == 1) { return Heap::LookupSingleCharacterStringFromCode(string[0]); } Object* result; { MaybeObject* maybe_result = AllocateRawAsciiString(string.length(), pretenure); if (!maybe_result->ToObject(&result)) return maybe_result; } // Copy the characters into the new object. SeqAsciiString* string_result = SeqAsciiString::cast(result); for (int i = 0; i < string.length(); i++) { string_result->SeqAsciiStringSet(i, string[i]); } return result; } MaybeObject* Heap::AllocateStringFromUtf8Slow(Vector<const char> string, PretenureFlag pretenure) { // V8 only supports characters in the Basic Multilingual Plane. const uc32 kMaxSupportedChar = 0xFFFF; // Count the number of characters in the UTF-8 string and check if // it is an ASCII string. Access<UnicodeCache::Utf8Decoder> decoder(isolate_->unicode_cache()->utf8_decoder()); decoder->Reset(string.start(), string.length()); int chars = 0; while (decoder->has_more()) { decoder->GetNext(); chars++; } Object* result; { MaybeObject* maybe_result = AllocateRawTwoByteString(chars, pretenure); if (!maybe_result->ToObject(&result)) return maybe_result; } // Convert and copy the characters into the new object. String* string_result = String::cast(result); decoder->Reset(string.start(), string.length()); for (int i = 0; i < chars; i++) { uc32 r = decoder->GetNext(); if (r > kMaxSupportedChar) { r = unibrow::Utf8::kBadChar; } string_result->Set(i, r); } return result; } MaybeObject* Heap::AllocateStringFromTwoByte(Vector<const uc16> string, PretenureFlag pretenure) { // Check if the string is an ASCII string. MaybeObject* maybe_result; if (String::IsAscii(string.start(), string.length())) { maybe_result = AllocateRawAsciiString(string.length(), pretenure); } else { // It's not an ASCII string. maybe_result = AllocateRawTwoByteString(string.length(), pretenure); } Object* result; if (!maybe_result->ToObject(&result)) return maybe_result; // Copy the characters into the new object, which may be either ASCII or // UTF-16. String* string_result = String::cast(result); for (int i = 0; i < string.length(); i++) { string_result->Set(i, string[i]); } return result; } Map* Heap::SymbolMapForString(String* string) { // If the string is in new space it cannot be used as a symbol. if (InNewSpace(string)) return NULL; // Find the corresponding symbol map for strings. switch (string->map()->instance_type()) { case STRING_TYPE: return symbol_map(); case ASCII_STRING_TYPE: return ascii_symbol_map(); case CONS_STRING_TYPE: return cons_symbol_map(); case CONS_ASCII_STRING_TYPE: return cons_ascii_symbol_map(); case EXTERNAL_STRING_TYPE: return external_symbol_map(); case EXTERNAL_ASCII_STRING_TYPE: return external_ascii_symbol_map(); case EXTERNAL_STRING_WITH_ASCII_DATA_TYPE: return external_symbol_with_ascii_data_map(); case SHORT_EXTERNAL_STRING_TYPE: return short_external_symbol_map(); case SHORT_EXTERNAL_ASCII_STRING_TYPE: return short_external_ascii_symbol_map(); case SHORT_EXTERNAL_STRING_WITH_ASCII_DATA_TYPE: return short_external_symbol_with_ascii_data_map(); default: return NULL; // No match found. } } MaybeObject* Heap::AllocateInternalSymbol(unibrow::CharacterStream* buffer, int chars, uint32_t hash_field) { ASSERT(chars >= 0); // Ensure the chars matches the number of characters in the buffer. ASSERT(static_cast<unsigned>(chars) == buffer->Length()); // Determine whether the string is ASCII. bool is_ascii = true; while (buffer->has_more()) { if (buffer->GetNext() > unibrow::Utf8::kMaxOneByteChar) { is_ascii = false; break; } } buffer->Rewind(); // Compute map and object size. int size; Map* map; if (is_ascii) { if (chars > SeqAsciiString::kMaxLength) { return Failure::OutOfMemoryException(); } map = ascii_symbol_map(); size = SeqAsciiString::SizeFor(chars); } else { if (chars > SeqTwoByteString::kMaxLength) { return Failure::OutOfMemoryException(); } map = symbol_map(); size = SeqTwoByteString::SizeFor(chars); } // Allocate string. Object* result; { MaybeObject* maybe_result = (size > MaxObjectSizeInPagedSpace()) ? lo_space_->AllocateRaw(size, NOT_EXECUTABLE) : old_data_space_->AllocateRaw(size); if (!maybe_result->ToObject(&result)) return maybe_result; } reinterpret_cast<HeapObject*>(result)->set_map_no_write_barrier(map); // Set length and hash fields of the allocated string. String* answer = String::cast(result); answer->set_length(chars); answer->set_hash_field(hash_field); ASSERT_EQ(size, answer->Size()); // Fill in the characters. for (int i = 0; i < chars; i++) { answer->Set(i, buffer->GetNext()); } return answer; } MaybeObject* Heap::AllocateRawAsciiString(int length, PretenureFlag pretenure) { if (length < 0 || length > SeqAsciiString::kMaxLength) { return Failure::OutOfMemoryException(); } int size = SeqAsciiString::SizeFor(length); ASSERT(size <= SeqAsciiString::kMaxSize); AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; AllocationSpace retry_space = OLD_DATA_SPACE; if (space == NEW_SPACE) { if (size > kMaxObjectSizeInNewSpace) { // Allocate in large object space, retry space will be ignored. space = LO_SPACE; } else if (size > MaxObjectSizeInPagedSpace()) { // Allocate in new space, retry in large object space. retry_space = LO_SPACE; } } else if (space == OLD_DATA_SPACE && size > MaxObjectSizeInPagedSpace()) { space = LO_SPACE; } Object* result; { MaybeObject* maybe_result = AllocateRaw(size, space, retry_space); if (!maybe_result->ToObject(&result)) return maybe_result; } // Partially initialize the object. HeapObject::cast(result)->set_map_no_write_barrier(ascii_string_map()); String::cast(result)->set_length(length); String::cast(result)->set_hash_field(String::kEmptyHashField); ASSERT_EQ(size, HeapObject::cast(result)->Size()); return result; } MaybeObject* Heap::AllocateRawTwoByteString(int length, PretenureFlag pretenure) { if (length < 0 || length > SeqTwoByteString::kMaxLength) { return Failure::OutOfMemoryException(); } int size = SeqTwoByteString::SizeFor(length); ASSERT(size <= SeqTwoByteString::kMaxSize); AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; AllocationSpace retry_space = OLD_DATA_SPACE; if (space == NEW_SPACE) { if (size > kMaxObjectSizeInNewSpace) { // Allocate in large object space, retry space will be ignored. space = LO_SPACE; } else if (size > MaxObjectSizeInPagedSpace()) { // Allocate in new space, retry in large object space. retry_space = LO_SPACE; } } else if (space == OLD_DATA_SPACE && size > MaxObjectSizeInPagedSpace()) { space = LO_SPACE; } Object* result; { MaybeObject* maybe_result = AllocateRaw(size, space, retry_space); if (!maybe_result->ToObject(&result)) return maybe_result; } // Partially initialize the object. HeapObject::cast(result)->set_map_no_write_barrier(string_map()); String::cast(result)->set_length(length); String::cast(result)->set_hash_field(String::kEmptyHashField); ASSERT_EQ(size, HeapObject::cast(result)->Size()); return result; } MaybeObject* Heap::AllocateEmptyFixedArray() { int size = FixedArray::SizeFor(0); Object* result; { MaybeObject* maybe_result = AllocateRaw(size, OLD_DATA_SPACE, OLD_DATA_SPACE); if (!maybe_result->ToObject(&result)) return maybe_result; } // Initialize the object. reinterpret_cast<FixedArray*>(result)->set_map_no_write_barrier( fixed_array_map()); reinterpret_cast<FixedArray*>(result)->set_length(0); return result; } MaybeObject* Heap::AllocateRawFixedArray(int length) { if (length < 0 || length > FixedArray::kMaxLength) { return Failure::OutOfMemoryException(); } ASSERT(length > 0); // Use the general function if we're forced to always allocate. if (always_allocate()) return AllocateFixedArray(length, TENURED); // Allocate the raw data for a fixed array. int size = FixedArray::SizeFor(length); return size <= kMaxObjectSizeInNewSpace ? new_space_.AllocateRaw(size) : lo_space_->AllocateRaw(size, NOT_EXECUTABLE); } MaybeObject* Heap::CopyFixedArrayWithMap(FixedArray* src, Map* map) { int len = src->length(); Object* obj; { MaybeObject* maybe_obj = AllocateRawFixedArray(len); if (!maybe_obj->ToObject(&obj)) return maybe_obj; } if (InNewSpace(obj)) { HeapObject* dst = HeapObject::cast(obj); dst->set_map_no_write_barrier(map); CopyBlock(dst->address() + kPointerSize, src->address() + kPointerSize, FixedArray::SizeFor(len) - kPointerSize); return obj; } HeapObject::cast(obj)->set_map_no_write_barrier(map); FixedArray* result = FixedArray::cast(obj); result->set_length(len); // Copy the content AssertNoAllocation no_gc; WriteBarrierMode mode = result->GetWriteBarrierMode(no_gc); for (int i = 0; i < len; i++) result->set(i, src->get(i), mode); return result; } MaybeObject* Heap::CopyFixedDoubleArrayWithMap(FixedDoubleArray* src, Map* map) { int len = src->length(); Object* obj; { MaybeObject* maybe_obj = AllocateRawFixedDoubleArray(len, NOT_TENURED); if (!maybe_obj->ToObject(&obj)) return maybe_obj; } HeapObject* dst = HeapObject::cast(obj); dst->set_map_no_write_barrier(map); CopyBlock( dst->address() + FixedDoubleArray::kLengthOffset, src->address() + FixedDoubleArray::kLengthOffset, FixedDoubleArray::SizeFor(len) - FixedDoubleArray::kLengthOffset); return obj; } MaybeObject* Heap::AllocateFixedArray(int length) { ASSERT(length >= 0); if (length == 0) return empty_fixed_array(); Object* result; { MaybeObject* maybe_result = AllocateRawFixedArray(length); if (!maybe_result->ToObject(&result)) return maybe_result; } // Initialize header. FixedArray* array = reinterpret_cast<FixedArray*>(result); array->set_map_no_write_barrier(fixed_array_map()); array->set_length(length); // Initialize body. ASSERT(!InNewSpace(undefined_value())); MemsetPointer(array->data_start(), undefined_value(), length); return result; } MaybeObject* Heap::AllocateRawFixedArray(int length, PretenureFlag pretenure) { if (length < 0 || length > FixedArray::kMaxLength) { return Failure::OutOfMemoryException(); } AllocationSpace space = (pretenure == TENURED) ? OLD_POINTER_SPACE : NEW_SPACE; int size = FixedArray::SizeFor(length); if (space == NEW_SPACE && size > kMaxObjectSizeInNewSpace) { // Too big for new space. space = LO_SPACE; } else if (space == OLD_POINTER_SPACE && size > MaxObjectSizeInPagedSpace()) { // Too big for old pointer space. space = LO_SPACE; } AllocationSpace retry_space = (size <= MaxObjectSizeInPagedSpace()) ? OLD_POINTER_SPACE : LO_SPACE; return AllocateRaw(size, space, retry_space); } MUST_USE_RESULT static MaybeObject* AllocateFixedArrayWithFiller( Heap* heap, int length, PretenureFlag pretenure, Object* filler) { ASSERT(length >= 0); ASSERT(heap->empty_fixed_array()->IsFixedArray()); if (length == 0) return heap->empty_fixed_array(); ASSERT(!heap->InNewSpace(filler)); Object* result; { MaybeObject* maybe_result = heap->AllocateRawFixedArray(length, pretenure); if (!maybe_result->ToObject(&result)) return maybe_result; } HeapObject::cast(result)->set_map_no_write_barrier(heap->fixed_array_map()); FixedArray* array = FixedArray::cast(result); array->set_length(length); MemsetPointer(array->data_start(), filler, length); return array; } MaybeObject* Heap::AllocateFixedArray(int length, PretenureFlag pretenure) { return AllocateFixedArrayWithFiller(this, length, pretenure, undefined_value()); } MaybeObject* Heap::AllocateFixedArrayWithHoles(int length, PretenureFlag pretenure) { return AllocateFixedArrayWithFiller(this, length, pretenure, the_hole_value()); } MaybeObject* Heap::AllocateUninitializedFixedArray(int length) { if (length == 0) return empty_fixed_array(); Object* obj; { MaybeObject* maybe_obj = AllocateRawFixedArray(length); if (!maybe_obj->ToObject(&obj)) return maybe_obj; } reinterpret_cast<FixedArray*>(obj)->set_map_no_write_barrier( fixed_array_map()); FixedArray::cast(obj)->set_length(length); return obj; } MaybeObject* Heap::AllocateEmptyFixedDoubleArray() { int size = FixedDoubleArray::SizeFor(0); Object* result; { MaybeObject* maybe_result = AllocateRaw(size, OLD_DATA_SPACE, OLD_DATA_SPACE); if (!maybe_result->ToObject(&result)) return maybe_result; } // Initialize the object. reinterpret_cast<FixedDoubleArray*>(result)->set_map_no_write_barrier( fixed_double_array_map()); reinterpret_cast<FixedDoubleArray*>(result)->set_length(0); return result; } MaybeObject* Heap::AllocateUninitializedFixedDoubleArray( int length, PretenureFlag pretenure) { if (length == 0) return empty_fixed_double_array(); Object* obj; { MaybeObject* maybe_obj = AllocateRawFixedDoubleArray(length, pretenure); if (!maybe_obj->ToObject(&obj)) return maybe_obj; } reinterpret_cast<FixedDoubleArray*>(obj)->set_map_no_write_barrier( fixed_double_array_map()); FixedDoubleArray::cast(obj)->set_length(length); return obj; } MaybeObject* Heap::AllocateRawFixedDoubleArray(int length, PretenureFlag pretenure) { if (length < 0 || length > FixedDoubleArray::kMaxLength) { return Failure::OutOfMemoryException(); } AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE; int size = FixedDoubleArray::SizeFor(length); if (space == NEW_SPACE && size > kMaxObjectSizeInNewSpace) { // Too big for new space. space = LO_SPACE; } else if (space == OLD_DATA_SPACE && size > MaxObjectSizeInPagedSpace()) { // Too big for old data space. space = LO_SPACE; } AllocationSpace retry_space = (size <= MaxObjectSizeInPagedSpace()) ? OLD_DATA_SPACE : LO_SPACE; return AllocateRaw(size, space, retry_space); } MaybeObject* Heap::AllocateHashTable(int length, PretenureFlag pretenure) { Object* result; { MaybeObject* maybe_result = AllocateFixedArray(length, pretenure); if (!maybe_result->ToObject(&result)) return maybe_result; } reinterpret_cast<HeapObject*>(result)->set_map_no_write_barrier( hash_table_map()); ASSERT(result->IsHashTable()); return result; } MaybeObject* Heap::AllocateGlobalContext() { Object* result; { MaybeObject* maybe_result = AllocateFixedArray(Context::GLOBAL_CONTEXT_SLOTS); if (!maybe_result->ToObject(&result)) return maybe_result; } Context* context = reinterpret_cast<Context*>(result); context->set_map_no_write_barrier(global_context_map()); ASSERT(context->IsGlobalContext()); ASSERT(result->IsContext()); return result; } MaybeObject* Heap::AllocateFunctionContext(int length, JSFunction* function) { ASSERT(length >= Context::MIN_CONTEXT_SLOTS); Object* result; { MaybeObject* maybe_result = AllocateFixedArray(length); if (!maybe_result->ToObject(&result)) return maybe_result; } Context* context = reinterpret_cast<Context*>(result); context->set_map_no_write_barrier(function_context_map()); context->set_closure(function); context->set_previous(function->context()); context->set_extension(NULL); context->set_global(function->context()->global()); return context; } MaybeObject* Heap::AllocateCatchContext(JSFunction* function, Context* previous, String* name, Object* thrown_object) { STATIC_ASSERT(Context::MIN_CONTEXT_SLOTS == Context::THROWN_OBJECT_INDEX); Object* result; { MaybeObject* maybe_result = AllocateFixedArray(Context::MIN_CONTEXT_SLOTS + 1); if (!maybe_result->ToObject(&result)) return maybe_result; } Context* context = reinterpret_cast<Context*>(result); context->set_map_no_write_barrier(catch_context_map()); context->set_closure(function); context->set_previous(previous); context->set_extension(name); context->set_global(previous->global()); context->set(Context::THROWN_OBJECT_INDEX, thrown_object); return context; } MaybeObject* Heap::AllocateWithContext(JSFunction* function, Context* previous, JSObject* extension) { Object* result; { MaybeObject* maybe_result = AllocateFixedArray(Context::MIN_CONTEXT_SLOTS); if (!maybe_result->ToObject(&result)) return maybe_result; } Context* context = reinterpret_cast<Context*>(result); context->set_map_no_write_barrier(with_context_map()); context->set_closure(function); context->set_previous(previous); context->set_extension(extension); context->set_global(previous->global()); return context; } MaybeObject* Heap::AllocateBlockContext(JSFunction* function, Context* previous, ScopeInfo* scope_info) { Object* result; { MaybeObject* maybe_result = AllocateFixedArrayWithHoles(scope_info->ContextLength()); if (!maybe_result->ToObject(&result)) return maybe_result; } Context* context = reinterpret_cast<Context*>(result); context->set_map_no_write_barrier(block_context_map()); context->set_closure(function); context->set_previous(previous); context->set_extension(scope_info); context->set_global(previous->global()); return context; } MaybeObject* Heap::AllocateScopeInfo(int length) { FixedArray* scope_info; MaybeObject* maybe_scope_info = AllocateFixedArray(length, TENURED); if (!maybe_scope_info->To(&scope_info)) return maybe_scope_info; scope_info->set_map_no_write_barrier(scope_info_map()); return scope_info; } MaybeObject* Heap::AllocateStruct(InstanceType type) { Map* map; switch (type) { #define MAKE_CASE(NAME, Name, name) \ case NAME##_TYPE: map = name##_map(); break; STRUCT_LIST(MAKE_CASE) #undef MAKE_CASE default: UNREACHABLE(); return Failure::InternalError(); } int size = map->instance_size(); AllocationSpace space = (size > MaxObjectSizeInPagedSpace()) ? LO_SPACE : OLD_POINTER_SPACE; Object* result; { MaybeObject* maybe_result = Allocate(map, space); if (!maybe_result->ToObject(&result)) return maybe_result; } Struct::cast(result)->InitializeBody(size); return result; } bool Heap::IsHeapIterable() { return (!old_pointer_space()->was_swept_conservatively() && !old_data_space()->was_swept_conservatively()); } void Heap::EnsureHeapIsIterable() { ASSERT(IsAllocationAllowed()); if (!IsHeapIterable()) { CollectAllGarbage(kMakeHeapIterableMask); } ASSERT(IsHeapIterable()); } bool Heap::IdleNotification(int hint) { if (hint >= 1000) return IdleGlobalGC(); if (contexts_disposed_ > 0 || !FLAG_incremental_marking || FLAG_expose_gc || Serializer::enabled()) { return true; } // By doing small chunks of GC work in each IdleNotification, // perform a round of incremental GCs and after that wait until // the mutator creates enough garbage to justify a new round. // An incremental GC progresses as follows: // 1. many incremental marking steps, // 2. one old space mark-sweep-compact, // 3. many lazy sweep steps. // Use mark-sweep-compact events to count incremental GCs in a round. intptr_t size_factor = Min(Max(hint, 30), 1000) / 10; // The size factor is in range [3..100]. intptr_t step_size = size_factor * IncrementalMarking::kAllocatedThreshold; if (incremental_marking()->IsStopped()) { if (!IsSweepingComplete() && !AdvanceSweepers(static_cast<int>(step_size))) { return false; } } if (mark_sweeps_since_idle_round_started_ >= kMaxMarkSweepsInIdleRound) { if (EnoughGarbageSinceLastIdleRound()) { StartIdleRound(); } else { return true; } } int new_mark_sweeps = ms_count_ - ms_count_at_last_idle_notification_; mark_sweeps_since_idle_round_started_ += new_mark_sweeps; ms_count_at_last_idle_notification_ = ms_count_; if (mark_sweeps_since_idle_round_started_ >= kMaxMarkSweepsInIdleRound) { FinishIdleRound(); return true; } if (incremental_marking()->IsStopped()) { if (hint < 1000 && !WorthStartingGCWhenIdle()) { FinishIdleRound(); return true; } incremental_marking()->Start(); } // This flag prevents incremental marking from requesting GC via stack guard idle_notification_will_schedule_next_gc_ = true; incremental_marking()->Step(step_size); idle_notification_will_schedule_next_gc_ = false; if (incremental_marking()->IsComplete()) { bool uncommit = false; if (gc_count_at_last_idle_gc_ == gc_count_) { // No GC since the last full GC, the mutator is probably not active. isolate_->compilation_cache()->Clear(); uncommit = true; } CollectAllGarbage(kNoGCFlags); gc_count_at_last_idle_gc_ = gc_count_; if (uncommit) { new_space_.Shrink(); UncommitFromSpace(); } } return false; } bool Heap::IdleGlobalGC() { static const int kIdlesBeforeScavenge = 4; static const int kIdlesBeforeMarkSweep = 7; static const int kIdlesBeforeMarkCompact = 8; static const int kMaxIdleCount = kIdlesBeforeMarkCompact + 1; static const unsigned int kGCsBetweenCleanup = 4; if (!last_idle_notification_gc_count_init_) { last_idle_notification_gc_count_ = gc_count_; last_idle_notification_gc_count_init_ = true; } bool uncommit = true; bool finished = false; // Reset the number of idle notifications received when a number of // GCs have taken place. This allows another round of cleanup based // on idle notifications if enough work has been carried out to // provoke a number of garbage collections. if (gc_count_ - last_idle_notification_gc_count_ < kGCsBetweenCleanup) { number_idle_notifications_ = Min(number_idle_notifications_ + 1, kMaxIdleCount); } else { number_idle_notifications_ = 0; last_idle_notification_gc_count_ = gc_count_; } if (number_idle_notifications_ == kIdlesBeforeScavenge) { if (contexts_disposed_ > 0) { HistogramTimerScope scope(isolate_->counters()->gc_context()); CollectAllGarbage(kNoGCFlags); } else { CollectGarbage(NEW_SPACE); } new_space_.Shrink(); last_idle_notification_gc_count_ = gc_count_; } else if (number_idle_notifications_ == kIdlesBeforeMarkSweep) { // Before doing the mark-sweep collections we clear the // compilation cache to avoid hanging on to source code and // generated code for cached functions. isolate_->compilation_cache()->Clear(); CollectAllGarbage(kNoGCFlags); new_space_.Shrink(); last_idle_notification_gc_count_ = gc_count_; } else if (number_idle_notifications_ == kIdlesBeforeMarkCompact) { CollectAllGarbage(kNoGCFlags); new_space_.Shrink(); last_idle_notification_gc_count_ = gc_count_; number_idle_notifications_ = 0; finished = true; } else if (contexts_disposed_ > 0) { if (FLAG_expose_gc) { contexts_disposed_ = 0; } else { HistogramTimerScope scope(isolate_->counters()->gc_context()); CollectAllGarbage(kNoGCFlags); last_idle_notification_gc_count_ = gc_count_; } // If this is the first idle notification, we reset the // notification count to avoid letting idle notifications for // context disposal garbage collections start a potentially too // aggressive idle GC cycle. if (number_idle_notifications_ <= 1) { number_idle_notifications_ = 0; uncommit = false; } } else if (number_idle_notifications_ > kIdlesBeforeMarkCompact) { // If we have received more than kIdlesBeforeMarkCompact idle // notifications we do not perform any cleanup because we don't // expect to gain much by doing so. finished = true; } // Make sure that we have no pending context disposals and // conditionally uncommit from space. // Take into account that we might have decided to delay full collection // because incremental marking is in progress. ASSERT((contexts_disposed_ == 0) || !incremental_marking()->IsStopped()); if (uncommit) UncommitFromSpace(); return finished; } #ifdef DEBUG void Heap::Print() { if (!HasBeenSetUp()) return; isolate()->PrintStack(); AllSpaces spaces; for (Space* space = spaces.next(); space != NULL; space = spaces.next()) space->Print(); } void Heap::ReportCodeStatistics(const char* title) { PrintF(">>>>>> Code Stats (%s) >>>>>>\n", title); PagedSpace::ResetCodeStatistics(); // We do not look for code in new space, map space, or old space. If code // somehow ends up in those spaces, we would miss it here. code_space_->CollectCodeStatistics(); lo_space_->CollectCodeStatistics(); PagedSpace::ReportCodeStatistics(); } // This function expects that NewSpace's allocated objects histogram is // populated (via a call to CollectStatistics or else as a side effect of a // just-completed scavenge collection). void Heap::ReportHeapStatistics(const char* title) { USE(title); PrintF(">>>>>> =============== %s (%d) =============== >>>>>>\n", title, gc_count_); PrintF("old_gen_promotion_limit_ %" V8_PTR_PREFIX "d\n", old_gen_promotion_limit_); PrintF("old_gen_allocation_limit_ %" V8_PTR_PREFIX "d\n", old_gen_allocation_limit_); PrintF("old_gen_limit_factor_ %d\n", old_gen_limit_factor_); PrintF("\n"); PrintF("Number of handles : %d\n", HandleScope::NumberOfHandles()); isolate_->global_handles()->PrintStats(); PrintF("\n"); PrintF("Heap statistics : "); isolate_->memory_allocator()->ReportStatistics(); PrintF("To space : "); new_space_.ReportStatistics(); PrintF("Old pointer space : "); old_pointer_space_->ReportStatistics(); PrintF("Old data space : "); old_data_space_->ReportStatistics(); PrintF("Code space : "); code_space_->ReportStatistics(); PrintF("Map space : "); map_space_->ReportStatistics(); PrintF("Cell space : "); cell_space_->ReportStatistics(); PrintF("Large object space : "); lo_space_->ReportStatistics(); PrintF(">>>>>> ========================================= >>>>>>\n"); } #endif // DEBUG bool Heap::Contains(HeapObject* value) { return Contains(value->address()); } bool Heap::Contains(Address addr) { if (OS::IsOutsideAllocatedSpace(addr)) return false; return HasBeenSetUp() && (new_space_.ToSpaceContains(addr) || old_pointer_space_->Contains(addr) || old_data_space_->Contains(addr) || code_space_->Contains(addr) || map_space_->Contains(addr) || cell_space_->Contains(addr) || lo_space_->SlowContains(addr)); } bool Heap::InSpace(HeapObject* value, AllocationSpace space) { return InSpace(value->address(), space); } bool Heap::InSpace(Address addr, AllocationSpace space) { if (OS::IsOutsideAllocatedSpace(addr)) return false; if (!HasBeenSetUp()) return false; switch (space) { case NEW_SPACE: return new_space_.ToSpaceContains(addr); case OLD_POINTER_SPACE: return old_pointer_space_->Contains(addr); case OLD_DATA_SPACE: return old_data_space_->Contains(addr); case CODE_SPACE: return code_space_->Contains(addr); case MAP_SPACE: return map_space_->Contains(addr); case CELL_SPACE: return cell_space_->Contains(addr); case LO_SPACE: return lo_space_->SlowContains(addr); } return false; } #ifdef DEBUG void Heap::Verify() { ASSERT(HasBeenSetUp()); store_buffer()->Verify(); VerifyPointersVisitor visitor; IterateRoots(&visitor, VISIT_ONLY_STRONG); new_space_.Verify(); old_pointer_space_->Verify(&visitor); map_space_->Verify(&visitor); VerifyPointersVisitor no_dirty_regions_visitor; old_data_space_->Verify(&no_dirty_regions_visitor); code_space_->Verify(&no_dirty_regions_visitor); cell_space_->Verify(&no_dirty_regions_visitor); lo_space_->Verify(); } #endif // DEBUG MaybeObject* Heap::LookupSymbol(Vector<const char> string) { Object* symbol = NULL; Object* new_table; { MaybeObject* maybe_new_table = symbol_table()->LookupSymbol(string, &symbol); if (!maybe_new_table->ToObject(&new_table)) return maybe_new_table; } // Can't use set_symbol_table because SymbolTable::cast knows that // SymbolTable is a singleton and checks for identity. roots_[kSymbolTableRootIndex] = new_table; ASSERT(symbol != NULL); return symbol; } MaybeObject* Heap::LookupAsciiSymbol(Vector<const char> string) { Object* symbol = NULL; Object* new_table; { MaybeObject* maybe_new_table = symbol_table()->LookupAsciiSymbol(string, &symbol); if (!maybe_new_table->ToObject(&new_table)) return maybe_new_table; } // Can't use set_symbol_table because SymbolTable::cast knows that // SymbolTable is a singleton and checks for identity. roots_[kSymbolTableRootIndex] = new_table; ASSERT(symbol != NULL); return symbol; } MaybeObject* Heap::LookupAsciiSymbol(Handle<SeqAsciiString> string, int from, int length) { Object* symbol = NULL; Object* new_table; { MaybeObject* maybe_new_table = symbol_table()->LookupSubStringAsciiSymbol(string, from, length, &symbol); if (!maybe_new_table->ToObject(&new_table)) return maybe_new_table; } // Can't use set_symbol_table because SymbolTable::cast knows that // SymbolTable is a singleton and checks for identity. roots_[kSymbolTableRootIndex] = new_table; ASSERT(symbol != NULL); return symbol; } MaybeObject* Heap::LookupTwoByteSymbol(Vector<const uc16> string) { Object* symbol = NULL; Object* new_table; { MaybeObject* maybe_new_table = symbol_table()->LookupTwoByteSymbol(string, &symbol); if (!maybe_new_table->ToObject(&new_table)) return maybe_new_table; } // Can't use set_symbol_table because SymbolTable::cast knows that // SymbolTable is a singleton and checks for identity. roots_[kSymbolTableRootIndex] = new_table; ASSERT(symbol != NULL); return symbol; } MaybeObject* Heap::LookupSymbol(String* string) { if (string->IsSymbol()) return string; Object* symbol = NULL; Object* new_table; { MaybeObject* maybe_new_table = symbol_table()->LookupString(string, &symbol); if (!maybe_new_table->ToObject(&new_table)) return maybe_new_table; } // Can't use set_symbol_table because SymbolTable::cast knows that // SymbolTable is a singleton and checks for identity. roots_[kSymbolTableRootIndex] = new_table; ASSERT(symbol != NULL); return symbol; } bool Heap::LookupSymbolIfExists(String* string, String** symbol) { if (string->IsSymbol()) { *symbol = string; return true; } return symbol_table()->LookupSymbolIfExists(string, symbol); } #ifdef DEBUG void Heap::ZapFromSpace() { NewSpacePageIterator it(new_space_.FromSpaceStart(), new_space_.FromSpaceEnd()); while (it.has_next()) { NewSpacePage* page = it.next(); for (Address cursor = page->body(), limit = page->body_limit(); cursor < limit; cursor += kPointerSize) { Memory::Address_at(cursor) = kFromSpaceZapValue; } } } #endif // DEBUG void Heap::IterateAndMarkPointersToFromSpace(Address start, Address end, ObjectSlotCallback callback) { Address slot_address = start; // We are not collecting slots on new space objects during mutation // thus we have to scan for pointers to evacuation candidates when we // promote objects. But we should not record any slots in non-black // objects. Grey object's slots would be rescanned. // White object might not survive until the end of collection // it would be a violation of the invariant to record it's slots. bool record_slots = false; if (incremental_marking()->IsCompacting()) { MarkBit mark_bit = Marking::MarkBitFrom(HeapObject::FromAddress(start)); record_slots = Marking::IsBlack(mark_bit); } while (slot_address < end) { Object** slot = reinterpret_cast<Object**>(slot_address); Object* object = *slot; // If the store buffer becomes overfull we mark pages as being exempt from // the store buffer. These pages are scanned to find pointers that point // to the new space. In that case we may hit newly promoted objects and // fix the pointers before the promotion queue gets to them. Thus the 'if'. if (object->IsHeapObject()) { if (Heap::InFromSpace(object)) { callback(reinterpret_cast<HeapObject**>(slot), HeapObject::cast(object)); Object* new_object = *slot; if (InNewSpace(new_object)) { SLOW_ASSERT(Heap::InToSpace(new_object)); SLOW_ASSERT(new_object->IsHeapObject()); store_buffer_.EnterDirectlyIntoStoreBuffer( reinterpret_cast<Address>(slot)); } SLOW_ASSERT(!MarkCompactCollector::IsOnEvacuationCandidate(new_object)); } else if (record_slots && MarkCompactCollector::IsOnEvacuationCandidate(object)) { mark_compact_collector()->RecordSlot(slot, slot, object); } } slot_address += kPointerSize; } } #ifdef DEBUG typedef bool (*CheckStoreBufferFilter)(Object** addr); bool IsAMapPointerAddress(Object** addr) { uintptr_t a = reinterpret_cast<uintptr_t>(addr); int mod = a % Map::kSize; return mod >= Map::kPointerFieldsBeginOffset && mod < Map::kPointerFieldsEndOffset; } bool EverythingsAPointer(Object** addr) { return true; } static void CheckStoreBuffer(Heap* heap, Object** current, Object** limit, Object**** store_buffer_position, Object*** store_buffer_top, CheckStoreBufferFilter filter, Address special_garbage_start, Address special_garbage_end) { Map* free_space_map = heap->free_space_map(); for ( ; current < limit; current++) { Object* o = *current; Address current_address = reinterpret_cast<Address>(current); // Skip free space. if (o == free_space_map) { Address current_address = reinterpret_cast<Address>(current); FreeSpace* free_space = FreeSpace::cast(HeapObject::FromAddress(current_address)); int skip = free_space->Size(); ASSERT(current_address + skip <= reinterpret_cast<Address>(limit)); ASSERT(skip > 0); current_address += skip - kPointerSize; current = reinterpret_cast<Object**>(current_address); continue; } // Skip the current linear allocation space between top and limit which is // unmarked with the free space map, but can contain junk. if (current_address == special_garbage_start && special_garbage_end != special_garbage_start) { current_address = special_garbage_end - kPointerSize; current = reinterpret_cast<Object**>(current_address); continue; } if (!(*filter)(current)) continue; ASSERT(current_address < special_garbage_start || current_address >= special_garbage_end); ASSERT(reinterpret_cast<uintptr_t>(o) != kFreeListZapValue); // We have to check that the pointer does not point into new space // without trying to cast it to a heap object since the hash field of // a string can contain values like 1 and 3 which are tagged null // pointers. if (!heap->InNewSpace(o)) continue; while (**store_buffer_position < current && *store_buffer_position < store_buffer_top) { (*store_buffer_position)++; } if (**store_buffer_position != current || *store_buffer_position == store_buffer_top) { Object** obj_start = current; while (!(*obj_start)->IsMap()) obj_start--; UNREACHABLE(); } } } // Check that the store buffer contains all intergenerational pointers by // scanning a page and ensuring that all pointers to young space are in the // store buffer. void Heap::OldPointerSpaceCheckStoreBuffer() { OldSpace* space = old_pointer_space(); PageIterator pages(space); store_buffer()->SortUniq(); while (pages.has_next()) { Page* page = pages.next(); Object** current = reinterpret_cast<Object**>(page->ObjectAreaStart()); Address end = page->ObjectAreaEnd(); Object*** store_buffer_position = store_buffer()->Start(); Object*** store_buffer_top = store_buffer()->Top(); Object** limit = reinterpret_cast<Object**>(end); CheckStoreBuffer(this, current, limit, &store_buffer_position, store_buffer_top, &EverythingsAPointer, space->top(), space->limit()); } } void Heap::MapSpaceCheckStoreBuffer() { MapSpace* space = map_space(); PageIterator pages(space); store_buffer()->SortUniq(); while (pages.has_next()) { Page* page = pages.next(); Object** current = reinterpret_cast<Object**>(page->ObjectAreaStart()); Address end = page->ObjectAreaEnd(); Object*** store_buffer_position = store_buffer()->Start(); Object*** store_buffer_top = store_buffer()->Top(); Object** limit = reinterpret_cast<Object**>(end); CheckStoreBuffer(this, current, limit, &store_buffer_position, store_buffer_top, &IsAMapPointerAddress, space->top(), space->limit()); } } void Heap::LargeObjectSpaceCheckStoreBuffer() { LargeObjectIterator it(lo_space()); for (HeapObject* object = it.Next(); object != NULL; object = it.Next()) { // We only have code, sequential strings, or fixed arrays in large // object space, and only fixed arrays can possibly contain pointers to // the young generation. if (object->IsFixedArray()) { Object*** store_buffer_position = store_buffer()->Start(); Object*** store_buffer_top = store_buffer()->Top(); Object** current = reinterpret_cast<Object**>(object->address()); Object** limit = reinterpret_cast<Object**>(object->address() + object->Size()); CheckStoreBuffer(this, current, limit, &store_buffer_position, store_buffer_top, &EverythingsAPointer, NULL, NULL); } } } #endif void Heap::IterateRoots(ObjectVisitor* v, VisitMode mode) { IterateStrongRoots(v, mode); IterateWeakRoots(v, mode); } void Heap::IterateWeakRoots(ObjectVisitor* v, VisitMode mode) { v->VisitPointer(reinterpret_cast<Object**>(&roots_[kSymbolTableRootIndex])); v->Synchronize(VisitorSynchronization::kSymbolTable); if (mode != VISIT_ALL_IN_SCAVENGE && mode != VISIT_ALL_IN_SWEEP_NEWSPACE) { // Scavenge collections have special processing for this. external_string_table_.Iterate(v); } v->Synchronize(VisitorSynchronization::kExternalStringsTable); } void Heap::IterateStrongRoots(ObjectVisitor* v, VisitMode mode) { v->VisitPointers(&roots_[0], &roots_[kStrongRootListLength]); v->Synchronize(VisitorSynchronization::kStrongRootList); v->VisitPointer(BitCast<Object**>(&hidden_symbol_)); v->Synchronize(VisitorSynchronization::kSymbol); isolate_->bootstrapper()->Iterate(v); v->Synchronize(VisitorSynchronization::kBootstrapper); isolate_->Iterate(v); v->Synchronize(VisitorSynchronization::kTop); Relocatable::Iterate(v); v->Synchronize(VisitorSynchronization::kRelocatable); #ifdef ENABLE_DEBUGGER_SUPPORT isolate_->debug()->Iterate(v); if (isolate_->deoptimizer_data() != NULL) { isolate_->deoptimizer_data()->Iterate(v); } #endif v->Synchronize(VisitorSynchronization::kDebug); isolate_->compilation_cache()->Iterate(v); v->Synchronize(VisitorSynchronization::kCompilationCache); // Iterate over local handles in handle scopes. isolate_->handle_scope_implementer()->Iterate(v); v->Synchronize(VisitorSynchronization::kHandleScope); // Iterate over the builtin code objects and code stubs in the // heap. Note that it is not necessary to iterate over code objects // on scavenge collections. if (mode != VISIT_ALL_IN_SCAVENGE) { isolate_->builtins()->IterateBuiltins(v); } v->Synchronize(VisitorSynchronization::kBuiltins); // Iterate over global handles. switch (mode) { case VISIT_ONLY_STRONG: isolate_->global_handles()->IterateStrongRoots(v); break; case VISIT_ALL_IN_SCAVENGE: isolate_->global_handles()->IterateNewSpaceStrongAndDependentRoots(v); break; case VISIT_ALL_IN_SWEEP_NEWSPACE: case VISIT_ALL: isolate_->global_handles()->IterateAllRoots(v); break; } v->Synchronize(VisitorSynchronization::kGlobalHandles); // Iterate over pointers being held by inactive threads. isolate_->thread_manager()->Iterate(v); v->Synchronize(VisitorSynchronization::kThreadManager); // Iterate over the pointers the Serialization/Deserialization code is // holding. // During garbage collection this keeps the partial snapshot cache alive. // During deserialization of the startup snapshot this creates the partial // snapshot cache and deserializes the objects it refers to. During // serialization this does nothing, since the partial snapshot cache is // empty. However the next thing we do is create the partial snapshot, // filling up the partial snapshot cache with objects it needs as we go. SerializerDeserializer::Iterate(v); // We don't do a v->Synchronize call here, because in debug mode that will // output a flag to the snapshot. However at this point the serializer and // deserializer are deliberately a little unsynchronized (see above) so the // checking of the sync flag in the snapshot would fail. } // TODO(1236194): Since the heap size is configurable on the command line // and through the API, we should gracefully handle the case that the heap // size is not big enough to fit all the initial objects. bool Heap::ConfigureHeap(int max_semispace_size, intptr_t max_old_gen_size, intptr_t max_executable_size) { if (HasBeenSetUp()) return false; if (max_semispace_size > 0) { if (max_semispace_size < Page::kPageSize) { max_semispace_size = Page::kPageSize; if (FLAG_trace_gc) { PrintF("Max semispace size cannot be less than %dkbytes\n", Page::kPageSize >> 10); } } max_semispace_size_ = max_semispace_size; } if (Snapshot::IsEnabled()) { // If we are using a snapshot we always reserve the default amount // of memory for each semispace because code in the snapshot has // write-barrier code that relies on the size and alignment of new // space. We therefore cannot use a larger max semispace size // than the default reserved semispace size. if (max_semispace_size_ > reserved_semispace_size_) { max_semispace_size_ = reserved_semispace_size_; if (FLAG_trace_gc) { PrintF("Max semispace size cannot be more than %dkbytes\n", reserved_semispace_size_ >> 10); } } } else { // If we are not using snapshots we reserve space for the actual // max semispace size. reserved_semispace_size_ = max_semispace_size_; } if (max_old_gen_size > 0) max_old_generation_size_ = max_old_gen_size; if (max_executable_size > 0) { max_executable_size_ = RoundUp(max_executable_size, Page::kPageSize); } // The max executable size must be less than or equal to the max old // generation size. if (max_executable_size_ > max_old_generation_size_) { max_executable_size_ = max_old_generation_size_; } // The new space size must be a power of two to support single-bit testing // for containment. max_semispace_size_ = RoundUpToPowerOf2(max_semispace_size_); reserved_semispace_size_ = RoundUpToPowerOf2(reserved_semispace_size_); initial_semispace_size_ = Min(initial_semispace_size_, max_semispace_size_); external_allocation_limit_ = 10 * max_semispace_size_; // The old generation is paged and needs at least one page for each space. int paged_space_count = LAST_PAGED_SPACE - FIRST_PAGED_SPACE + 1; max_old_generation_size_ = Max(static_cast<intptr_t>(paged_space_count * Page::kPageSize), RoundUp(max_old_generation_size_, Page::kPageSize)); configured_ = true; return true; } bool Heap::ConfigureHeapDefault() { return ConfigureHeap(static_cast<intptr_t>(FLAG_max_new_space_size / 2) * KB, static_cast<intptr_t>(FLAG_max_old_space_size) * MB, static_cast<intptr_t>(FLAG_max_executable_size) * MB); } void Heap::RecordStats(HeapStats* stats, bool take_snapshot) { *stats->start_marker = HeapStats::kStartMarker; *stats->end_marker = HeapStats::kEndMarker; *stats->new_space_size = new_space_.SizeAsInt(); *stats->new_space_capacity = static_cast<int>(new_space_.Capacity()); *stats->old_pointer_space_size = old_pointer_space_->Size(); *stats->old_pointer_space_capacity = old_pointer_space_->Capacity(); *stats->old_data_space_size = old_data_space_->Size(); *stats->old_data_space_capacity = old_data_space_->Capacity(); *stats->code_space_size = code_space_->Size(); *stats->code_space_capacity = code_space_->Capacity(); *stats->map_space_size = map_space_->Size(); *stats->map_space_capacity = map_space_->Capacity(); *stats->cell_space_size = cell_space_->Size(); *stats->cell_space_capacity = cell_space_->Capacity(); *stats->lo_space_size = lo_space_->Size(); isolate_->global_handles()->RecordStats(stats); *stats->memory_allocator_size = isolate()->memory_allocator()->Size(); *stats->memory_allocator_capacity = isolate()->memory_allocator()->Size() + isolate()->memory_allocator()->Available(); *stats->os_error = OS::GetLastError(); isolate()->memory_allocator()->Available(); if (take_snapshot) { HeapIterator iterator; for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { InstanceType type = obj->map()->instance_type(); ASSERT(0 <= type && type <= LAST_TYPE); stats->objects_per_type[type]++; stats->size_per_type[type] += obj->Size(); } } } intptr_t Heap::PromotedSpaceSize() { return old_pointer_space_->Size() + old_data_space_->Size() + code_space_->Size() + map_space_->Size() + cell_space_->Size() + lo_space_->Size(); } int Heap::PromotedExternalMemorySize() { if (amount_of_external_allocated_memory_ <= amount_of_external_allocated_memory_at_last_global_gc_) return 0; return amount_of_external_allocated_memory_ - amount_of_external_allocated_memory_at_last_global_gc_; } #ifdef DEBUG // Tags 0, 1, and 3 are used. Use 2 for marking visited HeapObject. static const int kMarkTag = 2; class HeapDebugUtils { public: explicit HeapDebugUtils(Heap* heap) : search_for_any_global_(false), search_target_(NULL), found_target_(false), object_stack_(20), heap_(heap) { } class MarkObjectVisitor : public ObjectVisitor { public: explicit MarkObjectVisitor(HeapDebugUtils* utils) : utils_(utils) { } void VisitPointers(Object** start, Object** end) { // Copy all HeapObject pointers in [start, end) for (Object** p = start; p < end; p++) { if ((*p)->IsHeapObject()) utils_->MarkObjectRecursively(p); } } HeapDebugUtils* utils_; }; void MarkObjectRecursively(Object** p) { if (!(*p)->IsHeapObject()) return; HeapObject* obj = HeapObject::cast(*p); Object* map = obj->map(); if (!map->IsHeapObject()) return; // visited before if (found_target_) return; // stop if target found object_stack_.Add(obj); if ((search_for_any_global_ && obj->IsJSGlobalObject()) || (!search_for_any_global_ && (obj == search_target_))) { found_target_ = true; return; } // not visited yet Map* map_p = reinterpret_cast<Map*>(HeapObject::cast(map)); Address map_addr = map_p->address(); obj->set_map_no_write_barrier(reinterpret_cast<Map*>(map_addr + kMarkTag)); MarkObjectRecursively(&map); MarkObjectVisitor mark_visitor(this); obj->IterateBody(map_p->instance_type(), obj->SizeFromMap(map_p), &mark_visitor); if (!found_target_) // don't pop if found the target object_stack_.RemoveLast(); } class UnmarkObjectVisitor : public ObjectVisitor { public: explicit UnmarkObjectVisitor(HeapDebugUtils* utils) : utils_(utils) { } void VisitPointers(Object** start, Object** end) { // Copy all HeapObject pointers in [start, end) for (Object** p = start; p < end; p++) { if ((*p)->IsHeapObject()) utils_->UnmarkObjectRecursively(p); } } HeapDebugUtils* utils_; }; void UnmarkObjectRecursively(Object** p) { if (!(*p)->IsHeapObject()) return; HeapObject* obj = HeapObject::cast(*p); Object* map = obj->map(); if (map->IsHeapObject()) return; // unmarked already Address map_addr = reinterpret_cast<Address>(map); map_addr -= kMarkTag; ASSERT_TAG_ALIGNED(map_addr); HeapObject* map_p = HeapObject::FromAddress(map_addr); obj->set_map_no_write_barrier(reinterpret_cast<Map*>(map_p)); UnmarkObjectRecursively(reinterpret_cast<Object**>(&map_p)); UnmarkObjectVisitor unmark_visitor(this); obj->IterateBody(Map::cast(map_p)->instance_type(), obj->SizeFromMap(Map::cast(map_p)), &unmark_visitor); } void MarkRootObjectRecursively(Object** root) { if (search_for_any_global_) { ASSERT(search_target_ == NULL); } else { ASSERT(search_target_->IsHeapObject()); } found_target_ = false; object_stack_.Clear(); MarkObjectRecursively(root); UnmarkObjectRecursively(root); if (found_target_) { PrintF("=====================================\n"); PrintF("==== Path to object ====\n"); PrintF("=====================================\n\n"); ASSERT(!object_stack_.is_empty()); for (int i = 0; i < object_stack_.length(); i++) { if (i > 0) PrintF("\n |\n |\n V\n\n"); Object* obj = object_stack_[i]; obj->Print(); } PrintF("=====================================\n"); } } // Helper class for visiting HeapObjects recursively. class MarkRootVisitor: public ObjectVisitor { public: explicit MarkRootVisitor(HeapDebugUtils* utils) : utils_(utils) { } void VisitPointers(Object** start, Object** end) { // Visit all HeapObject pointers in [start, end) for (Object** p = start; p < end; p++) { if ((*p)->IsHeapObject()) utils_->MarkRootObjectRecursively(p); } } HeapDebugUtils* utils_; }; bool search_for_any_global_; Object* search_target_; bool found_target_; List<Object*> object_stack_; Heap* heap_; friend class Heap; }; #endif bool Heap::SetUp(bool create_heap_objects) { #ifdef DEBUG allocation_timeout_ = FLAG_gc_interval; debug_utils_ = new HeapDebugUtils(this); #endif // Initialize heap spaces and initial maps and objects. Whenever something // goes wrong, just return false. The caller should check the results and // call Heap::TearDown() to release allocated memory. // // If the heap is not yet configured (e.g. through the API), configure it. // Configuration is based on the flags new-space-size (really the semispace // size) and old-space-size if set or the initial values of semispace_size_ // and old_generation_size_ otherwise. if (!configured_) { if (!ConfigureHeapDefault()) return false; } gc_initializer_mutex->Lock(); static bool initialized_gc = false; if (!initialized_gc) { initialized_gc = true; InitializeScavengingVisitorsTables(); NewSpaceScavenger::Initialize(); MarkCompactCollector::Initialize(); } gc_initializer_mutex->Unlock(); MarkMapPointersAsEncoded(false); // Set up memory allocator. if (!isolate_->memory_allocator()->SetUp(MaxReserved(), MaxExecutableSize())) return false; // Set up new space. if (!new_space_.SetUp(reserved_semispace_size_, max_semispace_size_)) { return false; } // Initialize old pointer space. old_pointer_space_ = new OldSpace(this, max_old_generation_size_, OLD_POINTER_SPACE, NOT_EXECUTABLE); if (old_pointer_space_ == NULL) return false; if (!old_pointer_space_->SetUp()) return false; // Initialize old data space. old_data_space_ = new OldSpace(this, max_old_generation_size_, OLD_DATA_SPACE, NOT_EXECUTABLE); if (old_data_space_ == NULL) return false; if (!old_data_space_->SetUp()) return false; // Initialize the code space, set its maximum capacity to the old // generation size. It needs executable memory. // On 64-bit platform(s), we put all code objects in a 2 GB range of // virtual address space, so that they can call each other with near calls. if (code_range_size_ > 0) { if (!isolate_->code_range()->SetUp(code_range_size_)) { return false; } } code_space_ = new OldSpace(this, max_old_generation_size_, CODE_SPACE, EXECUTABLE); if (code_space_ == NULL) return false; if (!code_space_->SetUp()) return false; // Initialize map space. map_space_ = new MapSpace(this, max_old_generation_size_, FLAG_max_map_space_pages, MAP_SPACE); if (map_space_ == NULL) return false; if (!map_space_->SetUp()) return false; // Initialize global property cell space. cell_space_ = new CellSpace(this, max_old_generation_size_, CELL_SPACE); if (cell_space_ == NULL) return false; if (!cell_space_->SetUp()) return false; // The large object code space may contain code or data. We set the memory // to be non-executable here for safety, but this means we need to enable it // explicitly when allocating large code objects. lo_space_ = new LargeObjectSpace(this, max_old_generation_size_, LO_SPACE); if (lo_space_ == NULL) return false; if (!lo_space_->SetUp()) return false; // Set up the seed that is used to randomize the string hash function. ASSERT(hash_seed() == 0); if (FLAG_randomize_hashes) { if (FLAG_hash_seed == 0) { set_hash_seed( Smi::FromInt(V8::RandomPrivate(isolate()) & 0x3fffffff)); } else { set_hash_seed(Smi::FromInt(FLAG_hash_seed)); } } if (create_heap_objects) { // Create initial maps. if (!CreateInitialMaps()) return false; if (!CreateApiObjects()) return false; // Create initial objects if (!CreateInitialObjects()) return false; global_contexts_list_ = undefined_value(); } LOG(isolate_, IntPtrTEvent("heap-capacity", Capacity())); LOG(isolate_, IntPtrTEvent("heap-available", Available())); store_buffer()->SetUp(); return true; } void Heap::SetStackLimits() { ASSERT(isolate_ != NULL); ASSERT(isolate_ == isolate()); // On 64 bit machines, pointers are generally out of range of Smis. We write // something that looks like an out of range Smi to the GC. // Set up the special root array entries containing the stack limits. // These are actually addresses, but the tag makes the GC ignore it. roots_[kStackLimitRootIndex] = reinterpret_cast<Object*>( (isolate_->stack_guard()->jslimit() & ~kSmiTagMask) | kSmiTag); roots_[kRealStackLimitRootIndex] = reinterpret_cast<Object*>( (isolate_->stack_guard()->real_jslimit() & ~kSmiTagMask) | kSmiTag); } void Heap::TearDown() { if (FLAG_print_cumulative_gc_stat) { PrintF("\n\n"); PrintF("gc_count=%d ", gc_count_); PrintF("mark_sweep_count=%d ", ms_count_); PrintF("max_gc_pause=%d ", get_max_gc_pause()); PrintF("min_in_mutator=%d ", get_min_in_mutator()); PrintF("max_alive_after_gc=%" V8_PTR_PREFIX "d ", get_max_alive_after_gc()); PrintF("\n\n"); } isolate_->global_handles()->TearDown(); external_string_table_.TearDown(); new_space_.TearDown(); if (old_pointer_space_ != NULL) { old_pointer_space_->TearDown(); delete old_pointer_space_; old_pointer_space_ = NULL; } if (old_data_space_ != NULL) { old_data_space_->TearDown(); delete old_data_space_; old_data_space_ = NULL; } if (code_space_ != NULL) { code_space_->TearDown(); delete code_space_; code_space_ = NULL; } if (map_space_ != NULL) { map_space_->TearDown(); delete map_space_; map_space_ = NULL; } if (cell_space_ != NULL) { cell_space_->TearDown(); delete cell_space_; cell_space_ = NULL; } if (lo_space_ != NULL) { lo_space_->TearDown(); delete lo_space_; lo_space_ = NULL; } store_buffer()->TearDown(); incremental_marking()->TearDown(); isolate_->memory_allocator()->TearDown(); #ifdef DEBUG delete debug_utils_; debug_utils_ = NULL; #endif } void Heap::Shrink() { // Try to shrink all paged spaces. PagedSpaces spaces; for (PagedSpace* space = spaces.next(); space != NULL; space = spaces.next()) { space->ReleaseAllUnusedPages(); } } void Heap::AddGCPrologueCallback(GCPrologueCallback callback, GCType gc_type) { ASSERT(callback != NULL); GCPrologueCallbackPair pair(callback, gc_type); ASSERT(!gc_prologue_callbacks_.Contains(pair)); return gc_prologue_callbacks_.Add(pair); } void Heap::RemoveGCPrologueCallback(GCPrologueCallback callback) { ASSERT(callback != NULL); for (int i = 0; i < gc_prologue_callbacks_.length(); ++i) { if (gc_prologue_callbacks_[i].callback == callback) { gc_prologue_callbacks_.Remove(i); return; } } UNREACHABLE(); } void Heap::AddGCEpilogueCallback(GCEpilogueCallback callback, GCType gc_type) { ASSERT(callback != NULL); GCEpilogueCallbackPair pair(callback, gc_type); ASSERT(!gc_epilogue_callbacks_.Contains(pair)); return gc_epilogue_callbacks_.Add(pair); } void Heap::RemoveGCEpilogueCallback(GCEpilogueCallback callback) { ASSERT(callback != NULL); for (int i = 0; i < gc_epilogue_callbacks_.length(); ++i) { if (gc_epilogue_callbacks_[i].callback == callback) { gc_epilogue_callbacks_.Remove(i); return; } } UNREACHABLE(); } #ifdef DEBUG class PrintHandleVisitor: public ObjectVisitor { public: void VisitPointers(Object** start, Object** end) { for (Object** p = start; p < end; p++) PrintF(" handle %p to %p\n", reinterpret_cast<void*>(p), reinterpret_cast<void*>(*p)); } }; void Heap::PrintHandles() { PrintF("Handles:\n"); PrintHandleVisitor v; isolate_->handle_scope_implementer()->Iterate(&v); } #endif Space* AllSpaces::next() { switch (counter_++) { case NEW_SPACE: return HEAP->new_space(); case OLD_POINTER_SPACE: return HEAP->old_pointer_space(); case OLD_DATA_SPACE: return HEAP->old_data_space(); case CODE_SPACE: return HEAP->code_space(); case MAP_SPACE: return HEAP->map_space(); case CELL_SPACE: return HEAP->cell_space(); case LO_SPACE: return HEAP->lo_space(); default: return NULL; } } PagedSpace* PagedSpaces::next() { switch (counter_++) { case OLD_POINTER_SPACE: return HEAP->old_pointer_space(); case OLD_DATA_SPACE: return HEAP->old_data_space(); case CODE_SPACE: return HEAP->code_space(); case MAP_SPACE: return HEAP->map_space(); case CELL_SPACE: return HEAP->cell_space(); default: return NULL; } } OldSpace* OldSpaces::next() { switch (counter_++) { case OLD_POINTER_SPACE: return HEAP->old_pointer_space(); case OLD_DATA_SPACE: return HEAP->old_data_space(); case CODE_SPACE: return HEAP->code_space(); default: return NULL; } } SpaceIterator::SpaceIterator() : current_space_(FIRST_SPACE), iterator_(NULL), size_func_(NULL) { } SpaceIterator::SpaceIterator(HeapObjectCallback size_func) : current_space_(FIRST_SPACE), iterator_(NULL), size_func_(size_func) { } SpaceIterator::~SpaceIterator() { // Delete active iterator if any. delete iterator_; } bool SpaceIterator::has_next() { // Iterate until no more spaces. return current_space_ != LAST_SPACE; } ObjectIterator* SpaceIterator::next() { if (iterator_ != NULL) { delete iterator_; iterator_ = NULL; // Move to the next space current_space_++; if (current_space_ > LAST_SPACE) { return NULL; } } // Return iterator for the new current space. return CreateIterator(); } // Create an iterator for the space to iterate. ObjectIterator* SpaceIterator::CreateIterator() { ASSERT(iterator_ == NULL); switch (current_space_) { case NEW_SPACE: iterator_ = new SemiSpaceIterator(HEAP->new_space(), size_func_); break; case OLD_POINTER_SPACE: iterator_ = new HeapObjectIterator(HEAP->old_pointer_space(), size_func_); break; case OLD_DATA_SPACE: iterator_ = new HeapObjectIterator(HEAP->old_data_space(), size_func_); break; case CODE_SPACE: iterator_ = new HeapObjectIterator(HEAP->code_space(), size_func_); break; case MAP_SPACE: iterator_ = new HeapObjectIterator(HEAP->map_space(), size_func_); break; case CELL_SPACE: iterator_ = new HeapObjectIterator(HEAP->cell_space(), size_func_); break; case LO_SPACE: iterator_ = new LargeObjectIterator(HEAP->lo_space(), size_func_); break; } // Return the newly allocated iterator; ASSERT(iterator_ != NULL); return iterator_; } class HeapObjectsFilter { public: virtual ~HeapObjectsFilter() {} virtual bool SkipObject(HeapObject* object) = 0; }; class UnreachableObjectsFilter : public HeapObjectsFilter { public: UnreachableObjectsFilter() { MarkReachableObjects(); } ~UnreachableObjectsFilter() { Isolate::Current()->heap()->mark_compact_collector()->ClearMarkbits(); } bool SkipObject(HeapObject* object) { MarkBit mark_bit = Marking::MarkBitFrom(object); return !mark_bit.Get(); } private: class MarkingVisitor : public ObjectVisitor { public: MarkingVisitor() : marking_stack_(10) {} void VisitPointers(Object** start, Object** end) { for (Object** p = start; p < end; p++) { if (!(*p)->IsHeapObject()) continue; HeapObject* obj = HeapObject::cast(*p); MarkBit mark_bit = Marking::MarkBitFrom(obj); if (!mark_bit.Get()) { mark_bit.Set(); marking_stack_.Add(obj); } } } void TransitiveClosure() { while (!marking_stack_.is_empty()) { HeapObject* obj = marking_stack_.RemoveLast(); obj->Iterate(this); } } private: List<HeapObject*> marking_stack_; }; void MarkReachableObjects() { Heap* heap = Isolate::Current()->heap(); MarkingVisitor visitor; heap->IterateRoots(&visitor, VISIT_ALL); visitor.TransitiveClosure(); } AssertNoAllocation no_alloc; }; HeapIterator::HeapIterator() : filtering_(HeapIterator::kNoFiltering), filter_(NULL) { Init(); } HeapIterator::HeapIterator(HeapIterator::HeapObjectsFiltering filtering) : filtering_(filtering), filter_(NULL) { Init(); } HeapIterator::~HeapIterator() { Shutdown(); } void HeapIterator::Init() { // Start the iteration. space_iterator_ = new SpaceIterator; switch (filtering_) { case kFilterUnreachable: filter_ = new UnreachableObjectsFilter; break; default: break; } object_iterator_ = space_iterator_->next(); } void HeapIterator::Shutdown() { #ifdef DEBUG // Assert that in filtering mode we have iterated through all // objects. Otherwise, heap will be left in an inconsistent state. if (filtering_ != kNoFiltering) { ASSERT(object_iterator_ == NULL); } #endif // Make sure the last iterator is deallocated. delete space_iterator_; space_iterator_ = NULL; object_iterator_ = NULL; delete filter_; filter_ = NULL; } HeapObject* HeapIterator::next() { if (filter_ == NULL) return NextObject(); HeapObject* obj = NextObject(); while (obj != NULL && filter_->SkipObject(obj)) obj = NextObject(); return obj; } HeapObject* HeapIterator::NextObject() { // No iterator means we are done. if (object_iterator_ == NULL) return NULL; if (HeapObject* obj = object_iterator_->next_object()) { // If the current iterator has more objects we are fine. return obj; } else { // Go though the spaces looking for one that has objects. while (space_iterator_->has_next()) { object_iterator_ = space_iterator_->next(); if (HeapObject* obj = object_iterator_->next_object()) { return obj; } } } // Done with the last space. object_iterator_ = NULL; return NULL; } void HeapIterator::reset() { // Restart the iterator. Shutdown(); Init(); } #if defined(DEBUG) || defined(LIVE_OBJECT_LIST) Object* const PathTracer::kAnyGlobalObject = reinterpret_cast<Object*>(NULL); class PathTracer::MarkVisitor: public ObjectVisitor { public: explicit MarkVisitor(PathTracer* tracer) : tracer_(tracer) {} void VisitPointers(Object** start, Object** end) { // Scan all HeapObject pointers in [start, end) for (Object** p = start; !tracer_->found() && (p < end); p++) { if ((*p)->IsHeapObject()) tracer_->MarkRecursively(p, this); } } private: PathTracer* tracer_; }; class PathTracer::UnmarkVisitor: public ObjectVisitor { public: explicit UnmarkVisitor(PathTracer* tracer) : tracer_(tracer) {} void VisitPointers(Object** start, Object** end) { // Scan all HeapObject pointers in [start, end) for (Object** p = start; p < end; p++) { if ((*p)->IsHeapObject()) tracer_->UnmarkRecursively(p, this); } } private: PathTracer* tracer_; }; void PathTracer::VisitPointers(Object** start, Object** end) { bool done = ((what_to_find_ == FIND_FIRST) && found_target_); // Visit all HeapObject pointers in [start, end) for (Object** p = start; !done && (p < end); p++) { if ((*p)->IsHeapObject()) { TracePathFrom(p); done = ((what_to_find_ == FIND_FIRST) && found_target_); } } } void PathTracer::Reset() { found_target_ = false; object_stack_.Clear(); } void PathTracer::TracePathFrom(Object** root) { ASSERT((search_target_ == kAnyGlobalObject) || search_target_->IsHeapObject()); found_target_in_trace_ = false; object_stack_.Clear(); MarkVisitor mark_visitor(this); MarkRecursively(root, &mark_visitor); UnmarkVisitor unmark_visitor(this); UnmarkRecursively(root, &unmark_visitor); ProcessResults(); } static bool SafeIsGlobalContext(HeapObject* obj) { return obj->map() == obj->GetHeap()->raw_unchecked_global_context_map(); } void PathTracer::MarkRecursively(Object** p, MarkVisitor* mark_visitor) { if (!(*p)->IsHeapObject()) return; HeapObject* obj = HeapObject::cast(*p); Object* map = obj->map(); if (!map->IsHeapObject()) return; // visited before if (found_target_in_trace_) return; // stop if target found object_stack_.Add(obj); if (((search_target_ == kAnyGlobalObject) && obj->IsJSGlobalObject()) || (obj == search_target_)) { found_target_in_trace_ = true; found_target_ = true; return; } bool is_global_context = SafeIsGlobalContext(obj); // not visited yet Map* map_p = reinterpret_cast<Map*>(HeapObject::cast(map)); Address map_addr = map_p->address(); obj->set_map_no_write_barrier(reinterpret_cast<Map*>(map_addr + kMarkTag)); // Scan the object body. if (is_global_context && (visit_mode_ == VISIT_ONLY_STRONG)) { // This is specialized to scan Context's properly. Object** start = reinterpret_cast<Object**>(obj->address() + Context::kHeaderSize); Object** end = reinterpret_cast<Object**>(obj->address() + Context::kHeaderSize + Context::FIRST_WEAK_SLOT * kPointerSize); mark_visitor->VisitPointers(start, end); } else { obj->IterateBody(map_p->instance_type(), obj->SizeFromMap(map_p), mark_visitor); } // Scan the map after the body because the body is a lot more interesting // when doing leak detection. MarkRecursively(&map, mark_visitor); if (!found_target_in_trace_) // don't pop if found the target object_stack_.RemoveLast(); } void PathTracer::UnmarkRecursively(Object** p, UnmarkVisitor* unmark_visitor) { if (!(*p)->IsHeapObject()) return; HeapObject* obj = HeapObject::cast(*p); Object* map = obj->map(); if (map->IsHeapObject()) return; // unmarked already Address map_addr = reinterpret_cast<Address>(map); map_addr -= kMarkTag; ASSERT_TAG_ALIGNED(map_addr); HeapObject* map_p = HeapObject::FromAddress(map_addr); obj->set_map_no_write_barrier(reinterpret_cast<Map*>(map_p)); UnmarkRecursively(reinterpret_cast<Object**>(&map_p), unmark_visitor); obj->IterateBody(Map::cast(map_p)->instance_type(), obj->SizeFromMap(Map::cast(map_p)), unmark_visitor); } void PathTracer::ProcessResults() { if (found_target_) { PrintF("=====================================\n"); PrintF("==== Path to object ====\n"); PrintF("=====================================\n\n"); ASSERT(!object_stack_.is_empty()); for (int i = 0; i < object_stack_.length(); i++) { if (i > 0) PrintF("\n |\n |\n V\n\n"); Object* obj = object_stack_[i]; #ifdef OBJECT_PRINT obj->Print(); #else obj->ShortPrint(); #endif } PrintF("=====================================\n"); } } #endif // DEBUG || LIVE_OBJECT_LIST #ifdef DEBUG // Triggers a depth-first traversal of reachable objects from roots // and finds a path to a specific heap object and prints it. void Heap::TracePathToObject(Object* target) { PathTracer tracer(target, PathTracer::FIND_ALL, VISIT_ALL); IterateRoots(&tracer, VISIT_ONLY_STRONG); } // Triggers a depth-first traversal of reachable objects from roots // and finds a path to any global object and prints it. Useful for // determining the source for leaks of global objects. void Heap::TracePathToGlobal() { PathTracer tracer(PathTracer::kAnyGlobalObject, PathTracer::FIND_ALL, VISIT_ALL); IterateRoots(&tracer, VISIT_ONLY_STRONG); } #endif static intptr_t CountTotalHolesSize() { intptr_t holes_size = 0; OldSpaces spaces; for (OldSpace* space = spaces.next(); space != NULL; space = spaces.next()) { holes_size += space->Waste() + space->Available(); } return holes_size; } GCTracer::GCTracer(Heap* heap) : start_time_(0.0), start_size_(0), gc_count_(0), full_gc_count_(0), allocated_since_last_gc_(0), spent_in_mutator_(0), promoted_objects_size_(0), heap_(heap) { if (!FLAG_trace_gc && !FLAG_print_cumulative_gc_stat) return; start_time_ = OS::TimeCurrentMillis(); start_size_ = heap_->SizeOfObjects(); for (int i = 0; i < Scope::kNumberOfScopes; i++) { scopes_[i] = 0; } in_free_list_or_wasted_before_gc_ = CountTotalHolesSize(); allocated_since_last_gc_ = heap_->SizeOfObjects() - heap_->alive_after_last_gc_; if (heap_->last_gc_end_timestamp_ > 0) { spent_in_mutator_ = Max(start_time_ - heap_->last_gc_end_timestamp_, 0.0); } steps_count_ = heap_->incremental_marking()->steps_count(); steps_took_ = heap_->incremental_marking()->steps_took(); longest_step_ = heap_->incremental_marking()->longest_step(); steps_count_since_last_gc_ = heap_->incremental_marking()->steps_count_since_last_gc(); steps_took_since_last_gc_ = heap_->incremental_marking()->steps_took_since_last_gc(); } GCTracer::~GCTracer() { // Printf ONE line iff flag is set. if (!FLAG_trace_gc && !FLAG_print_cumulative_gc_stat) return; bool first_gc = (heap_->last_gc_end_timestamp_ == 0); heap_->alive_after_last_gc_ = heap_->SizeOfObjects(); heap_->last_gc_end_timestamp_ = OS::TimeCurrentMillis(); int time = static_cast<int>(heap_->last_gc_end_timestamp_ - start_time_); // Update cumulative GC statistics if required. if (FLAG_print_cumulative_gc_stat) { heap_->max_gc_pause_ = Max(heap_->max_gc_pause_, time); heap_->max_alive_after_gc_ = Max(heap_->max_alive_after_gc_, heap_->alive_after_last_gc_); if (!first_gc) { heap_->min_in_mutator_ = Min(heap_->min_in_mutator_, static_cast<int>(spent_in_mutator_)); } } if (!FLAG_trace_gc_nvp) { int external_time = static_cast<int>(scopes_[Scope::EXTERNAL]); PrintF("%s %.1f -> %.1f MB, ", CollectorString(), static_cast<double>(start_size_) / MB, SizeOfHeapObjects()); if (external_time > 0) PrintF("%d / ", external_time); PrintF("%d ms", time); if (steps_count_ > 0) { if (collector_ == SCAVENGER) { PrintF(" (+ %d ms in %d steps since last GC)", static_cast<int>(steps_took_since_last_gc_), steps_count_since_last_gc_); } else { PrintF(" (+ %d ms in %d steps since start of marking, " "biggest step %f ms)", static_cast<int>(steps_took_), steps_count_, longest_step_); } } PrintF(".\n"); } else { PrintF("pause=%d ", time); PrintF("mutator=%d ", static_cast<int>(spent_in_mutator_)); PrintF("gc="); switch (collector_) { case SCAVENGER: PrintF("s"); break; case MARK_COMPACTOR: PrintF("ms"); break; default: UNREACHABLE(); } PrintF(" "); PrintF("external=%d ", static_cast<int>(scopes_[Scope::EXTERNAL])); PrintF("mark=%d ", static_cast<int>(scopes_[Scope::MC_MARK])); PrintF("sweep=%d ", static_cast<int>(scopes_[Scope::MC_SWEEP])); PrintF("sweepns=%d ", static_cast<int>(scopes_[Scope::MC_SWEEP_NEWSPACE])); PrintF("evacuate=%d ", static_cast<int>(scopes_[Scope::MC_EVACUATE_PAGES])); PrintF("new_new=%d ", static_cast<int>(scopes_[Scope::MC_UPDATE_NEW_TO_NEW_POINTERS])); PrintF("root_new=%d ", static_cast<int>(scopes_[Scope::MC_UPDATE_ROOT_TO_NEW_POINTERS])); PrintF("old_new=%d ", static_cast<int>(scopes_[Scope::MC_UPDATE_OLD_TO_NEW_POINTERS])); PrintF("compaction_ptrs=%d ", static_cast<int>(scopes_[Scope::MC_UPDATE_POINTERS_TO_EVACUATED])); PrintF("intracompaction_ptrs=%d ", static_cast<int>(scopes_[ Scope::MC_UPDATE_POINTERS_BETWEEN_EVACUATED])); PrintF("misc_compaction=%d ", static_cast<int>(scopes_[Scope::MC_UPDATE_MISC_POINTERS])); PrintF("total_size_before=%" V8_PTR_PREFIX "d ", start_size_); PrintF("total_size_after=%" V8_PTR_PREFIX "d ", heap_->SizeOfObjects()); PrintF("holes_size_before=%" V8_PTR_PREFIX "d ", in_free_list_or_wasted_before_gc_); PrintF("holes_size_after=%" V8_PTR_PREFIX "d ", CountTotalHolesSize()); PrintF("allocated=%" V8_PTR_PREFIX "d ", allocated_since_last_gc_); PrintF("promoted=%" V8_PTR_PREFIX "d ", promoted_objects_size_); if (collector_ == SCAVENGER) { PrintF("stepscount=%d ", steps_count_since_last_gc_); PrintF("stepstook=%d ", static_cast<int>(steps_took_since_last_gc_)); } else { PrintF("stepscount=%d ", steps_count_); PrintF("stepstook=%d ", static_cast<int>(steps_took_)); } PrintF("\n"); } heap_->PrintShortHeapStatistics(); } const char* GCTracer::CollectorString() { switch (collector_) { case SCAVENGER: return "Scavenge"; case MARK_COMPACTOR: return "Mark-sweep"; } return "Unknown GC"; } int KeyedLookupCache::Hash(Map* map, String* name) { // Uses only lower 32 bits if pointers are larger. uintptr_t addr_hash = static_cast<uint32_t>(reinterpret_cast<uintptr_t>(map)) >> kMapHashShift; return static_cast<uint32_t>((addr_hash ^ name->Hash()) & kCapacityMask); } int KeyedLookupCache::Lookup(Map* map, String* name) { int index = Hash(map, name); Key& key = keys_[index]; if ((key.map == map) && key.name->Equals(name)) { return field_offsets_[index]; } return kNotFound; } void KeyedLookupCache::Update(Map* map, String* name, int field_offset) { String* symbol; if (HEAP->LookupSymbolIfExists(name, &symbol)) { int index = Hash(map, symbol); Key& key = keys_[index]; key.map = map; key.name = symbol; field_offsets_[index] = field_offset; } } void KeyedLookupCache::Clear() { for (int index = 0; index < kLength; index++) keys_[index].map = NULL; } void DescriptorLookupCache::Clear() { for (int index = 0; index < kLength; index++) keys_[index].array = NULL; } #ifdef DEBUG void Heap::GarbageCollectionGreedyCheck() { ASSERT(FLAG_gc_greedy); if (isolate_->bootstrapper()->IsActive()) return; if (disallow_allocation_failure()) return; CollectGarbage(NEW_SPACE); } #endif TranscendentalCache::SubCache::SubCache(Type t) : type_(t), isolate_(Isolate::Current()) { uint32_t in0 = 0xffffffffu; // Bit-pattern for a NaN that isn't uint32_t in1 = 0xffffffffu; // generated by the FPU. for (int i = 0; i < kCacheSize; i++) { elements_[i].in[0] = in0; elements_[i].in[1] = in1; elements_[i].output = NULL; } } void TranscendentalCache::Clear() { for (int i = 0; i < kNumberOfCaches; i++) { if (caches_[i] != NULL) { delete caches_[i]; caches_[i] = NULL; } } } void ExternalStringTable::CleanUp() { int last = 0; for (int i = 0; i < new_space_strings_.length(); ++i) { if (new_space_strings_[i] == heap_->raw_unchecked_the_hole_value()) { continue; } if (heap_->InNewSpace(new_space_strings_[i])) { new_space_strings_[last++] = new_space_strings_[i]; } else { old_space_strings_.Add(new_space_strings_[i]); } } new_space_strings_.Rewind(last); last = 0; for (int i = 0; i < old_space_strings_.length(); ++i) { if (old_space_strings_[i] == heap_->raw_unchecked_the_hole_value()) { continue; } ASSERT(!heap_->InNewSpace(old_space_strings_[i])); old_space_strings_[last++] = old_space_strings_[i]; } old_space_strings_.Rewind(last); if (FLAG_verify_heap) { Verify(); } } void ExternalStringTable::TearDown() { new_space_strings_.Free(); old_space_strings_.Free(); } void Heap::QueueMemoryChunkForFree(MemoryChunk* chunk) { chunk->set_next_chunk(chunks_queued_for_free_); chunks_queued_for_free_ = chunk; } void Heap::FreeQueuedChunks() { if (chunks_queued_for_free_ == NULL) return; MemoryChunk* next; MemoryChunk* chunk; for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { next = chunk->next_chunk(); chunk->SetFlag(MemoryChunk::ABOUT_TO_BE_FREED); if (chunk->owner()->identity() == LO_SPACE) { // StoreBuffer::Filter relies on MemoryChunk::FromAnyPointerAddress. // If FromAnyPointerAddress encounters a slot that belongs to a large // chunk queued for deletion it will fail to find the chunk because // it try to perform a search in the list of pages owned by of the large // object space and queued chunks were detached from that list. // To work around this we split large chunk into normal kPageSize aligned // pieces and initialize size, owner and flags field of every piece. // If FromAnyPointerAddress encounters a slot that belongs to one of // these smaller pieces it will treat it as a slot on a normal Page. MemoryChunk* inner = MemoryChunk::FromAddress( chunk->address() + Page::kPageSize); MemoryChunk* inner_last = MemoryChunk::FromAddress( chunk->address() + chunk->size() - 1); while (inner <= inner_last) { // Size of a large chunk is always a multiple of // OS::AllocateAlignment() so there is always // enough space for a fake MemoryChunk header. inner->set_size(Page::kPageSize); inner->set_owner(lo_space()); inner->SetFlag(MemoryChunk::ABOUT_TO_BE_FREED); inner = MemoryChunk::FromAddress( inner->address() + Page::kPageSize); } } } isolate_->heap()->store_buffer()->Compact(); isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED); for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) { next = chunk->next_chunk(); isolate_->memory_allocator()->Free(chunk); } chunks_queued_for_free_ = NULL; } } } // namespace v8::internal
#pragma once #include <atomic> template < typename T, unsigned N > class ring_buffer { std::atomic< unsigned > head_idx_{0}; std::atomic< unsigned > tail_idx_{0}; T buffer_[N]; template < typename V > auto increment(V val, V inc = V(1)) const noexcept { return (val + inc) % N; } constexpr auto size(const unsigned current_head, const unsigned current_tail) const noexcept { return (current_head - current_tail + N) % N; } public: constexpr auto size() const noexcept { const auto current_head = head_idx_.load(std::memory_order_relaxed); const auto current_tail = tail_idx_.load(std::memory_order_relaxed); return (current_head - current_tail + N) % N; } constexpr auto capacity() const noexcept { return N - 1; } bool push(T item) const noexcept { const auto current_head = head_idx_.load(std::memory_order_relaxed); const auto next_head = increment(current_head); if (next_head != tail_idx_.load(std::memory_order_acquire)) { buffer_[current_head] = item; head_idx_.store(next_head, std::memory_order_release); return true; } return false; } bool push(const T *items, unsigned num) const noexcept { const auto current_head = head_idx_.load(std::memory_order_acquire); const auto current_tail = tail_idx_.load(std::memory_order_relaxed); if (num == 0 || capacity() - size(current_head, current_tail) < num) return false; const auto space_left_head = N - head_idx_; if (space_left_head >= num) { // All will fit without the head_idx_ overflowing // std::memcpy(&buffer_[current_head], items, num * sizeof(T)); for (unsigned i = 0; i < num; i++) buffer_[current_head + i] = items[i]; // head_idx_ += num; head_idx_.store(current_head + num, std::memory_order_release); } else { // The head_idx_ will overflow, write in 2 steps // std::memcpy(&buffer_[current_head], items, space_left_head * // sizeof(T)); for (unsigned i = 0; i < space_left_head; i++) buffer_[current_head + i] = items[i]; num -= space_left_head; // std::memcpy(&buffer_[0], (items + space_left_head), num * sizeof(T)); for (unsigned i = 0; i < num; i++) buffer_[i] = items[space_left_head + i]; head_idx_.store(num, std::memory_order_release); } return true; } bool pop(T &item) const noexcept { const auto current_tail = tail_idx_.load(std::memory_order_relaxed); if (current_tail == head_idx_.load(std::memory_order_acquire)) return false; item = buffer_[current_tail]; tail_idx_.store(increment(current_tail), std::memory_order_release); return true; } unsigned pop_chunk(T *destination, unsigned num) const noexcept { const auto current_head = head_idx_.load(std::memory_order_relaxed); const auto current_tail = tail_idx_.load(std::memory_order_acquire); if (num == 0 || destination == nullptr) return 0; // No data read if (current_tail == current_head) return 0; // No data read const auto num_elems = capacity() - size(current_head, current_tail); if (num > num_elems) num = num_elems; // Limit the number of elements to be read const auto space_left_tail = N - tail_idx_; if (space_left_tail >= num) { // All will read without the tail_idx_ overflowing for (unsigned i = 0; i < num; i++) destination[i] = buffer_[current_tail + i]; tail_idx_.store(current_tail + num, std::memory_order_release); } else { // The tail_idx_ will overflow, read in 2 steps for (unsigned i = 0; i < space_left_tail; i++) destination[i] = buffer_[current_tail + i]; const auto num_left = num - space_left_tail; for (unsigned i = 0; i < num_left; i++) destination[space_left_tail + i] = buffer_[i]; head_idx_.store(num_left, std::memory_order_release); } return num; } };
; ; ZX Spectrum specific routines ; by Stefano Bodrato, 14/09/2006 ; ; int zx_printer(); ; ; The result is: ; - 1 (true) if the ZX printer is connected ; - 0 (false) otherwise ; ; $Id: zx_printer.asm,v 1.2 2015/01/19 01:33:08 pauloscustodio Exp $ ; PUBLIC zx_printer zx_printer: ld hl,0 in a,($fb) bit 6,a ret nz inc hl ret
; A271574: Decimal expansion of Sum_{n>=0} 1/(n!)^3. ; 2,1,2,9,7,0,2,5,4,8,9,8,3,3,0,6,4,1,8,1,3,4,5,2,3,6,1,0,5,9,5,4,1,3,4,6,8,3,1,9,2,2,0,7,4,7,0,3,9,1,6,9,3,0,3,7,6,2,9,9,6,8,6,0,2,9,9,9,9,6,2,2,9,2,9,9,8,7,3,0,1,7,9,6,3,8,3,2,7,8,1,2,7,1,0,4,2,2,4,9 mov $1,1 mov $2,1 mov $3,$0 mul $3,5 lpb $3 mov $4,$3 cmp $4,0 add $3,$4 div $1,$3 mul $2,$3 add $1,$2 mov $5,$0 div $5,3 mov $4,$5 cmp $4,0 add $5,$4 div $1,$5 div $2,$5 sub $3,1 mov $4,$3 cmp $4,0 add $3,$4 div $1,$3 lpe mov $6,10 pow $6,$0 div $2,$6 div $1,$2 add $1,$6 mod $1,10 mov $0,$1
.global s_prepare_buffers s_prepare_buffers: push %r12 push %r14 push %r8 push %r9 push %rax push %rcx push %rdi push %rsi lea addresses_normal_ht+0x14316, %rcx nop xor $12417, %r8 mov (%rcx), %si nop nop nop nop cmp $29891, %rax lea addresses_A_ht+0x16d6e, %r9 nop nop nop nop cmp $32737, %rcx mov (%r9), %rsi nop nop add $57924, %r8 lea addresses_normal_ht+0x7d6e, %r14 nop nop nop nop inc %r12 mov $0x6162636465666768, %rsi movq %rsi, (%r14) nop nop nop nop nop cmp $46582, %r9 lea addresses_A_ht+0xeeee, %rcx nop nop nop nop and $36169, %r9 movw $0x6162, (%rcx) nop nop and $56095, %r8 lea addresses_normal_ht+0xd06e, %rsi lea addresses_D_ht+0x116fe, %rdi clflush (%rsi) nop nop nop add $35909, %rax mov $4, %rcx rep movsb nop nop nop nop cmp $48503, %rdi lea addresses_UC_ht+0x1406e, %rsi lea addresses_D_ht+0xd6e, %rdi nop sub $51793, %r8 mov $73, %rcx rep movsw cmp %r12, %r12 lea addresses_normal_ht+0x6f8c, %r14 nop nop add $39372, %r12 movl $0x61626364, (%r14) nop and %r12, %r12 lea addresses_WC_ht+0xa6ee, %rsi clflush (%rsi) nop nop nop nop add $36087, %r12 mov (%rsi), %r8w nop nop nop nop add $45375, %rax lea addresses_UC_ht+0x10e6e, %rsi lea addresses_UC_ht+0xca9a, %rdi nop nop nop sub $15853, %r12 mov $43, %rcx rep movsb and $32154, %r9 lea addresses_WT_ht+0x5fbc, %r14 nop nop nop nop nop inc %r8 mov (%r14), %r9d and %r8, %r8 lea addresses_UC_ht+0x1be02, %rcx nop xor %rax, %rax movl $0x61626364, (%rcx) nop inc %r12 lea addresses_WC_ht+0x56e, %rcx nop nop nop nop mfence mov $0x6162636465666768, %r12 movq %r12, (%rcx) nop nop nop nop and %rax, %rax lea addresses_UC_ht+0x11e6e, %rax nop nop inc %rdi mov (%rax), %r14d nop and $18944, %r8 lea addresses_WT_ht+0x15e7a, %r12 cmp %rax, %rax mov $0x6162636465666768, %r8 movq %r8, %xmm4 vmovups %ymm4, (%r12) nop nop nop nop and $2616, %rcx pop %rsi pop %rdi pop %rcx pop %rax pop %r9 pop %r8 pop %r14 pop %r12 ret .global s_faulty_load s_faulty_load: push %r10 push %r12 push %r13 push %r14 push %r9 push %rax push %rdi // Store lea addresses_PSE+0xbf0e, %r13 nop xor %rdi, %rdi movw $0x5152, (%r13) nop nop nop nop nop xor %rdi, %rdi // Faulty Load lea addresses_UC+0x16d6e, %r14 nop nop nop nop and %r12, %r12 movups (%r14), %xmm2 vpextrq $0, %xmm2, %rax lea oracles, %r9 and $0xff, %rax shlq $12, %rax mov (%r9,%rax,1), %rax pop %rdi pop %rax pop %r9 pop %r14 pop %r13 pop %r12 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_UC', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_PSE', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_UC', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 7, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 1, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 11, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 4, 'AVXalign': True, 'NT': False, 'congruent': 1, 'same': True}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_UC_ht', 'congruent': 8, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 2, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_UC_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}} {'37': 21000} 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 37 */
;******************************************************************************************************** ; uC/CPU ; CPU CONFIGURATION & PORT LAYER ; ; Copyright 2004-2020 Silicon Laboratories Inc. www.silabs.com ; ; SPDX-License-Identifier: APACHE-2.0 ; ; This software is subject to an open source license and is distributed by ; Silicon Laboratories Inc. pursuant to the terms of the Apache License, ; Version 2.0 available at www.apache.org/licenses/LICENSE-2.0. ; ;******************************************************************************************************** ;******************************************************************************************************** ; ; CPU PORT FILE ; ; ARMv6-M ; IAR C Compiler ; ; Filename : cpu_a.asm ; Version : v1.32.00 ;******************************************************************************************************** ; Note(s) : This port supports the ARM Cortex-M0, and Cortex-M0+ architectures. ;******************************************************************************************************** ;******************************************************************************************************** ; PUBLIC FUNCTIONS ;******************************************************************************************************** PUBLIC CPU_IntDis PUBLIC CPU_IntEn PUBLIC CPU_SR_Save PUBLIC CPU_SR_Restore PUBLIC CPU_WaitForInt PUBLIC CPU_WaitForExcept ;******************************************************************************************************** ; CODE GENERATION DIRECTIVES ;******************************************************************************************************** RSEG CODE:CODE:NOROOT(2) THUMB ;******************************************************************************************************** ; DISABLE and ENABLE INTERRUPTS ; ; Description : Disable/Enable interrupts. ; ; Prototypes : void CPU_IntDis(void); ; void CPU_IntEn (void); ;******************************************************************************************************** CPU_IntDis CPSID I BX LR CPU_IntEn CPSIE I BX LR ;******************************************************************************************************** ; CRITICAL SECTION FUNCTIONS ; ; Description : Disable/Enable interrupts by preserving the state of interrupts. Generally speaking, the ; state of the interrupt disable flag is stored in the local variable 'cpu_sr' & interrupts ; are then disabled ('cpu_sr' is allocated in all functions that need to disable interrupts). ; The previous interrupt state is restored by copying 'cpu_sr' into the CPU's status register. ; ; Prototypes : CPU_SR CPU_SR_Save (void); ; void CPU_SR_Restore(CPU_SR cpu_sr); ; ; Note(s) : (1) These functions are used in general like this : ; ; void Task (void *p_arg) ; { ; CPU_SR_ALLOC(); /* Allocate storage for CPU status register */ ; : ; : ; CPU_CRITICAL_ENTER(); /* cpu_sr = CPU_SR_Save(); */ ; : ; : ; CPU_CRITICAL_EXIT(); /* CPU_SR_Restore(cpu_sr); */ ; : ; } ;******************************************************************************************************** CPU_SR_Save MRS R0, PRIMASK ; Set prio int mask to mask all (except faults) CPSID I BX LR CPU_SR_Restore ; See Note #2. MSR PRIMASK, R0 BX LR ;******************************************************************************************************** ; WAIT FOR INTERRUPT ; ; Description : Enters sleep state, which will be exited when an interrupt is received. ; ; Prototypes : void CPU_WaitForInt (void) ; ; Argument(s) : none. ;******************************************************************************************************** CPU_WaitForInt WFI ; Wait for interrupt BX LR ;******************************************************************************************************** ; WAIT FOR EXCEPTION ; ; Description : Enters sleep state, which will be exited when an exception is received. ; ; Prototypes : void CPU_WaitForExcept (void) ; ; Argument(s) : none. ;******************************************************************************************************** CPU_WaitForExcept WFE ; Wait for exception BX LR ;******************************************************************************************************** ; CPU ASSEMBLY PORT FILE END ;******************************************************************************************************** END
; ***************************************************************************** ; * Provide SIMD optimizations for add_residual functions for HEVC decoding ; * Copyright (c) 2014 Pierre-Edouard LEPERE ; * ; * This file is part of FFmpeg. ; * ; * FFmpeg is free software; you can redistribute it and/or ; * modify it under the terms of the GNU Lesser General Public ; * License as published by the Free Software Foundation; either ; * version 2.1 of the License, or (at your option) any later version. ; * ; * FFmpeg is distributed in the hope that it will be useful, ; * but WITHOUT ANY WARRANTY; without even the implied warranty of ; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ; * Lesser General Public License for more details. ; * ; * You should have received a copy of the GNU Lesser General Public ; * License along with FFmpeg; if not, write to the Free Software ; * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ; ****************************************************************************** %include "libavutil/x86/x86util.asm" SECTION .text cextern pw_1023 %define max_pixels_10 pw_1023 ; the add_res macros and functions were largely inspired by h264_idct.asm from the x264 project %macro ADD_RES_MMX_4_8 0 mova m0, [r1] mova m2, [r1+8] movd m1, [r0] movd m3, [r0+r2] punpcklbw m1, m4 punpcklbw m3, m4 paddsw m0, m1 paddsw m2, m3 packuswb m0, m4 packuswb m2, m4 movd [r0], m0 movd [r0+r2], m2 %endmacro INIT_MMX mmxext ; void ff_hevc_add_residual_4_8_mmxext(uint8_t *dst, int16_t *res, ptrdiff_t stride) cglobal hevc_add_residual_4_8, 3, 3, 6 pxor m4, m4 ADD_RES_MMX_4_8 add r1, 16 lea r0, [r0+r2*2] ADD_RES_MMX_4_8 RET %macro ADD_RES_SSE_8_8 0 movq m0, [r0] movq m1, [r0+r2] punpcklbw m0, m4 punpcklbw m1, m4 mova m2, [r1] mova m3, [r1+16] paddsw m0, m2 paddsw m1, m3 packuswb m0, m1 movq m2, [r0+r2*2] movq m3, [r0+r3] punpcklbw m2, m4 punpcklbw m3, m4 mova m6, [r1+32] mova m7, [r1+48] paddsw m2, m6 paddsw m3, m7 packuswb m2, m3 movq [r0], m0 movhps [r0+r2], m0 movq [r0+r2*2], m2 movhps [r0+r3], m2 %endmacro %macro ADD_RES_SSE_16_32_8 3 mova m1, [%2] mova m2, m1 punpcklbw m1, m0 punpckhbw m2, m0 mova xm5, [r1+%1] mova xm6, [r1+%1+16] %if cpuflag(avx2) vinserti128 m5, m5, [r1+%1+32], 1 vinserti128 m6, m6, [r1+%1+48], 1 %endif paddsw m1, m5 paddsw m2, m6 mova m3, [%3] mova m4, m3 punpcklbw m3, m0 punpckhbw m4, m0 mova xm5, [r1+%1+mmsize*2] mova xm6, [r1+%1+mmsize*2+16] %if cpuflag(avx2) vinserti128 m5, m5, [r1+%1+96], 1 vinserti128 m6, m6, [r1+%1+112], 1 %endif paddsw m3, m5 paddsw m4, m6 packuswb m1, m2 packuswb m3, m4 mova [%2], m1 mova [%3], m3 %endmacro %macro TRANSFORM_ADD_8 0 ; void ff_hevc_add_residual_8_8_<opt>(uint8_t *dst, int16_t *res, ptrdiff_t stride) cglobal hevc_add_residual_8_8, 3, 4, 8 pxor m4, m4 lea r3, [r2*3] ADD_RES_SSE_8_8 add r1, 64 lea r0, [r0+r2*4] ADD_RES_SSE_8_8 RET ; void ff_hevc_add_residual_16_8_<opt>(uint8_t *dst, int16_t *res, ptrdiff_t stride) cglobal hevc_add_residual_16_8, 3, 5, 7 pxor m0, m0 lea r3, [r2*3] mov r4d, 4 .loop: ADD_RES_SSE_16_32_8 0, r0, r0+r2 ADD_RES_SSE_16_32_8 64, r0+r2*2, r0+r3 add r1, 128 lea r0, [r0+r2*4] dec r4d jg .loop RET ; void ff_hevc_add_residual_32_8_<opt>(uint8_t *dst, int16_t *res, ptrdiff_t stride) cglobal hevc_add_residual_32_8, 3, 5, 7 pxor m0, m0 mov r4d, 16 .loop: ADD_RES_SSE_16_32_8 0, r0, r0+16 ADD_RES_SSE_16_32_8 64, r0+r2, r0+r2+16 add r1, 128 lea r0, [r0+r2*2] dec r4d jg .loop RET %endmacro INIT_XMM sse2 TRANSFORM_ADD_8 INIT_XMM avx TRANSFORM_ADD_8 %if HAVE_AVX2_EXTERNAL INIT_YMM avx2 ; void ff_hevc_add_residual_32_8_avx2(uint8_t *dst, int16_t *res, ptrdiff_t stride) cglobal hevc_add_residual_32_8, 3, 5, 7 pxor m0, m0 lea r3, [r2*3] mov r4d, 8 .loop: ADD_RES_SSE_16_32_8 0, r0, r0+r2 ADD_RES_SSE_16_32_8 128, r0+r2*2, r0+r3 add r1, 256 lea r0, [r0+r2*4] dec r4d jg .loop RET %endif ;HAVE_AVX2_EXTERNAL %macro ADD_RES_SSE_8_10 4 mova m0, [%4] mova m1, [%4+16] mova m2, [%4+32] mova m3, [%4+48] paddw m0, [%1+0] paddw m1, [%1+%2] paddw m2, [%1+%2*2] paddw m3, [%1+%3] CLIPW m0, m4, m5 CLIPW m1, m4, m5 CLIPW m2, m4, m5 CLIPW m3, m4, m5 mova [%1+0], m0 mova [%1+%2], m1 mova [%1+%2*2], m2 mova [%1+%3], m3 %endmacro %macro ADD_RES_MMX_4_10 3 mova m0, [%1+0] mova m1, [%1+%2] paddw m0, [%3] paddw m1, [%3+8] CLIPW m0, m2, m3 CLIPW m1, m2, m3 mova [%1+0], m0 mova [%1+%2], m1 %endmacro %macro ADD_RES_SSE_16_10 3 mova m0, [%3] mova m1, [%3+16] mova m2, [%3+32] mova m3, [%3+48] paddw m0, [%1] paddw m1, [%1+16] paddw m2, [%1+%2] paddw m3, [%1+%2+16] CLIPW m0, m4, m5 CLIPW m1, m4, m5 CLIPW m2, m4, m5 CLIPW m3, m4, m5 mova [%1], m0 mova [%1+16], m1 mova [%1+%2], m2 mova [%1+%2+16], m3 %endmacro %macro ADD_RES_SSE_32_10 2 mova m0, [%2] mova m1, [%2+16] mova m2, [%2+32] mova m3, [%2+48] paddw m0, [%1] paddw m1, [%1+16] paddw m2, [%1+32] paddw m3, [%1+48] CLIPW m0, m4, m5 CLIPW m1, m4, m5 CLIPW m2, m4, m5 CLIPW m3, m4, m5 mova [%1], m0 mova [%1+16], m1 mova [%1+32], m2 mova [%1+48], m3 %endmacro %macro ADD_RES_AVX2_16_10 4 mova m0, [%4] mova m1, [%4+32] mova m2, [%4+64] mova m3, [%4+96] paddw m0, [%1+0] paddw m1, [%1+%2] paddw m2, [%1+%2*2] paddw m3, [%1+%3] CLIPW m0, m4, m5 CLIPW m1, m4, m5 CLIPW m2, m4, m5 CLIPW m3, m4, m5 mova [%1+0], m0 mova [%1+%2], m1 mova [%1+%2*2], m2 mova [%1+%3], m3 %endmacro %macro ADD_RES_AVX2_32_10 3 mova m0, [%3] mova m1, [%3+32] mova m2, [%3+64] mova m3, [%3+96] paddw m0, [%1] paddw m1, [%1+32] paddw m2, [%1+%2] paddw m3, [%1+%2+32] CLIPW m0, m4, m5 CLIPW m1, m4, m5 CLIPW m2, m4, m5 CLIPW m3, m4, m5 mova [%1], m0 mova [%1+32], m1 mova [%1+%2], m2 mova [%1+%2+32], m3 %endmacro ; void ff_hevc_add_residual_<4|8|16|32>_10(pixel *dst, int16_t *block, ptrdiff_t stride) INIT_MMX mmxext cglobal hevc_add_residual_4_10, 3, 3, 6 pxor m2, m2 mova m3, [max_pixels_10] ADD_RES_MMX_4_10 r0, r2, r1 add r1, 16 lea r0, [r0+2*r2] ADD_RES_MMX_4_10 r0, r2, r1 RET INIT_XMM sse2 cglobal hevc_add_residual_8_10, 3, 4, 6 pxor m4, m4 mova m5, [max_pixels_10] lea r3, [r2*3] ADD_RES_SSE_8_10 r0, r2, r3, r1 lea r0, [r0+r2*4] add r1, 64 ADD_RES_SSE_8_10 r0, r2, r3, r1 RET cglobal hevc_add_residual_16_10, 3, 5, 6 pxor m4, m4 mova m5, [max_pixels_10] mov r4d, 8 .loop: ADD_RES_SSE_16_10 r0, r2, r1 lea r0, [r0+r2*2] add r1, 64 dec r4d jg .loop RET cglobal hevc_add_residual_32_10, 3, 5, 6 pxor m4, m4 mova m5, [max_pixels_10] mov r4d, 32 .loop: ADD_RES_SSE_32_10 r0, r1 lea r0, [r0+r2] add r1, 64 dec r4d jg .loop RET %if HAVE_AVX2_EXTERNAL INIT_YMM avx2 cglobal hevc_add_residual_16_10, 3, 5, 6 pxor m4, m4 mova m5, [max_pixels_10] lea r3, [r2*3] mov r4d, 4 .loop: ADD_RES_AVX2_16_10 r0, r2, r3, r1 lea r0, [r0+r2*4] add r1, 128 dec r4d jg .loop RET cglobal hevc_add_residual_32_10, 3, 5, 6 pxor m4, m4 mova m5, [max_pixels_10] mov r4d, 16 .loop: ADD_RES_AVX2_32_10 r0, r2, r1 lea r0, [r0+r2*2] add r1, 128 dec r4d jg .loop RET %endif ;HAVE_AVX2_EXTERNAL
db 0 ; species ID placeholder db 40, 80, 35, 70, 35, 45 ; hp atk def spd sat sdf db FIGHTING, FIGHTING ; type db 190 ; catch rate db 74 ; base exp db NO_ITEM, NO_ITEM ; items db GENDER_F50 ; gender ratio db 100 ; unknown 1 db 20 ; step cycles to hatch db 5 ; unknown 2 INCBIN "gfx/pokemon/mankey/front.dimensions" db 0, 0, 0, 0 ; padding db GROWTH_MEDIUM_FAST ; growth rate dn EGG_GROUND, EGG_GROUND ; egg groups ; tm/hm learnset tmhm DYNAMICPUNCH, HEADBUTT, CURSE, TOXIC, ROCK_SMASH, PSYCH_UP, HIDDEN_POWER, SUNNY_DAY, SNORE, PROTECT, ENDURE, FRUSTRATION, IRON_TAIL, THUNDER, RETURN, DIG, MUD_SLAP, DOUBLE_TEAM, ICE_PUNCH, SWAGGER, SLEEP_TALK, SWIFT, DEFENSE_CURL, THUNDERPUNCH, DETECT, REST, ATTRACT, THIEF, FIRE_PUNCH, STRONG_ARM, THUNDERBOLT ; end
// // Open a parameter set file and print it. // // // Contact person Rob Kutschke // #include "Offline/GeneralUtilities/inc/ParameterSetFromFile.hh" // Framework includes. #include "art/Framework/Core/EDAnalyzer.h" #include "art/Framework/Principal/Event.h" // C++ includes. #include <iostream> namespace mu2e { class StandAloneParameterSet : public art::EDAnalyzer { public: explicit StandAloneParameterSet(fhicl::ParameterSet const& pset); virtual void analyze(const art::Event& e); }; StandAloneParameterSet::StandAloneParameterSet(fhicl::ParameterSet const& pset): art::EDAnalyzer(pset){ std::string filename=pset.get<std::string>("psetFile"); // Look for the specified file in FHICL_FILE_PATH. // If found, open it and turn it into a fhcil::ParameterSet. ParameterSetFromFile params(filename); std::cout <<"The file name is: " << filename << std::endl; std::cout << params.pSet().to_indented_string() << std::endl; } void StandAloneParameterSet::analyze( const art::Event& event ) { } } // end namespace mu2e DEFINE_ART_MODULE(mu2e::StandAloneParameterSet);
#include <conio.h> #include <iostream> #include <GL\glew.h> #include <GLFW\glfw3.h> #include <glm\glm.hpp> #include <imgui\imgui.h> #include <engine_base\ExceptionWrapper.h> #include <engine_base\imgui_impl_glfw_gl3.h> #include <engine_base\Input.h> #include <engine_base\ModelLoader.h> #include "Globals.h" #include "World.h" using namespace std; int cur_frame = 0; int total_frames = 1000; bool input_active = true; bool view_hull = false; bool calc_hull = true; int hull_counter = 0; static void error_callback(int error, const char* description) { fprintf(stderr, "Error: %s\n", description); } void run() { glfwSetErrorCallback(error_callback); if (!glfwInit()) { throw_exception(runtime_error("glfwInit failed")); } glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); GLFWwindow* window = glfwCreateWindow(1280, 720, "Intelligent Camera", NULL, NULL); if (!window) { glfwTerminate(); throw_exception(runtime_error("glfwCreateWindow failed")); } Input::init(window); glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); glfwMakeContextCurrent(window); // initialize GLEW glewExperimental = GL_TRUE; if (glewInit() != GLEW_OK) throw_exception(runtime_error("glewInit failed")); // GLEW throws some errors, so discard all the errors so far while (glGetError() != GL_NO_ERROR) {} ImGui_ImplGlfwGL3_Init(window, false); cout << ImGui::GetIO().MouseDrawCursor << endl; //glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED); glEnable(GL_DEPTH_TEST); glEnable(GL_CULL_FACE); glCullFace(GL_BACK); glDisable(GL_BLEND); //glEnable(GL_BLEND); //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glClearColor(100 / 255.f, 149 / 255.f, 237 / 255.f, 1.0f); glfwSwapInterval(.5); shared_ptr<World> world = make_shared<World>(); world->init(); double oldTime = glfwGetTime(); while (!Input::key_pressed_down(GLFW_KEY_ESCAPE)) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); double newTime = glfwGetTime(); double timeElapsed = newTime - oldTime; world->step(timeElapsed); oldTime = newTime; Input::clear(); glfwSwapBuffers(window); glfwPollEvents(); } glfwDestroyWindow(window); glfwTerminate(); } int main(int argc, char** argv) { try { run(); } catch (const exception& e) { char temp; cerr << e.what() << endl; cerr << "Press anything to quit..." << endl; _getch(); exit(EXIT_FAILURE); } exit(EXIT_SUCCESS); }
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1992 -- All Rights Reserved PROJECT: PC GEOS MODULE: FILE: prefmgrModuleList.asm AUTHOR: Chris Boyke ROUTINES: Name Description ---- ----------- REVISION HISTORY: Name Date Description ---- ---- ----------- CDB 5/ 4/92 Initial version. DESCRIPTION: Implementation of PrefMgrModuleListClass $Id: prefmgrModuleList.asm,v 1.1 97/04/04 16:27:12 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@
; SMSQ_SBAS_FILEINFO FileInfo Thing section sbas include 'dev8_keys_qdos_ioa' include 'dev8_keys_thg' include 'dev8_keys_err' include 'dev8_keys_qlv' xdef sb_fileinfo xref gu_thexn xref gu_thini xref gu_fopen xref gu_fclos sb_name dc.w 6,'SBASIC' ;+++ ; Initialise Thing ;--- sb_fileinfo lea sbfi_tab,a1 jsr gu_thini bne.s sbfi_rts lea sbfi_use,a2 move.l a2,th_use(a1) moveq #0,d0 sbfi_rts rts sbfi_tab dc.l th_name+10 ; size of linkage dc.l sbfi_thing-* ; thing dc.l '1.00' ; version sbfi_name dc.w 8,'FileInfo' sbfi_use move.l a1,d6 ; save this move.w mem.achp,a0 moveq #$18,d1 jsr (a0) ; allocate usage block move.l d6,d2 lea sbfi_entry,a2 ; entry code move.l #$00020004,d3 ; set facilities tst.l d0 rts sbfi_thing dc.l thh.flag ; flag dc.l 0 sbfi_entry sbfi.reg reg d1/d3/a0/a1 movem.l sbfi.reg,-(sp) move.l a0,a1 move.w (a1)+,d0 add.w d0,a1 ; end of filename moveq #3,d0 sbfi_extl move.b -(a1),d1 ror.l #8,d1 dbra d0,sbfi_extl and.l #$ffdfdfdf,d1 ; upper case cmp.l #'_BAS',d1 ; _BAS file? beq.s sbfi_do ; ... yes cmp.l #'_SAV',d1 ; _SAV file? beq.s sbfi_do ; ... yes cmp.l #'.BAS',d1 ; _BAS file? beq.s sbfi_do ; ... yes cmp.l #'.SAV',d1 ; _SAV file? bne.s sbfi_nf ; ... no sbfi_do tst.b d3 ; execute <> 0 beq.s sbfi_ok ; ... test, just say OK moveq #ioa.kshr,d3 jsr gu_fopen ; open the file bne.s sbfi_exit clr.w -(sp) ; set up parameters move.l a0,-(sp) move.l #$00080001,-(sp) ; size of parameter fram move.l sp,a1 ; parameter lea sb_name,a0 sub.l a2,a2 moveq #0,d1 move.l #$00080000,d2 jsr gu_thexn addq.l #4,sp move.l (sp)+,a0 ; channel ID addq.w #2,sp bne.s sbfi_close moveq #ioa.sown,d0 ; transfer ownership trap #2 tst.l d0 beq.s sbfi_exit ; it has transferred sbfi_close jsr gu_fclos ; the job may have gone leaving the ; channel so close it if open sbfi_ok moveq #0,d0 sbfi_exit movem.l (sp)+,sbfi.reg rts sbfi_nf moveq #err.fdnf,d0 bra sbfi_exit end
/* * Copyright 2012, The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include "bcc/Assert.h" #include "bcc/Config/Config.h" #include "bcc/Renderscript/RSTransforms.h" #include "bcc/Renderscript/RSUtils.h" #include "bcc/Support/Log.h" #include "bcinfo/MetadataExtractor.h" #include "rsDefines.h" #include <cstdlib> #include <vector> #include <llvm/IR/DerivedTypes.h> #include <llvm/IR/Function.h> #include <llvm/IR/Instructions.h> #include <llvm/IR/IRBuilder.h> #include <llvm/IR/Module.h> #include <llvm/Pass.h> #include <llvm/Support/raw_ostream.h> #include <llvm/IR/Type.h> using namespace bcc; namespace { /* RSEmbedInfoPass - This pass operates on the entire module and embeds a * string constaining relevant metadata directly as a global variable. * This information does not need to be consistent across Android releases, * because the standalone compiler + compatibility driver or system driver * will be using the same format (i.e. bcc_compat + libRSSupport.so or * bcc + libRSCpuRef are always paired together for installation). */ class RSEmbedInfoPass : public llvm::ModulePass { private: static char ID; llvm::Module *M; llvm::LLVMContext *C; public: RSEmbedInfoPass() : ModulePass(ID), M(nullptr) { } virtual void getAnalysisUsage(llvm::AnalysisUsage &AU) const override { AU.setPreservesAll(); } static std::string getRSInfoString(const llvm::Module *module) { std::string str; llvm::raw_string_ostream s(str); bcinfo::MetadataExtractor me(module); if (!me.extract()) { bccAssert(false && "Could not extract RS metadata for module!"); return std::string(""); } size_t exportVarCount = me.getExportVarCount(); size_t exportFuncCount = me.getExportFuncCount(); size_t exportForEachCount = me.getExportForEachSignatureCount(); size_t exportReduceCount = me.getExportReduceCount(); size_t objectSlotCount = me.getObjectSlotCount(); size_t pragmaCount = me.getPragmaCount(); const char **exportVarNameList = me.getExportVarNameList(); const char **exportFuncNameList = me.getExportFuncNameList(); const char **exportForEachNameList = me.getExportForEachNameList(); const uint32_t *exportForEachSignatureList = me.getExportForEachSignatureList(); const bcinfo::MetadataExtractor::Reduce *exportReduceList = me.getExportReduceList(); const uint32_t *objectSlotList = me.getObjectSlotList(); const char **pragmaKeyList = me.getPragmaKeyList(); const char **pragmaValueList = me.getPragmaValueList(); bool isThreadable = me.isThreadable(); const char *buildChecksum = me.getBuildChecksum(); size_t i; // We use a simple text format here that the compatibility library // can easily parse. Each section starts out with its name // followed by a count. The count denotes the number of lines to // parse for that particular category. Variables and Functions // merely put the appropriate identifier on the line. ForEach // kernels have the encoded int signature, followed by a hyphen // followed by the identifier (function to look up). General // reduce kernels have the encoded int signature, followed by a // hyphen followed by the accumulator data size, followed by a // hyphen followed by the identifier (reduction name); and then // for each possible constituent function, a hyphen followed by // the identifier (function name) -- in the case where the // function is omitted, "." is used in place of the identifier. // Object Slots are just listed as one integer per line. s << "exportVarCount: " << exportVarCount << "\n"; for (i = 0; i < exportVarCount; ++i) { s << exportVarNameList[i] << "\n"; } s << "exportFuncCount: " << exportFuncCount << "\n"; for (i = 0; i < exportFuncCount; ++i) { s << exportFuncNameList[i] << "\n"; } s << "exportForEachCount: " << exportForEachCount << "\n"; for (i = 0; i < exportForEachCount; ++i) { s << exportForEachSignatureList[i] << " - " << exportForEachNameList[i] << "\n"; } s << "exportReduceCount: " << exportReduceCount << "\n"; auto reduceFnName = [](const char *Name) { return Name ? Name : "."; }; for (i = 0; i < exportReduceCount; ++i) { const bcinfo::MetadataExtractor::Reduce &reduce = exportReduceList[i]; s << reduce.mSignature << " - " << reduce.mAccumulatorDataSize << " - " << reduce.mReduceName << " - " << reduceFnName(reduce.mInitializerName) << " - " << reduceFnName(reduce.mAccumulatorName) << " - " << ((reduce.mCombinerName != nullptr) ? reduce.mCombinerName : nameReduceCombinerFromAccumulator(reduce.mAccumulatorName)) << " - " << reduceFnName(reduce.mOutConverterName) << " - " << reduceFnName(reduce.mHalterName) << "\n"; } s << "objectSlotCount: " << objectSlotCount << "\n"; for (i = 0; i < objectSlotCount; ++i) { s << objectSlotList[i] << "\n"; } s << "pragmaCount: " << pragmaCount << "\n"; for (i = 0; i < pragmaCount; ++i) { s << pragmaKeyList[i] << " - " << pragmaValueList[i] << "\n"; } s << "isThreadable: " << ((isThreadable) ? "yes" : "no") << "\n"; if (buildChecksum != nullptr && buildChecksum[0]) { s << "buildChecksum: " << buildChecksum << "\n"; } s.flush(); return str; } virtual bool runOnModule(llvm::Module &M) { this->M = &M; C = &M.getContext(); // Embed this as the global variable .rs.info so that it will be // accessible from the shared object later. llvm::Constant *Init = llvm::ConstantDataArray::getString(*C, getRSInfoString(&M)); llvm::GlobalVariable *InfoGV = new llvm::GlobalVariable(M, Init->getType(), true, llvm::GlobalValue::ExternalLinkage, Init, kRsInfo); (void) InfoGV; return true; } virtual const char *getPassName() const { return "Embed Renderscript Info"; } }; // end RSEmbedInfoPass } // end anonymous namespace char RSEmbedInfoPass::ID = 0; namespace bcc { llvm::ModulePass * createRSEmbedInfoPass() { return new RSEmbedInfoPass(); } } // end namespace bcc
dnl AMD64 mpn_mul_basecase optimised for Intel Sandy bridge and Ivy bridge. dnl Contributed to the GNU project by Torbjörn Granlund. dnl Copyright 2003-2005, 2007, 2008, 2011-2013 Free Software Foundation, Inc. dnl This file is part of the GNU MP Library. dnl dnl The GNU MP Library is free software; you can redistribute it and/or modify dnl it under the terms of either: dnl dnl * the GNU Lesser General Public License as published by the Free dnl Software Foundation; either version 3 of the License, or (at your dnl option) any later version. dnl dnl or dnl dnl * the GNU General Public License as published by the Free Software dnl Foundation; either version 2 of the License, or (at your option) any dnl later version. dnl dnl or both in parallel, as here. dnl dnl The GNU MP Library is distributed in the hope that it will be useful, but dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License dnl for more details. dnl dnl You should have received copies of the GNU General Public License and the dnl GNU Lesser General Public License along with the GNU MP Library. If not, dnl see https://www.gnu.org/licenses/. include(`../config.m4') C cycles/limb mul_1 mul_2 mul_3 addmul_2 C AMD K8,K9 C AMD K10 C AMD bull C AMD pile C AMD steam C AMD bobcat C AMD jaguar C Intel P4 C Intel core C Intel NHM C Intel SBR 2.5 2.5 - 2.95 C Intel IBR 2.4 2.3 - 2.68 C Intel HWL 2.35 2.0 - 2.5 C Intel BWL C Intel atom C VIA nano C The inner loops of this code are the result of running a code generation and C optimisation tool suite written by David Harvey and Torbjorn Granlund. C TODO C * Fix the addmul_2 fluctuation affecting SBR. C * Improve feed-in code, avoiding zeroing of many registers and dummy adds in C the loops at the expense of code size. C * Adjoin a mul_3, avoiding slow mul_1 for odd vn. C * Consider replacing the 2-way mul_2 code with 4-way code, for a very slight C speedup. C * Further micro-optimise. C When playing with pointers, set this to $2 to fall back to conservative C indexing in wind-down code. define(`I',`$1') define(`rp', `%rdi') define(`up', `%rsi') define(`un_param',`%rdx') define(`vp', `%rcx') define(`vn', `%r8') define(`un', `%rbx') define(`w0', `%r10') define(`w1', `%r11') define(`w2', `%r12') define(`w3', `%r13') define(`n', `%rbp') define(`v0', `%r9') ABI_SUPPORT(DOS64) ABI_SUPPORT(STD64) ASM_START() TEXT ALIGN(16) PROLOGUE(mpn_mul_basecase) FUNC_ENTRY(4) IFDOS(` mov 56(%rsp), %r8d ') push %rbx push %rbp mov un_param, un C free up rdx neg un mov (up), %rax C shared for mul_1 and mul_2 lea (up,un_param,8), up C point at operand end lea (rp,un_param,8), rp C point at rp[un-1] mov (vp), v0 C shared for mul_1 and mul_2 mul v0 C shared for mul_1 and mul_2 test $1, R8(vn) jz L(do_mul_2) L(do_mul_1): test $1, R8(un) jnz L(m1x1) L(m1x0):mov %rax, w0 C un = 2, 4, 6, 8, ... mov %rdx, w1 mov 8(up,un,8), %rax test $2, R8(un) jnz L(m110) L(m100):lea 2(un), n C un = 4, 8, 12, ... jmp L(m1l0) L(m110):lea (un), n C un = 2, 6, 10, ... jmp L(m1l2) L(m1x1):mov %rax, w1 C un = 1, 3, 5, 7, ... mov %rdx, w0 test $2, R8(un) jz L(m111) L(m101):lea 3(un), n C un = 1, 5, 9, ... test n, n js L(m1l1) mov %rax, -8(rp) mov %rdx, (rp) pop %rbp pop %rbx FUNC_EXIT() ret L(m111):lea 1(un), n C un = 3, 7, 11, ... mov 8(up,un,8), %rax jmp L(m1l3) ALIGN(16) C FIXME L(m1tp):mov %rdx, w0 add %rax, w1 L(m1l1):mov -16(up,n,8), %rax adc $0, w0 mul v0 add %rax, w0 mov w1, -24(rp,n,8) mov -8(up,n,8), %rax mov %rdx, w1 adc $0, w1 L(m1l0):mul v0 mov w0, -16(rp,n,8) add %rax, w1 mov %rdx, w0 mov (up,n,8), %rax adc $0, w0 L(m1l3):mul v0 mov w1, -8(rp,n,8) mov %rdx, w1 add %rax, w0 mov 8(up,n,8), %rax adc $0, w1 L(m1l2):mul v0 mov w0, (rp,n,8) add $4, n jnc L(m1tp) L(m1ed):add %rax, w1 adc $0, %rdx mov w1, I(-8(rp),-24(rp,n,8)) mov %rdx, I((rp),-16(rp,n,8)) dec R32(vn) jz L(ret2) lea 8(vp), vp lea 8(rp), rp push %r12 push %r13 push %r14 jmp L(do_addmul) L(do_mul_2): define(`v1', `%r14') push %r12 push %r13 push %r14 mov 8(vp), v1 test $1, R8(un) jnz L(m2b1) L(m2b0):lea (un), n xor w0, w0 mov %rax, w2 mov %rdx, w1 jmp L(m2l0) L(m2b1):lea 1(un), n xor w1, w1 xor w2, w2 mov %rax, w0 mov %rdx, w3 jmp L(m2l1) ALIGN(32) L(m2tp):mul v0 add %rax, w0 mov %rdx, w3 adc $0, w3 L(m2l1):mov -8(up,n,8), %rax mul v1 add w1, w0 adc $0, w3 add %rax, w2 mov w0, -8(rp,n,8) mov %rdx, w0 adc $0, w0 mov (up,n,8), %rax mul v0 add %rax, w2 mov %rdx, w1 adc $0, w1 add w3, w2 L(m2l0):mov (up,n,8), %rax adc $0, w1 mul v1 mov w2, (rp,n,8) add %rax, w0 mov %rdx, w2 mov 8(up,n,8), %rax adc $0, w2 add $2, n jnc L(m2tp) L(m2ed):mul v0 add %rax, w0 mov %rdx, w3 adc $0, w3 mov I(-8(up),-8(up,n,8)), %rax mul v1 add w1, w0 adc $0, w3 add %rax, w2 mov w0, I(-8(rp),-8(rp,n,8)) adc $0, %rdx add w3, w2 mov w2, I((rp),(rp,n,8)) adc $0, %rdx mov %rdx, I(8(rp),8(rp,n,8)) add $-2, R32(vn) jz L(ret5) lea 16(vp), vp lea 16(rp), rp L(do_addmul): push %r15 push vn C save vn in new stack slot define(`vn', `(%rsp)') define(`X0', `%r14') define(`X1', `%r15') define(`v1', `%r8') L(outer): mov (vp), v0 mov 8(vp), v1 mov (up,un,8), %rax mul v0 test $1, R8(un) jnz L(a1x1) L(a1x0):mov (rp,un,8), X0 xor w0, w0 mov %rdx, w1 test $2, R8(un) jnz L(a110) L(a100):lea 2(un), n C un = 4, 8, 12, ... add %rax, X0 adc $0, w1 mov (up,un,8), %rax mul v1 mov 8(rp,un,8), X1 C FIXME: Use un jmp L(lo0) L(a110):lea (un), n C un = 2, 6, 10, ... xor w3, w3 jmp L(lo2) L(a1x1):mov (rp,un,8), X1 xor w2, w2 xor w1, w1 test $2, R8(un) jz L(a111) L(a101):lea 3(un), n C un = 1, 5, 9, ... mov %rdx, w3 add %rax, X1 mov (up,un,8), %rax mov 8(rp,un,8), X0 adc $0, w3 jmp L(top) L(a111):lea 1(un), n C un = 3, 7, 11, ... jmp L(lo3) ALIGN(32) L(top): mul v1 mov %rdx, w0 add %rax, X0 adc $0, w0 add w1, X1 adc $0, w3 add w2, X0 adc $0, w0 mov -16(up,n,8), %rax mul v0 add %rax, X0 mov %rdx, w1 adc $0, w1 mov -16(up,n,8), %rax mul v1 mov X1, -24(rp,n,8) mov -8(rp,n,8), X1 add w3, X0 adc $0, w1 L(lo0): mov %rdx, w2 mov X0, -16(rp,n,8) add %rax, X1 adc $0, w2 mov -8(up,n,8), %rax add w0, X1 adc $0, w2 mul v0 L(lo3): add %rax, X1 mov %rdx, w3 adc $0, w3 mov -8(up,n,8), %rax mul v1 add w1, X1 mov (rp,n,8), X0 adc $0, w3 mov %rdx, w0 add %rax, X0 adc $0, w0 mov (up,n,8), %rax mul v0 add w2, X0 mov X1, -8(rp,n,8) mov %rdx, w1 adc $0, w0 L(lo2): add %rax, X0 adc $0, w1 mov (up,n,8), %rax add w3, X0 adc $0, w1 mul v1 mov 8(rp,n,8), X1 add %rax, X1 mov %rdx, w2 adc $0, w2 mov 8(up,n,8), %rax mov X0, (rp,n,8) mul v0 add w0, X1 mov %rdx, w3 adc $0, w2 add %rax, X1 mov 8(up,n,8), %rax mov 16(rp,n,8), X0 C useless but harmless in final iter adc $0, w3 add $4, n jnc L(top) L(end): mul v1 add w1, X1 adc $0, w3 add w2, %rax adc $0, %rdx mov X1, I(-8(rp),-24(rp,n,8)) add w3, %rax adc $0, %rdx mov %rax, I((rp),-16(rp,n,8)) mov %rdx, I(8(rp),-8(rp,n,8)) addl $-2, vn lea 16(vp), vp lea 16(rp), rp jnz L(outer) pop %rax C deallocate vn slot pop %r15 L(ret5):pop %r14 pop %r13 pop %r12 L(ret2):pop %rbp pop %rbx FUNC_EXIT() ret EPILOGUE()
SFX_Headers_2:: db $ff, $ff, $ff ; padding SFX_Noise_Instrument01_2:: audio_header SFX_Noise_Instrument01_2, Ch8 SFX_Noise_Instrument02_2:: audio_header SFX_Noise_Instrument02_2, Ch8 SFX_Noise_Instrument03_2:: audio_header SFX_Noise_Instrument03_2, Ch8 SFX_Noise_Instrument04_2:: audio_header SFX_Noise_Instrument04_2, Ch8 SFX_Noise_Instrument05_2:: audio_header SFX_Noise_Instrument05_2, Ch8 SFX_Noise_Instrument06_2:: audio_header SFX_Noise_Instrument06_2, Ch8 SFX_Noise_Instrument07_2:: audio_header SFX_Noise_Instrument07_2, Ch8 SFX_Noise_Instrument08_2:: audio_header SFX_Noise_Instrument08_2, Ch8 SFX_Noise_Instrument09_2:: audio_header SFX_Noise_Instrument09_2, Ch8 SFX_Noise_Instrument10_2:: audio_header SFX_Noise_Instrument10_2, Ch8 SFX_Noise_Instrument11_2:: audio_header SFX_Noise_Instrument11_2, Ch8 SFX_Noise_Instrument12_2:: audio_header SFX_Noise_Instrument12_2, Ch8 SFX_Noise_Instrument13_2:: audio_header SFX_Noise_Instrument13_2, Ch8 SFX_Noise_Instrument14_2:: audio_header SFX_Noise_Instrument14_2, Ch8 SFX_Noise_Instrument15_2:: audio_header SFX_Noise_Instrument15_2, Ch8 SFX_Noise_Instrument16_2:: audio_header SFX_Noise_Instrument16_2, Ch8 SFX_Noise_Instrument17_2:: audio_header SFX_Noise_Instrument17_2, Ch8 SFX_Noise_Instrument18_2:: audio_header SFX_Noise_Instrument18_2, Ch8 SFX_Noise_Instrument19_2:: audio_header SFX_Noise_Instrument19_2, Ch8 SFX_Cry00_2:: audio_header SFX_Cry00_2, Ch5, Ch6, Ch8 SFX_Cry01_2:: audio_header SFX_Cry01_2, Ch5, Ch6, Ch8 SFX_Cry02_2:: audio_header SFX_Cry02_2, Ch5, Ch6, Ch8 SFX_Cry03_2:: audio_header SFX_Cry03_2, Ch5, Ch6, Ch8 SFX_Cry04_2:: audio_header SFX_Cry04_2, Ch5, Ch6, Ch8 SFX_Cry05_2:: audio_header SFX_Cry05_2, Ch5, Ch6, Ch8 SFX_Cry06_2:: audio_header SFX_Cry06_2, Ch5, Ch6, Ch8 SFX_Cry07_2:: audio_header SFX_Cry07_2, Ch5, Ch6, Ch8 SFX_Cry08_2:: audio_header SFX_Cry08_2, Ch5, Ch6, Ch8 SFX_Cry09_2:: audio_header SFX_Cry09_2, Ch5, Ch6, Ch8 SFX_Cry0A_2:: audio_header SFX_Cry0A_2, Ch5, Ch6, Ch8 SFX_Cry0B_2:: audio_header SFX_Cry0B_2, Ch5, Ch6, Ch8 SFX_Cry0C_2:: audio_header SFX_Cry0C_2, Ch5, Ch6, Ch8 SFX_Cry0D_2:: audio_header SFX_Cry0D_2, Ch5, Ch6, Ch8 SFX_Cry0E_2:: audio_header SFX_Cry0E_2, Ch5, Ch6, Ch8 SFX_Cry0F_2:: audio_header SFX_Cry0F_2, Ch5, Ch6, Ch8 SFX_Cry10_2:: audio_header SFX_Cry10_2, Ch5, Ch6, Ch8 SFX_Cry11_2:: audio_header SFX_Cry11_2, Ch5, Ch6, Ch8 SFX_Cry12_2:: audio_header SFX_Cry12_2, Ch5, Ch6, Ch8 SFX_Cry13_2:: audio_header SFX_Cry13_2, Ch5, Ch6, Ch8 SFX_Cry14_2:: audio_header SFX_Cry14_2, Ch5, Ch6, Ch8 SFX_Cry15_2:: audio_header SFX_Cry15_2, Ch5, Ch6, Ch8 SFX_Cry16_2:: audio_header SFX_Cry16_2, Ch5, Ch6, Ch8 SFX_Cry17_2:: audio_header SFX_Cry17_2, Ch5, Ch6, Ch8 SFX_Cry18_2:: audio_header SFX_Cry18_2, Ch5, Ch6, Ch8 SFX_Cry19_2:: audio_header SFX_Cry19_2, Ch5, Ch6, Ch8 SFX_Cry1A_2:: audio_header SFX_Cry1A_2, Ch5, Ch6, Ch8 SFX_Cry1B_2:: audio_header SFX_Cry1B_2, Ch5, Ch6, Ch8 SFX_Cry1C_2:: audio_header SFX_Cry1C_2, Ch5, Ch6, Ch8 SFX_Cry1D_2:: audio_header SFX_Cry1D_2, Ch5, Ch6, Ch8 SFX_Cry1E_2:: audio_header SFX_Cry1E_2, Ch5, Ch6, Ch8 SFX_Cry1F_2:: audio_header SFX_Cry1F_2, Ch5, Ch6, Ch8 SFX_Cry20_2:: audio_header SFX_Cry20_2, Ch5, Ch6, Ch8 SFX_Cry21_2:: audio_header SFX_Cry21_2, Ch5, Ch6, Ch8 SFX_Cry22_2:: audio_header SFX_Cry22_2, Ch5, Ch6, Ch8 SFX_Cry23_2:: audio_header SFX_Cry23_2, Ch5, Ch6, Ch8 SFX_Cry24_2:: audio_header SFX_Cry24_2, Ch5, Ch6, Ch8 SFX_Cry25_2:: audio_header SFX_Cry25_2, Ch5, Ch6, Ch8 SFX_Level_Up:: audio_header SFX_Level_Up, Ch5, Ch6, Ch7 SFX_Get_Item2_2:: audio_header SFX_Get_Item2_2, Ch5, Ch6, Ch7 SFX_Tink_2:: audio_header SFX_Tink_2, Ch5 SFX_Heal_HP_2:: audio_header SFX_Heal_HP_2, Ch5 SFX_Heal_Ailment_2:: audio_header SFX_Heal_Ailment_2, Ch5 SFX_Start_Menu_2:: audio_header SFX_Start_Menu_2, Ch8 SFX_Press_AB_2:: audio_header SFX_Press_AB_2, Ch5 SFX_Ball_Toss:: audio_header SFX_Ball_Toss, Ch5, Ch6 SFX_Ball_Poof:: audio_header SFX_Ball_Poof, Ch5, Ch8 SFX_Faint_Thud:: audio_header SFX_Faint_Thud, Ch5, Ch8 SFX_Run:: audio_header SFX_Run, Ch8 SFX_Dex_Page_Added:: audio_header SFX_Dex_Page_Added, Ch5, Ch6 SFX_Caught_Mon:: audio_header SFX_Caught_Mon, Ch5, Ch6, Ch7 SFX_Peck:: audio_header SFX_Peck, Ch8 SFX_Faint_Fall:: audio_header SFX_Faint_Fall, Ch5 SFX_Battle_09:: audio_header SFX_Battle_09, Ch5 SFX_Pound:: audio_header SFX_Pound, Ch8 SFX_Battle_0B:: audio_header SFX_Battle_0B, Ch8 SFX_Battle_0C:: audio_header SFX_Battle_0C, Ch8 SFX_Battle_0D:: audio_header SFX_Battle_0D, Ch8 SFX_Battle_0E:: audio_header SFX_Battle_0E, Ch8 SFX_Battle_0F:: audio_header SFX_Battle_0F, Ch8 SFX_Damage:: audio_header SFX_Damage, Ch8 SFX_Not_Very_Effective:: audio_header SFX_Not_Very_Effective, Ch8 SFX_Battle_12:: audio_header SFX_Battle_12, Ch8 SFX_Battle_13:: audio_header SFX_Battle_13, Ch8 SFX_Battle_14:: audio_header SFX_Battle_14, Ch8 SFX_Vine_Whip:: audio_header SFX_Vine_Whip, Ch8 SFX_Battle_16:: audio_header SFX_Battle_16, Ch8 SFX_Battle_17:: audio_header SFX_Battle_17, Ch8 SFX_Battle_18:: audio_header SFX_Battle_18, Ch8 SFX_Battle_19:: audio_header SFX_Battle_19, Ch8 SFX_Super_Effective:: audio_header SFX_Super_Effective, Ch8 SFX_Battle_1B:: audio_header SFX_Battle_1B, Ch8 SFX_Battle_1C:: audio_header SFX_Battle_1C, Ch8 SFX_Doubleslap:: audio_header SFX_Doubleslap, Ch8 SFX_Battle_1E:: audio_header SFX_Battle_1E, Ch5, Ch8 SFX_Horn_Drill:: audio_header SFX_Horn_Drill, Ch8 SFX_Battle_20:: audio_header SFX_Battle_20, Ch8 SFX_Battle_21:: audio_header SFX_Battle_21, Ch8 SFX_Battle_22:: audio_header SFX_Battle_22, Ch8 SFX_Battle_23:: audio_header SFX_Battle_23, Ch8 SFX_Battle_24:: audio_header SFX_Battle_24, Ch5, Ch8 SFX_Battle_25:: audio_header SFX_Battle_25, Ch8 SFX_Battle_26:: audio_header SFX_Battle_26, Ch8 SFX_Battle_27:: audio_header SFX_Battle_27, Ch5, Ch6, Ch8 SFX_Battle_28:: audio_header SFX_Battle_28, Ch5, Ch6, Ch8 SFX_Battle_29:: audio_header SFX_Battle_29, Ch5, Ch8 SFX_Battle_2A:: audio_header SFX_Battle_2A, Ch5, Ch6, Ch8 SFX_Battle_2B:: audio_header SFX_Battle_2B, Ch5, Ch8 SFX_Battle_2C:: audio_header SFX_Battle_2C, Ch5, Ch6, Ch8 SFX_Psybeam:: audio_header SFX_Psybeam, Ch5, Ch6, Ch8 SFX_Battle_2E:: audio_header SFX_Battle_2E, Ch5, Ch6, Ch8 SFX_Battle_2F:: audio_header SFX_Battle_2F, Ch5, Ch6, Ch8 SFX_Psychic_M:: audio_header SFX_Psychic_M, Ch5, Ch6, Ch8 SFX_Battle_31:: audio_header SFX_Battle_31, Ch5, Ch6 SFX_Battle_32:: audio_header SFX_Battle_32, Ch5, Ch6 SFX_Battle_33:: audio_header SFX_Battle_33, Ch5, Ch6 SFX_Battle_34:: audio_header SFX_Battle_34, Ch5, Ch6, Ch8 SFX_Battle_35:: audio_header SFX_Battle_35, Ch5, Ch6 SFX_Battle_36:: audio_header SFX_Battle_36, Ch5, Ch6, Ch8 SFX_Silph_Scope:: audio_header SFX_Silph_Scope, Ch5
db "PUSHPIN@" ; species name db "Believed to be" next "an omen of woe" next "and misfortune." page "Removing its pin" next "will unleash its" next "dark powers.@"
// Copyright (C) 2018-2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include "telemetry.hpp" #include <common/telemetry_extension.hpp> #include "utils.hpp" using namespace ov::frontend; std::string FrontEndTelemetryTest::getTestCaseName(const testing::TestParamInfo<TelemetryFEParam>& obj) { std::string res = obj.param.m_frontEndName + "_" + obj.param.m_modelName; return FrontEndTestUtils::fileToTestName(res); } void FrontEndTelemetryTest::SetUp() { FrontEndTestUtils::setupTestEnv(); m_fem = FrontEndManager(); // re-initialize after setting up environment initParamTest(); } void FrontEndTelemetryTest::initParamTest() { m_param = GetParam(); m_param.m_modelName = FrontEndTestUtils::make_model_path(m_param.m_modelsPath + m_param.m_modelName); } /////////////////////////////////////////////////////////////////// TEST_P(FrontEndTelemetryTest, TestTelemetryMock) { std::shared_ptr<ov::Function> function; { using namespace std::placeholders; ov::frontend::FrontEnd::Ptr m_frontEnd; ov::frontend::InputModel::Ptr m_inputModel; m_frontEnd = m_fem.load_by_framework(m_param.m_frontEndName); std::string category = "mo"; auto telemetry_extension = std::make_shared<TelemetryExtension>( category, std::bind(&TelemetryMock::send_event, &m_test_telemetry, _1, _2, _3, _4), std::bind(&TelemetryMock::send_error, &m_test_telemetry, _1, _2), std::bind(&TelemetryMock::send_stack_trace, &m_test_telemetry, _1, _2)); std::string action = "test_action"; std::string msg = "test_msg"; int version = 2; EXPECT_NO_THROW(telemetry_extension->send_event(action, msg, version)); EXPECT_NO_THROW(telemetry_extension->send_error(msg)); EXPECT_NO_THROW(telemetry_extension->send_stack_trace(msg)); EXPECT_EQ(m_test_telemetry.m_event_cnt, 1); EXPECT_EQ(m_test_telemetry.m_error_cnt, 1); EXPECT_EQ(m_test_telemetry.m_trace_cnt, 1); auto expected_res = std::set<std::tuple<std::string, std::string, std::string, int>>{ std::make_tuple(category, action, msg, version)}; EXPECT_EQ(m_test_telemetry.m_received_events, expected_res); EXPECT_EQ(m_test_telemetry.m_last_error, std::make_tuple(category, msg)); EXPECT_EQ(m_test_telemetry.m_last_trace, std::make_tuple(category, msg)); m_test_telemetry.clear(); EXPECT_NO_THROW(m_frontEnd->add_extension(telemetry_extension)); m_inputModel = m_frontEnd->load(m_param.m_modelName); function = m_frontEnd->convert(m_inputModel); EXPECT_EQ(m_test_telemetry.m_event_cnt, m_param.m_expected_events.size()); EXPECT_EQ(m_test_telemetry.m_received_events, m_param.m_expected_events); EXPECT_EQ(m_test_telemetry.m_trace_cnt, 0); EXPECT_EQ(m_test_telemetry.m_error_cnt, 0); m_test_telemetry.clear(); EXPECT_NO_THROW(m_frontEnd->add_extension(telemetry_extension)); m_inputModel = m_frontEnd->load(m_param.m_modelName); function = m_frontEnd->decode(m_inputModel); EXPECT_EQ(m_test_telemetry.m_event_cnt, m_param.m_expected_events.size()); EXPECT_EQ(m_test_telemetry.m_received_events, m_param.m_expected_events); EXPECT_EQ(m_test_telemetry.m_trace_cnt, 0); EXPECT_EQ(m_test_telemetry.m_error_cnt, 0); } }
// // Copyright 2018 gRPC authors. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // #include <grpc/support/port_platform.h> #include <inttypes.h> #include <limits.h> #include <string.h> #include "absl/container/inlined_vector.h" #include "absl/strings/match.h" #include "absl/strings/numbers.h" #include "absl/strings/str_cat.h" #include "absl/strings/str_join.h" #include "absl/strings/str_split.h" #include "absl/strings/string_view.h" #include "re2/re2.h" #include <grpc/grpc.h> #include "src/core/ext/filters/client_channel/lb_policy.h" #include "src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h" #include "src/core/ext/filters/client_channel/lb_policy_factory.h" #include "src/core/ext/filters/client_channel/lb_policy_registry.h" #include "src/core/ext/filters/client_channel/resolver/xds/xds_resolver.h" #include "src/core/ext/xds/xds_api.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/gpr/string.h" #include "src/core/lib/gprpp/orphanable.h" #include "src/core/lib/gprpp/ref_counted_ptr.h" #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/iomgr/work_serializer.h" #include "src/core/lib/transport/error_utils.h" #define GRPC_XDS_CLUSTER_MANAGER_CHILD_RETENTION_INTERVAL_MS (15 * 60 * 1000) namespace grpc_core { TraceFlag grpc_xds_cluster_manager_lb_trace(false, "xds_cluster_manager_lb"); namespace { constexpr char kXdsClusterManager[] = "xds_cluster_manager_experimental"; // Config for xds_cluster_manager LB policy. class XdsClusterManagerLbConfig : public LoadBalancingPolicy::Config { public: using ClusterMap = std::map<std::string, RefCountedPtr<LoadBalancingPolicy::Config>>; XdsClusterManagerLbConfig(ClusterMap cluster_map) : cluster_map_(std::move(cluster_map)) {} const char* name() const override { return kXdsClusterManager; } const ClusterMap& cluster_map() const { return cluster_map_; } private: ClusterMap cluster_map_; }; // xds_cluster_manager LB policy. class XdsClusterManagerLb : public LoadBalancingPolicy { public: explicit XdsClusterManagerLb(Args args); const char* name() const override { return kXdsClusterManager; } void UpdateLocked(UpdateArgs args) override; void ExitIdleLocked() override; void ResetBackoffLocked() override; private: // A simple wrapper for ref-counting a picker from the child policy. class ChildPickerWrapper : public RefCounted<ChildPickerWrapper> { public: ChildPickerWrapper(std::string name, std::unique_ptr<SubchannelPicker> picker) : name_(std::move(name)), picker_(std::move(picker)) {} PickResult Pick(PickArgs args) { return picker_->Pick(args); } const std::string& name() const { return name_; } private: std::string name_; std::unique_ptr<SubchannelPicker> picker_; }; // Picks a child using prefix or path matching and then delegates to that // child's picker. class ClusterPicker : public SubchannelPicker { public: // Maintains a map of cluster names to pickers. using ClusterMap = std::map<absl::string_view /*cluster_name*/, RefCountedPtr<ChildPickerWrapper>>; // It is required that the keys of cluster_map have to live at least as long // as the ClusterPicker instance. ClusterPicker(ClusterMap cluster_map, RefCountedPtr<XdsClusterManagerLbConfig> config) : cluster_map_(std::move(cluster_map)), config_(std::move(config)) {} PickResult Pick(PickArgs args) override; private: ClusterMap cluster_map_; // Take a reference to config so that we can use // XdsApi::RdsUpdate::RdsRoute::Matchers from it. RefCountedPtr<XdsClusterManagerLbConfig> config_; }; // Each ClusterChild holds a ref to its parent XdsClusterManagerLb. class ClusterChild : public InternallyRefCounted<ClusterChild> { public: ClusterChild(RefCountedPtr<XdsClusterManagerLb> xds_cluster_manager_policy, const std::string& name); ~ClusterChild(); void Orphan() override; void UpdateLocked(RefCountedPtr<LoadBalancingPolicy::Config> config, const ServerAddressList& addresses, const grpc_channel_args* args); void ExitIdleLocked(); void ResetBackoffLocked(); void DeactivateLocked(); grpc_connectivity_state connectivity_state() const { return connectivity_state_; } RefCountedPtr<ChildPickerWrapper> picker_wrapper() const { return picker_wrapper_; } private: class Helper : public ChannelControlHelper { public: explicit Helper(RefCountedPtr<ClusterChild> xds_cluster_manager_child) : xds_cluster_manager_child_(std::move(xds_cluster_manager_child)) {} ~Helper() { xds_cluster_manager_child_.reset(DEBUG_LOCATION, "Helper"); } RefCountedPtr<SubchannelInterface> CreateSubchannel( const grpc_channel_args& args) override; void UpdateState(grpc_connectivity_state state, const absl::Status& status, std::unique_ptr<SubchannelPicker> picker) override; void RequestReresolution() override; void AddTraceEvent(TraceSeverity severity, absl::string_view message) override; private: RefCountedPtr<ClusterChild> xds_cluster_manager_child_; }; // Methods for dealing with the child policy. OrphanablePtr<LoadBalancingPolicy> CreateChildPolicyLocked( const grpc_channel_args* args); static void OnDelayedRemovalTimer(void* arg, grpc_error* error); void OnDelayedRemovalTimerLocked(grpc_error* error); // The owning LB policy. RefCountedPtr<XdsClusterManagerLb> xds_cluster_manager_policy_; // Points to the corresponding key in children map. const std::string name_; OrphanablePtr<LoadBalancingPolicy> child_policy_; RefCountedPtr<ChildPickerWrapper> picker_wrapper_; grpc_connectivity_state connectivity_state_ = GRPC_CHANNEL_IDLE; bool seen_failure_since_ready_ = false; // States for delayed removal. grpc_timer delayed_removal_timer_; grpc_closure on_delayed_removal_timer_; bool delayed_removal_timer_callback_pending_ = false; bool shutdown_ = false; }; ~XdsClusterManagerLb(); void ShutdownLocked() override; void UpdateStateLocked(); // Current config from the resolver. RefCountedPtr<XdsClusterManagerLbConfig> config_; // Internal state. bool shutting_down_ = false; // Children. std::map<std::string, OrphanablePtr<ClusterChild>> children_; }; // // XdsClusterManagerLb::ClusterPicker // XdsClusterManagerLb::PickResult XdsClusterManagerLb::ClusterPicker::Pick( PickArgs args) { auto cluster_name = args.call_state->ExperimentalGetCallAttribute(kXdsClusterAttribute); auto it = cluster_map_.find(cluster_name); if (it != cluster_map_.end()) { return it->second->Pick(args); } PickResult result; result.type = PickResult::PICK_FAILED; result.error = grpc_error_set_int( GRPC_ERROR_CREATE_FROM_COPIED_STRING( absl::StrCat("xds cluster manager picker: unknown cluster \"", cluster_name, "\"") .c_str()), GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_INTERNAL); return result; } // // XdsClusterManagerLb // XdsClusterManagerLb::XdsClusterManagerLb(Args args) : LoadBalancingPolicy(std::move(args)) {} XdsClusterManagerLb::~XdsClusterManagerLb() { if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_cluster_manager_lb_trace)) { gpr_log( GPR_INFO, "[xds_cluster_manager_lb %p] destroying xds_cluster_manager LB policy", this); } } void XdsClusterManagerLb::ShutdownLocked() { if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_cluster_manager_lb_trace)) { gpr_log(GPR_INFO, "[xds_cluster_manager_lb %p] shutting down", this); } shutting_down_ = true; children_.clear(); } void XdsClusterManagerLb::ExitIdleLocked() { for (auto& p : children_) p.second->ExitIdleLocked(); } void XdsClusterManagerLb::ResetBackoffLocked() { for (auto& p : children_) p.second->ResetBackoffLocked(); } void XdsClusterManagerLb::UpdateLocked(UpdateArgs args) { if (shutting_down_) return; if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_cluster_manager_lb_trace)) { gpr_log(GPR_INFO, "[xds_cluster_manager_lb %p] Received update", this); } // Update config. config_ = std::move(args.config); // Deactivate the children not in the new config. for (const auto& p : children_) { const std::string& name = p.first; ClusterChild* child = p.second.get(); if (config_->cluster_map().find(name) == config_->cluster_map().end()) { child->DeactivateLocked(); } } // Add or update the children in the new config. for (const auto& p : config_->cluster_map()) { const std::string& name = p.first; const RefCountedPtr<LoadBalancingPolicy::Config>& config = p.second; auto it = children_.find(name); if (it == children_.end()) { it = children_ .emplace(name, MakeOrphanable<ClusterChild>( Ref(DEBUG_LOCATION, "ClusterChild"), name)) .first; } it->second->UpdateLocked(config, args.addresses, args.args); } UpdateStateLocked(); } void XdsClusterManagerLb::UpdateStateLocked() { // Also count the number of children in each state, to determine the // overall state. size_t num_ready = 0; size_t num_connecting = 0; size_t num_idle = 0; size_t num_transient_failures = 0; for (const auto& p : children_) { const auto& child_name = p.first; const ClusterChild* child = p.second.get(); // Skip the children that are not in the latest update. if (config_->cluster_map().find(child_name) == config_->cluster_map().end()) { continue; } switch (child->connectivity_state()) { case GRPC_CHANNEL_READY: { ++num_ready; break; } case GRPC_CHANNEL_CONNECTING: { ++num_connecting; break; } case GRPC_CHANNEL_IDLE: { ++num_idle; break; } case GRPC_CHANNEL_TRANSIENT_FAILURE: { ++num_transient_failures; break; } default: GPR_UNREACHABLE_CODE(return ); } } // Determine aggregated connectivity state. grpc_connectivity_state connectivity_state; if (num_ready > 0) { connectivity_state = GRPC_CHANNEL_READY; } else if (num_connecting > 0) { connectivity_state = GRPC_CHANNEL_CONNECTING; } else if (num_idle > 0) { connectivity_state = GRPC_CHANNEL_IDLE; } else { connectivity_state = GRPC_CHANNEL_TRANSIENT_FAILURE; } if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_cluster_manager_lb_trace)) { gpr_log(GPR_INFO, "[xds_cluster_manager_lb %p] connectivity changed to %s", this, ConnectivityStateName(connectivity_state)); } std::unique_ptr<SubchannelPicker> picker; absl::Status status; switch (connectivity_state) { case GRPC_CHANNEL_READY: { ClusterPicker::ClusterMap cluster_map; for (const auto& p : config_->cluster_map()) { const std::string& cluster_name = p.first; RefCountedPtr<ChildPickerWrapper>& child_picker = cluster_map[cluster_name]; child_picker = children_[cluster_name]->picker_wrapper(); if (child_picker == nullptr) { if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_cluster_manager_lb_trace)) { gpr_log( GPR_INFO, "[xds_cluster_manager_lb %p] child %s has not yet returned a " "picker; creating a QueuePicker.", this, cluster_name.c_str()); } child_picker = MakeRefCounted<ChildPickerWrapper>( cluster_name, absl::make_unique<QueuePicker>( Ref(DEBUG_LOCATION, "QueuePicker"))); } } picker = absl::make_unique<ClusterPicker>(std::move(cluster_map), config_); break; } case GRPC_CHANNEL_CONNECTING: case GRPC_CHANNEL_IDLE: picker = absl::make_unique<QueuePicker>(Ref(DEBUG_LOCATION, "QueuePicker")); break; default: grpc_error* error = grpc_error_set_int( GRPC_ERROR_CREATE_FROM_STATIC_STRING( "TRANSIENT_FAILURE from XdsClusterManagerLb"), GRPC_ERROR_INT_GRPC_STATUS, GRPC_STATUS_UNAVAILABLE); status = grpc_error_to_absl_status(error); picker = absl::make_unique<TransientFailurePicker>(error); } channel_control_helper()->UpdateState(connectivity_state, status, std::move(picker)); } // // XdsClusterManagerLb::ClusterChild // XdsClusterManagerLb::ClusterChild::ClusterChild( RefCountedPtr<XdsClusterManagerLb> xds_cluster_manager_policy, const std::string& name) : xds_cluster_manager_policy_(std::move(xds_cluster_manager_policy)), name_(name) { if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_cluster_manager_lb_trace)) { gpr_log(GPR_INFO, "[xds_cluster_manager_lb %p] created ClusterChild %p for %s", xds_cluster_manager_policy_.get(), this, name_.c_str()); } GRPC_CLOSURE_INIT(&on_delayed_removal_timer_, OnDelayedRemovalTimer, this, grpc_schedule_on_exec_ctx); } XdsClusterManagerLb::ClusterChild::~ClusterChild() { if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_cluster_manager_lb_trace)) { gpr_log(GPR_INFO, "[xds_cluster_manager_lb %p] ClusterChild %p: destroying " "child", xds_cluster_manager_policy_.get(), this); } xds_cluster_manager_policy_.reset(DEBUG_LOCATION, "ClusterChild"); } void XdsClusterManagerLb::ClusterChild::Orphan() { if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_cluster_manager_lb_trace)) { gpr_log(GPR_INFO, "[xds_cluster_manager_lb %p] ClusterChild %p %s: " "shutting down child", xds_cluster_manager_policy_.get(), this, name_.c_str()); } // Remove the child policy's interested_parties pollset_set from the // xDS policy. grpc_pollset_set_del_pollset_set( child_policy_->interested_parties(), xds_cluster_manager_policy_->interested_parties()); child_policy_.reset(); // Drop our ref to the child's picker, in case it's holding a ref to // the child. picker_wrapper_.reset(); if (delayed_removal_timer_callback_pending_) { grpc_timer_cancel(&delayed_removal_timer_); } shutdown_ = true; Unref(); } OrphanablePtr<LoadBalancingPolicy> XdsClusterManagerLb::ClusterChild::CreateChildPolicyLocked( const grpc_channel_args* args) { LoadBalancingPolicy::Args lb_policy_args; lb_policy_args.work_serializer = xds_cluster_manager_policy_->work_serializer(); lb_policy_args.args = args; lb_policy_args.channel_control_helper = absl::make_unique<Helper>(this->Ref(DEBUG_LOCATION, "Helper")); OrphanablePtr<LoadBalancingPolicy> lb_policy = MakeOrphanable<ChildPolicyHandler>(std::move(lb_policy_args), &grpc_xds_cluster_manager_lb_trace); if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_cluster_manager_lb_trace)) { gpr_log(GPR_INFO, "[xds_cluster_manager_lb %p] ClusterChild %p %s: Created " "new child " "policy handler %p", xds_cluster_manager_policy_.get(), this, name_.c_str(), lb_policy.get()); } // Add the xDS's interested_parties pollset_set to that of the newly created // child policy. This will make the child policy progress upon activity on // xDS LB, which in turn is tied to the application's call. grpc_pollset_set_add_pollset_set( lb_policy->interested_parties(), xds_cluster_manager_policy_->interested_parties()); return lb_policy; } void XdsClusterManagerLb::ClusterChild::UpdateLocked( RefCountedPtr<LoadBalancingPolicy::Config> config, const ServerAddressList& addresses, const grpc_channel_args* args) { if (xds_cluster_manager_policy_->shutting_down_) return; // Update child weight. // Reactivate if needed. if (delayed_removal_timer_callback_pending_) { delayed_removal_timer_callback_pending_ = false; grpc_timer_cancel(&delayed_removal_timer_); } // Create child policy if needed. if (child_policy_ == nullptr) { child_policy_ = CreateChildPolicyLocked(args); } // Construct update args. UpdateArgs update_args; update_args.config = std::move(config); update_args.addresses = addresses; update_args.args = grpc_channel_args_copy(args); // Update the policy. if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_cluster_manager_lb_trace)) { gpr_log(GPR_INFO, "[xds_cluster_manager_lb %p] ClusterChild %p %s: " "Updating child " "policy handler %p", xds_cluster_manager_policy_.get(), this, name_.c_str(), child_policy_.get()); } child_policy_->UpdateLocked(std::move(update_args)); } void XdsClusterManagerLb::ClusterChild::ExitIdleLocked() { child_policy_->ExitIdleLocked(); } void XdsClusterManagerLb::ClusterChild::ResetBackoffLocked() { child_policy_->ResetBackoffLocked(); } void XdsClusterManagerLb::ClusterChild::DeactivateLocked() { // If already deactivated, don't do that again. if (delayed_removal_timer_callback_pending_ == true) return; // Set the child weight to 0 so that future picker won't contain this child. // Start a timer to delete the child. Ref(DEBUG_LOCATION, "ClusterChild+timer").release(); grpc_timer_init(&delayed_removal_timer_, ExecCtx::Get()->Now() + GRPC_XDS_CLUSTER_MANAGER_CHILD_RETENTION_INTERVAL_MS, &on_delayed_removal_timer_); delayed_removal_timer_callback_pending_ = true; } void XdsClusterManagerLb::ClusterChild::OnDelayedRemovalTimer( void* arg, grpc_error* error) { ClusterChild* self = static_cast<ClusterChild*>(arg); GRPC_ERROR_REF(error); // Ref owned by the lambda self->xds_cluster_manager_policy_->work_serializer()->Run( [self, error]() { self->OnDelayedRemovalTimerLocked(error); }, DEBUG_LOCATION); } void XdsClusterManagerLb::ClusterChild::OnDelayedRemovalTimerLocked( grpc_error* error) { delayed_removal_timer_callback_pending_ = false; if (error == GRPC_ERROR_NONE && !shutdown_) { xds_cluster_manager_policy_->children_.erase(name_); } Unref(DEBUG_LOCATION, "ClusterChild+timer"); GRPC_ERROR_UNREF(error); } // // XdsClusterManagerLb::ClusterChild::Helper // RefCountedPtr<SubchannelInterface> XdsClusterManagerLb::ClusterChild::Helper::CreateSubchannel( const grpc_channel_args& args) { if (xds_cluster_manager_child_->xds_cluster_manager_policy_->shutting_down_) return nullptr; return xds_cluster_manager_child_->xds_cluster_manager_policy_ ->channel_control_helper() ->CreateSubchannel(args); } void XdsClusterManagerLb::ClusterChild::Helper::UpdateState( grpc_connectivity_state state, const absl::Status& status, std::unique_ptr<SubchannelPicker> picker) { if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_cluster_manager_lb_trace)) { gpr_log( GPR_INFO, "[xds_cluster_manager_lb %p] child %s: received update: state=%s (%s) " "picker=%p", xds_cluster_manager_child_->xds_cluster_manager_policy_.get(), xds_cluster_manager_child_->name_.c_str(), ConnectivityStateName(state), status.ToString().c_str(), picker.get()); } if (xds_cluster_manager_child_->xds_cluster_manager_policy_->shutting_down_) return; // Cache the picker in the ClusterChild. xds_cluster_manager_child_->picker_wrapper_ = MakeRefCounted<ChildPickerWrapper>(xds_cluster_manager_child_->name_, std::move(picker)); // Decide what state to report for aggregation purposes. // If we haven't seen a failure since the last time we were in state // READY, then we report the state change as-is. However, once we do see // a failure, we report TRANSIENT_FAILURE and ignore any subsequent state // changes until we go back into state READY. if (!xds_cluster_manager_child_->seen_failure_since_ready_) { if (state == GRPC_CHANNEL_TRANSIENT_FAILURE) { xds_cluster_manager_child_->seen_failure_since_ready_ = true; } } else { if (state != GRPC_CHANNEL_READY) return; xds_cluster_manager_child_->seen_failure_since_ready_ = false; } xds_cluster_manager_child_->connectivity_state_ = state; // Notify the LB policy. xds_cluster_manager_child_->xds_cluster_manager_policy_->UpdateStateLocked(); } void XdsClusterManagerLb::ClusterChild::Helper::RequestReresolution() { if (xds_cluster_manager_child_->xds_cluster_manager_policy_->shutting_down_) return; xds_cluster_manager_child_->xds_cluster_manager_policy_ ->channel_control_helper() ->RequestReresolution(); } void XdsClusterManagerLb::ClusterChild::Helper::AddTraceEvent( TraceSeverity severity, absl::string_view message) { if (xds_cluster_manager_child_->xds_cluster_manager_policy_->shutting_down_) return; xds_cluster_manager_child_->xds_cluster_manager_policy_ ->channel_control_helper() ->AddTraceEvent(severity, message); } // // factory // class XdsClusterManagerLbFactory : public LoadBalancingPolicyFactory { public: OrphanablePtr<LoadBalancingPolicy> CreateLoadBalancingPolicy( LoadBalancingPolicy::Args args) const override { return MakeOrphanable<XdsClusterManagerLb>(std::move(args)); } const char* name() const override { return kXdsClusterManager; } RefCountedPtr<LoadBalancingPolicy::Config> ParseLoadBalancingConfig( const Json& json, grpc_error** error) const override { GPR_DEBUG_ASSERT(error != nullptr && *error == GRPC_ERROR_NONE); if (json.type() == Json::Type::JSON_NULL) { // xds_cluster_manager was mentioned as a policy in the deprecated // loadBalancingPolicy field or in the client API. *error = GRPC_ERROR_CREATE_FROM_STATIC_STRING( "field:loadBalancingPolicy error:xds_cluster_manager policy requires " "configuration. Please use loadBalancingConfig field of service " "config instead."); return nullptr; } std::vector<grpc_error*> error_list; XdsClusterManagerLbConfig::ClusterMap cluster_map; std::set<std::string /*cluster_name*/> clusters_to_be_used; auto it = json.object_value().find("children"); if (it == json.object_value().end()) { error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING( "field:children error:required field not present")); } else if (it->second.type() != Json::Type::OBJECT) { error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING( "field:children error:type should be object")); } else { for (const auto& p : it->second.object_value()) { const std::string& child_name = p.first; if (child_name.empty()) { error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING( "field:children element error: name cannot be empty")); continue; } RefCountedPtr<LoadBalancingPolicy::Config> child_config; std::vector<grpc_error*> child_errors = ParseChildConfig(p.second, &child_config); if (!child_errors.empty()) { // Can't use GRPC_ERROR_CREATE_FROM_VECTOR() here, because the error // string is not static in this case. grpc_error* error = GRPC_ERROR_CREATE_FROM_COPIED_STRING( absl::StrCat("field:children name:", child_name).c_str()); for (grpc_error* child_error : child_errors) { error = grpc_error_add_child(error, child_error); } error_list.push_back(error); } else { cluster_map[child_name] = std::move(child_config); clusters_to_be_used.insert(child_name); } } } if (cluster_map.empty()) { error_list.push_back( GRPC_ERROR_CREATE_FROM_STATIC_STRING("no valid children configured")); } if (!error_list.empty()) { *error = GRPC_ERROR_CREATE_FROM_VECTOR( "xds_cluster_manager_experimental LB policy config", &error_list); return nullptr; } return MakeRefCounted<XdsClusterManagerLbConfig>(std::move(cluster_map)); } private: static std::vector<grpc_error*> ParseChildConfig( const Json& json, RefCountedPtr<LoadBalancingPolicy::Config>* child_config) { std::vector<grpc_error*> error_list; if (json.type() != Json::Type::OBJECT) { error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING( "value should be of type object")); return error_list; } auto it = json.object_value().find("childPolicy"); if (it == json.object_value().end()) { error_list.push_back( GRPC_ERROR_CREATE_FROM_STATIC_STRING("did not find childPolicy")); } else { grpc_error* parse_error = GRPC_ERROR_NONE; *child_config = LoadBalancingPolicyRegistry::ParseLoadBalancingConfig( it->second, &parse_error); if (*child_config == nullptr) { GPR_DEBUG_ASSERT(parse_error != GRPC_ERROR_NONE); std::vector<grpc_error*> child_errors; child_errors.push_back(parse_error); error_list.push_back( GRPC_ERROR_CREATE_FROM_VECTOR("field:childPolicy", &child_errors)); } } return error_list; } }; } // namespace } // namespace grpc_core // // Plugin registration // void grpc_lb_policy_xds_cluster_manager_init() { grpc_core::LoadBalancingPolicyRegistry::Builder:: RegisterLoadBalancingPolicyFactory( absl::make_unique<grpc_core::XdsClusterManagerLbFactory>()); } void grpc_lb_policy_xds_cluster_manager_shutdown() {}
%include "io.inc" extern printf section .data before_format db "before %s", 13, 10, 0 after_format db "after %s", 13, 10, 0 mystring db "a4bcDefgh2ij", 0 section .text global CMAIN toupper: push ebp lea ebp, [esp] ; TODO xor ebx, ebx mov ecx, [ebp + 8] change_string: mov bl, [ecx] test bl, bl jz return cmp bl, 'a' jb next_char cmp bl, 'z' ja next_char sub bl, 0x20 next_char: mov [ecx], bl inc ecx jmp change_string return: leave ret CMAIN: push ebp lea ebp, [esp] push mystring push before_format call printf add esp, 8 push mystring call toupper add esp, 4 push mystring push after_format call printf add esp, 8 leave ret
############################################################################### # Copyright 2018 Intel Corporation # All Rights Reserved. # # If this software was obtained under the Intel Simplified Software License, # the following terms apply: # # The source code, information and material ("Material") contained herein is # owned by Intel Corporation or its suppliers or licensors, and title to such # Material remains with Intel Corporation or its suppliers or licensors. The # Material contains proprietary information of Intel or its suppliers and # licensors. The Material is protected by worldwide copyright laws and treaty # provisions. No part of the Material may be used, copied, reproduced, # modified, published, uploaded, posted, transmitted, distributed or disclosed # in any way without Intel's prior express written permission. No license under # any patent, copyright or other intellectual property rights in the Material # is granted to or conferred upon you, either expressly, by implication, # inducement, estoppel or otherwise. Any license under such intellectual # property rights must be express and approved by Intel in writing. # # Unless otherwise agreed by Intel in writing, you may not remove or alter this # notice or any other notice embedded in Materials by Intel or Intel's # suppliers or licensors in any way. # # # If this software was obtained under the Apache License, Version 2.0 (the # "License"), the following terms apply: # # You may not use this file except in compliance with the License. You may # obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 # # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # # See the License for the specific language governing permissions and # limitations under the License. ############################################################################### .text .p2align 4, 0x90 Lpoly: .quad 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFF00000000, 0xFFFFFFFFFFFFFFFF, 0xFFFFFFFEFFFFFFFF LRR: .quad 0x200000003, 0x2ffffffff, 0x100000001, 0x400000002 LOne: .long 1,1,1,1,1,1,1,1 LTwo: .long 2,2,2,2,2,2,2,2 LThree: .long 3,3,3,3,3,3,3,3 .p2align 4, 0x90 .globl _sm2_mul_by_2 _sm2_mul_by_2: push %r12 push %r13 xor %r13, %r13 movq (%rsi), %r8 movq (8)(%rsi), %r9 movq (16)(%rsi), %r10 movq (24)(%rsi), %r11 shld $(1), %r11, %r13 shld $(1), %r10, %r11 shld $(1), %r9, %r10 shld $(1), %r8, %r9 shl $(1), %r8 mov %r8, %rax mov %r9, %rdx mov %r10, %rcx mov %r11, %r12 subq Lpoly+0(%rip), %rax sbbq Lpoly+8(%rip), %rdx sbbq Lpoly+16(%rip), %rcx sbbq Lpoly+24(%rip), %r12 sbb $(0), %r13 cmove %rax, %r8 cmove %rdx, %r9 cmove %rcx, %r10 cmove %r12, %r11 movq %r8, (%rdi) movq %r9, (8)(%rdi) movq %r10, (16)(%rdi) movq %r11, (24)(%rdi) pop %r13 pop %r12 ret .p2align 4, 0x90 .globl _sm2_div_by_2 _sm2_div_by_2: push %r12 push %r13 push %r14 movq (%rsi), %r8 movq (8)(%rsi), %r9 movq (16)(%rsi), %r10 movq (24)(%rsi), %r11 xor %r13, %r13 xor %r14, %r14 mov %r8, %rax mov %r9, %rdx mov %r10, %rcx mov %r11, %r12 addq Lpoly+0(%rip), %rax adcq Lpoly+8(%rip), %rdx adcq Lpoly+16(%rip), %rcx adcq Lpoly+24(%rip), %r12 adc $(0), %r13 test $(1), %r8 cmovne %rax, %r8 cmovne %rdx, %r9 cmovne %rcx, %r10 cmovne %r12, %r11 cmovne %r13, %r14 shrd $(1), %r9, %r8 shrd $(1), %r10, %r9 shrd $(1), %r11, %r10 shrd $(1), %r14, %r11 movq %r8, (%rdi) movq %r9, (8)(%rdi) movq %r10, (16)(%rdi) movq %r11, (24)(%rdi) pop %r14 pop %r13 pop %r12 ret .p2align 4, 0x90 .globl _sm2_mul_by_3 _sm2_mul_by_3: push %r12 push %r13 xor %r13, %r13 movq (%rsi), %r8 movq (8)(%rsi), %r9 movq (16)(%rsi), %r10 movq (24)(%rsi), %r11 shld $(1), %r11, %r13 shld $(1), %r10, %r11 shld $(1), %r9, %r10 shld $(1), %r8, %r9 shl $(1), %r8 mov %r8, %rax mov %r9, %rdx mov %r10, %rcx mov %r11, %r12 subq Lpoly+0(%rip), %rax sbbq Lpoly+8(%rip), %rdx sbbq Lpoly+16(%rip), %rcx sbbq Lpoly+24(%rip), %r12 sbb $(0), %r13 cmove %rax, %r8 cmove %rdx, %r9 cmove %rcx, %r10 cmove %r12, %r11 xor %r13, %r13 addq (%rsi), %r8 adcq (8)(%rsi), %r9 adcq (16)(%rsi), %r10 adcq (24)(%rsi), %r11 adc $(0), %r13 mov %r8, %rax mov %r9, %rdx mov %r10, %rcx mov %r11, %r12 subq Lpoly+0(%rip), %rax sbbq Lpoly+8(%rip), %rdx sbbq Lpoly+16(%rip), %rcx sbbq Lpoly+24(%rip), %r12 sbb $(0), %r13 cmove %rax, %r8 cmove %rdx, %r9 cmove %rcx, %r10 cmove %r12, %r11 movq %r8, (%rdi) movq %r9, (8)(%rdi) movq %r10, (16)(%rdi) movq %r11, (24)(%rdi) pop %r13 pop %r12 ret .p2align 4, 0x90 .globl _sm2_add _sm2_add: push %r12 push %r13 xor %r13, %r13 movq (%rsi), %r8 movq (8)(%rsi), %r9 movq (16)(%rsi), %r10 movq (24)(%rsi), %r11 addq (%rdx), %r8 adcq (8)(%rdx), %r9 adcq (16)(%rdx), %r10 adcq (24)(%rdx), %r11 adc $(0), %r13 mov %r8, %rax mov %r9, %rdx mov %r10, %rcx mov %r11, %r12 subq Lpoly+0(%rip), %rax sbbq Lpoly+8(%rip), %rdx sbbq Lpoly+16(%rip), %rcx sbbq Lpoly+24(%rip), %r12 sbb $(0), %r13 cmove %rax, %r8 cmove %rdx, %r9 cmove %rcx, %r10 cmove %r12, %r11 movq %r8, (%rdi) movq %r9, (8)(%rdi) movq %r10, (16)(%rdi) movq %r11, (24)(%rdi) pop %r13 pop %r12 ret .p2align 4, 0x90 .globl _sm2_sub _sm2_sub: push %r12 push %r13 xor %r13, %r13 movq (%rsi), %r8 movq (8)(%rsi), %r9 movq (16)(%rsi), %r10 movq (24)(%rsi), %r11 subq (%rdx), %r8 sbbq (8)(%rdx), %r9 sbbq (16)(%rdx), %r10 sbbq (24)(%rdx), %r11 sbb $(0), %r13 mov %r8, %rax mov %r9, %rdx mov %r10, %rcx mov %r11, %r12 addq Lpoly+0(%rip), %rax adcq Lpoly+8(%rip), %rdx adcq Lpoly+16(%rip), %rcx adcq Lpoly+24(%rip), %r12 test %r13, %r13 cmovne %rax, %r8 cmovne %rdx, %r9 cmovne %rcx, %r10 cmovne %r12, %r11 movq %r8, (%rdi) movq %r9, (8)(%rdi) movq %r10, (16)(%rdi) movq %r11, (24)(%rdi) pop %r13 pop %r12 ret .p2align 4, 0x90 .globl _sm2_neg _sm2_neg: push %r12 push %r13 xor %r13, %r13 xor %r8, %r8 xor %r9, %r9 xor %r10, %r10 xor %r11, %r11 subq (%rsi), %r8 sbbq (8)(%rsi), %r9 sbbq (16)(%rsi), %r10 sbbq (24)(%rsi), %r11 sbb $(0), %r13 mov %r8, %rax mov %r9, %rdx mov %r10, %rcx mov %r11, %r12 addq Lpoly+0(%rip), %rax adcq Lpoly+8(%rip), %rdx adcq Lpoly+16(%rip), %rcx adcq Lpoly+24(%rip), %r12 test %r13, %r13 cmovne %rax, %r8 cmovne %rdx, %r9 cmovne %rcx, %r10 cmovne %r12, %r11 movq %r8, (%rdi) movq %r9, (8)(%rdi) movq %r10, (16)(%rdi) movq %r11, (24)(%rdi) pop %r13 pop %r12 ret .p2align 4, 0x90 sm2_mmull: xor %r13, %r13 movq (%rbx), %rax mulq (%rsi) mov %rax, %r8 mov %rdx, %r9 movq (%rbx), %rax mulq (8)(%rsi) add %rax, %r9 adc $(0), %rdx mov %rdx, %r10 movq (%rbx), %rax mulq (16)(%rsi) add %rax, %r10 adc $(0), %rdx mov %rdx, %r11 movq (%rbx), %rax mulq (24)(%rsi) add %rax, %r11 adc $(0), %rdx mov %rdx, %r12 mov %r8, %r14 shl $(32), %r14 mov %r8, %r15 shr $(32), %r15 mov %r8, %rcx mov %r8, %rax xor %rbp, %rbp xor %rdx, %rdx sub %r14, %rcx sbb %r15, %rbp sbb %r14, %rdx sbb %r15, %rax add %rcx, %r9 adc %rbp, %r10 adc %rdx, %r11 adc %rax, %r12 adc $(0), %r13 xor %r8, %r8 movq (8)(%rbx), %rax mulq (%rsi) add %rax, %r9 adc $(0), %rdx mov %rdx, %rcx movq (8)(%rbx), %rax mulq (8)(%rsi) add %rcx, %r10 adc $(0), %rdx add %rax, %r10 adc $(0), %rdx mov %rdx, %rcx movq (8)(%rbx), %rax mulq (16)(%rsi) add %rcx, %r11 adc $(0), %rdx add %rax, %r11 adc $(0), %rdx mov %rdx, %rcx movq (8)(%rbx), %rax mulq (24)(%rsi) add %rcx, %r12 adc $(0), %rdx add %rax, %r12 adc %rdx, %r13 adc $(0), %r8 mov %r9, %r14 shl $(32), %r14 mov %r9, %r15 shr $(32), %r15 mov %r9, %rcx mov %r9, %rax xor %rbp, %rbp xor %rdx, %rdx sub %r14, %rcx sbb %r15, %rbp sbb %r14, %rdx sbb %r15, %rax add %rcx, %r10 adc %rbp, %r11 adc %rdx, %r12 adc %rax, %r13 adc $(0), %r8 xor %r9, %r9 movq (16)(%rbx), %rax mulq (%rsi) add %rax, %r10 adc $(0), %rdx mov %rdx, %rcx movq (16)(%rbx), %rax mulq (8)(%rsi) add %rcx, %r11 adc $(0), %rdx add %rax, %r11 adc $(0), %rdx mov %rdx, %rcx movq (16)(%rbx), %rax mulq (16)(%rsi) add %rcx, %r12 adc $(0), %rdx add %rax, %r12 adc $(0), %rdx mov %rdx, %rcx movq (16)(%rbx), %rax mulq (24)(%rsi) add %rcx, %r13 adc $(0), %rdx add %rax, %r13 adc %rdx, %r8 adc $(0), %r9 mov %r10, %r14 shl $(32), %r14 mov %r10, %r15 shr $(32), %r15 mov %r10, %rcx mov %r10, %rax xor %rbp, %rbp xor %rdx, %rdx sub %r14, %rcx sbb %r15, %rbp sbb %r14, %rdx sbb %r15, %rax add %rcx, %r11 adc %rbp, %r12 adc %rdx, %r13 adc %rax, %r8 adc $(0), %r9 xor %r10, %r10 movq (24)(%rbx), %rax mulq (%rsi) add %rax, %r11 adc $(0), %rdx mov %rdx, %rcx movq (24)(%rbx), %rax mulq (8)(%rsi) add %rcx, %r12 adc $(0), %rdx add %rax, %r12 adc $(0), %rdx mov %rdx, %rcx movq (24)(%rbx), %rax mulq (16)(%rsi) add %rcx, %r13 adc $(0), %rdx add %rax, %r13 adc $(0), %rdx mov %rdx, %rcx movq (24)(%rbx), %rax mulq (24)(%rsi) add %rcx, %r8 adc $(0), %rdx add %rax, %r8 adc %rdx, %r9 adc $(0), %r10 mov %r11, %r14 shl $(32), %r14 mov %r11, %r15 shr $(32), %r15 mov %r11, %rcx mov %r11, %rax xor %rbp, %rbp xor %rdx, %rdx sub %r14, %rcx sbb %r15, %rbp sbb %r14, %rdx sbb %r15, %rax add %rcx, %r12 adc %rbp, %r13 adc %rdx, %r8 adc %rax, %r9 adc $(0), %r10 xor %r11, %r11 movq Lpoly+0(%rip), %rcx movq Lpoly+8(%rip), %rbp movq Lpoly+16(%rip), %rbx movq Lpoly+24(%rip), %rdx mov %r12, %rax mov %r13, %r11 mov %r8, %r14 mov %r9, %r15 sub %rcx, %rax sbb %rbp, %r11 sbb %rbx, %r14 sbb %rdx, %r15 sbb $(0), %r10 cmovnc %rax, %r12 cmovnc %r11, %r13 cmovnc %r14, %r8 cmovnc %r15, %r9 movq %r12, (%rdi) movq %r13, (8)(%rdi) movq %r8, (16)(%rdi) movq %r9, (24)(%rdi) ret .p2align 4, 0x90 .globl _sm2_mul_montl _sm2_mul_montl: push %rbp push %rbx push %r12 push %r13 push %r14 push %r15 mov %rdx, %rbx call sm2_mmull pop %r15 pop %r14 pop %r13 pop %r12 pop %rbx pop %rbp ret .p2align 4, 0x90 .globl _sm2_to_mont _sm2_to_mont: push %rbp push %rbx push %r12 push %r13 push %r14 push %r15 lea LRR(%rip), %rbx call sm2_mmull pop %r15 pop %r14 pop %r13 pop %r12 pop %rbx pop %rbp ret .p2align 4, 0x90 .globl _sm2_sqr_montl _sm2_sqr_montl: push %rbp push %rbx push %r12 push %r13 push %r14 push %r15 movq (%rsi), %rbx movq (8)(%rsi), %rax mul %rbx mov %rax, %r9 mov %rdx, %r10 movq (16)(%rsi), %rax mul %rbx add %rax, %r10 adc $(0), %rdx mov %rdx, %r11 movq (24)(%rsi), %rax mul %rbx add %rax, %r11 adc $(0), %rdx mov %rdx, %r12 movq (8)(%rsi), %rbx movq (16)(%rsi), %rax mul %rbx add %rax, %r11 adc $(0), %rdx mov %rdx, %rbp movq (24)(%rsi), %rax mul %rbx add %rax, %r12 adc $(0), %rdx add %rbp, %r12 adc $(0), %rdx mov %rdx, %r13 movq (16)(%rsi), %rbx movq (24)(%rsi), %rax mul %rbx add %rax, %r13 adc $(0), %rdx mov %rdx, %r14 xor %r15, %r15 shld $(1), %r14, %r15 shld $(1), %r13, %r14 shld $(1), %r12, %r13 shld $(1), %r11, %r12 shld $(1), %r10, %r11 shld $(1), %r9, %r10 shl $(1), %r9 movq (%rsi), %rax mul %rax mov %rax, %r8 add %rdx, %r9 adc $(0), %r10 movq (8)(%rsi), %rax mul %rax add %rax, %r10 adc %rdx, %r11 adc $(0), %r12 movq (16)(%rsi), %rax mul %rax add %rax, %r12 adc %rdx, %r13 adc $(0), %r14 movq (24)(%rsi), %rax mul %rax add %rax, %r14 adc %rdx, %r15 mov %r8, %rax mov %r8, %rcx mov %r8, %rdx xor %rbp, %rbp xor %rbx, %rbx shl $(32), %r8 shr $(32), %rax sub %r8, %rcx sbb %rax, %rbp sbb %r8, %rbx sbb %rax, %rdx xor %r8, %r8 add %rcx, %r9 adc %rbp, %r10 adc %rbx, %r11 adc %rdx, %r12 adc $(0), %r8 mov %r9, %rax mov %r9, %rcx mov %r9, %rdx xor %rbp, %rbp xor %rbx, %rbx shl $(32), %r9 shr $(32), %rax sub %r9, %rcx sbb %rax, %rbp sbb %r9, %rbx sbb %rax, %rdx xor %r9, %r9 add %rcx, %r10 adc %rbp, %r11 adc %rbx, %r12 adc %rdx, %r13 adc $(0), %r9 add %r8, %r13 adc $(0), %r9 mov %r10, %rax mov %r10, %rcx mov %r10, %rdx xor %rbp, %rbp xor %rbx, %rbx shl $(32), %r10 shr $(32), %rax sub %r10, %rcx sbb %rax, %rbp sbb %r10, %rbx sbb %rax, %rdx xor %r10, %r10 add %rcx, %r11 adc %rbp, %r12 adc %rbx, %r13 adc %rdx, %r14 adc $(0), %r10 add %r9, %r14 adc $(0), %r10 mov %r11, %rax mov %r11, %rcx mov %r11, %rdx xor %rbp, %rbp xor %rbx, %rbx shl $(32), %r11 shr $(32), %rax sub %r11, %rcx sbb %rax, %rbp sbb %r11, %rbx sbb %rax, %rdx xor %r11, %r11 add %rcx, %r12 adc %rbp, %r13 adc %rbx, %r14 adc %rdx, %r15 adc $(0), %r11 add %r10, %r15 adc $(0), %r11 movq Lpoly+0(%rip), %rcx movq Lpoly+8(%rip), %rbp movq Lpoly+16(%rip), %rbx movq Lpoly+24(%rip), %rdx mov %r12, %rax mov %r13, %r8 mov %r14, %r9 mov %r15, %r10 sub %rcx, %rax sbb %rbp, %r8 sbb %rbx, %r9 sbb %rdx, %r10 sbb $(0), %r11 cmovnc %rax, %r12 cmovnc %r8, %r13 cmovnc %r9, %r14 cmovnc %r10, %r15 movq %r12, (%rdi) movq %r13, (8)(%rdi) movq %r14, (16)(%rdi) movq %r15, (24)(%rdi) pop %r15 pop %r14 pop %r13 pop %r12 pop %rbx pop %rbp ret .p2align 4, 0x90 .globl _sm2_mont_back _sm2_mont_back: push %rbp push %rbx push %r12 push %r13 push %r14 push %r15 movq (%rsi), %r10 movq (8)(%rsi), %r11 movq (16)(%rsi), %r12 movq (24)(%rsi), %r13 xor %r8, %r8 xor %r9, %r9 mov %r10, %r14 shl $(32), %r14 mov %r10, %r15 shr $(32), %r15 mov %r10, %rcx mov %r10, %rax xor %rbp, %rbp xor %rdx, %rdx sub %r14, %rcx sbb %r15, %rbp sbb %r14, %rdx sbb %r15, %rax add %rcx, %r11 adc %rbp, %r12 adc %rdx, %r13 adc %rax, %r8 adc $(0), %r9 xor %r10, %r10 mov %r11, %r14 shl $(32), %r14 mov %r11, %r15 shr $(32), %r15 mov %r11, %rcx mov %r11, %rax xor %rbp, %rbp xor %rdx, %rdx sub %r14, %rcx sbb %r15, %rbp sbb %r14, %rdx sbb %r15, %rax add %rcx, %r12 adc %rbp, %r13 adc %rdx, %r8 adc %rax, %r9 adc $(0), %r10 xor %r11, %r11 mov %r12, %r14 shl $(32), %r14 mov %r12, %r15 shr $(32), %r15 mov %r12, %rcx mov %r12, %rax xor %rbp, %rbp xor %rdx, %rdx sub %r14, %rcx sbb %r15, %rbp sbb %r14, %rdx sbb %r15, %rax add %rcx, %r13 adc %rbp, %r8 adc %rdx, %r9 adc %rax, %r10 adc $(0), %r11 xor %r12, %r12 mov %r13, %r14 shl $(32), %r14 mov %r13, %r15 shr $(32), %r15 mov %r13, %rcx mov %r13, %rax xor %rbp, %rbp xor %rdx, %rdx sub %r14, %rcx sbb %r15, %rbp sbb %r14, %rdx sbb %r15, %rax add %rcx, %r8 adc %rbp, %r9 adc %rdx, %r10 adc %rax, %r11 adc $(0), %r12 xor %r13, %r13 mov %r8, %rcx mov %r9, %rbp mov %r10, %rbx mov %r11, %rdx subq Lpoly+0(%rip), %rcx sbbq Lpoly+8(%rip), %rbp sbbq Lpoly+16(%rip), %rbx sbbq Lpoly+24(%rip), %rdx sbb $(0), %r12 cmovnc %rcx, %r8 cmovnc %rbp, %r9 cmovnc %rbx, %r10 cmovnc %rdx, %r11 movq %r8, (%rdi) movq %r9, (8)(%rdi) movq %r10, (16)(%rdi) movq %r11, (24)(%rdi) pop %r15 pop %r14 pop %r13 pop %r12 pop %rbx pop %rbp ret .p2align 4, 0x90 .globl _sm2_select_pp_w5 _sm2_select_pp_w5: push %r12 push %r13 movdqa LOne(%rip), %xmm0 movdqa %xmm0, %xmm8 movd %edx, %xmm1 pshufd $(0), %xmm1, %xmm1 pxor %xmm2, %xmm2 pxor %xmm3, %xmm3 pxor %xmm4, %xmm4 pxor %xmm5, %xmm5 pxor %xmm6, %xmm6 pxor %xmm7, %xmm7 mov $(16), %rcx .Lselect_loop_sse_w5gas_11: movdqa %xmm8, %xmm15 pcmpeqd %xmm1, %xmm15 paddd %xmm0, %xmm8 movdqa (%rsi), %xmm9 movdqa (16)(%rsi), %xmm10 movdqa (32)(%rsi), %xmm11 movdqa (48)(%rsi), %xmm12 movdqa (64)(%rsi), %xmm13 movdqa (80)(%rsi), %xmm14 add $(96), %rsi pand %xmm15, %xmm9 pand %xmm15, %xmm10 pand %xmm15, %xmm11 pand %xmm15, %xmm12 pand %xmm15, %xmm13 pand %xmm15, %xmm14 por %xmm9, %xmm2 por %xmm10, %xmm3 por %xmm11, %xmm4 por %xmm12, %xmm5 por %xmm13, %xmm6 por %xmm14, %xmm7 dec %rcx jnz .Lselect_loop_sse_w5gas_11 movdqu %xmm2, (%rdi) movdqu %xmm3, (16)(%rdi) movdqu %xmm4, (32)(%rdi) movdqu %xmm5, (48)(%rdi) movdqu %xmm6, (64)(%rdi) movdqu %xmm7, (80)(%rdi) pop %r13 pop %r12 ret .p2align 4, 0x90 .globl _sm2_select_ap_w7 _sm2_select_ap_w7: push %r12 push %r13 movdqa LOne(%rip), %xmm0 pxor %xmm2, %xmm2 pxor %xmm3, %xmm3 pxor %xmm4, %xmm4 pxor %xmm5, %xmm5 movdqa %xmm0, %xmm8 movd %edx, %xmm1 pshufd $(0), %xmm1, %xmm1 mov $(64), %rcx .Lselect_loop_sse_w7gas_12: movdqa %xmm8, %xmm15 pcmpeqd %xmm1, %xmm15 paddd %xmm0, %xmm8 movdqa (%rsi), %xmm9 movdqa (16)(%rsi), %xmm10 movdqa (32)(%rsi), %xmm11 movdqa (48)(%rsi), %xmm12 add $(64), %rsi pand %xmm15, %xmm9 pand %xmm15, %xmm10 pand %xmm15, %xmm11 pand %xmm15, %xmm12 por %xmm9, %xmm2 por %xmm10, %xmm3 por %xmm11, %xmm4 por %xmm12, %xmm5 dec %rcx jnz .Lselect_loop_sse_w7gas_12 movdqu %xmm2, (%rdi) movdqu %xmm3, (16)(%rdi) movdqu %xmm4, (32)(%rdi) movdqu %xmm5, (48)(%rdi) pop %r13 pop %r12 ret
; A198276: 19*2^n-1. ; 18,37,75,151,303,607,1215,2431,4863,9727,19455,38911,77823,155647,311295,622591,1245183,2490367,4980735,9961471,19922943,39845887,79691775,159383551,318767103,637534207,1275068415,2550136831,5100273663,10200547327,20401094655,40802189311,81604378623,163208757247,326417514495,652835028991,1305670057983,2611340115967,5222680231935,10445360463871,20890720927743,41781441855487,83562883710975,167125767421951,334251534843903,668503069687807,1337006139375615,2674012278751231,5348024557502463,10696049115004927,21392098230009855,42784196460019711,85568392920039423,171136785840078847,342273571680157695,684547143360315391,1369094286720630783,2738188573441261567,5476377146882523135,10952754293765046271,21905508587530092543,43811017175060185087,87622034350120370175,175244068700240740351,350488137400481480703,700976274800962961407,1401952549601925922815,2803905099203851845631,5607810198407703691263,11215620396815407382527,22431240793630814765055,44862481587261629530111,89724963174523259060223,179449926349046518120447,358899852698093036240895,717799705396186072481791,1435599410792372144963583,2871198821584744289927167,5742397643169488579854335,11484795286338977159708671,22969590572677954319417343,45939181145355908638834687,91878362290711817277669375,183756724581423634555338751,367513449162847269110677503,735026898325694538221355007,1470053796651389076442710015,2940107593302778152885420031,5880215186605556305770840063,11760430373211112611541680127,23520860746422225223083360255,47041721492844450446166720511,94083442985688900892333441023,188166885971377801784666882047,376333771942755603569333764095,752667543885511207138667528191,1505335087771022414277335056383,3010670175542044828554670112767,6021340351084089657109340225535,12042680702168179314218680451071 mov $1,2 pow $1,$0 sub $1,1 mul $1,19 add $1,18 mov $0,$1