@@ -319,6 +319,7 @@ where
319
319
} ;
320
320
321
321
* operand = new_value;
322
+ context. retire_op ( op) ;
322
323
}
323
324
Opcode :: LAnd
324
325
| Opcode :: LOr
@@ -358,6 +359,7 @@ where
358
359
// TODO: use potentially-updated result for return value here
359
360
self . do_store ( target, result. clone ( ) ) ?;
360
361
context. contribute_arg ( Argument :: Object ( result) ) ;
362
+ context. retire_op ( op) ;
361
363
}
362
364
Opcode :: FromBCD => self . do_from_bcd ( & mut context, op) ?,
363
365
Opcode :: ToBCD => self . do_to_bcd ( & mut context, op) ?,
@@ -368,6 +370,7 @@ where
368
370
369
371
let name = name. resolve ( & context. current_scope ) ?;
370
372
self . namespace . lock ( ) . insert ( name, object. clone ( ) ) ?;
373
+ context. retire_op ( op) ;
371
374
}
372
375
Opcode :: Fatal => {
373
376
let [ Argument :: ByteData ( typ) , Argument :: DWordData ( code) , Argument :: Object ( arg) ] =
@@ -377,6 +380,7 @@ where
377
380
} ;
378
381
let arg = arg. as_integer ( ) ?;
379
382
self . handler . handle_fatal_error ( * typ, * code, arg) ;
383
+ context. retire_op ( op) ;
380
384
}
381
385
Opcode :: OpRegion => {
382
386
let [
@@ -396,6 +400,7 @@ where
396
400
parent_device_path : context. current_scope . clone ( ) ,
397
401
} ) ;
398
402
self . namespace . lock ( ) . insert ( name. resolve ( & context. current_scope ) ?, region. wrap ( ) ) ?;
403
+ context. retire_op ( op) ;
399
404
}
400
405
Opcode :: DataRegion => {
401
406
let [
@@ -423,6 +428,7 @@ where
423
428
parent_device_path : context. current_scope . clone ( ) ,
424
429
} ) ;
425
430
self . namespace . lock ( ) . insert ( name. resolve ( & context. current_scope ) ?, region. wrap ( ) ) ?;
431
+ context. retire_op ( op) ;
426
432
}
427
433
Opcode :: Buffer => {
428
434
let [
@@ -444,6 +450,7 @@ where
444
450
context. current_block . pc += buffer_len;
445
451
446
452
context. contribute_arg ( Argument :: Object ( Object :: Buffer ( buffer) . wrap ( ) ) ) ;
453
+ context. retire_op ( op) ;
447
454
}
448
455
Opcode :: Package | Opcode :: VarPackage => {
449
456
let mut elements = Vec :: with_capacity ( op. expected_arguments ) ;
@@ -467,6 +474,7 @@ where
467
474
assert_eq ! ( context. peek( ) , Err ( AmlError :: RunOutOfStream ) ) ;
468
475
context. current_block = context. block_stack . pop ( ) . unwrap ( ) ;
469
476
context. contribute_arg ( Argument :: Object ( Object :: Package ( elements) . wrap ( ) ) ) ;
477
+ context. retire_op ( op) ;
470
478
}
471
479
Opcode :: If => {
472
480
let [
@@ -501,6 +509,7 @@ where
501
509
Err ( other) => Err ( other) ?,
502
510
}
503
511
}
512
+ context. retire_op ( op) ;
504
513
}
505
514
opcode @ Opcode :: CreateBitField
506
515
| opcode @ Opcode :: CreateByteField
@@ -524,6 +533,7 @@ where
524
533
name. resolve ( & context. current_scope ) ?,
525
534
Object :: BufferField { buffer : buffer. clone ( ) , offset : offset as usize , length } . wrap ( ) ,
526
535
) ?;
536
+ context. retire_op ( op) ;
527
537
}
528
538
Opcode :: CreateField => {
529
539
let [ Argument :: Object ( buffer) , Argument :: Object ( bit_index) , Argument :: Object ( num_bits) ] =
@@ -544,16 +554,19 @@ where
544
554
}
545
555
. wrap ( ) ,
546
556
) ?;
557
+ context. retire_op ( op) ;
547
558
}
548
559
Opcode :: Store => {
549
560
let [ Argument :: Object ( object) , target] = & op. arguments [ ..] else { panic ! ( ) } ;
550
561
self . do_store ( & target, object. clone ( ) ) ?;
562
+ context. retire_op ( op) ;
551
563
}
552
564
Opcode :: RefOf => {
553
565
let [ Argument :: Object ( object) ] = & op. arguments [ ..] else { panic ! ( ) } ;
554
566
let reference =
555
567
Object :: Reference { kind : ReferenceKind :: RefOf , inner : object. clone ( ) } . wrap ( ) ;
556
568
context. contribute_arg ( Argument :: Object ( reference) ) ;
569
+ context. retire_op ( op) ;
557
570
}
558
571
Opcode :: CondRefOf => {
559
572
let [ Argument :: Object ( object) , target] = & op. arguments [ ..] else { panic ! ( ) } ;
@@ -566,6 +579,7 @@ where
566
579
Object :: Integer ( u64:: MAX )
567
580
} ;
568
581
context. contribute_arg ( Argument :: Object ( result. wrap ( ) ) ) ;
582
+ context. retire_op ( op) ;
569
583
}
570
584
Opcode :: DerefOf => {
571
585
let [ Argument :: Object ( object) ] = & op. arguments [ ..] else { panic ! ( ) } ;
@@ -582,14 +596,17 @@ where
582
596
} ) ;
583
597
} ;
584
598
context. contribute_arg ( Argument :: Object ( result) ) ;
599
+ context. retire_op ( op) ;
585
600
}
586
601
Opcode :: Sleep => {
587
602
let [ Argument :: Object ( msec) ] = & op. arguments [ ..] else { panic ! ( ) } ;
588
603
self . handler . sleep ( msec. as_integer ( ) ?) ;
604
+ context. retire_op ( op) ;
589
605
}
590
606
Opcode :: Stall => {
591
607
let [ Argument :: Object ( usec) ] = & op. arguments [ ..] else { panic ! ( ) } ;
592
608
self . handler . stall ( usec. as_integer ( ) ?) ;
609
+ context. retire_op ( op) ;
593
610
}
594
611
Opcode :: Acquire => {
595
612
let [ Argument :: Object ( mutex) ] = & op. arguments [ ..] else { panic ! ( ) } ;
@@ -600,6 +617,7 @@ where
600
617
601
618
// TODO: should we do something with the sync level??
602
619
self . handler . acquire ( mutex, timeout) ?;
620
+ context. retire_op ( op) ;
603
621
}
604
622
Opcode :: Release => {
605
623
let [ Argument :: Object ( mutex) ] = & op. arguments [ ..] else { panic ! ( ) } ;
@@ -608,6 +626,7 @@ where
608
626
} ;
609
627
// TODO: should we do something with the sync level??
610
628
self . handler . release ( mutex) ;
629
+ context. retire_op ( op) ;
611
630
}
612
631
Opcode :: InternalMethodCall => {
613
632
let [ Argument :: Object ( method) , Argument :: Namestring ( method_scope) ] = & op. arguments [ 0 ..2 ]
@@ -632,6 +651,7 @@ where
632
651
MethodContext :: new_from_method ( method. clone ( ) , args, method_scope. clone ( ) ) ?;
633
652
let old_context = mem:: replace ( & mut context, new_context) ;
634
653
self . context_stack . lock ( ) . push ( old_context) ;
654
+ context. retire_op ( op) ;
635
655
}
636
656
Opcode :: Return => {
637
657
let [ Argument :: Object ( object) ] = & op. arguments [ ..] else { panic ! ( ) } ;
@@ -640,6 +660,7 @@ where
640
660
if let Some ( last) = self . context_stack . lock ( ) . pop ( ) {
641
661
context = last;
642
662
context. contribute_arg ( Argument :: Object ( object. clone ( ) ) ) ;
663
+ context. retire_op ( op) ;
643
664
} else {
644
665
/*
645
666
* If this is the top-most context, this is a `Return` from the actual
@@ -675,6 +696,7 @@ where
675
696
} ;
676
697
677
698
context. contribute_arg ( Argument :: Object ( Object :: Integer ( typ) . wrap ( ) ) ) ;
699
+ context. retire_op ( op) ;
678
700
}
679
701
Opcode :: SizeOf => self . do_size_of ( & mut context, op) ?,
680
702
Opcode :: Index => self . do_index ( & mut context, op) ?,
@@ -701,6 +723,7 @@ where
701
723
702
724
let kind = FieldUnitKind :: Bank { region, bank, bank_value } ;
703
725
self . parse_field_list ( & mut context, kind, * start_pc, * pkg_length, field_flags) ?;
726
+ context. retire_op ( op) ;
704
727
}
705
728
Opcode :: While => {
706
729
/*
@@ -713,6 +736,7 @@ where
713
736
if predicate == 0 {
714
737
// Exit from the while loop by skipping out of the current block
715
738
context. current_block = context. block_stack . pop ( ) . unwrap ( ) ;
739
+ context. retire_op ( op) ;
716
740
}
717
741
}
718
742
_ => panic ! ( "Unexpected operation has created in-flight op!" ) ,
@@ -1409,6 +1433,7 @@ where
1409
1433
// TODO: use result for arg
1410
1434
self . do_store ( target, result. clone ( ) ) ?;
1411
1435
context. contribute_arg ( Argument :: Object ( result) ) ;
1436
+ context. retire_op ( op) ;
1412
1437
Ok ( ( ) )
1413
1438
}
1414
1439
@@ -1450,6 +1475,7 @@ where
1450
1475
} ;
1451
1476
1452
1477
context. contribute_arg ( Argument :: Object ( Object :: Integer ( result) . wrap ( ) ) ) ;
1478
+ context. retire_op ( op) ;
1453
1479
Ok ( ( ) )
1454
1480
}
1455
1481
@@ -1459,12 +1485,8 @@ where
1459
1485
let operand = operand. clone ( ) . unwrap_transparent_reference ( ) . as_integer ( ) ?;
1460
1486
let result = if operand == 0 { u64:: MAX } else { 0 } ;
1461
1487
1462
- if let Some ( prev_op) = context. in_flight . last_mut ( ) {
1463
- if prev_op. arguments . len ( ) < prev_op. expected_arguments {
1464
- prev_op. arguments . push ( Argument :: Object ( Object :: Integer ( result) . wrap ( ) ) ) ;
1465
- }
1466
- }
1467
-
1488
+ context. contribute_arg ( Argument :: Object ( Object :: Integer ( result) . wrap ( ) ) ) ;
1489
+ context. retire_op ( op) ;
1468
1490
return Ok ( ( ) ) ;
1469
1491
}
1470
1492
@@ -1526,6 +1548,7 @@ where
1526
1548
let result = if result { Object :: Integer ( u64:: MAX ) } else { Object :: Integer ( 0 ) } ;
1527
1549
1528
1550
context. contribute_arg ( Argument :: Object ( result. wrap ( ) ) ) ;
1551
+ context. retire_op ( op) ;
1529
1552
Ok ( ( ) )
1530
1553
}
1531
1554
@@ -1558,6 +1581,7 @@ where
1558
1581
// TODO: use result of store
1559
1582
self . do_store ( target, result. clone ( ) ) ?;
1560
1583
context. contribute_arg ( Argument :: Object ( result) ) ;
1584
+ context. retire_op ( op) ;
1561
1585
Ok ( ( ) )
1562
1586
}
1563
1587
@@ -1601,6 +1625,7 @@ where
1601
1625
// TODO: use result of store
1602
1626
self . do_store ( target, result. clone ( ) ) ?;
1603
1627
context. contribute_arg ( Argument :: Object ( result) ) ;
1628
+ context. retire_op ( op) ;
1604
1629
Ok ( ( ) )
1605
1630
}
1606
1631
@@ -1627,6 +1652,7 @@ where
1627
1652
// TODO: use result of store
1628
1653
self . do_store ( target, result. clone ( ) ) ?;
1629
1654
context. contribute_arg ( Argument :: Object ( result) ) ;
1655
+ context. retire_op ( op) ;
1630
1656
Ok ( ( ) )
1631
1657
}
1632
1658
@@ -1670,6 +1696,7 @@ where
1670
1696
// TODO: use result of store
1671
1697
self . do_store ( target, result. clone ( ) ) ?;
1672
1698
context. contribute_arg ( Argument :: Object ( result) ) ;
1699
+ context. retire_op ( op) ;
1673
1700
Ok ( ( ) )
1674
1701
}
1675
1702
@@ -1707,6 +1734,7 @@ where
1707
1734
1708
1735
self . do_store ( target, result. clone ( ) ) ?;
1709
1736
context. contribute_arg ( Argument :: Object ( result) ) ;
1737
+ context. retire_op ( op) ;
1710
1738
1711
1739
Ok ( ( ) )
1712
1740
}
@@ -1736,6 +1764,7 @@ where
1736
1764
Object :: Debug => "[Debug Object]" . to_string ( ) ,
1737
1765
}
1738
1766
}
1767
+
1739
1768
let result = match source1. typ ( ) {
1740
1769
ObjectType :: Integer => {
1741
1770
let source1 = source1. as_integer ( ) ?;
@@ -1764,6 +1793,7 @@ where
1764
1793
// TODO: use result of store
1765
1794
self . do_store ( target, result. clone ( ) ) ?;
1766
1795
context. contribute_arg ( Argument :: Object ( result) ) ;
1796
+ context. retire_op ( op) ;
1767
1797
Ok ( ( ) )
1768
1798
}
1769
1799
@@ -1780,6 +1810,7 @@ where
1780
1810
}
1781
1811
1782
1812
context. contribute_arg ( Argument :: Object ( Object :: Integer ( result) . wrap ( ) ) ) ;
1813
+ context. retire_op ( op) ;
1783
1814
Ok ( ( ) )
1784
1815
}
1785
1816
@@ -1796,6 +1827,7 @@ where
1796
1827
}
1797
1828
1798
1829
context. contribute_arg ( Argument :: Object ( Object :: Integer ( result) . wrap ( ) ) ) ;
1830
+ context. retire_op ( op) ;
1799
1831
Ok ( ( ) )
1800
1832
}
1801
1833
@@ -1811,6 +1843,7 @@ where
1811
1843
} ;
1812
1844
1813
1845
context. contribute_arg ( Argument :: Object ( Object :: Integer ( result as u64 ) . wrap ( ) ) ) ;
1846
+ context. retire_op ( op) ;
1814
1847
Ok ( ( ) )
1815
1848
}
1816
1849
@@ -1861,6 +1894,7 @@ where
1861
1894
1862
1895
self . do_store ( target, result. clone ( ) ) ?;
1863
1896
context. contribute_arg ( Argument :: Object ( result) ) ;
1897
+ context. retire_op ( op) ;
1864
1898
Ok ( ( ) )
1865
1899
}
1866
1900
@@ -2374,9 +2408,19 @@ impl MethodContext {
2374
2408
}
2375
2409
2376
2410
fn start_in_flight_op ( & mut self , op : OpInFlight ) {
2411
+ trace ! (
2412
+ "START OP: {:?}, args: {:?}, with {} more needed" ,
2413
+ op. op,
2414
+ op. arguments,
2415
+ op. expected_arguments - op. arguments. len( )
2416
+ ) ;
2377
2417
self . in_flight . push ( op) ;
2378
2418
}
2379
2419
2420
+ fn retire_op ( & mut self , op : OpInFlight ) {
2421
+ trace ! ( "RETIRE OP: {:?}, args: {:?}" , op. op, op. arguments) ;
2422
+ }
2423
+
2380
2424
fn start_new_block ( & mut self , kind : BlockKind , length : usize ) {
2381
2425
let block = Block {
2382
2426
stream : & self . current_block . stream ( ) [ ..( self . current_block . pc + length) ] as * const [ u8 ] ,
0 commit comments