jbarnette-johnson 1.0.0.200806240111 → 1.0.0.200807291507

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (269) hide show
  1. data/MANIFEST +1 -0
  2. data/Rakefile +3 -10
  3. data/bin/johnson +2 -1
  4. data/ext/spidermonkey/context.c +3 -4
  5. data/ext/spidermonkey/context.h +1 -1
  6. data/ext/spidermonkey/conversions.c +39 -33
  7. data/ext/spidermonkey/debugger.c +5 -5
  8. data/ext/spidermonkey/immutable_node.c.erb +11 -11
  9. data/ext/spidermonkey/jroot.h +4 -4
  10. data/ext/spidermonkey/js_land_proxy.c +9 -8
  11. data/ext/spidermonkey/ruby_land_proxy.c +5 -4
  12. data/ext/spidermonkey/runtime.c +1 -1
  13. data/johnson.gemspec +36 -0
  14. data/lib/hoe.rb +0 -7
  15. data/lib/johnson/cli/options.rb +10 -4
  16. data/lib/johnson/spidermonkey/runtime.rb +2 -2
  17. data/lib/johnson/version.rb +4 -2
  18. data/lib/johnson.rb +1 -0
  19. data/test/johnson/runtime_test.rb +11 -0
  20. data/test/johnson/spidermonkey/ruby_land_proxy_test.rb +6 -0
  21. data/vendor/spidermonkey/.cvsignore +9 -0
  22. data/vendor/spidermonkey/Makefile.in +462 -0
  23. data/vendor/spidermonkey/Makefile.ref +364 -0
  24. data/vendor/spidermonkey/README.html +820 -0
  25. data/vendor/spidermonkey/SpiderMonkey.rsp +12 -0
  26. data/vendor/spidermonkey/Y.js +19 -0
  27. data/vendor/spidermonkey/build.mk +43 -0
  28. data/vendor/spidermonkey/config/AIX4.1.mk +65 -0
  29. data/vendor/spidermonkey/config/AIX4.2.mk +64 -0
  30. data/vendor/spidermonkey/config/AIX4.3.mk +65 -0
  31. data/vendor/spidermonkey/config/Darwin.mk +83 -0
  32. data/vendor/spidermonkey/config/Darwin1.3.mk +81 -0
  33. data/vendor/spidermonkey/config/Darwin1.4.mk +41 -0
  34. data/vendor/spidermonkey/config/Darwin5.2.mk +81 -0
  35. data/vendor/spidermonkey/config/Darwin5.3.mk +81 -0
  36. data/vendor/spidermonkey/config/HP-UXB.10.10.mk +77 -0
  37. data/vendor/spidermonkey/config/HP-UXB.10.20.mk +77 -0
  38. data/vendor/spidermonkey/config/HP-UXB.11.00.mk +80 -0
  39. data/vendor/spidermonkey/config/IRIX.mk +87 -0
  40. data/vendor/spidermonkey/config/IRIX5.3.mk +44 -0
  41. data/vendor/spidermonkey/config/IRIX6.1.mk +44 -0
  42. data/vendor/spidermonkey/config/IRIX6.2.mk +44 -0
  43. data/vendor/spidermonkey/config/IRIX6.3.mk +44 -0
  44. data/vendor/spidermonkey/config/IRIX6.5.mk +44 -0
  45. data/vendor/spidermonkey/config/Linux_All.mk +103 -0
  46. data/vendor/spidermonkey/config/Mac_OS10.0.mk +82 -0
  47. data/vendor/spidermonkey/config/OSF1V4.0.mk +72 -0
  48. data/vendor/spidermonkey/config/OSF1V5.0.mk +69 -0
  49. data/vendor/spidermonkey/config/SunOS4.1.4.mk +101 -0
  50. data/vendor/spidermonkey/config/SunOS5.10.mk +50 -0
  51. data/vendor/spidermonkey/config/SunOS5.3.mk +91 -0
  52. data/vendor/spidermonkey/config/SunOS5.4.mk +92 -0
  53. data/vendor/spidermonkey/config/SunOS5.5.1.mk +44 -0
  54. data/vendor/spidermonkey/config/SunOS5.5.mk +87 -0
  55. data/vendor/spidermonkey/config/SunOS5.6.mk +89 -0
  56. data/vendor/spidermonkey/config/SunOS5.7.mk +44 -0
  57. data/vendor/spidermonkey/config/SunOS5.8.mk +44 -0
  58. data/vendor/spidermonkey/config/SunOS5.9.mk +44 -0
  59. data/vendor/spidermonkey/config/WINNT4.0.mk +117 -0
  60. data/vendor/spidermonkey/config/WINNT5.0.mk +117 -0
  61. data/vendor/spidermonkey/config/WINNT5.1.mk +117 -0
  62. data/vendor/spidermonkey/config/WINNT5.2.mk +117 -0
  63. data/vendor/spidermonkey/config/WINNT6.0.mk +117 -0
  64. data/vendor/spidermonkey/config/dgux.mk +64 -0
  65. data/vendor/spidermonkey/config.mk +192 -0
  66. data/vendor/spidermonkey/editline/Makefile.ref +144 -0
  67. data/vendor/spidermonkey/editline/README +83 -0
  68. data/vendor/spidermonkey/editline/editline.3 +175 -0
  69. data/vendor/spidermonkey/editline/editline.c +1369 -0
  70. data/vendor/spidermonkey/editline/editline.h +135 -0
  71. data/vendor/spidermonkey/editline/sysunix.c +182 -0
  72. data/vendor/spidermonkey/editline/unix.h +82 -0
  73. data/vendor/spidermonkey/fdlibm/.cvsignore +7 -0
  74. data/vendor/spidermonkey/fdlibm/Makefile.in +127 -0
  75. data/vendor/spidermonkey/fdlibm/Makefile.ref +192 -0
  76. data/vendor/spidermonkey/fdlibm/e_acos.c +147 -0
  77. data/vendor/spidermonkey/fdlibm/e_acosh.c +105 -0
  78. data/vendor/spidermonkey/fdlibm/e_asin.c +156 -0
  79. data/vendor/spidermonkey/fdlibm/e_atan2.c +165 -0
  80. data/vendor/spidermonkey/fdlibm/e_atanh.c +110 -0
  81. data/vendor/spidermonkey/fdlibm/e_cosh.c +133 -0
  82. data/vendor/spidermonkey/fdlibm/e_exp.c +202 -0
  83. data/vendor/spidermonkey/fdlibm/e_fmod.c +184 -0
  84. data/vendor/spidermonkey/fdlibm/e_gamma.c +71 -0
  85. data/vendor/spidermonkey/fdlibm/e_gamma_r.c +70 -0
  86. data/vendor/spidermonkey/fdlibm/e_hypot.c +173 -0
  87. data/vendor/spidermonkey/fdlibm/e_j0.c +524 -0
  88. data/vendor/spidermonkey/fdlibm/e_j1.c +523 -0
  89. data/vendor/spidermonkey/fdlibm/e_jn.c +315 -0
  90. data/vendor/spidermonkey/fdlibm/e_lgamma.c +71 -0
  91. data/vendor/spidermonkey/fdlibm/e_lgamma_r.c +347 -0
  92. data/vendor/spidermonkey/fdlibm/e_log.c +184 -0
  93. data/vendor/spidermonkey/fdlibm/e_log10.c +134 -0
  94. data/vendor/spidermonkey/fdlibm/e_pow.c +386 -0
  95. data/vendor/spidermonkey/fdlibm/e_rem_pio2.c +222 -0
  96. data/vendor/spidermonkey/fdlibm/e_remainder.c +120 -0
  97. data/vendor/spidermonkey/fdlibm/e_scalb.c +89 -0
  98. data/vendor/spidermonkey/fdlibm/e_sinh.c +122 -0
  99. data/vendor/spidermonkey/fdlibm/e_sqrt.c +497 -0
  100. data/vendor/spidermonkey/fdlibm/fdlibm.h +273 -0
  101. data/vendor/spidermonkey/fdlibm/fdlibm.mak +1453 -0
  102. data/vendor/spidermonkey/fdlibm/fdlibm.mdp +0 -0
  103. data/vendor/spidermonkey/fdlibm/k_cos.c +135 -0
  104. data/vendor/spidermonkey/fdlibm/k_rem_pio2.c +354 -0
  105. data/vendor/spidermonkey/fdlibm/k_sin.c +114 -0
  106. data/vendor/spidermonkey/fdlibm/k_standard.c +785 -0
  107. data/vendor/spidermonkey/fdlibm/k_tan.c +170 -0
  108. data/vendor/spidermonkey/fdlibm/s_asinh.c +101 -0
  109. data/vendor/spidermonkey/fdlibm/s_atan.c +175 -0
  110. data/vendor/spidermonkey/fdlibm/s_cbrt.c +133 -0
  111. data/vendor/spidermonkey/fdlibm/s_ceil.c +120 -0
  112. data/vendor/spidermonkey/fdlibm/s_copysign.c +72 -0
  113. data/vendor/spidermonkey/fdlibm/s_cos.c +118 -0
  114. data/vendor/spidermonkey/fdlibm/s_erf.c +356 -0
  115. data/vendor/spidermonkey/fdlibm/s_expm1.c +267 -0
  116. data/vendor/spidermonkey/fdlibm/s_fabs.c +70 -0
  117. data/vendor/spidermonkey/fdlibm/s_finite.c +71 -0
  118. data/vendor/spidermonkey/fdlibm/s_floor.c +121 -0
  119. data/vendor/spidermonkey/fdlibm/s_frexp.c +99 -0
  120. data/vendor/spidermonkey/fdlibm/s_ilogb.c +85 -0
  121. data/vendor/spidermonkey/fdlibm/s_isnan.c +74 -0
  122. data/vendor/spidermonkey/fdlibm/s_ldexp.c +66 -0
  123. data/vendor/spidermonkey/fdlibm/s_lib_version.c +73 -0
  124. data/vendor/spidermonkey/fdlibm/s_log1p.c +211 -0
  125. data/vendor/spidermonkey/fdlibm/s_logb.c +79 -0
  126. data/vendor/spidermonkey/fdlibm/s_matherr.c +64 -0
  127. data/vendor/spidermonkey/fdlibm/s_modf.c +132 -0
  128. data/vendor/spidermonkey/fdlibm/s_nextafter.c +124 -0
  129. data/vendor/spidermonkey/fdlibm/s_rint.c +131 -0
  130. data/vendor/spidermonkey/fdlibm/s_scalbn.c +107 -0
  131. data/vendor/spidermonkey/fdlibm/s_signgam.c +40 -0
  132. data/vendor/spidermonkey/fdlibm/s_significand.c +68 -0
  133. data/vendor/spidermonkey/fdlibm/s_sin.c +118 -0
  134. data/vendor/spidermonkey/fdlibm/s_tan.c +112 -0
  135. data/vendor/spidermonkey/fdlibm/s_tanh.c +122 -0
  136. data/vendor/spidermonkey/fdlibm/w_acos.c +78 -0
  137. data/vendor/spidermonkey/fdlibm/w_acosh.c +78 -0
  138. data/vendor/spidermonkey/fdlibm/w_asin.c +80 -0
  139. data/vendor/spidermonkey/fdlibm/w_atan2.c +79 -0
  140. data/vendor/spidermonkey/fdlibm/w_atanh.c +81 -0
  141. data/vendor/spidermonkey/fdlibm/w_cosh.c +77 -0
  142. data/vendor/spidermonkey/fdlibm/w_exp.c +88 -0
  143. data/vendor/spidermonkey/fdlibm/w_fmod.c +78 -0
  144. data/vendor/spidermonkey/fdlibm/w_gamma.c +85 -0
  145. data/vendor/spidermonkey/fdlibm/w_gamma_r.c +81 -0
  146. data/vendor/spidermonkey/fdlibm/w_hypot.c +78 -0
  147. data/vendor/spidermonkey/fdlibm/w_j0.c +105 -0
  148. data/vendor/spidermonkey/fdlibm/w_j1.c +106 -0
  149. data/vendor/spidermonkey/fdlibm/w_jn.c +128 -0
  150. data/vendor/spidermonkey/fdlibm/w_lgamma.c +85 -0
  151. data/vendor/spidermonkey/fdlibm/w_lgamma_r.c +81 -0
  152. data/vendor/spidermonkey/fdlibm/w_log.c +78 -0
  153. data/vendor/spidermonkey/fdlibm/w_log10.c +81 -0
  154. data/vendor/spidermonkey/fdlibm/w_pow.c +99 -0
  155. data/vendor/spidermonkey/fdlibm/w_remainder.c +77 -0
  156. data/vendor/spidermonkey/fdlibm/w_scalb.c +95 -0
  157. data/vendor/spidermonkey/fdlibm/w_sinh.c +77 -0
  158. data/vendor/spidermonkey/fdlibm/w_sqrt.c +77 -0
  159. data/vendor/spidermonkey/javascript-trace.d +73 -0
  160. data/vendor/spidermonkey/js.c +3951 -0
  161. data/vendor/spidermonkey/js.mak +4438 -0
  162. data/vendor/spidermonkey/js.mdp +0 -0
  163. data/vendor/spidermonkey/js.msg +307 -0
  164. data/vendor/spidermonkey/js.pkg +2 -0
  165. data/vendor/spidermonkey/js3240.rc +79 -0
  166. data/vendor/spidermonkey/jsOS240.def +654 -0
  167. data/vendor/spidermonkey/jsapi.c +5836 -0
  168. data/vendor/spidermonkey/jsapi.h +2624 -0
  169. data/vendor/spidermonkey/jsarena.c +450 -0
  170. data/vendor/spidermonkey/jsarena.h +318 -0
  171. data/vendor/spidermonkey/jsarray.c +2988 -0
  172. data/vendor/spidermonkey/jsarray.h +124 -0
  173. data/vendor/spidermonkey/jsatom.c +1045 -0
  174. data/vendor/spidermonkey/jsatom.h +442 -0
  175. data/vendor/spidermonkey/jsbit.h +253 -0
  176. data/vendor/spidermonkey/jsbool.c +176 -0
  177. data/vendor/spidermonkey/jsbool.h +73 -0
  178. data/vendor/spidermonkey/jsclist.h +139 -0
  179. data/vendor/spidermonkey/jscntxt.c +1348 -0
  180. data/vendor/spidermonkey/jscntxt.h +1120 -0
  181. data/vendor/spidermonkey/jscompat.h +57 -0
  182. data/vendor/spidermonkey/jsconfig.h +248 -0
  183. data/vendor/spidermonkey/jsconfig.mk +181 -0
  184. data/vendor/spidermonkey/jscpucfg.c +383 -0
  185. data/vendor/spidermonkey/jscpucfg.h +212 -0
  186. data/vendor/spidermonkey/jsdate.c +2398 -0
  187. data/vendor/spidermonkey/jsdate.h +124 -0
  188. data/vendor/spidermonkey/jsdbgapi.c +1799 -0
  189. data/vendor/spidermonkey/jsdbgapi.h +464 -0
  190. data/vendor/spidermonkey/jsdhash.c +868 -0
  191. data/vendor/spidermonkey/jsdhash.h +592 -0
  192. data/vendor/spidermonkey/jsdtoa.c +3167 -0
  193. data/vendor/spidermonkey/jsdtoa.h +130 -0
  194. data/vendor/spidermonkey/jsdtracef.c +317 -0
  195. data/vendor/spidermonkey/jsdtracef.h +77 -0
  196. data/vendor/spidermonkey/jsemit.c +6909 -0
  197. data/vendor/spidermonkey/jsemit.h +741 -0
  198. data/vendor/spidermonkey/jsexn.c +1371 -0
  199. data/vendor/spidermonkey/jsexn.h +96 -0
  200. data/vendor/spidermonkey/jsfile.c +2736 -0
  201. data/vendor/spidermonkey/jsfile.h +56 -0
  202. data/vendor/spidermonkey/jsfile.msg +90 -0
  203. data/vendor/spidermonkey/jsfun.c +2634 -0
  204. data/vendor/spidermonkey/jsfun.h +254 -0
  205. data/vendor/spidermonkey/jsgc.c +3554 -0
  206. data/vendor/spidermonkey/jsgc.h +403 -0
  207. data/vendor/spidermonkey/jshash.c +476 -0
  208. data/vendor/spidermonkey/jshash.h +151 -0
  209. data/vendor/spidermonkey/jsify.pl +485 -0
  210. data/vendor/spidermonkey/jsinterp.c +6981 -0
  211. data/vendor/spidermonkey/jsinterp.h +521 -0
  212. data/vendor/spidermonkey/jsinvoke.c +43 -0
  213. data/vendor/spidermonkey/jsiter.c +1067 -0
  214. data/vendor/spidermonkey/jsiter.h +122 -0
  215. data/vendor/spidermonkey/jskeyword.tbl +124 -0
  216. data/vendor/spidermonkey/jskwgen.c +460 -0
  217. data/vendor/spidermonkey/jslibmath.h +266 -0
  218. data/vendor/spidermonkey/jslock.c +1309 -0
  219. data/vendor/spidermonkey/jslock.h +313 -0
  220. data/vendor/spidermonkey/jslocko.asm +60 -0
  221. data/vendor/spidermonkey/jslog2.c +94 -0
  222. data/vendor/spidermonkey/jslong.c +264 -0
  223. data/vendor/spidermonkey/jslong.h +412 -0
  224. data/vendor/spidermonkey/jsmath.c +568 -0
  225. data/vendor/spidermonkey/jsmath.h +57 -0
  226. data/vendor/spidermonkey/jsnum.c +1228 -0
  227. data/vendor/spidermonkey/jsnum.h +283 -0
  228. data/vendor/spidermonkey/jsobj.c +5266 -0
  229. data/vendor/spidermonkey/jsobj.h +709 -0
  230. data/vendor/spidermonkey/jsopcode.c +5245 -0
  231. data/vendor/spidermonkey/jsopcode.h +394 -0
  232. data/vendor/spidermonkey/jsopcode.tbl +523 -0
  233. data/vendor/spidermonkey/jsotypes.h +202 -0
  234. data/vendor/spidermonkey/jsparse.c +6680 -0
  235. data/vendor/spidermonkey/jsparse.h +511 -0
  236. data/vendor/spidermonkey/jsprf.c +1262 -0
  237. data/vendor/spidermonkey/jsprf.h +150 -0
  238. data/vendor/spidermonkey/jsproto.tbl +128 -0
  239. data/vendor/spidermonkey/jsprvtd.h +267 -0
  240. data/vendor/spidermonkey/jspubtd.h +744 -0
  241. data/vendor/spidermonkey/jsregexp.c +4352 -0
  242. data/vendor/spidermonkey/jsregexp.h +183 -0
  243. data/vendor/spidermonkey/jsreops.tbl +145 -0
  244. data/vendor/spidermonkey/jsscan.c +2003 -0
  245. data/vendor/spidermonkey/jsscan.h +387 -0
  246. data/vendor/spidermonkey/jsscope.c +1948 -0
  247. data/vendor/spidermonkey/jsscope.h +418 -0
  248. data/vendor/spidermonkey/jsscript.c +1832 -0
  249. data/vendor/spidermonkey/jsscript.h +287 -0
  250. data/vendor/spidermonkey/jsshell.msg +50 -0
  251. data/vendor/spidermonkey/jsstddef.h +83 -0
  252. data/vendor/spidermonkey/jsstr.c +5004 -0
  253. data/vendor/spidermonkey/jsstr.h +641 -0
  254. data/vendor/spidermonkey/jstypes.h +475 -0
  255. data/vendor/spidermonkey/jsutil.c +345 -0
  256. data/vendor/spidermonkey/jsutil.h +157 -0
  257. data/vendor/spidermonkey/jsxdrapi.c +800 -0
  258. data/vendor/spidermonkey/jsxdrapi.h +218 -0
  259. data/vendor/spidermonkey/jsxml.c +8471 -0
  260. data/vendor/spidermonkey/jsxml.h +349 -0
  261. data/vendor/spidermonkey/lock_SunOS.s +119 -0
  262. data/vendor/spidermonkey/perfect.js +39 -0
  263. data/vendor/spidermonkey/plify_jsdhash.sed +36 -0
  264. data/vendor/spidermonkey/prmjtime.c +846 -0
  265. data/vendor/spidermonkey/prmjtime.h +103 -0
  266. data/vendor/spidermonkey/resource.h +15 -0
  267. data/vendor/spidermonkey/rules.mk +197 -0
  268. data/vendor/spidermonkey/win32.order +384 -0
  269. metadata +4 -3
