@@ -245,10 +245,7 @@ pub enum Instruction {
245245 YieldValue {
246246 arg : Arg < u32 > ,
247247 } = 118 ,
248- Resume {
249- arg : Arg < u32 > ,
250- } = 149 ,
251- // ==================== RustPython-only instructions (119-135) ====================
248+ // ==================== RustPython-only instructions (119-133) ====================
252249 // Ideally, we want to be fully aligned with CPython opcodes, but we still have some leftovers.
253250 // So we assign random IDs to these opcodes.
254251 Break {
@@ -277,10 +274,106 @@ pub enum Instruction {
277274 target : Arg < Label > ,
278275 } = 130 ,
279276 JumpIfNotExcMatch ( Arg < Label > ) = 131 ,
280- SetExcInfo = 134 ,
281- Subscript = 135 ,
277+ SetExcInfo = 132 ,
278+ Subscript = 133 ,
279+ // End of custom instructions
280+ Resume {
281+ arg : Arg < u32 > ,
282+ } = 149 ,
283+ BinaryOpAddFloat = 150 , // Placeholder
284+ BinaryOpAddInt = 151 , // Placeholder
285+ BinaryOpAddUnicode = 152 , // Placeholder
286+ BinaryOpMultiplyFloat = 153 , // Placeholder
287+ BinaryOpMultiplyInt = 154 , // Placeholder
288+ BinaryOpSubtractFloat = 155 , // Placeholder
289+ BinaryOpSubtractInt = 156 , // Placeholder
290+ BinarySubscrDict = 157 , // Placeholder
291+ BinarySubscrGetitem = 158 , // Placeholder
292+ BinarySubscrListInt = 159 , // Placeholder
293+ BinarySubscrStrInt = 160 , // Placeholder
294+ BinarySubscrTupleInt = 161 , // Placeholder
295+ CallAllocAndEnterInit = 162 , // Placeholder
296+ CallBoundMethodExactArgs = 163 , // Placeholder
297+ CallBoundMethodGeneral = 164 , // Placeholder
298+ CallBuiltinClass = 165 , // Placeholder
299+ CallBuiltinFast = 166 , // Placeholder
300+ CallBuiltinFastWithKeywords = 167 , // Placeholder
301+ CallBuiltinO = 168 , // Placeholder
302+ CallIsinstance = 169 , // Placeholder
303+ CallLen = 170 , // Placeholder
304+ CallListAppend = 171 , // Placeholder
305+ CallMethodDescriptorFast = 172 , // Placeholder
306+ CallMethodDescriptorFastWithKeywords = 173 , // Placeholder
307+ CallMethodDescriptorNoargs = 174 , // Placeholder
308+ CallMethodDescriptorO = 175 , // Placeholder
309+ CallNonPyGeneral = 176 , // Placeholder
310+ CallPyExactArgs = 177 , // Placeholder
311+ CallPyGeneral = 178 , // Placeholder
312+ CallStr1 = 179 , // Placeholder
313+ CallTuple1 = 180 , // Placeholder
314+ CallType1 = 181 , // Placeholder
315+ CompareOpFloat = 182 , // Placeholder
316+ CompareOpInt = 183 , // Placeholder
317+ CompareOpStr = 184 , // Placeholder
318+ ContainsOpDict = 185 , // Placeholder
319+ ContainsOpSet = 186 , // Placeholder
320+ ForIterGen = 187 , // Placeholder
321+ ForIterList = 188 , // Placeholder
322+ ForIterRange = 189 , // Placeholder
323+ ForIterTuple = 190 , // Placeholder
324+ LoadAttrClass = 191 , // Placeholder
325+ LoadAttrGetattributeOverridden = 192 , // Placeholder
326+ LoadAttrInstanceValue = 193 , // Placeholder
327+ LoadAttrMethodLazyDict = 194 , // Placeholder
328+ LoadAttrMethodNoDict = 195 , // Placeholder
329+ LoadAttrMethodWithValues = 196 , // Placeholder
330+ LoadAttrModule = 197 , // Placeholder
331+ LoadAttrNondescriptorNoDict = 198 , // Placeholder
332+ LoadAttrNondescriptorWithValues = 199 , // Placeholder
333+ LoadAttrProperty = 200 , // Placeholder
334+ LoadAttrSlot = 201 , // Placeholder
335+ LoadAttrWithHint = 202 , // Placeholder
336+ LoadGlobalBuiltin = 203 , // Placeholder
337+ LoadGlobalModule = 204 , // Placeholder
338+ LoadSuperAttrAttr = 205 , // Placeholder
339+ LoadSuperAttrMethod = 206 , // Placeholder
340+ ResumeCheck = 207 , // Placeholder
341+ SendGen = 208 , // Placeholder
342+ StoreAttrInstanceValue = 209 , // Placeholder
343+ StoreAttrSlot = 210 , // Placeholder
344+ StoreAttrWithHint = 211 , // Placeholder
345+ StoreSubscrDict = 212 , // Placeholder
346+ StoreSubscrListInt = 213 , // Placeholder
347+ ToBoolAlwaysTrue = 214 , // Placeholder
348+ ToBoolBool = 215 , // Placeholder
349+ ToBoolInt = 216 , // Placeholder
350+ ToBoolList = 217 , // Placeholder
351+ ToBoolNone = 218 , // Placeholder
352+ ToBoolStr = 219 , // Placeholder
353+ UnpackSequenceList = 220 , // Placeholder
354+ UnpackSequenceTuple = 221 , // Placeholder
355+ UnpackSequenceTwoTuple = 222 , // Placeholder
356+ InstrumentedResume = 236 , // Placeholder
357+ InstrumentedEndFor = 237 , // Placeholder
358+ InstrumentedEndSend = 238 , // Placeholder
359+ InstrumentedReturnValue = 239 , // Placeholder
360+ InstrumentedReturnConst = 240 , // Placeholder
361+ InstrumentedYieldValue = 241 , // Placeholder
362+ InstrumentedLoadSuperAttr = 242 , // Placeholder
363+ InstrumentedForIter = 243 , // Placeholder
364+ InstrumentedCall = 244 , // Placeholder
365+ InstrumentedCallKw = 245 , // Placeholder
366+ InstrumentedCallFunctionEx = 246 , // Placeholder
367+ InstrumentedInstruction = 247 , // Placeholder
368+ InstrumentedJumpForward = 248 , // Placeholder
369+ InstrumentedJumpBackward = 249 , // Placeholder
370+ InstrumentedPopJumpIfTrue = 250 , // Placeholder
371+ InstrumentedPopJumpIfFalse = 251 , // Placeholder
372+ InstrumentedPopJumpIfNone = 252 , // Placeholder
373+ InstrumentedPopJumpIfNotNone = 253 , // Placeholder
374+ InstrumentedLine = 254 , // Placeholder
282375 // Pseudos (needs to be moved to `PseudoInstruction` enum.
283- LoadClosure ( Arg < NameIdx > ) = 253 , // TODO: Move to pseudos
376+ LoadClosure ( Arg < NameIdx > ) = 255 , // TODO: Move to pseudos
284377}
285378
286379const _: ( ) = assert ! ( mem:: size_of:: <Instruction >( ) == 1 ) ;
@@ -305,6 +398,12 @@ impl TryFrom<u8> for Instruction {
305398 // Resume has a non-contiguous opcode (149)
306399 let resume_id = u8:: from ( Self :: Resume { arg : Arg :: marker ( ) } ) ;
307400
401+ let specialized_start = u8:: from ( Self :: BinaryOpAddFloat ) ;
402+ let specialized_end = u8:: from ( Self :: UnpackSequenceTwoTuple ) ;
403+
404+ let instrumented_start = u8:: from ( Self :: InstrumentedResume ) ;
405+ let instrumented_end = u8:: from ( Self :: InstrumentedLine ) ;
406+
308407 // TODO: Remove this; This instruction needs to be pseudo
309408 let load_closure = u8:: from ( Self :: LoadClosure ( Arg :: marker ( ) ) ) ;
310409
@@ -345,6 +444,8 @@ impl TryFrom<u8> for Instruction {
345444 || value == resume_id
346445 || value == load_closure
347446 || custom_ops. contains ( & value)
447+ || ( specialized_start..=specialized_end) . contains ( & value)
448+ || ( instrumented_start..=instrumented_end) . contains ( & value)
348449 {
349450 Ok ( unsafe { mem:: transmute :: < u8 , Self > ( value) } )
350451 } else {
@@ -589,6 +690,98 @@ impl InstructionMetadata for Instruction {
589690 Self :: PopJumpIfNone { .. } => 0 ,
590691 Self :: PopJumpIfNotNone { .. } => 0 ,
591692 Self :: LoadClosure ( _) => 1 ,
693+ Self :: BinaryOpAddFloat => 0 ,
694+ Self :: BinaryOpAddInt => 0 ,
695+ Self :: BinaryOpAddUnicode => 0 ,
696+ Self :: BinaryOpMultiplyFloat => 0 ,
697+ Self :: BinaryOpMultiplyInt => 0 ,
698+ Self :: BinaryOpSubtractFloat => 0 ,
699+ Self :: BinaryOpSubtractInt => 0 ,
700+ Self :: BinarySubscrDict => 0 ,
701+ Self :: BinarySubscrGetitem => 0 ,
702+ Self :: BinarySubscrListInt => 0 ,
703+ Self :: BinarySubscrStrInt => 0 ,
704+ Self :: BinarySubscrTupleInt => 0 ,
705+ Self :: CallAllocAndEnterInit => 0 ,
706+ Self :: CallBoundMethodExactArgs => 0 ,
707+ Self :: CallBoundMethodGeneral => 0 ,
708+ Self :: CallBuiltinClass => 0 ,
709+ Self :: CallBuiltinFast => 0 ,
710+ Self :: CallBuiltinFastWithKeywords => 0 ,
711+ Self :: CallBuiltinO => 0 ,
712+ Self :: CallIsinstance => 0 ,
713+ Self :: CallLen => 0 ,
714+ Self :: CallListAppend => 0 ,
715+ Self :: CallMethodDescriptorFast => 0 ,
716+ Self :: CallMethodDescriptorFastWithKeywords => 0 ,
717+ Self :: CallMethodDescriptorNoargs => 0 ,
718+ Self :: CallMethodDescriptorO => 0 ,
719+ Self :: CallNonPyGeneral => 0 ,
720+ Self :: CallPyExactArgs => 0 ,
721+ Self :: CallPyGeneral => 0 ,
722+ Self :: CallStr1 => 0 ,
723+ Self :: CallTuple1 => 0 ,
724+ Self :: CallType1 => 0 ,
725+ Self :: CompareOpFloat => 0 ,
726+ Self :: CompareOpInt => 0 ,
727+ Self :: CompareOpStr => 0 ,
728+ Self :: ContainsOpDict => 0 ,
729+ Self :: ContainsOpSet => 0 ,
730+ Self :: ForIterGen => 0 ,
731+ Self :: ForIterList => 0 ,
732+ Self :: ForIterRange => 0 ,
733+ Self :: ForIterTuple => 0 ,
734+ Self :: LoadAttrClass => 0 ,
735+ Self :: LoadAttrGetattributeOverridden => 0 ,
736+ Self :: LoadAttrInstanceValue => 0 ,
737+ Self :: LoadAttrMethodLazyDict => 0 ,
738+ Self :: LoadAttrMethodNoDict => 0 ,
739+ Self :: LoadAttrMethodWithValues => 0 ,
740+ Self :: LoadAttrModule => 0 ,
741+ Self :: LoadAttrNondescriptorNoDict => 0 ,
742+ Self :: LoadAttrNondescriptorWithValues => 0 ,
743+ Self :: LoadAttrProperty => 0 ,
744+ Self :: LoadAttrSlot => 0 ,
745+ Self :: LoadAttrWithHint => 0 ,
746+ Self :: LoadGlobalBuiltin => 0 ,
747+ Self :: LoadGlobalModule => 0 ,
748+ Self :: LoadSuperAttrAttr => 0 ,
749+ Self :: LoadSuperAttrMethod => 0 ,
750+ Self :: ResumeCheck => 0 ,
751+ Self :: SendGen => 0 ,
752+ Self :: StoreAttrInstanceValue => 0 ,
753+ Self :: StoreAttrSlot => 0 ,
754+ Self :: StoreAttrWithHint => 0 ,
755+ Self :: StoreSubscrDict => 0 ,
756+ Self :: StoreSubscrListInt => 0 ,
757+ Self :: ToBoolAlwaysTrue => 0 ,
758+ Self :: ToBoolBool => 0 ,
759+ Self :: ToBoolInt => 0 ,
760+ Self :: ToBoolList => 0 ,
761+ Self :: ToBoolNone => 0 ,
762+ Self :: ToBoolStr => 0 ,
763+ Self :: UnpackSequenceList => 0 ,
764+ Self :: UnpackSequenceTuple => 0 ,
765+ Self :: UnpackSequenceTwoTuple => 0 ,
766+ Self :: InstrumentedResume => 0 ,
767+ Self :: InstrumentedEndFor => 0 ,
768+ Self :: InstrumentedEndSend => 0 ,
769+ Self :: InstrumentedReturnValue => 0 ,
770+ Self :: InstrumentedReturnConst => 0 ,
771+ Self :: InstrumentedYieldValue => 0 ,
772+ Self :: InstrumentedLoadSuperAttr => 0 ,
773+ Self :: InstrumentedForIter => 0 ,
774+ Self :: InstrumentedCall => 0 ,
775+ Self :: InstrumentedCallKw => 0 ,
776+ Self :: InstrumentedCallFunctionEx => 0 ,
777+ Self :: InstrumentedInstruction => 0 ,
778+ Self :: InstrumentedJumpForward => 0 ,
779+ Self :: InstrumentedJumpBackward => 0 ,
780+ Self :: InstrumentedPopJumpIfTrue => 0 ,
781+ Self :: InstrumentedPopJumpIfFalse => 0 ,
782+ Self :: InstrumentedPopJumpIfNone => 0 ,
783+ Self :: InstrumentedPopJumpIfNotNone => 0 ,
784+ Self :: InstrumentedLine => 0 ,
592785 }
593786 }
594787
0 commit comments