1
  
2
  
3
  
4
  
5
  
6
  
7
  
8
  
9
  
10
  
11
  
12
  
13
  
14
  
15
  
16
  
17
  
18
  
19
  
20
  
21
  
22
  
23
  
24
  
25
  
26
  
27
  
28
  
29
  
30
  
31
  
32
  
33
  
34
  
35
  
36
  
37
  
38
  
39
  
40
  
41
  
42
  
43
  
44
  
45
  
46
  
47
  
48
  
49
  
50
  
51
  
52
  
53
  
54
  
55
  
56
  
57
  
58
  
59
  
60
  
61
  
62
  
63
  
64
  
65
  
66
  
67
  
68
  
69
  
70
  
71
  
72
  
73
  
74
  
75
  
76
  
77
  
78
  
79
  
80
  
81
  
82
  
83
  
84
  
85
  
86
  
87
  
88
  
89
  
90
  
91
  
92
  
93
  
94
  
95
  
96
  
97
  
98
  
99
  
100
  
101
  
102
  
103
  
104
  
105
  
106
  
107
  
108
  
109
  
110
  
111
  
112
  
113
  
114
  
115
  
116
  
117
  
118
  
119
  
120
  
121
  
122
  
123
  
124
  
125
  
126
  
127
  
128
  
129
  
130
  
131
  
132
  
133
  
134
  
135
  
136
  
137
  
138
  
139
  
140
  
141
  
142
  
143
  
144
  
145
  
146
  
147
  
148
  
149
  
150
  
151
  
152
  
153
  
154
  
155
  
156
  
157
  
158
  
159
  
160
  
161
  
162
  
163
  
164
  
165
  
166
  
167
  
168
  
169
  
170
  
171
  
172
  
173
  
174
  
175
  
176
  
177
  
178
  
179
  
180
  
181
  
182
  
183
  
184
  
185
  
186
  
187
  
188
  
189
  
190
  
191
  
192
  
193
  
194
  
195
  
196
  
197
  
198
  
199
  
200
  
201
  
202
  
203
  
204
  
205
  
206
  
207
  
208
  
209
  
210
  
211
  
212
  
213
  
214
  
215
  
216
  
217
  
218
  
219
  
220
  
221
  
222
  
223
  
224
  
225
  
226
  
227
  
228
  
229
  
230
  
231
  
232
  
233
  
234
  
235
  
236
  
237
  
238
  
239
  
240
  
241
  
242
  
243
  
244
  
245
  
246
  
247
  
248
  
249
  
250
  
251
  
252
  
253
  
254
  
255
  
256
  
257
  
258
  
259
  
260
  
261
  
262
  
263
  
264
  
265
  
266
  
267
  
268
  
269
  
270
  
271
  
272
  
273
  
274
  
275
  
276
  
277
  
278
  
279
  
280
  
281
  
282
  
283
  
284
  
285
  
286
  
287
  
288
  
289
  
290
  
291
  
292
  
293
  
294
  
295
  
296
  
297
  
298
  
299
  
300
  
301
  
302
  
303
  
304
  
305
  
306
  
307
  
308
  
309
  
310
  
311
  
312
  
313
  
314
  
315
  
316
  
317
  
318
  
319
  
320
  
321
  
322
  
323
  
324
  
325
  
326
  
327
  
328
  
329
  
330
  
331
  
332
  
333
  
334
  
335
  
336
  
337
  
338
  
339
  
340
  
341
  
342
  
343
  
344
  
345
  
346
  
347
  
348
  
349
  
350
  
351
  
352
  
353
  
354
  
355
  
356
  
357
  
358
  
359
  
360
  
361
  
362
  
363
  
364
  
365
  
366
  
367
  
368
  
369
  
370
  
371
  
372
  
373
  
374
  
375
  
376
  
377
  
378
  
379
  
380
  
381
  
382
  
383
  
384
  
385
  
386
  
387
  
388
  
389
  
390
  
391
  
392
  
393
  
394
  
395
  
396
  
397
  
398
  
399
  
400
  
401
  
402
  
403
  
404
  
405
  
406
  
407
  
408
  
409
  
410
  
411
  
412
  
413
  
414
  
415
  
416
  
417
  
418
  
419
  
420
  
421
  
422
  
423
  
424
  
425
  
426
  
427
  
428
  
429
  
430
  
431
  
432
  
433
  
434
  
435
  
436
  
437
  
438
  
439
  
440
  
441
  
442
  
443
  
444
  
445
  
446
  
447
  
448
  
449
  
450
  
451
  
452
  
453
  
454
  
455
  
456
  
457
  
458
  
459
  
460
  
461
  
462
  
463
  
464
  
465
  
466
  
467
  
468
  
469
  
470
  
471
  
472
  
473
  
474
  
475
  
476
  
477
  
478
  
479
  
480
  
481
  
482
  
483
  
484
  
485
  
486
  
487
  
488
  
489
  
490
  
491
  
492
  
493
  
494
  
495
  
496
  
497
  
498
  
499
  
500
  
501
  
502
  
503
  
504
  
505
  
506
  
507
  
508
  
509
  
510
  
511
  
512
  
513
  
514
  
515
  
516
  
517
  
518
  
519
  
520
  
521
  
522
  
523
  
524
  
525
  
526
  
527
  
528
  
529
  
530
  
531
  
532
  
533
  
534
  
535
  
536
  
537
  
538
  
539
  
540
  
541
  
542
  
543
  
544
  
545
  
546
  
547
  
548
  
549
  
550
  
551
  
552
  
553
  
554
  
555
  
556
  
557
  
558
  
559
  
560
  
561
  
562
  
563
  
564
  
565
  
566
  
567
  
568
  
569
  
570
  
571
  
572
  
573
  
574
  
575
  
576
  
577
  
578
  
579
  
580
  
581
  
582
  
583
  
584
  
585
  
586
  
587
  
588
  
589
  
590
  
591
  
592
  
593
  
594
  
595
  
596
  
597
  
598
  
599
  
600
  
601
  
602
  
603
  
604
  
605
  
606
  
607
  
608
  
609
  
610
  
611
  
612
  
613
  
614
  
615
  
616
  
617
  
618
  
619
  
620
  
621
  
622
  
623
  
624
  
625
  
626
  
627
  
628
  
629
  
630
  
631
  
632
  
633
  
634
  
635
  
636
  
637
  
638
  
639
  
640
  
641
  
642
  
643
  
644
  
645
  
646
  
647
  
648
  
649
  
650
  
651
  
652
  
653
  
654
  
655
  
656
  
657
  
658
  
659
  
660
  
661
  
662
  
663
  
664
  
665
  
666
  
667
  
668
  
669
  
670
  
671
  
672
  
673
  
674
  
675
  
676
  
677
  
678
  
679
  
680
  
681
  
682
  
683
  
684
  
685
  
686
  
687
  
688
  
689
  
690
  
691
  
692
  
693
  
694
  
695
  
696
  
697
  
698
  
699
  
700
  
701
  
702
  
703
  
704
  
705
  
706
  
707
  
708
  
709
  
710
  
711
  
712
  
713
  
714
  
715
  
716
  
717
  
718
  
719
  
720
  
721
  
722
  
723
  
724
  
725
  
726
  
727
  
728
  
729
  
730
  
731
  
732
  
733
  
734
  
735
  
736
  
737
  
738
  
739
  
740
  
741
  
742
  
743
  
744
  
745
  
746
  
747
  
748
  
749
  
750
  
751
  
752
  
753
  
754
  
755
  
756
  
757
  
758
  
759
  
760
  
761
  
762
  
763
  
764
  
765
  
766
  
767
  
768
  
769
  
770
  
771
  
772
  
773
  
774
  
775
  
776
  
777
  
778
  
779
  
780
  
781
  
782
  
783
  
784
  
785
  
786
  
787
  
788
  
789
  
790
  
791
  
792
  
793
  
794
  
795
  
796
  
797
  
798
  
799
  
800
  
801
  
802
  
803
  
804
  
805
  
806
  
807
  
808
  
809
  
810
  
811
  
812
  
813
  
814
  
815
  
816
  
817
  
818
  
819
  
820
  
821
  
822
  
823
  
824
  
825
  
826
  
827
  
828
  
829
  
830
  
831
  
832
  
833
  
834
  
835
  
836
  
837
  
838
  
839
  
840
  
841
  
842
  
843
  
844
  
845
  
846
  
847
  
848
  
849
  
850
  
851
  
852
  
853
  
854
  
855
  
856
  
857
  
858
  
859
  
860
  
861
  
862
  
863
  
864
  
865
  
866
  
867
  
868
  
869
  
870
  
871
  
872
  
873
  
874
  
875
  
876
  
877
  
878
  
879
  
880
  
881
  
882
  
883
  
884
  
885
  
886
  
887
  
888
  
889
  
890
  
891
  
892
  
893
  
894
  
895
  
896
  
897
  
898
  
899
  
900
  
901
  
902
  
903
  
904
  
905
  
906
  
907
  
908
  
909
  
910
  
911
  
912
  
913
  
914
  
915
  
916
  
917
  
918
  
919
  
920
  
921
  
922
  
923
  
924
  
925
  
926
  
927
  
928
  
929
  
930
  
931
  
932
  
933
  
934
  
935
  
936
  
937
  
938
  
939
  
940
  
941
  
942
  
943
  
944
  
945
  
946
  
947
  
948
  
949
  
950
  
951
  
952
  
953
  
954
  
955
  
956
  
957
  
958
  
959
  
960
  
961
  
962
  
963
  
964
  
965
  
966
  
967
  
968
  
969
  
970
  
971
  
972
  
973
  
974
  
975
  
976
  
977
  
978
  
979
  
980
  
981
  
982
  
983
  
984
  
985
  
986
  
987
  
988
  
989
  
990
  
991
  
992
  
993
  
994
  
995
  
996
  
997
  
998
  
999
  
1000
  
1001
  
1002
  
1003
  
1004
  
1005
  
1006
  
1007
  
1008
  
1009
  
1010
  
1011
  
1012
  
1013
  
1014
  
1015
  
1016
  
1017
  
1018
  
1019
  
1020
  
1021
  
1022
  
1023
  
1024
  
1025
  
1026
  
1027
  
1028
  
1029
  
1030
  
1031
  
1032
  
1033
  
1034
  
1035
  
1036
  
1037
  
1038
  
1039
  
1040
  
1041
  
1042
  
1043
  
1044
  
1045
  
1046
  
1047
  
1048
  
1049
  
1050
  
1051
  
1052
  
1053
  
1054
  
1055
  
1056
  
1057
  
1058
  
1059
  
1060
  
1061
  
1062
  
1063
  
1064
  
1065
  
1066
  
1067
  
1068
  
1069
  
1070
  
1071
  
1072
  
1073
  
1074
  
1075
  
1076
  
1077
  
1078
  
1079
  
1080
  
1081
  
1082
  
1083
  
1084
  
1085
  
1086
  
1087
  
1088
  
1089
  
1090
  
1091
  
1092
  
1093
  
1094
  
1095
  
1096
  
1097
  
1098
  
1099
  
1100
  
1101
  
1102
  
1103
  
1104
  
1105
  
1106
  
1107
  
1108
  
1109
  
1110
  
1111
  
1112
  
1113
  
1114
  
1115
  
1116
  
1117
  
1118
  
1119
  
1120
  
1121
  
1122
  
1123
  
1124
  
1125
  
1126
  
1127
  
1128
  
1129
  
1130
  
1131
  
1132
  
1133
  
1134
  
1135
  
1136
  
1137
  
1138
  
1139
  
1140
  
1141
  
1142
  
1143
  
1144
  
1145
  
1146
  
1147
  
1148
  
1149
  
1150
  
1151
  
1152
  
1153
  
1154
  
1155
  
1156
  
1157
  
1158
  
1159
  
1160
  
1161
  
1162
  
1163
  
1164
  
1165
  
1166
  
1167
  
1168
  
1169
  
1170
  
1171
  
1172
  
1173
  
1174
  
1175
  
1176
  
1177
  
1178
  
1179
  
1180
  
1181
  
1182
  
1183
  
1184
  
1185
  
1186
  
1187
  
1188
  
1189
  
1190
  
1191
  
1192
  
1193
  
1194
  
1195
  
1196
  
1197
  
1198
  
1199
  
1200
  
1201
  
1202
  
1203
  
1204
  
1205
  
1206
  
1207
  
1208
  
1209
  
1210
  
1211
  
1212
  
1213
  
1214
  
1215
  
1216
  
1217
  
1218
  
1219
  
1220
  
1221
  
1222
  
1223
  
1224
  
1225
  
1226
  
1227
  
1228
  
1229
  
1230
  
1231
  
1232
  
1233
  
1234
  
1235
  
1236
  
1237
  
1238
  
1239
  
1240
  
1241
  
1242
  
1243
  
1244
  
1245
  
1246
  
1247
  
1248
  
1249
  
1250
  
1251
  
1252
  
1253
  
1254
  
1255
  
1256
  
1257
  
1258
  
1259
  
1260
  
1261
  
1262
  
1263
  
1264
  
1265
  
1266
  
1267
  
1268
  
1269
  
1270
  
1271
  
1272
  
1273
  
1274
  
1275
  
1276
  
1277
  
1278
  
1279
  
1280
  
1281
  
1282
  
1283
  
1284
  
1285
  
1286
  
1287
  
1288
  
1289
  
1290
  
1291
  
1292
  
1293
  
1294
  
1295
  
1296
  
1297
  
1298
  
1299
  
1300
  
1301
  
1302
  
1303
  
1304
  
1305
  
1306
  
1307
  
1308
  
1309
  
1310
  
1311
  
1312
  
1313
  
1314
  
1315
  
1316
  
1317
  
1318
  
1319
  
1320
  
1321
  
1322
  
1323
  
1324
  
1325
  
1326
  
1327
  
1328
  
1329
  
1330
  
1331
  
1332
  
1333
  
1334
  
1335
  
1336
  
1337
  
1338
  
1339
  
1340
  
1341
  
1342
  
1343
  
1344
  
1345
  
1346
  
1347
  
1348
  
1349
  
1350
  
1351
  
1352
  
1353
  
1354
  
1355
  
1356
  
1357
  
1358
  
1359
  
1360
  
1361
  
1362
  
1363
  
1364
  
1365
  
1366
  
1367
  
1368
  
1369
  
1370
  
1371
  
1372
  
1373
  
1374
  
1375
  
1376
  
1377
  
1378
  
1379
  
1380
  
1381
  
1382
  
1383
  
1384
  
1385
  
1386
  
1387
  
1388
  
1389
  
1390
  
1391
  
1392
  
1393
  
1394
  
1395
  
1396
  
1397
  
1398
  
1399
  
1400
  
1401
  
1402
  
1403
  
1404
  
1405
  
1406
  
1407
  
1408
  
1409
  
1410
  
1411
  
1412
  
1413
  
1414
  
1415
  
1416
  
1417
  
1418
  
1419
  
1420
  
1421
  
1422
  
1423
  
1424
  
1425
  
1426
  
1427
  
1428
  
1429
  
1430
  
1431
  
1432
  
1433
  
1434
  
1435
  
1436
  
1437
  
1438
  
1439
  
1440
  
1441
  
1442
  
1443
  
1444
  
1445
  
1446
  
1447
  
1448
  
1449
  
1450
  
1451
  
1452
  
1453
  
1454
  
1455
  
1456
  
1457
  
1458
  
1459
  
1460
  
1461
  
1462
  
1463
  
1464
  
1465
  
1466
  
1467
  
1468
  
1469
  
1470
  
1471
  
1472
  
1473
  
1474
  
1475
  
1476
  
1477
  
1478
  
1479
  
1480
  
1481
  
1482
  
1483
  
1484
  
1485
  
1486
  
1487
  
1488
  
1489
  
1490
  
1491
  
1492
  
1493
  
1494
  
1495
  
1496
  
1497
  
1498
  
1499
  
1500
  
1501
  
1502
  
1503
  
1504
  
1505
  
1506
  
1507
  
1508
  
1509
  
1510
  
1511
  
1512
  
1513
  
1514
  
1515
  
1516
  
1517
  
1518
  
1519
  
1520
  
1521
  
1522
  
1523
  
1524
  
1525
  
1526
  
1527
  
1528
  
1529
  
1530
  
1531
  
1532
  
1533
  
1534
  
1535
  
1536
  
1537
  
1538
  
1539
  
1540
  
1541
  
1542
  
1543
  
1544
  
1545
  
1546
  
1547
  
1548
  
1549
  
1550
  
1551
  
1552
  
1553
  
1554
  
1555
  
1556
  
1557
  
1558
  
1559
  
1560
  
1561
  
1562
  
1563
  
1564
  
1565
  
1566
  
1567
  
1568
  
1569
  
1570
  
1571
  
1572
  
1573
  
1574
  
1575
  
1576
  
1577
  
1578
  
1579
  
1580
  
1581
  
1582
  
1583
  
1584
  
1585
  
1586
  
1587
  
1588
  
1589
  
1590
  
1591
  
1592
  
1593
  
1594
  
1595
  
1596
  
1597
  
1598
  
1599
  
1600
  
1601
  
1602
  
1603
  
1604
  
1605
  
1606
  
1607
  
1608
  
1609
  
1610
  
1611
  
1612
  
1613
  
1614
  
1615
  
1616
  
1617
  
1618
  
1619
  
1620
  
1621
  
1622
  
1623
  
1624
  
1625
  
1626
  
1627
  
1628
  
1629
  
1630
  
1631
  
1632
  
1633
  
1634
  
1635
  
1636
  
1637
  
1638
  
1639
  
1640
  
1641
  
1642
  
1643
  
1644
  
1645
  
1646
  
1647
  
1648
  
1649
  
1650
  
1651
  
1652
  
1653
  
1654
  
1655
  
1656
  
1657
  
1658
  
1659
  
1660
  
1661
  
1662
  
1663
  
1664
  
1665
  
1666
  
1667
  
1668
  
1669
  
1670
  
1671
  
1672
  
1673
  
1674
  
1675
  
1676
  
1677
  
1678
  
1679
  
1680
  
1681
  
1682
  
1683
  
1684
  
1685
  
1686
  
1687
  
1688
  
1689
  
1690
  
1691
  
1692
  
1693
  
1694
  
1695
  
1696
  
1697
  
1698
  
1699
  
1700
  
1701
  
1702
  
1703
  
1704
  
1705
  
1706
  
1707
  
1708
  
1709
  
1710
  
1711
  
1712
  
1713
  
1714
  
1715
  
1716
  
1717
  
1718
  
1719
  
1720
  
1721
  
1722
  
1723
  
1724
  
1725
  
1726
  
1727
  
1728
  
1729
  
1730
  
1731
  
1732
  
1733
  
1734
  
1735
  
1736
  
1737
  
1738
  
1739
  
1740
  
1741
  
1742
  
1743
  
1744
  
1745
  
1746
  
1747
  
1748
  
1749
  
1750
  
1751
  
1752
  
1753
  
1754
  
1755
  
1756
  
1757
  
1758
  
1759
  
1760
  
1761
  
1762
  
1763
  
1764
  
1765
  
1766
  
1767
  
1768
  
1769
  
1770
  
1771
  
1772
  
1773
  
1774
  
1775
  
1776
  
1777
  
1778
  
1779
  
1780
  
1781
  
1782
  
1783
  
1784
  
1785
  
1786
  
1787
  
1788
  
1789
  
1790
  
1791
  
1792
  
1793
  
1794
  
1795
  
1796
  
1797
  
1798
  
1799
  
1800
  
1801
  
1802
  
1803
  
1804
  
1805
  
1806
  
1807
  
1808
  
1809
  
1810
  
1811
  
1812
  
1813
  
1814
  
1815
  
1816
  
1817
  
1818
  
1819
  
1820
  
1821
  
1822
  
1823
  
1824
  
1825
  
1826
  
1827
  
1828
  
1829
  
1830
  
1831
  
1832
  
1833
  
1834
  
1835
  
1836
  
1837
  
1838
  
1839
  
1840
  
1841
  
1842
  
1843
  
1844
  
1845
  
1846
  
1847
  
1848
  
1849
  
1850
  
1851
  
1852
  
1853
  
1854
  
1855
  
1856
  
1857
  
1858
  
1859
  
1860
  
1861
  
1862
  
1863
  
1864
  
1865
  
1866
  
1867
  
1868
  
1869
  
1870
  
1871
  
1872
  
1873
  
1874
  
1875
  
1876
  
1877
  
1878
  
1879
  
1880
  
1881
  
1882
  
1883
  
1884
  
1885
  
1886
  
1887
  
1888
  
1889
  
1890
  
1891
  
1892
  
1893
  
1894
  
1895
  
1896
  
1897
  
1898
  
1899
  
1900
  
1901
  
1902
  
1903
  
1904
  
1905
  
1906
  
1907
  
1908
  
1909
  
1910
  
1911
  
1912
  
1913
  
1914
  
1915
  
1916
  
1917
  
1918
  
1919
  
1920
  
1921
  
1922
  
1923
  
1924
  
1925
  
1926
  
1927
  
1928
  
1929
  
1930
  
1931
  
1932
  
1933
  
1934
  
1935
  
1936
  
1937
  
1938
  
1939
  
1940
  
1941
  
1942
  
1943
  
1944
  
1945
  
1946
  
1947
  
1948
  
1949
  
1950
  
1951
  
1952
  
1953
  
1954
  
1955
  
1956
  
1957
  
1958
  
1959
  
1960
  
1961
  
1962
  
1963
  
1964
  
1965
  
1966
  
1967
  
1968
  
1969
  
1970
  
1971
  
1972
  
1973
  
1974
  
1975
  
1976
  
1977
  
1978
  
1979
  
1980
  
1981
  
1982
  
1983
  
1984
  
1985
  