@@ -0,0 +1,592 @@
1
+ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
+ /* ***** BEGIN LICENSE BLOCK *****
3
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
+ *
5
+ * The contents of this file are subject to the Mozilla Public License Version
6
+ * 1.1 (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ * http://www.mozilla.org/MPL/
9
+ *
10
+ * Software distributed under the License is distributed on an "AS IS" basis,
11
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12
+ * for the specific language governing rights and limitations under the
13
+ * License.
14
+ *
15
+ * The Original Code is Mozilla JavaScript code.
16
+ *
17
+ * The Initial Developer of the Original Code is
18
+ * Netscape Communications Corporation.
19
+ * Portions created by the Initial Developer are Copyright (C) 1999-2001
20
+ * the Initial Developer. All Rights Reserved.
21
+ *
22
+ * Contributor(s):
23
+ * Brendan Eich <brendan@mozilla.org> (Original Author)
24
+ *
25
+ * Alternatively, the contents of this file may be used under the terms of
26
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
27
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28
+ * in which case the provisions of the GPL or the LGPL are applicable instead
29
+ * of those above. If you wish to allow use of your version of this file only
30
+ * under the terms of either the GPL or the LGPL, and not to allow others to
31
+ * use your version of this file under the terms of the MPL, indicate your
32
+ * decision by deleting the provisions above and replace them with the notice
33
+ * and other provisions required by the GPL or the LGPL. If you do not delete
34
+ * the provisions above, a recipient may use your version of this file under
35
+ * the terms of any one of the MPL, the GPL or the LGPL.
36
+ *
37
+ * ***** END LICENSE BLOCK ***** */
38
+
39
+ #ifndef jsdhash_h___
40
+ #define jsdhash_h___
41
+ /*
42
+ * Double hashing, a la Knuth 6.
43
+ */
44
+ #include "jstypes.h"
45
+
46
+ JS_BEGIN_EXTERN_C
47
+
48
+ #if defined(__GNUC__) && defined(__i386__) && (__GNUC__ >= 3) && !defined(XP_OS2)
49
+ #define JS_DHASH_FASTCALL __attribute__ ((regparm (3),stdcall))
50
+ #elif defined(XP_WIN)
51
+ #define JS_DHASH_FASTCALL __fastcall
52
+ #else
53
+ #define JS_DHASH_FASTCALL
54
+ #endif
55
+
56
+ #ifdef DEBUG_XXXbrendan
57
+ #define JS_DHASHMETER 1
58
+ #endif
59
+
60
+ /* Table size limit, do not equal or exceed (see min&maxAlphaFrac, below). */
61
+ #undef JS_DHASH_SIZE_LIMIT
62
+ #define JS_DHASH_SIZE_LIMIT JS_BIT(24)
63
+
64
+ /* Minimum table size, or gross entry count (net is at most .75 loaded). */
65
+ #ifndef JS_DHASH_MIN_SIZE
66
+ #define JS_DHASH_MIN_SIZE 16
67
+ #elif (JS_DHASH_MIN_SIZE & (JS_DHASH_MIN_SIZE - 1)) != 0
68
+ #error "JS_DHASH_MIN_SIZE must be a power of two!"
69
+ #endif
70
+
71
+ /*
72
+ * Multiplicative hash uses an unsigned 32 bit integer and the golden ratio,
73
+ * expressed as a fixed-point 32-bit fraction.
74
+ */
75
+ #define JS_DHASH_BITS 32
76
+ #define JS_DHASH_GOLDEN_RATIO 0x9E3779B9U
77
+
78
+ /* Primitive and forward-struct typedefs. */
79
+ typedef uint32 JSDHashNumber;
80
+ typedef struct JSDHashEntryHdr JSDHashEntryHdr;
81
+ typedef struct JSDHashEntryStub JSDHashEntryStub;
82
+ typedef struct JSDHashTable JSDHashTable;
83
+ typedef struct JSDHashTableOps JSDHashTableOps;
84
+
85
+ /*
86
+ * Table entry header structure.
87
+ *
88
+ * In order to allow in-line allocation of key and value, we do not declare
89
+ * either here. Instead, the API uses const void *key as a formal parameter.
90
+ * The key need not be stored in the entry; it may be part of the value, but
91
+ * need not be stored at all.
92
+ *
93
+ * Callback types are defined below and grouped into the JSDHashTableOps
94
+ * structure, for single static initialization per hash table sub-type.
95
+ *
96
+ * Each hash table sub-type should nest the JSDHashEntryHdr structure at the
97
+ * front of its particular entry type. The keyHash member contains the result
98
+ * of multiplying the hash code returned from the hashKey callback (see below)
99
+ * by JS_DHASH_GOLDEN_RATIO, then constraining the result to avoid the magic 0
100
+ * and 1 values. The stored keyHash value is table size invariant, and it is
101
+ * maintained automatically by JS_DHashTableOperate -- users should never set
102
+ * it, and its only uses should be via the entry macros below.
103
+ *
104
+ * The JS_DHASH_ENTRY_IS_LIVE macro tests whether entry is neither free nor
105
+ * removed. An entry may be either busy or free; if busy, it may be live or
106
+ * removed. Consumers of this API should not access members of entries that
107
+ * are not live.
108
+ *
109
+ * However, use JS_DHASH_ENTRY_IS_BUSY for faster liveness testing of entries
110
+ * returned by JS_DHashTableOperate, as JS_DHashTableOperate never returns a
111
+ * non-live, busy (i.e., removed) entry pointer to its caller. See below for
112
+ * more details on JS_DHashTableOperate's calling rules.
113
+ */
114
+ struct JSDHashEntryHdr {
115
+ JSDHashNumber keyHash; /* every entry must begin like this */
116
+ };
117
+
118
+ #define JS_DHASH_ENTRY_IS_FREE(entry) ((entry)->keyHash == 0)
119
+ #define JS_DHASH_ENTRY_IS_BUSY(entry) (!JS_DHASH_ENTRY_IS_FREE(entry))
120
+ #define JS_DHASH_ENTRY_IS_LIVE(entry) ((entry)->keyHash >= 2)
121
+
122
+ /*
123
+ * A JSDHashTable is currently 8 words (without the JS_DHASHMETER overhead)
124
+ * on most architectures, and may be allocated on the stack or within another
125
+ * structure or class (see below for the Init and Finish functions to use).
126
+ *
127
+ * To decide whether to use double hashing vs. chaining, we need to develop a
128
+ * trade-off relation, as follows:
129
+ *
130
+ * Let alpha be the load factor, esize the entry size in words, count the
131
+ * entry count, and pow2 the power-of-two table size in entries.
132
+ *
133
+ * (JSDHashTable overhead) > (JSHashTable overhead)
134
+ * (unused table entry space) > (malloc and .next overhead per entry) +
135
+ * (buckets overhead)
136
+ * (1 - alpha) * esize * pow2 > 2 * count + pow2
137
+ *
138
+ * Notice that alpha is by definition (count / pow2):
139
+ *
140
+ * (1 - alpha) * esize * pow2 > 2 * alpha * pow2 + pow2
141
+ * (1 - alpha) * esize > 2 * alpha + 1
142
+ *
143
+ * esize > (1 + 2 * alpha) / (1 - alpha)
144
+ *
145
+ * This assumes both tables must keep keyHash, key, and value for each entry,
146
+ * where key and value point to separately allocated strings or structures.
147
+ * If key and value can be combined into one pointer, then the trade-off is:
148
+ *
149
+ * esize > (1 + 3 * alpha) / (1 - alpha)
150
+ *
151
+ * If the entry value can be a subtype of JSDHashEntryHdr, rather than a type
152
+ * that must be allocated separately and referenced by an entry.value pointer
153
+ * member, and provided key's allocation can be fused with its entry's, then
154
+ * k (the words wasted per entry with chaining) is 4.
155
+ *
156
+ * To see these curves, feed gnuplot input like so:
157
+ *
158
+ * gnuplot> f(x,k) = (1 + k * x) / (1 - x)
159
+ * gnuplot> plot [0:.75] f(x,2), f(x,3), f(x,4)
160
+ *
161
+ * For k of 2 and a well-loaded table (alpha > .5), esize must be more than 4
162
+ * words for chaining to be more space-efficient than double hashing.
163
+ *
164
+ * Solving for alpha helps us decide when to shrink an underloaded table:
165
+ *
166
+ * esize > (1 + k * alpha) / (1 - alpha)
167
+ * esize - alpha * esize > 1 + k * alpha
168
+ * esize - 1 > (k + esize) * alpha
169
+ * (esize - 1) / (k + esize) > alpha
170
+ *
171
+ * alpha < (esize - 1) / (esize + k)
172
+ *
173
+ * Therefore double hashing should keep alpha >= (esize - 1) / (esize + k),
174
+ * assuming esize is not too large (in which case, chaining should probably be
175
+ * used for any alpha). For esize=2 and k=3, we want alpha >= .2; for esize=3
176
+ * and k=2, we want alpha >= .4. For k=4, esize could be 6, and alpha >= .5
177
+ * would still obtain. See the JS_DHASH_MIN_ALPHA macro further below.
178
+ *
179
+ * The current implementation uses a configurable lower bound on alpha, which
180
+ * defaults to .25, when deciding to shrink the table (while still respecting
181
+ * JS_DHASH_MIN_SIZE).
182
+ *
183
+ * Note a qualitative difference between chaining and double hashing: under
184
+ * chaining, entry addresses are stable across table shrinks and grows. With
185
+ * double hashing, you can't safely hold an entry pointer and use it after an
186
+ * ADD or REMOVE operation, unless you sample table->generation before adding
187
+ * or removing, and compare the sample after, dereferencing the entry pointer
188
+ * only if table->generation has not changed.
189
+ *
190
+ * The moral of this story: there is no one-size-fits-all hash table scheme,
191
+ * but for small table entry size, and assuming entry address stability is not
192
+ * required, double hashing wins.
193
+ */
194
+ struct JSDHashTable {
195
+ const JSDHashTableOps *ops; /* virtual operations, see below */
196
+ void *data; /* ops- and instance-specific data */
197
+ int16 hashShift; /* multiplicative hash shift */
198
+ uint8 maxAlphaFrac; /* 8-bit fixed point max alpha */
199
+ uint8 minAlphaFrac; /* 8-bit fixed point min alpha */
200
+ uint32 entrySize; /* number of bytes in an entry */
201
+ uint32 entryCount; /* number of entries in table */
202
+ uint32 removedCount; /* removed entry sentinels in table */
203
+ uint32 generation; /* entry storage generation number */
204
+ char *entryStore; /* entry storage */
205
+ #ifdef JS_DHASHMETER
206
+ struct JSDHashStats {
207
+ uint32 searches; /* total number of table searches */
208
+ uint32 steps; /* hash chain links traversed */
209
+ uint32 hits; /* searches that found key */
210
+ uint32 misses; /* searches that didn't find key */
211
+ uint32 lookups; /* number of JS_DHASH_LOOKUPs */
212
+ uint32 addMisses; /* adds that miss, and do work */
213
+ uint32 addOverRemoved; /* adds that recycled a removed entry */
214
+ uint32 addHits; /* adds that hit an existing entry */
215
+ uint32 addFailures; /* out-of-memory during add growth */
216
+ uint32 removeHits; /* removes that hit, and do work */
217
+ uint32 removeMisses; /* useless removes that miss */
218
+ uint32 removeFrees; /* removes that freed entry directly */
219
+ uint32 removeEnums; /* removes done by Enumerate */
220
+ uint32 grows; /* table expansions */
221
+ uint32 shrinks; /* table contractions */
222
+ uint32 compresses; /* table compressions */
223
+ uint32 enumShrinks; /* contractions after Enumerate */
224
+ } stats;
225
+ #endif
226
+ };
227
+
228
+ /*
229
+ * Size in entries (gross, not net of free and removed sentinels) for table.
230
+ * We store hashShift rather than sizeLog2 to optimize the collision-free case
231
+ * in SearchTable.
232
+ */
233
+ #define JS_DHASH_TABLE_SIZE(table) JS_BIT(JS_DHASH_BITS - (table)->hashShift)
234
+
235
+ /*
236
+ * Table space at entryStore is allocated and freed using these callbacks.
237
+ * The allocator should return null on error only (not if called with nbytes
238
+ * equal to 0; but note that jsdhash.c code will never call with 0 nbytes).
239
+ */
240
+ typedef void *
241
+ (* JS_DLL_CALLBACK JSDHashAllocTable)(JSDHashTable *table, uint32 nbytes);
242
+
243
+ typedef void
244
+ (* JS_DLL_CALLBACK JSDHashFreeTable) (JSDHashTable *table, void *ptr);
245
+
246
+ /*
247
+ * Compute the hash code for a given key to be looked up, added, or removed
248
+ * from table. A hash code may have any JSDHashNumber value.
249
+ */
250
+ typedef JSDHashNumber
251
+ (* JS_DLL_CALLBACK JSDHashHashKey) (JSDHashTable *table, const void *key);
252
+
253
+ /*
254
+ * Compare the key identifying entry in table with the provided key parameter.
255
+ * Return JS_TRUE if keys match, JS_FALSE otherwise.
256
+ */
257
+ typedef JSBool
258
+ (* JS_DLL_CALLBACK JSDHashMatchEntry)(JSDHashTable *table,
259
+ const JSDHashEntryHdr *entry,
260
+ const void *key);
261
+
262
+ /*
263
+ * Copy the data starting at from to the new entry storage at to. Do not add
264
+ * reference counts for any strong references in the entry, however, as this
265
+ * is a "move" operation: the old entry storage at from will be freed without
266
+ * any reference-decrementing callback shortly.
267
+ */
268
+ typedef void
269
+ (* JS_DLL_CALLBACK JSDHashMoveEntry)(JSDHashTable *table,
270
+ const JSDHashEntryHdr *from,
271
+ JSDHashEntryHdr *to);
272
+
273
+ /*
274
+ * Clear the entry and drop any strong references it holds. This callback is
275
+ * invoked during a JS_DHASH_REMOVE operation (see below for operation codes),
276
+ * but only if the given key is found in the table.
277
+ */
278
+ typedef void
279
+ (* JS_DLL_CALLBACK JSDHashClearEntry)(JSDHashTable *table,
280
+ JSDHashEntryHdr *entry);
281
+
282
+ /*
283
+ * Called when a table (whether allocated dynamically by itself, or nested in
284
+ * a larger structure, or allocated on the stack) is finished. This callback
285
+ * allows table->ops-specific code to finalize table->data.
286
+ */
287
+ typedef void
288
+ (* JS_DLL_CALLBACK JSDHashFinalize) (JSDHashTable *table);
289
+
290
+ /*
291
+ * Initialize a new entry, apart from keyHash. This function is called when
292
+ * JS_DHashTableOperate's JS_DHASH_ADD case finds no existing entry for the
293
+ * given key, and must add a new one. At that point, entry->keyHash is not
294
+ * set yet, to avoid claiming the last free entry in a severely overloaded
295
+ * table.
296
+ */
297
+ typedef JSBool
298
+ (* JS_DLL_CALLBACK JSDHashInitEntry)(JSDHashTable *table,
299
+ JSDHashEntryHdr *entry,
300
+ const void *key);
301
+
302
+ /*
303
+ * Finally, the "vtable" structure for JSDHashTable. The first eight hooks
304
+ * must be provided by implementations; they're called unconditionally by the
305
+ * generic jsdhash.c code. Hooks after these may be null.
306
+ *
307
+ * Summary of allocation-related hook usage with C++ placement new emphasis:
308
+ * allocTable Allocate raw bytes with malloc, no ctors run.
309
+ * freeTable Free raw bytes with free, no dtors run.
310
+ * initEntry Call placement new using default key-based ctor.
311
+ * Return JS_TRUE on success, JS_FALSE on error.
312
+ * moveEntry Call placement new using copy ctor, run dtor on old
313
+ * entry storage.
314
+ * clearEntry Run dtor on entry.
315
+ * finalize Stub unless table->data was initialized and needs to
316
+ * be finalized.
317
+ *
318
+ * Note the reason why initEntry is optional: the default hooks (stubs) clear
319
+ * entry storage: On successful JS_DHashTableOperate(tbl, key, JS_DHASH_ADD),
320
+ * the returned entry pointer addresses an entry struct whose keyHash member
321
+ * has been set non-zero, but all other entry members are still clear (null).
322
+ * JS_DHASH_ADD callers can test such members to see whether the entry was
323
+ * newly created by the JS_DHASH_ADD call that just succeeded. If placement
324
+ * new or similar initialization is required, define an initEntry hook. Of
325
+ * course, the clearEntry hook must zero or null appropriately.
326
+ *
327
+ * XXX assumes 0 is null for pointer types.
328
+ */
329
+ struct JSDHashTableOps {
330
+ /* Mandatory hooks. All implementations must provide these. */
331
+ JSDHashAllocTable allocTable;
332
+ JSDHashFreeTable freeTable;
333
+ JSDHashHashKey hashKey;
334
+ JSDHashMatchEntry matchEntry;
335
+ JSDHashMoveEntry moveEntry;
336
+ JSDHashClearEntry clearEntry;
337
+ JSDHashFinalize finalize;
338
+
339
+ /* Optional hooks start here. If null, these are not called. */
340
+ JSDHashInitEntry initEntry;
341
+ };
342
+
343
+ /*
344
+ * Default implementations for the above ops.
345
+ */
346
+ extern JS_PUBLIC_API(void *)
347
+ JS_DHashAllocTable(JSDHashTable *table, uint32 nbytes);
348
+
349
+ extern JS_PUBLIC_API(void)
350
+ JS_DHashFreeTable(JSDHashTable *table, void *ptr);
351
+
352
+ extern JS_PUBLIC_API(JSDHashNumber)
353
+ JS_DHashStringKey(JSDHashTable *table, const void *key);
354
+
355
+ /* A minimal entry contains a keyHash header and a void key pointer. */
356
+ struct JSDHashEntryStub {
357
+ JSDHashEntryHdr hdr;
358
+ const void *key;
359
+ };
360
+
361
+ extern JS_PUBLIC_API(JSDHashNumber)
362
+ JS_DHashVoidPtrKeyStub(JSDHashTable *table, const void *key);
363
+
364
+ extern JS_PUBLIC_API(JSBool)
365
+ JS_DHashMatchEntryStub(JSDHashTable *table,
366
+ const JSDHashEntryHdr *entry,
367
+ const void *key);
368
+
369
+ extern JS_PUBLIC_API(JSBool)
370
+ JS_DHashMatchStringKey(JSDHashTable *table,
371
+ const JSDHashEntryHdr *entry,
372
+ const void *key);
373
+
374
+ extern JS_PUBLIC_API(void)
375
+ JS_DHashMoveEntryStub(JSDHashTable *table,
376
+ const JSDHashEntryHdr *from,
377
+ JSDHashEntryHdr *to);
378
+
379
+ extern JS_PUBLIC_API(void)
380
+ JS_DHashClearEntryStub(JSDHashTable *table, JSDHashEntryHdr *entry);
381
+
382
+ extern JS_PUBLIC_API(void)
383
+ JS_DHashFreeStringKey(JSDHashTable *table, JSDHashEntryHdr *entry);
384
+
385
+ extern JS_PUBLIC_API(void)
386
+ JS_DHashFinalizeStub(JSDHashTable *table);
387
+
388
+ /*
389
+ * If you use JSDHashEntryStub or a subclass of it as your entry struct, and
390
+ * if your entries move via memcpy and clear via memset(0), you can use these
391
+ * stub operations.
392
+ */
393
+ extern JS_PUBLIC_API(const JSDHashTableOps *)
394
+ JS_DHashGetStubOps(void);
395
+
396
+ /*
397
+ * Dynamically allocate a new JSDHashTable using malloc, initialize it using
398
+ * JS_DHashTableInit, and return its address. Return null on malloc failure.
399
+ * Note that the entry storage at table->entryStore will be allocated using
400
+ * the ops->allocTable callback.
401
+ */
402
+ extern JS_PUBLIC_API(JSDHashTable *)
403
+ JS_NewDHashTable(const JSDHashTableOps *ops, void *data, uint32 entrySize,
404
+ uint32 capacity);
405
+
406
+ /*
407
+ * Finalize table's data, free its entry storage (via table->ops->freeTable),
408
+ * and return the memory starting at table to the malloc heap.
409
+ */
410
+ extern JS_PUBLIC_API(void)
411
+ JS_DHashTableDestroy(JSDHashTable *table);
412
+
413
+ /*
414
+ * Initialize table with ops, data, entrySize, and capacity. Capacity is a
415
+ * guess for the smallest table size at which the table will usually be less
416
+ * than 75% loaded (the table will grow or shrink as needed; capacity serves
417
+ * only to avoid inevitable early growth from JS_DHASH_MIN_SIZE).
418
+ */
419
+ extern JS_PUBLIC_API(JSBool)
420
+ JS_DHashTableInit(JSDHashTable *table, const JSDHashTableOps *ops, void *data,
421
+ uint32 entrySize, uint32 capacity);
422
+
423
+ /*
424
+ * Set maximum and minimum alpha for table. The defaults are 0.75 and .25.
425
+ * maxAlpha must be in [0.5, 0.9375] for the default JS_DHASH_MIN_SIZE; or if
426
+ * MinSize=JS_DHASH_MIN_SIZE <= 256, in [0.5, (float)(MinSize-1)/MinSize]; or
427
+ * else in [0.5, 255.0/256]. minAlpha must be in [0, maxAlpha / 2), so that
428
+ * we don't shrink on the very next remove after growing a table upon adding
429
+ * an entry that brings entryCount past maxAlpha * tableSize.
430
+ */
431
+ extern JS_PUBLIC_API(void)
432
+ JS_DHashTableSetAlphaBounds(JSDHashTable *table,
433
+ float maxAlpha,
434
+ float minAlpha);
435
+
436
+ /*
437
+ * Call this macro with k, the number of pointer-sized words wasted per entry
438
+ * under chaining, to compute the minimum alpha at which double hashing still
439
+ * beats chaining.
440
+ */
441
+ #define JS_DHASH_MIN_ALPHA(table, k) \
442
+ ((float)((table)->entrySize / sizeof(void *) - 1) \
443
+ / ((table)->entrySize / sizeof(void *) + (k)))
444
+
445
+ /*
446
+ * Default max/min alpha, and macros to compute the value for the |capacity|
447
+ * parameter to JS_NewDHashTable and JS_DHashTableInit, given default or any
448
+ * max alpha, such that adding entryCount entries right after initializing the
449
+ * table will not require a reallocation (so JS_DHASH_ADD can't fail for those
450
+ * JS_DHashTableOperate calls).
451
+ *
452
+ * NB: JS_DHASH_CAP is a helper macro meant for use only in JS_DHASH_CAPACITY.
453
+ * Don't use it directly!
454
+ */
455
+ #define JS_DHASH_DEFAULT_MAX_ALPHA 0.75
456
+ #define JS_DHASH_DEFAULT_MIN_ALPHA 0.25
457
+
458
+ #define JS_DHASH_CAP(entryCount, maxAlpha) \
459
+ ((uint32)((double)(entryCount) / (maxAlpha)))
460
+
461
+ #define JS_DHASH_CAPACITY(entryCount, maxAlpha) \
462
+ (JS_DHASH_CAP(entryCount, maxAlpha) + \
463
+ (((JS_DHASH_CAP(entryCount, maxAlpha) * (uint8)(0x100 * (maxAlpha))) \
464
+ >> 8) < (entryCount)))
465
+
466
+ #define JS_DHASH_DEFAULT_CAPACITY(entryCount) \
467
+ JS_DHASH_CAPACITY(entryCount, JS_DHASH_DEFAULT_MAX_ALPHA)
468
+
469
+ /*
470
+ * Finalize table's data, free its entry storage using table->ops->freeTable,
471
+ * and leave its members unchanged from their last live values (which leaves
472
+ * pointers dangling). If you want to burn cycles clearing table, it's up to
473
+ * your code to call memset.
474
+ */
475
+ extern JS_PUBLIC_API(void)
476
+ JS_DHashTableFinish(JSDHashTable *table);
477
+
478
+ /*
479
+ * To consolidate keyHash computation and table grow/shrink code, we use a
480
+ * single entry point for lookup, add, and remove operations. The operation
481
+ * codes are declared here, along with codes returned by JSDHashEnumerator
482
+ * functions, which control JS_DHashTableEnumerate's behavior.
483
+ */
484
+ typedef enum JSDHashOperator {
485
+ JS_DHASH_LOOKUP = 0, /* lookup entry */
486
+ JS_DHASH_ADD = 1, /* add entry */
487
+ JS_DHASH_REMOVE = 2, /* remove entry, or enumerator says remove */
488
+ JS_DHASH_NEXT = 0, /* enumerator says continue */
489
+ JS_DHASH_STOP = 1 /* enumerator says stop */
490
+ } JSDHashOperator;
491
+
492
+ /*
493
+ * To lookup a key in table, call:
494
+ *
495
+ * entry = JS_DHashTableOperate(table, key, JS_DHASH_LOOKUP);
496
+ *
497
+ * If JS_DHASH_ENTRY_IS_BUSY(entry) is true, key was found and it identifies
498
+ * entry. If JS_DHASH_ENTRY_IS_FREE(entry) is true, key was not found.
499
+ *
500
+ * To add an entry identified by key to table, call:
501
+ *
502
+ * entry = JS_DHashTableOperate(table, key, JS_DHASH_ADD);
503
+ *
504
+ * If entry is null upon return, then either the table is severely overloaded,
505
+ * and memory can't be allocated for entry storage via table->ops->allocTable;
506
+ * Or if table->ops->initEntry is non-null, the table->ops->initEntry op may
507
+ * have returned false.
508
+ *
509
+ * Otherwise, entry->keyHash has been set so that JS_DHASH_ENTRY_IS_BUSY(entry)
510
+ * is true, and it is up to the caller to initialize the key and value parts
511
+ * of the entry sub-type, if they have not been set already (i.e. if entry was
512
+ * not already in the table, and if the optional initEntry hook was not used).
513
+ *
514
+ * To remove an entry identified by key from table, call:
515
+ *
516
+ * (void) JS_DHashTableOperate(table, key, JS_DHASH_REMOVE);
517
+ *
518
+ * If key's entry is found, it is cleared (via table->ops->clearEntry) and
519
+ * the entry is marked so that JS_DHASH_ENTRY_IS_FREE(entry). This operation
520
+ * returns null unconditionally; you should ignore its return value.
521
+ */
522
+ extern JS_PUBLIC_API(JSDHashEntryHdr *) JS_DHASH_FASTCALL
523
+ JS_DHashTableOperate(JSDHashTable *table, const void *key, JSDHashOperator op);
524
+
525
+ /*
526
+ * Remove an entry already accessed via LOOKUP or ADD.
527
+ *
528
+ * NB: this is a "raw" or low-level routine, intended to be used only where
529
+ * the inefficiency of a full JS_DHashTableOperate (which rehashes in order
530
+ * to find the entry given its key) is not tolerable. This function does not
531
+ * shrink the table if it is underloaded. It does not update stats #ifdef
532
+ * JS_DHASHMETER, either.
533
+ */
534
+ extern JS_PUBLIC_API(void)
535
+ JS_DHashTableRawRemove(JSDHashTable *table, JSDHashEntryHdr *entry);
536
+
537
+ /*
538
+ * Enumerate entries in table using etor:
539
+ *
540
+ * count = JS_DHashTableEnumerate(table, etor, arg);
541
+ *
542
+ * JS_DHashTableEnumerate calls etor like so:
543
+ *
544
+ * op = etor(table, entry, number, arg);
545
+ *
546
+ * where number is a zero-based ordinal assigned to live entries according to
547
+ * their order in table->entryStore.
548
+ *
549
+ * The return value, op, is treated as a set of flags. If op is JS_DHASH_NEXT,
550
+ * then continue enumerating. If op contains JS_DHASH_REMOVE, then clear (via
551
+ * table->ops->clearEntry) and free entry. Then we check whether op contains
552
+ * JS_DHASH_STOP; if so, stop enumerating and return the number of live entries
553
+ * that were enumerated so far. Return the total number of live entries when
554
+ * enumeration completes normally.
555
+ *
556
+ * If etor calls JS_DHashTableOperate on table with op != JS_DHASH_LOOKUP, it
557
+ * must return JS_DHASH_STOP; otherwise undefined behavior results.
558
+ *
559
+ * If any enumerator returns JS_DHASH_REMOVE, table->entryStore may be shrunk
560
+ * or compressed after enumeration, but before JS_DHashTableEnumerate returns.
561
+ * Such an enumerator therefore can't safely set aside entry pointers, but an
562
+ * enumerator that never returns JS_DHASH_REMOVE can set pointers to entries
563
+ * aside, e.g., to avoid copying live entries into an array of the entry type.
564
+ * Copying entry pointers is cheaper, and safe so long as the caller of such a
565
+ * "stable" Enumerate doesn't use the set-aside pointers after any call either
566
+ * to PL_DHashTableOperate, or to an "unstable" form of Enumerate, which might
567
+ * grow or shrink entryStore.
568
+ *
569
+ * If your enumerator wants to remove certain entries, but set aside pointers
570
+ * to other entries that it retains, it can use JS_DHashTableRawRemove on the
571
+ * entries to be removed, returning JS_DHASH_NEXT to skip them. Likewise, if
572
+ * you want to remove entries, but for some reason you do not want entryStore
573
+ * to be shrunk or compressed, you can call JS_DHashTableRawRemove safely on
574
+ * the entry being enumerated, rather than returning JS_DHASH_REMOVE.
575
+ */
576
+ typedef JSDHashOperator
577
+ (* JS_DLL_CALLBACK JSDHashEnumerator)(JSDHashTable *table, JSDHashEntryHdr *hdr,
578
+ uint32 number, void *arg);
579
+
580
+ extern JS_PUBLIC_API(uint32)
581
+ JS_DHashTableEnumerate(JSDHashTable *table, JSDHashEnumerator etor, void *arg);
582
+
583
+ #ifdef JS_DHASHMETER
584
+ #include <stdio.h>
585
+
586
+ extern JS_PUBLIC_API(void)
587
+ JS_DHashTableDumpMeter(JSDHashTable *table, JSDHashEnumerator dump, FILE *fp);
588
+ #endif
589
+
590
+ JS_END_EXTERN_C
591
+
592
+ #endif /* jsdhash_h___ */