
    
Jj5                    <   d Z ddlmZ ddlZddlZddlZddlmZ ddlm	Z	  ee
      j                         j                  d   Zedz  ZdZd	Zg d
Zg dZddddddddddddgZddZddZ	 	 	 	 	 	 	 	 	 	 ddZd dZd dZedfd!dZd"dZedk(  r e        yy)#zISummarize the static-default effect of opcode 0x24 mode 1 on object+0x61.    )annotationsN)Path)Any   outmap1_01amap2_02d)zruntime-mode1-source-producerzobject61-route-control-effectzstrict-source-hotspot)zAruntime write/read trace for 0x0059e348 around opcode 0x24 mode 1zBproof that object+0x61 selects a current-route control-flow targetz?strict map1_01a source coordinate or event hotspot for map2_02dz5out/save_selector_opcode24_mode1_runtime_context.jsonz'mode1 source runtime-producer proof gap)pathdescriptionz)out/save_selector_object61_consumers.jsonz,object+0x61 consumer groups and route impactz/out/save_selector_object61_stream_operands.jsonz-current route object+0x61 stream operand scanz"out/runtime_trace_feasibility.jsonz"runtime trace availability blockerc                p    | j                         s|S t        j                  | j                  d            S )Nutf-8encoding)existsjsonloads	read_text)r
   fallbacks     R/home/exedev/hwanse/tools/summarize_save_selector_opcode24_mode1_default_effect.py	load_jsonr   "   s*    ;;=::dnngn677    c                    | y d| dz  dS )N0x   02x )values    r   hex_byter   (   s    }S!""r   c                   |j                  d      xs i }| j                  d      xs i }| j                  d      xs i }|j                  d      }t        |t              r|dz   nd }|j                  d      xs g }	|	r|	d   ni }
|j                  d      xs g D cg c]5  }|j                  d	      |j                  d
      |j                  d      d7 }}d}i dt        dt        d|j                  d      d|j                  d      d|j                  d      d|j                  d      d|j                  d      d|j                  d      d|j                  d      d|j                  d      d|j                  d      du d|j                  d       du d!|d"t        |      d#t        |      d$|d%|j                  d%      i d&|j                  d&      d'|j                  d'      d(|j                  d(      d)|j                  d)      d*|