1986
  
1987
  
1988
  
1989
  
1990
  
1991
  
1992
  
1993
  
1994
  
1995
  
1996
  
1997
  
1998
  
1999
  
2000
  
2001
  
2002
  
2003
  
2004
  
2005
  
2006
  
2007
  
2008
  
2009
  
2010
  
2011
  
2012
  
2013
  
2014
  
2015
  
2016
  
2017
  
2018
  
2019
  
2020
  
2021
  
2022
  
2023
  
2024
  
2025
  
2026
  
2027
  
2028
  
2029
  
2030
  
2031
  
2032
  
2033
  
2034
  
2035
  
2036
  
2037
  
2038
  
2039
  
2040
  
2041
  
2042
  
2043
  
2044
  
2045
  
2046
  
2047
  
2048
  
2049
  
2050
  
2051
  
2052
  
2053
  
2054
  
2055
  
2056
  
2057
  
2058
  
2059
  
2060
  
2061
  
2062
  
2063
  
2064
  
2065
  
2066
  
2067
  
2068
  
2069
  
2070
  
2071
  
2072
  
2073
  
2074
  
2075
  
2076
  
2077
  
2078
  
2079
  
2080
  
2081
  
2082
  
2083
  
2084
  
2085
  
2086
  
2087
  
2088
  
2089
  
2090
  
2091
  
2092
  
2093
  
2094
  
2095
  
2096
  
2097
  
2098
  
2099
  
2100
  
2101
  
2102
  
2103
  
2104
  
2105
  
2106
  
2107
  
2108
  
2109
  
2110
  
2111
  
2112
  
2113
  
2114
  
2115
  
2116
  
2117
  
2118
  
2119
  
2120
  
2121
  
2122
  
2123
  
2124
  
2125
  
2126
  
2127
  
2128
  
2129
  
2130
  
2131
  
2132
  
2133
  
2134
  
2135
  
2136
  
2137
  
2138
  
2139
  
2140
  
2141
  
2142
  
2143
  
2144
  
2145
  
2146
  
2147
  
2148
  
2149
  
2150
  
2151
  
2152
  
2153
  
2154
  
2155
  
2156
  
2157
  
2158
  
2159
  
2160
  
2161
  
2162
  
2163
  
2164
  
2165
  
2166
  
2167
  
2168
  
2169
  
2170
  
2171
  
2172
  
2173
  
2174
  
2175
  
2176
  
2177
  
2178
  
2179
  
2180
  
2181
  
2182
  
2183
  
2184
  
2185
  
2186
  
2187
  
2188
  
2189
  
2190
  
2191
  
2192
  
2193
  
2194
  
2195
  
2196
  
2197
  
2198
  
2199
  
2200
  
2201
  
2202
  
2203
  
2204
  
2205
  
2206
  
2207
  
2208
  
2209
  
2210
  
2211
  
2212
  
2213
  
2214
  
2215
  
2216
  
2217
  
2218
  
2219
  
2220
  
2221
  
2222
  
2223
  
2224
  
2225
  
2226
  
2227
  
2228
  
2229
  
2230
  
2231
  
2232
  
2233
  
2234
  
2235
  
2236
  
2237
  
2238
  
2239
  
2240
  
2241
  
2242
  
2243
  
2244
  
2245
  
2246
  
2247
  
2248
  
2249
  
2250
  
2251
  
2252
  
2253
  
2254
  
2255
  
2256
  
2257
  
2258
  
2259
  
2260
  
2261
  
2262
  
2263
  
2264
  
2265
  
2266
  
2267
  
2268
  
2269
  
2270
  
2271
  
2272
  
2273
  
2274
  
2275
  
2276
  
2277
  
2278
  
2279
  
2280
  
2281
  
2282
  
2283
  
2284
  
2285
  
2286
  
2287
  
2288
  
2289
  
2290
  
2291
  
2292
  
2293
  
2294
  
2295
  
2296
  
2297
  
2298
  
2299
  
2300
  
2301
  
2302
  
2303
  
2304
  
2305
  
2306
  
2307
  
2308
  
2309
  
2310
  
2311
  
2312
  
2313
  
2314
  
2315
  
2316
  
2317
  
2318
  
2319
  
2320
  
2321
  
2322
  
2323
  
2324
  
2325
  
2326
  
2327
  
2328
  
2329
  
2330
  
2331
  
2332
  
2333
  
2334
  
2335
  
2336
  
2337
  
2338
  
2339
  
2340
  
2341
  
2342
  
2343
  
2344
  
2345
  
2346
  
2347
  
2348
  
2349
  
2350
  
2351
  
2352
  
2353
  
2354
  
2355
  
2356
  
2357
  
2358
  
2359
  
2360
  
2361
  
2362
  
2363
  
2364
  
2365
  
2366
  
2367
  
2368
  
2369
  
2370
  
2371
  
2372
  
2373
  
2374
  
2375
  
2376
  
2377
  
2378
  
2379
  
2380
  
2381
  
2382
  
2383
  
2384
  
2385
  
2386
  
2387
  
2388
  
2389
  
2390
  
2391
  
2392
  
2393
  
2394
  
2395
  
2396
  
2397
  
2398
  
2399
  
2400
  
2401
  
2402
  
2403
  
2404
  
2405
  
2406
  
2407
  
2408
  
2409
  
2410
  
2411
  
2412
  
2413
  
2414
  
2415
  
2416
  
2417
  
2418
  
2419
  
2420
  
2421
  
2422
  
2423
  
2424
  
2425
  
2426
  
2427
  
2428
  
2429
  
2430
  
2431
  
2432
  
2433
  
2434
  
2435
  
2436
  
2437
  
2438
  
2439
  
2440
  
2441
  
2442
  
2443
  
2444
  
2445
  
2446
  
2447
  
2448
  
2449
  
2450
  
2451
  
2452
  
2453
  
2454
  
2455
  
2456
  
2457
  
2458
  
2459
  
2460
  
2461
  
2462
  
2463
  
2464
  
2465
  
2466
  
2467
  
2468
  
2469
  
2470
  
2471
  
2472
  
2473
  
2474
  
2475
  
2476
  
2477
  
2478
  
2479
  
2480
  
2481
  
2482
  
2483
  
2484
  
2485
  
2486
  
2487
  
2488
  
2489
  
2490
  
2491
  
2492
  
2493
  
2494
  
2495
  
2496
  
2497
  
2498
  
2499
  
2500
  
2501
  
2502
  
2503
  
2504
  
2505
  
2506
  
2507
  
2508
  
2509
  
2510
  
2511
  
2512
  
2513
  
2514
  
2515
  
2516
  
2517
  
2518
  
2519
  
2520
  
2521
  
2522
  
2523
  
2524
  
2525
  
2526
  
2527
  
2528
  
2529
  
2530
  
2531
  
2532
  
2533
  
2534
  
2535
  
2536
  
2537
  
2538
  
2539
  
2540
  
2541
  
2542
  
2543
  
2544
  
2545
  
2546
  
2547
  
2548
  
2549
  
2550
  
2551
  
2552
  
2553
  
2554
  
2555
  
2556
  
2557
  
2558
  
2559
  
2560
  
2561
  
2562
  
2563
  
2564
  
2565
  
2566
  
2567
  
2568
  
2569
  
2570
  
2571
  
2572
  
2573
  
2574
  
2575
  
2576
  
2577
  
2578
  
2579
  
2580
  
2581
  
2582
  
2583
  
2584
  
2585
  
2586
  
2587
  
2588
  
2589
  
2590
  
2591
  
2592
  
2593
  
2594
  
2595
  
2596
  
2597
  
2598
  
2599
  
2600
  
2601
  
2602
  
2603
  
2604
  
2605
  
2606
  
2607
  
2608
  
2609
  
2610
  
2611
  
2612
  
2613
  
2614
  
2615
  
2616
  
2617
  
2618
  
2619
  
2620
  
2621
  
2622
  
2623
  
2624
  
2625
  
2626
  
2627
  
2628
  
2629
  
2630
  
2631
  
2632
  
2633
  
2634
  
2635
  
2636
  
2637
  
2638
  
2639
  
2640
  
2641
  
2642
  
2643
  
2644
  
2645
  
2646
  
2647
  
2648
  
2649
  
2650
  
2651
  
2652
  
2653
  
2654
  
2655
  
2656
  
2657
  
2658
  
2659
  
2660
  
2661
  
2662
  
2663
  
2664
  
2665
  
2666
  
2667
  
2668
  
2669
  
2670
  
2671
  
2672
  
2673
  
2674
  
2675
  
2676
  
2677
  
2678
  
2679
  
2680
  
2681
  
2682
  
2683
  
2684
  
2685
  
2686
  
2687
  
2688
  
2689
  
2690
  
2691
  
2692
  
2693
  
2694
  
2695
  
2696
  
2697
  
2698
  
2699
  
2700
  
2701
  
2702
  
2703
  
2704
  
2705
  
2706
  
2707
  
2708
  
2709
  
2710
  
2711
  
2712
  
2713
  
2714
  
2715
  
2716
  
2717
  
2718
  
2719
  
2720
  
2721
  
2722
  
2723
  
2724
  
2725
  
2726
  
2727
  
2728
  
2729
  
2730
  
2731
  
2732
  
2733
  
2734
  
2735
  
2736
  
2737
  
2738
  
2739
  
2740
  
2741
  
2742
  
2743
  
2744
  
2745
  
2746
  
2747
  
2748
  
2749
  
2750
  
2751
  
2752
  
2753
  
2754
  
2755
  
2756
  
2757
  
2758
  
2759
  
2760
  
2761
  
2762
  
2763
  
2764
  
2765
  
2766
  
2767
  
2768
  
2769
  
2770
  
2771
  
2772
  
2773
  
2774
  
2775
  
2776
  
2777
  
2778
  
2779
  
2780
  
2781
  
2782
  
2783
  
2784
  
2785
  
2786
  
2787
  
2788
  
2789
  
2790
  
2791
  
2792
  
2793
  
2794
  
2795
  
2796
  
2797
  
2798
  
2799
  
2800
  
2801
  
2802
  
2803
  
2804
  
2805
  
2806
  
2807
  
2808
  
2809
  
2810
  
2811
  
2812
  
2813
  
2814
  
2815
  
2816
  
2817
  
2818
  
2819
  
2820
  
2821
  
2822
  
2823
  
2824
  
2825
  
2826
  
2827
  
2828
  
2829
  
2830
  
2831
  
2832
  
2833
  
2834
  
2835
  
2836
  
2837
  
2838
  
2839
  
2840
  
2841
  
2842
  
2843
  
2844
  
2845
  
2846
  
2847
  
2848
  
2849
  
2850
  
2851
  
2852
  
2853
  
2854
  
2855
  
2856
  
2857
  
2858
  
2859
  
2860
  
2861
  
2862
  
2863
  
2864
  
2865
  
2866
  
2867
  
2868
  
2869
  
2870
  
2871
  
2872
  
2873
  
2874
  
2875
  
2876
  
2877
  
2878
  
2879
  
2880
  
2881
  
2882
  
2883
  
2884
  
2885
  
2886
  
2887
  
2888
  
2889
  
2890
  
2891
  
2892
  
2893
  
2894
  
2895
  
2896
  
2897
  
2898
  
2899
  
2900
  
2901
  
2902
  
2903
  
2904
  
2905
  
2906
  
2907
  
2908
  
2909
  
2910
  
2911
  
2912
  
2913
  
2914
  
2915
  
2916
  
2917
  
2918
  
2919
  
2920
  
2921
  
2922
  
2923
  
2924
  
2925
  
2926
  
2927
  
2928
  
2929
  
2930
  
2931
  
2932
  
2933
  
2934
  
2935
  
2936
  
2937
  
2938
  
2939
  
2940
  
2941
  
2942
  
2943
  
2944
  
2945
  
2946
  
2947
  
2948
  
2949
  
2950
  
2951
  
2952
  
2953
  
2954
  
2955
  
2956
  
2957
  
2958
  
2959
  
2960
  
2961
  
2962
  
2963
  
2964
  
2965
  
2966
  
2967
  
2968
  
2969
  
2970
  
2971
  
2972
  
2973
  
2974
  
2975
  
2976
  
2977
  
2978
  
2979
  
2980
  
2981
  
2982
  
2983
  
2984
  
2985
  
2986
  
2987
  
2988
  
2989
  
2990
  
2991
  
2992
  
2993
  
2994
  
2995
  
2996
  
2997
  
2998
  
2999
  
3000
  
3001
  
3002
  
3003
  
3004
  
3005
  
3006
  
3007
  
3008
  
3009
  
3010
  
3011
  
3012
  
3013
  
3014
  
3015
  
3016
  
3017
  
3018
  
3019
  
3020
  
3021
  
3022
  
3023
  
3024
  
3025
  
3026
  
3027
  
3028
  
3029
  
3030
  
3031
  
3032
  
3033
  
3034
  
3035
  
3036
  
3037
  
3038
  
3039
  
3040
  
3041
  
3042
  
3043
  
3044
  
3045
  
3046
  
3047
  
3048
  
3049
  
3050
  
3051
  
3052
  
3053
  
3054
  
3055
  
3056
  
3057
  
3058
  
3059
  
3060
  
3061
  
3062
  
3063
  
3064
  
3065
  
3066
  
3067
  
3068
  
3069
  
3070
  
3071
  
3072
  
3073
  
3074
  
3075
  
3076
  
3077
  
3078
  
3079
  
3080
  
3081
  
3082
  
3083
  
3084
  
3085
  
3086
  
3087
  
3088
  
3089
  
3090
  
3091
  
3092
  
3093
  
3094
  
3095
  
3096
  
3097
  
3098
  
3099
  
3100
  
3101
  
3102
  
3103
  
3104
  
3105
  
3106
  
3107
  
3108
  
3109
  
3110
  
3111
  
3112
  
3113
  
3114
  
3115
  
3116
  
3117
  
3118
  
3119
  
3120
  
3121
  
3122
  
3123
  
3124
  
3125
  
3126
  
3127
  
3128
  
3129
  
3130
  
3131
  
3132
  
3133
  
3134
  
3135
  
3136
  
3137
  
3138
  
3139
  
3140
  
3141
  
3142
  
3143
  
3144
  
3145
  
3146
  
3147
  
3148
  
3149
  
3150
  
3151
  
3152
  
3153
  
3154
  
3155
  
3156
  
3157
  
3158
  
3159
  
3160
  
3161
  
3162
  
3163
  
3164
  
3165
  
3166
  
3167
  
3168
  
3169
  
3170
  
3171
  
3172
  
3173
  
3174
  
3175
  
3176
  
3177
  
3178
  
3179
  
3180
  
3181
  
3182
  
3183
  
3184
  
3185
  
3186
  
3187
  
3188
  
3189
  
3190
  
3191
  
3192
  
3193
  
3194
  
3195
  
3196
  
3197
  
3198
  
3199
  
3200
  
3201
  
3202
  
3203
  
3204
  
3205
  
3206
  
3207
  
3208
  
3209
  
3210
  
3211
  
3212
  
3213
  
3214
  
3215
  
3216
  
3217
  
3218
  
3219
  
3220
  
3221
  
3222
  
3223
  
3224
  
3225
  
3226
  
3227
  
3228
  
3229
  
3230
  
3231
  
3232
  
3233
  
3234
  
3235
  
3236
  
3237
  
3238
  
3239
  
3240
  
3241
  
3242
  
3243
  
3244
  
3245
  
3246
  
3247
  
3248
  
3249
  
3250
  
3251
  
3252
  
3253
  
3254
  
3255
  
3256
  
3257
  
3258
  
3259
  
3260
  
3261
  
3262
  
3263
  
3264
  
3265
  
3266
  
3267
  
3268
  
3269
  
3270
  
3271
  
3272
  
3273
  
3274
  
3275
  
3276
  
3277
  
3278
  
3279
  
3280
  
3281
  
3282
  
3283
  
3284
  
3285
  
3286
  
3287
  
3288
  
3289
  
3290
  
3291
  
3292
  
3293
  
3294
  
3295
  
3296
  
3297
  
3298
  
3299
  
3300
  
3301
  
3302
  
3303
  
3304
  
3305
  
3306
  
3307
  
3308
  
3309
  
3310
  
3311
  
3312
  
3313
  
3314
  
3315
  
3316
  
3317
  
3318
  
3319
  
3320
  
3321
  
3322
  
3323
  
3324
  
3325
  
3326
  
3327
  
3328
  
3329
  
3330
  
3331
  
3332
  
3333
  
3334
  
3335
  
3336
  
3337
  
3338
  
3339
  
3340
  
3341
  
3342
  
3343
  
3344
  
3345
  
3346
  
3347
  
3348
  
3349
  
3350
  
3351
  
3352
  
3353
  
3354
  
3355
  
3356
  
3357
  
3358
  
3359
  
3360
  
3361
  
3362
  
3363
  
3364
  
3365
  
3366
  
3367
  
3368
  
3369
  
3370
  
3371
  
3372
  
3373
  
3374
  
3375
  
3376
  
3377
  
3378
  
3379
  
3380
  
3381
  
3382
  
3383
  
3384
  
3385
  
3386
  
3387
  
3388
  
3389
  
3390
  
3391
  
3392
  
3393
  
3394
  
3395
  
3396
  
3397
  
3398
  
3399
  
3400
  
3401
  
3402
  
3403
  
3404
  
3405
  
3406
  
3407
  
3408
  
3409
  
3410
  
3411
  
3412
  
3413
  
3414
  
3415
  
3416
  
3417
  
3418
  
3419
  
3420
  
3421
  
3422
  
3423
  
3424
  
3425
  
3426
  
3427
  
3428
  
3429
  
3430
  
3431
  
3432
  
3433
  
3434
  
3435
  
3436
  
3437
  
3438
  
3439
  
3440
  
3441
  
3442
  
3443
  
3444
  
3445
  
3446
  
3447
  
3448
  
3449
  
3450
  
3451
  
3452
  
3453
  
3454
  
3455
  
3456
  
3457
  
3458
  
3459
  
3460
  
3461
  
3462
  
3463
  
3464
  
3465
  
3466
  
3467
  
3468
  
3469
  
3470
  
3471
  
3472
  
3473
  
3474
  
3475
  
3476
  
3477
  
3478
  
3479
  
3480
  
3481
  
3482
  
3483
  
3484
  
3485
  
3486
  
3487
  
3488
  
3489
  
3490
  
3491
  
3492
  
3493
  
3494
  
3495
  
3496
  
3497
  
3498
  
3499
  
3500
  
3501
  
3502
  
3503
  
3504
  
3505
  
3506
  
3507
  
3508
  
3509
  
3510
  
3511
  
3512
  
3513
  
3514
  
3515
  
3516
  
3517
  
3518
  
3519
  
3520
  
3521
  
3522
  
3523
  
3524
  
3525
  
3526
  
3527
  
3528
  
3529
  
3530
  
3531
  
3532
  
3533
  
3534
  
3535
  
3536
  
3537
  
3538
  
3539
  
3540
  
3541
  
3542
  
3543
  
3544
  
3545
  
3546
  
3547
  
3548
  
3549
  
3550
  
3551
  
3552
  
3553
  
3554
  
3555
  
3556
  
3557
  
3558
  
3559
  
3560
  
3561
  
3562
  
3563
  
3564
  
3565
  
/* 
|| This file is part of Pike. For copyright information see COPYRIGHT. 
|| Pike is distributed under GPL, LGPL and MPL. See the file COPYING 
|| for more information. 
*/ 
 
#include "global.h" 
#include "interpret.h" 
#include "object.h" 
#include "program.h" 
#include "svalue.h" 
#include "array.h" 
#include "mapping.h" 
#include "pike_error.h" 
#include "stralloc.h" 
#include "constants.h" 
#include "pike_macros.h" 
#include "multiset.h" 
#include "backend.h" 
#include "operators.h" 
#include "opcodes.h" 
#include "pike_embed.h" 
#include "lex.h" 
#include "builtin_functions.h" 
#include "signal_handler.h" 
#include "gc.h" 
#include "threads.h" 
#include "callback.h" 
#include "fd_control.h" 
#include "pike_security.h" 
#include "bignum.h" 
#include "pike_types.h" 
#include "pikecode.h" 
 
#include <fcntl.h> 
#include <errno.h> 
#include <ctype.h> 
 
#ifdef HAVE_MMAP 
#ifdef HAVE_SYS_TYPES_H 
#include <sys/types.h> 
#endif 
 
#ifdef HAVE_SYS_MMAN_H 
#include <sys/mman.h> 
#endif 
 
#ifdef MAP_NORESERVE 
#define USE_MMAP_FOR_STACK 
#endif 
#endif 
 
#ifdef USE_DTRACE 
#include "dtrace_probes.h" 
#else 
#include "dtrace/dtrace_probes_disabled.h" 
#endif 
 
/* 
 * Define the default evaluator stack size, used for just about everything. 
 */ 
#define EVALUATOR_STACK_SIZE  100000 
 
#define TRACE_LEN (100 + Pike_interpreter.trace_level * 10) 
 
/* Keep some margin on the stack space checks. They're lifted when 
 * handle_error runs to give it some room. */ 
/* Observed in 7.1: 40 was enough, 30 wasn't. */ 
#define SVALUE_STACK_MARGIN (100 + LOW_SVALUE_STACK_MARGIN) 
/* Observed in 7.4: 11000 was enough, 10000 wasn't. */ 
#define C_STACK_MARGIN (20000 + LOW_C_STACK_MARGIN) 
 
/* Another extra margin to use while dumping the raw error in 
 * exit_on_error, so that backtrace_frame._sprintf can be called 
 * then. */ 
#define LOW_SVALUE_STACK_MARGIN 20 
#define LOW_C_STACK_MARGIN 500 
 
