4 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdc-predef.h" 1 3 4
6 # 1 "././js-confdefs.h" 1
15 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 1 3 4
16 # 26 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 3 4
17 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/features.h" 1 3 4
18 # 365 "/usr/powerpc64-unknown-linux-gnu/usr/include/features.h" 3 4
19 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/cdefs.h" 1 3 4
20 # 410 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/cdefs.h" 3 4
21 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/wordsize.h" 1 3 4
22 # 411 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/cdefs.h" 2 3 4
23 # 366 "/usr/powerpc64-unknown-linux-gnu/usr/include/features.h" 2 3 4
24 # 389 "/usr/powerpc64-unknown-linux-gnu/usr/include/features.h" 3 4
25 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/gnu/stubs.h" 1 3 4
30 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/wordsize.h" 1 3 4
31 # 6 "/usr/powerpc64-unknown-linux-gnu/usr/include/gnu/stubs.h" 2 3 4
37 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/gnu/stubs-64-v1.h" 1 3 4
38 # 12 "/usr/powerpc64-unknown-linux-gnu/usr/include/gnu/stubs.h" 2 3 4
39 # 390 "/usr/powerpc64-unknown-linux-gnu/usr/include/features.h" 2 3 4
40 # 27 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 2 3 4
45 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/math-vector.h" 1 3 4
46 # 27 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/math-vector.h" 3 4
47 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/libm-simd-decl-stubs.h" 1 3 4
48 # 27 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/math-vector.h" 2 3 4
49 # 32 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 2 3 4
53 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/huge_val.h" 1 3 4
54 # 36 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 2 3 4
56 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/huge_valf.h" 1 3 4
57 # 38 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 2 3 4
58 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/huge_vall.h" 1 3 4
59 # 39 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 2 3 4
62 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/inf.h" 1 3 4
63 # 42 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 2 3 4
66 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/nan.h" 1 3 4
67 # 45 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 2 3 4
71 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/mathdef.h" 1 3 4
72 # 33 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/mathdef.h" 3 4
73 typedef float float_t;
74 typedef double double_t;
75 # 49 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 2 3 4
76 # 82 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 3 4
77 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/mathcalls.h" 1 3 4
78 # 52 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/mathcalls.h" 3 4
81 extern double acos (double __x) throw (); extern double __acos (double __x) throw ();
83 extern double asin (double __x) throw (); extern double __asin (double __x) throw ();
85 extern double atan (double __x) throw (); extern double __atan (double __x) throw ();
87 extern double atan2 (double __y, double __x) throw (); extern double __atan2 (double __y, double __x) throw ();
90 extern double cos (double __x) throw (); extern double __cos (double __x) throw ();
92 extern double sin (double __x) throw (); extern double __sin (double __x) throw ();
94 extern double tan (double __x) throw (); extern double __tan (double __x) throw ();
99 extern double cosh (double __x) throw (); extern double __cosh (double __x) throw ();
101 extern double sinh (double __x) throw (); extern double __sinh (double __x) throw ();
103 extern double tanh (double __x) throw (); extern double __tanh (double __x) throw ();
108 extern void sincos (double __x, double *__sinx, double *__cosx) throw (); extern void __sincos (double __x, double *__sinx, double *__cosx) throw ()
115 extern double acosh (double __x) throw (); extern double __acosh (double __x) throw ();
117 extern double asinh (double __x) throw (); extern double __asinh (double __x) throw ();
119 extern double atanh (double __x) throw (); extern double __atanh (double __x) throw ();
127 extern double exp (double __x) throw (); extern double __exp (double __x) throw ();
130 extern double frexp (double __x, int *__exponent) throw (); extern double __frexp (double __x, int *__exponent) throw ();
133 extern double ldexp (double __x, int __exponent) throw (); extern double __ldexp (double __x, int __exponent) throw ();
136 extern double log (double __x) throw (); extern double __log (double __x) throw ();
139 extern double log10 (double __x) throw (); extern double __log10 (double __x) throw ();
142 extern double modf (double __x, double *__iptr) throw (); extern double __modf (double __x, double *__iptr) throw () __attribute__ ((__nonnull__ (2)));
147 extern double exp10 (double __x) throw (); extern double __exp10 (double __x) throw ();
149 extern double pow10 (double __x) throw (); extern double __pow10 (double __x) throw ();
155 extern double expm1 (double __x) throw (); extern double __expm1 (double __x) throw ();
158 extern double log1p (double __x) throw (); extern double __log1p (double __x) throw ();
161 extern double logb (double __x) throw (); extern double __logb (double __x) throw ();
168 extern double exp2 (double __x) throw (); extern double __exp2 (double __x) throw ();
171 extern double log2 (double __x) throw (); extern double __log2 (double __x) throw ();
180 extern double pow (double __x, double __y) throw (); extern double __pow (double __x, double __y) throw ();
183 extern double sqrt (double __x) throw (); extern double __sqrt (double __x) throw ();
189 extern double hypot (double __x, double __y) throw (); extern double __hypot (double __x, double __y) throw ();
196 extern double cbrt (double __x) throw (); extern double __cbrt (double __x) throw ();
205 extern double ceil (double __x) throw () __attribute__ ((__const__)); extern double __ceil (double __x) throw () __attribute__ ((__const__));
208 extern double fabs (double __x) throw () __attribute__ ((__const__)); extern double __fabs (double __x) throw () __attribute__ ((__const__));
211 extern double floor (double __x) throw () __attribute__ ((__const__)); extern double __floor (double __x) throw () __attribute__ ((__const__));
214 extern double fmod (double __x, double __y) throw (); extern double __fmod (double __x, double __y) throw ();
219 extern int __isinf (double __value) throw () __attribute__ ((__const__));
222 extern int __finite (double __value) throw () __attribute__ ((__const__));
228 extern int isinf (double __value) throw () __attribute__ ((__const__));
231 extern int finite (double __value) throw () __attribute__ ((__const__));
234 extern double drem (double __x, double __y) throw (); extern double __drem (double __x, double __y) throw ();
238 extern double significand (double __x) throw (); extern double __significand (double __x) throw ();
244 extern double copysign (double __x, double __y) throw () __attribute__ ((__const__)); extern double __copysign (double __x, double __y) throw () __attribute__ ((__const__));
251 extern double nan (const char *__tagb) throw () __attribute__ ((__const__)); extern double __nan (const char *__tagb) throw () __attribute__ ((__const__));
257 extern int __isnan (double __value) throw () __attribute__ ((__const__));
261 extern int isnan (double __value) throw () __attribute__ ((__const__));
264 extern double j0 (double) throw (); extern double __j0 (double) throw ();
265 extern double j1 (double) throw (); extern double __j1 (double) throw ();
266 extern double jn (int, double) throw (); extern double __jn (int, double) throw ();
267 extern double y0 (double) throw (); extern double __y0 (double) throw ();
268 extern double y1 (double) throw (); extern double __y1 (double) throw ();
269 extern double yn (int, double) throw (); extern double __yn (int, double) throw ();
276 extern double erf (double) throw (); extern double __erf (double) throw ();
277 extern double erfc (double) throw (); extern double __erfc (double) throw ();
278 extern double lgamma (double) throw (); extern double __lgamma (double) throw ();
285 extern double tgamma (double) throw (); extern double __tgamma (double) throw ();
291 extern double gamma (double) throw (); extern double __gamma (double) throw ();
298 extern double lgamma_r (double, int *__signgamp) throw (); extern double __lgamma_r (double, int *__signgamp) throw ();
306 extern double rint (double __x) throw (); extern double __rint (double __x) throw ();
309 extern double nextafter (double __x, double __y) throw () __attribute__ ((__const__)); extern double __nextafter (double __x, double __y) throw () __attribute__ ((__const__));
311 extern double nexttoward (double __x, long double __y) throw () __attribute__ ((__const__)); extern double __nexttoward (double __x, long double __y) throw () __attribute__ ((__const__));
315 extern double remainder (double __x, double __y) throw (); extern double __remainder (double __x, double __y) throw ();
319 extern double scalbn (double __x, int __n) throw (); extern double __scalbn (double __x, int __n) throw ();
323 extern int ilogb (double __x) throw (); extern int __ilogb (double __x) throw ();
328 extern double scalbln (double __x, long int __n) throw (); extern double __scalbln (double __x, long int __n) throw ();
332 extern double nearbyint (double __x) throw (); extern double __nearbyint (double __x) throw ();
336 extern double round (double __x) throw () __attribute__ ((__const__)); extern double __round (double __x) throw () __attribute__ ((__const__));
340 extern double trunc (double __x) throw () __attribute__ ((__const__)); extern double __trunc (double __x) throw () __attribute__ ((__const__));
345 extern double remquo (double __x, double __y, int *__quo) throw (); extern double __remquo (double __x, double __y, int *__quo) throw ();
352 extern long int lrint (double __x) throw (); extern long int __lrint (double __x) throw ();
354 extern long long int llrint (double __x) throw (); extern long long int __llrint (double __x) throw ();
358 extern long int lround (double __x) throw (); extern long int __lround (double __x) throw ();
360 extern long long int llround (double __x) throw (); extern long long int __llround (double __x) throw ();
364 extern double fdim (double __x, double __y) throw (); extern double __fdim (double __x, double __y) throw ();
367 extern double fmax (double __x, double __y) throw () __attribute__ ((__const__)); extern double __fmax (double __x, double __y) throw () __attribute__ ((__const__));
370 extern double fmin (double __x, double __y) throw () __attribute__ ((__const__)); extern double __fmin (double __x, double __y) throw () __attribute__ ((__const__));
374 extern int __fpclassify (double __value) throw ()
375 __attribute__ ((__const__));
378 extern int __signbit (double __value) throw ()
379 __attribute__ ((__const__));
383 extern double fma (double __x, double __y, double __z) throw (); extern double __fma (double __x, double __y, double __z) throw ();
392 extern int __issignaling (double __value) throw ()
393 __attribute__ ((__const__));
398 extern double scalb (double __x, double __n) throw (); extern double __scalb (double __x, double __n) throw ();
399 # 83 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 2 3 4
400 # 101 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 3 4
401 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/mathcalls.h" 1 3 4
402 # 52 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/mathcalls.h" 3 4
405 extern float acosf (float __x) throw (); extern float __acosf (float __x) throw ();
407 extern float asinf (float __x) throw (); extern float __asinf (float __x) throw ();
409 extern float atanf (float __x) throw (); extern float __atanf (float __x) throw ();
411 extern float atan2f (float __y, float __x) throw (); extern float __atan2f (float __y, float __x) throw ();
414 extern float cosf (float __x) throw (); extern float __cosf (float __x) throw ();
416 extern float sinf (float __x) throw (); extern float __sinf (float __x) throw ();
418 extern float tanf (float __x) throw (); extern float __tanf (float __x) throw ();
423 extern float coshf (float __x) throw (); extern float __coshf (float __x) throw ();
425 extern float sinhf (float __x) throw (); extern float __sinhf (float __x) throw ();
427 extern float tanhf (float __x) throw (); extern float __tanhf (float __x) throw ();
432 extern void sincosf (float __x, float *__sinx, float *__cosx) throw (); extern void __sincosf (float __x, float *__sinx, float *__cosx) throw ()
439 extern float acoshf (float __x) throw (); extern float __acoshf (float __x) throw ();
441 extern float asinhf (float __x) throw (); extern float __asinhf (float __x) throw ();
443 extern float atanhf (float __x) throw (); extern float __atanhf (float __x) throw ();
451 extern float expf (float __x) throw (); extern float __expf (float __x) throw ();
454 extern float frexpf (float __x, int *__exponent) throw (); extern float __frexpf (float __x, int *__exponent) throw ();
457 extern float ldexpf (float __x, int __exponent) throw (); extern float __ldexpf (float __x, int __exponent) throw ();
460 extern float logf (float __x) throw (); extern float __logf (float __x) throw ();
463 extern float log10f (float __x) throw (); extern float __log10f (float __x) throw ();
466 extern float modff (float __x, float *__iptr) throw (); extern float __modff (float __x, float *__iptr) throw () __attribute__ ((__nonnull__ (2)));
471 extern float exp10f (float __x) throw (); extern float __exp10f (float __x) throw ();
473 extern float pow10f (float __x) throw (); extern float __pow10f (float __x) throw ();
479 extern float expm1f (float __x) throw (); extern float __expm1f (float __x) throw ();
482 extern float log1pf (float __x) throw (); extern float __log1pf (float __x) throw ();
485 extern float logbf (float __x) throw (); extern float __logbf (float __x) throw ();
492 extern float exp2f (float __x) throw (); extern float __exp2f (float __x) throw ();
495 extern float log2f (float __x) throw (); extern float __log2f (float __x) throw ();
504 extern float powf (float __x, float __y) throw (); extern float __powf (float __x, float __y) throw ();
507 extern float sqrtf (float __x) throw (); extern float __sqrtf (float __x) throw ();
513 extern float hypotf (float __x, float __y) throw (); extern float __hypotf (float __x, float __y) throw ();
520 extern float cbrtf (float __x) throw (); extern float __cbrtf (float __x) throw ();
529 extern float ceilf (float __x) throw () __attribute__ ((__const__)); extern float __ceilf (float __x) throw () __attribute__ ((__const__));
532 extern float fabsf (float __x) throw () __attribute__ ((__const__)); extern float __fabsf (float __x) throw () __attribute__ ((__const__));
535 extern float floorf (float __x) throw () __attribute__ ((__const__)); extern float __floorf (float __x) throw () __attribute__ ((__const__));
538 extern float fmodf (float __x, float __y) throw (); extern float __fmodf (float __x, float __y) throw ();
543 extern int __isinff (float __value) throw () __attribute__ ((__const__));
546 extern int __finitef (float __value) throw () __attribute__ ((__const__));
552 extern int isinff (float __value) throw () __attribute__ ((__const__));
555 extern int finitef (float __value) throw () __attribute__ ((__const__));
558 extern float dremf (float __x, float __y) throw (); extern float __dremf (float __x, float __y) throw ();
562 extern float significandf (float __x) throw (); extern float __significandf (float __x) throw ();
568 extern float copysignf (float __x, float __y) throw () __attribute__ ((__const__)); extern float __copysignf (float __x, float __y) throw () __attribute__ ((__const__));
575 extern float nanf (const char *__tagb) throw () __attribute__ ((__const__)); extern float __nanf (const char *__tagb) throw () __attribute__ ((__const__));
581 extern int __isnanf (float __value) throw () __attribute__ ((__const__));
585 extern int isnanf (float __value) throw () __attribute__ ((__const__));
588 extern float j0f (float) throw (); extern float __j0f (float) throw ();
589 extern float j1f (float) throw (); extern float __j1f (float) throw ();
590 extern float jnf (int, float) throw (); extern float __jnf (int, float) throw ();
591 extern float y0f (float) throw (); extern float __y0f (float) throw ();
592 extern float y1f (float) throw (); extern float __y1f (float) throw ();
593 extern float ynf (int, float) throw (); extern float __ynf (int, float) throw ();
600 extern float erff (float) throw (); extern float __erff (float) throw ();
601 extern float erfcf (float) throw (); extern float __erfcf (float) throw ();
602 extern float lgammaf (float) throw (); extern float __lgammaf (float) throw ();
609 extern float tgammaf (float) throw (); extern float __tgammaf (float) throw ();
615 extern float gammaf (float) throw (); extern float __gammaf (float) throw ();
622 extern float lgammaf_r (float, int *__signgamp) throw (); extern float __lgammaf_r (float, int *__signgamp) throw ();
630 extern float rintf (float __x) throw (); extern float __rintf (float __x) throw ();
633 extern float nextafterf (float __x, float __y) throw () __attribute__ ((__const__)); extern float __nextafterf (float __x, float __y) throw () __attribute__ ((__const__));
635 extern float nexttowardf (float __x, long double __y) throw () __attribute__ ((__const__)); extern float __nexttowardf (float __x, long double __y) throw () __attribute__ ((__const__));
639 extern float remainderf (float __x, float __y) throw (); extern float __remainderf (float __x, float __y) throw ();
643 extern float scalbnf (float __x, int __n) throw (); extern float __scalbnf (float __x, int __n) throw ();
647 extern int ilogbf (float __x) throw (); extern int __ilogbf (float __x) throw ();
652 extern float scalblnf (float __x, long int __n) throw (); extern float __scalblnf (float __x, long int __n) throw ();
656 extern float nearbyintf (float __x) throw (); extern float __nearbyintf (float __x) throw ();
660 extern float roundf (float __x) throw () __attribute__ ((__const__)); extern float __roundf (float __x) throw () __attribute__ ((__const__));
664 extern float truncf (float __x) throw () __attribute__ ((__const__)); extern float __truncf (float __x) throw () __attribute__ ((__const__));
669 extern float remquof (float __x, float __y, int *__quo) throw (); extern float __remquof (float __x, float __y, int *__quo) throw ();
676 extern long int lrintf (float __x) throw (); extern long int __lrintf (float __x) throw ();
678 extern long long int llrintf (float __x) throw (); extern long long int __llrintf (float __x) throw ();
682 extern long int lroundf (float __x) throw (); extern long int __lroundf (float __x) throw ();
684 extern long long int llroundf (float __x) throw (); extern long long int __llroundf (float __x) throw ();
688 extern float fdimf (float __x, float __y) throw (); extern float __fdimf (float __x, float __y) throw ();
691 extern float fmaxf (float __x, float __y) throw () __attribute__ ((__const__)); extern float __fmaxf (float __x, float __y) throw () __attribute__ ((__const__));
694 extern float fminf (float __x, float __y) throw () __attribute__ ((__const__)); extern float __fminf (float __x, float __y) throw () __attribute__ ((__const__));
698 extern int __fpclassifyf (float __value) throw ()
699 __attribute__ ((__const__));
702 extern int __signbitf (float __value) throw ()
703 __attribute__ ((__const__));
707 extern float fmaf (float __x, float __y, float __z) throw (); extern float __fmaf (float __x, float __y, float __z) throw ();
716 extern int __issignalingf (float __value) throw ()
717 __attribute__ ((__const__));
722 extern float scalbf (float __x, float __n) throw (); extern float __scalbf (float __x, float __n) throw ();
723 # 102 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 2 3 4
724 # 146 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 3 4
725 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/mathcalls.h" 1 3 4
726 # 52 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/mathcalls.h" 3 4
729 extern long double acosl (long double __x) throw (); extern long double __acosl (long double __x) throw ();
731 extern long double asinl (long double __x) throw (); extern long double __asinl (long double __x) throw ();
733 extern long double atanl (long double __x) throw (); extern long double __atanl (long double __x) throw ();
735 extern long double atan2l (long double __y, long double __x) throw (); extern long double __atan2l (long double __y, long double __x) throw ();
738 extern long double cosl (long double __x) throw (); extern long double __cosl (long double __x) throw ();
740 extern long double sinl (long double __x) throw (); extern long double __sinl (long double __x) throw ();
742 extern long double tanl (long double __x) throw (); extern long double __tanl (long double __x) throw ();
747 extern long double coshl (long double __x) throw (); extern long double __coshl (long double __x) throw ();
749 extern long double sinhl (long double __x) throw (); extern long double __sinhl (long double __x) throw ();
751 extern long double tanhl (long double __x) throw (); extern long double __tanhl (long double __x) throw ();
756 extern void sincosl (long double __x, long double *__sinx, long double *__cosx) throw (); extern void __sincosl (long double __x, long double *__sinx, long double *__cosx) throw ()
763 extern long double acoshl (long double __x) throw (); extern long double __acoshl (long double __x) throw ();
765 extern long double asinhl (long double __x) throw (); extern long double __asinhl (long double __x) throw ();
767 extern long double atanhl (long double __x) throw (); extern long double __atanhl (long double __x) throw ();
775 extern long double expl (long double __x) throw (); extern long double __expl (long double __x) throw ();
778 extern long double frexpl (long double __x, int *__exponent) throw (); extern long double __frexpl (long double __x, int *__exponent) throw ();
781 extern long double ldexpl (long double __x, int __exponent) throw (); extern long double __ldexpl (long double __x, int __exponent) throw ();
784 extern long double logl (long double __x) throw (); extern long double __logl (long double __x) throw ();
787 extern long double log10l (long double __x) throw (); extern long double __log10l (long double __x) throw ();
790 extern long double modfl (long double __x, long double *__iptr) throw (); extern long double __modfl (long double __x, long double *__iptr) throw () __attribute__ ((__nonnull__ (2)));
795 extern long double exp10l (long double __x) throw (); extern long double __exp10l (long double __x) throw ();
797 extern long double pow10l (long double __x) throw (); extern long double __pow10l (long double __x) throw ();
803 extern long double expm1l (long double __x) throw (); extern long double __expm1l (long double __x) throw ();
806 extern long double log1pl (long double __x) throw (); extern long double __log1pl (long double __x) throw ();
809 extern long double logbl (long double __x) throw (); extern long double __logbl (long double __x) throw ();
816 extern long double exp2l (long double __x) throw (); extern long double __exp2l (long double __x) throw ();
819 extern long double log2l (long double __x) throw (); extern long double __log2l (long double __x) throw ();
828 extern long double powl (long double __x, long double __y) throw (); extern long double __powl (long double __x, long double __y) throw ();
831 extern long double sqrtl (long double __x) throw (); extern long double __sqrtl (long double __x) throw ();
837 extern long double hypotl (long double __x, long double __y) throw (); extern long double __hypotl (long double __x, long double __y) throw ();
844 extern long double cbrtl (long double __x) throw (); extern long double __cbrtl (long double __x) throw ();
853 extern long double ceill (long double __x) throw () __attribute__ ((__const__)); extern long double __ceill (long double __x) throw () __attribute__ ((__const__));
856 extern long double fabsl (long double __x) throw () __attribute__ ((__const__)); extern long double __fabsl (long double __x) throw () __attribute__ ((__const__));
859 extern long double floorl (long double __x) throw () __attribute__ ((__const__)); extern long double __floorl (long double __x) throw () __attribute__ ((__const__));
862 extern long double fmodl (long double __x, long double __y) throw (); extern long double __fmodl (long double __x, long double __y) throw ();
867 extern int __isinfl (long double __value) throw () __attribute__ ((__const__));
870 extern int __finitel (long double __value) throw () __attribute__ ((__const__));
876 extern int isinfl (long double __value) throw () __attribute__ ((__const__));
879 extern int finitel (long double __value) throw () __attribute__ ((__const__));
882 extern long double dreml (long double __x, long double __y) throw (); extern long double __dreml (long double __x, long double __y) throw ();
886 extern long double significandl (long double __x) throw (); extern long double __significandl (long double __x) throw ();
892 extern long double copysignl (long double __x, long double __y) throw () __attribute__ ((__const__)); extern long double __copysignl (long double __x, long double __y) throw () __attribute__ ((__const__));
899 extern long double nanl (const char *__tagb) throw () __attribute__ ((__const__)); extern long double __nanl (const char *__tagb) throw () __attribute__ ((__const__));
905 extern int __isnanl (long double __value) throw () __attribute__ ((__const__));
909 extern int isnanl (long double __value) throw () __attribute__ ((__const__));
912 extern long double j0l (long double) throw (); extern long double __j0l (long double) throw ();
913 extern long double j1l (long double) throw (); extern long double __j1l (long double) throw ();
914 extern long double jnl (int, long double) throw (); extern long double __jnl (int, long double) throw ();
915 extern long double y0l (long double) throw (); extern long double __y0l (long double) throw ();
916 extern long double y1l (long double) throw (); extern long double __y1l (long double) throw ();
917 extern long double ynl (int, long double) throw (); extern long double __ynl (int, long double) throw ();
924 extern long double erfl (long double) throw (); extern long double __erfl (long double) throw ();
925 extern long double erfcl (long double) throw (); extern long double __erfcl (long double) throw ();
926 extern long double lgammal (long double) throw (); extern long double __lgammal (long double) throw ();
933 extern long double tgammal (long double) throw (); extern long double __tgammal (long double) throw ();
939 extern long double gammal (long double) throw (); extern long double __gammal (long double) throw ();
946 extern long double lgammal_r (long double, int *__signgamp) throw (); extern long double __lgammal_r (long double, int *__signgamp) throw ();
954 extern long double rintl (long double __x) throw (); extern long double __rintl (long double __x) throw ();
957 extern long double nextafterl (long double __x, long double __y) throw () __attribute__ ((__const__)); extern long double __nextafterl (long double __x, long double __y) throw () __attribute__ ((__const__));
959 extern long double nexttowardl (long double __x, long double __y) throw () __attribute__ ((__const__)); extern long double __nexttowardl (long double __x, long double __y) throw () __attribute__ ((__const__));
963 extern long double remainderl (long double __x, long double __y) throw (); extern long double __remainderl (long double __x, long double __y) throw ();
967 extern long double scalbnl (long double __x, int __n) throw (); extern long double __scalbnl (long double __x, int __n) throw ();
971 extern int ilogbl (long double __x) throw (); extern int __ilogbl (long double __x) throw ();
976 extern long double scalblnl (long double __x, long int __n) throw (); extern long double __scalblnl (long double __x, long int __n) throw ();
980 extern long double nearbyintl (long double __x) throw (); extern long double __nearbyintl (long double __x) throw ();
984 extern long double roundl (long double __x) throw () __attribute__ ((__const__)); extern long double __roundl (long double __x) throw () __attribute__ ((__const__));
988 extern long double truncl (long double __x) throw () __attribute__ ((__const__)); extern long double __truncl (long double __x) throw () __attribute__ ((__const__));
993 extern long double remquol (long double __x, long double __y, int *__quo) throw (); extern long double __remquol (long double __x, long double __y, int *__quo) throw ();
1000 extern long int lrintl (long double __x) throw (); extern long int __lrintl (long double __x) throw ();
1002 extern long long int llrintl (long double __x) throw (); extern long long int __llrintl (long double __x) throw ();
1006 extern long int lroundl (long double __x) throw (); extern long int __lroundl (long double __x) throw ();
1008 extern long long int llroundl (long double __x) throw (); extern long long int __llroundl (long double __x) throw ();
1012 extern long double fdiml (long double __x, long double __y) throw (); extern long double __fdiml (long double __x, long double __y) throw ();
1015 extern long double fmaxl (long double __x, long double __y) throw () __attribute__ ((__const__)); extern long double __fmaxl (long double __x, long double __y) throw () __attribute__ ((__const__));
1018 extern long double fminl (long double __x, long double __y) throw () __attribute__ ((__const__)); extern long double __fminl (long double __x, long double __y) throw () __attribute__ ((__const__));
1022 extern int __fpclassifyl (long double __value) throw ()
1023 __attribute__ ((__const__));
1026 extern int __signbitl (long double __value) throw ()
1027 __attribute__ ((__const__));
1031 extern long double fmal (long double __x, long double __y, long double __z) throw (); extern long double __fmal (long double __x, long double __y, long double __z) throw ();
1040 extern int __issignalingl (long double __value) throw ()
1041 __attribute__ ((__const__));
1046 extern long double scalbl (long double __x, long double __n) throw (); extern long double __scalbl (long double __x, long double __n) throw ();
1047 # 147 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 2 3 4
1048 # 162 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 3 4
1050 # 203 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 3 4
1069 # 315 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 3 4
1077 } _LIB_VERSION_TYPE;
1082 extern _LIB_VERSION_TYPE _LIB_VERSION;
1083 # 338 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 3 4
1097 extern int matherr (struct __exception *__exc) throw ();
1098 # 440 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 3 4
1099 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/mathinline.h" 1 3 4
1100 # 61 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/mathinline.h" 3 4
1101 extern __inline __attribute__ ((__gnu_inline__)) int
1102 __attribute__ ((__leaf__)) __signbitf (float __x) throw ()
1105 return __builtin_signbitf (__x);
1111 extern __inline __attribute__ ((__gnu_inline__)) int
1112 __attribute__ ((__leaf__)) __signbit (double __x) throw ()
1115 return __builtin_signbit (__x);
1122 extern __inline __attribute__ ((__gnu_inline__)) int
1123 __attribute__ ((__leaf__)) __signbitl (long double __x) throw ()
1125 return __signbit ((double) __x);
1127 # 116 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/mathinline.h" 3 4
1128 extern __inline __attribute__ ((__gnu_inline__)) double fdim (double __x, double __y) throw ();
1129 extern __inline __attribute__ ((__gnu_inline__)) double
1130 __attribute__ ((__leaf__)) fdim (double __x, double __y) throw ()
1132 return __x <= __y ? 0 : __x - __y;
1135 extern __inline __attribute__ ((__gnu_inline__)) float fdimf (float __x, float __y) throw ();
1136 extern __inline __attribute__ ((__gnu_inline__)) float
1137 __attribute__ ((__leaf__)) fdimf (float __x, float __y) throw ()
1139 return __x <= __y ? 0 : __x - __y;
1141 # 441 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 2 3 4
1142 # 502 "/usr/powerpc64-unknown-linux-gnu/usr/include/math.h" 3 4
1145 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 1 3 4
1146 # 32 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4
1147 # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4
1148 # 212 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 3 4
1149 typedef long unsigned int size_t;
1150 # 33 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 2 3 4
1159 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/waitflags.h" 1 3 4
1160 # 42 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 2 3 4
1161 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/waitstatus.h" 1 3 4
1162 # 64 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/waitstatus.h" 3 4
1163 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/endian.h" 1 3 4
1164 # 36 "/usr/powerpc64-unknown-linux-gnu/usr/include/endian.h" 3 4
1165 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/endian.h" 1 3 4
1166 # 37 "/usr/powerpc64-unknown-linux-gnu/usr/include/endian.h" 2 3 4
1167 # 60 "/usr/powerpc64-unknown-linux-gnu/usr/include/endian.h" 3 4
1168 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/byteswap.h" 1 3 4
1169 # 27 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/byteswap.h" 3 4
1170 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/types.h" 1 3 4
1171 # 27 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/types.h" 3 4
1172 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/wordsize.h" 1 3 4
1173 # 28 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/types.h" 2 3 4
1176 typedef unsigned char __u_char;
1177 typedef unsigned short int __u_short;
1178 typedef unsigned int __u_int;
1179 typedef unsigned long int __u_long;
1182 typedef signed char __int8_t;
1183 typedef unsigned char __uint8_t;
1184 typedef signed short int __int16_t;
1185 typedef unsigned short int __uint16_t;
1186 typedef signed int __int32_t;
1187 typedef unsigned int __uint32_t;
1189 typedef signed long int __int64_t;
1190 typedef unsigned long int __uint64_t;
1198 typedef long int __quad_t;
1199 typedef unsigned long int __u_quad_t;
1200 # 121 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/types.h" 3 4
1201 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/typesizes.h" 1 3 4
1202 # 122 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/types.h" 2 3 4
1205 typedef unsigned long int __dev_t;
1206 typedef unsigned int __uid_t;
1207 typedef unsigned int __gid_t;
1208 typedef unsigned long int __ino_t;
1209 typedef unsigned long int __ino64_t;
1210 typedef unsigned int __mode_t;
1211 typedef unsigned long int __nlink_t;
1212 typedef long int __off_t;
1213 typedef long int __off64_t;
1214 typedef int __pid_t;
1215 typedef struct { int __val[2]; } __fsid_t;
1216 typedef long int __clock_t;
1217 typedef unsigned long int __rlim_t;
1218 typedef unsigned long int __rlim64_t;
1219 typedef unsigned int __id_t;
1220 typedef long int __time_t;
1221 typedef unsigned int __useconds_t;
1222 typedef long int __suseconds_t;
1224 typedef int __daddr_t;
1225 typedef int __key_t;
1228 typedef int __clockid_t;
1231 typedef void * __timer_t;
1234 typedef long int __blksize_t;
1239 typedef long int __blkcnt_t;
1240 typedef long int __blkcnt64_t;
1243 typedef unsigned long int __fsblkcnt_t;
1244 typedef unsigned long int __fsblkcnt64_t;
1247 typedef unsigned long int __fsfilcnt_t;
1248 typedef unsigned long int __fsfilcnt64_t;
1251 typedef long int __fsword_t;
1253 typedef long int __ssize_t;
1256 typedef long int __syscall_slong_t;
1258 typedef unsigned long int __syscall_ulong_t;
1262 typedef __off64_t __loff_t;
1263 typedef __quad_t *__qaddr_t;
1264 typedef char *__caddr_t;
1267 typedef long int __intptr_t;
1270 typedef unsigned int __socklen_t;
1271 # 28 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/byteswap.h" 2 3 4
1278 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/byteswap-16.h" 1 3 4
1279 # 35 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/byteswap.h" 2 3 4
1280 # 43 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/byteswap.h" 3 4
1281 static __inline unsigned int
1282 __bswap_32 (unsigned int __bsx)
1284 return __builtin_bswap32 (__bsx);
1286 # 74 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/byteswap.h" 3 4
1287 static __inline __uint64_t
1288 __bswap_64 (__uint64_t __bsx)
1290 return __builtin_bswap64 (__bsx);
1292 # 61 "/usr/powerpc64-unknown-linux-gnu/usr/include/endian.h" 2 3 4
1293 # 65 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/waitstatus.h" 2 3 4
1308 unsigned int __w_retcode:8;
1309 unsigned int __w_coredump:1;
1310 unsigned int __w_termsig:7;
1312 } __wait_terminated;
1322 unsigned int __w_stopsig:8;
1323 unsigned int __w_stopval:8;
1327 # 43 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 2 3 4
1328 # 95 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4
1351 __extension__ typedef struct
1358 # 139 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4
1359 extern size_t __ctype_get_mb_cur_max (void) throw () __attribute__ ((__warn_unused_result__));
1364 extern double atof (const char *__nptr)
1365 throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1367 extern int atoi (const char *__nptr)
1368 throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1370 extern long int atol (const char *__nptr)
1371 throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1377 __extension__ extern long long int atoll (const char *__nptr)
1378 throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1384 extern double strtod (const char *__restrict __nptr,
1385 char **__restrict __endptr)
1386 throw () __attribute__ ((__nonnull__ (1)));
1392 extern float strtof (const char *__restrict __nptr,
1393 char **__restrict __endptr) throw () __attribute__ ((__nonnull__ (1)));
1395 extern long double strtold (const char *__restrict __nptr,
1396 char **__restrict __endptr)
1397 throw () __attribute__ ((__nonnull__ (1)));
1403 extern long int strtol (const char *__restrict __nptr,
1404 char **__restrict __endptr, int __base)
1405 throw () __attribute__ ((__nonnull__ (1)));
1407 extern unsigned long int strtoul (const char *__restrict __nptr,
1408 char **__restrict __endptr, int __base)
1409 throw () __attribute__ ((__nonnull__ (1)));
1415 extern long long int strtoq (const char *__restrict __nptr,
1416 char **__restrict __endptr, int __base)
1417 throw () __attribute__ ((__nonnull__ (1)));
1420 extern unsigned long long int strtouq (const char *__restrict __nptr,
1421 char **__restrict __endptr, int __base)
1422 throw () __attribute__ ((__nonnull__ (1)));
1429 extern long long int strtoll (const char *__restrict __nptr,
1430 char **__restrict __endptr, int __base)
1431 throw () __attribute__ ((__nonnull__ (1)));
1434 extern unsigned long long int strtoull (const char *__restrict __nptr,
1435 char **__restrict __endptr, int __base)
1436 throw () __attribute__ ((__nonnull__ (1)));
1438 # 235 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4
1439 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/xlocale.h" 1 3 4
1440 # 27 "/usr/powerpc64-unknown-linux-gnu/usr/include/xlocale.h" 3 4
1441 typedef struct __locale_struct
1444 struct __locale_data *__locales[13];
1447 const unsigned short int *__ctype_b;
1448 const int *__ctype_tolower;
1449 const int *__ctype_toupper;
1452 const char *__names[13];
1456 typedef __locale_t locale_t;
1457 # 236 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 2 3 4
1461 extern long int strtol_l (const char *__restrict __nptr,
1462 char **__restrict __endptr, int __base,
1463 __locale_t __loc) throw () __attribute__ ((__nonnull__ (1, 4)));
1465 extern unsigned long int strtoul_l (const char *__restrict __nptr,
1466 char **__restrict __endptr,
1467 int __base, __locale_t __loc)
1468 throw () __attribute__ ((__nonnull__ (1, 4)));
1471 extern long long int strtoll_l (const char *__restrict __nptr,
1472 char **__restrict __endptr, int __base,
1474 throw () __attribute__ ((__nonnull__ (1, 4)));
1477 extern unsigned long long int strtoull_l (const char *__restrict __nptr,
1478 char **__restrict __endptr,
1479 int __base, __locale_t __loc)
1480 throw () __attribute__ ((__nonnull__ (1, 4)));
1482 extern double strtod_l (const char *__restrict __nptr,
1483 char **__restrict __endptr, __locale_t __loc)
1484 throw () __attribute__ ((__nonnull__ (1, 3)));
1486 extern float strtof_l (const char *__restrict __nptr,
1487 char **__restrict __endptr, __locale_t __loc)
1488 throw () __attribute__ ((__nonnull__ (1, 3)));
1490 extern long double strtold_l (const char *__restrict __nptr,
1491 char **__restrict __endptr,
1493 throw () __attribute__ ((__nonnull__ (1, 3)));
1499 extern __inline __attribute__ ((__gnu_inline__)) int
1500 __attribute__ ((__leaf__)) atoi (const char *__nptr) throw ()
1502 return (int) strtol (__nptr, (char **) __null, 10);
1504 extern __inline __attribute__ ((__gnu_inline__)) long int
1505 __attribute__ ((__leaf__)) atol (const char *__nptr) throw ()
1507 return strtol (__nptr, (char **) __null, 10);
1513 __extension__ extern __inline __attribute__ ((__gnu_inline__)) long long int
1514 __attribute__ ((__leaf__)) atoll (const char *__nptr) throw ()
1516 return strtoll (__nptr, (char **) __null, 10);
1519 # 305 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4
1520 extern char *l64a (long int __n) throw () __attribute__ ((__warn_unused_result__));
1523 extern long int a64l (const char *__s)
1524 throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
1529 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/types.h" 1 3 4
1530 # 27 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/types.h" 3 4
1537 typedef __u_char u_char;
1538 typedef __u_short u_short;
1539 typedef __u_int u_int;
1540 typedef __u_long u_long;
1541 typedef __quad_t quad_t;
1542 typedef __u_quad_t u_quad_t;
1543 typedef __fsid_t fsid_t;
1548 typedef __loff_t loff_t;
1552 typedef __ino_t ino_t;
1559 typedef __ino64_t ino64_t;
1564 typedef __dev_t dev_t;
1569 typedef __gid_t gid_t;
1574 typedef __mode_t mode_t;
1579 typedef __nlink_t nlink_t;
1584 typedef __uid_t uid_t;
1590 typedef __off_t off_t;
1597 typedef __off64_t off64_t;
1602 typedef __pid_t pid_t;
1608 typedef __id_t id_t;
1613 typedef __ssize_t ssize_t;
1619 typedef __daddr_t daddr_t;
1620 typedef __caddr_t caddr_t;
1626 typedef __key_t key_t;
1627 # 132 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/types.h" 3 4
1628 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 1 3 4
1629 # 57 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 3 4
1632 typedef __clock_t clock_t;
1636 # 73 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 3 4
1639 typedef __time_t time_t;
1643 # 91 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 3 4
1644 typedef __clockid_t clockid_t;
1645 # 103 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 3 4
1646 typedef __timer_t timer_t;
1647 # 133 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/types.h" 2 3 4
1651 typedef __useconds_t useconds_t;
1655 typedef __suseconds_t suseconds_t;
1661 # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4
1662 # 147 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/types.h" 2 3 4
1666 typedef unsigned long int ulong;
1667 typedef unsigned short int ushort;
1668 typedef unsigned int uint;
1669 # 194 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/types.h" 3 4
1670 typedef int int8_t __attribute__ ((__mode__ (__QI__)));
1671 typedef int int16_t __attribute__ ((__mode__ (__HI__)));
1672 typedef int int32_t __attribute__ ((__mode__ (__SI__)));
1673 typedef int int64_t __attribute__ ((__mode__ (__DI__)));
1676 typedef unsigned int u_int8_t __attribute__ ((__mode__ (__QI__)));
1677 typedef unsigned int u_int16_t __attribute__ ((__mode__ (__HI__)));
1678 typedef unsigned int u_int32_t __attribute__ ((__mode__ (__SI__)));
1679 typedef unsigned int u_int64_t __attribute__ ((__mode__ (__DI__)));
1681 typedef int register_t __attribute__ ((__mode__ (__word__)));
1682 # 219 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/types.h" 3 4
1683 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/select.h" 1 3 4
1684 # 30 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/select.h" 3 4
1685 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/select.h" 1 3 4
1686 # 31 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/select.h" 2 3 4
1689 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/sigset.h" 1 3 4
1690 # 22 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/sigset.h" 3 4
1691 typedef int __sig_atomic_t;
1698 unsigned long int __val[(1024 / (8 * sizeof (unsigned long int)))];
1700 # 34 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/select.h" 2 3 4
1704 typedef __sigset_t sigset_t;
1710 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 1 3 4
1711 # 120 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 3 4
1715 __syscall_slong_t tv_nsec;
1717 # 44 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/select.h" 2 3 4
1719 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/time.h" 1 3 4
1720 # 30 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/time.h" 3 4
1724 __suseconds_t tv_usec;
1726 # 46 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/select.h" 2 3 4
1727 # 54 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/select.h" 3 4
1728 typedef long int __fd_mask;
1729 # 64 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/select.h" 3 4
1735 __fd_mask fds_bits[1024 / (8 * (int) sizeof (__fd_mask))];
1748 typedef __fd_mask fd_mask;
1749 # 96 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/select.h" 3 4
1751 # 106 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/select.h" 3 4
1752 extern int select (int __nfds, fd_set *__restrict __readfds,
1753 fd_set *__restrict __writefds,
1754 fd_set *__restrict __exceptfds,
1755 struct timeval *__restrict __timeout);
1756 # 118 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/select.h" 3 4
1757 extern int pselect (int __nfds, fd_set *__restrict __readfds,
1758 fd_set *__restrict __writefds,
1759 fd_set *__restrict __exceptfds,
1760 const struct timespec *__restrict __timeout,
1761 const __sigset_t *__restrict __sigmask);
1767 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/select2.h" 1 3 4
1768 # 24 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/select2.h" 3 4
1769 extern long int __fdelt_chk (long int __d);
1770 extern long int __fdelt_warn (long int __d)
1771 __attribute__((__warning__ ("bit outside of fd_set selected")));
1772 # 129 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/select.h" 2 3 4
1776 # 220 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/types.h" 2 3 4
1779 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/sysmacros.h" 1 3 4
1780 # 24 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/sysmacros.h" 3 4
1784 extern unsigned int gnu_dev_major (unsigned long long int __dev)
1785 throw () __attribute__ ((__const__));
1787 extern unsigned int gnu_dev_minor (unsigned long long int __dev)
1788 throw () __attribute__ ((__const__));
1790 extern unsigned long long int gnu_dev_makedev (unsigned int __major,
1791 unsigned int __minor)
1792 throw () __attribute__ ((__const__));
1795 __extension__ extern __inline __attribute__ ((__gnu_inline__)) __attribute__ ((__const__)) unsigned int
1796 __attribute__ ((__leaf__)) gnu_dev_major (unsigned long long int __dev) throw ()
1798 return ((__dev >> 8) & 0xfff) | ((unsigned int) (__dev >> 32) & ~0xfff);
1801 __extension__ extern __inline __attribute__ ((__gnu_inline__)) __attribute__ ((__const__)) unsigned int
1802 __attribute__ ((__leaf__)) gnu_dev_minor (unsigned long long int __dev) throw ()
1804 return (__dev & 0xff) | ((unsigned int) (__dev >> 12) & ~0xff);
1807 __extension__ extern __inline __attribute__ ((__gnu_inline__)) __attribute__ ((__const__)) unsigned long long int
1808 __attribute__ ((__leaf__)) gnu_dev_makedev (unsigned int __major, unsigned int __minor) throw ()
1810 return ((__minor & 0xff) | ((__major & 0xfff) << 8)
1811 | (((unsigned long long int) (__minor & ~0xff)) << 12)
1812 | (((unsigned long long int) (__major & ~0xfff)) << 32));
1816 # 223 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/types.h" 2 3 4
1822 typedef __blksize_t blksize_t;
1829 typedef __blkcnt_t blkcnt_t;
1833 typedef __fsblkcnt_t fsblkcnt_t;
1837 typedef __fsfilcnt_t fsfilcnt_t;
1838 # 262 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/types.h" 3 4
1839 typedef __blkcnt64_t blkcnt64_t;
1840 typedef __fsblkcnt64_t fsblkcnt64_t;
1841 typedef __fsfilcnt64_t fsfilcnt64_t;
1847 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/pthreadtypes.h" 1 3 4
1848 # 22 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/pthreadtypes.h" 3 4
1849 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/wordsize.h" 1 3 4
1850 # 23 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/pthreadtypes.h" 2 3 4
1851 # 49 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/pthreadtypes.h" 3 4
1852 typedef unsigned long int pthread_t;
1855 union pthread_attr_t
1861 typedef union pthread_attr_t pthread_attr_t;
1867 typedef struct __pthread_internal_list
1869 struct __pthread_internal_list *__prev;
1870 struct __pthread_internal_list *__next;
1872 # 79 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/pthreadtypes.h" 3 4
1875 struct __pthread_mutex_s
1878 unsigned int __count;
1881 unsigned int __nusers;
1889 __pthread_list_t __list;
1890 # 113 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/pthreadtypes.h" 3 4
1900 } pthread_mutexattr_t;
1910 unsigned int __futex;
1911 __extension__ unsigned long long int __total_seq;
1912 __extension__ unsigned long long int __wakeup_seq;
1913 __extension__ unsigned long long int __woken_seq;
1915 unsigned int __nwaiters;
1916 unsigned int __broadcast_seq;
1919 __extension__ long long int __align;
1926 } pthread_condattr_t;
1930 typedef unsigned int pthread_key_t;
1934 typedef int pthread_once_t;
1946 unsigned int __nr_readers;
1947 unsigned int __readers_wakeup;
1948 unsigned int __writer_wakeup;
1949 unsigned int __nr_readers_queued;
1950 unsigned int __nr_writers_queued;
1953 unsigned char __rwelision;
1954 unsigned char __pad1[7];
1955 unsigned long int __pad2;
1958 unsigned int __flags;
1961 # 202 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/pthreadtypes.h" 3 4
1971 } pthread_rwlockattr_t;
1977 typedef volatile int pthread_spinlock_t;
1986 } pthread_barrier_t;
1992 } pthread_barrierattr_t;
1993 # 271 "/usr/powerpc64-unknown-linux-gnu/usr/include/sys/types.h" 2 3 4
1997 # 315 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 2 3 4
2004 extern long int random (void) throw ();
2007 extern void srandom (unsigned int __seed) throw ();
2013 extern char *initstate (unsigned int __seed, char *__statebuf,
2014 size_t __statelen) throw () __attribute__ ((__nonnull__ (2)));
2018 extern char *setstate (char *__statebuf) throw () __attribute__ ((__nonnull__ (1)));
2037 extern int random_r (struct random_data *__restrict __buf,
2038 int32_t *__restrict __result) throw () __attribute__ ((__nonnull__ (1, 2)));
2040 extern int srandom_r (unsigned int __seed, struct random_data *__buf)
2041 throw () __attribute__ ((__nonnull__ (2)));
2043 extern int initstate_r (unsigned int __seed, char *__restrict __statebuf,
2045 struct random_data *__restrict __buf)
2046 throw () __attribute__ ((__nonnull__ (2, 4)));
2048 extern int setstate_r (char *__restrict __statebuf,
2049 struct random_data *__restrict __buf)
2050 throw () __attribute__ ((__nonnull__ (1, 2)));
2057 extern int rand (void) throw ();
2059 extern void srand (unsigned int __seed) throw ();
2064 extern int rand_r (unsigned int *__seed) throw ();
2072 extern double drand48 (void) throw ();
2073 extern double erand48 (unsigned short int __xsubi[3]) throw () __attribute__ ((__nonnull__ (1)));
2076 extern long int lrand48 (void) throw ();
2077 extern long int nrand48 (unsigned short int __xsubi[3])
2078 throw () __attribute__ ((__nonnull__ (1)));
2081 extern long int mrand48 (void) throw ();
2082 extern long int jrand48 (unsigned short int __xsubi[3])
2083 throw () __attribute__ ((__nonnull__ (1)));
2086 extern void srand48 (long int __seedval) throw ();
2087 extern unsigned short int *seed48 (unsigned short int __seed16v[3])
2088 throw () __attribute__ ((__nonnull__ (1)));
2089 extern void lcong48 (unsigned short int __param[7]) throw () __attribute__ ((__nonnull__ (1)));
2097 unsigned short int __x[3];
2098 unsigned short int __old_x[3];
2099 unsigned short int __c;
2100 unsigned short int __init;
2101 __extension__ unsigned long long int __a;
2106 extern int drand48_r (struct drand48_data *__restrict __buffer,
2107 double *__restrict __result) throw () __attribute__ ((__nonnull__ (1, 2)));
2108 extern int erand48_r (unsigned short int __xsubi[3],
2109 struct drand48_data *__restrict __buffer,
2110 double *__restrict __result) throw () __attribute__ ((__nonnull__ (1, 2)));
2113 extern int lrand48_r (struct drand48_data *__restrict __buffer,
2114 long int *__restrict __result)
2115 throw () __attribute__ ((__nonnull__ (1, 2)));
2116 extern int nrand48_r (unsigned short int __xsubi[3],
2117 struct drand48_data *__restrict __buffer,
2118 long int *__restrict __result)
2119 throw () __attribute__ ((__nonnull__ (1, 2)));
2122 extern int mrand48_r (struct drand48_data *__restrict __buffer,
2123 long int *__restrict __result)
2124 throw () __attribute__ ((__nonnull__ (1, 2)));
2125 extern int jrand48_r (unsigned short int __xsubi[3],
2126 struct drand48_data *__restrict __buffer,
2127 long int *__restrict __result)
2128 throw () __attribute__ ((__nonnull__ (1, 2)));
2131 extern int srand48_r (long int __seedval, struct drand48_data *__buffer)
2132 throw () __attribute__ ((__nonnull__ (2)));
2134 extern int seed48_r (unsigned short int __seed16v[3],
2135 struct drand48_data *__buffer) throw () __attribute__ ((__nonnull__ (1, 2)));
2137 extern int lcong48_r (unsigned short int __param[7],
2138 struct drand48_data *__buffer)
2139 throw () __attribute__ ((__nonnull__ (1, 2)));
2149 extern void *malloc (size_t __size) throw () __attribute__ ((__malloc__)) __attribute__ ((__warn_unused_result__));
2151 extern void *calloc (size_t __nmemb, size_t __size)
2152 throw () __attribute__ ((__malloc__)) __attribute__ ((__warn_unused_result__));
2163 extern void *realloc (void *__ptr, size_t __size)
2164 throw () __attribute__ ((__warn_unused_result__));
2166 extern void free (void *__ptr) throw ();
2171 extern void cfree (void *__ptr) throw ();
2175 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/alloca.h" 1 3 4
2176 # 24 "/usr/powerpc64-unknown-linux-gnu/usr/include/alloca.h" 3 4
2177 # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4
2178 # 25 "/usr/powerpc64-unknown-linux-gnu/usr/include/alloca.h" 2 3 4
2186 extern void *alloca (size_t __size) throw ();
2193 # 493 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 2 3 4
2199 extern void *valloc (size_t __size) throw () __attribute__ ((__malloc__)) __attribute__ ((__warn_unused_result__));
2204 extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size)
2205 throw () __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
2210 extern void *aligned_alloc (size_t __alignment, size_t __size)
2211 throw () __attribute__ ((__malloc__)) __attribute__ ((__alloc_size__ (2))) __attribute__ ((__warn_unused_result__));
2216 extern void abort (void) throw () __attribute__ ((__noreturn__));
2220 extern int atexit (void (*__func) (void)) throw () __attribute__ ((__nonnull__ (1)));
2225 extern "C++" int at_quick_exit (void (*__func) (void))
2226 throw () __asm ("at_quick_exit") __attribute__ ((__nonnull__ (1)));
2236 extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg)
2237 throw () __attribute__ ((__nonnull__ (1)));
2244 extern void exit (int __status) throw () __attribute__ ((__noreturn__));
2250 extern void quick_exit (int __status) throw () __attribute__ ((__noreturn__));
2258 extern void _Exit (int __status) throw () __attribute__ ((__noreturn__));
2265 extern char *getenv (const char *__name) throw () __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
2271 extern char *secure_getenv (const char *__name)
2272 throw () __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
2279 extern int putenv (char *__string) throw () __attribute__ ((__nonnull__ (1)));
2285 extern int setenv (const char *__name, const char *__value, int __replace)
2286 throw () __attribute__ ((__nonnull__ (2)));
2289 extern int unsetenv (const char *__name) throw () __attribute__ ((__nonnull__ (1)));
2296 extern int clearenv (void) throw ();
2297 # 606 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4
2298 extern char *mktemp (char *__template) throw () __attribute__ ((__nonnull__ (1)));
2299 # 619 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4
2300 extern int mkstemp (char *__template) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
2301 # 629 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4
2302 extern int mkstemp64 (char *__template) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
2303 # 641 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4
2304 extern int mkstemps (char *__template, int __suffixlen) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
2305 # 651 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4
2306 extern int mkstemps64 (char *__template, int __suffixlen)
2307 __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
2308 # 662 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4
2309 extern char *mkdtemp (char *__template) throw () __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
2310 # 673 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4
2311 extern int mkostemp (char *__template, int __flags) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
2312 # 683 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4
2313 extern int mkostemp64 (char *__template, int __flags) __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
2314 # 693 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4
2315 extern int mkostemps (char *__template, int __suffixlen, int __flags)
2316 __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
2317 # 705 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4
2318 extern int mkostemps64 (char *__template, int __suffixlen, int __flags)
2319 __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
2329 extern int system (const char *__command) __attribute__ ((__warn_unused_result__));
2336 extern char *canonicalize_file_name (const char *__name)
2337 throw () __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
2338 # 733 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4
2339 extern char *realpath (const char *__restrict __name,
2340 char *__restrict __resolved) throw () __attribute__ ((__warn_unused_result__));
2347 typedef int (*__compar_fn_t) (const void *, const void *);
2350 typedef __compar_fn_t comparison_fn_t;
2354 typedef int (*__compar_d_fn_t) (const void *, const void *, void *);
2360 extern void *bsearch (const void *__key, const void *__base,
2361 size_t __nmemb, size_t __size, __compar_fn_t __compar)
2362 __attribute__ ((__nonnull__ (1, 2, 5))) __attribute__ ((__warn_unused_result__));
2365 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/stdlib-bsearch.h" 1 3 4
2366 # 19 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/stdlib-bsearch.h" 3 4
2367 extern __inline __attribute__ ((__gnu_inline__)) void *
2368 bsearch (const void *__key, const void *__base, size_t __nmemb, size_t __size,
2369 __compar_fn_t __compar)
2371 size_t __l, __u, __idx;
2379 __idx = (__l + __u) / 2;
2380 __p = (void *) (((const char *) __base) + (__idx * __size));
2381 __comparison = (*__compar) (__key, __p);
2382 if (__comparison < 0)
2384 else if (__comparison > 0)
2387 return (void *) __p;
2392 # 760 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 2 3 4
2397 extern void qsort (void *__base, size_t __nmemb, size_t __size,
2398 __compar_fn_t __compar) __attribute__ ((__nonnull__ (1, 4)));
2400 extern void qsort_r (void *__base, size_t __nmemb, size_t __size,
2401 __compar_d_fn_t __compar, void *__arg)
2402 __attribute__ ((__nonnull__ (1, 4)));
2407 extern int abs (int __x) throw () __attribute__ ((__const__)) __attribute__ ((__warn_unused_result__));
2408 extern long int labs (long int __x) throw () __attribute__ ((__const__)) __attribute__ ((__warn_unused_result__));
2412 __extension__ extern long long int llabs (long long int __x)
2413 throw () __attribute__ ((__const__)) __attribute__ ((__warn_unused_result__));
2421 extern div_t div (int __numer, int __denom)
2422 throw () __attribute__ ((__const__)) __attribute__ ((__warn_unused_result__));
2423 extern ldiv_t ldiv (long int __numer, long int __denom)
2424 throw () __attribute__ ((__const__)) __attribute__ ((__warn_unused_result__));
2429 __extension__ extern lldiv_t lldiv (long long int __numer,
2430 long long int __denom)
2431 throw () __attribute__ ((__const__)) __attribute__ ((__warn_unused_result__));
2433 # 811 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4
2434 extern char *ecvt (double __value, int __ndigit, int *__restrict __decpt,
2435 int *__restrict __sign) throw () __attribute__ ((__nonnull__ (3, 4))) __attribute__ ((__warn_unused_result__));
2440 extern char *fcvt (double __value, int __ndigit, int *__restrict __decpt,
2441 int *__restrict __sign) throw () __attribute__ ((__nonnull__ (3, 4))) __attribute__ ((__warn_unused_result__));
2446 extern char *gcvt (double __value, int __ndigit, char *__buf)
2447 throw () __attribute__ ((__nonnull__ (3))) __attribute__ ((__warn_unused_result__));
2452 extern char *qecvt (long double __value, int __ndigit,
2453 int *__restrict __decpt, int *__restrict __sign)
2454 throw () __attribute__ ((__nonnull__ (3, 4))) __attribute__ ((__warn_unused_result__));
2455 extern char *qfcvt (long double __value, int __ndigit,
2456 int *__restrict __decpt, int *__restrict __sign)
2457 throw () __attribute__ ((__nonnull__ (3, 4))) __attribute__ ((__warn_unused_result__));
2458 extern char *qgcvt (long double __value, int __ndigit, char *__buf)
2459 throw () __attribute__ ((__nonnull__ (3))) __attribute__ ((__warn_unused_result__));
2464 extern int ecvt_r (double __value, int __ndigit, int *__restrict __decpt,
2465 int *__restrict __sign, char *__restrict __buf,
2466 size_t __len) throw () __attribute__ ((__nonnull__ (3, 4, 5)));
2467 extern int fcvt_r (double __value, int __ndigit, int *__restrict __decpt,
2468 int *__restrict __sign, char *__restrict __buf,
2469 size_t __len) throw () __attribute__ ((__nonnull__ (3, 4, 5)));
2471 extern int qecvt_r (long double __value, int __ndigit,
2472 int *__restrict __decpt, int *__restrict __sign,
2473 char *__restrict __buf, size_t __len)
2474 throw () __attribute__ ((__nonnull__ (3, 4, 5)));
2475 extern int qfcvt_r (long double __value, int __ndigit,
2476 int *__restrict __decpt, int *__restrict __sign,
2477 char *__restrict __buf, size_t __len)
2478 throw () __attribute__ ((__nonnull__ (3, 4, 5)));
2485 extern int mblen (const char *__s, size_t __n) throw ();
2488 extern int mbtowc (wchar_t *__restrict __pwc,
2489 const char *__restrict __s, size_t __n) throw ();
2492 extern int wctomb (char *__s, wchar_t __wchar) throw ();
2496 extern size_t mbstowcs (wchar_t *__restrict __pwcs,
2497 const char *__restrict __s, size_t __n) throw ();
2499 extern size_t wcstombs (char *__restrict __s,
2500 const wchar_t *__restrict __pwcs, size_t __n)
2510 extern int rpmatch (const char *__response) throw () __attribute__ ((__nonnull__ (1))) __attribute__ ((__warn_unused_result__));
2511 # 898 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4
2512 extern int getsubopt (char **__restrict __optionp,
2513 char *const *__restrict __tokens,
2514 char **__restrict __valuep)
2515 throw () __attribute__ ((__nonnull__ (1, 2, 3))) __attribute__ ((__warn_unused_result__));
2521 extern void setkey (const char *__key) throw () __attribute__ ((__nonnull__ (1)));
2529 extern int posix_openpt (int __oflag) __attribute__ ((__warn_unused_result__));
2537 extern int grantpt (int __fd) throw ();
2541 extern int unlockpt (int __fd) throw ();
2546 extern char *ptsname (int __fd) throw () __attribute__ ((__warn_unused_result__));
2553 extern int ptsname_r (int __fd, char *__buf, size_t __buflen)
2554 throw () __attribute__ ((__nonnull__ (2)));
2557 extern int getpt (void);
2564 extern int getloadavg (double __loadavg[], int __nelem)
2565 throw () __attribute__ ((__nonnull__ (1)));
2568 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/stdlib-float.h" 1 3 4
2569 # 24 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/stdlib-float.h" 3 4
2571 extern __inline __attribute__ ((__gnu_inline__)) double
2572 __attribute__ ((__leaf__)) atof (const char *__nptr) throw ()
2574 return strtod (__nptr, (char **) __null);
2577 # 955 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 2 3 4
2581 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/stdlib.h" 1 3 4
2582 # 23 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/stdlib.h" 3 4
2583 extern char *__realpath_chk (const char *__restrict __name,
2584 char *__restrict __resolved,
2585 size_t __resolvedlen) throw () __attribute__ ((__warn_unused_result__));
2586 extern char *__realpath_alias (const char *__restrict __name, char *__restrict __resolved) throw () __asm__ ("" "realpath")
2588 __attribute__ ((__warn_unused_result__));
2589 extern char *__realpath_chk_warn (const char *__restrict __name, char *__restrict __resolved, size_t __resolvedlen) throw () __asm__ ("" "__realpath_chk")
2592 __attribute__ ((__warn_unused_result__))
2593 __attribute__((__warning__ ("second argument of realpath must be either NULL or at " "least PATH_MAX bytes long buffer")))
2596 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__)) char *
2597 __attribute__ ((__leaf__)) realpath (const char *__restrict __name, char *__restrict __resolved) throw ()
2599 if (__builtin_object_size (__resolved, 2 > 1) != (size_t) -1)
2605 return __realpath_chk (__name, __resolved, __builtin_object_size (__resolved, 2 > 1));
2608 return __realpath_alias (__name, __resolved);
2612 extern int __ptsname_r_chk (int __fd, char *__buf, size_t __buflen,
2613 size_t __nreal) throw () __attribute__ ((__nonnull__ (2)));
2614 extern int __ptsname_r_alias (int __fd, char *__buf, size_t __buflen) throw () __asm__ ("" "ptsname_r")
2616 __attribute__ ((__nonnull__ (2)));
2617 extern int __ptsname_r_chk_warn (int __fd, char *__buf, size_t __buflen, size_t __nreal) throw () __asm__ ("" "__ptsname_r_chk")
2620 __attribute__ ((__nonnull__ (2))) __attribute__((__warning__ ("ptsname_r called with buflen bigger than " "size of buf")))
2623 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int
2624 __attribute__ ((__leaf__)) ptsname_r (int __fd, char *__buf, size_t __buflen) throw ()
2626 if (__builtin_object_size (__buf, 2 > 1) != (size_t) -1)
2628 if (!__builtin_constant_p (__buflen))
2629 return __ptsname_r_chk (__fd, __buf, __buflen, __builtin_object_size (__buf, 2 > 1));
2630 if (__buflen > __builtin_object_size (__buf, 2 > 1))
2631 return __ptsname_r_chk_warn (__fd, __buf, __buflen, __builtin_object_size (__buf, 2 > 1));
2633 return __ptsname_r_alias (__fd, __buf, __buflen);
2637 extern int __wctomb_chk (char *__s, wchar_t __wchar, size_t __buflen)
2638 throw () __attribute__ ((__warn_unused_result__));
2639 extern int __wctomb_alias (char *__s, wchar_t __wchar) throw () __asm__ ("" "wctomb")
2640 __attribute__ ((__warn_unused_result__));
2642 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__)) int
2643 __attribute__ ((__leaf__)) wctomb (char *__s, wchar_t __wchar) throw ()
2652 if (__builtin_object_size (__s, 2 > 1) != (size_t) -1 && 16 > __builtin_object_size (__s, 2 > 1))
2653 return __wctomb_chk (__s, __wchar, __builtin_object_size (__s, 2 > 1));
2654 return __wctomb_alias (__s, __wchar);
2658 extern size_t __mbstowcs_chk (wchar_t *__restrict __dst,
2659 const char *__restrict __src,
2660 size_t __len, size_t __dstlen) throw ();
2661 extern size_t __mbstowcs_alias (wchar_t *__restrict __dst, const char *__restrict __src, size_t __len) throw () __asm__ ("" "mbstowcs")
2665 extern size_t __mbstowcs_chk_warn (wchar_t *__restrict __dst, const char *__restrict __src, size_t __len, size_t __dstlen) throw () __asm__ ("" "__mbstowcs_chk")
2669 __attribute__((__warning__ ("mbstowcs called with dst buffer smaller than len " "* sizeof (wchar_t)")))
2672 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) size_t
2673 __attribute__ ((__leaf__)) mbstowcs (wchar_t *__restrict __dst, const char *__restrict __src, size_t __len) throw ()
2676 if (__builtin_object_size (__dst, 2 > 1) != (size_t) -1)
2678 if (!__builtin_constant_p (__len))
2679 return __mbstowcs_chk (__dst, __src, __len,
2680 __builtin_object_size (__dst, 2 > 1) / sizeof (wchar_t));
2682 if (__len > __builtin_object_size (__dst, 2 > 1) / sizeof (wchar_t))
2683 return __mbstowcs_chk_warn (__dst, __src, __len,
2684 __builtin_object_size (__dst, 2 > 1) / sizeof (wchar_t));
2686 return __mbstowcs_alias (__dst, __src, __len);
2690 extern size_t __wcstombs_chk (char *__restrict __dst,
2691 const wchar_t *__restrict __src,
2692 size_t __len, size_t __dstlen) throw ();
2693 extern size_t __wcstombs_alias (char *__restrict __dst, const wchar_t *__restrict __src, size_t __len) throw () __asm__ ("" "wcstombs")
2697 extern size_t __wcstombs_chk_warn (char *__restrict __dst, const wchar_t *__restrict __src, size_t __len, size_t __dstlen) throw () __asm__ ("" "__wcstombs_chk")
2701 __attribute__((__warning__ ("wcstombs called with dst buffer smaller than len")));
2703 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) size_t
2704 __attribute__ ((__leaf__)) wcstombs (char *__restrict __dst, const wchar_t *__restrict __src, size_t __len) throw ()
2707 if (__builtin_object_size (__dst, 2 > 1) != (size_t) -1)
2709 if (!__builtin_constant_p (__len))
2710 return __wcstombs_chk (__dst, __src, __len, __builtin_object_size (__dst, 2 > 1));
2711 if (__len > __builtin_object_size (__dst, 2 > 1))
2712 return __wcstombs_chk_warn (__dst, __src, __len, __builtin_object_size (__dst, 2 > 1));
2714 return __wcstombs_alias (__dst, __src, __len);
2716 # 959 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 2 3 4
2717 # 967 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdlib.h" 3 4
2720 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/string.h" 1 3 4
2721 # 27 "/usr/powerpc64-unknown-linux-gnu/usr/include/string.h" 3 4
2727 # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4
2728 # 33 "/usr/powerpc64-unknown-linux-gnu/usr/include/string.h" 2 3 4
2738 extern void *memcpy (void *__restrict __dest, const void *__restrict __src,
2739 size_t __n) throw () __attribute__ ((__nonnull__ (1, 2)));
2742 extern void *memmove (void *__dest, const void *__src, size_t __n)
2743 throw () __attribute__ ((__nonnull__ (1, 2)));
2750 extern void *memccpy (void *__restrict __dest, const void *__restrict __src,
2751 int __c, size_t __n)
2752 throw () __attribute__ ((__nonnull__ (1, 2)));
2758 extern void *memset (void *__s, int __c, size_t __n) throw () __attribute__ ((__nonnull__ (1)));
2761 extern int memcmp (const void *__s1, const void *__s2, size_t __n)
2762 throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
2768 extern void *memchr (void *__s, int __c, size_t __n)
2769 throw () __asm ("memchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
2770 extern const void *memchr (const void *__s, int __c, size_t __n)
2771 throw () __asm ("memchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
2774 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) void *
2775 memchr (void *__s, int __c, size_t __n) throw ()
2777 return __builtin_memchr (__s, __c, __n);
2780 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) const void *
2781 memchr (const void *__s, int __c, size_t __n) throw ()
2783 return __builtin_memchr (__s, __c, __n);
2797 extern "C++" void *rawmemchr (void *__s, int __c)
2798 throw () __asm ("rawmemchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
2799 extern "C++" const void *rawmemchr (const void *__s, int __c)
2800 throw () __asm ("rawmemchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
2808 extern "C++" void *memrchr (void *__s, int __c, size_t __n)
2809 throw () __asm ("memrchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
2810 extern "C++" const void *memrchr (const void *__s, int __c, size_t __n)
2811 throw () __asm ("memrchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
2821 extern char *strcpy (char *__restrict __dest, const char *__restrict __src)
2822 throw () __attribute__ ((__nonnull__ (1, 2)));
2824 extern char *strncpy (char *__restrict __dest,
2825 const char *__restrict __src, size_t __n)
2826 throw () __attribute__ ((__nonnull__ (1, 2)));
2829 extern char *strcat (char *__restrict __dest, const char *__restrict __src)
2830 throw () __attribute__ ((__nonnull__ (1, 2)));
2832 extern char *strncat (char *__restrict __dest, const char *__restrict __src,
2833 size_t __n) throw () __attribute__ ((__nonnull__ (1, 2)));
2836 extern int strcmp (const char *__s1, const char *__s2)
2837 throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
2839 extern int strncmp (const char *__s1, const char *__s2, size_t __n)
2840 throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
2843 extern int strcoll (const char *__s1, const char *__s2)
2844 throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
2846 extern size_t strxfrm (char *__restrict __dest,
2847 const char *__restrict __src, size_t __n)
2848 throw () __attribute__ ((__nonnull__ (2)));
2850 # 162 "/usr/powerpc64-unknown-linux-gnu/usr/include/string.h" 3 4
2851 extern int strcoll_l (const char *__s1, const char *__s2, __locale_t __l)
2852 throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 3)));
2854 extern size_t strxfrm_l (char *__dest, const char *__src, size_t __n,
2855 __locale_t __l) throw () __attribute__ ((__nonnull__ (2, 4)));
2860 extern char *strdup (const char *__s)
2861 throw () __attribute__ ((__malloc__)) __attribute__ ((__nonnull__ (1)));
2868 extern char *strndup (const char *__string, size_t __n)
2869 throw () __attribute__ ((__malloc__)) __attribute__ ((__nonnull__ (1)));
2870 # 206 "/usr/powerpc64-unknown-linux-gnu/usr/include/string.h" 3 4
2876 extern char *strchr (char *__s, int __c)
2877 throw () __asm ("strchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
2878 extern const char *strchr (const char *__s, int __c)
2879 throw () __asm ("strchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
2882 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) char *
2883 strchr (char *__s, int __c) throw ()
2885 return __builtin_strchr (__s, __c);
2888 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) const char *
2889 strchr (const char *__s, int __c) throw ()
2891 return __builtin_strchr (__s, __c);
2903 extern char *strrchr (char *__s, int __c)
2904 throw () __asm ("strrchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
2905 extern const char *strrchr (const char *__s, int __c)
2906 throw () __asm ("strrchr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
2909 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) char *
2910 strrchr (char *__s, int __c) throw ()
2912 return __builtin_strrchr (__s, __c);
2915 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) const char *
2916 strrchr (const char *__s, int __c) throw ()
2918 return __builtin_strrchr (__s, __c);
2932 extern "C++" char *strchrnul (char *__s, int __c)
2933 throw () __asm ("strchrnul") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
2934 extern "C++" const char *strchrnul (const char *__s, int __c)
2935 throw () __asm ("strchrnul") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
2945 extern size_t strcspn (const char *__s, const char *__reject)
2946 throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
2949 extern size_t strspn (const char *__s, const char *__accept)
2950 throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
2955 extern char *strpbrk (char *__s, const char *__accept)
2956 throw () __asm ("strpbrk") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
2957 extern const char *strpbrk (const char *__s, const char *__accept)
2958 throw () __asm ("strpbrk") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
2961 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) char *
2962 strpbrk (char *__s, const char *__accept) throw ()
2964 return __builtin_strpbrk (__s, __accept);
2967 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) const char *
2968 strpbrk (const char *__s, const char *__accept) throw ()
2970 return __builtin_strpbrk (__s, __accept);
2982 extern char *strstr (char *__haystack, const char *__needle)
2983 throw () __asm ("strstr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
2984 extern const char *strstr (const char *__haystack, const char *__needle)
2985 throw () __asm ("strstr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
2988 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) char *
2989 strstr (char *__haystack, const char *__needle) throw ()
2991 return __builtin_strstr (__haystack, __needle);
2994 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) const char *
2995 strstr (const char *__haystack, const char *__needle) throw ()
2997 return __builtin_strstr (__haystack, __needle);
3008 extern char *strtok (char *__restrict __s, const char *__restrict __delim)
3009 throw () __attribute__ ((__nonnull__ (2)));
3014 extern char *__strtok_r (char *__restrict __s,
3015 const char *__restrict __delim,
3016 char **__restrict __save_ptr)
3017 throw () __attribute__ ((__nonnull__ (2, 3)));
3019 extern char *strtok_r (char *__restrict __s, const char *__restrict __delim,
3020 char **__restrict __save_ptr)
3021 throw () __attribute__ ((__nonnull__ (2, 3)));
3027 extern "C++" char *strcasestr (char *__haystack, const char *__needle)
3028 throw () __asm ("strcasestr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
3029 extern "C++" const char *strcasestr (const char *__haystack,
3030 const char *__needle)
3031 throw () __asm ("strcasestr") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
3032 # 377 "/usr/powerpc64-unknown-linux-gnu/usr/include/string.h" 3 4
3033 extern void *memmem (const void *__haystack, size_t __haystacklen,
3034 const void *__needle, size_t __needlelen)
3035 throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 3)));
3039 extern void *__mempcpy (void *__restrict __dest,
3040 const void *__restrict __src, size_t __n)
3041 throw () __attribute__ ((__nonnull__ (1, 2)));
3042 extern void *mempcpy (void *__restrict __dest,
3043 const void *__restrict __src, size_t __n)
3044 throw () __attribute__ ((__nonnull__ (1, 2)));
3050 extern size_t strlen (const char *__s)
3051 throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
3057 extern size_t strnlen (const char *__string, size_t __maxlen)
3058 throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
3064 extern char *strerror (int __errnum) throw ();
3066 # 433 "/usr/powerpc64-unknown-linux-gnu/usr/include/string.h" 3 4
3067 extern char *strerror_r (int __errnum, char *__buf, size_t __buflen)
3068 throw () __attribute__ ((__nonnull__ (2))) __attribute__ ((__warn_unused_result__));
3074 extern char *strerror_l (int __errnum, __locale_t __l) throw ();
3080 extern void __bzero (void *__s, size_t __n) throw () __attribute__ ((__nonnull__ (1)));
3084 extern void bcopy (const void *__src, void *__dest, size_t __n)
3085 throw () __attribute__ ((__nonnull__ (1, 2)));
3088 extern void bzero (void *__s, size_t __n) throw () __attribute__ ((__nonnull__ (1)));
3091 extern int bcmp (const void *__s1, const void *__s2, size_t __n)
3092 throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
3098 extern char *index (char *__s, int __c)
3099 throw () __asm ("index") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
3100 extern const char *index (const char *__s, int __c)
3101 throw () __asm ("index") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
3104 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) char *
3105 index (char *__s, int __c) throw ()
3107 return __builtin_index (__s, __c);
3110 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) const char *
3111 index (const char *__s, int __c) throw ()
3113 return __builtin_index (__s, __c);
3126 extern char *rindex (char *__s, int __c)
3127 throw () __asm ("rindex") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
3128 extern const char *rindex (const char *__s, int __c)
3129 throw () __asm ("rindex") __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1)));
3132 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) char *
3133 rindex (char *__s, int __c) throw ()
3135 return __builtin_rindex (__s, __c);
3138 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) const char *
3139 rindex (const char *__s, int __c) throw ()
3141 return __builtin_rindex (__s, __c);
3152 extern int ffs (int __i) throw () __attribute__ ((__const__));
3157 extern int ffsl (long int __l) throw () __attribute__ ((__const__));
3158 __extension__ extern int ffsll (long long int __ll)
3159 throw () __attribute__ ((__const__));
3163 extern int strcasecmp (const char *__s1, const char *__s2)
3164 throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
3167 extern int strncasecmp (const char *__s1, const char *__s2, size_t __n)
3168 throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
3174 extern int strcasecmp_l (const char *__s1, const char *__s2,
3176 throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 3)));
3178 extern int strncasecmp_l (const char *__s1, const char *__s2,
3179 size_t __n, __locale_t __loc)
3180 throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 4)));
3186 extern char *strsep (char **__restrict __stringp,
3187 const char *__restrict __delim)
3188 throw () __attribute__ ((__nonnull__ (1, 2)));
3193 extern char *strsignal (int __sig) throw ();
3196 extern char *__stpcpy (char *__restrict __dest, const char *__restrict __src)
3197 throw () __attribute__ ((__nonnull__ (1, 2)));
3198 extern char *stpcpy (char *__restrict __dest, const char *__restrict __src)
3199 throw () __attribute__ ((__nonnull__ (1, 2)));
3203 extern char *__stpncpy (char *__restrict __dest,
3204 const char *__restrict __src, size_t __n)
3205 throw () __attribute__ ((__nonnull__ (1, 2)));
3206 extern char *stpncpy (char *__restrict __dest,
3207 const char *__restrict __src, size_t __n)
3208 throw () __attribute__ ((__nonnull__ (1, 2)));
3213 extern int strverscmp (const char *__s1, const char *__s2)
3214 throw () __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2)));
3217 extern char *strfry (char *__string) throw () __attribute__ ((__nonnull__ (1)));
3220 extern void *memfrob (void *__s, size_t __n) throw () __attribute__ ((__nonnull__ (1)));
3228 extern "C++" char *basename (char *__filename)
3229 throw () __asm ("basename") __attribute__ ((__nonnull__ (1)));
3230 extern "C++" const char *basename (const char *__filename)
3231 throw () __asm ("basename") __attribute__ ((__nonnull__ (1)));
3232 # 635 "/usr/powerpc64-unknown-linux-gnu/usr/include/string.h" 3 4
3233 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/string3.h" 1 3 4
3234 # 23 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/string3.h" 3 4
3235 extern void __warn_memset_zero_len (void) __attribute__((__warning__ ("memset used with constant zero length parameter; this could be due to transposed parameters")))
3237 # 49 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/string3.h" 3 4
3238 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) void *
3239 __attribute__ ((__leaf__)) memcpy (void *__restrict __dest, const void *__restrict __src, size_t __len) throw ()
3242 return __builtin___memcpy_chk (__dest, __src, __len, __builtin_object_size (__dest, 0));
3245 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) void *
3246 __attribute__ ((__leaf__)) memmove (void *__dest, const void *__src, size_t __len) throw ()
3248 return __builtin___memmove_chk (__dest, __src, __len, __builtin_object_size (__dest, 0));
3252 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) void *
3253 __attribute__ ((__leaf__)) mempcpy (void *__restrict __dest, const void *__restrict __src, size_t __len) throw ()
3256 return __builtin___mempcpy_chk (__dest, __src, __len, __builtin_object_size (__dest, 0));
3258 # 77 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/string3.h" 3 4
3259 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) void *
3260 __attribute__ ((__leaf__)) memset (void *__dest, int __ch, size_t __len) throw ()
3265 if (__builtin_constant_p (__len) && __len == 0
3266 && (!__builtin_constant_p (__ch) || __ch != 0))
3268 __warn_memset_zero_len ();
3272 return __builtin___memset_chk (__dest, __ch, __len, __builtin_object_size (__dest, 0));
3276 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) void
3277 __attribute__ ((__leaf__)) bcopy (const void *__src, void *__dest, size_t __len) throw ()
3279 (void) __builtin___memmove_chk (__dest, __src, __len, __builtin_object_size (__dest, 0));
3282 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) void
3283 __attribute__ ((__leaf__)) bzero (void *__dest, size_t __len) throw ()
3285 (void) __builtin___memset_chk (__dest, '\0', __len, __builtin_object_size (__dest, 0));
3289 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) char *
3290 __attribute__ ((__leaf__)) strcpy (char *__restrict __dest, const char *__restrict __src) throw ()
3292 return __builtin___strcpy_chk (__dest, __src, __builtin_object_size (__dest, 2 > 1));
3296 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) char *
3297 __attribute__ ((__leaf__)) stpcpy (char *__restrict __dest, const char *__restrict __src) throw ()
3299 return __builtin___stpcpy_chk (__dest, __src, __builtin_object_size (__dest, 2 > 1));
3304 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) char *
3305 __attribute__ ((__leaf__)) strncpy (char *__restrict __dest, const char *__restrict __src, size_t __len) throw ()
3308 return __builtin___strncpy_chk (__dest, __src, __len, __builtin_object_size (__dest, 2 > 1));
3312 extern char *__stpncpy_chk (char *__dest, const char *__src, size_t __n,
3313 size_t __destlen) throw ();
3314 extern char *__stpncpy_alias (char *__dest, const char *__src, size_t __n) throw () __asm__ ("" "stpncpy")
3317 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) char *
3318 __attribute__ ((__leaf__)) stpncpy (char *__dest, const char *__src, size_t __n) throw ()
3320 if (__builtin_object_size (__dest, 2 > 1) != (size_t) -1
3321 && (!__builtin_constant_p (__n) || __n <= __builtin_object_size (__dest, 2 > 1)))
3322 return __stpncpy_chk (__dest, __src, __n, __builtin_object_size (__dest, 2 > 1));
3323 return __stpncpy_alias (__dest, __src, __n);
3327 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) char *
3328 __attribute__ ((__leaf__)) strcat (char *__restrict __dest, const char *__restrict __src) throw ()
3330 return __builtin___strcat_chk (__dest, __src, __builtin_object_size (__dest, 2 > 1));
3334 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) char *
3335 __attribute__ ((__leaf__)) strncat (char *__restrict __dest, const char *__restrict __src, size_t __len) throw ()
3338 return __builtin___strncat_chk (__dest, __src, __len, __builtin_object_size (__dest, 2 > 1));
3340 # 636 "/usr/powerpc64-unknown-linux-gnu/usr/include/string.h" 2 3 4
3348 # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4
3349 # 147 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 3 4
3350 typedef long int ptrdiff_t;
3358 # 1 "jsinttypes.h" 1
3360 # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stdint.h" 1 3 4
3361 # 9 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stdint.h" 3 4
3362 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdint.h" 1 3 4
3363 # 26 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdint.h" 3 4
3364 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/wchar.h" 1 3 4
3365 # 27 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdint.h" 2 3 4
3366 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/wordsize.h" 1 3 4
3367 # 28 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdint.h" 2 3 4
3368 # 48 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdint.h" 3 4
3369 typedef unsigned char uint8_t;
3370 typedef unsigned short int uint16_t;
3372 typedef unsigned int uint32_t;
3376 typedef unsigned long int uint64_t;
3377 # 65 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdint.h" 3 4
3378 typedef signed char int_least8_t;
3379 typedef short int int_least16_t;
3380 typedef int int_least32_t;
3382 typedef long int int_least64_t;
3389 typedef unsigned char uint_least8_t;
3390 typedef unsigned short int uint_least16_t;
3391 typedef unsigned int uint_least32_t;
3393 typedef unsigned long int uint_least64_t;
3394 # 90 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdint.h" 3 4
3395 typedef signed char int_fast8_t;
3397 typedef long int int_fast16_t;
3398 typedef long int int_fast32_t;
3399 typedef long int int_fast64_t;
3400 # 103 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdint.h" 3 4
3401 typedef unsigned char uint_fast8_t;
3403 typedef unsigned long int uint_fast16_t;
3404 typedef unsigned long int uint_fast32_t;
3405 typedef unsigned long int uint_fast64_t;
3406 # 119 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdint.h" 3 4
3407 typedef long int intptr_t;
3410 typedef unsigned long int uintptr_t;
3411 # 134 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdint.h" 3 4
3412 typedef long int intmax_t;
3413 typedef unsigned long int uintmax_t;
3414 # 10 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stdint.h" 2 3 4
3415 # 75 "jsinttypes.h" 2
3420 typedef int8_t JSInt8;
3421 typedef int16_t JSInt16;
3422 typedef int32_t JSInt32;
3423 typedef int64_t JSInt64;
3424 typedef intptr_t JSIntPtr;
3426 typedef uint8_t JSUint8;
3427 typedef uint16_t JSUint16;
3428 typedef uint32_t JSUint32;
3429 typedef uint64_t JSUint64;
3430 typedef uintptr_t JSUintPtr;
3436 typedef unsigned int JSUintn;
3443 typedef double JSFloat64;
3450 typedef size_t JSSize;
3458 typedef ptrdiff_t JSPtrdiff;
3466 typedef JSUintPtr JSUptrdiff;
3468 typedef JSIntn JSBool;
3470 typedef JSUint8 JSPackedBool;
3475 typedef JSIntPtr JSWord;
3476 typedef JSUintPtr JSUword;
3480 typedef JSUintn uintn;
3481 typedef JSUint64 uint64;
3482 typedef JSUint32 uint32;
3483 typedef JSUint16 uint16;
3484 typedef JSUint8 uint8;
3487 typedef JSIntn intn;
3489 typedef JSInt64 int64;
3492 typedef JSInt32 int32;
3493 typedef JSInt16 int16;
3494 typedef JSInt8 int8;
3499 typedef JSFloat64 float64;
3517 typedef JSIntn intN;
3518 typedef JSUintn uintN;
3519 typedef JSUword jsuword;
3520 typedef JSWord jsword;
3521 typedef float float32;
3531 extern __attribute__((visibility ("default"))) void
3532 JS_Assert(const char *s, const char *file, JSIntn ln);
3534 extern __attribute__((visibility ("default"))) void JS_Abort(void);
3536 static inline void* js_malloc(size_t bytes) {
3537 return malloc(bytes);
3540 static inline void* js_calloc(size_t bytes) {
3541 return calloc(bytes, 1);
3544 static inline void* js_realloc(void* p, size_t bytes) {
3545 return realloc(p, bytes);
3548 static inline void js_free(void* p) {
3556 __attribute__((always_inline)) inline T *js_new() {
3557 void *memory = js_malloc(sizeof(T)); return memory ? new(memory) T () : __null;
3560 template <class T, class P1>
3561 __attribute__((always_inline)) inline T *js_new(const P1 &p1) {
3562 void *memory = js_malloc(sizeof(T)); return memory ? new(memory) T (p1) : __null;
3565 template <class T, class P1, class P2>
3566 __attribute__((always_inline)) inline T *js_new(const P1 &p1, const P2 &p2) {
3567 void *memory = js_malloc(sizeof(T)); return memory ? new(memory) T (p1, p2) : __null;
3570 template <class T, class P1, class P2, class P3>
3571 __attribute__((always_inline)) inline T *js_new(const P1 &p1, const P2 &p2, const P3 &p3) {
3572 void *memory = js_malloc(sizeof(T)); return memory ? new(memory) T (p1, p2, p3) : __null;
3575 template <class T, class P1, class P2, class P3, class P4>
3576 __attribute__((always_inline)) inline T *js_new(const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4) {
3577 void *memory = js_malloc(sizeof(T)); return memory ? new(memory) T (p1, p2, p3, p4) : __null;
3585 __attribute__((always_inline)) inline void js_delete(T *p) {
3592 static const int JSMinAlignment = 8;
3595 __attribute__((always_inline)) inline T *js_array_new(size_t n) {
3597 uint64 numBytes64 = uint64(JSMinAlignment) + uint64(sizeof(T)) * uint64(n);
3598 size_t numBytes = size_t(numBytes64);
3599 if (numBytes64 != numBytes) {
3603 void *memory = js_malloc(numBytes);
3606 *(size_t *)memory = n;
3607 memory = (void*)(uintptr_t(memory) + JSMinAlignment);
3608 return new(memory) T[n];
3612 __attribute__((always_inline)) inline void js_array_delete(T *p) {
3614 void* p0 = (void *)(uintptr_t(p) - JSMinAlignment);
3615 size_t n = *(size_t *)p0;
3616 for (size_t i = 0; i < n; i++)
3625 __attribute__((always_inline)) inline static void
3628 memset(t, 0, sizeof(T));
3632 __attribute__((always_inline)) inline static void
3633 PodZero(T *t, size_t nelem)
3635 memset(t, 0, nelem * sizeof(T));
3638 template <class T, size_t N> static void PodZero(T (&)[N]);
3639 template <class T, size_t N> static void PodZero(T (&)[N], size_t);
3641 template <class T, size_t N>
3642 __attribute__((always_inline)) inline static void
3643 PodArrayZero(T (&t)[N])
3645 memset(t, 0, N * sizeof(T));
3649 __attribute__((always_inline)) inline static void
3650 PodCopy(T *dst, const T *src, size_t nelem)
3657 for (const T *srcend = src + nelem; src != srcend; ++src, ++dst)
3660 memcpy(dst, src, nelem * sizeof(T));
3672 typedef jsuword jsbitmap_t;
3673 typedef jsbitmap_t jsbitmap;
3675 extern __attribute__((visibility ("default"))) JSIntn JS_CeilingLog2(JSUint32 i);
3680 extern __attribute__((visibility ("default"))) JSIntn JS_FloorLog2(JSUint32 i);
3685 CountTrailingZeros(size_t n)
3695 return __builtin_ctzll(n);
3705 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 1 3 4
3706 # 29 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4
3711 # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4
3712 # 34 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 2 3 4
3713 # 44 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4
3718 typedef struct _IO_FILE FILE;
3724 # 64 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4
3725 typedef struct _IO_FILE __FILE;
3726 # 74 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4
3727 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 1 3 4
3728 # 31 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 3 4
3729 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/_G_config.h" 1 3 4
3730 # 15 "/usr/powerpc64-unknown-linux-gnu/usr/include/_G_config.h" 3 4
3731 # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4
3732 # 16 "/usr/powerpc64-unknown-linux-gnu/usr/include/_G_config.h" 2 3 4
3737 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/wchar.h" 1 3 4
3738 # 82 "/usr/powerpc64-unknown-linux-gnu/usr/include/wchar.h" 3 4
3752 # 21 "/usr/powerpc64-unknown-linux-gnu/usr/include/_G_config.h" 2 3 4
3756 __mbstate_t __state;
3761 __mbstate_t __state;
3763 # 32 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 2 3 4
3764 # 49 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 3 4
3765 # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stdarg.h" 1 3 4
3766 # 40 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stdarg.h" 3 4
3767 typedef __builtin_va_list __gnuc_va_list;
3768 # 50 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 2 3 4
3769 # 144 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 3 4
3770 struct _IO_jump_t; struct _IO_FILE;
3771 # 154 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 3 4
3772 typedef void _IO_lock_t;
3779 struct _IO_marker *_next;
3780 struct _IO_FILE *_sbuf;
3785 # 177 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 3 4
3789 enum __codecvt_result
3796 # 245 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 3 4
3805 char* _IO_read_base;
3806 char* _IO_write_base;
3807 char* _IO_write_ptr;
3808 char* _IO_write_end;
3812 char *_IO_save_base;
3813 char *_IO_backup_base;
3816 struct _IO_marker *_markers;
3818 struct _IO_FILE *_chain;
3826 __off_t _old_offset;
3830 unsigned short _cur_column;
3831 signed char _vtable_offset;
3837 # 293 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 3 4
3839 # 302 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 3 4
3848 char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)];
3856 struct _IO_FILE_plus;
3858 extern struct _IO_FILE_plus _IO_2_1_stdin_;
3859 extern struct _IO_FILE_plus _IO_2_1_stdout_;
3860 extern struct _IO_FILE_plus _IO_2_1_stderr_;
3861 # 338 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 3 4
3862 typedef __ssize_t __io_read_fn (void *__cookie, char *__buf, size_t __nbytes);
3870 typedef __ssize_t __io_write_fn (void *__cookie, const char *__buf,
3879 typedef int __io_seek_fn (void *__cookie, __off64_t *__pos, int __w);
3882 typedef int __io_close_fn (void *__cookie);
3887 typedef __io_read_fn cookie_read_function_t;
3888 typedef __io_write_fn cookie_write_function_t;
3889 typedef __io_seek_fn cookie_seek_function_t;
3890 typedef __io_close_fn cookie_close_function_t;
3896 __io_write_fn *write;
3898 __io_close_fn *close;
3899 } _IO_cookie_io_functions_t;
3900 typedef _IO_cookie_io_functions_t cookie_io_functions_t;
3902 struct _IO_cookie_file;
3905 extern void _IO_cookie_init (struct _IO_cookie_file *__cfile, int __read_write,
3906 void *__cookie, _IO_cookie_io_functions_t __fns);
3914 extern int __underflow (_IO_FILE *);
3915 extern int __uflow (_IO_FILE *);
3916 extern int __overflow (_IO_FILE *, int);
3917 # 434 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 3 4
3918 extern int _IO_getc (_IO_FILE *__fp);
3919 extern int _IO_putc (int __c, _IO_FILE *__fp);
3920 extern int _IO_feof (_IO_FILE *__fp) throw ();
3921 extern int _IO_ferror (_IO_FILE *__fp) throw ();
3923 extern int _IO_peekc_locked (_IO_FILE *__fp);
3929 extern void _IO_flockfile (_IO_FILE *) throw ();
3930 extern void _IO_funlockfile (_IO_FILE *) throw ();
3931 extern int _IO_ftrylockfile (_IO_FILE *) throw ();
3932 # 464 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 3 4
3933 extern int _IO_vfscanf (_IO_FILE * __restrict, const char * __restrict,
3934 __gnuc_va_list, int *__restrict);
3935 extern int _IO_vfprintf (_IO_FILE *__restrict, const char *__restrict,
3937 extern __ssize_t _IO_padn (_IO_FILE *, int, __ssize_t);
3938 extern size_t _IO_sgetn (_IO_FILE *, void *, size_t);
3940 extern __off64_t _IO_seekoff (_IO_FILE *, __off64_t, int, int);
3941 extern __off64_t _IO_seekpos (_IO_FILE *, __off64_t, int);
3943 extern void _IO_free_backup_area (_IO_FILE *) throw ();
3944 # 526 "/usr/powerpc64-unknown-linux-gnu/usr/include/libio.h" 3 4
3946 # 75 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 2 3 4
3951 typedef __gnuc_va_list va_list;
3952 # 108 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4
3955 typedef _G_fpos_t fpos_t;
3961 typedef _G_fpos64_t fpos64_t;
3962 # 164 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4
3963 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/stdio_lim.h" 1 3 4
3964 # 165 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 2 3 4
3968 extern struct _IO_FILE *stdin;
3969 extern struct _IO_FILE *stdout;
3970 extern struct _IO_FILE *stderr;
3978 extern int remove (const char *__filename) throw ();
3980 extern int rename (const char *__old, const char *__new) throw ();
3985 extern int renameat (int __oldfd, const char *__old, int __newfd,
3986 const char *__new) throw ();
3995 extern FILE *tmpfile (void) __attribute__ ((__warn_unused_result__));
3996 # 205 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4
3997 extern FILE *tmpfile64 (void) __attribute__ ((__warn_unused_result__));
4001 extern char *tmpnam (char *__s) throw () __attribute__ ((__warn_unused_result__));
4007 extern char *tmpnam_r (char *__s) throw () __attribute__ ((__warn_unused_result__));
4008 # 227 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4
4009 extern char *tempnam (const char *__dir, const char *__pfx)
4010 throw () __attribute__ ((__malloc__)) __attribute__ ((__warn_unused_result__));
4019 extern int fclose (FILE *__stream);
4024 extern int fflush (FILE *__stream);
4026 # 252 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4
4027 extern int fflush_unlocked (FILE *__stream);
4028 # 262 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4
4029 extern int fcloseall (void);
4039 extern FILE *fopen (const char *__restrict __filename,
4040 const char *__restrict __modes) __attribute__ ((__warn_unused_result__));
4045 extern FILE *freopen (const char *__restrict __filename,
4046 const char *__restrict __modes,
4047 FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
4048 # 295 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4
4051 extern FILE *fopen64 (const char *__restrict __filename,
4052 const char *__restrict __modes) __attribute__ ((__warn_unused_result__));
4053 extern FILE *freopen64 (const char *__restrict __filename,
4054 const char *__restrict __modes,
4055 FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
4060 extern FILE *fdopen (int __fd, const char *__modes) throw () __attribute__ ((__warn_unused_result__));
4066 extern FILE *fopencookie (void *__restrict __magic_cookie,
4067 const char *__restrict __modes,
4068 _IO_cookie_io_functions_t __io_funcs) throw () __attribute__ ((__warn_unused_result__));
4073 extern FILE *fmemopen (void *__s, size_t __len, const char *__modes)
4074 throw () __attribute__ ((__warn_unused_result__));
4079 extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) throw () __attribute__ ((__warn_unused_result__));
4086 extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) throw ();
4090 extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
4091 int __modes, size_t __n) throw ();
4097 extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
4098 size_t __size) throw ();
4101 extern void setlinebuf (FILE *__stream) throw ();
4110 extern int fprintf (FILE *__restrict __stream,
4111 const char *__restrict __format, ...);
4116 extern int printf (const char *__restrict __format, ...);
4118 extern int sprintf (char *__restrict __s,
4119 const char *__restrict __format, ...) throw ();
4125 extern int vfprintf (FILE *__restrict __s, const char *__restrict __format,
4126 __gnuc_va_list __arg);
4131 extern int vprintf (const char *__restrict __format, __gnuc_va_list __arg);
4133 extern int vsprintf (char *__restrict __s, const char *__restrict __format,
4134 __gnuc_va_list __arg) throw ();
4140 extern int snprintf (char *__restrict __s, size_t __maxlen,
4141 const char *__restrict __format, ...)
4142 throw () __attribute__ ((__format__ (__printf__, 3, 4)));
4144 extern int vsnprintf (char *__restrict __s, size_t __maxlen,
4145 const char *__restrict __format, __gnuc_va_list __arg)
4146 throw () __attribute__ ((__format__ (__printf__, 3, 0)));
4153 extern int vasprintf (char **__restrict __ptr, const char *__restrict __f,
4154 __gnuc_va_list __arg)
4155 throw () __attribute__ ((__format__ (__printf__, 2, 0))) __attribute__ ((__warn_unused_result__));
4156 extern int __asprintf (char **__restrict __ptr,
4157 const char *__restrict __fmt, ...)
4158 throw () __attribute__ ((__format__ (__printf__, 2, 3))) __attribute__ ((__warn_unused_result__));
4159 extern int asprintf (char **__restrict __ptr,
4160 const char *__restrict __fmt, ...)
4161 throw () __attribute__ ((__format__ (__printf__, 2, 3))) __attribute__ ((__warn_unused_result__));
4166 extern int vdprintf (int __fd, const char *__restrict __fmt,
4167 __gnuc_va_list __arg)
4168 __attribute__ ((__format__ (__printf__, 2, 0)));
4169 extern int dprintf (int __fd, const char *__restrict __fmt, ...)
4170 __attribute__ ((__format__ (__printf__, 2, 3)));
4179 extern int fscanf (FILE *__restrict __stream,
4180 const char *__restrict __format, ...) __attribute__ ((__warn_unused_result__));
4185 extern int scanf (const char *__restrict __format, ...) __attribute__ ((__warn_unused_result__));
4187 extern int sscanf (const char *__restrict __s,
4188 const char *__restrict __format, ...) throw ();
4189 # 463 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4
4198 extern int vfscanf (FILE *__restrict __s, const char *__restrict __format,
4199 __gnuc_va_list __arg)
4200 __attribute__ ((__format__ (__scanf__, 2, 0))) __attribute__ ((__warn_unused_result__));
4206 extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg)
4207 __attribute__ ((__format__ (__scanf__, 1, 0))) __attribute__ ((__warn_unused_result__));
4210 extern int vsscanf (const char *__restrict __s,
4211 const char *__restrict __format, __gnuc_va_list __arg)
4212 throw () __attribute__ ((__format__ (__scanf__, 2, 0)));
4213 # 522 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4
4223 extern int fgetc (FILE *__stream);
4224 extern int getc (FILE *__stream);
4230 extern int getchar (void);
4232 # 550 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4
4233 extern int getc_unlocked (FILE *__stream);
4234 extern int getchar_unlocked (void);
4235 # 561 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4
4236 extern int fgetc_unlocked (FILE *__stream);
4248 extern int fputc (int __c, FILE *__stream);
4249 extern int putc (int __c, FILE *__stream);
4255 extern int putchar (int __c);
4257 # 594 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4
4258 extern int fputc_unlocked (int __c, FILE *__stream);
4266 extern int putc_unlocked (int __c, FILE *__stream);
4267 extern int putchar_unlocked (int __c);
4274 extern int getw (FILE *__stream);
4277 extern int putw (int __w, FILE *__stream);
4286 extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
4287 __attribute__ ((__warn_unused_result__));
4288 # 638 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4
4289 extern char *gets (char *__s) __attribute__ ((__warn_unused_result__)) __attribute__ ((__deprecated__));
4292 # 649 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4
4293 extern char *fgets_unlocked (char *__restrict __s, int __n,
4294 FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
4295 # 665 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4
4296 extern __ssize_t __getdelim (char **__restrict __lineptr,
4297 size_t *__restrict __n, int __delimiter,
4298 FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
4299 extern __ssize_t getdelim (char **__restrict __lineptr,
4300 size_t *__restrict __n, int __delimiter,
4301 FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
4309 extern __ssize_t getline (char **__restrict __lineptr,
4310 size_t *__restrict __n,
4311 FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
4320 extern int fputs (const char *__restrict __s, FILE *__restrict __stream);
4326 extern int puts (const char *__s);
4333 extern int ungetc (int __c, FILE *__stream);
4340 extern size_t fread (void *__restrict __ptr, size_t __size,
4341 size_t __n, FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
4346 extern size_t fwrite (const void *__restrict __ptr, size_t __size,
4347 size_t __n, FILE *__restrict __s);
4349 # 726 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4
4350 extern int fputs_unlocked (const char *__restrict __s,
4351 FILE *__restrict __stream);
4352 # 737 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4
4353 extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
4354 size_t __n, FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
4355 extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size,
4356 size_t __n, FILE *__restrict __stream);
4365 extern int fseek (FILE *__stream, long int __off, int __whence);
4370 extern long int ftell (FILE *__stream) __attribute__ ((__warn_unused_result__));
4375 extern void rewind (FILE *__stream);
4377 # 773 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4
4378 extern int fseeko (FILE *__stream, __off_t __off, int __whence);
4383 extern __off_t ftello (FILE *__stream) __attribute__ ((__warn_unused_result__));
4384 # 792 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4
4391 extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);
4396 extern int fsetpos (FILE *__stream, const fpos_t *__pos);
4397 # 815 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4
4401 extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);
4402 extern __off64_t ftello64 (FILE *__stream) __attribute__ ((__warn_unused_result__));
4403 extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos);
4404 extern int fsetpos64 (FILE *__stream, const fpos64_t *__pos);
4409 extern void clearerr (FILE *__stream) throw ();
4411 extern int feof (FILE *__stream) throw () __attribute__ ((__warn_unused_result__));
4413 extern int ferror (FILE *__stream) throw () __attribute__ ((__warn_unused_result__));
4418 extern void clearerr_unlocked (FILE *__stream) throw ();
4419 extern int feof_unlocked (FILE *__stream) throw () __attribute__ ((__warn_unused_result__));
4420 extern int ferror_unlocked (FILE *__stream) throw () __attribute__ ((__warn_unused_result__));
4429 extern void perror (const char *__s);
4436 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/sys_errlist.h" 1 3 4
4437 # 26 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/sys_errlist.h" 3 4
4438 extern int sys_nerr;
4439 extern const char *const sys_errlist[];
4442 extern int _sys_nerr;
4443 extern const char *const _sys_errlist[];
4444 # 854 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 2 3 4
4449 extern int fileno (FILE *__stream) throw () __attribute__ ((__warn_unused_result__));
4454 extern int fileno_unlocked (FILE *__stream) throw () __attribute__ ((__warn_unused_result__));
4455 # 872 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4
4456 extern FILE *popen (const char *__command, const char *__modes) __attribute__ ((__warn_unused_result__));
4462 extern int pclose (FILE *__stream);
4468 extern char *ctermid (char *__s) throw ();
4474 extern char *cuserid (char *__s);
4482 extern int obstack_printf (struct obstack *__restrict __obstack,
4483 const char *__restrict __format, ...)
4484 throw () __attribute__ ((__format__ (__printf__, 2, 3)));
4485 extern int obstack_vprintf (struct obstack *__restrict __obstack,
4486 const char *__restrict __format,
4487 __gnuc_va_list __args)
4488 throw () __attribute__ ((__format__ (__printf__, 2, 0)));
4496 extern void flockfile (FILE *__stream) throw ();
4500 extern int ftrylockfile (FILE *__stream) throw () __attribute__ ((__warn_unused_result__));
4503 extern void funlockfile (FILE *__stream) throw ();
4504 # 933 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 3 4
4505 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/stdio.h" 1 3 4
4506 # 43 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/stdio.h" 3 4
4507 extern __inline __attribute__ ((__gnu_inline__)) int
4510 return _IO_getc (stdin);
4516 extern __inline __attribute__ ((__gnu_inline__)) int
4517 fgetc_unlocked (FILE *__fp)
4519 return (__builtin_expect (((__fp)->_IO_read_ptr >= (__fp)->_IO_read_end), 0) ? __uflow (__fp) : *(unsigned char *) (__fp)->_IO_read_ptr++);
4526 extern __inline __attribute__ ((__gnu_inline__)) int
4527 getc_unlocked (FILE *__fp)
4529 return (__builtin_expect (((__fp)->_IO_read_ptr >= (__fp)->_IO_read_end), 0) ? __uflow (__fp) : *(unsigned char *) (__fp)->_IO_read_ptr++);
4533 extern __inline __attribute__ ((__gnu_inline__)) int
4534 getchar_unlocked (void)
4536 return (__builtin_expect (((stdin)->_IO_read_ptr >= (stdin)->_IO_read_end), 0) ? __uflow (stdin) : *(unsigned char *) (stdin)->_IO_read_ptr++);
4542 extern __inline __attribute__ ((__gnu_inline__)) int
4545 return _IO_putc (__c, stdout);
4551 extern __inline __attribute__ ((__gnu_inline__)) int
4552 fputc_unlocked (int __c, FILE *__stream)
4554 return (__builtin_expect (((__stream)->_IO_write_ptr >= (__stream)->_IO_write_end), 0) ? __overflow (__stream, (unsigned char) (__c)) : (unsigned char) (*(__stream)->_IO_write_ptr++ = (__c)));
4561 extern __inline __attribute__ ((__gnu_inline__)) int
4562 putc_unlocked (int __c, FILE *__stream)
4564 return (__builtin_expect (((__stream)->_IO_write_ptr >= (__stream)->_IO_write_end), 0) ? __overflow (__stream, (unsigned char) (__c)) : (unsigned char) (*(__stream)->_IO_write_ptr++ = (__c)));
4568 extern __inline __attribute__ ((__gnu_inline__)) int
4569 putchar_unlocked (int __c)
4571 return (__builtin_expect (((stdout)->_IO_write_ptr >= (stdout)->_IO_write_end), 0) ? __overflow (stdout, (unsigned char) (__c)) : (unsigned char) (*(stdout)->_IO_write_ptr++ = (__c)));
4578 extern __inline __attribute__ ((__gnu_inline__)) __ssize_t
4579 getline (char **__lineptr, size_t *__n, FILE *__stream)
4581 return __getdelim (__lineptr, __n, '\n', __stream);
4588 extern __inline __attribute__ ((__gnu_inline__)) int
4589 __attribute__ ((__leaf__)) feof_unlocked (FILE *__stream) throw ()
4591 return (((__stream)->_flags & 0x10) != 0);
4595 extern __inline __attribute__ ((__gnu_inline__)) int
4596 __attribute__ ((__leaf__)) ferror_unlocked (FILE *__stream) throw ()
4598 return (((__stream)->_flags & 0x20) != 0);
4600 # 934 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 2 3 4
4603 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/stdio2.h" 1 3 4
4604 # 23 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/stdio2.h" 3 4
4605 extern int __sprintf_chk (char *__restrict __s, int __flag, size_t __slen,
4606 const char *__restrict __format, ...) throw ();
4607 extern int __vsprintf_chk (char *__restrict __s, int __flag, size_t __slen,
4608 const char *__restrict __format,
4609 __gnuc_va_list __ap) throw ();
4612 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int
4613 __attribute__ ((__leaf__)) sprintf (char *__restrict __s, const char *__restrict __fmt, ...) throw ()
4615 return __builtin___sprintf_chk (__s, 2 - 1,
4616 __builtin_object_size (__s, 2 > 1), __fmt, __builtin_va_arg_pack ());
4624 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int
4625 __attribute__ ((__leaf__)) vsprintf (char *__restrict __s, const char *__restrict __fmt, __gnuc_va_list __ap) throw ()
4628 return __builtin___vsprintf_chk (__s, 2 - 1,
4629 __builtin_object_size (__s, 2 > 1), __fmt, __ap);
4634 extern int __snprintf_chk (char *__restrict __s, size_t __n, int __flag,
4635 size_t __slen, const char *__restrict __format,
4637 extern int __vsnprintf_chk (char *__restrict __s, size_t __n, int __flag,
4638 size_t __slen, const char *__restrict __format,
4639 __gnuc_va_list __ap) throw ();
4642 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int
4643 __attribute__ ((__leaf__)) snprintf (char *__restrict __s, size_t __n, const char *__restrict __fmt, ...) throw ()
4646 return __builtin___snprintf_chk (__s, __n, 2 - 1,
4647 __builtin_object_size (__s, 2 > 1), __fmt, __builtin_va_arg_pack ());
4655 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int
4656 __attribute__ ((__leaf__)) vsnprintf (char *__restrict __s, size_t __n, const char *__restrict __fmt, __gnuc_va_list __ap) throw ()
4659 return __builtin___vsnprintf_chk (__s, __n, 2 - 1,
4660 __builtin_object_size (__s, 2 > 1), __fmt, __ap);
4667 extern int __fprintf_chk (FILE *__restrict __stream, int __flag,
4668 const char *__restrict __format, ...);
4669 extern int __printf_chk (int __flag, const char *__restrict __format, ...);
4670 extern int __vfprintf_chk (FILE *__restrict __stream, int __flag,
4671 const char *__restrict __format, __gnuc_va_list __ap);
4672 extern int __vprintf_chk (int __flag, const char *__restrict __format,
4673 __gnuc_va_list __ap);
4676 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int
4677 fprintf (FILE *__restrict __stream, const char *__restrict __fmt, ...)
4679 return __fprintf_chk (__stream, 2 - 1, __fmt,
4680 __builtin_va_arg_pack ());
4683 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int
4684 printf (const char *__restrict __fmt, ...)
4686 return __printf_chk (2 - 1, __fmt, __builtin_va_arg_pack ());
4695 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int
4696 vprintf (const char *__restrict __fmt, __gnuc_va_list __ap)
4699 return __vfprintf_chk (stdout, 2 - 1, __fmt, __ap);
4705 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int
4706 vfprintf (FILE *__restrict __stream,
4707 const char *__restrict __fmt, __gnuc_va_list __ap)
4709 return __vfprintf_chk (__stream, 2 - 1, __fmt, __ap);
4713 extern int __dprintf_chk (int __fd, int __flag, const char *__restrict __fmt,
4714 ...) __attribute__ ((__format__ (__printf__, 3, 4)));
4715 extern int __vdprintf_chk (int __fd, int __flag,
4716 const char *__restrict __fmt, __gnuc_va_list __arg)
4717 __attribute__ ((__format__ (__printf__, 3, 0)));
4720 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int
4721 dprintf (int __fd, const char *__restrict __fmt, ...)
4723 return __dprintf_chk (__fd, 2 - 1, __fmt,
4724 __builtin_va_arg_pack ());
4731 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int
4732 vdprintf (int __fd, const char *__restrict __fmt, __gnuc_va_list __ap)
4734 return __vdprintf_chk (__fd, 2 - 1, __fmt, __ap);
4740 extern int __asprintf_chk (char **__restrict __ptr, int __flag,
4741 const char *__restrict __fmt, ...)
4742 throw () __attribute__ ((__format__ (__printf__, 3, 4))) __attribute__ ((__warn_unused_result__));
4743 extern int __vasprintf_chk (char **__restrict __ptr, int __flag,
4744 const char *__restrict __fmt, __gnuc_va_list __arg)
4745 throw () __attribute__ ((__format__ (__printf__, 3, 0))) __attribute__ ((__warn_unused_result__));
4746 extern int __obstack_printf_chk (struct obstack *__restrict __obstack,
4747 int __flag, const char *__restrict __format,
4749 throw () __attribute__ ((__format__ (__printf__, 3, 4)));
4750 extern int __obstack_vprintf_chk (struct obstack *__restrict __obstack,
4752 const char *__restrict __format,
4753 __gnuc_va_list __args)
4754 throw () __attribute__ ((__format__ (__printf__, 3, 0)));
4757 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int
4758 __attribute__ ((__leaf__)) asprintf (char **__restrict __ptr, const char *__restrict __fmt, ...) throw ()
4760 return __asprintf_chk (__ptr, 2 - 1, __fmt,
4761 __builtin_va_arg_pack ());
4764 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int
4765 __attribute__ ((__leaf__)) __asprintf (char **__restrict __ptr, const char *__restrict __fmt, ...) throw ()
4768 return __asprintf_chk (__ptr, 2 - 1, __fmt,
4769 __builtin_va_arg_pack ());
4772 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int
4773 __attribute__ ((__leaf__)) obstack_printf (struct obstack *__restrict __obstack, const char *__restrict __fmt, ...) throw ()
4776 return __obstack_printf_chk (__obstack, 2 - 1, __fmt,
4777 __builtin_va_arg_pack ());
4779 # 206 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/stdio2.h" 3 4
4780 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int
4781 __attribute__ ((__leaf__)) vasprintf (char **__restrict __ptr, const char *__restrict __fmt, __gnuc_va_list __ap) throw ()
4784 return __vasprintf_chk (__ptr, 2 - 1, __fmt, __ap);
4787 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) int
4788 __attribute__ ((__leaf__)) obstack_vprintf (struct obstack *__restrict __obstack, const char *__restrict __fmt, __gnuc_va_list __ap) throw ()
4791 return __obstack_vprintf_chk (__obstack, 2 - 1, __fmt,
4794 # 241 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/stdio2.h" 3 4
4795 extern char *__fgets_chk (char *__restrict __s, size_t __size, int __n,
4796 FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
4797 extern char *__fgets_alias (char *__restrict __s, int __n, FILE *__restrict __stream) __asm__ ("" "fgets")
4799 __attribute__ ((__warn_unused_result__));
4800 extern char *__fgets_chk_warn (char *__restrict __s, size_t __size, int __n, FILE *__restrict __stream) __asm__ ("" "__fgets_chk")
4803 __attribute__ ((__warn_unused_result__)) __attribute__((__warning__ ("fgets called with bigger size than length " "of destination buffer")))
4806 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__)) char *
4807 fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
4809 if (__builtin_object_size (__s, 2 > 1) != (size_t) -1)
4811 if (!__builtin_constant_p (__n) || __n <= 0)
4812 return __fgets_chk (__s, __builtin_object_size (__s, 2 > 1), __n, __stream);
4814 if ((size_t) __n > __builtin_object_size (__s, 2 > 1))
4815 return __fgets_chk_warn (__s, __builtin_object_size (__s, 2 > 1), __n, __stream);
4817 return __fgets_alias (__s, __n, __stream);
4820 extern size_t __fread_chk (void *__restrict __ptr, size_t __ptrlen,
4821 size_t __size, size_t __n,
4822 FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
4823 extern size_t __fread_alias (void *__restrict __ptr, size_t __size, size_t __n, FILE *__restrict __stream) __asm__ ("" "fread")
4826 __attribute__ ((__warn_unused_result__));
4827 extern size_t __fread_chk_warn (void *__restrict __ptr, size_t __ptrlen, size_t __size, size_t __n, FILE *__restrict __stream) __asm__ ("" "__fread_chk")
4832 __attribute__ ((__warn_unused_result__)) __attribute__((__warning__ ("fread called with bigger size * nmemb than length " "of destination buffer")))
4835 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__)) size_t
4836 fread (void *__restrict __ptr, size_t __size, size_t __n,
4837 FILE *__restrict __stream)
4839 if (__builtin_object_size (__ptr, 0) != (size_t) -1)
4841 if (!__builtin_constant_p (__size)
4842 || !__builtin_constant_p (__n)
4843 || (__size | __n) >= (((size_t) 1) << (8 * sizeof (size_t) / 2)))
4844 return __fread_chk (__ptr, __builtin_object_size (__ptr, 0), __size, __n, __stream);
4846 if (__size * __n > __builtin_object_size (__ptr, 0))
4847 return __fread_chk_warn (__ptr, __builtin_object_size (__ptr, 0), __size, __n, __stream);
4849 return __fread_alias (__ptr, __size, __n, __stream);
4853 extern char *__fgets_unlocked_chk (char *__restrict __s, size_t __size,
4854 int __n, FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
4855 extern char *__fgets_unlocked_alias (char *__restrict __s, int __n, FILE *__restrict __stream) __asm__ ("" "fgets_unlocked")
4857 __attribute__ ((__warn_unused_result__));
4858 extern char *__fgets_unlocked_chk_warn (char *__restrict __s, size_t __size, int __n, FILE *__restrict __stream) __asm__ ("" "__fgets_unlocked_chk")
4861 __attribute__ ((__warn_unused_result__)) __attribute__((__warning__ ("fgets_unlocked called with bigger size than length " "of destination buffer")))
4864 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__)) char *
4865 fgets_unlocked (char *__restrict __s, int __n, FILE *__restrict __stream)
4867 if (__builtin_object_size (__s, 2 > 1) != (size_t) -1)
4869 if (!__builtin_constant_p (__n) || __n <= 0)
4870 return __fgets_unlocked_chk (__s, __builtin_object_size (__s, 2 > 1), __n, __stream);
4872 if ((size_t) __n > __builtin_object_size (__s, 2 > 1))
4873 return __fgets_unlocked_chk_warn (__s, __builtin_object_size (__s, 2 > 1), __n, __stream);
4875 return __fgets_unlocked_alias (__s, __n, __stream);
4881 extern size_t __fread_unlocked_chk (void *__restrict __ptr, size_t __ptrlen,
4882 size_t __size, size_t __n,
4883 FILE *__restrict __stream) __attribute__ ((__warn_unused_result__));
4884 extern size_t __fread_unlocked_alias (void *__restrict __ptr, size_t __size, size_t __n, FILE *__restrict __stream) __asm__ ("" "fread_unlocked")
4887 __attribute__ ((__warn_unused_result__));
4888 extern size_t __fread_unlocked_chk_warn (void *__restrict __ptr, size_t __ptrlen, size_t __size, size_t __n, FILE *__restrict __stream) __asm__ ("" "__fread_unlocked_chk")
4893 __attribute__ ((__warn_unused_result__)) __attribute__((__warning__ ("fread_unlocked called with bigger size * nmemb than " "length of destination buffer")))
4896 extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__)) __attribute__ ((__artificial__)) __attribute__ ((__warn_unused_result__)) size_t
4897 fread_unlocked (void *__restrict __ptr, size_t __size, size_t __n,
4898 FILE *__restrict __stream)
4900 if (__builtin_object_size (__ptr, 0) != (size_t) -1)
4902 if (!__builtin_constant_p (__size)
4903 || !__builtin_constant_p (__n)
4904 || (__size | __n) >= (((size_t) 1) << (8 * sizeof (size_t) / 2)))
4905 return __fread_unlocked_chk (__ptr, __builtin_object_size (__ptr, 0), __size, __n,
4908 if (__size * __n > __builtin_object_size (__ptr, 0))
4909 return __fread_unlocked_chk_warn (__ptr, __builtin_object_size (__ptr, 0), __size, __n,
4914 if (__builtin_constant_p (__size)
4915 && __builtin_constant_p (__n)
4916 && (__size | __n) < (((size_t) 1) << (8 * sizeof (size_t) / 2))
4917 && __size * __n <= 8)
4919 size_t __cnt = __size * __n;
4920 char *__cptr = (char *) __ptr;
4924 for (; __cnt > 0; --__cnt)
4926 int __c = (__builtin_expect (((__stream)->_IO_read_ptr >= (__stream)->_IO_read_end), 0) ? __uflow (__stream) : *(unsigned char *) (__stream)->_IO_read_ptr++);
4931 return (__cptr - (char *) __ptr) / __size;
4934 return __fread_unlocked_alias (__ptr, __size, __n, __stream);
4936 # 937 "/usr/powerpc64-unknown-linux-gnu/usr/include/stdio.h" 2 3 4
4944 # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stdarg.h" 1 3 4
4954 extern __attribute__((visibility ("default"))) JSUint32 JS_snprintf(char *out, JSUint32 outlen, const char *fmt, ...);
4961 extern __attribute__((visibility ("default"))) char* JS_smprintf(const char *fmt, ...);
4966 extern __attribute__((visibility ("default"))) void JS_smprintf_free(char *mem);
4968 extern __attribute__((visibility ("default"))) char* JS_sprintf_append(char *last, const char *fmt, ...);
4970 typedef JSIntn (*JSStuffFunc)(void *arg, const char *s, JSUint32 slen);
4972 extern __attribute__((visibility ("default"))) JSUint32 JS_sxprintf(JSStuffFunc f, void *arg, const char *fmt, ...);
4977 extern __attribute__((visibility ("default"))) JSUint32 JS_vsnprintf(char *out, JSUint32 outlen, const char *fmt, va_list ap);
4978 extern __attribute__((visibility ("default"))) char* JS_vsmprintf(const char *fmt, va_list ap);
4979 extern __attribute__((visibility ("default"))) char* JS_vsprintf_append(char *last, const char *fmt, va_list ap);
4980 extern __attribute__((visibility ("default"))) JSUint32 JS_vsxprintf(JSStuffFunc f, void *arg, const char *fmt, va_list ap);
4982 extern __attribute__((visibility ("default"))) JSInt32 JS_sscanf(const char *buf, const char *fmt, ...);
4989 # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4
5001 JSVAL_TYPE_DOUBLE = 0x00,
5002 JSVAL_TYPE_INT32 = 0x01,
5003 JSVAL_TYPE_UNDEFINED = 0x02,
5004 JSVAL_TYPE_BOOLEAN = 0x03,
5005 JSVAL_TYPE_MAGIC = 0x04,
5006 JSVAL_TYPE_STRING = 0x05,
5007 JSVAL_TYPE_NULL = 0x06,
5008 JSVAL_TYPE_OBJECT = 0x07,
5012 JSVAL_TYPE_NONFUNOBJ = 0x57,
5013 JSVAL_TYPE_FUNOBJ = 0x67,
5015 JSVAL_TYPE_STRORNULL = 0x97,
5016 JSVAL_TYPE_OBJORNULL = 0x98,
5018 JSVAL_TYPE_BOXED = 0x99
5019 } __attribute__((packed));
5021 typedef int js_static_assert0[(sizeof(JSValueType) == 1) ? 1 : -1];
5025 JSVAL_TAG_MAX_DOUBLE = 0x1FFF0,
5026 JSVAL_TAG_INT32 = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_INT32,
5027 JSVAL_TAG_UNDEFINED = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_UNDEFINED,
5028 JSVAL_TAG_STRING = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_STRING,
5029 JSVAL_TAG_BOOLEAN = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_BOOLEAN,
5030 JSVAL_TAG_MAGIC = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_MAGIC,
5031 JSVAL_TAG_NULL = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_NULL,
5032 JSVAL_TAG_OBJECT = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_OBJECT
5033 } __attribute__((packed));
5035 typedef int js_static_assert1[(sizeof(JSValueTag) == sizeof(uint32)) ? 1 : -1];
5037 enum JSValueShiftedTag
5039 JSVAL_SHIFTED_TAG_MAX_DOUBLE = ((((uint64)JSVAL_TAG_MAX_DOUBLE) << 47) | 0xFFFFFFFF),
5040 JSVAL_SHIFTED_TAG_INT32 = (((uint64)JSVAL_TAG_INT32) << 47),
5041 JSVAL_SHIFTED_TAG_UNDEFINED = (((uint64)JSVAL_TAG_UNDEFINED) << 47),
5042 JSVAL_SHIFTED_TAG_STRING = (((uint64)JSVAL_TAG_STRING) << 47),
5043 JSVAL_SHIFTED_TAG_BOOLEAN = (((uint64)JSVAL_TAG_BOOLEAN) << 47),
5044 JSVAL_SHIFTED_TAG_MAGIC = (((uint64)JSVAL_TAG_MAGIC) << 47),
5045 JSVAL_SHIFTED_TAG_NULL = (((uint64)JSVAL_TAG_NULL) << 47),
5046 JSVAL_SHIFTED_TAG_OBJECT = (((uint64)JSVAL_TAG_OBJECT) << 47)
5047 } __attribute__((packed));
5049 typedef int js_static_assert2[(sizeof(JSValueShiftedTag) == sizeof(uint64)) ? 1 : -1];
5051 typedef enum JSWhyMagic
5055 JS_NATIVE_ENUMERATE,
5059 JS_GENERATOR_CLOSING,
5063 JS_SERIALIZE_NO_NODE,
5067 typedef struct JSString JSString;
5068 typedef struct JSFlatString JSFlatString;
5069 typedef struct JSObject JSObject;
5071 typedef union jsval_layout
5077 uint64 payload47 : 47;
5078 JSValueTag tag : 17;
5093 static __attribute__((always_inline)) inline JSBool
5094 JSVAL_IS_DOUBLE_IMPL(jsval_layout l)
5096 return l.asBits <= JSVAL_SHIFTED_TAG_MAX_DOUBLE;
5099 static __attribute__((always_inline)) inline jsval_layout
5100 DOUBLE_TO_JSVAL_IMPL(double d)
5108 static __attribute__((always_inline)) inline JSBool
5109 JSVAL_IS_INT32_IMPL(jsval_layout l)
5111 return (uint32)(l.asBits >> 47) == JSVAL_TAG_INT32;
5114 static __attribute__((always_inline)) inline int32
5115 JSVAL_TO_INT32_IMPL(jsval_layout l)
5117 return (int32)l.asBits;
5120 static __attribute__((always_inline)) inline jsval_layout
5121 INT32_TO_JSVAL_IMPL(int32 i32)
5124 l.asBits = ((uint64)(uint32)i32) | JSVAL_SHIFTED_TAG_INT32;
5128 static __attribute__((always_inline)) inline JSBool
5129 JSVAL_IS_NUMBER_IMPL(jsval_layout l)
5131 return l.asBits < JSVAL_SHIFTED_TAG_UNDEFINED;
5134 static __attribute__((always_inline)) inline JSBool
5135 JSVAL_IS_UNDEFINED_IMPL(jsval_layout l)
5137 return l.asBits == JSVAL_SHIFTED_TAG_UNDEFINED;
5140 static __attribute__((always_inline)) inline JSBool
5141 JSVAL_IS_STRING_IMPL(jsval_layout l)
5143 return (uint32)(l.asBits >> 47) == JSVAL_TAG_STRING;
5146 static __attribute__((always_inline)) inline jsval_layout
5147 STRING_TO_JSVAL_IMPL(JSString *str)
5150 uint64 strBits = (uint64)str;
5153 l.asBits = strBits | JSVAL_SHIFTED_TAG_STRING;
5157 static __attribute__((always_inline)) inline JSString *
5158 JSVAL_TO_STRING_IMPL(jsval_layout l)
5160 return (JSString *)(l.asBits & 0x00007FFFFFFFFFFFLL);
5163 static __attribute__((always_inline)) inline JSBool
5164 JSVAL_IS_BOOLEAN_IMPL(jsval_layout l)
5166 return (uint32)(l.asBits >> 47) == JSVAL_TAG_BOOLEAN;
5169 static __attribute__((always_inline)) inline JSBool
5170 JSVAL_TO_BOOLEAN_IMPL(jsval_layout l)
5172 return (JSBool)l.asBits;
5175 static __attribute__((always_inline)) inline jsval_layout
5176 BOOLEAN_TO_JSVAL_IMPL(JSBool b)
5179 l.asBits = ((uint64)(uint32)b) | JSVAL_SHIFTED_TAG_BOOLEAN;
5183 static __attribute__((always_inline)) inline JSBool
5184 JSVAL_IS_MAGIC_IMPL(jsval_layout l)
5186 return (l.asBits >> 47) == JSVAL_TAG_MAGIC;
5189 static __attribute__((always_inline)) inline JSObject *
5190 MAGIC_JSVAL_TO_OBJECT_OR_NULL_IMPL(jsval_layout l)
5192 uint64 ptrBits = l.asBits & 0x00007FFFFFFFFFFFLL;
5195 return (JSObject *)ptrBits;
5198 static __attribute__((always_inline)) inline JSBool
5199 JSVAL_IS_PRIMITIVE_IMPL(jsval_layout l)
5201 return l.asBits < JSVAL_SHIFTED_TAG_OBJECT;
5204 static __attribute__((always_inline)) inline JSBool
5205 JSVAL_IS_OBJECT_IMPL(jsval_layout l)
5208 return l.asBits >= JSVAL_SHIFTED_TAG_OBJECT;
5211 static __attribute__((always_inline)) inline JSBool
5212 JSVAL_IS_OBJECT_OR_NULL_IMPL(jsval_layout l)
5215 return l.asBits >= JSVAL_SHIFTED_TAG_NULL;
5218 static __attribute__((always_inline)) inline JSObject *
5219 JSVAL_TO_OBJECT_IMPL(jsval_layout l)
5221 uint64 ptrBits = l.asBits & 0x00007FFFFFFFFFFFLL;
5223 return (JSObject *)ptrBits;
5226 static __attribute__((always_inline)) inline jsval_layout
5227 OBJECT_TO_JSVAL_IMPL(JSObject *obj)
5230 uint64 objBits = (uint64)obj;
5233 l.asBits = objBits | JSVAL_SHIFTED_TAG_OBJECT;
5237 static __attribute__((always_inline)) inline JSBool
5238 JSVAL_IS_NULL_IMPL(jsval_layout l)
5240 return l.asBits == JSVAL_SHIFTED_TAG_NULL;
5243 static __attribute__((always_inline)) inline JSBool
5244 JSVAL_IS_GCTHING_IMPL(jsval_layout l)
5246 return l.asBits >= JSVAL_SHIFTED_TAG_STRING;
5249 static __attribute__((always_inline)) inline void *
5250 JSVAL_TO_GCTHING_IMPL(jsval_layout l)
5252 uint64 ptrBits = l.asBits & 0x00007FFFFFFFFFFFLL;
5254 return (void *)ptrBits;
5257 static __attribute__((always_inline)) inline JSBool
5258 JSVAL_IS_TRACEABLE_IMPL(jsval_layout l)
5260 return JSVAL_IS_GCTHING_IMPL(l) && !JSVAL_IS_NULL_IMPL(l);
5263 static __attribute__((always_inline)) inline uint32
5264 JSVAL_TRACE_KIND_IMPL(jsval_layout l)
5266 return (uint32)(JSBool)!(JSVAL_IS_OBJECT_IMPL(l));
5269 static __attribute__((always_inline)) inline jsval_layout
5270 PRIVATE_PTR_TO_JSVAL_IMPL(void *ptr)
5273 uint64 ptrBits = (uint64)ptr;
5275 l.asBits = ptrBits >> 1;
5280 static __attribute__((always_inline)) inline void *
5281 JSVAL_TO_PRIVATE_PTR_IMPL(jsval_layout l)
5284 return (void *)(l.asBits << 1);
5289 static __attribute__((always_inline)) inline double
5290 JS_CANONICALIZE_NAN(double d)
5292 if ((__builtin_expect((d != d), 0))) {
5294 l.asBits = 0x7FF8000000000000LL;
5300 typedef __attribute__((aligned (8))) uint64 jsval;
5301 typedef ptrdiff_t jsid;
5309 typedef JSInt32 jsint;
5310 typedef JSUint32 jsuint;
5311 typedef float64 jsdouble;
5312 typedef JSInt32 jsrefcount;
5317 typedef JSUint16 jschar;
5319 typedef enum JSVersion {
5320 JSVERSION_1_0 = 100,
5321 JSVERSION_1_1 = 110,
5322 JSVERSION_1_2 = 120,
5323 JSVERSION_1_3 = 130,
5324 JSVERSION_1_4 = 140,
5325 JSVERSION_ECMA_3 = 148,
5326 JSVERSION_1_5 = 150,
5327 JSVERSION_1_6 = 160,
5328 JSVERSION_1_7 = 170,
5329 JSVERSION_1_8 = 180,
5330 JSVERSION_ECMA_5 = 185,
5331 JSVERSION_DEFAULT = 0,
5332 JSVERSION_UNKNOWN = -1,
5333 JSVERSION_LATEST = JSVERSION_ECMA_5
5340 typedef enum JSType {
5353 typedef enum JSProtoKey {
5358 # 40 "jsproto.tbl" 2
5362 JSProto_Function = 2,
5364 JSProto_Boolean = 4,
5370 JSProto_RegExp = 10,
5372 JSProto_Namespace = 12,
5374 JSProto_Reflect = 14,
5375 JSProto_ASTNode = 15,
5377 JSProto_InternalError = 17,
5378 JSProto_EvalError = 18,
5379 JSProto_RangeError = 19,
5380 JSProto_ReferenceError = 20,
5381 JSProto_SyntaxError = 21,
5382 JSProto_TypeError = 22,
5383 JSProto_URIError = 23,
5384 JSProto_Generator = 24,
5385 JSProto_Iterator = 25,
5386 JSProto_StopIteration = 26,
5387 JSProto_ArrayBuffer = 27,
5388 JSProto_Int8Array = 28,
5389 JSProto_Uint8Array = 29,
5390 JSProto_Int16Array = 30,
5391 JSProto_Uint16Array = 31,
5392 JSProto_Int32Array = 32,
5393 JSProto_Uint32Array = 33,
5394 JSProto_Float32Array = 34,
5395 JSProto_Float64Array = 35,
5396 JSProto_Uint8ClampedArray = 36,
5398 JSProto_AnyName = 38,
5405 typedef enum JSAccessMode {
5426 typedef enum JSIterateOp {
5431 JSENUMERATE_INIT_ALL,
5441 typedef struct JSClass JSClass;
5442 typedef struct JSConstDoubleSpec JSConstDoubleSpec;
5443 typedef struct JSContext JSContext;
5444 typedef struct JSErrorReport JSErrorReport;
5445 typedef struct JSFunction JSFunction;
5446 typedef struct JSFunctionSpec JSFunctionSpec;
5447 typedef struct JSTracer JSTracer;
5448 typedef struct JSIdArray JSIdArray;
5449 typedef struct JSPropertyDescriptor JSPropertyDescriptor;
5450 typedef struct JSPropertySpec JSPropertySpec;
5451 typedef struct JSObjectMap JSObjectMap;
5452 typedef struct JSRuntime JSRuntime;
5453 typedef struct JSStackFrame JSStackFrame;
5454 typedef struct JSXDRState JSXDRState;
5455 typedef struct JSExceptionState JSExceptionState;
5456 typedef struct JSLocaleCallbacks JSLocaleCallbacks;
5457 typedef struct JSSecurityCallbacks JSSecurityCallbacks;
5458 typedef struct JSONParser JSONParser;
5459 typedef struct JSCompartment JSCompartment;
5460 typedef struct JSCrossCompartmentCall JSCrossCompartmentCall;
5461 typedef struct JSStructuredCloneWriter JSStructuredCloneWriter;
5462 typedef struct JSStructuredCloneReader JSStructuredCloneReader;
5463 typedef struct JSStructuredCloneCallbacks JSStructuredCloneCallbacks;
5466 typedef class JSWrapper JSWrapper;
5467 typedef class JSCrossCompartmentWrapper JSCrossCompartmentWrapper;
5470 (* JSPropertyOp)(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
5473 (* JSStrictPropertyOp)(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp);
5476 (* JSNewEnumerateOp)(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
5477 jsval *statep, jsid *idp);
5484 (* JSEnumerateOp)(JSContext *cx, JSObject *obj);
5487 (* JSResolveOp)(JSContext *cx, JSObject *obj, jsid id);
5490 (* JSNewResolveOp)(JSContext *cx, JSObject *obj, jsid id, uintN flags,
5498 (* JSConvertOp)(JSContext *cx, JSObject *obj, JSType type, jsval *vp);
5504 (* JSTypeOfOp)(JSContext *cx, JSObject *obj);
5512 (* JSFinalizeOp)(JSContext *cx, JSObject *obj);
5519 (* JSStringFinalizeOp)(JSContext *cx, JSString *str);
5528 (* JSCheckAccessOp)(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
5536 (* JSXDRObjectOp)(JSXDRState *xdr, JSObject **objp);
5544 (* JSHasInstanceOp)(JSContext *cx, JSObject *obj, const jsval *v, JSBool *bp);
5552 (* JSMarkOp)(JSContext *cx, JSObject *obj, void *arg);
5555 (* JSTraceOp)(JSTracer *trc, JSObject *obj);
5558 (* JSTraceCallback)(JSTracer *trc, void *thing, uint32 kind);
5565 (* JSTraceNamePrinter)(JSTracer *trc, char *buf, size_t bufsize);
5568 (* JSEqualityOp)(JSContext *cx, JSObject *obj, const jsval *v, JSBool *bp);
5577 (* JSNative)(JSContext *cx, uintN argc, jsval *vp);
5581 typedef enum JSContextOp {
5587 (* JSContextCallback)(JSContext *cx, uintN contextOp);
5594 typedef enum JSGCStatus {
5602 (* JSGCCallback)(JSContext *cx, JSGCStatus status);
5609 (* JSTraceDataOp)(JSTracer *trc, void *data);
5612 (* JSOperationCallback)(JSContext *cx);
5615 (* JSErrorReporter)(JSContext *cx, const char *message, JSErrorReport *report);
5622 typedef enum JSExnType {
5635 typedef struct JSErrorFormatString {
5644 } JSErrorFormatString;
5646 typedef const JSErrorFormatString *
5647 (* JSErrorCallback)(void *userRef, const char *locale,
5648 const uintN errorNumber);
5654 (* JSArgumentFormatter)(JSContext *cx, const char *format, JSBool fromJS,
5655 jsval **vpp, va_list *app);
5659 (* JSLocaleToUpperCase)(JSContext *cx, JSString *src, jsval *rval);
5662 (* JSLocaleToLowerCase)(JSContext *cx, JSString *src, jsval *rval);
5665 (* JSLocaleCompare)(JSContext *cx, JSString *src1, JSString *src2,
5669 (* JSLocaleToUnicode)(JSContext *cx, const char *src, jsval *rval);
5674 typedef struct JSPrincipals JSPrincipals;
5677 (* JSPrincipalsTranscoder)(JSXDRState *xdr, JSPrincipals **principalsp);
5679 typedef JSPrincipals *
5680 (* JSObjectPrincipalsFinder)(JSContext *cx, JSObject *obj);
5687 (* JSCSPEvalChecker)(JSContext *cx);
5695 (* JSWrapObjectCallback)(JSContext *cx, JSObject *obj, JSObject *proto, JSObject *parent,
5704 (* JSPreWrapCallback)(JSContext *cx, JSObject *scope, JSObject *obj, uintN flags);
5708 JSCOMPARTMENT_DESTROY
5712 (* JSCompartmentCallback)(JSContext *cx, JSCompartment *compartment, uintN compartmentOp);
5714 typedef JSObject *(*ReadStructuredCloneOp)(JSContext *cx, JSStructuredCloneReader *r,
5715 uint32 tag, uint32 data, void *closure);
5717 typedef JSBool (*WriteStructuredCloneOp)(JSContext *cx, JSStructuredCloneWriter *w,
5718 JSObject *obj, void *closure);
5725 typedef void (*StructuredCloneErrorOp)(JSContext *cx, uint32 errorid);
5733 static __attribute__((always_inline)) inline JSBool
5734 JSVAL_IS_NULL(jsval v)
5738 return JSVAL_IS_NULL_IMPL(l);
5741 static __attribute__((always_inline)) inline JSBool
5742 JSVAL_IS_VOID(jsval v)
5746 return JSVAL_IS_UNDEFINED_IMPL(l);
5749 static __attribute__((always_inline)) inline JSBool
5750 JSVAL_IS_INT(jsval v)
5754 return JSVAL_IS_INT32_IMPL(l);
5757 static __attribute__((always_inline)) inline jsint
5758 JSVAL_TO_INT(jsval v)
5763 return JSVAL_TO_INT32_IMPL(l);
5770 static __attribute__((always_inline)) inline jsval
5771 INT_TO_JSVAL(int32 i)
5773 return ((INT32_TO_JSVAL_IMPL(i)).asBits);
5776 static __attribute__((always_inline)) inline JSBool
5777 JSVAL_IS_DOUBLE(jsval v)
5781 return JSVAL_IS_DOUBLE_IMPL(l);
5784 static __attribute__((always_inline)) inline jsdouble
5785 JSVAL_TO_DOUBLE(jsval v)
5793 static __attribute__((always_inline)) inline jsval
5794 DOUBLE_TO_JSVAL(jsdouble d)
5796 d = JS_CANONICALIZE_NAN(d);
5797 return ((DOUBLE_TO_JSVAL_IMPL(d)).asBits);
5800 static __attribute__((always_inline)) inline jsval
5801 UINT_TO_JSVAL(uint32 i)
5803 if (i <= ((jsint)0x7fffffff))
5804 return INT_TO_JSVAL((int32)i);
5805 return DOUBLE_TO_JSVAL((jsdouble)i);
5808 static __attribute__((always_inline)) inline JSBool
5809 JSVAL_IS_NUMBER(jsval v)
5813 return JSVAL_IS_NUMBER_IMPL(l);
5816 static __attribute__((always_inline)) inline JSBool
5817 JSVAL_IS_STRING(jsval v)
5821 return JSVAL_IS_STRING_IMPL(l);
5824 static __attribute__((always_inline)) inline JSString *
5825 JSVAL_TO_STRING(jsval v)
5830 return JSVAL_TO_STRING_IMPL(l);
5833 static __attribute__((always_inline)) inline jsval
5834 STRING_TO_JSVAL(JSString *str)
5836 return ((STRING_TO_JSVAL_IMPL(str)).asBits);
5839 static __attribute__((always_inline)) inline JSBool
5840 JSVAL_IS_OBJECT(jsval v)
5844 return JSVAL_IS_OBJECT_OR_NULL_IMPL(l);
5847 static __attribute__((always_inline)) inline JSObject *
5848 JSVAL_TO_OBJECT(jsval v)
5853 return JSVAL_TO_OBJECT_IMPL(l);
5856 static __attribute__((always_inline)) inline jsval
5857 OBJECT_TO_JSVAL(JSObject *obj)
5860 return ((OBJECT_TO_JSVAL_IMPL(obj)).asBits);
5861 return ((((uint64)(uint32)(JSVAL_TAG_NULL)) << 47) | (0));
5864 static __attribute__((always_inline)) inline JSBool
5865 JSVAL_IS_BOOLEAN(jsval v)
5869 return JSVAL_IS_BOOLEAN_IMPL(l);
5872 static __attribute__((always_inline)) inline JSBool
5873 JSVAL_TO_BOOLEAN(jsval v)
5878 return JSVAL_TO_BOOLEAN_IMPL(l);
5881 static __attribute__((always_inline)) inline jsval
5882 BOOLEAN_TO_JSVAL(JSBool b)
5884 return ((BOOLEAN_TO_JSVAL_IMPL(b)).asBits);
5887 static __attribute__((always_inline)) inline JSBool
5888 JSVAL_IS_PRIMITIVE(jsval v)
5892 return JSVAL_IS_PRIMITIVE_IMPL(l);
5895 static __attribute__((always_inline)) inline JSBool
5896 JSVAL_IS_GCTHING(jsval v)
5900 return JSVAL_IS_GCTHING_IMPL(l);
5903 static __attribute__((always_inline)) inline void *
5904 JSVAL_TO_GCTHING(jsval v)
5909 return JSVAL_TO_GCTHING_IMPL(l);
5914 static __attribute__((always_inline)) inline jsval
5915 PRIVATE_TO_JSVAL(void *ptr)
5917 return ((PRIVATE_PTR_TO_JSVAL_IMPL(ptr)).asBits);
5920 static __attribute__((always_inline)) inline void *
5921 JSVAL_TO_PRIVATE(jsval v)
5926 return JSVAL_TO_PRIVATE_PTR_IMPL(l);
5929 static __attribute__((always_inline)) inline JSBool
5930 JSID_IS_STRING(jsid iden)
5932 return ((iden) & 0x7) == 0;
5935 static __attribute__((always_inline)) inline JSString *
5936 JSID_TO_STRING(jsid iden)
5939 return (JSString *)((iden));
5942 static __attribute__((always_inline)) inline JSBool
5943 JSID_IS_ZERO(jsid iden)
5948 __attribute__((visibility ("default"))) JSBool
5949 JS_StringHasBeenInterned(JSString *str);
5952 static __attribute__((always_inline)) inline jsid
5953 INTERNED_STRING_TO_JSID(JSString *str)
5959 (iden) = (size_t)str;
5963 static __attribute__((always_inline)) inline JSBool
5964 JSID_IS_INT(jsid iden)
5966 return !!((iden) & 0x1);
5969 static __attribute__((always_inline)) inline int32
5970 JSID_TO_INT(jsid iden)
5973 return ((int32)(iden)) >> 1;
5976 static __attribute__((always_inline)) inline JSBool
5977 INT_FITS_IN_JSID(int32 i)
5979 return ((jsuint)(i) - (jsuint)(-(1 << 30)) <=
5980 (jsuint)(((1 << 30) - 1) - (-(1 << 30))));
5983 static __attribute__((always_inline)) inline jsid
5984 INT_TO_JSID(int32 i)
5988 (iden) = ((i << 1) | 0x1);
5992 static __attribute__((always_inline)) inline JSBool
5993 JSID_IS_OBJECT(jsid iden)
5995 return ((iden) & 0x7) == 0x4 &&
5996 (size_t)(iden) != 0x4;
5999 static __attribute__((always_inline)) inline JSObject *
6000 JSID_TO_OBJECT(jsid iden)
6003 return (JSObject *)((iden) & ~(size_t)0x7);
6006 static __attribute__((always_inline)) inline jsid
6007 OBJECT_TO_JSID(JSObject *obj)
6012 (iden) = ((size_t)obj | 0x4);
6016 static __attribute__((always_inline)) inline JSBool
6017 JSID_IS_GCTHING(jsid iden)
6019 return JSID_IS_STRING(iden) || JSID_IS_OBJECT(iden);
6022 static __attribute__((always_inline)) inline void *
6023 JSID_TO_GCTHING(jsid iden)
6025 return (void *)((iden) & ~(size_t)0x7);
6033 static __attribute__((always_inline)) inline JSBool
6034 JSID_IS_DEFAULT_XML_NAMESPACE(jsid iden)
6038 return ((size_t)(iden) == 0x6);
6041 static __attribute__((always_inline)) inline JSBool
6042 JSID_IS_VOID(jsid iden)
6046 return ((size_t)(iden) == 0x2);
6049 static __attribute__((always_inline)) inline JSBool
6050 JSID_IS_EMPTY(jsid iden)
6052 return ((size_t)(iden) == 0x4);
6055 extern __attribute__((visibility ("default"))) int64
6059 extern __attribute__((visibility ("default"))) jsval
6060 JS_GetNaNValue(JSContext *cx);
6062 extern __attribute__((visibility ("default"))) jsval
6063 JS_GetNegativeInfinityValue(JSContext *cx);
6065 extern __attribute__((visibility ("default"))) jsval
6066 JS_GetPositiveInfinityValue(JSContext *cx);
6068 extern __attribute__((visibility ("default"))) jsval
6069 JS_GetEmptyStringValue(JSContext *cx);
6071 extern __attribute__((visibility ("default"))) JSString *
6072 JS_GetEmptyString(JSRuntime *rt);
6074 extern __attribute__((visibility ("default"))) JSBool
6075 JS_ConvertArguments(JSContext *cx, uintN argc, jsval *argv, const char *format,
6079 extern __attribute__((visibility ("default"))) JSBool
6080 JS_ConvertArgumentsVA(JSContext *cx, uintN argc, jsval *argv,
6081 const char *format, va_list ap);
6083 extern __attribute__((visibility ("default"))) JSBool
6084 JS_AddArgumentFormatter(JSContext *cx, const char *format,
6085 JSArgumentFormatter formatter);
6087 extern __attribute__((visibility ("default"))) void
6088 JS_RemoveArgumentFormatter(JSContext *cx, const char *format);
6092 extern __attribute__((visibility ("default"))) JSBool
6093 JS_ConvertValue(JSContext *cx, jsval v, JSType type, jsval *vp);
6095 extern __attribute__((visibility ("default"))) JSBool
6096 JS_ValueToObject(JSContext *cx, jsval v, JSObject **objp);
6098 extern __attribute__((visibility ("default"))) JSFunction *
6099 JS_ValueToFunction(JSContext *cx, jsval v);
6101 extern __attribute__((visibility ("default"))) JSFunction *
6102 JS_ValueToConstructor(JSContext *cx, jsval v);
6104 extern __attribute__((visibility ("default"))) JSString *
6105 JS_ValueToString(JSContext *cx, jsval v);
6107 extern __attribute__((visibility ("default"))) JSString *
6108 JS_ValueToSource(JSContext *cx, jsval v);
6110 extern __attribute__((visibility ("default"))) JSBool
6111 JS_ValueToNumber(JSContext *cx, jsval v, jsdouble *dp);
6113 extern __attribute__((visibility ("default"))) JSBool
6114 JS_DoubleIsInt32(jsdouble d, jsint *ip);
6120 extern __attribute__((visibility ("default"))) JSBool
6121 JS_ValueToECMAInt32(JSContext *cx, jsval v, int32 *ip);
6127 extern __attribute__((visibility ("default"))) JSBool
6128 JS_ValueToECMAUint32(JSContext *cx, jsval v, uint32 *ip);
6135 extern __attribute__((visibility ("default"))) JSBool
6136 JS_ValueToInt32(JSContext *cx, jsval v, int32 *ip);
6141 extern __attribute__((visibility ("default"))) JSBool
6142 JS_ValueToUint16(JSContext *cx, jsval v, uint16 *ip);
6144 extern __attribute__((visibility ("default"))) JSBool
6145 JS_ValueToBoolean(JSContext *cx, jsval v, JSBool *bp);
6147 extern __attribute__((visibility ("default"))) JSType
6148 JS_TypeOfValue(JSContext *cx, jsval v);
6150 extern __attribute__((visibility ("default"))) const char *
6151 JS_GetTypeName(JSContext *cx, JSType type);
6153 extern __attribute__((visibility ("default"))) JSBool
6154 JS_StrictlyEqual(JSContext *cx, jsval v1, jsval v2, JSBool *equal);
6156 extern __attribute__((visibility ("default"))) JSBool
6157 JS_SameValue(JSContext *cx, jsval v1, jsval v2, JSBool *same);
6159 extern __attribute__((visibility ("default"))) JSRuntime *
6160 JS_Init(uint32 maxbytes);
6165 extern __attribute__((visibility ("default"))) void
6166 JS_Finish(JSRuntime *rt);
6168 extern __attribute__((visibility ("default"))) void
6171 __attribute__((visibility ("default"))) void *
6172 JS_GetRuntimePrivate(JSRuntime *rt);
6174 __attribute__((visibility ("default"))) void
6175 JS_SetRuntimePrivate(JSRuntime *rt, void *data);
6177 extern __attribute__((visibility ("default"))) void
6178 JS_BeginRequest(JSContext *cx);
6180 extern __attribute__((visibility ("default"))) void
6181 JS_EndRequest(JSContext *cx);
6184 extern __attribute__((visibility ("default"))) void
6185 JS_YieldRequest(JSContext *cx);
6187 extern __attribute__((visibility ("default"))) jsrefcount
6188 JS_SuspendRequest(JSContext *cx);
6190 extern __attribute__((visibility ("default"))) void
6191 JS_ResumeRequest(JSContext *cx, jsrefcount saveDepth);
6193 extern __attribute__((visibility ("default"))) JSBool
6194 JS_IsInRequest(JSContext *cx);
6199 class JSAutoRequest {
6201 JSAutoRequest(JSContext *cx )
6202 : mContext(cx), mSaveDepth(0) {
6204 JS_BeginRequest(mContext);
6207 JS_EndRequest(mContext);
6211 mSaveDepth = JS_SuspendRequest(mContext);
6214 JS_ResumeRequest(mContext, mSaveDepth);
6218 JSContext *mContext;
6219 jsrefcount mSaveDepth;
6229 class JSAutoSuspendRequest {
6231 JSAutoSuspendRequest(JSContext *cx )
6232 : mContext(cx), mSaveDepth(0) {
6235 mSaveDepth = JS_SuspendRequest(mContext);
6238 ~JSAutoSuspendRequest() {
6244 JS_ResumeRequest(mContext, mSaveDepth);
6250 JSContext *mContext;
6251 jsrefcount mSaveDepth;
6261 class JSAutoCheckRequest {
6263 JSAutoCheckRequest(JSContext *cx ) {
6271 ~JSAutoCheckRequest() {
6288 extern __attribute__((visibility ("default"))) void
6289 JS_Lock(JSRuntime *rt);
6291 extern __attribute__((visibility ("default"))) void
6292 JS_Unlock(JSRuntime *rt);
6294 extern __attribute__((visibility ("default"))) JSContextCallback
6295 JS_SetContextCallback(JSRuntime *rt, JSContextCallback cxCallback);
6297 extern __attribute__((visibility ("default"))) JSContext *
6298 JS_NewContext(JSRuntime *rt, size_t stackChunkSize);
6300 extern __attribute__((visibility ("default"))) void
6301 JS_DestroyContext(JSContext *cx);
6303 extern __attribute__((visibility ("default"))) void
6304 JS_DestroyContextNoGC(JSContext *cx);
6306 extern __attribute__((visibility ("default"))) void
6307 JS_DestroyContextMaybeGC(JSContext *cx);
6309 extern __attribute__((visibility ("default"))) void *
6310 JS_GetContextPrivate(JSContext *cx);
6312 extern __attribute__((visibility ("default"))) void
6313 JS_SetContextPrivate(JSContext *cx, void *data);
6315 extern __attribute__((visibility ("default"))) JSRuntime *
6316 JS_GetRuntime(JSContext *cx);
6318 extern __attribute__((visibility ("default"))) JSContext *
6319 JS_ContextIterator(JSRuntime *rt, JSContext **iterp);
6321 extern __attribute__((visibility ("default"))) JSVersion
6322 JS_GetVersion(JSContext *cx);
6324 extern __attribute__((visibility ("default"))) JSVersion
6325 JS_SetVersion(JSContext *cx, JSVersion version);
6327 extern __attribute__((visibility ("default"))) const char *
6328 JS_VersionToString(JSVersion version);
6330 extern __attribute__((visibility ("default"))) JSVersion
6331 JS_StringToVersion(const char *string);
6333 extern __attribute__((visibility ("default"))) uint32
6334 JS_GetOptions(JSContext *cx);
6336 extern __attribute__((visibility ("default"))) uint32
6337 JS_SetOptions(JSContext *cx, uint32 options);
6339 extern __attribute__((visibility ("default"))) uint32
6340 JS_ToggleOptions(JSContext *cx, uint32 options);
6342 extern __attribute__((visibility ("default"))) const char *
6343 JS_GetImplementationVersion(void);
6345 extern __attribute__((visibility ("default"))) JSCompartmentCallback
6346 JS_SetCompartmentCallback(JSRuntime *rt, JSCompartmentCallback callback);
6348 extern __attribute__((visibility ("default"))) JSWrapObjectCallback
6349 JS_SetWrapObjectCallbacks(JSRuntime *rt,
6350 JSWrapObjectCallback callback,
6351 JSPreWrapCallback precallback);
6353 extern __attribute__((visibility ("default"))) JSCrossCompartmentCall *
6354 JS_EnterCrossCompartmentCall(JSContext *cx, JSObject *target);
6356 extern __attribute__((visibility ("default"))) void
6357 JS_LeaveCrossCompartmentCall(JSCrossCompartmentCall *call);
6359 extern __attribute__((visibility ("default"))) void *
6360 JS_SetCompartmentPrivate(JSContext *cx, JSCompartment *compartment, void *data);
6362 extern __attribute__((visibility ("default"))) void *
6363 JS_GetCompartmentPrivate(JSContext *cx, JSCompartment *compartment);
6365 extern __attribute__((visibility ("default"))) JSBool
6366 JS_WrapObject(JSContext *cx, JSObject **objp);
6368 extern __attribute__((visibility ("default"))) JSBool
6369 JS_WrapValue(JSContext *cx, jsval *vp);
6371 extern __attribute__((visibility ("default"))) JSObject *
6372 JS_TransplantObject(JSContext *cx, JSObject *origobj, JSObject *target);
6374 extern __attribute__((visibility ("default"))) JSObject *
6375 js_TransplantObjectWithWrapper(JSContext *cx,
6377 JSObject *origwrapper,
6378 JSObject *targetobj,
6379 JSObject *targetwrapper);
6381 extern __attribute__((visibility ("default"))) JSObject *
6382 js_TransplantObjectWithWrapper(JSContext *cx,
6384 JSObject *origwrapper,
6385 JSObject *targetobj,
6386 JSObject *targetwrapper);
6391 class __attribute__((visibility ("default"))) JSAutoEnterCompartment
6393 JSCrossCompartmentCall *call;
6396 JSAutoEnterCompartment() : call(__null) {}
6398 bool enter(JSContext *cx, JSObject *target);
6400 void enterAndIgnoreErrors(JSContext *cx, JSObject *target);
6402 bool entered() const { return call != __null; }
6404 ~JSAutoEnterCompartment() {
6405 if (call && call != reinterpret_cast<JSCrossCompartmentCall*>(1))
6406 JS_LeaveCrossCompartmentCall(call);
6409 void swap(JSAutoEnterCompartment &other) {
6410 JSCrossCompartmentCall *tmp = call;
6419 extern __attribute__((visibility ("default"))) JSObject *
6420 JS_GetGlobalObject(JSContext *cx);
6422 extern __attribute__((visibility ("default"))) void
6423 JS_SetGlobalObject(JSContext *cx, JSObject *obj);
6425 extern __attribute__((visibility ("default"))) JSBool
6426 JS_InitStandardClasses(JSContext *cx, JSObject *obj);
6428 extern __attribute__((visibility ("default"))) JSBool
6429 JS_ResolveStandardClass(JSContext *cx, JSObject *obj, jsid id,
6432 extern __attribute__((visibility ("default"))) JSBool
6433 JS_EnumerateStandardClasses(JSContext *cx, JSObject *obj);
6440 extern __attribute__((visibility ("default"))) JSIdArray *
6441 JS_EnumerateResolvedStandardClasses(JSContext *cx, JSObject *obj,
6444 extern __attribute__((visibility ("default"))) JSBool
6445 JS_GetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key,
6448 extern __attribute__((visibility ("default"))) JSObject *
6449 JS_GetScopeChain(JSContext *cx);
6451 extern __attribute__((visibility ("default"))) JSObject *
6452 JS_GetGlobalForObject(JSContext *cx, JSObject *obj);
6454 extern __attribute__((visibility ("default"))) JSObject *
6455 JS_GetGlobalForScopeChain(JSContext *cx);
6457 extern __attribute__((visibility ("default"))) jsval
6458 JS_ComputeThis(JSContext *cx, jsval *vp);
6463 JS_THIS(JSContext *cx, jsval *vp)
6465 return JSVAL_IS_PRIMITIVE(vp[1]) ? JS_ComputeThis(cx, vp) : vp[1];
6468 extern __attribute__((visibility ("default"))) void *
6469 JS_malloc(JSContext *cx, size_t nbytes);
6471 extern __attribute__((visibility ("default"))) void *
6472 JS_realloc(JSContext *cx, void *p, size_t nbytes);
6474 extern __attribute__((visibility ("default"))) void
6475 JS_free(JSContext *cx, void *p);
6477 extern __attribute__((visibility ("default"))) void
6478 JS_updateMallocCounter(JSContext *cx, size_t nbytes);
6480 extern __attribute__((visibility ("default"))) char *
6481 JS_strdup(JSContext *cx, const char *s);
6483 extern __attribute__((visibility ("default"))) JSBool
6484 JS_NewNumberValue(JSContext *cx, jsdouble d, jsval *rval);
6486 extern __attribute__((visibility ("default"))) JSBool
6487 JS_AddValueRoot(JSContext *cx, jsval *vp);
6489 extern __attribute__((visibility ("default"))) JSBool
6490 JS_AddStringRoot(JSContext *cx, JSString **rp);
6492 extern __attribute__((visibility ("default"))) JSBool
6493 JS_AddObjectRoot(JSContext *cx, JSObject **rp);
6495 extern __attribute__((visibility ("default"))) JSBool
6496 JS_AddGCThingRoot(JSContext *cx, void **rp);
6498 extern __attribute__((visibility ("default"))) JSBool
6499 JS_AddNamedValueRoot(JSContext *cx, jsval *vp, const char *name);
6501 extern __attribute__((visibility ("default"))) JSBool
6502 JS_AddNamedStringRoot(JSContext *cx, JSString **rp, const char *name);
6504 extern __attribute__((visibility ("default"))) JSBool
6505 JS_AddNamedObjectRoot(JSContext *cx, JSObject **rp, const char *name);
6507 extern __attribute__((visibility ("default"))) JSBool
6508 JS_AddNamedGCThingRoot(JSContext *cx, void **rp, const char *name);
6510 extern __attribute__((visibility ("default"))) JSBool
6511 JS_RemoveValueRoot(JSContext *cx, jsval *vp);
6513 extern __attribute__((visibility ("default"))) JSBool
6514 JS_RemoveStringRoot(JSContext *cx, JSString **rp);
6516 extern __attribute__((visibility ("default"))) JSBool
6517 JS_RemoveObjectRoot(JSContext *cx, JSObject **rp);
6519 extern __attribute__((visibility ("default"))) JSBool
6520 JS_RemoveGCThingRoot(JSContext *cx, void **rp);
6524 extern __attribute__((visibility ("default"))) JSBool
6525 js_AddRootRT(JSRuntime *rt, jsval *vp, const char *name);
6527 extern __attribute__((visibility ("default"))) JSBool
6528 js_AddGCThingRootRT(JSRuntime *rt, void **rp, const char *name);
6530 extern __attribute__((visibility ("default"))) JSBool
6531 js_RemoveRoot(JSRuntime *rt, void *rp);
6538 template<typename T> class AnchorPermitted;
6539 template<> class AnchorPermitted<JSObject *> { };
6540 template<> class AnchorPermitted<const JSObject *> { };
6541 template<> class AnchorPermitted<JSFunction *> { };
6542 template<> class AnchorPermitted<const JSFunction *> { };
6543 template<> class AnchorPermitted<JSString *> { };
6544 template<> class AnchorPermitted<const JSString *> { };
6545 template<> class AnchorPermitted<jsval> { };
6547 template<typename T>
6548 class Anchor: AnchorPermitted<T> {
6551 explicit Anchor(T t) { hold = t; }
6553 T &get() { return hold; }
6554 void set(const T &t) { hold = t; }
6555 void clear() { hold = 0; }
6559 Anchor(const Anchor &);
6560 const Anchor &operator=(const Anchor &);
6564 template<typename T>
6565 inline Anchor<T>::~Anchor() {
6567 asm volatile("":: "g" (hold) : "memory");
6579 extern __attribute__((noinline)) __attribute__((visibility ("default"))) void
6580 JS_AnchorPtr(void *p);
6582 typedef enum JSGCRootType {
6583 JS_GC_ROOT_VALUE_PTR,
6584 JS_GC_ROOT_GCTHING_PTR
6588 (* JSGCRootMapFun)(void *rp, JSGCRootType type, const char *name, void *data);
6590 extern __attribute__((visibility ("default"))) uint32
6591 JS_MapGCRoots(JSRuntime *rt, JSGCRootMapFun map, void *data);
6593 extern __attribute__((visibility ("default"))) JSBool
6594 JS_LockGCThing(JSContext *cx, void *thing);
6596 extern __attribute__((visibility ("default"))) JSBool
6597 JS_LockGCThingRT(JSRuntime *rt, void *thing);
6599 extern __attribute__((visibility ("default"))) JSBool
6600 JS_UnlockGCThing(JSContext *cx, void *thing);
6602 extern __attribute__((visibility ("default"))) JSBool
6603 JS_UnlockGCThingRT(JSRuntime *rt, void *thing);
6605 extern __attribute__((visibility ("default"))) void
6606 JS_SetExtraGCRoots(JSRuntime *rt, JSTraceDataOp traceOp, void *data);
6612 extern __attribute__((visibility ("default"))) void
6613 JS_MarkGCThing(JSContext *cx, jsval v, const char *name, void *arg);
6615 static __attribute__((always_inline)) inline JSBool
6616 JSVAL_IS_TRACEABLE(jsval v)
6620 return JSVAL_IS_TRACEABLE_IMPL(l);
6623 static __attribute__((always_inline)) inline void *
6624 JSVAL_TO_TRACEABLE(jsval v)
6626 return JSVAL_TO_GCTHING(v);
6629 static __attribute__((always_inline)) inline uint32
6630 JSVAL_TRACE_KIND(jsval v)
6635 return JSVAL_TRACE_KIND_IMPL(l);
6640 JSTraceCallback callback;
6641 JSTraceNamePrinter debugPrinter;
6642 const void *debugPrintArg;
6643 size_t debugPrintIndex;
6652 extern __attribute__((visibility ("default"))) void
6653 JS_CallTracer(JSTracer *trc, void *thing, uint32 kind);
6655 extern __attribute__((visibility ("default"))) void
6656 JS_TraceChildren(JSTracer *trc, void *thing, uint32 kind);
6658 extern __attribute__((visibility ("default"))) void
6659 JS_TraceRuntime(JSTracer *trc);
6661 extern __attribute__((visibility ("default"))) void
6662 JS_GC(JSContext *cx);
6664 extern __attribute__((visibility ("default"))) void
6665 JS_MaybeGC(JSContext *cx);
6667 extern __attribute__((visibility ("default"))) JSGCCallback
6668 JS_SetGCCallback(JSContext *cx, JSGCCallback cb);
6670 extern __attribute__((visibility ("default"))) JSGCCallback
6671 JS_SetGCCallbackRT(JSRuntime *rt, JSGCCallback cb);
6673 extern __attribute__((visibility ("default"))) JSBool
6674 JS_IsGCMarkingTracer(JSTracer *trc);
6676 extern __attribute__((visibility ("default"))) JSBool
6677 JS_IsAboutToBeFinalized(JSContext *cx, void *thing);
6679 typedef enum JSGCParamKey {
6684 JSGC_MAX_MALLOC_BYTES = 1,
6687 JSGC_STACKPOOL_LIFESPAN = 2,
6689 JSGC_TRIGGER_FACTOR = 3,
6698 JSGC_MAX_CODE_CACHE_BYTES = 6,
6704 JSGC_UNUSED_CHUNKS = 8
6707 typedef enum JSGCMode {
6709 JSGC_MODE_GLOBAL = 0,
6712 JSGC_MODE_COMPARTMENT = 1
6715 extern __attribute__((visibility ("default"))) void
6716 JS_SetGCParameter(JSRuntime *rt, JSGCParamKey key, uint32 value);
6718 extern __attribute__((visibility ("default"))) uint32
6719 JS_GetGCParameter(JSRuntime *rt, JSGCParamKey key);
6721 extern __attribute__((visibility ("default"))) void
6722 JS_SetGCParameterForThread(JSContext *cx, JSGCParamKey key, uint32 value);
6724 extern __attribute__((visibility ("default"))) uint32
6725 JS_GetGCParameterForThread(JSContext *cx, JSGCParamKey key);
6733 extern __attribute__((visibility ("default"))) void
6734 JS_FlushCaches(JSContext *cx);
6736 extern __attribute__((visibility ("default"))) intN
6737 JS_AddExternalStringFinalizer(JSStringFinalizeOp finalizer);
6739 extern __attribute__((visibility ("default"))) intN
6740 JS_RemoveExternalStringFinalizer(JSStringFinalizeOp finalizer);
6747 extern __attribute__((visibility ("default"))) JSString *
6748 JS_NewExternalString(JSContext *cx, jschar *chars, size_t length, intN type);
6754 extern __attribute__((visibility ("default"))) intN
6755 JS_GetExternalStringGCType(JSRuntime *rt, JSString *str);
6760 extern __attribute__((visibility ("default"))) void
6761 JS_SetThreadStackLimit(JSContext *cx, jsuword limitAddr);
6767 extern __attribute__((visibility ("default"))) void
6768 JS_SetNativeStackQuota(JSContext *cx, size_t stackSize);
6770 extern __attribute__((visibility ("default"))) void
6771 JS_SetScriptStackQuota(JSContext *cx, size_t quota);
6773 typedef void (*JSClassInternal)();
6781 JSPropertyOp addProperty;
6782 JSPropertyOp delProperty;
6783 JSPropertyOp getProperty;
6784 JSStrictPropertyOp setProperty;
6785 JSEnumerateOp enumerate;
6786 JSResolveOp resolve;
6787 JSConvertOp convert;
6788 JSFinalizeOp finalize;
6791 JSClassInternal reserved0;
6792 JSCheckAccessOp checkAccess;
6795 JSXDRObjectOp xdrObject;
6796 JSHasInstanceOp hasInstance;
6799 JSClassInternal reserved1;
6808 extern __attribute__((visibility ("default"))) void
6809 JS_DestroyIdArray(JSContext *cx, JSIdArray *ida);
6811 extern __attribute__((visibility ("default"))) JSBool
6812 JS_ValueToId(JSContext *cx, jsval v, jsid *idp);
6814 extern __attribute__((visibility ("default"))) JSBool
6815 JS_IdToValue(JSContext *cx, jsid id, jsval *vp);
6817 extern __attribute__((visibility ("default"))) JSBool
6818 JS_PropertyStub(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
6820 extern __attribute__((visibility ("default"))) JSBool
6821 JS_StrictPropertyStub(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp);
6823 extern __attribute__((visibility ("default"))) JSBool
6824 JS_EnumerateStub(JSContext *cx, JSObject *obj);
6826 extern __attribute__((visibility ("default"))) JSBool
6827 JS_ResolveStub(JSContext *cx, JSObject *obj, jsid id);
6829 extern __attribute__((visibility ("default"))) JSBool
6830 JS_ConvertStub(JSContext *cx, JSObject *obj, JSType type, jsval *vp);
6832 extern __attribute__((visibility ("default"))) void
6833 JS_FinalizeStub(JSContext *cx, JSObject *obj);
6835 struct JSConstDoubleSpec {
6847 struct JSPropertySpec {
6851 JSPropertyOp getter;
6852 JSStrictPropertyOp setter;
6855 struct JSFunctionSpec {
6862 extern __attribute__((visibility ("default"))) JSObject *
6863 JS_InitClass(JSContext *cx, JSObject *obj, JSObject *parent_proto,
6864 JSClass *clasp, JSNative constructor, uintN nargs,
6865 JSPropertySpec *ps, JSFunctionSpec *fs,
6866 JSPropertySpec *static_ps, JSFunctionSpec *static_fs);
6869 extern __attribute__((visibility ("default"))) JSClass *
6870 JS_GetClass(JSContext *cx, JSObject *obj);
6872 extern __attribute__((visibility ("default"))) JSBool
6873 JS_InstanceOf(JSContext *cx, JSObject *obj, JSClass *clasp, jsval *argv);
6875 extern __attribute__((visibility ("default"))) JSBool
6876 JS_HasInstance(JSContext *cx, JSObject *obj, jsval v, JSBool *bp);
6878 extern __attribute__((visibility ("default"))) void *
6879 JS_GetPrivate(JSContext *cx, JSObject *obj);
6881 extern __attribute__((visibility ("default"))) JSBool
6882 JS_SetPrivate(JSContext *cx, JSObject *obj, void *data);
6884 extern __attribute__((visibility ("default"))) void *
6885 JS_GetInstancePrivate(JSContext *cx, JSObject *obj, JSClass *clasp,
6888 extern __attribute__((visibility ("default"))) JSObject *
6889 JS_GetPrototype(JSContext *cx, JSObject *obj);
6891 extern __attribute__((visibility ("default"))) JSBool
6892 JS_SetPrototype(JSContext *cx, JSObject *obj, JSObject *proto);
6894 extern __attribute__((visibility ("default"))) JSObject *
6895 JS_GetParent(JSContext *cx, JSObject *obj);
6897 extern __attribute__((visibility ("default"))) JSBool
6898 JS_SetParent(JSContext *cx, JSObject *obj, JSObject *parent);
6900 extern __attribute__((visibility ("default"))) JSObject *
6901 JS_GetConstructor(JSContext *cx, JSObject *proto);
6908 extern __attribute__((visibility ("default"))) JSBool
6909 JS_GetObjectId(JSContext *cx, JSObject *obj, jsid *idp);
6911 extern __attribute__((visibility ("default"))) JSObject *
6912 JS_NewGlobalObject(JSContext *cx, JSClass *clasp);
6914 extern __attribute__((visibility ("default"))) JSObject *
6915 JS_NewCompartmentAndGlobalObject(JSContext *cx, JSClass *clasp, JSPrincipals *principals);
6917 extern __attribute__((visibility ("default"))) JSObject *
6918 JS_NewObject(JSContext *cx, JSClass *clasp, JSObject *proto, JSObject *parent);
6921 extern __attribute__((visibility ("default"))) JSBool
6922 JS_IsExtensible(JSObject *obj);
6928 extern __attribute__((visibility ("default"))) JSObject *
6929 JS_NewObjectWithGivenProto(JSContext *cx, JSClass *clasp, JSObject *proto,
6937 extern __attribute__((visibility ("default"))) JSBool
6938 JS_DeepFreezeObject(JSContext *cx, JSObject *obj);
6943 extern __attribute__((visibility ("default"))) JSBool
6944 JS_FreezeObject(JSContext *cx, JSObject *obj);
6946 extern __attribute__((visibility ("default"))) JSObject *
6947 JS_ConstructObject(JSContext *cx, JSClass *clasp, JSObject *proto,
6950 extern __attribute__((visibility ("default"))) JSObject *
6951 JS_ConstructObjectWithArguments(JSContext *cx, JSClass *clasp, JSObject *proto,
6952 JSObject *parent, uintN argc, jsval *argv);
6954 extern __attribute__((visibility ("default"))) JSObject *
6955 JS_New(JSContext *cx, JSObject *ctor, uintN argc, jsval *argv);
6957 extern __attribute__((visibility ("default"))) JSObject *
6958 JS_DefineObject(JSContext *cx, JSObject *obj, const char *name, JSClass *clasp,
6959 JSObject *proto, uintN attrs);
6961 extern __attribute__((visibility ("default"))) JSBool
6962 JS_DefineConstDoubles(JSContext *cx, JSObject *obj, JSConstDoubleSpec *cds);
6964 extern __attribute__((visibility ("default"))) JSBool
6965 JS_DefineProperties(JSContext *cx, JSObject *obj, JSPropertySpec *ps);
6967 extern __attribute__((visibility ("default"))) JSBool
6968 JS_DefineProperty(JSContext *cx, JSObject *obj, const char *name, jsval value,
6969 JSPropertyOp getter, JSStrictPropertyOp setter, uintN attrs);
6971 extern __attribute__((visibility ("default"))) JSBool
6972 JS_DefinePropertyById(JSContext *cx, JSObject *obj, jsid id, jsval value,
6973 JSPropertyOp getter, JSStrictPropertyOp setter, uintN attrs);
6975 extern __attribute__((visibility ("default"))) JSBool
6976 JS_DefineOwnProperty(JSContext *cx, JSObject *obj, jsid id, jsval descriptor, JSBool *bp);
6984 extern __attribute__((visibility ("default"))) JSBool
6985 JS_GetPropertyAttributes(JSContext *cx, JSObject *obj, const char *name,
6986 uintN *attrsp, JSBool *foundp);
6993 extern __attribute__((visibility ("default"))) JSBool
6994 JS_GetPropertyAttrsGetterAndSetter(JSContext *cx, JSObject *obj,
6996 uintN *attrsp, JSBool *foundp,
6997 JSPropertyOp *getterp,
6998 JSStrictPropertyOp *setterp);
7000 extern __attribute__((visibility ("default"))) JSBool
7001 JS_GetPropertyAttrsGetterAndSetterById(JSContext *cx, JSObject *obj,
7003 uintN *attrsp, JSBool *foundp,
7004 JSPropertyOp *getterp,
7005 JSStrictPropertyOp *setterp);
7013 extern __attribute__((visibility ("default"))) JSBool
7014 JS_SetPropertyAttributes(JSContext *cx, JSObject *obj, const char *name,
7015 uintN attrs, JSBool *foundp);
7017 extern __attribute__((visibility ("default"))) JSBool
7018 JS_DefinePropertyWithTinyId(JSContext *cx, JSObject *obj, const char *name,
7019 int8 tinyid, jsval value,
7020 JSPropertyOp getter, JSStrictPropertyOp setter,
7023 extern __attribute__((visibility ("default"))) JSBool
7024 JS_AliasProperty(JSContext *cx, JSObject *obj, const char *name,
7027 extern __attribute__((visibility ("default"))) JSBool
7028 JS_AlreadyHasOwnProperty(JSContext *cx, JSObject *obj, const char *name,
7031 extern __attribute__((visibility ("default"))) JSBool
7032 JS_AlreadyHasOwnPropertyById(JSContext *cx, JSObject *obj, jsid id,
7035 extern __attribute__((visibility ("default"))) JSBool
7036 JS_HasProperty(JSContext *cx, JSObject *obj, const char *name, JSBool *foundp);
7038 extern __attribute__((visibility ("default"))) JSBool
7039 JS_HasPropertyById(JSContext *cx, JSObject *obj, jsid id, JSBool *foundp);
7041 extern __attribute__((visibility ("default"))) JSBool
7042 JS_LookupProperty(JSContext *cx, JSObject *obj, const char *name, jsval *vp);
7044 extern __attribute__((visibility ("default"))) JSBool
7045 JS_LookupPropertyById(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
7047 extern __attribute__((visibility ("default"))) JSBool
7048 JS_LookupPropertyWithFlags(JSContext *cx, JSObject *obj, const char *name,
7049 uintN flags, jsval *vp);
7051 extern __attribute__((visibility ("default"))) JSBool
7052 JS_LookupPropertyWithFlagsById(JSContext *cx, JSObject *obj, jsid id,
7053 uintN flags, JSObject **objp, jsval *vp);
7055 struct JSPropertyDescriptor {
7058 JSPropertyOp getter;
7059 JSStrictPropertyOp setter;
7069 extern __attribute__((visibility ("default"))) JSBool
7070 JS_GetPropertyDescriptorById(JSContext *cx, JSObject *obj, jsid id, uintN flags,
7071 JSPropertyDescriptor *desc);
7073 extern __attribute__((visibility ("default"))) JSBool
7074 JS_GetOwnPropertyDescriptor(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
7076 extern __attribute__((visibility ("default"))) JSBool
7077 JS_GetProperty(JSContext *cx, JSObject *obj, const char *name, jsval *vp);
7079 extern __attribute__((visibility ("default"))) JSBool
7080 JS_GetPropertyDefault(JSContext *cx, JSObject *obj, const char *name, jsval def, jsval *vp);
7082 extern __attribute__((visibility ("default"))) JSBool
7083 JS_GetPropertyById(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
7085 extern __attribute__((visibility ("default"))) JSBool
7086 JS_GetPropertyByIdDefault(JSContext *cx, JSObject *obj, jsid id, jsval def, jsval *vp);
7088 extern __attribute__((visibility ("default"))) JSBool
7089 JS_GetMethodById(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
7092 extern __attribute__((visibility ("default"))) JSBool
7093 JS_GetMethod(JSContext *cx, JSObject *obj, const char *name, JSObject **objp,
7096 extern __attribute__((visibility ("default"))) JSBool
7097 JS_SetProperty(JSContext *cx, JSObject *obj, const char *name, jsval *vp);
7099 extern __attribute__((visibility ("default"))) JSBool
7100 JS_SetPropertyById(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
7102 extern __attribute__((visibility ("default"))) JSBool
7103 JS_DeleteProperty(JSContext *cx, JSObject *obj, const char *name);
7105 extern __attribute__((visibility ("default"))) JSBool
7106 JS_DeleteProperty2(JSContext *cx, JSObject *obj, const char *name,
7109 extern __attribute__((visibility ("default"))) JSBool
7110 JS_DeletePropertyById(JSContext *cx, JSObject *obj, jsid id);
7112 extern __attribute__((visibility ("default"))) JSBool
7113 JS_DeletePropertyById2(JSContext *cx, JSObject *obj, jsid id, jsval *rval);
7115 extern __attribute__((visibility ("default"))) JSBool
7116 JS_DefineUCProperty(JSContext *cx, JSObject *obj,
7117 const jschar *name, size_t namelen, jsval value,
7118 JSPropertyOp getter, JSStrictPropertyOp setter,
7127 extern __attribute__((visibility ("default"))) JSBool
7128 JS_GetUCPropertyAttributes(JSContext *cx, JSObject *obj,
7129 const jschar *name, size_t namelen,
7130 uintN *attrsp, JSBool *foundp);
7137 extern __attribute__((visibility ("default"))) JSBool
7138 JS_GetUCPropertyAttrsGetterAndSetter(JSContext *cx, JSObject *obj,
7139 const jschar *name, size_t namelen,
7140 uintN *attrsp, JSBool *foundp,
7141 JSPropertyOp *getterp,
7142 JSStrictPropertyOp *setterp);
7150 extern __attribute__((visibility ("default"))) JSBool
7151 JS_SetUCPropertyAttributes(JSContext *cx, JSObject *obj,
7152 const jschar *name, size_t namelen,
7153 uintN attrs, JSBool *foundp);
7156 extern __attribute__((visibility ("default"))) JSBool
7157 JS_DefineUCPropertyWithTinyId(JSContext *cx, JSObject *obj,
7158 const jschar *name, size_t namelen,
7159 int8 tinyid, jsval value,
7160 JSPropertyOp getter, JSStrictPropertyOp setter,
7163 extern __attribute__((visibility ("default"))) JSBool
7164 JS_AlreadyHasOwnUCProperty(JSContext *cx, JSObject *obj, const jschar *name,
7165 size_t namelen, JSBool *foundp);
7167 extern __attribute__((visibility ("default"))) JSBool
7168 JS_HasUCProperty(JSContext *cx, JSObject *obj,
7169 const jschar *name, size_t namelen,
7172 extern __attribute__((visibility ("default"))) JSBool
7173 JS_LookupUCProperty(JSContext *cx, JSObject *obj,
7174 const jschar *name, size_t namelen,
7177 extern __attribute__((visibility ("default"))) JSBool
7178 JS_GetUCProperty(JSContext *cx, JSObject *obj,
7179 const jschar *name, size_t namelen,
7182 extern __attribute__((visibility ("default"))) JSBool
7183 JS_SetUCProperty(JSContext *cx, JSObject *obj,
7184 const jschar *name, size_t namelen,
7187 extern __attribute__((visibility ("default"))) JSBool
7188 JS_DeleteUCProperty2(JSContext *cx, JSObject *obj,
7189 const jschar *name, size_t namelen,
7192 extern __attribute__((visibility ("default"))) JSObject *
7193 JS_NewArrayObject(JSContext *cx, jsint length, jsval *vector);
7195 extern __attribute__((visibility ("default"))) JSBool
7196 JS_IsArrayObject(JSContext *cx, JSObject *obj);
7198 extern __attribute__((visibility ("default"))) JSBool
7199 JS_GetArrayLength(JSContext *cx, JSObject *obj, jsuint *lengthp);
7201 extern __attribute__((visibility ("default"))) JSBool
7202 JS_SetArrayLength(JSContext *cx, JSObject *obj, jsuint length);
7204 extern __attribute__((visibility ("default"))) JSBool
7205 JS_HasArrayLength(JSContext *cx, JSObject *obj, jsuint *lengthp);
7207 extern __attribute__((visibility ("default"))) JSBool
7208 JS_DefineElement(JSContext *cx, JSObject *obj, jsint index, jsval value,
7209 JSPropertyOp getter, JSStrictPropertyOp setter, uintN attrs);
7211 extern __attribute__((visibility ("default"))) JSBool
7212 JS_AliasElement(JSContext *cx, JSObject *obj, const char *name, jsint alias);
7214 extern __attribute__((visibility ("default"))) JSBool
7215 JS_AlreadyHasOwnElement(JSContext *cx, JSObject *obj, jsint index,
7218 extern __attribute__((visibility ("default"))) JSBool
7219 JS_HasElement(JSContext *cx, JSObject *obj, jsint index, JSBool *foundp);
7221 extern __attribute__((visibility ("default"))) JSBool
7222 JS_LookupElement(JSContext *cx, JSObject *obj, jsint index, jsval *vp);
7224 extern __attribute__((visibility ("default"))) JSBool
7225 JS_GetElement(JSContext *cx, JSObject *obj, jsint index, jsval *vp);
7227 extern __attribute__((visibility ("default"))) JSBool
7228 JS_SetElement(JSContext *cx, JSObject *obj, jsint index, jsval *vp);
7230 extern __attribute__((visibility ("default"))) JSBool
7231 JS_DeleteElement(JSContext *cx, JSObject *obj, jsint index);
7233 extern __attribute__((visibility ("default"))) JSBool
7234 JS_DeleteElement2(JSContext *cx, JSObject *obj, jsint index, jsval *rval);
7236 extern __attribute__((visibility ("default"))) void
7237 JS_ClearScope(JSContext *cx, JSObject *obj);
7239 extern __attribute__((visibility ("default"))) JSIdArray *
7240 JS_Enumerate(JSContext *cx, JSObject *obj);
7247 extern __attribute__((visibility ("default"))) JSObject *
7248 JS_NewPropertyIterator(JSContext *cx, JSObject *obj);
7255 extern __attribute__((visibility ("default"))) JSBool
7256 JS_NextProperty(JSContext *cx, JSObject *iterobj, jsid *idp);
7258 extern __attribute__((visibility ("default"))) JSBool
7259 JS_CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
7260 jsval *vp, uintN *attrsp);
7262 extern __attribute__((visibility ("default"))) JSBool
7263 JS_GetReservedSlot(JSContext *cx, JSObject *obj, uint32 index, jsval *vp);
7265 extern __attribute__((visibility ("default"))) JSBool
7266 JS_SetReservedSlot(JSContext *cx, JSObject *obj, uint32 index, jsval v);
7273 struct JSPrincipals {
7277 void * (* getPrincipalArray)(JSContext *cx, JSPrincipals *);
7278 JSBool (* globalPrivilegesEnabled)(JSContext *cx, JSPrincipals *);
7281 jsrefcount refcount;
7283 void (* destroy)(JSContext *cx, JSPrincipals *);
7284 JSBool (* subsume)(JSPrincipals *, JSPrincipals *);
7291 extern __attribute__((visibility ("default"))) jsrefcount
7292 JS_HoldPrincipals(JSContext *cx, JSPrincipals *principals);
7294 extern __attribute__((visibility ("default"))) jsrefcount
7295 JS_DropPrincipals(JSContext *cx, JSPrincipals *principals);
7297 struct JSSecurityCallbacks {
7298 JSCheckAccessOp checkObjectAccess;
7299 JSPrincipalsTranscoder principalsTranscoder;
7300 JSObjectPrincipalsFinder findObjectPrincipals;
7301 JSCSPEvalChecker contentSecurityPolicyAllows;
7304 extern __attribute__((visibility ("default"))) JSSecurityCallbacks *
7305 JS_SetRuntimeSecurityCallbacks(JSRuntime *rt, JSSecurityCallbacks *callbacks);
7307 extern __attribute__((visibility ("default"))) JSSecurityCallbacks *
7308 JS_GetRuntimeSecurityCallbacks(JSRuntime *rt);
7310 extern __attribute__((visibility ("default"))) JSSecurityCallbacks *
7311 JS_SetContextSecurityCallbacks(JSContext *cx, JSSecurityCallbacks *callbacks);
7313 extern __attribute__((visibility ("default"))) JSSecurityCallbacks *
7314 JS_GetSecurityCallbacks(JSContext *cx);
7321 extern __attribute__((visibility ("default"))) JSFunction *
7322 JS_NewFunction(JSContext *cx, JSNative call, uintN nargs, uintN flags,
7323 JSObject *parent, const char *name);
7329 extern __attribute__((visibility ("default"))) JSFunction *
7330 JS_NewFunctionById(JSContext *cx, JSNative call, uintN nargs, uintN flags,
7331 JSObject *parent, jsid id);
7333 extern __attribute__((visibility ("default"))) JSObject *
7334 JS_GetFunctionObject(JSFunction *fun);
7342 extern __attribute__((visibility ("default"))) JSString *
7343 JS_GetFunctionId(JSFunction *fun);
7348 extern __attribute__((visibility ("default"))) uintN
7349 JS_GetFunctionFlags(JSFunction *fun);
7354 extern __attribute__((visibility ("default"))) uint16
7355 JS_GetFunctionArity(JSFunction *fun);
7363 extern __attribute__((visibility ("default"))) JSBool
7364 JS_ObjectIsFunction(JSContext *cx, JSObject *obj);
7366 extern __attribute__((visibility ("default"))) JSBool
7367 JS_ObjectIsCallable(JSContext *cx, JSObject *obj);
7369 extern __attribute__((visibility ("default"))) JSBool
7370 JS_DefineFunctions(JSContext *cx, JSObject *obj, JSFunctionSpec *fs);
7372 extern __attribute__((visibility ("default"))) JSFunction *
7373 JS_DefineFunction(JSContext *cx, JSObject *obj, const char *name, JSNative call,
7374 uintN nargs, uintN attrs);
7376 extern __attribute__((visibility ("default"))) JSFunction *
7377 JS_DefineUCFunction(JSContext *cx, JSObject *obj,
7378 const jschar *name, size_t namelen, JSNative call,
7379 uintN nargs, uintN attrs);
7381 extern __attribute__((visibility ("default"))) JSFunction *
7382 JS_DefineFunctionById(JSContext *cx, JSObject *obj, jsid id, JSNative call,
7383 uintN nargs, uintN attrs);
7385 extern __attribute__((visibility ("default"))) JSObject *
7386 JS_CloneFunctionObject(JSContext *cx, JSObject *funobj, JSObject *parent);
7388 extern __attribute__((visibility ("default"))) JSBool
7389 JS_BufferIsCompilableUnit(JSContext *cx, JSObject *obj,
7390 const char *bytes, size_t length);
7392 extern __attribute__((visibility ("default"))) JSObject *
7393 JS_CompileScript(JSContext *cx, JSObject *obj,
7394 const char *bytes, size_t length,
7395 const char *filename, uintN lineno);
7397 extern __attribute__((visibility ("default"))) JSObject *
7398 JS_CompileScriptForPrincipals(JSContext *cx, JSObject *obj,
7399 JSPrincipals *principals,
7400 const char *bytes, size_t length,
7401 const char *filename, uintN lineno);
7403 extern __attribute__((visibility ("default"))) JSObject *
7404 JS_CompileScriptForPrincipalsVersion(JSContext *cx, JSObject *obj,
7405 JSPrincipals *principals,
7406 const char *bytes, size_t length,
7407 const char *filename, uintN lineno,
7410 extern __attribute__((visibility ("default"))) JSObject *
7411 JS_CompileUCScript(JSContext *cx, JSObject *obj,
7412 const jschar *chars, size_t length,
7413 const char *filename, uintN lineno);
7415 extern __attribute__((visibility ("default"))) JSObject *
7416 JS_CompileUCScriptForPrincipals(JSContext *cx, JSObject *obj,
7417 JSPrincipals *principals,
7418 const jschar *chars, size_t length,
7419 const char *filename, uintN lineno);
7421 extern __attribute__((visibility ("default"))) JSObject *
7422 JS_CompileUCScriptForPrincipalsVersion(JSContext *cx, JSObject *obj,
7423 JSPrincipals *principals,
7424 const jschar *chars, size_t length,
7425 const char *filename, uintN lineno,
7428 extern __attribute__((visibility ("default"))) JSObject *
7429 JS_CompileFile(JSContext *cx, JSObject *obj, const char *filename);
7431 extern __attribute__((visibility ("default"))) JSObject *
7432 JS_CompileFileHandle(JSContext *cx, JSObject *obj, const char *filename,
7435 extern __attribute__((visibility ("default"))) JSObject *
7436 JS_CompileFileHandleForPrincipals(JSContext *cx, JSObject *obj,
7437 const char *filename, FILE *fh,
7438 JSPrincipals *principals);
7440 extern __attribute__((visibility ("default"))) JSObject *
7441 JS_CompileFileHandleForPrincipalsVersion(JSContext *cx, JSObject *obj,
7442 const char *filename, FILE *fh,
7443 JSPrincipals *principals,
7446 extern __attribute__((visibility ("default"))) JSFunction *
7447 JS_CompileFunction(JSContext *cx, JSObject *obj, const char *name,
7448 uintN nargs, const char **argnames,
7449 const char *bytes, size_t length,
7450 const char *filename, uintN lineno);
7452 extern __attribute__((visibility ("default"))) JSFunction *
7453 JS_CompileFunctionForPrincipals(JSContext *cx, JSObject *obj,
7454 JSPrincipals *principals, const char *name,
7455 uintN nargs, const char **argnames,
7456 const char *bytes, size_t length,
7457 const char *filename, uintN lineno);
7459 extern __attribute__((visibility ("default"))) JSFunction *
7460 JS_CompileUCFunction(JSContext *cx, JSObject *obj, const char *name,
7461 uintN nargs, const char **argnames,
7462 const jschar *chars, size_t length,
7463 const char *filename, uintN lineno);
7465 extern __attribute__((visibility ("default"))) JSFunction *
7466 JS_CompileUCFunctionForPrincipals(JSContext *cx, JSObject *obj,
7467 JSPrincipals *principals, const char *name,
7468 uintN nargs, const char **argnames,
7469 const jschar *chars, size_t length,
7470 const char *filename, uintN lineno);
7472 extern __attribute__((visibility ("default"))) JSFunction *
7473 JS_CompileUCFunctionForPrincipalsVersion(JSContext *cx, JSObject *obj,
7474 JSPrincipals *principals, const char *name,
7475 uintN nargs, const char **argnames,
7476 const jschar *chars, size_t length,
7477 const char *filename, uintN lineno,
7480 extern __attribute__((visibility ("default"))) JSString *
7481 JS_DecompileScriptObject(JSContext *cx, JSObject *scriptObj, const char *name, uintN indent);
7489 extern __attribute__((visibility ("default"))) JSString *
7490 JS_DecompileFunction(JSContext *cx, JSFunction *fun, uintN indent);
7492 extern __attribute__((visibility ("default"))) JSString *
7493 JS_DecompileFunctionBody(JSContext *cx, JSFunction *fun, uintN indent);
7495 extern __attribute__((visibility ("default"))) JSBool
7496 JS_ExecuteScript(JSContext *cx, JSObject *obj, JSObject *scriptObj, jsval *rval);
7498 extern __attribute__((visibility ("default"))) JSBool
7499 JS_ExecuteScriptVersion(JSContext *cx, JSObject *obj, JSObject *scriptObj, jsval *rval,
7506 typedef enum JSExecPart { JSEXEC_PROLOG, JSEXEC_MAIN } JSExecPart;
7508 extern __attribute__((visibility ("default"))) JSBool
7509 JS_EvaluateScript(JSContext *cx, JSObject *obj,
7510 const char *bytes, uintN length,
7511 const char *filename, uintN lineno,
7514 extern __attribute__((visibility ("default"))) JSBool
7515 JS_EvaluateScriptForPrincipals(JSContext *cx, JSObject *obj,
7516 JSPrincipals *principals,
7517 const char *bytes, uintN length,
7518 const char *filename, uintN lineno,
7521 extern __attribute__((visibility ("default"))) JSBool
7522 JS_EvaluateScriptForPrincipalsVersion(JSContext *cx, JSObject *obj,
7523 JSPrincipals *principals,
7524 const char *bytes, uintN length,
7525 const char *filename, uintN lineno,
7526 jsval *rval, JSVersion version);
7528 extern __attribute__((visibility ("default"))) JSBool
7529 JS_EvaluateUCScript(JSContext *cx, JSObject *obj,
7530 const jschar *chars, uintN length,
7531 const char *filename, uintN lineno,
7534 extern __attribute__((visibility ("default"))) JSBool
7535 JS_EvaluateUCScriptForPrincipalsVersion(JSContext *cx, JSObject *obj,
7536 JSPrincipals *principals,
7537 const jschar *chars, uintN length,
7538 const char *filename, uintN lineno,
7539 jsval *rval, JSVersion version);
7541 extern __attribute__((visibility ("default"))) JSBool
7542 JS_EvaluateUCScriptForPrincipals(JSContext *cx, JSObject *obj,
7543 JSPrincipals *principals,
7544 const jschar *chars, uintN length,
7545 const char *filename, uintN lineno,
7548 extern __attribute__((visibility ("default"))) JSBool
7549 JS_CallFunction(JSContext *cx, JSObject *obj, JSFunction *fun, uintN argc,
7550 jsval *argv, jsval *rval);
7552 extern __attribute__((visibility ("default"))) JSBool
7553 JS_CallFunctionName(JSContext *cx, JSObject *obj, const char *name, uintN argc,
7554 jsval *argv, jsval *rval);
7556 extern __attribute__((visibility ("default"))) JSBool
7557 JS_CallFunctionValue(JSContext *cx, JSObject *obj, jsval fval, uintN argc,
7558 jsval *argv, jsval *rval);
7569 Call(JSContext *cx, JSObject *thisObj, JSFunction *fun, uintN argc, jsval *argv, jsval *rval) {
7570 return !!JS_CallFunction(cx, thisObj, fun, argc, argv, rval);
7577 Call(JSContext *cx, JSObject *thisObj, const char *name, uintN argc, jsval *argv, jsval *rval) {
7578 return !!JS_CallFunctionName(cx, thisObj, name, argc, argv, rval);
7585 Call(JSContext *cx, JSObject *thisObj, jsval fun, uintN argc, jsval *argv, jsval *rval) {
7586 return !!JS_CallFunctionValue(cx, thisObj, fun, argc, argv, rval);
7589 extern __attribute__((visibility ("default"))) bool
7590 Call(JSContext *cx, jsval thisv, jsval fun, uintN argc, jsval *argv, jsval *rval);
7596 Call(JSContext *cx, jsval thisv, JSObject *funObj, uintN argc, jsval *argv, jsval *rval) {
7597 return Call(cx, thisv, OBJECT_TO_JSVAL(funObj), argc, argv, rval);
7604 extern __attribute__((visibility ("default"))) JSOperationCallback
7605 JS_SetOperationCallback(JSContext *cx, JSOperationCallback callback);
7607 extern __attribute__((visibility ("default"))) JSOperationCallback
7608 JS_GetOperationCallback(JSContext *cx);
7610 extern __attribute__((visibility ("default"))) void
7611 JS_TriggerOperationCallback(JSContext *cx);
7613 extern __attribute__((visibility ("default"))) void
7614 JS_TriggerAllOperationCallbacks(JSRuntime *rt);
7616 extern __attribute__((visibility ("default"))) JSBool
7617 JS_IsRunning(JSContext *cx);
7619 extern __attribute__((visibility ("default"))) JSStackFrame *
7620 JS_SaveFrameChain(JSContext *cx);
7622 extern __attribute__((visibility ("default"))) void
7623 JS_RestoreFrameChain(JSContext *cx, JSStackFrame *fp);
7625 extern __attribute__((visibility ("default"))) JSString *
7626 JS_NewStringCopyN(JSContext *cx, const char *s, size_t n);
7628 extern __attribute__((visibility ("default"))) JSString *
7629 JS_NewStringCopyZ(JSContext *cx, const char *s);
7631 extern __attribute__((visibility ("default"))) JSString *
7632 JS_InternJSString(JSContext *cx, JSString *str);
7634 extern __attribute__((visibility ("default"))) JSString *
7635 JS_InternString(JSContext *cx, const char *s);
7637 extern __attribute__((visibility ("default"))) JSString *
7638 JS_NewUCString(JSContext *cx, jschar *chars, size_t length);
7640 extern __attribute__((visibility ("default"))) JSString *
7641 JS_NewUCStringCopyN(JSContext *cx, const jschar *s, size_t n);
7643 extern __attribute__((visibility ("default"))) JSString *
7644 JS_NewUCStringCopyZ(JSContext *cx, const jschar *s);
7646 extern __attribute__((visibility ("default"))) JSString *
7647 JS_InternUCStringN(JSContext *cx, const jschar *s, size_t length);
7649 extern __attribute__((visibility ("default"))) JSString *
7650 JS_InternUCString(JSContext *cx, const jschar *s);
7652 extern __attribute__((visibility ("default"))) JSBool
7653 JS_CompareStrings(JSContext *cx, JSString *str1, JSString *str2, int32 *result);
7655 extern __attribute__((visibility ("default"))) JSBool
7656 JS_StringEqualsAscii(JSContext *cx, JSString *str, const char *asciiBytes, JSBool *match);
7658 extern __attribute__((visibility ("default"))) size_t
7659 JS_PutEscapedString(JSContext *cx, char *buffer, size_t size, JSString *str, char quote);
7661 extern __attribute__((visibility ("default"))) JSBool
7662 JS_FileEscapedString(FILE *fp, JSString *str, char quote);
7664 extern __attribute__((visibility ("default"))) size_t
7665 JS_GetStringLength(JSString *str);
7667 extern __attribute__((visibility ("default"))) const jschar *
7668 JS_GetStringCharsAndLength(JSContext *cx, JSString *str, size_t *length);
7670 extern __attribute__((visibility ("default"))) const jschar *
7671 JS_GetInternedStringChars(JSString *str);
7673 extern __attribute__((visibility ("default"))) const jschar *
7674 JS_GetInternedStringCharsAndLength(JSString *str, size_t *length);
7676 extern __attribute__((visibility ("default"))) const jschar *
7677 JS_GetStringCharsZ(JSContext *cx, JSString *str);
7679 extern __attribute__((visibility ("default"))) const jschar *
7680 JS_GetStringCharsZAndLength(JSContext *cx, JSString *str, size_t *length);
7682 extern __attribute__((visibility ("default"))) JSFlatString *
7683 JS_FlattenString(JSContext *cx, JSString *str);
7685 extern __attribute__((visibility ("default"))) const jschar *
7686 JS_GetFlatStringChars(JSFlatString *str);
7688 static __attribute__((always_inline)) inline JSFlatString *
7689 JSID_TO_FLAT_STRING(jsid id)
7692 return (JSFlatString *)((id));
7695 static __attribute__((always_inline)) inline JSFlatString *
7696 JS_ASSERT_STRING_IS_FLAT(JSString *str)
7699 return (JSFlatString *)str;
7702 static __attribute__((always_inline)) inline JSString *
7703 JS_FORGET_STRING_FLATNESS(JSFlatString *fstr)
7705 return (JSString *)fstr;
7712 extern __attribute__((visibility ("default"))) JSBool
7713 JS_FlatStringEqualsAscii(JSFlatString *str, const char *asciiBytes);
7715 extern __attribute__((visibility ("default"))) size_t
7716 JS_PutEscapedFlatString(char *buffer, size_t size, JSFlatString *str, char quote);
7722 extern __attribute__((visibility ("default"))) JSString *
7723 JS_NewGrowableString(JSContext *cx, jschar *chars, size_t length);
7725 extern __attribute__((visibility ("default"))) JSString *
7726 JS_NewDependentString(JSContext *cx, JSString *str, size_t start,
7733 extern __attribute__((visibility ("default"))) JSString *
7734 JS_ConcatStrings(JSContext *cx, JSString *left, JSString *right);
7740 extern __attribute__((visibility ("default"))) const jschar *
7741 JS_UndependString(JSContext *cx, JSString *str);
7747 extern __attribute__((visibility ("default"))) JSBool
7748 JS_MakeStringImmutable(JSContext *cx, JSString *str);
7754 __attribute__((visibility ("default"))) JSBool
7755 JS_CStringsAreUTF8(void);
7762 __attribute__((visibility ("default"))) void
7763 JS_SetCStringsAreUTF8(void);
7765 __attribute__((visibility ("default"))) JSBool
7766 JS_EncodeCharacters(JSContext *cx, const jschar *src, size_t srclen, char *dst,
7769 __attribute__((visibility ("default"))) JSBool
7770 JS_DecodeBytes(JSContext *cx, const char *src, size_t srclen, jschar *dst,
7777 __attribute__((visibility ("default"))) char *
7778 JS_EncodeString(JSContext *cx, JSString *str);
7785 __attribute__((visibility ("default"))) size_t
7786 JS_GetStringEncodingLength(JSContext *cx, JSString *str);
7788 __attribute__((visibility ("default"))) size_t
7789 JS_EncodeStringToBuffer(JSString *str, char *buffer, size_t length);
7793 class JSAutoByteString {
7795 JSAutoByteString(JSContext *cx, JSString *str )
7796 : mBytes(JS_EncodeString(cx, str)) {
7806 ~JSAutoByteString() {
7811 void initBytes(char *bytes) {
7816 char *encode(JSContext *cx, JSString *str) {
7819 mBytes = JS_EncodeString(cx, str);
7832 bool operator!() const {
7841 JSAutoByteString(const JSAutoByteString &another);
7842 JSAutoByteString &operator=(const JSAutoByteString &another);
7851 typedef JSBool (* JSONWriteCallback)(const jschar *buf, uint32 len, void *data);
7856 __attribute__((visibility ("default"))) JSBool
7857 JS_Stringify(JSContext *cx, jsval *vp, JSObject *replacer, jsval space,
7858 JSONWriteCallback callback, void *data);
7863 __attribute__((visibility ("default"))) JSBool
7864 JS_TryJSON(JSContext *cx, jsval *vp);
7869 __attribute__((visibility ("default"))) JSONParser *
7870 JS_BeginJSONParse(JSContext *cx, jsval *vp);
7872 __attribute__((visibility ("default"))) JSBool
7873 JS_ConsumeJSONText(JSContext *cx, JSONParser *jp, const jschar *data, uint32 len);
7875 __attribute__((visibility ("default"))) JSBool
7876 JS_FinishJSONParse(JSContext *cx, JSONParser *jp, jsval reviver);
7878 struct JSStructuredCloneCallbacks {
7879 ReadStructuredCloneOp read;
7880 WriteStructuredCloneOp write;
7881 StructuredCloneErrorOp reportError;
7884 __attribute__((visibility ("default"))) JSBool
7885 JS_ReadStructuredClone(JSContext *cx, const uint64 *data, size_t nbytes,
7886 uint32 version, jsval *vp,
7887 const JSStructuredCloneCallbacks *optionalCallbacks,
7891 __attribute__((visibility ("default"))) JSBool
7892 JS_WriteStructuredClone(JSContext *cx, jsval v, uint64 **datap, size_t *nbytesp,
7893 const JSStructuredCloneCallbacks *optionalCallbacks,
7896 __attribute__((visibility ("default"))) JSBool
7897 JS_StructuredClone(JSContext *cx, jsval v, jsval *vp,
7898 const JSStructuredCloneCallbacks *optionalCallbacks,
7903 class JSAutoStructuredCloneBuffer {
7910 JSAutoStructuredCloneBuffer()
7911 : cx_(__null), data_(__null), nbytes_(0), version_(1) {}
7913 ~JSAutoStructuredCloneBuffer() { clear(); }
7915 JSContext *cx() const { return cx_; }
7916 uint64 *data() const { return data_; }
7917 size_t nbytes() const { return nbytes_; }
7919 void clear(JSContext *cx=__null) {
7936 void adopt(JSContext *cx, uint64 *data, size_t nbytes,
7949 void steal(uint64 **datap, size_t *nbytesp, JSContext **cxp=__null,
7950 uint32 *versionp=__null) {
7956 *versionp = version_;
7964 bool read(jsval *vp, JSContext *cx=__null,
7965 const JSStructuredCloneCallbacks *optionalCallbacks=__null,
7966 void *closure=__null) const {
7971 return !!JS_ReadStructuredClone(cx, data_, nbytes_, version_, vp,
7972 optionalCallbacks, closure);
7975 bool write(JSContext *cx, jsval v,
7976 const JSStructuredCloneCallbacks *optionalCallbacks=__null,
7977 void *closure=__null) {
7980 bool ok = !!JS_WriteStructuredClone(cx, v, &data_, &nbytes_,
7981 optionalCallbacks, closure);
7993 void swap(JSAutoStructuredCloneBuffer &other) {
7994 JSContext *cx = other.cx_;
7995 uint64 *data = other.data_;
7996 size_t nbytes = other.nbytes_;
7997 uint32 version = other.version_;
7999 other.cx_ = this->cx_;
8000 other.data_ = this->data_;
8001 other.nbytes_ = this->nbytes_;
8002 other.version_ = this->version_;
8006 this->nbytes_ = nbytes;
8007 this->version_ = version;
8012 JSAutoStructuredCloneBuffer(const JSAutoStructuredCloneBuffer &other);
8013 JSAutoStructuredCloneBuffer &operator=(const JSAutoStructuredCloneBuffer &other);
8016 __attribute__((visibility ("default"))) void
8017 JS_SetStructuredCloneCallbacks(JSRuntime *rt, const JSStructuredCloneCallbacks *callbacks);
8019 __attribute__((visibility ("default"))) JSBool
8020 JS_ReadUint32Pair(JSStructuredCloneReader *r, uint32 *p1, uint32 *p2);
8022 __attribute__((visibility ("default"))) JSBool
8023 JS_ReadBytes(JSStructuredCloneReader *r, void *p, size_t len);
8025 __attribute__((visibility ("default"))) JSBool
8026 JS_WriteUint32Pair(JSStructuredCloneWriter *w, uint32 tag, uint32 data);
8028 __attribute__((visibility ("default"))) JSBool
8029 JS_WriteBytes(JSStructuredCloneWriter *w, const void *p, size_t len);
8036 struct JSLocaleCallbacks {
8037 JSLocaleToUpperCase localeToUpperCase;
8038 JSLocaleToLowerCase localeToLowerCase;
8039 JSLocaleCompare localeCompare;
8040 JSLocaleToUnicode localeToUnicode;
8041 JSErrorCallback localeGetErrorMessage;
8048 extern __attribute__((visibility ("default"))) void
8049 JS_SetLocaleCallbacks(JSContext *cx, JSLocaleCallbacks *callbacks);
8055 extern __attribute__((visibility ("default"))) JSLocaleCallbacks *
8056 JS_GetLocaleCallbacks(JSContext *cx);
8058 extern __attribute__((visibility ("default"))) void
8059 JS_ReportError(JSContext *cx, const char *format, ...);
8064 extern __attribute__((visibility ("default"))) void
8065 JS_ReportErrorNumber(JSContext *cx, JSErrorCallback errorCallback,
8066 void *userRef, const uintN errorNumber, ...);
8071 extern __attribute__((visibility ("default"))) void
8072 JS_ReportErrorNumberUC(JSContext *cx, JSErrorCallback errorCallback,
8073 void *userRef, const uintN errorNumber, ...);
8081 extern __attribute__((visibility ("default"))) JSBool
8082 JS_ReportWarning(JSContext *cx, const char *format, ...);
8084 extern __attribute__((visibility ("default"))) JSBool
8085 JS_ReportErrorFlagsAndNumber(JSContext *cx, uintN flags,
8086 JSErrorCallback errorCallback, void *userRef,
8087 const uintN errorNumber, ...);
8089 extern __attribute__((visibility ("default"))) JSBool
8090 JS_ReportErrorFlagsAndNumberUC(JSContext *cx, uintN flags,
8091 JSErrorCallback errorCallback, void *userRef,
8092 const uintN errorNumber, ...);
8097 extern __attribute__((visibility ("default"))) void
8098 JS_ReportOutOfMemory(JSContext *cx);
8103 extern __attribute__((visibility ("default"))) void
8104 JS_ReportAllocationOverflow(JSContext *cx);
8106 struct JSErrorReport {
8107 const char *filename;
8109 const char *linebuf;
8110 const char *tokenptr;
8111 const jschar *uclinebuf;
8112 const jschar *uctokenptr;
8115 const jschar *ucmessage;
8116 const jschar **messageArgs;
8119 extern __attribute__((visibility ("default"))) JSErrorReporter
8120 JS_SetErrorReporter(JSContext *cx, JSErrorReporter er);
8128 extern __attribute__((visibility ("default"))) JSObject *
8129 JS_NewDateObject(JSContext *cx, int year, int mon, int mday, int hour, int min, int sec);
8131 extern __attribute__((visibility ("default"))) JSObject *
8132 JS_NewDateObjectMsec(JSContext *cx, jsdouble msec);
8137 extern __attribute__((visibility ("default"))) JSBool
8138 JS_ObjectIsDate(JSContext *cx, JSObject *obj);
8140 extern __attribute__((visibility ("default"))) JSObject *
8141 JS_NewRegExpObject(JSContext *cx, JSObject *obj, char *bytes, size_t length, uintN flags);
8143 extern __attribute__((visibility ("default"))) JSObject *
8144 JS_NewUCRegExpObject(JSContext *cx, JSObject *obj, jschar *chars, size_t length, uintN flags);
8146 extern __attribute__((visibility ("default"))) void
8147 JS_SetRegExpInput(JSContext *cx, JSObject *obj, JSString *input, JSBool multiline);
8149 extern __attribute__((visibility ("default"))) void
8150 JS_ClearRegExpStatics(JSContext *cx, JSObject *obj);
8152 extern __attribute__((visibility ("default"))) JSBool
8153 JS_ExecuteRegExp(JSContext *cx, JSObject *obj, JSObject *reobj, jschar *chars, size_t length,
8154 size_t *indexp, JSBool test, jsval *rval);
8158 extern __attribute__((visibility ("default"))) JSObject *
8159 JS_NewRegExpObjectNoStatics(JSContext *cx, char *bytes, size_t length, uintN flags);
8161 extern __attribute__((visibility ("default"))) JSObject *
8162 JS_NewUCRegExpObjectNoStatics(JSContext *cx, jschar *chars, size_t length, uintN flags);
8164 extern __attribute__((visibility ("default"))) JSBool
8165 JS_ExecuteRegExpNoStatics(JSContext *cx, JSObject *reobj, jschar *chars, size_t length,
8166 size_t *indexp, JSBool test, jsval *rval);
8170 extern __attribute__((visibility ("default"))) JSBool
8171 JS_IsExceptionPending(JSContext *cx);
8173 extern __attribute__((visibility ("default"))) JSBool
8174 JS_GetPendingException(JSContext *cx, jsval *vp);
8176 extern __attribute__((visibility ("default"))) void
8177 JS_SetPendingException(JSContext *cx, jsval v);
8179 extern __attribute__((visibility ("default"))) void
8180 JS_ClearPendingException(JSContext *cx);
8182 extern __attribute__((visibility ("default"))) JSBool
8183 JS_ReportPendingException(JSContext *cx);
8185 extern __attribute__((visibility ("default"))) JSExceptionState *
8186 JS_SaveExceptionState(JSContext *cx);
8188 extern __attribute__((visibility ("default"))) void
8189 JS_RestoreExceptionState(JSContext *cx, JSExceptionState *state);
8191 extern __attribute__((visibility ("default"))) void
8192 JS_DropExceptionState(JSContext *cx, JSExceptionState *state);
8194 extern __attribute__((visibility ("default"))) JSErrorReport *
8195 JS_ErrorFromException(JSContext *cx, jsval v);
8201 extern __attribute__((visibility ("default"))) JSBool
8202 JS_ThrowReportedError(JSContext *cx, const char *message,
8203 JSErrorReport *reportp);
8208 extern __attribute__((visibility ("default"))) JSBool
8209 JS_ThrowStopIteration(JSContext *cx);
8211 extern __attribute__((visibility ("default"))) jsword
8212 JS_GetContextThread(JSContext *cx);
8214 extern __attribute__((visibility ("default"))) jsword
8215 JS_SetContextThread(JSContext *cx);
8217 extern __attribute__((visibility ("default"))) jsword
8218 JS_ClearContextThread(JSContext *cx);
8220 static __attribute__((always_inline)) inline JSBool
8221 JS_IsConstructing(JSContext *cx, const jsval *vp)
8226 return JSVAL_IS_MAGIC_IMPL(l);
8229 static __attribute__((always_inline)) inline JSBool
8230 JS_IsConstructing_PossiblyWithGivenThisObject(JSContext *cx, const jsval *vp,
8231 JSObject **maybeThis)
8237 isCtor = JSVAL_IS_MAGIC_IMPL(l);
8239 *maybeThis = MAGIC_JSVAL_TO_OBJECT_OR_NULL_IMPL(l);
8248 extern __attribute__((visibility ("default"))) JSObject *
8249 JS_NewObjectForConstructor(JSContext *cx, const jsval *vp);
8257 # 1 "jsstaticcheck.h" 1
8263 static const uintN JS_GCTHING_ALIGN = 8;
8264 static const uintN JS_GCTHING_ZEROBITS = 3;
8267 typedef uint8 jsbytecode;
8268 typedef uint8 jssrcnote;
8269 typedef uint32 jsatomid;
8272 typedef struct JSArgumentFormatMap JSArgumentFormatMap;
8273 typedef struct JSCodeGenerator JSCodeGenerator;
8274 typedef struct JSGCThing JSGCThing;
8275 typedef struct JSGenerator JSGenerator;
8276 typedef struct JSNativeEnumerator JSNativeEnumerator;
8277 typedef struct JSFunctionBox JSFunctionBox;
8278 typedef struct JSObjectBox JSObjectBox;
8279 typedef struct JSParseNode JSParseNode;
8280 typedef struct JSProperty JSProperty;
8281 typedef struct JSScript JSScript;
8282 typedef struct JSSharpObjectMap JSSharpObjectMap;
8283 typedef struct JSThread JSThread;
8284 typedef struct JSThreadData JSThreadData;
8285 typedef struct JSTreeContext JSTreeContext;
8286 typedef struct JSTryNote JSTryNote;
8289 typedef struct JSLinearString JSLinearString;
8290 typedef struct JSAtom JSAtom;
8291 typedef struct JSAtomList JSAtomList;
8292 typedef struct JSAtomListElement JSAtomListElement;
8293 typedef struct JSAtomMap JSAtomMap;
8294 typedef struct JSAtomState JSAtomState;
8295 typedef struct JSCodeSpec JSCodeSpec;
8296 typedef struct JSPrinter JSPrinter;
8297 typedef struct JSRegExpStatics JSRegExpStatics;
8298 typedef struct JSStackHeader JSStackHeader;
8299 typedef struct JSSubString JSSubString;
8300 typedef struct JSNativeTraceInfo JSNativeTraceInfo;
8301 typedef struct JSSpecializedNative JSSpecializedNative;
8302 typedef struct JSXML JSXML;
8303 typedef struct JSXMLArray JSXMLArray;
8304 typedef struct JSXMLArrayCursor JSXMLArrayCursor;
8310 struct ArgumentsData;
8313 class RegExpStatics;
8314 class AutoStringRooter;
8315 class ExecuteArgsGuard;
8316 class InvokeFrameGuard;
8317 class InvokeArgsGuard;
8318 class InvokeSessionGuard;
8319 class TraceRecorder;
8320 struct TraceMonitor;
8323 class FrameRegsIter;
8333 class ContextAllocPolicy;
8334 class SystemAllocPolicy;
8337 size_t MinInlineCapacity = 0,
8338 class AllocPolicy = ContextAllocPolicy>
8342 struct DefaultHasher;
8344 template <class Key,
8346 class HashPolicy = DefaultHasher<Key>,
8347 class AllocPolicy = ContextAllocPolicy>
8351 class HashPolicy = DefaultHasher<T>,
8352 class AllocPolicy = ContextAllocPolicy>
8355 class PropertyCache;
8356 struct PropertyCacheEntry;
8367 typedef enum JSTrapStatus {
8375 typedef JSTrapStatus
8376 (* JSTrapHandler)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
8379 typedef JSTrapStatus
8380 (* JSInterruptHook)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
8383 typedef JSTrapStatus
8384 (* JSDebuggerHandler)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
8387 typedef JSTrapStatus
8388 (* JSThrowHook)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval,
8392 (* JSWatchPointHandler)(JSContext *cx, JSObject *obj, jsid id, jsval old,
8393 jsval *newp, void *closure);
8397 (* JSNewScriptHook)(JSContext *cx,
8398 const char *filename,
8406 (* JSDestroyScriptHook)(JSContext *cx,
8411 (* JSSourceHandler)(const char *filename, uintN lineno, jschar *str,
8412 size_t length, void **listenerTSData, void *closure);
8415 (* JSInterpreterHook)(JSContext *cx, JSStackFrame *fp, JSBool before,
8416 JSBool *ok, void *closure);
8419 (* JSDebugErrorHook)(JSContext *cx, const char *message, JSErrorReport *report,
8422 typedef struct JSDebugHooks {
8423 JSInterruptHook interruptHook;
8424 void *interruptHookData;
8425 JSNewScriptHook newScriptHook;
8426 void *newScriptHookData;
8427 JSDestroyScriptHook destroyScriptHook;
8428 void *destroyScriptHookData;
8429 JSDebuggerHandler debuggerHandler;
8430 void *debuggerHandlerData;
8431 JSSourceHandler sourceHandler;
8432 void *sourceHandlerData;
8433 JSInterpreterHook executeHook;
8434 void *executeHookData;
8435 JSInterpreterHook callHook;
8437 JSThrowHook throwHook;
8438 void *throwHookData;
8439 JSDebugErrorHook debugErrorHook;
8440 void *debugErrorHookData;
8444 (* JSLookupPropOp)(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
8445 JSProperty **propp);
8452 (* JSAttributesOp)(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp);
8459 (* JSObjectOp)(JSContext *cx, JSObject *obj);
8466 (* JSIteratorOp)(JSContext *cx, JSObject *obj, JSBool keysonly);
8468 extern JSBool js_CStringsAreUTF8;
8475 extern __attribute__((visibility ("default"))) JSObject *
8476 js_ObjectToOuterObject(JSContext *cx, JSObject *obj);
8483 # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4
8491 # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4
8499 typedef uint32 JSHashNumber;
8500 typedef struct JSHashEntry JSHashEntry;
8501 typedef struct JSHashTable JSHashTable;
8506 typedef JSHashNumber (* JSHashFunction)(const void *key);
8507 typedef intN (* JSHashComparator)(const void *v1, const void *v2);
8508 typedef intN (* JSHashEnumerator)(JSHashEntry *he, intN i, void *arg);
8515 typedef struct JSHashAllocOps {
8516 void * (*allocTable)(void *pool, size_t size);
8517 void (*freeTable)(void *pool, void *item, size_t size);
8518 JSHashEntry * (*allocEntry)(void *pool, const void *key);
8519 void (*freeEntry)(void *pool, JSHashEntry *he, uintN flag);
8525 struct JSHashEntry {
8527 JSHashNumber keyHash;
8532 struct JSHashTable {
8533 JSHashEntry **buckets;
8536 JSHashFunction keyHash;
8537 JSHashComparator keyCompare;
8538 JSHashComparator valueCompare;
8539 JSHashAllocOps *allocOps;
8553 extern __attribute__((visibility ("default"))) JSHashTable *
8554 JS_NewHashTable(uint32 n, JSHashFunction keyHash,
8555 JSHashComparator keyCompare, JSHashComparator valueCompare,
8556 JSHashAllocOps *allocOps, void *allocPriv);
8558 extern __attribute__((visibility ("default"))) void
8559 JS_HashTableDestroy(JSHashTable *ht);
8562 extern __attribute__((visibility ("default"))) JSHashEntry **
8563 JS_HashTableRawLookup(JSHashTable *ht, JSHashNumber keyHash, const void *key);
8566 extern __attribute__((visibility ("default"))) JSHashEntry *
8567 JS_HashTableRawAdd(JSHashTable *ht, JSHashEntry **&hep, JSHashNumber keyHash,
8568 const void *key, void *value);
8571 extern __attribute__((visibility ("default"))) void
8572 JS_HashTableRawRemove(JSHashTable *ht, JSHashEntry **hep, JSHashEntry *he);
8575 extern __attribute__((visibility ("default"))) JSHashEntry *
8576 JS_HashTableAdd(JSHashTable *ht, const void *key, void *value);
8578 extern __attribute__((visibility ("default"))) JSBool
8579 JS_HashTableRemove(JSHashTable *ht, const void *key);
8581 extern __attribute__((visibility ("default"))) intN
8582 JS_HashTableEnumerateEntries(JSHashTable *ht, JSHashEnumerator f, void *arg);
8584 extern __attribute__((visibility ("default"))) void *
8585 JS_HashTableLookup(JSHashTable *ht, const void *key);
8587 extern __attribute__((visibility ("default"))) intN
8588 JS_HashTableDump(JSHashTable *ht, JSHashEnumerator dump, FILE *fp);
8591 extern __attribute__((visibility ("default"))) JSHashNumber
8592 JS_HashString(const void *key);
8595 extern __attribute__((visibility ("default"))) intN
8596 JS_CompareValues(const void *v1, const void *v2);
8600 # 1 "jshashtable.h" 1
8601 # 46 "jshashtable.h"
8604 # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/new" 1 3
8605 # 37 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/new" 3
8607 # 38 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/new" 3
8609 # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/powerpc64-unknown-linux-gnu/bits/c++config.h" 1 3
8610 # 186 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/powerpc64-unknown-linux-gnu/bits/c++config.h" 3
8613 typedef long unsigned int size_t;
8614 typedef long int ptrdiff_t;
8620 # 350 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/powerpc64-unknown-linux-gnu/bits/c++config.h" 3
8623 inline namespace __gnu_cxx_ldbl128 { }
8625 # 430 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/powerpc64-unknown-linux-gnu/bits/c++config.h" 3
8626 # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/powerpc64-unknown-linux-gnu/bits/os_defines.h" 1 3
8627 # 431 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/powerpc64-unknown-linux-gnu/bits/c++config.h" 2 3
8630 # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/powerpc64-unknown-linux-gnu/bits/cpu_defines.h" 1 3
8631 # 434 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/powerpc64-unknown-linux-gnu/bits/c++config.h" 2 3
8632 # 40 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/new" 2 3
8633 # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/exception" 1 3
8634 # 33 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/exception" 3
8636 # 34 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/exception" 3
8638 #pragma GCC visibility push(default)
8641 # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/bits/atomic_lockfree_defines.h" 1 3
8642 # 33 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/bits/atomic_lockfree_defines.h" 3
8644 # 34 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/bits/atomic_lockfree_defines.h" 3
8645 # 39 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/exception" 2 3
8651 # 60 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/exception" 3
8655 exception() throw() { }
8656 virtual ~exception() throw();
8660 virtual const char* what() const throw();
8665 class bad_exception : public exception
8668 bad_exception() throw() { }
8672 virtual ~bad_exception() throw();
8675 virtual const char* what() const throw();
8679 typedef void (*terminate_handler) ();
8682 typedef void (*unexpected_handler) ();
8685 terminate_handler set_terminate(terminate_handler) throw();
8686 # 102 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/exception" 3
8687 void terminate() throw() __attribute__ ((__noreturn__));
8690 unexpected_handler set_unexpected(unexpected_handler) throw();
8691 # 114 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/exception" 3
8692 void unexpected() __attribute__ ((__noreturn__));
8693 # 127 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/exception" 3
8694 bool uncaught_exception() throw() __attribute__ ((__pure__));
8702 # 152 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/exception" 3
8703 void __verbose_terminate_handler();
8710 #pragma GCC visibility pop
8711 # 41 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/new" 2 3
8713 #pragma GCC visibility push(default)
8725 class bad_alloc : public exception
8728 bad_alloc() throw() { }
8732 virtual ~bad_alloc() throw();
8735 virtual const char* what() const throw();
8737 # 85 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/new" 3
8738 class bad_array_length : public bad_alloc
8741 bad_array_length() throw() { };
8745 virtual ~bad_array_length() throw();
8748 virtual const char* what() const throw();
8752 struct nothrow_t { };
8754 extern const nothrow_t nothrow;
8758 typedef void (*new_handler)();
8762 new_handler set_new_handler(new_handler) throw();
8769 # 128 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/g++-v4/new" 3
8770 void* operator new(std::size_t) throw(std::bad_alloc)
8771 __attribute__((__externally_visible__));
8772 void* operator new[](std::size_t) throw(std::bad_alloc)
8773 __attribute__((__externally_visible__));
8774 void operator delete(void*) throw()
8775 __attribute__((__externally_visible__));
8776 void operator delete[](void*) throw()
8777 __attribute__((__externally_visible__));
8778 void* operator new(std::size_t, const std::nothrow_t&) throw()
8779 __attribute__((__externally_visible__));
8780 void* operator new[](std::size_t, const std::nothrow_t&) throw()
8781 __attribute__((__externally_visible__));
8782 void operator delete(void*, const std::nothrow_t&) throw()
8783 __attribute__((__externally_visible__));
8784 void operator delete[](void*, const std::nothrow_t&) throw()
8785 __attribute__((__externally_visible__));
8788 inline void* operator new(std::size_t, void* __p) throw()
8790 inline void* operator new[](std::size_t, void* __p) throw()
8794 inline void operator delete (void*, void*) throw() { }
8795 inline void operator delete[](void*, void*) throw() { }
8799 #pragma GCC visibility pop
8808 template <size_t i, size_t j> struct Min {
8809 static const size_t result = i < j ? i : j;
8811 template <size_t i, size_t j> struct Max {
8812 static const size_t result = i > j ? i : j;
8814 template <size_t i, size_t min, size_t max> struct Clamp {
8815 static const size_t result = i < min ? min : (i > max ? max : i);
8819 template <size_t x, size_t y> struct Pow {
8820 static const size_t result = x * Pow<x, y - 1>::result;
8822 template <size_t x> struct Pow<x,0> {
8823 static const size_t result = 1;
8827 template <size_t i> struct FloorLog2 {
8828 static const size_t result = 1 + FloorLog2<i / 2>::result;
8830 template <> struct FloorLog2<0> { };
8831 template <> struct FloorLog2<1> { static const size_t result = 0; };
8834 template <size_t i> struct CeilingLog2 {
8835 static const size_t result = FloorLog2<2 * i - 1>::result;
8839 template <size_t i> struct RoundUpPow2 {
8840 static const size_t result = 1u << CeilingLog2<i>::result;
8842 template <> struct RoundUpPow2<0> {
8843 static const size_t result = 1;
8847 template <class T> struct BitSize {
8848 static const size_t result = sizeof(T) * 8;
8852 template <bool> struct StaticAssert {};
8853 template <> struct StaticAssert<true> { typedef int result; };
8856 template <class T, class U> struct IsSameType {
8857 static const bool result = false;
8859 template <class T> struct IsSameType<T,T> {
8860 static const bool result = true;
8867 template <size_t N> struct NBitMask {
8868 typedef typename StaticAssert<N < BitSize<size_t>::result>::result _;
8869 static const size_t result = (size_t(1) << N) - 1;
8871 template <> struct NBitMask<BitSize<size_t>::result> {
8872 static const size_t result = size_t(-1);
8879 template <size_t N> struct MulOverflowMask {
8880 static const size_t result =
8881 ~NBitMask<BitSize<size_t>::result - CeilingLog2<N>::result>::result;
8883 template <> struct MulOverflowMask<0> { };
8884 template <> struct MulOverflowMask<1> { static const size_t result = 0; };
8891 template <class T> struct UnsafeRangeSizeMask {
8896 static const size_t result = MulOverflowMask<2 * sizeof(T)>::result;
8900 template <class T> struct StripConst { typedef T result; };
8901 template <class T> struct StripConst<const T> { typedef T result; };
8907 template <class T> struct IsPodType { static const bool result = false; };
8908 template <> struct IsPodType<char> { static const bool result = true; };
8909 template <> struct IsPodType<signed char> { static const bool result = true; };
8910 template <> struct IsPodType<unsigned char> { static const bool result = true; };
8911 template <> struct IsPodType<short> { static const bool result = true; };
8912 template <> struct IsPodType<unsigned short> { static const bool result = true; };
8913 template <> struct IsPodType<int> { static const bool result = true; };
8914 template <> struct IsPodType<unsigned int> { static const bool result = true; };
8915 template <> struct IsPodType<long> { static const bool result = true; };
8916 template <> struct IsPodType<unsigned long> { static const bool result = true; };
8917 template <> struct IsPodType<float> { static const bool result = true; };
8918 template <> struct IsPodType<double> { static const bool result = true; };
8921 template <class T, size_t N> inline T *ArraySize(T (&)[N]) { return N; }
8922 template <class T, size_t N> inline T *ArrayEnd(T (&arr)[N]) { return arr + N; }
8927 class ReentrancyGuard
8930 ReentrancyGuard(const ReentrancyGuard &);
8931 void operator=(const ReentrancyGuard &);
8942 ReentrancyGuard(T & )
8963 __attribute__((always_inline)) inline size_t
8964 RoundUpPow2(size_t x)
8966 size_t log2 = ((x) <= 1 ? 0 : 1 + (((void) 0), ((size_t)((8 * 8) - 1 - __builtin_clzll((x) - 1)))));
8968 size_t result = size_t(1) << log2;
8979 __attribute__((always_inline)) inline size_t
8980 PointerRangeSize(T *begin, T *end)
8982 return (size_t(end) - size_t(begin)) / sizeof(T);
8985 class SystemAllocPolicy
8988 void *malloc(size_t bytes) { return js_malloc(bytes); }
8989 void *realloc(void *p, size_t bytes) { return js_realloc(p, bytes); }
8990 void free(void *p) { js_free(p); }
8991 void reportAllocOverflow() const {}
8994 template <size_t nbytes>
8995 struct AlignedStorage
9002 const void *addr() const { return u.bytes; }
9003 void *addr() { return u.bytes; }
9007 struct AlignedStorage2
9010 char bytes[sizeof(T)];
9014 const T *addr() const { return (const T *)u.bytes; }
9015 T *addr() { return (T *)u.bytes; }
9019 class LazilyConstructed
9021 AlignedStorage2<T> storage;
9024 T &asT() { return *storage.addr(); }
9027 LazilyConstructed() { constructed = false; }
9028 ~LazilyConstructed() { if (constructed) asT().~T(); }
9030 bool empty() const { return !constructed; }
9034 new(storage.addr()) T();
9039 void construct(const T1 &t1) {
9041 new(storage.addr()) T(t1);
9045 template <class T1, class T2>
9046 void construct(const T1 &t1, const T2 &t2) {
9048 new(storage.addr()) T(t1, t2);
9052 template <class T1, class T2, class T3>
9053 void construct(const T1 &t1, const T2 &t2, const T3 &t3) {
9055 new(storage.addr()) T(t1, t2, t3);
9059 template <class T1, class T2, class T3, class T4>
9060 void construct(const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4) {
9062 new(storage.addr()) T(t1, t2, t3, t4);
9078 constructed = false;
9088 class Conditionally {
9089 LazilyConstructed<T> t;
9092 Conditionally(bool b) { if (b) t.construct(); }
9095 Conditionally(bool b, const T1 &t1) { if (b) t.construct(t1); }
9097 template <class T1, class T2>
9098 Conditionally(bool b, const T1 &t1, const T2 &t2) { if (b) t.construct(t1, t2); }
9102 class AlignedPtrAndFlag
9107 AlignedPtrAndFlag(T *t, bool flag) {
9109 bits = uintptr_t(t) | uintptr_t(flag);
9113 return (T *)(bits & ~uintptr_t(1));
9117 return (bits & 1) != 0;
9122 bits = uintptr_t(t) | uintptr_t(flag());
9130 bits &= ~uintptr_t(1);
9133 void set(T *t, bool flag) {
9135 bits = uintptr_t(t) | flag;
9141 Reverse(T *beg, T *end)
9143 while (beg != end) {
9155 Find(T *beg, T *end, const T &v)
9157 for (T *p = beg; p != end; ++p) {
9164 template <class Container>
9165 static inline typename Container::ElementType *
9166 Find(Container &c, const typename Container::ElementType &v)
9168 return Find(c.begin(), c.end(), v);
9171 template <typename InputIterT, typename CallableT>
9173 ForEach(InputIterT begin, InputIterT end, CallableT f)
9175 for (; begin != end; ++begin)
9183 return t1 < t2 ? t1 : t2;
9190 return t1 > t2 ? t1 : t2;
9196 InitConst(const T &t)
9198 return const_cast<T &>(t);
9202 # 47 "jshashtable.h" 2
9207 typedef uint32 HashNumber;
9212 template <class T, class HashPolicy, class AllocPolicy>
9213 class HashTable : AllocPolicy
9215 typedef typename tl::StripConst<T>::result NonConstT;
9216 typedef typename HashPolicy::KeyType Key;
9217 typedef typename HashPolicy::Lookup Lookup;
9224 static void assignT(NonConstT &dst, const T &src) { dst = src; }
9231 Entry() : keyHash(0), t() {}
9232 void operator=(const Entry &rhs) { keyHash = rhs.keyHash; assignT(t, rhs.t); }
9236 bool isFree() const { return keyHash == sFreeKey; }
9237 void setFree() { keyHash = sFreeKey; assignT(t, T()); }
9238 bool isRemoved() const { return keyHash == sRemovedKey; }
9239 void setRemoved() { keyHash = sRemovedKey; assignT(t, T()); }
9240 bool isLive() const { return isLiveHash(keyHash); }
9241 void setLive(HashNumber hn) { ((void) 0); keyHash = hn; }
9243 void setCollision() { ((void) 0); keyHash |= sCollisionBit; }
9244 void setCollision(HashNumber collisionBit) {
9245 ((void) 0); keyHash |= collisionBit;
9247 void unsetCollision() { ((void) 0); keyHash &= ~sCollisionBit; }
9248 bool hasCollision() const { ((void) 0); return keyHash & sCollisionBit; }
9249 bool matchHash(HashNumber hn) { return (keyHash & ~sCollisionBit) == hn; }
9250 HashNumber getKeyHash() const { ((void) 0); return keyHash; }
9261 friend class HashTable;
9262 typedef void (Ptr::* ConvertibleToBool)();
9268 Ptr(Entry &entry) : entry(&entry) {}
9271 bool found() const { return entry->isLive(); }
9272 operator ConvertibleToBool() const { return found() ? &Ptr::nonNull : 0; }
9273 bool operator==(const Ptr &rhs) const { ((void) 0); return entry == rhs.entry; }
9274 bool operator!=(const Ptr &rhs) const { return !(*this == rhs); }
9276 T &operator*() const { return entry->t; }
9277 T *operator->() const { return &entry->t; }
9281 class AddPtr : public Ptr
9283 friend class HashTable;
9291 AddPtr(Entry &entry, HashNumber hn) : Ptr(entry), keyHash(hn) {}
9304 friend class HashTable;
9306 Range(Entry *c, Entry *e) : cur(c), end(e) {
9307 while (cur != end && !cur->isLive())
9314 bool empty() const {
9325 while (++cur != end && !cur->isLive());
9328 # 182 "jshashtable.h"
9329 class Enum : public Range
9331 friend class HashTable;
9338 void operator=(const Enum &);
9341 template<class Map> explicit
9342 Enum(Map &map) : Range(map.all()), table(map.impl), removed(false) {}
9343 # 206 "jshashtable.h"
9344 void removeFront() {
9345 table.remove(*this->cur);
9352 table.checkUnderloaded();
9356 void endEnumeration() {
9358 table.checkUnderloaded();
9366 uint32 tableCapacity;
9369 uint32 removedCount;
9372 void setTableSizeLog2(unsigned sizeLog2) {
9373 hashShift = sHashBits - sizeLog2;
9374 tableCapacity = ((JSUint32)1 << (sizeLog2));
9376 # 263 "jshashtable.h"
9377 static const unsigned sMinSizeLog2 = 4;
9378 static const unsigned sMinSize = 1 << sMinSizeLog2;
9379 static const unsigned sSizeLimit = ((JSUint32)1 << (24));
9380 static const unsigned sHashBits = tl::BitSize<HashNumber>::result;
9381 static const uint8 sMinAlphaFrac = 64;
9382 static const uint8 sMaxAlphaFrac = 192;
9383 static const uint8 sInvMaxAlpha = 171;
9384 static const HashNumber sGoldenRatio = 0x9E3779B9U;
9385 static const HashNumber sCollisionBit = 1;
9386 static const HashNumber sFreeKey = 0;
9387 static const HashNumber sRemovedKey = 1;
9389 static bool isLiveHash(HashNumber hash)
9391 return hash > sRemovedKey;
9394 static HashNumber prepareHash(const Lookup& l)
9396 HashNumber keyHash = HashPolicy::hash(l);
9399 keyHash *= sGoldenRatio;
9402 if (!isLiveHash(keyHash))
9403 keyHash -= (sRemovedKey + 1);
9404 return keyHash & ~sCollisionBit;
9407 static Entry *createTable(AllocPolicy &alloc, uint32 capacity)
9409 Entry *newTable = (Entry *)alloc.malloc(capacity * sizeof(Entry));
9412 for (Entry *e = newTable, *end = e + capacity; e != end; ++e)
9417 static void destroyTable(AllocPolicy &alloc, Entry *oldTable, uint32 capacity)
9419 for (Entry *e = oldTable, *end = e + capacity; e != end; ++e)
9421 alloc.free(oldTable);
9425 HashTable(AllocPolicy ap)
9437 bool init(uint32 length)
9447 uint32 capacity = (length * sInvMaxAlpha) >> 7;
9449 if (capacity < sMinSize)
9450 capacity = sMinSize;
9453 uint32 roundUp = sMinSize, roundUpLog2 = sMinSizeLog2;
9454 while (roundUp < capacity) {
9460 if (capacity >= sSizeLimit) {
9461 this->reportAllocOverflow();
9465 table = createTable(*this, capacity);
9469 setTableSizeLog2(roundUpLog2);
9474 bool initialized() const
9482 destroyTable(*this, table, tableCapacity);
9486 static HashNumber hash1(HashNumber hash0, uint32 shift) {
9487 return hash0 >> shift;
9490 static HashNumber hash2(HashNumber hash0, uint32 log2, uint32 shift) {
9491 return ((hash0 << log2) >> shift) | 1;
9495 return entryCount + removedCount >= ((sMaxAlphaFrac * tableCapacity) >> 8);
9498 bool underloaded() {
9499 return tableCapacity > sMinSize &&
9500 entryCount <= ((sMinAlphaFrac * tableCapacity) >> 8);
9503 static bool match(Entry &e, const Lookup &l) {
9504 return HashPolicy::match(HashPolicy::getKey(e.t), l);
9507 Entry &lookup(const Lookup &l, HashNumber keyHash, unsigned collisionBit) const
9516 HashNumber h1 = hash1(keyHash, hashShift);
9517 Entry *entry = &table[h1];
9520 if (entry->isFree()) {
9526 if (entry->matchHash(keyHash) && match(*entry, l)) {
9532 unsigned sizeLog2 = sHashBits - hashShift;
9533 HashNumber h2 = hash2(keyHash, sizeLog2, hashShift);
9534 HashNumber sizeMask = (HashNumber(1) << sizeLog2) - 1;
9537 Entry *firstRemoved = __null;
9540 if ((__builtin_expect((entry->isRemoved()), 0))) {
9542 firstRemoved = entry;
9544 entry->setCollision(collisionBit);
9552 if (entry->isFree()) {
9554 return firstRemoved ? *firstRemoved : *entry;
9557 if (entry->matchHash(keyHash) && match(*entry, l)) {
9563 # 458 "jshashtable.h"
9564 Entry &findFreeEntry(HashNumber keyHash)
9572 HashNumber h1 = hash1(keyHash, hashShift);
9573 Entry *entry = &table[h1];
9576 if (entry->isFree()) {
9582 unsigned sizeLog2 = sHashBits - hashShift;
9583 HashNumber h2 = hash2(keyHash, sizeLog2, hashShift);
9584 HashNumber sizeMask = (HashNumber(1) << sizeLog2) - 1;
9588 entry->setCollision();
9595 if (entry->isFree()) {
9602 bool changeTableSize(int deltaLog2)
9605 Entry *oldTable = table;
9606 uint32 oldCap = tableCapacity;
9607 uint32 newLog2 = sHashBits - hashShift + deltaLog2;
9608 uint32 newCapacity = ((JSUint32)1 << (newLog2));
9609 if (newCapacity >= sSizeLimit) {
9610 this->reportAllocOverflow();
9614 Entry *newTable = createTable(*this, newCapacity);
9619 setTableSizeLog2(newLog2);
9625 for (Entry *src = oldTable, *end = src + oldCap; src != end; ++src) {
9626 if (src->isLive()) {
9627 src->unsetCollision();
9628 findFreeEntry(src->getKeyHash()) = *src;
9632 destroyTable(*this, oldTable, oldCap);
9636 void remove(Entry &e)
9639 if (e.hasCollision()) {
9652 void checkUnderloaded()
9654 if (underloaded()) {
9656 (void) changeTableSize(-1);
9663 for (Entry *e = table, *end = table + tableCapacity; e != end; ++e)
9673 return Range(table, table + tableCapacity);
9676 bool empty() const {
9680 uint32 count() const{
9684 uint32 generation() const {
9688 Ptr lookup(const Lookup &l) const {
9689 ReentrancyGuard g(*this);
9690 HashNumber keyHash = prepareHash(l);
9691 return Ptr(lookup(l, keyHash, 0));
9694 AddPtr lookupForAdd(const Lookup &l) const {
9695 ReentrancyGuard g(*this);
9696 HashNumber keyHash = prepareHash(l);
9697 Entry &entry = lookup(l, keyHash, sCollisionBit);
9701 return AddPtr(entry, keyHash);
9707 ReentrancyGuard g(*this);
9717 if (p.entry->isRemoved()) {
9720 p.keyHash |= sCollisionBit;
9726 if (removedCount >= (tableCapacity >> 2)) {
9734 if (!changeTableSize(deltaLog2))
9738 p.entry = &findFreeEntry(p.keyHash);
9742 p.entry->setLive(p.keyHash);
9755 bool add(AddPtr &p, T** pentry)
9759 *pentry = &p.entry->t;
9763 bool add(AddPtr &p, const T &t)
9771 bool relookupOrAdd(AddPtr& p, const Lookup &l, const T& t)
9777 ReentrancyGuard g(*this);
9778 p.entry = &lookup(l, p.keyHash, sCollisionBit);
9780 return p.found() || add(p, t);
9785 ReentrancyGuard g(*this);
9794 # 717 "jshashtable.h"
9795 template <class Key>
9796 struct DefaultHasher
9799 static HashNumber hash(const Lookup &l) {
9803 static bool match(const Key &k, const Lookup &l) {
9811 struct DefaultHasher<T *>
9814 static HashNumber hash(T *l) {
9819 return HashNumber(reinterpret_cast<size_t>(l) >>
9820 tl::FloorLog2<sizeof(void *)>::result);
9822 static bool match(T *k, T *l) {
9826 # 765 "jshashtable.h"
9827 template <class Key, class Value, class HashPolicy, class AllocPolicy>
9831 typedef typename HashPolicy::Lookup Lookup;
9835 template <class, class, class> friend class detail::HashTable;
9836 void operator=(const Entry &rhs) {
9837 const_cast<Key &>(key) = rhs.key;
9842 Entry() : key(), value() {}
9843 Entry(const Key &k, const Value &v) : key(k), value(v) {}
9851 struct MapHashPolicy : HashPolicy
9853 typedef Key KeyType;
9854 static const Key &getKey(Entry &e) { return e.key; }
9856 typedef detail::HashTable<Entry, MapHashPolicy, AllocPolicy> Impl;
9858 friend class Impl::Enum;
9861 HashMap(const HashMap &);
9862 HashMap &operator=(const HashMap &);
9871 HashMap(AllocPolicy a = AllocPolicy()) : impl(a) {}
9872 bool init(uint32 len = 0) { return impl.init(len); }
9873 bool initialized() const { return impl.initialized(); }
9874 # 826 "jshashtable.h"
9875 typedef typename Impl::Ptr Ptr;
9876 Ptr lookup(const Lookup &l) const { return impl.lookup(l); }
9879 void remove(Ptr p) { impl.remove(p); }
9880 # 867 "jshashtable.h"
9881 typedef typename Impl::AddPtr AddPtr;
9882 AddPtr lookupForAdd(const Lookup &l) const {
9883 return impl.lookupForAdd(l);
9886 bool add(AddPtr &p, const Key &k, const Value &v) {
9888 if (!impl.add(p, &pentry))
9890 const_cast<Key &>(pentry->key) = k;
9895 bool add(AddPtr &p, const Key &k) {
9897 if (!impl.add(p, &pentry))
9899 const_cast<Key &>(pentry->key) = k;
9903 bool relookupOrAdd(AddPtr &p, const Key &k, const Value &v) {
9904 return impl.relookupOrAdd(p, k, Entry(k, v));
9906 # 903 "jshashtable.h"
9907 typedef typename Impl::Range Range;
9908 Range all() const { return impl.all(); }
9909 size_t count() const { return impl.count(); }
9910 # 920 "jshashtable.h"
9911 typedef typename Impl::Enum Enum;
9914 void clear() { impl.clear(); }
9917 bool empty() const { return impl.empty(); }
9923 unsigned generation() const { return impl.generation(); }
9927 bool has(const Lookup &l) const {
9928 return impl.lookup(l) != __null;
9931 Entry *put(const Key &k, const Value &v) {
9932 AddPtr p = lookupForAdd(k);
9937 return add(p, k, v) ? &*p : __null;
9940 void remove(const Lookup &l) {
9941 if (Ptr p = lookup(l))
9945 # 971 "jshashtable.h"
9946 template <class T, class HashPolicy, class AllocPolicy>
9949 typedef typename HashPolicy::Lookup Lookup;
9952 struct SetOps : HashPolicy {
9954 static const KeyType &getKey(const T &t) { return t; }
9956 typedef detail::HashTable<const T, SetOps, AllocPolicy> Impl;
9958 friend class Impl::Enum;
9961 HashSet(const HashSet &);
9962 HashSet &operator=(const HashSet &);
9971 HashSet(AllocPolicy a = AllocPolicy()) : impl(a) {}
9972 bool init(uint32 len = 0) { return impl.init(len); }
9973 bool initialized() const { return impl.initialized(); }
9974 # 1011 "jshashtable.h"
9975 typedef typename Impl::Ptr Ptr;
9976 Ptr lookup(const Lookup &l) const { return impl.lookup(l); }
9979 void remove(Ptr p) { impl.remove(p); }
9980 # 1051 "jshashtable.h"
9981 typedef typename Impl::AddPtr AddPtr;
9982 AddPtr lookupForAdd(const Lookup &l) const {
9983 return impl.lookupForAdd(l);
9986 bool add(AddPtr &p, const T &t) {
9987 return impl.add(p, t);
9990 bool relookupOrAdd(AddPtr &p, const Lookup &l, const T &t) {
9991 return impl.relookupOrAdd(p, l, t);
9993 # 1074 "jshashtable.h"
9994 typedef typename Impl::Range Range;
9995 Range all() const { return impl.all(); }
9996 size_t count() const { return impl.count(); }
9997 # 1091 "jshashtable.h"
9998 typedef typename Impl::Enum Enum;
10001 void clear() { impl.clear(); }
10004 bool empty() const { return impl.empty(); }
10010 unsigned generation() const { return impl.generation(); }
10014 bool has(const Lookup &l) const {
10015 return impl.lookup(l) != __null;
10018 const T *put(const T &t) {
10019 AddPtr p = lookupForAdd(t);
10020 return p ? &*p : (add(p, t) ? &*p : __null);
10023 void remove(const Lookup &l) {
10024 if (Ptr p = lookup(l))
10034 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/ctype.h" 1 3 4
10035 # 28 "/usr/powerpc64-unknown-linux-gnu/usr/include/ctype.h" 3 4
10037 # 46 "/usr/powerpc64-unknown-linux-gnu/usr/include/ctype.h" 3 4
10040 _ISupper = (1 << (0)),
10041 _ISlower = (1 << (1)),
10042 _ISalpha = (1 << (2)),
10043 _ISdigit = (1 << (3)),
10044 _ISxdigit = (1 << (4)),
10045 _ISspace = (1 << (5)),
10046 _ISprint = (1 << (6)),
10047 _ISgraph = (1 << (7)),
10048 _ISblank = (1 << (8)),
10049 _IScntrl = (1 << (9)),
10050 _ISpunct = (1 << (10)),
10051 _ISalnum = (1 << (11))
10053 # 79 "/usr/powerpc64-unknown-linux-gnu/usr/include/ctype.h" 3 4
10054 extern const unsigned short int **__ctype_b_loc (void)
10055 throw () __attribute__ ((__const__));
10056 extern const __int32_t **__ctype_tolower_loc (void)
10057 throw () __attribute__ ((__const__));
10058 extern const __int32_t **__ctype_toupper_loc (void)
10059 throw () __attribute__ ((__const__));
10060 # 104 "/usr/powerpc64-unknown-linux-gnu/usr/include/ctype.h" 3 4
10067 extern int isalnum (int) throw ();
10068 extern int isalpha (int) throw ();
10069 extern int iscntrl (int) throw ();
10070 extern int isdigit (int) throw ();
10071 extern int islower (int) throw ();
10072 extern int isgraph (int) throw ();
10073 extern int isprint (int) throw ();
10074 extern int ispunct (int) throw ();
10075 extern int isspace (int) throw ();
10076 extern int isupper (int) throw ();
10077 extern int isxdigit (int) throw ();
10081 extern int tolower (int __c) throw ();
10084 extern int toupper (int __c) throw ();
10093 extern int isblank (int) throw ();
10100 extern int isctype (int __c, int __mask) throw ();
10107 extern int isascii (int __c) throw ();
10111 extern int toascii (int __c) throw ();
10115 extern int _toupper (int) throw ();
10116 extern int _tolower (int) throw ();
10117 # 271 "/usr/powerpc64-unknown-linux-gnu/usr/include/ctype.h" 3 4
10118 extern int isalnum_l (int, __locale_t) throw ();
10119 extern int isalpha_l (int, __locale_t) throw ();
10120 extern int iscntrl_l (int, __locale_t) throw ();
10121 extern int isdigit_l (int, __locale_t) throw ();
10122 extern int islower_l (int, __locale_t) throw ();
10123 extern int isgraph_l (int, __locale_t) throw ();
10124 extern int isprint_l (int, __locale_t) throw ();
10125 extern int ispunct_l (int, __locale_t) throw ();
10126 extern int isspace_l (int, __locale_t) throw ();
10127 extern int isupper_l (int, __locale_t) throw ();
10128 extern int isxdigit_l (int, __locale_t) throw ();
10130 extern int isblank_l (int, __locale_t) throw ();
10134 extern int __tolower_l (int __c, __locale_t __l) throw ();
10135 extern int tolower_l (int __c, __locale_t __l) throw ();
10138 extern int __toupper_l (int __c, __locale_t __l) throw ();
10139 extern int toupper_l (int __c, __locale_t __l) throw ();
10140 # 347 "/usr/powerpc64-unknown-linux-gnu/usr/include/ctype.h" 3 4
10148 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/pratom.h" 1
10149 # 14 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/pratom.h"
10150 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h" 1
10151 # 26 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h"
10152 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prcpucfg.h" 1
10153 # 27 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h" 2
10156 # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4
10157 # 30 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h" 2
10158 # 206 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h"
10160 # 246 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h"
10161 typedef unsigned char PRUint8;
10162 # 260 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h"
10163 typedef signed char PRInt8;
10164 # 285 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h"
10165 typedef unsigned short PRUint16;
10166 typedef short PRInt16;
10167 # 310 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h"
10168 typedef unsigned int PRUint32;
10169 typedef int PRInt32;
10170 # 365 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h"
10171 typedef long PRInt64;
10172 typedef unsigned long PRUint64;
10173 # 410 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h"
10174 typedef int PRIntn;
10175 typedef unsigned int PRUintn;
10176 # 421 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h"
10177 typedef double PRFloat64;
10184 typedef size_t PRSize;
10192 typedef PRInt32 PROffset32;
10193 typedef PRInt64 PROffset64;
10201 typedef ptrdiff_t PRPtrdiff;
10202 # 456 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h"
10203 typedef unsigned long PRUptrdiff;
10204 # 467 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h"
10205 typedef PRIntn PRBool;
10206 # 477 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h"
10207 typedef PRUint8 PRPackedBool;
10213 typedef enum { PR_FAILURE = -1, PR_SUCCESS = 0 } PRStatus;
10220 typedef PRUint16 PRUnichar;
10221 # 509 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h"
10222 typedef long PRWord;
10223 typedef unsigned long PRUword;
10224 # 574 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h"
10225 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/obsolete/protypes.h" 1
10226 # 575 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h" 2
10227 # 587 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prtypes.h"
10229 # 15 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/pratom.h" 2
10230 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prlock.h" 1
10231 # 21 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prlock.h"
10233 # 34 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prlock.h"
10234 typedef struct PRLock PRLock;
10235 # 51 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prlock.h"
10236 extern __attribute__((visibility("default"))) PRLock* PR_NewLock(void);
10237 # 62 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prlock.h"
10238 extern __attribute__((visibility("default"))) void PR_DestroyLock(PRLock *lock);
10239 # 73 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prlock.h"
10240 extern __attribute__((visibility("default"))) void PR_Lock(PRLock *lock);
10241 # 85 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prlock.h"
10242 extern __attribute__((visibility("default"))) PRStatus PR_Unlock(PRLock *lock);
10243 # 105 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prlock.h"
10244 extern __attribute__((visibility("default"))) void PR_AssertCurrentThreadOwnsLock(PRLock *lock);
10247 # 16 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/pratom.h" 2
10250 # 28 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/pratom.h"
10251 extern __attribute__((visibility("default"))) PRInt32 PR_AtomicIncrement(PRInt32 *val);
10252 # 39 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/pratom.h"
10253 extern __attribute__((visibility("default"))) PRInt32 PR_AtomicDecrement(PRInt32 *val);
10254 # 51 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/pratom.h"
10255 extern __attribute__((visibility("default"))) PRInt32 PR_AtomicSet(PRInt32 *val, PRInt32 newval);
10256 # 63 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/pratom.h"
10257 extern __attribute__((visibility("default"))) PRInt32 PR_AtomicAdd(PRInt32 *ptr, PRInt32 val);
10258 # 137 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/pratom.h"
10259 typedef struct PRStackElemStr PRStackElem;
10261 struct PRStackElemStr {
10262 PRStackElem *prstk_elem_next;
10266 typedef struct PRStackStr PRStack;
10267 # 155 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/pratom.h"
10268 extern __attribute__((visibility("default"))) PRStack * PR_CreateStack(const char *stack_name);
10269 # 167 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/pratom.h"
10270 extern __attribute__((visibility("default"))) void PR_StackPush(PRStack *stack, PRStackElem *stack_elem);
10271 # 180 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/pratom.h"
10272 extern __attribute__((visibility("default"))) PRStackElem * PR_StackPop(PRStack *stack);
10273 # 194 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/pratom.h"
10274 extern __attribute__((visibility("default"))) PRStatus PR_DestroyStack(PRStack *stack);
10278 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prlock.h" 1
10280 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prcvar.h" 1
10281 # 10 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prcvar.h"
10282 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prinrval.h" 1
10283 # 23 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prinrval.h"
10290 typedef PRUint32 PRIntervalTime;
10291 # 79 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prinrval.h"
10292 extern __attribute__((visibility("default"))) PRIntervalTime PR_IntervalNow(void);
10293 # 97 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prinrval.h"
10294 extern __attribute__((visibility("default"))) PRUint32 PR_TicksPerSecond(void);
10295 # 116 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prinrval.h"
10296 extern __attribute__((visibility("default"))) PRIntervalTime PR_SecondsToInterval(PRUint32 seconds);
10297 extern __attribute__((visibility("default"))) PRIntervalTime PR_MillisecondsToInterval(PRUint32 milli);
10298 extern __attribute__((visibility("default"))) PRIntervalTime PR_MicrosecondsToInterval(PRUint32 micro);
10299 # 137 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prinrval.h"
10300 extern __attribute__((visibility("default"))) PRUint32 PR_IntervalToSeconds(PRIntervalTime ticks);
10301 extern __attribute__((visibility("default"))) PRUint32 PR_IntervalToMilliseconds(PRIntervalTime ticks);
10302 extern __attribute__((visibility("default"))) PRUint32 PR_IntervalToMicroseconds(PRIntervalTime ticks);
10305 # 11 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prcvar.h" 2
10309 typedef struct PRCondVar PRCondVar;
10310 # 27 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prcvar.h"
10311 extern __attribute__((visibility("default"))) PRCondVar* PR_NewCondVar(PRLock *lock);
10319 extern __attribute__((visibility("default"))) void PR_DestroyCondVar(PRCondVar *cvar);
10320 # 65 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prcvar.h"
10321 extern __attribute__((visibility("default"))) PRStatus PR_WaitCondVar(PRCondVar *cvar, PRIntervalTime timeout);
10322 # 80 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prcvar.h"
10323 extern __attribute__((visibility("default"))) PRStatus PR_NotifyCondVar(PRCondVar *cvar);
10324 # 90 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prcvar.h"
10325 extern __attribute__((visibility("default"))) PRStatus PR_NotifyAllCondVar(PRCondVar *cvar);
10329 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prthread.h" 1
10330 # 49 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prthread.h"
10333 typedef struct PRThread PRThread;
10334 typedef struct PRThreadStack PRThreadStack;
10336 typedef enum PRThreadType {
10341 typedef enum PRThreadScope {
10344 PR_GLOBAL_BOUND_THREAD
10347 typedef enum PRThreadState {
10348 PR_JOINABLE_THREAD,
10349 PR_UNJOINABLE_THREAD
10352 typedef enum PRThreadPriority
10354 PR_PRIORITY_FIRST = 0,
10355 PR_PRIORITY_LOW = 0,
10356 PR_PRIORITY_NORMAL = 1,
10357 PR_PRIORITY_HIGH = 2,
10358 PR_PRIORITY_URGENT = 3,
10359 PR_PRIORITY_LAST = 3
10360 } PRThreadPriority;
10361 # 105 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prthread.h"
10362 extern __attribute__((visibility("default"))) PRThread* PR_CreateThread(PRThreadType type,
10363 void ( *start)(void *arg),
10365 PRThreadPriority priority,
10366 PRThreadScope scope,
10367 PRThreadState state,
10368 PRUint32 stackSize);
10369 # 126 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prthread.h"
10370 extern __attribute__((visibility("default"))) PRStatus PR_JoinThread(PRThread *thread);
10376 extern __attribute__((visibility("default"))) PRThread* PR_GetCurrentThread(void);
10384 extern __attribute__((visibility("default"))) PRThreadPriority PR_GetThreadPriority(const PRThread *thread);
10385 # 152 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prthread.h"
10386 extern __attribute__((visibility("default"))) void PR_SetThreadPriority(PRThread *thread, PRThreadPriority priority);
10392 extern __attribute__((visibility("default"))) PRStatus PR_SetCurrentThreadName(const char *name);
10397 extern __attribute__((visibility("default"))) const char * PR_GetThreadName(const PRThread *thread);
10398 # 189 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prthread.h"
10399 typedef void ( *PRThreadPrivateDTOR)(void *priv);
10401 extern __attribute__((visibility("default"))) PRStatus PR_NewThreadPrivateIndex(
10402 PRUintn *newIndex, PRThreadPrivateDTOR destructor);
10403 # 205 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prthread.h"
10404 extern __attribute__((visibility("default"))) PRStatus PR_SetThreadPrivate(PRUintn tpdIndex, void *priv);
10405 # 216 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prthread.h"
10406 extern __attribute__((visibility("default"))) void* PR_GetThreadPrivate(PRUintn tpdIndex);
10407 # 228 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prthread.h"
10408 extern __attribute__((visibility("default"))) PRStatus PR_Interrupt(PRThread *thread);
10414 extern __attribute__((visibility("default"))) void PR_ClearInterrupt(void);
10419 extern __attribute__((visibility("default"))) void PR_BlockInterrupt(void);
10424 extern __attribute__((visibility("default"))) void PR_UnblockInterrupt(void);
10425 # 253 "/usr/powerpc64-unknown-linux-gnu/usr/include/nspr/prthread.h"
10426 extern __attribute__((visibility("default"))) PRStatus PR_Sleep(PRIntervalTime ticks);
10431 extern __attribute__((visibility("default"))) PRThreadScope PR_GetThreadScope(const PRThread *thread);
10436 extern __attribute__((visibility("default"))) PRThreadType PR_GetThreadType(const PRThread *thread);
10441 extern __attribute__((visibility("default"))) PRThreadState PR_GetThreadState(const PRThread *thread);
10449 typedef struct JSFatLock JSFatLock;
10451 typedef struct JSThinLock {
10459 typedef PRLock JSLock;
10461 extern void js_Lock(JSContext *cx, JSThinLock *tl);
10462 extern void js_Unlock(JSContext *cx, JSThinLock *tl);
10463 extern void js_LockRuntime(JSRuntime *rt);
10464 extern void js_UnlockRuntime(JSRuntime *rt);
10465 extern int js_SetupLocks(int,int);
10466 extern void js_CleanupLocks();
10467 extern void js_InitLock(JSThinLock *);
10468 extern void js_FinishLock(JSThinLock *);
10471 js_CompareAndSwap(volatile jsword *w, jsword ov, jsword nv);
10475 js_AtomicSetMask(volatile jsword *w, jsword mask);
10482 js_AtomicClearMask(volatile jsword *w, jsword mask);
10494 AutoLock(JSLock *lock) : lock(lock) { PR_Lock(lock); }
10495 ~AutoLock() { PR_Unlock(lock); }
10505 JSDOUBLE_IS_NEGZERO(jsdouble d)
10512 return (d == 0 && (sizeof (d) == sizeof (float) ? __signbitf (d) : sizeof (d) == sizeof (double) ? __signbit (d) : __signbitl (d)));
10520 JSDOUBLE_IS_INT32(jsdouble d, int32_t* pi)
10522 if (JSDOUBLE_IS_NEGZERO(d))
10524 return d == (*pi = int32_t(d));
10527 static __attribute__((always_inline)) inline JSBool
10528 JSVAL_IS_SPECIFIC_INT32_IMPL(jsval_layout l, int32 i32)
10530 return l.asBits == (((uint64)(uint32)i32) | JSVAL_SHIFTED_TAG_INT32);
10533 static __attribute__((always_inline)) inline JSBool
10534 JSVAL_IS_SPECIFIC_BOOLEAN(jsval_layout l, JSBool b)
10536 return l.asBits == (((uint64)(uint32)b) | JSVAL_SHIFTED_TAG_BOOLEAN);
10539 static __attribute__((always_inline)) inline jsval_layout
10540 MAGIC_TO_JSVAL_IMPL(JSWhyMagic why)
10543 l.asBits = ((uint64)(uint32)why) | JSVAL_SHIFTED_TAG_MAGIC;
10547 static __attribute__((always_inline)) inline jsval_layout
10548 MAGIC_TO_JSVAL_IMPL(JSObject *obj)
10551 l.asBits = ((uint64)obj) | JSVAL_SHIFTED_TAG_MAGIC;
10555 static __attribute__((always_inline)) inline JSBool
10556 JSVAL_SAME_TYPE_IMPL(jsval_layout lhs, jsval_layout rhs)
10558 uint64 lbits = lhs.asBits, rbits = rhs.asBits;
10559 return (lbits <= JSVAL_TAG_MAX_DOUBLE && rbits <= JSVAL_TAG_MAX_DOUBLE) ||
10560 (((lbits ^ rbits) & 0xFFFF800000000000LL) == 0);
10563 static __attribute__((always_inline)) inline jsval_layout
10564 PRIVATE_UINT32_TO_JSVAL_IMPL(uint32 ui)
10567 l.asBits = (uint64)ui;
10572 static __attribute__((always_inline)) inline uint32
10573 JSVAL_TO_PRIVATE_UINT32_IMPL(jsval_layout l)
10576 return (uint32)l.asBits;
10579 static __attribute__((always_inline)) inline JSValueType
10580 JSVAL_EXTRACT_NON_DOUBLE_TYPE_IMPL(jsval_layout l)
10582 uint64 type = (l.asBits >> 47) & 0xF;
10584 return (JSValueType)type;
10587 static __attribute__((always_inline)) inline JSValueTag
10588 JSVAL_EXTRACT_NON_DOUBLE_TAG_IMPL(jsval_layout l)
10590 uint64 tag = l.asBits >> 47;
10592 return (JSValueTag)tag;
10596 typedef int js_static_assert3[(__builtin_offsetof (jsval_layout, s.payload) == 0) ? 1 : -1];
10597 typedef int js_static_assert4[((JSVAL_TYPE_NONFUNOBJ & 0xF) == JSVAL_TYPE_OBJECT) ? 1 : -1];
10598 typedef int js_static_assert5[((JSVAL_TYPE_FUNOBJ & 0xF) == JSVAL_TYPE_OBJECT) ? 1 : -1];
10601 static __attribute__((always_inline)) inline jsval_layout
10602 BOX_NON_DOUBLE_JSVAL(JSValueType type, uint64 *slot)
10607 uint32 isI32 = (uint32)(type < JSVAL_TYPE_MAGIC);
10608 uint32 shift = isI32 * 32;
10609 uint64 mask = ((uint64)-1) >> shift;
10610 uint64 payload = *slot & mask;
10616 l.asBits = payload | (((uint64)((JSValueTag)(JSVAL_TAG_MAX_DOUBLE | (type & 0xF)))) << 47);
10620 static __attribute__((always_inline)) inline void
10621 UNBOX_NON_DOUBLE_JSVAL(jsval_layout l, uint64 *out)
10624 *out = (l.asBits & 0x00007FFFFFFFFFFFLL);
10643 __attribute__((always_inline)) inline
10645 data.asBits = (((((uint64)(uint32)(JSVAL_TAG_NULL)) << 47) | (0)));
10648 __attribute__((always_inline)) inline
10649 void setUndefined() {
10650 data.asBits = (((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)));
10653 __attribute__((always_inline)) inline
10654 void setInt32(int32 i) {
10655 data = INT32_TO_JSVAL_IMPL(i);
10658 __attribute__((always_inline)) inline
10659 int32 &getInt32Ref() {
10661 return data.s.payload.i32;
10664 __attribute__((always_inline)) inline
10665 void setDouble(double d) {
10666 data = DOUBLE_TO_JSVAL_IMPL(d);
10669 __attribute__((always_inline)) inline
10670 double &getDoubleRef() {
10672 return data.asDouble;
10675 __attribute__((always_inline)) inline
10676 void setString(JSString *str) {
10677 data = STRING_TO_JSVAL_IMPL(str);
10680 __attribute__((always_inline)) inline
10681 void setObject(JSObject &obj) {
10682 data = OBJECT_TO_JSVAL_IMPL(&obj);
10685 __attribute__((always_inline)) inline
10686 void setBoolean(bool b) {
10687 data = BOOLEAN_TO_JSVAL_IMPL(b);
10690 __attribute__((always_inline)) inline
10691 void setMagic(JSWhyMagic why) {
10692 data = MAGIC_TO_JSVAL_IMPL(why);
10695 __attribute__((always_inline)) inline
10696 void setMagicWithObjectOrNullPayload(JSObject *obj) {
10697 data = MAGIC_TO_JSVAL_IMPL(obj);
10700 __attribute__((always_inline)) inline
10701 JSObject *getMagicObjectOrNullPayload() const {
10702 return MAGIC_JSVAL_TO_OBJECT_OR_NULL_IMPL(data);
10705 __attribute__((always_inline)) inline
10706 void setNumber(uint32 ui) {
10707 if (ui > ((jsint)0x7fffffff))
10708 setDouble((double)ui);
10710 setInt32((int32)ui);
10713 __attribute__((always_inline)) inline
10714 void setNumber(double d) {
10716 if (JSDOUBLE_IS_INT32(d, &i))
10722 __attribute__((always_inline)) inline
10723 void setObjectOrNull(JSObject *arg) {
10730 __attribute__((always_inline)) inline
10731 void setObjectOrUndefined(JSObject *arg) {
10738 __attribute__((always_inline)) inline
10739 void swap(Value &rhs) {
10740 uint64 tmp = rhs.data.asBits;
10741 rhs.data.asBits = data.asBits;
10747 __attribute__((always_inline)) inline
10748 bool isUndefined() const {
10749 return JSVAL_IS_UNDEFINED_IMPL(data);
10752 __attribute__((always_inline)) inline
10753 bool isNull() const {
10754 return JSVAL_IS_NULL_IMPL(data);
10757 __attribute__((always_inline)) inline
10758 bool isNullOrUndefined() const {
10759 return isNull() || isUndefined();
10762 __attribute__((always_inline)) inline
10763 bool isInt32() const {
10764 return JSVAL_IS_INT32_IMPL(data);
10767 __attribute__((always_inline)) inline
10768 bool isInt32(int32 i32) const {
10769 return JSVAL_IS_SPECIFIC_INT32_IMPL(data, i32);
10772 __attribute__((always_inline)) inline
10773 bool isDouble() const {
10774 return JSVAL_IS_DOUBLE_IMPL(data);
10777 __attribute__((always_inline)) inline
10778 bool isNumber() const {
10779 return JSVAL_IS_NUMBER_IMPL(data);
10782 __attribute__((always_inline)) inline
10783 bool isString() const {
10784 return JSVAL_IS_STRING_IMPL(data);
10787 __attribute__((always_inline)) inline
10788 bool isObject() const {
10789 return JSVAL_IS_OBJECT_IMPL(data);
10792 __attribute__((always_inline)) inline
10793 bool isPrimitive() const {
10794 return JSVAL_IS_PRIMITIVE_IMPL(data);
10797 __attribute__((always_inline)) inline
10798 bool isObjectOrNull() const {
10799 return JSVAL_IS_OBJECT_OR_NULL_IMPL(data);
10802 __attribute__((always_inline)) inline
10803 bool isGCThing() const {
10804 return JSVAL_IS_GCTHING_IMPL(data);
10807 __attribute__((always_inline)) inline
10808 bool isBoolean() const {
10809 return JSVAL_IS_BOOLEAN_IMPL(data);
10812 __attribute__((always_inline)) inline
10813 bool isTrue() const {
10814 return JSVAL_IS_SPECIFIC_BOOLEAN(data, true);
10817 __attribute__((always_inline)) inline
10818 bool isFalse() const {
10819 return JSVAL_IS_SPECIFIC_BOOLEAN(data, false);
10822 __attribute__((always_inline)) inline
10823 bool isMagic() const {
10824 return JSVAL_IS_MAGIC_IMPL(data);
10827 __attribute__((always_inline)) inline
10828 bool isMagic(JSWhyMagic why) const {
10830 return JSVAL_IS_MAGIC_IMPL(data);
10834 __attribute__((always_inline)) inline
10835 bool hasPtrPayload() const {
10836 return data.asBits >= JSVAL_SHIFTED_TAG_MAGIC;
10840 __attribute__((always_inline)) inline
10841 bool isMarkable() const {
10842 return JSVAL_IS_TRACEABLE_IMPL(data);
10845 __attribute__((always_inline)) inline
10846 int32 gcKind() const {
10848 return JSVAL_TRACE_KIND_IMPL(data);
10851 __attribute__((always_inline)) inline
10852 bool operator==(const Value &rhs) const {
10853 return data.asBits == rhs.data.asBits;
10856 __attribute__((always_inline)) inline
10857 bool operator!=(const Value &rhs) const {
10858 return data.asBits != rhs.data.asBits;
10864 friend bool SameType(const Value &lhs, const Value &rhs);
10868 __attribute__((always_inline)) inline
10869 int32 toInt32() const {
10871 return JSVAL_TO_INT32_IMPL(data);
10874 __attribute__((always_inline)) inline
10875 double toDouble() const {
10877 return data.asDouble;
10880 __attribute__((always_inline)) inline
10881 double toNumber() const {
10883 return isDouble() ? toDouble() : double(toInt32());
10886 __attribute__((always_inline)) inline
10887 JSString *toString() const {
10889 return JSVAL_TO_STRING_IMPL(data);
10892 __attribute__((always_inline)) inline
10893 JSObject &toObject() const {
10895 return *JSVAL_TO_OBJECT_IMPL(data);
10898 __attribute__((always_inline)) inline
10899 JSObject *toObjectOrNull() const {
10901 return JSVAL_TO_OBJECT_IMPL(data);
10904 __attribute__((always_inline)) inline
10905 void *toGCThing() const {
10907 return JSVAL_TO_GCTHING_IMPL(data);
10910 __attribute__((always_inline)) inline
10911 bool toBoolean() const {
10913 return JSVAL_TO_BOOLEAN_IMPL(data);
10916 __attribute__((always_inline)) inline
10917 uint32 payloadAsRawUint32() const {
10919 return data.s.payload.u32;
10922 __attribute__((always_inline)) inline
10923 uint64 asRawBits() const {
10924 return data.asBits;
10933 __attribute__((always_inline)) inline
10934 JSValueType extractNonDoubleType() const {
10935 return JSVAL_EXTRACT_NON_DOUBLE_TYPE_IMPL(data);
10938 __attribute__((always_inline)) inline
10939 JSValueTag extractNonDoubleTag() const {
10940 return JSVAL_EXTRACT_NON_DOUBLE_TAG_IMPL(data);
10943 __attribute__((always_inline)) inline
10944 void unboxNonDoubleTo(uint64 *out) const {
10945 UNBOX_NON_DOUBLE_JSVAL(data, out);
10948 __attribute__((always_inline)) inline
10949 void boxNonDoubleFrom(JSValueType type, uint64 *out) {
10950 data = BOX_NON_DOUBLE_JSVAL(type, out);
10958 __attribute__((always_inline)) inline
10959 JSValueType extractNonDoubleObjectTraceType() const {
10961 return JSVAL_EXTRACT_NON_DOUBLE_TYPE_IMPL(data);
10964 __attribute__((always_inline)) inline
10965 JSValueTag extractNonDoubleObjectTraceTag() const {
10967 return JSVAL_EXTRACT_NON_DOUBLE_TAG_IMPL(data);
10970 __attribute__((always_inline)) inline
10971 void setPrivate(void *ptr) {
10972 data = PRIVATE_PTR_TO_JSVAL_IMPL(ptr);
10975 __attribute__((always_inline)) inline
10976 void *toPrivate() const {
10978 return JSVAL_TO_PRIVATE_PTR_IMPL(data);
10981 __attribute__((always_inline)) inline
10982 void setPrivateUint32(uint32 ui) {
10983 data = PRIVATE_UINT32_TO_JSVAL_IMPL(ui);
10986 __attribute__((always_inline)) inline
10987 uint32 toPrivateUint32() const {
10989 return JSVAL_TO_PRIVATE_UINT32_IMPL(data);
10992 __attribute__((always_inline)) inline
10993 uint32 &getPrivateUint32Ref() {
10995 return data.s.payload.u32;
11004 __attribute__((always_inline)) inline
11005 void setUnmarkedPtr(void *ptr) {
11009 __attribute__((always_inline)) inline
11010 void *toUnmarkedPtr() const {
11014 const jsuword *payloadWord() const {
11015 return &data.s.payload.word;
11019 void staticAssertions() {
11020 typedef int js_static_assert6[(sizeof(JSValueType) == 1) ? 1 : -1];
11021 typedef int js_static_assert7[(sizeof(JSValueTag) == 4) ? 1 : -1];
11022 typedef int js_static_assert8[(sizeof(JSBool) == 4) ? 1 : -1];
11023 typedef int js_static_assert9[(sizeof(JSWhyMagic) <= 4) ? 1 : -1];
11024 typedef int js_static_assert10[(sizeof(jsval) == 8) ? 1 : -1];
11028 } __attribute__((aligned (8)));
11030 __attribute__((always_inline)) inline
11034 SameType(const Value &lhs, const Value &rhs)
11036 return JSVAL_SAME_TYPE_IMPL(lhs.data, rhs.data);
11039 static __attribute__((always_inline)) inline Value
11047 static __attribute__((always_inline)) inline Value
11055 static __attribute__((always_inline)) inline Value
11056 Int32Value(int32 i32)
11063 static __attribute__((always_inline)) inline Value
11064 DoubleValue(double dbl)
11071 static __attribute__((always_inline)) inline Value
11072 StringValue(JSString *str)
11079 static __attribute__((always_inline)) inline Value
11080 BooleanValue(bool boo)
11087 static __attribute__((always_inline)) inline Value
11088 ObjectValue(JSObject &obj)
11095 static __attribute__((always_inline)) inline Value
11096 MagicValue(JSWhyMagic why)
11103 static __attribute__((always_inline)) inline Value
11104 NumberValue(double dbl)
11111 static __attribute__((always_inline)) inline Value
11112 ObjectOrNullValue(JSObject *obj)
11115 v.setObjectOrNull(obj);
11119 static __attribute__((always_inline)) inline Value
11120 PrivateValue(void *ptr)
11127 static __attribute__((always_inline)) inline void
11128 ClearValueRange(Value *vec, uintN len, bool useHoles)
11131 for (uintN i = 0; i < len; i++)
11132 vec[i].setMagic(JS_ARRAY_HOLE);
11134 for (uintN i = 0; i < len; i++)
11135 vec[i].setUndefined();
11139 static inline jsval * Jsvalify(Value *v) { return (jsval *)v; }
11140 static inline const jsval * Jsvalify(const Value *v) { return (const jsval *)v; }
11141 static inline jsval & Jsvalify(Value &v) { return (jsval &)v; }
11142 static inline const jsval & Jsvalify(const Value &v) { return (const jsval &)v; }
11143 static inline Value * Valueify(jsval *v) { return (Value *)v; }
11144 static inline const Value * Valueify(const jsval *v) { return (const Value *)v; }
11145 static inline Value ** Valueify(jsval **v) { return (Value **)v; }
11146 static inline Value & Valueify(jsval &v) { return (Value &)v; }
11147 static inline const Value & Valueify(const jsval &v) { return (const Value &)v; }
11152 (* Native)(JSContext *cx, uintN argc, Value *vp);
11154 (* PropertyOp)(JSContext *cx, JSObject *obj, jsid id, Value *vp);
11156 (* StrictPropertyOp)(JSContext *cx, JSObject *obj, jsid id, JSBool strict, Value *vp);
11158 (* ConvertOp)(JSContext *cx, JSObject *obj, JSType type, Value *vp);
11160 (* NewEnumerateOp)(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
11161 Value *statep, jsid *idp);
11163 (* HasInstanceOp)(JSContext *cx, JSObject *obj, const Value *v, JSBool *bp);
11165 (* CheckAccessOp)(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
11168 (* EqualityOp)(JSContext *cx, JSObject *obj, const Value *v, JSBool *bp);
11170 (* DefinePropOp)(JSContext *cx, JSObject *obj, jsid id, const Value *value,
11171 PropertyOp getter, StrictPropertyOp setter, uintN attrs);
11173 (* PropertyIdOp)(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp);
11175 (* StrictPropertyIdOp)(JSContext *cx, JSObject *obj, jsid id, Value *vp, JSBool strict);
11177 (* DeleteIdOp)(JSContext *cx, JSObject *obj, jsid id, Value *vp, JSBool strict);
11179 (* CallOp)(JSContext *cx, uintN argc, Value *vp);
11181 (* LookupPropOp)(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
11182 JSProperty **propp);
11184 (* AttributesOp)(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp);
11186 (* TypeOfOp)(JSContext *cx, JSObject *obj);
11188 (* TraceOp)(JSTracer *trc, JSObject *obj);
11190 (* ObjectOp)(JSContext *cx, JSObject *obj);
11192 (* FinalizeOp)(JSContext *cx, JSObject *obj);
11194 class AutoIdVector;
11197 (* FixOp)(JSContext *cx, JSObject *obj, bool *fixed, AutoIdVector *props);
11199 static inline Native Valueify(JSNative f) { return (Native)f; }
11200 static inline JSNative Jsvalify(Native f) { return (JSNative)f; }
11201 static inline PropertyOp Valueify(JSPropertyOp f) { return (PropertyOp)f; }
11202 static inline JSPropertyOp Jsvalify(PropertyOp f) { return (JSPropertyOp)f; }
11203 static inline StrictPropertyOp Valueify(JSStrictPropertyOp f) { return (StrictPropertyOp)f; }
11204 static inline JSStrictPropertyOp Jsvalify(StrictPropertyOp f) { return (JSStrictPropertyOp)f; }
11205 static inline ConvertOp Valueify(JSConvertOp f) { return (ConvertOp)f; }
11206 static inline JSConvertOp Jsvalify(ConvertOp f) { return (JSConvertOp)f; }
11207 static inline NewEnumerateOp Valueify(JSNewEnumerateOp f) { return (NewEnumerateOp)f; }
11208 static inline JSNewEnumerateOp Jsvalify(NewEnumerateOp f) { return (JSNewEnumerateOp)f; }
11209 static inline HasInstanceOp Valueify(JSHasInstanceOp f) { return (HasInstanceOp)f; }
11210 static inline JSHasInstanceOp Jsvalify(HasInstanceOp f) { return (JSHasInstanceOp)f; }
11211 static inline CheckAccessOp Valueify(JSCheckAccessOp f) { return (CheckAccessOp)f; }
11212 static inline JSCheckAccessOp Jsvalify(CheckAccessOp f) { return (JSCheckAccessOp)f; }
11213 static inline EqualityOp Valueify(JSEqualityOp f);
11214 static inline JSEqualityOp Jsvalify(EqualityOp f);
11216 static const PropertyOp PropertyStub = (PropertyOp)JS_PropertyStub;
11217 static const StrictPropertyOp StrictPropertyStub = (StrictPropertyOp)JS_StrictPropertyStub;
11218 static const JSEnumerateOp EnumerateStub = JS_EnumerateStub;
11219 static const JSResolveOp ResolveStub = JS_ResolveStub;
11220 static const ConvertOp ConvertStub = (ConvertOp)JS_ConvertStub;
11221 static const JSFinalizeOp FinalizeStub = JS_FinalizeStub;
11223 struct ClassSizeMeasurement {
11224 const char *name; uint32 flags; PropertyOp addProperty; PropertyOp delProperty; PropertyOp getProperty; StrictPropertyOp setProperty; JSEnumerateOp enumerate; JSResolveOp resolve; ConvertOp convert; JSFinalizeOp finalize; JSClassInternal reserved0; CheckAccessOp checkAccess; Native call; Native construct; JSXDRObjectOp xdrObject; HasInstanceOp hasInstance; JSMarkOp mark;
11227 struct ClassExtension {
11228 EqualityOp equality;
11229 JSObjectOp outerObject;
11230 JSObjectOp innerObject;
11231 JSIteratorOp iteratorObject;
11238 js::LookupPropOp lookupProperty;
11239 js::DefinePropOp defineProperty;
11240 js::PropertyIdOp getProperty;
11241 js::StrictPropertyIdOp setProperty;
11242 js::AttributesOp getAttributes;
11243 js::AttributesOp setAttributes;
11244 js::DeleteIdOp deleteProperty;
11245 js::NewEnumerateOp enumerate;
11246 js::TypeOfOp typeOf;
11249 js::ObjectOp thisObject;
11250 js::FinalizeOp clear;
11256 const char *name; uint32 flags; PropertyOp addProperty; PropertyOp delProperty; PropertyOp getProperty; StrictPropertyOp setProperty; JSEnumerateOp enumerate; JSResolveOp resolve; ConvertOp convert; JSFinalizeOp finalize; JSClassInternal reserved0; CheckAccessOp checkAccess; Native call; Native construct; JSXDRObjectOp xdrObject; HasInstanceOp hasInstance; JSMarkOp mark;
11257 ClassExtension ext;
11259 uint8 pad[sizeof(JSClass) - sizeof(ClassSizeMeasurement) -
11260 sizeof(ClassExtension) - sizeof(ObjectOps)];
11263 static const uint32 NON_NATIVE = (1<<((8 + 8)+4));
11265 bool isNative() const {
11266 return !(flags & NON_NATIVE);
11270 typedef int js_static_assert11[(__builtin_offsetof (JSClass, name) == __builtin_offsetof (Class, name)) ? 1 : -1];
11271 typedef int js_static_assert12[(__builtin_offsetof (JSClass, flags) == __builtin_offsetof (Class, flags)) ? 1 : -1];
11272 typedef int js_static_assert13[(__builtin_offsetof (JSClass, addProperty) == __builtin_offsetof (Class, addProperty)) ? 1 : -1];
11273 typedef int js_static_assert14[(__builtin_offsetof (JSClass, delProperty) == __builtin_offsetof (Class, delProperty)) ? 1 : -1];
11274 typedef int js_static_assert15[(__builtin_offsetof (JSClass, getProperty) == __builtin_offsetof (Class, getProperty)) ? 1 : -1];
11275 typedef int js_static_assert16[(__builtin_offsetof (JSClass, setProperty) == __builtin_offsetof (Class, setProperty)) ? 1 : -1];
11276 typedef int js_static_assert17[(__builtin_offsetof (JSClass, enumerate) == __builtin_offsetof (Class, enumerate)) ? 1 : -1];
11277 typedef int js_static_assert18[(__builtin_offsetof (JSClass, resolve) == __builtin_offsetof (Class, resolve)) ? 1 : -1];
11278 typedef int js_static_assert19[(__builtin_offsetof (JSClass, convert) == __builtin_offsetof (Class, convert)) ? 1 : -1];
11279 typedef int js_static_assert20[(__builtin_offsetof (JSClass, finalize) == __builtin_offsetof (Class, finalize)) ? 1 : -1];
11280 typedef int js_static_assert21[(__builtin_offsetof (JSClass, reserved0) == __builtin_offsetof (Class, reserved0)) ? 1 : -1];
11281 typedef int js_static_assert22[(__builtin_offsetof (JSClass, checkAccess) == __builtin_offsetof (Class, checkAccess)) ? 1 : -1];
11282 typedef int js_static_assert23[(__builtin_offsetof (JSClass, call) == __builtin_offsetof (Class, call)) ? 1 : -1];
11283 typedef int js_static_assert24[(__builtin_offsetof (JSClass, construct) == __builtin_offsetof (Class, construct)) ? 1 : -1];
11284 typedef int js_static_assert25[(__builtin_offsetof (JSClass, xdrObject) == __builtin_offsetof (Class, xdrObject)) ? 1 : -1];
11285 typedef int js_static_assert26[(__builtin_offsetof (JSClass, hasInstance) == __builtin_offsetof (Class, hasInstance)) ? 1 : -1];
11286 typedef int js_static_assert27[(__builtin_offsetof (JSClass, mark) == __builtin_offsetof (Class, mark)) ? 1 : -1];
11287 typedef int js_static_assert28[(sizeof(JSClass) == sizeof(Class)) ? 1 : -1];
11289 struct PropertyDescriptor {
11293 StrictPropertyOp setter;
11297 typedef int js_static_assert29[(__builtin_offsetof (JSPropertyDescriptor, obj) == __builtin_offsetof (PropertyDescriptor, obj)) ? 1 : -1];
11298 typedef int js_static_assert30[(__builtin_offsetof (JSPropertyDescriptor, attrs) == __builtin_offsetof (PropertyDescriptor, attrs)) ? 1 : -1];
11299 typedef int js_static_assert31[(__builtin_offsetof (JSPropertyDescriptor, getter) == __builtin_offsetof (PropertyDescriptor, getter)) ? 1 : -1];
11300 typedef int js_static_assert32[(__builtin_offsetof (JSPropertyDescriptor, setter) == __builtin_offsetof (PropertyDescriptor, setter)) ? 1 : -1];
11301 typedef int js_static_assert33[(__builtin_offsetof (JSPropertyDescriptor, value) == __builtin_offsetof (PropertyDescriptor, value)) ? 1 : -1];
11302 typedef int js_static_assert34[(__builtin_offsetof (JSPropertyDescriptor, shortid) == __builtin_offsetof (PropertyDescriptor, shortid)) ? 1 : -1];
11303 typedef int js_static_assert35[(sizeof(JSPropertyDescriptor) == sizeof(PropertyDescriptor)) ? 1 : -1];
11305 static __attribute__((always_inline)) inline JSClass * Jsvalify(Class *c) { return (JSClass *)c; }
11306 static __attribute__((always_inline)) inline Class * Valueify(JSClass *c) { return (Class *)c; }
11307 static __attribute__((always_inline)) inline JSPropertyDescriptor * Jsvalify(PropertyDescriptor *p) { return (JSPropertyDescriptor *) p; }
11308 static __attribute__((always_inline)) inline PropertyDescriptor * Valueify(JSPropertyDescriptor *p) { return (PropertyDescriptor *) p; }
11310 typedef js::Value ValueArgType;
11312 static __attribute__((always_inline)) inline const Value &
11313 ValueArgToConstRef(const Value &v)
11321 static __attribute__((always_inline)) inline void
11322 MakeRangeGCSafe(Value *vec, size_t len)
11327 static __attribute__((always_inline)) inline void
11328 MakeRangeGCSafe(Value *beg, Value *end)
11330 PodZero(beg, end - beg);
11333 static __attribute__((always_inline)) inline void
11334 MakeRangeGCSafe(jsid *beg, jsid *end)
11336 for (jsid *id = beg; id != end; ++id)
11337 *id = INT_TO_JSID(0);
11340 static __attribute__((always_inline)) inline void
11341 MakeRangeGCSafe(jsid *vec, size_t len)
11343 MakeRangeGCSafe(vec, vec + len);
11346 static __attribute__((always_inline)) inline void
11347 MakeRangeGCSafe(const Shape **beg, const Shape **end)
11349 PodZero(beg, end - beg);
11352 static __attribute__((always_inline)) inline void
11353 MakeRangeGCSafe(const Shape **vec, size_t len)
11358 static __attribute__((always_inline)) inline void
11359 SetValueRangeToUndefined(Value *beg, Value *end)
11361 for (Value *v = beg; v != end; ++v)
11365 static __attribute__((always_inline)) inline void
11366 SetValueRangeToUndefined(Value *vec, size_t len)
11368 SetValueRangeToUndefined(vec, vec + len);
11371 static __attribute__((always_inline)) inline void
11372 SetValueRangeToNull(Value *beg, Value *end)
11374 for (Value *v = beg; v != end; ++v)
11378 static __attribute__((always_inline)) inline void
11379 SetValueRangeToNull(Value *vec, size_t len)
11381 SetValueRangeToNull(vec, vec + len);
11390 static __attribute__((always_inline)) inline void
11391 Debug_SetValueRangeToCrashOnTouch(Value *beg, Value *end)
11399 static __attribute__((always_inline)) inline void
11400 Debug_SetValueRangeToCrashOnTouch(Value *vec, size_t len)
11417 template <class T, size_t N, class AP, bool IsPod>
11421 static inline void destroy(T *begin, T *end) {
11422 for (T *p = begin; p != end; ++p)
11427 static inline void initialize(T *begin, T *end) {
11428 for (T *p = begin; p != end; ++p)
11437 static inline void copyConstruct(T *dst, const U *srcbeg, const U *srcend) {
11438 for (const U *p = srcbeg; p != srcend; ++p, ++dst)
11447 static inline void copyConstructN(T *dst, size_t n, const U &u) {
11448 for (T *end = dst + n; dst != end; ++dst)
11458 static inline bool growTo(Vector<T,N,AP> &v, size_t newcap) {
11460 T *newbuf = reinterpret_cast<T *>(v.malloc(newcap * sizeof(T)));
11463 for (T *dst = newbuf, *src = v.beginNoCheck(); src != v.endNoCheck(); ++dst, ++src)
11465 VectorImpl::destroy(v.beginNoCheck(), v.endNoCheck());
11469 v.mCapacity = newcap;
11479 template <class T, size_t N, class AP>
11480 struct VectorImpl<T, N, AP, true>
11482 static inline void destroy(T *, T *) {}
11484 static inline void initialize(T *begin, T *end) {
11486 for (T *p = begin; p != end; ++p)
11491 static inline void copyConstruct(T *dst, const U *srcbeg, const U *srcend) {
11499 for (const U *p = srcbeg; p != srcend; ++p, ++dst)
11503 static inline void copyConstructN(T *dst, size_t n, const T &t) {
11504 for (T *p = dst, *end = dst + n; p != end; ++p)
11508 static inline bool growTo(Vector<T,N,AP> &v, size_t newcap) {
11510 size_t bytes = sizeof(T) * newcap;
11511 T *newbuf = reinterpret_cast<T *>(v.realloc(v.mBegin, bytes));
11516 v.mCapacity = newcap;
11521 template <class T, size_t N, class AllocPolicy>
11522 class Vector : AllocPolicy
11526 static const bool sElemIsPod = tl::IsPodType<T>::result;
11527 typedef VectorImpl<T, N, AllocPolicy, sElemIsPod> Impl;
11528 friend struct VectorImpl<T, N, AllocPolicy, sElemIsPod>;
11530 bool calculateNewCapacity(size_t curLength, size_t lengthInc, size_t &newCap);
11531 bool growStorageBy(size_t lengthInc);
11532 bool growHeapStorageBy(size_t lengthInc);
11533 bool convertToHeapStorage(size_t lengthInc);
11535 template <bool InitNewElems> inline bool growByImpl(size_t inc);
11539 static const int sMaxInlineBytes = 1024;
11543 static const size_t sInlineCapacity =
11544 tl::Min<N, sMaxInlineBytes / sizeof(T)>::result;
11547 static const size_t sInlineBytes =
11548 tl::Max<1, sInlineCapacity * sizeof(T)>::result;
11554 AlignedStorage<sInlineBytes> storage;
11561 Vector(const Vector &);
11562 Vector &operator=(const Vector &);
11566 bool usingInlineStorage() const {
11567 return mBegin == (T *)storage.addr();
11570 T *beginNoCheck() const {
11575 return mBegin + mLength;
11578 const T *endNoCheck() const {
11579 return mBegin + mLength;
11583 typedef T ElementType;
11585 Vector(AllocPolicy = AllocPolicy());
11590 const AllocPolicy &allocPolicy() const {
11594 enum { InlineLength = N };
11596 size_t length() const {
11600 bool empty() const {
11601 return mLength == 0;
11604 size_t capacity() const {
11615 return mBegin + mLength;
11618 const T *end() const {
11620 return mBegin + mLength;
11623 T &operator[](size_t i) {
11628 const T &operator[](size_t i) const {
11635 return *(end() - 1);
11638 const T &back() const {
11640 return *(end() - 1);
11646 bool reserve(size_t capacity);
11649 void shrinkBy(size_t incr);
11652 bool growBy(size_t incr);
11655 bool resize(size_t newLength);
11658 bool growByUninitialized(size_t incr);
11659 bool resizeUninitialized(size_t newLength);
11663 bool append(const T &t);
11664 bool appendN(const T &t, size_t n);
11665 template <class U> bool append(const U *begin, const U *end);
11666 template <class U> bool append(const U *begin, size_t length);
11667 template <class U, size_t O, class BP> bool append(const Vector<U,O,BP> &other);
11673 T *extractRawBuffer();
11680 void replaceRawBuffer(T *p, size_t length);
11686 bool insert(T *p, const T &val);
11695 template <class T, size_t N, class AllocPolicy>
11696 __attribute__((always_inline)) inline
11697 Vector<T,N,AllocPolicy>::Vector(AllocPolicy ap)
11698 : AllocPolicy(ap), mBegin((T *)storage.addr()), mLength(0),
11699 mCapacity(sInlineCapacity)
11705 template <class T, size_t N, class AP>
11706 __attribute__((always_inline)) inline
11707 Vector<T,N,AP>::~Vector()
11709 ReentrancyGuard g(*this); ((void) 0); ((void) 0);
11710 Impl::destroy(beginNoCheck(), endNoCheck());
11711 if (!usingInlineStorage())
11712 this->free(beginNoCheck());
11719 template <class T, size_t N, class AP>
11725 Vector<T,N,AP>::calculateNewCapacity(size_t curLength, size_t lengthInc,
11728 size_t newMinCap = curLength + lengthInc;
11734 if (newMinCap < curLength ||
11735 newMinCap & tl::MulOverflowMask<2 * sizeof(T)>::result) {
11736 this->reportAllocOverflow();
11741 newCap = RoundUpPow2(newMinCap);
11747 if (newCap & tl::UnsafeRangeSizeMask<T>::result) {
11748 this->reportAllocOverflow();
11758 template <class T, size_t N, class AP>
11759 __attribute__((always_inline)) inline
11763 Vector<T,N,AP>::growHeapStorageBy(size_t lengthInc)
11767 return calculateNewCapacity(mLength, lengthInc, newCap) &&
11768 Impl::growTo(*this, newCap);
11776 template <class T, size_t N, class AP>
11781 Vector<T,N,AP>::convertToHeapStorage(size_t lengthInc)
11785 if (!calculateNewCapacity(mLength, lengthInc, newCap))
11789 T *newBuf = reinterpret_cast<T *>(this->malloc(newCap * sizeof(T)));
11794 Impl::copyConstruct(newBuf, beginNoCheck(), endNoCheck());
11795 Impl::destroy(beginNoCheck(), endNoCheck());
11800 mCapacity = newCap;
11804 template <class T, size_t N, class AP>
11805 __attribute__((noinline))
11809 Vector<T,N,AP>::growStorageBy(size_t incr)
11812 return usingInlineStorage()
11813 ? convertToHeapStorage(incr)
11814 : growHeapStorageBy(incr);
11817 template <class T, size_t N, class AP>
11822 Vector<T,N,AP>::reserve(size_t request)
11824 ReentrancyGuard g(*this); ((void) 0); ((void) 0);
11825 if (request > mCapacity)
11826 return growStorageBy(request - mLength);
11830 template <class T, size_t N, class AP>
11832 Vector<T,N,AP>::shrinkBy(size_t incr)
11834 ReentrancyGuard g(*this); ((void) 0); ((void) 0);
11836 Impl::destroy(endNoCheck() - incr, endNoCheck());
11840 template <class T, size_t N, class AP>
11841 template <bool InitNewElems>
11842 __attribute__((always_inline)) inline
11846 Vector<T,N,AP>::growByImpl(size_t incr)
11848 ReentrancyGuard g(*this); ((void) 0); ((void) 0);
11849 if (incr > mCapacity - mLength && !growStorageBy(incr))
11853 T *newend = endNoCheck() + incr;
11855 Impl::initialize(endNoCheck(), newend);
11860 template <class T, size_t N, class AP>
11861 __attribute__((always_inline)) inline
11865 Vector<T,N,AP>::growBy(size_t incr)
11867 return growByImpl<true>(incr);
11870 template <class T, size_t N, class AP>
11871 __attribute__((always_inline)) inline
11875 Vector<T,N,AP>::growByUninitialized(size_t incr)
11877 return growByImpl<false>(incr);
11880 template <class T, size_t N, class AP>
11886 Vector<T,N,AP>::resize(size_t newLength)
11888 size_t curLength = mLength;
11889 if (newLength > curLength)
11890 return growBy(newLength - curLength);
11891 shrinkBy(curLength - newLength);
11895 template <class T, size_t N, class AP>
11896 __attribute__((always_inline)) inline
11900 Vector<T,N,AP>::resizeUninitialized(size_t newLength)
11902 size_t curLength = mLength;
11903 if (newLength > curLength)
11904 return growByUninitialized(newLength - curLength);
11905 shrinkBy(curLength - newLength);
11909 template <class T, size_t N, class AP>
11911 Vector<T,N,AP>::clear()
11913 ReentrancyGuard g(*this); ((void) 0); ((void) 0);
11914 Impl::destroy(beginNoCheck(), endNoCheck());
11918 template <class T, size_t N, class AP>
11919 __attribute__((always_inline)) inline
11923 Vector<T,N,AP>::append(const T &t)
11925 ReentrancyGuard g(*this); ((void) 0); ((void) 0);
11926 if (mLength == mCapacity && !growStorageBy(1))
11930 new(endNoCheck()) T(t);
11935 template <class T, size_t N, class AP>
11936 __attribute__((always_inline)) inline
11940 Vector<T,N,AP>::appendN(const T &t, size_t needed)
11942 ReentrancyGuard g(*this); ((void) 0); ((void) 0);
11943 if (mLength + needed > mCapacity && !growStorageBy(needed))
11947 Impl::copyConstructN(endNoCheck(), needed, t);
11952 template <class T, size_t N, class AP>
11957 Vector<T,N,AP>::insert(T *p, const T &val)
11960 size_t pos = p - begin();
11962 size_t oldLength = mLength;
11963 if (pos == oldLength)
11964 return append(val);
11966 T oldBack = back();
11967 if (!append(oldBack))
11970 for (size_t i = oldLength; i > pos; --i)
11971 (*this)[i] = (*this)[i - 1];
11972 (*this)[pos] = val;
11976 template<typename T, size_t N, class AP>
11978 Vector<T,N,AP>::erase(T *it)
11981 while (it + 1 != end()) {
11988 template <class T, size_t N, class AP>
11990 __attribute__((always_inline)) inline
11994 Vector<T,N,AP>::append(const U *insBegin, const U *insEnd)
11996 ReentrancyGuard g(*this); ((void) 0); ((void) 0);
11997 size_t needed = PointerRangeSize(insBegin, insEnd);
11998 if (mLength + needed > mCapacity && !growStorageBy(needed))
12002 Impl::copyConstruct(endNoCheck(), insBegin, insEnd);
12007 template <class T, size_t N, class AP>
12008 template <class U, size_t O, class BP>
12013 Vector<T,N,AP>::append(const Vector<U,O,BP> &other)
12015 return append(other.begin(), other.end());
12018 template <class T, size_t N, class AP>
12020 __attribute__((always_inline)) inline
12024 Vector<T,N,AP>::append(const U *insBegin, size_t length)
12026 return this->append(insBegin, insBegin + length);
12029 template <class T, size_t N, class AP>
12030 __attribute__((always_inline)) inline void
12031 Vector<T,N,AP>::popBack()
12033 ReentrancyGuard g(*this); ((void) 0); ((void) 0);
12036 endNoCheck()->~T();
12039 template <class T, size_t N, class AP>
12040 __attribute__((always_inline)) inline T
12041 Vector<T,N,AP>::popCopy()
12048 template <class T, size_t N, class AP>
12050 Vector<T,N,AP>::extractRawBuffer()
12053 if (usingInlineStorage()) {
12054 ret = reinterpret_cast<T *>(this->malloc(mLength * sizeof(T)));
12057 Impl::copyConstruct(ret, beginNoCheck(), endNoCheck());
12058 Impl::destroy(beginNoCheck(), endNoCheck());
12063 mBegin = (T *)storage.addr();
12065 mCapacity = sInlineCapacity;
12070 template <class T, size_t N, class AP>
12072 Vector<T,N,AP>::replaceRawBuffer(T *p, size_t length)
12074 ReentrancyGuard g(*this); ((void) 0); ((void) 0);
12077 Impl::destroy(beginNoCheck(), endNoCheck());
12078 if (!usingInlineStorage())
12079 this->free(beginNoCheck());
12082 if (length <= sInlineCapacity) {
12088 mBegin = (T *)storage.addr();
12090 mCapacity = sInlineCapacity;
12091 Impl::copyConstruct(mBegin, p, p + length);
12092 Impl::destroy(p, p + length);
12097 mCapacity = length;
12105 struct JSCompartment;
12110 template <typename T> struct Arena;
12111 struct ArenaBitmap;
12112 struct MarkingDelay;
12117 static const size_t CellShift = 3;
12118 static const size_t CellSize = size_t(1) << CellShift;
12119 static const size_t CellMask = CellSize - 1;
12121 inline Arena<Cell> *arena() const;
12122 inline Chunk *chunk() const;
12123 inline ArenaBitmap *bitmap() const;
12124 __attribute__((always_inline)) inline size_t cellIndex() const;
12126 __attribute__((always_inline)) inline bool isMarked(uint32 color) const;
12127 __attribute__((always_inline)) inline bool markIfUnmarked(uint32 color) const;
12128 __attribute__((always_inline)) inline void unmark(uint32 color) const;
12130 inline JSCompartment *compartment() const;
12133 __attribute__((always_inline)) inline js::gc::Cell *asCell() { return this; }
12135 __attribute__((always_inline)) inline js::gc::FreeCell *asFreeCell() {
12136 return reinterpret_cast<FreeCell *>(this);
12141 struct FreeCell : Cell {
12148 typedef int js_static_assert36[(sizeof(FreeCell) == 8) ? 1 : -1];
12156 class JSProxyHandler;
12157 class AutoPropDescArrayRooter;
12163 static inline PropertyOp
12164 CastAsPropertyOp(JSObject *object)
12166 return (__extension__ (PropertyOp) (size_t) (object));
12169 static inline StrictPropertyOp
12170 CastAsStrictPropertyOp(JSObject *object)
12172 return (__extension__ (StrictPropertyOp) (size_t) (object));
12175 static inline JSPropertyOp
12176 CastAsJSPropertyOp(JSObject *object)
12178 return (__extension__ (JSPropertyOp) (size_t) (object));
12181 static inline JSStrictPropertyOp
12182 CastAsJSStrictPropertyOp(JSObject *object)
12184 return (__extension__ (JSStrictPropertyOp) (size_t) (object));
12188 CastAsObject(PropertyOp op)
12190 return (__extension__ (JSObject *) (size_t) (op));
12194 CastAsObject(StrictPropertyOp op)
12196 return (__extension__ (JSObject *) (size_t) (op));
12200 CastAsObjectJsval(PropertyOp op)
12202 return ObjectOrNullValue(CastAsObject(op));
12206 CastAsObjectJsval(StrictPropertyOp op)
12208 return ObjectOrNullValue(CastAsObject(op));
12218 friend class js::AutoPropDescArrayRooter;
12224 bool initialize(JSContext* cx, jsid id, const js::Value &v);
12227 bool isAccessorDescriptor() const {
12228 return hasGet || hasSet;
12232 bool isDataDescriptor() const {
12233 return hasValue || hasWritable;
12237 bool isGenericDescriptor() const {
12238 return !isAccessorDescriptor() && !isDataDescriptor();
12241 bool configurable() const {
12242 return (attrs & 0x04) == 0;
12245 bool enumerable() const {
12246 return (attrs & 0x01) != 0;
12249 bool writable() const {
12250 return (attrs & 0x02) == 0;
12253 JSObject* getterObject() const {
12254 return get.isUndefined() ? __null : &get.toObject();
12256 JSObject* setterObject() const {
12257 return set.isUndefined() ? __null : &set.toObject();
12260 const js::Value &getterValue() const {
12263 const js::Value &setterValue() const {
12267 js::PropertyOp getter() const {
12268 return js::CastAsPropertyOp(getterObject());
12270 js::StrictPropertyOp setter() const {
12271 return js::CastAsStrictPropertyOp(setterObject());
12276 js::Value value, get, set;
12285 bool hasWritable : 1;
12286 bool hasEnumerable : 1;
12287 bool hasConfigurable : 1;
12292 typedef Vector<PropDesc, 1> PropDescArray;
12296 struct JSObjectMap {
12300 static __attribute__((visibility ("default"))) const JSObjectMap sharedNonNative;
12302 explicit JSObjectMap(uint32 shape) : shape(shape), slotSpan(0) {}
12303 JSObjectMap(uint32 shape, uint32 slotSpan) : shape(shape), slotSpan(slotSpan) {}
12305 enum { INVALID_SHAPE = 0x8fffffff, SHAPELESS = 0xffffffff };
12307 bool isNative() const { return this != &sharedNonNative; }
12311 JSObjectMap(JSObjectMap &);
12312 void operator=(JSObjectMap &);
12321 extern __attribute__((visibility ("default"))) JSBool
12322 js_LookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
12323 JSProperty **propp);
12326 js_DefineProperty(JSContext *cx, JSObject *obj, jsid id, const js::Value *value,
12327 js::PropertyOp getter, js::StrictPropertyOp setter, uintN attrs);
12330 js_GetProperty(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, js::Value *vp);
12333 js_GetProperty(JSContext *cx, JSObject *obj, jsid id, js::Value *vp)
12335 return js_GetProperty(cx, obj, obj, id, vp);
12341 GetPropertyDefault(JSContext *cx, JSObject *obj, jsid id, const Value &def, Value *vp);
12346 js_SetProperty(JSContext *cx, JSObject *obj, jsid id, js::Value *vp, JSBool strict);
12349 js_GetAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp);
12352 js_SetAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp);
12355 js_DeleteProperty(JSContext *cx, JSObject *obj, jsid id, js::Value *rval, JSBool strict);
12357 extern __attribute__((visibility ("default"))) JSBool
12358 js_Enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op,
12359 js::Value *statep, jsid *idp);
12362 js_TypeOf(JSContext *cx, JSObject *obj);
12366 struct NativeIterator;
12372 namespace nanojit {
12373 class ValidateWriter;
12376 struct JSObject : js::gc::Cell {
12383 friend class js::TraceRecorder;
12384 friend class nanojit::ValidateWriter;
12385 friend class GetPropCompiler;
12388 js::Shape *lastProp;
12395 inline void setLastProperty(const js::Shape *shape);
12396 inline void removeLastProperty();
12403 inline const js::Shape *lastProperty() const;
12405 inline js::Shape **nativeSearch(jsid id, bool adding = false);
12406 inline const js::Shape *nativeLookup(jsid id);
12408 inline bool nativeContains(jsid id);
12409 inline bool nativeContains(const js::Shape &shape);
12414 NOT_EXTENSIBLE = 0x04,
12417 METHOD_BARRIER = 0x20,
12420 BOUND_FUNCTION = 0x100,
12421 HAS_EQUALITY = 0x200,
12422 METHOD_THRASH_COUNT_MASK = 0xc00,
12423 METHOD_THRASH_COUNT_SHIFT = 10,
12424 METHOD_THRASH_COUNT_MAX = METHOD_THRASH_COUNT_MASK >> METHOD_THRASH_COUNT_SHIFT
12433 NSLOTS_LIMIT = ((JSUint32)1 << (NSLOTS_BITS))
12440 js::EmptyShape **emptyShapes;
12448 inline bool canProvideEmptyShape(js::Class *clasp);
12449 inline js::EmptyShape *getEmptyShape(JSContext *cx, js::Class *aclasp,
12452 bool isNative() const { return map->isNative(); }
12454 js::Class *getClass() const { return clasp; }
12455 JSClass *getJSClass() const { return Jsvalify(clasp); }
12457 bool hasClass(const js::Class *c) const {
12461 const js::ObjectOps *getOps() const {
12462 return &getClass()->ops;
12465 inline void trace(JSTracer *trc);
12467 uint32 shape() const {
12472 bool isDelegate() const { return !!(flags & DELEGATE); }
12473 void setDelegate() { flags |= DELEGATE; }
12474 void clearDelegate() { flags &= ~DELEGATE; }
12476 bool isBoundFunction() const { return !!(flags & BOUND_FUNCTION); }
12478 static void setDelegateNullSafe(JSObject *obj) {
12480 obj->setDelegate();
12483 bool isSystem() const { return !!(flags & SYSTEM); }
12484 void setSystem() { flags |= SYSTEM; }
12491 bool branded() { return !!(flags & BRANDED); }
12498 bool brand(JSContext *cx);
12499 bool unbrand(JSContext *cx);
12501 bool generic() { return !!(flags & GENERIC); }
12502 void setGeneric() { flags |= GENERIC; }
12504 uintN getMethodThrashCount() const {
12505 return (flags & METHOD_THRASH_COUNT_MASK) >> METHOD_THRASH_COUNT_SHIFT;
12508 void setMethodThrashCount(uintN count) {
12510 flags = (flags & ~METHOD_THRASH_COUNT_MASK) | (count << METHOD_THRASH_COUNT_SHIFT);
12513 bool hasSpecialEquality() const { return !!(flags & HAS_EQUALITY); }
12514 void assertSpecialEqualitySynced() const {
12519 inline void syncSpecialEquality();
12522 void generateOwnShape(JSContext *cx);
12524 void setOwnShape(uint32 s) { flags |= OWN_SHAPE; objShape = s; }
12525 void clearOwnShape() { flags &= ~OWN_SHAPE; objShape = map->shape; }
12528 inline bool nativeEmpty() const;
12530 bool hasOwnShape() const { return !!(flags & OWN_SHAPE); }
12532 void setMap(const JSObjectMap *amap) {
12534 map = const_cast<JSObjectMap *>(amap);
12535 objShape = map->shape;
12538 void setSharedNonNativeMap() {
12539 setMap(&JSObjectMap::sharedNonNative);
12542 void deletingShapeChange(JSContext *cx, const js::Shape &shape);
12543 const js::Shape *methodShapeChange(JSContext *cx, const js::Shape &shape);
12544 bool methodShapeChange(JSContext *cx, uint32 slot);
12545 void protoShapeChange(JSContext *cx);
12546 void shadowingShapeChange(JSContext *cx, const js::Shape &shape);
12547 bool globalObjectOwnShapeChange(JSContext *cx);
12548 void watchpointOwnShapeChange(JSContext *cx) { generateOwnShape(cx); }
12550 void extensibleShapeChange(JSContext *cx) {
12552 generateOwnShape(cx);
12555 bool hasMethodBarrier() { return !!(flags & METHOD_BARRIER); }
12556 void setMethodBarrier() { flags |= METHOD_BARRIER; }
12564 bool brandedOrHasMethodBarrier() { return !!(flags & (BRANDED | METHOD_BARRIER)); }
12571 const js::Shape *methodReadBarrier(JSContext *cx, const js::Shape &shape, js::Value *vp);
12573 const js::Shape *methodWriteBarrier(JSContext *cx, const js::Shape &shape, const js::Value &v);
12574 bool methodWriteBarrier(JSContext *cx, uint32 slot, const js::Value &v);
12576 bool isIndexed() const { return !!(flags & INDEXED); }
12577 void setIndexed() { flags |= INDEXED; }
12584 inline bool inDictionaryMode() const;
12586 inline uint32 propertyCount() const;
12588 inline bool hasPropertyTable() const;
12590 unsigned finalizeKind() const;
12592 uint32 numSlots() const { return capacity; }
12594 size_t slotsAndStructSize(uint32 nslots) const;
12595 size_t slotsAndStructSize() const { return slotsAndStructSize(numSlots()); }
12597 inline js::Value* fixedSlots() const;
12598 inline size_t numFixedSlots() const;
12600 static inline size_t getFixedSlotOffset(size_t slot);
12604 static const uint32 SLOT_CAPACITY_MIN = 8;
12606 bool allocSlots(JSContext *cx, size_t nslots);
12607 bool growSlots(JSContext *cx, size_t nslots);
12608 void shrinkSlots(JSContext *cx, size_t nslots);
12610 bool ensureSlots(JSContext *cx, size_t nslots) {
12611 if (numSlots() < nslots)
12612 return growSlots(cx, nslots);
12616 bool ensureInstanceReservedSlots(JSContext *cx, size_t nreserved);
12622 js::Value *getSlots() const {
12631 bool ensureClassReservedSlotsForEmptyObject(JSContext *cx);
12633 inline bool ensureClassReservedSlots(JSContext *cx);
12635 uint32 slotSpan() const { return map->slotSpan; }
12637 bool containsSlot(uint32 slot) const { return slot < slotSpan(); }
12639 js::Value& getSlotRef(uintN slot) {
12641 return slots[slot];
12644 js::Value &nativeGetSlotRef(uintN slot) {
12647 return getSlotRef(slot);
12650 const js::Value &getSlot(uintN slot) const {
12652 return slots[slot];
12655 const js::Value &nativeGetSlot(uintN slot) const {
12658 return getSlot(slot);
12661 void setSlot(uintN slot, const js::Value &value) {
12663 slots[slot] = value;
12666 void nativeSetSlot(uintN slot, const js::Value &value) {
12669 return setSlot(slot, value);
12672 inline js::Value getReservedSlot(uintN index) const;
12675 inline void updateShape(JSContext *cx);
12676 inline void updateFlags(const js::Shape *shape, bool isDefinitelyAtom = false);
12679 inline void extend(JSContext *cx, const js::Shape *shape, bool isDefinitelyAtom = false);
12681 JSObject *getProto() const { return proto; }
12682 void clearProto() { proto = __null; }
12684 void setProto(JSObject *newProto) {
12689 setDelegateNullSafe(newProto);
12693 JSObject *getParent() const {
12697 void clearParent() {
12701 void setParent(JSObject *newParent) {
12706 setDelegateNullSafe(newParent);
12707 parent = newParent;
12710 __attribute__((visibility ("default"))) JSObject * getGlobal() const;
12712 bool isGlobal() const {
12713 return !!(getClass()->flags & (1<<((8 + 8)+2)));
12716 void *getPrivate() const {
12718 return privateData;
12721 void setPrivate(void *data) {
12723 privateData = data;
12732 enum ImmutabilityType { SEAL, FREEZE };
12740 bool sealOrFreeze(JSContext *cx, ImmutabilityType it);
12743 bool isExtensible() const { return !(flags & NOT_EXTENSIBLE); }
12744 bool preventExtensions(JSContext *cx, js::AutoIdVector *props);
12747 inline bool seal(JSContext *cx) { return sealOrFreeze(cx, SEAL); }
12749 bool freeze(JSContext *cx) { return sealOrFreeze(cx, FREEZE); }
12756 static const uint32 JSSLOT_PRIMITIVE_THIS = 0;
12759 inline const js::Value &getPrimitiveThis() const;
12760 inline void setPrimitiveThis(const js::Value &pthis);
12766 inline uint32 getArrayLength() const;
12767 inline void setArrayLength(uint32 length);
12769 inline uint32 getDenseArrayCapacity();
12770 inline js::Value* getDenseArrayElements();
12771 inline const js::Value &getDenseArrayElement(uintN idx);
12772 inline js::Value* addressOfDenseArrayElement(uintN idx);
12773 inline void setDenseArrayElement(uintN idx, const js::Value &val);
12774 inline void shrinkDenseArrayElements(JSContext *cx, uintN cap);
12776 enum EnsureDenseResult { ED_OK, ED_FAILED, ED_SPARSE };
12777 inline EnsureDenseResult ensureDenseArrayElements(JSContext *cx, uintN index, uintN extra);
12783 bool willBeSparseDenseArray(uintN requiredCapacity, uintN newElementsHint);
12785 JSBool makeDenseArraySlow(JSContext *cx);
12793 static const uint32 JSSLOT_ARGS_DATA = 1;
12797 static const uint32 JSSLOT_ARGS_LENGTH = 0;
12798 static const uint32 ARGS_CLASS_RESERVED_SLOTS = 2;
12799 static const uint32 ARGS_FIRST_FREE_SLOT = ARGS_CLASS_RESERVED_SLOTS + 1;
12802 static const uint32 ARGS_LENGTH_OVERRIDDEN_BIT = 0x1;
12803 static const uint32 ARGS_PACKED_BITS_COUNT = 1;
12808 inline void setArgsLength(uint32 argc);
12814 inline uint32 getArgsInitialLength() const;
12816 inline void setArgsLengthOverridden();
12817 inline bool isArgsLengthOverridden() const;
12819 inline js::ArgumentsData *getArgsData() const;
12820 inline void setArgsData(js::ArgumentsData *data);
12822 inline const js::Value &getArgsCallee() const;
12823 inline void setArgsCallee(const js::Value &callee);
12825 inline const js::Value &getArgsElement(uint32 i) const;
12826 inline js::Value *getArgsElements() const;
12827 inline js::Value *addressOfArgsElement(uint32 i);
12828 inline void setArgsElement(uint32 i, const js::Value &v);
12832 static const uint32 JSSLOT_CALL_CALLEE = 0;
12833 static const uint32 JSSLOT_CALL_ARGUMENTS = 1;
12837 static const uint32 CALL_RESERVED_SLOTS = 2;
12840 inline bool callIsForEval() const;
12843 inline JSStackFrame *maybeCallObjStackFrame() const;
12849 inline JSObject *getCallObjCallee() const;
12850 inline JSFunction *getCallObjCalleeFunction() const;
12851 inline void setCallObjCallee(JSObject *callee);
12853 inline const js::Value &getCallObjArguments() const;
12854 inline void setCallObjArguments(const js::Value &v);
12857 inline const js::Value &callObjArg(uintN i) const;
12858 inline js::Value &callObjArg(uintN i);
12861 inline const js::Value &callObjVar(uintN i) const;
12862 inline js::Value &callObjVar(uintN i);
12868 static const uint32 JSSLOT_DATE_UTC_TIME = 0;
12875 static const uint32 JSSLOT_DATE_COMPONENTS_START = 1;
12877 static const uint32 JSSLOT_DATE_LOCAL_TIME = 1;
12878 static const uint32 JSSLOT_DATE_LOCAL_YEAR = 2;
12879 static const uint32 JSSLOT_DATE_LOCAL_MONTH = 3;
12880 static const uint32 JSSLOT_DATE_LOCAL_DATE = 4;
12881 static const uint32 JSSLOT_DATE_LOCAL_DAY = 5;
12882 static const uint32 JSSLOT_DATE_LOCAL_HOURS = 6;
12883 static const uint32 JSSLOT_DATE_LOCAL_MINUTES = 7;
12884 static const uint32 JSSLOT_DATE_LOCAL_SECONDS = 8;
12886 static const uint32 DATE_CLASS_RESERVED_SLOTS = 9;
12888 inline const js::Value &getDateUTCTime() const;
12889 inline void setDateUTCTime(const js::Value &pthis);
12896 friend struct JSFunction;
12897 friend class js::mjit::Compiler;
12903 static const uint32 JSSLOT_FLAT_CLOSURE_UPVARS = 0;
12910 static const uint32 JSSLOT_FUN_METHOD_ATOM = 0;
12911 static const uint32 JSSLOT_FUN_METHOD_OBJ = 1;
12913 static const uint32 JSSLOT_BOUND_FUNCTION_THIS = 0;
12914 static const uint32 JSSLOT_BOUND_FUNCTION_ARGS_COUNT = 1;
12917 static const uint32 FUN_CLASS_RESERVED_SLOTS = 2;
12919 inline JSFunction *getFunctionPrivate() const;
12921 inline js::Value *getFlatClosureUpvars() const;
12922 inline js::Value getFlatClosureUpvar(uint32 i) const;
12923 inline js::Value &getFlatClosureUpvar(uint32 i);
12924 inline void setFlatClosureUpvars(js::Value *upvars);
12926 inline bool hasMethodObj(const JSObject& obj) const;
12927 inline void setMethodObj(JSObject& obj);
12929 inline bool initBoundFunction(JSContext *cx, const js::Value &thisArg,
12930 const js::Value *args, uintN argslen);
12932 inline JSObject *getBoundFunctionTarget() const;
12933 inline const js::Value &getBoundFunctionThis() const;
12934 inline const js::Value *getBoundFunctionArguments(uintN &argslen) const;
12941 static const uint32 JSSLOT_REGEXP_LAST_INDEX = 0;
12944 static const uint32 REGEXP_CLASS_RESERVED_SLOTS = 1;
12946 inline const js::Value &getRegExpLastIndex() const;
12947 inline void setRegExpLastIndex(const js::Value &v);
12948 inline void setRegExpLastIndex(jsdouble d);
12949 inline void zeroRegExpLastIndex();
12955 inline js::NativeIterator *getNativeIterator() const;
12956 inline void setNativeIterator(js::NativeIterator *);
12962 inline JSScript *getScript() const;
12965 static const uint32 JSSLOT_NAME_PREFIX = 0;
12966 static const uint32 JSSLOT_NAME_URI = 1;
12968 static const uint32 JSSLOT_NAMESPACE_DECLARED = 2;
12970 static const uint32 JSSLOT_QNAME_LOCAL_NAME = 2;
12973 static const uint32 NAMESPACE_CLASS_RESERVED_SLOTS = 3;
12974 static const uint32 QNAME_CLASS_RESERVED_SLOTS = 3;
12976 inline JSLinearString *getNamePrefix() const;
12977 inline jsval getNamePrefixVal() const;
12978 inline void setNamePrefix(JSLinearString *prefix);
12979 inline void clearNamePrefix();
12981 inline JSLinearString *getNameURI() const;
12982 inline jsval getNameURIVal() const;
12983 inline void setNameURI(JSLinearString *uri);
12985 inline jsval getNamespaceDeclared() const;
12986 inline void setNamespaceDeclared(jsval decl);
12988 inline JSLinearString *getQNameLocalName() const;
12989 inline jsval getQNameLocalNameVal() const;
12990 inline void setQNameLocalName(JSLinearString *name);
12996 inline js::JSProxyHandler *getProxyHandler() const;
12997 inline const js::Value &getProxyPrivate() const;
12998 inline void setProxyPrivate(const js::Value &priv);
12999 inline const js::Value &getProxyExtra() const;
13000 inline void setProxyExtra(const js::Value &extra);
13005 inline JSObject *getWithThis() const;
13006 inline void setWithThis(JSObject *thisp);
13011 inline bool isCallable();
13014 void init(JSContext *cx, js::Class *aclasp, JSObject *proto, JSObject *parent,
13015 void *priv, bool useHoles);
13017 inline void finish(JSContext *cx);
13018 __attribute__((always_inline)) inline void finalize(JSContext *cx);
13024 inline bool initSharingEmptyShape(JSContext *cx,
13031 inline bool hasSlotsArray() const;
13034 inline void freeSlotsArray(JSContext *cx);
13037 inline void revertToFixedSlots(JSContext *cx);
13039 inline bool hasProperty(JSContext *cx, jsid id, bool *foundp, uintN flags = 0);
13041 bool allocSlot(JSContext *cx, uint32 *slotp);
13042 bool freeSlot(JSContext *cx, uint32 slot);
13045 bool reportReadOnly(JSContext* cx, jsid id, uintN report = 0x0);
13046 bool reportNotConfigurable(JSContext* cx, jsid id, uintN report = 0x0);
13047 bool reportNotExtensible(JSContext *cx, uintN report = 0x0);
13050 js::Shape *getChildProperty(JSContext *cx, js::Shape *parent, js::Shape &child);
13052 const js::Shape *addPropertyInternal(JSContext *cx, jsid id,
13053 js::PropertyOp getter, js::StrictPropertyOp setter,
13054 uint32 slot, uintN attrs,
13055 uintN flags, intN shortid,
13058 bool toDictionaryMode(JSContext *cx);
13062 const js::Shape *addProperty(JSContext *cx, jsid id,
13063 js::PropertyOp getter, js::StrictPropertyOp setter,
13064 uint32 slot, uintN attrs,
13065 uintN flags, intN shortid);
13068 const js::Shape *addDataProperty(JSContext *cx, jsid id, uint32 slot, uintN attrs) {
13070 return addProperty(cx, id, __null, __null, slot, attrs, 0, 0);
13074 const js::Shape *putProperty(JSContext *cx, jsid id,
13075 js::PropertyOp getter, js::StrictPropertyOp setter,
13076 uint32 slot, uintN attrs,
13077 uintN flags, intN shortid);
13080 const js::Shape *changeProperty(JSContext *cx, const js::Shape *shape, uintN attrs, uintN mask,
13081 js::PropertyOp getter, js::StrictPropertyOp setter);
13084 bool removeProperty(JSContext *cx, jsid id);
13087 void clear(JSContext *cx);
13089 JSBool lookupProperty(JSContext *cx, jsid id, JSObject **objp, JSProperty **propp) {
13090 js::LookupPropOp op = getOps()->lookupProperty;
13091 return (op ? op : js_LookupProperty)(cx, this, id, objp, propp);
13094 JSBool defineProperty(JSContext *cx, jsid id, const js::Value &value,
13095 js::PropertyOp getter = js::PropertyStub,
13096 js::StrictPropertyOp setter = js::StrictPropertyStub,
13097 uintN attrs = 0x01) {
13098 js::DefinePropOp op = getOps()->defineProperty;
13099 return (op ? op : js_DefineProperty)(cx, this, id, &value, getter, setter, attrs);
13102 JSBool getProperty(JSContext *cx, JSObject *receiver, jsid id, js::Value *vp) {
13103 js::PropertyIdOp op = getOps()->getProperty;
13104 return (op ? op : (js::PropertyIdOp)js_GetProperty)(cx, this, receiver, id, vp);
13107 JSBool getProperty(JSContext *cx, jsid id, js::Value *vp) {
13108 return getProperty(cx, this, id, vp);
13111 JSBool setProperty(JSContext *cx, jsid id, js::Value *vp, JSBool strict) {
13112 js::StrictPropertyIdOp op = getOps()->setProperty;
13113 return (op ? op : js_SetProperty)(cx, this, id, vp, strict);
13116 JSBool getAttributes(JSContext *cx, jsid id, uintN *attrsp) {
13117 js::AttributesOp op = getOps()->getAttributes;
13118 return (op ? op : js_GetAttributes)(cx, this, id, attrsp);
13121 JSBool setAttributes(JSContext *cx, jsid id, uintN *attrsp) {
13122 js::AttributesOp op = getOps()->setAttributes;
13123 return (op ? op : js_SetAttributes)(cx, this, id, attrsp);
13126 JSBool deleteProperty(JSContext *cx, jsid id, js::Value *rval, JSBool strict) {
13127 js::DeleteIdOp op = getOps()->deleteProperty;
13128 return (op ? op : js_DeleteProperty)(cx, this, id, rval, strict);
13131 JSBool enumerate(JSContext *cx, JSIterateOp iterop, js::Value *statep, jsid *idp) {
13132 js::NewEnumerateOp op = getOps()->enumerate;
13133 return (op ? op : js_Enumerate)(cx, this, iterop, statep, idp);
13136 JSType typeOf(JSContext *cx) {
13137 js::TypeOfOp op = getOps()->typeOf;
13138 return (op ? op : js_TypeOf)(cx, this);
13142 JSObject *thisObject(JSContext *cx) {
13143 JSObjectOp op = getOps()->thisObject;
13144 return op ? op(cx, this) : this;
13147 static bool thisObject(JSContext *cx, const js::Value &v, js::Value *vp);
13149 inline JSCompartment *getCompartment() const;
13151 inline JSObject *getThrowTypeError() const;
13153 __attribute__((visibility ("default"))) JSObject * clone(JSContext *cx, JSObject *proto, JSObject *parent);
13154 __attribute__((visibility ("default"))) bool copyPropertiesFrom(JSContext *cx, JSObject *obj);
13155 bool swap(JSContext *cx, JSObject *other);
13157 const js::Shape *defineBlockVariable(JSContext *cx, jsid id, intN index);
13159 inline bool canHaveMethodBarrier() const;
13161 inline bool isArguments() const;
13162 inline bool isNormalArguments() const;
13163 inline bool isStrictArguments() const;
13164 inline bool isArray() const;
13165 inline bool isDenseArray() const;
13166 inline bool isSlowArray() const;
13167 inline bool isNumber() const;
13168 inline bool isBoolean() const;
13169 inline bool isString() const;
13170 inline bool isPrimitive() const;
13171 inline bool isDate() const;
13172 inline bool isFunction() const;
13173 inline bool isObject() const;
13174 inline bool isWith() const;
13175 inline bool isBlock() const;
13176 inline bool isStaticBlock() const;
13177 inline bool isClonedBlock() const;
13178 inline bool isCall() const;
13179 inline bool isRegExp() const;
13180 inline bool isScript() const;
13181 inline bool isXML() const;
13182 inline bool isXMLId() const;
13183 inline bool isNamespace() const;
13184 inline bool isQName() const;
13186 inline bool isProxy() const;
13187 inline bool isObjectProxy() const;
13188 inline bool isFunctionProxy() const;
13190 __attribute__((visibility ("default"))) bool isWrapper() const;
13191 __attribute__((visibility ("default"))) JSObject * unwrap(uintN *flagsp = __null);
13193 inline void initArrayClass();
13197 typedef int js_static_assert37[(sizeof(JSObject) % sizeof(js::Value) == 0) ? 1 : -1];
13200 JSObject::fixedSlots() const {
13201 return (js::Value*) (jsuword(this) + sizeof(JSObject));
13208 JSObject::hasSlotsArray() const { return this->slots != fixedSlots(); }
13211 JSObject::getFixedSlotOffset(size_t slot) {
13212 return sizeof(JSObject) + (slot * sizeof(js::Value));
13215 struct JSObject_Slots2 : JSObject { js::Value fslots[2]; };
13216 struct JSObject_Slots4 : JSObject { js::Value fslots[4]; };
13217 struct JSObject_Slots8 : JSObject { js::Value fslots[8]; };
13218 struct JSObject_Slots12 : JSObject { js::Value fslots[12]; };
13219 struct JSObject_Slots16 : JSObject { js::Value fslots[16]; };
13222 OBJ_TO_INNER_OBJECT(JSContext *cx, JSObject *&obj)
13224 if (JSObjectOp op = obj->getClass()->ext.innerObject)
13229 OBJ_TO_OUTER_OBJECT(JSContext *cx, JSObject *&obj)
13231 if (JSObjectOp op = obj->getClass()->ext.outerObject)
13235 class JSValueArray {
13240 JSValueArray(jsval *v, size_t c) : array(v), length(c) {}
13248 ValueArray(js::Value *v, size_t c) : array(v), length(c) {}
13251 extern js::Class js_ObjectClass;
13252 extern js::Class js_WithClass;
13253 extern js::Class js_BlockClass;
13255 inline bool JSObject::isObject() const { return getClass() == &js_ObjectClass; }
13256 inline bool JSObject::isWith() const { return getClass() == &js_WithClass; }
13257 inline bool JSObject::isBlock() const { return getClass() == &js_BlockClass; }
13259 static const uint32 JSSLOT_BLOCK_DEPTH = 0;
13260 static const uint32 JSSLOT_BLOCK_FIRST_FREE_SLOT = JSSLOT_BLOCK_DEPTH + 1;
13266 JSObject::isStaticBlock() const
13268 return isBlock() && !getProto();
13275 JSObject::isClonedBlock() const
13277 return isBlock() && !!getProto();
13280 static const uint32 JSSLOT_WITH_THIS = 1;
13283 js_NewWithObject(JSContext *cx, JSObject *proto, JSObject *parent, jsint depth);
13286 js_UnwrapWithObject(JSContext *cx, JSObject *withobj)
13289 return withobj->getProto();
13299 js_NewBlockObject(JSContext *cx);
13302 js_CloneBlockObject(JSContext *cx, JSObject *proto, JSStackFrame *fp);
13305 js_PutBlockObject(JSContext *cx, JSBool normalUnwind);
13308 js_XDRBlockObject(JSXDRState *xdr, JSObject **objp);
13310 struct JSSharpObjectMap {
13313 JSHashTable *table;
13316 extern JSHashEntry *
13317 js_EnterSharpObject(JSContext *cx, JSObject *obj, JSIdArray **idap,
13321 js_LeaveSharpObject(JSContext *cx, JSIdArray **idap);
13328 js_TraceSharpMap(JSTracer *trc, JSSharpObjectMap *map);
13331 js_HasOwnPropertyHelper(JSContext *cx, js::LookupPropOp lookup, uintN argc,
13335 js_HasOwnProperty(JSContext *cx, js::LookupPropOp lookup, JSObject *obj, jsid id,
13336 JSObject **objp, JSProperty **propp);
13339 js_NewPropertyDescriptorObject(JSContext *cx, jsid id, uintN attrs,
13340 const js::Value &getter, const js::Value &setter,
13341 const js::Value &value, js::Value *vp);
13344 js_PropertyIsEnumerable(JSContext *cx, JSObject *obj, jsid id, js::Value *vp);
13347 __attribute__((visibility ("default"))) JSBool js_obj_defineGetter(JSContext *cx, uintN argc, js::Value *vp);
13348 __attribute__((visibility ("default"))) JSBool js_obj_defineSetter(JSContext *cx, uintN argc, js::Value *vp);
13352 js_InitObjectClass(JSContext *cx, JSObject *obj);
13356 DefineConstructorAndPrototype(JSContext *cx, JSObject *obj, JSProtoKey key, JSAtom *atom,
13357 JSObject *protoProto, Class *clasp,
13358 Native constructor, uintN nargs,
13359 JSPropertySpec *ps, JSFunctionSpec *fs,
13360 JSPropertySpec *static_ps, JSFunctionSpec *static_fs);
13364 js_InitClass(JSContext *cx, JSObject *obj, JSObject *parent_proto,
13365 js::Class *clasp, js::Native constructor, uintN nargs,
13366 JSPropertySpec *ps, JSFunctionSpec *fs,
13367 JSPropertySpec *static_ps, JSFunctionSpec *static_fs);
13372 extern const char js_watch_str[];
13373 extern const char js_unwatch_str[];
13374 extern const char js_hasOwnProperty_str[];
13375 extern const char js_isPrototypeOf_str[];
13376 extern const char js_propertyIsEnumerable_str[];
13379 extern const char js_defineGetter_str[];
13380 extern const char js_defineSetter_str[];
13381 extern const char js_lookupGetter_str[];
13382 extern const char js_lookupSetter_str[];
13386 js_PopulateObject(JSContext *cx, JSObject *newborn, JSObject *props);
13392 js_GetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key,
13396 js_SetClassObject(JSContext *cx, JSObject *obj, JSProtoKey key,
13397 JSObject *cobj, JSObject *prototype);
13404 js_FindClassObject(JSContext *cx, JSObject *start, JSProtoKey key,
13405 js::Value *vp, js::Class *clasp = __null);
13408 js_ConstructObject(JSContext *cx, js::Class *clasp, JSObject *proto,
13409 JSObject *parent, uintN argc, js::Value *argv);
13414 js_CreateThisForFunctionWithProto(JSContext *cx, JSObject *callee, JSObject *proto);
13418 js_CreateThisForFunction(JSContext *cx, JSObject *callee);
13422 js_CreateThis(JSContext *cx, JSObject *callee);
13425 js_CheckForStringIndex(jsid id);
13434 js_PurgeScopeChainHelper(JSContext *cx, JSObject *obj, jsid id);
13437 js_PurgeScopeChain(JSContext *cx, JSObject *obj, jsid id)
13439 if (obj->isDelegate())
13440 js_PurgeScopeChainHelper(cx, obj, id);
13447 extern const js::Shape *
13448 js_AddNativeProperty(JSContext *cx, JSObject *obj, jsid id,
13449 js::PropertyOp getter, js::StrictPropertyOp setter, uint32 slot,
13450 uintN attrs, uintN flags, intN shortid);
13457 extern const js::Shape *
13458 js_ChangeNativePropertyAttrs(JSContext *cx, JSObject *obj,
13459 const js::Shape *shape, uintN attrs, uintN mask,
13460 js::PropertyOp getter, js::StrictPropertyOp setter);
13463 js_DefineOwnProperty(JSContext *cx, JSObject *obj, jsid id,
13464 const js::Value &descriptor, JSBool *bp);
13469 const uintN JSDNP_CACHE_RESULT = 1;
13470 const uintN JSDNP_DONT_PURGE = 2;
13471 const uintN JSDNP_SET_METHOD = 4;
13474 const uintN JSDNP_UNQUALIFIED = 8;
13477 js_DefineNativeProperty(JSContext *cx, JSObject *obj, jsid id, const js::Value &value,
13478 js::PropertyOp getter, js::StrictPropertyOp setter, uintN attrs,
13479 uintN flags, intN shortid, JSProperty **propp,
13480 uintN defineHow = 0);
13488 js_LookupPropertyWithFlags(JSContext *cx, JSObject *obj, jsid id, uintN flags,
13489 JSObject **objp, JSProperty **propp);
13492 extern __attribute__((visibility ("default"))) js::Class js_CallClass;
13493 extern __attribute__((visibility ("default"))) js::Class js_DeclEnvClass;
13506 IsCacheableNonGlobalScope(JSObject *obj)
13510 js::Class *clasp = obj->getClass();
13511 bool cacheable = (clasp == &js_CallClass ||
13512 clasp == &js_BlockClass ||
13513 clasp == &js_DeclEnvClass);
13524 extern js::PropertyCacheEntry *
13525 js_FindPropertyHelper(JSContext *cx, jsid id, JSBool cacheResult,
13526 JSObject **objp, JSObject **pobjp, JSProperty **propp);
13532 extern __attribute__((visibility ("default"))) JSBool
13533 js_FindProperty(JSContext *cx, jsid id, JSObject **objp, JSObject **pobjp,
13534 JSProperty **propp);
13537 js_FindIdentifierBase(JSContext *cx, JSObject *scopeChain, jsid id);
13540 js_FindVariableScope(JSContext *cx, JSFunction **funp);
13542 const uintN JSGET_CACHE_RESULT = 1;
13543 const uintN JSGET_METHOD_BARRIER = 0;
13544 const uintN JSGET_NO_METHOD_BARRIER = 2;
13553 js_NativeGet(JSContext *cx, JSObject *obj, JSObject *pobj, const js::Shape *shape, uintN getHow,
13557 js_NativeSet(JSContext *cx, JSObject *obj, const js::Shape *shape, bool added,
13558 bool strict, js::Value *vp);
13561 js_GetPropertyHelper(JSContext *cx, JSObject *obj, jsid id, uint32 getHow, js::Value *vp);
13567 js_GetPropertyHelperWithShape(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id,
13568 uint32 getHow, js::Value *vp,
13569 const js::Shape **shapeOut, JSObject **holderOut);
13572 js_GetOwnPropertyDescriptor(JSContext *cx, JSObject *obj, jsid id, js::Value *vp);
13575 js_GetMethod(JSContext *cx, JSObject *obj, jsid id, uintN getHow, js::Value *vp);
13583 extern __attribute__((visibility ("default"))) bool
13584 js_CheckUndeclaredVarAssignment(JSContext *cx, JSString *propname);
13587 js_SetPropertyHelper(JSContext *cx, JSObject *obj, jsid id, uintN defineHow,
13588 js::Value *vp, JSBool strict);
13595 js_SetNativeAttributes(JSContext *cx, JSObject *obj, js::Shape *shape,
13605 HasNativeMethod(JSObject *obj, jsid methodid, Native native);
13611 DefaultValue(JSContext *cx, JSObject *obj, JSType hint, Value *vp);
13614 CheckAccess(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode,
13615 js::Value *vp, uintN *attrsp);
13623 js_IsDelegate(JSContext *cx, JSObject *obj, const js::Value &v);
13629 extern __attribute__((visibility ("default"))) JSBool
13630 js_GetClassPrototype(JSContext *cx, JSObject *scope, JSProtoKey protoKey,
13631 JSObject **protop, js::Class *clasp = __null);
13634 js_SetClassPrototype(JSContext *cx, JSObject *ctor, JSObject *proto,
13642 js_PrimitiveToObject(JSContext *cx, js::Value *vp);
13649 js_ValueToObjectOrNull(JSContext *cx, const js::Value &v, JSObject **objp);
13658 ToObjectSlow(JSContext *cx, js::Value *vp);
13660 __attribute__((always_inline)) inline JSObject *
13661 ToObject(JSContext *cx, js::Value *vp)
13663 if (vp->isObject())
13664 return &vp->toObject();
13665 return ToObjectSlow(cx, vp);
13675 js_ValueToNonNullObject(JSContext *cx, const js::Value &v);
13678 js_TryValueOf(JSContext *cx, JSObject *obj, JSType type, js::Value *rval);
13681 js_TryMethod(JSContext *cx, JSObject *obj, JSAtom *atom,
13682 uintN argc, js::Value *argv, js::Value *rval);
13685 js_XDRObject(JSXDRState *xdr, JSObject **objp);
13688 js_TraceObject(JSTracer *trc, JSObject *obj);
13691 js_PrintObjectSlotName(JSTracer *trc, char *buf, size_t bufsize);
13694 js_ClearNative(JSContext *cx, JSObject *obj);
13700 js_GetReservedSlot(JSContext *cx, JSObject *obj, uint32 index, js::Value *vp);
13706 js_SetReservedSlot(JSContext *cx, JSObject *obj, uint32 index, const js::Value &v);
13709 js_CheckPrincipalsAccess(JSContext *cx, JSObject *scopeobj,
13710 JSPrincipals *principals, JSAtom *caller);
13714 js_CheckContentSecurityPolicy(JSContext *cx, JSObject *scopeObj);
13717 extern const char *
13718 js_ComputeFilename(JSContext *cx, JSStackFrame *caller,
13719 JSPrincipals *principals, uintN *linenop);
13722 js_ReportGetterOnlyAssignment(JSContext *cx);
13724 extern __attribute__((visibility ("default"))) JSBool
13725 js_GetterOnlyPropertyStub(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp);
13728 js_InferFlags(JSContext *cx, uintN defaultFlags);
13732 js_Object(JSContext *cx, uintN argc, js::Value *vp);
13741 SetProto(JSContext *cx, JSObject *obj, JSObject *proto, bool checkForCycles);
13744 obj_toStringHelper(JSContext *cx, JSObject *obj);
13746 enum EvalType { INDIRECT_EVAL, DIRECT_EVAL };
13752 EvalKernel(JSContext *cx, uintN argc, js::Value *vp, EvalType evalType, JSStackFrame *caller,
13753 JSObject *scopeobj);
13755 extern __attribute__((visibility ("default"))) bool
13756 IsBuiltinEvalFunction(JSFunction *fun);
13762 UNIT_STRING_LIMIT = 256U,
13763 SMALL_CHAR_LIMIT = 128U,
13764 NUM_SMALL_CHARS = 64U,
13765 INT_STRING_LIMIT = 256U,
13766 NUM_HUNDRED_STRINGS = 156U
13771 js_GetDependentStringChars(JSString *str);
13774 js_ConcatStrings(JSContext *cx, JSString *left, JSString *right);
13776 typedef int js_static_assert38[((8 * 8) >= 32) ? 1 : -1];
13778 struct JSRopeBufferInfo {
13784 namespace js { namespace mjit {
13788 struct JSLinearString;
13792 friend class js::TraceRecorder;
13793 friend class js::mjit::Compiler;
13795 friend JSAtom *js_AtomizeString(JSContext *cx, JSString *str, uintN flags);
13801 size_t lengthAndFlags;
13803 const jschar *chars;
13807 jschar inlineStorage[4];
13819 size_t externalStringType;
13822 static const size_t TYPE_FLAGS_MASK = (((JSUint32)1 << (4)) - 1);
13823 static const size_t LENGTH_SHIFT = 4;
13825 static const size_t TYPE_MASK = (((JSUint32)1 << (2)) - 1);
13826 static const size_t FLAT = 0x0;
13827 static const size_t DEPENDENT = 0x1;
13828 static const size_t ROPE = 0x2;
13831 static const size_t DEPENDENT_BIT = ((JSUint32)1 << (0));
13832 static const size_t ROPE_BIT = ((JSUint32)1 << (1));
13834 static const size_t ATOMIZED = ((JSUint32)1 << (2));
13835 static const size_t EXTENSIBLE = ((JSUint32)1 << (3));
13838 size_t buildLengthAndFlags(size_t length, size_t flags) {
13839 return (length << LENGTH_SHIFT) | flags;
13842 inline js::gc::Cell *asCell() {
13843 return reinterpret_cast<js::gc::Cell *>(this);
13846 inline js::gc::FreeCell *asFreeCell() {
13847 return reinterpret_cast<js::gc::FreeCell *>(this);
13854 static const size_t MAX_LENGTH = (1 << 28) - 1;
13856 __attribute__((always_inline)) inline bool isDependent() const {
13857 return lengthAndFlags & DEPENDENT_BIT;
13860 __attribute__((always_inline)) inline bool isFlat() const {
13861 return (lengthAndFlags & TYPE_MASK) == FLAT;
13864 __attribute__((always_inline)) inline bool isExtensible() const {
13866 return lengthAndFlags & EXTENSIBLE;
13869 __attribute__((always_inline)) inline bool isAtomized() const {
13871 return lengthAndFlags & ATOMIZED;
13874 __attribute__((always_inline)) inline bool isRope() const {
13875 return lengthAndFlags & ROPE_BIT;
13878 __attribute__((always_inline)) inline size_t length() const {
13879 return lengthAndFlags >> LENGTH_SHIFT;
13882 __attribute__((always_inline)) inline bool empty() const {
13883 return lengthAndFlags <= TYPE_FLAGS_MASK;
13887 __attribute__((always_inline)) inline const jschar *getChars(JSContext *cx) {
13889 return flatten(cx);
13890 return nonRopeChars();
13894 __attribute__((always_inline)) inline const jschar *getCharsZ(JSContext *cx) {
13896 return undepend(cx);
13897 return flatChars();
13900 __attribute__((always_inline)) inline void initFlatNotTerminated(jschar *chars, size_t length) {
13903 lengthAndFlags = buildLengthAndFlags(length, FLAT);
13908 __attribute__((always_inline)) inline void initFlat(jschar *chars, size_t length) {
13909 initFlatNotTerminated(chars, length);
13913 __attribute__((always_inline)) inline void initShortString(const jschar *chars, size_t length) {
13917 lengthAndFlags = buildLengthAndFlags(length, FLAT);
13921 __attribute__((always_inline)) inline void initFlatExtensible(jschar *chars, size_t length, size_t cap) {
13925 lengthAndFlags = buildLengthAndFlags(length, FLAT | EXTENSIBLE);
13930 __attribute__((always_inline)) inline JSFlatString *assertIsFlat() {
13932 return reinterpret_cast<JSFlatString *>(this);
13935 __attribute__((always_inline)) inline const jschar *flatChars() const {
13940 __attribute__((always_inline)) inline size_t flatLength() const {
13945 inline void flatSetAtomized() {
13948 lengthAndFlags |= ATOMIZED;
13951 inline void flatClearExtensible() {
13957 if (lengthAndFlags & EXTENSIBLE)
13958 lengthAndFlags &= ~EXTENSIBLE;
13965 inline void initDependent(JSString *base, const jschar *chars, size_t length) {
13970 lengthAndFlags = buildLengthAndFlags(length, DEPENDENT);
13975 inline JSLinearString *dependentBase() const {
13977 return s.base->assertIsLinear();
13980 __attribute__((always_inline)) inline const jschar *dependentChars() {
13985 inline size_t dependentLength() const {
13990 const jschar *undepend(JSContext *cx);
13992 const jschar *nonRopeChars() const {
13998 inline void initRopeNode(JSString *left, JSString *right, size_t length) {
14000 lengthAndFlags = buildLengthAndFlags(length, ROPE);
14005 inline JSString *ropeLeft() const {
14010 inline JSString *ropeRight() const {
14015 inline void finishTraversalConversion(JSString *base, const jschar *baseBegin, const jschar *end) {
14017 lengthAndFlags = buildLengthAndFlags(end - u.chars, DEPENDENT);
14021 const jschar *flatten(JSContext *maybecx);
14023 JSLinearString *ensureLinear(JSContext *cx) {
14024 if (isRope() && !flatten(cx))
14026 return reinterpret_cast<JSLinearString *>(this);
14029 bool isLinear() const {
14033 JSLinearString *assertIsLinear() {
14035 return reinterpret_cast<JSLinearString *>(this);
14038 typedef uint8 SmallChar;
14040 static inline bool fitsInSmallChar(jschar c) {
14042 return c < SMALL_CHAR_LIMIT && toSmallChar[c] != INVALID_SMALL_CHAR;
14048 static inline bool isUnitString(void *ptr) {
14050 jsuword delta = reinterpret_cast<jsuword>(ptr) -
14051 reinterpret_cast<jsuword>(unitStringTable);
14052 if (delta >= UNIT_STRING_LIMIT * sizeof(JSString))
14063 static inline bool isLength2String(void *ptr) {
14065 jsuword delta = reinterpret_cast<jsuword>(ptr) -
14066 reinterpret_cast<jsuword>(length2StringTable);
14067 if (delta >= NUM_SMALL_CHARS * NUM_SMALL_CHARS * sizeof(JSString))
14078 static inline bool isHundredString(void *ptr) {
14080 jsuword delta = reinterpret_cast<jsuword>(ptr) -
14081 reinterpret_cast<jsuword>(hundredStringTable);
14082 if (delta >= NUM_HUNDRED_STRINGS * sizeof(JSString))
14093 static inline bool isStatic(void *ptr) {
14094 return isUnitString(ptr) || isLength2String(ptr) || isHundredString(ptr);
14102 static const SmallChar INVALID_SMALL_CHAR = -1;
14104 static const jschar fromSmallChar[];
14105 static const SmallChar toSmallChar[];
14106 static const JSString unitStringTable[];
14107 static const JSString length2StringTable[];
14108 static const JSString hundredStringTable[];
14113 static const JSString *const intStringTable[];
14116 static JSFlatString *unitString(jschar c);
14117 static JSLinearString *getUnitString(JSContext *cx, JSString *str, size_t index);
14118 static JSFlatString *length2String(jschar c1, jschar c2);
14119 static JSFlatString *length2String(uint32 i);
14120 static JSFlatString *intString(jsint i);
14122 static JSFlatString *lookupStaticString(const jschar *chars, size_t length);
14124 __attribute__((always_inline)) inline void finalize(JSContext *cx);
14126 static size_t offsetOfLengthAndFlags() {
14127 return __builtin_offsetof (JSString, lengthAndFlags);
14130 static size_t offsetOfChars() {
14131 return __builtin_offsetof (JSString, u.chars);
14134 static void staticAsserts() {
14135 typedef int js_static_assert39[(((JSString::MAX_LENGTH << JSString::LENGTH_SHIFT) >> JSString::LENGTH_SHIFT) == JSString::MAX_LENGTH) ? 1 : -1]
14145 struct JSLinearString : JSString
14147 const jschar *chars() const { return JSString::nonRopeChars(); }
14150 typedef int js_static_assert40[(sizeof(JSLinearString) == sizeof(JSString)) ? 1 : -1];
14156 struct JSFlatString : JSLinearString
14158 const jschar *charsZ() const { return chars(); }
14161 typedef int js_static_assert41[(sizeof(JSFlatString) == sizeof(JSString)) ? 1 : -1];
14167 struct JSAtom : JSFlatString
14171 struct JSExternalString : JSString
14173 static const uintN TYPE_LIMIT = 8;
14174 static JSStringFinalizeOp str_finalizers[TYPE_LIMIT];
14176 static intN changeFinalizer(JSStringFinalizeOp oldop,
14177 JSStringFinalizeOp newop) {
14178 for (uintN i = 0; i != (sizeof (str_finalizers) / sizeof (str_finalizers)[0]); i++) {
14179 if (str_finalizers[i] == oldop) {
14180 str_finalizers[i] = newop;
14187 void finalize(JSContext *cx);
14191 typedef int js_static_assert42[(sizeof(JSString) == sizeof(JSExternalString)) ? 1 : -1];
14198 class JSShortString : public js::gc::Cell
14209 inline jschar *init(size_t length) {
14211 mHeader.initShortString(mHeader.inlineStorage, length);
14212 return mHeader.inlineStorage;
14215 inline jschar *getInlineStorageBeforeInit() {
14216 return mHeader.inlineStorage;
14219 inline void initAtOffsetInBuffer(jschar *p, size_t length) {
14221 mHeader.initShortString(p, length);
14224 inline void resetLength(size_t length) {
14225 mHeader.initShortString(mHeader.flatChars(), length);
14228 inline JSString *header() {
14232 static const size_t FREE_STRING_WORDS = 2;
14234 static const size_t MAX_SHORT_STRING_LENGTH =
14235 ((sizeof(JSString) + FREE_STRING_WORDS * sizeof(size_t)) / sizeof(jschar)) - 1;
14237 static inline bool fitsIntoShortString(size_t length) {
14238 return length <= MAX_SHORT_STRING_LENGTH;
14241 __attribute__((always_inline)) inline void finalize(JSContext *cx);
14243 static void staticAsserts() {
14244 typedef int js_static_assert43[(__builtin_offsetof (JSString, inlineStorage) == sizeof(JSString) - JSShortString::FREE_STRING_WORDS * sizeof(void *)) ? 1 : -1]
14246 typedef int js_static_assert44[(__builtin_offsetof (JSShortString, mDummy) == sizeof(JSString)) ? 1 : -1];
14247 typedef int js_static_assert45[(__builtin_offsetof (JSString, inlineStorage) + sizeof(jschar) * (JSShortString::MAX_SHORT_STRING_LENGTH + 1) == sizeof(JSShortString)) ? 1 : -1]
14255 class StringBuffer;
14257 class StringSegmentRange;
14258 class MutatingRopeSegmentRange;
14267 extern const jschar *
14268 js_GetStringChars(JSContext *cx, JSString *str);
14270 extern const jschar *
14271 js_UndependString(JSContext *cx, JSString *str);
14274 js_MakeStringImmutable(JSContext *cx, JSString *str);
14277 js_toLowerCase(JSContext *cx, JSString *str);
14280 js_toUpperCase(JSContext *cx, JSString *str);
14282 struct JSSubString {
14284 const jschar *chars;
14287 extern jschar js_empty_ucstr[];
14288 extern JSSubString js_EmptySubString;
14291 extern const uint8 js_X[];
14292 extern const uint8 js_Y[];
14293 extern const uint32 js_A[];
14296 typedef enum JSCharType {
14297 JSCT_UNASSIGNED = 0,
14298 JSCT_UPPERCASE_LETTER = 1,
14299 JSCT_LOWERCASE_LETTER = 2,
14300 JSCT_TITLECASE_LETTER = 3,
14301 JSCT_MODIFIER_LETTER = 4,
14302 JSCT_OTHER_LETTER = 5,
14303 JSCT_NON_SPACING_MARK = 6,
14304 JSCT_ENCLOSING_MARK = 7,
14305 JSCT_COMBINING_SPACING_MARK = 8,
14306 JSCT_DECIMAL_DIGIT_NUMBER = 9,
14307 JSCT_LETTER_NUMBER = 10,
14308 JSCT_OTHER_NUMBER = 11,
14309 JSCT_SPACE_SEPARATOR = 12,
14310 JSCT_LINE_SEPARATOR = 13,
14311 JSCT_PARAGRAPH_SEPARATOR = 14,
14314 JSCT_PRIVATE_USE = 18,
14315 JSCT_SURROGATE = 19,
14316 JSCT_DASH_PUNCTUATION = 20,
14317 JSCT_START_PUNCTUATION = 21,
14318 JSCT_END_PUNCTUATION = 22,
14319 JSCT_CONNECTOR_PUNCTUATION = 23,
14320 JSCT_OTHER_PUNCTUATION = 24,
14321 JSCT_MATH_SYMBOL = 25,
14322 JSCT_CURRENCY_SYMBOL = 26,
14323 JSCT_MODIFIER_SYMBOL = 27,
14324 JSCT_OTHER_SYMBOL = 28
14327 extern const bool js_alnum[];
14329 const jschar BYTE_ORDER_MARK = 0xFEFF;
14330 const jschar NO_BREAK_SPACE = 0x00A0;
14336 JS_ISSPACE(jschar c)
14341 return (w <= ' ' && (w == ' ' || (9 <= w && w <= 0xD))) || w == NO_BREAK_SPACE;
14343 return w == BYTE_ORDER_MARK || ((js_A[js_Y[(js_X[(uint16)(w)>>6]<<6)|((w)&0x3F)]]) & 0x00070000) == 0x00040000;
14346 extern js::Class js_StringClass;
14352 JSObject::isString() const
14354 return getClass() == &js_StringClass;
14358 js_InitStringClass(JSContext *cx, JSObject *obj);
14360 extern const char js_escape_str[];
14361 extern const char js_unescape_str[];
14362 extern const char js_uneval_str[];
14363 extern const char js_decodeURI_str[];
14364 extern const char js_encodeURI_str[];
14365 extern const char js_decodeURIComponent_str[];
14366 extern const char js_encodeURIComponent_str[];
14369 extern JSFlatString *
14370 js_NewString(JSContext *cx, jschar *chars, size_t length);
14372 extern JSLinearString *
14373 js_NewDependentString(JSContext *cx, JSString *base, size_t start,
14377 extern JSFlatString *
14378 js_NewStringCopyN(JSContext *cx, const jschar *s, size_t n);
14380 extern JSFlatString *
14381 js_NewStringCopyN(JSContext *cx, const char *s, size_t n);
14384 extern JSFlatString *
14385 js_NewStringCopyZ(JSContext *cx, const jschar *s);
14387 extern JSFlatString *
14388 js_NewStringCopyZ(JSContext *cx, const char *s);
14393 extern const char *
14394 js_ValueToPrintable(JSContext *cx, const js::Value &,
14395 JSAutoByteString *bytes, bool asSource = false);
14402 js_ValueToString(JSContext *cx, const js::Value &v);
14411 static __attribute__((always_inline)) inline JSString *
14412 ValueToString_TestForStringInline(JSContext *cx, const Value &v)
14415 return v.toString();
14416 return js_ValueToString(cx, v);
14428 ValueToStringBuffer(JSContext *cx, const Value &v, StringBuffer &sb);
14436 extern __attribute__((visibility ("default"))) JSString *
14437 js_ValueToSource(JSContext *cx, const js::Value &v);
14444 js_HashString(JSLinearString *str)
14446 const jschar *s = str->chars();
14447 size_t n = str->length();
14449 for (h = 0; n; s++, n--)
14450 h = (((h) << (4)) | ((h) >> (32 - (4)))) ^ *s;
14464 EqualStrings(JSContext *cx, JSString *str1, JSString *str2, JSBool *result);
14471 EqualStrings(JSLinearString *str1, JSLinearString *str2);
14481 CompareStrings(JSContext *cx, JSString *str1, JSString *str2, int32 *result);
14490 StringEqualsAscii(JSLinearString *str, const char *asciiBytes);
14500 static const jsuint sBMHCharSetSize = 256;
14501 static const jsuint sBMHPatLenMax = 255;
14502 static const jsint sBMHBadPattern = -2;
14505 js_BoyerMooreHorspool(const jschar *text, jsuint textlen,
14506 const jschar *pat, jsuint patlen);
14509 js_strlen(const jschar *s);
14512 js_strchr(const jschar *s, jschar c);
14515 js_strchr_limit(const jschar *s, jschar c, const jschar *limit);
14520 js_short_strncpy(jschar *dest, const jschar *src, size_t num)
14527 for (size_t i = 0; i < num; i++)
14534 static inline const jschar *
14535 js_SkipWhiteSpace(const jschar *s, const jschar *end)
14538 while (s != end && JS_ISSPACE(*s))
14549 js_InflateString(JSContext *cx, const char *bytes, size_t *length);
14552 js_DeflateString(JSContext *cx, const jschar *chars, size_t length);
14561 js_InflateStringToBuffer(JSContext *cx, const char *bytes, size_t length,
14562 jschar *chars, size_t *charsLength);
14568 js_InflateUTF8StringToBuffer(JSContext *cx, const char *bytes, size_t length,
14569 jschar *chars, size_t *charsLength);
14576 js_GetDeflatedStringLength(JSContext *cx, const jschar *chars,
14577 size_t charsLength);
14583 js_GetDeflatedUTF8StringLength(JSContext *cx, const jschar *chars,
14584 size_t charsLength);
14593 js_DeflateStringToBuffer(JSContext *cx, const jschar *chars,
14594 size_t charsLength, char *bytes, size_t *length);
14600 js_DeflateStringToUTF8Buffer(JSContext *cx, const jschar *chars,
14601 size_t charsLength, char *bytes, size_t *length);
14605 js_str_escape(JSContext *cx, uintN argc, js::Value *argv, js::Value *rval);
14613 str_replace(JSContext *cx, uintN argc, js::Value *vp);
14617 js_str_toString(JSContext *cx, uintN argc, js::Value *vp);
14620 js_str_charAt(JSContext *cx, uintN argc, js::Value *vp);
14623 js_str_charCodeAt(JSContext *cx, uintN argc, js::Value *vp);
14630 js_OneUcs4ToUtf8Char(uint8 *utf8Buffer, uint32 ucs4Char);
14635 PutEscapedStringImpl(char *buffer, size_t size, FILE *fp, JSLinearString *str, uint32 quote);
14638 PutEscapedString(char *buffer, size_t size, JSLinearString *str, uint32 quote)
14640 size_t n = PutEscapedStringImpl(buffer, size, __null, str, quote);
14656 FileEscapedString(FILE *fp, JSLinearString *str, uint32 quote)
14658 return PutEscapedStringImpl(__null, 0, fp, str, quote) != size_t(-1);
14664 js_String(JSContext *cx, uintN argc, js::Value *vp);
14667 static __attribute__((always_inline)) inline jsid
14668 JSID_FROM_BITS(size_t bits)
14675 static __attribute__((always_inline)) inline jsid
14676 ATOM_TO_JSID(JSAtom *atom)
14679 return JSID_FROM_BITS((size_t)atom);
14683 static __attribute__((always_inline)) inline JSBool
14684 JSID_IS_ATOM(jsid id)
14686 return JSID_IS_STRING(id);
14689 static __attribute__((always_inline)) inline JSBool
14690 JSID_IS_ATOM(jsid id, JSAtom *atom)
14692 return (id) == (ATOM_TO_JSID(atom));
14695 static __attribute__((always_inline)) inline JSAtom *
14696 JSID_TO_ATOM(jsid id)
14698 return (JSAtom *)JSID_TO_STRING(id);
14703 static __attribute__((always_inline)) inline Value
14706 if (JSID_IS_STRING(id))
14707 return StringValue(JSID_TO_STRING(id));
14708 if ((__builtin_expect((JSID_IS_INT(id)), 1)))
14709 return Int32Value(JSID_TO_INT(id));
14710 if ((__builtin_expect((JSID_IS_OBJECT(id)), 1)))
14711 return ObjectValue(*JSID_TO_OBJECT(id));
14713 return UndefinedValue();
14716 static __attribute__((always_inline)) inline jsval
14719 return Jsvalify(IdToValue(id));
14724 extern const char *
14725 js_AtomToPrintableString(JSContext *cx, JSAtom *atom, JSAutoByteString *bytes);
14727 struct JSAtomListElement {
14733 JSHashTable *table;
14737 struct JSAtomList : public JSAtomSet
14744 list = __null; table = __null; count = 0;
14750 JSAtomList(const JSAtomSet& as) {
14751 list = as.list; table = as.table; count = as.count;
14757 void clear() { ((void) 0); list = __null; table = __null; count = 0; }
14759 JSAtomListElement *lookup(JSAtom *atom) {
14761 return rawLookup(atom, hep);
14764 JSAtomListElement *rawLookup(JSAtom *atom, JSHashEntry **&hep);
14766 enum AddHow { UNIQUE, SHADOW, HOIST };
14768 JSAtomListElement *add(js::Parser *parser, JSAtom *atom, AddHow how = UNIQUE);
14770 void remove(js::Parser *parser, JSAtom *atom) {
14772 JSAtomListElement *ale = rawLookup(atom, hep);
14774 rawRemove(parser, ale, hep);
14777 void rawRemove(js::Parser *parser, JSAtomListElement *ale, JSHashEntry **hep);
14784 struct JSAutoAtomList: public JSAtomList
14786 JSAutoAtomList(js::Parser *p): parser(p) {}
14789 js::Parser *parser;
14798 class JSAtomListIterator {
14800 JSAtomListElement* next;
14804 JSAtomListIterator(JSAtomList* al) : list(al) { reset(); }
14807 next = (JSAtomListElement *) list->list;
14811 JSAtomListElement* operator ()();
14823 typedef int js_static_assert46[(((size_t)(0x1 | 0x2)) < JS_GCTHING_ALIGN) ? 1 : -1];
14825 typedef uintptr_t AtomEntryType;
14827 static __attribute__((always_inline)) inline JSAtom *
14828 AtomEntryToKey(AtomEntryType entry)
14831 return (JSAtom *)(entry & ~((size_t)(0x1 | 0x2)));
14836 typedef JSLinearString *Lookup;
14838 static HashNumber hash(JSLinearString *str) {
14839 return js_HashString(str);
14842 static bool match(AtomEntryType entry, JSLinearString *lookup) {
14843 return entry ? EqualStrings(AtomEntryToKey(entry), lookup) : false;
14847 typedef HashSet<AtomEntryType, AtomHasher, SystemAllocPolicy> AtomSet;
14864 JSAtom *booleanAtoms[2];
14865 JSAtom *typeAtoms[JSTYPE_LIMIT];
14869 JSAtom *classAtoms[JSProto_LIMIT];
14872 JSAtom *anonymousAtom;
14874 JSAtom *argumentsAtom;
14877 JSAtom *calleeAtom;
14878 JSAtom *callerAtom;
14879 JSAtom *classPrototypeAtom;
14880 JSAtom *constructorAtom;
14883 JSAtom *fileNameAtom;
14885 JSAtom *globalAtom;
14886 JSAtom *ignoreCaseAtom;
14889 JSAtom *toISOStringAtom;
14890 JSAtom *iteratorAtom;
14892 JSAtom *lastIndexAtom;
14893 JSAtom *lengthAtom;
14894 JSAtom *lineNumberAtom;
14895 JSAtom *messageAtom;
14896 JSAtom *multilineAtom;
14899 JSAtom *noSuchMethodAtom;
14900 JSAtom *objectNullAtom;
14901 JSAtom *objectUndefinedAtom;
14904 JSAtom *sourceAtom;
14906 JSAtom *stickyAtom;
14907 JSAtom *toGMTStringAtom;
14908 JSAtom *toLocaleStringAtom;
14909 JSAtom *toSourceAtom;
14910 JSAtom *toStringAtom;
14911 JSAtom *toUTCStringAtom;
14912 JSAtom *valueOfAtom;
14913 JSAtom *toJSONAtom;
14915 JSAtom *enumerableAtom;
14916 JSAtom *configurableAtom;
14917 JSAtom *writableAtom;
14920 JSAtom *useStrictAtom;
14923 JSAtom *InfinityAtom;
14925 JSAtom *builderAtom;
14929 JSAtom *namespaceAtom;
14931 JSAtom *qualifierAtom;
14935 JSAtom *starQualifierAtom;
14940 JSAtom *functionNamespaceURIAtom;
14945 JSAtom *getOwnPropertyDescriptorAtom;
14946 JSAtom *getPropertyDescriptorAtom;
14947 JSAtom *definePropertyAtom;
14948 JSAtom *deleteAtom;
14949 JSAtom *getOwnPropertyNamesAtom;
14950 JSAtom *enumerateAtom;
14954 JSAtom *hasOwnAtom;
14956 JSAtom *iterateAtom;
14960 JSAtom *XMLListAtom;
14961 JSAtom *decodeURIAtom;
14962 JSAtom *decodeURIComponentAtom;
14963 JSAtom *defineGetterAtom;
14964 JSAtom *defineSetterAtom;
14965 JSAtom *encodeURIAtom;
14966 JSAtom *encodeURIComponentAtom;
14967 JSAtom *escapeAtom;
14968 JSAtom *hasOwnPropertyAtom;
14969 JSAtom *isFiniteAtom;
14971 JSAtom *isPrototypeOfAtom;
14972 JSAtom *isXMLNameAtom;
14973 JSAtom *lookupGetterAtom;
14974 JSAtom *lookupSetterAtom;
14975 JSAtom *parseFloatAtom;
14976 JSAtom *parseIntAtom;
14977 JSAtom *propertyIsEnumerableAtom;
14978 JSAtom *unescapeAtom;
14979 JSAtom *unevalAtom;
14980 JSAtom *unwatchAtom;
14985 extern const char *const js_common_atom_names[];
14986 extern const size_t js_common_atom_count;
14988 # 1 "jsproto.tbl" 1
14990 # 1 "jsversion.h" 1
14991 # 40 "jsproto.tbl" 2
14993 extern const char js_Null_str[];
14994 extern const char js_Object_str[];
14995 extern const char js_Function_str[];
14996 extern const char js_Array_str[];
14997 extern const char js_Boolean_str[];
14998 extern const char js_JSON_str[];
14999 extern const char js_Date_str[];
15000 extern const char js_Math_str[];
15001 extern const char js_Number_str[];
15002 extern const char js_String_str[];
15003 extern const char js_RegExp_str[];
15004 extern const char js_XML_str[];
15005 extern const char js_Namespace_str[];
15006 extern const char js_QName_str[];
15007 extern const char js_Reflect_str[];
15008 extern const char js_ASTNode_str[];
15009 extern const char js_Error_str[];
15010 extern const char js_InternalError_str[];
15011 extern const char js_EvalError_str[];
15012 extern const char js_RangeError_str[];
15013 extern const char js_ReferenceError_str[];
15014 extern const char js_SyntaxError_str[];
15015 extern const char js_TypeError_str[];
15016 extern const char js_URIError_str[];
15017 extern const char js_Generator_str[];
15018 extern const char js_Iterator_str[];
15019 extern const char js_StopIteration_str[];
15020 extern const char js_ArrayBuffer_str[];
15021 extern const char js_Int8Array_str[];
15022 extern const char js_Uint8Array_str[];
15023 extern const char js_Int16Array_str[];
15024 extern const char js_Uint16Array_str[];
15025 extern const char js_Int32Array_str[];
15026 extern const char js_Uint32Array_str[];
15027 extern const char js_Float32Array_str[];
15028 extern const char js_Float64Array_str[];
15029 extern const char js_Uint8ClampedArray_str[];
15030 extern const char js_Proxy_str[];
15031 extern const char js_AnyName_str[];
15035 extern const char js_anonymous_str[];
15036 extern const char js_apply_str[];
15037 extern const char js_arguments_str[];
15038 extern const char js_arity_str[];
15039 extern const char js_call_str[];
15040 extern const char js_callee_str[];
15041 extern const char js_caller_str[];
15042 extern const char js_class_prototype_str[];
15043 extern const char js_close_str[];
15044 extern const char js_constructor_str[];
15045 extern const char js_count_str[];
15046 extern const char js_etago_str[];
15047 extern const char js_each_str[];
15048 extern const char js_eval_str[];
15049 extern const char js_fileName_str[];
15050 extern const char js_get_str[];
15051 extern const char js_getter_str[];
15052 extern const char js_global_str[];
15053 extern const char js_ignoreCase_str[];
15054 extern const char js_index_str[];
15055 extern const char js_input_str[];
15056 extern const char js_iterator_str[];
15057 extern const char js_join_str[];
15058 extern const char js_lastIndex_str[];
15059 extern const char js_length_str[];
15060 extern const char js_lineNumber_str[];
15061 extern const char js_message_str[];
15062 extern const char js_multiline_str[];
15063 extern const char js_name_str[];
15064 extern const char js_namespace_str[];
15065 extern const char js_next_str[];
15066 extern const char js_noSuchMethod_str[];
15067 extern const char js_object_str[];
15068 extern const char js_proto_str[];
15069 extern const char js_ptagc_str[];
15070 extern const char js_qualifier_str[];
15071 extern const char js_send_str[];
15072 extern const char js_setter_str[];
15073 extern const char js_set_str[];
15074 extern const char js_source_str[];
15075 extern const char js_space_str[];
15076 extern const char js_stack_str[];
15077 extern const char js_sticky_str[];
15078 extern const char js_stago_str[];
15079 extern const char js_star_str[];
15080 extern const char js_starQualifier_str[];
15081 extern const char js_tagc_str[];
15082 extern const char js_toGMTString_str[];
15083 extern const char js_toLocaleString_str[];
15084 extern const char js_toSource_str[];
15085 extern const char js_toString_str[];
15086 extern const char js_toUTCString_str[];
15087 extern const char js_undefined_str[];
15088 extern const char js_valueOf_str[];
15089 extern const char js_toJSON_str[];
15090 extern const char js_xml_str[];
15091 extern const char js_enumerable_str[];
15092 extern const char js_configurable_str[];
15093 extern const char js_writable_str[];
15094 extern const char js_value_str[];
15095 extern const char js_test_str[];
15103 js_InitAtomState(JSRuntime *rt);
15110 js_FinishAtomState(JSRuntime *rt);
15117 js_TraceAtomState(JSTracer *trc);
15120 js_SweepAtomState(JSContext *cx);
15123 js_InitCommonAtoms(JSContext *cx);
15126 js_FinishCommonAtoms(JSContext *cx);
15133 js_AtomizeString(JSContext *cx, JSString *str, uintN flags);
15136 js_Atomize(JSContext *cx, const char *bytes, size_t length, uintN flags);
15139 js_AtomizeChars(JSContext *cx, const jschar *chars, size_t length, uintN flags);
15146 js_GetExistingStringAtom(JSContext *cx, const jschar *chars, size_t length);
15152 js_ValueToAtom(JSContext *cx, const js::Value &v, JSAtom **atomp);
15158 js_ValueToStringId(JSContext *cx, const js::Value &v, jsid *idp);
15164 js_InternNonIntElementId(JSContext *cx, JSObject *obj, const js::Value &idval,
15170 js_InternNonIntElementId(JSContext *cx, JSObject *obj, const js::Value &idval,
15171 jsid *idp, js::Value *vp);
15178 js_InitAtomMap(JSContext *cx, JSAtomMap *map, JSAtomList *al);
15184 const uintN MIN_SPARSE_INDEX = 256;
15186 inline JSObject::EnsureDenseResult
15187 JSObject::ensureDenseArrayElements(JSContext *cx, uintN index, uintN extra)
15190 uintN currentCapacity = numSlots();
15192 uintN requiredCapacity;
15195 if (index < currentCapacity)
15197 requiredCapacity = index + 1;
15198 if (requiredCapacity == 0) {
15203 requiredCapacity = index + extra;
15204 if (requiredCapacity < index) {
15208 if (requiredCapacity <= currentCapacity)
15216 if (requiredCapacity > MIN_SPARSE_INDEX &&
15217 willBeSparseDenseArray(requiredCapacity, extra)) {
15220 return growSlots(cx, requiredCapacity) ? ED_OK : ED_FAILED;
15227 js_StringIsIndex(JSLinearString *str, jsuint *indexp);
15230 js_IdIsIndex(jsid id, jsuint *indexp)
15232 if (JSID_IS_INT(id)) {
15234 i = JSID_TO_INT(id);
15237 *indexp = (jsuint)i;
15241 if ((__builtin_expect((!JSID_IS_STRING(id)), 0)))
15244 return js_StringIsIndex(JSID_TO_ATOM(id), indexp);
15252 js_IdValIsIndex(JSContext *cx, jsval id, jsuint *indexp, bool *isIndex)
15254 if (JSVAL_IS_INT(id)) {
15256 i = JSVAL_TO_INT(id);
15261 *indexp = (jsuint)i;
15266 if (!JSVAL_IS_STRING(id)) {
15271 JSLinearString *str = JSVAL_TO_STRING(id)->ensureLinear(cx);
15275 *isIndex = js_StringIsIndex(str, indexp);
15279 extern js::Class js_ArrayClass, js_SlowArrayClass;
15285 JSObject::isDenseArray() const
15287 return getClass() == &js_ArrayClass;
15294 JSObject::isSlowArray() const
15296 return getClass() == &js_SlowArrayClass;
15303 JSObject::isArray() const
15305 return isDenseArray() || isSlowArray();
15308 static inline JSObject *
15309 js_GetProtoIfDenseArray(JSObject *obj)
15311 return obj->isDenseArray() ? obj->getProto() : obj;
15315 js_InitArrayClass(JSContext *cx, JSObject *obj);
15321 js_InitContextBusyArrayTable(JSContext *cx);
15328 NewDenseEmptyArray(JSContext *cx, JSObject *proto=__null);
15332 NewDenseAllocatedArray(JSContext *cx, uint length, JSObject *proto=__null);
15339 NewDenseUnallocatedArray(JSContext *cx, uint length, JSObject *proto=__null);
15343 NewDenseCopiedArray(JSContext *cx, uint length, Value *vp, JSObject *proto=__null);
15347 NewSlowEmptyArray(JSContext *cx);
15352 js_GetLengthProperty(JSContext *cx, JSObject *obj, jsuint *lengthp);
15355 js_SetLengthProperty(JSContext *cx, JSObject *obj, jsdouble length);
15358 js_HasLengthProperty(JSContext *cx, JSObject *obj, jsuint *lengthp);
15361 js_IndexToId(JSContext *cx, jsuint index, jsid *idp);
15373 GetElements(JSContext *cx, JSObject *aobj, jsuint length, js::Value *vp);
15380 typedef JSBool (*JSComparator)(void *arg, const void *a, const void *b,
15383 enum JSMergeSortElemType {
15392 js_MergeSort(void *vec, size_t nel, size_t elsize, JSComparator cmp,
15393 void *arg, void *tmp, JSMergeSortElemType elemType);
15401 array_sort(JSContext *cx, uintN argc, js::Value *vp);
15410 js_ArrayCompPush(JSContext *cx, JSObject *obj, const js::Value &vp);
15412 __attribute__((visibility ("default"))) JSBool
15413 js_CoerceArrayToCanvasImageData(JSObject *obj, jsuint offset, jsuint count,
15417 js_PrototypeHasIndexedProperties(JSContext *cx, JSObject *obj);
15423 js_GetDenseArrayElementValue(JSContext *cx, JSObject *obj, jsid id,
15428 js_Array(JSContext *cx, uintN argc, js::Value *vp);
15430 __attribute__((visibility ("default"))) JSBool
15431 js_CloneDensePrimitiveArray(JSContext *cx, JSObject *obj, JSObject **clone);
15437 __attribute__((visibility ("default"))) JSBool
15438 js_IsDensePrimitiveArray(JSObject *obj);
15441 js_EnsureDenseArrayCapacity(JSContext *cx, JSObject *obj, jsint i);
15446 extern js::Class js_BooleanClass;
15452 JSObject::isBoolean() const
15454 return getClass() == &js_BooleanClass;
15458 js_InitBooleanClass(JSContext *cx, JSObject *obj);
15461 js_BooleanToString(JSContext *cx, JSBool b);
15469 BooleanToStringBuffer(JSContext *cx, JSBool b, StringBuffer &sb);
15474 js_ValueToBoolean(const js::Value &v);
15482 typedef struct JSArena JSArena;
15483 typedef struct JSArenaPool JSArenaPool;
15492 struct JSArenaPool {
15504 extern __attribute__((visibility ("default"))) void
15505 JS_InitArenaPool(JSArenaPool *pool, const char *name, size_t size,
15506 size_t align, size_t *quotap);
15513 extern __attribute__((visibility ("default"))) void
15514 JS_FreeArenaPool(JSArenaPool *pool);
15519 extern __attribute__((visibility ("default"))) void
15520 JS_FinishArenaPool(JSArenaPool *pool);
15525 extern __attribute__((visibility ("default"))) void
15526 JS_ArenaFinish(void);
15531 extern __attribute__((visibility ("default"))) void
15532 JS_ArenaShutDown(void);
15537 extern __attribute__((visibility ("default"))) void *
15538 JS_ArenaAllocate(JSArenaPool *pool, size_t nb);
15540 extern __attribute__((visibility ("default"))) void *
15541 JS_ArenaRealloc(JSArenaPool *pool, void *p, size_t size, size_t incr);
15543 extern __attribute__((visibility ("default"))) void *
15544 JS_ArenaGrow(JSArenaPool *pool, void *p, size_t size, size_t incr);
15546 extern __attribute__((visibility ("default"))) void
15547 JS_ArenaRelease(JSArenaPool *pool, char *mark);
15553 typedef struct JSCListStr {
15554 struct JSCListStr *next;
15555 struct JSCListStr *prev;
15564 typedef uint32 JSDHashNumber;
15565 typedef struct JSDHashEntryHdr JSDHashEntryHdr;
15566 typedef struct JSDHashEntryStub JSDHashEntryStub;
15567 typedef struct JSDHashTable JSDHashTable;
15568 typedef struct JSDHashTableOps JSDHashTableOps;
15570 struct JSDHashEntryHdr {
15571 JSDHashNumber keyHash;
15574 struct JSDHashTable {
15575 const JSDHashTableOps *ops;
15578 uint8 maxAlphaFrac;
15579 uint8 minAlphaFrac;
15582 uint32 removedCount;
15589 (* JSDHashAllocTable)(JSDHashTable *table, uint32 nbytes);
15592 (* JSDHashFreeTable) (JSDHashTable *table, void *ptr);
15598 typedef JSDHashNumber
15599 (* JSDHashHashKey) (JSDHashTable *table, const void *key);
15606 (* JSDHashMatchEntry)(JSDHashTable *table, const JSDHashEntryHdr *entry,
15616 (* JSDHashMoveEntry)(JSDHashTable *table, const JSDHashEntryHdr *from,
15617 JSDHashEntryHdr *to);
15625 (* JSDHashClearEntry)(JSDHashTable *table, JSDHashEntryHdr *entry);
15633 (* JSDHashFinalize) (JSDHashTable *table);
15636 (* JSDHashInitEntry)(JSDHashTable *table, JSDHashEntryHdr *entry,
15639 struct JSDHashTableOps {
15641 JSDHashAllocTable allocTable;
15642 JSDHashFreeTable freeTable;
15643 JSDHashHashKey hashKey;
15644 JSDHashMatchEntry matchEntry;
15645 JSDHashMoveEntry moveEntry;
15646 JSDHashClearEntry clearEntry;
15647 JSDHashFinalize finalize;
15650 JSDHashInitEntry initEntry;
15656 extern __attribute__((visibility ("default"))) void *
15657 JS_DHashAllocTable(JSDHashTable *table, uint32 nbytes);
15659 extern __attribute__((visibility ("default"))) void
15660 JS_DHashFreeTable(JSDHashTable *table, void *ptr);
15662 extern __attribute__((visibility ("default"))) JSDHashNumber
15663 JS_DHashStringKey(JSDHashTable *table, const void *key);
15666 struct JSDHashEntryStub {
15667 JSDHashEntryHdr hdr;
15671 extern __attribute__((visibility ("default"))) JSDHashNumber
15672 JS_DHashVoidPtrKeyStub(JSDHashTable *table, const void *key);
15674 extern __attribute__((visibility ("default"))) JSBool
15675 JS_DHashMatchEntryStub(JSDHashTable *table,
15676 const JSDHashEntryHdr *entry,
15679 extern __attribute__((visibility ("default"))) JSBool
15680 JS_DHashMatchStringKey(JSDHashTable *table,
15681 const JSDHashEntryHdr *entry,
15684 extern __attribute__((visibility ("default"))) void
15685 JS_DHashMoveEntryStub(JSDHashTable *table,
15686 const JSDHashEntryHdr *from,
15687 JSDHashEntryHdr *to);
15689 extern __attribute__((visibility ("default"))) void
15690 JS_DHashClearEntryStub(JSDHashTable *table, JSDHashEntryHdr *entry);
15692 extern __attribute__((visibility ("default"))) void
15693 JS_DHashFreeStringKey(JSDHashTable *table, JSDHashEntryHdr *entry);
15695 extern __attribute__((visibility ("default"))) void
15696 JS_DHashFinalizeStub(JSDHashTable *table);
15703 extern __attribute__((visibility ("default"))) const JSDHashTableOps *
15704 JS_DHashGetStubOps(void);
15712 extern __attribute__((visibility ("default"))) JSDHashTable *
15713 JS_NewDHashTable(const JSDHashTableOps *ops, void *data, uint32 entrySize,
15720 extern __attribute__((visibility ("default"))) void
15721 JS_DHashTableDestroy(JSDHashTable *table);
15729 extern __attribute__((visibility ("default"))) JSBool
15730 JS_DHashTableInit(JSDHashTable *table, const JSDHashTableOps *ops, void *data,
15731 uint32 entrySize, uint32 capacity);
15733 extern __attribute__((visibility ("default"))) void
15734 JS_DHashTableSetAlphaBounds(JSDHashTable *table,
15738 extern __attribute__((visibility ("default"))) void
15739 JS_DHashTableFinish(JSDHashTable *table);
15747 typedef enum JSDHashOperator {
15748 JS_DHASH_LOOKUP = 0,
15750 JS_DHASH_REMOVE = 2,
15755 extern __attribute__((visibility ("default"))) JSDHashEntryHdr *
15756 JS_DHashTableOperate(JSDHashTable *table, const void *key, JSDHashOperator op);
15758 extern __attribute__((visibility ("default"))) void
15759 JS_DHashTableRawRemove(JSDHashTable *table, JSDHashEntryHdr *entry);
15761 typedef JSDHashOperator
15762 (* JSDHashEnumerator)(JSDHashTable *table, JSDHashEntryHdr *hdr, uint32 number,
15765 extern __attribute__((visibility ("default"))) uint32
15766 JS_DHashTableEnumerate(JSDHashTable *table, JSDHashEnumerator etor, void *arg);
15780 js_DestroyDtoaState(DtoaState *state);
15783 js_strtod_harder(DtoaState *state, const char *s00, char **se, int *err);
15785 typedef enum JSDToStrMode {
15787 DTOSTR_STANDARD_EXPONENTIAL,
15789 DTOSTR_EXPONENTIAL,
15794 js_dtostr(DtoaState *state, char *buffer, size_t bufferSize, JSDToStrMode mode, int precision,
15798 js_dtobasestr(DtoaState *state, int base, double d);
15810 # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4
15811 # 46 "jsopcode.h" 2
15818 typedef enum JSOp {
15821 # 1 "jsopcode.tbl" 1
15822 # 113 "jsopcode.tbl"
15828 JSOP_ENTERWITH = 3,
15829 JSOP_LEAVEWITH = 4,
15836 JSOP_ARGUMENTS = 9,
15840 JSOP_FORLOCAL = 11,
15845 JSOP_SETCONST = 14,
15890 JSOP_CALLNAME = 57,
15905 JSOP_TABLESWITCH = 70,
15906 JSOP_LOOKUPSWITCH = 71,
15909 JSOP_STRICTEQ = 72,
15910 JSOP_STRICTNE = 73,
15917 # 220 "jsopcode.tbl"
15919 JSOP_MOREITER = 76,
15922 JSOP_FUNAPPLY = 78,
15940 JSOP_GETLOCAL = 86,
15941 JSOP_SETLOCAL = 87,
15945 # 256 "jsopcode.tbl"
15947 JSOP_NEWARRAY = 90,
15948 JSOP_NEWOBJECT = 91,
15950 JSOP_INITPROP = 93,
15951 JSOP_INITELEM = 94,
15952 JSOP_DEFSHARP = 95,
15953 JSOP_USESHARP = 96,
15961 JSOP_INCLOCAL = 101,
15962 JSOP_DECLOCAL = 102,
15963 JSOP_LOCALINC = 103,
15964 JSOP_LOCALDEC = 104,
15969 JSOP_FORNAME = 106,
15970 JSOP_FORPROP = 107,
15971 JSOP_FORELEM = 108,
15975 JSOP_BINDNAME = 110,
15976 JSOP_SETNAME = 111,
15983 JSOP_INSTANCEOF = 114,
15986 JSOP_DEBUGGER = 115,
15993 JSOP_EXCEPTION = 118,
16003 JSOP_CONDSWITCH = 120,
16005 JSOP_DEFAULT = 122,
16015 JSOP_ENUMELEM = 124,
16029 JSOP_DEFCONST = 128,
16042 JSOP_SETLOCALPOP = 132,
16052 JSOP_FINALLY = 135,
16060 JSOP_GETFCSLOT = 136,
16061 JSOP_CALLFCSLOT = 137,
16076 JSOP_DEFLOCALFUN = 140,
16086 JSOP_DEFAULTX = 148,
16087 JSOP_TABLESWITCHX = 149,
16088 JSOP_LOOKUPSWITCHX = 150,
16091 JSOP_BACKPATCH = 151,
16092 JSOP_BACKPATCH_POP = 152,
16095 JSOP_THROWING = 153,
16098 JSOP_SETRVAL = 154,
16099 JSOP_RETRVAL = 155,
16102 JSOP_GETGNAME = 156,
16103 JSOP_SETGNAME = 157,
16104 JSOP_INCGNAME = 158,
16105 JSOP_DECGNAME = 159,
16106 JSOP_GNAMEINC = 160,
16107 JSOP_GNAMEDEC = 161,
16113 JSOP_DEFXMLNS = 163,
16114 JSOP_ANYNAME = 164,
16115 JSOP_QNAMEPART = 165,
16116 JSOP_QNAMECONST = 166,
16118 JSOP_TOATTRNAME = 168,
16119 JSOP_TOATTRVAL = 169,
16120 JSOP_ADDATTRNAME = 170,
16121 JSOP_ADDATTRVAL = 171,
16122 JSOP_BINDXMLNAME = 172,
16123 JSOP_SETXMLNAME = 173,
16124 JSOP_XMLNAME = 174,
16125 JSOP_DESCENDANTS = 175,
16127 JSOP_ENDFILTER = 177,
16129 JSOP_TOXMLLIST = 179,
16130 JSOP_XMLTAGEXPR = 180,
16131 JSOP_XMLELTEXPR = 181,
16132 JSOP_NOTRACE = 182,
16133 JSOP_XMLCDATA = 183,
16134 JSOP_XMLCOMMENT = 184,
16136 JSOP_DELDESC = 186,
16138 JSOP_CALLPROP = 187,
16139 # 457 "jsopcode.tbl"
16140 JSOP_BLOCKCHAIN = 188,
16141 JSOP_NULLBLOCKCHAIN = 189,
16154 JSOP_INDEXBASE = 191,
16155 JSOP_RESETBASE = 192,
16156 JSOP_RESETBASE0 = 193,
16161 JSOP_STARTXML = 194,
16162 JSOP_STARTXMLEXPR = 195,
16164 JSOP_CALLELEM = 196,
16176 JSOP_GETXPROP = 198,
16178 JSOP_CALLXMLNAME = 199,
16183 JSOP_TYPEOFEXPR = 200,
16188 JSOP_ENTERBLOCK = 201,
16189 JSOP_LEAVEBLOCK = 202,
16192 JSOP_IFPRIMTOP = 203,
16195 JSOP_PRIMTOP = 204,
16200 JSOP_GENERATOR = 205,
16202 JSOP_ARRAYPUSH = 207,
16207 JSOP_GETFUNNS = 208,
16212 JSOP_ENUMCONSTELEM = 209,
16218 JSOP_LEAVEBLOCKEXPR = 210,
16223 JSOP_GETTHISPROP = 211,
16224 JSOP_GETARGPROP = 212,
16225 JSOP_GETLOCALPROP = 213,
16231 JSOP_INDEXBASE1 = 214,
16232 JSOP_INDEXBASE2 = 215,
16233 JSOP_INDEXBASE3 = 216,
16235 JSOP_CALLGNAME = 217,
16236 JSOP_CALLLOCAL = 218,
16237 JSOP_CALLARG = 219,
16238 JSOP_BINDGNAME = 220,
16261 JSOP_DEFFUN_FC = 225,
16262 JSOP_DEFLOCALFUN_FC = 226,
16263 JSOP_LAMBDA_FC = 227,
16278 JSOP_GETUPVAR_DBG = 230,
16279 JSOP_CALLUPVAR_DBG = 231,
16280 JSOP_DEFFUN_DBGFC = 232,
16281 JSOP_DEFLOCALFUN_DBGFC = 233,
16282 JSOP_LAMBDA_DBGFC = 234,
16287 JSOP_SETMETHOD = 235,
16288 JSOP_INITMETHOD = 236,
16289 JSOP_UNBRAND = 237,
16290 JSOP_UNBRANDTHIS = 238,
16292 JSOP_SHARPINIT = 239,
16295 JSOP_GETGLOBAL = 240,
16296 JSOP_CALLGLOBAL = 241,
16299 JSOP_FUNCALL = 242,
16301 JSOP_FORGNAME = 243,
16302 # 63 "jsopcode.h" 2
16311 JSOP_GETPROP2 = JSOP_LIMIT,
16312 JSOP_GETELEM2 = JSOP_LIMIT + 1,
16313 JSOP_FAKE_LIMIT = JSOP_GETELEM2
16316 struct JSCodeSpec {
16324 uint32 type() const { return ((format) & 0x001f); }
16328 extern const JSCodeSpec js_CodeSpec[];
16329 extern uintN js_NumCodeSpecs;
16330 extern const char *js_CodeName[];
16331 extern const char js_EscapeMap[];
16334 js_QuoteString(JSContext *cx, JSString *str, jschar quote);
16337 js_NewPrinter(JSContext *cx, const char *name, JSFunction *fun,
16338 uintN indent, JSBool pretty, JSBool grouped, JSBool strict);
16341 js_DestroyPrinter(JSPrinter *jp);
16344 js_GetPrinterOutput(JSPrinter *jp);
16347 js_printf(JSPrinter *jp, const char *format, ...);
16350 js_puts(JSPrinter *jp, const char *s);
16353 js_GetIndexFromBytecode(JSContext *cx, JSScript *script, jsbytecode *pc,
16357 js_GetVariableBytecodeLength(jsbytecode *pc);
16364 js_GetVariableStackUses(JSOp op, jsbytecode *pc);
16371 js_GetEnterBlockStackDefs(JSContext *cx, JSScript *script, jsbytecode *pc);
16374 static inline uintN
16375 js_GetStackUses(const JSCodeSpec *cs, JSOp op, jsbytecode *pc)
16378 if (cs->nuses >= 0)
16380 return js_GetVariableStackUses(op, pc);
16383 static inline uintN
16384 js_GetStackDefs(JSContext *cx, const JSCodeSpec *cs, JSOp op, JSScript *script,
16388 if (cs->ndefs >= 0)
16393 return js_GetEnterBlockStackDefs(cx, script, pc);
16397 js_DecompileScript(JSPrinter *jp, JSScript *script);
16400 js_DecompileFunctionBody(JSPrinter *jp);
16403 js_DecompileFunction(JSPrinter *jp);
16405 typedef JSBool (* JSDecompilerPtr)(JSPrinter *);
16408 js_DecompileToString(JSContext *cx, const char *name, JSFunction *fun,
16409 uintN indent, JSBool pretty, JSBool grouped, JSBool strict,
16410 JSDecompilerPtr decompiler);
16413 js_DecompileValueGenerator(JSContext *cx, intN spindex, jsval v,
16414 JSString *fallback);
16422 static inline char *
16423 DecompileValueGenerator(JSContext *cx, intN spindex, const Value &v,
16424 JSString *fallback)
16426 return js_DecompileValueGenerator(cx, spindex, Jsvalify(v), fallback);
16437 js_ReconstructStackDepth(JSContext *cx, JSScript *script, jsbytecode *pc);
16444 # 48 "jsdbgapi.h" 2
16449 extern __attribute__((visibility ("default"))) JSCrossCompartmentCall *
16450 JS_EnterCrossCompartmentCallScript(JSContext *cx, JSScript *target);
16457 class __attribute__((visibility ("default"))) AutoEnterScriptCompartment
16459 JSCrossCompartmentCall *call;
16462 AutoEnterScriptCompartment() : call(__null) {}
16464 bool enter(JSContext *cx, JSScript *target);
16466 bool entered() const { return call != __null; }
16468 ~AutoEnterScriptCompartment() {
16469 if (call && call != reinterpret_cast<JSCrossCompartmentCall*>(1))
16470 JS_LeaveCrossCompartmentCall(call);
16479 extern __attribute__((visibility ("default"))) JSScript *
16480 JS_GetScriptFromObject(JSObject *scriptObject);
16482 extern __attribute__((visibility ("default"))) JSString *
16483 JS_DecompileScript(JSContext *cx, JSScript *script, const char *name, uintN indent);
16489 extern __attribute__((visibility ("default"))) void
16490 JS_SetRuntimeDebugMode(JSRuntime *rt, JSBool debug);
16492 extern __attribute__((visibility ("default"))) JSBool
16493 JS_GetDebugMode(JSContext *cx);
16500 __attribute__((visibility ("default"))) JSBool
16501 JS_SetDebugModeForCompartment(JSContext *cx, JSCompartment *comp, JSBool debug);
16506 __attribute__((visibility ("default"))) JSBool
16507 JS_SetDebugMode(JSContext *cx, JSBool debug);
16510 extern __attribute__((visibility ("default"))) JSBool
16511 js_SetSingleStepMode(JSContext *cx, JSScript *script, JSBool singleStep);
16514 extern __attribute__((visibility ("default"))) JSBool
16515 JS_SetSingleStepMode(JSContext *cx, JSScript *script, JSBool singleStep);
16522 extern jsbytecode *
16523 js_UntrapScriptCode(JSContext *cx, JSScript *script);
16526 extern __attribute__((visibility ("default"))) JSBool
16527 JS_SetTrap(JSContext *cx, JSScript *script, jsbytecode *pc,
16528 JSTrapHandler handler, jsval closure);
16530 extern __attribute__((visibility ("default"))) JSOp
16531 JS_GetTrapOpcode(JSContext *cx, JSScript *script, jsbytecode *pc);
16533 extern __attribute__((visibility ("default"))) void
16534 JS_ClearTrap(JSContext *cx, JSScript *script, jsbytecode *pc,
16535 JSTrapHandler *handlerp, jsval *closurep);
16537 extern __attribute__((visibility ("default"))) void
16538 JS_ClearScriptTraps(JSContext *cx, JSScript *script);
16540 extern __attribute__((visibility ("default"))) void
16541 JS_ClearAllTraps(JSContext *cx);
16543 extern __attribute__((visibility ("default"))) JSTrapStatus
16544 JS_HandleTrap(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval);
16546 extern __attribute__((visibility ("default"))) JSBool
16547 JS_SetInterrupt(JSRuntime *rt, JSInterruptHook handler, void *closure);
16549 extern __attribute__((visibility ("default"))) JSBool
16550 JS_ClearInterrupt(JSRuntime *rt, JSInterruptHook *handlerp, void **closurep);
16554 extern __attribute__((visibility ("default"))) JSBool
16555 JS_SetWatchPoint(JSContext *cx, JSObject *obj, jsid id,
16556 JSWatchPointHandler handler, JSObject *closure);
16558 extern __attribute__((visibility ("default"))) JSBool
16559 JS_ClearWatchPoint(JSContext *cx, JSObject *obj, jsid id,
16560 JSWatchPointHandler *handlerp, JSObject **closurep);
16562 extern __attribute__((visibility ("default"))) JSBool
16563 JS_ClearWatchPointsForObject(JSContext *cx, JSObject *obj);
16565 extern __attribute__((visibility ("default"))) JSBool
16566 JS_ClearAllWatchPoints(JSContext *cx);
16574 js_TraceWatchPoints(JSTracer *trc, JSObject *obj);
16577 js_SweepWatchPoints(JSContext *cx);
16582 js_watch_set(JSContext *cx, JSObject *obj, jsid id, JSBool strict, js::Value *vp);
16589 IsWatchedProperty(JSContext *cx, const Shape *shape);
16599 extern __attribute__((visibility ("default"))) uintN
16600 JS_PCToLineNumber(JSContext *cx, JSScript *script, jsbytecode *pc);
16602 extern __attribute__((visibility ("default"))) jsbytecode *
16603 JS_LineNumberToPC(JSContext *cx, JSScript *script, uintN lineno);
16605 extern __attribute__((visibility ("default"))) jsbytecode *
16606 JS_EndPC(JSContext *cx, JSScript *script);
16608 extern __attribute__((visibility ("default"))) uintN
16609 JS_GetFunctionArgumentCount(JSContext *cx, JSFunction *fun);
16611 extern __attribute__((visibility ("default"))) JSBool
16612 JS_FunctionHasLocalNames(JSContext *cx, JSFunction *fun);
16619 extern __attribute__((visibility ("default"))) jsuword *
16620 JS_GetFunctionLocalNameArray(JSContext *cx, JSFunction *fun, void **markp);
16622 extern __attribute__((visibility ("default"))) JSAtom *
16623 JS_LocalNameToAtom(jsuword w);
16625 extern __attribute__((visibility ("default"))) JSString *
16626 JS_AtomKey(JSAtom *atom);
16628 extern __attribute__((visibility ("default"))) void
16629 JS_ReleaseFunctionLocalNameArray(JSContext *cx, void *mark);
16631 extern __attribute__((visibility ("default"))) JSScript *
16632 JS_GetFunctionScript(JSContext *cx, JSFunction *fun);
16634 extern __attribute__((visibility ("default"))) JSNative
16635 JS_GetFunctionNative(JSContext *cx, JSFunction *fun);
16637 extern __attribute__((visibility ("default"))) JSPrincipals *
16638 JS_GetScriptPrincipals(JSContext *cx, JSScript *script);
16640 extern __attribute__((visibility ("default"))) JSStackFrame *
16641 JS_FrameIterator(JSContext *cx, JSStackFrame **iteratorp);
16643 extern __attribute__((visibility ("default"))) JSScript *
16644 JS_GetFrameScript(JSContext *cx, JSStackFrame *fp);
16646 extern __attribute__((visibility ("default"))) jsbytecode *
16647 JS_GetFramePC(JSContext *cx, JSStackFrame *fp);
16652 extern __attribute__((visibility ("default"))) JSStackFrame *
16653 JS_GetScriptedCaller(JSContext *cx, JSStackFrame *fp);
16659 extern JSPrincipals *
16660 js_StackFramePrincipals(JSContext *cx, JSStackFrame *fp);
16663 js_EvalFramePrincipals(JSContext *cx, JSObject *callee, JSStackFrame *caller);
16665 extern __attribute__((visibility ("default"))) void *
16666 JS_GetFrameAnnotation(JSContext *cx, JSStackFrame *fp);
16668 extern __attribute__((visibility ("default"))) void
16669 JS_SetFrameAnnotation(JSContext *cx, JSStackFrame *fp, void *annotation);
16671 extern __attribute__((visibility ("default"))) void *
16672 JS_GetFramePrincipalArray(JSContext *cx, JSStackFrame *fp);
16674 extern __attribute__((visibility ("default"))) JSBool
16675 JS_IsScriptFrame(JSContext *cx, JSStackFrame *fp);
16678 extern __attribute__((visibility ("default"))) JSObject *
16679 JS_GetFrameObject(JSContext *cx, JSStackFrame *fp);
16681 extern __attribute__((visibility ("default"))) JSObject *
16682 JS_GetFrameScopeChain(JSContext *cx, JSStackFrame *fp);
16684 extern __attribute__((visibility ("default"))) JSObject *
16685 JS_GetFrameCallObject(JSContext *cx, JSStackFrame *fp);
16687 extern __attribute__((visibility ("default"))) JSBool
16688 JS_GetFrameThis(JSContext *cx, JSStackFrame *fp, jsval *thisv);
16690 extern __attribute__((visibility ("default"))) JSFunction *
16691 JS_GetFrameFunction(JSContext *cx, JSStackFrame *fp);
16693 extern __attribute__((visibility ("default"))) JSObject *
16694 JS_GetFrameFunctionObject(JSContext *cx, JSStackFrame *fp);
16698 extern __attribute__((visibility ("default"))) JSBool
16699 JS_IsConstructorFrame(JSContext *cx, JSStackFrame *fp);
16701 extern __attribute__((visibility ("default"))) JSBool
16702 JS_IsDebuggerFrame(JSContext *cx, JSStackFrame *fp);
16704 extern __attribute__((visibility ("default"))) jsval
16705 JS_GetFrameReturnValue(JSContext *cx, JSStackFrame *fp);
16707 extern __attribute__((visibility ("default"))) void
16708 JS_SetFrameReturnValue(JSContext *cx, JSStackFrame *fp, jsval rval);
16710 extern __attribute__((visibility ("default"))) JSObject *
16711 JS_GetFrameCalleeObject(JSContext *cx, JSStackFrame *fp);
16718 extern __attribute__((visibility ("default"))) JSBool
16719 JS_GetValidFrameCalleeObject(JSContext *cx, JSStackFrame *fp, jsval *vp);
16723 extern __attribute__((visibility ("default"))) const char *
16724 JS_GetScriptFilename(JSContext *cx, JSScript *script);
16726 extern __attribute__((visibility ("default"))) uintN
16727 JS_GetScriptBaseLineNumber(JSContext *cx, JSScript *script);
16729 extern __attribute__((visibility ("default"))) uintN
16730 JS_GetScriptLineExtent(JSContext *cx, JSScript *script);
16732 extern __attribute__((visibility ("default"))) JSVersion
16733 JS_GetScriptVersion(JSContext *cx, JSScript *script);
16735 extern __attribute__((visibility ("default"))) void
16736 JS_SetNewScriptHookProc(JSRuntime *rt, JSNewScriptHook hook, void *callerdata);
16738 extern __attribute__((visibility ("default"))) void
16739 JS_SetDestroyScriptHookProc(JSRuntime *rt, JSDestroyScriptHook hook,
16744 extern __attribute__((visibility ("default"))) JSBool
16745 JS_EvaluateUCInStackFrame(JSContext *cx, JSStackFrame *fp,
16746 const jschar *chars, uintN length,
16747 const char *filename, uintN lineno,
16750 extern __attribute__((visibility ("default"))) JSBool
16751 JS_EvaluateInStackFrame(JSContext *cx, JSStackFrame *fp,
16752 const char *bytes, uintN length,
16753 const char *filename, uintN lineno,
16758 typedef struct JSPropertyDesc {
16767 typedef struct JSPropertyDescArray {
16769 JSPropertyDesc *array;
16770 } JSPropertyDescArray;
16772 typedef struct JSScopeProperty JSScopeProperty;
16774 extern __attribute__((visibility ("default"))) JSScopeProperty *
16775 JS_PropertyIterator(JSObject *obj, JSScopeProperty **iteratorp);
16777 extern __attribute__((visibility ("default"))) JSBool
16778 JS_GetPropertyDesc(JSContext *cx, JSObject *obj, JSScopeProperty *shape,
16779 JSPropertyDesc *pd);
16781 extern __attribute__((visibility ("default"))) JSBool
16782 JS_GetPropertyDescArray(JSContext *cx, JSObject *obj, JSPropertyDescArray *pda);
16784 extern __attribute__((visibility ("default"))) void
16785 JS_PutPropertyDescArray(JSContext *cx, JSPropertyDescArray *pda);
16789 extern __attribute__((visibility ("default"))) JSBool
16790 JS_SetDebuggerHandler(JSRuntime *rt, JSDebuggerHandler hook, void *closure);
16792 extern __attribute__((visibility ("default"))) JSBool
16793 JS_SetSourceHandler(JSRuntime *rt, JSSourceHandler handler, void *closure);
16795 extern __attribute__((visibility ("default"))) JSBool
16796 JS_SetExecuteHook(JSRuntime *rt, JSInterpreterHook hook, void *closure);
16798 extern __attribute__((visibility ("default"))) JSBool
16799 JS_SetCallHook(JSRuntime *rt, JSInterpreterHook hook, void *closure);
16801 extern __attribute__((visibility ("default"))) JSBool
16802 JS_SetThrowHook(JSRuntime *rt, JSThrowHook hook, void *closure);
16804 extern __attribute__((visibility ("default"))) JSBool
16805 JS_SetDebugErrorHook(JSRuntime *rt, JSDebugErrorHook hook, void *closure);
16809 extern __attribute__((visibility ("default"))) size_t
16810 JS_GetObjectTotalSize(JSContext *cx, JSObject *obj);
16812 extern __attribute__((visibility ("default"))) size_t
16813 JS_GetFunctionTotalSize(JSContext *cx, JSFunction *fun);
16815 extern __attribute__((visibility ("default"))) size_t
16816 JS_GetScriptTotalSize(JSContext *cx, JSScript *script);
16823 extern __attribute__((visibility ("default"))) uint32
16824 JS_GetTopScriptFilenameFlags(JSContext *cx, JSStackFrame *fp);
16830 extern __attribute__((visibility ("default"))) uint32
16831 JS_GetScriptFilenameFlags(JSScript *script);
16833 extern __attribute__((visibility ("default"))) JSBool
16834 JS_FlagScriptFilenamePrefix(JSRuntime *rt, const char *prefix, uint32 flags);
16836 extern __attribute__((visibility ("default"))) JSBool
16837 JS_IsSystemObject(JSContext *cx, JSObject *obj);
16844 extern __attribute__((visibility ("default"))) JSBool
16845 JS_MakeSystemObject(JSContext *cx, JSObject *obj);
16849 extern __attribute__((visibility ("default"))) JSObject *
16850 JS_UnwrapObject(JSContext *cx, JSObject *obj);
16854 extern __attribute__((visibility ("default"))) void
16855 js_RevertVersion(JSContext *cx);
16857 extern __attribute__((visibility ("default"))) const JSDebugHooks *
16858 JS_GetGlobalDebugHooks(JSRuntime *rt);
16860 extern __attribute__((visibility ("default"))) JSDebugHooks *
16861 JS_SetContextDebugHooks(JSContext *cx, const JSDebugHooks *hooks);
16864 extern __attribute__((visibility ("default"))) JSDebugHooks *
16865 JS_ClearContextDebugHooks(JSContext *cx);
16867 extern __attribute__((visibility ("default"))) JSBool
16868 JS_StartProfiling();
16870 extern __attribute__((visibility ("default"))) void
16871 JS_StopProfiling();
16873 extern __attribute__((visibility ("default"))) JSBool
16874 JS_DefineProfilingFunctions(JSContext *cx, JSObject *obj);
16877 # 49 "jsscript.h" 2
16884 typedef enum JSTryNoteKind {
16896 static const uint32 FREE_VALUE = 0xfffffffful;
16898 void checkInvariants() {
16899 typedef int js_static_assert47[(sizeof(UpvarCookie) == sizeof(uint32)) ? 1 : -1];
16900 typedef int js_static_assert48[(UPVAR_LEVEL_LIMIT < FREE_LEVEL) ? 1 : -1];
16908 static const uint16 FREE_LEVEL = 0x3fff;
16914 static const uint16 UPVAR_LEVEL_LIMIT = 16;
16915 static const uint16 CALLEE_SLOT = 0xffff;
16916 static bool isLevelReserved(uint16 level) { return level >= FREE_LEVEL; }
16918 bool isFree() const { return value == FREE_VALUE; }
16919 uint32 asInteger() const { return value; }
16921 uint16 level() const { ((void) 0); return uint16(value >> 16); }
16922 uint16 slot() const { ((void) 0); return uint16(value); }
16924 void set(const UpvarCookie &other) { set(other.level(), other.slot()); }
16925 void set(uint16 newLevel, uint16 newSlot) { value = (uint32(newLevel) << 16) | newSlot; }
16926 void makeFree() { set(0xffff, 0xffff); ((void) 0); }
16927 void fromInteger(uint32 u32) { value = u32; }
16944 typedef struct JSTryNoteArray {
16949 typedef struct JSObjectArray {
16954 typedef struct JSUpvarArray {
16955 js::UpvarCookie *vector;
16959 typedef struct JSConstArray {
16964 struct JSArenaPool;
16968 struct GlobalSlotArray {
16979 enum BindingKind { NONE, ARGUMENT, VARIABLE, CONSTANT, UPVAR };
16988 js::Shape *lastBinding;
16994 inline Bindings(JSContext *cx);
17001 inline void transfer(JSContext *cx, Bindings *bindings);
17008 inline void clone(JSContext *cx, Bindings *bindings);
17010 uint16 countArgs() const { return nargs; }
17011 uint16 countVars() const { return nvars; }
17012 uint16 countUpvars() const { return nupvars; }
17014 uintN countArgsAndVars() const { return nargs + nvars; }
17016 uintN countLocalNames() const { return nargs + nvars + nupvars; }
17018 bool hasUpvars() const { return nupvars > 0; }
17019 bool hasLocalNames() const { return countLocalNames() > 0; }
17022 inline const js::Shape *lastShape() const;
17029 BINDING_COUNT_LIMIT = 0xFFFF
17032 bool add(JSContext *cx, JSAtom *name, BindingKind kind);
17035 bool addVariable(JSContext *cx, JSAtom *name) {
17036 return add(cx, name, VARIABLE);
17038 bool addConstant(JSContext *cx, JSAtom *name) {
17039 return add(cx, name, CONSTANT);
17041 bool addUpvar(JSContext *cx, JSAtom *name) {
17042 return add(cx, name, UPVAR);
17044 bool addArgument(JSContext *cx, JSAtom *name, uint16 *slotp) {
17047 return add(cx, name, ARGUMENT);
17049 bool addDestructuring(JSContext *cx, uint16 *slotp) {
17051 return add(cx, __null, ARGUMENT);
17060 BindingKind lookup(JSContext *cx, JSAtom *name, uintN *indexp) const;
17063 bool hasBinding(JSContext *cx, JSAtom *name) const {
17064 return lookup(cx, name, __null) != NONE;
17068 getLocalNameArray(JSContext *cx, JSArenaPool *pool);
17074 int sharpSlotBase(JSContext *cx);
17081 void makeImmutable();
17083 const js::Shape *lastArgument() const;
17084 const js::Shape *lastVariable() const;
17085 const js::Shape *lastUpvar() const;
17087 void trace(JSTracer *trc);
17094 static JSScript *NewScript(JSContext *cx, uint32 length, uint32 nsrcnotes, uint32 natoms,
17095 uint32 nobjects, uint32 nupvars, uint32 nregexps,
17096 uint32 ntrynotes, uint32 nconsts, uint32 nglobals,
17097 uint16 nClosedArgs, uint16 nClosedVars, JSVersion version);
17099 static JSScript *NewScriptFromCG(JSContext *cx, JSCodeGenerator *cg);
17119 uint8 objectsOffset;
17122 uint8 upvarsOffset;
17124 uint8 regexpsOffset;
17126 uint8 trynotesOffset;
17127 uint8 globalsOffset;
17130 bool noScriptRval:1;
17132 bool savedCallerFun:1;
17134 bool strictModeCode:1;
17135 bool compileAndGo:1;
17137 bool usesArguments:1;
17138 bool warnedAboutTwoArgumentEval:1;
17141 bool hasSingletons:1;
17149 JSCompartment *compartment;
17150 const char *filename;
17153 uint16 staticLevel;
17154 uint16 nClosedArgs;
17155 uint16 nClosedVars;
17156 js::Bindings bindings;
17158 JSPrincipals *principals;
17162 JSScript *nextToGC;
17169 uint32 *closedSlots;
17173 jssrcnote *notes() { return (jssrcnote *)(code + length); }
17175 static const uint8 INVALID_OFFSET = 0xFF;
17176 static bool isValidOffset(uint8 offset) { return offset != INVALID_OFFSET; }
17178 JSObjectArray *objects() {
17180 return (JSObjectArray *)((uint8 *) (this + 1) + objectsOffset);
17183 JSUpvarArray *upvars() {
17185 return (JSUpvarArray *) ((uint8 *) (this + 1) + upvarsOffset);
17188 JSObjectArray *regexps() {
17190 return (JSObjectArray *) ((uint8 *) (this + 1) + regexpsOffset);
17193 JSTryNoteArray *trynotes() {
17195 return (JSTryNoteArray *) ((uint8 *) (this + 1) + trynotesOffset);
17198 js::GlobalSlotArray *globals() {
17200 return (js::GlobalSlotArray *) ((uint8 *) (this + 1) + globalsOffset);
17203 JSConstArray *consts() {
17205 return (JSConstArray *) ((uint8 *) (this + 1) + constOffset);
17208 JSAtom *getAtom(size_t index) {
17210 return atomMap.vector[index];
17213 JSObject *getObject(size_t index) {
17214 JSObjectArray *arr = objects();
17216 return arr->vector[index];
17219 uint32 getGlobalSlot(size_t index) {
17220 js::GlobalSlotArray *arr = globals();
17222 return arr->vector[index].slot;
17225 JSAtom *getGlobalAtom(size_t index) {
17226 js::GlobalSlotArray *arr = globals();
17228 return getAtom(arr->vector[index].atomIndex);
17231 JSVersion getVersion() const {
17232 return JSVersion(version);
17235 inline JSFunction *getFunction(size_t index);
17237 inline JSObject *getRegExp(size_t index);
17239 const js::Value &getConst(size_t index) {
17240 JSConstArray *arr = consts();
17242 return arr->vector[index];
17250 inline bool isEmpty() const;
17252 uint32 getClosedArg(uint32 index) {
17254 return closedSlots[index];
17257 uint32 getClosedVar(uint32 index) {
17259 return closedSlots[nClosedArgs + index];
17262 void copyClosedSlotsTo(JSScript *other);
17268 static inline uintN
17269 StackDepth(JSScript *script)
17271 return script->nslots - script->nfixed;
17274 extern __attribute__((visibility ("default"))) js::Class js_ScriptClass;
17277 js_InitScriptClass(JSContext *cx, JSObject *obj);
17284 js_InitRuntimeScriptState(JSRuntime *rt);
17293 js_FreeRuntimeScriptState(JSRuntime *rt);
17295 extern const char *
17296 js_SaveScriptFilename(JSContext *cx, const char *filename);
17298 extern const char *
17299 js_SaveScriptFilenameRT(JSRuntime *rt, const char *filename, uint32 flags);
17302 js_GetScriptFilenameFlags(const char *filename);
17305 js_MarkScriptFilename(const char *filename);
17308 js_MarkScriptFilenames(JSRuntime *rt);
17311 js_SweepScriptFilenames(JSRuntime *rt);
17319 extern __attribute__((visibility ("default"))) void
17320 js_CallNewScriptHook(JSContext *cx, JSScript *script, JSFunction *fun);
17323 js_CallDestroyScriptHook(JSContext *cx, JSScript *script);
17330 js_DestroyScript(JSContext *cx, JSScript *script);
17333 js_DestroyScriptFromGC(JSContext *cx, JSScript *script);
17342 js_DestroyCachedScript(JSContext *cx, JSScript *script);
17345 js_TraceScript(JSTracer *trc, JSScript *script);
17348 js_NewScriptObject(JSContext *cx, JSScript *script);
17351 js_GetSrcNoteCached(JSContext *cx, JSScript *script, jsbytecode *pc);
17359 js_FramePCToLineNumber(JSContext *cx, JSStackFrame *fp);
17362 js_PCToLineNumber(JSContext *cx, JSScript *script, jsbytecode *pc);
17364 extern jsbytecode *
17365 js_LineNumberToPC(JSScript *script, uintN lineno);
17367 extern __attribute__((visibility ("default"))) uintN
17368 js_GetScriptLineExtent(JSScript *script);
17371 js_GetOpcode(JSContext *cx, JSScript *script, jsbytecode *pc)
17373 JSOp op = (JSOp) *pc;
17374 if (op == JSOP_TRAP)
17375 op = JS_GetTrapOpcode(cx, script, pc);
17380 js_CloneScript(JSContext *cx, JSScript *script);
17383 js_XDRScript(JSXDRState *xdr, JSScript **scriptp, JSBool *hasMagic);
17389 JSObject::isScript() const
17391 return getClass() == &js_ScriptClass;
17395 JSObject::getScript() const
17398 return static_cast<JSScript *>(getPrivate());
17402 struct JSFunction : public JSObject_Slots2
17414 JSNativeTraceInfo *trcinfo;
17421 JSPackedBool wrapper;
17429 void *nativeOrScript;
17433 bool optimizedClosure() const { return ((this)->flags & 0xc000) > 0x4000; }
17434 bool needsWrapper() const { return (((this)->flags & 0xc000) == 0xc000) && u.i.skipmin != 0; }
17435 bool isInterpreted() const { return (((this)->flags & 0xc000) >= 0x4000); }
17436 bool isNative() const { return !(((this)->flags & 0xc000) >= 0x4000); }
17437 bool isConstructor() const { return flags & 0x0200; }
17438 bool isHeavyweight() const { return ((flags) & 0x80); }
17439 bool isFlatClosure() const { return ((this)->flags & 0xc000) == 0x8000; }
17441 bool isFunctionPrototype() const { return flags & 0x0800; }
17444 inline bool inStrictMode() const;
17446 void setArgCount(uint16 nargs) {
17448 this->nargs = nargs;
17452 enum { MAX_ARGS_AND_VARS = 2 * ((1U << 16) - 1) };
17457 bool mightEscape() const {
17458 return isInterpreted() && (isFlatClosure() || !script()->bindings.hasUpvars());
17461 bool joinable() const {
17462 return flags & 0x0001;
17465 JSObject &compiledFunObj() {
17477 METHOD_ATOM_SLOT = JSSLOT_FUN_METHOD_ATOM
17481 void setJoinable() {
17483 getSlotRef(METHOD_ATOM_SLOT).setNull();
17492 JSAtom *methodAtom() const {
17493 return (joinable() && getSlot(METHOD_ATOM_SLOT).isString())
17494 ? (((void) 0), (JSAtom *)getSlot(METHOD_ATOM_SLOT).toString())
17498 void setMethodAtom(JSAtom *atom) {
17500 getSlotRef(METHOD_ATOM_SLOT).setString((atom));
17503 js::Native maybeNative() const {
17504 return isInterpreted() ? __null : u.n.native;
17507 JSScript *script() const {
17512 static uintN offsetOfNativeOrScript() {
17513 typedef int js_static_assert49[(__builtin_offsetof (U, n.native) == __builtin_offsetof (U, i.script)) ? 1 : -1];
17514 typedef int js_static_assert50[(__builtin_offsetof (U, n.native) == __builtin_offsetof (U, nativeOrScript)) ? 1 : -1];
17515 return __builtin_offsetof (JSFunction, u.nativeOrScript);
17519 static const uint32 CLASS_RESERVED_SLOTS = JSObject::FUN_CLASS_RESERVED_SLOTS;
17522 extern js::Class js_ArgumentsClass;
17526 extern Class StrictArgumentsClass;
17528 struct ArgumentsData {
17530 js::Value slots[1];
17539 JSObject::isNormalArguments() const
17541 return getClass() == &js_ArgumentsClass;
17548 JSObject::isStrictArguments() const
17550 return getClass() == &js::StrictArgumentsClass;
17557 JSObject::isArguments() const
17559 return isNormalArguments() || isStrictArguments();
17564 extern __attribute__((visibility ("default"))) js::Class js_CallClass;
17565 extern __attribute__((visibility ("default"))) js::Class js_FunctionClass;
17566 extern js::Class js_DeclEnvClass;
17572 JSObject::isCall() const
17574 return getClass() == &js_CallClass;
17581 JSObject::isFunction() const
17583 return getClass() == &js_FunctionClass;
17586 inline JSFunction *
17587 JSObject::getFunctionPrivate() const
17590 return reinterpret_cast<JSFunction *>(getPrivate());
17602 NewCallObject(JSContext *cx, js::Bindings *bindings, JSObject &scopeChain, JSObject *callee);
17610 static __attribute__((always_inline)) inline
17614 IsFunctionObject(const js::Value &v)
17616 return v.isObject() && v.toObject().isFunction();
17619 static __attribute__((always_inline)) inline
17623 IsFunctionObject(const js::Value &v, JSObject **funobj)
17625 return v.isObject() && (*funobj = &v.toObject())->isFunction();
17628 static __attribute__((always_inline)) inline
17632 IsFunctionObject(const js::Value &v, JSFunction **fun)
17635 bool b = IsFunctionObject(v, &funobj);
17637 *fun = funobj->getFunctionPrivate();
17641 extern __attribute__((always_inline)) inline
17645 SameTraceType(const Value &lhs, const Value &rhs)
17647 return SameType(lhs, rhs) &&
17648 (lhs.isPrimitive() ||
17649 lhs.toObject().isFunction() == rhs.toObject().isFunction());
17656 IsInternalFunctionObject(JSObject *funobj)
17659 JSFunction *fun = (JSFunction *) funobj->getPrivate();
17660 return funobj == fun && (fun->flags & 0x08) && !funobj->getParent();
17664 static __attribute__((always_inline)) inline
17668 IsConstructing(const Value *vp)
17671 return vp[1].isMagic();
17674 static __attribute__((always_inline)) inline
17678 IsConstructing_PossiblyWithGivenThisObject(const Value *vp, JSObject **ctorThis)
17681 bool isCtor = vp[1].isMagic();
17683 *ctorThis = vp[1].getMagicObjectOrNullPayload();
17687 inline const char *
17688 GetFunctionNameBytes(JSContext *cx, JSFunction *fun, JSAutoByteString *bytes)
17691 return bytes->encode(cx, (fun->atom));
17692 return js_anonymous_str;
17695 extern __attribute__((visibility ("default"))) bool
17696 IsBuiltinFunctionConstructor(JSFunction *fun);
17699 LookupInterpretedFunctionPrototype(JSContext *cx, JSObject *funobj);
17704 fun_toStringHelper(JSContext *cx, JSObject *obj, uintN indent);
17706 extern JSFunction *
17707 js_NewFunction(JSContext *cx, JSObject *funobj, js::Native native, uintN nargs,
17708 uintN flags, JSObject *parent, JSAtom *atom);
17711 js_InitFunctionClass(JSContext *cx, JSObject *obj);
17714 js_InitArgumentsClass(JSContext *cx, JSObject *obj);
17717 js_TraceFunction(JSTracer *trc, JSFunction *fun);
17720 js_FinalizeFunction(JSContext *cx, JSFunction *fun);
17723 js_CloneFunctionObject(JSContext *cx, JSFunction *fun, JSObject *parent,
17727 CloneFunctionObject(JSContext *cx, JSFunction *fun, JSObject *parent)
17731 if (!js_GetClassPrototype(cx, parent, JSProto_Function, &proto))
17733 return js_CloneFunctionObject(cx, fun, parent, proto);
17737 js_AllocFlatClosure(JSContext *cx, JSFunction *fun, JSObject *scopeChain);
17740 js_NewFlatClosure(JSContext *cx, JSFunction *fun, JSOp op, size_t oplen);
17743 js_NewDebuggableFlatClosure(JSContext *cx, JSFunction *fun);
17745 extern JSFunction *
17746 js_DefineFunction(JSContext *cx, JSObject *obj, jsid id, js::Native native,
17747 uintN nargs, uintN flags);
17749 extern JSFunction *
17750 js_ValueToFunction(JSContext *cx, const js::Value *vp, uintN flags);
17753 js_ValueToFunctionObject(JSContext *cx, js::Value *vp, uintN flags);
17756 js_ValueToCallableObject(JSContext *cx, js::Value *vp, uintN flags);
17759 js_ReportIsNotFunction(JSContext *cx, const js::Value *vp, uintN flags);
17762 js_GetCallObject(JSContext *cx, JSStackFrame *fp);
17765 js_CreateCallObjectOnTrace(JSContext *cx, JSFunction *fun, JSObject *callee, JSObject *scopeChain);
17768 js_PutCallObject(JSContext *cx, JSStackFrame *fp);
17771 js_PutCallObjectOnTrace(JSContext *cx, JSObject *scopeChain, uint32 nargs,
17772 js::Value *argv, uint32 nvars, js::Value *slots);
17777 GetCallArg(JSContext *cx, JSObject *obj, jsid id, js::Value *vp);
17780 GetCallVar(JSContext *cx, JSObject *obj, jsid id, js::Value *vp);
17787 GetCallVarChecked(JSContext *cx, JSObject *obj, jsid id, js::Value *vp);
17790 GetCallUpvar(JSContext *cx, JSObject *obj, jsid id, js::Value *vp);
17793 SetCallArg(JSContext *cx, JSObject *obj, jsid id, JSBool strict, js::Value *vp);
17796 SetCallVar(JSContext *cx, JSObject *obj, jsid id, JSBool strict, js::Value *vp);
17799 SetCallUpvar(JSContext *cx, JSObject *obj, jsid id, JSBool strict, js::Value *vp);
17804 js_GetArgsValue(JSContext *cx, JSStackFrame *fp, js::Value *vp);
17807 js_GetArgsProperty(JSContext *cx, JSStackFrame *fp, jsid id, js::Value *vp);
17810 js_GetArgsObject(JSContext *cx, JSStackFrame *fp);
17813 js_PutArgsObject(JSContext *cx, JSStackFrame *fp);
17819 js_IsNamedLambda(JSFunction *fun) { return (fun->flags & 0x08) && fun->atom; }
17821 const uint32 JS_ARGS_LENGTH_MAX = ((JSUint32)1 << (19)) - 1024;
17827 typedef int js_static_assert51[(JS_ARGS_LENGTH_MAX <= ((JSUint32)1 << (30))) ? 1 : -1];
17828 typedef int js_static_assert52[(((JS_ARGS_LENGTH_MAX << 1) | 1) <= ((jsint)0x7fffffff)) ? 1 : -1];
17831 js_XDRFunctionObject(JSXDRState *xdr, JSObject **objp);
17834 js_fun_apply(JSContext *cx, uintN argc, js::Value *vp);
17837 js_fun_call(JSContext *cx, uintN argc, js::Value *vp);
17841 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/setjmp.h" 1 3 4
17842 # 27 "/usr/powerpc64-unknown-linux-gnu/usr/include/setjmp.h" 3 4
17845 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/setjmp.h" 1 3 4
17846 # 31 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/setjmp.h" 3 4
17847 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/wordsize.h" 1 3 4
17848 # 32 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/setjmp.h" 2 3 4
17849 # 42 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/setjmp.h" 3 4
17850 typedef long int __jmp_buf[64] __attribute__ ((__aligned__ (16)));
17851 # 30 "/usr/powerpc64-unknown-linux-gnu/usr/include/setjmp.h" 2 3 4
17852 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/sigset.h" 1 3 4
17853 # 31 "/usr/powerpc64-unknown-linux-gnu/usr/include/setjmp.h" 2 3 4
17857 struct __jmp_buf_tag
17863 __jmp_buf __jmpbuf;
17864 int __mask_was_saved;
17865 __sigset_t __saved_mask;
17871 typedef struct __jmp_buf_tag jmp_buf[1];
17875 extern int setjmp (jmp_buf __env) throw ();
17882 extern int __sigsetjmp (struct __jmp_buf_tag __env[1], int __savemask) throw ();
17886 extern int _setjmp (struct __jmp_buf_tag __env[1]) throw ();
17897 extern void longjmp (struct __jmp_buf_tag __env[1], int __val)
17898 throw () __attribute__ ((__noreturn__));
17906 extern void _longjmp (struct __jmp_buf_tag __env[1], int __val)
17907 throw () __attribute__ ((__noreturn__));
17915 typedef struct __jmp_buf_tag sigjmp_buf[1];
17916 # 102 "/usr/powerpc64-unknown-linux-gnu/usr/include/setjmp.h" 3 4
17917 extern void siglongjmp (sigjmp_buf __env, int __val)
17918 throw () __attribute__ ((__noreturn__));
17924 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/setjmp2.h" 1 3 4
17925 # 25 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/setjmp2.h" 3 4
17926 extern void longjmp (struct __jmp_buf_tag __env[1], int __val) throw () __asm__ ("" "__longjmp_chk")
17928 __attribute__ ((__noreturn__));
17929 extern void _longjmp (struct __jmp_buf_tag __env[1], int __val) throw () __asm__ ("" "__longjmp_chk")
17931 __attribute__ ((__noreturn__));
17932 extern void siglongjmp (struct __jmp_buf_tag __env[1], int __val) throw () __asm__ ("" "__longjmp_chk")
17934 __attribute__ ((__noreturn__));
17935 # 110 "/usr/powerpc64-unknown-linux-gnu/usr/include/setjmp.h" 2 3 4
17946 # 1 "jsgcchunk.h" 1
17953 const size_t GC_CHUNK_SHIFT = 20;
17956 const size_t GC_CHUNK_SIZE = size_t(1) << GC_CHUNK_SHIFT;
17957 const size_t GC_CHUNK_MASK = GC_CHUNK_SIZE - 1;
17959 __attribute__((visibility ("default"))) void *
17962 __attribute__((visibility ("default"))) void
17963 FreeGCChunk(void *p);
17965 class GCChunkAllocator {
17967 GCChunkAllocator() {}
17970 void *chunk = doAlloc();
17975 void free(void *chunk) {
17982 virtual void *doAlloc() {
17983 return AllocGCChunk();
17986 virtual void doFree(void *chunk) {
17987 FreeGCChunk(chunk);
17991 GCChunkAllocator(const GCChunkAllocator &);
17992 void operator=(const GCChunkAllocator &);
17995 extern GCChunkAllocator defaultGCChunkAllocator;
18001 # 1 "jsversion.h" 1
18005 # 1 "jsgcstats.h" 1
18013 enum ConservativeGCTest {
18015 CGCT_VALIDWITHOFFSET,
18025 struct ConservativeGCStats {
18026 uint32 counter[gc::CGCT_END];
18029 void add(const ConservativeGCStats &another) {
18030 for (size_t i = 0; i != (sizeof (counter) / sizeof (counter)[0]); ++i)
18031 counter[i] += another.counter[i];
18034 void dump(FILE *fp);
18036 # 136 "jsgcstats.h"
18038 # 175 "jsgcstats.h"
18041 extern __attribute__((visibility ("default"))) void
18042 js_DumpGCStats(JSRuntime *rt, FILE *fp);
18046 struct JSCompartment;
18049 js_TraceXML(JSTracer *trc, JSXML* thing);
18067 enum FinalizeKind {
18074 FINALIZE_OBJECT_LAST = FINALIZE_OBJECT16,
18079 FINALIZE_SHORT_STRING,
18081 FINALIZE_EXTERNAL_STRING,
18085 const uintN JS_FINALIZE_OBJECT_LIMIT = 6;
18088 struct ArenaHeader {
18089 JSCompartment *compartment;
18090 Arena<FreeCell> *next;
18091 FreeCell *freeList;
18092 unsigned thingKind;
18100 template <typename T>
18101 union ThingOrCell {
18106 template <typename T, size_t N, size_t R>
18108 ThingOrCell<T> things[N];
18112 template <typename T, size_t N>
18113 struct Things<T, N, 0> {
18114 ThingOrCell<T> things[N];
18117 template <typename T>
18119 static const size_t ArenaSize = 4096;
18121 struct AlignedArenaHeader {
18122 T align[(sizeof(ArenaHeader) + sizeof(T) - 1) / sizeof(T)];
18127 ArenaHeader aheader;
18128 AlignedArenaHeader align;
18131 static const size_t ThingsPerArena = (ArenaSize - sizeof(AlignedArenaHeader)) / sizeof(T);
18132 static const size_t FillerSize = ArenaSize - sizeof(AlignedArenaHeader) - sizeof(T) * ThingsPerArena;
18133 Things<T, ThingsPerArena, FillerSize> t;
18135 inline Chunk *chunk() const;
18136 inline size_t arenaIndex() const;
18138 inline ArenaHeader *header() { return &aheader; };
18140 inline MarkingDelay *getMarkingDelay() const;
18141 inline ArenaBitmap *bitmap() const;
18143 inline ConservativeGCTest mark(T *thing, JSTracer *trc);
18144 void markDelayedChildren(JSTracer *trc);
18145 inline bool inFreeList(void *thing) const;
18146 inline T *getAlignedThing(void *thing);
18151 void init(JSCompartment *compartment, unsigned thingKind);
18153 typedef int js_static_assert53[(sizeof(Arena<FreeCell>) == 4096) ? 1 : -1];
18159 static const uint32 BLACK = 0;
18162 struct ArenaBitmap {
18163 static const size_t BitCount = Arena<FreeCell>::ArenaSize / Cell::CellSize;
18164 static const size_t BitWords = BitCount / (8 * 8);
18166 uintptr_t bitmap[BitWords];
18168 __attribute__((always_inline)) inline bool isMarked(size_t bit, uint32 color) {
18171 uintptr_t *word = &bitmap[bit / (8 * 8)];
18172 return *word & (uintptr_t(1) << (bit % (8 * 8)));
18175 __attribute__((always_inline)) inline bool markIfUnmarked(size_t bit, uint32 color) {
18177 uintptr_t *word = &bitmap[bit / (8 * 8)];
18178 uintptr_t mask = (uintptr_t(1) << (bit % (8 * 8)));
18182 if (color != BLACK) {
18184 word = &bitmap[bit / (8 * 8)];
18185 mask = (uintptr_t(1) << (bit % (8 * 8)));
18193 __attribute__((always_inline)) inline void unmark(size_t bit, uint32 color) {
18196 uintptr_t *word = &bitmap[bit / (8 * 8)];
18197 *word &= ~(uintptr_t(1) << (bit % (8 * 8)));
18203 typedef int js_static_assert54[(Arena<FreeCell>::ArenaSize % Cell::CellSize == 0) ? 1 : -1];
18204 typedef int js_static_assert55[(ArenaBitmap::BitCount % (8 * 8) == 0) ? 1 : -1];
18207 struct MarkingDelay {
18209 uintptr_t unmarkedChildren;
18215 unmarkedChildren = 0;
18219 struct EmptyArenaLists {
18221 Arena<FreeCell> *cellFreeList;
18224 Arena<FreeCell> *freeLists[FINALIZE_LIMIT];
18230 Arena<FreeCell> *getOtherArena() {
18231 Arena<FreeCell> *arena = cellFreeList;
18233 cellFreeList = arena->header()->next;
18236 for (int i = 0; i < FINALIZE_LIMIT; i++) {
18237 if ((arena = (Arena<FreeCell> *) freeLists[i])) {
18238 freeLists[i] = freeLists[i]->header()->next;
18246 template <typename T>
18247 inline Arena<T> *getTypedFreeList(unsigned thingKind);
18249 template <typename T>
18250 inline Arena<T> *getNext(JSCompartment *comp, unsigned thingKind);
18252 template <typename T>
18253 inline void insert(Arena<T> *arena);
18256 template <typename T>
18258 EmptyArenaLists::getTypedFreeList(unsigned thingKind) {
18260 Arena<T> *arena = (Arena<T>*) freeLists[thingKind];
18262 freeLists[thingKind] = freeLists[thingKind]->header()->next;
18268 template<typename T>
18270 EmptyArenaLists::getNext(JSCompartment *comp, unsigned thingKind) {
18271 Arena<T> *arena = getTypedFreeList<T>(thingKind);
18275 arena->header()->isUsed = true;
18276 arena->header()->thingKind = thingKind;
18277 arena->header()->compartment = comp;
18280 arena = (Arena<T> *)getOtherArena();
18282 arena->init(comp, thingKind);
18286 template <typename T>
18288 EmptyArenaLists::insert(Arena<T> *arena) {
18289 unsigned thingKind = arena->header()->thingKind;
18291 arena->header()->next = freeLists[thingKind];
18292 freeLists[thingKind] = (Arena<FreeCell> *) arena;
18298 JSRuntime *runtime;
18299 EmptyArenaLists emptyArenaLists;
18306 static const size_t BytesPerArena = sizeof(Arena<FreeCell>) +
18307 sizeof(ArenaBitmap) +
18308 sizeof(MarkingDelay);
18310 static const size_t ArenasPerChunk = (GC_CHUNK_SIZE - sizeof(ChunkInfo)) / BytesPerArena;
18312 Arena<FreeCell> arenas[ArenasPerChunk];
18313 ArenaBitmap bitmaps[ArenasPerChunk];
18314 MarkingDelay markingDelay[ArenasPerChunk];
18318 void clearMarkBitmap();
18319 void init(JSRuntime *rt);
18322 bool hasAvailableArenas();
18323 bool withinArenasRange(Cell *cell);
18325 template <typename T>
18326 Arena<T> *allocateArena(JSCompartment *comp, unsigned thingKind);
18328 template <typename T>
18329 void releaseArena(Arena<T> *a);
18331 JSRuntime *getRuntime();
18333 typedef int js_static_assert56[(sizeof(Chunk) <= GC_CHUNK_SIZE) ? 1 : -1];
18334 typedef int js_static_assert57[(sizeof(Chunk) + Chunk::BytesPerArena > GC_CHUNK_SIZE) ? 1 : -1];
18337 Cell::arena() const
18339 uintptr_t addr = uintptr_t(this);
18341 addr &= ~(Arena<FreeCell>::ArenaSize - 1);
18342 return reinterpret_cast<Arena<Cell> *>(addr);
18346 Cell::chunk() const
18348 uintptr_t addr = uintptr_t(this);
18350 addr &= ~(GC_CHUNK_SIZE - 1);
18351 return reinterpret_cast<Chunk *>(addr);
18355 Cell::bitmap() const
18357 return &chunk()->bitmaps[arena()->arenaIndex()];
18362 Cell::cellIndex() const
18364 return reinterpret_cast<const FreeCell *>(this) - reinterpret_cast<FreeCell *>(&arena()->t);
18367 template <typename T>
18369 Arena<T>::chunk() const
18371 uintptr_t addr = uintptr_t(this);
18373 addr &= ~(GC_CHUNK_SIZE - 1);
18374 return reinterpret_cast<Chunk *>(addr);
18377 template <typename T>
18379 Arena<T>::arenaIndex() const
18381 return reinterpret_cast<const Arena<FreeCell> *>(this) - chunk()->arenas;
18384 template <typename T>
18386 Arena<T>::getMarkingDelay() const
18388 return &chunk()->markingDelay[arenaIndex()];
18391 template <typename T>
18393 Arena<T>::bitmap() const
18395 return &chunk()->bitmaps[arenaIndex()];
18398 template <typename T>
18400 Arena<T>::getAlignedThing(void *thing)
18402 jsuword start = reinterpret_cast<jsuword>(&t.things[0]);
18403 jsuword offset = reinterpret_cast<jsuword>(thing) - start;
18404 offset -= offset % aheader.thingSize;
18405 return reinterpret_cast<T *>(start + offset);
18409 AssertValidColor(const void *thing, uint32 color)
18418 Cell::isMarked(uint32 color = BLACK) const
18420 AssertValidColor(this, color);
18421 return bitmap()->isMarked(cellIndex(), color);
18427 Cell::markIfUnmarked(uint32 color = BLACK) const
18429 AssertValidColor(this, color);
18430 return bitmap()->markIfUnmarked(cellIndex(), color);
18434 Cell::unmark(uint32 color) const
18437 AssertValidColor(this, color);
18438 bitmap()->unmark(cellIndex(), color);
18442 Cell::compartment() const
18444 return arena()->header()->compartment;
18447 template <typename T>
18450 GetArena(Cell *cell)
18452 return reinterpret_cast<Arena<T> *>(cell->arena());
18455 const size_t GC_ARENA_ALLOCATION_TRIGGER = 30 * js::GC_CHUNK_SIZE;
18463 const float GC_HEAP_GROWTH_FACTOR = 3.0f;
18465 static inline size_t
18466 GetFinalizableTraceKind(size_t thingKind)
18468 typedef int js_static_assert58[(JSExternalString::TYPE_LIMIT == 8) ? 1 : -1];
18470 static const uint8 map[FINALIZE_LIMIT] = {
18487 return map[thingKind];
18494 IsFinalizableStringKind(unsigned thingKind)
18496 return unsigned(FINALIZE_SHORT_STRING) <= thingKind &&
18497 thingKind <= unsigned(FINALIZE_EXTERNAL_STRING);
18505 GetExternalStringGCType(JSExternalString *str)
18507 typedef int js_static_assert59[(FINALIZE_STRING + 1 == FINALIZE_EXTERNAL_STRING) ? 1 : -1];
18510 unsigned thingKind = str->externalStringType;
18512 return intN(thingKind);
18515 static inline uint32
18516 GetGCThingTraceKind(void *thing)
18519 if (JSString::isStatic(thing))
18521 Cell *cell = reinterpret_cast<Cell *>(thing);
18522 return GetFinalizableTraceKind(cell->arena()->header()->thingKind);
18525 static inline JSRuntime *
18526 GetGCThingRuntime(void *thing)
18528 return reinterpret_cast<FreeCell *>(thing)->chunk()->info.runtime;
18538 Arena<FreeCell> *head;
18539 Arena<FreeCell> *cursor;
18541 inline void init() {
18546 inline Arena<FreeCell> *getNextWithFreeList() {
18547 Arena<FreeCell> *a;
18548 while (cursor != __null) {
18549 ArenaHeader *aheader = cursor->header();
18551 cursor = aheader->next;
18552 if (aheader->freeList)
18558 inline void insert(Arena<FreeCell> *a) {
18559 a->header()->next = head;
18563 void releaseAll() {
18565 Arena<FreeCell> *next = head->header()->next;
18566 head->chunk()->releaseArena(head);
18573 inline bool isEmpty() const {
18574 return (head == __null);
18579 FreeCell **finalizables[FINALIZE_LIMIT];
18583 inline FreeCell *getNext(uint32 kind) {
18584 FreeCell *top = __null;
18585 if (finalizables[kind]) {
18586 top = *finalizables[kind];
18588 *finalizables[kind] = top->link;
18590 finalizables[kind] = __null;
18600 template <typename T>
18601 inline void populate(Arena<T> *a, uint32 thingKind) {
18602 finalizables[thingKind] = &a->header()->freeList;
18608 typedef Vector<gc::Chunk *, 32, SystemAllocPolicy> GCChunks;
18612 typedef void *Lookup;
18614 static HashNumber hash(void *key) {
18615 return HashNumber(uintptr_t(key) >> JS_GCTHING_ZEROBITS);
18618 static bool match(void *l, void *k) { return l == k; }
18621 typedef HashMap<void *, uint32, GCPtrHasher, SystemAllocPolicy> GCLocks;
18625 RootInfo(const char *name, JSGCRootType type) : name(name), type(type) {}
18630 typedef js::HashMap<void *,
18632 js::DefaultHasher<void *>,
18633 js::SystemAllocPolicy> RootedValueMap;
18636 typedef int js_static_assert60[(sizeof(HashNumber) == 4) ? 1 : -1];
18638 struct WrapperHasher
18640 typedef Value Lookup;
18642 static HashNumber hash(Value key) {
18643 uint64 bits = (Jsvalify(key));
18644 return (uint32)bits ^ (uint32)(bits >> 32);
18647 static bool match(const Value &l, const Value &k) { return l == k; }
18650 typedef HashMap<Value, Value, WrapperHasher, SystemAllocPolicy> WrapperMap;
18652 class AutoValueVector;
18653 class AutoIdVector;
18657 CheckGCFreeListLink(js::gc::FreeCell *cell)
18673 RefillFinalizableFreeList(JSContext *cx, unsigned thingKind);
18676 js_GetExternalStringGCType(JSString *str);
18678 extern __attribute__((visibility ("default"))) uint32
18679 js_GetGCThingTraceKind(void *thing);
18682 js_InitGC(JSRuntime *rt, uint32 maxbytes);
18685 js_FinishGC(JSRuntime *rt);
18688 js_AddRoot(JSContext *cx, js::Value *vp, const char *name);
18691 js_AddGCThingRoot(JSContext *cx, void **rp, const char *name);
18694 js_MapGCRoots(JSRuntime *rt, JSGCRootMapFun map, void *data);
18697 typedef struct JSPtrTable {
18703 js_RegisterCloseableIterator(JSContext *cx, JSObject *obj);
18711 js_LockGCThingRT(JSRuntime *rt, void *thing);
18714 js_UnlockGCThingRT(JSRuntime *rt, void *thing);
18716 extern __attribute__((visibility ("default"))) bool
18717 IsAboutToBeFinalized(JSContext *cx, void *thing);
18719 extern __attribute__((visibility ("default"))) bool
18720 js_GCThingIsMarked(void *thing, uintN color);
18723 js_TraceStackFrame(JSTracer *trc, JSStackFrame *fp);
18728 MarkRuntime(JSTracer *trc);
18731 TraceRuntime(JSTracer *trc);
18733 extern __attribute__((visibility ("default"))) void
18734 MarkContext(JSTracer *trc, JSContext *acx);
18738 TriggerGC(JSRuntime *rt);
18742 TriggerCompartmentGC(JSCompartment *comp);
18745 MaybeGC(JSContext *cx);
18752 typedef enum JSGCInvocationKind {
18760 GC_LAST_CONTEXT = 1
18761 } JSGCInvocationKind;
18765 js_GC(JSContext *cx, JSCompartment *comp, JSGCInvocationKind gckind);
18768 js_WaitForGC(JSRuntime *rt);
18777 js_DestroyScriptsToGC(JSContext *cx, JSCompartment *comp);
18781 class GCHelperThread {
18782 static const size_t FREE_ARRAY_SIZE = size_t(1) << 16;
18783 static const size_t FREE_ARRAY_LENGTH = FREE_ARRAY_SIZE / sizeof(void *);
18787 PRCondVar* sweepingDone;
18791 Vector<void **, 16, js::SystemAllocPolicy> freeVector;
18793 void **freeCursorEnd;
18795 __attribute__((visibility ("default"))) void
18796 replenishAndFreeLater(void *ptr);
18798 static void freeElementsAndArray(void **array, void **end) {
18800 for (void **p = array; p != end; ++p)
18805 static void threadMain(void* arg);
18807 void threadLoop(JSRuntime *rt);
18814 sweepingDone(__null),
18817 freeCursor(__null),
18818 freeCursorEnd(__null) { }
18820 bool init(JSRuntime *rt);
18821 void finish(JSRuntime *rt);
18824 void startBackgroundSweep(JSRuntime *rt);
18827 void waitBackgroundSweepEnd(JSRuntime *rt);
18829 void freeLater(void *ptr) {
18831 if (freeCursor != freeCursorEnd)
18832 *freeCursor++ = ptr;
18834 replenishAndFreeLater(ptr);
18840 struct GCChunkHasher {
18841 typedef gc::Chunk *Lookup;
18847 static HashNumber hash(gc::Chunk *chunk) {
18849 return HashNumber(jsuword(chunk) >> GC_CHUNK_SHIFT);
18852 static bool match(gc::Chunk *k, gc::Chunk *l) {
18859 typedef HashSet<js::gc::Chunk *, GCChunkHasher, SystemAllocPolicy> GCChunkSet;
18861 struct ConservativeGCThreadData {
18867 jsuword *nativeStackTop;
18871 jsuword words[(((sizeof(jmp_buf))+(sizeof(jsuword))-1)/(sizeof(jsuword)))];
18872 } registerSnapshot;
18879 unsigned requestThreshold;
18881 __attribute__((noinline)) void recordStackTop();
18884 void updateForRequestEnd(unsigned suspendCount) {
18888 nativeStackTop = __null;
18892 bool hasStackToScan() const {
18893 return !!nativeStackTop;
18897 struct GCMarker : public JSTracer {
18902 jsuword stackLimit;
18904 js::gc::Arena<js::gc::Cell> *unmarkedArenaStackTop;
18907 explicit GCMarker(JSContext *cx);
18910 uint32 getMarkColor() const {
18914 void setMarkColor(uint32 newColor) {
18919 markDelayedChildren();
18923 void delayMarkingChildren(void *thing);
18925 __attribute__((visibility ("default"))) void markDelayedChildren();
18929 MarkStackRangeConservatively(JSTracer *trc, Value *begin, Value *end);
18934 js_FinalizeStringRT(JSRuntime *rt, JSString *str);
18941 js_MarkTraps(JSTracer *trc);
18950 SetProtoCheckingForCycles(JSContext *cx, JSObject *obj, JSObject *proto);
18953 NewCompartment(JSContext *cx, JSPrincipals *principals);
18958 inline JSCompartment *
18959 JSObject::getCompartment() const
18961 return compartment();
18979 JSINTERP_NORMAL = 0,
18980 JSINTERP_RECORD = 1,
18981 JSINTERP_SAFEPOINT = 2,
18982 JSINTERP_PROFILE = 3
18989 JSFRAME_GLOBAL = 0x1,
18990 JSFRAME_FUNCTION = 0x2,
18991 JSFRAME_DUMMY = 0x4,
18994 JSFRAME_EVAL = 0x8,
18995 JSFRAME_DEBUGGER = 0x10,
18996 JSFRAME_GENERATOR = 0x20,
18997 JSFRAME_FLOATING_GENERATOR = 0x40,
18998 JSFRAME_CONSTRUCTING = 0x80,
19001 JSFRAME_ASSIGNING = 0x100,
19002 JSFRAME_YIELDING = 0x200,
19003 JSFRAME_FINISHED_IN_INTERPRETER = 0x400,
19006 JSFRAME_OVERRIDE_ARGS = 0x1000,
19007 JSFRAME_OVERFLOW_ARGS = 0x2000,
19008 JSFRAME_UNDERFLOW_ARGS = 0x4000,
19011 JSFRAME_HAS_IMACRO_PC = 0x8000,
19012 JSFRAME_HAS_CALL_OBJ = 0x10000,
19013 JSFRAME_HAS_ARGS_OBJ = 0x20000,
19014 JSFRAME_HAS_HOOK_DATA = 0x40000,
19015 JSFRAME_HAS_ANNOTATION = 0x80000,
19016 JSFRAME_HAS_RVAL = 0x100000,
19017 JSFRAME_HAS_SCOPECHAIN = 0x200000,
19018 JSFRAME_HAS_PREVPC = 0x400000
19021 namespace js { namespace mjit { struct JITScript; } }
19027 struct JSStackFrame
19030 mutable uint32 flags_;
19040 mutable JSObject *scopeChain_;
19041 JSStackFrame *prev_;
19046 jsbytecode *prevpc_;
19047 jsbytecode *imacropc_;
19051 friend class js::StackSpace;
19052 friend class js::FrameRegsIter;
19053 friend struct JSContext;
19055 inline void initPrev(JSContext *cx);
19059 bool isFunctionFrame() const {
19060 return !!(flags_ & JSFRAME_FUNCTION);
19063 bool isGlobalFrame() const {
19064 return !!(flags_ & JSFRAME_GLOBAL);
19067 bool isDummyFrame() const {
19068 return !!(flags_ & JSFRAME_DUMMY);
19071 bool isScriptFrame() const {
19072 return !!(flags_ & (JSFRAME_FUNCTION | JSFRAME_GLOBAL));
19075 bool isEvalFrame() const {
19077 return flags_ & JSFRAME_EVAL;
19080 bool isExecuteFrame() const {
19081 return !!(flags_ & (JSFRAME_GLOBAL | JSFRAME_EVAL));
19084 inline void initCallFrame(JSContext *cx, JSObject &callee, JSFunction *fun,
19085 uint32 nactual, uint32 flags);
19088 inline void resetInvokeCallFrame();
19091 inline void initCallFrameCallerHalf(JSContext *cx, uint32 flags, void *ncode);
19092 inline void initCallFrameEarlyPrologue(JSFunction *fun, uint32 nactual);
19093 inline void initCallFrameLatePrologue();
19096 inline void initEvalFrame(JSContext *cx, JSScript *script, JSStackFrame *prev,
19098 inline void initGlobalFrame(JSScript *script, JSObject &chain, uint32 flags);
19101 inline void stealFrameAndSlots(js::Value *vp, JSStackFrame *otherfp,
19102 js::Value *othervp, js::Value *othersp);
19105 inline void initDummyFrame(JSContext *cx, JSObject &chain);
19107 JSStackFrame *prev() const {
19111 inline void resetGeneratorPrev(JSContext *cx);
19113 js::Value *slots() const {
19114 return (js::Value *)(this + 1);
19117 js::Value *base() const {
19118 return slots() + script()->nfixed;
19121 js::Value &varSlot(uintN i) {
19127 jsbytecode *pc(JSContext *cx, JSStackFrame *next = __null);
19129 jsbytecode *prevpc() {
19134 JSScript *script() const {
19136 return isFunctionFrame()
19137 ? isEvalFrame() ? args.script : fun()->script()
19141 JSScript *functionScript() const {
19143 return isEvalFrame() ? args.script : fun()->script();
19146 JSScript *globalScript() const {
19148 return exec.script;
19151 JSScript *maybeScript() const {
19152 return isScriptFrame() ? script() : __null;
19155 size_t numFixed() const {
19156 return script()->nfixed;
19159 size_t numSlots() const {
19160 return script()->nslots;
19163 size_t numGlobalVars() const {
19165 return exec.script->nfixed;
19174 JSFunction* fun() const {
19179 JSFunction* maybeFun() const {
19180 return isFunctionFrame() ? fun() : __null;
19183 bool hasArgs() const {
19184 return isFunctionFrame() && !isEvalFrame();
19187 uintN numFormalArgs() const {
19189 return fun()->nargs;
19192 js::Value &formalArg(uintN i) const {
19194 return formalArgs()[i];
19197 js::Value *formalArgs() const {
19199 return (js::Value *)this - numFormalArgs();
19202 js::Value *formalArgsEnd() const {
19204 return (js::Value *)this;
19207 js::Value *maybeFormalArgs() const {
19208 return (flags_ & (JSFRAME_FUNCTION | JSFRAME_EVAL)) == JSFRAME_FUNCTION
19213 inline uintN numActualArgs() const;
19214 inline js::Value *actualArgs() const;
19215 inline js::Value *actualArgsEnd() const;
19217 inline js::Value &canonicalActualArg(uintN i) const;
19218 template <class Op> inline void forEachCanonicalActualArg(Op op);
19219 template <class Op> inline void forEachFormalArg(Op op);
19221 inline void clearMissingArgs();
19223 bool hasArgsObj() const {
19224 return !!(flags_ & JSFRAME_HAS_ARGS_OBJ);
19227 JSObject &argsObj() const {
19233 JSObject *maybeArgsObj() const {
19234 return hasArgsObj() ? &argsObj() : __null;
19237 inline void setArgsObj(JSObject &obj);
19238 inline void clearArgsObj();
19240 js::Value &functionThis() const {
19243 return ((js::Value *)this)[-1];
19244 return formalArgs()[-1];
19247 JSObject &constructorThis() const {
19249 return formalArgs()[-1].toObject();
19252 js::Value &globalThis() const {
19254 return ((js::Value *)this)[-1];
19257 js::Value &thisValue() const {
19258 if (flags_ & (JSFRAME_EVAL | JSFRAME_GLOBAL))
19259 return ((js::Value *)this)[-1];
19260 return formalArgs()[-1];
19263 inline bool computeThis(JSContext *cx);
19265 js::Value &calleeValue() const {
19268 return ((js::Value *)this)[-2];
19269 return formalArgs()[-2];
19272 JSObject &callee() const {
19274 return calleeValue().toObject();
19277 JSObject *maybeCallee() const {
19278 return isFunctionFrame() ? &callee() : __null;
19287 bool getValidCalleeObject(JSContext *cx, js::Value *vp);
19289 JSObject &scopeChain() const {
19291 if (!(flags_ & JSFRAME_HAS_SCOPECHAIN)) {
19292 scopeChain_ = callee().getParent();
19293 flags_ |= JSFRAME_HAS_SCOPECHAIN;
19295 return *scopeChain_;
19298 bool hasCallObj() const {
19299 return !!(flags_ & JSFRAME_HAS_CALL_OBJ);
19302 inline JSObject &callObj() const;
19303 inline JSObject *maybeCallObj() const;
19304 inline void setScopeChainNoCallObj(JSObject &obj);
19305 inline void setScopeChainAndCallObj(JSObject &obj);
19306 inline void clearCallObj();
19308 bool hasImacropc() const {
19309 return flags_ & JSFRAME_HAS_IMACRO_PC;
19312 jsbytecode *imacropc() const {
19317 jsbytecode *maybeImacropc() const {
19318 return hasImacropc() ? imacropc() : __null;
19321 void clearImacropc() {
19322 flags_ &= ~JSFRAME_HAS_IMACRO_PC;
19325 void setImacropc(jsbytecode *pc) {
19329 flags_ |= JSFRAME_HAS_IMACRO_PC;
19334 void* annotation() const {
19335 return (flags_ & JSFRAME_HAS_ANNOTATION) ? annotation_ : __null;
19338 void setAnnotation(void *annot) {
19339 flags_ |= JSFRAME_HAS_ANNOTATION;
19340 annotation_ = annot;
19345 bool hasHookData() const {
19346 return !!(flags_ & JSFRAME_HAS_HOOK_DATA);
19349 void* hookData() const {
19354 void* maybeHookData() const {
19355 return hasHookData() ? hookData_ : __null;
19358 void setHookData(void *v) {
19360 flags_ |= JSFRAME_HAS_HOOK_DATA;
19365 const js::Value &returnValue() {
19366 if (!(flags_ & JSFRAME_HAS_RVAL))
19367 rval_.setUndefined();
19371 void markReturnValue() {
19372 flags_ |= JSFRAME_HAS_RVAL;
19375 void setReturnValue(const js::Value &v) {
19380 void clearReturnValue() {
19381 rval_.setUndefined();
19387 void *nativeReturnAddress() const {
19391 void setNativeReturnAddress(void *addr) {
19395 void **addressOfNativeReturnAddress() {
19399 bool isGeneratorFrame() const {
19400 return !!(flags_ & JSFRAME_GENERATOR);
19403 bool isFloatingGenerator() const {
19405 return !!(flags_ & JSFRAME_FLOATING_GENERATOR);
19408 void initFloatingGenerator() {
19410 flags_ |= (JSFRAME_GENERATOR | JSFRAME_FLOATING_GENERATOR);
19413 void unsetFloatingGenerator() {
19414 flags_ &= ~JSFRAME_FLOATING_GENERATOR;
19417 void setFloatingGenerator() {
19418 flags_ |= JSFRAME_FLOATING_GENERATOR;
19425 bool isConstructing() const {
19426 return !!(flags_ & JSFRAME_CONSTRUCTING);
19429 uint32 isConstructingFlag() const {
19435 bool isDebuggerFrame() const {
19436 return !!(flags_ & JSFRAME_DEBUGGER);
19439 bool isEvalOrDebuggerFrame() const {
19440 return !!(flags_ & (JSFRAME_EVAL | JSFRAME_DEBUGGER));
19443 bool hasOverriddenArgs() const {
19444 return !!(flags_ & JSFRAME_OVERRIDE_ARGS);
19447 bool hasOverflowArgs() const {
19448 return !!(flags_ & JSFRAME_OVERFLOW_ARGS);
19451 void setOverriddenArgs() {
19452 flags_ |= JSFRAME_OVERRIDE_ARGS;
19455 bool isAssigning() const {
19456 return !!(flags_ & JSFRAME_ASSIGNING);
19459 void setAssigning() {
19460 flags_ |= JSFRAME_ASSIGNING;
19463 void clearAssigning() {
19464 flags_ &= ~JSFRAME_ASSIGNING;
19467 bool isYielding() {
19468 return !!(flags_ & JSFRAME_YIELDING);
19471 void setYielding() {
19472 flags_ |= JSFRAME_YIELDING;
19475 void clearYielding() {
19476 flags_ &= ~JSFRAME_YIELDING;
19479 void setFinishedInInterpreter() {
19480 flags_ |= JSFRAME_FINISHED_IN_INTERPRETER;
19483 bool finishedInInterpreter() const {
19484 return !!(flags_ & JSFRAME_FINISHED_IN_INTERPRETER);
19487 inline JSObject &varobj(js::StackSegment *seg) const;
19488 inline JSObject &varobj(JSContext *cx) const;
19492 static size_t offsetOfFlags() {
19493 return __builtin_offsetof (JSStackFrame, flags_);
19496 static size_t offsetOfExec() {
19497 return __builtin_offsetof (JSStackFrame, exec);
19500 void *addressOfArgs() {
19504 static size_t offsetOfScopeChain() {
19505 return __builtin_offsetof (JSStackFrame, scopeChain_);
19508 JSObject **addressOfScopeChain() {
19510 return &scopeChain_;
19513 static size_t offsetOfPrev() {
19514 return __builtin_offsetof (JSStackFrame, prev_);
19517 static size_t offsetOfReturnValue() {
19518 return __builtin_offsetof (JSStackFrame, rval_);
19521 static ptrdiff_t offsetOfncode() {
19522 return __builtin_offsetof (JSStackFrame, ncode_);
19525 static ptrdiff_t offsetOfCallee(JSFunction *fun) {
19527 return -(fun->nargs + 2) * sizeof(js::Value);
19530 static ptrdiff_t offsetOfThis(JSFunction *fun) {
19531 return fun == __null
19532 ? -1 * ptrdiff_t(sizeof(js::Value))
19533 : -(fun->nargs + 1) * ptrdiff_t(sizeof(js::Value));
19536 static ptrdiff_t offsetOfFormalArg(JSFunction *fun, uintN i) {
19538 return (-(int)fun->nargs + i) * sizeof(js::Value);
19541 static size_t offsetOfFixed(uintN i) {
19542 return sizeof(JSStackFrame) + i * sizeof(js::Value);
19547 void staticAsserts() {
19548 typedef int js_static_assert61[(__builtin_offsetof (JSStackFrame, rval_) % sizeof(js::Value) == 0) ? 1 : -1];
19549 typedef int js_static_assert62[(sizeof(JSStackFrame) % sizeof(js::Value) == 0) ? 1 : -1];
19558 void methodjitStaticAsserts();
19568 static const size_t VALUES_PER_STACK_FRAME = sizeof(JSStackFrame) / sizeof(Value);
19571 GetBlockChain(JSContext *cx, JSStackFrame *fp);
19574 GetBlockChainFast(JSContext *cx, JSStackFrame *fp, JSOp op, size_t oplen);
19577 GetScopeChain(JSContext *cx);
19580 GetScopeChain(JSContext *cx, JSStackFrame *fp);
19583 GetScopeChainFast(JSContext *cx, JSStackFrame *fp, JSOp op, size_t oplen);
19590 ReportIncompatibleMethod(JSContext *cx, Value *vp, Class *clasp);
19592 template <typename T>
19593 bool GetPrimitiveThis(JSContext *cx, Value *vp, T *v);
19596 PutActivationObjects(JSContext *cx, JSStackFrame *fp);
19599 PutOwnedActivationObjects(JSContext *cx, JSStackFrame *fp);
19611 BoxThisForVp(JSContext *cx, js::Value *vp);
19623 CallArgs(Value *argv, uintN argc) : argv_(argv), argc_(argc) {}
19625 Value *base() const { return argv_ - 2; }
19626 Value &callee() const { return argv_[-2]; }
19627 Value &thisv() const { return argv_[-1]; }
19628 Value &operator[](unsigned i) const { ((void) 0); return argv_[i]; }
19629 Value *argv() const { return argv_; }
19630 uintN argc() const { return argc_; }
19631 Value &rval() const { return argv_[-2]; }
19638 Invoke(JSContext *cx, const CallArgs &args, uint32 flags);
19640 class InvokeSessionGuard;
19646 ExternalInvoke(JSContext *cx, const Value &thisv, const Value &fval,
19647 uintN argc, Value *argv, Value *rval);
19653 ExternalGetOrSet(JSContext *cx, JSObject *obj, jsid id, const Value &fval,
19654 JSAccessMode mode, uintN argc, Value *argv, Value *rval);
19660 InvokeConstructor(JSContext *cx, const CallArgs &args);
19666 InvokeConstructorWithGivenThis(JSContext *cx, JSObject *thisobj, const Value &fval,
19667 uintN argc, Value *argv, Value *rval);
19673 ExternalInvokeConstructor(JSContext *cx, const Value &fval, uintN argc, Value *argv,
19680 DirectEval(JSContext *cx, JSFunction *evalfun, uint32 argc, Value *vp);
19686 DirectEval(JSContext *cx, JSFunction *evalfun, uint32 argc, Value *vp);
19696 Execute(JSContext *cx, JSObject *chain, JSScript *script,
19697 JSStackFrame *prev, uintN flags, Value *result);
19703 extern __attribute__((noinline))
19707 Interpret(JSContext *cx, JSStackFrame *stopFp, uintN inlineCallCount = 0, JSInterpMode mode = JSINTERP_NORMAL);
19711 # 1000 "jsinterp.h"
19713 RunScript(JSContext *cx, JSScript *script, JSStackFrame *fp);
19717 # 1003 "jsinterp.h"
19719 CheckRedeclaration(JSContext *cx, JSObject *obj, jsid id, uintN attrs);
19723 # 1006 "jsinterp.h"
19725 StrictlyEqual(JSContext *cx, const Value &lval, const Value &rval, JSBool *equal);
19730 # 1010 "jsinterp.h"
19732 SameValue(JSContext *cx, const Value &v1, const Value &v2, JSBool *same);
19735 TypeOfValue(JSContext *cx, const Value &v);
19739 # 1016 "jsinterp.h"
19741 InstanceOf(JSContext *cx, JSObject *obj, Class *clasp, Value *argv)
19743 if (obj && obj->getClass() == clasp)
19745 extern bool InstanceOfSlow(JSContext *, JSObject *, Class *, Value *);
19746 return InstanceOfSlow(cx, obj, clasp, argv);
19750 HasInstance(JSContext *cx, JSObject *obj, const js::Value *v, JSBool *bp);
19753 GetInstancePrivate(JSContext *cx, JSObject *obj, Class *clasp, Value *argv)
19755 if (!InstanceOf(cx, obj, clasp, argv))
19757 return obj->getPrivate();
19762 # 1036 "jsinterp.h"
19764 ValueToId(JSContext *cx, const Value &v, jsid *idp);
19765 # 1046 "jsinterp.h"
19766 extern const js::Value &
19767 GetUpvar(JSContext *cx, uintN level, js::UpvarCookie cookie);
19770 # 1077 "jsinterp.h"
19772 js_EnterWith(JSContext *cx, jsint stackIndex, JSOp op, size_t oplen);
19775 js_LeaveWith(JSContext *cx);
19784 js_DoIncDec(JSContext *cx, const JSCodeSpec *cs, js::Value *vp, js::Value *vp2);
19791 js_LogOpcode(JSContext *cx);
19797 js_MeterOpcodePair(JSOp op1, JSOp op2);
19800 js_MeterSlotOpcode(JSOp op, uint32 slot);
19808 js_UnwindScope(JSContext *cx, jsint stackDepth, JSBool normalUnwind);
19811 js_OnUnknownMethod(JSContext *cx, js::Value *vp);
19814 js_IsActiveWithOrBlock(JSContext *cx, JSObject *obj, int stackDepth);
19820 typedef double (*UnaryFunType)(double);
19824 static const unsigned SizeLog2 = 12;
19825 static const unsigned Size = 1 << SizeLog2;
19826 struct Entry { double in; UnaryFunType f; double out; };
19832 uintN hash(double x) {
19833 union { double d; struct { uint32 one, two; } s; } u = { x };
19834 uint32 hash32 = u.s.one ^ u.s.two;
19835 uint16 hash16 = (uint16)(hash32 ^ (hash32 >> 16));
19836 return (hash16 & (Size - 1)) ^ (hash16 >> (16 - SizeLog2));
19843 double lookup(UnaryFunType f, double x) {
19844 uintN index = hash(x);
19845 Entry &e = table[index];
19846 if (e.in == x && e.f == f)
19850 return (e.out = f(x));
19860 extern js::Class js_MathClass;
19863 js_InitMathClass(JSContext *cx, JSObject *obj);
19869 js_IsMathFunction(JSNative native);
19872 js_InitRandom(JSContext *cx);
19875 js_math_abs(JSContext *cx, uintN argc, js::Value *vp);
19878 js_math_ceil(JSContext *cx, uintN argc, js::Value *vp);
19881 js_math_floor(JSContext *cx, uintN argc, js::Value *vp);
19884 js_math_max(JSContext *cx, uintN argc, js::Value *vp);
19887 js_math_min(JSContext *cx, uintN argc, js::Value *vp);
19890 js_math_round(JSContext *cx, uintN argc, js::Value *vp);
19893 js_math_ceil_impl(jsdouble x);
19896 js_math_floor_impl(jsdouble x);
19899 js_math_round_impl(jsdouble x);
19902 # 1 "jspropertycache.h" 1
19903 # 48 "jspropertycache.h"
19905 # 57 "jspropertycache.h"
19907 PCVCAP_PROTOBITS = 4,
19908 PCVCAP_PROTOSIZE = ((JSUint32)1 << (PCVCAP_PROTOBITS)),
19909 PCVCAP_PROTOMASK = (((JSUint32)1 << (PCVCAP_PROTOBITS)) - 1),
19911 PCVCAP_SCOPEBITS = 4,
19912 PCVCAP_SCOPESIZE = ((JSUint32)1 << (PCVCAP_SCOPEBITS)),
19913 PCVCAP_SCOPEMASK = (((JSUint32)1 << (PCVCAP_SCOPEBITS)) - 1),
19915 PCVCAP_TAGBITS = PCVCAP_PROTOBITS + PCVCAP_SCOPEBITS,
19916 PCVCAP_TAGMASK = (((JSUint32)1 << (PCVCAP_TAGBITS)) - 1)
19919 const uint32 SHAPE_OVERFLOW_BIT = ((JSUint32)1 << (32 - PCVCAP_TAGBITS));
19920 # 81 "jspropertycache.h"
19934 bool isNull() const { return v == 0; }
19935 void setNull() { v = 0; }
19937 bool isFunObj() const { return (v & TAG) == OBJECT; }
19938 JSObject &toFunObj() const {
19940 return *reinterpret_cast<JSObject *>(v);
19942 void setFunObj(JSObject &obj) {
19943 v = reinterpret_cast<jsuword>(&obj);
19946 bool isSlot() const { return v & SLOT; }
19947 uint32 toSlot() const { ((void) 0); return uint32(v) >> 1; }
19948 void setSlot(uint32 slot) { v = (jsuword(slot) << 1) | SLOT; }
19950 bool isShape() const { return (v & TAG) == SHAPE; }
19951 const js::Shape *toShape() const {
19953 return reinterpret_cast<js::Shape *>(v & ~TAG);
19955 void setShape(const js::Shape *shape) {
19957 v = reinterpret_cast<jsuword>(shape) | SHAPE;
19961 struct PropertyCacheEntry
19968 bool adding() const { return vcapTag() == 0 && kshape != vshape(); }
19969 bool directHit() const { return vcapTag() == 0 && kshape == vshape(); }
19971 jsuword vcapTag() const { return vcap & PCVCAP_TAGMASK; }
19972 uint32 vshape() const { return uint32(vcap >> PCVCAP_TAGBITS); }
19973 jsuword scopeIndex() const { return (vcap >> PCVCAP_PROTOBITS) & PCVCAP_SCOPEMASK; }
19974 jsuword protoIndex() const { return vcap & PCVCAP_PROTOMASK; }
19976 void assign(jsbytecode *kpc, jsuword kshape, jsuword vshape,
19977 uintN scopeIndex, uintN protoIndex, PCVal vword) {
19984 this->kshape = kshape;
19985 this->vcap = (vshape << PCVCAP_TAGBITS) | (scopeIndex << PCVCAP_PROTOBITS) | protoIndex;
19986 this->vword = vword;
19989 # 160 "jspropertycache.h"
19990 class PropertyCache
19995 SIZE = ((JSUint32)1 << (SIZE_LOG2)),
19996 MASK = (((JSUint32)1 << (SIZE_LOG2)) - 1)
19999 PropertyCacheEntry table[SIZE];
20001 # 214 "jspropertycache.h"
20002 static inline jsuword
20003 hash(jsbytecode *pc, jsuword kshape)
20005 return ((((jsuword(pc) >> SIZE_LOG2) ^ jsuword(pc)) + kshape) & MASK);
20008 static inline bool matchShape(JSContext *cx, JSObject *obj, uint32 shape);
20010 JSAtom *fullTest(JSContext *cx, jsbytecode *pc, JSObject **objp,
20011 JSObject **pobjp, PropertyCacheEntry *entry);
20016 inline void assertEmpty() {}
20020 __attribute__((always_inline)) inline void test(JSContext *cx, jsbytecode *pc,
20021 JSObject *&obj, JSObject *&pobj,
20022 PropertyCacheEntry *&entry, JSAtom *&atom);
20023 # 243 "jspropertycache.h"
20024 __attribute__((always_inline)) inline bool testForSet(JSContext *cx, jsbytecode *pc, JSObject *obj,
20025 PropertyCacheEntry **entryp, JSObject **obj2p,
20027 # 256 "jspropertycache.h"
20028 __attribute__((always_inline)) inline bool testForInit(JSRuntime *rt, jsbytecode *pc, JSObject *obj,
20029 const js::Shape **shapep, PropertyCacheEntry **entryp);
20030 # 267 "jspropertycache.h"
20031 PropertyCacheEntry *fill(JSContext *cx, JSObject *obj, uintN scopeIndex,
20032 uintN protoIndex, JSObject *pobj,
20033 const js::Shape *shape, JSBool adding = false);
20035 void purge(JSContext *cx);
20036 void purgeForScript(JSContext *cx, JSScript *script);
20041 # 1 "jspropertytree.h" 1
20042 # 47 "jspropertytree.h"
20045 struct ShapeHasher {
20046 typedef js::Shape *Key;
20047 typedef const js::Shape *Lookup;
20049 static inline HashNumber hash(const Lookup l);
20050 static inline bool match(Key k, Lookup l);
20053 typedef HashSet<js::Shape *, ShapeHasher, SystemAllocPolicy> KidsHash;
20055 class KidsPointer {
20066 bool isNull() const { return !w; }
20067 void setNull() { w = 0; }
20069 bool isShape() const { return (w & TAG) == SHAPE && !isNull(); }
20070 js::Shape *toShape() const {
20072 return reinterpret_cast<js::Shape *>(w & ~jsuword(TAG));
20074 void setShape(js::Shape *shape) {
20077 w = reinterpret_cast<jsuword>(shape) | SHAPE;
20080 bool isHash() const { return (w & TAG) == HASH; }
20081 KidsHash *toHash() const {
20083 return reinterpret_cast<KidsHash *>(w & ~jsuword(TAG));
20085 void setHash(KidsHash *hash) {
20088 w = reinterpret_cast<jsuword>(hash) | HASH;
20098 friend struct ::JSFunction;
20100 JSCompartment *compartment;
20101 JSArenaPool arenaPool;
20102 js::Shape *freeList;
20104 bool insertChild(JSContext *cx, js::Shape *parent, js::Shape *child);
20105 void removeChild(js::Shape *child);
20110 enum { MAX_HEIGHT = 128 };
20112 PropertyTree(JSCompartment *comp)
20113 : compartment(comp), freeList(__null)
20115 PodZero(&arenaPool);
20121 js::Shape *newShapeUnchecked();
20122 js::Shape *newShape(JSContext *cx);
20123 js::Shape *getChild(JSContext *cx, js::Shape *parent, const js::Shape &child);
20125 void orphanChildren(js::Shape *shape);
20126 void sweepShapes(JSContext *cx);
20127 void unmarkShapes(JSContext *cx);
20129 static void dumpShapes(JSContext *cx);
20143 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 1 3 4
20144 # 29 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 3 4
20153 # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4
20154 # 38 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 2 3 4
20158 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/time.h" 1 3 4
20159 # 88 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/time.h" 3 4
20160 # 1 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/timex.h" 1 3 4
20161 # 25 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/timex.h" 3 4
20164 unsigned int modes;
20165 __syscall_slong_t offset;
20166 __syscall_slong_t freq;
20167 __syscall_slong_t maxerror;
20168 __syscall_slong_t esterror;
20170 __syscall_slong_t constant;
20171 __syscall_slong_t precision;
20172 __syscall_slong_t tolerance;
20173 struct timeval time;
20174 __syscall_slong_t tick;
20175 __syscall_slong_t ppsfreq;
20176 __syscall_slong_t jitter;
20178 __syscall_slong_t stabil;
20179 __syscall_slong_t jitcnt;
20180 __syscall_slong_t calcnt;
20181 __syscall_slong_t errcnt;
20182 __syscall_slong_t stbcnt;
20187 int :32; int :32; int :32; int :32;
20188 int :32; int :32; int :32; int :32;
20189 int :32; int :32; int :32;
20191 # 89 "/usr/powerpc64-unknown-linux-gnu/usr/include/bits/time.h" 2 3 4
20196 extern int clock_adjtime (__clockid_t __clock_id, struct timex *__utx) throw ();
20199 # 42 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 2 3 4
20200 # 131 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 3 4
20216 long int tm_gmtoff;
20217 const char *tm_zone;
20233 struct timespec it_interval;
20234 struct timespec it_value;
20239 # 186 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 3 4
20243 extern clock_t clock (void) throw ();
20246 extern time_t time (time_t *__timer) throw ();
20249 extern double difftime (time_t __time1, time_t __time0)
20250 throw () __attribute__ ((__const__));
20253 extern time_t mktime (struct tm *__tp) throw ();
20259 extern size_t strftime (char *__restrict __s, size_t __maxsize,
20260 const char *__restrict __format,
20261 const struct tm *__restrict __tp) throw ();
20267 extern char *strptime (const char *__restrict __s,
20268 const char *__restrict __fmt, struct tm *__tp)
20277 extern size_t strftime_l (char *__restrict __s, size_t __maxsize,
20278 const char *__restrict __format,
20279 const struct tm *__restrict __tp,
20280 __locale_t __loc) throw ();
20284 extern char *strptime_l (const char *__restrict __s,
20285 const char *__restrict __fmt, struct tm *__tp,
20286 __locale_t __loc) throw ();
20293 extern struct tm *gmtime (const time_t *__timer) throw ();
20297 extern struct tm *localtime (const time_t *__timer) throw ();
20303 extern struct tm *gmtime_r (const time_t *__restrict __timer,
20304 struct tm *__restrict __tp) throw ();
20308 extern struct tm *localtime_r (const time_t *__restrict __timer,
20309 struct tm *__restrict __tp) throw ();
20315 extern char *asctime (const struct tm *__tp) throw ();
20318 extern char *ctime (const time_t *__timer) throw ();
20326 extern char *asctime_r (const struct tm *__restrict __tp,
20327 char *__restrict __buf) throw ();
20330 extern char *ctime_r (const time_t *__restrict __timer,
20331 char *__restrict __buf) throw ();
20336 extern char *__tzname[2];
20337 extern int __daylight;
20338 extern long int __timezone;
20343 extern char *tzname[2];
20347 extern void tzset (void) throw ();
20351 extern int daylight;
20352 extern long int timezone;
20358 extern int stime (const time_t *__when) throw ();
20359 # 319 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 3 4
20360 extern time_t timegm (struct tm *__tp) throw ();
20363 extern time_t timelocal (struct tm *__tp) throw ();
20366 extern int dysize (int __year) throw () __attribute__ ((__const__));
20367 # 334 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 3 4
20368 extern int nanosleep (const struct timespec *__requested_time,
20369 struct timespec *__remaining);
20373 extern int clock_getres (clockid_t __clock_id, struct timespec *__res) throw ();
20376 extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) throw ();
20379 extern int clock_settime (clockid_t __clock_id, const struct timespec *__tp)
20387 extern int clock_nanosleep (clockid_t __clock_id, int __flags,
20388 const struct timespec *__req,
20389 struct timespec *__rem);
20392 extern int clock_getcpuclockid (pid_t __pid, clockid_t *__clock_id) throw ();
20397 extern int timer_create (clockid_t __clock_id,
20398 struct sigevent *__restrict __evp,
20399 timer_t *__restrict __timerid) throw ();
20402 extern int timer_delete (timer_t __timerid) throw ();
20405 extern int timer_settime (timer_t __timerid, int __flags,
20406 const struct itimerspec *__restrict __value,
20407 struct itimerspec *__restrict __ovalue) throw ();
20410 extern int timer_gettime (timer_t __timerid, struct itimerspec *__value)
20414 extern int timer_getoverrun (timer_t __timerid) throw ();
20420 extern int timespec_get (struct timespec *__ts, int __base)
20421 throw () __attribute__ ((__nonnull__ (1)));
20422 # 403 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 3 4
20423 extern int getdate_err;
20424 # 412 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 3 4
20425 extern struct tm *getdate (const char *__string);
20426 # 426 "/usr/powerpc64-unknown-linux-gnu/usr/include/time.h" 3 4
20427 extern int getdate_r (const char *__restrict __string,
20428 struct tm *__restrict __resbufp);
20432 # 47 "prmjtime.h" 2
20441 class DSTOffsetCache {
20443 inline DSTOffsetCache();
20444 JSInt64 getDSTOffsetMilliseconds(int64 localTimeMilliseconds, JSContext *cx);
20446 inline void purge();
20452 JSInt64 computeDSTOffsetMilliseconds(int64 localTimeSeconds);
20454 JSInt64 offsetMilliseconds;
20455 JSInt64 rangeStartSeconds, rangeEndSeconds;
20457 JSInt64 oldOffsetMilliseconds;
20458 JSInt64 oldRangeStartSeconds, oldRangeEndSeconds;
20460 static const JSInt64 MAX_UNIX_TIMET = 2145859200;
20461 static const JSInt64 MILLISECONDS_PER_SECOND = 1000;
20462 static const JSInt64 SECONDS_PER_MINUTE = 60;
20463 static const JSInt64 SECONDS_PER_HOUR = 60 * SECONDS_PER_MINUTE;
20464 static const JSInt64 SECONDS_PER_DAY = 24 * SECONDS_PER_HOUR;
20466 static const JSInt64 RANGE_EXPANSION_AMOUNT = 30 * SECONDS_PER_DAY;
20469 void sanityCheck();
20476 void noteOffsetCalculation() {
20479 void noteCacheHit() {
20482 void noteCacheMissIncrease() {
20485 void noteCacheMissDecrease() {
20488 void noteCacheMissIncreasingOffsetChangeUpper() {
20491 void noteCacheMissIncreasingOffsetChangeExpand() {
20494 void noteCacheMissLargeIncrease() {
20497 void noteCacheMissDecreasingOffsetChangeLower() {
20500 void noteCacheMissDecreasingOffsetChangeExpand() {
20503 void noteCacheMissLargeDecrease() {
20511 typedef struct PRMJTime PRMJTime;
20538 PRMJ_LocalGMTDifference(void);
20542 PRMJ_FormatTime(char *buf, int buflen, const char *fmt, PRMJTime *tm);
20547 typedef struct JSGSNCache {
20549 JSDHashTable table;
20556 js_PurgeGSNCache(JSGSNCache *cache);
20563 namespace nanojit {
20568 template<typename K> struct DefaultHash;
20569 template<typename K, typename V, typename H> class HashMap;
20570 template<typename T> class Seq;
20577 static const size_t MONITOR_N_GLOBAL_STATES = 4;
20578 static const size_t FRAGMENT_TABLE_SIZE = 512;
20579 static const size_t MAX_NATIVE_STACK_SLOTS = 4096;
20580 static const size_t MAX_CALL_STACK_ENTRIES = 500;
20581 static const size_t MAX_GLOBAL_SLOTS = 4096;
20582 static const size_t GLOBAL_SLOTS_BUFFER_SIZE = MAX_GLOBAL_SLOTS + 1;
20583 static const size_t MAX_SLOW_NATIVE_EXTRA_SLOTS = 16;
20587 class FrameInfoCache;
20590 struct TreeFragment;
20591 struct TracerState;
20592 template<typename T> class Queue;
20593 typedef Queue<uint16> SlotList;
20603 class JaegerCompartment;
20612 class ContextAllocPolicy
20617 ContextAllocPolicy(JSContext *cx) : cx(cx) {}
20618 JSContext *context() const { return cx; }
20621 void *malloc(size_t bytes);
20622 void free(void *p);
20623 void *realloc(void *p, size_t bytes);
20624 void reportAllocOverflow() const;
20633 StackSegment *previousInContext;
20636 StackSegment *previousInMemory;
20639 JSStackFrame *initialFrame;
20642 JSFrameRegs *suspendedRegs;
20645 JSObject *initialVarObj;
20652 : cx(__null), previousInContext(__null), previousInMemory(__null),
20653 initialFrame(__null), suspendedRegs(((JSFrameRegs *)0x1)),
20654 initialVarObj(__null), saved(false)
20661 Value *valueRangeBegin() const {
20662 return (Value *)(this + 1);
20665 bool inContext() const {
20671 bool isActive() const {
20674 return !suspendedRegs;
20677 bool isSuspended() const {
20680 return cx && suspendedRegs;
20685 bool isSaved() const {
20692 void joinContext(JSContext *cx, JSStackFrame *f) {
20696 suspendedRegs = __null;
20700 void leaveContext() {
20703 initialFrame = __null;
20704 suspendedRegs = ((JSFrameRegs *)0x1);
20708 JSContext *maybeContext() const {
20716 void suspend(JSFrameRegs *regs) {
20719 suspendedRegs = regs;
20725 suspendedRegs = __null;
20731 void save(JSFrameRegs *regs) {
20747 JSStackFrame *getInitialFrame() const {
20749 return initialFrame;
20752 inline JSFrameRegs *getCurrentRegs() const;
20753 inline JSStackFrame *getCurrentFrame() const;
20757 JSFrameRegs *getSuspendedRegs() const {
20759 return suspendedRegs;
20762 JSStackFrame *getSuspendedFrame() const {
20763 return suspendedRegs->fp;
20768 void setPreviousInContext(StackSegment *seg) {
20769 previousInContext = seg;
20772 StackSegment *getPreviousInContext() const {
20773 return previousInContext;
20776 void setPreviousInMemory(StackSegment *seg) {
20777 previousInMemory = seg;
20780 StackSegment *getPreviousInMemory() const {
20781 return previousInMemory;
20784 void setInitialVarObj(JSObject *obj) {
20786 initialVarObj = obj;
20789 bool hasInitialVarObj() {
20791 return initialVarObj != __null;
20794 JSObject &getInitialVarObj() const {
20796 return *initialVarObj;
20804 static const size_t VALUES_PER_STACK_SEGMENT = sizeof(StackSegment) / sizeof(Value);
20805 typedef int js_static_assert63[(sizeof(StackSegment) % sizeof(Value) == 0) ? 1 : -1];
20808 class InvokeArgsGuard : public CallArgs
20810 friend class StackSpace;
20813 Value *prevInvokeArgEnd;
20819 InvokeArgsGuard() : cx(__null), seg(__null) {}
20820 ~InvokeArgsGuard();
20821 bool pushed() const { return cx != __null; }
20828 struct InvokeArgsAlreadyOnTheStack : CallArgs
20830 InvokeArgsAlreadyOnTheStack(Value *vp, uintN argc) : CallArgs(vp + 2, argc) {}
20834 class InvokeFrameGuard
20836 friend class StackSpace;
20839 JSFrameRegs *prevRegs_;
20841 InvokeFrameGuard() : cx_(__null) {}
20842 ~InvokeFrameGuard() { if (pushed()) pop(); }
20843 bool pushed() const { return cx_ != __null; }
20844 JSContext *pushedFrameContext() const { ((void) 0); return cx_; }
20846 JSStackFrame *fp() const { return regs_.fp; }
20852 friend class StackSpace;
20854 StackSegment *seg_;
20858 FrameGuard() : cx_(__null), vp_(__null), fp_(__null) {}
20860 bool pushed() const { return cx_ != __null; }
20861 StackSegment *segment() const { return seg_; }
20862 Value *vp() const { return vp_; }
20863 JSStackFrame *fp() const { return fp_; }
20867 class ExecuteFrameGuard : public FrameGuard
20869 friend class StackSpace;
20874 class DummyFrameGuard : public FrameGuard
20876 friend class StackSpace;
20881 class GeneratorFrameGuard : public FrameGuard
20891 StackSegment *currentSegment;
20893 Value *invokeArgEnd;
20895 friend class InvokeArgsGuard;
20896 friend class InvokeFrameGuard;
20897 friend class FrameGuard;
20899 bool pushSegmentForInvoke(JSContext *cx, uintN argc, InvokeArgsGuard *ag);
20900 void popSegmentForInvoke(const InvokeArgsGuard &ag);
20902 bool pushInvokeFrameSlow(JSContext *cx, const InvokeArgsGuard &ag,
20903 InvokeFrameGuard *fg);
20904 void popInvokeFrameSlow(const CallArgs &args);
20906 bool getSegmentAndFrame(JSContext *cx, uintN vplen, uintN nslots,
20907 FrameGuard *fg) const;
20908 void pushSegmentAndFrame(JSContext *cx, JSFrameRegs *regs, FrameGuard *fg);
20909 void popSegmentAndFrame(JSContext *cx);
20911 struct EnsureSpaceCheck {
20912 inline bool operator()(const StackSpace &, JSContext *, Value *, uintN);
20915 struct LimitCheck {
20916 JSStackFrame *base;
20918 LimitCheck(JSStackFrame *base, Value **limit) : base(base), limit(limit) {}
20919 inline bool operator()(const StackSpace &, JSContext *, Value *, uintN);
20922 template <class Check>
20923 inline JSStackFrame *getCallFrame(JSContext *cx, Value *sp, uintN nactual,
20924 JSFunction *fun, JSScript *script,
20925 uint32 *pflags, Check check) const;
20927 inline void popInvokeArgs(const InvokeArgsGuard &args);
20928 inline void popInvokeFrame(const InvokeFrameGuard &ag);
20930 inline Value *firstUnused() const;
20932 inline bool isCurrentAndActive(JSContext *cx) const;
20933 friend class AllFramesIter;
20934 StackSegment *getCurrentSegment() const { return currentSegment; }
20942 static const size_t CAPACITY_VALS = 512 * 1024;
20943 static const size_t CAPACITY_BYTES = CAPACITY_VALS * sizeof(Value);
20944 static const size_t COMMIT_VALS = 16 * 1024;
20945 static const size_t COMMIT_BYTES = COMMIT_VALS * sizeof(Value);
20947 static const size_t STACK_QUOTA = (VALUES_PER_STACK_FRAME + 18) *
20954 inline bool ensureEnoughSpaceToEnterTrace();
20957 static const ptrdiff_t MAX_TRACE_SPACE_VALS =
20958 MAX_NATIVE_STACK_SLOTS + MAX_CALL_STACK_ENTRIES * VALUES_PER_STACK_FRAME +
20959 (VALUES_PER_STACK_SEGMENT + VALUES_PER_STACK_FRAME );
20962 void mark(JSTracer *trc);
20964 bool pushInvokeArgs(JSContext *cx, uintN argc, InvokeArgsGuard *ag);
20967 bool getInvokeFrame(JSContext *cx, const CallArgs &args, JSFunction *fun,
20968 JSScript *script, uint32 *flags, InvokeFrameGuard *fg) const;
20970 void pushInvokeFrame(JSContext *cx, const CallArgs &args, InvokeFrameGuard *fg);
20973 bool getExecuteFrame(JSContext *cx, JSScript *script, ExecuteFrameGuard *fg) const;
20974 void pushExecuteFrame(JSContext *cx, JSObject *initialVarObj, ExecuteFrameGuard *fg);
20980 inline JSStackFrame *getInlineFrame(JSContext *cx, Value *sp, uintN nactual,
20981 JSFunction *fun, JSScript *script,
20982 uint32 *flags) const;
20983 inline void pushInlineFrame(JSContext *cx, JSScript *script, JSStackFrame *fp,
20984 JSFrameRegs *regs);
20985 inline void popInlineFrame(JSContext *cx, JSStackFrame *prev, js::Value *newsp);
20988 bool getGeneratorFrame(JSContext *cx, uintN vplen, uintN nslots,
20989 GeneratorFrameGuard *fg);
20990 void pushGeneratorFrame(JSContext *cx, JSFrameRegs *regs, GeneratorFrameGuard *fg);
20993 bool pushDummyFrame(JSContext *cx, JSObject &scopeChain, DummyFrameGuard *fg);
20996 inline JSStackFrame *getInlineFrameWithinLimit(JSContext *cx, Value *sp, uintN nactual,
20997 JSFunction *fun, JSScript *script, uint32 *flags,
20998 JSStackFrame *base, Value **limit) const;
21005 inline Value *getStackLimit(JSContext *cx);
21011 bool bumpCommitAndLimit(JSStackFrame *base, Value *from, uintN nvals, Value **limit) const;
21017 inline bool ensureSpace(JSContext *maybecx, Value *from, ptrdiff_t nvals) const;
21020 typedef int js_static_assert64[(StackSpace::CAPACITY_VALS % StackSpace::COMMIT_VALS == 0) ? 1 : -1];
21022 class FrameRegsIter
21025 StackSegment *curseg;
21026 JSStackFrame *curfp;
21031 void incSlow(JSStackFrame *fp, JSStackFrame *prev);
21034 inline FrameRegsIter(JSContext *cx);
21036 bool done() const { return curfp == __null; }
21037 inline FrameRegsIter &operator++();
21039 JSStackFrame *fp() const { return curfp; }
21040 Value *sp() const { return cursp; }
21041 jsbytecode *pc() const { return curpc; }
21047 class AllFramesIter
21050 AllFramesIter(JSContext *cx);
21052 bool done() const { return curfp == __null; }
21053 AllFramesIter& operator++();
21055 JSStackFrame *fp() const { return curfp; }
21058 StackSegment *curcs;
21059 JSStackFrame *curfp;
21064 struct JSPendingProxyOperation {
21065 JSPendingProxyOperation *next;
21069 struct JSThreadData {
21072 unsigned requestDepth;
21074 volatile int32 interruptFlags;
21077 js::StackSpace stackSpace;
21089 JSGSNCache gsnCache;
21092 js::PropertyCache propertyCache;
21100 DtoaState *dtoaState;
21103 jsuword *nativeStackBase;
21106 JSPendingProxyOperation *pendingProxyOperation;
21108 js::ConservativeGCThreadData conservativeGC;
21112 void mark(JSTracer *trc);
21113 void purge(JSContext *cx);
21116 inline void triggerOperationCallback(JSRuntime *rt);
21126 typedef js::HashMap<void *,
21128 js::DefaultHasher<void *>,
21129 js::SystemAllocPolicy> Map;
21132 JSCList contextList;
21138 unsigned suspendCount;
21151 js_CurrentThread(JSRuntime *rt);
21159 js_InitContextThread(JSContext *cx);
21165 js_ClearContextThread(JSContext *cx);
21169 typedef enum JSDestroyContextMode {
21174 } JSDestroyContextMode;
21176 typedef enum JSRuntimeState {
21183 typedef struct JSPropertyTreeEntry {
21184 JSDHashEntryHdr hdr;
21186 } JSPropertyTreeEntry;
21189 (* JSActivityCallback)(void *arg, JSBool active);
21193 typedef js::Vector<JSCompartment *, 0, js::SystemAllocPolicy> WrapperVector;
21199 JSCompartment *atomsCompartment;
21201 bool atomsCompartmentIsLocked;
21205 js::WrapperVector compartments;
21208 JSRuntimeState state;
21211 JSContextCallback cxCallback;
21214 JSCompartmentCallback compartmentCallback;
21222 void setActivityCallback(JSActivityCallback cb, void *arg) {
21223 activityCallback = cb;
21224 activityCallbackArg = arg;
21227 JSActivityCallback activityCallback;
21228 void *activityCallbackArg;
21230 uint32 protoHazardShape;
21233 js::GCChunkSet gcChunkSet;
21235 js::RootedValueMap gcRootsHash;
21236 js::GCLocks gcLocksHash;
21237 jsrefcount gcKeepAtoms;
21239 size_t gcTriggerBytes;
21240 size_t gcLastBytes;
21242 size_t gcMaxMallocBytes;
21243 size_t gcChunksWaitingToExpire;
21244 uint32 gcEmptyArenaPoolLifespan;
21246 js::GCMarker *gcMarkingTracer;
21247 uint32 gcTriggerFactor;
21248 int64 gcJitReleaseTime;
21250 volatile bool gcIsNeeded;
21256 JSCompartment *gcTriggerCompartment;
21259 JSCompartment *gcCurrentCompartment;
21268 bool gcMarkAndSweep;
21270 bool gcRegenShapes;
21276 JSGCCallback gcCallback;
21283 volatile ptrdiff_t gcMallocBytes;
21286 js::GCChunkAllocator *gcChunkAllocator;
21288 void setCustomGCChunkAllocator(js::GCChunkAllocator *allocator) {
21291 gcChunkAllocator = allocator;
21298 JSTraceDataOp gcExtraRootsTraceOp;
21299 void *gcExtraRootsData;
21302 js::Value NaNValue;
21303 js::Value negativeInfinityValue;
21304 js::Value positiveInfinityValue;
21306 JSFlatString *emptyString;
21309 JSCList contextList;
21312 JSDebugHooks globalDebugHooks;
21320 JSCList watchPointList;
21329 PRCondVar *requestDone;
21330 uint32 requestCount;
21331 JSThread *gcThread;
21333 js::GCHelperThread gcHelperThread;
21342 PRCondVar *stateChange;
21350 PRLock *debuggerLock;
21352 JSThread::Map threads;
21354 uint32 debuggerMutations;
21360 JSSecurityCallbacks *securityCallbacks;
21363 const JSStructuredCloneCallbacks *structuredCloneCallbacks;
21370 int32 propertyRemovals;
21373 struct JSHashTable *scriptFilenameTable;
21374 JSCList scriptFilenamePrefixes;
21376 PRLock *scriptFilenameTableLock;
21380 const char *thousandsSeparator;
21381 const char *decimalSeparator;
21382 const char *numGrouping;
21384 JSObject *anynameObject;
21385 JSObject *functionNamespaceObject;
21389 volatile int32 interruptCounter;
21391 volatile uint32 shapeGen;
21394 JSAtomState atomState;
21396 JSWrapObjectCallback wrapObjectCallback;
21397 JSPreWrapCallback preWrapObjectCallback;
21402 uint32 stringMemoryUsed;
21407 bool init(uint32 maxbytes);
21409 void setGCTriggerFactor(uint32 factor);
21410 void setGCLastBytes(size_t lastBytes);
21416 void* malloc(size_t bytes, JSContext *cx = __null) {
21417 updateMallocCounter(bytes);
21418 void *p = ::js_malloc(bytes);
21419 return (__builtin_expect((!!p), 1)) ? p : onOutOfMemory(__null, bytes, cx);
21426 void* calloc(size_t bytes, JSContext *cx = __null) {
21427 updateMallocCounter(bytes);
21428 void *p = ::js_calloc(bytes);
21429 return (__builtin_expect((!!p), 1)) ? p : onOutOfMemory(reinterpret_cast<void *>(1), bytes, cx);
21432 void* realloc(void* p, size_t oldBytes, size_t newBytes, JSContext *cx = __null) {
21434 updateMallocCounter(newBytes - oldBytes);
21435 void *p2 = ::js_realloc(p, newBytes);
21436 return (__builtin_expect((!!p2), 1)) ? p2 : onOutOfMemory(p, newBytes, cx);
21439 void* realloc(void* p, size_t bytes, JSContext *cx = __null) {
21445 updateMallocCounter(bytes);
21446 void *p2 = ::js_realloc(p, bytes);
21447 return (__builtin_expect((!!p2), 1)) ? p2 : onOutOfMemory(p, bytes, cx);
21450 void free(void* p) { ::js_free(p); }
21452 bool isGCMallocLimitReached() const { return gcMallocBytes <= 0; }
21454 void resetGCMallocBytes() { gcMallocBytes = ptrdiff_t(gcMaxMallocBytes); }
21456 void setGCMaxMallocBytes(size_t value) {
21461 gcMaxMallocBytes = (ptrdiff_t(value) >= 0) ? value : size_t(-1) >> 1;
21462 resetGCMallocBytes();
21465 void updateMallocCounter(size_t nbytes) {
21467 ptrdiff_t newCount = gcMallocBytes - ptrdiff_t(nbytes);
21468 gcMallocBytes = newCount;
21469 if ((__builtin_expect((newCount <= 0), 0)))
21477 __attribute__((visibility ("default"))) void onTooMuchMalloc();
21479 __attribute__((visibility ("default"))) void * onOutOfMemory(void *p, size_t nbytes, JSContext *cx);
21482 struct JSArgumentFormatMap {
21483 const char *format;
21485 JSArgumentFormatter formatter;
21486 JSArgumentFormatMap *next;
21489 typedef struct JSResolvingKey {
21494 typedef struct JSResolvingEntry {
21495 JSDHashEntryHdr hdr;
21496 JSResolvingKey key;
21498 } JSResolvingEntry;
21504 extern const JSDebugHooks js_NullDebugHooks;
21508 class AutoGCRooter;
21514 OptionsHasXML(uint32 options)
21516 return !!(options & ((JSUint32)1 << (6)));
21523 OptionsHasAnonFunFix(uint32 options)
21525 return !!(options & ((JSUint32)1 << (10)));
21532 OptionsSameVersionFlags(uint32 self, uint32 other)
21534 static const uint32 mask = ((JSUint32)1 << (6)) | ((JSUint32)1 << (10));
21535 return !((self & mask) ^ (other & mask));
21538 namespace VersionFlags {
21539 static const uintN MASK = 0x0FFF;
21540 static const uintN HAS_XML = 0x1000;
21541 static const uintN ANONFUNFIX = 0x2000;
21542 static const uintN FULL_MASK = 0x3FFF;
21545 static inline JSVersion
21546 VersionNumber(JSVersion version)
21548 return JSVersion(uint32(version) & VersionFlags::MASK);
21555 VersionHasXML(JSVersion version)
21557 return !!(version & VersionFlags::HAS_XML);
21565 VersionShouldParseXML(JSVersion version)
21567 return VersionHasXML(version) || VersionNumber(version) >= JSVERSION_1_6;
21574 VersionHasAnonFunFix(JSVersion version)
21576 return !!(version & VersionFlags::ANONFUNFIX);
21580 VersionSetXML(JSVersion *version, bool enable)
21583 *version = JSVersion(uint32(*version) | VersionFlags::HAS_XML);
21585 *version = JSVersion(uint32(*version) & ~VersionFlags::HAS_XML);
21589 VersionSetAnonFunFix(JSVersion *version, bool enable)
21592 *version = JSVersion(uint32(*version) | VersionFlags::ANONFUNFIX);
21594 *version = JSVersion(uint32(*version) & ~VersionFlags::ANONFUNFIX);
21597 static inline JSVersion
21598 VersionExtractFlags(JSVersion version)
21600 return JSVersion(uint32(version) & ~VersionFlags::MASK);
21604 VersionCopyFlags(JSVersion *version, JSVersion from)
21606 *version = JSVersion(VersionNumber(*version) | VersionExtractFlags(from));
21613 VersionHasFlags(JSVersion version)
21615 return !!VersionExtractFlags(version);
21618 static inline uintN
21619 VersionFlagsToOptions(JSVersion version)
21621 uintN copts = (VersionHasXML(version) ? ((JSUint32)1 << (6)) : 0) |
21622 (VersionHasAnonFunFix(version) ? ((JSUint32)1 << (10)) : 0);
21627 static inline JSVersion
21628 OptionFlagsToVersion(uintN options, JSVersion version)
21630 VersionSetXML(&version, OptionsHasXML(options));
21631 VersionSetAnonFunFix(&version, OptionsHasAnonFunFix(options));
21639 VersionIsKnown(JSVersion version)
21641 return VersionNumber(version) != JSVERSION_UNKNOWN;
21644 typedef js::HashSet<JSObject *,
21645 js::DefaultHasher<JSObject *>,
21646 js::SystemAllocPolicy> BusyArraysMap;
21652 explicit JSContext(JSRuntime *rt);
21659 JSVersion defaultVersion;
21660 JSVersion versionOverride;
21661 bool hasVersionOverride;
21665 js::Value exception;
21672 JSLocaleCallbacks *localeCallbacks;
21680 JSDHashTable *resolvingTable;
21686 JSPackedBool generatingError;
21689 jsuword stackLimit;
21692 size_t scriptStackQuota;
21695 JSRuntime *const runtime;
21698 JSCompartment *compartment;
21706 JSStackFrame* fp() {
21711 JSStackFrame* maybefp() {
21713 return regs ? regs->fp : __null;
21722 friend class js::StackSpace;
21723 friend bool js::Interpret(JSContext *, JSStackFrame *, uintN, JSInterpMode);
21725 void resetCompartment();
21726 void wrapPendingException();
21729 void setCurrentRegs(JSFrameRegs *regs) {
21735 JSArenaPool tempPool;
21738 JSArenaPool regExpPool;
21741 JSObject *globalObject;
21744 JSSharpObjectMap sharpObjectMap;
21745 js::BusyArraysMap busyArrays;
21748 JSArgumentFormatMap *argumentFormatMap;
21758 JSErrorReporter errorReporter;
21761 JSOperationCallback operationCallback;
21772 js::StackSegment *currentSegment;
21775 void assertSegmentsInSync() const {
21780 bool hasActiveSegment() const {
21781 assertSegmentsInSync();
21786 js::StackSegment *activeSegment() const {
21788 return currentSegment;
21792 js::StackSegment *getCurrentSegment() const {
21793 assertSegmentsInSync();
21794 return currentSegment;
21797 inline js::RegExpStatics *regExpStatics();
21800 void pushSegmentAndFrame(js::StackSegment *newseg, JSFrameRegs ®s);
21803 void popSegmentAndFrame();
21806 void saveActiveSegment();
21809 void restoreSegment();
21812 inline JSStackFrame *computeNextFrame(JSStackFrame *fp);
21818 js::StackSegment *containingSegment(const JSStackFrame *target);
21821 JSStackFrame *findFrameAtLevel(uintN targetLevel) const {
21822 JSStackFrame *fp = regs->fp;
21825 if (fp->script()->staticLevel == targetLevel)
21837 bool canSetDefaultVersion() const {
21838 return !regs && !hasVersionOverride;
21842 void overrideVersion(JSVersion newVersion) {
21844 versionOverride = newVersion;
21845 hasVersionOverride = true;
21849 void setDefaultVersion(JSVersion version) {
21850 defaultVersion = version;
21853 void clearVersionOverride() { hasVersionOverride = false; }
21854 JSVersion getDefaultVersion() const { return defaultVersion; }
21855 bool isVersionOverridden() const { return hasVersionOverride; }
21857 JSVersion getVersionOverride() const {
21859 return versionOverride;
21866 bool maybeOverrideVersion(JSVersion newVersion) {
21867 if (canSetDefaultVersion()) {
21868 setDefaultVersion(newVersion);
21871 overrideVersion(newVersion);
21877 void maybeMigrateVersionOverride() {
21878 if ((__builtin_expect((!isVersionOverridden() || currentSegment), 1)))
21880 defaultVersion = versionOverride;
21881 clearVersionOverride();
21886 JSVersion findVersion() const {
21887 if (hasVersionOverride)
21888 return versionOverride;
21892 JSStackFrame *fp = regs->fp;
21893 while (fp && !fp->isScriptFrame())
21896 return fp->script()->getVersion();
21899 return defaultVersion;
21902 void setRunOptions(uintN ropts) {
21904 runOptions = ropts;
21908 void setCompileOptions(uintN newcopts) {
21910 if ((__builtin_expect((getCompileOptions() == newcopts), 1)))
21912 JSVersion version = findVersion();
21913 JSVersion newVersion = js::OptionFlagsToVersion(newcopts, version);
21914 maybeOverrideVersion(newVersion);
21917 uintN getRunOptions() const { return runOptions; }
21918 uintN getCompileOptions() const { return js::VersionFlagsToOptions(findVersion()); }
21919 uintN allOptions() const { return getRunOptions() | getCompileOptions(); }
21921 bool hasRunOption(uintN ropt) const {
21923 return !!(runOptions & ropt);
21926 bool hasStrictOption() const { return hasRunOption(((JSUint32)1 << (0))); }
21927 bool hasWErrorOption() const { return hasRunOption(((JSUint32)1 << (1))); }
21928 bool hasAtLineOption() const { return hasRunOption(((JSUint32)1 << (5))); }
21932 unsigned outstandingRequests;
21935 JSCList threadLinks;
21942 js::AutoGCRooter *autoGCRooters;
21945 const JSDebugHooks *debugHooks;
21948 JSSecurityCallbacks *securityCallbacks;
21951 uintN resolveFlags;
21957 js::Value iterValue;
21959 void updateJITEnabled();
21961 DSTOffsetCache dstOffsetCache;
21964 JSObject *enumerators;
21973 js::Vector<JSGenerator *, 2, js::SystemAllocPolicy> genStack;
21981 JSGenerator *generatorFor(JSStackFrame *fp) const;
21984 inline bool ensureGeneratorStackSpace();
21986 bool enterGenerator(JSGenerator *gen) {
21987 return genStack.append(gen);
21990 void leaveGenerator(JSGenerator *gen) {
21992 genStack.popBack();
22000 js::GCHelperThread *gcBackgroundFree;
22003 inline void* malloc(size_t bytes) {
22004 return runtime->malloc(bytes, this);
22007 inline void* mallocNoReport(size_t bytes) {
22009 return runtime->malloc(bytes, __null);
22012 inline void* calloc(size_t bytes) {
22014 return runtime->calloc(bytes, this);
22017 inline void* realloc(void* p, size_t bytes) {
22018 return runtime->realloc(p, bytes, this);
22021 inline void* realloc(void* p, size_t oldBytes, size_t newBytes) {
22022 return runtime->realloc(p, oldBytes, newBytes, this);
22025 inline void free(void* p) {
22027 if (gcBackgroundFree) {
22028 gcBackgroundFree->freeLater(p);
22036 __attribute__((always_inline)) inline T *create() {
22037 void *memory = this->malloc(sizeof(T)); if (!memory) return __null; return new(memory) T ();
22040 template <class T, class P1>
22041 __attribute__((always_inline)) inline T *create(const P1 &p1) {
22042 void *memory = this->malloc(sizeof(T)); if (!memory) return __null; return new(memory) T (p1);
22045 template <class T, class P1, class P2>
22046 __attribute__((always_inline)) inline T *create(const P1 &p1, const P2 &p2) {
22047 void *memory = this->malloc(sizeof(T)); if (!memory) return __null; return new(memory) T (p1, p2);
22050 template <class T, class P1, class P2, class P3>
22051 __attribute__((always_inline)) inline T *create(const P1 &p1, const P2 &p2, const P3 &p3) {
22052 void *memory = this->malloc(sizeof(T)); if (!memory) return __null; return new(memory) T (p1, p2, p3);
22057 __attribute__((always_inline)) inline void destroy(T *p) {
22064 js::StackSpace &stack() const {
22065 return (&(this)->thread->data)->stackSpace;
22074 void assertValidStackDepth(uintN ) {}
22077 bool isExceptionPending() {
22081 js::Value getPendingException() {
22086 void setPendingException(js::Value v);
22088 void clearPendingException() {
22089 this->throwing = false;
22090 this->exception.setUndefined();
22100 __attribute__((visibility ("default"))) void checkMallocGCPressure(void *p);
22103 static inline uintN
22104 FramePCOffset(JSContext *cx, JSStackFrame* fp)
22106 jsbytecode *pc = fp->hasImacropc() ? fp->imacropc() : fp->pc(cx);
22107 return uintN(pc - fp->script()->code);
22110 static inline JSAtom **
22111 FrameAtomBase(JSContext *cx, JSStackFrame *fp)
22113 return fp->hasImacropc()
22114 ? ((JSAtom **)((uint8 *)(&cx->runtime->atomState) + __builtin_offsetof (JSAtomState, emptyAtom)))
22115 : fp->script()->atomMap.vector;
22120 class AutoGCRooter {
22122 AutoGCRooter(JSContext *cx, ptrdiff_t tag)
22123 : down(cx->autoGCRooters), tag(tag), context(cx)
22127 cx->autoGCRooters = this;
22133 context->autoGCRooters = down;
22137 inline void trace(JSTracer *trc);
22140 #pragma GCC visibility push(default)
22142 friend __attribute__((visibility ("default"))) void MarkContext(JSTracer *trc, JSContext *acx);
22143 friend void MarkRuntime(JSTracer *trc);
22145 #pragma GCC visibility pop
22149 AutoGCRooter * const down;
22153 JSContext * const context;
22177 AutoGCRooter(AutoGCRooter &ida);
22178 void operator=(AutoGCRooter &ida);
22182 class AutoValueRooter : private AutoGCRooter
22185 explicit AutoValueRooter(JSContext *cx
22187 : AutoGCRooter(cx, JSVAL), val(js::NullValue())
22192 AutoValueRooter(JSContext *cx, const Value &v
22194 : AutoGCRooter(cx, JSVAL), val(v)
22199 AutoValueRooter(JSContext *cx, jsval v
22201 : AutoGCRooter(cx, JSVAL), val(js::Valueify(v))
22212 void set(Value v) {
22217 void set(jsval v) {
22219 val = js::Valueify(v);
22222 const Value &value() const {
22232 const jsval &jsval_value() const {
22234 return Jsvalify(val);
22237 jsval *jsval_addr() {
22239 return Jsvalify(&val);
22242 friend void AutoGCRooter::trace(JSTracer *trc);
22243 friend void MarkRuntime(JSTracer *trc);
22250 class AutoObjectRooter : private AutoGCRooter {
22252 AutoObjectRooter(JSContext *cx, JSObject *obj = __null
22254 : AutoGCRooter(cx, OBJECT), obj(obj)
22259 void setObject(JSObject *obj) {
22263 JSObject * object() const {
22267 JSObject ** addr() {
22271 friend void AutoGCRooter::trace(JSTracer *trc);
22272 friend void MarkRuntime(JSTracer *trc);
22279 class AutoStringRooter : private AutoGCRooter {
22281 AutoStringRooter(JSContext *cx, JSString *str = __null
22283 : AutoGCRooter(cx, STRING), str(str)
22288 void setString(JSString *str) {
22292 JSString * string() const {
22296 JSString ** addr() {
22300 friend void AutoGCRooter::trace(JSTracer *trc);
22307 class AutoArrayRooter : private AutoGCRooter {
22309 AutoArrayRooter(JSContext *cx, size_t len, Value *vec
22311 : AutoGCRooter(cx, len), array(vec)
22317 AutoArrayRooter(JSContext *cx, size_t len, jsval *vec
22319 : AutoGCRooter(cx, len), array(Valueify(vec))
22325 void changeLength(size_t newLength) {
22326 tag = ptrdiff_t(newLength);
22330 void changeArray(Value *newArray, size_t newLength) {
22331 changeLength(newLength);
22337 friend void AutoGCRooter::trace(JSTracer *trc);
22343 class AutoShapeRooter : private AutoGCRooter {
22345 AutoShapeRooter(JSContext *cx, const js::Shape *shape
22347 : AutoGCRooter(cx, SHAPE), shape(shape)
22352 friend void AutoGCRooter::trace(JSTracer *trc);
22353 friend void MarkRuntime(JSTracer *trc);
22356 const js::Shape * const shape;
22360 class AutoScriptRooter : private AutoGCRooter {
22362 AutoScriptRooter(JSContext *cx, JSScript *script
22364 : AutoGCRooter(cx, SCRIPT), script(script)
22369 void setScript(JSScript *script) {
22370 this->script = script;
22373 friend void AutoGCRooter::trace(JSTracer *trc);
22380 class AutoIdRooter : private AutoGCRooter
22383 explicit AutoIdRooter(JSContext *cx, jsid id = INT_TO_JSID(0)
22385 : AutoGCRooter(cx, ID), id_(id)
22398 friend void AutoGCRooter::trace(JSTracer *trc);
22399 friend void MarkRuntime(JSTracer *trc);
22406 class AutoIdArray : private AutoGCRooter {
22408 AutoIdArray(JSContext *cx, JSIdArray *ida )
22409 : AutoGCRooter(cx, IDARRAY), idArray(ida)
22415 JS_DestroyIdArray(context, idArray);
22418 return idArray == __null;
22420 jsid operator[](size_t i) const {
22423 return idArray->vector[i];
22425 size_t length() const {
22426 return idArray->length;
22429 friend void AutoGCRooter::trace(JSTracer *trc);
22431 JSIdArray *steal() {
22432 JSIdArray *copy = idArray;
22438 inline void trace(JSTracer *trc);
22441 JSIdArray * idArray;
22445 AutoIdArray(AutoIdArray &ida);
22446 void operator=(AutoIdArray &ida);
22450 class AutoEnumStateRooter : private AutoGCRooter
22453 AutoEnumStateRooter(JSContext *cx, JSObject *obj
22455 : AutoGCRooter(cx, ENUMERATOR), obj(obj), stateValue()
22461 ~AutoEnumStateRooter() {
22462 if (!stateValue.isNull()) {
22466 obj->enumerate(context, JSENUMERATE_DESTROY, &stateValue, 0);
22471 friend void AutoGCRooter::trace(JSTracer *trc);
22473 const Value &state() const { return stateValue; }
22474 Value *addr() { return &stateValue; }
22477 void trace(JSTracer *trc);
22479 JSObject * const obj;
22487 class AutoXMLRooter : private AutoGCRooter {
22489 AutoXMLRooter(JSContext *cx, JSXML *xml
22491 : AutoGCRooter(cx, XML), xml(xml)
22497 friend void AutoGCRooter::trace(JSTracer *trc);
22498 friend void MarkRuntime(JSTracer *trc);
22506 class AutoBindingsRooter : private AutoGCRooter {
22508 AutoBindingsRooter(JSContext *cx, Bindings &bindings
22510 : AutoGCRooter(cx, BINDINGS), bindings(bindings)
22515 friend void AutoGCRooter::trace(JSTracer *trc);
22518 Bindings &bindings;
22524 explicit AutoLockGC(JSRuntime *rt
22529 PR_Lock((rt)->gcLock);
22531 ~AutoLockGC() { PR_Unlock((rt)->gcLock); }
22538 class AutoUnlockGC {
22544 explicit AutoUnlockGC(JSRuntime *rt
22549 PR_Unlock((rt)->gcLock);
22551 ~AutoUnlockGC() { PR_Lock((rt)->gcLock); }
22554 class AutoLockAtomsCompartment {
22560 AutoLockAtomsCompartment(JSContext *cx
22565 js_Lock(cx, &cx->runtime->atomState.lock);
22567 cx->runtime->atomsCompartmentIsLocked = true;
22570 ~AutoLockAtomsCompartment() {
22572 cx->runtime->atomsCompartmentIsLocked = false;
22574 js_Unlock(cx, &cx->runtime->atomState.lock);
22578 class AutoUnlockAtomsCompartment {
22583 AutoUnlockAtomsCompartment(JSContext *cx
22589 cx->runtime->atomsCompartmentIsLocked = false;
22591 js_Unlock(cx, &cx->runtime->atomState.lock);
22593 ~AutoUnlockAtomsCompartment() {
22594 js_Lock(cx, &cx->runtime->atomState.lock);
22596 cx->runtime->atomsCompartmentIsLocked = true;
22601 class AutoKeepAtoms {
22606 explicit AutoKeepAtoms(JSRuntime *rt
22611 PR_AtomicIncrement((PRInt32 *)(&(rt)->gcKeepAtoms));;
22613 ~AutoKeepAtoms() { PR_AtomicDecrement((PRInt32 *)(&(rt)->gcKeepAtoms));; }
22616 class AutoArenaAllocator {
22622 explicit AutoArenaAllocator(JSArenaPool *pool
22624 : pool(pool), mark(((void *) (pool)->current->avail))
22628 ~AutoArenaAllocator() { do { char *_m = (char *)(mark); JSArena *_a = (pool)->current; if (_a != &(pool)->first && (((jsuword)(_m) - (jsuword)((_a)->base)) <= ((jsuword)((_a)->avail) - (jsuword)((_a)->base)))) { _a->avail = (jsuword)(((jsuword)(_m) + (pool)->mask) & ~(pool)->mask); ((void) 0); ; ; } else { JS_ArenaRelease(pool, _m); } ; } while (0); }
22630 template <typename T>
22631 T *alloc(size_t elems) {
22633 do { JSArena *_a = (pool)->current; size_t _nb = (((jsuword)(elems * sizeof(T)) + (pool)->mask) & ~(pool)->mask); jsuword _p = _a->avail; if ((_nb > _a->limit) || _p > _a->limit - _nb) _p = (jsuword)JS_ArenaAllocate(pool, _nb); else _a->avail = _p + _nb; ptr = (void *) _p; do { } while (0) ; } while (0);
22634 return static_cast<T *>(ptr);
22638 class AutoReleasePtr {
22643 AutoReleasePtr operator=(const AutoReleasePtr &other);
22646 explicit AutoReleasePtr(JSContext *cx, void *ptr
22652 ~AutoReleasePtr() { cx->free(ptr); }
22658 class AutoReleaseNullablePtr {
22663 AutoReleaseNullablePtr operator=(const AutoReleaseNullablePtr &other);
22666 explicit AutoReleaseNullablePtr(JSContext *cx, void *ptr
22672 void reset(void *ptr2) {
22677 ~AutoReleaseNullablePtr() { if (ptr) cx->free(ptr); }
22680 class AutoLocalNameArray {
22682 explicit AutoLocalNameArray(JSContext *cx, JSFunction *fun
22685 mark(((void *) (&cx->tempPool)->current->avail)),
22686 names(fun->script()->bindings.getLocalNameArray(cx, &cx->tempPool)),
22687 count(fun->script()->bindings.countLocalNames())
22692 ~AutoLocalNameArray() {
22693 do { char *_m = (char *)(mark); JSArena *_a = (&context->tempPool)->current; if (_a != &(&context->tempPool)->first && (((jsuword)(_m) - (jsuword)((_a)->base)) <= ((jsuword)((_a)->avail) - (jsuword)((_a)->base)))) { _a->avail = (jsuword)(((jsuword)(_m) + (&context->tempPool)->mask) & ~(&context->tempPool)->mask); ((void) 0); ; ; } else { JS_ArenaRelease(&context->tempPool, _m); } ; } while (0);
22696 operator bool() const { return !!names; }
22698 uint32 length() const { return count; }
22700 const jsuword &operator [](unsigned i) const { return names[i]; }
22703 JSContext *context;
22711 template <class RefCountable>
22712 class AlreadyIncRefed
22714 typedef RefCountable *****ConvertibleToBool;
22719 explicit AlreadyIncRefed(RefCountable *obj) : obj(obj) {}
22721 bool null() const { return obj == __null; }
22722 operator ConvertibleToBool() const { return (ConvertibleToBool)obj; }
22724 RefCountable *operator->() const { ((void) 0); return obj; }
22725 RefCountable &operator*() const { ((void) 0); return *obj; }
22726 RefCountable *get() const { return obj; }
22729 template <class RefCountable>
22732 typedef RefCountable *****ConvertibleToBool;
22737 explicit NeedsIncRef(RefCountable *obj) : obj(obj) {}
22739 bool null() const { return obj == __null; }
22740 operator ConvertibleToBool() const { return (ConvertibleToBool)obj; }
22742 RefCountable *operator->() const { ((void) 0); return obj; }
22743 RefCountable &operator*() const { ((void) 0); return *obj; }
22744 RefCountable *get() const { return obj; }
22747 template <class RefCountable>
22750 typedef RefCountable *****ConvertibleToBool;
22752 JSContext *const cx;
22755 AutoRefCount(const AutoRefCount &);
22756 void operator=(const AutoRefCount &);
22759 explicit AutoRefCount(JSContext *cx)
22760 : cx(cx), obj(__null)
22763 AutoRefCount(JSContext *cx, NeedsIncRef<RefCountable> aobj)
22764 : cx(cx), obj(aobj.get())
22770 AutoRefCount(JSContext *cx, AlreadyIncRefed<RefCountable> aobj)
22771 : cx(cx), obj(aobj.get())
22779 void reset(NeedsIncRef<RefCountable> aobj) {
22787 void reset(AlreadyIncRefed<RefCountable> aobj) {
22793 bool null() const { return obj == __null; }
22794 operator ConvertibleToBool() const { return (ConvertibleToBool)obj; }
22796 RefCountable *operator->() const { ((void) 0); return obj; }
22797 RefCountable &operator*() const { ((void) 0); return *obj; }
22798 RefCountable *get() const { return obj; }
22803 class JSAutoResolveFlags
22806 JSAutoResolveFlags(JSContext *cx, uintN flags
22808 : mContext(cx), mSaved(cx->resolveFlags)
22811 cx->resolveFlags = flags;
22814 ~JSAutoResolveFlags() { mContext->resolveFlags = mSaved; }
22817 JSContext *mContext;
22822 extern JSThreadData *
22823 js_CurrentThreadData(JSRuntime *rt);
22826 js_InitThreads(JSRuntime *rt);
22829 js_FinishThreads(JSRuntime *rt);
22832 js_PurgeThreads(JSContext *cx);
22839 class ThreadDataIter : public JSThread::Map::Range
22842 ThreadDataIter(JSRuntime *rt) : JSThread::Map::Range(rt->threads.all()) {}
22844 JSThreadData *threadData() const {
22845 return &front().value->data;
22856 js_NewContext(JSRuntime *rt, size_t stackChunkSize);
22859 js_DestroyContext(JSContext *cx, JSDestroyContextMode mode);
22861 static inline JSContext *
22862 js_ContextFromLinkField(JSCList *link)
22865 return (JSContext *) ((uint8 *) link - __builtin_offsetof (JSContext, link));
22873 js_ContextIterator(JSRuntime *rt, JSBool unlocked, JSContext **iterp);
22880 extern __attribute__((visibility ("default"))) JSContext *
22881 js_NextActiveContext(JSRuntime *, JSContext *);
22887 js_StartResolving(JSContext *cx, JSResolvingKey *key, uint32 flag,
22888 JSResolvingEntry **entryp);
22891 js_StopResolving(JSContext *cx, JSResolvingKey *key, uint32 flag,
22892 JSResolvingEntry *entry, uint32 generation);
22898 typedef enum JSErrNum {
22903 JSMSG_NOT_AN_ERROR = 0,
22904 JSMSG_NOT_DEFINED = 1,
22905 JSMSG_INACTIVE = 2,
22906 JSMSG_MORE_ARGS_NEEDED = 3,
22907 JSMSG_BAD_CHAR = 4,
22908 JSMSG_BAD_TYPE = 5,
22909 JSMSG_ALLOC_OVERFLOW = 6,
22910 JSMSG_MISSING_HEXDIGITS = 7,
22911 JSMSG_INCOMPATIBLE_PROTO = 8,
22912 JSMSG_NO_CONSTRUCTOR = 9,
22913 JSMSG_CANT_ALIAS = 10,
22914 JSMSG_NOT_SCRIPTED_FUNCTION = 11,
22915 JSMSG_BAD_SORT_ARG = 12,
22916 JSMSG_BAD_ATOMIC_NUMBER = 13,
22917 JSMSG_TOO_MANY_LITERALS = 14,
22918 JSMSG_CANT_WATCH = 15,
22919 JSMSG_STACK_UNDERFLOW = 16,
22920 JSMSG_NEED_DIET = 17,
22921 JSMSG_TOO_MANY_LOCAL_ROOTS = 18,
22922 JSMSG_READ_ONLY = 19,
22923 JSMSG_BAD_FORMAL = 20,
22924 JSMSG_CANT_DELETE = 21,
22925 JSMSG_NOT_FUNCTION = 22,
22926 JSMSG_NOT_CONSTRUCTOR = 23,
22927 JSMSG_SCRIPT_STACK_QUOTA = 24,
22928 JSMSG_TOO_DEEP = 25,
22929 JSMSG_OVER_RECURSED = 26,
22930 JSMSG_IN_NOT_OBJECT = 27,
22931 JSMSG_BAD_NEW_RESULT = 28,
22932 JSMSG_BAD_SHARP_DEF = 29,
22933 JSMSG_BAD_SHARP_USE = 30,
22934 JSMSG_BAD_INSTANCEOF_RHS = 31,
22935 JSMSG_BAD_BYTECODE = 32,
22936 JSMSG_BAD_RADIX = 33,
22937 JSMSG_PAREN_BEFORE_LET = 34,
22938 JSMSG_CANT_CONVERT = 35,
22939 JSMSG_CYCLIC_VALUE = 36,
22940 JSMSG_COMPILE_EXECED_SCRIPT = 37,
22941 JSMSG_CANT_CONVERT_TO = 38,
22942 JSMSG_NO_PROPERTIES = 39,
22943 JSMSG_CANT_FIND_CLASS = 40,
22944 JSMSG_CANT_XDR_CLASS = 41,
22945 JSMSG_BYTECODE_TOO_BIG = 42,
22946 JSMSG_UNKNOWN_FORMAT = 43,
22947 JSMSG_TOO_MANY_CON_ARGS = 44,
22948 JSMSG_TOO_MANY_FUN_ARGS = 45,
22949 JSMSG_BAD_QUANTIFIER = 46,
22950 JSMSG_MIN_TOO_BIG = 47,
22951 JSMSG_MAX_TOO_BIG = 48,
22952 JSMSG_OUT_OF_ORDER = 49,
22953 JSMSG_BAD_DESTRUCT_DECL = 50,
22954 JSMSG_BAD_DESTRUCT_ASS = 51,
22955 JSMSG_PAREN_AFTER_LET = 52,
22956 JSMSG_CURLY_AFTER_LET = 53,
22957 JSMSG_MISSING_PAREN = 54,
22958 JSMSG_UNTERM_CLASS = 55,
22959 JSMSG_TRAILING_SLASH = 56,
22960 JSMSG_BAD_CLASS_RANGE = 57,
22961 JSMSG_BAD_REGEXP_FLAG = 58,
22962 JSMSG_NO_INPUT = 59,
22963 JSMSG_CANT_OPEN = 60,
22964 JSMSG_BAD_STRING_MASK = 61,
22965 JSMSG_UNMATCHED_RIGHT_PAREN = 62,
22966 JSMSG_END_OF_DATA = 63,
22967 JSMSG_SEEK_BEYOND_START = 64,
22968 JSMSG_SEEK_BEYOND_END = 65,
22969 JSMSG_END_SEEK = 66,
22970 JSMSG_WHITHER_WHENCE = 67,
22971 JSMSG_BAD_SCRIPT_MAGIC = 68,
22972 JSMSG_PAREN_BEFORE_FORMAL = 69,
22973 JSMSG_MISSING_FORMAL = 70,
22974 JSMSG_PAREN_AFTER_FORMAL = 71,
22975 JSMSG_CURLY_BEFORE_BODY = 72,
22976 JSMSG_CURLY_AFTER_BODY = 73,
22977 JSMSG_PAREN_BEFORE_COND = 74,
22978 JSMSG_PAREN_AFTER_COND = 75,
22979 JSMSG_DESTRUCT_DUP_ARG = 76,
22980 JSMSG_NAME_AFTER_DOT = 77,
22981 JSMSG_BRACKET_IN_INDEX = 78,
22982 JSMSG_XML_WHOLE_PROGRAM = 79,
22983 JSMSG_PAREN_BEFORE_SWITCH = 80,
22984 JSMSG_PAREN_AFTER_SWITCH = 81,
22985 JSMSG_CURLY_BEFORE_SWITCH = 82,
22986 JSMSG_COLON_AFTER_CASE = 83,
22987 JSMSG_WHILE_AFTER_DO = 84,
22988 JSMSG_PAREN_AFTER_FOR = 85,
22989 JSMSG_SEMI_AFTER_FOR_INIT = 86,
22990 JSMSG_SEMI_AFTER_FOR_COND = 87,
22991 JSMSG_PAREN_AFTER_FOR_CTRL = 88,
22992 JSMSG_CURLY_BEFORE_TRY = 89,
22993 JSMSG_CURLY_AFTER_TRY = 90,
22994 JSMSG_PAREN_BEFORE_CATCH = 91,
22995 JSMSG_CATCH_IDENTIFIER = 92,
22996 JSMSG_PAREN_AFTER_CATCH = 93,
22997 JSMSG_CURLY_BEFORE_CATCH = 94,
22998 JSMSG_CURLY_AFTER_CATCH = 95,
22999 JSMSG_CURLY_BEFORE_FINALLY = 96,
23000 JSMSG_CURLY_AFTER_FINALLY = 97,
23001 JSMSG_CATCH_OR_FINALLY = 98,
23002 JSMSG_PAREN_BEFORE_WITH = 99,
23003 JSMSG_PAREN_AFTER_WITH = 100,
23004 JSMSG_CURLY_IN_COMPOUND = 101,
23005 JSMSG_NO_VARIABLE_NAME = 102,
23006 JSMSG_COLON_IN_COND = 103,
23007 JSMSG_PAREN_AFTER_ARGS = 104,
23008 JSMSG_BRACKET_AFTER_LIST = 105,
23009 JSMSG_COLON_AFTER_ID = 106,
23010 JSMSG_CURLY_AFTER_LIST = 107,
23011 JSMSG_PAREN_IN_PAREN = 108,
23012 JSMSG_SEMI_BEFORE_STMNT = 109,
23013 JSMSG_NO_RETURN_VALUE = 110,
23014 JSMSG_DUPLICATE_FORMAL = 111,
23015 JSMSG_EQUAL_AS_ASSIGN = 112,
23016 JSMSG_OPTIMIZED_CLOSURE_LEAK = 113,
23017 JSMSG_TOO_MANY_DEFAULTS = 114,
23018 JSMSG_TOO_MANY_CASES = 115,
23019 JSMSG_BAD_SWITCH = 116,
23020 JSMSG_BAD_FOR_LEFTSIDE = 117,
23021 JSMSG_CATCH_AFTER_GENERAL = 118,
23022 JSMSG_CATCH_WITHOUT_TRY = 119,
23023 JSMSG_FINALLY_WITHOUT_TRY = 120,
23024 JSMSG_LABEL_NOT_FOUND = 121,
23025 JSMSG_TOUGH_BREAK = 122,
23026 JSMSG_BAD_CONTINUE = 123,
23027 JSMSG_BAD_RETURN_OR_YIELD = 124,
23028 JSMSG_BAD_LABEL = 125,
23029 JSMSG_DUPLICATE_LABEL = 126,
23030 JSMSG_VAR_HIDES_ARG = 127,
23031 JSMSG_BAD_VAR_INIT = 128,
23032 JSMSG_BAD_LEFTSIDE_OF_ASS = 129,
23033 JSMSG_BAD_OPERAND = 130,
23034 JSMSG_BAD_PROP_ID = 131,
23035 JSMSG_RESERVED_ID = 132,
23036 JSMSG_SYNTAX_ERROR = 133,
23037 JSMSG_BAD_SHARP_VAR_DEF = 134,
23038 JSMSG_BAD_PROTOTYPE = 135,
23039 JSMSG_MISSING_EXPONENT = 136,
23040 JSMSG_OUT_OF_MEMORY = 137,
23041 JSMSG_UNTERMINATED_STRING = 138,
23042 JSMSG_TOO_MANY_PARENS = 139,
23043 JSMSG_UNTERMINATED_COMMENT = 140,
23044 JSMSG_UNTERMINATED_REGEXP = 141,
23045 JSMSG_BAD_CLONE_FUNOBJ_SCOPE = 142,
23046 JSMSG_SHARPVAR_TOO_BIG = 143,
23047 JSMSG_ILLEGAL_CHARACTER = 144,
23048 JSMSG_BAD_OCTAL = 145,
23049 JSMSG_BAD_INDIRECT_CALL = 146,
23050 JSMSG_UNCAUGHT_EXCEPTION = 147,
23051 JSMSG_INVALID_BACKREF = 148,
23052 JSMSG_BAD_BACKREF = 149,
23053 JSMSG_PRECISION_RANGE = 150,
23054 JSMSG_BAD_GETTER_OR_SETTER = 151,
23055 JSMSG_BAD_ARRAY_LENGTH = 152,
23056 JSMSG_CANT_DESCRIBE_PROPS = 153,
23057 JSMSG_BAD_APPLY_ARGS = 154,
23058 JSMSG_REDECLARED_VAR = 155,
23059 JSMSG_UNDECLARED_VAR = 156,
23060 JSMSG_ANON_NO_RETURN_VALUE = 157,
23061 JSMSG_DEPRECATED_USAGE = 158,
23062 JSMSG_BAD_URI = 159,
23063 JSMSG_GETTER_ONLY = 160,
23064 JSMSG_IDSTART_AFTER_NUMBER = 161,
23065 JSMSG_UNDEFINED_PROP = 162,
23066 JSMSG_USELESS_EXPR = 163,
23067 JSMSG_REDECLARED_PARAM = 164,
23068 JSMSG_NEWREGEXP_FLAGGED = 165,
23069 JSMSG_RESERVED_SLOT_RANGE = 166,
23070 JSMSG_CANT_DECODE_PRINCIPALS = 167,
23071 JSMSG_CANT_SEAL_OBJECT = 168,
23072 JSMSG_TOO_MANY_CATCH_VARS = 169,
23073 JSMSG_BAD_XML_MARKUP = 170,
23074 JSMSG_BAD_XML_CHARACTER = 171,
23075 JSMSG_BAD_DEFAULT_XML_NAMESPACE = 172,
23076 JSMSG_BAD_XML_NAME_SYNTAX = 173,
23077 JSMSG_BRACKET_AFTER_ATTR_EXPR = 174,
23078 JSMSG_NESTING_GENERATOR = 175,
23079 JSMSG_CURLY_IN_XML_EXPR = 176,
23080 JSMSG_BAD_XML_NAMESPACE = 177,
23081 JSMSG_BAD_XML_ATTR_NAME = 178,
23082 JSMSG_BAD_XML_NAME = 179,
23083 JSMSG_BAD_XML_CONVERSION = 180,
23084 JSMSG_BAD_XMLLIST_CONVERSION = 181,
23085 JSMSG_BAD_GENERATOR_SEND = 182,
23086 JSMSG_NO_ASSIGN_IN_XML_ATTR = 183,
23087 JSMSG_BAD_XML_ATTR_VALUE = 184,
23088 JSMSG_XML_TAG_NAME_MISMATCH = 185,
23089 JSMSG_BAD_XML_TAG_SYNTAX = 186,
23090 JSMSG_BAD_XML_LIST_SYNTAX = 187,
23091 JSMSG_INCOMPATIBLE_METHOD = 188,
23092 JSMSG_CANT_SET_XML_ATTRS = 189,
23093 JSMSG_END_OF_XML_SOURCE = 190,
23094 JSMSG_END_OF_XML_ENTITY = 191,
23095 JSMSG_BAD_XML_QNAME = 192,
23096 JSMSG_BAD_FOR_EACH_LOOP = 193,
23097 JSMSG_BAD_XMLLIST_PUT = 194,
23098 JSMSG_UNKNOWN_XML_ENTITY = 195,
23099 JSMSG_BAD_XML_NCR = 196,
23100 JSMSG_UNDEFINED_XML_NAME = 197,
23101 JSMSG_DUPLICATE_XML_ATTR = 198,
23102 JSMSG_TOO_MANY_LOCALS = 199,
23103 JSMSG_ARRAY_INIT_TOO_BIG = 200,
23104 JSMSG_REGEXP_TOO_COMPLEX = 201,
23105 JSMSG_BUFFER_TOO_SMALL = 202,
23106 JSMSG_BAD_SURROGATE_CHAR = 203,
23107 JSMSG_UTF8_CHAR_TOO_LARGE = 204,
23108 JSMSG_MALFORMED_UTF8_CHAR = 205,
23109 JSMSG_USER_DEFINED_ERROR = 206,
23110 JSMSG_WRONG_CONSTRUCTOR = 207,
23111 JSMSG_BAD_GENERATOR_RETURN = 208,
23112 JSMSG_BAD_ANON_GENERATOR_RETURN = 209,
23113 JSMSG_NAME_AFTER_FOR_PAREN = 210,
23114 JSMSG_IN_AFTER_FOR_NAME = 211,
23115 JSMSG_BAD_TRAP_RETURN_VALUE = 212,
23116 JSMSG_KEYWORD_NOT_NS = 213,
23117 JSMSG_BAD_GENERATOR_YIELD = 214,
23118 JSMSG_BAD_GENERATOR_SYNTAX = 215,
23119 JSMSG_ARRAY_COMP_LEFTSIDE = 216,
23120 JSMSG_NON_XML_FILTER = 217,
23121 JSMSG_EMPTY_ARRAY_REDUCE = 218,
23122 JSMSG_NON_LIST_XML_METHOD = 219,
23123 JSMSG_BAD_DELETE_OPERAND = 220,
23124 JSMSG_BAD_INCOP_OPERAND = 221,
23125 JSMSG_UNEXPECTED_TYPE = 222,
23126 JSMSG_LET_DECL_NOT_IN_BLOCK = 223,
23127 JSMSG_BAD_OBJECT_INIT = 224,
23128 JSMSG_CANT_SET_ARRAY_ATTRS = 225,
23129 JSMSG_EVAL_ARITY = 226,
23130 JSMSG_MISSING_FUN_ARG = 227,
23131 JSMSG_JSON_BAD_PARSE = 228,
23132 JSMSG_JSON_BAD_STRINGIFY = 229,
23133 JSMSG_XDR_CLOSURE_WRAPPER = 230,
23134 JSMSG_NOT_NONNULL_OBJECT = 231,
23135 JSMSG_DEPRECATED_OCTAL = 232,
23136 JSMSG_STRICT_CODE_WITH = 233,
23137 JSMSG_DUPLICATE_PROPERTY = 234,
23138 JSMSG_DEPRECATED_DELETE_OPERAND = 235,
23139 JSMSG_DEPRECATED_ASSIGN = 236,
23140 JSMSG_BAD_BINDING = 237,
23141 JSMSG_INVALID_DESCRIPTOR = 238,
23142 JSMSG_OBJECT_NOT_EXTENSIBLE = 239,
23143 JSMSG_CANT_REDEFINE_PROP = 240,
23144 JSMSG_CANT_APPEND_TO_ARRAY = 241,
23145 JSMSG_CANT_DEFINE_ARRAY_LENGTH = 242,
23146 JSMSG_CANT_DEFINE_ARRAY_INDEX = 243,
23147 JSMSG_TYPED_ARRAY_BAD_INDEX = 244,
23148 JSMSG_TYPED_ARRAY_NEGATIVE_ARG = 245,
23149 JSMSG_TYPED_ARRAY_BAD_ARGS = 246,
23150 JSMSG_CSP_BLOCKED_FUNCTION = 247,
23151 JSMSG_BAD_GET_SET_FIELD = 248,
23152 JSMSG_BAD_PROXY_FIX = 249,
23153 JSMSG_INVALID_EVAL_SCOPE_ARG = 250,
23154 JSMSG_ACCESSOR_WRONG_ARGS = 251,
23155 JSMSG_THROW_TYPE_ERROR = 252,
23156 JSMSG_BAD_TOISOSTRING_PROP = 253,
23157 JSMSG_BAD_PARSE_NODE = 254,
23158 JSMSG_NOT_EXPECTED_TYPE = 255,
23159 JSMSG_CALLER_IS_STRICT = 256,
23160 JSMSG_NEED_DEBUG_MODE = 257,
23161 JSMSG_STRICT_CODE_LET_EXPR_STMT = 258,
23162 JSMSG_CANT_CHANGE_EXTENSIBILITY = 259,
23163 JSMSG_SC_BAD_SERIALIZED_DATA = 260,
23164 JSMSG_SC_UNSUPPORTED_TYPE = 261,
23165 JSMSG_SC_RECURSION = 262,
23166 JSMSG_CANT_WRAP_XML_OBJECT = 263,
23167 JSMSG_BAD_CLONE_VERSION = 264,
23168 JSMSG_CANT_CLONE_OBJECT = 265,
23169 JSMSG_NON_NATIVE_SCOPE = 266,
23170 JSMSG_STRICT_FUNCTION_STATEMENT = 267,
23171 JSMSG_INVALID_FOR_IN_INIT = 268,
23172 JSMSG_CLEARED_SCOPE = 269,
23173 # 3000 "jscntxt.h" 2
23178 extern __attribute__((visibility ("default"))) const JSErrorFormatString *
23179 js_GetErrorMessage(void *userRef, const char *locale, const uintN errorNumber);
23183 js_ReportErrorVA(JSContext *cx, uintN flags, const char *format, va_list ap);
23186 js_ReportErrorNumberVA(JSContext *cx, uintN flags, JSErrorCallback callback,
23187 void *userRef, const uintN errorNumber,
23188 JSBool charArgs, va_list ap);
23191 js_ExpandErrorArguments(JSContext *cx, JSErrorCallback callback,
23192 void *userRef, const uintN errorNumber,
23193 char **message, JSErrorReport *reportp,
23194 bool charArgs, va_list ap);
23198 js_ReportOutOfMemory(JSContext *cx);
23204 js_ReportOutOfScriptQuota(JSContext *cx);
23206 extern __attribute__((visibility ("default"))) void
23207 js_ReportOverRecursed(JSContext *cx);
23209 extern __attribute__((visibility ("default"))) void
23210 js_ReportAllocationOverflow(JSContext *cx);
23212 extern __attribute__((visibility ("default"))) void
23213 js_ReportErrorAgain(JSContext *cx, const char *message, JSErrorReport *report);
23216 js_ReportIsNotDefined(JSContext *cx, const char *name);
23222 js_ReportIsNullOrUndefined(JSContext *cx, intN spindex, const js::Value &v,
23223 JSString *fallback);
23226 js_ReportMissingArg(JSContext *cx, const js::Value &v, uintN arg);
23234 js_ReportValueErrorFlags(JSContext *cx, uintN flags, const uintN errorNumber,
23235 intN spindex, const js::Value &v, JSString *fallback,
23236 const char *arg1, const char *arg2);
23238 extern JSErrorFormatString js_ErrorFormatString[JSErr_Limit];
23240 __attribute__((always_inline)) inline void
23241 JSThreadData::triggerOperationCallback(JSRuntime *rt)
23249 if (interruptFlags)
23251 PR_AtomicSet((PRInt32 *)(&interruptFlags), (PRInt32)(1));
23255 if (requestDepth != 0)
23256 PR_AtomicIncrement((PRInt32 *)(&rt->interruptCounter));
23265 js_InvokeOperationCallback(JSContext *cx);
23268 js_HandleExecutionInterrupt(JSContext *cx);
23274 __attribute__((visibility ("default"))) void
23275 TriggerOperationCallback(JSContext *cx);
23278 TriggerAllOperationCallbacks(JSRuntime *rt);
23282 extern JSStackFrame *
23283 js_GetScriptedCaller(JSContext *cx, JSStackFrame *fp);
23286 js_GetCurrentBytecodePC(JSContext* cx);
23292 js_CurrentPCIsInImacro(JSContext *cx);
23296 class RegExpStatics;
23298 extern __attribute__((visibility ("default"))) void
23299 LeaveTrace(JSContext *cx);
23309 static inline JSStackFrame *
23310 js_GetTopStackFrame(JSContext *cx)
23312 js::LeaveTrace(cx);
23313 return cx->maybefp();
23316 static inline JSBool
23317 js_IsPropertyCacheDisabled(JSContext *cx)
23319 return cx->runtime->shapeGen >= js::SHAPE_OVERFLOW_BIT;
23322 static inline uint32
23323 js_RegenerateShapeForGC(JSRuntime *rt)
23333 uint32 shape = rt->shapeGen;
23334 shape = (shape + 1) | (shape & js::SHAPE_OVERFLOW_BIT);
23335 rt->shapeGen = shape;
23342 ContextAllocPolicy::malloc(size_t bytes)
23344 return cx->malloc(bytes);
23348 ContextAllocPolicy::free(void *p)
23354 ContextAllocPolicy::realloc(void *p, size_t bytes)
23356 return cx->realloc(p, bytes);
23360 ContextAllocPolicy::reportAllocOverflow() const
23362 js_ReportAllocationOverflow(cx);
23366 class AutoVectorRooter : protected AutoGCRooter
23369 explicit AutoVectorRooter(JSContext *cx, ptrdiff_t tag
23371 : AutoGCRooter(cx, tag), vector(cx)
23376 size_t length() const { return vector.length(); }
23378 bool append(const T &v) { return vector.append(v); }
23380 void popBack() { vector.popBack(); }
23382 bool growBy(size_t inc) {
23383 size_t oldLength = vector.length();
23384 if (!vector.growByUninitialized(inc))
23386 MakeRangeGCSafe(vector.begin() + oldLength, vector.end());
23390 bool resize(size_t newLength) {
23391 size_t oldLength = vector.length();
23392 if (newLength <= oldLength) {
23393 vector.shrinkBy(oldLength - newLength);
23396 if (!vector.growByUninitialized(newLength - oldLength))
23398 MakeRangeGCSafe(vector.begin() + oldLength, vector.end());
23402 bool reserve(size_t newLength) {
23403 return vector.reserve(newLength);
23406 T &operator[](size_t i) { return vector[i]; }
23407 const T &operator[](size_t i) const { return vector[i]; }
23409 const T *begin() const { return vector.begin(); }
23410 T *begin() { return vector.begin(); }
23412 const T *end() const { return vector.end(); }
23413 T *end() { return vector.end(); }
23415 const T &back() const { return vector.back(); }
23417 friend void AutoGCRooter::trace(JSTracer *trc);
23420 Vector<T, 8> vector;
23424 class AutoValueVector : public AutoVectorRooter<Value>
23427 explicit AutoValueVector(JSContext *cx
23429 : AutoVectorRooter<Value>(cx, VALVECTOR)
23434 const jsval *jsval_begin() const { return Jsvalify(begin()); }
23435 jsval *jsval_begin() { return Jsvalify(begin()); }
23437 const jsval *jsval_end() const { return Jsvalify(end()); }
23438 jsval *jsval_end() { return Jsvalify(end()); }
23443 class AutoIdVector : public AutoVectorRooter<jsid>
23446 explicit AutoIdVector(JSContext *cx
23448 : AutoVectorRooter<jsid>(cx, IDVECTOR)
23456 class AutoShapeVector : public AutoVectorRooter<const Shape *>
23459 explicit AutoShapeVector(JSContext *cx
23461 : AutoVectorRooter<const Shape *>(cx, SHAPEVECTOR)
23470 NewIdArray(JSContext *cx, jsint length);
23480 typedef union jsdpun {
23493 JSDOUBLE_IS_NaN(jsdouble d)
23498 return (sizeof (d) == sizeof (float) ? __isnanf (d) : sizeof (d) == sizeof (double) ? __isnan (d) : __isnanl (d));
23503 JSDOUBLE_IS_FINITE(jsdouble d)
23515 JSDOUBLE_IS_INFINITE(jsdouble d)
23523 return (sizeof (d) == sizeof (float) ? __isinff (d) : sizeof (d) == sizeof (double) ? __isinf (d) : __isinfl (d));
23537 JSDOUBLE_IS_NEG(jsdouble d)
23544 return (sizeof (d) == sizeof (float) ? __signbitf (d) : sizeof (d) == sizeof (double) ? __signbit (d) : __signbitl (d));
23548 static inline uint32
23549 JS_HASH_DOUBLE(jsdouble d)
23553 return u.s.lo ^ u.s.hi;
23556 extern jsdouble js_NaN;
23557 extern jsdouble js_PositiveInfinity;
23558 extern jsdouble js_NegativeInfinity;
23562 js_InitRuntimeNumberState(JSContext *cx);
23565 js_FinishRuntimeNumberState(JSContext *cx);
23568 extern js::Class js_NumberClass;
23574 JSObject::isNumber() const
23576 return getClass() == &js_NumberClass;
23580 js_InitNumberClass(JSContext *cx, JSObject *obj);
23585 extern const char js_Infinity_str[];
23586 extern const char js_NaN_str[];
23587 extern const char js_isNaN_str[];
23588 extern const char js_isFinite_str[];
23589 extern const char js_parseFloat_str[];
23590 extern const char js_parseInt_str[];
23593 js_IntToString(JSContext *cx, jsint i);
23601 js_NumberToString(JSContext *cx, jsdouble d);
23610 NumberValueToStringBuffer(JSContext *cx, const Value &v, StringBuffer &sb);
23613 extern JSFlatString *
23614 NumberToString(JSContext *cx, jsdouble d);
23621 struct ToCStringBuf
23628 static const size_t sbufSize = 34;
23629 char sbuf[sbufSize];
23643 NumberToCString(JSContext *cx, ToCStringBuf *cbuf, jsdouble d, jsint base = 10);
23649 const double DOUBLE_INTEGRAL_PRECISION_LIMIT = uint64(1) << 53;
23655 GetPrefixInteger(JSContext *cx, const jschar *start, const jschar *end, int base,
23656 const jschar **endp, jsdouble *dp);
23662 __attribute__((always_inline)) inline
23666 ValueToNumber(JSContext *cx, const js::Value &v, double *out)
23668 if (v.isNumber()) {
23669 *out = v.toNumber();
23672 extern bool ValueToNumberSlow(JSContext *, js::Value, double *);
23673 return ValueToNumberSlow(cx, v, out);
23677 __attribute__((always_inline)) inline
23681 ValueToNumber(JSContext *cx, js::Value *vp)
23683 if (vp->isNumber())
23686 extern bool ValueToNumberSlow(JSContext *, js::Value, double *);
23687 if (!ValueToNumberSlow(cx, *vp, &d))
23698 __attribute__((always_inline)) inline
23702 ValueToECMAInt32(JSContext *cx, const js::Value &v, int32_t *out)
23705 *out = v.toInt32();
23708 extern bool ValueToECMAInt32Slow(JSContext *, const js::Value &, int32_t *);
23709 return ValueToECMAInt32Slow(cx, v, out);
23712 __attribute__((always_inline)) inline
23716 ValueToECMAUint32(JSContext *cx, const js::Value &v, uint32_t *out)
23719 *out = (uint32_t)v.toInt32();
23722 extern bool ValueToECMAUint32Slow(JSContext *, const js::Value &, uint32_t *);
23723 return ValueToECMAUint32Slow(cx, v, out);
23731 __attribute__((always_inline)) inline
23735 ValueToInt32(JSContext *cx, const js::Value &v, int32_t *out)
23738 *out = v.toInt32();
23741 extern bool ValueToInt32Slow(JSContext *, const js::Value &, int32_t *);
23742 return ValueToInt32Slow(cx, v, out);
23750 __attribute__((always_inline)) inline
23754 ValueToUint16(JSContext *cx, const js::Value &v, uint16_t *out)
23757 *out = (uint16_t)v.toInt32();
23760 extern bool ValueToUint16Slow(JSContext *, const js::Value &, uint16_t *);
23761 return ValueToUint16Slow(cx, v, out);
23766 static inline int32
23767 js_DoubleToECMAInt32(jsdouble d)
23771 jsdouble two32, two31;
23773 if (!JSDOUBLE_IS_FINITE(d))
23777 if ((jsdouble) i == d)
23780 two32 = 4294967296.0;
23781 two31 = 2147483648.0;
23782 d = fmod(d, two32);
23783 d = (d >= 0) ? floor(d) : ceil(d) + two32;
23784 return (int32) (d >= two31 ? d - two32 : d);
23789 js_DoubleToECMAUint32(jsdouble d);
23795 static inline jsdouble
23796 js_DoubleToInteger(jsdouble d)
23801 if (!JSDOUBLE_IS_FINITE(d)) {
23802 if (JSDOUBLE_IS_NaN(d))
23807 JSBool neg = (d < 0);
23808 d = floor(neg ? -d : d);
23810 return neg ? -d : d;
23814 js_strtod(JSContext *cx, const jschar *s, const jschar *send,
23815 const jschar **ep, jsdouble *dp);
23818 js_num_valueOf(JSContext *cx, uintN argc, js::Value *vp);
23822 static __attribute__((always_inline)) inline
23826 ValueFitsInInt32(const Value &v, int32_t *pi)
23832 return v.isDouble() && JSDOUBLE_IS_INT32(v.toDouble(), pi);
23835 template<typename T> struct NumberTraits { };
23836 template<> struct NumberTraits<int32> {
23837 static __attribute__((always_inline)) inline int32 NaN() { return 0; }
23838 static __attribute__((always_inline)) inline int32 toSelfType(int32 i) { return i; }
23839 static __attribute__((always_inline)) inline int32 toSelfType(jsdouble d) { return js_DoubleToECMAUint32(d); }
23841 template<> struct NumberTraits<jsdouble> {
23842 static __attribute__((always_inline)) inline jsdouble NaN() { return js_NaN; }
23843 static __attribute__((always_inline)) inline jsdouble toSelfType(int32 i) { return i; }
23844 static __attribute__((always_inline)) inline jsdouble toSelfType(jsdouble d) { return d; }
23847 template<typename T>
23848 static __attribute__((always_inline)) inline
23852 StringToNumberType(JSContext *cx, JSString *str, T *result)
23854 size_t length = str->length();
23855 const jschar *chars = str->getChars(__null);
23860 jschar c = chars[0];
23861 if ('0' <= c && c <= '9') {
23862 *result = NumberTraits<T>::toSelfType(T(c - '0'));
23865 if (JS_ISSPACE(c)) {
23866 *result = NumberTraits<T>::toSelfType(T(0));
23869 *result = NumberTraits<T>::NaN();
23873 const jschar *bp = chars;
23874 const jschar *end = chars + length;
23875 bp = js_SkipWhiteSpace(bp, end);
23878 if (end - bp >= 2 && bp[0] == '0' && (bp[1] == 'x' || bp[1] == 'X')) {
23880 const jschar *endptr;
23882 if (!GetPrefixInteger(cx, bp + 2, end, 16, &endptr, &d) ||
23883 js_SkipWhiteSpace(endptr, end) != end) {
23884 *result = NumberTraits<T>::NaN();
23887 *result = NumberTraits<T>::toSelfType(d);
23893 if (!js_strtod(cx, bp, end, &ep, &d) || js_SkipWhiteSpace(ep, end) != end) {
23894 *result = NumberTraits<T>::NaN();
23897 *result = NumberTraits<T>::toSelfType(d);
23906 # 1 "jsversion.h" 1
23913 # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4
23917 # 1 "jsversion.h" 1
23926 # 1 "jskeyword.tbl" 1
23927 # 45 "jskeyword.tbl"
23928 extern const char js_false_str[];
23929 extern const char js_true_str[];
23930 extern const char js_null_str[];
23933 extern const char js_break_str[];
23934 extern const char js_case_str[];
23935 extern const char js_catch_str[];
23936 extern const char js_continue_str[];
23937 extern const char js_debugger_str[];
23938 extern const char js_default_str[];
23939 extern const char js_delete_str[];
23940 extern const char js_do_str[];
23941 extern const char js_else_str[];
23942 extern const char js_finally_str[];
23943 extern const char js_for_str[];
23944 extern const char js_function_str[];
23945 extern const char js_if_str[];
23946 extern const char js_in_str[];
23947 extern const char js_instanceof_str[];
23948 extern const char js_new_str[];
23949 extern const char js_return_str[];
23950 extern const char js_switch_str[];
23951 extern const char js_this_str[];
23952 extern const char js_throw_str[];
23953 extern const char js_try_str[];
23954 extern const char js_typeof_str[];
23955 extern const char js_var_str[];
23956 extern const char js_void_str[];
23957 extern const char js_while_str[];
23958 extern const char js_with_str[];
23964 extern const char js_class_str[];
23965 extern const char js_enum_str[];
23966 extern const char js_export_str[];
23967 extern const char js_extends_str[];
23968 extern const char js_import_str[];
23969 extern const char js_super_str[];
23976 extern const char js_const_str[];
23981 extern const char js_let_str[];
23986 extern const char js_yield_str[];
23992 extern const char js_implements_str[];
23993 extern const char js_interface_str[];
23994 extern const char js_package_str[];
23995 extern const char js_private_str[];
23996 extern const char js_protected_str[];
23997 extern const char js_public_str[];
23998 extern const char js_static_str[];
24011 TOK_HOOK = 5, TOK_COLON = 6,
24022 TOK_STAR = 17, TOK_DIVOP = 18,
24024 TOK_INC = 20, TOK_DEC = 21,
24026 TOK_LB = 23, TOK_RB = 24,
24027 TOK_LC = 25, TOK_RC = 26,
24028 TOK_LP = 27, TOK_RP = 28,
24057 TOK_INSTANCEOF = 57,
24067 TOK_XMLCOMMENT = 67,
24078 TOK_ARRAYCOMP = 78,
24079 TOK_ARRAYPUSH = 79,
24080 TOK_LEXICALSCOPE = 80,
24090 TOK_STRICT_RESERVED,
24098 TokenKindIsXML(TokenKind tt)
24100 return tt == TOK_AT || tt == TOK_DBLCOLON || tt == TOK_ANYNAME;
24107 TreeTypeIsXML(TokenKind tt)
24109 return tt == TOK_XMLCOMMENT || tt == TOK_XMLCDATA || tt == TOK_XMLPI ||
24110 tt == TOK_XMLELEM || tt == TOK_XMLLIST;
24117 TokenKindIsDecl(TokenKind tt)
24120 return tt == TOK_VAR || tt == TOK_LET;
24130 bool operator==(const TokenPtr& bptr) {
24131 return index == bptr.index && lineno == bptr.lineno;
24134 bool operator!=(const TokenPtr& bptr) {
24135 return index != bptr.index || lineno != bptr.lineno;
24138 bool operator <(const TokenPtr& bptr) {
24139 return lineno < bptr.lineno ||
24140 (lineno == bptr.lineno && index < bptr.index);
24143 bool operator <=(const TokenPtr& bptr) {
24144 return lineno < bptr.lineno ||
24145 (lineno == bptr.lineno && index <= bptr.index);
24148 bool operator >(const TokenPtr& bptr) {
24149 return !(*this <= bptr);
24152 bool operator >=(const TokenPtr& bptr) {
24153 return !(*this < bptr);
24161 bool operator==(const TokenPos& bpos) {
24162 return begin == bpos.begin && end == bpos.end;
24165 bool operator!=(const TokenPos& bpos) {
24166 return begin != bpos.begin || end != bpos.end;
24169 bool operator <(const TokenPos& bpos) {
24170 return begin < bpos.begin;
24173 bool operator <=(const TokenPos& bpos) {
24174 return begin <= bpos.begin;
24177 bool operator >(const TokenPos& bpos) {
24178 return !(*this <= bpos);
24181 bool operator >=(const TokenPos& bpos) {
24182 return !(*this < bpos);
24205 enum TokenStreamFlags
24209 TSF_NEWLINES = 0x04,
24210 TSF_OPERAND = 0x08,
24211 TSF_UNEXPECTED_EOF = 0x10,
24212 TSF_KEYWORD_IS_NAME = 0x20,
24213 TSF_STRICT_MODE_CODE = 0x40,
24214 TSF_DIRTYLINE = 0x80,
24215 TSF_OWNFILENAME = 0x100,
24216 TSF_XMLTAGMODE = 0x200,
24217 TSF_XMLTEXTMODE = 0x400,
24218 TSF_XMLONLYMODE = 0x800,
24219 TSF_OCTAL_CHAR = 0x1000,
24221 TSF_IN_HTML_COMMENT = 0x2000
24232 static const size_t ntokens = 4;
24234 static const uintN ntokensMask = ntokens - 1;
24237 typedef Vector<jschar, 32> CharBuffer;
24239 TokenStream(JSContext *);
24245 bool init(const jschar *base, size_t length, const char *filename, uintN lineno,
24246 JSVersion version);
24251 JSContext *getContext() const { return cx; }
24252 bool onCurrentLine(const TokenPos &pos) const { return lineno == pos.end.lineno; }
24253 const Token ¤tToken() const { return tokens[cursor]; }
24254 const CharBuffer &getTokenbuf() const { return tokenbuf; }
24255 const char *getFilename() const { return filename; }
24256 uintN getLineno() const { return lineno; }
24258 JSVersion versionNumber() const { return VersionNumber(version); }
24259 JSVersion versionWithFlags() const { return version; }
24260 bool hasAnonFunFix() const { return VersionHasAnonFunFix(version); }
24261 bool hasXML() const { return xml || VersionShouldParseXML(versionNumber()); }
24262 void setXML(bool enabled) { xml = enabled; }
24265 void setStrictMode(bool enabled = true) { setFlag(enabled, TSF_STRICT_MODE_CODE); }
24266 void setXMLTagMode(bool enabled = true) { setFlag(enabled, TSF_XMLTAGMODE); }
24267 void setXMLOnlyMode(bool enabled = true) { setFlag(enabled, TSF_XMLONLYMODE); }
24268 void setUnexpectedEOF(bool enabled = true) { setFlag(enabled, TSF_UNEXPECTED_EOF); }
24269 void setOctalCharacterEscape(bool enabled = true) { setFlag(enabled, TSF_OCTAL_CHAR); }
24271 bool isStrictMode() { return !!(flags & TSF_STRICT_MODE_CODE); }
24272 bool isXMLTagMode() { return !!(flags & TSF_XMLTAGMODE); }
24273 bool isXMLOnlyMode() { return !!(flags & TSF_XMLONLYMODE); }
24274 bool isUnexpectedEOF() { return !!(flags & TSF_UNEXPECTED_EOF); }
24275 bool isEOF() const { return !!(flags & TSF_EOF); }
24276 bool isError() const { return !!(flags & TSF_ERROR); }
24277 bool hasOctalCharacterEscape() const { return flags & TSF_OCTAL_CHAR; }
24280 bool reportCompileErrorNumberVA(JSParseNode *pn, uintN flags, uintN errorNumber, va_list ap);
24281 void mungeCurrentToken(TokenKind newKind) { tokens[cursor].type = newKind; }
24282 void mungeCurrentToken(JSOp newOp) { tokens[cursor].u.s.op = newOp; }
24283 void mungeCurrentToken(TokenKind newKind, JSOp newOp) {
24284 mungeCurrentToken(newKind);
24285 mungeCurrentToken(newOp);
24289 static JSAtom *atomize(JSContext *cx, CharBuffer &cb);
24296 TokenStream * const parent;
24299 Flagger(TokenStream *parent, uintN withFlags) : parent(parent), flags(withFlags) {
24300 parent->flags |= flags;
24303 ~Flagger() { parent->flags &= ~flags; }
24305 friend class Flagger;
24307 void setFlag(bool enabled, TokenStreamFlags flag) {
24319 TokenKind getToken() {
24321 while (lookahead != 0) {
24324 cursor = (cursor + 1) & ntokensMask;
24325 TokenKind tt = currentToken().type;
24332 if (flags & TSF_ERROR)
24335 return getTokenInternal();
24339 TokenKind getToken(uintN withFlags) {
24340 Flagger flagger(this, withFlags);
24347 void ungetToken() {
24350 cursor = (cursor - 1) & ntokensMask;
24353 TokenKind peekToken(uintN withFlags = 0) {
24354 Flagger flagger(this, withFlags);
24355 if (lookahead != 0) {
24357 return tokens[(cursor + lookahead) & ntokensMask].type;
24359 TokenKind tt = getToken();
24364 TokenKind peekTokenSameLine(uintN withFlags = 0) {
24365 Flagger flagger(this, withFlags);
24366 if (!onCurrentLine(currentToken().pos))
24368 TokenKind tt = peekToken(TSF_NEWLINES);
24375 JSBool matchToken(TokenKind tt, uintN withFlags = 0) {
24376 Flagger flagger(this, withFlags);
24377 if (getToken() == tt)
24384 typedef struct TokenBuf {
24390 TokenKind getTokenInternal();
24393 int32 getCharIgnoreEOL();
24394 void ungetChar(int32 c);
24395 void ungetCharIgnoreEOL(int32 c);
24396 Token *newToken(ptrdiff_t adjust);
24397 bool peekUnicodeEscape(int32 *c);
24398 bool matchUnicodeEscapeIdStart(int32 *c);
24399 bool matchUnicodeEscapeIdent(int32 *c);
24400 JSBool peekChars(intN n, jschar *cp);
24401 JSBool getXMLEntity();
24404 JSBool matchChar(int32 expect) {
24405 int32 c = getChar();
24413 int32 c = getChar();
24418 void skipChars(intN n) {
24423 JSContext * const cx;
24424 Token tokens[ntokens];
24430 jschar *prevLinebase;
24432 const char *filename;
24433 JSSourceHandler listener;
24434 void *listenerData;
24435 void *listenerTSData;
24436 CharBuffer tokenbuf;
24437 bool maybeEOL[256];
24438 bool maybeStrSpecial[256];
24450 js_CloseTokenStream(JSContext *cx, js::TokenStream *ts);
24452 extern __attribute__((visibility ("default"))) int
24453 js_fgets(char *buf, int size, FILE *file);
24457 struct KeywordInfo {
24459 TokenKind tokentype;
24468 extern const KeywordInfo *
24469 FindKeyword(const jschar *s, size_t length);
24477 typedef void (*JSMapKeywordFun)(const char *);
24484 js_IsIdentifier(JSLinearString *str);
24502 ReportCompileErrorNumber(JSContext *cx, TokenStream *ts, JSParseNode *pn, uintN flags,
24503 uintN errorNumber, ...);
24508 ReportStrictModeError(JSContext *cx, TokenStream *ts, JSTreeContext *tc, JSParseNode *pn,
24509 uintN errorNumber, ...);
24516 typedef enum JSParseNodeArity {
24525 } JSParseNodeArity;
24527 struct JSDefinition;
24531 struct GlobalScope {
24532 GlobalScope(JSContext *cx, JSObject *globalObj, JSCodeGenerator *cg)
24533 : globalObj(globalObj), cg(cg), defs(ContextAllocPolicy(cx))
24538 JSFunctionBox *funbox;
24543 GlobalDef(uint32 knownSlot)
24544 : atom(__null), knownSlot(knownSlot)
24546 GlobalDef(JSAtom *atom, JSFunctionBox *box) :
24547 atom(atom), funbox(box)
24551 JSObject *globalObj;
24552 JSCodeGenerator *cg;
24554 Vector<GlobalDef, 16, ContextAllocPolicy> defs;
24560 struct JSParseNode {
24571 js::TokenPos pn_pos;
24573 JSParseNode *pn_next;
24574 JSParseNode *pn_link;
24580 JSParseNode **tail;
24592 JSParseNode *right;
24606 JSFunctionBox *funbox;
24607 JSObjectBox *objbox;
24612 JSDefinition *lexdef;
24614 js::UpvarCookie cookie;
24633 void inline init(js::TokenKind type, JSOp op, JSParseNodeArity arity) {
24640 pn_next = pn_link = __null;
24643 static JSParseNode *create(JSParseNodeArity arity, JSTreeContext *tc);
24646 static JSParseNode *newBinaryOrAppend(js::TokenKind tt, JSOp op, JSParseNode *left,
24647 JSParseNode *right, JSTreeContext *tc);
24655 JSParseNode *expr() const {
24658 return pn_u.name.expr;
24661 JSDefinition *lexdef() const {
24664 return pn_u.name.lexdef;
24667 JSParseNode *maybeExpr() { return pn_used ? __null : expr(); }
24668 JSDefinition *maybeLexDef() { return pn_used ? lexdef() : __null; }
24670 uintN frameLevel() const {
24672 return pn_u.name.cookie.level();
24675 uintN frameSlot() const {
24677 return pn_u.name.cookie.slot();
24680 inline bool test(uintN flag) const;
24682 bool isLet() const { return test(0x01); }
24683 bool isConst() const { return test(0x02); }
24684 bool isInitialized() const { return test(0x04); }
24685 bool isBlockChild() const { return test(0x20); }
24686 bool isPlaceholder() const { return test(0x80); }
24687 bool isDeoptimized() const { return test(0x400); }
24688 bool isAssigned() const { return test(0x08); }
24689 bool isFunArg() const { return test(0x100); }
24690 bool isClosed() const { return test(0x800); }
24692 bool isTopLevel() const { return test(0x10); }
24697 void become(JSParseNode *pn2);
24701 bool isLiteral() const {
24702 return ((js::TokenKind)(this)->pn_type) == js::TOK_NUMBER ||
24703 ((js::TokenKind)(this)->pn_type) == js::TOK_STRING ||
24704 (((js::TokenKind)(this)->pn_type) == js::TOK_PRIMARY && ((JSOp)(this)->pn_op) != JSOP_THIS);
24707 bool isStringExprStatement() const {
24708 if (((js::TokenKind)(this)->pn_type) == js::TOK_SEMI) {
24710 JSParseNode *kid = pn_u.unary.kid;
24711 return kid && ((js::TokenKind)(kid)->pn_type) == js::TOK_STRING && !kid->pn_parens;
24721 bool isEscapeFreeStringLiteral() const {
24723 JSString *str = (pn_u.name.atom);
24730 return (pn_pos.begin.lineno == pn_pos.end.lineno &&
24731 pn_pos.begin.index + str->length() + 2 == pn_pos.end.index);
24735 bool isDirectivePrologueMember() const { return pn_u.unary.hidden; }
24741 bool isGeneratorExpr() const {
24742 if (((js::TokenKind)(this)->pn_type) == js::TOK_LP) {
24743 JSParseNode *callee = this->pn_u.list.head;
24744 if (((js::TokenKind)(callee)->pn_type) == js::TOK_FUNCTION) {
24745 JSParseNode *body = (((js::TokenKind)(callee->pn_u.name.expr)->pn_type) == js::TOK_UPVARS)
24746 ? callee->pn_u.name.expr->pn_u.nameset.tree
24747 : callee->pn_u.name.expr;
24748 if (((js::TokenKind)(body)->pn_type) == js::TOK_LEXICALSCOPE)
24755 JSParseNode *generatorExpr() const {
24757 JSParseNode *callee = this->pn_u.list.head;
24758 JSParseNode *body = ((js::TokenKind)(callee->pn_u.name.expr)->pn_type) == js::TOK_UPVARS
24759 ? callee->pn_u.name.expr->pn_u.nameset.tree
24760 : callee->pn_u.name.expr;
24762 return body->pn_u.name.expr;
24770 JSParseNode *last() const {
24773 return (JSParseNode *)((char *)pn_u.list.tail - __builtin_offsetof (JSParseNode, pn_next));
24778 pn_u.list.head = __null;
24779 pn_u.list.tail = &pn_u.list.head;
24780 pn_u.list.count = 0;
24781 pn_u.list.xflags = 0;
24782 pn_u.name.blockid = 0;
24785 void initList(JSParseNode *pn) {
24787 pn_u.list.head = pn;
24788 pn_u.list.tail = &pn->pn_next;
24789 pn_u.list.count = 1;
24790 pn_u.list.xflags = 0;
24791 pn_u.name.blockid = 0;
24794 void append(JSParseNode *pn) {
24796 *pn_u.list.tail = pn;
24797 pn_u.list.tail = &pn->pn_next;
24801 bool getConstantValue(JSContext *cx, bool strictChecks, js::Value *vp);
24802 inline bool isConstant();
24807 struct NullaryNode : public JSParseNode {
24808 static inline NullaryNode *create(JSTreeContext *tc) {
24809 return (NullaryNode *)JSParseNode::create(PN_NULLARY, tc);
24813 struct UnaryNode : public JSParseNode {
24814 static inline UnaryNode *create(JSTreeContext *tc) {
24815 return (UnaryNode *)JSParseNode::create(PN_UNARY, tc);
24819 struct BinaryNode : public JSParseNode {
24820 static inline BinaryNode *create(JSTreeContext *tc) {
24821 return (BinaryNode *)JSParseNode::create(PN_BINARY, tc);
24825 struct TernaryNode : public JSParseNode {
24826 static inline TernaryNode *create(JSTreeContext *tc) {
24827 return (TernaryNode *)JSParseNode::create(PN_TERNARY, tc);
24831 struct ListNode : public JSParseNode {
24832 static inline ListNode *create(JSTreeContext *tc) {
24833 return (ListNode *)JSParseNode::create(PN_LIST, tc);
24837 struct FunctionNode : public JSParseNode {
24838 static inline FunctionNode *create(JSTreeContext *tc) {
24839 return (FunctionNode *)JSParseNode::create(PN_FUNC, tc);
24843 struct NameNode : public JSParseNode {
24844 static NameNode *create(JSAtom *atom, JSTreeContext *tc);
24846 void inline initCommon(JSTreeContext *tc);
24849 struct NameSetNode : public JSParseNode {
24850 static inline NameSetNode *create(JSTreeContext *tc) {
24851 return (NameSetNode *)JSParseNode::create(PN_NAMESET, tc);
24855 struct LexicalScopeNode : public JSParseNode {
24856 static inline LexicalScopeNode *create(JSTreeContext *tc) {
24857 return (LexicalScopeNode *)JSParseNode::create(PN_NAME, tc);
24863 struct JSDefinition : public JSParseNode
24866 JSDefinition *resolve() {
24867 JSParseNode *pn = this;
24868 while (!pn->pn_defn) {
24869 if (pn->pn_type == js::TOK_ASSIGN) {
24870 pn = pn->pn_u.binary.left;
24875 return (JSDefinition *) pn;
24878 bool isFreeVar() const {
24880 return pn_u.name.cookie.isFree() || test(0x40);
24883 bool isGlobal() const {
24892 enum Kind { VAR, CONST, LET, FUNCTION, ARG, UNKNOWN };
24894 bool isBindingForm() { return int(kind()) <= int(LET); }
24896 static const char *kindString(Kind kind);
24899 if (((js::TokenKind)(this)->pn_type) == js::TOK_FUNCTION)
24902 if (((JSOp)(this)->pn_op) == JSOP_NOP)
24904 if (((JSOp)(this)->pn_op) == JSOP_GETARG)
24918 JSParseNode::test(uintN flag) const
24922 return !!(pn_u.name.dflags & flag);
24926 JSParseNode::setFunArg()
24931 pn_u.name.lexdef->pn_u.name.dflags |= 0x100;
24932 pn_u.name.dflags |= 0x100;
24935 struct JSObjectBox {
24936 JSObjectBox *traceLink;
24937 JSObjectBox *emitLink;
24939 JSObjectBox *parent;
24941 bool isFunctionBox;
24946 struct JSFunctionBox : public JSObjectBox
24949 JSFunctionBox *siblings;
24950 JSFunctionBox *kids;
24951 JSFunctionBox *parent;
24952 JSParseNode *methods;
24957 js::Bindings bindings;
24963 bool joinable() const;
24969 bool inAnyDynamicScope() const;
24971 bool shouldUnbrand(uintN methods, uintN slowMethods) const;
24974 struct JSFunctionBoxQueue {
24975 JSFunctionBox **vector;
24979 size_t count() { return head - tail; }
24980 size_t length() { return lengthMask + 1; }
24982 JSFunctionBoxQueue()
24983 : vector(__null), head(0), tail(0), lengthMask(0) { }
24985 bool init(uint32 count) {
24986 lengthMask = (((JSUint32)1 << (JS_CeilingLog2(count))) - 1);
24987 vector = js_array_new<JSFunctionBox*>(length());
24991 ~JSFunctionBoxQueue() { js_array_delete(vector); }
24993 void push(JSFunctionBox *funbox) {
24994 if (!funbox->queued) {
24996 vector[head++ & lengthMask] = funbox;
24997 funbox->queued = true;
25001 JSFunctionBox *pull() {
25005 JSFunctionBox *funbox = vector[tail++ & lengthMask];
25006 funbox->queued = false;
25013 typedef struct BindData BindData;
25017 struct Parser : private js::AutoGCRooter
25019 JSContext * const context;
25020 JSAtomListElement *aleFreeList;
25021 void *tempFreeList[6U];
25022 TokenStream tokenStream;
25023 void *tempPoolMark;
25024 JSPrincipals *principals;
25025 JSStackFrame *const callerFrame;
25026 JSObject *const callerVarObj;
25027 JSParseNode *nodeList;
25028 uint32 functionCount;
25029 JSObjectBox *traceListHead;
25033 js::AutoKeepAtoms keepAtoms;
25035 Parser(JSContext *cx, JSPrincipals *prin = __null, JSStackFrame *cfp = __null);
25038 friend void js::AutoGCRooter::trace(JSTracer *trc);
25039 friend struct ::JSTreeContext;
25040 friend struct Compiler;
25048 bool init(const jschar *base, size_t length, const char *filename, uintN lineno,
25049 JSVersion version);
25051 void setPrincipals(JSPrincipals *prin);
25053 const char *getFilename() const { return tokenStream.getFilename(); }
25054 JSVersion versionWithFlags() const { return tokenStream.versionWithFlags(); }
25055 JSVersion versionNumber() const { return tokenStream.versionNumber(); }
25056 bool hasXML() const { return tokenStream.hasXML(); }
25057 bool hasAnonFunFix() const { return tokenStream.hasAnonFunFix(); }
25062 JSParseNode *parse(JSObject *chain);
25065 JSParseNode *parseXMLText(JSObject *chain, bool allowList);
25071 JSObjectBox *newObjectBox(JSObject *obj);
25073 JSFunctionBox *newFunctionBox(JSObject *obj, JSParseNode *fn, JSTreeContext *tc);
25079 JSFunction *newFunction(JSTreeContext *tc, JSAtom *atom, uintN lambda);
25086 bool analyzeFunctions(JSTreeContext *tc);
25087 void cleanFunctionList(JSFunctionBox **funbox);
25088 bool markFunArgs(JSFunctionBox *funbox);
25089 void setFunctionKinds(JSFunctionBox *funbox, uint32 *tcflags);
25091 void trace(JSTracer *trc);
25096 inline bool reportErrorNumber(JSParseNode *pn, uintN flags, uintN errorNumber, ...);
25100 JSParseNode *functionStmt();
25101 JSParseNode *functionExpr();
25102 JSParseNode *statements();
25103 JSParseNode *statement();
25104 JSParseNode *switchStatement();
25105 JSParseNode *forStatement();
25106 JSParseNode *tryStatement();
25107 JSParseNode *withStatement();
25109 JSParseNode *letStatement();
25111 JSParseNode *expressionStatement();
25112 JSParseNode *variables(bool inLetHead);
25113 JSParseNode *expr();
25114 JSParseNode *assignExpr();
25115 JSParseNode *condExpr();
25116 JSParseNode *orExpr();
25117 JSParseNode *andExpr();
25118 JSParseNode *bitOrExpr();
25119 JSParseNode *bitXorExpr();
25120 JSParseNode *bitAndExpr();
25121 JSParseNode *eqExpr();
25122 JSParseNode *relExpr();
25123 JSParseNode *shiftExpr();
25124 JSParseNode *addExpr();
25125 JSParseNode *mulExpr();
25126 JSParseNode *unaryExpr();
25127 JSParseNode *memberExpr(JSBool allowCallSyntax);
25128 JSParseNode *primaryExpr(js::TokenKind tt, JSBool afterDot);
25129 JSParseNode *parenExpr(JSBool *genexp = __null);
25134 bool recognizeDirectivePrologue(JSParseNode *pn, bool *isDirectivePrologueMember);
25136 enum FunctionType { GETTER, SETTER, GENERAL };
25137 bool functionArguments(JSTreeContext &funtc, JSFunctionBox *funbox, JSParseNode **list);
25138 JSParseNode *functionBody();
25139 JSParseNode *functionDef(JSAtom *name, FunctionType type, uintN lambda);
25141 JSParseNode *condition();
25142 JSParseNode *comprehensionTail(JSParseNode *kid, uintN blockid,
25143 js::TokenKind type = js::TOK_SEMI, JSOp op = JSOP_NOP);
25144 JSParseNode *generatorExpr(JSParseNode *kid);
25145 JSBool argumentList(JSParseNode *listNode);
25146 JSParseNode *bracketedExpr();
25147 JSParseNode *letBlock(JSBool statement);
25148 JSParseNode *returnOrYield(bool useAssignExpr);
25149 JSParseNode *destructuringExpr(BindData *data, js::TokenKind tt);
25152 JSParseNode *endBracketedExpr();
25154 JSParseNode *propertySelector();
25155 JSParseNode *qualifiedSuffix(JSParseNode *pn);
25156 JSParseNode *qualifiedIdentifier();
25157 JSParseNode *attributeIdentifier();
25158 JSParseNode *xmlExpr(JSBool inTag);
25159 JSParseNode *xmlAtomNode();
25160 JSParseNode *xmlNameExpr();
25161 JSParseNode *xmlTagContent(js::TokenKind tagtype, JSAtom **namep);
25162 JSBool xmlElementContent(JSParseNode *pn);
25163 JSParseNode *xmlElementOrList(JSBool allowList);
25164 JSParseNode *xmlElementOrListRoot(JSBool allowList);
25172 Parser::reportErrorNumber(JSParseNode *pn, uintN flags, uintN errorNumber, ...)
25175 __builtin_va_start(args,errorNumber);
25176 bool result = tokenStream.reportCompileErrorNumberVA(pn, flags, errorNumber, args);
25177 __builtin_va_end(args);
25184 GlobalScope *globalScope;
25186 Compiler(JSContext *cx, JSPrincipals *prin = __null, JSStackFrame *cfp = __null);
25197 init(const jschar *base, size_t length, const char *filename, uintN lineno, JSVersion version)
25199 return parser.init(base, length, filename, lineno, version);
25208 compileFunctionBody(JSContext *cx, JSFunction *fun, JSPrincipals *principals,
25209 js::Bindings *bindings, const jschar *chars, size_t length,
25210 const char *filename, uintN lineno, JSVersion version);
25213 compileScript(JSContext *cx, JSObject *scopeChain, JSStackFrame *callerFrame,
25214 JSPrincipals *principals, uint32 tcflags,
25215 const jschar *chars, size_t length,
25216 const char *filename, uintN lineno, JSVersion version,
25217 JSString *source = __null, uintN staticLevel = 0);
25220 static bool defineGlobals(JSContext *cx, GlobalScope &globalScope, JSScript *script);
25231 js_FoldConstants(JSContext *cx, JSParseNode *pn, JSTreeContext *tc,
25232 bool inCond = false);
25239 # 1 "jscompartment.h" 1
25240 # 50 "jscompartment.h"
25243 extern const char js_AnyName_str[];
25244 extern const char js_AttributeName_str[];
25245 extern const char js_isXMLName_str[];
25246 extern const char js_XMLList_str[];
25248 extern const char js_amp_entity_str[];
25249 extern const char js_gt_entity_str[];
25250 extern const char js_lt_entity_str[];
25251 extern const char js_quot_entity_str[];
25254 (* JSIdentityOp)(const void *a, const void *b);
25256 struct JSXMLArray {
25260 JSXMLArrayCursor *cursors;
25263 length = capacity = 0;
25268 void finish(JSContext *cx);
25270 bool setCapacity(JSContext *cx, uint32 capacity);
25274 struct JSXMLArrayCursor
25278 JSXMLArrayCursor *next;
25279 JSXMLArrayCursor **prevp;
25282 JSXMLArrayCursor(JSXMLArray *array)
25283 : array(array), index(0), next(array->cursors), prevp(&array->cursors),
25287 next->prevp = &next;
25288 array->cursors = this;
25291 ~JSXMLArrayCursor() { disconnect(); }
25293 void disconnect() {
25297 next->prevp = prevp;
25303 if (!array || index >= array->length)
25305 return root = array->vector[index++];
25308 void *getCurrent() {
25309 if (!array || index >= array->length)
25311 return root = array->vector[index];
25314 void trace(JSTracer *trc);
25317 typedef enum JSXMLClass {
25319 JSXML_CLASS_ELEMENT,
25320 JSXML_CLASS_ATTRIBUTE,
25321 JSXML_CLASS_PROCESSING_INSTRUCTION,
25323 JSXML_CLASS_COMMENT,
25327 typedef struct JSXMLListVar {
25330 JSObject *targetprop;
25333 typedef struct JSXMLElemVar {
25335 JSXMLArray namespaces;
25339 struct JSXML : js::gc::Cell {
25356 void finalize(JSContext *cx) {
25357 if ((((this)->xml_class) < JSXML_CLASS_ATTRIBUTE)) {
25358 u.list.kids.finish(cx);
25359 if (xml_class == JSXML_CLASS_ELEMENT) {
25360 u.elem.namespaces.finish(cx);
25361 u.elem.attrs.finish(cx);
25374 js_NewXML(JSContext *cx, JSXMLClass xml_class);
25377 js_TraceXML(JSTracer *trc, JSXML *xml);
25380 js_NewXMLObject(JSContext *cx, JSXMLClass xml_class);
25383 js_GetXMLObject(JSContext *cx, JSXML *xml);
25385 extern __attribute__((visibility ("default"))) js::Class js_XMLClass;
25386 extern __attribute__((visibility ("default"))) js::Class js_NamespaceClass;
25387 extern __attribute__((visibility ("default"))) js::Class js_QNameClass;
25388 extern __attribute__((visibility ("default"))) js::Class js_AttributeNameClass;
25389 extern __attribute__((visibility ("default"))) js::Class js_AnyNameClass;
25390 extern js::Class js_XMLFilterClass;
25399 JSObject::isXML() const
25401 return getClass() == &js_XMLClass;
25408 JSObject::isXMLId() const
25410 js::Class *clasp = getClass();
25411 return clasp == &js_QNameClass ||
25412 clasp == &js_AttributeNameClass ||
25413 clasp == &js_AnyNameClass;
25422 JSObject::isNamespace() const
25424 return getClass() == &js_NamespaceClass;
25431 JSObject::isQName() const
25433 js::Class* clasp = getClass();
25434 return clasp == &js_QNameClass ||
25435 clasp == &js_AttributeNameClass ||
25436 clasp == &js_AnyNameClass;
25443 IsXML(const js::Value &v)
25445 return v.isObject() && v.toObject().isXML();
25449 js_InitNamespaceClass(JSContext *cx, JSObject *obj);
25452 js_InitQNameClass(JSContext *cx, JSObject *obj);
25455 js_InitXMLClass(JSContext *cx, JSObject *obj);
25458 js_InitXMLClasses(JSContext *cx, JSObject *obj);
25461 js_GetFunctionNamespace(JSContext *cx, js::Value *vp);
25468 js_IsFunctionQName(JSContext *cx, JSObject *obj, jsid *funidp);
25471 js_GetDefaultXMLNamespace(JSContext *cx, jsval *vp);
25474 js_SetDefaultXMLNamespace(JSContext *cx, const js::Value &v);
25482 js_IsXMLName(JSContext *cx, jsval v);
25485 js_ToAttributeName(JSContext *cx, js::Value *vp);
25487 extern JSFlatString *
25488 js_EscapeAttributeValue(JSContext *cx, JSString *str, JSBool quote);
25491 js_AddAttributePart(JSContext *cx, JSBool isName, JSString *str,
25494 extern JSFlatString *
25495 js_EscapeElementValue(JSContext *cx, JSString *str);
25498 js_ValueToXMLString(JSContext *cx, const js::Value &v);
25501 js_ConstructXMLQNameObject(JSContext *cx, const js::Value & nsval,
25502 const js::Value & lnval);
25505 js_GetAnyName(JSContext *cx, jsid *idp);
25511 js_FindXMLProperty(JSContext *cx, const js::Value &nameval, JSObject **objp, jsid *idp);
25514 js_GetXMLMethod(JSContext *cx, JSObject *obj, jsid id, js::Value *vp);
25517 js_GetXMLDescendants(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
25520 js_DeleteXMLListElements(JSContext *cx, JSObject *listobj);
25523 js_StepXMLListFilter(JSContext *cx, JSBool initialized);
25526 js_ValueToXMLObject(JSContext *cx, const js::Value &v);
25529 js_ValueToXMLListObject(JSContext *cx, const js::Value &v);
25532 js_NewXMLSpecialObject(JSContext *cx, JSXMLClass xml_class, JSString *name,
25536 js_MakeXMLCDATAString(JSContext *cx, JSString *str);
25539 js_MakeXMLCommentString(JSContext *cx, JSString *str);
25542 js_MakeXMLPIString(JSContext *cx, JSString *name, JSString *str);
25546 js_TestXMLEquality(JSContext *cx, const js::Value &v1, const js::Value &v2,
25550 js_ConcatenateXML(JSContext *cx, JSObject *obj1, JSObject *obj2, js::Value *vp);
25551 # 51 "jscompartment.h" 2
25560 class ExecutableAllocator;
25567 typedef HashMap<jsbytecode*,
25569 DefaultHasher<jsbytecode*>,
25570 SystemAllocPolicy> RecordAttemptMap;
25573 typedef HashMap<jsbytecode*,
25575 DefaultHasher<jsbytecode*>,
25576 SystemAllocPolicy> LoopProfileMap;
25580 typedef HashSet<JSScript *,
25581 DefaultHasher<JSScript *>,
25582 SystemAllocPolicy> TracedScriptSet;
25584 typedef HashMap<JSFunction *,
25586 DefaultHasher<JSFunction *>,
25587 SystemAllocPolicy> ToSourceCache;
25589 struct TraceMonitor;
25595 TraceMonitor* traceMonitor;
25599 FrameInfo** callstackBase;
25603 VMSideExit* lastTreeExitGuard;
25604 VMSideExit* lastTreeCallGuard;
25606 void* rpAtLastTreeCall;
25607 VMSideExit* outermostTreeExitGuard;
25608 TreeFragment* outermostTree;
25609 uintN* inlineCallCountp;
25610 VMSideExit** innermostNestedGuardp;
25611 VMSideExit* innermost;
25618 uint32 builtinStatus;
25621 double* deepBailSp;
25625 js::Value* nativeVp;
25627 TracerState(JSContext *cx, TraceMonitor *tm, TreeFragment *ti,
25628 uintN &inlineCallCountp, VMSideExit** innermostNestedGuardp);
25638 struct TraceNativeStorage
25640 double stack_global_buf[MAX_NATIVE_STACK_SLOTS + GLOBAL_SLOTS_BUFFER_SIZE];
25641 FrameInfo *callstack_buf[MAX_CALL_STACK_ENTRIES];
25643 double *stack() { return stack_global_buf; }
25644 double *global() { return stack_global_buf + MAX_NATIVE_STACK_SLOTS; }
25645 FrameInfo **callstack() { return callstack_buf; }
25649 struct GlobalState {
25650 JSObject* globalObj;
25651 uint32 globalShape;
25652 SlotList* globalSlots;
25660 struct TraceMonitor {
25661 # 170 "jscompartment.h"
25662 JSContext *tracecx;
25669 js::TracerState *tracerState;
25670 js::VMSideExit *bailExit;
25673 unsigned iterationCounter;
25680 TraceNativeStorage *storage;
25681 # 214 "jscompartment.h"
25682 VMAllocator* dataAlloc;
25683 VMAllocator* traceAlloc;
25684 VMAllocator* tempAlloc;
25685 nanojit::CodeAlloc* codeAlloc;
25686 nanojit::Assembler* assembler;
25687 FrameInfoCache* frameCache;
25693 TraceRecorder* recorder;
25696 LoopProfile* profile;
25698 GlobalState globalStates[MONITOR_N_GLOBAL_STATES];
25699 TreeFragment *vmfragments[FRAGMENT_TABLE_SIZE];
25700 RecordAttemptMap* recordAttempts;
25703 LoopProfileMap* loopProfiles;
25709 uint32 maxCodeCacheBytes;
25721 TypeMap* cachedTempTypeMap;
25724 TracedScriptSet tracedScripts;
25725 # 270 "jscompartment.h"
25726 bool ontrace() const {
25734 void sweep(JSContext *cx);
25737 void mark(JSTracer *trc);
25739 bool outOfMemory() const;
25743 class JaegerCompartment;
25746 # 308 "jscompartment.h"
25749 class NativeIterCache {
25750 static const size_t SIZE = size_t(1) << 8;
25753 JSObject *data[SIZE];
25755 static size_t getIndex(uint32 key) {
25756 return size_t(key) % SIZE;
25765 PodArrayZero(data);
25769 PodArrayZero(data);
25773 JSObject *get(uint32 key) const {
25774 return data[getIndex(key)];
25777 void set(uint32 key, JSObject *iterobj) {
25778 data[getIndex(key)] = iterobj;
25781 # 350 "jscompartment.h"
25787 DtoaCache() : s(__null) {}
25788 void purge() { s = __null; }
25790 JSString *lookup(jsint base, double d) {
25791 return this->s && base == this->base && d == this->d ? this->s : __null;
25794 void cache(jsint base, double d, JSString *s) {
25804 struct __attribute__((visibility ("default"))) JSCompartment {
25806 JSPrincipals *principals;
25807 js::gc::Chunk *chunk;
25809 js::gc::ArenaList arenas[js::gc::FINALIZE_LIMIT];
25810 js::gc::FreeLists freeLists;
25813 size_t gcTriggerBytes;
25814 size_t gcLastBytes;
25815 # 394 "jscompartment.h"
25816 JSScript *scriptsToGC[((JSUint32)1 << (6))];
25824 js::WrapperMap crossCompartmentWrappers;
25825 # 411 "jscompartment.h"
25826 js::PropertyTree propertyTree;
25827 # 425 "jscompartment.h"
25828 js::EmptyShape *emptyArgumentsShape;
25829 js::EmptyShape *emptyBlockShape;
25830 js::EmptyShape *emptyCallShape;
25831 js::EmptyShape *emptyDeclEnvShape;
25832 js::EmptyShape *emptyEnumeratorShape;
25833 js::EmptyShape *emptyWithShape;
25835 typedef js::HashSet<js::EmptyShape *,
25836 js::DefaultHasher<js::EmptyShape *>,
25837 js::SystemAllocPolicy> EmptyShapeSet;
25839 EmptyShapeSet emptyShapes;
25844 JSC::ExecutableAllocator *regExpAllocator;
25846 js::NativeIterCache nativeIterCache;
25848 js::ToSourceCache toSourceCache;
25850 JSCompartment(JSRuntime *rt);
25856 void markCrossCompartment(JSTracer *trc);
25859 void mark(JSTracer *trc);
25861 bool wrap(JSContext *cx, js::Value *vp);
25862 bool wrap(JSContext *cx, JSString **strp);
25863 bool wrap(JSContext *cx, JSObject **objp);
25864 bool wrapId(JSContext *cx, jsid *idp);
25865 bool wrap(JSContext *cx, js::PropertyOp *op);
25866 bool wrap(JSContext *cx, js::StrictPropertyOp *op);
25867 bool wrap(JSContext *cx, js::PropertyDescriptor *desc);
25868 bool wrap(JSContext *cx, js::AutoIdVector &props);
25870 void sweep(JSContext *cx, uint32 releaseInterval);
25871 void purge(JSContext *cx);
25872 void finishArenaLists();
25873 void finalizeObjectArenaLists(JSContext *cx);
25874 void finalizeStringArenaLists(JSContext *cx);
25875 bool arenaListsAreEmpty();
25877 void setGCLastBytes(size_t lastBytes);
25879 js::DtoaCache dtoaCache;
25882 js::MathCache *mathCache;
25884 js::MathCache *allocMathCache(JSContext *cx);
25888 typedef js::HashMap<jsbytecode*,
25890 js::DefaultHasher<jsbytecode*>,
25891 js::SystemAllocPolicy> BackEdgeMap;
25893 BackEdgeMap backEdgeTable;
25895 JSCompartment *thisForCtor() { return this; }
25897 js::MathCache *getMathCache(JSContext *cx) {
25898 return mathCache ? mathCache : allocMathCache(cx);
25901 bool isMarked() { return marked; }
25902 void clearMark() { marked = false; }
25904 size_t backEdgeCount(jsbytecode *pc) const;
25905 size_t incBackEdgeCount(jsbytecode *pc);
25907 # 519 "jscompartment.h"
25910 # 519 "jscompartment.h"
25912 JS_ON_TRACE(JSContext *cx)
25920 # 549 "jscompartment.h"
25921 static inline js::TraceRecorder *
25922 TRACE_RECORDER(JSContext *cx)
25931 static inline js::LoopProfile *
25932 TRACE_PROFILER(JSContext *cx)
25942 static inline MathCache *
25943 GetMathCache(JSContext *cx)
25945 return cx->compartment->getMathCache(cx);
25948 # 587 "jscompartment.h"
25951 class PreserveCompartment {
25955 JSCompartment *oldCompartment;
25958 PreserveCompartment(JSContext *cx ) : cx(cx) {
25960 oldCompartment = cx->compartment;
25963 ~PreserveCompartment() {
25964 cx->compartment = oldCompartment;
25968 class SwitchToCompartment : public PreserveCompartment {
25970 SwitchToCompartment(JSContext *cx, JSCompartment *newCompartment) : PreserveCompartment(cx) {
25971 cx->compartment = newCompartment;
25974 SwitchToCompartment(JSContext *cx, JSObject *target) : PreserveCompartment(cx) {
25975 cx->compartment = target->getCompartment();
25979 class AssertCompartmentUnchanged {
25981 JSContext * const cx;
25982 JSCompartment * const oldCompartment;
25985 AssertCompartmentUnchanged(JSContext *cx )
25986 : cx(cx), oldCompartment(cx->compartment) {
25990 ~AssertCompartmentUnchanged() {
26002 # 1 "jsstrinlines.h" 1
26003 # 44 "jsstrinlines.h"
26004 # 1 "jscntxtinlines.h" 1
26005 # 49 "jscntxtinlines.h"
26008 # 1 "/usr/lib/gcc/powerpc64-unknown-linux-gnu/4.9.3/include/stddef.h" 1 3 4
26009 # 46 "jsregexp.h" 2
26011 extern js::Class js_RegExpClass;
26015 class RegExpStatics
26017 typedef Vector<int, 20, SystemAllocPolicy> MatchPairs;
26018 MatchPairs matchPairs;
26020 JSLinearString *matchPairsInput;
26022 JSString *pendingInput;
26024 RegExpStatics *bufferLink;
26027 bool createDependent(JSContext *cx, size_t start, size_t end, Value *out) const;
26029 void copyTo(RegExpStatics &dst) {
26030 dst.matchPairs.clear();
26032 ((void) (dst.matchPairs.append(matchPairs)));
26033 dst.matchPairsInput = matchPairsInput;
26034 dst.pendingInput = pendingInput;
26038 void aboutToWrite() {
26039 if (bufferLink && !bufferLink->copied) {
26040 copyTo(*bufferLink);
26041 bufferLink->copied = true;
26045 bool save(JSContext *cx, RegExpStatics *buffer) {
26047 buffer->bufferLink = bufferLink;
26048 bufferLink = buffer;
26049 if (!buffer->matchPairs.reserve(matchPairs.length())) {
26050 js_ReportOutOfMemory(cx);
26057 if (bufferLink->copied)
26058 bufferLink->copyTo(*this);
26059 bufferLink = bufferLink->bufferLink;
26062 void checkInvariants() {
26070 void checkParenNum(size_t pairNum) const {
26075 bool pairIsPresent(size_t pairNum) const {
26076 return get(pairNum, 0) >= 0;
26080 size_t getParenLength(size_t pairNum) const {
26081 checkParenNum(pairNum);
26083 return get(pairNum, 1) - get(pairNum, 0);
26086 int get(size_t pairNum, bool which) const {
26088 return matchPairs[2 * pairNum + which];
26096 bool makeMatch(JSContext *cx, size_t checkValidIndex, size_t pairNum, Value *out) const;
26098 static const uintN allFlags = 0x01 | 0x02 | 0x08 | 0x04;
26100 struct InitBuffer {};
26101 explicit RegExpStatics(InitBuffer) : bufferLink(__null), copied(false) {}
26103 friend class PreserveRegExpStatics;
26106 RegExpStatics() : bufferLink(__null), copied(false) { clear(); }
26108 static RegExpStatics *extractFrom(JSObject *global);
26112 bool updateFromMatch(JSContext *cx, JSLinearString *input, int *buf, size_t matchItemCount) {
26114 pendingInput = input;
26116 if (!matchPairs.resizeUninitialized(matchItemCount)) {
26117 js_ReportOutOfMemory(cx);
26121 for (size_t i = 0; i < matchItemCount; ++i)
26122 matchPairs[i] = buf[i];
26124 matchPairsInput = input;
26128 void setMultiline(bool enabled) {
26131 flags = flags | 0x04;
26133 flags = flags & ~0x04;
26139 pendingInput = __null;
26140 matchPairsInput = __null;
26141 matchPairs.clear();
26145 void reset(JSString *newInput, bool newMultiline) {
26148 pendingInput = newInput;
26149 setMultiline(newMultiline);
26153 void setPendingInput(JSString *newInput) {
26155 pendingInput = newInput;
26159 size_t pairCount() const {
26161 return matchPairs.length() / 2;
26165 size_t parenCount() const {
26166 size_t pc = pairCount();
26171 JSString *getPendingInput() const { return pendingInput; }
26172 uintN getFlags() const { return flags; }
26173 bool multiline() const { return flags & 0x04; }
26175 size_t matchStart() const {
26176 int start = get(0, 0);
26178 return size_t(start);
26181 size_t matchLimit() const {
26182 int limit = get(0, 1);
26184 return size_t(limit);
26188 bool matched() const {
26191 return get(0, 1) - get(0, 0) > 0;
26194 void mark(JSTracer *trc) const {
26196 do { JSString *str_ = (pendingInput); ((void) 0); do { do { } while (0); JS_CallTracer(((trc)), (str_), (1)); } while (0); } while (0);
26197 if (matchPairsInput)
26198 do { JSString *str_ = (matchPairsInput); ((void) 0); do { do { } while (0); JS_CallTracer(((trc)), (str_), (1)); } while (0); } while (0);
26203 bool createPendingInput(JSContext *cx, Value *out) const;
26204 bool createLastMatch(JSContext *cx, Value *out) const { return makeMatch(cx, 0, 0, out); }
26205 bool createLastParen(JSContext *cx, Value *out) const;
26206 bool createLeftContext(JSContext *cx, Value *out) const;
26207 bool createRightContext(JSContext *cx, Value *out) const;
26210 bool createParen(JSContext *cx, size_t pairNum, Value *out) const {
26212 if (pairNum >= pairCount()) {
26213 out->setString(cx->runtime->emptyString);
26216 return makeMatch(cx, pairNum * 2, pairNum, out);
26221 void getParen(size_t pairNum, JSSubString *out) const;
26222 void getLastMatch(JSSubString *out) const;
26223 void getLastParen(JSSubString *out) const;
26224 void getLeftContext(JSSubString *out) const;
26225 void getRightContext(JSSubString *out) const;
26228 class PreserveRegExpStatics
26230 RegExpStatics *const original;
26231 RegExpStatics buffer;
26234 explicit PreserveRegExpStatics(RegExpStatics *original)
26235 : original(original),
26236 buffer(RegExpStatics::InitBuffer())
26239 bool init(JSContext *cx) {
26240 return original->save(cx, &buffer);
26243 ~PreserveRegExpStatics() {
26244 original->restore();
26254 VALUE_IS_REGEXP(JSContext *cx, js::Value v)
26256 return !v.isPrimitive() && v.toObject().isRegExp();
26259 inline const js::Value &
26260 JSObject::getRegExpLastIndex() const
26263 return getSlot(JSSLOT_REGEXP_LAST_INDEX);
26267 JSObject::setRegExpLastIndex(const js::Value &v)
26270 setSlot(JSSLOT_REGEXP_LAST_INDEX, v);
26274 JSObject::setRegExpLastIndex(jsdouble d)
26277 setSlot(JSSLOT_REGEXP_LAST_INDEX, js::NumberValue(d));
26281 JSObject::zeroRegExpLastIndex()
26284 getSlotRef(JSSLOT_REGEXP_LAST_INDEX).setInt32(0);
26287 namespace js { class AutoStringRooter; }
26293 JSObject::isRegExp() const
26295 return getClass() == &js_RegExpClass;
26298 extern __attribute__((visibility ("default"))) JSBool
26299 js_ObjectIsRegExp(JSObject *obj);
26302 js_InitRegExpClass(JSContext *cx, JSObject *obj);
26308 js_regexp_toString(JSContext *cx, JSObject *obj, js::Value *vp);
26310 extern __attribute__((visibility ("default"))) JSObject *
26311 js_CloneRegExpObject(JSContext *cx, JSObject *obj, JSObject *proto);
26317 extern __attribute__((visibility ("default"))) void
26318 js_SaveAndClearRegExpStatics(JSContext *cx, js::RegExpStatics *res, js::AutoStringRooter *tvr);
26321 extern __attribute__((visibility ("default"))) void
26322 js_RestoreRegExpStatics(JSContext *cx, js::RegExpStatics *res);
26325 js_XDRRegExpObject(JSXDRState *xdr, JSObject **objp);
26328 js_regexp_exec(JSContext *cx, uintN argc, js::Value *vp);
26330 js_regexp_test(JSContext *cx, uintN argc, js::Value *vp);
26331 # 50 "jscntxtinlines.h" 2
26336 static inline JSObject *
26337 GetGlobalForScopeChain(JSContext *cx)
26339 # 65 "jscntxtinlines.h"
26343 return cx->fp()->scopeChain().getGlobal();
26345 JSObject *scope = cx->globalObject;
26347 JS_ReportErrorNumber(cx, js_GetErrorMessage, __null, JSMSG_INACTIVE);
26350 OBJ_TO_INNER_OBJECT(cx, scope);
26355 # 88 "jscntxtinlines.h"
26358 # 88 "jscntxtinlines.h"
26360 JSContext::ensureGeneratorStackSpace()
26362 bool ok = genStack.reserve(genStack.length() + 1);
26364 js_ReportOutOfMemory(this);
26369 JSContext::computeNextFrame(JSStackFrame *fp)
26371 JSStackFrame *next = __null;
26372 for (js::StackSegment *ss = currentSegment; ; ss = ss->getPreviousInContext()) {
26373 JSStackFrame *end = ss->getInitialFrame()->prev();
26374 for (JSStackFrame *f = ss->getCurrentFrame(); f != end; next = f, f = f->prev()) {
26378 if (end != ss->getPreviousInContext()->getCurrentFrame())
26383 inline js::RegExpStatics *
26384 JSContext::regExpStatics()
26386 return js::RegExpStatics::extractFrom(js::GetGlobalForScopeChain(this));
26391 __attribute__((always_inline)) inline JSFrameRegs *
26392 StackSegment::getCurrentRegs() const
26395 return isActive() ? cx->regs : getSuspendedRegs();
26398 __attribute__((always_inline)) inline JSStackFrame *
26399 StackSegment::getCurrentFrame() const
26401 return getCurrentRegs()->fp;
26405 StackSpace::firstUnused() const
26407 StackSegment *seg = currentSegment;
26412 if (seg->inContext()) {
26413 Value *sp = seg->getCurrentRegs()->sp;
26414 if (invokeArgEnd > sp) {
26418 return invokeArgEnd;
26424 return invokeArgEnd;
26429 __attribute__((always_inline)) inline
26431 # 158 "jscntxtinlines.h"
26433 StackSpace::isCurrentAndActive(JSContext *cx) const
26440 return currentSegment &&
26441 currentSegment->isActive() &&
26442 currentSegment == cx->getCurrentSegment();
26446 __attribute__((always_inline)) inline
26448 # 172 "jscntxtinlines.h"
26450 StackSpace::ensureSpace(JSContext *maybecx, Value *from, ptrdiff_t nvals) const
26453 # 192 "jscntxtinlines.h"
26454 if (end - from < nvals) {
26456 js_ReportOutOfScriptQuota(maybecx);
26468 __attribute__((always_inline)) inline
26470 # 206 "jscntxtinlines.h"
26472 StackSpace::ensureEnoughSpaceToEnterTrace()
26477 return end - firstUnused() > MAX_TRACE_SPACE_VALS;
26480 __attribute__((always_inline)) inline
26482 # 215 "jscntxtinlines.h"
26484 StackSpace::EnsureSpaceCheck::operator()(const StackSpace &stack, JSContext *cx,
26485 Value *from, uintN nvals)
26487 return stack.ensureSpace(cx, from, nvals);
26490 __attribute__((always_inline)) inline
26492 # 222 "jscntxtinlines.h"
26494 StackSpace::LimitCheck::operator()(const StackSpace &stack, JSContext *cx,
26495 Value *from, uintN nvals)
26499 if (*limit - from >= ptrdiff_t(nvals))
26501 if (stack.bumpCommitAndLimit(base, from, nvals, limit))
26503 js_ReportOverRecursed(cx);
26507 __attribute__((always_inline)) inline
26509 # 236 "jscntxtinlines.h"
26511 StackSpace::pushInvokeArgs(JSContext *cx, uintN argc, InvokeArgsGuard *ag)
26513 if ((__builtin_expect((!isCurrentAndActive(cx)), 0)))
26514 return pushSegmentForInvoke(cx, argc, ag);
26516 Value *sp = cx->regs->sp;
26517 Value *start = invokeArgEnd > sp ? invokeArgEnd : sp;
26519 uintN nvals = 2 + argc;
26520 if (!ensureSpace(cx, start, nvals))
26524 Value *vpend = vp + nvals;
26528 ag->prevInvokeArgEnd = invokeArgEnd;
26529 invokeArgEnd = vpend;
26538 ag->argv_ = vp + 2;
26543 __attribute__((always_inline)) inline void
26544 StackSpace::popInvokeArgs(const InvokeArgsGuard &ag)
26546 if ((__builtin_expect((ag.seg != __null), 0))) {
26547 popSegmentForInvoke(ag);
26560 invokeArgEnd = ag.prevInvokeArgEnd;
26563 __attribute__((always_inline)) inline
26564 InvokeArgsGuard::~InvokeArgsGuard()
26566 if ((__builtin_expect((!pushed()), 0)))
26568 cx->stack().popInvokeArgs(*this);
26571 template <class Check>
26572 __attribute__((always_inline)) inline JSStackFrame *
26573 StackSpace::getCallFrame(JSContext *cx, Value *firstUnused, uintN nactual,
26574 JSFunction *fun, JSScript *script, uint32 *flags,
26580 uintN nvals = VALUES_PER_STACK_FRAME + script->nslots;
26581 uintN nformal = fun->nargs;
26585 if (nactual == nformal) {
26586 if ((__builtin_expect((!check(*this, cx, firstUnused, nvals)), 0)))
26588 return reinterpret_cast<JSStackFrame *>(firstUnused);
26591 if (nactual < nformal) {
26592 *flags |= JSFRAME_UNDERFLOW_ARGS;
26593 uintN nmissing = nformal - nactual;
26594 if ((__builtin_expect((!check(*this, cx, firstUnused, nmissing + nvals)), 0)))
26596 SetValueRangeToUndefined(firstUnused, nmissing);
26597 return reinterpret_cast<JSStackFrame *>(firstUnused + nmissing);
26600 *flags |= JSFRAME_OVERFLOW_ARGS;
26601 uintN ncopy = 2 + nformal;
26602 if ((__builtin_expect((!check(*this, cx, firstUnused, ncopy + nvals)), 0)))
26605 Value *dst = firstUnused;
26606 Value *src = firstUnused - (2 + nactual);
26607 PodCopy(dst, src, ncopy);
26608 Debug_SetValueRangeToCrashOnTouch(src, ncopy);
26609 return reinterpret_cast<JSStackFrame *>(firstUnused + ncopy);
26612 __attribute__((always_inline)) inline
26614 # 338 "jscntxtinlines.h"
26616 StackSpace::getInvokeFrame(JSContext *cx, const CallArgs &args,
26617 JSFunction *fun, JSScript *script,
26618 uint32 *flags, InvokeFrameGuard *fg) const
26622 Value *firstUnused = args.argv() + args.argc();
26623 fg->regs_.fp = getCallFrame(cx, firstUnused, args.argc(), fun, script, flags,
26624 EnsureSpaceCheck());
26625 fg->regs_.sp = fg->regs_.fp->slots() + script->nfixed;
26626 fg->regs_.pc = script->code;
26628 return fg->regs_.fp != __null;
26631 __attribute__((always_inline)) inline void
26632 StackSpace::pushInvokeFrame(JSContext *cx, const CallArgs &args,
26633 InvokeFrameGuard *fg)
26637 if ((__builtin_expect((!currentSegment->inContext()), 0))) {
26638 cx->pushSegmentAndFrame(currentSegment, fg->regs_);
26640 fg->prevRegs_ = cx->regs;
26641 cx->setCurrentRegs(&fg->regs_);
26648 __attribute__((always_inline)) inline void
26649 StackSpace::popInvokeFrame(const InvokeFrameGuard &fg)
26651 JSContext *cx = fg.cx_;
26652 JSStackFrame *fp = fg.regs_.fp;
26655 if ((__builtin_expect((currentSegment->getInitialFrame() == fp), 0))) {
26656 cx->popSegmentAndFrame();
26661 cx->setCurrentRegs(fg.prevRegs_);
26665 __attribute__((always_inline)) inline void
26666 InvokeFrameGuard::pop()
26669 cx_->stack().popInvokeFrame(*this);
26673 __attribute__((always_inline)) inline JSStackFrame *
26674 StackSpace::getInlineFrame(JSContext *cx, Value *sp, uintN nactual,
26675 JSFunction *fun, JSScript *script, uint32 *flags) const
26681 return getCallFrame(cx, sp, nactual, fun, script, flags, EnsureSpaceCheck());
26684 __attribute__((always_inline)) inline JSStackFrame *
26685 StackSpace::getInlineFrameWithinLimit(JSContext *cx, Value *sp, uintN nactual,
26686 JSFunction *fun, JSScript *script, uint32 *flags,
26687 JSStackFrame *base, Value **limit) const
26693 return getCallFrame(cx, sp, nactual, fun, script, flags, LimitCheck(base, limit));
26696 __attribute__((always_inline)) inline void
26697 StackSpace::pushInlineFrame(JSContext *cx, JSScript *script, JSStackFrame *fp,
26704 regs->pc = script->code;
26705 regs->sp = fp->slots() + script->nfixed;
26708 __attribute__((always_inline)) inline void
26709 StackSpace::popInlineFrame(JSContext *cx, JSStackFrame *prev, Value *newsp)
26717 JSFrameRegs *regs = cx->regs;
26718 regs->pc = prev->pc(cx, regs->fp);
26723 __attribute__((always_inline)) inline Value *
26724 StackSpace::getStackLimit(JSContext *cx)
26726 Value *sp = cx->regs->sp;
26728 Value *limit = sp + STACK_QUOTA;
26729 # 466 "jscntxtinlines.h"
26730 if ((__builtin_expect((limit <= end), 1)))
26732 uintN minimum = cx->fp()->numSlots() + VALUES_PER_STACK_FRAME;
26733 return ensureSpace(cx, sp, minimum) ? sp + minimum : __null;
26738 FrameRegsIter::FrameRegsIter(JSContext *cx)
26741 curseg = cx->getCurrentSegment();
26742 if ((__builtin_expect((!curseg || !curseg->isActive()), 0))) {
26747 curfp = cx->regs->fp;
26748 cursp = cx->regs->sp;
26749 curpc = cx->regs->pc;
26753 inline FrameRegsIter &
26754 FrameRegsIter::operator++()
26756 JSStackFrame *fp = curfp;
26757 JSStackFrame *prev = curfp = curfp->prev();
26761 curpc = curfp->pc(cx, fp);
26763 if ((__builtin_expect((fp == curseg->getInitialFrame()), 0))) {
26768 cursp = fp->formalArgsEnd();
26772 class AutoNamespaceArray : protected AutoGCRooter {
26774 AutoNamespaceArray(JSContext *cx) : AutoGCRooter(cx, NAMESPACES) {
26778 ~AutoNamespaceArray() {
26779 array.finish(context);
26782 uint32 length() const { return array.length; }
26785 friend void AutoGCRooter::trace(JSTracer *trc);
26789 # 636 "jscntxtinlines.h"
26790 template <class T1> inline void
26791 assertSameCompartment(JSContext *cx, T1 t1)
26799 template <class T1, class T2> inline void
26800 assertSameCompartment(JSContext *cx, T1 t1, T2 t2)
26809 template <class T1, class T2, class T3> inline void
26810 assertSameCompartment(JSContext *cx, T1 t1, T2 t2, T3 t3)
26820 template <class T1, class T2, class T3, class T4> inline void
26821 assertSameCompartment(JSContext *cx, T1 t1, T2 t2, T3 t3, T4 t4)
26832 template <class T1, class T2, class T3, class T4, class T5> inline void
26833 assertSameCompartment(JSContext *cx, T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
26835 # 689 "jscntxtinlines.h"
26841 __attribute__((always_inline)) inline
26843 # 694 "jscntxtinlines.h"
26845 CallJSNative(JSContext *cx, js::Native native, uintN argc, js::Value *vp)
26850 assertSameCompartment(cx, ValueArray(vp, argc + 2));
26851 JSBool ok = native(cx, argc, vp);
26853 assertSameCompartment(cx, vp[0]);
26859 extern JSBool CallOrConstructBoundFunction(JSContext *, uintN, js::Value *);
26862 __attribute__((always_inline)) inline
26864 # 712 "jscntxtinlines.h"
26866 CallJSNativeConstructor(JSContext *cx, js::Native native, uintN argc, js::Value *vp)
26873 if (!CallJSNative(cx, native, argc, vp))
26875 # 738 "jscntxtinlines.h"
26876 extern JSBool proxy_Construct(JSContext *, uintN, Value *);
26884 __attribute__((always_inline)) inline
26886 # 746 "jscntxtinlines.h"
26888 CallJSPropertyOp(JSContext *cx, js::PropertyOp op, JSObject *obj, jsid id, js::Value *vp)
26890 assertSameCompartment(cx, obj, id, *vp);
26891 JSBool ok = op(cx, obj, id, vp);
26893 assertSameCompartment(cx, obj, *vp);
26897 __attribute__((always_inline)) inline
26899 # 756 "jscntxtinlines.h"
26901 CallJSPropertyOpSetter(JSContext *cx, js::StrictPropertyOp op, JSObject *obj, jsid id,
26902 JSBool strict, js::Value *vp)
26904 assertSameCompartment(cx, obj, id, *vp);
26905 return op(cx, obj, id, strict, vp);
26910 # 764 "jscntxtinlines.h"
26912 CallSetter(JSContext *cx, JSObject *obj, jsid id, js::StrictPropertyOp op, uintN attrs,
26913 uintN shortid, JSBool strict, js::Value *vp)
26916 return ExternalGetOrSet(cx, obj, id, CastAsObjectJsval(op), JSACC_WRITE, 1, vp, vp);
26919 return js_ReportGetterOnlyAssignment(cx);
26922 id = INT_TO_JSID(shortid);
26923 return CallJSPropertyOpSetter(cx, op, obj, id, strict, vp);
26925 # 791 "jscntxtinlines.h"
26927 LeaveTraceIfGlobalObject(JSContext *cx, JSObject *obj)
26934 LeaveTraceIfArgumentsObject(JSContext *cx, JSObject *obj)
26936 if (obj->isArguments())
26940 static inline JSBool
26941 CanLeaveTrace(JSContext *cx)
26954 JSContext::setPendingException(js::Value v) {
26955 this->throwing = true;
26956 this->exception = v;
26957 assertSameCompartment(this, v);
26959 # 45 "jsstrinlines.h" 2
26965 # 48 "jsstrinlines.h"
26967 CheckStringLength(JSContext *cx, size_t length)
26969 if ((__builtin_expect((length > JSString::MAX_LENGTH), 0))) {
26970 js_ReportAllocationOverflow(cx);
26976 # 67 "jsstrinlines.h"
26979 typedef Vector<jschar, 32> CharBuffer;
26982 static inline bool checkLength(JSContext *cx, size_t length);
26983 inline bool checkLength(size_t length);
26984 JSContext *context() const { return cb.allocPolicy().context(); }
26987 explicit inline StringBuffer(JSContext *cx);
26988 bool reserve(size_t len);
26989 bool resize(size_t len);
26990 bool append(const jschar c);
26991 bool append(const jschar *chars, size_t len);
26992 bool append(const jschar *begin, const jschar *end);
26993 bool append(JSString *str);
26994 bool append(JSAtom *atom);
26995 bool appendN(const jschar c, size_t n);
26996 bool appendInflated(const char *cstr, size_t len);
26997 JSAtom *atomize(uintN flags = 0);
26998 static JSAtom *atomize(JSContext *cx, const CharBuffer &cb, uintN flags = 0);
26999 static JSAtom *atomize(JSContext *cx, const jschar *begin, size_t length, uintN flags = 0);
27001 void replaceRawBuffer(jschar *chars, size_t len) { cb.replaceRawBuffer(chars, len); }
27002 jschar *begin() { return cb.begin(); }
27003 jschar *end() { return cb.end(); }
27004 const jschar *begin() const { return cb.begin(); }
27005 const jschar *end() const { return cb.end(); }
27006 bool empty() const { return cb.empty(); }
27007 inline jsint length() const;
27014 JSFlatString *finishString();
27016 template <size_t ArrayLength>
27017 bool append(const char (&array)[ArrayLength]) {
27018 return cb.append(array, array + ArrayLength - 1);
27023 StringBuffer::StringBuffer(JSContext *cx)
27029 # 117 "jsstrinlines.h"
27031 StringBuffer::reserve(size_t len)
27033 if (!checkLength(len))
27035 return cb.reserve(len);
27040 # 125 "jsstrinlines.h"
27042 StringBuffer::resize(size_t len)
27044 if (!checkLength(len))
27046 return cb.resize(len);
27051 # 133 "jsstrinlines.h"
27053 StringBuffer::append(const jschar c)
27055 if (!checkLength(cb.length() + 1))
27057 return cb.append(c);
27062 # 141 "jsstrinlines.h"
27064 StringBuffer::append(const jschar *chars, size_t len)
27066 if (!checkLength(cb.length() + len))
27068 return cb.append(chars, len);
27073 # 149 "jsstrinlines.h"
27075 StringBuffer::append(const jschar *begin, const jschar *end)
27077 if (!checkLength(cb.length() + (end - begin)))
27079 return cb.append(begin, end);
27084 # 157 "jsstrinlines.h"
27086 StringBuffer::append(JSString *str)
27088 JSLinearString *linear = str->ensureLinear(context());
27089 size_t strLen = linear->length();
27090 if (!checkLength(cb.length() + strLen))
27092 return cb.append(linear->chars(), strLen);
27097 # 167 "jsstrinlines.h"
27099 StringBuffer::append(JSAtom *atom)
27101 size_t strLen = atom->length();
27102 if (!checkLength(cb.length() + strLen))
27104 return cb.append(atom->chars(), strLen);
27109 # 176 "jsstrinlines.h"
27111 StringBuffer::appendN(const jschar c, size_t n)
27113 if (!checkLength(cb.length() + n))
27115 return cb.appendN(c, n);
27120 # 184 "jsstrinlines.h"
27122 StringBuffer::appendInflated(const char *cstr, size_t cstrlen)
27124 size_t lengthBefore = length();
27125 if (!cb.growByUninitialized(cstrlen))
27131 js_InflateStringToBuffer(context(), cstr, cstrlen, begin() + lengthBefore, &cstrlen);
27137 StringBuffer::length() const
27139 typedef int js_static_assert65[(jsint(JSString::MAX_LENGTH) == JSString::MAX_LENGTH) ? 1 : -1];
27141 return jsint(cb.length());
27146 # 207 "jsstrinlines.h"
27148 StringBuffer::checkLength(size_t length)
27150 return CheckStringLength(context(), length);
27155 inline JSFlatString *
27156 JSString::unitString(jschar c)
27160 return const_cast<JSString *>(&unitStringTable[c])->assertIsFlat();
27167 inline JSLinearString *
27168 JSString::getUnitString(JSContext *cx, JSString *str, size_t index)
27172 const jschar *chars = str->getChars(cx);
27175 jschar c = chars[index];
27176 if (c < UNIT_STRING_LIMIT)
27177 return unitString(c);
27179 return js_NewDependentString(cx, str, index, 1);
27182 inline JSFlatString *
27183 JSString::length2String(jschar c1, jschar c2)
27188 return const_cast<JSString *> (
27189 &length2StringTable[(((size_t)toSmallChar[c1]) << 6) + toSmallChar[c2]]
27197 inline JSFlatString *
27198 JSString::length2String(uint32 i)
27202 return length2String('0' + i / 10, '0' + i % 10);
27209 inline JSFlatString *
27210 JSString::intString(jsint i)
27213 jsuint u = jsuint(i);
27215 return const_cast<JSString *>(JSString::intStringTable[u])->assertIsFlat();
27223 inline JSFlatString *
27224 JSString::lookupStaticString(const jschar *chars, size_t length)
27228 if (chars[0] < UNIT_STRING_LIMIT)
27229 return unitString(chars[0]);
27233 if (fitsInSmallChar(chars[0]) && fitsInSmallChar(chars[1]))
27234 return length2String(chars[0], chars[1]);
27243 typedef int js_static_assert66[(INT_STRING_LIMIT <= 999) ? 1 : -1];
27245 if ('1' <= chars[0] && chars[0] <= '9' &&
27246 '0' <= chars[1] && chars[1] <= '9' &&
27247 '0' <= chars[2] && chars[2] <= '9') {
27248 jsint i = (chars[0] - '0') * 100 +
27249 (chars[1] - '0') * 10 +
27252 if (jsuint(i) < INT_STRING_LIMIT)
27253 return intString(i);
27262 JSString::finalize(JSContext *cx) {
27265 if (isDependent()) {
27267 } else if (isFlat()) {
27272 cx->runtime->stringMemoryUsed -= length() * 2;
27273 cx->free(const_cast<jschar *>(flatChars()));
27278 JSShortString::finalize(JSContext *cx)
27286 JSExternalString::finalize(JSContext *cx)
27294 jschar *chars = const_cast<jschar *>(flatChars());
27297 JSStringFinalizeOp finalizer = str_finalizers[externalStringType];
27299 finalizer(cx, this);
27303 JSExternalString::finalize()
27306 JSStringFinalizeOp finalizer = str_finalizers[externalStringType];
27312 finalizer(__null, this);
27318 class RopeBuilder {
27323 RopeBuilder(JSContext *cx)
27324 : cx(cx), res(cx->runtime->emptyString)
27327 inline bool append(JSString *str) {
27328 res = js_ConcatStrings(cx, res, str);
27332 inline JSString *result() {
27337 class StringSegmentRange
27343 Vector<JSString *, 32> stack;
27346 bool settle(JSString *str) {
27347 while (str->isRope()) {
27348 if (!stack.append(str->ropeRight()))
27350 str = str->ropeLeft();
27357 StringSegmentRange(JSContext *cx)
27358 : stack(cx), cur(__null)
27361 __attribute__((warn_unused_result)) bool init(JSString *str) {
27363 return settle(str);
27366 bool empty() const {
27367 return cur == __null;
27370 JSString *front() const {
27375 __attribute__((warn_unused_result)) bool popFront() {
27377 if (stack.empty()) {
27381 return settle(stack.popCopy());
27396 struct PropertyTable {
27397 static const uint32 MAX_LINEAR_SEARCHES = 7;
27398 static const uint32 MIN_SIZE_LOG2 = 4;
27399 static const uint32 MIN_SIZE = ((JSUint32)1 << (MIN_SIZE_LOG2));
27404 uint32 removedCount;
27408 js::Shape **entries;
27410 PropertyTable(uint32 nentries)
27411 : hashShift(32 - MIN_SIZE_LOG2),
27412 entryCount(nentries),
27414 freelist(0xffffffff)
27424 uint32 capacity() const { return ((JSUint32)1 << (32 - hashShift)); }
27427 bool needsToGrow() const {
27428 uint32 size = capacity();
27429 return entryCount + removedCount >= size - (size >> 2);
27437 bool grow(JSContext *cx);
27444 bool init(JSRuntime *rt, js::Shape *lastProp);
27445 bool change(int log2Delta, JSContext *cx);
27446 js::Shape **search(jsid id, bool adding);
27455 class PropertyTree;
27457 static inline PropertyOp
27458 CastAsPropertyOp(js::Class *clasp)
27460 return (__extension__ (PropertyOp) (size_t) (clasp));
27468 struct Shape : public JSObjectMap
27470 friend struct ::JSObject;
27471 friend struct ::JSFunction;
27472 friend class js::PropertyTree;
27473 friend class js::Bindings;
27474 friend bool IsShapeAboutToBeFinalized(JSContext *cx, const js::Shape *shape);
27477 mutable size_t numLinearSearches;
27478 mutable js::PropertyTable *table;
27482 inline void freeTable(JSContext *cx);
27484 static bool initEmptyShapes(JSCompartment *comp);
27485 static void finishEmptyShapes(JSCompartment *comp);
27495 js::PropertyOp rawGetter;
27496 JSObject *getterObj;
27504 js::StrictPropertyOp rawSetter;
27506 JSObject *setterObj;
27514 mutable uint8 flags;
27519 mutable js::Shape *parent;
27521 mutable js::KidsPointer kids;
27523 mutable js::Shape **listp;
27529 static inline js::Shape **search(JSRuntime *rt, js::Shape **startp, jsid id,
27530 bool adding = false);
27531 static js::Shape *newDictionaryShape(JSContext *cx, const js::Shape &child, js::Shape **listp);
27532 static js::Shape *newDictionaryList(JSContext *cx, js::Shape **listp);
27534 inline void removeFromDictionary(JSObject *obj) const;
27535 inline void insertIntoDictionary(js::Shape **dictp);
27537 js::Shape *getChild(JSContext *cx, const js::Shape &child, js::Shape **listp);
27539 bool hashify(JSRuntime *rt);
27541 bool hasTable() const {
27543 return numLinearSearches > PropertyTable::MAX_LINEAR_SEARCHES;
27546 js::PropertyTable *getTable() const {
27551 void setTable(js::PropertyTable *t) const {
27556 void setParent(js::Shape *p) {
27557 typedef int js_static_assert67[(uint32(0xffffffff) == ~uint32(0)) ? 1 : -1];
27559 slotSpan = ((p->slotSpan)>(slot + 1)?(p->slotSpan):(slot + 1));
27564 void insertFree(js::Shape **freep) {
27571 parent->listp = &parent;
27576 void removeFree() {
27580 parent->listp = listp;
27584 const js::Shape *previous() const {
27590 friend struct Shape;
27592 const Shape *cursor;
27596 Range(const Shape *shape) : cursor(shape) { }
27598 bool empty() const {
27600 return !cursor->parent;
27603 const Shape &front() const {
27610 cursor = cursor->parent;
27614 Range all() const {
27615 return Range(this);
27628 SHARED_EMPTY = 0x02,
27634 SHAPE_REGEN = 0x04,
27637 IN_DICTIONARY = 0x08,
27643 Shape(jsid id, js::PropertyOp getter, js::StrictPropertyOp setter, uint32 slot, uintN attrs,
27644 uintN flags, intN shortid, uint32 shape = INVALID_SHAPE, uint32 slotSpan = 0);
27647 Shape(JSCompartment *comp, Class *aclasp);
27649 bool marked() const { return (flags & MARK) != 0; }
27650 void mark() const { flags |= MARK; }
27651 void clearMark() { flags &= ~MARK; }
27653 bool hasRegenFlag() const { return (flags & SHAPE_REGEN) != 0; }
27654 void setRegenFlag() { flags |= SHAPE_REGEN; }
27655 void clearRegenFlag() { flags &= ~SHAPE_REGEN; }
27657 bool inDictionary() const { return (flags & IN_DICTIONARY) != 0; }
27658 bool frozen() const { return (flags & FROZEN) != 0; }
27659 void setFrozen() { flags |= FROZEN; }
27661 bool isEmptyShape() const { ((void) 0); return !parent; }
27667 HAS_SHORTID = 0x40,
27669 PUBLIC_FLAGS = ALIAS | HAS_SHORTID | METHOD
27672 uintN getFlags() const { return flags & PUBLIC_FLAGS; }
27673 bool isAlias() const { return (flags & ALIAS) != 0; }
27674 bool hasShortID() const { return (flags & HAS_SHORTID) != 0; }
27675 bool isMethod() const { return (flags & METHOD) != 0; }
27677 JSObject &methodObject() const { ((void) 0); return *getterObj; }
27679 js::PropertyOp getter() const { return rawGetter; }
27680 bool hasDefaultGetter() const { return !rawGetter; }
27681 js::PropertyOp getterOp() const { ((void) 0); return rawGetter; }
27682 JSObject *getterObject() const { ((void) 0); return getterObj; }
27685 js::Value getterValue() const {
27687 return getterObj ? js::ObjectValue(*getterObj) : js::UndefinedValue();
27690 js::Value getterOrUndefined() const {
27691 return hasGetterValue() && getterObj ? js::ObjectValue(*getterObj) : js::UndefinedValue();
27694 js::StrictPropertyOp setter() const { return rawSetter; }
27695 bool hasDefaultSetter() const { return !rawSetter; }
27696 js::StrictPropertyOp setterOp() const { ((void) 0); return rawSetter; }
27697 JSObject *setterObject() const { ((void) 0); return setterObj; }
27700 js::Value setterValue() const {
27702 return setterObj ? js::ObjectValue(*setterObj) : js::UndefinedValue();
27705 js::Value setterOrUndefined() const {
27706 return hasSetterValue() && setterObj ? js::ObjectValue(*setterObj) : js::UndefinedValue();
27709 inline JSDHashNumber hash() const;
27710 inline bool matches(const js::Shape *p) const;
27711 inline bool matchesParamsAfterId(js::PropertyOp agetter, js::StrictPropertyOp asetter,
27712 uint32 aslot, uintN aattrs, uintN aflags,
27713 intN ashortid) const;
27715 bool get(JSContext* cx, JSObject *receiver, JSObject *obj, JSObject *pobj, js::Value* vp) const;
27716 bool set(JSContext* cx, JSObject *obj, bool strict, js::Value* vp) const;
27718 inline bool isSharedPermanent() const;
27720 void trace(JSTracer *trc) const;
27722 bool hasSlot() const { return (attrs & 0x40) == 0; }
27724 uint8 attributes() const { return attrs; }
27725 bool configurable() const { return (attrs & 0x04) == 0; }
27726 bool enumerable() const { return (attrs & 0x01) != 0; }
27727 bool writable() const {
27729 return (attrs & 0x02) == 0;
27731 bool hasGetterValue() const { return attrs & 0x10; }
27732 bool hasSetterValue() const { return attrs & 0x20; }
27734 bool hasDefaultGetterOrIsMethod() const {
27735 return hasDefaultGetter() || isMethod();
27738 bool isDataDescriptor() const {
27739 return (attrs & (0x20 | 0x10)) == 0;
27741 bool isAccessorDescriptor() const {
27742 return (attrs & (0x20 | 0x10)) != 0;
27751 bool shadowable() const {
27753 return hasSlot() || (attrs & 0x80);
27756 uint32 entryCount() const {
27758 return getTable()->entryCount;
27760 const js::Shape *shape = this;
27762 for (js::Shape::Range r = shape->all(); !r.empty(); r.popFront())
27773 struct EmptyShape : public js::Shape
27775 EmptyShape(JSCompartment *comp, js::Class *aclasp);
27777 js::Class *getClass() const { return clasp; };
27779 static EmptyShape *create(JSCompartment *comp, js::Class *clasp) {
27780 js::Shape *eprop = comp->propertyTree.newShapeUnchecked();
27783 return new (eprop) EmptyShape(comp, clasp);
27786 static EmptyShape *create(JSContext *cx, js::Class *clasp) {
27787 js::Shape *eprop = ((cx)->compartment->propertyTree).newShape(cx);
27790 return new (eprop) EmptyShape(cx->compartment, clasp);
27796 inline js::Shape **
27797 JSObject::nativeSearch(jsid id, bool adding)
27799 return js::Shape::search(compartment()->rt, &lastProp, id, adding);
27802 inline const js::Shape *
27803 JSObject::nativeLookup(jsid id)
27806 return ((js::Shape *) (jsuword(*(nativeSearch(id))) & ~(jsuword(1))));
27813 JSObject::nativeContains(jsid id)
27815 return nativeLookup(id) != __null;
27822 JSObject::nativeContains(const js::Shape &shape)
27824 return nativeLookup(shape.id) == &shape;
27827 inline const js::Shape *
27828 JSObject::lastProperty() const
27839 JSObject::nativeEmpty() const
27841 return lastProperty()->isEmptyShape();
27848 JSObject::inDictionaryMode() const
27850 return lastProperty()->inDictionary();
27854 JSObject::propertyCount() const
27856 return lastProperty()->entryCount();
27863 JSObject::hasPropertyTable() const
27865 return lastProperty()->hasTable();
27872 JSObject::setLastProperty(const js::Shape *shape)
27879 lastProp = const_cast<js::Shape *>(shape);
27883 JSObject::removeLastProperty()
27888 lastProp = lastProp->parent;
27894 Shape::removeFromDictionary(JSObject *obj) const
27908 parent->listp = listp;
27914 Shape::insertIntoDictionary(js::Shape **dictp)
27931 parent->listp = &parent;
27939 js_GenerateShape(JSRuntime *rt);
27942 js_GenerateShape(JSContext *cx);
27946 __attribute__((always_inline)) inline js::Shape **
27947 Shape::search(JSRuntime *rt, js::Shape **startp, jsid id, bool adding)
27949 js::Shape *start = *startp;
27952 if (start->hasTable())
27953 return start->getTable()->search(id, adding);
27955 if (start->numLinearSearches == PropertyTable::MAX_LINEAR_SEARCHES) {
27956 if (start->hashify(rt))
27957 return start->getTable()->search(id, adding);
27962 start->numLinearSearches++;
27966 for (spp = startp; js::Shape *shape = *spp; spp = &shape->parent) {
27967 if (shape->id == id) {
27982 Shape::isSharedPermanent() const
27984 return (~attrs & (0x40 | 0x04)) == 0;
27995 # 1 "jsatominlines.h" 1
27996 # 49 "jsatominlines.h"
27999 # 49 "jsatominlines.h"
28001 js_ValueToAtom(JSContext *cx, const js::Value &v, JSAtom **atomp)
28005 # 62 "jsatominlines.h"
28006 if (v.isString()) {
28007 str = v.toString();
28008 if (str->isAtomized()) {
28009 *atomp = (((void) 0), (JSAtom *)str);
28013 str = js_ValueToString(cx, v);
28017 atom = js_AtomizeString(cx, str, 0);
28026 # 80 "jsatominlines.h"
28028 js_ValueToStringId(JSContext *cx, const js::Value &v, jsid *idp)
28031 if (js_ValueToAtom(cx, v, &atom)) {
28032 *idp = ATOM_TO_JSID(atom);
28040 # 91 "jsatominlines.h"
28042 js_InternNonIntElementId(JSContext *cx, JSObject *obj, const js::Value &idval,
28048 extern bool js_InternNonIntElementIdSlow(JSContext *, JSObject *,
28049 const js::Value &, jsid *);
28050 if (idval.isObject())
28051 return js_InternNonIntElementIdSlow(cx, obj, idval, idp);
28054 return js_ValueToStringId(cx, idval, idp);
28059 # 107 "jsatominlines.h"
28061 js_InternNonIntElementId(JSContext *cx, JSObject *obj, const js::Value &idval,
28062 jsid *idp, js::Value *vp)
28067 extern bool js_InternNonIntElementIdSlow(JSContext *, JSObject *,
28069 jsid *, js::Value *);
28070 if (idval.isObject())
28071 return js_InternNonIntElementIdSlow(cx, obj, idval, idp, vp);
28075 if (js_ValueToAtom(cx, idval, &atom)) {
28076 *idp = ATOM_TO_JSID(atom);
28077 vp->setString((atom));
28085 # 130 "jsatominlines.h"
28087 js_Int32ToId(JSContext* cx, int32 index, jsid* id)
28089 if (INT_FITS_IN_JSID(index)) {
28090 *id = INT_TO_JSID(index);
28094 JSString* str = js_NumberToString(cx, index);
28098 return js_ValueToStringId(cx, js::StringValue(str), id);
28102 # 1 "jsinterpinlines.h" 1
28103 # 48 "jsinterpinlines.h"
28109 static const char nullName[];
28111 static const char *FunctionClassname(const JSFunction *fun);
28112 static const char *ScriptFilename(JSScript *script);
28113 static int FunctionLineNumber(JSContext *cx, const JSFunction *fun);
28114 static const char *FunctionName(JSContext *cx, const JSFunction *fun, JSAutoByteString *bytes);
28116 static void enterJSFunImpl(JSContext *cx, JSFunction *fun, JSScript *script);
28117 static void handleFunctionReturn(JSContext *cx, JSFunction *fun, JSScript *script);
28118 static void finalizeObjectImpl(JSObject *obj);
28120 static bool callTrackingActive(JSContext *);
28122 static void enterJSFun(JSContext *, JSFunction *, JSScript *, int counter = 1);
28123 static void exitJSFun(JSContext *, JSFunction *, JSScript *, int counter = 0);
28125 static void startExecution(JSContext *cx, JSScript *script);
28126 static void stopExecution(JSContext *cx, JSScript *script);
28128 static void resizeHeap(JSCompartment *compartment, size_t oldSize, size_t newSize);
28131 static void createObject(JSContext *cx, JSObject *obj);
28133 static void resizeObject(JSContext *cx, JSObject *obj, size_t oldSize, size_t newSize);
28136 static void finalizeObject(JSObject *obj);
28138 static void createString(JSContext *cx, JSString *string, size_t length);
28143 static void finalizeString(JSString *string);
28145 static void compileScriptBegin(JSContext *cx, const char *filename, int lineno);
28146 static void compileScriptEnd(JSContext *cx, JSScript *script, const char *filename, int lineno);
28148 static void calloutBegin(JSContext *cx, JSFunction *fun);
28149 static void calloutEnd(JSContext *cx, JSFunction *fun);
28151 static void acquireMemory(JSContext *cx, void *address, size_t nbytes);
28152 static void releaseMemory(JSContext *cx, void *address, size_t nbytes);
28154 static void GCStart(JSCompartment *compartment);
28155 static void GCEnd(JSCompartment *compartment);
28156 static void GCStartMarkPhase(JSCompartment *compartment);
28158 static void GCEndMarkPhase(JSCompartment *compartment);
28159 static void GCStartSweepPhase(JSCompartment *compartment);
28160 static void GCEndSweepPhase(JSCompartment *compartment);
28162 static bool CustomMark(JSString *string);
28163 static bool CustomMark(const char *string);
28164 static bool CustomMark(int marker);
28166 static bool startProfiling();
28167 static void stopProfiling();
28174 Probes::callTrackingActive(JSContext *cx)
28181 Probes::enterJSFun(JSContext *cx, JSFunction *fun, JSScript *script, int counter)
28193 Probes::exitJSFun(JSContext *cx, JSFunction *fun, JSScript *script, int counter)
28199 Probes::createObject(JSContext *cx, JSObject *obj)
28210 Probes::finalizeObject(JSObject *obj)
28216 Probes::startExecution(JSContext *cx, JSScript *script)
28222 Probes::stopExecution(JSContext *cx, JSScript *script)
28232 inline void Probes::resizeHeap(JSCompartment *compartment, size_t oldSize, size_t newSize) {}
28233 inline void Probes::resizeObject(JSContext *cx, JSObject *obj, size_t oldSize, size_t newSize) {}
28234 inline void Probes::createString(JSContext *cx, JSString *string, size_t length) {}
28235 inline void Probes::finalizeString(JSString *string) {}
28236 inline void Probes::compileScriptBegin(JSContext *cx, const char *filename, int lineno) {}
28237 inline void Probes::compileScriptEnd(JSContext *cx, JSScript *script, const char *filename, int lineno) {}
28238 inline void Probes::calloutBegin(JSContext *cx, JSFunction *fun) {}
28239 inline void Probes::calloutEnd(JSContext *cx, JSFunction *fun) {}
28240 inline void Probes::acquireMemory(JSContext *cx, void *address, size_t nbytes) {}
28241 inline void Probes::releaseMemory(JSContext *cx, void *address, size_t nbytes) {}
28242 inline void Probes::GCStart(JSCompartment *compartment) {}
28243 inline void Probes::GCEnd(JSCompartment *compartment) {}
28244 inline void Probes::GCStartMarkPhase(JSCompartment *compartment) {}
28245 inline void Probes::GCEndMarkPhase(JSCompartment *compartment) {}
28246 inline void Probes::GCStartSweepPhase(JSCompartment *compartment) {}
28247 inline void Probes::GCEndSweepPhase(JSCompartment *compartment) {}
28248 inline bool Probes::CustomMark(JSString *string) { return (JSIntn)1; }
28249 inline bool Probes::CustomMark(const char *string) { return (JSIntn)1; }
28250 inline bool Probes::CustomMark(int marker) { return (JSIntn)1; }
28252 struct AutoFunctionCallProbe {
28253 JSContext * const cx;
28258 AutoFunctionCallProbe(JSContext *cx, JSFunction *fun, JSScript *script
28260 : cx(cx), fun(fun), script(script)
28263 Probes::enterJSFun(cx, fun, script);
28266 ~AutoFunctionCallProbe() {
28267 Probes::exitJSFun(cx, fun, script);
28272 # 49 "jsinterpinlines.h" 2
28274 # 1 "methodjit/MethodJIT.h" 1
28275 # 51 "jsinterpinlines.h" 2
28277 # 1 "jsfuninlines.h" 1
28278 # 46 "jsfuninlines.h"
28281 # 46 "jsfuninlines.h"
28283 JSFunction::inStrictMode() const
28285 return script()->strictModeCode;
28287 # 53 "jsinterpinlines.h" 2
28290 JSStackFrame::initPrev(JSContext *cx)
28293 if (JSFrameRegs *regs = cx->regs) {
28295 prevpc_ = regs->pc;
28307 JSStackFrame::resetGeneratorPrev(JSContext *cx)
28309 flags_ |= JSFRAME_HAS_PREVPC;
28314 JSStackFrame::initCallFrame(JSContext *cx, JSObject &callee, JSFunction *fun,
28315 uint32 nactual, uint32 flagsArg)
28323 flags_ = JSFRAME_FUNCTION | JSFRAME_HAS_PREVPC | JSFRAME_HAS_SCOPECHAIN | flagsArg;
28325 args.nactual = nactual;
28326 scopeChain_ = callee.getParent();
28336 JSStackFrame::resetInvokeCallFrame()
28349 flags_ &= JSFRAME_FUNCTION |
28350 JSFRAME_OVERFLOW_ARGS |
28351 JSFRAME_HAS_PREVPC |
28352 JSFRAME_UNDERFLOW_ARGS;
28355 scopeChain_ = callee().getParent();
28359 JSStackFrame::initCallFrameCallerHalf(JSContext *cx, uint32 flagsArg,
28367 flags_ = JSFRAME_FUNCTION | flagsArg;
28368 prev_ = cx->regs->fp;
28377 JSStackFrame::initCallFrameEarlyPrologue(JSFunction *fun, uint32 nactual)
28380 if (flags_ & (JSFRAME_OVERFLOW_ARGS | JSFRAME_UNDERFLOW_ARGS))
28381 args.nactual = nactual;
28389 JSStackFrame::initCallFrameLatePrologue()
28391 SetValueRangeToUndefined(slots(), script()->nfixed);
28395 JSStackFrame::initEvalFrame(JSContext *cx, JSScript *script, JSStackFrame *prev, uint32 flagsArg)
28402 js::Value *dstvp = (js::Value *)this - 2;
28403 js::Value *srcvp = prev->flags_ & (JSFRAME_GLOBAL | JSFRAME_EVAL)
28404 ? (js::Value *)prev - 2
28405 : prev->formalArgs() - 2;
28406 dstvp[0] = srcvp[0];
28407 dstvp[1] = srcvp[1];
28412 flags_ = flagsArg | JSFRAME_HAS_PREVPC | JSFRAME_HAS_SCOPECHAIN |
28413 (prev->flags_ & (JSFRAME_FUNCTION | JSFRAME_GLOBAL | JSFRAME_HAS_CALL_OBJ));
28414 if (isFunctionFrame()) {
28416 args.script = script;
28418 exec.script = script;
28421 scopeChain_ = &prev->scopeChain();
28425 prevpc_ = prev->pc(cx);
28428 setAnnotation(prev->annotation());
28432 JSStackFrame::initGlobalFrame(JSScript *script, JSObject &chain, uint32 flagsArg)
28437 js::Value *vp = (js::Value *)this - 2;
28438 vp[0].setUndefined();
28439 vp[1].setUndefined();
28442 flags_ = flagsArg | JSFRAME_GLOBAL | JSFRAME_HAS_PREVPC | JSFRAME_HAS_SCOPECHAIN;
28443 exec.script = script;
28444 args.script = (JSScript *)0xbad;
28445 scopeChain_ = &chain;
28453 JSStackFrame::initDummyFrame(JSContext *cx, JSObject &chain)
28456 flags_ = JSFRAME_DUMMY | JSFRAME_HAS_PREVPC | JSFRAME_HAS_SCOPECHAIN;
28459 setScopeChainNoCallObj(chain);
28463 JSStackFrame::stealFrameAndSlots(js::Value *vp, JSStackFrame *otherfp,
28464 js::Value *othervp, js::Value *othersp)
28471 PodCopy(vp, othervp, othersp - othervp);
28475 if (otherfp->hasOverflowArgs())
28476 Debug_SetValueRangeToCrashOnTouch(othervp, othervp + 2 + otherfp->numFormalArgs());
28484 if (hasCallObj()) {
28485 callObj().setPrivate(this);
28486 otherfp->flags_ &= ~JSFRAME_HAS_CALL_OBJ;
28487 if (js_IsNamedLambda(fun())) {
28488 JSObject *env = callObj().getParent();
28490 env->setPrivate(this);
28493 if (hasArgsObj()) {
28494 JSObject &args = argsObj();
28496 if (args.isNormalArguments())
28497 args.setPrivate(this);
28500 otherfp->flags_ &= ~JSFRAME_HAS_ARGS_OBJ;
28505 JSStackFrame::canonicalActualArg(uintN i) const
28507 if (i < numFormalArgs())
28508 return formalArg(i);
28510 return actualArgs()[i];
28513 template <class Op>
28515 JSStackFrame::forEachCanonicalActualArg(Op op)
28517 uintN nformal = fun()->nargs;
28518 js::Value *formals = formalArgsEnd() - nformal;
28519 uintN nactual = numActualArgs();
28520 if (nactual <= nformal) {
28522 js::Value *actualsEnd = formals + nactual;
28523 for (js::Value *p = formals; p != actualsEnd; ++p, ++i)
28527 js::Value *formalsEnd = formalArgsEnd();
28528 for (js::Value *p = formals; p != formalsEnd; ++p, ++i)
28530 js::Value *actuals = formalsEnd - (nactual + 2);
28531 js::Value *actualsEnd = formals - 2;
28532 for (js::Value *p = actuals; p != actualsEnd; ++p, ++i)
28537 template <class Op>
28539 JSStackFrame::forEachFormalArg(Op op)
28541 js::Value *formals = formalArgsEnd() - fun()->nargs;
28542 js::Value *formalsEnd = formalArgsEnd();
28544 for (js::Value *p = formals; p != formalsEnd; ++p, ++i)
28550 struct CopyNonHoleArgsTo
28552 CopyNonHoleArgsTo(JSObject *aobj, Value *dst) : aobj(aobj), dst(dst) {}
28555 void operator()(uintN argi, Value *src) {
28556 if (aobj->getArgsElement(argi).isMagic(JS_ARGS_HOLE))
28557 dst->setUndefined();
28567 CopyTo(Value *dst) : dst(dst) {}
28568 void operator()(uintN, Value *src) {
28575 __attribute__((always_inline)) inline void
28576 JSStackFrame::clearMissingArgs()
28578 if (flags_ & JSFRAME_UNDERFLOW_ARGS)
28579 SetValueRangeToUndefined(formalArgs() + numActualArgs(), formalArgsEnd());
28584 # 347 "jsinterpinlines.h"
28586 JSStackFrame::computeThis(JSContext *cx)
28588 js::Value &thisv = thisValue();
28589 if (thisv.isObject())
28591 if (isFunctionFrame()) {
28592 if (fun()->inStrictMode())
28603 if (!js::BoxThisForVp(cx, &thisv - 1))
28609 JSStackFrame::varobj(js::StackSegment *seg) const
28612 return isFunctionFrame() ? callObj() : seg->getInitialVarObj();
28616 JSStackFrame::varobj(JSContext *cx) const
28619 return isFunctionFrame() ? callObj() : cx->activeSegment()->getInitialVarObj();
28623 JSStackFrame::numActualArgs() const
28626 if ((__builtin_expect((flags_ & (JSFRAME_OVERFLOW_ARGS | JSFRAME_UNDERFLOW_ARGS)), 0)))
28627 return hasArgsObj() ? argsObj().getArgsInitialLength() : args.nactual;
28628 return numFormalArgs();
28632 JSStackFrame::actualArgs() const
28635 js::Value *argv = formalArgs();
28636 if ((__builtin_expect((flags_ & JSFRAME_OVERFLOW_ARGS), 0))) {
28637 uintN nactual = hasArgsObj() ? argsObj().getArgsInitialLength() : args.nactual;
28638 return argv - (2 + nactual);
28644 JSStackFrame::actualArgsEnd() const
28647 if ((__builtin_expect((flags_ & JSFRAME_OVERFLOW_ARGS), 0)))
28648 return formalArgs() - 2;
28649 return formalArgs() + numActualArgs();
28653 JSStackFrame::setArgsObj(JSObject &obj)
28658 flags_ |= JSFRAME_HAS_ARGS_OBJ;
28662 JSStackFrame::clearArgsObj()
28665 args.nactual = args.obj->getArgsInitialLength();
28666 flags_ ^= JSFRAME_HAS_ARGS_OBJ;
28670 JSStackFrame::setScopeChainNoCallObj(JSObject &obj)
28672 # 442 "jsinterpinlines.h"
28673 scopeChain_ = &obj;
28674 flags_ |= JSFRAME_HAS_SCOPECHAIN;
28679 JSStackFrame::setScopeChainAndCallObj(JSObject &obj)
28683 scopeChain_ = &obj;
28684 flags_ |= JSFRAME_HAS_SCOPECHAIN | JSFRAME_HAS_CALL_OBJ;
28688 JSStackFrame::clearCallObj()
28691 flags_ ^= JSFRAME_HAS_CALL_OBJ;
28695 JSStackFrame::callObj() const
28698 JSObject *pobj = &scopeChain();
28699 while ((__builtin_expect((pobj->getClass() != &js_CallClass), 0))) {
28701 pobj = pobj->getParent();
28707 JSStackFrame::maybeCallObj() const
28709 return hasCallObj() ? &callObj() : __null;
28714 class AutoPreserveEnumerators {
28716 JSObject *enumerators;
28719 AutoPreserveEnumerators(JSContext *cx) : cx(cx), enumerators(cx->enumerators)
28723 ~AutoPreserveEnumerators()
28725 cx->enumerators = enumerators;
28729 struct AutoInterpPreparer {
28733 AutoInterpPreparer(JSContext *cx, JSScript *script)
28734 : cx(cx), script(script)
28739 ~AutoInterpPreparer()
28746 PutActivationObjects(JSContext *cx, JSStackFrame *fp)
28752 if (fp->hasCallObj()) {
28753 js_PutCallObject(cx, fp);
28754 } else if (fp->hasArgsObj()) {
28755 js_PutArgsObject(cx, fp);
28765 PutOwnedActivationObjects(JSContext *cx, JSStackFrame *fp)
28768 if (!fp->isEvalFrame() || fp->script()->strictModeCode)
28769 PutActivationObjects(cx, fp);
28772 class InvokeSessionGuard
28774 InvokeArgsGuard args_;
28775 InvokeFrameGuard frame_;
28776 Value savedCallee_, savedThis_;
28777 Value *formals_, *actuals_;
28778 unsigned nformals_;
28780 Value *stackLimit_;
28783 bool optimized() const { return frame_.pushed(); }
28786 InvokeSessionGuard() : args_(), frame_() {}
28787 inline ~InvokeSessionGuard();
28789 bool start(JSContext *cx, const Value &callee, const Value &thisv, uintN argc);
28790 bool invoke(JSContext *cx) const;
28792 bool started() const {
28793 return args_.pushed();
28796 Value &operator[](unsigned i) const {
28798 Value &arg = i < nformals_ ? formals_[i] : actuals_[i];
28804 uintN argc() const {
28805 return args_.argc();
28808 const Value &rval() const {
28809 return optimized() ? frame_.fp()->returnValue() : args_.rval();
28814 InvokeSessionGuard::~InvokeSessionGuard()
28816 if (frame_.pushed())
28817 PutActivationObjects(frame_.pushedFrameContext(), frame_.fp());
28822 # 589 "jsinterpinlines.h"
28824 InvokeSessionGuard::invoke(JSContext *cx) const
28829 formals_[-2] = savedCallee_;
28830 formals_[-1] = savedThis_;
28838 return Invoke(cx, args_, 0);
28841 JSStackFrame *fp = frame_.fp();
28842 fp->clearMissingArgs();
28843 PutActivationObjects(cx, frame_.fp());
28844 fp->resetInvokeCallFrame();
28845 SetValueRangeToUndefined(fp->slots(), script_->nfixed);
28849 AutoPreserveEnumerators preserve(cx);
28850 Probes::enterJSFun(cx, fp->fun(), script_);
28856 cx->regs->pc = script_->code;
28857 ok = Interpret(cx, cx->fp());
28859 Probes::exitJSFun(cx, fp->fun(), script_);
28868 template<typename T> class PrimitiveBehavior { };
28871 class PrimitiveBehavior<JSString *> {
28873 static inline bool isType(const Value &v) { return v.isString(); }
28874 static inline JSString *extract(const Value &v) { return v.toString(); }
28875 static inline Class *getClass() { return &js_StringClass; }
28879 class PrimitiveBehavior<bool> {
28881 static inline bool isType(const Value &v) { return v.isBoolean(); }
28882 static inline bool extract(const Value &v) { return v.toBoolean(); }
28883 static inline Class *getClass() { return &js_BooleanClass; }
28887 class PrimitiveBehavior<double> {
28889 static inline bool isType(const Value &v) { return v.isNumber(); }
28890 static inline double extract(const Value &v) { return v.toNumber(); }
28891 static inline Class *getClass() { return &js_NumberClass; }
28895 # 703 "jsinterpinlines.h"
28898 # 703 "jsinterpinlines.h"
28900 ComputeImplicitThis(JSContext *cx, JSObject *obj, const Value &funval, Value *vp)
28902 vp->setUndefined();
28904 if (!funval.isObject())
28907 if (!obj->isGlobal()) {
28908 if (IsCacheableNonGlobalScope(obj))
28911 JSObject *callee = &funval.toObject();
28913 if (callee->isProxy()) {
28914 callee = callee->unwrap();
28915 if (!callee->isFunction())
28918 if (callee->isFunction()) {
28919 JSFunction *fun = callee->getFunctionPrivate();
28920 if (fun->isInterpreted() && fun->inStrictMode())
28923 if (callee->getGlobal() == cx->fp()->scopeChain().getGlobal())
28927 obj = obj->thisObject(cx);
28931 vp->setObject(*obj);
28935 template <typename T>
28938 # 741 "jsinterpinlines.h"
28939 GetPrimitiveThis(JSContext *cx, Value *vp, T *v)
28941 typedef detail::PrimitiveBehavior<T> Behavior;
28943 const Value &thisv = vp[1];
28944 if (Behavior::isType(thisv)) {
28945 *v = Behavior::extract(thisv);
28949 if (thisv.isObject() && thisv.toObject().getClass() == Behavior::getClass()) {
28950 *v = Behavior::extract(thisv.toObject().getPrimitiveThis());
28954 ReportIncompatibleMethod(cx, vp, Behavior::getClass());
28957 # 771 "jsinterpinlines.h"
28958 __attribute__((always_inline)) inline JSObject *
28959 ValuePropertyBearer(JSContext *cx, const Value &v, int spindex)
28962 return &v.toObject();
28964 JSProtoKey protoKey;
28965 if (v.isString()) {
28966 protoKey = JSProto_String;
28967 } else if (v.isNumber()) {
28968 protoKey = JSProto_Number;
28969 } else if (v.isBoolean()) {
28970 protoKey = JSProto_Boolean;
28973 js_ReportIsNullOrUndefined(cx, spindex, v, __null);
28978 if (!js_GetClassPrototype(cx, __null, protoKey, &pobj))
28985 # 796 "jsinterpinlines.h"
28987 ScriptEpilogue(JSContext *cx, JSStackFrame *fp, JSBool ok)
28989 if (!fp->isExecuteFrame())
28990 Probes::exitJSFun(cx, fp->maybeFun(), fp->maybeScript());
28992 JSInterpreterHook hook =
28993 fp->isExecuteFrame() ? cx->debugHooks->executeHook : cx->debugHooks->callHook;
28996 if ((__builtin_expect((hook != __null), 0)) && (hookData = fp->maybeHookData()))
28997 hook(cx, fp, (JSIntn)0, &ok, hookData);
28999 if (fp->isEvalFrame()) {
29006 if (fp->script()->strictModeCode) {
29011 js_PutCallObject(cx, fp);
29019 if (fp->isFunctionFrame() && !fp->isYielding()) {
29021 PutActivationObjects(cx, fp);
29029 if (fp->isConstructing() && ok) {
29030 if (fp->returnValue().isPrimitive())
29031 fp->setReturnValue(ObjectValue(fp->constructorThis()));
29040 # 1 "jsobjinlines.h" 1
29041 # 45 "jsobjinlines.h"
29044 extern js::Class js_DateClass;
29050 JSObject::isDate() const
29052 return getClass() == &js_DateClass;
29062 js_InitDateClass(JSContext *cx, JSObject *obj);
29064 extern __attribute__((visibility ("default"))) JSObject*
29065 js_NewDateObjectMsec(JSContext* cx, jsdouble msec_time);
29067 extern __attribute__((visibility ("default"))) JSObject*
29068 js_NewDateObject(JSContext* cx, int year, int mon, int mday,
29069 int hour, int min, int sec);
29075 extern __attribute__((visibility ("default"))) JSBool
29076 js_DateIsValid(JSContext *cx, JSObject* obj);
29078 extern __attribute__((visibility ("default"))) int
29079 js_DateGetYear(JSContext *cx, JSObject* obj);
29081 extern __attribute__((visibility ("default"))) int
29082 js_DateGetMonth(JSContext *cx, JSObject* obj);
29084 extern __attribute__((visibility ("default"))) int
29085 js_DateGetDate(JSContext *cx, JSObject* obj);
29087 extern __attribute__((visibility ("default"))) int
29088 js_DateGetHours(JSContext *cx, JSObject* obj);
29090 extern __attribute__((visibility ("default"))) int
29091 js_DateGetMinutes(JSContext *cx, JSObject* obj);
29093 extern __attribute__((visibility ("default"))) int
29094 js_DateGetSeconds(JSContext *cx, JSObject* obj);
29096 extern __attribute__((visibility ("default"))) jsdouble
29097 js_DateGetMsecSinceEpoch(JSContext *cx, JSObject *obj);
29099 typedef uint32 JSIntervalTime;
29101 extern __attribute__((visibility ("default"))) JSIntervalTime
29106 js_Date(JSContext *cx, uintN argc, js::Value *vp);
29107 # 46 "jsobjinlines.h" 2
29111 # 1 "jsversion.h" 1
29116 struct NativeIterator {
29119 jsid *props_cursor;
29121 uint32 *shapes_array;
29122 uint32 shapes_length;
29127 bool isKeyIter() const { return (flags & 0x2) == 0; }
29129 inline jsid *begin() const {
29130 return props_array;
29133 inline jsid *end() const {
29137 size_t numKeys() const {
29138 return end() - begin();
29141 jsid *current() const {
29143 return props_cursor;
29147 props_cursor = props_cursor + 1;
29150 static NativeIterator *allocateIterator(JSContext *cx, uint32 slength,
29151 const js::AutoIdVector &props);
29152 void init(JSObject *obj, uintN flags, uint32 slength, uint32 key);
29154 void mark(JSTracer *trc);
29160 VectorToIdArray(JSContext *cx, js::AutoIdVector &props, JSIdArray **idap);
29162 __attribute__((visibility ("default"))) bool
29163 GetPropertyNames(JSContext *cx, JSObject *obj, uintN flags, js::AutoIdVector *props);
29168 GetIterator(JSContext *cx, JSObject *obj, uintN flags, js::Value *vp);
29173 VectorToKeyIterator(JSContext *cx, JSObject *obj, uintN flags, js::AutoIdVector &props, js::Value *vp);
29178 VectorToValueIterator(JSContext *cx, JSObject *obj, uintN flags, js::AutoIdVector &props, js::Value *vp);
29187 EnumeratedIdVectorToIterator(JSContext *cx, JSObject *obj, uintN flags, js::AutoIdVector &props, js::Value *vp);
29197 extern __attribute__((visibility ("default"))) JSBool
29198 js_ValueToIterator(JSContext *cx, uintN flags, js::Value *vp);
29200 extern __attribute__((visibility ("default"))) JSBool
29201 js_CloseIterator(JSContext *cx, JSObject *iterObj);
29206 js_SuppressDeletedProperty(JSContext *cx, JSObject *obj, jsid id);
29211 js_SuppressDeletedIndexProperties(JSContext *cx, JSObject *obj, jsint begin, jsint end);
29219 js_IteratorMore(JSContext *cx, JSObject *iterobj, js::Value *rval);
29222 js_IteratorNext(JSContext *cx, JSObject *iterobj, js::Value *rval);
29225 js_ThrowStopIteration(JSContext *cx);
29232 typedef enum JSGeneratorState {
29238 } JSGeneratorState;
29240 struct JSGenerator {
29242 JSGeneratorState state;
29244 JSObject *enumerators;
29245 JSStackFrame *floating;
29246 js::Value floatingStack[1];
29248 JSStackFrame *floatingFrame() {
29252 JSStackFrame *liveFrame() {
29260 js_NewGenerator(JSContext *cx);
29262 inline JSStackFrame *
29263 js_FloatingFrameIfGenerator(JSContext *cx, JSStackFrame *fp)
29266 if ((__builtin_expect((fp->isGeneratorFrame()), 0)))
29267 return cx->generatorFor(fp)->floatingFrame();
29272 extern JSGenerator *
29273 js_FloatingFrameToGenerator(JSStackFrame *fp);
29275 inline JSStackFrame *
29276 js_LiveFrameIfGenerator(JSStackFrame *fp)
29278 return fp->isGeneratorFrame() ? js_FloatingFrameToGenerator(fp)->liveFrame() : fp;
29283 extern js::Class js_GeneratorClass;
29284 extern js::Class js_IteratorClass;
29285 extern js::Class js_StopIterationClass;
29291 js_ValueIsStopIteration(const js::Value &v)
29293 return v.isObject() && v.toObject().getClass() == &js_StopIterationClass;
29297 js_InitIteratorClasses(JSContext *cx, JSObject *obj);
29298 # 48 "jsobjinlines.h" 2
29302 # 51 "jsobjinlines.h" 2
29309 class __attribute__((visibility ("default"))) JSProxyHandler {
29312 explicit JSProxyHandler(void *family);
29313 virtual ~JSProxyHandler();
29316 virtual bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set,
29317 PropertyDescriptor *desc) = 0;
29318 virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set,
29319 PropertyDescriptor *desc) = 0;
29320 virtual bool defineProperty(JSContext *cx, JSObject *proxy, jsid id,
29321 PropertyDescriptor *desc) = 0;
29322 virtual bool getOwnPropertyNames(JSContext *cx, JSObject *proxy, js::AutoIdVector &props) = 0;
29323 virtual bool delete_(JSContext *cx, JSObject *proxy, jsid id, bool *bp) = 0;
29324 virtual bool enumerate(JSContext *cx, JSObject *proxy, js::AutoIdVector &props) = 0;
29325 virtual bool fix(JSContext *cx, JSObject *proxy, Value *vp) = 0;
29328 virtual bool has(JSContext *cx, JSObject *proxy, jsid id, bool *bp);
29329 virtual bool hasOwn(JSContext *cx, JSObject *proxy, jsid id, bool *bp);
29330 virtual bool get(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, js::Value *vp);
29331 virtual bool set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, bool strict,
29333 virtual bool keys(JSContext *cx, JSObject *proxy, js::AutoIdVector &props);
29334 virtual bool iterate(JSContext *cx, JSObject *proxy, uintN flags, js::Value *vp);
29337 virtual bool call(JSContext *cx, JSObject *proxy, uintN argc, js::Value *vp);
29338 virtual bool construct(JSContext *cx, JSObject *proxy,
29339 uintN argc, js::Value *argv, js::Value *rval);
29340 virtual bool hasInstance(JSContext *cx, JSObject *proxy, const js::Value *vp, bool *bp);
29341 virtual JSType typeOf(JSContext *cx, JSObject *proxy);
29342 virtual JSString *obj_toString(JSContext *cx, JSObject *proxy);
29343 virtual JSString *fun_toString(JSContext *cx, JSObject *proxy, uintN indent);
29344 virtual void finalize(JSContext *cx, JSObject *proxy);
29345 virtual void trace(JSTracer *trc, JSObject *proxy);
29347 virtual bool isOuterWindow() {
29351 inline void *family() {
29360 static bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set,
29361 PropertyDescriptor *desc);
29362 static bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set, Value *vp);
29363 static bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set,
29364 PropertyDescriptor *desc);
29365 static bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set,
29367 static bool defineProperty(JSContext *cx, JSObject *proxy, jsid id, PropertyDescriptor *desc);
29368 static bool defineProperty(JSContext *cx, JSObject *proxy, jsid id, const Value &v);
29369 static bool getOwnPropertyNames(JSContext *cx, JSObject *proxy, js::AutoIdVector &props);
29370 static bool delete_(JSContext *cx, JSObject *proxy, jsid id, bool *bp);
29371 static bool enumerate(JSContext *cx, JSObject *proxy, js::AutoIdVector &props);
29372 static bool fix(JSContext *cx, JSObject *proxy, Value *vp);
29375 static bool has(JSContext *cx, JSObject *proxy, jsid id, bool *bp);
29376 static bool hasOwn(JSContext *cx, JSObject *proxy, jsid id, bool *bp);
29377 static bool get(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, Value *vp);
29378 static bool set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, bool strict,
29380 static bool keys(JSContext *cx, JSObject *proxy, js::AutoIdVector &props);
29381 static bool iterate(JSContext *cx, JSObject *proxy, uintN flags, Value *vp);
29384 static bool call(JSContext *cx, JSObject *proxy, uintN argc, js::Value *vp);
29385 static bool construct(JSContext *cx, JSObject *proxy, uintN argc, js::Value *argv, js::Value *rval);
29386 static bool hasInstance(JSContext *cx, JSObject *proxy, const js::Value *vp, bool *bp);
29387 static JSType typeOf(JSContext *cx, JSObject *proxy);
29388 static JSString *obj_toString(JSContext *cx, JSObject *proxy);
29389 static JSString *fun_toString(JSContext *cx, JSObject *proxy, uintN indent);
29393 const uint32 JSSLOT_PROXY_HANDLER = 0;
29394 const uint32 JSSLOT_PROXY_PRIVATE = 1;
29395 const uint32 JSSLOT_PROXY_EXTRA = 2;
29397 const uint32 JSSLOT_PROXY_CALL = 3;
29398 const uint32 JSSLOT_PROXY_CONSTRUCT = 4;
29400 extern __attribute__((visibility ("default"))) js::Class ObjectProxyClass;
29401 extern __attribute__((visibility ("default"))) js::Class FunctionProxyClass;
29402 extern __attribute__((visibility ("default"))) js::Class OuterWindowProxyClass;
29403 extern js::Class CallableObjectClass;
29411 JSObject::isObjectProxy() const
29413 return getClass() == &js::ObjectProxyClass ||
29414 getClass() == &js::OuterWindowProxyClass;
29421 JSObject::isFunctionProxy() const
29423 return getClass() == &js::FunctionProxyClass;
29430 JSObject::isProxy() const
29432 return isObjectProxy() || isFunctionProxy();
29435 inline js::JSProxyHandler *
29436 JSObject::getProxyHandler() const
29439 return (js::JSProxyHandler *) getSlot(js::JSSLOT_PROXY_HANDLER).toPrivate();
29442 inline const js::Value &
29443 JSObject::getProxyPrivate() const
29446 return getSlot(js::JSSLOT_PROXY_PRIVATE);
29450 JSObject::setProxyPrivate(const js::Value &priv)
29453 setSlot(js::JSSLOT_PROXY_PRIVATE, priv);
29456 inline const js::Value &
29457 JSObject::getProxyExtra() const
29460 return getSlot(js::JSSLOT_PROXY_EXTRA);
29464 JSObject::setProxyExtra(const js::Value &extra)
29467 setSlot(js::JSSLOT_PROXY_EXTRA, extra);
29472 __attribute__((visibility ("default"))) JSObject *
29473 NewProxyObject(JSContext *cx, JSProxyHandler *handler, const js::Value &priv,
29474 JSObject *proto, JSObject *parent,
29475 JSObject *call = __null, JSObject *construct = __null);
29477 __attribute__((visibility ("default"))) JSBool
29478 FixProxy(JSContext *cx, JSObject *proxy, JSBool *bp);
29484 extern js::Class js_ProxyClass;
29486 extern __attribute__((visibility ("default"))) JSObject *
29487 js_InitProxyClass(JSContext *cx, JSObject *obj);
29490 # 53 "jsobjinlines.h" 2
29491 # 61 "jsobjinlines.h"
29492 # 1 "jsscopeinlines.h" 1
29493 # 53 "jsscopeinlines.h"
29495 js::Shape::freeTable(JSContext *cx)
29498 cx->destroy(getTable());
29503 inline js::EmptyShape *
29504 JSObject::getEmptyShape(JSContext *cx, js::Class *aclasp,
29508 int i = kind - js::gc::FINALIZE_OBJECT0;
29510 if (!emptyShapes) {
29511 emptyShapes = (js::EmptyShape**)
29512 cx->calloc(sizeof(js::EmptyShape*) * js::gc::JS_FINALIZE_OBJECT_LIMIT);
29520 emptyShapes[0] = js::EmptyShape::create(cx, aclasp);
29521 if (!emptyShapes[0]) {
29522 cx->free(emptyShapes);
29523 emptyShapes = __null;
29530 if (!emptyShapes[i]) {
29531 emptyShapes[i] = js::EmptyShape::create(cx, aclasp);
29532 if (!emptyShapes[i])
29536 return emptyShapes[i];
29541 # 98 "jsscopeinlines.h"
29543 JSObject::canProvideEmptyShape(js::Class *aclasp)
29545 return !emptyShapes || emptyShapes[0]->getClass() == aclasp;
29549 JSObject::updateShape(JSContext *cx)
29552 js::LeaveTraceIfGlobalObject(cx, this);
29554 setOwnShape(js_GenerateShape(cx));
29556 objShape = lastProp->shape;
29560 JSObject::updateFlags(const js::Shape *shape, bool isDefinitelyAtom)
29563 if (!isDefinitelyAtom && js_IdIsIndex(shape->id, &index))
29566 if (shape->isMethod())
29567 setMethodBarrier();
29571 JSObject::extend(JSContext *cx, const js::Shape *shape, bool isDefinitelyAtom)
29573 setLastProperty(shape);
29574 updateFlags(shape, isDefinitelyAtom);
29579 JSObject::trace(JSTracer *trc)
29584 JSContext *cx = trc->context;
29585 js::Shape *shape = lastProp;
29587 if (((trc)->callback == __null) && cx->runtime->gcRegenShapes) {
29592 if (!shape->hasRegenFlag()) {
29593 shape->shape = js_RegenerateShapeForGC(cx->runtime);
29594 shape->setRegenFlag();
29597 uint32 newShape = shape->shape;
29598 if (hasOwnShape()) {
29599 newShape = js_RegenerateShapeForGC(cx->runtime);
29602 objShape = newShape;
29608 } while ((shape = shape->parent) != __null);
29614 Shape::Shape(jsid id, js::PropertyOp getter, js::StrictPropertyOp setter, uint32 slot, uintN attrs,
29615 uintN flags, intN shortid, uint32 shape, uint32 slotSpan)
29616 : JSObjectMap(shape, slotSpan),
29617 numLinearSearches(0), id(id), rawGetter(getter), rawSetter(setter), slot(slot),
29618 attrs(uint8(attrs)), flags(uint8(flags)), shortid(int16(shortid)), parent(__null)
29627 Shape::Shape(JSCompartment *comp, Class *aclasp)
29628 : JSObjectMap(js_GenerateShape(comp->rt), (((aclasp)->flags >> 8) & (((JSUint32)1 << (8)) - 1))),
29629 numLinearSearches(0),
29635 flags(SHARED_EMPTY),
29642 inline JSDHashNumber
29643 Shape::hash() const
29645 JSDHashNumber hash = 0;
29650 hash = (((hash) << (4)) | ((hash) >> (32 - (4)))) ^ jsuword(rawGetter);
29652 hash = (((hash) << (4)) | ((hash) >> (32 - (4)))) ^ jsuword(rawSetter);
29653 hash = (((hash) << (4)) | ((hash) >> (32 - (4)))) ^ (flags & PUBLIC_FLAGS);
29654 hash = (((hash) << (4)) | ((hash) >> (32 - (4)))) ^ attrs;
29655 hash = (((hash) << (4)) | ((hash) >> (32 - (4)))) ^ shortid;
29656 hash = (((hash) << (4)) | ((hash) >> (32 - (4)))) ^ slot;
29657 hash = (((hash) << (4)) | ((hash) >> (32 - (4)))) ^ (id);
29663 # 217 "jsscopeinlines.h"
29665 Shape::matches(const js::Shape *other) const
29669 return id == other->id &&
29670 matchesParamsAfterId(other->rawGetter, other->rawSetter, other->slot, other->attrs,
29671 other->flags, other->shortid);
29676 # 227 "jsscopeinlines.h"
29678 Shape::matchesParamsAfterId(js::PropertyOp agetter, js::StrictPropertyOp asetter, uint32 aslot,
29679 uintN aattrs, uintN aflags, intN ashortid) const
29682 return rawGetter == agetter &&
29683 rawSetter == asetter &&
29686 ((flags ^ aflags) & PUBLIC_FLAGS) == 0 &&
29687 shortid == ashortid;
29692 # 240 "jsscopeinlines.h"
29694 Shape::get(JSContext* cx, JSObject *receiver, JSObject* obj, JSObject *pobj, js::Value* vp) const
29699 if (hasGetterValue()) {
29701 js::Value fval = getterValue();
29702 return js::ExternalGetOrSet(cx, receiver, id, fval, JSACC_READ, 0, 0, vp);
29706 vp->setObject(methodObject());
29707 return pobj->methodReadBarrier(cx, *this, vp);
29714 if (obj->getClass() == &js_WithClass)
29715 obj = js_UnwrapWithObject(cx, obj);
29716 return js::CallJSPropertyOp(cx, getterOp(), obj, ((this)->hasShortID() ? INT_TO_JSID((this)->shortid) : (this)->id), vp);
29721 # 266 "jsscopeinlines.h"
29723 Shape::set(JSContext* cx, JSObject* obj, bool strict, js::Value* vp) const
29727 if (attrs & 0x20) {
29728 js::Value fval = setterValue();
29729 return js::ExternalGetOrSet(cx, obj, id, fval, JSACC_WRITE, 1, vp, vp);
29733 return js_ReportGetterOnlyAssignment(cx);
29736 if (obj->getClass() == &js_WithClass)
29737 obj = js_UnwrapWithObject(cx, obj);
29738 return js::CallJSPropertyOpSetter(cx, setterOp(), obj, ((this)->hasShortID() ? INT_TO_JSID((this)->shortid) : (this)->id), strict, vp);
29742 EmptyShape::EmptyShape(JSCompartment *comp, js::Class *aclasp)
29743 : js::Shape(comp, aclasp)
29752 # 62 "jsobjinlines.h" 2
29756 # 1 "jsgcinlines.h" 1
29757 # 58 "jsgcinlines.h"
29762 const size_t SLOTS_TO_THING_KIND_LIMIT = 17;
29765 static inline FinalizeKind
29766 GetGCObjectKind(size_t numSlots)
29768 extern FinalizeKind slotsToThingKind[];
29770 if (numSlots >= SLOTS_TO_THING_KIND_LIMIT)
29771 return FINALIZE_OBJECT0;
29772 return slotsToThingKind[numSlots];
29776 static inline size_t
29777 GetGCKindSlots(FinalizeKind thingKind)
29780 switch (thingKind) {
29781 case FINALIZE_OBJECT0:
29783 case FINALIZE_OBJECT2:
29785 case FINALIZE_OBJECT4:
29787 case FINALIZE_OBJECT8:
29789 case FINALIZE_OBJECT12:
29791 case FINALIZE_OBJECT16:
29801 # 109 "jsgcinlines.h"
29802 template <typename T>
29803 __attribute__((always_inline)) inline T *
29804 NewFinalizableGCThing(JSContext *cx, unsigned thingKind)
29815 js::gc::FreeCell *cell = cx->compartment->freeLists.getNext(thingKind);
29817 CheckGCFreeListLink(cell);
29820 if (!RefillFinalizableFreeList(cx, thingKind))
29829 js_NewGCObject(JSContext *cx, js::gc::FinalizeKind kind)
29832 JSObject *obj = NewFinalizableGCThing<JSObject>(cx, kind);
29834 obj->capacity = js::gc::GetGCKindSlots(kind);
29839 js_NewGCString(JSContext *cx)
29841 return NewFinalizableGCThing<JSString>(cx, js::gc::FINALIZE_STRING);
29844 inline JSShortString *
29845 js_NewGCShortString(JSContext *cx)
29847 return NewFinalizableGCThing<JSShortString>(cx, js::gc::FINALIZE_SHORT_STRING);
29850 inline JSExternalString *
29851 js_NewGCExternalString(JSContext *cx, uintN type)
29854 JSExternalString *str = NewFinalizableGCThing<JSExternalString>(cx, js::gc::FINALIZE_EXTERNAL_STRING);
29859 js_NewGCFunction(JSContext *cx)
29861 JSFunction *fun = NewFinalizableGCThing<JSFunction>(cx, js::gc::FINALIZE_FUNCTION);
29863 fun->capacity = JSObject::FUN_CLASS_RESERVED_SLOTS;
29869 js_NewGCXML(JSContext *cx)
29871 return NewFinalizableGCThing<JSXML>(cx, js::gc::FINALIZE_XML);
29878 static __attribute__((always_inline)) inline void
29879 TypedMarker(JSTracer *trc, JSXML *thing);
29881 static __attribute__((always_inline)) inline void
29882 TypedMarker(JSTracer *trc, JSObject *thing);
29884 static __attribute__((always_inline)) inline void
29885 TypedMarker(JSTracer *trc, JSFunction *thing);
29887 static __attribute__((always_inline)) inline void
29888 TypedMarker(JSTracer *trc, JSShortString *thing);
29890 static __attribute__((always_inline)) inline void
29891 TypedMarker(JSTracer *trc, JSString *thing);
29893 template<typename T>
29894 static __attribute__((always_inline)) inline void
29895 Mark(JSTracer *trc, T *thing)
29904 JSRuntime *rt = trc->context->runtime;
29906 if (rt->gcCurrentCompartment && thing->asCell()->compartment() != rt->gcCurrentCompartment)
29909 if (!((trc)->callback == __null)) {
29910 uint32 kind = GetGCThingTraceKind(thing);
29911 trc->callback(trc, thing, kind);
29915 TypedMarker(trc, thing);
29926 MarkString(JSTracer *trc, JSString *str)
29929 if (JSString::isStatic(str))
29936 MarkString(JSTracer *trc, JSString *str, const char *name)
29940 MarkString(trc, str);
29944 MarkObject(JSTracer *trc, JSObject &obj, const char *name)
29960 MarkChildren(JSTracer *trc, JSObject *obj)
29967 if (JSObject *proto = obj->getProto())
29968 MarkObject(trc, *proto, "proto");
29969 if (JSObject *parent = obj->getParent())
29970 MarkObject(trc, *parent, "parent");
29972 if (obj->emptyShapes) {
29973 int count = FINALIZE_OBJECT_LAST - FINALIZE_OBJECT0 + 1;
29974 for (int i = 0; i < count; i++) {
29975 if (obj->emptyShapes[i])
29976 obj->emptyShapes[i]->trace(trc);
29981 TraceOp op = obj->getOps()->trace;
29982 (op ? op : js_TraceObject)(trc, obj);
29986 MarkChildren(JSTracer *trc, JSString *str)
29988 if (str->isDependent())
29989 MarkString(trc, str->dependentBase(), "base");
29990 else if (str->isRope()) {
29991 MarkString(trc, str->ropeLeft(), "left child");
29992 MarkString(trc, str->ropeRight(), "right child");
29998 MarkChildren(JSTracer *trc, JSXML *xml)
30000 js_TraceXML(trc, xml);
30006 # 311 "jsgcinlines.h"
30008 RecursionTooDeep(GCMarker *gcmarker) {
30013 return !((jsuword)(&stackDummy) > gcmarker->stackLimit);
30017 static __attribute__((always_inline)) inline void
30018 TypedMarker(JSTracer *trc, JSXML *thing)
30020 if (!reinterpret_cast<Cell *>(thing)->markIfUnmarked(reinterpret_cast<GCMarker *>(trc)->getMarkColor()))
30022 GCMarker *gcmarker = static_cast<GCMarker *>(trc);
30023 if (RecursionTooDeep(gcmarker)) {
30024 gcmarker->delayMarkingChildren(thing);
30026 MarkChildren(trc, thing);
30030 static __attribute__((always_inline)) inline void
30031 TypedMarker(JSTracer *trc, JSObject *thing)
30036 GCMarker *gcmarker = static_cast<GCMarker *>(trc);
30037 if (!thing->markIfUnmarked(gcmarker->getMarkColor()))
30040 if (RecursionTooDeep(gcmarker)) {
30041 gcmarker->delayMarkingChildren(thing);
30043 MarkChildren(trc, thing);
30047 static __attribute__((always_inline)) inline void
30048 TypedMarker(JSTracer *trc, JSFunction *thing)
30053 GCMarker *gcmarker = static_cast<GCMarker *>(trc);
30054 if (!thing->markIfUnmarked(gcmarker->getMarkColor()))
30057 if (RecursionTooDeep(gcmarker)) {
30058 gcmarker->delayMarkingChildren(thing);
30060 MarkChildren(trc, static_cast<JSObject *>(thing));
30064 static __attribute__((always_inline)) inline void
30065 TypedMarker(JSTracer *trc, JSShortString *thing)
30072 (void) thing->asCell()->markIfUnmarked();
30079 static __attribute__((always_inline)) inline JSString *
30083 return (JSString *)(size_t(str) | 1);
30086 static __attribute__((always_inline)) inline
30088 # 390 "jsgcinlines.h"
30090 Tagged(JSString *str)
30092 return (size_t(str) & 1) != 0;
30095 static __attribute__((always_inline)) inline JSString *
30096 Untag(JSString *str)
30099 return (JSString *)(size_t(str) & ~size_t(1));
30102 static __attribute__((always_inline)) inline void
30103 NonRopeTypedMarker(JSRuntime *rt, JSString *str)
30108 if (rt->gcCurrentCompartment) {
30110 if (JSString::isStatic(str))
30117 if (str->asCell()->compartment() != rt->gcCurrentCompartment) {
30121 if (!str->asCell()->markIfUnmarked())
30123 if (!str->isDependent())
30125 str = str->dependentBase();
30128 while (!JSString::isStatic(str) &&
30129 str->asCell()->markIfUnmarked() &&
30130 str->isDependent()) {
30131 str = str->dependentBase();
30140 static __attribute__((always_inline)) inline void
30141 TypedMarker(JSTracer *trc, JSString *str)
30143 using namespace detail;
30144 JSRuntime *rt = trc->context->runtime;
30149 if (!str->isRope()) {
30150 NonRopeTypedMarker(rt, str);
30160 JSString *parent = __null;
30161 first_visit_node: {
30164 if (!str->asCell()->markIfUnmarked())
30166 JSString *left = str->ropeLeft();
30167 if (left->isRope()) {
30169 str->u.left = Tag(parent);
30172 goto first_visit_node;
30177 NonRopeTypedMarker(rt, left);
30179 visit_right_child: {
30180 JSString *right = str->ropeRight();
30181 if (right->isRope()) {
30183 str->s.right = Tag(parent);
30186 goto first_visit_node;
30191 NonRopeTypedMarker(rt, right);
30196 if (Tagged(parent->u.left)) {
30198 JSString *nextParent = Untag(parent->u.left);
30199 parent->u.left = str;
30201 parent = nextParent;
30202 goto visit_right_child;
30205 JSString *nextParent = Untag(parent->s.right);
30206 parent->s.right = str;
30208 parent = nextParent;
30214 MarkAtomRange(JSTracer *trc, size_t len, JSAtom **vec, const char *name)
30216 for (uint32 i = 0; i < len; i++) {
30217 if (JSAtom *atom = vec[i]) {
30219 JSString *str = (atom);
30220 if (!JSString::isStatic(str))
30227 MarkObjectRange(JSTracer *trc, size_t len, JSObject **vec, const char *name)
30229 for (uint32 i = 0; i < len; i++) {
30230 if (JSObject *obj = vec[i]) {
30238 MarkId(JSTracer *trc, jsid id)
30240 if (JSID_IS_STRING(id)) {
30241 JSString *str = JSID_TO_STRING(id);
30242 if (!JSString::isStatic(str))
30245 else if ((__builtin_expect((JSID_IS_OBJECT(id)), 0)))
30246 Mark(trc, JSID_TO_OBJECT(id));
30250 MarkId(JSTracer *trc, jsid id, const char *name)
30257 MarkIdRange(JSTracer *trc, jsid *beg, jsid *end, const char *name)
30259 for (jsid *idp = beg; idp != end; ++idp) {
30266 MarkIdRange(JSTracer *trc, size_t len, jsid *vec, const char *name)
30268 MarkIdRange(trc, vec, vec + len, name);
30272 MarkKind(JSTracer *trc, void *thing, uint32 kind)
30278 Mark(trc, reinterpret_cast<JSObject *>(thing));
30281 MarkString(trc, reinterpret_cast<JSString *>(thing));
30285 Mark(trc, reinterpret_cast<JSXML *>(thing));
30295 MarkValueRaw(JSTracer *trc, const js::Value &v)
30297 if (v.isMarkable()) {
30299 return MarkKind(trc, v.toGCThing(), v.gcKind());
30304 MarkValue(JSTracer *trc, const js::Value &v, const char *name)
30307 MarkValueRaw(trc, v);
30311 MarkValueRange(JSTracer *trc, Value *beg, Value *end, const char *name)
30313 for (Value *vp = beg; vp < end; ++vp) {
30315 MarkValueRaw(trc, *vp);
30320 MarkValueRange(JSTracer *trc, size_t len, Value *vec, const char *name)
30322 MarkValueRange(trc, vec, vec + len, name);
30326 MarkShapeRange(JSTracer *trc, const Shape **beg, const Shape **end, const char *name)
30328 for (const Shape **sp = beg; sp < end; ++sp) {
30335 MarkShapeRange(JSTracer *trc, size_t len, const Shape **vec, const char *name)
30337 MarkShapeRange(trc, vec, vec + len, name);
30342 MarkGCThing(JSTracer *trc, void *thing, uint32 kind)
30347 MarkKind(trc, thing, kind);
30351 MarkGCThing(JSTracer *trc, void *thing)
30355 MarkKind(trc, thing, GetGCThingTraceKind(thing));
30359 MarkGCThing(JSTracer *trc, void *thing, const char *name)
30362 MarkGCThing(trc, thing);
30366 MarkGCThing(JSTracer *trc, void *thing, const char *name, size_t index)
30369 MarkGCThing(trc, thing);
30373 Mark(JSTracer *trc, void *thing, uint32 kind, const char *name)
30377 MarkKind(trc, thing, kind);
30381 # 66 "jsobjinlines.h" 2
30383 # 67 "jsobjinlines.h" 2
30387 # 68 "jsobjinlines.h"
30389 JSObject::preventExtensions(JSContext *cx, js::AutoIdVector *props)
30393 if (js::FixOp fix = getOps()->fix) {
30395 if (!fix(cx, this, &success, props))
30398 JS_ReportErrorNumber(cx, js_GetErrorMessage, __null, JSMSG_CANT_CHANGE_EXTENSIBILITY);
30402 if (!GetPropertyNames(cx, this, 0x10 | 0x8, props))
30407 extensibleShapeChange(cx);
30409 flags |= NOT_EXTENSIBLE;
30415 # 93 "jsobjinlines.h"
30417 JSObject::brand(JSContext *cx)
30422 generateOwnShape(cx);
30423 if (js_IsPropertyCacheDisabled(cx))
30431 # 106 "jsobjinlines.h"
30433 JSObject::unbrand(JSContext *cx)
30437 generateOwnShape(cx);
30438 if (js_IsPropertyCacheDisabled(cx))
30447 JSObject::syncSpecialEquality()
30449 if (clasp->ext.equality)
30450 flags |= JSObject::HAS_EQUALITY;
30454 JSObject::finalize(JSContext *cx)
30461 js::Class *clasp = getClass();
30462 if (clasp->finalize)
30463 clasp->finalize(cx, this);
30465 js::Probes::finalizeObject(this);
30474 inline const js::Shape *
30475 JSObject::methodReadBarrier(JSContext *cx, const js::Shape &shape, js::Value *vp)
30487 JSObject *funobj = &vp->toObject();
30488 JSFunction *fun = funobj->getFunctionPrivate();
30492 funobj = CloneFunctionObject(cx, fun, funobj->getParent());
30495 funobj->setMethodObj(*this);
30502 uint32 slot = shape.slot;
30503 const js::Shape *newshape = methodShapeChange(cx, shape);
30508 vp->setObject(*funobj);
30509 nativeSetSlot(slot, *vp);
30510 # 200 "jsobjinlines.h"
30514 static __attribute__((always_inline)) inline
30516 # 203 "jsobjinlines.h"
30518 ChangesMethodValue(const js::Value &prev, const js::Value &v)
30521 return prev.isObject() && (prevObj = &prev.toObject())->isFunction() &&
30522 (!v.isObject() || &v.toObject() != prevObj);
30525 inline const js::Shape *
30526 JSObject::methodWriteBarrier(JSContext *cx, const js::Shape &shape, const js::Value &v)
30528 if (brandedOrHasMethodBarrier() && shape.slot != 0xffffffff) {
30529 const js::Value &prev = nativeGetSlot(shape.slot);
30531 if (ChangesMethodValue(prev, v)) {
30533 return methodShapeChange(cx, shape);
30541 # 225 "jsobjinlines.h"
30543 JSObject::methodWriteBarrier(JSContext *cx, uint32 slot, const js::Value &v)
30545 if (brandedOrHasMethodBarrier()) {
30546 const js::Value &prev = nativeGetSlot(slot);
30548 if (ChangesMethodValue(prev, v)) {
30550 return methodShapeChange(cx, slot);
30558 # 239 "jsobjinlines.h"
30560 JSObject::ensureClassReservedSlots(JSContext *cx)
30562 return !nativeEmpty() || ensureClassReservedSlotsForEmptyObject(cx);
30566 JSObject::getReservedSlot(uintN index) const
30568 return (index < numSlots()) ? getSlot(index) : js::UndefinedValue();
30573 # 251 "jsobjinlines.h"
30575 JSObject::canHaveMethodBarrier() const
30577 return isObject() || isFunction() || isPrimitive() || isDate();
30582 # 257 "jsobjinlines.h"
30584 JSObject::isPrimitive() const
30586 return isNumber() || isString() || isBoolean();
30589 inline const js::Value &
30590 JSObject::getPrimitiveThis() const
30593 return getSlot(JSSLOT_PRIMITIVE_THIS);
30597 JSObject::setPrimitiveThis(const js::Value &pthis)
30600 setSlot(JSSLOT_PRIMITIVE_THIS, pthis);
30604 JSObject::finalizeKind() const
30606 return js::gc::FinalizeKind(arena()->header()->thingKind);
30610 JSObject::numFixedSlots() const
30613 return JSObject::FUN_CLASS_RESERVED_SLOTS;
30614 if (!hasSlotsArray())
30616 return js::gc::GetGCKindSlots(js::gc::FinalizeKind(finalizeKind()));
30620 JSObject::slotsAndStructSize(uint32 nslots) const
30622 bool isFun = isFunction() && this == (JSObject*) getPrivate();
30624 int ndslots = hasSlotsArray() ? nslots : 0;
30625 int nfslots = isFun ? 0 : numFixedSlots();
30627 return sizeof(js::Value) * (ndslots + nfslots)
30628 + isFun ? sizeof(JSFunction) : sizeof(JSObject);
30632 JSObject::getArrayLength() const
30635 return (uint32)(size_t) getPrivate();
30639 JSObject::setArrayLength(uint32 length)
30642 setPrivate((void*) length);
30646 JSObject::getDenseArrayCapacity()
30653 JSObject::getDenseArrayElements()
30659 inline const js::Value &
30660 JSObject::getDenseArrayElement(uintN idx)
30663 return getSlot(idx);
30667 JSObject::addressOfDenseArrayElement(uintN idx)
30670 return &getSlotRef(idx);
30674 JSObject::setDenseArrayElement(uintN idx, const js::Value &val)
30681 JSObject::shrinkDenseArrayElements(JSContext *cx, uintN cap)
30684 shrinkSlots(cx, cap);
30688 JSObject::setArgsLength(uint32 argc)
30693 getSlotRef(JSSLOT_ARGS_LENGTH).setInt32(argc << ARGS_PACKED_BITS_COUNT);
30698 JSObject::getArgsInitialLength() const
30701 uint32 argc = uint32(getSlot(JSSLOT_ARGS_LENGTH).toInt32()) >> ARGS_PACKED_BITS_COUNT;
30707 JSObject::setArgsLengthOverridden()
30710 getSlotRef(JSSLOT_ARGS_LENGTH).getInt32Ref() |= ARGS_LENGTH_OVERRIDDEN_BIT;
30715 # 387 "jsobjinlines.h"
30717 JSObject::isArgsLengthOverridden() const
30720 const js::Value &v = getSlot(JSSLOT_ARGS_LENGTH);
30721 return v.toInt32() & ARGS_LENGTH_OVERRIDDEN_BIT;
30724 inline js::ArgumentsData *
30725 JSObject::getArgsData() const
30728 return (js::ArgumentsData *) getSlot(JSSLOT_ARGS_DATA).toPrivate();
30732 JSObject::setArgsData(js::ArgumentsData *data)
30735 getSlotRef(JSSLOT_ARGS_DATA).setPrivate(data);
30738 inline const js::Value &
30739 JSObject::getArgsCallee() const
30741 return getArgsData()->callee;
30745 JSObject::setArgsCallee(const js::Value &callee)
30747 getArgsData()->callee = callee;
30750 inline const js::Value &
30751 JSObject::getArgsElement(uint32 i) const
30755 return getArgsData()->slots[i];
30759 JSObject::getArgsElements() const
30762 return getArgsData()->slots;
30766 JSObject::addressOfArgsElement(uint32 i)
30770 return &getArgsData()->slots[i];
30774 JSObject::setArgsElement(uint32 i, const js::Value &v)
30778 getArgsData()->slots[i] = v;
30783 # 452 "jsobjinlines.h"
30785 JSObject::callIsForEval() const
30791 return getSlot(JSSLOT_CALL_CALLEE).isNull();
30794 inline JSStackFrame *
30795 JSObject::maybeCallObjStackFrame() const
30798 return reinterpret_cast<JSStackFrame *>(getPrivate());
30802 JSObject::setCallObjCallee(JSObject *callee)
30806 return getSlotRef(JSSLOT_CALL_CALLEE).setObjectOrNull(callee);
30810 JSObject::getCallObjCallee() const
30813 return getSlot(JSSLOT_CALL_CALLEE).toObjectOrNull();
30816 inline JSFunction *
30817 JSObject::getCallObjCalleeFunction() const
30820 return getSlot(JSSLOT_CALL_CALLEE).toObject().getFunctionPrivate();
30823 inline const js::Value &
30824 JSObject::getCallObjArguments() const
30828 return getSlot(JSSLOT_CALL_ARGUMENTS);
30832 JSObject::setCallObjArguments(const js::Value &v)
30836 setSlot(JSSLOT_CALL_ARGUMENTS, v);
30839 inline const js::Value &
30840 JSObject::callObjArg(uintN i) const
30844 return getSlot(JSObject::CALL_RESERVED_SLOTS + i);
30848 JSObject::callObjArg(uintN i)
30852 return getSlotRef(JSObject::CALL_RESERVED_SLOTS + i);
30855 inline const js::Value &
30856 JSObject::callObjVar(uintN i) const
30858 JSFunction *fun = getCallObjCalleeFunction();
30861 return getSlot(JSObject::CALL_RESERVED_SLOTS + fun->nargs + i);
30865 JSObject::callObjVar(uintN i)
30867 JSFunction *fun = getCallObjCalleeFunction();
30870 return getSlotRef(JSObject::CALL_RESERVED_SLOTS + fun->nargs + i);
30873 inline const js::Value &
30874 JSObject::getDateUTCTime() const
30877 return getSlot(JSSLOT_DATE_UTC_TIME);
30881 JSObject::setDateUTCTime(const js::Value &time)
30884 setSlot(JSSLOT_DATE_UTC_TIME, time);
30888 JSObject::getFlatClosureUpvars() const
30895 return (js::Value *) getSlot(JSSLOT_FLAT_CLOSURE_UPVARS).toPrivate();
30899 JSObject::getFlatClosureUpvar(uint32 i) const
30902 return getFlatClosureUpvars()[i];
30906 JSObject::getFlatClosureUpvar(uint32 i)
30909 return getFlatClosureUpvars()[i];
30913 JSObject::setFlatClosureUpvars(js::Value *upvars)
30917 getSlotRef(JSSLOT_FLAT_CLOSURE_UPVARS).setPrivate(upvars);
30922 # 588 "jsobjinlines.h"
30924 JSObject::hasMethodObj(const JSObject& obj) const
30926 return JSSLOT_FUN_METHOD_OBJ < numSlots() &&
30927 getSlot(JSSLOT_FUN_METHOD_OBJ).isObject() &&
30928 &getSlot(JSSLOT_FUN_METHOD_OBJ).toObject() == &obj;
30932 JSObject::setMethodObj(JSObject& obj)
30934 getSlotRef(JSSLOT_FUN_METHOD_OBJ).setObject(obj);
30937 inline js::NativeIterator *
30938 JSObject::getNativeIterator() const
30940 return (js::NativeIterator *) getPrivate();
30944 JSObject::setNativeIterator(js::NativeIterator *ni)
30949 inline JSLinearString *
30950 JSObject::getNamePrefix() const
30953 const js::Value &v = getSlot(JSSLOT_NAME_PREFIX);
30954 return !v.isUndefined() ? v.toString()->assertIsLinear() : __null;
30958 JSObject::getNamePrefixVal() const
30961 return js::Jsvalify(getSlot(JSSLOT_NAME_PREFIX));
30965 JSObject::setNamePrefix(JSLinearString *prefix)
30968 setSlot(JSSLOT_NAME_PREFIX, prefix ? js::StringValue(prefix) : js::UndefinedValue());
30972 JSObject::clearNamePrefix()
30975 setSlot(JSSLOT_NAME_PREFIX, js::UndefinedValue());
30978 inline JSLinearString *
30979 JSObject::getNameURI() const
30982 const js::Value &v = getSlot(JSSLOT_NAME_URI);
30983 return !v.isUndefined() ? v.toString()->assertIsLinear() : __null;
30987 JSObject::getNameURIVal() const
30990 return js::Jsvalify(getSlot(JSSLOT_NAME_URI));
30994 JSObject::setNameURI(JSLinearString *uri)
30997 setSlot(JSSLOT_NAME_URI, uri ? js::StringValue(uri) : js::UndefinedValue());
31001 JSObject::getNamespaceDeclared() const
31004 return js::Jsvalify(getSlot(JSSLOT_NAMESPACE_DECLARED));
31008 JSObject::setNamespaceDeclared(jsval decl)
31011 setSlot(JSSLOT_NAMESPACE_DECLARED, js::Valueify(decl));
31014 inline JSLinearString *
31015 JSObject::getQNameLocalName() const
31018 const js::Value &v = getSlot(JSSLOT_QNAME_LOCAL_NAME);
31019 return !v.isUndefined() ? v.toString()->assertIsLinear() : __null;
31023 JSObject::getQNameLocalNameVal() const
31026 return js::Jsvalify(getSlot(JSSLOT_QNAME_LOCAL_NAME));
31030 JSObject::setQNameLocalName(JSLinearString *name)
31033 setSlot(JSSLOT_QNAME_LOCAL_NAME, name ? js::StringValue(name) : js::UndefinedValue());
31037 JSObject::getWithThis() const
31039 return &getSlot(JSSLOT_WITH_THIS).toObject();
31043 JSObject::setWithThis(JSObject *thisp)
31045 getSlotRef(JSSLOT_WITH_THIS).setObject(*thisp);
31049 JSObject::init(JSContext *cx, js::Class *aclasp, JSObject *proto, JSObject *parent,
31050 void *priv, bool useHoles)
31054 # 731 "jsobjinlines.h"
31058 privateData = priv;
31059 slots = fixedSlots();
31066 ClearValueRange(slots, capacity, useHoles);
31068 emptyShapes = __null;
31072 JSObject::finish(JSContext *cx)
31078 if (hasSlotsArray())
31079 freeSlotsArray(cx);
31081 cx->free(emptyShapes);
31086 # 760 "jsobjinlines.h"
31088 JSObject::initSharingEmptyShape(JSContext *cx,
31092 void *privateValue,
31095 init(cx, aclasp, proto, parent, privateValue, false);
31099 js::EmptyShape *empty = proto->getEmptyShape(cx, aclasp, kind);
31108 JSObject::freeSlotsArray(JSContext *cx)
31115 JSObject::revertToFixedSlots(JSContext *cx)
31118 size_t fixed = numFixedSlots();
31120 memcpy(fixedSlots(), slots, fixed * sizeof(js::Value));
31121 freeSlotsArray(cx);
31122 slots = fixedSlots();
31128 # 799 "jsobjinlines.h"
31130 JSObject::hasProperty(JSContext *cx, jsid id, bool *foundp, uintN flags)
31134 JSAutoResolveFlags rf(cx, flags);
31135 if (!lookupProperty(cx, id, &pobj, &prop))
31143 # 811 "jsobjinlines.h"
31145 JSObject::isCallable()
31147 return isFunction() || getClass()->call;
31152 # 817 "jsobjinlines.h"
31154 js_IsCallable(const js::Value &v)
31156 return v.isObject() && v.toObject().isCallable();
31161 class AutoPropDescArrayRooter : private AutoGCRooter
31164 AutoPropDescArrayRooter(JSContext *cx)
31165 : AutoGCRooter(cx, DESCRIPTORS), descriptors(cx)
31168 PropDesc *append() {
31169 if (!descriptors.append(PropDesc()))
31171 return &descriptors.back();
31174 PropDesc& operator[](size_t i) {
31176 return descriptors[i];
31179 friend void AutoGCRooter::trace(JSTracer *trc);
31182 PropDescArray descriptors;
31185 class AutoPropertyDescriptorRooter : private AutoGCRooter, public PropertyDescriptor
31188 AutoPropertyDescriptorRooter(JSContext *cx) : AutoGCRooter(cx, DESCRIPTOR) {
31191 getter = (PropertyOp) __null;
31192 setter = (StrictPropertyOp) __null;
31193 value.setUndefined();
31196 AutoPropertyDescriptorRooter(JSContext *cx, PropertyDescriptor *desc)
31197 : AutoGCRooter(cx, DESCRIPTOR)
31200 attrs = desc->attrs;
31201 getter = desc->getter;
31202 setter = desc->setter;
31203 value = desc->value;
31206 friend void AutoGCRooter::trace(JSTracer *trc);
31211 # 873 "jsobjinlines.h"
31213 InitScopeForObject(JSContext* cx, JSObject* obj, js::Class *clasp, JSObject* proto,
31214 gc::FinalizeKind kind)
31220 js::EmptyShape *empty = __null;
31223 if (proto->canProvideEmptyShape(clasp)) {
31224 empty = proto->getEmptyShape(cx, clasp, kind);
31231 empty = js::EmptyShape::create(cx, clasp);
31234 uint32 freeslot = (((clasp)->flags >> 8) & (((JSUint32)1 << (8)) - 1));
31235 if (freeslot > obj->numSlots() && !obj->allocSlots(cx, freeslot))
31239 obj->setMap(empty);
31254 static inline JSObject *
31255 NewNativeClassInstance(JSContext *cx, Class *clasp, JSObject *proto,
31256 JSObject *parent, gc::FinalizeKind kind)
31265 JSObject* obj = js_NewGCObject(cx, kind);
31272 bool useHoles = (clasp == &js_ArrayClass);
31273 obj->init(cx, clasp, proto, parent, __null, useHoles);
31276 js::EmptyShape *empty = proto->getEmptyShape(cx, clasp, kind);
31279 obj->setMap(empty);
31287 static inline JSObject *
31288 NewNativeClassInstance(JSContext *cx, Class *clasp, JSObject *proto, JSObject *parent)
31290 gc::FinalizeKind kind = gc::GetGCObjectKind((((clasp)->flags >> 8) & (((JSUint32)1 << (8)) - 1)));
31291 return NewNativeClassInstance(cx, clasp, proto, parent, kind);
31296 # 956 "jsobjinlines.h"
31297 FindClassPrototype(JSContext *cx, JSObject *scope, JSProtoKey protoKey, JSObject **protop,
31306 static inline JSObject *
31307 NewBuiltinClassInstance(JSContext *cx, Class *clasp, gc::FinalizeKind kind)
31311 JSProtoKey protoKey = ((JSProtoKey) (((clasp)->flags >> ((8 + 8) + 8)) & (((JSUint32)1 << (8)) - 1)));
31316 if (!cx->hasfp()) {
31317 global = cx->globalObject;
31318 OBJ_TO_INNER_OBJECT(cx, global);
31322 global = cx->fp()->scopeChain().getGlobal();
31326 const Value &v = global->getReservedSlot(JSProto_LIMIT + protoKey);
31328 if (v.isObject()) {
31329 proto = &v.toObject();
31332 if (!FindClassPrototype(cx, global, protoKey, &proto, clasp))
31336 return NewNativeClassInstance(cx, clasp, proto, global, kind);
31339 static inline JSObject *
31340 NewBuiltinClassInstance(JSContext *cx, Class *clasp)
31342 gc::FinalizeKind kind = gc::GetGCObjectKind((((clasp)->flags >> 8) & (((JSUint32)1 << (8)) - 1)));
31343 return NewBuiltinClassInstance(cx, clasp, kind);
31346 static inline JSProtoKey
31347 GetClassProtoKey(js::Class *clasp)
31349 JSProtoKey key = ((JSProtoKey) (((clasp)->flags >> ((8 + 8) + 8)) & (((JSUint32)1 << (8)) - 1)));
31350 if (key != JSProto_Null)
31352 if (clasp->flags & (1<<((8 + 8)+1)))
31353 return JSProto_Object;
31354 return JSProto_Null;
31357 namespace WithProto {
31363 # 1049 "jsobjinlines.h"
31364 static __attribute__((always_inline)) inline
31366 # 1049 "jsobjinlines.h"
31368 FindProto(JSContext *cx, js::Class *clasp, JSObject *parent, JSObject ** proto)
31370 JSProtoKey protoKey = GetClassProtoKey(clasp);
31371 if (!js_GetClassPrototype(cx, parent, protoKey, proto, clasp))
31373 if (!(*proto) && !js_GetClassPrototype(cx, parent, JSProto_Object, proto))
31381 template <bool withProto, bool isFunction>
31382 static __attribute__((always_inline)) inline JSObject *
31383 NewObject(JSContext *cx, js::Class *clasp, JSObject *proto, JSObject *parent,
31384 gc::FinalizeKind kind)
31387 if (withProto == WithProto::Class && !proto) {
31388 if (!FindProto(cx, clasp, parent, &proto))
31391 # 1081 "jsobjinlines.h"
31392 JSObject* obj = isFunction ? js_NewGCFunction(cx) : js_NewGCObject(cx, kind);
31403 obj->init(cx, clasp, proto,
31404 (!parent && proto) ? proto->getParent() : parent,
31405 __null, clasp == &js_ArrayClass);
31407 if (clasp->isNative()) {
31408 if (!InitScopeForObject(cx, obj, clasp, proto, kind)) {
31413 obj->setSharedNonNativeMap();
31417 Probes::createObject(cx, obj);
31422 static __attribute__((always_inline)) inline JSObject *
31423 NewFunction(JSContext *cx, JSObject *parent)
31425 return detail::NewObject<WithProto::Class, true>(cx, &js_FunctionClass, __null, parent,
31426 gc::FINALIZE_OBJECT2);
31429 template <WithProto::e withProto>
31430 static __attribute__((always_inline)) inline JSObject *
31431 NewNonFunction(JSContext *cx, js::Class *clasp, JSObject *proto, JSObject *parent,
31432 gc::FinalizeKind kind)
31434 return detail::NewObject<withProto, false>(cx, clasp, proto, parent, kind);
31437 template <WithProto::e withProto>
31438 static __attribute__((always_inline)) inline JSObject *
31439 NewNonFunction(JSContext *cx, js::Class *clasp, JSObject *proto, JSObject *parent)
31441 gc::FinalizeKind kind = gc::GetGCObjectKind((((clasp)->flags >> 8) & (((JSUint32)1 << (8)) - 1)));
31442 return detail::NewObject<withProto, false>(cx, clasp, proto, parent, kind);
31445 template <WithProto::e withProto>
31446 static __attribute__((always_inline)) inline JSObject *
31447 NewObject(JSContext *cx, js::Class *clasp, JSObject *proto, JSObject *parent,
31448 gc::FinalizeKind kind)
31450 if (clasp == &js_FunctionClass)
31451 return detail::NewObject<withProto, true>(cx, clasp, proto, parent, kind);
31452 return detail::NewObject<withProto, false>(cx, clasp, proto, parent, kind);
31455 template <WithProto::e withProto>
31456 static __attribute__((always_inline)) inline JSObject *
31457 NewObject(JSContext *cx, js::Class *clasp, JSObject *proto, JSObject *parent)
31459 gc::FinalizeKind kind = gc::GetGCObjectKind((((clasp)->flags >> 8) & (((JSUint32)1 << (8)) - 1)));
31460 return NewObject<withProto>(cx, clasp, proto, parent, kind);
31467 static inline gc::FinalizeKind
31468 GuessObjectGCKind(size_t numSlots, bool isArray)
31471 return gc::GetGCObjectKind(numSlots);
31472 return isArray ? gc::FINALIZE_OBJECT8 : gc::FINALIZE_OBJECT4;
31479 static inline gc::FinalizeKind
31480 NewObjectGCKind(JSContext *cx, js::Class *clasp)
31482 if (clasp == &js_ArrayClass || clasp == &js_SlowArrayClass)
31483 return gc::FINALIZE_OBJECT8;
31484 if (clasp == &js_FunctionClass)
31485 return gc::FINALIZE_OBJECT2;
31486 return gc::FINALIZE_OBJECT4;
31490 static inline JSObject *
31491 CopyInitializerObject(JSContext *cx, JSObject *baseobj)
31496 gc::FinalizeKind kind = gc::FinalizeKind(baseobj->finalizeKind());
31497 JSObject *obj = NewBuiltinClassInstance(cx, &js_ObjectClass, kind);
31499 if (!obj || !obj->ensureSlots(cx, baseobj->numSlots()))
31502 obj->flags = baseobj->flags;
31503 obj->lastProp = baseobj->lastProp;
31504 obj->objShape = baseobj->objShape;
31508 # 1206 "jsobjinlines.h"
31509 static __attribute__((always_inline)) inline
31511 # 1206 "jsobjinlines.h"
31513 ClassMethodIsNative(JSContext *cx, JSObject *obj, Class *clasp, jsid methodid,
31518 if (HasNativeMethod(obj, methodid, native))
31521 JSObject *pobj = obj->getProto();
31522 return pobj && pobj->getClass() == clasp &&
31523 HasNativeMethod(pobj, methodid, native);
31534 using namespace js;
31535 using namespace js::gc;
31541 js_EnterLocalRootScope(JSContext *cx)
31547 js_LeaveLocalRootScope(JSContext *cx)
31552 js_LeaveLocalRootScopeWithResult(JSContext *cx, jsval rval)
31557 js_LeaveLocalRootScopeWithResult(JSContext *cx, Value rval)
31562 js_LeaveLocalRootScopeWithResult(JSContext *cx, void *rval)
31566 const char js_AttributeName_str[] = "AttributeName";
31567 const char js_isXMLName_str[] = "isXMLName";
31568 const char js_XMLList_str[] = "XMLList";
31569 const char js_localName_str[] = "localName";
31570 const char js_xml_parent_str[] = "parent";
31571 const char js_prefix_str[] = "prefix";
31572 const char js_toXMLString_str[] = "toXMLString";
31573 const char js_uri_str[] = "uri";
31575 const char js_amp_entity_str[] = "&";
31576 const char js_gt_entity_str[] = ">";
31577 const char js_lt_entity_str[] = "<";
31578 const char js_quot_entity_str[] = """;
31579 const char js_leftcurly_entity_str[] = "{";
31584 GetXMLFunction(JSContext *cx, JSObject *obj, jsid id, jsval *vp);
31587 IsDeclared(const JSObject *obj)
31592 v = obj->getNamespaceDeclared();
31594 return v == ((((uint64)(uint32)(JSVAL_TAG_BOOLEAN)) << 47) | ((JSIntn)1));
31598 xml_isXMLName(JSContext *cx, uintN argc, jsval *vp)
31600 *vp = BOOLEAN_TO_JSVAL(js_IsXMLName(cx, argc ? vp[2] : ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0))));
31609 static inline JSObject *
31610 NewBuiltinClassInstanceXML(JSContext *cx, Class *clasp)
31612 JSObject *obj = NewBuiltinClassInstance(cx, clasp);
31614 obj->syncSpecialEquality();
31618 static JSBool NamePrefix_getter(JSContext *cx, JSObject *obj, jsid id, jsval *vp) { if (obj->getClass() == &js_NamespaceClass) *vp = obj->getNamePrefixVal(); return true; }
31620 static JSBool NameURI_getter(JSContext *cx, JSObject *obj, jsid id, jsval *vp) { if (obj->getClass() == &js_NamespaceClass) *vp = obj->getNameURIVal(); return true; }
31624 namespace_equality(JSContext *cx, JSObject *obj, const Value *v, JSBool *bp)
31629 obj2 = v->toObjectOrNull();
31630 *bp = (!obj2 || obj2->getClass() != &js_NamespaceClass)
31632 : EqualStrings(obj->getNameURI(), obj2->getNameURI());
31636 __attribute__((visibility ("default"))) Class js_NamespaceClass = {
31639 (((JSObject::NAMESPACE_CLASS_RESERVED_SLOTS) & (((JSUint32)1 << (8)) - 1)) << 8) |
31640 (1<<((8 + 8)+3)) | ((JSProto_Namespace) << ((8 + 8) + 8)),
31644 StrictPropertyStub,
31657 namespace_equality,
31668 static JSPropertySpec namespace_props[] = {
31669 {js_prefix_str, 0, (0x01 | 0x02 | 0x04 | 0x40), NamePrefix_getter, 0},
31670 {js_uri_str, 0, (0x01 | 0x02 | 0x04 | 0x40), NameURI_getter, 0},
31675 namespace_toString(JSContext *cx, uintN argc, Value *vp)
31677 JSObject *obj = ToObject(cx, &vp[1]);
31680 if (!JS_InstanceOf(cx, obj, Jsvalify(&js_NamespaceClass), Jsvalify(vp + 2)))
31682 *vp = Valueify(obj->getNameURIVal());
31686 static JSFunctionSpec namespace_methods[] = {
31687 {js_toString_str, ((JSNative)(namespace_toString)), 0, (0) | 0x1000},
31688 {__null, __null, 0, 0}
31692 NewXMLNamespace(JSContext *cx, JSLinearString *prefix, JSLinearString *uri, JSBool declared)
31696 obj = NewBuiltinClassInstanceXML(cx, &js_NamespaceClass);
31703 obj->setNamePrefix(prefix);
31705 obj->setNameURI(uri);
31707 obj->setNamespaceDeclared(((((uint64)(uint32)(JSVAL_TAG_BOOLEAN)) << 47) | ((JSIntn)1)));
31715 static JSBool QNameNameURI_getter(JSContext *cx, JSObject *obj, jsid id, jsval *vp) { if (obj->getClass() == &js_QNameClass) *vp = JSVAL_IS_VOID(obj->getNameURIVal()) ? ((((uint64)(uint32)(JSVAL_TAG_NULL)) << 47) | (0)) : obj->getNameURIVal(); return true; }
31718 static JSBool QNameLocalName_getter(JSContext *cx, JSObject *obj, jsid id, jsval *vp) { if (obj->getClass() == &js_QNameClass) *vp = obj->getQNameLocalNameVal(); return true; }
31723 qname_identity(JSObject *qna, JSObject *qnb)
31725 JSLinearString *uri1 = qna->getNameURI();
31726 JSLinearString *uri2 = qnb->getNameURI();
31730 if (uri1 && !EqualStrings(uri1, uri2))
31732 return EqualStrings(qna->getQNameLocalName(), qnb->getQNameLocalName());
31736 qname_equality(JSContext *cx, JSObject *qn, const Value *v, JSBool *bp)
31740 obj2 = v->toObjectOrNull();
31741 *bp = (!obj2 || obj2->getClass() != &js_QNameClass)
31743 : qname_identity(qn, obj2);
31747 __attribute__((visibility ("default"))) Class js_QNameClass = {
31750 (((JSObject::QNAME_CLASS_RESERVED_SLOTS) & (((JSUint32)1 << (8)) - 1)) << 8) |
31751 (1<<((8 + 8)+3)) | ((JSProto_QName) << ((8 + 8) + 8)),
31755 StrictPropertyStub,
31782 __attribute__((visibility ("default"))) Class js_AttributeNameClass = {
31783 js_AttributeName_str,
31785 (((JSObject::QNAME_CLASS_RESERVED_SLOTS) & (((JSUint32)1 << (8)) - 1)) << 8) |
31786 (1<<((8 + 8)+3)) | (1<<((8 + 8)+1)),
31790 StrictPropertyStub,
31797 __attribute__((visibility ("default"))) Class js_AnyNameClass = {
31800 (((JSObject::QNAME_CLASS_RESERVED_SLOTS) & (((JSUint32)1 << (8)) - 1)) << 8) |
31801 (1<<((8 + 8)+3)) | (1<<((8 + 8)+1)),
31805 StrictPropertyStub,
31814 static JSPropertySpec qname_props[] = {
31815 {js_uri_str, 0, (0x01 | 0x02 | 0x04 | 0x40), QNameNameURI_getter, 0},
31816 {js_localName_str, 0, (0x01 | 0x02 | 0x04 | 0x40), QNameLocalName_getter, 0},
31821 ConvertQNameToString(JSContext *cx, JSObject *obj)
31824 JSString *uri = obj->getNameURI();
31828 str = (cx->runtime->atomState.starQualifierAtom);
31829 } else if (uri->empty()) {
31831 str = cx->runtime->emptyString;
31833 JSString *qualstr = (cx->runtime->atomState.qualifierAtom);
31834 str = js_ConcatStrings(cx, uri, qualstr);
31838 str = js_ConcatStrings(cx, str, obj->getQNameLocalName());
31842 if (obj->getClass() == &js_AttributeNameClass) {
31843 JS::Anchor<JSString *> anchor(str);
31844 size_t length = str->length();
31845 jschar *chars = (jschar *) cx->malloc((length + 2) * sizeof(jschar));
31849 const jschar *strChars = str->getChars(cx);
31854 memcpy((chars + 1), (strChars), (length) * sizeof(jschar));
31855 chars[++length] = 0;
31856 str = js_NewString(cx, chars, length);
31866 qname_toString(JSContext *cx, uintN argc, Value *vp)
31868 JSObject *obj = ToObject(cx, &vp[1]);
31872 if (!InstanceOf(cx, obj, &js_QNameClass, vp + 2))
31875 JSString *str = ConvertQNameToString(cx, obj);
31879 vp->setString(str);
31883 static JSFunctionSpec qname_methods[] = {
31884 {js_toString_str, ((JSNative)(qname_toString)), 0, (0) | 0x1000},
31885 {__null, __null, 0, 0}
31890 InitXMLQName(JSObject *obj, JSLinearString *uri, JSLinearString *prefix,
31891 JSLinearString *localName)
31898 obj->setNameURI(uri);
31900 obj->setNamePrefix(prefix);
31902 obj->setQNameLocalName(localName);
31906 NewXMLQName(JSContext *cx, JSLinearString *uri, JSLinearString *prefix,
31907 JSLinearString *localName)
31909 JSObject *obj = NewBuiltinClassInstanceXML(cx, &js_QNameClass);
31912 InitXMLQName(obj, uri, prefix, localName);
31918 NewXMLAttributeName(JSContext *cx, JSLinearString *uri, JSLinearString *prefix,
31919 JSLinearString *localName)
31925 JSObject *obj = NewNonFunction<WithProto::Given>(cx, &js_AttributeNameClass, __null, __null);
31929 InitXMLQName(obj, uri, prefix, localName);
31935 js_ConstructXMLQNameObject(JSContext *cx, const Value &nsval, const Value &lnval)
31944 if (nsval.isObject() &&
31945 nsval.toObject().getClass() == &js_AnyNameClass) {
31951 return js_ConstructObject(cx, &js_QNameClass, __null, __null, 2, argv);
31955 IsXMLName(const jschar *cp, size_t n)
31961 if (n != 0 && (((js_A[js_Y[(js_X[(uint16)(*cp)>>6]<<6)|((*cp)&0x3F)]]) & 0x00000100) || (*cp) == '_')) {
31964 if (!(((js_A[js_Y[(js_X[(uint16)(c)>>6]<<6)|((c)&0x3F)]]) & 0x00000080) || (c) == '.' || (c) == '-' || (c) == '_'))
31973 js_IsXMLName(JSContext *cx, jsval v)
31975 JSLinearString *name = __null;
31976 JSErrorReporter older;
31984 if (!JSVAL_IS_PRIMITIVE(v) &&
31985 JSVAL_TO_OBJECT(v)->isQName()) {
31986 name = JSVAL_TO_OBJECT(v)->getQNameLocalName();
31988 older = JS_SetErrorReporter(cx, __null);
31989 JSString *str = js_ValueToString(cx, Valueify(v));
31991 name = str->ensureLinear(cx);
31992 JS_SetErrorReporter(cx, older);
31994 JS_ClearPendingException(cx);
31999 return IsXMLName(name->chars(), name->length());
32007 NamespaceHelper(JSContext *cx, JSObject *obj, intN argc, jsval *argv,
32010 jsval urival, prefixval;
32012 JSBool isNamespace, isQName;
32014 JSLinearString *empty, *prefix, *uri;
32016 isNamespace = isQName = (JSIntn)0;
32021 urival = ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0));
32023 urival = argv[argc > 1];
32024 if (!JSVAL_IS_PRIMITIVE(urival)) {
32025 uriobj = JSVAL_TO_OBJECT(urival);
32026 clasp = uriobj->getClass();
32027 isNamespace = (clasp == &js_NamespaceClass);
32028 isQName = (clasp == &js_QNameClass);
32034 if (argc == 1 && isNamespace) {
32040 obj = NewBuiltinClassInstanceXML(cx, &js_NamespaceClass);
32044 *rval = OBJECT_TO_JSVAL(obj);
32047 empty = cx->runtime->emptyString;
32048 obj->setNamePrefix(empty);
32049 obj->setNameURI(empty);
32051 if (argc == 1 || argc == -1) {
32053 obj->setNameURI(uriobj->getNameURI());
32054 obj->setNamePrefix(uriobj->getNamePrefix());
32055 } else if (isQName && (uri = uriobj->getNameURI())) {
32056 obj->setNameURI(uri);
32057 obj->setNamePrefix(uriobj->getNamePrefix());
32059 JSString *str = js_ValueToString(cx, Valueify(urival));
32062 uri = str->ensureLinear(cx);
32065 obj->setNameURI(uri);
32067 obj->clearNamePrefix();
32069 } else if (argc == 2) {
32070 if (!isQName || !(uri = uriobj->getNameURI())) {
32071 JSString *str = js_ValueToString(cx, Valueify(urival));
32074 uri = str->ensureLinear(cx);
32078 obj->setNameURI(uri);
32080 prefixval = argv[0];
32081 if (uri->empty()) {
32082 if (!JSVAL_IS_VOID(prefixval)) {
32083 JSString *str = js_ValueToString(cx, Valueify(prefixval));
32086 if (!str->empty()) {
32087 JSAutoByteString bytes;
32088 if (js_ValueToPrintable(cx, StringValue(str), &bytes)) {
32089 JS_ReportErrorNumber(cx, js_GetErrorMessage, __null,
32090 JSMSG_BAD_XML_NAMESPACE, bytes.ptr());
32095 } else if (JSVAL_IS_VOID(prefixval) || !js_IsXMLName(cx, prefixval)) {
32096 obj->clearNamePrefix();
32098 JSString *str = js_ValueToString(cx, Valueify(prefixval));
32101 prefix = str->ensureLinear(cx);
32104 obj->setNamePrefix(prefix);
32111 Namespace(JSContext *cx, uintN argc, Value *vp)
32113 JSObject *thisobj = __null;
32114 (void)IsConstructing_PossiblyWithGivenThisObject(vp, &thisobj);
32115 return NamespaceHelper(cx, thisobj, argc, Jsvalify(vp + 2), Jsvalify(vp));
32123 QNameHelper(JSContext *cx, JSObject *obj, intN argc, jsval *argv, jsval *rval)
32125 jsval nameval, nsval;
32126 JSBool isQName, isNamespace;
32128 JSLinearString *uri, *prefix, *name;
32132 nameval = ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0));
32133 isQName = (JSIntn)0;
32135 nameval = argv[argc > 1];
32137 !JSVAL_IS_PRIMITIVE(nameval) &&
32138 JSVAL_TO_OBJECT(nameval)->getClass() == &js_QNameClass;
32143 if (argc == 1 && isQName) {
32150 obj = NewBuiltinClassInstanceXML(cx, &js_QNameClass);
32154 *rval = OBJECT_TO_JSVAL(obj);
32159 qn = JSVAL_TO_OBJECT(nameval);
32161 uri = qn->getNameURI();
32162 prefix = qn->getNamePrefix();
32163 name = qn->getQNameLocalName();
32168 nameval = qn->getQNameLocalNameVal();
32172 name = cx->runtime->emptyString;
32173 } else if (argc < 0) {
32174 name = (cx->runtime->atomState.typeAtoms[JSTYPE_VOID]);
32176 JSString *str = js_ValueToString(cx, Valueify(nameval));
32179 name = str->ensureLinear(cx);
32182 argv[argc > 1] = STRING_TO_JSVAL(name);
32185 if (argc > 1 && !JSVAL_IS_VOID(argv[0])) {
32187 } else if (((name)->length() == 1 && *(name)->chars() == '*')) {
32188 nsval = ((((uint64)(uint32)(JSVAL_TAG_NULL)) << 47) | (0));
32190 if (!js_GetDefaultXMLNamespace(cx, &nsval))
32197 if (JSVAL_IS_NULL(nsval)) {
32199 prefix = uri = __null;
32208 isNamespace = isQName = (JSIntn)0;
32209 if (!JSVAL_IS_PRIMITIVE(nsval)) {
32210 obj2 = JSVAL_TO_OBJECT(nsval);
32211 isNamespace = (obj2->getClass() == &js_NamespaceClass);
32212 isQName = (obj2->getClass() == &js_QNameClass);
32215 else obj2 = __null;
32219 uri = obj2->getNameURI();
32220 prefix = obj2->getNamePrefix();
32221 } else if (isQName && (uri = obj2->getNameURI())) {
32223 prefix = obj2->getNamePrefix();
32226 JSString *str = js_ValueToString(cx, Valueify(nsval));
32229 uri = str->ensureLinear(cx);
32232 argv[0] = STRING_TO_JSVAL(uri);
32235 prefix = uri->empty() ? cx->runtime->emptyString : __null;
32240 InitXMLQName(obj, uri, prefix, name);
32245 QName(JSContext *cx, uintN argc, Value *vp)
32247 JSObject *thisobj = __null;
32248 (void)IsConstructing_PossiblyWithGivenThisObject(vp, &thisobj);
32249 return QNameHelper(cx, thisobj, argc, Jsvalify(vp + 2), Jsvalify(vp));
32256 namespace_identity(const void *a, const void *b)
32258 const JSObject *nsa = (const JSObject *) a;
32259 const JSObject *nsb = (const JSObject *) b;
32260 JSLinearString *prefixa = nsa->getNamePrefix();
32261 JSLinearString *prefixb = nsb->getNamePrefix();
32263 if (prefixa && prefixb) {
32264 if (!EqualStrings(prefixa, prefixb))
32267 if (prefixa || prefixb)
32270 return EqualStrings(nsa->getNameURI(), nsb->getNameURI());
32274 attr_identity(const void *a, const void *b)
32276 const JSXML *xmla = (const JSXML *) a;
32277 const JSXML *xmlb = (const JSXML *) b;
32279 return qname_identity(xmla->name, xmlb->name);
32283 JSXMLArrayCursor::trace(JSTracer *trc) {
32287 for (JSXMLArrayCursor *cursor = this; cursor; cursor = cursor->next)
32288 js::gc::MarkGCThing(trc, cursor->root, "cursor_root", index++);
32292 XMLArrayCursorTrace(JSTracer *trc, JSXMLArrayCursor *cursor)
32294 cursor->trace(trc);
32301 JSXMLArray::setCapacity(JSContext *cx, uint32 newCapacity)
32303 if (newCapacity == 0) {
32319 !(tmp = (void **) js_realloc(vector, newCapacity * sizeof(void *)))) {
32321 JS_ReportOutOfMemory(cx);
32326 capacity = ((JSUint32)1 << (31)) | newCapacity;
32333 if (capacity & ((JSUint32)1 << (31)))
32335 if (length < capacity)
32336 setCapacity(__null, length);
32340 JSXMLArray::finish(JSContext *cx)
32344 while (JSXMLArrayCursor *cursor = cursors)
32345 cursor->disconnect();
32355 XMLArrayFindMember(const JSXMLArray *array, void *elt, JSIdentityOp identity)
32361 vector = array->vector;
32363 for (i = 0, n = array->length; i < n; i++) {
32364 if (identity(vector[i], elt))
32368 for (i = 0, n = array->length; i < n; i++) {
32369 if (vector[i] == elt)
32373 return ((uint32) -1);
32377 XMLArrayAddMember(JSContext *cx, JSXMLArray *array, uint32 index, void *elt)
32379 uint32 capacity, i;
32383 if (index >= array->length) {
32384 if (index >= ((array)->capacity & (((JSUint32)1 << (31)) - 1))) {
32386 capacity = index + 1;
32387 if (index >= 256) {
32388 capacity = ((((capacity)+(32)-1)/(32))*(32));
32390 do { unsigned int j_ = (unsigned int)(capacity); (log2) = (j_ <= 1 ? 0 : 32 - __builtin_clz(j_ - 1)); } while (0);
32391 capacity = ((JSUint32)1 << (log2));
32397 !(vector = (void **)
32398 js_realloc(array->vector, capacity * sizeof(void *)))) {
32399 JS_ReportOutOfMemory(cx);
32402 array->capacity = capacity;
32403 array->vector = vector;
32404 for (i = array->length; i < index; i++)
32405 vector[i] = __null;
32407 array->length = index + 1;
32410 array->vector[index] = elt;
32415 XMLArrayInsert(JSContext *cx, JSXMLArray *array, uint32 i, uint32 n)
32418 JSXMLArrayCursor *cursor;
32422 if (!array->setCapacity(cx, j + n))
32425 array->length = j + n;
32429 array->vector[j + n] = array->vector[j];
32432 for (cursor = array->cursors; cursor; cursor = cursor->next) {
32433 if (cursor->index > i)
32434 cursor->index += n;
32440 XMLArrayDelete(JSContext *cx, JSXMLArray *array, uint32 index, JSBool compress)
32443 void **vector, *elt;
32444 JSXMLArrayCursor *cursor;
32446 length = array->length;
32447 if (index >= length)
32450 vector = array->vector;
32451 elt = vector[index];
32453 while (++index < length)
32454 vector[index-1] = vector[index];
32455 array->length = length - 1;
32456 array->capacity = ((array)->capacity & (((JSUint32)1 << (31)) - 1));
32458 vector[index] = __null;
32461 for (cursor = array->cursors; cursor; cursor = cursor->next) {
32462 if (cursor->index > index)
32469 XMLArrayTruncate(JSContext *cx, JSXMLArray *array, uint32 length)
32474 if (length >= array->length)
32479 cx->free(array->vector);
32482 vector = (void **) js_realloc(array->vector, length * sizeof(void *));
32487 if (array->length > length)
32488 array->length = length;
32489 array->capacity = length;
32490 array->vector = vector;
32493 static const char js_ignoreComments_str[] = "ignoreComments";
32494 static const char js_ignoreProcessingInstructions_str[]
32495 = "ignoreProcessingInstructions";
32496 static const char js_ignoreWhitespace_str[] = "ignoreWhitespace";
32497 static const char js_prettyPrinting_str[] = "prettyPrinting";
32498 static const char js_prettyIndent_str[] = "prettyIndent";
32505 static JSPropertySpec xml_static_props[] = {
32506 {js_ignoreComments_str, 0, 0x04, __null, __null},
32507 {js_ignoreProcessingInstructions_str, 0, 0x04, __null, __null},
32508 {js_ignoreWhitespace_str, 0, 0x04, __null, __null},
32509 {js_prettyPrinting_str, 0, 0x04, __null, __null},
32510 {js_prettyIndent_str, 0, 0x04, __null, __null},
32514 static const char xml_namespace_str[] = "http://www.w3.org/XML/1998/namespace";
32515 static const char xmlns_namespace_str[] = "http://www.w3.org/2000/xmlns/";
32518 ParseNodeToQName(Parser *parser, JSParseNode *pn,
32519 JSXMLArray *inScopeNSes, JSBool isAttributeName)
32521 JSContext *cx = parser->context;
32522 JSLinearString *str, *uri, *prefix, *localName;
32523 size_t length, offset;
32524 const jschar *start, *limit, *colon;
32527 JSLinearString *nsprefix;
32530 str = pn->pn_u.name.atom;
32531 start = str->chars();
32532 length = str->length();
32536 uri = cx->runtime->emptyString;
32537 limit = start + length;
32538 colon = js_strchr_limit(start, ':', limit);
32540 offset = colon - start;
32541 prefix = js_NewDependentString(cx, str, 0, offset);
32545 if ((offset >= 3 && (((jschar) (((js_A[js_Y[(js_X[(uint16)((start)[0])>>6]<<6)|(((start)[0])&0x3F)]]) & 0x00200000) ? ((start)[0]) + ((int32)(js_A[js_Y[(js_X[(uint16)((start)[0])>>6]<<6)|(((start)[0])&0x3F)]]) >> 22) : ((start)[0]))) == 'x' && ((jschar) (((js_A[js_Y[(js_X[(uint16)((start)[1])>>6]<<6)|(((start)[1])&0x3F)]]) & 0x00200000) ? ((start)[1]) + ((int32)(js_A[js_Y[(js_X[(uint16)((start)[1])>>6]<<6)|(((start)[1])&0x3F)]]) >> 22) : ((start)[1]))) == 'm' && ((jschar) (((js_A[js_Y[(js_X[(uint16)((start)[2])>>6]<<6)|(((start)[2])&0x3F)]]) & 0x00200000) ? ((start)[2]) + ((int32)(js_A[js_Y[(js_X[(uint16)((start)[2])>>6]<<6)|(((start)[2])&0x3F)]]) >> 22) : ((start)[2]))) == 'l'))) {
32547 uri = JS_ASSERT_STRING_IS_FLAT(JS_InternString(cx, xml_namespace_str));
32550 } else if (offset == 5 && (((jschar) (((js_A[js_Y[(js_X[(uint16)((start)[3])>>6]<<6)|(((start)[3])&0x3F)]]) & 0x00200000) ? ((start)[3]) + ((int32)(js_A[js_Y[(js_X[(uint16)((start)[3])>>6]<<6)|(((start)[3])&0x3F)]]) >> 22) : ((start)[3]))) == 'n' && ((jschar) (((js_A[js_Y[(js_X[(uint16)((start)[4])>>6]<<6)|(((start)[4])&0x3F)]]) & 0x00200000) ? ((start)[4]) + ((int32)(js_A[js_Y[(js_X[(uint16)((start)[4])>>6]<<6)|(((start)[4])&0x3F)]]) >> 22) : ((start)[4]))) == 's')) {
32551 uri = JS_ASSERT_STRING_IS_FLAT(JS_InternString(cx, xmlns_namespace_str));
32559 n = inScopeNSes->length;
32562 ns = (((n) < (inScopeNSes)->length) ? (JSObject *) (inScopeNSes)->vector[n] : __null);
32563 nsprefix = ns->getNamePrefix();
32564 if (nsprefix && EqualStrings(nsprefix, prefix)) {
32565 uri = ns->getNameURI();
32572 Value v = StringValue(prefix);
32573 JSAutoByteString bytes;
32574 if (js_ValueToPrintable(parser->context, v, &bytes)) {
32575 ReportCompileErrorNumber(parser->context, &parser->tokenStream, pn,
32576 0x0, JSMSG_BAD_XML_NAMESPACE, bytes.ptr());
32581 localName = js_NewStringCopyN(parser->context, colon + 1, length - (offset + 1));
32585 if (isAttributeName) {
32596 n = inScopeNSes->length;
32599 ns = (((n) < (inScopeNSes)->length) ? (JSObject *) (inScopeNSes)->vector[n] : __null);
32600 nsprefix = ns->getNamePrefix();
32601 if (!nsprefix || nsprefix->empty()) {
32602 uri = ns->getNameURI();
32606 prefix = uri->empty() ? parser->context->runtime->emptyString : __null;
32611 return NewXMLQName(parser->context, uri, prefix, localName);
32615 ChompXMLWhitespace(JSContext *cx, JSString *str)
32617 size_t length, newlength, offset;
32618 const jschar *cp, *start, *end;
32621 length = str->length();
32622 start = str->getChars(cx);
32626 for (cp = start, end = cp + length; cp < end; cp++) {
32628 if (!((c) == ' ' || (c) == '\t' || (c) == '\r' || (c) == '\n'))
32633 if (!((c) == ' ' || (c) == '\t' || (c) == '\r' || (c) == '\n'))
32637 newlength = end - cp;
32638 if (newlength == length)
32640 offset = cp - start;
32641 return js_NewDependentString(cx, str, offset, newlength);
32645 ParseNodeToXML(Parser *parser, JSParseNode *pn,
32646 JSXMLArray *inScopeNSes, uintN flags)
32648 JSContext *cx = parser->context;
32649 JSXML *xml, *kid, *attr, *attrj;
32650 JSLinearString *str;
32651 uint32 length, n, i, j;
32652 JSParseNode *pn2, *pn3, *head, **pnp;
32654 JSObject *qn, *attrjqn;
32655 JSXMLClass xml_class;
32658 if (!((jsuword)(&stackDummy) > cx->stackLimit)) {
32659 ReportCompileErrorNumber(cx, &parser->tokenStream, pn, 0x0,
32660 JSMSG_OVER_RECURSED);
32665 if (!js_EnterLocalRootScope(cx))
32667 switch (pn->pn_type) {
32669 length = inScopeNSes->length;
32670 pn2 = pn->pn_u.list.head;
32671 xml = ParseNodeToXML(parser, pn2, inScopeNSes, flags);
32675 n = pn->pn_u.list.count;
32678 if (!xml->u.list.kids.setCapacity(cx, n))
32682 while ((pn2 = pn2->pn_next) != __null) {
32683 if (!pn2->pn_next) {
32689 if ((flags & ((JSUint32)1 << (2))) &&
32690 n > 1 && pn2->pn_type == TOK_XMLSPACE) {
32695 kid = ParseNodeToXML(parser, pn2, inScopeNSes, flags);
32696 if (kid == ((JSXML *) 1)) {
32705 do { if ((&xml->u.list.kids)->length <= (i)) (&xml->u.list.kids)->length = (i) + 1; ((&xml->u.list.kids)->vector[i] = (void *)(kid)); } while (0);
32710 if ((flags & ((JSUint32)1 << (2))) &&
32711 n > 1 && kid->xml_class == JSXML_CLASS_TEXT) {
32712 JSString *str = ChompXMLWhitespace(cx, kid->u.value);
32715 kid->u.value = str;
32720 if (n < pn->pn_u.list.count - 2)
32721 xml->u.list.kids.trim();
32722 XMLArrayTruncate(cx, inScopeNSes, length);
32726 xml = js_NewXML(cx, JSXML_CLASS_LIST);
32730 n = pn->pn_u.list.count;
32731 if (!xml->u.list.kids.setCapacity(cx, n))
32735 for (pn2 = pn->pn_u.list.head; pn2; pn2 = pn2->pn_next) {
32741 if (pn2->pn_type == TOK_XMLSPACE) {
32746 kid = ParseNodeToXML(parser, pn2, inScopeNSes, flags);
32747 if (kid == ((JSXML *) 1)) {
32755 do { if ((&xml->u.list.kids)->length <= (i)) (&xml->u.list.kids)->length = (i) + 1; ((&xml->u.list.kids)->vector[i] = (void *)(kid)); } while (0);
32759 if (n < pn->pn_u.list.count)
32760 xml->u.list.kids.trim();
32765 length = inScopeNSes->length;
32766 pn2 = pn->pn_u.list.head;
32768 if (pn2->pn_arity == PN_LIST)
32771 xml = js_NewXML(cx, JSXML_CLASS_ELEMENT);
32777 n = pn->pn_u.list.count - 1;
32778 pnp = &pn2->pn_next;
32780 while ((pn2 = *pnp) != __null) {
32782 const jschar *chars;
32784 if (pn2->pn_type != TOK_XMLNAME || pn2->pn_arity != PN_NULLARY)
32788 for (pn3 = head; pn3 != pn2; pn3 = pn3->pn_next->pn_next) {
32789 if (pn3->pn_u.name.atom == pn2->pn_u.name.atom) {
32790 Value v = StringValue((pn2->pn_u.name.atom));
32791 JSAutoByteString bytes;
32792 if (js_ValueToPrintable(cx, v, &bytes)) {
32793 ReportCompileErrorNumber(cx, &parser->tokenStream, pn2,
32794 0x0, JSMSG_DUPLICATE_XML_ATTR,
32801 JSAtom *atom = pn2->pn_u.name.atom;
32802 pn2 = pn2->pn_next;
32804 if (pn2->pn_type != TOK_XMLATTR)
32807 chars = atom->chars();
32808 length = atom->length();
32810 ((((jschar) (((js_A[js_Y[(js_X[(uint16)((chars)[0])>>6]<<6)|(((chars)[0])&0x3F)]]) & 0x00200000) ? ((chars)[0]) + ((int32)(js_A[js_Y[(js_X[(uint16)((chars)[0])>>6]<<6)|(((chars)[0])&0x3F)]]) >> 22) : ((chars)[0]))) == 'x' && ((jschar) (((js_A[js_Y[(js_X[(uint16)((chars)[1])>>6]<<6)|(((chars)[1])&0x3F)]]) & 0x00200000) ? ((chars)[1]) + ((int32)(js_A[js_Y[(js_X[(uint16)((chars)[1])>>6]<<6)|(((chars)[1])&0x3F)]]) >> 22) : ((chars)[1]))) == 'm' && ((jschar) (((js_A[js_Y[(js_X[(uint16)((chars)[2])>>6]<<6)|(((chars)[2])&0x3F)]]) & 0x00200000) ? ((chars)[2]) + ((int32)(js_A[js_Y[(js_X[(uint16)((chars)[2])>>6]<<6)|(((chars)[2])&0x3F)]]) >> 22) : ((chars)[2]))) == 'l') && (((jschar) (((js_A[js_Y[(js_X[(uint16)((chars)[3])>>6]<<6)|(((chars)[3])&0x3F)]]) & 0x00200000) ? ((chars)[3]) + ((int32)(js_A[js_Y[(js_X[(uint16)((chars)[3])>>6]<<6)|(((chars)[3])&0x3F)]]) >> 22) : ((chars)[3]))) == 'n' && ((jschar) (((js_A[js_Y[(js_X[(uint16)((chars)[4])>>6]<<6)|(((chars)[4])&0x3F)]]) & 0x00200000) ? ((chars)[4]) + ((int32)(js_A[js_Y[(js_X[(uint16)((chars)[4])>>6]<<6)|(((chars)[4])&0x3F)]]) >> 22) : ((chars)[4]))) == 's')) &&
32811 (length == 5 || chars[5] == ':')) {
32812 JSLinearString *uri, *prefix;
32814 uri = (pn2->pn_u.name.atom);
32817 prefix = cx->runtime->emptyString;
32819 prefix = js_NewStringCopyN(cx, chars + 6, length - 6);
32830 ns = NewXMLNamespace(cx, prefix, uri, (JSIntn)1);
32834 if (!(XMLArrayFindMember(inScopeNSes, (void *)(ns), namespace_identity) != ((uint32) -1))) {
32835 if (!XMLArrayAddMember(cx, inScopeNSes, (inScopeNSes)->length, (void *)((ns))) ||
32836 !XMLArrayAddMember(cx, &xml->u.elem.namespaces, (&xml->u.elem.namespaces)->length, (void *)((ns)))) {
32843 *pnp = pn2->pn_next;
32848 pnp = &pn2->pn_next;
32851 xml->u.elem.namespaces.trim();
32854 pn2 = pn->pn_u.list.head;
32855 qn = ParseNodeToQName(parser, pn2, inScopeNSes, (JSIntn)0);
32862 if (!xml->u.elem.attrs.setCapacity(cx, n))
32865 for (i = 0; (pn2 = pn2->pn_next) != __null; i++) {
32866 qn = ParseNodeToQName(parser, pn2, inScopeNSes, (JSIntn)1);
32868 xml->u.elem.attrs.length = i;
32876 for (j = 0; j < i; j++) {
32877 attrj = (((j) < (&xml->u.elem.attrs)->length) ? (JSXML *) (&xml->u.elem.attrs)->vector[j] : __null);
32878 attrjqn = attrj->name;
32879 if (EqualStrings(attrjqn->getNameURI(), qn->getNameURI()) &&
32880 EqualStrings(attrjqn->getQNameLocalName(), qn->getQNameLocalName())) {
32881 Value v = StringValue((pn2->pn_u.name.atom));
32882 JSAutoByteString bytes;
32883 if (js_ValueToPrintable(cx, v, &bytes)) {
32884 ReportCompileErrorNumber(cx, &parser->tokenStream, pn2,
32885 0x0, JSMSG_DUPLICATE_XML_ATTR,
32892 pn2 = pn2->pn_next;
32896 attr = js_NewXML(cx, JSXML_CLASS_ATTRIBUTE);
32900 do { if ((&xml->u.elem.attrs)->length <= (i)) (&xml->u.elem.attrs)->length = (i) + 1; ((&xml->u.elem.attrs)->vector[i] = (void *)(attr)); } while (0);
32901 attr->parent = xml;
32903 attr->u.value = (pn2->pn_u.name.atom);
32907 if (pn->pn_type == TOK_XMLPTAGC)
32908 XMLArrayTruncate(cx, inScopeNSes, length);
32914 case TOK_XMLCOMMENT:
32916 str = (pn->pn_u.name.atom);
32918 if (pn->pn_type == TOK_XMLCOMMENT) {
32919 if (flags & ((JSUint32)1 << (0)))
32921 xml_class = JSXML_CLASS_COMMENT;
32922 } else if (pn->pn_type == TOK_XMLPI) {
32923 if ((str->length() == 3 && (((jschar) (((js_A[js_Y[(js_X[(uint16)((str->chars())[0])>>6]<<6)|(((str->chars())[0])&0x3F)]]) & 0x00200000) ? ((str->chars())[0]) + ((int32)(js_A[js_Y[(js_X[(uint16)((str->chars())[0])>>6]<<6)|(((str->chars())[0])&0x3F)]]) >> 22) : ((str->chars())[0]))) == 'x' && ((jschar) (((js_A[js_Y[(js_X[(uint16)((str->chars())[1])>>6]<<6)|(((str->chars())[1])&0x3F)]]) & 0x00200000) ? ((str->chars())[1]) + ((int32)(js_A[js_Y[(js_X[(uint16)((str->chars())[1])>>6]<<6)|(((str->chars())[1])&0x3F)]]) >> 22) : ((str->chars())[1]))) == 'm' && ((jschar) (((js_A[js_Y[(js_X[(uint16)((str->chars())[2])>>6]<<6)|(((str->chars())[2])&0x3F)]]) & 0x00200000) ? ((str->chars())[2]) + ((int32)(js_A[js_Y[(js_X[(uint16)((str->chars())[2])>>6]<<6)|(((str->chars())[2])&0x3F)]]) >> 22) : ((str->chars())[2]))) == 'l'))) {
32924 Value v = StringValue(str);
32925 JSAutoByteString bytes;
32926 if (js_ValueToPrintable(cx, v, &bytes)) {
32927 ReportCompileErrorNumber(cx, &parser->tokenStream, pn,
32928 0x0, JSMSG_RESERVED_ID, bytes.ptr());
32933 if (flags & ((JSUint32)1 << (1)))
32936 qn = ParseNodeToQName(parser, pn, inScopeNSes, (JSIntn)0);
32940 str = pn->pn_u.apair.atom2
32941 ? (pn->pn_u.apair.atom2)
32942 : cx->runtime->emptyString;
32943 xml_class = JSXML_CLASS_PROCESSING_INSTRUCTION;
32946 xml_class = JSXML_CLASS_TEXT;
32949 xml = js_NewXML(cx, xml_class);
32953 if (pn->pn_type == TOK_XMLSPACE)
32954 xml->xml_flags |= 0x1;
32955 xml->u.value = str;
32962 js_LeaveLocalRootScopeWithResult(cx, xml);
32966 js_LeaveLocalRootScope(cx);
32967 return ((JSXML *) 1);
32972 ReportCompileErrorNumber(cx, &parser->tokenStream, pn, 0x0, JSMSG_BAD_XML_MARKUP);
32974 js_LeaveLocalRootScope(cx);
32983 GetXMLSetting(JSContext *cx, const char *name, jsval *vp)
32987 if (!js_FindClassObject(cx, __null, JSProto_XML, Valueify(&v)))
32989 if (!(!JSVAL_IS_PRIMITIVE(v) && JSVAL_TO_OBJECT(v)->isFunction())) {
32990 *vp = ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0));
32993 return JS_GetProperty(cx, JSVAL_TO_OBJECT(v), name, vp);
32997 GetBooleanXMLSetting(JSContext *cx, const char *name, JSBool *bp)
33001 return GetXMLSetting(cx, name, &v) && JS_ValueToBoolean(cx, v, bp);
33005 GetUint32XMLSetting(JSContext *cx, const char *name, uint32 *uip)
33009 return GetXMLSetting(cx, name, &v) && JS_ValueToECMAUint32(cx, v, uip);
33013 GetXMLSettingFlags(JSContext *cx, uintN *flagsp)
33017 if (!GetBooleanXMLSetting(cx, js_ignoreComments_str, &flag[0]) ||
33018 !GetBooleanXMLSetting(cx, js_ignoreProcessingInstructions_str, &flag[1]) ||
33019 !GetBooleanXMLSetting(cx, js_ignoreWhitespace_str, &flag[2]) ||
33020 !GetBooleanXMLSetting(cx, js_prettyPrinting_str, &flag[3])) {
33025 for (size_t n = 0; n < 4; ++n)
33027 *flagsp |= ((JSUint32)1 << (n));
33032 ParseXMLSource(JSContext *cx, JSString *src)
33035 JSLinearString *uri;
33036 size_t urilen, srclen, length, offset, dstlen;
33038 const jschar *srcp, *endp;
33040 const char *filename;
33044 static const char prefix[] = "<parent xmlns=\"";
33045 static const char middle[] = "\">";
33046 static const char suffix[] = "</parent>";
33050 if (!js_GetDefaultXMLNamespace(cx, &nsval))
33052 uri = JSVAL_TO_OBJECT(nsval)->getNameURI();
33053 uri = js_EscapeAttributeValue(cx, uri, (JSIntn)0);
33057 urilen = uri->length();
33058 srclen = src->length();
33059 length = (sizeof(prefix) - 1) + urilen + (sizeof(middle) - 1) + srclen +
33060 (sizeof(suffix) - 1);
33062 chars = (jschar *) cx->malloc((length + 1) * sizeof(jschar));
33067 js_InflateStringToBuffer(cx, prefix, (sizeof(prefix) - 1), chars, &dstlen);
33069 memcpy((chars + offset), (uri->chars()), (urilen) * sizeof(jschar));
33071 dstlen = length - offset + 1;
33072 js_InflateStringToBuffer(cx, middle, (sizeof(middle) - 1), chars + offset,
33075 srcp = src->getChars(cx);
33080 memcpy((chars + offset), (srcp), (srclen) * sizeof(jschar));
33082 dstlen = length - offset + 1;
33083 js_InflateStringToBuffer(cx, suffix, (sizeof(suffix) - 1), chars + offset,
33085 chars [offset + dstlen] = 0;
33089 FrameRegsIter i(cx);
33090 for (; !i.done() && !i.pc(); ++i)
33095 JSStackFrame *fp = i.fp();
33096 op = (JSOp) *i.pc();
33097 if (op == JSOP_TOXML || op == JSOP_TOXMLLIST) {
33098 filename = fp->script()->filename;
33099 lineno = js_FramePCToLineNumber(cx, fp);
33100 for (endp = srcp + srclen; srcp < endp; srcp++) {
33109 if (parser.init(chars, length, filename, lineno, cx->findVersion())) {
33110 JSObject *scopeChain = GetScopeChain(cx);
33115 JSParseNode *pn = parser.parseXMLText(scopeChain, false);
33117 if (pn && GetXMLSettingFlags(cx, &flags)) {
33118 AutoNamespaceArray namespaces(cx);
33119 if (namespaces.array.setCapacity(cx, 1))
33120 xml = ParseNodeToXML(&parser, pn, &namespaces.array, flags);
33132 OrphanXMLChild(JSContext *cx, JSXML *xml, uint32 i)
33136 ns = (((0) < (&xml->u.elem.namespaces)->length) ? (JSObject *) (&xml->u.elem.namespaces)->vector[0] : __null);
33137 xml = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null);
33140 if (xml->xml_class == JSXML_CLASS_ELEMENT) {
33141 if (!XMLArrayAddMember(cx, &xml->u.elem.namespaces, (&xml->u.elem.namespaces)->length, (void *)((ns))))
33143 ns->setNamespaceDeclared(((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)));
33145 xml->parent = __null;
33150 ToXML(JSContext *cx, jsval v)
33158 if (JSVAL_IS_PRIMITIVE(v)) {
33159 if (JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v))
33162 obj = JSVAL_TO_OBJECT(v);
33163 if (obj->isXML()) {
33164 xml = (JSXML *) obj->getPrivate();
33165 if (xml->xml_class == JSXML_CLASS_LIST) {
33166 if (xml->u.list.kids.length != 1)
33168 xml = (((0) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[0] : __null);
33171 return js_GetXMLObject(cx, xml);
33177 clasp = obj->getClass();
33178 if (clasp->flags & (1<<7)) {
33182 if (clasp != &js_StringClass &&
33183 clasp != &js_NumberClass &&
33184 clasp != &js_BooleanClass) {
33189 str = js_ValueToString(cx, Valueify(v));
33192 if (str->empty()) {
33198 xml = ParseXMLSource(cx, str);
33201 length = ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (xml)->u.list.kids.length : 0);
33205 obj = js_NewXMLObject(cx, JSXML_CLASS_TEXT);
33208 } else if (length == 1) {
33209 xml = OrphanXMLChild(cx, xml, 0);
33212 obj = js_GetXMLObject(cx, xml);
33216 JS_ReportErrorNumber(cx, js_GetErrorMessage, __null, JSMSG_SYNTAX_ERROR);
33222 ((void)js_ReportValueErrorFlags(cx, 0x0, JSMSG_BAD_XML_CONVERSION, 0, Valueify(v), __null, __null, __null))
33228 Append(JSContext *cx, JSXML *list, JSXML *kid);
33231 ToXMLList(JSContext *cx, jsval v)
33233 JSObject *obj, *listobj;
33234 JSXML *xml, *list, *kid;
33239 if (JSVAL_IS_PRIMITIVE(v)) {
33240 if (JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v))
33243 obj = JSVAL_TO_OBJECT(v);
33244 if (obj->isXML()) {
33245 xml = (JSXML *) obj->getPrivate();
33246 if (xml->xml_class != JSXML_CLASS_LIST) {
33247 listobj = js_NewXMLObject(cx, JSXML_CLASS_LIST);
33250 list = (JSXML *) listobj->getPrivate();
33251 if (!Append(cx, list, xml))
33258 clasp = obj->getClass();
33259 if (clasp->flags & (1<<7)) {
33263 if (clasp != &js_StringClass &&
33264 clasp != &js_NumberClass &&
33265 clasp != &js_BooleanClass) {
33270 str = js_ValueToString(cx, Valueify(v));
33273 if (str->empty()) {
33277 if (!js_EnterLocalRootScope(cx))
33279 xml = ParseXMLSource(cx, str);
33281 js_LeaveLocalRootScope(cx);
33284 length = ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (xml)->u.list.kids.length : 0);
33287 listobj = js_NewXMLObject(cx, JSXML_CLASS_LIST);
33289 list = (JSXML *) listobj->getPrivate();
33290 for (i = 0; i < length; i++) {
33291 kid = OrphanXMLChild(cx, xml, i);
33292 if (!kid || !Append(cx, list, kid)) {
33300 js_LeaveLocalRootScopeWithResult(cx, listobj);
33304 ((void)js_ReportValueErrorFlags(cx, 0x0, JSMSG_BAD_XMLLIST_CONVERSION, 0, Valueify(v), __null, __null, __null))
33309 static JSFlatString *
33310 MakeXMLSpecialString(JSContext *cx, StringBuffer &sb,
33311 JSString *str, JSString *str2,
33312 const jschar *prefix, size_t prefixlength,
33313 const jschar *suffix, size_t suffixlength)
33315 if (!sb.append(prefix, prefixlength) || !sb.append(str))
33317 if (str2 && !str2->empty()) {
33318 if (!sb.append(' ') || !sb.append(str2))
33321 if (!sb.append(suffix, suffixlength))
33324 return sb.finishString();
33327 static JSFlatString *
33328 MakeXMLCDATAString(JSContext *cx, StringBuffer &sb, JSString *str)
33330 static const jschar cdata_prefix_ucNstr[] = {'<', '!', '[',
33331 'C', 'D', 'A', 'T', 'A',
33333 static const jschar cdata_suffix_ucNstr[] = {']', ']', '>'};
33335 return MakeXMLSpecialString(cx, sb, str, __null,
33336 cdata_prefix_ucNstr, 9,
33337 cdata_suffix_ucNstr, 3);
33340 static JSFlatString *
33341 MakeXMLCommentString(JSContext *cx, StringBuffer &sb, JSString *str)
33343 static const jschar comment_prefix_ucNstr[] = {'<', '!', '-', '-'};
33344 static const jschar comment_suffix_ucNstr[] = {'-', '-', '>'};
33346 return MakeXMLSpecialString(cx, sb, str, __null,
33347 comment_prefix_ucNstr, 4,
33348 comment_suffix_ucNstr, 3);
33351 static JSFlatString *
33352 MakeXMLPIString(JSContext *cx, StringBuffer &sb, JSString *name,
33355 static const jschar pi_prefix_ucNstr[] = {'<', '?'};
33356 static const jschar pi_suffix_ucNstr[] = {'?', '>'};
33358 return MakeXMLSpecialString(cx, sb, name, value,
33359 pi_prefix_ucNstr, 2,
33360 pi_suffix_ucNstr, 2);
33371 AppendAttributeValue(JSContext *cx, StringBuffer &sb, JSString *valstr)
33373 if (!sb.append('='))
33375 valstr = js_EscapeAttributeValue(cx, valstr, (JSIntn)1);
33376 return valstr && sb.append(valstr);
33384 static JSFlatString *
33385 EscapeElementValue(JSContext *cx, StringBuffer &sb, JSString *str, uint32 toSourceFlag)
33387 size_t length = str->length();
33388 const jschar *start = str->getChars(cx);
33392 for (const jschar *cp = start, *end = start + length; cp != end; ++cp) {
33396 if (!sb.append(js_lt_entity_str))
33400 if (!sb.append(js_gt_entity_str))
33404 if (!sb.append(js_amp_entity_str))
33412 if (toSourceFlag) {
33413 if (!sb.append(js_leftcurly_entity_str))
33423 return sb.finishString();
33431 static JSFlatString *
33432 EscapeAttributeValue(JSContext *cx, StringBuffer &sb, JSString *str, JSBool quote)
33434 size_t length = str->length();
33435 const jschar *start = str->getChars(cx);
33439 if (quote && !sb.append('"'))
33442 for (const jschar *cp = start, *end = start + length; cp != end; ++cp) {
33446 if (!sb.append(js_quot_entity_str))
33450 if (!sb.append(js_lt_entity_str))
33454 if (!sb.append(js_amp_entity_str))
33458 if (!sb.append("
"))
33462 if (!sb.append("
"))
33466 if (!sb.append("	"))
33475 if (quote && !sb.append('"'))
33478 return sb.finishString();
33483 GetNamespace(JSContext *cx, JSObject *qn, const JSXMLArray *inScopeNSes)
33485 JSLinearString *uri, *prefix, *nsprefix;
33486 JSObject *match, *ns;
33490 uri = qn->getNameURI();
33491 prefix = qn->getNamePrefix();
33494 JSAutoByteString bytes;
33495 const char *s = !prefix ?
33497 : js_ValueToPrintable(cx, StringValue(prefix), &bytes);
33499 JS_ReportErrorNumber(cx, js_GetErrorMessage, __null, JSMSG_BAD_XML_NAMESPACE, s);
33506 for (i = 0, n = inScopeNSes->length; i < n; i++) {
33507 ns = (((i) < (inScopeNSes)->length) ? (JSObject *) (inScopeNSes)->vector[i] : __null);
33511 if (EqualStrings(ns->getNameURI(), uri)) {
33512 nsprefix = ns->getNamePrefix();
33513 if (nsprefix == prefix ||
33514 ((nsprefix && prefix)
33515 ? EqualStrings(nsprefix, prefix)
33516 : (nsprefix ? nsprefix : prefix)->empty())) {
33526 argv[0] = prefix ? STRING_TO_JSVAL(prefix) : ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0));
33527 argv[1] = STRING_TO_JSVAL(uri);
33528 ns = js_ConstructObject(cx, &js_NamespaceClass, __null, __null,
33529 2, Valueify(argv));
33537 static JSLinearString *
33538 GeneratePrefix(JSContext *cx, JSLinearString *uri, JSXMLArray *decls)
33540 const jschar *cp, *start, *end;
33541 size_t length, newlength, offset;
33542 uint32 i, n, m, serial;
33546 JSLinearString *nsprefix, *prefix;
33550 if (decls->length == 0)
33551 return js_NewStringCopyZ(cx, "a");
33559 start = uri->chars();
33560 end = start + uri->length();
33562 while (--cp > start) {
33563 if (*cp == '.' || *cp == '/' || *cp == ':') {
33566 if (IsXMLName(cp, length) && !(length >= 3 && (((jschar) (((js_A[js_Y[(js_X[(uint16)((cp)[0])>>6]<<6)|(((cp)[0])&0x3F)]]) & 0x00200000) ? ((cp)[0]) + ((int32)(js_A[js_Y[(js_X[(uint16)((cp)[0])>>6]<<6)|(((cp)[0])&0x3F)]]) >> 22) : ((cp)[0]))) == 'x' && ((jschar) (((js_A[js_Y[(js_X[(uint16)((cp)[1])>>6]<<6)|(((cp)[1])&0x3F)]]) & 0x00200000) ? ((cp)[1]) + ((int32)(js_A[js_Y[(js_X[(uint16)((cp)[1])>>6]<<6)|(((cp)[1])&0x3F)]]) >> 22) : ((cp)[1]))) == 'm' && ((jschar) (((js_A[js_Y[(js_X[(uint16)((cp)[2])>>6]<<6)|(((cp)[2])&0x3F)]]) & 0x00200000) ? ((cp)[2]) + ((int32)(js_A[js_Y[(js_X[(uint16)((cp)[2])>>6]<<6)|(((cp)[2])&0x3F)]]) >> 22) : ((cp)[2]))) == 'l')))
33573 bp = (jschar *) cp;
33574 newlength = length;
33575 if ((length >= 3 && (((jschar) (((js_A[js_Y[(js_X[(uint16)((cp)[0])>>6]<<6)|(((cp)[0])&0x3F)]]) & 0x00200000) ? ((cp)[0]) + ((int32)(js_A[js_Y[(js_X[(uint16)((cp)[0])>>6]<<6)|(((cp)[0])&0x3F)]]) >> 22) : ((cp)[0]))) == 'x' && ((jschar) (((js_A[js_Y[(js_X[(uint16)((cp)[1])>>6]<<6)|(((cp)[1])&0x3F)]]) & 0x00200000) ? ((cp)[1]) + ((int32)(js_A[js_Y[(js_X[(uint16)((cp)[1])>>6]<<6)|(((cp)[1])&0x3F)]]) >> 22) : ((cp)[1]))) == 'm' && ((jschar) (((js_A[js_Y[(js_X[(uint16)((cp)[2])>>6]<<6)|(((cp)[2])&0x3F)]]) & 0x00200000) ? ((cp)[2]) + ((int32)(js_A[js_Y[(js_X[(uint16)((cp)[2])>>6]<<6)|(((cp)[2])&0x3F)]]) >> 22) : ((cp)[2]))) == 'l')) || !IsXMLName(cp, length)) {
33576 newlength = length + 2 + (size_t) log10((double) decls->length);
33578 cx->malloc((newlength + 1) * sizeof(jschar));
33583 for (i = 0; i < newlength; i++)
33594 for (i = 0, n = decls->length; i < n; i++) {
33595 ns = (((i) < (decls)->length) ? (JSObject *) (decls)->vector[i] : __null);
33596 if (ns && (nsprefix = ns->getNamePrefix()) &&
33597 nsprefix->length() == newlength &&
33598 !memcmp(nsprefix->chars(), bp,
33599 newlength * sizeof(jschar))) {
33601 newlength = length + 2 + (size_t) log10((double) n);
33603 cx->malloc((newlength + 1) * sizeof(jschar));
33606 memcpy((bp), (cp), (length) * sizeof(jschar));
33611 dp = bp + length + 2 + (size_t) log10((double) serial);
33613 for (m = serial; m != 0; m /= 10)
33614 *--dp = (jschar)('0' + m % 10);
33625 offset = cp - start;
33626 prefix = js_NewDependentString(cx, uri, offset, length);
33628 prefix = js_NewString(cx, bp, newlength);
33636 namespace_match(const void *a, const void *b)
33638 const JSObject *nsa = (const JSObject *) a;
33639 const JSObject *nsb = (const JSObject *) b;
33640 JSLinearString *prefixa, *prefixb = nsb->getNamePrefix();
33643 prefixa = nsa->getNamePrefix();
33644 return prefixa && EqualStrings(prefixa, prefixb);
33646 return EqualStrings(nsa->getNameURI(), nsb->getNameURI());
33653 XMLToXMLString(JSContext *cx, JSXML *xml, const JSXMLArray *ancestorNSes,
33654 uint32 indentLevel)
33656 JSBool pretty, indentKids;
33657 StringBuffer sb(cx);
33659 JSLinearString *prefix, *nsuri;
33660 uint32 i, n, nextIndentLevel;
33661 JSObject *ns, *ns2;
33662 AutoNamespaceArray empty(cx), decls(cx), ancdecls(cx);
33664 if (!GetBooleanXMLSetting(cx, js_prettyPrinting_str, &pretty))
33668 if (!sb.appendN(' ', indentLevel & ~0x80000000))
33674 switch (xml->xml_class) {
33675 case JSXML_CLASS_TEXT:
33678 str = ChompXMLWhitespace(cx, xml->u.value);
33682 str = xml->u.value;
33684 return EscapeElementValue(cx, sb, str, indentLevel & 0x80000000);
33686 case JSXML_CLASS_ATTRIBUTE:
33688 return EscapeAttributeValue(cx, sb, xml->u.value,
33689 (indentLevel & 0x80000000) != 0);
33691 case JSXML_CLASS_COMMENT:
33693 return MakeXMLCommentString(cx, sb, xml->u.value);
33695 case JSXML_CLASS_PROCESSING_INSTRUCTION:
33697 return MakeXMLPIString(cx, sb, xml->name->getQNameLocalName(),
33700 case JSXML_CLASS_LIST:
33703 JSXMLArrayCursor cursor(&xml->u.list.kids);
33705 while (JSXML *kid = (JSXML *) cursor.getNext()) {
33706 if (pretty && i != 0) {
33707 if (!sb.append('\n'))
33711 JSString *kidstr = XMLToXMLString(cx, kid, ancestorNSes, indentLevel);
33712 if (!kidstr || !sb.append(kidstr))
33719 return cx->runtime->emptyString;
33720 return sb.finishString();
33726 if (!js_EnterLocalRootScope(cx))
33731 ancestorNSes = &empty.array;
33735 JSXMLArrayCursor cursor(&xml->u.elem.namespaces);
33736 while ((ns = (JSObject *) cursor.getNext()) != __null) {
33737 if (!IsDeclared(ns))
33739 if (!(XMLArrayFindMember(ancestorNSes, (void *)(ns), namespace_identity) != ((uint32) -1))) {
33741 ns2 = NewXMLNamespace(cx, ns->getNamePrefix(), ns->getNameURI(), (JSIntn)1);
33742 if (!ns2 || !XMLArrayAddMember(cx, &decls.array, (&decls.array)->length, (void *)((ns2))))
33754 if (!ancdecls.array.setCapacity(cx, ancestorNSes->length + decls.length()))
33756 for (i = 0, n = ancestorNSes->length; i < n; i++) {
33757 ns2 = (((i) < (ancestorNSes)->length) ? (JSObject *) (ancestorNSes)->vector[i] : __null);
33761 if (!XMLArrayAddMember(cx, &ancdecls.array, (&ancdecls.array)->length, (void *)((ns2))))
33764 for (i = 0, n = decls.length(); i < n; i++) {
33765 ns2 = (((i) < (&decls.array)->length) ? (JSObject *) (&decls.array)->vector[i] : __null);
33769 if (!XMLArrayAddMember(cx, &ancdecls.array, (&ancdecls.array)->length, (void *)((ns2))))
33774 ns = GetNamespace(cx, xml->name, &ancdecls.array);
33779 prefix = ns->getNamePrefix();
33782 nsuri = ns->getNameURI();
33783 if (!xml->name->getNamePrefix()) {
33784 prefix = cx->runtime->emptyString;
33786 prefix = GeneratePrefix(cx, nsuri, &ancdecls.array);
33790 ns = NewXMLNamespace(cx, prefix, nsuri, (JSIntn)1);
33794 if (prefix->empty()) {
33795 i = XMLArrayFindMember(&decls.array, ns, namespace_match);
33796 if (i != ((uint32) -1))
33797 XMLArrayDelete(cx, &decls.array, i, (JSIntn)1);
33800 if (!XMLArrayAddMember(cx, &ancdecls.array, (&ancdecls.array)->length, (void *)((ns))) ||
33801 !XMLArrayAddMember(cx, &decls.array, (&decls.array)->length, (void *)((ns)))) {
33807 if (!sb.append('<'))
33810 if (!prefix->empty()) {
33811 if (!sb.append(prefix) || !sb.append(':'))
33814 if (!sb.append(xml->name->getQNameLocalName()))
33818 JSXMLArrayCursor cursor(&xml->u.elem.attrs);
33819 while (JSXML *attr = (JSXML *) cursor.getNext()) {
33820 if (!sb.append(' '))
33822 ns2 = GetNamespace(cx, attr->name, &ancdecls.array);
33827 prefix = ns2->getNamePrefix();
33829 prefix = GeneratePrefix(cx, ns2->getNameURI(), &ancdecls.array);
33834 ns2 = NewXMLNamespace(cx, prefix, ns2->getNameURI(), (JSIntn)1);
33838 if (!XMLArrayAddMember(cx, &ancdecls.array, (&ancdecls.array)->length, (void *)((ns2))) ||
33839 !XMLArrayAddMember(cx, &decls.array, (&decls.array)->length, (void *)((ns2)))) {
33845 if (!prefix->empty()) {
33846 if (!sb.append(prefix) || !sb.append(':'))
33851 if (!sb.append(attr->name->getQNameLocalName()))
33855 if (!AppendAttributeValue(cx, sb, attr->u.value))
33862 JSXMLArrayCursor cursor(&decls.array);
33863 while (JSObject *ns3 = (JSObject *) cursor.getNext()) {
33866 if (!sb.append(" xmlns"))
33870 prefix = ns3->getNamePrefix();
33872 prefix = GeneratePrefix(cx, ns3->getNameURI(), &ancdecls.array);
33875 ns3->setNamePrefix(prefix);
33879 if (!prefix->empty()) {
33880 if (!sb.append(':') || !sb.append(prefix))
33885 if (!AppendAttributeValue(cx, sb, ns3->getNameURI()))
33891 n = xml->u.list.kids.length;
33893 if (!sb.append("/>"))
33897 if (!sb.append('>'))
33901 indentKids = n > 1 ||
33903 (kid = (((0) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[0] : __null)) &&
33904 kid->xml_class != JSXML_CLASS_TEXT);
33907 if (pretty && indentKids) {
33908 if (!GetUint32XMLSetting(cx, js_prettyIndent_str, &i))
33910 nextIndentLevel = indentLevel + i;
33912 nextIndentLevel = indentLevel & 0x80000000;
33916 JSXMLArrayCursor cursor(&xml->u.list.kids);
33917 while (JSXML *kid = (JSXML *) cursor.getNext()) {
33918 if (pretty && indentKids) {
33919 if (!sb.append('\n'))
33923 JSString *kidstr = XMLToXMLString(cx, kid, &ancdecls.array, nextIndentLevel);
33927 if (!sb.append(kidstr))
33932 if (pretty && indentKids) {
33933 if (!sb.append('\n') ||
33934 !sb.appendN(' ', indentLevel & ~0x80000000))
33937 if (!sb.append("</"))
33941 prefix = ns->getNamePrefix();
33942 if (prefix && !prefix->empty()) {
33943 if (!sb.append(prefix) || !sb.append(':'))
33948 if (!sb.append(xml->name->getQNameLocalName()) || !sb.append('>'))
33952 str = sb.finishString();
33954 js_LeaveLocalRootScopeWithResult(cx, str);
33960 ToXMLString(JSContext *cx, jsval v, uint32 toSourceFlag)
33966 if (JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v)) {
33967 JS_ReportErrorNumber(cx, js_GetErrorMessage, __null,
33968 JSMSG_BAD_XML_CONVERSION,
33969 JSVAL_IS_NULL(v) ? js_null_str : js_undefined_str);
33973 if (JSVAL_IS_BOOLEAN(v) || JSVAL_IS_NUMBER(v))
33974 return js_ValueToString(cx, Valueify(v));
33976 if (JSVAL_IS_STRING(v)) {
33977 StringBuffer sb(cx);
33978 return EscapeElementValue(cx, sb, JSVAL_TO_STRING(v), toSourceFlag);
33981 obj = JSVAL_TO_OBJECT(v);
33982 if (!obj->isXML()) {
33983 if (!DefaultValue(cx, obj, JSTYPE_STRING, Valueify(&v)))
33985 str = js_ValueToString(cx, Valueify(v));
33988 StringBuffer sb(cx);
33989 return EscapeElementValue(cx, sb, str, toSourceFlag);
33993 xml = (JSXML *) obj->getPrivate();
33994 return XMLToXMLString(cx, xml, __null, toSourceFlag | 0);
33998 ToAttributeName(JSContext *cx, jsval v)
34000 JSLinearString *name, *uri, *prefix;
34005 if (JSVAL_IS_STRING(v)) {
34006 name = JSVAL_TO_STRING(v)->ensureLinear(cx);
34009 uri = prefix = cx->runtime->emptyString;
34011 if (JSVAL_IS_PRIMITIVE(v)) {
34012 ((void)js_ReportValueErrorFlags(cx, 0x0, JSMSG_BAD_XML_ATTR_NAME, 0, Valueify(v), __null, __null, __null))
34017 obj = JSVAL_TO_OBJECT(v);
34018 clasp = obj->getClass();
34019 if (clasp == &js_AttributeNameClass)
34022 if (clasp == &js_QNameClass) {
34024 uri = qn->getNameURI();
34025 prefix = qn->getNamePrefix();
34026 name = qn->getQNameLocalName();
34028 if (clasp == &js_AnyNameClass) {
34029 name = (cx->runtime->atomState.starAtom);
34031 JSString *str = js_ValueToString(cx, Valueify(v));
34034 name = str->ensureLinear(cx);
34038 uri = prefix = cx->runtime->emptyString;
34042 qn = NewXMLAttributeName(cx, uri, prefix, name);
34049 ReportBadXMLName(JSContext *cx, const Value &idval)
34051 ((void)js_ReportValueErrorFlags(cx, 0x0, JSMSG_BAD_XML_NAME, 0, idval, __null, __null, __null));
34055 IsFunctionQName(JSContext *cx, JSObject *qn, jsid *funidp)
34058 JSLinearString *uri;
34060 atom = cx->runtime->atomState.functionNamespaceURIAtom;
34061 uri = qn->getNameURI();
34064 EqualStrings(uri, (atom)))) {
34065 return JS_ValueToId(cx, STRING_TO_JSVAL(qn->getQNameLocalName()), funidp);
34067 *funidp = ((jsid)0x2);
34072 js_IsFunctionQName(JSContext *cx, JSObject *obj, jsid *funidp)
34074 if (obj->getClass() == &js_QNameClass)
34075 return IsFunctionQName(cx, obj, funidp);
34076 *funidp = ((jsid)0x2);
34081 ToXMLName(JSContext *cx, jsval v, jsid *funidp)
34083 JSAtom *atomizedName;
34089 if (JSVAL_IS_STRING(v)) {
34090 name = JSVAL_TO_STRING(v);
34092 if (JSVAL_IS_PRIMITIVE(v)) {
34093 ReportBadXMLName(cx, Valueify(v));
34097 obj = JSVAL_TO_OBJECT(v);
34098 clasp = obj->getClass();
34099 if (clasp == &js_AttributeNameClass || clasp == &js_QNameClass)
34101 if (clasp == &js_AnyNameClass) {
34102 name = (cx->runtime->atomState.starAtom);
34105 name = js_ValueToString(cx, Valueify(v));
34110 atomizedName = js_AtomizeString(cx, name, 0);
34114 if (js_IdIsIndex(ATOM_TO_JSID(atomizedName), &index))
34117 if (*atomizedName->chars() == '@') {
34118 name = js_NewDependentString(cx, name, 1, name->length() - 1);
34121 *funidp = ((jsid)0x2);
34122 return ToAttributeName(cx, STRING_TO_JSVAL(name));
34126 v = STRING_TO_JSVAL(name);
34127 obj = js_ConstructObject(cx, &js_QNameClass, __null, __null, 1, Valueify(&v));
34132 if (!IsFunctionQName(cx, obj, funidp))
34137 JSAutoByteString bytes;
34138 if (js_ValueToPrintable(cx, StringValue(name), &bytes))
34139 JS_ReportErrorNumber(cx, js_GetErrorMessage, __null, JSMSG_BAD_XML_NAME, bytes.ptr());
34145 AddInScopeNamespace(JSContext *cx, JSXML *xml, JSObject *ns)
34147 JSLinearString *prefix, *prefix2;
34148 JSObject *match, *ns2;
34151 if (xml->xml_class != JSXML_CLASS_ELEMENT)
34155 prefix = ns->getNamePrefix();
34158 for (i = 0, n = xml->u.elem.namespaces.length; i < n; i++) {
34159 ns2 = (((i) < (&xml->u.elem.namespaces)->length) ? (JSObject *) (&xml->u.elem.namespaces)->vector[i] : __null);
34160 if (ns2 && EqualStrings(ns2->getNameURI(), ns->getNameURI())) {
34165 if (!match && !XMLArrayAddMember(cx, &xml->u.elem.namespaces, n, (void *)(ns)))
34168 if (prefix->empty() && xml->name->getNameURI()->empty())
34174 for (i = 0, n = xml->u.elem.namespaces.length; i < n; i++) {
34175 ns2 = (((i) < (&xml->u.elem.namespaces)->length) ? (JSObject *) (&xml->u.elem.namespaces)->vector[i] : __null);
34176 if (ns2 && (prefix2 = ns2->getNamePrefix()) &&
34177 EqualStrings(prefix2, prefix)) {
34183 if (match && !EqualStrings(match->getNameURI(), ns->getNameURI())) {
34184 ns2 = ((JSObject *) XMLArrayDelete(cx, &xml->u.elem.namespaces, m, (JSIntn)1))
34187 match->clearNamePrefix();
34188 if (!AddInScopeNamespace(cx, xml, match))
34191 if (!XMLArrayAddMember(cx, &xml->u.elem.namespaces, (&xml->u.elem.namespaces)->length, (void *)((ns))))
34201 Append(JSContext *cx, JSXML *list, JSXML *xml)
34207 i = list->u.list.kids.length;
34209 if (xml->xml_class == JSXML_CLASS_LIST) {
34210 list->u.list.target = xml->u.list.target;
34211 list->u.list.targetprop = xml->u.list.targetprop;
34212 n = ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (xml)->u.list.kids.length : 0);
34214 if (!list->u.list.kids.setCapacity(cx, k))
34216 for (j = 0; j < n; j++) {
34217 kid = (((j) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[j] : __null);
34219 do { if ((&list->u.list.kids)->length <= (i + j)) (&list->u.list.kids)->length = (i + j) + 1; ((&list->u.list.kids)->vector[i + j] = (void *)(kid)); } while (0);
34224 list->u.list.target = xml->parent;
34225 if (xml->xml_class == JSXML_CLASS_PROCESSING_INSTRUCTION)
34226 list->u.list.targetprop = __null;
34228 list->u.list.targetprop = xml->name;
34229 if (!XMLArrayAddMember(cx, &list->u.list.kids, i, (void *)(xml)))
34236 DeepCopyInLRS(JSContext *cx, JSXML *xml, uintN flags);
34239 DeepCopy(JSContext *cx, JSXML *xml, JSObject *obj, uintN flags)
34244 if (!js_EnterLocalRootScope(cx))
34246 copy = DeepCopyInLRS(cx, xml, flags);
34250 obj->setPrivate(copy);
34251 copy->object = obj;
34252 } else if (!js_GetXMLObject(cx, copy)) {
34256 js_LeaveLocalRootScopeWithResult(cx, copy);
34266 DeepCopySetInLRS(JSContext *cx, JSXMLArray *from, JSXMLArray *to, JSXML *parent,
34274 if (!to->setCapacity(cx, n))
34277 JSXMLArrayCursor cursor(from);
34279 while (JSXML *kid = (JSXML *) cursor.getNext()) {
34280 if ((flags & ((JSUint32)1 << (0))) &&
34281 kid->xml_class == JSXML_CLASS_COMMENT) {
34284 if ((flags & ((JSUint32)1 << (1))) &&
34285 kid->xml_class == JSXML_CLASS_PROCESSING_INSTRUCTION) {
34288 if ((flags & ((JSUint32)1 << (2))) &&
34289 (kid->xml_flags & 0x1)) {
34292 kid2 = DeepCopyInLRS(cx, kid, flags);
34298 if ((flags & ((JSUint32)1 << (2))) &&
34299 n > 1 && kid2->xml_class == JSXML_CLASS_TEXT) {
34300 str = ChompXMLWhitespace(cx, kid2->u.value);
34305 kid2->u.value = str;
34308 do { if ((to)->length <= (j)) (to)->length = (j) + 1; ((to)->vector[j] = (void *)(kid2)); } while (0);
34310 if (parent->xml_class != JSXML_CLASS_LIST)
34311 kid2->parent = parent;
34320 DeepCopyInLRS(JSContext *cx, JSXML *xml, uintN flags)
34326 JSObject *ns, *ns2;
34328 do { int stackDummy_; if (!((jsuword)(&stackDummy_) > cx->stackLimit)) { js_ReportOverRecursed(cx); return __null; } } while (0);
34330 copy = js_NewXML(cx, JSXMLClass(xml->xml_class));
34335 qn = NewXMLQName(cx, qn->getNameURI(), qn->getNamePrefix(), qn->getQNameLocalName());
34342 copy->xml_flags = xml->xml_flags;
34344 if ((((xml)->xml_class) >= JSXML_CLASS_ATTRIBUTE)) {
34345 copy->u.value = xml->u.value;
34348 ok = DeepCopySetInLRS(cx, &xml->u.list.kids, ©->u.list.kids, copy, flags);
34352 if (xml->xml_class == JSXML_CLASS_LIST) {
34353 copy->u.list.target = xml->u.list.target;
34354 copy->u.list.targetprop = xml->u.list.targetprop;
34356 n = xml->u.elem.namespaces.length;
34357 ok = copy->u.elem.namespaces.setCapacity(cx, n);
34360 for (i = 0; i < n; i++) {
34361 ns = (((i) < (&xml->u.elem.namespaces)->length) ? (JSObject *) (&xml->u.elem.namespaces)->vector[i] : __null);
34364 ns2 = NewXMLNamespace(cx, ns->getNamePrefix(), ns->getNameURI(),
34367 copy->u.elem.namespaces.length = i;
34371 do { if ((©->u.elem.namespaces)->length <= (i)) (©->u.elem.namespaces)->length = (i) + 1; ((©->u.elem.namespaces)->vector[i] = (void *)(ns2)); } while (0);
34374 ok = DeepCopySetInLRS(cx, &xml->u.elem.attrs, ©->u.elem.attrs, copy,
34389 DeleteByIndex(JSContext *cx, JSXML *xml, uint32 index)
34393 if ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) && index < xml->u.list.kids.length) {
34394 kid = (((index) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[index] : __null);
34396 kid->parent = __null;
34397 XMLArrayDelete(cx, &xml->u.list.kids, index, (JSIntn)1);
34401 typedef JSBool (*JSXMLNameMatcher)(JSObject *nameqn, JSXML *xml);
34404 MatchAttrName(JSObject *nameqn, JSXML *attr)
34406 JSObject *attrqn = attr->name;
34407 JSLinearString *localName = nameqn->getQNameLocalName();
34408 JSLinearString *uri;
34410 return (((localName)->length() == 1 && *(localName)->chars() == '*') ||
34411 EqualStrings(attrqn->getQNameLocalName(), localName)) &&
34412 (!(uri = nameqn->getNameURI()) ||
34413 EqualStrings(attrqn->getNameURI(), uri));
34417 MatchElemName(JSObject *nameqn, JSXML *elem)
34419 JSLinearString *localName = nameqn->getQNameLocalName();
34420 JSLinearString *uri;
34422 return (((localName)->length() == 1 && *(localName)->chars() == '*') ||
34423 (elem->xml_class == JSXML_CLASS_ELEMENT &&
34424 EqualStrings(elem->name->getQNameLocalName(), localName))) &&
34425 (!(uri = nameqn->getNameURI()) ||
34426 (elem->xml_class == JSXML_CLASS_ELEMENT &&
34427 EqualStrings(elem->name->getNameURI(), uri)));
34432 DescendantsHelper(JSContext *cx, JSXML *xml, JSObject *nameqn, JSXML *list)
34437 do { int stackDummy_; if (!((jsuword)(&stackDummy_) > cx->stackLimit)) { js_ReportOverRecursed(cx); return (JSIntn)0; } } while (0);
34439 if (xml->xml_class == JSXML_CLASS_ELEMENT &&
34440 nameqn->getClass() == &js_AttributeNameClass) {
34441 for (i = 0, n = xml->u.elem.attrs.length; i < n; i++) {
34442 attr = (((i) < (&xml->u.elem.attrs)->length) ? (JSXML *) (&xml->u.elem.attrs)->vector[i] : __null);
34443 if (attr && MatchAttrName(nameqn, attr)) {
34444 if (!Append(cx, list, attr))
34450 for (i = 0, n = ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (xml)->u.list.kids.length : 0); i < n; i++) {
34451 kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null);
34454 if (nameqn->getClass() != &js_AttributeNameClass &&
34455 MatchElemName(nameqn, kid)) {
34456 if (!Append(cx, list, kid))
34459 if (!DescendantsHelper(cx, kid, nameqn, list))
34466 Descendants(JSContext *cx, JSXML *xml, jsval id)
34475 nameqn = ToXMLName(cx, id, &funid);
34479 listobj = js_NewXMLObject(cx, JSXML_CLASS_LIST);
34482 list = (JSXML *) listobj->getPrivate();
34483 if (!JSID_IS_VOID(funid))
34492 list->name = nameqn;
34493 if (!js_EnterLocalRootScope(cx))
34495 if (xml->xml_class == JSXML_CLASS_LIST) {
34497 for (i = 0, n = xml->u.list.kids.length; i < n; i++) {
34498 kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null);
34499 if (kid && kid->xml_class == JSXML_CLASS_ELEMENT) {
34500 ok = DescendantsHelper(cx, kid, nameqn, list);
34506 ok = DescendantsHelper(cx, xml, nameqn, list);
34508 js_LeaveLocalRootScopeWithResult(cx, list);
34511 list->name = __null;
34517 XMLEquals(JSContext *cx, JSXML *xml, JSXML *vxml, JSBool *bp)
34519 JSObject *qn, *vqn;
34521 JSXML *kid, *vkid, *attr, *vattr;
34522 JSObject *xobj, *vobj;
34525 if (xml->xml_class != vxml->xml_class) {
34526 if (xml->xml_class == JSXML_CLASS_LIST && xml->u.list.kids.length == 1) {
34527 xml = (((0) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[0] : __null);
34531 if (vxml->xml_class == JSXML_CLASS_LIST && vxml->u.list.kids.length == 1) {
34532 vxml = (((0) < (&vxml->u.list.kids)->length) ? (JSXML *) (&vxml->u.list.kids)->vector[0] : __null);
34544 EqualStrings(qn->getQNameLocalName(), vqn->getQNameLocalName()) &&
34545 EqualStrings(qn->getNameURI(), vqn->getNameURI());
34547 *bp = vqn == __null;
34552 if ((((xml)->xml_class) >= JSXML_CLASS_ATTRIBUTE)) {
34553 if (!EqualStrings(cx, xml->u.value, vxml->u.value, bp))
34555 } else if (xml->u.list.kids.length != vxml->u.list.kids.length) {
34559 JSXMLArrayCursor cursor(&xml->u.list.kids);
34560 JSXMLArrayCursor vcursor(&vxml->u.list.kids);
34562 kid = (JSXML *) cursor.getNext();
34563 vkid = (JSXML *) vcursor.getNext();
34564 if (!kid || !vkid) {
34565 *bp = !kid && !vkid;
34568 xobj = js_GetXMLObject(cx, kid);
34569 vobj = js_GetXMLObject(cx, vkid);
34570 if (!xobj || !vobj ||
34571 !js_TestXMLEquality(cx, ObjectValue(*xobj), ObjectValue(*vobj), bp))
34578 if (*bp && xml->xml_class == JSXML_CLASS_ELEMENT) {
34579 n = xml->u.elem.attrs.length;
34580 if (n != vxml->u.elem.attrs.length)
34582 for (i = 0; *bp && i < n; i++) {
34583 attr = (((i) < (&xml->u.elem.attrs)->length) ? (JSXML *) (&xml->u.elem.attrs)->vector[i] : __null);
34586 j = XMLArrayFindMember(&vxml->u.elem.attrs, (void *)(attr), attr_identity);
34587 if (j == ((uint32) -1)) {
34591 vattr = (((j) < (&vxml->u.elem.attrs)->length) ? (JSXML *) (&vxml->u.elem.attrs)->vector[j] : __null);
34594 if (!EqualStrings(cx, attr->u.value, vattr->u.value, bp))
34605 Equals(JSContext *cx, JSXML *xml, jsval v, JSBool *bp)
34610 if (JSVAL_IS_PRIMITIVE(v)) {
34612 if (xml->xml_class == JSXML_CLASS_LIST) {
34613 if (xml->u.list.kids.length == 1) {
34614 vxml = (((0) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[0] : __null);
34617 vobj = js_GetXMLObject(cx, vxml);
34620 return js_TestXMLEquality(cx, ObjectValue(*vobj), Valueify(v), bp);
34622 if (JSVAL_IS_VOID(v) && xml->u.list.kids.length == 0)
34626 vobj = JSVAL_TO_OBJECT(v);
34627 if (!vobj->isXML()) {
34630 vxml = (JSXML *) vobj->getPrivate();
34631 if (!XMLEquals(cx, xml, vxml, bp))
34639 CheckCycle(JSContext *cx, JSXML *xml, JSXML *kid)
34645 JS_ReportErrorNumber(cx, js_GetErrorMessage, __null,
34646 JSMSG_CYCLIC_VALUE, js_XML_str);
34649 } while ((xml = xml->parent) != __null);
34656 Insert(JSContext *cx, JSXML *xml, uint32 i, jsval v)
34663 if (!(((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE))
34668 if (!JSVAL_IS_PRIMITIVE(v)) {
34669 vobj = JSVAL_TO_OBJECT(v);
34670 if (vobj->isXML()) {
34671 vxml = (JSXML *) vobj->getPrivate();
34672 if (vxml->xml_class == JSXML_CLASS_LIST) {
34673 n = vxml->u.list.kids.length;
34676 for (j = 0; j < n; j++) {
34677 kid = (((j) < (&vxml->u.list.kids)->length) ? (JSXML *) (&vxml->u.list.kids)->vector[j] : __null);
34680 if (!CheckCycle(cx, xml, kid))
34683 } else if (vxml->xml_class == JSXML_CLASS_ELEMENT) {
34685 if (!CheckCycle(cx, xml, vxml))
34691 str = js_ValueToString(cx, Valueify(v));
34695 vxml = js_NewXML(cx, JSXML_CLASS_TEXT);
34698 vxml->u.value = str;
34701 if (i > xml->u.list.kids.length)
34702 i = xml->u.list.kids.length;
34704 if (!XMLArrayInsert(cx, &xml->u.list.kids, i, n))
34707 if (vxml->xml_class == JSXML_CLASS_LIST) {
34708 for (j = 0; j < n; j++) {
34709 kid = (((j) < (&vxml->u.list.kids)->length) ? (JSXML *) (&vxml->u.list.kids)->vector[j] : __null);
34713 do { if ((&xml->u.list.kids)->length <= (i + j)) (&xml->u.list.kids)->length = (i + j) + 1; ((&xml->u.list.kids)->vector[i + j] = (void *)(kid)); } while (0);
34718 vxml->parent = xml;
34719 do { if ((&xml->u.list.kids)->length <= (i)) (&xml->u.list.kids)->length = (i) + 1; ((&xml->u.list.kids)->vector[i] = (void *)(vxml)); } while (0);
34725 IndexToId(JSContext *cx, uint32 index, jsid *idp)
34730 if (index <= ((1 << 30) - 1)) {
34731 *idp = INT_TO_JSID(index);
34733 str = js_NumberToString(cx, (jsdouble) index);
34736 atom = js_AtomizeString(cx, str, 0);
34739 *idp = ATOM_TO_JSID(atom);
34746 Replace(JSContext *cx, JSXML *xml, uint32 i, jsval v)
34753 if (!(((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE))
34761 n = xml->u.list.kids.length;
34766 if (!JSVAL_IS_PRIMITIVE(v)) {
34767 vobj = JSVAL_TO_OBJECT(v);
34769 vxml = (JSXML *) vobj->getPrivate();
34772 switch (vxml ? JSXMLClass(vxml->xml_class) : JSXML_CLASS_LIMIT) {
34773 case JSXML_CLASS_ELEMENT:
34775 if (!CheckCycle(cx, xml, vxml))
34777 case JSXML_CLASS_COMMENT:
34778 case JSXML_CLASS_PROCESSING_INSTRUCTION:
34779 case JSXML_CLASS_TEXT:
34782 case JSXML_CLASS_LIST:
34784 DeleteByIndex(cx, xml, i);
34785 if (!Insert(cx, xml, i, v))
34790 str = js_ValueToString(cx, Valueify(v));
34794 vxml = js_NewXML(cx, JSXML_CLASS_TEXT);
34797 vxml->u.value = str;
34800 vxml->parent = xml;
34802 kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null);
34804 kid->parent = __null;
34806 if (!XMLArrayAddMember(cx, &xml->u.list.kids, i, (void *)(vxml)))
34816 DeleteNamedProperty(JSContext *cx, JSXML *xml, JSObject *nameqn,
34820 uint32 index, deleteCount;
34822 JSXMLNameMatcher matcher;
34824 if (xml->xml_class == JSXML_CLASS_LIST) {
34825 array = &xml->u.list.kids;
34826 for (index = 0; index < array->length; index++) {
34827 kid = (((index) < (array)->length) ? (JSXML *) (array)->vector[index] : __null);
34828 if (kid && kid->xml_class == JSXML_CLASS_ELEMENT)
34829 DeleteNamedProperty(cx, kid, nameqn, attributes);
34831 } else if (xml->xml_class == JSXML_CLASS_ELEMENT) {
34833 array = &xml->u.elem.attrs;
34834 matcher = MatchAttrName;
34836 array = &xml->u.list.kids;
34837 matcher = MatchElemName;
34840 for (index = 0; index < array->length; index++) {
34841 kid = (((index) < (array)->length) ? (JSXML *) (array)->vector[index] : __null);
34842 if (kid && matcher(nameqn, kid)) {
34843 kid->parent = __null;
34844 XMLArrayDelete(cx, array, index, (JSIntn)0);
34846 } else if (deleteCount != 0) {
34847 do { if ((array)->length <= (index - deleteCount)) (array)->length = (index - deleteCount) + 1; ((array)->vector[index - deleteCount] = (void *)(array->vector[index])); } while (0)
34852 array->length -= deleteCount;
34858 DeleteListElement(JSContext *cx, JSXML *xml, uint32 index)
34860 JSXML *kid, *parent;
34865 if (index < xml->u.list.kids.length) {
34866 kid = (((index) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[index] : __null);
34868 parent = kid->parent;
34873 if (kid->xml_class == JSXML_CLASS_ATTRIBUTE) {
34874 DeleteNamedProperty(cx, parent, kid->name, (JSIntn)1);
34876 kidIndex = XMLArrayFindMember(&parent->u.list.kids, (void *)(kid), __null)
34879 DeleteByIndex(cx, parent, kidIndex);
34882 XMLArrayDelete(cx, &xml->u.list.kids, index, (JSIntn)1);
34888 SyncInScopeNamespaces(JSContext *cx, JSXML *xml)
34890 JSXMLArray *nsarray;
34894 nsarray = &xml->u.elem.namespaces;
34895 while ((xml = xml->parent) != __null) {
34896 for (i = 0, n = xml->u.elem.namespaces.length; i < n; i++) {
34897 ns = (((i) < (&xml->u.elem.namespaces)->length) ? (JSObject *) (&xml->u.elem.namespaces)->vector[i] : __null);
34898 if (ns && !(XMLArrayFindMember(nsarray, (void *)(ns), namespace_identity) != ((uint32) -1))) {
34899 if (!XMLArrayAddMember(cx, nsarray, (nsarray)->length, (void *)((ns))))
34908 GetNamedProperty(JSContext *cx, JSXML *xml, JSObject* nameqn, JSXML *list)
34911 JSXMLNameMatcher matcher;
34914 if (xml->xml_class == JSXML_CLASS_LIST) {
34915 JSXMLArrayCursor cursor(&xml->u.list.kids);
34916 while (JSXML *kid = (JSXML *) cursor.getNext()) {
34917 if (kid->xml_class == JSXML_CLASS_ELEMENT &&
34918 !GetNamedProperty(cx, kid, nameqn, list)) {
34922 } else if (xml->xml_class == JSXML_CLASS_ELEMENT) {
34923 attrs = (nameqn->getClass() == &js_AttributeNameClass);
34925 array = &xml->u.elem.attrs;
34926 matcher = MatchAttrName;
34928 array = &xml->u.list.kids;
34929 matcher = MatchElemName;
34932 JSXMLArrayCursor cursor(array);
34933 while (JSXML *kid = (JSXML *) cursor.getNext()) {
34934 if (matcher(nameqn, kid)) {
34936 kid->xml_class == JSXML_CLASS_ELEMENT &&
34937 !SyncInScopeNamespaces(cx, kid)) {
34940 if (!Append(cx, list, kid))
34951 GetProperty(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
34953 JSXML *xml, *list, *kid;
34955 JSObject *kidobj, *listobj;
34959 xml = (JSXML *) GetInstancePrivate(cx, obj, &js_XMLClass, __null);
34963 if (js_IdIsIndex(id, &index)) {
34964 if (!(((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE)) {
34965 *vp = (index == 0) ? OBJECT_TO_JSVAL(obj) : ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0));
34974 if (index < xml->u.list.kids.length) {
34975 kid = (((index) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[index] : __null);
34977 *vp = ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0));
34980 kidobj = js_GetXMLObject(cx, kid);
34984 *vp = OBJECT_TO_JSVAL(kidobj);
34986 *vp = ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0));
34995 nameqn = ToXMLName(cx, IdToJsval(id), &funid);
34998 if (!JSID_IS_VOID(funid))
34999 return GetXMLFunction(cx, obj, funid, vp);
35001 jsval roots[2] = { OBJECT_TO_JSVAL(nameqn), ((((uint64)(uint32)(JSVAL_TAG_NULL)) << 47) | (0)) };
35002 AutoArrayRooter tvr(cx, (sizeof (roots) / sizeof (roots)[0]), Valueify(roots));
35004 listobj = js_NewXMLObject(cx, JSXML_CLASS_LIST);
35008 roots[1] = OBJECT_TO_JSVAL(listobj);
35010 list = (JSXML *) listobj->getPrivate();
35011 if (!GetNamedProperty(cx, xml, nameqn, list))
35014 list->u.list.target = xml;
35015 list->u.list.targetprop = nameqn;
35016 *vp = OBJECT_TO_JSVAL(listobj);
35021 CopyOnWrite(JSContext *cx, JSXML *xml, JSObject *obj)
35025 xml = DeepCopy(cx, xml, obj, 0);
35037 KidToString(JSContext *cx, JSXML *xml, uint32 index)
35042 kid = (((index) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[index] : __null);
35044 return cx->runtime->emptyString;
35045 kidobj = js_GetXMLObject(cx, kid);
35048 return js_ValueToString(cx, ObjectValue(*kidobj));
35053 ResolveValue(JSContext *cx, JSXML *list, JSXML **result);
35057 PutProperty(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp)
35059 JSBool ok, primitiveAssign;
35060 enum { OBJ_ROOT, ID_ROOT, VAL_ROOT };
35061 JSXML *xml, *vxml, *rxml, *kid, *attr, *parent, *copy, *kid2, *match;
35062 JSObject *vobj, *nameobj, *attrobj, *parentobj, *kidobj, *copyobj;
35063 JSObject *targetprop, *nameqn, *attrqn;
35064 uint32 index, i, j, k, n, q, matchIndex;
35065 jsval attrval, nsval;
35069 xml = (JSXML *) GetInstancePrivate(cx, obj, &js_XMLClass, __null);
35073 xml = (xml->object == obj ? xml : CopyOnWrite(cx, xml, obj));
35079 if (!JSVAL_IS_PRIMITIVE(*vp)) {
35080 vobj = JSVAL_TO_OBJECT(*vp);
35082 vxml = (JSXML *) vobj->getPrivate();
35085 ok = js_EnterLocalRootScope(cx);
35091 roots[OBJ_ROOT] = OBJECT_TO_JSVAL(obj);
35092 roots[ID_ROOT] = IdToJsval(id);
35093 roots[VAL_ROOT] = *vp;
35094 AutoArrayRooter tvr(cx, (sizeof (roots) / sizeof (roots)[0]), Valueify(roots));
35096 if (js_IdIsIndex(id, &index)) {
35097 if (xml->xml_class != JSXML_CLASS_LIST) {
35099 ReportBadXMLName(cx, IdToValue(id));
35109 if (xml->u.list.target) {
35110 ok = ResolveValue(cx, xml->u.list.target, &rxml);
35121 if (index >= xml->u.list.kids.length) {
35124 if (rxml->xml_class == JSXML_CLASS_LIST) {
35125 if (rxml->u.list.kids.length != 1)
35127 rxml = (((0) < (&rxml->u.list.kids)->length) ? (JSXML *) (&rxml->u.list.kids)->vector[0] : __null);
35130 ok = js_GetXMLObject(cx, rxml) != __null;
35135 if (!(((rxml)->xml_class) < JSXML_CLASS_ATTRIBUTE))
35140 targetprop = xml->u.list.targetprop;
35141 if (!targetprop || ((targetprop->getQNameLocalName())->length() == 1 && *(targetprop->getQNameLocalName())->chars() == '*')) {
35143 kid = js_NewXML(cx, JSXML_CLASS_TEXT);
35147 nameobj = targetprop;
35148 if (nameobj->getClass() == &js_AttributeNameClass) {
35154 ok = GetProperty(cx, rxml->object, id, &attrval);
35157 if (JSVAL_IS_PRIMITIVE(attrval))
35159 attrobj = JSVAL_TO_OBJECT(attrval);
35160 attr = (JSXML *) attrobj->getPrivate();
35161 if (((((attr)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (attr)->u.list.kids.length : 0) != 0)
35164 kid = js_NewXML(cx, JSXML_CLASS_ATTRIBUTE);
35167 kid = js_NewXML(cx, JSXML_CLASS_ELEMENT);
35173 kid->name = targetprop;
35177 kid->parent = rxml;
35180 i = xml->u.list.kids.length;
35181 if (kid->xml_class != JSXML_CLASS_ATTRIBUTE) {
35190 n = rxml->u.list.kids.length;
35192 if (n != 0 && i != 0) {
35193 for (n = j, j = 0; j < n; j++) {
35194 if (rxml->u.list.kids.vector[j] ==
35195 xml->u.list.kids.vector[i-1]) {
35201 kidobj = js_GetXMLObject(cx, kid);
35204 ok = Insert(cx, rxml, j + 1, OBJECT_TO_JSVAL(kidobj));
35215 kid->name = (vxml->xml_class == JSXML_CLASS_LIST)
35216 ? vxml->u.list.targetprop
35222 ok = Append(cx, xml, kid);
35229 vxml->xml_class == JSXML_CLASS_TEXT ||
35230 vxml->xml_class == JSXML_CLASS_ATTRIBUTE) {
35231 ok = JS_ConvertValue(cx, *vp, JSTYPE_STRING, vp);
35234 roots[VAL_ROOT] = *vp;
35238 kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null);
35241 parent = kid->parent;
35242 if (kid->xml_class == JSXML_CLASS_ATTRIBUTE) {
35243 nameobj = kid->name;
35244 if (nameobj->getClass() != &js_AttributeNameClass) {
35245 nameobj = NewXMLAttributeName(cx, nameobj->getNameURI(), nameobj->getNamePrefix(),
35246 nameobj->getQNameLocalName());
35250 id = OBJECT_TO_JSID(nameobj);
35254 parentobj = js_GetXMLObject(cx, parent);
35257 ok = PutProperty(cx, parentobj, id, strict, vp);
35262 ok = GetProperty(cx, parentobj, id, vp);
35265 attr = (JSXML *) JSVAL_TO_OBJECT(*vp)->getPrivate();
35268 if (attr->u.list.kids.length != 0)
35269 xml->u.list.kids.vector[i] = attr->u.list.kids.vector[0];
35274 else if (vxml && vxml->xml_class == JSXML_CLASS_LIST) {
35276 copy = DeepCopyInLRS(cx, vxml, 0);
35279 copyobj = js_GetXMLObject(cx, copy);
35285 q = XMLArrayFindMember(&parent->u.list.kids, (void *)(kid), __null);
35287 ok = Replace(cx, parent, q, OBJECT_TO_JSVAL(copyobj));
35298 n = copy->u.list.kids.length;
35300 XMLArrayDelete(cx, &xml->u.list.kids, i, (JSIntn)1);
35302 ok = XMLArrayInsert(cx, &xml->u.list.kids, i + 1, n - 1);
35306 for (j = 0; j < n; j++)
35307 xml->u.list.kids.vector[i + j] = copy->u.list.kids.vector[j];
35312 else if (vxml || (((kid)->xml_class) >= JSXML_CLASS_ATTRIBUTE)) {
35314 q = XMLArrayFindMember(&parent->u.list.kids, (void *)(kid), __null);
35316 ok = Replace(cx, parent, q, *vp);
35320 vxml = (((q) < (&parent->u.list.kids)->length) ? (JSXML *) (&parent->u.list.kids)->vector[q] : __null);
35323 roots[VAL_ROOT] = *vp = OBJECT_TO_JSVAL(vxml->object);
35328 vobj = ToXML(cx, *vp);
35331 roots[VAL_ROOT] = *vp = OBJECT_TO_JSVAL(vobj);
35332 vxml = (JSXML *) vobj->getPrivate();
35334 do { if ((&xml->u.list.kids)->length <= (i)) (&xml->u.list.kids)->length = (i) + 1; ((&xml->u.list.kids)->vector[i] = (void *)(vxml)); } while (0);
35339 kidobj = js_GetXMLObject(cx, kid);
35342 id = ATOM_TO_JSID(cx->runtime->atomState.starAtom);
35343 ok = PutProperty(cx, kidobj, id, strict, vp);
35351 nameqn = ToXMLName(cx, IdToJsval(id), &funid);
35354 if (!JSID_IS_VOID(funid)) {
35355 ok = js_SetProperty(cx, obj, funid, Valueify(vp), false);
35359 roots[ID_ROOT] = OBJECT_TO_JSVAL(nameobj);
35361 if (xml->xml_class == JSXML_CLASS_LIST) {
35367 n = ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (xml)->u.list.kids.length : 0);
35371 ok = ResolveValue(cx, xml, &rxml);
35374 if (!rxml || ((((rxml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (rxml)->u.list.kids.length : 0) != 1)
35376 ok = Append(cx, xml, rxml);
35381 xml = (((0) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[0] : __null);
35385 obj = js_GetXMLObject(cx, xml);
35388 roots[OBJ_ROOT] = OBJECT_TO_JSVAL(obj);
35399 if ((((xml)->xml_class) >= JSXML_CLASS_ATTRIBUTE))
35403 vxml->xml_class == JSXML_CLASS_TEXT ||
35404 vxml->xml_class == JSXML_CLASS_ATTRIBUTE) {
35405 ok = JS_ConvertValue(cx, *vp, JSTYPE_STRING, vp);
35409 rxml = DeepCopyInLRS(cx, vxml, 0);
35410 if (!rxml || !js_GetXMLObject(cx, rxml))
35413 *vp = OBJECT_TO_JSVAL(vxml->object);
35415 roots[VAL_ROOT] = *vp;
35421 ok = js_GetDefaultXMLNamespace(cx, &nsval);
35425 if (nameobj->getClass() == &js_AttributeNameClass) {
35427 if (!js_IsXMLName(cx, OBJECT_TO_JSVAL(nameobj)))
35431 if (vxml && vxml->xml_class == JSXML_CLASS_LIST) {
35432 n = vxml->u.list.kids.length;
35434 *vp = STRING_TO_JSVAL(cx->runtime->emptyString);
35436 JSString *left = KidToString(cx, vxml, 0);
35440 JSString *space = cx->runtime->atomState.spaceAtom;
35441 for (i = 1; i < n; i++) {
35442 left = js_ConcatStrings(cx, left, space);
35445 JSString *right = KidToString(cx, vxml, i);
35448 left = js_ConcatStrings(cx, left, right);
35453 roots[VAL_ROOT] = *vp = STRING_TO_JSVAL(left);
35456 ok = JS_ConvertValue(cx, *vp, JSTYPE_STRING, vp);
35459 roots[VAL_ROOT] = *vp;
35464 for (i = 0, n = xml->u.elem.attrs.length; i < n; i++) {
35465 attr = (((i) < (&xml->u.elem.attrs)->length) ? (JSXML *) (&xml->u.elem.attrs)->vector[i] : __null);
35468 attrqn = attr->name;
35469 if (EqualStrings(attrqn->getQNameLocalName(), nameqn->getQNameLocalName())) {
35470 JSLinearString *uri = nameqn->getNameURI();
35471 if (!uri || EqualStrings(attrqn->getNameURI(), uri)) {
35475 DeleteNamedProperty(cx, xml, attrqn, (JSIntn)1);
35486 JSLinearString *uri = nameqn->getNameURI();
35487 JSLinearString *left, *right;
35489 left = right = cx->runtime->emptyString;
35492 right = nameqn->getNamePrefix();
35494 nameqn = NewXMLQName(cx, left, right, nameqn->getQNameLocalName());
35499 attr = js_NewXML(cx, JSXML_CLASS_ATTRIBUTE);
35502 attr->parent = xml;
35503 attr->name = nameqn;
35506 ok = XMLArrayAddMember(cx, &xml->u.elem.attrs, n, (void *)(attr));
35511 ns = GetNamespace(cx, nameqn, __null);
35514 ok = AddInScopeNamespace(cx, xml, ns);
35520 attr->u.value = JSVAL_TO_STRING(*vp);
35525 if (!js_IsXMLName(cx, OBJECT_TO_JSVAL(nameobj)) &&
35526 !((nameqn->getQNameLocalName())->length() == 1 && *(nameqn->getQNameLocalName())->chars() == '*')) {
35532 primitiveAssign = !vxml && !((nameqn->getQNameLocalName())->length() == 1 && *(nameqn->getQNameLocalName())->chars() == '*');
35535 k = n = xml->u.list.kids.length;
35536 matchIndex = ((uint32) -1);
35540 kid = (((k) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[k] : __null);
35541 if (kid && MatchElemName(nameqn, kid)) {
35542 if (matchIndex != ((uint32) -1))
35543 DeleteByIndex(cx, xml, matchIndex);
35552 kid2->parent = xml;
35556 if (matchIndex == ((uint32) -1)) {
35561 if (primitiveAssign) {
35562 JSLinearString *uri = nameqn->getNameURI();
35563 JSLinearString *left, *right;
35565 ns = JSVAL_TO_OBJECT(nsval);
35566 left = ns->getNameURI();
35567 right = ns->getNamePrefix();
35570 right = nameqn->getNamePrefix();
35572 nameqn = NewXMLQName(cx, left, right, nameqn->getQNameLocalName());
35577 vobj = js_NewXMLObject(cx, JSXML_CLASS_ELEMENT);
35580 vxml = (JSXML *) vobj->getPrivate();
35581 vxml->parent = xml;
35582 vxml->name = nameqn;
35585 ns = GetNamespace(cx, nameqn, __null);
35588 ok = Replace(cx, xml, matchIndex, OBJECT_TO_JSVAL(vobj));
35591 ok = AddInScopeNamespace(cx, vxml, ns);
35598 if (primitiveAssign) {
35599 JSXMLArrayCursor cursor(&xml->u.list.kids);
35600 cursor.index = matchIndex;
35601 kid = (JSXML *) cursor.getCurrent();
35602 if ((((kid)->xml_class) < JSXML_CLASS_ATTRIBUTE)) {
35603 kid->u.list.kids.finish(cx);
35604 kid->u.list.kids.init();
35605 ok = kid->u.list.kids.setCapacity(cx, 1);
35611 ok = JS_ConvertValue(cx, *vp, JSTYPE_STRING, vp);
35612 if (ok && !JSVAL_TO_STRING(*vp)->empty()) {
35613 roots[VAL_ROOT] = *vp;
35614 if ((JSXML *) cursor.getCurrent() == kid)
35615 ok = Replace(cx, kid, 0, *vp);
35620 ok = Replace(cx, xml, matchIndex, *vp);
35625 js_LeaveLocalRootScope(cx);
35630 JSAutoByteString bytes;
35631 if (js_ValueToPrintable(cx, IdToValue(id), &bytes))
35632 JS_ReportErrorNumber(cx, js_GetErrorMessage, __null, JSMSG_BAD_XMLLIST_PUT, bytes.ptr());
35641 ResolveValue(JSContext *cx, JSXML *list, JSXML **result)
35643 JSXML *target, *base;
35644 JSObject *targetprop;
35648 if (list->xml_class != JSXML_CLASS_LIST || list->u.list.kids.length != 0) {
35649 if (!js_GetXMLObject(cx, list))
35655 target = list->u.list.target;
35656 targetprop = list->u.list.targetprop;
35657 if (!target || !targetprop || ((targetprop->getQNameLocalName())->length() == 1 && *(targetprop->getQNameLocalName())->chars() == '*')) {
35662 if (targetprop->getClass() == &js_AttributeNameClass) {
35667 if (!ResolveValue(cx, target, &base))
35673 if (!js_GetXMLObject(cx, base))
35676 id = OBJECT_TO_JSID(targetprop);
35677 if (!GetProperty(cx, base->object, id, &tv))
35679 target = (JSXML *) JSVAL_TO_OBJECT(tv)->getPrivate();
35681 if (((((target)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (target)->u.list.kids.length : 0) == 0) {
35682 if (base->xml_class == JSXML_CLASS_LIST && ((((base)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (base)->u.list.kids.length : 0) > 1) {
35686 tv = STRING_TO_JSVAL(cx->runtime->emptyString);
35687 if (!PutProperty(cx, base->object, id, false, &tv))
35689 if (!GetProperty(cx, base->object, id, &tv))
35691 target = (JSXML *) JSVAL_TO_OBJECT(tv)->getPrivate();
35699 HasNamedProperty(JSXML *xml, JSObject *nameqn)
35703 JSXMLNameMatcher matcher;
35706 if (xml->xml_class == JSXML_CLASS_LIST) {
35708 JSXMLArrayCursor cursor(&xml->u.list.kids);
35709 while (JSXML *kid = (JSXML *) cursor.getNext()) {
35710 found = HasNamedProperty(kid, nameqn);
35717 if (xml->xml_class == JSXML_CLASS_ELEMENT) {
35718 if (nameqn->getClass() == &js_AttributeNameClass) {
35719 array = &xml->u.elem.attrs;
35720 matcher = MatchAttrName;
35722 array = &xml->u.list.kids;
35723 matcher = MatchElemName;
35725 for (i = 0, n = array->length; i < n; i++) {
35726 JSXML *kid = (((i) < (array)->length) ? (JSXML *) (array)->vector[i] : __null);
35727 if (kid && matcher(nameqn, kid))
35736 HasIndexedProperty(JSXML *xml, uint32 i)
35738 if (xml->xml_class == JSXML_CLASS_LIST)
35739 return i < ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (xml)->u.list.kids.length : 0);
35741 if (xml->xml_class == JSXML_CLASS_ELEMENT)
35748 HasSimpleContent(JSXML *xml);
35751 HasFunctionProperty(JSContext *cx, JSObject *obj, jsid funid, JSBool *found)
35759 if (!js_LookupProperty(cx, obj, funid, &pobj, &prop))
35762 xml = (JSXML *) obj->getPrivate();
35763 if (HasSimpleContent(xml)) {
35764 AutoObjectRooter tvr(cx);
35770 if (!js_GetClassPrototype(cx, __null, JSProto_String, tvr.addr()))
35774 if (!js_LookupProperty(cx, tvr.object(), funid, &pobj, &prop))
35778 *found = (prop != __null);
35784 HasProperty(JSContext *cx, JSObject *obj, jsval id, JSBool *found)
35792 xml = (JSXML *) obj->getPrivate();
35793 if (!js_IdValIsIndex(cx, id, &i, &isIndex))
35797 *found = HasIndexedProperty(xml, i);
35799 qn = ToXMLName(cx, id, &funid);
35802 if (!JSID_IS_VOID(funid)) {
35803 if (!HasFunctionProperty(cx, obj, funid, found))
35806 *found = HasNamedProperty(xml, qn);
35813 xml_finalize(JSContext *cx, JSObject *obj)
35815 JSXML *xml = (JSXML *) obj->getPrivate();
35818 if (xml->object == obj)
35819 xml->object = __null;
35823 xml_trace_vector(JSTracer *trc, JSXML **vec, uint32 len)
35828 for (i = 0; i < len; i++) {
35838 xml_lookupProperty(JSContext *cx, JSObject *obj, jsid id, JSObject **objp,
35839 JSProperty **propp)
35847 xml = (JSXML *) obj->getPrivate();
35848 if (js_IdIsIndex(id, &i)) {
35849 found = HasIndexedProperty(xml, i);
35851 qn = ToXMLName(cx, IdToJsval(id), &funid);
35854 if (!JSID_IS_VOID(funid))
35855 return js_LookupProperty(cx, obj, funid, objp, propp);
35856 found = HasNamedProperty(xml, qn);
35862 const Shape *shape =
35863 js_AddNativeProperty(cx, obj, id,
35864 Valueify(GetProperty), Valueify(PutProperty),
35871 *propp = (JSProperty *) shape;
35877 xml_defineProperty(JSContext *cx, JSObject *obj, jsid id, const Value *v,
35878 PropertyOp getter, StrictPropertyOp setter, uintN attrs)
35880 if (IsFunctionObject(*v) || getter || setter ||
35881 (attrs & 0x01) == 0 ||
35882 (attrs & (0x02 | 0x04 | 0x40))) {
35883 return js_DefineProperty(cx, obj, id, v, getter, setter, attrs);
35886 jsval tmp = Jsvalify(*v);
35887 return PutProperty(cx, obj, id, false, &tmp);
35891 xml_getProperty(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp)
35893 if (JSID_IS_DEFAULT_XML_NAMESPACE(id)) {
35894 vp->setUndefined();
35898 return GetProperty(cx, obj, id, Jsvalify(vp));
35902 xml_setProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp, JSBool strict)
35904 return PutProperty(cx, obj, id, strict, Jsvalify(vp));
35908 xml_getAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
35911 if (!HasProperty(cx, obj, IdToJsval(id), &found))
35914 *attrsp = found ? 0x01 : 0;
35919 xml_setAttributes(JSContext *cx, JSObject *obj, jsid id, uintN *attrsp)
35922 if (!HasProperty(cx, obj, IdToJsval(id), &found))
35926 JS_ReportErrorNumber(cx, js_GetErrorMessage, __null,
35927 JSMSG_CANT_SET_XML_ATTRS);
35934 xml_deleteProperty(JSContext *cx, JSObject *obj, jsid id, Value *rval, JSBool strict)
35942 idval = IdToJsval(id);
35943 xml = (JSXML *) obj->getPrivate();
35944 if (js_IdIsIndex(id, &index)) {
35945 if (xml->xml_class != JSXML_CLASS_LIST) {
35947 ReportBadXMLName(cx, IdToValue(id));
35952 DeleteListElement(cx, xml, index);
35954 nameqn = ToXMLName(cx, idval, &funid);
35957 if (!JSID_IS_VOID(funid))
35958 return js_DeleteProperty(cx, obj, funid, rval, false);
35960 DeleteNamedProperty(cx, xml, nameqn,
35961 nameqn->getClass() == &js_AttributeNameClass);
35964 if (!obj->nativeEmpty() && !js_DeleteProperty(cx, obj, id, rval, false))
35967 rval->setBoolean(true);
35972 xml_convert(JSContext *cx, JSObject *obj, JSType type, Value *rval)
35974 return js_TryMethod(cx, obj, cx->runtime->atomState.toStringAtom, 0, __null, rval);
35978 xml_enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op, Value *statep, jsid *idp)
35981 uint32 length, index;
35982 JSXMLArrayCursor *cursor;
35984 xml = (JSXML *)obj->getPrivate();
35985 length = ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (xml)->u.list.kids.length : 0);
35988 case JSENUMERATE_INIT:
35989 case JSENUMERATE_INIT_ALL:
35991 statep->setInt32(0);
35993 cursor = cx->create<JSXMLArrayCursor>(&xml->u.list.kids);
35996 statep->setPrivate(cursor);
35999 *idp = INT_TO_JSID(length);
36002 case JSENUMERATE_NEXT:
36003 if (statep->isInt32(0)) {
36007 cursor = (JSXMLArrayCursor *) statep->toPrivate();
36008 if (cursor && cursor->array && (index = cursor->index) < length) {
36009 *idp = INT_TO_JSID(index);
36010 cursor->index = index + 1;
36015 case JSENUMERATE_DESTROY:
36016 if (!statep->isInt32(0)) {
36017 cursor = (JSXMLArrayCursor *) statep->toPrivate();
36019 cx->destroy(cursor);
36028 xml_typeOf(JSContext *cx, JSObject *obj)
36034 xml_hasInstance(JSContext *cx, JSObject *obj, const Value *, JSBool *bp)
36040 xml_trace(JSTracer *trc, JSObject *obj)
36042 JSXML *xml = (JSXML *) obj->getPrivate();
36044 do { do { } while (0); JS_CallTracer((trc), (xml), (2)); } while (0);
36048 xml_fix(JSContext *cx, JSObject *obj, bool *success, AutoIdVector *props)
36056 xml_clear(JSContext *cx, JSObject *obj)
36061 HasSimpleContent(JSXML *xml)
36068 switch (xml->xml_class) {
36069 case JSXML_CLASS_COMMENT:
36070 case JSXML_CLASS_PROCESSING_INSTRUCTION:
36072 case JSXML_CLASS_LIST:
36073 if (xml->u.list.kids.length == 0)
36075 if (xml->u.list.kids.length == 1) {
36076 kid = (((0) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[0] : __null);
36084 simple = (JSIntn)1;
36085 for (i = 0, n = ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (xml)->u.list.kids.length : 0); i < n; i++) {
36086 kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null);
36087 if (kid && kid->xml_class == JSXML_CLASS_ELEMENT) {
36088 simple = (JSIntn)0;
36100 js_GetXMLMethod(JSContext *cx, JSObject *obj, jsid id, Value *vp)
36104 if (JSID_IS_OBJECT(id)) {
36107 if (!js_IsFunctionQName(cx, JSID_TO_OBJECT(id), &funid))
36109 if (!JSID_IS_VOID(funid))
36117 AutoValueRooter tvr(cx);
36118 JSBool ok = GetXMLFunction(cx, obj, id, Jsvalify(tvr.addr()));
36124 js_TestXMLEquality(JSContext *cx, const Value &v1, const Value &v2, JSBool *bp)
36129 JSString *str, *vstr;
36134 if (v1.isObject() && v1.toObject().isXML()) {
36135 obj = &v1.toObject();
36139 obj = &v2.toObject();
36144 xml = (JSXML *) obj->getPrivate();
36146 if (!JSVAL_IS_PRIMITIVE(v)) {
36147 vobj = JSVAL_TO_OBJECT(v);
36149 vxml = (JSXML *) vobj->getPrivate();
36152 if (xml->xml_class == JSXML_CLASS_LIST) {
36153 ok = Equals(cx, xml, v, bp);
36155 if (vxml->xml_class == JSXML_CLASS_LIST) {
36156 ok = Equals(cx, vxml, OBJECT_TO_JSVAL(obj), bp);
36158 if (((xml->xml_class == JSXML_CLASS_TEXT ||
36159 xml->xml_class == JSXML_CLASS_ATTRIBUTE) &&
36160 HasSimpleContent(vxml)) ||
36161 ((vxml->xml_class == JSXML_CLASS_TEXT ||
36162 vxml->xml_class == JSXML_CLASS_ATTRIBUTE) &&
36163 HasSimpleContent(xml))) {
36164 ok = js_EnterLocalRootScope(cx);
36166 ok = (str = js_ValueToString(cx, ObjectValue(*obj))) &&
36167 (vstr = js_ValueToString(cx, Valueify(v)));
36169 ok = EqualStrings(cx, str, vstr, bp);
36170 js_LeaveLocalRootScope(cx);
36173 ok = XMLEquals(cx, xml, vxml, bp);
36177 ok = js_EnterLocalRootScope(cx);
36179 if (HasSimpleContent(xml)) {
36180 ok = (str = js_ValueToString(cx, ObjectValue(*obj))) &&
36181 (vstr = js_ValueToString(cx, Valueify(v)));
36183 ok = EqualStrings(cx, str, vstr, bp);
36184 } else if (JSVAL_IS_STRING(v) || JSVAL_IS_NUMBER(v)) {
36185 str = js_ValueToString(cx, ObjectValue(*obj));
36188 } else if (JSVAL_IS_STRING(v)) {
36189 ok = EqualStrings(cx, str, JSVAL_TO_STRING(v), bp);
36191 ok = JS_ValueToNumber(cx, STRING_TO_JSVAL(str), &d);
36193 d2 = JSVAL_IS_INT(v) ? JSVAL_TO_INT(v)
36194 : JSVAL_TO_DOUBLE(v);
36195 *bp = ((d) == (d2));
36201 js_LeaveLocalRootScope(cx);
36208 js_ConcatenateXML(JSContext *cx, JSObject *obj, JSObject *robj, Value *vp)
36212 JSXML *list, *lxml, *rxml;
36215 ok = js_EnterLocalRootScope(cx);
36219 listobj = js_NewXMLObject(cx, JSXML_CLASS_LIST);
36225 list = (JSXML *) listobj->getPrivate();
36226 lxml = (JSXML *) obj->getPrivate();
36227 ok = Append(cx, list, lxml);
36232 rxml = (JSXML *) robj->getPrivate();
36233 ok = Append(cx, list, rxml);
36237 vp->setObject(*listobj);
36239 js_LeaveLocalRootScopeWithResult(cx, *vp);
36243 __attribute__((visibility ("default"))) Class js_XMLClass = {
36245 (1<<0) | (1<<((8 + 8)+3)) |
36246 ((JSProto_XML) << ((8 + 8) + 8)),
36250 StrictPropertyStub,
36261 ((JSMarkOp)(xml_trace)),
36262 {__null,__null,__null,__null,__null},
36264 xml_lookupProperty,
36265 xml_defineProperty,
36270 xml_deleteProperty,
36281 StartNonListXMLMethod(JSContext *cx, jsval *vp, JSObject **objp)
36289 *objp = ToObject(cx, Valueify(&vp[1]));
36292 xml = (JSXML *) GetInstancePrivate(cx, *objp, &js_XMLClass, Valueify(vp + 2));
36293 if (!xml || xml->xml_class != JSXML_CLASS_LIST)
36296 if (xml->u.list.kids.length == 1) {
36297 xml = (((0) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[0] : __null);
36299 *objp = js_GetXMLObject(cx, xml);
36302 vp[1] = OBJECT_TO_JSVAL(*objp);
36307 fun = (((void) 0), (JSFunction *) (JSVAL_TO_OBJECT(*vp))->getPrivate());
36308 JS_snprintf(numBuf, sizeof numBuf, "%u", xml->u.list.kids.length);
36309 JSAutoByteString funNameBytes;
36310 if (const char *funName = GetFunctionNameBytes(cx, fun, &funNameBytes)) {
36311 JS_ReportErrorNumber(cx, js_GetErrorMessage, __null, JSMSG_NON_LIST_XML_METHOD,
36318 xml_addNamespace(JSContext *cx, uintN argc, jsval *vp)
36322 JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0);
36323 if (xml->xml_class != JSXML_CLASS_ELEMENT)
36325 xml = (xml->object == obj ? xml : CopyOnWrite(cx, xml, obj));
36329 if (!NamespaceHelper(cx, __null, argc == 0 ? -1 : 1, vp + 2, vp))
36333 ns = JSVAL_TO_OBJECT(*vp);
36334 if (!AddInScopeNamespace(cx, xml, ns))
36336 ns->setNamespaceDeclared(((((uint64)(uint32)(JSVAL_TAG_BOOLEAN)) << 47) | ((JSIntn)1)));
36339 *vp = OBJECT_TO_JSVAL(obj);
36344 xml_appendChild(JSContext *cx, uintN argc, jsval *vp)
36350 JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0);
36351 xml = (xml->object == obj ? xml : CopyOnWrite(cx, xml, obj));
36356 if (!js_GetAnyName(cx, &name))
36359 if (!GetProperty(cx, obj, name, &v))
36363 vobj = JSVAL_TO_OBJECT(v);
36365 vxml = (JSXML *) vobj->getPrivate();
36368 if (!IndexToId(cx, vxml->u.list.kids.length, &name))
36370 *vp = (argc != 0) ? vp[2] : ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0));
36372 if (!PutProperty(cx, JSVAL_TO_OBJECT(v), name, false, vp))
36375 *vp = OBJECT_TO_JSVAL(obj);
36381 xml_attribute(JSContext *cx, uintN argc, jsval *vp)
36386 js_ReportMissingArg(cx, Valueify(*vp), 0);
36390 qn = ToAttributeName(cx, vp[2]);
36393 vp[2] = OBJECT_TO_JSVAL(qn);
36395 jsid id = OBJECT_TO_JSID(qn);
36396 JSObject *obj = ToObject(cx, Valueify(&vp[1]));
36399 return GetProperty(cx, obj, id, vp);
36404 xml_attributes(JSContext *cx, uintN argc, jsval *vp)
36406 jsval name = STRING_TO_JSVAL((cx->runtime->atomState.starAtom));
36407 JSObject *qn = ToAttributeName(cx, name);
36411 AutoObjectRooter tvr(cx, qn);
36412 jsid id = OBJECT_TO_JSID(qn);
36413 JSObject *obj = ToObject(cx, Valueify(&vp[1]));
36416 return GetProperty(cx, obj, id, vp);
36420 xml_list_helper(JSContext *cx, JSXML *xml, jsval *rval)
36425 listobj = js_NewXMLObject(cx, JSXML_CLASS_LIST);
36429 *rval = OBJECT_TO_JSVAL(listobj);
36430 list = (JSXML *) listobj->getPrivate();
36431 list->u.list.target = xml;
36436 ValueToId(JSContext *cx, jsval v, AutoIdRooter *idr)
36438 if (JSVAL_IS_INT(v)) {
36439 jsint i = JSVAL_TO_INT(v);
36440 if (INT_FITS_IN_JSID(i))
36441 *idr->addr() = INT_TO_JSID(i);
36442 else if (!js_ValueToStringId(cx, Valueify(v), idr->addr()))
36444 } else if (JSVAL_IS_STRING(v)) {
36445 JSAtom *atom = js_AtomizeString(cx, JSVAL_TO_STRING(v), 0);
36448 *idr->addr() = ATOM_TO_JSID(atom);
36449 } else if (!JSVAL_IS_PRIMITIVE(v)) {
36450 *idr->addr() = OBJECT_TO_JSID(JSVAL_TO_OBJECT(v));
36452 ReportBadXMLName(cx, Valueify(v));
36459 xml_child_helper(JSContext *cx, JSObject *obj, JSXML *xml, jsval name,
36470 if (!js_IdValIsIndex(cx, name, &index, &isIndex))
36474 if (index >= ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (xml)->u.list.kids.length : 0)) {
36475 *rval = ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0));
36477 kid = (((index) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[index] : __null);
36479 *rval = ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0));
36481 kidobj = js_GetXMLObject(cx, kid);
36484 *rval = OBJECT_TO_JSVAL(kidobj);
36490 AutoIdRooter idr(cx);
36491 if (!ValueToId(cx, name, &idr))
36494 return GetProperty(cx, obj, idr.id(), rval);
36499 xml_child(JSContext *cx, uintN argc, jsval *vp)
36502 JSXML *list, *vxml;
36505 JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0;
36506 jsval name = argc != 0 ? vp[2] : ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0));
36507 if (xml->xml_class == JSXML_CLASS_LIST) {
36509 list = xml_list_helper(cx, xml, vp);
36513 JSXMLArrayCursor cursor(&xml->u.list.kids);
36514 while (JSXML *kid = (JSXML *) cursor.getNext()) {
36515 kidobj = js_GetXMLObject(cx, kid);
36518 if (!xml_child_helper(cx, kidobj, kid, name, &v))
36520 if (JSVAL_IS_VOID(v)) {
36526 vxml = (JSXML *) JSVAL_TO_OBJECT(v)->getPrivate();
36527 if ((!(((vxml)->xml_class) < JSXML_CLASS_ATTRIBUTE) || vxml->u.list.kids.length != 0) &&
36528 !Append(cx, list, vxml)) {
36536 if (!xml_child_helper(cx, obj, xml, name, vp))
36538 if (JSVAL_IS_VOID(*vp) && !xml_list_helper(cx, xml, vp))
36544 xml_childIndex(JSContext *cx, uintN argc, jsval *vp)
36549 JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0);
36550 parent = xml->parent;
36551 if (!parent || xml->xml_class == JSXML_CLASS_ATTRIBUTE) {
36552 *vp = DOUBLE_TO_JSVAL(js_NaN);
36555 for (i = 0, n = ((((parent)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (parent)->u.list.kids.length : 0); i < n; i++) {
36556 if ((((i) < (&parent->u.list.kids)->length) ? (JSXML *) (&parent->u.list.kids)->vector[i] : __null) == xml)
36560 if (i <= ((jsint)0x7fffffff))
36561 *vp = INT_TO_JSVAL(i);
36563 *vp = DOUBLE_TO_JSVAL(i);
36569 xml_children(JSContext *cx, uintN argc, jsval *vp)
36571 JSObject *obj = ToObject(cx, Valueify(&vp[1]));
36574 jsid name = ATOM_TO_JSID(cx->runtime->atomState.starAtom);
36575 return GetProperty(cx, obj, name, vp);
36580 xml_comments_helper(JSContext *cx, JSObject *obj, JSXML *xml, jsval *vp)
36582 JSXML *list, *kid, *vxml;
36588 list = xml_list_helper(cx, xml, vp);
36594 if (xml->xml_class == JSXML_CLASS_LIST) {
36596 for (i = 0, n = ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (xml)->u.list.kids.length : 0); i < n; i++) {
36597 kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null);
36598 if (kid && kid->xml_class == JSXML_CLASS_ELEMENT) {
36599 ok = js_EnterLocalRootScope(cx);
36602 kidobj = js_GetXMLObject(cx, kid);
36604 ok = xml_comments_helper(cx, kidobj, kid, &v);
36607 v = ((((uint64)(uint32)(JSVAL_TAG_NULL)) << 47) | (0));
36609 js_LeaveLocalRootScopeWithResult(cx, Valueify(v));
36612 vxml = (JSXML *) JSVAL_TO_OBJECT(v)->getPrivate();
36613 if (((((vxml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (vxml)->u.list.kids.length : 0) != 0) {
36614 ok = Append(cx, list, vxml);
36622 for (i = 0, n = ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (xml)->u.list.kids.length : 0); i < n; i++) {
36623 kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null);
36624 if (kid && kid->xml_class == JSXML_CLASS_COMMENT) {
36625 ok = Append(cx, list, kid);
36636 xml_comments(JSContext *cx, uintN argc, jsval *vp)
36638 JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0;
36639 return xml_comments_helper(cx, obj, xml, vp);
36644 xml_contains(JSContext *cx, uintN argc, jsval *vp)
36650 JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0;
36651 value = argc != 0 ? vp[2] : ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0));
36652 if (xml->xml_class == JSXML_CLASS_LIST) {
36654 JSXMLArrayCursor cursor(&xml->u.list.kids);
36655 while (JSXML *kid = (JSXML *) cursor.getNext()) {
36656 kidobj = js_GetXMLObject(cx, kid);
36657 if (!kidobj || !js_TestXMLEquality(cx, ObjectValue(*kidobj), Valueify(value), &eq))
36663 if (!js_TestXMLEquality(cx, ObjectValue(*obj), Valueify(value), &eq))
36666 *vp = BOOLEAN_TO_JSVAL(eq);
36672 xml_copy(JSContext *cx, uintN argc, jsval *vp)
36676 JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0;
36677 copy = DeepCopy(cx, xml, __null, 0);
36680 *vp = OBJECT_TO_JSVAL(copy->object);
36686 xml_descendants(JSContext *cx, uintN argc, jsval *vp)
36691 JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0;
36692 name = argc == 0 ? STRING_TO_JSVAL((cx->runtime->atomState.starAtom)) : vp[2];
36693 list = Descendants(cx, xml, name);
36696 *vp = OBJECT_TO_JSVAL(list->object);
36702 xml_elements_helper(JSContext *cx, JSObject *obj, JSXML *xml,
36703 JSObject *nameqn, jsval *vp)
36705 JSXML *list, *vxml;
36711 list = xml_list_helper(cx, xml, vp);
36715 list->u.list.targetprop = nameqn;
36718 if (xml->xml_class == JSXML_CLASS_LIST) {
36720 JSXMLArrayCursor cursor(&xml->u.list.kids);
36721 while (JSXML *kid = (JSXML *) cursor.getNext()) {
36722 if (kid->xml_class == JSXML_CLASS_ELEMENT) {
36723 ok = js_EnterLocalRootScope(cx);
36726 kidobj = js_GetXMLObject(cx, kid);
36728 ok = xml_elements_helper(cx, kidobj, kid, nameqn, &v);
36731 v = ((((uint64)(uint32)(JSVAL_TAG_NULL)) << 47) | (0));
36733 js_LeaveLocalRootScopeWithResult(cx, Valueify(v));
36736 vxml = (JSXML *) JSVAL_TO_OBJECT(v)->getPrivate();
36737 if (((((vxml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (vxml)->u.list.kids.length : 0) != 0) {
36738 ok = Append(cx, list, vxml);
36745 for (i = 0, n = ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (xml)->u.list.kids.length : 0); i < n; i++) {
36746 JSXML *kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null);
36747 if (kid && kid->xml_class == JSXML_CLASS_ELEMENT &&
36748 MatchElemName(nameqn, kid)) {
36749 ok = Append(cx, list, kid);
36760 xml_elements(JSContext *cx, uintN argc, jsval *vp)
36766 JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0;
36768 name = (argc == 0) ? STRING_TO_JSVAL((cx->runtime->atomState.starAtom)) : vp[2];
36769 nameqn = ToXMLName(cx, name, &funid);
36773 if (!JSID_IS_VOID(funid))
36774 return xml_list_helper(cx, xml, vp) != __null;
36776 return xml_elements_helper(cx, obj, xml, nameqn, vp);
36781 xml_hasOwnProperty(JSContext *cx, uintN argc, jsval *vp)
36786 JSObject *obj = ToObject(cx, Valueify(&vp[1]));
36789 if (!InstanceOf(cx, obj, &js_XMLClass, Valueify(vp + 2)))
36792 name = argc != 0 ? vp[2] : ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0));
36793 if (!HasProperty(cx, obj, name, &found))
36796 *vp = ((((uint64)(uint32)(JSVAL_TAG_BOOLEAN)) << 47) | ((JSIntn)1));
36799 return js_HasOwnPropertyHelper(cx, js_LookupProperty, argc, Valueify(vp));
36804 xml_hasComplexContent(JSContext *cx, uintN argc, jsval *vp)
36810 JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0;
36812 switch (xml->xml_class) {
36813 case JSXML_CLASS_ATTRIBUTE:
36814 case JSXML_CLASS_COMMENT:
36815 case JSXML_CLASS_PROCESSING_INSTRUCTION:
36816 case JSXML_CLASS_TEXT:
36817 *vp = ((((uint64)(uint32)(JSVAL_TAG_BOOLEAN)) << 47) | ((JSIntn)0));
36819 case JSXML_CLASS_LIST:
36820 if (xml->u.list.kids.length == 0) {
36821 *vp = ((((uint64)(uint32)(JSVAL_TAG_BOOLEAN)) << 47) | ((JSIntn)1));
36822 } else if (xml->u.list.kids.length == 1) {
36823 kid = (((0) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[0] : __null);
36825 kidobj = js_GetXMLObject(cx, kid);
36829 xml = (JSXML *) obj->getPrivate();
36835 *vp = ((((uint64)(uint32)(JSVAL_TAG_BOOLEAN)) << 47) | ((JSIntn)0));
36836 for (i = 0, n = xml->u.list.kids.length; i < n; i++) {
36837 kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null);
36838 if (kid && kid->xml_class == JSXML_CLASS_ELEMENT) {
36839 *vp = ((((uint64)(uint32)(JSVAL_TAG_BOOLEAN)) << 47) | ((JSIntn)1));
36850 xml_hasSimpleContent(JSContext *cx, uintN argc, jsval *vp)
36852 JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0;
36853 *vp = BOOLEAN_TO_JSVAL(HasSimpleContent(xml));
36858 FindInScopeNamespaces(JSContext *cx, JSXML *xml, JSXMLArray *nsarray)
36860 uint32 length, i, j, n;
36861 JSObject *ns, *ns2;
36862 JSLinearString *prefix, *prefix2;
36864 length = nsarray->length;
36866 if (xml->xml_class != JSXML_CLASS_ELEMENT)
36868 for (i = 0, n = xml->u.elem.namespaces.length; i < n; i++) {
36869 ns = (((i) < (&xml->u.elem.namespaces)->length) ? (JSObject *) (&xml->u.elem.namespaces)->vector[i] : __null);
36873 prefix = ns->getNamePrefix();
36874 for (j = 0; j < length; j++) {
36875 ns2 = (((j) < (nsarray)->length) ? (JSObject *) (nsarray)->vector[j] : __null);
36877 prefix2 = ns2->getNamePrefix();
36878 if ((prefix2 && prefix)
36879 ? EqualStrings(prefix2, prefix)
36880 : EqualStrings(ns2->getNameURI(), ns->getNameURI())) {
36887 if (!XMLArrayAddMember(cx, nsarray, (nsarray)->length, (void *)((ns))))
36892 } while ((xml = xml->parent) != __null);
36906 NamespacesToJSArray(JSContext *cx, JSXMLArray *array, jsval *rval)
36908 JSObject *arrayobj = NewDenseEmptyArray(cx);
36911 *rval = OBJECT_TO_JSVAL(arrayobj);
36913 AutoValueRooter tvr(cx);
36914 for (uint32 i = 0, n = array->length; i < n; i++) {
36915 JSObject *ns = (((i) < (array)->length) ? (JSObject *) (array)->vector[i] : __null);
36918 tvr.set(ObjectValue(*ns));
36919 if (!arrayobj->setProperty(cx, INT_TO_JSID(i), tvr.addr(), false))
36926 xml_inScopeNamespaces(JSContext *cx, uintN argc, jsval *vp)
36928 JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0);
36930 AutoNamespaceArray namespaces(cx);
36931 return FindInScopeNamespaces(cx, xml, &namespaces.array) &&
36932 NamespacesToJSArray(cx, &namespaces.array, vp);
36936 xml_insertChildAfter(JSContext *cx, uintN argc, jsval *vp)
36942 JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0);
36943 *vp = OBJECT_TO_JSVAL(obj);
36944 if (!(((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) || argc == 0)
36948 if (JSVAL_IS_NULL(arg)) {
36952 if (!(!JSVAL_IS_PRIMITIVE(arg) && JSVAL_TO_OBJECT(arg)->isXML()))
36954 kid = (JSXML *) JSVAL_TO_OBJECT(arg)->getPrivate();
36955 i = XMLArrayFindMember(&xml->u.list.kids, (void *)(kid), __null);
36956 if (i == ((uint32) -1))
36961 xml = (xml->object == obj ? xml : CopyOnWrite(cx, xml, obj));
36964 return Insert(cx, xml, i, argc >= 2 ? vp[3] : ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)));
36968 xml_insertChildBefore(JSContext *cx, uintN argc, jsval *vp)
36974 JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0);
36975 *vp = OBJECT_TO_JSVAL(obj);
36976 if (!(((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) || argc == 0)
36980 if (JSVAL_IS_NULL(arg)) {
36982 i = xml->u.list.kids.length;
36984 if (!(!JSVAL_IS_PRIMITIVE(arg) && JSVAL_TO_OBJECT(arg)->isXML()))
36986 kid = (JSXML *) JSVAL_TO_OBJECT(arg)->getPrivate();
36987 i = XMLArrayFindMember(&xml->u.list.kids, (void *)(kid), __null);
36988 if (i == ((uint32) -1))
36992 xml = (xml->object == obj ? xml : CopyOnWrite(cx, xml, obj));
36995 return Insert(cx, xml, i, argc >= 2 ? vp[3] : ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)));
37000 xml_length(JSContext *cx, uintN argc, jsval *vp)
37002 JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0;
37003 if (xml->xml_class != JSXML_CLASS_LIST) {
37004 *vp = ((((uint64)(uint32)(JSVAL_TAG_INT32)) << 47) | (1));
37006 uint32 l = xml->u.list.kids.length;
37007 if (l <= ((jsint)0x7fffffff))
37008 *vp = INT_TO_JSVAL(l);
37010 *vp = DOUBLE_TO_JSVAL(l);
37016 xml_localName(JSContext *cx, uintN argc, jsval *vp)
37018 JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0);
37019 *vp = xml->name ? xml->name->getQNameLocalNameVal() : ((((uint64)(uint32)(JSVAL_TAG_NULL)) << 47) | (0));
37024 xml_name(JSContext *cx, uintN argc, jsval *vp)
37026 JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0);
37027 *vp = OBJECT_TO_JSVAL(xml->name);
37032 xml_namespace(JSContext *cx, uintN argc, jsval *vp)
37034 JSLinearString *prefix, *nsprefix;
37038 JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0);
37039 if (argc == 0 && !((uintN)(((xml)->xml_class) - JSXML_CLASS_ELEMENT) <= (uintN)(JSXML_CLASS_PROCESSING_INSTRUCTION - JSXML_CLASS_ELEMENT))) {
37040 *vp = ((((uint64)(uint32)(JSVAL_TAG_NULL)) << 47) | (0));
37047 JSString *str = js_ValueToString(cx, Valueify(vp[2]));
37050 prefix = str->ensureLinear(cx);
37053 vp[2] = STRING_TO_JSVAL(prefix);
37056 AutoNamespaceArray inScopeNSes(cx);
37057 if (!FindInScopeNamespaces(cx, xml, &inScopeNSes.array))
37061 ns = GetNamespace(cx, xml->name, &inScopeNSes.array);
37066 for (i = 0, length = inScopeNSes.array.length; i < length; i++) {
37067 ns = (((i) < (&inScopeNSes.array)->length) ? (JSObject *) (&inScopeNSes.array)->vector[i] : __null);
37069 nsprefix = ns->getNamePrefix();
37070 if (nsprefix && EqualStrings(nsprefix, prefix))
37077 *vp = (!ns) ? ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)) : OBJECT_TO_JSVAL(ns);
37082 xml_namespaceDeclarations(JSContext *cx, uintN argc, jsval *vp)
37084 JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0);
37085 if ((((xml)->xml_class) >= JSXML_CLASS_ATTRIBUTE))
37088 AutoNamespaceArray ancestors(cx);
37089 AutoNamespaceArray declared(cx);
37092 while ((yml = yml->parent) != __null) {
37094 for (uint32 i = 0, n = yml->u.elem.namespaces.length; i < n; i++) {
37095 JSObject *ns = (((i) < (&yml->u.elem.namespaces)->length) ? (JSObject *) (&yml->u.elem.namespaces)->vector[i] : __null);
37096 if (ns && !(XMLArrayFindMember(&ancestors.array, (void *)(ns), namespace_match) != ((uint32) -1))) {
37097 if (!XMLArrayAddMember(cx, &ancestors.array, (&ancestors.array)->length, (void *)((ns))))
37103 for (uint32 i = 0, n = xml->u.elem.namespaces.length; i < n; i++) {
37104 JSObject *ns = (((i) < (&xml->u.elem.namespaces)->length) ? (JSObject *) (&xml->u.elem.namespaces)->vector[i] : __null);
37107 if (!IsDeclared(ns))
37109 if (!(XMLArrayFindMember(&ancestors.array, (void *)(ns), namespace_match) != ((uint32) -1))) {
37110 if (!XMLArrayAddMember(cx, &declared.array, (&declared.array)->length, (void *)((ns))))
37115 return NamespacesToJSArray(cx, &declared.array, vp);
37118 static const char js_attribute_str[] = "attribute";
37119 static const char js_text_str[] = "text";
37122 const char *js_xml_class_str[] = {
37126 "processing-instruction",
37132 xml_nodeKind(JSContext *cx, uintN argc, jsval *vp)
37136 JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0);
37137 str = JS_InternString(cx, js_xml_class_str[xml->xml_class]);
37140 *vp = STRING_TO_JSVAL(str);
37145 NormalizingDelete(JSContext *cx, JSXML *xml, uint32 index)
37147 if (xml->xml_class == JSXML_CLASS_LIST)
37148 DeleteListElement(cx, xml, index);
37150 DeleteByIndex(cx, xml, index);
37155 xml_normalize_helper(JSContext *cx, JSObject *obj, JSXML *xml)
37162 if (!(((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE))
37165 xml = (xml->object == obj ? xml : CopyOnWrite(cx, xml, obj));
37169 for (i = 0, n = xml->u.list.kids.length; i < n; i++) {
37170 kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null);
37173 if (kid->xml_class == JSXML_CLASS_ELEMENT) {
37174 kidobj = js_GetXMLObject(cx, kid);
37175 if (!kidobj || !xml_normalize_helper(cx, kidobj, kid))
37177 } else if (kid->xml_class == JSXML_CLASS_TEXT) {
37178 while (i + 1 < n &&
37179 (kid2 = (((i + 1) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i + 1] : __null)) &&
37180 kid2->xml_class == JSXML_CLASS_TEXT) {
37181 str = js_ConcatStrings(cx, kid->u.value, kid2->u.value);
37184 NormalizingDelete(cx, xml, i + 1);
37185 n = xml->u.list.kids.length;
37186 kid->u.value = str;
37188 if (kid->u.value->empty()) {
37189 NormalizingDelete(cx, xml, i);
37190 n = xml->u.list.kids.length;
37200 xml_normalize(JSContext *cx, uintN argc, jsval *vp)
37202 JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0;
37203 *vp = OBJECT_TO_JSVAL(obj);
37204 return xml_normalize_helper(cx, obj, xml);
37209 xml_parent(JSContext *cx, uintN argc, jsval *vp)
37211 JSXML *parent, *kid;
37213 JSObject *parentobj;
37215 JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0;
37216 parent = xml->parent;
37217 if (xml->xml_class == JSXML_CLASS_LIST) {
37218 *vp = ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0));
37219 n = xml->u.list.kids.length;
37223 kid = (((0) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[0] : __null);
37226 parent = kid->parent;
37227 for (i = 1; i < n; i++) {
37228 kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null);
37229 if (kid && kid->parent != parent)
37235 *vp = ((((uint64)(uint32)(JSVAL_TAG_NULL)) << 47) | (0));
37239 parentobj = js_GetXMLObject(cx, parent);
37242 *vp = OBJECT_TO_JSVAL(parentobj);
37248 xml_processingInstructions_helper(JSContext *cx, JSObject *obj, JSXML *xml,
37249 JSObject *nameqn, jsval *vp)
37251 JSXML *list, *vxml;
37257 list = xml_list_helper(cx, xml, vp);
37261 list->u.list.targetprop = nameqn;
37264 if (xml->xml_class == JSXML_CLASS_LIST) {
37266 JSXMLArrayCursor cursor(&xml->u.list.kids);
37267 while (JSXML *kid = (JSXML *) cursor.getNext()) {
37268 if (kid->xml_class == JSXML_CLASS_ELEMENT) {
37269 ok = js_EnterLocalRootScope(cx);
37272 kidobj = js_GetXMLObject(cx, kid);
37274 ok = xml_processingInstructions_helper(cx, kidobj, kid,
37278 v = ((((uint64)(uint32)(JSVAL_TAG_NULL)) << 47) | (0));
37280 js_LeaveLocalRootScopeWithResult(cx, Valueify(v));
37283 vxml = (JSXML *) JSVAL_TO_OBJECT(v)->getPrivate();
37284 if (((((vxml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (vxml)->u.list.kids.length : 0) != 0) {
37285 ok = Append(cx, list, vxml);
37293 for (i = 0, n = ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (xml)->u.list.kids.length : 0); i < n; i++) {
37294 JSXML *kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null);
37295 if (kid && kid->xml_class == JSXML_CLASS_PROCESSING_INSTRUCTION) {
37296 JSLinearString *localName = nameqn->getQNameLocalName();
37297 if (((localName)->length() == 1 && *(localName)->chars() == '*') ||
37298 EqualStrings(localName, kid->name->getQNameLocalName())) {
37299 ok = Append(cx, list, kid);
37311 xml_processingInstructions(JSContext *cx, uintN argc, jsval *vp)
37317 JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0;
37319 name = (argc == 0) ? STRING_TO_JSVAL((cx->runtime->atomState.starAtom)) : vp[2];
37320 nameqn = ToXMLName(cx, name, &funid);
37323 vp[2] = OBJECT_TO_JSVAL(nameqn);
37325 if (!JSID_IS_VOID(funid))
37326 return xml_list_helper(cx, xml, vp) != __null;
37328 return xml_processingInstructions_helper(cx, obj, xml, nameqn, vp);
37332 xml_prependChild(JSContext *cx, uintN argc, jsval *vp)
37334 JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0);
37335 xml = (xml->object == obj ? xml : CopyOnWrite(cx, xml, obj));
37338 *vp = OBJECT_TO_JSVAL(obj);
37339 return Insert(cx, xml, 0, argc != 0 ? vp[2] : ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)));
37344 xml_propertyIsEnumerable(JSContext *cx, uintN argc, jsval *vp)
37349 JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0;
37350 *vp = ((((uint64)(uint32)(JSVAL_TAG_BOOLEAN)) << 47) | ((JSIntn)0));
37352 if (!js_IdValIsIndex(cx, vp[2], &index, &isIndex))
37356 if (xml->xml_class == JSXML_CLASS_LIST) {
37358 *vp = BOOLEAN_TO_JSVAL(index < xml->u.list.kids.length);
37361 *vp = BOOLEAN_TO_JSVAL(index == 0);
37369 namespace_full_match(const void *a, const void *b)
37371 const JSObject *nsa = (const JSObject *) a;
37372 const JSObject *nsb = (const JSObject *) b;
37373 JSLinearString *prefixa = nsa->getNamePrefix();
37374 JSLinearString *prefixb;
37377 prefixb = nsb->getNamePrefix();
37378 if (prefixb && !EqualStrings(prefixa, prefixb))
37381 return EqualStrings(nsa->getNameURI(), nsb->getNameURI());
37385 xml_removeNamespace_helper(JSContext *cx, JSXML *xml, JSObject *ns)
37387 JSObject *thisns, *attrns;
37391 thisns = GetNamespace(cx, xml->name, &xml->u.elem.namespaces);
37396 for (i = 0, n = xml->u.elem.attrs.length; i < n; i++) {
37397 attr = (((i) < (&xml->u.elem.attrs)->length) ? (JSXML *) (&xml->u.elem.attrs)->vector[i] : __null);
37400 attrns = GetNamespace(cx, attr->name, &xml->u.elem.namespaces);
37406 i = XMLArrayFindMember(&xml->u.elem.namespaces, (void *)(ns), namespace_full_match);
37407 if (i != ((uint32) -1))
37408 XMLArrayDelete(cx, &xml->u.elem.namespaces, i, (JSIntn)1);
37410 for (i = 0, n = xml->u.list.kids.length; i < n; i++) {
37411 kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null);
37412 if (kid && kid->xml_class == JSXML_CLASS_ELEMENT) {
37413 if (!xml_removeNamespace_helper(cx, kid, ns))
37421 xml_removeNamespace(JSContext *cx, uintN argc, jsval *vp)
37425 JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0);
37426 if (xml->xml_class != JSXML_CLASS_ELEMENT)
37428 xml = (xml->object == obj ? xml : CopyOnWrite(cx, xml, obj));
37432 if (!NamespaceHelper(cx, __null, argc == 0 ? -1 : 1, vp + 2, vp))
37435 ns = JSVAL_TO_OBJECT(*vp);
37438 if (!xml_removeNamespace_helper(cx, xml, ns))
37441 *vp = OBJECT_TO_JSVAL(obj);
37446 xml_replace(JSContext *cx, uintN argc, jsval *vp)
37453 JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0);
37454 if (xml->xml_class != JSXML_CLASS_ELEMENT)
37458 value = STRING_TO_JSVAL((cx->runtime->atomState.typeAtoms[JSTYPE_VOID]));
37461 vxml = (!JSVAL_IS_PRIMITIVE(value) && JSVAL_TO_OBJECT(value)->isXML())
37462 ? (JSXML *) JSVAL_TO_OBJECT(value)->getPrivate()
37465 if (!JS_ConvertValue(cx, value, JSTYPE_STRING, &vp[3]))
37469 vxml = DeepCopy(cx, vxml, __null, 0);
37472 value = vp[3] = OBJECT_TO_JSVAL(vxml->object);
37476 xml = (xml->object == obj ? xml : CopyOnWrite(cx, xml, obj));
37484 if (!js_IdValIsIndex(cx, vp[2], &index, &haveIndex))
37493 if (!QNameHelper(cx, __null, argc == 0 ? -1 : 1, vp + 2, vp))
37496 nameqn = JSVAL_TO_OBJECT(*vp);
37498 i = xml->u.list.kids.length;
37499 index = ((uint32) -1);
37502 kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null);
37503 if (kid && MatchElemName(nameqn, kid)) {
37504 if (i != ((uint32) -1))
37505 DeleteByIndex(cx, xml, i);
37510 if (index == ((uint32) -1))
37514 if (!Replace(cx, xml, index, value))
37518 *vp = OBJECT_TO_JSVAL(obj);
37523 xml_setChildren(JSContext *cx, uintN argc, jsval *vp)
37527 if (!StartNonListXMLMethod(cx, vp, &obj))
37530 *vp = argc != 0 ? vp[2] : ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0));
37531 if (!PutProperty(cx, obj, ATOM_TO_JSID(cx->runtime->atomState.starAtom), false, vp))
37534 *vp = OBJECT_TO_JSVAL(obj);
37539 xml_setLocalName(JSContext *cx, uintN argc, jsval *vp)
37543 JSLinearString *namestr;
37545 JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0);
37546 if (!((uintN)(((xml)->xml_class) - JSXML_CLASS_ELEMENT) <= (uintN)(JSXML_CLASS_PROCESSING_INSTRUCTION - JSXML_CLASS_ELEMENT)))
37550 namestr = (cx->runtime->atomState.typeAtoms[JSTYPE_VOID]);
37553 if (!JSVAL_IS_PRIMITIVE(name) &&
37554 JSVAL_TO_OBJECT(name)->getClass() == &js_QNameClass) {
37555 nameqn = JSVAL_TO_OBJECT(name);
37556 namestr = nameqn->getQNameLocalName();
37558 if (!JS_ConvertValue(cx, name, JSTYPE_STRING, &vp[2]))
37561 namestr = JSVAL_TO_STRING(name)->ensureLinear(cx);
37567 xml = (xml->object == obj ? xml : CopyOnWrite(cx, xml, obj));
37571 xml->name->setQNameLocalName(namestr);
37576 xml_setName(JSContext *cx, uintN argc, jsval *vp)
37581 JSXMLArray *nsarray;
37585 JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0);
37586 if (!((uintN)(((xml)->xml_class) - JSXML_CLASS_ELEMENT) <= (uintN)(JSXML_CLASS_PROCESSING_INSTRUCTION - JSXML_CLASS_ELEMENT)))
37590 name = STRING_TO_JSVAL((cx->runtime->atomState.typeAtoms[JSTYPE_VOID]));
37593 if (!JSVAL_IS_PRIMITIVE(name) &&
37594 JSVAL_TO_OBJECT(name)->getClass() == &js_QNameClass &&
37595 !(nameqn = JSVAL_TO_OBJECT(name))->getNameURI()) {
37596 name = vp[2] = nameqn->getQNameLocalNameVal();
37600 nameqn = js_ConstructObject(cx, &js_QNameClass, __null, __null, 1, Valueify(&name));
37605 if (xml->xml_class == JSXML_CLASS_PROCESSING_INSTRUCTION)
37606 nameqn->setNameURI(cx->runtime->emptyString);
37608 xml = (xml->object == obj ? xml : CopyOnWrite(cx, xml, obj));
37611 xml->name = nameqn;
37613 if (xml->xml_class == JSXML_CLASS_ELEMENT) {
37616 if (!xml->parent || xml->parent->xml_class != JSXML_CLASS_ELEMENT)
37618 nsowner = xml->parent;
37621 if (nameqn->getNamePrefix()) {
37623 ns = GetNamespace(cx, nameqn, &nsowner->u.elem.namespaces);
37628 if ((XMLArrayFindMember(&nsowner->u.elem.namespaces, (void *)(ns), __null) != ((uint32) -1)))
37634 nsarray = &nsowner->u.elem.namespaces;
37635 for (i = 0, n = nsarray->length; i < n; i++) {
37636 ns = (((i) < (nsarray)->length) ? (JSObject *) (nsarray)->vector[i] : __null);
37637 if (ns && EqualStrings(ns->getNameURI(), nameqn->getNameURI())) {
37638 nameqn->setNamePrefix(ns->getNamePrefix());
37643 ns = NewXMLNamespace(cx, __null, nameqn->getNameURI(), (JSIntn)1);
37648 if (!AddInScopeNamespace(cx, nsowner, ns))
37650 vp[0] = ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0));
37655 xml_setNamespace(JSContext *cx, uintN argc, jsval *vp)
37662 JSObject *obj; JSXML *xml = StartNonListXMLMethod(cx, vp, &obj); if (!xml) return (JSIntn)0; ((void) 0);
37663 if (!((uintN)(((xml)->xml_class) - JSXML_CLASS_ELEMENT) <= (uintN)(JSXML_CLASS_PROCESSING_INSTRUCTION - JSXML_CLASS_ELEMENT)))
37666 xml = (xml->object == obj ? xml : CopyOnWrite(cx, xml, obj));
37670 ns = js_ConstructObject(cx, &js_NamespaceClass, __null, obj,
37671 argc == 0 ? 0 : 1, Valueify(vp + 2));
37674 vp[0] = OBJECT_TO_JSVAL(ns);
37675 ns->setNamespaceDeclared(((((uint64)(uint32)(JSVAL_TAG_BOOLEAN)) << 47) | ((JSIntn)1)));
37677 qnargv[0] = OBJECT_TO_JSVAL(ns);
37678 qnargv[1] = OBJECT_TO_JSVAL(xml->name);
37679 qn = js_ConstructObject(cx, &js_QNameClass, __null, __null, 2, Valueify(qnargv));
37689 if (xml->xml_class == JSXML_CLASS_ELEMENT) {
37692 if (!xml->parent || xml->parent->xml_class != JSXML_CLASS_ELEMENT)
37694 nsowner = xml->parent;
37696 if (!AddInScopeNamespace(cx, nsowner, ns))
37698 vp[0] = ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0));
37704 xml_text_helper(JSContext *cx, JSObject *obj, JSXML *xml, jsval *vp)
37706 JSXML *list, *kid, *vxml;
37712 list = xml_list_helper(cx, xml, vp);
37716 if (xml->xml_class == JSXML_CLASS_LIST) {
37718 for (i = 0, n = xml->u.list.kids.length; i < n; i++) {
37719 kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null);
37720 if (kid && kid->xml_class == JSXML_CLASS_ELEMENT) {
37721 ok = js_EnterLocalRootScope(cx);
37724 kidobj = js_GetXMLObject(cx, kid);
37726 ok = xml_text_helper(cx, kidobj, kid, &v);
37729 v = ((((uint64)(uint32)(JSVAL_TAG_NULL)) << 47) | (0));
37731 js_LeaveLocalRootScopeWithResult(cx, Valueify(v));
37734 vxml = (JSXML *) JSVAL_TO_OBJECT(v)->getPrivate();
37735 if (((((vxml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (vxml)->u.list.kids.length : 0) != 0 && !Append(cx, list, vxml))
37740 for (i = 0, n = ((((xml)->xml_class) < JSXML_CLASS_ATTRIBUTE) ? (xml)->u.list.kids.length : 0); i < n; i++) {
37741 kid = (((i) < (&xml->u.list.kids)->length) ? (JSXML *) (&xml->u.list.kids)->vector[i] : __null);
37742 if (kid && kid->xml_class == JSXML_CLASS_TEXT) {
37743 if (!Append(cx, list, kid))
37752 xml_text(JSContext *cx, uintN argc, jsval *vp)
37754 JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0;
37755 return xml_text_helper(cx, obj, xml, vp);
37760 xml_toString_helper(JSContext *cx, JSXML *xml)
37762 JSString *str, *kidstr;
37764 if (xml->xml_class == JSXML_CLASS_ATTRIBUTE ||
37765 xml->xml_class == JSXML_CLASS_TEXT) {
37766 return xml->u.value;
37769 if (!HasSimpleContent(xml))
37770 return ToXMLString(cx, OBJECT_TO_JSVAL(xml->object), 0);
37772 str = cx->runtime->emptyString;
37773 if (!js_EnterLocalRootScope(cx))
37775 JSXMLArrayCursor cursor(&xml->u.list.kids);
37776 while (JSXML *kid = (JSXML *) cursor.getNext()) {
37777 if (kid->xml_class != JSXML_CLASS_COMMENT &&
37778 kid->xml_class != JSXML_CLASS_PROCESSING_INSTRUCTION) {
37779 kidstr = xml_toString_helper(cx, kid);
37784 str = js_ConcatStrings(cx, str, kidstr);
37789 js_LeaveLocalRootScopeWithResult(cx, str);
37794 xml_toSource(JSContext *cx, uintN argc, jsval *vp)
37796 JSObject *obj = ToObject(cx, Valueify(&vp[1]));
37799 JSString *str = ToXMLString(cx, OBJECT_TO_JSVAL(obj), 0x80000000);
37802 *vp = STRING_TO_JSVAL(str);
37807 xml_toString(JSContext *cx, uintN argc, jsval *vp)
37811 JSObject *obj = ToObject(cx, Valueify(&vp[1])); if (!obj) return (JSIntn)0; JSXML *xml = (JSXML *)GetInstancePrivate(cx, obj, &js_XMLClass, Valueify(vp+2)); if (!xml) return (JSIntn)0;
37812 str = xml_toString_helper(cx, xml);
37815 *vp = STRING_TO_JSVAL(str);
37821 xml_toXMLString(JSContext *cx, uintN argc, jsval *vp)
37823 JSObject *obj = ToObject(cx, Valueify(&vp[1]));
37826 JSString *str = ToXMLString(cx, OBJECT_TO_JSVAL(obj), 0);
37829 *vp = STRING_TO_JSVAL(str);
37835 xml_valueOf(JSContext *cx, uintN argc, jsval *vp)
37837 JSObject *obj = ToObject(cx, Valueify(&vp[1]));
37840 *vp = OBJECT_TO_JSVAL(obj);
37844 static JSFunctionSpec xml_methods[] = {
37845 {"addNamespace", ((JSNative)(xml_addNamespace)), 1, (0) | 0x1000},
37846 {"appendChild", ((JSNative)(xml_appendChild)), 1, (0) | 0x1000},
37847 {js_attribute_str, ((JSNative)(xml_attribute)), 1, (0) | 0x1000},
37848 {"attributes", ((JSNative)(xml_attributes)), 0, (0) | 0x1000},
37849 {"child", ((JSNative)(xml_child)), 1, (0) | 0x1000},
37850 {"childIndex", ((JSNative)(xml_childIndex)), 0, (0) | 0x1000},
37851 {"children", ((JSNative)(xml_children)), 0, (0) | 0x1000},
37852 {"comments", ((JSNative)(xml_comments)), 0, (0) | 0x1000},
37853 {"contains", ((JSNative)(xml_contains)), 1, (0) | 0x1000},
37854 {"copy", ((JSNative)(xml_copy)), 0, (0) | 0x1000},
37855 {"descendants", ((JSNative)(xml_descendants)), 1, (0) | 0x1000},
37856 {"elements", ((JSNative)(xml_elements)), 1, (0) | 0x1000},
37857 {"hasOwnProperty", ((JSNative)(xml_hasOwnProperty)), 1, (0) | 0x1000},
37858 {"hasComplexContent", ((JSNative)(xml_hasComplexContent)), 1, (0) | 0x1000},
37859 {"hasSimpleContent", ((JSNative)(xml_hasSimpleContent)), 1, (0) | 0x1000},
37860 {"inScopeNamespaces", ((JSNative)(xml_inScopeNamespaces)), 0, (0) | 0x1000},
37861 {"insertChildAfter", ((JSNative)(xml_insertChildAfter)), 2, (0) | 0x1000},
37862 {"insertChildBefore", ((JSNative)(xml_insertChildBefore)), 2, (0) | 0x1000},
37863 {js_length_str, ((JSNative)(xml_length)), 0, (0) | 0x1000},
37864 {js_localName_str, ((JSNative)(xml_localName)), 0, (0) | 0x1000},
37865 {js_name_str, ((JSNative)(xml_name)), 0, (0) | 0x1000},
37866 {js_namespace_str, ((JSNative)(xml_namespace)), 1, (0) | 0x1000},
37867 {"namespaceDeclarations", ((JSNative)(xml_namespaceDeclarations)), 0, (0) | 0x1000},
37868 {"nodeKind", ((JSNative)(xml_nodeKind)), 0, (0) | 0x1000},
37869 {"normalize", ((JSNative)(xml_normalize)), 0, (0) | 0x1000},
37870 {js_xml_parent_str, ((JSNative)(xml_parent)), 0, (0) | 0x1000},
37871 {"processingInstructions", ((JSNative)(xml_processingInstructions)), 1, (0) | 0x1000},
37872 {"prependChild", ((JSNative)(xml_prependChild)), 1, (0) | 0x1000},
37873 {"propertyIsEnumerable", ((JSNative)(xml_propertyIsEnumerable)), 1, (0) | 0x1000},
37874 {"removeNamespace", ((JSNative)(xml_removeNamespace)), 1, (0) | 0x1000},
37875 {"replace", ((JSNative)(xml_replace)), 2, (0) | 0x1000},
37876 {"setChildren", ((JSNative)(xml_setChildren)), 1, (0) | 0x1000},
37877 {"setLocalName", ((JSNative)(xml_setLocalName)), 1, (0) | 0x1000},
37878 {"setName", ((JSNative)(xml_setName)), 1, (0) | 0x1000},
37879 {"setNamespace", ((JSNative)(xml_setNamespace)), 1, (0) | 0x1000},
37880 {js_text_str, ((JSNative)(xml_text)), 0, (0) | 0x1000},
37881 {js_toSource_str, ((JSNative)(xml_toSource)), 0, (0) | 0x1000},
37882 {js_toString_str, ((JSNative)(xml_toString)), 0, (0) | 0x1000},
37883 {js_toXMLString_str, ((JSNative)(xml_toXMLString)), 0, (0) | 0x1000},
37884 {js_valueOf_str, ((JSNative)(xml_valueOf)), 0, (0) | 0x1000},
37885 {__null, __null, 0, 0}
37889 CopyXMLSettings(JSContext *cx, JSObject *from, JSObject *to)
37896 for (i = 0; xml_static_props[i].name; i++) {
37897 name = xml_static_props[i].name;
37898 if (!JS_GetProperty(cx, from, name, &v))
37900 if (name == js_prettyIndent_str) {
37901 if (!JSVAL_IS_NUMBER(v))
37904 if (!JSVAL_IS_BOOLEAN(v))
37907 if (!JS_SetProperty(cx, to, name, &v))
37915 SetDefaultXMLSettings(JSContext *cx, JSObject *obj)
37921 for (i = 0; xml_static_props[i].name; i++) {
37922 v = (xml_static_props[i].name != js_prettyIndent_str)
37923 ? ((((uint64)(uint32)(JSVAL_TAG_BOOLEAN)) << 47) | ((JSIntn)1)) : INT_TO_JSVAL(2);
37924 if (!JS_SetProperty(cx, obj, xml_static_props[i].name, &v))
37931 xml_settings(JSContext *cx, uintN argc, jsval *vp)
37933 JSObject *settings = JS_NewObject(cx, __null, __null, __null);
37936 *vp = OBJECT_TO_JSVAL(settings);
37937 JSObject *obj = ToObject(cx, Valueify(&vp[1]));
37940 return CopyXMLSettings(cx, obj, settings);
37944 xml_setSettings(JSContext *cx, uintN argc, jsval *vp)
37946 JSObject *settings;
37950 JSObject *obj = ToObject(cx, Valueify(&vp[1]));
37953 v = (argc == 0) ? ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0)) : vp[2];
37954 if (JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v)) {
37955 ok = SetDefaultXMLSettings(cx, obj);
37957 if (JSVAL_IS_PRIMITIVE(v))
37959 settings = JSVAL_TO_OBJECT(v);
37960 ok = CopyXMLSettings(cx, settings, obj);
37966 xml_defaultSettings(JSContext *cx, uintN argc, jsval *vp)
37968 JSObject *settings;
37970 settings = JS_NewObject(cx, __null, __null, __null);
37973 *vp = OBJECT_TO_JSVAL(settings);
37974 return SetDefaultXMLSettings(cx, settings);
37977 static JSFunctionSpec xml_static_methods[] = {
37978 {"settings", ((JSNative)(xml_settings)), 0, (0) | 0x1000},
37979 {"setSettings", ((JSNative)(xml_setSettings)), 1, (0) | 0x1000},
37980 {"defaultSettings", ((JSNative)(xml_defaultSettings)), 0, (0) | 0x1000},
37981 {__null, __null, 0, 0}
37985 XML(JSContext *cx, uintN argc, Value *vp)
37988 JSObject *xobj, *vobj;
37991 jsval v = argc ? Jsvalify(vp[2]) : ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0));
37993 if (JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v))
37994 v = STRING_TO_JSVAL(cx->runtime->emptyString);
37996 xobj = ToXML(cx, v);
37999 xml = (JSXML *) xobj->getPrivate();
38001 if (IsConstructing(vp) && !JSVAL_IS_PRIMITIVE(v)) {
38002 vobj = JSVAL_TO_OBJECT(v);
38003 clasp = vobj->getClass();
38004 if (clasp == &js_XMLClass ||
38005 (clasp->flags & (1<<7))) {
38006 copy = DeepCopy(cx, xml, __null, 0);
38009 vp->setObject(*copy->object);
38014 vp->setObject(*xobj);
38019 XMLList(JSContext *cx, uintN argc, jsval *vp)
38021 JSObject *vobj, *listobj;
38024 jsval v = argc ? vp[2] : ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0));
38026 if (JSVAL_IS_NULL(v) || JSVAL_IS_VOID(v))
38027 v = STRING_TO_JSVAL(cx->runtime->emptyString);
38029 if (IsConstructing(Valueify(vp)) && !JSVAL_IS_PRIMITIVE(v)) {
38030 vobj = JSVAL_TO_OBJECT(v);
38031 if (vobj->isXML()) {
38032 xml = (JSXML *) vobj->getPrivate();
38033 if (xml->xml_class == JSXML_CLASS_LIST) {
38034 listobj = js_NewXMLObject(cx, JSXML_CLASS_LIST);
38037 *vp = OBJECT_TO_JSVAL(listobj);
38039 list = (JSXML *) listobj->getPrivate();
38040 if (!Append(cx, list, xml))
38048 listobj = ToXMLList(cx, v);
38052 *vp = OBJECT_TO_JSVAL(listobj);
38062 js_NewXML(JSContext *cx, JSXMLClass xml_class)
38064 JSXML *xml = js_NewGCXML(cx);
38068 xml->object = __null;
38069 xml->domnode = __null;
38070 xml->parent = __null;
38071 xml->name = __null;
38072 xml->xml_class = xml_class;
38073 xml->xml_flags = 0;
38074 if (((xml_class) >= JSXML_CLASS_ATTRIBUTE)) {
38075 xml->u.value = cx->runtime->emptyString;
38077 xml->u.list.kids.init();
38078 if (xml_class == JSXML_CLASS_LIST) {
38079 xml->u.list.target = __null;
38080 xml->u.list.targetprop = __null;
38082 xml->u.elem.namespaces.init();
38083 xml->u.elem.attrs.init();
38096 js_TraceXML(JSTracer *trc, JSXML *xml)
38099 MarkObject(trc, *xml->object, "object");
38101 MarkObject(trc, *xml->name, "name");
38103 do { do { } while (0); JS_CallTracer((trc), (xml->parent), (2)); } while (0);
38105 if ((((xml)->xml_class) >= JSXML_CLASS_ATTRIBUTE)) {
38107 MarkString(trc, xml->u.value, "value");
38111 xml_trace_vector(trc,
38112 (JSXML **) xml->u.list.kids.vector,
38113 xml->u.list.kids.length);
38114 XMLArrayCursorTrace(trc, xml->u.list.kids.cursors);
38115 if (((trc)->callback == __null))
38116 xml->u.list.kids.trim();
38118 if (xml->xml_class == JSXML_CLASS_LIST) {
38119 if (xml->u.list.target)
38120 do { do { } while (0); JS_CallTracer((trc), (xml->u.list.target), (2)); } while (0);
38121 if (xml->u.list.targetprop)
38122 MarkObject(trc, *xml->u.list.targetprop, "targetprop");
38124 MarkObjectRange(trc, xml->u.elem.namespaces.length,
38125 (JSObject **) xml->u.elem.namespaces.vector,
38127 XMLArrayCursorTrace(trc, xml->u.elem.namespaces.cursors);
38128 if (((trc)->callback == __null))
38129 xml->u.elem.namespaces.trim();
38131 xml_trace_vector(trc,
38132 (JSXML **) xml->u.elem.attrs.vector,
38133 xml->u.elem.attrs.length);
38134 XMLArrayCursorTrace(trc, xml->u.elem.attrs.cursors);
38135 if (((trc)->callback == __null))
38136 xml->u.elem.attrs.trim();
38141 js_NewXMLObject(JSContext *cx, JSXMLClass xml_class)
38143 JSXML *xml = js_NewXML(cx, xml_class);
38147 AutoXMLRooter root(cx, xml);
38148 return js_GetXMLObject(cx, xml);
38152 NewXMLObject(JSContext *cx, JSXML *xml)
38156 obj = NewNonFunction<WithProto::Class>(cx, &js_XMLClass, __null, __null);
38159 obj->setPrivate(xml);
38165 js_GetXMLObject(JSContext *cx, JSXML *xml)
38175 obj = NewXMLObject(cx, xml);
38183 js_InitNamespaceClass(JSContext *cx, JSObject *obj)
38185 return js_InitClass(cx, obj, __null, &js_NamespaceClass, Namespace, 2,
38186 namespace_props, namespace_methods, __null, __null);
38190 js_InitQNameClass(JSContext *cx, JSObject *obj)
38192 return js_InitClass(cx, obj, __null, &js_QNameClass, QName, 2,
38193 qname_props, qname_methods, __null, __null);
38197 js_InitXMLClass(JSContext *cx, JSObject *obj)
38199 JSObject *proto, *pobj;
38207 if (!JS_DefineFunction(cx, obj, js_isXMLName_str, xml_isXMLName, 1, 0))
38211 proto = js_InitClass(cx, obj, __null, &js_XMLClass, XML, 1,
38212 __null, xml_methods,
38213 xml_static_props, xml_static_methods);
38217 xml = js_NewXML(cx, JSXML_CLASS_TEXT);
38220 proto->setPrivate(xml);
38221 xml->object = proto;
38230 if (!js_LookupProperty(cx, proto,
38231 ATOM_TO_JSID(cx->runtime->atomState.constructorAtom),
38236 shape = (Shape *) prop;
38237 cval = Jsvalify(pobj->nativeGetSlot(shape->slot));
38241 vp[0] = ((((uint64)(uint32)(JSVAL_TAG_NULL)) << 47) | (0));
38243 vp[2] = ((((uint64)(uint32)(JSVAL_TAG_UNDEFINED)) << 47) | (0));
38244 if (!xml_setSettings(cx, 1, vp))
38248 fun = JS_DefineFunction(cx, obj, js_XMLList_str, XMLList, 1, 0x0200);
38251 if (!js_SetClassPrototype(cx, (static_cast<JSObject *>(fun)), proto,
38259 js_InitXMLClasses(JSContext *cx, JSObject *obj)
38261 if (!js_InitNamespaceClass(cx, obj))
38263 if (!js_InitQNameClass(cx, obj))
38265 return js_InitXMLClass(cx, obj);
38269 js_GetFunctionNamespace(JSContext *cx, Value *vp)
38271 JSObject *global = cx->hasfp() ? cx->fp()->scopeChain().getGlobal() : cx->globalObject;
38273 *vp = global->getReservedSlot(((((JSProto_LIMIT * 3) + 1) + 1) + 1));
38274 if (vp->isUndefined()) {
38275 JSRuntime *rt = cx->runtime;
38276 JSLinearString *prefix = rt->atomState.typeAtoms[JSTYPE_FUNCTION];
38277 JSLinearString *uri = rt->atomState.functionNamespaceURIAtom;
38278 JSObject *obj = NewXMLNamespace(cx, prefix, uri, (JSIntn)0);
38284 vp->setObject(*obj);
38285 if (!js_SetReservedSlot(cx, global, ((((JSProto_LIMIT * 3) + 1) + 1) + 1), *vp))
38293 js_GetDefaultXMLNamespace(JSContext *cx, jsval *vp)
38295 JSObject *ns, *obj, *tmp;
38298 JSObject *scopeChain = GetScopeChain(cx);
38301 for (tmp = scopeChain; tmp; tmp = tmp->getParent()) {
38302 Class *clasp = tmp->getClass();
38303 if (clasp == &js_BlockClass || clasp == &js_WithClass)
38305 if (!tmp->getProperty(cx, ((jsid)0x6), Valueify(&v)))
38307 if (!JSVAL_IS_PRIMITIVE(v)) {
38314 ns = js_ConstructObject(cx, &js_NamespaceClass, __null, obj, 0, __null);
38317 v = OBJECT_TO_JSVAL(ns);
38318 if (!obj->defineProperty(cx, ((jsid)0x6), Valueify(v),
38319 PropertyStub, StrictPropertyStub, 0x04)) {
38327 js_SetDefaultXMLNamespace(JSContext *cx, const Value &v)
38330 argv[0].setString(cx->runtime->emptyString);
38332 JSObject *ns = js_ConstructObject(cx, &js_NamespaceClass, __null, __null, 2, argv);
38336 JSStackFrame *fp = js_GetTopStackFrame(cx);
38337 JSObject &varobj = fp->varobj(cx);
38338 if (!varobj.defineProperty(cx, ((jsid)0x6), ObjectValue(*ns),
38339 PropertyStub, StrictPropertyStub, 0x04)) {
38346 js_ToAttributeName(JSContext *cx, Value *vp)
38350 qn = ToAttributeName(cx, Jsvalify(*vp));
38353 vp->setObject(*qn);
38358 js_EscapeAttributeValue(JSContext *cx, JSString *str, JSBool quote)
38360 StringBuffer sb(cx);
38361 return EscapeAttributeValue(cx, sb, str, quote);
38365 js_AddAttributePart(JSContext *cx, JSBool isName, JSString *str, JSString *str2)
38367 size_t len = str->length();
38368 const jschar *chars = str->getChars(cx);
38372 size_t len2 = str2->length();
38373 const jschar *chars2 = str2->getChars(cx);
38377 size_t newlen = (isName) ? len + 1 + len2 : len + 2 + len2 + 1;
38378 jschar *newchars = (jschar *) cx->malloc((newlen+1) * sizeof(jschar));
38382 memcpy((newchars), (chars), (len) * sizeof(jschar));
38386 memcpy((newchars), (chars2), (len2) * sizeof(jschar));
38391 memcpy((newchars), (chars2), (len2) * sizeof(jschar));
38396 return js_NewString(cx, newchars - newlen, newlen);
38400 js_EscapeElementValue(JSContext *cx, JSString *str)
38402 StringBuffer sb(cx);
38403 return EscapeElementValue(cx, sb, str, 0);
38407 js_ValueToXMLString(JSContext *cx, const Value &v)
38409 return ToXMLString(cx, Jsvalify(v), 0);
38413 js_GetAnyName(JSContext *cx, jsid *idp)
38415 JSObject *global = cx->hasfp() ? cx->fp()->scopeChain().getGlobal() : cx->globalObject;
38416 Value v = global->getReservedSlot(JSProto_AnyName);
38417 if (v.isUndefined()) {
38418 JSObject *obj = NewNonFunction<WithProto::Given>(cx, &js_AnyNameClass, __null, global);
38424 JSRuntime *rt = cx->runtime;
38425 InitXMLQName(obj, rt->emptyString, rt->emptyString,
38426 (rt->atomState.starAtom));
38430 if (!js_SetReservedSlot(cx, global, JSProto_AnyName, v))
38433 *idp = OBJECT_TO_JSID(&v.toObject());
38438 js_FindXMLProperty(JSContext *cx, const Value &nameval, JSObject **objp, jsid *idp)
38444 JSObject *obj, *target, *proto, *pobj;
38450 nameobj = &nameval.toObject();
38451 if (nameobj->getClass() == &js_AnyNameClass) {
38452 v = STRING_TO_JSVAL((cx->runtime->atomState.starAtom));
38453 nameobj = js_ConstructObject(cx, &js_QNameClass, __null, __null, 1,
38463 if (!IsFunctionQName(cx, qn, &funid))
38466 obj = &js_GetTopStackFrame(cx)->scopeChain();
38470 while (target->getClass() == &js_WithClass) {
38471 proto = target->getProto();
38477 if (target->isXML()) {
38478 if (JSID_IS_VOID(funid)) {
38479 xml = (JSXML *) target->getPrivate();
38480 found = HasNamedProperty(xml, qn);
38482 if (!HasFunctionProperty(cx, target, funid, &found))
38486 *idp = OBJECT_TO_JSID(nameobj);
38490 } else if (!JSID_IS_VOID(funid)) {
38491 if (!target->lookupProperty(cx, funid, &pobj, &prop))
38499 } while ((obj = obj->getParent()) != __null);
38501 JSAutoByteString printable;
38502 JSString *str = ConvertQNameToString(cx, nameobj);
38503 if (str && js_ValueToPrintable(cx, StringValue(str), &printable)) {
38504 JS_ReportErrorFlagsAndNumber(cx, 0x0, js_GetErrorMessage, __null,
38505 JSMSG_UNDEFINED_XML_NAME, printable.ptr());
38511 GetXMLFunction(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
38519 JSObject *target = obj;
38520 AutoObjectRooter tvr(cx);
38522 if (!js_GetProperty(cx, target, id, Valueify(vp)))
38524 if ((!JSVAL_IS_PRIMITIVE(*vp) && JSVAL_TO_OBJECT(*vp)->isFunction()))
38526 target = target->getProto();
38527 if (target == __null || !target->isNative())
38529 tvr.setObject(target);
38532 JSXML *xml = (JSXML *) obj->getPrivate();
38533 if (!HasSimpleContent(xml))
38537 if (!js_GetClassPrototype(cx, __null, JSProto_String, tvr.addr()))
38541 return tvr.object()->getProperty(cx, id, Valueify(vp));
38545 GetPrivate(JSContext *cx, JSObject *obj, const char *method)
38549 xml = (JSXML *) GetInstancePrivate(cx, obj, &js_XMLClass, __null);
38551 JS_ReportErrorNumber(cx, js_GetErrorMessage, __null,
38552 JSMSG_INCOMPATIBLE_METHOD,
38553 js_XML_str, method, obj->getClass()->name);
38559 js_GetXMLDescendants(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
38563 xml = GetPrivate(cx, obj, "descendants internal method");
38567 list = Descendants(cx, xml, id);
38570 *vp = OBJECT_TO_JSVAL(list->object);
38575 js_DeleteXMLListElements(JSContext *cx, JSObject *listobj)
38580 list = (JSXML *) listobj->getPrivate();
38581 for (n = list->u.list.kids.length; n != 0; --n)
38582 DeleteListElement(cx, list, 0);
38592 JSXMLArrayCursor cursor;
38594 JSXMLFilter(JSXML *list, JSXMLArray *array)
38595 : list(list), result(__null), kid(__null), cursor(array) {}
38601 xmlfilter_trace(JSTracer *trc, JSObject *obj)
38603 JSXMLFilter *filter = (JSXMLFilter *) obj->getPrivate();
38608 do { do { } while (0); JS_CallTracer((trc), (filter->list), (2)); } while (0);
38609 if (filter->result)
38610 do { do { } while (0); JS_CallTracer((trc), (filter->result), (2)); } while (0);
38612 do { do { } while (0); JS_CallTracer((trc), (filter->kid), (2)); } while (0);
38621 xmlfilter_finalize(JSContext *cx, JSObject *obj)
38623 JSXMLFilter *filter = (JSXMLFilter *) obj->getPrivate();
38627 cx->destroy(filter);
38630 Class js_XMLFilterClass = {
38632 (1<<0) | (1<<((8 + 8)+1)) | (1<<((8 + 8)+3)),
38636 StrictPropertyStub,
38640 xmlfilter_finalize,
38647 ((JSMarkOp)(xmlfilter_trace))
38651 js_StepXMLListFilter(JSContext *cx, JSBool initialized)
38654 JSObject *obj, *filterobj, *resobj, *kidobj;
38656 JSXMLFilter *filter;
38659 sp = Jsvalify(cx->regs->sp);
38660 if (!initialized) {
38665 if (!(!JSVAL_IS_PRIMITIVE(sp[-2]) && JSVAL_TO_OBJECT(sp[-2])->isXML())) {
38666 ((void)js_ReportValueErrorFlags(cx, 0x0, JSMSG_NON_XML_FILTER, -2, Valueify(sp[-2]), __null, __null, __null));
38669 obj = JSVAL_TO_OBJECT(sp[-2]);
38670 xml = (JSXML *) obj->getPrivate();
38672 if (xml->xml_class == JSXML_CLASS_LIST) {
38675 obj = js_NewXMLObject(cx, JSXML_CLASS_LIST);
38683 sp[-1] = OBJECT_TO_JSVAL(obj);
38684 list = (JSXML *) obj->getPrivate();
38685 if (!Append(cx, list, xml))
38689 filterobj = NewNonFunction<WithProto::Given>(cx, &js_XMLFilterClass, __null, __null);
38697 filter = cx->create<JSXMLFilter>(list, &list->u.list.kids);
38700 filterobj->setPrivate(filter);
38703 sp[-2] = OBJECT_TO_JSVAL(filterobj);
38705 resobj = js_NewXMLObject(cx, JSXML_CLASS_LIST);
38710 filter->result = (JSXML *) resobj->getPrivate();
38715 filter = (JSXMLFilter *) JSVAL_TO_OBJECT(sp[-2])->getPrivate();
38719 if (js_ValueToBoolean(Valueify(sp[-1])) &&
38720 !Append(cx, filter->result, filter->kid)) {
38726 filter->kid = (JSXML *) filter->cursor.getNext();
38727 if (!filter->kid) {
38732 filter->cursor.disconnect();
38734 sp[-2] = OBJECT_TO_JSVAL(filter->result->object);
38737 kidobj = js_GetXMLObject(cx, filter->kid);
38743 sp[-1] = OBJECT_TO_JSVAL(kidobj);
38748 js_ValueToXMLObject(JSContext *cx, const Value &v)
38750 return ToXML(cx, Jsvalify(v));
38754 js_ValueToXMLListObject(JSContext *cx, const Value &v)
38756 return ToXMLList(cx, Jsvalify(v));
38760 js_NewXMLSpecialObject(JSContext *cx, JSXMLClass xml_class, JSString *name,
38768 if (!GetXMLSettingFlags(cx, &flags))
38771 if ((xml_class == JSXML_CLASS_COMMENT &&
38772 (flags & ((JSUint32)1 << (0)))) ||
38773 (xml_class == JSXML_CLASS_PROCESSING_INSTRUCTION &&
38774 (flags & ((JSUint32)1 << (1))))) {
38775 return js_NewXMLObject(cx, JSXML_CLASS_TEXT);
38778 obj = js_NewXMLObject(cx, xml_class);
38781 xml = (JSXML *) obj->getPrivate();
38783 JSLinearString *linearName = name->ensureLinear(cx);
38786 qn = NewXMLQName(cx, cx->runtime->emptyString, __null, linearName);
38791 xml->u.value = value;
38796 js_MakeXMLCDATAString(JSContext *cx, JSString *str)
38798 StringBuffer sb(cx);
38799 return MakeXMLCDATAString(cx, sb, str);
38803 js_MakeXMLCommentString(JSContext *cx, JSString *str)
38805 StringBuffer sb(cx);
38806 return MakeXMLCommentString(cx, sb, str);
38810 js_MakeXMLPIString(JSContext *cx, JSString *name, JSString *str)
38812 StringBuffer sb(cx);
38813 return MakeXMLPIString(cx, sb, name, str);