j                  d+      |
j                  d,      |
j                  d-      |
j                  d.      |
j                  d/      |
j                  d0      |
j                  d1      |
j                  d2      d3d4dd5d6d7d6d8dd9dd:t        d;t        d<t        d=t        t              d>d?d@g dAdB|S c c}w )CNstoragecurrentBoundarycurrentModestaticInitialValue   branchCapableRowsr   groupsnamerangerouteImpact)r'   r(   r)   aa  With the current static evidence, opcode 0x24 mode 1 reads the zero-filled byte 0x0059e348 and would write object+0x61 = 3 at process start. The existing object+0x61 consumers use that field as linked-object state, and the current map1_01a->map2_02d stream operands contain no frontier leaf, frontier reader, or false-target operand. The only branch-capable row is opcode 0x2f at 0x00542e74, whose dword [stream+4] is 0x00001618 for map2_16j.cns. Therefore the static/default mode1 effect is not route promotion evidence; a runtime producer trace for 0x0059e348 or a strict map1_01a hotspot is still required.sourcetargetopcodeVaHexopcodeValueHexcurrentModeByteHexstreamPlus1HexcurrentModeTargetHextargetVaHexmode1SourceHex mode1SourceStaticInitialValueHexstaticInitialValueHex!mode1SourceStaticInitialValueKindstaticInitialValueKindmode1SourceHasRawBytemode1SourceSaveBackednotSavedataBackedFmode1SourceHasStaticProducernoStaticProducerdefaultObject61ValuedefaultObject61ValueHexobject61ConsumerGroupCountobject61ConsumerGroupsobjectHandlerOpcodeCountrouteOperandRowCountbranchCapableRowCountdirectFrontierOperandCountbranchFrontierOperandCountbranchOperand	wordVaHex	opcodeHexhandlerVaHexvalueHexvalueMeaningnextDwordHexnextDwordKindcns)rF   rG   rH   rI   rJ   rK   rL   rM   staticDefaultPromotesRouteruntimeProducerRequiredTstrictHotspotRequired
proofFound$opcode24Mode1DefaultEffectProofFound'failedOpcode24Mode1DefaultEffectGateIdsmissingEvidenceevidenceRefsevidenceRefCountpromotionStatusblockedremainingProofs)zKcapture a runtime write/read trace for 0x0059e348 around opcode 0x24 mode 1zNprove object+0x61 selects a current-route control-flow target, if it ever doeszFfind a strict map1_01a source coordinate or event hotspot for map2_02d
conclusion)
get
isinstanceintSOURCETARGETr   len-FAILED_OPCODE24_MODE1_DEFAULT_EFFECT_GATE_IDS.OPCODE24_MODE1_DEFAULT_EFFECT_MISSING_EVIDENCE+OPCODE24_MODE1_DEFAULT_EFFECT_EVIDENCE_REFS)opcode24_handlermode1_runtime_contextobject61_consumersobject61_stream_operandsr    current_boundarycurrent_modesource_valuedefault_object61_valuebranch_rowsbranchgroupobject_groupsrZ   s                 r   build_summaryrp   .   s    $''	28bG'++,=>D"#''6<"L;;34L1;L#1N\A-TX*../BCIrK*[^F (++H5; 	 IIf%YYw' 99]3	
M 	X 0&0&0 	'++M:0 	*../?@	0
 	.223CD0 	 0 0 ?0 	/334DE0 	+GKK8O,P0 	,W[[9Q-R0 	 -D!E0 	 !6!:!:;N!OSX!X0 	'(=(A(ABT(UY^(^0 	 60 	"8,B#C0 	%c-&80  	!-!0" 	#$<$@$@A[$\#0$ 	 8 < <=S T%0& 	 !9!=!=>U!V'0( 	%&>&B&BC_&`)0* 	%&>&B&BC_&`+0, 	K0K0"JJ~6

:."JJ~6"JJ~6#ZZ8::e$	
-0@ 	%eA0B 	"4C0D 	 E0F 	eG0H 	/I0J 	23`K0L 	IM0N 	CO0P 	C KLQ0R 	9S0T 	 
U0^ 	j_0 0!s   :K c                   | j                  d      xs i }ddd| d    d| d    dd	| j                  d
       d| j                  d       dd| j                  d       dd| j                  d       dd| j                  d       d| j                  d       dd| j                  d       dd| j                  d       d| j                  d       d| j                  d       d| j                  d       d | j                  d!       d"| j                  d#       d$|j                  d%       d&|j                  d'       d(|j                  d)       d*|j                  d+       d	d,| j                  d-       d.| d/    dd0| d1    dd2| j                  d3       dd| d4   dd5dg}|j                  d6 | d7   D               |j                  g d8       |j                  d9 | d:   D               |j                  g d;       |j                  d< | d=   D               |j                  g d>       | j                  d?      xs g D ]J  }|j                  d@|j                  dA       dB|j                  dC       dD|j                  dE       dF       L |j                  g dG       |j                  dH | j                  dI      xs g D               |j                  d       dJj                  |      S )KNrE   z0# Save Selector Opcode 0x24 Mode1 Default Effect z
- route: `r*   z -> r+   `z- opcode: `r,   z	` value `r-   z- mode target: `r0   z- mode1 source: `r2   z- static source value: `r3   z` (r5   )z- default object+0x61 value: `r=   z- save-backed source: r8   z- static source producer: r:   z- object+0x61 consumer groups: r>   z- route operand rows: rA   z- direct frontier operands: rC   z- branch frontier operands: rD   z- branch operand: `rF   z
` opcode `rG   z` next `rK   z` `rM   z!- static default promotes route: rN   z- proofFound: `rQ   z)- opcode24Mode1DefaultEffectProofFound: `rR   z- promotion status: `rW   rZ   z## Failed Gatesc              3  (   K   | ]
  }d | d  yw)- `rs   Nr   .0items     r   	<genexpr>zmarkdown.<locals>.<genexpr>   s     ^43tfA^s   rS   )rr   z## Missing Evidencerr   c              3  &   K   | ]	  }d |   ywz- Nr   rw   s     r   rz   zmarkdown.<locals>.<genexpr>   s     D2dVD   rT   )rr   z## Evidence Refsrr   c              3  8   K   | ]  }d |d    d|d      yw)rv   r
   z`: r   Nr   rx   rows     r   rz   zmarkdown.<locals>.<genexpr>   s/       c&k]#c-012s   rU   )rr   z## Object+0x61 Consumer Groupsrr   z | group | range | route impact |z| --- | --- | --- |r?   z| r'   z | `r(   z` | r)   z |)rr   z## Remaining Proofsrr   c              3  &   K   | ]	  }d |   ywr|   r   rw   s     r   rz   zmarkdown.<locals>.<genexpr>   s     N2dVNr}   rY   
)r[   extendappendjoin)summaryrm   linesrn   s       r   markdownr   ~   s{   [[)/RF:

WX&'tGH,=+>a@
gkk-017;;GW;X:YYZ[
7;;'=>?qA
GKK(89:!<
"7;;/Q#R"SSVW^WbWb  dG  XH  WI  IJ  	K
(5N)O(PPQR
 -D!E FG
$W[[1O%P$QR
)'++6R*S)TU
 -C!D EF
&w{{3O'P&QR
&w{{3O'P&QR
fjj56jKAX@YYabhblblm{b|a}  ~A  BH  BL  BL  MR  BS  AT  TU  	V
+GKK8T,U+VW
',/02
3G<b4c3ddef
,= >?qA


1E4 
LL^73\+]^^	LL  
 
LLD1B)CDD	LL  
 
LL >*  
LL   56<" gr%))F+,D71C0DDS`IaHbbdefg	LL01	LLN5F)G)M2NN	LL99Ur   c                   | j                  d      xs i }dj                  d | j                  d      xs g D              }dj                  d | j                  d      xs g D              }dj                  d | d	   D              }dj                  d
 | d   D              }dj                  d | d   D              }dj                  g dddddt        j                  | d          dt        j                  | d          ddt        j                  t	        | j                  d                   dt        j                  t	        | j                  d                   ddt        j                  t	        | j                  d                   ddt        j                  t	        | j                  d                   ddt        j                  t	        | j                  d                    d!t        j                  t	        | j                  d"                   d#d$t        j                  t	        | j                  d%                   dd&| j                  d'       d(d)| j                  d*       d(d+| j                  d,       d(d-| j                  d.       d(d/| j                  d0       d(d1| j                  d2       d(d3t        j                  t	        |j                  d4                   d5t        j                  t	        |j                  d6                   d7t        j                  t	        |j                  d8                   d9t        j                  t	        |j                  d:                   d	d;| j                  d<       d(d=t        j                  t	        | d>                dd?t        j                  t	        | j                  d@                   ddAdBt        j                  | dC          dDdEd| dAdFd| dAdGd| dAdHdI|dJdK|dA      S )LNrE   r   c              3  6  K   | ]  }d t        j                  t        |j                  d                   dt        j                  t        |j                  d                   dt        j                  t        |j                  d                   d  yw)z<tr><td>r'   z</td><td><code>r(   z</code></td><td>r)   z
</td></tr>N)htmlescapestrr[   )rx   rn   s     r   rz   zhtml_page.<locals>.<genexpr>   s       	{{3uyy0123 4[[UYYw%7!89: ;{{3uyy789: ;	s   BBr?   c              3  `   K   | ]&  }d t        j                  t        |             d ( ywz<li></li>N)r   r   r   rw   s     r   rz   zhtml_page.<locals>.<genexpr>   s'     mdkk#d)45U;ms   ,.rY   rr   c              3  N   K   | ]  }d t        j                  |       d  yw)
<li><code></code></li>Nr   r   rw   s     r   rz   zhtml_page.<locals>.<genexpr>   s+       T[[&'|4   #%rS   c              3  N   K   | ]  }d t        j                  |       d  ywr   r   rw   s     r   rz   zhtml_page.<locals>.<genexpr>   s+       t{{4 !'r   rT   c              3     K   | ]9  }d t        j                  |d          dt        j                  |d          d ; yw)r   r
   z	</code>: r   r   Nr   r   s     r   rz   zhtml_page.<locals>.<genexpr>   sE       T[[V-.iCDV8W7XX]^s   ?ArU   zb<!doctype html><meta charset="utf-8"><title>Save Selector Opcode 0x24 Mode1 Default Effect</title>z<style>body{font-family:system-ui,sans-serif;background:#111;color:#eee}table{border-collapse:collapse;max-width:1400px}td,th{border:1px solid #444;padding:6px 8px;vertical-align:top}code{color:#9bd4ff}</style>z7<h1>Save Selector Opcode 0x24 Mode1 Default Effect</h1>z<ul>z<li>route: <code>r*   z -&gt; r+   r   z<li>opcode: <code>r,   z</code> value <code>r-   z<li>mode target: <code>r0   z<li>mode1 source: <code>r2   z<li>static source value: <code>r3   z	</code> (r5   z)</li>z%<li>default object+0x61 value: <code>r=   z<li>save-backed source: r8   r   z<li>static source producer: r:   z!<li>object+0x61 consumer groups: r>   z<li>route operand rows: rA   z<li>direct frontier operands: rC   z<li>branch frontier operands: rD   z<li>branch operand: <code>rF   z</code> opcode <code>rG   z</code> next <code>rK   z</code> <code>rM   z#<li>static default promotes route: rN   z<li>proofFound: <code>rQ   z<li>promotion status: <code>rW   z</ul>z<p>rZ   z</p>z<h2>Failed Gates</h2>z<h2>Missing Evidence</h2>z<h2>Evidence Refs</h2>z$<h2>Object+0x61 Consumer Groups</h2>zW<table><thead><tr><th>group</th><th>range</th><th>route impact</th></tr></thead><tbody>z</tbody></table>z<h2>Remaining Proofs</h2><ul>)r[   r   r   r   r   )r   rm   r&   proofsfailed_gatesmissing_evidenceevidence_refss          r   	html_pager      s   [[)/RFYY  [[!9:@b F YYmTeHfHljlmmF77 EF L ww -.  GG >* M 99 $n$ 	]$ 	B$ 		$
 DKK(9:;74;;wW_O`CaBbbno$ T[[W[[-G)HIJJ^_c_j_jknovozoz  |L  pM  lN  `O  _P  P\  	]$ "$++c'++>T2U.V"W!XXde$ #4;;s7;;?O3P/Q#R"SS_`$ *$++c'++Fh:i6j*k)lluvz  wB  wB  CF  GN  GR  GR  Sv  Gw  Cx  wy  vz  z@  	A$ 0CLe@f<g0h/iiuv$ #7;;/F#G"HN$ 'w{{3Q'R&SSXY$ ,GKK8T,U+VV[\$ #7;;/E#F"GuM$ )5Q)R(SSXY$  )5Q)R(SSXY!$" %T[[VZZ5L1M%N$OOdeiepepqtu{uu  AL  vM  rN  fO  eP  Pc  dh  do  do  ps  tz  t~  t~  M  tN  pO  dP  cQ  Q_  `d  `k  `k  lo  pv  pz  pz  {@  pA  lB  `C  _D  DP  	Q#$$ .gkk:V.W-XX]^%$& !S1F-G!H IV'$( 't{{3w{{CT7U3V'W&XXde)$* 	+$, dkk',/016-$. 	 /$0 |nE"1$2 	$3$4  &5$6 	!7$8 }oU#9$: 	/;$< 	b=$> 	?$@ 	A$B 	(C$D 	E$F 	G$ $ $r   c                   |j                  dd       |dz  }|j                  t        j                  | dd      dz   d	       |9|j                  j                  dd       |j                  t        |       d	       |S )
NT)parentsexist_okz0save_selector_opcode24_mode1_default_effect.jsonF   )ensure_asciiindentr   r   r   )mkdir
write_textr   dumpsparentr   )r   out_dirhtml_outjson_outs       r   write_outputsr      s    MM$M.KKH

7q9D@   dT:Ig.AOr   c            	        t        j                  t              } | j                  dt        t
               | j                  dt               | j                         }t        t        |j                  dz  i       t        |j                  dz  i       t        |j                  dz  i       t        |j                  d	z  i             }t        ||j                  |j                        }t        d
|        y )N)r   z	--out-dir)typedefaultz
--html-out)r   z#save_selector_opcode24_handler.jsonz1save_selector_opcode24_mode1_runtime_context.jsonz%save_selector_object61_consumers.jsonz+save_selector_object61_stream_operands.jsonz'wrote opcode24 mode1 default effect -> )argparseArgumentParser__doc__add_argumentr   OUT
parse_argsrp   r   r   r   r   print)parserargsr   r   s       r   mainr     s    $$9F
$<
40D$,,!FFK$,,!TTVXY$,,!HH"M$,,!NNPRS	G WdllDMMBH	3H:
>?r   __main__)r
   r   r   r   returnr   )r   z
int | Noner   z
str | None)
rd   dictre   r   rf   r   rg   r   r   r   )r   r   r   r   )r   r   r   r   r   zPath | Noner   r   )r   None)r   
__future__r   r   r   r   pathlibr   typingr   __file__resolver   ROOTr   r^   r_   ra   rb   rc   r   r   rp   r   r   r   r   __name__r   r   r   <module>r      s   O "      H~''*
Ul		1 -
2 . EU~8Iwx>O~1Bfg	/ +8#MMM M #	M
 
M`8v;| 25d 
@ zF r   