text
stringlengths
1
1.05M
default rel %define XMMWORD %define YMMWORD %define ZMMWORD section .text code align=64 EXTERN OPENSSL_ia32cap_P global bn_mul_mont ALIGN 16 bn_mul_mont: mov QWORD[8+rsp],rdi ;WIN64 prologue mov QWORD[16+rsp],rsi mov rax,rsp $L$SEH_begin_bn_mul_mont: mov rdi,rcx mov rsi,rdx mov rdx,r8 mov rcx,r9 mov r8,QWORD[40+rsp] mov r9,QWORD[48+rsp] mov r9d,r9d mov rax,rsp test r9d,3 jnz NEAR $L$mul_enter cmp r9d,8 jb NEAR $L$mul_enter cmp rdx,rsi jne NEAR $L$mul4x_enter test r9d,7 jz NEAR $L$sqr8x_enter jmp NEAR $L$mul4x_enter ALIGN 16 $L$mul_enter: push rbx push rbp push r12 push r13 push r14 push r15 neg r9 mov r11,rsp lea r10,[((-16))+r9*8+rsp] neg r9 and r10,-1024 sub r11,r10 and r11,-4096 lea rsp,[r11*1+r10] mov r11,QWORD[rsp] cmp rsp,r10 ja NEAR $L$mul_page_walk jmp NEAR $L$mul_page_walk_done ALIGN 16 $L$mul_page_walk: lea rsp,[((-4096))+rsp] mov r11,QWORD[rsp] cmp rsp,r10 ja NEAR $L$mul_page_walk $L$mul_page_walk_done: mov QWORD[8+r9*8+rsp],rax $L$mul_body: mov r12,rdx mov r8,QWORD[r8] mov rbx,QWORD[r12] mov rax,QWORD[rsi] xor r14,r14 xor r15,r15 mov rbp,r8 mul rbx mov r10,rax mov rax,QWORD[rcx] imul rbp,r10 mov r11,rdx mul rbp add r10,rax mov rax,QWORD[8+rsi] adc rdx,0 mov r13,rdx lea r15,[1+r15] jmp NEAR $L$1st_enter ALIGN 16 $L$1st: add r13,rax mov rax,QWORD[r15*8+rsi] adc rdx,0 add r13,r11 mov r11,r10 adc rdx,0 mov QWORD[((-16))+r15*8+rsp],r13 mov r13,rdx $L$1st_enter: mul rbx add r11,rax mov rax,QWORD[r15*8+rcx] adc rdx,0 lea r15,[1+r15] mov r10,rdx mul rbp cmp r15,r9 jne NEAR $L$1st add r13,rax mov rax,QWORD[rsi] adc rdx,0 add r13,r11 adc rdx,0 mov QWORD[((-16))+r15*8+rsp],r13 mov r13,rdx mov r11,r10 xor rdx,rdx add r13,r11 adc rdx,0 mov QWORD[((-8))+r9*8+rsp],r13 mov QWORD[r9*8+rsp],rdx lea r14,[1+r14] jmp NEAR $L$outer ALIGN 16 $L$outer: mov rbx,QWORD[r14*8+r12] xor r15,r15 mov rbp,r8 mov r10,QWORD[rsp] mul rbx add r10,rax mov rax,QWORD[rcx] adc rdx,0 imul rbp,r10 mov r11,rdx mul rbp add r10,rax mov rax,QWORD[8+rsi] adc rdx,0 mov r10,QWORD[8+rsp] mov r13,rdx lea r15,[1+r15] jmp NEAR $L$inner_enter ALIGN 16 $L$inner: add r13,rax mov rax,QWORD[r15*8+rsi] adc rdx,0 add r13,r10 mov r10,QWORD[r15*8+rsp] adc rdx,0 mov QWORD[((-16))+r15*8+rsp],r13 mov r13,rdx $L$inner_enter: mul rbx add r11,rax mov rax,QWORD[r15*8+rcx] adc rdx,0 add r10,r11 mov r11,rdx adc r11,0 lea r15,[1+r15] mul rbp cmp r15,r9 jne NEAR $L$inner add r13,rax mov rax,QWORD[rsi] adc rdx,0 add r13,r10 mov r10,QWORD[r15*8+rsp] adc rdx,0 mov QWORD[((-16))+r15*8+rsp],r13 mov r13,rdx xor rdx,rdx add r13,r11 adc rdx,0 add r13,r10 adc rdx,0 mov QWORD[((-8))+r9*8+rsp],r13 mov QWORD[r9*8+rsp],rdx lea r14,[1+r14] cmp r14,r9 jb NEAR $L$outer xor r14,r14 mov rax,QWORD[rsp] lea rsi,[rsp] mov r15,r9 jmp NEAR $L$sub ALIGN 16 $L$sub: sbb rax,QWORD[r14*8+rcx] mov QWORD[r14*8+rdi],rax mov rax,QWORD[8+r14*8+rsi] lea r14,[1+r14] dec r15 jnz NEAR $L$sub sbb rax,0 xor r14,r14 and rsi,rax not rax mov rcx,rdi and rcx,rax mov r15,r9 or rsi,rcx ALIGN 16 $L$copy: mov rax,QWORD[r14*8+rsi] mov QWORD[r14*8+rsp],r14 mov QWORD[r14*8+rdi],rax lea r14,[1+r14] sub r15,1 jnz NEAR $L$copy mov rsi,QWORD[8+r9*8+rsp] mov rax,1 mov r15,QWORD[((-48))+rsi] mov r14,QWORD[((-40))+rsi] mov r13,QWORD[((-32))+rsi] mov r12,QWORD[((-24))+rsi] mov rbp,QWORD[((-16))+rsi] mov rbx,QWORD[((-8))+rsi] lea rsp,[rsi] $L$mul_epilogue: mov rdi,QWORD[8+rsp] ;WIN64 epilogue mov rsi,QWORD[16+rsp] DB 0F3h,0C3h ;repret $L$SEH_end_bn_mul_mont: ALIGN 16 bn_mul4x_mont: mov QWORD[8+rsp],rdi ;WIN64 prologue mov QWORD[16+rsp],rsi mov rax,rsp $L$SEH_begin_bn_mul4x_mont: mov rdi,rcx mov rsi,rdx mov rdx,r8 mov rcx,r9 mov r8,QWORD[40+rsp] mov r9,QWORD[48+rsp] mov r9d,r9d mov rax,rsp $L$mul4x_enter: push rbx push rbp push r12 push r13 push r14 push r15 neg r9 mov r11,rsp lea r10,[((-32))+r9*8+rsp] neg r9 and r10,-1024 sub r11,r10 and r11,-4096 lea rsp,[r11*1+r10] mov r11,QWORD[rsp] cmp rsp,r10 ja NEAR $L$mul4x_page_walk jmp NEAR $L$mul4x_page_walk_done $L$mul4x_page_walk: lea rsp,[((-4096))+rsp] mov r11,QWORD[rsp] cmp rsp,r10 ja NEAR $L$mul4x_page_walk $L$mul4x_page_walk_done: mov QWORD[8+r9*8+rsp],rax $L$mul4x_body: mov QWORD[16+r9*8+rsp],rdi mov r12,rdx mov r8,QWORD[r8] mov rbx,QWORD[r12] mov rax,QWORD[rsi] xor r14,r14 xor r15,r15 mov rbp,r8 mul rbx mov r10,rax mov rax,QWORD[rcx] imul rbp,r10 mov r11,rdx mul rbp add r10,rax mov rax,QWORD[8+rsi] adc rdx,0 mov rdi,rdx mul rbx add r11,rax mov rax,QWORD[8+rcx] adc rdx,0 mov r10,rdx mul rbp add rdi,rax mov rax,QWORD[16+rsi] adc rdx,0 add rdi,r11 lea r15,[4+r15] adc rdx,0 mov QWORD[rsp],rdi mov r13,rdx jmp NEAR $L$1st4x ALIGN 16 $L$1st4x: mul rbx add r10,rax mov rax,QWORD[((-16))+r15*8+rcx] adc rdx,0 mov r11,rdx mul rbp add r13,rax mov rax,QWORD[((-8))+r15*8+rsi] adc rdx,0 add r13,r10 adc rdx,0 mov QWORD[((-24))+r15*8+rsp],r13 mov rdi,rdx mul rbx add r11,rax mov rax,QWORD[((-8))+r15*8+rcx] adc rdx,0 mov r10,rdx mul rbp add rdi,rax mov rax,QWORD[r15*8+rsi] adc rdx,0 add rdi,r11 adc rdx,0 mov QWORD[((-16))+r15*8+rsp],rdi mov r13,rdx mul rbx add r10,rax mov rax,QWORD[r15*8+rcx] adc rdx,0 mov r11,rdx mul rbp add r13,rax mov rax,QWORD[8+r15*8+rsi] adc rdx,0 add r13,r10 adc rdx,0 mov QWORD[((-8))+r15*8+rsp],r13 mov rdi,rdx mul rbx add r11,rax mov rax,QWORD[8+r15*8+rcx] adc rdx,0 lea r15,[4+r15] mov r10,rdx mul rbp add rdi,rax mov rax,QWORD[((-16))+r15*8+rsi] adc rdx,0 add rdi,r11 adc rdx,0 mov QWORD[((-32))+r15*8+rsp],rdi mov r13,rdx cmp r15,r9 jb NEAR $L$1st4x mul rbx add r10,rax mov rax,QWORD[((-16))+r15*8+rcx] adc rdx,0 mov r11,rdx mul rbp add r13,rax mov rax,QWORD[((-8))+r15*8+rsi] adc rdx,0 add r13,r10 adc rdx,0 mov QWORD[((-24))+r15*8+rsp],r13 mov rdi,rdx mul rbx add r11,rax mov rax,QWORD[((-8))+r15*8+rcx] adc rdx,0 mov r10,rdx mul rbp add rdi,rax mov rax,QWORD[rsi] adc rdx,0 add rdi,r11 adc rdx,0 mov QWORD[((-16))+r15*8+rsp],rdi mov r13,rdx xor rdi,rdi add r13,r10 adc rdi,0 mov QWORD[((-8))+r15*8+rsp],r13 mov QWORD[r15*8+rsp],rdi lea r14,[1+r14] ALIGN 4 $L$outer4x: mov rbx,QWORD[r14*8+r12] xor r15,r15 mov r10,QWORD[rsp] mov rbp,r8 mul rbx add r10,rax mov rax,QWORD[rcx] adc rdx,0 imul rbp,r10 mov r11,rdx mul rbp add r10,rax mov rax,QWORD[8+rsi] adc rdx,0 mov rdi,rdx mul rbx add r11,rax mov rax,QWORD[8+rcx] adc rdx,0 add r11,QWORD[8+rsp] adc rdx,0 mov r10,rdx mul rbp add rdi,rax mov rax,QWORD[16+rsi] adc rdx,0 add rdi,r11 lea r15,[4+r15] adc rdx,0 mov QWORD[rsp],rdi mov r13,rdx jmp NEAR $L$inner4x ALIGN 16 $L$inner4x: mul rbx add r10,rax mov rax,QWORD[((-16))+r15*8+rcx] adc rdx,0 add r10,QWORD[((-16))+r15*8+rsp] adc rdx,0 mov r11,rdx mul rbp add r13,rax mov rax,QWORD[((-8))+r15*8+rsi] adc rdx,0 add r13,r10 adc rdx,0 mov QWORD[((-24))+r15*8+rsp],r13 mov rdi,rdx mul rbx add r11,rax mov rax,QWORD[((-8))+r15*8+rcx] adc rdx,0 add r11,QWORD[((-8))+r15*8+rsp] adc rdx,0 mov r10,rdx mul rbp add rdi,rax mov rax,QWORD[r15*8+rsi] adc rdx,0 add rdi,r11 adc rdx,0 mov QWORD[((-16))+r15*8+rsp],rdi mov r13,rdx mul rbx add r10,rax mov rax,QWORD[r15*8+rcx] adc rdx,0 add r10,QWORD[r15*8+rsp] adc rdx,0 mov r11,rdx mul rbp add r13,rax mov rax,QWORD[8+r15*8+rsi] adc rdx,0 add r13,r10 adc rdx,0 mov QWORD[((-8))+r15*8+rsp],r13 mov rdi,rdx mul rbx add r11,rax mov rax,QWORD[8+r15*8+rcx] adc rdx,0 add r11,QWORD[8+r15*8+rsp] adc rdx,0 lea r15,[4+r15] mov r10,rdx mul rbp add rdi,rax mov rax,QWORD[((-16))+r15*8+rsi] adc rdx,0 add rdi,r11 adc rdx,0 mov QWORD[((-32))+r15*8+rsp],rdi mov r13,rdx cmp r15,r9 jb NEAR $L$inner4x mul rbx add r10,rax mov rax,QWORD[((-16))+r15*8+rcx] adc rdx,0 add r10,QWORD[((-16))+r15*8+rsp] adc rdx,0 mov r11,rdx mul rbp add r13,rax mov rax,QWORD[((-8))+r15*8+rsi] adc rdx,0 add r13,r10 adc rdx,0 mov QWORD[((-24))+r15*8+rsp],r13 mov rdi,rdx mul rbx add r11,rax mov rax,QWORD[((-8))+r15*8+rcx] adc rdx,0 add r11,QWORD[((-8))+r15*8+rsp] adc rdx,0 lea r14,[1+r14] mov r10,rdx mul rbp add rdi,rax mov rax,QWORD[rsi] adc rdx,0 add rdi,r11 adc rdx,0 mov QWORD[((-16))+r15*8+rsp],rdi mov r13,rdx xor rdi,rdi add r13,r10 adc rdi,0 add r13,QWORD[r9*8+rsp] adc rdi,0 mov QWORD[((-8))+r15*8+rsp],r13 mov QWORD[r15*8+rsp],rdi cmp r14,r9 jb NEAR $L$outer4x mov rdi,QWORD[16+r9*8+rsp] lea r15,[((-4))+r9] mov rax,QWORD[rsp] pxor xmm0,xmm0 mov rdx,QWORD[8+rsp] shr r15,2 lea rsi,[rsp] xor r14,r14 sub rax,QWORD[rcx] mov rbx,QWORD[16+rsi] mov rbp,QWORD[24+rsi] sbb rdx,QWORD[8+rcx] jmp NEAR $L$sub4x ALIGN 16 $L$sub4x: mov QWORD[r14*8+rdi],rax mov QWORD[8+r14*8+rdi],rdx sbb rbx,QWORD[16+r14*8+rcx] mov rax,QWORD[32+r14*8+rsi] mov rdx,QWORD[40+r14*8+rsi] sbb rbp,QWORD[24+r14*8+rcx] mov QWORD[16+r14*8+rdi],rbx mov QWORD[24+r14*8+rdi],rbp sbb rax,QWORD[32+r14*8+rcx] mov rbx,QWORD[48+r14*8+rsi] mov rbp,QWORD[56+r14*8+rsi] sbb rdx,QWORD[40+r14*8+rcx] lea r14,[4+r14] dec r15 jnz NEAR $L$sub4x mov QWORD[r14*8+rdi],rax mov rax,QWORD[32+r14*8+rsi] sbb rbx,QWORD[16+r14*8+rcx] mov QWORD[8+r14*8+rdi],rdx sbb rbp,QWORD[24+r14*8+rcx] mov QWORD[16+r14*8+rdi],rbx sbb rax,0 mov QWORD[24+r14*8+rdi],rbp xor r14,r14 and rsi,rax not rax mov rcx,rdi and rcx,rax lea r15,[((-4))+r9] or rsi,rcx shr r15,2 movdqu xmm1,XMMWORD[rsi] movdqa XMMWORD[rsp],xmm0 movdqu XMMWORD[rdi],xmm1 jmp NEAR $L$copy4x ALIGN 16 $L$copy4x: movdqu xmm2,XMMWORD[16+r14*1+rsi] movdqu xmm1,XMMWORD[32+r14*1+rsi] movdqa XMMWORD[16+r14*1+rsp],xmm0 movdqu XMMWORD[16+r14*1+rdi],xmm2 movdqa XMMWORD[32+r14*1+rsp],xmm0 movdqu XMMWORD[32+r14*1+rdi],xmm1 lea r14,[32+r14] dec r15 jnz NEAR $L$copy4x movdqu xmm2,XMMWORD[16+r14*1+rsi] movdqa XMMWORD[16+r14*1+rsp],xmm0 movdqu XMMWORD[16+r14*1+rdi],xmm2 mov rsi,QWORD[8+r9*8+rsp] mov rax,1 mov r15,QWORD[((-48))+rsi] mov r14,QWORD[((-40))+rsi] mov r13,QWORD[((-32))+rsi] mov r12,QWORD[((-24))+rsi] mov rbp,QWORD[((-16))+rsi] mov rbx,QWORD[((-8))+rsi] lea rsp,[rsi] $L$mul4x_epilogue: mov rdi,QWORD[8+rsp] ;WIN64 epilogue mov rsi,QWORD[16+rsp] DB 0F3h,0C3h ;repret $L$SEH_end_bn_mul4x_mont: EXTERN bn_sqr8x_internal ALIGN 32 bn_sqr8x_mont: mov QWORD[8+rsp],rdi ;WIN64 prologue mov QWORD[16+rsp],rsi mov rax,rsp $L$SEH_begin_bn_sqr8x_mont: mov rdi,rcx mov rsi,rdx mov rdx,r8 mov rcx,r9 mov r8,QWORD[40+rsp] mov r9,QWORD[48+rsp] mov rax,rsp $L$sqr8x_enter: push rbx push rbp push r12 push r13 push r14 push r15 $L$sqr8x_prologue: mov r10d,r9d shl r9d,3 shl r10,3+2 neg r9 lea r11,[((-64))+r9*2+rsp] mov rbp,rsp mov r8,QWORD[r8] sub r11,rsi and r11,4095 cmp r10,r11 jb NEAR $L$sqr8x_sp_alt sub rbp,r11 lea rbp,[((-64))+r9*2+rbp] jmp NEAR $L$sqr8x_sp_done ALIGN 32 $L$sqr8x_sp_alt: lea r10,[((4096-64))+r9*2] lea rbp,[((-64))+r9*2+rbp] sub r11,r10 mov r10,0 cmovc r11,r10 sub rbp,r11 $L$sqr8x_sp_done: and rbp,-64 mov r11,rsp sub r11,rbp and r11,-4096 lea rsp,[rbp*1+r11] mov r10,QWORD[rsp] cmp rsp,rbp ja NEAR $L$sqr8x_page_walk jmp NEAR $L$sqr8x_page_walk_done ALIGN 16 $L$sqr8x_page_walk: lea rsp,[((-4096))+rsp] mov r10,QWORD[rsp] cmp rsp,rbp ja NEAR $L$sqr8x_page_walk $L$sqr8x_page_walk_done: mov r10,r9 neg r9 mov QWORD[32+rsp],r8 mov QWORD[40+rsp],rax $L$sqr8x_body: DB 102,72,15,110,209 pxor xmm0,xmm0 DB 102,72,15,110,207 DB 102,73,15,110,218 call bn_sqr8x_internal lea rbx,[r9*1+rdi] mov rcx,r9 mov rdx,r9 DB 102,72,15,126,207 sar rcx,3+2 jmp NEAR $L$sqr8x_sub ALIGN 32 $L$sqr8x_sub: mov r12,QWORD[rbx] mov r13,QWORD[8+rbx] mov r14,QWORD[16+rbx] mov r15,QWORD[24+rbx] lea rbx,[32+rbx] sbb r12,QWORD[rbp] sbb r13,QWORD[8+rbp] sbb r14,QWORD[16+rbp] sbb r15,QWORD[24+rbp] lea rbp,[32+rbp] mov QWORD[rdi],r12 mov QWORD[8+rdi],r13 mov QWORD[16+rdi],r14 mov QWORD[24+rdi],r15 lea rdi,[32+rdi] inc rcx jnz NEAR $L$sqr8x_sub sbb rax,0 lea rbx,[r9*1+rbx] lea rdi,[r9*1+rdi] DB 102,72,15,110,200 pxor xmm0,xmm0 pshufd xmm1,xmm1,0 mov rsi,QWORD[40+rsp] jmp NEAR $L$sqr8x_cond_copy ALIGN 32 $L$sqr8x_cond_copy: movdqa xmm2,XMMWORD[rbx] movdqa xmm3,XMMWORD[16+rbx] lea rbx,[32+rbx] movdqu xmm4,XMMWORD[rdi] movdqu xmm5,XMMWORD[16+rdi] lea rdi,[32+rdi] movdqa XMMWORD[(-32)+rbx],xmm0 movdqa XMMWORD[(-16)+rbx],xmm0 movdqa XMMWORD[(-32)+rdx*1+rbx],xmm0 movdqa XMMWORD[(-16)+rdx*1+rbx],xmm0 pcmpeqd xmm0,xmm1 pand xmm2,xmm1 pand xmm3,xmm1 pand xmm4,xmm0 pand xmm5,xmm0 pxor xmm0,xmm0 por xmm4,xmm2 por xmm5,xmm3 movdqu XMMWORD[(-32)+rdi],xmm4 movdqu XMMWORD[(-16)+rdi],xmm5 add r9,32 jnz NEAR $L$sqr8x_cond_copy mov rax,1 mov r15,QWORD[((-48))+rsi] mov r14,QWORD[((-40))+rsi] mov r13,QWORD[((-32))+rsi] mov r12,QWORD[((-24))+rsi] mov rbp,QWORD[((-16))+rsi] mov rbx,QWORD[((-8))+rsi] lea rsp,[rsi] $L$sqr8x_epilogue: mov rdi,QWORD[8+rsp] ;WIN64 epilogue mov rsi,QWORD[16+rsp] DB 0F3h,0C3h ;repret $L$SEH_end_bn_sqr8x_mont: DB 77,111,110,116,103,111,109,101,114,121,32,77,117,108,116,105 DB 112,108,105,99,97,116,105,111,110,32,102,111,114,32,120,56 DB 54,95,54,52,44,32,67,82,89,80,84,79,71,65,77,83 DB 32,98,121,32,60,97,112,112,114,111,64,111,112,101,110,115 DB 115,108,46,111,114,103,62,0 ALIGN 16 EXTERN __imp_RtlVirtualUnwind ALIGN 16 mul_handler: push rsi push rdi push rbx push rbp push r12 push r13 push r14 push r15 pushfq sub rsp,64 mov rax,QWORD[120+r8] mov rbx,QWORD[248+r8] mov rsi,QWORD[8+r9] mov r11,QWORD[56+r9] mov r10d,DWORD[r11] lea r10,[r10*1+rsi] cmp rbx,r10 jb NEAR $L$common_seh_tail mov rax,QWORD[152+r8] mov r10d,DWORD[4+r11] lea r10,[r10*1+rsi] cmp rbx,r10 jae NEAR $L$common_seh_tail mov r10,QWORD[192+r8] mov rax,QWORD[8+r10*8+rax] jmp NEAR $L$common_pop_regs ALIGN 16 sqr_handler: push rsi push rdi push rbx push rbp push r12 push r13 push r14 push r15 pushfq sub rsp,64 mov rax,QWORD[120+r8] mov rbx,QWORD[248+r8] mov rsi,QWORD[8+r9] mov r11,QWORD[56+r9] mov r10d,DWORD[r11] lea r10,[r10*1+rsi] cmp rbx,r10 jb NEAR $L$common_seh_tail mov r10d,DWORD[4+r11] lea r10,[r10*1+rsi] cmp rbx,r10 jb NEAR $L$common_pop_regs mov rax,QWORD[152+r8] mov r10d,DWORD[8+r11] lea r10,[r10*1+rsi] cmp rbx,r10 jae NEAR $L$common_seh_tail mov rax,QWORD[40+rax] $L$common_pop_regs: mov rbx,QWORD[((-8))+rax] mov rbp,QWORD[((-16))+rax] mov r12,QWORD[((-24))+rax] mov r13,QWORD[((-32))+rax] mov r14,QWORD[((-40))+rax] mov r15,QWORD[((-48))+rax] mov QWORD[144+r8],rbx mov QWORD[160+r8],rbp mov QWORD[216+r8],r12 mov QWORD[224+r8],r13 mov QWORD[232+r8],r14 mov QWORD[240+r8],r15 $L$common_seh_tail: mov rdi,QWORD[8+rax] mov rsi,QWORD[16+rax] mov QWORD[152+r8],rax mov QWORD[168+r8],rsi mov QWORD[176+r8],rdi mov rdi,QWORD[40+r9] mov rsi,r8 mov ecx,154 DD 0xa548f3fc mov rsi,r9 xor rcx,rcx mov rdx,QWORD[8+rsi] mov r8,QWORD[rsi] mov r9,QWORD[16+rsi] mov r10,QWORD[40+rsi] lea r11,[56+rsi] lea r12,[24+rsi] mov QWORD[32+rsp],r10 mov QWORD[40+rsp],r11 mov QWORD[48+rsp],r12 mov QWORD[56+rsp],rcx call QWORD[__imp_RtlVirtualUnwind] mov eax,1 add rsp,64 popfq pop r15 pop r14 pop r13 pop r12 pop rbp pop rbx pop rdi pop rsi DB 0F3h,0C3h ;repret section .pdata rdata align=4 ALIGN 4 DD $L$SEH_begin_bn_mul_mont wrt ..imagebase DD $L$SEH_end_bn_mul_mont wrt ..imagebase DD $L$SEH_info_bn_mul_mont wrt ..imagebase DD $L$SEH_begin_bn_mul4x_mont wrt ..imagebase DD $L$SEH_end_bn_mul4x_mont wrt ..imagebase DD $L$SEH_info_bn_mul4x_mont wrt ..imagebase DD $L$SEH_begin_bn_sqr8x_mont wrt ..imagebase DD $L$SEH_end_bn_sqr8x_mont wrt ..imagebase DD $L$SEH_info_bn_sqr8x_mont wrt ..imagebase section .xdata rdata align=8 ALIGN 8 $L$SEH_info_bn_mul_mont: DB 9,0,0,0 DD mul_handler wrt ..imagebase DD $L$mul_body wrt ..imagebase,$L$mul_epilogue wrt ..imagebase $L$SEH_info_bn_mul4x_mont: DB 9,0,0,0 DD mul_handler wrt ..imagebase DD $L$mul4x_body wrt ..imagebase,$L$mul4x_epilogue wrt ..imagebase $L$SEH_info_bn_sqr8x_mont: DB 9,0,0,0 DD sqr_handler wrt ..imagebase DD $L$sqr8x_prologue wrt ..imagebase,$L$sqr8x_body wrt ..imagebase,$L$sqr8x_epilogue wrt ..imagebase ALIGN 8
frame 1, 16 frame 2, 06 frame 3, 06 frame 0, 06 frame 3, 06 endanim
/*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include "mitkUndoController.h" #include "mitkInteractionConst.h" #include "mitkLimitedLinearUndo.h" #include "mitkRenderingManager.h" #include "mitkVerboseLimitedLinearUndo.h" // static member-variables init. mitk::UndoModel::Pointer mitk::UndoController::m_CurUndoModel; mitk::UndoController::UndoModelMap mitk::UndoController::m_UndoModelList; mitk::UndoController::UndoType mitk::UndoController::m_CurUndoType; // const mitk::UndoController::UndoType mitk::UndoController::DEFAULTUNDOMODEL = LIMITEDLINEARUNDO; const mitk::UndoController::UndoType mitk::UndoController::DEFAULTUNDOMODEL = VERBOSE_LIMITEDLINEARUNDO; mitk::UndoController::UndoController(UndoType undoType) { if (SwitchUndoModel(undoType) == false) // existiert noch nicht in static-Liste { switch (undoType) { case LIMITEDLINEARUNDO: m_CurUndoModel = mitk::LimitedLinearUndo::New(); m_CurUndoType = undoType; m_UndoModelList.insert(UndoModelMap::value_type(undoType, m_CurUndoModel)); break; case VERBOSE_LIMITEDLINEARUNDO: m_CurUndoModel = mitk::VerboseLimitedLinearUndo::New(); m_CurUndoType = undoType; m_UndoModelList.insert(UndoModelMap::value_type(undoType, m_CurUndoModel)); break; // case ### // insert here, in add- and RemoveUndoModel new sets of UndoModels! // break; default: m_CurUndoModel = VerboseLimitedLinearUndo::New(); m_CurUndoType = undoType; m_UndoModelList.insert(UndoModelMap::value_type(undoType, m_CurUndoModel)); } } } mitk::UndoController::~UndoController() { } bool mitk::UndoController::SetOperationEvent(UndoStackItem *operationEvent) { m_CurUndoModel->SetOperationEvent(operationEvent); return true; } bool mitk::UndoController::Undo() { return this->Undo(true); } bool mitk::UndoController::Undo(bool fine) { bool ret = m_CurUndoModel->Undo(fine); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); return ret; } bool mitk::UndoController::Redo() { return this->Redo(true); } bool mitk::UndoController::Redo(bool fine) { bool ret = m_CurUndoModel->Redo(fine); mitk::RenderingManager::GetInstance()->RequestUpdateAll(); return ret; } void mitk::UndoController::Clear() { m_CurUndoModel->Clear(); } void mitk::UndoController::ClearRedoList() { m_CurUndoModel->ClearRedoList(); } bool mitk::UndoController::RedoListEmpty() { return m_CurUndoModel->RedoListEmpty(); } //##Documentation //##Switches the UndoModel to the given Type //##if there is no equal Type in List, then return false bool mitk::UndoController::SwitchUndoModel(UndoType undoType) { if (m_CurUndoType == undoType) { return true; // already switched, don't need to be switched! } auto undoModelIter = m_UndoModelList.find(undoType); if (undoModelIter == m_UndoModelList.end()) { // undoType not found in List return false; } // found-> switch to UndoModel m_CurUndoModel = (undoModelIter)->second; m_CurUndoType = (undoModelIter)->first; return true; } //##Documentation //##adds a new kind of UndoModel to the set of UndoModels //##and switches to that UndoModel //##if the UndoModel exists already in the List, then nothing is done bool mitk::UndoController::AddUndoModel(UndoType undoType) { if (m_UndoModelList.find(undoType) != m_UndoModelList.end()) { // UndoModel already exists return false; } // doesn't already exist in list switch (undoType) { case LIMITEDLINEARUNDO: m_CurUndoModel = LimitedLinearUndo::New(); m_CurUndoType = undoType; m_UndoModelList.insert(UndoModelMap::value_type(undoType, m_CurUndoModel)); break; case VERBOSE_LIMITEDLINEARUNDO: m_CurUndoModel = VerboseLimitedLinearUndo::New(); m_CurUndoType = undoType; m_UndoModelList.insert(UndoModelMap::value_type(undoType, m_CurUndoModel)); break; default: // that undoType is not implemented! return false; } return true; } //##Documentation //##Removes an UndoModel from the set of UndoModels //##If that UndoModel is currently selected, then the DefaultUndoModel(const) is set. //##If the default is not in List, then the first UndoModel is set. //##UndoList may not be empty, so if the UndoType is the last, then return false; bool mitk::UndoController::RemoveUndoModel(UndoType undoType) { if (m_UndoModelList.size() < 2) { // for no empty m_UndoModelList return false; } // try deleting Element int ok = m_UndoModelList.erase(undoType); if (ok == 0) { // delete unsucessful; Element of undoType not found return false; } // if m_CurUndoModel is the one removed, then change it to default or to the next or first if (m_CurUndoType == undoType) { // we have to change m_CurUndoModel and m_CurUndoType to an existing Model // if defaultUndoModel exists, then set to default auto undoModelIter = m_UndoModelList.find(DEFAULTUNDOMODEL); if (undoModelIter == m_UndoModelList.end()) { // DefaultUndoModel does not exists in m_CurUndoModelList undoModelIter = m_UndoModelList.begin(); } m_CurUndoModel = (undoModelIter)->second; m_CurUndoType = (undoModelIter)->first; return true; } // m_CurUndoType was not undoType and is not changed return true; } int mitk::UndoController::GetLastObjectEventIdInList() { return m_CurUndoModel->GetLastObjectEventIdInList(); } int mitk::UndoController::GetLastGroupEventIdInList() { return m_CurUndoModel->GetLastGroupEventIdInList(); } mitk::OperationEvent *mitk::UndoController::GetLastOfType(OperationActor *destination, OperationType opType) { return m_CurUndoModel->GetLastOfType(destination, opType); } mitk::UndoModel *mitk::UndoController::GetCurrentUndoModel() { return m_CurUndoModel; }
; A044235: Numbers n such that string 6,0 occurs in the base 8 representation of n but not of n-1. ; 48,112,176,240,304,368,384,432,496,560,624,688,752,816,880,896,944,1008,1072,1136,1200,1264,1328,1392,1408,1456,1520,1584,1648,1712,1776,1840,1904,1920,1968,2032,2096,2160,2224,2288,2352 mov $5,$0 add $5,1 mov $7,$0 lpb $5 mov $0,$7 sub $5,1 sub $0,$5 mov $2,4 mov $3,$0 lpb $2 mov $4,2 lpb $4 mov $4,$3 lpe mov $2,3 add $4,1 add $4,$3 mod $4,9 pow $2,$4 lpe mov $6,$2 sub $6,1 mul $6,16 add $6,16 add $1,$6 lpe
kernel: file format elf32-i386 Disassembly of section .text: 80100000 <multiboot_header>: 80100000: 02 b0 ad 1b 00 00 add 0x1bad(%eax),%dh 80100006: 00 00 add %al,(%eax) 80100008: fe 4f 52 decb 0x52(%edi) 8010000b: e4 .byte 0xe4 8010000c <entry>: # Entering xv6 on boot processor, with paging off. .globl entry entry: # Turn on page size extension for 4Mbyte pages movl %cr4, %eax 8010000c: 0f 20 e0 mov %cr4,%eax orl $(CR4_PSE), %eax 8010000f: 83 c8 10 or $0x10,%eax movl %eax, %cr4 80100012: 0f 22 e0 mov %eax,%cr4 # Set page directory movl $(V2P_WO(entrypgdir)), %eax 80100015: b8 00 90 10 00 mov $0x109000,%eax movl %eax, %cr3 8010001a: 0f 22 d8 mov %eax,%cr3 # Turn on paging. movl %cr0, %eax 8010001d: 0f 20 c0 mov %cr0,%eax orl $(CR0_PG|CR0_WP), %eax 80100020: 0d 00 00 01 80 or $0x80010000,%eax movl %eax, %cr0 80100025: 0f 22 c0 mov %eax,%cr0 # Set up the stack pointer. movl $(stack + KSTACKSIZE), %esp 80100028: bc c0 b5 10 80 mov $0x8010b5c0,%esp # Jump to main(), and switch to executing at # high addresses. The indirect call is needed because # the assembler produces a PC-relative instruction # for a direct jump. mov $main, %eax 8010002d: b8 f0 2d 10 80 mov $0x80102df0,%eax jmp *%eax 80100032: ff e0 jmp *%eax 80100034: 66 90 xchg %ax,%ax 80100036: 66 90 xchg %ax,%ax 80100038: 66 90 xchg %ax,%ax 8010003a: 66 90 xchg %ax,%ax 8010003c: 66 90 xchg %ax,%ax 8010003e: 66 90 xchg %ax,%ax 80100040 <binit>: struct buf head; } bcache; void binit(void) { 80100040: 55 push %ebp 80100041: 89 e5 mov %esp,%ebp 80100043: 53 push %ebx //PAGEBREAK! // Create linked list of buffers bcache.head.prev = &bcache.head; bcache.head.next = &bcache.head; for(b = bcache.buf; b < bcache.buf+NBUF; b++){ 80100044: bb f4 b5 10 80 mov $0x8010b5f4,%ebx { 80100049: 83 ec 14 sub $0x14,%esp initlock(&bcache.lock, "bcache"); 8010004c: c7 44 24 04 e0 6b 10 movl $0x80106be0,0x4(%esp) 80100053: 80 80100054: c7 04 24 c0 b5 10 80 movl $0x8010b5c0,(%esp) 8010005b: e8 10 40 00 00 call 80104070 <initlock> bcache.head.next = &bcache.head; 80100060: ba bc fc 10 80 mov $0x8010fcbc,%edx bcache.head.prev = &bcache.head; 80100065: c7 05 0c fd 10 80 bc movl $0x8010fcbc,0x8010fd0c 8010006c: fc 10 80 bcache.head.next = &bcache.head; 8010006f: c7 05 10 fd 10 80 bc movl $0x8010fcbc,0x8010fd10 80100076: fc 10 80 80100079: eb 09 jmp 80100084 <binit+0x44> 8010007b: 90 nop 8010007c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80100080: 89 da mov %ebx,%edx for(b = bcache.buf; b < bcache.buf+NBUF; b++){ 80100082: 89 c3 mov %eax,%ebx 80100084: 8d 43 0c lea 0xc(%ebx),%eax b->next = bcache.head.next; 80100087: 89 53 54 mov %edx,0x54(%ebx) b->prev = &bcache.head; 8010008a: c7 43 50 bc fc 10 80 movl $0x8010fcbc,0x50(%ebx) initsleeplock(&b->lock, "buffer"); 80100091: 89 04 24 mov %eax,(%esp) 80100094: c7 44 24 04 e7 6b 10 movl $0x80106be7,0x4(%esp) 8010009b: 80 8010009c: e8 9f 3e 00 00 call 80103f40 <initsleeplock> bcache.head.next->prev = b; 801000a1: a1 10 fd 10 80 mov 0x8010fd10,%eax 801000a6: 89 58 50 mov %ebx,0x50(%eax) for(b = bcache.buf; b < bcache.buf+NBUF; b++){ 801000a9: 8d 83 5c 02 00 00 lea 0x25c(%ebx),%eax 801000af: 3d bc fc 10 80 cmp $0x8010fcbc,%eax bcache.head.next = b; 801000b4: 89 1d 10 fd 10 80 mov %ebx,0x8010fd10 for(b = bcache.buf; b < bcache.buf+NBUF; b++){ 801000ba: 75 c4 jne 80100080 <binit+0x40> } } 801000bc: 83 c4 14 add $0x14,%esp 801000bf: 5b pop %ebx 801000c0: 5d pop %ebp 801000c1: c3 ret 801000c2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801000c9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801000d0 <bread>: } // Return a locked buf with the contents of the indicated block. struct buf* bread(uint dev, uint blockno) { 801000d0: 55 push %ebp 801000d1: 89 e5 mov %esp,%ebp 801000d3: 57 push %edi 801000d4: 56 push %esi 801000d5: 53 push %ebx 801000d6: 83 ec 1c sub $0x1c,%esp 801000d9: 8b 75 08 mov 0x8(%ebp),%esi acquire(&bcache.lock); 801000dc: c7 04 24 c0 b5 10 80 movl $0x8010b5c0,(%esp) { 801000e3: 8b 7d 0c mov 0xc(%ebp),%edi acquire(&bcache.lock); 801000e6: e8 f5 40 00 00 call 801041e0 <acquire> for(b = bcache.head.next; b != &bcache.head; b = b->next){ 801000eb: 8b 1d 10 fd 10 80 mov 0x8010fd10,%ebx 801000f1: 81 fb bc fc 10 80 cmp $0x8010fcbc,%ebx 801000f7: 75 12 jne 8010010b <bread+0x3b> 801000f9: eb 25 jmp 80100120 <bread+0x50> 801000fb: 90 nop 801000fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80100100: 8b 5b 54 mov 0x54(%ebx),%ebx 80100103: 81 fb bc fc 10 80 cmp $0x8010fcbc,%ebx 80100109: 74 15 je 80100120 <bread+0x50> if(b->dev == dev && b->blockno == blockno){ 8010010b: 3b 73 04 cmp 0x4(%ebx),%esi 8010010e: 75 f0 jne 80100100 <bread+0x30> 80100110: 3b 7b 08 cmp 0x8(%ebx),%edi 80100113: 75 eb jne 80100100 <bread+0x30> b->refcnt++; 80100115: 83 43 4c 01 addl $0x1,0x4c(%ebx) 80100119: eb 3f jmp 8010015a <bread+0x8a> 8010011b: 90 nop 8010011c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(b = bcache.head.prev; b != &bcache.head; b = b->prev){ 80100120: 8b 1d 0c fd 10 80 mov 0x8010fd0c,%ebx 80100126: 81 fb bc fc 10 80 cmp $0x8010fcbc,%ebx 8010012c: 75 0d jne 8010013b <bread+0x6b> 8010012e: eb 58 jmp 80100188 <bread+0xb8> 80100130: 8b 5b 50 mov 0x50(%ebx),%ebx 80100133: 81 fb bc fc 10 80 cmp $0x8010fcbc,%ebx 80100139: 74 4d je 80100188 <bread+0xb8> if(b->refcnt == 0 && (b->flags & B_DIRTY) == 0) { 8010013b: 8b 43 4c mov 0x4c(%ebx),%eax 8010013e: 85 c0 test %eax,%eax 80100140: 75 ee jne 80100130 <bread+0x60> 80100142: f6 03 04 testb $0x4,(%ebx) 80100145: 75 e9 jne 80100130 <bread+0x60> b->dev = dev; 80100147: 89 73 04 mov %esi,0x4(%ebx) b->blockno = blockno; 8010014a: 89 7b 08 mov %edi,0x8(%ebx) b->flags = 0; 8010014d: c7 03 00 00 00 00 movl $0x0,(%ebx) b->refcnt = 1; 80100153: c7 43 4c 01 00 00 00 movl $0x1,0x4c(%ebx) release(&bcache.lock); 8010015a: c7 04 24 c0 b5 10 80 movl $0x8010b5c0,(%esp) 80100161: e8 ea 40 00 00 call 80104250 <release> acquiresleep(&b->lock); 80100166: 8d 43 0c lea 0xc(%ebx),%eax 80100169: 89 04 24 mov %eax,(%esp) 8010016c: e8 0f 3e 00 00 call 80103f80 <acquiresleep> struct buf *b; b = bget(dev, blockno); if((b->flags & B_VALID) == 0) { 80100171: f6 03 02 testb $0x2,(%ebx) 80100174: 75 08 jne 8010017e <bread+0xae> iderw(b); 80100176: 89 1c 24 mov %ebx,(%esp) 80100179: e8 a2 1f 00 00 call 80102120 <iderw> } return b; } 8010017e: 83 c4 1c add $0x1c,%esp 80100181: 89 d8 mov %ebx,%eax 80100183: 5b pop %ebx 80100184: 5e pop %esi 80100185: 5f pop %edi 80100186: 5d pop %ebp 80100187: c3 ret panic("bget: no buffers"); 80100188: c7 04 24 ee 6b 10 80 movl $0x80106bee,(%esp) 8010018f: e8 cc 01 00 00 call 80100360 <panic> 80100194: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 8010019a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 801001a0 <bwrite>: // Write b's contents to disk. Must be locked. void bwrite(struct buf *b) { 801001a0: 55 push %ebp 801001a1: 89 e5 mov %esp,%ebp 801001a3: 53 push %ebx 801001a4: 83 ec 14 sub $0x14,%esp 801001a7: 8b 5d 08 mov 0x8(%ebp),%ebx if(!holdingsleep(&b->lock)) 801001aa: 8d 43 0c lea 0xc(%ebx),%eax 801001ad: 89 04 24 mov %eax,(%esp) 801001b0: e8 6b 3e 00 00 call 80104020 <holdingsleep> 801001b5: 85 c0 test %eax,%eax 801001b7: 74 10 je 801001c9 <bwrite+0x29> panic("bwrite"); b->flags |= B_DIRTY; 801001b9: 83 0b 04 orl $0x4,(%ebx) iderw(b); 801001bc: 89 5d 08 mov %ebx,0x8(%ebp) } 801001bf: 83 c4 14 add $0x14,%esp 801001c2: 5b pop %ebx 801001c3: 5d pop %ebp iderw(b); 801001c4: e9 57 1f 00 00 jmp 80102120 <iderw> panic("bwrite"); 801001c9: c7 04 24 ff 6b 10 80 movl $0x80106bff,(%esp) 801001d0: e8 8b 01 00 00 call 80100360 <panic> 801001d5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801001d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801001e0 <brelse>: // Release a locked buffer. // Move to the head of the MRU list. void brelse(struct buf *b) { 801001e0: 55 push %ebp 801001e1: 89 e5 mov %esp,%ebp 801001e3: 56 push %esi 801001e4: 53 push %ebx 801001e5: 83 ec 10 sub $0x10,%esp 801001e8: 8b 5d 08 mov 0x8(%ebp),%ebx if(!holdingsleep(&b->lock)) 801001eb: 8d 73 0c lea 0xc(%ebx),%esi 801001ee: 89 34 24 mov %esi,(%esp) 801001f1: e8 2a 3e 00 00 call 80104020 <holdingsleep> 801001f6: 85 c0 test %eax,%eax 801001f8: 74 5b je 80100255 <brelse+0x75> panic("brelse"); releasesleep(&b->lock); 801001fa: 89 34 24 mov %esi,(%esp) 801001fd: e8 de 3d 00 00 call 80103fe0 <releasesleep> acquire(&bcache.lock); 80100202: c7 04 24 c0 b5 10 80 movl $0x8010b5c0,(%esp) 80100209: e8 d2 3f 00 00 call 801041e0 <acquire> b->refcnt--; if (b->refcnt == 0) { 8010020e: 83 6b 4c 01 subl $0x1,0x4c(%ebx) 80100212: 75 2f jne 80100243 <brelse+0x63> // no one is waiting for it. b->next->prev = b->prev; 80100214: 8b 43 54 mov 0x54(%ebx),%eax 80100217: 8b 53 50 mov 0x50(%ebx),%edx 8010021a: 89 50 50 mov %edx,0x50(%eax) b->prev->next = b->next; 8010021d: 8b 43 50 mov 0x50(%ebx),%eax 80100220: 8b 53 54 mov 0x54(%ebx),%edx 80100223: 89 50 54 mov %edx,0x54(%eax) b->next = bcache.head.next; 80100226: a1 10 fd 10 80 mov 0x8010fd10,%eax b->prev = &bcache.head; 8010022b: c7 43 50 bc fc 10 80 movl $0x8010fcbc,0x50(%ebx) b->next = bcache.head.next; 80100232: 89 43 54 mov %eax,0x54(%ebx) bcache.head.next->prev = b; 80100235: a1 10 fd 10 80 mov 0x8010fd10,%eax 8010023a: 89 58 50 mov %ebx,0x50(%eax) bcache.head.next = b; 8010023d: 89 1d 10 fd 10 80 mov %ebx,0x8010fd10 } release(&bcache.lock); 80100243: c7 45 08 c0 b5 10 80 movl $0x8010b5c0,0x8(%ebp) } 8010024a: 83 c4 10 add $0x10,%esp 8010024d: 5b pop %ebx 8010024e: 5e pop %esi 8010024f: 5d pop %ebp release(&bcache.lock); 80100250: e9 fb 3f 00 00 jmp 80104250 <release> panic("brelse"); 80100255: c7 04 24 06 6c 10 80 movl $0x80106c06,(%esp) 8010025c: e8 ff 00 00 00 call 80100360 <panic> 80100261: 66 90 xchg %ax,%ax 80100263: 66 90 xchg %ax,%ax 80100265: 66 90 xchg %ax,%ax 80100267: 66 90 xchg %ax,%ax 80100269: 66 90 xchg %ax,%ax 8010026b: 66 90 xchg %ax,%ax 8010026d: 66 90 xchg %ax,%ax 8010026f: 90 nop 80100270 <consoleread>: } } int consoleread(struct inode *ip, char *dst, int n) { 80100270: 55 push %ebp 80100271: 89 e5 mov %esp,%ebp 80100273: 57 push %edi 80100274: 56 push %esi 80100275: 53 push %ebx 80100276: 83 ec 1c sub $0x1c,%esp 80100279: 8b 7d 08 mov 0x8(%ebp),%edi 8010027c: 8b 75 0c mov 0xc(%ebp),%esi uint target; int c; iunlock(ip); 8010027f: 89 3c 24 mov %edi,(%esp) 80100282: e8 09 15 00 00 call 80101790 <iunlock> target = n; acquire(&cons.lock); 80100287: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 8010028e: e8 4d 3f 00 00 call 801041e0 <acquire> while(n > 0){ 80100293: 8b 55 10 mov 0x10(%ebp),%edx 80100296: 85 d2 test %edx,%edx 80100298: 0f 8e bc 00 00 00 jle 8010035a <consoleread+0xea> 8010029e: 8b 5d 10 mov 0x10(%ebp),%ebx 801002a1: eb 25 jmp 801002c8 <consoleread+0x58> 801002a3: 90 nop 801002a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi while(input.r == input.w){ if(myproc()->killed){ 801002a8: e8 f3 33 00 00 call 801036a0 <myproc> 801002ad: 8b 40 24 mov 0x24(%eax),%eax 801002b0: 85 c0 test %eax,%eax 801002b2: 75 74 jne 80100328 <consoleread+0xb8> release(&cons.lock); ilock(ip); return -1; } sleep(&input.r, &cons.lock); 801002b4: c7 44 24 04 20 a5 10 movl $0x8010a520,0x4(%esp) 801002bb: 80 801002bc: c7 04 24 a0 ff 10 80 movl $0x8010ffa0,(%esp) 801002c3: e8 38 39 00 00 call 80103c00 <sleep> while(input.r == input.w){ 801002c8: a1 a0 ff 10 80 mov 0x8010ffa0,%eax 801002cd: 3b 05 a4 ff 10 80 cmp 0x8010ffa4,%eax 801002d3: 74 d3 je 801002a8 <consoleread+0x38> } c = input.buf[input.r++ % INPUT_BUF]; 801002d5: 8d 50 01 lea 0x1(%eax),%edx 801002d8: 89 15 a0 ff 10 80 mov %edx,0x8010ffa0 801002de: 89 c2 mov %eax,%edx 801002e0: 83 e2 7f and $0x7f,%edx 801002e3: 0f b6 8a 20 ff 10 80 movzbl -0x7fef00e0(%edx),%ecx 801002ea: 0f be d1 movsbl %cl,%edx if(c == C('D')){ // EOF 801002ed: 83 fa 04 cmp $0x4,%edx 801002f0: 74 57 je 80100349 <consoleread+0xd9> // caller gets a 0-byte result. input.r--; } break; } *dst++ = c; 801002f2: 83 c6 01 add $0x1,%esi --n; 801002f5: 83 eb 01 sub $0x1,%ebx if(c == '\n') 801002f8: 83 fa 0a cmp $0xa,%edx *dst++ = c; 801002fb: 88 4e ff mov %cl,-0x1(%esi) if(c == '\n') 801002fe: 74 53 je 80100353 <consoleread+0xe3> while(n > 0){ 80100300: 85 db test %ebx,%ebx 80100302: 75 c4 jne 801002c8 <consoleread+0x58> 80100304: 8b 45 10 mov 0x10(%ebp),%eax break; } release(&cons.lock); 80100307: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 8010030e: 89 45 e4 mov %eax,-0x1c(%ebp) 80100311: e8 3a 3f 00 00 call 80104250 <release> ilock(ip); 80100316: 89 3c 24 mov %edi,(%esp) 80100319: e8 92 13 00 00 call 801016b0 <ilock> 8010031e: 8b 45 e4 mov -0x1c(%ebp),%eax return target - n; 80100321: eb 1e jmp 80100341 <consoleread+0xd1> 80100323: 90 nop 80100324: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi release(&cons.lock); 80100328: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 8010032f: e8 1c 3f 00 00 call 80104250 <release> ilock(ip); 80100334: 89 3c 24 mov %edi,(%esp) 80100337: e8 74 13 00 00 call 801016b0 <ilock> return -1; 8010033c: b8 ff ff ff ff mov $0xffffffff,%eax } 80100341: 83 c4 1c add $0x1c,%esp 80100344: 5b pop %ebx 80100345: 5e pop %esi 80100346: 5f pop %edi 80100347: 5d pop %ebp 80100348: c3 ret if(n < target){ 80100349: 39 5d 10 cmp %ebx,0x10(%ebp) 8010034c: 76 05 jbe 80100353 <consoleread+0xe3> input.r--; 8010034e: a3 a0 ff 10 80 mov %eax,0x8010ffa0 80100353: 8b 45 10 mov 0x10(%ebp),%eax 80100356: 29 d8 sub %ebx,%eax 80100358: eb ad jmp 80100307 <consoleread+0x97> while(n > 0){ 8010035a: 31 c0 xor %eax,%eax 8010035c: eb a9 jmp 80100307 <consoleread+0x97> 8010035e: 66 90 xchg %ax,%ax 80100360 <panic>: { 80100360: 55 push %ebp 80100361: 89 e5 mov %esp,%ebp 80100363: 56 push %esi 80100364: 53 push %ebx 80100365: 83 ec 40 sub $0x40,%esp } static inline void cli(void) { asm volatile("cli"); 80100368: fa cli cons.locking = 0; 80100369: c7 05 54 a5 10 80 00 movl $0x0,0x8010a554 80100370: 00 00 00 getcallerpcs(&s, pcs); 80100373: 8d 5d d0 lea -0x30(%ebp),%ebx cprintf("lapicid %d: panic: ", lapicid()); 80100376: e8 e5 23 00 00 call 80102760 <lapicid> 8010037b: 8d 75 f8 lea -0x8(%ebp),%esi 8010037e: c7 04 24 0d 6c 10 80 movl $0x80106c0d,(%esp) 80100385: 89 44 24 04 mov %eax,0x4(%esp) 80100389: e8 c2 02 00 00 call 80100650 <cprintf> cprintf(s); 8010038e: 8b 45 08 mov 0x8(%ebp),%eax 80100391: 89 04 24 mov %eax,(%esp) 80100394: e8 b7 02 00 00 call 80100650 <cprintf> cprintf("\n"); 80100399: c7 04 24 57 75 10 80 movl $0x80107557,(%esp) 801003a0: e8 ab 02 00 00 call 80100650 <cprintf> getcallerpcs(&s, pcs); 801003a5: 8d 45 08 lea 0x8(%ebp),%eax 801003a8: 89 5c 24 04 mov %ebx,0x4(%esp) 801003ac: 89 04 24 mov %eax,(%esp) 801003af: e8 dc 3c 00 00 call 80104090 <getcallerpcs> 801003b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi cprintf(" %p", pcs[i]); 801003b8: 8b 03 mov (%ebx),%eax 801003ba: 83 c3 04 add $0x4,%ebx 801003bd: c7 04 24 21 6c 10 80 movl $0x80106c21,(%esp) 801003c4: 89 44 24 04 mov %eax,0x4(%esp) 801003c8: e8 83 02 00 00 call 80100650 <cprintf> for(i=0; i<10; i++) 801003cd: 39 f3 cmp %esi,%ebx 801003cf: 75 e7 jne 801003b8 <panic+0x58> panicked = 1; // freeze other CPU 801003d1: c7 05 58 a5 10 80 01 movl $0x1,0x8010a558 801003d8: 00 00 00 801003db: eb fe jmp 801003db <panic+0x7b> 801003dd: 8d 76 00 lea 0x0(%esi),%esi 801003e0 <consputc>: if(panicked){ 801003e0: 8b 15 58 a5 10 80 mov 0x8010a558,%edx 801003e6: 85 d2 test %edx,%edx 801003e8: 74 06 je 801003f0 <consputc+0x10> 801003ea: fa cli 801003eb: eb fe jmp 801003eb <consputc+0xb> 801003ed: 8d 76 00 lea 0x0(%esi),%esi { 801003f0: 55 push %ebp 801003f1: 89 e5 mov %esp,%ebp 801003f3: 57 push %edi 801003f4: 56 push %esi 801003f5: 53 push %ebx 801003f6: 89 c3 mov %eax,%ebx 801003f8: 83 ec 1c sub $0x1c,%esp if(c == BACKSPACE){ 801003fb: 3d 00 01 00 00 cmp $0x100,%eax 80100400: 0f 84 ac 00 00 00 je 801004b2 <consputc+0xd2> uartputc(c); 80100406: 89 04 24 mov %eax,(%esp) 80100409: e8 42 53 00 00 call 80105750 <uartputc> asm volatile("out %0,%1" : : "a" (data), "d" (port)); 8010040e: bf d4 03 00 00 mov $0x3d4,%edi 80100413: b8 0e 00 00 00 mov $0xe,%eax 80100418: 89 fa mov %edi,%edx 8010041a: ee out %al,(%dx) asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 8010041b: be d5 03 00 00 mov $0x3d5,%esi 80100420: 89 f2 mov %esi,%edx 80100422: ec in (%dx),%al pos = inb(CRTPORT+1) << 8; 80100423: 0f b6 c8 movzbl %al,%ecx asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80100426: 89 fa mov %edi,%edx 80100428: c1 e1 08 shl $0x8,%ecx 8010042b: b8 0f 00 00 00 mov $0xf,%eax 80100430: ee out %al,(%dx) asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80100431: 89 f2 mov %esi,%edx 80100433: ec in (%dx),%al pos |= inb(CRTPORT+1); 80100434: 0f b6 c0 movzbl %al,%eax 80100437: 09 c1 or %eax,%ecx if(c == '\n') 80100439: 83 fb 0a cmp $0xa,%ebx 8010043c: 0f 84 0d 01 00 00 je 8010054f <consputc+0x16f> else if(c == BACKSPACE){ 80100442: 81 fb 00 01 00 00 cmp $0x100,%ebx 80100448: 0f 84 e8 00 00 00 je 80100536 <consputc+0x156> crt[pos++] = (c&0xff) | 0x0700; // black on white 8010044e: 0f b6 db movzbl %bl,%ebx 80100451: 80 cf 07 or $0x7,%bh 80100454: 8d 79 01 lea 0x1(%ecx),%edi 80100457: 66 89 9c 09 00 80 0b mov %bx,-0x7ff48000(%ecx,%ecx,1) 8010045e: 80 if(pos < 0 || pos > 25*80) 8010045f: 81 ff d0 07 00 00 cmp $0x7d0,%edi 80100465: 0f 87 bf 00 00 00 ja 8010052a <consputc+0x14a> if((pos/80) >= 24){ // Scroll up. 8010046b: 81 ff 7f 07 00 00 cmp $0x77f,%edi 80100471: 7f 68 jg 801004db <consputc+0xfb> 80100473: 89 f8 mov %edi,%eax 80100475: 89 fb mov %edi,%ebx 80100477: c1 e8 08 shr $0x8,%eax 8010047a: 89 c6 mov %eax,%esi 8010047c: 8d 8c 3f 00 80 0b 80 lea -0x7ff48000(%edi,%edi,1),%ecx asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80100483: bf d4 03 00 00 mov $0x3d4,%edi 80100488: b8 0e 00 00 00 mov $0xe,%eax 8010048d: 89 fa mov %edi,%edx 8010048f: ee out %al,(%dx) 80100490: 89 f0 mov %esi,%eax 80100492: b2 d5 mov $0xd5,%dl 80100494: ee out %al,(%dx) 80100495: b8 0f 00 00 00 mov $0xf,%eax 8010049a: 89 fa mov %edi,%edx 8010049c: ee out %al,(%dx) 8010049d: 89 d8 mov %ebx,%eax 8010049f: b2 d5 mov $0xd5,%dl 801004a1: ee out %al,(%dx) crt[pos] = ' ' | 0x0700; 801004a2: b8 20 07 00 00 mov $0x720,%eax 801004a7: 66 89 01 mov %ax,(%ecx) } 801004aa: 83 c4 1c add $0x1c,%esp 801004ad: 5b pop %ebx 801004ae: 5e pop %esi 801004af: 5f pop %edi 801004b0: 5d pop %ebp 801004b1: c3 ret uartputc('\b'); uartputc(' '); uartputc('\b'); 801004b2: c7 04 24 08 00 00 00 movl $0x8,(%esp) 801004b9: e8 92 52 00 00 call 80105750 <uartputc> 801004be: c7 04 24 20 00 00 00 movl $0x20,(%esp) 801004c5: e8 86 52 00 00 call 80105750 <uartputc> 801004ca: c7 04 24 08 00 00 00 movl $0x8,(%esp) 801004d1: e8 7a 52 00 00 call 80105750 <uartputc> 801004d6: e9 33 ff ff ff jmp 8010040e <consputc+0x2e> memmove(crt, crt+80, sizeof(crt[0])*23*80); 801004db: c7 44 24 08 60 0e 00 movl $0xe60,0x8(%esp) 801004e2: 00 pos -= 80; 801004e3: 8d 5f b0 lea -0x50(%edi),%ebx memmove(crt, crt+80, sizeof(crt[0])*23*80); 801004e6: c7 44 24 04 a0 80 0b movl $0x800b80a0,0x4(%esp) 801004ed: 80 memset(crt+pos, 0, sizeof(crt[0])*(24*80 - pos)); 801004ee: 8d b4 1b 00 80 0b 80 lea -0x7ff48000(%ebx,%ebx,1),%esi memmove(crt, crt+80, sizeof(crt[0])*23*80); 801004f5: c7 04 24 00 80 0b 80 movl $0x800b8000,(%esp) 801004fc: e8 3f 3e 00 00 call 80104340 <memmove> memset(crt+pos, 0, sizeof(crt[0])*(24*80 - pos)); 80100501: b8 d0 07 00 00 mov $0x7d0,%eax 80100506: 29 f8 sub %edi,%eax 80100508: 01 c0 add %eax,%eax 8010050a: 89 34 24 mov %esi,(%esp) 8010050d: 89 44 24 08 mov %eax,0x8(%esp) 80100511: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80100518: 00 80100519: e8 82 3d 00 00 call 801042a0 <memset> 8010051e: 89 f1 mov %esi,%ecx 80100520: be 07 00 00 00 mov $0x7,%esi 80100525: e9 59 ff ff ff jmp 80100483 <consputc+0xa3> panic("pos under/overflow"); 8010052a: c7 04 24 25 6c 10 80 movl $0x80106c25,(%esp) 80100531: e8 2a fe ff ff call 80100360 <panic> if(pos > 0) --pos; 80100536: 85 c9 test %ecx,%ecx 80100538: 8d 79 ff lea -0x1(%ecx),%edi 8010053b: 0f 85 1e ff ff ff jne 8010045f <consputc+0x7f> 80100541: b9 00 80 0b 80 mov $0x800b8000,%ecx 80100546: 31 db xor %ebx,%ebx 80100548: 31 f6 xor %esi,%esi 8010054a: e9 34 ff ff ff jmp 80100483 <consputc+0xa3> pos += 80 - pos%80; 8010054f: 89 c8 mov %ecx,%eax 80100551: ba 67 66 66 66 mov $0x66666667,%edx 80100556: f7 ea imul %edx 80100558: c1 ea 05 shr $0x5,%edx 8010055b: 8d 04 92 lea (%edx,%edx,4),%eax 8010055e: c1 e0 04 shl $0x4,%eax 80100561: 8d 78 50 lea 0x50(%eax),%edi 80100564: e9 f6 fe ff ff jmp 8010045f <consputc+0x7f> 80100569: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80100570 <printint>: { 80100570: 55 push %ebp 80100571: 89 e5 mov %esp,%ebp 80100573: 57 push %edi 80100574: 56 push %esi 80100575: 89 d6 mov %edx,%esi 80100577: 53 push %ebx 80100578: 83 ec 1c sub $0x1c,%esp if(sign && (sign = xx < 0)) 8010057b: 85 c9 test %ecx,%ecx 8010057d: 74 61 je 801005e0 <printint+0x70> 8010057f: 85 c0 test %eax,%eax 80100581: 79 5d jns 801005e0 <printint+0x70> x = -xx; 80100583: f7 d8 neg %eax 80100585: bf 01 00 00 00 mov $0x1,%edi i = 0; 8010058a: 31 c9 xor %ecx,%ecx 8010058c: eb 04 jmp 80100592 <printint+0x22> 8010058e: 66 90 xchg %ax,%ax buf[i++] = digits[x % base]; 80100590: 89 d9 mov %ebx,%ecx 80100592: 31 d2 xor %edx,%edx 80100594: f7 f6 div %esi 80100596: 8d 59 01 lea 0x1(%ecx),%ebx 80100599: 0f b6 92 50 6c 10 80 movzbl -0x7fef93b0(%edx),%edx }while((x /= base) != 0); 801005a0: 85 c0 test %eax,%eax buf[i++] = digits[x % base]; 801005a2: 88 54 1d d7 mov %dl,-0x29(%ebp,%ebx,1) }while((x /= base) != 0); 801005a6: 75 e8 jne 80100590 <printint+0x20> if(sign) 801005a8: 85 ff test %edi,%edi buf[i++] = digits[x % base]; 801005aa: 89 d8 mov %ebx,%eax if(sign) 801005ac: 74 08 je 801005b6 <printint+0x46> buf[i++] = '-'; 801005ae: 8d 59 02 lea 0x2(%ecx),%ebx 801005b1: c6 44 05 d8 2d movb $0x2d,-0x28(%ebp,%eax,1) while(--i >= 0) 801005b6: 83 eb 01 sub $0x1,%ebx 801005b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi consputc(buf[i]); 801005c0: 0f be 44 1d d8 movsbl -0x28(%ebp,%ebx,1),%eax while(--i >= 0) 801005c5: 83 eb 01 sub $0x1,%ebx consputc(buf[i]); 801005c8: e8 13 fe ff ff call 801003e0 <consputc> while(--i >= 0) 801005cd: 83 fb ff cmp $0xffffffff,%ebx 801005d0: 75 ee jne 801005c0 <printint+0x50> } 801005d2: 83 c4 1c add $0x1c,%esp 801005d5: 5b pop %ebx 801005d6: 5e pop %esi 801005d7: 5f pop %edi 801005d8: 5d pop %ebp 801005d9: c3 ret 801005da: 8d b6 00 00 00 00 lea 0x0(%esi),%esi x = xx; 801005e0: 31 ff xor %edi,%edi 801005e2: eb a6 jmp 8010058a <printint+0x1a> 801005e4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801005ea: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 801005f0 <consolewrite>: int consolewrite(struct inode *ip, char *buf, int n) { 801005f0: 55 push %ebp 801005f1: 89 e5 mov %esp,%ebp 801005f3: 57 push %edi 801005f4: 56 push %esi 801005f5: 53 push %ebx 801005f6: 83 ec 1c sub $0x1c,%esp int i; iunlock(ip); 801005f9: 8b 45 08 mov 0x8(%ebp),%eax { 801005fc: 8b 75 10 mov 0x10(%ebp),%esi iunlock(ip); 801005ff: 89 04 24 mov %eax,(%esp) 80100602: e8 89 11 00 00 call 80101790 <iunlock> acquire(&cons.lock); 80100607: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 8010060e: e8 cd 3b 00 00 call 801041e0 <acquire> 80100613: 8b 7d 0c mov 0xc(%ebp),%edi for(i = 0; i < n; i++) 80100616: 85 f6 test %esi,%esi 80100618: 8d 1c 37 lea (%edi,%esi,1),%ebx 8010061b: 7e 12 jle 8010062f <consolewrite+0x3f> 8010061d: 8d 76 00 lea 0x0(%esi),%esi consputc(buf[i] & 0xff); 80100620: 0f b6 07 movzbl (%edi),%eax 80100623: 83 c7 01 add $0x1,%edi 80100626: e8 b5 fd ff ff call 801003e0 <consputc> for(i = 0; i < n; i++) 8010062b: 39 df cmp %ebx,%edi 8010062d: 75 f1 jne 80100620 <consolewrite+0x30> release(&cons.lock); 8010062f: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 80100636: e8 15 3c 00 00 call 80104250 <release> ilock(ip); 8010063b: 8b 45 08 mov 0x8(%ebp),%eax 8010063e: 89 04 24 mov %eax,(%esp) 80100641: e8 6a 10 00 00 call 801016b0 <ilock> return n; } 80100646: 83 c4 1c add $0x1c,%esp 80100649: 89 f0 mov %esi,%eax 8010064b: 5b pop %ebx 8010064c: 5e pop %esi 8010064d: 5f pop %edi 8010064e: 5d pop %ebp 8010064f: c3 ret 80100650 <cprintf>: { 80100650: 55 push %ebp 80100651: 89 e5 mov %esp,%ebp 80100653: 57 push %edi 80100654: 56 push %esi 80100655: 53 push %ebx 80100656: 83 ec 1c sub $0x1c,%esp locking = cons.locking; 80100659: a1 54 a5 10 80 mov 0x8010a554,%eax if(locking) 8010065e: 85 c0 test %eax,%eax locking = cons.locking; 80100660: 89 45 e0 mov %eax,-0x20(%ebp) if(locking) 80100663: 0f 85 27 01 00 00 jne 80100790 <cprintf+0x140> if (fmt == 0) 80100669: 8b 45 08 mov 0x8(%ebp),%eax 8010066c: 85 c0 test %eax,%eax 8010066e: 89 c1 mov %eax,%ecx 80100670: 0f 84 2b 01 00 00 je 801007a1 <cprintf+0x151> for(i = 0; (c = fmt[i] & 0xff) != 0; i++){ 80100676: 0f b6 00 movzbl (%eax),%eax 80100679: 31 db xor %ebx,%ebx 8010067b: 89 cf mov %ecx,%edi 8010067d: 8d 75 0c lea 0xc(%ebp),%esi 80100680: 85 c0 test %eax,%eax 80100682: 75 4c jne 801006d0 <cprintf+0x80> 80100684: eb 5f jmp 801006e5 <cprintf+0x95> 80100686: 66 90 xchg %ax,%ax c = fmt[++i] & 0xff; 80100688: 83 c3 01 add $0x1,%ebx 8010068b: 0f b6 14 1f movzbl (%edi,%ebx,1),%edx if(c == 0) 8010068f: 85 d2 test %edx,%edx 80100691: 74 52 je 801006e5 <cprintf+0x95> switch(c){ 80100693: 83 fa 70 cmp $0x70,%edx 80100696: 74 72 je 8010070a <cprintf+0xba> 80100698: 7f 66 jg 80100700 <cprintf+0xb0> 8010069a: 83 fa 25 cmp $0x25,%edx 8010069d: 8d 76 00 lea 0x0(%esi),%esi 801006a0: 0f 84 a2 00 00 00 je 80100748 <cprintf+0xf8> 801006a6: 83 fa 64 cmp $0x64,%edx 801006a9: 75 7d jne 80100728 <cprintf+0xd8> printint(*argp++, 10, 1); 801006ab: 8d 46 04 lea 0x4(%esi),%eax 801006ae: b9 01 00 00 00 mov $0x1,%ecx 801006b3: 89 45 e4 mov %eax,-0x1c(%ebp) 801006b6: 8b 06 mov (%esi),%eax 801006b8: ba 0a 00 00 00 mov $0xa,%edx 801006bd: e8 ae fe ff ff call 80100570 <printint> 801006c2: 8b 75 e4 mov -0x1c(%ebp),%esi for(i = 0; (c = fmt[i] & 0xff) != 0; i++){ 801006c5: 83 c3 01 add $0x1,%ebx 801006c8: 0f b6 04 1f movzbl (%edi,%ebx,1),%eax 801006cc: 85 c0 test %eax,%eax 801006ce: 74 15 je 801006e5 <cprintf+0x95> if(c != '%'){ 801006d0: 83 f8 25 cmp $0x25,%eax 801006d3: 74 b3 je 80100688 <cprintf+0x38> consputc(c); 801006d5: e8 06 fd ff ff call 801003e0 <consputc> for(i = 0; (c = fmt[i] & 0xff) != 0; i++){ 801006da: 83 c3 01 add $0x1,%ebx 801006dd: 0f b6 04 1f movzbl (%edi,%ebx,1),%eax 801006e1: 85 c0 test %eax,%eax 801006e3: 75 eb jne 801006d0 <cprintf+0x80> if(locking) 801006e5: 8b 45 e0 mov -0x20(%ebp),%eax 801006e8: 85 c0 test %eax,%eax 801006ea: 74 0c je 801006f8 <cprintf+0xa8> release(&cons.lock); 801006ec: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 801006f3: e8 58 3b 00 00 call 80104250 <release> } 801006f8: 83 c4 1c add $0x1c,%esp 801006fb: 5b pop %ebx 801006fc: 5e pop %esi 801006fd: 5f pop %edi 801006fe: 5d pop %ebp 801006ff: c3 ret switch(c){ 80100700: 83 fa 73 cmp $0x73,%edx 80100703: 74 53 je 80100758 <cprintf+0x108> 80100705: 83 fa 78 cmp $0x78,%edx 80100708: 75 1e jne 80100728 <cprintf+0xd8> printint(*argp++, 16, 0); 8010070a: 8d 46 04 lea 0x4(%esi),%eax 8010070d: 31 c9 xor %ecx,%ecx 8010070f: 89 45 e4 mov %eax,-0x1c(%ebp) 80100712: 8b 06 mov (%esi),%eax 80100714: ba 10 00 00 00 mov $0x10,%edx 80100719: e8 52 fe ff ff call 80100570 <printint> 8010071e: 8b 75 e4 mov -0x1c(%ebp),%esi break; 80100721: eb a2 jmp 801006c5 <cprintf+0x75> 80100723: 90 nop 80100724: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi consputc('%'); 80100728: b8 25 00 00 00 mov $0x25,%eax 8010072d: 89 55 e4 mov %edx,-0x1c(%ebp) 80100730: e8 ab fc ff ff call 801003e0 <consputc> consputc(c); 80100735: 8b 55 e4 mov -0x1c(%ebp),%edx 80100738: 89 d0 mov %edx,%eax 8010073a: e8 a1 fc ff ff call 801003e0 <consputc> 8010073f: eb 99 jmp 801006da <cprintf+0x8a> 80100741: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi consputc('%'); 80100748: b8 25 00 00 00 mov $0x25,%eax 8010074d: e8 8e fc ff ff call 801003e0 <consputc> break; 80100752: e9 6e ff ff ff jmp 801006c5 <cprintf+0x75> 80100757: 90 nop if((s = (char*)*argp++) == 0) 80100758: 8d 46 04 lea 0x4(%esi),%eax 8010075b: 8b 36 mov (%esi),%esi 8010075d: 89 45 e4 mov %eax,-0x1c(%ebp) s = "(null)"; 80100760: b8 38 6c 10 80 mov $0x80106c38,%eax 80100765: 85 f6 test %esi,%esi 80100767: 0f 44 f0 cmove %eax,%esi for(; *s; s++) 8010076a: 0f be 06 movsbl (%esi),%eax 8010076d: 84 c0 test %al,%al 8010076f: 74 16 je 80100787 <cprintf+0x137> 80100771: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80100778: 83 c6 01 add $0x1,%esi consputc(*s); 8010077b: e8 60 fc ff ff call 801003e0 <consputc> for(; *s; s++) 80100780: 0f be 06 movsbl (%esi),%eax 80100783: 84 c0 test %al,%al 80100785: 75 f1 jne 80100778 <cprintf+0x128> if((s = (char*)*argp++) == 0) 80100787: 8b 75 e4 mov -0x1c(%ebp),%esi 8010078a: e9 36 ff ff ff jmp 801006c5 <cprintf+0x75> 8010078f: 90 nop acquire(&cons.lock); 80100790: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 80100797: e8 44 3a 00 00 call 801041e0 <acquire> 8010079c: e9 c8 fe ff ff jmp 80100669 <cprintf+0x19> panic("null fmt"); 801007a1: c7 04 24 3f 6c 10 80 movl $0x80106c3f,(%esp) 801007a8: e8 b3 fb ff ff call 80100360 <panic> 801007ad: 8d 76 00 lea 0x0(%esi),%esi 801007b0 <consoleintr>: { 801007b0: 55 push %ebp 801007b1: 89 e5 mov %esp,%ebp 801007b3: 57 push %edi 801007b4: 56 push %esi int c, doprocdump = 0; 801007b5: 31 f6 xor %esi,%esi { 801007b7: 53 push %ebx 801007b8: 83 ec 1c sub $0x1c,%esp 801007bb: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&cons.lock); 801007be: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 801007c5: e8 16 3a 00 00 call 801041e0 <acquire> 801007ca: 8d b6 00 00 00 00 lea 0x0(%esi),%esi while((c = getc()) >= 0){ 801007d0: ff d3 call *%ebx 801007d2: 85 c0 test %eax,%eax 801007d4: 89 c7 mov %eax,%edi 801007d6: 78 48 js 80100820 <consoleintr+0x70> switch(c){ 801007d8: 83 ff 10 cmp $0x10,%edi 801007db: 0f 84 2f 01 00 00 je 80100910 <consoleintr+0x160> 801007e1: 7e 5d jle 80100840 <consoleintr+0x90> 801007e3: 83 ff 15 cmp $0x15,%edi 801007e6: 0f 84 d4 00 00 00 je 801008c0 <consoleintr+0x110> 801007ec: 83 ff 7f cmp $0x7f,%edi 801007ef: 90 nop 801007f0: 75 53 jne 80100845 <consoleintr+0x95> if(input.e != input.w){ 801007f2: a1 a8 ff 10 80 mov 0x8010ffa8,%eax 801007f7: 3b 05 a4 ff 10 80 cmp 0x8010ffa4,%eax 801007fd: 74 d1 je 801007d0 <consoleintr+0x20> input.e--; 801007ff: 83 e8 01 sub $0x1,%eax 80100802: a3 a8 ff 10 80 mov %eax,0x8010ffa8 consputc(BACKSPACE); 80100807: b8 00 01 00 00 mov $0x100,%eax 8010080c: e8 cf fb ff ff call 801003e0 <consputc> while((c = getc()) >= 0){ 80100811: ff d3 call *%ebx 80100813: 85 c0 test %eax,%eax 80100815: 89 c7 mov %eax,%edi 80100817: 79 bf jns 801007d8 <consoleintr+0x28> 80100819: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi release(&cons.lock); 80100820: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 80100827: e8 24 3a 00 00 call 80104250 <release> if(doprocdump) { 8010082c: 85 f6 test %esi,%esi 8010082e: 0f 85 ec 00 00 00 jne 80100920 <consoleintr+0x170> } 80100834: 83 c4 1c add $0x1c,%esp 80100837: 5b pop %ebx 80100838: 5e pop %esi 80100839: 5f pop %edi 8010083a: 5d pop %ebp 8010083b: c3 ret 8010083c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi switch(c){ 80100840: 83 ff 08 cmp $0x8,%edi 80100843: 74 ad je 801007f2 <consoleintr+0x42> if(c != 0 && input.e-input.r < INPUT_BUF){ 80100845: 85 ff test %edi,%edi 80100847: 74 87 je 801007d0 <consoleintr+0x20> 80100849: a1 a8 ff 10 80 mov 0x8010ffa8,%eax 8010084e: 89 c2 mov %eax,%edx 80100850: 2b 15 a0 ff 10 80 sub 0x8010ffa0,%edx 80100856: 83 fa 7f cmp $0x7f,%edx 80100859: 0f 87 71 ff ff ff ja 801007d0 <consoleintr+0x20> input.buf[input.e++ % INPUT_BUF] = c; 8010085f: 8d 50 01 lea 0x1(%eax),%edx 80100862: 83 e0 7f and $0x7f,%eax c = (c == '\r') ? '\n' : c; 80100865: 83 ff 0d cmp $0xd,%edi input.buf[input.e++ % INPUT_BUF] = c; 80100868: 89 15 a8 ff 10 80 mov %edx,0x8010ffa8 c = (c == '\r') ? '\n' : c; 8010086e: 0f 84 b8 00 00 00 je 8010092c <consoleintr+0x17c> input.buf[input.e++ % INPUT_BUF] = c; 80100874: 89 f9 mov %edi,%ecx 80100876: 88 88 20 ff 10 80 mov %cl,-0x7fef00e0(%eax) consputc(c); 8010087c: 89 f8 mov %edi,%eax 8010087e: e8 5d fb ff ff call 801003e0 <consputc> if(c == '\n' || c == C('D') || input.e == input.r+INPUT_BUF){ 80100883: 83 ff 04 cmp $0x4,%edi 80100886: a1 a8 ff 10 80 mov 0x8010ffa8,%eax 8010088b: 74 19 je 801008a6 <consoleintr+0xf6> 8010088d: 83 ff 0a cmp $0xa,%edi 80100890: 74 14 je 801008a6 <consoleintr+0xf6> 80100892: 8b 0d a0 ff 10 80 mov 0x8010ffa0,%ecx 80100898: 8d 91 80 00 00 00 lea 0x80(%ecx),%edx 8010089e: 39 d0 cmp %edx,%eax 801008a0: 0f 85 2a ff ff ff jne 801007d0 <consoleintr+0x20> wakeup(&input.r); 801008a6: c7 04 24 a0 ff 10 80 movl $0x8010ffa0,(%esp) input.w = input.e; 801008ad: a3 a4 ff 10 80 mov %eax,0x8010ffa4 wakeup(&input.r); 801008b2: e8 d9 34 00 00 call 80103d90 <wakeup> 801008b7: e9 14 ff ff ff jmp 801007d0 <consoleintr+0x20> 801008bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi while(input.e != input.w && 801008c0: a1 a8 ff 10 80 mov 0x8010ffa8,%eax 801008c5: 3b 05 a4 ff 10 80 cmp 0x8010ffa4,%eax 801008cb: 75 2b jne 801008f8 <consoleintr+0x148> 801008cd: e9 fe fe ff ff jmp 801007d0 <consoleintr+0x20> 801008d2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi input.e--; 801008d8: a3 a8 ff 10 80 mov %eax,0x8010ffa8 consputc(BACKSPACE); 801008dd: b8 00 01 00 00 mov $0x100,%eax 801008e2: e8 f9 fa ff ff call 801003e0 <consputc> while(input.e != input.w && 801008e7: a1 a8 ff 10 80 mov 0x8010ffa8,%eax 801008ec: 3b 05 a4 ff 10 80 cmp 0x8010ffa4,%eax 801008f2: 0f 84 d8 fe ff ff je 801007d0 <consoleintr+0x20> input.buf[(input.e-1) % INPUT_BUF] != '\n'){ 801008f8: 83 e8 01 sub $0x1,%eax 801008fb: 89 c2 mov %eax,%edx 801008fd: 83 e2 7f and $0x7f,%edx while(input.e != input.w && 80100900: 80 ba 20 ff 10 80 0a cmpb $0xa,-0x7fef00e0(%edx) 80100907: 75 cf jne 801008d8 <consoleintr+0x128> 80100909: e9 c2 fe ff ff jmp 801007d0 <consoleintr+0x20> 8010090e: 66 90 xchg %ax,%ax doprocdump = 1; 80100910: be 01 00 00 00 mov $0x1,%esi 80100915: e9 b6 fe ff ff jmp 801007d0 <consoleintr+0x20> 8010091a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi } 80100920: 83 c4 1c add $0x1c,%esp 80100923: 5b pop %ebx 80100924: 5e pop %esi 80100925: 5f pop %edi 80100926: 5d pop %ebp procdump(); // now call procdump() wo. cons.lock held 80100927: e9 44 35 00 00 jmp 80103e70 <procdump> input.buf[input.e++ % INPUT_BUF] = c; 8010092c: c6 80 20 ff 10 80 0a movb $0xa,-0x7fef00e0(%eax) consputc(c); 80100933: b8 0a 00 00 00 mov $0xa,%eax 80100938: e8 a3 fa ff ff call 801003e0 <consputc> 8010093d: a1 a8 ff 10 80 mov 0x8010ffa8,%eax 80100942: e9 5f ff ff ff jmp 801008a6 <consoleintr+0xf6> 80100947: 89 f6 mov %esi,%esi 80100949: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80100950 <consoleinit>: void consoleinit(void) { 80100950: 55 push %ebp 80100951: 89 e5 mov %esp,%ebp 80100953: 83 ec 18 sub $0x18,%esp initlock(&cons.lock, "console"); 80100956: c7 44 24 04 48 6c 10 movl $0x80106c48,0x4(%esp) 8010095d: 80 8010095e: c7 04 24 20 a5 10 80 movl $0x8010a520,(%esp) 80100965: e8 06 37 00 00 call 80104070 <initlock> devsw[CONSOLE].write = consolewrite; devsw[CONSOLE].read = consoleread; cons.locking = 1; ioapicenable(IRQ_KBD, 0); 8010096a: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80100971: 00 80100972: c7 04 24 01 00 00 00 movl $0x1,(%esp) devsw[CONSOLE].write = consolewrite; 80100979: c7 05 6c 09 11 80 f0 movl $0x801005f0,0x8011096c 80100980: 05 10 80 devsw[CONSOLE].read = consoleread; 80100983: c7 05 68 09 11 80 70 movl $0x80100270,0x80110968 8010098a: 02 10 80 cons.locking = 1; 8010098d: c7 05 54 a5 10 80 01 movl $0x1,0x8010a554 80100994: 00 00 00 ioapicenable(IRQ_KBD, 0); 80100997: e8 14 19 00 00 call 801022b0 <ioapicenable> } 8010099c: c9 leave 8010099d: c3 ret 8010099e: 66 90 xchg %ax,%ax 801009a0 <exec>: #include "x86.h" #include "elf.h" int exec(char *path, char **argv) { 801009a0: 55 push %ebp 801009a1: 89 e5 mov %esp,%ebp 801009a3: 57 push %edi 801009a4: 56 push %esi 801009a5: 53 push %ebx 801009a6: 81 ec 2c 01 00 00 sub $0x12c,%esp uint argc, sz, sp, ustack[3+MAXARG+1]; struct elfhdr elf; struct inode *ip; struct proghdr ph; pde_t *pgdir, *oldpgdir; struct proc *curproc = myproc(); 801009ac: e8 ef 2c 00 00 call 801036a0 <myproc> 801009b1: 89 85 f4 fe ff ff mov %eax,-0x10c(%ebp) begin_op(); 801009b7: e8 54 21 00 00 call 80102b10 <begin_op> if((ip = namei(path)) == 0){ 801009bc: 8b 45 08 mov 0x8(%ebp),%eax 801009bf: 89 04 24 mov %eax,(%esp) 801009c2: e8 39 15 00 00 call 80101f00 <namei> 801009c7: 85 c0 test %eax,%eax 801009c9: 89 c3 mov %eax,%ebx 801009cb: 0f 84 c2 01 00 00 je 80100b93 <exec+0x1f3> end_op(); cprintf("exec: fail\n"); return -1; } ilock(ip); 801009d1: 89 04 24 mov %eax,(%esp) 801009d4: e8 d7 0c 00 00 call 801016b0 <ilock> pgdir = 0; // Check ELF header if(readi(ip, (char*)&elf, 0, sizeof(elf)) != sizeof(elf)) 801009d9: 8d 85 24 ff ff ff lea -0xdc(%ebp),%eax 801009df: c7 44 24 0c 34 00 00 movl $0x34,0xc(%esp) 801009e6: 00 801009e7: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) 801009ee: 00 801009ef: 89 44 24 04 mov %eax,0x4(%esp) 801009f3: 89 1c 24 mov %ebx,(%esp) 801009f6: e8 65 0f 00 00 call 80101960 <readi> 801009fb: 83 f8 34 cmp $0x34,%eax 801009fe: 74 20 je 80100a20 <exec+0x80> bad: if(pgdir) freevm(pgdir); if(ip){ iunlockput(ip); 80100a00: 89 1c 24 mov %ebx,(%esp) 80100a03: e8 08 0f 00 00 call 80101910 <iunlockput> end_op(); 80100a08: e8 73 21 00 00 call 80102b80 <end_op> } return -1; 80100a0d: b8 ff ff ff ff mov $0xffffffff,%eax } 80100a12: 81 c4 2c 01 00 00 add $0x12c,%esp 80100a18: 5b pop %ebx 80100a19: 5e pop %esi 80100a1a: 5f pop %edi 80100a1b: 5d pop %ebp 80100a1c: c3 ret 80100a1d: 8d 76 00 lea 0x0(%esi),%esi if(elf.magic != ELF_MAGIC) 80100a20: 81 bd 24 ff ff ff 7f cmpl $0x464c457f,-0xdc(%ebp) 80100a27: 45 4c 46 80100a2a: 75 d4 jne 80100a00 <exec+0x60> if((pgdir = setupkvm()) == 0) 80100a2c: e8 0f 5f 00 00 call 80106940 <setupkvm> 80100a31: 85 c0 test %eax,%eax 80100a33: 89 85 f0 fe ff ff mov %eax,-0x110(%ebp) 80100a39: 74 c5 je 80100a00 <exec+0x60> for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){ 80100a3b: 66 83 bd 50 ff ff ff cmpw $0x0,-0xb0(%ebp) 80100a42: 00 80100a43: 8b b5 40 ff ff ff mov -0xc0(%ebp),%esi sz = 0; 80100a49: c7 85 ec fe ff ff 00 movl $0x0,-0x114(%ebp) 80100a50: 00 00 00 for(i=0, off=elf.phoff; i<elf.phnum; i++, off+=sizeof(ph)){ 80100a53: 0f 84 da 00 00 00 je 80100b33 <exec+0x193> 80100a59: 31 ff xor %edi,%edi 80100a5b: eb 18 jmp 80100a75 <exec+0xd5> 80100a5d: 8d 76 00 lea 0x0(%esi),%esi 80100a60: 0f b7 85 50 ff ff ff movzwl -0xb0(%ebp),%eax 80100a67: 83 c7 01 add $0x1,%edi 80100a6a: 83 c6 20 add $0x20,%esi 80100a6d: 39 f8 cmp %edi,%eax 80100a6f: 0f 8e be 00 00 00 jle 80100b33 <exec+0x193> if(readi(ip, (char*)&ph, off, sizeof(ph)) != sizeof(ph)) 80100a75: 8d 85 04 ff ff ff lea -0xfc(%ebp),%eax 80100a7b: c7 44 24 0c 20 00 00 movl $0x20,0xc(%esp) 80100a82: 00 80100a83: 89 74 24 08 mov %esi,0x8(%esp) 80100a87: 89 44 24 04 mov %eax,0x4(%esp) 80100a8b: 89 1c 24 mov %ebx,(%esp) 80100a8e: e8 cd 0e 00 00 call 80101960 <readi> 80100a93: 83 f8 20 cmp $0x20,%eax 80100a96: 0f 85 84 00 00 00 jne 80100b20 <exec+0x180> if(ph.type != ELF_PROG_LOAD) 80100a9c: 83 bd 04 ff ff ff 01 cmpl $0x1,-0xfc(%ebp) 80100aa3: 75 bb jne 80100a60 <exec+0xc0> if(ph.memsz < ph.filesz) 80100aa5: 8b 85 18 ff ff ff mov -0xe8(%ebp),%eax 80100aab: 3b 85 14 ff ff ff cmp -0xec(%ebp),%eax 80100ab1: 72 6d jb 80100b20 <exec+0x180> if(ph.vaddr + ph.memsz < ph.vaddr) 80100ab3: 03 85 0c ff ff ff add -0xf4(%ebp),%eax 80100ab9: 72 65 jb 80100b20 <exec+0x180> if((sz = allocuvm(pgdir, sz, ph.vaddr + ph.memsz)) == 0) 80100abb: 89 44 24 08 mov %eax,0x8(%esp) 80100abf: 8b 85 ec fe ff ff mov -0x114(%ebp),%eax 80100ac5: 89 44 24 04 mov %eax,0x4(%esp) 80100ac9: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax 80100acf: 89 04 24 mov %eax,(%esp) 80100ad2: e8 d9 5c 00 00 call 801067b0 <allocuvm> 80100ad7: 85 c0 test %eax,%eax 80100ad9: 89 85 ec fe ff ff mov %eax,-0x114(%ebp) 80100adf: 74 3f je 80100b20 <exec+0x180> if(ph.vaddr % PGSIZE != 0) 80100ae1: 8b 85 0c ff ff ff mov -0xf4(%ebp),%eax 80100ae7: a9 ff 0f 00 00 test $0xfff,%eax 80100aec: 75 32 jne 80100b20 <exec+0x180> if(loaduvm(pgdir, (char*)ph.vaddr, ip, ph.off, ph.filesz) < 0) 80100aee: 8b 95 14 ff ff ff mov -0xec(%ebp),%edx 80100af4: 89 44 24 04 mov %eax,0x4(%esp) 80100af8: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax 80100afe: 89 5c 24 08 mov %ebx,0x8(%esp) 80100b02: 89 54 24 10 mov %edx,0x10(%esp) 80100b06: 8b 95 08 ff ff ff mov -0xf8(%ebp),%edx 80100b0c: 89 04 24 mov %eax,(%esp) 80100b0f: 89 54 24 0c mov %edx,0xc(%esp) 80100b13: e8 d8 5b 00 00 call 801066f0 <loaduvm> 80100b18: 85 c0 test %eax,%eax 80100b1a: 0f 89 40 ff ff ff jns 80100a60 <exec+0xc0> freevm(pgdir); 80100b20: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax 80100b26: 89 04 24 mov %eax,(%esp) 80100b29: e8 92 5d 00 00 call 801068c0 <freevm> 80100b2e: e9 cd fe ff ff jmp 80100a00 <exec+0x60> iunlockput(ip); 80100b33: 89 1c 24 mov %ebx,(%esp) 80100b36: e8 d5 0d 00 00 call 80101910 <iunlockput> 80100b3b: 90 nop 80100b3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi end_op(); 80100b40: e8 3b 20 00 00 call 80102b80 <end_op> sz = PGROUNDUP(sz); 80100b45: 8b 85 ec fe ff ff mov -0x114(%ebp),%eax 80100b4b: 05 ff 0f 00 00 add $0xfff,%eax 80100b50: 25 00 f0 ff ff and $0xfffff000,%eax if((sz = allocuvm(pgdir, sz, sz + 2*PGSIZE)) == 0) 80100b55: 8d 90 00 20 00 00 lea 0x2000(%eax),%edx 80100b5b: 89 44 24 04 mov %eax,0x4(%esp) 80100b5f: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax 80100b65: 89 54 24 08 mov %edx,0x8(%esp) 80100b69: 89 04 24 mov %eax,(%esp) 80100b6c: e8 3f 5c 00 00 call 801067b0 <allocuvm> 80100b71: 85 c0 test %eax,%eax 80100b73: 89 85 e8 fe ff ff mov %eax,-0x118(%ebp) 80100b79: 75 33 jne 80100bae <exec+0x20e> freevm(pgdir); 80100b7b: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax 80100b81: 89 04 24 mov %eax,(%esp) 80100b84: e8 37 5d 00 00 call 801068c0 <freevm> return -1; 80100b89: b8 ff ff ff ff mov $0xffffffff,%eax 80100b8e: e9 7f fe ff ff jmp 80100a12 <exec+0x72> end_op(); 80100b93: e8 e8 1f 00 00 call 80102b80 <end_op> cprintf("exec: fail\n"); 80100b98: c7 04 24 61 6c 10 80 movl $0x80106c61,(%esp) 80100b9f: e8 ac fa ff ff call 80100650 <cprintf> return -1; 80100ba4: b8 ff ff ff ff mov $0xffffffff,%eax 80100ba9: e9 64 fe ff ff jmp 80100a12 <exec+0x72> clearpteu(pgdir, (char*)(sz - 2*PGSIZE)); 80100bae: 8b 9d e8 fe ff ff mov -0x118(%ebp),%ebx 80100bb4: 89 d8 mov %ebx,%eax 80100bb6: 2d 00 20 00 00 sub $0x2000,%eax 80100bbb: 89 44 24 04 mov %eax,0x4(%esp) 80100bbf: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax 80100bc5: 89 04 24 mov %eax,(%esp) 80100bc8: e8 23 5e 00 00 call 801069f0 <clearpteu> for(argc = 0; argv[argc]; argc++) { 80100bcd: 8b 45 0c mov 0xc(%ebp),%eax 80100bd0: 8b 00 mov (%eax),%eax 80100bd2: 85 c0 test %eax,%eax 80100bd4: 0f 84 59 01 00 00 je 80100d33 <exec+0x393> 80100bda: 8b 4d 0c mov 0xc(%ebp),%ecx 80100bdd: 31 d2 xor %edx,%edx 80100bdf: 8d 71 04 lea 0x4(%ecx),%esi 80100be2: 89 cf mov %ecx,%edi 80100be4: 89 d1 mov %edx,%ecx 80100be6: 89 f2 mov %esi,%edx 80100be8: 89 fe mov %edi,%esi 80100bea: 89 cf mov %ecx,%edi 80100bec: eb 0a jmp 80100bf8 <exec+0x258> 80100bee: 66 90 xchg %ax,%ax 80100bf0: 83 c2 04 add $0x4,%edx if(argc >= MAXARG) 80100bf3: 83 ff 20 cmp $0x20,%edi 80100bf6: 74 83 je 80100b7b <exec+0x1db> sp = (sp - (strlen(argv[argc]) + 1)) & ~3; 80100bf8: 89 04 24 mov %eax,(%esp) 80100bfb: 89 95 ec fe ff ff mov %edx,-0x114(%ebp) 80100c01: e8 ba 38 00 00 call 801044c0 <strlen> 80100c06: f7 d0 not %eax 80100c08: 01 c3 add %eax,%ebx if(copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0) 80100c0a: 8b 06 mov (%esi),%eax sp = (sp - (strlen(argv[argc]) + 1)) & ~3; 80100c0c: 83 e3 fc and $0xfffffffc,%ebx if(copyout(pgdir, sp, argv[argc], strlen(argv[argc]) + 1) < 0) 80100c0f: 89 04 24 mov %eax,(%esp) 80100c12: e8 a9 38 00 00 call 801044c0 <strlen> 80100c17: 83 c0 01 add $0x1,%eax 80100c1a: 89 44 24 0c mov %eax,0xc(%esp) 80100c1e: 8b 06 mov (%esi),%eax 80100c20: 89 5c 24 04 mov %ebx,0x4(%esp) 80100c24: 89 44 24 08 mov %eax,0x8(%esp) 80100c28: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax 80100c2e: 89 04 24 mov %eax,(%esp) 80100c31: e8 1a 5f 00 00 call 80106b50 <copyout> 80100c36: 85 c0 test %eax,%eax 80100c38: 0f 88 3d ff ff ff js 80100b7b <exec+0x1db> for(argc = 0; argv[argc]; argc++) { 80100c3e: 8b 95 ec fe ff ff mov -0x114(%ebp),%edx ustack[3+argc] = sp; 80100c44: 8d 8d 58 ff ff ff lea -0xa8(%ebp),%ecx 80100c4a: 89 9c bd 64 ff ff ff mov %ebx,-0x9c(%ebp,%edi,4) for(argc = 0; argv[argc]; argc++) { 80100c51: 83 c7 01 add $0x1,%edi 80100c54: 8b 02 mov (%edx),%eax 80100c56: 89 d6 mov %edx,%esi 80100c58: 85 c0 test %eax,%eax 80100c5a: 75 94 jne 80100bf0 <exec+0x250> 80100c5c: 89 fa mov %edi,%edx ustack[3+argc] = 0; 80100c5e: c7 84 95 64 ff ff ff movl $0x0,-0x9c(%ebp,%edx,4) 80100c65: 00 00 00 00 ustack[2] = sp - (argc+1)*4; // argv pointer 80100c69: 8d 04 95 04 00 00 00 lea 0x4(,%edx,4),%eax ustack[1] = argc; 80100c70: 89 95 5c ff ff ff mov %edx,-0xa4(%ebp) ustack[2] = sp - (argc+1)*4; // argv pointer 80100c76: 89 da mov %ebx,%edx 80100c78: 29 c2 sub %eax,%edx sp -= (3+argc+1) * 4; 80100c7a: 83 c0 0c add $0xc,%eax 80100c7d: 29 c3 sub %eax,%ebx if(copyout(pgdir, sp, ustack, (3+argc+1)*4) < 0) 80100c7f: 89 44 24 0c mov %eax,0xc(%esp) 80100c83: 8b 85 f0 fe ff ff mov -0x110(%ebp),%eax 80100c89: 89 4c 24 08 mov %ecx,0x8(%esp) 80100c8d: 89 5c 24 04 mov %ebx,0x4(%esp) ustack[0] = 0xffffffff; // fake return PC 80100c91: c7 85 58 ff ff ff ff movl $0xffffffff,-0xa8(%ebp) 80100c98: ff ff ff if(copyout(pgdir, sp, ustack, (3+argc+1)*4) < 0) 80100c9b: 89 04 24 mov %eax,(%esp) ustack[2] = sp - (argc+1)*4; // argv pointer 80100c9e: 89 95 60 ff ff ff mov %edx,-0xa0(%ebp) if(copyout(pgdir, sp, ustack, (3+argc+1)*4) < 0) 80100ca4: e8 a7 5e 00 00 call 80106b50 <copyout> 80100ca9: 85 c0 test %eax,%eax 80100cab: 0f 88 ca fe ff ff js 80100b7b <exec+0x1db> for(last=s=path; *s; s++) 80100cb1: 8b 45 08 mov 0x8(%ebp),%eax 80100cb4: 0f b6 10 movzbl (%eax),%edx 80100cb7: 84 d2 test %dl,%dl 80100cb9: 74 19 je 80100cd4 <exec+0x334> 80100cbb: 8b 4d 08 mov 0x8(%ebp),%ecx 80100cbe: 83 c0 01 add $0x1,%eax last = s+1; 80100cc1: 80 fa 2f cmp $0x2f,%dl for(last=s=path; *s; s++) 80100cc4: 0f b6 10 movzbl (%eax),%edx last = s+1; 80100cc7: 0f 44 c8 cmove %eax,%ecx 80100cca: 83 c0 01 add $0x1,%eax for(last=s=path; *s; s++) 80100ccd: 84 d2 test %dl,%dl 80100ccf: 75 f0 jne 80100cc1 <exec+0x321> 80100cd1: 89 4d 08 mov %ecx,0x8(%ebp) safestrcpy(curproc->name, last, sizeof(curproc->name)); 80100cd4: 8b bd f4 fe ff ff mov -0x10c(%ebp),%edi 80100cda: 8b 45 08 mov 0x8(%ebp),%eax 80100cdd: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 80100ce4: 00 80100ce5: 89 44 24 04 mov %eax,0x4(%esp) 80100ce9: 89 f8 mov %edi,%eax 80100ceb: 83 c0 6c add $0x6c,%eax 80100cee: 89 04 24 mov %eax,(%esp) 80100cf1: e8 8a 37 00 00 call 80104480 <safestrcpy> curproc->pgdir = pgdir; 80100cf6: 8b 8d f0 fe ff ff mov -0x110(%ebp),%ecx oldpgdir = curproc->pgdir; 80100cfc: 8b 77 04 mov 0x4(%edi),%esi curproc->tf->eip = elf.entry; // main 80100cff: 8b 47 18 mov 0x18(%edi),%eax curproc->pgdir = pgdir; 80100d02: 89 4f 04 mov %ecx,0x4(%edi) curproc->sz = sz; 80100d05: 8b 8d e8 fe ff ff mov -0x118(%ebp),%ecx 80100d0b: 89 0f mov %ecx,(%edi) curproc->tf->eip = elf.entry; // main 80100d0d: 8b 95 3c ff ff ff mov -0xc4(%ebp),%edx 80100d13: 89 50 38 mov %edx,0x38(%eax) curproc->tf->esp = sp; 80100d16: 8b 47 18 mov 0x18(%edi),%eax 80100d19: 89 58 44 mov %ebx,0x44(%eax) switchuvm(curproc); 80100d1c: 89 3c 24 mov %edi,(%esp) 80100d1f: e8 3c 58 00 00 call 80106560 <switchuvm> freevm(oldpgdir); 80100d24: 89 34 24 mov %esi,(%esp) 80100d27: e8 94 5b 00 00 call 801068c0 <freevm> return 0; 80100d2c: 31 c0 xor %eax,%eax 80100d2e: e9 df fc ff ff jmp 80100a12 <exec+0x72> for(argc = 0; argv[argc]; argc++) { 80100d33: 8b 9d e8 fe ff ff mov -0x118(%ebp),%ebx 80100d39: 31 d2 xor %edx,%edx 80100d3b: 8d 8d 58 ff ff ff lea -0xa8(%ebp),%ecx 80100d41: e9 18 ff ff ff jmp 80100c5e <exec+0x2be> 80100d46: 66 90 xchg %ax,%ax 80100d48: 66 90 xchg %ax,%ax 80100d4a: 66 90 xchg %ax,%ax 80100d4c: 66 90 xchg %ax,%ax 80100d4e: 66 90 xchg %ax,%ax 80100d50 <fileinit>: struct file file[NFILE]; } ftable; void fileinit(void) { 80100d50: 55 push %ebp 80100d51: 89 e5 mov %esp,%ebp 80100d53: 83 ec 18 sub $0x18,%esp initlock(&ftable.lock, "ftable"); 80100d56: c7 44 24 04 6d 6c 10 movl $0x80106c6d,0x4(%esp) 80100d5d: 80 80100d5e: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) 80100d65: e8 06 33 00 00 call 80104070 <initlock> } 80100d6a: c9 leave 80100d6b: c3 ret 80100d6c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80100d70 <filealloc>: // Allocate a file structure. struct file* filealloc(void) { 80100d70: 55 push %ebp 80100d71: 89 e5 mov %esp,%ebp 80100d73: 53 push %ebx struct file *f; acquire(&ftable.lock); for(f = ftable.file; f < ftable.file + NFILE; f++){ 80100d74: bb f4 ff 10 80 mov $0x8010fff4,%ebx { 80100d79: 83 ec 14 sub $0x14,%esp acquire(&ftable.lock); 80100d7c: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) 80100d83: e8 58 34 00 00 call 801041e0 <acquire> 80100d88: eb 11 jmp 80100d9b <filealloc+0x2b> 80100d8a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi for(f = ftable.file; f < ftable.file + NFILE; f++){ 80100d90: 83 c3 18 add $0x18,%ebx 80100d93: 81 fb 54 09 11 80 cmp $0x80110954,%ebx 80100d99: 74 25 je 80100dc0 <filealloc+0x50> if(f->ref == 0){ 80100d9b: 8b 43 04 mov 0x4(%ebx),%eax 80100d9e: 85 c0 test %eax,%eax 80100da0: 75 ee jne 80100d90 <filealloc+0x20> f->ref = 1; release(&ftable.lock); 80100da2: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) f->ref = 1; 80100da9: c7 43 04 01 00 00 00 movl $0x1,0x4(%ebx) release(&ftable.lock); 80100db0: e8 9b 34 00 00 call 80104250 <release> return f; } } release(&ftable.lock); return 0; } 80100db5: 83 c4 14 add $0x14,%esp return f; 80100db8: 89 d8 mov %ebx,%eax } 80100dba: 5b pop %ebx 80100dbb: 5d pop %ebp 80100dbc: c3 ret 80100dbd: 8d 76 00 lea 0x0(%esi),%esi release(&ftable.lock); 80100dc0: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) 80100dc7: e8 84 34 00 00 call 80104250 <release> } 80100dcc: 83 c4 14 add $0x14,%esp return 0; 80100dcf: 31 c0 xor %eax,%eax } 80100dd1: 5b pop %ebx 80100dd2: 5d pop %ebp 80100dd3: c3 ret 80100dd4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80100dda: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80100de0 <filedup>: // Increment ref count for file f. struct file* filedup(struct file *f) { 80100de0: 55 push %ebp 80100de1: 89 e5 mov %esp,%ebp 80100de3: 53 push %ebx 80100de4: 83 ec 14 sub $0x14,%esp 80100de7: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&ftable.lock); 80100dea: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) 80100df1: e8 ea 33 00 00 call 801041e0 <acquire> if(f->ref < 1) 80100df6: 8b 43 04 mov 0x4(%ebx),%eax 80100df9: 85 c0 test %eax,%eax 80100dfb: 7e 1a jle 80100e17 <filedup+0x37> panic("filedup"); f->ref++; 80100dfd: 83 c0 01 add $0x1,%eax 80100e00: 89 43 04 mov %eax,0x4(%ebx) release(&ftable.lock); 80100e03: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) 80100e0a: e8 41 34 00 00 call 80104250 <release> return f; } 80100e0f: 83 c4 14 add $0x14,%esp 80100e12: 89 d8 mov %ebx,%eax 80100e14: 5b pop %ebx 80100e15: 5d pop %ebp 80100e16: c3 ret panic("filedup"); 80100e17: c7 04 24 74 6c 10 80 movl $0x80106c74,(%esp) 80100e1e: e8 3d f5 ff ff call 80100360 <panic> 80100e23: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80100e29: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80100e30 <fileclose>: // Close file f. (Decrement ref count, close when reaches 0.) void fileclose(struct file *f) { 80100e30: 55 push %ebp 80100e31: 89 e5 mov %esp,%ebp 80100e33: 57 push %edi 80100e34: 56 push %esi 80100e35: 53 push %ebx 80100e36: 83 ec 1c sub $0x1c,%esp 80100e39: 8b 7d 08 mov 0x8(%ebp),%edi struct file ff; acquire(&ftable.lock); 80100e3c: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) 80100e43: e8 98 33 00 00 call 801041e0 <acquire> if(f->ref < 1) 80100e48: 8b 57 04 mov 0x4(%edi),%edx 80100e4b: 85 d2 test %edx,%edx 80100e4d: 0f 8e 89 00 00 00 jle 80100edc <fileclose+0xac> panic("fileclose"); if(--f->ref > 0){ 80100e53: 83 ea 01 sub $0x1,%edx 80100e56: 85 d2 test %edx,%edx 80100e58: 89 57 04 mov %edx,0x4(%edi) 80100e5b: 74 13 je 80100e70 <fileclose+0x40> release(&ftable.lock); 80100e5d: c7 45 08 c0 ff 10 80 movl $0x8010ffc0,0x8(%ebp) else if(ff.type == FD_INODE){ begin_op(); iput(ff.ip); end_op(); } } 80100e64: 83 c4 1c add $0x1c,%esp 80100e67: 5b pop %ebx 80100e68: 5e pop %esi 80100e69: 5f pop %edi 80100e6a: 5d pop %ebp release(&ftable.lock); 80100e6b: e9 e0 33 00 00 jmp 80104250 <release> ff = *f; 80100e70: 0f b6 47 09 movzbl 0x9(%edi),%eax 80100e74: 8b 37 mov (%edi),%esi 80100e76: 8b 5f 0c mov 0xc(%edi),%ebx f->type = FD_NONE; 80100e79: c7 07 00 00 00 00 movl $0x0,(%edi) ff = *f; 80100e7f: 88 45 e7 mov %al,-0x19(%ebp) 80100e82: 8b 47 10 mov 0x10(%edi),%eax release(&ftable.lock); 80100e85: c7 04 24 c0 ff 10 80 movl $0x8010ffc0,(%esp) ff = *f; 80100e8c: 89 45 e0 mov %eax,-0x20(%ebp) release(&ftable.lock); 80100e8f: e8 bc 33 00 00 call 80104250 <release> if(ff.type == FD_PIPE) 80100e94: 83 fe 01 cmp $0x1,%esi 80100e97: 74 0f je 80100ea8 <fileclose+0x78> else if(ff.type == FD_INODE){ 80100e99: 83 fe 02 cmp $0x2,%esi 80100e9c: 74 22 je 80100ec0 <fileclose+0x90> } 80100e9e: 83 c4 1c add $0x1c,%esp 80100ea1: 5b pop %ebx 80100ea2: 5e pop %esi 80100ea3: 5f pop %edi 80100ea4: 5d pop %ebp 80100ea5: c3 ret 80100ea6: 66 90 xchg %ax,%ax pipeclose(ff.pipe, ff.writable); 80100ea8: 0f be 75 e7 movsbl -0x19(%ebp),%esi 80100eac: 89 1c 24 mov %ebx,(%esp) 80100eaf: 89 74 24 04 mov %esi,0x4(%esp) 80100eb3: e8 a8 23 00 00 call 80103260 <pipeclose> 80100eb8: eb e4 jmp 80100e9e <fileclose+0x6e> 80100eba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi begin_op(); 80100ec0: e8 4b 1c 00 00 call 80102b10 <begin_op> iput(ff.ip); 80100ec5: 8b 45 e0 mov -0x20(%ebp),%eax 80100ec8: 89 04 24 mov %eax,(%esp) 80100ecb: e8 00 09 00 00 call 801017d0 <iput> } 80100ed0: 83 c4 1c add $0x1c,%esp 80100ed3: 5b pop %ebx 80100ed4: 5e pop %esi 80100ed5: 5f pop %edi 80100ed6: 5d pop %ebp end_op(); 80100ed7: e9 a4 1c 00 00 jmp 80102b80 <end_op> panic("fileclose"); 80100edc: c7 04 24 7c 6c 10 80 movl $0x80106c7c,(%esp) 80100ee3: e8 78 f4 ff ff call 80100360 <panic> 80100ee8: 90 nop 80100ee9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80100ef0 <filestat>: // Get metadata about file f. int filestat(struct file *f, struct stat *st) { 80100ef0: 55 push %ebp 80100ef1: 89 e5 mov %esp,%ebp 80100ef3: 53 push %ebx 80100ef4: 83 ec 14 sub $0x14,%esp 80100ef7: 8b 5d 08 mov 0x8(%ebp),%ebx if(f->type == FD_INODE){ 80100efa: 83 3b 02 cmpl $0x2,(%ebx) 80100efd: 75 31 jne 80100f30 <filestat+0x40> ilock(f->ip); 80100eff: 8b 43 10 mov 0x10(%ebx),%eax 80100f02: 89 04 24 mov %eax,(%esp) 80100f05: e8 a6 07 00 00 call 801016b0 <ilock> stati(f->ip, st); 80100f0a: 8b 45 0c mov 0xc(%ebp),%eax 80100f0d: 89 44 24 04 mov %eax,0x4(%esp) 80100f11: 8b 43 10 mov 0x10(%ebx),%eax 80100f14: 89 04 24 mov %eax,(%esp) 80100f17: e8 14 0a 00 00 call 80101930 <stati> iunlock(f->ip); 80100f1c: 8b 43 10 mov 0x10(%ebx),%eax 80100f1f: 89 04 24 mov %eax,(%esp) 80100f22: e8 69 08 00 00 call 80101790 <iunlock> return 0; } return -1; } 80100f27: 83 c4 14 add $0x14,%esp return 0; 80100f2a: 31 c0 xor %eax,%eax } 80100f2c: 5b pop %ebx 80100f2d: 5d pop %ebp 80100f2e: c3 ret 80100f2f: 90 nop 80100f30: 83 c4 14 add $0x14,%esp return -1; 80100f33: b8 ff ff ff ff mov $0xffffffff,%eax } 80100f38: 5b pop %ebx 80100f39: 5d pop %ebp 80100f3a: c3 ret 80100f3b: 90 nop 80100f3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80100f40 <fileread>: // Read from file f. int fileread(struct file *f, char *addr, int n) { 80100f40: 55 push %ebp 80100f41: 89 e5 mov %esp,%ebp 80100f43: 57 push %edi 80100f44: 56 push %esi 80100f45: 53 push %ebx 80100f46: 83 ec 1c sub $0x1c,%esp 80100f49: 8b 5d 08 mov 0x8(%ebp),%ebx 80100f4c: 8b 75 0c mov 0xc(%ebp),%esi 80100f4f: 8b 7d 10 mov 0x10(%ebp),%edi int r; if(f->readable == 0) 80100f52: 80 7b 08 00 cmpb $0x0,0x8(%ebx) 80100f56: 74 68 je 80100fc0 <fileread+0x80> return -1; if(f->type == FD_PIPE) 80100f58: 8b 03 mov (%ebx),%eax 80100f5a: 83 f8 01 cmp $0x1,%eax 80100f5d: 74 49 je 80100fa8 <fileread+0x68> return piperead(f->pipe, addr, n); if(f->type == FD_INODE){ 80100f5f: 83 f8 02 cmp $0x2,%eax 80100f62: 75 63 jne 80100fc7 <fileread+0x87> ilock(f->ip); 80100f64: 8b 43 10 mov 0x10(%ebx),%eax 80100f67: 89 04 24 mov %eax,(%esp) 80100f6a: e8 41 07 00 00 call 801016b0 <ilock> if((r = readi(f->ip, addr, f->off, n)) > 0) 80100f6f: 89 7c 24 0c mov %edi,0xc(%esp) 80100f73: 8b 43 14 mov 0x14(%ebx),%eax 80100f76: 89 74 24 04 mov %esi,0x4(%esp) 80100f7a: 89 44 24 08 mov %eax,0x8(%esp) 80100f7e: 8b 43 10 mov 0x10(%ebx),%eax 80100f81: 89 04 24 mov %eax,(%esp) 80100f84: e8 d7 09 00 00 call 80101960 <readi> 80100f89: 85 c0 test %eax,%eax 80100f8b: 89 c6 mov %eax,%esi 80100f8d: 7e 03 jle 80100f92 <fileread+0x52> f->off += r; 80100f8f: 01 43 14 add %eax,0x14(%ebx) iunlock(f->ip); 80100f92: 8b 43 10 mov 0x10(%ebx),%eax 80100f95: 89 04 24 mov %eax,(%esp) 80100f98: e8 f3 07 00 00 call 80101790 <iunlock> if((r = readi(f->ip, addr, f->off, n)) > 0) 80100f9d: 89 f0 mov %esi,%eax return r; } panic("fileread"); } 80100f9f: 83 c4 1c add $0x1c,%esp 80100fa2: 5b pop %ebx 80100fa3: 5e pop %esi 80100fa4: 5f pop %edi 80100fa5: 5d pop %ebp 80100fa6: c3 ret 80100fa7: 90 nop return piperead(f->pipe, addr, n); 80100fa8: 8b 43 0c mov 0xc(%ebx),%eax 80100fab: 89 45 08 mov %eax,0x8(%ebp) } 80100fae: 83 c4 1c add $0x1c,%esp 80100fb1: 5b pop %ebx 80100fb2: 5e pop %esi 80100fb3: 5f pop %edi 80100fb4: 5d pop %ebp return piperead(f->pipe, addr, n); 80100fb5: e9 26 24 00 00 jmp 801033e0 <piperead> 80100fba: 8d b6 00 00 00 00 lea 0x0(%esi),%esi return -1; 80100fc0: b8 ff ff ff ff mov $0xffffffff,%eax 80100fc5: eb d8 jmp 80100f9f <fileread+0x5f> panic("fileread"); 80100fc7: c7 04 24 86 6c 10 80 movl $0x80106c86,(%esp) 80100fce: e8 8d f3 ff ff call 80100360 <panic> 80100fd3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80100fd9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80100fe0 <filewrite>: //PAGEBREAK! // Write to file f. int filewrite(struct file *f, char *addr, int n) { 80100fe0: 55 push %ebp 80100fe1: 89 e5 mov %esp,%ebp 80100fe3: 57 push %edi 80100fe4: 56 push %esi 80100fe5: 53 push %ebx 80100fe6: 83 ec 2c sub $0x2c,%esp 80100fe9: 8b 45 0c mov 0xc(%ebp),%eax 80100fec: 8b 7d 08 mov 0x8(%ebp),%edi 80100fef: 89 45 dc mov %eax,-0x24(%ebp) 80100ff2: 8b 45 10 mov 0x10(%ebp),%eax int r; if(f->writable == 0) 80100ff5: 80 7f 09 00 cmpb $0x0,0x9(%edi) { 80100ff9: 89 45 e4 mov %eax,-0x1c(%ebp) if(f->writable == 0) 80100ffc: 0f 84 ae 00 00 00 je 801010b0 <filewrite+0xd0> return -1; if(f->type == FD_PIPE) 80101002: 8b 07 mov (%edi),%eax 80101004: 83 f8 01 cmp $0x1,%eax 80101007: 0f 84 c2 00 00 00 je 801010cf <filewrite+0xef> return pipewrite(f->pipe, addr, n); if(f->type == FD_INODE){ 8010100d: 83 f8 02 cmp $0x2,%eax 80101010: 0f 85 d7 00 00 00 jne 801010ed <filewrite+0x10d> // and 2 blocks of slop for non-aligned writes. // this really belongs lower down, since writei() // might be writing a device like the console. int max = ((MAXOPBLOCKS-1-1-2) / 2) * 512; int i = 0; while(i < n){ 80101016: 8b 45 e4 mov -0x1c(%ebp),%eax 80101019: 31 db xor %ebx,%ebx 8010101b: 85 c0 test %eax,%eax 8010101d: 7f 31 jg 80101050 <filewrite+0x70> 8010101f: e9 9c 00 00 00 jmp 801010c0 <filewrite+0xe0> 80101024: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi begin_op(); ilock(f->ip); if ((r = writei(f->ip, addr + i, f->off, n1)) > 0) f->off += r; iunlock(f->ip); 80101028: 8b 4f 10 mov 0x10(%edi),%ecx f->off += r; 8010102b: 01 47 14 add %eax,0x14(%edi) 8010102e: 89 45 e0 mov %eax,-0x20(%ebp) iunlock(f->ip); 80101031: 89 0c 24 mov %ecx,(%esp) 80101034: e8 57 07 00 00 call 80101790 <iunlock> end_op(); 80101039: e8 42 1b 00 00 call 80102b80 <end_op> 8010103e: 8b 45 e0 mov -0x20(%ebp),%eax if(r < 0) break; if(r != n1) 80101041: 39 f0 cmp %esi,%eax 80101043: 0f 85 98 00 00 00 jne 801010e1 <filewrite+0x101> panic("short filewrite"); i += r; 80101049: 01 c3 add %eax,%ebx while(i < n){ 8010104b: 39 5d e4 cmp %ebx,-0x1c(%ebp) 8010104e: 7e 70 jle 801010c0 <filewrite+0xe0> int n1 = n - i; 80101050: 8b 75 e4 mov -0x1c(%ebp),%esi 80101053: b8 00 06 00 00 mov $0x600,%eax 80101058: 29 de sub %ebx,%esi 8010105a: 81 fe 00 06 00 00 cmp $0x600,%esi 80101060: 0f 4f f0 cmovg %eax,%esi begin_op(); 80101063: e8 a8 1a 00 00 call 80102b10 <begin_op> ilock(f->ip); 80101068: 8b 47 10 mov 0x10(%edi),%eax 8010106b: 89 04 24 mov %eax,(%esp) 8010106e: e8 3d 06 00 00 call 801016b0 <ilock> if ((r = writei(f->ip, addr + i, f->off, n1)) > 0) 80101073: 89 74 24 0c mov %esi,0xc(%esp) 80101077: 8b 47 14 mov 0x14(%edi),%eax 8010107a: 89 44 24 08 mov %eax,0x8(%esp) 8010107e: 8b 45 dc mov -0x24(%ebp),%eax 80101081: 01 d8 add %ebx,%eax 80101083: 89 44 24 04 mov %eax,0x4(%esp) 80101087: 8b 47 10 mov 0x10(%edi),%eax 8010108a: 89 04 24 mov %eax,(%esp) 8010108d: e8 ce 09 00 00 call 80101a60 <writei> 80101092: 85 c0 test %eax,%eax 80101094: 7f 92 jg 80101028 <filewrite+0x48> iunlock(f->ip); 80101096: 8b 4f 10 mov 0x10(%edi),%ecx 80101099: 89 45 e0 mov %eax,-0x20(%ebp) 8010109c: 89 0c 24 mov %ecx,(%esp) 8010109f: e8 ec 06 00 00 call 80101790 <iunlock> end_op(); 801010a4: e8 d7 1a 00 00 call 80102b80 <end_op> if(r < 0) 801010a9: 8b 45 e0 mov -0x20(%ebp),%eax 801010ac: 85 c0 test %eax,%eax 801010ae: 74 91 je 80101041 <filewrite+0x61> } return i == n ? n : -1; } panic("filewrite"); } 801010b0: 83 c4 2c add $0x2c,%esp return -1; 801010b3: b8 ff ff ff ff mov $0xffffffff,%eax } 801010b8: 5b pop %ebx 801010b9: 5e pop %esi 801010ba: 5f pop %edi 801010bb: 5d pop %ebp 801010bc: c3 ret 801010bd: 8d 76 00 lea 0x0(%esi),%esi return i == n ? n : -1; 801010c0: 3b 5d e4 cmp -0x1c(%ebp),%ebx 801010c3: 89 d8 mov %ebx,%eax 801010c5: 75 e9 jne 801010b0 <filewrite+0xd0> } 801010c7: 83 c4 2c add $0x2c,%esp 801010ca: 5b pop %ebx 801010cb: 5e pop %esi 801010cc: 5f pop %edi 801010cd: 5d pop %ebp 801010ce: c3 ret return pipewrite(f->pipe, addr, n); 801010cf: 8b 47 0c mov 0xc(%edi),%eax 801010d2: 89 45 08 mov %eax,0x8(%ebp) } 801010d5: 83 c4 2c add $0x2c,%esp 801010d8: 5b pop %ebx 801010d9: 5e pop %esi 801010da: 5f pop %edi 801010db: 5d pop %ebp return pipewrite(f->pipe, addr, n); 801010dc: e9 0f 22 00 00 jmp 801032f0 <pipewrite> panic("short filewrite"); 801010e1: c7 04 24 8f 6c 10 80 movl $0x80106c8f,(%esp) 801010e8: e8 73 f2 ff ff call 80100360 <panic> panic("filewrite"); 801010ed: c7 04 24 95 6c 10 80 movl $0x80106c95,(%esp) 801010f4: e8 67 f2 ff ff call 80100360 <panic> 801010f9: 66 90 xchg %ax,%ax 801010fb: 66 90 xchg %ax,%ax 801010fd: 66 90 xchg %ax,%ax 801010ff: 90 nop 80101100 <bfree>: } // Free a disk block. static void bfree(int dev, uint b) { 80101100: 55 push %ebp 80101101: 89 e5 mov %esp,%ebp 80101103: 57 push %edi 80101104: 89 d7 mov %edx,%edi 80101106: 56 push %esi 80101107: 53 push %ebx struct buf *bp; int bi, m; bp = bread(dev, BBLOCK(b, sb)); bi = b % BPB; m = 1 << (bi % 8); 80101108: bb 01 00 00 00 mov $0x1,%ebx { 8010110d: 83 ec 1c sub $0x1c,%esp bp = bread(dev, BBLOCK(b, sb)); 80101110: c1 ea 0c shr $0xc,%edx 80101113: 03 15 d8 09 11 80 add 0x801109d8,%edx 80101119: 89 04 24 mov %eax,(%esp) 8010111c: 89 54 24 04 mov %edx,0x4(%esp) 80101120: e8 ab ef ff ff call 801000d0 <bread> m = 1 << (bi % 8); 80101125: 89 f9 mov %edi,%ecx bi = b % BPB; 80101127: 81 e7 ff 0f 00 00 and $0xfff,%edi 8010112d: 89 fa mov %edi,%edx m = 1 << (bi % 8); 8010112f: 83 e1 07 and $0x7,%ecx if((bp->data[bi/8] & m) == 0) 80101132: c1 fa 03 sar $0x3,%edx m = 1 << (bi % 8); 80101135: d3 e3 shl %cl,%ebx bp = bread(dev, BBLOCK(b, sb)); 80101137: 89 c6 mov %eax,%esi if((bp->data[bi/8] & m) == 0) 80101139: 0f b6 44 10 5c movzbl 0x5c(%eax,%edx,1),%eax 8010113e: 0f b6 c8 movzbl %al,%ecx 80101141: 85 d9 test %ebx,%ecx 80101143: 74 20 je 80101165 <bfree+0x65> panic("freeing free block"); bp->data[bi/8] &= ~m; 80101145: f7 d3 not %ebx 80101147: 21 c3 and %eax,%ebx 80101149: 88 5c 16 5c mov %bl,0x5c(%esi,%edx,1) log_write(bp); 8010114d: 89 34 24 mov %esi,(%esp) 80101150: e8 5b 1b 00 00 call 80102cb0 <log_write> brelse(bp); 80101155: 89 34 24 mov %esi,(%esp) 80101158: e8 83 f0 ff ff call 801001e0 <brelse> } 8010115d: 83 c4 1c add $0x1c,%esp 80101160: 5b pop %ebx 80101161: 5e pop %esi 80101162: 5f pop %edi 80101163: 5d pop %ebp 80101164: c3 ret panic("freeing free block"); 80101165: c7 04 24 9f 6c 10 80 movl $0x80106c9f,(%esp) 8010116c: e8 ef f1 ff ff call 80100360 <panic> 80101171: eb 0d jmp 80101180 <balloc> 80101173: 90 nop 80101174: 90 nop 80101175: 90 nop 80101176: 90 nop 80101177: 90 nop 80101178: 90 nop 80101179: 90 nop 8010117a: 90 nop 8010117b: 90 nop 8010117c: 90 nop 8010117d: 90 nop 8010117e: 90 nop 8010117f: 90 nop 80101180 <balloc>: { 80101180: 55 push %ebp 80101181: 89 e5 mov %esp,%ebp 80101183: 57 push %edi 80101184: 56 push %esi 80101185: 53 push %ebx 80101186: 83 ec 2c sub $0x2c,%esp 80101189: 89 45 d8 mov %eax,-0x28(%ebp) for(b = 0; b < sb.size; b += BPB){ 8010118c: a1 c0 09 11 80 mov 0x801109c0,%eax 80101191: 85 c0 test %eax,%eax 80101193: 0f 84 8c 00 00 00 je 80101225 <balloc+0xa5> 80101199: c7 45 dc 00 00 00 00 movl $0x0,-0x24(%ebp) bp = bread(dev, BBLOCK(b, sb)); 801011a0: 8b 75 dc mov -0x24(%ebp),%esi 801011a3: 89 f0 mov %esi,%eax 801011a5: c1 f8 0c sar $0xc,%eax 801011a8: 03 05 d8 09 11 80 add 0x801109d8,%eax 801011ae: 89 44 24 04 mov %eax,0x4(%esp) 801011b2: 8b 45 d8 mov -0x28(%ebp),%eax 801011b5: 89 04 24 mov %eax,(%esp) 801011b8: e8 13 ef ff ff call 801000d0 <bread> 801011bd: 89 45 e4 mov %eax,-0x1c(%ebp) 801011c0: a1 c0 09 11 80 mov 0x801109c0,%eax 801011c5: 89 45 e0 mov %eax,-0x20(%ebp) for(bi = 0; bi < BPB && b + bi < sb.size; bi++){ 801011c8: 31 c0 xor %eax,%eax 801011ca: eb 33 jmp 801011ff <balloc+0x7f> 801011cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if((bp->data[bi/8] & m) == 0){ // Is block free? 801011d0: 8b 5d e4 mov -0x1c(%ebp),%ebx 801011d3: 89 c2 mov %eax,%edx m = 1 << (bi % 8); 801011d5: 89 c1 mov %eax,%ecx if((bp->data[bi/8] & m) == 0){ // Is block free? 801011d7: c1 fa 03 sar $0x3,%edx m = 1 << (bi % 8); 801011da: 83 e1 07 and $0x7,%ecx 801011dd: bf 01 00 00 00 mov $0x1,%edi 801011e2: d3 e7 shl %cl,%edi if((bp->data[bi/8] & m) == 0){ // Is block free? 801011e4: 0f b6 5c 13 5c movzbl 0x5c(%ebx,%edx,1),%ebx m = 1 << (bi % 8); 801011e9: 89 f9 mov %edi,%ecx if((bp->data[bi/8] & m) == 0){ // Is block free? 801011eb: 0f b6 fb movzbl %bl,%edi 801011ee: 85 cf test %ecx,%edi 801011f0: 74 46 je 80101238 <balloc+0xb8> for(bi = 0; bi < BPB && b + bi < sb.size; bi++){ 801011f2: 83 c0 01 add $0x1,%eax 801011f5: 83 c6 01 add $0x1,%esi 801011f8: 3d 00 10 00 00 cmp $0x1000,%eax 801011fd: 74 05 je 80101204 <balloc+0x84> 801011ff: 3b 75 e0 cmp -0x20(%ebp),%esi 80101202: 72 cc jb 801011d0 <balloc+0x50> brelse(bp); 80101204: 8b 45 e4 mov -0x1c(%ebp),%eax 80101207: 89 04 24 mov %eax,(%esp) 8010120a: e8 d1 ef ff ff call 801001e0 <brelse> for(b = 0; b < sb.size; b += BPB){ 8010120f: 81 45 dc 00 10 00 00 addl $0x1000,-0x24(%ebp) 80101216: 8b 45 dc mov -0x24(%ebp),%eax 80101219: 3b 05 c0 09 11 80 cmp 0x801109c0,%eax 8010121f: 0f 82 7b ff ff ff jb 801011a0 <balloc+0x20> panic("balloc: out of blocks"); 80101225: c7 04 24 b2 6c 10 80 movl $0x80106cb2,(%esp) 8010122c: e8 2f f1 ff ff call 80100360 <panic> 80101231: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi bp->data[bi/8] |= m; // Mark block in use. 80101238: 09 d9 or %ebx,%ecx 8010123a: 8b 5d e4 mov -0x1c(%ebp),%ebx 8010123d: 88 4c 13 5c mov %cl,0x5c(%ebx,%edx,1) log_write(bp); 80101241: 89 1c 24 mov %ebx,(%esp) 80101244: e8 67 1a 00 00 call 80102cb0 <log_write> brelse(bp); 80101249: 89 1c 24 mov %ebx,(%esp) 8010124c: e8 8f ef ff ff call 801001e0 <brelse> bp = bread(dev, bno); 80101251: 8b 45 d8 mov -0x28(%ebp),%eax 80101254: 89 74 24 04 mov %esi,0x4(%esp) 80101258: 89 04 24 mov %eax,(%esp) 8010125b: e8 70 ee ff ff call 801000d0 <bread> memset(bp->data, 0, BSIZE); 80101260: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 80101267: 00 80101268: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 8010126f: 00 bp = bread(dev, bno); 80101270: 89 c3 mov %eax,%ebx memset(bp->data, 0, BSIZE); 80101272: 8d 40 5c lea 0x5c(%eax),%eax 80101275: 89 04 24 mov %eax,(%esp) 80101278: e8 23 30 00 00 call 801042a0 <memset> log_write(bp); 8010127d: 89 1c 24 mov %ebx,(%esp) 80101280: e8 2b 1a 00 00 call 80102cb0 <log_write> brelse(bp); 80101285: 89 1c 24 mov %ebx,(%esp) 80101288: e8 53 ef ff ff call 801001e0 <brelse> } 8010128d: 83 c4 2c add $0x2c,%esp 80101290: 89 f0 mov %esi,%eax 80101292: 5b pop %ebx 80101293: 5e pop %esi 80101294: 5f pop %edi 80101295: 5d pop %ebp 80101296: c3 ret 80101297: 89 f6 mov %esi,%esi 80101299: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801012a0 <iget>: // Find the inode with number inum on device dev // and return the in-memory copy. Does not lock // the inode and does not read it from disk. static struct inode* iget(uint dev, uint inum) { 801012a0: 55 push %ebp 801012a1: 89 e5 mov %esp,%ebp 801012a3: 57 push %edi 801012a4: 89 c7 mov %eax,%edi 801012a6: 56 push %esi struct inode *ip, *empty; acquire(&icache.lock); // Is the inode already cached? empty = 0; 801012a7: 31 f6 xor %esi,%esi { 801012a9: 53 push %ebx for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ 801012aa: bb 14 0a 11 80 mov $0x80110a14,%ebx { 801012af: 83 ec 1c sub $0x1c,%esp acquire(&icache.lock); 801012b2: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) { 801012b9: 89 55 e4 mov %edx,-0x1c(%ebp) acquire(&icache.lock); 801012bc: e8 1f 2f 00 00 call 801041e0 <acquire> for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ 801012c1: 8b 55 e4 mov -0x1c(%ebp),%edx 801012c4: eb 14 jmp 801012da <iget+0x3a> 801012c6: 66 90 xchg %ax,%ax if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){ ip->ref++; release(&icache.lock); return ip; } if(empty == 0 && ip->ref == 0) // Remember empty slot. 801012c8: 85 f6 test %esi,%esi 801012ca: 74 3c je 80101308 <iget+0x68> for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ 801012cc: 81 c3 90 00 00 00 add $0x90,%ebx 801012d2: 81 fb 34 26 11 80 cmp $0x80112634,%ebx 801012d8: 74 46 je 80101320 <iget+0x80> if(ip->ref > 0 && ip->dev == dev && ip->inum == inum){ 801012da: 8b 4b 08 mov 0x8(%ebx),%ecx 801012dd: 85 c9 test %ecx,%ecx 801012df: 7e e7 jle 801012c8 <iget+0x28> 801012e1: 39 3b cmp %edi,(%ebx) 801012e3: 75 e3 jne 801012c8 <iget+0x28> 801012e5: 39 53 04 cmp %edx,0x4(%ebx) 801012e8: 75 de jne 801012c8 <iget+0x28> ip->ref++; 801012ea: 83 c1 01 add $0x1,%ecx return ip; 801012ed: 89 de mov %ebx,%esi release(&icache.lock); 801012ef: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) ip->ref++; 801012f6: 89 4b 08 mov %ecx,0x8(%ebx) release(&icache.lock); 801012f9: e8 52 2f 00 00 call 80104250 <release> ip->ref = 1; ip->valid = 0; release(&icache.lock); return ip; } 801012fe: 83 c4 1c add $0x1c,%esp 80101301: 89 f0 mov %esi,%eax 80101303: 5b pop %ebx 80101304: 5e pop %esi 80101305: 5f pop %edi 80101306: 5d pop %ebp 80101307: c3 ret 80101308: 85 c9 test %ecx,%ecx 8010130a: 0f 44 f3 cmove %ebx,%esi for(ip = &icache.inode[0]; ip < &icache.inode[NINODE]; ip++){ 8010130d: 81 c3 90 00 00 00 add $0x90,%ebx 80101313: 81 fb 34 26 11 80 cmp $0x80112634,%ebx 80101319: 75 bf jne 801012da <iget+0x3a> 8010131b: 90 nop 8010131c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(empty == 0) 80101320: 85 f6 test %esi,%esi 80101322: 74 29 je 8010134d <iget+0xad> ip->dev = dev; 80101324: 89 3e mov %edi,(%esi) ip->inum = inum; 80101326: 89 56 04 mov %edx,0x4(%esi) ip->ref = 1; 80101329: c7 46 08 01 00 00 00 movl $0x1,0x8(%esi) ip->valid = 0; 80101330: c7 46 4c 00 00 00 00 movl $0x0,0x4c(%esi) release(&icache.lock); 80101337: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) 8010133e: e8 0d 2f 00 00 call 80104250 <release> } 80101343: 83 c4 1c add $0x1c,%esp 80101346: 89 f0 mov %esi,%eax 80101348: 5b pop %ebx 80101349: 5e pop %esi 8010134a: 5f pop %edi 8010134b: 5d pop %ebp 8010134c: c3 ret panic("iget: no inodes"); 8010134d: c7 04 24 c8 6c 10 80 movl $0x80106cc8,(%esp) 80101354: e8 07 f0 ff ff call 80100360 <panic> 80101359: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80101360 <bmap>: // Return the disk block address of the nth block in inode ip. // If there is no such block, bmap allocates one. static uint bmap(struct inode *ip, uint bn) { 80101360: 55 push %ebp 80101361: 89 e5 mov %esp,%ebp 80101363: 57 push %edi 80101364: 56 push %esi 80101365: 53 push %ebx 80101366: 89 c3 mov %eax,%ebx 80101368: 83 ec 1c sub $0x1c,%esp uint addr, *a; struct buf *bp; if(bn < NDIRECT){ 8010136b: 83 fa 0b cmp $0xb,%edx 8010136e: 77 18 ja 80101388 <bmap+0x28> 80101370: 8d 34 90 lea (%eax,%edx,4),%esi if((addr = ip->addrs[bn]) == 0) 80101373: 8b 46 5c mov 0x5c(%esi),%eax 80101376: 85 c0 test %eax,%eax 80101378: 74 66 je 801013e0 <bmap+0x80> brelse(bp); return addr; } panic("bmap: out of range"); } 8010137a: 83 c4 1c add $0x1c,%esp 8010137d: 5b pop %ebx 8010137e: 5e pop %esi 8010137f: 5f pop %edi 80101380: 5d pop %ebp 80101381: c3 ret 80101382: 8d b6 00 00 00 00 lea 0x0(%esi),%esi bn -= NDIRECT; 80101388: 8d 72 f4 lea -0xc(%edx),%esi if(bn < NINDIRECT){ 8010138b: 83 fe 7f cmp $0x7f,%esi 8010138e: 77 77 ja 80101407 <bmap+0xa7> if((addr = ip->addrs[NDIRECT]) == 0) 80101390: 8b 80 8c 00 00 00 mov 0x8c(%eax),%eax 80101396: 85 c0 test %eax,%eax 80101398: 74 5e je 801013f8 <bmap+0x98> bp = bread(ip->dev, addr); 8010139a: 89 44 24 04 mov %eax,0x4(%esp) 8010139e: 8b 03 mov (%ebx),%eax 801013a0: 89 04 24 mov %eax,(%esp) 801013a3: e8 28 ed ff ff call 801000d0 <bread> if((addr = a[bn]) == 0){ 801013a8: 8d 54 b0 5c lea 0x5c(%eax,%esi,4),%edx bp = bread(ip->dev, addr); 801013ac: 89 c7 mov %eax,%edi if((addr = a[bn]) == 0){ 801013ae: 8b 32 mov (%edx),%esi 801013b0: 85 f6 test %esi,%esi 801013b2: 75 19 jne 801013cd <bmap+0x6d> a[bn] = addr = balloc(ip->dev); 801013b4: 8b 03 mov (%ebx),%eax 801013b6: 89 55 e4 mov %edx,-0x1c(%ebp) 801013b9: e8 c2 fd ff ff call 80101180 <balloc> 801013be: 8b 55 e4 mov -0x1c(%ebp),%edx 801013c1: 89 02 mov %eax,(%edx) 801013c3: 89 c6 mov %eax,%esi log_write(bp); 801013c5: 89 3c 24 mov %edi,(%esp) 801013c8: e8 e3 18 00 00 call 80102cb0 <log_write> brelse(bp); 801013cd: 89 3c 24 mov %edi,(%esp) 801013d0: e8 0b ee ff ff call 801001e0 <brelse> } 801013d5: 83 c4 1c add $0x1c,%esp brelse(bp); 801013d8: 89 f0 mov %esi,%eax } 801013da: 5b pop %ebx 801013db: 5e pop %esi 801013dc: 5f pop %edi 801013dd: 5d pop %ebp 801013de: c3 ret 801013df: 90 nop ip->addrs[bn] = addr = balloc(ip->dev); 801013e0: 8b 03 mov (%ebx),%eax 801013e2: e8 99 fd ff ff call 80101180 <balloc> 801013e7: 89 46 5c mov %eax,0x5c(%esi) } 801013ea: 83 c4 1c add $0x1c,%esp 801013ed: 5b pop %ebx 801013ee: 5e pop %esi 801013ef: 5f pop %edi 801013f0: 5d pop %ebp 801013f1: c3 ret 801013f2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi ip->addrs[NDIRECT] = addr = balloc(ip->dev); 801013f8: 8b 03 mov (%ebx),%eax 801013fa: e8 81 fd ff ff call 80101180 <balloc> 801013ff: 89 83 8c 00 00 00 mov %eax,0x8c(%ebx) 80101405: eb 93 jmp 8010139a <bmap+0x3a> panic("bmap: out of range"); 80101407: c7 04 24 d8 6c 10 80 movl $0x80106cd8,(%esp) 8010140e: e8 4d ef ff ff call 80100360 <panic> 80101413: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80101419: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101420 <readsb>: { 80101420: 55 push %ebp 80101421: 89 e5 mov %esp,%ebp 80101423: 56 push %esi 80101424: 53 push %ebx 80101425: 83 ec 10 sub $0x10,%esp bp = bread(dev, 1); 80101428: 8b 45 08 mov 0x8(%ebp),%eax 8010142b: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) 80101432: 00 { 80101433: 8b 75 0c mov 0xc(%ebp),%esi bp = bread(dev, 1); 80101436: 89 04 24 mov %eax,(%esp) 80101439: e8 92 ec ff ff call 801000d0 <bread> memmove(sb, bp->data, sizeof(*sb)); 8010143e: 89 34 24 mov %esi,(%esp) 80101441: c7 44 24 08 1c 00 00 movl $0x1c,0x8(%esp) 80101448: 00 bp = bread(dev, 1); 80101449: 89 c3 mov %eax,%ebx memmove(sb, bp->data, sizeof(*sb)); 8010144b: 8d 40 5c lea 0x5c(%eax),%eax 8010144e: 89 44 24 04 mov %eax,0x4(%esp) 80101452: e8 e9 2e 00 00 call 80104340 <memmove> brelse(bp); 80101457: 89 5d 08 mov %ebx,0x8(%ebp) } 8010145a: 83 c4 10 add $0x10,%esp 8010145d: 5b pop %ebx 8010145e: 5e pop %esi 8010145f: 5d pop %ebp brelse(bp); 80101460: e9 7b ed ff ff jmp 801001e0 <brelse> 80101465: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101469: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101470 <iinit>: { 80101470: 55 push %ebp 80101471: 89 e5 mov %esp,%ebp 80101473: 53 push %ebx 80101474: bb 20 0a 11 80 mov $0x80110a20,%ebx 80101479: 83 ec 24 sub $0x24,%esp initlock(&icache.lock, "icache"); 8010147c: c7 44 24 04 eb 6c 10 movl $0x80106ceb,0x4(%esp) 80101483: 80 80101484: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) 8010148b: e8 e0 2b 00 00 call 80104070 <initlock> initsleeplock(&icache.inode[i].lock, "inode"); 80101490: 89 1c 24 mov %ebx,(%esp) 80101493: 81 c3 90 00 00 00 add $0x90,%ebx 80101499: c7 44 24 04 f2 6c 10 movl $0x80106cf2,0x4(%esp) 801014a0: 80 801014a1: e8 9a 2a 00 00 call 80103f40 <initsleeplock> for(i = 0; i < NINODE; i++) { 801014a6: 81 fb 40 26 11 80 cmp $0x80112640,%ebx 801014ac: 75 e2 jne 80101490 <iinit+0x20> readsb(dev, &sb); 801014ae: 8b 45 08 mov 0x8(%ebp),%eax 801014b1: c7 44 24 04 c0 09 11 movl $0x801109c0,0x4(%esp) 801014b8: 80 801014b9: 89 04 24 mov %eax,(%esp) 801014bc: e8 5f ff ff ff call 80101420 <readsb> cprintf("sb: size %d nblocks %d ninodes %d nlog %d logstart %d\ 801014c1: a1 d8 09 11 80 mov 0x801109d8,%eax 801014c6: c7 04 24 58 6d 10 80 movl $0x80106d58,(%esp) 801014cd: 89 44 24 1c mov %eax,0x1c(%esp) 801014d1: a1 d4 09 11 80 mov 0x801109d4,%eax 801014d6: 89 44 24 18 mov %eax,0x18(%esp) 801014da: a1 d0 09 11 80 mov 0x801109d0,%eax 801014df: 89 44 24 14 mov %eax,0x14(%esp) 801014e3: a1 cc 09 11 80 mov 0x801109cc,%eax 801014e8: 89 44 24 10 mov %eax,0x10(%esp) 801014ec: a1 c8 09 11 80 mov 0x801109c8,%eax 801014f1: 89 44 24 0c mov %eax,0xc(%esp) 801014f5: a1 c4 09 11 80 mov 0x801109c4,%eax 801014fa: 89 44 24 08 mov %eax,0x8(%esp) 801014fe: a1 c0 09 11 80 mov 0x801109c0,%eax 80101503: 89 44 24 04 mov %eax,0x4(%esp) 80101507: e8 44 f1 ff ff call 80100650 <cprintf> } 8010150c: 83 c4 24 add $0x24,%esp 8010150f: 5b pop %ebx 80101510: 5d pop %ebp 80101511: c3 ret 80101512: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80101519: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101520 <ialloc>: { 80101520: 55 push %ebp 80101521: 89 e5 mov %esp,%ebp 80101523: 57 push %edi 80101524: 56 push %esi 80101525: 53 push %ebx 80101526: 83 ec 2c sub $0x2c,%esp 80101529: 8b 45 0c mov 0xc(%ebp),%eax for(inum = 1; inum < sb.ninodes; inum++){ 8010152c: 83 3d c8 09 11 80 01 cmpl $0x1,0x801109c8 { 80101533: 8b 7d 08 mov 0x8(%ebp),%edi 80101536: 89 45 e4 mov %eax,-0x1c(%ebp) for(inum = 1; inum < sb.ninodes; inum++){ 80101539: 0f 86 a2 00 00 00 jbe 801015e1 <ialloc+0xc1> 8010153f: be 01 00 00 00 mov $0x1,%esi 80101544: bb 01 00 00 00 mov $0x1,%ebx 80101549: eb 1a jmp 80101565 <ialloc+0x45> 8010154b: 90 nop 8010154c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi brelse(bp); 80101550: 89 14 24 mov %edx,(%esp) for(inum = 1; inum < sb.ninodes; inum++){ 80101553: 83 c3 01 add $0x1,%ebx brelse(bp); 80101556: e8 85 ec ff ff call 801001e0 <brelse> for(inum = 1; inum < sb.ninodes; inum++){ 8010155b: 89 de mov %ebx,%esi 8010155d: 3b 1d c8 09 11 80 cmp 0x801109c8,%ebx 80101563: 73 7c jae 801015e1 <ialloc+0xc1> bp = bread(dev, IBLOCK(inum, sb)); 80101565: 89 f0 mov %esi,%eax 80101567: c1 e8 03 shr $0x3,%eax 8010156a: 03 05 d4 09 11 80 add 0x801109d4,%eax 80101570: 89 3c 24 mov %edi,(%esp) 80101573: 89 44 24 04 mov %eax,0x4(%esp) 80101577: e8 54 eb ff ff call 801000d0 <bread> 8010157c: 89 c2 mov %eax,%edx dip = (struct dinode*)bp->data + inum%IPB; 8010157e: 89 f0 mov %esi,%eax 80101580: 83 e0 07 and $0x7,%eax 80101583: c1 e0 06 shl $0x6,%eax 80101586: 8d 4c 02 5c lea 0x5c(%edx,%eax,1),%ecx if(dip->type == 0){ // a free inode 8010158a: 66 83 39 00 cmpw $0x0,(%ecx) 8010158e: 75 c0 jne 80101550 <ialloc+0x30> memset(dip, 0, sizeof(*dip)); 80101590: 89 0c 24 mov %ecx,(%esp) 80101593: c7 44 24 08 40 00 00 movl $0x40,0x8(%esp) 8010159a: 00 8010159b: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 801015a2: 00 801015a3: 89 55 dc mov %edx,-0x24(%ebp) 801015a6: 89 4d e0 mov %ecx,-0x20(%ebp) 801015a9: e8 f2 2c 00 00 call 801042a0 <memset> dip->type = type; 801015ae: 0f b7 45 e4 movzwl -0x1c(%ebp),%eax log_write(bp); // mark it allocated on the disk 801015b2: 8b 55 dc mov -0x24(%ebp),%edx dip->type = type; 801015b5: 8b 4d e0 mov -0x20(%ebp),%ecx log_write(bp); // mark it allocated on the disk 801015b8: 89 55 e4 mov %edx,-0x1c(%ebp) dip->type = type; 801015bb: 66 89 01 mov %ax,(%ecx) log_write(bp); // mark it allocated on the disk 801015be: 89 14 24 mov %edx,(%esp) 801015c1: e8 ea 16 00 00 call 80102cb0 <log_write> brelse(bp); 801015c6: 8b 55 e4 mov -0x1c(%ebp),%edx 801015c9: 89 14 24 mov %edx,(%esp) 801015cc: e8 0f ec ff ff call 801001e0 <brelse> } 801015d1: 83 c4 2c add $0x2c,%esp return iget(dev, inum); 801015d4: 89 f2 mov %esi,%edx } 801015d6: 5b pop %ebx return iget(dev, inum); 801015d7: 89 f8 mov %edi,%eax } 801015d9: 5e pop %esi 801015da: 5f pop %edi 801015db: 5d pop %ebp return iget(dev, inum); 801015dc: e9 bf fc ff ff jmp 801012a0 <iget> panic("ialloc: no inodes"); 801015e1: c7 04 24 f8 6c 10 80 movl $0x80106cf8,(%esp) 801015e8: e8 73 ed ff ff call 80100360 <panic> 801015ed: 8d 76 00 lea 0x0(%esi),%esi 801015f0 <iupdate>: { 801015f0: 55 push %ebp 801015f1: 89 e5 mov %esp,%ebp 801015f3: 56 push %esi 801015f4: 53 push %ebx 801015f5: 83 ec 10 sub $0x10,%esp 801015f8: 8b 5d 08 mov 0x8(%ebp),%ebx bp = bread(ip->dev, IBLOCK(ip->inum, sb)); 801015fb: 8b 43 04 mov 0x4(%ebx),%eax memmove(dip->addrs, ip->addrs, sizeof(ip->addrs)); 801015fe: 83 c3 5c add $0x5c,%ebx bp = bread(ip->dev, IBLOCK(ip->inum, sb)); 80101601: c1 e8 03 shr $0x3,%eax 80101604: 03 05 d4 09 11 80 add 0x801109d4,%eax 8010160a: 89 44 24 04 mov %eax,0x4(%esp) 8010160e: 8b 43 a4 mov -0x5c(%ebx),%eax 80101611: 89 04 24 mov %eax,(%esp) 80101614: e8 b7 ea ff ff call 801000d0 <bread> dip = (struct dinode*)bp->data + ip->inum%IPB; 80101619: 8b 53 a8 mov -0x58(%ebx),%edx 8010161c: 83 e2 07 and $0x7,%edx 8010161f: c1 e2 06 shl $0x6,%edx 80101622: 8d 54 10 5c lea 0x5c(%eax,%edx,1),%edx bp = bread(ip->dev, IBLOCK(ip->inum, sb)); 80101626: 89 c6 mov %eax,%esi dip->type = ip->type; 80101628: 0f b7 43 f4 movzwl -0xc(%ebx),%eax memmove(dip->addrs, ip->addrs, sizeof(ip->addrs)); 8010162c: 83 c2 0c add $0xc,%edx dip->type = ip->type; 8010162f: 66 89 42 f4 mov %ax,-0xc(%edx) dip->major = ip->major; 80101633: 0f b7 43 f6 movzwl -0xa(%ebx),%eax 80101637: 66 89 42 f6 mov %ax,-0xa(%edx) dip->minor = ip->minor; 8010163b: 0f b7 43 f8 movzwl -0x8(%ebx),%eax 8010163f: 66 89 42 f8 mov %ax,-0x8(%edx) dip->nlink = ip->nlink; 80101643: 0f b7 43 fa movzwl -0x6(%ebx),%eax 80101647: 66 89 42 fa mov %ax,-0x6(%edx) dip->size = ip->size; 8010164b: 8b 43 fc mov -0x4(%ebx),%eax 8010164e: 89 42 fc mov %eax,-0x4(%edx) memmove(dip->addrs, ip->addrs, sizeof(ip->addrs)); 80101651: 89 5c 24 04 mov %ebx,0x4(%esp) 80101655: 89 14 24 mov %edx,(%esp) 80101658: c7 44 24 08 34 00 00 movl $0x34,0x8(%esp) 8010165f: 00 80101660: e8 db 2c 00 00 call 80104340 <memmove> log_write(bp); 80101665: 89 34 24 mov %esi,(%esp) 80101668: e8 43 16 00 00 call 80102cb0 <log_write> brelse(bp); 8010166d: 89 75 08 mov %esi,0x8(%ebp) } 80101670: 83 c4 10 add $0x10,%esp 80101673: 5b pop %ebx 80101674: 5e pop %esi 80101675: 5d pop %ebp brelse(bp); 80101676: e9 65 eb ff ff jmp 801001e0 <brelse> 8010167b: 90 nop 8010167c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101680 <idup>: { 80101680: 55 push %ebp 80101681: 89 e5 mov %esp,%ebp 80101683: 53 push %ebx 80101684: 83 ec 14 sub $0x14,%esp 80101687: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&icache.lock); 8010168a: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) 80101691: e8 4a 2b 00 00 call 801041e0 <acquire> ip->ref++; 80101696: 83 43 08 01 addl $0x1,0x8(%ebx) release(&icache.lock); 8010169a: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) 801016a1: e8 aa 2b 00 00 call 80104250 <release> } 801016a6: 83 c4 14 add $0x14,%esp 801016a9: 89 d8 mov %ebx,%eax 801016ab: 5b pop %ebx 801016ac: 5d pop %ebp 801016ad: c3 ret 801016ae: 66 90 xchg %ax,%ax 801016b0 <ilock>: { 801016b0: 55 push %ebp 801016b1: 89 e5 mov %esp,%ebp 801016b3: 56 push %esi 801016b4: 53 push %ebx 801016b5: 83 ec 10 sub $0x10,%esp 801016b8: 8b 5d 08 mov 0x8(%ebp),%ebx if(ip == 0 || ip->ref < 1) 801016bb: 85 db test %ebx,%ebx 801016bd: 0f 84 b3 00 00 00 je 80101776 <ilock+0xc6> 801016c3: 8b 53 08 mov 0x8(%ebx),%edx 801016c6: 85 d2 test %edx,%edx 801016c8: 0f 8e a8 00 00 00 jle 80101776 <ilock+0xc6> acquiresleep(&ip->lock); 801016ce: 8d 43 0c lea 0xc(%ebx),%eax 801016d1: 89 04 24 mov %eax,(%esp) 801016d4: e8 a7 28 00 00 call 80103f80 <acquiresleep> if(ip->valid == 0){ 801016d9: 8b 43 4c mov 0x4c(%ebx),%eax 801016dc: 85 c0 test %eax,%eax 801016de: 74 08 je 801016e8 <ilock+0x38> } 801016e0: 83 c4 10 add $0x10,%esp 801016e3: 5b pop %ebx 801016e4: 5e pop %esi 801016e5: 5d pop %ebp 801016e6: c3 ret 801016e7: 90 nop bp = bread(ip->dev, IBLOCK(ip->inum, sb)); 801016e8: 8b 43 04 mov 0x4(%ebx),%eax 801016eb: c1 e8 03 shr $0x3,%eax 801016ee: 03 05 d4 09 11 80 add 0x801109d4,%eax 801016f4: 89 44 24 04 mov %eax,0x4(%esp) 801016f8: 8b 03 mov (%ebx),%eax 801016fa: 89 04 24 mov %eax,(%esp) 801016fd: e8 ce e9 ff ff call 801000d0 <bread> dip = (struct dinode*)bp->data + ip->inum%IPB; 80101702: 8b 53 04 mov 0x4(%ebx),%edx 80101705: 83 e2 07 and $0x7,%edx 80101708: c1 e2 06 shl $0x6,%edx 8010170b: 8d 54 10 5c lea 0x5c(%eax,%edx,1),%edx bp = bread(ip->dev, IBLOCK(ip->inum, sb)); 8010170f: 89 c6 mov %eax,%esi ip->type = dip->type; 80101711: 0f b7 02 movzwl (%edx),%eax memmove(ip->addrs, dip->addrs, sizeof(ip->addrs)); 80101714: 83 c2 0c add $0xc,%edx ip->type = dip->type; 80101717: 66 89 43 50 mov %ax,0x50(%ebx) ip->major = dip->major; 8010171b: 0f b7 42 f6 movzwl -0xa(%edx),%eax 8010171f: 66 89 43 52 mov %ax,0x52(%ebx) ip->minor = dip->minor; 80101723: 0f b7 42 f8 movzwl -0x8(%edx),%eax 80101727: 66 89 43 54 mov %ax,0x54(%ebx) ip->nlink = dip->nlink; 8010172b: 0f b7 42 fa movzwl -0x6(%edx),%eax 8010172f: 66 89 43 56 mov %ax,0x56(%ebx) ip->size = dip->size; 80101733: 8b 42 fc mov -0x4(%edx),%eax 80101736: 89 43 58 mov %eax,0x58(%ebx) memmove(ip->addrs, dip->addrs, sizeof(ip->addrs)); 80101739: 8d 43 5c lea 0x5c(%ebx),%eax 8010173c: 89 54 24 04 mov %edx,0x4(%esp) 80101740: c7 44 24 08 34 00 00 movl $0x34,0x8(%esp) 80101747: 00 80101748: 89 04 24 mov %eax,(%esp) 8010174b: e8 f0 2b 00 00 call 80104340 <memmove> brelse(bp); 80101750: 89 34 24 mov %esi,(%esp) 80101753: e8 88 ea ff ff call 801001e0 <brelse> if(ip->type == 0) 80101758: 66 83 7b 50 00 cmpw $0x0,0x50(%ebx) ip->valid = 1; 8010175d: c7 43 4c 01 00 00 00 movl $0x1,0x4c(%ebx) if(ip->type == 0) 80101764: 0f 85 76 ff ff ff jne 801016e0 <ilock+0x30> panic("ilock: no type"); 8010176a: c7 04 24 10 6d 10 80 movl $0x80106d10,(%esp) 80101771: e8 ea eb ff ff call 80100360 <panic> panic("ilock"); 80101776: c7 04 24 0a 6d 10 80 movl $0x80106d0a,(%esp) 8010177d: e8 de eb ff ff call 80100360 <panic> 80101782: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80101789: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101790 <iunlock>: { 80101790: 55 push %ebp 80101791: 89 e5 mov %esp,%ebp 80101793: 56 push %esi 80101794: 53 push %ebx 80101795: 83 ec 10 sub $0x10,%esp 80101798: 8b 5d 08 mov 0x8(%ebp),%ebx if(ip == 0 || !holdingsleep(&ip->lock) || ip->ref < 1) 8010179b: 85 db test %ebx,%ebx 8010179d: 74 24 je 801017c3 <iunlock+0x33> 8010179f: 8d 73 0c lea 0xc(%ebx),%esi 801017a2: 89 34 24 mov %esi,(%esp) 801017a5: e8 76 28 00 00 call 80104020 <holdingsleep> 801017aa: 85 c0 test %eax,%eax 801017ac: 74 15 je 801017c3 <iunlock+0x33> 801017ae: 8b 43 08 mov 0x8(%ebx),%eax 801017b1: 85 c0 test %eax,%eax 801017b3: 7e 0e jle 801017c3 <iunlock+0x33> releasesleep(&ip->lock); 801017b5: 89 75 08 mov %esi,0x8(%ebp) } 801017b8: 83 c4 10 add $0x10,%esp 801017bb: 5b pop %ebx 801017bc: 5e pop %esi 801017bd: 5d pop %ebp releasesleep(&ip->lock); 801017be: e9 1d 28 00 00 jmp 80103fe0 <releasesleep> panic("iunlock"); 801017c3: c7 04 24 1f 6d 10 80 movl $0x80106d1f,(%esp) 801017ca: e8 91 eb ff ff call 80100360 <panic> 801017cf: 90 nop 801017d0 <iput>: { 801017d0: 55 push %ebp 801017d1: 89 e5 mov %esp,%ebp 801017d3: 57 push %edi 801017d4: 56 push %esi 801017d5: 53 push %ebx 801017d6: 83 ec 1c sub $0x1c,%esp 801017d9: 8b 75 08 mov 0x8(%ebp),%esi acquiresleep(&ip->lock); 801017dc: 8d 7e 0c lea 0xc(%esi),%edi 801017df: 89 3c 24 mov %edi,(%esp) 801017e2: e8 99 27 00 00 call 80103f80 <acquiresleep> if(ip->valid && ip->nlink == 0){ 801017e7: 8b 56 4c mov 0x4c(%esi),%edx 801017ea: 85 d2 test %edx,%edx 801017ec: 74 07 je 801017f5 <iput+0x25> 801017ee: 66 83 7e 56 00 cmpw $0x0,0x56(%esi) 801017f3: 74 2b je 80101820 <iput+0x50> releasesleep(&ip->lock); 801017f5: 89 3c 24 mov %edi,(%esp) 801017f8: e8 e3 27 00 00 call 80103fe0 <releasesleep> acquire(&icache.lock); 801017fd: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) 80101804: e8 d7 29 00 00 call 801041e0 <acquire> ip->ref--; 80101809: 83 6e 08 01 subl $0x1,0x8(%esi) release(&icache.lock); 8010180d: c7 45 08 e0 09 11 80 movl $0x801109e0,0x8(%ebp) } 80101814: 83 c4 1c add $0x1c,%esp 80101817: 5b pop %ebx 80101818: 5e pop %esi 80101819: 5f pop %edi 8010181a: 5d pop %ebp release(&icache.lock); 8010181b: e9 30 2a 00 00 jmp 80104250 <release> acquire(&icache.lock); 80101820: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) 80101827: e8 b4 29 00 00 call 801041e0 <acquire> int r = ip->ref; 8010182c: 8b 5e 08 mov 0x8(%esi),%ebx release(&icache.lock); 8010182f: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) 80101836: e8 15 2a 00 00 call 80104250 <release> if(r == 1){ 8010183b: 83 fb 01 cmp $0x1,%ebx 8010183e: 75 b5 jne 801017f5 <iput+0x25> 80101840: 8d 4e 30 lea 0x30(%esi),%ecx 80101843: 89 f3 mov %esi,%ebx 80101845: 89 7d e4 mov %edi,-0x1c(%ebp) 80101848: 89 cf mov %ecx,%edi 8010184a: eb 0b jmp 80101857 <iput+0x87> 8010184c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101850: 83 c3 04 add $0x4,%ebx { int i, j; struct buf *bp; uint *a; for(i = 0; i < NDIRECT; i++){ 80101853: 39 fb cmp %edi,%ebx 80101855: 74 19 je 80101870 <iput+0xa0> if(ip->addrs[i]){ 80101857: 8b 53 5c mov 0x5c(%ebx),%edx 8010185a: 85 d2 test %edx,%edx 8010185c: 74 f2 je 80101850 <iput+0x80> bfree(ip->dev, ip->addrs[i]); 8010185e: 8b 06 mov (%esi),%eax 80101860: e8 9b f8 ff ff call 80101100 <bfree> ip->addrs[i] = 0; 80101865: c7 43 5c 00 00 00 00 movl $0x0,0x5c(%ebx) 8010186c: eb e2 jmp 80101850 <iput+0x80> 8010186e: 66 90 xchg %ax,%ax } } if(ip->addrs[NDIRECT]){ 80101870: 8b 86 8c 00 00 00 mov 0x8c(%esi),%eax 80101876: 8b 7d e4 mov -0x1c(%ebp),%edi 80101879: 85 c0 test %eax,%eax 8010187b: 75 2b jne 801018a8 <iput+0xd8> brelse(bp); bfree(ip->dev, ip->addrs[NDIRECT]); ip->addrs[NDIRECT] = 0; } ip->size = 0; 8010187d: c7 46 58 00 00 00 00 movl $0x0,0x58(%esi) iupdate(ip); 80101884: 89 34 24 mov %esi,(%esp) 80101887: e8 64 fd ff ff call 801015f0 <iupdate> ip->type = 0; 8010188c: 31 c0 xor %eax,%eax 8010188e: 66 89 46 50 mov %ax,0x50(%esi) iupdate(ip); 80101892: 89 34 24 mov %esi,(%esp) 80101895: e8 56 fd ff ff call 801015f0 <iupdate> ip->valid = 0; 8010189a: c7 46 4c 00 00 00 00 movl $0x0,0x4c(%esi) 801018a1: e9 4f ff ff ff jmp 801017f5 <iput+0x25> 801018a6: 66 90 xchg %ax,%ax bp = bread(ip->dev, ip->addrs[NDIRECT]); 801018a8: 89 44 24 04 mov %eax,0x4(%esp) 801018ac: 8b 06 mov (%esi),%eax for(j = 0; j < NINDIRECT; j++){ 801018ae: 31 db xor %ebx,%ebx bp = bread(ip->dev, ip->addrs[NDIRECT]); 801018b0: 89 04 24 mov %eax,(%esp) 801018b3: e8 18 e8 ff ff call 801000d0 <bread> for(j = 0; j < NINDIRECT; j++){ 801018b8: 89 7d e0 mov %edi,-0x20(%ebp) a = (uint*)bp->data; 801018bb: 8d 48 5c lea 0x5c(%eax),%ecx bp = bread(ip->dev, ip->addrs[NDIRECT]); 801018be: 89 45 e4 mov %eax,-0x1c(%ebp) for(j = 0; j < NINDIRECT; j++){ 801018c1: 89 cf mov %ecx,%edi 801018c3: 31 c0 xor %eax,%eax 801018c5: eb 0e jmp 801018d5 <iput+0x105> 801018c7: 90 nop 801018c8: 83 c3 01 add $0x1,%ebx 801018cb: 81 fb 80 00 00 00 cmp $0x80,%ebx 801018d1: 89 d8 mov %ebx,%eax 801018d3: 74 10 je 801018e5 <iput+0x115> if(a[j]) 801018d5: 8b 14 87 mov (%edi,%eax,4),%edx 801018d8: 85 d2 test %edx,%edx 801018da: 74 ec je 801018c8 <iput+0xf8> bfree(ip->dev, a[j]); 801018dc: 8b 06 mov (%esi),%eax 801018de: e8 1d f8 ff ff call 80101100 <bfree> 801018e3: eb e3 jmp 801018c8 <iput+0xf8> brelse(bp); 801018e5: 8b 45 e4 mov -0x1c(%ebp),%eax 801018e8: 8b 7d e0 mov -0x20(%ebp),%edi 801018eb: 89 04 24 mov %eax,(%esp) 801018ee: e8 ed e8 ff ff call 801001e0 <brelse> bfree(ip->dev, ip->addrs[NDIRECT]); 801018f3: 8b 96 8c 00 00 00 mov 0x8c(%esi),%edx 801018f9: 8b 06 mov (%esi),%eax 801018fb: e8 00 f8 ff ff call 80101100 <bfree> ip->addrs[NDIRECT] = 0; 80101900: c7 86 8c 00 00 00 00 movl $0x0,0x8c(%esi) 80101907: 00 00 00 8010190a: e9 6e ff ff ff jmp 8010187d <iput+0xad> 8010190f: 90 nop 80101910 <iunlockput>: { 80101910: 55 push %ebp 80101911: 89 e5 mov %esp,%ebp 80101913: 53 push %ebx 80101914: 83 ec 14 sub $0x14,%esp 80101917: 8b 5d 08 mov 0x8(%ebp),%ebx iunlock(ip); 8010191a: 89 1c 24 mov %ebx,(%esp) 8010191d: e8 6e fe ff ff call 80101790 <iunlock> iput(ip); 80101922: 89 5d 08 mov %ebx,0x8(%ebp) } 80101925: 83 c4 14 add $0x14,%esp 80101928: 5b pop %ebx 80101929: 5d pop %ebp iput(ip); 8010192a: e9 a1 fe ff ff jmp 801017d0 <iput> 8010192f: 90 nop 80101930 <stati>: // Copy stat information from inode. // Caller must hold ip->lock. void stati(struct inode *ip, struct stat *st) { 80101930: 55 push %ebp 80101931: 89 e5 mov %esp,%ebp 80101933: 8b 55 08 mov 0x8(%ebp),%edx 80101936: 8b 45 0c mov 0xc(%ebp),%eax st->dev = ip->dev; 80101939: 8b 0a mov (%edx),%ecx 8010193b: 89 48 04 mov %ecx,0x4(%eax) st->ino = ip->inum; 8010193e: 8b 4a 04 mov 0x4(%edx),%ecx 80101941: 89 48 08 mov %ecx,0x8(%eax) st->type = ip->type; 80101944: 0f b7 4a 50 movzwl 0x50(%edx),%ecx 80101948: 66 89 08 mov %cx,(%eax) st->nlink = ip->nlink; 8010194b: 0f b7 4a 56 movzwl 0x56(%edx),%ecx 8010194f: 66 89 48 0c mov %cx,0xc(%eax) st->size = ip->size; 80101953: 8b 52 58 mov 0x58(%edx),%edx 80101956: 89 50 10 mov %edx,0x10(%eax) } 80101959: 5d pop %ebp 8010195a: c3 ret 8010195b: 90 nop 8010195c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101960 <readi>: //PAGEBREAK! // Read data from inode. // Caller must hold ip->lock. int readi(struct inode *ip, char *dst, uint off, uint n) { 80101960: 55 push %ebp 80101961: 89 e5 mov %esp,%ebp 80101963: 57 push %edi 80101964: 56 push %esi 80101965: 53 push %ebx 80101966: 83 ec 2c sub $0x2c,%esp 80101969: 8b 45 0c mov 0xc(%ebp),%eax 8010196c: 8b 7d 08 mov 0x8(%ebp),%edi 8010196f: 8b 75 10 mov 0x10(%ebp),%esi 80101972: 89 45 e0 mov %eax,-0x20(%ebp) 80101975: 8b 45 14 mov 0x14(%ebp),%eax uint tot, m; struct buf *bp; if(ip->type == T_DEV){ 80101978: 66 83 7f 50 03 cmpw $0x3,0x50(%edi) { 8010197d: 89 45 e4 mov %eax,-0x1c(%ebp) if(ip->type == T_DEV){ 80101980: 0f 84 aa 00 00 00 je 80101a30 <readi+0xd0> if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].read) return -1; return devsw[ip->major].read(ip, dst, n); } if(off > ip->size || off + n < off) 80101986: 8b 47 58 mov 0x58(%edi),%eax 80101989: 39 f0 cmp %esi,%eax 8010198b: 0f 82 c7 00 00 00 jb 80101a58 <readi+0xf8> 80101991: 8b 5d e4 mov -0x1c(%ebp),%ebx 80101994: 89 da mov %ebx,%edx 80101996: 01 f2 add %esi,%edx 80101998: 0f 82 ba 00 00 00 jb 80101a58 <readi+0xf8> return -1; if(off + n > ip->size) n = ip->size - off; 8010199e: 89 c1 mov %eax,%ecx 801019a0: 29 f1 sub %esi,%ecx 801019a2: 39 d0 cmp %edx,%eax 801019a4: 0f 43 cb cmovae %ebx,%ecx for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ 801019a7: 31 c0 xor %eax,%eax 801019a9: 85 c9 test %ecx,%ecx n = ip->size - off; 801019ab: 89 4d e4 mov %ecx,-0x1c(%ebp) for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ 801019ae: 74 70 je 80101a20 <readi+0xc0> 801019b0: 89 7d d8 mov %edi,-0x28(%ebp) 801019b3: 89 c7 mov %eax,%edi 801019b5: 8d 76 00 lea 0x0(%esi),%esi bp = bread(ip->dev, bmap(ip, off/BSIZE)); 801019b8: 8b 5d d8 mov -0x28(%ebp),%ebx 801019bb: 89 f2 mov %esi,%edx 801019bd: c1 ea 09 shr $0x9,%edx 801019c0: 89 d8 mov %ebx,%eax 801019c2: e8 99 f9 ff ff call 80101360 <bmap> 801019c7: 89 44 24 04 mov %eax,0x4(%esp) 801019cb: 8b 03 mov (%ebx),%eax m = min(n - tot, BSIZE - off%BSIZE); 801019cd: bb 00 02 00 00 mov $0x200,%ebx bp = bread(ip->dev, bmap(ip, off/BSIZE)); 801019d2: 89 04 24 mov %eax,(%esp) 801019d5: e8 f6 e6 ff ff call 801000d0 <bread> m = min(n - tot, BSIZE - off%BSIZE); 801019da: 8b 4d e4 mov -0x1c(%ebp),%ecx 801019dd: 29 f9 sub %edi,%ecx bp = bread(ip->dev, bmap(ip, off/BSIZE)); 801019df: 89 c2 mov %eax,%edx m = min(n - tot, BSIZE - off%BSIZE); 801019e1: 89 f0 mov %esi,%eax 801019e3: 25 ff 01 00 00 and $0x1ff,%eax 801019e8: 29 c3 sub %eax,%ebx memmove(dst, bp->data + off%BSIZE, m); 801019ea: 8d 44 02 5c lea 0x5c(%edx,%eax,1),%eax m = min(n - tot, BSIZE - off%BSIZE); 801019ee: 39 cb cmp %ecx,%ebx memmove(dst, bp->data + off%BSIZE, m); 801019f0: 89 44 24 04 mov %eax,0x4(%esp) 801019f4: 8b 45 e0 mov -0x20(%ebp),%eax m = min(n - tot, BSIZE - off%BSIZE); 801019f7: 0f 47 d9 cmova %ecx,%ebx memmove(dst, bp->data + off%BSIZE, m); 801019fa: 89 5c 24 08 mov %ebx,0x8(%esp) for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ 801019fe: 01 df add %ebx,%edi 80101a00: 01 de add %ebx,%esi memmove(dst, bp->data + off%BSIZE, m); 80101a02: 89 55 dc mov %edx,-0x24(%ebp) 80101a05: 89 04 24 mov %eax,(%esp) 80101a08: e8 33 29 00 00 call 80104340 <memmove> brelse(bp); 80101a0d: 8b 55 dc mov -0x24(%ebp),%edx 80101a10: 89 14 24 mov %edx,(%esp) 80101a13: e8 c8 e7 ff ff call 801001e0 <brelse> for(tot=0; tot<n; tot+=m, off+=m, dst+=m){ 80101a18: 01 5d e0 add %ebx,-0x20(%ebp) 80101a1b: 39 7d e4 cmp %edi,-0x1c(%ebp) 80101a1e: 77 98 ja 801019b8 <readi+0x58> } return n; 80101a20: 8b 45 e4 mov -0x1c(%ebp),%eax } 80101a23: 83 c4 2c add $0x2c,%esp 80101a26: 5b pop %ebx 80101a27: 5e pop %esi 80101a28: 5f pop %edi 80101a29: 5d pop %ebp 80101a2a: c3 ret 80101a2b: 90 nop 80101a2c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].read) 80101a30: 0f bf 47 52 movswl 0x52(%edi),%eax 80101a34: 66 83 f8 09 cmp $0x9,%ax 80101a38: 77 1e ja 80101a58 <readi+0xf8> 80101a3a: 8b 04 c5 60 09 11 80 mov -0x7feef6a0(,%eax,8),%eax 80101a41: 85 c0 test %eax,%eax 80101a43: 74 13 je 80101a58 <readi+0xf8> return devsw[ip->major].read(ip, dst, n); 80101a45: 8b 75 e4 mov -0x1c(%ebp),%esi 80101a48: 89 75 10 mov %esi,0x10(%ebp) } 80101a4b: 83 c4 2c add $0x2c,%esp 80101a4e: 5b pop %ebx 80101a4f: 5e pop %esi 80101a50: 5f pop %edi 80101a51: 5d pop %ebp return devsw[ip->major].read(ip, dst, n); 80101a52: ff e0 jmp *%eax 80101a54: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return -1; 80101a58: b8 ff ff ff ff mov $0xffffffff,%eax 80101a5d: eb c4 jmp 80101a23 <readi+0xc3> 80101a5f: 90 nop 80101a60 <writei>: // PAGEBREAK! // Write data to inode. // Caller must hold ip->lock. int writei(struct inode *ip, char *src, uint off, uint n) { 80101a60: 55 push %ebp 80101a61: 89 e5 mov %esp,%ebp 80101a63: 57 push %edi 80101a64: 56 push %esi 80101a65: 53 push %ebx 80101a66: 83 ec 2c sub $0x2c,%esp 80101a69: 8b 45 08 mov 0x8(%ebp),%eax 80101a6c: 8b 75 0c mov 0xc(%ebp),%esi 80101a6f: 8b 4d 14 mov 0x14(%ebp),%ecx uint tot, m; struct buf *bp; if(ip->type == T_DEV){ 80101a72: 66 83 78 50 03 cmpw $0x3,0x50(%eax) { 80101a77: 89 75 dc mov %esi,-0x24(%ebp) 80101a7a: 8b 75 10 mov 0x10(%ebp),%esi 80101a7d: 89 45 d8 mov %eax,-0x28(%ebp) 80101a80: 89 4d e0 mov %ecx,-0x20(%ebp) if(ip->type == T_DEV){ 80101a83: 0f 84 b7 00 00 00 je 80101b40 <writei+0xe0> if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].write) return -1; return devsw[ip->major].write(ip, src, n); } if(off > ip->size || off + n < off) 80101a89: 8b 45 d8 mov -0x28(%ebp),%eax 80101a8c: 39 70 58 cmp %esi,0x58(%eax) 80101a8f: 0f 82 e3 00 00 00 jb 80101b78 <writei+0x118> 80101a95: 8b 4d e0 mov -0x20(%ebp),%ecx 80101a98: 89 c8 mov %ecx,%eax 80101a9a: 01 f0 add %esi,%eax 80101a9c: 0f 82 d6 00 00 00 jb 80101b78 <writei+0x118> return -1; if(off + n > MAXFILE*BSIZE) 80101aa2: 3d 00 18 01 00 cmp $0x11800,%eax 80101aa7: 0f 87 cb 00 00 00 ja 80101b78 <writei+0x118> return -1; for(tot=0; tot<n; tot+=m, off+=m, src+=m){ 80101aad: 85 c9 test %ecx,%ecx 80101aaf: c7 45 e4 00 00 00 00 movl $0x0,-0x1c(%ebp) 80101ab6: 74 77 je 80101b2f <writei+0xcf> bp = bread(ip->dev, bmap(ip, off/BSIZE)); 80101ab8: 8b 7d d8 mov -0x28(%ebp),%edi 80101abb: 89 f2 mov %esi,%edx m = min(n - tot, BSIZE - off%BSIZE); 80101abd: bb 00 02 00 00 mov $0x200,%ebx bp = bread(ip->dev, bmap(ip, off/BSIZE)); 80101ac2: c1 ea 09 shr $0x9,%edx 80101ac5: 89 f8 mov %edi,%eax 80101ac7: e8 94 f8 ff ff call 80101360 <bmap> 80101acc: 89 44 24 04 mov %eax,0x4(%esp) 80101ad0: 8b 07 mov (%edi),%eax 80101ad2: 89 04 24 mov %eax,(%esp) 80101ad5: e8 f6 e5 ff ff call 801000d0 <bread> m = min(n - tot, BSIZE - off%BSIZE); 80101ada: 8b 4d e0 mov -0x20(%ebp),%ecx 80101add: 2b 4d e4 sub -0x1c(%ebp),%ecx memmove(bp->data + off%BSIZE, src, m); 80101ae0: 8b 55 dc mov -0x24(%ebp),%edx bp = bread(ip->dev, bmap(ip, off/BSIZE)); 80101ae3: 89 c7 mov %eax,%edi m = min(n - tot, BSIZE - off%BSIZE); 80101ae5: 89 f0 mov %esi,%eax 80101ae7: 25 ff 01 00 00 and $0x1ff,%eax 80101aec: 29 c3 sub %eax,%ebx 80101aee: 39 cb cmp %ecx,%ebx 80101af0: 0f 47 d9 cmova %ecx,%ebx memmove(bp->data + off%BSIZE, src, m); 80101af3: 8d 44 07 5c lea 0x5c(%edi,%eax,1),%eax for(tot=0; tot<n; tot+=m, off+=m, src+=m){ 80101af7: 01 de add %ebx,%esi memmove(bp->data + off%BSIZE, src, m); 80101af9: 89 54 24 04 mov %edx,0x4(%esp) 80101afd: 89 5c 24 08 mov %ebx,0x8(%esp) 80101b01: 89 04 24 mov %eax,(%esp) 80101b04: e8 37 28 00 00 call 80104340 <memmove> log_write(bp); 80101b09: 89 3c 24 mov %edi,(%esp) 80101b0c: e8 9f 11 00 00 call 80102cb0 <log_write> brelse(bp); 80101b11: 89 3c 24 mov %edi,(%esp) 80101b14: e8 c7 e6 ff ff call 801001e0 <brelse> for(tot=0; tot<n; tot+=m, off+=m, src+=m){ 80101b19: 01 5d e4 add %ebx,-0x1c(%ebp) 80101b1c: 8b 45 e4 mov -0x1c(%ebp),%eax 80101b1f: 01 5d dc add %ebx,-0x24(%ebp) 80101b22: 39 45 e0 cmp %eax,-0x20(%ebp) 80101b25: 77 91 ja 80101ab8 <writei+0x58> } if(n > 0 && off > ip->size){ 80101b27: 8b 45 d8 mov -0x28(%ebp),%eax 80101b2a: 39 70 58 cmp %esi,0x58(%eax) 80101b2d: 72 39 jb 80101b68 <writei+0x108> ip->size = off; iupdate(ip); } return n; 80101b2f: 8b 45 e0 mov -0x20(%ebp),%eax } 80101b32: 83 c4 2c add $0x2c,%esp 80101b35: 5b pop %ebx 80101b36: 5e pop %esi 80101b37: 5f pop %edi 80101b38: 5d pop %ebp 80101b39: c3 ret 80101b3a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].write) 80101b40: 0f bf 40 52 movswl 0x52(%eax),%eax 80101b44: 66 83 f8 09 cmp $0x9,%ax 80101b48: 77 2e ja 80101b78 <writei+0x118> 80101b4a: 8b 04 c5 64 09 11 80 mov -0x7feef69c(,%eax,8),%eax 80101b51: 85 c0 test %eax,%eax 80101b53: 74 23 je 80101b78 <writei+0x118> return devsw[ip->major].write(ip, src, n); 80101b55: 89 4d 10 mov %ecx,0x10(%ebp) } 80101b58: 83 c4 2c add $0x2c,%esp 80101b5b: 5b pop %ebx 80101b5c: 5e pop %esi 80101b5d: 5f pop %edi 80101b5e: 5d pop %ebp return devsw[ip->major].write(ip, src, n); 80101b5f: ff e0 jmp *%eax 80101b61: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi ip->size = off; 80101b68: 8b 45 d8 mov -0x28(%ebp),%eax 80101b6b: 89 70 58 mov %esi,0x58(%eax) iupdate(ip); 80101b6e: 89 04 24 mov %eax,(%esp) 80101b71: e8 7a fa ff ff call 801015f0 <iupdate> 80101b76: eb b7 jmp 80101b2f <writei+0xcf> } 80101b78: 83 c4 2c add $0x2c,%esp return -1; 80101b7b: b8 ff ff ff ff mov $0xffffffff,%eax } 80101b80: 5b pop %ebx 80101b81: 5e pop %esi 80101b82: 5f pop %edi 80101b83: 5d pop %ebp 80101b84: c3 ret 80101b85: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101b89: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101b90 <namecmp>: //PAGEBREAK! // Directories int namecmp(const char *s, const char *t) { 80101b90: 55 push %ebp 80101b91: 89 e5 mov %esp,%ebp 80101b93: 83 ec 18 sub $0x18,%esp return strncmp(s, t, DIRSIZ); 80101b96: 8b 45 0c mov 0xc(%ebp),%eax 80101b99: c7 44 24 08 0e 00 00 movl $0xe,0x8(%esp) 80101ba0: 00 80101ba1: 89 44 24 04 mov %eax,0x4(%esp) 80101ba5: 8b 45 08 mov 0x8(%ebp),%eax 80101ba8: 89 04 24 mov %eax,(%esp) 80101bab: e8 10 28 00 00 call 801043c0 <strncmp> } 80101bb0: c9 leave 80101bb1: c3 ret 80101bb2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80101bb9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101bc0 <dirlookup>: // Look for a directory entry in a directory. // If found, set *poff to byte offset of entry. struct inode* dirlookup(struct inode *dp, char *name, uint *poff) { 80101bc0: 55 push %ebp 80101bc1: 89 e5 mov %esp,%ebp 80101bc3: 57 push %edi 80101bc4: 56 push %esi 80101bc5: 53 push %ebx 80101bc6: 83 ec 2c sub $0x2c,%esp 80101bc9: 8b 5d 08 mov 0x8(%ebp),%ebx uint off, inum; struct dirent de; if(dp->type != T_DIR) 80101bcc: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) 80101bd1: 0f 85 97 00 00 00 jne 80101c6e <dirlookup+0xae> panic("dirlookup not DIR"); for(off = 0; off < dp->size; off += sizeof(de)){ 80101bd7: 8b 53 58 mov 0x58(%ebx),%edx 80101bda: 31 ff xor %edi,%edi 80101bdc: 8d 75 d8 lea -0x28(%ebp),%esi 80101bdf: 85 d2 test %edx,%edx 80101be1: 75 0d jne 80101bf0 <dirlookup+0x30> 80101be3: eb 73 jmp 80101c58 <dirlookup+0x98> 80101be5: 8d 76 00 lea 0x0(%esi),%esi 80101be8: 83 c7 10 add $0x10,%edi 80101beb: 39 7b 58 cmp %edi,0x58(%ebx) 80101bee: 76 68 jbe 80101c58 <dirlookup+0x98> if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80101bf0: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) 80101bf7: 00 80101bf8: 89 7c 24 08 mov %edi,0x8(%esp) 80101bfc: 89 74 24 04 mov %esi,0x4(%esp) 80101c00: 89 1c 24 mov %ebx,(%esp) 80101c03: e8 58 fd ff ff call 80101960 <readi> 80101c08: 83 f8 10 cmp $0x10,%eax 80101c0b: 75 55 jne 80101c62 <dirlookup+0xa2> panic("dirlookup read"); if(de.inum == 0) 80101c0d: 66 83 7d d8 00 cmpw $0x0,-0x28(%ebp) 80101c12: 74 d4 je 80101be8 <dirlookup+0x28> return strncmp(s, t, DIRSIZ); 80101c14: 8d 45 da lea -0x26(%ebp),%eax 80101c17: 89 44 24 04 mov %eax,0x4(%esp) 80101c1b: 8b 45 0c mov 0xc(%ebp),%eax 80101c1e: c7 44 24 08 0e 00 00 movl $0xe,0x8(%esp) 80101c25: 00 80101c26: 89 04 24 mov %eax,(%esp) 80101c29: e8 92 27 00 00 call 801043c0 <strncmp> continue; if(namecmp(name, de.name) == 0){ 80101c2e: 85 c0 test %eax,%eax 80101c30: 75 b6 jne 80101be8 <dirlookup+0x28> // entry matches path element if(poff) 80101c32: 8b 45 10 mov 0x10(%ebp),%eax 80101c35: 85 c0 test %eax,%eax 80101c37: 74 05 je 80101c3e <dirlookup+0x7e> *poff = off; 80101c39: 8b 45 10 mov 0x10(%ebp),%eax 80101c3c: 89 38 mov %edi,(%eax) inum = de.inum; 80101c3e: 0f b7 55 d8 movzwl -0x28(%ebp),%edx return iget(dp->dev, inum); 80101c42: 8b 03 mov (%ebx),%eax 80101c44: e8 57 f6 ff ff call 801012a0 <iget> } } return 0; } 80101c49: 83 c4 2c add $0x2c,%esp 80101c4c: 5b pop %ebx 80101c4d: 5e pop %esi 80101c4e: 5f pop %edi 80101c4f: 5d pop %ebp 80101c50: c3 ret 80101c51: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80101c58: 83 c4 2c add $0x2c,%esp return 0; 80101c5b: 31 c0 xor %eax,%eax } 80101c5d: 5b pop %ebx 80101c5e: 5e pop %esi 80101c5f: 5f pop %edi 80101c60: 5d pop %ebp 80101c61: c3 ret panic("dirlookup read"); 80101c62: c7 04 24 39 6d 10 80 movl $0x80106d39,(%esp) 80101c69: e8 f2 e6 ff ff call 80100360 <panic> panic("dirlookup not DIR"); 80101c6e: c7 04 24 27 6d 10 80 movl $0x80106d27,(%esp) 80101c75: e8 e6 e6 ff ff call 80100360 <panic> 80101c7a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80101c80 <namex>: // If parent != 0, return the inode for the parent and copy the final // path element into name, which must have room for DIRSIZ bytes. // Must be called inside a transaction since it calls iput(). static struct inode* namex(char *path, int nameiparent, char *name) { 80101c80: 55 push %ebp 80101c81: 89 e5 mov %esp,%ebp 80101c83: 57 push %edi 80101c84: 89 cf mov %ecx,%edi 80101c86: 56 push %esi 80101c87: 53 push %ebx 80101c88: 89 c3 mov %eax,%ebx 80101c8a: 83 ec 2c sub $0x2c,%esp struct inode *ip, *next; if(*path == '/') 80101c8d: 80 38 2f cmpb $0x2f,(%eax) { 80101c90: 89 55 e0 mov %edx,-0x20(%ebp) if(*path == '/') 80101c93: 0f 84 51 01 00 00 je 80101dea <namex+0x16a> ip = iget(ROOTDEV, ROOTINO); else ip = idup(myproc()->cwd); 80101c99: e8 02 1a 00 00 call 801036a0 <myproc> 80101c9e: 8b 70 68 mov 0x68(%eax),%esi acquire(&icache.lock); 80101ca1: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) 80101ca8: e8 33 25 00 00 call 801041e0 <acquire> ip->ref++; 80101cad: 83 46 08 01 addl $0x1,0x8(%esi) release(&icache.lock); 80101cb1: c7 04 24 e0 09 11 80 movl $0x801109e0,(%esp) 80101cb8: e8 93 25 00 00 call 80104250 <release> 80101cbd: eb 04 jmp 80101cc3 <namex+0x43> 80101cbf: 90 nop path++; 80101cc0: 83 c3 01 add $0x1,%ebx while(*path == '/') 80101cc3: 0f b6 03 movzbl (%ebx),%eax 80101cc6: 3c 2f cmp $0x2f,%al 80101cc8: 74 f6 je 80101cc0 <namex+0x40> if(*path == 0) 80101cca: 84 c0 test %al,%al 80101ccc: 0f 84 ed 00 00 00 je 80101dbf <namex+0x13f> while(*path != '/' && *path != 0) 80101cd2: 0f b6 03 movzbl (%ebx),%eax 80101cd5: 89 da mov %ebx,%edx 80101cd7: 84 c0 test %al,%al 80101cd9: 0f 84 b1 00 00 00 je 80101d90 <namex+0x110> 80101cdf: 3c 2f cmp $0x2f,%al 80101ce1: 75 0f jne 80101cf2 <namex+0x72> 80101ce3: e9 a8 00 00 00 jmp 80101d90 <namex+0x110> 80101ce8: 3c 2f cmp $0x2f,%al 80101cea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80101cf0: 74 0a je 80101cfc <namex+0x7c> path++; 80101cf2: 83 c2 01 add $0x1,%edx while(*path != '/' && *path != 0) 80101cf5: 0f b6 02 movzbl (%edx),%eax 80101cf8: 84 c0 test %al,%al 80101cfa: 75 ec jne 80101ce8 <namex+0x68> 80101cfc: 89 d1 mov %edx,%ecx 80101cfe: 29 d9 sub %ebx,%ecx if(len >= DIRSIZ) 80101d00: 83 f9 0d cmp $0xd,%ecx 80101d03: 0f 8e 8f 00 00 00 jle 80101d98 <namex+0x118> memmove(name, s, DIRSIZ); 80101d09: 89 5c 24 04 mov %ebx,0x4(%esp) 80101d0d: c7 44 24 08 0e 00 00 movl $0xe,0x8(%esp) 80101d14: 00 80101d15: 89 3c 24 mov %edi,(%esp) 80101d18: 89 55 e4 mov %edx,-0x1c(%ebp) 80101d1b: e8 20 26 00 00 call 80104340 <memmove> path++; 80101d20: 8b 55 e4 mov -0x1c(%ebp),%edx 80101d23: 89 d3 mov %edx,%ebx while(*path == '/') 80101d25: 80 3a 2f cmpb $0x2f,(%edx) 80101d28: 75 0e jne 80101d38 <namex+0xb8> 80101d2a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi path++; 80101d30: 83 c3 01 add $0x1,%ebx while(*path == '/') 80101d33: 80 3b 2f cmpb $0x2f,(%ebx) 80101d36: 74 f8 je 80101d30 <namex+0xb0> while((path = skipelem(path, name)) != 0){ ilock(ip); 80101d38: 89 34 24 mov %esi,(%esp) 80101d3b: e8 70 f9 ff ff call 801016b0 <ilock> if(ip->type != T_DIR){ 80101d40: 66 83 7e 50 01 cmpw $0x1,0x50(%esi) 80101d45: 0f 85 85 00 00 00 jne 80101dd0 <namex+0x150> iunlockput(ip); return 0; } if(nameiparent && *path == '\0'){ 80101d4b: 8b 55 e0 mov -0x20(%ebp),%edx 80101d4e: 85 d2 test %edx,%edx 80101d50: 74 09 je 80101d5b <namex+0xdb> 80101d52: 80 3b 00 cmpb $0x0,(%ebx) 80101d55: 0f 84 a5 00 00 00 je 80101e00 <namex+0x180> // Stop one level early. iunlock(ip); return ip; } if((next = dirlookup(ip, name, 0)) == 0){ 80101d5b: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) 80101d62: 00 80101d63: 89 7c 24 04 mov %edi,0x4(%esp) 80101d67: 89 34 24 mov %esi,(%esp) 80101d6a: e8 51 fe ff ff call 80101bc0 <dirlookup> 80101d6f: 85 c0 test %eax,%eax 80101d71: 74 5d je 80101dd0 <namex+0x150> iunlock(ip); 80101d73: 89 34 24 mov %esi,(%esp) 80101d76: 89 45 e4 mov %eax,-0x1c(%ebp) 80101d79: e8 12 fa ff ff call 80101790 <iunlock> iput(ip); 80101d7e: 89 34 24 mov %esi,(%esp) 80101d81: e8 4a fa ff ff call 801017d0 <iput> iunlockput(ip); return 0; } iunlockput(ip); ip = next; 80101d86: 8b 45 e4 mov -0x1c(%ebp),%eax 80101d89: 89 c6 mov %eax,%esi 80101d8b: e9 33 ff ff ff jmp 80101cc3 <namex+0x43> while(*path != '/' && *path != 0) 80101d90: 31 c9 xor %ecx,%ecx 80101d92: 8d b6 00 00 00 00 lea 0x0(%esi),%esi memmove(name, s, len); 80101d98: 89 4c 24 08 mov %ecx,0x8(%esp) 80101d9c: 89 5c 24 04 mov %ebx,0x4(%esp) 80101da0: 89 3c 24 mov %edi,(%esp) 80101da3: 89 55 dc mov %edx,-0x24(%ebp) 80101da6: 89 4d e4 mov %ecx,-0x1c(%ebp) 80101da9: e8 92 25 00 00 call 80104340 <memmove> name[len] = 0; 80101dae: 8b 4d e4 mov -0x1c(%ebp),%ecx 80101db1: 8b 55 dc mov -0x24(%ebp),%edx 80101db4: c6 04 0f 00 movb $0x0,(%edi,%ecx,1) 80101db8: 89 d3 mov %edx,%ebx 80101dba: e9 66 ff ff ff jmp 80101d25 <namex+0xa5> } if(nameiparent){ 80101dbf: 8b 45 e0 mov -0x20(%ebp),%eax 80101dc2: 85 c0 test %eax,%eax 80101dc4: 75 4c jne 80101e12 <namex+0x192> 80101dc6: 89 f0 mov %esi,%eax iput(ip); return 0; } return ip; } 80101dc8: 83 c4 2c add $0x2c,%esp 80101dcb: 5b pop %ebx 80101dcc: 5e pop %esi 80101dcd: 5f pop %edi 80101dce: 5d pop %ebp 80101dcf: c3 ret iunlock(ip); 80101dd0: 89 34 24 mov %esi,(%esp) 80101dd3: e8 b8 f9 ff ff call 80101790 <iunlock> iput(ip); 80101dd8: 89 34 24 mov %esi,(%esp) 80101ddb: e8 f0 f9 ff ff call 801017d0 <iput> } 80101de0: 83 c4 2c add $0x2c,%esp return 0; 80101de3: 31 c0 xor %eax,%eax } 80101de5: 5b pop %ebx 80101de6: 5e pop %esi 80101de7: 5f pop %edi 80101de8: 5d pop %ebp 80101de9: c3 ret ip = iget(ROOTDEV, ROOTINO); 80101dea: ba 01 00 00 00 mov $0x1,%edx 80101def: b8 01 00 00 00 mov $0x1,%eax 80101df4: e8 a7 f4 ff ff call 801012a0 <iget> 80101df9: 89 c6 mov %eax,%esi 80101dfb: e9 c3 fe ff ff jmp 80101cc3 <namex+0x43> iunlock(ip); 80101e00: 89 34 24 mov %esi,(%esp) 80101e03: e8 88 f9 ff ff call 80101790 <iunlock> } 80101e08: 83 c4 2c add $0x2c,%esp return ip; 80101e0b: 89 f0 mov %esi,%eax } 80101e0d: 5b pop %ebx 80101e0e: 5e pop %esi 80101e0f: 5f pop %edi 80101e10: 5d pop %ebp 80101e11: c3 ret iput(ip); 80101e12: 89 34 24 mov %esi,(%esp) 80101e15: e8 b6 f9 ff ff call 801017d0 <iput> return 0; 80101e1a: 31 c0 xor %eax,%eax 80101e1c: eb aa jmp 80101dc8 <namex+0x148> 80101e1e: 66 90 xchg %ax,%ax 80101e20 <dirlink>: { 80101e20: 55 push %ebp 80101e21: 89 e5 mov %esp,%ebp 80101e23: 57 push %edi 80101e24: 56 push %esi 80101e25: 53 push %ebx 80101e26: 83 ec 2c sub $0x2c,%esp 80101e29: 8b 5d 08 mov 0x8(%ebp),%ebx if((ip = dirlookup(dp, name, 0)) != 0){ 80101e2c: 8b 45 0c mov 0xc(%ebp),%eax 80101e2f: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) 80101e36: 00 80101e37: 89 1c 24 mov %ebx,(%esp) 80101e3a: 89 44 24 04 mov %eax,0x4(%esp) 80101e3e: e8 7d fd ff ff call 80101bc0 <dirlookup> 80101e43: 85 c0 test %eax,%eax 80101e45: 0f 85 8b 00 00 00 jne 80101ed6 <dirlink+0xb6> for(off = 0; off < dp->size; off += sizeof(de)){ 80101e4b: 8b 43 58 mov 0x58(%ebx),%eax 80101e4e: 31 ff xor %edi,%edi 80101e50: 8d 75 d8 lea -0x28(%ebp),%esi 80101e53: 85 c0 test %eax,%eax 80101e55: 75 13 jne 80101e6a <dirlink+0x4a> 80101e57: eb 35 jmp 80101e8e <dirlink+0x6e> 80101e59: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80101e60: 8d 57 10 lea 0x10(%edi),%edx 80101e63: 39 53 58 cmp %edx,0x58(%ebx) 80101e66: 89 d7 mov %edx,%edi 80101e68: 76 24 jbe 80101e8e <dirlink+0x6e> if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80101e6a: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) 80101e71: 00 80101e72: 89 7c 24 08 mov %edi,0x8(%esp) 80101e76: 89 74 24 04 mov %esi,0x4(%esp) 80101e7a: 89 1c 24 mov %ebx,(%esp) 80101e7d: e8 de fa ff ff call 80101960 <readi> 80101e82: 83 f8 10 cmp $0x10,%eax 80101e85: 75 5e jne 80101ee5 <dirlink+0xc5> if(de.inum == 0) 80101e87: 66 83 7d d8 00 cmpw $0x0,-0x28(%ebp) 80101e8c: 75 d2 jne 80101e60 <dirlink+0x40> strncpy(de.name, name, DIRSIZ); 80101e8e: 8b 45 0c mov 0xc(%ebp),%eax 80101e91: c7 44 24 08 0e 00 00 movl $0xe,0x8(%esp) 80101e98: 00 80101e99: 89 44 24 04 mov %eax,0x4(%esp) 80101e9d: 8d 45 da lea -0x26(%ebp),%eax 80101ea0: 89 04 24 mov %eax,(%esp) 80101ea3: e8 88 25 00 00 call 80104430 <strncpy> de.inum = inum; 80101ea8: 8b 45 10 mov 0x10(%ebp),%eax if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80101eab: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) 80101eb2: 00 80101eb3: 89 7c 24 08 mov %edi,0x8(%esp) 80101eb7: 89 74 24 04 mov %esi,0x4(%esp) 80101ebb: 89 1c 24 mov %ebx,(%esp) de.inum = inum; 80101ebe: 66 89 45 d8 mov %ax,-0x28(%ebp) if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80101ec2: e8 99 fb ff ff call 80101a60 <writei> 80101ec7: 83 f8 10 cmp $0x10,%eax 80101eca: 75 25 jne 80101ef1 <dirlink+0xd1> return 0; 80101ecc: 31 c0 xor %eax,%eax } 80101ece: 83 c4 2c add $0x2c,%esp 80101ed1: 5b pop %ebx 80101ed2: 5e pop %esi 80101ed3: 5f pop %edi 80101ed4: 5d pop %ebp 80101ed5: c3 ret iput(ip); 80101ed6: 89 04 24 mov %eax,(%esp) 80101ed9: e8 f2 f8 ff ff call 801017d0 <iput> return -1; 80101ede: b8 ff ff ff ff mov $0xffffffff,%eax 80101ee3: eb e9 jmp 80101ece <dirlink+0xae> panic("dirlink read"); 80101ee5: c7 04 24 48 6d 10 80 movl $0x80106d48,(%esp) 80101eec: e8 6f e4 ff ff call 80100360 <panic> panic("dirlink"); 80101ef1: c7 04 24 3e 73 10 80 movl $0x8010733e,(%esp) 80101ef8: e8 63 e4 ff ff call 80100360 <panic> 80101efd: 8d 76 00 lea 0x0(%esi),%esi 80101f00 <namei>: struct inode* namei(char *path) { 80101f00: 55 push %ebp char name[DIRSIZ]; return namex(path, 0, name); 80101f01: 31 d2 xor %edx,%edx { 80101f03: 89 e5 mov %esp,%ebp 80101f05: 83 ec 18 sub $0x18,%esp return namex(path, 0, name); 80101f08: 8b 45 08 mov 0x8(%ebp),%eax 80101f0b: 8d 4d ea lea -0x16(%ebp),%ecx 80101f0e: e8 6d fd ff ff call 80101c80 <namex> } 80101f13: c9 leave 80101f14: c3 ret 80101f15: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80101f19: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80101f20 <nameiparent>: struct inode* nameiparent(char *path, char *name) { 80101f20: 55 push %ebp return namex(path, 1, name); 80101f21: ba 01 00 00 00 mov $0x1,%edx { 80101f26: 89 e5 mov %esp,%ebp return namex(path, 1, name); 80101f28: 8b 4d 0c mov 0xc(%ebp),%ecx 80101f2b: 8b 45 08 mov 0x8(%ebp),%eax } 80101f2e: 5d pop %ebp return namex(path, 1, name); 80101f2f: e9 4c fd ff ff jmp 80101c80 <namex> 80101f34: 66 90 xchg %ax,%ax 80101f36: 66 90 xchg %ax,%ax 80101f38: 66 90 xchg %ax,%ax 80101f3a: 66 90 xchg %ax,%ax 80101f3c: 66 90 xchg %ax,%ax 80101f3e: 66 90 xchg %ax,%ax 80101f40 <idestart>: } // Start the request for b. Caller must hold idelock. static void idestart(struct buf *b) { 80101f40: 55 push %ebp 80101f41: 89 e5 mov %esp,%ebp 80101f43: 56 push %esi 80101f44: 89 c6 mov %eax,%esi 80101f46: 53 push %ebx 80101f47: 83 ec 10 sub $0x10,%esp if(b == 0) 80101f4a: 85 c0 test %eax,%eax 80101f4c: 0f 84 99 00 00 00 je 80101feb <idestart+0xab> panic("idestart"); if(b->blockno >= FSSIZE) 80101f52: 8b 48 08 mov 0x8(%eax),%ecx 80101f55: 81 f9 e7 03 00 00 cmp $0x3e7,%ecx 80101f5b: 0f 87 7e 00 00 00 ja 80101fdf <idestart+0x9f> asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80101f61: ba f7 01 00 00 mov $0x1f7,%edx 80101f66: 66 90 xchg %ax,%ax 80101f68: ec in (%dx),%al while(((r = inb(0x1f7)) & (IDE_BSY|IDE_DRDY)) != IDE_DRDY) 80101f69: 83 e0 c0 and $0xffffffc0,%eax 80101f6c: 3c 40 cmp $0x40,%al 80101f6e: 75 f8 jne 80101f68 <idestart+0x28> asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80101f70: 31 db xor %ebx,%ebx 80101f72: ba f6 03 00 00 mov $0x3f6,%edx 80101f77: 89 d8 mov %ebx,%eax 80101f79: ee out %al,(%dx) 80101f7a: ba f2 01 00 00 mov $0x1f2,%edx 80101f7f: b8 01 00 00 00 mov $0x1,%eax 80101f84: ee out %al,(%dx) 80101f85: 0f b6 c1 movzbl %cl,%eax 80101f88: b2 f3 mov $0xf3,%dl 80101f8a: ee out %al,(%dx) idewait(0); outb(0x3f6, 0); // generate interrupt outb(0x1f2, sector_per_block); // number of sectors outb(0x1f3, sector & 0xff); outb(0x1f4, (sector >> 8) & 0xff); 80101f8b: 89 c8 mov %ecx,%eax 80101f8d: b2 f4 mov $0xf4,%dl 80101f8f: c1 f8 08 sar $0x8,%eax 80101f92: ee out %al,(%dx) 80101f93: b2 f5 mov $0xf5,%dl 80101f95: 89 d8 mov %ebx,%eax 80101f97: ee out %al,(%dx) outb(0x1f5, (sector >> 16) & 0xff); outb(0x1f6, 0xe0 | ((b->dev&1)<<4) | ((sector>>24)&0x0f)); 80101f98: 0f b6 46 04 movzbl 0x4(%esi),%eax 80101f9c: b2 f6 mov $0xf6,%dl 80101f9e: 83 e0 01 and $0x1,%eax 80101fa1: c1 e0 04 shl $0x4,%eax 80101fa4: 83 c8 e0 or $0xffffffe0,%eax 80101fa7: ee out %al,(%dx) if(b->flags & B_DIRTY){ 80101fa8: f6 06 04 testb $0x4,(%esi) 80101fab: 75 13 jne 80101fc0 <idestart+0x80> 80101fad: ba f7 01 00 00 mov $0x1f7,%edx 80101fb2: b8 20 00 00 00 mov $0x20,%eax 80101fb7: ee out %al,(%dx) outb(0x1f7, write_cmd); outsl(0x1f0, b->data, BSIZE/4); } else { outb(0x1f7, read_cmd); } } 80101fb8: 83 c4 10 add $0x10,%esp 80101fbb: 5b pop %ebx 80101fbc: 5e pop %esi 80101fbd: 5d pop %ebp 80101fbe: c3 ret 80101fbf: 90 nop 80101fc0: b2 f7 mov $0xf7,%dl 80101fc2: b8 30 00 00 00 mov $0x30,%eax 80101fc7: ee out %al,(%dx) asm volatile("cld; rep outsl" : 80101fc8: b9 80 00 00 00 mov $0x80,%ecx outsl(0x1f0, b->data, BSIZE/4); 80101fcd: 83 c6 5c add $0x5c,%esi 80101fd0: ba f0 01 00 00 mov $0x1f0,%edx 80101fd5: fc cld 80101fd6: f3 6f rep outsl %ds:(%esi),(%dx) } 80101fd8: 83 c4 10 add $0x10,%esp 80101fdb: 5b pop %ebx 80101fdc: 5e pop %esi 80101fdd: 5d pop %ebp 80101fde: c3 ret panic("incorrect blockno"); 80101fdf: c7 04 24 b4 6d 10 80 movl $0x80106db4,(%esp) 80101fe6: e8 75 e3 ff ff call 80100360 <panic> panic("idestart"); 80101feb: c7 04 24 ab 6d 10 80 movl $0x80106dab,(%esp) 80101ff2: e8 69 e3 ff ff call 80100360 <panic> 80101ff7: 89 f6 mov %esi,%esi 80101ff9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102000 <ideinit>: { 80102000: 55 push %ebp 80102001: 89 e5 mov %esp,%ebp 80102003: 83 ec 18 sub $0x18,%esp initlock(&idelock, "ide"); 80102006: c7 44 24 04 c6 6d 10 movl $0x80106dc6,0x4(%esp) 8010200d: 80 8010200e: c7 04 24 80 a5 10 80 movl $0x8010a580,(%esp) 80102015: e8 56 20 00 00 call 80104070 <initlock> ioapicenable(IRQ_IDE, ncpu - 1); 8010201a: a1 00 2d 11 80 mov 0x80112d00,%eax 8010201f: c7 04 24 0e 00 00 00 movl $0xe,(%esp) 80102026: 83 e8 01 sub $0x1,%eax 80102029: 89 44 24 04 mov %eax,0x4(%esp) 8010202d: e8 7e 02 00 00 call 801022b0 <ioapicenable> asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102032: ba f7 01 00 00 mov $0x1f7,%edx 80102037: 90 nop 80102038: ec in (%dx),%al while(((r = inb(0x1f7)) & (IDE_BSY|IDE_DRDY)) != IDE_DRDY) 80102039: 83 e0 c0 and $0xffffffc0,%eax 8010203c: 3c 40 cmp $0x40,%al 8010203e: 75 f8 jne 80102038 <ideinit+0x38> asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102040: ba f6 01 00 00 mov $0x1f6,%edx 80102045: b8 f0 ff ff ff mov $0xfffffff0,%eax 8010204a: ee out %al,(%dx) 8010204b: b9 e8 03 00 00 mov $0x3e8,%ecx asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102050: b2 f7 mov $0xf7,%dl 80102052: eb 09 jmp 8010205d <ideinit+0x5d> 80102054: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(i=0; i<1000; i++){ 80102058: 83 e9 01 sub $0x1,%ecx 8010205b: 74 0f je 8010206c <ideinit+0x6c> 8010205d: ec in (%dx),%al if(inb(0x1f7) != 0){ 8010205e: 84 c0 test %al,%al 80102060: 74 f6 je 80102058 <ideinit+0x58> havedisk1 = 1; 80102062: c7 05 60 a5 10 80 01 movl $0x1,0x8010a560 80102069: 00 00 00 asm volatile("out %0,%1" : : "a" (data), "d" (port)); 8010206c: ba f6 01 00 00 mov $0x1f6,%edx 80102071: b8 e0 ff ff ff mov $0xffffffe0,%eax 80102076: ee out %al,(%dx) } 80102077: c9 leave 80102078: c3 ret 80102079: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80102080 <ideintr>: // Interrupt handler. void ideintr(void) { 80102080: 55 push %ebp 80102081: 89 e5 mov %esp,%ebp 80102083: 57 push %edi 80102084: 56 push %esi 80102085: 53 push %ebx 80102086: 83 ec 1c sub $0x1c,%esp struct buf *b; // First queued buffer is the active request. acquire(&idelock); 80102089: c7 04 24 80 a5 10 80 movl $0x8010a580,(%esp) 80102090: e8 4b 21 00 00 call 801041e0 <acquire> if((b = idequeue) == 0){ 80102095: 8b 1d 64 a5 10 80 mov 0x8010a564,%ebx 8010209b: 85 db test %ebx,%ebx 8010209d: 74 30 je 801020cf <ideintr+0x4f> release(&idelock); return; } idequeue = b->qnext; 8010209f: 8b 43 58 mov 0x58(%ebx),%eax 801020a2: a3 64 a5 10 80 mov %eax,0x8010a564 // Read data if needed. if(!(b->flags & B_DIRTY) && idewait(1) >= 0) 801020a7: 8b 33 mov (%ebx),%esi 801020a9: f7 c6 04 00 00 00 test $0x4,%esi 801020af: 74 37 je 801020e8 <ideintr+0x68> insl(0x1f0, b->data, BSIZE/4); // Wake process waiting for this buf. b->flags |= B_VALID; b->flags &= ~B_DIRTY; 801020b1: 83 e6 fb and $0xfffffffb,%esi 801020b4: 83 ce 02 or $0x2,%esi 801020b7: 89 33 mov %esi,(%ebx) wakeup(b); 801020b9: 89 1c 24 mov %ebx,(%esp) 801020bc: e8 cf 1c 00 00 call 80103d90 <wakeup> // Start disk on next buf in queue. if(idequeue != 0) 801020c1: a1 64 a5 10 80 mov 0x8010a564,%eax 801020c6: 85 c0 test %eax,%eax 801020c8: 74 05 je 801020cf <ideintr+0x4f> idestart(idequeue); 801020ca: e8 71 fe ff ff call 80101f40 <idestart> release(&idelock); 801020cf: c7 04 24 80 a5 10 80 movl $0x8010a580,(%esp) 801020d6: e8 75 21 00 00 call 80104250 <release> release(&idelock); } 801020db: 83 c4 1c add $0x1c,%esp 801020de: 5b pop %ebx 801020df: 5e pop %esi 801020e0: 5f pop %edi 801020e1: 5d pop %ebp 801020e2: c3 ret 801020e3: 90 nop 801020e4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 801020e8: ba f7 01 00 00 mov $0x1f7,%edx 801020ed: 8d 76 00 lea 0x0(%esi),%esi 801020f0: ec in (%dx),%al while(((r = inb(0x1f7)) & (IDE_BSY|IDE_DRDY)) != IDE_DRDY) 801020f1: 89 c1 mov %eax,%ecx 801020f3: 83 e1 c0 and $0xffffffc0,%ecx 801020f6: 80 f9 40 cmp $0x40,%cl 801020f9: 75 f5 jne 801020f0 <ideintr+0x70> if(checkerr && (r & (IDE_DF|IDE_ERR)) != 0) 801020fb: a8 21 test $0x21,%al 801020fd: 75 b2 jne 801020b1 <ideintr+0x31> insl(0x1f0, b->data, BSIZE/4); 801020ff: 8d 7b 5c lea 0x5c(%ebx),%edi asm volatile("cld; rep insl" : 80102102: b9 80 00 00 00 mov $0x80,%ecx 80102107: ba f0 01 00 00 mov $0x1f0,%edx 8010210c: fc cld 8010210d: f3 6d rep insl (%dx),%es:(%edi) 8010210f: 8b 33 mov (%ebx),%esi 80102111: eb 9e jmp 801020b1 <ideintr+0x31> 80102113: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80102119: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102120 <iderw>: // Sync buf with disk. // If B_DIRTY is set, write buf to disk, clear B_DIRTY, set B_VALID. // Else if B_VALID is not set, read buf from disk, set B_VALID. void iderw(struct buf *b) { 80102120: 55 push %ebp 80102121: 89 e5 mov %esp,%ebp 80102123: 53 push %ebx 80102124: 83 ec 14 sub $0x14,%esp 80102127: 8b 5d 08 mov 0x8(%ebp),%ebx struct buf **pp; if(!holdingsleep(&b->lock)) 8010212a: 8d 43 0c lea 0xc(%ebx),%eax 8010212d: 89 04 24 mov %eax,(%esp) 80102130: e8 eb 1e 00 00 call 80104020 <holdingsleep> 80102135: 85 c0 test %eax,%eax 80102137: 0f 84 9e 00 00 00 je 801021db <iderw+0xbb> panic("iderw: buf not locked"); if((b->flags & (B_VALID|B_DIRTY)) == B_VALID) 8010213d: 8b 03 mov (%ebx),%eax 8010213f: 83 e0 06 and $0x6,%eax 80102142: 83 f8 02 cmp $0x2,%eax 80102145: 0f 84 a8 00 00 00 je 801021f3 <iderw+0xd3> panic("iderw: nothing to do"); if(b->dev != 0 && !havedisk1) 8010214b: 8b 53 04 mov 0x4(%ebx),%edx 8010214e: 85 d2 test %edx,%edx 80102150: 74 0d je 8010215f <iderw+0x3f> 80102152: a1 60 a5 10 80 mov 0x8010a560,%eax 80102157: 85 c0 test %eax,%eax 80102159: 0f 84 88 00 00 00 je 801021e7 <iderw+0xc7> panic("iderw: ide disk 1 not present"); acquire(&idelock); //DOC:acquire-lock 8010215f: c7 04 24 80 a5 10 80 movl $0x8010a580,(%esp) 80102166: e8 75 20 00 00 call 801041e0 <acquire> // Append b to idequeue. b->qnext = 0; for(pp=&idequeue; *pp; pp=&(*pp)->qnext) //DOC:insert-queue 8010216b: a1 64 a5 10 80 mov 0x8010a564,%eax b->qnext = 0; 80102170: c7 43 58 00 00 00 00 movl $0x0,0x58(%ebx) for(pp=&idequeue; *pp; pp=&(*pp)->qnext) //DOC:insert-queue 80102177: 85 c0 test %eax,%eax 80102179: 75 07 jne 80102182 <iderw+0x62> 8010217b: eb 4e jmp 801021cb <iderw+0xab> 8010217d: 8d 76 00 lea 0x0(%esi),%esi 80102180: 89 d0 mov %edx,%eax 80102182: 8b 50 58 mov 0x58(%eax),%edx 80102185: 85 d2 test %edx,%edx 80102187: 75 f7 jne 80102180 <iderw+0x60> 80102189: 83 c0 58 add $0x58,%eax ; *pp = b; 8010218c: 89 18 mov %ebx,(%eax) // Start disk if necessary. if(idequeue == b) 8010218e: 39 1d 64 a5 10 80 cmp %ebx,0x8010a564 80102194: 74 3c je 801021d2 <iderw+0xb2> idestart(b); // Wait for request to finish. while((b->flags & (B_VALID|B_DIRTY)) != B_VALID){ 80102196: 8b 03 mov (%ebx),%eax 80102198: 83 e0 06 and $0x6,%eax 8010219b: 83 f8 02 cmp $0x2,%eax 8010219e: 74 1a je 801021ba <iderw+0x9a> sleep(b, &idelock); 801021a0: c7 44 24 04 80 a5 10 movl $0x8010a580,0x4(%esp) 801021a7: 80 801021a8: 89 1c 24 mov %ebx,(%esp) 801021ab: e8 50 1a 00 00 call 80103c00 <sleep> while((b->flags & (B_VALID|B_DIRTY)) != B_VALID){ 801021b0: 8b 13 mov (%ebx),%edx 801021b2: 83 e2 06 and $0x6,%edx 801021b5: 83 fa 02 cmp $0x2,%edx 801021b8: 75 e6 jne 801021a0 <iderw+0x80> } release(&idelock); 801021ba: c7 45 08 80 a5 10 80 movl $0x8010a580,0x8(%ebp) } 801021c1: 83 c4 14 add $0x14,%esp 801021c4: 5b pop %ebx 801021c5: 5d pop %ebp release(&idelock); 801021c6: e9 85 20 00 00 jmp 80104250 <release> for(pp=&idequeue; *pp; pp=&(*pp)->qnext) //DOC:insert-queue 801021cb: b8 64 a5 10 80 mov $0x8010a564,%eax 801021d0: eb ba jmp 8010218c <iderw+0x6c> idestart(b); 801021d2: 89 d8 mov %ebx,%eax 801021d4: e8 67 fd ff ff call 80101f40 <idestart> 801021d9: eb bb jmp 80102196 <iderw+0x76> panic("iderw: buf not locked"); 801021db: c7 04 24 ca 6d 10 80 movl $0x80106dca,(%esp) 801021e2: e8 79 e1 ff ff call 80100360 <panic> panic("iderw: ide disk 1 not present"); 801021e7: c7 04 24 f5 6d 10 80 movl $0x80106df5,(%esp) 801021ee: e8 6d e1 ff ff call 80100360 <panic> panic("iderw: nothing to do"); 801021f3: c7 04 24 e0 6d 10 80 movl $0x80106de0,(%esp) 801021fa: e8 61 e1 ff ff call 80100360 <panic> 801021ff: 90 nop 80102200 <ioapicinit>: ioapic->data = data; } void ioapicinit(void) { 80102200: 55 push %ebp 80102201: 89 e5 mov %esp,%ebp 80102203: 56 push %esi 80102204: 53 push %ebx 80102205: 83 ec 10 sub $0x10,%esp int i, id, maxintr; ioapic = (volatile struct ioapic*)IOAPIC; 80102208: c7 05 34 26 11 80 00 movl $0xfec00000,0x80112634 8010220f: 00 c0 fe ioapic->reg = reg; 80102212: c7 05 00 00 c0 fe 01 movl $0x1,0xfec00000 80102219: 00 00 00 return ioapic->data; 8010221c: 8b 15 34 26 11 80 mov 0x80112634,%edx 80102222: 8b 42 10 mov 0x10(%edx),%eax ioapic->reg = reg; 80102225: c7 02 00 00 00 00 movl $0x0,(%edx) return ioapic->data; 8010222b: 8b 1d 34 26 11 80 mov 0x80112634,%ebx maxintr = (ioapicread(REG_VER) >> 16) & 0xFF; id = ioapicread(REG_ID) >> 24; if(id != ioapicid) 80102231: 0f b6 15 60 27 11 80 movzbl 0x80112760,%edx maxintr = (ioapicread(REG_VER) >> 16) & 0xFF; 80102238: c1 e8 10 shr $0x10,%eax 8010223b: 0f b6 f0 movzbl %al,%esi return ioapic->data; 8010223e: 8b 43 10 mov 0x10(%ebx),%eax id = ioapicread(REG_ID) >> 24; 80102241: c1 e8 18 shr $0x18,%eax if(id != ioapicid) 80102244: 39 c2 cmp %eax,%edx 80102246: 74 12 je 8010225a <ioapicinit+0x5a> cprintf("ioapicinit: id isn't equal to ioapicid; not a MP\n"); 80102248: c7 04 24 14 6e 10 80 movl $0x80106e14,(%esp) 8010224f: e8 fc e3 ff ff call 80100650 <cprintf> 80102254: 8b 1d 34 26 11 80 mov 0x80112634,%ebx 8010225a: ba 10 00 00 00 mov $0x10,%edx 8010225f: 31 c0 xor %eax,%eax 80102261: eb 07 jmp 8010226a <ioapicinit+0x6a> 80102263: 90 nop 80102264: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102268: 89 cb mov %ecx,%ebx ioapic->reg = reg; 8010226a: 89 13 mov %edx,(%ebx) ioapic->data = data; 8010226c: 8b 1d 34 26 11 80 mov 0x80112634,%ebx 80102272: 8d 48 20 lea 0x20(%eax),%ecx // Mark all interrupts edge-triggered, active high, disabled, // and not routed to any CPUs. for(i = 0; i <= maxintr; i++){ ioapicwrite(REG_TABLE+2*i, INT_DISABLED | (T_IRQ0 + i)); 80102275: 81 c9 00 00 01 00 or $0x10000,%ecx for(i = 0; i <= maxintr; i++){ 8010227b: 83 c0 01 add $0x1,%eax ioapic->data = data; 8010227e: 89 4b 10 mov %ecx,0x10(%ebx) 80102281: 8d 4a 01 lea 0x1(%edx),%ecx 80102284: 83 c2 02 add $0x2,%edx ioapic->reg = reg; 80102287: 89 0b mov %ecx,(%ebx) ioapic->data = data; 80102289: 8b 0d 34 26 11 80 mov 0x80112634,%ecx for(i = 0; i <= maxintr; i++){ 8010228f: 39 c6 cmp %eax,%esi ioapic->data = data; 80102291: c7 41 10 00 00 00 00 movl $0x0,0x10(%ecx) for(i = 0; i <= maxintr; i++){ 80102298: 7d ce jge 80102268 <ioapicinit+0x68> ioapicwrite(REG_TABLE+2*i+1, 0); } } 8010229a: 83 c4 10 add $0x10,%esp 8010229d: 5b pop %ebx 8010229e: 5e pop %esi 8010229f: 5d pop %ebp 801022a0: c3 ret 801022a1: eb 0d jmp 801022b0 <ioapicenable> 801022a3: 90 nop 801022a4: 90 nop 801022a5: 90 nop 801022a6: 90 nop 801022a7: 90 nop 801022a8: 90 nop 801022a9: 90 nop 801022aa: 90 nop 801022ab: 90 nop 801022ac: 90 nop 801022ad: 90 nop 801022ae: 90 nop 801022af: 90 nop 801022b0 <ioapicenable>: void ioapicenable(int irq, int cpunum) { 801022b0: 55 push %ebp 801022b1: 89 e5 mov %esp,%ebp 801022b3: 8b 55 08 mov 0x8(%ebp),%edx 801022b6: 53 push %ebx 801022b7: 8b 45 0c mov 0xc(%ebp),%eax // Mark interrupt edge-triggered, active high, // enabled, and routed to the given cpunum, // which happens to be that cpu's APIC ID. ioapicwrite(REG_TABLE+2*irq, T_IRQ0 + irq); 801022ba: 8d 5a 20 lea 0x20(%edx),%ebx 801022bd: 8d 4c 12 10 lea 0x10(%edx,%edx,1),%ecx ioapic->reg = reg; 801022c1: 8b 15 34 26 11 80 mov 0x80112634,%edx ioapicwrite(REG_TABLE+2*irq+1, cpunum << 24); 801022c7: c1 e0 18 shl $0x18,%eax ioapic->reg = reg; 801022ca: 89 0a mov %ecx,(%edx) ioapic->data = data; 801022cc: 8b 15 34 26 11 80 mov 0x80112634,%edx ioapicwrite(REG_TABLE+2*irq+1, cpunum << 24); 801022d2: 83 c1 01 add $0x1,%ecx ioapic->data = data; 801022d5: 89 5a 10 mov %ebx,0x10(%edx) ioapic->reg = reg; 801022d8: 89 0a mov %ecx,(%edx) ioapic->data = data; 801022da: 8b 15 34 26 11 80 mov 0x80112634,%edx 801022e0: 89 42 10 mov %eax,0x10(%edx) } 801022e3: 5b pop %ebx 801022e4: 5d pop %ebp 801022e5: c3 ret 801022e6: 66 90 xchg %ax,%ax 801022e8: 66 90 xchg %ax,%ax 801022ea: 66 90 xchg %ax,%ax 801022ec: 66 90 xchg %ax,%ax 801022ee: 66 90 xchg %ax,%ax 801022f0 <kfree>: // which normally should have been returned by a // call to kalloc(). (The exception is when // initializing the allocator; see kinit above.) void kfree(char *v) { 801022f0: 55 push %ebp 801022f1: 89 e5 mov %esp,%ebp 801022f3: 53 push %ebx 801022f4: 83 ec 14 sub $0x14,%esp 801022f7: 8b 5d 08 mov 0x8(%ebp),%ebx struct run *r; if((uint)v % PGSIZE || v < end || V2P(v) >= PHYSTOP) 801022fa: f7 c3 ff 0f 00 00 test $0xfff,%ebx 80102300: 75 7c jne 8010237e <kfree+0x8e> 80102302: 81 fb a8 54 11 80 cmp $0x801154a8,%ebx 80102308: 72 74 jb 8010237e <kfree+0x8e> 8010230a: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax 80102310: 3d ff ff ff 0d cmp $0xdffffff,%eax 80102315: 77 67 ja 8010237e <kfree+0x8e> panic("kfree"); // Fill with junk to catch dangling refs. memset(v, 1, PGSIZE); 80102317: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 8010231e: 00 8010231f: c7 44 24 04 01 00 00 movl $0x1,0x4(%esp) 80102326: 00 80102327: 89 1c 24 mov %ebx,(%esp) 8010232a: e8 71 1f 00 00 call 801042a0 <memset> if(kmem.use_lock) 8010232f: 8b 15 74 26 11 80 mov 0x80112674,%edx 80102335: 85 d2 test %edx,%edx 80102337: 75 37 jne 80102370 <kfree+0x80> acquire(&kmem.lock); r = (struct run*)v; r->next = kmem.freelist; 80102339: a1 78 26 11 80 mov 0x80112678,%eax 8010233e: 89 03 mov %eax,(%ebx) kmem.freelist = r; if(kmem.use_lock) 80102340: a1 74 26 11 80 mov 0x80112674,%eax kmem.freelist = r; 80102345: 89 1d 78 26 11 80 mov %ebx,0x80112678 if(kmem.use_lock) 8010234b: 85 c0 test %eax,%eax 8010234d: 75 09 jne 80102358 <kfree+0x68> release(&kmem.lock); } 8010234f: 83 c4 14 add $0x14,%esp 80102352: 5b pop %ebx 80102353: 5d pop %ebp 80102354: c3 ret 80102355: 8d 76 00 lea 0x0(%esi),%esi release(&kmem.lock); 80102358: c7 45 08 40 26 11 80 movl $0x80112640,0x8(%ebp) } 8010235f: 83 c4 14 add $0x14,%esp 80102362: 5b pop %ebx 80102363: 5d pop %ebp release(&kmem.lock); 80102364: e9 e7 1e 00 00 jmp 80104250 <release> 80102369: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi acquire(&kmem.lock); 80102370: c7 04 24 40 26 11 80 movl $0x80112640,(%esp) 80102377: e8 64 1e 00 00 call 801041e0 <acquire> 8010237c: eb bb jmp 80102339 <kfree+0x49> panic("kfree"); 8010237e: c7 04 24 46 6e 10 80 movl $0x80106e46,(%esp) 80102385: e8 d6 df ff ff call 80100360 <panic> 8010238a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80102390 <freerange>: { 80102390: 55 push %ebp 80102391: 89 e5 mov %esp,%ebp 80102393: 56 push %esi 80102394: 53 push %ebx 80102395: 83 ec 10 sub $0x10,%esp p = (char*)PGROUNDUP((uint)vstart); 80102398: 8b 45 08 mov 0x8(%ebp),%eax { 8010239b: 8b 75 0c mov 0xc(%ebp),%esi p = (char*)PGROUNDUP((uint)vstart); 8010239e: 8d 90 ff 0f 00 00 lea 0xfff(%eax),%edx 801023a4: 81 e2 00 f0 ff ff and $0xfffff000,%edx for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 801023aa: 8d 9a 00 10 00 00 lea 0x1000(%edx),%ebx 801023b0: 39 de cmp %ebx,%esi 801023b2: 73 08 jae 801023bc <freerange+0x2c> 801023b4: eb 18 jmp 801023ce <freerange+0x3e> 801023b6: 66 90 xchg %ax,%ax 801023b8: 89 da mov %ebx,%edx 801023ba: 89 c3 mov %eax,%ebx kfree(p); 801023bc: 89 14 24 mov %edx,(%esp) 801023bf: e8 2c ff ff ff call 801022f0 <kfree> for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 801023c4: 8d 83 00 10 00 00 lea 0x1000(%ebx),%eax 801023ca: 39 f0 cmp %esi,%eax 801023cc: 76 ea jbe 801023b8 <freerange+0x28> } 801023ce: 83 c4 10 add $0x10,%esp 801023d1: 5b pop %ebx 801023d2: 5e pop %esi 801023d3: 5d pop %ebp 801023d4: c3 ret 801023d5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801023d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801023e0 <kinit1>: { 801023e0: 55 push %ebp 801023e1: 89 e5 mov %esp,%ebp 801023e3: 56 push %esi 801023e4: 53 push %ebx 801023e5: 83 ec 10 sub $0x10,%esp 801023e8: 8b 75 0c mov 0xc(%ebp),%esi initlock(&kmem.lock, "kmem"); 801023eb: c7 44 24 04 4c 6e 10 movl $0x80106e4c,0x4(%esp) 801023f2: 80 801023f3: c7 04 24 40 26 11 80 movl $0x80112640,(%esp) 801023fa: e8 71 1c 00 00 call 80104070 <initlock> p = (char*)PGROUNDUP((uint)vstart); 801023ff: 8b 45 08 mov 0x8(%ebp),%eax kmem.use_lock = 0; 80102402: c7 05 74 26 11 80 00 movl $0x0,0x80112674 80102409: 00 00 00 p = (char*)PGROUNDUP((uint)vstart); 8010240c: 8d 90 ff 0f 00 00 lea 0xfff(%eax),%edx 80102412: 81 e2 00 f0 ff ff and $0xfffff000,%edx for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 80102418: 8d 9a 00 10 00 00 lea 0x1000(%edx),%ebx 8010241e: 39 de cmp %ebx,%esi 80102420: 73 0a jae 8010242c <kinit1+0x4c> 80102422: eb 1a jmp 8010243e <kinit1+0x5e> 80102424: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102428: 89 da mov %ebx,%edx 8010242a: 89 c3 mov %eax,%ebx kfree(p); 8010242c: 89 14 24 mov %edx,(%esp) 8010242f: e8 bc fe ff ff call 801022f0 <kfree> for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 80102434: 8d 83 00 10 00 00 lea 0x1000(%ebx),%eax 8010243a: 39 c6 cmp %eax,%esi 8010243c: 73 ea jae 80102428 <kinit1+0x48> } 8010243e: 83 c4 10 add $0x10,%esp 80102441: 5b pop %ebx 80102442: 5e pop %esi 80102443: 5d pop %ebp 80102444: c3 ret 80102445: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102449: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102450 <kinit2>: { 80102450: 55 push %ebp 80102451: 89 e5 mov %esp,%ebp 80102453: 56 push %esi 80102454: 53 push %ebx 80102455: 83 ec 10 sub $0x10,%esp p = (char*)PGROUNDUP((uint)vstart); 80102458: 8b 45 08 mov 0x8(%ebp),%eax { 8010245b: 8b 75 0c mov 0xc(%ebp),%esi p = (char*)PGROUNDUP((uint)vstart); 8010245e: 8d 90 ff 0f 00 00 lea 0xfff(%eax),%edx 80102464: 81 e2 00 f0 ff ff and $0xfffff000,%edx for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 8010246a: 8d 9a 00 10 00 00 lea 0x1000(%edx),%ebx 80102470: 39 de cmp %ebx,%esi 80102472: 73 08 jae 8010247c <kinit2+0x2c> 80102474: eb 18 jmp 8010248e <kinit2+0x3e> 80102476: 66 90 xchg %ax,%ax 80102478: 89 da mov %ebx,%edx 8010247a: 89 c3 mov %eax,%ebx kfree(p); 8010247c: 89 14 24 mov %edx,(%esp) 8010247f: e8 6c fe ff ff call 801022f0 <kfree> for(; p + PGSIZE <= (char*)vend; p += PGSIZE) 80102484: 8d 83 00 10 00 00 lea 0x1000(%ebx),%eax 8010248a: 39 c6 cmp %eax,%esi 8010248c: 73 ea jae 80102478 <kinit2+0x28> kmem.use_lock = 1; 8010248e: c7 05 74 26 11 80 01 movl $0x1,0x80112674 80102495: 00 00 00 } 80102498: 83 c4 10 add $0x10,%esp 8010249b: 5b pop %ebx 8010249c: 5e pop %esi 8010249d: 5d pop %ebp 8010249e: c3 ret 8010249f: 90 nop 801024a0 <kalloc>: // Allocate one 4096-byte page of physical memory. // Returns a pointer that the kernel can use. // Returns 0 if the memory cannot be allocated. char* kalloc(void) { 801024a0: 55 push %ebp 801024a1: 89 e5 mov %esp,%ebp 801024a3: 53 push %ebx 801024a4: 83 ec 14 sub $0x14,%esp struct run *r; if(kmem.use_lock) 801024a7: a1 74 26 11 80 mov 0x80112674,%eax 801024ac: 85 c0 test %eax,%eax 801024ae: 75 30 jne 801024e0 <kalloc+0x40> acquire(&kmem.lock); r = kmem.freelist; 801024b0: 8b 1d 78 26 11 80 mov 0x80112678,%ebx if(r) 801024b6: 85 db test %ebx,%ebx 801024b8: 74 08 je 801024c2 <kalloc+0x22> kmem.freelist = r->next; 801024ba: 8b 13 mov (%ebx),%edx 801024bc: 89 15 78 26 11 80 mov %edx,0x80112678 if(kmem.use_lock) 801024c2: 85 c0 test %eax,%eax 801024c4: 74 0c je 801024d2 <kalloc+0x32> release(&kmem.lock); 801024c6: c7 04 24 40 26 11 80 movl $0x80112640,(%esp) 801024cd: e8 7e 1d 00 00 call 80104250 <release> return (char*)r; } 801024d2: 83 c4 14 add $0x14,%esp 801024d5: 89 d8 mov %ebx,%eax 801024d7: 5b pop %ebx 801024d8: 5d pop %ebp 801024d9: c3 ret 801024da: 8d b6 00 00 00 00 lea 0x0(%esi),%esi acquire(&kmem.lock); 801024e0: c7 04 24 40 26 11 80 movl $0x80112640,(%esp) 801024e7: e8 f4 1c 00 00 call 801041e0 <acquire> 801024ec: a1 74 26 11 80 mov 0x80112674,%eax 801024f1: eb bd jmp 801024b0 <kalloc+0x10> 801024f3: 66 90 xchg %ax,%ax 801024f5: 66 90 xchg %ax,%ax 801024f7: 66 90 xchg %ax,%ax 801024f9: 66 90 xchg %ax,%ax 801024fb: 66 90 xchg %ax,%ax 801024fd: 66 90 xchg %ax,%ax 801024ff: 90 nop 80102500 <kbdgetc>: asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102500: ba 64 00 00 00 mov $0x64,%edx 80102505: ec in (%dx),%al normalmap, shiftmap, ctlmap, ctlmap }; uint st, data, c; st = inb(KBSTATP); if((st & KBS_DIB) == 0) 80102506: a8 01 test $0x1,%al 80102508: 0f 84 ba 00 00 00 je 801025c8 <kbdgetc+0xc8> 8010250e: b2 60 mov $0x60,%dl 80102510: ec in (%dx),%al return -1; data = inb(KBDATAP); 80102511: 0f b6 c8 movzbl %al,%ecx if(data == 0xE0){ 80102514: 81 f9 e0 00 00 00 cmp $0xe0,%ecx 8010251a: 0f 84 88 00 00 00 je 801025a8 <kbdgetc+0xa8> shift |= E0ESC; return 0; } else if(data & 0x80){ 80102520: 84 c0 test %al,%al 80102522: 79 2c jns 80102550 <kbdgetc+0x50> // Key released data = (shift & E0ESC ? data : data & 0x7F); 80102524: 8b 15 b4 a5 10 80 mov 0x8010a5b4,%edx 8010252a: f6 c2 40 test $0x40,%dl 8010252d: 75 05 jne 80102534 <kbdgetc+0x34> 8010252f: 89 c1 mov %eax,%ecx 80102531: 83 e1 7f and $0x7f,%ecx shift &= ~(shiftcode[data] | E0ESC); 80102534: 0f b6 81 80 6f 10 80 movzbl -0x7fef9080(%ecx),%eax 8010253b: 83 c8 40 or $0x40,%eax 8010253e: 0f b6 c0 movzbl %al,%eax 80102541: f7 d0 not %eax 80102543: 21 d0 and %edx,%eax 80102545: a3 b4 a5 10 80 mov %eax,0x8010a5b4 return 0; 8010254a: 31 c0 xor %eax,%eax 8010254c: c3 ret 8010254d: 8d 76 00 lea 0x0(%esi),%esi { 80102550: 55 push %ebp 80102551: 89 e5 mov %esp,%ebp 80102553: 53 push %ebx 80102554: 8b 1d b4 a5 10 80 mov 0x8010a5b4,%ebx } else if(shift & E0ESC){ 8010255a: f6 c3 40 test $0x40,%bl 8010255d: 74 09 je 80102568 <kbdgetc+0x68> // Last character was an E0 escape; or with 0x80 data |= 0x80; 8010255f: 83 c8 80 or $0xffffff80,%eax shift &= ~E0ESC; 80102562: 83 e3 bf and $0xffffffbf,%ebx data |= 0x80; 80102565: 0f b6 c8 movzbl %al,%ecx } shift |= shiftcode[data]; 80102568: 0f b6 91 80 6f 10 80 movzbl -0x7fef9080(%ecx),%edx shift ^= togglecode[data]; 8010256f: 0f b6 81 80 6e 10 80 movzbl -0x7fef9180(%ecx),%eax shift |= shiftcode[data]; 80102576: 09 da or %ebx,%edx shift ^= togglecode[data]; 80102578: 31 c2 xor %eax,%edx c = charcode[shift & (CTL | SHIFT)][data]; 8010257a: 89 d0 mov %edx,%eax 8010257c: 83 e0 03 and $0x3,%eax 8010257f: 8b 04 85 60 6e 10 80 mov -0x7fef91a0(,%eax,4),%eax shift ^= togglecode[data]; 80102586: 89 15 b4 a5 10 80 mov %edx,0x8010a5b4 if(shift & CAPSLOCK){ 8010258c: 83 e2 08 and $0x8,%edx c = charcode[shift & (CTL | SHIFT)][data]; 8010258f: 0f b6 04 08 movzbl (%eax,%ecx,1),%eax if(shift & CAPSLOCK){ 80102593: 74 0b je 801025a0 <kbdgetc+0xa0> if('a' <= c && c <= 'z') 80102595: 8d 50 9f lea -0x61(%eax),%edx 80102598: 83 fa 19 cmp $0x19,%edx 8010259b: 77 1b ja 801025b8 <kbdgetc+0xb8> c += 'A' - 'a'; 8010259d: 83 e8 20 sub $0x20,%eax else if('A' <= c && c <= 'Z') c += 'a' - 'A'; } return c; } 801025a0: 5b pop %ebx 801025a1: 5d pop %ebp 801025a2: c3 ret 801025a3: 90 nop 801025a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi shift |= E0ESC; 801025a8: 83 0d b4 a5 10 80 40 orl $0x40,0x8010a5b4 return 0; 801025af: 31 c0 xor %eax,%eax 801025b1: c3 ret 801025b2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi else if('A' <= c && c <= 'Z') 801025b8: 8d 48 bf lea -0x41(%eax),%ecx c += 'a' - 'A'; 801025bb: 8d 50 20 lea 0x20(%eax),%edx 801025be: 83 f9 19 cmp $0x19,%ecx 801025c1: 0f 46 c2 cmovbe %edx,%eax return c; 801025c4: eb da jmp 801025a0 <kbdgetc+0xa0> 801025c6: 66 90 xchg %ax,%ax return -1; 801025c8: b8 ff ff ff ff mov $0xffffffff,%eax 801025cd: c3 ret 801025ce: 66 90 xchg %ax,%ax 801025d0 <kbdintr>: void kbdintr(void) { 801025d0: 55 push %ebp 801025d1: 89 e5 mov %esp,%ebp 801025d3: 83 ec 18 sub $0x18,%esp consoleintr(kbdgetc); 801025d6: c7 04 24 00 25 10 80 movl $0x80102500,(%esp) 801025dd: e8 ce e1 ff ff call 801007b0 <consoleintr> } 801025e2: c9 leave 801025e3: c3 ret 801025e4: 66 90 xchg %ax,%ax 801025e6: 66 90 xchg %ax,%ax 801025e8: 66 90 xchg %ax,%ax 801025ea: 66 90 xchg %ax,%ax 801025ec: 66 90 xchg %ax,%ax 801025ee: 66 90 xchg %ax,%ax 801025f0 <fill_rtcdate>: return inb(CMOS_RETURN); } static void fill_rtcdate(struct rtcdate *r) { 801025f0: 55 push %ebp 801025f1: 89 c1 mov %eax,%ecx 801025f3: 89 e5 mov %esp,%ebp asm volatile("out %0,%1" : : "a" (data), "d" (port)); 801025f5: ba 70 00 00 00 mov $0x70,%edx 801025fa: 53 push %ebx 801025fb: 31 c0 xor %eax,%eax 801025fd: ee out %al,(%dx) asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 801025fe: bb 71 00 00 00 mov $0x71,%ebx 80102603: 89 da mov %ebx,%edx 80102605: ec in (%dx),%al return inb(CMOS_RETURN); 80102606: 0f b6 c0 movzbl %al,%eax asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102609: b2 70 mov $0x70,%dl 8010260b: 89 01 mov %eax,(%ecx) 8010260d: b8 02 00 00 00 mov $0x2,%eax 80102612: ee out %al,(%dx) asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102613: 89 da mov %ebx,%edx 80102615: ec in (%dx),%al 80102616: 0f b6 c0 movzbl %al,%eax asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102619: b2 70 mov $0x70,%dl 8010261b: 89 41 04 mov %eax,0x4(%ecx) 8010261e: b8 04 00 00 00 mov $0x4,%eax 80102623: ee out %al,(%dx) asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102624: 89 da mov %ebx,%edx 80102626: ec in (%dx),%al 80102627: 0f b6 c0 movzbl %al,%eax asm volatile("out %0,%1" : : "a" (data), "d" (port)); 8010262a: b2 70 mov $0x70,%dl 8010262c: 89 41 08 mov %eax,0x8(%ecx) 8010262f: b8 07 00 00 00 mov $0x7,%eax 80102634: ee out %al,(%dx) asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102635: 89 da mov %ebx,%edx 80102637: ec in (%dx),%al 80102638: 0f b6 c0 movzbl %al,%eax asm volatile("out %0,%1" : : "a" (data), "d" (port)); 8010263b: b2 70 mov $0x70,%dl 8010263d: 89 41 0c mov %eax,0xc(%ecx) 80102640: b8 08 00 00 00 mov $0x8,%eax 80102645: ee out %al,(%dx) asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102646: 89 da mov %ebx,%edx 80102648: ec in (%dx),%al 80102649: 0f b6 c0 movzbl %al,%eax asm volatile("out %0,%1" : : "a" (data), "d" (port)); 8010264c: b2 70 mov $0x70,%dl 8010264e: 89 41 10 mov %eax,0x10(%ecx) 80102651: b8 09 00 00 00 mov $0x9,%eax 80102656: ee out %al,(%dx) asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102657: 89 da mov %ebx,%edx 80102659: ec in (%dx),%al 8010265a: 0f b6 d8 movzbl %al,%ebx 8010265d: 89 59 14 mov %ebx,0x14(%ecx) r->minute = cmos_read(MINS); r->hour = cmos_read(HOURS); r->day = cmos_read(DAY); r->month = cmos_read(MONTH); r->year = cmos_read(YEAR); } 80102660: 5b pop %ebx 80102661: 5d pop %ebp 80102662: c3 ret 80102663: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80102669: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102670 <lapicinit>: if(!lapic) 80102670: a1 7c 26 11 80 mov 0x8011267c,%eax { 80102675: 55 push %ebp 80102676: 89 e5 mov %esp,%ebp if(!lapic) 80102678: 85 c0 test %eax,%eax 8010267a: 0f 84 c0 00 00 00 je 80102740 <lapicinit+0xd0> lapic[index] = value; 80102680: c7 80 f0 00 00 00 3f movl $0x13f,0xf0(%eax) 80102687: 01 00 00 lapic[ID]; // wait for write to finish, by reading 8010268a: 8b 50 20 mov 0x20(%eax),%edx lapic[index] = value; 8010268d: c7 80 e0 03 00 00 0b movl $0xb,0x3e0(%eax) 80102694: 00 00 00 lapic[ID]; // wait for write to finish, by reading 80102697: 8b 50 20 mov 0x20(%eax),%edx lapic[index] = value; 8010269a: c7 80 20 03 00 00 20 movl $0x20020,0x320(%eax) 801026a1: 00 02 00 lapic[ID]; // wait for write to finish, by reading 801026a4: 8b 50 20 mov 0x20(%eax),%edx lapic[index] = value; 801026a7: c7 80 80 03 00 00 80 movl $0x989680,0x380(%eax) 801026ae: 96 98 00 lapic[ID]; // wait for write to finish, by reading 801026b1: 8b 50 20 mov 0x20(%eax),%edx lapic[index] = value; 801026b4: c7 80 50 03 00 00 00 movl $0x10000,0x350(%eax) 801026bb: 00 01 00 lapic[ID]; // wait for write to finish, by reading 801026be: 8b 50 20 mov 0x20(%eax),%edx lapic[index] = value; 801026c1: c7 80 60 03 00 00 00 movl $0x10000,0x360(%eax) 801026c8: 00 01 00 lapic[ID]; // wait for write to finish, by reading 801026cb: 8b 50 20 mov 0x20(%eax),%edx if(((lapic[VER]>>16) & 0xFF) >= 4) 801026ce: 8b 50 30 mov 0x30(%eax),%edx 801026d1: c1 ea 10 shr $0x10,%edx 801026d4: 80 fa 03 cmp $0x3,%dl 801026d7: 77 6f ja 80102748 <lapicinit+0xd8> lapic[index] = value; 801026d9: c7 80 70 03 00 00 33 movl $0x33,0x370(%eax) 801026e0: 00 00 00 lapic[ID]; // wait for write to finish, by reading 801026e3: 8b 50 20 mov 0x20(%eax),%edx lapic[index] = value; 801026e6: c7 80 80 02 00 00 00 movl $0x0,0x280(%eax) 801026ed: 00 00 00 lapic[ID]; // wait for write to finish, by reading 801026f0: 8b 50 20 mov 0x20(%eax),%edx lapic[index] = value; 801026f3: c7 80 80 02 00 00 00 movl $0x0,0x280(%eax) 801026fa: 00 00 00 lapic[ID]; // wait for write to finish, by reading 801026fd: 8b 50 20 mov 0x20(%eax),%edx lapic[index] = value; 80102700: c7 80 b0 00 00 00 00 movl $0x0,0xb0(%eax) 80102707: 00 00 00 lapic[ID]; // wait for write to finish, by reading 8010270a: 8b 50 20 mov 0x20(%eax),%edx lapic[index] = value; 8010270d: c7 80 10 03 00 00 00 movl $0x0,0x310(%eax) 80102714: 00 00 00 lapic[ID]; // wait for write to finish, by reading 80102717: 8b 50 20 mov 0x20(%eax),%edx lapic[index] = value; 8010271a: c7 80 00 03 00 00 00 movl $0x88500,0x300(%eax) 80102721: 85 08 00 lapic[ID]; // wait for write to finish, by reading 80102724: 8b 50 20 mov 0x20(%eax),%edx 80102727: 90 nop while(lapic[ICRLO] & DELIVS) 80102728: 8b 90 00 03 00 00 mov 0x300(%eax),%edx 8010272e: 80 e6 10 and $0x10,%dh 80102731: 75 f5 jne 80102728 <lapicinit+0xb8> lapic[index] = value; 80102733: c7 80 80 00 00 00 00 movl $0x0,0x80(%eax) 8010273a: 00 00 00 lapic[ID]; // wait for write to finish, by reading 8010273d: 8b 40 20 mov 0x20(%eax),%eax } 80102740: 5d pop %ebp 80102741: c3 ret 80102742: 8d b6 00 00 00 00 lea 0x0(%esi),%esi lapic[index] = value; 80102748: c7 80 40 03 00 00 00 movl $0x10000,0x340(%eax) 8010274f: 00 01 00 lapic[ID]; // wait for write to finish, by reading 80102752: 8b 50 20 mov 0x20(%eax),%edx 80102755: eb 82 jmp 801026d9 <lapicinit+0x69> 80102757: 89 f6 mov %esi,%esi 80102759: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102760 <lapicid>: if (!lapic) 80102760: a1 7c 26 11 80 mov 0x8011267c,%eax { 80102765: 55 push %ebp 80102766: 89 e5 mov %esp,%ebp if (!lapic) 80102768: 85 c0 test %eax,%eax 8010276a: 74 0c je 80102778 <lapicid+0x18> return lapic[ID] >> 24; 8010276c: 8b 40 20 mov 0x20(%eax),%eax } 8010276f: 5d pop %ebp return lapic[ID] >> 24; 80102770: c1 e8 18 shr $0x18,%eax } 80102773: c3 ret 80102774: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return 0; 80102778: 31 c0 xor %eax,%eax } 8010277a: 5d pop %ebp 8010277b: c3 ret 8010277c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102780 <lapiceoi>: if(lapic) 80102780: a1 7c 26 11 80 mov 0x8011267c,%eax { 80102785: 55 push %ebp 80102786: 89 e5 mov %esp,%ebp if(lapic) 80102788: 85 c0 test %eax,%eax 8010278a: 74 0d je 80102799 <lapiceoi+0x19> lapic[index] = value; 8010278c: c7 80 b0 00 00 00 00 movl $0x0,0xb0(%eax) 80102793: 00 00 00 lapic[ID]; // wait for write to finish, by reading 80102796: 8b 40 20 mov 0x20(%eax),%eax } 80102799: 5d pop %ebp 8010279a: c3 ret 8010279b: 90 nop 8010279c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801027a0 <microdelay>: { 801027a0: 55 push %ebp 801027a1: 89 e5 mov %esp,%ebp } 801027a3: 5d pop %ebp 801027a4: c3 ret 801027a5: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801027a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801027b0 <lapicstartap>: { 801027b0: 55 push %ebp asm volatile("out %0,%1" : : "a" (data), "d" (port)); 801027b1: ba 70 00 00 00 mov $0x70,%edx 801027b6: 89 e5 mov %esp,%ebp 801027b8: b8 0f 00 00 00 mov $0xf,%eax 801027bd: 53 push %ebx 801027be: 8b 4d 08 mov 0x8(%ebp),%ecx 801027c1: 8b 5d 0c mov 0xc(%ebp),%ebx 801027c4: ee out %al,(%dx) 801027c5: b8 0a 00 00 00 mov $0xa,%eax 801027ca: b2 71 mov $0x71,%dl 801027cc: ee out %al,(%dx) wrv[0] = 0; 801027cd: 31 c0 xor %eax,%eax 801027cf: 66 a3 67 04 00 80 mov %ax,0x80000467 wrv[1] = addr >> 4; 801027d5: 89 d8 mov %ebx,%eax 801027d7: c1 e8 04 shr $0x4,%eax 801027da: 66 a3 69 04 00 80 mov %ax,0x80000469 lapic[index] = value; 801027e0: a1 7c 26 11 80 mov 0x8011267c,%eax lapicw(ICRHI, apicid<<24); 801027e5: c1 e1 18 shl $0x18,%ecx lapicw(ICRLO, STARTUP | (addr>>12)); 801027e8: c1 eb 0c shr $0xc,%ebx lapic[index] = value; 801027eb: 89 88 10 03 00 00 mov %ecx,0x310(%eax) lapic[ID]; // wait for write to finish, by reading 801027f1: 8b 50 20 mov 0x20(%eax),%edx lapic[index] = value; 801027f4: c7 80 00 03 00 00 00 movl $0xc500,0x300(%eax) 801027fb: c5 00 00 lapic[ID]; // wait for write to finish, by reading 801027fe: 8b 50 20 mov 0x20(%eax),%edx lapic[index] = value; 80102801: c7 80 00 03 00 00 00 movl $0x8500,0x300(%eax) 80102808: 85 00 00 lapic[ID]; // wait for write to finish, by reading 8010280b: 8b 50 20 mov 0x20(%eax),%edx lapic[index] = value; 8010280e: 89 88 10 03 00 00 mov %ecx,0x310(%eax) lapic[ID]; // wait for write to finish, by reading 80102814: 8b 50 20 mov 0x20(%eax),%edx lapicw(ICRLO, STARTUP | (addr>>12)); 80102817: 89 da mov %ebx,%edx 80102819: 80 ce 06 or $0x6,%dh lapic[index] = value; 8010281c: 89 90 00 03 00 00 mov %edx,0x300(%eax) lapic[ID]; // wait for write to finish, by reading 80102822: 8b 58 20 mov 0x20(%eax),%ebx lapic[index] = value; 80102825: 89 88 10 03 00 00 mov %ecx,0x310(%eax) lapic[ID]; // wait for write to finish, by reading 8010282b: 8b 48 20 mov 0x20(%eax),%ecx lapic[index] = value; 8010282e: 89 90 00 03 00 00 mov %edx,0x300(%eax) lapic[ID]; // wait for write to finish, by reading 80102834: 8b 40 20 mov 0x20(%eax),%eax } 80102837: 5b pop %ebx 80102838: 5d pop %ebp 80102839: c3 ret 8010283a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80102840 <cmostime>: // qemu seems to use 24-hour GWT and the values are BCD encoded void cmostime(struct rtcdate *r) { 80102840: 55 push %ebp 80102841: ba 70 00 00 00 mov $0x70,%edx 80102846: 89 e5 mov %esp,%ebp 80102848: b8 0b 00 00 00 mov $0xb,%eax 8010284d: 57 push %edi 8010284e: 56 push %esi 8010284f: 53 push %ebx 80102850: 83 ec 4c sub $0x4c,%esp 80102853: ee out %al,(%dx) asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 80102854: b2 71 mov $0x71,%dl 80102856: ec in (%dx),%al 80102857: 88 45 b7 mov %al,-0x49(%ebp) 8010285a: 8d 5d b8 lea -0x48(%ebp),%ebx struct rtcdate t1, t2; int sb, bcd; sb = cmos_read(CMOS_STATB); bcd = (sb & (1 << 2)) == 0; 8010285d: 80 65 b7 04 andb $0x4,-0x49(%ebp) 80102861: 8d 7d d0 lea -0x30(%ebp),%edi 80102864: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi asm volatile("out %0,%1" : : "a" (data), "d" (port)); 80102868: be 70 00 00 00 mov $0x70,%esi // make sure CMOS doesn't modify time while we read it for(;;) { fill_rtcdate(&t1); 8010286d: 89 d8 mov %ebx,%eax 8010286f: e8 7c fd ff ff call 801025f0 <fill_rtcdate> 80102874: b8 0a 00 00 00 mov $0xa,%eax 80102879: 89 f2 mov %esi,%edx 8010287b: ee out %al,(%dx) asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 8010287c: ba 71 00 00 00 mov $0x71,%edx 80102881: ec in (%dx),%al if(cmos_read(CMOS_STATA) & CMOS_UIP) 80102882: 84 c0 test %al,%al 80102884: 78 e7 js 8010286d <cmostime+0x2d> continue; fill_rtcdate(&t2); 80102886: 89 f8 mov %edi,%eax 80102888: e8 63 fd ff ff call 801025f0 <fill_rtcdate> if(memcmp(&t1, &t2, sizeof(t1)) == 0) 8010288d: c7 44 24 08 18 00 00 movl $0x18,0x8(%esp) 80102894: 00 80102895: 89 7c 24 04 mov %edi,0x4(%esp) 80102899: 89 1c 24 mov %ebx,(%esp) 8010289c: e8 4f 1a 00 00 call 801042f0 <memcmp> 801028a1: 85 c0 test %eax,%eax 801028a3: 75 c3 jne 80102868 <cmostime+0x28> break; } // convert if(bcd) { 801028a5: 80 7d b7 00 cmpb $0x0,-0x49(%ebp) 801028a9: 75 78 jne 80102923 <cmostime+0xe3> #define CONV(x) (t1.x = ((t1.x >> 4) * 10) + (t1.x & 0xf)) CONV(second); 801028ab: 8b 45 b8 mov -0x48(%ebp),%eax 801028ae: 89 c2 mov %eax,%edx 801028b0: 83 e0 0f and $0xf,%eax 801028b3: c1 ea 04 shr $0x4,%edx 801028b6: 8d 14 92 lea (%edx,%edx,4),%edx 801028b9: 8d 04 50 lea (%eax,%edx,2),%eax 801028bc: 89 45 b8 mov %eax,-0x48(%ebp) CONV(minute); 801028bf: 8b 45 bc mov -0x44(%ebp),%eax 801028c2: 89 c2 mov %eax,%edx 801028c4: 83 e0 0f and $0xf,%eax 801028c7: c1 ea 04 shr $0x4,%edx 801028ca: 8d 14 92 lea (%edx,%edx,4),%edx 801028cd: 8d 04 50 lea (%eax,%edx,2),%eax 801028d0: 89 45 bc mov %eax,-0x44(%ebp) CONV(hour ); 801028d3: 8b 45 c0 mov -0x40(%ebp),%eax 801028d6: 89 c2 mov %eax,%edx 801028d8: 83 e0 0f and $0xf,%eax 801028db: c1 ea 04 shr $0x4,%edx 801028de: 8d 14 92 lea (%edx,%edx,4),%edx 801028e1: 8d 04 50 lea (%eax,%edx,2),%eax 801028e4: 89 45 c0 mov %eax,-0x40(%ebp) CONV(day ); 801028e7: 8b 45 c4 mov -0x3c(%ebp),%eax 801028ea: 89 c2 mov %eax,%edx 801028ec: 83 e0 0f and $0xf,%eax 801028ef: c1 ea 04 shr $0x4,%edx 801028f2: 8d 14 92 lea (%edx,%edx,4),%edx 801028f5: 8d 04 50 lea (%eax,%edx,2),%eax 801028f8: 89 45 c4 mov %eax,-0x3c(%ebp) CONV(month ); 801028fb: 8b 45 c8 mov -0x38(%ebp),%eax 801028fe: 89 c2 mov %eax,%edx 80102900: 83 e0 0f and $0xf,%eax 80102903: c1 ea 04 shr $0x4,%edx 80102906: 8d 14 92 lea (%edx,%edx,4),%edx 80102909: 8d 04 50 lea (%eax,%edx,2),%eax 8010290c: 89 45 c8 mov %eax,-0x38(%ebp) CONV(year ); 8010290f: 8b 45 cc mov -0x34(%ebp),%eax 80102912: 89 c2 mov %eax,%edx 80102914: 83 e0 0f and $0xf,%eax 80102917: c1 ea 04 shr $0x4,%edx 8010291a: 8d 14 92 lea (%edx,%edx,4),%edx 8010291d: 8d 04 50 lea (%eax,%edx,2),%eax 80102920: 89 45 cc mov %eax,-0x34(%ebp) #undef CONV } *r = t1; 80102923: 8b 4d 08 mov 0x8(%ebp),%ecx 80102926: 8b 45 b8 mov -0x48(%ebp),%eax 80102929: 89 01 mov %eax,(%ecx) 8010292b: 8b 45 bc mov -0x44(%ebp),%eax 8010292e: 89 41 04 mov %eax,0x4(%ecx) 80102931: 8b 45 c0 mov -0x40(%ebp),%eax 80102934: 89 41 08 mov %eax,0x8(%ecx) 80102937: 8b 45 c4 mov -0x3c(%ebp),%eax 8010293a: 89 41 0c mov %eax,0xc(%ecx) 8010293d: 8b 45 c8 mov -0x38(%ebp),%eax 80102940: 89 41 10 mov %eax,0x10(%ecx) 80102943: 8b 45 cc mov -0x34(%ebp),%eax 80102946: 89 41 14 mov %eax,0x14(%ecx) r->year += 2000; 80102949: 81 41 14 d0 07 00 00 addl $0x7d0,0x14(%ecx) } 80102950: 83 c4 4c add $0x4c,%esp 80102953: 5b pop %ebx 80102954: 5e pop %esi 80102955: 5f pop %edi 80102956: 5d pop %ebp 80102957: c3 ret 80102958: 66 90 xchg %ax,%ax 8010295a: 66 90 xchg %ax,%ax 8010295c: 66 90 xchg %ax,%ax 8010295e: 66 90 xchg %ax,%ax 80102960 <install_trans>: } // Copy committed blocks from log to their home location static void install_trans(void) { 80102960: 55 push %ebp 80102961: 89 e5 mov %esp,%ebp 80102963: 57 push %edi 80102964: 56 push %esi 80102965: 53 push %ebx int tail; for (tail = 0; tail < log.lh.n; tail++) { 80102966: 31 db xor %ebx,%ebx { 80102968: 83 ec 1c sub $0x1c,%esp for (tail = 0; tail < log.lh.n; tail++) { 8010296b: a1 c8 26 11 80 mov 0x801126c8,%eax 80102970: 85 c0 test %eax,%eax 80102972: 7e 78 jle 801029ec <install_trans+0x8c> 80102974: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi struct buf *lbuf = bread(log.dev, log.start+tail+1); // read log block 80102978: a1 b4 26 11 80 mov 0x801126b4,%eax 8010297d: 01 d8 add %ebx,%eax 8010297f: 83 c0 01 add $0x1,%eax 80102982: 89 44 24 04 mov %eax,0x4(%esp) 80102986: a1 c4 26 11 80 mov 0x801126c4,%eax 8010298b: 89 04 24 mov %eax,(%esp) 8010298e: e8 3d d7 ff ff call 801000d0 <bread> 80102993: 89 c7 mov %eax,%edi struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst 80102995: 8b 04 9d cc 26 11 80 mov -0x7feed934(,%ebx,4),%eax for (tail = 0; tail < log.lh.n; tail++) { 8010299c: 83 c3 01 add $0x1,%ebx struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst 8010299f: 89 44 24 04 mov %eax,0x4(%esp) 801029a3: a1 c4 26 11 80 mov 0x801126c4,%eax 801029a8: 89 04 24 mov %eax,(%esp) 801029ab: e8 20 d7 ff ff call 801000d0 <bread> memmove(dbuf->data, lbuf->data, BSIZE); // copy block to dst 801029b0: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 801029b7: 00 struct buf *dbuf = bread(log.dev, log.lh.block[tail]); // read dst 801029b8: 89 c6 mov %eax,%esi memmove(dbuf->data, lbuf->data, BSIZE); // copy block to dst 801029ba: 8d 47 5c lea 0x5c(%edi),%eax 801029bd: 89 44 24 04 mov %eax,0x4(%esp) 801029c1: 8d 46 5c lea 0x5c(%esi),%eax 801029c4: 89 04 24 mov %eax,(%esp) 801029c7: e8 74 19 00 00 call 80104340 <memmove> bwrite(dbuf); // write dst to disk 801029cc: 89 34 24 mov %esi,(%esp) 801029cf: e8 cc d7 ff ff call 801001a0 <bwrite> brelse(lbuf); 801029d4: 89 3c 24 mov %edi,(%esp) 801029d7: e8 04 d8 ff ff call 801001e0 <brelse> brelse(dbuf); 801029dc: 89 34 24 mov %esi,(%esp) 801029df: e8 fc d7 ff ff call 801001e0 <brelse> for (tail = 0; tail < log.lh.n; tail++) { 801029e4: 39 1d c8 26 11 80 cmp %ebx,0x801126c8 801029ea: 7f 8c jg 80102978 <install_trans+0x18> } } 801029ec: 83 c4 1c add $0x1c,%esp 801029ef: 5b pop %ebx 801029f0: 5e pop %esi 801029f1: 5f pop %edi 801029f2: 5d pop %ebp 801029f3: c3 ret 801029f4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801029fa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80102a00 <write_head>: // Write in-memory log header to disk. // This is the true point at which the // current transaction commits. static void write_head(void) { 80102a00: 55 push %ebp 80102a01: 89 e5 mov %esp,%ebp 80102a03: 57 push %edi 80102a04: 56 push %esi 80102a05: 53 push %ebx 80102a06: 83 ec 1c sub $0x1c,%esp struct buf *buf = bread(log.dev, log.start); 80102a09: a1 b4 26 11 80 mov 0x801126b4,%eax 80102a0e: 89 44 24 04 mov %eax,0x4(%esp) 80102a12: a1 c4 26 11 80 mov 0x801126c4,%eax 80102a17: 89 04 24 mov %eax,(%esp) 80102a1a: e8 b1 d6 ff ff call 801000d0 <bread> struct logheader *hb = (struct logheader *) (buf->data); int i; hb->n = log.lh.n; 80102a1f: 8b 1d c8 26 11 80 mov 0x801126c8,%ebx for (i = 0; i < log.lh.n; i++) { 80102a25: 31 d2 xor %edx,%edx 80102a27: 85 db test %ebx,%ebx struct buf *buf = bread(log.dev, log.start); 80102a29: 89 c7 mov %eax,%edi hb->n = log.lh.n; 80102a2b: 89 58 5c mov %ebx,0x5c(%eax) 80102a2e: 8d 70 5c lea 0x5c(%eax),%esi for (i = 0; i < log.lh.n; i++) { 80102a31: 7e 17 jle 80102a4a <write_head+0x4a> 80102a33: 90 nop 80102a34: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi hb->block[i] = log.lh.block[i]; 80102a38: 8b 0c 95 cc 26 11 80 mov -0x7feed934(,%edx,4),%ecx 80102a3f: 89 4c 96 04 mov %ecx,0x4(%esi,%edx,4) for (i = 0; i < log.lh.n; i++) { 80102a43: 83 c2 01 add $0x1,%edx 80102a46: 39 da cmp %ebx,%edx 80102a48: 75 ee jne 80102a38 <write_head+0x38> } bwrite(buf); 80102a4a: 89 3c 24 mov %edi,(%esp) 80102a4d: e8 4e d7 ff ff call 801001a0 <bwrite> brelse(buf); 80102a52: 89 3c 24 mov %edi,(%esp) 80102a55: e8 86 d7 ff ff call 801001e0 <brelse> } 80102a5a: 83 c4 1c add $0x1c,%esp 80102a5d: 5b pop %ebx 80102a5e: 5e pop %esi 80102a5f: 5f pop %edi 80102a60: 5d pop %ebp 80102a61: c3 ret 80102a62: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80102a69: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102a70 <initlog>: { 80102a70: 55 push %ebp 80102a71: 89 e5 mov %esp,%ebp 80102a73: 56 push %esi 80102a74: 53 push %ebx 80102a75: 83 ec 30 sub $0x30,%esp 80102a78: 8b 5d 08 mov 0x8(%ebp),%ebx initlock(&log.lock, "log"); 80102a7b: c7 44 24 04 80 70 10 movl $0x80107080,0x4(%esp) 80102a82: 80 80102a83: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) 80102a8a: e8 e1 15 00 00 call 80104070 <initlock> readsb(dev, &sb); 80102a8f: 8d 45 dc lea -0x24(%ebp),%eax 80102a92: 89 44 24 04 mov %eax,0x4(%esp) 80102a96: 89 1c 24 mov %ebx,(%esp) 80102a99: e8 82 e9 ff ff call 80101420 <readsb> log.start = sb.logstart; 80102a9e: 8b 45 ec mov -0x14(%ebp),%eax log.size = sb.nlog; 80102aa1: 8b 55 e8 mov -0x18(%ebp),%edx struct buf *buf = bread(log.dev, log.start); 80102aa4: 89 1c 24 mov %ebx,(%esp) log.dev = dev; 80102aa7: 89 1d c4 26 11 80 mov %ebx,0x801126c4 struct buf *buf = bread(log.dev, log.start); 80102aad: 89 44 24 04 mov %eax,0x4(%esp) log.size = sb.nlog; 80102ab1: 89 15 b8 26 11 80 mov %edx,0x801126b8 log.start = sb.logstart; 80102ab7: a3 b4 26 11 80 mov %eax,0x801126b4 struct buf *buf = bread(log.dev, log.start); 80102abc: e8 0f d6 ff ff call 801000d0 <bread> for (i = 0; i < log.lh.n; i++) { 80102ac1: 31 d2 xor %edx,%edx log.lh.n = lh->n; 80102ac3: 8b 58 5c mov 0x5c(%eax),%ebx 80102ac6: 8d 70 5c lea 0x5c(%eax),%esi for (i = 0; i < log.lh.n; i++) { 80102ac9: 85 db test %ebx,%ebx log.lh.n = lh->n; 80102acb: 89 1d c8 26 11 80 mov %ebx,0x801126c8 for (i = 0; i < log.lh.n; i++) { 80102ad1: 7e 17 jle 80102aea <initlog+0x7a> 80102ad3: 90 nop 80102ad4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi log.lh.block[i] = lh->block[i]; 80102ad8: 8b 4c 96 04 mov 0x4(%esi,%edx,4),%ecx 80102adc: 89 0c 95 cc 26 11 80 mov %ecx,-0x7feed934(,%edx,4) for (i = 0; i < log.lh.n; i++) { 80102ae3: 83 c2 01 add $0x1,%edx 80102ae6: 39 da cmp %ebx,%edx 80102ae8: 75 ee jne 80102ad8 <initlog+0x68> brelse(buf); 80102aea: 89 04 24 mov %eax,(%esp) 80102aed: e8 ee d6 ff ff call 801001e0 <brelse> static void recover_from_log(void) { read_head(); install_trans(); // if committed, copy from log to disk 80102af2: e8 69 fe ff ff call 80102960 <install_trans> log.lh.n = 0; 80102af7: c7 05 c8 26 11 80 00 movl $0x0,0x801126c8 80102afe: 00 00 00 write_head(); // clear the log 80102b01: e8 fa fe ff ff call 80102a00 <write_head> } 80102b06: 83 c4 30 add $0x30,%esp 80102b09: 5b pop %ebx 80102b0a: 5e pop %esi 80102b0b: 5d pop %ebp 80102b0c: c3 ret 80102b0d: 8d 76 00 lea 0x0(%esi),%esi 80102b10 <begin_op>: } // called at the start of each FS system call. void begin_op(void) { 80102b10: 55 push %ebp 80102b11: 89 e5 mov %esp,%ebp 80102b13: 83 ec 18 sub $0x18,%esp acquire(&log.lock); 80102b16: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) 80102b1d: e8 be 16 00 00 call 801041e0 <acquire> 80102b22: eb 18 jmp 80102b3c <begin_op+0x2c> 80102b24: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi while(1){ if(log.committing){ sleep(&log, &log.lock); 80102b28: c7 44 24 04 80 26 11 movl $0x80112680,0x4(%esp) 80102b2f: 80 80102b30: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) 80102b37: e8 c4 10 00 00 call 80103c00 <sleep> if(log.committing){ 80102b3c: a1 c0 26 11 80 mov 0x801126c0,%eax 80102b41: 85 c0 test %eax,%eax 80102b43: 75 e3 jne 80102b28 <begin_op+0x18> } else if(log.lh.n + (log.outstanding+1)*MAXOPBLOCKS > LOGSIZE){ 80102b45: a1 bc 26 11 80 mov 0x801126bc,%eax 80102b4a: 8b 15 c8 26 11 80 mov 0x801126c8,%edx 80102b50: 83 c0 01 add $0x1,%eax 80102b53: 8d 0c 80 lea (%eax,%eax,4),%ecx 80102b56: 8d 14 4a lea (%edx,%ecx,2),%edx 80102b59: 83 fa 1e cmp $0x1e,%edx 80102b5c: 7f ca jg 80102b28 <begin_op+0x18> // this op might exhaust log space; wait for commit. sleep(&log, &log.lock); } else { log.outstanding += 1; release(&log.lock); 80102b5e: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) log.outstanding += 1; 80102b65: a3 bc 26 11 80 mov %eax,0x801126bc release(&log.lock); 80102b6a: e8 e1 16 00 00 call 80104250 <release> break; } } } 80102b6f: c9 leave 80102b70: c3 ret 80102b71: eb 0d jmp 80102b80 <end_op> 80102b73: 90 nop 80102b74: 90 nop 80102b75: 90 nop 80102b76: 90 nop 80102b77: 90 nop 80102b78: 90 nop 80102b79: 90 nop 80102b7a: 90 nop 80102b7b: 90 nop 80102b7c: 90 nop 80102b7d: 90 nop 80102b7e: 90 nop 80102b7f: 90 nop 80102b80 <end_op>: // called at the end of each FS system call. // commits if this was the last outstanding operation. void end_op(void) { 80102b80: 55 push %ebp 80102b81: 89 e5 mov %esp,%ebp 80102b83: 57 push %edi 80102b84: 56 push %esi 80102b85: 53 push %ebx 80102b86: 83 ec 1c sub $0x1c,%esp int do_commit = 0; acquire(&log.lock); 80102b89: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) 80102b90: e8 4b 16 00 00 call 801041e0 <acquire> log.outstanding -= 1; 80102b95: a1 bc 26 11 80 mov 0x801126bc,%eax if(log.committing) 80102b9a: 8b 15 c0 26 11 80 mov 0x801126c0,%edx log.outstanding -= 1; 80102ba0: 83 e8 01 sub $0x1,%eax if(log.committing) 80102ba3: 85 d2 test %edx,%edx log.outstanding -= 1; 80102ba5: a3 bc 26 11 80 mov %eax,0x801126bc if(log.committing) 80102baa: 0f 85 f3 00 00 00 jne 80102ca3 <end_op+0x123> panic("log.committing"); if(log.outstanding == 0){ 80102bb0: 85 c0 test %eax,%eax 80102bb2: 0f 85 cb 00 00 00 jne 80102c83 <end_op+0x103> // begin_op() may be waiting for log space, // and decrementing log.outstanding has decreased // the amount of reserved space. wakeup(&log); } release(&log.lock); 80102bb8: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) } static void commit() { if (log.lh.n > 0) { 80102bbf: 31 db xor %ebx,%ebx log.committing = 1; 80102bc1: c7 05 c0 26 11 80 01 movl $0x1,0x801126c0 80102bc8: 00 00 00 release(&log.lock); 80102bcb: e8 80 16 00 00 call 80104250 <release> if (log.lh.n > 0) { 80102bd0: a1 c8 26 11 80 mov 0x801126c8,%eax 80102bd5: 85 c0 test %eax,%eax 80102bd7: 0f 8e 90 00 00 00 jle 80102c6d <end_op+0xed> 80102bdd: 8d 76 00 lea 0x0(%esi),%esi struct buf *to = bread(log.dev, log.start+tail+1); // log block 80102be0: a1 b4 26 11 80 mov 0x801126b4,%eax 80102be5: 01 d8 add %ebx,%eax 80102be7: 83 c0 01 add $0x1,%eax 80102bea: 89 44 24 04 mov %eax,0x4(%esp) 80102bee: a1 c4 26 11 80 mov 0x801126c4,%eax 80102bf3: 89 04 24 mov %eax,(%esp) 80102bf6: e8 d5 d4 ff ff call 801000d0 <bread> 80102bfb: 89 c6 mov %eax,%esi struct buf *from = bread(log.dev, log.lh.block[tail]); // cache block 80102bfd: 8b 04 9d cc 26 11 80 mov -0x7feed934(,%ebx,4),%eax for (tail = 0; tail < log.lh.n; tail++) { 80102c04: 83 c3 01 add $0x1,%ebx struct buf *from = bread(log.dev, log.lh.block[tail]); // cache block 80102c07: 89 44 24 04 mov %eax,0x4(%esp) 80102c0b: a1 c4 26 11 80 mov 0x801126c4,%eax 80102c10: 89 04 24 mov %eax,(%esp) 80102c13: e8 b8 d4 ff ff call 801000d0 <bread> memmove(to->data, from->data, BSIZE); 80102c18: c7 44 24 08 00 02 00 movl $0x200,0x8(%esp) 80102c1f: 00 struct buf *from = bread(log.dev, log.lh.block[tail]); // cache block 80102c20: 89 c7 mov %eax,%edi memmove(to->data, from->data, BSIZE); 80102c22: 8d 40 5c lea 0x5c(%eax),%eax 80102c25: 89 44 24 04 mov %eax,0x4(%esp) 80102c29: 8d 46 5c lea 0x5c(%esi),%eax 80102c2c: 89 04 24 mov %eax,(%esp) 80102c2f: e8 0c 17 00 00 call 80104340 <memmove> bwrite(to); // write the log 80102c34: 89 34 24 mov %esi,(%esp) 80102c37: e8 64 d5 ff ff call 801001a0 <bwrite> brelse(from); 80102c3c: 89 3c 24 mov %edi,(%esp) 80102c3f: e8 9c d5 ff ff call 801001e0 <brelse> brelse(to); 80102c44: 89 34 24 mov %esi,(%esp) 80102c47: e8 94 d5 ff ff call 801001e0 <brelse> for (tail = 0; tail < log.lh.n; tail++) { 80102c4c: 3b 1d c8 26 11 80 cmp 0x801126c8,%ebx 80102c52: 7c 8c jl 80102be0 <end_op+0x60> write_log(); // Write modified blocks from cache to log write_head(); // Write header to disk -- the real commit 80102c54: e8 a7 fd ff ff call 80102a00 <write_head> install_trans(); // Now install writes to home locations 80102c59: e8 02 fd ff ff call 80102960 <install_trans> log.lh.n = 0; 80102c5e: c7 05 c8 26 11 80 00 movl $0x0,0x801126c8 80102c65: 00 00 00 write_head(); // Erase the transaction from the log 80102c68: e8 93 fd ff ff call 80102a00 <write_head> acquire(&log.lock); 80102c6d: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) 80102c74: e8 67 15 00 00 call 801041e0 <acquire> log.committing = 0; 80102c79: c7 05 c0 26 11 80 00 movl $0x0,0x801126c0 80102c80: 00 00 00 wakeup(&log); 80102c83: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) 80102c8a: e8 01 11 00 00 call 80103d90 <wakeup> release(&log.lock); 80102c8f: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) 80102c96: e8 b5 15 00 00 call 80104250 <release> } 80102c9b: 83 c4 1c add $0x1c,%esp 80102c9e: 5b pop %ebx 80102c9f: 5e pop %esi 80102ca0: 5f pop %edi 80102ca1: 5d pop %ebp 80102ca2: c3 ret panic("log.committing"); 80102ca3: c7 04 24 84 70 10 80 movl $0x80107084,(%esp) 80102caa: e8 b1 d6 ff ff call 80100360 <panic> 80102caf: 90 nop 80102cb0 <log_write>: // modify bp->data[] // log_write(bp) // brelse(bp) void log_write(struct buf *b) { 80102cb0: 55 push %ebp 80102cb1: 89 e5 mov %esp,%ebp 80102cb3: 53 push %ebx 80102cb4: 83 ec 14 sub $0x14,%esp int i; if (log.lh.n >= LOGSIZE || log.lh.n >= log.size - 1) 80102cb7: a1 c8 26 11 80 mov 0x801126c8,%eax { 80102cbc: 8b 5d 08 mov 0x8(%ebp),%ebx if (log.lh.n >= LOGSIZE || log.lh.n >= log.size - 1) 80102cbf: 83 f8 1d cmp $0x1d,%eax 80102cc2: 0f 8f 98 00 00 00 jg 80102d60 <log_write+0xb0> 80102cc8: 8b 0d b8 26 11 80 mov 0x801126b8,%ecx 80102cce: 8d 51 ff lea -0x1(%ecx),%edx 80102cd1: 39 d0 cmp %edx,%eax 80102cd3: 0f 8d 87 00 00 00 jge 80102d60 <log_write+0xb0> panic("too big a transaction"); if (log.outstanding < 1) 80102cd9: a1 bc 26 11 80 mov 0x801126bc,%eax 80102cde: 85 c0 test %eax,%eax 80102ce0: 0f 8e 86 00 00 00 jle 80102d6c <log_write+0xbc> panic("log_write outside of trans"); acquire(&log.lock); 80102ce6: c7 04 24 80 26 11 80 movl $0x80112680,(%esp) 80102ced: e8 ee 14 00 00 call 801041e0 <acquire> for (i = 0; i < log.lh.n; i++) { 80102cf2: 8b 15 c8 26 11 80 mov 0x801126c8,%edx 80102cf8: 83 fa 00 cmp $0x0,%edx 80102cfb: 7e 54 jle 80102d51 <log_write+0xa1> if (log.lh.block[i] == b->blockno) // log absorbtion 80102cfd: 8b 4b 08 mov 0x8(%ebx),%ecx for (i = 0; i < log.lh.n; i++) { 80102d00: 31 c0 xor %eax,%eax if (log.lh.block[i] == b->blockno) // log absorbtion 80102d02: 39 0d cc 26 11 80 cmp %ecx,0x801126cc 80102d08: 75 0f jne 80102d19 <log_write+0x69> 80102d0a: eb 3c jmp 80102d48 <log_write+0x98> 80102d0c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80102d10: 39 0c 85 cc 26 11 80 cmp %ecx,-0x7feed934(,%eax,4) 80102d17: 74 2f je 80102d48 <log_write+0x98> for (i = 0; i < log.lh.n; i++) { 80102d19: 83 c0 01 add $0x1,%eax 80102d1c: 39 d0 cmp %edx,%eax 80102d1e: 75 f0 jne 80102d10 <log_write+0x60> break; } log.lh.block[i] = b->blockno; 80102d20: 89 0c 95 cc 26 11 80 mov %ecx,-0x7feed934(,%edx,4) if (i == log.lh.n) log.lh.n++; 80102d27: 83 c2 01 add $0x1,%edx 80102d2a: 89 15 c8 26 11 80 mov %edx,0x801126c8 b->flags |= B_DIRTY; // prevent eviction 80102d30: 83 0b 04 orl $0x4,(%ebx) release(&log.lock); 80102d33: c7 45 08 80 26 11 80 movl $0x80112680,0x8(%ebp) } 80102d3a: 83 c4 14 add $0x14,%esp 80102d3d: 5b pop %ebx 80102d3e: 5d pop %ebp release(&log.lock); 80102d3f: e9 0c 15 00 00 jmp 80104250 <release> 80102d44: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi log.lh.block[i] = b->blockno; 80102d48: 89 0c 85 cc 26 11 80 mov %ecx,-0x7feed934(,%eax,4) 80102d4f: eb df jmp 80102d30 <log_write+0x80> 80102d51: 8b 43 08 mov 0x8(%ebx),%eax 80102d54: a3 cc 26 11 80 mov %eax,0x801126cc if (i == log.lh.n) 80102d59: 75 d5 jne 80102d30 <log_write+0x80> 80102d5b: eb ca jmp 80102d27 <log_write+0x77> 80102d5d: 8d 76 00 lea 0x0(%esi),%esi panic("too big a transaction"); 80102d60: c7 04 24 93 70 10 80 movl $0x80107093,(%esp) 80102d67: e8 f4 d5 ff ff call 80100360 <panic> panic("log_write outside of trans"); 80102d6c: c7 04 24 a9 70 10 80 movl $0x801070a9,(%esp) 80102d73: e8 e8 d5 ff ff call 80100360 <panic> 80102d78: 66 90 xchg %ax,%ax 80102d7a: 66 90 xchg %ax,%ax 80102d7c: 66 90 xchg %ax,%ax 80102d7e: 66 90 xchg %ax,%ax 80102d80 <mpmain>: } // Common CPU setup code. static void mpmain(void) { 80102d80: 55 push %ebp 80102d81: 89 e5 mov %esp,%ebp 80102d83: 53 push %ebx 80102d84: 83 ec 14 sub $0x14,%esp cprintf("cpu%d: starting %d\n", cpuid(), cpuid()); 80102d87: e8 f4 08 00 00 call 80103680 <cpuid> 80102d8c: 89 c3 mov %eax,%ebx 80102d8e: e8 ed 08 00 00 call 80103680 <cpuid> 80102d93: 89 5c 24 08 mov %ebx,0x8(%esp) 80102d97: c7 04 24 c4 70 10 80 movl $0x801070c4,(%esp) 80102d9e: 89 44 24 04 mov %eax,0x4(%esp) 80102da2: e8 a9 d8 ff ff call 80100650 <cprintf> idtinit(); // load idt register 80102da7: e8 d4 26 00 00 call 80105480 <idtinit> xchg(&(mycpu()->started), 1); // tell startothers() we're up 80102dac: e8 4f 08 00 00 call 80103600 <mycpu> 80102db1: 89 c2 mov %eax,%edx xchg(volatile uint *addr, uint newval) { uint result; // The + in "+m" denotes a read-modify-write operand. asm volatile("lock; xchgl %0, %1" : 80102db3: b8 01 00 00 00 mov $0x1,%eax 80102db8: f0 87 82 a0 00 00 00 lock xchg %eax,0xa0(%edx) scheduler(); // start running processes 80102dbf: e8 9c 0b 00 00 call 80103960 <scheduler> 80102dc4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80102dca: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80102dd0 <mpenter>: { 80102dd0: 55 push %ebp 80102dd1: 89 e5 mov %esp,%ebp 80102dd3: 83 ec 08 sub $0x8,%esp switchkvm(); 80102dd6: e8 65 37 00 00 call 80106540 <switchkvm> seginit(); 80102ddb: e8 a0 36 00 00 call 80106480 <seginit> lapicinit(); 80102de0: e8 8b f8 ff ff call 80102670 <lapicinit> mpmain(); 80102de5: e8 96 ff ff ff call 80102d80 <mpmain> 80102dea: 66 90 xchg %ax,%ax 80102dec: 66 90 xchg %ax,%ax 80102dee: 66 90 xchg %ax,%ax 80102df0 <main>: { 80102df0: 55 push %ebp 80102df1: 89 e5 mov %esp,%ebp 80102df3: 53 push %ebx // The linker has placed the image of entryother.S in // _binary_entryother_start. code = P2V(0x7000); memmove(code, _binary_entryother_start, (uint)_binary_entryother_size); for(c = cpus; c < cpus+ncpu; c++){ 80102df4: bb 80 27 11 80 mov $0x80112780,%ebx { 80102df9: 83 e4 f0 and $0xfffffff0,%esp 80102dfc: 83 ec 10 sub $0x10,%esp kinit1(end, P2V(4*1024*1024)); // phys page allocator 80102dff: c7 44 24 04 00 00 40 movl $0x80400000,0x4(%esp) 80102e06: 80 80102e07: c7 04 24 a8 54 11 80 movl $0x801154a8,(%esp) 80102e0e: e8 cd f5 ff ff call 801023e0 <kinit1> kvmalloc(); // kernel page table 80102e13: e8 b8 3b 00 00 call 801069d0 <kvmalloc> mpinit(); // detect other processors 80102e18: e8 73 01 00 00 call 80102f90 <mpinit> 80102e1d: 8d 76 00 lea 0x0(%esi),%esi lapicinit(); // interrupt controller 80102e20: e8 4b f8 ff ff call 80102670 <lapicinit> seginit(); // segment descriptors 80102e25: e8 56 36 00 00 call 80106480 <seginit> picinit(); // disable pic 80102e2a: e8 21 03 00 00 call 80103150 <picinit> 80102e2f: 90 nop ioapicinit(); // another interrupt controller 80102e30: e8 cb f3 ff ff call 80102200 <ioapicinit> consoleinit(); // console hardware 80102e35: e8 16 db ff ff call 80100950 <consoleinit> uartinit(); // serial port 80102e3a: e8 61 29 00 00 call 801057a0 <uartinit> 80102e3f: 90 nop pinit(); // process table 80102e40: e8 9b 07 00 00 call 801035e0 <pinit> tvinit(); // trap vectors 80102e45: e8 96 25 00 00 call 801053e0 <tvinit> binit(); // buffer cache 80102e4a: e8 f1 d1 ff ff call 80100040 <binit> 80102e4f: 90 nop fileinit(); // file table 80102e50: e8 fb de ff ff call 80100d50 <fileinit> ideinit(); // disk 80102e55: e8 a6 f1 ff ff call 80102000 <ideinit> memmove(code, _binary_entryother_start, (uint)_binary_entryother_size); 80102e5a: c7 44 24 08 8a 00 00 movl $0x8a,0x8(%esp) 80102e61: 00 80102e62: c7 44 24 04 8c a4 10 movl $0x8010a48c,0x4(%esp) 80102e69: 80 80102e6a: c7 04 24 00 70 00 80 movl $0x80007000,(%esp) 80102e71: e8 ca 14 00 00 call 80104340 <memmove> for(c = cpus; c < cpus+ncpu; c++){ 80102e76: 69 05 00 2d 11 80 b0 imul $0xb0,0x80112d00,%eax 80102e7d: 00 00 00 80102e80: 05 80 27 11 80 add $0x80112780,%eax 80102e85: 39 d8 cmp %ebx,%eax 80102e87: 76 6a jbe 80102ef3 <main+0x103> 80102e89: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(c == mycpu()) // We've started already. 80102e90: e8 6b 07 00 00 call 80103600 <mycpu> 80102e95: 39 d8 cmp %ebx,%eax 80102e97: 74 41 je 80102eda <main+0xea> continue; // Tell entryother.S what stack to use, where to enter, and what // pgdir to use. We cannot use kpgdir yet, because the AP processor // is running in low memory, so we use entrypgdir for the APs too. stack = kalloc(); 80102e99: e8 02 f6 ff ff call 801024a0 <kalloc> *(void**)(code-4) = stack + KSTACKSIZE; *(void(**)(void))(code-8) = mpenter; 80102e9e: c7 05 f8 6f 00 80 d0 movl $0x80102dd0,0x80006ff8 80102ea5: 2d 10 80 *(int**)(code-12) = (void *) V2P(entrypgdir); 80102ea8: c7 05 f4 6f 00 80 00 movl $0x109000,0x80006ff4 80102eaf: 90 10 00 *(void**)(code-4) = stack + KSTACKSIZE; 80102eb2: 05 00 10 00 00 add $0x1000,%eax 80102eb7: a3 fc 6f 00 80 mov %eax,0x80006ffc lapicstartap(c->apicid, V2P(code)); 80102ebc: 0f b6 03 movzbl (%ebx),%eax 80102ebf: c7 44 24 04 00 70 00 movl $0x7000,0x4(%esp) 80102ec6: 00 80102ec7: 89 04 24 mov %eax,(%esp) 80102eca: e8 e1 f8 ff ff call 801027b0 <lapicstartap> 80102ecf: 90 nop // wait for cpu to finish mpmain() while(c->started == 0) 80102ed0: 8b 83 a0 00 00 00 mov 0xa0(%ebx),%eax 80102ed6: 85 c0 test %eax,%eax 80102ed8: 74 f6 je 80102ed0 <main+0xe0> for(c = cpus; c < cpus+ncpu; c++){ 80102eda: 69 05 00 2d 11 80 b0 imul $0xb0,0x80112d00,%eax 80102ee1: 00 00 00 80102ee4: 81 c3 b0 00 00 00 add $0xb0,%ebx 80102eea: 05 80 27 11 80 add $0x80112780,%eax 80102eef: 39 c3 cmp %eax,%ebx 80102ef1: 72 9d jb 80102e90 <main+0xa0> kinit2(P2V(4*1024*1024), P2V(PHYSTOP)); // must come after startothers() 80102ef3: c7 44 24 04 00 00 00 movl $0x8e000000,0x4(%esp) 80102efa: 8e 80102efb: c7 04 24 00 00 40 80 movl $0x80400000,(%esp) 80102f02: e8 49 f5 ff ff call 80102450 <kinit2> userinit(); // first user process 80102f07: e8 c4 07 00 00 call 801036d0 <userinit> mpmain(); // finish this processor's setup 80102f0c: e8 6f fe ff ff call 80102d80 <mpmain> 80102f11: 66 90 xchg %ax,%ax 80102f13: 66 90 xchg %ax,%ax 80102f15: 66 90 xchg %ax,%ax 80102f17: 66 90 xchg %ax,%ax 80102f19: 66 90 xchg %ax,%ax 80102f1b: 66 90 xchg %ax,%ax 80102f1d: 66 90 xchg %ax,%ax 80102f1f: 90 nop 80102f20 <mpsearch1>: } // Look for an MP structure in the len bytes at addr. static struct mp* mpsearch1(uint a, int len) { 80102f20: 55 push %ebp 80102f21: 89 e5 mov %esp,%ebp 80102f23: 56 push %esi uchar *e, *p, *addr; addr = P2V(a); 80102f24: 8d b0 00 00 00 80 lea -0x80000000(%eax),%esi { 80102f2a: 53 push %ebx e = addr+len; 80102f2b: 8d 1c 16 lea (%esi,%edx,1),%ebx { 80102f2e: 83 ec 10 sub $0x10,%esp for(p = addr; p < e; p += sizeof(struct mp)) 80102f31: 39 de cmp %ebx,%esi 80102f33: 73 3c jae 80102f71 <mpsearch1+0x51> 80102f35: 8d 76 00 lea 0x0(%esi),%esi if(memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0) 80102f38: c7 44 24 08 04 00 00 movl $0x4,0x8(%esp) 80102f3f: 00 80102f40: c7 44 24 04 d8 70 10 movl $0x801070d8,0x4(%esp) 80102f47: 80 80102f48: 89 34 24 mov %esi,(%esp) 80102f4b: e8 a0 13 00 00 call 801042f0 <memcmp> 80102f50: 85 c0 test %eax,%eax 80102f52: 75 16 jne 80102f6a <mpsearch1+0x4a> 80102f54: 31 c9 xor %ecx,%ecx 80102f56: 31 d2 xor %edx,%edx sum += addr[i]; 80102f58: 0f b6 04 16 movzbl (%esi,%edx,1),%eax for(i=0; i<len; i++) 80102f5c: 83 c2 01 add $0x1,%edx sum += addr[i]; 80102f5f: 01 c1 add %eax,%ecx for(i=0; i<len; i++) 80102f61: 83 fa 10 cmp $0x10,%edx 80102f64: 75 f2 jne 80102f58 <mpsearch1+0x38> if(memcmp(p, "_MP_", 4) == 0 && sum(p, sizeof(struct mp)) == 0) 80102f66: 84 c9 test %cl,%cl 80102f68: 74 10 je 80102f7a <mpsearch1+0x5a> for(p = addr; p < e; p += sizeof(struct mp)) 80102f6a: 83 c6 10 add $0x10,%esi 80102f6d: 39 f3 cmp %esi,%ebx 80102f6f: 77 c7 ja 80102f38 <mpsearch1+0x18> return (struct mp*)p; return 0; } 80102f71: 83 c4 10 add $0x10,%esp return 0; 80102f74: 31 c0 xor %eax,%eax } 80102f76: 5b pop %ebx 80102f77: 5e pop %esi 80102f78: 5d pop %ebp 80102f79: c3 ret 80102f7a: 83 c4 10 add $0x10,%esp 80102f7d: 89 f0 mov %esi,%eax 80102f7f: 5b pop %ebx 80102f80: 5e pop %esi 80102f81: 5d pop %ebp 80102f82: c3 ret 80102f83: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80102f89: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80102f90 <mpinit>: return conf; } void mpinit(void) { 80102f90: 55 push %ebp 80102f91: 89 e5 mov %esp,%ebp 80102f93: 57 push %edi 80102f94: 56 push %esi 80102f95: 53 push %ebx 80102f96: 83 ec 1c sub $0x1c,%esp if((p = ((bda[0x0F]<<8)| bda[0x0E]) << 4)){ 80102f99: 0f b6 05 0f 04 00 80 movzbl 0x8000040f,%eax 80102fa0: 0f b6 15 0e 04 00 80 movzbl 0x8000040e,%edx 80102fa7: c1 e0 08 shl $0x8,%eax 80102faa: 09 d0 or %edx,%eax 80102fac: c1 e0 04 shl $0x4,%eax 80102faf: 85 c0 test %eax,%eax 80102fb1: 75 1b jne 80102fce <mpinit+0x3e> p = ((bda[0x14]<<8)|bda[0x13])*1024; 80102fb3: 0f b6 05 14 04 00 80 movzbl 0x80000414,%eax 80102fba: 0f b6 15 13 04 00 80 movzbl 0x80000413,%edx 80102fc1: c1 e0 08 shl $0x8,%eax 80102fc4: 09 d0 or %edx,%eax 80102fc6: c1 e0 0a shl $0xa,%eax if((mp = mpsearch1(p-1024, 1024))) 80102fc9: 2d 00 04 00 00 sub $0x400,%eax if((mp = mpsearch1(p, 1024))) 80102fce: ba 00 04 00 00 mov $0x400,%edx 80102fd3: e8 48 ff ff ff call 80102f20 <mpsearch1> 80102fd8: 85 c0 test %eax,%eax 80102fda: 89 c7 mov %eax,%edi 80102fdc: 0f 84 22 01 00 00 je 80103104 <mpinit+0x174> if((mp = mpsearch()) == 0 || mp->physaddr == 0) 80102fe2: 8b 77 04 mov 0x4(%edi),%esi 80102fe5: 85 f6 test %esi,%esi 80102fe7: 0f 84 30 01 00 00 je 8010311d <mpinit+0x18d> conf = (struct mpconf*) P2V((uint) mp->physaddr); 80102fed: 8d 86 00 00 00 80 lea -0x80000000(%esi),%eax if(memcmp(conf, "PCMP", 4) != 0) 80102ff3: c7 44 24 08 04 00 00 movl $0x4,0x8(%esp) 80102ffa: 00 80102ffb: c7 44 24 04 dd 70 10 movl $0x801070dd,0x4(%esp) 80103002: 80 80103003: 89 04 24 mov %eax,(%esp) conf = (struct mpconf*) P2V((uint) mp->physaddr); 80103006: 89 45 e4 mov %eax,-0x1c(%ebp) if(memcmp(conf, "PCMP", 4) != 0) 80103009: e8 e2 12 00 00 call 801042f0 <memcmp> 8010300e: 85 c0 test %eax,%eax 80103010: 0f 85 07 01 00 00 jne 8010311d <mpinit+0x18d> if(conf->version != 1 && conf->version != 4) 80103016: 0f b6 86 06 00 00 80 movzbl -0x7ffffffa(%esi),%eax 8010301d: 3c 04 cmp $0x4,%al 8010301f: 0f 85 0b 01 00 00 jne 80103130 <mpinit+0x1a0> if(sum((uchar*)conf, conf->length) != 0) 80103025: 0f b7 86 04 00 00 80 movzwl -0x7ffffffc(%esi),%eax for(i=0; i<len; i++) 8010302c: 85 c0 test %eax,%eax 8010302e: 74 21 je 80103051 <mpinit+0xc1> sum = 0; 80103030: 31 c9 xor %ecx,%ecx for(i=0; i<len; i++) 80103032: 31 d2 xor %edx,%edx 80103034: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi sum += addr[i]; 80103038: 0f b6 9c 16 00 00 00 movzbl -0x80000000(%esi,%edx,1),%ebx 8010303f: 80 for(i=0; i<len; i++) 80103040: 83 c2 01 add $0x1,%edx sum += addr[i]; 80103043: 01 d9 add %ebx,%ecx for(i=0; i<len; i++) 80103045: 39 d0 cmp %edx,%eax 80103047: 7f ef jg 80103038 <mpinit+0xa8> if(sum((uchar*)conf, conf->length) != 0) 80103049: 84 c9 test %cl,%cl 8010304b: 0f 85 cc 00 00 00 jne 8010311d <mpinit+0x18d> struct mp *mp; struct mpconf *conf; struct mpproc *proc; struct mpioapic *ioapic; if((conf = mpconfig(&mp)) == 0) 80103051: 8b 45 e4 mov -0x1c(%ebp),%eax 80103054: 85 c0 test %eax,%eax 80103056: 0f 84 c1 00 00 00 je 8010311d <mpinit+0x18d> panic("Expect to run on an SMP"); ismp = 1; lapic = (uint*)conf->lapicaddr; 8010305c: 8b 86 24 00 00 80 mov -0x7fffffdc(%esi),%eax ismp = 1; 80103062: bb 01 00 00 00 mov $0x1,%ebx lapic = (uint*)conf->lapicaddr; 80103067: a3 7c 26 11 80 mov %eax,0x8011267c for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){ 8010306c: 0f b7 96 04 00 00 80 movzwl -0x7ffffffc(%esi),%edx 80103073: 8d 86 2c 00 00 80 lea -0x7fffffd4(%esi),%eax 80103079: 03 55 e4 add -0x1c(%ebp),%edx 8010307c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103080: 39 c2 cmp %eax,%edx 80103082: 76 1b jbe 8010309f <mpinit+0x10f> 80103084: 0f b6 08 movzbl (%eax),%ecx switch(*p){ 80103087: 80 f9 04 cmp $0x4,%cl 8010308a: 77 74 ja 80103100 <mpinit+0x170> 8010308c: ff 24 8d 1c 71 10 80 jmp *-0x7fef8ee4(,%ecx,4) 80103093: 90 nop 80103094: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi p += sizeof(struct mpioapic); continue; case MPBUS: case MPIOINTR: case MPLINTR: p += 8; 80103098: 83 c0 08 add $0x8,%eax for(p=(uchar*)(conf+1), e=(uchar*)conf+conf->length; p<e; ){ 8010309b: 39 c2 cmp %eax,%edx 8010309d: 77 e5 ja 80103084 <mpinit+0xf4> default: ismp = 0; break; } } if(!ismp) 8010309f: 85 db test %ebx,%ebx 801030a1: 0f 84 93 00 00 00 je 8010313a <mpinit+0x1aa> panic("Didn't find a suitable machine"); if(mp->imcrp){ 801030a7: 80 7f 0c 00 cmpb $0x0,0xc(%edi) 801030ab: 74 12 je 801030bf <mpinit+0x12f> asm volatile("out %0,%1" : : "a" (data), "d" (port)); 801030ad: ba 22 00 00 00 mov $0x22,%edx 801030b2: b8 70 00 00 00 mov $0x70,%eax 801030b7: ee out %al,(%dx) asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 801030b8: b2 23 mov $0x23,%dl 801030ba: ec in (%dx),%al // Bochs doesn't support IMCR, so this doesn't run on Bochs. // But it would on real hardware. outb(0x22, 0x70); // Select IMCR outb(0x23, inb(0x23) | 1); // Mask external interrupts. 801030bb: 83 c8 01 or $0x1,%eax asm volatile("out %0,%1" : : "a" (data), "d" (port)); 801030be: ee out %al,(%dx) } } 801030bf: 83 c4 1c add $0x1c,%esp 801030c2: 5b pop %ebx 801030c3: 5e pop %esi 801030c4: 5f pop %edi 801030c5: 5d pop %ebp 801030c6: c3 ret 801030c7: 90 nop if(ncpu < NCPU) { 801030c8: 8b 35 00 2d 11 80 mov 0x80112d00,%esi 801030ce: 83 fe 07 cmp $0x7,%esi 801030d1: 7f 17 jg 801030ea <mpinit+0x15a> cpus[ncpu].apicid = proc->apicid; // apicid may differ from ncpu 801030d3: 0f b6 48 01 movzbl 0x1(%eax),%ecx 801030d7: 69 f6 b0 00 00 00 imul $0xb0,%esi,%esi ncpu++; 801030dd: 83 05 00 2d 11 80 01 addl $0x1,0x80112d00 cpus[ncpu].apicid = proc->apicid; // apicid may differ from ncpu 801030e4: 88 8e 80 27 11 80 mov %cl,-0x7feed880(%esi) p += sizeof(struct mpproc); 801030ea: 83 c0 14 add $0x14,%eax continue; 801030ed: eb 91 jmp 80103080 <mpinit+0xf0> 801030ef: 90 nop ioapicid = ioapic->apicno; 801030f0: 0f b6 48 01 movzbl 0x1(%eax),%ecx p += sizeof(struct mpioapic); 801030f4: 83 c0 08 add $0x8,%eax ioapicid = ioapic->apicno; 801030f7: 88 0d 60 27 11 80 mov %cl,0x80112760 continue; 801030fd: eb 81 jmp 80103080 <mpinit+0xf0> 801030ff: 90 nop ismp = 0; 80103100: 31 db xor %ebx,%ebx 80103102: eb 83 jmp 80103087 <mpinit+0xf7> return mpsearch1(0xF0000, 0x10000); 80103104: ba 00 00 01 00 mov $0x10000,%edx 80103109: b8 00 00 0f 00 mov $0xf0000,%eax 8010310e: e8 0d fe ff ff call 80102f20 <mpsearch1> if((mp = mpsearch()) == 0 || mp->physaddr == 0) 80103113: 85 c0 test %eax,%eax return mpsearch1(0xF0000, 0x10000); 80103115: 89 c7 mov %eax,%edi if((mp = mpsearch()) == 0 || mp->physaddr == 0) 80103117: 0f 85 c5 fe ff ff jne 80102fe2 <mpinit+0x52> panic("Expect to run on an SMP"); 8010311d: c7 04 24 e2 70 10 80 movl $0x801070e2,(%esp) 80103124: e8 37 d2 ff ff call 80100360 <panic> 80103129: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(conf->version != 1 && conf->version != 4) 80103130: 3c 01 cmp $0x1,%al 80103132: 0f 84 ed fe ff ff je 80103025 <mpinit+0x95> 80103138: eb e3 jmp 8010311d <mpinit+0x18d> panic("Didn't find a suitable machine"); 8010313a: c7 04 24 fc 70 10 80 movl $0x801070fc,(%esp) 80103141: e8 1a d2 ff ff call 80100360 <panic> 80103146: 66 90 xchg %ax,%ax 80103148: 66 90 xchg %ax,%ax 8010314a: 66 90 xchg %ax,%ax 8010314c: 66 90 xchg %ax,%ax 8010314e: 66 90 xchg %ax,%ax 80103150 <picinit>: #define IO_PIC2 0xA0 // Slave (IRQs 8-15) // Don't use the 8259A interrupt controllers. Xv6 assumes SMP hardware. void picinit(void) { 80103150: 55 push %ebp 80103151: ba 21 00 00 00 mov $0x21,%edx 80103156: 89 e5 mov %esp,%ebp 80103158: b8 ff ff ff ff mov $0xffffffff,%eax 8010315d: ee out %al,(%dx) 8010315e: b2 a1 mov $0xa1,%dl 80103160: ee out %al,(%dx) // mask all interrupts outb(IO_PIC1+1, 0xFF); outb(IO_PIC2+1, 0xFF); } 80103161: 5d pop %ebp 80103162: c3 ret 80103163: 66 90 xchg %ax,%ax 80103165: 66 90 xchg %ax,%ax 80103167: 66 90 xchg %ax,%ax 80103169: 66 90 xchg %ax,%ax 8010316b: 66 90 xchg %ax,%ax 8010316d: 66 90 xchg %ax,%ax 8010316f: 90 nop 80103170 <pipealloc>: int writeopen; // write fd is still open }; int pipealloc(struct file **f0, struct file **f1) { 80103170: 55 push %ebp 80103171: 89 e5 mov %esp,%ebp 80103173: 57 push %edi 80103174: 56 push %esi 80103175: 53 push %ebx 80103176: 83 ec 1c sub $0x1c,%esp 80103179: 8b 75 08 mov 0x8(%ebp),%esi 8010317c: 8b 5d 0c mov 0xc(%ebp),%ebx struct pipe *p; p = 0; *f0 = *f1 = 0; 8010317f: c7 03 00 00 00 00 movl $0x0,(%ebx) 80103185: c7 06 00 00 00 00 movl $0x0,(%esi) if((*f0 = filealloc()) == 0 || (*f1 = filealloc()) == 0) 8010318b: e8 e0 db ff ff call 80100d70 <filealloc> 80103190: 85 c0 test %eax,%eax 80103192: 89 06 mov %eax,(%esi) 80103194: 0f 84 a4 00 00 00 je 8010323e <pipealloc+0xce> 8010319a: e8 d1 db ff ff call 80100d70 <filealloc> 8010319f: 85 c0 test %eax,%eax 801031a1: 89 03 mov %eax,(%ebx) 801031a3: 0f 84 87 00 00 00 je 80103230 <pipealloc+0xc0> goto bad; if((p = (struct pipe*)kalloc()) == 0) 801031a9: e8 f2 f2 ff ff call 801024a0 <kalloc> 801031ae: 85 c0 test %eax,%eax 801031b0: 89 c7 mov %eax,%edi 801031b2: 74 7c je 80103230 <pipealloc+0xc0> goto bad; p->readopen = 1; 801031b4: c7 80 3c 02 00 00 01 movl $0x1,0x23c(%eax) 801031bb: 00 00 00 p->writeopen = 1; 801031be: c7 80 40 02 00 00 01 movl $0x1,0x240(%eax) 801031c5: 00 00 00 p->nwrite = 0; 801031c8: c7 80 38 02 00 00 00 movl $0x0,0x238(%eax) 801031cf: 00 00 00 p->nread = 0; 801031d2: c7 80 34 02 00 00 00 movl $0x0,0x234(%eax) 801031d9: 00 00 00 initlock(&p->lock, "pipe"); 801031dc: 89 04 24 mov %eax,(%esp) 801031df: c7 44 24 04 30 71 10 movl $0x80107130,0x4(%esp) 801031e6: 80 801031e7: e8 84 0e 00 00 call 80104070 <initlock> (*f0)->type = FD_PIPE; 801031ec: 8b 06 mov (%esi),%eax 801031ee: c7 00 01 00 00 00 movl $0x1,(%eax) (*f0)->readable = 1; 801031f4: 8b 06 mov (%esi),%eax 801031f6: c6 40 08 01 movb $0x1,0x8(%eax) (*f0)->writable = 0; 801031fa: 8b 06 mov (%esi),%eax 801031fc: c6 40 09 00 movb $0x0,0x9(%eax) (*f0)->pipe = p; 80103200: 8b 06 mov (%esi),%eax 80103202: 89 78 0c mov %edi,0xc(%eax) (*f1)->type = FD_PIPE; 80103205: 8b 03 mov (%ebx),%eax 80103207: c7 00 01 00 00 00 movl $0x1,(%eax) (*f1)->readable = 0; 8010320d: 8b 03 mov (%ebx),%eax 8010320f: c6 40 08 00 movb $0x0,0x8(%eax) (*f1)->writable = 1; 80103213: 8b 03 mov (%ebx),%eax 80103215: c6 40 09 01 movb $0x1,0x9(%eax) (*f1)->pipe = p; 80103219: 8b 03 mov (%ebx),%eax return 0; 8010321b: 31 db xor %ebx,%ebx (*f1)->pipe = p; 8010321d: 89 78 0c mov %edi,0xc(%eax) if(*f0) fileclose(*f0); if(*f1) fileclose(*f1); return -1; } 80103220: 83 c4 1c add $0x1c,%esp 80103223: 89 d8 mov %ebx,%eax 80103225: 5b pop %ebx 80103226: 5e pop %esi 80103227: 5f pop %edi 80103228: 5d pop %ebp 80103229: c3 ret 8010322a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(*f0) 80103230: 8b 06 mov (%esi),%eax 80103232: 85 c0 test %eax,%eax 80103234: 74 08 je 8010323e <pipealloc+0xce> fileclose(*f0); 80103236: 89 04 24 mov %eax,(%esp) 80103239: e8 f2 db ff ff call 80100e30 <fileclose> if(*f1) 8010323e: 8b 03 mov (%ebx),%eax return -1; 80103240: bb ff ff ff ff mov $0xffffffff,%ebx if(*f1) 80103245: 85 c0 test %eax,%eax 80103247: 74 d7 je 80103220 <pipealloc+0xb0> fileclose(*f1); 80103249: 89 04 24 mov %eax,(%esp) 8010324c: e8 df db ff ff call 80100e30 <fileclose> } 80103251: 83 c4 1c add $0x1c,%esp 80103254: 89 d8 mov %ebx,%eax 80103256: 5b pop %ebx 80103257: 5e pop %esi 80103258: 5f pop %edi 80103259: 5d pop %ebp 8010325a: c3 ret 8010325b: 90 nop 8010325c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103260 <pipeclose>: void pipeclose(struct pipe *p, int writable) { 80103260: 55 push %ebp 80103261: 89 e5 mov %esp,%ebp 80103263: 56 push %esi 80103264: 53 push %ebx 80103265: 83 ec 10 sub $0x10,%esp 80103268: 8b 5d 08 mov 0x8(%ebp),%ebx 8010326b: 8b 75 0c mov 0xc(%ebp),%esi acquire(&p->lock); 8010326e: 89 1c 24 mov %ebx,(%esp) 80103271: e8 6a 0f 00 00 call 801041e0 <acquire> if(writable){ 80103276: 85 f6 test %esi,%esi 80103278: 74 3e je 801032b8 <pipeclose+0x58> p->writeopen = 0; wakeup(&p->nread); 8010327a: 8d 83 34 02 00 00 lea 0x234(%ebx),%eax p->writeopen = 0; 80103280: c7 83 40 02 00 00 00 movl $0x0,0x240(%ebx) 80103287: 00 00 00 wakeup(&p->nread); 8010328a: 89 04 24 mov %eax,(%esp) 8010328d: e8 fe 0a 00 00 call 80103d90 <wakeup> } else { p->readopen = 0; wakeup(&p->nwrite); } if(p->readopen == 0 && p->writeopen == 0){ 80103292: 8b 93 3c 02 00 00 mov 0x23c(%ebx),%edx 80103298: 85 d2 test %edx,%edx 8010329a: 75 0a jne 801032a6 <pipeclose+0x46> 8010329c: 8b 83 40 02 00 00 mov 0x240(%ebx),%eax 801032a2: 85 c0 test %eax,%eax 801032a4: 74 32 je 801032d8 <pipeclose+0x78> release(&p->lock); kfree((char*)p); } else release(&p->lock); 801032a6: 89 5d 08 mov %ebx,0x8(%ebp) } 801032a9: 83 c4 10 add $0x10,%esp 801032ac: 5b pop %ebx 801032ad: 5e pop %esi 801032ae: 5d pop %ebp release(&p->lock); 801032af: e9 9c 0f 00 00 jmp 80104250 <release> 801032b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi wakeup(&p->nwrite); 801032b8: 8d 83 38 02 00 00 lea 0x238(%ebx),%eax p->readopen = 0; 801032be: c7 83 3c 02 00 00 00 movl $0x0,0x23c(%ebx) 801032c5: 00 00 00 wakeup(&p->nwrite); 801032c8: 89 04 24 mov %eax,(%esp) 801032cb: e8 c0 0a 00 00 call 80103d90 <wakeup> 801032d0: eb c0 jmp 80103292 <pipeclose+0x32> 801032d2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi release(&p->lock); 801032d8: 89 1c 24 mov %ebx,(%esp) 801032db: e8 70 0f 00 00 call 80104250 <release> kfree((char*)p); 801032e0: 89 5d 08 mov %ebx,0x8(%ebp) } 801032e3: 83 c4 10 add $0x10,%esp 801032e6: 5b pop %ebx 801032e7: 5e pop %esi 801032e8: 5d pop %ebp kfree((char*)p); 801032e9: e9 02 f0 ff ff jmp 801022f0 <kfree> 801032ee: 66 90 xchg %ax,%ax 801032f0 <pipewrite>: //PAGEBREAK: 40 int pipewrite(struct pipe *p, char *addr, int n) { 801032f0: 55 push %ebp 801032f1: 89 e5 mov %esp,%ebp 801032f3: 57 push %edi 801032f4: 56 push %esi 801032f5: 53 push %ebx 801032f6: 83 ec 1c sub $0x1c,%esp 801032f9: 8b 5d 08 mov 0x8(%ebp),%ebx int i; acquire(&p->lock); 801032fc: 89 1c 24 mov %ebx,(%esp) 801032ff: e8 dc 0e 00 00 call 801041e0 <acquire> for(i = 0; i < n; i++){ 80103304: 8b 4d 10 mov 0x10(%ebp),%ecx 80103307: 85 c9 test %ecx,%ecx 80103309: 0f 8e b2 00 00 00 jle 801033c1 <pipewrite+0xd1> 8010330f: 8b 4d 0c mov 0xc(%ebp),%ecx while(p->nwrite == p->nread + PIPESIZE){ //DOC: pipewrite-full if(p->readopen == 0 || myproc()->killed){ release(&p->lock); return -1; } wakeup(&p->nread); 80103312: 8d bb 34 02 00 00 lea 0x234(%ebx),%edi 80103318: 8b 83 38 02 00 00 mov 0x238(%ebx),%eax sleep(&p->nwrite, &p->lock); //DOC: pipewrite-sleep 8010331e: 8d b3 38 02 00 00 lea 0x238(%ebx),%esi 80103324: 89 4d e4 mov %ecx,-0x1c(%ebp) 80103327: 03 4d 10 add 0x10(%ebp),%ecx 8010332a: 89 4d e0 mov %ecx,-0x20(%ebp) while(p->nwrite == p->nread + PIPESIZE){ //DOC: pipewrite-full 8010332d: 8b 8b 34 02 00 00 mov 0x234(%ebx),%ecx 80103333: 81 c1 00 02 00 00 add $0x200,%ecx 80103339: 39 c8 cmp %ecx,%eax 8010333b: 74 38 je 80103375 <pipewrite+0x85> 8010333d: eb 55 jmp 80103394 <pipewrite+0xa4> 8010333f: 90 nop if(p->readopen == 0 || myproc()->killed){ 80103340: e8 5b 03 00 00 call 801036a0 <myproc> 80103345: 8b 40 24 mov 0x24(%eax),%eax 80103348: 85 c0 test %eax,%eax 8010334a: 75 33 jne 8010337f <pipewrite+0x8f> wakeup(&p->nread); 8010334c: 89 3c 24 mov %edi,(%esp) 8010334f: e8 3c 0a 00 00 call 80103d90 <wakeup> sleep(&p->nwrite, &p->lock); //DOC: pipewrite-sleep 80103354: 89 5c 24 04 mov %ebx,0x4(%esp) 80103358: 89 34 24 mov %esi,(%esp) 8010335b: e8 a0 08 00 00 call 80103c00 <sleep> while(p->nwrite == p->nread + PIPESIZE){ //DOC: pipewrite-full 80103360: 8b 83 34 02 00 00 mov 0x234(%ebx),%eax 80103366: 8b 93 38 02 00 00 mov 0x238(%ebx),%edx 8010336c: 05 00 02 00 00 add $0x200,%eax 80103371: 39 c2 cmp %eax,%edx 80103373: 75 23 jne 80103398 <pipewrite+0xa8> if(p->readopen == 0 || myproc()->killed){ 80103375: 8b 93 3c 02 00 00 mov 0x23c(%ebx),%edx 8010337b: 85 d2 test %edx,%edx 8010337d: 75 c1 jne 80103340 <pipewrite+0x50> release(&p->lock); 8010337f: 89 1c 24 mov %ebx,(%esp) 80103382: e8 c9 0e 00 00 call 80104250 <release> return -1; 80103387: b8 ff ff ff ff mov $0xffffffff,%eax p->data[p->nwrite++ % PIPESIZE] = addr[i]; } wakeup(&p->nread); //DOC: pipewrite-wakeup1 release(&p->lock); return n; } 8010338c: 83 c4 1c add $0x1c,%esp 8010338f: 5b pop %ebx 80103390: 5e pop %esi 80103391: 5f pop %edi 80103392: 5d pop %ebp 80103393: c3 ret while(p->nwrite == p->nread + PIPESIZE){ //DOC: pipewrite-full 80103394: 89 c2 mov %eax,%edx 80103396: 66 90 xchg %ax,%ax p->data[p->nwrite++ % PIPESIZE] = addr[i]; 80103398: 8b 4d e4 mov -0x1c(%ebp),%ecx 8010339b: 8d 42 01 lea 0x1(%edx),%eax 8010339e: 81 e2 ff 01 00 00 and $0x1ff,%edx 801033a4: 89 83 38 02 00 00 mov %eax,0x238(%ebx) 801033aa: 83 45 e4 01 addl $0x1,-0x1c(%ebp) 801033ae: 0f b6 09 movzbl (%ecx),%ecx 801033b1: 88 4c 13 34 mov %cl,0x34(%ebx,%edx,1) for(i = 0; i < n; i++){ 801033b5: 8b 4d e4 mov -0x1c(%ebp),%ecx 801033b8: 3b 4d e0 cmp -0x20(%ebp),%ecx 801033bb: 0f 85 6c ff ff ff jne 8010332d <pipewrite+0x3d> wakeup(&p->nread); //DOC: pipewrite-wakeup1 801033c1: 8d 83 34 02 00 00 lea 0x234(%ebx),%eax 801033c7: 89 04 24 mov %eax,(%esp) 801033ca: e8 c1 09 00 00 call 80103d90 <wakeup> release(&p->lock); 801033cf: 89 1c 24 mov %ebx,(%esp) 801033d2: e8 79 0e 00 00 call 80104250 <release> return n; 801033d7: 8b 45 10 mov 0x10(%ebp),%eax 801033da: eb b0 jmp 8010338c <pipewrite+0x9c> 801033dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801033e0 <piperead>: int piperead(struct pipe *p, char *addr, int n) { 801033e0: 55 push %ebp 801033e1: 89 e5 mov %esp,%ebp 801033e3: 57 push %edi 801033e4: 56 push %esi 801033e5: 53 push %ebx 801033e6: 83 ec 1c sub $0x1c,%esp 801033e9: 8b 75 08 mov 0x8(%ebp),%esi 801033ec: 8b 7d 0c mov 0xc(%ebp),%edi int i; acquire(&p->lock); 801033ef: 89 34 24 mov %esi,(%esp) 801033f2: e8 e9 0d 00 00 call 801041e0 <acquire> while(p->nread == p->nwrite && p->writeopen){ //DOC: pipe-empty 801033f7: 8b 86 34 02 00 00 mov 0x234(%esi),%eax 801033fd: 3b 86 38 02 00 00 cmp 0x238(%esi),%eax 80103403: 75 5b jne 80103460 <piperead+0x80> 80103405: 8b 9e 40 02 00 00 mov 0x240(%esi),%ebx 8010340b: 85 db test %ebx,%ebx 8010340d: 74 51 je 80103460 <piperead+0x80> if(myproc()->killed){ release(&p->lock); return -1; } sleep(&p->nread, &p->lock); //DOC: piperead-sleep 8010340f: 8d 9e 34 02 00 00 lea 0x234(%esi),%ebx 80103415: eb 25 jmp 8010343c <piperead+0x5c> 80103417: 90 nop 80103418: 89 74 24 04 mov %esi,0x4(%esp) 8010341c: 89 1c 24 mov %ebx,(%esp) 8010341f: e8 dc 07 00 00 call 80103c00 <sleep> while(p->nread == p->nwrite && p->writeopen){ //DOC: pipe-empty 80103424: 8b 86 34 02 00 00 mov 0x234(%esi),%eax 8010342a: 3b 86 38 02 00 00 cmp 0x238(%esi),%eax 80103430: 75 2e jne 80103460 <piperead+0x80> 80103432: 8b 96 40 02 00 00 mov 0x240(%esi),%edx 80103438: 85 d2 test %edx,%edx 8010343a: 74 24 je 80103460 <piperead+0x80> if(myproc()->killed){ 8010343c: e8 5f 02 00 00 call 801036a0 <myproc> 80103441: 8b 48 24 mov 0x24(%eax),%ecx 80103444: 85 c9 test %ecx,%ecx 80103446: 74 d0 je 80103418 <piperead+0x38> release(&p->lock); 80103448: 89 34 24 mov %esi,(%esp) 8010344b: e8 00 0e 00 00 call 80104250 <release> addr[i] = p->data[p->nread++ % PIPESIZE]; } wakeup(&p->nwrite); //DOC: piperead-wakeup release(&p->lock); return i; } 80103450: 83 c4 1c add $0x1c,%esp return -1; 80103453: b8 ff ff ff ff mov $0xffffffff,%eax } 80103458: 5b pop %ebx 80103459: 5e pop %esi 8010345a: 5f pop %edi 8010345b: 5d pop %ebp 8010345c: c3 ret 8010345d: 8d 76 00 lea 0x0(%esi),%esi for(i = 0; i < n; i++){ //DOC: piperead-copy 80103460: 8b 55 10 mov 0x10(%ebp),%edx if(p->nread == p->nwrite) 80103463: 31 db xor %ebx,%ebx for(i = 0; i < n; i++){ //DOC: piperead-copy 80103465: 85 d2 test %edx,%edx 80103467: 7f 2b jg 80103494 <piperead+0xb4> 80103469: eb 31 jmp 8010349c <piperead+0xbc> 8010346b: 90 nop 8010346c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi addr[i] = p->data[p->nread++ % PIPESIZE]; 80103470: 8d 48 01 lea 0x1(%eax),%ecx 80103473: 25 ff 01 00 00 and $0x1ff,%eax 80103478: 89 8e 34 02 00 00 mov %ecx,0x234(%esi) 8010347e: 0f b6 44 06 34 movzbl 0x34(%esi,%eax,1),%eax 80103483: 88 04 1f mov %al,(%edi,%ebx,1) for(i = 0; i < n; i++){ //DOC: piperead-copy 80103486: 83 c3 01 add $0x1,%ebx 80103489: 3b 5d 10 cmp 0x10(%ebp),%ebx 8010348c: 74 0e je 8010349c <piperead+0xbc> if(p->nread == p->nwrite) 8010348e: 8b 86 34 02 00 00 mov 0x234(%esi),%eax 80103494: 3b 86 38 02 00 00 cmp 0x238(%esi),%eax 8010349a: 75 d4 jne 80103470 <piperead+0x90> wakeup(&p->nwrite); //DOC: piperead-wakeup 8010349c: 8d 86 38 02 00 00 lea 0x238(%esi),%eax 801034a2: 89 04 24 mov %eax,(%esp) 801034a5: e8 e6 08 00 00 call 80103d90 <wakeup> release(&p->lock); 801034aa: 89 34 24 mov %esi,(%esp) 801034ad: e8 9e 0d 00 00 call 80104250 <release> } 801034b2: 83 c4 1c add $0x1c,%esp return i; 801034b5: 89 d8 mov %ebx,%eax } 801034b7: 5b pop %ebx 801034b8: 5e pop %esi 801034b9: 5f pop %edi 801034ba: 5d pop %ebp 801034bb: c3 ret 801034bc: 66 90 xchg %ax,%ax 801034be: 66 90 xchg %ax,%ax 801034c0 <allocproc>: // If found, change state to EMBRYO and initialize // state required to run in the kernel. // Otherwise return 0. static struct proc* allocproc(void) { 801034c0: 55 push %ebp 801034c1: 89 e5 mov %esp,%ebp 801034c3: 53 push %ebx struct proc *p; char *sp; acquire(&ptable.lock); for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 801034c4: bb 54 2d 11 80 mov $0x80112d54,%ebx { 801034c9: 83 ec 14 sub $0x14,%esp acquire(&ptable.lock); 801034cc: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 801034d3: e8 08 0d 00 00 call 801041e0 <acquire> 801034d8: eb 11 jmp 801034eb <allocproc+0x2b> 801034da: 8d b6 00 00 00 00 lea 0x0(%esi),%esi for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 801034e0: 83 c3 7c add $0x7c,%ebx 801034e3: 81 fb 54 4c 11 80 cmp $0x80114c54,%ebx 801034e9: 74 7d je 80103568 <allocproc+0xa8> if(p->state == UNUSED) 801034eb: 8b 43 0c mov 0xc(%ebx),%eax 801034ee: 85 c0 test %eax,%eax 801034f0: 75 ee jne 801034e0 <allocproc+0x20> release(&ptable.lock); return 0; found: p->state = EMBRYO; p->pid = nextpid++; 801034f2: a1 04 a0 10 80 mov 0x8010a004,%eax release(&ptable.lock); 801034f7: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) p->state = EMBRYO; 801034fe: c7 43 0c 01 00 00 00 movl $0x1,0xc(%ebx) p->pid = nextpid++; 80103505: 8d 50 01 lea 0x1(%eax),%edx 80103508: 89 15 04 a0 10 80 mov %edx,0x8010a004 8010350e: 89 43 10 mov %eax,0x10(%ebx) release(&ptable.lock); 80103511: e8 3a 0d 00 00 call 80104250 <release> // Allocate kernel stack. if((p->kstack = kalloc()) == 0){ 80103516: e8 85 ef ff ff call 801024a0 <kalloc> 8010351b: 85 c0 test %eax,%eax 8010351d: 89 43 08 mov %eax,0x8(%ebx) 80103520: 74 5a je 8010357c <allocproc+0xbc> return 0; } sp = p->kstack + KSTACKSIZE; // Leave room for trap frame. sp -= sizeof *p->tf; 80103522: 8d 90 b4 0f 00 00 lea 0xfb4(%eax),%edx // Set up new context to start executing at forkret, // which returns to trapret. sp -= 4; *(uint*)sp = (uint)trapret; sp -= sizeof *p->context; 80103528: 05 9c 0f 00 00 add $0xf9c,%eax sp -= sizeof *p->tf; 8010352d: 89 53 18 mov %edx,0x18(%ebx) *(uint*)sp = (uint)trapret; 80103530: c7 40 14 d5 53 10 80 movl $0x801053d5,0x14(%eax) p->context = (struct context*)sp; memset(p->context, 0, sizeof *p->context); 80103537: c7 44 24 08 14 00 00 movl $0x14,0x8(%esp) 8010353e: 00 8010353f: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80103546: 00 80103547: 89 04 24 mov %eax,(%esp) p->context = (struct context*)sp; 8010354a: 89 43 1c mov %eax,0x1c(%ebx) memset(p->context, 0, sizeof *p->context); 8010354d: e8 4e 0d 00 00 call 801042a0 <memset> p->context->eip = (uint)forkret; 80103552: 8b 43 1c mov 0x1c(%ebx),%eax 80103555: c7 40 10 90 35 10 80 movl $0x80103590,0x10(%eax) return p; 8010355c: 89 d8 mov %ebx,%eax } 8010355e: 83 c4 14 add $0x14,%esp 80103561: 5b pop %ebx 80103562: 5d pop %ebp 80103563: c3 ret 80103564: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi release(&ptable.lock); 80103568: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 8010356f: e8 dc 0c 00 00 call 80104250 <release> } 80103574: 83 c4 14 add $0x14,%esp return 0; 80103577: 31 c0 xor %eax,%eax } 80103579: 5b pop %ebx 8010357a: 5d pop %ebp 8010357b: c3 ret p->state = UNUSED; 8010357c: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx) return 0; 80103583: eb d9 jmp 8010355e <allocproc+0x9e> 80103585: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103589: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103590 <forkret>: // A fork child's very first scheduling by scheduler() // will swtch here. "Return" to user space. void forkret(void) { 80103590: 55 push %ebp 80103591: 89 e5 mov %esp,%ebp 80103593: 83 ec 18 sub $0x18,%esp static int first = 1; // Still holding ptable.lock from scheduler. release(&ptable.lock); 80103596: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 8010359d: e8 ae 0c 00 00 call 80104250 <release> if (first) { 801035a2: a1 00 a0 10 80 mov 0x8010a000,%eax 801035a7: 85 c0 test %eax,%eax 801035a9: 75 05 jne 801035b0 <forkret+0x20> iinit(ROOTDEV); initlog(ROOTDEV); } // Return to "caller", actually trapret (see allocproc). } 801035ab: c9 leave 801035ac: c3 ret 801035ad: 8d 76 00 lea 0x0(%esi),%esi iinit(ROOTDEV); 801035b0: c7 04 24 01 00 00 00 movl $0x1,(%esp) first = 0; 801035b7: c7 05 00 a0 10 80 00 movl $0x0,0x8010a000 801035be: 00 00 00 iinit(ROOTDEV); 801035c1: e8 aa de ff ff call 80101470 <iinit> initlog(ROOTDEV); 801035c6: c7 04 24 01 00 00 00 movl $0x1,(%esp) 801035cd: e8 9e f4 ff ff call 80102a70 <initlog> } 801035d2: c9 leave 801035d3: c3 ret 801035d4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801035da: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 801035e0 <pinit>: { 801035e0: 55 push %ebp 801035e1: 89 e5 mov %esp,%ebp 801035e3: 83 ec 18 sub $0x18,%esp initlock(&ptable.lock, "ptable"); 801035e6: c7 44 24 04 35 71 10 movl $0x80107135,0x4(%esp) 801035ed: 80 801035ee: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 801035f5: e8 76 0a 00 00 call 80104070 <initlock> } 801035fa: c9 leave 801035fb: c3 ret 801035fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103600 <mycpu>: { 80103600: 55 push %ebp 80103601: 89 e5 mov %esp,%ebp 80103603: 56 push %esi 80103604: 53 push %ebx 80103605: 83 ec 10 sub $0x10,%esp asm volatile("pushfl; popl %0" : "=r" (eflags)); 80103608: 9c pushf 80103609: 58 pop %eax if(readeflags()&FL_IF) 8010360a: f6 c4 02 test $0x2,%ah 8010360d: 75 57 jne 80103666 <mycpu+0x66> apicid = lapicid(); 8010360f: e8 4c f1 ff ff call 80102760 <lapicid> for (i = 0; i < ncpu; ++i) { 80103614: 8b 35 00 2d 11 80 mov 0x80112d00,%esi 8010361a: 85 f6 test %esi,%esi 8010361c: 7e 3c jle 8010365a <mycpu+0x5a> if (cpus[i].apicid == apicid) 8010361e: 0f b6 15 80 27 11 80 movzbl 0x80112780,%edx 80103625: 39 c2 cmp %eax,%edx 80103627: 74 2d je 80103656 <mycpu+0x56> 80103629: b9 30 28 11 80 mov $0x80112830,%ecx for (i = 0; i < ncpu; ++i) { 8010362e: 31 d2 xor %edx,%edx 80103630: 83 c2 01 add $0x1,%edx 80103633: 39 f2 cmp %esi,%edx 80103635: 74 23 je 8010365a <mycpu+0x5a> if (cpus[i].apicid == apicid) 80103637: 0f b6 19 movzbl (%ecx),%ebx 8010363a: 81 c1 b0 00 00 00 add $0xb0,%ecx 80103640: 39 c3 cmp %eax,%ebx 80103642: 75 ec jne 80103630 <mycpu+0x30> return &cpus[i]; 80103644: 69 c2 b0 00 00 00 imul $0xb0,%edx,%eax } 8010364a: 83 c4 10 add $0x10,%esp 8010364d: 5b pop %ebx 8010364e: 5e pop %esi 8010364f: 5d pop %ebp return &cpus[i]; 80103650: 05 80 27 11 80 add $0x80112780,%eax } 80103655: c3 ret for (i = 0; i < ncpu; ++i) { 80103656: 31 d2 xor %edx,%edx 80103658: eb ea jmp 80103644 <mycpu+0x44> panic("unknown apicid\n"); 8010365a: c7 04 24 3c 71 10 80 movl $0x8010713c,(%esp) 80103661: e8 fa cc ff ff call 80100360 <panic> panic("mycpu called with interrupts enabled\n"); 80103666: c7 04 24 18 72 10 80 movl $0x80107218,(%esp) 8010366d: e8 ee cc ff ff call 80100360 <panic> 80103672: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80103679: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103680 <cpuid>: cpuid() { 80103680: 55 push %ebp 80103681: 89 e5 mov %esp,%ebp 80103683: 83 ec 08 sub $0x8,%esp return mycpu()-cpus; 80103686: e8 75 ff ff ff call 80103600 <mycpu> } 8010368b: c9 leave return mycpu()-cpus; 8010368c: 2d 80 27 11 80 sub $0x80112780,%eax 80103691: c1 f8 04 sar $0x4,%eax 80103694: 69 c0 a3 8b 2e ba imul $0xba2e8ba3,%eax,%eax } 8010369a: c3 ret 8010369b: 90 nop 8010369c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801036a0 <myproc>: myproc(void) { 801036a0: 55 push %ebp 801036a1: 89 e5 mov %esp,%ebp 801036a3: 53 push %ebx 801036a4: 83 ec 04 sub $0x4,%esp pushcli(); 801036a7: e8 44 0a 00 00 call 801040f0 <pushcli> c = mycpu(); 801036ac: e8 4f ff ff ff call 80103600 <mycpu> p = c->proc; 801036b1: 8b 98 ac 00 00 00 mov 0xac(%eax),%ebx popcli(); 801036b7: e8 74 0a 00 00 call 80104130 <popcli> } 801036bc: 83 c4 04 add $0x4,%esp 801036bf: 89 d8 mov %ebx,%eax 801036c1: 5b pop %ebx 801036c2: 5d pop %ebp 801036c3: c3 ret 801036c4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801036ca: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 801036d0 <userinit>: { 801036d0: 55 push %ebp 801036d1: 89 e5 mov %esp,%ebp 801036d3: 53 push %ebx 801036d4: 83 ec 14 sub $0x14,%esp p = allocproc(); 801036d7: e8 e4 fd ff ff call 801034c0 <allocproc> 801036dc: 89 c3 mov %eax,%ebx initproc = p; 801036de: a3 b8 a5 10 80 mov %eax,0x8010a5b8 if((p->pgdir = setupkvm()) == 0) 801036e3: e8 58 32 00 00 call 80106940 <setupkvm> 801036e8: 85 c0 test %eax,%eax 801036ea: 89 43 04 mov %eax,0x4(%ebx) 801036ed: 0f 84 d4 00 00 00 je 801037c7 <userinit+0xf7> inituvm(p->pgdir, _binary_initcode_start, (int)_binary_initcode_size); 801036f3: 89 04 24 mov %eax,(%esp) 801036f6: c7 44 24 08 2c 00 00 movl $0x2c,0x8(%esp) 801036fd: 00 801036fe: c7 44 24 04 60 a4 10 movl $0x8010a460,0x4(%esp) 80103705: 80 80103706: e8 65 2f 00 00 call 80106670 <inituvm> p->sz = PGSIZE; 8010370b: c7 03 00 10 00 00 movl $0x1000,(%ebx) memset(p->tf, 0, sizeof(*p->tf)); 80103711: c7 44 24 08 4c 00 00 movl $0x4c,0x8(%esp) 80103718: 00 80103719: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80103720: 00 80103721: 8b 43 18 mov 0x18(%ebx),%eax 80103724: 89 04 24 mov %eax,(%esp) 80103727: e8 74 0b 00 00 call 801042a0 <memset> p->tf->cs = (SEG_UCODE << 3) | DPL_USER; 8010372c: 8b 43 18 mov 0x18(%ebx),%eax 8010372f: ba 1b 00 00 00 mov $0x1b,%edx p->tf->ds = (SEG_UDATA << 3) | DPL_USER; 80103734: b9 23 00 00 00 mov $0x23,%ecx p->tf->cs = (SEG_UCODE << 3) | DPL_USER; 80103739: 66 89 50 3c mov %dx,0x3c(%eax) p->tf->ds = (SEG_UDATA << 3) | DPL_USER; 8010373d: 8b 43 18 mov 0x18(%ebx),%eax 80103740: 66 89 48 2c mov %cx,0x2c(%eax) p->tf->es = p->tf->ds; 80103744: 8b 43 18 mov 0x18(%ebx),%eax 80103747: 0f b7 50 2c movzwl 0x2c(%eax),%edx 8010374b: 66 89 50 28 mov %dx,0x28(%eax) p->tf->ss = p->tf->ds; 8010374f: 8b 43 18 mov 0x18(%ebx),%eax 80103752: 0f b7 50 2c movzwl 0x2c(%eax),%edx 80103756: 66 89 50 48 mov %dx,0x48(%eax) p->tf->eflags = FL_IF; 8010375a: 8b 43 18 mov 0x18(%ebx),%eax 8010375d: c7 40 40 00 02 00 00 movl $0x200,0x40(%eax) p->tf->esp = PGSIZE; 80103764: 8b 43 18 mov 0x18(%ebx),%eax 80103767: c7 40 44 00 10 00 00 movl $0x1000,0x44(%eax) p->tf->eip = 0; // beginning of initcode.S 8010376e: 8b 43 18 mov 0x18(%ebx),%eax 80103771: c7 40 38 00 00 00 00 movl $0x0,0x38(%eax) safestrcpy(p->name, "initcode", sizeof(p->name)); 80103778: 8d 43 6c lea 0x6c(%ebx),%eax 8010377b: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 80103782: 00 80103783: c7 44 24 04 65 71 10 movl $0x80107165,0x4(%esp) 8010378a: 80 8010378b: 89 04 24 mov %eax,(%esp) 8010378e: e8 ed 0c 00 00 call 80104480 <safestrcpy> p->cwd = namei("/"); 80103793: c7 04 24 6e 71 10 80 movl $0x8010716e,(%esp) 8010379a: e8 61 e7 ff ff call 80101f00 <namei> 8010379f: 89 43 68 mov %eax,0x68(%ebx) acquire(&ptable.lock); 801037a2: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 801037a9: e8 32 0a 00 00 call 801041e0 <acquire> p->state = RUNNABLE; 801037ae: c7 43 0c 03 00 00 00 movl $0x3,0xc(%ebx) release(&ptable.lock); 801037b5: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 801037bc: e8 8f 0a 00 00 call 80104250 <release> } 801037c1: 83 c4 14 add $0x14,%esp 801037c4: 5b pop %ebx 801037c5: 5d pop %ebp 801037c6: c3 ret panic("userinit: out of memory?"); 801037c7: c7 04 24 4c 71 10 80 movl $0x8010714c,(%esp) 801037ce: e8 8d cb ff ff call 80100360 <panic> 801037d3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801037d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801037e0 <growproc>: { 801037e0: 55 push %ebp 801037e1: 89 e5 mov %esp,%ebp 801037e3: 56 push %esi 801037e4: 53 push %ebx 801037e5: 83 ec 10 sub $0x10,%esp 801037e8: 8b 75 08 mov 0x8(%ebp),%esi struct proc *curproc = myproc(); 801037eb: e8 b0 fe ff ff call 801036a0 <myproc> if(n > 0){ 801037f0: 83 fe 00 cmp $0x0,%esi struct proc *curproc = myproc(); 801037f3: 89 c3 mov %eax,%ebx sz = curproc->sz; 801037f5: 8b 00 mov (%eax),%eax if(n > 0){ 801037f7: 7e 2f jle 80103828 <growproc+0x48> if((sz = allocuvm(curproc->pgdir, sz, sz + n)) == 0) 801037f9: 01 c6 add %eax,%esi 801037fb: 89 74 24 08 mov %esi,0x8(%esp) 801037ff: 89 44 24 04 mov %eax,0x4(%esp) 80103803: 8b 43 04 mov 0x4(%ebx),%eax 80103806: 89 04 24 mov %eax,(%esp) 80103809: e8 a2 2f 00 00 call 801067b0 <allocuvm> 8010380e: 85 c0 test %eax,%eax 80103810: 74 36 je 80103848 <growproc+0x68> curproc->sz = sz; 80103812: 89 03 mov %eax,(%ebx) switchuvm(curproc); 80103814: 89 1c 24 mov %ebx,(%esp) 80103817: e8 44 2d 00 00 call 80106560 <switchuvm> return 0; 8010381c: 31 c0 xor %eax,%eax } 8010381e: 83 c4 10 add $0x10,%esp 80103821: 5b pop %ebx 80103822: 5e pop %esi 80103823: 5d pop %ebp 80103824: c3 ret 80103825: 8d 76 00 lea 0x0(%esi),%esi } else if(n < 0){ 80103828: 74 e8 je 80103812 <growproc+0x32> if((sz = deallocuvm(curproc->pgdir, sz, sz + n)) == 0) 8010382a: 01 c6 add %eax,%esi 8010382c: 89 74 24 08 mov %esi,0x8(%esp) 80103830: 89 44 24 04 mov %eax,0x4(%esp) 80103834: 8b 43 04 mov 0x4(%ebx),%eax 80103837: 89 04 24 mov %eax,(%esp) 8010383a: e8 61 30 00 00 call 801068a0 <deallocuvm> 8010383f: 85 c0 test %eax,%eax 80103841: 75 cf jne 80103812 <growproc+0x32> 80103843: 90 nop 80103844: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return -1; 80103848: b8 ff ff ff ff mov $0xffffffff,%eax 8010384d: eb cf jmp 8010381e <growproc+0x3e> 8010384f: 90 nop 80103850 <fork>: { 80103850: 55 push %ebp 80103851: 89 e5 mov %esp,%ebp 80103853: 57 push %edi 80103854: 56 push %esi 80103855: 53 push %ebx 80103856: 83 ec 1c sub $0x1c,%esp struct proc *curproc = myproc(); 80103859: e8 42 fe ff ff call 801036a0 <myproc> 8010385e: 89 c3 mov %eax,%ebx if((np = allocproc()) == 0){ 80103860: e8 5b fc ff ff call 801034c0 <allocproc> 80103865: 85 c0 test %eax,%eax 80103867: 89 c7 mov %eax,%edi 80103869: 89 45 e4 mov %eax,-0x1c(%ebp) 8010386c: 0f 84 bc 00 00 00 je 8010392e <fork+0xde> if((np->pgdir = copyuvm(curproc->pgdir, curproc->sz)) == 0){ 80103872: 8b 03 mov (%ebx),%eax 80103874: 89 44 24 04 mov %eax,0x4(%esp) 80103878: 8b 43 04 mov 0x4(%ebx),%eax 8010387b: 89 04 24 mov %eax,(%esp) 8010387e: e8 9d 31 00 00 call 80106a20 <copyuvm> 80103883: 85 c0 test %eax,%eax 80103885: 89 47 04 mov %eax,0x4(%edi) 80103888: 0f 84 a7 00 00 00 je 80103935 <fork+0xe5> np->sz = curproc->sz; 8010388e: 8b 03 mov (%ebx),%eax 80103890: 8b 4d e4 mov -0x1c(%ebp),%ecx 80103893: 89 01 mov %eax,(%ecx) *np->tf = *curproc->tf; 80103895: 8b 79 18 mov 0x18(%ecx),%edi 80103898: 89 c8 mov %ecx,%eax np->parent = curproc; 8010389a: 89 59 14 mov %ebx,0x14(%ecx) *np->tf = *curproc->tf; 8010389d: 8b 73 18 mov 0x18(%ebx),%esi 801038a0: b9 13 00 00 00 mov $0x13,%ecx 801038a5: f3 a5 rep movsl %ds:(%esi),%es:(%edi) for(i = 0; i < NOFILE; i++) 801038a7: 31 f6 xor %esi,%esi np->tf->eax = 0; 801038a9: 8b 40 18 mov 0x18(%eax),%eax 801038ac: c7 40 1c 00 00 00 00 movl $0x0,0x1c(%eax) 801038b3: 90 nop 801038b4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(curproc->ofile[i]) 801038b8: 8b 44 b3 28 mov 0x28(%ebx,%esi,4),%eax 801038bc: 85 c0 test %eax,%eax 801038be: 74 0f je 801038cf <fork+0x7f> np->ofile[i] = filedup(curproc->ofile[i]); 801038c0: 89 04 24 mov %eax,(%esp) 801038c3: e8 18 d5 ff ff call 80100de0 <filedup> 801038c8: 8b 55 e4 mov -0x1c(%ebp),%edx 801038cb: 89 44 b2 28 mov %eax,0x28(%edx,%esi,4) for(i = 0; i < NOFILE; i++) 801038cf: 83 c6 01 add $0x1,%esi 801038d2: 83 fe 10 cmp $0x10,%esi 801038d5: 75 e1 jne 801038b8 <fork+0x68> np->cwd = idup(curproc->cwd); 801038d7: 8b 43 68 mov 0x68(%ebx),%eax safestrcpy(np->name, curproc->name, sizeof(curproc->name)); 801038da: 83 c3 6c add $0x6c,%ebx np->cwd = idup(curproc->cwd); 801038dd: 89 04 24 mov %eax,(%esp) 801038e0: e8 9b dd ff ff call 80101680 <idup> 801038e5: 8b 7d e4 mov -0x1c(%ebp),%edi 801038e8: 89 47 68 mov %eax,0x68(%edi) safestrcpy(np->name, curproc->name, sizeof(curproc->name)); 801038eb: 8d 47 6c lea 0x6c(%edi),%eax 801038ee: 89 5c 24 04 mov %ebx,0x4(%esp) 801038f2: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 801038f9: 00 801038fa: 89 04 24 mov %eax,(%esp) 801038fd: e8 7e 0b 00 00 call 80104480 <safestrcpy> pid = np->pid; 80103902: 8b 5f 10 mov 0x10(%edi),%ebx acquire(&ptable.lock); 80103905: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 8010390c: e8 cf 08 00 00 call 801041e0 <acquire> np->state = RUNNABLE; 80103911: c7 47 0c 03 00 00 00 movl $0x3,0xc(%edi) release(&ptable.lock); 80103918: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 8010391f: e8 2c 09 00 00 call 80104250 <release> return pid; 80103924: 89 d8 mov %ebx,%eax } 80103926: 83 c4 1c add $0x1c,%esp 80103929: 5b pop %ebx 8010392a: 5e pop %esi 8010392b: 5f pop %edi 8010392c: 5d pop %ebp 8010392d: c3 ret return -1; 8010392e: b8 ff ff ff ff mov $0xffffffff,%eax 80103933: eb f1 jmp 80103926 <fork+0xd6> kfree(np->kstack); 80103935: 8b 7d e4 mov -0x1c(%ebp),%edi 80103938: 8b 47 08 mov 0x8(%edi),%eax 8010393b: 89 04 24 mov %eax,(%esp) 8010393e: e8 ad e9 ff ff call 801022f0 <kfree> return -1; 80103943: b8 ff ff ff ff mov $0xffffffff,%eax np->kstack = 0; 80103948: c7 47 08 00 00 00 00 movl $0x0,0x8(%edi) np->state = UNUSED; 8010394f: c7 47 0c 00 00 00 00 movl $0x0,0xc(%edi) return -1; 80103956: eb ce jmp 80103926 <fork+0xd6> 80103958: 90 nop 80103959: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80103960 <scheduler>: { 80103960: 55 push %ebp 80103961: 89 e5 mov %esp,%ebp 80103963: 57 push %edi 80103964: 56 push %esi 80103965: 53 push %ebx 80103966: 83 ec 1c sub $0x1c,%esp struct cpu *c = mycpu(); 80103969: e8 92 fc ff ff call 80103600 <mycpu> 8010396e: 89 c6 mov %eax,%esi c->proc = 0; 80103970: c7 80 ac 00 00 00 00 movl $0x0,0xac(%eax) 80103977: 00 00 00 8010397a: 8d 78 04 lea 0x4(%eax),%edi 8010397d: 8d 76 00 lea 0x0(%esi),%esi asm volatile("sti"); 80103980: fb sti acquire(&ptable.lock); 80103981: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103988: bb 54 2d 11 80 mov $0x80112d54,%ebx acquire(&ptable.lock); 8010398d: e8 4e 08 00 00 call 801041e0 <acquire> 80103992: eb 0f jmp 801039a3 <scheduler+0x43> 80103994: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103998: 83 c3 7c add $0x7c,%ebx 8010399b: 81 fb 54 4c 11 80 cmp $0x80114c54,%ebx 801039a1: 74 45 je 801039e8 <scheduler+0x88> if(p->state != RUNNABLE) 801039a3: 83 7b 0c 03 cmpl $0x3,0xc(%ebx) 801039a7: 75 ef jne 80103998 <scheduler+0x38> c->proc = p; 801039a9: 89 9e ac 00 00 00 mov %ebx,0xac(%esi) switchuvm(p); 801039af: 89 1c 24 mov %ebx,(%esp) for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 801039b2: 83 c3 7c add $0x7c,%ebx switchuvm(p); 801039b5: e8 a6 2b 00 00 call 80106560 <switchuvm> swtch(&(c->scheduler), p->context); 801039ba: 8b 43 a0 mov -0x60(%ebx),%eax p->state = RUNNING; 801039bd: c7 43 90 04 00 00 00 movl $0x4,-0x70(%ebx) swtch(&(c->scheduler), p->context); 801039c4: 89 3c 24 mov %edi,(%esp) 801039c7: 89 44 24 04 mov %eax,0x4(%esp) 801039cb: e8 0b 0b 00 00 call 801044db <swtch> switchkvm(); 801039d0: e8 6b 2b 00 00 call 80106540 <switchkvm> for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 801039d5: 81 fb 54 4c 11 80 cmp $0x80114c54,%ebx c->proc = 0; 801039db: c7 86 ac 00 00 00 00 movl $0x0,0xac(%esi) 801039e2: 00 00 00 for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 801039e5: 75 bc jne 801039a3 <scheduler+0x43> 801039e7: 90 nop release(&ptable.lock); 801039e8: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 801039ef: e8 5c 08 00 00 call 80104250 <release> } 801039f4: eb 8a jmp 80103980 <scheduler+0x20> 801039f6: 8d 76 00 lea 0x0(%esi),%esi 801039f9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103a00 <sched>: { 80103a00: 55 push %ebp 80103a01: 89 e5 mov %esp,%ebp 80103a03: 56 push %esi 80103a04: 53 push %ebx 80103a05: 83 ec 10 sub $0x10,%esp struct proc *p = myproc(); 80103a08: e8 93 fc ff ff call 801036a0 <myproc> if(!holding(&ptable.lock)) 80103a0d: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) struct proc *p = myproc(); 80103a14: 89 c3 mov %eax,%ebx if(!holding(&ptable.lock)) 80103a16: e8 85 07 00 00 call 801041a0 <holding> 80103a1b: 85 c0 test %eax,%eax 80103a1d: 74 4f je 80103a6e <sched+0x6e> if(mycpu()->ncli != 1) 80103a1f: e8 dc fb ff ff call 80103600 <mycpu> 80103a24: 83 b8 a4 00 00 00 01 cmpl $0x1,0xa4(%eax) 80103a2b: 75 65 jne 80103a92 <sched+0x92> if(p->state == RUNNING) 80103a2d: 83 7b 0c 04 cmpl $0x4,0xc(%ebx) 80103a31: 74 53 je 80103a86 <sched+0x86> asm volatile("pushfl; popl %0" : "=r" (eflags)); 80103a33: 9c pushf 80103a34: 58 pop %eax if(readeflags()&FL_IF) 80103a35: f6 c4 02 test $0x2,%ah 80103a38: 75 40 jne 80103a7a <sched+0x7a> intena = mycpu()->intena; 80103a3a: e8 c1 fb ff ff call 80103600 <mycpu> swtch(&p->context, mycpu()->scheduler); 80103a3f: 83 c3 1c add $0x1c,%ebx intena = mycpu()->intena; 80103a42: 8b b0 a8 00 00 00 mov 0xa8(%eax),%esi swtch(&p->context, mycpu()->scheduler); 80103a48: e8 b3 fb ff ff call 80103600 <mycpu> 80103a4d: 8b 40 04 mov 0x4(%eax),%eax 80103a50: 89 1c 24 mov %ebx,(%esp) 80103a53: 89 44 24 04 mov %eax,0x4(%esp) 80103a57: e8 7f 0a 00 00 call 801044db <swtch> mycpu()->intena = intena; 80103a5c: e8 9f fb ff ff call 80103600 <mycpu> 80103a61: 89 b0 a8 00 00 00 mov %esi,0xa8(%eax) } 80103a67: 83 c4 10 add $0x10,%esp 80103a6a: 5b pop %ebx 80103a6b: 5e pop %esi 80103a6c: 5d pop %ebp 80103a6d: c3 ret panic("sched ptable.lock"); 80103a6e: c7 04 24 70 71 10 80 movl $0x80107170,(%esp) 80103a75: e8 e6 c8 ff ff call 80100360 <panic> panic("sched interruptible"); 80103a7a: c7 04 24 9c 71 10 80 movl $0x8010719c,(%esp) 80103a81: e8 da c8 ff ff call 80100360 <panic> panic("sched running"); 80103a86: c7 04 24 8e 71 10 80 movl $0x8010718e,(%esp) 80103a8d: e8 ce c8 ff ff call 80100360 <panic> panic("sched locks"); 80103a92: c7 04 24 82 71 10 80 movl $0x80107182,(%esp) 80103a99: e8 c2 c8 ff ff call 80100360 <panic> 80103a9e: 66 90 xchg %ax,%ax 80103aa0 <exit>: { 80103aa0: 55 push %ebp 80103aa1: 89 e5 mov %esp,%ebp 80103aa3: 56 push %esi if(curproc == initproc) 80103aa4: 31 f6 xor %esi,%esi { 80103aa6: 53 push %ebx 80103aa7: 83 ec 10 sub $0x10,%esp struct proc *curproc = myproc(); 80103aaa: e8 f1 fb ff ff call 801036a0 <myproc> if(curproc == initproc) 80103aaf: 3b 05 b8 a5 10 80 cmp 0x8010a5b8,%eax struct proc *curproc = myproc(); 80103ab5: 89 c3 mov %eax,%ebx if(curproc == initproc) 80103ab7: 0f 84 ea 00 00 00 je 80103ba7 <exit+0x107> 80103abd: 8d 76 00 lea 0x0(%esi),%esi if(curproc->ofile[fd]){ 80103ac0: 8b 44 b3 28 mov 0x28(%ebx,%esi,4),%eax 80103ac4: 85 c0 test %eax,%eax 80103ac6: 74 10 je 80103ad8 <exit+0x38> fileclose(curproc->ofile[fd]); 80103ac8: 89 04 24 mov %eax,(%esp) 80103acb: e8 60 d3 ff ff call 80100e30 <fileclose> curproc->ofile[fd] = 0; 80103ad0: c7 44 b3 28 00 00 00 movl $0x0,0x28(%ebx,%esi,4) 80103ad7: 00 for(fd = 0; fd < NOFILE; fd++){ 80103ad8: 83 c6 01 add $0x1,%esi 80103adb: 83 fe 10 cmp $0x10,%esi 80103ade: 75 e0 jne 80103ac0 <exit+0x20> begin_op(); 80103ae0: e8 2b f0 ff ff call 80102b10 <begin_op> iput(curproc->cwd); 80103ae5: 8b 43 68 mov 0x68(%ebx),%eax 80103ae8: 89 04 24 mov %eax,(%esp) 80103aeb: e8 e0 dc ff ff call 801017d0 <iput> end_op(); 80103af0: e8 8b f0 ff ff call 80102b80 <end_op> curproc->cwd = 0; 80103af5: c7 43 68 00 00 00 00 movl $0x0,0x68(%ebx) acquire(&ptable.lock); 80103afc: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103b03: e8 d8 06 00 00 call 801041e0 <acquire> wakeup1(curproc->parent); 80103b08: 8b 43 14 mov 0x14(%ebx),%eax static void wakeup1(void *chan) { struct proc *p; for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80103b0b: ba 54 2d 11 80 mov $0x80112d54,%edx 80103b10: eb 11 jmp 80103b23 <exit+0x83> 80103b12: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80103b18: 83 c2 7c add $0x7c,%edx 80103b1b: 81 fa 54 4c 11 80 cmp $0x80114c54,%edx 80103b21: 74 1d je 80103b40 <exit+0xa0> if(p->state == SLEEPING && p->chan == chan) 80103b23: 83 7a 0c 02 cmpl $0x2,0xc(%edx) 80103b27: 75 ef jne 80103b18 <exit+0x78> 80103b29: 3b 42 20 cmp 0x20(%edx),%eax 80103b2c: 75 ea jne 80103b18 <exit+0x78> p->state = RUNNABLE; 80103b2e: c7 42 0c 03 00 00 00 movl $0x3,0xc(%edx) for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80103b35: 83 c2 7c add $0x7c,%edx 80103b38: 81 fa 54 4c 11 80 cmp $0x80114c54,%edx 80103b3e: 75 e3 jne 80103b23 <exit+0x83> p->parent = initproc; 80103b40: a1 b8 a5 10 80 mov 0x8010a5b8,%eax 80103b45: b9 54 2d 11 80 mov $0x80112d54,%ecx 80103b4a: eb 0f jmp 80103b5b <exit+0xbb> 80103b4c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103b50: 83 c1 7c add $0x7c,%ecx 80103b53: 81 f9 54 4c 11 80 cmp $0x80114c54,%ecx 80103b59: 74 34 je 80103b8f <exit+0xef> if(p->parent == curproc){ 80103b5b: 39 59 14 cmp %ebx,0x14(%ecx) 80103b5e: 75 f0 jne 80103b50 <exit+0xb0> if(p->state == ZOMBIE) 80103b60: 83 79 0c 05 cmpl $0x5,0xc(%ecx) p->parent = initproc; 80103b64: 89 41 14 mov %eax,0x14(%ecx) if(p->state == ZOMBIE) 80103b67: 75 e7 jne 80103b50 <exit+0xb0> 80103b69: ba 54 2d 11 80 mov $0x80112d54,%edx 80103b6e: eb 0b jmp 80103b7b <exit+0xdb> for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80103b70: 83 c2 7c add $0x7c,%edx 80103b73: 81 fa 54 4c 11 80 cmp $0x80114c54,%edx 80103b79: 74 d5 je 80103b50 <exit+0xb0> if(p->state == SLEEPING && p->chan == chan) 80103b7b: 83 7a 0c 02 cmpl $0x2,0xc(%edx) 80103b7f: 75 ef jne 80103b70 <exit+0xd0> 80103b81: 3b 42 20 cmp 0x20(%edx),%eax 80103b84: 75 ea jne 80103b70 <exit+0xd0> p->state = RUNNABLE; 80103b86: c7 42 0c 03 00 00 00 movl $0x3,0xc(%edx) 80103b8d: eb e1 jmp 80103b70 <exit+0xd0> curproc->state = ZOMBIE; 80103b8f: c7 43 0c 05 00 00 00 movl $0x5,0xc(%ebx) sched(); 80103b96: e8 65 fe ff ff call 80103a00 <sched> panic("zombie exit"); 80103b9b: c7 04 24 bd 71 10 80 movl $0x801071bd,(%esp) 80103ba2: e8 b9 c7 ff ff call 80100360 <panic> panic("init exiting"); 80103ba7: c7 04 24 b0 71 10 80 movl $0x801071b0,(%esp) 80103bae: e8 ad c7 ff ff call 80100360 <panic> 80103bb3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80103bb9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103bc0 <yield>: { 80103bc0: 55 push %ebp 80103bc1: 89 e5 mov %esp,%ebp 80103bc3: 83 ec 18 sub $0x18,%esp acquire(&ptable.lock); //DOC: yieldlock 80103bc6: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103bcd: e8 0e 06 00 00 call 801041e0 <acquire> myproc()->state = RUNNABLE; 80103bd2: e8 c9 fa ff ff call 801036a0 <myproc> 80103bd7: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) sched(); 80103bde: e8 1d fe ff ff call 80103a00 <sched> release(&ptable.lock); 80103be3: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103bea: e8 61 06 00 00 call 80104250 <release> } 80103bef: c9 leave 80103bf0: c3 ret 80103bf1: eb 0d jmp 80103c00 <sleep> 80103bf3: 90 nop 80103bf4: 90 nop 80103bf5: 90 nop 80103bf6: 90 nop 80103bf7: 90 nop 80103bf8: 90 nop 80103bf9: 90 nop 80103bfa: 90 nop 80103bfb: 90 nop 80103bfc: 90 nop 80103bfd: 90 nop 80103bfe: 90 nop 80103bff: 90 nop 80103c00 <sleep>: { 80103c00: 55 push %ebp 80103c01: 89 e5 mov %esp,%ebp 80103c03: 57 push %edi 80103c04: 56 push %esi 80103c05: 53 push %ebx 80103c06: 83 ec 1c sub $0x1c,%esp 80103c09: 8b 7d 08 mov 0x8(%ebp),%edi 80103c0c: 8b 75 0c mov 0xc(%ebp),%esi struct proc *p = myproc(); 80103c0f: e8 8c fa ff ff call 801036a0 <myproc> if(p == 0) 80103c14: 85 c0 test %eax,%eax struct proc *p = myproc(); 80103c16: 89 c3 mov %eax,%ebx if(p == 0) 80103c18: 0f 84 7c 00 00 00 je 80103c9a <sleep+0x9a> if(lk == 0) 80103c1e: 85 f6 test %esi,%esi 80103c20: 74 6c je 80103c8e <sleep+0x8e> if(lk != &ptable.lock){ //DOC: sleeplock0 80103c22: 81 fe 20 2d 11 80 cmp $0x80112d20,%esi 80103c28: 74 46 je 80103c70 <sleep+0x70> acquire(&ptable.lock); //DOC: sleeplock1 80103c2a: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103c31: e8 aa 05 00 00 call 801041e0 <acquire> release(lk); 80103c36: 89 34 24 mov %esi,(%esp) 80103c39: e8 12 06 00 00 call 80104250 <release> p->chan = chan; 80103c3e: 89 7b 20 mov %edi,0x20(%ebx) p->state = SLEEPING; 80103c41: c7 43 0c 02 00 00 00 movl $0x2,0xc(%ebx) sched(); 80103c48: e8 b3 fd ff ff call 80103a00 <sched> p->chan = 0; 80103c4d: c7 43 20 00 00 00 00 movl $0x0,0x20(%ebx) release(&ptable.lock); 80103c54: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103c5b: e8 f0 05 00 00 call 80104250 <release> acquire(lk); 80103c60: 89 75 08 mov %esi,0x8(%ebp) } 80103c63: 83 c4 1c add $0x1c,%esp 80103c66: 5b pop %ebx 80103c67: 5e pop %esi 80103c68: 5f pop %edi 80103c69: 5d pop %ebp acquire(lk); 80103c6a: e9 71 05 00 00 jmp 801041e0 <acquire> 80103c6f: 90 nop p->chan = chan; 80103c70: 89 78 20 mov %edi,0x20(%eax) p->state = SLEEPING; 80103c73: c7 40 0c 02 00 00 00 movl $0x2,0xc(%eax) sched(); 80103c7a: e8 81 fd ff ff call 80103a00 <sched> p->chan = 0; 80103c7f: c7 43 20 00 00 00 00 movl $0x0,0x20(%ebx) } 80103c86: 83 c4 1c add $0x1c,%esp 80103c89: 5b pop %ebx 80103c8a: 5e pop %esi 80103c8b: 5f pop %edi 80103c8c: 5d pop %ebp 80103c8d: c3 ret panic("sleep without lk"); 80103c8e: c7 04 24 cf 71 10 80 movl $0x801071cf,(%esp) 80103c95: e8 c6 c6 ff ff call 80100360 <panic> panic("sleep"); 80103c9a: c7 04 24 c9 71 10 80 movl $0x801071c9,(%esp) 80103ca1: e8 ba c6 ff ff call 80100360 <panic> 80103ca6: 8d 76 00 lea 0x0(%esi),%esi 80103ca9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103cb0 <wait>: { 80103cb0: 55 push %ebp 80103cb1: 89 e5 mov %esp,%ebp 80103cb3: 56 push %esi 80103cb4: 53 push %ebx 80103cb5: 83 ec 10 sub $0x10,%esp struct proc *curproc = myproc(); 80103cb8: e8 e3 f9 ff ff call 801036a0 <myproc> acquire(&ptable.lock); 80103cbd: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) struct proc *curproc = myproc(); 80103cc4: 89 c6 mov %eax,%esi acquire(&ptable.lock); 80103cc6: e8 15 05 00 00 call 801041e0 <acquire> havekids = 0; 80103ccb: 31 c0 xor %eax,%eax for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103ccd: bb 54 2d 11 80 mov $0x80112d54,%ebx 80103cd2: eb 0f jmp 80103ce3 <wait+0x33> 80103cd4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80103cd8: 83 c3 7c add $0x7c,%ebx 80103cdb: 81 fb 54 4c 11 80 cmp $0x80114c54,%ebx 80103ce1: 74 1d je 80103d00 <wait+0x50> if(p->parent != curproc) 80103ce3: 39 73 14 cmp %esi,0x14(%ebx) 80103ce6: 75 f0 jne 80103cd8 <wait+0x28> if(p->state == ZOMBIE){ 80103ce8: 83 7b 0c 05 cmpl $0x5,0xc(%ebx) 80103cec: 74 2f je 80103d1d <wait+0x6d> for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103cee: 83 c3 7c add $0x7c,%ebx havekids = 1; 80103cf1: b8 01 00 00 00 mov $0x1,%eax for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103cf6: 81 fb 54 4c 11 80 cmp $0x80114c54,%ebx 80103cfc: 75 e5 jne 80103ce3 <wait+0x33> 80103cfe: 66 90 xchg %ax,%ax if(!havekids || curproc->killed){ 80103d00: 85 c0 test %eax,%eax 80103d02: 74 6e je 80103d72 <wait+0xc2> 80103d04: 8b 46 24 mov 0x24(%esi),%eax 80103d07: 85 c0 test %eax,%eax 80103d09: 75 67 jne 80103d72 <wait+0xc2> sleep(curproc, &ptable.lock); //DOC: wait-sleep 80103d0b: c7 44 24 04 20 2d 11 movl $0x80112d20,0x4(%esp) 80103d12: 80 80103d13: 89 34 24 mov %esi,(%esp) 80103d16: e8 e5 fe ff ff call 80103c00 <sleep> } 80103d1b: eb ae jmp 80103ccb <wait+0x1b> kfree(p->kstack); 80103d1d: 8b 43 08 mov 0x8(%ebx),%eax pid = p->pid; 80103d20: 8b 73 10 mov 0x10(%ebx),%esi kfree(p->kstack); 80103d23: 89 04 24 mov %eax,(%esp) 80103d26: e8 c5 e5 ff ff call 801022f0 <kfree> freevm(p->pgdir); 80103d2b: 8b 43 04 mov 0x4(%ebx),%eax p->kstack = 0; 80103d2e: c7 43 08 00 00 00 00 movl $0x0,0x8(%ebx) freevm(p->pgdir); 80103d35: 89 04 24 mov %eax,(%esp) 80103d38: e8 83 2b 00 00 call 801068c0 <freevm> release(&ptable.lock); 80103d3d: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) p->pid = 0; 80103d44: c7 43 10 00 00 00 00 movl $0x0,0x10(%ebx) p->parent = 0; 80103d4b: c7 43 14 00 00 00 00 movl $0x0,0x14(%ebx) p->name[0] = 0; 80103d52: c6 43 6c 00 movb $0x0,0x6c(%ebx) p->killed = 0; 80103d56: c7 43 24 00 00 00 00 movl $0x0,0x24(%ebx) p->state = UNUSED; 80103d5d: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx) release(&ptable.lock); 80103d64: e8 e7 04 00 00 call 80104250 <release> } 80103d69: 83 c4 10 add $0x10,%esp return pid; 80103d6c: 89 f0 mov %esi,%eax } 80103d6e: 5b pop %ebx 80103d6f: 5e pop %esi 80103d70: 5d pop %ebp 80103d71: c3 ret release(&ptable.lock); 80103d72: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103d79: e8 d2 04 00 00 call 80104250 <release> } 80103d7e: 83 c4 10 add $0x10,%esp return -1; 80103d81: b8 ff ff ff ff mov $0xffffffff,%eax } 80103d86: 5b pop %ebx 80103d87: 5e pop %esi 80103d88: 5d pop %ebp 80103d89: c3 ret 80103d8a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80103d90 <wakeup>: } // Wake up all processes sleeping on chan. void wakeup(void *chan) { 80103d90: 55 push %ebp 80103d91: 89 e5 mov %esp,%ebp 80103d93: 53 push %ebx 80103d94: 83 ec 14 sub $0x14,%esp 80103d97: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&ptable.lock); 80103d9a: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103da1: e8 3a 04 00 00 call 801041e0 <acquire> for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80103da6: b8 54 2d 11 80 mov $0x80112d54,%eax 80103dab: eb 0d jmp 80103dba <wakeup+0x2a> 80103dad: 8d 76 00 lea 0x0(%esi),%esi 80103db0: 83 c0 7c add $0x7c,%eax 80103db3: 3d 54 4c 11 80 cmp $0x80114c54,%eax 80103db8: 74 1e je 80103dd8 <wakeup+0x48> if(p->state == SLEEPING && p->chan == chan) 80103dba: 83 78 0c 02 cmpl $0x2,0xc(%eax) 80103dbe: 75 f0 jne 80103db0 <wakeup+0x20> 80103dc0: 3b 58 20 cmp 0x20(%eax),%ebx 80103dc3: 75 eb jne 80103db0 <wakeup+0x20> p->state = RUNNABLE; 80103dc5: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) for(p = ptable.proc; p < &ptable.proc[NPROC]; p++) 80103dcc: 83 c0 7c add $0x7c,%eax 80103dcf: 3d 54 4c 11 80 cmp $0x80114c54,%eax 80103dd4: 75 e4 jne 80103dba <wakeup+0x2a> 80103dd6: 66 90 xchg %ax,%ax wakeup1(chan); release(&ptable.lock); 80103dd8: c7 45 08 20 2d 11 80 movl $0x80112d20,0x8(%ebp) } 80103ddf: 83 c4 14 add $0x14,%esp 80103de2: 5b pop %ebx 80103de3: 5d pop %ebp release(&ptable.lock); 80103de4: e9 67 04 00 00 jmp 80104250 <release> 80103de9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80103df0 <kill>: // Kill the process with the given pid. // Process won't exit until it returns // to user space (see trap in trap.c). int kill(int pid) { 80103df0: 55 push %ebp 80103df1: 89 e5 mov %esp,%ebp 80103df3: 53 push %ebx 80103df4: 83 ec 14 sub $0x14,%esp 80103df7: 8b 5d 08 mov 0x8(%ebp),%ebx struct proc *p; acquire(&ptable.lock); 80103dfa: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103e01: e8 da 03 00 00 call 801041e0 <acquire> for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103e06: b8 54 2d 11 80 mov $0x80112d54,%eax 80103e0b: eb 0d jmp 80103e1a <kill+0x2a> 80103e0d: 8d 76 00 lea 0x0(%esi),%esi 80103e10: 83 c0 7c add $0x7c,%eax 80103e13: 3d 54 4c 11 80 cmp $0x80114c54,%eax 80103e18: 74 36 je 80103e50 <kill+0x60> if(p->pid == pid){ 80103e1a: 39 58 10 cmp %ebx,0x10(%eax) 80103e1d: 75 f1 jne 80103e10 <kill+0x20> p->killed = 1; // Wake process from sleep if necessary. if(p->state == SLEEPING) 80103e1f: 83 78 0c 02 cmpl $0x2,0xc(%eax) p->killed = 1; 80103e23: c7 40 24 01 00 00 00 movl $0x1,0x24(%eax) if(p->state == SLEEPING) 80103e2a: 74 14 je 80103e40 <kill+0x50> p->state = RUNNABLE; release(&ptable.lock); 80103e2c: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103e33: e8 18 04 00 00 call 80104250 <release> return 0; } } release(&ptable.lock); return -1; } 80103e38: 83 c4 14 add $0x14,%esp return 0; 80103e3b: 31 c0 xor %eax,%eax } 80103e3d: 5b pop %ebx 80103e3e: 5d pop %ebp 80103e3f: c3 ret p->state = RUNNABLE; 80103e40: c7 40 0c 03 00 00 00 movl $0x3,0xc(%eax) 80103e47: eb e3 jmp 80103e2c <kill+0x3c> 80103e49: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi release(&ptable.lock); 80103e50: c7 04 24 20 2d 11 80 movl $0x80112d20,(%esp) 80103e57: e8 f4 03 00 00 call 80104250 <release> } 80103e5c: 83 c4 14 add $0x14,%esp return -1; 80103e5f: b8 ff ff ff ff mov $0xffffffff,%eax } 80103e64: 5b pop %ebx 80103e65: 5d pop %ebp 80103e66: c3 ret 80103e67: 89 f6 mov %esi,%esi 80103e69: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103e70 <procdump>: // Print a process listing to console. For debugging. // Runs when user types ^P on console. // No lock to avoid wedging a stuck machine further. void procdump(void) { 80103e70: 55 push %ebp 80103e71: 89 e5 mov %esp,%ebp 80103e73: 57 push %edi 80103e74: 56 push %esi 80103e75: 53 push %ebx 80103e76: bb c0 2d 11 80 mov $0x80112dc0,%ebx 80103e7b: 83 ec 4c sub $0x4c,%esp 80103e7e: 8d 75 e8 lea -0x18(%ebp),%esi 80103e81: eb 20 jmp 80103ea3 <procdump+0x33> 80103e83: 90 nop 80103e84: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(p->state == SLEEPING){ getcallerpcs((uint*)p->context->ebp+2, pc); for(i=0; i<10 && pc[i] != 0; i++) cprintf(" %p", pc[i]); } cprintf("\n"); 80103e88: c7 04 24 57 75 10 80 movl $0x80107557,(%esp) 80103e8f: e8 bc c7 ff ff call 80100650 <cprintf> 80103e94: 83 c3 7c add $0x7c,%ebx for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ 80103e97: 81 fb c0 4c 11 80 cmp $0x80114cc0,%ebx 80103e9d: 0f 84 8d 00 00 00 je 80103f30 <procdump+0xc0> if(p->state == UNUSED) 80103ea3: 8b 43 a0 mov -0x60(%ebx),%eax 80103ea6: 85 c0 test %eax,%eax 80103ea8: 74 ea je 80103e94 <procdump+0x24> if(p->state >= 0 && p->state < NELEM(states) && states[p->state]) 80103eaa: 83 f8 05 cmp $0x5,%eax state = "???"; 80103ead: ba e0 71 10 80 mov $0x801071e0,%edx if(p->state >= 0 && p->state < NELEM(states) && states[p->state]) 80103eb2: 77 11 ja 80103ec5 <procdump+0x55> 80103eb4: 8b 14 85 40 72 10 80 mov -0x7fef8dc0(,%eax,4),%edx state = "???"; 80103ebb: b8 e0 71 10 80 mov $0x801071e0,%eax 80103ec0: 85 d2 test %edx,%edx 80103ec2: 0f 44 d0 cmove %eax,%edx cprintf("%d %s %s", p->pid, state, p->name); 80103ec5: 8b 43 a4 mov -0x5c(%ebx),%eax 80103ec8: 89 5c 24 0c mov %ebx,0xc(%esp) 80103ecc: 89 54 24 08 mov %edx,0x8(%esp) 80103ed0: c7 04 24 e4 71 10 80 movl $0x801071e4,(%esp) 80103ed7: 89 44 24 04 mov %eax,0x4(%esp) 80103edb: e8 70 c7 ff ff call 80100650 <cprintf> if(p->state == SLEEPING){ 80103ee0: 83 7b a0 02 cmpl $0x2,-0x60(%ebx) 80103ee4: 75 a2 jne 80103e88 <procdump+0x18> getcallerpcs((uint*)p->context->ebp+2, pc); 80103ee6: 8d 45 c0 lea -0x40(%ebp),%eax 80103ee9: 89 44 24 04 mov %eax,0x4(%esp) 80103eed: 8b 43 b0 mov -0x50(%ebx),%eax 80103ef0: 8d 7d c0 lea -0x40(%ebp),%edi 80103ef3: 8b 40 0c mov 0xc(%eax),%eax 80103ef6: 83 c0 08 add $0x8,%eax 80103ef9: 89 04 24 mov %eax,(%esp) 80103efc: e8 8f 01 00 00 call 80104090 <getcallerpcs> 80103f01: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi for(i=0; i<10 && pc[i] != 0; i++) 80103f08: 8b 17 mov (%edi),%edx 80103f0a: 85 d2 test %edx,%edx 80103f0c: 0f 84 76 ff ff ff je 80103e88 <procdump+0x18> cprintf(" %p", pc[i]); 80103f12: 89 54 24 04 mov %edx,0x4(%esp) 80103f16: 83 c7 04 add $0x4,%edi 80103f19: c7 04 24 21 6c 10 80 movl $0x80106c21,(%esp) 80103f20: e8 2b c7 ff ff call 80100650 <cprintf> for(i=0; i<10 && pc[i] != 0; i++) 80103f25: 39 f7 cmp %esi,%edi 80103f27: 75 df jne 80103f08 <procdump+0x98> 80103f29: e9 5a ff ff ff jmp 80103e88 <procdump+0x18> 80103f2e: 66 90 xchg %ax,%ax } } 80103f30: 83 c4 4c add $0x4c,%esp 80103f33: 5b pop %ebx 80103f34: 5e pop %esi 80103f35: 5f pop %edi 80103f36: 5d pop %ebp 80103f37: c3 ret 80103f38: 66 90 xchg %ax,%ax 80103f3a: 66 90 xchg %ax,%ax 80103f3c: 66 90 xchg %ax,%ax 80103f3e: 66 90 xchg %ax,%ax 80103f40 <initsleeplock>: #include "spinlock.h" #include "sleeplock.h" void initsleeplock(struct sleeplock *lk, char *name) { 80103f40: 55 push %ebp 80103f41: 89 e5 mov %esp,%ebp 80103f43: 53 push %ebx 80103f44: 83 ec 14 sub $0x14,%esp 80103f47: 8b 5d 08 mov 0x8(%ebp),%ebx initlock(&lk->lk, "sleep lock"); 80103f4a: c7 44 24 04 58 72 10 movl $0x80107258,0x4(%esp) 80103f51: 80 80103f52: 8d 43 04 lea 0x4(%ebx),%eax 80103f55: 89 04 24 mov %eax,(%esp) 80103f58: e8 13 01 00 00 call 80104070 <initlock> lk->name = name; 80103f5d: 8b 45 0c mov 0xc(%ebp),%eax lk->locked = 0; 80103f60: c7 03 00 00 00 00 movl $0x0,(%ebx) lk->pid = 0; 80103f66: c7 43 3c 00 00 00 00 movl $0x0,0x3c(%ebx) lk->name = name; 80103f6d: 89 43 38 mov %eax,0x38(%ebx) } 80103f70: 83 c4 14 add $0x14,%esp 80103f73: 5b pop %ebx 80103f74: 5d pop %ebp 80103f75: c3 ret 80103f76: 8d 76 00 lea 0x0(%esi),%esi 80103f79: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80103f80 <acquiresleep>: void acquiresleep(struct sleeplock *lk) { 80103f80: 55 push %ebp 80103f81: 89 e5 mov %esp,%ebp 80103f83: 56 push %esi 80103f84: 53 push %ebx 80103f85: 83 ec 10 sub $0x10,%esp 80103f88: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&lk->lk); 80103f8b: 8d 73 04 lea 0x4(%ebx),%esi 80103f8e: 89 34 24 mov %esi,(%esp) 80103f91: e8 4a 02 00 00 call 801041e0 <acquire> while (lk->locked) { 80103f96: 8b 13 mov (%ebx),%edx 80103f98: 85 d2 test %edx,%edx 80103f9a: 74 16 je 80103fb2 <acquiresleep+0x32> 80103f9c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi sleep(lk, &lk->lk); 80103fa0: 89 74 24 04 mov %esi,0x4(%esp) 80103fa4: 89 1c 24 mov %ebx,(%esp) 80103fa7: e8 54 fc ff ff call 80103c00 <sleep> while (lk->locked) { 80103fac: 8b 03 mov (%ebx),%eax 80103fae: 85 c0 test %eax,%eax 80103fb0: 75 ee jne 80103fa0 <acquiresleep+0x20> } lk->locked = 1; 80103fb2: c7 03 01 00 00 00 movl $0x1,(%ebx) lk->pid = myproc()->pid; 80103fb8: e8 e3 f6 ff ff call 801036a0 <myproc> 80103fbd: 8b 40 10 mov 0x10(%eax),%eax 80103fc0: 89 43 3c mov %eax,0x3c(%ebx) release(&lk->lk); 80103fc3: 89 75 08 mov %esi,0x8(%ebp) } 80103fc6: 83 c4 10 add $0x10,%esp 80103fc9: 5b pop %ebx 80103fca: 5e pop %esi 80103fcb: 5d pop %ebp release(&lk->lk); 80103fcc: e9 7f 02 00 00 jmp 80104250 <release> 80103fd1: eb 0d jmp 80103fe0 <releasesleep> 80103fd3: 90 nop 80103fd4: 90 nop 80103fd5: 90 nop 80103fd6: 90 nop 80103fd7: 90 nop 80103fd8: 90 nop 80103fd9: 90 nop 80103fda: 90 nop 80103fdb: 90 nop 80103fdc: 90 nop 80103fdd: 90 nop 80103fde: 90 nop 80103fdf: 90 nop 80103fe0 <releasesleep>: void releasesleep(struct sleeplock *lk) { 80103fe0: 55 push %ebp 80103fe1: 89 e5 mov %esp,%ebp 80103fe3: 56 push %esi 80103fe4: 53 push %ebx 80103fe5: 83 ec 10 sub $0x10,%esp 80103fe8: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&lk->lk); 80103feb: 8d 73 04 lea 0x4(%ebx),%esi 80103fee: 89 34 24 mov %esi,(%esp) 80103ff1: e8 ea 01 00 00 call 801041e0 <acquire> lk->locked = 0; 80103ff6: c7 03 00 00 00 00 movl $0x0,(%ebx) lk->pid = 0; 80103ffc: c7 43 3c 00 00 00 00 movl $0x0,0x3c(%ebx) wakeup(lk); 80104003: 89 1c 24 mov %ebx,(%esp) 80104006: e8 85 fd ff ff call 80103d90 <wakeup> release(&lk->lk); 8010400b: 89 75 08 mov %esi,0x8(%ebp) } 8010400e: 83 c4 10 add $0x10,%esp 80104011: 5b pop %ebx 80104012: 5e pop %esi 80104013: 5d pop %ebp release(&lk->lk); 80104014: e9 37 02 00 00 jmp 80104250 <release> 80104019: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104020 <holdingsleep>: int holdingsleep(struct sleeplock *lk) { 80104020: 55 push %ebp 80104021: 89 e5 mov %esp,%ebp 80104023: 57 push %edi int r; acquire(&lk->lk); r = lk->locked && (lk->pid == myproc()->pid); 80104024: 31 ff xor %edi,%edi { 80104026: 56 push %esi 80104027: 53 push %ebx 80104028: 83 ec 1c sub $0x1c,%esp 8010402b: 8b 5d 08 mov 0x8(%ebp),%ebx acquire(&lk->lk); 8010402e: 8d 73 04 lea 0x4(%ebx),%esi 80104031: 89 34 24 mov %esi,(%esp) 80104034: e8 a7 01 00 00 call 801041e0 <acquire> r = lk->locked && (lk->pid == myproc()->pid); 80104039: 8b 03 mov (%ebx),%eax 8010403b: 85 c0 test %eax,%eax 8010403d: 74 13 je 80104052 <holdingsleep+0x32> 8010403f: 8b 5b 3c mov 0x3c(%ebx),%ebx 80104042: e8 59 f6 ff ff call 801036a0 <myproc> 80104047: 3b 58 10 cmp 0x10(%eax),%ebx 8010404a: 0f 94 c0 sete %al 8010404d: 0f b6 c0 movzbl %al,%eax 80104050: 89 c7 mov %eax,%edi release(&lk->lk); 80104052: 89 34 24 mov %esi,(%esp) 80104055: e8 f6 01 00 00 call 80104250 <release> return r; } 8010405a: 83 c4 1c add $0x1c,%esp 8010405d: 89 f8 mov %edi,%eax 8010405f: 5b pop %ebx 80104060: 5e pop %esi 80104061: 5f pop %edi 80104062: 5d pop %ebp 80104063: c3 ret 80104064: 66 90 xchg %ax,%ax 80104066: 66 90 xchg %ax,%ax 80104068: 66 90 xchg %ax,%ax 8010406a: 66 90 xchg %ax,%ax 8010406c: 66 90 xchg %ax,%ax 8010406e: 66 90 xchg %ax,%ax 80104070 <initlock>: #include "proc.h" #include "spinlock.h" void initlock(struct spinlock *lk, char *name) { 80104070: 55 push %ebp 80104071: 89 e5 mov %esp,%ebp 80104073: 8b 45 08 mov 0x8(%ebp),%eax lk->name = name; 80104076: 8b 55 0c mov 0xc(%ebp),%edx lk->locked = 0; 80104079: c7 00 00 00 00 00 movl $0x0,(%eax) lk->name = name; 8010407f: 89 50 04 mov %edx,0x4(%eax) lk->cpu = 0; 80104082: c7 40 08 00 00 00 00 movl $0x0,0x8(%eax) } 80104089: 5d pop %ebp 8010408a: c3 ret 8010408b: 90 nop 8010408c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104090 <getcallerpcs>: } // Record the current call stack in pcs[] by following the %ebp chain. void getcallerpcs(void *v, uint pcs[]) { 80104090: 55 push %ebp 80104091: 89 e5 mov %esp,%ebp uint *ebp; int i; ebp = (uint*)v - 2; 80104093: 8b 45 08 mov 0x8(%ebp),%eax { 80104096: 8b 4d 0c mov 0xc(%ebp),%ecx 80104099: 53 push %ebx ebp = (uint*)v - 2; 8010409a: 8d 50 f8 lea -0x8(%eax),%edx for(i = 0; i < 10; i++){ 8010409d: 31 c0 xor %eax,%eax 8010409f: 90 nop if(ebp == 0 || ebp < (uint*)KERNBASE || ebp == (uint*)0xffffffff) 801040a0: 8d 9a 00 00 00 80 lea -0x80000000(%edx),%ebx 801040a6: 81 fb fe ff ff 7f cmp $0x7ffffffe,%ebx 801040ac: 77 1a ja 801040c8 <getcallerpcs+0x38> break; pcs[i] = ebp[1]; // saved %eip 801040ae: 8b 5a 04 mov 0x4(%edx),%ebx 801040b1: 89 1c 81 mov %ebx,(%ecx,%eax,4) for(i = 0; i < 10; i++){ 801040b4: 83 c0 01 add $0x1,%eax ebp = (uint*)ebp[0]; // saved %ebp 801040b7: 8b 12 mov (%edx),%edx for(i = 0; i < 10; i++){ 801040b9: 83 f8 0a cmp $0xa,%eax 801040bc: 75 e2 jne 801040a0 <getcallerpcs+0x10> } for(; i < 10; i++) pcs[i] = 0; } 801040be: 5b pop %ebx 801040bf: 5d pop %ebp 801040c0: c3 ret 801040c1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi pcs[i] = 0; 801040c8: c7 04 81 00 00 00 00 movl $0x0,(%ecx,%eax,4) for(; i < 10; i++) 801040cf: 83 c0 01 add $0x1,%eax 801040d2: 83 f8 0a cmp $0xa,%eax 801040d5: 74 e7 je 801040be <getcallerpcs+0x2e> pcs[i] = 0; 801040d7: c7 04 81 00 00 00 00 movl $0x0,(%ecx,%eax,4) for(; i < 10; i++) 801040de: 83 c0 01 add $0x1,%eax 801040e1: 83 f8 0a cmp $0xa,%eax 801040e4: 75 e2 jne 801040c8 <getcallerpcs+0x38> 801040e6: eb d6 jmp 801040be <getcallerpcs+0x2e> 801040e8: 90 nop 801040e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801040f0 <pushcli>: // it takes two popcli to undo two pushcli. Also, if interrupts // are off, then pushcli, popcli leaves them off. void pushcli(void) { 801040f0: 55 push %ebp 801040f1: 89 e5 mov %esp,%ebp 801040f3: 53 push %ebx 801040f4: 83 ec 04 sub $0x4,%esp 801040f7: 9c pushf 801040f8: 5b pop %ebx asm volatile("cli"); 801040f9: fa cli int eflags; eflags = readeflags(); cli(); if(mycpu()->ncli == 0) 801040fa: e8 01 f5 ff ff call 80103600 <mycpu> 801040ff: 8b 80 a4 00 00 00 mov 0xa4(%eax),%eax 80104105: 85 c0 test %eax,%eax 80104107: 75 11 jne 8010411a <pushcli+0x2a> mycpu()->intena = eflags & FL_IF; 80104109: e8 f2 f4 ff ff call 80103600 <mycpu> 8010410e: 81 e3 00 02 00 00 and $0x200,%ebx 80104114: 89 98 a8 00 00 00 mov %ebx,0xa8(%eax) mycpu()->ncli += 1; 8010411a: e8 e1 f4 ff ff call 80103600 <mycpu> 8010411f: 83 80 a4 00 00 00 01 addl $0x1,0xa4(%eax) } 80104126: 83 c4 04 add $0x4,%esp 80104129: 5b pop %ebx 8010412a: 5d pop %ebp 8010412b: c3 ret 8010412c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104130 <popcli>: void popcli(void) { 80104130: 55 push %ebp 80104131: 89 e5 mov %esp,%ebp 80104133: 83 ec 18 sub $0x18,%esp asm volatile("pushfl; popl %0" : "=r" (eflags)); 80104136: 9c pushf 80104137: 58 pop %eax if(readeflags()&FL_IF) 80104138: f6 c4 02 test $0x2,%ah 8010413b: 75 49 jne 80104186 <popcli+0x56> panic("popcli - interruptible"); if(--mycpu()->ncli < 0) 8010413d: e8 be f4 ff ff call 80103600 <mycpu> 80104142: 8b 88 a4 00 00 00 mov 0xa4(%eax),%ecx 80104148: 8d 51 ff lea -0x1(%ecx),%edx 8010414b: 85 d2 test %edx,%edx 8010414d: 89 90 a4 00 00 00 mov %edx,0xa4(%eax) 80104153: 78 25 js 8010417a <popcli+0x4a> panic("popcli"); if(mycpu()->ncli == 0 && mycpu()->intena) 80104155: e8 a6 f4 ff ff call 80103600 <mycpu> 8010415a: 8b 90 a4 00 00 00 mov 0xa4(%eax),%edx 80104160: 85 d2 test %edx,%edx 80104162: 74 04 je 80104168 <popcli+0x38> sti(); } 80104164: c9 leave 80104165: c3 ret 80104166: 66 90 xchg %ax,%ax if(mycpu()->ncli == 0 && mycpu()->intena) 80104168: e8 93 f4 ff ff call 80103600 <mycpu> 8010416d: 8b 80 a8 00 00 00 mov 0xa8(%eax),%eax 80104173: 85 c0 test %eax,%eax 80104175: 74 ed je 80104164 <popcli+0x34> asm volatile("sti"); 80104177: fb sti } 80104178: c9 leave 80104179: c3 ret panic("popcli"); 8010417a: c7 04 24 7a 72 10 80 movl $0x8010727a,(%esp) 80104181: e8 da c1 ff ff call 80100360 <panic> panic("popcli - interruptible"); 80104186: c7 04 24 63 72 10 80 movl $0x80107263,(%esp) 8010418d: e8 ce c1 ff ff call 80100360 <panic> 80104192: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104199: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801041a0 <holding>: { 801041a0: 55 push %ebp 801041a1: 89 e5 mov %esp,%ebp 801041a3: 56 push %esi r = lock->locked && lock->cpu == mycpu(); 801041a4: 31 f6 xor %esi,%esi { 801041a6: 53 push %ebx 801041a7: 8b 5d 08 mov 0x8(%ebp),%ebx pushcli(); 801041aa: e8 41 ff ff ff call 801040f0 <pushcli> r = lock->locked && lock->cpu == mycpu(); 801041af: 8b 03 mov (%ebx),%eax 801041b1: 85 c0 test %eax,%eax 801041b3: 74 12 je 801041c7 <holding+0x27> 801041b5: 8b 5b 08 mov 0x8(%ebx),%ebx 801041b8: e8 43 f4 ff ff call 80103600 <mycpu> 801041bd: 39 c3 cmp %eax,%ebx 801041bf: 0f 94 c0 sete %al 801041c2: 0f b6 c0 movzbl %al,%eax 801041c5: 89 c6 mov %eax,%esi popcli(); 801041c7: e8 64 ff ff ff call 80104130 <popcli> } 801041cc: 89 f0 mov %esi,%eax 801041ce: 5b pop %ebx 801041cf: 5e pop %esi 801041d0: 5d pop %ebp 801041d1: c3 ret 801041d2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801041d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801041e0 <acquire>: { 801041e0: 55 push %ebp 801041e1: 89 e5 mov %esp,%ebp 801041e3: 53 push %ebx 801041e4: 83 ec 14 sub $0x14,%esp pushcli(); // disable interrupts to avoid deadlock. 801041e7: e8 04 ff ff ff call 801040f0 <pushcli> if(holding(lk)) 801041ec: 8b 45 08 mov 0x8(%ebp),%eax 801041ef: 89 04 24 mov %eax,(%esp) 801041f2: e8 a9 ff ff ff call 801041a0 <holding> 801041f7: 85 c0 test %eax,%eax 801041f9: 75 3a jne 80104235 <acquire+0x55> asm volatile("lock; xchgl %0, %1" : 801041fb: b9 01 00 00 00 mov $0x1,%ecx while(xchg(&lk->locked, 1) != 0) 80104200: 8b 55 08 mov 0x8(%ebp),%edx 80104203: 89 c8 mov %ecx,%eax 80104205: f0 87 02 lock xchg %eax,(%edx) 80104208: 85 c0 test %eax,%eax 8010420a: 75 f4 jne 80104200 <acquire+0x20> __sync_synchronize(); 8010420c: 0f ae f0 mfence lk->cpu = mycpu(); 8010420f: 8b 5d 08 mov 0x8(%ebp),%ebx 80104212: e8 e9 f3 ff ff call 80103600 <mycpu> 80104217: 89 43 08 mov %eax,0x8(%ebx) getcallerpcs(&lk, lk->pcs); 8010421a: 8b 45 08 mov 0x8(%ebp),%eax 8010421d: 83 c0 0c add $0xc,%eax 80104220: 89 44 24 04 mov %eax,0x4(%esp) 80104224: 8d 45 08 lea 0x8(%ebp),%eax 80104227: 89 04 24 mov %eax,(%esp) 8010422a: e8 61 fe ff ff call 80104090 <getcallerpcs> } 8010422f: 83 c4 14 add $0x14,%esp 80104232: 5b pop %ebx 80104233: 5d pop %ebp 80104234: c3 ret panic("acquire"); 80104235: c7 04 24 81 72 10 80 movl $0x80107281,(%esp) 8010423c: e8 1f c1 ff ff call 80100360 <panic> 80104241: eb 0d jmp 80104250 <release> 80104243: 90 nop 80104244: 90 nop 80104245: 90 nop 80104246: 90 nop 80104247: 90 nop 80104248: 90 nop 80104249: 90 nop 8010424a: 90 nop 8010424b: 90 nop 8010424c: 90 nop 8010424d: 90 nop 8010424e: 90 nop 8010424f: 90 nop 80104250 <release>: { 80104250: 55 push %ebp 80104251: 89 e5 mov %esp,%ebp 80104253: 53 push %ebx 80104254: 83 ec 14 sub $0x14,%esp 80104257: 8b 5d 08 mov 0x8(%ebp),%ebx if(!holding(lk)) 8010425a: 89 1c 24 mov %ebx,(%esp) 8010425d: e8 3e ff ff ff call 801041a0 <holding> 80104262: 85 c0 test %eax,%eax 80104264: 74 21 je 80104287 <release+0x37> lk->pcs[0] = 0; 80104266: c7 43 0c 00 00 00 00 movl $0x0,0xc(%ebx) lk->cpu = 0; 8010426d: c7 43 08 00 00 00 00 movl $0x0,0x8(%ebx) __sync_synchronize(); 80104274: 0f ae f0 mfence asm volatile("movl $0, %0" : "+m" (lk->locked) : ); 80104277: c7 03 00 00 00 00 movl $0x0,(%ebx) } 8010427d: 83 c4 14 add $0x14,%esp 80104280: 5b pop %ebx 80104281: 5d pop %ebp popcli(); 80104282: e9 a9 fe ff ff jmp 80104130 <popcli> panic("release"); 80104287: c7 04 24 89 72 10 80 movl $0x80107289,(%esp) 8010428e: e8 cd c0 ff ff call 80100360 <panic> 80104293: 66 90 xchg %ax,%ax 80104295: 66 90 xchg %ax,%ax 80104297: 66 90 xchg %ax,%ax 80104299: 66 90 xchg %ax,%ax 8010429b: 66 90 xchg %ax,%ax 8010429d: 66 90 xchg %ax,%ax 8010429f: 90 nop 801042a0 <memset>: #include "types.h" #include "x86.h" void* memset(void *dst, int c, uint n) { 801042a0: 55 push %ebp 801042a1: 89 e5 mov %esp,%ebp 801042a3: 8b 55 08 mov 0x8(%ebp),%edx 801042a6: 57 push %edi 801042a7: 8b 4d 10 mov 0x10(%ebp),%ecx 801042aa: 53 push %ebx if ((int)dst%4 == 0 && n%4 == 0){ 801042ab: f6 c2 03 test $0x3,%dl 801042ae: 75 05 jne 801042b5 <memset+0x15> 801042b0: f6 c1 03 test $0x3,%cl 801042b3: 74 13 je 801042c8 <memset+0x28> asm volatile("cld; rep stosb" : 801042b5: 89 d7 mov %edx,%edi 801042b7: 8b 45 0c mov 0xc(%ebp),%eax 801042ba: fc cld 801042bb: f3 aa rep stos %al,%es:(%edi) c &= 0xFF; stosl(dst, (c<<24)|(c<<16)|(c<<8)|c, n/4); } else stosb(dst, c, n); return dst; } 801042bd: 5b pop %ebx 801042be: 89 d0 mov %edx,%eax 801042c0: 5f pop %edi 801042c1: 5d pop %ebp 801042c2: c3 ret 801042c3: 90 nop 801042c4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi c &= 0xFF; 801042c8: 0f b6 7d 0c movzbl 0xc(%ebp),%edi stosl(dst, (c<<24)|(c<<16)|(c<<8)|c, n/4); 801042cc: c1 e9 02 shr $0x2,%ecx 801042cf: 89 f8 mov %edi,%eax 801042d1: 89 fb mov %edi,%ebx 801042d3: c1 e0 18 shl $0x18,%eax 801042d6: c1 e3 10 shl $0x10,%ebx 801042d9: 09 d8 or %ebx,%eax 801042db: 09 f8 or %edi,%eax 801042dd: c1 e7 08 shl $0x8,%edi 801042e0: 09 f8 or %edi,%eax asm volatile("cld; rep stosl" : 801042e2: 89 d7 mov %edx,%edi 801042e4: fc cld 801042e5: f3 ab rep stos %eax,%es:(%edi) } 801042e7: 5b pop %ebx 801042e8: 89 d0 mov %edx,%eax 801042ea: 5f pop %edi 801042eb: 5d pop %ebp 801042ec: c3 ret 801042ed: 8d 76 00 lea 0x0(%esi),%esi 801042f0 <memcmp>: int memcmp(const void *v1, const void *v2, uint n) { 801042f0: 55 push %ebp 801042f1: 89 e5 mov %esp,%ebp 801042f3: 8b 45 10 mov 0x10(%ebp),%eax 801042f6: 57 push %edi 801042f7: 56 push %esi 801042f8: 8b 75 0c mov 0xc(%ebp),%esi 801042fb: 53 push %ebx 801042fc: 8b 5d 08 mov 0x8(%ebp),%ebx const uchar *s1, *s2; s1 = v1; s2 = v2; while(n-- > 0){ 801042ff: 85 c0 test %eax,%eax 80104301: 8d 78 ff lea -0x1(%eax),%edi 80104304: 74 26 je 8010432c <memcmp+0x3c> if(*s1 != *s2) 80104306: 0f b6 03 movzbl (%ebx),%eax 80104309: 31 d2 xor %edx,%edx 8010430b: 0f b6 0e movzbl (%esi),%ecx 8010430e: 38 c8 cmp %cl,%al 80104310: 74 16 je 80104328 <memcmp+0x38> 80104312: eb 24 jmp 80104338 <memcmp+0x48> 80104314: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104318: 0f b6 44 13 01 movzbl 0x1(%ebx,%edx,1),%eax 8010431d: 83 c2 01 add $0x1,%edx 80104320: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 80104324: 38 c8 cmp %cl,%al 80104326: 75 10 jne 80104338 <memcmp+0x48> while(n-- > 0){ 80104328: 39 fa cmp %edi,%edx 8010432a: 75 ec jne 80104318 <memcmp+0x28> return *s1 - *s2; s1++, s2++; } return 0; } 8010432c: 5b pop %ebx return 0; 8010432d: 31 c0 xor %eax,%eax } 8010432f: 5e pop %esi 80104330: 5f pop %edi 80104331: 5d pop %ebp 80104332: c3 ret 80104333: 90 nop 80104334: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104338: 5b pop %ebx return *s1 - *s2; 80104339: 29 c8 sub %ecx,%eax } 8010433b: 5e pop %esi 8010433c: 5f pop %edi 8010433d: 5d pop %ebp 8010433e: c3 ret 8010433f: 90 nop 80104340 <memmove>: void* memmove(void *dst, const void *src, uint n) { 80104340: 55 push %ebp 80104341: 89 e5 mov %esp,%ebp 80104343: 57 push %edi 80104344: 8b 45 08 mov 0x8(%ebp),%eax 80104347: 56 push %esi 80104348: 8b 75 0c mov 0xc(%ebp),%esi 8010434b: 53 push %ebx 8010434c: 8b 5d 10 mov 0x10(%ebp),%ebx const char *s; char *d; s = src; d = dst; if(s < d && s + n > d){ 8010434f: 39 c6 cmp %eax,%esi 80104351: 73 35 jae 80104388 <memmove+0x48> 80104353: 8d 0c 1e lea (%esi,%ebx,1),%ecx 80104356: 39 c8 cmp %ecx,%eax 80104358: 73 2e jae 80104388 <memmove+0x48> s += n; d += n; while(n-- > 0) 8010435a: 85 db test %ebx,%ebx d += n; 8010435c: 8d 3c 18 lea (%eax,%ebx,1),%edi while(n-- > 0) 8010435f: 8d 53 ff lea -0x1(%ebx),%edx 80104362: 74 1b je 8010437f <memmove+0x3f> 80104364: f7 db neg %ebx 80104366: 8d 34 19 lea (%ecx,%ebx,1),%esi 80104369: 01 fb add %edi,%ebx 8010436b: 90 nop 8010436c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi *--d = *--s; 80104370: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 80104374: 88 0c 13 mov %cl,(%ebx,%edx,1) while(n-- > 0) 80104377: 83 ea 01 sub $0x1,%edx 8010437a: 83 fa ff cmp $0xffffffff,%edx 8010437d: 75 f1 jne 80104370 <memmove+0x30> } else while(n-- > 0) *d++ = *s++; return dst; } 8010437f: 5b pop %ebx 80104380: 5e pop %esi 80104381: 5f pop %edi 80104382: 5d pop %ebp 80104383: c3 ret 80104384: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi while(n-- > 0) 80104388: 31 d2 xor %edx,%edx 8010438a: 85 db test %ebx,%ebx 8010438c: 74 f1 je 8010437f <memmove+0x3f> 8010438e: 66 90 xchg %ax,%ax *d++ = *s++; 80104390: 0f b6 0c 16 movzbl (%esi,%edx,1),%ecx 80104394: 88 0c 10 mov %cl,(%eax,%edx,1) 80104397: 83 c2 01 add $0x1,%edx while(n-- > 0) 8010439a: 39 da cmp %ebx,%edx 8010439c: 75 f2 jne 80104390 <memmove+0x50> } 8010439e: 5b pop %ebx 8010439f: 5e pop %esi 801043a0: 5f pop %edi 801043a1: 5d pop %ebp 801043a2: c3 ret 801043a3: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801043a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801043b0 <memcpy>: // memcpy exists to placate GCC. Use memmove. void* memcpy(void *dst, const void *src, uint n) { 801043b0: 55 push %ebp 801043b1: 89 e5 mov %esp,%ebp return memmove(dst, src, n); } 801043b3: 5d pop %ebp return memmove(dst, src, n); 801043b4: eb 8a jmp 80104340 <memmove> 801043b6: 8d 76 00 lea 0x0(%esi),%esi 801043b9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801043c0 <strncmp>: int strncmp(const char *p, const char *q, uint n) { 801043c0: 55 push %ebp 801043c1: 89 e5 mov %esp,%ebp 801043c3: 56 push %esi 801043c4: 8b 75 10 mov 0x10(%ebp),%esi 801043c7: 53 push %ebx 801043c8: 8b 4d 08 mov 0x8(%ebp),%ecx 801043cb: 8b 5d 0c mov 0xc(%ebp),%ebx while(n > 0 && *p && *p == *q) 801043ce: 85 f6 test %esi,%esi 801043d0: 74 30 je 80104402 <strncmp+0x42> 801043d2: 0f b6 01 movzbl (%ecx),%eax 801043d5: 84 c0 test %al,%al 801043d7: 74 2f je 80104408 <strncmp+0x48> 801043d9: 0f b6 13 movzbl (%ebx),%edx 801043dc: 38 d0 cmp %dl,%al 801043de: 75 46 jne 80104426 <strncmp+0x66> 801043e0: 8d 51 01 lea 0x1(%ecx),%edx 801043e3: 01 ce add %ecx,%esi 801043e5: eb 14 jmp 801043fb <strncmp+0x3b> 801043e7: 90 nop 801043e8: 0f b6 02 movzbl (%edx),%eax 801043eb: 84 c0 test %al,%al 801043ed: 74 31 je 80104420 <strncmp+0x60> 801043ef: 0f b6 19 movzbl (%ecx),%ebx 801043f2: 83 c2 01 add $0x1,%edx 801043f5: 38 d8 cmp %bl,%al 801043f7: 75 17 jne 80104410 <strncmp+0x50> n--, p++, q++; 801043f9: 89 cb mov %ecx,%ebx while(n > 0 && *p && *p == *q) 801043fb: 39 f2 cmp %esi,%edx n--, p++, q++; 801043fd: 8d 4b 01 lea 0x1(%ebx),%ecx while(n > 0 && *p && *p == *q) 80104400: 75 e6 jne 801043e8 <strncmp+0x28> if(n == 0) return 0; return (uchar)*p - (uchar)*q; } 80104402: 5b pop %ebx return 0; 80104403: 31 c0 xor %eax,%eax } 80104405: 5e pop %esi 80104406: 5d pop %ebp 80104407: c3 ret 80104408: 0f b6 1b movzbl (%ebx),%ebx while(n > 0 && *p && *p == *q) 8010440b: 31 c0 xor %eax,%eax 8010440d: 8d 76 00 lea 0x0(%esi),%esi return (uchar)*p - (uchar)*q; 80104410: 0f b6 d3 movzbl %bl,%edx 80104413: 29 d0 sub %edx,%eax } 80104415: 5b pop %ebx 80104416: 5e pop %esi 80104417: 5d pop %ebp 80104418: c3 ret 80104419: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104420: 0f b6 5b 01 movzbl 0x1(%ebx),%ebx 80104424: eb ea jmp 80104410 <strncmp+0x50> while(n > 0 && *p && *p == *q) 80104426: 89 d3 mov %edx,%ebx 80104428: eb e6 jmp 80104410 <strncmp+0x50> 8010442a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80104430 <strncpy>: char* strncpy(char *s, const char *t, int n) { 80104430: 55 push %ebp 80104431: 89 e5 mov %esp,%ebp 80104433: 8b 45 08 mov 0x8(%ebp),%eax 80104436: 56 push %esi 80104437: 8b 4d 10 mov 0x10(%ebp),%ecx 8010443a: 53 push %ebx 8010443b: 8b 5d 0c mov 0xc(%ebp),%ebx char *os; os = s; while(n-- > 0 && (*s++ = *t++) != 0) 8010443e: 89 c2 mov %eax,%edx 80104440: eb 19 jmp 8010445b <strncpy+0x2b> 80104442: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80104448: 83 c3 01 add $0x1,%ebx 8010444b: 0f b6 4b ff movzbl -0x1(%ebx),%ecx 8010444f: 83 c2 01 add $0x1,%edx 80104452: 84 c9 test %cl,%cl 80104454: 88 4a ff mov %cl,-0x1(%edx) 80104457: 74 09 je 80104462 <strncpy+0x32> 80104459: 89 f1 mov %esi,%ecx 8010445b: 85 c9 test %ecx,%ecx 8010445d: 8d 71 ff lea -0x1(%ecx),%esi 80104460: 7f e6 jg 80104448 <strncpy+0x18> ; while(n-- > 0) 80104462: 31 c9 xor %ecx,%ecx 80104464: 85 f6 test %esi,%esi 80104466: 7e 0f jle 80104477 <strncpy+0x47> *s++ = 0; 80104468: c6 04 0a 00 movb $0x0,(%edx,%ecx,1) 8010446c: 89 f3 mov %esi,%ebx 8010446e: 83 c1 01 add $0x1,%ecx 80104471: 29 cb sub %ecx,%ebx while(n-- > 0) 80104473: 85 db test %ebx,%ebx 80104475: 7f f1 jg 80104468 <strncpy+0x38> return os; } 80104477: 5b pop %ebx 80104478: 5e pop %esi 80104479: 5d pop %ebp 8010447a: c3 ret 8010447b: 90 nop 8010447c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104480 <safestrcpy>: // Like strncpy but guaranteed to NUL-terminate. char* safestrcpy(char *s, const char *t, int n) { 80104480: 55 push %ebp 80104481: 89 e5 mov %esp,%ebp 80104483: 8b 4d 10 mov 0x10(%ebp),%ecx 80104486: 56 push %esi 80104487: 8b 45 08 mov 0x8(%ebp),%eax 8010448a: 53 push %ebx 8010448b: 8b 55 0c mov 0xc(%ebp),%edx char *os; os = s; if(n <= 0) 8010448e: 85 c9 test %ecx,%ecx 80104490: 7e 26 jle 801044b8 <safestrcpy+0x38> 80104492: 8d 74 0a ff lea -0x1(%edx,%ecx,1),%esi 80104496: 89 c1 mov %eax,%ecx 80104498: eb 17 jmp 801044b1 <safestrcpy+0x31> 8010449a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi return os; while(--n > 0 && (*s++ = *t++) != 0) 801044a0: 83 c2 01 add $0x1,%edx 801044a3: 0f b6 5a ff movzbl -0x1(%edx),%ebx 801044a7: 83 c1 01 add $0x1,%ecx 801044aa: 84 db test %bl,%bl 801044ac: 88 59 ff mov %bl,-0x1(%ecx) 801044af: 74 04 je 801044b5 <safestrcpy+0x35> 801044b1: 39 f2 cmp %esi,%edx 801044b3: 75 eb jne 801044a0 <safestrcpy+0x20> ; *s = 0; 801044b5: c6 01 00 movb $0x0,(%ecx) return os; } 801044b8: 5b pop %ebx 801044b9: 5e pop %esi 801044ba: 5d pop %ebp 801044bb: c3 ret 801044bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801044c0 <strlen>: int strlen(const char *s) { 801044c0: 55 push %ebp int n; for(n = 0; s[n]; n++) 801044c1: 31 c0 xor %eax,%eax { 801044c3: 89 e5 mov %esp,%ebp 801044c5: 8b 55 08 mov 0x8(%ebp),%edx for(n = 0; s[n]; n++) 801044c8: 80 3a 00 cmpb $0x0,(%edx) 801044cb: 74 0c je 801044d9 <strlen+0x19> 801044cd: 8d 76 00 lea 0x0(%esi),%esi 801044d0: 83 c0 01 add $0x1,%eax 801044d3: 80 3c 02 00 cmpb $0x0,(%edx,%eax,1) 801044d7: 75 f7 jne 801044d0 <strlen+0x10> ; return n; } 801044d9: 5d pop %ebp 801044da: c3 ret 801044db <swtch>: # a struct context, and save its address in *old. # Switch stacks to new and pop previously-saved registers. .globl swtch swtch: movl 4(%esp), %eax 801044db: 8b 44 24 04 mov 0x4(%esp),%eax movl 8(%esp), %edx 801044df: 8b 54 24 08 mov 0x8(%esp),%edx # Save old callee-saved registers pushl %ebp 801044e3: 55 push %ebp pushl %ebx 801044e4: 53 push %ebx pushl %esi 801044e5: 56 push %esi pushl %edi 801044e6: 57 push %edi # Switch stacks movl %esp, (%eax) 801044e7: 89 20 mov %esp,(%eax) movl %edx, %esp 801044e9: 89 d4 mov %edx,%esp # Load new callee-saved registers popl %edi 801044eb: 5f pop %edi popl %esi 801044ec: 5e pop %esi popl %ebx 801044ed: 5b pop %ebx popl %ebp 801044ee: 5d pop %ebp ret 801044ef: c3 ret 801044f0 <fetchint>: // to a saved program counter, and then the first argument. // Fetch the int at addr from the current process. int fetchint(uint addr, int *ip) { 801044f0: 55 push %ebp 801044f1: 89 e5 mov %esp,%ebp 801044f3: 53 push %ebx 801044f4: 83 ec 04 sub $0x4,%esp 801044f7: 8b 5d 08 mov 0x8(%ebp),%ebx struct proc *curproc = myproc(); 801044fa: e8 a1 f1 ff ff call 801036a0 <myproc> if(addr >= curproc->sz || addr+4 > curproc->sz) 801044ff: 8b 00 mov (%eax),%eax 80104501: 39 d8 cmp %ebx,%eax 80104503: 76 1b jbe 80104520 <fetchint+0x30> 80104505: 8d 53 04 lea 0x4(%ebx),%edx 80104508: 39 d0 cmp %edx,%eax 8010450a: 72 14 jb 80104520 <fetchint+0x30> return -1; *ip = *(int*)(addr); 8010450c: 8b 45 0c mov 0xc(%ebp),%eax 8010450f: 8b 13 mov (%ebx),%edx 80104511: 89 10 mov %edx,(%eax) return 0; 80104513: 31 c0 xor %eax,%eax } 80104515: 83 c4 04 add $0x4,%esp 80104518: 5b pop %ebx 80104519: 5d pop %ebp 8010451a: c3 ret 8010451b: 90 nop 8010451c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return -1; 80104520: b8 ff ff ff ff mov $0xffffffff,%eax 80104525: eb ee jmp 80104515 <fetchint+0x25> 80104527: 89 f6 mov %esi,%esi 80104529: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104530 <fetchstr>: // Fetch the nul-terminated string at addr from the current process. // Doesn't actually copy the string - just sets *pp to point at it. // Returns length of string, not including nul. int fetchstr(uint addr, char **pp) { 80104530: 55 push %ebp 80104531: 89 e5 mov %esp,%ebp 80104533: 53 push %ebx 80104534: 83 ec 04 sub $0x4,%esp 80104537: 8b 5d 08 mov 0x8(%ebp),%ebx char *s, *ep; struct proc *curproc = myproc(); 8010453a: e8 61 f1 ff ff call 801036a0 <myproc> if(addr >= curproc->sz) 8010453f: 39 18 cmp %ebx,(%eax) 80104541: 76 26 jbe 80104569 <fetchstr+0x39> return -1; *pp = (char*)addr; 80104543: 8b 4d 0c mov 0xc(%ebp),%ecx 80104546: 89 da mov %ebx,%edx 80104548: 89 19 mov %ebx,(%ecx) ep = (char*)curproc->sz; 8010454a: 8b 00 mov (%eax),%eax for(s = *pp; s < ep; s++){ 8010454c: 39 c3 cmp %eax,%ebx 8010454e: 73 19 jae 80104569 <fetchstr+0x39> if(*s == 0) 80104550: 80 3b 00 cmpb $0x0,(%ebx) 80104553: 75 0d jne 80104562 <fetchstr+0x32> 80104555: eb 21 jmp 80104578 <fetchstr+0x48> 80104557: 90 nop 80104558: 80 3a 00 cmpb $0x0,(%edx) 8010455b: 90 nop 8010455c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104560: 74 16 je 80104578 <fetchstr+0x48> for(s = *pp; s < ep; s++){ 80104562: 83 c2 01 add $0x1,%edx 80104565: 39 d0 cmp %edx,%eax 80104567: 77 ef ja 80104558 <fetchstr+0x28> return s - *pp; } return -1; } 80104569: 83 c4 04 add $0x4,%esp return -1; 8010456c: b8 ff ff ff ff mov $0xffffffff,%eax } 80104571: 5b pop %ebx 80104572: 5d pop %ebp 80104573: c3 ret 80104574: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104578: 83 c4 04 add $0x4,%esp return s - *pp; 8010457b: 89 d0 mov %edx,%eax 8010457d: 29 d8 sub %ebx,%eax } 8010457f: 5b pop %ebx 80104580: 5d pop %ebp 80104581: c3 ret 80104582: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104589: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104590 <argint>: // Fetch the nth 32-bit system call argument. int argint(int n, int *ip) { 80104590: 55 push %ebp 80104591: 89 e5 mov %esp,%ebp 80104593: 56 push %esi 80104594: 8b 75 0c mov 0xc(%ebp),%esi 80104597: 53 push %ebx 80104598: 8b 5d 08 mov 0x8(%ebp),%ebx return fetchint((myproc()->tf->esp) + 4 + 4*n, ip); 8010459b: e8 00 f1 ff ff call 801036a0 <myproc> 801045a0: 89 75 0c mov %esi,0xc(%ebp) 801045a3: 8b 40 18 mov 0x18(%eax),%eax 801045a6: 8b 40 44 mov 0x44(%eax),%eax 801045a9: 8d 44 98 04 lea 0x4(%eax,%ebx,4),%eax 801045ad: 89 45 08 mov %eax,0x8(%ebp) } 801045b0: 5b pop %ebx 801045b1: 5e pop %esi 801045b2: 5d pop %ebp return fetchint((myproc()->tf->esp) + 4 + 4*n, ip); 801045b3: e9 38 ff ff ff jmp 801044f0 <fetchint> 801045b8: 90 nop 801045b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801045c0 <argptr>: // Fetch the nth word-sized system call argument as a pointer // to a block of memory of size bytes. Check that the pointer // lies within the process address space. int argptr(int n, char **pp, int size) { 801045c0: 55 push %ebp 801045c1: 89 e5 mov %esp,%ebp 801045c3: 56 push %esi 801045c4: 53 push %ebx 801045c5: 83 ec 20 sub $0x20,%esp 801045c8: 8b 5d 10 mov 0x10(%ebp),%ebx int i; struct proc *curproc = myproc(); 801045cb: e8 d0 f0 ff ff call 801036a0 <myproc> 801045d0: 89 c6 mov %eax,%esi if(argint(n, &i) < 0) 801045d2: 8d 45 f4 lea -0xc(%ebp),%eax 801045d5: 89 44 24 04 mov %eax,0x4(%esp) 801045d9: 8b 45 08 mov 0x8(%ebp),%eax 801045dc: 89 04 24 mov %eax,(%esp) 801045df: e8 ac ff ff ff call 80104590 <argint> 801045e4: 85 c0 test %eax,%eax 801045e6: 78 28 js 80104610 <argptr+0x50> return -1; if(size < 0 || (uint)i >= curproc->sz || (uint)i+size > curproc->sz) 801045e8: 85 db test %ebx,%ebx 801045ea: 78 24 js 80104610 <argptr+0x50> 801045ec: 8b 55 f4 mov -0xc(%ebp),%edx 801045ef: 8b 06 mov (%esi),%eax 801045f1: 39 c2 cmp %eax,%edx 801045f3: 73 1b jae 80104610 <argptr+0x50> 801045f5: 01 d3 add %edx,%ebx 801045f7: 39 d8 cmp %ebx,%eax 801045f9: 72 15 jb 80104610 <argptr+0x50> return -1; *pp = (char*)i; 801045fb: 8b 45 0c mov 0xc(%ebp),%eax 801045fe: 89 10 mov %edx,(%eax) return 0; } 80104600: 83 c4 20 add $0x20,%esp return 0; 80104603: 31 c0 xor %eax,%eax } 80104605: 5b pop %ebx 80104606: 5e pop %esi 80104607: 5d pop %ebp 80104608: c3 ret 80104609: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104610: 83 c4 20 add $0x20,%esp return -1; 80104613: b8 ff ff ff ff mov $0xffffffff,%eax } 80104618: 5b pop %ebx 80104619: 5e pop %esi 8010461a: 5d pop %ebp 8010461b: c3 ret 8010461c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104620 <argstr>: // Check that the pointer is valid and the string is nul-terminated. // (There is no shared writable memory, so the string can't change // between this check and being used by the kernel.) int argstr(int n, char **pp) { 80104620: 55 push %ebp 80104621: 89 e5 mov %esp,%ebp 80104623: 83 ec 28 sub $0x28,%esp int addr; if(argint(n, &addr) < 0) 80104626: 8d 45 f4 lea -0xc(%ebp),%eax 80104629: 89 44 24 04 mov %eax,0x4(%esp) 8010462d: 8b 45 08 mov 0x8(%ebp),%eax 80104630: 89 04 24 mov %eax,(%esp) 80104633: e8 58 ff ff ff call 80104590 <argint> 80104638: 85 c0 test %eax,%eax 8010463a: 78 14 js 80104650 <argstr+0x30> return -1; return fetchstr(addr, pp); 8010463c: 8b 45 0c mov 0xc(%ebp),%eax 8010463f: 89 44 24 04 mov %eax,0x4(%esp) 80104643: 8b 45 f4 mov -0xc(%ebp),%eax 80104646: 89 04 24 mov %eax,(%esp) 80104649: e8 e2 fe ff ff call 80104530 <fetchstr> } 8010464e: c9 leave 8010464f: c3 ret return -1; 80104650: b8 ff ff ff ff mov $0xffffffff,%eax } 80104655: c9 leave 80104656: c3 ret 80104657: 89 f6 mov %esi,%esi 80104659: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104660 <syscall>: [SYS_close] sys_close, }; void syscall(void) { 80104660: 55 push %ebp 80104661: 89 e5 mov %esp,%ebp 80104663: 56 push %esi 80104664: 53 push %ebx 80104665: 83 ec 10 sub $0x10,%esp int num; struct proc *curproc = myproc(); 80104668: e8 33 f0 ff ff call 801036a0 <myproc> num = curproc->tf->eax; 8010466d: 8b 70 18 mov 0x18(%eax),%esi struct proc *curproc = myproc(); 80104670: 89 c3 mov %eax,%ebx num = curproc->tf->eax; 80104672: 8b 46 1c mov 0x1c(%esi),%eax if(num > 0 && num < NELEM(syscalls) && syscalls[num]) { 80104675: 8d 50 ff lea -0x1(%eax),%edx 80104678: 83 fa 14 cmp $0x14,%edx 8010467b: 77 1b ja 80104698 <syscall+0x38> 8010467d: 8b 14 85 c0 72 10 80 mov -0x7fef8d40(,%eax,4),%edx 80104684: 85 d2 test %edx,%edx 80104686: 74 10 je 80104698 <syscall+0x38> curproc->tf->eax = syscalls[num](); 80104688: ff d2 call *%edx 8010468a: 89 46 1c mov %eax,0x1c(%esi) } else { cprintf("%d %s: unknown sys call %d\n", curproc->pid, curproc->name, num); curproc->tf->eax = -1; } } 8010468d: 83 c4 10 add $0x10,%esp 80104690: 5b pop %ebx 80104691: 5e pop %esi 80104692: 5d pop %ebp 80104693: c3 ret 80104694: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi cprintf("%d %s: unknown sys call %d\n", 80104698: 89 44 24 0c mov %eax,0xc(%esp) curproc->pid, curproc->name, num); 8010469c: 8d 43 6c lea 0x6c(%ebx),%eax 8010469f: 89 44 24 08 mov %eax,0x8(%esp) cprintf("%d %s: unknown sys call %d\n", 801046a3: 8b 43 10 mov 0x10(%ebx),%eax 801046a6: c7 04 24 91 72 10 80 movl $0x80107291,(%esp) 801046ad: 89 44 24 04 mov %eax,0x4(%esp) 801046b1: e8 9a bf ff ff call 80100650 <cprintf> curproc->tf->eax = -1; 801046b6: 8b 43 18 mov 0x18(%ebx),%eax 801046b9: c7 40 1c ff ff ff ff movl $0xffffffff,0x1c(%eax) } 801046c0: 83 c4 10 add $0x10,%esp 801046c3: 5b pop %ebx 801046c4: 5e pop %esi 801046c5: 5d pop %ebp 801046c6: c3 ret 801046c7: 66 90 xchg %ax,%ax 801046c9: 66 90 xchg %ax,%ax 801046cb: 66 90 xchg %ax,%ax 801046cd: 66 90 xchg %ax,%ax 801046cf: 90 nop 801046d0 <fdalloc>: // Allocate a file descriptor for the given file. // Takes over file reference from caller on success. static int fdalloc(struct file *f) { 801046d0: 55 push %ebp 801046d1: 89 e5 mov %esp,%ebp 801046d3: 53 push %ebx 801046d4: 89 c3 mov %eax,%ebx 801046d6: 83 ec 04 sub $0x4,%esp int fd; struct proc *curproc = myproc(); 801046d9: e8 c2 ef ff ff call 801036a0 <myproc> for(fd = 0; fd < NOFILE; fd++){ 801046de: 31 d2 xor %edx,%edx if(curproc->ofile[fd] == 0){ 801046e0: 8b 4c 90 28 mov 0x28(%eax,%edx,4),%ecx 801046e4: 85 c9 test %ecx,%ecx 801046e6: 74 18 je 80104700 <fdalloc+0x30> for(fd = 0; fd < NOFILE; fd++){ 801046e8: 83 c2 01 add $0x1,%edx 801046eb: 83 fa 10 cmp $0x10,%edx 801046ee: 75 f0 jne 801046e0 <fdalloc+0x10> curproc->ofile[fd] = f; return fd; } } return -1; } 801046f0: 83 c4 04 add $0x4,%esp return -1; 801046f3: b8 ff ff ff ff mov $0xffffffff,%eax } 801046f8: 5b pop %ebx 801046f9: 5d pop %ebp 801046fa: c3 ret 801046fb: 90 nop 801046fc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi curproc->ofile[fd] = f; 80104700: 89 5c 90 28 mov %ebx,0x28(%eax,%edx,4) } 80104704: 83 c4 04 add $0x4,%esp return fd; 80104707: 89 d0 mov %edx,%eax } 80104709: 5b pop %ebx 8010470a: 5d pop %ebp 8010470b: c3 ret 8010470c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104710 <create>: return -1; } static struct inode* create(char *path, short type, short major, short minor) { 80104710: 55 push %ebp 80104711: 89 e5 mov %esp,%ebp 80104713: 57 push %edi 80104714: 56 push %esi 80104715: 53 push %ebx 80104716: 83 ec 3c sub $0x3c,%esp 80104719: 89 4d d0 mov %ecx,-0x30(%ebp) 8010471c: 8b 4d 08 mov 0x8(%ebp),%ecx struct inode *ip, *dp; char name[DIRSIZ]; if((dp = nameiparent(path, name)) == 0) 8010471f: 8d 5d da lea -0x26(%ebp),%ebx 80104722: 89 5c 24 04 mov %ebx,0x4(%esp) 80104726: 89 04 24 mov %eax,(%esp) { 80104729: 89 55 d4 mov %edx,-0x2c(%ebp) 8010472c: 89 4d cc mov %ecx,-0x34(%ebp) if((dp = nameiparent(path, name)) == 0) 8010472f: e8 ec d7 ff ff call 80101f20 <nameiparent> 80104734: 85 c0 test %eax,%eax 80104736: 89 c7 mov %eax,%edi 80104738: 0f 84 da 00 00 00 je 80104818 <create+0x108> return 0; ilock(dp); 8010473e: 89 04 24 mov %eax,(%esp) 80104741: e8 6a cf ff ff call 801016b0 <ilock> if((ip = dirlookup(dp, name, 0)) != 0){ 80104746: c7 44 24 08 00 00 00 movl $0x0,0x8(%esp) 8010474d: 00 8010474e: 89 5c 24 04 mov %ebx,0x4(%esp) 80104752: 89 3c 24 mov %edi,(%esp) 80104755: e8 66 d4 ff ff call 80101bc0 <dirlookup> 8010475a: 85 c0 test %eax,%eax 8010475c: 89 c6 mov %eax,%esi 8010475e: 74 40 je 801047a0 <create+0x90> iunlockput(dp); 80104760: 89 3c 24 mov %edi,(%esp) 80104763: e8 a8 d1 ff ff call 80101910 <iunlockput> ilock(ip); 80104768: 89 34 24 mov %esi,(%esp) 8010476b: e8 40 cf ff ff call 801016b0 <ilock> if(type == T_FILE && ip->type == T_FILE) 80104770: 66 83 7d d4 02 cmpw $0x2,-0x2c(%ebp) 80104775: 75 11 jne 80104788 <create+0x78> 80104777: 66 83 7e 50 02 cmpw $0x2,0x50(%esi) 8010477c: 89 f0 mov %esi,%eax 8010477e: 75 08 jne 80104788 <create+0x78> panic("create: dirlink"); iunlockput(dp); return ip; } 80104780: 83 c4 3c add $0x3c,%esp 80104783: 5b pop %ebx 80104784: 5e pop %esi 80104785: 5f pop %edi 80104786: 5d pop %ebp 80104787: c3 ret iunlockput(ip); 80104788: 89 34 24 mov %esi,(%esp) 8010478b: e8 80 d1 ff ff call 80101910 <iunlockput> } 80104790: 83 c4 3c add $0x3c,%esp return 0; 80104793: 31 c0 xor %eax,%eax } 80104795: 5b pop %ebx 80104796: 5e pop %esi 80104797: 5f pop %edi 80104798: 5d pop %ebp 80104799: c3 ret 8010479a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if((ip = ialloc(dp->dev, type)) == 0) 801047a0: 0f bf 45 d4 movswl -0x2c(%ebp),%eax 801047a4: 89 44 24 04 mov %eax,0x4(%esp) 801047a8: 8b 07 mov (%edi),%eax 801047aa: 89 04 24 mov %eax,(%esp) 801047ad: e8 6e cd ff ff call 80101520 <ialloc> 801047b2: 85 c0 test %eax,%eax 801047b4: 89 c6 mov %eax,%esi 801047b6: 0f 84 bf 00 00 00 je 8010487b <create+0x16b> ilock(ip); 801047bc: 89 04 24 mov %eax,(%esp) 801047bf: e8 ec ce ff ff call 801016b0 <ilock> ip->major = major; 801047c4: 0f b7 45 d0 movzwl -0x30(%ebp),%eax 801047c8: 66 89 46 52 mov %ax,0x52(%esi) ip->minor = minor; 801047cc: 0f b7 45 cc movzwl -0x34(%ebp),%eax 801047d0: 66 89 46 54 mov %ax,0x54(%esi) ip->nlink = 1; 801047d4: b8 01 00 00 00 mov $0x1,%eax 801047d9: 66 89 46 56 mov %ax,0x56(%esi) iupdate(ip); 801047dd: 89 34 24 mov %esi,(%esp) 801047e0: e8 0b ce ff ff call 801015f0 <iupdate> if(type == T_DIR){ // Create . and .. entries. 801047e5: 66 83 7d d4 01 cmpw $0x1,-0x2c(%ebp) 801047ea: 74 34 je 80104820 <create+0x110> if(dirlink(dp, name, ip->inum) < 0) 801047ec: 8b 46 04 mov 0x4(%esi),%eax 801047ef: 89 5c 24 04 mov %ebx,0x4(%esp) 801047f3: 89 3c 24 mov %edi,(%esp) 801047f6: 89 44 24 08 mov %eax,0x8(%esp) 801047fa: e8 21 d6 ff ff call 80101e20 <dirlink> 801047ff: 85 c0 test %eax,%eax 80104801: 78 6c js 8010486f <create+0x15f> iunlockput(dp); 80104803: 89 3c 24 mov %edi,(%esp) 80104806: e8 05 d1 ff ff call 80101910 <iunlockput> } 8010480b: 83 c4 3c add $0x3c,%esp return ip; 8010480e: 89 f0 mov %esi,%eax } 80104810: 5b pop %ebx 80104811: 5e pop %esi 80104812: 5f pop %edi 80104813: 5d pop %ebp 80104814: c3 ret 80104815: 8d 76 00 lea 0x0(%esi),%esi return 0; 80104818: 31 c0 xor %eax,%eax 8010481a: e9 61 ff ff ff jmp 80104780 <create+0x70> 8010481f: 90 nop dp->nlink++; // for ".." 80104820: 66 83 47 56 01 addw $0x1,0x56(%edi) iupdate(dp); 80104825: 89 3c 24 mov %edi,(%esp) 80104828: e8 c3 cd ff ff call 801015f0 <iupdate> if(dirlink(ip, ".", ip->inum) < 0 || dirlink(ip, "..", dp->inum) < 0) 8010482d: 8b 46 04 mov 0x4(%esi),%eax 80104830: c7 44 24 04 34 73 10 movl $0x80107334,0x4(%esp) 80104837: 80 80104838: 89 34 24 mov %esi,(%esp) 8010483b: 89 44 24 08 mov %eax,0x8(%esp) 8010483f: e8 dc d5 ff ff call 80101e20 <dirlink> 80104844: 85 c0 test %eax,%eax 80104846: 78 1b js 80104863 <create+0x153> 80104848: 8b 47 04 mov 0x4(%edi),%eax 8010484b: c7 44 24 04 33 73 10 movl $0x80107333,0x4(%esp) 80104852: 80 80104853: 89 34 24 mov %esi,(%esp) 80104856: 89 44 24 08 mov %eax,0x8(%esp) 8010485a: e8 c1 d5 ff ff call 80101e20 <dirlink> 8010485f: 85 c0 test %eax,%eax 80104861: 79 89 jns 801047ec <create+0xdc> panic("create dots"); 80104863: c7 04 24 27 73 10 80 movl $0x80107327,(%esp) 8010486a: e8 f1 ba ff ff call 80100360 <panic> panic("create: dirlink"); 8010486f: c7 04 24 36 73 10 80 movl $0x80107336,(%esp) 80104876: e8 e5 ba ff ff call 80100360 <panic> panic("create: ialloc"); 8010487b: c7 04 24 18 73 10 80 movl $0x80107318,(%esp) 80104882: e8 d9 ba ff ff call 80100360 <panic> 80104887: 89 f6 mov %esi,%esi 80104889: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104890 <argfd.constprop.0>: argfd(int n, int *pfd, struct file **pf) 80104890: 55 push %ebp 80104891: 89 e5 mov %esp,%ebp 80104893: 56 push %esi 80104894: 89 c6 mov %eax,%esi 80104896: 53 push %ebx 80104897: 89 d3 mov %edx,%ebx 80104899: 83 ec 20 sub $0x20,%esp if(argint(n, &fd) < 0) 8010489c: 8d 45 f4 lea -0xc(%ebp),%eax 8010489f: 89 44 24 04 mov %eax,0x4(%esp) 801048a3: c7 04 24 00 00 00 00 movl $0x0,(%esp) 801048aa: e8 e1 fc ff ff call 80104590 <argint> 801048af: 85 c0 test %eax,%eax 801048b1: 78 2d js 801048e0 <argfd.constprop.0+0x50> if(fd < 0 || fd >= NOFILE || (f=myproc()->ofile[fd]) == 0) 801048b3: 83 7d f4 0f cmpl $0xf,-0xc(%ebp) 801048b7: 77 27 ja 801048e0 <argfd.constprop.0+0x50> 801048b9: e8 e2 ed ff ff call 801036a0 <myproc> 801048be: 8b 55 f4 mov -0xc(%ebp),%edx 801048c1: 8b 44 90 28 mov 0x28(%eax,%edx,4),%eax 801048c5: 85 c0 test %eax,%eax 801048c7: 74 17 je 801048e0 <argfd.constprop.0+0x50> if(pfd) 801048c9: 85 f6 test %esi,%esi 801048cb: 74 02 je 801048cf <argfd.constprop.0+0x3f> *pfd = fd; 801048cd: 89 16 mov %edx,(%esi) if(pf) 801048cf: 85 db test %ebx,%ebx 801048d1: 74 1d je 801048f0 <argfd.constprop.0+0x60> *pf = f; 801048d3: 89 03 mov %eax,(%ebx) return 0; 801048d5: 31 c0 xor %eax,%eax } 801048d7: 83 c4 20 add $0x20,%esp 801048da: 5b pop %ebx 801048db: 5e pop %esi 801048dc: 5d pop %ebp 801048dd: c3 ret 801048de: 66 90 xchg %ax,%ax 801048e0: 83 c4 20 add $0x20,%esp return -1; 801048e3: b8 ff ff ff ff mov $0xffffffff,%eax } 801048e8: 5b pop %ebx 801048e9: 5e pop %esi 801048ea: 5d pop %ebp 801048eb: c3 ret 801048ec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return 0; 801048f0: 31 c0 xor %eax,%eax 801048f2: eb e3 jmp 801048d7 <argfd.constprop.0+0x47> 801048f4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801048fa: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80104900 <sys_dup>: { 80104900: 55 push %ebp if(argfd(0, 0, &f) < 0) 80104901: 31 c0 xor %eax,%eax { 80104903: 89 e5 mov %esp,%ebp 80104905: 53 push %ebx 80104906: 83 ec 24 sub $0x24,%esp if(argfd(0, 0, &f) < 0) 80104909: 8d 55 f4 lea -0xc(%ebp),%edx 8010490c: e8 7f ff ff ff call 80104890 <argfd.constprop.0> 80104911: 85 c0 test %eax,%eax 80104913: 78 23 js 80104938 <sys_dup+0x38> if((fd=fdalloc(f)) < 0) 80104915: 8b 45 f4 mov -0xc(%ebp),%eax 80104918: e8 b3 fd ff ff call 801046d0 <fdalloc> 8010491d: 85 c0 test %eax,%eax 8010491f: 89 c3 mov %eax,%ebx 80104921: 78 15 js 80104938 <sys_dup+0x38> filedup(f); 80104923: 8b 45 f4 mov -0xc(%ebp),%eax 80104926: 89 04 24 mov %eax,(%esp) 80104929: e8 b2 c4 ff ff call 80100de0 <filedup> return fd; 8010492e: 89 d8 mov %ebx,%eax } 80104930: 83 c4 24 add $0x24,%esp 80104933: 5b pop %ebx 80104934: 5d pop %ebp 80104935: c3 ret 80104936: 66 90 xchg %ax,%ax return -1; 80104938: b8 ff ff ff ff mov $0xffffffff,%eax 8010493d: eb f1 jmp 80104930 <sys_dup+0x30> 8010493f: 90 nop 80104940 <sys_read>: { 80104940: 55 push %ebp if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) 80104941: 31 c0 xor %eax,%eax { 80104943: 89 e5 mov %esp,%ebp 80104945: 83 ec 28 sub $0x28,%esp if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) 80104948: 8d 55 ec lea -0x14(%ebp),%edx 8010494b: e8 40 ff ff ff call 80104890 <argfd.constprop.0> 80104950: 85 c0 test %eax,%eax 80104952: 78 54 js 801049a8 <sys_read+0x68> 80104954: 8d 45 f0 lea -0x10(%ebp),%eax 80104957: 89 44 24 04 mov %eax,0x4(%esp) 8010495b: c7 04 24 02 00 00 00 movl $0x2,(%esp) 80104962: e8 29 fc ff ff call 80104590 <argint> 80104967: 85 c0 test %eax,%eax 80104969: 78 3d js 801049a8 <sys_read+0x68> 8010496b: 8b 45 f0 mov -0x10(%ebp),%eax 8010496e: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80104975: 89 44 24 08 mov %eax,0x8(%esp) 80104979: 8d 45 f4 lea -0xc(%ebp),%eax 8010497c: 89 44 24 04 mov %eax,0x4(%esp) 80104980: e8 3b fc ff ff call 801045c0 <argptr> 80104985: 85 c0 test %eax,%eax 80104987: 78 1f js 801049a8 <sys_read+0x68> return fileread(f, p, n); 80104989: 8b 45 f0 mov -0x10(%ebp),%eax 8010498c: 89 44 24 08 mov %eax,0x8(%esp) 80104990: 8b 45 f4 mov -0xc(%ebp),%eax 80104993: 89 44 24 04 mov %eax,0x4(%esp) 80104997: 8b 45 ec mov -0x14(%ebp),%eax 8010499a: 89 04 24 mov %eax,(%esp) 8010499d: e8 9e c5 ff ff call 80100f40 <fileread> } 801049a2: c9 leave 801049a3: c3 ret 801049a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return -1; 801049a8: b8 ff ff ff ff mov $0xffffffff,%eax } 801049ad: c9 leave 801049ae: c3 ret 801049af: 90 nop 801049b0 <sys_write>: { 801049b0: 55 push %ebp if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) 801049b1: 31 c0 xor %eax,%eax { 801049b3: 89 e5 mov %esp,%ebp 801049b5: 83 ec 28 sub $0x28,%esp if(argfd(0, 0, &f) < 0 || argint(2, &n) < 0 || argptr(1, &p, n) < 0) 801049b8: 8d 55 ec lea -0x14(%ebp),%edx 801049bb: e8 d0 fe ff ff call 80104890 <argfd.constprop.0> 801049c0: 85 c0 test %eax,%eax 801049c2: 78 54 js 80104a18 <sys_write+0x68> 801049c4: 8d 45 f0 lea -0x10(%ebp),%eax 801049c7: 89 44 24 04 mov %eax,0x4(%esp) 801049cb: c7 04 24 02 00 00 00 movl $0x2,(%esp) 801049d2: e8 b9 fb ff ff call 80104590 <argint> 801049d7: 85 c0 test %eax,%eax 801049d9: 78 3d js 80104a18 <sys_write+0x68> 801049db: 8b 45 f0 mov -0x10(%ebp),%eax 801049de: c7 04 24 01 00 00 00 movl $0x1,(%esp) 801049e5: 89 44 24 08 mov %eax,0x8(%esp) 801049e9: 8d 45 f4 lea -0xc(%ebp),%eax 801049ec: 89 44 24 04 mov %eax,0x4(%esp) 801049f0: e8 cb fb ff ff call 801045c0 <argptr> 801049f5: 85 c0 test %eax,%eax 801049f7: 78 1f js 80104a18 <sys_write+0x68> return filewrite(f, p, n); 801049f9: 8b 45 f0 mov -0x10(%ebp),%eax 801049fc: 89 44 24 08 mov %eax,0x8(%esp) 80104a00: 8b 45 f4 mov -0xc(%ebp),%eax 80104a03: 89 44 24 04 mov %eax,0x4(%esp) 80104a07: 8b 45 ec mov -0x14(%ebp),%eax 80104a0a: 89 04 24 mov %eax,(%esp) 80104a0d: e8 ce c5 ff ff call 80100fe0 <filewrite> } 80104a12: c9 leave 80104a13: c3 ret 80104a14: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return -1; 80104a18: b8 ff ff ff ff mov $0xffffffff,%eax } 80104a1d: c9 leave 80104a1e: c3 ret 80104a1f: 90 nop 80104a20 <sys_close>: { 80104a20: 55 push %ebp 80104a21: 89 e5 mov %esp,%ebp 80104a23: 83 ec 28 sub $0x28,%esp if(argfd(0, &fd, &f) < 0) 80104a26: 8d 55 f4 lea -0xc(%ebp),%edx 80104a29: 8d 45 f0 lea -0x10(%ebp),%eax 80104a2c: e8 5f fe ff ff call 80104890 <argfd.constprop.0> 80104a31: 85 c0 test %eax,%eax 80104a33: 78 23 js 80104a58 <sys_close+0x38> myproc()->ofile[fd] = 0; 80104a35: e8 66 ec ff ff call 801036a0 <myproc> 80104a3a: 8b 55 f0 mov -0x10(%ebp),%edx 80104a3d: c7 44 90 28 00 00 00 movl $0x0,0x28(%eax,%edx,4) 80104a44: 00 fileclose(f); 80104a45: 8b 45 f4 mov -0xc(%ebp),%eax 80104a48: 89 04 24 mov %eax,(%esp) 80104a4b: e8 e0 c3 ff ff call 80100e30 <fileclose> return 0; 80104a50: 31 c0 xor %eax,%eax } 80104a52: c9 leave 80104a53: c3 ret 80104a54: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return -1; 80104a58: b8 ff ff ff ff mov $0xffffffff,%eax } 80104a5d: c9 leave 80104a5e: c3 ret 80104a5f: 90 nop 80104a60 <sys_fstat>: { 80104a60: 55 push %ebp if(argfd(0, 0, &f) < 0 || argptr(1, (void*)&st, sizeof(*st)) < 0) 80104a61: 31 c0 xor %eax,%eax { 80104a63: 89 e5 mov %esp,%ebp 80104a65: 83 ec 28 sub $0x28,%esp if(argfd(0, 0, &f) < 0 || argptr(1, (void*)&st, sizeof(*st)) < 0) 80104a68: 8d 55 f0 lea -0x10(%ebp),%edx 80104a6b: e8 20 fe ff ff call 80104890 <argfd.constprop.0> 80104a70: 85 c0 test %eax,%eax 80104a72: 78 34 js 80104aa8 <sys_fstat+0x48> 80104a74: 8d 45 f4 lea -0xc(%ebp),%eax 80104a77: c7 44 24 08 14 00 00 movl $0x14,0x8(%esp) 80104a7e: 00 80104a7f: 89 44 24 04 mov %eax,0x4(%esp) 80104a83: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80104a8a: e8 31 fb ff ff call 801045c0 <argptr> 80104a8f: 85 c0 test %eax,%eax 80104a91: 78 15 js 80104aa8 <sys_fstat+0x48> return filestat(f, st); 80104a93: 8b 45 f4 mov -0xc(%ebp),%eax 80104a96: 89 44 24 04 mov %eax,0x4(%esp) 80104a9a: 8b 45 f0 mov -0x10(%ebp),%eax 80104a9d: 89 04 24 mov %eax,(%esp) 80104aa0: e8 4b c4 ff ff call 80100ef0 <filestat> } 80104aa5: c9 leave 80104aa6: c3 ret 80104aa7: 90 nop return -1; 80104aa8: b8 ff ff ff ff mov $0xffffffff,%eax } 80104aad: c9 leave 80104aae: c3 ret 80104aaf: 90 nop 80104ab0 <sys_link>: { 80104ab0: 55 push %ebp 80104ab1: 89 e5 mov %esp,%ebp 80104ab3: 57 push %edi 80104ab4: 56 push %esi 80104ab5: 53 push %ebx 80104ab6: 83 ec 3c sub $0x3c,%esp if(argstr(0, &old) < 0 || argstr(1, &new) < 0) 80104ab9: 8d 45 d4 lea -0x2c(%ebp),%eax 80104abc: 89 44 24 04 mov %eax,0x4(%esp) 80104ac0: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80104ac7: e8 54 fb ff ff call 80104620 <argstr> 80104acc: 85 c0 test %eax,%eax 80104ace: 0f 88 e6 00 00 00 js 80104bba <sys_link+0x10a> 80104ad4: 8d 45 d0 lea -0x30(%ebp),%eax 80104ad7: 89 44 24 04 mov %eax,0x4(%esp) 80104adb: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80104ae2: e8 39 fb ff ff call 80104620 <argstr> 80104ae7: 85 c0 test %eax,%eax 80104ae9: 0f 88 cb 00 00 00 js 80104bba <sys_link+0x10a> begin_op(); 80104aef: e8 1c e0 ff ff call 80102b10 <begin_op> if((ip = namei(old)) == 0){ 80104af4: 8b 45 d4 mov -0x2c(%ebp),%eax 80104af7: 89 04 24 mov %eax,(%esp) 80104afa: e8 01 d4 ff ff call 80101f00 <namei> 80104aff: 85 c0 test %eax,%eax 80104b01: 89 c3 mov %eax,%ebx 80104b03: 0f 84 ac 00 00 00 je 80104bb5 <sys_link+0x105> ilock(ip); 80104b09: 89 04 24 mov %eax,(%esp) 80104b0c: e8 9f cb ff ff call 801016b0 <ilock> if(ip->type == T_DIR){ 80104b11: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) 80104b16: 0f 84 91 00 00 00 je 80104bad <sys_link+0xfd> ip->nlink++; 80104b1c: 66 83 43 56 01 addw $0x1,0x56(%ebx) if((dp = nameiparent(new, name)) == 0) 80104b21: 8d 7d da lea -0x26(%ebp),%edi iupdate(ip); 80104b24: 89 1c 24 mov %ebx,(%esp) 80104b27: e8 c4 ca ff ff call 801015f0 <iupdate> iunlock(ip); 80104b2c: 89 1c 24 mov %ebx,(%esp) 80104b2f: e8 5c cc ff ff call 80101790 <iunlock> if((dp = nameiparent(new, name)) == 0) 80104b34: 8b 45 d0 mov -0x30(%ebp),%eax 80104b37: 89 7c 24 04 mov %edi,0x4(%esp) 80104b3b: 89 04 24 mov %eax,(%esp) 80104b3e: e8 dd d3 ff ff call 80101f20 <nameiparent> 80104b43: 85 c0 test %eax,%eax 80104b45: 89 c6 mov %eax,%esi 80104b47: 74 4f je 80104b98 <sys_link+0xe8> ilock(dp); 80104b49: 89 04 24 mov %eax,(%esp) 80104b4c: e8 5f cb ff ff call 801016b0 <ilock> if(dp->dev != ip->dev || dirlink(dp, name, ip->inum) < 0){ 80104b51: 8b 03 mov (%ebx),%eax 80104b53: 39 06 cmp %eax,(%esi) 80104b55: 75 39 jne 80104b90 <sys_link+0xe0> 80104b57: 8b 43 04 mov 0x4(%ebx),%eax 80104b5a: 89 7c 24 04 mov %edi,0x4(%esp) 80104b5e: 89 34 24 mov %esi,(%esp) 80104b61: 89 44 24 08 mov %eax,0x8(%esp) 80104b65: e8 b6 d2 ff ff call 80101e20 <dirlink> 80104b6a: 85 c0 test %eax,%eax 80104b6c: 78 22 js 80104b90 <sys_link+0xe0> iunlockput(dp); 80104b6e: 89 34 24 mov %esi,(%esp) 80104b71: e8 9a cd ff ff call 80101910 <iunlockput> iput(ip); 80104b76: 89 1c 24 mov %ebx,(%esp) 80104b79: e8 52 cc ff ff call 801017d0 <iput> end_op(); 80104b7e: e8 fd df ff ff call 80102b80 <end_op> } 80104b83: 83 c4 3c add $0x3c,%esp return 0; 80104b86: 31 c0 xor %eax,%eax } 80104b88: 5b pop %ebx 80104b89: 5e pop %esi 80104b8a: 5f pop %edi 80104b8b: 5d pop %ebp 80104b8c: c3 ret 80104b8d: 8d 76 00 lea 0x0(%esi),%esi iunlockput(dp); 80104b90: 89 34 24 mov %esi,(%esp) 80104b93: e8 78 cd ff ff call 80101910 <iunlockput> ilock(ip); 80104b98: 89 1c 24 mov %ebx,(%esp) 80104b9b: e8 10 cb ff ff call 801016b0 <ilock> ip->nlink--; 80104ba0: 66 83 6b 56 01 subw $0x1,0x56(%ebx) iupdate(ip); 80104ba5: 89 1c 24 mov %ebx,(%esp) 80104ba8: e8 43 ca ff ff call 801015f0 <iupdate> iunlockput(ip); 80104bad: 89 1c 24 mov %ebx,(%esp) 80104bb0: e8 5b cd ff ff call 80101910 <iunlockput> end_op(); 80104bb5: e8 c6 df ff ff call 80102b80 <end_op> } 80104bba: 83 c4 3c add $0x3c,%esp return -1; 80104bbd: b8 ff ff ff ff mov $0xffffffff,%eax } 80104bc2: 5b pop %ebx 80104bc3: 5e pop %esi 80104bc4: 5f pop %edi 80104bc5: 5d pop %ebp 80104bc6: c3 ret 80104bc7: 89 f6 mov %esi,%esi 80104bc9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104bd0 <sys_unlink>: { 80104bd0: 55 push %ebp 80104bd1: 89 e5 mov %esp,%ebp 80104bd3: 57 push %edi 80104bd4: 56 push %esi 80104bd5: 53 push %ebx 80104bd6: 83 ec 5c sub $0x5c,%esp if(argstr(0, &path) < 0) 80104bd9: 8d 45 c0 lea -0x40(%ebp),%eax 80104bdc: 89 44 24 04 mov %eax,0x4(%esp) 80104be0: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80104be7: e8 34 fa ff ff call 80104620 <argstr> 80104bec: 85 c0 test %eax,%eax 80104bee: 0f 88 76 01 00 00 js 80104d6a <sys_unlink+0x19a> begin_op(); 80104bf4: e8 17 df ff ff call 80102b10 <begin_op> if((dp = nameiparent(path, name)) == 0){ 80104bf9: 8b 45 c0 mov -0x40(%ebp),%eax 80104bfc: 8d 5d ca lea -0x36(%ebp),%ebx 80104bff: 89 5c 24 04 mov %ebx,0x4(%esp) 80104c03: 89 04 24 mov %eax,(%esp) 80104c06: e8 15 d3 ff ff call 80101f20 <nameiparent> 80104c0b: 85 c0 test %eax,%eax 80104c0d: 89 45 b4 mov %eax,-0x4c(%ebp) 80104c10: 0f 84 4f 01 00 00 je 80104d65 <sys_unlink+0x195> ilock(dp); 80104c16: 8b 75 b4 mov -0x4c(%ebp),%esi 80104c19: 89 34 24 mov %esi,(%esp) 80104c1c: e8 8f ca ff ff call 801016b0 <ilock> if(namecmp(name, ".") == 0 || namecmp(name, "..") == 0) 80104c21: c7 44 24 04 34 73 10 movl $0x80107334,0x4(%esp) 80104c28: 80 80104c29: 89 1c 24 mov %ebx,(%esp) 80104c2c: e8 5f cf ff ff call 80101b90 <namecmp> 80104c31: 85 c0 test %eax,%eax 80104c33: 0f 84 21 01 00 00 je 80104d5a <sys_unlink+0x18a> 80104c39: c7 44 24 04 33 73 10 movl $0x80107333,0x4(%esp) 80104c40: 80 80104c41: 89 1c 24 mov %ebx,(%esp) 80104c44: e8 47 cf ff ff call 80101b90 <namecmp> 80104c49: 85 c0 test %eax,%eax 80104c4b: 0f 84 09 01 00 00 je 80104d5a <sys_unlink+0x18a> if((ip = dirlookup(dp, name, &off)) == 0) 80104c51: 8d 45 c4 lea -0x3c(%ebp),%eax 80104c54: 89 5c 24 04 mov %ebx,0x4(%esp) 80104c58: 89 44 24 08 mov %eax,0x8(%esp) 80104c5c: 89 34 24 mov %esi,(%esp) 80104c5f: e8 5c cf ff ff call 80101bc0 <dirlookup> 80104c64: 85 c0 test %eax,%eax 80104c66: 89 c3 mov %eax,%ebx 80104c68: 0f 84 ec 00 00 00 je 80104d5a <sys_unlink+0x18a> ilock(ip); 80104c6e: 89 04 24 mov %eax,(%esp) 80104c71: e8 3a ca ff ff call 801016b0 <ilock> if(ip->nlink < 1) 80104c76: 66 83 7b 56 00 cmpw $0x0,0x56(%ebx) 80104c7b: 0f 8e 24 01 00 00 jle 80104da5 <sys_unlink+0x1d5> if(ip->type == T_DIR && !isdirempty(ip)){ 80104c81: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) 80104c86: 8d 75 d8 lea -0x28(%ebp),%esi 80104c89: 74 7d je 80104d08 <sys_unlink+0x138> memset(&de, 0, sizeof(de)); 80104c8b: c7 44 24 08 10 00 00 movl $0x10,0x8(%esp) 80104c92: 00 80104c93: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80104c9a: 00 80104c9b: 89 34 24 mov %esi,(%esp) 80104c9e: e8 fd f5 ff ff call 801042a0 <memset> if(writei(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80104ca3: 8b 45 c4 mov -0x3c(%ebp),%eax 80104ca6: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) 80104cad: 00 80104cae: 89 74 24 04 mov %esi,0x4(%esp) 80104cb2: 89 44 24 08 mov %eax,0x8(%esp) 80104cb6: 8b 45 b4 mov -0x4c(%ebp),%eax 80104cb9: 89 04 24 mov %eax,(%esp) 80104cbc: e8 9f cd ff ff call 80101a60 <writei> 80104cc1: 83 f8 10 cmp $0x10,%eax 80104cc4: 0f 85 cf 00 00 00 jne 80104d99 <sys_unlink+0x1c9> if(ip->type == T_DIR){ 80104cca: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) 80104ccf: 0f 84 a3 00 00 00 je 80104d78 <sys_unlink+0x1a8> iunlockput(dp); 80104cd5: 8b 45 b4 mov -0x4c(%ebp),%eax 80104cd8: 89 04 24 mov %eax,(%esp) 80104cdb: e8 30 cc ff ff call 80101910 <iunlockput> ip->nlink--; 80104ce0: 66 83 6b 56 01 subw $0x1,0x56(%ebx) iupdate(ip); 80104ce5: 89 1c 24 mov %ebx,(%esp) 80104ce8: e8 03 c9 ff ff call 801015f0 <iupdate> iunlockput(ip); 80104ced: 89 1c 24 mov %ebx,(%esp) 80104cf0: e8 1b cc ff ff call 80101910 <iunlockput> end_op(); 80104cf5: e8 86 de ff ff call 80102b80 <end_op> } 80104cfa: 83 c4 5c add $0x5c,%esp return 0; 80104cfd: 31 c0 xor %eax,%eax } 80104cff: 5b pop %ebx 80104d00: 5e pop %esi 80104d01: 5f pop %edi 80104d02: 5d pop %ebp 80104d03: c3 ret 80104d04: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi for(off=2*sizeof(de); off<dp->size; off+=sizeof(de)){ 80104d08: 83 7b 58 20 cmpl $0x20,0x58(%ebx) 80104d0c: 0f 86 79 ff ff ff jbe 80104c8b <sys_unlink+0xbb> 80104d12: bf 20 00 00 00 mov $0x20,%edi 80104d17: eb 15 jmp 80104d2e <sys_unlink+0x15e> 80104d19: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104d20: 8d 57 10 lea 0x10(%edi),%edx 80104d23: 3b 53 58 cmp 0x58(%ebx),%edx 80104d26: 0f 83 5f ff ff ff jae 80104c8b <sys_unlink+0xbb> 80104d2c: 89 d7 mov %edx,%edi if(readi(dp, (char*)&de, off, sizeof(de)) != sizeof(de)) 80104d2e: c7 44 24 0c 10 00 00 movl $0x10,0xc(%esp) 80104d35: 00 80104d36: 89 7c 24 08 mov %edi,0x8(%esp) 80104d3a: 89 74 24 04 mov %esi,0x4(%esp) 80104d3e: 89 1c 24 mov %ebx,(%esp) 80104d41: e8 1a cc ff ff call 80101960 <readi> 80104d46: 83 f8 10 cmp $0x10,%eax 80104d49: 75 42 jne 80104d8d <sys_unlink+0x1bd> if(de.inum != 0) 80104d4b: 66 83 7d d8 00 cmpw $0x0,-0x28(%ebp) 80104d50: 74 ce je 80104d20 <sys_unlink+0x150> iunlockput(ip); 80104d52: 89 1c 24 mov %ebx,(%esp) 80104d55: e8 b6 cb ff ff call 80101910 <iunlockput> iunlockput(dp); 80104d5a: 8b 45 b4 mov -0x4c(%ebp),%eax 80104d5d: 89 04 24 mov %eax,(%esp) 80104d60: e8 ab cb ff ff call 80101910 <iunlockput> end_op(); 80104d65: e8 16 de ff ff call 80102b80 <end_op> } 80104d6a: 83 c4 5c add $0x5c,%esp return -1; 80104d6d: b8 ff ff ff ff mov $0xffffffff,%eax } 80104d72: 5b pop %ebx 80104d73: 5e pop %esi 80104d74: 5f pop %edi 80104d75: 5d pop %ebp 80104d76: c3 ret 80104d77: 90 nop dp->nlink--; 80104d78: 8b 45 b4 mov -0x4c(%ebp),%eax 80104d7b: 66 83 68 56 01 subw $0x1,0x56(%eax) iupdate(dp); 80104d80: 89 04 24 mov %eax,(%esp) 80104d83: e8 68 c8 ff ff call 801015f0 <iupdate> 80104d88: e9 48 ff ff ff jmp 80104cd5 <sys_unlink+0x105> panic("isdirempty: readi"); 80104d8d: c7 04 24 58 73 10 80 movl $0x80107358,(%esp) 80104d94: e8 c7 b5 ff ff call 80100360 <panic> panic("unlink: writei"); 80104d99: c7 04 24 6a 73 10 80 movl $0x8010736a,(%esp) 80104da0: e8 bb b5 ff ff call 80100360 <panic> panic("unlink: nlink < 1"); 80104da5: c7 04 24 46 73 10 80 movl $0x80107346,(%esp) 80104dac: e8 af b5 ff ff call 80100360 <panic> 80104db1: eb 0d jmp 80104dc0 <sys_open> 80104db3: 90 nop 80104db4: 90 nop 80104db5: 90 nop 80104db6: 90 nop 80104db7: 90 nop 80104db8: 90 nop 80104db9: 90 nop 80104dba: 90 nop 80104dbb: 90 nop 80104dbc: 90 nop 80104dbd: 90 nop 80104dbe: 90 nop 80104dbf: 90 nop 80104dc0 <sys_open>: int sys_open(void) { 80104dc0: 55 push %ebp 80104dc1: 89 e5 mov %esp,%ebp 80104dc3: 57 push %edi 80104dc4: 56 push %esi 80104dc5: 53 push %ebx 80104dc6: 83 ec 2c sub $0x2c,%esp char *path; int fd, omode; struct file *f; struct inode *ip; if(argstr(0, &path) < 0 || argint(1, &omode) < 0) 80104dc9: 8d 45 e0 lea -0x20(%ebp),%eax 80104dcc: 89 44 24 04 mov %eax,0x4(%esp) 80104dd0: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80104dd7: e8 44 f8 ff ff call 80104620 <argstr> 80104ddc: 85 c0 test %eax,%eax 80104dde: 0f 88 d1 00 00 00 js 80104eb5 <sys_open+0xf5> 80104de4: 8d 45 e4 lea -0x1c(%ebp),%eax 80104de7: 89 44 24 04 mov %eax,0x4(%esp) 80104deb: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80104df2: e8 99 f7 ff ff call 80104590 <argint> 80104df7: 85 c0 test %eax,%eax 80104df9: 0f 88 b6 00 00 00 js 80104eb5 <sys_open+0xf5> return -1; begin_op(); 80104dff: e8 0c dd ff ff call 80102b10 <begin_op> if(omode & O_CREATE){ 80104e04: f6 45 e5 02 testb $0x2,-0x1b(%ebp) 80104e08: 0f 85 82 00 00 00 jne 80104e90 <sys_open+0xd0> if(ip == 0){ end_op(); return -1; } } else { if((ip = namei(path)) == 0){ 80104e0e: 8b 45 e0 mov -0x20(%ebp),%eax 80104e11: 89 04 24 mov %eax,(%esp) 80104e14: e8 e7 d0 ff ff call 80101f00 <namei> 80104e19: 85 c0 test %eax,%eax 80104e1b: 89 c6 mov %eax,%esi 80104e1d: 0f 84 8d 00 00 00 je 80104eb0 <sys_open+0xf0> end_op(); return -1; } ilock(ip); 80104e23: 89 04 24 mov %eax,(%esp) 80104e26: e8 85 c8 ff ff call 801016b0 <ilock> if(ip->type == T_DIR && omode != O_RDONLY){ 80104e2b: 66 83 7e 50 01 cmpw $0x1,0x50(%esi) 80104e30: 0f 84 92 00 00 00 je 80104ec8 <sys_open+0x108> end_op(); return -1; } } if((f = filealloc()) == 0 || (fd = fdalloc(f)) < 0){ 80104e36: e8 35 bf ff ff call 80100d70 <filealloc> 80104e3b: 85 c0 test %eax,%eax 80104e3d: 89 c3 mov %eax,%ebx 80104e3f: 0f 84 93 00 00 00 je 80104ed8 <sys_open+0x118> 80104e45: e8 86 f8 ff ff call 801046d0 <fdalloc> 80104e4a: 85 c0 test %eax,%eax 80104e4c: 89 c7 mov %eax,%edi 80104e4e: 0f 88 94 00 00 00 js 80104ee8 <sys_open+0x128> fileclose(f); iunlockput(ip); end_op(); return -1; } iunlock(ip); 80104e54: 89 34 24 mov %esi,(%esp) 80104e57: e8 34 c9 ff ff call 80101790 <iunlock> end_op(); 80104e5c: e8 1f dd ff ff call 80102b80 <end_op> f->type = FD_INODE; 80104e61: c7 03 02 00 00 00 movl $0x2,(%ebx) f->ip = ip; f->off = 0; f->readable = !(omode & O_WRONLY); 80104e67: 8b 45 e4 mov -0x1c(%ebp),%eax f->ip = ip; 80104e6a: 89 73 10 mov %esi,0x10(%ebx) f->off = 0; 80104e6d: c7 43 14 00 00 00 00 movl $0x0,0x14(%ebx) f->readable = !(omode & O_WRONLY); 80104e74: 89 c2 mov %eax,%edx 80104e76: 83 e2 01 and $0x1,%edx 80104e79: 83 f2 01 xor $0x1,%edx f->writable = (omode & O_WRONLY) || (omode & O_RDWR); 80104e7c: a8 03 test $0x3,%al f->readable = !(omode & O_WRONLY); 80104e7e: 88 53 08 mov %dl,0x8(%ebx) return fd; 80104e81: 89 f8 mov %edi,%eax f->writable = (omode & O_WRONLY) || (omode & O_RDWR); 80104e83: 0f 95 43 09 setne 0x9(%ebx) } 80104e87: 83 c4 2c add $0x2c,%esp 80104e8a: 5b pop %ebx 80104e8b: 5e pop %esi 80104e8c: 5f pop %edi 80104e8d: 5d pop %ebp 80104e8e: c3 ret 80104e8f: 90 nop ip = create(path, T_FILE, 0, 0); 80104e90: 8b 45 e0 mov -0x20(%ebp),%eax 80104e93: 31 c9 xor %ecx,%ecx 80104e95: ba 02 00 00 00 mov $0x2,%edx 80104e9a: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80104ea1: e8 6a f8 ff ff call 80104710 <create> if(ip == 0){ 80104ea6: 85 c0 test %eax,%eax ip = create(path, T_FILE, 0, 0); 80104ea8: 89 c6 mov %eax,%esi if(ip == 0){ 80104eaa: 75 8a jne 80104e36 <sys_open+0x76> 80104eac: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi end_op(); 80104eb0: e8 cb dc ff ff call 80102b80 <end_op> } 80104eb5: 83 c4 2c add $0x2c,%esp return -1; 80104eb8: b8 ff ff ff ff mov $0xffffffff,%eax } 80104ebd: 5b pop %ebx 80104ebe: 5e pop %esi 80104ebf: 5f pop %edi 80104ec0: 5d pop %ebp 80104ec1: c3 ret 80104ec2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(ip->type == T_DIR && omode != O_RDONLY){ 80104ec8: 8b 45 e4 mov -0x1c(%ebp),%eax 80104ecb: 85 c0 test %eax,%eax 80104ecd: 0f 84 63 ff ff ff je 80104e36 <sys_open+0x76> 80104ed3: 90 nop 80104ed4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi iunlockput(ip); 80104ed8: 89 34 24 mov %esi,(%esp) 80104edb: e8 30 ca ff ff call 80101910 <iunlockput> 80104ee0: eb ce jmp 80104eb0 <sys_open+0xf0> 80104ee2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi fileclose(f); 80104ee8: 89 1c 24 mov %ebx,(%esp) 80104eeb: e8 40 bf ff ff call 80100e30 <fileclose> 80104ef0: eb e6 jmp 80104ed8 <sys_open+0x118> 80104ef2: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80104ef9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80104f00 <sys_mkdir>: int sys_mkdir(void) { 80104f00: 55 push %ebp 80104f01: 89 e5 mov %esp,%ebp 80104f03: 83 ec 28 sub $0x28,%esp char *path; struct inode *ip; begin_op(); 80104f06: e8 05 dc ff ff call 80102b10 <begin_op> if(argstr(0, &path) < 0 || (ip = create(path, T_DIR, 0, 0)) == 0){ 80104f0b: 8d 45 f4 lea -0xc(%ebp),%eax 80104f0e: 89 44 24 04 mov %eax,0x4(%esp) 80104f12: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80104f19: e8 02 f7 ff ff call 80104620 <argstr> 80104f1e: 85 c0 test %eax,%eax 80104f20: 78 2e js 80104f50 <sys_mkdir+0x50> 80104f22: 8b 45 f4 mov -0xc(%ebp),%eax 80104f25: 31 c9 xor %ecx,%ecx 80104f27: ba 01 00 00 00 mov $0x1,%edx 80104f2c: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80104f33: e8 d8 f7 ff ff call 80104710 <create> 80104f38: 85 c0 test %eax,%eax 80104f3a: 74 14 je 80104f50 <sys_mkdir+0x50> end_op(); return -1; } iunlockput(ip); 80104f3c: 89 04 24 mov %eax,(%esp) 80104f3f: e8 cc c9 ff ff call 80101910 <iunlockput> end_op(); 80104f44: e8 37 dc ff ff call 80102b80 <end_op> return 0; 80104f49: 31 c0 xor %eax,%eax } 80104f4b: c9 leave 80104f4c: c3 ret 80104f4d: 8d 76 00 lea 0x0(%esi),%esi end_op(); 80104f50: e8 2b dc ff ff call 80102b80 <end_op> return -1; 80104f55: b8 ff ff ff ff mov $0xffffffff,%eax } 80104f5a: c9 leave 80104f5b: c3 ret 80104f5c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104f60 <sys_mknod>: int sys_mknod(void) { 80104f60: 55 push %ebp 80104f61: 89 e5 mov %esp,%ebp 80104f63: 83 ec 28 sub $0x28,%esp struct inode *ip; char *path; int major, minor; begin_op(); 80104f66: e8 a5 db ff ff call 80102b10 <begin_op> if((argstr(0, &path)) < 0 || 80104f6b: 8d 45 ec lea -0x14(%ebp),%eax 80104f6e: 89 44 24 04 mov %eax,0x4(%esp) 80104f72: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80104f79: e8 a2 f6 ff ff call 80104620 <argstr> 80104f7e: 85 c0 test %eax,%eax 80104f80: 78 5e js 80104fe0 <sys_mknod+0x80> argint(1, &major) < 0 || 80104f82: 8d 45 f0 lea -0x10(%ebp),%eax 80104f85: 89 44 24 04 mov %eax,0x4(%esp) 80104f89: c7 04 24 01 00 00 00 movl $0x1,(%esp) 80104f90: e8 fb f5 ff ff call 80104590 <argint> if((argstr(0, &path)) < 0 || 80104f95: 85 c0 test %eax,%eax 80104f97: 78 47 js 80104fe0 <sys_mknod+0x80> argint(2, &minor) < 0 || 80104f99: 8d 45 f4 lea -0xc(%ebp),%eax 80104f9c: 89 44 24 04 mov %eax,0x4(%esp) 80104fa0: c7 04 24 02 00 00 00 movl $0x2,(%esp) 80104fa7: e8 e4 f5 ff ff call 80104590 <argint> argint(1, &major) < 0 || 80104fac: 85 c0 test %eax,%eax 80104fae: 78 30 js 80104fe0 <sys_mknod+0x80> (ip = create(path, T_DEV, major, minor)) == 0){ 80104fb0: 0f bf 45 f4 movswl -0xc(%ebp),%eax argint(2, &minor) < 0 || 80104fb4: ba 03 00 00 00 mov $0x3,%edx (ip = create(path, T_DEV, major, minor)) == 0){ 80104fb9: 0f bf 4d f0 movswl -0x10(%ebp),%ecx 80104fbd: 89 04 24 mov %eax,(%esp) argint(2, &minor) < 0 || 80104fc0: 8b 45 ec mov -0x14(%ebp),%eax 80104fc3: e8 48 f7 ff ff call 80104710 <create> 80104fc8: 85 c0 test %eax,%eax 80104fca: 74 14 je 80104fe0 <sys_mknod+0x80> end_op(); return -1; } iunlockput(ip); 80104fcc: 89 04 24 mov %eax,(%esp) 80104fcf: e8 3c c9 ff ff call 80101910 <iunlockput> end_op(); 80104fd4: e8 a7 db ff ff call 80102b80 <end_op> return 0; 80104fd9: 31 c0 xor %eax,%eax } 80104fdb: c9 leave 80104fdc: c3 ret 80104fdd: 8d 76 00 lea 0x0(%esi),%esi end_op(); 80104fe0: e8 9b db ff ff call 80102b80 <end_op> return -1; 80104fe5: b8 ff ff ff ff mov $0xffffffff,%eax } 80104fea: c9 leave 80104feb: c3 ret 80104fec: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80104ff0 <sys_chdir>: int sys_chdir(void) { 80104ff0: 55 push %ebp 80104ff1: 89 e5 mov %esp,%ebp 80104ff3: 56 push %esi 80104ff4: 53 push %ebx 80104ff5: 83 ec 20 sub $0x20,%esp char *path; struct inode *ip; struct proc *curproc = myproc(); 80104ff8: e8 a3 e6 ff ff call 801036a0 <myproc> 80104ffd: 89 c6 mov %eax,%esi begin_op(); 80104fff: e8 0c db ff ff call 80102b10 <begin_op> if(argstr(0, &path) < 0 || (ip = namei(path)) == 0){ 80105004: 8d 45 f4 lea -0xc(%ebp),%eax 80105007: 89 44 24 04 mov %eax,0x4(%esp) 8010500b: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80105012: e8 09 f6 ff ff call 80104620 <argstr> 80105017: 85 c0 test %eax,%eax 80105019: 78 4a js 80105065 <sys_chdir+0x75> 8010501b: 8b 45 f4 mov -0xc(%ebp),%eax 8010501e: 89 04 24 mov %eax,(%esp) 80105021: e8 da ce ff ff call 80101f00 <namei> 80105026: 85 c0 test %eax,%eax 80105028: 89 c3 mov %eax,%ebx 8010502a: 74 39 je 80105065 <sys_chdir+0x75> end_op(); return -1; } ilock(ip); 8010502c: 89 04 24 mov %eax,(%esp) 8010502f: e8 7c c6 ff ff call 801016b0 <ilock> if(ip->type != T_DIR){ 80105034: 66 83 7b 50 01 cmpw $0x1,0x50(%ebx) iunlockput(ip); 80105039: 89 1c 24 mov %ebx,(%esp) if(ip->type != T_DIR){ 8010503c: 75 22 jne 80105060 <sys_chdir+0x70> end_op(); return -1; } iunlock(ip); 8010503e: e8 4d c7 ff ff call 80101790 <iunlock> iput(curproc->cwd); 80105043: 8b 46 68 mov 0x68(%esi),%eax 80105046: 89 04 24 mov %eax,(%esp) 80105049: e8 82 c7 ff ff call 801017d0 <iput> end_op(); 8010504e: e8 2d db ff ff call 80102b80 <end_op> curproc->cwd = ip; return 0; 80105053: 31 c0 xor %eax,%eax curproc->cwd = ip; 80105055: 89 5e 68 mov %ebx,0x68(%esi) } 80105058: 83 c4 20 add $0x20,%esp 8010505b: 5b pop %ebx 8010505c: 5e pop %esi 8010505d: 5d pop %ebp 8010505e: c3 ret 8010505f: 90 nop iunlockput(ip); 80105060: e8 ab c8 ff ff call 80101910 <iunlockput> end_op(); 80105065: e8 16 db ff ff call 80102b80 <end_op> } 8010506a: 83 c4 20 add $0x20,%esp return -1; 8010506d: b8 ff ff ff ff mov $0xffffffff,%eax } 80105072: 5b pop %ebx 80105073: 5e pop %esi 80105074: 5d pop %ebp 80105075: c3 ret 80105076: 8d 76 00 lea 0x0(%esi),%esi 80105079: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105080 <sys_exec>: int sys_exec(void) { 80105080: 55 push %ebp 80105081: 89 e5 mov %esp,%ebp 80105083: 57 push %edi 80105084: 56 push %esi 80105085: 53 push %ebx 80105086: 81 ec ac 00 00 00 sub $0xac,%esp char *path, *argv[MAXARG]; int i; uint uargv, uarg; if(argstr(0, &path) < 0 || argint(1, (int*)&uargv) < 0){ 8010508c: 8d 85 5c ff ff ff lea -0xa4(%ebp),%eax 80105092: 89 44 24 04 mov %eax,0x4(%esp) 80105096: c7 04 24 00 00 00 00 movl $0x0,(%esp) 8010509d: e8 7e f5 ff ff call 80104620 <argstr> 801050a2: 85 c0 test %eax,%eax 801050a4: 0f 88 84 00 00 00 js 8010512e <sys_exec+0xae> 801050aa: 8d 85 60 ff ff ff lea -0xa0(%ebp),%eax 801050b0: 89 44 24 04 mov %eax,0x4(%esp) 801050b4: c7 04 24 01 00 00 00 movl $0x1,(%esp) 801050bb: e8 d0 f4 ff ff call 80104590 <argint> 801050c0: 85 c0 test %eax,%eax 801050c2: 78 6a js 8010512e <sys_exec+0xae> return -1; } memset(argv, 0, sizeof(argv)); 801050c4: 8d 85 68 ff ff ff lea -0x98(%ebp),%eax for(i=0;; i++){ 801050ca: 31 db xor %ebx,%ebx memset(argv, 0, sizeof(argv)); 801050cc: c7 44 24 08 80 00 00 movl $0x80,0x8(%esp) 801050d3: 00 801050d4: 8d b5 68 ff ff ff lea -0x98(%ebp),%esi 801050da: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 801050e1: 00 801050e2: 8d bd 64 ff ff ff lea -0x9c(%ebp),%edi 801050e8: 89 04 24 mov %eax,(%esp) 801050eb: e8 b0 f1 ff ff call 801042a0 <memset> if(i >= NELEM(argv)) return -1; if(fetchint(uargv+4*i, (int*)&uarg) < 0) 801050f0: 8b 85 60 ff ff ff mov -0xa0(%ebp),%eax 801050f6: 89 7c 24 04 mov %edi,0x4(%esp) 801050fa: 8d 04 98 lea (%eax,%ebx,4),%eax 801050fd: 89 04 24 mov %eax,(%esp) 80105100: e8 eb f3 ff ff call 801044f0 <fetchint> 80105105: 85 c0 test %eax,%eax 80105107: 78 25 js 8010512e <sys_exec+0xae> return -1; if(uarg == 0){ 80105109: 8b 85 64 ff ff ff mov -0x9c(%ebp),%eax 8010510f: 85 c0 test %eax,%eax 80105111: 74 2d je 80105140 <sys_exec+0xc0> argv[i] = 0; break; } if(fetchstr(uarg, &argv[i]) < 0) 80105113: 89 74 24 04 mov %esi,0x4(%esp) 80105117: 89 04 24 mov %eax,(%esp) 8010511a: e8 11 f4 ff ff call 80104530 <fetchstr> 8010511f: 85 c0 test %eax,%eax 80105121: 78 0b js 8010512e <sys_exec+0xae> for(i=0;; i++){ 80105123: 83 c3 01 add $0x1,%ebx 80105126: 83 c6 04 add $0x4,%esi if(i >= NELEM(argv)) 80105129: 83 fb 20 cmp $0x20,%ebx 8010512c: 75 c2 jne 801050f0 <sys_exec+0x70> return -1; } return exec(path, argv); } 8010512e: 81 c4 ac 00 00 00 add $0xac,%esp return -1; 80105134: b8 ff ff ff ff mov $0xffffffff,%eax } 80105139: 5b pop %ebx 8010513a: 5e pop %esi 8010513b: 5f pop %edi 8010513c: 5d pop %ebp 8010513d: c3 ret 8010513e: 66 90 xchg %ax,%ax return exec(path, argv); 80105140: 8d 85 68 ff ff ff lea -0x98(%ebp),%eax 80105146: 89 44 24 04 mov %eax,0x4(%esp) 8010514a: 8b 85 5c ff ff ff mov -0xa4(%ebp),%eax argv[i] = 0; 80105150: c7 84 9d 68 ff ff ff movl $0x0,-0x98(%ebp,%ebx,4) 80105157: 00 00 00 00 return exec(path, argv); 8010515b: 89 04 24 mov %eax,(%esp) 8010515e: e8 3d b8 ff ff call 801009a0 <exec> } 80105163: 81 c4 ac 00 00 00 add $0xac,%esp 80105169: 5b pop %ebx 8010516a: 5e pop %esi 8010516b: 5f pop %edi 8010516c: 5d pop %ebp 8010516d: c3 ret 8010516e: 66 90 xchg %ax,%ax 80105170 <sys_pipe>: int sys_pipe(void) { 80105170: 55 push %ebp 80105171: 89 e5 mov %esp,%ebp 80105173: 53 push %ebx 80105174: 83 ec 24 sub $0x24,%esp int *fd; struct file *rf, *wf; int fd0, fd1; if(argptr(0, (void*)&fd, 2*sizeof(fd[0])) < 0) 80105177: 8d 45 ec lea -0x14(%ebp),%eax 8010517a: c7 44 24 08 08 00 00 movl $0x8,0x8(%esp) 80105181: 00 80105182: 89 44 24 04 mov %eax,0x4(%esp) 80105186: c7 04 24 00 00 00 00 movl $0x0,(%esp) 8010518d: e8 2e f4 ff ff call 801045c0 <argptr> 80105192: 85 c0 test %eax,%eax 80105194: 78 6d js 80105203 <sys_pipe+0x93> return -1; if(pipealloc(&rf, &wf) < 0) 80105196: 8d 45 f4 lea -0xc(%ebp),%eax 80105199: 89 44 24 04 mov %eax,0x4(%esp) 8010519d: 8d 45 f0 lea -0x10(%ebp),%eax 801051a0: 89 04 24 mov %eax,(%esp) 801051a3: e8 c8 df ff ff call 80103170 <pipealloc> 801051a8: 85 c0 test %eax,%eax 801051aa: 78 57 js 80105203 <sys_pipe+0x93> return -1; fd0 = -1; if((fd0 = fdalloc(rf)) < 0 || (fd1 = fdalloc(wf)) < 0){ 801051ac: 8b 45 f0 mov -0x10(%ebp),%eax 801051af: e8 1c f5 ff ff call 801046d0 <fdalloc> 801051b4: 85 c0 test %eax,%eax 801051b6: 89 c3 mov %eax,%ebx 801051b8: 78 33 js 801051ed <sys_pipe+0x7d> 801051ba: 8b 45 f4 mov -0xc(%ebp),%eax 801051bd: e8 0e f5 ff ff call 801046d0 <fdalloc> 801051c2: 85 c0 test %eax,%eax 801051c4: 78 1a js 801051e0 <sys_pipe+0x70> myproc()->ofile[fd0] = 0; fileclose(rf); fileclose(wf); return -1; } fd[0] = fd0; 801051c6: 8b 55 ec mov -0x14(%ebp),%edx 801051c9: 89 1a mov %ebx,(%edx) fd[1] = fd1; 801051cb: 8b 55 ec mov -0x14(%ebp),%edx 801051ce: 89 42 04 mov %eax,0x4(%edx) return 0; } 801051d1: 83 c4 24 add $0x24,%esp return 0; 801051d4: 31 c0 xor %eax,%eax } 801051d6: 5b pop %ebx 801051d7: 5d pop %ebp 801051d8: c3 ret 801051d9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi myproc()->ofile[fd0] = 0; 801051e0: e8 bb e4 ff ff call 801036a0 <myproc> 801051e5: c7 44 98 28 00 00 00 movl $0x0,0x28(%eax,%ebx,4) 801051ec: 00 fileclose(rf); 801051ed: 8b 45 f0 mov -0x10(%ebp),%eax 801051f0: 89 04 24 mov %eax,(%esp) 801051f3: e8 38 bc ff ff call 80100e30 <fileclose> fileclose(wf); 801051f8: 8b 45 f4 mov -0xc(%ebp),%eax 801051fb: 89 04 24 mov %eax,(%esp) 801051fe: e8 2d bc ff ff call 80100e30 <fileclose> } 80105203: 83 c4 24 add $0x24,%esp return -1; 80105206: b8 ff ff ff ff mov $0xffffffff,%eax } 8010520b: 5b pop %ebx 8010520c: 5d pop %ebp 8010520d: c3 ret 8010520e: 66 90 xchg %ax,%ax 80105210 <sys_fork>: #include "mmu.h" #include "proc.h" int sys_fork(void) { 80105210: 55 push %ebp 80105211: 89 e5 mov %esp,%ebp return fork(); } 80105213: 5d pop %ebp return fork(); 80105214: e9 37 e6 ff ff jmp 80103850 <fork> 80105219: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80105220 <sys_exit>: int sys_exit(void) { 80105220: 55 push %ebp 80105221: 89 e5 mov %esp,%ebp 80105223: 83 ec 08 sub $0x8,%esp exit(); 80105226: e8 75 e8 ff ff call 80103aa0 <exit> return 0; // not reached } 8010522b: 31 c0 xor %eax,%eax 8010522d: c9 leave 8010522e: c3 ret 8010522f: 90 nop 80105230 <sys_wait>: int sys_wait(void) { 80105230: 55 push %ebp 80105231: 89 e5 mov %esp,%ebp return wait(); } 80105233: 5d pop %ebp return wait(); 80105234: e9 77 ea ff ff jmp 80103cb0 <wait> 80105239: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80105240 <sys_kill>: int sys_kill(void) { 80105240: 55 push %ebp 80105241: 89 e5 mov %esp,%ebp 80105243: 83 ec 28 sub $0x28,%esp int pid; if(argint(0, &pid) < 0) 80105246: 8d 45 f4 lea -0xc(%ebp),%eax 80105249: 89 44 24 04 mov %eax,0x4(%esp) 8010524d: c7 04 24 00 00 00 00 movl $0x0,(%esp) 80105254: e8 37 f3 ff ff call 80104590 <argint> 80105259: 85 c0 test %eax,%eax 8010525b: 78 13 js 80105270 <sys_kill+0x30> return -1; return kill(pid); 8010525d: 8b 45 f4 mov -0xc(%ebp),%eax 80105260: 89 04 24 mov %eax,(%esp) 80105263: e8 88 eb ff ff call 80103df0 <kill> } 80105268: c9 leave 80105269: c3 ret 8010526a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi return -1; 80105270: b8 ff ff ff ff mov $0xffffffff,%eax } 80105275: c9 leave 80105276: c3 ret 80105277: 89 f6 mov %esi,%esi 80105279: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105280 <sys_getpid>: int sys_getpid(void) { 80105280: 55 push %ebp 80105281: 89 e5 mov %esp,%ebp 80105283: 83 ec 08 sub $0x8,%esp return myproc()->pid; 80105286: e8 15 e4 ff ff call 801036a0 <myproc> 8010528b: 8b 40 10 mov 0x10(%eax),%eax } 8010528e: c9 leave 8010528f: c3 ret 80105290 <sys_sbrk>: int sys_sbrk(void) { 80105290: 55 push %ebp 80105291: 89 e5 mov %esp,%ebp 80105293: 53 push %ebx 80105294: 83 ec 24 sub $0x24,%esp int addr; int n; if(argint(0, &n) < 0) 80105297: 8d 45 f4 lea -0xc(%ebp),%eax 8010529a: 89 44 24 04 mov %eax,0x4(%esp) 8010529e: c7 04 24 00 00 00 00 movl $0x0,(%esp) 801052a5: e8 e6 f2 ff ff call 80104590 <argint> 801052aa: 85 c0 test %eax,%eax 801052ac: 78 22 js 801052d0 <sys_sbrk+0x40> return -1; addr = myproc()->sz; 801052ae: e8 ed e3 ff ff call 801036a0 <myproc> if(growproc(n) < 0) 801052b3: 8b 55 f4 mov -0xc(%ebp),%edx addr = myproc()->sz; 801052b6: 8b 18 mov (%eax),%ebx if(growproc(n) < 0) 801052b8: 89 14 24 mov %edx,(%esp) 801052bb: e8 20 e5 ff ff call 801037e0 <growproc> 801052c0: 85 c0 test %eax,%eax 801052c2: 78 0c js 801052d0 <sys_sbrk+0x40> return -1; return addr; 801052c4: 89 d8 mov %ebx,%eax } 801052c6: 83 c4 24 add $0x24,%esp 801052c9: 5b pop %ebx 801052ca: 5d pop %ebp 801052cb: c3 ret 801052cc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return -1; 801052d0: b8 ff ff ff ff mov $0xffffffff,%eax 801052d5: eb ef jmp 801052c6 <sys_sbrk+0x36> 801052d7: 89 f6 mov %esi,%esi 801052d9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801052e0 <sys_sleep>: int sys_sleep(void) { 801052e0: 55 push %ebp 801052e1: 89 e5 mov %esp,%ebp 801052e3: 53 push %ebx 801052e4: 83 ec 24 sub $0x24,%esp int n; uint ticks0; if(argint(0, &n) < 0) 801052e7: 8d 45 f4 lea -0xc(%ebp),%eax 801052ea: 89 44 24 04 mov %eax,0x4(%esp) 801052ee: c7 04 24 00 00 00 00 movl $0x0,(%esp) 801052f5: e8 96 f2 ff ff call 80104590 <argint> 801052fa: 85 c0 test %eax,%eax 801052fc: 78 7e js 8010537c <sys_sleep+0x9c> return -1; acquire(&tickslock); 801052fe: c7 04 24 60 4c 11 80 movl $0x80114c60,(%esp) 80105305: e8 d6 ee ff ff call 801041e0 <acquire> ticks0 = ticks; while(ticks - ticks0 < n){ 8010530a: 8b 55 f4 mov -0xc(%ebp),%edx ticks0 = ticks; 8010530d: 8b 1d a0 54 11 80 mov 0x801154a0,%ebx while(ticks - ticks0 < n){ 80105313: 85 d2 test %edx,%edx 80105315: 75 29 jne 80105340 <sys_sleep+0x60> 80105317: eb 4f jmp 80105368 <sys_sleep+0x88> 80105319: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(myproc()->killed){ release(&tickslock); return -1; } sleep(&ticks, &tickslock); 80105320: c7 44 24 04 60 4c 11 movl $0x80114c60,0x4(%esp) 80105327: 80 80105328: c7 04 24 a0 54 11 80 movl $0x801154a0,(%esp) 8010532f: e8 cc e8 ff ff call 80103c00 <sleep> while(ticks - ticks0 < n){ 80105334: a1 a0 54 11 80 mov 0x801154a0,%eax 80105339: 29 d8 sub %ebx,%eax 8010533b: 3b 45 f4 cmp -0xc(%ebp),%eax 8010533e: 73 28 jae 80105368 <sys_sleep+0x88> if(myproc()->killed){ 80105340: e8 5b e3 ff ff call 801036a0 <myproc> 80105345: 8b 40 24 mov 0x24(%eax),%eax 80105348: 85 c0 test %eax,%eax 8010534a: 74 d4 je 80105320 <sys_sleep+0x40> release(&tickslock); 8010534c: c7 04 24 60 4c 11 80 movl $0x80114c60,(%esp) 80105353: e8 f8 ee ff ff call 80104250 <release> return -1; 80105358: b8 ff ff ff ff mov $0xffffffff,%eax } release(&tickslock); return 0; } 8010535d: 83 c4 24 add $0x24,%esp 80105360: 5b pop %ebx 80105361: 5d pop %ebp 80105362: c3 ret 80105363: 90 nop 80105364: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi release(&tickslock); 80105368: c7 04 24 60 4c 11 80 movl $0x80114c60,(%esp) 8010536f: e8 dc ee ff ff call 80104250 <release> } 80105374: 83 c4 24 add $0x24,%esp return 0; 80105377: 31 c0 xor %eax,%eax } 80105379: 5b pop %ebx 8010537a: 5d pop %ebp 8010537b: c3 ret return -1; 8010537c: b8 ff ff ff ff mov $0xffffffff,%eax 80105381: eb da jmp 8010535d <sys_sleep+0x7d> 80105383: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80105389: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105390 <sys_uptime>: // return how many clock tick interrupts have occurred // since start. int sys_uptime(void) { 80105390: 55 push %ebp 80105391: 89 e5 mov %esp,%ebp 80105393: 53 push %ebx 80105394: 83 ec 14 sub $0x14,%esp uint xticks; acquire(&tickslock); 80105397: c7 04 24 60 4c 11 80 movl $0x80114c60,(%esp) 8010539e: e8 3d ee ff ff call 801041e0 <acquire> xticks = ticks; 801053a3: 8b 1d a0 54 11 80 mov 0x801154a0,%ebx release(&tickslock); 801053a9: c7 04 24 60 4c 11 80 movl $0x80114c60,(%esp) 801053b0: e8 9b ee ff ff call 80104250 <release> return xticks; } 801053b5: 83 c4 14 add $0x14,%esp 801053b8: 89 d8 mov %ebx,%eax 801053ba: 5b pop %ebx 801053bb: 5d pop %ebp 801053bc: c3 ret 801053bd <alltraps>: # vectors.S sends all traps here. .globl alltraps alltraps: # Build trap frame. pushl %ds 801053bd: 1e push %ds pushl %es 801053be: 06 push %es pushl %fs 801053bf: 0f a0 push %fs pushl %gs 801053c1: 0f a8 push %gs pushal 801053c3: 60 pusha # Set up data segments. movw $(SEG_KDATA<<3), %ax 801053c4: 66 b8 10 00 mov $0x10,%ax movw %ax, %ds 801053c8: 8e d8 mov %eax,%ds movw %ax, %es 801053ca: 8e c0 mov %eax,%es # Call trap(tf), where tf=%esp pushl %esp 801053cc: 54 push %esp call trap 801053cd: e8 de 00 00 00 call 801054b0 <trap> addl $4, %esp 801053d2: 83 c4 04 add $0x4,%esp 801053d5 <trapret>: # Return falls through to trapret... .globl trapret trapret: popal 801053d5: 61 popa popl %gs 801053d6: 0f a9 pop %gs popl %fs 801053d8: 0f a1 pop %fs popl %es 801053da: 07 pop %es popl %ds 801053db: 1f pop %ds addl $0x8, %esp # trapno and errcode 801053dc: 83 c4 08 add $0x8,%esp iret 801053df: cf iret 801053e0 <tvinit>: void tvinit(void) { int i; for(i = 0; i < 256; i++) 801053e0: 31 c0 xor %eax,%eax 801053e2: 8d b6 00 00 00 00 lea 0x0(%esi),%esi SETGATE(idt[i], 0, SEG_KCODE<<3, vectors[i], 0); 801053e8: 8b 14 85 08 a0 10 80 mov -0x7fef5ff8(,%eax,4),%edx 801053ef: b9 08 00 00 00 mov $0x8,%ecx 801053f4: 66 89 0c c5 a2 4c 11 mov %cx,-0x7feeb35e(,%eax,8) 801053fb: 80 801053fc: c6 04 c5 a4 4c 11 80 movb $0x0,-0x7feeb35c(,%eax,8) 80105403: 00 80105404: c6 04 c5 a5 4c 11 80 movb $0x8e,-0x7feeb35b(,%eax,8) 8010540b: 8e 8010540c: 66 89 14 c5 a0 4c 11 mov %dx,-0x7feeb360(,%eax,8) 80105413: 80 80105414: c1 ea 10 shr $0x10,%edx 80105417: 66 89 14 c5 a6 4c 11 mov %dx,-0x7feeb35a(,%eax,8) 8010541e: 80 for(i = 0; i < 256; i++) 8010541f: 83 c0 01 add $0x1,%eax 80105422: 3d 00 01 00 00 cmp $0x100,%eax 80105427: 75 bf jne 801053e8 <tvinit+0x8> { 80105429: 55 push %ebp SETGATE(idt[T_SYSCALL], 1, SEG_KCODE<<3, vectors[T_SYSCALL], DPL_USER); 8010542a: ba 08 00 00 00 mov $0x8,%edx { 8010542f: 89 e5 mov %esp,%ebp 80105431: 83 ec 18 sub $0x18,%esp SETGATE(idt[T_SYSCALL], 1, SEG_KCODE<<3, vectors[T_SYSCALL], DPL_USER); 80105434: a1 08 a1 10 80 mov 0x8010a108,%eax initlock(&tickslock, "time"); 80105439: c7 44 24 04 79 73 10 movl $0x80107379,0x4(%esp) 80105440: 80 80105441: c7 04 24 60 4c 11 80 movl $0x80114c60,(%esp) SETGATE(idt[T_SYSCALL], 1, SEG_KCODE<<3, vectors[T_SYSCALL], DPL_USER); 80105448: 66 89 15 a2 4e 11 80 mov %dx,0x80114ea2 8010544f: 66 a3 a0 4e 11 80 mov %ax,0x80114ea0 80105455: c1 e8 10 shr $0x10,%eax 80105458: c6 05 a4 4e 11 80 00 movb $0x0,0x80114ea4 8010545f: c6 05 a5 4e 11 80 ef movb $0xef,0x80114ea5 80105466: 66 a3 a6 4e 11 80 mov %ax,0x80114ea6 initlock(&tickslock, "time"); 8010546c: e8 ff eb ff ff call 80104070 <initlock> } 80105471: c9 leave 80105472: c3 ret 80105473: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80105479: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105480 <idtinit>: void idtinit(void) { 80105480: 55 push %ebp pd[0] = size-1; 80105481: b8 ff 07 00 00 mov $0x7ff,%eax 80105486: 89 e5 mov %esp,%ebp 80105488: 83 ec 10 sub $0x10,%esp 8010548b: 66 89 45 fa mov %ax,-0x6(%ebp) pd[1] = (uint)p; 8010548f: b8 a0 4c 11 80 mov $0x80114ca0,%eax 80105494: 66 89 45 fc mov %ax,-0x4(%ebp) pd[2] = (uint)p >> 16; 80105498: c1 e8 10 shr $0x10,%eax 8010549b: 66 89 45 fe mov %ax,-0x2(%ebp) asm volatile("lidt (%0)" : : "r" (pd)); 8010549f: 8d 45 fa lea -0x6(%ebp),%eax 801054a2: 0f 01 18 lidtl (%eax) lidt(idt, sizeof(idt)); } 801054a5: c9 leave 801054a6: c3 ret 801054a7: 89 f6 mov %esi,%esi 801054a9: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 801054b0 <trap>: //PAGEBREAK: 41 void trap(struct trapframe *tf) { 801054b0: 55 push %ebp 801054b1: 89 e5 mov %esp,%ebp 801054b3: 57 push %edi 801054b4: 56 push %esi 801054b5: 53 push %ebx 801054b6: 83 ec 3c sub $0x3c,%esp 801054b9: 8b 5d 08 mov 0x8(%ebp),%ebx if(tf->trapno == T_SYSCALL){ 801054bc: 8b 43 30 mov 0x30(%ebx),%eax 801054bf: 83 f8 40 cmp $0x40,%eax 801054c2: 0f 84 a0 01 00 00 je 80105668 <trap+0x1b8> if(myproc()->killed) exit(); return; } switch(tf->trapno){ 801054c8: 83 e8 20 sub $0x20,%eax 801054cb: 83 f8 1f cmp $0x1f,%eax 801054ce: 77 08 ja 801054d8 <trap+0x28> 801054d0: ff 24 85 20 74 10 80 jmp *-0x7fef8be0(,%eax,4) 801054d7: 90 nop lapiceoi(); break; //PAGEBREAK: 13 default: if(myproc() == 0 || (tf->cs&3) == 0){ 801054d8: e8 c3 e1 ff ff call 801036a0 <myproc> 801054dd: 85 c0 test %eax,%eax 801054df: 90 nop 801054e0: 0f 84 fa 01 00 00 je 801056e0 <trap+0x230> 801054e6: f6 43 3c 03 testb $0x3,0x3c(%ebx) 801054ea: 0f 84 f0 01 00 00 je 801056e0 <trap+0x230> static inline uint rcr2(void) { uint val; asm volatile("movl %%cr2,%0" : "=r" (val)); 801054f0: 0f 20 d1 mov %cr2,%ecx cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n", tf->trapno, cpuid(), tf->eip, rcr2()); panic("trap"); } // In user space, assume process misbehaved. cprintf("pid %d %s: trap %d err %d on cpu %d " 801054f3: 8b 53 38 mov 0x38(%ebx),%edx 801054f6: 89 4d d8 mov %ecx,-0x28(%ebp) 801054f9: 89 55 dc mov %edx,-0x24(%ebp) 801054fc: e8 7f e1 ff ff call 80103680 <cpuid> 80105501: 8b 73 30 mov 0x30(%ebx),%esi 80105504: 89 c7 mov %eax,%edi 80105506: 8b 43 34 mov 0x34(%ebx),%eax 80105509: 89 45 e4 mov %eax,-0x1c(%ebp) "eip 0x%x addr 0x%x--kill proc\n", myproc()->pid, myproc()->name, tf->trapno, 8010550c: e8 8f e1 ff ff call 801036a0 <myproc> 80105511: 89 45 e0 mov %eax,-0x20(%ebp) 80105514: e8 87 e1 ff ff call 801036a0 <myproc> cprintf("pid %d %s: trap %d err %d on cpu %d " 80105519: 8b 55 dc mov -0x24(%ebp),%edx 8010551c: 89 74 24 0c mov %esi,0xc(%esp) myproc()->pid, myproc()->name, tf->trapno, 80105520: 8b 75 e0 mov -0x20(%ebp),%esi cprintf("pid %d %s: trap %d err %d on cpu %d " 80105523: 8b 4d d8 mov -0x28(%ebp),%ecx 80105526: 89 7c 24 14 mov %edi,0x14(%esp) 8010552a: 89 54 24 18 mov %edx,0x18(%esp) 8010552e: 8b 55 e4 mov -0x1c(%ebp),%edx myproc()->pid, myproc()->name, tf->trapno, 80105531: 83 c6 6c add $0x6c,%esi cprintf("pid %d %s: trap %d err %d on cpu %d " 80105534: 89 4c 24 1c mov %ecx,0x1c(%esp) myproc()->pid, myproc()->name, tf->trapno, 80105538: 89 74 24 08 mov %esi,0x8(%esp) cprintf("pid %d %s: trap %d err %d on cpu %d " 8010553c: 89 54 24 10 mov %edx,0x10(%esp) 80105540: 8b 40 10 mov 0x10(%eax),%eax 80105543: c7 04 24 dc 73 10 80 movl $0x801073dc,(%esp) 8010554a: 89 44 24 04 mov %eax,0x4(%esp) 8010554e: e8 fd b0 ff ff call 80100650 <cprintf> tf->err, cpuid(), tf->eip, rcr2()); myproc()->killed = 1; 80105553: e8 48 e1 ff ff call 801036a0 <myproc> 80105558: c7 40 24 01 00 00 00 movl $0x1,0x24(%eax) 8010555f: 90 nop } // Force process exit if it has been killed and is in user space. // (If it is still executing in the kernel, let it keep running // until it gets to the regular system call return.) if(myproc() && myproc()->killed && (tf->cs&3) == DPL_USER) 80105560: e8 3b e1 ff ff call 801036a0 <myproc> 80105565: 85 c0 test %eax,%eax 80105567: 74 0c je 80105575 <trap+0xc5> 80105569: e8 32 e1 ff ff call 801036a0 <myproc> 8010556e: 8b 50 24 mov 0x24(%eax),%edx 80105571: 85 d2 test %edx,%edx 80105573: 75 4b jne 801055c0 <trap+0x110> exit(); // Force process to give up CPU on clock tick. // If interrupts were on while locks held, would need to check nlock. if(myproc() && myproc()->state == RUNNING && 80105575: e8 26 e1 ff ff call 801036a0 <myproc> 8010557a: 85 c0 test %eax,%eax 8010557c: 74 0d je 8010558b <trap+0xdb> 8010557e: 66 90 xchg %ax,%ax 80105580: e8 1b e1 ff ff call 801036a0 <myproc> 80105585: 83 78 0c 04 cmpl $0x4,0xc(%eax) 80105589: 74 4d je 801055d8 <trap+0x128> tf->trapno == T_IRQ0+IRQ_TIMER) yield(); // Check if the process has been killed since we yielded if(myproc() && myproc()->killed && (tf->cs&3) == DPL_USER) 8010558b: e8 10 e1 ff ff call 801036a0 <myproc> 80105590: 85 c0 test %eax,%eax 80105592: 74 1d je 801055b1 <trap+0x101> 80105594: e8 07 e1 ff ff call 801036a0 <myproc> 80105599: 8b 40 24 mov 0x24(%eax),%eax 8010559c: 85 c0 test %eax,%eax 8010559e: 74 11 je 801055b1 <trap+0x101> 801055a0: 0f b7 43 3c movzwl 0x3c(%ebx),%eax 801055a4: 83 e0 03 and $0x3,%eax 801055a7: 66 83 f8 03 cmp $0x3,%ax 801055ab: 0f 84 e8 00 00 00 je 80105699 <trap+0x1e9> exit(); } 801055b1: 83 c4 3c add $0x3c,%esp 801055b4: 5b pop %ebx 801055b5: 5e pop %esi 801055b6: 5f pop %edi 801055b7: 5d pop %ebp 801055b8: c3 ret 801055b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(myproc() && myproc()->killed && (tf->cs&3) == DPL_USER) 801055c0: 0f b7 43 3c movzwl 0x3c(%ebx),%eax 801055c4: 83 e0 03 and $0x3,%eax 801055c7: 66 83 f8 03 cmp $0x3,%ax 801055cb: 75 a8 jne 80105575 <trap+0xc5> exit(); 801055cd: e8 ce e4 ff ff call 80103aa0 <exit> 801055d2: eb a1 jmp 80105575 <trap+0xc5> 801055d4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi if(myproc() && myproc()->state == RUNNING && 801055d8: 83 7b 30 20 cmpl $0x20,0x30(%ebx) 801055dc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801055e0: 75 a9 jne 8010558b <trap+0xdb> yield(); 801055e2: e8 d9 e5 ff ff call 80103bc0 <yield> 801055e7: eb a2 jmp 8010558b <trap+0xdb> 801055e9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(cpuid() == 0){ 801055f0: e8 8b e0 ff ff call 80103680 <cpuid> 801055f5: 85 c0 test %eax,%eax 801055f7: 0f 84 b3 00 00 00 je 801056b0 <trap+0x200> 801055fd: 8d 76 00 lea 0x0(%esi),%esi lapiceoi(); 80105600: e8 7b d1 ff ff call 80102780 <lapiceoi> break; 80105605: e9 56 ff ff ff jmp 80105560 <trap+0xb0> 8010560a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi kbdintr(); 80105610: e8 bb cf ff ff call 801025d0 <kbdintr> lapiceoi(); 80105615: e8 66 d1 ff ff call 80102780 <lapiceoi> break; 8010561a: e9 41 ff ff ff jmp 80105560 <trap+0xb0> 8010561f: 90 nop uartintr(); 80105620: e8 1b 02 00 00 call 80105840 <uartintr> lapiceoi(); 80105625: e8 56 d1 ff ff call 80102780 <lapiceoi> break; 8010562a: e9 31 ff ff ff jmp 80105560 <trap+0xb0> 8010562f: 90 nop cprintf("cpu%d: spurious interrupt at %x:%x\n", 80105630: 8b 7b 38 mov 0x38(%ebx),%edi 80105633: 0f b7 73 3c movzwl 0x3c(%ebx),%esi 80105637: e8 44 e0 ff ff call 80103680 <cpuid> 8010563c: c7 04 24 84 73 10 80 movl $0x80107384,(%esp) 80105643: 89 7c 24 0c mov %edi,0xc(%esp) 80105647: 89 74 24 08 mov %esi,0x8(%esp) 8010564b: 89 44 24 04 mov %eax,0x4(%esp) 8010564f: e8 fc af ff ff call 80100650 <cprintf> lapiceoi(); 80105654: e8 27 d1 ff ff call 80102780 <lapiceoi> break; 80105659: e9 02 ff ff ff jmp 80105560 <trap+0xb0> 8010565e: 66 90 xchg %ax,%ax ideintr(); 80105660: e8 1b ca ff ff call 80102080 <ideintr> 80105665: eb 96 jmp 801055fd <trap+0x14d> 80105667: 90 nop 80105668: 90 nop 80105669: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi if(myproc()->killed) 80105670: e8 2b e0 ff ff call 801036a0 <myproc> 80105675: 8b 70 24 mov 0x24(%eax),%esi 80105678: 85 f6 test %esi,%esi 8010567a: 75 2c jne 801056a8 <trap+0x1f8> myproc()->tf = tf; 8010567c: e8 1f e0 ff ff call 801036a0 <myproc> 80105681: 89 58 18 mov %ebx,0x18(%eax) syscall(); 80105684: e8 d7 ef ff ff call 80104660 <syscall> if(myproc()->killed) 80105689: e8 12 e0 ff ff call 801036a0 <myproc> 8010568e: 8b 48 24 mov 0x24(%eax),%ecx 80105691: 85 c9 test %ecx,%ecx 80105693: 0f 84 18 ff ff ff je 801055b1 <trap+0x101> } 80105699: 83 c4 3c add $0x3c,%esp 8010569c: 5b pop %ebx 8010569d: 5e pop %esi 8010569e: 5f pop %edi 8010569f: 5d pop %ebp exit(); 801056a0: e9 fb e3 ff ff jmp 80103aa0 <exit> 801056a5: 8d 76 00 lea 0x0(%esi),%esi exit(); 801056a8: e8 f3 e3 ff ff call 80103aa0 <exit> 801056ad: eb cd jmp 8010567c <trap+0x1cc> 801056af: 90 nop acquire(&tickslock); 801056b0: c7 04 24 60 4c 11 80 movl $0x80114c60,(%esp) 801056b7: e8 24 eb ff ff call 801041e0 <acquire> wakeup(&ticks); 801056bc: c7 04 24 a0 54 11 80 movl $0x801154a0,(%esp) ticks++; 801056c3: 83 05 a0 54 11 80 01 addl $0x1,0x801154a0 wakeup(&ticks); 801056ca: e8 c1 e6 ff ff call 80103d90 <wakeup> release(&tickslock); 801056cf: c7 04 24 60 4c 11 80 movl $0x80114c60,(%esp) 801056d6: e8 75 eb ff ff call 80104250 <release> 801056db: e9 1d ff ff ff jmp 801055fd <trap+0x14d> 801056e0: 0f 20 d7 mov %cr2,%edi cprintf("unexpected trap %d from cpu %d eip %x (cr2=0x%x)\n", 801056e3: 8b 73 38 mov 0x38(%ebx),%esi 801056e6: e8 95 df ff ff call 80103680 <cpuid> 801056eb: 89 7c 24 10 mov %edi,0x10(%esp) 801056ef: 89 74 24 0c mov %esi,0xc(%esp) 801056f3: 89 44 24 08 mov %eax,0x8(%esp) 801056f7: 8b 43 30 mov 0x30(%ebx),%eax 801056fa: c7 04 24 a8 73 10 80 movl $0x801073a8,(%esp) 80105701: 89 44 24 04 mov %eax,0x4(%esp) 80105705: e8 46 af ff ff call 80100650 <cprintf> panic("trap"); 8010570a: c7 04 24 7e 73 10 80 movl $0x8010737e,(%esp) 80105711: e8 4a ac ff ff call 80100360 <panic> 80105716: 66 90 xchg %ax,%ax 80105718: 66 90 xchg %ax,%ax 8010571a: 66 90 xchg %ax,%ax 8010571c: 66 90 xchg %ax,%ax 8010571e: 66 90 xchg %ax,%ax 80105720 <uartgetc>: } static int uartgetc(void) { if(!uart) 80105720: a1 bc a5 10 80 mov 0x8010a5bc,%eax { 80105725: 55 push %ebp 80105726: 89 e5 mov %esp,%ebp if(!uart) 80105728: 85 c0 test %eax,%eax 8010572a: 74 14 je 80105740 <uartgetc+0x20> asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 8010572c: ba fd 03 00 00 mov $0x3fd,%edx 80105731: ec in (%dx),%al return -1; if(!(inb(COM1+5) & 0x01)) 80105732: a8 01 test $0x1,%al 80105734: 74 0a je 80105740 <uartgetc+0x20> 80105736: b2 f8 mov $0xf8,%dl 80105738: ec in (%dx),%al return -1; return inb(COM1+0); 80105739: 0f b6 c0 movzbl %al,%eax } 8010573c: 5d pop %ebp 8010573d: c3 ret 8010573e: 66 90 xchg %ax,%ax return -1; 80105740: b8 ff ff ff ff mov $0xffffffff,%eax } 80105745: 5d pop %ebp 80105746: c3 ret 80105747: 89 f6 mov %esi,%esi 80105749: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80105750 <uartputc>: if(!uart) 80105750: a1 bc a5 10 80 mov 0x8010a5bc,%eax 80105755: 85 c0 test %eax,%eax 80105757: 74 3f je 80105798 <uartputc+0x48> { 80105759: 55 push %ebp 8010575a: 89 e5 mov %esp,%ebp 8010575c: 56 push %esi 8010575d: be fd 03 00 00 mov $0x3fd,%esi 80105762: 53 push %ebx if(!uart) 80105763: bb 80 00 00 00 mov $0x80,%ebx { 80105768: 83 ec 10 sub $0x10,%esp 8010576b: eb 14 jmp 80105781 <uartputc+0x31> 8010576d: 8d 76 00 lea 0x0(%esi),%esi microdelay(10); 80105770: c7 04 24 0a 00 00 00 movl $0xa,(%esp) 80105777: e8 24 d0 ff ff call 801027a0 <microdelay> for(i = 0; i < 128 && !(inb(COM1+5) & 0x20); i++) 8010577c: 83 eb 01 sub $0x1,%ebx 8010577f: 74 07 je 80105788 <uartputc+0x38> 80105781: 89 f2 mov %esi,%edx 80105783: ec in (%dx),%al 80105784: a8 20 test $0x20,%al 80105786: 74 e8 je 80105770 <uartputc+0x20> outb(COM1+0, c); 80105788: 0f b6 45 08 movzbl 0x8(%ebp),%eax asm volatile("out %0,%1" : : "a" (data), "d" (port)); 8010578c: ba f8 03 00 00 mov $0x3f8,%edx 80105791: ee out %al,(%dx) } 80105792: 83 c4 10 add $0x10,%esp 80105795: 5b pop %ebx 80105796: 5e pop %esi 80105797: 5d pop %ebp 80105798: f3 c3 repz ret 8010579a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801057a0 <uartinit>: { 801057a0: 55 push %ebp 801057a1: 31 c9 xor %ecx,%ecx 801057a3: 89 e5 mov %esp,%ebp 801057a5: 89 c8 mov %ecx,%eax 801057a7: 57 push %edi 801057a8: bf fa 03 00 00 mov $0x3fa,%edi 801057ad: 56 push %esi 801057ae: 89 fa mov %edi,%edx 801057b0: 53 push %ebx 801057b1: 83 ec 1c sub $0x1c,%esp 801057b4: ee out %al,(%dx) 801057b5: be fb 03 00 00 mov $0x3fb,%esi 801057ba: b8 80 ff ff ff mov $0xffffff80,%eax 801057bf: 89 f2 mov %esi,%edx 801057c1: ee out %al,(%dx) 801057c2: b8 0c 00 00 00 mov $0xc,%eax 801057c7: b2 f8 mov $0xf8,%dl 801057c9: ee out %al,(%dx) 801057ca: bb f9 03 00 00 mov $0x3f9,%ebx 801057cf: 89 c8 mov %ecx,%eax 801057d1: 89 da mov %ebx,%edx 801057d3: ee out %al,(%dx) 801057d4: b8 03 00 00 00 mov $0x3,%eax 801057d9: 89 f2 mov %esi,%edx 801057db: ee out %al,(%dx) 801057dc: b2 fc mov $0xfc,%dl 801057de: 89 c8 mov %ecx,%eax 801057e0: ee out %al,(%dx) 801057e1: b8 01 00 00 00 mov $0x1,%eax 801057e6: 89 da mov %ebx,%edx 801057e8: ee out %al,(%dx) asm volatile("in %1,%0" : "=a" (data) : "d" (port)); 801057e9: b2 fd mov $0xfd,%dl 801057eb: ec in (%dx),%al if(inb(COM1+5) == 0xFF) 801057ec: 3c ff cmp $0xff,%al 801057ee: 74 42 je 80105832 <uartinit+0x92> uart = 1; 801057f0: c7 05 bc a5 10 80 01 movl $0x1,0x8010a5bc 801057f7: 00 00 00 801057fa: 89 fa mov %edi,%edx 801057fc: ec in (%dx),%al 801057fd: b2 f8 mov $0xf8,%dl 801057ff: ec in (%dx),%al ioapicenable(IRQ_COM1, 0); 80105800: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80105807: 00 for(p="xv6...\n"; *p; p++) 80105808: bb a0 74 10 80 mov $0x801074a0,%ebx ioapicenable(IRQ_COM1, 0); 8010580d: c7 04 24 04 00 00 00 movl $0x4,(%esp) 80105814: e8 97 ca ff ff call 801022b0 <ioapicenable> for(p="xv6...\n"; *p; p++) 80105819: b8 78 00 00 00 mov $0x78,%eax 8010581e: 66 90 xchg %ax,%ax uartputc(*p); 80105820: 89 04 24 mov %eax,(%esp) for(p="xv6...\n"; *p; p++) 80105823: 83 c3 01 add $0x1,%ebx uartputc(*p); 80105826: e8 25 ff ff ff call 80105750 <uartputc> for(p="xv6...\n"; *p; p++) 8010582b: 0f be 03 movsbl (%ebx),%eax 8010582e: 84 c0 test %al,%al 80105830: 75 ee jne 80105820 <uartinit+0x80> } 80105832: 83 c4 1c add $0x1c,%esp 80105835: 5b pop %ebx 80105836: 5e pop %esi 80105837: 5f pop %edi 80105838: 5d pop %ebp 80105839: c3 ret 8010583a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80105840 <uartintr>: void uartintr(void) { 80105840: 55 push %ebp 80105841: 89 e5 mov %esp,%ebp 80105843: 83 ec 18 sub $0x18,%esp consoleintr(uartgetc); 80105846: c7 04 24 20 57 10 80 movl $0x80105720,(%esp) 8010584d: e8 5e af ff ff call 801007b0 <consoleintr> } 80105852: c9 leave 80105853: c3 ret 80105854 <vector0>: # generated by vectors.pl - do not edit # handlers .globl alltraps .globl vector0 vector0: pushl $0 80105854: 6a 00 push $0x0 pushl $0 80105856: 6a 00 push $0x0 jmp alltraps 80105858: e9 60 fb ff ff jmp 801053bd <alltraps> 8010585d <vector1>: .globl vector1 vector1: pushl $0 8010585d: 6a 00 push $0x0 pushl $1 8010585f: 6a 01 push $0x1 jmp alltraps 80105861: e9 57 fb ff ff jmp 801053bd <alltraps> 80105866 <vector2>: .globl vector2 vector2: pushl $0 80105866: 6a 00 push $0x0 pushl $2 80105868: 6a 02 push $0x2 jmp alltraps 8010586a: e9 4e fb ff ff jmp 801053bd <alltraps> 8010586f <vector3>: .globl vector3 vector3: pushl $0 8010586f: 6a 00 push $0x0 pushl $3 80105871: 6a 03 push $0x3 jmp alltraps 80105873: e9 45 fb ff ff jmp 801053bd <alltraps> 80105878 <vector4>: .globl vector4 vector4: pushl $0 80105878: 6a 00 push $0x0 pushl $4 8010587a: 6a 04 push $0x4 jmp alltraps 8010587c: e9 3c fb ff ff jmp 801053bd <alltraps> 80105881 <vector5>: .globl vector5 vector5: pushl $0 80105881: 6a 00 push $0x0 pushl $5 80105883: 6a 05 push $0x5 jmp alltraps 80105885: e9 33 fb ff ff jmp 801053bd <alltraps> 8010588a <vector6>: .globl vector6 vector6: pushl $0 8010588a: 6a 00 push $0x0 pushl $6 8010588c: 6a 06 push $0x6 jmp alltraps 8010588e: e9 2a fb ff ff jmp 801053bd <alltraps> 80105893 <vector7>: .globl vector7 vector7: pushl $0 80105893: 6a 00 push $0x0 pushl $7 80105895: 6a 07 push $0x7 jmp alltraps 80105897: e9 21 fb ff ff jmp 801053bd <alltraps> 8010589c <vector8>: .globl vector8 vector8: pushl $8 8010589c: 6a 08 push $0x8 jmp alltraps 8010589e: e9 1a fb ff ff jmp 801053bd <alltraps> 801058a3 <vector9>: .globl vector9 vector9: pushl $0 801058a3: 6a 00 push $0x0 pushl $9 801058a5: 6a 09 push $0x9 jmp alltraps 801058a7: e9 11 fb ff ff jmp 801053bd <alltraps> 801058ac <vector10>: .globl vector10 vector10: pushl $10 801058ac: 6a 0a push $0xa jmp alltraps 801058ae: e9 0a fb ff ff jmp 801053bd <alltraps> 801058b3 <vector11>: .globl vector11 vector11: pushl $11 801058b3: 6a 0b push $0xb jmp alltraps 801058b5: e9 03 fb ff ff jmp 801053bd <alltraps> 801058ba <vector12>: .globl vector12 vector12: pushl $12 801058ba: 6a 0c push $0xc jmp alltraps 801058bc: e9 fc fa ff ff jmp 801053bd <alltraps> 801058c1 <vector13>: .globl vector13 vector13: pushl $13 801058c1: 6a 0d push $0xd jmp alltraps 801058c3: e9 f5 fa ff ff jmp 801053bd <alltraps> 801058c8 <vector14>: .globl vector14 vector14: pushl $14 801058c8: 6a 0e push $0xe jmp alltraps 801058ca: e9 ee fa ff ff jmp 801053bd <alltraps> 801058cf <vector15>: .globl vector15 vector15: pushl $0 801058cf: 6a 00 push $0x0 pushl $15 801058d1: 6a 0f push $0xf jmp alltraps 801058d3: e9 e5 fa ff ff jmp 801053bd <alltraps> 801058d8 <vector16>: .globl vector16 vector16: pushl $0 801058d8: 6a 00 push $0x0 pushl $16 801058da: 6a 10 push $0x10 jmp alltraps 801058dc: e9 dc fa ff ff jmp 801053bd <alltraps> 801058e1 <vector17>: .globl vector17 vector17: pushl $17 801058e1: 6a 11 push $0x11 jmp alltraps 801058e3: e9 d5 fa ff ff jmp 801053bd <alltraps> 801058e8 <vector18>: .globl vector18 vector18: pushl $0 801058e8: 6a 00 push $0x0 pushl $18 801058ea: 6a 12 push $0x12 jmp alltraps 801058ec: e9 cc fa ff ff jmp 801053bd <alltraps> 801058f1 <vector19>: .globl vector19 vector19: pushl $0 801058f1: 6a 00 push $0x0 pushl $19 801058f3: 6a 13 push $0x13 jmp alltraps 801058f5: e9 c3 fa ff ff jmp 801053bd <alltraps> 801058fa <vector20>: .globl vector20 vector20: pushl $0 801058fa: 6a 00 push $0x0 pushl $20 801058fc: 6a 14 push $0x14 jmp alltraps 801058fe: e9 ba fa ff ff jmp 801053bd <alltraps> 80105903 <vector21>: .globl vector21 vector21: pushl $0 80105903: 6a 00 push $0x0 pushl $21 80105905: 6a 15 push $0x15 jmp alltraps 80105907: e9 b1 fa ff ff jmp 801053bd <alltraps> 8010590c <vector22>: .globl vector22 vector22: pushl $0 8010590c: 6a 00 push $0x0 pushl $22 8010590e: 6a 16 push $0x16 jmp alltraps 80105910: e9 a8 fa ff ff jmp 801053bd <alltraps> 80105915 <vector23>: .globl vector23 vector23: pushl $0 80105915: 6a 00 push $0x0 pushl $23 80105917: 6a 17 push $0x17 jmp alltraps 80105919: e9 9f fa ff ff jmp 801053bd <alltraps> 8010591e <vector24>: .globl vector24 vector24: pushl $0 8010591e: 6a 00 push $0x0 pushl $24 80105920: 6a 18 push $0x18 jmp alltraps 80105922: e9 96 fa ff ff jmp 801053bd <alltraps> 80105927 <vector25>: .globl vector25 vector25: pushl $0 80105927: 6a 00 push $0x0 pushl $25 80105929: 6a 19 push $0x19 jmp alltraps 8010592b: e9 8d fa ff ff jmp 801053bd <alltraps> 80105930 <vector26>: .globl vector26 vector26: pushl $0 80105930: 6a 00 push $0x0 pushl $26 80105932: 6a 1a push $0x1a jmp alltraps 80105934: e9 84 fa ff ff jmp 801053bd <alltraps> 80105939 <vector27>: .globl vector27 vector27: pushl $0 80105939: 6a 00 push $0x0 pushl $27 8010593b: 6a 1b push $0x1b jmp alltraps 8010593d: e9 7b fa ff ff jmp 801053bd <alltraps> 80105942 <vector28>: .globl vector28 vector28: pushl $0 80105942: 6a 00 push $0x0 pushl $28 80105944: 6a 1c push $0x1c jmp alltraps 80105946: e9 72 fa ff ff jmp 801053bd <alltraps> 8010594b <vector29>: .globl vector29 vector29: pushl $0 8010594b: 6a 00 push $0x0 pushl $29 8010594d: 6a 1d push $0x1d jmp alltraps 8010594f: e9 69 fa ff ff jmp 801053bd <alltraps> 80105954 <vector30>: .globl vector30 vector30: pushl $0 80105954: 6a 00 push $0x0 pushl $30 80105956: 6a 1e push $0x1e jmp alltraps 80105958: e9 60 fa ff ff jmp 801053bd <alltraps> 8010595d <vector31>: .globl vector31 vector31: pushl $0 8010595d: 6a 00 push $0x0 pushl $31 8010595f: 6a 1f push $0x1f jmp alltraps 80105961: e9 57 fa ff ff jmp 801053bd <alltraps> 80105966 <vector32>: .globl vector32 vector32: pushl $0 80105966: 6a 00 push $0x0 pushl $32 80105968: 6a 20 push $0x20 jmp alltraps 8010596a: e9 4e fa ff ff jmp 801053bd <alltraps> 8010596f <vector33>: .globl vector33 vector33: pushl $0 8010596f: 6a 00 push $0x0 pushl $33 80105971: 6a 21 push $0x21 jmp alltraps 80105973: e9 45 fa ff ff jmp 801053bd <alltraps> 80105978 <vector34>: .globl vector34 vector34: pushl $0 80105978: 6a 00 push $0x0 pushl $34 8010597a: 6a 22 push $0x22 jmp alltraps 8010597c: e9 3c fa ff ff jmp 801053bd <alltraps> 80105981 <vector35>: .globl vector35 vector35: pushl $0 80105981: 6a 00 push $0x0 pushl $35 80105983: 6a 23 push $0x23 jmp alltraps 80105985: e9 33 fa ff ff jmp 801053bd <alltraps> 8010598a <vector36>: .globl vector36 vector36: pushl $0 8010598a: 6a 00 push $0x0 pushl $36 8010598c: 6a 24 push $0x24 jmp alltraps 8010598e: e9 2a fa ff ff jmp 801053bd <alltraps> 80105993 <vector37>: .globl vector37 vector37: pushl $0 80105993: 6a 00 push $0x0 pushl $37 80105995: 6a 25 push $0x25 jmp alltraps 80105997: e9 21 fa ff ff jmp 801053bd <alltraps> 8010599c <vector38>: .globl vector38 vector38: pushl $0 8010599c: 6a 00 push $0x0 pushl $38 8010599e: 6a 26 push $0x26 jmp alltraps 801059a0: e9 18 fa ff ff jmp 801053bd <alltraps> 801059a5 <vector39>: .globl vector39 vector39: pushl $0 801059a5: 6a 00 push $0x0 pushl $39 801059a7: 6a 27 push $0x27 jmp alltraps 801059a9: e9 0f fa ff ff jmp 801053bd <alltraps> 801059ae <vector40>: .globl vector40 vector40: pushl $0 801059ae: 6a 00 push $0x0 pushl $40 801059b0: 6a 28 push $0x28 jmp alltraps 801059b2: e9 06 fa ff ff jmp 801053bd <alltraps> 801059b7 <vector41>: .globl vector41 vector41: pushl $0 801059b7: 6a 00 push $0x0 pushl $41 801059b9: 6a 29 push $0x29 jmp alltraps 801059bb: e9 fd f9 ff ff jmp 801053bd <alltraps> 801059c0 <vector42>: .globl vector42 vector42: pushl $0 801059c0: 6a 00 push $0x0 pushl $42 801059c2: 6a 2a push $0x2a jmp alltraps 801059c4: e9 f4 f9 ff ff jmp 801053bd <alltraps> 801059c9 <vector43>: .globl vector43 vector43: pushl $0 801059c9: 6a 00 push $0x0 pushl $43 801059cb: 6a 2b push $0x2b jmp alltraps 801059cd: e9 eb f9 ff ff jmp 801053bd <alltraps> 801059d2 <vector44>: .globl vector44 vector44: pushl $0 801059d2: 6a 00 push $0x0 pushl $44 801059d4: 6a 2c push $0x2c jmp alltraps 801059d6: e9 e2 f9 ff ff jmp 801053bd <alltraps> 801059db <vector45>: .globl vector45 vector45: pushl $0 801059db: 6a 00 push $0x0 pushl $45 801059dd: 6a 2d push $0x2d jmp alltraps 801059df: e9 d9 f9 ff ff jmp 801053bd <alltraps> 801059e4 <vector46>: .globl vector46 vector46: pushl $0 801059e4: 6a 00 push $0x0 pushl $46 801059e6: 6a 2e push $0x2e jmp alltraps 801059e8: e9 d0 f9 ff ff jmp 801053bd <alltraps> 801059ed <vector47>: .globl vector47 vector47: pushl $0 801059ed: 6a 00 push $0x0 pushl $47 801059ef: 6a 2f push $0x2f jmp alltraps 801059f1: e9 c7 f9 ff ff jmp 801053bd <alltraps> 801059f6 <vector48>: .globl vector48 vector48: pushl $0 801059f6: 6a 00 push $0x0 pushl $48 801059f8: 6a 30 push $0x30 jmp alltraps 801059fa: e9 be f9 ff ff jmp 801053bd <alltraps> 801059ff <vector49>: .globl vector49 vector49: pushl $0 801059ff: 6a 00 push $0x0 pushl $49 80105a01: 6a 31 push $0x31 jmp alltraps 80105a03: e9 b5 f9 ff ff jmp 801053bd <alltraps> 80105a08 <vector50>: .globl vector50 vector50: pushl $0 80105a08: 6a 00 push $0x0 pushl $50 80105a0a: 6a 32 push $0x32 jmp alltraps 80105a0c: e9 ac f9 ff ff jmp 801053bd <alltraps> 80105a11 <vector51>: .globl vector51 vector51: pushl $0 80105a11: 6a 00 push $0x0 pushl $51 80105a13: 6a 33 push $0x33 jmp alltraps 80105a15: e9 a3 f9 ff ff jmp 801053bd <alltraps> 80105a1a <vector52>: .globl vector52 vector52: pushl $0 80105a1a: 6a 00 push $0x0 pushl $52 80105a1c: 6a 34 push $0x34 jmp alltraps 80105a1e: e9 9a f9 ff ff jmp 801053bd <alltraps> 80105a23 <vector53>: .globl vector53 vector53: pushl $0 80105a23: 6a 00 push $0x0 pushl $53 80105a25: 6a 35 push $0x35 jmp alltraps 80105a27: e9 91 f9 ff ff jmp 801053bd <alltraps> 80105a2c <vector54>: .globl vector54 vector54: pushl $0 80105a2c: 6a 00 push $0x0 pushl $54 80105a2e: 6a 36 push $0x36 jmp alltraps 80105a30: e9 88 f9 ff ff jmp 801053bd <alltraps> 80105a35 <vector55>: .globl vector55 vector55: pushl $0 80105a35: 6a 00 push $0x0 pushl $55 80105a37: 6a 37 push $0x37 jmp alltraps 80105a39: e9 7f f9 ff ff jmp 801053bd <alltraps> 80105a3e <vector56>: .globl vector56 vector56: pushl $0 80105a3e: 6a 00 push $0x0 pushl $56 80105a40: 6a 38 push $0x38 jmp alltraps 80105a42: e9 76 f9 ff ff jmp 801053bd <alltraps> 80105a47 <vector57>: .globl vector57 vector57: pushl $0 80105a47: 6a 00 push $0x0 pushl $57 80105a49: 6a 39 push $0x39 jmp alltraps 80105a4b: e9 6d f9 ff ff jmp 801053bd <alltraps> 80105a50 <vector58>: .globl vector58 vector58: pushl $0 80105a50: 6a 00 push $0x0 pushl $58 80105a52: 6a 3a push $0x3a jmp alltraps 80105a54: e9 64 f9 ff ff jmp 801053bd <alltraps> 80105a59 <vector59>: .globl vector59 vector59: pushl $0 80105a59: 6a 00 push $0x0 pushl $59 80105a5b: 6a 3b push $0x3b jmp alltraps 80105a5d: e9 5b f9 ff ff jmp 801053bd <alltraps> 80105a62 <vector60>: .globl vector60 vector60: pushl $0 80105a62: 6a 00 push $0x0 pushl $60 80105a64: 6a 3c push $0x3c jmp alltraps 80105a66: e9 52 f9 ff ff jmp 801053bd <alltraps> 80105a6b <vector61>: .globl vector61 vector61: pushl $0 80105a6b: 6a 00 push $0x0 pushl $61 80105a6d: 6a 3d push $0x3d jmp alltraps 80105a6f: e9 49 f9 ff ff jmp 801053bd <alltraps> 80105a74 <vector62>: .globl vector62 vector62: pushl $0 80105a74: 6a 00 push $0x0 pushl $62 80105a76: 6a 3e push $0x3e jmp alltraps 80105a78: e9 40 f9 ff ff jmp 801053bd <alltraps> 80105a7d <vector63>: .globl vector63 vector63: pushl $0 80105a7d: 6a 00 push $0x0 pushl $63 80105a7f: 6a 3f push $0x3f jmp alltraps 80105a81: e9 37 f9 ff ff jmp 801053bd <alltraps> 80105a86 <vector64>: .globl vector64 vector64: pushl $0 80105a86: 6a 00 push $0x0 pushl $64 80105a88: 6a 40 push $0x40 jmp alltraps 80105a8a: e9 2e f9 ff ff jmp 801053bd <alltraps> 80105a8f <vector65>: .globl vector65 vector65: pushl $0 80105a8f: 6a 00 push $0x0 pushl $65 80105a91: 6a 41 push $0x41 jmp alltraps 80105a93: e9 25 f9 ff ff jmp 801053bd <alltraps> 80105a98 <vector66>: .globl vector66 vector66: pushl $0 80105a98: 6a 00 push $0x0 pushl $66 80105a9a: 6a 42 push $0x42 jmp alltraps 80105a9c: e9 1c f9 ff ff jmp 801053bd <alltraps> 80105aa1 <vector67>: .globl vector67 vector67: pushl $0 80105aa1: 6a 00 push $0x0 pushl $67 80105aa3: 6a 43 push $0x43 jmp alltraps 80105aa5: e9 13 f9 ff ff jmp 801053bd <alltraps> 80105aaa <vector68>: .globl vector68 vector68: pushl $0 80105aaa: 6a 00 push $0x0 pushl $68 80105aac: 6a 44 push $0x44 jmp alltraps 80105aae: e9 0a f9 ff ff jmp 801053bd <alltraps> 80105ab3 <vector69>: .globl vector69 vector69: pushl $0 80105ab3: 6a 00 push $0x0 pushl $69 80105ab5: 6a 45 push $0x45 jmp alltraps 80105ab7: e9 01 f9 ff ff jmp 801053bd <alltraps> 80105abc <vector70>: .globl vector70 vector70: pushl $0 80105abc: 6a 00 push $0x0 pushl $70 80105abe: 6a 46 push $0x46 jmp alltraps 80105ac0: e9 f8 f8 ff ff jmp 801053bd <alltraps> 80105ac5 <vector71>: .globl vector71 vector71: pushl $0 80105ac5: 6a 00 push $0x0 pushl $71 80105ac7: 6a 47 push $0x47 jmp alltraps 80105ac9: e9 ef f8 ff ff jmp 801053bd <alltraps> 80105ace <vector72>: .globl vector72 vector72: pushl $0 80105ace: 6a 00 push $0x0 pushl $72 80105ad0: 6a 48 push $0x48 jmp alltraps 80105ad2: e9 e6 f8 ff ff jmp 801053bd <alltraps> 80105ad7 <vector73>: .globl vector73 vector73: pushl $0 80105ad7: 6a 00 push $0x0 pushl $73 80105ad9: 6a 49 push $0x49 jmp alltraps 80105adb: e9 dd f8 ff ff jmp 801053bd <alltraps> 80105ae0 <vector74>: .globl vector74 vector74: pushl $0 80105ae0: 6a 00 push $0x0 pushl $74 80105ae2: 6a 4a push $0x4a jmp alltraps 80105ae4: e9 d4 f8 ff ff jmp 801053bd <alltraps> 80105ae9 <vector75>: .globl vector75 vector75: pushl $0 80105ae9: 6a 00 push $0x0 pushl $75 80105aeb: 6a 4b push $0x4b jmp alltraps 80105aed: e9 cb f8 ff ff jmp 801053bd <alltraps> 80105af2 <vector76>: .globl vector76 vector76: pushl $0 80105af2: 6a 00 push $0x0 pushl $76 80105af4: 6a 4c push $0x4c jmp alltraps 80105af6: e9 c2 f8 ff ff jmp 801053bd <alltraps> 80105afb <vector77>: .globl vector77 vector77: pushl $0 80105afb: 6a 00 push $0x0 pushl $77 80105afd: 6a 4d push $0x4d jmp alltraps 80105aff: e9 b9 f8 ff ff jmp 801053bd <alltraps> 80105b04 <vector78>: .globl vector78 vector78: pushl $0 80105b04: 6a 00 push $0x0 pushl $78 80105b06: 6a 4e push $0x4e jmp alltraps 80105b08: e9 b0 f8 ff ff jmp 801053bd <alltraps> 80105b0d <vector79>: .globl vector79 vector79: pushl $0 80105b0d: 6a 00 push $0x0 pushl $79 80105b0f: 6a 4f push $0x4f jmp alltraps 80105b11: e9 a7 f8 ff ff jmp 801053bd <alltraps> 80105b16 <vector80>: .globl vector80 vector80: pushl $0 80105b16: 6a 00 push $0x0 pushl $80 80105b18: 6a 50 push $0x50 jmp alltraps 80105b1a: e9 9e f8 ff ff jmp 801053bd <alltraps> 80105b1f <vector81>: .globl vector81 vector81: pushl $0 80105b1f: 6a 00 push $0x0 pushl $81 80105b21: 6a 51 push $0x51 jmp alltraps 80105b23: e9 95 f8 ff ff jmp 801053bd <alltraps> 80105b28 <vector82>: .globl vector82 vector82: pushl $0 80105b28: 6a 00 push $0x0 pushl $82 80105b2a: 6a 52 push $0x52 jmp alltraps 80105b2c: e9 8c f8 ff ff jmp 801053bd <alltraps> 80105b31 <vector83>: .globl vector83 vector83: pushl $0 80105b31: 6a 00 push $0x0 pushl $83 80105b33: 6a 53 push $0x53 jmp alltraps 80105b35: e9 83 f8 ff ff jmp 801053bd <alltraps> 80105b3a <vector84>: .globl vector84 vector84: pushl $0 80105b3a: 6a 00 push $0x0 pushl $84 80105b3c: 6a 54 push $0x54 jmp alltraps 80105b3e: e9 7a f8 ff ff jmp 801053bd <alltraps> 80105b43 <vector85>: .globl vector85 vector85: pushl $0 80105b43: 6a 00 push $0x0 pushl $85 80105b45: 6a 55 push $0x55 jmp alltraps 80105b47: e9 71 f8 ff ff jmp 801053bd <alltraps> 80105b4c <vector86>: .globl vector86 vector86: pushl $0 80105b4c: 6a 00 push $0x0 pushl $86 80105b4e: 6a 56 push $0x56 jmp alltraps 80105b50: e9 68 f8 ff ff jmp 801053bd <alltraps> 80105b55 <vector87>: .globl vector87 vector87: pushl $0 80105b55: 6a 00 push $0x0 pushl $87 80105b57: 6a 57 push $0x57 jmp alltraps 80105b59: e9 5f f8 ff ff jmp 801053bd <alltraps> 80105b5e <vector88>: .globl vector88 vector88: pushl $0 80105b5e: 6a 00 push $0x0 pushl $88 80105b60: 6a 58 push $0x58 jmp alltraps 80105b62: e9 56 f8 ff ff jmp 801053bd <alltraps> 80105b67 <vector89>: .globl vector89 vector89: pushl $0 80105b67: 6a 00 push $0x0 pushl $89 80105b69: 6a 59 push $0x59 jmp alltraps 80105b6b: e9 4d f8 ff ff jmp 801053bd <alltraps> 80105b70 <vector90>: .globl vector90 vector90: pushl $0 80105b70: 6a 00 push $0x0 pushl $90 80105b72: 6a 5a push $0x5a jmp alltraps 80105b74: e9 44 f8 ff ff jmp 801053bd <alltraps> 80105b79 <vector91>: .globl vector91 vector91: pushl $0 80105b79: 6a 00 push $0x0 pushl $91 80105b7b: 6a 5b push $0x5b jmp alltraps 80105b7d: e9 3b f8 ff ff jmp 801053bd <alltraps> 80105b82 <vector92>: .globl vector92 vector92: pushl $0 80105b82: 6a 00 push $0x0 pushl $92 80105b84: 6a 5c push $0x5c jmp alltraps 80105b86: e9 32 f8 ff ff jmp 801053bd <alltraps> 80105b8b <vector93>: .globl vector93 vector93: pushl $0 80105b8b: 6a 00 push $0x0 pushl $93 80105b8d: 6a 5d push $0x5d jmp alltraps 80105b8f: e9 29 f8 ff ff jmp 801053bd <alltraps> 80105b94 <vector94>: .globl vector94 vector94: pushl $0 80105b94: 6a 00 push $0x0 pushl $94 80105b96: 6a 5e push $0x5e jmp alltraps 80105b98: e9 20 f8 ff ff jmp 801053bd <alltraps> 80105b9d <vector95>: .globl vector95 vector95: pushl $0 80105b9d: 6a 00 push $0x0 pushl $95 80105b9f: 6a 5f push $0x5f jmp alltraps 80105ba1: e9 17 f8 ff ff jmp 801053bd <alltraps> 80105ba6 <vector96>: .globl vector96 vector96: pushl $0 80105ba6: 6a 00 push $0x0 pushl $96 80105ba8: 6a 60 push $0x60 jmp alltraps 80105baa: e9 0e f8 ff ff jmp 801053bd <alltraps> 80105baf <vector97>: .globl vector97 vector97: pushl $0 80105baf: 6a 00 push $0x0 pushl $97 80105bb1: 6a 61 push $0x61 jmp alltraps 80105bb3: e9 05 f8 ff ff jmp 801053bd <alltraps> 80105bb8 <vector98>: .globl vector98 vector98: pushl $0 80105bb8: 6a 00 push $0x0 pushl $98 80105bba: 6a 62 push $0x62 jmp alltraps 80105bbc: e9 fc f7 ff ff jmp 801053bd <alltraps> 80105bc1 <vector99>: .globl vector99 vector99: pushl $0 80105bc1: 6a 00 push $0x0 pushl $99 80105bc3: 6a 63 push $0x63 jmp alltraps 80105bc5: e9 f3 f7 ff ff jmp 801053bd <alltraps> 80105bca <vector100>: .globl vector100 vector100: pushl $0 80105bca: 6a 00 push $0x0 pushl $100 80105bcc: 6a 64 push $0x64 jmp alltraps 80105bce: e9 ea f7 ff ff jmp 801053bd <alltraps> 80105bd3 <vector101>: .globl vector101 vector101: pushl $0 80105bd3: 6a 00 push $0x0 pushl $101 80105bd5: 6a 65 push $0x65 jmp alltraps 80105bd7: e9 e1 f7 ff ff jmp 801053bd <alltraps> 80105bdc <vector102>: .globl vector102 vector102: pushl $0 80105bdc: 6a 00 push $0x0 pushl $102 80105bde: 6a 66 push $0x66 jmp alltraps 80105be0: e9 d8 f7 ff ff jmp 801053bd <alltraps> 80105be5 <vector103>: .globl vector103 vector103: pushl $0 80105be5: 6a 00 push $0x0 pushl $103 80105be7: 6a 67 push $0x67 jmp alltraps 80105be9: e9 cf f7 ff ff jmp 801053bd <alltraps> 80105bee <vector104>: .globl vector104 vector104: pushl $0 80105bee: 6a 00 push $0x0 pushl $104 80105bf0: 6a 68 push $0x68 jmp alltraps 80105bf2: e9 c6 f7 ff ff jmp 801053bd <alltraps> 80105bf7 <vector105>: .globl vector105 vector105: pushl $0 80105bf7: 6a 00 push $0x0 pushl $105 80105bf9: 6a 69 push $0x69 jmp alltraps 80105bfb: e9 bd f7 ff ff jmp 801053bd <alltraps> 80105c00 <vector106>: .globl vector106 vector106: pushl $0 80105c00: 6a 00 push $0x0 pushl $106 80105c02: 6a 6a push $0x6a jmp alltraps 80105c04: e9 b4 f7 ff ff jmp 801053bd <alltraps> 80105c09 <vector107>: .globl vector107 vector107: pushl $0 80105c09: 6a 00 push $0x0 pushl $107 80105c0b: 6a 6b push $0x6b jmp alltraps 80105c0d: e9 ab f7 ff ff jmp 801053bd <alltraps> 80105c12 <vector108>: .globl vector108 vector108: pushl $0 80105c12: 6a 00 push $0x0 pushl $108 80105c14: 6a 6c push $0x6c jmp alltraps 80105c16: e9 a2 f7 ff ff jmp 801053bd <alltraps> 80105c1b <vector109>: .globl vector109 vector109: pushl $0 80105c1b: 6a 00 push $0x0 pushl $109 80105c1d: 6a 6d push $0x6d jmp alltraps 80105c1f: e9 99 f7 ff ff jmp 801053bd <alltraps> 80105c24 <vector110>: .globl vector110 vector110: pushl $0 80105c24: 6a 00 push $0x0 pushl $110 80105c26: 6a 6e push $0x6e jmp alltraps 80105c28: e9 90 f7 ff ff jmp 801053bd <alltraps> 80105c2d <vector111>: .globl vector111 vector111: pushl $0 80105c2d: 6a 00 push $0x0 pushl $111 80105c2f: 6a 6f push $0x6f jmp alltraps 80105c31: e9 87 f7 ff ff jmp 801053bd <alltraps> 80105c36 <vector112>: .globl vector112 vector112: pushl $0 80105c36: 6a 00 push $0x0 pushl $112 80105c38: 6a 70 push $0x70 jmp alltraps 80105c3a: e9 7e f7 ff ff jmp 801053bd <alltraps> 80105c3f <vector113>: .globl vector113 vector113: pushl $0 80105c3f: 6a 00 push $0x0 pushl $113 80105c41: 6a 71 push $0x71 jmp alltraps 80105c43: e9 75 f7 ff ff jmp 801053bd <alltraps> 80105c48 <vector114>: .globl vector114 vector114: pushl $0 80105c48: 6a 00 push $0x0 pushl $114 80105c4a: 6a 72 push $0x72 jmp alltraps 80105c4c: e9 6c f7 ff ff jmp 801053bd <alltraps> 80105c51 <vector115>: .globl vector115 vector115: pushl $0 80105c51: 6a 00 push $0x0 pushl $115 80105c53: 6a 73 push $0x73 jmp alltraps 80105c55: e9 63 f7 ff ff jmp 801053bd <alltraps> 80105c5a <vector116>: .globl vector116 vector116: pushl $0 80105c5a: 6a 00 push $0x0 pushl $116 80105c5c: 6a 74 push $0x74 jmp alltraps 80105c5e: e9 5a f7 ff ff jmp 801053bd <alltraps> 80105c63 <vector117>: .globl vector117 vector117: pushl $0 80105c63: 6a 00 push $0x0 pushl $117 80105c65: 6a 75 push $0x75 jmp alltraps 80105c67: e9 51 f7 ff ff jmp 801053bd <alltraps> 80105c6c <vector118>: .globl vector118 vector118: pushl $0 80105c6c: 6a 00 push $0x0 pushl $118 80105c6e: 6a 76 push $0x76 jmp alltraps 80105c70: e9 48 f7 ff ff jmp 801053bd <alltraps> 80105c75 <vector119>: .globl vector119 vector119: pushl $0 80105c75: 6a 00 push $0x0 pushl $119 80105c77: 6a 77 push $0x77 jmp alltraps 80105c79: e9 3f f7 ff ff jmp 801053bd <alltraps> 80105c7e <vector120>: .globl vector120 vector120: pushl $0 80105c7e: 6a 00 push $0x0 pushl $120 80105c80: 6a 78 push $0x78 jmp alltraps 80105c82: e9 36 f7 ff ff jmp 801053bd <alltraps> 80105c87 <vector121>: .globl vector121 vector121: pushl $0 80105c87: 6a 00 push $0x0 pushl $121 80105c89: 6a 79 push $0x79 jmp alltraps 80105c8b: e9 2d f7 ff ff jmp 801053bd <alltraps> 80105c90 <vector122>: .globl vector122 vector122: pushl $0 80105c90: 6a 00 push $0x0 pushl $122 80105c92: 6a 7a push $0x7a jmp alltraps 80105c94: e9 24 f7 ff ff jmp 801053bd <alltraps> 80105c99 <vector123>: .globl vector123 vector123: pushl $0 80105c99: 6a 00 push $0x0 pushl $123 80105c9b: 6a 7b push $0x7b jmp alltraps 80105c9d: e9 1b f7 ff ff jmp 801053bd <alltraps> 80105ca2 <vector124>: .globl vector124 vector124: pushl $0 80105ca2: 6a 00 push $0x0 pushl $124 80105ca4: 6a 7c push $0x7c jmp alltraps 80105ca6: e9 12 f7 ff ff jmp 801053bd <alltraps> 80105cab <vector125>: .globl vector125 vector125: pushl $0 80105cab: 6a 00 push $0x0 pushl $125 80105cad: 6a 7d push $0x7d jmp alltraps 80105caf: e9 09 f7 ff ff jmp 801053bd <alltraps> 80105cb4 <vector126>: .globl vector126 vector126: pushl $0 80105cb4: 6a 00 push $0x0 pushl $126 80105cb6: 6a 7e push $0x7e jmp alltraps 80105cb8: e9 00 f7 ff ff jmp 801053bd <alltraps> 80105cbd <vector127>: .globl vector127 vector127: pushl $0 80105cbd: 6a 00 push $0x0 pushl $127 80105cbf: 6a 7f push $0x7f jmp alltraps 80105cc1: e9 f7 f6 ff ff jmp 801053bd <alltraps> 80105cc6 <vector128>: .globl vector128 vector128: pushl $0 80105cc6: 6a 00 push $0x0 pushl $128 80105cc8: 68 80 00 00 00 push $0x80 jmp alltraps 80105ccd: e9 eb f6 ff ff jmp 801053bd <alltraps> 80105cd2 <vector129>: .globl vector129 vector129: pushl $0 80105cd2: 6a 00 push $0x0 pushl $129 80105cd4: 68 81 00 00 00 push $0x81 jmp alltraps 80105cd9: e9 df f6 ff ff jmp 801053bd <alltraps> 80105cde <vector130>: .globl vector130 vector130: pushl $0 80105cde: 6a 00 push $0x0 pushl $130 80105ce0: 68 82 00 00 00 push $0x82 jmp alltraps 80105ce5: e9 d3 f6 ff ff jmp 801053bd <alltraps> 80105cea <vector131>: .globl vector131 vector131: pushl $0 80105cea: 6a 00 push $0x0 pushl $131 80105cec: 68 83 00 00 00 push $0x83 jmp alltraps 80105cf1: e9 c7 f6 ff ff jmp 801053bd <alltraps> 80105cf6 <vector132>: .globl vector132 vector132: pushl $0 80105cf6: 6a 00 push $0x0 pushl $132 80105cf8: 68 84 00 00 00 push $0x84 jmp alltraps 80105cfd: e9 bb f6 ff ff jmp 801053bd <alltraps> 80105d02 <vector133>: .globl vector133 vector133: pushl $0 80105d02: 6a 00 push $0x0 pushl $133 80105d04: 68 85 00 00 00 push $0x85 jmp alltraps 80105d09: e9 af f6 ff ff jmp 801053bd <alltraps> 80105d0e <vector134>: .globl vector134 vector134: pushl $0 80105d0e: 6a 00 push $0x0 pushl $134 80105d10: 68 86 00 00 00 push $0x86 jmp alltraps 80105d15: e9 a3 f6 ff ff jmp 801053bd <alltraps> 80105d1a <vector135>: .globl vector135 vector135: pushl $0 80105d1a: 6a 00 push $0x0 pushl $135 80105d1c: 68 87 00 00 00 push $0x87 jmp alltraps 80105d21: e9 97 f6 ff ff jmp 801053bd <alltraps> 80105d26 <vector136>: .globl vector136 vector136: pushl $0 80105d26: 6a 00 push $0x0 pushl $136 80105d28: 68 88 00 00 00 push $0x88 jmp alltraps 80105d2d: e9 8b f6 ff ff jmp 801053bd <alltraps> 80105d32 <vector137>: .globl vector137 vector137: pushl $0 80105d32: 6a 00 push $0x0 pushl $137 80105d34: 68 89 00 00 00 push $0x89 jmp alltraps 80105d39: e9 7f f6 ff ff jmp 801053bd <alltraps> 80105d3e <vector138>: .globl vector138 vector138: pushl $0 80105d3e: 6a 00 push $0x0 pushl $138 80105d40: 68 8a 00 00 00 push $0x8a jmp alltraps 80105d45: e9 73 f6 ff ff jmp 801053bd <alltraps> 80105d4a <vector139>: .globl vector139 vector139: pushl $0 80105d4a: 6a 00 push $0x0 pushl $139 80105d4c: 68 8b 00 00 00 push $0x8b jmp alltraps 80105d51: e9 67 f6 ff ff jmp 801053bd <alltraps> 80105d56 <vector140>: .globl vector140 vector140: pushl $0 80105d56: 6a 00 push $0x0 pushl $140 80105d58: 68 8c 00 00 00 push $0x8c jmp alltraps 80105d5d: e9 5b f6 ff ff jmp 801053bd <alltraps> 80105d62 <vector141>: .globl vector141 vector141: pushl $0 80105d62: 6a 00 push $0x0 pushl $141 80105d64: 68 8d 00 00 00 push $0x8d jmp alltraps 80105d69: e9 4f f6 ff ff jmp 801053bd <alltraps> 80105d6e <vector142>: .globl vector142 vector142: pushl $0 80105d6e: 6a 00 push $0x0 pushl $142 80105d70: 68 8e 00 00 00 push $0x8e jmp alltraps 80105d75: e9 43 f6 ff ff jmp 801053bd <alltraps> 80105d7a <vector143>: .globl vector143 vector143: pushl $0 80105d7a: 6a 00 push $0x0 pushl $143 80105d7c: 68 8f 00 00 00 push $0x8f jmp alltraps 80105d81: e9 37 f6 ff ff jmp 801053bd <alltraps> 80105d86 <vector144>: .globl vector144 vector144: pushl $0 80105d86: 6a 00 push $0x0 pushl $144 80105d88: 68 90 00 00 00 push $0x90 jmp alltraps 80105d8d: e9 2b f6 ff ff jmp 801053bd <alltraps> 80105d92 <vector145>: .globl vector145 vector145: pushl $0 80105d92: 6a 00 push $0x0 pushl $145 80105d94: 68 91 00 00 00 push $0x91 jmp alltraps 80105d99: e9 1f f6 ff ff jmp 801053bd <alltraps> 80105d9e <vector146>: .globl vector146 vector146: pushl $0 80105d9e: 6a 00 push $0x0 pushl $146 80105da0: 68 92 00 00 00 push $0x92 jmp alltraps 80105da5: e9 13 f6 ff ff jmp 801053bd <alltraps> 80105daa <vector147>: .globl vector147 vector147: pushl $0 80105daa: 6a 00 push $0x0 pushl $147 80105dac: 68 93 00 00 00 push $0x93 jmp alltraps 80105db1: e9 07 f6 ff ff jmp 801053bd <alltraps> 80105db6 <vector148>: .globl vector148 vector148: pushl $0 80105db6: 6a 00 push $0x0 pushl $148 80105db8: 68 94 00 00 00 push $0x94 jmp alltraps 80105dbd: e9 fb f5 ff ff jmp 801053bd <alltraps> 80105dc2 <vector149>: .globl vector149 vector149: pushl $0 80105dc2: 6a 00 push $0x0 pushl $149 80105dc4: 68 95 00 00 00 push $0x95 jmp alltraps 80105dc9: e9 ef f5 ff ff jmp 801053bd <alltraps> 80105dce <vector150>: .globl vector150 vector150: pushl $0 80105dce: 6a 00 push $0x0 pushl $150 80105dd0: 68 96 00 00 00 push $0x96 jmp alltraps 80105dd5: e9 e3 f5 ff ff jmp 801053bd <alltraps> 80105dda <vector151>: .globl vector151 vector151: pushl $0 80105dda: 6a 00 push $0x0 pushl $151 80105ddc: 68 97 00 00 00 push $0x97 jmp alltraps 80105de1: e9 d7 f5 ff ff jmp 801053bd <alltraps> 80105de6 <vector152>: .globl vector152 vector152: pushl $0 80105de6: 6a 00 push $0x0 pushl $152 80105de8: 68 98 00 00 00 push $0x98 jmp alltraps 80105ded: e9 cb f5 ff ff jmp 801053bd <alltraps> 80105df2 <vector153>: .globl vector153 vector153: pushl $0 80105df2: 6a 00 push $0x0 pushl $153 80105df4: 68 99 00 00 00 push $0x99 jmp alltraps 80105df9: e9 bf f5 ff ff jmp 801053bd <alltraps> 80105dfe <vector154>: .globl vector154 vector154: pushl $0 80105dfe: 6a 00 push $0x0 pushl $154 80105e00: 68 9a 00 00 00 push $0x9a jmp alltraps 80105e05: e9 b3 f5 ff ff jmp 801053bd <alltraps> 80105e0a <vector155>: .globl vector155 vector155: pushl $0 80105e0a: 6a 00 push $0x0 pushl $155 80105e0c: 68 9b 00 00 00 push $0x9b jmp alltraps 80105e11: e9 a7 f5 ff ff jmp 801053bd <alltraps> 80105e16 <vector156>: .globl vector156 vector156: pushl $0 80105e16: 6a 00 push $0x0 pushl $156 80105e18: 68 9c 00 00 00 push $0x9c jmp alltraps 80105e1d: e9 9b f5 ff ff jmp 801053bd <alltraps> 80105e22 <vector157>: .globl vector157 vector157: pushl $0 80105e22: 6a 00 push $0x0 pushl $157 80105e24: 68 9d 00 00 00 push $0x9d jmp alltraps 80105e29: e9 8f f5 ff ff jmp 801053bd <alltraps> 80105e2e <vector158>: .globl vector158 vector158: pushl $0 80105e2e: 6a 00 push $0x0 pushl $158 80105e30: 68 9e 00 00 00 push $0x9e jmp alltraps 80105e35: e9 83 f5 ff ff jmp 801053bd <alltraps> 80105e3a <vector159>: .globl vector159 vector159: pushl $0 80105e3a: 6a 00 push $0x0 pushl $159 80105e3c: 68 9f 00 00 00 push $0x9f jmp alltraps 80105e41: e9 77 f5 ff ff jmp 801053bd <alltraps> 80105e46 <vector160>: .globl vector160 vector160: pushl $0 80105e46: 6a 00 push $0x0 pushl $160 80105e48: 68 a0 00 00 00 push $0xa0 jmp alltraps 80105e4d: e9 6b f5 ff ff jmp 801053bd <alltraps> 80105e52 <vector161>: .globl vector161 vector161: pushl $0 80105e52: 6a 00 push $0x0 pushl $161 80105e54: 68 a1 00 00 00 push $0xa1 jmp alltraps 80105e59: e9 5f f5 ff ff jmp 801053bd <alltraps> 80105e5e <vector162>: .globl vector162 vector162: pushl $0 80105e5e: 6a 00 push $0x0 pushl $162 80105e60: 68 a2 00 00 00 push $0xa2 jmp alltraps 80105e65: e9 53 f5 ff ff jmp 801053bd <alltraps> 80105e6a <vector163>: .globl vector163 vector163: pushl $0 80105e6a: 6a 00 push $0x0 pushl $163 80105e6c: 68 a3 00 00 00 push $0xa3 jmp alltraps 80105e71: e9 47 f5 ff ff jmp 801053bd <alltraps> 80105e76 <vector164>: .globl vector164 vector164: pushl $0 80105e76: 6a 00 push $0x0 pushl $164 80105e78: 68 a4 00 00 00 push $0xa4 jmp alltraps 80105e7d: e9 3b f5 ff ff jmp 801053bd <alltraps> 80105e82 <vector165>: .globl vector165 vector165: pushl $0 80105e82: 6a 00 push $0x0 pushl $165 80105e84: 68 a5 00 00 00 push $0xa5 jmp alltraps 80105e89: e9 2f f5 ff ff jmp 801053bd <alltraps> 80105e8e <vector166>: .globl vector166 vector166: pushl $0 80105e8e: 6a 00 push $0x0 pushl $166 80105e90: 68 a6 00 00 00 push $0xa6 jmp alltraps 80105e95: e9 23 f5 ff ff jmp 801053bd <alltraps> 80105e9a <vector167>: .globl vector167 vector167: pushl $0 80105e9a: 6a 00 push $0x0 pushl $167 80105e9c: 68 a7 00 00 00 push $0xa7 jmp alltraps 80105ea1: e9 17 f5 ff ff jmp 801053bd <alltraps> 80105ea6 <vector168>: .globl vector168 vector168: pushl $0 80105ea6: 6a 00 push $0x0 pushl $168 80105ea8: 68 a8 00 00 00 push $0xa8 jmp alltraps 80105ead: e9 0b f5 ff ff jmp 801053bd <alltraps> 80105eb2 <vector169>: .globl vector169 vector169: pushl $0 80105eb2: 6a 00 push $0x0 pushl $169 80105eb4: 68 a9 00 00 00 push $0xa9 jmp alltraps 80105eb9: e9 ff f4 ff ff jmp 801053bd <alltraps> 80105ebe <vector170>: .globl vector170 vector170: pushl $0 80105ebe: 6a 00 push $0x0 pushl $170 80105ec0: 68 aa 00 00 00 push $0xaa jmp alltraps 80105ec5: e9 f3 f4 ff ff jmp 801053bd <alltraps> 80105eca <vector171>: .globl vector171 vector171: pushl $0 80105eca: 6a 00 push $0x0 pushl $171 80105ecc: 68 ab 00 00 00 push $0xab jmp alltraps 80105ed1: e9 e7 f4 ff ff jmp 801053bd <alltraps> 80105ed6 <vector172>: .globl vector172 vector172: pushl $0 80105ed6: 6a 00 push $0x0 pushl $172 80105ed8: 68 ac 00 00 00 push $0xac jmp alltraps 80105edd: e9 db f4 ff ff jmp 801053bd <alltraps> 80105ee2 <vector173>: .globl vector173 vector173: pushl $0 80105ee2: 6a 00 push $0x0 pushl $173 80105ee4: 68 ad 00 00 00 push $0xad jmp alltraps 80105ee9: e9 cf f4 ff ff jmp 801053bd <alltraps> 80105eee <vector174>: .globl vector174 vector174: pushl $0 80105eee: 6a 00 push $0x0 pushl $174 80105ef0: 68 ae 00 00 00 push $0xae jmp alltraps 80105ef5: e9 c3 f4 ff ff jmp 801053bd <alltraps> 80105efa <vector175>: .globl vector175 vector175: pushl $0 80105efa: 6a 00 push $0x0 pushl $175 80105efc: 68 af 00 00 00 push $0xaf jmp alltraps 80105f01: e9 b7 f4 ff ff jmp 801053bd <alltraps> 80105f06 <vector176>: .globl vector176 vector176: pushl $0 80105f06: 6a 00 push $0x0 pushl $176 80105f08: 68 b0 00 00 00 push $0xb0 jmp alltraps 80105f0d: e9 ab f4 ff ff jmp 801053bd <alltraps> 80105f12 <vector177>: .globl vector177 vector177: pushl $0 80105f12: 6a 00 push $0x0 pushl $177 80105f14: 68 b1 00 00 00 push $0xb1 jmp alltraps 80105f19: e9 9f f4 ff ff jmp 801053bd <alltraps> 80105f1e <vector178>: .globl vector178 vector178: pushl $0 80105f1e: 6a 00 push $0x0 pushl $178 80105f20: 68 b2 00 00 00 push $0xb2 jmp alltraps 80105f25: e9 93 f4 ff ff jmp 801053bd <alltraps> 80105f2a <vector179>: .globl vector179 vector179: pushl $0 80105f2a: 6a 00 push $0x0 pushl $179 80105f2c: 68 b3 00 00 00 push $0xb3 jmp alltraps 80105f31: e9 87 f4 ff ff jmp 801053bd <alltraps> 80105f36 <vector180>: .globl vector180 vector180: pushl $0 80105f36: 6a 00 push $0x0 pushl $180 80105f38: 68 b4 00 00 00 push $0xb4 jmp alltraps 80105f3d: e9 7b f4 ff ff jmp 801053bd <alltraps> 80105f42 <vector181>: .globl vector181 vector181: pushl $0 80105f42: 6a 00 push $0x0 pushl $181 80105f44: 68 b5 00 00 00 push $0xb5 jmp alltraps 80105f49: e9 6f f4 ff ff jmp 801053bd <alltraps> 80105f4e <vector182>: .globl vector182 vector182: pushl $0 80105f4e: 6a 00 push $0x0 pushl $182 80105f50: 68 b6 00 00 00 push $0xb6 jmp alltraps 80105f55: e9 63 f4 ff ff jmp 801053bd <alltraps> 80105f5a <vector183>: .globl vector183 vector183: pushl $0 80105f5a: 6a 00 push $0x0 pushl $183 80105f5c: 68 b7 00 00 00 push $0xb7 jmp alltraps 80105f61: e9 57 f4 ff ff jmp 801053bd <alltraps> 80105f66 <vector184>: .globl vector184 vector184: pushl $0 80105f66: 6a 00 push $0x0 pushl $184 80105f68: 68 b8 00 00 00 push $0xb8 jmp alltraps 80105f6d: e9 4b f4 ff ff jmp 801053bd <alltraps> 80105f72 <vector185>: .globl vector185 vector185: pushl $0 80105f72: 6a 00 push $0x0 pushl $185 80105f74: 68 b9 00 00 00 push $0xb9 jmp alltraps 80105f79: e9 3f f4 ff ff jmp 801053bd <alltraps> 80105f7e <vector186>: .globl vector186 vector186: pushl $0 80105f7e: 6a 00 push $0x0 pushl $186 80105f80: 68 ba 00 00 00 push $0xba jmp alltraps 80105f85: e9 33 f4 ff ff jmp 801053bd <alltraps> 80105f8a <vector187>: .globl vector187 vector187: pushl $0 80105f8a: 6a 00 push $0x0 pushl $187 80105f8c: 68 bb 00 00 00 push $0xbb jmp alltraps 80105f91: e9 27 f4 ff ff jmp 801053bd <alltraps> 80105f96 <vector188>: .globl vector188 vector188: pushl $0 80105f96: 6a 00 push $0x0 pushl $188 80105f98: 68 bc 00 00 00 push $0xbc jmp alltraps 80105f9d: e9 1b f4 ff ff jmp 801053bd <alltraps> 80105fa2 <vector189>: .globl vector189 vector189: pushl $0 80105fa2: 6a 00 push $0x0 pushl $189 80105fa4: 68 bd 00 00 00 push $0xbd jmp alltraps 80105fa9: e9 0f f4 ff ff jmp 801053bd <alltraps> 80105fae <vector190>: .globl vector190 vector190: pushl $0 80105fae: 6a 00 push $0x0 pushl $190 80105fb0: 68 be 00 00 00 push $0xbe jmp alltraps 80105fb5: e9 03 f4 ff ff jmp 801053bd <alltraps> 80105fba <vector191>: .globl vector191 vector191: pushl $0 80105fba: 6a 00 push $0x0 pushl $191 80105fbc: 68 bf 00 00 00 push $0xbf jmp alltraps 80105fc1: e9 f7 f3 ff ff jmp 801053bd <alltraps> 80105fc6 <vector192>: .globl vector192 vector192: pushl $0 80105fc6: 6a 00 push $0x0 pushl $192 80105fc8: 68 c0 00 00 00 push $0xc0 jmp alltraps 80105fcd: e9 eb f3 ff ff jmp 801053bd <alltraps> 80105fd2 <vector193>: .globl vector193 vector193: pushl $0 80105fd2: 6a 00 push $0x0 pushl $193 80105fd4: 68 c1 00 00 00 push $0xc1 jmp alltraps 80105fd9: e9 df f3 ff ff jmp 801053bd <alltraps> 80105fde <vector194>: .globl vector194 vector194: pushl $0 80105fde: 6a 00 push $0x0 pushl $194 80105fe0: 68 c2 00 00 00 push $0xc2 jmp alltraps 80105fe5: e9 d3 f3 ff ff jmp 801053bd <alltraps> 80105fea <vector195>: .globl vector195 vector195: pushl $0 80105fea: 6a 00 push $0x0 pushl $195 80105fec: 68 c3 00 00 00 push $0xc3 jmp alltraps 80105ff1: e9 c7 f3 ff ff jmp 801053bd <alltraps> 80105ff6 <vector196>: .globl vector196 vector196: pushl $0 80105ff6: 6a 00 push $0x0 pushl $196 80105ff8: 68 c4 00 00 00 push $0xc4 jmp alltraps 80105ffd: e9 bb f3 ff ff jmp 801053bd <alltraps> 80106002 <vector197>: .globl vector197 vector197: pushl $0 80106002: 6a 00 push $0x0 pushl $197 80106004: 68 c5 00 00 00 push $0xc5 jmp alltraps 80106009: e9 af f3 ff ff jmp 801053bd <alltraps> 8010600e <vector198>: .globl vector198 vector198: pushl $0 8010600e: 6a 00 push $0x0 pushl $198 80106010: 68 c6 00 00 00 push $0xc6 jmp alltraps 80106015: e9 a3 f3 ff ff jmp 801053bd <alltraps> 8010601a <vector199>: .globl vector199 vector199: pushl $0 8010601a: 6a 00 push $0x0 pushl $199 8010601c: 68 c7 00 00 00 push $0xc7 jmp alltraps 80106021: e9 97 f3 ff ff jmp 801053bd <alltraps> 80106026 <vector200>: .globl vector200 vector200: pushl $0 80106026: 6a 00 push $0x0 pushl $200 80106028: 68 c8 00 00 00 push $0xc8 jmp alltraps 8010602d: e9 8b f3 ff ff jmp 801053bd <alltraps> 80106032 <vector201>: .globl vector201 vector201: pushl $0 80106032: 6a 00 push $0x0 pushl $201 80106034: 68 c9 00 00 00 push $0xc9 jmp alltraps 80106039: e9 7f f3 ff ff jmp 801053bd <alltraps> 8010603e <vector202>: .globl vector202 vector202: pushl $0 8010603e: 6a 00 push $0x0 pushl $202 80106040: 68 ca 00 00 00 push $0xca jmp alltraps 80106045: e9 73 f3 ff ff jmp 801053bd <alltraps> 8010604a <vector203>: .globl vector203 vector203: pushl $0 8010604a: 6a 00 push $0x0 pushl $203 8010604c: 68 cb 00 00 00 push $0xcb jmp alltraps 80106051: e9 67 f3 ff ff jmp 801053bd <alltraps> 80106056 <vector204>: .globl vector204 vector204: pushl $0 80106056: 6a 00 push $0x0 pushl $204 80106058: 68 cc 00 00 00 push $0xcc jmp alltraps 8010605d: e9 5b f3 ff ff jmp 801053bd <alltraps> 80106062 <vector205>: .globl vector205 vector205: pushl $0 80106062: 6a 00 push $0x0 pushl $205 80106064: 68 cd 00 00 00 push $0xcd jmp alltraps 80106069: e9 4f f3 ff ff jmp 801053bd <alltraps> 8010606e <vector206>: .globl vector206 vector206: pushl $0 8010606e: 6a 00 push $0x0 pushl $206 80106070: 68 ce 00 00 00 push $0xce jmp alltraps 80106075: e9 43 f3 ff ff jmp 801053bd <alltraps> 8010607a <vector207>: .globl vector207 vector207: pushl $0 8010607a: 6a 00 push $0x0 pushl $207 8010607c: 68 cf 00 00 00 push $0xcf jmp alltraps 80106081: e9 37 f3 ff ff jmp 801053bd <alltraps> 80106086 <vector208>: .globl vector208 vector208: pushl $0 80106086: 6a 00 push $0x0 pushl $208 80106088: 68 d0 00 00 00 push $0xd0 jmp alltraps 8010608d: e9 2b f3 ff ff jmp 801053bd <alltraps> 80106092 <vector209>: .globl vector209 vector209: pushl $0 80106092: 6a 00 push $0x0 pushl $209 80106094: 68 d1 00 00 00 push $0xd1 jmp alltraps 80106099: e9 1f f3 ff ff jmp 801053bd <alltraps> 8010609e <vector210>: .globl vector210 vector210: pushl $0 8010609e: 6a 00 push $0x0 pushl $210 801060a0: 68 d2 00 00 00 push $0xd2 jmp alltraps 801060a5: e9 13 f3 ff ff jmp 801053bd <alltraps> 801060aa <vector211>: .globl vector211 vector211: pushl $0 801060aa: 6a 00 push $0x0 pushl $211 801060ac: 68 d3 00 00 00 push $0xd3 jmp alltraps 801060b1: e9 07 f3 ff ff jmp 801053bd <alltraps> 801060b6 <vector212>: .globl vector212 vector212: pushl $0 801060b6: 6a 00 push $0x0 pushl $212 801060b8: 68 d4 00 00 00 push $0xd4 jmp alltraps 801060bd: e9 fb f2 ff ff jmp 801053bd <alltraps> 801060c2 <vector213>: .globl vector213 vector213: pushl $0 801060c2: 6a 00 push $0x0 pushl $213 801060c4: 68 d5 00 00 00 push $0xd5 jmp alltraps 801060c9: e9 ef f2 ff ff jmp 801053bd <alltraps> 801060ce <vector214>: .globl vector214 vector214: pushl $0 801060ce: 6a 00 push $0x0 pushl $214 801060d0: 68 d6 00 00 00 push $0xd6 jmp alltraps 801060d5: e9 e3 f2 ff ff jmp 801053bd <alltraps> 801060da <vector215>: .globl vector215 vector215: pushl $0 801060da: 6a 00 push $0x0 pushl $215 801060dc: 68 d7 00 00 00 push $0xd7 jmp alltraps 801060e1: e9 d7 f2 ff ff jmp 801053bd <alltraps> 801060e6 <vector216>: .globl vector216 vector216: pushl $0 801060e6: 6a 00 push $0x0 pushl $216 801060e8: 68 d8 00 00 00 push $0xd8 jmp alltraps 801060ed: e9 cb f2 ff ff jmp 801053bd <alltraps> 801060f2 <vector217>: .globl vector217 vector217: pushl $0 801060f2: 6a 00 push $0x0 pushl $217 801060f4: 68 d9 00 00 00 push $0xd9 jmp alltraps 801060f9: e9 bf f2 ff ff jmp 801053bd <alltraps> 801060fe <vector218>: .globl vector218 vector218: pushl $0 801060fe: 6a 00 push $0x0 pushl $218 80106100: 68 da 00 00 00 push $0xda jmp alltraps 80106105: e9 b3 f2 ff ff jmp 801053bd <alltraps> 8010610a <vector219>: .globl vector219 vector219: pushl $0 8010610a: 6a 00 push $0x0 pushl $219 8010610c: 68 db 00 00 00 push $0xdb jmp alltraps 80106111: e9 a7 f2 ff ff jmp 801053bd <alltraps> 80106116 <vector220>: .globl vector220 vector220: pushl $0 80106116: 6a 00 push $0x0 pushl $220 80106118: 68 dc 00 00 00 push $0xdc jmp alltraps 8010611d: e9 9b f2 ff ff jmp 801053bd <alltraps> 80106122 <vector221>: .globl vector221 vector221: pushl $0 80106122: 6a 00 push $0x0 pushl $221 80106124: 68 dd 00 00 00 push $0xdd jmp alltraps 80106129: e9 8f f2 ff ff jmp 801053bd <alltraps> 8010612e <vector222>: .globl vector222 vector222: pushl $0 8010612e: 6a 00 push $0x0 pushl $222 80106130: 68 de 00 00 00 push $0xde jmp alltraps 80106135: e9 83 f2 ff ff jmp 801053bd <alltraps> 8010613a <vector223>: .globl vector223 vector223: pushl $0 8010613a: 6a 00 push $0x0 pushl $223 8010613c: 68 df 00 00 00 push $0xdf jmp alltraps 80106141: e9 77 f2 ff ff jmp 801053bd <alltraps> 80106146 <vector224>: .globl vector224 vector224: pushl $0 80106146: 6a 00 push $0x0 pushl $224 80106148: 68 e0 00 00 00 push $0xe0 jmp alltraps 8010614d: e9 6b f2 ff ff jmp 801053bd <alltraps> 80106152 <vector225>: .globl vector225 vector225: pushl $0 80106152: 6a 00 push $0x0 pushl $225 80106154: 68 e1 00 00 00 push $0xe1 jmp alltraps 80106159: e9 5f f2 ff ff jmp 801053bd <alltraps> 8010615e <vector226>: .globl vector226 vector226: pushl $0 8010615e: 6a 00 push $0x0 pushl $226 80106160: 68 e2 00 00 00 push $0xe2 jmp alltraps 80106165: e9 53 f2 ff ff jmp 801053bd <alltraps> 8010616a <vector227>: .globl vector227 vector227: pushl $0 8010616a: 6a 00 push $0x0 pushl $227 8010616c: 68 e3 00 00 00 push $0xe3 jmp alltraps 80106171: e9 47 f2 ff ff jmp 801053bd <alltraps> 80106176 <vector228>: .globl vector228 vector228: pushl $0 80106176: 6a 00 push $0x0 pushl $228 80106178: 68 e4 00 00 00 push $0xe4 jmp alltraps 8010617d: e9 3b f2 ff ff jmp 801053bd <alltraps> 80106182 <vector229>: .globl vector229 vector229: pushl $0 80106182: 6a 00 push $0x0 pushl $229 80106184: 68 e5 00 00 00 push $0xe5 jmp alltraps 80106189: e9 2f f2 ff ff jmp 801053bd <alltraps> 8010618e <vector230>: .globl vector230 vector230: pushl $0 8010618e: 6a 00 push $0x0 pushl $230 80106190: 68 e6 00 00 00 push $0xe6 jmp alltraps 80106195: e9 23 f2 ff ff jmp 801053bd <alltraps> 8010619a <vector231>: .globl vector231 vector231: pushl $0 8010619a: 6a 00 push $0x0 pushl $231 8010619c: 68 e7 00 00 00 push $0xe7 jmp alltraps 801061a1: e9 17 f2 ff ff jmp 801053bd <alltraps> 801061a6 <vector232>: .globl vector232 vector232: pushl $0 801061a6: 6a 00 push $0x0 pushl $232 801061a8: 68 e8 00 00 00 push $0xe8 jmp alltraps 801061ad: e9 0b f2 ff ff jmp 801053bd <alltraps> 801061b2 <vector233>: .globl vector233 vector233: pushl $0 801061b2: 6a 00 push $0x0 pushl $233 801061b4: 68 e9 00 00 00 push $0xe9 jmp alltraps 801061b9: e9 ff f1 ff ff jmp 801053bd <alltraps> 801061be <vector234>: .globl vector234 vector234: pushl $0 801061be: 6a 00 push $0x0 pushl $234 801061c0: 68 ea 00 00 00 push $0xea jmp alltraps 801061c5: e9 f3 f1 ff ff jmp 801053bd <alltraps> 801061ca <vector235>: .globl vector235 vector235: pushl $0 801061ca: 6a 00 push $0x0 pushl $235 801061cc: 68 eb 00 00 00 push $0xeb jmp alltraps 801061d1: e9 e7 f1 ff ff jmp 801053bd <alltraps> 801061d6 <vector236>: .globl vector236 vector236: pushl $0 801061d6: 6a 00 push $0x0 pushl $236 801061d8: 68 ec 00 00 00 push $0xec jmp alltraps 801061dd: e9 db f1 ff ff jmp 801053bd <alltraps> 801061e2 <vector237>: .globl vector237 vector237: pushl $0 801061e2: 6a 00 push $0x0 pushl $237 801061e4: 68 ed 00 00 00 push $0xed jmp alltraps 801061e9: e9 cf f1 ff ff jmp 801053bd <alltraps> 801061ee <vector238>: .globl vector238 vector238: pushl $0 801061ee: 6a 00 push $0x0 pushl $238 801061f0: 68 ee 00 00 00 push $0xee jmp alltraps 801061f5: e9 c3 f1 ff ff jmp 801053bd <alltraps> 801061fa <vector239>: .globl vector239 vector239: pushl $0 801061fa: 6a 00 push $0x0 pushl $239 801061fc: 68 ef 00 00 00 push $0xef jmp alltraps 80106201: e9 b7 f1 ff ff jmp 801053bd <alltraps> 80106206 <vector240>: .globl vector240 vector240: pushl $0 80106206: 6a 00 push $0x0 pushl $240 80106208: 68 f0 00 00 00 push $0xf0 jmp alltraps 8010620d: e9 ab f1 ff ff jmp 801053bd <alltraps> 80106212 <vector241>: .globl vector241 vector241: pushl $0 80106212: 6a 00 push $0x0 pushl $241 80106214: 68 f1 00 00 00 push $0xf1 jmp alltraps 80106219: e9 9f f1 ff ff jmp 801053bd <alltraps> 8010621e <vector242>: .globl vector242 vector242: pushl $0 8010621e: 6a 00 push $0x0 pushl $242 80106220: 68 f2 00 00 00 push $0xf2 jmp alltraps 80106225: e9 93 f1 ff ff jmp 801053bd <alltraps> 8010622a <vector243>: .globl vector243 vector243: pushl $0 8010622a: 6a 00 push $0x0 pushl $243 8010622c: 68 f3 00 00 00 push $0xf3 jmp alltraps 80106231: e9 87 f1 ff ff jmp 801053bd <alltraps> 80106236 <vector244>: .globl vector244 vector244: pushl $0 80106236: 6a 00 push $0x0 pushl $244 80106238: 68 f4 00 00 00 push $0xf4 jmp alltraps 8010623d: e9 7b f1 ff ff jmp 801053bd <alltraps> 80106242 <vector245>: .globl vector245 vector245: pushl $0 80106242: 6a 00 push $0x0 pushl $245 80106244: 68 f5 00 00 00 push $0xf5 jmp alltraps 80106249: e9 6f f1 ff ff jmp 801053bd <alltraps> 8010624e <vector246>: .globl vector246 vector246: pushl $0 8010624e: 6a 00 push $0x0 pushl $246 80106250: 68 f6 00 00 00 push $0xf6 jmp alltraps 80106255: e9 63 f1 ff ff jmp 801053bd <alltraps> 8010625a <vector247>: .globl vector247 vector247: pushl $0 8010625a: 6a 00 push $0x0 pushl $247 8010625c: 68 f7 00 00 00 push $0xf7 jmp alltraps 80106261: e9 57 f1 ff ff jmp 801053bd <alltraps> 80106266 <vector248>: .globl vector248 vector248: pushl $0 80106266: 6a 00 push $0x0 pushl $248 80106268: 68 f8 00 00 00 push $0xf8 jmp alltraps 8010626d: e9 4b f1 ff ff jmp 801053bd <alltraps> 80106272 <vector249>: .globl vector249 vector249: pushl $0 80106272: 6a 00 push $0x0 pushl $249 80106274: 68 f9 00 00 00 push $0xf9 jmp alltraps 80106279: e9 3f f1 ff ff jmp 801053bd <alltraps> 8010627e <vector250>: .globl vector250 vector250: pushl $0 8010627e: 6a 00 push $0x0 pushl $250 80106280: 68 fa 00 00 00 push $0xfa jmp alltraps 80106285: e9 33 f1 ff ff jmp 801053bd <alltraps> 8010628a <vector251>: .globl vector251 vector251: pushl $0 8010628a: 6a 00 push $0x0 pushl $251 8010628c: 68 fb 00 00 00 push $0xfb jmp alltraps 80106291: e9 27 f1 ff ff jmp 801053bd <alltraps> 80106296 <vector252>: .globl vector252 vector252: pushl $0 80106296: 6a 00 push $0x0 pushl $252 80106298: 68 fc 00 00 00 push $0xfc jmp alltraps 8010629d: e9 1b f1 ff ff jmp 801053bd <alltraps> 801062a2 <vector253>: .globl vector253 vector253: pushl $0 801062a2: 6a 00 push $0x0 pushl $253 801062a4: 68 fd 00 00 00 push $0xfd jmp alltraps 801062a9: e9 0f f1 ff ff jmp 801053bd <alltraps> 801062ae <vector254>: .globl vector254 vector254: pushl $0 801062ae: 6a 00 push $0x0 pushl $254 801062b0: 68 fe 00 00 00 push $0xfe jmp alltraps 801062b5: e9 03 f1 ff ff jmp 801053bd <alltraps> 801062ba <vector255>: .globl vector255 vector255: pushl $0 801062ba: 6a 00 push $0x0 pushl $255 801062bc: 68 ff 00 00 00 push $0xff jmp alltraps 801062c1: e9 f7 f0 ff ff jmp 801053bd <alltraps> 801062c6: 66 90 xchg %ax,%ax 801062c8: 66 90 xchg %ax,%ax 801062ca: 66 90 xchg %ax,%ax 801062cc: 66 90 xchg %ax,%ax 801062ce: 66 90 xchg %ax,%ax 801062d0 <walkpgdir>: // Return the address of the PTE in page table pgdir // that corresponds to virtual address va. If alloc!=0, // create any required page table pages. static pte_t * walkpgdir(pde_t *pgdir, const void *va, int alloc) { 801062d0: 55 push %ebp 801062d1: 89 e5 mov %esp,%ebp 801062d3: 57 push %edi 801062d4: 56 push %esi 801062d5: 89 d6 mov %edx,%esi pde_t *pde; pte_t *pgtab; pde = &pgdir[PDX(va)]; 801062d7: c1 ea 16 shr $0x16,%edx { 801062da: 53 push %ebx pde = &pgdir[PDX(va)]; 801062db: 8d 3c 90 lea (%eax,%edx,4),%edi { 801062de: 83 ec 1c sub $0x1c,%esp if(*pde & PTE_P){ 801062e1: 8b 1f mov (%edi),%ebx 801062e3: f6 c3 01 test $0x1,%bl 801062e6: 74 28 je 80106310 <walkpgdir+0x40> pgtab = (pte_t*)P2V(PTE_ADDR(*pde)); 801062e8: 81 e3 00 f0 ff ff and $0xfffff000,%ebx 801062ee: 81 c3 00 00 00 80 add $0x80000000,%ebx // The permissions here are overly generous, but they can // be further restricted by the permissions in the page table // entries, if necessary. *pde = V2P(pgtab) | PTE_P | PTE_W | PTE_U; } return &pgtab[PTX(va)]; 801062f4: c1 ee 0a shr $0xa,%esi } 801062f7: 83 c4 1c add $0x1c,%esp return &pgtab[PTX(va)]; 801062fa: 89 f2 mov %esi,%edx 801062fc: 81 e2 fc 0f 00 00 and $0xffc,%edx 80106302: 8d 04 13 lea (%ebx,%edx,1),%eax } 80106305: 5b pop %ebx 80106306: 5e pop %esi 80106307: 5f pop %edi 80106308: 5d pop %ebp 80106309: c3 ret 8010630a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi if(!alloc || (pgtab = (pte_t*)kalloc()) == 0) 80106310: 85 c9 test %ecx,%ecx 80106312: 74 34 je 80106348 <walkpgdir+0x78> 80106314: e8 87 c1 ff ff call 801024a0 <kalloc> 80106319: 85 c0 test %eax,%eax 8010631b: 89 c3 mov %eax,%ebx 8010631d: 74 29 je 80106348 <walkpgdir+0x78> memset(pgtab, 0, PGSIZE); 8010631f: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 80106326: 00 80106327: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 8010632e: 00 8010632f: 89 04 24 mov %eax,(%esp) 80106332: e8 69 df ff ff call 801042a0 <memset> *pde = V2P(pgtab) | PTE_P | PTE_W | PTE_U; 80106337: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax 8010633d: 83 c8 07 or $0x7,%eax 80106340: 89 07 mov %eax,(%edi) 80106342: eb b0 jmp 801062f4 <walkpgdir+0x24> 80106344: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi } 80106348: 83 c4 1c add $0x1c,%esp return 0; 8010634b: 31 c0 xor %eax,%eax } 8010634d: 5b pop %ebx 8010634e: 5e pop %esi 8010634f: 5f pop %edi 80106350: 5d pop %ebp 80106351: c3 ret 80106352: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80106359: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80106360 <mappages>: // Create PTEs for virtual addresses starting at va that refer to // physical addresses starting at pa. va and size might not // be page-aligned. static int mappages(pde_t *pgdir, void *va, uint size, uint pa, int perm) { 80106360: 55 push %ebp 80106361: 89 e5 mov %esp,%ebp 80106363: 57 push %edi 80106364: 56 push %esi 80106365: 53 push %ebx char *a, *last; pte_t *pte; a = (char*)PGROUNDDOWN((uint)va); 80106366: 89 d3 mov %edx,%ebx { 80106368: 83 ec 1c sub $0x1c,%esp 8010636b: 8b 7d 08 mov 0x8(%ebp),%edi a = (char*)PGROUNDDOWN((uint)va); 8010636e: 81 e3 00 f0 ff ff and $0xfffff000,%ebx { 80106374: 89 45 e0 mov %eax,-0x20(%ebp) last = (char*)PGROUNDDOWN(((uint)va) + size - 1); 80106377: 8d 44 0a ff lea -0x1(%edx,%ecx,1),%eax 8010637b: 89 45 e4 mov %eax,-0x1c(%ebp) for(;;){ if((pte = walkpgdir(pgdir, a, 1)) == 0) return -1; if(*pte & PTE_P) panic("remap"); *pte = pa | perm | PTE_P; 8010637e: 83 4d 0c 01 orl $0x1,0xc(%ebp) last = (char*)PGROUNDDOWN(((uint)va) + size - 1); 80106382: 81 65 e4 00 f0 ff ff andl $0xfffff000,-0x1c(%ebp) 80106389: 29 df sub %ebx,%edi 8010638b: eb 18 jmp 801063a5 <mappages+0x45> 8010638d: 8d 76 00 lea 0x0(%esi),%esi if(*pte & PTE_P) 80106390: f6 00 01 testb $0x1,(%eax) 80106393: 75 3d jne 801063d2 <mappages+0x72> *pte = pa | perm | PTE_P; 80106395: 0b 75 0c or 0xc(%ebp),%esi if(a == last) 80106398: 3b 5d e4 cmp -0x1c(%ebp),%ebx *pte = pa | perm | PTE_P; 8010639b: 89 30 mov %esi,(%eax) if(a == last) 8010639d: 74 29 je 801063c8 <mappages+0x68> break; a += PGSIZE; 8010639f: 81 c3 00 10 00 00 add $0x1000,%ebx if((pte = walkpgdir(pgdir, a, 1)) == 0) 801063a5: 8b 45 e0 mov -0x20(%ebp),%eax 801063a8: b9 01 00 00 00 mov $0x1,%ecx 801063ad: 89 da mov %ebx,%edx 801063af: 8d 34 3b lea (%ebx,%edi,1),%esi 801063b2: e8 19 ff ff ff call 801062d0 <walkpgdir> 801063b7: 85 c0 test %eax,%eax 801063b9: 75 d5 jne 80106390 <mappages+0x30> pa += PGSIZE; } return 0; } 801063bb: 83 c4 1c add $0x1c,%esp return -1; 801063be: b8 ff ff ff ff mov $0xffffffff,%eax } 801063c3: 5b pop %ebx 801063c4: 5e pop %esi 801063c5: 5f pop %edi 801063c6: 5d pop %ebp 801063c7: c3 ret 801063c8: 83 c4 1c add $0x1c,%esp return 0; 801063cb: 31 c0 xor %eax,%eax } 801063cd: 5b pop %ebx 801063ce: 5e pop %esi 801063cf: 5f pop %edi 801063d0: 5d pop %ebp 801063d1: c3 ret panic("remap"); 801063d2: c7 04 24 a8 74 10 80 movl $0x801074a8,(%esp) 801063d9: e8 82 9f ff ff call 80100360 <panic> 801063de: 66 90 xchg %ax,%ax 801063e0 <deallocuvm.part.0>: // Deallocate user pages to bring the process size from oldsz to // newsz. oldsz and newsz need not be page-aligned, nor does newsz // need to be less than oldsz. oldsz can be larger than the actual // process size. Returns the new process size. int deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) 801063e0: 55 push %ebp 801063e1: 89 e5 mov %esp,%ebp 801063e3: 57 push %edi 801063e4: 89 c7 mov %eax,%edi 801063e6: 56 push %esi 801063e7: 89 d6 mov %edx,%esi 801063e9: 53 push %ebx uint a, pa; if(newsz >= oldsz) return oldsz; a = PGROUNDUP(newsz); 801063ea: 8d 99 ff 0f 00 00 lea 0xfff(%ecx),%ebx deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) 801063f0: 83 ec 1c sub $0x1c,%esp a = PGROUNDUP(newsz); 801063f3: 81 e3 00 f0 ff ff and $0xfffff000,%ebx for(; a < oldsz; a += PGSIZE){ 801063f9: 39 d3 cmp %edx,%ebx deallocuvm(pde_t *pgdir, uint oldsz, uint newsz) 801063fb: 89 4d e0 mov %ecx,-0x20(%ebp) for(; a < oldsz; a += PGSIZE){ 801063fe: 72 3b jb 8010643b <deallocuvm.part.0+0x5b> 80106400: eb 5e jmp 80106460 <deallocuvm.part.0+0x80> 80106402: 8d b6 00 00 00 00 lea 0x0(%esi),%esi pte = walkpgdir(pgdir, (char*)a, 0); if(!pte) a = PGADDR(PDX(a) + 1, 0, 0) - PGSIZE; else if((*pte & PTE_P) != 0){ 80106408: 8b 10 mov (%eax),%edx 8010640a: f6 c2 01 test $0x1,%dl 8010640d: 74 22 je 80106431 <deallocuvm.part.0+0x51> pa = PTE_ADDR(*pte); if(pa == 0) 8010640f: 81 e2 00 f0 ff ff and $0xfffff000,%edx 80106415: 74 54 je 8010646b <deallocuvm.part.0+0x8b> panic("kfree"); char *v = P2V(pa); 80106417: 81 c2 00 00 00 80 add $0x80000000,%edx kfree(v); 8010641d: 89 14 24 mov %edx,(%esp) 80106420: 89 45 e4 mov %eax,-0x1c(%ebp) 80106423: e8 c8 be ff ff call 801022f0 <kfree> *pte = 0; 80106428: 8b 45 e4 mov -0x1c(%ebp),%eax 8010642b: c7 00 00 00 00 00 movl $0x0,(%eax) for(; a < oldsz; a += PGSIZE){ 80106431: 81 c3 00 10 00 00 add $0x1000,%ebx 80106437: 39 f3 cmp %esi,%ebx 80106439: 73 25 jae 80106460 <deallocuvm.part.0+0x80> pte = walkpgdir(pgdir, (char*)a, 0); 8010643b: 31 c9 xor %ecx,%ecx 8010643d: 89 da mov %ebx,%edx 8010643f: 89 f8 mov %edi,%eax 80106441: e8 8a fe ff ff call 801062d0 <walkpgdir> if(!pte) 80106446: 85 c0 test %eax,%eax 80106448: 75 be jne 80106408 <deallocuvm.part.0+0x28> a = PGADDR(PDX(a) + 1, 0, 0) - PGSIZE; 8010644a: 81 e3 00 00 c0 ff and $0xffc00000,%ebx 80106450: 81 c3 00 f0 3f 00 add $0x3ff000,%ebx for(; a < oldsz; a += PGSIZE){ 80106456: 81 c3 00 10 00 00 add $0x1000,%ebx 8010645c: 39 f3 cmp %esi,%ebx 8010645e: 72 db jb 8010643b <deallocuvm.part.0+0x5b> } } return newsz; } 80106460: 8b 45 e0 mov -0x20(%ebp),%eax 80106463: 83 c4 1c add $0x1c,%esp 80106466: 5b pop %ebx 80106467: 5e pop %esi 80106468: 5f pop %edi 80106469: 5d pop %ebp 8010646a: c3 ret panic("kfree"); 8010646b: c7 04 24 46 6e 10 80 movl $0x80106e46,(%esp) 80106472: e8 e9 9e ff ff call 80100360 <panic> 80106477: 89 f6 mov %esi,%esi 80106479: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80106480 <seginit>: { 80106480: 55 push %ebp 80106481: 89 e5 mov %esp,%ebp 80106483: 83 ec 18 sub $0x18,%esp c = &cpus[cpuid()]; 80106486: e8 f5 d1 ff ff call 80103680 <cpuid> c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0); 8010648b: 31 c9 xor %ecx,%ecx 8010648d: ba ff ff ff ff mov $0xffffffff,%edx c = &cpus[cpuid()]; 80106492: 69 c0 b0 00 00 00 imul $0xb0,%eax,%eax 80106498: 05 80 27 11 80 add $0x80112780,%eax c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0); 8010649d: 66 89 50 78 mov %dx,0x78(%eax) c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); 801064a1: ba ff ff ff ff mov $0xffffffff,%edx lgdt(c->gdt, sizeof(c->gdt)); 801064a6: 83 c0 70 add $0x70,%eax c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0); 801064a9: 66 89 48 0a mov %cx,0xa(%eax) c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); 801064ad: 31 c9 xor %ecx,%ecx 801064af: 66 89 50 10 mov %dx,0x10(%eax) c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); 801064b3: ba ff ff ff ff mov $0xffffffff,%edx c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); 801064b8: 66 89 48 12 mov %cx,0x12(%eax) c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); 801064bc: 31 c9 xor %ecx,%ecx 801064be: 66 89 50 18 mov %dx,0x18(%eax) c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER); 801064c2: ba ff ff ff ff mov $0xffffffff,%edx c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); 801064c7: 66 89 48 1a mov %cx,0x1a(%eax) c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER); 801064cb: 31 c9 xor %ecx,%ecx c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0); 801064cd: c6 40 0d 9a movb $0x9a,0xd(%eax) 801064d1: c6 40 0e cf movb $0xcf,0xe(%eax) c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); 801064d5: c6 40 15 92 movb $0x92,0x15(%eax) 801064d9: c6 40 16 cf movb $0xcf,0x16(%eax) c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); 801064dd: c6 40 1d fa movb $0xfa,0x1d(%eax) 801064e1: c6 40 1e cf movb $0xcf,0x1e(%eax) c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER); 801064e5: c6 40 25 f2 movb $0xf2,0x25(%eax) 801064e9: c6 40 26 cf movb $0xcf,0x26(%eax) 801064ed: 66 89 50 20 mov %dx,0x20(%eax) pd[0] = size-1; 801064f1: ba 2f 00 00 00 mov $0x2f,%edx c->gdt[SEG_KCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, 0); 801064f6: c6 40 0c 00 movb $0x0,0xc(%eax) 801064fa: c6 40 0f 00 movb $0x0,0xf(%eax) c->gdt[SEG_KDATA] = SEG(STA_W, 0, 0xffffffff, 0); 801064fe: c6 40 14 00 movb $0x0,0x14(%eax) 80106502: c6 40 17 00 movb $0x0,0x17(%eax) c->gdt[SEG_UCODE] = SEG(STA_X|STA_R, 0, 0xffffffff, DPL_USER); 80106506: c6 40 1c 00 movb $0x0,0x1c(%eax) 8010650a: c6 40 1f 00 movb $0x0,0x1f(%eax) c->gdt[SEG_UDATA] = SEG(STA_W, 0, 0xffffffff, DPL_USER); 8010650e: 66 89 48 22 mov %cx,0x22(%eax) 80106512: c6 40 24 00 movb $0x0,0x24(%eax) 80106516: c6 40 27 00 movb $0x0,0x27(%eax) 8010651a: 66 89 55 f2 mov %dx,-0xe(%ebp) pd[1] = (uint)p; 8010651e: 66 89 45 f4 mov %ax,-0xc(%ebp) pd[2] = (uint)p >> 16; 80106522: c1 e8 10 shr $0x10,%eax 80106525: 66 89 45 f6 mov %ax,-0xa(%ebp) asm volatile("lgdt (%0)" : : "r" (pd)); 80106529: 8d 45 f2 lea -0xe(%ebp),%eax 8010652c: 0f 01 10 lgdtl (%eax) } 8010652f: c9 leave 80106530: c3 ret 80106531: eb 0d jmp 80106540 <switchkvm> 80106533: 90 nop 80106534: 90 nop 80106535: 90 nop 80106536: 90 nop 80106537: 90 nop 80106538: 90 nop 80106539: 90 nop 8010653a: 90 nop 8010653b: 90 nop 8010653c: 90 nop 8010653d: 90 nop 8010653e: 90 nop 8010653f: 90 nop 80106540 <switchkvm>: lcr3(V2P(kpgdir)); // switch to the kernel page table 80106540: a1 a4 54 11 80 mov 0x801154a4,%eax { 80106545: 55 push %ebp 80106546: 89 e5 mov %esp,%ebp lcr3(V2P(kpgdir)); // switch to the kernel page table 80106548: 05 00 00 00 80 add $0x80000000,%eax } static inline void lcr3(uint val) { asm volatile("movl %0,%%cr3" : : "r" (val)); 8010654d: 0f 22 d8 mov %eax,%cr3 } 80106550: 5d pop %ebp 80106551: c3 ret 80106552: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80106559: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80106560 <switchuvm>: { 80106560: 55 push %ebp 80106561: 89 e5 mov %esp,%ebp 80106563: 57 push %edi 80106564: 56 push %esi 80106565: 53 push %ebx 80106566: 83 ec 1c sub $0x1c,%esp 80106569: 8b 75 08 mov 0x8(%ebp),%esi if(p == 0) 8010656c: 85 f6 test %esi,%esi 8010656e: 0f 84 cd 00 00 00 je 80106641 <switchuvm+0xe1> if(p->kstack == 0) 80106574: 8b 46 08 mov 0x8(%esi),%eax 80106577: 85 c0 test %eax,%eax 80106579: 0f 84 da 00 00 00 je 80106659 <switchuvm+0xf9> if(p->pgdir == 0) 8010657f: 8b 7e 04 mov 0x4(%esi),%edi 80106582: 85 ff test %edi,%edi 80106584: 0f 84 c3 00 00 00 je 8010664d <switchuvm+0xed> pushcli(); 8010658a: e8 61 db ff ff call 801040f0 <pushcli> mycpu()->gdt[SEG_TSS] = SEG16(STS_T32A, &mycpu()->ts, 8010658f: e8 6c d0 ff ff call 80103600 <mycpu> 80106594: 89 c3 mov %eax,%ebx 80106596: e8 65 d0 ff ff call 80103600 <mycpu> 8010659b: 89 c7 mov %eax,%edi 8010659d: e8 5e d0 ff ff call 80103600 <mycpu> 801065a2: 83 c7 08 add $0x8,%edi 801065a5: 89 45 e4 mov %eax,-0x1c(%ebp) 801065a8: e8 53 d0 ff ff call 80103600 <mycpu> 801065ad: 8b 4d e4 mov -0x1c(%ebp),%ecx 801065b0: ba 67 00 00 00 mov $0x67,%edx 801065b5: 66 89 93 98 00 00 00 mov %dx,0x98(%ebx) 801065bc: 66 89 bb 9a 00 00 00 mov %di,0x9a(%ebx) 801065c3: c6 83 9d 00 00 00 99 movb $0x99,0x9d(%ebx) 801065ca: 83 c1 08 add $0x8,%ecx 801065cd: c1 e9 10 shr $0x10,%ecx 801065d0: 83 c0 08 add $0x8,%eax 801065d3: c1 e8 18 shr $0x18,%eax 801065d6: 88 8b 9c 00 00 00 mov %cl,0x9c(%ebx) 801065dc: c6 83 9e 00 00 00 40 movb $0x40,0x9e(%ebx) 801065e3: 88 83 9f 00 00 00 mov %al,0x9f(%ebx) mycpu()->ts.iomb = (ushort) 0xFFFF; 801065e9: bb ff ff ff ff mov $0xffffffff,%ebx mycpu()->gdt[SEG_TSS].s = 0; 801065ee: e8 0d d0 ff ff call 80103600 <mycpu> 801065f3: 80 a0 9d 00 00 00 ef andb $0xef,0x9d(%eax) mycpu()->ts.ss0 = SEG_KDATA << 3; 801065fa: e8 01 d0 ff ff call 80103600 <mycpu> 801065ff: b9 10 00 00 00 mov $0x10,%ecx 80106604: 66 89 48 10 mov %cx,0x10(%eax) mycpu()->ts.esp0 = (uint)p->kstack + KSTACKSIZE; 80106608: e8 f3 cf ff ff call 80103600 <mycpu> 8010660d: 8b 56 08 mov 0x8(%esi),%edx 80106610: 8d 8a 00 10 00 00 lea 0x1000(%edx),%ecx 80106616: 89 48 0c mov %ecx,0xc(%eax) mycpu()->ts.iomb = (ushort) 0xFFFF; 80106619: e8 e2 cf ff ff call 80103600 <mycpu> 8010661e: 66 89 58 6e mov %bx,0x6e(%eax) asm volatile("ltr %0" : : "r" (sel)); 80106622: b8 28 00 00 00 mov $0x28,%eax 80106627: 0f 00 d8 ltr %ax lcr3(V2P(p->pgdir)); // switch to process's address space 8010662a: 8b 46 04 mov 0x4(%esi),%eax 8010662d: 05 00 00 00 80 add $0x80000000,%eax asm volatile("movl %0,%%cr3" : : "r" (val)); 80106632: 0f 22 d8 mov %eax,%cr3 } 80106635: 83 c4 1c add $0x1c,%esp 80106638: 5b pop %ebx 80106639: 5e pop %esi 8010663a: 5f pop %edi 8010663b: 5d pop %ebp popcli(); 8010663c: e9 ef da ff ff jmp 80104130 <popcli> panic("switchuvm: no process"); 80106641: c7 04 24 ae 74 10 80 movl $0x801074ae,(%esp) 80106648: e8 13 9d ff ff call 80100360 <panic> panic("switchuvm: no pgdir"); 8010664d: c7 04 24 d9 74 10 80 movl $0x801074d9,(%esp) 80106654: e8 07 9d ff ff call 80100360 <panic> panic("switchuvm: no kstack"); 80106659: c7 04 24 c4 74 10 80 movl $0x801074c4,(%esp) 80106660: e8 fb 9c ff ff call 80100360 <panic> 80106665: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80106669: 8d bc 27 00 00 00 00 lea 0x0(%edi,%eiz,1),%edi 80106670 <inituvm>: { 80106670: 55 push %ebp 80106671: 89 e5 mov %esp,%ebp 80106673: 57 push %edi 80106674: 56 push %esi 80106675: 53 push %ebx 80106676: 83 ec 1c sub $0x1c,%esp 80106679: 8b 75 10 mov 0x10(%ebp),%esi 8010667c: 8b 45 08 mov 0x8(%ebp),%eax 8010667f: 8b 7d 0c mov 0xc(%ebp),%edi if(sz >= PGSIZE) 80106682: 81 fe ff 0f 00 00 cmp $0xfff,%esi { 80106688: 89 45 e4 mov %eax,-0x1c(%ebp) if(sz >= PGSIZE) 8010668b: 77 54 ja 801066e1 <inituvm+0x71> mem = kalloc(); 8010668d: e8 0e be ff ff call 801024a0 <kalloc> memset(mem, 0, PGSIZE); 80106692: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 80106699: 00 8010669a: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 801066a1: 00 mem = kalloc(); 801066a2: 89 c3 mov %eax,%ebx memset(mem, 0, PGSIZE); 801066a4: 89 04 24 mov %eax,(%esp) 801066a7: e8 f4 db ff ff call 801042a0 <memset> mappages(pgdir, 0, PGSIZE, V2P(mem), PTE_W|PTE_U); 801066ac: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax 801066b2: b9 00 10 00 00 mov $0x1000,%ecx 801066b7: 89 04 24 mov %eax,(%esp) 801066ba: 8b 45 e4 mov -0x1c(%ebp),%eax 801066bd: 31 d2 xor %edx,%edx 801066bf: c7 44 24 04 06 00 00 movl $0x6,0x4(%esp) 801066c6: 00 801066c7: e8 94 fc ff ff call 80106360 <mappages> memmove(mem, init, sz); 801066cc: 89 75 10 mov %esi,0x10(%ebp) 801066cf: 89 7d 0c mov %edi,0xc(%ebp) 801066d2: 89 5d 08 mov %ebx,0x8(%ebp) } 801066d5: 83 c4 1c add $0x1c,%esp 801066d8: 5b pop %ebx 801066d9: 5e pop %esi 801066da: 5f pop %edi 801066db: 5d pop %ebp memmove(mem, init, sz); 801066dc: e9 5f dc ff ff jmp 80104340 <memmove> panic("inituvm: more than a page"); 801066e1: c7 04 24 ed 74 10 80 movl $0x801074ed,(%esp) 801066e8: e8 73 9c ff ff call 80100360 <panic> 801066ed: 8d 76 00 lea 0x0(%esi),%esi 801066f0 <loaduvm>: { 801066f0: 55 push %ebp 801066f1: 89 e5 mov %esp,%ebp 801066f3: 57 push %edi 801066f4: 56 push %esi 801066f5: 53 push %ebx 801066f6: 83 ec 1c sub $0x1c,%esp if((uint) addr % PGSIZE != 0) 801066f9: f7 45 0c ff 0f 00 00 testl $0xfff,0xc(%ebp) 80106700: 0f 85 98 00 00 00 jne 8010679e <loaduvm+0xae> for(i = 0; i < sz; i += PGSIZE){ 80106706: 8b 75 18 mov 0x18(%ebp),%esi 80106709: 31 db xor %ebx,%ebx 8010670b: 85 f6 test %esi,%esi 8010670d: 75 1a jne 80106729 <loaduvm+0x39> 8010670f: eb 77 jmp 80106788 <loaduvm+0x98> 80106711: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80106718: 81 c3 00 10 00 00 add $0x1000,%ebx 8010671e: 81 ee 00 10 00 00 sub $0x1000,%esi 80106724: 39 5d 18 cmp %ebx,0x18(%ebp) 80106727: 76 5f jbe 80106788 <loaduvm+0x98> 80106729: 8b 55 0c mov 0xc(%ebp),%edx if((pte = walkpgdir(pgdir, addr+i, 0)) == 0) 8010672c: 31 c9 xor %ecx,%ecx 8010672e: 8b 45 08 mov 0x8(%ebp),%eax 80106731: 01 da add %ebx,%edx 80106733: e8 98 fb ff ff call 801062d0 <walkpgdir> 80106738: 85 c0 test %eax,%eax 8010673a: 74 56 je 80106792 <loaduvm+0xa2> pa = PTE_ADDR(*pte); 8010673c: 8b 00 mov (%eax),%eax n = PGSIZE; 8010673e: bf 00 10 00 00 mov $0x1000,%edi 80106743: 8b 4d 14 mov 0x14(%ebp),%ecx pa = PTE_ADDR(*pte); 80106746: 25 00 f0 ff ff and $0xfffff000,%eax n = PGSIZE; 8010674b: 81 fe 00 10 00 00 cmp $0x1000,%esi 80106751: 0f 42 fe cmovb %esi,%edi if(readi(ip, P2V(pa), offset+i, n) != n) 80106754: 05 00 00 00 80 add $0x80000000,%eax 80106759: 89 44 24 04 mov %eax,0x4(%esp) 8010675d: 8b 45 10 mov 0x10(%ebp),%eax 80106760: 01 d9 add %ebx,%ecx 80106762: 89 7c 24 0c mov %edi,0xc(%esp) 80106766: 89 4c 24 08 mov %ecx,0x8(%esp) 8010676a: 89 04 24 mov %eax,(%esp) 8010676d: e8 ee b1 ff ff call 80101960 <readi> 80106772: 39 f8 cmp %edi,%eax 80106774: 74 a2 je 80106718 <loaduvm+0x28> } 80106776: 83 c4 1c add $0x1c,%esp return -1; 80106779: b8 ff ff ff ff mov $0xffffffff,%eax } 8010677e: 5b pop %ebx 8010677f: 5e pop %esi 80106780: 5f pop %edi 80106781: 5d pop %ebp 80106782: c3 ret 80106783: 90 nop 80106784: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80106788: 83 c4 1c add $0x1c,%esp return 0; 8010678b: 31 c0 xor %eax,%eax } 8010678d: 5b pop %ebx 8010678e: 5e pop %esi 8010678f: 5f pop %edi 80106790: 5d pop %ebp 80106791: c3 ret panic("loaduvm: address should exist"); 80106792: c7 04 24 07 75 10 80 movl $0x80107507,(%esp) 80106799: e8 c2 9b ff ff call 80100360 <panic> panic("loaduvm: addr must be page aligned"); 8010679e: c7 04 24 a8 75 10 80 movl $0x801075a8,(%esp) 801067a5: e8 b6 9b ff ff call 80100360 <panic> 801067aa: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801067b0 <allocuvm>: { 801067b0: 55 push %ebp 801067b1: 89 e5 mov %esp,%ebp 801067b3: 57 push %edi 801067b4: 56 push %esi 801067b5: 53 push %ebx 801067b6: 83 ec 1c sub $0x1c,%esp 801067b9: 8b 7d 10 mov 0x10(%ebp),%edi if(newsz >= KERNBASE) 801067bc: 85 ff test %edi,%edi 801067be: 0f 88 7e 00 00 00 js 80106842 <allocuvm+0x92> if(newsz < oldsz) 801067c4: 3b 7d 0c cmp 0xc(%ebp),%edi return oldsz; 801067c7: 8b 45 0c mov 0xc(%ebp),%eax if(newsz < oldsz) 801067ca: 72 78 jb 80106844 <allocuvm+0x94> a = PGROUNDUP(oldsz); 801067cc: 8d 98 ff 0f 00 00 lea 0xfff(%eax),%ebx 801067d2: 81 e3 00 f0 ff ff and $0xfffff000,%ebx for(; a < newsz; a += PGSIZE){ 801067d8: 39 df cmp %ebx,%edi 801067da: 77 4a ja 80106826 <allocuvm+0x76> 801067dc: eb 72 jmp 80106850 <allocuvm+0xa0> 801067de: 66 90 xchg %ax,%ax memset(mem, 0, PGSIZE); 801067e0: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 801067e7: 00 801067e8: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 801067ef: 00 801067f0: 89 04 24 mov %eax,(%esp) 801067f3: e8 a8 da ff ff call 801042a0 <memset> if(mappages(pgdir, (char*)a, PGSIZE, V2P(mem), PTE_W|PTE_U) < 0){ 801067f8: 8d 86 00 00 00 80 lea -0x80000000(%esi),%eax 801067fe: b9 00 10 00 00 mov $0x1000,%ecx 80106803: 89 04 24 mov %eax,(%esp) 80106806: 8b 45 08 mov 0x8(%ebp),%eax 80106809: 89 da mov %ebx,%edx 8010680b: c7 44 24 04 06 00 00 movl $0x6,0x4(%esp) 80106812: 00 80106813: e8 48 fb ff ff call 80106360 <mappages> 80106818: 85 c0 test %eax,%eax 8010681a: 78 44 js 80106860 <allocuvm+0xb0> for(; a < newsz; a += PGSIZE){ 8010681c: 81 c3 00 10 00 00 add $0x1000,%ebx 80106822: 39 df cmp %ebx,%edi 80106824: 76 2a jbe 80106850 <allocuvm+0xa0> mem = kalloc(); 80106826: e8 75 bc ff ff call 801024a0 <kalloc> if(mem == 0){ 8010682b: 85 c0 test %eax,%eax mem = kalloc(); 8010682d: 89 c6 mov %eax,%esi if(mem == 0){ 8010682f: 75 af jne 801067e0 <allocuvm+0x30> cprintf("allocuvm out of memory\n"); 80106831: c7 04 24 25 75 10 80 movl $0x80107525,(%esp) 80106838: e8 13 9e ff ff call 80100650 <cprintf> if(newsz >= oldsz) 8010683d: 3b 7d 0c cmp 0xc(%ebp),%edi 80106840: 77 48 ja 8010688a <allocuvm+0xda> return 0; 80106842: 31 c0 xor %eax,%eax } 80106844: 83 c4 1c add $0x1c,%esp 80106847: 5b pop %ebx 80106848: 5e pop %esi 80106849: 5f pop %edi 8010684a: 5d pop %ebp 8010684b: c3 ret 8010684c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80106850: 83 c4 1c add $0x1c,%esp 80106853: 89 f8 mov %edi,%eax 80106855: 5b pop %ebx 80106856: 5e pop %esi 80106857: 5f pop %edi 80106858: 5d pop %ebp 80106859: c3 ret 8010685a: 8d b6 00 00 00 00 lea 0x0(%esi),%esi cprintf("allocuvm out of memory (2)\n"); 80106860: c7 04 24 3d 75 10 80 movl $0x8010753d,(%esp) 80106867: e8 e4 9d ff ff call 80100650 <cprintf> if(newsz >= oldsz) 8010686c: 3b 7d 0c cmp 0xc(%ebp),%edi 8010686f: 76 0d jbe 8010687e <allocuvm+0xce> 80106871: 8b 4d 0c mov 0xc(%ebp),%ecx 80106874: 89 fa mov %edi,%edx 80106876: 8b 45 08 mov 0x8(%ebp),%eax 80106879: e8 62 fb ff ff call 801063e0 <deallocuvm.part.0> kfree(mem); 8010687e: 89 34 24 mov %esi,(%esp) 80106881: e8 6a ba ff ff call 801022f0 <kfree> return 0; 80106886: 31 c0 xor %eax,%eax 80106888: eb ba jmp 80106844 <allocuvm+0x94> 8010688a: 8b 4d 0c mov 0xc(%ebp),%ecx 8010688d: 89 fa mov %edi,%edx 8010688f: 8b 45 08 mov 0x8(%ebp),%eax 80106892: e8 49 fb ff ff call 801063e0 <deallocuvm.part.0> return 0; 80106897: 31 c0 xor %eax,%eax 80106899: eb a9 jmp 80106844 <allocuvm+0x94> 8010689b: 90 nop 8010689c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801068a0 <deallocuvm>: { 801068a0: 55 push %ebp 801068a1: 89 e5 mov %esp,%ebp 801068a3: 8b 55 0c mov 0xc(%ebp),%edx 801068a6: 8b 4d 10 mov 0x10(%ebp),%ecx 801068a9: 8b 45 08 mov 0x8(%ebp),%eax if(newsz >= oldsz) 801068ac: 39 d1 cmp %edx,%ecx 801068ae: 73 08 jae 801068b8 <deallocuvm+0x18> } 801068b0: 5d pop %ebp 801068b1: e9 2a fb ff ff jmp 801063e0 <deallocuvm.part.0> 801068b6: 66 90 xchg %ax,%ax 801068b8: 89 d0 mov %edx,%eax 801068ba: 5d pop %ebp 801068bb: c3 ret 801068bc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 801068c0 <freevm>: // Free a page table and all the physical memory pages // in the user part. void freevm(pde_t *pgdir) { 801068c0: 55 push %ebp 801068c1: 89 e5 mov %esp,%ebp 801068c3: 56 push %esi 801068c4: 53 push %ebx 801068c5: 83 ec 10 sub $0x10,%esp 801068c8: 8b 75 08 mov 0x8(%ebp),%esi uint i; if(pgdir == 0) 801068cb: 85 f6 test %esi,%esi 801068cd: 74 59 je 80106928 <freevm+0x68> 801068cf: 31 c9 xor %ecx,%ecx 801068d1: ba 00 00 00 80 mov $0x80000000,%edx 801068d6: 89 f0 mov %esi,%eax panic("freevm: no pgdir"); deallocuvm(pgdir, KERNBASE, 0); for(i = 0; i < NPDENTRIES; i++){ 801068d8: 31 db xor %ebx,%ebx 801068da: e8 01 fb ff ff call 801063e0 <deallocuvm.part.0> 801068df: eb 12 jmp 801068f3 <freevm+0x33> 801068e1: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 801068e8: 83 c3 01 add $0x1,%ebx 801068eb: 81 fb 00 04 00 00 cmp $0x400,%ebx 801068f1: 74 27 je 8010691a <freevm+0x5a> if(pgdir[i] & PTE_P){ 801068f3: 8b 14 9e mov (%esi,%ebx,4),%edx 801068f6: f6 c2 01 test $0x1,%dl 801068f9: 74 ed je 801068e8 <freevm+0x28> char * v = P2V(PTE_ADDR(pgdir[i])); 801068fb: 81 e2 00 f0 ff ff and $0xfffff000,%edx for(i = 0; i < NPDENTRIES; i++){ 80106901: 83 c3 01 add $0x1,%ebx char * v = P2V(PTE_ADDR(pgdir[i])); 80106904: 81 c2 00 00 00 80 add $0x80000000,%edx kfree(v); 8010690a: 89 14 24 mov %edx,(%esp) 8010690d: e8 de b9 ff ff call 801022f0 <kfree> for(i = 0; i < NPDENTRIES; i++){ 80106912: 81 fb 00 04 00 00 cmp $0x400,%ebx 80106918: 75 d9 jne 801068f3 <freevm+0x33> } } kfree((char*)pgdir); 8010691a: 89 75 08 mov %esi,0x8(%ebp) } 8010691d: 83 c4 10 add $0x10,%esp 80106920: 5b pop %ebx 80106921: 5e pop %esi 80106922: 5d pop %ebp kfree((char*)pgdir); 80106923: e9 c8 b9 ff ff jmp 801022f0 <kfree> panic("freevm: no pgdir"); 80106928: c7 04 24 59 75 10 80 movl $0x80107559,(%esp) 8010692f: e8 2c 9a ff ff call 80100360 <panic> 80106934: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 8010693a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80106940 <setupkvm>: { 80106940: 55 push %ebp 80106941: 89 e5 mov %esp,%ebp 80106943: 56 push %esi 80106944: 53 push %ebx 80106945: 83 ec 10 sub $0x10,%esp if((pgdir = (pde_t*)kalloc()) == 0) 80106948: e8 53 bb ff ff call 801024a0 <kalloc> 8010694d: 85 c0 test %eax,%eax 8010694f: 89 c6 mov %eax,%esi 80106951: 74 6d je 801069c0 <setupkvm+0x80> memset(pgdir, 0, PGSIZE); 80106953: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 8010695a: 00 for(k = kmap; k < &kmap[NELEM(kmap)]; k++) 8010695b: bb 20 a4 10 80 mov $0x8010a420,%ebx memset(pgdir, 0, PGSIZE); 80106960: c7 44 24 04 00 00 00 movl $0x0,0x4(%esp) 80106967: 00 80106968: 89 04 24 mov %eax,(%esp) 8010696b: e8 30 d9 ff ff call 801042a0 <memset> if(mappages(pgdir, k->virt, k->phys_end - k->phys_start, 80106970: 8b 53 0c mov 0xc(%ebx),%edx 80106973: 8b 43 04 mov 0x4(%ebx),%eax 80106976: 8b 4b 08 mov 0x8(%ebx),%ecx 80106979: 89 54 24 04 mov %edx,0x4(%esp) 8010697d: 8b 13 mov (%ebx),%edx 8010697f: 89 04 24 mov %eax,(%esp) 80106982: 29 c1 sub %eax,%ecx 80106984: 89 f0 mov %esi,%eax 80106986: e8 d5 f9 ff ff call 80106360 <mappages> 8010698b: 85 c0 test %eax,%eax 8010698d: 78 19 js 801069a8 <setupkvm+0x68> for(k = kmap; k < &kmap[NELEM(kmap)]; k++) 8010698f: 83 c3 10 add $0x10,%ebx 80106992: 81 fb 60 a4 10 80 cmp $0x8010a460,%ebx 80106998: 72 d6 jb 80106970 <setupkvm+0x30> 8010699a: 89 f0 mov %esi,%eax } 8010699c: 83 c4 10 add $0x10,%esp 8010699f: 5b pop %ebx 801069a0: 5e pop %esi 801069a1: 5d pop %ebp 801069a2: c3 ret 801069a3: 90 nop 801069a4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi freevm(pgdir); 801069a8: 89 34 24 mov %esi,(%esp) 801069ab: e8 10 ff ff ff call 801068c0 <freevm> } 801069b0: 83 c4 10 add $0x10,%esp return 0; 801069b3: 31 c0 xor %eax,%eax } 801069b5: 5b pop %ebx 801069b6: 5e pop %esi 801069b7: 5d pop %ebp 801069b8: c3 ret 801069b9: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi return 0; 801069c0: 31 c0 xor %eax,%eax 801069c2: eb d8 jmp 8010699c <setupkvm+0x5c> 801069c4: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801069ca: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 801069d0 <kvmalloc>: { 801069d0: 55 push %ebp 801069d1: 89 e5 mov %esp,%ebp 801069d3: 83 ec 08 sub $0x8,%esp kpgdir = setupkvm(); 801069d6: e8 65 ff ff ff call 80106940 <setupkvm> 801069db: a3 a4 54 11 80 mov %eax,0x801154a4 lcr3(V2P(kpgdir)); // switch to the kernel page table 801069e0: 05 00 00 00 80 add $0x80000000,%eax 801069e5: 0f 22 d8 mov %eax,%cr3 } 801069e8: c9 leave 801069e9: c3 ret 801069ea: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 801069f0 <clearpteu>: // Clear PTE_U on a page. Used to create an inaccessible // page beneath the user stack. void clearpteu(pde_t *pgdir, char *uva) { 801069f0: 55 push %ebp pte_t *pte; pte = walkpgdir(pgdir, uva, 0); 801069f1: 31 c9 xor %ecx,%ecx { 801069f3: 89 e5 mov %esp,%ebp 801069f5: 83 ec 18 sub $0x18,%esp pte = walkpgdir(pgdir, uva, 0); 801069f8: 8b 55 0c mov 0xc(%ebp),%edx 801069fb: 8b 45 08 mov 0x8(%ebp),%eax 801069fe: e8 cd f8 ff ff call 801062d0 <walkpgdir> if(pte == 0) 80106a03: 85 c0 test %eax,%eax 80106a05: 74 05 je 80106a0c <clearpteu+0x1c> panic("clearpteu"); *pte &= ~PTE_U; 80106a07: 83 20 fb andl $0xfffffffb,(%eax) } 80106a0a: c9 leave 80106a0b: c3 ret panic("clearpteu"); 80106a0c: c7 04 24 6a 75 10 80 movl $0x8010756a,(%esp) 80106a13: e8 48 99 ff ff call 80100360 <panic> 80106a18: 90 nop 80106a19: 8d b4 26 00 00 00 00 lea 0x0(%esi,%eiz,1),%esi 80106a20 <copyuvm>: // Given a parent process's page table, create a copy // of it for a child. pde_t* copyuvm(pde_t *pgdir, uint sz) { 80106a20: 55 push %ebp 80106a21: 89 e5 mov %esp,%ebp 80106a23: 57 push %edi 80106a24: 56 push %esi 80106a25: 53 push %ebx 80106a26: 83 ec 2c sub $0x2c,%esp pde_t *d; pte_t *pte; uint pa, i, flags; char *mem; if((d = setupkvm()) == 0) 80106a29: e8 12 ff ff ff call 80106940 <setupkvm> 80106a2e: 85 c0 test %eax,%eax 80106a30: 89 45 e0 mov %eax,-0x20(%ebp) 80106a33: 0f 84 b9 00 00 00 je 80106af2 <copyuvm+0xd2> return 0; for(i = 0; i < sz; i += PGSIZE){ 80106a39: 8b 45 0c mov 0xc(%ebp),%eax 80106a3c: 85 c0 test %eax,%eax 80106a3e: 0f 84 94 00 00 00 je 80106ad8 <copyuvm+0xb8> 80106a44: 31 ff xor %edi,%edi 80106a46: eb 48 jmp 80106a90 <copyuvm+0x70> panic("copyuvm: page not present"); pa = PTE_ADDR(*pte); flags = PTE_FLAGS(*pte); if((mem = kalloc()) == 0) goto bad; memmove(mem, (char*)P2V(pa), PGSIZE); 80106a48: 81 c6 00 00 00 80 add $0x80000000,%esi 80106a4e: c7 44 24 08 00 10 00 movl $0x1000,0x8(%esp) 80106a55: 00 80106a56: 89 74 24 04 mov %esi,0x4(%esp) 80106a5a: 89 04 24 mov %eax,(%esp) 80106a5d: e8 de d8 ff ff call 80104340 <memmove> if(mappages(d, (void*)i, PGSIZE, V2P(mem), flags) < 0) { 80106a62: 8b 45 e4 mov -0x1c(%ebp),%eax 80106a65: b9 00 10 00 00 mov $0x1000,%ecx 80106a6a: 89 fa mov %edi,%edx 80106a6c: 89 44 24 04 mov %eax,0x4(%esp) 80106a70: 8d 83 00 00 00 80 lea -0x80000000(%ebx),%eax 80106a76: 89 04 24 mov %eax,(%esp) 80106a79: 8b 45 e0 mov -0x20(%ebp),%eax 80106a7c: e8 df f8 ff ff call 80106360 <mappages> 80106a81: 85 c0 test %eax,%eax 80106a83: 78 63 js 80106ae8 <copyuvm+0xc8> for(i = 0; i < sz; i += PGSIZE){ 80106a85: 81 c7 00 10 00 00 add $0x1000,%edi 80106a8b: 39 7d 0c cmp %edi,0xc(%ebp) 80106a8e: 76 48 jbe 80106ad8 <copyuvm+0xb8> if((pte = walkpgdir(pgdir, (void *) i, 0)) == 0) 80106a90: 8b 45 08 mov 0x8(%ebp),%eax 80106a93: 31 c9 xor %ecx,%ecx 80106a95: 89 fa mov %edi,%edx 80106a97: e8 34 f8 ff ff call 801062d0 <walkpgdir> 80106a9c: 85 c0 test %eax,%eax 80106a9e: 74 62 je 80106b02 <copyuvm+0xe2> if(!(*pte & PTE_P)) 80106aa0: 8b 00 mov (%eax),%eax 80106aa2: a8 01 test $0x1,%al 80106aa4: 74 50 je 80106af6 <copyuvm+0xd6> pa = PTE_ADDR(*pte); 80106aa6: 89 c6 mov %eax,%esi flags = PTE_FLAGS(*pte); 80106aa8: 25 ff 0f 00 00 and $0xfff,%eax 80106aad: 89 45 e4 mov %eax,-0x1c(%ebp) pa = PTE_ADDR(*pte); 80106ab0: 81 e6 00 f0 ff ff and $0xfffff000,%esi if((mem = kalloc()) == 0) 80106ab6: e8 e5 b9 ff ff call 801024a0 <kalloc> 80106abb: 85 c0 test %eax,%eax 80106abd: 89 c3 mov %eax,%ebx 80106abf: 75 87 jne 80106a48 <copyuvm+0x28> } } return d; bad: freevm(d); 80106ac1: 8b 45 e0 mov -0x20(%ebp),%eax 80106ac4: 89 04 24 mov %eax,(%esp) 80106ac7: e8 f4 fd ff ff call 801068c0 <freevm> return 0; 80106acc: 31 c0 xor %eax,%eax } 80106ace: 83 c4 2c add $0x2c,%esp 80106ad1: 5b pop %ebx 80106ad2: 5e pop %esi 80106ad3: 5f pop %edi 80106ad4: 5d pop %ebp 80106ad5: c3 ret 80106ad6: 66 90 xchg %ax,%ax 80106ad8: 8b 45 e0 mov -0x20(%ebp),%eax 80106adb: 83 c4 2c add $0x2c,%esp 80106ade: 5b pop %ebx 80106adf: 5e pop %esi 80106ae0: 5f pop %edi 80106ae1: 5d pop %ebp 80106ae2: c3 ret 80106ae3: 90 nop 80106ae4: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi kfree(mem); 80106ae8: 89 1c 24 mov %ebx,(%esp) 80106aeb: e8 00 b8 ff ff call 801022f0 <kfree> goto bad; 80106af0: eb cf jmp 80106ac1 <copyuvm+0xa1> return 0; 80106af2: 31 c0 xor %eax,%eax 80106af4: eb d8 jmp 80106ace <copyuvm+0xae> panic("copyuvm: page not present"); 80106af6: c7 04 24 8e 75 10 80 movl $0x8010758e,(%esp) 80106afd: e8 5e 98 ff ff call 80100360 <panic> panic("copyuvm: pte should exist"); 80106b02: c7 04 24 74 75 10 80 movl $0x80107574,(%esp) 80106b09: e8 52 98 ff ff call 80100360 <panic> 80106b0e: 66 90 xchg %ax,%ax 80106b10 <uva2ka>: //PAGEBREAK! // Map user virtual address to kernel address. char* uva2ka(pde_t *pgdir, char *uva) { 80106b10: 55 push %ebp pte_t *pte; pte = walkpgdir(pgdir, uva, 0); 80106b11: 31 c9 xor %ecx,%ecx { 80106b13: 89 e5 mov %esp,%ebp 80106b15: 83 ec 08 sub $0x8,%esp pte = walkpgdir(pgdir, uva, 0); 80106b18: 8b 55 0c mov 0xc(%ebp),%edx 80106b1b: 8b 45 08 mov 0x8(%ebp),%eax 80106b1e: e8 ad f7 ff ff call 801062d0 <walkpgdir> if((*pte & PTE_P) == 0) 80106b23: 8b 00 mov (%eax),%eax 80106b25: 89 c2 mov %eax,%edx 80106b27: 83 e2 05 and $0x5,%edx return 0; if((*pte & PTE_U) == 0) 80106b2a: 83 fa 05 cmp $0x5,%edx 80106b2d: 75 11 jne 80106b40 <uva2ka+0x30> return 0; return (char*)P2V(PTE_ADDR(*pte)); 80106b2f: 25 00 f0 ff ff and $0xfffff000,%eax 80106b34: 05 00 00 00 80 add $0x80000000,%eax } 80106b39: c9 leave 80106b3a: c3 ret 80106b3b: 90 nop 80106b3c: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi return 0; 80106b40: 31 c0 xor %eax,%eax } 80106b42: c9 leave 80106b43: c3 ret 80106b44: 8d b6 00 00 00 00 lea 0x0(%esi),%esi 80106b4a: 8d bf 00 00 00 00 lea 0x0(%edi),%edi 80106b50 <copyout>: // Copy len bytes from p to user address va in page table pgdir. // Most useful when pgdir is not the current page table. // uva2ka ensures this only works for PTE_U pages. int copyout(pde_t *pgdir, uint va, void *p, uint len) { 80106b50: 55 push %ebp 80106b51: 89 e5 mov %esp,%ebp 80106b53: 57 push %edi 80106b54: 56 push %esi 80106b55: 53 push %ebx 80106b56: 83 ec 1c sub $0x1c,%esp 80106b59: 8b 5d 14 mov 0x14(%ebp),%ebx 80106b5c: 8b 4d 0c mov 0xc(%ebp),%ecx 80106b5f: 8b 7d 10 mov 0x10(%ebp),%edi char *buf, *pa0; uint n, va0; buf = (char*)p; while(len > 0){ 80106b62: 85 db test %ebx,%ebx 80106b64: 75 3a jne 80106ba0 <copyout+0x50> 80106b66: eb 68 jmp 80106bd0 <copyout+0x80> va0 = (uint)PGROUNDDOWN(va); pa0 = uva2ka(pgdir, (char*)va0); if(pa0 == 0) return -1; n = PGSIZE - (va - va0); 80106b68: 8b 4d e4 mov -0x1c(%ebp),%ecx 80106b6b: 89 f2 mov %esi,%edx if(n > len) n = len; memmove(pa0 + (va - va0), buf, n); 80106b6d: 89 7c 24 04 mov %edi,0x4(%esp) n = PGSIZE - (va - va0); 80106b71: 29 ca sub %ecx,%edx 80106b73: 81 c2 00 10 00 00 add $0x1000,%edx 80106b79: 39 da cmp %ebx,%edx 80106b7b: 0f 47 d3 cmova %ebx,%edx memmove(pa0 + (va - va0), buf, n); 80106b7e: 29 f1 sub %esi,%ecx 80106b80: 01 c8 add %ecx,%eax 80106b82: 89 54 24 08 mov %edx,0x8(%esp) 80106b86: 89 04 24 mov %eax,(%esp) 80106b89: 89 55 e4 mov %edx,-0x1c(%ebp) 80106b8c: e8 af d7 ff ff call 80104340 <memmove> len -= n; buf += n; 80106b91: 8b 55 e4 mov -0x1c(%ebp),%edx va = va0 + PGSIZE; 80106b94: 8d 8e 00 10 00 00 lea 0x1000(%esi),%ecx buf += n; 80106b9a: 01 d7 add %edx,%edi while(len > 0){ 80106b9c: 29 d3 sub %edx,%ebx 80106b9e: 74 30 je 80106bd0 <copyout+0x80> pa0 = uva2ka(pgdir, (char*)va0); 80106ba0: 8b 45 08 mov 0x8(%ebp),%eax va0 = (uint)PGROUNDDOWN(va); 80106ba3: 89 ce mov %ecx,%esi 80106ba5: 81 e6 00 f0 ff ff and $0xfffff000,%esi pa0 = uva2ka(pgdir, (char*)va0); 80106bab: 89 74 24 04 mov %esi,0x4(%esp) va0 = (uint)PGROUNDDOWN(va); 80106baf: 89 4d e4 mov %ecx,-0x1c(%ebp) pa0 = uva2ka(pgdir, (char*)va0); 80106bb2: 89 04 24 mov %eax,(%esp) 80106bb5: e8 56 ff ff ff call 80106b10 <uva2ka> if(pa0 == 0) 80106bba: 85 c0 test %eax,%eax 80106bbc: 75 aa jne 80106b68 <copyout+0x18> } return 0; } 80106bbe: 83 c4 1c add $0x1c,%esp return -1; 80106bc1: b8 ff ff ff ff mov $0xffffffff,%eax } 80106bc6: 5b pop %ebx 80106bc7: 5e pop %esi 80106bc8: 5f pop %edi 80106bc9: 5d pop %ebp 80106bca: c3 ret 80106bcb: 90 nop 80106bcc: 8d 74 26 00 lea 0x0(%esi,%eiz,1),%esi 80106bd0: 83 c4 1c add $0x1c,%esp return 0; 80106bd3: 31 c0 xor %eax,%eax } 80106bd5: 5b pop %ebx 80106bd6: 5e pop %esi 80106bd7: 5f pop %edi 80106bd8: 5d pop %ebp 80106bd9: c3 ret
; Program 8.5 ; SSE Scalar Operations - NASM (64-bit) ; Copyright (c) 2019 Hall & Slonka section .data align 16 valueA: dd 1.2 pi: dq 3.14159265358979 section .bss result: resd 1 ; space for storing result section .text global _main _main: ; scalar examples movss xmm0, [rel valueA] ; move valueA to XMM0 addss xmm0, [rel valueA] ; add valueA to XMM0 movss [rel result], xmm0 ; store result mov eax, DWORD [rel result] ; move result to EAX movsd xmm0, [rel pi] ; move pi to XMM0 mov rax, 60 xor rdi, rdi syscall
#ifndef CPU_HPP #define CPU_HPP #pragma once #include <cstdint> #include <ostream> #include <vector> #include <array> #include <string> #include <bitset> #define ASSERT(EXPR, MSG) if (!(EXPR)) throw std::runtime_error(MSG); #define NON_CMA_ABLE(T) \ public: \ T(const T &) = delete; \ T(T &&) noexcept = delete; \ \ public: \ T operator=(const T &) = delete; namespace Turing { class Ram final { NON_CMA_ABLE(Ram) public: Ram() = default; public: uint8_t Read(uint8_t addr) { if (addr >= 0x0 && addr <= 0xFF) return mRegisters[addr]; return 0; } void Write(uint8_t addr, uint8_t data) { if (addr >= 0x0 && addr <= 0xFF) mRegisters[addr] = data; } void Dump(uint8_t from, uint8_t to) { for (uint8_t addr = from; addr < to; addr++) std::cout << std::bitset<8>(mRegisters[addr]) << ' ' << static_cast<int>(addr) << '\n'; std::cout << '\n'; } private: std::array<uint8_t, 0xFF> mRegisters{}; }; enum OpCode : uint8_t { NOP = 0x0, LDX = 0x1, LDY = 0x2, STX = 0x3, STY = 0x4, ADD = 0x5, SUB = 0x6, JMP = 0x7, }; class Cpu final { NON_CMA_ABLE(Cpu) public: explicit Cpu(Ram &ram) : mRam(ram) {} public: void Run(const std::vector<uint8_t> &program) { ASSERT(0x10 >= program.size(), "Program max size 0x10") auto size = static_cast<uint8_t>(program.size()); for (uint8_t addr = 0x0; addr < size; addr++) mRam.Write(addr, program[addr]); mRam.Dump(0x0, size); Dump(); } void Clock() { mOpCode = mRam.Read(mProgramCounter); mProgramCounter++; if (mInstructions[mOpCode].Operation) (this->*mInstructions[mOpCode].Operation)(); } void Fetch() { mFetched = mRam.Read(mStackPointer); } void Dump() { std::cout << "Register X: " << static_cast<int>(mRegisterX) << '\n' << "Register Y: " << static_cast<int>(mRegisterY) << '\n' << "Overflow: " << static_cast<int>(mOverflow) << '\n' << "Underflow: " << static_cast<int>(mUnderflow) << '\n' << "Fetched: " << static_cast<int>(mFetched) << '\n' << "Stack Pointer: " << static_cast<int>(mStackPointer) << '\n' << "Program Counter: " << static_cast<int>(mProgramCounter) << '\n' << "Op Code: " << static_cast<int>(mOpCode) << '\n' << "Tmp: " << static_cast<int>(mTmp) << '\n' << '\n'; } private: void LDX() { Fetch(); mRegisterX = mFetched; } void LDY() { Fetch(); mRegisterY = mFetched; } void STX() { mRam.Write(mStackPointer, mRegisterX); } void STY() { mRam.Write(mStackPointer, mRegisterY); } void ADD() { mTmp = mRegisterX + mRegisterY; if (mTmp > 0xFF) mOverflow = true; } void SUB() { mTmp = mRegisterX - mRegisterY; if (mTmp < 0x0) mUnderflow = true; } void JMP() { mProgramCounter = mStackPointer; } private: struct Instruction { std::string Name; void (Cpu::*Operation)() = nullptr; }; private: Ram &mRam; uint8_t mRegisterX{}; uint8_t mRegisterY{}; bool mOverflow{}; bool mUnderflow{}; uint8_t mFetched{}; uint8_t mStackPointer{}; uint8_t mProgramCounter{}; uint8_t mOpCode{}; uint8_t mTmp{}; std::vector<Instruction> mInstructions{ {"NOP", nullptr}, {"LDX", &Cpu::LDX}, {"LDY", &Cpu::LDY}, {"STX", &Cpu::STX}, {"STY", &Cpu::STY}, {"ADD", &Cpu::ADD}, {"SUB", &Cpu::SUB}, {"JMP", &Cpu::JMP}, }; }; } #endif
/** * Copyright Soramitsu Co., Ltd. All Rights Reserved. * SPDX-License-Identifier: Apache-2.0 */ #ifndef LIBP2P_DIALER_MOCK_HPP #define LIBP2P_DIALER_MOCK_HPP #include <gmock/gmock.h> #include "libp2p/network/dialer.hpp" namespace libp2p::network { struct DialerMock : public Dialer { ~DialerMock() override = default; MOCK_METHOD2(dial, void(const peer::PeerInfo &, DialResultFunc)); MOCK_METHOD3(newStream, void(const peer::PeerInfo &, const peer::Protocol &, StreamResultFunc)); }; } // namespace libp2p::network #endif // LIBP2P_DIALER_MOCK_HPP
// Test using some simple supported string escapes \r \f \n \' \" // Commodore 64 PRG executable file .file [name="string-escapes-0.prg", type="prg", segments="Program"] .segmentdef Program [segments="Basic, Code, Data"] .segmentdef Basic [start=$0801] .segmentdef Code [start=$80d] .segmentdef Data [startAfter="Code"] .segment Basic :BasicUpstart(main) .label SCREEN = $400 .segment Code main: { ldx #0 __b1: // while(MESSAGE[i]) lda MESSAGE,x cmp #0 bne __b2 // } rts __b2: // SCREEN[i] = MESSAGE[i++] lda MESSAGE,x sta SCREEN,x // SCREEN[i] = MESSAGE[i++]; inx jmp __b1 } .segment Data MESSAGE: .text @"\r\f\n\"'\\" .byte 0
; ; ANSI Video handling for the VZ200 ; ; Handles colors referring to current PAPER/INK/etc. settings ; ; Scrollup ; ; ; $Id: f_ansi_scrollup.asm,v 1.3 2016-06-12 16:06:43 dom Exp $ ; SECTION code_clib PUBLIC ansi_SCROLLUP .ansi_SCROLLUP LD HL,0101h CALL 11CDh ; L2A - convert location to screen address push hl ex de,hl ld h,d ld l,$20 ld bc,480 ldir ld b,32 dec hl .cfill ld (hl),32 ;' ' dec hl djnz cfill pop de ld a,$E0 and d ld d,a ld h,d ld l,$20 ld bc,480 ldir ld b,32 dec hl .afill ld (hl),0 dec hl djnz afill ret
; lzo1y_f1.asm -- lzo1y_decompress_asm_fast ; ; This file is part of the LZO real-time data compression library. ; ; Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer ; Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer ; All Rights Reserved. ; ; The LZO library is free software; you can redistribute it and/or ; modify it under the terms of the GNU General Public License as ; published by the Free Software Foundation; either version 2 of ; the License, or (at your option) any later version. ; ; The LZO 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 General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with the LZO library; see the file COPYING. ; If not, write to the Free Software Foundation, Inc., ; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ; ; Markus F.X.J. Oberhumer ; <markus@oberhumer.com> ; http://www.oberhumer.com/opensource/lzo/ ; ; /***** DO NOT EDIT - GENERATED AUTOMATICALLY *****/ include asminit.def public _lzo1y_decompress_asm_fast _lzo1y_decompress_asm_fast: db 85,87,86,83,81,82,131,236,12,252,139,116,36,40,139,124 db 36,48,189,3,0,0,0,49,192,49,219,172,60,17,118,27 db 44,14,235,34,5,255,0,0,0,138,30,70,8,219,116,244 db 141,68,24,21,235,16,137,246,138,6,70,60,16,115,65,8 db 192,116,230,131,192,6,137,193,49,232,193,233,2,33,232,139 db 22,131,198,4,137,23,131,199,4,73,117,243,41,198,41,199 db 138,6,70,60,16,115,25,193,232,2,138,30,141,151,255,251 db 255,255,141,4,152,70,41,194,139,10,137,15,1,239,235,110 db 60,64,114,52,137,193,193,232,2,141,87,255,33,232,138,30 db 193,233,4,141,4,152,70,41,194,131,193,2,57,232,115,54 db 235,110,5,255,0,0,0,138,30,70,8,219,116,244,141,76 db 24,36,49,192,235,14,137,246,60,32,114,116,131,224,31,116 db 230,141,72,5,102,139,6,141,87,255,193,232,2,131,198,2 db 41,194,57,232,114,58,141,68,15,253,193,233,2,139,26,131 db 194,4,137,31,131,199,4,73,117,243,137,199,49,219,138,70 db 254,33,232,15,132,63,255,255,255,139,22,1,198,137,23,1 db 199,138,6,70,233,119,255,255,255,141,180,38,0,0,0,0 db 135,214,41,233,243,164,137,214,235,212,129,193,255,0,0,0 db 138,30,70,8,219,116,243,141,76,11,12,235,23,141,118,0 db 60,16,114,44,137,193,131,224,8,193,224,13,131,225,7,116 db 223,131,193,5,102,139,6,131,198,2,141,151,0,192,255,255 db 193,232,2,116,43,41,194,233,122,255,255,255,141,116,38,0 db 193,232,2,138,30,141,87,255,141,4,152,70,41,194,138,2 db 136,7,138,90,1,136,95,1,131,199,2,233,110,255,255,255 db 131,249,6,15,149,192,139,84,36,40,3,84,36,44,57,214 db 119,38,114,29,43,124,36,48,139,84,36,52,137,58,247,216 db 131,196,12,90,89,91,94,95,93,195,184,1,0,0,0,235 db 227,184,8,0,0,0,235,220,184,4,0,0,0,235,213,144 end
; A077898: Expansion of (1 - x)^(-1)/(1 + x - 2*x^2). ; 1,0,3,-2,9,-12,31,-54,117,-224,459,-906,1825,-3636,7287,-14558,29133,-58248,116515,-233010,466041,-932060,1864143,-3728262,7456549,-14913072,29826171,-59652314,119304657,-238609284,477218599,-954437166,1908874365,-3817748696,7635497427,-15270994818,30541989673,-61083979308,122167958655,-244335917270,488671834581,-977343669120,1954687338283,-3909374676522,7818749353089,-15637498706132,31274997412311,-62549994824574,125099989649197,-250199979298344,500399958596739,-1000799917193426,2001599834386905,-4003199668773756,8006399337547567,-16012798675095078,32025597350190213,-64051194700380368,128102389400760795,-256204778801521530,512409557603043121,-1024819115206086180,2049638230412172423,-4099276460824344782,8198552921648689629,-16397105843297379192,32794211686594758451,-65588423373189516834,131176846746379033737,-262353693492758067404,524707386985516134879,-1049414773971032269686,2098829547942064539445,-4197659095884129078816,8395318191768258157707,-16790636383536516315338,33581272767073032630753,-67162545534146065261428,134325091068292130522935,-268650182136584261045790,537300364273168522091661,-1074600728546337044183240,2149201457092674088366563,-4298402914185348176733042,8596805828370696353466169,-17193611656741392706932252,34387223313482785413864591,-68774446626965570827729094,137548893253931141655458277,-275097786507862283310916464,550195573015724566621833019,-1100391146031449133243665946,2200782292062898266487331985,-4401564584125796532974663876,8803129168251593065949327847,-17606258336503186131898655598,35212516673006372263797311293,-70425033346012744527594622488,140850066692025489055189245075,-281700133384050978110378490050 add $0,2 mov $2,-2 mov $3,2 lpb $0 sub $0,1 mov $1,$2 add $3,$2 mul $3,$2 add $4,$3 lpe sub $2,$4 mul $1,$2 sub $1,4 div $1,8 mov $0,$1
MoonMonsB1: db $0A db 8,ZUBAT db 7,ZUBAT db 7,GEODUDE db 8,GEODUDE db 9,ZUBAT db 10,PARAS db 10,ZUBAT db 11,ZUBAT db 9,CLEFAIRY db 9,GEODUDE db $00
/* Copyright (c) 2003-2016, John Hurst 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. 3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. */ /*! \file asdcp-unwrap.cpp \version $Id: asdcp-unwrap.cpp,v 1.9 2016/11/22 17:58:19 jhurst Exp $ \brief AS-DCP file manipulation utility This program extracts picture, sound and text essence from AS-DCP files. For more information about asdcplib, please refer to the header file AS_DCP.h */ #include <KM_fileio.h> #include <WavFileWriter.h> using namespace ASDCP; const ui32_t FRAME_BUFFER_SIZE = 4 * Kumu::Megabyte; //------------------------------------------------------------------------------------------ // // command line option parser class static const char* PROGRAM_NAME = "asdcp-unwrap"; // program name for messages // Increment the iterator, test for an additional non-option command line argument. // Causes the caller to return if there are no remaining arguments or if the next // argument begins with '-'. #define TEST_EXTRA_ARG(i,c) \ if ( ++i >= argc || argv[(i)][0] == '-' ) { \ fprintf(stderr, "Argument not found for option -%c.\n", (c)); \ return; \ } // void banner(FILE* stream = stdout) { fprintf(stream, "\n\ %s (asdcplib %s)\n\n\ Copyright (c) 2003-2015 John Hurst\n\n\ asdcplib may be copied only under the terms of the license found at\n\ the top of every file in the asdcplib distribution kit.\n\n\ Specify the -h (help) option for further information about %s\n\n", PROGRAM_NAME, ASDCP::Version(), PROGRAM_NAME); } // void usage(FILE* stream = stdout) { fprintf(stream, "\ USAGE: %s [-h|-help] [-V]\n\ \n\ %s -G [-v] <input-file>\n\ \n\ %s [-1|-2] [-3] [-b <buffer-size>] [-d <duration>]\n\ [-f <starting-frame>] [-m] [-p <frame-rate>] [-R] [-s <size>] [-v] [-W]\n\ [-w] <input-file> [<file-prefix>]\n\n", PROGRAM_NAME, PROGRAM_NAME, PROGRAM_NAME); fprintf(stream, "\ Options:\n\ -1 - Split Wave essence to mono WAV files during extract.\n\ Default is multichannel WAV\n\ -2 - Split Wave essence to stereo WAV files during extract.\n\ Default is multichannel WAV\n\ -3 - Force stereoscopic interpretation of a JP2K file.\n\ -b <buffer-size> - Specify size in bytes of picture frame buffer\n\ Defaults to 4,194,304 (4MB)\n\ -d <duration> - Number of frames to process, default all\n\ -e <extension> - Extension to use for Unknown D-Cinema Data files. default dcdata\n\ -f <start-frame> - Starting frame number, default 0\n \ -G - Perform GOP start lookup test on MXF+Interop MPEG file\n\ -h | -help - Show help\n\ -k <key-string> - Use key for ciphertext operations\n\ -m - verify HMAC values when reading\n\ -p <rate> - Alternative picture rate when unwrapping PCM:\n\ Use one of [23|24|25|30|48|50|60], 24 is default\n\ -s <size> - Number of bytes to dump to output when -v is given\n\ -V - Show version information\n\ -v - Verbose, prints informative messages to stderr\n\ -W - Read input file only, do not write destination file\n\ -w <width> - Width of numeric element in a series of frame file names\n\ (default 6)\n\ -z - Fail if j2c inputs have unequal parameters (default)\n\ -Z - Ignore unequal parameters in j2c inputs\n\ \n\ NOTES: o There is no option grouping, all options must be distinct arguments.\n\ o All option arguments must be separated from the option by whitespace.\n\ o An argument of \"23\" to the -p option will be interpreted\n\ as 24000/1001 fps.\n\n"); } // enum MajorMode_t { MMT_NONE, MMT_EXTRACT, MMT_GOP_START, }; // class CommandOptions { CommandOptions(); public: MajorMode_t mode; bool error_flag; // true if the given options are in error or not complete bool key_flag; // true if an encryption key was given bool read_hmac; // true if HMAC values are to be validated bool split_wav; // true if PCM is to be extracted to stereo WAV files bool mono_wav; // true if PCM is to be extracted to mono WAV files bool verbose_flag; // true if the verbose option was selected ui32_t fb_dump_size; // number of bytes of frame buffer to dump bool no_write_flag; // true if no output files are to be written bool version_flag; // true if the version display option was selected bool help_flag; // true if the help display option was selected bool stereo_image_flag; // if true, expect stereoscopic JP2K input (left eye first) ui32_t number_width; // number of digits in a serialized filename (for JPEG extract) ui32_t start_frame; // frame number to begin processing ui32_t duration; // number of frames to be processed bool duration_flag; // true if duration argument given bool j2c_pedantic; // passed to JP2K::SequenceParser::OpenRead ui32_t picture_rate; // fps of picture when wrapping PCM ui32_t fb_size; // size of picture frame buffer const char* file_prefix; // filename pre for files written by the extract mode byte_t key_value[KeyLen]; // value of given encryption key (when key_flag is true) byte_t key_id_value[UUIDlen];// value of given key ID (when key_id_flag is true) PCM::ChannelFormat_t channel_fmt; // audio channel arrangement const char* input_filename; std::string prefix_buffer; const char* extension; // file extension to use for unknown D-Cinema Data track files. // Rational PictureRate() { if ( picture_rate == 16 ) return EditRate_16; if ( picture_rate == 18 ) return EditRate_18; if ( picture_rate == 20 ) return EditRate_20; if ( picture_rate == 22 ) return EditRate_22; if ( picture_rate == 23 ) return EditRate_23_98; if ( picture_rate == 24 ) return EditRate_24; if ( picture_rate == 25 ) return EditRate_25; if ( picture_rate == 30 ) return EditRate_30; if ( picture_rate == 48 ) return EditRate_48; if ( picture_rate == 50 ) return EditRate_50; if ( picture_rate == 60 ) return EditRate_60; if ( picture_rate == 96 ) return EditRate_96; if ( picture_rate == 100 ) return EditRate_100; if ( picture_rate == 120 ) return EditRate_120; if ( picture_rate == 192 ) return EditRate_192; if ( picture_rate == 200 ) return EditRate_200; if ( picture_rate == 240 ) return EditRate_240; return EditRate_24; } // CommandOptions(int argc, const char** argv) : mode(MMT_EXTRACT), error_flag(true), key_flag(false), read_hmac(false), split_wav(false), mono_wav(false), verbose_flag(false), fb_dump_size(0), no_write_flag(false), version_flag(false), help_flag(false), stereo_image_flag(false), number_width(6), start_frame(0), duration(0xffffffff), duration_flag(false), j2c_pedantic(true), picture_rate(24), fb_size(FRAME_BUFFER_SIZE), file_prefix(0), channel_fmt(PCM::CF_NONE), input_filename(0), extension("dcdata") { memset(key_value, 0, KeyLen); memset(key_id_value, 0, UUIDlen); for ( int i = 1; i < argc; ++i ) { if ( (strcmp( argv[i], "-help") == 0) ) { help_flag = true; continue; } if ( argv[i][0] == '-' && ( isalpha(argv[i][1]) || isdigit(argv[i][1]) ) && argv[i][2] == 0 ) { switch ( argv[i][1] ) { case '1': mono_wav = true; break; case '2': split_wav = true; break; case '3': stereo_image_flag = true; break; case 'b': TEST_EXTRA_ARG(i, 'b'); fb_size = Kumu::xabs(strtol(argv[i], 0, 10)); break; case 'd': TEST_EXTRA_ARG(i, 'd'); duration_flag = true; duration = Kumu::xabs(strtol(argv[i], 0, 10)); break; case 'e': TEST_EXTRA_ARG(i, 'e'); extension = argv[i]; break; case 'f': TEST_EXTRA_ARG(i, 'f'); start_frame = Kumu::xabs(strtol(argv[i], 0, 10)); break; case 'G': mode = MMT_GOP_START; break; case 'h': help_flag = true; break; case 'k': key_flag = true; TEST_EXTRA_ARG(i, 'k'); { ui32_t length; Kumu::hex2bin(argv[i], key_value, KeyLen, &length); if ( length != KeyLen ) { fprintf(stderr, "Unexpected key length: %u, expecting %u characters.\n", length, KeyLen); return; } } break; case 'm': read_hmac = true; break; case 'p': TEST_EXTRA_ARG(i, 'p'); picture_rate = Kumu::xabs(strtol(argv[i], 0, 10)); break; case 's': TEST_EXTRA_ARG(i, 's'); fb_dump_size = Kumu::xabs(strtol(argv[i], 0, 10)); break; case 'V': version_flag = true; break; case 'v': verbose_flag = true; break; case 'W': no_write_flag = true; break; case 'w': TEST_EXTRA_ARG(i, 'w'); number_width = Kumu::xabs(strtol(argv[i], 0, 10)); break; case 'Z': j2c_pedantic = false; break; case 'z': j2c_pedantic = true; break; default: fprintf(stderr, "Unrecognized option: %s\n", argv[i]); return; } } else { if ( argv[i][0] != '-' ) { if ( input_filename == 0 ) { input_filename = argv[i]; } else if ( file_prefix == 0 ) { file_prefix = argv[i]; } } else { fprintf(stderr, "Unrecognized argument: %s\n", argv[i]); return; } } } if ( help_flag || version_flag ) return; if ( ( mode == MMT_EXTRACT || mode == MMT_GOP_START ) && input_filename == 0 ) { fputs("Option requires at least one filename argument.\n", stderr); return; } if ( mode == MMT_EXTRACT && file_prefix == 0 ) { prefix_buffer = Kumu::PathSetExtension(input_filename, "") + "_"; file_prefix = prefix_buffer.c_str(); } error_flag = false; } }; //------------------------------------------------------------------------------------------ // MPEG2 essence // Read a plaintext MPEG2 Video Elementary Stream from a plaintext ASDCP file // Read a plaintext MPEG2 Video Elementary Stream from a ciphertext ASDCP file // Read a ciphertext MPEG2 Video Elementary Stream from a ciphertext ASDCP file // Result_t read_MPEG2_file(CommandOptions& Options) { AESDecContext* Context = 0; HMACContext* HMAC = 0; MPEG2::MXFReader Reader; MPEG2::FrameBuffer FrameBuffer(Options.fb_size); Kumu::FileWriter OutFile; ui32_t frame_count = 0; Result_t result = Reader.OpenRead(Options.input_filename); if ( ASDCP_SUCCESS(result) ) { MPEG2::VideoDescriptor VDesc; Reader.FillVideoDescriptor(VDesc); frame_count = VDesc.ContainerDuration; if ( Options.verbose_flag ) { fprintf(stderr, "Frame Buffer size: %u\n", Options.fb_size); MPEG2::VideoDescriptorDump(VDesc); } } if ( ASDCP_SUCCESS(result) && ( ! Options.no_write_flag ) ) { char filename[256]; snprintf(filename, 256, "%s.ves", Options.file_prefix); result = OutFile.OpenWrite(filename); } if ( ASDCP_SUCCESS(result) && Options.key_flag ) { Context = new AESDecContext; result = Context->InitKey(Options.key_value); if ( ASDCP_SUCCESS(result) && Options.read_hmac ) { WriterInfo Info; Reader.FillWriterInfo(Info); if ( Info.UsesHMAC ) { HMAC = new HMACContext; result = HMAC->InitKey(Options.key_value, Info.LabelSetType); } else { fputs("File does not contain HMAC values, ignoring -m option.\n", stderr); } } } ui32_t last_frame = Options.start_frame + ( Options.duration ? Options.duration : frame_count); if ( last_frame > frame_count ) last_frame = frame_count; for ( ui32_t i = Options.start_frame; ASDCP_SUCCESS(result) && i < last_frame; i++ ) { result = Reader.ReadFrame(i, FrameBuffer, Context, HMAC); if ( ASDCP_SUCCESS(result) ) { if ( Options.verbose_flag ) FrameBuffer.Dump(stderr, Options.fb_dump_size); if ( ! Options.no_write_flag ) { ui32_t write_count = 0; result = OutFile.Write(FrameBuffer.Data(), FrameBuffer.Size(), &write_count); } } } return result; } // Result_t gop_start_test(CommandOptions& Options) { using namespace ASDCP::MPEG2; MXFReader Reader; MPEG2::FrameBuffer FrameBuffer(Options.fb_size); ui32_t frame_count = 0; Result_t result = Reader.OpenRead(Options.input_filename); if ( ASDCP_SUCCESS(result) ) { MPEG2::VideoDescriptor VDesc; Reader.FillVideoDescriptor(VDesc); frame_count = VDesc.ContainerDuration; if ( Options.verbose_flag ) { fprintf(stderr, "Frame Buffer size: %u\n", Options.fb_size); MPEG2::VideoDescriptorDump(VDesc); } } ui32_t last_frame = Options.start_frame + ( Options.duration ? Options.duration : frame_count); if ( last_frame > frame_count ) last_frame = frame_count; for ( ui32_t i = Options.start_frame; ASDCP_SUCCESS(result) && i < last_frame; i++ ) { result = Reader.ReadFrameGOPStart(i, FrameBuffer); if ( ASDCP_SUCCESS(result) ) { if ( Options.verbose_flag ) FrameBuffer.Dump(stderr, Options.fb_dump_size); if ( FrameBuffer.FrameType() != FRAME_I ) fprintf(stderr, "Expecting an I frame, got %c\n", FrameTypeChar(FrameBuffer.FrameType())); fprintf(stderr, "Requested frame %u, got %u\n", i, FrameBuffer.FrameNumber()); } } return result; } //------------------------------------------------------------------------------------------ // JPEG 2000 essence // Read one or more plaintext JPEG 2000 stereoscopic codestream pairs from a plaintext ASDCP file // Read one or more plaintext JPEG 2000 stereoscopic codestream pairs from a ciphertext ASDCP file // Read one or more ciphertext JPEG 2000 stereoscopic codestream pairs from a ciphertext ASDCP file Result_t read_JP2K_S_file(CommandOptions& Options) { AESDecContext* Context = 0; HMACContext* HMAC = 0; JP2K::MXFSReader Reader; JP2K::FrameBuffer FrameBuffer(Options.fb_size); ui32_t frame_count = 0; Result_t result = Reader.OpenRead(Options.input_filename); if ( ASDCP_SUCCESS(result) ) { JP2K::PictureDescriptor PDesc; Reader.FillPictureDescriptor(PDesc); frame_count = PDesc.ContainerDuration; if ( Options.verbose_flag ) { fprintf(stderr, "Frame Buffer size: %u\n", Options.fb_size); JP2K::PictureDescriptorDump(PDesc); } } if ( ASDCP_SUCCESS(result) && Options.key_flag ) { Context = new AESDecContext; result = Context->InitKey(Options.key_value); if ( ASDCP_SUCCESS(result) && Options.read_hmac ) { WriterInfo Info; Reader.FillWriterInfo(Info); if ( Info.UsesHMAC ) { HMAC = new HMACContext; result = HMAC->InitKey(Options.key_value, Info.LabelSetType); } else { fputs("File does not contain HMAC values, ignoring -m option.\n", stderr); } } } const int filename_max = 1024; char filename[filename_max]; ui32_t last_frame = Options.start_frame + ( Options.duration ? Options.duration : frame_count); if ( last_frame > frame_count ) last_frame = frame_count; char left_format[64]; char right_format[64]; snprintf(left_format, 64, "%%s%%0%duL.j2c", Options.number_width); snprintf(right_format, 64, "%%s%%0%duR.j2c", Options.number_width); for ( ui32_t i = Options.start_frame; ASDCP_SUCCESS(result) && i < last_frame; i++ ) { result = Reader.ReadFrame(i, JP2K::SP_LEFT, FrameBuffer, Context, HMAC); if ( ASDCP_SUCCESS(result) ) { if ( ! Options.no_write_flag ) { Kumu::FileWriter OutFile; ui32_t write_count; snprintf(filename, filename_max, left_format, Options.file_prefix, i); result = OutFile.OpenWrite(filename); if ( ASDCP_SUCCESS(result) ) result = OutFile.Write(FrameBuffer.Data(), FrameBuffer.Size(), &write_count); } if ( Options.verbose_flag ) FrameBuffer.Dump(stderr, Options.fb_dump_size); } if ( ASDCP_SUCCESS(result) ) result = Reader.ReadFrame(i, JP2K::SP_RIGHT, FrameBuffer, Context, HMAC); if ( ASDCP_SUCCESS(result) ) { if ( ! Options.no_write_flag ) { Kumu::FileWriter OutFile; ui32_t write_count; snprintf(filename, filename_max, right_format, Options.file_prefix, i); result = OutFile.OpenWrite(filename); if ( ASDCP_SUCCESS(result) ) result = OutFile.Write(FrameBuffer.Data(), FrameBuffer.Size(), &write_count); } if ( Options.verbose_flag ) FrameBuffer.Dump(stderr, Options.fb_dump_size); } } return result; } // Read one or more plaintext JPEG 2000 codestreams from a plaintext ASDCP file // Read one or more plaintext JPEG 2000 codestreams from a ciphertext ASDCP file // Read one or more ciphertext JPEG 2000 codestreams from a ciphertext ASDCP file // Result_t read_JP2K_file(CommandOptions& Options) { AESDecContext* Context = 0; HMACContext* HMAC = 0; JP2K::MXFReader Reader; JP2K::FrameBuffer FrameBuffer(Options.fb_size); ui32_t frame_count = 0; Result_t result = Reader.OpenRead(Options.input_filename); if ( ASDCP_SUCCESS(result) ) { JP2K::PictureDescriptor PDesc; Reader.FillPictureDescriptor(PDesc); frame_count = PDesc.ContainerDuration; if ( Options.verbose_flag ) { fprintf(stderr, "Frame Buffer size: %u\n", Options.fb_size); JP2K::PictureDescriptorDump(PDesc); } } if ( ASDCP_SUCCESS(result) && Options.key_flag ) { Context = new AESDecContext; result = Context->InitKey(Options.key_value); if ( ASDCP_SUCCESS(result) && Options.read_hmac ) { WriterInfo Info; Reader.FillWriterInfo(Info); if ( Info.UsesHMAC ) { HMAC = new HMACContext; result = HMAC->InitKey(Options.key_value, Info.LabelSetType); } else { fputs("File does not contain HMAC values, ignoring -m option.\n", stderr); } } } ui32_t last_frame = Options.start_frame + ( Options.duration ? Options.duration : frame_count); if ( last_frame > frame_count ) last_frame = frame_count; char name_format[64]; snprintf(name_format, 64, "%%s%%0%du.j2c", Options.number_width); for ( ui32_t i = Options.start_frame; ASDCP_SUCCESS(result) && i < last_frame; i++ ) { result = Reader.ReadFrame(i, FrameBuffer, Context, HMAC); if ( ASDCP_SUCCESS(result) ) { if ( ! Options.no_write_flag ) { Kumu::FileWriter OutFile; char filename[256]; ui32_t write_count; snprintf(filename, 256, name_format, Options.file_prefix, i); result = OutFile.OpenWrite(filename); if ( ASDCP_SUCCESS(result) ) result = OutFile.Write(FrameBuffer.Data(), FrameBuffer.Size(), &write_count); } if ( Options.verbose_flag ) FrameBuffer.Dump(stderr, Options.fb_dump_size); } } return result; } //------------------------------------------------------------------------------------------ // PCM essence // Read one or more plaintext PCM audio streams from a plaintext ASDCP file // Read one or more plaintext PCM audio streams from a ciphertext ASDCP file // Read one or more ciphertext PCM audio streams from a ciphertext ASDCP file // Result_t read_PCM_file(CommandOptions& Options) { AESDecContext* Context = 0; HMACContext* HMAC = 0; PCM::MXFReader Reader; PCM::FrameBuffer FrameBuffer; WavFileWriter OutWave; PCM::AudioDescriptor ADesc; ui32_t last_frame = 0; Result_t result = Reader.OpenRead(Options.input_filename); if ( ASDCP_SUCCESS(result) ) { Reader.FillAudioDescriptor(ADesc); if ( ADesc.EditRate != EditRate_23_98 && ADesc.EditRate != EditRate_24 && ADesc.EditRate != EditRate_25 && ADesc.EditRate != EditRate_30 && ADesc.EditRate != EditRate_48 && ADesc.EditRate != EditRate_50 && ADesc.EditRate != EditRate_60 ) ADesc.EditRate = Options.PictureRate(); if ( Options.fb_size != FRAME_BUFFER_SIZE ) { FrameBuffer.Capacity(Options.fb_size); } else { FrameBuffer.Capacity(PCM::CalcFrameBufferSize(ADesc)); } if ( Options.verbose_flag ) { fprintf(stderr, "Frame Buffer size: %u\n", Options.fb_size); PCM::AudioDescriptorDump(ADesc); } } if ( ASDCP_SUCCESS(result) ) { last_frame = ADesc.ContainerDuration; if ( Options.duration > 0 && Options.duration < last_frame ) last_frame = Options.duration; if ( Options.start_frame > 0 ) { if ( Options.start_frame > ADesc.ContainerDuration ) { fprintf(stderr, "Start value greater than file duration.\n"); return RESULT_FAIL; } last_frame = Kumu::xmin(Options.start_frame + last_frame, ADesc.ContainerDuration); } ADesc.ContainerDuration = last_frame - Options.start_frame; if ( ! Options.no_write_flag ) { OutWave.OpenWrite(ADesc, Options.file_prefix, ( Options.split_wav ? WavFileWriter::ST_STEREO : ( Options.mono_wav ? WavFileWriter::ST_MONO : WavFileWriter::ST_NONE ) )); } } if ( ASDCP_SUCCESS(result) && Options.key_flag ) { Context = new AESDecContext; result = Context->InitKey(Options.key_value); if ( ASDCP_SUCCESS(result) && Options.read_hmac ) { WriterInfo Info; Reader.FillWriterInfo(Info); if ( Info.UsesHMAC ) { HMAC = new HMACContext; result = HMAC->InitKey(Options.key_value, Info.LabelSetType); } else { fputs("File does not contain HMAC values, ignoring -m option.\n", stderr); } } } for ( ui32_t i = Options.start_frame; ASDCP_SUCCESS(result) && i < last_frame; i++ ) { result = Reader.ReadFrame(i, FrameBuffer, Context, HMAC); if ( ASDCP_SUCCESS(result) ) { if ( Options.verbose_flag ) FrameBuffer.Dump(stderr, Options.fb_dump_size); if ( ! Options.no_write_flag ) { result = OutWave.WriteFrame(FrameBuffer); } } } return result; } //------------------------------------------------------------------------------------------ // TimedText essence // Read one or more timed text streams from a plaintext ASDCP file // Read one or more timed text streams from a ciphertext ASDCP file // Read one or more timed text streams from a ciphertext ASDCP file // Result_t read_timed_text_file(CommandOptions& Options) { AESDecContext* Context = 0; HMACContext* HMAC = 0; TimedText::MXFReader Reader; TimedText::FrameBuffer FrameBuffer; TimedText::TimedTextDescriptor TDesc; Result_t result = Reader.OpenRead(Options.input_filename); if ( ASDCP_SUCCESS(result) ) { Reader.FillTimedTextDescriptor(TDesc); FrameBuffer.Capacity(Options.fb_size); if ( Options.verbose_flag ) TimedText::DescriptorDump(TDesc); } if ( ASDCP_SUCCESS(result) && Options.key_flag ) { Context = new AESDecContext; result = Context->InitKey(Options.key_value); if ( ASDCP_SUCCESS(result) && Options.read_hmac ) { WriterInfo Info; Reader.FillWriterInfo(Info); if ( Info.UsesHMAC ) { HMAC = new HMACContext; result = HMAC->InitKey(Options.key_value, Info.LabelSetType); } else { fputs("File does not contain HMAC values, ignoring -m option.\n", stderr); } } } if ( ASDCP_FAILURE(result) ) return result; std::string XMLDoc; std::string out_path = Kumu::PathDirname(Options.file_prefix); ui32_t write_count; char buf[64]; TimedText::ResourceList_t::const_iterator ri; result = Reader.ReadTimedTextResource(XMLDoc, Context, HMAC); if ( ASDCP_SUCCESS(result) && ( ! Options.no_write_flag ) ) { Kumu::FileWriter Writer; result = Writer.OpenWrite(Options.file_prefix); if ( ASDCP_SUCCESS(result) ) result = Writer.Write(reinterpret_cast<const byte_t*>(XMLDoc.c_str()), XMLDoc.size(), &write_count); } for ( ri = TDesc.ResourceList.begin() ; ri != TDesc.ResourceList.end() && ASDCP_SUCCESS(result); ri++ ) { result = Reader.ReadAncillaryResource(ri->ResourceID, FrameBuffer, Context, HMAC); if ( ASDCP_SUCCESS(result) && ( ! Options.no_write_flag ) ) { Kumu::FileWriter Writer; result = Writer.OpenWrite(Kumu::PathJoin(out_path, Kumu::UUID(ri->ResourceID).EncodeHex(buf, 64)).c_str()); if ( ASDCP_SUCCESS(result) ) result = Writer.Write(FrameBuffer.RoData(), FrameBuffer.Size(), &write_count); if ( Options.verbose_flag ) FrameBuffer.Dump(stderr, Options.fb_dump_size); } } return result; } // Read one or more plaintext DCData bytestreams from a plaintext ASDCP file // Read one or more plaintext DCData bytestreams from a ciphertext ASDCP file // Read one or more ciphertext DCData byestreams from a ciphertext ASDCP file // Result_t read_DCData_file(CommandOptions& Options) { AESDecContext* Context = 0; HMACContext* HMAC = 0; DCData::MXFReader Reader; DCData::FrameBuffer FrameBuffer(Options.fb_size); ui32_t frame_count = 0; Result_t result = Reader.OpenRead(Options.input_filename); if ( ASDCP_SUCCESS(result) ) { DCData::DCDataDescriptor DDesc; Reader.FillDCDataDescriptor(DDesc); frame_count = DDesc.ContainerDuration; if ( Options.verbose_flag ) { fprintf(stderr, "Frame Buffer size: %u\n", Options.fb_size); DCData::DCDataDescriptorDump(DDesc); } } if ( ASDCP_SUCCESS(result) && Options.key_flag ) { Context = new AESDecContext; result = Context->InitKey(Options.key_value); if ( ASDCP_SUCCESS(result) && Options.read_hmac ) { WriterInfo Info; Reader.FillWriterInfo(Info); if ( Info.UsesHMAC ) { HMAC = new HMACContext; result = HMAC->InitKey(Options.key_value, Info.LabelSetType); } else { fputs("File does not contain HMAC values, ignoring -m option.\n", stderr); } } } ui32_t last_frame = Options.start_frame + ( Options.duration ? Options.duration : frame_count); if ( last_frame > frame_count ) last_frame = frame_count; char name_format[64]; snprintf(name_format, 64, "%%s%%0%du.%s", Options.number_width, Options.extension); for ( ui32_t i = Options.start_frame; ASDCP_SUCCESS(result) && i < last_frame; i++ ) { result = Reader.ReadFrame(i, FrameBuffer, Context, HMAC); if ( ASDCP_SUCCESS(result) ) { if ( ! Options.no_write_flag ) { Kumu::FileWriter OutFile; char filename[256]; ui32_t write_count; snprintf(filename, 256, name_format, Options.file_prefix, i); result = OutFile.OpenWrite(filename); if ( ASDCP_SUCCESS(result) ) result = OutFile.Write(FrameBuffer.Data(), FrameBuffer.Size(), &write_count); } if ( Options.verbose_flag ) FrameBuffer.Dump(stderr, Options.fb_dump_size); } } return result; } // int main(int argc, const char** argv) { Result_t result = RESULT_OK; char str_buf[64]; CommandOptions Options(argc, argv); if ( Options.version_flag ) banner(); if ( Options.help_flag ) usage(); if ( Options.version_flag || Options.help_flag ) return 0; if ( Options.error_flag ) { fprintf(stderr, "There was a problem. Type %s -h for help.\n", PROGRAM_NAME); return 3; } if ( Options.mode == MMT_GOP_START ) { result = gop_start_test(Options); } else if ( Options.mode == MMT_EXTRACT ) { EssenceType_t EssenceType; result = ASDCP::EssenceType(Options.input_filename, EssenceType); if ( ASDCP_SUCCESS(result) ) { switch ( EssenceType ) { case ESS_MPEG2_VES: result = read_MPEG2_file(Options); break; case ESS_JPEG_2000: if ( Options.stereo_image_flag ) result = read_JP2K_S_file(Options); else result = read_JP2K_file(Options); break; case ESS_JPEG_2000_S: result = read_JP2K_S_file(Options); break; case ESS_PCM_24b_48k: case ESS_PCM_24b_96k: result = read_PCM_file(Options); break; case ESS_TIMED_TEXT: result = read_timed_text_file(Options); break; case ESS_DCDATA_UNKNOWN: result = read_DCData_file(Options); break; case ESS_DCDATA_DOLBY_ATMOS: Options.extension = "atmos"; result = read_DCData_file(Options); break; default: fprintf(stderr, "%s: Unknown file type, not ASDCP essence.\n", Options.input_filename); return 5; } } } else { fprintf(stderr, "Unhandled mode: %d.\n", Options.mode); return 6; } if ( ASDCP_FAILURE(result) ) { fputs("Program stopped on error.\n", stderr); if ( result == RESULT_SFORMAT ) { fputs("Use option '-3' to force stereoscopic mode.\n", stderr); } else if ( result != RESULT_FAIL ) { fputs(result, stderr); fputc('\n', stderr); } return 1; } return 0; } // // end asdcp-unwrap.cpp //
.ORIG x4800 .FILL x0013 ; EXTRA1_DAYS[0] .FILL x4807 ; EXTRA1_NAME_PTR[0] .FILL xFFFD ; EXTRA1_HOURS[0] .FILL x0002 ; EXTRA2_DAYS[0] .FILL x4809 ; EXTRA2_NAME_PTR[0] .FILL x0001 ; EXTRA2_HOURS[0] .FILL xFFFF ; EXTRA3_DAYS[0] .FILL x0044 ; EXTRA1_NAME[0] .FILL x0000 ; EXTRA1_NAME[1] .FILL x0045 ; EXTRA2_NAME[0] .FILL x0045 ; EXTRA2_NAME[1] .FILL x0045 ; EXTRA2_NAME[2] .FILL x0045 ; EXTRA2_NAME[3] .FILL x0045 ; EXTRA2_NAME[4] .FILL x0045 ; EXTRA2_NAME[5] .FILL x0045 ; EXTRA2_NAME[6] .FILL x0045 ; EXTRA2_NAME[7] .FILL x0045 ; EXTRA2_NAME[8] .FILL x0045 ; EXTRA2_NAME[9] .FILL x0000 ; EXTRA2_NAME[10] .END
// Copyright 2014 the V8 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. #include "src/runtime/runtime-utils.h" #include "src/arguments.h" #include "src/factory.h" #include "src/messages.h" #include "src/objects-inl.h" #include "src/runtime/runtime.h" namespace v8 { namespace internal { void Runtime::SetupArrayBuffer(Isolate* isolate, Handle<JSArrayBuffer> array_buffer, bool is_external, void* data, size_t allocated_length, SharedFlag shared) { DCHECK(array_buffer->GetInternalFieldCount() == v8::ArrayBuffer::kInternalFieldCount); for (int i = 0; i < v8::ArrayBuffer::kInternalFieldCount; i++) { array_buffer->SetInternalField(i, Smi::FromInt(0)); } array_buffer->set_backing_store(data); array_buffer->set_bit_field(0); array_buffer->set_is_external(is_external); array_buffer->set_is_neuterable(shared == SharedFlag::kNotShared); array_buffer->set_is_shared(shared == SharedFlag::kShared); if (data && !is_external) { isolate->heap()->RegisterNewArrayBuffer( isolate->heap()->InNewSpace(*array_buffer), data, allocated_length); } Handle<Object> byte_length = isolate->factory()->NewNumberFromSize(allocated_length); CHECK(byte_length->IsSmi() || byte_length->IsHeapNumber()); array_buffer->set_byte_length(*byte_length); } bool Runtime::SetupArrayBufferAllocatingData(Isolate* isolate, Handle<JSArrayBuffer> array_buffer, size_t allocated_length, bool initialize, SharedFlag shared) { void* data; CHECK(isolate->array_buffer_allocator() != NULL); // Prevent creating array buffers when serializing. DCHECK(!isolate->serializer_enabled()); if (allocated_length != 0) { if (initialize) { data = isolate->array_buffer_allocator()->Allocate(allocated_length); } else { data = isolate->array_buffer_allocator()->AllocateUninitialized( allocated_length); } if (data == NULL) return false; } else { data = NULL; } SetupArrayBuffer(isolate, array_buffer, false, data, allocated_length, shared); return true; } void Runtime::NeuterArrayBuffer(Handle<JSArrayBuffer> array_buffer) { array_buffer->Neuter(); } RUNTIME_FUNCTION(Runtime_ArrayBufferInitialize) { HandleScope scope(isolate); DCHECK(args.length() == 3); CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, holder, 0); CONVERT_NUMBER_ARG_HANDLE_CHECKED(byteLength, 1); CONVERT_BOOLEAN_ARG_CHECKED(is_shared, 2); if (!holder->byte_length()->IsUndefined()) { // ArrayBuffer is already initialized; probably a fuzz test. return *holder; } size_t allocated_length = 0; if (!TryNumberToSize(isolate, *byteLength, &allocated_length)) { THROW_NEW_ERROR_RETURN_FAILURE( isolate, NewRangeError(MessageTemplate::kInvalidArrayBufferLength)); } if (!Runtime::SetupArrayBufferAllocatingData( isolate, holder, allocated_length, true, is_shared ? SharedFlag::kShared : SharedFlag::kNotShared)) { THROW_NEW_ERROR_RETURN_FAILURE( isolate, NewRangeError(MessageTemplate::kInvalidArrayBufferLength)); } return *holder; } RUNTIME_FUNCTION(Runtime_ArrayBufferGetByteLength) { SealHandleScope shs(isolate); DCHECK(args.length() == 1); CONVERT_ARG_CHECKED(JSArrayBuffer, holder, 0); return holder->byte_length(); } RUNTIME_FUNCTION(Runtime_ArrayBufferSliceImpl) { HandleScope scope(isolate); DCHECK(args.length() == 3); CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, source, 0); CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, target, 1); CONVERT_NUMBER_ARG_HANDLE_CHECKED(first, 2); RUNTIME_ASSERT(!source.is_identical_to(target)); size_t start = 0; RUNTIME_ASSERT(TryNumberToSize(isolate, *first, &start)); size_t target_length = NumberToSize(isolate, target->byte_length()); if (target_length == 0) return isolate->heap()->undefined_value(); size_t source_byte_length = NumberToSize(isolate, source->byte_length()); RUNTIME_ASSERT(start <= source_byte_length); RUNTIME_ASSERT(source_byte_length - start >= target_length); uint8_t* source_data = reinterpret_cast<uint8_t*>(source->backing_store()); uint8_t* target_data = reinterpret_cast<uint8_t*>(target->backing_store()); CopyBytes(target_data, source_data + start, target_length); return isolate->heap()->undefined_value(); } RUNTIME_FUNCTION(Runtime_ArrayBufferIsView) { HandleScope scope(isolate); DCHECK(args.length() == 1); CONVERT_ARG_CHECKED(Object, object, 0); return isolate->heap()->ToBoolean(object->IsJSArrayBufferView()); } RUNTIME_FUNCTION(Runtime_ArrayBufferNeuter) { HandleScope scope(isolate); DCHECK(args.length() == 1); CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, array_buffer, 0); if (array_buffer->backing_store() == NULL) { CHECK(Smi::FromInt(0) == array_buffer->byte_length()); return isolate->heap()->undefined_value(); } // Shared array buffers should never be neutered. RUNTIME_ASSERT(!array_buffer->is_shared()); DCHECK(!array_buffer->is_external()); void* backing_store = array_buffer->backing_store(); size_t byte_length = NumberToSize(isolate, array_buffer->byte_length()); array_buffer->set_is_external(true); Runtime::NeuterArrayBuffer(array_buffer); isolate->heap()->UnregisterArrayBuffer( isolate->heap()->InNewSpace(*array_buffer), backing_store); isolate->array_buffer_allocator()->Free(backing_store, byte_length); return isolate->heap()->undefined_value(); } void Runtime::ArrayIdToTypeAndSize(int arrayId, ExternalArrayType* array_type, ElementsKind* fixed_elements_kind, size_t* element_size) { switch (arrayId) { #define ARRAY_ID_CASE(Type, type, TYPE, ctype, size) \ case ARRAY_ID_##TYPE: \ *array_type = kExternal##Type##Array; \ *fixed_elements_kind = TYPE##_ELEMENTS; \ *element_size = size; \ break; TYPED_ARRAYS(ARRAY_ID_CASE) #undef ARRAY_ID_CASE default: UNREACHABLE(); } } RUNTIME_FUNCTION(Runtime_TypedArrayInitialize) { HandleScope scope(isolate); DCHECK(args.length() == 6); CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); CONVERT_SMI_ARG_CHECKED(arrayId, 1); CONVERT_ARG_HANDLE_CHECKED(Object, maybe_buffer, 2); CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_offset_object, 3); CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_length_object, 4); CONVERT_BOOLEAN_ARG_CHECKED(initialize, 5); RUNTIME_ASSERT(arrayId >= Runtime::ARRAY_ID_FIRST && arrayId <= Runtime::ARRAY_ID_LAST); ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization. size_t element_size = 1; // Bogus initialization. ElementsKind fixed_elements_kind = INT8_ELEMENTS; // Bogus initialization. Runtime::ArrayIdToTypeAndSize(arrayId, &array_type, &fixed_elements_kind, &element_size); RUNTIME_ASSERT(holder->map()->elements_kind() == fixed_elements_kind); size_t byte_offset = 0; size_t byte_length = 0; RUNTIME_ASSERT(TryNumberToSize(isolate, *byte_offset_object, &byte_offset)); RUNTIME_ASSERT(TryNumberToSize(isolate, *byte_length_object, &byte_length)); if (maybe_buffer->IsJSArrayBuffer()) { Handle<JSArrayBuffer> buffer = Handle<JSArrayBuffer>::cast(maybe_buffer); size_t array_buffer_byte_length = NumberToSize(isolate, buffer->byte_length()); RUNTIME_ASSERT(byte_offset <= array_buffer_byte_length); RUNTIME_ASSERT(array_buffer_byte_length - byte_offset >= byte_length); } else { RUNTIME_ASSERT(maybe_buffer->IsNull()); } RUNTIME_ASSERT(byte_length % element_size == 0); size_t length = byte_length / element_size; if (length > static_cast<unsigned>(Smi::kMaxValue)) { THROW_NEW_ERROR_RETURN_FAILURE( isolate, NewRangeError(MessageTemplate::kInvalidTypedArrayLength)); } // All checks are done, now we can modify objects. DCHECK(holder->GetInternalFieldCount() == v8::ArrayBufferView::kInternalFieldCount); for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { holder->SetInternalField(i, Smi::FromInt(0)); } Handle<Object> length_obj = isolate->factory()->NewNumberFromSize(length); holder->set_length(*length_obj); holder->set_byte_offset(*byte_offset_object); holder->set_byte_length(*byte_length_object); if (!maybe_buffer->IsNull()) { Handle<JSArrayBuffer> buffer = Handle<JSArrayBuffer>::cast(maybe_buffer); holder->set_buffer(*buffer); Handle<FixedTypedArrayBase> elements = isolate->factory()->NewFixedTypedArrayWithExternalPointer( static_cast<int>(length), array_type, static_cast<uint8_t*>(buffer->backing_store()) + byte_offset); holder->set_elements(*elements); } else { Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer(); Runtime::SetupArrayBuffer(isolate, buffer, true, NULL, byte_length, SharedFlag::kNotShared); holder->set_buffer(*buffer); Handle<FixedTypedArrayBase> elements = isolate->factory()->NewFixedTypedArray(static_cast<int>(length), array_type, initialize); holder->set_elements(*elements); } return isolate->heap()->undefined_value(); } // Initializes a typed array from an array-like object. // If an array-like object happens to be a typed array of the same type, // initializes backing store using memove. // // Returns true if backing store was initialized or false otherwise. RUNTIME_FUNCTION(Runtime_TypedArrayInitializeFromArrayLike) { HandleScope scope(isolate); DCHECK(args.length() == 4); CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); CONVERT_SMI_ARG_CHECKED(arrayId, 1); CONVERT_ARG_HANDLE_CHECKED(Object, source, 2); CONVERT_NUMBER_ARG_HANDLE_CHECKED(length_obj, 3); RUNTIME_ASSERT(arrayId >= Runtime::ARRAY_ID_FIRST && arrayId <= Runtime::ARRAY_ID_LAST); ExternalArrayType array_type = kExternalInt8Array; // Bogus initialization. size_t element_size = 1; // Bogus initialization. ElementsKind fixed_elements_kind = INT8_ELEMENTS; // Bogus initialization. Runtime::ArrayIdToTypeAndSize(arrayId, &array_type, &fixed_elements_kind, &element_size); RUNTIME_ASSERT(holder->map()->elements_kind() == fixed_elements_kind); Handle<JSArrayBuffer> buffer = isolate->factory()->NewJSArrayBuffer(); size_t length = 0; if (source->IsJSTypedArray() && JSTypedArray::cast(*source)->type() == array_type) { length_obj = handle(JSTypedArray::cast(*source)->length(), isolate); length = JSTypedArray::cast(*source)->length_value(); } else { RUNTIME_ASSERT(TryNumberToSize(isolate, *length_obj, &length)); } if ((length > static_cast<unsigned>(Smi::kMaxValue)) || (length > (kMaxInt / element_size))) { THROW_NEW_ERROR_RETURN_FAILURE( isolate, NewRangeError(MessageTemplate::kInvalidTypedArrayLength)); } size_t byte_length = length * element_size; DCHECK(holder->GetInternalFieldCount() == v8::ArrayBufferView::kInternalFieldCount); for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { holder->SetInternalField(i, Smi::FromInt(0)); } // NOTE: not initializing backing store. // We assume that the caller of this function will initialize holder // with the loop // for(i = 0; i < length; i++) { holder[i] = source[i]; } // We assume that the caller of this function is always a typed array // constructor. // If source is a typed array, this loop will always run to completion, // so we are sure that the backing store will be initialized. // Otherwise, the indexing operation might throw, so the loop will not // run to completion and the typed array might remain partly initialized. // However we further assume that the caller of this function is a typed array // constructor, and the exception will propagate out of the constructor, // therefore uninitialized memory will not be accessible by a user program. // // TODO(dslomov): revise this once we support subclassing. if (!Runtime::SetupArrayBufferAllocatingData(isolate, buffer, byte_length, false)) { THROW_NEW_ERROR_RETURN_FAILURE( isolate, NewRangeError(MessageTemplate::kInvalidArrayBufferLength)); } holder->set_buffer(*buffer); holder->set_byte_offset(Smi::FromInt(0)); Handle<Object> byte_length_obj( isolate->factory()->NewNumberFromSize(byte_length)); holder->set_byte_length(*byte_length_obj); holder->set_length(*length_obj); Handle<FixedTypedArrayBase> elements = isolate->factory()->NewFixedTypedArrayWithExternalPointer( static_cast<int>(length), array_type, static_cast<uint8_t*>(buffer->backing_store())); holder->set_elements(*elements); if (source->IsJSTypedArray()) { Handle<JSTypedArray> typed_array(JSTypedArray::cast(*source)); if (typed_array->type() == holder->type()) { uint8_t* backing_store = static_cast<uint8_t*>(typed_array->GetBuffer()->backing_store()); size_t source_byte_offset = NumberToSize(isolate, typed_array->byte_offset()); memcpy(buffer->backing_store(), backing_store + source_byte_offset, byte_length); return isolate->heap()->true_value(); } } return isolate->heap()->false_value(); } #define BUFFER_VIEW_GETTER(Type, getter, accessor) \ RUNTIME_FUNCTION(Runtime_##Type##Get##getter) { \ HandleScope scope(isolate); \ DCHECK_EQ(1, args.length()); \ CONVERT_ARG_HANDLE_CHECKED(JS##Type, holder, 0); \ return holder->accessor(); \ } BUFFER_VIEW_GETTER(ArrayBufferView, ByteLength, byte_length) BUFFER_VIEW_GETTER(ArrayBufferView, ByteOffset, byte_offset) BUFFER_VIEW_GETTER(TypedArray, Length, length) BUFFER_VIEW_GETTER(DataView, Buffer, buffer) #undef BUFFER_VIEW_GETTER RUNTIME_FUNCTION(Runtime_TypedArrayGetBuffer) { HandleScope scope(isolate); DCHECK_EQ(1, args.length()); CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, holder, 0); return *holder->GetBuffer(); } // Return codes for Runtime_TypedArraySetFastCases. // Should be synchronized with typedarray.js natives. enum TypedArraySetResultCodes { // Set from typed array of the same type. // This is processed by TypedArraySetFastCases TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE = 0, // Set from typed array of the different type, overlapping in memory. TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING = 1, // Set from typed array of the different type, non-overlapping. TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING = 2, // Set from non-typed array. TYPED_ARRAY_SET_NON_TYPED_ARRAY = 3 }; RUNTIME_FUNCTION(Runtime_TypedArraySetFastCases) { HandleScope scope(isolate); DCHECK(args.length() == 3); if (!args[0]->IsJSTypedArray()) { THROW_NEW_ERROR_RETURN_FAILURE( isolate, NewTypeError(MessageTemplate::kNotTypedArray)); } if (!args[1]->IsJSTypedArray()) return Smi::FromInt(TYPED_ARRAY_SET_NON_TYPED_ARRAY); CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, target_obj, 0); CONVERT_ARG_HANDLE_CHECKED(JSTypedArray, source_obj, 1); CONVERT_NUMBER_ARG_HANDLE_CHECKED(offset_obj, 2); Handle<JSTypedArray> target(JSTypedArray::cast(*target_obj)); Handle<JSTypedArray> source(JSTypedArray::cast(*source_obj)); size_t offset = 0; RUNTIME_ASSERT(TryNumberToSize(isolate, *offset_obj, &offset)); size_t target_length = target->length_value(); size_t source_length = source->length_value(); size_t target_byte_length = NumberToSize(isolate, target->byte_length()); size_t source_byte_length = NumberToSize(isolate, source->byte_length()); if (offset > target_length || offset + source_length > target_length || offset + source_length < offset) { // overflow THROW_NEW_ERROR_RETURN_FAILURE( isolate, NewRangeError(MessageTemplate::kTypedArraySetSourceTooLarge)); } size_t target_offset = NumberToSize(isolate, target->byte_offset()); size_t source_offset = NumberToSize(isolate, source->byte_offset()); uint8_t* target_base = static_cast<uint8_t*>(target->GetBuffer()->backing_store()) + target_offset; uint8_t* source_base = static_cast<uint8_t*>(source->GetBuffer()->backing_store()) + source_offset; // Typed arrays of the same type: use memmove. if (target->type() == source->type()) { memmove(target_base + offset * target->element_size(), source_base, source_byte_length); return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_SAME_TYPE); } // Typed arrays of different types over the same backing store if ((source_base <= target_base && source_base + source_byte_length > target_base) || (target_base <= source_base && target_base + target_byte_length > source_base)) { // We do not support overlapping ArrayBuffers DCHECK(target->GetBuffer()->backing_store() == source->GetBuffer()->backing_store()); return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_OVERLAPPING); } else { // Non-overlapping typed arrays return Smi::FromInt(TYPED_ARRAY_SET_TYPED_ARRAY_NONOVERLAPPING); } } RUNTIME_FUNCTION(Runtime_TypedArrayMaxSizeInHeap) { DCHECK(args.length() == 0); DCHECK_OBJECT_SIZE(FLAG_typed_array_max_size_in_heap + FixedTypedArrayBase::kDataOffset); return Smi::FromInt(FLAG_typed_array_max_size_in_heap); } RUNTIME_FUNCTION(Runtime_IsTypedArray) { HandleScope scope(isolate); DCHECK(args.length() == 1); return isolate->heap()->ToBoolean(args[0]->IsJSTypedArray()); } RUNTIME_FUNCTION(Runtime_IsSharedTypedArray) { HandleScope scope(isolate); DCHECK(args.length() == 1); return isolate->heap()->ToBoolean( args[0]->IsJSTypedArray() && JSTypedArray::cast(args[0])->GetBuffer()->is_shared()); } RUNTIME_FUNCTION(Runtime_IsSharedIntegerTypedArray) { HandleScope scope(isolate); DCHECK(args.length() == 1); if (!args[0]->IsJSTypedArray()) { return isolate->heap()->false_value(); } Handle<JSTypedArray> obj(JSTypedArray::cast(args[0])); return isolate->heap()->ToBoolean(obj->GetBuffer()->is_shared() && obj->type() != kExternalFloat32Array && obj->type() != kExternalFloat64Array); } RUNTIME_FUNCTION(Runtime_DataViewInitialize) { HandleScope scope(isolate); DCHECK(args.length() == 4); CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); CONVERT_ARG_HANDLE_CHECKED(JSArrayBuffer, buffer, 1); CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_offset, 2); CONVERT_NUMBER_ARG_HANDLE_CHECKED(byte_length, 3); DCHECK(holder->GetInternalFieldCount() == v8::ArrayBufferView::kInternalFieldCount); for (int i = 0; i < v8::ArrayBufferView::kInternalFieldCount; i++) { holder->SetInternalField(i, Smi::FromInt(0)); } size_t buffer_length = 0; size_t offset = 0; size_t length = 0; RUNTIME_ASSERT( TryNumberToSize(isolate, buffer->byte_length(), &buffer_length)); RUNTIME_ASSERT(TryNumberToSize(isolate, *byte_offset, &offset)); RUNTIME_ASSERT(TryNumberToSize(isolate, *byte_length, &length)); // TODO(jkummerow): When we have a "safe numerics" helper class, use it here. // Entire range [offset, offset + length] must be in bounds. RUNTIME_ASSERT(offset <= buffer_length); RUNTIME_ASSERT(offset + length <= buffer_length); // No overflow. RUNTIME_ASSERT(offset + length >= offset); holder->set_buffer(*buffer); holder->set_byte_offset(*byte_offset); holder->set_byte_length(*byte_length); return isolate->heap()->undefined_value(); } inline static bool NeedToFlipBytes(bool is_little_endian) { #ifdef V8_TARGET_LITTLE_ENDIAN return !is_little_endian; #else return is_little_endian; #endif } template <int n> inline void CopyBytes(uint8_t* target, uint8_t* source) { for (int i = 0; i < n; i++) { *(target++) = *(source++); } } template <int n> inline void FlipBytes(uint8_t* target, uint8_t* source) { source = source + (n - 1); for (int i = 0; i < n; i++) { *(target++) = *(source--); } } template <typename T> inline static bool DataViewGetValue(Isolate* isolate, Handle<JSDataView> data_view, Handle<Object> byte_offset_obj, bool is_little_endian, T* result) { size_t byte_offset = 0; if (!TryNumberToSize(isolate, *byte_offset_obj, &byte_offset)) { return false; } Handle<JSArrayBuffer> buffer(JSArrayBuffer::cast(data_view->buffer())); size_t data_view_byte_offset = NumberToSize(isolate, data_view->byte_offset()); size_t data_view_byte_length = NumberToSize(isolate, data_view->byte_length()); if (byte_offset + sizeof(T) > data_view_byte_length || byte_offset + sizeof(T) < byte_offset) { // overflow return false; } union Value { T data; uint8_t bytes[sizeof(T)]; }; Value value; size_t buffer_offset = data_view_byte_offset + byte_offset; DCHECK(NumberToSize(isolate, buffer->byte_length()) >= buffer_offset + sizeof(T)); uint8_t* source = static_cast<uint8_t*>(buffer->backing_store()) + buffer_offset; if (NeedToFlipBytes(is_little_endian)) { FlipBytes<sizeof(T)>(value.bytes, source); } else { CopyBytes<sizeof(T)>(value.bytes, source); } *result = value.data; return true; } template <typename T> static bool DataViewSetValue(Isolate* isolate, Handle<JSDataView> data_view, Handle<Object> byte_offset_obj, bool is_little_endian, T data) { size_t byte_offset = 0; if (!TryNumberToSize(isolate, *byte_offset_obj, &byte_offset)) { return false; } Handle<JSArrayBuffer> buffer(JSArrayBuffer::cast(data_view->buffer())); size_t data_view_byte_offset = NumberToSize(isolate, data_view->byte_offset()); size_t data_view_byte_length = NumberToSize(isolate, data_view->byte_length()); if (byte_offset + sizeof(T) > data_view_byte_length || byte_offset + sizeof(T) < byte_offset) { // overflow return false; } union Value { T data; uint8_t bytes[sizeof(T)]; }; Value value; value.data = data; size_t buffer_offset = data_view_byte_offset + byte_offset; DCHECK(NumberToSize(isolate, buffer->byte_length()) >= buffer_offset + sizeof(T)); uint8_t* target = static_cast<uint8_t*>(buffer->backing_store()) + buffer_offset; if (NeedToFlipBytes(is_little_endian)) { FlipBytes<sizeof(T)>(target, value.bytes); } else { CopyBytes<sizeof(T)>(target, value.bytes); } return true; } #define DATA_VIEW_GETTER(TypeName, Type, Converter) \ RUNTIME_FUNCTION(Runtime_DataViewGet##TypeName) { \ HandleScope scope(isolate); \ DCHECK(args.length() == 3); \ CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); \ CONVERT_NUMBER_ARG_HANDLE_CHECKED(offset, 1); \ CONVERT_BOOLEAN_ARG_CHECKED(is_little_endian, 2); \ Type result; \ if (DataViewGetValue(isolate, holder, offset, is_little_endian, \ &result)) { \ return *isolate->factory()->Converter(result); \ } else { \ THROW_NEW_ERROR_RETURN_FAILURE( \ isolate, \ NewRangeError(MessageTemplate::kInvalidDataViewAccessorOffset)); \ } \ } DATA_VIEW_GETTER(Uint8, uint8_t, NewNumberFromUint) DATA_VIEW_GETTER(Int8, int8_t, NewNumberFromInt) DATA_VIEW_GETTER(Uint16, uint16_t, NewNumberFromUint) DATA_VIEW_GETTER(Int16, int16_t, NewNumberFromInt) DATA_VIEW_GETTER(Uint32, uint32_t, NewNumberFromUint) DATA_VIEW_GETTER(Int32, int32_t, NewNumberFromInt) DATA_VIEW_GETTER(Float32, float, NewNumber) DATA_VIEW_GETTER(Float64, double, NewNumber) #undef DATA_VIEW_GETTER template <typename T> static T DataViewConvertValue(double value); template <> int8_t DataViewConvertValue<int8_t>(double value) { return static_cast<int8_t>(DoubleToInt32(value)); } template <> int16_t DataViewConvertValue<int16_t>(double value) { return static_cast<int16_t>(DoubleToInt32(value)); } template <> int32_t DataViewConvertValue<int32_t>(double value) { return DoubleToInt32(value); } template <> uint8_t DataViewConvertValue<uint8_t>(double value) { return static_cast<uint8_t>(DoubleToUint32(value)); } template <> uint16_t DataViewConvertValue<uint16_t>(double value) { return static_cast<uint16_t>(DoubleToUint32(value)); } template <> uint32_t DataViewConvertValue<uint32_t>(double value) { return DoubleToUint32(value); } template <> float DataViewConvertValue<float>(double value) { return static_cast<float>(value); } template <> double DataViewConvertValue<double>(double value) { return value; } #define DATA_VIEW_SETTER(TypeName, Type) \ RUNTIME_FUNCTION(Runtime_DataViewSet##TypeName) { \ HandleScope scope(isolate); \ DCHECK(args.length() == 4); \ CONVERT_ARG_HANDLE_CHECKED(JSDataView, holder, 0); \ CONVERT_NUMBER_ARG_HANDLE_CHECKED(offset, 1); \ CONVERT_NUMBER_ARG_HANDLE_CHECKED(value, 2); \ CONVERT_BOOLEAN_ARG_CHECKED(is_little_endian, 3); \ Type v = DataViewConvertValue<Type>(value->Number()); \ if (DataViewSetValue(isolate, holder, offset, is_little_endian, v)) { \ return isolate->heap()->undefined_value(); \ } else { \ THROW_NEW_ERROR_RETURN_FAILURE( \ isolate, \ NewRangeError(MessageTemplate::kInvalidDataViewAccessorOffset)); \ } \ } DATA_VIEW_SETTER(Uint8, uint8_t) DATA_VIEW_SETTER(Int8, int8_t) DATA_VIEW_SETTER(Uint16, uint16_t) DATA_VIEW_SETTER(Int16, int16_t) DATA_VIEW_SETTER(Uint32, uint32_t) DATA_VIEW_SETTER(Int32, int32_t) DATA_VIEW_SETTER(Float32, float) DATA_VIEW_SETTER(Float64, double) #undef DATA_VIEW_SETTER } // namespace internal } // namespace v8
; A096025: Numbers n such that (n+j) mod (2+j) = 1 for j from 0 to 6 and (n+7) mod 9 <> 1. ; 843,1683,3363,4203,5883,6723,8403,9243,10923,11763,13443,14283,15963,16803,18483,19323,21003,21843,23523,24363,26043,26883,28563,29403,31083,31923,33603,34443,36123,36963,38643,39483,41163,42003,43683 mul $0,6 div $0,4 mul $0,840 add $0,843
// // Generated by Microsoft (R) HLSL Shader Compiler 9.30.9200.20714 // // /// // // Input signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_Position 0 xyzw 0 POS float // TEXCOORD 0 xy 1 NONE float // COLOR 0 xyzw 2 NONE float xyzw // // // Output signature: // // Name Index Mask Register SysValue Format Used // -------------------- ----- ------ -------- -------- ------- ------ // SV_Target 0 xyzw 0 TARGET float xyzw // ps_4_0 dcl_input_ps linear v2.xyzw dcl_output o0.xyzw mov o0.xyzw, v2.xyzw ret // Approximately 2 instruction slots used
// Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2012 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "main.h" #include "db.h" #include "txdb.h" #include "init.h" #include "miner.h" #include "bitcoinrpc.h" using namespace json_spirit; using namespace std; Value getsubsidy(const Array& params, bool fHelp) { if (fHelp || params.size() > 1) throw runtime_error( "getsubsidy [nTarget]\n" "Returns proof-of-work subsidy value for the specified value of target."); return (uint64_t)GetProofOfWorkReward(0); } Value getmininginfo(const Array& params, bool fHelp) { if (fHelp || params.size() != 0) throw runtime_error( "getmininginfo\n" "Returns an object containing mining-related information."); uint64_t nMinWeight = 0, nMaxWeight = 0, nWeight = 0; pwalletMain->GetStakeWeight(*pwalletMain, nMinWeight, nMaxWeight, nWeight); Object obj, diff, weight; obj.push_back(Pair("blocks", (int)nBestHeight)); obj.push_back(Pair("currentblocksize",(uint64_t)nLastBlockSize)); obj.push_back(Pair("currentblocktx",(uint64_t)nLastBlockTx)); diff.push_back(Pair("proof-of-work", GetDifficulty())); diff.push_back(Pair("proof-of-stake", GetDifficulty(GetLastBlockIndex(pindexBest, true)))); diff.push_back(Pair("search-interval", (int)nLastCoinStakeSearchInterval)); obj.push_back(Pair("difficulty", diff)); obj.push_back(Pair("blockvalue", (uint64_t)GetProofOfWorkReward(0))); obj.push_back(Pair("netmhashps", GetPoWMHashPS())); obj.push_back(Pair("netstakeweight", GetPoSKernelPS())); obj.push_back(Pair("errors", GetWarnings("statusbar"))); obj.push_back(Pair("pooledtx", (uint64_t)mempool.size())); weight.push_back(Pair("minimum", (uint64_t)nMinWeight)); weight.push_back(Pair("maximum", (uint64_t)nMaxWeight)); weight.push_back(Pair("combined", (uint64_t)nWeight)); obj.push_back(Pair("stakeweight", weight)); obj.push_back(Pair("stakeinterest", (uint64_t)COIN_YEAR_REWARD)); obj.push_back(Pair("testnet", fTestNet)); return obj; } Value getstakinginfo(const Array& params, bool fHelp) { if (fHelp || params.size() != 0) throw runtime_error( "getstakinginfo\n" "Returns an object containing staking-related information."); uint64_t nMinWeight = 0, nMaxWeight = 0, nWeight = 0; pwalletMain->GetStakeWeight(*pwalletMain, nMinWeight, nMaxWeight, nWeight); uint64_t nNetworkWeight = GetPoSKernelPS(); bool staking = nLastCoinStakeSearchInterval && nWeight; int nExpectedTime = staking ? (nTargetSpacing * nNetworkWeight / nWeight) : -1; Object obj; obj.push_back(Pair("enabled", GetBoolArg("-staking", true))); obj.push_back(Pair("staking", staking)); obj.push_back(Pair("errors", GetWarnings("statusbar"))); obj.push_back(Pair("currentblocksize", (uint64_t)nLastBlockSize)); obj.push_back(Pair("currentblocktx", (uint64_t)nLastBlockTx)); obj.push_back(Pair("pooledtx", (uint64_t)mempool.size())); obj.push_back(Pair("difficulty", GetDifficulty(GetLastBlockIndex(pindexBest, true)))); obj.push_back(Pair("search-interval", (int)nLastCoinStakeSearchInterval)); obj.push_back(Pair("weight", (uint64_t)nWeight)); obj.push_back(Pair("netstakeweight", (uint64_t)nNetworkWeight)); obj.push_back(Pair("expectedtime", nExpectedTime)); return obj; } Value getworkex(const Array& params, bool fHelp) { if (fHelp || params.size() > 2) throw runtime_error( "getworkex [data, coinbase]\n" "If [data, coinbase] is not specified, returns extended work data.\n" ); if (vNodes.empty()) throw JSONRPCError(-9, "PantherCoin is not connected!"); if (IsInitialBlockDownload()) throw JSONRPCError(-10, "PantherCoin is downloading blocks..."); if (pindexBest->nHeight >= LAST_POW_BLOCK) throw JSONRPCError(RPC_MISC_ERROR, "No more PoW blocks"); typedef map<uint256, pair<CBlock*, CScript> > mapNewBlock_t; static mapNewBlock_t mapNewBlock; static vector<CBlock*> vNewBlock; static CReserveKey reservekey(pwalletMain); if (params.size() == 0) { // Update block static unsigned int nTransactionsUpdatedLast; static CBlockIndex* pindexPrev; static int64_t nStart; static CBlock* pblock; if (pindexPrev != pindexBest || (nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 60)) { if (pindexPrev != pindexBest) { // Deallocate old blocks since they're obsolete now mapNewBlock.clear(); BOOST_FOREACH(CBlock* pblock, vNewBlock) delete pblock; vNewBlock.clear(); } nTransactionsUpdatedLast = nTransactionsUpdated; pindexPrev = pindexBest; nStart = GetTime(); // Create new block pblock = CreateNewBlock(pwalletMain); if (!pblock) throw JSONRPCError(-7, "Out of memory"); vNewBlock.push_back(pblock); } // Update nTime pblock->nTime = max(pindexPrev->GetPastTimeLimit()+1, GetAdjustedTime()); pblock->nNonce = 0; // Update nExtraNonce static unsigned int nExtraNonce = 0; IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); // Save mapNewBlock[pblock->hashMerkleRoot] = make_pair(pblock, pblock->vtx[0].vin[0].scriptSig); // Prebuild hash buffers char pmidstate[32]; char pdata[128]; char phash1[64]; FormatHashBuffers(pblock, pmidstate, pdata, phash1); uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256(); CTransaction coinbaseTx = pblock->vtx[0]; std::vector<uint256> merkle = pblock->GetMerkleBranch(0); Object result; result.push_back(Pair("data", HexStr(BEGIN(pdata), END(pdata)))); result.push_back(Pair("target", HexStr(BEGIN(hashTarget), END(hashTarget)))); CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); ssTx << coinbaseTx; result.push_back(Pair("coinbase", HexStr(ssTx.begin(), ssTx.end()))); Array merkle_arr; BOOST_FOREACH(uint256 merkleh, merkle) { merkle_arr.push_back(HexStr(BEGIN(merkleh), END(merkleh))); } result.push_back(Pair("merkle", merkle_arr)); return result; } else { // Parse parameters vector<unsigned char> vchData = ParseHex(params[0].get_str()); vector<unsigned char> coinbase; if(params.size() == 2) coinbase = ParseHex(params[1].get_str()); if (vchData.size() != 128) throw JSONRPCError(-8, "Invalid parameter"); CBlock* pdata = (CBlock*)&vchData[0]; // Byte reverse for (int i = 0; i < 128/4; i++) ((unsigned int*)pdata)[i] = ByteReverse(((unsigned int*)pdata)[i]); // Get saved block if (!mapNewBlock.count(pdata->hashMerkleRoot)) return false; CBlock* pblock = mapNewBlock[pdata->hashMerkleRoot].first; pblock->nTime = pdata->nTime; pblock->nNonce = pdata->nNonce; if(coinbase.size() == 0) pblock->vtx[0].vin[0].scriptSig = mapNewBlock[pdata->hashMerkleRoot].second; else CDataStream(coinbase, SER_NETWORK, PROTOCOL_VERSION) >> pblock->vtx[0]; // FIXME - HACK! pblock->hashMerkleRoot = pblock->BuildMerkleTree(); return CheckWork(pblock, *pwalletMain, reservekey); } } Value getwork(const Array& params, bool fHelp) { if (fHelp || params.size() > 1) throw runtime_error( "getwork [data]\n" "If [data] is not specified, returns formatted hash data to work on:\n" " \"midstate\" : precomputed hash state after hashing the first half of the data (DEPRECATED)\n" // deprecated " \"data\" : block data\n" " \"hash1\" : formatted hash buffer for second hash (DEPRECATED)\n" // deprecated " \"target\" : little endian hash target\n" "If [data] is specified, tries to solve the block and returns true if it was successful."); if (vNodes.empty()) throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "PantherCoin is not connected!"); if (IsInitialBlockDownload()) throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "PantherCoin is downloading blocks..."); if (pindexBest->nHeight >= LAST_POW_BLOCK) throw JSONRPCError(RPC_MISC_ERROR, "No more PoW blocks"); typedef map<uint256, pair<CBlock*, CScript> > mapNewBlock_t; static mapNewBlock_t mapNewBlock; // FIXME: thread safety static vector<CBlock*> vNewBlock; static CReserveKey reservekey(pwalletMain); if (params.size() == 0) { // Update block static unsigned int nTransactionsUpdatedLast; static CBlockIndex* pindexPrev; static int64_t nStart; static CBlock* pblock; if (pindexPrev != pindexBest || (nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 60)) { if (pindexPrev != pindexBest) { // Deallocate old blocks since they're obsolete now mapNewBlock.clear(); BOOST_FOREACH(CBlock* pblock, vNewBlock) delete pblock; vNewBlock.clear(); } // Clear pindexPrev so future getworks make a new block, despite any failures from here on pindexPrev = NULL; // Store the pindexBest used before CreateNewBlock, to avoid races nTransactionsUpdatedLast = nTransactionsUpdated; CBlockIndex* pindexPrevNew = pindexBest; nStart = GetTime(); // Create new block pblock = CreateNewBlock(pwalletMain); if (!pblock) throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory"); vNewBlock.push_back(pblock); // Need to update only after we know CreateNewBlock succeeded pindexPrev = pindexPrevNew; } // Update nTime pblock->UpdateTime(pindexPrev); pblock->nNonce = 0; // Update nExtraNonce static unsigned int nExtraNonce = 0; IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); // Save mapNewBlock[pblock->hashMerkleRoot] = make_pair(pblock, pblock->vtx[0].vin[0].scriptSig); // Pre-build hash buffers char pmidstate[32]; char pdata[128]; char phash1[64]; FormatHashBuffers(pblock, pmidstate, pdata, phash1); uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256(); Object result; result.push_back(Pair("midstate", HexStr(BEGIN(pmidstate), END(pmidstate)))); // deprecated result.push_back(Pair("data", HexStr(BEGIN(pdata), END(pdata)))); result.push_back(Pair("hash1", HexStr(BEGIN(phash1), END(phash1)))); // deprecated result.push_back(Pair("target", HexStr(BEGIN(hashTarget), END(hashTarget)))); return result; } else { // Parse parameters vector<unsigned char> vchData = ParseHex(params[0].get_str()); if (vchData.size() != 128) throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter"); CBlock* pdata = (CBlock*)&vchData[0]; // Byte reverse for (int i = 0; i < 128/4; i++) ((unsigned int*)pdata)[i] = ByteReverse(((unsigned int*)pdata)[i]); // Get saved block if (!mapNewBlock.count(pdata->hashMerkleRoot)) return false; CBlock* pblock = mapNewBlock[pdata->hashMerkleRoot].first; pblock->nTime = pdata->nTime; pblock->nNonce = pdata->nNonce; pblock->vtx[0].vin[0].scriptSig = mapNewBlock[pdata->hashMerkleRoot].second; pblock->hashMerkleRoot = pblock->BuildMerkleTree(); return CheckWork(pblock, *pwalletMain, reservekey); } } Value getblocktemplate(const Array& params, bool fHelp) { if (fHelp || params.size() > 1) throw runtime_error( "getblocktemplate [params]\n" "Returns data needed to construct a block to work on:\n" " \"version\" : block version\n" " \"previousblockhash\" : hash of current highest block\n" " \"transactions\" : contents of non-coinbase transactions that should be included in the next block\n" " \"coinbaseaux\" : data that should be included in coinbase\n" " \"coinbasevalue\" : maximum allowable input to coinbase transaction, including the generation award and transaction fees\n" " \"target\" : hash target\n" " \"mintime\" : minimum timestamp appropriate for next block\n" " \"curtime\" : current timestamp\n" " \"mutable\" : list of ways the block template may be changed\n" " \"noncerange\" : range of valid nonces\n" " \"sigoplimit\" : limit of sigops in blocks\n" " \"sizelimit\" : limit of block size\n" " \"bits\" : compressed target of next block\n" " \"height\" : height of the next block\n" "See https://en.bitcoin.it/wiki/BIP_0022 for full specification."); std::string strMode = "template"; if (params.size() > 0) { const Object& oparam = params[0].get_obj(); const Value& modeval = find_value(oparam, "mode"); if (modeval.type() == str_type) strMode = modeval.get_str(); else if (modeval.type() == null_type) { /* Do nothing */ } else throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); } if (strMode != "template") throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); if (vNodes.empty()) throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "PantherCoin is not connected!"); if (IsInitialBlockDownload()) throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "PantherCoin is downloading blocks..."); if (pindexBest->nHeight >= LAST_POW_BLOCK) throw JSONRPCError(RPC_MISC_ERROR, "No more PoW blocks"); static CReserveKey reservekey(pwalletMain); // Update block static unsigned int nTransactionsUpdatedLast; static CBlockIndex* pindexPrev; static int64_t nStart; static CBlock* pblock; if (pindexPrev != pindexBest || (nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 5)) { // Clear pindexPrev so future calls make a new block, despite any failures from here on pindexPrev = NULL; // Store the pindexBest used before CreateNewBlock, to avoid races nTransactionsUpdatedLast = nTransactionsUpdated; CBlockIndex* pindexPrevNew = pindexBest; nStart = GetTime(); // Create new block if(pblock) { delete pblock; pblock = NULL; } pblock = CreateNewBlock(pwalletMain); if (!pblock) throw JSONRPCError(RPC_OUT_OF_MEMORY, "Out of memory"); // Need to update only after we know CreateNewBlock succeeded pindexPrev = pindexPrevNew; } // Update nTime pblock->UpdateTime(pindexPrev); pblock->nNonce = 0; Array transactions; map<uint256, int64_t> setTxIndex; int i = 0; CTxDB txdb("r"); BOOST_FOREACH (CTransaction& tx, pblock->vtx) { uint256 txHash = tx.GetHash(); setTxIndex[txHash] = i++; if (tx.IsCoinBase() || tx.IsCoinStake()) continue; Object entry; CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); ssTx << tx; entry.push_back(Pair("data", HexStr(ssTx.begin(), ssTx.end()))); entry.push_back(Pair("hash", txHash.GetHex())); MapPrevTx mapInputs; map<uint256, CTxIndex> mapUnused; bool fInvalid = false; if (tx.FetchInputs(txdb, mapUnused, false, false, mapInputs, fInvalid)) { entry.push_back(Pair("fee", (int64_t)(tx.GetValueIn(mapInputs) - tx.GetValueOut()))); Array deps; BOOST_FOREACH (MapPrevTx::value_type& inp, mapInputs) { if (setTxIndex.count(inp.first)) deps.push_back(setTxIndex[inp.first]); } entry.push_back(Pair("depends", deps)); int64_t nSigOps = tx.GetLegacySigOpCount(); nSigOps += tx.GetP2SHSigOpCount(mapInputs); entry.push_back(Pair("sigops", nSigOps)); } transactions.push_back(entry); } Object aux; aux.push_back(Pair("flags", HexStr(COINBASE_FLAGS.begin(), COINBASE_FLAGS.end()))); uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256(); static Array aMutable; if (aMutable.empty()) { aMutable.push_back("time"); aMutable.push_back("transactions"); aMutable.push_back("prevblock"); } Object result; result.push_back(Pair("version", pblock->nVersion)); result.push_back(Pair("previousblockhash", pblock->hashPrevBlock.GetHex())); result.push_back(Pair("transactions", transactions)); result.push_back(Pair("coinbaseaux", aux)); result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0].vout[0].nValue)); result.push_back(Pair("target", hashTarget.GetHex())); result.push_back(Pair("mintime", (int64_t)pindexPrev->GetPastTimeLimit()+1)); result.push_back(Pair("mutable", aMutable)); result.push_back(Pair("noncerange", "00000000ffffffff")); result.push_back(Pair("sigoplimit", (int64_t)MAX_BLOCK_SIGOPS)); result.push_back(Pair("sizelimit", (int64_t)MAX_BLOCK_SIZE)); result.push_back(Pair("curtime", (int64_t)pblock->nTime)); result.push_back(Pair("bits", strprintf("%08x", pblock->nBits))); result.push_back(Pair("height", (int64_t)(pindexPrev->nHeight+1))); return result; } Value submitblock(const Array& params, bool fHelp) { if (fHelp || params.size() < 1 || params.size() > 2) throw runtime_error( "submitblock <hex data> [optional-params-obj]\n" "[optional-params-obj] parameter is currently ignored.\n" "Attempts to submit new block to network.\n" "See https://en.bitcoin.it/wiki/BIP_0022 for full specification."); vector<unsigned char> blockData(ParseHex(params[0].get_str())); CDataStream ssBlock(blockData, SER_NETWORK, PROTOCOL_VERSION); CBlock block; try { ssBlock >> block; } catch (std::exception &e) { throw JSONRPCError(RPC_DESERIALIZATION_ERROR, "Block decode failed"); } bool fAccepted = ProcessBlock(NULL, &block); if (!fAccepted) return "rejected"; return Value::null; }
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r12 push %r9 push %rbp push %rcx push %rdi push %rdx push %rsi lea addresses_D_ht+0x1b454, %rsi lea addresses_UC_ht+0x8454, %rdi nop cmp %r12, %r12 mov $72, %rcx rep movsb nop sub $53960, %r9 lea addresses_UC_ht+0x171d4, %rsi lea addresses_D_ht+0x10854, %rdi nop nop cmp $14673, %rdx mov $44, %rcx rep movsw nop nop nop nop inc %r12 lea addresses_WC_ht+0x1ec54, %rsi nop xor $32693, %r11 mov $0x6162636465666768, %r12 movq %r12, (%rsi) sub $16731, %rcx lea addresses_A_ht+0x7454, %r12 sub %rdx, %rdx mov (%r12), %edi nop add %rcx, %rcx lea addresses_A_ht+0x6d44, %r11 nop nop nop dec %r12 movb (%r11), %dl nop nop nop nop nop xor $22550, %rsi lea addresses_normal_ht+0xceb4, %rsi lea addresses_normal_ht+0x3473, %rdi inc %rdx mov $71, %rcx rep movsl nop nop nop add %rsi, %rsi lea addresses_WC_ht+0x4574, %rsi lea addresses_A_ht+0xf154, %rdi nop nop nop nop dec %rdx mov $56, %rcx rep movsw nop nop nop nop nop inc %r12 lea addresses_WC_ht+0x2854, %rsi lea addresses_D_ht+0xcb0e, %rdi nop nop add $59511, %rbp mov $90, %rcx rep movsq nop xor $44283, %r12 lea addresses_normal_ht+0x3f4a, %r12 nop nop dec %rdi movl $0x61626364, (%r12) and $56868, %rdi lea addresses_A_ht+0x162d4, %rsi lea addresses_UC_ht+0x1c0b4, %rdi nop nop nop and $35739, %r9 mov $56, %rcx rep movsl dec %rcx pop %rsi pop %rdx pop %rdi pop %rcx pop %rbp pop %r9 pop %r12 pop %r11 ret .global s_faulty_load s_faulty_load: push %r12 push %r8 push %r9 push %rbp push %rbx push %rcx push %rdx // Store mov $0x3b8, %rdx nop nop nop add %rbp, %rbp movl $0x51525354, (%rdx) // Exception!!! mov (0), %rbp inc %r8 // Load lea addresses_PSE+0x14a36, %rdx nop nop sub $19278, %r12 mov (%rdx), %r8 nop nop xor $58585, %rbx // Store lea addresses_WC+0xa50, %rbp nop nop nop nop nop sub %rbx, %rbx movw $0x5152, (%rbp) nop nop nop nop nop sub $20312, %r8 // Store mov $0xc54, %rcx clflush (%rcx) nop nop nop nop xor $29915, %rbp mov $0x5152535455565758, %rdx movq %rdx, %xmm7 vmovups %ymm7, (%rcx) nop nop sub %r8, %r8 // Store mov $0x6d4, %r8 nop nop nop nop cmp $17979, %rdx mov $0x5152535455565758, %r9 movq %r9, %xmm7 movups %xmm7, (%r8) nop nop nop inc %rbp // Store lea addresses_WC+0x8854, %rbp nop nop nop cmp %r12, %r12 movb $0x51, (%rbp) nop nop nop and %rcx, %rcx // Store mov $0x51f, %rbp clflush (%rbp) nop nop nop nop cmp %r12, %r12 movl $0x51525354, (%rbp) nop nop cmp $11425, %rbx // Faulty Load lea addresses_normal+0x17454, %rbp nop nop inc %r12 vmovups (%rbp), %ymm4 vextracti128 $1, %ymm4, %xmm4 vpextrq $1, %xmm4, %r8 lea oracles, %rbp and $0xff, %r8 shlq $12, %r8 mov (%rbp,%r8,1), %r8 pop %rdx pop %rcx pop %rbx pop %rbp pop %r9 pop %r8 pop %r12 ret /* <gen_faulty_load> [REF] {'src': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 0, 'same': False, 'type': 'addresses_normal'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 2, 'same': False, 'type': 'addresses_P'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 1, 'same': False, 'type': 'addresses_PSE'}, 'OP': 'LOAD'} {'dst': {'NT': False, 'AVXalign': False, 'size': 2, 'congruent': 1, 'same': False, 'type': 'addresses_WC'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 6, 'same': False, 'type': 'addresses_P'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 16, 'congruent': 0, 'same': False, 'type': 'addresses_P'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 10, 'same': False, 'type': 'addresses_WC'}, 'OP': 'STOR'} {'dst': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 0, 'same': False, 'type': 'addresses_P'}, 'OP': 'STOR'} [Faulty Load] {'src': {'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0, 'same': True, 'type': 'addresses_normal'}, 'OP': 'LOAD'} <gen_prepare_buffer> {'src': {'congruent': 10, 'same': False, 'type': 'addresses_D_ht'}, 'dst': {'congruent': 11, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM'} {'src': {'congruent': 7, 'same': False, 'type': 'addresses_UC_ht'}, 'dst': {'congruent': 10, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM'} {'dst': {'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 7, 'same': False, 'type': 'addresses_WC_ht'}, 'OP': 'STOR'} {'src': {'NT': False, 'AVXalign': False, 'size': 4, 'congruent': 7, 'same': True, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'} {'src': {'NT': False, 'AVXalign': False, 'size': 1, 'congruent': 0, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'LOAD'} {'src': {'congruent': 5, 'same': False, 'type': 'addresses_normal_ht'}, 'dst': {'congruent': 0, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'REPM'} {'src': {'congruent': 4, 'same': False, 'type': 'addresses_WC_ht'}, 'dst': {'congruent': 6, 'same': False, 'type': 'addresses_A_ht'}, 'OP': 'REPM'} {'src': {'congruent': 10, 'same': False, 'type': 'addresses_WC_ht'}, 'dst': {'congruent': 1, 'same': False, 'type': 'addresses_D_ht'}, 'OP': 'REPM'} {'dst': {'NT': False, 'AVXalign': True, 'size': 4, 'congruent': 1, 'same': False, 'type': 'addresses_normal_ht'}, 'OP': 'STOR'} {'src': {'congruent': 6, 'same': False, 'type': 'addresses_A_ht'}, 'dst': {'congruent': 5, 'same': False, 'type': 'addresses_UC_ht'}, 'OP': 'REPM'} {'34': 21829} 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 34 */
SFX_Headers_1:: dbw -1, -1 ; padding SFX_Snare1_1:: dbw CH7, SFX_Snare1_1_Ch1 SFX_Snare2_1:: dbw CH7, SFX_Snare2_1_Ch1 SFX_Snare3_1:: dbw CH7, SFX_Snare3_1_Ch1 SFX_Snare4_1:: dbw CH7, SFX_Snare4_1_Ch1 SFX_Snare5_1:: dbw CH7, SFX_Snare5_1_Ch1 SFX_Triangle1_1:: dbw CH7, SFX_Triangle1_1_Ch1 SFX_Triangle2_1:: dbw CH7, SFX_Triangle2_1_Ch1 SFX_Snare6_1:: dbw CH7, SFX_Snare6_1_Ch1 SFX_Snare7_1:: dbw CH7, SFX_Snare7_1_Ch1 SFX_Snare8_1:: dbw CH7, SFX_Snare8_1_Ch1 SFX_Snare9_1:: dbw CH7, SFX_Snare9_1_Ch1 SFX_Cymbal1_1:: dbw CH7, SFX_Cymbal1_1_Ch1 SFX_Cymbal2_1:: dbw CH7, SFX_Cymbal2_1_Ch1 SFX_Cymbal3_1:: dbw CH7, SFX_Cymbal3_1_Ch1 SFX_Muted_Snare1_1:: dbw CH7, SFX_Muted_Snare1_1_Ch1 SFX_Triangle3_1:: dbw CH7, SFX_Triangle3_1_Ch1 SFX_Muted_Snare2_1:: dbw CH7, SFX_Muted_Snare2_1_Ch1 SFX_Muted_Snare3_1:: dbw CH7, SFX_Muted_Snare3_1_Ch1 SFX_Muted_Snare4_1:: dbw CH7, SFX_Muted_Snare4_1_Ch1 SFX_Cry00_1:: dbw ( $80 | CH4 ), SFX_Cry00_1_Ch1 dbw CH5, SFX_Cry00_1_Ch2 dbw CH7, SFX_Cry00_1_Ch3 SFX_Cry01_1:: dbw ( $80 | CH4 ), SFX_Cry01_1_Ch1 dbw CH5, SFX_Cry01_1_Ch2 dbw CH7, SFX_Cry01_1_Ch3 SFX_Cry02_1:: dbw ( $80 | CH4 ), SFX_Cry02_1_Ch1 dbw CH5, SFX_Cry02_1_Ch2 dbw CH7, SFX_Cry02_1_Ch3 SFX_Cry03_1:: dbw ( $80 | CH4 ), SFX_Cry03_1_Ch1 dbw CH5, SFX_Cry03_1_Ch2 dbw CH7, SFX_Cry03_1_Ch3 SFX_Cry04_1:: dbw ( $80 | CH4 ), SFX_Cry04_1_Ch1 dbw CH5, SFX_Cry04_1_Ch2 dbw CH7, SFX_Cry04_1_Ch3 SFX_Cry05_1:: dbw ( $80 | CH4 ), SFX_Cry05_1_Ch1 dbw CH5, SFX_Cry05_1_Ch2 dbw CH7, SFX_Cry05_1_Ch3 SFX_Cry06_1:: dbw ( $80 | CH4 ), SFX_Cry06_1_Ch1 dbw CH5, SFX_Cry06_1_Ch2 dbw CH7, SFX_Cry06_1_Ch3 SFX_Cry07_1:: dbw ( $80 | CH4 ), SFX_Cry07_1_Ch1 dbw CH5, SFX_Cry07_1_Ch2 dbw CH7, SFX_Cry07_1_Ch3 SFX_Cry08_1:: dbw ( $80 | CH4 ), SFX_Cry08_1_Ch1 dbw CH5, SFX_Cry08_1_Ch2 dbw CH7, SFX_Cry08_1_Ch3 SFX_Cry09_1:: dbw ( $80 | CH4 ), SFX_Cry09_1_Ch1 dbw CH5, SFX_Cry09_1_Ch2 dbw CH7, SFX_Cry09_1_Ch3 SFX_Cry0A_1:: dbw ( $80 | CH4 ), SFX_Cry0A_1_Ch1 dbw CH5, SFX_Cry0A_1_Ch2 dbw CH7, SFX_Cry0A_1_Ch3 SFX_Cry0B_1:: dbw ( $80 | CH4 ), SFX_Cry0B_1_Ch1 dbw CH5, SFX_Cry0B_1_Ch2 dbw CH7, SFX_Cry0B_1_Ch3 SFX_Cry0C_1:: dbw ( $80 | CH4 ), SFX_Cry0C_1_Ch1 dbw CH5, SFX_Cry0C_1_Ch2 dbw CH7, SFX_Cry0C_1_Ch3 SFX_Cry0D_1:: dbw ( $80 | CH4 ), SFX_Cry0D_1_Ch1 dbw CH5, SFX_Cry0D_1_Ch2 dbw CH7, SFX_Cry0D_1_Ch3 SFX_Cry0E_1:: dbw ( $80 | CH4 ), SFX_Cry0E_1_Ch1 dbw CH5, SFX_Cry0E_1_Ch2 dbw CH7, SFX_Cry0E_1_Ch3 SFX_Cry0F_1:: dbw ( $80 | CH4 ), SFX_Cry0F_1_Ch1 dbw CH5, SFX_Cry0F_1_Ch2 dbw CH7, SFX_Cry0F_1_Ch3 SFX_Cry10_1:: dbw ( $80 | CH4 ), SFX_Cry10_1_Ch1 dbw CH5, SFX_Cry10_1_Ch2 dbw CH7, SFX_Cry10_1_Ch3 SFX_Cry11_1:: dbw ( $80 | CH4 ), SFX_Cry11_1_Ch1 dbw CH5, SFX_Cry11_1_Ch2 dbw CH7, SFX_Cry11_1_Ch3 SFX_Cry12_1:: dbw ( $80 | CH4 ), SFX_Cry12_1_Ch1 dbw CH5, SFX_Cry12_1_Ch2 dbw CH7, SFX_Cry12_1_Ch3 SFX_Cry13_1:: dbw ( $80 | CH4 ), SFX_Cry13_1_Ch1 dbw CH5, SFX_Cry13_1_Ch2 dbw CH7, SFX_Cry13_1_Ch3 SFX_Cry14_1:: dbw ( $80 | CH4 ), SFX_Cry14_1_Ch1 dbw CH5, SFX_Cry14_1_Ch2 dbw CH7, SFX_Cry14_1_Ch3 SFX_Cry15_1:: dbw ( $80 | CH4 ), SFX_Cry15_1_Ch1 dbw CH5, SFX_Cry15_1_Ch2 dbw CH7, SFX_Cry15_1_Ch3 SFX_Cry16_1:: dbw ( $80 | CH4 ), SFX_Cry16_1_Ch1 dbw CH5, SFX_Cry16_1_Ch2 dbw CH7, SFX_Cry16_1_Ch3 SFX_Cry17_1:: dbw ( $80 | CH4 ), SFX_Cry17_1_Ch1 dbw CH5, SFX_Cry17_1_Ch2 dbw CH7, SFX_Cry17_1_Ch3 SFX_Cry18_1:: dbw ( $80 | CH4 ), SFX_Cry18_1_Ch1 dbw CH5, SFX_Cry18_1_Ch2 dbw CH7, SFX_Cry18_1_Ch3 SFX_Cry19_1:: dbw ( $80 | CH4 ), SFX_Cry19_1_Ch1 dbw CH5, SFX_Cry19_1_Ch2 dbw CH7, SFX_Cry19_1_Ch3 SFX_Cry1A_1:: dbw ( $80 | CH4 ), SFX_Cry1A_1_Ch1 dbw CH5, SFX_Cry1A_1_Ch2 dbw CH7, SFX_Cry1A_1_Ch3 SFX_Cry1B_1:: dbw ( $80 | CH4 ), SFX_Cry1B_1_Ch1 dbw CH5, SFX_Cry1B_1_Ch2 dbw CH7, SFX_Cry1B_1_Ch3 SFX_Cry1C_1:: dbw ( $80 | CH4 ), SFX_Cry1C_1_Ch1 dbw CH5, SFX_Cry1C_1_Ch2 dbw CH7, SFX_Cry1C_1_Ch3 SFX_Cry1D_1:: dbw ( $80 | CH4 ), SFX_Cry1D_1_Ch1 dbw CH5, SFX_Cry1D_1_Ch2 dbw CH7, SFX_Cry1D_1_Ch3 SFX_Cry1E_1:: dbw ( $80 | CH4 ), SFX_Cry1E_1_Ch1 dbw CH5, SFX_Cry1E_1_Ch2 dbw CH7, SFX_Cry1E_1_Ch3 SFX_Cry1F_1:: dbw ( $80 | CH4 ), SFX_Cry1F_1_Ch1 dbw CH5, SFX_Cry1F_1_Ch2 dbw CH7, SFX_Cry1F_1_Ch3 SFX_Cry20_1:: dbw ( $80 | CH4 ), SFX_Cry20_1_Ch1 dbw CH5, SFX_Cry20_1_Ch2 dbw CH7, SFX_Cry20_1_Ch3 SFX_Cry21_1:: dbw ( $80 | CH4 ), SFX_Cry21_1_Ch1 dbw CH5, SFX_Cry21_1_Ch2 dbw CH7, SFX_Cry21_1_Ch3 SFX_Cry22_1:: dbw ( $80 | CH4 ), SFX_Cry22_1_Ch1 dbw CH5, SFX_Cry22_1_Ch2 dbw CH7, SFX_Cry22_1_Ch3 SFX_Cry23_1:: dbw ( $80 | CH4 ), SFX_Cry23_1_Ch1 dbw CH5, SFX_Cry23_1_Ch2 dbw CH7, SFX_Cry23_1_Ch3 SFX_Cry24_1:: dbw ( $80 | CH4 ), SFX_Cry24_1_Ch1 dbw CH5, SFX_Cry24_1_Ch2 dbw CH7, SFX_Cry24_1_Ch3 SFX_Cry25_1:: dbw ( $80 | CH4 ), SFX_Cry25_1_Ch1 dbw CH5, SFX_Cry25_1_Ch2 dbw CH7, SFX_Cry25_1_Ch3 SFX_Get_Item1_1:: dbw ( $80 | CH4 ), SFX_Get_Item1_1_Ch1 dbw CH5, SFX_Get_Item1_1_Ch2 dbw CH6, SFX_Get_Item1_1_Ch3 SFX_Get_Item2_1:: dbw ( $80 | CH4 ), SFX_Get_Item2_1_Ch1 dbw CH5, SFX_Get_Item2_1_Ch2 dbw CH6, SFX_Get_Item2_1_Ch3 SFX_Tink_1:: dbw CH4, SFX_Tink_1_Ch1 SFX_Heal_HP_1:: dbw CH4, SFX_Heal_HP_1_Ch1 SFX_Heal_Ailment_1:: dbw CH4, SFX_Heal_Ailment_1_Ch1 SFX_Start_Menu_1:: dbw CH7, SFX_Start_Menu_1_Ch1 SFX_Press_AB_1:: dbw CH4, SFX_Press_AB_1_Ch1 SFX_Pokedex_Rating_1:: dbw ( $80 | CH4 ), SFX_Pokedex_Rating_1_Ch1 dbw CH5, SFX_Pokedex_Rating_1_Ch2 dbw CH6, SFX_Pokedex_Rating_1_Ch3 SFX_Get_Key_Item_1:: dbw ( $80 | CH4 ), SFX_Get_Key_Item_1_Ch1 dbw CH5, SFX_Get_Key_Item_1_Ch2 dbw CH6, SFX_Get_Key_Item_1_Ch3 SFX_Poisoned_1:: dbw CH4, SFX_Poisoned_1_Ch1 SFX_Trade_Machine_1:: dbw CH4, SFX_Trade_Machine_1_Ch1 SFX_Turn_On_PC_1:: dbw CH4, SFX_Turn_On_PC_1_Ch1 SFX_Turn_Off_PC_1:: dbw CH4, SFX_Turn_Off_PC_1_Ch1 SFX_Enter_PC_1:: dbw CH4, SFX_Enter_PC_1_Ch1 SFX_Shrink_1:: dbw CH4, SFX_Shrink_1_Ch1 SFX_Switch_1:: dbw CH4, SFX_Switch_1_Ch1 SFX_Healing_Machine_1:: dbw CH4, SFX_Healing_Machine_1_Ch1 SFX_Teleport_Exit1_1:: dbw CH4, SFX_Teleport_Exit1_1_Ch1 SFX_Teleport_Enter1_1:: dbw CH4, SFX_Teleport_Enter1_1_Ch1 SFX_Teleport_Exit2_1:: dbw CH4, SFX_Teleport_Exit2_1_Ch1 SFX_Ledge_1:: dbw CH4, SFX_Ledge_1_Ch1 SFX_Teleport_Enter2_1:: dbw CH7, SFX_Teleport_Enter2_1_Ch1 SFX_Fly_1:: dbw CH7, SFX_Fly_1_Ch1 SFX_Denied_1:: dbw ( $40 | CH4 ), SFX_Denied_1_Ch1 dbw CH5, SFX_Denied_1_Ch2 SFX_Arrow_Tiles_1:: dbw CH4, SFX_Arrow_Tiles_1_Ch1 SFX_Push_Boulder_1:: dbw CH7, SFX_Push_Boulder_1_Ch1 SFX_SS_Anne_Horn_1:: dbw ( $40 | CH4 ), SFX_SS_Anne_Horn_1_Ch1 dbw CH5, SFX_SS_Anne_Horn_1_Ch2 SFX_Withdraw_Deposit_1:: dbw CH4, SFX_Withdraw_Deposit_1_Ch1 SFX_Cut_1:: dbw CH7, SFX_Cut_1_Ch1 SFX_Go_Inside_1:: dbw CH7, SFX_Go_Inside_1_Ch1 SFX_Swap_1:: dbw ( $40 | CH4 ), SFX_Swap_1_Ch1 dbw CH5, SFX_Swap_1_Ch2 SFX_59_1:: dbw ( $40 | CH4 ), SFX_59_1_Ch1 dbw CH5, SFX_59_1_Ch2 SFX_Purchase_1:: dbw ( $40 | CH4 ), SFX_Purchase_1_Ch1 dbw CH5, SFX_Purchase_1_Ch2 SFX_Collision_1:: dbw CH4, SFX_Collision_1_Ch1 SFX_Go_Outside_1:: dbw CH7, SFX_Go_Outside_1_Ch1 SFX_Save_1:: dbw ( $40 | CH4 ), SFX_Save_1_Ch1 dbw CH5, SFX_Save_1_Ch2 SFX_Pokeflute:: dbw CH2, SFX_Pokeflute_Ch1 SFX_Safari_Zone_PA:: dbw CH4, SFX_Safari_Zone_PA_Ch1
/** * @file * @brief Item creation routines. **/ #include "AppHdr.h" #include "makeitem.h" #include <algorithm> #include "art-enum.h" // unrand -> magic staff silliness #include "artefact.h" #include "colour.h" #include "describe.h" #include "dungeon.h" #include "evoke.h" #include "item-name.h" #include "item-prop.h" #include "item-status-flag-type.h" #include "items.h" #include "libutil.h" // map_find #include "randbook.h" #include "spl-book.h" #include "state.h" #include "stepdown.h" #include "stringutil.h" int create_item_named(string name, coord_def pos, string *error) { trim_string(name); item_list ilist; const string err = ilist.add_item(name, false); if (!err.empty()) { if (error) *error = err; return NON_ITEM; } item_spec ispec = ilist.get_item(0); int item = dgn_place_item(ispec, pos); if (item != NON_ITEM) link_items(); else if (error) *error = "Failed to create item '" + name + "'"; return item; } bool got_curare_roll(const int item_level) { return one_chance_in(item_level > 27 ? 6 : item_level < 2 ? 15 : (364 - 7 * item_level) / 25); } /// A mapping from randomly-described object types to their per-game descript static map<object_class_type, item_description_type> _type_to_idesc = { {OBJ_WANDS, IDESC_WANDS}, {OBJ_POTIONS, IDESC_POTIONS}, {OBJ_JEWELLERY, IDESC_RINGS}, {OBJ_SCROLLS, IDESC_SCROLLS}, {OBJ_STAVES, IDESC_STAVES}, }; /** * Initialize the randomized appearance of a given item. * * For e.g. wand names, potions colors, helmet tiles... * * XXX: could this be moved into a constructor or reset method...? * * @param item The item to have its appearance initialized. */ void item_colour(item_def &item) { // Compute random tile/colour choice. item.rnd = 1 + random2(255); // reserve 0 for uninitialized // reserve the high bit for marking 1 in 10 books "visually special" if (item.base_type == OBJ_BOOKS) { if (one_chance_in(10)) item.rnd |= 128; else item.rnd = 1 + random2(127); // can't just trim the high bit, // since it might be the only set bit } if (is_unrandom_artefact(item)) return; // don't stomp on item.special! // initialize item appearance. // we don't actually *need* to store this now, but we *do* need to store // it in appearance at some point, since sub_type isn't public information // for un-id'd items, and therefore can't be used to do a lookup at the // time item names/colours are calculated. // it would probably be better to store this at the time that item_info is // generated (get_item_info), but that requires some save compat work (and // would be wrong if we ever try to get item colour/names directly...?) // possibly a todo for a later date. if (auto idesc = map_find(_type_to_idesc, item.base_type)) item.subtype_rnd = you.item_description[*idesc][item.sub_type]; } // Does Xom consider an item boring? static bool _is_boring_item(int type, int sub_type) { switch (type) { case OBJ_SCROLLS: // These scrolls increase knowledge and thus reduce risk. switch (sub_type) { case SCR_REMOVE_CURSE: case SCR_IDENTIFY: case SCR_MAGIC_MAPPING: return true; default: break; } break; case OBJ_JEWELLERY: return sub_type == AMU_NOTHING; default: break; } return false; } static weapon_type _determine_weapon_subtype(int item_level) { if (item_level > 6 && one_chance_in(30) && x_chance_in_y(10 + item_level, 100)) { return random_choose(WPN_LAJATANG, WPN_FUSTIBALUS, WPN_TRIPLE_CROSSBOW, WPN_DEMON_WHIP, WPN_DEMON_BLADE, WPN_DEMON_TRIDENT, WPN_DOUBLE_SWORD, WPN_EVENINGSTAR, WPN_EXECUTIONERS_AXE, WPN_QUICK_BLADE, WPN_TRIPLE_SWORD); } else if (x_chance_in_y(item_level, 20)) { // Pick a weapon based on rarity. while (true) { const int wpntype = random2(NUM_WEAPONS); if (x_chance_in_y(weapon_rarity(wpntype), 10)) return static_cast<weapon_type>(wpntype); } } else if (x_chance_in_y(item_level, item_level+7)) { return random_choose(WPN_QUARTERSTAFF, WPN_FALCHION, WPN_LONG_SWORD, WPN_WAR_AXE, WPN_TRIDENT, WPN_FLAIL, WPN_RAPIER); } else { return random_choose(WPN_HUNTING_SLING, WPN_SPEAR, WPN_HAND_AXE, WPN_MACE, // Not worth _weighted for one doubled type. WPN_DAGGER, WPN_DAGGER, WPN_CLUB, WPN_WHIP, WPN_SHORT_SWORD); } } static bool _try_make_item_unrand(item_def& item, int force_type, int agent) { if (player_in_branch(BRANCH_PANDEMONIUM) && agent == NO_AGENT) return false; int idx = find_okay_unrandart(item.base_type, force_type, player_in_branch(BRANCH_ABYSS) && agent == NO_AGENT); if (idx != -1 && make_item_unrandart(item, idx)) return true; return false; } static bool _weapon_disallows_randart(int sub_type) { // Clubs are never randarts. return sub_type == WPN_CLUB; } // Return whether we made an artefact. static bool _try_make_weapon_artefact(item_def& item, int force_type, int item_level, bool force_randart, int agent) { if (item_level > 2 && x_chance_in_y(101 + item_level * 3, 4000) || force_randart) { // Make a randart or unrandart. // 1 in 20 randarts are unrandarts. if (one_chance_in(item_level == ISPEC_GOOD_ITEM ? 7 : 20) && !force_randart) { if (_try_make_item_unrand(item, force_type, agent)) return true; } if (_weapon_disallows_randart(item.sub_type)) return false; // Mean enchantment +6. item.plus = 12 - biased_random2(7,2); item.plus -= biased_random2(7,2); item.plus -= biased_random2(7,2); bool cursed = false; if (one_chance_in(5)) { cursed = true; item.plus = 3 - random2(6); } else if (item.plus < 0 && !one_chance_in(3)) cursed = true; // On weapons, an enchantment of less than 0 is never viable. item.plus = max(static_cast<int>(item.plus), random2(2)); // The rest are normal randarts. make_item_randart(item); if (cursed) do_curse_item(item); return true; } return false; } /** * The number of times to try finding a brand for a given item. * * Result may vary from call to call. */ static int _num_brand_tries(const item_def& item, int item_level) { if (item_level >= ISPEC_GIFT) return 5; if (is_demonic(item) || x_chance_in_y(101 + item_level, 300)) return 1; return 0; } brand_type determine_weapon_brand(const item_def& item, int item_level) { // Forced ego. if (item.brand != 0) return static_cast<brand_type>(item.brand); const weapon_type wpn_type = static_cast<weapon_type>(item.sub_type); const int tries = _num_brand_tries(item, item_level); brand_type rc = SPWPN_NORMAL; for (int count = 0; count < tries && rc == SPWPN_NORMAL; ++count) rc = choose_weapon_brand(wpn_type); ASSERT(is_weapon_brand_ok(item.sub_type, rc, true)); return rc; } // Reject brands which are outright bad for the item. Unorthodox combinations // are ok, since they can happen on randarts. bool is_weapon_brand_ok(int type, int brand, bool /*strict*/) { item_def item; item.base_type = OBJ_WEAPONS; item.sub_type = type; if (brand <= SPWPN_NORMAL) return true; if (type == WPN_QUICK_BLADE && brand == SPWPN_SPEED) return false; switch ((brand_type)brand) { // Universal brands. case SPWPN_NORMAL: case SPWPN_VENOM: case SPWPN_PROTECTION: case SPWPN_SPEED: case SPWPN_VORPAL: case SPWPN_CHAOS: case SPWPN_HOLY_WRATH: case SPWPN_ELECTROCUTION: case SPWPN_FLAMING: case SPWPN_FREEZING: case SPWPN_SILVER: case SPWPN_ACID: case SPWPN_REACHING: break; // Melee-only brands. case SPWPN_DRAINING: case SPWPN_VAMPIRISM: case SPWPN_PAIN: case SPWPN_DISTORTION: case SPWPN_ANTIMAGIC: case SPWPN_REAPING: // only exists on Sword of Zonguldrok case SPWPN_PACIFING: case SPWPN_SLUGGISH: case SPWPN_SLIMIFYING: if (is_range_weapon(item)) return false; break; // Ranged-only brands. case SPWPN_PENETRATION: //case SPWPN_ACID: // Only exists on Punk if (!is_range_weapon(item)) return false; break; #if TAG_MAJOR_VERSION == 34 // Removed brands. case SPWPN_RETURNING: case SPWPN_ORC_SLAYING: case SPWPN_FLAME: case SPWPN_FROST: case SPWPN_EVASION: return false; #endif case SPWPN_CONFUSE: case SPWPN_FORBID_BRAND: case SPWPN_DEBUG_RANDART: case NUM_SPECIAL_WEAPONS: case NUM_REAL_SPECIAL_WEAPONS: die("invalid brand %d on weapon %d (%s)", brand, type, item.name(DESC_PLAIN).c_str()); break; } return true; } static void _roll_weapon_type(item_def& item, int item_level) { for (int i = 0; i < 1000; ++i) { item.sub_type = _determine_weapon_subtype(item_level); if (is_weapon_brand_ok(item.sub_type, item.brand, true)) return; } item.brand = SPWPN_NORMAL; // fall back to no brand } /// Plusses for a non-artefact weapon with positive plusses. int determine_nice_weapon_plusses(int item_level) { const int chance = (item_level >= ISPEC_GIFT ? 200 : item_level); // Odd-looking, but this is how the algorithm compacts {dlb}. int plus = 0; for (int i = 0; i < 4; ++i) { plus += random2(3); if (random2(425) > 35 + chance) break; } return plus; } static void _generate_weapon_item(item_def& item, bool allow_uniques, int force_type, int item_level, int agent = NO_AGENT) { // Determine weapon type. if (force_type != OBJ_RANDOM) item.sub_type = force_type; else _roll_weapon_type(item, item_level); // Fall back to an ordinary item if randarts not allowed for this type. if (item_level == ISPEC_RANDART && _weapon_disallows_randart(item.sub_type)) item_level = ISPEC_GOOD_ITEM; // Forced randart. if (item_level == ISPEC_RANDART) { int ego = item.brand; for (int i = 0; i < 100; ++i) if (_try_make_weapon_artefact(item, force_type, 0, true, agent) && is_artefact(item)) { if (ego > SPWPN_NORMAL) item.props[ARTEFACT_PROPS_KEY].get_vector()[ARTP_BRAND].get_short() = ego; if (randart_is_bad(item)) // recheck, the brand changed { force_type = item.sub_type; item.clear(); item.quantity = 1; item.base_type = OBJ_WEAPONS; item.sub_type = force_type; continue; } return; } // fall back to an ordinary item item_level = ISPEC_GOOD_ITEM; } // If we make the unique roll, no further generation necessary. if (allow_uniques && _try_make_weapon_artefact(item, force_type, item_level, false, agent)) { return; } ASSERT(!is_artefact(item)); // Artefacts handled, let's make a normal item. const bool force_good = item_level >= ISPEC_GIFT; const bool forced_ego = item.brand > 0; const bool no_brand = item.brand == SPWPN_FORBID_BRAND; if (no_brand) set_item_ego_type(item, OBJ_WEAPONS, SPWPN_NORMAL); // If it's forced to be a good item, reroll clubs. while (force_good && force_type == OBJ_RANDOM && item.sub_type == WPN_CLUB) _roll_weapon_type(item, item_level); item.plus = 0; if (item_level < 0) { // Thoroughly damaged, could had been good once. if (!no_brand && (forced_ego || one_chance_in(4))) { // Brand is set as for "good" items. set_item_ego_type(item, OBJ_WEAPONS, determine_weapon_brand(item, 2 + 2 * env.absdepth0)); } item.plus -= 1 + random2(3); if (item_level == ISPEC_BAD) do_curse_item(item); } else if ((force_good || is_demonic(item) || forced_ego || x_chance_in_y(51 + item_level, 200)) && (!item.is_mundane() || force_good)) { // Make a better item (possibly ego). if (!no_brand) { set_item_ego_type(item, OBJ_WEAPONS, determine_weapon_brand(item, item_level)); } // if acquired item still not ego... enchant it up a bit. if (force_good && item.brand == SPWPN_NORMAL) item.plus += 2 + random2(3); item.plus += determine_nice_weapon_plusses(item_level); // squash boring items. if (!force_good && item.brand == SPWPN_NORMAL && item.plus < 3) item.plus = 0; } else { if (one_chance_in(12)) { // Make a cursed item. do_curse_item(item); item.plus -= random2(4); set_item_ego_type(item, OBJ_WEAPONS, SPWPN_NORMAL); } } } // Remember to update the code in is_missile_brand_ok if adding or altering // brands that are applied to missiles. {due} static special_missile_type _determine_missile_brand(const item_def& item, int item_level) { // Forced ego. if (item.brand != 0) return static_cast<special_missile_type>(item.brand); special_missile_type rc = SPMSL_NORMAL; // Weight of SPMSL_NORMAL // Gifts from Trog/Oka can be unbranded boomerangs/javelins // but not poisoned darts int nw = item_level >= ISPEC_GOOD_ITEM ? 0 : item_level == ISPEC_GIFT ? 120 : random2(2000 - 55 * item_level); // Weight of SPMSL_POISONED int pw = item_level >= ISPEC_GIFT ? 0 : random2(2000 - 55 * item_level); switch (item.sub_type) { case MI_THROWING_NET: case MI_STONE: case MI_LARGE_ROCK: case MI_SLING_BULLET: case MI_ARROW: case MI_BOLT: rc = SPMSL_NORMAL; break; case MI_DART: // Curare is special cased, all the others aren't. if (got_curare_roll(item_level)) { rc = SPMSL_CURARE; break; } rc = random_choose_weighted(60, SPMSL_BLINDING, 20, SPMSL_FRENZY, pw, SPMSL_POISONED); break; case MI_JAVELIN: rc = random_choose_weighted(90, SPMSL_SILVER, nw, SPMSL_NORMAL); break; case MI_BOOMERANG: rc = random_choose_weighted(30, SPMSL_SILVER, 30, SPMSL_DISPERSAL, nw, SPMSL_NORMAL); break; } ASSERT(is_missile_brand_ok(item.sub_type, rc, true)); return rc; } bool is_missile_brand_ok(int type, int brand, bool strict) { // Launcher ammo can never be branded. if ((type == MI_STONE || type == MI_LARGE_ROCK || type == MI_SLING_BULLET || type == MI_ARROW || type == MI_BOLT) && brand != SPMSL_NORMAL && strict) { return false; } // Never generates, only used for chaos-branded missiles. if (brand == SPMSL_FLAME || brand == SPMSL_FROST) return false; // In contrast, darts should always be branded. // And all of these brands save poison are unique to darts. switch (brand) { case SPMSL_POISONED: if (type == MI_DART) return true; break; case SPMSL_CURARE: case SPMSL_PARALYSIS: case SPMSL_FRENZY: return type == MI_DART; case SPMSL_BLINDING: // possible on ex-pies return type == MI_DART || (type == MI_BOOMERANG && !strict); default: if (type == MI_DART) return false; } // Everything else doesn't matter. if (brand == SPMSL_NORMAL) return true; // In non-strict mode, everything other than darts is mostly ok. if (!strict) return true; // Not a missile? if (type == 0) return true; // Specifics switch (brand) { case SPMSL_POISONED: return false; case SPMSL_CHAOS: return type == MI_BOOMERANG || type == MI_JAVELIN; case SPMSL_DISPERSAL: return type == MI_BOOMERANG; case SPMSL_SILVER: return type == MI_JAVELIN || type == MI_BOOMERANG; default: break; } // Assume no, if we've gotten this far. return false; } static void _generate_missile_item(item_def& item, int force_type, int item_level) { const bool no_brand = (item.brand == SPMSL_FORBID_BRAND); if (no_brand) item.brand = SPMSL_NORMAL; item.plus = 0; if (force_type != OBJ_RANDOM) item.sub_type = force_type; else { item.sub_type = random_choose_weighted(50, MI_STONE, 20, MI_ARROW, 12, MI_BOLT, 12, MI_SLING_BULLET, 10, MI_DART, 3, MI_BOOMERANG, 2, MI_JAVELIN, 1, MI_THROWING_NET, 1, MI_LARGE_ROCK); } // No fancy rocks -- break out before we get to special stuff. if (item.sub_type == MI_LARGE_ROCK) { item.quantity = 2 + random2avg(5,2); return; } else if (item.sub_type == MI_STONE) { item.quantity = 1 + random2(7); // sequence points for random2 item.quantity += random2(10); item.quantity += random2(12); item.quantity += random2(10); return; } else if (item.sub_type == MI_THROWING_NET) // no fancy nets, either { item.quantity = 1 + one_chance_in(4); // and only one, rarely two return; } if (!no_brand) { set_item_ego_type(item, OBJ_MISSILES, _determine_missile_brand(item, item_level)); } // Reduced quantity if special. if (item.sub_type == MI_JAVELIN || item.sub_type == MI_BOOMERANG || (item.sub_type == MI_DART && get_ammo_brand(item) != SPMSL_POISONED) || get_ammo_brand(item) == SPMSL_RETURNING) { item.quantity = random_range(2, 8); } else { item.quantity = 1 + random2(7); // sequence points for random2 item.quantity += random2(10); item.quantity += random2(10); if (get_ammo_brand(item) == SPMSL_NORMAL) item.quantity += random2(12); } if (item.sub_type == MI_ARROW || item.sub_type == MI_BOLT || item.sub_type == MI_SLING_BULLET) { item.quantity *= 3; } } static bool _armour_disallows_randart(int sub_type) { // Scarves are never randarts. return sub_type == ARM_SCARF; } static bool _try_make_armour_artefact(item_def& item, int force_type, int item_level, bool force_randart, int agent) { if (item_level > 2 && x_chance_in_y(101 + item_level * 3, 4000) || force_randart) { // Make a randart or unrandart. // 1 in 20 randarts are unrandarts. if (one_chance_in(item_level == ISPEC_GOOD_ITEM ? 7 : 20) && !force_randart) { if (_try_make_item_unrand(item, force_type, agent)) return true; } if (_armour_disallows_randart(item.sub_type)) return false; // The rest are normal randarts. // 10% of boots become barding. if (item.sub_type == ARM_BOOTS && one_chance_in(10)) { item.sub_type = random_choose(ARM_NAGA_BARDING, ARM_CENTAUR_BARDING); } // Determine enchantment and cursedness. if (one_chance_in(5)) { do_curse_item(item); item.plus = 0; } else { int max_plus = armour_max_enchant(item); item.plus = random2(max_plus + 1); if (one_chance_in(5)) item.plus += random2(max_plus + 6) / 2; if (one_chance_in(6)) item.plus -= random2(max_plus + 6); if (item.plus < 0 && !one_chance_in(3)) do_curse_item(item); } // On body armour, an enchantment of less than 0 is never viable. if (get_armour_slot(item) == EQ_BODY_ARMOUR) item.plus = max(static_cast<int>(item.plus), random2(2)); // Needs to be done after the barding chance else we get randart // bardings named Boots of xy. make_item_randart(item); // Don't let unenchantable armour get minuses. if (!armour_is_enchantable(item)) item.plus = 0; return true; } return false; } /** * Generate an appropriate ego for a type of armour. * * @param item The type of armour in question. * @return An ego appropriate to the item type. * May be SPARM_NORMAL. */ static special_armour_type _generate_armour_type_ego(armour_type type) { // TODO: move this into data switch (type) { case ARM_LARGE_SHIELD: return random_choose_weighted(1, SPARM_RESISTANCE, 3, SPARM_FIRE_RESISTANCE, 3, SPARM_COLD_RESISTANCE, 3, SPARM_POISON_RESISTANCE, 3, SPARM_POSITIVE_ENERGY, 6, SPARM_BUNKER, 6, SPARM_REFLECTION, 12, SPARM_PROTECTION); case ARM_SHIELD: case ARM_BUCKLER: return random_choose_weighted(1, SPARM_RESISTANCE, 3, SPARM_FIRE_RESISTANCE, 3, SPARM_COLD_RESISTANCE, 3, SPARM_POISON_RESISTANCE, 3, SPARM_POSITIVE_ENERGY, 6, SPARM_REFLECTION, 12, SPARM_PROTECTION); case ARM_SCARF: return random_choose_weighted(1, SPARM_SPIRIT_SHIELD, 1, SPARM_RESISTANCE, 1, SPARM_REPULSION, 1, SPARM_CLOUD_IMMUNE); case ARM_CLOAK: return random_choose(SPARM_POISON_RESISTANCE, SPARM_INVISIBILITY, SPARM_MAGIC_RESISTANCE, SPARM_STEALTH, SPARM_PRESERVATION); case ARM_HAT: return random_choose_weighted(7, SPARM_NORMAL, 3, SPARM_MAGIC_RESISTANCE, 2, SPARM_INTELLIGENCE, 2, SPARM_SEE_INVISIBLE); case ARM_HELMET: return random_choose(SPARM_SEE_INVISIBLE, SPARM_INTELLIGENCE); case ARM_GLOVES: return random_choose(SPARM_DEXTERITY, SPARM_STRENGTH, SPARM_ARCHERY); case ARM_BOOTS: return random_choose(SPARM_RUNNING, SPARM_FLYING, SPARM_STEALTH); case ARM_NAGA_BARDING: case ARM_CENTAUR_BARDING: return random_choose(SPARM_FLYING, SPARM_STEALTH, SPARM_COLD_RESISTANCE, SPARM_FIRE_RESISTANCE); case ARM_ROBE: return random_choose_weighted(1, SPARM_RESISTANCE, 1, SPARM_ARCHMAGI, 2, SPARM_NORMAL, 2, SPARM_COLD_RESISTANCE, 2, SPARM_FIRE_RESISTANCE, 2, SPARM_POSITIVE_ENERGY, 4, SPARM_MAGIC_RESISTANCE); case ARM_PLATE_ARMOUR: return random_choose_weighted(26, SPARM_FIRE_RESISTANCE, 26, SPARM_COLD_RESISTANCE, 19, SPARM_POISON_RESISTANCE, 15, SPARM_MAGIC_RESISTANCE, 7, SPARM_POSITIVE_ENERGY, 7, SPARM_PONDEROUSNESS); // other body armour default: break; } // dragon/troll armour, animal hides, and crystal plate are never generated // with egos. (unless they're artefacts, but those aren't handled here.) // TODO: deduplicate with armour_is_special() (same except for animal skin) if (armour_type_is_hide(type) || type == ARM_ANIMAL_SKIN || type == ARM_CRYSTAL_PLATE_ARMOUR) { return SPARM_NORMAL; } return random_choose_weighted(7, SPARM_FIRE_RESISTANCE, 7, SPARM_COLD_RESISTANCE, 5, SPARM_POISON_RESISTANCE, 4, SPARM_MAGIC_RESISTANCE, 2, SPARM_POSITIVE_ENERGY); } /** * Generate an appropriate ego for a piece of armour. * * @param item The item in question. * @return The item's current ego, if it already has one; * otherwise, an ego appropriate to the item. * May be SPARM_NORMAL. */ static special_armour_type _generate_armour_ego(const item_def& item) { if (item.brand != SPARM_NORMAL) return static_cast<special_armour_type>(item.brand); const special_armour_type ego = _generate_armour_type_ego(static_cast<armour_type>(item.sub_type)); ASSERT(is_armour_brand_ok(item.sub_type, ego, true)); return ego; } bool is_armour_brand_ok(int type, int brand, bool strict) { equipment_type slot = get_armour_slot((armour_type)type); // Currently being too restrictive results in asserts, being too // permissive will generate such items on "any armour ego:XXX". // The latter is definitely so much safer -- 1KB switch ((special_armour_type)brand) { case SPARM_FORBID_EGO: case SPARM_NORMAL: return true; case SPARM_FLYING: if (slot == EQ_BODY_ARMOUR) return true; // deliberate fall-through case SPARM_RUNNING: #if TAG_MAJOR_VERSION == 34 case SPARM_JUMPING: #endif return slot == EQ_BOOTS; case SPARM_STEALTH: return slot == EQ_BOOTS || slot == EQ_CLOAK; case SPARM_ARCHMAGI: return !strict || type == ARM_ROBE; case SPARM_PONDEROUSNESS: return true; case SPARM_PRESERVATION: #if TAG_MAJOR_VERSION == 34 if (type == ARM_PLATE_ARMOUR && !strict) return true; // deliberate fall-through #endif case SPARM_INVISIBILITY: return slot == EQ_CLOAK; case SPARM_REFLECTION: case SPARM_PROTECTION: return slot == EQ_SHIELD; case SPARM_STRENGTH: case SPARM_DEXTERITY: if (!strict) return true; // deliberate fall-through case SPARM_ARCHERY: return slot == EQ_GLOVES; case SPARM_SEE_INVISIBLE: case SPARM_INTELLIGENCE: return slot == EQ_HELMET; case SPARM_FIRE_RESISTANCE: case SPARM_COLD_RESISTANCE: case SPARM_RESISTANCE: if (type == ARM_FIRE_DRAGON_ARMOUR || type == ARM_ICE_DRAGON_ARMOUR || type == ARM_GOLD_DRAGON_ARMOUR) { return false; // contradictory or redundant } return true; // in portal vaults, these can happen on every slot case SPARM_MAGIC_RESISTANCE: if (type == ARM_HAT) return true; // deliberate fall-through case SPARM_POISON_RESISTANCE: case SPARM_POSITIVE_ENERGY: if (type == ARM_PEARL_DRAGON_ARMOUR && brand == SPARM_POSITIVE_ENERGY) return false; // contradictory or redundant return slot == EQ_BODY_ARMOUR || slot == EQ_SHIELD || slot == EQ_CLOAK || !strict; case SPARM_SPIRIT_SHIELD: return #if TAG_MAJOR_VERSION == 34 type == ARM_HAT || type == ARM_CAP || #endif slot == EQ_SHIELD || type == ARM_SCARF || !strict; case SPARM_BUNKER: return slot == EQ_SHIELD && type == ARM_LARGE_SHIELD; case SPARM_REPULSION: case SPARM_CLOUD_IMMUNE: return type == ARM_SCARF; case NUM_SPECIAL_ARMOURS: case NUM_REAL_SPECIAL_ARMOURS: die("invalid armour brand"); } return true; } /** * Return the number of plusses required for a type of armour to be notable. * (From plus alone.) * * @param armour_type The type of armour being considered. * @return The armour plus value required to be interesting. */ static int _armour_plus_threshold(equipment_type armour_type) { switch (armour_type) { // body armour is very common; squelch most of it case EQ_BODY_ARMOUR: return 3; // shields are fairly common case EQ_SHIELD: return 2; // aux armour is relatively uncommon default: return 1; } } /** * Pick an armour type (ex. plate armour), based on item_level * * @param item_level The rough power level of the item. * * @return The selected armour type. */ static armour_type _get_random_armour_type(int item_level) { // Dummy value for initilization, always changed by the conditional // (and not changing it would trigger an ASSERT) armour_type armtype = NUM_ARMOURS; // Secondary armours. if (one_chance_in(5)) { // Total weight is 60, each slot has a weight of 12 armtype = random_choose_weighted(12, ARM_BOOTS, 12, ARM_GLOVES, // Cloak slot 9, ARM_CLOAK, 3, ARM_SCARF, // Head slot 10, ARM_HELMET, 2, ARM_HAT, // Shield slot 4, ARM_SHIELD, 6, ARM_BUCKLER, 2, ARM_LARGE_SHIELD); } else if (x_chance_in_y(11 + item_level, 10000)) { // High level dragon scales armtype = random_choose(ARM_STEAM_DRAGON_ARMOUR, ARM_ACID_DRAGON_ARMOUR, ARM_STORM_DRAGON_ARMOUR, ARM_GOLD_DRAGON_ARMOUR, ARM_SWAMP_DRAGON_ARMOUR, ARM_PEARL_DRAGON_ARMOUR, ARM_SHADOW_DRAGON_ARMOUR, ARM_QUICKSILVER_DRAGON_ARMOUR); } else if (x_chance_in_y(11 + item_level, 8000)) { // Crystal plate, some armours which are normally gained by butchering // monsters for hides. armtype = random_choose(ARM_CRYSTAL_PLATE_ARMOUR, ARM_TROLL_LEATHER_ARMOUR, ARM_FIRE_DRAGON_ARMOUR, ARM_ICE_DRAGON_ARMOUR); } else if (x_chance_in_y(11 + item_level, 60)) { // All the "mundane" armours. Generally the player will find at least // one copy of these by the Lair. armtype = random_choose(ARM_ROBE, ARM_LEATHER_ARMOUR, ARM_RING_MAIL, ARM_SCALE_MAIL, ARM_CHAIN_MAIL, ARM_PLATE_ARMOUR); } else if (x_chance_in_y(11 + item_level, 35)) { // All the "mundane" amours except plate. armtype = random_choose(ARM_ROBE, ARM_LEATHER_ARMOUR, ARM_RING_MAIL, ARM_SCALE_MAIL, ARM_CHAIN_MAIL); } else { // Default (lowest-level) armours. armtype = random_choose(ARM_ROBE, ARM_LEATHER_ARMOUR, ARM_RING_MAIL); } ASSERT(armtype != NUM_ARMOURS); return armtype; } static void _generate_armour_item(item_def& item, bool allow_uniques, int force_type, int item_level, int agent = NO_AGENT) { if (force_type != OBJ_RANDOM) item.sub_type = force_type; else { for (int i = 0; i < 1000; ++i) { item.sub_type = _get_random_armour_type(item_level); if (is_armour_brand_ok(item.sub_type, item.brand, true)) break; } } // Fall back to an ordinary item if artefacts not allowed for this type. if (item_level == ISPEC_RANDART && _armour_disallows_randart(item.sub_type)) item_level = ISPEC_GOOD_ITEM; // Forced randart. if (item_level == ISPEC_RANDART) { int ego = item.brand; for (int i = 0; i < 100; ++i) if (_try_make_armour_artefact(item, force_type, 0, true, agent) && is_artefact(item)) { // borrowed from similar code for weapons -- is this really the // best way to force an ego?? if (ego > SPARM_NORMAL) { item.props[ARTEFACT_PROPS_KEY].get_vector()[ARTP_BRAND].get_short() = ego; if (randart_is_bad(item)) // recheck, the brand changed { force_type = item.sub_type; item.clear(); item.quantity = 1; item.base_type = OBJ_ARMOUR; item.sub_type = force_type; continue; } } return; } // fall back to an ordinary item item_level = ISPEC_GOOD_ITEM; } if (allow_uniques && _try_make_armour_artefact(item, force_type, item_level, false, agent)) { return; } if (item.sub_type == ARM_BOOTS) { if (one_chance_in(8)) item.sub_type = ARM_NAGA_BARDING; else if (one_chance_in(7)) item.sub_type = ARM_CENTAUR_BARDING; } const bool force_good = item_level >= ISPEC_GIFT; const bool forced_ego = (item.brand > 0); const bool no_ego = (item.brand == SPARM_FORBID_EGO); if (no_ego) item.brand = SPARM_NORMAL; if (item_level < 0) { // Thoroughly damaged, could have been good once. if (!no_ego && (forced_ego || one_chance_in(4))) { // Brand is set as for "good" items. set_item_ego_type(item, OBJ_ARMOUR, _generate_armour_ego(item)); } item.plus -= 1 + random2(3); if (item_level == ISPEC_BAD) do_curse_item(item); } // Scarves always get an ego. else if (item.sub_type == ARM_SCARF) set_item_ego_type(item, OBJ_ARMOUR, _generate_armour_ego(item)); else if ((forced_ego || item.sub_type == ARM_HAT || x_chance_in_y(51 + item_level, 250)) && !item.is_mundane() || force_good) { // Make a good item... item.plus += random2(3); if (item.sub_type <= ARM_PLATE_ARMOUR && x_chance_in_y(21 + item_level, 300)) { item.plus += random2(3); } if (!no_ego && x_chance_in_y(31 + item_level, 350)) { // ...an ego item, in fact. set_item_ego_type(item, OBJ_ARMOUR, _generate_armour_ego(item)); if (get_armour_ego_type(item) == SPARM_PONDEROUSNESS) item.plus += 3 + random2(8); } } else if (one_chance_in(12)) { // Make a bad (cursed) item. do_curse_item(item); if (one_chance_in(5)) item.plus -= random2(3); set_item_ego_type(item, OBJ_ARMOUR, SPARM_NORMAL); } // Don't overenchant items. if (item.plus > armour_max_enchant(item)) item.plus = armour_max_enchant(item); // Don't let unenchantable armour get minuses. if (!armour_is_enchantable(item)) item.plus = 0; // Never give brands to scales or hides, in case of misbehaving vaults. if (armour_type_is_hide(static_cast<armour_type>(item.sub_type))) set_item_ego_type(item, OBJ_ARMOUR, SPARM_NORMAL); // squash boring items. if (!force_good && item.brand == SPARM_NORMAL && item.plus > 0 && item.plus < _armour_plus_threshold(get_armour_slot(item))) { item.plus = 0; } } static monster_type _choose_random_monster_corpse() { for (int count = 0; count < 1000; ++count) { monster_type spc = mons_species(static_cast<monster_type>( random2(NUM_MONSTERS))); if (mons_class_flag(spc, M_NO_POLY_TO | M_CANT_SPAWN)) continue; if (mons_class_can_leave_corpse(spc)) return spc; } return MONS_RAT; // if you can't find anything else... } /** * Choose a random wand subtype for ordinary wand generation. * * Some wands [mostly more powerful ones] are less common than others. * Attack wands are more common, mostly to preserve historical wand freqs. * * @return A random wand_type. */ static int _random_wand_subtype() { // total weight 75 [arbitrary] return random_choose_weighted(10, WAND_FLAME, 10, WAND_ICEBLAST, 8, WAND_RANDOM_EFFECTS, 8, WAND_POLYMORPH, 8, WAND_PARALYSIS, 8, WAND_ACID, 6, WAND_DISINTEGRATION, 6, WAND_DIGGING, 5, WAND_ENSLAVEMENT, 3, WAND_CLOUDS, 3, WAND_SCATTERSHOT, 1, WAND_HEAL_WOUNDS, 1, WAND_HASTING, 1, WAND_TELEPORTATION); } /** * Should wands of this type NOT spawn extremely early on? (At very low * item_level, or in the hands of very low HD monsters?) * * @param type The wand_type in question. * @return Whether it'd be excessively mean for this wand to be used * against very early players. */ bool is_high_tier_wand(int type) { switch (type) { case WAND_ENSLAVEMENT: case WAND_PARALYSIS: case WAND_ACID: case WAND_ICEBLAST: case WAND_DISINTEGRATION: case WAND_CLOUDS: case WAND_SCATTERSHOT: return true; default: return false; } } static void _generate_wand_item(item_def& item, int force_type, int item_level) { if (force_type != OBJ_RANDOM) item.sub_type = force_type; else item.sub_type = _random_wand_subtype(); // Add wand charges and ensure we have at least one charge. item.charges = 1 + random2avg(wand_charge_value(item.sub_type), 3); // Don't let monsters pickup early high-tier wands if (item_level < 2 && is_high_tier_wand(item.sub_type)) item.flags |= ISFLAG_NO_PICKUP; } static void _generate_food_item(item_def& item, int force_quant, int force_type) { // Determine sub_type: if (force_type == OBJ_RANDOM) item.sub_type = FOOD_RATION; else item.sub_type = force_type; // Happens with ghoul food acquirement -- use place_chunks() outherwise if (item.sub_type == FOOD_CHUNK) { // Set chunk flavour: item.plus = _choose_random_monster_corpse(); item.orig_monnum = item.plus; // Set duration. item.freshness = (10 + random2(11)) * 10; } // Determine quantity. item.quantity = force_quant > 1 ? force_quant : 1; } static void _generate_potion_item(item_def& item, int force_type, int item_level, int agent) { item.quantity = 1; if (one_chance_in(18)) item.quantity++; if (one_chance_in(25)) item.quantity++; if (force_type != OBJ_RANDOM) item.sub_type = force_type; else { int stype; int tries = 500; // If created by Xom, keep going until an approved potion is chosen // Currently does nothing, until we come up with a boring potion. do { // total weight: 1045 stype = random_choose_weighted(192, POT_CURING, 105, POT_HEAL_WOUNDS, 73, POT_LIGNIFY, 73, POT_FLIGHT, 73, POT_HASTE, 66, POT_DEGENERATION, 66, POT_MIGHT, 66, POT_AGILITY, 66, POT_BRILLIANCE, 53, POT_MUTATION, 35, POT_INVISIBILITY, 35, POT_RESISTANCE, 35, POT_MAGIC, 35, POT_BERSERK_RAGE, 35, POT_CANCELLATION, 35, POT_AMBROSIA, 2, POT_EXPERIENCE); } while (agent == GOD_XOM && _is_boring_item(OBJ_POTIONS, stype) && --tries > 0); item.sub_type = stype; } // don't let monsters pickup early dangerous potions if (item_level < 2 && item.sub_type == POT_BERSERK_RAGE) item.flags |= ISFLAG_NO_PICKUP; } static void _generate_scroll_item(item_def& item, int force_type, int item_level, int agent) { // determine sub_type: if (force_type != OBJ_RANDOM) item.sub_type = force_type; else { const int depth_mod = random2(1 + item_level); int tries = 500; // If this item is created by Xom, keep looping until an // interesting scroll is discovered (as determined by // _is_boring_item). Otherwise just weighted-choose a scroll. do { // total weight: 709 if depth_mod < 4 // 828 otherwise // -122 in sprint item.sub_type = random_choose_weighted( 200, SCR_IDENTIFY, 112, SCR_REMOVE_CURSE, // [Cha] don't generate teleportation scrolls if in sprint 100, (crawl_state.game_is_sprint() ? NUM_SCROLLS : SCR_TELEPORTATION), 45, SCR_AMNESIA, 40, SCR_ENCHANT_ARMOUR, 40, SCR_ENCHANT_WEAPON, 40, SCR_MAGIC_MAPPING, 32, SCR_FEAR, 32, SCR_FOG, 32, SCR_BLINKING, 32, SCR_IMMOLATION, // [Cha] don't generate noise scrolls if in sprint 22, (crawl_state.game_is_sprint() ? NUM_SCROLLS : SCR_NOISE), 22, SCR_RANDOM_USELESSNESS, // Higher-level scrolls. 27, (depth_mod < 4 ? NUM_SCROLLS : SCR_VULNERABILITY), 17, (depth_mod < 4 ? NUM_SCROLLS : SCR_SUMMONING), 15, (depth_mod < 4 ? NUM_SCROLLS : SCR_ACQUIREMENT), 15, (depth_mod < 4 ? NUM_SCROLLS : SCR_SILENCE), 15, (depth_mod < 4 ? NUM_SCROLLS : SCR_BRAND_WEAPON), 15, (depth_mod < 4 ? NUM_SCROLLS : SCR_TORMENT), 15, (depth_mod < 4 ? NUM_SCROLLS : SCR_HOLY_WORD), // DON'T MAKE UNIQUE SCROLL 0, SCR_COLLECTION, 0, SCR_WISH); } while (item.sub_type == NUM_SCROLLS || item.sub_type == SCR_COLLECTION || item.sub_type == SCR_WISH || agent == GOD_XOM && _is_boring_item(OBJ_SCROLLS, item.sub_type) && --tries > 0); } item.quantity = random_choose_weighted(46, 1, 1, 2, 1, 3); item.plus = 0; } /// Choose a random spellbook type for the given level. static book_type _choose_book_type(int item_level) { const book_type book = static_cast<book_type>(random2(NUM_FIXED_BOOKS)); if (item_type_removed(OBJ_BOOKS, book)) return _choose_book_type(item_level); // choose something else // If this book is really rare for this depth, continue trying. const int rarity = book_rarity(book); ASSERT(rarity != 100); // 'removed item' - ugh... if (!one_chance_in(100) && x_chance_in_y(rarity-1, item_level+1)) return _choose_book_type(item_level); // choose something else return book; } /// Choose a random skill for a manual to be generated for. static skill_type _choose_manual_skill() { // spell skill (or invo/evo) if (one_chance_in(4)) { return static_cast<skill_type>( SK_SPELLCASTING + random2(NUM_SKILLS - SK_SPELLCASTING)); } // mundane skill #if TAG_MAJOR_VERSION == 34 skill_type skill = SK_TRAPS; while (skill == SK_TRAPS || skill == SK_STABBING) skill = static_cast<skill_type>(random2(SK_LAST_MUNDANE+1)); return skill; #else return static_cast<skill_type>(random2(SK_LAST_MUNDANE + 1)); #endif } static void _generate_book_item(item_def& item, bool allow_uniques, int force_type, int item_level) { if (force_type != OBJ_RANDOM) item.sub_type = force_type; else if (item_level > 6 && x_chance_in_y(21 + item_level, 4000)) item.sub_type = BOOK_MANUAL; // skill manual - rare! else item.sub_type = _choose_book_type(item_level); if (item.sub_type == BOOK_MANUAL) { item.skill = _choose_manual_skill(); // Set number of bonus skill points. item.skill_points = random_range(2000, 3000); // Preidentify. set_ident_type(item, true); set_ident_flags(item, ISFLAG_IDENT_MASK); return; // rare enough without being replaced with randarts } // Only randomly generate randart books for OBJ_RANDOM, since randart // spellbooks aren't merely of-the-same-type-but-better, but // have an entirely different set of spells. if (allow_uniques && item_level > 2 && force_type == OBJ_RANDOM && x_chance_in_y(101 + item_level * 3, 4000)) { int choice = random_choose_weighted( 29, BOOK_RANDART_THEME, 1, BOOK_RANDART_LEVEL); item.sub_type = choice; } if (item.sub_type == BOOK_RANDART_THEME) build_themed_book(item, capped_spell_filter(20)); else if (item.sub_type == BOOK_RANDART_LEVEL) { int max_level = min(9, max(1, item_level / 3)); int spl_level = random_range(1, max_level); make_book_level_randart(item, spl_level); } } static void _generate_staff_item(item_def& item, bool allow_uniques, int force_type, int item_level, int agent) { // If we make the unique roll, no further generation necessary. // Copied unrand code from _try_make_weapon_artefact since randart enhancer staves // can't happen. if (allow_uniques && one_chance_in(item_level == ISPEC_GOOD_ITEM ? 27 : 100)) { // Temporarily fix the base_type to get enhancer staves item.base_type = OBJ_WEAPONS; if (_try_make_item_unrand(item, WPN_STAFF, agent)) return; item.base_type = OBJ_STAVES; } if (force_type == OBJ_RANDOM) { do { item.sub_type = random2(NUM_STAVES); } while (item_type_removed(OBJ_STAVES, item.sub_type)); // staves of energy are 25% less common, wizardry/power // are more common if (item.sub_type == STAFF_ENERGY && one_chance_in(4)) item.sub_type = random_choose(STAFF_WIZARDRY, STAFF_POWER); } else item.sub_type = force_type; if (one_chance_in(16)) do_curse_item(item); } static void _generate_rod_item(item_def& item, int force_type, int item_level) { if (force_type == OBJ_RANDOM) { do { item.sub_type = random2(NUM_RODS); } while (item_type_removed(OBJ_RODS, item.sub_type) || item.sub_type == ROD_PAKELLAS); } else item.sub_type = force_type; init_rod_mp(item, -1, item_level); if (one_chance_in(16)) do_curse_item(item); } static void _generate_rune_item(item_def& item, int force_type) { if (force_type == OBJ_RANDOM) { vector<int> possibles; for (int i = 0; i < NUM_RUNE_TYPES; i++) if (!item_type_removed(OBJ_RUNES, i) && !you.runes[i]) possibles.push_back(i); item.sub_type = possibles.empty() ? RUNE_DEMONIC : *random_iterator(possibles); } else item.sub_type = force_type; } static bool _try_make_jewellery_unrandart(item_def& item, int force_type, int item_level, int agent) { int type = (force_type == NUM_RINGS) ? get_random_ring_type() : (force_type == NUM_JEWELLERY) ? get_random_amulet_type() : force_type; if (item_level > 2 && one_chance_in(20) && x_chance_in_y(101 + item_level * 3, 2000)) { if (_try_make_item_unrand(item, type, agent)) return true; } return false; } /** * Generate a random 'bad' plus for a ring type that cares about plusses. * * @return a bad 'plus', between -2 and -6 (inclusive). */ static int _bad_ring_plus() { int plus = -2; if (coinflip()) --plus; if (one_chance_in(3)) plus -= random2(4); return plus; } /** * Generate a random 'good' plus for a ring type that cares about plusses. * * @param subtype The type of ring in question. * @return Between 1 and 6 (inclusive); 2-6 for statrings. * (+1 stat rings are extremely boring.) */ static int _good_jewellery_plus(int subtype) { switch (subtype) { case RING_STRENGTH: case RING_DEXTERITY: case RING_INTELLIGENCE: case AMU_REFLECTION: return 2 + (one_chance_in(3) ? random2(2) : random2avg(5, 2)); default: return 1 + (one_chance_in(3) ? random2(3) : random2avg(6, 2)); } } /** * Generate a random 'plus' for a given type of ring. * * @param subtype The type of ring in question. * @return A 'plus' for that ring. 0 for most types. */ static int _determine_ring_plus(int subtype) { switch (subtype) { case RING_PROTECTION: case RING_STRENGTH: case RING_SLAYING: case RING_EVASION: case RING_DEXTERITY: case RING_INTELLIGENCE: if (one_chance_in(5)) // 20% of such rings are cursed {dlb} return _bad_ring_plus(); return _good_jewellery_plus(subtype); case AMU_REFLECTION: return _good_jewellery_plus(subtype); default: return 0; } } static void _generate_jewellery_item(item_def& item, bool allow_uniques, int force_type, int item_level, int agent) { if (allow_uniques && item_level != ISPEC_RANDART && _try_make_jewellery_unrandart(item, force_type, item_level, agent)) { return; } // Determine subtype. // Note: removed double probability reduction for some subtypes if (force_type != OBJ_RANDOM && force_type != NUM_RINGS && force_type != NUM_JEWELLERY) { item.sub_type = force_type; } else { int tries = 500; do { if (force_type == NUM_RINGS) item.sub_type = get_random_ring_type(); else if (force_type == NUM_JEWELLERY) item.sub_type = get_random_amulet_type(); else item.sub_type = (one_chance_in(4) ? get_random_amulet_type() : get_random_ring_type()); } while (agent == GOD_XOM && _is_boring_item(OBJ_JEWELLERY, item.sub_type) && --tries > 0); } item.plus = _determine_ring_plus(item.sub_type); if (item.plus < 0) do_curse_item(item); // All jewellery base types should now work. - bwr if (item_level == ISPEC_RANDART || allow_uniques && item_level > 2 && x_chance_in_y(101 + item_level * 3, 4000)) { make_item_randart(item); } else if (item.sub_type == RING_ATTENTION || item.sub_type == RING_TELEPORTATION || item.sub_type == AMU_INACCURACY || one_chance_in(50)) { // Bad jewellery is always cursed {dlb}: do_curse_item(item); } } static void _generate_mercenary_item(item_def& item) { item.props[MERCENARY_UNIT_KEY].get_int() = random_choose_weighted( 20, MONS_MERC_FIGHTER, 5, MONS_MERC_KNIGHT, 1, MONS_MERC_DEATH_KNIGHT, 1, MONS_MERC_PALADIN, 20, MONS_MERC_SKALD, 5, MONS_MERC_INFUSER, 1, MONS_MERC_TIDEHUNTER, 20, MONS_MERC_WITCH, 5, MONS_MERC_SORCERESS, 1, MONS_MERC_ELEMENTALIST, 20, MONS_MERC_BRIGAND, 5, MONS_MERC_ASSASSIN, 1, MONS_MERC_CLEANER, 20, MONS_MERC_SHAMAN, 5, MONS_MERC_SHAMAN_II, 1, MONS_MERC_SHAMAN_III, //아래부턴 일반 몬스터들 50, MONS_KOBOLD, 20, MONS_BIG_KOBOLD, 20, MONS_NAGA, 5, MONS_NAGA_WARRIOR, 5, MONS_NAGA_MAGE, 1, MONS_NAGARAJA, 15, MONS_DEEP_ELF_MAGE, 1, MONS_DEEP_ELF_DEMONOLOGIST, 1, MONS_DEEP_ELF_ANNIHILATOR, 1, MONS_DEEP_ELF_SORCERER, 1, MONS_DEEP_ELF_HIGH_PRIEST, 30, MONS_GNOLL, 10, MONS_GNOLL_SERGEANT, 30, MONS_MERFOLK, 5, MONS_MERFOLK_IMPALER, 50, MONS_ORC, 20, MONS_ORC_WARRIOR, 10, MONS_ORC_WIZARD, 10, MONS_ORC_PRIEST, 5, MONS_ORC_KNIGHT, 5, MONS_ORC_HIGH_PRIEST, 5, MONS_ORC_SORCERER, 1, MONS_ORC_WARLORD ); } static void _generate_misc_item(item_def& item, int force_type) { if (force_type != OBJ_RANDOM) item.sub_type = force_type; else { item.sub_type = random_choose(MISC_FAN_OF_GALES, MISC_LAMP_OF_FIRE, MISC_PHIAL_OF_FLOODS, MISC_LIGHTNING_ROD, MISC_DISC_OF_STORMS, MISC_BOX_OF_BEASTS, MISC_SACK_OF_SPIDERS, MISC_CRYSTAL_BALL_OF_ENERGY, MISC_PHANTOM_MIRROR, MISC_TIN_OF_TREMORSTONES, MISC_PIPE); } if (item.sub_type == MISC_MERCENARY) { _generate_mercenary_item(item); } } /** * Alter the inputed item to have no "plusses" (mostly weapon/armour enchantment) * * @param[in,out] item_slot The item slot of the item to remove "plusses" from. */ void squash_plusses(int item_slot) { item_def& item(mitm[item_slot]); item.plus = 0; item.plus2 = 0; item.brand = 0; set_equip_desc(item, ISFLAG_NO_DESC); } static bool _ego_unrand_only(int base_type, int ego) { if (base_type == OBJ_WEAPONS) { switch (static_cast<brand_type>(ego)) { case SPWPN_REAPING: case SPWPN_ACID: return true; default: return false; } } // all armours are ok? return false; } // Make a corresponding randart instead as a fallback. // Attempts to use base type, sub type, and ego (for armour/weapons). // Artefacts can explicitly specify a base type and fallback type. // Could be even more flexible: maybe allow an item spec to describe // complex fallbacks? static void _setup_fallback_randart(const int unrand_id, item_def &item, int &force_type, int &item_level) { ASSERT(get_unrand_entry(unrand_id)); const unrandart_entry &unrand = *get_unrand_entry(unrand_id); dprf("Placing fallback randart for %s", unrand.name); uint8_t fallback_sub_type; if (unrand.fallback_base_type != OBJ_UNASSIGNED) { item.base_type = unrand.fallback_base_type; fallback_sub_type = unrand.fallback_sub_type; } else { item.base_type = unrand.base_type; fallback_sub_type = unrand.sub_type; } if (item.base_type == OBJ_WEAPONS && fallback_sub_type == WPN_STAFF) { item.base_type = OBJ_STAVES; if (unrand_id == UNRAND_WUCAD_MU) force_type = STAFF_ENERGY; else if (unrand_id == UNRAND_OLGREB) force_type = STAFF_POISON; else force_type = OBJ_RANDOM; // XXX: small chance of the other unrand... // (but we won't hit this case until a new staff unrand is added) } else if (item.base_type == OBJ_JEWELLERY && fallback_sub_type == AMU_NOTHING) { force_type = NUM_JEWELLERY; } else force_type = fallback_sub_type; // import some brand information from the unrand. TODO: I'm doing this for // the sake of vault designers who make themed vaults. But it also often // makes the item more redundant with the unrand; maybe add a bit more // flexibility in item specs so that this part is optional? However, from a // seeding perspective, it also makes sense if the item generated is // very comparable. // unset fallback_brand is -1. In that case it will try to use the regular // brand if there is one. If the end result here is 0, the brand (for // weapons) will be chosen randomly. So to force randomness, use // SPWPN_NORMAL on the fallback ego, or set neither. (Randarts cannot be // unbranded.) item.brand = unrand.fallback_brand; // no type checking here... if (item.brand < 0 && !_ego_unrand_only(item.base_type, unrand.prpty[ARTP_BRAND]) && item.base_type == unrand.base_type // brand isn't well-defined for != case && ((item.base_type == OBJ_WEAPONS && is_weapon_brand_ok(item.sub_type, unrand.prpty[ARTP_BRAND], true)) || (item.base_type == OBJ_ARMOUR && is_armour_brand_ok(item.sub_type, unrand.prpty[ARTP_BRAND], true)))) { // maybe do jewellery too? item.brand = unrand.prpty[ARTP_BRAND]; } if (item.brand < 0) item.brand = 0; item_level = ISPEC_RANDART; } /** * Create an item. * * Various parameters determine whether the item can be an artifact, set the * item class (ex. weapon, wand), set the item subtype (ex. * hand axe, wand of flame), set the item ego (ex. of flaming, of running), set * the rough power level of the item, and set the agent of the item (which * affects what artefacts can be generated, and also non-artefact items if the * agent is Xom). Item class, Item type, and Item ego can also be randomly * selected (by setting those parameters to OBJ_RANDOM, OBJ_RANDOM, and 0 * respectively). * * @param allow_uniques Can the item generated be an artefact? * @param force_class The desired OBJECTS class (Example: OBJ_ARMOUR) * @param force_type The desired SUBTYPE - enum varies by OBJ * @param item_level How powerful the item is allowed to be * @param force_ego The desired ego/brand * @param agent The agent creating the item (Example: Xom) or -1 if NA * * @return The generated item's item slot or NON_ITEM if it fails. */ int items(bool allow_uniques, object_class_type force_class, int force_type, int item_level, int force_ego, int agent) { rng::subgenerator item_rng; ASSERT(force_ego <= 0 || force_class == OBJ_WEAPONS || force_class == OBJ_ARMOUR || force_class == OBJ_MISSILES || force_class == OBJ_MISCELLANY); // Find an empty slot for the item (with culling if required). int p = get_mitm_slot(10); if (p == NON_ITEM) return NON_ITEM; item_def& item(mitm[p]); const bool force_good = item_level >= ISPEC_GIFT; if (force_ego != 0) allow_uniques = false; item.brand = force_ego; // cap item_level unless an acquirement-level item {dlb}: if (item_level > 50 && !force_good) item_level = 50; // determine base_type for item generated {dlb}: if (force_class != OBJ_RANDOM) { ASSERT(force_class < NUM_OBJECT_CLASSES); item.base_type = force_class; } else { ASSERT(force_type == OBJ_RANDOM); // Total weight: 1960 item.base_type = random_choose_weighted( 1, OBJ_RODS, 9, OBJ_STAVES, 30, OBJ_BOOKS, 50, OBJ_JEWELLERY, 70, OBJ_WANDS, 140, OBJ_FOOD, 212, OBJ_ARMOUR, 212, OBJ_WEAPONS, 176, OBJ_POTIONS, 300, OBJ_MISSILES, 320, OBJ_SCROLLS, 440, OBJ_GOLD); // misc items placement wholly dependent upon current depth {dlb}: if (item_level > 7 && x_chance_in_y(21 + item_level, 5000)) item.base_type = OBJ_MISCELLANY; if (item_level < 7 && (item.base_type == OBJ_BOOKS || item.base_type == OBJ_STAVES || item.base_type == OBJ_RODS || item.base_type == OBJ_WANDS) && random2(7) >= item_level) { item.base_type = random_choose(OBJ_POTIONS, OBJ_SCROLLS); } } ASSERT(force_type == OBJ_RANDOM || item.base_type == OBJ_JEWELLERY && force_type == NUM_JEWELLERY || force_type < get_max_subtype(item.base_type)); // make_item_randart() might do things differently based upon the // acquirement agent, especially for god gifts. if (agent != NO_AGENT && !is_stackable_item(item)) origin_acquired(item, agent); item.quantity = 1; // generally the case if (force_ego < SP_FORBID_EGO) { const int unrand_id = -force_ego; if (get_unique_item_status(unrand_id) == UNIQ_NOT_EXISTS) { make_item_unrandart(mitm[p], unrand_id); ASSERT(mitm[p].is_valid()); return p; } _setup_fallback_randart(unrand_id, item, force_type, item_level); allow_uniques = false; } // Determine sub_type accordingly. {dlb} switch (item.base_type) { case OBJ_WEAPONS: _generate_weapon_item(item, allow_uniques, force_type, item_level, agent); break; case OBJ_MISSILES: _generate_missile_item(item, force_type, item_level); break; case OBJ_ARMOUR: _generate_armour_item(item, allow_uniques, force_type, item_level, agent); break; case OBJ_WANDS: _generate_wand_item(item, force_type, item_level); break; case OBJ_FOOD: _generate_food_item(item, allow_uniques, force_type); break; case OBJ_POTIONS: _generate_potion_item(item, force_type, item_level, agent); break; case OBJ_SCROLLS: _generate_scroll_item(item, force_type, item_level, agent); break; case OBJ_JEWELLERY: _generate_jewellery_item(item, allow_uniques, force_type, item_level, agent); break; case OBJ_BOOKS: _generate_book_item(item, allow_uniques, force_type, item_level); break; case OBJ_STAVES: // Don't generate unrand staves this way except through acquirement, // since they also generate as OBJ_WEAPONS. _generate_staff_item(item, (agent != NO_AGENT), force_type, item_level, agent); break; case OBJ_RODS: _generate_rod_item(item, force_type, item_level); break; case OBJ_ORBS: // always forced in current setup {dlb} case OBJ_RUNES: _generate_rune_item(item, force_type); break; case OBJ_MISCELLANY: _generate_misc_item(item, force_type); break; // that is, everything turns to gold if not enumerated above, so ... {dlb} default: item.base_type = OBJ_GOLD; if (force_good) item.quantity = 100 + random2(400); else { item.quantity = 1 + random2avg(19, 2); item.quantity += random2(item_level); } break; } // Colour the item. item_colour(item); // Set brand appearance. item_set_appearance(item); // Don't place the item just yet. item.pos.reset(); item.link = NON_ITEM; // Note that item might be invalidated now, since p could have changed. ASSERTM(mitm[p].is_valid(), "idx: %d, qty: %hd, base: %d, sub: %d, spe: %d, col: %d, rnd: %d", item.index(), item.quantity, (int)item.base_type, (int)item.sub_type, item.special, (int)item.get_colour(), (int)item.rnd); return p; } void reroll_brand(item_def &item, int item_level) { ASSERT(!is_artefact(item)); switch (item.base_type) { case OBJ_WEAPONS: item.brand = determine_weapon_brand(item, item_level); break; case OBJ_MISSILES: item.brand = _determine_missile_brand(item, item_level); break; case OBJ_ARMOUR: item.brand = _generate_armour_ego(item); break; default: die("can't reroll brands of this type"); } item_set_appearance(item); } static int _roll_rod_enchant(int item_level) { int value = 0; if (one_chance_in(4)) value -= random_range(1, 3); if (item_level >= ISPEC_GIFT) value += 2; int pr = 20 + item_level * 2; if (pr > 80) pr = 80; while (random2(100) < pr) value++; return stepdown_value(value, 4, 4, 4, 9); } void init_rod_mp(item_def& item, int ncharges, int item_level) { ASSERT(item.base_type == OBJ_RODS); if (ncharges != -1) { item.charge_cap = ncharges * ROD_CHARGE_MULT; item.rod_plus = 0; } else { item.charge_cap = random_range(9, 14) * ROD_CHARGE_MULT; item.rod_plus = _roll_rod_enchant(item_level); } item.charges = item.charge_cap; } static bool _weapon_is_visibly_special(const item_def &item) { const int brand = get_weapon_brand(item); const bool visibly_branded = (brand != SPWPN_NORMAL); if (get_equip_desc(item) != ISFLAG_NO_DESC) return false; if (visibly_branded || is_artefact(item) || item.plus > 0) return true; if (item.is_mundane()) return false; if (item.flags & ISFLAG_CURSED && one_chance_in(3)) return true; return false; } static bool _armour_is_visibly_special(const item_def &item) { const int brand = get_armour_ego_type(item); const bool visibly_branded = (brand != SPARM_NORMAL); if (get_equip_desc(item) != ISFLAG_NO_DESC) return false; if (visibly_branded || is_artefact(item) || item.plus > 0) return true; if (item.is_mundane()) return false; if (item.flags & ISFLAG_CURSED && one_chance_in(3)) return true; return false; } jewellery_type get_random_amulet_type() { int res; do { res = random_range(AMU_FIRST_AMULET, NUM_JEWELLERY - 1); } // Do not generate removed item types. while (item_type_removed(OBJ_JEWELLERY, res)); return jewellery_type(res); } static jewellery_type _get_raw_random_ring_type() { jewellery_type ring; do { ring = (jewellery_type)(random_range(RING_FIRST_RING, NUM_RINGS - 1)); } while (ring == RING_TELEPORTATION && crawl_state.game_is_sprint() || item_type_removed(OBJ_JEWELLERY, ring)); return ring; } jewellery_type get_random_ring_type() { const jewellery_type j = _get_raw_random_ring_type(); // Adjusted distribution here. - bwr if (j == RING_SLAYING && !one_chance_in(3)) return _get_raw_random_ring_type(); return j; } // Sets item appearance to match brands, if any. void item_set_appearance(item_def &item) { // Artefact appearance overrides cosmetic flags anyway. if (is_artefact(item)) return; if (get_equip_desc(item) != ISFLAG_NO_DESC) return; switch (item.base_type) { case OBJ_WEAPONS: if (_weapon_is_visibly_special(item)) set_equip_desc(item, random_choose(ISFLAG_GLOWING, ISFLAG_RUNED)); break; case OBJ_ARMOUR: if (_armour_is_visibly_special(item)) { set_equip_desc(item, random_choose(ISFLAG_GLOWING, ISFLAG_RUNED, ISFLAG_EMBROIDERED_SHINY)); } break; default: break; } } #if defined(DEBUG_DIAGNOSTICS) || defined(DEBUG_TESTS) static int _test_item_level() { switch (random2(10)) { case 0: return ISPEC_GOOD_ITEM; case 1: return ISPEC_DAMAGED; case 2: return ISPEC_BAD; case 3: return ISPEC_RANDART; default: return random2(50); } } void makeitem_tests() { int i, level; item_def item; mpr("Running generate_weapon_item tests."); for (i = 0; i < 10000; ++i) { item.clear(); level = _test_item_level(); item.base_type = OBJ_WEAPONS; item.brand = coinflip() ? SPWPN_NORMAL : random2(NUM_REAL_SPECIAL_WEAPONS); #if TAG_MAJOR_VERSION == 34 if (item.brand == SPWPN_ORC_SLAYING || item.brand == SPWPN_REACHING || item.brand == SPWPN_RETURNING || item.brand == SPWPN_CONFUSE) { item.brand = SPWPN_FORBID_BRAND; } #endif auto weap_type = coinflip() ? OBJ_RANDOM : random2(NUM_WEAPONS); _generate_weapon_item(item, coinflip(), weap_type, level); } mpr("Running generate_armour_item tests."); for (i = 0; i < 10000; ++i) { item.clear(); level = _test_item_level(); item.base_type = OBJ_ARMOUR; item.brand = coinflip() ? SPARM_NORMAL : random2(NUM_REAL_SPECIAL_ARMOURS); int type = coinflip() ? OBJ_RANDOM : random2(NUM_ARMOURS); #if TAG_MAJOR_VERSION == 34 if (type == ARM_CAP) type = ARM_HAT; #endif _generate_armour_item(item, coinflip(), type, level); } } #endif
; A104626: Numbers having three 1's in their base-phi representation. ; 4,5,6,8,19,48,124,323,844,2208,5779,15128,39604,103683,271444,710648,1860499,4870848,12752044,33385283,87403804,228826128,599074579,1568397608,4106118244,10749957123,28143753124,73681302248,192900153619,505019158608,1322157322204,3461452808003,9062201101804,23725150497408,62113250390419,162614600673848,425730551631124,1114577054219523,2918000611027444,7639424778862808 mov $2,1 mov $5,$0 lpb $0 add $3,$2 add $1,$3 trn $1,3 add $2,1 add $3,$1 trn $4,$0 sub $0,1 add $4,1 lpe add $4,1 add $1,$4 trn $1,4 lpb $5 add $1,1 sub $5,1 lpe add $1,4
#include <cmath> #include "GOPlayer.h" #include "GOConsumable.h" #include "GameContext.h" GOPlayer::GOPlayer(const GameContext &context, Rect frame) : GameObject(context, frame) { physics = std::make_shared<PhysicsState>(this); physics->gravity = true; physics->still = false; originalSize = frame.size; health = 100; } void GOPlayer::handleEvent(SDL_Event *e) { if (e->type == SDL_KEYDOWN) { switch (e->key.keysym.sym) { case SDLK_g: physics->gravity = !physics->gravity; if (!physics->gravity) { jumped = true; physics->velocity *= 0; } break; } } GameObject::handleEvent(e); } void GOPlayer::handleKeyboard(const Uint8 *state) { if (!dead) { bool sitDown = false; bool moveLeft = false; bool moveRight = false; Vector2D moveVector = Vector2D(); if (state[SDL_SCANCODE_LEFT] || state[SDL_SCANCODE_A]) { moveVector += Vector2D(-speed, 0); moveLeft = true; } if (state[SDL_SCANCODE_RIGHT] || state[SDL_SCANCODE_D]) { moveVector += Vector2D(speed, 0); moveRight = true; } if (state[SDL_SCANCODE_UP] || state[SDL_SCANCODE_W] || state[SDL_SCANCODE_SPACE]) { if (!physics->gravity) { moveVector += Vector2D(0, -speed); } else { if (!jumped) { physics->velocity += Vector2D(0, -jumpSpeed); jumped = true; } } } if (state[SDL_SCANCODE_DOWN] || state[SDL_SCANCODE_S] || state[SDL_SCANCODE_LCTRL] || state[SDL_SCANCODE_RCTRL]) { if (!physics->gravity) { moveVector += Vector2D(0, speed); } else { sitDown = true; } } setCrouched(sitDown); if (moveLeft && !moveRight) { moveAnimation->turnLeft(true); crouchAnimation->turnLeft(true); crouchMoveAnimation->turnLeft(true); } if (moveRight && !moveLeft) { moveAnimation->turnLeft(false); crouchAnimation->turnLeft(false); crouchMoveAnimation->turnLeft(false); } if (!moveLeft && !moveRight && !jumped && !crouched) animation = idleAnimation; if (!moveLeft && !moveRight && !jumped && crouched) animation = crouchAnimation; if ((moveLeft || moveRight) && !jumped && !crouched) animation = moveAnimation; if ((moveLeft || moveRight) && !jumped && crouched) animation = crouchMoveAnimation; if (jumped && crouched) animation = crouchAnimation; if (jumped && !crouched) animation = jumpAnimation; frame.center.x += moveVector.x; frame.center.y += moveVector.y; } GameObject::handleKeyboard(state); } void GOPlayer::handleEnterCollision(Collision collision) { if (auto consumable = dynamic_cast<GOConsumable *>(collision.collider)) { power += 1; powerBar->setValue(power); consumable->removed = true; speed += 0.01f; jumpSpeed += 0.01f; if (power > 99) { win(); } } } void GOPlayer::handleExitCollision(__attribute__((unused)) GameObject *collider) { if (physics->colliders.empty()) { jumped = true; } } void GOPlayer::handleCollision(Collision collision) { if (fabs(collision.collisionVector.x) > fabs(collision.collisionVector.y)) { if (collision.collisionVector.y > 0 && jumped && physics->gravity) { jumped = false; } } } void GOPlayer::dealDamage(int damage) { if (!won) { health -= damage; healthBar->setValue(health); if (health < 0) { die(); } } } void GOPlayer::die() { dead = true; deathText->visible = true; } void GOPlayer::win() { won = true; winText->visible = true; } GOPlayer::~GOPlayer() { delete idleAnimation; delete moveAnimation; delete jumpAnimation; delete crouchAnimation; delete crouchMoveAnimation; delete deathText; delete winText; delete healthBar; delete powerBar; } void GOPlayer::setCrouched(bool value) { if (value && !this->crouched) { this->crouched = true; frame.size.height = originalSize.height / 2; frame.center.y += frame.size.height / 2; } else if (!value && this->crouched) { this->crouched = false; frame.center.y -= frame.size.height / 2; frame.size.height = originalSize.height; } }
/** * Calculator Comrade Library * License: https://github.com/DmitryDzz/calculator-comrade-lib/blob/master/LICENSE * Author: Dmitry Dzakhov * Email: info@robot-mitya.ru */ #include <gmock/gmock.h> #include "calculator/calculator.h" #include "calc_helper.h" using namespace calculatorcomrade; #define TEST_MEM(test_name) TEST(TestMem, test_name) TEST_MEM(Plus) { Calculator c; Register &x = c.getX(); Register &m = c.getM(); c.input(Button::d2); c.input(Button::memPlus); ASSERT_EQ(2, getIntValue(x)); ASSERT_EQ(2, getIntValue(m)); c.input(Button::d3); c.input(Button::memPlus); ASSERT_EQ(3, getIntValue(x)); ASSERT_EQ(5, getIntValue(m)); } //2 m+ => mem 2 //3 => mem 3 //mr => mem 2 //mc => 2 //mc => 2 //TODO DZZ Check it on hardware. TEST_MEM(MemClear) { Calculator c; Register &x = c.getX(); Register &m = c.getM(); ASSERT_FALSE(c.memHasValue()); c.input(Button::d2); c.input(Button::memPlus); ASSERT_EQ(2, getIntValue(x)); ASSERT_EQ(2, getIntValue(m)); ASSERT_TRUE(c.memHasValue()); c.input(Button::d3); ASSERT_EQ(3, getIntValue(x)); ASSERT_EQ(2, getIntValue(m)); ASSERT_TRUE(c.memHasValue()); c.input(Button::memR); ASSERT_EQ(2, getIntValue(x)); ASSERT_EQ(2, getIntValue(m)); ASSERT_TRUE(c.memHasValue()); c.input(Button::memC); ASSERT_EQ(2, getIntValue(x)); ASSERT_EQ(0, getIntValue(m)); ASSERT_FALSE(c.memHasValue()); c.input(Button::memC); ASSERT_EQ(2, getIntValue(x)); ASSERT_EQ(0, getIntValue(m)); ASSERT_FALSE(c.memHasValue()); } //2 m+ => mem 2 //3 => mem 3 //mrc => mem 2 //mrc => 2 //mrc => 2 TEST_MEM(MemRC) { Calculator c; Register &x = c.getX(); Register &m = c.getM(); ASSERT_FALSE(c.memHasValue()); c.input(Button::d2); c.input(Button::memPlus); ASSERT_EQ(2, getIntValue(x)); ASSERT_EQ(2, getIntValue(m)); ASSERT_TRUE(c.memHasValue()); c.input(Button::d3); ASSERT_EQ(3, getIntValue(x)); ASSERT_EQ(2, getIntValue(m)); ASSERT_TRUE(c.memHasValue()); c.input(Button::memRC); ASSERT_EQ(2, getIntValue(x)); ASSERT_EQ(2, getIntValue(m)); ASSERT_TRUE(c.memHasValue()); c.input(Button::memRC); ASSERT_EQ(2, getIntValue(x)); ASSERT_EQ(0, getIntValue(m)); ASSERT_FALSE(c.memHasValue()); c.input(Button::memRC); ASSERT_EQ(2, getIntValue(x)); ASSERT_EQ(0, getIntValue(m)); ASSERT_FALSE(c.memHasValue()); } // 2 m+ 3 m+ 5 m- => hasMemory == false TEST_MEM(MemClearHack) { Calculator c; Register &x = c.getX(); Register &m = c.getM(); ASSERT_FALSE(c.memHasValue()); c.input(Button::d2); c.input(Button::memPlus); ASSERT_EQ(2, getIntValue(x)); ASSERT_EQ(2, getIntValue(m)); ASSERT_TRUE(c.memHasValue()); c.input(Button::d3); c.input(Button::memPlus); ASSERT_EQ(3, getIntValue(x)); ASSERT_EQ(5, getIntValue(m)); ASSERT_TRUE(c.memHasValue()); c.input(Button::d5); c.input(Button::memMinus); ASSERT_EQ(5, getIntValue(x)); ASSERT_EQ(0, getIntValue(m)); ASSERT_FALSE(c.memHasValue()); } //2 m+ 3 mr = => 2 //= => 2 TEST_MEM(MemAndRegisterY) { Calculator c(8); Register &x = c.getX(); Register &m = c.getM(); c.input(Button::d2); c.input(Button::memPlus); ASSERT_EQ(2, getIntValue(x)); ASSERT_EQ(2, getIntValue(m)); ASSERT_TRUE(c.memHasValue()); c.input(Button::d3); c.input(Button::memR); ASSERT_EQ(2, getIntValue(x)); ASSERT_EQ(2, getIntValue(m)); ASSERT_TRUE(c.memHasValue()); c.input(Button::equals); ASSERT_EQ(2, getIntValue(x)); ASSERT_EQ(2, getIntValue(m)); ASSERT_TRUE(c.memHasValue()); c.input(Button::equals); ASSERT_EQ(2, getIntValue(x)); ASSERT_EQ(2, getIntValue(m)); ASSERT_TRUE(c.memHasValue()); } TEST_MEM(MemPlusSpecial1) { Calculator c; Register &x = c.getX(); Register &y = c.getY(); Register &m = c.getM(); c.input(Button::d2); c.input(Button::plus); c.input(Button::d3); c.input(Button::memPlus); ASSERT_EQ(5, getIntValue(x)); ASSERT_EQ(0, getIntValue(y)); ASSERT_EQ(Operation::add, c.getOperation()); ASSERT_EQ(5, getIntValue(m)); c.input(Button::equals); ASSERT_EQ(5, getIntValue(x)); ASSERT_EQ(0, getIntValue(y)); ASSERT_EQ(Operation::add, c.getOperation()); ASSERT_EQ(5, getIntValue(m)); } TEST_MEM(MemPlusSpecial2) { Calculator c; Register &x = c.getX(); Register &y = c.getY(); Register &m = c.getM(); c.input(Button::d2); c.input(Button::mul); c.input(Button::d3); c.input(Button::memPlus); ASSERT_EQ(6, getIntValue(x)); ASSERT_EQ(0, getIntValue(y)); ASSERT_EQ(Operation::add, c.getOperation()); ASSERT_EQ(6, getIntValue(m)); c.input(Button::equals); ASSERT_EQ(6, getIntValue(x)); ASSERT_EQ(0, getIntValue(y)); ASSERT_EQ(Operation::add, c.getOperation()); ASSERT_EQ(6, getIntValue(m)); } TEST_MEM(MemPlusSpecial3) { Calculator c; Register &x = c.getX(); Register &y = c.getY(); Register &m = c.getM(); c.input(Button::d2); c.input(Button::plus); c.input(Button::memPlus); ASSERT_EQ(2, getIntValue(x)); ASSERT_EQ(0, getIntValue(y)); ASSERT_EQ(Operation::add, c.getOperation()); ASSERT_EQ(2, getIntValue(m)); c.input(Button::equals); ASSERT_EQ(2, getIntValue(x)); ASSERT_EQ(0, getIntValue(y)); ASSERT_EQ(Operation::add, c.getOperation()); ASSERT_EQ(2, getIntValue(m)); } TEST_MEM(MemPlusSpecial4) { Calculator c; Register &x = c.getX(); Register &y = c.getY(); Register &m = c.getM(); c.input(Button::d3); c.input(Button::mul); c.input(Button::memPlus); ASSERT_EQ(9, getIntValue(x)); ASSERT_EQ(0, getIntValue(y)); ASSERT_EQ(Operation::add, c.getOperation()); ASSERT_EQ(9, getIntValue(m)); c.input(Button::equals); ASSERT_EQ(9, getIntValue(x)); ASSERT_EQ(0, getIntValue(y)); ASSERT_EQ(Operation::add, c.getOperation()); ASSERT_EQ(9, getIntValue(m)); } TEST_MEM(MemPlusSpecial5) { Calculator c; Register &x = c.getX(); Register &y = c.getY(); Register &m = c.getM(); c.input(Button::d2); c.input(Button::plus); c.input(Button::d3); c.input(Button::equals); ASSERT_EQ(5, getIntValue(x)); ASSERT_EQ(3, getIntValue(y)); ASSERT_EQ(Operation::add, c.getOperation()); ASSERT_EQ(0, getIntValue(m)); c.input(Button::memPlus); ASSERT_EQ(5, getIntValue(x)); ASSERT_EQ(3, getIntValue(y)); ASSERT_EQ(Operation::add, c.getOperation()); ASSERT_EQ(5, getIntValue(m)); c.input(Button::equals); ASSERT_EQ(8, getIntValue(x)); ASSERT_EQ(3, getIntValue(y)); ASSERT_EQ(Operation::add, c.getOperation()); ASSERT_EQ(5, getIntValue(m)); } TEST_MEM(MemPlusSpecial6) { Calculator c; Register &x = c.getX(); Register &y = c.getY(); Register &m = c.getM(); c.input(Button::d2); c.input(Button::mul); c.input(Button::d3); c.input(Button::equals); ASSERT_EQ(6, getIntValue(x)); ASSERT_EQ(2, getIntValue(y)); ASSERT_EQ(Operation::mul, c.getOperation()); ASSERT_EQ(0, getIntValue(m)); c.input(Button::memPlus); ASSERT_EQ(6, getIntValue(x)); ASSERT_EQ(2, getIntValue(y)); ASSERT_EQ(Operation::mul, c.getOperation()); ASSERT_EQ(6, getIntValue(m)); c.input(Button::equals); ASSERT_EQ(12, getIntValue(x)); ASSERT_EQ(2, getIntValue(y)); ASSERT_EQ(Operation::mul, c.getOperation()); ASSERT_EQ(6, getIntValue(m)); } TEST_MEM(MemMinusSpecial1) { Calculator c; Register &x = c.getX(); Register &y = c.getY(); Register &m = c.getM(); c.input(Button::d2); c.input(Button::plus); c.input(Button::d3); c.input(Button::memMinus); ASSERT_EQ(5, getIntValue(x)); ASSERT_EQ(0, getIntValue(y)); ASSERT_EQ(Operation::add, c.getOperation()); ASSERT_EQ(-5, getIntValue(m)); c.input(Button::equals); ASSERT_EQ(5, getIntValue(x)); ASSERT_EQ(0, getIntValue(y)); ASSERT_EQ(Operation::add, c.getOperation()); ASSERT_EQ(-5, getIntValue(m)); } TEST_MEM(MemMinusSpecial2) { Calculator c; Register &x = c.getX(); Register &y = c.getY(); Register &m = c.getM(); c.input(Button::d2); c.input(Button::mul); c.input(Button::d3); c.input(Button::memMinus); ASSERT_EQ(6, getIntValue(x)); ASSERT_EQ(0, getIntValue(y)); ASSERT_EQ(Operation::add, c.getOperation()); ASSERT_EQ(-6, getIntValue(m)); c.input(Button::equals); ASSERT_EQ(6, getIntValue(x)); ASSERT_EQ(0, getIntValue(y)); ASSERT_EQ(Operation::add, c.getOperation()); ASSERT_EQ(-6, getIntValue(m)); } TEST_MEM(MemMinusSpecial3) { Calculator c; Register &x = c.getX(); Register &y = c.getY(); Register &m = c.getM(); c.input(Button::d2); c.input(Button::plus); c.input(Button::memMinus); ASSERT_EQ(2, getIntValue(x)); ASSERT_EQ(0, getIntValue(y)); ASSERT_EQ(Operation::add, c.getOperation()); ASSERT_EQ(-2, getIntValue(m)); c.input(Button::equals); ASSERT_EQ(2, getIntValue(x)); ASSERT_EQ(0, getIntValue(y)); ASSERT_EQ(Operation::add, c.getOperation()); ASSERT_EQ(-2, getIntValue(m)); } TEST_MEM(MemMinusSpecial4) { Calculator c; Register &x = c.getX(); Register &y = c.getY(); Register &m = c.getM(); c.input(Button::d3); c.input(Button::mul); c.input(Button::memMinus); ASSERT_EQ(9, getIntValue(x)); ASSERT_EQ(0, getIntValue(y)); ASSERT_EQ(Operation::add, c.getOperation()); ASSERT_EQ(-9, getIntValue(m)); c.input(Button::equals); ASSERT_EQ(9, getIntValue(x)); ASSERT_EQ(0, getIntValue(y)); ASSERT_EQ(Operation::add, c.getOperation()); ASSERT_EQ(-9, getIntValue(m)); } TEST_MEM(MemMinusSpecial5) { Calculator c; Register &x = c.getX(); Register &y = c.getY(); Register &m = c.getM(); c.input(Button::d2); c.input(Button::plus); c.input(Button::d3); c.input(Button::equals); ASSERT_EQ(5, getIntValue(x)); ASSERT_EQ(3, getIntValue(y)); ASSERT_EQ(Operation::add, c.getOperation()); ASSERT_EQ(0, getIntValue(m)); c.input(Button::memMinus); ASSERT_EQ(5, getIntValue(x)); ASSERT_EQ(3, getIntValue(y)); ASSERT_EQ(Operation::add, c.getOperation()); ASSERT_EQ(-5, getIntValue(m)); c.input(Button::equals); ASSERT_EQ(8, getIntValue(x)); ASSERT_EQ(3, getIntValue(y)); ASSERT_EQ(Operation::add, c.getOperation()); ASSERT_EQ(-5, getIntValue(m)); } TEST_MEM(MemMinusSpecial6) { Calculator c; Register &x = c.getX(); Register &y = c.getY(); Register &m = c.getM(); c.input(Button::d2); c.input(Button::mul); c.input(Button::d3); c.input(Button::equals); ASSERT_EQ(6, getIntValue(x)); ASSERT_EQ(2, getIntValue(y)); ASSERT_EQ(Operation::mul, c.getOperation()); ASSERT_EQ(0, getIntValue(m)); c.input(Button::memMinus); ASSERT_EQ(6, getIntValue(x)); ASSERT_EQ(2, getIntValue(y)); ASSERT_EQ(Operation::mul, c.getOperation()); ASSERT_EQ(-6, getIntValue(m)); c.input(Button::equals); ASSERT_EQ(12, getIntValue(x)); ASSERT_EQ(2, getIntValue(y)); ASSERT_EQ(Operation::mul, c.getOperation()); ASSERT_EQ(-6, getIntValue(m)); } //99 * 99999999 m+ => err 98.999999 TEST_MEM(NoMemOnOverflow) { Calculator c(8); Register &x = c.getX(); Register &y = c.getY(); ASSERT_FALSE(c.memHasValue()); c.input(Button::d9); c.input(Button::d9); c.input(Button::mul); for (int8_t i = 0; i < 8; i++) c.input(Button::d9); c.input(Button::memPlus); ASSERT_EQ(98999999, getIntValue(x)); ASSERT_EQ(6, x.getPointPos()); ASSERT_TRUE(x.hasError()); ASSERT_TRUE(y.isZero()); ASSERT_FALSE(c.memHasValue()); c.input(Button::ce); c.input(Button::equals); ASSERT_EQ(98999999, getIntValue(x)); ASSERT_EQ(6, x.getPointPos()); ASSERT_FALSE(x.hasError()); ASSERT_TRUE(y.isZero()); ASSERT_FALSE(c.memHasValue()); } //99999999 m+ 9 m+ => err mem 0 //mr, mc, 1 => err mem 0 //ce => mem 0 //mr => mem 99999999 TEST_MEM(MemOverflow) { Calculator c(8); Register &x = c.getX(); Register &y = c.getY(); Register &m = c.getM(); for (int8_t i = 0; i < 8; i++) c.input(Button::d9); c.input(Button::memPlus); ASSERT_EQ(99999999, getIntValue(x)); ASSERT_EQ(99999999, getIntValue(m)); ASSERT_TRUE(c.memHasValue()); c.input(Button::d9); c.input(Button::memPlus); ASSERT_TRUE(x.isZero()); ASSERT_TRUE(x.hasError()); ASSERT_TRUE(c.memHasValue()); c.input(Button::memR); c.input(Button::memC); c.input(Button::d1); ASSERT_TRUE(x.isZero()); ASSERT_TRUE(x.hasError()); ASSERT_TRUE(c.memHasValue()); c.input(Button::ce); ASSERT_TRUE(x.isZero()); ASSERT_TRUE(x.hasError()); // ce doesn't clear the error ASSERT_TRUE(c.memHasValue()); c.input(Button::ceca); ASSERT_TRUE(x.isZero()); ASSERT_FALSE(x.hasError()); // ceca and ca clear the error ASSERT_TRUE(c.memHasValue()); c.input(Button::memR); ASSERT_EQ(99999999, getIntValue(x)); ASSERT_EQ(99999999, getIntValue(m)); ASSERT_FALSE(x.hasError()); ASSERT_TRUE(c.memHasValue()); } void TestMemTruncatesX(Calculator &c) { Register &x = c.getX(); Register &m = c.getM(); c.input(Button::memC); c.input(Button::ca); for (int8_t i = 0; i < 8; i++) c.input(Button::d9); c.input(Button::memPlus); ASSERT_EQ(99999999, getIntValue(x)); ASSERT_EQ(99999999, getIntValue(m)); ASSERT_TRUE(c.memHasValue()); c.input(Button::point); c.input(Button::d1); c.input(Button::memPlus); ASSERT_FALSE(x.hasError()); uint8_t options = c.getOptions(); if (options & Config::OPTION_MEM_CAN_TRUNC_X) { ASSERT_TRUE(x.isZero()); } else { ASSERT_EQ(1, getIntValue(x)); ASSERT_EQ(1, x.getPointPos()); } ASSERT_EQ(99999999, getIntValue(m)); ASSERT_TRUE(c.memHasValue()); c.input(Button::memR); ASSERT_FALSE(x.hasError()); ASSERT_EQ(99999999, getIntValue(x)); ASSERT_EQ(99999999, getIntValue(m)); ASSERT_TRUE(c.memHasValue()); } // I found two types of acting for different calculators in this test: // Citizen calculators (I'm not sure that all of them) act this way: // 99999999 m+ 0.1 m+ => mem 0 // mr => mem 99999999 // While other calculators I've tested act in the other way: // 99999999 m+ 0.1 m+ => mem 0.0000001 // mr => mem 99999999 TEST_MEM(MemTruncsX) { Calculator c(8); uint8_t options = c.getOptions(); options |= Config::OPTION_MEM_CAN_TRUNC_X; c.setOptions(options); TestMemTruncatesX(c); options &= ~Config::OPTION_MEM_CAN_TRUNC_X; c.setOptions(options); TestMemTruncatesX(c); } TEST_MEM(DivMemRestore) { Calculator c(8); Register &x = c.getX(); Register &y = c.getY(); Register &m = c.getM(); c.input(Button::d2); c.input(Button::memPlus); c.input(Button::d8); c.input(Button::div); ASSERT_EQ(8, getIntValue(x)); ASSERT_EQ(0, getIntValue(y)); ASSERT_EQ(2, getIntValue(m)); c.input(Button::memR); ASSERT_EQ(2, getIntValue(x)); ASSERT_EQ(8, getIntValue(y)); ASSERT_EQ(2, getIntValue(m)); c.input(Button::equals); ASSERT_EQ(4, getIntValue(x)); ASSERT_EQ(2, getIntValue(y)); ASSERT_EQ(2, getIntValue(m)); c.input(Button::equals); ASSERT_EQ(2, getIntValue(x)); ASSERT_EQ(2, getIntValue(y)); ASSERT_EQ(2, getIntValue(m)); } TEST_MEM(MulMemRestore) { Calculator c(8); Register &x = c.getX(); Register &y = c.getY(); Register &m = c.getM(); c.input(Button::d2); c.input(Button::memPlus); c.input(Button::d3); ASSERT_EQ(3, getIntValue(x)); ASSERT_EQ(0, getIntValue(y)); ASSERT_EQ(2, getIntValue(m)); c.input(Button::mul); c.input(Button::memR); ASSERT_EQ(2, getIntValue(x)); ASSERT_EQ(3, getIntValue(y)); ASSERT_EQ(2, getIntValue(m)); c.input(Button::equals); ASSERT_EQ(6, getIntValue(x)); ASSERT_EQ(3, getIntValue(y)); ASSERT_EQ(2, getIntValue(m)); c.input(Button::equals); ASSERT_EQ(18, getIntValue(x)); ASSERT_EQ(3, getIntValue(y)); ASSERT_EQ(2, getIntValue(m)); }
/* -------------------------------------------------------------------------- */ /* Copyright 2002-2019, OpenNebula Project, OpenNebula Systems */ /* */ /* 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 <climits> #include "AclManager.h" #include "PoolObjectAuth.h" #include "SqlDB.h" /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ const char * AclManager::table = "acl"; const char * AclManager::db_names = "oid, user, resource, rights, zone"; const char * AclManager::db_bootstrap = "CREATE TABLE IF NOT EXISTS " "acl (oid INT PRIMARY KEY, user BIGINT, resource BIGINT, " "rights BIGINT, zone BIGINT, UNIQUE(user, resource, rights, zone))"; /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ static int get_lastOID(SqlDB * db) { ostringstream oss; int _last_oid = -1; single_cb<int> cb; cb.set_callback(&_last_oid); oss << "SELECT last_oid FROM pool_control WHERE tablename='acl'"; db->exec_rd(oss, &cb); cb.unset_callback(); return _last_oid; } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ static void set_lastOID(SqlDB * db, int lastOID) { ostringstream oss; oss << "REPLACE INTO pool_control (tablename, last_oid) VALUES ('acl'," << lastOID << ")"; db->exec_wr(oss); } /* -------------------------------------------------------------------------- */ AclManager::AclManager( SqlDB * _db, int _zone_id, bool _is_federation_slave, time_t _timer_period) :zone_id(_zone_id), db(_db), is_federation_slave(_is_federation_slave), timer_period(_timer_period) { int lastOID; pthread_mutex_init(&mutex, 0); am.addListener(this); //Federation slaves do not need to init the pool if (is_federation_slave) { return; } lastOID = get_lastOID(db); if (lastOID == -1) { // Add a default rules for the ACL engine string error_str; // Users in group USERS can create standard resources // @1 VM+IMAGE+TEMPLATE+DOCUMENT+SECGROUP+VMGROUP/* CREATE * add_rule(AclRule::GROUP_ID | 1, AclRule::ALL_ID | PoolObjectSQL::VM | PoolObjectSQL::IMAGE | PoolObjectSQL::TEMPLATE | PoolObjectSQL::DOCUMENT | PoolObjectSQL::SECGROUP | PoolObjectSQL::VMGROUP, AuthRequest::CREATE, AclRule::ALL_ID, error_str); // * ZONE/* USE * add_rule(AclRule::ALL_ID, AclRule::ALL_ID | PoolObjectSQL::ZONE, AuthRequest::USE, AclRule::ALL_ID, error_str); // * MARKETPLACE+MARKETPLACEAPP/* USE * add_rule(AclRule::ALL_ID, AclRule::ALL_ID | PoolObjectSQL::MARKETPLACE | PoolObjectSQL::MARKETPLACEAPP, AuthRequest::USE, AclRule::ALL_ID, error_str); } } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ extern "C" void * acl_action_loop(void *arg) { AclManager * aclm; if ( arg == 0 ) { return 0; } NebulaLog::log("ACL",Log::INFO,"ACL Manager started."); aclm = static_cast<AclManager *>(arg); aclm->am.loop(aclm->timer_period); NebulaLog::log("ACL",Log::INFO,"ACL Manager stopped."); return 0; } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ int AclManager::start() { int rc; NebulaLog::log("ACL",Log::INFO,"Starting ACL Manager..."); rc = select(); if (is_federation_slave) { pthread_attr_t pattr; pthread_attr_init (&pattr); pthread_attr_setdetachstate (&pattr, PTHREAD_CREATE_JOINABLE); rc += pthread_create(&acl_thread,&pattr,acl_action_loop,(void *) this); } else { NebulaLog::log("ACL",Log::INFO,"ACL Manager started."); } return rc; } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ void AclManager::finalize() { if (is_federation_slave) { am.finalize(); } else { NebulaLog::log("ACL",Log::INFO,"ACL Manager stopped."); } } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ AclManager::~AclManager() { multimap<long long, AclRule *>::iterator it; lock(); for ( it = acl_rules.begin(); it != acl_rules.end(); it++ ) { delete it->second; } unlock(); pthread_mutex_destroy(&mutex); } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ const bool AclManager::authorize( int uid, const set<int>& user_groups, const PoolObjectAuth& obj_perms, AuthRequest::Operation op) { bool auth = false; // Build masks for request long long user_req; long long resource_oid_req; if (static_cast<long long int>(op) & 0x10LL) //No lockable object { op = static_cast<AuthRequest::Operation>(op & 0x0FLL); } else if (obj_perms.locked > 0 && obj_perms.locked <= static_cast<long long int>(op)) { return false; } if ( obj_perms.oid >= 0 ) { resource_oid_req = obj_perms.obj_type | AclRule::INDIVIDUAL_ID | obj_perms.oid; } else { resource_oid_req = AclRule::NONE_ID; } long long resource_gid_req; if ((obj_perms.gid >= 0) && (!obj_perms.disable_group_acl)) { resource_gid_req = obj_perms.obj_type | AclRule::GROUP_ID | obj_perms.gid; } else { resource_gid_req = AclRule::NONE_ID; } set<long long> resource_cid_req; if (!obj_perms.disable_cluster_acl) { set<int>::iterator i; for(i = obj_perms.cids.begin(); i != obj_perms.cids.end(); i++) { resource_cid_req.insert( obj_perms.obj_type | AclRule::CLUSTER_ID | *i ); } } long long resource_all_req ; if (!obj_perms.disable_all_acl) { resource_all_req = obj_perms.obj_type | AclRule::ALL_ID; } else { resource_all_req = AclRule::NONE_ID; } long long rights_req = op; long long resource_oid_mask = obj_perms.obj_type | AclRule::INDIVIDUAL_ID | 0x00000000FFFFFFFFLL; long long resource_gid_mask = obj_perms.obj_type | AclRule::GROUP_ID | 0x00000000FFFFFFFFLL; long long resource_cid_mask = obj_perms.obj_type | AclRule::CLUSTER_ID | 0x00000000FFFFFFFFLL; if (NebulaLog::log_level() >= Log::DDEBUG) { ostringstream oss; // Create a temporal rule, to log the request long long log_resource; if ( obj_perms.oid >= 0 ) { log_resource = resource_oid_req; } else if ( obj_perms.gid >= 0 ) { log_resource = resource_gid_req; } else { log_resource = resource_all_req; } AclRule log_rule(-1, AclRule::INDIVIDUAL_ID | uid, log_resource, rights_req, AclRule::INDIVIDUAL_ID | zone_id); oss << "Request " << log_rule.to_str(); NebulaLog::log("ACL",Log::DDEBUG,oss); } // ------------------------------------------------------------------------- // Create temporary rules from the object permissions // ------------------------------------------------------------------------- AclRule owner_rule; AclRule group_rule; AclRule other_rule; multimap<long long, AclRule *> tmp_rules; obj_perms.get_acl_rules(owner_rule, group_rule, other_rule, zone_id); tmp_rules.insert( make_pair(owner_rule.user, &owner_rule) ); tmp_rules.insert( make_pair(group_rule.user, &group_rule) ); tmp_rules.insert( make_pair(other_rule.user, &other_rule) ); // ------------------------------------------------------------------------- // Look for rules that apply to everyone // ------------------------------------------------------------------------- user_req = AclRule::ALL_ID; auth = match_rules_wrapper(user_req, resource_oid_req, resource_gid_req, resource_cid_req, resource_all_req, rights_req, resource_oid_mask, resource_gid_mask, resource_cid_mask, tmp_rules); if ( auth == true ) { return true; } // ------------------------------------------------------------------------- // Look for rules that apply to the individual user id // ------------------------------------------------------------------------- user_req = AclRule::INDIVIDUAL_ID | uid; auth = match_rules_wrapper(user_req, resource_oid_req, resource_gid_req, resource_cid_req, resource_all_req, rights_req, resource_oid_mask, resource_gid_mask, resource_cid_mask, tmp_rules); if ( auth == true ) { return true; } // ---------------------------------------------------------- // Look for rules that apply to each one of the user's groups // ---------------------------------------------------------- set<int>::iterator g_it; for (g_it = user_groups.begin(); g_it != user_groups.end(); g_it++) { user_req = AclRule::GROUP_ID | *g_it; auth = match_rules_wrapper(user_req, resource_oid_req, resource_gid_req, resource_cid_req, resource_all_req, rights_req, resource_oid_mask, resource_gid_mask, resource_cid_mask, tmp_rules); if ( auth == true ) { return true; } } NebulaLog::log("ACL",Log::DDEBUG,"No more rules, permission not granted "); return false; } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ const bool AclManager::oneadmin_authorize( const PoolObjectAuth& obj_perms, AuthRequest::Operation op) { if (static_cast<long long int>(op) & 0x10LL) //No lockable object { return true; } else if (obj_perms.locked > 0 && obj_perms.locked <= static_cast<long long int>(op)) { return false; } return true; } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ bool AclManager::match_rules_wrapper( long long user_req, long long resource_oid_req, long long resource_gid_req, const set<long long>& resource_cid_req, long long resource_all_req, long long rights_req, long long individual_obj_type, long long group_obj_type, long long cluster_obj_type, const multimap<long long, AclRule*> &tmp_rules) { bool auth = false; // Match against the tmp rules auth = match_rules( user_req, resource_oid_req, resource_gid_req, resource_cid_req, resource_all_req, rights_req, individual_obj_type, group_obj_type, cluster_obj_type, tmp_rules); if ( auth == true ) { return true; } // Match against the internal rules lock(); auth = match_rules( user_req, resource_oid_req, resource_gid_req, resource_cid_req, resource_all_req, rights_req, individual_obj_type, group_obj_type, cluster_obj_type, acl_rules); unlock(); return auth; } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ static bool match_cluster_req( const set<long long> &resource_cid_req, long long resource_cid_mask, long long rule_resource) { set<long long>::iterator i; for(i = resource_cid_req.begin(); i != resource_cid_req.end(); i++) { // rule's object type and cluster object ID match if ( ( rule_resource & resource_cid_mask ) == *i ) { return true; } } return false; } /* -------------------------------------------------------------------------- */ bool AclManager::match_rules( long long user_req, long long resource_oid_req, long long resource_gid_req, const set<long long>& resource_cid_req, long long resource_all_req, long long rights_req, long long resource_oid_mask, long long resource_gid_mask, long long resource_cid_mask, const multimap<long long, AclRule*> &rules) { bool auth = false; ostringstream oss; multimap<long long, AclRule *>::const_iterator it; pair<multimap<long long, AclRule *>::const_iterator, multimap<long long, AclRule *>::const_iterator> index; long long zone_oid_mask = AclRule::INDIVIDUAL_ID | 0x00000000FFFFFFFFLL; long long zone_req = AclRule::INDIVIDUAL_ID | zone_id; long long zone_all_req = AclRule::ALL_ID; index = rules.equal_range( user_req ); for ( it = index.first; it != index.second; it++) { if (NebulaLog::log_level() >= Log::DDEBUG) { oss.str(""); oss << "> Rule " << it->second->to_str(); NebulaLog::log("ACL",Log::DDEBUG,oss); } auth = ( // Rule applies in any Zone ( ( it->second->zone & zone_all_req ) == zone_all_req ) || // Rule applies in this Zone ( ( it->second->zone & zone_oid_mask ) == zone_req ) ) && // Rule grants the requested rights ( ( it->second->rights & rights_req ) == rights_req ) && ( // Rule grants permission for all objects of this type ( ( it->second->resource & resource_all_req ) == resource_all_req ) || // Or rule's object type and group object ID match ( ( it->second->resource & resource_gid_mask ) == resource_gid_req ) || // Or rule's object type and individual object ID match ( ( it->second->resource & resource_oid_mask ) == resource_oid_req ) || // Or rule's object type and one of the cluster object ID match match_cluster_req(resource_cid_req, resource_cid_mask, it->second->resource) ); if ( auth == true ) { NebulaLog::log("ACL",Log::DDEBUG,"Permission granted"); break; } } return auth; } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ int AclManager::add_rule(long long user, long long resource, long long rights, long long zone, string& error_str) { if (is_federation_slave) { NebulaLog::log("ONE",Log::ERROR, "AclManager::add_rule called, but this " "OpenNebula is a federation slave"); return -1; } lock(); int lastOID = get_lastOID(db); if (lastOID == INT_MAX) { lastOID = -1; } AclRule * rule = new AclRule(++lastOID, user, resource, rights, zone); ostringstream oss; int rc; multimap<long long, AclRule *>::iterator it; pair<multimap<long long, AclRule *>::iterator, multimap<long long, AclRule *>::iterator> index; bool found = false; index = acl_rules.equal_range( user ); for ( it = index.first; (it != index.second && !found); it++) { found = *(it->second) == *rule; } if ( found ) { goto error_duplicated; } if ( rule->malformed(error_str) ) { goto error_malformed; } rc = insert(rule); if ( rc != 0 ) { goto error_insert; } acl_rules.insert( make_pair(rule->user, rule) ); acl_rules_oids.insert( make_pair(rule->oid, rule) ); set_lastOID(db, lastOID); unlock(); return lastOID; error_duplicated: oss << "Rule " << rule->to_str() << " already exists"; rc = -1; goto error_common; error_malformed: oss << "Rule " << rule->to_str() << " is malformed: " << error_str; rc = -2; goto error_common; error_insert: oss << "Error inserting rule in DB"; rc = -3; goto error_common; error_common: error_str = oss.str(); delete rule; unlock(); return rc; } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ int AclManager::del_rule(int oid, string& error_str) { multimap<long long, AclRule *>::iterator it; pair<multimap<long long, AclRule *>::iterator, multimap<long long, AclRule *>::iterator> index; AclRule * rule; int rc; bool found = false; if (is_federation_slave) { NebulaLog::log("ONE",Log::ERROR, "AclManager::del_rule called, but this " "OpenNebula is a federation slave"); return -1; } lock(); // Check the rule exists found = acl_rules_oids.count(oid) > 0; if ( !found ) { ostringstream oss; oss << "Rule " << oid << " does not exist"; error_str = oss.str(); unlock(); return -1; } rule = acl_rules_oids[oid]; // Look for it in the multimap found = false; index = acl_rules.equal_range( rule->user ); it = index.first; while ( !found && it != index.second ) { found = *rule == *(it->second); if ( !found ) { it++; } } if ( !found ) { ostringstream oss; oss << "Internal error: ACL Rule " << oid << " indexed by oid, but not in by user attribute"; NebulaLog::log("ACL",Log::ERROR,oss); unlock(); return -1; } rc = drop( oid ); if ( rc != 0 ) { error_str = "SQL DB error"; unlock(); return -1; } rule = it->second; acl_rules.erase( it ); acl_rules_oids.erase( oid ); delete rule; unlock(); return 0; } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ int AclManager::del_rule( long long user, long long resource, long long rights, long long zone, string& error_str) { lock(); AclRule * rule = new AclRule(-1, user, resource, rights, zone); int oid = -1; bool found = false; multimap<long long, AclRule *>::iterator it; pair<multimap<long long, AclRule *>::iterator, multimap<long long, AclRule *>::iterator> index; index = acl_rules.equal_range( user ); for ( it = index.first; (it != index.second && !found); it++) { found = *(it->second) == *rule; if (found) { oid = it->second->get_oid(); } } unlock(); if (oid != -1) { return del_rule(oid, error_str); } else { error_str = "Rule does not exist"; return -1; } } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ void AclManager::del_uid_rules(int uid) { long long user_req = AclRule::INDIVIDUAL_ID | uid; // Delete rules that match // #uid __/__ __ del_user_matching_rules(user_req); } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ void AclManager::del_gid_rules(int gid) { long long request = AclRule::GROUP_ID | gid; long long resource_gid_mask = AclRule::GROUP_ID | 0x00000000FFFFFFFFLL; // Delete rules that match // @gid __/__ __ del_user_matching_rules(request); // __ __/@gid __ del_resource_matching_rules(request, resource_gid_mask); } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ void AclManager::del_cid_rules(int cid) { long long request = AclRule::CLUSTER_ID | cid; long long resource_gid_mask = AclRule::CLUSTER_ID | 0x00000000FFFFFFFFLL; // Delete rules that match // __ __/%cid __ del_resource_matching_rules(request, resource_gid_mask); } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ void AclManager::del_zid_rules(int zid) { long long request = AclRule::INDIVIDUAL_ID | zid; // Delete rules that match // __ __/__ __ #zid del_zone_matching_rules(request); } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ void AclManager::del_resource_rules(int oid, PoolObjectSQL::ObjectType obj_type) { long long request = obj_type | AclRule::INDIVIDUAL_ID | oid; long long mask = 0xFFFFFFFFFFFFFFFFLL; // Delete rules that are an exact match, i.e. for oid=7 and obj_type=IMAGE, // this rule applies, but can't be deleted: // __ IMAGE+TEMPLATE/#7 __ del_resource_matching_rules(request, mask); } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ void AclManager::del_user_matching_rules(long long user_req) { multimap<long long, AclRule *>::iterator it; pair<multimap<long long, AclRule *>::iterator, multimap<long long, AclRule *>::iterator> index; vector<int> oids; vector<int>::iterator oid_it; string error_str; lock(); index = acl_rules.equal_range( user_req ); for ( it = index.first; it != index.second; it++) { oids.push_back(it->second->oid); } unlock(); for ( oid_it = oids.begin() ; oid_it < oids.end(); oid_it++ ) { del_rule(*oid_it, error_str); } } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ void AclManager::del_resource_matching_rules(long long resource_req, long long resource_mask) { multimap<long long, AclRule *>::iterator it; vector<int> oids; vector<int>::iterator oid_it; string error_str; lock(); for ( it = acl_rules.begin(); it != acl_rules.end(); it++ ) { if ( ( it->second->resource & resource_mask ) == resource_req ) { oids.push_back(it->second->oid); } } unlock(); for ( oid_it = oids.begin() ; oid_it < oids.end(); oid_it++ ) { del_rule(*oid_it, error_str); } } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ void AclManager::del_zone_matching_rules(long long zone_req) { multimap<long long, AclRule *>::iterator it; vector<int> oids; vector<int>::iterator oid_it; string error_str; lock(); for ( it = acl_rules.begin(); it != acl_rules.end(); it++ ) { if ( it->second->zone == zone_req ) { oids.push_back(it->second->oid); } } unlock(); for ( oid_it = oids.begin() ; oid_it < oids.end(); oid_it++ ) { del_rule(*oid_it, error_str); } } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ void AclManager::reverse_search(int uid, const set<int>& user_groups, PoolObjectSQL::ObjectType obj_type, AuthRequest::Operation op, bool disable_all_acl, bool disable_cluster_acl, bool disable_group_acl, bool& all, vector<int>& oids, vector<int>& gids, vector<int>& cids) { ostringstream oss; multimap<long long, AclRule *>::iterator it; pair<multimap<long long, AclRule *>::iterator, multimap<long long, AclRule *>::iterator> index; // Build masks for request long long resource_oid_req = obj_type | AclRule::INDIVIDUAL_ID; long long resource_gid_req = obj_type | AclRule::GROUP_ID; long long resource_all_req = obj_type | AclRule::ALL_ID; long long resource_cid_req = obj_type | AclRule::CLUSTER_ID; long long rights_req = op; long long resource_oid_mask = ( obj_type | AclRule::INDIVIDUAL_ID ); long long resource_gid_mask = ( obj_type | AclRule::GROUP_ID ); long long resource_cid_mask = ( obj_type | AclRule::CLUSTER_ID ); long long zone_oid_req = AclRule::INDIVIDUAL_ID | zone_id; long long zone_all_req = AclRule::ALL_ID; if (NebulaLog::log_level() >= Log::DDEBUG) { // Create a temporal rule, to log the request long long log_resource; log_resource = resource_all_req; AclRule log_rule(-1, AclRule::INDIVIDUAL_ID | uid, log_resource, rights_req, zone_oid_req); oss << "Reverse search request " << log_rule.to_str(); NebulaLog::log("ACL",Log::DDEBUG,oss); } // --------------------------------------------------- // Look for the rules that match // --------------------------------------------------- vector<long long> user_reqs; vector<long long>::iterator reqs_it; set<int>::iterator g_it; // rules that apply to everyone user_reqs.push_back(AclRule::ALL_ID); // rules that apply to the individual user id user_reqs.push_back(AclRule::INDIVIDUAL_ID | uid); // rules that apply to each one of the user's groups for (g_it = user_groups.begin(); g_it != user_groups.end(); g_it++) { user_reqs.push_back(AclRule::GROUP_ID | *g_it); } all = false; for (reqs_it = user_reqs.begin(); reqs_it != user_reqs.end(); reqs_it++) { lock(); index = acl_rules.equal_range( *reqs_it ); for ( it = index.first; it != index.second; it++) { // Rule grants the requested rights if ( ( ( it->second->rights & rights_req ) == rights_req ) && // Rule applies in this zone or in all zones ( ( it->second->zone == zone_oid_req ) || ( it->second->zone == zone_all_req ) ) ) { if (NebulaLog::log_level() >= Log::DDEBUG) { oss.str(""); oss << "> Rule " << it->second->to_str(); NebulaLog::log("ACL",Log::DDEBUG,oss); } // Rule grants permission for all objects of this type if ((!disable_all_acl) && ((it->second->resource & resource_all_req) == resource_all_req)) { all = true; break; } // Rule grants permission for all objects of a group else if ((!disable_group_acl) && ((it->second->resource & resource_gid_mask) == resource_gid_req)) { gids.push_back(it->second->resource_id()); } // Rule grants permission for all objects of a cluster else if ((!disable_cluster_acl) && ((it->second->resource & resource_cid_mask) == resource_cid_req)) { cids.push_back(it->second->resource_id()); } // Rule grants permission for an individual object else if ((it->second->resource & resource_oid_mask) == resource_oid_req) { oids.push_back(it->second->resource_id()); } } } unlock(); if ( all == true ) { oids.clear(); gids.clear(); cids.clear(); } } } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ int AclManager::bootstrap(SqlDB * _db) { ostringstream oss(db_bootstrap); return _db->exec_local_wr(oss); } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ int AclManager::select_cb(void *nil, int num, char **values, char **names) { if ( (num != 5) || (!values[0]) || (!values[1]) || (!values[2]) || (!values[3]) || (!values[4]) ) { return -1; } istringstream iss; int oid = atoi(values[0]); long long rule_values[4]; for ( int i = 0; i < 4; i++ ) { iss.str( values[i+1] ); iss >> rule_values[i]; if ( iss.fail() == true ) { return -1; } iss.clear(); } AclRule * rule = new AclRule(oid, rule_values[0], rule_values[1], rule_values[2], rule_values[3]); if (NebulaLog::log_level() >= Log::DDEBUG) { ostringstream oss; oss << "Loading ACL Rule " << rule->to_str(); NebulaLog::log("ACL",Log::DDEBUG,oss); } acl_rules.insert( make_pair(rule->user, rule) ); acl_rules_oids.insert( make_pair(rule->oid, rule) ); return 0; } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ int AclManager::select() { multimap<long long, AclRule *>::iterator it; ostringstream oss; int rc; oss << "SELECT " << db_names << " FROM " << table; set_callback(static_cast<Callbackable::Callback>(&AclManager::select_cb)); lock(); for ( it = acl_rules.begin(); it != acl_rules.end(); it++ ) { delete it->second; } acl_rules.clear(); acl_rules_oids.clear(); rc = db->exec_rd(oss,this); unlock(); unset_callback(); return rc; } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ int AclManager::insert(AclRule * rule, SqlDB * db) { ostringstream oss; int rc; // Construct the SQL statement to Insert oss << "INSERT INTO " << table <<" ("<< db_names <<") VALUES (" << rule->oid << "," << rule->user << "," << rule->resource << "," << rule->rights << "," << rule->zone << ")"; rc = db->exec_wr(oss); return rc; } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ int AclManager::drop(int oid) { ostringstream oss; int rc; oss << "DELETE FROM " << table << " WHERE " << "oid=" << oid; rc = db->exec_wr(oss); return rc; } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ int AclManager::dump(ostringstream& oss) { map<int, AclRule *>::iterator it; string xml; lock(); oss << "<ACL_POOL>"; for ( it = acl_rules_oids.begin() ; it != acl_rules_oids.end(); it++ ) { oss << it->second->to_xml(xml); } oss << "</ACL_POOL>"; unlock(); return 0; } /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */
; void sp1_PutTilesInv(struct sp1_Rect *r, struct sp1_tp *src) SECTION code_clib SECTION code_temp_sp1 PUBLIC _sp1_PutTilesInv EXTERN l0_sp1_PutTilesInv_callee _sp1_PutTilesInv: pop af pop hl pop de push de push hl push af jp l0_sp1_PutTilesInv_callee
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; ;;; Microsoft Research Singularity ;;; ;;; Copyright (c) Microsoft Corporation. All rights reserved. ;;; ;;; This file contains ARM-specific assembly code. ;;; ; Signed divide of r1 by r0 ; Return: ; r0 - quotient ; r1 - remainder OPT 2 ; disable listing INCLUDE kxarm.inc OPT 1 ; reenable listing IMPORT __rt_div0 IF Thumbing AREA |.text|, CODE, READONLY, THUMB ELSE AREA |.text|, CODE, READONLY ENDIF EXPORT |__rt_sdiv| [FUNC] |__rt_sdiv| IF Thumbing ; Switch from Thumb mode to ARM mode DCW 0x4778 ; bx pc DCW 0x46C0 ; nop ENDIF ANDS a4, r0, #&80000000 RSBMI r0, r0, #0 EORS ip, a4, r1, ASR #32 RSBCS r1, r1, #0 MOVS a3, r0 BEQ DivideByZero while CMP a3, r1, LSR #8 MOVLS a3, a3, LSL #8 BLO while CMP a3, r1, LSR #1 BHI goto7 CMP a3, r1, LSR #2 BHI goto6 CMP a3, r1, LSR #3 BHI goto5 CMP a3, r1, LSR #4 BHI goto4 CMP a3, r1, LSR #5 BHI goto3 CMP a3, r1, LSR #6 BHI goto2 CMP a3, r1, LSR #7 BHI goto1 loop MOVHI a3, a3, LSR #8 CMP r1, a3, LSL #7 ADC a4, a4, a4 SUBCS r1, r1, a3, LSL #7 CMP r1, a3, LSL #6 goto1 ADC a4, a4, a4 SUBCS r1, r1, a3, LSL #6 CMP r1, a3, LSL #5 goto2 ADC a4, a4, a4 SUBCS r1, r1, a3, LSL #5 CMP r1, a3, LSL #4 goto3 ADC a4, a4, a4 SUBCS r1, r1, a3, LSL #4 CMP r1, a3, LSL #3 goto4 ADC a4, a4, a4 SUBCS r1, r1, a3, LSL #3 CMP r1, a3, LSL #2 goto5 ADC a4, a4, a4 SUBCS r1, r1, a3, LSL #2 CMP r1, a3, LSL #1 goto6 ADC a4, a4, a4 SUBCS r1, r1, a3, LSL #1 goto7 CMP r1, a3 ADC a4, a4, a4 SUBCS r1, r1, a3 CMP a3, r0 BNE loop MOV r0, a4 MOVS ip, ip, ASL #1 RSBCS r0, r0, #0 RSBMI r1, r1, #0 end IF Interworking :LOR: Thumbing BX lr ELSE MOV pc, lr ENDIF ; ; Divide by zero has occurred. Raise an exception ; call RaiseException(STATUS_INTEGER_DIVIDE_BY_ZERO, 0, 0, NULL) ; DivideByZero ldr r12, =__rt_div0 ldr r0, =0xC0000094 mov r1, #0 mov r2, #0 mov r3, #0 IF Thumbing bx r12 ELSE mov pc, r12 ENDIF END
; A133398: Numbers that are not Mersenne primes. ; 1,2,4,5,6,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,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 add $0,1 mov $3,1 add $3,$0 sub $0,1 mov $1,$3 mov $2,$3 lpb $0 trn $0,$2 add $1,1 add $2,3 mul $3,2 sub $3,$2 sub $2,2 mul $3,2 add $3,1 trn $3,$2 add $3,1 add $0,$3 lpe sub $1,1
//===---- CGObjC.cpp - Emit LLVM Code for Objective-C ---------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This contains code to emit Objective-C code as LLVM code. // //===----------------------------------------------------------------------===// #include "CGDebugInfo.h" #include "CGObjCRuntime.h" #include "CodeGenFunction.h" #include "CodeGenModule.h" #include "ConstantEmitter.h" #include "TargetInfo.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Attr.h" #include "clang/AST/DeclObjC.h" #include "clang/AST/StmtObjC.h" #include "clang/Basic/Diagnostic.h" #include "clang/CodeGen/CGFunctionInfo.h" #include "llvm/ADT/STLExtras.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/InlineAsm.h" using namespace clang; using namespace CodeGen; typedef llvm::PointerIntPair<llvm::Value*,1,bool> TryEmitResult; static TryEmitResult tryEmitARCRetainScalarExpr(CodeGenFunction &CGF, const Expr *e); static RValue AdjustObjCObjectType(CodeGenFunction &CGF, QualType ET, RValue Result); /// Given the address of a variable of pointer type, find the correct /// null to store into it. static llvm::Constant *getNullForVariable(Address addr) { llvm::Type *type = addr.getElementType(); return llvm::ConstantPointerNull::get(cast<llvm::PointerType>(type)); } /// Emits an instance of NSConstantString representing the object. llvm::Value *CodeGenFunction::EmitObjCStringLiteral(const ObjCStringLiteral *E) { llvm::Constant *C = CGM.getObjCRuntime().GenerateConstantString(E->getString()).getPointer(); // FIXME: This bitcast should just be made an invariant on the Runtime. return llvm::ConstantExpr::getBitCast(C, ConvertType(E->getType())); } /// EmitObjCBoxedExpr - This routine generates code to call /// the appropriate expression boxing method. This will either be /// one of +[NSNumber numberWith<Type>:], or +[NSString stringWithUTF8String:], /// or [NSValue valueWithBytes:objCType:]. /// llvm::Value * CodeGenFunction::EmitObjCBoxedExpr(const ObjCBoxedExpr *E) { // Generate the correct selector for this literal's concrete type. // Get the method. const ObjCMethodDecl *BoxingMethod = E->getBoxingMethod(); const Expr *SubExpr = E->getSubExpr(); if (E->isExpressibleAsConstantInitializer()) { ConstantEmitter ConstEmitter(CGM); return ConstEmitter.tryEmitAbstract(E, E->getType()); } assert(BoxingMethod->isClassMethod() && "BoxingMethod must be a class method"); Selector Sel = BoxingMethod->getSelector(); // Generate a reference to the class pointer, which will be the receiver. // Assumes that the method was introduced in the class that should be // messaged (avoids pulling it out of the result type). CGObjCRuntime &Runtime = CGM.getObjCRuntime(); const ObjCInterfaceDecl *ClassDecl = BoxingMethod->getClassInterface(); llvm::Value *Receiver = Runtime.GetClass(*this, ClassDecl); CallArgList Args; const ParmVarDecl *ArgDecl = *BoxingMethod->param_begin(); QualType ArgQT = ArgDecl->getType().getUnqualifiedType(); // ObjCBoxedExpr supports boxing of structs and unions // via [NSValue valueWithBytes:objCType:] const QualType ValueType(SubExpr->getType().getCanonicalType()); if (ValueType->isObjCBoxableRecordType()) { // Emit CodeGen for first parameter // and cast value to correct type Address Temporary = CreateMemTemp(SubExpr->getType()); EmitAnyExprToMem(SubExpr, Temporary, Qualifiers(), /*isInit*/ true); Address BitCast = Builder.CreateBitCast(Temporary, ConvertType(ArgQT)); Args.add(RValue::get(BitCast.getPointer()), ArgQT); // Create char array to store type encoding std::string Str; getContext().getObjCEncodingForType(ValueType, Str); llvm::Constant *GV = CGM.GetAddrOfConstantCString(Str).getPointer(); // Cast type encoding to correct type const ParmVarDecl *EncodingDecl = BoxingMethod->parameters()[1]; QualType EncodingQT = EncodingDecl->getType().getUnqualifiedType(); llvm::Value *Cast = Builder.CreateBitCast(GV, ConvertType(EncodingQT)); Args.add(RValue::get(Cast), EncodingQT); } else { Args.add(EmitAnyExpr(SubExpr), ArgQT); } RValue result = Runtime.GenerateMessageSend( *this, ReturnValueSlot(), BoxingMethod->getReturnType(), Sel, Receiver, Args, ClassDecl, BoxingMethod); return Builder.CreateBitCast(result.getScalarVal(), ConvertType(E->getType())); } llvm::Value *CodeGenFunction::EmitObjCCollectionLiteral(const Expr *E, const ObjCMethodDecl *MethodWithObjects) { ASTContext &Context = CGM.getContext(); const ObjCDictionaryLiteral *DLE = nullptr; const ObjCArrayLiteral *ALE = dyn_cast<ObjCArrayLiteral>(E); if (!ALE) DLE = cast<ObjCDictionaryLiteral>(E); // Optimize empty collections by referencing constants, when available. uint64_t NumElements = ALE ? ALE->getNumElements() : DLE->getNumElements(); if (NumElements == 0 && CGM.getLangOpts().ObjCRuntime.hasEmptyCollections()) { StringRef ConstantName = ALE ? "__NSArray0__" : "__NSDictionary0__"; QualType IdTy(CGM.getContext().getObjCIdType()); llvm::Constant *Constant = CGM.CreateRuntimeVariable(ConvertType(IdTy), ConstantName); LValue LV = MakeNaturalAlignAddrLValue(Constant, IdTy); llvm::Value *Ptr = EmitLoadOfScalar(LV, E->getBeginLoc()); cast<llvm::LoadInst>(Ptr)->setMetadata( CGM.getModule().getMDKindID("invariant.load"), llvm::MDNode::get(getLLVMContext(), None)); return Builder.CreateBitCast(Ptr, ConvertType(E->getType())); } // Compute the type of the array we're initializing. llvm::APInt APNumElements(Context.getTypeSize(Context.getSizeType()), NumElements); QualType ElementType = Context.getObjCIdType().withConst(); QualType ElementArrayType = Context.getConstantArrayType(ElementType, APNumElements, nullptr, ArrayType::Normal, /*IndexTypeQuals=*/0); // Allocate the temporary array(s). Address Objects = CreateMemTemp(ElementArrayType, "objects"); Address Keys = Address::invalid(); if (DLE) Keys = CreateMemTemp(ElementArrayType, "keys"); // In ARC, we may need to do extra work to keep all the keys and // values alive until after the call. SmallVector<llvm::Value *, 16> NeededObjects; bool TrackNeededObjects = (getLangOpts().ObjCAutoRefCount && CGM.getCodeGenOpts().OptimizationLevel != 0); // Perform the actual initialialization of the array(s). for (uint64_t i = 0; i < NumElements; i++) { if (ALE) { // Emit the element and store it to the appropriate array slot. const Expr *Rhs = ALE->getElement(i); LValue LV = MakeAddrLValue(Builder.CreateConstArrayGEP(Objects, i), ElementType, AlignmentSource::Decl); llvm::Value *value = EmitScalarExpr(Rhs); EmitStoreThroughLValue(RValue::get(value), LV, true); if (TrackNeededObjects) { NeededObjects.push_back(value); } } else { // Emit the key and store it to the appropriate array slot. const Expr *Key = DLE->getKeyValueElement(i).Key; LValue KeyLV = MakeAddrLValue(Builder.CreateConstArrayGEP(Keys, i), ElementType, AlignmentSource::Decl); llvm::Value *keyValue = EmitScalarExpr(Key); EmitStoreThroughLValue(RValue::get(keyValue), KeyLV, /*isInit=*/true); // Emit the value and store it to the appropriate array slot. const Expr *Value = DLE->getKeyValueElement(i).Value; LValue ValueLV = MakeAddrLValue(Builder.CreateConstArrayGEP(Objects, i), ElementType, AlignmentSource::Decl); llvm::Value *valueValue = EmitScalarExpr(Value); EmitStoreThroughLValue(RValue::get(valueValue), ValueLV, /*isInit=*/true); if (TrackNeededObjects) { NeededObjects.push_back(keyValue); NeededObjects.push_back(valueValue); } } } // Generate the argument list. CallArgList Args; ObjCMethodDecl::param_const_iterator PI = MethodWithObjects->param_begin(); const ParmVarDecl *argDecl = *PI++; QualType ArgQT = argDecl->getType().getUnqualifiedType(); Args.add(RValue::get(Objects.getPointer()), ArgQT); if (DLE) { argDecl = *PI++; ArgQT = argDecl->getType().getUnqualifiedType(); Args.add(RValue::get(Keys.getPointer()), ArgQT); } argDecl = *PI; ArgQT = argDecl->getType().getUnqualifiedType(); llvm::Value *Count = llvm::ConstantInt::get(CGM.getTypes().ConvertType(ArgQT), NumElements); Args.add(RValue::get(Count), ArgQT); // Generate a reference to the class pointer, which will be the receiver. Selector Sel = MethodWithObjects->getSelector(); QualType ResultType = E->getType(); const ObjCObjectPointerType *InterfacePointerType = ResultType->getAsObjCInterfacePointerType(); ObjCInterfaceDecl *Class = InterfacePointerType->getObjectType()->getInterface(); CGObjCRuntime &Runtime = CGM.getObjCRuntime(); llvm::Value *Receiver = Runtime.GetClass(*this, Class); // Generate the message send. RValue result = Runtime.GenerateMessageSend( *this, ReturnValueSlot(), MethodWithObjects->getReturnType(), Sel, Receiver, Args, Class, MethodWithObjects); // The above message send needs these objects, but in ARC they are // passed in a buffer that is essentially __unsafe_unretained. // Therefore we must prevent the optimizer from releasing them until // after the call. if (TrackNeededObjects) { EmitARCIntrinsicUse(NeededObjects); } return Builder.CreateBitCast(result.getScalarVal(), ConvertType(E->getType())); } llvm::Value *CodeGenFunction::EmitObjCArrayLiteral(const ObjCArrayLiteral *E) { return EmitObjCCollectionLiteral(E, E->getArrayWithObjectsMethod()); } llvm::Value *CodeGenFunction::EmitObjCDictionaryLiteral( const ObjCDictionaryLiteral *E) { return EmitObjCCollectionLiteral(E, E->getDictWithObjectsMethod()); } /// Emit a selector. llvm::Value *CodeGenFunction::EmitObjCSelectorExpr(const ObjCSelectorExpr *E) { // Untyped selector. // Note that this implementation allows for non-constant strings to be passed // as arguments to @selector(). Currently, the only thing preventing this // behaviour is the type checking in the front end. return CGM.getObjCRuntime().GetSelector(*this, E->getSelector()); } llvm::Value *CodeGenFunction::EmitObjCProtocolExpr(const ObjCProtocolExpr *E) { // FIXME: This should pass the Decl not the name. return CGM.getObjCRuntime().GenerateProtocolRef(*this, E->getProtocol()); } /// Adjust the type of an Objective-C object that doesn't match up due /// to type erasure at various points, e.g., related result types or the use /// of parameterized classes. static RValue AdjustObjCObjectType(CodeGenFunction &CGF, QualType ExpT, RValue Result) { if (!ExpT->isObjCRetainableType()) return Result; // If the converted types are the same, we're done. llvm::Type *ExpLLVMTy = CGF.ConvertType(ExpT); if (ExpLLVMTy == Result.getScalarVal()->getType()) return Result; // We have applied a substitution. Cast the rvalue appropriately. return RValue::get(CGF.Builder.CreateBitCast(Result.getScalarVal(), ExpLLVMTy)); } /// Decide whether to extend the lifetime of the receiver of a /// returns-inner-pointer message. static bool shouldExtendReceiverForInnerPointerMessage(const ObjCMessageExpr *message) { switch (message->getReceiverKind()) { // For a normal instance message, we should extend unless the // receiver is loaded from a variable with precise lifetime. case ObjCMessageExpr::Instance: { const Expr *receiver = message->getInstanceReceiver(); // Look through OVEs. if (auto opaque = dyn_cast<OpaqueValueExpr>(receiver)) { if (opaque->getSourceExpr()) receiver = opaque->getSourceExpr()->IgnoreParens(); } const ImplicitCastExpr *ice = dyn_cast<ImplicitCastExpr>(receiver); if (!ice || ice->getCastKind() != CK_LValueToRValue) return true; receiver = ice->getSubExpr()->IgnoreParens(); // Look through OVEs. if (auto opaque = dyn_cast<OpaqueValueExpr>(receiver)) { if (opaque->getSourceExpr()) receiver = opaque->getSourceExpr()->IgnoreParens(); } // Only __strong variables. if (receiver->getType().getObjCLifetime() != Qualifiers::OCL_Strong) return true; // All ivars and fields have precise lifetime. if (isa<MemberExpr>(receiver) || isa<ObjCIvarRefExpr>(receiver)) return false; // Otherwise, check for variables. const DeclRefExpr *declRef = dyn_cast<DeclRefExpr>(ice->getSubExpr()); if (!declRef) return true; const VarDecl *var = dyn_cast<VarDecl>(declRef->getDecl()); if (!var) return true; // All variables have precise lifetime except local variables with // automatic storage duration that aren't specially marked. return (var->hasLocalStorage() && !var->hasAttr<ObjCPreciseLifetimeAttr>()); } case ObjCMessageExpr::Class: case ObjCMessageExpr::SuperClass: // It's never necessary for class objects. return false; case ObjCMessageExpr::SuperInstance: // We generally assume that 'self' lives throughout a method call. return false; } llvm_unreachable("invalid receiver kind"); } /// Given an expression of ObjC pointer type, check whether it was /// immediately loaded from an ARC __weak l-value. static const Expr *findWeakLValue(const Expr *E) { assert(E->getType()->isObjCRetainableType()); E = E->IgnoreParens(); if (auto CE = dyn_cast<CastExpr>(E)) { if (CE->getCastKind() == CK_LValueToRValue) { if (CE->getSubExpr()->getType().getObjCLifetime() == Qualifiers::OCL_Weak) return CE->getSubExpr(); } } return nullptr; } /// The ObjC runtime may provide entrypoints that are likely to be faster /// than an ordinary message send of the appropriate selector. /// /// The entrypoints are guaranteed to be equivalent to just sending the /// corresponding message. If the entrypoint is implemented naively as just a /// message send, using it is a trade-off: it sacrifices a few cycles of /// overhead to save a small amount of code. However, it's possible for /// runtimes to detect and special-case classes that use "standard" /// behavior; if that's dynamically a large proportion of all objects, using /// the entrypoint will also be faster than using a message send. /// /// If the runtime does support a required entrypoint, then this method will /// generate a call and return the resulting value. Otherwise it will return /// None and the caller can generate a msgSend instead. static Optional<llvm::Value *> tryGenerateSpecializedMessageSend(CodeGenFunction &CGF, QualType ResultType, llvm::Value *Receiver, const CallArgList& Args, Selector Sel, const ObjCMethodDecl *method, bool isClassMessage) { auto &CGM = CGF.CGM; if (!CGM.getCodeGenOpts().ObjCConvertMessagesToRuntimeCalls) return None; auto &Runtime = CGM.getLangOpts().ObjCRuntime; switch (Sel.getMethodFamily()) { case OMF_alloc: if (isClassMessage && Runtime.shouldUseRuntimeFunctionsForAlloc() && ResultType->isObjCObjectPointerType()) { // [Foo alloc] -> objc_alloc(Foo) or // [self alloc] -> objc_alloc(self) if (Sel.isUnarySelector() && Sel.getNameForSlot(0) == "alloc") return CGF.EmitObjCAlloc(Receiver, CGF.ConvertType(ResultType)); // [Foo allocWithZone:nil] -> objc_allocWithZone(Foo) or // [self allocWithZone:nil] -> objc_allocWithZone(self) if (Sel.isKeywordSelector() && Sel.getNumArgs() == 1 && Args.size() == 1 && Args.front().getType()->isPointerType() && Sel.getNameForSlot(0) == "allocWithZone") { const llvm::Value* arg = Args.front().getKnownRValue().getScalarVal(); if (isa<llvm::ConstantPointerNull>(arg)) return CGF.EmitObjCAllocWithZone(Receiver, CGF.ConvertType(ResultType)); return None; } } break; case OMF_autorelease: if (ResultType->isObjCObjectPointerType() && CGM.getLangOpts().getGC() == LangOptions::NonGC && Runtime.shouldUseARCFunctionsForRetainRelease()) return CGF.EmitObjCAutorelease(Receiver, CGF.ConvertType(ResultType)); break; case OMF_retain: if (ResultType->isObjCObjectPointerType() && CGM.getLangOpts().getGC() == LangOptions::NonGC && Runtime.shouldUseARCFunctionsForRetainRelease()) return CGF.EmitObjCRetainNonBlock(Receiver, CGF.ConvertType(ResultType)); break; case OMF_release: if (ResultType->isVoidType() && CGM.getLangOpts().getGC() == LangOptions::NonGC && Runtime.shouldUseARCFunctionsForRetainRelease()) { CGF.EmitObjCRelease(Receiver, ARCPreciseLifetime); return nullptr; } break; default: break; } return None; } CodeGen::RValue CGObjCRuntime::GeneratePossiblySpecializedMessageSend( CodeGenFunction &CGF, ReturnValueSlot Return, QualType ResultType, Selector Sel, llvm::Value *Receiver, const CallArgList &Args, const ObjCInterfaceDecl *OID, const ObjCMethodDecl *Method, bool isClassMessage) { if (Optional<llvm::Value *> SpecializedResult = tryGenerateSpecializedMessageSend(CGF, ResultType, Receiver, Args, Sel, Method, isClassMessage)) { return RValue::get(SpecializedResult.getValue()); } return GenerateMessageSend(CGF, Return, ResultType, Sel, Receiver, Args, OID, Method); } static void AppendFirstImpliedRuntimeProtocols( const ObjCProtocolDecl *PD, llvm::UniqueVector<const ObjCProtocolDecl *> &PDs) { if (!PD->isNonRuntimeProtocol()) { const auto *Can = PD->getCanonicalDecl(); PDs.insert(Can); return; } for (const auto *ParentPD : PD->protocols()) AppendFirstImpliedRuntimeProtocols(ParentPD, PDs); } std::vector<const ObjCProtocolDecl *> CGObjCRuntime::GetRuntimeProtocolList(ObjCProtocolDecl::protocol_iterator begin, ObjCProtocolDecl::protocol_iterator end) { std::vector<const ObjCProtocolDecl *> RuntimePds; llvm::DenseSet<const ObjCProtocolDecl *> NonRuntimePDs; for (; begin != end; ++begin) { const auto *It = *begin; const auto *Can = It->getCanonicalDecl(); if (Can->isNonRuntimeProtocol()) NonRuntimePDs.insert(Can); else RuntimePds.push_back(Can); } // If there are no non-runtime protocols then we can just stop now. if (NonRuntimePDs.empty()) return RuntimePds; // Else we have to search through the non-runtime protocol's inheritancy // hierarchy DAG stopping whenever a branch either finds a runtime protocol or // a non-runtime protocol without any parents. These are the "first-implied" // protocols from a non-runtime protocol. llvm::UniqueVector<const ObjCProtocolDecl *> FirstImpliedProtos; for (const auto *PD : NonRuntimePDs) AppendFirstImpliedRuntimeProtocols(PD, FirstImpliedProtos); // Walk the Runtime list to get all protocols implied via the inclusion of // this protocol, e.g. all protocols it inherits from including itself. llvm::DenseSet<const ObjCProtocolDecl *> AllImpliedProtocols; for (const auto *PD : RuntimePds) { const auto *Can = PD->getCanonicalDecl(); AllImpliedProtocols.insert(Can); Can->getImpliedProtocols(AllImpliedProtocols); } // Similar to above, walk the list of first-implied protocols to find the set // all the protocols implied excluding the listed protocols themselves since // they are not yet a part of the `RuntimePds` list. for (const auto *PD : FirstImpliedProtos) { PD->getImpliedProtocols(AllImpliedProtocols); } // From the first-implied list we have to finish building the final protocol // list. If a protocol in the first-implied list was already implied via some // inheritance path through some other protocols then it would be redundant to // add it here and so we skip over it. for (const auto *PD : FirstImpliedProtos) { if (!AllImpliedProtocols.contains(PD)) { RuntimePds.push_back(PD); } } return RuntimePds; } /// Instead of '[[MyClass alloc] init]', try to generate /// 'objc_alloc_init(MyClass)'. This provides a code size improvement on the /// caller side, as well as the optimized objc_alloc. static Optional<llvm::Value *> tryEmitSpecializedAllocInit(CodeGenFunction &CGF, const ObjCMessageExpr *OME) { auto &Runtime = CGF.getLangOpts().ObjCRuntime; if (!Runtime.shouldUseRuntimeFunctionForCombinedAllocInit()) return None; // Match the exact pattern '[[MyClass alloc] init]'. Selector Sel = OME->getSelector(); if (OME->getReceiverKind() != ObjCMessageExpr::Instance || !OME->getType()->isObjCObjectPointerType() || !Sel.isUnarySelector() || Sel.getNameForSlot(0) != "init") return None; // Okay, this is '[receiver init]', check if 'receiver' is '[cls alloc]' // with 'cls' a Class. auto *SubOME = dyn_cast<ObjCMessageExpr>(OME->getInstanceReceiver()->IgnoreParenCasts()); if (!SubOME) return None; Selector SubSel = SubOME->getSelector(); if (!SubOME->getType()->isObjCObjectPointerType() || !SubSel.isUnarySelector() || SubSel.getNameForSlot(0) != "alloc") return None; llvm::Value *Receiver = nullptr; switch (SubOME->getReceiverKind()) { case ObjCMessageExpr::Instance: if (!SubOME->getInstanceReceiver()->getType()->isObjCClassType()) return None; Receiver = CGF.EmitScalarExpr(SubOME->getInstanceReceiver()); break; case ObjCMessageExpr::Class: { QualType ReceiverType = SubOME->getClassReceiver(); const ObjCObjectType *ObjTy = ReceiverType->castAs<ObjCObjectType>(); const ObjCInterfaceDecl *ID = ObjTy->getInterface(); assert(ID && "null interface should be impossible here"); Receiver = CGF.CGM.getObjCRuntime().GetClass(CGF, ID); break; } case ObjCMessageExpr::SuperInstance: case ObjCMessageExpr::SuperClass: return None; } return CGF.EmitObjCAllocInit(Receiver, CGF.ConvertType(OME->getType())); } RValue CodeGenFunction::EmitObjCMessageExpr(const ObjCMessageExpr *E, ReturnValueSlot Return) { // Only the lookup mechanism and first two arguments of the method // implementation vary between runtimes. We can get the receiver and // arguments in generic code. bool isDelegateInit = E->isDelegateInitCall(); const ObjCMethodDecl *method = E->getMethodDecl(); // If the method is -retain, and the receiver's being loaded from // a __weak variable, peephole the entire operation to objc_loadWeakRetained. if (method && E->getReceiverKind() == ObjCMessageExpr::Instance && method->getMethodFamily() == OMF_retain) { if (auto lvalueExpr = findWeakLValue(E->getInstanceReceiver())) { LValue lvalue = EmitLValue(lvalueExpr); llvm::Value *result = EmitARCLoadWeakRetained(lvalue.getAddress(*this)); return AdjustObjCObjectType(*this, E->getType(), RValue::get(result)); } } if (Optional<llvm::Value *> Val = tryEmitSpecializedAllocInit(*this, E)) return AdjustObjCObjectType(*this, E->getType(), RValue::get(*Val)); // We don't retain the receiver in delegate init calls, and this is // safe because the receiver value is always loaded from 'self', // which we zero out. We don't want to Block_copy block receivers, // though. bool retainSelf = (!isDelegateInit && CGM.getLangOpts().ObjCAutoRefCount && method && method->hasAttr<NSConsumesSelfAttr>()); CGObjCRuntime &Runtime = CGM.getObjCRuntime(); bool isSuperMessage = false; bool isClassMessage = false; ObjCInterfaceDecl *OID = nullptr; // Find the receiver QualType ReceiverType; llvm::Value *Receiver = nullptr; switch (E->getReceiverKind()) { case ObjCMessageExpr::Instance: ReceiverType = E->getInstanceReceiver()->getType(); isClassMessage = ReceiverType->isObjCClassType(); if (retainSelf) { TryEmitResult ter = tryEmitARCRetainScalarExpr(*this, E->getInstanceReceiver()); Receiver = ter.getPointer(); if (ter.getInt()) retainSelf = false; } else Receiver = EmitScalarExpr(E->getInstanceReceiver()); break; case ObjCMessageExpr::Class: { ReceiverType = E->getClassReceiver(); OID = ReceiverType->castAs<ObjCObjectType>()->getInterface(); assert(OID && "Invalid Objective-C class message send"); Receiver = Runtime.GetClass(*this, OID); isClassMessage = true; break; } case ObjCMessageExpr::SuperInstance: ReceiverType = E->getSuperType(); Receiver = LoadObjCSelf(); isSuperMessage = true; break; case ObjCMessageExpr::SuperClass: ReceiverType = E->getSuperType(); Receiver = LoadObjCSelf(); isSuperMessage = true; isClassMessage = true; break; } if (retainSelf) Receiver = EmitARCRetainNonBlock(Receiver); // In ARC, we sometimes want to "extend the lifetime" // (i.e. retain+autorelease) of receivers of returns-inner-pointer // messages. if (getLangOpts().ObjCAutoRefCount && method && method->hasAttr<ObjCReturnsInnerPointerAttr>() && shouldExtendReceiverForInnerPointerMessage(E)) Receiver = EmitARCRetainAutorelease(ReceiverType, Receiver); QualType ResultType = method ? method->getReturnType() : E->getType(); CallArgList Args; EmitCallArgs(Args, method, E->arguments(), /*AC*/AbstractCallee(method)); // For delegate init calls in ARC, do an unsafe store of null into // self. This represents the call taking direct ownership of that // value. We have to do this after emitting the other call // arguments because they might also reference self, but we don't // have to worry about any of them modifying self because that would // be an undefined read and write of an object in unordered // expressions. if (isDelegateInit) { assert(getLangOpts().ObjCAutoRefCount && "delegate init calls should only be marked in ARC"); // Do an unsafe store of null into self. Address selfAddr = GetAddrOfLocalVar(cast<ObjCMethodDecl>(CurCodeDecl)->getSelfDecl()); Builder.CreateStore(getNullForVariable(selfAddr), selfAddr); } RValue result; if (isSuperMessage) { // super is only valid in an Objective-C method const ObjCMethodDecl *OMD = cast<ObjCMethodDecl>(CurFuncDecl); bool isCategoryImpl = isa<ObjCCategoryImplDecl>(OMD->getDeclContext()); result = Runtime.GenerateMessageSendSuper(*this, Return, ResultType, E->getSelector(), OMD->getClassInterface(), isCategoryImpl, Receiver, isClassMessage, Args, method); } else { // Call runtime methods directly if we can. result = Runtime.GeneratePossiblySpecializedMessageSend( *this, Return, ResultType, E->getSelector(), Receiver, Args, OID, method, isClassMessage); } // For delegate init calls in ARC, implicitly store the result of // the call back into self. This takes ownership of the value. if (isDelegateInit) { Address selfAddr = GetAddrOfLocalVar(cast<ObjCMethodDecl>(CurCodeDecl)->getSelfDecl()); llvm::Value *newSelf = result.getScalarVal(); // The delegate return type isn't necessarily a matching type; in // fact, it's quite likely to be 'id'. llvm::Type *selfTy = selfAddr.getElementType(); newSelf = Builder.CreateBitCast(newSelf, selfTy); Builder.CreateStore(newSelf, selfAddr); } return AdjustObjCObjectType(*this, E->getType(), result); } namespace { struct FinishARCDealloc final : EHScopeStack::Cleanup { void Emit(CodeGenFunction &CGF, Flags flags) override { const ObjCMethodDecl *method = cast<ObjCMethodDecl>(CGF.CurCodeDecl); const ObjCImplDecl *impl = cast<ObjCImplDecl>(method->getDeclContext()); const ObjCInterfaceDecl *iface = impl->getClassInterface(); if (!iface->getSuperClass()) return; bool isCategory = isa<ObjCCategoryImplDecl>(impl); // Call [super dealloc] if we have a superclass. llvm::Value *self = CGF.LoadObjCSelf(); CallArgList args; CGF.CGM.getObjCRuntime().GenerateMessageSendSuper(CGF, ReturnValueSlot(), CGF.getContext().VoidTy, method->getSelector(), iface, isCategory, self, /*is class msg*/ false, args, method); } }; } /// StartObjCMethod - Begin emission of an ObjCMethod. This generates /// the LLVM function and sets the other context used by /// CodeGenFunction. void CodeGenFunction::StartObjCMethod(const ObjCMethodDecl *OMD, const ObjCContainerDecl *CD) { SourceLocation StartLoc = OMD->getBeginLoc(); FunctionArgList args; // Check if we should generate debug info for this method. if (OMD->hasAttr<NoDebugAttr>()) DebugInfo = nullptr; // disable debug info indefinitely for this function llvm::Function *Fn = CGM.getObjCRuntime().GenerateMethod(OMD, CD); const CGFunctionInfo &FI = CGM.getTypes().arrangeObjCMethodDeclaration(OMD); if (OMD->isDirectMethod()) { Fn->setVisibility(llvm::Function::HiddenVisibility); CGM.SetLLVMFunctionAttributes(OMD, FI, Fn); CGM.SetLLVMFunctionAttributesForDefinition(OMD, Fn); } else { CGM.SetInternalFunctionAttributes(OMD, Fn, FI); } args.push_back(OMD->getSelfDecl()); args.push_back(OMD->getCmdDecl()); args.append(OMD->param_begin(), OMD->param_end()); CurGD = OMD; CurEHLocation = OMD->getEndLoc(); StartFunction(OMD, OMD->getReturnType(), Fn, FI, args, OMD->getLocation(), StartLoc); if (OMD->isDirectMethod()) { // This function is a direct call, it has to implement a nil check // on entry. // // TODO: possibly have several entry points to elide the check CGM.getObjCRuntime().GenerateDirectMethodPrologue(*this, Fn, OMD, CD); } // In ARC, certain methods get an extra cleanup. if (CGM.getLangOpts().ObjCAutoRefCount && OMD->isInstanceMethod() && OMD->getSelector().isUnarySelector()) { const IdentifierInfo *ident = OMD->getSelector().getIdentifierInfoForSlot(0); if (ident->isStr("dealloc")) EHStack.pushCleanup<FinishARCDealloc>(getARCCleanupKind()); } } static llvm::Value *emitARCRetainLoadOfScalar(CodeGenFunction &CGF, LValue lvalue, QualType type); /// Generate an Objective-C method. An Objective-C method is a C function with /// its pointer, name, and types registered in the class structure. void CodeGenFunction::GenerateObjCMethod(const ObjCMethodDecl *OMD) { StartObjCMethod(OMD, OMD->getClassInterface()); PGO.assignRegionCounters(GlobalDecl(OMD), CurFn); assert(isa<CompoundStmt>(OMD->getBody())); incrementProfileCounter(OMD->getBody()); EmitCompoundStmtWithoutScope(*cast<CompoundStmt>(OMD->getBody())); FinishFunction(OMD->getBodyRBrace()); } /// emitStructGetterCall - Call the runtime function to load a property /// into the return value slot. static void emitStructGetterCall(CodeGenFunction &CGF, ObjCIvarDecl *ivar, bool isAtomic, bool hasStrong) { ASTContext &Context = CGF.getContext(); Address src = CGF.EmitLValueForIvar(CGF.TypeOfSelfObject(), CGF.LoadObjCSelf(), ivar, 0) .getAddress(CGF); // objc_copyStruct (ReturnValue, &structIvar, // sizeof (Type of Ivar), isAtomic, false); CallArgList args; Address dest = CGF.Builder.CreateBitCast(CGF.ReturnValue, CGF.VoidPtrTy); args.add(RValue::get(dest.getPointer()), Context.VoidPtrTy); src = CGF.Builder.CreateBitCast(src, CGF.VoidPtrTy); args.add(RValue::get(src.getPointer()), Context.VoidPtrTy); CharUnits size = CGF.getContext().getTypeSizeInChars(ivar->getType()); args.add(RValue::get(CGF.CGM.getSize(size)), Context.getSizeType()); args.add(RValue::get(CGF.Builder.getInt1(isAtomic)), Context.BoolTy); args.add(RValue::get(CGF.Builder.getInt1(hasStrong)), Context.BoolTy); llvm::FunctionCallee fn = CGF.CGM.getObjCRuntime().GetGetStructFunction(); CGCallee callee = CGCallee::forDirect(fn); CGF.EmitCall(CGF.getTypes().arrangeBuiltinFunctionCall(Context.VoidTy, args), callee, ReturnValueSlot(), args); } /// Determine whether the given architecture supports unaligned atomic /// accesses. They don't have to be fast, just faster than a function /// call and a mutex. static bool hasUnalignedAtomics(llvm::Triple::ArchType arch) { // FIXME: Allow unaligned atomic load/store on x86. (It is not // currently supported by the backend.) return 0; } /// Return the maximum size that permits atomic accesses for the given /// architecture. static CharUnits getMaxAtomicAccessSize(CodeGenModule &CGM, llvm::Triple::ArchType arch) { // ARM has 8-byte atomic accesses, but it's not clear whether we // want to rely on them here. // In the default case, just assume that any size up to a pointer is // fine given adequate alignment. return CharUnits::fromQuantity(CGM.PointerSizeInBytes); } namespace { class PropertyImplStrategy { public: enum StrategyKind { /// The 'native' strategy is to use the architecture's provided /// reads and writes. Native, /// Use objc_setProperty and objc_getProperty. GetSetProperty, /// Use objc_setProperty for the setter, but use expression /// evaluation for the getter. SetPropertyAndExpressionGet, /// Use objc_copyStruct. CopyStruct, /// The 'expression' strategy is to emit normal assignment or /// lvalue-to-rvalue expressions. Expression }; StrategyKind getKind() const { return StrategyKind(Kind); } bool hasStrongMember() const { return HasStrong; } bool isAtomic() const { return IsAtomic; } bool isCopy() const { return IsCopy; } CharUnits getIvarSize() const { return IvarSize; } CharUnits getIvarAlignment() const { return IvarAlignment; } PropertyImplStrategy(CodeGenModule &CGM, const ObjCPropertyImplDecl *propImpl); private: unsigned Kind : 8; unsigned IsAtomic : 1; unsigned IsCopy : 1; unsigned HasStrong : 1; CharUnits IvarSize; CharUnits IvarAlignment; }; } /// Pick an implementation strategy for the given property synthesis. PropertyImplStrategy::PropertyImplStrategy(CodeGenModule &CGM, const ObjCPropertyImplDecl *propImpl) { const ObjCPropertyDecl *prop = propImpl->getPropertyDecl(); ObjCPropertyDecl::SetterKind setterKind = prop->getSetterKind(); IsCopy = (setterKind == ObjCPropertyDecl::Copy); IsAtomic = prop->isAtomic(); HasStrong = false; // doesn't matter here. // Evaluate the ivar's size and alignment. ObjCIvarDecl *ivar = propImpl->getPropertyIvarDecl(); QualType ivarType = ivar->getType(); auto TInfo = CGM.getContext().getTypeInfoInChars(ivarType); IvarSize = TInfo.Width; IvarAlignment = TInfo.Align; // If we have a copy property, we always have to use getProperty/setProperty. // TODO: we could actually use setProperty and an expression for non-atomics. if (IsCopy) { Kind = GetSetProperty; return; } // Handle retain. if (setterKind == ObjCPropertyDecl::Retain) { // In GC-only, there's nothing special that needs to be done. if (CGM.getLangOpts().getGC() == LangOptions::GCOnly) { // fallthrough // In ARC, if the property is non-atomic, use expression emission, // which translates to objc_storeStrong. This isn't required, but // it's slightly nicer. } else if (CGM.getLangOpts().ObjCAutoRefCount && !IsAtomic) { // Using standard expression emission for the setter is only // acceptable if the ivar is __strong, which won't be true if // the property is annotated with __attribute__((NSObject)). // TODO: falling all the way back to objc_setProperty here is // just laziness, though; we could still use objc_storeStrong // if we hacked it right. if (ivarType.getObjCLifetime() == Qualifiers::OCL_Strong) Kind = Expression; else Kind = SetPropertyAndExpressionGet; return; // Otherwise, we need to at least use setProperty. However, if // the property isn't atomic, we can use normal expression // emission for the getter. } else if (!IsAtomic) { Kind = SetPropertyAndExpressionGet; return; // Otherwise, we have to use both setProperty and getProperty. } else { Kind = GetSetProperty; return; } } // If we're not atomic, just use expression accesses. if (!IsAtomic) { Kind = Expression; return; } // Properties on bitfield ivars need to be emitted using expression // accesses even if they're nominally atomic. if (ivar->isBitField()) { Kind = Expression; return; } // GC-qualified or ARC-qualified ivars need to be emitted as // expressions. This actually works out to being atomic anyway, // except for ARC __strong, but that should trigger the above code. if (ivarType.hasNonTrivialObjCLifetime() || (CGM.getLangOpts().getGC() && CGM.getContext().getObjCGCAttrKind(ivarType))) { Kind = Expression; return; } // Compute whether the ivar has strong members. if (CGM.getLangOpts().getGC()) if (const RecordType *recordType = ivarType->getAs<RecordType>()) HasStrong = recordType->getDecl()->hasObjectMember(); // We can never access structs with object members with a native // access, because we need to use write barriers. This is what // objc_copyStruct is for. if (HasStrong) { Kind = CopyStruct; return; } // Otherwise, this is target-dependent and based on the size and // alignment of the ivar. // If the size of the ivar is not a power of two, give up. We don't // want to get into the business of doing compare-and-swaps. if (!IvarSize.isPowerOfTwo()) { Kind = CopyStruct; return; } llvm::Triple::ArchType arch = CGM.getTarget().getTriple().getArch(); // Most architectures require memory to fit within a single cache // line, so the alignment has to be at least the size of the access. // Otherwise we have to grab a lock. if (IvarAlignment < IvarSize && !hasUnalignedAtomics(arch)) { Kind = CopyStruct; return; } // If the ivar's size exceeds the architecture's maximum atomic // access size, we have to use CopyStruct. if (IvarSize > getMaxAtomicAccessSize(CGM, arch)) { Kind = CopyStruct; return; } // Otherwise, we can use native loads and stores. Kind = Native; } /// Generate an Objective-C property getter function. /// /// The given Decl must be an ObjCImplementationDecl. \@synthesize /// is illegal within a category. void CodeGenFunction::GenerateObjCGetter(ObjCImplementationDecl *IMP, const ObjCPropertyImplDecl *PID) { llvm::Constant *AtomicHelperFn = CodeGenFunction(CGM).GenerateObjCAtomicGetterCopyHelperFunction(PID); ObjCMethodDecl *OMD = PID->getGetterMethodDecl(); assert(OMD && "Invalid call to generate getter (empty method)"); StartObjCMethod(OMD, IMP->getClassInterface()); generateObjCGetterBody(IMP, PID, OMD, AtomicHelperFn); FinishFunction(OMD->getEndLoc()); } static bool hasTrivialGetExpr(const ObjCPropertyImplDecl *propImpl) { const Expr *getter = propImpl->getGetterCXXConstructor(); if (!getter) return true; // Sema only makes only of these when the ivar has a C++ class type, // so the form is pretty constrained. // If the property has a reference type, we might just be binding a // reference, in which case the result will be a gl-value. We should // treat this as a non-trivial operation. if (getter->isGLValue()) return false; // If we selected a trivial copy-constructor, we're okay. if (const CXXConstructExpr *construct = dyn_cast<CXXConstructExpr>(getter)) return (construct->getConstructor()->isTrivial()); // The constructor might require cleanups (in which case it's never // trivial). assert(isa<ExprWithCleanups>(getter)); return false; } /// emitCPPObjectAtomicGetterCall - Call the runtime function to /// copy the ivar into the resturn slot. static void emitCPPObjectAtomicGetterCall(CodeGenFunction &CGF, llvm::Value *returnAddr, ObjCIvarDecl *ivar, llvm::Constant *AtomicHelperFn) { // objc_copyCppObjectAtomic (&returnSlot, &CppObjectIvar, // AtomicHelperFn); CallArgList args; // The 1st argument is the return Slot. args.add(RValue::get(returnAddr), CGF.getContext().VoidPtrTy); // The 2nd argument is the address of the ivar. llvm::Value *ivarAddr = CGF.EmitLValueForIvar(CGF.TypeOfSelfObject(), CGF.LoadObjCSelf(), ivar, 0) .getPointer(CGF); ivarAddr = CGF.Builder.CreateBitCast(ivarAddr, CGF.Int8PtrTy); args.add(RValue::get(ivarAddr), CGF.getContext().VoidPtrTy); // Third argument is the helper function. args.add(RValue::get(AtomicHelperFn), CGF.getContext().VoidPtrTy); llvm::FunctionCallee copyCppAtomicObjectFn = CGF.CGM.getObjCRuntime().GetCppAtomicObjectGetFunction(); CGCallee callee = CGCallee::forDirect(copyCppAtomicObjectFn); CGF.EmitCall( CGF.getTypes().arrangeBuiltinFunctionCall(CGF.getContext().VoidTy, args), callee, ReturnValueSlot(), args); } void CodeGenFunction::generateObjCGetterBody(const ObjCImplementationDecl *classImpl, const ObjCPropertyImplDecl *propImpl, const ObjCMethodDecl *GetterMethodDecl, llvm::Constant *AtomicHelperFn) { // If there's a non-trivial 'get' expression, we just have to emit that. if (!hasTrivialGetExpr(propImpl)) { if (!AtomicHelperFn) { auto *ret = ReturnStmt::Create(getContext(), SourceLocation(), propImpl->getGetterCXXConstructor(), /* NRVOCandidate=*/nullptr); EmitReturnStmt(*ret); } else { ObjCIvarDecl *ivar = propImpl->getPropertyIvarDecl(); emitCPPObjectAtomicGetterCall(*this, ReturnValue.getPointer(), ivar, AtomicHelperFn); } return; } const ObjCPropertyDecl *prop = propImpl->getPropertyDecl(); QualType propType = prop->getType(); ObjCMethodDecl *getterMethod = propImpl->getGetterMethodDecl(); ObjCIvarDecl *ivar = propImpl->getPropertyIvarDecl(); // Pick an implementation strategy. PropertyImplStrategy strategy(CGM, propImpl); switch (strategy.getKind()) { case PropertyImplStrategy::Native: { // We don't need to do anything for a zero-size struct. if (strategy.getIvarSize().isZero()) return; LValue LV = EmitLValueForIvar(TypeOfSelfObject(), LoadObjCSelf(), ivar, 0); // Currently, all atomic accesses have to be through integer // types, so there's no point in trying to pick a prettier type. uint64_t ivarSize = getContext().toBits(strategy.getIvarSize()); llvm::Type *bitcastType = llvm::Type::getIntNTy(getLLVMContext(), ivarSize); bitcastType = bitcastType->getPointerTo(); // addrspace 0 okay // Perform an atomic load. This does not impose ordering constraints. Address ivarAddr = LV.getAddress(*this); ivarAddr = Builder.CreateBitCast(ivarAddr, bitcastType); llvm::LoadInst *load = Builder.CreateLoad(ivarAddr, "load"); load->setAtomic(llvm::AtomicOrdering::Unordered); // Store that value into the return address. Doing this with a // bitcast is likely to produce some pretty ugly IR, but it's not // the *most* terrible thing in the world. llvm::Type *retTy = ConvertType(getterMethod->getReturnType()); uint64_t retTySize = CGM.getDataLayout().getTypeSizeInBits(retTy); llvm::Value *ivarVal = load; if (ivarSize > retTySize) { llvm::Type *newTy = llvm::Type::getIntNTy(getLLVMContext(), retTySize); ivarVal = Builder.CreateTrunc(load, newTy); bitcastType = newTy->getPointerTo(); } Builder.CreateStore(ivarVal, Builder.CreateBitCast(ReturnValue, bitcastType)); // Make sure we don't do an autorelease. AutoreleaseResult = false; return; } case PropertyImplStrategy::GetSetProperty: { llvm::FunctionCallee getPropertyFn = CGM.getObjCRuntime().GetPropertyGetFunction(); if (!getPropertyFn) { CGM.ErrorUnsupported(propImpl, "Obj-C getter requiring atomic copy"); return; } CGCallee callee = CGCallee::forDirect(getPropertyFn); // Return (ivar-type) objc_getProperty((id) self, _cmd, offset, true). // FIXME: Can't this be simpler? This might even be worse than the // corresponding gcc code. llvm::Value *cmd = Builder.CreateLoad(GetAddrOfLocalVar(getterMethod->getCmdDecl()), "cmd"); llvm::Value *self = Builder.CreateBitCast(LoadObjCSelf(), VoidPtrTy); llvm::Value *ivarOffset = EmitIvarOffset(classImpl->getClassInterface(), ivar); CallArgList args; args.add(RValue::get(self), getContext().getObjCIdType()); args.add(RValue::get(cmd), getContext().getObjCSelType()); args.add(RValue::get(ivarOffset), getContext().getPointerDiffType()); args.add(RValue::get(Builder.getInt1(strategy.isAtomic())), getContext().BoolTy); // FIXME: We shouldn't need to get the function info here, the // runtime already should have computed it to build the function. llvm::CallBase *CallInstruction; RValue RV = EmitCall(getTypes().arrangeBuiltinFunctionCall( getContext().getObjCIdType(), args), callee, ReturnValueSlot(), args, &CallInstruction); if (llvm::CallInst *call = dyn_cast<llvm::CallInst>(CallInstruction)) call->setTailCall(); // We need to fix the type here. Ivars with copy & retain are // always objects so we don't need to worry about complex or // aggregates. RV = RValue::get(Builder.CreateBitCast( RV.getScalarVal(), getTypes().ConvertType(getterMethod->getReturnType()))); EmitReturnOfRValue(RV, propType); // objc_getProperty does an autorelease, so we should suppress ours. AutoreleaseResult = false; return; } case PropertyImplStrategy::CopyStruct: emitStructGetterCall(*this, ivar, strategy.isAtomic(), strategy.hasStrongMember()); return; case PropertyImplStrategy::Expression: case PropertyImplStrategy::SetPropertyAndExpressionGet: { LValue LV = EmitLValueForIvar(TypeOfSelfObject(), LoadObjCSelf(), ivar, 0); QualType ivarType = ivar->getType(); switch (getEvaluationKind(ivarType)) { case TEK_Complex: { ComplexPairTy pair = EmitLoadOfComplex(LV, SourceLocation()); EmitStoreOfComplex(pair, MakeAddrLValue(ReturnValue, ivarType), /*init*/ true); return; } case TEK_Aggregate: { // The return value slot is guaranteed to not be aliased, but // that's not necessarily the same as "on the stack", so // we still potentially need objc_memmove_collectable. EmitAggregateCopy(/* Dest= */ MakeAddrLValue(ReturnValue, ivarType), /* Src= */ LV, ivarType, getOverlapForReturnValue()); return; } case TEK_Scalar: { llvm::Value *value; if (propType->isReferenceType()) { value = LV.getAddress(*this).getPointer(); } else { // We want to load and autoreleaseReturnValue ARC __weak ivars. if (LV.getQuals().getObjCLifetime() == Qualifiers::OCL_Weak) { if (getLangOpts().ObjCAutoRefCount) { value = emitARCRetainLoadOfScalar(*this, LV, ivarType); } else { value = EmitARCLoadWeak(LV.getAddress(*this)); } // Otherwise we want to do a simple load, suppressing the // final autorelease. } else { value = EmitLoadOfLValue(LV, SourceLocation()).getScalarVal(); AutoreleaseResult = false; } value = Builder.CreateBitCast( value, ConvertType(GetterMethodDecl->getReturnType())); } EmitReturnOfRValue(RValue::get(value), propType); return; } } llvm_unreachable("bad evaluation kind"); } } llvm_unreachable("bad @property implementation strategy!"); } /// emitStructSetterCall - Call the runtime function to store the value /// from the first formal parameter into the given ivar. static void emitStructSetterCall(CodeGenFunction &CGF, ObjCMethodDecl *OMD, ObjCIvarDecl *ivar) { // objc_copyStruct (&structIvar, &Arg, // sizeof (struct something), true, false); CallArgList args; // The first argument is the address of the ivar. llvm::Value *ivarAddr = CGF.EmitLValueForIvar(CGF.TypeOfSelfObject(), CGF.LoadObjCSelf(), ivar, 0) .getPointer(CGF); ivarAddr = CGF.Builder.CreateBitCast(ivarAddr, CGF.Int8PtrTy); args.add(RValue::get(ivarAddr), CGF.getContext().VoidPtrTy); // The second argument is the address of the parameter variable. ParmVarDecl *argVar = *OMD->param_begin(); DeclRefExpr argRef(CGF.getContext(), argVar, false, argVar->getType().getNonReferenceType(), VK_LValue, SourceLocation()); llvm::Value *argAddr = CGF.EmitLValue(&argRef).getPointer(CGF); argAddr = CGF.Builder.CreateBitCast(argAddr, CGF.Int8PtrTy); args.add(RValue::get(argAddr), CGF.getContext().VoidPtrTy); // The third argument is the sizeof the type. llvm::Value *size = CGF.CGM.getSize(CGF.getContext().getTypeSizeInChars(ivar->getType())); args.add(RValue::get(size), CGF.getContext().getSizeType()); // The fourth argument is the 'isAtomic' flag. args.add(RValue::get(CGF.Builder.getTrue()), CGF.getContext().BoolTy); // The fifth argument is the 'hasStrong' flag. // FIXME: should this really always be false? args.add(RValue::get(CGF.Builder.getFalse()), CGF.getContext().BoolTy); llvm::FunctionCallee fn = CGF.CGM.getObjCRuntime().GetSetStructFunction(); CGCallee callee = CGCallee::forDirect(fn); CGF.EmitCall( CGF.getTypes().arrangeBuiltinFunctionCall(CGF.getContext().VoidTy, args), callee, ReturnValueSlot(), args); } /// emitCPPObjectAtomicSetterCall - Call the runtime function to store /// the value from the first formal parameter into the given ivar, using /// the Cpp API for atomic Cpp objects with non-trivial copy assignment. static void emitCPPObjectAtomicSetterCall(CodeGenFunction &CGF, ObjCMethodDecl *OMD, ObjCIvarDecl *ivar, llvm::Constant *AtomicHelperFn) { // objc_copyCppObjectAtomic (&CppObjectIvar, &Arg, // AtomicHelperFn); CallArgList args; // The first argument is the address of the ivar. llvm::Value *ivarAddr = CGF.EmitLValueForIvar(CGF.TypeOfSelfObject(), CGF.LoadObjCSelf(), ivar, 0) .getPointer(CGF); ivarAddr = CGF.Builder.CreateBitCast(ivarAddr, CGF.Int8PtrTy); args.add(RValue::get(ivarAddr), CGF.getContext().VoidPtrTy); // The second argument is the address of the parameter variable. ParmVarDecl *argVar = *OMD->param_begin(); DeclRefExpr argRef(CGF.getContext(), argVar, false, argVar->getType().getNonReferenceType(), VK_LValue, SourceLocation()); llvm::Value *argAddr = CGF.EmitLValue(&argRef).getPointer(CGF); argAddr = CGF.Builder.CreateBitCast(argAddr, CGF.Int8PtrTy); args.add(RValue::get(argAddr), CGF.getContext().VoidPtrTy); // Third argument is the helper function. args.add(RValue::get(AtomicHelperFn), CGF.getContext().VoidPtrTy); llvm::FunctionCallee fn = CGF.CGM.getObjCRuntime().GetCppAtomicObjectSetFunction(); CGCallee callee = CGCallee::forDirect(fn); CGF.EmitCall( CGF.getTypes().arrangeBuiltinFunctionCall(CGF.getContext().VoidTy, args), callee, ReturnValueSlot(), args); } static bool hasTrivialSetExpr(const ObjCPropertyImplDecl *PID) { Expr *setter = PID->getSetterCXXAssignment(); if (!setter) return true; // Sema only makes only of these when the ivar has a C++ class type, // so the form is pretty constrained. // An operator call is trivial if the function it calls is trivial. // This also implies that there's nothing non-trivial going on with // the arguments, because operator= can only be trivial if it's a // synthesized assignment operator and therefore both parameters are // references. if (CallExpr *call = dyn_cast<CallExpr>(setter)) { if (const FunctionDecl *callee = dyn_cast_or_null<FunctionDecl>(call->getCalleeDecl())) if (callee->isTrivial()) return true; return false; } assert(isa<ExprWithCleanups>(setter)); return false; } static bool UseOptimizedSetter(CodeGenModule &CGM) { if (CGM.getLangOpts().getGC() != LangOptions::NonGC) return false; return CGM.getLangOpts().ObjCRuntime.hasOptimizedSetter(); } void CodeGenFunction::generateObjCSetterBody(const ObjCImplementationDecl *classImpl, const ObjCPropertyImplDecl *propImpl, llvm::Constant *AtomicHelperFn) { ObjCIvarDecl *ivar = propImpl->getPropertyIvarDecl(); ObjCMethodDecl *setterMethod = propImpl->getSetterMethodDecl(); // Just use the setter expression if Sema gave us one and it's // non-trivial. if (!hasTrivialSetExpr(propImpl)) { if (!AtomicHelperFn) // If non-atomic, assignment is called directly. EmitStmt(propImpl->getSetterCXXAssignment()); else // If atomic, assignment is called via a locking api. emitCPPObjectAtomicSetterCall(*this, setterMethod, ivar, AtomicHelperFn); return; } PropertyImplStrategy strategy(CGM, propImpl); switch (strategy.getKind()) { case PropertyImplStrategy::Native: { // We don't need to do anything for a zero-size struct. if (strategy.getIvarSize().isZero()) return; Address argAddr = GetAddrOfLocalVar(*setterMethod->param_begin()); LValue ivarLValue = EmitLValueForIvar(TypeOfSelfObject(), LoadObjCSelf(), ivar, /*quals*/ 0); Address ivarAddr = ivarLValue.getAddress(*this); // Currently, all atomic accesses have to be through integer // types, so there's no point in trying to pick a prettier type. llvm::Type *bitcastType = llvm::Type::getIntNTy(getLLVMContext(), getContext().toBits(strategy.getIvarSize())); // Cast both arguments to the chosen operation type. argAddr = Builder.CreateElementBitCast(argAddr, bitcastType); ivarAddr = Builder.CreateElementBitCast(ivarAddr, bitcastType); // This bitcast load is likely to cause some nasty IR. llvm::Value *load = Builder.CreateLoad(argAddr); // Perform an atomic store. There are no memory ordering requirements. llvm::StoreInst *store = Builder.CreateStore(load, ivarAddr); store->setAtomic(llvm::AtomicOrdering::Unordered); return; } case PropertyImplStrategy::GetSetProperty: case PropertyImplStrategy::SetPropertyAndExpressionGet: { llvm::FunctionCallee setOptimizedPropertyFn = nullptr; llvm::FunctionCallee setPropertyFn = nullptr; if (UseOptimizedSetter(CGM)) { // 10.8 and iOS 6.0 code and GC is off setOptimizedPropertyFn = CGM.getObjCRuntime().GetOptimizedPropertySetFunction( strategy.isAtomic(), strategy.isCopy()); if (!setOptimizedPropertyFn) { CGM.ErrorUnsupported(propImpl, "Obj-C optimized setter - NYI"); return; } } else { setPropertyFn = CGM.getObjCRuntime().GetPropertySetFunction(); if (!setPropertyFn) { CGM.ErrorUnsupported(propImpl, "Obj-C setter requiring atomic copy"); return; } } // Emit objc_setProperty((id) self, _cmd, offset, arg, // <is-atomic>, <is-copy>). llvm::Value *cmd = Builder.CreateLoad(GetAddrOfLocalVar(setterMethod->getCmdDecl())); llvm::Value *self = Builder.CreateBitCast(LoadObjCSelf(), VoidPtrTy); llvm::Value *ivarOffset = EmitIvarOffset(classImpl->getClassInterface(), ivar); Address argAddr = GetAddrOfLocalVar(*setterMethod->param_begin()); llvm::Value *arg = Builder.CreateLoad(argAddr, "arg"); arg = Builder.CreateBitCast(arg, VoidPtrTy); CallArgList args; args.add(RValue::get(self), getContext().getObjCIdType()); args.add(RValue::get(cmd), getContext().getObjCSelType()); if (setOptimizedPropertyFn) { args.add(RValue::get(arg), getContext().getObjCIdType()); args.add(RValue::get(ivarOffset), getContext().getPointerDiffType()); CGCallee callee = CGCallee::forDirect(setOptimizedPropertyFn); EmitCall(getTypes().arrangeBuiltinFunctionCall(getContext().VoidTy, args), callee, ReturnValueSlot(), args); } else { args.add(RValue::get(ivarOffset), getContext().getPointerDiffType()); args.add(RValue::get(arg), getContext().getObjCIdType()); args.add(RValue::get(Builder.getInt1(strategy.isAtomic())), getContext().BoolTy); args.add(RValue::get(Builder.getInt1(strategy.isCopy())), getContext().BoolTy); // FIXME: We shouldn't need to get the function info here, the runtime // already should have computed it to build the function. CGCallee callee = CGCallee::forDirect(setPropertyFn); EmitCall(getTypes().arrangeBuiltinFunctionCall(getContext().VoidTy, args), callee, ReturnValueSlot(), args); } return; } case PropertyImplStrategy::CopyStruct: emitStructSetterCall(*this, setterMethod, ivar); return; case PropertyImplStrategy::Expression: break; } // Otherwise, fake up some ASTs and emit a normal assignment. ValueDecl *selfDecl = setterMethod->getSelfDecl(); DeclRefExpr self(getContext(), selfDecl, false, selfDecl->getType(), VK_LValue, SourceLocation()); ImplicitCastExpr selfLoad(ImplicitCastExpr::OnStack, selfDecl->getType(), CK_LValueToRValue, &self, VK_RValue, FPOptionsOverride()); ObjCIvarRefExpr ivarRef(ivar, ivar->getType().getNonReferenceType(), SourceLocation(), SourceLocation(), &selfLoad, true, true); ParmVarDecl *argDecl = *setterMethod->param_begin(); QualType argType = argDecl->getType().getNonReferenceType(); DeclRefExpr arg(getContext(), argDecl, false, argType, VK_LValue, SourceLocation()); ImplicitCastExpr argLoad(ImplicitCastExpr::OnStack, argType.getUnqualifiedType(), CK_LValueToRValue, &arg, VK_RValue, FPOptionsOverride()); // The property type can differ from the ivar type in some situations with // Objective-C pointer types, we can always bit cast the RHS in these cases. // The following absurdity is just to ensure well-formed IR. CastKind argCK = CK_NoOp; if (ivarRef.getType()->isObjCObjectPointerType()) { if (argLoad.getType()->isObjCObjectPointerType()) argCK = CK_BitCast; else if (argLoad.getType()->isBlockPointerType()) argCK = CK_BlockPointerToObjCPointerCast; else argCK = CK_CPointerToObjCPointerCast; } else if (ivarRef.getType()->isBlockPointerType()) { if (argLoad.getType()->isBlockPointerType()) argCK = CK_BitCast; else argCK = CK_AnyPointerToBlockPointerCast; } else if (ivarRef.getType()->isPointerType()) { argCK = CK_BitCast; } ImplicitCastExpr argCast(ImplicitCastExpr::OnStack, ivarRef.getType(), argCK, &argLoad, VK_RValue, FPOptionsOverride()); Expr *finalArg = &argLoad; if (!getContext().hasSameUnqualifiedType(ivarRef.getType(), argLoad.getType())) finalArg = &argCast; BinaryOperator *assign = BinaryOperator::Create( getContext(), &ivarRef, finalArg, BO_Assign, ivarRef.getType(), VK_RValue, OK_Ordinary, SourceLocation(), FPOptionsOverride()); EmitStmt(assign); } /// Generate an Objective-C property setter function. /// /// The given Decl must be an ObjCImplementationDecl. \@synthesize /// is illegal within a category. void CodeGenFunction::GenerateObjCSetter(ObjCImplementationDecl *IMP, const ObjCPropertyImplDecl *PID) { llvm::Constant *AtomicHelperFn = CodeGenFunction(CGM).GenerateObjCAtomicSetterCopyHelperFunction(PID); ObjCMethodDecl *OMD = PID->getSetterMethodDecl(); assert(OMD && "Invalid call to generate setter (empty method)"); StartObjCMethod(OMD, IMP->getClassInterface()); generateObjCSetterBody(IMP, PID, AtomicHelperFn); FinishFunction(OMD->getEndLoc()); } namespace { struct DestroyIvar final : EHScopeStack::Cleanup { private: llvm::Value *addr; const ObjCIvarDecl *ivar; CodeGenFunction::Destroyer *destroyer; bool useEHCleanupForArray; public: DestroyIvar(llvm::Value *addr, const ObjCIvarDecl *ivar, CodeGenFunction::Destroyer *destroyer, bool useEHCleanupForArray) : addr(addr), ivar(ivar), destroyer(destroyer), useEHCleanupForArray(useEHCleanupForArray) {} void Emit(CodeGenFunction &CGF, Flags flags) override { LValue lvalue = CGF.EmitLValueForIvar(CGF.TypeOfSelfObject(), addr, ivar, /*CVR*/ 0); CGF.emitDestroy(lvalue.getAddress(CGF), ivar->getType(), destroyer, flags.isForNormalCleanup() && useEHCleanupForArray); } }; } /// Like CodeGenFunction::destroyARCStrong, but do it with a call. static void destroyARCStrongWithStore(CodeGenFunction &CGF, Address addr, QualType type) { llvm::Value *null = getNullForVariable(addr); CGF.EmitARCStoreStrongCall(addr, null, /*ignored*/ true); } static void emitCXXDestructMethod(CodeGenFunction &CGF, ObjCImplementationDecl *impl) { CodeGenFunction::RunCleanupsScope scope(CGF); llvm::Value *self = CGF.LoadObjCSelf(); const ObjCInterfaceDecl *iface = impl->getClassInterface(); for (const ObjCIvarDecl *ivar = iface->all_declared_ivar_begin(); ivar; ivar = ivar->getNextIvar()) { QualType type = ivar->getType(); // Check whether the ivar is a destructible type. QualType::DestructionKind dtorKind = type.isDestructedType(); if (!dtorKind) continue; CodeGenFunction::Destroyer *destroyer = nullptr; // Use a call to objc_storeStrong to destroy strong ivars, for the // general benefit of the tools. if (dtorKind == QualType::DK_objc_strong_lifetime) { destroyer = destroyARCStrongWithStore; // Otherwise use the default for the destruction kind. } else { destroyer = CGF.getDestroyer(dtorKind); } CleanupKind cleanupKind = CGF.getCleanupKind(dtorKind); CGF.EHStack.pushCleanup<DestroyIvar>(cleanupKind, self, ivar, destroyer, cleanupKind & EHCleanup); } assert(scope.requiresCleanups() && "nothing to do in .cxx_destruct?"); } void CodeGenFunction::GenerateObjCCtorDtorMethod(ObjCImplementationDecl *IMP, ObjCMethodDecl *MD, bool ctor) { MD->createImplicitParams(CGM.getContext(), IMP->getClassInterface()); StartObjCMethod(MD, IMP->getClassInterface()); // Emit .cxx_construct. if (ctor) { // Suppress the final autorelease in ARC. AutoreleaseResult = false; for (const auto *IvarInit : IMP->inits()) { FieldDecl *Field = IvarInit->getAnyMember(); ObjCIvarDecl *Ivar = cast<ObjCIvarDecl>(Field); LValue LV = EmitLValueForIvar(TypeOfSelfObject(), LoadObjCSelf(), Ivar, 0); EmitAggExpr(IvarInit->getInit(), AggValueSlot::forLValue(LV, *this, AggValueSlot::IsDestructed, AggValueSlot::DoesNotNeedGCBarriers, AggValueSlot::IsNotAliased, AggValueSlot::DoesNotOverlap)); } // constructor returns 'self'. CodeGenTypes &Types = CGM.getTypes(); QualType IdTy(CGM.getContext().getObjCIdType()); llvm::Value *SelfAsId = Builder.CreateBitCast(LoadObjCSelf(), Types.ConvertType(IdTy)); EmitReturnOfRValue(RValue::get(SelfAsId), IdTy); // Emit .cxx_destruct. } else { emitCXXDestructMethod(*this, IMP); } FinishFunction(); } llvm::Value *CodeGenFunction::LoadObjCSelf() { VarDecl *Self = cast<ObjCMethodDecl>(CurFuncDecl)->getSelfDecl(); DeclRefExpr DRE(getContext(), Self, /*is enclosing local*/ (CurFuncDecl != CurCodeDecl), Self->getType(), VK_LValue, SourceLocation()); return EmitLoadOfScalar(EmitDeclRefLValue(&DRE), SourceLocation()); } QualType CodeGenFunction::TypeOfSelfObject() { const ObjCMethodDecl *OMD = cast<ObjCMethodDecl>(CurFuncDecl); ImplicitParamDecl *selfDecl = OMD->getSelfDecl(); const ObjCObjectPointerType *PTy = cast<ObjCObjectPointerType>( getContext().getCanonicalType(selfDecl->getType())); return PTy->getPointeeType(); } void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S){ llvm::FunctionCallee EnumerationMutationFnPtr = CGM.getObjCRuntime().EnumerationMutationFunction(); if (!EnumerationMutationFnPtr) { CGM.ErrorUnsupported(&S, "Obj-C fast enumeration for this runtime"); return; } CGCallee EnumerationMutationFn = CGCallee::forDirect(EnumerationMutationFnPtr); CGDebugInfo *DI = getDebugInfo(); if (DI) DI->EmitLexicalBlockStart(Builder, S.getSourceRange().getBegin()); RunCleanupsScope ForScope(*this); // The local variable comes into scope immediately. AutoVarEmission variable = AutoVarEmission::invalid(); if (const DeclStmt *SD = dyn_cast<DeclStmt>(S.getElement())) variable = EmitAutoVarAlloca(*cast<VarDecl>(SD->getSingleDecl())); JumpDest LoopEnd = getJumpDestInCurrentScope("forcoll.end"); // Fast enumeration state. QualType StateTy = CGM.getObjCFastEnumerationStateType(); Address StatePtr = CreateMemTemp(StateTy, "state.ptr"); EmitNullInitialization(StatePtr, StateTy); // Number of elements in the items array. static const unsigned NumItems = 16; // Fetch the countByEnumeratingWithState:objects:count: selector. IdentifierInfo *II[] = { &CGM.getContext().Idents.get("countByEnumeratingWithState"), &CGM.getContext().Idents.get("objects"), &CGM.getContext().Idents.get("count") }; Selector FastEnumSel = CGM.getContext().Selectors.getSelector(llvm::array_lengthof(II), &II[0]); QualType ItemsTy = getContext().getConstantArrayType(getContext().getObjCIdType(), llvm::APInt(32, NumItems), nullptr, ArrayType::Normal, 0); Address ItemsPtr = CreateMemTemp(ItemsTy, "items.ptr"); // Emit the collection pointer. In ARC, we do a retain. llvm::Value *Collection; if (getLangOpts().ObjCAutoRefCount) { Collection = EmitARCRetainScalarExpr(S.getCollection()); // Enter a cleanup to do the release. EmitObjCConsumeObject(S.getCollection()->getType(), Collection); } else { Collection = EmitScalarExpr(S.getCollection()); } // The 'continue' label needs to appear within the cleanup for the // collection object. JumpDest AfterBody = getJumpDestInCurrentScope("forcoll.next"); // Send it our message: CallArgList Args; // The first argument is a temporary of the enumeration-state type. Args.add(RValue::get(StatePtr.getPointer()), getContext().getPointerType(StateTy)); // The second argument is a temporary array with space for NumItems // pointers. We'll actually be loading elements from the array // pointer written into the control state; this buffer is so that // collections that *aren't* backed by arrays can still queue up // batches of elements. Args.add(RValue::get(ItemsPtr.getPointer()), getContext().getPointerType(ItemsTy)); // The third argument is the capacity of that temporary array. llvm::Type *NSUIntegerTy = ConvertType(getContext().getNSUIntegerType()); llvm::Constant *Count = llvm::ConstantInt::get(NSUIntegerTy, NumItems); Args.add(RValue::get(Count), getContext().getNSUIntegerType()); // Start the enumeration. RValue CountRV = CGM.getObjCRuntime().GenerateMessageSend(*this, ReturnValueSlot(), getContext().getNSUIntegerType(), FastEnumSel, Collection, Args); // The initial number of objects that were returned in the buffer. llvm::Value *initialBufferLimit = CountRV.getScalarVal(); llvm::BasicBlock *EmptyBB = createBasicBlock("forcoll.empty"); llvm::BasicBlock *LoopInitBB = createBasicBlock("forcoll.loopinit"); llvm::Value *zero = llvm::Constant::getNullValue(NSUIntegerTy); // If the limit pointer was zero to begin with, the collection is // empty; skip all this. Set the branch weight assuming this has the same // probability of exiting the loop as any other loop exit. uint64_t EntryCount = getCurrentProfileCount(); Builder.CreateCondBr( Builder.CreateICmpEQ(initialBufferLimit, zero, "iszero"), EmptyBB, LoopInitBB, createProfileWeights(EntryCount, getProfileCount(S.getBody()))); // Otherwise, initialize the loop. EmitBlock(LoopInitBB); // Save the initial mutations value. This is the value at an // address that was written into the state object by // countByEnumeratingWithState:objects:count:. Address StateMutationsPtrPtr = Builder.CreateStructGEP(StatePtr, 2, "mutationsptr.ptr"); llvm::Value *StateMutationsPtr = Builder.CreateLoad(StateMutationsPtrPtr, "mutationsptr"); llvm::Value *initialMutations = Builder.CreateAlignedLoad(StateMutationsPtr, getPointerAlign(), "forcoll.initial-mutations"); // Start looping. This is the point we return to whenever we have a // fresh, non-empty batch of objects. llvm::BasicBlock *LoopBodyBB = createBasicBlock("forcoll.loopbody"); EmitBlock(LoopBodyBB); // The current index into the buffer. llvm::PHINode *index = Builder.CreatePHI(NSUIntegerTy, 3, "forcoll.index"); index->addIncoming(zero, LoopInitBB); // The current buffer size. llvm::PHINode *count = Builder.CreatePHI(NSUIntegerTy, 3, "forcoll.count"); count->addIncoming(initialBufferLimit, LoopInitBB); incrementProfileCounter(&S); // Check whether the mutations value has changed from where it was // at start. StateMutationsPtr should actually be invariant between // refreshes. StateMutationsPtr = Builder.CreateLoad(StateMutationsPtrPtr, "mutationsptr"); llvm::Value *currentMutations = Builder.CreateAlignedLoad(StateMutationsPtr, getPointerAlign(), "statemutations"); llvm::BasicBlock *WasMutatedBB = createBasicBlock("forcoll.mutated"); llvm::BasicBlock *WasNotMutatedBB = createBasicBlock("forcoll.notmutated"); Builder.CreateCondBr(Builder.CreateICmpEQ(currentMutations, initialMutations), WasNotMutatedBB, WasMutatedBB); // If so, call the enumeration-mutation function. EmitBlock(WasMutatedBB); llvm::Value *V = Builder.CreateBitCast(Collection, ConvertType(getContext().getObjCIdType())); CallArgList Args2; Args2.add(RValue::get(V), getContext().getObjCIdType()); // FIXME: We shouldn't need to get the function info here, the runtime already // should have computed it to build the function. EmitCall( CGM.getTypes().arrangeBuiltinFunctionCall(getContext().VoidTy, Args2), EnumerationMutationFn, ReturnValueSlot(), Args2); // Otherwise, or if the mutation function returns, just continue. EmitBlock(WasNotMutatedBB); // Initialize the element variable. RunCleanupsScope elementVariableScope(*this); bool elementIsVariable; LValue elementLValue; QualType elementType; if (const DeclStmt *SD = dyn_cast<DeclStmt>(S.getElement())) { // Initialize the variable, in case it's a __block variable or something. EmitAutoVarInit(variable); const VarDecl *D = cast<VarDecl>(SD->getSingleDecl()); DeclRefExpr tempDRE(getContext(), const_cast<VarDecl *>(D), false, D->getType(), VK_LValue, SourceLocation()); elementLValue = EmitLValue(&tempDRE); elementType = D->getType(); elementIsVariable = true; if (D->isARCPseudoStrong()) elementLValue.getQuals().setObjCLifetime(Qualifiers::OCL_ExplicitNone); } else { elementLValue = LValue(); // suppress warning elementType = cast<Expr>(S.getElement())->getType(); elementIsVariable = false; } llvm::Type *convertedElementType = ConvertType(elementType); // Fetch the buffer out of the enumeration state. // TODO: this pointer should actually be invariant between // refreshes, which would help us do certain loop optimizations. Address StateItemsPtr = Builder.CreateStructGEP(StatePtr, 1, "stateitems.ptr"); llvm::Value *EnumStateItems = Builder.CreateLoad(StateItemsPtr, "stateitems"); // Fetch the value at the current index from the buffer. llvm::Value *CurrentItemPtr = Builder.CreateGEP(EnumStateItems, index, "currentitem.ptr"); llvm::Value *CurrentItem = Builder.CreateAlignedLoad(CurrentItemPtr, getPointerAlign()); if (SanOpts.has(SanitizerKind::ObjCCast)) { // Before using an item from the collection, check that the implicit cast // from id to the element type is valid. This is done with instrumentation // roughly corresponding to: // // if (![item isKindOfClass:expectedCls]) { /* emit diagnostic */ } const ObjCObjectPointerType *ObjPtrTy = elementType->getAsObjCInterfacePointerType(); const ObjCInterfaceType *InterfaceTy = ObjPtrTy ? ObjPtrTy->getInterfaceType() : nullptr; if (InterfaceTy) { SanitizerScope SanScope(this); auto &C = CGM.getContext(); assert(InterfaceTy->getDecl() && "No decl for ObjC interface type"); Selector IsKindOfClassSel = GetUnarySelector("isKindOfClass", C); CallArgList IsKindOfClassArgs; llvm::Value *Cls = CGM.getObjCRuntime().GetClass(*this, InterfaceTy->getDecl()); IsKindOfClassArgs.add(RValue::get(Cls), C.getObjCClassType()); llvm::Value *IsClass = CGM.getObjCRuntime() .GenerateMessageSend(*this, ReturnValueSlot(), C.BoolTy, IsKindOfClassSel, CurrentItem, IsKindOfClassArgs) .getScalarVal(); llvm::Constant *StaticData[] = { EmitCheckSourceLocation(S.getBeginLoc()), EmitCheckTypeDescriptor(QualType(InterfaceTy, 0))}; EmitCheck({{IsClass, SanitizerKind::ObjCCast}}, SanitizerHandler::InvalidObjCCast, ArrayRef<llvm::Constant *>(StaticData), CurrentItem); } } // Cast that value to the right type. CurrentItem = Builder.CreateBitCast(CurrentItem, convertedElementType, "currentitem"); // Make sure we have an l-value. Yes, this gets evaluated every // time through the loop. if (!elementIsVariable) { elementLValue = EmitLValue(cast<Expr>(S.getElement())); EmitStoreThroughLValue(RValue::get(CurrentItem), elementLValue); } else { EmitStoreThroughLValue(RValue::get(CurrentItem), elementLValue, /*isInit*/ true); } // If we do have an element variable, this assignment is the end of // its initialization. if (elementIsVariable) EmitAutoVarCleanups(variable); // Perform the loop body, setting up break and continue labels. BreakContinueStack.push_back(BreakContinue(LoopEnd, AfterBody)); { RunCleanupsScope Scope(*this); EmitStmt(S.getBody()); } BreakContinueStack.pop_back(); // Destroy the element variable now. elementVariableScope.ForceCleanup(); // Check whether there are more elements. EmitBlock(AfterBody.getBlock()); llvm::BasicBlock *FetchMoreBB = createBasicBlock("forcoll.refetch"); // First we check in the local buffer. llvm::Value *indexPlusOne = Builder.CreateAdd(index, llvm::ConstantInt::get(NSUIntegerTy, 1)); // If we haven't overrun the buffer yet, we can continue. // Set the branch weights based on the simplifying assumption that this is // like a while-loop, i.e., ignoring that the false branch fetches more // elements and then returns to the loop. Builder.CreateCondBr( Builder.CreateICmpULT(indexPlusOne, count), LoopBodyBB, FetchMoreBB, createProfileWeights(getProfileCount(S.getBody()), EntryCount)); index->addIncoming(indexPlusOne, AfterBody.getBlock()); count->addIncoming(count, AfterBody.getBlock()); // Otherwise, we have to fetch more elements. EmitBlock(FetchMoreBB); CountRV = CGM.getObjCRuntime().GenerateMessageSend(*this, ReturnValueSlot(), getContext().getNSUIntegerType(), FastEnumSel, Collection, Args); // If we got a zero count, we're done. llvm::Value *refetchCount = CountRV.getScalarVal(); // (note that the message send might split FetchMoreBB) index->addIncoming(zero, Builder.GetInsertBlock()); count->addIncoming(refetchCount, Builder.GetInsertBlock()); Builder.CreateCondBr(Builder.CreateICmpEQ(refetchCount, zero), EmptyBB, LoopBodyBB); // No more elements. EmitBlock(EmptyBB); if (!elementIsVariable) { // If the element was not a declaration, set it to be null. llvm::Value *null = llvm::Constant::getNullValue(convertedElementType); elementLValue = EmitLValue(cast<Expr>(S.getElement())); EmitStoreThroughLValue(RValue::get(null), elementLValue); } if (DI) DI->EmitLexicalBlockEnd(Builder, S.getSourceRange().getEnd()); ForScope.ForceCleanup(); EmitBlock(LoopEnd.getBlock()); } void CodeGenFunction::EmitObjCAtTryStmt(const ObjCAtTryStmt &S) { CGM.getObjCRuntime().EmitTryStmt(*this, S); } void CodeGenFunction::EmitObjCAtThrowStmt(const ObjCAtThrowStmt &S) { CGM.getObjCRuntime().EmitThrowStmt(*this, S); } void CodeGenFunction::EmitObjCAtSynchronizedStmt( const ObjCAtSynchronizedStmt &S) { CGM.getObjCRuntime().EmitSynchronizedStmt(*this, S); } namespace { struct CallObjCRelease final : EHScopeStack::Cleanup { CallObjCRelease(llvm::Value *object) : object(object) {} llvm::Value *object; void Emit(CodeGenFunction &CGF, Flags flags) override { // Releases at the end of the full-expression are imprecise. CGF.EmitARCRelease(object, ARCImpreciseLifetime); } }; } /// Produce the code for a CK_ARCConsumeObject. Does a primitive /// release at the end of the full-expression. llvm::Value *CodeGenFunction::EmitObjCConsumeObject(QualType type, llvm::Value *object) { // If we're in a conditional branch, we need to make the cleanup // conditional. pushFullExprCleanup<CallObjCRelease>(getARCCleanupKind(), object); return object; } llvm::Value *CodeGenFunction::EmitObjCExtendObjectLifetime(QualType type, llvm::Value *value) { return EmitARCRetainAutorelease(type, value); } /// Given a number of pointers, inform the optimizer that they're /// being intrinsically used up until this point in the program. void CodeGenFunction::EmitARCIntrinsicUse(ArrayRef<llvm::Value*> values) { llvm::Function *&fn = CGM.getObjCEntrypoints().clang_arc_use; if (!fn) fn = CGM.getIntrinsic(llvm::Intrinsic::objc_clang_arc_use); // This isn't really a "runtime" function, but as an intrinsic it // doesn't really matter as long as we align things up. EmitNounwindRuntimeCall(fn, values); } static void setARCRuntimeFunctionLinkage(CodeGenModule &CGM, llvm::Value *RTF) { if (auto *F = dyn_cast<llvm::Function>(RTF)) { // If the target runtime doesn't naturally support ARC, emit weak // references to the runtime support library. We don't really // permit this to fail, but we need a particular relocation style. if (!CGM.getLangOpts().ObjCRuntime.hasNativeARC() && !CGM.getTriple().isOSBinFormatCOFF()) { F->setLinkage(llvm::Function::ExternalWeakLinkage); } } } static void setARCRuntimeFunctionLinkage(CodeGenModule &CGM, llvm::FunctionCallee RTF) { setARCRuntimeFunctionLinkage(CGM, RTF.getCallee()); } /// Perform an operation having the signature /// i8* (i8*) /// where a null input causes a no-op and returns null. static llvm::Value *emitARCValueOperation( CodeGenFunction &CGF, llvm::Value *value, llvm::Type *returnType, llvm::Function *&fn, llvm::Intrinsic::ID IntID, llvm::CallInst::TailCallKind tailKind = llvm::CallInst::TCK_None) { if (isa<llvm::ConstantPointerNull>(value)) return value; if (!fn) { fn = CGF.CGM.getIntrinsic(IntID); setARCRuntimeFunctionLinkage(CGF.CGM, fn); } // Cast the argument to 'id'. llvm::Type *origType = returnType ? returnType : value->getType(); value = CGF.Builder.CreateBitCast(value, CGF.Int8PtrTy); // Call the function. llvm::CallInst *call = CGF.EmitNounwindRuntimeCall(fn, value); call->setTailCallKind(tailKind); // Cast the result back to the original type. return CGF.Builder.CreateBitCast(call, origType); } /// Perform an operation having the following signature: /// i8* (i8**) static llvm::Value *emitARCLoadOperation(CodeGenFunction &CGF, Address addr, llvm::Function *&fn, llvm::Intrinsic::ID IntID) { if (!fn) { fn = CGF.CGM.getIntrinsic(IntID); setARCRuntimeFunctionLinkage(CGF.CGM, fn); } // Cast the argument to 'id*'. llvm::Type *origType = addr.getElementType(); addr = CGF.Builder.CreateBitCast(addr, CGF.Int8PtrPtrTy); // Call the function. llvm::Value *result = CGF.EmitNounwindRuntimeCall(fn, addr.getPointer()); // Cast the result back to a dereference of the original type. if (origType != CGF.Int8PtrTy) result = CGF.Builder.CreateBitCast(result, origType); return result; } /// Perform an operation having the following signature: /// i8* (i8**, i8*) static llvm::Value *emitARCStoreOperation(CodeGenFunction &CGF, Address addr, llvm::Value *value, llvm::Function *&fn, llvm::Intrinsic::ID IntID, bool ignored) { assert(addr.getElementType() == value->getType()); if (!fn) { fn = CGF.CGM.getIntrinsic(IntID); setARCRuntimeFunctionLinkage(CGF.CGM, fn); } llvm::Type *origType = value->getType(); llvm::Value *args[] = { CGF.Builder.CreateBitCast(addr.getPointer(), CGF.Int8PtrPtrTy), CGF.Builder.CreateBitCast(value, CGF.Int8PtrTy) }; llvm::CallInst *result = CGF.EmitNounwindRuntimeCall(fn, args); if (ignored) return nullptr; return CGF.Builder.CreateBitCast(result, origType); } /// Perform an operation having the following signature: /// void (i8**, i8**) static void emitARCCopyOperation(CodeGenFunction &CGF, Address dst, Address src, llvm::Function *&fn, llvm::Intrinsic::ID IntID) { assert(dst.getType() == src.getType()); if (!fn) { fn = CGF.CGM.getIntrinsic(IntID); setARCRuntimeFunctionLinkage(CGF.CGM, fn); } llvm::Value *args[] = { CGF.Builder.CreateBitCast(dst.getPointer(), CGF.Int8PtrPtrTy), CGF.Builder.CreateBitCast(src.getPointer(), CGF.Int8PtrPtrTy) }; CGF.EmitNounwindRuntimeCall(fn, args); } /// Perform an operation having the signature /// i8* (i8*) /// where a null input causes a no-op and returns null. static llvm::Value *emitObjCValueOperation(CodeGenFunction &CGF, llvm::Value *value, llvm::Type *returnType, llvm::FunctionCallee &fn, StringRef fnName) { if (isa<llvm::ConstantPointerNull>(value)) return value; if (!fn) { llvm::FunctionType *fnType = llvm::FunctionType::get(CGF.Int8PtrTy, CGF.Int8PtrTy, false); fn = CGF.CGM.CreateRuntimeFunction(fnType, fnName); // We have Native ARC, so set nonlazybind attribute for performance if (llvm::Function *f = dyn_cast<llvm::Function>(fn.getCallee())) if (fnName == "objc_retain") f->addFnAttr(llvm::Attribute::NonLazyBind); } // Cast the argument to 'id'. llvm::Type *origType = returnType ? returnType : value->getType(); value = CGF.Builder.CreateBitCast(value, CGF.Int8PtrTy); // Call the function. llvm::CallBase *Inst = CGF.EmitCallOrInvoke(fn, value); // Cast the result back to the original type. return CGF.Builder.CreateBitCast(Inst, origType); } /// Produce the code to do a retain. Based on the type, calls one of: /// call i8* \@objc_retain(i8* %value) /// call i8* \@objc_retainBlock(i8* %value) llvm::Value *CodeGenFunction::EmitARCRetain(QualType type, llvm::Value *value) { if (type->isBlockPointerType()) return EmitARCRetainBlock(value, /*mandatory*/ false); else return EmitARCRetainNonBlock(value); } /// Retain the given object, with normal retain semantics. /// call i8* \@objc_retain(i8* %value) llvm::Value *CodeGenFunction::EmitARCRetainNonBlock(llvm::Value *value) { return emitARCValueOperation(*this, value, nullptr, CGM.getObjCEntrypoints().objc_retain, llvm::Intrinsic::objc_retain); } /// Retain the given block, with _Block_copy semantics. /// call i8* \@objc_retainBlock(i8* %value) /// /// \param mandatory - If false, emit the call with metadata /// indicating that it's okay for the optimizer to eliminate this call /// if it can prove that the block never escapes except down the stack. llvm::Value *CodeGenFunction::EmitARCRetainBlock(llvm::Value *value, bool mandatory) { llvm::Value *result = emitARCValueOperation(*this, value, nullptr, CGM.getObjCEntrypoints().objc_retainBlock, llvm::Intrinsic::objc_retainBlock); // If the copy isn't mandatory, add !clang.arc.copy_on_escape to // tell the optimizer that it doesn't need to do this copy if the // block doesn't escape, where being passed as an argument doesn't // count as escaping. if (!mandatory && isa<llvm::Instruction>(result)) { llvm::CallInst *call = cast<llvm::CallInst>(result->stripPointerCasts()); assert(call->getCalledOperand() == CGM.getObjCEntrypoints().objc_retainBlock); call->setMetadata("clang.arc.copy_on_escape", llvm::MDNode::get(Builder.getContext(), None)); } return result; } static void emitAutoreleasedReturnValueMarker(CodeGenFunction &CGF) { // Fetch the void(void) inline asm which marks that we're going to // do something with the autoreleased return value. llvm::InlineAsm *&marker = CGF.CGM.getObjCEntrypoints().retainAutoreleasedReturnValueMarker; if (!marker) { StringRef assembly = CGF.CGM.getTargetCodeGenInfo() .getARCRetainAutoreleasedReturnValueMarker(); // If we have an empty assembly string, there's nothing to do. if (assembly.empty()) { // Otherwise, at -O0, build an inline asm that we're going to call // in a moment. } else if (CGF.CGM.getCodeGenOpts().OptimizationLevel == 0) { llvm::FunctionType *type = llvm::FunctionType::get(CGF.VoidTy, /*variadic*/false); marker = llvm::InlineAsm::get(type, assembly, "", /*sideeffects*/ true); // If we're at -O1 and above, we don't want to litter the code // with this marker yet, so leave a breadcrumb for the ARC // optimizer to pick up. } else { const char *markerKey = "clang.arc.retainAutoreleasedReturnValueMarker"; if (!CGF.CGM.getModule().getModuleFlag(markerKey)) { auto *str = llvm::MDString::get(CGF.getLLVMContext(), assembly); CGF.CGM.getModule().addModuleFlag(llvm::Module::Error, markerKey, str); } } } // Call the marker asm if we made one, which we do only at -O0. if (marker) CGF.Builder.CreateCall(marker, None, CGF.getBundlesForFunclet(marker)); } /// Retain the given object which is the result of a function call. /// call i8* \@objc_retainAutoreleasedReturnValue(i8* %value) /// /// Yes, this function name is one character away from a different /// call with completely different semantics. llvm::Value * CodeGenFunction::EmitARCRetainAutoreleasedReturnValue(llvm::Value *value) { emitAutoreleasedReturnValueMarker(*this); llvm::CallInst::TailCallKind tailKind = CGM.getTargetCodeGenInfo().markARCOptimizedReturnCallsAsNoTail() ? llvm::CallInst::TCK_NoTail : llvm::CallInst::TCK_None; return emitARCValueOperation( *this, value, nullptr, CGM.getObjCEntrypoints().objc_retainAutoreleasedReturnValue, llvm::Intrinsic::objc_retainAutoreleasedReturnValue, tailKind); } /// Claim a possibly-autoreleased return value at +0. This is only /// valid to do in contexts which do not rely on the retain to keep /// the object valid for all of its uses; for example, when /// the value is ignored, or when it is being assigned to an /// __unsafe_unretained variable. /// /// call i8* \@objc_unsafeClaimAutoreleasedReturnValue(i8* %value) llvm::Value * CodeGenFunction::EmitARCUnsafeClaimAutoreleasedReturnValue(llvm::Value *value) { emitAutoreleasedReturnValueMarker(*this); llvm::CallInst::TailCallKind tailKind = CGM.getTargetCodeGenInfo().markARCOptimizedReturnCallsAsNoTail() ? llvm::CallInst::TCK_NoTail : llvm::CallInst::TCK_None; return emitARCValueOperation( *this, value, nullptr, CGM.getObjCEntrypoints().objc_unsafeClaimAutoreleasedReturnValue, llvm::Intrinsic::objc_unsafeClaimAutoreleasedReturnValue, tailKind); } /// Release the given object. /// call void \@objc_release(i8* %value) void CodeGenFunction::EmitARCRelease(llvm::Value *value, ARCPreciseLifetime_t precise) { if (isa<llvm::ConstantPointerNull>(value)) return; llvm::Function *&fn = CGM.getObjCEntrypoints().objc_release; if (!fn) { fn = CGM.getIntrinsic(llvm::Intrinsic::objc_release); setARCRuntimeFunctionLinkage(CGM, fn); } // Cast the argument to 'id'. value = Builder.CreateBitCast(value, Int8PtrTy); // Call objc_release. llvm::CallInst *call = EmitNounwindRuntimeCall(fn, value); if (precise == ARCImpreciseLifetime) { call->setMetadata("clang.imprecise_release", llvm::MDNode::get(Builder.getContext(), None)); } } /// Destroy a __strong variable. /// /// At -O0, emit a call to store 'null' into the address; /// instrumenting tools prefer this because the address is exposed, /// but it's relatively cumbersome to optimize. /// /// At -O1 and above, just load and call objc_release. /// /// call void \@objc_storeStrong(i8** %addr, i8* null) void CodeGenFunction::EmitARCDestroyStrong(Address addr, ARCPreciseLifetime_t precise) { if (CGM.getCodeGenOpts().OptimizationLevel == 0) { llvm::Value *null = getNullForVariable(addr); EmitARCStoreStrongCall(addr, null, /*ignored*/ true); return; } llvm::Value *value = Builder.CreateLoad(addr); EmitARCRelease(value, precise); } /// Store into a strong object. Always calls this: /// call void \@objc_storeStrong(i8** %addr, i8* %value) llvm::Value *CodeGenFunction::EmitARCStoreStrongCall(Address addr, llvm::Value *value, bool ignored) { assert(addr.getElementType() == value->getType()); llvm::Function *&fn = CGM.getObjCEntrypoints().objc_storeStrong; if (!fn) { fn = CGM.getIntrinsic(llvm::Intrinsic::objc_storeStrong); setARCRuntimeFunctionLinkage(CGM, fn); } llvm::Value *args[] = { Builder.CreateBitCast(addr.getPointer(), Int8PtrPtrTy), Builder.CreateBitCast(value, Int8PtrTy) }; EmitNounwindRuntimeCall(fn, args); if (ignored) return nullptr; return value; } /// Store into a strong object. Sometimes calls this: /// call void \@objc_storeStrong(i8** %addr, i8* %value) /// Other times, breaks it down into components. llvm::Value *CodeGenFunction::EmitARCStoreStrong(LValue dst, llvm::Value *newValue, bool ignored) { QualType type = dst.getType(); bool isBlock = type->isBlockPointerType(); // Use a store barrier at -O0 unless this is a block type or the // lvalue is inadequately aligned. if (shouldUseFusedARCCalls() && !isBlock && (dst.getAlignment().isZero() || dst.getAlignment() >= CharUnits::fromQuantity(PointerAlignInBytes))) { return EmitARCStoreStrongCall(dst.getAddress(*this), newValue, ignored); } // Otherwise, split it out. // Retain the new value. newValue = EmitARCRetain(type, newValue); // Read the old value. llvm::Value *oldValue = EmitLoadOfScalar(dst, SourceLocation()); // Store. We do this before the release so that any deallocs won't // see the old value. EmitStoreOfScalar(newValue, dst); // Finally, release the old value. EmitARCRelease(oldValue, dst.isARCPreciseLifetime()); return newValue; } /// Autorelease the given object. /// call i8* \@objc_autorelease(i8* %value) llvm::Value *CodeGenFunction::EmitARCAutorelease(llvm::Value *value) { return emitARCValueOperation(*this, value, nullptr, CGM.getObjCEntrypoints().objc_autorelease, llvm::Intrinsic::objc_autorelease); } /// Autorelease the given object. /// call i8* \@objc_autoreleaseReturnValue(i8* %value) llvm::Value * CodeGenFunction::EmitARCAutoreleaseReturnValue(llvm::Value *value) { return emitARCValueOperation(*this, value, nullptr, CGM.getObjCEntrypoints().objc_autoreleaseReturnValue, llvm::Intrinsic::objc_autoreleaseReturnValue, llvm::CallInst::TCK_Tail); } /// Do a fused retain/autorelease of the given object. /// call i8* \@objc_retainAutoreleaseReturnValue(i8* %value) llvm::Value * CodeGenFunction::EmitARCRetainAutoreleaseReturnValue(llvm::Value *value) { return emitARCValueOperation(*this, value, nullptr, CGM.getObjCEntrypoints().objc_retainAutoreleaseReturnValue, llvm::Intrinsic::objc_retainAutoreleaseReturnValue, llvm::CallInst::TCK_Tail); } /// Do a fused retain/autorelease of the given object. /// call i8* \@objc_retainAutorelease(i8* %value) /// or /// %retain = call i8* \@objc_retainBlock(i8* %value) /// call i8* \@objc_autorelease(i8* %retain) llvm::Value *CodeGenFunction::EmitARCRetainAutorelease(QualType type, llvm::Value *value) { if (!type->isBlockPointerType()) return EmitARCRetainAutoreleaseNonBlock(value); if (isa<llvm::ConstantPointerNull>(value)) return value; llvm::Type *origType = value->getType(); value = Builder.CreateBitCast(value, Int8PtrTy); value = EmitARCRetainBlock(value, /*mandatory*/ true); value = EmitARCAutorelease(value); return Builder.CreateBitCast(value, origType); } /// Do a fused retain/autorelease of the given object. /// call i8* \@objc_retainAutorelease(i8* %value) llvm::Value * CodeGenFunction::EmitARCRetainAutoreleaseNonBlock(llvm::Value *value) { return emitARCValueOperation(*this, value, nullptr, CGM.getObjCEntrypoints().objc_retainAutorelease, llvm::Intrinsic::objc_retainAutorelease); } /// i8* \@objc_loadWeak(i8** %addr) /// Essentially objc_autorelease(objc_loadWeakRetained(addr)). llvm::Value *CodeGenFunction::EmitARCLoadWeak(Address addr) { return emitARCLoadOperation(*this, addr, CGM.getObjCEntrypoints().objc_loadWeak, llvm::Intrinsic::objc_loadWeak); } /// i8* \@objc_loadWeakRetained(i8** %addr) llvm::Value *CodeGenFunction::EmitARCLoadWeakRetained(Address addr) { return emitARCLoadOperation(*this, addr, CGM.getObjCEntrypoints().objc_loadWeakRetained, llvm::Intrinsic::objc_loadWeakRetained); } /// i8* \@objc_storeWeak(i8** %addr, i8* %value) /// Returns %value. llvm::Value *CodeGenFunction::EmitARCStoreWeak(Address addr, llvm::Value *value, bool ignored) { return emitARCStoreOperation(*this, addr, value, CGM.getObjCEntrypoints().objc_storeWeak, llvm::Intrinsic::objc_storeWeak, ignored); } /// i8* \@objc_initWeak(i8** %addr, i8* %value) /// Returns %value. %addr is known to not have a current weak entry. /// Essentially equivalent to: /// *addr = nil; objc_storeWeak(addr, value); void CodeGenFunction::EmitARCInitWeak(Address addr, llvm::Value *value) { // If we're initializing to null, just write null to memory; no need // to get the runtime involved. But don't do this if optimization // is enabled, because accounting for this would make the optimizer // much more complicated. if (isa<llvm::ConstantPointerNull>(value) && CGM.getCodeGenOpts().OptimizationLevel == 0) { Builder.CreateStore(value, addr); return; } emitARCStoreOperation(*this, addr, value, CGM.getObjCEntrypoints().objc_initWeak, llvm::Intrinsic::objc_initWeak, /*ignored*/ true); } /// void \@objc_destroyWeak(i8** %addr) /// Essentially objc_storeWeak(addr, nil). void CodeGenFunction::EmitARCDestroyWeak(Address addr) { llvm::Function *&fn = CGM.getObjCEntrypoints().objc_destroyWeak; if (!fn) { fn = CGM.getIntrinsic(llvm::Intrinsic::objc_destroyWeak); setARCRuntimeFunctionLinkage(CGM, fn); } // Cast the argument to 'id*'. addr = Builder.CreateBitCast(addr, Int8PtrPtrTy); EmitNounwindRuntimeCall(fn, addr.getPointer()); } /// void \@objc_moveWeak(i8** %dest, i8** %src) /// Disregards the current value in %dest. Leaves %src pointing to nothing. /// Essentially (objc_copyWeak(dest, src), objc_destroyWeak(src)). void CodeGenFunction::EmitARCMoveWeak(Address dst, Address src) { emitARCCopyOperation(*this, dst, src, CGM.getObjCEntrypoints().objc_moveWeak, llvm::Intrinsic::objc_moveWeak); } /// void \@objc_copyWeak(i8** %dest, i8** %src) /// Disregards the current value in %dest. Essentially /// objc_release(objc_initWeak(dest, objc_readWeakRetained(src))) void CodeGenFunction::EmitARCCopyWeak(Address dst, Address src) { emitARCCopyOperation(*this, dst, src, CGM.getObjCEntrypoints().objc_copyWeak, llvm::Intrinsic::objc_copyWeak); } void CodeGenFunction::emitARCCopyAssignWeak(QualType Ty, Address DstAddr, Address SrcAddr) { llvm::Value *Object = EmitARCLoadWeakRetained(SrcAddr); Object = EmitObjCConsumeObject(Ty, Object); EmitARCStoreWeak(DstAddr, Object, false); } void CodeGenFunction::emitARCMoveAssignWeak(QualType Ty, Address DstAddr, Address SrcAddr) { llvm::Value *Object = EmitARCLoadWeakRetained(SrcAddr); Object = EmitObjCConsumeObject(Ty, Object); EmitARCStoreWeak(DstAddr, Object, false); EmitARCDestroyWeak(SrcAddr); } /// Produce the code to do a objc_autoreleasepool_push. /// call i8* \@objc_autoreleasePoolPush(void) llvm::Value *CodeGenFunction::EmitObjCAutoreleasePoolPush() { llvm::Function *&fn = CGM.getObjCEntrypoints().objc_autoreleasePoolPush; if (!fn) { fn = CGM.getIntrinsic(llvm::Intrinsic::objc_autoreleasePoolPush); setARCRuntimeFunctionLinkage(CGM, fn); } return EmitNounwindRuntimeCall(fn); } /// Produce the code to do a primitive release. /// call void \@objc_autoreleasePoolPop(i8* %ptr) void CodeGenFunction::EmitObjCAutoreleasePoolPop(llvm::Value *value) { assert(value->getType() == Int8PtrTy); if (getInvokeDest()) { // Call the runtime method not the intrinsic if we are handling exceptions llvm::FunctionCallee &fn = CGM.getObjCEntrypoints().objc_autoreleasePoolPopInvoke; if (!fn) { llvm::FunctionType *fnType = llvm::FunctionType::get(Builder.getVoidTy(), Int8PtrTy, false); fn = CGM.CreateRuntimeFunction(fnType, "objc_autoreleasePoolPop"); setARCRuntimeFunctionLinkage(CGM, fn); } // objc_autoreleasePoolPop can throw. EmitRuntimeCallOrInvoke(fn, value); } else { llvm::FunctionCallee &fn = CGM.getObjCEntrypoints().objc_autoreleasePoolPop; if (!fn) { fn = CGM.getIntrinsic(llvm::Intrinsic::objc_autoreleasePoolPop); setARCRuntimeFunctionLinkage(CGM, fn); } EmitRuntimeCall(fn, value); } } /// Produce the code to do an MRR version objc_autoreleasepool_push. /// Which is: [[NSAutoreleasePool alloc] init]; /// Where alloc is declared as: + (id) alloc; in NSAutoreleasePool class. /// init is declared as: - (id) init; in its NSObject super class. /// llvm::Value *CodeGenFunction::EmitObjCMRRAutoreleasePoolPush() { CGObjCRuntime &Runtime = CGM.getObjCRuntime(); llvm::Value *Receiver = Runtime.EmitNSAutoreleasePoolClassRef(*this); // [NSAutoreleasePool alloc] IdentifierInfo *II = &CGM.getContext().Idents.get("alloc"); Selector AllocSel = getContext().Selectors.getSelector(0, &II); CallArgList Args; RValue AllocRV = Runtime.GenerateMessageSend(*this, ReturnValueSlot(), getContext().getObjCIdType(), AllocSel, Receiver, Args); // [Receiver init] Receiver = AllocRV.getScalarVal(); II = &CGM.getContext().Idents.get("init"); Selector InitSel = getContext().Selectors.getSelector(0, &II); RValue InitRV = Runtime.GenerateMessageSend(*this, ReturnValueSlot(), getContext().getObjCIdType(), InitSel, Receiver, Args); return InitRV.getScalarVal(); } /// Allocate the given objc object. /// call i8* \@objc_alloc(i8* %value) llvm::Value *CodeGenFunction::EmitObjCAlloc(llvm::Value *value, llvm::Type *resultType) { return emitObjCValueOperation(*this, value, resultType, CGM.getObjCEntrypoints().objc_alloc, "objc_alloc"); } /// Allocate the given objc object. /// call i8* \@objc_allocWithZone(i8* %value) llvm::Value *CodeGenFunction::EmitObjCAllocWithZone(llvm::Value *value, llvm::Type *resultType) { return emitObjCValueOperation(*this, value, resultType, CGM.getObjCEntrypoints().objc_allocWithZone, "objc_allocWithZone"); } llvm::Value *CodeGenFunction::EmitObjCAllocInit(llvm::Value *value, llvm::Type *resultType) { return emitObjCValueOperation(*this, value, resultType, CGM.getObjCEntrypoints().objc_alloc_init, "objc_alloc_init"); } /// Produce the code to do a primitive release. /// [tmp drain]; void CodeGenFunction::EmitObjCMRRAutoreleasePoolPop(llvm::Value *Arg) { IdentifierInfo *II = &CGM.getContext().Idents.get("drain"); Selector DrainSel = getContext().Selectors.getSelector(0, &II); CallArgList Args; CGM.getObjCRuntime().GenerateMessageSend(*this, ReturnValueSlot(), getContext().VoidTy, DrainSel, Arg, Args); } void CodeGenFunction::destroyARCStrongPrecise(CodeGenFunction &CGF, Address addr, QualType type) { CGF.EmitARCDestroyStrong(addr, ARCPreciseLifetime); } void CodeGenFunction::destroyARCStrongImprecise(CodeGenFunction &CGF, Address addr, QualType type) { CGF.EmitARCDestroyStrong(addr, ARCImpreciseLifetime); } void CodeGenFunction::destroyARCWeak(CodeGenFunction &CGF, Address addr, QualType type) { CGF.EmitARCDestroyWeak(addr); } void CodeGenFunction::emitARCIntrinsicUse(CodeGenFunction &CGF, Address addr, QualType type) { llvm::Value *value = CGF.Builder.CreateLoad(addr); CGF.EmitARCIntrinsicUse(value); } /// Autorelease the given object. /// call i8* \@objc_autorelease(i8* %value) llvm::Value *CodeGenFunction::EmitObjCAutorelease(llvm::Value *value, llvm::Type *returnType) { return emitObjCValueOperation( *this, value, returnType, CGM.getObjCEntrypoints().objc_autoreleaseRuntimeFunction, "objc_autorelease"); } /// Retain the given object, with normal retain semantics. /// call i8* \@objc_retain(i8* %value) llvm::Value *CodeGenFunction::EmitObjCRetainNonBlock(llvm::Value *value, llvm::Type *returnType) { return emitObjCValueOperation( *this, value, returnType, CGM.getObjCEntrypoints().objc_retainRuntimeFunction, "objc_retain"); } /// Release the given object. /// call void \@objc_release(i8* %value) void CodeGenFunction::EmitObjCRelease(llvm::Value *value, ARCPreciseLifetime_t precise) { if (isa<llvm::ConstantPointerNull>(value)) return; llvm::FunctionCallee &fn = CGM.getObjCEntrypoints().objc_releaseRuntimeFunction; if (!fn) { llvm::FunctionType *fnType = llvm::FunctionType::get(Builder.getVoidTy(), Int8PtrTy, false); fn = CGM.CreateRuntimeFunction(fnType, "objc_release"); setARCRuntimeFunctionLinkage(CGM, fn); // We have Native ARC, so set nonlazybind attribute for performance if (llvm::Function *f = dyn_cast<llvm::Function>(fn.getCallee())) f->addFnAttr(llvm::Attribute::NonLazyBind); } // Cast the argument to 'id'. value = Builder.CreateBitCast(value, Int8PtrTy); // Call objc_release. llvm::CallBase *call = EmitCallOrInvoke(fn, value); if (precise == ARCImpreciseLifetime) { call->setMetadata("clang.imprecise_release", llvm::MDNode::get(Builder.getContext(), None)); } } namespace { struct CallObjCAutoreleasePoolObject final : EHScopeStack::Cleanup { llvm::Value *Token; CallObjCAutoreleasePoolObject(llvm::Value *token) : Token(token) {} void Emit(CodeGenFunction &CGF, Flags flags) override { CGF.EmitObjCAutoreleasePoolPop(Token); } }; struct CallObjCMRRAutoreleasePoolObject final : EHScopeStack::Cleanup { llvm::Value *Token; CallObjCMRRAutoreleasePoolObject(llvm::Value *token) : Token(token) {} void Emit(CodeGenFunction &CGF, Flags flags) override { CGF.EmitObjCMRRAutoreleasePoolPop(Token); } }; } void CodeGenFunction::EmitObjCAutoreleasePoolCleanup(llvm::Value *Ptr) { if (CGM.getLangOpts().ObjCAutoRefCount) EHStack.pushCleanup<CallObjCAutoreleasePoolObject>(NormalCleanup, Ptr); else EHStack.pushCleanup<CallObjCMRRAutoreleasePoolObject>(NormalCleanup, Ptr); } static bool shouldRetainObjCLifetime(Qualifiers::ObjCLifetime lifetime) { switch (lifetime) { case Qualifiers::OCL_None: case Qualifiers::OCL_ExplicitNone: case Qualifiers::OCL_Strong: case Qualifiers::OCL_Autoreleasing: return true; case Qualifiers::OCL_Weak: return false; } llvm_unreachable("impossible lifetime!"); } static TryEmitResult tryEmitARCRetainLoadOfScalar(CodeGenFunction &CGF, LValue lvalue, QualType type) { llvm::Value *result; bool shouldRetain = shouldRetainObjCLifetime(type.getObjCLifetime()); if (shouldRetain) { result = CGF.EmitLoadOfLValue(lvalue, SourceLocation()).getScalarVal(); } else { assert(type.getObjCLifetime() == Qualifiers::OCL_Weak); result = CGF.EmitARCLoadWeakRetained(lvalue.getAddress(CGF)); } return TryEmitResult(result, !shouldRetain); } static TryEmitResult tryEmitARCRetainLoadOfScalar(CodeGenFunction &CGF, const Expr *e) { e = e->IgnoreParens(); QualType type = e->getType(); // If we're loading retained from a __strong xvalue, we can avoid // an extra retain/release pair by zeroing out the source of this // "move" operation. if (e->isXValue() && !type.isConstQualified() && type.getObjCLifetime() == Qualifiers::OCL_Strong) { // Emit the lvalue. LValue lv = CGF.EmitLValue(e); // Load the object pointer. llvm::Value *result = CGF.EmitLoadOfLValue(lv, SourceLocation()).getScalarVal(); // Set the source pointer to NULL. CGF.EmitStoreOfScalar(getNullForVariable(lv.getAddress(CGF)), lv); return TryEmitResult(result, true); } // As a very special optimization, in ARC++, if the l-value is the // result of a non-volatile assignment, do a simple retain of the // result of the call to objc_storeWeak instead of reloading. if (CGF.getLangOpts().CPlusPlus && !type.isVolatileQualified() && type.getObjCLifetime() == Qualifiers::OCL_Weak && isa<BinaryOperator>(e) && cast<BinaryOperator>(e)->getOpcode() == BO_Assign) return TryEmitResult(CGF.EmitScalarExpr(e), false); // Try to emit code for scalar constant instead of emitting LValue and // loading it because we are not guaranteed to have an l-value. One of such // cases is DeclRefExpr referencing non-odr-used constant-evaluated variable. if (const auto *decl_expr = dyn_cast<DeclRefExpr>(e)) { auto *DRE = const_cast<DeclRefExpr *>(decl_expr); if (CodeGenFunction::ConstantEmission constant = CGF.tryEmitAsConstant(DRE)) return TryEmitResult(CGF.emitScalarConstant(constant, DRE), !shouldRetainObjCLifetime(type.getObjCLifetime())); } return tryEmitARCRetainLoadOfScalar(CGF, CGF.EmitLValue(e), type); } typedef llvm::function_ref<llvm::Value *(CodeGenFunction &CGF, llvm::Value *value)> ValueTransform; /// Insert code immediately after a call. static llvm::Value *emitARCOperationAfterCall(CodeGenFunction &CGF, llvm::Value *value, ValueTransform doAfterCall, ValueTransform doFallback) { if (llvm::CallInst *call = dyn_cast<llvm::CallInst>(value)) { CGBuilderTy::InsertPoint ip = CGF.Builder.saveIP(); // Place the retain immediately following the call. CGF.Builder.SetInsertPoint(call->getParent(), ++llvm::BasicBlock::iterator(call)); value = doAfterCall(CGF, value); CGF.Builder.restoreIP(ip); return value; } else if (llvm::InvokeInst *invoke = dyn_cast<llvm::InvokeInst>(value)) { CGBuilderTy::InsertPoint ip = CGF.Builder.saveIP(); // Place the retain at the beginning of the normal destination block. llvm::BasicBlock *BB = invoke->getNormalDest(); CGF.Builder.SetInsertPoint(BB, BB->begin()); value = doAfterCall(CGF, value); CGF.Builder.restoreIP(ip); return value; // Bitcasts can arise because of related-result returns. Rewrite // the operand. } else if (llvm::BitCastInst *bitcast = dyn_cast<llvm::BitCastInst>(value)) { llvm::Value *operand = bitcast->getOperand(0); operand = emitARCOperationAfterCall(CGF, operand, doAfterCall, doFallback); bitcast->setOperand(0, operand); return bitcast; // Generic fall-back case. } else { // Retain using the non-block variant: we never need to do a copy // of a block that's been returned to us. return doFallback(CGF, value); } } /// Given that the given expression is some sort of call (which does /// not return retained), emit a retain following it. static llvm::Value *emitARCRetainCallResult(CodeGenFunction &CGF, const Expr *e) { llvm::Value *value = CGF.EmitScalarExpr(e); return emitARCOperationAfterCall(CGF, value, [](CodeGenFunction &CGF, llvm::Value *value) { return CGF.EmitARCRetainAutoreleasedReturnValue(value); }, [](CodeGenFunction &CGF, llvm::Value *value) { return CGF.EmitARCRetainNonBlock(value); }); } /// Given that the given expression is some sort of call (which does /// not return retained), perform an unsafeClaim following it. static llvm::Value *emitARCUnsafeClaimCallResult(CodeGenFunction &CGF, const Expr *e) { llvm::Value *value = CGF.EmitScalarExpr(e); return emitARCOperationAfterCall(CGF, value, [](CodeGenFunction &CGF, llvm::Value *value) { return CGF.EmitARCUnsafeClaimAutoreleasedReturnValue(value); }, [](CodeGenFunction &CGF, llvm::Value *value) { return value; }); } llvm::Value *CodeGenFunction::EmitARCReclaimReturnedObject(const Expr *E, bool allowUnsafeClaim) { if (allowUnsafeClaim && CGM.getLangOpts().ObjCRuntime.hasARCUnsafeClaimAutoreleasedReturnValue()) { return emitARCUnsafeClaimCallResult(*this, E); } else { llvm::Value *value = emitARCRetainCallResult(*this, E); return EmitObjCConsumeObject(E->getType(), value); } } /// Determine whether it might be important to emit a separate /// objc_retain_block on the result of the given expression, or /// whether it's okay to just emit it in a +1 context. static bool shouldEmitSeparateBlockRetain(const Expr *e) { assert(e->getType()->isBlockPointerType()); e = e->IgnoreParens(); // For future goodness, emit block expressions directly in +1 // contexts if we can. if (isa<BlockExpr>(e)) return false; if (const CastExpr *cast = dyn_cast<CastExpr>(e)) { switch (cast->getCastKind()) { // Emitting these operations in +1 contexts is goodness. case CK_LValueToRValue: case CK_ARCReclaimReturnedObject: case CK_ARCConsumeObject: case CK_ARCProduceObject: return false; // These operations preserve a block type. case CK_NoOp: case CK_BitCast: return shouldEmitSeparateBlockRetain(cast->getSubExpr()); // These operations are known to be bad (or haven't been considered). case CK_AnyPointerToBlockPointerCast: default: return true; } } return true; } namespace { /// A CRTP base class for emitting expressions of retainable object /// pointer type in ARC. template <typename Impl, typename Result> class ARCExprEmitter { protected: CodeGenFunction &CGF; Impl &asImpl() { return *static_cast<Impl*>(this); } ARCExprEmitter(CodeGenFunction &CGF) : CGF(CGF) {} public: Result visit(const Expr *e); Result visitCastExpr(const CastExpr *e); Result visitPseudoObjectExpr(const PseudoObjectExpr *e); Result visitBlockExpr(const BlockExpr *e); Result visitBinaryOperator(const BinaryOperator *e); Result visitBinAssign(const BinaryOperator *e); Result visitBinAssignUnsafeUnretained(const BinaryOperator *e); Result visitBinAssignAutoreleasing(const BinaryOperator *e); Result visitBinAssignWeak(const BinaryOperator *e); Result visitBinAssignStrong(const BinaryOperator *e); // Minimal implementation: // Result visitLValueToRValue(const Expr *e) // Result visitConsumeObject(const Expr *e) // Result visitExtendBlockObject(const Expr *e) // Result visitReclaimReturnedObject(const Expr *e) // Result visitCall(const Expr *e) // Result visitExpr(const Expr *e) // // Result emitBitCast(Result result, llvm::Type *resultType) // llvm::Value *getValueOfResult(Result result) }; } /// Try to emit a PseudoObjectExpr under special ARC rules. /// /// This massively duplicates emitPseudoObjectRValue. template <typename Impl, typename Result> Result ARCExprEmitter<Impl,Result>::visitPseudoObjectExpr(const PseudoObjectExpr *E) { SmallVector<CodeGenFunction::OpaqueValueMappingData, 4> opaques; // Find the result expression. const Expr *resultExpr = E->getResultExpr(); assert(resultExpr); Result result; for (PseudoObjectExpr::const_semantics_iterator i = E->semantics_begin(), e = E->semantics_end(); i != e; ++i) { const Expr *semantic = *i; // If this semantic expression is an opaque value, bind it // to the result of its source expression. if (const OpaqueValueExpr *ov = dyn_cast<OpaqueValueExpr>(semantic)) { typedef CodeGenFunction::OpaqueValueMappingData OVMA; OVMA opaqueData; // If this semantic is the result of the pseudo-object // expression, try to evaluate the source as +1. if (ov == resultExpr) { assert(!OVMA::shouldBindAsLValue(ov)); result = asImpl().visit(ov->getSourceExpr()); opaqueData = OVMA::bind(CGF, ov, RValue::get(asImpl().getValueOfResult(result))); // Otherwise, just bind it. } else { opaqueData = OVMA::bind(CGF, ov, ov->getSourceExpr()); } opaques.push_back(opaqueData); // Otherwise, if the expression is the result, evaluate it // and remember the result. } else if (semantic == resultExpr) { result = asImpl().visit(semantic); // Otherwise, evaluate the expression in an ignored context. } else { CGF.EmitIgnoredExpr(semantic); } } // Unbind all the opaques now. for (unsigned i = 0, e = opaques.size(); i != e; ++i) opaques[i].unbind(CGF); return result; } template <typename Impl, typename Result> Result ARCExprEmitter<Impl, Result>::visitBlockExpr(const BlockExpr *e) { // The default implementation just forwards the expression to visitExpr. return asImpl().visitExpr(e); } template <typename Impl, typename Result> Result ARCExprEmitter<Impl,Result>::visitCastExpr(const CastExpr *e) { switch (e->getCastKind()) { // No-op casts don't change the type, so we just ignore them. case CK_NoOp: return asImpl().visit(e->getSubExpr()); // These casts can change the type. case CK_CPointerToObjCPointerCast: case CK_BlockPointerToObjCPointerCast: case CK_AnyPointerToBlockPointerCast: case CK_BitCast: { llvm::Type *resultType = CGF.ConvertType(e->getType()); assert(e->getSubExpr()->getType()->hasPointerRepresentation()); Result result = asImpl().visit(e->getSubExpr()); return asImpl().emitBitCast(result, resultType); } // Handle some casts specially. case CK_LValueToRValue: return asImpl().visitLValueToRValue(e->getSubExpr()); case CK_ARCConsumeObject: return asImpl().visitConsumeObject(e->getSubExpr()); case CK_ARCExtendBlockObject: return asImpl().visitExtendBlockObject(e->getSubExpr()); case CK_ARCReclaimReturnedObject: return asImpl().visitReclaimReturnedObject(e->getSubExpr()); // Otherwise, use the default logic. default: return asImpl().visitExpr(e); } } template <typename Impl, typename Result> Result ARCExprEmitter<Impl,Result>::visitBinaryOperator(const BinaryOperator *e) { switch (e->getOpcode()) { case BO_Comma: CGF.EmitIgnoredExpr(e->getLHS()); CGF.EnsureInsertPoint(); return asImpl().visit(e->getRHS()); case BO_Assign: return asImpl().visitBinAssign(e); default: return asImpl().visitExpr(e); } } template <typename Impl, typename Result> Result ARCExprEmitter<Impl,Result>::visitBinAssign(const BinaryOperator *e) { switch (e->getLHS()->getType().getObjCLifetime()) { case Qualifiers::OCL_ExplicitNone: return asImpl().visitBinAssignUnsafeUnretained(e); case Qualifiers::OCL_Weak: return asImpl().visitBinAssignWeak(e); case Qualifiers::OCL_Autoreleasing: return asImpl().visitBinAssignAutoreleasing(e); case Qualifiers::OCL_Strong: return asImpl().visitBinAssignStrong(e); case Qualifiers::OCL_None: return asImpl().visitExpr(e); } llvm_unreachable("bad ObjC ownership qualifier"); } /// The default rule for __unsafe_unretained emits the RHS recursively, /// stores into the unsafe variable, and propagates the result outward. template <typename Impl, typename Result> Result ARCExprEmitter<Impl,Result>:: visitBinAssignUnsafeUnretained(const BinaryOperator *e) { // Recursively emit the RHS. // For __block safety, do this before emitting the LHS. Result result = asImpl().visit(e->getRHS()); // Perform the store. LValue lvalue = CGF.EmitCheckedLValue(e->getLHS(), CodeGenFunction::TCK_Store); CGF.EmitStoreThroughLValue(RValue::get(asImpl().getValueOfResult(result)), lvalue); return result; } template <typename Impl, typename Result> Result ARCExprEmitter<Impl,Result>::visitBinAssignAutoreleasing(const BinaryOperator *e) { return asImpl().visitExpr(e); } template <typename Impl, typename Result> Result ARCExprEmitter<Impl,Result>::visitBinAssignWeak(const BinaryOperator *e) { return asImpl().visitExpr(e); } template <typename Impl, typename Result> Result ARCExprEmitter<Impl,Result>::visitBinAssignStrong(const BinaryOperator *e) { return asImpl().visitExpr(e); } /// The general expression-emission logic. template <typename Impl, typename Result> Result ARCExprEmitter<Impl,Result>::visit(const Expr *e) { // We should *never* see a nested full-expression here, because if // we fail to emit at +1, our caller must not retain after we close // out the full-expression. This isn't as important in the unsafe // emitter. assert(!isa<ExprWithCleanups>(e)); // Look through parens, __extension__, generic selection, etc. e = e->IgnoreParens(); // Handle certain kinds of casts. if (const CastExpr *ce = dyn_cast<CastExpr>(e)) { return asImpl().visitCastExpr(ce); // Handle the comma operator. } else if (auto op = dyn_cast<BinaryOperator>(e)) { return asImpl().visitBinaryOperator(op); // TODO: handle conditional operators here // For calls and message sends, use the retained-call logic. // Delegate inits are a special case in that they're the only // returns-retained expression that *isn't* surrounded by // a consume. } else if (isa<CallExpr>(e) || (isa<ObjCMessageExpr>(e) && !cast<ObjCMessageExpr>(e)->isDelegateInitCall())) { return asImpl().visitCall(e); // Look through pseudo-object expressions. } else if (const PseudoObjectExpr *pseudo = dyn_cast<PseudoObjectExpr>(e)) { return asImpl().visitPseudoObjectExpr(pseudo); } else if (auto *be = dyn_cast<BlockExpr>(e)) return asImpl().visitBlockExpr(be); return asImpl().visitExpr(e); } namespace { /// An emitter for +1 results. struct ARCRetainExprEmitter : public ARCExprEmitter<ARCRetainExprEmitter, TryEmitResult> { ARCRetainExprEmitter(CodeGenFunction &CGF) : ARCExprEmitter(CGF) {} llvm::Value *getValueOfResult(TryEmitResult result) { return result.getPointer(); } TryEmitResult emitBitCast(TryEmitResult result, llvm::Type *resultType) { llvm::Value *value = result.getPointer(); value = CGF.Builder.CreateBitCast(value, resultType); result.setPointer(value); return result; } TryEmitResult visitLValueToRValue(const Expr *e) { return tryEmitARCRetainLoadOfScalar(CGF, e); } /// For consumptions, just emit the subexpression and thus elide /// the retain/release pair. TryEmitResult visitConsumeObject(const Expr *e) { llvm::Value *result = CGF.EmitScalarExpr(e); return TryEmitResult(result, true); } TryEmitResult visitBlockExpr(const BlockExpr *e) { TryEmitResult result = visitExpr(e); // Avoid the block-retain if this is a block literal that doesn't need to be // copied to the heap. if (e->getBlockDecl()->canAvoidCopyToHeap()) result.setInt(true); return result; } /// Block extends are net +0. Naively, we could just recurse on /// the subexpression, but actually we need to ensure that the /// value is copied as a block, so there's a little filter here. TryEmitResult visitExtendBlockObject(const Expr *e) { llvm::Value *result; // will be a +0 value // If we can't safely assume the sub-expression will produce a // block-copied value, emit the sub-expression at +0. if (shouldEmitSeparateBlockRetain(e)) { result = CGF.EmitScalarExpr(e); // Otherwise, try to emit the sub-expression at +1 recursively. } else { TryEmitResult subresult = asImpl().visit(e); // If that produced a retained value, just use that. if (subresult.getInt()) { return subresult; } // Otherwise it's +0. result = subresult.getPointer(); } // Retain the object as a block. result = CGF.EmitARCRetainBlock(result, /*mandatory*/ true); return TryEmitResult(result, true); } /// For reclaims, emit the subexpression as a retained call and /// skip the consumption. TryEmitResult visitReclaimReturnedObject(const Expr *e) { llvm::Value *result = emitARCRetainCallResult(CGF, e); return TryEmitResult(result, true); } /// When we have an undecorated call, retroactively do a claim. TryEmitResult visitCall(const Expr *e) { llvm::Value *result = emitARCRetainCallResult(CGF, e); return TryEmitResult(result, true); } // TODO: maybe special-case visitBinAssignWeak? TryEmitResult visitExpr(const Expr *e) { // We didn't find an obvious production, so emit what we've got and // tell the caller that we didn't manage to retain. llvm::Value *result = CGF.EmitScalarExpr(e); return TryEmitResult(result, false); } }; } static TryEmitResult tryEmitARCRetainScalarExpr(CodeGenFunction &CGF, const Expr *e) { return ARCRetainExprEmitter(CGF).visit(e); } static llvm::Value *emitARCRetainLoadOfScalar(CodeGenFunction &CGF, LValue lvalue, QualType type) { TryEmitResult result = tryEmitARCRetainLoadOfScalar(CGF, lvalue, type); llvm::Value *value = result.getPointer(); if (!result.getInt()) value = CGF.EmitARCRetain(type, value); return value; } /// EmitARCRetainScalarExpr - Semantically equivalent to /// EmitARCRetainObject(e->getType(), EmitScalarExpr(e)), but making a /// best-effort attempt to peephole expressions that naturally produce /// retained objects. llvm::Value *CodeGenFunction::EmitARCRetainScalarExpr(const Expr *e) { // The retain needs to happen within the full-expression. if (const ExprWithCleanups *cleanups = dyn_cast<ExprWithCleanups>(e)) { RunCleanupsScope scope(*this); return EmitARCRetainScalarExpr(cleanups->getSubExpr()); } TryEmitResult result = tryEmitARCRetainScalarExpr(*this, e); llvm::Value *value = result.getPointer(); if (!result.getInt()) value = EmitARCRetain(e->getType(), value); return value; } llvm::Value * CodeGenFunction::EmitARCRetainAutoreleaseScalarExpr(const Expr *e) { // The retain needs to happen within the full-expression. if (const ExprWithCleanups *cleanups = dyn_cast<ExprWithCleanups>(e)) { RunCleanupsScope scope(*this); return EmitARCRetainAutoreleaseScalarExpr(cleanups->getSubExpr()); } TryEmitResult result = tryEmitARCRetainScalarExpr(*this, e); llvm::Value *value = result.getPointer(); if (result.getInt()) value = EmitARCAutorelease(value); else value = EmitARCRetainAutorelease(e->getType(), value); return value; } llvm::Value *CodeGenFunction::EmitARCExtendBlockObject(const Expr *e) { llvm::Value *result; bool doRetain; if (shouldEmitSeparateBlockRetain(e)) { result = EmitScalarExpr(e); doRetain = true; } else { TryEmitResult subresult = tryEmitARCRetainScalarExpr(*this, e); result = subresult.getPointer(); doRetain = !subresult.getInt(); } if (doRetain) result = EmitARCRetainBlock(result, /*mandatory*/ true); return EmitObjCConsumeObject(e->getType(), result); } llvm::Value *CodeGenFunction::EmitObjCThrowOperand(const Expr *expr) { // In ARC, retain and autorelease the expression. if (getLangOpts().ObjCAutoRefCount) { // Do so before running any cleanups for the full-expression. // EmitARCRetainAutoreleaseScalarExpr does this for us. return EmitARCRetainAutoreleaseScalarExpr(expr); } // Otherwise, use the normal scalar-expression emission. The // exception machinery doesn't do anything special with the // exception like retaining it, so there's no safety associated with // only running cleanups after the throw has started, and when it // matters it tends to be substantially inferior code. return EmitScalarExpr(expr); } namespace { /// An emitter for assigning into an __unsafe_unretained context. struct ARCUnsafeUnretainedExprEmitter : public ARCExprEmitter<ARCUnsafeUnretainedExprEmitter, llvm::Value*> { ARCUnsafeUnretainedExprEmitter(CodeGenFunction &CGF) : ARCExprEmitter(CGF) {} llvm::Value *getValueOfResult(llvm::Value *value) { return value; } llvm::Value *emitBitCast(llvm::Value *value, llvm::Type *resultType) { return CGF.Builder.CreateBitCast(value, resultType); } llvm::Value *visitLValueToRValue(const Expr *e) { return CGF.EmitScalarExpr(e); } /// For consumptions, just emit the subexpression and perform the /// consumption like normal. llvm::Value *visitConsumeObject(const Expr *e) { llvm::Value *value = CGF.EmitScalarExpr(e); return CGF.EmitObjCConsumeObject(e->getType(), value); } /// No special logic for block extensions. (This probably can't /// actually happen in this emitter, though.) llvm::Value *visitExtendBlockObject(const Expr *e) { return CGF.EmitARCExtendBlockObject(e); } /// For reclaims, perform an unsafeClaim if that's enabled. llvm::Value *visitReclaimReturnedObject(const Expr *e) { return CGF.EmitARCReclaimReturnedObject(e, /*unsafe*/ true); } /// When we have an undecorated call, just emit it without adding /// the unsafeClaim. llvm::Value *visitCall(const Expr *e) { return CGF.EmitScalarExpr(e); } /// Just do normal scalar emission in the default case. llvm::Value *visitExpr(const Expr *e) { return CGF.EmitScalarExpr(e); } }; } static llvm::Value *emitARCUnsafeUnretainedScalarExpr(CodeGenFunction &CGF, const Expr *e) { return ARCUnsafeUnretainedExprEmitter(CGF).visit(e); } /// EmitARCUnsafeUnretainedScalarExpr - Semantically equivalent to /// immediately releasing the resut of EmitARCRetainScalarExpr, but /// avoiding any spurious retains, including by performing reclaims /// with objc_unsafeClaimAutoreleasedReturnValue. llvm::Value *CodeGenFunction::EmitARCUnsafeUnretainedScalarExpr(const Expr *e) { // Look through full-expressions. if (const ExprWithCleanups *cleanups = dyn_cast<ExprWithCleanups>(e)) { RunCleanupsScope scope(*this); return emitARCUnsafeUnretainedScalarExpr(*this, cleanups->getSubExpr()); } return emitARCUnsafeUnretainedScalarExpr(*this, e); } std::pair<LValue,llvm::Value*> CodeGenFunction::EmitARCStoreUnsafeUnretained(const BinaryOperator *e, bool ignored) { // Evaluate the RHS first. If we're ignoring the result, assume // that we can emit at an unsafe +0. llvm::Value *value; if (ignored) { value = EmitARCUnsafeUnretainedScalarExpr(e->getRHS()); } else { value = EmitScalarExpr(e->getRHS()); } // Emit the LHS and perform the store. LValue lvalue = EmitLValue(e->getLHS()); EmitStoreOfScalar(value, lvalue); return std::pair<LValue,llvm::Value*>(std::move(lvalue), value); } std::pair<LValue,llvm::Value*> CodeGenFunction::EmitARCStoreStrong(const BinaryOperator *e, bool ignored) { // Evaluate the RHS first. TryEmitResult result = tryEmitARCRetainScalarExpr(*this, e->getRHS()); llvm::Value *value = result.getPointer(); bool hasImmediateRetain = result.getInt(); // If we didn't emit a retained object, and the l-value is of block // type, then we need to emit the block-retain immediately in case // it invalidates the l-value. if (!hasImmediateRetain && e->getType()->isBlockPointerType()) { value = EmitARCRetainBlock(value, /*mandatory*/ false); hasImmediateRetain = true; } LValue lvalue = EmitLValue(e->getLHS()); // If the RHS was emitted retained, expand this. if (hasImmediateRetain) { llvm::Value *oldValue = EmitLoadOfScalar(lvalue, SourceLocation()); EmitStoreOfScalar(value, lvalue); EmitARCRelease(oldValue, lvalue.isARCPreciseLifetime()); } else { value = EmitARCStoreStrong(lvalue, value, ignored); } return std::pair<LValue,llvm::Value*>(lvalue, value); } std::pair<LValue,llvm::Value*> CodeGenFunction::EmitARCStoreAutoreleasing(const BinaryOperator *e) { llvm::Value *value = EmitARCRetainAutoreleaseScalarExpr(e->getRHS()); LValue lvalue = EmitLValue(e->getLHS()); EmitStoreOfScalar(value, lvalue); return std::pair<LValue,llvm::Value*>(lvalue, value); } void CodeGenFunction::EmitObjCAutoreleasePoolStmt( const ObjCAutoreleasePoolStmt &ARPS) { const Stmt *subStmt = ARPS.getSubStmt(); const CompoundStmt &S = cast<CompoundStmt>(*subStmt); CGDebugInfo *DI = getDebugInfo(); if (DI) DI->EmitLexicalBlockStart(Builder, S.getLBracLoc()); // Keep track of the current cleanup stack depth. RunCleanupsScope Scope(*this); if (CGM.getLangOpts().ObjCRuntime.hasNativeARC()) { llvm::Value *token = EmitObjCAutoreleasePoolPush(); EHStack.pushCleanup<CallObjCAutoreleasePoolObject>(NormalCleanup, token); } else { llvm::Value *token = EmitObjCMRRAutoreleasePoolPush(); EHStack.pushCleanup<CallObjCMRRAutoreleasePoolObject>(NormalCleanup, token); } for (const auto *I : S.body()) EmitStmt(I); if (DI) DI->EmitLexicalBlockEnd(Builder, S.getRBracLoc()); } /// EmitExtendGCLifetime - Given a pointer to an Objective-C object, /// make sure it survives garbage collection until this point. void CodeGenFunction::EmitExtendGCLifetime(llvm::Value *object) { // We just use an inline assembly. llvm::FunctionType *extenderType = llvm::FunctionType::get(VoidTy, VoidPtrTy, RequiredArgs::All); llvm::InlineAsm *extender = llvm::InlineAsm::get(extenderType, /* assembly */ "", /* constraints */ "r", /* side effects */ true); object = Builder.CreateBitCast(object, VoidPtrTy); EmitNounwindRuntimeCall(extender, object); } /// GenerateObjCAtomicSetterCopyHelperFunction - Given a c++ object type with /// non-trivial copy assignment function, produce following helper function. /// static void copyHelper(Ty *dest, const Ty *source) { *dest = *source; } /// llvm::Constant * CodeGenFunction::GenerateObjCAtomicSetterCopyHelperFunction( const ObjCPropertyImplDecl *PID) { if (!getLangOpts().CPlusPlus || !getLangOpts().ObjCRuntime.hasAtomicCopyHelper()) return nullptr; QualType Ty = PID->getPropertyIvarDecl()->getType(); if (!Ty->isRecordType()) return nullptr; const ObjCPropertyDecl *PD = PID->getPropertyDecl(); if ((!(PD->getPropertyAttributes() & ObjCPropertyAttribute::kind_atomic))) return nullptr; llvm::Constant *HelperFn = nullptr; if (hasTrivialSetExpr(PID)) return nullptr; assert(PID->getSetterCXXAssignment() && "SetterCXXAssignment - null"); if ((HelperFn = CGM.getAtomicSetterHelperFnMap(Ty))) return HelperFn; ASTContext &C = getContext(); IdentifierInfo *II = &CGM.getContext().Idents.get("__assign_helper_atomic_property_"); QualType ReturnTy = C.VoidTy; QualType DestTy = C.getPointerType(Ty); QualType SrcTy = Ty; SrcTy.addConst(); SrcTy = C.getPointerType(SrcTy); SmallVector<QualType, 2> ArgTys; ArgTys.push_back(DestTy); ArgTys.push_back(SrcTy); QualType FunctionTy = C.getFunctionType(ReturnTy, ArgTys, {}); FunctionDecl *FD = FunctionDecl::Create( C, C.getTranslationUnitDecl(), SourceLocation(), SourceLocation(), II, FunctionTy, nullptr, SC_Static, false, false); FunctionArgList args; ImplicitParamDecl DstDecl(C, FD, SourceLocation(), /*Id=*/nullptr, DestTy, ImplicitParamDecl::Other); args.push_back(&DstDecl); ImplicitParamDecl SrcDecl(C, FD, SourceLocation(), /*Id=*/nullptr, SrcTy, ImplicitParamDecl::Other); args.push_back(&SrcDecl); const CGFunctionInfo &FI = CGM.getTypes().arrangeBuiltinFunctionDeclaration(ReturnTy, args); llvm::FunctionType *LTy = CGM.getTypes().GetFunctionType(FI); llvm::Function *Fn = llvm::Function::Create(LTy, llvm::GlobalValue::InternalLinkage, "__assign_helper_atomic_property_", &CGM.getModule()); CGM.SetInternalFunctionAttributes(GlobalDecl(), Fn, FI); StartFunction(FD, ReturnTy, Fn, FI, args); DeclRefExpr DstExpr(C, &DstDecl, false, DestTy, VK_RValue, SourceLocation()); UnaryOperator *DST = UnaryOperator::Create( C, &DstExpr, UO_Deref, DestTy->getPointeeType(), VK_LValue, OK_Ordinary, SourceLocation(), false, FPOptionsOverride()); DeclRefExpr SrcExpr(C, &SrcDecl, false, SrcTy, VK_RValue, SourceLocation()); UnaryOperator *SRC = UnaryOperator::Create( C, &SrcExpr, UO_Deref, SrcTy->getPointeeType(), VK_LValue, OK_Ordinary, SourceLocation(), false, FPOptionsOverride()); Expr *Args[2] = {DST, SRC}; CallExpr *CalleeExp = cast<CallExpr>(PID->getSetterCXXAssignment()); CXXOperatorCallExpr *TheCall = CXXOperatorCallExpr::Create( C, OO_Equal, CalleeExp->getCallee(), Args, DestTy->getPointeeType(), VK_LValue, SourceLocation(), FPOptionsOverride()); EmitStmt(TheCall); FinishFunction(); HelperFn = CGM.getFunctionPointer(Fn, FD->getType()); HelperFn = llvm::ConstantExpr::getBitCast(HelperFn, VoidPtrTy); CGM.setAtomicSetterHelperFnMap(Ty, HelperFn); return HelperFn; } llvm::Constant * CodeGenFunction::GenerateObjCAtomicGetterCopyHelperFunction( const ObjCPropertyImplDecl *PID) { if (!getLangOpts().CPlusPlus || !getLangOpts().ObjCRuntime.hasAtomicCopyHelper()) return nullptr; const ObjCPropertyDecl *PD = PID->getPropertyDecl(); QualType Ty = PD->getType(); if (!Ty->isRecordType()) return nullptr; if ((!(PD->getPropertyAttributes() & ObjCPropertyAttribute::kind_atomic))) return nullptr; llvm::Constant *HelperFn = nullptr; if (hasTrivialGetExpr(PID)) return nullptr; assert(PID->getGetterCXXConstructor() && "getGetterCXXConstructor - null"); if ((HelperFn = CGM.getAtomicGetterHelperFnMap(Ty))) return HelperFn; ASTContext &C = getContext(); IdentifierInfo *II = &CGM.getContext().Idents.get("__copy_helper_atomic_property_"); QualType ReturnTy = C.VoidTy; QualType DestTy = C.getPointerType(Ty); QualType SrcTy = Ty; SrcTy.addConst(); SrcTy = C.getPointerType(SrcTy); SmallVector<QualType, 2> ArgTys; ArgTys.push_back(DestTy); ArgTys.push_back(SrcTy); QualType FunctionTy = C.getFunctionType(ReturnTy, ArgTys, {}); FunctionDecl *FD = FunctionDecl::Create( C, C.getTranslationUnitDecl(), SourceLocation(), SourceLocation(), II, FunctionTy, nullptr, SC_Static, false, false); FunctionArgList args; ImplicitParamDecl DstDecl(C, FD, SourceLocation(), /*Id=*/nullptr, DestTy, ImplicitParamDecl::Other); args.push_back(&DstDecl); ImplicitParamDecl SrcDecl(C, FD, SourceLocation(), /*Id=*/nullptr, SrcTy, ImplicitParamDecl::Other); args.push_back(&SrcDecl); const CGFunctionInfo &FI = CGM.getTypes().arrangeBuiltinFunctionDeclaration(ReturnTy, args); llvm::FunctionType *LTy = CGM.getTypes().GetFunctionType(FI); llvm::Function *Fn = llvm::Function::Create( LTy, llvm::GlobalValue::InternalLinkage, "__copy_helper_atomic_property_", &CGM.getModule()); CGM.SetInternalFunctionAttributes(GlobalDecl(), Fn, FI); StartFunction(FD, ReturnTy, Fn, FI, args); DeclRefExpr SrcExpr(getContext(), &SrcDecl, false, SrcTy, VK_RValue, SourceLocation()); UnaryOperator *SRC = UnaryOperator::Create( C, &SrcExpr, UO_Deref, SrcTy->getPointeeType(), VK_LValue, OK_Ordinary, SourceLocation(), false, FPOptionsOverride()); CXXConstructExpr *CXXConstExpr = cast<CXXConstructExpr>(PID->getGetterCXXConstructor()); SmallVector<Expr*, 4> ConstructorArgs; ConstructorArgs.push_back(SRC); ConstructorArgs.append(std::next(CXXConstExpr->arg_begin()), CXXConstExpr->arg_end()); CXXConstructExpr *TheCXXConstructExpr = CXXConstructExpr::Create(C, Ty, SourceLocation(), CXXConstExpr->getConstructor(), CXXConstExpr->isElidable(), ConstructorArgs, CXXConstExpr->hadMultipleCandidates(), CXXConstExpr->isListInitialization(), CXXConstExpr->isStdInitListInitialization(), CXXConstExpr->requiresZeroInitialization(), CXXConstExpr->getConstructionKind(), SourceRange()); DeclRefExpr DstExpr(getContext(), &DstDecl, false, DestTy, VK_RValue, SourceLocation()); RValue DV = EmitAnyExpr(&DstExpr); CharUnits Alignment = getContext().getTypeAlignInChars(TheCXXConstructExpr->getType()); EmitAggExpr(TheCXXConstructExpr, AggValueSlot::forAddr(Address(DV.getScalarVal(), Alignment), Qualifiers(), AggValueSlot::IsDestructed, AggValueSlot::DoesNotNeedGCBarriers, AggValueSlot::IsNotAliased, AggValueSlot::DoesNotOverlap)); FinishFunction(); HelperFn = CGM.getFunctionPointer(Fn, FD->getType()); HelperFn = llvm::ConstantExpr::getBitCast(HelperFn, VoidPtrTy); CGM.setAtomicGetterHelperFnMap(Ty, HelperFn); return HelperFn; } llvm::Value * CodeGenFunction::EmitBlockCopyAndAutorelease(llvm::Value *Block, QualType Ty) { // Get selectors for retain/autorelease. IdentifierInfo *CopyID = &getContext().Idents.get("copy"); Selector CopySelector = getContext().Selectors.getNullarySelector(CopyID); IdentifierInfo *AutoreleaseID = &getContext().Idents.get("autorelease"); Selector AutoreleaseSelector = getContext().Selectors.getNullarySelector(AutoreleaseID); // Emit calls to retain/autorelease. CGObjCRuntime &Runtime = CGM.getObjCRuntime(); llvm::Value *Val = Block; RValue Result; Result = Runtime.GenerateMessageSend(*this, ReturnValueSlot(), Ty, CopySelector, Val, CallArgList(), nullptr, nullptr); Val = Result.getScalarVal(); Result = Runtime.GenerateMessageSend(*this, ReturnValueSlot(), Ty, AutoreleaseSelector, Val, CallArgList(), nullptr, nullptr); Val = Result.getScalarVal(); return Val; } llvm::Value * CodeGenFunction::EmitBuiltinAvailable(ArrayRef<llvm::Value *> Args) { assert(Args.size() == 3 && "Expected 3 argument here!"); if (!CGM.IsOSVersionAtLeastFn) { llvm::FunctionType *FTy = llvm::FunctionType::get(Int32Ty, {Int32Ty, Int32Ty, Int32Ty}, false); CGM.IsOSVersionAtLeastFn = CGM.CreateRuntimeFunction(FTy, "__isOSVersionAtLeast"); } llvm::Value *CallRes = EmitNounwindRuntimeCall(CGM.IsOSVersionAtLeastFn, Args); return Builder.CreateICmpNE(CallRes, llvm::Constant::getNullValue(Int32Ty)); } void CodeGenModule::emitAtAvailableLinkGuard() { if (!IsOSVersionAtLeastFn) return; // @available requires CoreFoundation only on Darwin. if (!Target.getTriple().isOSDarwin()) return; // Add -framework CoreFoundation to the linker commands. We still want to // emit the core foundation reference down below because otherwise if // CoreFoundation is not used in the code, the linker won't link the // framework. auto &Context = getLLVMContext(); llvm::Metadata *Args[2] = {llvm::MDString::get(Context, "-framework"), llvm::MDString::get(Context, "CoreFoundation")}; LinkerOptionsMetadata.push_back(llvm::MDNode::get(Context, Args)); // Emit a reference to a symbol from CoreFoundation to ensure that // CoreFoundation is linked into the final binary. llvm::FunctionType *FTy = llvm::FunctionType::get(Int32Ty, {VoidPtrTy}, false); llvm::FunctionCallee CFFunc = CreateRuntimeFunction(FTy, "CFBundleGetVersionNumber"); llvm::FunctionType *CheckFTy = llvm::FunctionType::get(VoidTy, {}, false); llvm::FunctionCallee CFLinkCheckFuncRef = CreateRuntimeFunction( CheckFTy, "__clang_at_available_requires_core_foundation_framework", llvm::AttributeList(), /*Local=*/true); llvm::Function *CFLinkCheckFunc = cast<llvm::Function>(CFLinkCheckFuncRef.getCallee()->stripPointerCasts()); if (CFLinkCheckFunc->empty()) { CFLinkCheckFunc->setLinkage(llvm::GlobalValue::LinkOnceAnyLinkage); CFLinkCheckFunc->setVisibility(llvm::GlobalValue::HiddenVisibility); CodeGenFunction CGF(*this); CGF.Builder.SetInsertPoint(CGF.createBasicBlock("", CFLinkCheckFunc)); CGF.EmitNounwindRuntimeCall(CFFunc, llvm::Constant::getNullValue(VoidPtrTy)); CGF.Builder.CreateUnreachable(); addCompilerUsedGlobal(CFLinkCheckFunc); } } CGObjCRuntime::~CGObjCRuntime() {}
.global s_prepare_buffers s_prepare_buffers: ret .global s_faulty_load s_faulty_load: push %r10 push %r8 push %rax push %rcx push %rdi push %rdx // Store lea addresses_RW+0x110a5, %rcx nop nop nop nop nop cmp $19923, %rdi mov $0x5152535455565758, %r8 movq %r8, %xmm2 movups %xmm2, (%rcx) nop and %rcx, %rcx // Faulty Load lea addresses_RW+0x110a5, %rax clflush (%rax) nop nop nop nop nop sub $31587, %rdi mov (%rax), %r8d lea oracles, %rdi and $0xff, %r8 shlq $12, %r8 mov (%rdi,%r8,1), %r8 pop %rdx pop %rdi pop %rcx pop %rax pop %r8 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'NT': False, 'AVXalign': False, 'size': 1, 'type': 'addresses_RW', 'congruent': 0}} {'dst': {'same': True, 'NT': False, 'AVXalign': False, 'size': 16, 'type': 'addresses_RW', 'congruent': 0}, 'OP': 'STOR'} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'NT': False, 'AVXalign': False, 'size': 4, 'type': 'addresses_RW', 'congruent': 0}} <gen_prepare_buffer> {'58': 8} 58 58 58 58 58 58 58 58 */
; A287553: Positions of 1 in A053839. ; 2,5,12,15,17,24,27,30,36,39,42,45,51,54,57,64,65,72,75,78,84,87,90,93,99,102,105,112,114,117,124,127,132,135,138,141,147,150,153,160,162,165,172,175,177,184,187,190,195,198,201,208,210,213,220,223,225,232,235,238,244,247,250,253,257,264,267,270,276,279,282,285,291,294,297,304,306,309,316,319,324,327,330,333,339,342,345,352,354,357,364,367,369,376,379,382,387,390,393,400,402,405,412,415,417,424,427,430,436,439,442,445,450,453,460,463,465,472,475,478,484,487,490,493,499,502,505,512,516,519,522,525,531,534,537,544,546,549,556,559,561,568,571,574,579,582,585,592,594,597,604,607,609,616,619,622,628,631,634,637,642,645,652,655,657,664,667,670,676,679,682,685,691,694,697,704,705,712,715,718,724,727,730,733,739,742,745,752,754,757,764,767,771,774,777,784,786,789,796,799,801,808,811,814,820,823,826,829,834,837,844,847,849,856,859,862,868,871,874,877,883,886,889,896,897,904,907,910,916,919,922,925,931,934,937,944,946,949,956,959,964,967,970,973,979,982,985,992,994,997 mov $2,$0 mov $3,$0 mul $3,8 add $3,4 mov $0,$3 mov $5,$3 lpb $0,1 add $0,$5 lpb $0,1 add $3,$0 div $0,4 lpe lpe sub $0,1 mov $1,$0 lpb $3,1 mod $3,4 lpe mul $1,$3 add $1,4 mov $4,$2 mul $4,4 add $1,$4
#include "utils.h" #ifdef SMTRAT_DEVOPTION_Statistics namespace smtrat { namespace mcsat { namespace onecellcad { OCStatistics &getStatistic() { static OCStatistics &mStatistics = statistics_get<OCStatistics>("mcsat-explanation-onecellcad"); return mStatistics; } } } } #endif
; ; jcgryext.asm - grayscale colorspace conversion (64-bit AVX2) ; ; Copyright (C) 2011, 2016, D. R. Commander. ; Copyright (C) 2015, Intel Corporation. ; ; Based on the x86 SIMD extension for IJG JPEG library ; Copyright (C) 1999-2006, MIYASAKA Masaru. ; For conditions of distribution and use, see copyright notice in jsimdext.inc ; ; This file should be assembled with NASM (Netwide Assembler), ; can *not* be assembled with Microsoft's MASM or any compatible ; assembler (including Borland's Turbo Assembler). ; NASM is available from http://nasm.sourceforge.net/ or ; http://sourceforge.net/project/showfiles.php?group_id=6208 ; ; [TAB8] %include "jcolsamp.inc" ; -------------------------------------------------------------------------- ; ; Convert some rows of samples to the output colorspace. ; ; GLOBAL(void) ; jsimd_rgb_gray_convert_avx2(JDIMENSION img_width, JSAMPARRAY input_buf, ; JSAMPIMAGE output_buf, JDIMENSION output_row, ; int num_rows); ; ; r10d = JDIMENSION img_width ; r11 = JSAMPARRAY input_buf ; r12 = JSAMPIMAGE output_buf ; r13d = JDIMENSION output_row ; r14d = int num_rows %define wk(i) rbp - (WK_NUM - (i)) * SIZEOF_YMMWORD ; ymmword wk[WK_NUM] %define WK_NUM 2 align 32 GLOBAL_FUNCTION(jsimd_rgb_gray_convert_avx2) EXTN(jsimd_rgb_gray_convert_avx2): push rbp mov rax, rsp ; rax = original rbp sub rsp, byte 4 and rsp, byte (-SIZEOF_YMMWORD) ; align to 256 bits mov [rsp], rax mov rbp, rsp ; rbp = aligned rbp lea rsp, [wk(0)] collect_args 5 push rbx mov ecx, r10d test rcx, rcx jz near .return push rcx mov rsi, r12 mov ecx, r13d mov rdi, JSAMPARRAY [rsi+0*SIZEOF_JSAMPARRAY] lea rdi, [rdi+rcx*SIZEOF_JSAMPROW] pop rcx mov rsi, r11 mov eax, r14d test rax, rax jle near .return .rowloop: push rdi push rsi push rcx ; col mov rsi, JSAMPROW [rsi] ; inptr mov rdi, JSAMPROW [rdi] ; outptr0 cmp rcx, byte SIZEOF_YMMWORD jae near .columnloop %if RGB_PIXELSIZE == 3 ; --------------- .column_ld1: push rax push rdx lea rcx, [rcx+rcx*2] ; imul ecx,RGB_PIXELSIZE test cl, SIZEOF_BYTE jz short .column_ld2 sub rcx, byte SIZEOF_BYTE movzx rax, BYTE [rsi+rcx] .column_ld2: test cl, SIZEOF_WORD jz short .column_ld4 sub rcx, byte SIZEOF_WORD movzx rdx, WORD [rsi+rcx] shl rax, WORD_BIT or rax, rdx .column_ld4: vmovd xmmA, eax pop rdx pop rax test cl, SIZEOF_DWORD jz short .column_ld8 sub rcx, byte SIZEOF_DWORD vmovd xmmF, XMM_DWORD [rsi+rcx] vpslldq xmmA, xmmA, SIZEOF_DWORD vpor xmmA, xmmA, xmmF .column_ld8: test cl, SIZEOF_MMWORD jz short .column_ld16 sub rcx, byte SIZEOF_MMWORD vmovq xmmB, XMM_MMWORD [rsi+rcx] vpslldq xmmA, xmmA, SIZEOF_MMWORD vpor xmmA, xmmA, xmmB .column_ld16: test cl, SIZEOF_XMMWORD jz short .column_ld32 sub rcx, byte SIZEOF_XMMWORD vmovdqu xmmB, XMM_MMWORD [rsi+rcx] vperm2i128 ymmA, ymmA, ymmA, 1 vpor ymmA, ymmB .column_ld32: test cl, SIZEOF_YMMWORD jz short .column_ld64 sub rcx, byte SIZEOF_YMMWORD vmovdqa ymmF, ymmA vmovdqu ymmA, YMMWORD [rsi+0*SIZEOF_YMMWORD] .column_ld64: test cl, 2*SIZEOF_YMMWORD mov rcx, SIZEOF_YMMWORD jz short .rgb_gray_cnv vmovdqa ymmB, ymmA vmovdqu ymmA, YMMWORD [rsi+0*SIZEOF_YMMWORD] vmovdqu ymmF, YMMWORD [rsi+1*SIZEOF_YMMWORD] jmp short .rgb_gray_cnv .columnloop: vmovdqu ymmA, YMMWORD [rsi+0*SIZEOF_YMMWORD] vmovdqu ymmF, YMMWORD [rsi+1*SIZEOF_YMMWORD] vmovdqu ymmB, YMMWORD [rsi+2*SIZEOF_YMMWORD] .rgb_gray_cnv: ; ymmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05 ; 15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A) ; ymmF=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F ; 0G 1G 2G 0H 1H 2H 0I 1I 2I 0J 1J 2J 0K 1K 2K 0L) ; ymmB=(1L 2L 0M 1M 2M 0N 1N 2N 0O 1O 2O 0P 1P 2P 0Q 1Q ; 2Q 0R 1R 2R 0S 1S 2S 0T 1T 2T 0U 1U 2U 0V 1V 2V) vmovdqu ymmC, ymmA vinserti128 ymmA, ymmF, xmmA, 0 ; ymmA=(00 10 20 01 11 21 02 12 22 03 13 23 04 14 24 05 ; 0G 1G 2G 0H 1H 2H 0I 1I 2I 0J 1J 2J 0K 1K 2K 0L) vinserti128 ymmC, ymmC, xmmB, 0 ; ymmC=(1L 2L 0M 1M 2M 0N 1N 2N 0O 1O 2O 0P 1P 2P 0Q 1Q ; 15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A) vinserti128 ymmB, ymmB, xmmF, 0 ; ymmB=(2A 0B 1B 2B 0C 1C 2C 0D 1D 2D 0E 1E 2E 0F 1F 2F ; 2Q 0R 1R 2R 0S 1S 2S 0T 1T 2T 0U 1U 2U 0V 1V 2V) vperm2i128 ymmF, ymmC, ymmC, 1 ; ymmF=(15 25 06 16 26 07 17 27 08 18 28 09 19 29 0A 1A ; 1L 2L 0M 1M 2M 0N 1N 2N 0O 1O 2O 0P 1P 2P 0Q 1Q) vmovdqa ymmG, ymmA vpslldq ymmA, ymmA, 8 ; ymmA=(-- -- -- -- -- -- -- -- 00 10 20 01 11 21 02 12 ; 22 03 13 23 04 14 24 05 0G 1G 2G 0H 1H 2H 0I 1I) vpsrldq ymmG, ymmG, 8 ; ymmG=(22 03 13 23 04 14 24 05 0G 1G 2G 0H 1H 2H 0I 1I ; 2I 0J 1J 2J 0K 1K 2K 0L -- -- -- -- -- -- -- --) vpunpckhbw ymmA, ymmA, ymmF ; ymmA=(00 08 10 18 20 28 01 09 11 19 21 29 02 0A 12 1A ; 0G 0O 1G 1O 2G 2O 0H 0P 1H 1P 2H 2P 0I 0Q 1I 1Q) vpslldq ymmF, ymmF, 8 ; ymmF=(-- -- -- -- -- -- -- -- 15 25 06 16 26 07 17 27 ; 08 18 28 09 19 29 0A 1A 1L 2L 0M 1M 2M 0N 1N 2N) vpunpcklbw ymmG, ymmG, ymmB ; ymmG=(22 2A 03 0B 13 1B 23 2B 04 0C 14 1C 24 2C 05 0D ; 2I 2Q 0J 0R 1J 1R 2J 2R 0K 0S 1K 1S 2K 2S 0L 0T) vpunpckhbw ymmF, ymmF, ymmB ; ymmF=(15 1D 25 2D 06 0E 16 1E 26 2E 07 0F 17 1F 27 2F ; 1L 1T 2L 2T 0M 0U 1M 1U 2M 2U 0N 0V 1N 1V 2N 2V) vmovdqa ymmD, ymmA vpslldq ymmA, ymmA, 8 ; ymmA=(-- -- -- -- -- -- -- -- 00 08 10 18 20 28 01 09 ; 11 19 21 29 02 0A 12 1A 0G 0O 1G 1O 2G 2O 0H 0P) vpsrldq ymmD, ymmD, 8 ; ymmD=(11 19 21 29 02 0A 12 1A 0G 0O 1G 1O 2G 2O 0H 0P ; 1H 1P 2H 2P 0I 0Q 1I 1Q -- -- -- -- -- -- -- --) vpunpckhbw ymmA, ymmA, ymmG ; ymmA=(00 04 08 0C 10 14 18 1C 20 24 28 2C 01 05 09 0D ; 0G 0K 0O 0S 1G 1K 1O 1S 2G 2K 2O 2S 0H 0L 0P 0T) vpslldq ymmG, ymmG, 8 ; ymmG=(-- -- -- -- -- -- -- -- 22 2A 03 0B 13 1B 23 2B ; 04 0C 14 1C 24 2C 05 0D 2I 2Q 0J 0R 1J 1R 2J 2R) vpunpcklbw ymmD, ymmD, ymmF ; ymmD=(11 15 19 1D 21 25 29 2D 02 06 0A 0E 12 16 1A 1E ; 1H 1L 1P 1T 2H 2L 2P 2T 0I 0M 0Q 0U 1I 1M 1Q 1U) vpunpckhbw ymmG, ymmG, ymmF ; ymmG=(22 26 2A 2E 03 07 0B 0F 13 17 1B 1F 23 27 2B 2F ; 2I 2M 2Q 2U 0J 0N 0R 0V 1J 1N 1R 1V 2J 2N 2R 2V) vmovdqa ymmE, ymmA vpslldq ymmA, ymmA, 8 ; ymmA=(-- -- -- -- -- -- -- -- 00 04 08 0C 10 14 18 1C ; 20 24 28 2C 01 05 09 0D 0G 0K 0O 0S 1G 1K 1O 1S) vpsrldq ymmE, ymmE, 8 ; ymmE=(20 24 28 2C 01 05 09 0D 0G 0K 0O 0S 1G 1K 1O 1S ; 2G 2K 2O 2S 0H 0L 0P 0T -- -- -- -- -- -- -- --) vpunpckhbw ymmA, ymmA, ymmD ; ymmA=(00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E ; 0G 0I 0K 0M 0O 0Q 0S 0U 1G 1I 1K 1M 1O 1Q 1S 1U) vpslldq ymmD, ymmD, 8 ; ymmD=(-- -- -- -- -- -- -- -- 11 15 19 1D 21 25 29 2D ; 02 06 0A 0E 12 16 1A 1E 1H 1L 1P 1T 2H 2L 2P 2T) vpunpcklbw ymmE, ymmE, ymmG ; ymmE=(20 22 24 26 28 2A 2C 2E 01 03 05 07 09 0B 0D 0F ; 2G 2I 2K 2M 2O 2Q 2S 2U 0H 0J 0L 0N 0P 0R 0T 0V) vpunpckhbw ymmD, ymmD, ymmG ; ymmD=(11 13 15 17 19 1B 1D 1F 21 23 25 27 29 2B 2D 2F ; 1H 1J 1L 1N 1P 1R 1T 1V 2H 2J 2L 2N 2P 2R 2T 2V) vpxor ymmH, ymmH, ymmH vmovdqa ymmC, ymmA vpunpcklbw ymmA, ymmA, ymmH ; ymmA=(00 02 04 06 08 0A 0C 0E 0G 0I 0K 0M 0O 0Q 0S 0U) vpunpckhbw ymmC, ymmC, ymmH ; ymmC=(10 12 14 16 18 1A 1C 1E 1G 1I 1K 1M 1O 1Q 1S 1U) vmovdqa ymmB, ymmE vpunpcklbw ymmE, ymmE, ymmH ; ymmE=(20 22 24 26 28 2A 2C 2E 2G 2I 2K 2M 2O 2Q 2S 2U) vpunpckhbw ymmB, ymmB, ymmH ; ymmB=(01 03 05 07 09 0B 0D 0F 0H 0J 0L 0N 0P 0R 0T 0V) vmovdqa ymmF, ymmD vpunpcklbw ymmD, ymmD, ymmH ; ymmD=(11 13 15 17 19 1B 1D 1F 1H 1J 1L 1N 1P 1R 1T 1V) vpunpckhbw ymmF, ymmF, ymmH ; ymmF=(21 23 25 27 29 2B 2D 2F 2H 2J 2L 2N 2P 2R 2T 2V) %else ; RGB_PIXELSIZE == 4 ; ----------- .column_ld1: test cl, SIZEOF_XMMWORD/16 jz short .column_ld2 sub rcx, byte SIZEOF_XMMWORD/16 vmovd xmmA, XMM_DWORD [rsi+rcx*RGB_PIXELSIZE] .column_ld2: test cl, SIZEOF_XMMWORD/8 jz short .column_ld4 sub rcx, byte SIZEOF_XMMWORD/8 vmovq xmmF, XMM_MMWORD [rsi+rcx*RGB_PIXELSIZE] vpslldq xmmA, xmmA, SIZEOF_MMWORD vpor xmmA, xmmA, xmmF .column_ld4: test cl, SIZEOF_XMMWORD/4 jz short .column_ld8 sub rcx, byte SIZEOF_XMMWORD/4 vmovdqa xmmF, xmmA vperm2i128 ymmF, ymmF, ymmF, 1 vmovdqu xmmA, XMMWORD [rsi+rcx*RGB_PIXELSIZE] vpor ymmA, ymmA, ymmF .column_ld8: test cl, SIZEOF_XMMWORD/2 jz short .column_ld16 sub rcx, byte SIZEOF_XMMWORD/2 vmovdqa ymmF, ymmA vmovdqu ymmA, YMMWORD [rsi+rcx*RGB_PIXELSIZE] .column_ld16: test cl, SIZEOF_XMMWORD mov rcx, SIZEOF_YMMWORD jz short .rgb_gray_cnv vmovdqa ymmE, ymmA vmovdqa ymmH, ymmF vmovdqu ymmA, YMMWORD [rsi+0*SIZEOF_YMMWORD] vmovdqu ymmF, YMMWORD [rsi+1*SIZEOF_YMMWORD] jmp short .rgb_gray_cnv .columnloop: vmovdqu ymmA, YMMWORD [rsi+0*SIZEOF_YMMWORD] vmovdqu ymmF, YMMWORD [rsi+1*SIZEOF_YMMWORD] vmovdqu ymmE, YMMWORD [rsi+2*SIZEOF_YMMWORD] vmovdqu ymmH, YMMWORD [rsi+3*SIZEOF_YMMWORD] .rgb_gray_cnv: ; ymmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33 ; 04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37) ; ymmF=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B ; 0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F) ; ymmE=(0G 1G 2G 3G 0H 1H 2H 3H 0I 1I 2I 3I 0J 1J 2J 3J ; 0K 1K 2K 3K 0L 1L 2L 3L 0M 1M 2M 3M 0N 1N 2N 3N) ; ymmH=(0O 1O 2O 3O 0P 1P 2P 3P 0Q 1Q 2Q 3Q 0R 1R 2R 3R ; 0S 1S 2S 3S 0T 1T 2T 3T 0U 1U 2U 3U 0V 1V 2V 3V) vmovdqa ymmB, ymmA vinserti128 ymmA, ymmA, xmmE, 1 ; ymmA=(00 10 20 30 01 11 21 31 02 12 22 32 03 13 23 33 ; 0G 1G 2G 3G 0H 1H 2H 3H 0I 1I 2I 3I 0J 1J 2J 3J) vperm2i128 ymmE, ymmB, ymmE, 0x31 ; ymmE=(04 14 24 34 05 15 25 35 06 16 26 36 07 17 27 37 ; 0K 1K 2K 3K 0L 1L 2L 3L 0M 1M 2M 3M 0N 1N 2N 3N) vmovdqa ymmB, ymmF vinserti128 ymmF, ymmF, xmmH, 1 ; ymmF=(08 18 28 38 09 19 29 39 0A 1A 2A 3A 0B 1B 2B 3B ; 0O 1O 2O 3O 0P 1P 2P 3P 0Q 1Q 2Q 3Q 0R 1R 2R 3R) vperm2i128 ymmH, ymmB, ymmH, 0x31 ; ymmH=(0C 1C 2C 3C 0D 1D 2D 3D 0E 1E 2E 3E 0F 1F 2F 3F ; 0S 1S 2S 3S 0T 1T 2T 3T 0U 1U 2U 3U 0V 1V 2V 3V) vmovdqa ymmD, ymmA vpunpcklbw ymmA, ymmA, ymmE ; ymmA=(00 04 10 14 20 24 30 34 01 05 11 15 21 25 31 35 ; 0G 0K 1G 1K 2G 2K 3G 3K 0H 0L 1H 1L 2H 2L 3H 3L) vpunpckhbw ymmD, ymmD, ymmE ; ymmD=(02 06 12 16 22 26 32 36 03 07 13 17 23 27 33 37 ; 0I 0M 1I 1M 2I 2M 3I 3M 0J 0N 1J 1N 2J 2N 3J 3N) vmovdqa ymmC, ymmF vpunpcklbw ymmF, ymmF, ymmH ; ymmF=(08 0C 18 1C 28 2C 38 3C 09 0D 19 1D 29 2D 39 3D ; 0O 0S 1O 1S 2O 2S 3O 3S 0P 0T 1P 1T 2P 2T 3P 3T) vpunpckhbw ymmC, ymmC, ymmH ; ymmC=(0A 0E 1A 1E 2A 2E 3A 3E 0B 0F 1B 1F 2B 2F 3B 3F ; 0Q 0U 1Q 1U 2Q 2U 3Q 3U 0R 0V 1R 1V 2R 2V 3R 3V) vmovdqa ymmB, ymmA vpunpcklwd ymmA, ymmA, ymmF ; ymmA=(00 04 08 0C 10 14 18 1C 20 24 28 2C 30 34 38 3C ; 0G 0K 0O 0S 1G 1K 1O 1S 2G 2K 2O 2S 3G 3K 3O 3S) vpunpckhwd ymmB, ymmB, ymmF ; ymmB=(01 05 09 0D 11 15 19 1D 21 25 29 2D 31 35 39 3D ; 0H 0L 0P 0T 1H 1L 1P 1T 2H 2L 2P 2T 3H 3L 3P 3T) vmovdqa ymmG, ymmD vpunpcklwd ymmD, ymmD, ymmC ; ymmD=(02 06 0A 0E 12 16 1A 1E 22 26 2A 2E 32 36 3A 3E ; 0I 0M 0Q 0U 1I 1M 1Q 1U 2I 2M 2Q 2U 3I 3M 3Q 3U) vpunpckhwd ymmG, ymmG, ymmC ; ymmG=(03 07 0B 0F 13 17 1B 1F 23 27 2B 2F 33 37 3B 3F ; 0J 0N 0R 0V 1J 1N 1R 1V 2J 2N 2R 2V 3J 3N 3R 3V) vmovdqa ymmE, ymmA vpunpcklbw ymmA, ymmA, ymmD ; ymmA=(00 02 04 06 08 0A 0C 0E 10 12 14 16 18 1A 1C 1E ; 0G 0I 0K 0M 0O 0Q 0S 0U 1G 1I 1K 1M 1O 1Q 1S 1U) vpunpckhbw ymmE, ymmE, ymmD ; ymmE=(20 22 24 26 28 2A 2C 2E 30 32 34 36 38 3A 3C 3E ; 2G 2I 2K 2M 2O 2Q 2S 2U 3G 3I 3K 3M 3O 3Q 3S 3U) vmovdqa ymmH, ymmB vpunpcklbw ymmB, ymmB, ymmG ; ymmB=(01 03 05 07 09 0B 0D 0F 11 13 15 17 19 1B 1D 1F ; 0H 0J 0L 0N 0P 0R 0T 0V 1H 1J 1L 1N 1P 1R 1T 1V) vpunpckhbw ymmH, ymmH, ymmG ; ymmH=(21 23 25 27 29 2B 2D 2F 31 33 35 37 39 3B 3D 3F ; 2H 2J 2L 2N 2P 2R 2T 2V 3H 3J 3L 3N 3P 3R 3T 3V) vpxor ymmF, ymmF, ymmF vmovdqa ymmC, ymmA vpunpcklbw ymmA, ymmA, ymmF ; ymmA=(00 02 04 06 08 0A 0C 0E 0G 0I 0K 0M 0O 0Q 0S 0U) vpunpckhbw ymmC, ymmC, ymmF ; ymmC=(10 12 14 16 18 1A 1C 1E 1G 1I 1K 1M 1O 1Q 1S 1U) vmovdqa ymmD, ymmB vpunpcklbw ymmB, ymmB, ymmF ; ymmB=(01 03 05 07 09 0B 0D 0F 0H 0J 0L 0N 0P 0R 0T 0V) vpunpckhbw ymmD, ymmD, ymmF ; ymmD=(11 13 15 17 19 1B 1D 1F 1H 1J 1L 1N 1P 1R 1T 1V) vmovdqa ymmG, ymmE vpunpcklbw ymmE, ymmE, ymmF ; ymmE=(20 22 24 26 28 2A 2C 2E 2G 2I 2K 2M 2O 2Q 2S 2U) vpunpckhbw ymmG, ymmG, ymmF ; ymmG=(30 32 34 36 38 3A 3C 3E 3G 3I 3K 3M 3O 3Q 3S 3U) vpunpcklbw ymmF, ymmF, ymmH vpunpckhbw ymmH, ymmH, ymmH vpsrlw ymmF, ymmF, BYTE_BIT ; ymmF=(21 23 25 27 29 2B 2D 2F 2H 2J 2L 2N 2P 2R 2T 2V) vpsrlw ymmH, ymmH, BYTE_BIT ; ymmH=(31 33 35 37 39 3B 3D 3F 3H 3J 3L 3N 3P 3R 3T 3V) %endif ; RGB_PIXELSIZE ; --------------- ; ymm0=R(02468ACEGIKMOQSU)=RE, ymm2=G(02468ACEGIKMOQSU)=GE, ymm4=B(02468ACEGIKMOQSU)=BE ; ymm1=R(13579BDFHJLNPRTV)=RO, ymm3=G(13579BDFHJLNPRTV)=GO, ymm5=B(13579BDFHJLNPRTV)=BO ; (Original) ; Y = 0.29900 * R + 0.58700 * G + 0.11400 * B ; ; (This implementation) ; Y = 0.29900 * R + 0.33700 * G + 0.11400 * B + 0.25000 * G vmovdqa ymm6, ymm1 vpunpcklwd ymm1, ymm1, ymm3 vpunpckhwd ymm6, ymm6, ymm3 vpmaddwd ymm1, ymm1, [rel PW_F0299_F0337] ; ymm1=ROL*FIX(0.299)+GOL*FIX(0.337) vpmaddwd ymm6, ymm6, [rel PW_F0299_F0337] ; ymm6=ROH*FIX(0.299)+GOH*FIX(0.337) vmovdqa ymm7, ymm6 ; ymm7=ROH*FIX(0.299)+GOH*FIX(0.337) vmovdqa ymm6, ymm0 vpunpcklwd ymm0, ymm0, ymm2 vpunpckhwd ymm6, ymm6, ymm2 vpmaddwd ymm0, ymm0, [rel PW_F0299_F0337] ; ymm0=REL*FIX(0.299)+GEL*FIX(0.337) vpmaddwd ymm6, ymm6, [rel PW_F0299_F0337] ; ymm6=REH*FIX(0.299)+GEH*FIX(0.337) vmovdqa YMMWORD [wk(0)], ymm0 ; wk(0)=REL*FIX(0.299)+GEL*FIX(0.337) vmovdqa YMMWORD [wk(1)], ymm6 ; wk(1)=REH*FIX(0.299)+GEH*FIX(0.337) vmovdqa ymm0, ymm5 ; ymm0=BO vmovdqa ymm6, ymm4 ; ymm6=BE vmovdqa ymm4, ymm0 vpunpcklwd ymm0, ymm0, ymm3 vpunpckhwd ymm4, ymm4, ymm3 vpmaddwd ymm0, ymm0, [rel PW_F0114_F0250] ; ymm0=BOL*FIX(0.114)+GOL*FIX(0.250) vpmaddwd ymm4, ymm4, [rel PW_F0114_F0250] ; ymm4=BOH*FIX(0.114)+GOH*FIX(0.250) vmovdqa ymm3, [rel PD_ONEHALF] ; ymm3=[PD_ONEHALF] vpaddd ymm0, ymm0, ymm1 vpaddd ymm4, ymm4, ymm7 vpaddd ymm0, ymm0, ymm3 vpaddd ymm4, ymm4, ymm3 vpsrld ymm0, ymm0, SCALEBITS ; ymm0=YOL vpsrld ymm4, ymm4, SCALEBITS ; ymm4=YOH vpackssdw ymm0, ymm0, ymm4 ; ymm0=YO vmovdqa ymm4, ymm6 vpunpcklwd ymm6, ymm6, ymm2 vpunpckhwd ymm4, ymm4, ymm2 vpmaddwd ymm6, ymm6, [rel PW_F0114_F0250] ; ymm6=BEL*FIX(0.114)+GEL*FIX(0.250) vpmaddwd ymm4, ymm4, [rel PW_F0114_F0250] ; ymm4=BEH*FIX(0.114)+GEH*FIX(0.250) vmovdqa ymm2, [rel PD_ONEHALF] ; ymm2=[PD_ONEHALF] vpaddd ymm6, ymm6, YMMWORD [wk(0)] vpaddd ymm4, ymm4, YMMWORD [wk(1)] vpaddd ymm6, ymm6, ymm2 vpaddd ymm4, ymm4, ymm2 vpsrld ymm6, ymm6, SCALEBITS ; ymm6=YEL vpsrld ymm4, ymm4, SCALEBITS ; ymm4=YEH vpackssdw ymm6, ymm6, ymm4 ; ymm6=YE vpsllw ymm0, ymm0, BYTE_BIT vpor ymm6, ymm6, ymm0 ; ymm6=Y vmovdqu YMMWORD [rdi], ymm6 ; Save Y sub rcx, byte SIZEOF_YMMWORD add rsi, RGB_PIXELSIZE*SIZEOF_YMMWORD ; inptr add rdi, byte SIZEOF_YMMWORD ; outptr0 cmp rcx, byte SIZEOF_YMMWORD jae near .columnloop test rcx, rcx jnz near .column_ld1 pop rcx ; col pop rsi pop rdi add rsi, byte SIZEOF_JSAMPROW ; input_buf add rdi, byte SIZEOF_JSAMPROW dec rax ; num_rows jg near .rowloop .return: pop rbx vzeroupper uncollect_args 5 mov rsp, rbp ; rsp <- aligned rbp pop rsp ; rsp <- original rbp pop rbp ret ; For some reason, the OS X linker does not honor the request to align the ; segment unless we do this. align 32
SECTION code_graphics PUBLIC textpixl defc BASE = $00 ; .. X. .X XX ; .. .. .. .. ; ; .. X. .X XX ; X. X. X. X. ; ; .. X. .X XX ; .X .X .X .X ; ; .. X. .X XX ; XX XX XX XX .textpixl defb BASE+0, BASE+2, BASE+1, BASE+3 defb BASE+8, BASE+10, BASE+9, BASE+11 defb BASE+4, BASE+6, BASE+5, BASE+7 defb BASE+12, BASE+14, BASE+13, BASE+15 SECTION code_graphics PUBLIC zxn_create_tilemap_graphics PUBLIC _zxn_create_tilemap_graphics EXTERN asm_zxn_copytiles zxn_create_tilemap_graphics: _zxn_create_tilemap_graphics: ld hl,-256 add hl,sp ld sp,hl xor a make_char_loop: ld b,a ex af,af call create_char call create_char ex af,af inc a cp 16 jr nz,make_char_loop ld hl,0 add hl,sp ld bc,$1000 ;16 tiles, start char 0 call asm_zxn_copytiles ld hl,256 add hl,sp ld sp,hl ret create_char: rr b sbc a,a and 0x0f ld c,a rr b sbc a,a and 0xf0 or c ld c,4 loop: ld (hl),a inc hl dec c jr nz,loop ret
/** * Copyright (C) 2013 10gen Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License, version 3, * as published by the Free Software Foundation. * * This program 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 Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * * As a special exception, the copyright holders give permission to link the * code of portions of this program with the OpenSSL library under certain * conditions as described in each individual source file and distribute * linked combinations including the program with the OpenSSL library. You * must comply with the GNU Affero General Public License in all respects * for all of the code used other than as permitted herein. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you do not * wish to do so, delete this exception statement from your version. If you * delete this exception statement from all source files in the program, * then also delete it in the license file. */ #include "mongol/platform/basic.h" #include "mongol/client/connpool.h" #include "mongol/db/auth/action_type.h" #include "mongol/db/auth/authorization_session.h" #include "mongol/db/auth/privilege.h" #include "mongol/db/commands.h" #include "mongol/db/field_parser.h" #include "mongol/db/namespace_string.h" #include "mongol/s/catalog/catalog_cache.h" #include "mongol/s/catalog/catalog_manager.h" #include "mongol/s/chunk_manager.h" #include "mongol/s/client/shard_connection.h" #include "mongol/s/client/shard_registry.h" #include "mongol/s/config.h" #include "mongol/s/grid.h" namespace mongol { using std::shared_ptr; using std::string; using std::stringstream; using std::vector; namespace { /** * Mongos-side command for merging chunks, passes command to appropriate shard. */ class ClusterMergeChunksCommand : public Command { public: ClusterMergeChunksCommand() : Command("mergeChunks") {} virtual void help(stringstream& h) const { h << "Merge Chunks command\n" << "usage: { mergeChunks : <ns>, bounds : [ <min key>, <max key> ] }"; } virtual Status checkAuthForCommand(ClientBasic* client, const std::string& dbname, const BSONObj& cmdObj) { if (!AuthorizationSession::get(client)->isAuthorizedForActionsOnResource( ResourcePattern::forExactNamespace(NamespaceString(parseNs(dbname, cmdObj))), ActionType::splitChunk)) { return Status(ErrorCodes::Unauthorized, "Unauthorized"); } return Status::OK(); } virtual std::string parseNs(const std::string& dbname, const BSONObj& cmdObj) const { return parseNsFullyQualified(dbname, cmdObj); } virtual bool adminOnly() const { return true; } virtual bool slaveOk() const { return false; } virtual bool isWriteCommandForConfigServer() const { return false; } // Required static BSONField<string> nsField; static BSONField<vector<BSONObj>> boundsField; // Used to send sharding state static BSONField<string> shardNameField; static BSONField<string> configField; bool run(OperationContext* txn, const string& dbname, BSONObj& cmdObj, int, string& errmsg, BSONObjBuilder& result) { vector<BSONObj> bounds; if (!FieldParser::extract(cmdObj, boundsField, &bounds, &errmsg)) { return false; } if (bounds.size() == 0) { errmsg = "no bounds were specified"; return false; } if (bounds.size() != 2) { errmsg = "only a min and max bound may be specified"; return false; } BSONObj minKey = bounds[0]; BSONObj maxKey = bounds[1]; if (minKey.isEmpty()) { errmsg = "no min key specified"; return false; } if (maxKey.isEmpty()) { errmsg = "no max key specified"; return false; } const NamespaceString nss(parseNs(dbname, cmdObj)); if (nss.size() == 0) { return appendCommandStatus( result, Status(ErrorCodes::InvalidNamespace, "no namespace specified")); } auto status = grid.catalogCache()->getDatabase(txn, nss.db().toString()); if (!status.isOK()) { return appendCommandStatus(result, status.getStatus()); } std::shared_ptr<DBConfig> config = status.getValue(); if (!config->isSharded(nss.ns())) { return appendCommandStatus( result, Status(ErrorCodes::NamespaceNotSharded, "ns [" + nss.ns() + " is not sharded.")); } // This refreshes the chunk metadata if stale. ChunkManagerPtr manager = config->getChunkManagerIfExists(txn, nss.ns(), true); if (!manager) { return appendCommandStatus( result, Status(ErrorCodes::NamespaceNotSharded, "ns [" + nss.ns() + " is not sharded.")); } if (!manager->getShardKeyPattern().isShardKey(minKey) || !manager->getShardKeyPattern().isShardKey(maxKey)) { errmsg = stream() << "shard key bounds " << "[" << minKey << "," << maxKey << ")" << " are not valid for shard key pattern " << manager->getShardKeyPattern().toBSON(); return false; } minKey = manager->getShardKeyPattern().normalizeShardKey(minKey); maxKey = manager->getShardKeyPattern().normalizeShardKey(maxKey); ChunkPtr firstChunk = manager->findIntersectingChunk(txn, minKey); verify(firstChunk); BSONObjBuilder remoteCmdObjB; remoteCmdObjB.append(cmdObj[ClusterMergeChunksCommand::nsField()]); remoteCmdObjB.append(cmdObj[ClusterMergeChunksCommand::boundsField()]); remoteCmdObjB.append(ClusterMergeChunksCommand::configField(), grid.shardRegistry()->getConfigServerConnectionString().toString()); remoteCmdObjB.append(ClusterMergeChunksCommand::shardNameField(), firstChunk->getShardId()); BSONObj remoteResult; // Throws, but handled at level above. Don't want to rewrap to preserve exception // formatting. const auto shard = grid.shardRegistry()->getShard(txn, firstChunk->getShardId()); if (!shard) { return appendCommandStatus( result, Status(ErrorCodes::ShardNotFound, str::stream() << "Can't find shard for chunk: " << firstChunk->toString())); } ShardConnection conn(shard->getConnString(), ""); bool ok = conn->runCommand("admin", remoteCmdObjB.obj(), remoteResult); conn.done(); result.appendElements(remoteResult); return ok; } } clusterMergeChunksCommand; BSONField<string> ClusterMergeChunksCommand::nsField("mergeChunks"); BSONField<vector<BSONObj>> ClusterMergeChunksCommand::boundsField("bounds"); BSONField<string> ClusterMergeChunksCommand::configField("config"); BSONField<string> ClusterMergeChunksCommand::shardNameField("shardName"); } // namespace } // namespace mongol
// 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 "base/callback.h" #include "base/logging.h" #include "chrome/browser/external_protocol/external_protocol_handler.h" #include "chrome/browser/importer/importer_progress_dialog.h" #include "ui/gfx/native_widget_types.h" #if defined(OS_WIN) #include "chrome/browser/first_run/first_run.h" #include "chrome/browser/first_run/first_run_import_observer.h" #include "chrome/browser/ui/views/first_run_bubble.h" #else #include "chrome/browser/ui/certificate_dialogs.h" #endif #if defined(USE_NSS) #include "chrome/browser/ui/crypto_module_password_dialog.h" #endif class SSLClientAuthHandler; class TabContents; namespace content { class WebContents; } namespace net { class HttpNetworkSession; class SSLCertRequestInfo; class X509Certificate; } namespace views { class Widget; } namespace chrome { void ShowAboutIPCDialog() { // TODO(beng): NOTIMPLEMENTED(); } } // namespace chrome #if defined(OS_WIN) void ShowCertificateViewer(content::WebContents* web_contents, gfx::NativeWindow parent, net::X509Certificate* cert) { // No certificate viewer on Windows. } #endif // OS_WIN namespace importer { void ShowImportProgressDialog(uint16 items, ImporterHost* importer_host, ImporterObserver* importer_observer, const SourceProfile& source_profile, Profile* target_profile, bool first_run) { // TODO(beng); NOTIMPLEMENTED(); } } // namespace importer #if !defined(OS_CHROMEOS) // static void ExternalProtocolHandler::RunExternalProtocolDialog( const GURL& url, int render_process_host_id, int routing_id) { } #endif
/* * Copyright (c) 2020 The WebRTC 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 "modules/audio_processing/agc2/rnn_vad/rnn_fc.h" #include <array> #include <vector> #include "api/array_view.h" #include "modules/audio_processing/agc2/cpu_features.h" #include "modules/audio_processing/agc2/rnn_vad/test_utils.h" #include "modules/audio_processing/test/performance_timer.h" #include "rtc_base/logging.h" #include "rtc_base/system/arch.h" #include "test/gtest.h" #include "third_party/rnnoise/src/rnn_vad_weights.h" namespace webrtc { namespace rnn_vad { namespace { using ::rnnoise::kInputDenseBias; using ::rnnoise::kInputDenseWeights; using ::rnnoise::kInputLayerInputSize; using ::rnnoise::kInputLayerOutputSize; // Fully connected layer test data. constexpr std::array<float, 42> kFullyConnectedInputVector = { -1.00131f, -0.627069f, -7.81097f, 7.86285f, -2.87145f, 3.32365f, -0.653161f, 0.529839f, -0.425307f, 0.25583f, 0.235094f, 0.230527f, -0.144687f, 0.182785f, 0.57102f, 0.125039f, 0.479482f, -0.0255439f, -0.0073141f, -0.147346f, -0.217106f, -0.0846906f, -8.34943f, 3.09065f, 1.42628f, -0.85235f, -0.220207f, -0.811163f, 2.09032f, -2.01425f, -0.690268f, -0.925327f, -0.541354f, 0.58455f, -0.606726f, -0.0372358f, 0.565991f, 0.435854f, 0.420812f, 0.162198f, -2.13f, 10.0089f}; constexpr std::array<float, 24> kFullyConnectedExpectedOutput = { -0.623293f, -0.988299f, 0.999378f, 0.967168f, 0.103087f, -0.978545f, -0.856347f, 0.346675f, 1.f, -0.717442f, -0.544176f, 0.960363f, 0.983443f, 0.999991f, -0.824335f, 0.984742f, 0.990208f, 0.938179f, 0.875092f, 0.999846f, 0.997707f, -0.999382f, 0.973153f, -0.966605f}; class RnnFcParametrization : public ::testing::TestWithParam<AvailableCpuFeatures> {}; // Checks that the output of a fully connected layer is within tolerance given // test input data. TEST_P(RnnFcParametrization, CheckFullyConnectedLayerOutput) { FullyConnectedLayer fc(kInputLayerInputSize, kInputLayerOutputSize, kInputDenseBias, kInputDenseWeights, ActivationFunction::kTansigApproximated, /*cpu_features=*/GetParam(), /*layer_name=*/"FC"); fc.ComputeOutput(kFullyConnectedInputVector); ExpectNearAbsolute(kFullyConnectedExpectedOutput, fc, 1e-5f); } TEST_P(RnnFcParametrization, DISABLED_BenchmarkFullyConnectedLayer) { const AvailableCpuFeatures cpu_features = GetParam(); FullyConnectedLayer fc(kInputLayerInputSize, kInputLayerOutputSize, kInputDenseBias, kInputDenseWeights, ActivationFunction::kTansigApproximated, cpu_features, /*layer_name=*/"FC"); constexpr int kNumTests = 10000; ::webrtc::test::PerformanceTimer perf_timer(kNumTests); for (int k = 0; k < kNumTests; ++k) { perf_timer.StartTimer(); fc.ComputeOutput(kFullyConnectedInputVector); perf_timer.StopTimer(); } RTC_LOG(LS_INFO) << "CPU features: " << cpu_features.ToString() << " | " << (perf_timer.GetDurationAverage() / 1000) << " +/- " << (perf_timer.GetDurationStandardDeviation() / 1000) << " ms"; } // Finds the relevant CPU features combinations to test. std::vector<AvailableCpuFeatures> GetCpuFeaturesToTest() { std::vector<AvailableCpuFeatures> v; v.push_back(NoAvailableCpuFeatures()); AvailableCpuFeatures available = GetAvailableCpuFeatures(); if (available.sse2) { v.push_back({/*sse2=*/true, /*avx2=*/false, /*neon=*/false}); } if (available.avx2) { v.push_back({/*sse2=*/false, /*avx2=*/true, /*neon=*/false}); } if (available.neon) { v.push_back({/*sse2=*/false, /*avx2=*/false, /*neon=*/true}); } return v; } INSTANTIATE_TEST_SUITE_P( RnnVadTest, RnnFcParametrization, ::testing::ValuesIn(GetCpuFeaturesToTest()), [](const ::testing::TestParamInfo<AvailableCpuFeatures>& info) { return info.param.ToString(); }); } // namespace } // namespace rnn_vad } // namespace webrtc
; A233684: Number of (n+1) X (1+1) 0..3 arrays with every 2 X 2 subblock having the sum of the squares of the edge differences equal to 10, and no two adjacent values equal. ; Submitted by Jamie Morken(w3) ; 32,108,356,1188,3940,13108,43540,144740,480964,1598548,5312436,17655684,58676452,195006452,648083796,2153846948,7158099972,23789267092,79061340148,262752815812,873233798180,2902108995124,9644881349524,32053840078308,106527868913988,354035175520468,1176602015454260,3910324170682884,12995588067596132,43189592957698164,143536477912011220,477029744477320996,1585362692599301764,5268801151761186068,17510356277564238964,58193992928735804740,193402164941770432164,642753581972091410100 add $0,3 mov $1,2 mov $2,1 mov $3,2 lpb $0 sub $0,1 add $1,$3 add $2,$5 add $4,1 mov $5,$4 mov $4,$2 add $4,$1 mul $5,2 add $1,$5 mov $3,$5 mov $5,$1 lpe mov $0,$1 div $0,8 mul $0,4
INCLUDE "clib_cfg.asm" SECTION code_clib SECTION code_l_sdcc PUBLIC __mullong EXTERN l_mulu_32_32x32 __mullong: ; multiply two 32-bit multiplicands into a 32-bit product ; ; enter : stack = multiplicand (32-bit), multiplicand (32-bit), ret ; ; exit : dehl = product pop af exx pop hl pop de ; dehl = multiplicand exx pop hl pop de ; dehl = multiplicand push de push hl push de push hl push af IF (__CLIB_OPT_IMATH <= 50) || (__SDCC_IY) jp l_mulu_32_32x32 ENDIF IF (__CLIB_OPT_IMATH > 50) && (__SDCC_IX) push ix call l_mulu_32_32x32 pop ix ret ENDIF
; A132440: Infinitesimal Pascal matrix: generator (lower triangular matrix representation) of the Pascal matrix, the classical operator xDx, iterated Laguerre transforms, associated matrices of the list partition transform and general Euler transformation for sequences. ; 0,1,0,0,2,0,0,0,3,0,0,0,0,4,0,0,0,0,0,5,0,0,0,0,0,0,6,0,0,0,0,0,0,0,7,0,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,0,0,9,0,0,0,0,0,0,0,0,0,0,10,0,0,0,0,0,0,0,0,0,0,0,11,0,0,0,0,0,0,0,0,0,0,0,0,12,0,0,0,0,0,0,0,0,0,0 lpb $0 add $1,$2 add $2,1 sub $0,$2 cmp $1,$0 mul $1,$2 lpe mov $0,$1
#include "text_data.h" #include <algorithm> using namespace std; namespace TechLog1C{ Time::Time(): time_(0){} Time::Time(std::uint64_t time): time_(time){} Time::Time(std::uint8_t year, std::uint8_t month, std::uint8_t day, std::uint8_t hour, std::uint8_t minute, std::uint8_t second, std::uint32_t mseconds) { time_ = year * 10000000000000000ULL + month * 100000000000000ULL + day * 1000000000000ULL + hour * 10000000000ULL + minute * 100000000ULL + second * 1000000ULL + mseconds; } bool operator<(const Time& lhs, const Time& rhs){ return lhs.time_ < rhs.time_; } bool operator==(const Time& lhs, const Time& rhs){ return lhs.time_ == rhs.time_; } EventOut::EventOut(): reader_(nullptr), start_(0), length_(0), count_lines_(0), count_lines_agr_(0), id_(0){} EventOut::EventOut(const EventOut& event_out): reader_(event_out.reader_), time_(event_out.time_), start_(event_out.start_), length_(event_out.length_), count_lines_(event_out.count_lines_), count_lines_agr_(event_out.count_lines_agr_), process_(event_out.process_), id_(event_out.id_){} EventOut::EventOut(EventOut&& event_out): reader_(event_out.reader_), time_(event_out.time_), start_(event_out.start_), length_(event_out.length_), count_lines_(event_out.count_lines_), count_lines_agr_(event_out.count_lines_agr_), process_(move(event_out.process_)), id_(event_out.id_){} EventOut::EventOut(Reader* reader, uint64_t start, uint32_t length): reader_(reader), time_(0), start_(start), length_(length), count_lines_(0), count_lines_agr_(0), process_(""), id_(0){} EventOut::EventOut(Reader* reader, Time time, uint64_t start, uint32_t length, uint32_t count_lines, uint32_t count_lines_agr, std::string process, uint32_t id): reader_(reader), time_(time), start_(start), length_(length), count_lines_(count_lines), count_lines_agr_(count_lines_agr), process_(process), id_(id){} string EventOut::AsString(){ if(!reader_) return ""; string str(length_ + 12, '0'); string part_date = to_string(time_.Day()); part_date.copy(&str[2] - part_date.size(), part_date.size(), 0); str[2] = '.'; part_date = to_string(time_.Month()); part_date.copy(&str[5] - part_date.size(), part_date.size(), 0); str[5] = '.'; part_date = to_string(time_.Year()); part_date.copy(&str[8] - part_date.size(), part_date.size(), 0); str[8] = ' '; part_date = to_string(time_.Hour()); part_date.copy(&str[11] - part_date.size(), part_date.size(), 0); str[11] = ':'; reader_->Read(&str[12], start_, str.size() - 12); return str; } wstring EventOut::AsWString(){ if(!reader_) return L""; return Utf8ToWideChar(AsString()); } vector<wstring> EventOut::AsWStrings(){ vector<wstring> strings; if(count_lines_ == 1){ strings.push_back(AsWString()); } else{ wstring wstr = AsWString(); wstring_view wstrv(wstr); auto pos = wstrv.find(L'\n'); while(pos != wstring_view::npos){ strings.push_back(wstring(&wstrv[0], pos)); wstrv.remove_prefix(pos + 1); pos = wstrv.find(L'\n'); } strings.push_back(wstring(&wstrv[0], wstrv.size())); } return strings; } bool operator==(const EventOut& lhs, const EventOut& rhs){ return lhs.reader_ == rhs.reader_ && lhs.time_ == rhs.time_ && lhs.start_ == rhs.start_ && lhs.length_ == rhs.length_; } bool operator!=(const EventOut& lhs, const EventOut& rhs){ return !(lhs == rhs); } }
/* _____ * /\ _ \ __ * \ \ \_\ \ __ __ __ /\_\ * \ \ __ \ /'_ `\ /\ \/\ \\/\ \ * \ \ \/\ \ /\ \_\ \\ \ \_\ \\ \ \ * \ \_\ \_\\ \____ \\ \____/ \ \_\ * \/_/\/_/ \/____\ \\/___/ \/_/ * /\____/ * \_/__/ * * Copyright (c) 2011 Joshua Larouche * * * License: (BSD) * 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 Agui 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. */ #ifndef AGUI_ALLEGRO5_FONT_HPP #define AGUI_ALLEGRO5_FONT_HPP #include "Agui/BaseTypes.hpp" //Allegro 5 #include <allegro5/allegro.h> #include <allegro5/allegro5.h> #include <allegro5/allegro_image.h> #include <allegro5/allegro_primitives.h> #include <allegro5/allegro_font.h> #include <allegro5/allegro_ttf.h> namespace agui { class Allegro5Font : public Font { ALLEGRO_FONT* font; std::string path; int height; int lineHeight; bool autoFree; public: virtual void free(); ALLEGRO_FONT* getFont() const; virtual int getLineHeight() const; virtual int getHeight() const; virtual int getTextWidth(const std::string &text) const; virtual const std::string& getPath() const; Allegro5Font(void); Allegro5Font(const std::string &fileName, int height, FontFlags fontFlags = FONT_DEFAULT_FLAGS, float borderWidth = 0, agui::Color borderColor = agui::Color()); virtual void reload(const std::string &fileName, int height, FontFlags fontFlags = FONT_DEFAULT_FLAGS, float borderWidth = 0, agui::Color borderColor = agui::Color()); virtual void setFont(ALLEGRO_FONT* font, const std::string &path, bool autoFree = false); virtual ~Allegro5Font(void); }; } #endif
; A310439: Coordination sequence Gal.6.321.4 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings. ; Submitted by Jon Maiga ; 1,4,10,15,19,24,29,33,38,44,48,52,58,63,67,72,77,81,86,92,96,100,106,111,115,120,125,129,134,140,144,148,154,159,163,168,173,177,182,188,192,196,202,207,211,216,221,225,230,236 mov $1,$0 seq $1,315275 ; Coordination sequence Gal.6.329.3 where G.u.t.v denotes the coordination sequence for a vertex of type v in tiling number t in the Galebach list of u-uniform tilings. mov $2,$0 mul $0,7 sub $0,1 mod $0,$1 mul $2,3 add $0,$2 add $0,1
#include "ArgParser.h" #include "ArgParseException.h" #include <string> #include <vector> #include <algorithm> #include <utility> //for std::pair using std::string; using std::vector; ArgParser::ArgParser() : finalized(false) { } ArgParser::ArgParser(const int argc, char *argv[], const string switches, const string dataOptions) : allSwitches(switches), allDataOpts(dataOptions) { for(int i = 0; i < argc; ++i) args.push_back(string(argv[i])); commonIter = args.begin(); finalized = true; } void ArgParser::operator()(const int argc, char *argv[], const string switches, const string dataOptions) { if(!finalized) { for(int i = 0; i < argc; ++i) args.push_back(string(argv[i])); allSwitches = switches; allDataOpts = dataOptions; commonIter = args.begin(); finalized = true; } } void ArgParser::parse() { ++commonIter; //first arg is the program name, skip it string arg; while(commonIter != args.end()) { arg = *commonIter; if(arg[0] != '-') //matches 'op', 'f.txt' etc. processOperand(); else if(arg.length() == 1) //matches (only) '-' processOperand(); else if(arg[1] != '-') //mathes '-c', '-dRe' etc. processSingleDash(); else if(arg.length() == 2) //matches (only) '--' processOperand(); else //matches '--reedirect', '--file=name' etc processDoubleDash(); } } bool ArgParser::isSwitchSet(const string svitch) const { return std::find(switchesSet.begin(), switchesSet.end(), svitch) != switchesSet.end(); } bool ArgParser::isDataOptSet(const string dataOption) const { for(std::pair<string, string> p : dataOptsSet) if(p.first == dataOption) return true; return false; } bool ArgParser::isSet(const string option) const { return isSwitchSet(option) || isDataOptSet(option); } string ArgParser::getDataForOpt(const string option) const { for(std::pair<string, string> p : dataOptsSet) if(p.first == option) return p.second; throw ArgParseException("No such data option set: " + option); } vector<string> ArgParser::getSwitches() const { return switchesSet; } vector<string> ArgParser::getDataOptions() const { vector<string> dataOpts; for(std::pair<string, string> p : dataOptsSet) dataOpts.push_back(p.first); return dataOpts; } vector<string> ArgParser::getAllOptions() const { vector<string> options; //copy all switches std::copy(switchesSet.begin(), switchesSet.end(), std::back_inserter(options)); //copy all data options(only options, not their data) for(std::pair<string, string> p : dataOptsSet) options.push_back(p.first); return options; } vector<string> ArgParser::getOperands() const { return operands; }
; A110613: a(n+3) = 5*a(n+2) - 2*a(n+1) - 8*a(n), a(0) = 1, a(1) = 0, a(2) = 3. ; 1,0,3,7,29,107,421,1659,6597,26299,105029,419771,1678405,6712251,26846277,107379643,429507653,1718008763,6871991365,27487878075,109951337541,439805000635,1759219303493,7036875815867,28147500467269,112589996276667,450359973921861,1801439873317819,7205759448532037,28823037704649659,115292150639641669,461168602200652731,1844674408086783045,7378697630915476411,29514790520798594117,118059162077467753403,472236648298417767493,1888946593170764577723,7555786372637245326405,30223145490457355336635,120892581961646169408581,483570327846218173758395,1934281311384139687281733,7737125245535092733623227,30948500982137438903485509,123794003928543891551927227,495176015714163838083679301,1980704062856631896086657979,7922816251426480671850513477,31691265005705828862409817019,126765060022823127799654794309,507060240091292135898650229691,2028240960365167792994663023685,8112963841460669670778776304571,32451855365842675680715353637957,129807421463370696718061911391163,519229685853482774862648639243333,2076918743413931075431396544330683,8307674973655724253687190152037445,33230699894622896918671968557579195,132922799578491587482534290129175621,531691198313966349545829992314420155 mov $3,2 mov $5,$0 lpb $3 sub $3,1 add $0,$3 sub $0,1 mov $2,$3 mov $4,$0 max $4,0 seq $4,214142 ; Number of 0..4 colorings of a 1 X (n+1) array circular in the n+1 direction with new values 0..4 introduced in row major order. mul $2,$4 add $1,$2 mov $6,$4 lpe min $5,1 mul $5,$6 sub $1,$5 mov $0,$1
; A168184: Characteristic function of numbers that are not multiples of 10. ; 0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1 gcd $0,10 div $0,10 pow $1,$0 mov $0,$1
; A011861: a(n) = floor(n(n-1)/8). ; 0,0,0,0,1,2,3,5,7,9,11,13,16,19,22,26,30,34,38,42,47,52,57,63,69,75,81,87,94,101,108,116,124,132,140,148,157,166,175,185,195,205,215,225,236,247,258,270,282,294,306,318,331,344,357,371,385,399,413,427,442,457,472,488,504,520,536,552,569,586,603,621,639,657,675,693,712,731,750,770,790,810,830,850,871,892,913,935,957,979,1001,1023,1046,1069,1092,1116,1140,1164,1188,1212,1237,1262,1287,1313,1339,1365,1391,1417,1444,1471,1498,1526,1554,1582,1610,1638,1667,1696,1725,1755,1785,1815,1845,1875,1906,1937,1968,2000,2032,2064,2096,2128,2161,2194,2227,2261,2295,2329,2363,2397,2432,2467,2502,2538,2574,2610,2646,2682,2719,2756,2793,2831,2869,2907,2945,2983,3022,3061,3100,3140,3180,3220,3260,3300,3341,3382,3423,3465,3507,3549,3591,3633,3676,3719,3762,3806,3850,3894,3938,3982,4027,4072,4117,4163,4209,4255,4301,4347,4394,4441,4488,4536,4584,4632,4680,4728,4777,4826,4875,4925,4975,5025,5075,5125,5176,5227,5278,5330,5382,5434,5486,5538,5591,5644,5697,5751,5805,5859,5913,5967,6022,6077,6132,6188,6244,6300,6356,6412,6469,6526,6583,6641,6699,6757,6815,6873,6932,6991,7050,7110,7170,7230,7290,7350,7411,7472,7533,7595,7657,7719 bin $0,2 div $0,4 mov $1,$0
page ,132 subttl emstack.asm - Emulator Stack Management Area ;*** ;emstack.asm - Emulator Stack Management Area ; ; Copyright (c) 1986-89, Microsoft Corporation ; ;Purpose: ; Emulator Stack Management Area ; ; This Module contains Proprietary Information of Microsoft ; Corporation and should be treated as Confidential. ; ;Revision History: ; See emulator.hst ; ;******************************************************************************* ProfBegin STACK ;*********************************************************************; ; ; ; Emulator Stack Management Area ; ; ; ;*********************************************************************; ; The emulator maintains an "finite" stack of 12 byte registers. ; Stand-alone emulator has 1 chunk only. ; This is done using a list of finite length stack chunks, each of ; which has the following format: ; +00 first (deepest) 12 byte register ; +12 next 12 byte register ; (and so on through last possible register) ; MACROS used to manipulate the emulator/8087 memory stack ; This macro allocates a new TOS register, returns SI with its address. PUSHST MACRO local pushstok mov esi,[CURstk] ; 14 get address of current register cmp esi,[LIMstk] ; 15 is current register end of stack jne short pushstok ; 16 no, still room in stack call OverStk ; stack overflow error pushstok: add esi,Reg87Len ; 4 increment SI to next free register mov [CURstk],esi ; 15 set current top of stack ENDM ; 64 total ; This macro deallocates TOS register, returns SI with new TOS address. ; Note: assumes SI contains TOS address, CURstk ; BASstk converted back to a variable to enable macro use for 8087 stack ; handling. Brad Verheiden, 4-13-84. POPSTsi MACRO local popstok cmp esi,[BASstk] ; 15 was it last register in the chunk ? jnz short popstok ; 16 no, still room in current chunk call UnderStk ; stack underflow error popstok: sub esi,Reg87Len ; 4 decrement SI to previous register mov [CURstk],esi ; 15 set current top of stack ENDM ; 64 total POPST MACRO mov esi,[CURstk] POPSTsi ENDM ChangeDIfromTOStoNOS MACRO sub edi,Reg87Len ENDM page ; This area contains two procedures, OverStk and UnderStk, ; which generate a stack overflow error. ; OverStk: invoked within PUSHST macro ; on entry, the stack is full ; on return, SI contains address of base of stack ; UnderStk: invoked within POPST macro ; on entry, the stack is empty ; on return, SI contains address of base of stack pub OverStk OR byte ptr [CURerr+1],StackOverflow/256 ; raise stack overflow CMP [Have8087],0 ; Is 8087 present JZ short OverStkEnd ; No - don't touch AX OR AH,StackOverflow/256 ; Indicate memory overflow for 8087 pub OverStkEnd RET ; finished pub UnderStk OR byte ptr [CURerr+1],StackUnderflow/256 ; raise stack underflow RET ; finished ProfEnd STACK
; A124720: Number of ternary Lyndon words of length n with exactly two 1's. ; Submitted by Jon Maiga ; 2,5,16,38,96,220,512,1144,2560,5616,12288,26592,57344,122816,262144,556928,1179648,2490112,5242880,11009536,23068672,48233472,100663296,209713152,436207616,905965568,1879048192,3892305920,8053063680,16642981888,34359738368,70866927616,146028888064,300647645184,618475290624,1271310188544,2611340115968,5360118923264,10995116277760,22539987845120,46179488366592,94557998940160,193514046488576,395824183902208,809240558043136,1653665483980800,3377699720527872,6896136921022464,14073748835532800 mov $1,1 mov $2,1 mov $4,1 lpb $0 add $1,$0 sub $0,1 mov $5,$1 add $1,1 add $1,$4 mul $1,2 mov $3,$4 mov $4,$2 mov $2,$3 mul $2,2 add $5,$4 lpe add $5,$4 mov $0,$5 add $0,1
MODULE __printf_number SECTION code_clib PUBLIC __printf_number EXTERN __printf_print_to_buf EXTERN __printf_print_the_buffer EXTERN l_int2long_s EXTERN l_long_neg EXTERN l_long_div_u EXTERN l_div_u EXTERN l_neg EXTERN get_16bit_ap_parameter EXTERN __printf_add_offset EXTERN __printf_issccz80 EXTERN __printf_get_base EXTERN __printf_check_long_flag EXTERN __printf_context EXTERN __math_block2 defc handlelong = 1 ; Print a number ; Entry: hl = fmt (character after format) ; de = ap ; c = 1 = signed, 0 = unsigned __printf_number: push hl ;save fmt IF __CPU_INTEL__ | __CPU_GBZ80__ call __printf_check_long_flag ELSE bit 6,(ix-4) ENDIF jr z,printf_number16 IF __CPU_INTEL__ | __CPU_GBZ80__ call __printf_issccz80 ELSE bit 0,(ix+6) ;sccz80 flag ENDIF jr nz,pickuplong_sccz80 ; Picking up a long sdcc style ex de,hl ;hl=where tp pick up from ld e,(hl) ;LSW inc hl ld d,(hl) inc hl IF __CPU_GBZ80__ ld a,(hl+) ELSE ld a,(hl) inc hl ENDIF ld b,(hl) inc hl push hl ; save ap ld h,b ld l,a ex de,hl ;dehl=long, c: 1=signed, 0=unsigned printlong: ld a,c jp miniprintn pickuplong_sccz80: ex de,hl ld e,(hl) ;MSW inc hl ld d,(hl) dec hl dec hl ld b,(hl) ;LSW dec hl IF __CPU_GBZ80__ ld a,(hl-) ELSE ld a,(hl) dec hl ENDIF dec hl push hl ;Save ap for next time ld h,b ld l,a jr printlong printf_number16: call get_16bit_ap_parameter ;de = new ap, hl = number to print push de ; save ap ld de,0 ;make it a long ld a,c ;signed? and a call nz,l_int2long_s ;extend it out jr printlong ; Entry: a = flag (0=unsigned, 1 = signed) ; dehl = number miniprintn: ld b,a IF handlelong ld a,d ELSE ld a,h ENDIF rlca and 1 and b jr z,noneg IF handlelong call l_long_neg ELSE call l_neg ENDIF ld a,'-' printsign: call __printf_print_to_buf jr miniprintn_start_process noneg: IF __CPU_INTEL__ || __CPU_GBZ80__ push hl IF __CPU_GBZ80__ ld hl,__printf_context ld a,(hl+) ld h,(hl) ld l,a ELSE ld hl,(__printf_context) ENDIF dec hl dec hl dec hl dec hl ld c,l ld b,h pop hl ld a,(bc) and 8 ld a,' ' jr nz,printsign ld a,(bc) and 2 ld a,'+' jr nz,printsign ld a,(bc) and 16 jr z,miniprintn_start_process ELSE ld a,' ' bit 3,(ix-4) jr nz,printsign ld a,'+' bit 1,(ix-4) ;do we force a + jr nz,printsign bit 4,(ix-4) ;# indicator jr z,miniprintn_start_process ENDIF IF __CPU_INTEL__ | __CPU_GBZ80__ push hl call __printf_get_base ld a,l pop hl ELSE ld a,(ix-9) ;get base ENDIF cp 10 jr z,miniprintn_start_process push af ld a,'0' call __printf_print_to_buf pop af cp 16 jr nz,miniprintn_start_process ld a,'x' IF __CPU_INTEL__ | __CPU_GBZ80__ call __printf_add_offset ELSE add (ix-3) ENDIF call __printf_print_to_buf miniprintn_start_process: xor a push af ; set terminator .divloop IF handlelong IF __CPU_INTEL__ | __CPU_GBZ80__ push de ; number MSW push hl ; number LSW call __printf_get_base ld d,h ld e,h call l_long_div_u ld a,(__math_block2) ;We know that's where the modulus is kept cp 255 push af ELSE push de ; number MSW push hl ; number LSW ld l,(ix-9) ;base ld h,0 ld d,h ld e,h call l_long_div_u exx ld a,l cp 255 ; force flag to non-zero push af ; save reminder as a digit in stack exx ENDIF ELSE ex de,hl IF __CPU_INTEL__ | __CPU_GBZ80__ call __printf_get_base ELSE ld l,(ix-9) ;base ld h,0 ENDIF call l_div_u ;hl=de/hl de=de%hl ld a,e cp 255 ; force flag to non-zero push af ; save reminder as a digit in stack ENDIF ld a,h IF handlelong or d or e ENDIF or l ; is integer part of last division zero ? jr nz,divloop ; not still ?.. loop ; now recurse for the single digit ; pick all from stack until you get the terminator ; .printloop pop af jp z,__printf_print_the_buffer add '0' ; We only print hex at level 2 cp '9'+1 jr c,printloop1 add 'a' - '9' -1 IF __CPU_INTEL__ | __CPU_GBZ80__ call __printf_add_offset ELSE add (ix-3) ENDIF printloop1: call __printf_print_to_buf jr printloop
//*************************************************************************** // // Copyright (c) 1998-1999 Microsoft Corporation // // ENUMOBJ.CPP // // alanbos 15-Aug-96 Created. // // Defines the implementation of ISWbemObjectSet // //*************************************************************************** #include "precomp.h" //*************************************************************************** // // CSWbemEventSource::CSWbemEventSource // // DESCRIPTION: // // Constructor. // //*************************************************************************** CSWbemEventSource::CSWbemEventSource( CSWbemServices *pService, IEnumWbemClassObject *pIEnumWbemClassObject) { m_Dispatch.SetObj (this, IID_ISWbemEventSource, CLSID_SWbemEventSource, L"SWbemEventSource"); m_cRef=0; m_pSWbemServices = pService; if (m_pSWbemServices) { m_pSWbemServices->AddRef (); CSWbemSecurity *pSecurity = m_pSWbemServices->GetSecurityInfo (); if (pSecurity) { m_SecurityInfo = new CSWbemSecurity (pIEnumWbemClassObject, pSecurity); pSecurity->Release (); } } InterlockedIncrement(&g_cObj); } //*************************************************************************** // // CSWbemEventSource::~CSWbemEventSource // // DESCRIPTION: // // Destructor. // //*************************************************************************** CSWbemEventSource::~CSWbemEventSource(void) { InterlockedDecrement(&g_cObj); if (m_pSWbemServices) m_pSWbemServices->Release (); if (m_SecurityInfo) m_SecurityInfo->Release (); } //*************************************************************************** // HRESULT CSWbemEventSource::QueryInterface // long CSWbemEventSource::AddRef // long CSWbemEventSource::Release // // DESCRIPTION: // // Standard Com IUNKNOWN functions. // //*************************************************************************** STDMETHODIMP CSWbemEventSource::QueryInterface ( IN REFIID riid, OUT LPVOID *ppv ) { *ppv=NULL; if (IID_IUnknown==riid) *ppv = reinterpret_cast<IUnknown*>(this); else if (IID_ISWbemEventSource==riid) *ppv = (ISWbemEventSource*)this; else if (IID_IDispatch==riid) *ppv = (IDispatch *)this; else if (IID_ISupportErrorInfo==riid) *ppv = (ISupportErrorInfo *)this; else if (IID_IProvideClassInfo==riid) *ppv = (IProvideClassInfo *)this; if (NULL!=*ppv) { ((LPUNKNOWN)*ppv)->AddRef(); return NOERROR; } return ResultFromScode(E_NOINTERFACE); } STDMETHODIMP_(ULONG) CSWbemEventSource::AddRef(void) { InterlockedIncrement(&m_cRef); return m_cRef; } STDMETHODIMP_(ULONG) CSWbemEventSource::Release(void) { LONG cRef = InterlockedDecrement(&m_cRef); if (0 != cRef) { _ASSERT(cRef > 0); return cRef; } delete this; return 0; } //*************************************************************************** // HRESULT CSWbemEventSource::InterfaceSupportsErrorInfo // // DESCRIPTION: // // Standard Com ISupportErrorInfo functions. // //*************************************************************************** STDMETHODIMP CSWbemEventSource::InterfaceSupportsErrorInfo (IN REFIID riid) { return (IID_ISWbemEventSource == riid) ? S_OK : S_FALSE; } //*************************************************************************** // // SCODE CSWbemEventSource::NextEvent // // DESCRIPTION: // // Get the next event, or timeout // // PARAMETERS: // // lTimeout Number of ms to wait for object (or wbemTimeoutInfinite for // indefinite) // ppObject On return may contain the next element (if any) // // RETURN VALUES: // // WBEM_S_NO_ERROR success // WBEM_E_FAILED otherwise // //*************************************************************************** HRESULT CSWbemEventSource::NextEvent ( long lTimeout, ISWbemObject **ppObject ) { HRESULT hr = WBEM_E_FAILED; ResetLastErrors (); if (NULL == ppObject) hr = WBEM_E_INVALID_PARAMETER; else { *ppObject = NULL; if (m_SecurityInfo) { IEnumWbemClassObject *pIEnumWbemClassObject = (IEnumWbemClassObject *) m_SecurityInfo->GetProxy (); if (pIEnumWbemClassObject) { IWbemClassObject *pIWbemClassObject = NULL; ULONG returned = 0; bool needToResetSecurity = false; HANDLE hThreadToken = NULL; if (m_SecurityInfo->SetSecurity (needToResetSecurity, hThreadToken)) hr = pIEnumWbemClassObject->Next (lTimeout, 1, &pIWbemClassObject, &returned); if (needToResetSecurity) m_SecurityInfo->ResetSecurity (hThreadToken); if (SUCCEEDED(hr) && (0 < returned) && pIWbemClassObject) { CSWbemObject *pObject = new CSWbemObject (m_pSWbemServices, pIWbemClassObject, m_SecurityInfo); if (!pObject) hr = WBEM_E_OUT_OF_MEMORY; else if (FAILED(hr = pObject->QueryInterface (IID_ISWbemObject, (PPVOID) ppObject))) delete pObject; pIWbemClassObject->Release (); } else if (WBEM_S_TIMEDOUT == hr) { /* * Since a timeout would be indistinguishable from an end-of-enumeration * in automation terms we flag it as a real error rather than an S-CODE. */ hr = wbemErrTimedout; } SetWbemError (m_pSWbemServices); pIEnumWbemClassObject->Release (); } } } if (FAILED(hr)) m_Dispatch.RaiseException (hr); return hr; } //*************************************************************************** // // SCODE CSWbemEventSource::get_Security_ // // DESCRIPTION: // // Return the security configurator // // WBEM_S_NO_ERROR success // WBEM_E_INVALID_PARAMETER bad input parameters // WBEM_E_FAILED otherwise // //*************************************************************************** HRESULT CSWbemEventSource::get_Security_ ( ISWbemSecurity **ppSecurity ) { HRESULT hr = WBEM_E_FAILED; ResetLastErrors (); if (NULL == ppSecurity) hr = WBEM_E_INVALID_PARAMETER; else // Bug ID 566345 { *ppSecurity = NULL; if (m_SecurityInfo) { *ppSecurity = m_SecurityInfo; (*ppSecurity)->AddRef (); hr = WBEM_S_NO_ERROR; } } if (FAILED(hr)) m_Dispatch.RaiseException (hr); return hr; }
; Emulate 'rl bc' instruction, only carry is affected ; CPU Min T Max T ; 8080 90 90 ; 8085 88 88 ; gbz80 16 16 ; r2k 8 8 ; z180 14 14 ; z80 16 16 ; z80n 16 16 SECTION code_crt0_sccz80 PUBLIC __z80asm__rl_bc __z80asm__rl_bc: IF __CPU_INTEL__ push af ld a, c rla ld c, a ld a, b rla ld b, a jr nc, carry0 pop af scf ret carry0: pop af and a ret ELSE rl c rl b ret ENDIF
bits 64 section .data HSP: dq 256 LCL: dq 1024 ARG: dq 2048 THIS: dq 4096 THAT: dq 0 section .text ; D=17 mov rdx, 17 ; *SP=D mov rax, [HSP] mov [rax], rdx ; SP++ mov rax, [HSP] add rax, 1 mov [HSP], rax
; Z88 Small C+ Run time Library ; Moved functions over to proper libdefs ; To make startup code smaller and neater! ; ; 6/9/98 djm ; 13/5/99 djm Added carry conditions... SECTION code_clib SECTION code_l_sccz80 PUBLIC l_eq l_eq: ; de == hl ; carry set if true or a sbc hl,de scf ret z or a ret
;[]-----------------------------------------------------------------[] ;| MEMCPY.ASM -- copy a block of n bytes from src to dst | ;[]-----------------------------------------------------------------[] ; ; C/C++ Run Time Library - Version 10.0 ; ; Copyright (c) 1991, 2000 by Inprise Corporation ; All Rights Reserved. ; ; $Revision: 9.0 $ include RULES.ASI ; Segments Definitions Header@ ;----------------------------------------------------------------------- ; ;Name memcpy - copy a block of n bytes from src to dst ; ;Usage void *memcpy(void *dest, const void *src, size_t n); ; ;Prototype in mem.h & string.h ; ;Description memcpy copies a block of n bytes from src to dest. ; No overlap checking is performed. ; ;Return value memcpy returns dest ; ;----------------------------------------------------------------------- Code_seg@ Func@ memcpy, _EXPFUNC, _RTLENTRY, <pointer dest>,<pointer src>,<int n> Link@ esi,edi mov edi,dest ; get dest mov eax,edi ; copy to eax for return value mov esi,src mov ecx,n mov edx,ecx ; save count shr ecx,1 ; calculate longword count shr ecx,1 cld rep movsd ; copy longwords mov ecx,edx ; get back count and ecx,3 ; calculate remainder byte count (0-3) rep movsb ; copy remaining bytes Unlink@ esi,edi Return@ EndFunc@ memcpy Code_EndS@ end
// Copyright (c) 2010 Satoshi Nakamoto // Copyright (c) 2009-2012 The Bitcoin developers // Copyright (c) 2018 The Gamblecoin Developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <boost/assign/list_of.hpp> #include "base58.h" #include "bitcoinrpc.h" #include "db.h" #include "init.h" #include "main.h" #include "net.h" #include "wallet.h" using namespace std; using namespace boost; using namespace boost::assign; using namespace json_spirit; // These are all in bitcoinrpc.cpp: extern Object JSONRPCError(int code, const string& message); extern int64 AmountFromValue(const Value& value); extern Value ValueFromAmount(int64 amount); extern std::string HelpRequiringPassphrase(); extern void EnsureWalletIsUnlocked(); void ScriptPubKeyToJSON(const CScript& scriptPubKey, Object& out) { txnouttype type; vector<CTxDestination> addresses; int nRequired; out.push_back(Pair("asm", scriptPubKey.ToString())); out.push_back(Pair("hex", HexStr(scriptPubKey.begin(), scriptPubKey.end()))); if (!ExtractDestinations(scriptPubKey, type, addresses, nRequired)) { out.push_back(Pair("type", GetTxnOutputType(TX_NONSTANDARD))); return; } out.push_back(Pair("reqSigs", nRequired)); out.push_back(Pair("type", GetTxnOutputType(type))); Array a; BOOST_FOREACH(const CTxDestination& addr, addresses) a.push_back(CBitcoinAddress(addr).ToString()); out.push_back(Pair("addresses", a)); } void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry) { entry.push_back(Pair("txid", tx.GetHash().GetHex())); entry.push_back(Pair("version", tx.nVersion)); entry.push_back(Pair("locktime", (boost::int64_t)tx.nLockTime)); Array vin; BOOST_FOREACH(const CTxIn& txin, tx.vin) { Object in; if (tx.IsCoinBase()) in.push_back(Pair("coinbase", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()))); else { in.push_back(Pair("txid", txin.prevout.hash.GetHex())); in.push_back(Pair("vout", (boost::int64_t)txin.prevout.n)); Object o; o.push_back(Pair("asm", txin.scriptSig.ToString())); o.push_back(Pair("hex", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()))); in.push_back(Pair("scriptSig", o)); } in.push_back(Pair("sequence", (boost::int64_t)txin.nSequence)); vin.push_back(in); } entry.push_back(Pair("vin", vin)); Array vout; for (unsigned int i = 0; i < tx.vout.size(); i++) { const CTxOut& txout = tx.vout[i]; Object out; out.push_back(Pair("value", ValueFromAmount(txout.nValue))); out.push_back(Pair("n", (boost::int64_t)i)); Object o; ScriptPubKeyToJSON(txout.scriptPubKey, o); out.push_back(Pair("scriptPubKey", o)); vout.push_back(out); } entry.push_back(Pair("vout", vout)); if (hashBlock != 0) { entry.push_back(Pair("blockhash", hashBlock.GetHex())); map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find(hashBlock); if (mi != mapBlockIndex.end() && (*mi).second) { CBlockIndex* pindex = (*mi).second; if (pindex->IsInMainChain()) { entry.push_back(Pair("confirmations", 1 + nBestHeight - pindex->nHeight)); entry.push_back(Pair("time", (boost::int64_t)pindex->nTime)); } else entry.push_back(Pair("confirmations", 0)); } } } Value getrawtransaction(const Array& params, bool fHelp) { if (fHelp || params.size() < 1 || params.size() > 2) throw runtime_error( "getrawtransaction <txid> [verbose=0]\n" "If verbose=0, returns a string that is\n" "serialized, hex-encoded data for <txid>.\n" "If verbose is non-zero, returns an Object\n" "with information about <txid>."); uint256 hash; hash.SetHex(params[0].get_str()); bool fVerbose = false; if (params.size() > 1) fVerbose = (params[1].get_int() != 0); CTransaction tx; uint256 hashBlock = 0; if (!GetTransaction(hash, tx, hashBlock)) throw JSONRPCError(-5, "No information available about transaction"); CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); ssTx << tx; string strHex = HexStr(ssTx.begin(), ssTx.end()); if (!fVerbose) return strHex; Object result; result.push_back(Pair("hex", strHex)); TxToJSON(tx, hashBlock, result); return result; } Value listunspent(const Array& params, bool fHelp) { if (fHelp || params.size() > 2) throw runtime_error( "listunspent [minconf=1] [maxconf=999999]\n" "Returns array of unspent transaction outputs\n" "with between minconf and maxconf (inclusive) confirmations.\n" "Results are an array of Objects, each of which has:\n" "{txid, vout, scriptPubKey, amount, confirmations}"); RPCTypeCheck(params, list_of(int_type)(int_type)); int nMinDepth = 1; if (params.size() > 0) nMinDepth = params[0].get_int(); int nMaxDepth = 999999; if (params.size() > 1) nMaxDepth = params[1].get_int(); Array results; vector<COutput> vecOutputs; pwalletMain->AvailableCoins(vecOutputs, false); BOOST_FOREACH(const COutput& out, vecOutputs) { if (out.nDepth < nMinDepth || out.nDepth > nMaxDepth) continue; int64 nValue = out.tx->vout[out.i].nValue; const CScript& pk = out.tx->vout[out.i].scriptPubKey; Object entry; entry.push_back(Pair("txid", out.tx->GetHash().GetHex())); entry.push_back(Pair("vout", out.i)); entry.push_back(Pair("scriptPubKey", HexStr(pk.begin(), pk.end()))); entry.push_back(Pair("amount",ValueFromAmount(nValue))); entry.push_back(Pair("confirmations",out.nDepth)); results.push_back(entry); } return results; } Value createrawtransaction(const Array& params, bool fHelp) { if (fHelp || params.size() != 2) throw runtime_error( "createrawtransaction [{\"txid\":txid,\"vout\":n},...] {address:amount,...}\n" "Create a transaction spending given inputs\n" "(array of objects containing transaction id and output number),\n" "sending to given address(es).\n" "Returns hex-encoded raw transaction.\n" "Note that the transaction's inputs are not signed, and\n" "it is not stored in the wallet or transmitted to the network."); RPCTypeCheck(params, list_of(array_type)(obj_type)); Array inputs = params[0].get_array(); Object sendTo = params[1].get_obj(); CTransaction rawTx; BOOST_FOREACH(Value& input, inputs) { const Object& o = input.get_obj(); const Value& txid_v = find_value(o, "txid"); if (txid_v.type() != str_type) throw JSONRPCError(-8, "Invalid parameter, missing txid key"); string txid = txid_v.get_str(); if (!IsHex(txid)) throw JSONRPCError(-8, "Invalid parameter, expected hex txid"); const Value& vout_v = find_value(o, "vout"); if (vout_v.type() != int_type) throw JSONRPCError(-8, "Invalid parameter, missing vout key"); int nOutput = vout_v.get_int(); if (nOutput < 0) throw JSONRPCError(-8, "Invalid parameter, vout must be positive"); CTxIn in(COutPoint(uint256(txid), nOutput)); rawTx.vin.push_back(in); } set<CBitcoinAddress> setAddress; BOOST_FOREACH(const Pair& s, sendTo) { CBitcoinAddress address(s.name_); if (!address.IsValid()) throw JSONRPCError(-5, string("Invalid Bitcoin address:")+s.name_); if (setAddress.count(address)) throw JSONRPCError(-8, string("Invalid parameter, duplicated address: ")+s.name_); setAddress.insert(address); CScript scriptPubKey; scriptPubKey.SetDestination(address.Get()); int64 nAmount = AmountFromValue(s.value_); CTxOut out(nAmount, scriptPubKey); rawTx.vout.push_back(out); } CDataStream ss(SER_NETWORK, PROTOCOL_VERSION); ss << rawTx; return HexStr(ss.begin(), ss.end()); } Value decoderawtransaction(const Array& params, bool fHelp) { if (fHelp || params.size() != 1) throw runtime_error( "decoderawtransaction <hex string>\n" "Return a JSON object representing the serialized, hex-encoded transaction."); RPCTypeCheck(params, list_of(str_type)); vector<unsigned char> txData(ParseHex(params[0].get_str())); CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION); CTransaction tx; try { ssData >> tx; } catch (std::exception &e) { throw JSONRPCError(-22, "TX decode failed"); } Object result; TxToJSON(tx, 0, result); return result; } Value signrawtransaction(const Array& params, bool fHelp) { if (fHelp || params.size() < 1 || params.size() > 4) throw runtime_error( "signrawtransaction <hex string> [{\"txid\":txid,\"vout\":n,\"scriptPubKey\":hex},...] [<privatekey1>,...] [sighashtype=\"ALL\"]\n" "Sign inputs for raw transaction (serialized, hex-encoded).\n" "Second optional argument is an array of previous transaction outputs that\n" "this transaction depends on but may not yet be in the blockchain.\n" "Third optional argument is an array of base58-encoded private\n" "keys that, if given, will be the only keys used to sign the transaction.\n" "Fourth option is a string that is one of six values; ALL, NONE, SINGLE or\n" "ALL|ANYONECANPAY, NONE|ANYONECANPAY, SINGLE|ANYONECANPAY.\n" "Returns json object with keys:\n" " hex : raw transaction with signature(s) (hex-encoded string)\n" " complete : 1 if transaction has a complete set of signature (0 if not)" + HelpRequiringPassphrase()); if (params.size() < 3) EnsureWalletIsUnlocked(); RPCTypeCheck(params, list_of(str_type)(array_type)(array_type)); vector<unsigned char> txData(ParseHex(params[0].get_str())); CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION); vector<CTransaction> txVariants; while (!ssData.empty()) { try { CTransaction tx; ssData >> tx; txVariants.push_back(tx); } catch (std::exception &e) { throw JSONRPCError(-22, "TX decode failed"); } } if (txVariants.empty()) throw JSONRPCError(-22, "Missing transaction"); // mergedTx will end up with all the signatures; it // starts as a clone of the rawtx: CTransaction mergedTx(txVariants[0]); bool fComplete = true; // Fetch previous transactions (inputs): map<COutPoint, CScript> mapPrevOut; { MapPrevTx mapPrevTx; CTxDB txdb("r"); map<uint256, CTxIndex> unused; bool fInvalid; mergedTx.FetchInputs(txdb, unused, false, false, mapPrevTx, fInvalid); // Copy results into mapPrevOut: BOOST_FOREACH(const CTxIn& txin, mergedTx.vin) { const uint256& prevHash = txin.prevout.hash; if (mapPrevTx.count(prevHash)) mapPrevOut[txin.prevout] = mapPrevTx[prevHash].second.vout[txin.prevout.n].scriptPubKey; } } // Add previous txouts given in the RPC call: if (params.size() > 1) { Array prevTxs = params[1].get_array(); BOOST_FOREACH(Value& p, prevTxs) { if (p.type() != obj_type) throw JSONRPCError(-22, "expected object with {\"txid'\",\"vout\",\"scriptPubKey\"}"); Object prevOut = p.get_obj(); RPCTypeCheck(prevOut, map_list_of("txid", str_type)("vout", int_type)("scriptPubKey", str_type)); string txidHex = find_value(prevOut, "txid").get_str(); if (!IsHex(txidHex)) throw JSONRPCError(-22, "txid must be hexadecimal"); uint256 txid; txid.SetHex(txidHex); int nOut = find_value(prevOut, "vout").get_int(); if (nOut < 0) throw JSONRPCError(-22, "vout must be positive"); string pkHex = find_value(prevOut, "scriptPubKey").get_str(); if (!IsHex(pkHex)) throw JSONRPCError(-22, "scriptPubKey must be hexadecimal"); vector<unsigned char> pkData(ParseHex(pkHex)); CScript scriptPubKey(pkData.begin(), pkData.end()); COutPoint outpoint(txid, nOut); if (mapPrevOut.count(outpoint)) { // Complain if scriptPubKey doesn't match if (mapPrevOut[outpoint] != scriptPubKey) { string err("Previous output scriptPubKey mismatch:\n"); err = err + mapPrevOut[outpoint].ToString() + "\nvs:\n"+ scriptPubKey.ToString(); throw JSONRPCError(-22, err); } } else mapPrevOut[outpoint] = scriptPubKey; } } bool fGivenKeys = false; CBasicKeyStore tempKeystore; if (params.size() > 2) { fGivenKeys = true; Array keys = params[2].get_array(); BOOST_FOREACH(Value k, keys) { CBitcoinSecret vchSecret; bool fGood = vchSecret.SetString(k.get_str()); if (!fGood) throw JSONRPCError(-5,"Invalid private key"); CKey key; bool fCompressed; CSecret secret = vchSecret.GetSecret(fCompressed); key.SetSecret(secret, fCompressed); tempKeystore.AddKey(key); } } const CKeyStore& keystore = (fGivenKeys ? tempKeystore : *pwalletMain); int nHashType = SIGHASH_ALL; if (params.size() > 3) { static map<string, int> mapSigHashValues = boost::assign::map_list_of (string("ALL"), int(SIGHASH_ALL)) (string("ALL|ANYONECANPAY"), int(SIGHASH_ALL|SIGHASH_ANYONECANPAY)) (string("NONE"), int(SIGHASH_NONE)) (string("NONE|ANYONECANPAY"), int(SIGHASH_NONE|SIGHASH_ANYONECANPAY)) (string("SINGLE"), int(SIGHASH_SINGLE)) (string("SINGLE|ANYONECANPAY"), int(SIGHASH_SINGLE|SIGHASH_ANYONECANPAY)) ; string strHashType = params[3].get_str(); if (mapSigHashValues.count(strHashType)) nHashType = mapSigHashValues[strHashType]; else throw JSONRPCError(-8, "Invalid sighash param"); } // Sign what we can: for (unsigned int i = 0; i < mergedTx.vin.size(); i++) { CTxIn& txin = mergedTx.vin[i]; if (mapPrevOut.count(txin.prevout) == 0) { fComplete = false; continue; } const CScript& prevPubKey = mapPrevOut[txin.prevout]; txin.scriptSig.clear(); SignSignature(keystore, prevPubKey, mergedTx, i, nHashType); // ... and merge in other signatures: BOOST_FOREACH(const CTransaction& txv, txVariants) { txin.scriptSig = CombineSignatures(prevPubKey, mergedTx, i, txin.scriptSig, txv.vin[i].scriptSig); } if (!VerifyScript(txin.scriptSig, prevPubKey, mergedTx, i, true, 0)) fComplete = false; } Object result; CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); ssTx << mergedTx; result.push_back(Pair("hex", HexStr(ssTx.begin(), ssTx.end()))); result.push_back(Pair("complete", fComplete)); return result; } Value sendrawtransaction(const Array& params, bool fHelp) { if (fHelp || params.size() < 1 || params.size() > 1) throw runtime_error( "sendrawtransaction <hex string>\n" "Submits raw transaction (serialized, hex-encoded) to local node and network."); RPCTypeCheck(params, list_of(str_type)); // parse hex string from parameter vector<unsigned char> txData(ParseHex(params[0].get_str())); CDataStream ssData(txData, SER_NETWORK, PROTOCOL_VERSION); CTransaction tx; // deserialize binary data stream try { ssData >> tx; } catch (std::exception &e) { throw JSONRPCError(-22, "TX decode failed"); } uint256 hashTx = tx.GetHash(); // See if the transaction is already in a block // or in the memory pool: CTransaction existingTx; uint256 hashBlock = 0; if (GetTransaction(hashTx, existingTx, hashBlock)) { if (hashBlock != 0) throw JSONRPCError(-5, string("transaction already in block ")+hashBlock.GetHex()); // Not in block, but already in the memory pool; will drop // through to re-relay it. } else { // push to local node CTxDB txdb("r"); if (!tx.AcceptToMemoryPool(txdb)) throw JSONRPCError(-22, "TX rejected"); SyncWithWallets(tx, NULL, true); } RelayMessage(CInv(MSG_TX, hashTx), tx); return hashTx.GetHex(); }
#include<bits/stdc++.h> using namespace std; int main() { vector<int> arr = {-5, -2, 5, 2, 4, 7, 1, 8, 0, -8}; int i = -1, temp = 0; for (int j = 0; j < arr.size() - 1; j++){ if(arr[j] < 0){ i++; temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; } } int pos = i+1, neg = 0; while(pos < arr.size() && neg < pos && arr[neg] < 0){ temp = arr[neg]; arr[neg] = arr[pos]; arr[pos] = temp; pos++; neg+=2; } for (int j = 0; j < arr.size() - 1; j++) cout << arr[j] << '\t'; return 0; }
; $Id: beeper_mwr.asm $ ; ; 1 bit sound library - version for "memory write" I/O architectures ; by Stefano Bodrato, 31/03/08 ; ; ZX Spectrum-like call: ; HL=duration ; DE=frequency ; IF !__CPU_GBZ80__ && !__CPU_INTEL__ SECTION code_clib PUBLIC beeper PUBLIC _beeper INCLUDE "games/games.inc" EXTERN __snd_tick ;EXTERN bit_open_di ;EXTERN bit_close_ei .beeper ._beeper push ix ld a,l srl l srl l cpl and 3 ld c,a ld b,0 ld ix,beixp3 add ix,bc ;call bit_open_di ld a,(__snd_tick) .beixp3 nop nop nop inc b inc c .behllp dec c jr nz,behllp ld c,$3F dec b jp nz,behllp xor sndbit_mask ld (sndbit_port),a ; This is three cycles slower tha the OUT based version ld b,h ld c,a bit sndbit_bit,a ;if o/p go again! jr nz,be_again ld a,d or e jr z,be_end ld a,c ld c,l dec de jp (ix) .be_again ld c,l inc c jp (ix) .be_end ;call bit_close_ei pop ix ret ENDIF
;LickilickyBaseStats: ; 38f92 (e:4f92) db DEX_LICKILICKY ; pokedex id db 110 ; base hp db 85 ; base attack db 95 ; base defense db 50 ; base speed db 95 ; base special db NORMAL ; species type 1 db NORMAL ; species type 2 db FULL_HEAL ; catch rate db 193 ; base exp yield INCBIN "pic/ymon/lickilicky.pic",0,1 ; 77, sprite dimensions dw LickilickyPicFront dw LickilickyPicBack db LICK db 0 db 0 db 0 db 0 ; growth rate ; learnset tmlearn 1,3,5,6,8 tmlearn 9,10,11,12,13,14,15,16 tmlearn 17,18,19,24 tmlearn 25,26,27,30,31,32 tmlearn 34,35,36,37,38,40 tmlearn 42,44,48 tmlearn 51,53,54 db BANK(LickilickyPicFront)
// Copyright (c) 2001, Daniel C. Nuffer // Copyright (c) 2001-2010 Hartmut Kaiser // // 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) #if !defined(BOOST_SPIRIT_ITERATOR_BUF_ID_CHECK_POLICY_MAR_16_2007_1108AM) #define BOOST_SPIRIT_ITERATOR_BUF_ID_CHECK_POLICY_MAR_16_2007_1108AM #include <boost/spirit/home/support/iterators/multi_pass_fwd.hpp> #include <boost/spirit/home/support/iterators/detail/multi_pass.hpp> #include <boost/config.hpp> #include <boost/throw_exception.hpp> #include <exception> // for std::exception namespace boost { namespace spirit { namespace iterator_policies { /////////////////////////////////////////////////////////////////////////// // class illegal_backtracking // thrown by buf_id_check CheckingPolicy if an instance of an iterator is // used after another one has invalidated the queue /////////////////////////////////////////////////////////////////////////// class illegal_backtracking : public std::exception { public: illegal_backtracking() throw() {} ~illegal_backtracking() throw() {} char const* what() const throw() { return "boost::spirit::multi_pass::illegal_backtracking"; } }; /////////////////////////////////////////////////////////////////////////////// // class buf_id_check // Implementation of the CheckingPolicy used by multi_pass // This policy is most effective when used together with the std_deque // StoragePolicy. // // If used with the fixed_size_queue StoragePolicy, it will not detect // iterator dereferences that are out of the range of the queue. /////////////////////////////////////////////////////////////////////////////// struct buf_id_check { /////////////////////////////////////////////////////////////////////// struct unique //: detail::default_checking_policy { unique() : buf_id(0) {} unique(unique const& x) : buf_id(x.buf_id) {} void swap(unique& x) { boost::swap(buf_id, x.buf_id); } // called to verify that everything is ok. template <typename MultiPass> static void docheck(MultiPass const& mp) { if (mp.buf_id != mp.shared()->shared_buf_id) boost::throw_exception(illegal_backtracking()); } // called from multi_pass::clear_queue, so we can increment the count template <typename MultiPass> static void clear_queue(MultiPass& mp) { ++mp.shared()->shared_buf_id; ++mp.buf_id; } template <typename MultiPass> static void destroy(MultiPass&) {} protected: unsigned long buf_id; }; /////////////////////////////////////////////////////////////////////// struct shared { shared() : shared_buf_id(0) {} unsigned long shared_buf_id; }; }; }}} #endif
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r13 push %r9 push %rbp push %rbx push %rcx push %rdi push %rsi lea addresses_A_ht+0x1ed68, %rdi nop add %r11, %r11 movl $0x61626364, (%rdi) nop nop nop nop nop and $60414, %r13 lea addresses_normal_ht+0xbf28, %rsi lea addresses_WT_ht+0x2903, %rdi nop nop nop nop and $31315, %r9 mov $38, %rcx rep movsw nop and %rcx, %rcx lea addresses_A_ht+0x5b68, %r11 nop nop nop nop cmp $26897, %rbp movw $0x6162, (%r11) xor $6024, %r9 lea addresses_WC_ht+0x19d0e, %rcx nop nop nop nop nop xor $40817, %r9 movb $0x61, (%rcx) nop nop add $39177, %rsi lea addresses_WC_ht+0x14ce6, %r9 clflush (%r9) nop nop nop nop nop xor %rcx, %rcx mov $0x6162636465666768, %rsi movq %rsi, (%r9) nop nop nop nop cmp $30260, %rbp lea addresses_A_ht+0x12168, %rsi lea addresses_UC_ht+0x10b68, %rdi and %rbx, %rbx mov $13, %rcx rep movsl nop nop nop nop nop dec %rbx lea addresses_WT_ht+0x1968, %r11 nop nop nop nop nop dec %r13 mov $0x6162636465666768, %r9 movq %r9, %xmm7 movups %xmm7, (%r11) nop nop nop nop nop dec %rdi lea addresses_normal_ht+0x11748, %rsi lea addresses_normal_ht+0x2838, %rdi nop cmp $39620, %rbp mov $103, %rcx rep movsb nop nop nop nop sub %rbx, %rbx lea addresses_normal_ht+0x1b6e8, %r11 nop nop add %rbp, %rbp movb (%r11), %r9b nop nop nop nop nop cmp $2685, %r13 lea addresses_D_ht+0x10886, %rsi lea addresses_WT_ht+0x1a168, %rdi nop nop nop nop nop xor %r13, %r13 mov $116, %rcx rep movsb inc %rcx lea addresses_A_ht+0x85c4, %r11 nop nop nop nop nop sub $36695, %rbx movb $0x61, (%r11) nop nop nop nop sub %rbx, %rbx lea addresses_WT_ht+0x1de68, %rcx nop nop nop and $6997, %rbp movups (%rcx), %xmm4 vpextrq $1, %xmm4, %r9 nop nop nop nop dec %rbx pop %rsi pop %rdi pop %rcx pop %rbx pop %rbp pop %r9 pop %r13 pop %r11 ret .global s_faulty_load s_faulty_load: push %r10 push %r13 push %r14 push %r9 push %rbp push %rdi push %rdx // Load lea addresses_normal+0x1d0e8, %r14 sub $38563, %r9 mov (%r14), %dx lfence // Store lea addresses_normal+0x1a5dc, %r13 clflush (%r13) nop nop cmp %r10, %r10 movw $0x5152, (%r13) nop nop nop nop sub $41598, %r9 // Faulty Load lea addresses_D+0x18168, %r14 nop nop nop nop cmp %rdi, %rdi mov (%r14), %r9w lea oracles, %r10 and $0xff, %r9 shlq $12, %r9 mov (%r10,%r9,1), %r9 pop %rdx pop %rdi pop %rbp pop %r9 pop %r14 pop %r13 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 2, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_D', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 10, 'same': True}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 0, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 8, 'same': True}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 9, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 11, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 4, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 2, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_normal_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 7, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 0, 'same': False}, 'dst': {'type': 'addresses_WT_ht', 'congruent': 8, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_A_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}} {'36': 5148} 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 */
; A171008: Write the n-th prime in binary and change all 0's to 1's and all 1's to 0's. ; Submitted by Christian Krause ; 1,0,10,0,100,10,1110,1100,1000,10,0,11010,10110,10100,10000,1010,100,10,111100,111000,110110,110000,101100,100110,11110,11010,11000,10100,10010,1110,0,1111100,1110110,1110100,1101010,1101000,1100010,1011100 seq $0,145382 ; Write the n-th prime in binary. Change all 0's to 1's and all 1's to 0's. a(n) is the decimal equivalent of the result. seq $0,7088 ; The binary numbers (or binary words, or binary vectors, or binary expansion of n): numbers written in base 2.
db 0 ; species ID placeholder db 35, 35, 35, 35, 35, 35 ; hp atk def spd sat sdf db FIGHTING, FIGHTING ; type db 75 ; catch rate db 91 ; base exp db NO_ITEM, NO_ITEM ; items db GENDER_F0 ; gender ratio db 25 ; step cycles to hatch INCBIN "gfx/pokemon/tyrogue/front.dimensions" db GROWTH_MEDIUM_FAST ; growth rate dn EGG_NONE, EGG_NONE ; egg groups db 70 ; happiness ; tm/hm learnset tmhm TOXIC, BULK_UP, HIDDEN_POWER, SUNNY_DAY, PROTECT, RAIN_DANCE, FRUSTRATION, EARTHQUAKE, RETURN, BRICK_BREAK, DOUBLE_TEAM, FACADE, SECRET_POWER, REST, ATTRACT, THIEF, ENDURE, CAPTIVATE, ROCK_SLIDE, SLEEP_TALK, NATURAL_GIFT, SWAGGER, SUBSTITUTE, STRENGTH, ROCK_SMASH, HELPING_HAND, MUD_SLAP, SNORE, SWIFT, UPROAR, VACUUM_WAVE ; end
/* * BSD LICENSE * Copyright (c) 2021 Samsung Electronics Corporation * 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 Samsung Electronics Corporation 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 "src/allocator/context_manager/gc_ctx/gc_ctx.h" #include "src/include/pos_event_id.h" #include "src/logger/logger.h" namespace pos { GcCtx::GcCtx(void) { normalGcthreshold = DEFAULT_GC_THRESHOLD; urgentGcthreshold = DEFAULT_URGENT_THRESHOLD; curGcMode = MODE_NO_GC; } int GcCtx::GetNormalGcThreshold(void) { return normalGcthreshold; } int GcCtx::GetUrgentThreshold(void) { return urgentGcthreshold; } void GcCtx::SetNormalGcThreshold(int inputThreshold) { normalGcthreshold = inputThreshold; } void GcCtx::SetUrgentThreshold(int inputThreshold) { urgentGcthreshold = inputThreshold; } GcMode GcCtx::GetCurrentGcMode(int numFreeSegments) { if (urgentGcthreshold >= numFreeSegments) { if (curGcMode != MODE_URGENT_GC) { POS_TRACE_INFO(EID(ALLOCATOR_CURRENT_GC_MODE), "Change GC STATE from GCState:{} to URGENT GC MODE, free segment count:{}", (int)curGcMode, numFreeSegments); } curGcMode = MODE_URGENT_GC; } else if (normalGcthreshold >= numFreeSegments) { if (curGcMode != MODE_NORMAL_GC) { POS_TRACE_INFO(EID(ALLOCATOR_CURRENT_GC_MODE), "Change GC STATE from GCState:{} to NORMAL GC MODE, free segment count:{}", (int)curGcMode, numFreeSegments); } curGcMode = MODE_NORMAL_GC; } else { if (curGcMode != MODE_NO_GC) { POS_TRACE_INFO(EID(ALLOCATOR_CURRENT_GC_MODE), "Change GC STATE from GCState:{} to NO GC MODE, free segment count:{}", (int)curGcMode, numFreeSegments); } curGcMode = MODE_NO_GC; } return curGcMode; } } // namespace pos
; ; This file is automatically generated ; ; Do not edit!!! ; ; djm 12/2/2000 ; ; ZSock Lib function: sock_flush XLIB sock_flush LIB no_zsock INCLUDE "#packages.def" INCLUDE "#zsock.def" .sock_flush ld a,r_sock_flush call_pkg(tcp_all) ret nc ; We failed..are we installed? cp rc_pnf scf ;signal error ret nz ;Internal error call_pkg(tcp_ayt) jr nc,sock_flush jp no_zsock
.inesprg 2 ; 1x 16KB PRG code .ineschr 1 ; 1x 8KB CHR data .inesmap 0 ; mapper 0 = NROM, no bank swapping .inesmir 1 ; background mirroring .rsset $0000 ;;start variables at ram location 0 gamestate .rs 1 ; .rs 1 means reserve one byte of space shipx .rs 1 ; ship horizontal position shipy .rs 1 ; ship vertical position scroll .rs 1 ; horizontal scroll count nametable .rs 1 ; which nametable to draw first bouncedir .rs 1 ; is ship going up or down random .rs 1 ; random number generator enemyx .rs 1 ; enemy horizontal position enemyy .rs 1 ; enemy vertical position enemycounter .rs 1 ;interval to update enemy position bulletx .rs 1 bullety .rs 1 score1 .rs 1 ;score 1's place score10 .rs 1 ;score 10's place score100 .rs 1 ;score 100's place realscore .rs 1 ;score 10's place scorecounter .rs 1 ;score 10's place .bank 0 .org $8000 RESET: SEI ; disable IRQs CLD ; disable decimal mode LDX #$40 STX $4017 ; disable APU frame IRQ LDX #$FF TXS ; Set up stack INX ; now X = 0 STX $2000 ; disable NMI STX $2001 ; disable rendering STX $4010 ; disable DMC IRQs vblankwait1: ; First wait for vblank to make sure PPU is ready BIT $2002 BPL vblankwait1 clrmem: LDA #0 STA $0000, x STA $0100, x STA $0300, x STA $0400, x STA $0500, x STA $0600, x STA $0700, x LDA #$FE STA $0200, x INX BNE clrmem vblankwait2: ; Second wait for vblank, PPU is ready after this BIT $2002 BPL vblankwait2 ;;;Set some initial ship stats LDA #100 STA shipy LDA #120 STA shipx ;enemy LDA #150 STA enemyy LDA #170 STA enemyx LDA #0 STA enemycounter ;bullet LDA #0 STA bulletx LDA #$FE ;makes it off screen STA bullety ;start scroll at 0 LDA #0 STA scroll ;score LDA #123 CLC ADC #31 STA realscore ;set initial nametable to 0 LDA #0 STA nametable LDA #0 STA bouncedir ;random seed ;TODO set this second time when player first shoots LDA #27 STA random ;must be set up before re-enabling NMI ;otherwise it won't have time to finish ;rendering the background JSR UpdateBackground JSR UpdateBackground2 JSR UpdateBackgroundName ;my own palette JSR SetColors ;enable nmi JSR SetNameTable Forever: JMP Forever ;jump back to Forever, infinite loop, waiting for NMI ;GAME LAYOUT ;Init Code -> Infinite Loop -> NMI -> Graphics Updates -> Read Buttons -> Game Engine --\ ; ^ | ; \------------------------------------------------------------------/ NMI: ;OAM and nametable updates have to finish before scanline 0 LDA #$02 STA $4014 ; set the high byte (02) of the RAM address, start OAM transfer ;do any nametable changes here - last chance before PPU Cleanup JSR UpdateScore ;PPU CLEANUP SECTION LDA #$00 STA $2006 ; clean up PPU address registers STA $2006 LDA #%00011110 ; enable sprites, enable background, no clipping on left side STA $2001 ;do scrolling INC scroll ; add one to our scroll variable each frame LDA scroll BNE SwapNameTablesCheck JSR SwapNameTables SwapNameTablesCheck: LDA scroll STA $2005 LDA #$00 ; no vertical scrolling STA $2005 JSR SetNameTable ;TODO not sure if i'm setting these registers in the correct order ;all graphics updates done by this point, now run game engine GameEngine: JSR ControllerCheck JSR ProcessBullet JSR ProcessBullet JSR UpdateEnemy JSR CheckEnemyCollision JSR UpdateSprites JSR ConvertScore RTI ; return from interrupt ConvertScore: ;routine to get realscore in hex ; LDA realscore ; AND #%00001111 ; STA score1 ; LDA realscore ; AND #%11110000 ; LSR A ; LSR A ; LSR A ; LSR A ; STA score10 ;routine to get realscore in decimal LDA #0 STA score1 STA score10 STA score100 LDA realscore STA scorecounter ScoreLoop: LDA scorecounter BEQ FinishScore DEC scorecounter INC score1 LDA score1 CMP #10 BNE ScoreLoop LDA #0 STA score1 INC score10 LDA score10 CMP #10 BNE ScoreLoop LDA #0 STA score10 INC score100 JMP ScoreLoop FinishScore: RTS UpdateScore: LDA $2002 ; read PPU status to reset the high/low latch LDA #$22 ;writing to first tile of nametable STA $2006 ; write the high byte of column address LDA #$4D STA $2006 ; write the low byte of column address LDA score100 STA $2007 LDA score10 STA $2007 LDA score1 STA $2007 RTS UpdateEnemy: DEC enemyx LDA enemyx BNE SkipEnemyUpdate JSR NEXTRND LDA random ;divide by two and add 50 to end up in the range of 50-178 LSR A ADC #50 STA enemyy ;prevent enemy animation from jumping during the 1 frame LDA #255 STA enemyx SkipEnemyUpdate: RTS CheckEnemyCollision: ;only do collision check is bullet is active LDA bullety CMP #$FE BEQ NoCollision ;compare x coordinate LDA bulletx CMP enemyx BCC NoCollision LDA enemyx CLC ADC #10 CMP bulletx BCC NoCollision ;compare y coordinate LDA bullety CLC ADC #6 CMP enemyy BCC NoCollision LDA enemyy CLC ADC #8 CMP bullety BCC NoCollision ;if there was a hit LDA #$FE STA enemyy STA bullety ;update score ; INC score1 ; LDA score1 ; CMP #10 ;if score==10 increase score10 set score1 back to 0 ; BNE NoCollision ; LDA #0 ; STA score1 ; INC score10 INC realscore NoCollision: RTS ProcessBullet: LDA bullety CMP #$FE BEQ SkipBullet INC bulletx LDA bulletx CMP #$FF BNE SkipBullet ;if it's reached the end then move it off screen LDA #$FE STA bullety SkipBullet: RTS SetColors: LDA $2002 ; read PPU status to reset the high/low latch to high ;background colors LDA #$3F STA $2006 ; write the high byte of $3F10 address LDA #$00 STA $2006 ; write the low byte of $3F10 address LDA #$3C ;blue background STA $2007 ; LDA #53 ;pink LDA #40 ;green STA $2007 ; LDA #32 ;white LDA #39 ;brown STA $2007 LDA #47 ;black STA $2007 ;ship color LDA #$3F STA $2006 ; write the high byte of $3F10 address LDA #$11 STA $2006 ; write the low byte of $3F10 address LDA #21 ;red - enemy STA $2007 LDA #33 ;light blue STA $2007 LDA #18 ;dark blue STA $2007 RTS SwapNameTables: LDA nametable ; load current nametable number (0 or 1) EOR #$01 ; exclusive OR of bit 0 will flip that bit STA nametable ; so if nametable was 0, now 1 ; if nametable was 1, now 0 ; BNE CLCCheck ; CLC ; CLCCheck: RTS SetNameTable: LDA #%10010000 ; enable NMI, sprites from Pattern Table 0, background from Pattern Table 1 ORA nametable ; select correct nametable for bit 0 STA $2000 RTS ControllerCheck: LDA #1 STA $4016 LDA #0 STA $4016 ; tell both the controllers to latch buttons LDA $4016 ; player 1 - A AND #1 BEQ NotPressedA LDA shipy STA bullety LDA shipx STA bulletx NotPressedA: LDA $4016 ; player 1 - B LDA $4016 ; player 1 - Select LDA $4016 ; player 1 - Start LDA $4016 ; player 1 - Up AND #1 BEQ NotPressedUp DEC shipy NotPressedUp: LDA $4016 ; player 1 - Down AND #1 BEQ NotPressedDown INC shipy NotPressedDown: LDA $4016 ; player 1 - Left AND #1 BEQ NotPressedLeft DEC shipx NotPressedLeft: LDA $4016 ; player 1 - Right AND #1 BEQ NotPressedRight INC shipx NotPressedRight: RTS ;Random Number Generator NEXTRND: LDA random ASL A ; A = RND * 2 ASL A ; A = RND * 4 CLC ADC random ; A = RND * 5 CLC ADC #17 ; A = RND * 5 + 17 STA random RTS UpdateSprites: ; BallCheckHigh: ; LDA shipy ; CMP #38 ; BNE BallCheckLow ; LDA #0 ; STA bouncedir ; JMP BounceStage ; BallCheckLow: ; CMP #216 ; BNE BounceStage ; LDA #1 ; STA bouncedir ; BounceStage: ; LDA bouncedir ; BNE BounceUp ;if ; INC shipy ; JMP FinishBounce ; BounceUp: ;else ; DEC shipy ; FinishBounce: ;endif ; ship oam LDA shipy STA $0200 LDA #117 STA $0201 LDA #$00 STA $0202 LDA shipx STA $0203 ; enemy oam LDA enemyy STA $0204 LDA #240 STA $0205 LDA #$00 STA $0206 LDA enemyx STA $0207 ; bullet oam LDA bullety STA $0208 LDA #116 STA $0209 LDA #$00 STA $020A LDA bulletx STA $020B ;;update paddle sprites RTS UpdateBackground: LDA $2002 ; read PPU status to reset the high/low latch ;NAMETABLE 1 LDA #$20 ;writing to first tile of nametable STA $2006 ; write the high byte of column address LDA #$00 STA $2006 ; write the low byte of column address ; loop Y for 28 times ; loop X for 32 times LDY #30 MyLoopY: LDX #32 MyLoopX: LDA #75 CPY #2 BEQ GroundTile CPY #1 BEQ GroundTile LDA #36 GroundTile: STA $2007 DEX BNE MyLoopX DEY BNE MyLoopY ;NAMETABLE 2 LDA #$24 ;writing to first tile of nametable STA $2006 ; write the high byte of column address LDA #$00 STA $2006 ; write the low byte of column address ; loop Y for 28 times ; loop X for 32 times LDY #30 MyLoopY3: LDX #32 MyLoopX3: LDA #75 CPY #2 BEQ GroundTile2 CPY #1 BEQ GroundTile2 LDA #36 GroundTile2: STA $2007 DEX BNE MyLoopX3 DEY BNE MyLoopY3 RTS UpdateBackground2: LDA $2002 ; read PPU status to reset the high/low latch ;NAMETABLE1 LDA #$20 ;writing to first tile of nametable STA $2006 ; write the high byte of column address LDA #$00 STA $2006 ; write the low byte of column address ; loop Y for 28 times ; loop X for 32 times LDY #5 MyLoopY2: LDX #32 MyLoopX2: LDA #71 STA $2007 DEX BNE MyLoopX2 DEY BNE MyLoopY2 ;NAMETABLE 2 LDA #$24 ;writing to first tile of nametable STA $2006 ; write the high byte of column address LDA #$00 STA $2006 ; write the low byte of column address ; loop Y for 28 times ; loop X for 32 times LDY #5 MyLoopY4: LDX #32 MyLoopX4: LDA #71 STA $2007 DEX BNE MyLoopX4 DEY BNE MyLoopY4 RTS UpdateBackgroundName: LDA $2002 ; read PPU status to reset the high/low latch LDA #$26 ;writing to first tile of nametable STA $2006 ; write the high byte of column address LDA #$08 STA $2006 ; write the low byte of column address LDX #0 ; start out at 0 LoadNameLoop: LDA myname, x ; load data from address (PaletteData + the value in x) ; 1st time through loop it will load PaletteData+0 ; 2nd time through loop it will load PaletteData+1 ; 3rd time through loop it will load PaletteData+2 ; etc STA $2007 ; write to PPU INX ; X = X + 1 CPX #11 ; size of db BNE LoadNameLoop ; Branch to LoadPalettesLoop if compare was Not Equal to zero ; if compare was equal to 32, keep going down RTS myname: .db $17,$0e,$1c,$24,$12,$1c,$24,$0c,$18,$18,$15 ;NES IS COOL in hex .org $FFFA ;first of the three vectors starts here .dw NMI ;when an NMI happens (once per frame if enabled) the ;processor will jump to the label NMI: .dw RESET ;when the processor first turns on or is reset, it will jump ;to the label RESET: .dw 0 ;external interrupt IRQ is not used in this tutorial ;;;;;;;;;;;;;; .incbin "alternate.chr"
; ; Generic pseudo graphics routines for text-only platforms ; ; Plot pixel1 at (x,y) coordinate. ; SECTION code_clib PUBLIC plotpixel .plotpixel defc NEEDplot = 1 INCLUDE "pixel1.inc"
;3-ex1.1.asm ; Allow user enter day (any digit, 1 digit) ; If 1-7, display "Valid day" ; else, display "Not a valid day" .MODEL SMALL .STACK 100 .DATA opText DB 'Enter a day: $' nl DB 13,10,'$' op DB ? valid DB 'Valid day$' inval DB 'Not a valid day$' .CODE MAIN PROC MOV AX,@DATA MOV DS,AX ; ask for operator MOV AH, 09h LEA DX, opText INT 21h MOV AH, 01h INT 21h MOV op, AL CALL newline ; if 1 <= op <= 7 CMP op, '1' JL INVA CMP op, '7' JG INVA LEA DX, valid JMP fin INVA: LEA DX, inval FIN: MOV AH, 09h INT 21H MOV AX,4C00H INT 21H MAIN ENDP newline PROC MOV AH, 09h LEA DX, nl INT 21h RET newline ENDP END MAIN
.data 0x10010402 vettore: .byte 5, 4, 100, 3 fine_dati: .text la $t8, vettore # USATA PER LA CONDIZIONE DI FINE AREA DATI (FINE VETTORE, SENZA LUNGHEZZA ESPLICITA) lb $t0, vettore # first word loaded la $s0, fine_dati li $t3, 0 # int sum li $t4, 0 # array index for_loop: # USO QUESTE SE HO ESPLICITA LA LUNGHEZZA DELL'ARRAY #sltiu $t7, $t2, 4 # array length #beq $t7, $0, loop_end # loop-end condition # ALTRIMENTI USO QUESTO DICHIARANDO 'FINE_DATI:' addu $t9, $t4, $t8 # t9 = index + [data-address] beq $t9, $s0, loop_end # loop-end condition: t9 == [fine-dati address] add $t3, $t3, $t0 # sum addiu $t4, $t4, 1 # next byte lb $t0, vettore($t4) # next byte loaded j for_loop loop_end: li $v0, 10 syscall
SECTION code_clib SECTION code_fp_am9511 PUBLIC ___mulsint2slong EXTERN cam32_sdcc___mulsint2slong ; multiply two signed 16-bit multiplicands into a 32-bit product ; ; enter : stack = multiplicand (16-bit), multiplicand (16-bit), ret ; ; exit : dehl = product defc ___mulsint2slong = cam32_sdcc___mulsint2slong
;***************************************************************************** ;* MMX/SSE2/AVX-optimized 10-bit H.264 chroma MC code ;***************************************************************************** ;* Copyright (C) 2005-2011 x264 project ;* ;* Authors: Daniel Kang <daniel.d.kang@gmail.com> ;* ;* This file is part of Libav. ;* ;* Libav 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. ;* ;* Libav 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 Libav; 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_RODATA cextern pw_4 cextern pw_8 cextern pw_32 cextern pw_64 SECTION .text %macro MV0_PIXELS_MC8 0 lea r4, [r2*3 ] lea r5, [r2*4 ] .next4rows: movu m0, [r1 ] movu m1, [r1+r2 ] CHROMAMC_AVG m0, [r0 ] CHROMAMC_AVG m1, [r0+r2 ] mova [r0 ], m0 mova [r0+r2 ], m1 movu m0, [r1+r2*2] movu m1, [r1+r4 ] CHROMAMC_AVG m0, [r0+r2*2] CHROMAMC_AVG m1, [r0+r4 ] mova [r0+r2*2], m0 mova [r0+r4 ], m1 add r1, r5 add r0, r5 sub r3d, 4 jne .next4rows %endmacro ;----------------------------------------------------------------------------- ; void ff_put/avg_h264_chroma_mc8(pixel *dst, pixel *src, int stride, int h, ; int mx, int my) ;----------------------------------------------------------------------------- %macro CHROMA_MC8 1 cglobal %1_h264_chroma_mc8_10, 6,7,8 movsxdifnidn r2, r2d mov r6d, r5d or r6d, r4d jne .at_least_one_non_zero ; mx == 0 AND my == 0 - no filter needed MV0_PIXELS_MC8 REP_RET .at_least_one_non_zero: mov r6d, 2 test r5d, r5d je .x_interpolation mov r6, r2 ; dxy = x ? 1 : stride test r4d, r4d jne .xy_interpolation .x_interpolation: ; mx == 0 XOR my == 0 - 1 dimensional filter only or r4d, r5d ; x + y movd m5, r4d mova m4, [pw_8] mova m6, [pw_4] ; mm6 = rnd >> 3 SPLATW m5, m5 ; mm5 = B = x psubw m4, m5 ; mm4 = A = 8-x .next1drow: movu m0, [r1 ] ; mm0 = src[0..7] movu m2, [r1+r6] ; mm2 = src[1..8] pmullw m0, m4 ; mm0 = A * src[0..7] pmullw m2, m5 ; mm2 = B * src[1..8] paddw m0, m6 paddw m0, m2 psrlw m0, 3 CHROMAMC_AVG m0, [r0] mova [r0], m0 ; dst[0..7] = (A * src[0..7] + B * src[1..8] + (rnd >> 3)) >> 3 add r0, r2 add r1, r2 dec r3d jne .next1drow REP_RET .xy_interpolation: ; general case, bilinear movd m4, r4m ; x movd m6, r5m ; y SPLATW m4, m4 ; mm4 = x words SPLATW m6, m6 ; mm6 = y words psllw m5, m4, 3 ; mm5 = 8x pmullw m4, m6 ; mm4 = x * y psllw m6, 3 ; mm6 = 8y paddw m1, m5, m6 ; mm7 = 8x+8y mova m7, m4 ; DD = x * y psubw m5, m4 ; mm5 = B = 8x - xy psubw m6, m4 ; mm6 = C = 8y - xy paddw m4, [pw_64] psubw m4, m1 ; mm4 = A = xy - (8x+8y) + 64 movu m0, [r1 ] ; mm0 = src[0..7] movu m1, [r1+2] ; mm1 = src[1..8] .next2drow: add r1, r2 pmullw m2, m0, m4 pmullw m1, m5 paddw m2, m1 ; mm2 = A * src[0..7] + B * src[1..8] movu m0, [r1] movu m1, [r1+2] pmullw m3, m0, m6 paddw m2, m3 ; mm2 += C * src[0..7+strde] pmullw m3, m1, m7 paddw m2, m3 ; mm2 += D * src[1..8+strde] paddw m2, [pw_32] psrlw m2, 6 CHROMAMC_AVG m2, [r0] mova [r0], m2 ; dst[0..7] = (mm2 + 32) >> 6 add r0, r2 dec r3d jne .next2drow REP_RET %endmacro ;----------------------------------------------------------------------------- ; void ff_put/avg_h264_chroma_mc4(pixel *dst, pixel *src, int stride, int h, ; int mx, int my) ;----------------------------------------------------------------------------- ;TODO: xmm mc4 %macro MC4_OP 2 movq %1, [r1 ] movq m1, [r1+2] add r1, r2 pmullw %1, m4 pmullw m1, m2 paddw m1, %1 mova %1, m1 pmullw %2, m5 pmullw m1, m3 paddw %2, [pw_32] paddw m1, %2 psrlw m1, 6 CHROMAMC_AVG m1, %2, [r0] movq [r0], m1 add r0, r2 %endmacro %macro CHROMA_MC4 1 cglobal %1_h264_chroma_mc4_10, 6,6,7 movsxdifnidn r2, r2d movd m2, r4m ; x movd m3, r5m ; y mova m4, [pw_8] mova m5, m4 SPLATW m2, m2 SPLATW m3, m3 psubw m4, m2 psubw m5, m3 movq m0, [r1 ] movq m6, [r1+2] add r1, r2 pmullw m0, m4 pmullw m6, m2 paddw m6, m0 .next2rows: MC4_OP m0, m6 MC4_OP m6, m0 sub r3d, 2 jnz .next2rows REP_RET %endmacro ;----------------------------------------------------------------------------- ; void ff_put/avg_h264_chroma_mc2(pixel *dst, pixel *src, int stride, int h, ; int mx, int my) ;----------------------------------------------------------------------------- %macro CHROMA_MC2 1 cglobal %1_h264_chroma_mc2_10, 6,7 movsxdifnidn r2, r2d mov r6d, r4d shl r4d, 16 sub r4d, r6d add r4d, 8 imul r5d, r4d ; x*y<<16 | y*(8-x) shl r4d, 3 sub r4d, r5d ; x*(8-y)<<16 | (8-x)*(8-y) movd m5, r4d movd m6, r5d punpckldq m5, m5 ; mm5 = {A,B,A,B} punpckldq m6, m6 ; mm6 = {C,D,C,D} pxor m7, m7 pshufw m2, [r1], 0x94 ; mm0 = src[0,1,1,2] .nextrow: add r1, r2 movq m1, m2 pmaddwd m1, m5 ; mm1 = A * src[0,1] + B * src[1,2] pshufw m0, [r1], 0x94 ; mm0 = src[0,1,1,2] movq m2, m0 pmaddwd m0, m6 paddw m1, [pw_32] paddw m1, m0 ; mm1 += C * src[0,1] + D * src[1,2] psrlw m1, 6 packssdw m1, m7 CHROMAMC_AVG m1, m3, [r0] movd [r0], m1 add r0, r2 dec r3d jnz .nextrow REP_RET %endmacro %macro NOTHING 2-3 %endmacro %macro AVG 2-3 %if %0==3 movq %2, %3 %endif pavgw %1, %2 %endmacro %define CHROMAMC_AVG NOTHING INIT_XMM sse2 CHROMA_MC8 put INIT_XMM avx CHROMA_MC8 put INIT_MMX mmxext CHROMA_MC4 put CHROMA_MC2 put %define CHROMAMC_AVG AVG INIT_XMM sse2 CHROMA_MC8 avg INIT_XMM avx CHROMA_MC8 avg INIT_MMX mmxext CHROMA_MC4 avg CHROMA_MC2 avg
.data message : .asciiz"FIM" space : .asciiz", " .text main: addi $t0,$zero,10 while: bltz $t0,exit jal printNumber add $t0,$t0,-1 j while exit: li $v0, 4 la $a0, message syscall #fim do programa li $v0, 10 syscall printNumber: li $v0, 1 add $a0, $t0, $zero syscall li $v0, 4 la $a0, space syscall jr $ra
; A061866: a(n) is the number of solutions to x+y+z = 0 mod 3, where 1 <= x < y < z <= n. ; 0,0,0,1,2,4,8,13,20,30,42,57,76,98,124,155,190,230,276,327,384,448,518,595,680,772,872,981,1098,1224,1360,1505,1660,1826,2002,2189,2388,2598,2820,3055,3302,3562,3836,4123,4424,4740,5070,5415,5776,6152,6544,6953,7378,7820 mov $1,$0 bin $0,3 div $1,3 mul $1,2 add $1,$0 mov $0,$1 div $0,3
include "../constants.asm" org #0000 skybox: db 0 texture_set: db 1 floortypeandcolor: ; db 0 db #60 ceilingtypeandcolor: ; db 0 db #d0 map: db 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7 db 4,0,7,7,7,7,7,7,7,7,7,7,7,7,7,7 db 7,0,7,7,7,7,0,0,0,0,0,7,7,7,7,7 db 128+8,0,128+8,1,128+8,7,0,128+8,0,128+8,0,7,7,7,7,7 db 7,0,7,128+8,7,7,0,0,0,0,0,7,0,7,7,7 db 128+8,0,128+8,0,128+8,7,7,3,7,7,7,7,0,7,7,7 db 7,0,7,0,7,7,7,0,7,7,7,7,0,7,7,7 db 128+8,0,128+8,0,128+8,7,7,0,0,0,0,0,0,7,7,7 db 7,0,7,0,7,7,7,7,0,7,7,7,3,7,7,7 db 7,0,0,0,0,0,0,0,0,3,3,0,0,0,0,5 db 7,7,7,7,7,1,7,7,1,7,7,7,7,7,7,7 db 7,0,0,0,0,0,7,0,0,0,7,7,7,7,7,7 db 7,0,0,0,0,0,7,0,0,0,7,7,7,7,7,7 db 7,0,0,0,0,0,7,7,0,7,7,7,7,7,7,7 db 7,0,0,0,0,0,7,7,0,0,0,7,7,7,7,7 db 7,7,7,7,7,7,7,7,128+8,7,7,7,7,7,7,7 pickups: db 3 ; item type, x, y, sprite db ITEM_KEY , 3*16+8,5*16+8,SPRITE_PATTERN_KEY db ITEM_KEY ,12*16+8,4*16+8,SPRITE_PATTERN_KEY db ITEM_ARROW , 8*16+8,2*16+8,SPRITE_PATTERN_CHEST enemies: db 12 ; enemy type, x, y, sprite, color, hit points, state1, state2, state3 db ENEMY_SNAKE , 1*16+4, 7*16+8, ENEMY_SNAKE_SPRITE_PATTERN, 10, 2,0,0,0 db ENEMY_SNAKE , 8*16+4,13*16+8, ENEMY_SNAKE_SPRITE_PATTERN, 10, 2,0,0,0 db ENEMY_SKELETON , 3*16+4,13*16+8, ENEMY_SKELETON_SPRITE_PATTERN, 14, 2,0,0,0 db ENEMY_SKELETON , 5*16+4,13*16+8, ENEMY_SKELETON_SPRITE_PATTERN, 14, 2,0,0,0 db ENEMY_SKELETON , 1*16+4,14*16+8, ENEMY_SKELETON_SPRITE_PATTERN, 14, 2,0,0,0 db ENEMY_SKELETON , 6*16+4, 4*16+8, ENEMY_SKELETON_SPRITE_PATTERN, 14, 2,0,0,0 db ENEMY_SKELETON ,10*16+4, 4*16+8, ENEMY_SKELETON_SPRITE_PATTERN, 14, 2,0,0,0 db ENEMY_RAT_H , 7*16+8, 7*16+8, ENEMY_RAT_SPRITE_PATTERN, 13, 1,0,0,0 ; for switches, state1 is the initial state, state2 is the event triggered, state3 is the parameter of the event db ENEMY_SWITCH , 1*16+8,14*16+8, ENEMY_SWITCH_RIGHT_SPRITE_PATTERN, 15, 1,SWITCH_STATE_RIGHT,EVENT_OPEN_GATE,7+5*16 db ENEMY_SWITCH ,10*16+8,14*16+8, ENEMY_SWITCH_RIGHT_SPRITE_PATTERN, 15, 1,SWITCH_STATE_RIGHT,EVENT_OPEN_GATE,9+9*16 db ENEMY_SWITCH ,10*16+8, 2*16+8, ENEMY_SWITCH_RIGHT_SPRITE_PATTERN, 15, 1,SWITCH_STATE_RIGHT,EVENT_OPEN_GATE,10+9*16 db ENEMY_SWITCH ,12*16+8, 9*16+8, ENEMY_SWITCH_RIGHT_SPRITE_PATTERN, 15, 1,SWITCH_STATE_RIGHT,EVENT_OPEN_GATE,12+8*16 events_map: db 3 ; x, y, event ID (the first 4 IDs are reserved for 4 potential messages below (each of them ; 4 lines of 22 characters each)) db #10,#20,0 db #30,#50,1 db #80,#E0,2 messages_map: dw 22*12 ;; length of the message data block below db "OH GODS OF OLYMPUS! " db "THIS PLACE IS FULL OF " db "TRAPPED SOULS. THIS IS" db "A TORTURE CHAMBER! " db " A PRISONER SAYS: " db "POPOLON! IT IS YOU!! " db "SAVE US! THE KERES DID" db "THIS!! " db " A PRISONER SAYS: " db "THE KERES ARE SPIRITS " db "OF DEATH! THEY DESPISE" db "THANATOS! "
// 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. #include "olap/rowset/segment_v2/bitmap_index_reader.h" #include "olap/rowset/segment_v2/bitmap_index_writer.h" #include "olap/key_coder.h" #include <gtest/gtest.h> #include <string> #include "common/logging.h" #include "env/env.h" #include "olap/fs/block_manager.h" #include "olap/fs/fs_util.h" #include "olap/olap_common.h" #include "olap/types.h" #include "runtime/mem_tracker.h" #include "runtime/mem_pool.h" #include "util/file_utils.h" namespace doris { namespace segment_v2 { class BitmapIndexTest : public testing::Test { public: const std::string kTestDir = "./ut_dir/bitmap_index_test"; BitmapIndexTest() : _tracker(new MemTracker()), _pool(_tracker.get()) {} void SetUp() override { if (FileUtils::check_exist(kTestDir)) { ASSERT_TRUE(FileUtils::remove_all(kTestDir).ok()); } ASSERT_TRUE(FileUtils::create_dir(kTestDir).ok()); } void TearDown() override { if (FileUtils::check_exist(kTestDir)) { ASSERT_TRUE(FileUtils::remove_all(kTestDir).ok()); } } private: std::shared_ptr<MemTracker> _tracker; MemPool _pool; }; template<FieldType type> void write_index_file(std::string& filename, const void* values, size_t value_count, size_t null_count, ColumnIndexMetaPB* meta) { const TypeInfo* type_info = get_type_info(type); { std::unique_ptr<fs::WritableBlock> wblock; fs::CreateBlockOptions opts({ filename }); ASSERT_TRUE(fs::fs_util::block_mgr_for_ut()->create_block(opts, &wblock).ok()); std::unique_ptr<BitmapIndexWriter> writer; BitmapIndexWriter::create(type_info, &writer); writer->add_values(values, value_count); writer->add_nulls(null_count); ASSERT_TRUE(writer->finish(wblock.get(), meta).ok()); ASSERT_EQ(BITMAP_INDEX, meta->type()); ASSERT_TRUE(wblock->close().ok()); } } template<FieldType type> void get_bitmap_reader_iter(std::string& file_name, const ColumnIndexMetaPB& meta, BitmapIndexReader** reader, BitmapIndexIterator** iter) { *reader = new BitmapIndexReader(file_name, &meta.bitmap_index()); auto st = (*reader)->load(true, false); ASSERT_TRUE(st.ok()); st = (*reader)->new_iterator(iter); ASSERT_TRUE(st.ok()); } TEST_F(BitmapIndexTest, test_invert) { size_t num_uint8_rows = 1024 * 10; int* val = new int[num_uint8_rows]; for (int i = 0; i < num_uint8_rows; ++i) { val[i] = i; } std::string file_name = kTestDir + "/invert"; ColumnIndexMetaPB meta; write_index_file<OLAP_FIELD_TYPE_INT>(file_name, val, num_uint8_rows, 0, &meta); { std::unique_ptr<RandomAccessFile> rfile; BitmapIndexReader* reader = nullptr; BitmapIndexIterator* iter = nullptr; get_bitmap_reader_iter<OLAP_FIELD_TYPE_INT>(file_name, meta, &reader, &iter); int value = 2; bool exact_match; Status st = iter->seek_dictionary(&value, &exact_match); ASSERT_TRUE(st.ok()); ASSERT_TRUE(exact_match); ASSERT_EQ(2, iter->current_ordinal()); Roaring bitmap; iter->read_bitmap(iter->current_ordinal(), &bitmap); ASSERT_TRUE(Roaring::bitmapOf(1, 2) == bitmap); int value2 = 1024 * 9; st = iter->seek_dictionary(&value2, &exact_match); ASSERT_TRUE(st.ok()); ASSERT_TRUE(exact_match); ASSERT_EQ(1024 * 9, iter->current_ordinal()); iter->read_union_bitmap(iter->current_ordinal(), iter->bitmap_nums(), &bitmap); ASSERT_EQ(1025, bitmap.cardinality()); int value3 = 1024; iter->seek_dictionary(&value3, &exact_match); ASSERT_EQ(1024, iter->current_ordinal()); Roaring bitmap2; iter->read_union_bitmap(0, iter->current_ordinal(), &bitmap2); ASSERT_EQ(1024, bitmap2.cardinality()); delete reader; delete iter; } delete[] val; } TEST_F(BitmapIndexTest, test_invert_2) { size_t num_uint8_rows = 1024 * 10; int* val = new int[num_uint8_rows]; for (int i = 0; i < 1024; ++i) { val[i] = i; } for (int i = 1024; i < num_uint8_rows; ++i) { val[i] = i * 10; } std::string file_name = kTestDir + "/invert2"; ColumnIndexMetaPB meta; write_index_file<OLAP_FIELD_TYPE_INT>(file_name, val, num_uint8_rows, 0, &meta); { BitmapIndexReader* reader = nullptr; BitmapIndexIterator* iter = nullptr; get_bitmap_reader_iter<OLAP_FIELD_TYPE_INT>(file_name, meta, &reader, &iter); int value = 1026; bool exact_match; auto st = iter->seek_dictionary(&value, &exact_match); ASSERT_TRUE(st.ok()); ASSERT_TRUE(!exact_match); ASSERT_EQ(1024, iter->current_ordinal()); Roaring bitmap; iter->read_union_bitmap(0, iter->current_ordinal(), &bitmap); ASSERT_EQ(1024, bitmap.cardinality()); delete reader; delete iter; } delete[] val; } TEST_F(BitmapIndexTest, test_multi_pages) { size_t num_uint8_rows = 1024 * 1024; int64_t* val = new int64_t[num_uint8_rows]; for (int i = 0; i < num_uint8_rows; ++i) { val[i] = random() + 10000; } val[1024 * 510] = 2019; std::string file_name = kTestDir + "/mul"; ColumnIndexMetaPB meta; write_index_file<OLAP_FIELD_TYPE_BIGINT>(file_name, val, num_uint8_rows, 0, &meta); { BitmapIndexReader* reader = nullptr; BitmapIndexIterator* iter = nullptr; get_bitmap_reader_iter<OLAP_FIELD_TYPE_BIGINT>(file_name, meta, &reader, &iter); int64_t value = 2019; bool exact_match; auto st = iter->seek_dictionary(&value, &exact_match); ASSERT_TRUE(st.ok()) << "status:" << st.to_string(); ASSERT_EQ(0, iter->current_ordinal()); Roaring bitmap; iter->read_bitmap(iter->current_ordinal(), &bitmap); ASSERT_EQ(1,bitmap.cardinality()); delete reader; delete iter; } delete[] val; } TEST_F(BitmapIndexTest, test_null) { size_t num_uint8_rows = 1024; int64_t* val = new int64_t[num_uint8_rows]; for (int i = 0; i < num_uint8_rows; ++i) { val[i] = i; } std::string file_name = kTestDir + "/null"; ColumnIndexMetaPB meta; write_index_file<OLAP_FIELD_TYPE_BIGINT>(file_name, val, num_uint8_rows, 30, &meta); { BitmapIndexReader* reader = nullptr; BitmapIndexIterator* iter = nullptr; get_bitmap_reader_iter<OLAP_FIELD_TYPE_BIGINT>(file_name, meta, &reader, &iter); Roaring bitmap; iter->read_null_bitmap(&bitmap); ASSERT_EQ(30,bitmap.cardinality()); delete reader; delete iter; } delete[] val; } } } int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); }
; ; ; Z88 Maths Routines ; ; C Interface for Small C+ Compiler ; ; 7/12/98 djm ;Convert from integer to FP.. ;We could enter in here with a long in dehl, so, mod to compiler I think! SECTION code_fp INCLUDE "target/z88/def/fpp.def" PUBLIC ufloat EXTERN fa .ufloat push de ;msb exx pop hl ld c,0 ;no exponent ld a,h push af res 7,h fpp(FP_FLT) pop af rlca jr nc,ufloat_out ;no high bit ;to multiply by two, increment the exponent inc c .ufloat_out ld (fa+3),hl ld a,c ld (fa+5),a exx ld (fa+1),hl xor a ld (fa),a ret
; A291008: p-INVERT of (1,1,1,1,1,...), where p(S) = 1 - 7*S^2. ; 0,7,14,70,224,868,3080,11368,41216,150640,548576,2000992,7293440,26592832,96946304,353449600,1288577024,4697851648,17127165440,62441440768,227645874176,829940392960,3025756030976,11031154419712,40216845025280,146620616568832,534542303289344,1948808305991680,7104870431719424,25902590699388928,94434403989094400,344284352174522368,1255175128283611136,4576056369614356480,16683163508930379776,60822665235546898432,221744311524676075520,808424614462633541632,2947315098073323536384,10745177882922448322560,39174246354284837863424,142819560006104365662208,520684598137917758504960,1898286556312461710983168,6920680701452429972996096,25231080740779630211891200,91986245690273840261758976,335358975825225461794865152,1222635425792093965160284160,4457424706535540701089759232,16250661967823645193141223424,59245872174860534592821002240,215995716156662940344489345024,787466665362489088245904703488,2870907627664955818558745477120,10466615247504846166592919175168,38158676260999427244538311213056,139117044007027931488634137477120,507186145580052426444498142232576,1849074555202272441820801109327872,6741265983884859442308591072051200,24576979298983353535541988800069632,89601554501275863724935524032446464,326664984796451848663122980865310720 add $0,1 mov $4,2 lpb $0 sub $0,1 mov $3,$1 mov $1,$2 mul $1,3 add $4,$3 mul $4,2 mov $2,$4 lpe div $1,12 mul $1,7 mov $0,$1
; AMD64 mpn_addsub_n ; ; Copyright 2017 Jens Nurmann ; ; This file is part of the MPIR Library. ; The MPIR 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. ; The MPIR 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 the MPIR Library; see the file COPYING.LIB. If not, write ; to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, ; Boston, MA 02110-1301, USA. ; (rdi,r8) = (rsi,r8)+(rdx,r8)-(rcx,r8) ; rax = summed carry and borrow in range [ -1..1 ] ; the main loop has been enhanced with the MPIR SuperOptimizer ; the gain was roughly 4% execution speed for operands in LD1$ ; ; mp_limb_t mpn_addsub_n(mp_ptr, mp_ptr, mp_ptr, mp_ptr, mp_size_t) ; rax rdi rsi rdx rcx r8 ; rax rcx rdx r8 r9 [rsp+40] ; cycles per limb with all operands in: ; LD1$ LD2$ ; Haswell ??? ??? ; Broadwell ??? ??? ; Skylake 1.6-1.7 1.7-1.85 %include 'yasm_mac.inc' %define reg_save_list rsi, rdi, r12 ; definition according to Linux 64 bit ABI %define ResP rdi %define Src1P rsi %define Src2P rdx %define Src3P rcx %define Size r8 %define Spills eax %define Carry al %define Borrow ah %define Limb0 r9 %define Limb1 r10 %define Limb2 r11 %define Limb3 r12 align 32 BITS 64 FRAME_PROC mpn_addsub_n, 0, reg_save_list mov rdi, rcx mov rsi, rdx mov rdx, r8 mov rcx, r9 mov r8, [rsp+stack_use+40] sub Src3P, 32 sub ResP, 32 xor Spills, Spills ; clears carry & borrow jmp .Check align 16 .Loop: ; do not delete! ; this seemingly unreasoned AVX instruction optimizes the allocation of ; read/write operations to ports 2, 3 & 7 (write allways ending up ; on port 7) which allows a sustained 2r1w execution per cycle vpor ymm0, ymm0, ymm0 shr Carry, 1 mov Limb0, [Src1P] mov Limb1, [Src1P+8] mov Limb2, [Src1P+16] mov Limb3, [Src1P+24] lea Src3P, [Src3P+32] lea ResP, [ResP+32] adc Limb0, [Src2P] adc Limb1, [Src2P+8] adc Limb2, [Src2P+16] adc Limb3, [Src2P+24] setc Carry lea Src2P, [Src2P+32] shr Borrow, 1 sbb Limb0, [Src3P] sbb Limb1, [Src3P+8] lea Src1P, [Src1P+32] mov [ResP], Limb0 sbb Limb2, [Src3P+16] mov [ResP+8], Limb1 mov [ResP+16], Limb2 sbb Limb3, [Src3P+24] setc Borrow mov [ResP+24], Limb3 ; label @ $a (mod $10) seems ok from benchmark figures .Check: sub Size, 4 jnc .Loop add Src3P, 32 add ResP, 32 add Size, 4 je .Exit shr Carry, 1 mov Limb0, [Src1P] adc Limb0, [Src2P] setc Carry shr Borrow, 1 sbb Limb0, [Src3P] setc Borrow mov [ResP], Limb0 dec Size je .Exit shr Carry, 1 mov Limb0, [Src1P+8] adc Limb0, [Src2P+8] setc Carry shr Borrow, 1 sbb Limb0, [Src3P+8] setc Borrow mov [ResP+8], Limb0 dec Size je .Exit shr Carry, 1 mov Limb0, [Src1P+16] adc Limb0, [Src2P+16] setc Carry shr Borrow, 1 sbb Limb0, [Src3P+16] mov [ResP+16], Limb0 setc Borrow ; label @ $2 (mod $10) ok from benchmark figures .Exit: sub Carry, Borrow movsx rax, Carry END_PROC reg_save_list
; ; Z88 Graphics Functions - Small C+ stubs ; ; Written around the Interlogic Standard Library ; ; Stubs Written by D Morris - 30/9/98 ; ; ; $Id: w_point_callee.asm $ ; ; CALLER LINKAGE FOR FUNCTION POINTERS ; ----- void point(int x, int y) ;Result is true/false SECTION code_graphics PUBLIC point_callee PUBLIC _point_callee PUBLIC ASMDISP_POINT_CALLEE EXTERN swapgfxbk EXTERN swapgfxbk1 EXTERN w_pointxy .point_callee ._point_callee pop af pop de ; y pop hl ; x push af .asmentry push ix call swapgfxbk call w_pointxy push af call swapgfxbk1 pop af pop ix ld hl,1 ret nz ;pixel set dec hl ret DEFC ASMDISP_POINT_CALLEE = asmentry - point_callee
name a_filexx___ EXTERN ___interrupt_tab_0x2C PUBLIC ___interrupt_0x2C PUBLIC _r_tau0_channel0_interrupt PUBLIC _vtest_function SECTION `.text`:CODE:ROOT(0) _r_tau0_channel0_interrupt: ___interrupt_0x2C: reti REQUIRE ___interrupt_tab_0x2C ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; asm function ;;;;;;;;;;;;;;;; RSEG CODE:CODE _vtest_function: ret end
//===--- NameLookup.cpp - Swift Name Lookup Routines ----------------------===// // // This source file is part of the Swift.org open source project // // Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors // Licensed under Apache License v2.0 with Runtime Library Exception // // See https://swift.org/LICENSE.txt for license information // See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors // //===----------------------------------------------------------------------===// // // This file implements interfaces for performing name lookup. // //===----------------------------------------------------------------------===// #include "swift/AST/NameLookup.h" #include "swift/AST/ASTContext.h" #include "swift/AST/ASTVisitor.h" #include "swift/AST/ClangModuleLoader.h" #include "swift/AST/DebuggerClient.h" #include "swift/AST/ExistentialLayout.h" #include "swift/AST/LazyResolver.h" #include "swift/AST/Initializer.h" #include "swift/AST/NameLookupRequests.h" #include "swift/AST/ParameterList.h" #include "swift/AST/ReferencedNameTracker.h" #include "swift/Basic/SourceManager.h" #include "swift/Basic/Statistic.h" #include "swift/Basic/STLExtras.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/TinyPtrVector.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" #define DEBUG_TYPE "namelookup" using namespace swift; using namespace swift::namelookup; void VisibleDeclConsumer::anchor() {} void VectorDeclConsumer::anchor() {} void NamedDeclConsumer::anchor() {} ValueDecl *LookupResultEntry::getBaseDecl() const { if (BaseDC == nullptr) return nullptr; if (auto *AFD = dyn_cast<AbstractFunctionDecl>(BaseDC)) return AFD->getImplicitSelfDecl(); if (auto *PBI = dyn_cast<PatternBindingInitializer>(BaseDC)) { auto *selfDecl = PBI->getImplicitSelfDecl(); assert(selfDecl); return selfDecl; } auto *nominalDecl = BaseDC->getSelfNominalTypeDecl(); assert(nominalDecl); return nominalDecl; } void DebuggerClient::anchor() {} void AccessFilteringDeclConsumer::foundDecl( ValueDecl *D, DeclVisibilityKind reason, DynamicLookupInfo dynamicLookupInfo) { if (D->isInvalid()) return; if (!D->isAccessibleFrom(DC)) return; ChainedConsumer.foundDecl(D, reason, dynamicLookupInfo); } void LookupResultEntry::print(llvm::raw_ostream& out) const { getValueDecl()->print(out); if (auto dc = getBaseDecl()) { out << "\nbase: "; dc->print(out); out << "\n"; } else out << "\n(no-base)\n"; } bool swift::removeOverriddenDecls(SmallVectorImpl<ValueDecl*> &decls) { if (decls.size() < 2) return false; llvm::SmallPtrSet<ValueDecl*, 8> overridden; for (auto decl : decls) { // Don't look at the overrides of operators in protocols. The global // lookup of operators means that we can find overriding operators that // aren't relevant to the types in hand, and will fail to type check. if (isa<ProtocolDecl>(decl->getDeclContext())) { if (auto func = dyn_cast<FuncDecl>(decl)) if (func->isOperator()) continue; } while (auto overrides = decl->getOverriddenDecl()) { overridden.insert(overrides); // Because initializers from Objective-C base classes have greater // visibility than initializers written in Swift classes, we can // have a "break" in the set of declarations we found, where // C.init overrides B.init overrides A.init, but only C.init and // A.init are in the chain. Make sure we still remove A.init from the // set in this case. if (decl->getFullName().getBaseName() == DeclBaseName::createConstructor()) { /// FIXME: Avoid the possibility of an infinite loop by fixing the root /// cause instead (incomplete circularity detection). assert(decl != overrides && "Circular class inheritance?"); decl = overrides; continue; } break; } } // If no methods were overridden, we're done. if (overridden.empty()) return false; // Erase any overridden declarations bool anyOverridden = false; decls.erase(std::remove_if(decls.begin(), decls.end(), [&](ValueDecl *decl) -> bool { if (overridden.count(decl) > 0) { anyOverridden = true; return true; } return false; }), decls.end()); return anyOverridden; } enum class ConstructorComparison { Worse, Same, Better, }; /// Determines whether \p ctor1 is a "better" initializer than \p ctor2. static ConstructorComparison compareConstructors(ConstructorDecl *ctor1, ConstructorDecl *ctor2, const swift::ASTContext &ctx) { bool available1 = !ctor1->getAttrs().isUnavailable(ctx); bool available2 = !ctor2->getAttrs().isUnavailable(ctx); // An unavailable initializer is always worse than an available initializer. if (available1 < available2) return ConstructorComparison::Worse; if (available1 > available2) return ConstructorComparison::Better; CtorInitializerKind kind1 = ctor1->getInitKind(); CtorInitializerKind kind2 = ctor2->getInitKind(); if (kind1 > kind2) return ConstructorComparison::Worse; if (kind1 < kind2) return ConstructorComparison::Better; return ConstructorComparison::Same; } /// Given a set of declarations whose names and signatures have matched, /// figure out which of these declarations have been shadowed by others. static void recordShadowedDeclsAfterSignatureMatch( ArrayRef<ValueDecl *> decls, const ModuleDecl *curModule, llvm::SmallPtrSetImpl<ValueDecl *> &shadowed) { assert(decls.size() > 1 && "Nothing collided"); // Compare each declaration to every other declaration. This is // unavoidably O(n^2) in the number of declarations, but because they // all have the same signature, we expect n to remain small. ASTContext &ctx = curModule->getASTContext(); for (unsigned firstIdx : indices(decls)) { auto firstDecl = decls[firstIdx]; auto firstModule = firstDecl->getModuleContext(); auto firstSig = firstDecl->getOverloadSignature(); for (unsigned secondIdx : range(firstIdx + 1, decls.size())) { // Determine whether one module takes precedence over another. auto secondDecl = decls[secondIdx]; auto secondModule = secondDecl->getModuleContext(); // Swift 4 compatibility hack: Don't shadow properties defined in // extensions of generic types with properties defined elsewhere. // This is due to the fact that in Swift 4, we only gave custom overload // types to properties in extensions of generic types, otherwise we // used the null type. if (!ctx.isSwiftVersionAtLeast(5)) { auto secondSig = secondDecl->getOverloadSignature(); if (firstSig.IsVariable && secondSig.IsVariable) if (firstSig.InExtensionOfGenericType != secondSig.InExtensionOfGenericType) continue; } // If one declaration is in a protocol or extension thereof and the // other is not, prefer the one that is not. if ((bool)firstDecl->getDeclContext()->getSelfProtocolDecl() != (bool)secondDecl->getDeclContext()->getSelfProtocolDecl()) { if (firstDecl->getDeclContext()->getSelfProtocolDecl()) { shadowed.insert(firstDecl); break; } else { shadowed.insert(secondDecl); continue; } } // If one declaration is available and the other is not, prefer the // available one. if (firstDecl->getAttrs().isUnavailable(ctx) != secondDecl->getAttrs().isUnavailable(ctx)) { if (firstDecl->getAttrs().isUnavailable(ctx)) { shadowed.insert(firstDecl); break; } else { shadowed.insert(secondDecl); continue; } } // Don't apply module-shadowing rules to members of protocol types. if (isa<ProtocolDecl>(firstDecl->getDeclContext()) || isa<ProtocolDecl>(secondDecl->getDeclContext())) continue; // Prefer declarations in the current module over those in another // module. // FIXME: This is a hack. We should query a (lazily-built, cached) // module graph to determine shadowing. if ((firstModule == curModule) != (secondModule == curModule)) { // If the first module is the current module, the second declaration // is shadowed by the first. if (firstModule == curModule) { shadowed.insert(secondDecl); continue; } // Otherwise, the first declaration is shadowed by the second. There is // no point in continuing to compare the first declaration to others. shadowed.insert(firstDecl); break; } // Prefer declarations in the any module over those in the standard // library module. if (auto swiftModule = ctx.getStdlibModule()) { if ((firstModule == swiftModule) != (secondModule == swiftModule)) { // If the second module is the standard library module, the second // declaration is shadowed by the first. if (secondModule == swiftModule) { shadowed.insert(secondDecl); continue; } // Otherwise, the first declaration is shadowed by the second. There is // no point in continuing to compare the first declaration to others. shadowed.insert(firstDecl); break; } } // The Foundation overlay introduced Data.withUnsafeBytes, which is // treated as being ambiguous with SwiftNIO's Data.withUnsafeBytes // extension. Apply a special-case name shadowing rule to use the // latter rather than the former, which be the consequence of a more // significant change to name shadowing in the future. if (auto owningStruct1 = firstDecl->getDeclContext()->getSelfStructDecl()) { if (auto owningStruct2 = secondDecl->getDeclContext()->getSelfStructDecl()) { if (owningStruct1 == owningStruct2 && owningStruct1->getName().is("Data") && isa<FuncDecl>(firstDecl) && isa<FuncDecl>(secondDecl) && firstDecl->getFullName() == secondDecl->getFullName() && firstDecl->getBaseName().userFacingName() == "withUnsafeBytes") { // If the second module is the Foundation module and the first // is the NIOFoundationCompat module, the second is shadowed by the // first. if (firstDecl->getModuleContext()->getName() .is("NIOFoundationCompat") && secondDecl->getModuleContext()->getName().is("Foundation")) { shadowed.insert(secondDecl); continue; } // If it's the other way around, the first declaration is shadowed // by the second. if (secondDecl->getModuleContext()->getName() .is("NIOFoundationCompat") && firstDecl->getModuleContext()->getName().is("Foundation")) { shadowed.insert(firstDecl); break; } } } } // Prefer declarations in an overlay to similar declarations in // the Clang module it customizes. if (firstDecl->hasClangNode() != secondDecl->hasClangNode()) { auto clangLoader = ctx.getClangModuleLoader(); if (!clangLoader) continue; if (clangLoader->isInOverlayModuleForImportedModule( firstDecl->getDeclContext(), secondDecl->getDeclContext())) { shadowed.insert(secondDecl); continue; } if (clangLoader->isInOverlayModuleForImportedModule( secondDecl->getDeclContext(), firstDecl->getDeclContext())) { shadowed.insert(firstDecl); break; } } } } } /// Look through the given set of declarations (that all have the same name), /// recording those that are shadowed by another declaration in the /// \c shadowed set. static void recordShadowedDeclsForImportedInits( ArrayRef<ConstructorDecl *> ctors, llvm::SmallPtrSetImpl<ValueDecl *> &shadowed) { assert(ctors.size() > 1 && "No collisions"); ASTContext &ctx = ctors.front()->getASTContext(); // Find the "best" constructor with this signature. ConstructorDecl *bestCtor = ctors[0]; for (auto ctor : ctors.slice(1)) { auto comparison = compareConstructors(ctor, bestCtor, ctx); if (comparison == ConstructorComparison::Better) bestCtor = ctor; } // Shadow any initializers that are worse. for (auto ctor : ctors) { auto comparison = compareConstructors(ctor, bestCtor, ctx); if (comparison == ConstructorComparison::Worse) shadowed.insert(ctor); } } /// Look through the given set of declarations (that all have the same name), /// recording those that are shadowed by another declaration in the /// \c shadowed set. static void recordShadowedDecls(ArrayRef<ValueDecl *> decls, const ModuleDecl *curModule, llvm::SmallPtrSetImpl<ValueDecl *> &shadowed) { if (decls.size() < 2) return; auto typeResolver = decls[0]->getASTContext().getLazyResolver(); // Categorize all of the declarations based on their overload signatures. llvm::SmallDenseMap<CanType, llvm::TinyPtrVector<ValueDecl *>> collisions; llvm::SmallVector<CanType, 2> collisionTypes; llvm::SmallDenseMap<NominalTypeDecl *, llvm::TinyPtrVector<ConstructorDecl *>> importedInitializerCollisions; llvm::TinyPtrVector<NominalTypeDecl *> importedInitializerCollectionTypes; for (auto decl : decls) { // Specifically keep track of imported initializers, which can come from // Objective-C init methods, Objective-C factory methods, renamed C // functions, or be synthesized by the importer. if (decl->hasClangNode() || (isa<NominalTypeDecl>(decl->getDeclContext()) && cast<NominalTypeDecl>(decl->getDeclContext())->hasClangNode())) { if (auto ctor = dyn_cast<ConstructorDecl>(decl)) { auto nominal = ctor->getDeclContext()->getSelfNominalTypeDecl(); auto &knownInits = importedInitializerCollisions[nominal]; if (knownInits.size() == 1) { importedInitializerCollectionTypes.push_back(nominal); } knownInits.push_back(ctor); } } CanType signature; if (!isa<TypeDecl>(decl)) { // We need an interface type here. if (typeResolver) typeResolver->resolveDeclSignature(decl); // If the decl is currently being validated, this is likely a recursive // reference and we'll want to skip ahead so as to avoid having its type // attempt to desugar itself. if (!decl->hasValidSignature()) continue; // FIXME: the canonical type makes a poor signature, because we don't // canonicalize away default arguments. signature = decl->getInterfaceType()->getCanonicalType(); // FIXME: The type of a variable or subscript doesn't include // enough context to distinguish entities from different // constrained extensions, so use the overload signature's // type. This is layering a partial fix upon a total hack. if (auto asd = dyn_cast<AbstractStorageDecl>(decl)) signature = asd->getOverloadSignatureType(); } else if (decl->getDeclContext()->isTypeContext()) { // Do not apply shadowing rules for member types. continue; } // Record this declaration based on its signature. auto &known = collisions[signature]; if (known.size() == 1) { collisionTypes.push_back(signature); } known.push_back(decl); } // Check whether we have shadowing for signature collisions. for (auto signature : collisionTypes) { recordShadowedDeclsAfterSignatureMatch(collisions[signature], curModule, shadowed); } // Check whether we have shadowing for imported initializer collisions. for (auto nominal : importedInitializerCollectionTypes) { recordShadowedDeclsForImportedInits(importedInitializerCollisions[nominal], shadowed); } } bool swift::removeShadowedDecls(SmallVectorImpl<ValueDecl*> &decls, const ModuleDecl *curModule) { // Collect declarations with the same (full) name. llvm::SmallDenseMap<DeclName, llvm::TinyPtrVector<ValueDecl *>> collidingDeclGroups; bool anyCollisions = false; for (auto decl : decls) { // Record this declaration based on its full name. auto &knownDecls = collidingDeclGroups[decl->getFullName()]; if (!knownDecls.empty()) anyCollisions = true; knownDecls.push_back(decl); } // If nothing collided, we're done. if (!anyCollisions) return false; // Walk through the declarations again, marking any declarations that shadow. llvm::SmallPtrSet<ValueDecl *, 4> shadowed; for (auto decl : decls) { auto known = collidingDeclGroups.find(decl->getFullName()); if (known == collidingDeclGroups.end()) { // We already handled this group. continue; } recordShadowedDecls(known->second, curModule, shadowed); collidingDeclGroups.erase(known); } // If no declarations were shadowed, we're done. if (shadowed.empty()) return false; // Remove shadowed declarations from the list of declarations. bool anyRemoved = false; decls.erase(std::remove_if(decls.begin(), decls.end(), [&](ValueDecl *vd) { if (shadowed.count(vd) > 0) { anyRemoved = true; return true; } return false; }), decls.end()); return anyRemoved; } namespace { enum class DiscriminatorMatch { NoDiscriminator, Matches, Different }; } // end anonymous namespace static DiscriminatorMatch matchDiscriminator(Identifier discriminator, const ValueDecl *value) { if (value->getFormalAccess() > AccessLevel::FilePrivate) return DiscriminatorMatch::NoDiscriminator; auto containingFile = dyn_cast<FileUnit>(value->getDeclContext()->getModuleScopeContext()); if (!containingFile) return DiscriminatorMatch::Different; if (discriminator == containingFile->getDiscriminatorForPrivateValue(value)) return DiscriminatorMatch::Matches; return DiscriminatorMatch::Different; } static DiscriminatorMatch matchDiscriminator(Identifier discriminator, LookupResultEntry lookupResult) { return matchDiscriminator(discriminator, lookupResult.getValueDecl()); } template <typename Result> void namelookup::filterForDiscriminator(SmallVectorImpl<Result> &results, DebuggerClient *debugClient) { if (debugClient == nullptr) return; Identifier discriminator = debugClient->getPreferredPrivateDiscriminator(); if (discriminator.empty()) return; auto lastMatchIter = std::find_if(results.rbegin(), results.rend(), [discriminator](Result next) -> bool { return matchDiscriminator(discriminator, next) == DiscriminatorMatch::Matches; }); if (lastMatchIter == results.rend()) return; Result lastMatch = *lastMatchIter; auto newEnd = std::remove_if(results.begin(), lastMatchIter.base()-1, [discriminator](Result next) -> bool { return matchDiscriminator(discriminator, next) == DiscriminatorMatch::Different; }); results.erase(newEnd, results.end()); results.push_back(lastMatch); } template void namelookup::filterForDiscriminator<LookupResultEntry>( SmallVectorImpl<LookupResultEntry> &results, DebuggerClient *debugClient); void namelookup::recordLookupOfTopLevelName(DeclContext *topLevelContext, DeclName name, bool isCascading) { auto SF = dyn_cast<SourceFile>(topLevelContext); if (!SF) return; auto *nameTracker = SF->getReferencedNameTracker(); if (!nameTracker) return; nameTracker->addTopLevelName(name.getBaseName(), isCascading); } /// Retrieve the set of type declarations that are directly referenced from /// the given parsed type representation. static DirectlyReferencedTypeDecls directReferencesForTypeRepr(Evaluator &evaluator, ASTContext &ctx, TypeRepr *typeRepr, DeclContext *dc); /// Retrieve the set of type declarations that are directly referenced from /// the given type. static DirectlyReferencedTypeDecls directReferencesForType(Type type); /// Given a set of type declarations, find all of the nominal type declarations /// that they reference, looking through typealiases as appropriate. static TinyPtrVector<NominalTypeDecl *> resolveTypeDeclsToNominal(Evaluator &evaluator, ASTContext &ctx, ArrayRef<TypeDecl *> typeDecls, SmallVectorImpl<ModuleDecl *> &modulesFound, bool &anyObject); SelfBounds SelfBoundsFromWhereClauseRequest::evaluate( Evaluator &evaluator, llvm::PointerUnion<TypeDecl *, ExtensionDecl *> decl) const { auto *typeDecl = decl.dyn_cast<TypeDecl *>(); auto *protoDecl = dyn_cast_or_null<ProtocolDecl>(typeDecl); auto *extDecl = decl.dyn_cast<ExtensionDecl *>(); DeclContext *dc = protoDecl ? (DeclContext *)protoDecl : (DeclContext *)extDecl; // A protocol or extension 'where' clause can reference associated types of // the protocol itself, so we have to start unqualified lookup from 'dc'. // // However, the right hand side of a 'Self' conformance constraint must be // resolved before unqualified lookup into 'dc' can work, so we make an // exception here and begin lookup from the parent context instead. auto *lookupDC = dc->getParent(); auto requirements = protoDecl ? protoDecl->getTrailingWhereClause() : extDecl->getTrailingWhereClause(); ASTContext &ctx = dc->getASTContext(); SelfBounds result; if (requirements == nullptr) return result; for (const auto &req : requirements->getRequirements()) { // We only care about type constraints. if (req.getKind() != RequirementReprKind::TypeConstraint) continue; // The left-hand side of the type constraint must be 'Self'. bool isSelfLHS = false; if (auto typeRepr = req.getSubjectRepr()) { if (auto identTypeRepr = dyn_cast<SimpleIdentTypeRepr>(typeRepr)) isSelfLHS = (identTypeRepr->getIdentifier() == ctx.Id_Self); } else if (Type type = req.getSubject()) { isSelfLHS = type->isEqual(dc->getSelfInterfaceType()); } if (!isSelfLHS) continue; // Resolve the right-hand side. DirectlyReferencedTypeDecls rhsDecls; if (auto typeRepr = req.getConstraintRepr()) { rhsDecls = directReferencesForTypeRepr(evaluator, ctx, typeRepr, lookupDC); } else if (Type type = req.getConstraint()) { rhsDecls = directReferencesForType(type); } SmallVector<ModuleDecl *, 2> modulesFound; auto rhsNominals = resolveTypeDeclsToNominal(evaluator, ctx, rhsDecls, modulesFound, result.anyObject); result.decls.insert(result.decls.end(), rhsNominals.begin(), rhsNominals.end()); } return result; } SelfBounds swift::getSelfBoundsFromWhereClause( llvm::PointerUnion<TypeDecl *, ExtensionDecl *> decl) { auto *typeDecl = decl.dyn_cast<TypeDecl *>(); auto *extDecl = decl.dyn_cast<ExtensionDecl *>(); auto &ctx = typeDecl ? typeDecl->getASTContext() : extDecl->getASTContext(); return evaluateOrDefault(ctx.evaluator, SelfBoundsFromWhereClauseRequest{decl}, {}); } TinyPtrVector<TypeDecl *> TypeDeclsFromWhereClauseRequest::evaluate(Evaluator &evaluator, ExtensionDecl *ext) const { ASTContext &ctx = ext->getASTContext(); TinyPtrVector<TypeDecl *> result; for (const auto &req : ext->getGenericParams()->getTrailingRequirements()) { auto resolve = [&](TypeLoc loc) { DirectlyReferencedTypeDecls decls; if (auto *typeRepr = loc.getTypeRepr()) decls = directReferencesForTypeRepr(evaluator, ctx, typeRepr, ext); else if (Type type = loc.getType()) decls = directReferencesForType(type); result.insert(result.end(), decls.begin(), decls.end()); }; switch (req.getKind()) { case RequirementReprKind::TypeConstraint: resolve(req.getSubjectLoc()); resolve(req.getConstraintLoc()); break; case RequirementReprKind::SameType: resolve(req.getFirstTypeLoc()); resolve(req.getSecondTypeLoc()); break; case RequirementReprKind::LayoutConstraint: resolve(req.getSubjectLoc()); break; } } return result; } #pragma mark Member lookup table void LazyMemberLoader::anchor() {} void LazyConformanceLoader::anchor() {} /// Lookup table used to store members of a nominal type (and its extensions) /// for fast retrieval. class swift::MemberLookupTable { /// The last extension that was included within the member lookup table's /// results. ExtensionDecl *LastExtensionIncluded = nullptr; /// The type of the internal lookup table. typedef llvm::DenseMap<DeclName, llvm::TinyPtrVector<ValueDecl *>> LookupTable; /// Lookup table mapping names to the set of declarations with that name. LookupTable Lookup; public: /// Create a new member lookup table. explicit MemberLookupTable(ASTContext &ctx); /// Update a lookup table with members from newly-added extensions. void updateLookupTable(NominalTypeDecl *nominal); /// Add the given member to the lookup table. void addMember(Decl *members); /// Add the given members to the lookup table. void addMembers(DeclRange members); /// Iterator into the lookup table. typedef LookupTable::iterator iterator; iterator begin() { return Lookup.begin(); } iterator end() { return Lookup.end(); } iterator find(DeclName name) { return Lookup.find(name); } void dump(llvm::raw_ostream &os) const { os << "LastExtensionIncluded:\n"; if (LastExtensionIncluded) LastExtensionIncluded->printContext(os, 2); else os << " nullptr\n"; os << "Lookup:\n "; for (auto &pair : Lookup) { pair.getFirst().print(os) << ":\n "; for (auto &decl : pair.getSecond()) { os << "- "; decl->dumpRef(os); os << "\n "; } } os << "\n"; } LLVM_ATTRIBUTE_DEPRECATED(void dump() const LLVM_ATTRIBUTE_USED, "only for use within the debugger") { dump(llvm::errs()); } // Mark all Decls in this table as not-resident in a table, drop // references to them. Should only be called when this was not fully-populated // from an IterableDeclContext. void clear() { // LastExtensionIncluded would only be non-null if this was populated from // an IterableDeclContext (though it might still be null in that case). assert(LastExtensionIncluded == nullptr); for (auto const &i : Lookup) { for (auto d : i.getSecond()) { d->setAlreadyInLookupTable(false); } } Lookup.clear(); } // Only allow allocation of member lookup tables using the allocator in // ASTContext or by doing a placement new. void *operator new(size_t Bytes, ASTContext &C, unsigned Alignment = alignof(MemberLookupTable)) { return C.Allocate(Bytes, Alignment); } void *operator new(size_t Bytes, void *Mem) { assert(Mem); return Mem; } }; namespace { /// Stores the set of Objective-C methods with a given selector within the /// Objective-C method lookup table. struct StoredObjCMethods { /// The generation count at which this list was last updated. unsigned Generation = 0; /// The set of methods with the given selector. llvm::TinyPtrVector<AbstractFunctionDecl *> Methods; }; } // end anonymous namespace /// Class member lookup table, which is a member lookup table with a second /// table for lookup based on Objective-C selector. class ClassDecl::ObjCMethodLookupTable : public llvm::DenseMap<std::pair<ObjCSelector, char>, StoredObjCMethods> { public: // Only allow allocation of member lookup tables using the allocator in // ASTContext or by doing a placement new. void *operator new(size_t Bytes, ASTContext &C, unsigned Alignment = alignof(MemberLookupTable)) { return C.Allocate(Bytes, Alignment); } void *operator new(size_t Bytes, void *Mem) { assert(Mem); return Mem; } }; MemberLookupTable::MemberLookupTable(ASTContext &ctx) { // Register a cleanup with the ASTContext to call the lookup table // destructor. ctx.addCleanup([this]() { this->~MemberLookupTable(); }); } void MemberLookupTable::addMember(Decl *member) { // Only value declarations matter. auto vd = dyn_cast<ValueDecl>(member); if (!vd) return; // @_implements members get added under their declared name. auto A = vd->getAttrs().getAttribute<ImplementsAttr>(); // Unnamed entities w/o @_implements synonyms cannot be found by name lookup. if (!A && !vd->hasName()) return; // If this declaration is already in the lookup table, don't add it // again. if (vd->isAlreadyInLookupTable()) { return; } vd->setAlreadyInLookupTable(); // Add this declaration to the lookup set under its compound name and simple // name. vd->getFullName().addToLookupTable(Lookup, vd); // And if given a synonym, under that name too. if (A) A->getMemberName().addToLookupTable(Lookup, vd); } void MemberLookupTable::addMembers(DeclRange members) { for (auto member : members) { addMember(member); } } void MemberLookupTable::updateLookupTable(NominalTypeDecl *nominal) { // If the last extension we included is the same as the last known extension, // we're already up-to-date. if (LastExtensionIncluded == nominal->LastExtension) return; // Add members from each of the extensions that we have not yet visited. for (auto next = LastExtensionIncluded ? LastExtensionIncluded->NextExtension.getPointer() : nominal->FirstExtension; next; (LastExtensionIncluded = next,next = next->NextExtension.getPointer())) { addMembers(next->getMembers()); } } void NominalTypeDecl::addedMember(Decl *member) { // Remember if we added a destructor. if (auto *CD = dyn_cast<ClassDecl>(this)) if (isa<DestructorDecl>(member)) CD->setHasDestructor(); // If we have a lookup table, add the new member to it. if (LookupTable.getPointer()) { LookupTable.getPointer()->addMember(member); } } void NominalTypeDecl::addedExtension(ExtensionDecl * ext) { if (hasLazyMembers()) setLookupTablePopulated(false); } void ExtensionDecl::addedMember(Decl *member) { if (NextExtension.getInt()) { auto nominal = getExtendedNominal(); if (!nominal) return; if (nominal->LookupTable.getPointer() && nominal->isLookupTablePopulated()) { // Make sure we have the complete list of extensions. // FIXME: This is completely unnecessary. We want to determine whether // our own extension has already been included in the lookup table. (void)nominal->getExtensions(); nominal->LookupTable.getPointer()->addMember(member); } } } // For lack of anywhere more sensible to put it, here's a diagram of the pieces // involved in finding members and extensions of a NominalTypeDecl. // // ┌────────────────────────────┬─┐ // │IterableDeclContext │ │ ┌─────────────────────────────┐ // │------------------- │ │ │┌───────────────┬┐ ▼ // │Decl *LastDecl ───────────┼─┼─────┘│Decl ││ ┌───────────────┬┐ // │Decl *FirstDecl ───────────┼─┼─────▶│---- ││ │Decl ││ // │ │ │ │Decl *NextDecl├┼─▶│---- ││ // │bool HasLazyMembers │ │ ├───────────────┘│ │Decl *NextDecl ││ // │IterableDeclContextKind Kind│ │ │ │ ├───────────────┘│ // │ │ │ │ValueDecl │ │ │ // ├────────────────────────────┘ │ │--------- │ │ValueDecl │ // │ │ │DeclName Name │ │--------- │ // │NominalTypeDecl │ └────────────────┘ │DeclName Name │ // │--------------- │ ▲ └────────────────┘ // │ExtensionDecl *FirstExtension─┼────────┐ │ ▲ // │ExtensionDecl *LastExtension ─┼───────┐│ │ └───┐ // │ │ ││ └──────────────────────┐│ // │MemberLookupTable *LookupTable├─┐ ││ ││ // │bool LookupTableComplete │ │ ││ ┌─────────────────┐ ││ // └──────────────────────────────┘ │ ││ │ExtensionDecl │ ││ // │ ││ │------------- │ ││ // ┌─────────────┘ │└────▶│ExtensionDecl │ ││ // │ │ │ *NextExtension ├──┐ ││ // ▼ │ └─────────────────┘ │ ││ // ┌─────────────────────────────────────┐│ ┌─────────────────┐ │ ││ // │MemberLookupTable ││ │ExtensionDecl │ │ ││ // │----------------- ││ │------------- │ │ ││ // │ExtensionDecl *LastExtensionIncluded ├┴─────▶│ExtensionDecl │◀─┘ ││ // │ │ │ *NextExtension │ ││ // │┌───────────────────────────────────┐│ └─────────────────┘ ││ // ││DenseMap<Declname, ...> LookupTable││ ││ // ││-----------------------------------││ ┌──────────────────────────┐ ││ // ││[NameA] TinyPtrVector<ValueDecl *> ││ │TinyPtrVector<ValueDecl *>│ ││ // ││[NameB] TinyPtrVector<ValueDecl *> ││ │--------------------------│ ││ // ││[NameC] TinyPtrVector<ValueDecl *>─┼┼─▶│[0] ValueDecl * ─────┼─┘│ // │└───────────────────────────────────┘│ │[1] ValueDecl * ─────┼──┘ // └─────────────────────────────────────┘ └──────────────────────────┘ // // The HasLazyMembers, Kind, and LookupTableComplete fields are packed into // PointerIntPairs so don't go grepping for them; but for purposes of // illustration they are effectively their own fields. // // MemberLookupTable is populated en-masse when the IterableDeclContext's // (IDC's) list of Decls is populated. But MemberLookupTable can also be // populated incrementally by one-name-at-a-time lookups by lookupDirect, in // which case those Decls are _not_ added to the IDC's list. They are cached in // the loader they come from, lifecycle-wise, and are added to the // MemberLookupTable to accelerate subsequent retrieval, but the IDC is not // considered populated until someone calls getMembers(). // // If the IDC list is later populated and/or an extension is added _after_ // MemberLookupTable is constructed (and possibly has entries in it), // MemberLookupTable is purged and reconstructed from IDC's list. // // In all lookup routines, the 'ignoreNewExtensions' flag means that // lookup should only use the set of extensions already observed. static bool populateLookupTableEntryFromLazyIDCLoader(ASTContext &ctx, MemberLookupTable &LookupTable, DeclName name, IterableDeclContext *IDC) { if (IDC->isLoadingLazyMembers()) { return false; } IDC->setLoadingLazyMembers(true); auto ci = ctx.getOrCreateLazyIterableContextData(IDC, /*lazyLoader=*/nullptr); if (auto res = ci->loader->loadNamedMembers(IDC, name.getBaseName(), ci->memberData)) { IDC->setLoadingLazyMembers(false); if (auto s = ctx.Stats) { ++s->getFrontendCounters().NamedLazyMemberLoadSuccessCount; } for (auto d : *res) { LookupTable.addMember(d); } return false; } else { IDC->setLoadingLazyMembers(false); if (auto s = ctx.Stats) { ++s->getFrontendCounters().NamedLazyMemberLoadFailureCount; } return true; } } static void populateLookupTableEntryFromCurrentMembersWithoutLoading( ASTContext &ctx, MemberLookupTable &LookupTable, DeclName name, IterableDeclContext *IDC) { for (auto m : IDC->getCurrentMembersWithoutLoading()) { if (auto v = dyn_cast<ValueDecl>(m)) { if (v->getFullName().matchesRef(name.getBaseName())) { LookupTable.addMember(m); } } } } static bool populateLookupTableEntryFromExtensions(ASTContext &ctx, MemberLookupTable &table, NominalTypeDecl *nominal, DeclName name, bool ignoreNewExtensions) { if (!ignoreNewExtensions) { for (auto e : nominal->getExtensions()) { if (e->wasDeserialized() || e->hasClangNode()) { if (populateLookupTableEntryFromLazyIDCLoader(ctx, table, name, e)) { return true; } } else { populateLookupTableEntryFromCurrentMembersWithoutLoading(ctx, table, name, e); } } } return false; } bool NominalTypeDecl::isLookupTablePopulated() const { return LookupTable.getInt(); } void NominalTypeDecl::setLookupTablePopulated(bool value) { LookupTable.setInt(value); } void NominalTypeDecl::prepareLookupTable(bool ignoreNewExtensions) { // If we haven't allocated the lookup table yet, do so now. if (!LookupTable.getPointer()) { auto &ctx = getASTContext(); LookupTable.setPointer(new (ctx) MemberLookupTable(ctx)); } if (hasLazyMembers()) { // Lazy members: if the table needs population, populate the table _only // from those members already in the IDC member list_ such as implicits or // globals-as-members, then update table entries from the extensions that // have the same names as any such initial-population members. if (!isLookupTablePopulated()) { setLookupTablePopulated(true); LookupTable.getPointer()->addMembers(getCurrentMembersWithoutLoading()); llvm::SetVector<DeclName> baseNamesPresent; for (auto entry : *LookupTable.getPointer()) { baseNamesPresent.insert(entry.getFirst().getBaseName()); } for (auto baseName : baseNamesPresent) { populateLookupTableEntryFromExtensions(getASTContext(), *LookupTable.getPointer(), this, baseName, ignoreNewExtensions); } } } else { // No lazy members: if the table needs population, populate the table // en-masse; and in either case update the extensions. if (!isLookupTablePopulated()) { setLookupTablePopulated(true); LookupTable.getPointer()->addMembers(getMembers()); } if (!ignoreNewExtensions) { LookupTable.getPointer()->updateLookupTable(this); } } } void NominalTypeDecl::makeMemberVisible(ValueDecl *member) { if (!LookupTable.getPointer()) { auto &ctx = getASTContext(); LookupTable.setPointer(new (ctx) MemberLookupTable(ctx)); } LookupTable.getPointer()->addMember(member); } static TinyPtrVector<ValueDecl *> maybeFilterOutAttrImplements(TinyPtrVector<ValueDecl *> decls, DeclName name, bool includeAttrImplements) { if (includeAttrImplements) return decls; TinyPtrVector<ValueDecl*> result; for (auto V : decls) { // Filter-out any decl that doesn't have the name we're looking for // (asserting as a consistency-check that such entries all have // @_implements attrs for the name!) if (V->getFullName().matchesRef(name)) { result.push_back(V); } else { auto A = V->getAttrs().getAttribute<ImplementsAttr>(); assert(A && A->getMemberName().matchesRef(name)); } } return result; } TinyPtrVector<ValueDecl *> NominalTypeDecl::lookupDirect( DeclName name, OptionSet<LookupDirectFlags> flags) { ASTContext &ctx = getASTContext(); if (auto s = ctx.Stats) { ++s->getFrontendCounters().NominalTypeLookupDirectCount; } // We only use NamedLazyMemberLoading when a user opts-in and we have // not yet loaded all the members into the IDC list in the first place. bool useNamedLazyMemberLoading = (ctx.LangOpts.NamedLazyMemberLoading && hasLazyMembers()); bool ignoreNewExtensions = flags.contains(LookupDirectFlags::IgnoreNewExtensions); bool includeAttrImplements = flags.contains(LookupDirectFlags::IncludeAttrImplements); // FIXME: At present, lazy member is not able to find inherited constructors // in imported classes, because SwiftDeclConverter::importInheritedConstructors() // is only called via ClangImporter::Implementation::loadAllMembers(). if (hasClangNode() && name.getBaseName() == DeclBaseName::createConstructor()) useNamedLazyMemberLoading = false; LLVM_DEBUG(llvm::dbgs() << getNameStr() << ".lookupDirect(" << name << ", " << ignoreNewExtensions << ")" << ", isLookupTablePopulated()=" << isLookupTablePopulated() << ", hasLazyMembers()=" << hasLazyMembers() << ", useNamedLazyMemberLoading=" << useNamedLazyMemberLoading << "\n"); // We check the LookupTable at most twice, possibly treating a miss in the // first try as a cache-miss that we then do a cache-fill on, and retry. for (int i = 0; i < 2; ++i) { // First, if we're _not_ doing NamedLazyMemberLoading, we make sure we've // populated the IDC and brought it up to date with any extensions. This // will flip the hasLazyMembers() flag to false as well. if (!useNamedLazyMemberLoading) { // It's possible that the lookup table exists but has information in it // that is either currently out of date or soon to be out of date. // This can happen two ways: // // - We've not yet indexed the members we have (isLookupTablePopulated() // is zero). // // - We've still got more lazy members left to load; this can happen // even if we _did_ index some members. // // In either of these cases, we want to reset the table to empty and // mark it as needing reconstruction. if (LookupTable.getPointer() && (hasLazyMembers() || !isLookupTablePopulated())) { LookupTable.getPointer()->clear(); setLookupTablePopulated(false); } (void)getMembers(); // Make sure we have the complete list of members (in this nominal and in // all extensions). if (!ignoreNewExtensions) { for (auto E : getExtensions()) (void)E->getMembers(); } } // Next, in all cases, prepare the lookup table for use, possibly // repopulating it from the IDC if the IDC member list has just grown. prepareLookupTable(ignoreNewExtensions); // Look for a declaration with this name. auto known = LookupTable.getPointer()->find(name); // We found something; return it. if (known != LookupTable.getPointer()->end()) return maybeFilterOutAttrImplements(known->second, name, includeAttrImplements); // If we have no more second chances, stop now. if (!useNamedLazyMemberLoading || i > 0) break; // If we get here, we had a cache-miss and _are_ using // NamedLazyMemberLoading. Try to populate a _single_ entry in the // MemberLookupTable from both this nominal and all of its extensions, and // retry. Any failure to load here flips the useNamedLazyMemberLoading to // false, and we fall back to loading all members during the retry. auto &Table = *LookupTable.getPointer(); if (populateLookupTableEntryFromLazyIDCLoader(ctx, Table, name, this) || populateLookupTableEntryFromExtensions(ctx, Table, this, name, ignoreNewExtensions)) { useNamedLazyMemberLoading = false; } } // None of our attempts found anything. return { }; } void ClassDecl::createObjCMethodLookup() { assert(!ObjCMethodLookup && "Already have an Objective-C member table"); auto &ctx = getASTContext(); ObjCMethodLookup = new (ctx) ObjCMethodLookupTable(); // Register a cleanup with the ASTContext to call the lookup table // destructor. ctx.addCleanup([this]() { this->ObjCMethodLookup->~ObjCMethodLookupTable(); }); } MutableArrayRef<AbstractFunctionDecl *> ClassDecl::lookupDirect(ObjCSelector selector, bool isInstance) { if (!ObjCMethodLookup) { createObjCMethodLookup(); } // If any modules have been loaded since we did the search last (or if we // hadn't searched before), look in those modules, too. auto &stored = (*ObjCMethodLookup)[{selector, isInstance}]; ASTContext &ctx = getASTContext(); if (ctx.getCurrentGeneration() > stored.Generation) { ctx.loadObjCMethods(this, selector, isInstance, stored.Generation, stored.Methods); stored.Generation = ctx.getCurrentGeneration(); } return { stored.Methods.begin(), stored.Methods.end() }; } void ClassDecl::recordObjCMethod(AbstractFunctionDecl *method, ObjCSelector selector) { if (!ObjCMethodLookup) { createObjCMethodLookup(); } // Record the method. bool isInstanceMethod = method->isObjCInstanceMethod(); auto &vec = (*ObjCMethodLookup)[{selector, isInstanceMethod}].Methods; // Check whether we have a duplicate. This only checks more than one // element in ill-formed code, so the linear search is acceptable. if (std::find(vec.begin(), vec.end(), method) != vec.end()) return; if (auto *sf = method->getParentSourceFile()) { if (vec.size() == 1) { // We have a conflict. sf->ObjCMethodConflicts.push_back(std::make_tuple(this, selector, isInstanceMethod)); } if (vec.empty()) { sf->ObjCMethodList.push_back(method); } } vec.push_back(method); } /// Configure name lookup for the given declaration context and options. /// /// This utility is used by qualified name lookup. static void configureLookup(const DeclContext *dc, NLOptions &options, ReferencedNameTracker *&tracker, bool &isLookupCascading) { auto &ctx = dc->getASTContext(); if (ctx.isAccessControlDisabled()) options |= NL_IgnoreAccessControl; // Find the dependency tracker we'll need for this lookup. tracker = nullptr; if (auto containingSourceFile = dyn_cast<SourceFile>(dc->getModuleScopeContext())) { tracker = containingSourceFile->getReferencedNameTracker(); } auto checkLookupCascading = [dc, options]() -> Optional<bool> { switch (static_cast<unsigned>(options & NL_KnownDependencyMask)) { case 0: return dc->isCascadingContextForLookup( /*functionsAreNonCascading=*/false); case NL_KnownNonCascadingDependency: return false; case NL_KnownCascadingDependency: return true; case NL_KnownNoDependency: return None; default: // FIXME: Use llvm::CountPopulation_64 when that's declared constexpr. #if defined(__clang__) || defined(__GNUC__) static_assert(__builtin_popcountll(NL_KnownDependencyMask) == 2, "mask should only include four values"); #endif llvm_unreachable("mask only includes four values"); } }; // Determine whether a lookup here will cascade. isLookupCascading = false; if (tracker) { if (auto maybeLookupCascade = checkLookupCascading()) isLookupCascading = maybeLookupCascade.getValue(); else tracker = nullptr; } } /// Determine whether the given declaration is an acceptable lookup /// result when searching from the given DeclContext. static bool isAcceptableLookupResult(const DeclContext *dc, NLOptions options, ValueDecl *decl, bool onlyCompleteObjectInits) { // Filter out designated initializers, if requested. if (onlyCompleteObjectInits) { if (auto ctor = dyn_cast<ConstructorDecl>(decl)) { if (isa<ClassDecl>(ctor->getDeclContext()) && !ctor->isInheritable()) return false; } else { return false; } } // Ignore stub implementations. if (auto ctor = dyn_cast<ConstructorDecl>(decl)) { if (ctor->hasStubImplementation()) return false; } // Check access. if (!(options & NL_IgnoreAccessControl)) { return decl->isAccessibleFrom(dc); } return true; } void namelookup::pruneLookupResultSet(const DeclContext *dc, NLOptions options, SmallVectorImpl<ValueDecl *> &decls) { // If we're supposed to remove overridden declarations, do so now. if (options & NL_RemoveOverridden) removeOverriddenDecls(decls); // If we're supposed to remove shadowed/hidden declarations, do so now. ModuleDecl *M = dc->getParentModule(); if (options & NL_RemoveNonVisible) removeShadowedDecls(decls, M); filterForDiscriminator(decls, M->getDebugClient()); } /// Inspect the given type to determine which nominal type declarations it /// directly references, to facilitate name lookup into those types. static void extractDirectlyReferencedNominalTypes( Type type, SmallVectorImpl<NominalTypeDecl *> &decls) { if (auto nominal = type->getAnyNominal()) { decls.push_back(nominal); return; } if (auto unbound = type->getAs<UnboundGenericType>()) { if (auto nominal = dyn_cast<NominalTypeDecl>(unbound->getDecl())) decls.push_back(nominal); return; } if (auto archetypeTy = type->getAs<ArchetypeType>()) { // Look in the protocols to which the archetype conforms (always). for (auto proto : archetypeTy->getConformsTo()) decls.push_back(proto); // Look into the superclasses of this archetype. if (auto superclass = archetypeTy->getSuperclass()) { if (auto superclassDecl = superclass->getClassOrBoundGenericClass()) decls.push_back(superclassDecl); } return; } if (auto compositionTy = type->getAs<ProtocolCompositionType>()) { auto layout = compositionTy->getExistentialLayout(); for (auto proto : layout.getProtocols()) { auto *protoDecl = proto->getDecl(); decls.push_back(protoDecl); } if (auto superclass = layout.explicitSuperclass) { auto *superclassDecl = superclass->getClassOrBoundGenericClass(); if (superclassDecl) decls.push_back(superclassDecl); } return; } llvm_unreachable("Not a type containing nominal types?"); } bool DeclContext::lookupQualified(Type type, DeclName member, NLOptions options, LazyResolver *typeResolver, SmallVectorImpl<ValueDecl *> &decls) const { using namespace namelookup; assert(decls.empty() && "additive lookup not supported"); // Handle AnyObject lookup. if (type->isAnyObject()) return lookupAnyObject(member, options, decls); // Handle lookup in a module. if (auto moduleTy = type->getAs<ModuleType>()) return lookupQualified(moduleTy->getModule(), member, options, decls); // Figure out which nominal types we will look into. SmallVector<NominalTypeDecl *, 4> nominalTypesToLookInto; extractDirectlyReferencedNominalTypes(type, nominalTypesToLookInto); return lookupQualified(nominalTypesToLookInto, member, options, decls); } bool DeclContext::lookupQualified(ArrayRef<NominalTypeDecl *> typeDecls, DeclName member, NLOptions options, SmallVectorImpl<ValueDecl *> &decls) const { using namespace namelookup; assert(decls.empty() && "additive lookup not supported"); // Configure lookup and dig out the tracker. ReferencedNameTracker *tracker = nullptr; bool isLookupCascading; configureLookup(this, options, tracker, isLookupCascading); // Tracking for the nominal types we'll visit. SmallVector<NominalTypeDecl *, 4> stack; llvm::SmallPtrSet<NominalTypeDecl *, 4> visited; bool sawClassDecl = false; // Add the given nominal type to the stack. auto addNominalType = [&](NominalTypeDecl *nominal) { if (!visited.insert(nominal).second) return false; if (isa<ClassDecl>(nominal)) sawClassDecl = true; stack.push_back(nominal); return true; }; // Add all of the nominal types to the stack. for (auto nominal : typeDecls) { addNominalType(nominal); } // Whether we only want to return complete object initializers. bool onlyCompleteObjectInits = false; // Visit all of the nominal types we know about, discovering any others // we need along the way. auto &ctx = getASTContext(); auto typeResolver = ctx.getLazyResolver(); bool wantProtocolMembers = (options & NL_ProtocolMembers); while (!stack.empty()) { auto current = stack.back(); stack.pop_back(); if (tracker) tracker->addUsedMember({current, member.getBaseName()},isLookupCascading); // Make sure we've resolved implicit members, if we need them. if (typeResolver) { if (member.getBaseName() == DeclBaseName::createConstructor()) typeResolver->resolveImplicitConstructors(current); typeResolver->resolveImplicitMember(current, member); } // Look for results within the current nominal type and its extensions. bool currentIsProtocol = isa<ProtocolDecl>(current); auto flags = OptionSet<NominalTypeDecl::LookupDirectFlags>(); if (options & NL_IncludeAttributeImplements) flags |= NominalTypeDecl::LookupDirectFlags::IncludeAttrImplements; for (auto decl : current->lookupDirect(member, flags)) { // If we're performing a type lookup, don't even attempt to validate // the decl if its not a type. if ((options & NL_OnlyTypes) && !isa<TypeDecl>(decl)) continue; if (isAcceptableLookupResult(this, options, decl, onlyCompleteObjectInits)) decls.push_back(decl); } // Visit superclass. if (auto classDecl = dyn_cast<ClassDecl>(current)) { // If we're looking for initializers, only look at the superclass if the // current class permits inheritance. Even then, only find complete // object initializers. bool visitSuperclass = true; if (member.getBaseName() == DeclBaseName::createConstructor()) { if (classDecl->inheritsSuperclassInitializers(typeResolver)) onlyCompleteObjectInits = true; else visitSuperclass = false; } if (visitSuperclass) { if (auto superclassDecl = classDecl->getSuperclassDecl()) if (visited.insert(superclassDecl).second) stack.push_back(superclassDecl); } } // If we're not looking at a protocol and we're not supposed to // visit the protocols that this type conforms to, skip the next // step. if (!wantProtocolMembers && !currentIsProtocol) continue; SmallVector<ProtocolDecl *, 4> protocols; if (auto *protoDecl = dyn_cast<ProtocolDecl>(current)) { // If we haven't seen a class declaration yet, look into the protocol. if (!sawClassDecl) { if (auto superclassDecl = protoDecl->getSuperclassDecl()) { visited.insert(superclassDecl); stack.push_back(superclassDecl); } } // Collect inherited protocols. for (auto inheritedProto : protoDecl->getInheritedProtocols()) { addNominalType(inheritedProto); } } else { // Collect the protocols to which the nominal type conforms. for (auto proto : current->getAllProtocols()) { if (visited.insert(proto).second) { stack.push_back(proto); } } // For a class, we don't need to visit the protocol members of the // superclass: that's already handled. if (isa<ClassDecl>(current)) wantProtocolMembers = false; } } pruneLookupResultSet(this, options, decls); if (auto *debugClient = this->getParentModule()->getDebugClient()) { debugClient->finishLookupInNominals(this, typeDecls, member, options, decls); } // We're done. Report success/failure. return !decls.empty(); } bool DeclContext::lookupQualified(ModuleDecl *module, DeclName member, NLOptions options, SmallVectorImpl<ValueDecl *> &decls) const { using namespace namelookup; // Configure lookup and dig out the tracker. ReferencedNameTracker *tracker = nullptr; bool isLookupCascading; configureLookup(this, options, tracker, isLookupCascading); ASTContext &ctx = getASTContext(); auto topLevelScope = getModuleScopeContext(); if (module == topLevelScope->getParentModule()) { if (tracker) { recordLookupOfTopLevelName(topLevelScope, member, isLookupCascading); } lookupInModule(module, /*accessPath=*/{}, member, decls, NLKind::QualifiedLookup, ResolutionKind::Overloadable, ctx.getLazyResolver(), topLevelScope); } else { // Note: This is a lookup into another module. Unless we're compiling // multiple modules at once, or if the other module re-exports this one, // it shouldn't be possible to have a dependency from that module on // anything in this one. // Perform the lookup in all imports of this module. forAllVisibleModules(this, [&](const ModuleDecl::ImportedModule &import) -> bool { if (import.second != module) return true; lookupInModule(import.second, import.first, member, decls, NLKind::QualifiedLookup, ResolutionKind::Overloadable, ctx.getLazyResolver(), topLevelScope); // If we're able to do an unscoped lookup, we see everything. No need // to keep going. return !import.first.empty(); }); } llvm::SmallPtrSet<ValueDecl *, 4> knownDecls; decls.erase(std::remove_if(decls.begin(), decls.end(), [&](ValueDecl *vd) -> bool { // If we're performing a type lookup, skip non-types. if ((options & NL_OnlyTypes) && !isa<TypeDecl>(vd)) return true; return !knownDecls.insert(vd).second; }), decls.end()); pruneLookupResultSet(this, options, decls); if (auto *debugClient = this->getParentModule()->getDebugClient()) { debugClient->finishLookupInModule(this, module, member, options, decls); } // We're done. Report success/failure. return !decls.empty(); } bool DeclContext::lookupAnyObject(DeclName member, NLOptions options, SmallVectorImpl<ValueDecl *> &decls) const { using namespace namelookup; assert(decls.empty() && "additive lookup not supported"); // Configure lookup and dig out the tracker. ReferencedNameTracker *tracker = nullptr; bool isLookupCascading; configureLookup(this, options, tracker, isLookupCascading); // Record this lookup. if (tracker) tracker->addDynamicLookupName(member.getBaseName(), isLookupCascading); // Type-only lookup won't find anything on AnyObject. if (options & NL_OnlyTypes) return false; // Collect all of the visible declarations. SmallVector<ValueDecl *, 4> allDecls; forAllVisibleModules(this, [&](ModuleDecl::ImportedModule import) { import.second->lookupClassMember(import.first, member, allDecls); }); // For each declaration whose context is not something we've // already visited above, add it to the list of declarations. llvm::SmallPtrSet<ValueDecl *, 4> knownDecls; for (auto decl : allDecls) { // If the declaration is not @objc, it cannot be called dynamically. if (!decl->isObjC()) continue; // If the declaration has an override, name lookup will also have // found the overridden method. Skip this declaration, because we // prefer the overridden method. if (decl->getOverriddenDecl()) continue; auto dc = decl->getDeclContext(); auto nominal = dc->getSelfNominalTypeDecl(); assert(nominal && "Couldn't find nominal type?"); (void)nominal; // If we didn't see this declaration before, and it's an acceptable // result, add it to the list. // declaration to the list. if (knownDecls.insert(decl).second && isAcceptableLookupResult(this, options, decl, /*onlyCompleteObjectInits=*/false)) decls.push_back(decl); } pruneLookupResultSet(this, options, decls); if (auto *debugClient = this->getParentModule()->getDebugClient()) { debugClient->finishLookupInAnyObject(this, member, options, decls); } // We're done. Report success/failure. return !decls.empty(); } void DeclContext::lookupAllObjCMethods( ObjCSelector selector, SmallVectorImpl<AbstractFunctionDecl *> &results) const { // Collect all of the methods with this selector. forAllVisibleModules(this, [&](ModuleDecl::ImportedModule import) { import.second->lookupObjCMethods(selector, results); }); // Filter out duplicates. llvm::SmallPtrSet<AbstractFunctionDecl *, 8> visited; results.erase( std::remove_if(results.begin(), results.end(), [&](AbstractFunctionDecl *func) -> bool { return !visited.insert(func).second; }), results.end()); } /// Given a set of type declarations, find all of the nominal type declarations /// that they reference, looking through typealiases as appropriate. static TinyPtrVector<NominalTypeDecl *> resolveTypeDeclsToNominal(Evaluator &evaluator, ASTContext &ctx, ArrayRef<TypeDecl *> typeDecls, SmallVectorImpl<ModuleDecl *> &modulesFound, bool &anyObject, llvm::SmallPtrSetImpl<TypeAliasDecl *> &typealiases) { TinyPtrVector<NominalTypeDecl *> nominalDecls; for (auto typeDecl : typeDecls) { // Nominal type declarations get copied directly. if (auto nominalDecl = dyn_cast<NominalTypeDecl>(typeDecl)) { nominalDecls.push_back(nominalDecl); continue; } // Recursively resolve typealiases. if (auto typealias = dyn_cast<TypeAliasDecl>(typeDecl)) { // FIXME: Ad hoc recursion breaking, so we don't look through the // same typealias multiple times. if (!typealiases.insert(typealias).second) continue; auto underlyingTypeReferences = evaluateOrDefault(evaluator, UnderlyingTypeDeclsReferencedRequest{typealias}, {}); auto underlyingNominalReferences = resolveTypeDeclsToNominal(evaluator, ctx, underlyingTypeReferences, modulesFound, anyObject, typealiases); nominalDecls.insert(nominalDecls.end(), underlyingNominalReferences.begin(), underlyingNominalReferences.end()); // Recognize Swift.AnyObject directly. if (typealias->getName().is("AnyObject")) { // TypeRepr version: Builtin.AnyObject if (auto typeRepr = typealias->getUnderlyingTypeLoc().getTypeRepr()) { if (auto compound = dyn_cast<CompoundIdentTypeRepr>(typeRepr)) { auto components = compound->getComponents(); if (components.size() == 2 && components[0]->getIdentifier().is("Builtin") && components[1]->getIdentifier().is("AnyObject")) { anyObject = true; } } } // Type version: an empty class-bound existential. if (auto type = typealias->getUnderlyingTypeLoc().getType()) { if (type->isAnyObject()) anyObject = true; } } continue; } // Keep track of modules we see. if (auto module = dyn_cast<ModuleDecl>(typeDecl)) { modulesFound.push_back(module); continue; } // Make sure we didn't miss some interesting kind of type declaration. assert(isa<AbstractTypeParamDecl>(typeDecl)); } return nominalDecls; } static TinyPtrVector<NominalTypeDecl *> resolveTypeDeclsToNominal(Evaluator &evaluator, ASTContext &ctx, ArrayRef<TypeDecl *> typeDecls, SmallVectorImpl<ModuleDecl *> &modulesFound, bool &anyObject) { llvm::SmallPtrSet<TypeAliasDecl *, 4> typealiases; return resolveTypeDeclsToNominal(evaluator, ctx, typeDecls, modulesFound, anyObject, typealiases); } /// Perform unqualified name lookup for types at the given location. static DirectlyReferencedTypeDecls directReferencesForUnqualifiedTypeLookup(ASTContext &ctx, DeclName name, SourceLoc loc, DeclContext *dc) { DirectlyReferencedTypeDecls results; UnqualifiedLookup::Options options = UnqualifiedLookup::Flags::TypeLookup; UnqualifiedLookup lookup(name, dc, ctx.getLazyResolver(), loc, options); for (const auto &result : lookup.Results) { if (auto typeDecl = dyn_cast<TypeDecl>(result.getValueDecl())) results.push_back(typeDecl); } return results; } /// Perform qualified name lookup for types. static DirectlyReferencedTypeDecls directReferencesForQualifiedTypeLookup(Evaluator &evaluator, ASTContext &ctx, ArrayRef<TypeDecl *> baseTypes, DeclName name, DeclContext *dc) { DirectlyReferencedTypeDecls result; auto addResults = [&result](ArrayRef<ValueDecl *> found){ for (auto decl : found){ assert(isa<TypeDecl>(decl) && "Lookup should only have found type declarations"); result.push_back(cast<TypeDecl>(decl)); } }; { // Look into the base types. SmallVector<ValueDecl *, 4> members; auto options = NL_RemoveNonVisible | NL_OnlyTypes; // Look through the type declarations we were given, resolving them down // to nominal type declarations, module declarations, and SmallVector<ModuleDecl *, 2> moduleDecls; bool anyObject = false; auto nominalTypeDecls = resolveTypeDeclsToNominal(ctx.evaluator, ctx, baseTypes, moduleDecls, anyObject); dc->lookupQualified(nominalTypeDecls, name, options, members); // Search all of the modules. for (auto module : moduleDecls) { auto innerOptions = options; innerOptions &= ~NL_RemoveOverridden; innerOptions &= ~NL_RemoveNonVisible; dc->lookupQualified(module, name, innerOptions, members); } addResults(members); } return result; } /// Determine the types directly referenced by the given identifier type. static DirectlyReferencedTypeDecls directReferencesForIdentTypeRepr(Evaluator &evaluator, ASTContext &ctx, IdentTypeRepr *ident, DeclContext *dc) { DirectlyReferencedTypeDecls current; bool firstComponent = true; for (const auto &component : ident->getComponentRange()) { // If we already set a declaration, use it. if (auto typeDecl = component->getBoundDecl()) { current = {1, typeDecl}; continue; } // For the first component, perform unqualified name lookup. if (current.empty()) { current = directReferencesForUnqualifiedTypeLookup(ctx, component->getIdentifier(), component->getIdLoc(), dc); // If we didn't find anything, fail now. if (current.empty()) return current; firstComponent = false; continue; } // For subsequent components, perform qualified name lookup. current = directReferencesForQualifiedTypeLookup(evaluator, ctx, current, component->getIdentifier(), dc); if (current.empty()) return current; } return current; } static DirectlyReferencedTypeDecls directReferencesForTypeRepr(Evaluator &evaluator, ASTContext &ctx, TypeRepr *typeRepr, DeclContext *dc) { switch (typeRepr->getKind()) { case TypeReprKind::Array: return {1, ctx.getArrayDecl()}; case TypeReprKind::Attributed: { auto attributed = cast<AttributedTypeRepr>(typeRepr); return directReferencesForTypeRepr(evaluator, ctx, attributed->getTypeRepr(), dc); } case TypeReprKind::Composition: { DirectlyReferencedTypeDecls result; auto composition = cast<CompositionTypeRepr>(typeRepr); for (auto component : composition->getTypes()) { auto componentResult = directReferencesForTypeRepr(evaluator, ctx, component, dc); result.insert(result.end(), componentResult.begin(), componentResult.end()); } return result; } case TypeReprKind::CompoundIdent: case TypeReprKind::GenericIdent: case TypeReprKind::SimpleIdent: return directReferencesForIdentTypeRepr(evaluator, ctx, cast<IdentTypeRepr>(typeRepr), dc); case TypeReprKind::Dictionary: return { 1, ctx.getDictionaryDecl()}; case TypeReprKind::Tuple: { auto tupleRepr = cast<TupleTypeRepr>(typeRepr); if (tupleRepr->isParenType()) { return directReferencesForTypeRepr(evaluator, ctx, tupleRepr->getElementType(0), dc); } return { }; } case TypeReprKind::Error: case TypeReprKind::Function: case TypeReprKind::InOut: case TypeReprKind::Metatype: case TypeReprKind::Owned: case TypeReprKind::Protocol: case TypeReprKind::Shared: case TypeReprKind::SILBox: return { }; case TypeReprKind::OpaqueReturn: return { }; case TypeReprKind::Fixed: llvm_unreachable("Cannot get fixed TypeReprs in name lookup"); case TypeReprKind::Optional: case TypeReprKind::ImplicitlyUnwrappedOptional: return { 1, ctx.getOptionalDecl() }; } llvm_unreachable("unhandled kind"); } static DirectlyReferencedTypeDecls directReferencesForType(Type type) { // If it's a typealias, return that. if (auto aliasType = dyn_cast<TypeAliasType>(type.getPointer())) return { 1, aliasType->getDecl() }; // If there is a generic declaration, return it. if (auto genericDecl = type->getAnyGeneric()) return { 1, genericDecl }; if (type->isExistentialType()) { DirectlyReferencedTypeDecls result; const auto &layout = type->getExistentialLayout(); // Superclass. if (auto superclassType = layout.explicitSuperclass) { if (auto superclassDecl = superclassType->getAnyGeneric()) { result.push_back(superclassDecl); } } // Protocols. for (auto protocolTy : layout.getProtocols()) result.push_back(protocolTy->getDecl()); return result; } return { }; } DirectlyReferencedTypeDecls InheritedDeclsReferencedRequest::evaluate( Evaluator &evaluator, llvm::PointerUnion<TypeDecl *, ExtensionDecl *> decl, unsigned index) const { // Prefer syntactic information when we have it. TypeLoc &typeLoc = getTypeLoc(decl, index); if (auto typeRepr = typeLoc.getTypeRepr()) { // Figure out the context in which name lookup will occur. DeclContext *dc; if (auto typeDecl = decl.dyn_cast<TypeDecl *>()) dc = typeDecl->getInnermostDeclContext(); else dc = decl.get<ExtensionDecl *>(); return directReferencesForTypeRepr(evaluator, dc->getASTContext(), typeRepr, dc); } // Fall back to semantic types. // FIXME: In the long run, we shouldn't need this. Non-syntactic results // should be cached. if (auto type = typeLoc.getType()) { return directReferencesForType(type); } return { }; } DirectlyReferencedTypeDecls UnderlyingTypeDeclsReferencedRequest::evaluate( Evaluator &evaluator, TypeAliasDecl *typealias) const { // Prefer syntactic information when we have it. if (auto typeRepr = typealias->getUnderlyingTypeLoc().getTypeRepr()) { return directReferencesForTypeRepr(evaluator, typealias->getASTContext(), typeRepr, typealias); } // Fall back to semantic types. // FIXME: In the long run, we shouldn't need this. Non-syntactic results // should be cached. if (auto type = typealias->getUnderlyingTypeLoc().getType()) { return directReferencesForType(type); } return { }; } /// Evaluate a superclass declaration request. llvm::Expected<ClassDecl *> SuperclassDeclRequest::evaluate(Evaluator &evaluator, NominalTypeDecl *subject) const { auto &Ctx = subject->getASTContext(); for (unsigned i : indices(subject->getInherited())) { // Find the inherited declarations referenced at this position. auto inheritedTypes = evaluateOrDefault(evaluator, InheritedDeclsReferencedRequest{subject, i}, {}); // Resolve those type declarations to nominal type declarations. SmallVector<ModuleDecl *, 2> modulesFound; bool anyObject = false; auto inheritedNominalTypes = resolveTypeDeclsToNominal(evaluator, Ctx, inheritedTypes, modulesFound, anyObject); // Look for a class declaration. for (auto inheritedNominal : inheritedNominalTypes) { if (auto classDecl = dyn_cast<ClassDecl>(inheritedNominal)) return classDecl; } } // Protocols also support '... where Self : Superclass'. auto *proto = dyn_cast<ProtocolDecl>(subject); if (proto == nullptr) return nullptr; auto selfBounds = getSelfBoundsFromWhereClause(proto); for (auto inheritedNominal : selfBounds.decls) if (auto classDecl = dyn_cast<ClassDecl>(inheritedNominal)) return classDecl; return nullptr; } llvm::Expected<NominalTypeDecl *> ExtendedNominalRequest::evaluate(Evaluator &evaluator, ExtensionDecl *ext) const { DirectlyReferencedTypeDecls referenced; ASTContext &ctx = ext->getASTContext(); // Prefer syntactic information when we have it. TypeLoc &typeLoc = ext->getExtendedTypeLoc(); if (auto typeRepr = typeLoc.getTypeRepr()) { referenced = directReferencesForTypeRepr(evaluator, ctx, typeRepr, ext); } else if (auto type = typeLoc.getType()) { // Fall back to semantic types. // FIXME: In the long run, we shouldn't need this. Non-syntactic results // should be cached. referenced = directReferencesForType(type); } // Resolve those type declarations to nominal type declarations. SmallVector<ModuleDecl *, 2> modulesFound; bool anyObject = false; auto nominalTypes = resolveTypeDeclsToNominal(evaluator, ctx, referenced, modulesFound, anyObject); return nominalTypes.empty() ? nullptr : nominalTypes.front(); } llvm::Expected<NominalTypeDecl *> CustomAttrNominalRequest::evaluate(Evaluator &evaluator, CustomAttr *attr, DeclContext *dc) const { // Find the types referenced by the custom attribute. auto &ctx = dc->getASTContext(); TypeLoc &typeLoc = attr->getTypeLoc(); DirectlyReferencedTypeDecls decls; if (auto typeRepr = typeLoc.getTypeRepr()) { decls = directReferencesForTypeRepr( evaluator, ctx, typeRepr, dc); } else if (Type type = typeLoc.getType()) { decls = directReferencesForType(type); } // Dig out the nominal type declarations. SmallVector<ModuleDecl *, 2> modulesFound; bool anyObject = false; auto nominals = resolveTypeDeclsToNominal(evaluator, ctx, decls, modulesFound, anyObject); if (nominals.size() == 1 && !isa<ProtocolDecl>(nominals.front())) return nominals.front(); return nullptr; } void swift::getDirectlyInheritedNominalTypeDecls( llvm::PointerUnion<TypeDecl *, ExtensionDecl *> decl, unsigned i, llvm::SmallVectorImpl<std::pair<SourceLoc, NominalTypeDecl *>> &result, bool &anyObject) { auto typeDecl = decl.dyn_cast<TypeDecl *>(); auto extDecl = decl.dyn_cast<ExtensionDecl *>(); ASTContext &ctx = typeDecl ? typeDecl->getASTContext() : extDecl->getASTContext(); // Find inherited declarations. auto referenced = evaluateOrDefault(ctx.evaluator, InheritedDeclsReferencedRequest{decl, i}, {}); // Resolve those type declarations to nominal type declarations. SmallVector<ModuleDecl *, 2> modulesFound; auto nominalTypes = resolveTypeDeclsToNominal(ctx.evaluator, ctx, referenced, modulesFound, anyObject); // Dig out the source location // FIXME: This is a hack. We need cooperation from // InheritedDeclsReferencedRequest to make this work. SourceLoc loc; if (TypeRepr *typeRepr = typeDecl ? typeDecl->getInherited()[i].getTypeRepr() : extDecl->getInherited()[i].getTypeRepr()){ loc = typeRepr->getLoc(); } // Form the result. for (auto nominal : nominalTypes) { result.push_back({loc, nominal}); } } SmallVector<std::pair<SourceLoc, NominalTypeDecl *>, 4> swift::getDirectlyInheritedNominalTypeDecls( llvm::PointerUnion<TypeDecl *, ExtensionDecl *> decl, bool &anyObject) { auto typeDecl = decl.dyn_cast<TypeDecl *>(); auto extDecl = decl.dyn_cast<ExtensionDecl *>(); // Gather results from all of the inherited types. unsigned numInherited = typeDecl ? typeDecl->getInherited().size() : extDecl->getInherited().size(); SmallVector<std::pair<SourceLoc, NominalTypeDecl *>, 4> result; for (unsigned i : range(numInherited)) { getDirectlyInheritedNominalTypeDecls(decl, i, result, anyObject); } auto *protoDecl = dyn_cast_or_null<ProtocolDecl>(typeDecl); if (protoDecl == nullptr) return result; // FIXME: Refactor SelfBoundsFromWhereClauseRequest to dig out // the source location. SourceLoc loc = SourceLoc(); auto selfBounds = getSelfBoundsFromWhereClause(decl); anyObject |= selfBounds.anyObject; for (auto inheritedNominal : selfBounds.decls) result.emplace_back(loc, inheritedNominal); return result; } void FindLocalVal::checkPattern(const Pattern *Pat, DeclVisibilityKind Reason) { switch (Pat->getKind()) { case PatternKind::Tuple: for (auto &field : cast<TuplePattern>(Pat)->getElements()) checkPattern(field.getPattern(), Reason); return; case PatternKind::Paren: case PatternKind::Typed: case PatternKind::Var: return checkPattern(Pat->getSemanticsProvidingPattern(), Reason); case PatternKind::Named: return checkValueDecl(cast<NamedPattern>(Pat)->getDecl(), Reason); case PatternKind::EnumElement: { auto *OP = cast<EnumElementPattern>(Pat); if (OP->hasSubPattern()) checkPattern(OP->getSubPattern(), Reason); return; } case PatternKind::OptionalSome: checkPattern(cast<OptionalSomePattern>(Pat)->getSubPattern(), Reason); return; case PatternKind::Is: { auto *isPat = cast<IsPattern>(Pat); if (isPat->hasSubPattern()) checkPattern(isPat->getSubPattern(), Reason); return; } // Handle non-vars. case PatternKind::Bool: case PatternKind::Expr: case PatternKind::Any: return; } } void FindLocalVal::checkParameterList(const ParameterList *params) { for (auto param : *params) { checkValueDecl(param, DeclVisibilityKind::FunctionParameter); } } void FindLocalVal::checkGenericParams(GenericParamList *Params) { if (!Params) return; for (auto P : *Params) checkValueDecl(P, DeclVisibilityKind::GenericParameter); } void FindLocalVal::checkSourceFile(const SourceFile &SF) { for (Decl *D : SF.Decls) if (auto *TLCD = dyn_cast<TopLevelCodeDecl>(D)) visitBraceStmt(TLCD->getBody(), /*isTopLevel=*/true); } void FindLocalVal::checkStmtCondition(const StmtCondition &Cond) { SourceLoc start = SourceLoc(); for (auto entry : Cond) { if (start.isInvalid()) start = entry.getStartLoc(); if (auto *P = entry.getPatternOrNull()) { SourceRange previousConditionsToHere = SourceRange(start, entry.getEndLoc()); if (!isReferencePointInRange(previousConditionsToHere)) checkPattern(P, DeclVisibilityKind::LocalVariable); } } } void FindLocalVal::visitIfStmt(IfStmt *S) { if (!isReferencePointInRange(S->getSourceRange())) return; if (!S->getElseStmt() || !isReferencePointInRange(S->getElseStmt()->getSourceRange())) { checkStmtCondition(S->getCond()); } visit(S->getThenStmt()); if (S->getElseStmt()) visit(S->getElseStmt()); } void FindLocalVal::visitGuardStmt(GuardStmt *S) { if (SM.isBeforeInBuffer(Loc, S->getStartLoc())) return; // Names in the guard aren't visible until after the body. if (!isReferencePointInRange(S->getBody()->getSourceRange())) checkStmtCondition(S->getCond()); visit(S->getBody()); } void FindLocalVal::visitWhileStmt(WhileStmt *S) { if (!isReferencePointInRange(S->getSourceRange())) return; checkStmtCondition(S->getCond()); visit(S->getBody()); } void FindLocalVal::visitRepeatWhileStmt(RepeatWhileStmt *S) { visit(S->getBody()); } void FindLocalVal::visitDoStmt(DoStmt *S) { visit(S->getBody()); } void FindLocalVal::visitForEachStmt(ForEachStmt *S) { if (!isReferencePointInRange(S->getSourceRange())) return; visit(S->getBody()); if (!isReferencePointInRange(S->getSequence()->getSourceRange())) checkPattern(S->getPattern(), DeclVisibilityKind::LocalVariable); } void FindLocalVal::visitBraceStmt(BraceStmt *S, bool isTopLevelCode) { if (isTopLevelCode) { if (SM.isBeforeInBuffer(Loc, S->getStartLoc())) return; } else { if (!isReferencePointInRange(S->getSourceRange())) return; } for (auto elem : S->getElements()) { if (auto *S = elem.dyn_cast<Stmt*>()) visit(S); } for (auto elem : S->getElements()) { if (auto *D = elem.dyn_cast<Decl*>()) { if (auto *VD = dyn_cast<ValueDecl>(D)) checkValueDecl(VD, DeclVisibilityKind::LocalVariable); } } } void FindLocalVal::visitSwitchStmt(SwitchStmt *S) { if (!isReferencePointInRange(S->getSourceRange())) return; for (CaseStmt *C : S->getCases()) { visit(C); } } void FindLocalVal::visitCaseStmt(CaseStmt *S) { if (!isReferencePointInRange(S->getSourceRange())) return; // Pattern names aren't visible in the patterns themselves, // just in the body or in where guards. bool inPatterns = isReferencePointInRange(S->getLabelItemsRange()); auto items = S->getCaseLabelItems(); if (inPatterns) { for (const auto &CLI : items) { auto guard = CLI.getGuardExpr(); if (guard && isReferencePointInRange(guard->getSourceRange())) { checkPattern(CLI.getPattern(), DeclVisibilityKind::LocalVariable); break; } } } if (!inPatterns && !items.empty()) { for (auto *vd : S->getCaseBodyVariablesOrEmptyArray()) { checkValueDecl(vd, DeclVisibilityKind::LocalVariable); } } visit(S->getBody()); } void FindLocalVal::visitDoCatchStmt(DoCatchStmt *S) { if (!isReferencePointInRange(S->getSourceRange())) return; visit(S->getBody()); visitCatchClauses(S->getCatches()); } void FindLocalVal::visitCatchClauses(ArrayRef<CatchStmt*> clauses) { // TODO: some sort of binary search? for (auto clause : clauses) { visitCatchStmt(clause); } } void FindLocalVal::visitCatchStmt(CatchStmt *S) { if (!isReferencePointInRange(S->getSourceRange())) return; // Names in the pattern aren't visible until after the pattern. if (!isReferencePointInRange(S->getErrorPattern()->getSourceRange())) checkPattern(S->getErrorPattern(), DeclVisibilityKind::LocalVariable); visit(S->getBody()); }
; A155121: a(n) = 2*n*(1 + n + n^2 + n^3) - 3. ; -3,5,57,237,677,1557,3105,5597,9357,14757,22217,32205,45237,61877,82737,108477,139805,177477,222297,275117,336837,408405,490817,585117,692397,813797,950505,1103757,1274837,1465077,1675857,1908605,2164797,2445957,2753657,3089517,3455205,3852437,4282977,4748637,5251277,5792805,6375177,7000397,7670517,8387637,9153905,9971517,10842717,11769797,12755097,13801005,14909957,16084437,17326977,18640157,20026605,21488997,23030057,24652557,26359317,28153205,30037137,32014077,34087037,36259077,38533305,40912877,43400997,46000917,48715937,51549405,54504717,57585317,60794697,64136397,67614005,71231157,74991537,78898877,82956957,87169605,91540697,96074157,100773957,105644117,110688705,115911837,121317677,126910437,132694377,138673805,144853077,151236597,157828817,164634237,171657405,178902917,186375417,194079597,202020197,210202005,218629857,227308637,236243277,245438757,254900105,264632397,274640757,284930357,295506417,306374205,317539037,329006277,340781337,352869677,365276805,378008277,391069697,404466717,418205037,432290405,446728617,461525517,476686997,492218997,508127505,524418557,541098237,558172677,575648057,593530605,611826597,630542357,649684257,669258717,689272205,709731237,730642377,752012237,773847477,796154805,818940977,842212797,865977117,890240837,915010905,940294317,966098117,992429397,1019295297,1046703005,1074659757,1103172837,1132249577,1161897357,1192123605,1222935797,1254341457,1286348157,1318963517,1352195205,1386050937,1420538477,1455665637,1491440277,1527870305,1564963677,1602728397,1641172517,1680304137,1720131405,1760662517,1801905717,1843869297,1886561597,1929991005,1974165957,2019094937,2064786477,2111249157,2158491605,2206522497,2255350557,2304984557,2355433317,2406705705,2458810637,2511757077,2565554037,2620210577,2675735805,2732138877,2789428997,2847615417,2906707437,2966714405,3027645717,3089510817,3152319197,3216080397,3280804005,3346499657,3413177037,3480845877,3549515957,3619197105,3689899197,3761632157,3834405957,3908230617,3983116205,4059072837,4136110677,4214239937,4293470877,4373813805,4455279077,4537877097,4621618317,4706513237,4792572405,4879806417,4968225917,5057841597,5148664197,5240704505,5333973357,5428481637,5524240277,5621260257,5719552605,5819128397,5919998757,6022174857,6125667917,6230489205,6336650037,6444161777,6553035837,6663283677,6774916805,6887946777,7002385197,7118243717,7235534037,7354267905,7474457117,7596113517,7719248997 mov $1,$0 mul $1,$0 add $0,$1 mov $2,$0 sub $0,4 mul $1,$2 add $1,$0 div $1,2 mul $1,4 add $1,5
# Timing test pushi 1 store 0 L1: pushi 1 load 0 add store 0 pushi 1 pop pushi 1 pop pushi 1 pop pushi 1 pop pushi 1 pop pushi 1 pop load 0 pushi 500000 isGt jmpIfFalse l1 L2: nop
// Copyright 2013 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/logging.h" #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h" #include "chrome/browser/extensions/api/image_writer_private/error_messages.h" #include "chrome/browser/extensions/api/image_writer_private/image_writer_private_api.h" #include "chrome/browser/extensions/api/image_writer_private/operation_manager.h" namespace image_writer_api = extensions::api::image_writer_private; namespace extensions { ImageWriterPrivateWriteFromUrlFunction:: ImageWriterPrivateWriteFromUrlFunction() { } ImageWriterPrivateWriteFromUrlFunction:: ~ImageWriterPrivateWriteFromUrlFunction() { } bool ImageWriterPrivateWriteFromUrlFunction::RunImpl() { scoped_ptr<image_writer_api::WriteFromUrl::Params> params( image_writer_api::WriteFromUrl::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); GURL url(params->image_url); if (!url.is_valid()) { error_ = image_writer::error::kUrlInvalid; return false; } #if defined(OS_CHROMEOS) // The Chrome OS temporary partition is too small for Chrome OS images, thus // we must always use the downloads folder. bool save_image_as_download = true; #else bool save_image_as_download = false; if (params->options.get() && params->options->save_as_download.get()) { save_image_as_download = true; } #endif std::string hash; if (params->options.get() && params->options->image_hash.get()) { hash = *params->options->image_hash; } image_writer::OperationManager::Get(GetProfile())->StartWriteFromUrl( extension_id(), url, render_view_host(), hash, save_image_as_download, params->storage_unit_id, base::Bind(&ImageWriterPrivateWriteFromUrlFunction::OnWriteStarted, this)); return true; } void ImageWriterPrivateWriteFromUrlFunction::OnWriteStarted( bool success, const std::string& error) { if (!success) { error_ = error; } SendResponse(success); } ImageWriterPrivateWriteFromFileFunction:: ImageWriterPrivateWriteFromFileFunction() { } ImageWriterPrivateWriteFromFileFunction:: ~ImageWriterPrivateWriteFromFileFunction() { } bool ImageWriterPrivateWriteFromFileFunction::RunImpl() { std::string filesystem_name; std::string filesystem_path; std::string storage_unit_id; EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &storage_unit_id)); EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &filesystem_name)); EXTENSION_FUNCTION_VALIDATE(args_->GetString(2, &filesystem_path)); base::FilePath path; if (!extensions::app_file_handler_util::ValidateFileEntryAndGetPath( filesystem_name, filesystem_path, render_view_host_, &path, &error_)) return false; image_writer::OperationManager::Get(GetProfile())->StartWriteFromFile( extension_id(), path, storage_unit_id, base::Bind(&ImageWriterPrivateWriteFromFileFunction::OnWriteStarted, this)); return true; } void ImageWriterPrivateWriteFromFileFunction::OnWriteStarted( bool success, const std::string& error) { if (!success) { error_ = error; } SendResponse(success); } ImageWriterPrivateCancelWriteFunction::ImageWriterPrivateCancelWriteFunction() { } ImageWriterPrivateCancelWriteFunction:: ~ImageWriterPrivateCancelWriteFunction() { } bool ImageWriterPrivateCancelWriteFunction::RunImpl() { image_writer::OperationManager::Get(GetProfile())->CancelWrite( extension_id(), base::Bind(&ImageWriterPrivateCancelWriteFunction::OnWriteCancelled, this)); return true; } void ImageWriterPrivateCancelWriteFunction::OnWriteCancelled( bool success, const std::string& error) { if (!success) { error_ = error; } SendResponse(success); } ImageWriterPrivateDestroyPartitionsFunction:: ImageWriterPrivateDestroyPartitionsFunction() { } ImageWriterPrivateDestroyPartitionsFunction:: ~ImageWriterPrivateDestroyPartitionsFunction() { } bool ImageWriterPrivateDestroyPartitionsFunction::RunImpl() { scoped_ptr<image_writer_api::DestroyPartitions::Params> params( image_writer_api::DestroyPartitions::Params::Create(*args_)); EXTENSION_FUNCTION_VALIDATE(params.get()); SendResponse(true); return true; } ImageWriterPrivateListRemovableStorageDevicesFunction:: ImageWriterPrivateListRemovableStorageDevicesFunction() { } ImageWriterPrivateListRemovableStorageDevicesFunction:: ~ImageWriterPrivateListRemovableStorageDevicesFunction() { } bool ImageWriterPrivateListRemovableStorageDevicesFunction::RunImpl() { RemovableStorageProvider::GetAllDevices( base::Bind( &ImageWriterPrivateListRemovableStorageDevicesFunction::OnDeviceListReady, this)); return true; } void ImageWriterPrivateListRemovableStorageDevicesFunction::OnDeviceListReady( scoped_refptr<StorageDeviceList> device_list, bool success) { if (success) { results_ = image_writer_api::ListRemovableStorageDevices::Results::Create( device_list.get()->data); SendResponse(true); } else { error_ = image_writer::error::kDeviceListError; SendResponse(false); } } } // namespace extensions
10 ORG 100H 20 JP MAIN 30WRASR EQU 0BFAFH 40PUTSTR EQU 0BFF1H 50INKEY EQU 089BEH 60PUTCHR EQU 0BE62H 70INITSR EQU 0871AH 80AOUT EQU 0BD09H 90OPENSR EQU 0BCE8H 100CLOSSR EQU 0BCEBH 110LRDSR EQU 0BD15H 120WAITK EQU 0BFCDH 130WCHRSR EQU 0BFAFH 140WSTSR EQU 0BFB2H 150A2HEX EQU 0F9BDH 160RPTCHR EQU 0BFEEH 170REGOUT EQU 0BD03H 200MAIN: CALL CLS 210 LD HL,GREET 220 CALL STRLN 230 LD DE,00000H 240 CALL PUTSTR 250 LD HL,SAMPLE 260 CALL STRLN 270 LD A,B 280 LD (LENGTH),A 290 LD DE,KEY 300MAIN00: LD A,(HL) 310 CP 0 ; end of the text 320 JP Z,THEEND 330 LD A,(DE) ; end of KEY 340 CP 0 350 JP NZ,MAIN01 360 LD DE,KEY ; Rotate back to start 370 LD A,(DE) 380MAIN01: LD B,(HL) 390 XOR B 400 LD (HL),A 410 INC HL 420 INC DE 430 JP MAIN00 ; loop 440THEEND: LD A,(LENGTH) 450 LD B,A 460 LD HL,BUFFER 470 LD DE,SAMPLE 480END00: LD A,(DE) 490 INC DE 500 CALL HEXIFY 510 DJNZ END00 520 LD (HL),0 530 LD HL,BUFFER 540 LD B,74 550 LD DE,0100H 560 CALL PUTSTR 570 CALL WAIT 580 INC HL 590 LD B,74 600 LD DE,0100H 610 CALL PUTSTR 620 LD HL,FINALM 630 CALL STRLN 640 LD DE,0500H 650 CALL PUTSTR 660 CALL WAIT 670 CALL CLS 999 RET 3000DEHEX: LD A,(DE) 3010 INC DE 3020 CALL HALF 3030 SLA A 3040 SLA A 3050 SLA A 3060 SLA A 3070 PUSH BC 3080 LD B,A 3090 LD A,(DE) 3100 INC DE 3110 CALL HALF 3120 ADD A,B 3130 LD (HL),A 3140 INC HL 3150 POP BC 3160 DJNZ DEHEX 3170 LD (HL),0 3180 RET 3190WAIT: CALL WAITK 3200 CP 0 3210 JP Z,WAIT 3220 RET 3230CLS: LD B,144 3240 LD DE,0 3250CLS0: LD A,32 3260 CALL RPTCHR 3270 RET 3280CLLN: LD B,24 3290 LD E,0 3300 JP CLS0 3310HEXIFY: PUSH AF 3320 AND 0F0H 3330 RRCA 3340 RRCA 3350 RRCA 3360 RRCA 3370 CALL NIBBLE 3380 INC HL 3390 POP AF 3400 AND 15 3410 CALL NIBBLE 3420 INC HL 3430 RET 3440NIBBLE: SUB 10 3450 JP M,ZERO9 3460 ADD A,7 3470ZERO9: ADD A,58 3480 LD (HL),A 3490 RET 3500STRLN: LD B,0 3510 PUSH HL 3520STRLN0: LD A,(HL) 3530 CP 0 3540 JP Z,STRLN1 3550 INC HL 3560 INC B 3570 JP STRLN0 3580STRLN1: POP HL 3590 RET 3600HALF: SUB 48 3610 CP 10 3620 JP M,HALF9 3630 SUB 7 3640HALF9: RET 5000GREET: DB 'Matasano Challenge 5' 5010 DB 0 5020BUFFER: DEFS 180 5030LENGTH: DB 0 5040POSB: DB 0,0 5050POSS: DB 0,0 5060KEY: DB 'ICE' 5070KEYT: DB 0 5080SAMPLE:DB 'Burning ' 5090 DB 39,'em, if you ain' 5100 DB 39 5110 DB 't quick and nimble' 5120 DB 10 5130 DB 'I go crazy ' 5140 DB 'when I hear a cymbal' 5150SAMPLX: DB 0 5160MSG00: DB 0,0,' [' 5170MSG01: DB 0,'] ^ ' 5180MSG03: DB 0,0,' --> ' 5190MSG02: DB 0,0,0 5200FINALM: DB '[correct answer!]',0 
SECTION code_fp_am9511 PUBLIC cam32_sdcc_exp10 EXTERN asm_sdcc_read1, _am9511_exp10 .cam32_sdcc_exp10 call asm_sdcc_read1 jp _am9511_exp10
#include "catch_run_context.h" #include "catch_compiler_capabilities.h" #include "catch_context.h" #include "catch_enforce.h" #include "catch_random_number_generator.h" #include "catch_stream.h" #include "catch_output_redirect.h" #include <cassert> #include <algorithm> #include <sstream> namespace Catch { namespace Generators { struct GeneratorTracker : TestCaseTracking::TrackerBase, IGeneratorTracker { size_t m_index = static_cast<size_t>( -1 ); GeneratorBasePtr m_generator; GeneratorTracker( TestCaseTracking::NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ) : TrackerBase( nameAndLocation, ctx, parent ) {} ~GeneratorTracker(); static GeneratorTracker& acquire( TrackerContext& ctx, TestCaseTracking::NameAndLocation const& nameAndLocation ) { std::shared_ptr<GeneratorTracker> tracker; ITracker& currentTracker = ctx.currentTracker(); if( TestCaseTracking::ITrackerPtr childTracker = currentTracker.findChild( nameAndLocation ) ) { assert( childTracker ); assert( childTracker->isIndexTracker() ); tracker = std::static_pointer_cast<GeneratorTracker>( childTracker ); } else { tracker = std::make_shared<GeneratorTracker>( nameAndLocation, ctx, &currentTracker ); currentTracker.addChild( tracker ); } if( !ctx.completedCycle() && !tracker->isComplete() ) { if( tracker->m_runState != ExecutingChildren && tracker->m_runState != NeedsAnotherRun ) tracker->moveNext(); tracker->open(); } return *tracker; } void moveNext() { m_index++; m_children.clear(); } // TrackerBase interface bool isIndexTracker() const override { return true; } auto hasGenerator() const -> bool override { return !!m_generator; } void close() override { TrackerBase::close(); if( m_runState == CompletedSuccessfully && m_index < m_generator->size()-1 ) m_runState = Executing; } // IGeneratorTracker interface auto getGenerator() const -> GeneratorBasePtr const& override { return m_generator; } void setGenerator( GeneratorBasePtr&& generator ) override { m_generator = std::move( generator ); } auto getIndex() const -> size_t override { return m_index; } }; GeneratorTracker::~GeneratorTracker() {} } RunContext::RunContext(IConfigPtr const& _config, IStreamingReporterPtr&& reporter) : m_runInfo(_config->name()), m_context(getCurrentMutableContext()), m_config(_config), m_reporter(std::move(reporter)), m_lastAssertionInfo{ StringRef(), SourceLineInfo("",0), StringRef(), ResultDisposition::Normal }, m_includeSuccessfulResults( m_config->includeSuccessfulResults() || m_reporter->getPreferences().shouldReportAllAssertions ) { m_context.setRunner(this); m_context.setConfig(m_config); m_context.setResultCapture(this); m_reporter->testRunStarting(m_runInfo); } RunContext::~RunContext() { m_reporter->testRunEnded(TestRunStats(m_runInfo, m_totals, aborting())); } void RunContext::testGroupStarting(std::string const& testSpec, std::size_t groupIndex, std::size_t groupsCount) { m_reporter->testGroupStarting(GroupInfo(testSpec, groupIndex, groupsCount)); } void RunContext::testGroupEnded(std::string const& testSpec, Totals const& totals, std::size_t groupIndex, std::size_t groupsCount) { m_reporter->testGroupEnded(TestGroupStats(GroupInfo(testSpec, groupIndex, groupsCount), totals, aborting())); } Totals RunContext::runTest(TestCase const& testCase) { Totals prevTotals = m_totals; std::string redirectedCout; std::string redirectedCerr; auto const& testInfo = testCase.getTestCaseInfo(); m_reporter->testCaseStarting(testInfo); m_activeTestCase = &testCase; ITracker& rootTracker = m_trackerContext.startRun(); assert(rootTracker.isSectionTracker()); static_cast<SectionTracker&>(rootTracker).addInitialFilters(m_config->getSectionsToRun()); do { m_trackerContext.startCycle(); m_testCaseTracker = &SectionTracker::acquire(m_trackerContext, TestCaseTracking::NameAndLocation(testInfo.name, testInfo.lineInfo)); runCurrentTest(redirectedCout, redirectedCerr); } while (!m_testCaseTracker->isSuccessfullyCompleted() && !aborting()); Totals deltaTotals = m_totals.delta(prevTotals); if (testInfo.expectedToFail() && deltaTotals.testCases.passed > 0) { deltaTotals.assertions.failed++; deltaTotals.testCases.passed--; deltaTotals.testCases.failed++; } m_totals.testCases += deltaTotals.testCases; m_reporter->testCaseEnded(TestCaseStats(testInfo, deltaTotals, redirectedCout, redirectedCerr, aborting())); m_activeTestCase = nullptr; m_testCaseTracker = nullptr; return deltaTotals; } IConfigPtr RunContext::config() const { return m_config; } IStreamingReporter& RunContext::reporter() const { return *m_reporter; } void RunContext::assertionEnded(AssertionResult const & result) { if (result.getResultType() == ResultWas::Ok) { m_totals.assertions.passed++; m_lastAssertionPassed = true; } else if (!result.isOk()) { m_lastAssertionPassed = false; if( m_activeTestCase->getTestCaseInfo().okToFail() ) m_totals.assertions.failedButOk++; else m_totals.assertions.failed++; } else { m_lastAssertionPassed = true; } // We have no use for the return value (whether messages should be cleared), because messages were made scoped // and should be let to clear themselves out. static_cast<void>(m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals))); // Reset working state resetAssertionInfo(); m_lastResult = result; } void RunContext::resetAssertionInfo() { m_lastAssertionInfo.macroName = StringRef(); m_lastAssertionInfo.capturedExpression = "{Unknown expression after the reported line}"_sr; } bool RunContext::sectionStarted(SectionInfo const & sectionInfo, Counts & assertions) { ITracker& sectionTracker = SectionTracker::acquire(m_trackerContext, TestCaseTracking::NameAndLocation(sectionInfo.name, sectionInfo.lineInfo)); if (!sectionTracker.isOpen()) return false; m_activeSections.push_back(&sectionTracker); m_lastAssertionInfo.lineInfo = sectionInfo.lineInfo; m_reporter->sectionStarting(sectionInfo); assertions = m_totals.assertions; return true; } auto RunContext::acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IGeneratorTracker& { using namespace Generators; GeneratorTracker& tracker = GeneratorTracker::acquire( m_trackerContext, TestCaseTracking::NameAndLocation( "generator", lineInfo ) ); assert( tracker.isOpen() ); m_lastAssertionInfo.lineInfo = lineInfo; return tracker; } bool RunContext::testForMissingAssertions(Counts& assertions) { if (assertions.total() != 0) return false; if (!m_config->warnAboutMissingAssertions()) return false; if (m_trackerContext.currentTracker().hasChildren()) return false; m_totals.assertions.failed++; assertions.failed++; return true; } void RunContext::sectionEnded(SectionEndInfo const & endInfo) { Counts assertions = m_totals.assertions - endInfo.prevAssertions; bool missingAssertions = testForMissingAssertions(assertions); if (!m_activeSections.empty()) { m_activeSections.back()->close(); m_activeSections.pop_back(); } m_reporter->sectionEnded(SectionStats(endInfo.sectionInfo, assertions, endInfo.durationInSeconds, missingAssertions)); m_messages.clear(); } void RunContext::sectionEndedEarly(SectionEndInfo const & endInfo) { if (m_unfinishedSections.empty()) m_activeSections.back()->fail(); else m_activeSections.back()->close(); m_activeSections.pop_back(); m_unfinishedSections.push_back(endInfo); } void RunContext::benchmarkStarting( BenchmarkInfo const& info ) { m_reporter->benchmarkStarting( info ); } void RunContext::benchmarkEnded( BenchmarkStats const& stats ) { m_reporter->benchmarkEnded( stats ); } void RunContext::pushScopedMessage(MessageInfo const & message) { m_messages.push_back(message); } void RunContext::popScopedMessage(MessageInfo const & message) { m_messages.erase(std::remove(m_messages.begin(), m_messages.end(), message), m_messages.end()); } std::string RunContext::getCurrentTestName() const { return m_activeTestCase ? m_activeTestCase->getTestCaseInfo().name : std::string(); } const AssertionResult * RunContext::getLastResult() const { return &(*m_lastResult); } void RunContext::exceptionEarlyReported() { m_shouldReportUnexpected = false; } void RunContext::handleFatalErrorCondition( StringRef message ) { // First notify reporter that bad things happened m_reporter->fatalErrorEncountered(message); // Don't rebuild the result -- the stringification itself can cause more fatal errors // Instead, fake a result data. AssertionResultData tempResult( ResultWas::FatalErrorCondition, { false } ); tempResult.message = message; AssertionResult result(m_lastAssertionInfo, tempResult); assertionEnded(result); handleUnfinishedSections(); // Recreate section for test case (as we will lose the one that was in scope) auto const& testCaseInfo = m_activeTestCase->getTestCaseInfo(); SectionInfo testCaseSection(testCaseInfo.lineInfo, testCaseInfo.name); Counts assertions; assertions.failed = 1; SectionStats testCaseSectionStats(testCaseSection, assertions, 0, false); m_reporter->sectionEnded(testCaseSectionStats); auto const& testInfo = m_activeTestCase->getTestCaseInfo(); Totals deltaTotals; deltaTotals.testCases.failed = 1; deltaTotals.assertions.failed = 1; m_reporter->testCaseEnded(TestCaseStats(testInfo, deltaTotals, std::string(), std::string(), false)); m_totals.testCases.failed++; testGroupEnded(std::string(), m_totals, 1, 1); m_reporter->testRunEnded(TestRunStats(m_runInfo, m_totals, false)); } bool RunContext::lastAssertionPassed() { return m_lastAssertionPassed; } void RunContext::assertionPassed() { m_lastAssertionPassed = true; ++m_totals.assertions.passed; resetAssertionInfo(); } bool RunContext::aborting() const { return m_totals.assertions.failed >= static_cast<std::size_t>(m_config->abortAfter()); } void RunContext::runCurrentTest(std::string & redirectedCout, std::string & redirectedCerr) { auto const& testCaseInfo = m_activeTestCase->getTestCaseInfo(); SectionInfo testCaseSection(testCaseInfo.lineInfo, testCaseInfo.name); m_reporter->sectionStarting(testCaseSection); Counts prevAssertions = m_totals.assertions; double duration = 0; m_shouldReportUnexpected = true; m_lastAssertionInfo = { "TEST_CASE"_sr, testCaseInfo.lineInfo, StringRef(), ResultDisposition::Normal }; seedRng(*m_config); Timer timer; CATCH_TRY { if (m_reporter->getPreferences().shouldRedirectStdOut) { #if !defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT) RedirectedStdOut redirectedStdOut; RedirectedStdErr redirectedStdErr; timer.start(); invokeActiveTestCase(); redirectedCout += redirectedStdOut.str(); redirectedCerr += redirectedStdErr.str(); #else OutputRedirect r(redirectedCout, redirectedCerr); timer.start(); invokeActiveTestCase(); #endif } else { timer.start(); invokeActiveTestCase(); } duration = timer.getElapsedSeconds(); } CATCH_CATCH_ANON (TestFailureException&) { // This just means the test was aborted due to failure } CATCH_CATCH_ALL { // Under CATCH_CONFIG_FAST_COMPILE, unexpected exceptions under REQUIRE assertions // are reported without translation at the point of origin. if( m_shouldReportUnexpected ) { AssertionReaction dummyReaction; handleUnexpectedInflightException( m_lastAssertionInfo, translateActiveException(), dummyReaction ); } } Counts assertions = m_totals.assertions - prevAssertions; bool missingAssertions = testForMissingAssertions(assertions); m_testCaseTracker->close(); handleUnfinishedSections(); m_messages.clear(); SectionStats testCaseSectionStats(testCaseSection, assertions, duration, missingAssertions); m_reporter->sectionEnded(testCaseSectionStats); } void RunContext::invokeActiveTestCase() { FatalConditionHandler fatalConditionHandler; // Handle signals m_activeTestCase->invoke(); fatalConditionHandler.reset(); } void RunContext::handleUnfinishedSections() { // If sections ended prematurely due to an exception we stored their // infos here so we can tear them down outside the unwind process. for (auto it = m_unfinishedSections.rbegin(), itEnd = m_unfinishedSections.rend(); it != itEnd; ++it) sectionEnded(*it); m_unfinishedSections.clear(); } void RunContext::handleExpr( AssertionInfo const& info, ITransientExpression const& expr, AssertionReaction& reaction ) { m_reporter->assertionStarting( info ); bool negated = isFalseTest( info.resultDisposition ); bool result = expr.getResult() != negated; if( result ) { if (!m_includeSuccessfulResults) { assertionPassed(); } else { reportExpr(info, ResultWas::Ok, &expr, negated); } } else { reportExpr(info, ResultWas::ExpressionFailed, &expr, negated ); populateReaction( reaction ); } } void RunContext::reportExpr( AssertionInfo const &info, ResultWas::OfType resultType, ITransientExpression const *expr, bool negated ) { m_lastAssertionInfo = info; AssertionResultData data( resultType, LazyExpression( negated ) ); AssertionResult assertionResult{ info, data }; assertionResult.m_resultData.lazyExpression.m_transientExpression = expr; assertionEnded( assertionResult ); } void RunContext::handleMessage( AssertionInfo const& info, ResultWas::OfType resultType, StringRef const& message, AssertionReaction& reaction ) { m_reporter->assertionStarting( info ); m_lastAssertionInfo = info; AssertionResultData data( resultType, LazyExpression( false ) ); data.message = message; AssertionResult assertionResult{ m_lastAssertionInfo, data }; assertionEnded( assertionResult ); if( !assertionResult.isOk() ) populateReaction( reaction ); } void RunContext::handleUnexpectedExceptionNotThrown( AssertionInfo const& info, AssertionReaction& reaction ) { handleNonExpr(info, Catch::ResultWas::DidntThrowException, reaction); } void RunContext::handleUnexpectedInflightException( AssertionInfo const& info, std::string const& message, AssertionReaction& reaction ) { m_lastAssertionInfo = info; AssertionResultData data( ResultWas::ThrewException, LazyExpression( false ) ); data.message = message; AssertionResult assertionResult{ info, data }; assertionEnded( assertionResult ); populateReaction( reaction ); } void RunContext::populateReaction( AssertionReaction& reaction ) { reaction.shouldDebugBreak = m_config->shouldDebugBreak(); reaction.shouldThrow = aborting() || (m_lastAssertionInfo.resultDisposition & ResultDisposition::Normal); } void RunContext::handleIncomplete( AssertionInfo const& info ) { m_lastAssertionInfo = info; AssertionResultData data( ResultWas::ThrewException, LazyExpression( false ) ); data.message = "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE"; AssertionResult assertionResult{ info, data }; assertionEnded( assertionResult ); } void RunContext::handleNonExpr( AssertionInfo const &info, ResultWas::OfType resultType, AssertionReaction &reaction ) { m_lastAssertionInfo = info; AssertionResultData data( resultType, LazyExpression( false ) ); AssertionResult assertionResult{ info, data }; assertionEnded( assertionResult ); if( !assertionResult.isOk() ) populateReaction( reaction ); } IResultCapture& getResultCapture() { if (auto* capture = getCurrentContext().getResultCapture()) return *capture; else CATCH_INTERNAL_ERROR("No result capture instance"); } }
.global s_prepare_buffers s_prepare_buffers: push %r10 push %r12 push %r13 push %r14 push %r8 push %rcx push %rdi push %rsi lea addresses_normal_ht+0x15f06, %rsi lea addresses_A_ht+0x17f06, %rdi nop nop nop sub $55769, %r12 mov $17, %rcx rep movsq xor $9004, %rcx lea addresses_UC_ht+0x66c6, %r12 clflush (%r12) nop nop add $8853, %r8 mov $0x6162636465666768, %r14 movq %r14, %xmm4 movups %xmm4, (%r12) nop nop xor %r12, %r12 lea addresses_WC_ht+0x2b96, %rcx nop nop sub $30698, %r10 mov $0x6162636465666768, %r8 movq %r8, %xmm7 vmovups %ymm7, (%rcx) nop nop inc %r14 lea addresses_WT_ht+0x1dce6, %r8 nop nop nop add %rdi, %rdi movups (%r8), %xmm1 vpextrq $1, %xmm1, %r10 nop nop sub %r8, %r8 lea addresses_WC_ht+0x6a46, %rsi lea addresses_normal_ht+0x15b8c, %rdi nop nop nop nop nop add %r13, %r13 mov $9, %rcx rep movsb nop nop nop nop nop sub $14544, %r13 lea addresses_A_ht+0x13306, %rsi lea addresses_WC_ht+0x14d06, %rdi nop nop nop nop nop add %r12, %r12 mov $18, %rcx rep movsb cmp $176, %r10 lea addresses_D_ht+0x13706, %rsi lea addresses_UC_ht+0x1211a, %rdi nop nop dec %r10 mov $91, %rcx rep movsb nop nop nop nop nop add $22288, %r14 lea addresses_D_ht+0x13306, %rsi lea addresses_D_ht+0x1e46, %rdi nop nop nop inc %r14 mov $16, %rcx rep movsq nop nop nop nop add %r12, %r12 lea addresses_WC_ht+0x17446, %rsi nop xor $27699, %r10 vmovups (%rsi), %ymm5 vextracti128 $0, %ymm5, %xmm5 vpextrq $1, %xmm5, %rdi inc %r13 lea addresses_A_ht+0x3506, %rdi clflush (%rdi) nop nop sub %r13, %r13 movb (%rdi), %r14b nop nop nop nop cmp $1194, %rcx lea addresses_WT_ht+0x508a, %r13 nop xor %r10, %r10 movl $0x61626364, (%r13) nop nop nop nop and %rdi, %rdi lea addresses_normal_ht+0xf106, %rcx nop nop nop nop cmp $17573, %r12 movw $0x6162, (%rcx) nop nop nop nop nop inc %r10 pop %rsi pop %rdi pop %rcx pop %r8 pop %r14 pop %r13 pop %r12 pop %r10 ret .global s_faulty_load s_faulty_load: push %r10 push %r13 push %r15 push %rbp push %rbx push %rdi // Faulty Load lea addresses_PSE+0x15706, %r15 nop nop inc %rdi mov (%r15), %bp lea oracles, %rdi and $0xff, %rbp shlq $12, %rbp mov (%rdi,%rbp,1), %rbp pop %rdi pop %rbx pop %rbp pop %r15 pop %r13 pop %r10 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'size': 8, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': False}} [Faulty Load] {'OP': 'LOAD', 'src': {'type': 'addresses_PSE', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 0, 'same': True}} <gen_prepare_buffer> {'OP': 'REPM', 'src': {'type': 'addresses_normal_ht', 'congruent': 10, 'same': False}, 'dst': {'type': 'addresses_A_ht', 'congruent': 11, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_UC_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 6, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WC_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WT_ht', 'size': 16, 'AVXalign': False, 'NT': False, 'congruent': 5, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_WC_ht', 'congruent': 3, 'same': False}, 'dst': {'type': 'addresses_normal_ht', 'congruent': 1, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_A_ht', 'congruent': 10, 'same': True}, 'dst': {'type': 'addresses_WC_ht', 'congruent': 9, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 11, 'same': False}, 'dst': {'type': 'addresses_UC_ht', 'congruent': 2, 'same': False}} {'OP': 'REPM', 'src': {'type': 'addresses_D_ht', 'congruent': 9, 'same': False}, 'dst': {'type': 'addresses_D_ht', 'congruent': 4, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_WC_ht', 'size': 32, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}} {'OP': 'LOAD', 'src': {'type': 'addresses_A_ht', 'size': 1, 'AVXalign': False, 'NT': False, 'congruent': 8, 'same': False}} {'OP': 'STOR', 'dst': {'type': 'addresses_WT_ht', 'size': 4, 'AVXalign': False, 'NT': False, 'congruent': 1, 'same': True}} {'OP': 'STOR', 'dst': {'type': 'addresses_normal_ht', 'size': 2, 'AVXalign': False, 'NT': False, 'congruent': 4, 'same': False}} {'33': 21829} 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 */
; Listing generated by Microsoft (R) Optimizing Compiler Version 19.23.28008.0 TITLE C:\Users\libit\source\repos\L008A\L008A\L008A.cpp .686P .XMM include listing.inc .model flat INCLUDELIB LIBCMT INCLUDELIB OLDNAMES CONST SEGMENT $SG5561 DB 'Hello World!', 0aH, 00H ORG $+2 $SG5562 DB '%d', 0aH, 00H CONST ENDS PUBLIC ___local_stdio_printf_options PUBLIC __vfprintf_l PUBLIC _printf PUBLIC ?f@@YAHHH@Z ; f PUBLIC _main PUBLIC ?_OptionsStorage@?1??__local_stdio_printf_options@@9@4_KA ; `__local_stdio_printf_options'::`2'::_OptionsStorage EXTRN ___acrt_iob_func:PROC EXTRN ___stdio_common_vfprintf:PROC ; COMDAT ?_OptionsStorage@?1??__local_stdio_printf_options@@9@4_KA _BSS SEGMENT ?_OptionsStorage@?1??__local_stdio_printf_options@@9@4_KA DQ 01H DUP (?) ; `__local_stdio_printf_options'::`2'::_OptionsStorage _BSS ENDS ; Function compile flags: /Odtp _TEXT SEGMENT _a$ = -12 ; size = 4 _b$ = -8 ; size = 4 _c$ = -4 ; size = 4 _main PROC ; File C:\Users\libit\source\repos\L008A\L008A\L008A.cpp ; Line 14 push ebp mov ebp, esp sub esp, 12 ; 0000000cH ; Line 15 mov DWORD PTR _a$[ebp], 1 ; Line 16 mov DWORD PTR _b$[ebp], 2 ; Line 17 mov DWORD PTR _c$[ebp], 0 ; Line 19 push OFFSET $SG5561 call _printf add esp, 4 ; Line 20 mov eax, DWORD PTR _b$[ebp] push eax mov ecx, DWORD PTR _a$[ebp] push ecx call ?f@@YAHHH@Z ; f add esp, 8 mov DWORD PTR _c$[ebp], eax ; Line 21 mov edx, DWORD PTR _c$[ebp] push edx push OFFSET $SG5562 call _printf add esp, 8 ; Line 23 xor eax, eax mov esp, ebp pop ebp ret 0 _main ENDP _TEXT ENDS ; Function compile flags: /Odtp _TEXT SEGMENT _c$ = -4 ; size = 4 _a$ = 8 ; size = 4 _b$ = 12 ; size = 4 ?f@@YAHHH@Z PROC ; f ; File C:\Users\libit\source\repos\L008A\L008A\L008A.cpp ; Line 7 push ebp mov ebp, esp push ecx ; Line 8 mov DWORD PTR _c$[ebp], 0 ; Line 9 mov eax, DWORD PTR _a$[ebp] add eax, DWORD PTR _b$[ebp] mov DWORD PTR _c$[ebp], eax ; Line 10 mov eax, DWORD PTR _c$[ebp] ; Line 11 mov esp, ebp pop ebp ret 0 ?f@@YAHHH@Z ENDP ; f _TEXT ENDS ; Function compile flags: /Odtp ; COMDAT _printf _TEXT SEGMENT __Result$ = -8 ; size = 4 __ArgList$ = -4 ; size = 4 __Format$ = 8 ; size = 4 _printf PROC ; COMDAT ; File C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\stdio.h ; Line 954 push ebp mov ebp, esp sub esp, 8 ; Line 957 lea eax, DWORD PTR __Format$[ebp+4] mov DWORD PTR __ArgList$[ebp], eax ; Line 958 mov ecx, DWORD PTR __ArgList$[ebp] push ecx push 0 mov edx, DWORD PTR __Format$[ebp] push edx push 1 call ___acrt_iob_func add esp, 4 push eax call __vfprintf_l add esp, 16 ; 00000010H mov DWORD PTR __Result$[ebp], eax ; Line 959 mov DWORD PTR __ArgList$[ebp], 0 ; Line 960 mov eax, DWORD PTR __Result$[ebp] ; Line 961 mov esp, ebp pop ebp ret 0 _printf ENDP _TEXT ENDS ; Function compile flags: /Odtp ; COMDAT __vfprintf_l _TEXT SEGMENT __Stream$ = 8 ; size = 4 __Format$ = 12 ; size = 4 __Locale$ = 16 ; size = 4 __ArgList$ = 20 ; size = 4 __vfprintf_l PROC ; COMDAT ; File C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\stdio.h ; Line 642 push ebp mov ebp, esp ; Line 643 mov eax, DWORD PTR __ArgList$[ebp] push eax mov ecx, DWORD PTR __Locale$[ebp] push ecx mov edx, DWORD PTR __Format$[ebp] push edx mov eax, DWORD PTR __Stream$[ebp] push eax call ___local_stdio_printf_options mov ecx, DWORD PTR [eax+4] push ecx mov edx, DWORD PTR [eax] push edx call ___stdio_common_vfprintf add esp, 24 ; 00000018H ; Line 644 pop ebp ret 0 __vfprintf_l ENDP _TEXT ENDS ; Function compile flags: /Odtp ; COMDAT ___local_stdio_printf_options _TEXT SEGMENT ___local_stdio_printf_options PROC ; COMDAT ; File C:\Program Files (x86)\Windows Kits\10\include\10.0.17763.0\ucrt\corecrt_stdio_config.h ; Line 86 push ebp mov ebp, esp ; Line 88 mov eax, OFFSET ?_OptionsStorage@?1??__local_stdio_printf_options@@9@4_KA ; `__local_stdio_printf_options'::`2'::_OptionsStorage ; Line 89 pop ebp ret 0 ___local_stdio_printf_options ENDP _TEXT ENDS END
COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Copyright (c) GeoWorks 1992 -- All Rights Reserved PROJECT: PC GEOS MODULE: FILE: bigcalcBuildPCF.asm AUTHOR: Christian Puscasiu, Apr 29, 1992 ROUTINES: Name Description ---- ----------- INT BigCalcCheckNumberOfPCFs checkes whether there is a limit on the number of open PCFs. GLB BigCalcDestroyPCF Destroys a form INT BigCalcProcessBuildPCF actually builds the PCF INT BigCalcProcessCheckPCFExists checks whether a particular PCF exists already INT BigCalcProcessBuildNewPCF Builds the new template from the information in the DataResource INT BigCalcProcessBuildFixedArgsPCF duplicates the resource in which the blank PCF is INT BigCalcProcessBuildVariableArgsPCF EXT BigCalcLockDataResource Lock the DataResource block, and ensure all localization aspects are dealt with. INT UseMetricUnits Change from miles/gallons to kilometers/liters. INT UseLocalCurrencySymbol Do a string substitution for the $ INT InsertNewSymbol Do a search and replace of a character with a string REVISION HISTORY: Name Date Description ---- ---- ----------- CP 4/29/92 Initial revision andres 10/29/96 Don't need this for DOVE andres 11/18/96 Don't need this for PENELOPE DESCRIPTION: this file contains all the code to build out new PCF's $Id: bigcalcBuildPCF.asm,v 1.1 97/04/04 14:37:54 newdeal Exp $ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ COMMENT @%%%%%%%%%%%% DON'T NEED THIS FOR RESPONDER %%%%%%%%%%%%%%%%%%%%%%@ ProcessCode segment COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% PCFChooserGetNewPCFFromList %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: This is to get the ID from the FunctionChooser CALLED BY: PASS: *ds:si = PCFChooserClass object ds:di = PCFChooserClass instance data ds:bx = PCFChooserClass object (same as *ds:si) es = dgroup ax = message # RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- CP 4/22/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ PCFChooserNewPCFFromList method dynamic PCFChooserClass, MSG_PCF_CHOOSER_NEW_PCF_FROM_LIST uses ax, cx, dx, bp .enter ; ; see if we are over the allowable limit of PCFs ; call BigCalcCheckNumberOfPCFs ; ; get the PreCannedFunctionID ; mov si, ds:[di].PCFCI_chooserList.offset mov ax, MSG_GEN_ITEM_GROUP_GET_SELECTION call ObjCallInstanceNoLock push ax ; ; dismiss the Interaction ; mov cx, IC_DISMISS mov ax, MSG_GEN_GUP_INTERACTION_COMMAND call ObjCallInstanceNoLock pop cx call BigCalcProcessBuildPCF .leave ret PCFChooserNewPCFFromList endm COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BigCalcCheckNumberOfPCFs %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: checkes whether there is a limit on the number of open PCFs. CALLED BY: PASS: nothing RETURN: carry set if too many PCFs are about to be set carry unset if it is safe to open another PCF DESTROYED: nothing SIDE EFFECTS: If will close the one opened the longest time ago if the user is to go over the limit PSEUDO CODE/STRATEGY: REVISION HISTORY: Name Date Description ---- ---- ----------- CP 7/ 8/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ BigCalcCheckNumberOfPCFs proc near uses ax,bx,cx,dx,si,di,bp .enter push ds:[LMBH_handle] ; ; find the maximum allowable number of PCFs (if any) ; mov cx, cs mov dx, offset numberWSString ;cx:dx <- key mov ds, cx mov si, offset confString ;ds:si <- category call InitFileReadInteger pop bx call MemDerefDS ; ; if the category doesn't exist in the .ini file ; then the we can open as many as we want ; jc okToOpenNew tst ax jz okToOpenNew ; ; ax cobtains the # of children, so we want to see wether ; that's over the limit ; push ax mov bx, handle BigCalcPCFHolder mov si, offset BigCalcPCFHolder mov di, mask MF_CALL or mask MF_FIXUP_DS mov ax, MSG_GEN_COUNT_CHILDREN call ObjMessage pop ax cmp ax, dx jg okToOpenNew ; ; we need to close the last recently opened ; clr cx mov di, mask MF_CALL or mask MF_FIXUP_DS mov ax, MSG_GEN_FIND_CHILD_AT_POSITION call ObjMessage call BigCalcDestroyPCF okToOpenNew: .leave ret BigCalcCheckNumberOfPCFs endp confString char "bigcalc",0 numberWSString char "numberWS",0 COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BigCalcDestroyPCF %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Destroys a form CALLED BY: GLOBAL PASS: CX:DX = OD of form to be destroys RETURN: Nothing DESTROYED: AX, BX, CX, DX, DI, SI, BP PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: We can't use MSG_GEN_DESTROY_AND_FREE_BLOCK, as we are displayed non-modal windows that have Window menus that reside in a separate block. REVISION HISTORY: Name Date Description ---- ---- ----------- Don 10/11/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ BigCalcDestroyPCF proc near .enter if 0 ; Remove this child from the tree ; mov ax, MSG_GEN_REMOVE movdw bxsi, cxdx mov dl, VUM_NOW mov bp, mask CCF_MARK_DIRTY clr di call ObjMessage ; Destroy the object block itself ; mov ax, MSG_META_BLOCK_FREE clr di call ObjMessage else mov ax, MSG_GEN_DESTROY_AND_FREE_BLOCK movdw bxsi, cxdx clr di call ObjMessage endif .leave ret BigCalcDestroyPCF endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BigCalcProcessBuildPCF %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: actually builds the PCF CALLED BY: BigCalcProcesNewPCFFromList, BigCalcProcessNewPCF PASS: cx -- PreCannedFunctionID == Item# RETURN: nothing DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- CP 4/22/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ BigCalcProcessBuildPCF proc near uses ax,bx,cx,dx,si,di,bp .enter ; ; first I have to check wether the new PCF isn't already built ; out, so I will just bring it to the top ; call BigCalcProcessCheckPCFExists jc done ; ; build the PCF ; shl cx mov di, offset PCFDataTable add di, cx mov dx, cs:[di] push dx call BigCalcProcessBuildNewPCF movdw cxdx, bxsi ; ; ^lcx:dx is the optr of the new PCF ; mov bx, handle BigCalcPCFHolder mov si, offset BigCalcPCFHolder clr di mov bp, CCO_LAST or mask CCF_DIRTY mov ax, MSG_GEN_ADD_CHILD call ObjMessage movdw bxsi, cxdx ; ; set the newly added child usable ; clr di mov dl, VUM_NOW mov ax, MSG_GEN_SET_USABLE call ObjMessage pop dx clr di mov ax, MSG_PCF_INIT_INST_DATA call ObjMessage clr di mov ax, MSG_GEN_INTERACTION_INITIATE call ObjMessage done: ; ; after the PCF has been brought to live the focus will be put ; into the first field ; clr di mov ax, MSG_PCF_MAKE_FOCUS call ObjMessage .leave ret BigCalcProcessBuildPCF endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BigCalcProcessCheckPCFExists %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: checks whether a particular PCF exists already CALLED BY: PASS: cx = PreCannedFunctionID == Item# RETURN: cx:dx = PCF that has been brought up carry set if the PCF was found carry unset if not DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- CP 4/22/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ BigCalcProcessCheckPCFExists proc near uses ax,di,bp .enter mov bx, handle BigCalcPCFHolder mov si, offset BigCalcPCFHolder mov di, mask MF_CALL or mask MF_FIXUP_DS mov ax, MSG_PCF_HOLDER_BRING_PCF_TO_TOP call ObjMessage movdw bxsi, cxdx .leave ret BigCalcProcessCheckPCFExists endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BigCalcProcessBuildNewPCF %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Builds the new template from the information in the DataResource CALLED BY: BigCalcProcessBuildPCF PASS: dx == chunk handle to the data RETURN: cx:dx == optr to the new PCF DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- CP 4/29/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ BigCalcProcessBuildNewPCF proc near uses ax,cx,dx,di,bp .enter call BigCalcLockDataResource ; ; dereference the chunck handle ; mov bp, dx mov bp, es:[bp] ; ; get the first byte of info ; mov al, es:[bp] clr ah shl ax mov di, ax call MemUnlock ; ; call the appropriate function according to the PCFTType which ; is the first thing in the record in es:[bp] ; call cs:[BuildPCFTable][di] .leave ret BigCalcProcessBuildNewPCF endp BuildPCFTable word \ \ offset BigCalcProcessBuildVariableArgsPCF, offset BigCalcProcessBuildFixedArgsPCF COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BigCalcProcessBuildFixedArgsPCF %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: duplicates the resource in which the blank PCF is CALLED BY: BigCalcProcessBuildNewPCF PASS: nothing RETURN: ^lbx:si the new PCF DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- CP 4/29/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ BigCalcProcessBuildFixedArgsPCF proc near uses ax,cx .enter mov bx, handle FixedArgsPCFTemplateResource mov si, offset GenericFixedArgsPCF mov ax, -1 mov cx, -1 call ObjDuplicateResource .leave ret BigCalcProcessBuildFixedArgsPCF endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BigCalcProcessBuildVariableArgsPCF %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: CALLED BY: PASS: RETURN: ^lbx:si the new PCF DESTROYED: nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- CP 4/29/92 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ BigCalcProcessBuildVariableArgsPCF proc near uses ax,cx .enter mov bx, handle VariableArgsPCFTemplateResource mov si, offset GenericVariableArgsPCF mov ax, -1 mov cx, -1 call ObjDuplicateResource .leave ret BigCalcProcessBuildVariableArgsPCF endp ;---------------------------------------------------------------------------- ; Table (order important) ;---------------------------------------------------------------------------- PCFDataTable word \ offset AveragePCFData, offset CtermPCFData, offset DblDeclBalancePCFData, offset FutureValuePCFData, offset PaymentPCFData, offset PresentValuePCFData, offset RatePCFData, offset StandardDeviationPCFData, offset StraightLineDepPCFData, offset SumPCFData, offset SumOfYearDepPCFData, offset TermPCFData, offset VariancePCFData, offset SalesTaxPCFData, offset SalesTotalPCFData, offset ProfitMarginPCFData, offset MarkupCostPCFData, offset MarkupProfitPCFData, offset DiscountPCFData, offset BreakEvenPCFData, offset BreakevenProfitPCFData, offset HomeLoanPCFData, offset CarLoanPCFData, offset CollegePCFData, offset SavingsGoalPCFData, offset CarMilagePCFData, offset CarLeasePCFData, offset LoanAmountPCFData, offset LoanPmtPCFData, offset LoanInterestPCFData, offset HomeSalePCFData, offset HomePurLoanPCFData CheckHack <(length PCFDataTable) eq PreCannedFunctionID> COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BigCalcLockDataResource %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Lock the DataResource block, and ensure all localization aspects are dealt with. CALLED BY: EXTERNAL PASS: Nothing RETURN: AX = DataResource segment BX = DataResource handle ES = DataResource segment DESTROYED: Nothing PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- Don 10/14/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ BigCalcLockDataResource proc far uses di .enter ; ; Lock down the block. If the block has been discarded, ; we'll need to make all of our localization changes. ; mov bx, handle DataResource call MemLock mov es, ax assume es:DataResource mov di, es:[Discarded] cmp {byte} es:[di], BB_FALSE assume es:Nothing je done ; ; We need to setup the right strings for the worksheets. There, ; the currency symbol, gallons and miles need to be localized. ; First check the measurement system and change miles/gallons if ; we want to do metric. ; push ax, bx, cx, dx, si, ds mov ds, ax call LocalGetMeasurementType ; if metric, make it so cmp al, MEASURE_METRIC ; check for metric... jne doCurrency ; no, handle currency symbol ; ; change miles to kilometers and gallons to liters. ; call UseMetricUnits ; ; Handle using a different currency type. If it's $, we're OK. ; doCurrency: call UseLocalCurrencySymbol pop ax, bx, cx, dx, si, ds assume es:DataResource mov di, es:[Discarded] mov {byte} es:[di], BB_FALSE assume es:Nothing done: .leave ret BigCalcLockDataResource endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% UseMetricUnits %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Change from miles/gallons to kilometers/liters. CALLED BY: INTERNAL BigCalcLockDataResource PASS: DS, ES = DataResource segment RETURN: DS, ES = DataResource segment (may have moved) DESTROYED: AX, CX, DI, SI PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 9/28/93 Initial version %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ UseMetricUnits proc near .enter ; change the "miles" string first mov si, offset DataResource:MetricMiles mov di, es:[si] ; es:di -> call LocalStringSize ; cx = string size add cx, 2 ; 2 more for poss DBCS mov ax, offset MilesText call LMemReAlloc ; resize chunk mov si, ds:[si] ; ds:si -> source mov di, ax mov di, es:[di] ; es:di -> dest sub cx, 2 rep movsb ; copy the string over clr ax stosw ; store DBCS NULL ; now change the "gallons" string. mov si, offset MetricGallons ; ax = chunk handle mov di, es:[si] ; es:di -> call LocalStringSize ; cx = string size add cx, 2 ; 2 more for poss DBCS mov ax, offset GallonsText call LMemReAlloc ; resize chunk mov si, ds:[si] ; ds:si -> source mov di, ax mov di, es:[di] ; es:di -> dest sub cx, 2 rep movsb ; copy the string over clr ax stosw ; store DBCS NULL .leave ret UseMetricUnits endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% UseLocalCurrencySymbol %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Do a string substitution for the $ CALLED BY: INTERNAL BigCalcLockDataResource PASS: DS, ES = DataResource segment RETURN: DS, ES = DataResource segment (updated) DESTROYED: AX, BX, CX, DX, DI, SI PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 9/28/93 Initial version witt 11/12/93 DBCS-zied for wider buffer; sizes not lengths %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ UseLocalCurrencySymbol proc far curStringSize local word newStringSize local word currencySize local word SBCS< currencyBuffer local CURRENCY_SYMBOL_LENGTH dup (char) > DBCS< currencyBuffer local CURRENCY_SYMBOL_LENGTH dup (word) > .enter ForceRef curStringSize ForceRef newStringSize ; get the current currency symbol. segmov es, ss, di lea di, ss:currencyBuffer call LocalGetCurrencyFormat ; es:di -> null-term string call LocalStringSize ; cx = string size mov ss:currencySize, cx ; now that we have the string, lock down the resource and ; replace the string. segmov es, ds, ax mov ax, 1 ; looking for a hex 1 mov si, offset DataResource:DollarText call InsertNewSymbol ; replace char in each string mov si, offset DataResource:DollarYearText call InsertNewSymbol mov si, offset DataResource:DollarMonthText call InsertNewSymbol mov si, offset DataResource:DollarUnitText call InsertNewSymbol .leave ret UseLocalCurrencySymbol endp COMMENT @%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% InsertNewSymbol %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% SYNOPSIS: Do a search and replace of a character with a string CALLED BY: INTERNAL UseLocalCurrencySymbol PASS: ds - locked resource with strings to replace es == ds si - chunk handle of string to replace ax - character to search for (unused) inherited local vars from UseLocalCurrencySymbol RETURN: nothing DESTROYED: CX, DI, SI PSEUDO CODE/STRATEGY: KNOWN BUGS/SIDE EFFECTS/IDEAS: REVISION HISTORY: Name Date Description ---- ---- ----------- jim 9/28/93 Initial version witt 11/12/93 DBCS-ized, uses size instead of length %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%@ InsertNewSymbol proc near uses ax .enter inherit UseLocalCurrencySymbol mov di, ds:[si] ; es:di -> text call LocalStringSize ; get current size mov curStringSize, cx ; save current size add cx, currencySize ; add in new string size mov newStringSize, cx ; save new string size add cx, 2 ; add in enuf for DBCS nullterm mov ax, si ; ax = chunk handle call LMemReAlloc ; resize the chunk ; now that the chunk is bigger, find the replacement char ; and nudge the rest of the existing string down a bit. mov di, ds:[si] ; es:di -> string mov si, di ; ds:si -> string mov ax, 1 ; find \\\1 in UI resource LocalFindChar ; es:di -> after char push di push si ; save initial offset add si, curStringSize ; point to end of new string add si, currencySize ; length of both minus escape LocalPrevChar dssi mov {word} ds:[si], 0 ; store DBCS null at end xchg di, si ; si = after escape position LocalPrevChar esdi ; di = destination pop ax ; ax = initial position sub ax, si ; -(# bytes past esc) add ax, curStringSize ; # bytes to copy at string end mov cx, ax add si, cx ; copy from end of string LocalPrevChar dssi std rep movsb cld pop di LocalPrevChar esdi segmov ds, ss, si lea si, currencyBuffer mov cx, currencySize rep movsb segmov ds, es, di ; restore DS .leave ret InsertNewSymbol endp ProcessCode ends
; A163608: a(n) = ((5 + 2*sqrt(2))*(2 + sqrt(2))^n + (5 - 2*sqrt(2))*(2 - sqrt(2))^n)/2. ; 5,14,46,156,532,1816,6200,21168,72272,246752,842464,2876352,9820480,33529216,114475904,390845184,1334428928,4556025344,15555243520,53108923392,181325206528,619082979328,2113681504256,7216560058368,24638877224960,84122388783104,287211800682496,980602425163776,3347986099290112,11430739546832896,39026985988751360,133246464861339648,454931887467855872,1553234620148744192,5303074705659265024,18105829582339571712,61817168918039756800,211057016507479883776,720593728193840021504,2460260879760400318464 mov $1,5 mov $2,4 lpb $0 sub $0,1 sub $1,2 mul $2,2 add $2,$1 add $1,$2 lpe mov $0,$1
.global s_prepare_buffers s_prepare_buffers: push %r11 push %r14 push %r8 push %r9 push %rcx push %rdi push %rdx push %rsi lea addresses_WC_ht+0x14f3d, %r9 nop nop nop nop nop dec %r11 mov $0x6162636465666768, %rdi movq %rdi, %xmm4 vmovups %ymm4, (%r9) nop nop nop nop xor $7218, %r14 lea addresses_UC_ht+0x161dc, %rsi lea addresses_D_ht+0x16fc, %rdi nop nop add %rdx, %rdx mov $11, %rcx rep movsb nop nop xor %r11, %r11 lea addresses_D_ht+0x163c, %rcx nop nop nop sub %rdx, %rdx mov (%rcx), %r14w nop nop nop cmp %rdi, %rdi lea addresses_WC_ht+0x50dc, %rsi lea addresses_A_ht+0x1a53c, %rdi clflush (%rsi) nop nop nop sub $20236, %r8 mov $61, %rcx rep movsb nop nop nop add %rsi, %rsi lea addresses_UC_ht+0xb11c, %rsi lea addresses_WT_ht+0x1c4ec, %rdi nop and %r11, %r11 mov $127, %rcx rep movsl nop nop nop nop cmp %r9, %r9 lea addresses_A_ht+0x16e3c, %rsi add %rdx, %rdx mov $0x6162636465666768, %rdi movq %rdi, (%rsi) nop nop nop sub $49474, %rcx lea addresses_UC_ht+0x4e34, %r14 clflush (%r14) nop nop nop inc %r8 mov (%r14), %esi nop nop nop add %r9, %r9 lea addresses_WT_ht+0xac3c, %rcx nop dec %r8 mov $0x6162636465666768, %rsi movq %rsi, %xmm6 vmovups %ymm6, (%rcx) nop nop nop nop cmp %r9, %r9 lea addresses_WC_ht+0x70bc, %rdi dec %rsi mov $0x6162636465666768, %r11 movq %r11, (%rdi) nop nop nop cmp $15640, %r8 pop %rsi pop %rdx pop %rdi pop %rcx pop %r9 pop %r8 pop %r14 pop %r11 ret .global s_faulty_load s_faulty_load: push %r11 push %r12 push %r13 push %r15 push %rbp push %rdi push %rsi // Faulty Load lea addresses_D+0xe3c, %r15 nop nop and $44143, %r11 mov (%r15), %rdi lea oracles, %rsi and $0xff, %rdi shlq $12, %rdi mov (%rsi,%rdi,1), %rdi pop %rsi pop %rdi pop %rbp pop %r15 pop %r13 pop %r12 pop %r11 ret /* <gen_faulty_load> [REF] {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D', 'NT': True, 'AVXalign': False, 'size': 1, 'congruent': 0}} [Faulty Load] {'OP': 'LOAD', 'src': {'same': True, 'type': 'addresses_D', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 0}} <gen_prepare_buffer> {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 0}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 5, 'type': 'addresses_UC_ht'}, 'dst': {'same': False, 'congruent': 4, 'type': 'addresses_D_ht'}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_D_ht', 'NT': False, 'AVXalign': True, 'size': 2, 'congruent': 11}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 4, 'type': 'addresses_WC_ht'}, 'dst': {'same': False, 'congruent': 8, 'type': 'addresses_A_ht'}} {'OP': 'REPM', 'src': {'same': False, 'congruent': 4, 'type': 'addresses_UC_ht'}, 'dst': {'same': False, 'congruent': 4, 'type': 'addresses_WT_ht'}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_A_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 11}} {'OP': 'LOAD', 'src': {'same': False, 'type': 'addresses_UC_ht', 'NT': False, 'AVXalign': True, 'size': 4, 'congruent': 3}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WT_ht', 'NT': False, 'AVXalign': False, 'size': 32, 'congruent': 9}} {'OP': 'STOR', 'dst': {'same': False, 'type': 'addresses_WC_ht', 'NT': False, 'AVXalign': False, 'size': 8, 'congruent': 7}} {'36': 21829} 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 36 */
; A158633: a(n) = 529*n^2 - 23. ; 506,2093,4738,8441,13202,19021,25898,33833,42826,52877,63986,76153,89378,103661,119002,135401,152858,171373,190946,211577,233266,256013,279818,304681,330602,357581,385618,414713,444866,476077,508346,541673,576058,611501,648002,685561,724178,763853,804586,846377,889226,933133,978098,1024121,1071202,1119341,1168538,1218793,1270106,1322477,1375906,1430393,1485938,1542541,1600202,1658921,1718698,1779533,1841426,1904377,1968386,2033453,2099578,2166761,2235002,2304301,2374658,2446073,2518546,2592077,2666666,2742313,2819018,2896781,2975602,3055481,3136418,3218413,3301466,3385577,3470746,3556973,3644258,3732601,3822002,3912461,4003978,4096553,4190186,4284877,4380626,4477433,4575298,4674221,4774202,4875241,4977338,5080493,5184706,5289977 mov $1,2 add $1,$0 mul $1,$0 mul $1,529 add $1,506 mov $0,$1
/**************************************************************************************************************************** esp32_tcp.hpp For WebSockets2_Generic Library Based on and modified from Gil Maimon's ArduinoWebsockets library https://github.com/gilmaimon/ArduinoWebsockets to support STM32F/L/H/G/WB/MP1, nRF52, SAMD21/SAMD51, SAM DUE, Teensy boards besides ESP8266 and ESP32 The library provides simple and easy interface for websockets (Client and Server). Built by Khoi Hoang https://github.com/khoih-prog/Websockets2_Generic Licensed under MIT license Version: 1.2.3 Version Modified By Date Comments ------- ----------- ---------- ----------- 1.0.0 K Hoang 14/07/2020 Initial coding/porting to support nRF52 and SAMD21/SAMD51 boards. Add SINRIC/Alexa support 1.0.1 K Hoang 16/07/2020 Add support to Ethernet W5x00 to nRF52, SAMD21/SAMD51 and SAM DUE boards 1.0.2 K Hoang 18/07/2020 Add support to Ethernet ENC28J60 to nRF52, SAMD21/SAMD51 and SAM DUE boards 1.0.3 K Hoang 18/07/2020 Add support to STM32F boards using Ethernet W5x00, ENC28J60 and LAN8742A 1.0.4 K Hoang 27/07/2020 Add support to STM32F/L/H/G/WB/MP1 and Seeeduino SAMD21/SAMD51 using Ethernet W5x00, ENC28J60, LAN8742A and WiFiNINA. Add examples and Packages' Patches. 1.0.5 K Hoang 29/07/2020 Sync with ArduinoWebsockets v0.4.18 to fix ESP8266 SSL bug. 1.0.6 K Hoang 06/08/2020 Add non-blocking WebSocketsServer feature and non-blocking examples. 1.0.7 K Hoang 03/10/2020 Add support to Ethernet ENC28J60 using EthernetENC and UIPEthernet v2.0.9 1.1.0 K Hoang 08/12/2020 Add support to Teensy 4.1 using NativeEthernet 1.2.0 K Hoang 16/04/2021 Add limited support (client only) to ESP32-S2 and LAN8720 for STM32F4/F7 1.2.1 K Hoang 16/04/2021 Add support to new ESP32-S2 boards. Restore Websocket Server function for ESP32-S2. 1.2.2 K Hoang 16/04/2021 Add support to ESP32-C3 1.2.3 K Hoang 02/05/2021 Update CA Certs and Fingerprint for EP32 and ESP8266 secured exampled. *****************************************************************************************************************************/ #pragma once #ifdef ESP32 #include <Tiny_Websockets_Generic/internals/ws_common.hpp> #include <Tiny_Websockets_Generic/network/tcp_client.hpp> #include <Tiny_Websockets_Generic/network/tcp_server.hpp> #include <Tiny_Websockets_Generic/network/generic_esp/generic_esp_clients.hpp> #include <WiFi.h> #include <HTTPClient.h> namespace websockets2_generic { namespace network2_generic { typedef GenericEspTcpClient<WiFiClient> Esp32TcpClient; class SecuredEsp32TcpClient : public GenericEspTcpClient<WiFiClientSecure> { public: void setCACert(const char* ca_cert) { this->client.setCACert(ca_cert); } void setCertificate(const char* client_ca) { this->client.setCertificate(client_ca); } void setPrivateKey(const char* private_key) { this->client.setPrivateKey(private_key); } void setInsecure() { this->client.setInsecure(); } }; class Esp32TcpServer : public TcpServer { public: Esp32TcpServer() {} bool poll() override { yield(); return server.hasClient(); } bool listen(const uint16_t port) override { yield(); server = WiFiServer(port); server.begin(port); return available(); } TcpClient* accept() override { while (available()) { auto client = server.available(); if (client) { return new Esp32TcpClient{client}; } // KH, from v1.0.6, add to enable non-blocking when no WS Client else { // Return NULL Client. Remember to test for NULL and process correctly return NULL; } } return new Esp32TcpClient; } bool available() override { yield(); return static_cast<bool>(server); } void close() override { yield(); server.close(); } virtual ~Esp32TcpServer() { if (available()) close(); } protected: int getSocket() const override { return -1; // Not Implemented } private: WiFiServer server; }; } // namespace network2_generic } // namespace websockets2_generic #endif // #ifdef ESP32
; Listing generated by Microsoft (R) Optimizing Compiler Version 19.00.23506.0 TITLE D:\scottsdocs\sourcecode\OpenGLboxes\code\box.cpp .686P .XMM include listing.inc .model flat INCLUDELIB MSVCRTD INCLUDELIB OLDNAMES END
// Copyright 2013 Daniel Parker // Distributed under the Boost license, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // See https://sourceforge.net/projects/jsoncons/files/ for latest version // See https://sourceforge.net/p/jsoncons/wiki/Home/ for documentation. #ifndef JSONCONS_JSONCONS_CONFIG_HPP #define JSONCONS_JSONCONS_CONFIG_HPP #include <stdexcept> #include <string> #include <sstream> #include <vector> #include <istream> #include <ostream> #include <iomanip> #include <cstdlib> #include <cmath> #include <cstdarg> #include <limits> // std::numeric_limits #define JSONCONS_NO_MACRO_EXP namespace jsoncons { // Follow boost #if defined (__clang__) # if defined(_GLIBCXX_USE_NOEXCEPT) # define JSONCONS_NOEXCEPT _GLIBCXX_USE_NOEXCEPT # else # define JSONCONS_NOEXCEPT noexcept # endif #elif defined(__GNUC__) # define JSONCONS_NOEXCEPT _GLIBCXX_USE_NOEXCEPT #else # define JSONCONS_NOEXCEPT #endif #ifdef _MSC_VER #pragma warning( disable : 4290 ) inline bool is_nan(double x) { return _isnan( x ) != 0; } inline bool is_inf(double x) { return !_finite(x) && !_isnan(x); } inline bool is_pos_inf(double x) { return is_inf(x) && x > 0; } inline bool is_neg_inf(double x) { return is_inf(x) && x < 0; } inline int c99_vsnprintf(char* str, size_t size, const char* format, va_list ap) { int count = -1; if (size != 0) count = _vsnprintf_s(str, size, _TRUNCATE, format, ap); if (count == -1) count = _vscprintf(format, ap); return count; } inline int c99_snprintf(char* str, size_t size, const char* format, ...) { int count; va_list ap; va_start(ap, format); count = c99_vsnprintf(str, size, format, ap); va_end(ap); return count; } #else inline bool is_nan(double x) { return std::isnan( x ); } inline bool is_pos_inf(double x) {return std::isinf(x) && x > 0;} inline bool is_neg_inf(double x) {return std::isinf(x) && x > 0;} #if __cplusplus >= 201103L #define c99_snprintf snprintf #else #define c99_snprintf std::snprintf #endif #endif #ifdef _MSC_VER template <typename Char> std::basic_string<Char> float_to_string(double val, size_t precision) { std::basic_string<Char> s; char buf[_CVTBUFSIZE]; int decimal_point = 0; int sign = 0; if (precision >= _CVTBUFSIZE) { precision = _CVTBUFSIZE - 1; } int err = _ecvt_s(buf, _CVTBUFSIZE, val, static_cast<int>(precision), &decimal_point, &sign); if (err != 0) { throw std::runtime_error("Failed attempting double to string conversion"); } if (sign != 0) { s.push_back('-'); } int len = static_cast<int>(precision); int decimal; int exponent; if (decimal_point < 0 || decimal_point > len) { decimal = 1; exponent = decimal_point - 1; } else { decimal = decimal_point; exponent = 0; } while (len >= 2 && buf[len - 1] == '0' && (len - 1) != decimal) { --len; } if (decimal == 0) { s.push_back('0'); s.push_back('.'); } s.push_back(buf[0]); for (int i = 1; i < len; ++i) { if (i == decimal) { s.push_back('.'); } s.push_back(buf[i]); } if (exponent != 0) { s.push_back('e'); if (exponent > 0) { s.push_back('+'); } int err2 = _itoa_s(exponent,buf,_CVTBUFSIZE,10); if (err2 != 0) { throw std::runtime_error("Failed attempting double to string conversion"); } for (int i = 0; i < _CVTBUFSIZE && buf[i]; ++i) { s.push_back(buf[i]); } } return s; } #else template <typename Char> std::basic_string<Char> float_to_string(double val, size_t precision) { std::basic_ostringstream<Char> os; os.imbue(std::locale::classic()); os << std::showpoint << std::setprecision(precision) << val; std::basic_string<Char> s(os.str()); typename std::basic_string<Char>::size_type exp_pos= s.find('e'); std::basic_string<Char> exp; if (exp_pos != std::basic_string<Char>::npos) { exp = s.substr(exp_pos); s.erase(exp_pos); } int len = s.size(); while (len >= 2 && s[len - 1] == '0' && s[len - 2] != '.') { --len; } s.erase(len); if (exp_pos != std::basic_string<Char>::npos) { s.append(exp); } return s; } #endif #ifdef _MSC_VER inline double string_to_float(const std::string& s) { static _locale_t locale = _create_locale(LC_NUMERIC, "C"); const char* begin = &s[0]; char* end = const_cast<char*>(begin)+s.size(); double val = _strtod_l(begin,&end,locale); if (begin == end) { throw std::invalid_argument("Invalid float value"); } return val; } inline double string_to_float(const std::wstring& s) { static _locale_t locale = _create_locale(LC_NUMERIC, "C"); const wchar_t* begin = &s[0]; wchar_t* end = const_cast<wchar_t*>(begin)+s.size(); double val = _wcstod_l(begin,&end,locale); if (begin == end) { throw std::invalid_argument("Invalid float value"); } return val; } #else template <typename Char> inline double string_to_float(const std::basic_string<Char>& s) { std::basic_istringstream<Char> ss(s); ss.imbue(std::locale::classic()); double val; ss >> val; if (ss.fail()) { throw std::invalid_argument("Invalid float value"); } return val; } #endif } #endif
; A007160: Number of diagonal dissections of a convex (n+6)-gon into n regions. ; Submitted by Jamie Morken(s2) ; 1,20,225,1925,14014,91728,556920,3197700,17587350,93486536,483367885,2442687975,12109051500,59053512000,283963030560,1348824395160,6338392712550,29503515951000,136173391604250,623760137794794,2837765901615876,12830687578253600,57687379921990000,258036428781495000,1148778180935215740,5092251470031437712,22482616666565081565,98895396544366364075,433523488531780456600,1894348154025766188288,8252975559922289612416,35854933598114873081840,155364230812405655190150,671562047460616464310200 mov $2,$0 mul $0,2 add $0,6 bin $0,$2 mov $1,$2 add $1,4 bin $1,3 mul $0,$1 div $0,4
.model small .stack 100h .data bytes db 65,66 words dw 45h .code mov ax, @data mov ds, ax mov bp, offset words mov ax, 82h mov si,0 sub word ptr [ds:bp],2 mov ax, [ds:bp] ;despliega cx veces lo que esta contenido en AL mov AH,0ah xor bx,bx mov cx,1 int 10h fin: mov ah,4ch int 21h end
// Copyright (c) 2017 The STRAKS developers // Copyright (c) 2017-2018 The Methuselah Developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #if defined(HAVE_CONFIG_H) #include "config/methuselah-config.h" #endif #include <cstddef> #if defined(HAVE_SYS_SELECT_H) #include <sys/select.h> #endif extern "C" void* memcpy(void* a, const void* b, size_t c); void* memcpy_int(void* a, const void* b, size_t c) { return memcpy(a, b, c); } namespace { // trigger: Use the memcpy_int wrapper which calls our internal memcpy. // A direct call to memcpy may be optimized away by the compiler. // test: Fill an array with a sequence of integers. memcpy to a new empty array. // Verify that the arrays are equal. Use an odd size to decrease the odds of // the call being optimized away. template <unsigned int T> bool sanity_test_memcpy() { unsigned int memcpy_test[T]; unsigned int memcpy_verify[T] = {}; for (unsigned int i = 0; i != T; ++i) memcpy_test[i] = i; memcpy_int(memcpy_verify, memcpy_test, sizeof(memcpy_test)); for (unsigned int i = 0; i != T; ++i) { if (memcpy_verify[i] != i) return false; } return true; } #if defined(HAVE_SYS_SELECT_H) // trigger: Call FD_SET to trigger __fdelt_chk. FORTIFY_SOURCE must be defined // as >0 and optimizations must be set to at least -O2. // test: Add a file descriptor to an empty fd_set. Verify that it has been // correctly added. bool sanity_test_fdelt() { fd_set fds; FD_ZERO(&fds); FD_SET(0, &fds); return FD_ISSET(0, &fds); } #endif } // anon namespace bool glibc_sanity_test() { #if defined(HAVE_SYS_SELECT_H) if (!sanity_test_fdelt()) return false; #endif return sanity_test_memcpy<1025>(); }