#ifdef HAVE_COMPUTED_GOTO 
PIKE_OPCODE_T *fcode_to_opcode = NULL; 
struct op_2_f *opcode_to_fcode = NULL; 
#endif /* HAVE_COMPUTED_GOTO */ 
 
PMOD_EXPORT const char Pike_check_stack_errmsg[] = 
  "Svalue stack overflow. " 
  "(%ld of %ld entries on stack, needed %ld more entries)\n"; 
PMOD_EXPORT const char Pike_check_mark_stack_errmsg[] = 
  "Mark stack overflow.\n"; 
PMOD_EXPORT const char Pike_check_c_stack_errmsg[] = 
  "C stack overflow.\n"; 
#ifdef PIKE_DEBUG 
PMOD_EXPORT const char msg_stack_error[] = 
  "Stack error.\n"; 
PMOD_EXPORT const char msg_pop_neg[] = 
  "Popping negative number of args.... (%"PRINTPTRDIFFT"d) \n"; 
#endif 
 
 
#ifdef PIKE_DEBUG 
static char trace_buffer[2000]; 
#endif 
 
#ifdef INTERNAL_PROFILING 
PMOD_EXPORT unsigned long evaluator_callback_calls = 0; 
#endif 
 
 
int fast_check_threads_counter = 0; 
 
/* This is used for strapping the interpreter before the threads 
 * are loaded, and when there's no support for threads. 
 */ 
static struct Pike_interpreter_struct static_pike_interpreter; 
 
/* Pike_sp points to first unused value on stack 
 * (much simpler than letting it point at the last used value.) 
 */ 
PMOD_EXPORT struct Pike_interpreter_struct *Pike_interpreter_pointer = 
  &static_pike_interpreter; 
PMOD_EXPORT int Pike_stack_size = EVALUATOR_STACK_SIZE; 
 
static void do_trace_call(INT32 args, dynamic_buffer *old_buf); 
static void do_trace_func_return (int got_retval, struct object *o, int fun); 
static void do_trace_return (int got_retval, dynamic_buffer *old_buf); 
 
PMOD_EXPORT struct Pike_interpreter_struct * pike_get_interpreter_pointer() 
{ 
  return Pike_interpreter_pointer; 
} 
 
void push_sp_mark(void) 
{ 
  if(Pike_mark_sp == Pike_interpreter.mark_stack + Pike_stack_size) 
    Pike_error("No more mark stack!\n"); 
  *Pike_mark_sp++=Pike_sp; 
} 
ptrdiff_t pop_sp_mark(void) 
{ 
#ifdef PIKE_DEBUG 
  if(Pike_mark_sp < Pike_interpreter.mark_stack) 
    Pike_fatal("Mark stack underflow!\n"); 
#endif 
  return Pike_sp - *--Pike_mark_sp; 
} 
 
 
#ifdef PIKE_DEBUG 
void gc_mark_stack_external (struct pike_frame *f, 
                             struct svalue *stack_p, struct svalue *stack) 
{ 
  for (; f; f = f->next) 
    GC_ENTER (f, T_PIKE_FRAME) { 
      if (!debug_gc_check (f, " as frame on stack")) { 
        gc_mark_external (f->current_object, " in current_object in frame on stack"); 
        gc_mark_external (f->current_program, " in current_program in frame on stack"); 
        if (f->locals) {            /* Check really needed? */ 
          if (f->flags & PIKE_FRAME_MALLOCED_LOCALS) { 
            gc_mark_external_svalues(f->locals, f->num_locals, 
                                     " in malloced locals of trampoline frame on stack"); 
          } else { 
            if (f->locals > stack_p || (stack_p - f->locals) >= 0x10000) { 
              fatal("Unreasonable locals: stack:%p locals:%p\n", 
                    stack_p, f->locals); 
            } 
            gc_mark_external_svalues (f->locals, stack_p - f->locals, " on svalue stack"); 
            stack_p = f->locals; 
          } 
        } 
      } 
    } GC_LEAVE; 
  if (stack != stack_p) 
    gc_mark_external_svalues (stack, stack_p - stack, " on svalue stack"); 
} 
 
static void gc_check_stack_callback(struct callback *foo, void *bar, void *gazonk) 
{ 
  if (Pike_interpreter.evaluator_stack 
#ifdef PIKE_DEBUG 
      /* Avoid this if the thread is swapped out. Useful when calling 
       * locate_references from gdb. */ 
      && Pike_sp != (void *) -1 
#endif 
     ) 
    gc_mark_stack_external (Pike_fp, Pike_sp, Pike_interpreter.evaluator_stack); 
} 
#endif 
 
/* Execute Pike code starting at pc. 
 * 
 * Called once with NULL to initialize tables. 
 * 
 * Returns 0 if pc is NULL. 
 * 
 * Returns -1 if the code terminated due to a RETURN. 
 * 
 * Note: All callers except catching_eval_instruction need to save 
 * Pike_interpreter.catching_eval_jmpbuf, zero it, and restore it 
 * afterwards. 
 */ 
static int eval_instruction(PIKE_OPCODE_T *pc); 
 
PMOD_EXPORT int low_init_interpreter(struct Pike_interpreter_struct *interpreter) 
{ 
#ifdef USE_MMAP_FOR_STACK 
  static int fd = -1; 
 
#ifndef MAP_VARIABLE 
#define MAP_VARIABLE 0 
#endif 
 
#ifndef MAP_PRIVATE 
#define MAP_PRIVATE 0 
#endif 
 
#ifndef MAP_FAILED 
#define MAP_FAILED -1 
#endif 
 
#ifndef MAP_ANONYMOUS 
#define MAP_ANONYMOUS 0 
  if(fd == -1) 
  { 
    while(1) 
    { 
      fd=open("/dev/zero",O_RDONLY); 
      if(fd >= 0) break; 
      if(errno != EINTR) 
      { 
        interpreter->evaluator_stack=0; 
        interpreter->mark_stack=0; 
        goto use_malloc; 
#define NEED_USE_MALLOC_LABEL 
      } 
    } 
    /* Don't keep this fd on exec() */ 
    set_close_on_exec(fd, 1); 
  } 
#endif 
 
#define MMALLOC(X,Y)                                                  \ 
  (Y *)mmap(0, (X)*sizeof(Y), PROT_READ|PROT_WRITE,                     \ 
            MAP_NORESERVE|MAP_PRIVATE|MAP_ANONYMOUS, fd, 0) 
 
  interpreter->evaluator_stack_malloced = 0; 
  interpreter->mark_stack_malloced = 0; 
  interpreter->evaluator_stack = MMALLOC(Pike_stack_size,struct svalue); 
  interpreter->mark_stack = MMALLOC(Pike_stack_size, struct svalue *); 
  if((char *)MAP_FAILED == (char *)interpreter->evaluator_stack) { 
    interpreter->evaluator_stack = 0; 
    interpreter->evaluator_stack_malloced = 1; 
  } 
  if((char *)MAP_FAILED == (char *)interpreter->mark_stack) { 
    interpreter->mark_stack = 0; 
    interpreter->mark_stack_malloced = 1; 
  } 
 
#ifdef NEED_USE_MALLOC_LABEL 
use_malloc: 
#endif /* NEED_USE_MALLOC_LABEL */ 
 
#else /* !USE_MMAP_FOR_STACK */ 
  interpreter->evaluator_stack = 0; 
  interpreter->evaluator_stack_malloced = 1; 
  interpreter->mark_stack = 0; 
  interpreter->mark_stack_malloced = 1; 
#endif /* USE_MMAP_FOR_STACK */ 
 
  if(!interpreter->evaluator_stack) 
  { 
    if (!(interpreter->evaluator_stack = 
          (struct svalue *)malloc(Pike_stack_size*sizeof(struct svalue)))) 
      return 1;     /* Out of memory (evaluator stack). */ 
  } 
 
  if(!interpreter->mark_stack) 
  { 
    if (!(interpreter->mark_stack = 
          (struct svalue **)malloc(Pike_stack_size*sizeof(struct svalue *)))) 
      return 2;     /* Out of memory (mark stack). */ 
  } 
 
  interpreter->stack_pointer = interpreter->evaluator_stack; 
  interpreter->mark_stack_pointer = interpreter->mark_stack; 
  interpreter->frame_pointer = 0; 
  interpreter->catch_ctx = NULL; 
  interpreter->catching_eval_jmpbuf = NULL; 
 
  interpreter->svalue_stack_margin = SVALUE_STACK_MARGIN; 
  interpreter->c_stack_margin = C_STACK_MARGIN; 
 
#ifdef PROFILING 
  interpreter->unlocked_time = 0; 
  interpreter->accounted_time = 0; 
#endif 
 
  interpreter->trace_level = default_t_flag; 
 
  return 0; /* OK. */ 
} 
 
static struct pike_frame *free_pike_frame; 
 
PMOD_EXPORT void init_interpreter(void) 
{ 
  PIKE_MEMPOOL_CREATE(&free_pike_frame); 
  if (low_init_interpreter(Pike_interpreter_pointer)) { 
    Pike_fatal("Out of memory initializing the interpreter stack.\n"); 
  } 
 
#ifdef PIKE_DEBUG 
  { 
    static struct callback *spcb; 
    if(!spcb) 
    { 
      spcb=add_gc_callback(gc_check_stack_callback,0,0); 
      dmalloc_accept_leak(spcb); 
    } 
  } 
#endif 
#if defined(HAVE_COMPUTED_GOTO) || defined(PIKE_USE_MACHINE_CODE) 
  { 
    static int tables_need_init=1; 
    if(tables_need_init) { 
      /* Initialize the fcode_to_opcode table / jump labels. */ 
#if !defined(OPCODE_INLINE_RETURN) 
      eval_instruction(NULL); 
#endif 
#if defined(PIKE_USE_MACHINE_CODE) && !defined(PIKE_DEBUG) 
      /* Simple operator opcodes... */ 
#define SET_INSTR_ADDRESS(X, Y)       (instrs[(X)-F_OFFSET].address = (void *)Y) 
      SET_INSTR_ADDRESS(F_COMPL,              o_compl); 
      SET_INSTR_ADDRESS(F_LSH,                  o_lsh); 
      SET_INSTR_ADDRESS(F_RSH,                  o_rsh); 
      SET_INSTR_ADDRESS(F_SUBTRACT,             o_subtract); 
      SET_INSTR_ADDRESS(F_AND,                  o_and); 
      SET_INSTR_ADDRESS(F_OR,                   o_or); 
      SET_INSTR_ADDRESS(F_XOR,                  o_xor); 
      SET_INSTR_ADDRESS(F_MULTIPLY,             o_multiply); 
      SET_INSTR_ADDRESS(F_DIVIDE,               o_divide); 
      SET_INSTR_ADDRESS(F_MOD,                  o_mod); 
      SET_INSTR_ADDRESS(F_CAST,                 f_cast); 
      SET_INSTR_ADDRESS(F_CAST_TO_INT,          o_cast_to_int); 
      SET_INSTR_ADDRESS(F_CAST_TO_STRING,       o_cast_to_string); 
      SET_INSTR_ADDRESS(F_RANGE,                o_range2); 
      SET_INSTR_ADDRESS(F_SSCANF,               o_sscanf); 
#endif /* PIKE_USE_MACHINE_CODE && !PIKE_DEBUG */ 
      tables_need_init=0; 
#ifdef INIT_INTERPRETER_STATE 
      INIT_INTERPRETER_STATE(); 
#endif 
    } 
  } 
#endif /* HAVE_COMPUTED_GOTO || PIKE_USE_MACHINE_CODE */ 
} 
 
/* 
 * lvalues are stored in two svalues in one of these formats: 
 * array[index]   : { array, index }  
 * mapping[index] : { mapping, index }  
 * multiset[index] : { multiset, index }  
 * object[index] : { object, index } (external object indexing) 
 * local variable : { svalue pointer (T_SVALUE_PTR), nothing (T_VOID) } 
 * global variable : { object, identifier index (T_OBJ_INDEX) } (internal object indexing) 
 * lvalue array: { T_ARRAY_LVALUE, array with lvalue pairs } 
 */ 
 
void lvalue_to_svalue_no_free(struct svalue *to,struct svalue *lval) 
{ 
#ifdef PIKE_SECURITY 
  if(TYPEOF(*lval) <= MAX_COMPLEX) 
    if(!CHECK_DATA_SECURITY(lval->u.array, SECURITY_BIT_INDEX)) 
      Pike_error("Index permission denied.\n"); 
#endif 
  switch(TYPEOF(*lval)) 
  { 
   case T_ARRAY_LVALUE: 
    { 
      INT32 e; 
      struct array *a; 
      TYPE_FIELD types = 0; 
      ONERROR err; 
      a=allocate_array(lval[1].u.array->size>>1); 
      SET_ONERROR(err, do_free_array, a); 
      for(e=0;e<a->size;e++) { 
        lvalue_to_svalue_no_free(ITEM(a)+e, ITEM(lval[1].u.array)+(e<<1)); 
        types |= 1 << TYPEOF(ITEM(a)[e]); 
      } 
      a->type_field = types; 
      SET_SVAL(*to, T_ARRAY, 0, array, a); 
      UNSET_ONERROR(err); 
      break; 
    } 
       
    case T_SVALUE_PTR: 
      dmalloc_touch_svalue(lval->u.lval); 
      assign_svalue_no_free(to, lval->u.lval); 
      break; 
 
    case T_OBJECT: 
      /* FIXME: Object subtypes! */ 
      if (TYPEOF(lval[1]) == T_OBJ_INDEX) 
        low_object_index_no_free (to, lval->u.object, lval[1].u.identifier); 
      else 
        object_index_no_free(to, lval->u.object, SUBTYPEOF(*lval), lval+1); 
      break; 
       
    case T_ARRAY: 
      simple_array_index_no_free(to, lval->u.array, lval+1); 
      break; 
       
    case T_MAPPING: 
      mapping_index_no_free(to, lval->u.mapping, lval+1); 
      break; 
       
    case T_MULTISET: 
      if(multiset_member(lval->u.multiset,lval+1)) 
      { 
        SET_SVAL(*to, T_INT, NUMBER_NUMBER, integer, 1); 
      }else{ 
        SET_SVAL(*to, T_INT, NUMBER_UNDEFINED, integer, 0); 
      } 
      break; 
       
    default: 
      if(SAFE_IS_ZERO(lval)) 
        index_error(0,0,0,lval,lval+1,"Indexing the NULL value.\n"); 
      else 
        index_error(0,0,0,lval,lval+1,"Indexing a basic type.\n"); 
  } 
} 
 
PMOD_EXPORT void assign_lvalue(struct svalue *lval,struct svalue *from) 
{ 
#ifdef PIKE_SECURITY 
  if(TYPEOF(*lval) <= MAX_COMPLEX) 
    if(!CHECK_DATA_SECURITY(lval->u.array, SECURITY_BIT_SET_INDEX)) 
      Pike_error("Assign index permission denied.\n"); 
#endif 
 
  switch(TYPEOF(*lval)) 
  { 
    case T_ARRAY_LVALUE: 
    { 
      INT32 e; 
      if(TYPEOF(*from) != T_ARRAY) 
        Pike_error("Trying to assign combined lvalue from non-array.\n"); 
 
      if(from->u.array->size < (lval[1].u.array->size>>1)) 
        Pike_error("Not enough values for multiple assign.\n"); 
 
      if(from->u.array->size > (lval[1].u.array->size>>1)) 
        Pike_error("Too many values for multiple assign.\n"); 
 
      for(e=0;e<from->u.array->size;e++) 
        assign_lvalue(lval[1].u.array->item+(e<<1),from->u.array->item+e); 
    } 
    break; 
 
  case T_SVALUE_PTR: 
    dmalloc_touch_svalue(from); 
    dmalloc_touch_svalue(lval->u.lval); 
    assign_svalue(lval->u.lval,from); 
    break; 
 
  case T_OBJECT: 
    /* FIXME: Object subtypes! */ 
    if (TYPEOF(lval[1]) == T_OBJ_INDEX) 
      object_low_set_index (lval->u.object, lval[1].u.identifier, from); 
    else 
      object_set_index(lval->u.object, SUBTYPEOF(*lval), lval+1, from); 
    break; 
 
  case T_ARRAY: 
    simple_set_index(lval->u.array, lval+1, from); 
    break; 
 
  case T_MAPPING: 
    mapping_insert(lval->u.mapping, lval+1, from); 
    break; 
 
  case T_MULTISET: 
    if(UNSAFE_IS_ZERO(from)) 
      multiset_delete(lval->u.multiset, lval+1); 
    else 
      multiset_insert(lval->u.multiset, lval+1); 
    break; 
     
  default: 
   if(SAFE_IS_ZERO(lval)) 
     index_error(0,0,0,lval,lval+1,"Indexing the NULL value.\n"); 
   else 
     index_error(0,0,0,lval,lval+1,"Indexing a basic type.\n"); 
  } 
} 
 
/* On error callback. lvalue is followed by value to assign. */ 
static void o_assign_lvalue(struct svalue *lvalue) 
{ 
  assign_lvalue(lvalue, lvalue+2); 
} 
 
union anything *get_pointer_if_this_type(struct svalue *lval, TYPE_T t) 
{ 
#ifdef PIKE_SECURITY 
  if(TYPEOF(*lval) <= MAX_COMPLEX) 
    if(!CHECK_DATA_SECURITY(lval->u.array, SECURITY_BIT_SET_INDEX)) 
      Pike_error("Assign index permission denied.\n"); 
#endif 
 
  switch(TYPEOF(*lval)) 
  { 
    case T_ARRAY_LVALUE: 
      return 0; 
       
    case T_SVALUE_PTR: 
      dmalloc_touch_svalue(lval->u.lval); 
      if(TYPEOF(*(lval->u.lval)) == t) return & ( lval->u.lval->u ); 
      return 0; 
 
    case T_OBJECT: 
      /* FIXME: What about object subtypes? */ 
      return object_get_item_ptr(lval->u.object, SUBTYPEOF(*lval), lval+1, t); 
       
    case T_ARRAY: 
      return array_get_item_ptr(lval->u.array,lval+1,t); 
       
    case T_MAPPING: 
      return mapping_get_item_ptr(lval->u.mapping,lval+1,t); 
 
    case T_MULTISET: return 0; 
       
    default: 
      if(SAFE_IS_ZERO(lval)) 
        index_error(0,0,0,lval,lval+1,"Indexing the NULL value.\n"); 
      else 
        index_error(0,0,0,lval,lval+1,"Indexing a basic type.\n"); 
      return 0; 
  } 
} 
 
#ifdef PIKE_DEBUG 
 
INLINE void pike_trace(int level,char *fmt, ...) ATTRIBUTE((format (printf, 2, 3))); 
INLINE void pike_trace(int level,char *fmt, ...) 
{ 
  if(Pike_interpreter.trace_level > level) 
  { 
    va_list args; 
    va_start(args,fmt); 
    vsprintf(trace_buffer,fmt,args); 
    va_end(args); 
    write_to_stderr(trace_buffer,strlen(trace_buffer)); 
  } 
} 
 
void my_describe_inherit_structure(struct program *p) 
{ 
  struct inherit *in,*last=0; 
  int e,i=0; 
  last=p->inherits-1; 
 
  fprintf(stderr,"PROGRAM[%d]: inherits=%d identifers_refs=%d ppid=%d\n", 
          p->id, 
          p->num_inherits, 
          p->num_identifier_references, 
          p->parent ? p->parent->id : -1); 
  for(e=0;e<p->num_identifier_references;e++) 
  { 
    in=INHERIT_FROM_INT(p,e); 
    while(last < in) 
    { 
      last++; 
      fprintf(stderr, 
              "[%ld]%*s parent{ offset=%d ident=%d id=%d } " 
              "id{ level=%d } prog=%d\n", 
              DO_NOT_WARN((long)(last - p->inherits)), 
              last->inherit_level*2,"", 
              last->parent_offset, 
              last->parent_identifier, 
              last->prog->parent ? last->prog->parent->id : -1, 
              last->identifier_level, 
              last->prog->id); 
      i=0; 
    } 
 
    fprintf(stderr,"   %*s %d,%d: %s\n", 
              in->inherit_level*2,"", 
              e,i, 
            ID_FROM_INT(p,e)->name->str); 
    i++; 
  } 
} 
 
#define TRACE(X) pike_trace X 
#else 
#define TRACE(X) 
#endif 
 
static struct inherit dummy_inherit 
#ifdef PIKE_DEBUG 
  = {-4711, -4711, -4711, -4711, (size_t) -4711, -4711, NULL, NULL, NULL} 
#endif 
; 
 
/* Find the lexical scope @[depth] levels out. 
 * 
 * @[loc]: 
 *   Input: 
 *     struct object *o         // object to start from. 
 *     struct inherit *inherit  // inherit in o->prog. 
 *    (int parent_identifier)   // identifier in o to start from. 
 *                              // Only if depth == 0. 
 * 
 *   Output: 
 *     struct object *o         // object containing the scope. 
 *     struct inherit *inherit  // inherit in o->prog being the scope. 
 *     int parent_identifier    // identifier in o from the inherit. 
 */ 
