-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1195.bug
executable file
·1431 lines (1431 loc) · 48.7 KB
/
1195.bug
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
diff -r 1194/src/config/CVS/Tag 1195/src/config/CVS/Tag
1c1
< D2006.09.18.05.09.59
---
> D2006.09.18.18.04.29
diff -r 1194/src/CVS/Entries 1195/src/CVS/Entries
38a39
> /jsarray.c/3.96/Mon Nov 17 05:02:47 2014//D2006.09.18.18.04.29
56a58,59
> /jsemit.c/3.213/Mon Nov 17 05:02:47 2014//D2006.09.18.18.04.29
> /jsemit.h/3.67/Mon Nov 17 05:02:47 2014//D2006.09.18.18.04.29
58a62
> /jsfun.c/3.164/Mon Nov 17 05:02:47 2014//D2006.09.18.18.04.29
63a68
> /jsinterp.c/3.291/Mon Nov 17 05:02:47 2014//D2006.09.18.18.04.29
76a82
> /jsobj.c/3.287/Result of merge//D2006.09.18.18.04.29
77a84,86
> /jsopcode.c/3.184/Mon Nov 17 05:02:47 2014//D2006.09.18.18.04.29
> /jsopcode.h/3.37/Mon Nov 17 05:02:47 2014//D2006.09.18.18.04.29
> /jsopcode.tbl/3.78/Mon Nov 17 05:02:47 2014//D2006.09.18.18.04.29
78a88,89
> /jsparse.c/3.246/Mon Nov 17 05:02:47 2014//D2006.09.18.18.04.29
> /jsparse.h/3.39/Mon Nov 17 05:02:47 2014//D2006.09.18.18.04.29
85a97
> /jsscan.c/3.113/Mon Nov 17 05:02:47 2014//D2006.09.18.18.04.29
88a101
> /jsscript.c/3.112/Mon Nov 17 05:02:47 2014//D2006.09.18.18.04.29
105,117d117
< /jsarray.c/3.95/Mon Nov 17 05:02:48 2014//D2006.09.18.05.09.59
< /jsemit.c/3.212/Mon Nov 17 05:02:48 2014//D2006.09.18.05.09.59
< /jsemit.h/3.66/Mon Nov 17 05:02:48 2014//D2006.09.18.05.09.59
< /jsfun.c/3.163/Mon Nov 17 05:02:48 2014//D2006.09.18.05.09.59
< /jsinterp.c/3.290/Mon Nov 17 05:02:48 2014//D2006.09.18.05.09.59
< /jsobj.c/3.286/Result of merge//D2006.09.18.05.09.59
< /jsopcode.c/3.183/Mon Nov 17 05:02:49 2014//D2006.09.18.05.09.59
< /jsopcode.h/3.36/Mon Nov 17 05:02:49 2014//D2006.09.18.05.09.59
< /jsopcode.tbl/3.77/Mon Nov 17 05:02:49 2014//D2006.09.18.05.09.59
< /jsparse.c/3.245/Mon Nov 17 05:02:49 2014//D2006.09.18.05.09.59
< /jsparse.h/3.38/Mon Nov 17 05:02:49 2014//D2006.09.18.05.09.59
< /jsscan.c/3.112/Mon Nov 17 05:02:49 2014//D2006.09.18.05.09.59
< /jsscript.c/3.111/Mon Nov 17 05:02:49 2014//D2006.09.18.05.09.59
diff -r 1194/src/CVS/Tag 1195/src/CVS/Tag
1c1
< D2006.09.18.05.09.59
---
> D2006.09.18.18.04.29
diff -r 1194/src/editline/CVS/Tag 1195/src/editline/CVS/Tag
1c1
< D2006.09.18.05.09.59
---
> D2006.09.18.18.04.29
diff -r 1194/src/fdlibm/CVS/Tag 1195/src/fdlibm/CVS/Tag
1c1
< D2006.09.18.05.09.59
---
> D2006.09.18.18.04.29
diff -r 1194/src/jsarray.c 1195/src/jsarray.c
1587c1587
< callable = js_ValueToCallableObject(cx, &argv[0], 0);
---
> callable = js_ValueToCallableObject(cx, &argv[0], JSV2F_SEARCH_STACK);
diff -r 1194/src/jsemit.c 1195/src/jsemit.c
1415c1415,1417
< if (label) {
---
> if (label)
> index = js_NewSrcNote2(cx, cg, noteType, (ptrdiff_t) ALE_INDEX(label));
> else if (noteType != SRC_NULL)
1417,1426c1419,1422
< if (index < 0)
< return -1;
< if (!js_SetSrcNoteOffset(cx, cg, (uintN)index, 0,
< (ptrdiff_t) ALE_INDEX(label))) {
< return -1;
< }
< } else if (noteType != SRC_NULL) {
< if (js_NewSrcNote(cx, cg, noteType) < 0)
< return -1;
< }
---
> else
> index = 0;
> if (index < 0)
> return -1;
2272,2275c2268,2271
< * uses of JSOP_GETMETHOD that implicitly qualify the method-property name with
< * a function:: prefix. All other JSOP_GETMETHOD and JSOP_SETMETHOD uses must
< * be explicit, so need a distinct source note (SRC_PCDELTA rather than PCBASE)
< * for round-tripping through the beloved decompiler.
---
> * uses of JSOP_GETMETHOD that implicitly qualify the method property's name
> * with a function:: prefix. All other JSOP_GETMETHOD and JSOP_SETMETHOD uses
> * must be explicit, so we need a distinct source note (SRC_METHODBASE rather
> * than SRC_PCBASE) for round-tripping through the beloved decompiler.
2285c2281
< ? SRC_PCDELTA
---
> ? SRC_METHODBASE
2845a2842,2843
> uintN noteCount, noteCountDelta;
>
2846a2845
> noteCount = CG_NOTE_COUNT(cg);
2850a2850,2852
> noteCountDelta = CG_NOTE_COUNT(cg) - noteCount;
> if (noteCountDelta != 0)
> caseNoteIndex += noteCountDelta;
3333c3335,3336
< if (pn2->pn_type == TOK_COMMA) {
---
> /* Nullary comma node makes a hole in the array destructurer. */
> if (pn2->pn_type == TOK_COMMA && pn2->pn_arity == PN_NULLARY) {
4209a4213
> op = JSOP_NOP;
4221,4222d4224
< op = JSOP_NOP;
< goto destructuring_for;
5286a5289,5292
> #if JS_HAS_DESTRUCTURING
> pn2->pn_type != TOK_RB &&
> pn2->pn_type != TOK_RC &&
> #endif
5314c5320
< if (!EmitDestructuringOps(cx, cg, op, pn2))
---
> if (!EmitDestructuringOps(cx, cg, JSOP_NOP, pn2))
5790d5795
< tmp = CG_OFFSET(cg);
5809a5815
> JS_ASSERT(CG_OFFSET(cg) == top);
5815,5818c5821,5830
< if (noteIndex >= 0 &&
< !js_SetSrcNoteOffset(cx, cg, (uintN)noteIndex, 0,
< CG_OFFSET(cg) - tmp)) {
< return JS_FALSE;
---
> op = pn->pn_op;
> if (op == JSOP_LEAVEBLOCKEXPR) {
> if (js_NewSrcNote2(cx, cg, SRC_PCBASE, CG_OFFSET(cg) - top) < 0)
> return JS_FALSE;
> } else {
> if (noteIndex >= 0 &&
> !js_SetSrcNoteOffset(cx, cg, (uintN)noteIndex, 0,
> CG_OFFSET(cg) - top)) {
> return JS_FALSE;
> }
5822c5834
< EMIT_UINT16_IMM_OP(pn->pn_op, count);
---
> EMIT_UINT16_IMM_OP(op, count);
6282c6294
< {"unused21", 0, 0, 0},
---
> {"extended", -1, 0, 0},
diff -r 1194/src/jsemit.h 1195/src/jsemit.h
82a83,97
> /*
> * STMT_TYPE_MAYBE_SCOPE tells whether a statement type is always, or may
> * become, a lexical scope. It therefore includes block and switch (the two
> * "maybe" scopes) and excludes with (which has dynamic scope, pending the
> * "reformed with" in ES4/JS2). It includes all try-catch-finally types.
> *
> * STMT_TYPE_LINKS_SCOPE tells whether a JSStmtInfo of the given type eagerly
> * links to other scoping statement info records. It excludes the two "maybe"
> * types, block and switch, as well as the try and both finally types, since
> * try, etc., don't need block scope unless they contain let declarations.
> *
> * We treat with as a static scope because it prevents lexical binding from
> * continuing further up the static scope chain. With the "reformed with"
> * proposal for JS2, we'll be able to model it statically, too.
> */
85a101
>
87a104
>
483a501,511
> *
> * Note on adding new source notes: every pair of bytecodes (A, B) where A and
> * B have disjoint sets of source notes that could apply to each bytecode may
> * reuse the same note type value for two notes (snA, snB) that have the same
> * arity, offsetBias, and isSpanDep initializers in js_SrcNoteSpec. This is
> * why SRC_IF and SRC_INITPROP have the same value below. For bad historical
> * reasons, some bytecodes below that could be overlayed have not been, but
> * before using SRC_EXTENDED, consider compressing the existing note types.
> *
> * Don't forget to update JSXDR_BYTECODE_VERSION in jsxdrapi.h for all such
> * incompatible source note or other bytecode changes.
498,501c526,528
< SRC_PCDELTA = 7, /* distance from comma-operator to next POP,
< or from CONDSWITCH to first CASE opcode --
< or SRC_PCBASE variant for obj.function::foo
< gets and sets */
---
> SRC_PCDELTA = 7, /* distance forward from comma-operator to
> next POP, or from CONDSWITCH to first CASE
> opcode, etc. -- always a forward delta */
507,508c534,539
< SRC_PCBASE = 12, /* distance back from annotated get- or setprop
< op to first obj.prop.subprop bytecode */
---
> SRC_PCBASE = 12, /* distance back from annotated getprop or
> setprop op to left-most obj.prop.subprop
> bytecode -- always a backward delta */
> SRC_METHODBASE = 13, /* SRC_PCBASE variant for obj.function::foo
> gets and sets; disjoint from SRC_LABEL by
> bytecode to which it applies */
518c549
< SRC_UNUSED21 = 21, /* unused */
---
> SRC_EXTENDED = 21, /* extended source note, 32-159, in next byte */
diff -r 1194/src/jsfun.c 1195/src/jsfun.c
2237,2238c2237
< JSType type;
< JSString *fallback;
---
> JSStackFrame *fp;
2243,2250c2242,2243
< /*
< * We provide the typename as the fallback to handle the case when
< * valueOf is not a function, which prevents ValueToString from being
< * called as the default case inside js_DecompileValueGenerator (and
< * so recursing back to here).
< */
< type = JS_TypeOfValue(cx, *vp);
< fallback = ATOM_TO_STRING(cx->runtime->atomState.typeAtoms[type]);
---
> for (fp = cx->fp; fp && !fp->spbase; fp = fp->down)
> continue;
2252c2245,2247
< (flags & JSV2F_SEARCH_STACK)
---
> (fp && fp->spbase <= vp && vp < fp->sp)
> ? vp - fp->sp
> : (flags & JSV2F_SEARCH_STACK)
2254,2255d2248
< : cx->fp
< ? vp - cx->fp->sp
2258c2251
< fallback);
---
> NULL);
diff -r 1194/src/jsinterp.c 1195/src/jsinterp.c
2336,2341c2336,2338
< /*
< * N.B. JSOP_SWAP doesn't swap the corresponding generating pcs
< * for the operands it swaps.
< */
< ltmp = sp[-1];
< sp[-1] = sp[-2];
---
> vp = sp - depth; /* swap generating pc's for the decompiler */
> ltmp = vp[-1];
> vp[-1] = vp[-2];
2342a2340,2342
> rtmp = sp[-1];
> sp[-1] = sp[-2];
> sp[-2] = rtmp;
2944,2945c2944,2948
< rval = sp[-1];
< PUSH_OPND(rval);
---
> vp = sp - 1; /* address top of stack */
> rval = *vp;
> vp -= depth; /* address generating pc */
> vp[1] = *vp;
> PUSH(rval);
2949,2953c2952,2959
< JS_ASSERT(sp - 1 > fp->spbase);
< lval = FETCH_OPND(-2);
< rval = FETCH_OPND(-1);
< PUSH_OPND(lval);
< PUSH_OPND(rval);
---
> JS_ASSERT(sp - 2 >= fp->spbase);
> vp = sp - 1; /* address top of stack */
> lval = vp[-1];
> rval = *vp;
> vp -= depth; /* address generating pc */
> vp[1] = vp[2] = *vp;
> PUSH(lval);
> PUSH(rval);
3292a3299
> pc2 = (jsbytecode *) sp[-2-depth];
3299a3307
> sp[-depth] = (jsval)pc2;
3303a3312
> pc2 = (jsbytecode *) sp[-2-depth];
3310a3320
> sp[-depth] = (jsval)pc2;
diff -r 1194/src/jsobj.c 1195/src/jsobj.c
3807c3807
< jsval v;
---
> jsval v, save;
3810c3810
< v = OBJECT_TO_JSVAL(obj);
---
> v = save = OBJECT_TO_JSVAL(obj);
3854c3854
< str = js_DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, v, str);
---
> str = js_DecompileValueGenerator(cx, JSDVG_SEARCH_STACK, save, str);
Only in 1194/src: .#jsobj.c.3.287
diff -r 1194/src/jsopcode.c 1195/src/jsopcode.c
445c445
< #define QUOTE_IN_XML 0x10000
---
> #define DONT_ESCAPE 0x10000
450c450
< JSBool inXML, ok;
---
> JSBool dontEscape, ok;
457c457
< inXML = (quote & QUOTE_IN_XML) != 0;
---
> dontEscape = (quote & DONT_ESCAPE) != 0;
493c493
< ok = inXML
---
> ok = dontEscape
573d572
< JSPackedBool dvgflag; /* js_DecompileValueGenerator magic flag */
574a574
> jsbytecode *dvgfence; /* js_DecompileValueGenerator fencepost */
603d602
< jp->dvgflag = JS_FALSE;
604a604
> jp->dvgfence = NULL;
647a648
> const char *bp;
655,660c656,661
< JS_ASSERT(jp->sprinter.base[offset+0] == ' ');
< JS_ASSERT(jp->sprinter.base[offset+1] == '{');
< JS_ASSERT(!jp->pretty || jp->sprinter.base[offset+2] == '\n');
<
< jp->spaceOffset = offset;
< jp->braceState = DONT_BRACE;
---
> bp = jp->sprinter.base;
> if (bp[offset+0] == ' ' && bp[offset+1] == '{') {
> JS_ASSERT(!jp->pretty || bp[offset+2] == '\n');
> jp->spaceOffset = offset;
> jp->braceState = DONT_BRACE;
> }
695,714c696,715
< JS_ASSERT(bp[offset+0] == ' ');
< JS_ASSERT(bp[offset+1] == '{');
< delta = 2;
< if (jp->pretty) {
< /* If pretty, we don't have to worry about 'else'. */
< JS_ASSERT(bp[offset+2] == '\n');
< } else if (bp[offset-1] != ')') {
< /* Must keep ' ' to avoid 'dolet' or 'elselet'. */
< ++offset;
< delta = 1;
< }
<
< from = offset + delta;
< memmove(bp + offset, bp + from, jp->sprinter.offset - from);
< jp->sprinter.offset -= delta;
< jp->spaceOffset = -1;
<
< format += 2;
< if (*format == '\0')
< return 0;
---
> if (bp[offset+0] == ' ' && bp[offset+1] == '{') {
> delta = 2;
> if (jp->pretty) {
> /* If pretty, we don't have to worry about 'else'. */
> JS_ASSERT(bp[offset+2] == '\n');
> } else if (bp[offset-1] != ')') {
> /* Must keep ' ' to avoid 'dolet' or 'elselet'. */
> ++offset;
> delta = 1;
> }
>
> from = offset + delta;
> memmove(bp + offset, bp + from, jp->sprinter.offset - from);
> jp->sprinter.offset -= delta;
> jp->spaceOffset = -1;
>
> format += 2;
> if (*format == '\0')
> return 0;
> }
769a771,823
> /*
> * Get a stacked offset from ss->sprinter.base, or if the stacked value |off|
> * is negative, lazily fetch the generating pc at |spindex = 1 + off| and try
> * to decompile the code that generated the missing value. This is used when
> * reporting errors, where the model stack will lack |pcdepth| non-negative
> * offsets (see js_DecompileValueGenerator and js_DecompileCode).
> *
> * If the stacked offset is -1, return 0 to index the NUL padding at the start
> * of ss->sprinter.base. If this happens, it means there is a decompiler bug
> * to fix, but it won't violate memory safety.
> */
> static ptrdiff_t
> GetOff(SprintStack *ss, uintN i)
> {
> ptrdiff_t off;
> JSString *str;
>
> off = ss->offsets[i];
> if (off < 0) {
> #if defined DEBUG_brendan || defined DEBUG_mrbkap || defined DEBUG_crowder
> JS_ASSERT(off < -1);
> #endif
> if (++off == 0) {
> if (!ss->sprinter.base && SprintPut(&ss->sprinter, "", 0) >= 0)
> memset(ss->sprinter.base, 0, ss->sprinter.offset);
> return 0;
> }
>
> str = js_DecompileValueGenerator(ss->sprinter.context, off,
> JSVAL_NULL, NULL);
> if (!str)
> return 0;
> off = SprintCString(&ss->sprinter, JS_GetStringBytes(str));
> if (off < 0)
> off = 0;
> ss->offsets[i] = off;
> }
> return off;
> }
>
> static const char *
> GetStr(SprintStack *ss, uintN i)
> {
> ptrdiff_t off;
>
> /*
> * Must call GetOff before using ss->sprinter.base, since it may be null
> * until bootstrapped by GetOff.
> */
> off = GetOff(ss, i);
> return OFF2STR(&ss->sprinter, off);
> }
>
802a857
> memset(OFF2STR(&ss->sprinter, ss->sprinter.offset), 0, PAREN_SLOP);
820a876
> off = GetOff(ss, top);
824,827c880,881
< ss->offsets[top] -= 2;
< ss->sprinter.offset = ss->offsets[top];
< off = Sprint(&ss->sprinter, "(%s)",
< OFF2STR(&ss->sprinter, ss->sprinter.offset + 2));
---
> ss->sprinter.offset = ss->offsets[top] = off - 2;
> off = Sprint(&ss->sprinter, "(%s)", OFF2STR(&ss->sprinter, off));
829c883
< off = ss->sprinter.offset = ss->offsets[top];
---
> ss->sprinter.offset = off;
833a888,896
> static const char *
> PopStr(SprintStack *ss, JSOp op)
> {
> ptrdiff_t off;
>
> off = PopOff(ss, op);
> return OFF2STR(&ss->sprinter, off);
> }
>
875c938
< off = isCondSwitch ? ss->offsets[ss->top-1] : PopOff(ss, JSOP_NOP);
---
> off = isCondSwitch ? GetOff(ss, ss->top-1) : PopOff(ss, JSOP_NOP);
1021a1085,1144
> const char *
> GetLocal(SprintStack *ss, jsint i)
> {
> ptrdiff_t off;
> JSContext *cx;
> JSScript *script;
> jsatomid j, n;
> JSAtom *atom;
> JSObject *obj;
> jsint depth, count;
> JSScopeProperty *sprop;
> const char *rval;
>
> #define LOCAL_ASSERT(expr) JS_BEGIN_MACRO \
> JS_ASSERT(expr); \
> if (!(expr)) return NULL; \
> JS_END_MACRO
>
> off = ss->offsets[i];
> if (off >= 0)
> return OFF2STR(&ss->sprinter, off);
>
> /*
> * We must be called from js_DecompileValueGenerator (via Decompile) when
> * dereferencing a local that's undefined or null. Search script->atomMap
> * for the block containing this local by its stack index, i.
> */
> cx = ss->sprinter.context;
> script = ss->printer->script;
> for (j = 0, n = script->atomMap.length; j < n; j++) {
> atom = script->atomMap.vector[j];
> if (ATOM_IS_OBJECT(atom)) {
> obj = ATOM_TO_OBJECT(atom);
> if (OBJ_GET_CLASS(cx, obj) == &js_BlockClass) {
> depth = OBJ_BLOCK_DEPTH(cx, obj);
> count = OBJ_BLOCK_COUNT(cx, obj);
> if ((jsuint)(i - depth) < (jsuint)count)
> break;
> }
> }
> }
>
> LOCAL_ASSERT(j < n);
> i -= depth;
> for (sprop = OBJ_SCOPE(obj)->lastProp; sprop; sprop = sprop->parent) {
> if (sprop->shortid == i)
> break;
> }
>
> LOCAL_ASSERT(sprop && JSID_IS_ATOM(sprop->id));
> atom = JSID_TO_ATOM(sprop->id);
> rval = QuoteString(&ss->sprinter, ATOM_TO_STRING(atom), 0);
> if (!rval)
> return NULL;
> RETRACT(&ss->sprinter, rval);
> return rval;
>
> #undef LOCAL_ASSERT
> }
>
1027c1150
< jsbytecode *endpc, *pc2, *done, *forelem_tail, *forelem_done;
---
> jsbytecode *startpc, *endpc, *pc2, *done, *forelem_tail, *forelem_done;
1066c1189
< #define POP_STR() OFF2STR(&ss->sprinter, PopOff(ss, op))
---
> #define POP_STR() PopStr(ss, op)
1114a1238
> startpc = pc;
1139c1263,1264
< if (jp->dvgflag && pc + oplen == endpc) {
---
> if (pc + oplen == jp->dvgfence) {
> JSStackFrame *fp;
1141a1267,1273
> /*
> * Rewrite non-get ops to their "get" format if the error is in
> * the bytecode at pc, so we don't decompile more than the error
> * expression.
> */
> for (fp = cx->fp; fp && !fp->script; fp = fp->down)
> continue;
1143c1275,1277
< if (format & (JOF_SET|JOF_DEL|JOF_INCDEC|JOF_IMPORT|JOF_FOR)) {
---
> if (((fp && pc == fp->pc) ||
> (pc == startpc && cs->nuses != 0)) &&
> format & (JOF_SET|JOF_DEL|JOF_INCDEC|JOF_IMPORT|JOF_FOR)) {
1159a1294,1297
>
> i = cs->nuses - js_CodeSpec[op].nuses;
> while (--i >= 0)
> PopOff(ss, JSOP_NOP);
1189c1327
< JS_ASSERT(0);
---
> LOCAL_ASSERT(0);
1207c1345
< JS_ASSERT(js_CodeSpec[saveop].length == oplen);
---
> LOCAL_ASSERT(js_CodeSpec[saveop].length == oplen);
1209c1347
< jp->dvgflag = JS_FALSE;
---
> jp->dvgfence = NULL;
1223c1361
< JS_ASSERT(op != saveop);
---
> LOCAL_ASSERT(op != saveop);
1236c1374
< JS_ASSERT(op == JSOP_ADD);
---
> LOCAL_ASSERT(op == JSOP_ADD);
1330c1468
< js_printf(jp, "\t%s:\n", rval);
---
> js_printf(CLEAR_MAYBE_BRACE(jp), "\t%s:\n", rval);
1353c1491
< JS_ASSERT(ATOM_IS_OBJECT(atom));
---
> LOCAL_ASSERT(ATOM_IS_OBJECT(atom));
1581c1719
< JS_ASSERT(pc[len] == JSOP_LEAVEBLOCKEXPR);
---
> LOCAL_ASSERT(pc[len] == JSOP_LEAVEBLOCKEXPR);
1649c1787
< JS_ASSERT(!strcmp(rval, iter_cookie));
---
> LOCAL_ASSERT(!strcmp(rval, iter_cookie));
1654c1792
< JS_ASSERT(!js_GetSrcNote(jp->script, pc));
---
> LOCAL_ASSERT(!js_GetSrcNote(jp->script, pc));
1677d1814
< atom = GET_ATOM(cx, jp->script, pc);
1693c1830
< JS_ASSERT(sprop->shortid < argc);
---
> LOCAL_ASSERT(sprop->shortid < argc);
1733,1735c1870,1872
< str = ATOM_TO_STRING(atomv[i - OBJ_BLOCK_DEPTH(cx, obj)]);
< rval = QuoteString(&ss->sprinter, str, 0);
< if (!rval) {
---
> atom = atomv[i - OBJ_BLOCK_DEPTH(cx, obj)];
> str = ATOM_TO_STRING(atom);
> if (!QuoteString(&jp->sprinter, str, 0)) {
1739,1740d1875
< RETRACT(&ss->sprinter, rval);
< js_printf(jp, "%s", rval);
1745c1880
< JS_ASSERT(len > 0);
---
> LOCAL_ASSERT(len > 0);
1779,1780c1914,1918
< if (sn) {
< JS_ASSERT(op == JSOP_LEAVEBLOCK);
---
> if (op == JSOP_LEAVEBLOCKEXPR) {
> LOCAL_ASSERT(SN_TYPE(sn) == SRC_PCBASE);
> rval = POP_STR();
> } else if (sn) {
> LOCAL_ASSERT(op == JSOP_LEAVEBLOCK);
1786,1787d1923
< if (op == JSOP_LEAVEBLOCKEXPR)
< rval = POP_STR();
1790c1926
< JS_ASSERT(top >= depth);
---
> LOCAL_ASSERT(top >= depth);
1793c1929
< ss->sprinter.offset = ss->offsets[top];
---
> ss->sprinter.offset = GetOff(ss, top);
1802,1844c1938,1939
< if ((uintN)i < ss->top) {
< rval = OFF2STR(&ss->sprinter, ss->offsets[i]);
< } else {
< jsatomid j, n;
< JSScript *script;
< jsint depth, count;
< JSScopeProperty *sprop;
<
< /*
< * We must be called from js_DecompileValueGenerator when
< * dereferencing a local that's undefined or null. Search
< * jp->script->atomMap for the block containing this local
< * by its stack index, i.
< */
< script = jp->script;
< for (j = 0, n = script->atomMap.length; j < n; j++) {
< atom = script->atomMap.vector[j];
< if (ATOM_IS_OBJECT(atom)) {
< obj = ATOM_TO_OBJECT(atom);
< if (OBJ_GET_CLASS(cx, obj) == &js_BlockClass) {
< depth = OBJ_BLOCK_DEPTH(cx, obj);
< count = OBJ_BLOCK_COUNT(cx, obj);
< if ((jsuint)(i - depth) < (jsuint)count)
< break;
< }
< }
< }
<
< LOCAL_ASSERT(j < n);
< i -= depth;
< for (sprop = OBJ_SCOPE(obj)->lastProp; sprop;
< sprop = sprop->parent) {
< if (sprop->shortid == i)
< break;
< }
<
< LOCAL_ASSERT(sprop && JSID_IS_ATOM(sprop->id));
< atom = JSID_TO_ATOM(sprop->id);
< rval = QuoteString(&ss->sprinter, ATOM_TO_STRING(atom), 0);
< if (!rval)
< return JS_FALSE;
< RETRACT(&ss->sprinter, rval);
< }
---
> LOCAL_ASSERT((uintN)i < ss->top);
> rval = GetLocal(ss, i);
1848a1944
> case JSOP_SETLOCALPOP:
1850c1946
< lval = OFF2STR(&ss->sprinter, ss->offsets[i]);
---
> lval = GetStr(ss, i);
1857c1953
< lval = OFF2STR(&ss->sprinter, ss->offsets[i]);
---
> lval = GetLocal(ss, i);
1863c1959
< lval = OFF2STR(&ss->sprinter, ss->offsets[i]);
---
> lval = GetLocal(ss, i);
1868c1964
< lval = OFF2STR(&ss->sprinter, ss->offsets[i]);
---
> lval = GetStr(ss, i);
2206c2302
< JS_ASSERT(*xval != '\0');
---
> LOCAL_ASSERT(*xval != '\0');
2221c2317
< rval = OFF2STR(&ss->sprinter, ss->offsets[ss->top-1]);
---
> rval = GetStr(ss, ss->top-1);
2289c2385,2391
< LOCAL_ASSERT(strcmp(rval, forelem_cookie) == 0);
---
> if (strcmp(rval, forelem_cookie) != 0) {
> if (strcmp(lval, "()") == 0)
> lval = "";
> js_printf(jp, "\t%s[%s] = %s\n", lval, xval, rval);
> todo = -2;
> break;
> }
2306c2408
< rval = OFF2STR(&ss->sprinter, ss->offsets[ss->top-2]);
---
> rval = GetStr(ss, ss->top-2);
2313c2415
< rval = OFF2STR(&ss->sprinter, ss->offsets[ss->top-1]);
---
> rval = GetStr(ss, ss->top-1);
2359a2462,2469
> if (op == JSOP_SETLOCALPOP) {
> if (!PushOff(ss, todo, saveop))
> return JS_FALSE;
> rval = POP_STR();
> LOCAL_ASSERT(*rval != '\0');
> js_printf(jp, "\t%s;\n", rval);
> todo = -2;
> }
2526c2636
< op = saveop;
---
> op = JSOP_GETELEM;
2587c2697
< op = saveop;
---
> op = JSOP_GETELEM;
2806c2916
< default: JS_ASSERT(0);
---
> default: LOCAL_ASSERT(0);
2830c2940
< inXML ? QUOTE_IN_XML : '"');
---
> inXML ? DONT_ESCAPE : '"');
2873c2983
< JS_ASSERT(sn && SN_TYPE(sn) == SRC_SWITCH);
---
> LOCAL_ASSERT(sn && SN_TYPE(sn) == SRC_SWITCH);
2900c3010
< JS_ASSERT(SN_TYPE(sn) == SRC_LABEL);
---
> LOCAL_ASSERT(SN_TYPE(sn) == SRC_LABEL);
2934c3044
< JS_ASSERT(sn && SN_TYPE(sn) == SRC_SWITCH);
---
> LOCAL_ASSERT(sn && SN_TYPE(sn) == SRC_SWITCH);
2951c3061
< JS_ASSERT(SN_TYPE(sn) == SRC_LABEL);
---
> LOCAL_ASSERT(SN_TYPE(sn) == SRC_LABEL);
2982c3092
< JS_ASSERT(sn && SN_TYPE(sn) == SRC_SWITCH);
---
> LOCAL_ASSERT(sn && SN_TYPE(sn) == SRC_SWITCH);
2994,2995c3104,3105
< JS_ASSERT(*pc2 == JSOP_CASE || *pc2 == JSOP_DEFAULT ||
< *pc2 == JSOP_CASEX || *pc2 == JSOP_DEFAULTX);
---
> LOCAL_ASSERT(*pc2 == JSOP_CASE || *pc2 == JSOP_DEFAULT ||
> *pc2 == JSOP_CASEX || *pc2 == JSOP_DEFAULTX);
3001c3111
< JS_ASSERT(sn && SN_TYPE(sn) == SRC_PCDELTA);
---
> LOCAL_ASSERT(sn && SN_TYPE(sn) == SRC_PCDELTA);
3019,3020c3129,3130
< JS_ASSERT(*pc2 == JSOP_CASE || *pc2 == JSOP_DEFAULT ||
< *pc2 == JSOP_CASEX || *pc2 == JSOP_DEFAULTX);
---
> LOCAL_ASSERT(*pc2 == JSOP_CASE || *pc2 == JSOP_DEFAULT ||
> *pc2 == JSOP_CASEX || *pc2 == JSOP_DEFAULTX);
3026c3136
< JS_ASSERT(sn && SN_TYPE(sn) == SRC_PCDELTA);
---
> LOCAL_ASSERT(sn && SN_TYPE(sn) == SRC_PCDELTA);
3069c3179
< JS_ASSERT(ATOM_IS_OBJECT(atom));
---
> LOCAL_ASSERT(ATOM_IS_OBJECT(atom));
3190,3191c3300,3301
< JS_ASSERT(strncmp(rval, js_function_str, 8) == 0 &&
< rval[8] == ' ');
---
> LOCAL_ASSERT(strncmp(rval, js_function_str, 8) == 0 &&
> rval[8] == ' ');
3193c3303
< JS_ASSERT(rval[strlen(rval)-1] == '}');
---
> LOCAL_ASSERT(rval[strlen(rval)-1] == '}');
3373d3482
< atom = GET_ATOM(cx, jp->script, pc);
3448c3557,3558
< js_DecompileCode(JSPrinter *jp, JSScript *script, jsbytecode *pc, uintN len)
---
> js_DecompileCode(JSPrinter *jp, JSScript *script, jsbytecode *pc, uintN len,
> uintN pcdepth)
3449a3560
> uintN depth, i;
3457a3569,3571
> depth = script->depth;
> JS_ASSERT(pcdepth <= depth);
>
3465,3466c3579,3580
< offsetsz = script->depth * sizeof(ptrdiff_t);
< opcodesz = script->depth * sizeof(jsbytecode);
---
> offsetsz = depth * sizeof(ptrdiff_t);
> opcodesz = depth * sizeof(jsbytecode);
3474c3588,3627
< ss.top = ss.inArrayInit = 0;
---
> ss.top = pcdepth;
> ss.inArrayInit = 0;
>
> /*
> * If we are called from js_DecompileValueGenerator with a portion of
> * script's bytecode that starts with a non-zero model stack depth given
> * by pcdepth, attempt to initialize the missing string offsets in ss to
> * |spindex| negative indexes from fp->sp for the activation fp in which
> * the error arose.
> *
> * See js_DecompileValueGenerator for how its |spindex| parameter is used,
> * and see also GetOff, which makes use of the ss.offsets[i] < -1 that are
> * potentially stored below.
> */
> if (pcdepth != 0) {
> JSStackFrame *fp;
> ptrdiff_t top;
>
> for (fp = cx->fp; fp && !fp->script; fp = fp->down)
> continue;
> top = fp ? fp->sp - fp->spbase : 0;
> for (i = 0; i < pcdepth; i++) {
> ss.offsets[i] = -1;
> ss.opcodes[i] = JSOP_NOP;
> }
> if (fp && fp->pc == pc) {
> JS_ASSERT((uintN)top == pcdepth);
> for (i = 0; i < pcdepth; i++) {
> ptrdiff_t off;
> jsbytecode *genpc;
>
> off = (intN)i - (intN)depth;
> genpc = (jsbytecode *) fp->spbase[off];
> if (JS_UPTRDIFF(genpc, script->code) < script->length) {
> ss.offsets[i] += (ptrdiff_t)i - top;
> ss.opcodes[i] = *genpc;
> }
> }
> }
> }
3485,3486c3638,3639
< last = OFF2STR(&ss.sprinter, PopOff(&ss, JSOP_NOP));
< } while (ss.top);
---
> last = OFF2STR(&ss.sprinter, PopOff(&ss, JSOP_POP));
> } while (ss.top > pcdepth);
3499c3652
< return js_DecompileCode(jp, script, script->code, (uintN)script->length);
---
> return js_DecompileCode(jp, script, script->code, (uintN)script->length, 0);
3519c3672
< ok = js_DecompileCode(jp, script, script->code, (uintN)script->length);
---
> ok = js_DecompileCode(jp, script, script->code, (uintN)script->length, 0);
3532a3686,3687
> jsbytecode *pc;
> ptrdiff_t len;
3587a3743
> pc = fun->u.i.script->main;
3590a3747,3757
>
> #if JS_HAS_DESTRUCTURING
> if (!params[i]) {
> JS_ASSERT(*pc == JSOP_GETARG);
> pc += JSOP_GETARG_LENGTH;
> JS_ASSERT(*pc == JSOP_DUP);
> /* FIXME: bug 346642 */
> continue;
> }
> #endif
>
3597a3765
> pc = NULL;
3607c3775,3776
< ok = js_DecompileScript(jp, fun->u.i.script);
---
> len = fun->u.i.script->code + fun->u.i.script->length - pc;
> ok = js_DecompileCode(jp, fun->u.i.script, pc, (uintN)len, 0);
3632c3801,3802
< jsval *sp, *base, *limit;
---
> jsval *sp, *spbase, *base, *limit;
> intN depth, pcdepth;
3636d3805
< intN depth;
3638c3807
< uintN len;
---
> ptrdiff_t len, oplen;
3648a3818,3828
> sp = fp->sp;
> spbase = fp->spbase;
> if ((uintN)(sp - spbase) > fp->script->depth) {
> /*
> * Preparing to make an internal invocation, using an argv stack
> * segment pushed just above fp's operand stack space. Such an argv
> * stack has no generating pc "basement", so we must fall back.
> */
> goto do_fallback;
> }
>
3660a3841
> spbase = down->spbase;
3671c3852
< base = fp->spbase;
---
> spbase = base = fp->spbase;
3698c3879,3881
< for (sp = limit; sp > base; ) {
---
> for (sp = limit;;) {
> if (sp <= base)
> goto do_fallback;
3702c3885,3886
< pc = (jsbytecode *) sp[-depth];
---
> sp -= depth;
> pc = (jsbytecode *) *sp;
3736c3920
< * from sp[-(1+depth)].
---
> * from fp->sp[-(1+depth)].
3747,3749c3931,3950
< /* XXX handle null as a special case, to avoid calling null "object" */
< if (op == JSOP_NULL)
< return ATOM_TO_STRING(cx->runtime->atomState.nullAtom);
---
> /* None of these stack-writing ops generates novel values. */
> JS_ASSERT(op != JSOP_CASE && op != JSOP_CASEX &&
> op != JSOP_DUP && op != JSOP_DUP2 &&
> op != JSOP_SWAP);
>
> /*
> * |this| could convert to a very long object initialiser, so cite it by
> * its keyword name instead.
> */
> if (op == JSOP_THIS)
> return JS_NewStringCopyZ(cx, js_this_str);
>
> /*
> * JSOP_BINDNAME is special: it generates a value, the base object of a
> * reference. But if it is the generating op for a diagnostic produced by
> * js_DecompileValueGenerator, the name being bound is irrelevant. Just
> * fall back to the base object.
> */
> if (op == JSOP_BINDNAME)
> goto do_fallback;
3751c3952
< /* NAME ops are self-contained, but others require left context. */
---
> /* NAME ops are self-contained, others require left or right context. */
3753,3755c3954,3958
< if ((cs->format & JOF_MODEMASK) == JOF_NAME) {
< begin = pc;
< } else {
---
> begin = pc;
> end = pc + cs->length;
> if ((cs->format & JOF_MODEMASK) != JOF_NAME) {
> JSSrcNoteType noteType;
>