-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path491.bug
More file actions
executable file
·4158 lines (4158 loc) · 153 KB
/
491.bug
File metadata and controls
executable file
·4158 lines (4158 loc) · 153 KB
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 490/src/config/CVS/Tag 491/src/config/CVS/Tag
1c1
< D2006.05.19.17.25.36
---
> D2006.05.21.05.27.28
diff -r 490/src/CVS/Entries 491/src/CVS/Entries
36a37,38
> /Makefile.in/3.106/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
> /Makefile.ref/3.40/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
38a41
> /js.c/3.115/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
39a43,45
> /js.msg/3.56/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
> /jsapi.c/3.264/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
> /jsapi.h/3.122/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
43a50,51
> /jsatom.c/3.75/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
> /jsatom.h/3.46/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
45a54,55
> /jscntxt.c/3.84/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
> /jscntxt.h/3.100/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
46a57
> /jsconfig.h/3.41/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
47a59
> /jsdbgapi.c/3.64/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
50a63,64
> /jsemit.c/3.155/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
> /jsemit.h/3.44/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
53a68,70
> /jsfun.c/3.157/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
> /jsfun.h/3.27/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
> /jsgc.c/3.138/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
56a74,78
> /jsinterp.c/3.242/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
> /jsinterp.h/3.50/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
> /jsiter.c/3.2/Sat May 20 22:27:28 2006//D2006.05.21.05.27.28
> /jsiter.h/3.2/Sat May 20 22:27:28 2006//D2006.05.21.05.27.28
> /jskeyword.tbl/3.6/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
62a85,92
> /jsobj.c/3.259/Result of merge//D2006.05.21.05.27.28
> /jsobj.h/3.46/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
> /jsopcode.c/3.122/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
> /jsopcode.h/3.30/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
> /jsopcode.tbl/3.52/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
> /jsosdep.h/3.21/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
> /jsparse.c/3.171/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
> /jsparse.h/3.28/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
64a95
> /jsproto.tbl/3.3/Sat May 20 22:27:28 2006//D2006.05.21.05.27.28
65a97,98
> /jspubtd.h/3.58/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
> /jsregexp.c/3.119/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
66a100,101
> /jsscan.c/3.101/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
> /jsscan.h/3.45/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
68a104
> /jsscript.c/3.99/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
69a106,107
> /jsstr.c/3.129/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
> /jsstr.h/3.31/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
74a113
> /jsxml.c/3.107/Mon Nov 17 04:55:40 2014//D2006.05.21.05.27.28
78,116d116
< /Makefile.in/3.105/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /Makefile.ref/3.39/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /js.c/3.114/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /js.msg/3.55/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsapi.c/3.263/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsapi.h/3.121/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsatom.c/3.74/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsatom.h/3.45/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jscntxt.c/3.83/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jscntxt.h/3.99/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsconfig.h/3.40/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsdbgapi.c/3.63/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsemit.c/3.154/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsemit.h/3.43/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsfun.c/3.156/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsfun.h/3.26/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsgc.c/3.137/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsinterp.c/3.241/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsinterp.h/3.49/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsiter.c/3.1/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsiter.h/3.1/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jskeyword.tbl/3.5/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsobj.c/3.258/Result of merge//D2006.05.19.17.25.36
< /jsobj.h/3.45/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsopcode.c/3.121/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsopcode.h/3.29/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsopcode.tbl/3.51/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsosdep.h/3.20/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsparse.c/3.170/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsparse.h/3.27/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsproto.tbl/3.2/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jspubtd.h/3.57/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsregexp.c/3.118/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsscan.c/3.100/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsscan.h/3.44/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsscript.c/3.98/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsstr.c/3.128/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsstr.h/3.30/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
< /jsxml.c/3.106/Mon Nov 17 04:55:44 2014//D2006.05.19.17.25.36
diff -r 490/src/CVS/Tag 491/src/CVS/Tag
1c1
< D2006.05.19.17.25.36
---
> D2006.05.21.05.27.28
diff -r 490/src/editline/CVS/Tag 491/src/editline/CVS/Tag
1c1
< D2006.05.19.17.25.36
---
> D2006.05.21.05.27.28
diff -r 490/src/fdlibm/CVS/Tag 491/src/fdlibm/CVS/Tag
1c1
< D2006.05.19.17.25.36
---
> D2006.05.21.05.27.28
diff -r 490/src/jsapi.c 491/src/jsapi.c
88a89,92
> #if JS_HAS_GENERATORS
> #include "jsiter.h"
> #endif
>
1087,1105d1090
< static JSBool
< AlreadyHasOwnProperty(JSContext *cx, JSObject *obj, JSAtom *atom, jsval *vp)
< {
< JSScopeProperty *sprop;
< JSScope *scope;
<
< JS_ASSERT(OBJ_IS_NATIVE(obj));
< JS_LOCK_OBJ(cx, obj);
< scope = OBJ_SCOPE(obj);
< sprop = SCOPE_GET_PROPERTY(scope, ATOM_TO_JSID(atom));
< if (vp) {
< *vp = (sprop && SPROP_HAS_VALID_SLOT(sprop, scope))
< ? LOCKED_OBJ_GET_SLOT(obj, sprop->slot)
< : JSVAL_VOID;
< }
< JS_UNLOCK_SCOPE(cx, scope);
< return sprop != NULL;
< }
<
1109,1147d1093
< JSContext *ocx;
< JSAtom **classAtoms;
< JSProtoKey key;
< jsval v;
<
< if (!obj) {
< /* Clearing cx->globalObject: clear cached class object refs too. */
< memset(cx->classObjects, 0, sizeof cx->classObjects);
< } else {
< /*
< * In case someone initialized obj's standard classes on another
< * context, then handed obj off to cx, try to find that other context
< * and copy its class objects into cx's.
< */
< ocx = js_FindContextForGlobal(cx, obj);
< if (ocx) {
< memcpy(cx->classObjects, ocx->classObjects,
< sizeof cx->classObjects);
< } else {
< /*
< * Darn, can't find another context in which obj's standard classes,
< * or at least some of them, were initialized. Try to make obj and
< * cx agree on the state of the standard classes.
< */
< memset(cx->classObjects, 0, sizeof cx->classObjects);
< classAtoms = cx->runtime->atomState.classAtoms;
< for (key = JSProto_Null; key < JSProto_LIMIT; key++) {
< if (AlreadyHasOwnProperty(cx, obj, classAtoms[key], &v) &&
< !JSVAL_IS_PRIMITIVE(v)) {
< cx->classObjects[key] = JSVAL_TO_OBJECT(v);
< }
< }
< }
< }
<
< /*
< * Do this after js_FindContextForGlobal, so it can assert that obj is not
< * yet cx->globalObject.
< */
1272a1219,1221
> #if JS_HAS_GENERATORS
> js_InitIteratorClasses(cx, obj) &&
> #endif
1309a1259,1261
> #if JS_HAS_GENERATORS
> {js_InitIteratorClasses, CLASS_ATOM_OFFSET(StopIteration)},
> #endif
1386a1339,1342
> #if JS_HAS_GENERATORS
> {js_InitIteratorClasses, EAGERLY_PINNED_CLASS_ATOM(Iterator)},
> #endif
>
1494a1451,1464
> static JSBool
> AlreadyHasOwnProperty(JSContext *cx, JSObject *obj, JSAtom *atom)
> {
> JSScopeProperty *sprop;
> JSScope *scope;
>
> JS_ASSERT(OBJ_IS_NATIVE(obj));
> JS_LOCK_OBJ(cx, obj);
> scope = OBJ_SCOPE(obj);
> sprop = SCOPE_GET_PROPERTY(scope, ATOM_TO_JSID(atom));
> JS_UNLOCK_SCOPE(cx, scope);
> return sprop != NULL;
> }
>
1507c1477
< if (!AlreadyHasOwnProperty(cx, obj, atom, NULL) &&
---
> if (!AlreadyHasOwnProperty(cx, obj, atom) &&
1516c1486
< if (!AlreadyHasOwnProperty(cx, obj, atom, NULL) &&
---
> if (!AlreadyHasOwnProperty(cx, obj, atom) &&
1547c1517
< *foundp = AlreadyHasOwnProperty(cx, obj, atom, NULL);
---
> *foundp = AlreadyHasOwnProperty(cx, obj, atom);
1628c1598,1605
< return cx->fp ? cx->fp->scopeChain : NULL;
---
> JSStackFrame *fp;
>
> fp = cx->fp;
> if (!fp) {
> JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL, JSMSG_INACTIVE);
> return NULL;
> }
> return js_GetScopeChain(cx, fp);
2174c2151
< JS_PUSH_SINGLE_TEMP_ROOT(cx, OBJECT_TO_JSVAL(proto), &tvr);
---
> JS_PUSH_SINGLE_TEMP_ROOT(cx, proto, &tvr);
2179c2156,2158
< * class is anonymous, i.e. for internal use only.
---
> * class (a) is anonymous, i.e. for internal use only; (b) the class
> * of obj (the global object) is has a reserved slot indexed by key;
> * and (c) key is not the null key.
2181c2160,2162
< if (clasp->flags & JSCLASS_IS_ANONYMOUS) {
---
> if ((clasp->flags & JSCLASS_IS_ANONYMOUS) &&
> (OBJ_GET_CLASS(cx, obj)->flags & JSCLASS_IS_GLOBAL) &&
> key != JSProto_Null) {
2186c2167,2171
< NULL, NULL, 0, NULL);
---
> NULL, NULL,
> (clasp->flags & JSCLASS_IS_ANONYMOUS)
> ? JSPROP_READONLY | JSPROP_PERMANENT
> : 0,
> NULL);
2189a2175
>
2242,2243c2228,2229
< if (key != JSProto_Null)
< js_SetClassObject(cx, obj, key, ctor);
---
> if (key != JSProto_Null && !js_SetClassObject(cx, obj, key, ctor))
> goto bad;
3213,3214d3198
< if (cx->globalObject == obj)
< memset(cx->classObjects, 0, sizeof cx->classObjects);
4374c4358
< cx->rval2set = JS_TRUE;
---
> cx->rval2set = JS_RVAL2_VALUE;
diff -r 490/src/jsapi.h 491/src/jsapi.h
965a966,982
> #define JSCLASS_IS_GLOBAL (1<<(JSCLASS_HIGH_FLAGS_SHIFT+2))
>
> /*
> * ECMA-262 requires that most constructors used internally create objects
> * with "the original Foo.prototype value" as their [[Prototype]] (__proto__)
> * member initial value. The "original ... value" verbiage is there because
> * in ECMA-262, global properties naming class objects are read/write and
> * deleteable, for the most part.
> *
> * Implementing this efficiently requires that global objects have classes
> * with the following flags. Failure to use JSCLASS_GLOBAL_FLAGS won't break
> * anything except the ECMA-262 "original prototype value" behavior, which was
> * broken for years in SpiderMonkey. In other words, without these flags you
> * get backward compatibility.
> */
> #define JSCLASS_GLOBAL_FLAGS \
> (JSCLASS_IS_GLOBAL | JSCLASS_HAS_RESERVED_SLOTS(JSProto_LIMIT))
diff -r 490/src/jsatom.c 491/src/jsatom.c
89c89
< #define JS_PROTO(name,init) const char js_##name##_str[] = #name;
---
> #define JS_PROTO(name,code,init) const char js_##name##_str[] = #name;
94c94
< #define JS_PROTO(name,init) js_##name##_str,
---
> #define JS_PROTO(name,code,init) js_##name##_str,
112a113
> const char js_iterator_str[] = "__iterator__";
114a116
> const char js_next_str[] = "next";
312a315
> FROB(iteratorAtom, js_iterator_str);
314a318
> FROB(nextAtom, js_next_str);
diff -r 490/src/jsatom.h 491/src/jsatom.h
181a182
> JSAtom *iteratorAtom;
184a186
> JSAtom *nextAtom;
253c255
< #define JS_PROTO(name,init) extern const char js_##name##_str[];
---
> #define JS_PROTO(name,code,init) extern const char js_##name##_str[];
257,272d258
< extern const char js_Arguments_str[];
< extern const char js_Array_str[];
< extern const char js_Boolean_str[];
< extern const char js_Call_str[];
< extern const char js_Date_str[];
< extern const char js_Function_str[];
< extern const char js_Math_str[];
< extern const char js_Namespace_str[];
< extern const char js_Number_str[];
< extern const char js_Object_str[];
< extern const char js_QName_str[];
< extern const char js_RegExp_str[];
< extern const char js_Script_str[];
< extern const char js_String_str[];
< extern const char js_XML_str[];
< extern const char js_File_str[];
287a274
> extern const char js_iterator_str[];
290a278
> extern const char js_next_str[];
diff -r 490/src/js.c 491/src/js.c
2302c2302
< "global", JSCLASS_NEW_RESOLVE,
---
> "global", JSCLASS_NEW_RESOLVE | JSCLASS_GLOBAL_FLAGS,
diff -r 490/src/jscntxt.c 491/src/jscntxt.c
770,892d769
< JS_STATIC_DLL_CALLBACK(JSObject *)
< js_InitNullClass(JSContext *cx, JSObject *obj)
< {
< JS_ASSERT(0);
< return NULL;
< }
<
< #define JS_PROTO(name,init) extern JSObject *init(JSContext *, JSObject *);
< #include "jsproto.tbl"
< #undef JS_PROTO
<
< static JSObjectOp lazy_prototype_init[JSProto_LIMIT] = {
< #define JS_PROTO(name,init) init,
< #include "jsproto.tbl"
< #undef JS_PROTO
< };
<
< /*
< * We optimize prototype caching by storing strong references to standard
< * object prototypes in each cx whose globalObject is populated (eagerly or
< * lazily) with the standard class constructors and global functions.
< *
< * But since in anything like a browser embedding, an object statically
< * scoped by one global object may be accessed by script running on another
< * global object's context, we must not dynamically scope cached prototypes.
< * This may require searching all contexts for a given thread, in the event
< * that a given execution context does not have a global object equal to the
< * global of a given target object.
< */
< JSContext *
< js_FindContextForGlobal(JSContext *cx, JSObject *obj)
< {
< JSCList *head, *link;
< JSContext *ocx;
<
< JS_ASSERT(cx->globalObject != obj);
< #ifdef JS_THREADSAFE
< head = &cx->thread->contextList;
< #else
< head = &cx->runtime->contextList;
< #endif
< for (link = head->next; link != head; link = link->next) {
< #ifdef JS_THREADSAFE
< ocx = CX_FROM_THREAD_LINKS(link);
< JS_ASSERT(ocx->thread == cx->thread);
< #else
< ocx = (JSContext *) link;
< #endif
< if (ocx != cx && ocx->globalObject == obj)
< return ocx;
< }
< return NULL;
< }
<
< JSBool
< js_GetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key,
< JSObject **objp)
< {
< JSBool ok;
< JSResolvingKey rkey;
< JSResolvingEntry *rentry;
< uint32 generation;
< JSObject *tmp, *cobj;
< JSContext *ocx;
< JSObjectOp init;
<
< rkey.obj = obj;
< rkey.id = ATOM_TO_JSID(cx->runtime->atomState.classAtoms[key]);
< ok = js_StartResolving(cx, &rkey, JSRESFLAG_LOOKUP, &rentry);
< if (!ok)
< return JS_FALSE;
< if (!rentry) {
< /* Already caching key in obj -- suppress recursion. */
< *objp = NULL;
< return JS_TRUE;
< }
< generation = cx->resolvingTable->generation;
<
< while ((tmp = OBJ_GET_PARENT(cx, obj)) != NULL)
< obj = tmp;
< if (obj == cx->globalObject) {
< ocx = cx;
< } else {
< ocx = js_FindContextForGlobal(cx, obj);
< if (!ocx) {
< cobj = NULL;
< goto out;
< }
< }
<
< cobj = ocx->classObjects[key];
< if (!cobj) {
< init = lazy_prototype_init[key];
< if (init) {
< if (!init(cx, obj))
< ok = JS_FALSE;
< cobj = ocx->classObjects[key];
< }
< }
<
< out:
< *objp = cobj;
< js_StopResolving(cx, &rkey, JSRESFLAG_LOOKUP, rentry, generation);
< return ok;
< }
<
< void
< js_SetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key,
< JSObject *value)
< {
< JSContext *ocx;
<
< JS_ASSERT(!OBJ_GET_PARENT(cx, obj));
< if (obj == cx->globalObject) {
< ocx = cx;
< } else {
< ocx = js_FindContextForGlobal(cx, obj);
< if (!ocx)
< return;
< }
< ocx->classObjects[key] = value;
< }
<
diff -r 490/src/jscntxt.h 491/src/jscntxt.h
353a354,367
> #if JS_HAS_LVALUE_RETURN
> /*
> * Values for the cx->rval2set flag byte. This flag tells whether cx->rval2
> * is unset (CLEAR), set to a jsval (VALUE) naming a property in the object
> * referenced by cx->fp->rval, or set to a jsid (ITERKEY) result of a native
> * iterator's it.next() call (where the return value of it.next() is the next
> * value in the iteration).
> *
> * The ITERKEY case is just an optimization for native iterators, as general
> * iterators can return an array of length 2 to return a [key, value] pair.
> */
> enum { JS_RVAL2_CLEAR, JS_RVAL2_VALUE, JS_RVAL2_ITERKEY };
> #endif
>
417a432,433
> * Context-linked stack of temporary GC roots.
> *
422a439,447
> * To root a single GC-thing pointer, which need not be tagged and stored as a
> * jsval, use JS_PUSH_SINGLE_TEMP_ROOT. The (jsval)(val) cast works because a
> * GC-thing is aligned on a 0 mod 8 boundary, and object has the 0 jsval tag.
> * So any GC-thing may be tagged as if it were an object and untagged, if it's
> * then used only as an opaque pointer until discriminated by other means than
> * tag bits (this is how the GC mark function uses its |thing| parameter -- it
> * consults GC-thing flags stored separately from the thing to decide the type
> * of thing).
> *
447c472
< (tvr)->u.value = (val); \
---
> (tvr)->u.value = (jsval)(val); \
552c577
< JSPackedBool rval2set;
---
> uint8 rval2set;
604,605c629,630
< /* Roots for the standard class objects (Object, Function, etc.) */
< JSObject *classObjects[JSProto_LIMIT];
---
> /* Iterator cache to speed up native default for-in loop case. */
> JSObject *cachedIterObj;
610c635
< #endif
---
> #endif
740,753d764
< * Fast access to immutable standard objects (constructors and prototypes).
< */
< extern JSContext *
< js_FindContextForGlobal(JSContext *cx, JSObject *obj);
<
< extern JSBool
< js_GetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key,
< JSObject **objp);
<
< extern void
< js_SetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key,
< JSObject *value);
<
< /*
diff -r 490/src/jsconfig.h 491/src/jsconfig.h
44c44
< #define JS_VERSION 160
---
> #define JS_VERSION 170
106a107,108
> #define JS_HAS_GENERATORS 0 /* has yield in generator function */
> #define JS_HAS_BLOCK_SCOPE 0 /* has block scope via let/arraycomp */
135a138,139
> #define JS_HAS_GENERATORS 0 /* has yield in generator function */
> #define JS_HAS_BLOCK_SCOPE 0 /* has block scope via let/arraycomp */
160a165,193
> #define JS_HAS_GENERATORS 0 /* has yield in generator function */
> #define JS_HAS_BLOCK_SCOPE 0 /* has block scope via let/arraycomp */
>
> #elif JS_VERSION == 170
>
> #define JS_HAS_STR_HTML_HELPERS 1 /* has str.anchor, str.bold, etc. */
> #define JS_HAS_PERL_SUBSTR 1 /* has str.substr */
> #define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */
> #define JS_HAS_OBJ_WATCHPOINT 1 /* has o.watch and o.unwatch */
> #define JS_HAS_EXPORT_IMPORT 1 /* has export fun; import obj.fun */
> #define JS_HAS_EVAL_THIS_SCOPE 1 /* Math.eval is same as with (Math) */
> #define JS_HAS_SHARP_VARS 1 /* has #n=, #n# for object literals */
> #define JS_HAS_SCRIPT_OBJECT 1 /* has (new Script("x++")).exec() */
> #define JS_HAS_XDR 1 /* has XDR API and internal support */
> #define JS_HAS_XDR_FREEZE_THAW 0 /* has XDR freeze/thaw script methods */
> #define JS_HAS_TOSOURCE 1 /* has Object/Array toSource method */
> #define JS_HAS_DEBUGGER_KEYWORD 1 /* has hook for debugger keyword */
> #define JS_HAS_CATCH_GUARD 1 /* has exception handling catch guard */
> #define JS_HAS_SPARSE_ARRAYS 0 /* array methods preserve empty elems */
> #define JS_HAS_GETTER_SETTER 1 /* has JS2 getter/setter functions */
> #define JS_HAS_UNEVAL 1 /* has uneval() top-level function */
> #define JS_HAS_CONST 1 /* has JS2 const as alternative var */
> #define JS_HAS_FUN_EXPR_STMT 1 /* has function expression statement */
> #define JS_HAS_LVALUE_RETURN 1 /* has o.item(i) = j; for native item */
> #define JS_HAS_NO_SUCH_METHOD 1 /* has o.__noSuchMethod__ handler */
> #define JS_HAS_XML_SUPPORT 1 /* has ECMAScript for XML support */
> #define JS_HAS_ARRAY_EXTRAS 1 /* has indexOf and Lispy extras */
> #define JS_HAS_GENERATORS 1 /* has yield in generator function */
> #define JS_HAS_BLOCK_SCOPE 1 /* has block scope via let/arraycomp */
diff -r 490/src/jsdbgapi.c 491/src/jsdbgapi.c
785c785
< return fp->scopeChain;
---
> return js_GetScopeChain(cx, fp);
903a904
> JSObject *scobj;
907a909,912
> scobj = js_GetScopeChain(cx, fp);
> if (!scobj)
> return JS_FALSE;
>
916c921
< script = JS_CompileUCScriptForPrincipals(cx, fp->scopeChain,
---
> script = JS_CompileUCScriptForPrincipals(cx, scobj,
924,925c929,930
< ok = js_Execute(cx, fp->scopeChain, script, fp,
< JSFRAME_DEBUGGER | JSFRAME_EVAL, rval);
---
> ok = js_Execute(cx, scobj, script, fp, JSFRAME_DEBUGGER | JSFRAME_EVAL,
> rval);
diff -r 490/src/jsemit.c 491/src/jsemit.c
235a236
> const char js_finally_block_str[] = "finally block";
245c246
< "try statement", /* TRY */
---
> "block scope", /* BLOCK_SCOPE */
247c248,250
< "finally statement", /* FINALLY */
---
> "try block", /* TRY */
> js_finally_block_str, /* FINALLY */
> js_finally_block_str, /* SUBROUTINE */
1228a1232,1247
> if (STMT_TYPE_IS_SCOPE(type)) {
> stmt->downScope = tc->topScopeStmt;
> tc->topScopeStmt = stmt;
> } else {
> stmt->downScope = NULL;
> }
> stmt->blockObj = NULL;
> }
>
> void
> js_PushBlockScope(JSTreeContext *tc, JSStmtInfo *stmt, JSObject *blockObj,
> ptrdiff_t top)
> {
> js_PushStatement(tc, stmt, STMT_BLOCK_SCOPE, top);
> blockObj->slots[JSSLOT_PARENT] = OBJECT_TO_JSVAL(tc->blockChain);
> tc->blockChain = stmt->blockObj = blockObj;
1246a1266,1277
> /*
> * Macro to emit a bytecode followed by a uint16 immediate operand stored in
> * big-endian order, used for arg and var numbers as well as for atomIndexes.
> * NB: We use cx and cg from our caller's lexical environment, and return
> * false on error.
> */
> #define EMIT_UINT16_IMM_OP(op, i) \
> JS_BEGIN_MACRO \
> if (js_Emit3(cx, cg, op, UINT16_HI(i), UINT16_LO(i)) < 0) \
> return JS_FALSE; \
> JS_END_MACRO
>
1321d1351
< * JSOP_POP2 isn't decompiled, so it doesn't need to be HIDDEN.
1323c1353,1355
< if (js_Emit1(cx, cg, JSOP_POP2) < 0)
---
> if (js_NewSrcNote(cx, cg, SRC_HIDDEN) < 0)
> return JS_FALSE;
> if (js_Emit1(cx, cg, JSOP_ENDITER) < 0)
1334a1367,1380
> #if JS_HAS_BLOCK_SCOPE
> case STMT_BLOCK_SCOPE:
> {
> uintN i;
>
> /* There is a Block object with locals on the stack to pop. */
> if (js_NewSrcNote(cx, cg, SRC_HIDDEN) < 0)
> return JS_FALSE;
> i = OBJ_BLOCK_COUNT(cx, stmt->blockObj);
> EMIT_UINT16_IMM_OP(JSOP_LEAVEBLOCK, i);
> break;
> }
> #endif
>
1396c1442,1454
< tc->topStmt = tc->topStmt->down;
---
> JSStmtInfo *stmt;
> JSStmtType type;
>
> stmt = tc->topStmt;
> tc->topStmt = stmt->down;
> type = stmt->type;
> if (STMT_TYPE_IS_SCOPE(type)) {
> tc->topScopeStmt = stmt->downScope;
> if (type == STMT_BLOCK_SCOPE) {
> tc->blockChain =
> JSVAL_TO_OBJECT(stmt->blockObj->slots[JSSLOT_PARENT]);
> }
> }
1438a1497,1541
> /*
> * Find a lexically scoped variable (one declared by let, catch, or an array
> * comprehension) named by atom, looking in tc's compile-time scopes.
> *
> * Return null on error. If atom is found, return the statement info record
> * in which it was found directly, and set *slotp to its stack slot (if any).
> * If atom is not found, return &LL_NOT_FOUND.
> */
> static JSStmtInfo LL_NOT_FOUND;
>
> static JSStmtInfo *
> LexicalLookup(JSContext *cx, JSTreeContext *tc, JSAtom *atom, jsint *slotp)
> {
> JSStmtInfo *stmt;
> JSObject *obj, *pobj;
> JSProperty *prop;
> JSScopeProperty *sprop;
>
> *slotp = -1;
> for (stmt = tc->topScopeStmt; stmt; stmt = stmt->downScope) {
> if (stmt->type == STMT_WITH)
> return stmt;
> if (stmt->type == STMT_CATCH && stmt->label == atom)
> return stmt;
>
> JS_ASSERT(stmt->type == STMT_BLOCK_SCOPE);
> obj = stmt->blockObj;
> if (!js_LookupProperty(cx, obj, ATOM_TO_JSID(atom), &pobj, &prop))
> return NULL;
> if (prop) {
> if (pobj != obj) {
> stmt = &LL_NOT_FOUND;
> } else {
> sprop = (JSScopeProperty *) prop;
> JS_ASSERT(sprop->flags & SPROP_HAS_SHORTID);
> *slotp = OBJ_BLOCK_DEPTH(cx, obj) + sprop->shortid;
> }
> OBJ_DROP_PROPERTY(cx, pobj, prop);
> return stmt;
> }
> }
>
> return &LL_NOT_FOUND;
> }
>
1444a1548,1549
> JSStmtInfo *stmt;
> jsint slot;
1464,1466c1569,1578
< if (obj == fp->scopeChain &&
< !js_InWithStatement(&cg->treeContext) &&
< !js_InCatchBlock(&cg->treeContext, atom)) {
---
> if (obj == fp->scopeChain) {
> /* XXX this will need revising when 'let const' is added. */
> stmt = LexicalLookup(cx, &cg->treeContext, atom, &slot);
> if (!stmt)
> return JS_FALSE;
> if (stmt != &LL_NOT_FOUND) {
> fp = fp->down;
> continue;
> }
>
1610,1621d1721
< * Macro to emit a bytecode followed by a uint16 immediate operand stored in
< * big-endian order, used for arg and var numbers as well as for atomIndexes.
< * NB: We use cx and cg from our caller's lexical environment, and return
< * false on error.
< */
< #define EMIT_UINT16_IMM_OP(op, i) \
< JS_BEGIN_MACRO \
< if (js_Emit3(cx, cg, op, ATOM_INDEX_HI(i), ATOM_INDEX_LO(i)) < 0) \
< return JS_FALSE; \
< JS_END_MACRO
<
< /*
1724c1824
< * whether optimization occurred, in which case LookupArgOrVar also updated
---
> * whether optimization occurred, in which case BindNameToSlot also updated
1732c1832
< LookupArgOrVar(JSContext *cx, JSTreeContext *tc, JSParseNode *pn)
---
> BindNameToSlot(JSContext *cx, JSTreeContext *tc, JSParseNode *pn)
1733a1834,1837
> JSAtom *atom;
> JSStmtInfo *stmt;
> jsint slot;
> JSOp op;
1738,1741d1841
< JSAtom *atom;
< JSProperty *prop;
< JSScopeProperty *sprop;
< JSOp op;
1744d1843
< jsint slot;
1745a1845,1846
> JSProperty *prop;
> JSScopeProperty *sprop;
1755a1857,1896
> * We can't optimize if we are compiling a with statement and its body,
> * or we're in a catch block whose exception variable has the same name
> * as this node. FIXME: we should be able to optimize catch vars to be
> * block-locals.
> */
> atom = pn->pn_atom;
> stmt = LexicalLookup(cx, tc, atom, &slot);
> if (!stmt)
> return JS_FALSE;
>
> if (stmt != &LL_NOT_FOUND) {
> if (stmt->type == STMT_WITH)
> return JS_TRUE;
> if (stmt->type == STMT_CATCH) {
> JS_ASSERT(stmt->label == atom);
> return JS_TRUE;
> }
>
> JS_ASSERT(stmt->type == STMT_BLOCK_SCOPE);
> JS_ASSERT(slot >= 0);
> op = pn->pn_op;
> switch (op) {
> case JSOP_NAME: op = JSOP_GETLOCAL; break;
> case JSOP_SETNAME: op = JSOP_SETLOCAL; break;
> case JSOP_INCNAME: op = JSOP_INCLOCAL; break;
> case JSOP_NAMEINC: op = JSOP_LOCALINC; break;
> case JSOP_DECNAME: op = JSOP_DECLOCAL; break;
> case JSOP_NAMEDEC: op = JSOP_LOCALDEC; break;
> case JSOP_FORNAME: op = JSOP_FORLOCAL; break;
> case JSOP_DELNAME: op = JSOP_FALSE; break;
> default: JS_ASSERT(0);
> }
> if (op != pn->pn_op) {
> pn->pn_op = op;
> pn->pn_slot = slot;
> }
> return JS_TRUE;
> }
>
> /*
1763c1904,1905
< if (cx->fp->flags & JSFRAME_SCRIPT_OBJECT)
---
> fp = cx->fp;
> if (fp->flags & JSFRAME_SCRIPT_OBJECT)
1778d1919
< fp = cx->fp;
1801,1803c1942
< * We can't optimize if we're in an eval called inside a with statement,
< * or we're compiling a with statement and its body, or we're in a catch
< * block whose exception variable has the same name as pn.
---
> * We can't optimize if we are in an eval called inside a with statement.
1805,1808c1944
< atom = pn->pn_atom;
< if (fp->scopeChain != obj ||
< js_InWithStatement(tc) ||
< js_InCatchBlock(tc, atom)) {
---
> if (fp->scopeChain != obj)
1810d1945
< }
2014c2149
< if (pn2->pn_type == TOK_NAME && !LookupArgOrVar(cx, tc, pn2))
---
> if (pn2->pn_type == TOK_NAME && !BindNameToSlot(cx, tc, pn2))
2044c2179
< if (!LookupArgOrVar(cx, tc, pn))
---
> if (!BindNameToSlot(cx, tc, pn))
2056c2191
< if (pn2->pn_type == TOK_NAME && !LookupArgOrVar(cx, tc, pn2))
---
> if (pn2->pn_type == TOK_NAME && !BindNameToSlot(cx, tc, pn2))
2108c2243
< if (!LookupArgOrVar(cx, &cg->treeContext, pn2))
---
> if (!BindNameToSlot(cx, &cg->treeContext, pn2))
2196c2331
< if (!LookupArgOrVar(cx, &cg->treeContext, left))
---
> if (!BindNameToSlot(cx, &cg->treeContext, left))
2251c2386
< if (!LookupArgOrVar(cx, &cg->treeContext, left))
---
> if (!BindNameToSlot(cx, &cg->treeContext, left))
2789c2924,2927
< ok = js_EmitTree(cx, cg, body) && js_Emit1(cx, cg, JSOP_STOP) >= 0;
---
> ok = (!(cg->treeContext.flags & TCF_FUN_IS_GENERATOR) ||
> js_Emit1(cx, cg, JSOP_GENERATOR) >= 0) &&
> js_EmitTree(cx, cg, body) &&
> js_Emit1(cx, cg, JSOP_STOP) >= 0;
3200c3338
< if (js_Emit1(cx, cg, JSOP_PUSH) < 0)
---
> if (js_Emit1(cx, cg, JSOP_STARTITER) < 0)
3231,3237c3369,3377
< case JSOP_GETARG: /* FALL THROUGH */
< case JSOP_SETARG: op = JSOP_FORARG; break;
< case JSOP_GETVAR: /* FALL THROUGH */
< case JSOP_SETVAR: op = JSOP_FORVAR; break;
< case JSOP_GETGVAR:
< case JSOP_SETGVAR: op = JSOP_FORNAME; break;
< default: JS_ASSERT(0);
---
> case JSOP_GETARG: /* FALL THROUGH */
> case JSOP_SETARG: op = JSOP_FORARG; break;
> case JSOP_GETVAR: /* FALL THROUGH */
> case JSOP_SETVAR: op = JSOP_FORVAR; break;
> case JSOP_GETGVAR: /* FALL THROUGH */
> case JSOP_SETGVAR: op = JSOP_FORNAME; break;
> case JSOP_GETLOCAL: /* FALL THROUGH */
> case JSOP_SETLOCAL: op = JSOP_FORLOCAL; break;
> default: JS_ASSERT(0);
3241c3381
< if (!LookupArgOrVar(cx, &cg->treeContext, pn3))
---
> if (!BindNameToSlot(cx, &cg->treeContext, pn3))
3246c3386,3387
< if (pn3->pn_attrs & JSPROP_READONLY)
---
> if (pn3->pn_attrs & JSPROP_READONLY) {
> JS_ASSERT(op == JSOP_FORVAR);
3247a3389
> }
3432c3574
< /* Now fixup all breaks and continues (before for/in's final POP2). */
---
> /* Now fixup all breaks and continues (before for/in's JSOP_ENDITER). */
3437c3579
< if (js_Emit1(cx, cg, JSOP_POP2) < 0)
---
> if (js_Emit1(cx, cg, JSOP_ENDITER) < 0)
3807c3949
< if (!LookupArgOrVar(cx, &cg->treeContext, pn2))
---
> if (!BindNameToSlot(cx, &cg->treeContext, pn2))
3940a4083,4091
> #if JS_HAS_GENERATORS
> case TOK_YIELD:
> if (!js_EmitTree(cx, cg, pn->pn_kid))
> return JS_FALSE;
> if (js_Emit1(cx, cg, JSOP_YIELD) < 0)
> return JS_FALSE;
> break;
> #endif
>
4067c4218
< if (!LookupArgOrVar(cx, &cg->treeContext, pn2))
---
> if (!BindNameToSlot(cx, &cg->treeContext, pn2))
4372c4523
< if (!LookupArgOrVar(cx, &cg->treeContext, pn2))
---
> if (!BindNameToSlot(cx, &cg->treeContext, pn2))
4447c4598
< if (!LookupArgOrVar(cx, &cg->treeContext, pn2))
---
> if (!BindNameToSlot(cx, &cg->treeContext, pn2))
4575a4727,4772
> #if JS_HAS_BLOCK_SCOPE
> case TOK_LEXICALSCOPE:
> {
> JSObject *obj;
> jsint count;
>
> atom = pn->pn_atom;
> obj = ATOM_TO_OBJECT(atom);
> js_PushBlockScope(&cg->treeContext, &stmtInfo, obj, CG_OFFSET(cg));
>
> OBJ_SET_BLOCK_DEPTH(cx, obj, cg->stackDepth);
> count = OBJ_BLOCK_COUNT(cx, obj);
> cg->stackDepth += count;
> if ((uintN)cg->stackDepth > cg->maxStackDepth)
> cg->maxStackDepth = cg->stackDepth;
>
> ale = js_IndexAtom(cx, atom, &cg->atomList);
> if (!ale)
> return JS_FALSE;
> EMIT_ATOM_INDEX_OP(JSOP_ENTERBLOCK, ALE_INDEX(ale));
>
> if (!js_EmitTree(cx, cg, pn->pn_expr))
> return JS_FALSE;
>
> EMIT_UINT16_IMM_OP(JSOP_LEAVEBLOCK, count);
> cg->stackDepth -= count;
>
> if (!js_PopStatementCG(cx, cg))
> return JS_FALSE;
> break;
> }
> #endif
>
> #if JS_HAS_GENERATORS
> case TOK_ARRAYPUSH:
> /*
> * Pick up the array's stack index from pn->pn_array, which points up
> * the tree to our TOK_ARRAYCOMP ancestor. See below under the array
> * initialiser code generator for array comprehension special casing.
> */
> if (!js_EmitTree(cx, cg, pn->pn_kid))
> return JS_FALSE;
> EMIT_UINT16_IMM_OP(pn->pn_op, pn->pn_array->pn_extra);
> break;
> #endif
>
4576a4774,4776
> #if JS_HAS_GENERATORS
> case TOK_ARRAYCOMP:
> #endif
4599a4800,4818
> #if JS_HAS_GENERATORS
> if (pn->pn_type == TOK_ARRAYCOMP) {
> /*
> * Pass the new array's stack index to the TOK_ARRAYPUSH case by
> * storing it in pn->pn_extra, then simply traverse the TOK_FOR
> * node and its kids under pn2 to generate this comprehension.
> */
> JS_ASSERT(cg->stackDepth > 0);
> pn->pn_extra = (uint32) (cg->stackDepth - 1);
> if (!js_EmitTree(cx, cg, pn2))
> return JS_FALSE;