PMOD_EXPORT void find_external_context(struct external_variable_context *loc, 
                                       int depth) 
{ 
  struct program *p; 
 
  TRACE((4, "-find_external_context(%d, inherit=%ld)\n", depth, 
         DO_NOT_WARN((long)(loc->o->prog ? loc->inherit - loc->o->prog->inherits : 0)))); 
 
#ifdef PIKE_DEBUG 
  if(!loc->o) 
    Pike_fatal("No object\n"); 
#endif 
 
  if (!(p = loc->o->prog)) { 
    /* magic fallback */ 
    p = get_program_for_object_being_destructed(loc->o); 
    if(!p) 
    { 
      Pike_error("Cannot access parent of destructed object.\n"); 
    } 
  } 
 
#ifdef DEBUG_MALLOC 
  if (loc->o->refs == 0x55555555) { 
    fprintf(stderr, "The object %p has been zapped!\n", loc->o); 
    describe(p); 
    Pike_fatal("Object zapping detected.\n"); 
  } 
  if (p && p->refs == 0x55555555) { 
    fprintf(stderr, "The program %p has been zapped!\n", p); 
    describe(p); 
    fprintf(stderr, "Which taken from the object %p\n", loc->o); 
    describe(loc->o); 
    Pike_fatal("Looks like the program %p has been zapped!\n", p); 
  } 
#endif /* DEBUG_MALLOC */ 
 
  while(--depth>=0) 
  { 
    struct inherit *inh = loc->inherit; 
 
    if (!p) 
      Pike_error("Attempting to access parent of destructed object.\n"); 
 
#ifdef PIKE_DEBUG   
    if(Pike_interpreter.trace_level>8) 
      my_describe_inherit_structure(p); 
#endif 
 
    TRACE((4,"-   i->parent_offset=%d i->parent_identifier=%d\n", 
           inh->parent_offset, 
           inh->parent_identifier)); 
 
    TRACE((4,"-   o->parent_identifier=%d inherit->identifier_level=%d\n", 
           (p->flags & PROGRAM_USES_PARENT) ? 
           LOW_PARENT_INFO(loc->o, p)->parent_identifier : -1, 
           inh->identifier_level)); 
 
    switch(inh->parent_offset) 
    { 
      default: 
        { 
          /* Find the program that inherited us. */ 
          int my_level = inh->inherit_level; 
#ifdef PIKE_DEBUG 
        if(!my_level) 
            Pike_fatal("Gahhh! inherit level zero in wrong place!\n"); 
#endif 
        while(loc->inherit->inherit_level >= my_level) 
          { 
            TRACE((5,"-   inherit-- (%d >= %d)\n", 
                   loc->inherit->inherit_level, my_level)); 
            loc->inherit--; 
            TRACE((5, "-   identifier_level: %d\n", 
                   loc->inherit->identifier_level)); 
          } 
 
          find_external_context(loc, inh->parent_offset); 
          TRACE((5, 
                 "-    inh->parent_identifier: %d\n" 
                 "-    inh->identifier_level: %d\n" 
                 "-    loc->parent_identifier: %d\n" 
                 "-    loc->inherit->parent_offset: %d\n" 
                 "-    loc->inherit->identifier_level: %d\n", 
                 inh->parent_identifier, 
                 inh->identifier_level, 
                 loc->parent_identifier, 
                 loc->inherit->parent_offset, 
                 loc->inherit->identifier_level)); 
 
          loc->parent_identifier = 
            inh->parent_identifier + 
            loc->inherit->identifier_level; 
          TRACE((5, "-    parent_identifier: %d\n", loc->parent_identifier)); 
        } 
        break; 
 
      case INHERIT_PARENT: 
        TRACE((5,"-   Following inherit->parent\n")); 
        loc->parent_identifier=inh->parent_identifier; 
        loc->o=inh->parent; 
#ifdef PIKE_DEBUG   
      TRACE((5, "-   parent_identifier: %d\n" 
               "-   o: %p\n" 
               "-   inh: %"PRINTPTRDIFFT"d\n", 
               loc->parent_identifier, 
               loc->o, 
               loc->inherit - loc->o->prog->inherits)); 
        if(Pike_interpreter.trace_level>5) { 
          dump_program_tables(loc->o->prog, 4); 
        } 
#endif 
      break; 
 
      case OBJECT_PARENT: 
        TRACE((5,"-   Following o->parent\n")); 
 
#ifdef PIKE_DEBUG 
      /* Can this happen legitimately? Well, someone will hopefully 
         * let me know in that case. /mast */ 
        if (!(p->flags & PROGRAM_USES_PARENT)) 
          Pike_fatal ("Attempting to access parent of object without parent pointer.\n"); 
#endif 
 
        loc->parent_identifier=LOW_PARENT_INFO(loc->o,p)->parent_identifier; 
        loc->o=LOW_PARENT_INFO(loc->o,p)->parent; 
#ifdef PIKE_DEBUG   
      TRACE((5, "-   parent_identifier: %d\n" 
               "-   o: %p\n", 
               loc->parent_identifier, 
               loc->o)); 
        if(Pike_interpreter.trace_level>5) { 
          dump_program_tables(loc->o->prog, 4); 
        } 
#endif 
      break; 
    } 
 
#ifdef PIKE_DEBUG 
    /* I don't think this should happen either. The gc doesn't zap the 
     * pointer even if the object is destructed, at least. /mast */ 
    if (!loc->o) Pike_fatal ("No parent object.\n"); 
#endif 
 
    p = loc->o->prog; 
 
#ifdef DEBUG_MALLOC 
    if (loc->o->refs == 0x55555555) { 
      fprintf(stderr, "The object %p has been zapped!\n", loc->o); 
      describe(p); 
      Pike_fatal("Object zapping detected.\n"); 
    } 
    if (p && p->refs == 0x55555555) { 
      fprintf(stderr, "The program %p has been zapped!\n", p); 
      describe(p); 
      fprintf(stderr, "Which taken from the object %p\n", loc->o); 
      describe(loc->o); 
      Pike_fatal("Looks like the program %p has been zapped!\n", p); 
    } 
#endif /* DEBUG_MALLOC */ 
 
    if (p) { 
#ifdef PIKE_DEBUG 
      if(loc->parent_identifier < 0 || 
         loc->parent_identifier > p->num_identifier_references) 
        Pike_fatal("Identifier out of range, loc->parent_identifer=%d!\n", 
                   loc->parent_identifier); 
#endif 
      loc->inherit=INHERIT_FROM_INT(p, loc->parent_identifier); 
      TRACE((5, "-   loc->inherit: %"PRINTPTRDIFFT"d\n", 
             loc->inherit - loc->o->prog->inherits)); 
    } 
    else 
      /* Return a valid pointer to a dummy inherit for the convenience 
       * of the caller. Identifier offsets will be bogus but it'll 
       * never get to that since the object is destructed. */ 
      loc->inherit = &dummy_inherit; 
 
    TRACE((5,"-   Parent identifier = %d (%s), inherit # = %ld\n", 
           loc->parent_identifier, 
           p ? ID_FROM_INT(p, loc->parent_identifier)->name->str : "N/A", 
           p ? DO_NOT_WARN((long)(loc->inherit - p->inherits)) : -1)); 
     
#ifdef DEBUG_MALLOC 
    if (p && loc->inherit->storage_offset == 0x55555555) { 
      fprintf(stderr, "The inherit %p has been zapped!\n", loc->inherit); 
      debug_malloc_dump_references(loc->inherit,0,2,0); 
      fprintf(stderr, "It was extracted from the program %p %d\n", p, loc->parent_identifier); 
      describe(p); 
      fprintf(stderr, "Which was in turn taken from the object %p\n", loc->o); 
      describe(loc->o); 
      Pike_fatal("Looks like the program %p has been zapped!\n", p); 
    } 
#endif /* DEBUG_MALLOC */ 
  } 
 
  TRACE((4,"--find_external_context: parent_id=%d (%s)\n", 
         loc->parent_identifier, 
         p ? ID_FROM_INT(p,loc->parent_identifier)->name->str : "N/A" 
         )); 
} 
 
#ifdef PIKE_DEBUG 
void print_return_value(void) 
{ 
  if(Pike_interpreter.trace_level>3) 
  { 
    char *s; 
    dynamic_buffer save_buf; 
 
    init_buf(&save_buf); 
    safe_describe_svalue(Pike_sp-1,0,0); 
    s=simple_free_buf(&save_buf); 
    if((size_t)strlen(s) > (size_t)TRACE_LEN) 
    { 
      s[TRACE_LEN]=0; 
      s[TRACE_LEN-1]='.'; 
      s[TRACE_LEN-2]='.'; 
      s[TRACE_LEN-3]='.'; 
    } 
    fprintf(stderr,"-    value: %s\n",s); 
    free(s); 
  } 
} 
#else 
#define print_return_value() 
#endif 
 
struct callback_list evaluator_callbacks; 
 
 
/* 
 * reset the stack machine. 
 */ 
void reset_evaluator(void) 
{ 
  Pike_fp=0; 
  pop_n_elems(Pike_sp - Pike_interpreter.evaluator_stack); 
 
#ifdef PIKE_DEBUG 
  if (Pike_interpreter.catch_ctx) 
    Pike_fatal ("Catch context spillover.\n"); 
  if (Pike_interpreter.catching_eval_jmpbuf) 
    Pike_fatal ("Got an active catching_eval_jmpbuf.\n"); 
#endif 
} 
 
#ifdef PIKE_DEBUG 
 
#define BACKLOG 100 
struct backlog 
{ 
  PIKE_INSTR_T instruction; 
  INT32 arg,arg2; 
  INT32 program_id; 
  PIKE_OPCODE_T *pc; 
#ifdef _REENTRANT 
  struct thread_state *thread_state; 
#endif 
  ptrdiff_t stack; 
  ptrdiff_t mark_stack; 
}; 
 
struct backlog backlog[BACKLOG]; 
int backlogp=BACKLOG-1; 
 
static INLINE void low_debug_instr_prologue (PIKE_INSTR_T instr) 
{ 
  if(Pike_interpreter.trace_level > 2) 
  { 
    char *file = NULL, *f; 
    struct pike_string *filep; 
    INT_TYPE linep; 
 
    filep = get_line(Pike_fp->pc,Pike_fp->context->prog,&linep); 
    if (filep && !filep->size_shift) { 
      file = filep->str; 
      while((f=STRCHR(file,'/'))) 
        file=f+1; 
    } 
    fprintf(stderr,"- %s:%4ld:%p(%"PRINTPTRDIFFT"d): " 
            "%-25s %4"PRINTPTRDIFFT"d %4"PRINTPTRDIFFT"d\n", 
            file ? file : "-",(long)linep, 
            Pike_fp->pc, Pike_fp->pc - Pike_fp->context->prog->program, 
            get_opcode_name(instr), 
            Pike_sp-Pike_interpreter.evaluator_stack, 
            Pike_mark_sp-Pike_interpreter.mark_stack); 
    free_string(filep); 
  } 
 
#ifdef HAVE_COMPUTED_GOTO 
  if (instr)  
    ADD_RUNNED(instr); 
  else 
    Pike_fatal("NULL Instruction!\n"); 
#else /* !HAVE_COMPUTED_GOTO */ 
  if(instr + F_OFFSET < F_MAX_OPCODE)  
    ADD_RUNNED(instr); 
#endif /* HAVE_COMPUTED_GOTO */ 
 
  if(d_flag ) 
  { 
    backlogp++; 
    if(backlogp >= BACKLOG) backlogp=0; 
 
    backlog[backlogp].program_id = Pike_fp->context->prog->id; 
    backlog[backlogp].instruction=instr; 
    backlog[backlogp].pc = Pike_fp->pc; 
    backlog[backlogp].stack = Pike_sp - Pike_interpreter.evaluator_stack; 
    backlog[backlogp].mark_stack = Pike_mark_sp - Pike_interpreter.mark_stack; 
#ifdef _REENTRANT 
    backlog[backlogp].thread_state=Pike_interpreter.thread_state; 
#endif 
 
#ifdef _REENTRANT 
    CHECK_INTERPRETER_LOCK(); 
    if(d_flag>1) DEBUG_CHECK_THREAD(); 
#endif 
 
    INVALIDATE_SVAL(Pike_sp[0]); 
    INVALIDATE_SVAL(Pike_sp[1]); 
    INVALIDATE_SVAL(Pike_sp[2]); 
    INVALIDATE_SVAL(Pike_sp[3]); 
 
    if(Pike_sp<Pike_interpreter.evaluator_stack || 
       Pike_mark_sp < Pike_interpreter.mark_stack || Pike_fp->locals>Pike_sp) 
      Pike_fatal("Stack error (generic) sp=%p/%p mark_sp=%p/%p locals=%p.\n", 
                 Pike_sp, 
                 Pike_interpreter.evaluator_stack, 
                 Pike_mark_sp, 
                 Pike_interpreter.mark_stack, 
                 Pike_fp->locals); 
 
    if(Pike_mark_sp > Pike_interpreter.mark_stack+Pike_stack_size) 
      Pike_fatal("Mark Stack error (overflow).\n"); 
 
 
    if(Pike_mark_sp < Pike_interpreter.mark_stack) 
      Pike_fatal("Mark Stack error (underflow).\n"); 
 
    if(Pike_sp > Pike_interpreter.evaluator_stack+Pike_stack_size) 
      Pike_fatal("stack error (overflow).\n"); 
 
 
    /* The locals will not be correct when running FILL_STACK 
       (actually, they will always be incorrect before running FILL_STACK, 
       but at least currently that is the first opcode run). 
    */ 
 
    /* as it turns out, this is no longer true.. */ 
    /* if( instr+F_OFFSET != F_FILL_STACK ) */ 
    /* { */ 
    /*     if(/\* Pike_fp->fun>=0 && *\/ Pike_fp->current_object->prog && */ 
    /*        Pike_fp->locals+Pike_fp->num_locals > Pike_sp) */ 
    /*         Pike_fatal("Stack error (stupid! %p %p+%x).\n",Pike_sp, */ 
    /*                    Pike_fp->locals, Pike_fp->num_locals*sizeof(struct svalue)); */ 
    /* } */ 
 
    if(Pike_interpreter.recoveries && 
       (Pike_sp-Pike_interpreter.evaluator_stack < 
        Pike_interpreter.recoveries->stack_pointer)) 
      Pike_fatal("Stack error (underflow).\n"); 
 
    if(Pike_mark_sp > Pike_interpreter.mark_stack && 
       Pike_mark_sp[-1] > Pike_sp) 
      Pike_fatal("Stack error (underflow?)\n"); 
       
    if(d_flag > 9) do_debug(); 
 
    debug_malloc_touch(Pike_fp->current_object); 
    switch(d_flag) 
    { 
      default: 
      case 3: 
        check_object(Pike_fp->current_object); 
        /*      break; */ 
 
      case 2: 
        check_object_context(Pike_fp->current_object, 
                             Pike_fp->context->prog, 
                             Pike_fp->current_object->storage+ 
                             Pike_fp->context->storage_offset); 
      case 1: 
      case 0: 
        break; 
    } 
  } 
} 
 
#define DEBUG_LOG_ARG(ARG)                                    \ 
  (backlog[backlogp].arg = (ARG),                               \ 
   (Pike_interpreter.trace_level>3 ?                            \ 
    sprintf(trace_buffer, "-    Arg = %ld\n",                   \ 
            (long) backlog[backlogp].arg),                      \ 
    write_to_stderr(trace_buffer,strlen(trace_buffer)) : 0)) 
 
#define DEBUG_LOG_ARG2(ARG2)                                  \ 
  (backlog[backlogp].arg2 = (ARG2),                             \ 
   (Pike_interpreter.trace_level>3 ?                            \ 
    sprintf(trace_buffer, "-    Arg2 = %ld\n",                  \ 
            (long) backlog[backlogp].arg2),                     \ 
    write_to_stderr(trace_buffer,strlen(trace_buffer)) : 0)) 
 
void dump_backlog(void) 
{ 
#ifdef _REENTRANT 
  struct thread_state *thread=0; 
#endif 
 
  int e; 
  if(!d_flag || backlogp<0 || backlogp>=BACKLOG) 
    return; 
 
  e=backlogp; 
  do 
  { 
    struct program *p; 
    e++; 
    if(e>=BACKLOG) e=0; 
 
    p = id_to_program (backlog[e].program_id); 
    if (p) 
    { 
      struct pike_string *file; 
      INT_TYPE line; 
 
#ifdef _REENTRANT 
      if(thread != backlog[e].thread_state) 
      { 
        fprintf(stderr,"[Thread swap, Pike_interpreter.thread_state=%p]\n",backlog[e].thread_state); 
        thread = backlog[e].thread_state; 
      } 
#endif 
 
      file = get_line(backlog[e].pc,p, &line); 
#ifdef HAVE_COMPUTED_GOTO 
      fprintf(stderr,"%s:%ld:(%"PRINTPTRDIFFT"d): %s", 
              file->str, 
              (long)line, 
              backlog[e].pc - p->program, 
              get_opcode_name(backlog[e].instruction)); 
#else /* !HAVE_COMPUTED_GOTO */ 
      if(backlog[e].instruction+F_OFFSET > F_MAX_OPCODE) 
      { 
        fprintf(stderr,"%s:%ld:(%"PRINTPTRDIFFT"d): ILLEGAL INSTRUCTION %d\n", 
                file->str, 
                (long)line, 
                backlog[e].pc - p->program, 
                backlog[e].instruction + F_OFFSET); 
        free_string(file); 
        continue; 
      } 
 
      fprintf(stderr,"%s:%ld:(%"PRINTPTRDIFFT"d): %s", 
              file->str, 
              (long)line, 
              backlog[e].pc - p->program, 
              low_get_f_name(backlog[e].instruction + F_OFFSET, p)); 
      if(instrs[backlog[e].instruction].flags & I_HASARG2) 
      { 
        fprintf(stderr,"(%ld,%ld)", 
                (long)backlog[e].arg, 
                (long)backlog[e].arg2); 
      } 
      else if(instrs[backlog[e].instruction].flags & I_POINTER) 
      { 
        fprintf(stderr,"(%+ld)", (long)backlog[e].arg); 
      } 
      else if(instrs[backlog[e].instruction].flags & I_HASARG) 
      { 
        fprintf(stderr,"(%ld)", (long)backlog[e].arg); 
      } 
      fprintf(stderr," %ld, %ld\n", 
              DO_NOT_WARN((long)backlog[e].stack), 
              DO_NOT_WARN((long)backlog[e].mark_stack)); 
#endif /* HAVE_COMPUTED_GOTO */ 
      free_string(file); 
    } 
  }while(e!=backlogp); 
} 
 
#else  /* PIKE_DEBUG */ 
 
#define DEBUG_LOG_ARG(arg) 0 
#define DEBUG_LOG_ARG2(arg2) 0 
 
#endif        /* !PIKE_DEBUG */ 
 
 
#define POP_CATCH_CONTEXT do {                                         \ 
    struct catch_context *cc = Pike_interpreter.catch_ctx;             \ 
    DO_IF_DEBUG (                                                      \ 
      TRACE((3,"-   Popping catch context %p ==> %p\n",                        \ 
            cc, cc ? cc->prev : NULL));                                \ 
      if (!Pike_interpreter.catching_eval_jmpbuf)                      \ 
       Pike_fatal ("Not in catching eval.\n");                         \ 
      if (!cc)                                                         \ 
       Pike_fatal ("Catch context dropoff.\n");                        \ 
      if (cc->frame != Pike_fp)                                                \ 
       Pike_fatal ("Catch context doesn't belong to this frame.\n");   \ 
      if (Pike_mark_sp != cc->recovery.mark_sp + Pike_interpreter.mark_stack) \ 
       Pike_fatal ("Mark sp diff in catch context pop.\n");            \ 
    );                                                                 \ 
    debug_malloc_touch (cc);                                           \ 
    UNSETJMP (cc->recovery);                                           \ 
    Pike_fp->expendible = cc->save_expendible;                         \ 
    Pike_interpreter.catch_ctx = cc->prev;                             \ 
    really_free_catch_context (cc);                                    \ 
  } while (0) 
 
static struct catch_context *free_catch_context; 
static int num_catch_ctx, num_free_catch_ctx; 
 
PMOD_EXPORT void really_free_catch_context( struct catch_context *data ) 
{ 
    if( num_free_catch_ctx > 100 && free_catch_context ) 
    { 
      num_catch_ctx--; 
      free( data ); 
    } 
    else 
    { 
      data->prev = free_catch_context; 
 
      num_free_catch_ctx++; 
      PIKE_MEM_NA(*data); 
      free_catch_context = data; 
    } 
} 
 
struct catch_context *alloc_catch_context(void) 
{ 
    struct catch_context *res; 
    if( free_catch_context ) 
    { 
        num_free_catch_ctx--; 
        res = free_catch_context; 
        PIKE_MEM_RW(res->prev); 
        free_catch_context = res->prev; 
        PIKE_MEM_WO(*res); 
    } 
    else 
    { 
        num_catch_ctx++; 
        res = xalloc( sizeof( struct catch_context ) ); 
    } 
    return res; 
} 
 
void count_memory_in_catch_contexts(size_t *num, size_t *size ) 
{ 
  *num = (num_catch_ctx-num_free_catch_ctx); 
  *size = num_catch_ctx * (sizeof(struct catch_context)+8); /* assumes 8 bytes overhead. */ 
} 
 
static void free_all_catch_context_blocks(void) 
{ 
    struct catch_context *x = free_catch_context, *n; 
    while( x ) 
    { 
        PIKE_MEM_RW(x->prev); 
        n = x->prev; 
        free( x ); 
        x = n; 
    } 
    free_catch_context = NULL; 
} 
 
static int catching_eval_instruction (PIKE_OPCODE_T *pc); 
 
 
#ifdef PIKE_USE_MACHINE_CODE 
#ifdef OPCODE_INLINE_RETURN 
/* Catch notes: 
 * 
 * Typical F_CATCH use: 
 * 
 *   F_CATCH 
 *      F_PTR   continue_label 
 * 
 *   ENTRY 
 * 
 *   catch body 
 * 
 *   F_EXIT_CATCH 
 * 
 *   F_BRANCH 
 *      F_PTR   continue_label 
 * 
 *   ENTRY 
 * 
 * continue_label: 
 * 
 *   rest of code. 
 */ 
 
/* Modified calling-conventions to simplify code-generation when 
 * INTER_RETURN is inlined. 
 * 
 * cf interpret_functions.h:F_CATCH 
 * 
 * Arguments: 
 *   addr: 
 *     Address where the continue POINTER (INT32) is stored. 
 *     Directly after the POINTER is the ENTRY for the catch block. 
 * 
 * Returns: 
 *   (PIKE_OPCODE_T *)-1 on INTER_RETURN. 
 *   jump_destination otherwise. 
 */ 
PIKE_OPCODE_T *inter_return_opcode_F_CATCH(PIKE_OPCODE_T *addr) 
{ 
#ifdef PIKE_DEBUG 
  if (d_flag || Pike_interpreter.trace_level > 2) { 
    low_debug_instr_prologue (F_CATCH - F_OFFSET); 
    if (Pike_interpreter.trace_level>3) { 
      sprintf(trace_buffer, "-    Addr = %p\n", addr); 
      write_to_stderr(trace_buffer,strlen(trace_buffer)); 
    } 
  } 
#endif 
  { 
    struct catch_context *new_catch_ctx = alloc_catch_context(); 
#ifdef PIKE_DEBUG 
      new_catch_ctx->frame = Pike_fp; 
      init_recovery (&new_catch_ctx->recovery, 0, 0, PERR_LOCATION()); 
#else 
      init_recovery (&new_catch_ctx->recovery, 0); 
#endif 
    new_catch_ctx->save_expendible = Pike_fp->expendible; 
    new_catch_ctx->continue_reladdr = ((INT32 *)addr)[0] 
      /* We need to run the entry prologue... */ 
      - ENTRY_PROLOGUE_SIZE; 
 
    new_catch_ctx->next_addr = addr; 
    new_catch_ctx->prev = Pike_interpreter.catch_ctx; 
    Pike_interpreter.catch_ctx = new_catch_ctx; 
    DO_IF_DEBUG({ 
        TRACE((3,"-   Pushed catch context %p\n", new_catch_ctx)); 
      }); 
  } 
 
  Pike_fp->expendible = Pike_fp->locals + Pike_fp->num_locals; 
 
  /* Need to adjust next_addr by sizeof(INT32) to skip past the jump 
   * address to the continue position after the catch block. */ 
  addr = (PIKE_OPCODE_T *) ((INT32 *) addr + 1); 
 
  if (Pike_interpreter.catching_eval_jmpbuf) { 
    /* There's already a catching_eval_instruction around our 
     * eval_instruction, so we can just continue. */ 
    debug_malloc_touch_named (Pike_interpreter.catch_ctx, "(1)"); 
    /* Skip past the entry prologue... */ 
    addr += ENTRY_PROLOGUE_SIZE; 
    DO_IF_DEBUG({ 
        TRACE((3,"-   In active catch; continuing at %p\n", addr)); 
      }); 
    return addr; 
  } 
  else { 
    debug_malloc_touch_named (Pike_interpreter.catch_ctx, "(2)"); 
 
    while (1) { 
      /* Loop here every time an exception is caught. Once we've 
       * gotten here and set things up to run eval_instruction from 
       * inside catching_eval_instruction, we keep doing it until it's 
       * time to return. */ 
 
      int res; 
 
      DO_IF_DEBUG({ 
          TRACE((3,"-   Activating catch; calling %p in context %p\n", 
                 addr, Pike_interpreter.catch_ctx)); 
        }); 
 
      res = catching_eval_instruction (addr); 
 
      DO_IF_DEBUG({ 
          TRACE((3,"-   catching_eval_instruction(%p) returned %d\n", 
                 addr, res)); 
        }); 
 
      if (res != -3) { 
        /* There was an inter return inside the evaluated code. Just 
         * propagate it. */ 
        DO_IF_DEBUG ({ 
            TRACE((3,"-   Returning from catch.\n")); 
            if (res != -1) Pike_fatal ("Unexpected return value from " 
                                       "catching_eval_instruction: %d\n", res); 
          }); 
        break; 
      } 
 
      else { 
        /* Caught an exception. */ 
        struct catch_context *cc = Pike_interpreter.catch_ctx; 
 
        DO_IF_DEBUG ({ 
            TRACE((3,"-   Caught exception. catch context: %p\n", cc)); 
            if (!cc) Pike_fatal ("Catch context dropoff.\n"); 
            if (cc->frame != Pike_fp) 
              Pike_fatal ("Catch context doesn't belong to this frame.\n"); 
          }); 
 
        debug_malloc_touch_named (cc, "(3)"); 
        UNSETJMP (cc->recovery); 
        Pike_fp->expendible = cc->save_expendible; 
        move_svalue (Pike_sp++, &throw_value); 
        mark_free_svalue (&throw_value); 
        low_destruct_objects_to_destruct(); 
 
        if (cc->continue_reladdr < 0) 
          FAST_CHECK_THREADS_ON_BRANCH(); 
        addr = cc->next_addr + cc->continue_reladdr; 
 
        DO_IF_DEBUG({ 
            TRACE((3,"-   Popping catch context %p ==> %p\n", 
                   cc, cc->prev)); 
            if (!addr) Pike_fatal ("Unexpected null continue addr.\n"); 
          }); 
 
        Pike_interpreter.catch_ctx = cc->prev; 
        really_free_catch_context (cc); 
      } 
    } 
 
    return (PIKE_OPCODE_T *)(ptrdiff_t)-1;  /* INTER_RETURN; */ 
  } 
} 
 
void *do_inter_return_label = (void*)(ptrdiff_t)-1; 
#else 
/* Labels to jump to to cause eval_instruction to return */ 
/* FIXME: Replace these with assembler lables */ 
void *do_inter_return_label = NULL; 
void *dummy_label = NULL; 
#endif 
 
#ifndef CALL_MACHINE_CODE 
#define CALL_MACHINE_CODE(pc)                                       \ 
  do {                                                          \ 
    /* The test is needed to get the labels to work... */       \ 
    if (pc) {                                                   \ 
      /* No extra setup needed!                                 \ 
       */                                                       \ 
      return ((int (*)(void))(pc))();                           \ 
    }                                                           \ 
  } while(0) 
#endif /* !CALL_MACHINE_CODE */ 
 
#ifndef EXIT_MACHINE_CODE 
#define EXIT_MACHINE_CODE() 
#endif 
 
/* Intended to be called from machine code before inlined function 
 * calls (primarily the CALL_BUILTIN opcodes), to ensure thread 
 * switching. */ 
void call_check_threads_etc() 
{ 
  FAST_CHECK_THREADS_ON_CALL(); 
} 
 
#if defined(OPCODE_INLINE_BRANCH) || defined(INS_F_JUMP) || \ 
    defined(INS_F_JUMP_WITH_ARG) || defined(INS_F_JUMP_WITH_TWO_ARGS) 
/* Intended to be called from machine code on backward branch jumps, 
 * to ensure thread switching. */ 
void branch_check_threads_etc() 
{ 
  FAST_CHECK_THREADS_ON_BRANCH(); 
} 
#endif 
 
#ifdef PIKE_DEBUG 
 
static void debug_instr_prologue (PIKE_INSTR_T instr) 
{ 
  low_debug_instr_prologue (instr); 
} 
 
#define DEBUG_PROLOGUE(OPCODE, EXTRA) do {                            \ 
    if (d_flag || Pike_interpreter.trace_level > 2) {                   \ 
      debug_instr_prologue ((OPCODE) - F_OFFSET);                       \ 
      EXTRA;                                                            \ 
    }                                                                   \ 
  } while (0) 
 
/* The following are intended to be called directly from generated 
 * machine code. */ 
void simple_debug_instr_prologue_0 (PIKE_INSTR_T instr) 
{ 
  if (d_flag || Pike_interpreter.trace_level > 2) 
    low_debug_instr_prologue (instr); 
} 
void simple_debug_instr_prologue_1 (PIKE_INSTR_T instr, INT32 arg) 
{ 
  if (d_flag || Pike_interpreter.trace_level > 2) { 
    low_debug_instr_prologue (instr); 
    DEBUG_LOG_ARG (arg); 
  } 
} 
void simple_debug_instr_prologue_2 (PIKE_INSTR_T instr, INT32 arg1, INT32 arg2) 
{ 
  if (d_flag || Pike_interpreter.trace_level > 2) { 
    low_debug_instr_prologue (instr); 
    DEBUG_LOG_ARG (arg1); 
    DEBUG_LOG_ARG2 (arg2); 
  } 
} 
 
#endif        /* !PIKE_DEBUG */ 
 
#endif /* PIKE_USE_MACHINE_CODE */ 
 
/* These don't change when eval_instruction_without_debug is compiled. */ 
#ifdef PIKE_DEBUG 
#define REAL_PIKE_DEBUG 
#define DO_IF_REAL_DEBUG(X) X 
#define DO_IF_NOT_REAL_DEBUG(X) 
#else 
#define DO_IF_REAL_DEBUG(X) 
#define DO_IF_NOT_REAL_DEBUG(X) X 
#endif 
 
#ifdef PIKE_SMALL_EVAL_INSTRUCTION 
#undef PROG_COUNTER 
#define PROG_COUNTER        Pike_fp->pc+1 
#endif /* PIKE_SMALL_EVAL_INSTRUCTION */ 
 
#if defined(PIKE_USE_MACHINE_CODE) || defined(PIKE_SMALL_EVAL_INSTRUCTION) 
 
#ifndef DEF_PROG_COUNTER 
#define DEF_PROG_COUNTER 
#endif /* !DEF_PROG_COUNTER */ 
 
#ifndef DEBUG_PROLOGUE 
#define DEBUG_PROLOGUE(OPCODE, EXTRA) do {} while (0) 
#endif 
 
#define OPCODE0(O,N,F,C) \ 
void PIKE_CONCAT(opcode_,O)(void) { \ 
  DEF_PROG_COUNTER; \ 
  DEBUG_PROLOGUE (O, ;);                                                \ 
C } 
 
#define OPCODE1(O,N,F,C) \ 
void PIKE_CONCAT(opcode_,O)(INT32 arg1) {\ 
  DEF_PROG_COUNTER; \ 
  DEBUG_PROLOGUE (O, DEBUG_LOG_ARG (arg1));                             \ 
C } 
 
#define OPCODE2(O,N,F,C) \ 
void PIKE_CONCAT(opcode_,O)(INT32 arg1,INT32 arg2) { \ 
  DEF_PROG_COUNTER; \ 
  DEBUG_PROLOGUE (O, DEBUG_LOG_ARG (arg1); DEBUG_LOG_ARG2 (arg2));      \ 
C } 
 
#if defined(OPCODE_RETURN_JUMPADDR) || defined(PIKE_SMALL_EVAL_INSTRUCTION) 
 
#define OPCODE0_JUMP(O,N,F,C)                                         \ 
  void *PIKE_CONCAT(jump_opcode_,O)(void) {                             \ 
    void *jumpaddr DO_IF_DEBUG(= NULL);                                 \ 
    DEF_PROG_COUNTER;                                                   \ 
    DEBUG_PROLOGUE (O, ;);                                              \ 
    C;                                                                  \ 
    JUMP_DONE;                                                          \ 
  } 
 
#define OPCODE1_JUMP(O,N,F,C)                                         \ 
  void *PIKE_CONCAT(jump_opcode_,O)(INT32 arg1) {                       \ 
    void *jumpaddr DO_IF_DEBUG(= NULL);                                 \ 
    DEF_PROG_COUNTER;                                                   \ 
    DEBUG_PROLOGUE (O, DEBUG_LOG_ARG (arg1));                           \ 
    C;                                                                  \ 
    JUMP_DONE;                                                          \ 
  } 
 
#define OPCODE2_JUMP(O,N,F,C)                                         \ 
  void *PIKE_CONCAT(jump_opcode_,O)(INT32 arg1, INT32 arg2) {           \ 
    void *jumpaddr DO_IF_DEBUG(= NULL);                                 \ 
    DEF_PROG_COUNTER;                                                   \ 
    DEBUG_PROLOGUE (O, DEBUG_LOG_ARG (arg1); DEBUG_LOG_ARG2 (arg2));    \ 
    C;                                                                  \ 
    JUMP_DONE;                                                          \ 
  } 
 
#define SET_PROG_COUNTER(X) (jumpaddr = (X)) 
 
#ifdef PIKE_DEBUG 
#define JUMP_DONE do {                                                      \ 
    if (!jumpaddr)                                                      \ 
      Pike_fatal ("Instruction didn't set jump address.\n");            \ 
    return jumpaddr;                                                    \ 
  } while (0) 
#else 
#define JUMP_DONE return jumpaddr 
#endif 
 
#else  /* !OPCODE_RETURN_JUMPADDR && !PIKE_SMALL_EVAL_INSTRUCTION */ 
#define OPCODE0_JUMP OPCODE0 
#define OPCODE1_JUMP OPCODE1 
#define OPCODE2_JUMP OPCODE2 
#define JUMP_DONE DONE 
#endif      /* OPCODE_RETURN_JUMPADDR || PIKE_SMALL_EVAL_INSTRUCTION */ 
 
#if defined(OPCODE_INLINE_BRANCH) || defined(PIKE_SMALL_EVAL_INSTRUCTION) 
#define TEST_OPCODE0(O,N,F,C) \ 
ptrdiff_t PIKE_CONCAT(test_opcode_,O)(void) { \ 
    ptrdiff_t branch_taken = 0; \ 
    DEF_PROG_COUNTER; \ 
    DEBUG_PROLOGUE (O, ;);                                              \ 
    C; \ 
    return branch_taken; \ 
  } 
 
#define TEST_OPCODE1(O,N,F,C) \ 
ptrdiff_t PIKE_CONCAT(test_opcode_,O)(INT32 arg1) {\ 
    ptrdiff_t branch_taken = 0; \ 
    DEF_PROG_COUNTER; \ 
    DEBUG_PROLOGUE (O, DEBUG_LOG_ARG (arg1));                           \ 
    C; \ 
    return branch_taken; \ 
  } 
 
 
#define TEST_OPCODE2(O,N,F,C) \ 
ptrdiff_t PIKE_CONCAT(test_opcode_,O)(INT32 arg1, INT32 arg2) { \ 
    ptrdiff_t branch_taken = 0; \ 
    DEF_PROG_COUNTER; \ 
    DEBUG_PROLOGUE (O, DEBUG_LOG_ARG (arg1); DEBUG_LOG_ARG2 (arg2));    \ 
    C; \ 
    return branch_taken; \ 
  } 
 
#define DO_BRANCH()   (branch_taken = -1) 
#define DONT_BRANCH()       (branch_taken = 0) 
#else /* !OPCODE_INLINE_BRANCH && !PIKE_SMALL_EVAL_INSTRUCTION */ 
#define TEST_OPCODE0(O,N,F,C) OPCODE0_PTRJUMP(O,N,F,C) 
#define TEST_OPCODE1(O,N,F,C) OPCODE1_PTRJUMP(O,N,F,C) 
#define TEST_OPCODE2(O,N,F,C) OPCODE2_PTRJUMP(O,N,F,C) 
#endif /* OPCODE_INLINE_BRANCH || PIKE_SMALL_EVAL_INSTRUCTION */ 
 
#define OPCODE0_TAIL(O,N,F,C) OPCODE0(O,N,F,C) 
#define OPCODE1_TAIL(O,N,F,C) OPCODE1(O,N,F,C) 
#define OPCODE2_TAIL(O,N,F,C) OPCODE2(O,N,F,C) 
 
#define OPCODE0_PTRJUMP(O,N,F,C) OPCODE0_JUMP(O,N,F,C) 
#define OPCODE1_PTRJUMP(O,N,F,C) OPCODE1_JUMP(O,N,F,C) 
#define OPCODE2_PTRJUMP(O,N,F,C) OPCODE2_JUMP(O,N,F,C) 
#define OPCODE0_TAILPTRJUMP(O,N,F,C) OPCODE0_PTRJUMP(O,N,F,C) 
#define OPCODE1_TAILPTRJUMP(O,N,F,C) OPCODE1_PTRJUMP(O,N,F,C) 
#define OPCODE2_TAILPTRJUMP(O,N,F,C) OPCODE2_PTRJUMP(O,N,F,C) 
 
#define OPCODE0_RETURN(O,N,F,C) OPCODE0_JUMP(O,N,F | I_RETURN,C) 
#define OPCODE1_RETURN(O,N,F,C) OPCODE1_JUMP(O,N,F | I_RETURN,C) 
#define OPCODE2_RETURN(O,N,F,C) OPCODE2_JUMP(O,N,F | I_RETURN,C) 
#define OPCODE0_TAILRETURN(O,N,F,C) OPCODE0_RETURN(O,N,F,C) 
#define OPCODE1_TAILRETURN(O,N,F,C) OPCODE1_RETURN(O,N,F,C) 
#define OPCODE2_TAILRETURN(O,N,F,C) OPCODE2_RETURN(O,N,F,C) 
 
/* BRANCH opcodes only generate code for the test, 
 * so that the branch instruction can be inlined. 
 */ 
#define OPCODE0_BRANCH(O,N,F,C) TEST_OPCODE0(O,N,F,C) 
#define OPCODE1_BRANCH(O,N,F,C) TEST_OPCODE1(O,N,F,C) 
#define OPCODE2_BRANCH(O,N,F,C) TEST_OPCODE2(O,N,F,C) 
#define OPCODE0_TAILBRANCH(O,N,F,C) TEST_OPCODE0(O,N,F,C) 
#define OPCODE1_TAILBRANCH(O,N,F,C) TEST_OPCODE1(O,N,F,C) 
#define OPCODE2_TAILBRANCH(O,N,F,C) TEST_OPCODE2(O,N,F,C) 
 
#define OPCODE0_ALIAS(O,N,F,C) 
#define OPCODE1_ALIAS(O,N,F,C) 
#define OPCODE2_ALIAS(O,N,F,C) 
 
#undef HAVE_COMPUTED_GOTO 
 
#ifdef GLOBAL_DEF_PROG_COUNTER 
GLOBAL_DEF_PROG_COUNTER; 
#endif 
 
#ifndef SET_PROG_COUNTER 
#define SET_PROG_COUNTER(X) (PROG_COUNTER=(X)) 
#endif /* SET_PROG_COUNTER */ 
 
#undef DONE 
#undef FETCH 
#undef INTER_RETURN 
 
#define DONE return 
#define FETCH 
#define INTER_RETURN {SET_PROG_COUNTER(do_inter_return_label);JUMP_DONE;} 
 
#if defined(PIKE_USE_MACHINE_CODE) && defined(_M_IX86) 
/* Disable frame pointer optimization */ 
#pragma optimize("y", off) 
#endif 
 
#include "interpret_functions_fixed.h" 
 
#if defined(PIKE_USE_MACHINE_CODE) && defined(_M_IX86) 
/* Restore optimization */ 
#pragma optimize("", on) 
#endif 
 
#ifdef PIKE_SMALL_EVAL_INSTRUCTION 
#undef SET_PROG_COUNTER 
#undef PROG_COUNTER 
#define PROG_COUNTER        pc 
#endif 
 
#endif /* PIKE_USE_MACHINE_CODE || PIKE_SMALL_EVAL_INSTRUCTION */ 
 
#ifdef PIKE_USE_MACHINE_CODE 
 
#ifdef PIKE_DEBUG 
/* Note: The debug code is extracted, to keep the frame size constant. */ 
static int eval_instruction_low(PIKE_OPCODE_T *pc); 
#endif /* PIKE_DEBUG */ 
 
static int eval_instruction(PIKE_OPCODE_T *pc) 
#ifdef PIKE_DEBUG 
{ 
  int x; 
  if (Pike_interpreter.trace_level > 5 && pc) { 
    int i; 
    fprintf(stderr, "Calling code at %p:\n", pc); 
#ifdef PIKE_OPCODE_ALIGN 
    if (((INT32)pc) % PIKE_OPCODE_ALIGN) { 
      Pike_fatal("Odd offset!\n"); 
    } 
#endif /* PIKE_OPCODE_ALIGN */ 
#ifdef DISASSEMBLE_CODE 
    DISASSEMBLE_CODE(pc, 16*4); 
#else /* !DISASSEMBLE_CODE */ 
    for (i=0; i < 16; i+=4) { 
      fprintf(stderr, 
              "  0x%08x 0x%08x 0x%08x 0x%08x\n", 
              ((int *)pc)[i], 
              ((int *)pc)[i+1], 
              ((int *)pc)[i+2], 
              ((int *)pc)[i+3]); 
    } 
#endif /* DISASSEMBLE_CODE */ 
  } 
  x = eval_instruction_low(pc); 
  pike_trace(3, "-    eval_instruction(%p) ==> %d\n", pc, x); 
  return x; 
} 
 
static int eval_instruction_low(PIKE_OPCODE_T *pc) 
#endif /* PIKE_DEBUG */ 
{ 
#ifndef OPCODE_INLINE_RETURN 
  if(pc == NULL) { 
    if(do_inter_return_label != NULL) 
      Pike_fatal("eval_instruction called with NULL (twice).\n"); 
 
#ifdef __GNUC__ 
    do_inter_return_label = && inter_return_label; 
#elif defined (_M_IX86) 
    /* MSVC. */ 
    _asm 
    { 
      lea eax,inter_return_label 
      mov do_inter_return_label,eax 
    } 
#else 
#error Machine code not supported with this compiler. 
#endif 
 
#if 0 
    /* Paranoia. 
     * 
     * This can happen on systems with delay slots if the labels aren't 
     * used explicitly. 
     */ 
    if (do_inter_return_label == do_escape_catch_label) { 
      Pike_fatal("Inter return and escape catch labels are equal: %p\n", 
                 do_inter_return_label); 
    } 
#endif 
 
    /* Trick optimizer */ 
    if(!dummy_label) 
      return 0; 
  } 
 
  /* This else is important to avoid an overoptimization bug in (at 
   * least) gcc 4.0.2 20050808 which caused the address stored in 
   * do_inter_return_label to be at the CALL_MACHINE_CODE below. */ 
  else { 
#endif /* !OPCODE_INLINE_RETURN */ 
    CALL_MACHINE_CODE(pc); 
 
#ifndef OPCODE_INLINE_RETURN 
    /* This code is never reached, but will 
     * prevent gcc from optimizing the labels below too much 
     */ 
 
#ifdef PIKE_DEBUG 
    fprintf(stderr,"We have reached the end of the world!\n"); 
#endif 
  } 
 
#ifdef __GNUC__ 
  goto *dummy_label; 
#endif 
 
 inter_return_label: 
#endif /*!OPCODE_INLINE_RETURUN */ 
#ifdef PIKE_DEBUG 
  pike_trace(3, "-    Inter return\n"); 
#endif 
  EXIT_MACHINE_CODE(); 
  return -1; 
} 
 
#else /* PIKE_USE_MACHINE_CODE */ 
 
 
#ifndef SET_PROG_COUNTER 
#define SET_PROG_COUNTER(X) (PROG_COUNTER=(X)) 
#endif /* SET_PROG_COUNTER */ 
 
#ifdef HAVE_COMPUTED_GOTO 
int lookup_sort_fun(const void *a, const void *b) 
{ 
  return (int)(((ptrdiff_t)((struct op_2_f *)a)->opcode) - 
               ((ptrdiff_t)((struct op_2_f *)b)->opcode)); 
} 
#endif /* HAVE_COMPUTED_GOTO */ 
 
/* NOTE: Due to the implementation of computed goto, 
 *       interpreter.h may only be included once. 
 */ 
#if defined(PIKE_DEBUG) && !defined(HAVE_COMPUTED_GOTO) 
#define eval_instruction eval_instruction_with_debug 
#include "interpreter_debug.h" 
 
#undef eval_instruction 
#define eval_instruction eval_instruction_without_debug 
 
#undef PIKE_DEBUG 
#undef NDEBUG 
#undef DO_IF_DEBUG 
#define DO_IF_DEBUG(X) 
#define print_return_value() 
#include "interpreter.h" 
 
#define PIKE_DEBUG 
#define NDEBUG 
#undef DO_IF_DEBUG 
#define DO_IF_DEBUG(X) X 
#undef print_return_value 
 
#undef eval_instruction 
 
static INLINE int eval_instruction(unsigned char *pc) 
{ 
  if(d_flag || Pike_interpreter.trace_level>2) 
    return eval_instruction_with_debug(pc); 
  else 
    return eval_instruction_without_debug(pc); 
} 
 
 
#else /* !PIKE_DEBUG || HAVE_COMPUTED_GOTO */ 
#include "interpreter.h" 
#endif 
 
 
#endif /* PIKE_USE_MACHINE_CODE */ 
 
#undef REAL_PIKE_DEBUG 
#undef DO_IF_REAL_DEBUG 
#undef DO_IF_NOT_REAL_DEBUG 
 
 
static void do_trace_call(INT32 args, dynamic_buffer *old_buf) 
{ 
  struct pike_string *filep = NULL; 
  char *file, *s; 
  INT_TYPE linep; 
  INT32 e; 
  ptrdiff_t len = 0; 
 
  my_strcat("("); 
  for(e=0;e<args;e++) 
  { 
    if(e) my_strcat(","); 
    safe_describe_svalue(Pike_sp-args+e,0,0); 
  } 
  my_strcat(")"); 
 
  s=simple_free_buf(old_buf); 
  if((size_t)strlen(s) > (size_t)TRACE_LEN) 
  { 
    s[TRACE_LEN]=0; 
    s[TRACE_LEN-1]='.'; 
    s[TRACE_LEN-2]='.'; 
    s[TRACE_LEN-3]='.'; 
  } 
 
  if(Pike_fp && Pike_fp->pc) 
  { 
    char *f; 
    filep = get_line(Pike_fp->pc,Pike_fp->context->prog,&linep); 
    if (filep->size_shift) 
      file = "..."; 
    else { 
      file = filep->str; 
      while((f = STRCHR(file, '/')) 
#ifdef __NT__ 
          || (f = STRCHR(file, '\\')) 
#endif /* __NT__ */ 
          ) 
        file=f+1; 
      len = filep->len - (file - filep->str); 
    } 
  }else{ 
    linep=0; 
    file="-"; 
  } 
 
  if (len < 30) 
  { 
    char buf[40]; 
    if (linep) 
      SNPRINTF(buf, sizeof (buf), "%s:%ld:", file, (long)linep); 
    else 
      SNPRINTF(buf, sizeof (buf), "%s:", file); 
    fprintf(stderr, "- %-20s %s\n",buf,s); 
  } else if (linep) { 
    fprintf(stderr, "- %s:%ld: %s\n", file, (long)linep, s); 
  } else { 
    fprintf(stderr, "- %s: %s\n", file, s); 
  } 
 
  if (filep) { 
    free_string(filep); 
  } 
  free(s); 
} 
 
static void do_trace_func_return (int got_retval, struct object *o, int fun) 
{ 
  dynamic_buffer save_buf; 
  init_buf (&save_buf); 
  if (o) { 
    if (o->prog) { 
      struct identifier *id = ID_FROM_INT (o->prog, fun); 
      char buf[50]; 
      sprintf(buf, "%lx->", DO_NOT_WARN((long) PTR_TO_INT (o))); 
      my_strcat(buf); 
      if (id->name->size_shift) 
        my_strcat ("[widestring function name]"); 
      else 
        my_strcat(id->name->str); 
      my_strcat ("() "); 
    } 
    else 
      my_strcat ("function in destructed object "); 
  } 
  do_trace_return (got_retval, &save_buf); 
} 
 
static void do_trace_return (int got_retval, dynamic_buffer *old_buf) 
{ 
  struct pike_string *filep = NULL; 
  char *file, *s; 
  INT_TYPE linep; 
 
  if (got_retval) { 
    my_strcat ("returns: "); 
    safe_describe_svalue(Pike_sp-1,0,0); 
  } 
  else 
    my_strcat ("returns with no value"); 
 
  s=simple_free_buf(old_buf); 
  if((size_t)strlen(s) > (size_t)TRACE_LEN) 
  { 
    s[TRACE_LEN]=0; 
    s[TRACE_LEN-1]='.'; 
    s[TRACE_LEN-2]='.'; 
    s[TRACE_LEN-3]='.'; 
  } 
 
  if(Pike_fp && Pike_fp->pc) 
  { 
    char *f; 
    filep = get_line(Pike_fp->pc,Pike_fp->context->prog,&linep); 
    if (filep->size_shift) 
      file = "..."; 
    else { 
      file = filep->str; 
      while((f=STRCHR(file,'/'))) 
        file=f+1; 
    } 
  }else{ 
    linep=0; 
    file="-"; 
  } 
 
  { 
    char buf[40]; 
    if (linep) 
      SNPRINTF(buf, sizeof (buf), "%s:%ld:", file, (long)linep); 
    else 
      SNPRINTF(buf, sizeof (buf), "%s:", file); 
    fprintf(stderr,"- %-20s %s\n",buf,s); 
  } 
 
  if (filep) { 
    free_string(filep); 
  } 
  free(s); 
} 
 
static struct pike_frame_chunk { 
  struct pike_frame_chunk *next; 
} *pike_frame_chunks; 
static int num_pike_frame_chunks; 
static int num_pike_frames; 
 
PMOD_EXPORT void really_free_pike_frame( struct pike_frame *X ) 
{ 
    free_object(X->current_object); 
    if(X->current_program) 
        free_program(X->current_program); 
    if(X->scope) 
        free_pike_scope(X->scope); 
    DO_IF_SECURITY( if(X->current_creds) free_object(X->current_creds) ); 
    DO_IF_DEBUG( 
        if(X->flags & PIKE_FRAME_MALLOCED_LOCALS) 
            Pike_fatal("Pike frame is not supposed to have malloced locals here!\n")); 
  DO_IF_DMALLOC( 
    X->current_program=0; 
    X->context=0; 
    X->scope=0; 
    X->current_object=0; 
    X->flags=0; 
    X->expendible=0; 
    X->locals=0; 
    DO_IF_SECURITY( X->current_creds=0; ) 
  ); 
  X->next = free_pike_frame; 
  PIKE_MEMPOOL_FREE(&free_pike_frame, X, sizeof(struct pike_frame)); 
  free_pike_frame = X; 
} 
 
struct pike_frame *alloc_pike_frame(void) 
{ 
    struct pike_frame *res; 
    if( free_pike_frame ) 
    { 
      res = free_pike_frame; 
      PIKE_MEMPOOL_ALLOC(&free_pike_frame, res, sizeof(struct pike_frame)); 
      PIKE_MEM_RW_RANGE(&res->next, sizeof(void*)); 
      free_pike_frame = res->next; 
      PIKE_MEM_WO_RANGE(&res->next, sizeof(void*)); 
      res->refs=0; 
      add_ref(res);     /* For DMALLOC... */ 
      res->flags=0; 
      res->next=0; 
      res->scope=0; 
 
      DO_IF_SECURITY( 
        if(CURRENT_CREDS) { 
          add_ref(res->current_creds=CURRENT_CREDS); 
        } else { 
          res->current_creds = 0; 
        }); 
 
      return res; 
    } 
 
    /* Need to allocate more. */ 
    { 
      unsigned int i; 
#define FRAMES_PER_CHUNK ((4096*4-8-sizeof(struct pike_frame_chunk))/sizeof(struct pike_frame)) 
#define FRAME_CHUNK_SIZE (FRAMES_PER_CHUNK*sizeof(struct pike_frame))+sizeof(struct pike_frame_chunk) 
 
      void *p = xalloc( FRAME_CHUNK_SIZE ); 
      num_pike_frame_chunks++; 
      ((struct pike_frame_chunk*)p)->next = pike_frame_chunks; 
      pike_frame_chunks = p; 
      free_pike_frame = res = (struct pike_frame*)((char*)p+sizeof(struct pike_frame_chunk)); 
      for( i=1; i<FRAMES_PER_CHUNK; i++ ) 
      { 
        res->next = &free_pike_frame[i]; 
        res = res->next; 
      } 
      res->next = NULL; 
      num_pike_frames+=FRAMES_PER_CHUNK; 
    } 
    return alloc_pike_frame(); 
} 
 
void count_memory_in_pike_frames(size_t *num, size_t *size ) 
{ 
  *num = num_pike_frames; 
  *size = num_pike_frame_chunks * (FRAME_CHUNK_SIZE*8); 
} 
#undef FRAMES_PER_CHUNK 
#undef FRAME_CHUNK_SIZE 
 
static void free_all_pike_frame_blocks(void) 
{ 
  struct pike_frame_chunk *x = pike_frame_chunks, *n; 
  while( x ) 
  { 
    n = x->next; 
    free(x); 
    x = n; 
  } 
  free_pike_frame = NULL; 
  pike_frame_chunks = NULL; 
  num_pike_frames=0; 
  num_pike_frame_chunks=0; 
} 
 
void really_free_pike_scope(struct pike_frame *scope) 
{ 
  if(scope->flags & PIKE_FRAME_MALLOCED_LOCALS) 
  { 
    free_mixed_svalues(scope->locals,scope->num_locals); 
    free((char *)(scope->locals)); 
#ifdef PIKE_DEBUG 
    scope->flags&=~PIKE_FRAME_MALLOCED_LOCALS; 
#endif 
  } 
  really_free_pike_frame(scope); 
} 
 
void *lower_mega_apply( INT32 args, struct object *o, ptrdiff_t fun ) 
{ 
  struct program *p; 
  check_stack(256); 
  check_mark_stack(256); 
 
  if( (p = o->prog) ) 
  { 
    struct svalue *save_sp = Pike_sp - args; 
    struct reference *ref = p->identifier_references + fun; 
    struct inherit *context = p->inherits + ref->inherit_offset; 
    struct identifier *function = context->prog->identifiers + ref->identifier_offset; 
    struct svalue *constant = NULL; 
    struct pike_frame *new_frame = NULL; 
 
    int type = (function->identifier_flags & (IDENTIFIER_TYPE_MASK|IDENTIFIER_ALIAS)); 
    if( o->prog != pike_trampoline_program && function->func.offset != -1 ) 
    { 
      switch( type ) 
      { 
        case IDENTIFIER_CONSTANT: 
          constant = &context->prog->constants[function->func.const_info.offset].sval; 
          if( TYPEOF(*constant) != PIKE_T_PROGRAM ) 
            break; 
        case IDENTIFIER_C_FUNCTION: 
        case IDENTIFIER_PIKE_FUNCTION: 
          if( !new_frame ) 
          { 
            new_frame=alloc_pike_frame(); 
            debug_malloc_touch(new_frame); 
          } 
#ifdef PROFILING 
          new_frame->children_base = Pike_interpreter.accounted_time; 
          new_frame->start_time = get_cpu_time() - Pike_interpreter.unlocked_time; 
 
          /* This is mostly for profiling, but 
           * could also be used to find out the name of a function 
           * in a destructed object. -hubbe 
           * 
           * Since it not used for anything but profiling yet, I will 
           * put it here until someone needs it. -Hubbe 
           */ 
          new_frame->ident = ref->identifier_offset; 
          DO_IF_PROFILING_DEBUG({ 
              fprintf(stderr, "%p{: Push at %" PRINT_CPU_TIME 
                      " %" PRINT_CPU_TIME "\n", 
                      Pike_interpreter.thread_state, new_frame->start_time, 
                      new_frame->children_base); 
            }); 
#endif 
          new_frame->next = Pike_fp; 
          add_ref(new_frame->current_object = o); 
          add_ref(new_frame->current_program = p); 
          new_frame->context = context; 
          new_frame->fun = DO_NOT_WARN((unsigned INT16)fun); 
          new_frame->expendible = new_frame->locals = save_sp; 
          new_frame->args = args; 
          new_frame->save_sp = save_sp; 
 
#ifdef PIKE_DEBUG 
          if (Pike_in_gc > GC_PASS_PREPARE && Pike_in_gc < GC_PASS_FREE) 
            Pike_fatal("Pike code called within gc.\n"); 
#endif 
 
          Pike_fp = new_frame; 
          debug_malloc_touch(Pike_fp); 
#ifdef PROFILING 
          function->num_calls++; 
          function->recur_depth++; 
#endif 
#ifdef PIKE_USE_MACHINE_CODE 
          call_check_threads_etc(); 
#endif 
 
          if( !constant ) 
          { 
            if (PIKE_FN_START_ENABLED()) 
            { 
              /* DTrace enter probe 
                 arg0: function name 
                 arg1: object 
              */ 
              dynamic_buffer save_buf; 
              dynbuf_string obj_name; 
              struct svalue obj_sval; 
              SET_SVAL(obj_sval, T_OBJECT, 0, object, o); 
              init_buf(&save_buf); 
              safe_describe_svalue(&obj_sval, 0, NULL); 
              obj_name = complex_free_buf(&save_buf); 
              PIKE_FN_START(function->name->size_shift == 0 ? 
                            function->name->str : "[widestring fn name]", 
                            obj_name.str); 
            } 
            if(UNLIKELY(Pike_interpreter.trace_level)) 
            { 
              dynamic_buffer save_buf; 
              char buf[50]; 
 
              init_buf(&save_buf); 
              sprintf(buf, "%lx->", DO_NOT_WARN((long) PTR_TO_INT (o))); 
              my_strcat(buf); 
              if (function->name->size_shift) 
                my_strcat ("[widestring function name]"); 
              else 
                my_strcat(function->name->str); 
              do_trace_call(args, &save_buf); 
            } 
            if( type == IDENTIFIER_C_FUNCTION ) 
            { 
              new_frame->num_args = args; 
              new_frame->num_locals = args; 
              new_frame->current_storage = o->storage+context->storage_offset; 
              new_frame->pc = 0; 
              (*function->func.c_fun)(args); 
 
              /* .. and below follows what is basically a copy of the 
               * low_return function... 
               */ 
              if(save_sp+1 > Pike_sp) 
              { 
                push_int(0); 
              } else if(save_sp+1 < Pike_sp) { 
                stack_pop_n_elems_keep_top( Pike_sp-save_sp-1 ); 
              } 
              if(UNLIKELY(Pike_interpreter.trace_level>1)) 
                do_trace_func_return (1, o, fun); 
              goto pop; 
            } 
            new_frame->save_mark_sp=new_frame->mark_sp_base=Pike_mark_sp; 
            new_frame->pc = new_frame->context->prog->program + function->func.offset 
#ifdef ENTRY_PROLOGUE_SIZE 
              + ENTRY_PROLOGUE_SIZE 
#endif /* ENTRY_PROLOGUE_SIZE */ 
              ; 
            return new_frame->pc; 
          } 
          else 
          { 
            struct object *tmp; 
            new_frame->pc = 0; 
            new_frame->num_args = 0; 
            tmp=parent_clone_object(constant->u.program, 
                                    o, 
                                    fun, 
                                    args); 
            push_object(tmp); 
          pop: 
            POP_PIKE_FRAME(); 
            return 0; 
          } 
      } 
    } 
  } 
  return low_mega_apply( APPLY_LOW, args, o, (void*)fun ); 
} 
 
/* Apply a function. 
 * 
 * Application types: 
 * 
 *   APPLY_STACK:         Apply Pike_sp[-args] with args-1 arguments. 
 * 
 *   APPLY_SVALUE:        Apply the svalue at arg1, and adjust the stack 
 *                        to leave a return value. 
 * 
 *   APPLY_SVALUE_STRICT: Apply the svalue at arg1, and don't adjust the 
 *                        stack for functions that return void. 
 * 
 *   APPLY_LOW:           Apply function #arg2 in object arg1. 
 * 
 * Return values: 
 * 
 *   Returns zero if the function was invalid or has been executed. 
 * 
 *   Returns one if a frame has been set up to start the function 
 *   with eval_instruction(Pike_fp->pc - ENTRY_PROLOGUE_SIZE). After 
 *   eval_instruction() is done the frame needs to be removed by a call 
 *   to low_return() or low_return_pop(). 
 */ 
void* low_mega_apply(enum apply_type type, INT32 args, void *arg1, void *arg2) 
{ 
  struct object *o = NULL; 
  struct pike_frame *scope=0; 
  ptrdiff_t fun=0; 
  struct svalue *save_sp=Pike_sp-args; 
 
#if defined(PIKE_DEBUG) && defined(_REENTRANT) 
  if(d_flag) 
    { 
      THREAD_T self = th_self(); 
 
      CHECK_INTERPRETER_LOCK(); 
 
      if (Pike_interpreter.thread_state) { 
        if (!th_equal(Pike_interpreter.thread_state->id, self)) 
          Pike_fatal("Current thread is wrong.\n"); 
 
        DEBUG_CHECK_THREAD(); 
      } 
    } 
#endif 
 
  switch(type) 
  { 
  case APPLY_STACK: 
    if(!args) 
      PIKE_ERROR("`()", "Too few arguments (apply stack).\n", Pike_sp, 0); 
    args--; 
    arg1=(void *)(Pike_sp-args-1); 
 
  case APPLY_SVALUE: 
  case APPLY_SVALUE_STRICT: 
  apply_svalue: 
  { 
    struct svalue *s=(struct svalue *)arg1; 
    switch(TYPEOF(*s)) 
    { 
    case T_INT: 
      if (!s->u.integer) { 
        PIKE_ERROR("0", "Attempt to call the NULL-value\n", Pike_sp, args); 
      } else { 
        Pike_error("Attempt to call the value %"PRINTPIKEINT"d\n",  
                   s->u.integer); 
      } 
 
    case T_STRING: 
      if (s->u.string->len > 20) { 
        Pike_error("Attempt to call the string \"%20S\"...\n", s->u.string); 
      } else { 
        Pike_error("Attempt to call the string \"%S\"\n", s->u.string); 
      } 
    case T_MAPPING: 
      Pike_error("Attempt to call a mapping\n"); 
    default: 
      Pike_error("Call to non-function value type:%s.\n", 
                 get_name_of_type(TYPEOF(*s))); 
 
    case T_FUNCTION: 
      if(SUBTYPEOF(*s) == FUNCTION_BUILTIN) 
      { 
#ifdef PIKE_DEBUG 
      struct svalue *expected_stack = Pike_sp-args; 
#endif 
      if(Pike_interpreter.trace_level>1) 
        { 
          dynamic_buffer save_buf; 
          init_buf(&save_buf); 
          if (s->u.efun->name->size_shift) 
            my_strcat ("[widestring function name]"); 
          else 
            my_strcat (s->u.efun->name->str); 
          do_trace_call(args, &save_buf); 
        } 
        if (PIKE_FN_START_ENABLED()) { 
          /* DTrace enter probe 
             arg0: function name 
             arg1: object 
           */ 
          PIKE_FN_START(s->u.efun->name->size_shift == 0 ? 
                        s->u.efun->name->str : "[widestring fn name]", 
                        ""); 
        } 
        FAST_CHECK_THREADS_ON_CALL(); 
        (*(s->u.efun->function))(args); 
        if (PIKE_FN_DONE_ENABLED()) { 
          /* DTrace leave probe 
             arg0: function name 
          */ 
          PIKE_FN_DONE(s->u.efun->name->size_shift == 0 ? 
                       s->u.efun->name->str : "[widestring fn name]"); 
        } 
 
#ifdef PIKE_DEBUG 
      s->u.efun->runs++; 
        if(Pike_sp != expected_stack + !s->u.efun->may_return_void) 
        { 
          if(Pike_sp < expected_stack) 
            Pike_fatal("Function popped too many arguments: %S\n", 
                       s->u.efun->name); 
          if(Pike_sp>expected_stack+1) 
            Pike_fatal("Function left droppings on stack: %S\n", 
                       s->u.efun->name); 
          if(Pike_sp == expected_stack && !s->u.efun->may_return_void) 
            Pike_fatal("Non-void function returned without return value on stack: %S %d\n", 
                       s->u.efun->name, s->u.efun->may_return_void); 
          if(Pike_sp==expected_stack+1 && s->u.efun->may_return_void) 
            Pike_fatal("Void function returned with a value on the stack: %S %d\n", 
                       s->u.efun->name, s->u.efun->may_return_void); 
        } 
#endif 
 
        break; 
      }else{ 
        type=APPLY_SVALUE; 
        o=s->u.object; 
        fun = SUBTYPEOF(*s); 
        if(o->prog == pike_trampoline_program && 
           fun == QUICK_FIND_LFUN(pike_trampoline_program, LFUN_CALL)) 
        { 
          fun=((struct pike_trampoline *)(o->storage))->func; 
          scope=((struct pike_trampoline *)(o->storage))->frame; 
          o=scope->current_object; 
        } 
        goto apply_low; 
      } 
      break; 
 
    case T_ARRAY: 
      if(Pike_interpreter.trace_level) 
      { 
        dynamic_buffer save_buf; 
        init_buf(&save_buf); 
        safe_describe_svalue(s,0,0); 
        do_trace_call(args, &save_buf); 
      } 
      if (PIKE_FN_START_ENABLED()) { 
        /* DTrace enter probe 
           arg0: function name 
           arg1: object 
        */ 
        PIKE_FN_START("[array]", ""); 
      } 
      apply_array(s->u.array, args, (type == APPLY_STACK)); 
      break; 
 
    case PIKE_T_TYPE: 
      if (args != 1) { 
        /* FIXME: Casts to object ought to propagate to apply program below. */ 
        SIMPLE_WRONG_NUM_ARGS_ERROR("cast", 1); 
      } 
      o_cast(s->u.type, compile_type_to_runtime_type(s->u.type)); 
      break; 
 
    case T_PROGRAM: 
      if(Pike_interpreter.trace_level) 
      { 
        dynamic_buffer save_buf; 
        init_buf(&save_buf); 
        safe_describe_svalue(s,0,0); 
        do_trace_call(args, &save_buf); 
      } 
      if (PIKE_FN_START_ENABLED()) { 
        /* DTrace enter probe 
           arg0: function name 
           arg1: object 
        */ 
        dynamic_buffer save_buf; 
        dynbuf_string prog_name; 
        init_buf(&save_buf); 
        safe_describe_svalue(s,0,0); 
        prog_name = complex_free_buf(&save_buf); 
        PIKE_FN_START("[program]", prog_name.str); 
      } 
      push_object(clone_object(s->u.program,args)); 
      break; 
 
    case T_OBJECT: 
      /* FIXME: Object subtypes! */ 
      o=s->u.object; 
      if(o->prog == pike_trampoline_program) 
      { 
        fun=((struct pike_trampoline *)(o->storage))->func; 
        scope=((struct pike_trampoline *)(o->storage))->frame; 
        o=scope->current_object; 
        goto apply_low; 
      } 
      fun=LFUN_CALL; 
      type=APPLY_SVALUE; 
      goto call_lfun; 
    } 
    break; 
  } 
 
  call_lfun: { 
    int lfun; 
#ifdef PIKE_DEBUG 
    if(fun < 0 || fun >= NUM_LFUNS) 
      Pike_fatal("Apply lfun on illegal value!\n"); 
#endif 
    if(!o->prog) 
      PIKE_ERROR("destructed object", "Apply on destructed object.\n", Pike_sp, args); 
    lfun = FIND_LFUN(o->prog, fun); 
    if (lfun < 0) 
      Pike_error ("Cannot call undefined lfun %s.\n", lfun_names[fun]); 
    fun = lfun; 
    goto apply_low; 
  } 
 
  case APPLY_LOW: 
    o = (struct object *)arg1; 
    fun = PTR_TO_INT(arg2); 
    if(o->prog == pike_trampoline_program && 
       fun == QUICK_FIND_LFUN(pike_trampoline_program, LFUN_CALL)) 
    { 
      fun=((struct pike_trampoline *)(o->storage))->func; 
      scope=((struct pike_trampoline *)(o->storage))->frame; 
      o=scope->current_object; 
    } 
 
  apply_low: 
#include "apply_low.h" 
    break; 
  } 
 
  if(save_sp+1 > Pike_sp) 
  { 
    if(type != APPLY_SVALUE_STRICT) { 
      push_int(0); 
      if(Pike_interpreter.trace_level>1) 
        do_trace_func_return (1, o, fun); 
    } 
    else 
      if(Pike_interpreter.trace_level>1) 
        do_trace_func_return (0, o, fun); 
  }else{ 
    if(save_sp+1 < Pike_sp) 
    { 
      assign_svalue(save_sp,Pike_sp-1); 
      pop_n_elems(Pike_sp-save_sp-1); 
      low_destruct_objects_to_destruct(); /* consider using a flag for immediate destruct instead... */ 
    } 
    if(Pike_interpreter.trace_level>1) 
      do_trace_func_return (1, o, fun); 
  } 
 
  if (PIKE_FN_DONE_ENABLED()) { 
    /* DTrace leave probe 
       arg0: function name 
    */ 
    char *fn = "(unknown)"; 
    if (o && o->prog) { 
      struct identifier *id = ID_FROM_INT(o->prog, fun); 
      fn = id->name->size_shift == 0 ? id->name->str : "[widestring fn name]"; 
    } 
    PIKE_FN_DONE(fn); 
  } 
 
  return 0; 
} 
 
 
 
#define basic_low_return(save_sp)                     \ 
  DO_IF_DEBUG(                                          \ 
    if(Pike_mark_sp < Pike_fp->save_mark_sp)            \ 
      Pike_fatal("Popped below save_mark_sp!\n");       \ 
    if(Pike_sp<Pike_interpreter.evaluator_stack)        \ 
      Pike_fatal("Stack error (also simple).\n");       \ 
    )                                                   \ 
                                                        \ 
    Pike_mark_sp=Pike_fp->save_mark_sp;                 \ 
                                                        \ 
  POP_PIKE_FRAME() 
 
 
void low_return(void) 
{ 
  struct svalue *save_sp = Pike_fp->save_sp+1; 
  struct object *o = Pike_fp->current_object; 
  int fun = Pike_fp->fun; 
 
  if (PIKE_FN_DONE_ENABLED()) { 
    /* DTrace leave probe 
       arg0: function name 
    */ 
    char *fn = "(unknown)"; 
    if (o && o->prog) { 
      struct identifier *id = ID_FROM_INT(o->prog, fun); 
      fn = id->name->size_shift == 0 ? id->name->str : "[widestring fn name]"; 
    } 
    PIKE_FN_DONE(fn); 
  } 
 
#if defined (PIKE_USE_MACHINE_CODE) && defined (OPCODE_RETURN_JUMPADDR) 
  /* If the function that returns is the only ref to the current 
   * object and its program then the program would be freed in 
   * destruct_objects_to_destruct below. However, we're still 
   * executing in an opcode in its code so we need prog->program to 
   * stick around for a little while more to handle the returned 
   * address. We therefore add a ref to the current object so that 
   * it'll live through this function. */ 
  add_ref (o); 
#endif 
 
  basic_low_return (save_sp); 
 
  stack_pop_n_elems_keep_top (Pike_sp - save_sp); 
  { 
      /* consider using a flag for immediate destruct instead... */ 
      extern struct object *objects_to_destruct; 
      if( objects_to_destruct ) 
          destruct_objects_to_destruct(); 
  } 
 
#ifdef PIKE_DEBUG 
  if(save_sp > Pike_sp) 
      Pike_fatal("Pike function did not leave an return value\n"); 
#endif 
 
  if(UNLIKELY(Pike_interpreter.trace_level>1)) 
    do_trace_func_return (1, o, fun); 
 
#if defined (PIKE_USE_MACHINE_CODE) && defined (OPCODE_RETURN_JUMPADDR) 
  free_object (o); 
#endif 
} 
 
void low_return_pop(void) 
{ 
  struct svalue *save_sp = Pike_fp->save_sp; 
#if defined (PIKE_USE_MACHINE_CODE) && defined (OPCODE_RETURN_JUMPADDR) 
  /* See note above. */ 
  struct object *o = Pike_fp->current_object; 
  add_ref (o); 
#endif 
 
  if (PIKE_FN_DONE_ENABLED()) { 
    /* DTrace leave probe 
       arg0: function name 
    */ 
    char *fn = "(unknown)"; 
    struct object *o = Pike_fp->current_object; 
    int fun = Pike_fp->fun; 
    if (o && o->prog) { 
      struct identifier *id = ID_FROM_INT(o->prog, fun); 
      fn = id->name->size_shift == 0 ? id->name->str : "[widestring fn name]"; 
    } 
    PIKE_FN_DONE(fn); 
  } 
 
  basic_low_return (save_sp); 
 
  pop_n_elems(Pike_sp-save_sp); 
  /* consider using a flag for immediate destruct instead... */ 
  destruct_objects_to_destruct(); 
 
#if defined (PIKE_USE_MACHINE_CODE) && defined (OPCODE_RETURN_JUMPADDR) 
  free_object (o); 
#endif 
} 
 
 
void unlink_previous_frame(void) 
{ 
  struct pike_frame *current, *prev; 
 
  current=Pike_interpreter.frame_pointer; 
  prev=current->next; 
#ifdef PIKE_DEBUG 
  { 
    JMP_BUF *rec; 
 
    /* Check if any recoveries belong to the frame we're 
     * about to unlink. 
     */ 
    if((rec=Pike_interpreter.recoveries)) 
    { 
      while(rec->frame_pointer == current) rec=rec->previous; 
      /* FIXME: Wouldn't a simple return be ok? */ 
      if(rec->frame_pointer == current->next) 
        Pike_fatal("You can't touch this!\n"); 
    } 
  } 
#endif 
  /* Save various fields from the previous frame. 
   */ 
  current->save_sp=prev->save_sp; 
  current->save_mark_sp=prev->save_mark_sp; 
  current->flags = prev->flags; 
 
  /* Unlink the top frame temporarily. */ 
  Pike_interpreter.frame_pointer=prev; 
 
#ifdef PROFILING 
  { 
    /* We must update the profiling info of the previous frame 
     * to account for that the current frame has gone away. 
     */ 
    cpu_time_t total_time = 
      get_cpu_time() - (Pike_interpreter.unlocked_time + current->start_time); 
    cpu_time_t child_time = 
      Pike_interpreter.accounted_time - current->children_base; 
    struct identifier *function = 
      current->context->prog->identifiers + current->ident; 
    if (!function->recur_depth) 
      function->total_time += total_time; 
    total_time -= child_time; 
    function->self_time += total_time; 
    Pike_interpreter.accounted_time += total_time; 
#ifdef PROFILING_DEBUG 
    fprintf(stderr, "%p: Unlinking previous frame.\n" 
            "Previous: %" PRINT_CPU_TIME " %" PRINT_CPU_TIME "\n" 
            "Current:  %" PRINT_CPU_TIME " %" PRINT_CPU_TIME "\n", 
            Pike_interpreter.thread_state, 
            prev->start_time, prev->children_base, 
            current->start_time, current->children_base); 
#endif /* PROFILING_DEBUG */ 
  } 
#endif /* PROFILING */ 
 
  /* Unlink the frame. */ 
  POP_PIKE_FRAME(); 
 
  /* Hook our frame again. */ 
  current->next=Pike_interpreter.frame_pointer; 
  Pike_interpreter.frame_pointer=current; 
 
#ifdef PROFILING 
  current->children_base = Pike_interpreter.accounted_time; 
  current->start_time = get_cpu_time() - Pike_interpreter.unlocked_time; 
#endif /* PROFILING */ 
} 
 
static void restore_catching_eval_jmpbuf (LOW_JMP_BUF *p) 
{ 
  Pike_interpreter.catching_eval_jmpbuf = p; 
} 
 
PMOD_EXPORT void mega_apply(enum apply_type type, INT32 args, void *arg1, void *arg2) 
{ 
  /* Save and clear Pike_interpreter.catching_eval_jmpbuf so that the 
   * following eval_instruction will install a LOW_JMP_BUF of its 
   * own to handle catches. */ 
  LOW_JMP_BUF *saved_jmpbuf = Pike_interpreter.catching_eval_jmpbuf; 
  ONERROR uwp; 
  Pike_interpreter.catching_eval_jmpbuf = NULL; 
  SET_ONERROR (uwp, restore_catching_eval_jmpbuf, saved_jmpbuf); 
 
  /* The C stack margin is normally 8 kb, but if we get here during a 
   * lowered margin then don't fail just because of that, unless it's 
   * practically zero. */ 
  check_c_stack(Pike_interpreter.c_stack_margin ? 
                Pike_interpreter.c_stack_margin : 100); 
  if( low_mega_apply(type, args, arg1, arg2) ) 
  { 
    eval_instruction(Pike_fp->pc 
#ifdef ENTRY_PROLOGUE_SIZE 
                   - ENTRY_PROLOGUE_SIZE 
#endif /* ENTRY_PROLOGUE_SIZE */ 
                   ); 
    low_return(); 
  } 
  CALL_AND_UNSET_ONERROR(uwp); 
} 
 
PMOD_EXPORT void mega_apply_low(INT32 args, void *arg1, ptrdiff_t arg2) 
{ 
  /* Save and clear Pike_interpreter.catching_eval_jmpbuf so that the 
   * following eval_instruction will install a LOW_JMP_BUF of its 
   * own to handle catches. */ 
  LOW_JMP_BUF *saved_jmpbuf = Pike_interpreter.catching_eval_jmpbuf; 
  ONERROR uwp; 
  Pike_interpreter.catching_eval_jmpbuf = NULL; 
  SET_ONERROR (uwp, restore_catching_eval_jmpbuf, saved_jmpbuf); 
 
  /* The C stack margin is normally 8 kb, but if we get here during a 
   * lowered margin then don't fail just because of that, unless it's 
   * practically zero. */ 
  check_c_stack(Pike_interpreter.c_stack_margin ? 
                Pike_interpreter.c_stack_margin : 100); 
  if( lower_mega_apply( args, arg1, arg2 ) ) 
  { 
    eval_instruction(Pike_fp->pc 
#ifdef ENTRY_PROLOGUE_SIZE 
                   - ENTRY_PROLOGUE_SIZE 
#endif /* ENTRY_PROLOGUE_SIZE */ 
                   ); 
    low_return(); 
  } 
  CALL_AND_UNSET_ONERROR(uwp); 
} 
 
/* Put catch outside of eval_instruction, so the setjmp won't affect 
 * the optimization of eval_instruction. 
 */ 
static int catching_eval_instruction (PIKE_OPCODE_T *pc) 
{ 
  LOW_JMP_BUF jmpbuf; 
#ifdef PIKE_DEBUG 
  if (Pike_interpreter.catching_eval_jmpbuf) 
    Pike_fatal ("catching_eval_jmpbuf already active.\n"); 
#endif 
  Pike_interpreter.catching_eval_jmpbuf = &jmpbuf; 
  if (LOW_SETJMP (jmpbuf)) 
  { 
    Pike_interpreter.catching_eval_jmpbuf = NULL; 
#ifdef PIKE_DEBUG 
    pike_trace(3, "-    catching_eval_instruction(%p) caught error ==> -3\n", 
               pc); 
#endif 
    return -3; 
  }else{ 
    int x; 
    check_c_stack(8192); 
    x = eval_instruction(pc); 
    Pike_interpreter.catching_eval_jmpbuf = NULL; 
#ifdef PIKE_DEBUG 
    pike_trace(3, "-    catching_eval_instruction(%p) ==> %d\n", pc, x); 
#endif 
    return x; 
  } 
} 
 
/*! @decl mixed `()(function fun, mixed ... args) 
 *! @decl mixed call_function(function fun, mixed ... args) 
 *! 
 *! Call a function. 
 *! 
 *! Calls the function @[fun] with the arguments specified by @[args]. 
 *! 
 *! @seealso 
 *!   @[lfun::`()()] 
 */ 
PMOD_EXPORT void f_call_function(INT32 args) 
{ 
  mega_apply(APPLY_STACK,args,0,0); 
} 
 
/*! @class MasterObject 
 */ 
 
/*! @decl void handle_error(mixed exception) 
 *! 
 *!   Called by the Pike runtime if an exception isn't caught. 
 *! 
 *! @param exception 
 *!   Value that was @[throw()]'n. 
 *! 
 *! @seealso 
 *!   @[describe_backtrace()] 
 */ 
 
/*! @endclass 
 */ 
 
PMOD_EXPORT void call_handle_error(void) 
{ 
  dmalloc_touch_svalue(&throw_value); 
 
  if (Pike_interpreter.svalue_stack_margin > LOW_SVALUE_STACK_MARGIN) { 
    int old_t_flag = Pike_interpreter.trace_level; 
    Pike_interpreter.trace_level = 0; 
    Pike_interpreter.svalue_stack_margin = LOW_SVALUE_STACK_MARGIN; 
    Pike_interpreter.c_stack_margin = LOW_C_STACK_MARGIN; 
    move_svalue (Pike_sp++, &throw_value); 
    mark_free_svalue (&throw_value); 
 
    if (get_master()) {             /* May return NULL at odd times. */ 
      ONERROR tmp; 
      SET_ONERROR(tmp,exit_on_error,"Error in handle_error in master object!"); 
      APPLY_MASTER("handle_error", 1); 
      UNSET_ONERROR(tmp); 
    } 
    else { 
      dynamic_buffer save_buf; 
      char *s; 
      fprintf (stderr, "There's no master to handle the error. Dumping it raw:\n"); 
      init_buf(&save_buf); 
      safe_describe_svalue (Pike_sp - 1, 0, 0); 
      s=simple_free_buf(&save_buf); 
      fprintf(stderr,"%s\n",s); 
      free(s); 
      if (TYPEOF(Pike_sp[-1]) == PIKE_T_OBJECT && Pike_sp[-1].u.object->prog) { 
        int fun = find_identifier("backtrace", Pike_sp[-1].u.object->prog); 
        if (fun != -1) { 
          fprintf(stderr, "Attempting to extract the backtrace.\n"); 
          safe_apply_low2(Pike_sp[-1].u.object, fun, 0, 0); 
          init_buf(&save_buf); 
          safe_describe_svalue(Pike_sp - 1, 0, 0); 
          pop_stack(); 
          s=simple_free_buf(&save_buf); 
          fprintf(stderr,"%s\n",s); 
          free(s); 
        } 
      } 
    } 
 
    pop_stack(); 
    Pike_interpreter.svalue_stack_margin = SVALUE_STACK_MARGIN; 
    Pike_interpreter.c_stack_margin = C_STACK_MARGIN; 
    Pike_interpreter.trace_level = old_t_flag; 
  } 
 
  else { 
    free_svalue(&throw_value); 
    mark_free_svalue (&throw_value); 
  } 
} 
 
/* NOTE: This function may only be called from the compiler! */ 
int apply_low_safe_and_stupid(struct object *o, INT32 offset) 
{ 
  JMP_BUF tmp; 
  struct pike_frame *new_frame=alloc_pike_frame(); 
  int ret; 
  volatile int use_dummy_reference = 1; 
  struct program *prog = o->prog; 
  int p_flags = prog->flags; 
  LOW_JMP_BUF *saved_jmpbuf; 
  int fun = -1; 
 
  /* Search for a function that belongs to the current program, 
   * since this is needed for opcodes that use INHERIT_FROM_* 
   * (eg F_EXTERN) to work. 
   */ 
  for (fun = prog->num_identifier_references; fun--;) { 
    if (!prog->identifier_references[fun].inherit_offset) { 
      use_dummy_reference = 0; 
      break; 
    } 
  } 
 
  if (use_dummy_reference) { 
    /* No suitable function was found, so add one. */ 
    struct identifier dummy; 
    struct reference dummy_ref = { 
      0, 0, ID_HIDDEN, 
      PIKE_T_UNKNOWN, { 0, }, 
    }; 
    /* FIXME: Assert that o->prog == Pike_compiler->new_program */ 
    copy_shared_string(dummy.name, empty_pike_string); 
    copy_pike_type(dummy.type, function_type_string); 
    dummy.filename_strno = -1; 
    dummy.linenumber = 0; 
    dummy.run_time_type = PIKE_T_FUNCTION; 
    dummy.identifier_flags = IDENTIFIER_PIKE_FUNCTION|IDENTIFIER_HAS_BODY; 
    dummy.func.offset = offset; 
    dummy.opt_flags = 0; 
    dummy_ref.identifier_offset = prog->num_identifiers; 
    add_to_identifiers(dummy); 
    fun = prog->num_identifier_references; 
    add_to_identifier_references(dummy_ref); 
  } 
 
  /* FIXME: Is this up-to-date with mega_apply? */ 
  new_frame->next = Pike_fp; 
  add_ref(new_frame->current_object = o); 
  add_ref(new_frame->current_program = prog); 
  new_frame->context = prog->inherits; 
  new_frame->locals = Pike_sp; 
  new_frame->expendible=new_frame->locals; 
  new_frame->args = 0; 
  new_frame->num_args=0; 
  new_frame->num_locals=0; 
  new_frame->fun = fun; 
  new_frame->pc = 0; 
  new_frame->current_storage=o->storage; 
 
#ifdef PIKE_DEBUG       
  if (Pike_fp && (new_frame->locals < Pike_fp->locals)) { 
    fatal("New locals below old locals: %p < %p\n", 
          new_frame->locals, Pike_fp->locals); 
  } 
#endif /* PIKE_DEBUG */ 
 
  Pike_fp = new_frame; 
 
  saved_jmpbuf = Pike_interpreter.catching_eval_jmpbuf; 
  Pike_interpreter.catching_eval_jmpbuf = NULL; 
 
  if(SETJMP(tmp)) 
  { 
    ret=1; 
  }else{ 
    int tmp; 
    new_frame->mark_sp_base=new_frame->save_mark_sp=Pike_mark_sp; 
    tmp=eval_instruction(prog->program + offset); 
    Pike_mark_sp=new_frame->save_mark_sp; 
     
#ifdef PIKE_DEBUG 
    if (tmp != -1) 
      Pike_fatal ("Unexpected return value from eval_instruction: %d\n", tmp); 
    if(Pike_sp<Pike_interpreter.evaluator_stack) 
      Pike_fatal("Stack error (simple).\n"); 
#endif 
    ret=0; 
  } 
  UNSETJMP(tmp); 
 
  Pike_interpreter.catching_eval_jmpbuf = saved_jmpbuf; 
 
  if (use_dummy_reference) { 
    /* Pop the dummy identifier. */ 
    free_type(function_type_string); 
    free_string(empty_pike_string); 
    prog->num_identifier_references--; 
    prog->num_identifiers--; 
  } 
 
  assert (new_frame == Pike_fp); 
  LOW_POP_PIKE_FRAME (new_frame); 
 
  return ret; 
} 
 
int safe_apply_low2(struct object *o, int fun, int args, 
                                const char *fun_name) 
{ 
  JMP_BUF recovery; 
  int ret = 0; 
 
  free_svalue(& throw_value); 
  mark_free_svalue (&throw_value); 
  if(SETJMP_SP(recovery, args)) 
  { 
    if(fun_name) call_handle_error(); 
    push_int(0); 
    ret = 0; 
  }else{ 
    if (fun >= 0) { 
      apply_low(o,fun,args); 
    } else if (fun_name) { 
      Pike_error("Cannot call unknown function \"%s\".\n", fun_name); 
    } else { 
      pop_n_elems(args); 
      push_int(0); 
    } 
    ret = 1; 
  } 
  UNSETJMP(recovery); 
  return ret; 
} 
 
PMOD_EXPORT int safe_apply_low(struct object *o, int fun, int args) 
{ 
  return safe_apply_low2(o, fun, args, "Unknown function."); 
} 
 
PMOD_EXPORT int safe_apply(struct object *o, const char *fun, INT32 args) 
{ 
  int id; 
#ifdef PIKE_DEBUG 
  if(!o->prog) Pike_fatal("Apply safe on destructed object.\n"); 
#endif 
  id = find_identifier(fun, o->prog); 
  return safe_apply_low2(o, id, args, fun); 
} 
 
/* Returns nonzero if the function was called in some handler. */ 
int low_unsafe_apply_handler(const char *fun, 
                                         struct object *handler, 
                                         struct object *compat, 
                                         INT32 args) 
{ 
  int i; 
#if 0 
  fprintf(stderr, "low_unsafe_apply_handler(\"%s\", 0x%08p, 0x%08p, %d)\n", 
          fun, handler, compat, args); 
#endif /* 0 */ 
  if (handler && handler->prog && 
      (i = find_identifier(fun, handler->prog)) != -1) { 
    apply_low(handler, i, args); 
  } else if (compat && compat->prog && 
             (i = find_identifier(fun, compat->prog)) != -1) { 
    apply_low(compat, i, args); 
  } else { 
    struct object *master_obj = get_master(); 
    if (master_obj && (i = find_identifier(fun, master_obj->prog)) != -1) 
      apply_low(master_obj, i, args); 
    else { 
      pop_n_elems(args); 
      push_undefined(); 
      return 0; 
    } 
  } 
  return 1; 
} 
 
void low_safe_apply_handler(const char *fun, 
                                        struct object *handler, 
                                        struct object *compat, 
                                        INT32 args) 
{ 
  int i; 
#if 0 
  fprintf(stderr, "low_safe_apply_handler(\"%s\", 0x%08p, 0x%08p, %d)\n", 
          fun, handler, compat, args); 
#endif /* 0 */ 
  if (handler && handler->prog && 
      (i = find_identifier(fun, handler->prog)) != -1) { 
    safe_apply_low2(handler, i, args, fun); 
  } else if (compat && compat->prog && 
             (i = find_identifier(fun, compat->prog)) != -1) { 
    safe_apply_low2(compat, i, args, fun); 
  } else { 
    struct object *master_obj = master(); 
    if ((i = find_identifier(fun, master_obj->prog)) != -1) 
      safe_apply_low2(master_obj, i, args, fun); 
    else { 
      pop_n_elems(args); 
      push_undefined(); 
    } 
  } 
} 
 
/* NOTE: Returns 1 if result on stack, 0 otherwise. */ 
PMOD_EXPORT int safe_apply_handler(const char *fun, 
                                   struct object *handler, 
                                   struct object *compat, 
                                   INT32 args, 
                                   TYPE_FIELD rettypes) 
{ 
  JMP_BUF recovery; 
  int ret; 
 
  STACK_LEVEL_START(args); 
 
#if 0 
  fprintf(stderr, "safe_apply_handler(\"%s\", 0x%08p, 0x%08p, %d)\n", 
          fun, handler, compat, args); 
#endif /* 0 */ 
 
  free_svalue(& throw_value); 
  mark_free_svalue (&throw_value); 
 
  if (SETJMP_SP(recovery, args)) { 
    ret = 0; 
  } else { 
    if (low_unsafe_apply_handler (fun, handler, compat, args) && 
        rettypes && !((1 << TYPEOF(Pike_sp[-1])) & rettypes)) { 
      if ((rettypes & BIT_ZERO) && SAFE_IS_ZERO (Pike_sp - 1)) { 
        pop_stack(); 
        push_int(0); 
      } 
      else { 
        Pike_error("Invalid return value from %s: %O\n", 
                   fun, Pike_sp-1); 
      } 
    } 
 
    ret = 1; 
  } 
 
  UNSETJMP(recovery); 
 
  STACK_LEVEL_DONE(ret); 
 
  return ret; 
} 
 
PMOD_EXPORT void apply_lfun(struct object *o, int lfun, int args) 
{ 
  int fun; 
#ifdef PIKE_DEBUG 
  if(lfun < 0 || lfun >= NUM_LFUNS) 
    Pike_fatal("Apply lfun on illegal value!\n"); 
#endif 
  if(!o->prog) 
    PIKE_ERROR("destructed object", "Apply on destructed object.\n", 
               Pike_sp, args); 
 
  if ((fun = (int)FIND_LFUN(o->prog, lfun)) < 0) 
    Pike_error("Calling undefined lfun::%s.\n", lfun_names[lfun]); 
 
  apply_low(o, fun, args); 
} 
 
PMOD_EXPORT void apply_shared(struct object *o, 
                  struct pike_string *fun, 
                  int args) 
{ 
  int id = find_shared_string_identifier(fun, o->prog); 
  if (id >= 0) 
    apply_low(o, id, args); 
  else 
    Pike_error("Cannot call unknown function \"%S\".\n", fun); 
} 
 
PMOD_EXPORT void apply(struct object *o, const char *fun, int args) 
{ 
  int id = find_identifier(fun, o->prog); 
  if (id >= 0) 
    apply_low(o, id, args); 
  else 
    Pike_error ("Cannot call unknown function \"%s\".\n", fun); 
} 
 
 
PMOD_EXPORT void apply_svalue(struct svalue *s, INT32 args) 
{ 
  if(TYPEOF(*s) == T_INT) 
  { 
    pop_n_elems(args); 
    push_int(0); 
  }else{ 
    ptrdiff_t expected_stack=Pike_sp-args+1 - Pike_interpreter.evaluator_stack; 
 
    strict_apply_svalue(s,args); 
    if(Pike_sp > (expected_stack + Pike_interpreter.evaluator_stack)) 
    { 
      pop_n_elems(Pike_sp-(expected_stack + Pike_interpreter.evaluator_stack)); 
    } 
    else if(Pike_sp < (expected_stack + Pike_interpreter.evaluator_stack)) 
    { 
      push_int(0); 
    } 
#ifdef PIKE_DEBUG 
    if(Pike_sp < (expected_stack + Pike_interpreter.evaluator_stack)) 
      Pike_fatal("Stack underflow!\n"); 
#endif 
  } 
} 
 
PMOD_EXPORT void safe_apply_svalue(struct svalue *s, int args, int handle_errors) 
{ 
  JMP_BUF recovery; 
  free_svalue(& throw_value); 
  mark_free_svalue (&throw_value); 
  if(SETJMP_SP(recovery, args)) 
  { 
    if(handle_errors) call_handle_error(); 
    push_int(0); 
  }else{ 
    apply_svalue (s, args); 
  } 
  UNSETJMP(recovery); 
} 
 
/* Apply function @[fun] in parent @[depth] levels up with @[args] arguments. 
 */ 
PMOD_EXPORT void apply_external(int depth, int fun, INT32 args) 
{ 
  struct external_variable_context loc; 
 
  loc.o = Pike_fp->current_object; 
  loc.parent_identifier = Pike_fp->fun; 
  if (loc.o->prog) { 
    loc.inherit = INHERIT_FROM_INT(loc.o->prog, loc.parent_identifier); 
 
    find_external_context(&loc, depth); 
 
    apply_low(loc.o, fun + loc.inherit->identifier_level, args); 
  } else { 
    PIKE_ERROR("destructed object", "Apply on parent of destructed object.\n", 
               Pike_sp, args); 
  } 
} 
 
#ifdef PIKE_DEBUG 
void slow_check_stack(void) 
{ 
  struct svalue *s,**m; 
  struct pike_frame *f; 
 
  debug_check_stack(); 
 
  if(Pike_sp > &(Pike_interpreter.evaluator_stack[Pike_stack_size])) 
    Pike_fatal("Svalue stack overflow. " 
          "(%ld entries on stack, stack_size is %ld entries)\n", 
          PTRDIFF_T_TO_LONG(Pike_sp - Pike_interpreter.evaluator_stack), 
          PTRDIFF_T_TO_LONG(Pike_stack_size)); 
 
  if(Pike_mark_sp > &(Pike_interpreter.mark_stack[Pike_stack_size])) 
    Pike_fatal("Mark stack overflow.\n"); 
 
  if(Pike_mark_sp < Pike_interpreter.mark_stack) 
    Pike_fatal("Mark stack underflow.\n"); 
 
  for(s=Pike_interpreter.evaluator_stack;s<Pike_sp;s++) { 
    /* NOTE: Freed svalues are allowed on the stack. */ 
    if (TYPEOF(*s) != PIKE_T_FREE) check_svalue(s); 
  } 
 
  s=Pike_interpreter.evaluator_stack; 
  for(m=Pike_interpreter.mark_stack;m<Pike_mark_sp;m++) 
  { 
    if(*m < s) 
      Pike_fatal("Mark stack failure.\n"); 
 
    s=*m; 
  } 
 
  if(s > &(Pike_interpreter.evaluator_stack[Pike_stack_size])) 
    Pike_fatal("Mark stack exceeds svalue stack\n"); 
 
  for(f=Pike_fp;f;f=f->next) 
  { 
    if(f->locals) 
    { 
      if(f->locals < Pike_interpreter.evaluator_stack || 
        f->locals > &(Pike_interpreter.evaluator_stack[Pike_stack_size])) 
      Pike_fatal("Local variable pointer points to FinspÄng.\n"); 
 
      if(f->args < 0 || f->args > Pike_stack_size) 
        Pike_fatal("FEL FEL FEL! HELP!! (corrupted pike_frame)\n"); 
    } 
  } 
} 
 
 
static const char *safe_idname_from_int(struct program *prog, int func) 
{ 
  /* ID_FROM_INT with a thick layer of checks. */ 
  struct reference *ref; 
  struct inherit *inher; 
  struct identifier *id; 
  if (!prog) 
    return "<null program *>"; 
  if (func < 0 || func >= prog->num_identifier_references) 
    return "<offset outside prog->identifier_references>"; 
  if (!prog->identifier_references) 
    return "<null prog->identifier_references>"; 
  ref = prog->identifier_references + func; 
  if (ref->inherit_offset >= prog->num_inherits) 
    return "<offset outside prog->inherits>"; 
  if (!prog->inherits) 
    return "<null prog->inherits>"; 
  inher = prog->inherits + ref->inherit_offset; 
  prog = inher->prog; 
  if (!prog) 
    return "<null inherited prog>"; 
  if (ref->identifier_offset >= prog->num_identifiers) 
    return "<offset outside inherited prog->identifiers>"; 
  if (!prog->identifiers) 
    return "<null inherited prog->identifiers>"; 
  id = prog->identifiers + ref->identifier_offset; 
  if (!id->name) 
    return "<null identifier->name>"; 
  if (id->name->size_shift) 
    return "<wide identifier->name->str>"; 
  /* FIXME: Convert wide string identifiers to narrow strings? */ 
  return id->name->str; 
} 
 
/*: Prints the Pike backtrace for the interpreter context in the given 
 *: thread to stderr, without messing in the internals (doesn't even 
 *: use dynamic_buffer). 
 *: 
 *: This function is intended only for convenient use inside a 
 *: debugger session; it can't be used from inside the code. 
 */ 
void gdb_backtrace ( 
#ifdef PIKE_THREADS 
  THREAD_T thread_id 
#endif 
) 
{ 
  struct pike_frame *f, *of; 
 
#ifdef PIKE_THREADS 
  extern struct thread_state *gdb_thread_state_for_id(THREAD_T); 
  struct thread_state *ts = gdb_thread_state_for_id(thread_id); 
  if (!ts) { 
    fputs ("Not a Pike thread.\n", stderr); 
    return; 
  } 
  f = ts->state.frame_pointer; 
#else 
  f = Pike_fp; 
#endif 
 
  for (of = 0; f; f = (of = f)->next) 
    if (f->refs) { 
      int args, i; 
      char *file = NULL; 
      INT_TYPE line; 
 
      if (f->context) { 
        if (f->pc) 
          file = low_get_line_plain (f->pc, f->context->prog, &line, 0); 
        else 
          file = low_get_program_line_plain (f->context->prog, &line, 0); 
      } 
      if (file) 
        fprintf (stderr, "%s:%ld: ", file, (long)line); 
      else 
        fputs ("unknown program: ", stderr); 
 
      if (f->current_program) { 
        /* FIXME: Wide string identifiers. */ 
        fputs (safe_idname_from_int(f->current_program, f->fun), stderr); 
        fputc ('(', stderr); 
      } 
      else 
        fputs ("unknown function(", stderr); 
 
      if(!f->locals) 
      { 
        args=0; 
      }else{ 
        args=f->num_args; 
        args = DO_NOT_WARN((INT32) MINIMUM(f->num_args, Pike_sp - f->locals)); 
        if(of) 
          args = DO_NOT_WARN((INT32)MINIMUM(f->num_args,of->locals - f->locals)); 
        args=MAXIMUM(args,0); 
      } 
 
      for (i = 0; i < args; i++) { 
        struct svalue *arg = f->locals + i; 
 
        switch (TYPEOF(*arg)) { 
          case T_INT: 
            fprintf (stderr, "%ld", (long) arg->u.integer); 
            break; 
 
          case T_TYPE: 
            /* FIXME: */ 
            fputs("type-value", stderr); 
            break; 
 
          case T_STRING: { 
            int i,j=0; 
            fputc ('"', stderr); 
            for(i=0; i < arg->u.string->len && i < 100; i++) 
            { 
              switch(j=index_shared_string(arg->u.string,i)) 
              { 
                case '\n': 
                  fputc ('\\', stderr); 
                  fputc ('n', stderr); 
                  break; 
 
                case '\t': 
                  fputc ('\\', stderr); 
                  fputc ('t', stderr); 
                  break; 
 
                case '\b': 
                  fputc ('\\', stderr); 
                  fputc ('b', stderr); 
                  break; 
 
                case '\r': 
                  fputc ('\\', stderr); 
                  fputc ('r', stderr); 
                  break; 
 
 
                case '"': 
                case '\\': 
                  fputc ('\\', stderr); 
                  fputc (j, stderr); 
                  break; 
 
                default: 
                  if(j>=0 && j<256 && isprint(j)) 
                  { 
                    fputc (j, stderr); 
                    break; 
                  } 
 
                  fputc ('\\', stderr); 
                  fprintf (stderr, "%o", j); 
 
                  switch(index_shared_string(arg->u.string,i+1)) 
                  { 
                    case '0': case '1': case '2': case '3': 
                    case '4': case '5': case '6': case '7': 
                    case '8': case '9': 
                      fputc ('"', stderr); 
                      fputc ('"', stderr); 
                  } 
                  break; 
              }  
            } 
            fputc ('"', stderr); 
            if (i < arg->u.string->len) 
              fprintf (stderr, "+[%ld]", (long) (arg->u.string->len - i)); 
            break; 
          } 
 
          case T_FUNCTION: 
            /* FIXME: Wide string identifiers. */ 
            if(SUBTYPEOF(*arg) == FUNCTION_BUILTIN) 
              fputs (arg->u.efun->name->str, stderr); 
            else if(arg->u.object->prog) 
              fputs (safe_idname_from_int(arg->u.object->prog, 
                                          SUBTYPEOF(*arg)), stderr); 
            else 
              fputc ('0', stderr); 
            break; 
 
          case T_OBJECT: { 
            struct program *p = arg->u.object->prog; 
            if (p && p->num_linenumbers) { 
              file = low_get_program_line_plain (p, &line, 0); 
              fprintf (stderr, "object(%s:%ld)", file, (long)line); 
            } 
            else 
              fputs ("object", stderr); 
            break; 
          } 
 
          case T_PROGRAM: { 
            struct program *p = arg->u.program; 
            if (p->num_linenumbers) { 
              file = low_get_program_line_plain (p, &line, 0); 
              fprintf (stderr, "program(%s:%ld)", file, (long)line); 
            } 
            else 
              fputs ("program", stderr); 
            break; 
          } 
 
          case T_FLOAT: 
            fprintf (stderr, "%f",(double) arg->u.float_number); 
            break; 
 
          case T_ARRAY: 
            fprintf (stderr, "array[%ld]", (long) arg->u.array->size); 
            break; 
 
          case T_MULTISET: 
            fprintf (stderr, "multiset[%ld]", (long) multiset_sizeof (arg->u.multiset)); 
            break; 
 
          case T_MAPPING: 
            fprintf (stderr, "mapping[%ld]", (long) m_sizeof (arg->u.mapping)); 
            break; 
 
          default: 
            fprintf (stderr, "<Unknown %d>", TYPEOF(*arg)); 
        } 
 
        if (i < args - 1) fputs (", ", stderr); 
      } 
      fputs (")\n", stderr); 
    } 
    else 
      fputs ("frame with no references\n", stderr); 
} 
 
/*: Prints the Pike backtraces for the interpreter contexts in all 
 *: Pike threads to stderr, using @[gdb_backtrace]. 
 *: 
 *: This function is intended only for convenient use inside a 
 *: debugger session; it can't be used from inside the program. 
 */ 
void gdb_backtraces() 
{ 
#ifdef PIKE_THREADS 
  extern INT32 gdb_next_thread_state(INT32, struct thread_state **); 
  INT32 i = 0; 
  struct thread_state *ts = 0; 
  while ((i = gdb_next_thread_state (i, &ts)), ts) { 
    fprintf (stderr, "\nTHREAD_ID %p (swapped %s):\n", 
             (void *)(ptrdiff_t)ts->id, ts->swapped ? "out" : "in"); 
    gdb_backtrace (ts->id); 
  } 
#else 
  gdb_backtrace(); 
#endif 
} 
#endif 
 
PMOD_EXPORT void custom_check_stack(ptrdiff_t amount, const char *fmt, ...) 
{ 
  if (low_stack_check(amount)) { 
    va_list args; 
    va_start(args, fmt); 
    va_error(fmt, args); 
  } 
} 
 
PMOD_EXPORT void low_cleanup_interpret(struct Pike_interpreter_struct *interpreter) 
{ 
#ifdef USE_MMAP_FOR_STACK 
  if(!interpreter->evaluator_stack_malloced) 
  { 
    munmap((char *)interpreter->evaluator_stack, 
           Pike_stack_size*sizeof(struct svalue)); 
    interpreter->evaluator_stack = 0; 
  } 
  if(!interpreter->mark_stack_malloced) 
  { 
    munmap((char *)interpreter->mark_stack, 
           Pike_stack_size*sizeof(struct svalue *)); 
    interpreter->mark_stack = 0; 
  } 
#endif 
 
  if(interpreter->evaluator_stack) 
    free((char *)interpreter->evaluator_stack); 
  if(interpreter->mark_stack) 
    free((char *)interpreter->mark_stack); 
 
  interpreter->mark_stack = 0; 
  interpreter->evaluator_stack = 0; 
  interpreter->mark_stack_malloced = 0; 
  interpreter->evaluator_stack_malloced = 0; 
 
  interpreter->stack_pointer = 0; 
  interpreter->mark_stack_pointer = 0; 
  interpreter->frame_pointer = 0; 
} 
 
PMOD_EXPORT void cleanup_interpret(void) 
{ 
  while(Pike_fp) 
    POP_PIKE_FRAME(); 
 
  reset_evaluator(); 
 
  low_cleanup_interpret(&Pike_interpreter); 
} 
 
void really_clean_up_interpret(void) 
{ 
#ifdef DO_PIKE_CLEANUP 
#if 0 
  struct pike_frame_block *p; 
  int e; 
  for(p=pike_frame_blocks;p;p=p->next) 
    for(e=0;e<128;e++) 
      debug_malloc_dump_references( p->x + e); 
#endif 
  free_callback_list (&evaluator_callbacks); 
  free_all_pike_frame_blocks(); 
  free_all_catch_context_blocks(); 
#endif 
}