distil 0.7.0

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 (552) hide show
  1. data/Rakefile +28 -0
  2. data/VERSION +1 -0
  3. data/bin/distil +45 -0
  4. data/distil.gemspec +586 -0
  5. data/lib/bootstrap-template.js +56 -0
  6. data/lib/configurable.rb +125 -0
  7. data/lib/file-set.rb +42 -0
  8. data/lib/file-types/css-file.rb +75 -0
  9. data/lib/file-types/html-file.rb +11 -0
  10. data/lib/file-types/javascript-file.rb +98 -0
  11. data/lib/file-types/json-file.rb +14 -0
  12. data/lib/file-types/nib-file.rb +9 -0
  13. data/lib/jsdoc.conf +18 -0
  14. data/lib/jsl.conf +121 -0
  15. data/lib/project.rb +96 -0
  16. data/lib/source-file.rb +181 -0
  17. data/lib/target.rb +96 -0
  18. data/lib/task.rb +239 -0
  19. data/lib/tasks/copy-task.rb +21 -0
  20. data/lib/tasks/css-task.rb +18 -0
  21. data/lib/tasks/javascript-task.rb +125 -0
  22. data/lib/tasks/multiple-output-task.rb +134 -0
  23. data/lib/tasks/nib-task.rb +83 -0
  24. data/lib/tasks/output-task.rb +73 -0
  25. data/lib/tasks/single-output-task.rb +83 -0
  26. data/lib/tasks/test-task.rb +280 -0
  27. data/lib/test/HtmlTestReporter.js +127 -0
  28. data/lib/test/Test.js +248 -0
  29. data/lib/test/TestReporter.js +79 -0
  30. data/lib/test/TestRunner.js +132 -0
  31. data/lib/test/browser.rb +97 -0
  32. data/lib/test/scriptwrapper.html +10 -0
  33. data/lib/test/unittest.html +127 -0
  34. data/vendor/Makefile +35 -0
  35. data/vendor/extconf.rb +3 -0
  36. data/vendor/jsdoc-extras/plugins/distil-plugin.js +142 -0
  37. data/vendor/jsdoc-extras/plugins/interface-plugin.js +36 -0
  38. data/vendor/jsdoc-extras/templates/coherent/allclasses.tmpl +17 -0
  39. data/vendor/jsdoc-extras/templates/coherent/allfiles.tmpl +53 -0
  40. data/vendor/jsdoc-extras/templates/coherent/class.tmpl +803 -0
  41. data/vendor/jsdoc-extras/templates/coherent/index.tmpl +37 -0
  42. data/vendor/jsdoc-extras/templates/coherent/publish.js +242 -0
  43. data/vendor/jsdoc-extras/templates/coherent/showdown.js +421 -0
  44. data/vendor/jsdoc-extras/templates/coherent/static/code-footer.html +3 -0
  45. data/vendor/jsdoc-extras/templates/coherent/static/code-header.html +7 -0
  46. data/vendor/jsdoc-extras/templates/coherent/static/default.css +297 -0
  47. data/vendor/jsdoc-extras/templates/coherent/static/header.html +2 -0
  48. data/vendor/jsdoc-extras/templates/coherent/static/index.html +19 -0
  49. data/vendor/jsdoc-extras/templates/coherent/symbol.tmpl +35 -0
  50. data/vendor/jsdoc-toolkit/README.txt +183 -0
  51. data/vendor/jsdoc-toolkit/app/frame/Chain.js +102 -0
  52. data/vendor/jsdoc-toolkit/app/frame/Dumper.js +144 -0
  53. data/vendor/jsdoc-toolkit/app/frame/Hash.js +84 -0
  54. data/vendor/jsdoc-toolkit/app/frame/Link.js +171 -0
  55. data/vendor/jsdoc-toolkit/app/frame/Namespace.js +10 -0
  56. data/vendor/jsdoc-toolkit/app/frame/Opt.js +134 -0
  57. data/vendor/jsdoc-toolkit/app/frame/Reflection.js +26 -0
  58. data/vendor/jsdoc-toolkit/app/frame/String.js +93 -0
  59. data/vendor/jsdoc-toolkit/app/frame/Testrun.js +129 -0
  60. data/vendor/jsdoc-toolkit/app/frame.js +33 -0
  61. data/vendor/jsdoc-toolkit/app/handlers/FOODOC.js +26 -0
  62. data/vendor/jsdoc-toolkit/app/handlers/XMLDOC/DomReader.js +159 -0
  63. data/vendor/jsdoc-toolkit/app/handlers/XMLDOC/XMLDoc.js +16 -0
  64. data/vendor/jsdoc-toolkit/app/handlers/XMLDOC/XMLParse.js +292 -0
  65. data/vendor/jsdoc-toolkit/app/handlers/XMLDOC.js +26 -0
  66. data/vendor/jsdoc-toolkit/app/lib/JSDOC/DocComment.js +204 -0
  67. data/vendor/jsdoc-toolkit/app/lib/JSDOC/DocTag.js +300 -0
  68. data/vendor/jsdoc-toolkit/app/lib/JSDOC/JsDoc.js +126 -0
  69. data/vendor/jsdoc-toolkit/app/lib/JSDOC/JsPlate.js +109 -0
  70. data/vendor/jsdoc-toolkit/app/lib/JSDOC/Lang.js +144 -0
  71. data/vendor/jsdoc-toolkit/app/lib/JSDOC/Parser.js +144 -0
  72. data/vendor/jsdoc-toolkit/app/lib/JSDOC/PluginManager.js +33 -0
  73. data/vendor/jsdoc-toolkit/app/lib/JSDOC/Symbol.js +644 -0
  74. data/vendor/jsdoc-toolkit/app/lib/JSDOC/SymbolSet.js +241 -0
  75. data/vendor/jsdoc-toolkit/app/lib/JSDOC/TextStream.js +41 -0
  76. data/vendor/jsdoc-toolkit/app/lib/JSDOC/Token.js +18 -0
  77. data/vendor/jsdoc-toolkit/app/lib/JSDOC/TokenReader.js +332 -0
  78. data/vendor/jsdoc-toolkit/app/lib/JSDOC/TokenStream.js +133 -0
  79. data/vendor/jsdoc-toolkit/app/lib/JSDOC/Util.js +32 -0
  80. data/vendor/jsdoc-toolkit/app/lib/JSDOC/Walker.js +499 -0
  81. data/vendor/jsdoc-toolkit/app/lib/JSDOC.js +106 -0
  82. data/vendor/jsdoc-toolkit/app/main.js +129 -0
  83. data/vendor/jsdoc-toolkit/app/plugins/commentSrcJson.js +20 -0
  84. data/vendor/jsdoc-toolkit/app/plugins/frameworkPrototype.js +16 -0
  85. data/vendor/jsdoc-toolkit/app/plugins/functionCall.js +10 -0
  86. data/vendor/jsdoc-toolkit/app/plugins/publishSrcHilite.js +54 -0
  87. data/vendor/jsdoc-toolkit/app/plugins/symbolLink.js +10 -0
  88. data/vendor/jsdoc-toolkit/app/plugins/tagParamConfig.js +31 -0
  89. data/vendor/jsdoc-toolkit/app/plugins/tagSynonyms.js +43 -0
  90. data/vendor/jsdoc-toolkit/app/run.js +348 -0
  91. data/vendor/jsdoc-toolkit/app/t/TestDoc.js +144 -0
  92. data/vendor/jsdoc-toolkit/app/t/runner.js +13 -0
  93. data/vendor/jsdoc-toolkit/app/test/addon.js +24 -0
  94. data/vendor/jsdoc-toolkit/app/test/anon_inner.js +14 -0
  95. data/vendor/jsdoc-toolkit/app/test/augments.js +31 -0
  96. data/vendor/jsdoc-toolkit/app/test/augments2.js +26 -0
  97. data/vendor/jsdoc-toolkit/app/test/borrows.js +46 -0
  98. data/vendor/jsdoc-toolkit/app/test/borrows2.js +23 -0
  99. data/vendor/jsdoc-toolkit/app/test/config.js +22 -0
  100. data/vendor/jsdoc-toolkit/app/test/constructs.js +18 -0
  101. data/vendor/jsdoc-toolkit/app/test/encoding.js +10 -0
  102. data/vendor/jsdoc-toolkit/app/test/encoding_other.js +12 -0
  103. data/vendor/jsdoc-toolkit/app/test/event.js +54 -0
  104. data/vendor/jsdoc-toolkit/app/test/exports.js +14 -0
  105. data/vendor/jsdoc-toolkit/app/test/functions_anon.js +39 -0
  106. data/vendor/jsdoc-toolkit/app/test/functions_nested.js +33 -0
  107. data/vendor/jsdoc-toolkit/app/test/global.js +13 -0
  108. data/vendor/jsdoc-toolkit/app/test/globals.js +25 -0
  109. data/vendor/jsdoc-toolkit/app/test/ignore.js +10 -0
  110. data/vendor/jsdoc-toolkit/app/test/inner.js +16 -0
  111. data/vendor/jsdoc-toolkit/app/test/jsdoc_test.js +477 -0
  112. data/vendor/jsdoc-toolkit/app/test/lend.js +33 -0
  113. data/vendor/jsdoc-toolkit/app/test/memberof.js +19 -0
  114. data/vendor/jsdoc-toolkit/app/test/memberof2.js +38 -0
  115. data/vendor/jsdoc-toolkit/app/test/memberof3.js +33 -0
  116. data/vendor/jsdoc-toolkit/app/test/memberof_constructor.js +17 -0
  117. data/vendor/jsdoc-toolkit/app/test/module.js +17 -0
  118. data/vendor/jsdoc-toolkit/app/test/name.js +19 -0
  119. data/vendor/jsdoc-toolkit/app/test/namespace_nested.js +23 -0
  120. data/vendor/jsdoc-toolkit/app/test/nocode.js +13 -0
  121. data/vendor/jsdoc-toolkit/app/test/oblit_anon.js +20 -0
  122. data/vendor/jsdoc-toolkit/app/test/overview.js +20 -0
  123. data/vendor/jsdoc-toolkit/app/test/param_inline.js +37 -0
  124. data/vendor/jsdoc-toolkit/app/test/params_optional.js +8 -0
  125. data/vendor/jsdoc-toolkit/app/test/prototype.js +17 -0
  126. data/vendor/jsdoc-toolkit/app/test/prototype_nested.js +9 -0
  127. data/vendor/jsdoc-toolkit/app/test/prototype_oblit.js +13 -0
  128. data/vendor/jsdoc-toolkit/app/test/prototype_oblit_constructor.js +24 -0
  129. data/vendor/jsdoc-toolkit/app/test/public.js +10 -0
  130. data/vendor/jsdoc-toolkit/app/test/scripts/code.js +5 -0
  131. data/vendor/jsdoc-toolkit/app/test/scripts/notcode.txt +5 -0
  132. data/vendor/jsdoc-toolkit/app/test/shared.js +42 -0
  133. data/vendor/jsdoc-toolkit/app/test/shared2.js +2 -0
  134. data/vendor/jsdoc-toolkit/app/test/shortcuts.js +22 -0
  135. data/vendor/jsdoc-toolkit/app/test/static_this.js +13 -0
  136. data/vendor/jsdoc-toolkit/app/test/synonyms.js +31 -0
  137. data/vendor/jsdoc-toolkit/app/test/tosource.js +23 -0
  138. data/vendor/jsdoc-toolkit/app/test/variable_redefine.js +14 -0
  139. data/vendor/jsdoc-toolkit/app/test.js +342 -0
  140. data/vendor/jsdoc-toolkit/changes.txt +116 -0
  141. data/vendor/jsdoc-toolkit/conf/sample.conf +31 -0
  142. data/vendor/jsdoc-toolkit/java/build.xml +36 -0
  143. data/vendor/jsdoc-toolkit/java/build_1.4.xml +36 -0
  144. data/vendor/jsdoc-toolkit/java/classes/js.jar +0 -0
  145. data/vendor/jsdoc-toolkit/java/src/JsDebugRun.java +21 -0
  146. data/vendor/jsdoc-toolkit/java/src/JsRun.java +21 -0
  147. data/vendor/jsdoc-toolkit/jsdebug.jar +0 -0
  148. data/vendor/jsdoc-toolkit/jsrun.jar +0 -0
  149. data/vendor/jsdoc-toolkit/jsrun.sh +53 -0
  150. data/vendor/jsdoc-toolkit/templates/jsdoc/allclasses.tmpl +17 -0
  151. data/vendor/jsdoc-toolkit/templates/jsdoc/allfiles.tmpl +56 -0
  152. data/vendor/jsdoc-toolkit/templates/jsdoc/class.tmpl +649 -0
  153. data/vendor/jsdoc-toolkit/templates/jsdoc/index.tmpl +39 -0
  154. data/vendor/jsdoc-toolkit/templates/jsdoc/publish.js +201 -0
  155. data/vendor/jsdoc-toolkit/templates/jsdoc/static/code-footer.html +3 -0
  156. data/vendor/jsdoc-toolkit/templates/jsdoc/static/code-header.html +14 -0
  157. data/vendor/jsdoc-toolkit/templates/jsdoc/static/default.css +162 -0
  158. data/vendor/jsdoc-toolkit/templates/jsdoc/static/header.html +2 -0
  159. data/vendor/jsdoc-toolkit/templates/jsdoc/static/index.html +19 -0
  160. data/vendor/jsdoc-toolkit/templates/jsdoc/symbol.tmpl +35 -0
  161. data/vendor/jsl-0.3.0/src/JavaScriptLintAPI.cpp +333 -0
  162. data/vendor/jsl-0.3.0/src/JavaScriptLintAPI.h +86 -0
  163. data/vendor/jsl-0.3.0/src/Makefile.in +375 -0
  164. data/vendor/jsl-0.3.0/src/Makefile.ref +372 -0
  165. data/vendor/jsl-0.3.0/src/README.html +826 -0
  166. data/vendor/jsl-0.3.0/src/SpiderMonkey.rsp +12 -0
  167. data/vendor/jsl-0.3.0/src/_jsl_online.php +223 -0
  168. data/vendor/jsl-0.3.0/src/config/AIX4.1.mk +65 -0
  169. data/vendor/jsl-0.3.0/src/config/AIX4.2.mk +64 -0
  170. data/vendor/jsl-0.3.0/src/config/AIX4.3.mk +65 -0
  171. data/vendor/jsl-0.3.0/src/config/Darwin.mk +81 -0
  172. data/vendor/jsl-0.3.0/src/config/Darwin1.3.mk +81 -0
  173. data/vendor/jsl-0.3.0/src/config/Darwin1.4.mk +41 -0
  174. data/vendor/jsl-0.3.0/src/config/Darwin5.2.mk +81 -0
  175. data/vendor/jsl-0.3.0/src/config/Darwin5.3.mk +81 -0
  176. data/vendor/jsl-0.3.0/src/config/HP-UXB.10.10.mk +77 -0
  177. data/vendor/jsl-0.3.0/src/config/HP-UXB.10.20.mk +77 -0
  178. data/vendor/jsl-0.3.0/src/config/HP-UXB.11.00.mk +80 -0
  179. data/vendor/jsl-0.3.0/src/config/IRIX.mk +87 -0
  180. data/vendor/jsl-0.3.0/src/config/IRIX5.3.mk +44 -0
  181. data/vendor/jsl-0.3.0/src/config/IRIX6.1.mk +44 -0
  182. data/vendor/jsl-0.3.0/src/config/IRIX6.2.mk +44 -0
  183. data/vendor/jsl-0.3.0/src/config/IRIX6.3.mk +44 -0
  184. data/vendor/jsl-0.3.0/src/config/IRIX6.5.mk +44 -0
  185. data/vendor/jsl-0.3.0/src/config/Linux_All.mk +103 -0
  186. data/vendor/jsl-0.3.0/src/config/Mac_OS10.0.mk +82 -0
  187. data/vendor/jsl-0.3.0/src/config/OSF1V4.0.mk +72 -0
  188. data/vendor/jsl-0.3.0/src/config/OSF1V5.0.mk +69 -0
  189. data/vendor/jsl-0.3.0/src/config/SunOS4.1.4.mk +101 -0
  190. data/vendor/jsl-0.3.0/src/config/SunOS5.3.mk +91 -0
  191. data/vendor/jsl-0.3.0/src/config/SunOS5.4.mk +92 -0
  192. data/vendor/jsl-0.3.0/src/config/SunOS5.5.1.mk +44 -0
  193. data/vendor/jsl-0.3.0/src/config/SunOS5.5.mk +87 -0
  194. data/vendor/jsl-0.3.0/src/config/SunOS5.6.mk +89 -0
  195. data/vendor/jsl-0.3.0/src/config/SunOS5.7.mk +44 -0
  196. data/vendor/jsl-0.3.0/src/config/SunOS5.8.mk +44 -0
  197. data/vendor/jsl-0.3.0/src/config/SunOS5.9.mk +44 -0
  198. data/vendor/jsl-0.3.0/src/config/WINNT4.0.mk +112 -0
  199. data/vendor/jsl-0.3.0/src/config/WINNT5.0.mk +112 -0
  200. data/vendor/jsl-0.3.0/src/config/WINNT5.1.mk +112 -0
  201. data/vendor/jsl-0.3.0/src/config/WINNT5.2.mk +112 -0
  202. data/vendor/jsl-0.3.0/src/config/dgux.mk +64 -0
  203. data/vendor/jsl-0.3.0/src/config.mk +166 -0
  204. data/vendor/jsl-0.3.0/src/editline/Makefile.ref +144 -0
  205. data/vendor/jsl-0.3.0/src/editline/README +83 -0
  206. data/vendor/jsl-0.3.0/src/editline/editline.3 +175 -0
  207. data/vendor/jsl-0.3.0/src/editline/editline.c +1369 -0
  208. data/vendor/jsl-0.3.0/src/editline/editline.h +135 -0
  209. data/vendor/jsl-0.3.0/src/editline/sysunix.c +182 -0
  210. data/vendor/jsl-0.3.0/src/editline/unix.h +82 -0
  211. data/vendor/jsl-0.3.0/src/fdlibm/Makefile.in +127 -0
  212. data/vendor/jsl-0.3.0/src/fdlibm/Makefile.ref +192 -0
  213. data/vendor/jsl-0.3.0/src/fdlibm/e_acos.c +147 -0
  214. data/vendor/jsl-0.3.0/src/fdlibm/e_acosh.c +105 -0
  215. data/vendor/jsl-0.3.0/src/fdlibm/e_asin.c +156 -0
  216. data/vendor/jsl-0.3.0/src/fdlibm/e_atan2.c +165 -0
  217. data/vendor/jsl-0.3.0/src/fdlibm/e_atanh.c +110 -0
  218. data/vendor/jsl-0.3.0/src/fdlibm/e_cosh.c +133 -0
  219. data/vendor/jsl-0.3.0/src/fdlibm/e_exp.c +202 -0
  220. data/vendor/jsl-0.3.0/src/fdlibm/e_fmod.c +184 -0
  221. data/vendor/jsl-0.3.0/src/fdlibm/e_gamma.c +71 -0
  222. data/vendor/jsl-0.3.0/src/fdlibm/e_gamma_r.c +70 -0
  223. data/vendor/jsl-0.3.0/src/fdlibm/e_hypot.c +173 -0
  224. data/vendor/jsl-0.3.0/src/fdlibm/e_j0.c +524 -0
  225. data/vendor/jsl-0.3.0/src/fdlibm/e_j1.c +523 -0
  226. data/vendor/jsl-0.3.0/src/fdlibm/e_jn.c +315 -0
  227. data/vendor/jsl-0.3.0/src/fdlibm/e_lgamma.c +71 -0
  228. data/vendor/jsl-0.3.0/src/fdlibm/e_lgamma_r.c +347 -0
  229. data/vendor/jsl-0.3.0/src/fdlibm/e_log.c +184 -0
  230. data/vendor/jsl-0.3.0/src/fdlibm/e_log10.c +134 -0
  231. data/vendor/jsl-0.3.0/src/fdlibm/e_pow.c +386 -0
  232. data/vendor/jsl-0.3.0/src/fdlibm/e_rem_pio2.c +221 -0
  233. data/vendor/jsl-0.3.0/src/fdlibm/e_remainder.c +120 -0
  234. data/vendor/jsl-0.3.0/src/fdlibm/e_scalb.c +89 -0
  235. data/vendor/jsl-0.3.0/src/fdlibm/e_sinh.c +122 -0
  236. data/vendor/jsl-0.3.0/src/fdlibm/e_sqrt.c +497 -0
  237. data/vendor/jsl-0.3.0/src/fdlibm/fdlibm.dsp +160 -0
  238. data/vendor/jsl-0.3.0/src/fdlibm/fdlibm.h +273 -0
  239. data/vendor/jsl-0.3.0/src/fdlibm/fdlibm.mak +1453 -0
  240. data/vendor/jsl-0.3.0/src/fdlibm/fdlibm.mdp +0 -0
  241. data/vendor/jsl-0.3.0/src/fdlibm/k_cos.c +134 -0
  242. data/vendor/jsl-0.3.0/src/fdlibm/k_rem_pio2.c +354 -0
  243. data/vendor/jsl-0.3.0/src/fdlibm/k_sin.c +114 -0
  244. data/vendor/jsl-0.3.0/src/fdlibm/k_standard.c +785 -0
  245. data/vendor/jsl-0.3.0/src/fdlibm/k_tan.c +170 -0
  246. data/vendor/jsl-0.3.0/src/fdlibm/s_asinh.c +101 -0
  247. data/vendor/jsl-0.3.0/src/fdlibm/s_atan.c +175 -0
  248. data/vendor/jsl-0.3.0/src/fdlibm/s_cbrt.c +133 -0
  249. data/vendor/jsl-0.3.0/src/fdlibm/s_ceil.c +120 -0
  250. data/vendor/jsl-0.3.0/src/fdlibm/s_copysign.c +72 -0
  251. data/vendor/jsl-0.3.0/src/fdlibm/s_cos.c +118 -0
  252. data/vendor/jsl-0.3.0/src/fdlibm/s_erf.c +356 -0
  253. data/vendor/jsl-0.3.0/src/fdlibm/s_expm1.c +267 -0
  254. data/vendor/jsl-0.3.0/src/fdlibm/s_fabs.c +70 -0
  255. data/vendor/jsl-0.3.0/src/fdlibm/s_finite.c +71 -0
  256. data/vendor/jsl-0.3.0/src/fdlibm/s_floor.c +121 -0
  257. data/vendor/jsl-0.3.0/src/fdlibm/s_frexp.c +99 -0
  258. data/vendor/jsl-0.3.0/src/fdlibm/s_ilogb.c +85 -0
  259. data/vendor/jsl-0.3.0/src/fdlibm/s_isnan.c +74 -0
  260. data/vendor/jsl-0.3.0/src/fdlibm/s_ldexp.c +66 -0
  261. data/vendor/jsl-0.3.0/src/fdlibm/s_lib_version.c +73 -0
  262. data/vendor/jsl-0.3.0/src/fdlibm/s_log1p.c +211 -0
  263. data/vendor/jsl-0.3.0/src/fdlibm/s_logb.c +79 -0
  264. data/vendor/jsl-0.3.0/src/fdlibm/s_matherr.c +64 -0
  265. data/vendor/jsl-0.3.0/src/fdlibm/s_modf.c +132 -0
  266. data/vendor/jsl-0.3.0/src/fdlibm/s_nextafter.c +124 -0
  267. data/vendor/jsl-0.3.0/src/fdlibm/s_rint.c +131 -0
  268. data/vendor/jsl-0.3.0/src/fdlibm/s_scalbn.c +107 -0
  269. data/vendor/jsl-0.3.0/src/fdlibm/s_signgam.c +40 -0
  270. data/vendor/jsl-0.3.0/src/fdlibm/s_significand.c +68 -0
  271. data/vendor/jsl-0.3.0/src/fdlibm/s_sin.c +118 -0
  272. data/vendor/jsl-0.3.0/src/fdlibm/s_tan.c +112 -0
  273. data/vendor/jsl-0.3.0/src/fdlibm/s_tanh.c +122 -0
  274. data/vendor/jsl-0.3.0/src/fdlibm/w_acos.c +78 -0
  275. data/vendor/jsl-0.3.0/src/fdlibm/w_acosh.c +78 -0
  276. data/vendor/jsl-0.3.0/src/fdlibm/w_asin.c +80 -0
  277. data/vendor/jsl-0.3.0/src/fdlibm/w_atan2.c +79 -0
  278. data/vendor/jsl-0.3.0/src/fdlibm/w_atanh.c +81 -0
  279. data/vendor/jsl-0.3.0/src/fdlibm/w_cosh.c +77 -0
  280. data/vendor/jsl-0.3.0/src/fdlibm/w_exp.c +88 -0
  281. data/vendor/jsl-0.3.0/src/fdlibm/w_fmod.c +78 -0
  282. data/vendor/jsl-0.3.0/src/fdlibm/w_gamma.c +85 -0
  283. data/vendor/jsl-0.3.0/src/fdlibm/w_gamma_r.c +81 -0
  284. data/vendor/jsl-0.3.0/src/fdlibm/w_hypot.c +78 -0
  285. data/vendor/jsl-0.3.0/src/fdlibm/w_j0.c +105 -0
  286. data/vendor/jsl-0.3.0/src/fdlibm/w_j1.c +106 -0
  287. data/vendor/jsl-0.3.0/src/fdlibm/w_jn.c +128 -0
  288. data/vendor/jsl-0.3.0/src/fdlibm/w_lgamma.c +85 -0
  289. data/vendor/jsl-0.3.0/src/fdlibm/w_lgamma_r.c +81 -0
  290. data/vendor/jsl-0.3.0/src/fdlibm/w_log.c +78 -0
  291. data/vendor/jsl-0.3.0/src/fdlibm/w_log10.c +81 -0
  292. data/vendor/jsl-0.3.0/src/fdlibm/w_pow.c +99 -0
  293. data/vendor/jsl-0.3.0/src/fdlibm/w_remainder.c +77 -0
  294. data/vendor/jsl-0.3.0/src/fdlibm/w_scalb.c +95 -0
  295. data/vendor/jsl-0.3.0/src/fdlibm/w_sinh.c +77 -0
  296. data/vendor/jsl-0.3.0/src/fdlibm/w_sqrt.c +77 -0
  297. data/vendor/jsl-0.3.0/src/js.c +2447 -0
  298. data/vendor/jsl-0.3.0/src/js.dsp +420 -0
  299. data/vendor/jsl-0.3.0/src/js.mak +4025 -0
  300. data/vendor/jsl-0.3.0/src/js.mdp +0 -0
  301. data/vendor/jsl-0.3.0/src/js.msg +291 -0
  302. data/vendor/jsl-0.3.0/src/js.pkg +2 -0
  303. data/vendor/jsl-0.3.0/src/js3240.rc +79 -0
  304. data/vendor/jsl-0.3.0/src/jsOS240.def +654 -0
  305. data/vendor/jsl-0.3.0/src/jsapi.c +4405 -0
  306. data/vendor/jsl-0.3.0/src/jsapi.h +1856 -0
  307. data/vendor/jsl-0.3.0/src/jsarena.c +567 -0
  308. data/vendor/jsl-0.3.0/src/jsarena.h +302 -0
  309. data/vendor/jsl-0.3.0/src/jsarray.c +1428 -0
  310. data/vendor/jsl-0.3.0/src/jsarray.h +77 -0
  311. data/vendor/jsl-0.3.0/src/jsatom.c +927 -0
  312. data/vendor/jsl-0.3.0/src/jsatom.h +426 -0
  313. data/vendor/jsl-0.3.0/src/jsbit.h +113 -0
  314. data/vendor/jsl-0.3.0/src/jsbool.c +220 -0
  315. data/vendor/jsl-0.3.0/src/jsbool.h +62 -0
  316. data/vendor/jsl-0.3.0/src/jsclist.h +139 -0
  317. data/vendor/jsl-0.3.0/src/jscntxt.c +1036 -0
  318. data/vendor/jsl-0.3.0/src/jscntxt.h +608 -0
  319. data/vendor/jsl-0.3.0/src/jscompat.h +57 -0
  320. data/vendor/jsl-0.3.0/src/jsconfig.h +489 -0
  321. data/vendor/jsl-0.3.0/src/jsconfig.mk +181 -0
  322. data/vendor/jsl-0.3.0/src/jscpucfg.c +377 -0
  323. data/vendor/jsl-0.3.0/src/jscpucfg.h +204 -0
  324. data/vendor/jsl-0.3.0/src/jsdate.c +2238 -0
  325. data/vendor/jsl-0.3.0/src/jsdate.h +118 -0
  326. data/vendor/jsl-0.3.0/src/jsdbgapi.c +1260 -0
  327. data/vendor/jsl-0.3.0/src/jsdbgapi.h +345 -0
  328. data/vendor/jsl-0.3.0/src/jsdhash.c +763 -0
  329. data/vendor/jsl-0.3.0/src/jsdhash.h +579 -0
  330. data/vendor/jsl-0.3.0/src/jsdtoa.c +3135 -0
  331. data/vendor/jsl-0.3.0/src/jsdtoa.h +130 -0
  332. data/vendor/jsl-0.3.0/src/jsemit.c +4851 -0
  333. data/vendor/jsl-0.3.0/src/jsemit.h +576 -0
  334. data/vendor/jsl-0.3.0/src/jsexn.c +1084 -0
  335. data/vendor/jsl-0.3.0/src/jsexn.h +102 -0
  336. data/vendor/jsl-0.3.0/src/jsfile.c +2610 -0
  337. data/vendor/jsl-0.3.0/src/jsfile.h +50 -0
  338. data/vendor/jsl-0.3.0/src/jsfile.msg +89 -0
  339. data/vendor/jsl-0.3.0/src/jsfun.c +2015 -0
  340. data/vendor/jsl-0.3.0/src/jsfun.h +158 -0
  341. data/vendor/jsl-0.3.0/src/jsgc.c +1441 -0
  342. data/vendor/jsl-0.3.0/src/jsgc.h +230 -0
  343. data/vendor/jsl-0.3.0/src/jshash.c +471 -0
  344. data/vendor/jsl-0.3.0/src/jshash.h +152 -0
  345. data/vendor/jsl-0.3.0/src/jsify.pl +485 -0
  346. data/vendor/jsl-0.3.0/src/jsinterp.c +4797 -0
  347. data/vendor/jsl-0.3.0/src/jsinterp.h +302 -0
  348. data/vendor/jsl-0.3.0/src/jsl-test.js +28 -0
  349. data/vendor/jsl-0.3.0/src/jsl.c +2371 -0
  350. data/vendor/jsl-0.3.0/src/jsl.conf +127 -0
  351. data/vendor/jsl-0.3.0/src/jsl.conf.old +124 -0
  352. data/vendor/jsl-0.3.0/src/jsl.dsp +242 -0
  353. data/vendor/jsl-0.3.0/src/jsl.dsw +59 -0
  354. data/vendor/jsl-0.3.0/src/jslibmath.h +290 -0
  355. data/vendor/jsl-0.3.0/src/jslock.c +1261 -0
  356. data/vendor/jsl-0.3.0/src/jslock.h +289 -0
  357. data/vendor/jsl-0.3.0/src/jslocko.asm +59 -0
  358. data/vendor/jsl-0.3.0/src/jslog2.c +83 -0
  359. data/vendor/jsl-0.3.0/src/jslong.c +281 -0
  360. data/vendor/jsl-0.3.0/src/jslong.h +437 -0
  361. data/vendor/jsl-0.3.0/src/jsmath.c +477 -0
  362. data/vendor/jsl-0.3.0/src/jsmath.h +55 -0
  363. data/vendor/jsl-0.3.0/src/jsnum.c +1148 -0
  364. data/vendor/jsl-0.3.0/src/jsnum.h +257 -0
  365. data/vendor/jsl-0.3.0/src/jsobj.c +4066 -0
  366. data/vendor/jsl-0.3.0/src/jsobj.h +475 -0
  367. data/vendor/jsl-0.3.0/src/jsopcode.c +2730 -0
  368. data/vendor/jsl-0.3.0/src/jsopcode.h +275 -0
  369. data/vendor/jsl-0.3.0/src/jsopcode.tbl +344 -0
  370. data/vendor/jsl-0.3.0/src/jsosdep.h +127 -0
  371. data/vendor/jsl-0.3.0/src/jsotypes.h +211 -0
  372. data/vendor/jsl-0.3.0/src/jsparse.c +4438 -0
  373. data/vendor/jsl-0.3.0/src/jsparse.h +345 -0
  374. data/vendor/jsl-0.3.0/src/jsprf.c +1212 -0
  375. data/vendor/jsl-0.3.0/src/jsprf.h +148 -0
  376. data/vendor/jsl-0.3.0/src/jsprvtd.h +174 -0
  377. data/vendor/jsl-0.3.0/src/jspubtd.h +586 -0
  378. data/vendor/jsl-0.3.0/src/jsregexp.c +3831 -0
  379. data/vendor/jsl-0.3.0/src/jsregexp.h +180 -0
  380. data/vendor/jsl-0.3.0/src/jsscan.c +1814 -0
  381. data/vendor/jsl-0.3.0/src/jsscan.h +267 -0
  382. data/vendor/jsl-0.3.0/src/jsscope.c +1639 -0
  383. data/vendor/jsl-0.3.0/src/jsscope.h +389 -0
  384. data/vendor/jsl-0.3.0/src/jsscript.c +1284 -0
  385. data/vendor/jsl-0.3.0/src/jsscript.h +179 -0
  386. data/vendor/jsl-0.3.0/src/jsshell.msg +50 -0
  387. data/vendor/jsl-0.3.0/src/jsstddef.h +83 -0
  388. data/vendor/jsl-0.3.0/src/jsstr.c +4502 -0
  389. data/vendor/jsl-0.3.0/src/jsstr.h +448 -0
  390. data/vendor/jsl-0.3.0/src/jstypes.h +391 -0
  391. data/vendor/jsl-0.3.0/src/jsutil.c +157 -0
  392. data/vendor/jsl-0.3.0/src/jsutil.h +75 -0
  393. data/vendor/jsl-0.3.0/src/jsxdrapi.c +686 -0
  394. data/vendor/jsl-0.3.0/src/jsxdrapi.h +193 -0
  395. data/vendor/jsl-0.3.0/src/liveconnect/LiveConnect.dsp +157 -0
  396. data/vendor/jsl-0.3.0/src/liveconnect/LiveConnectShell.dsp +120 -0
  397. data/vendor/jsl-0.3.0/src/liveconnect/LiveConnectShell.dsw +44 -0
  398. data/vendor/jsl-0.3.0/src/liveconnect/Makefile.in +106 -0
  399. data/vendor/jsl-0.3.0/src/liveconnect/Makefile.ref +169 -0
  400. data/vendor/jsl-0.3.0/src/liveconnect/README.html +719 -0
  401. data/vendor/jsl-0.3.0/src/liveconnect/_jni/netscape_javascript_JSException.h +14 -0
  402. data/vendor/jsl-0.3.0/src/liveconnect/_jni/netscape_javascript_JSObject.h +155 -0
  403. data/vendor/jsl-0.3.0/src/liveconnect/classes/Makefile.in +89 -0
  404. data/vendor/jsl-0.3.0/src/liveconnect/classes/Makefile.ref +57 -0
  405. data/vendor/jsl-0.3.0/src/liveconnect/classes/netscape/Makefile.ref +47 -0
  406. data/vendor/jsl-0.3.0/src/liveconnect/classes/netscape/javascript/JSException.java +140 -0
  407. data/vendor/jsl-0.3.0/src/liveconnect/classes/netscape/javascript/JSObject.java +183 -0
  408. data/vendor/jsl-0.3.0/src/liveconnect/classes/netscape/javascript/JSProxy.java +58 -0
  409. data/vendor/jsl-0.3.0/src/liveconnect/classes/netscape/javascript/JSRunnable.java +70 -0
  410. data/vendor/jsl-0.3.0/src/liveconnect/classes/netscape/javascript/JSUtil.java +59 -0
  411. data/vendor/jsl-0.3.0/src/liveconnect/classes/netscape/javascript/Makefile.ref +53 -0
  412. data/vendor/jsl-0.3.0/src/liveconnect/config/AIX4.1.mk +45 -0
  413. data/vendor/jsl-0.3.0/src/liveconnect/config/AIX4.2.mk +45 -0
  414. data/vendor/jsl-0.3.0/src/liveconnect/config/AIX4.3.mk +50 -0
  415. data/vendor/jsl-0.3.0/src/liveconnect/config/HP-UXB.10.10.mk +43 -0
  416. data/vendor/jsl-0.3.0/src/liveconnect/config/HP-UXB.10.20.mk +43 -0
  417. data/vendor/jsl-0.3.0/src/liveconnect/config/HP-UXB.11.00.mk +43 -0
  418. data/vendor/jsl-0.3.0/src/liveconnect/config/IRIX6.2.mk +43 -0
  419. data/vendor/jsl-0.3.0/src/liveconnect/config/IRIX6.3.mk +43 -0
  420. data/vendor/jsl-0.3.0/src/liveconnect/config/IRIX6.5.mk +43 -0
  421. data/vendor/jsl-0.3.0/src/liveconnect/config/Linux_All.mk +73 -0
  422. data/vendor/jsl-0.3.0/src/liveconnect/config/OSF1V4.0.mk +65 -0
  423. data/vendor/jsl-0.3.0/src/liveconnect/config/OSF1V5.0.mk +62 -0
  424. data/vendor/jsl-0.3.0/src/liveconnect/config/SunOS5.5.1.mk +55 -0
  425. data/vendor/jsl-0.3.0/src/liveconnect/config/SunOS5.6.mk +39 -0
  426. data/vendor/jsl-0.3.0/src/liveconnect/config/SunOS5.7.mk +39 -0
  427. data/vendor/jsl-0.3.0/src/liveconnect/config/SunOS5.8.mk +39 -0
  428. data/vendor/jsl-0.3.0/src/liveconnect/config/WINNT4.0.mk +53 -0
  429. data/vendor/jsl-0.3.0/src/liveconnect/jsj.c +884 -0
  430. data/vendor/jsl-0.3.0/src/liveconnect/jsj.msg +98 -0
  431. data/vendor/jsl-0.3.0/src/liveconnect/jsj_JSObject.c +1379 -0
  432. data/vendor/jsl-0.3.0/src/liveconnect/jsj_JavaArray.c +481 -0
  433. data/vendor/jsl-0.3.0/src/liveconnect/jsj_JavaClass.c +749 -0
  434. data/vendor/jsl-0.3.0/src/liveconnect/jsj_JavaMember.c +186 -0
  435. data/vendor/jsl-0.3.0/src/liveconnect/jsj_JavaObject.c +1099 -0
  436. data/vendor/jsl-0.3.0/src/liveconnect/jsj_JavaPackage.c +548 -0
  437. data/vendor/jsl-0.3.0/src/liveconnect/jsj_array.c +207 -0
  438. data/vendor/jsl-0.3.0/src/liveconnect/jsj_class.c +765 -0
  439. data/vendor/jsl-0.3.0/src/liveconnect/jsj_convert.c +954 -0
  440. data/vendor/jsl-0.3.0/src/liveconnect/jsj_field.c +421 -0
  441. data/vendor/jsl-0.3.0/src/liveconnect/jsj_hash.c +504 -0
  442. data/vendor/jsl-0.3.0/src/liveconnect/jsj_hash.h +161 -0
  443. data/vendor/jsl-0.3.0/src/liveconnect/jsj_method.c +1823 -0
  444. data/vendor/jsl-0.3.0/src/liveconnect/jsj_nodl.c +1 -0
  445. data/vendor/jsl-0.3.0/src/liveconnect/jsj_private.h +689 -0
  446. data/vendor/jsl-0.3.0/src/liveconnect/jsj_simpleapi.c +219 -0
  447. data/vendor/jsl-0.3.0/src/liveconnect/jsj_utils.c +513 -0
  448. data/vendor/jsl-0.3.0/src/liveconnect/jsjava.h +313 -0
  449. data/vendor/jsl-0.3.0/src/liveconnect/liveconnect.pkg +3 -0
  450. data/vendor/jsl-0.3.0/src/liveconnect/netscape_javascript_JSObject.h +155 -0
  451. data/vendor/jsl-0.3.0/src/liveconnect/nsCLiveconnect.cpp +785 -0
  452. data/vendor/jsl-0.3.0/src/liveconnect/nsCLiveconnect.h +197 -0
  453. data/vendor/jsl-0.3.0/src/liveconnect/nsCLiveconnectFactory.cpp +163 -0
  454. data/vendor/jsl-0.3.0/src/liveconnect/nsCLiveconnectFactory.h +76 -0
  455. data/vendor/jsl-0.3.0/src/liveconnect/nsILiveconnect.h +195 -0
  456. data/vendor/jsl-0.3.0/src/liveconnect/nsISecureLiveconnect.h +84 -0
  457. data/vendor/jsl-0.3.0/src/liveconnect/nsISecurityContext.h +135 -0
  458. data/vendor/jsl-0.3.0/src/liveconnect/win32.order +6 -0
  459. data/vendor/jsl-0.3.0/src/lock_SunOS.s +114 -0
  460. data/vendor/jsl-0.3.0/src/perfect.js +39 -0
  461. data/vendor/jsl-0.3.0/src/perlconnect/JS.def +6 -0
  462. data/vendor/jsl-0.3.0/src/perlconnect/JS.dsp +107 -0
  463. data/vendor/jsl-0.3.0/src/perlconnect/JS.pm +318 -0
  464. data/vendor/jsl-0.3.0/src/perlconnect/JS.xs +1050 -0
  465. data/vendor/jsl-0.3.0/src/perlconnect/Makefile.PL +67 -0
  466. data/vendor/jsl-0.3.0/src/perlconnect/Makefile.ref +152 -0
  467. data/vendor/jsl-0.3.0/src/perlconnect/PerlConnect.dsp +103 -0
  468. data/vendor/jsl-0.3.0/src/perlconnect/PerlConnect.dsw +59 -0
  469. data/vendor/jsl-0.3.0/src/perlconnect/PerlConnect.pm +126 -0
  470. data/vendor/jsl-0.3.0/src/perlconnect/PerlConnectShell.dsp +89 -0
  471. data/vendor/jsl-0.3.0/src/perlconnect/README.html +345 -0
  472. data/vendor/jsl-0.3.0/src/perlconnect/bg.jpg +0 -0
  473. data/vendor/jsl-0.3.0/src/perlconnect/jsperl.c +1100 -0
  474. data/vendor/jsl-0.3.0/src/perlconnect/jsperl.h +52 -0
  475. data/vendor/jsl-0.3.0/src/perlconnect/jsperlbuild.pl +81 -0
  476. data/vendor/jsl-0.3.0/src/perlconnect/jsperlpvt.h +57 -0
  477. data/vendor/jsl-0.3.0/src/perlconnect/test.js +73 -0
  478. data/vendor/jsl-0.3.0/src/perlconnect/test.pl +244 -0
  479. data/vendor/jsl-0.3.0/src/perlconnect/typemap +121 -0
  480. data/vendor/jsl-0.3.0/src/plify_jsdhash.sed +31 -0
  481. data/vendor/jsl-0.3.0/src/prmjtime.c +646 -0
  482. data/vendor/jsl-0.3.0/src/prmjtime.h +95 -0
  483. data/vendor/jsl-0.3.0/src/resource.h +15 -0
  484. data/vendor/jsl-0.3.0/src/rules.mk +193 -0
  485. data/vendor/jsl-0.3.0/src/win32.order +391 -0
  486. data/vendor/jsl-0.3.0/tests/conf/always_use_option_explicit.js +4 -0
  487. data/vendor/jsl-0.3.0/tests/conf/define.js +8 -0
  488. data/vendor/jsl-0.3.0/tests/conf/jscript_function_extensions-1.js +7 -0
  489. data/vendor/jsl-0.3.0/tests/conf/jscript_function_extensions-2.js +8 -0
  490. data/vendor/jsl-0.3.0/tests/conf/jscript_function_extensions-3.js +27 -0
  491. data/vendor/jsl-0.3.0/tests/conf/jscript_function_extensions-4.js +4 -0
  492. data/vendor/jsl-0.3.0/tests/conf/lambda_assign_requires_semicolon.js +24 -0
  493. data/vendor/jsl-0.3.0/tests/conf/legacy_control_comments.js +8 -0
  494. data/vendor/jsl-0.3.0/tests/control_comments/control_comments.js +33 -0
  495. data/vendor/jsl-0.3.0/tests/control_comments/declare.js +26 -0
  496. data/vendor/jsl-0.3.0/tests/control_comments/import-overflow.js +9 -0
  497. data/vendor/jsl-0.3.0/tests/control_comments/import.js +5 -0
  498. data/vendor/jsl-0.3.0/tests/control_comments/import2.js +2 -0
  499. data/vendor/jsl-0.3.0/tests/control_comments/invalid_fallthru.js +13 -0
  500. data/vendor/jsl-0.3.0/tests/control_comments/option_explicit-with.js +12 -0
  501. data/vendor/jsl-0.3.0/tests/control_comments/option_explicit.js +64 -0
  502. data/vendor/jsl-0.3.0/tests/errors/unterminated_comment.js +8 -0
  503. data/vendor/jsl-0.3.0/tests/html/script_tag_in_js_literal.html +14 -0
  504. data/vendor/jsl-0.3.0/tests/run_tests.pl +71 -0
  505. data/vendor/jsl-0.3.0/tests/warnings/ambiguous_else_stmt.js +21 -0
  506. data/vendor/jsl-0.3.0/tests/warnings/ambiguous_nested_stmt.js +66 -0
  507. data/vendor/jsl-0.3.0/tests/warnings/ambiguous_newline.js +261 -0
  508. data/vendor/jsl-0.3.0/tests/warnings/anon_no_return_value.js +26 -0
  509. data/vendor/jsl-0.3.0/tests/warnings/assign_to_function_call.js +16 -0
  510. data/vendor/jsl-0.3.0/tests/warnings/block_without_braces.js +13 -0
  511. data/vendor/jsl-0.3.0/tests/warnings/comma_separated_stmts.js +17 -0
  512. data/vendor/jsl-0.3.0/tests/warnings/comparison_type_conv.js +44 -0
  513. data/vendor/jsl-0.3.0/tests/warnings/default_not_at_end.js +15 -0
  514. data/vendor/jsl-0.3.0/tests/warnings/dup_option_explicit.js +5 -0
  515. data/vendor/jsl-0.3.0/tests/warnings/duplicate_case_in_switch.js +62 -0
  516. data/vendor/jsl-0.3.0/tests/warnings/duplicate_formal.js +5 -0
  517. data/vendor/jsl-0.3.0/tests/warnings/empty_statement.js +29 -0
  518. data/vendor/jsl-0.3.0/tests/warnings/equal_as_assign.js +7 -0
  519. data/vendor/jsl-0.3.0/tests/warnings/inc_dec_within_stmt-ignore.js +21 -0
  520. data/vendor/jsl-0.3.0/tests/warnings/inc_dec_within_stmt.js +63 -0
  521. data/vendor/jsl-0.3.0/tests/warnings/jsl_cc_not_understood.js +5 -0
  522. data/vendor/jsl-0.3.0/tests/warnings/leading_decimal_point.js +7 -0
  523. data/vendor/jsl-0.3.0/tests/warnings/legacy_cc_not_understood.js +9 -0
  524. data/vendor/jsl-0.3.0/tests/warnings/meaningless_block.js +12 -0
  525. data/vendor/jsl-0.3.0/tests/warnings/misplaced_regex.js +20 -0
  526. data/vendor/jsl-0.3.0/tests/warnings/missing_break.js +87 -0
  527. data/vendor/jsl-0.3.0/tests/warnings/missing_break_for_last_case.js +19 -0
  528. data/vendor/jsl-0.3.0/tests/warnings/missing_default_case.js +51 -0
  529. data/vendor/jsl-0.3.0/tests/warnings/missing_option_explicit.js +5 -0
  530. data/vendor/jsl-0.3.0/tests/warnings/missing_semicolon.js +19 -0
  531. data/vendor/jsl-0.3.0/tests/warnings/multiple_plus_minus.js +10 -0
  532. data/vendor/jsl-0.3.0/tests/warnings/nested_comment.js +6 -0
  533. data/vendor/jsl-0.3.0/tests/warnings/no_return_value.js +25 -0
  534. data/vendor/jsl-0.3.0/tests/warnings/octal_number.js +5 -0
  535. data/vendor/jsl-0.3.0/tests/warnings/parseint_missing_radix.js +15 -0
  536. data/vendor/jsl-0.3.0/tests/warnings/partial_option_explicit.js +5 -0
  537. data/vendor/jsl-0.3.0/tests/warnings/redeclared_var.js +10 -0
  538. data/vendor/jsl-0.3.0/tests/warnings/spidermonkey/bad_backref.js +5 -0
  539. data/vendor/jsl-0.3.0/tests/warnings/spidermonkey/deprecated_usage.js +11 -0
  540. data/vendor/jsl-0.3.0/tests/warnings/spidermonkey/invalid_backref.js +5 -0
  541. data/vendor/jsl-0.3.0/tests/warnings/spidermonkey/trailing_comma.js +5 -0
  542. data/vendor/jsl-0.3.0/tests/warnings/trailing_comma_in_array.js +8 -0
  543. data/vendor/jsl-0.3.0/tests/warnings/trailing_decimal_point.js +7 -0
  544. data/vendor/jsl-0.3.0/tests/warnings/unreachable_code.js +29 -0
  545. data/vendor/jsl-0.3.0/tests/warnings/use_of_label.js +19 -0
  546. data/vendor/jsl-0.3.0/tests/warnings/useless_assign.js +20 -0
  547. data/vendor/jsl-0.3.0/tests/warnings/useless_comparison.js +55 -0
  548. data/vendor/jsl-0.3.0/tests/warnings/useless_void.js +6 -0
  549. data/vendor/jsl-0.3.0/tests/warnings/var_hides_arg.js +4 -0
  550. data/vendor/jsl-0.3.0/tests/warnings/with_statement.js +7 -0
  551. data/vendor/yuicompressor-2.4.2.jar +0 -0
  552. metadata +605 -0
@@ -0,0 +1,1261 @@
1
+ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2
+ *
3
+ * ***** BEGIN LICENSE BLOCK *****
4
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5
+ *
6
+ * The contents of this file are subject to the Mozilla Public License Version
7
+ * 1.1 (the "License"); you may not use this file except in compliance with
8
+ * the License. You may obtain a copy of the License at
9
+ * http://www.mozilla.org/MPL/
10
+ *
11
+ * Software distributed under the License is distributed on an "AS IS" basis,
12
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13
+ * for the specific language governing rights and limitations under the
14
+ * License.
15
+ *
16
+ * The Original Code is Mozilla Communicator client code, released
17
+ * March 31, 1998.
18
+ *
19
+ * The Initial Developer of the Original Code is
20
+ * Netscape Communications Corporation.
21
+ * Portions created by the Initial Developer are Copyright (C) 1998
22
+ * the Initial Developer. All Rights Reserved.
23
+ *
24
+ * Contributor(s):
25
+ *
26
+ * Alternatively, the contents of this file may be used under the terms of
27
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
28
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29
+ * in which case the provisions of the GPL or the LGPL are applicable instead
30
+ * of those above. If you wish to allow use of your version of this file only
31
+ * under the terms of either the GPL or the LGPL, and not to allow others to
32
+ * use your version of this file under the terms of the MPL, indicate your
33
+ * decision by deleting the provisions above and replace them with the notice
34
+ * and other provisions required by the GPL or the LGPL. If you do not delete
35
+ * the provisions above, a recipient may use your version of this file under
36
+ * the terms of any one of the MPL, the GPL or the LGPL.
37
+ *
38
+ * ***** END LICENSE BLOCK ***** */
39
+
40
+ #ifdef JS_THREADSAFE
41
+
42
+ /*
43
+ * JS locking stubs.
44
+ */
45
+ #include "jsstddef.h"
46
+ #include <stdlib.h>
47
+ #include "jspubtd.h"
48
+ #include "prthread.h"
49
+ #include "jsutil.h" /* Added by JSIFY */
50
+ #include "jstypes.h"
51
+ #include "jsbit.h"
52
+ #include "jscntxt.h"
53
+ #include "jsdtoa.h"
54
+ #include "jsgc.h"
55
+ #include "jslock.h"
56
+ #include "jsscope.h"
57
+ #include "jsstr.h"
58
+
59
+ #define ReadWord(W) (W)
60
+
61
+ #ifndef NSPR_LOCK
62
+
63
+ #include <memory.h>
64
+
65
+ static PRLock **global_locks;
66
+ static uint32 global_lock_count = 1;
67
+ static uint32 global_locks_log2 = 0;
68
+ static uint32 global_locks_mask = 0;
69
+
70
+ #define GLOBAL_LOCK_INDEX(id) (((uint32)(id) >> 2) & global_locks_mask)
71
+
72
+ static void
73
+ js_LockGlobal(void *id)
74
+ {
75
+ uint32 i = GLOBAL_LOCK_INDEX(id);
76
+ PR_Lock(global_locks[i]);
77
+ }
78
+
79
+ static void
80
+ js_UnlockGlobal(void *id)
81
+ {
82
+ uint32 i = GLOBAL_LOCK_INDEX(id);
83
+ PR_Unlock(global_locks[i]);
84
+ }
85
+
86
+ /* Exclude Alpha NT. */
87
+ #if defined(_WIN32) && defined(_M_IX86)
88
+ #pragma warning( disable : 4035 )
89
+
90
+ static JS_INLINE int
91
+ js_CompareAndSwap(jsword *w, jsword ov, jsword nv)
92
+ {
93
+ __asm {
94
+ mov eax, ov
95
+ mov ecx, nv
96
+ mov ebx, w
97
+ lock cmpxchg [ebx], ecx
98
+ sete al
99
+ and eax, 1h
100
+ }
101
+ }
102
+
103
+ #elif defined(__GNUC__) && defined(__i386__)
104
+
105
+ /* Note: This fails on 386 cpus, cmpxchgl is a >= 486 instruction */
106
+ static JS_INLINE int
107
+ js_CompareAndSwap(jsword *w, jsword ov, jsword nv)
108
+ {
109
+ unsigned int res;
110
+
111
+ __asm__ __volatile__ (
112
+ "lock\n"
113
+ "cmpxchgl %2, (%1)\n"
114
+ "sete %%al\n"
115
+ "andl $1, %%eax\n"
116
+ : "=a" (res)
117
+ : "r" (w), "r" (nv), "a" (ov)
118
+ : "cc", "memory");
119
+ return (int)res;
120
+ }
121
+
122
+ #elif defined(SOLARIS) && defined(sparc) && defined(ULTRA_SPARC)
123
+
124
+ static JS_INLINE int
125
+ js_CompareAndSwap(jsword *w, jsword ov, jsword nv)
126
+ {
127
+ #if defined(__GNUC__)
128
+ unsigned int res;
129
+ JS_ASSERT(ov != nv);
130
+ asm volatile ("\
131
+ stbar\n\
132
+ cas [%1],%2,%3\n\
133
+ cmp %2,%3\n\
134
+ be,a 1f\n\
135
+ mov 1,%0\n\
136
+ mov 0,%0\n\
137
+ 1:"
138
+ : "=r" (res)
139
+ : "r" (w), "r" (ov), "r" (nv));
140
+ return (int)res;
141
+ #else /* !__GNUC__ */
142
+ extern int compare_and_swap(jsword*, jsword, jsword);
143
+ JS_ASSERT(ov != nv);
144
+ return compare_and_swap(w, ov, nv);
145
+ #endif
146
+ }
147
+
148
+ #elif defined(AIX)
149
+
150
+ #include <sys/atomic_op.h>
151
+
152
+ static JS_INLINE int
153
+ js_CompareAndSwap(jsword *w, jsword ov, jsword nv)
154
+ {
155
+ return !_check_lock((atomic_p)w, ov, nv);
156
+ }
157
+
158
+ #else
159
+
160
+ #error "Define NSPR_LOCK if your platform lacks a compare-and-swap instruction."
161
+
162
+ #endif /* arch-tests */
163
+
164
+ #endif /* !NSPR_LOCK */
165
+
166
+ jsword
167
+ js_CurrentThreadId()
168
+ {
169
+ return CurrentThreadId();
170
+ }
171
+
172
+ void
173
+ js_InitLock(JSThinLock *tl)
174
+ {
175
+ #ifdef NSPR_LOCK
176
+ tl->owner = 0;
177
+ tl->fat = (JSFatLock*)JS_NEW_LOCK();
178
+ #else
179
+ memset(tl, 0, sizeof(JSThinLock));
180
+ #endif
181
+ }
182
+
183
+ void
184
+ js_FinishLock(JSThinLock *tl)
185
+ {
186
+ #ifdef NSPR_LOCK
187
+ tl->owner = 0xdeadbeef;
188
+ if (tl->fat)
189
+ JS_DESTROY_LOCK(((JSLock*)tl->fat));
190
+ #else
191
+ JS_ASSERT(tl->owner == 0);
192
+ JS_ASSERT(tl->fat == NULL);
193
+ #endif
194
+ }
195
+
196
+ static void js_Dequeue(JSThinLock *);
197
+
198
+ #ifdef DEBUG_SCOPE_COUNT
199
+
200
+ #include <stdio.h>
201
+ #include "jsdhash.h"
202
+
203
+ static FILE *logfp;
204
+ static JSDHashTable logtbl;
205
+
206
+ typedef struct logentry {
207
+ JSDHashEntryStub stub;
208
+ char op;
209
+ const char *file;
210
+ int line;
211
+ } logentry;
212
+
213
+ static void
214
+ logit(JSScope *scope, char op, const char *file, int line)
215
+ {
216
+ logentry *entry;
217
+
218
+ if (!logfp) {
219
+ logfp = fopen("/tmp/scope.log", "w");
220
+ if (!logfp)
221
+ return;
222
+ setvbuf(logfp, NULL, _IONBF, 0);
223
+ }
224
+ fprintf(logfp, "%p %c %s %d\n", scope, op, file, line);
225
+
226
+ if (!logtbl.entryStore &&
227
+ !JS_DHashTableInit(&logtbl, JS_DHashGetStubOps(), NULL,
228
+ sizeof(logentry), 100)) {
229
+ return;
230
+ }
231
+ entry = (logentry *) JS_DHashTableOperate(&logtbl, scope, JS_DHASH_ADD);
232
+ if (!entry)
233
+ return;
234
+ entry->stub.key = scope;
235
+ entry->op = op;
236
+ entry->file = file;
237
+ entry->line = line;
238
+ }
239
+
240
+ void
241
+ js_unlog_scope(JSScope *scope)
242
+ {
243
+ if (!logtbl.entryStore)
244
+ return;
245
+ (void) JS_DHashTableOperate(&logtbl, scope, JS_DHASH_REMOVE);
246
+ }
247
+
248
+ # define LOGIT(scope,op) logit(scope, op, __FILE__, __LINE__)
249
+
250
+ #else
251
+
252
+ # define LOGIT(scope,op) /* nothing */
253
+
254
+ #endif /* DEBUG_SCOPE_COUNT */
255
+
256
+ /*
257
+ * Return true if scope's ownercx, or the ownercx of a single-threaded scope
258
+ * for which ownercx is waiting to become multi-threaded and shared, is cx.
259
+ * That condition implies deadlock in ClaimScope if cx's thread were to wait
260
+ * to share scope.
261
+ *
262
+ * (i) rt->gcLock held
263
+ */
264
+ static JSBool
265
+ WillDeadlock(JSScope *scope, JSContext *cx)
266
+ {
267
+ JSContext *ownercx;
268
+
269
+ do {
270
+ ownercx = scope->ownercx;
271
+ if (ownercx == cx) {
272
+ JS_RUNTIME_METER(cx->runtime, deadlocksAvoided);
273
+ return JS_TRUE;
274
+ }
275
+ } while (ownercx && (scope = ownercx->scopeToShare) != NULL);
276
+ return JS_FALSE;
277
+ }
278
+
279
+ /*
280
+ * Make scope multi-threaded, i.e. share its ownership among contexts in rt
281
+ * using a "thin" or (if necessary due to contention) "fat" lock. Called only
282
+ * from ClaimScope, immediately below, when we detect deadlock were we to wait
283
+ * for scope's lock, because its ownercx is waiting on a scope owned by the
284
+ * calling cx.
285
+ *
286
+ * (i) rt->gcLock held
287
+ */
288
+ static void
289
+ ShareScope(JSRuntime *rt, JSScope *scope)
290
+ {
291
+ JSScope **todop;
292
+
293
+ if (scope->u.link) {
294
+ for (todop = &rt->scopeSharingTodo; *todop != scope;
295
+ todop = &(*todop)->u.link) {
296
+ JS_ASSERT(*todop != NO_SCOPE_SHARING_TODO);
297
+ }
298
+ *todop = scope->u.link;
299
+ scope->u.link = NULL; /* null u.link for sanity ASAP */
300
+ JS_NOTIFY_ALL_CONDVAR(rt->scopeSharingDone);
301
+ }
302
+ js_InitLock(&scope->lock);
303
+ if (scope == rt->setSlotScope) {
304
+ /*
305
+ * Nesting locks on another thread that's using scope->ownercx: give
306
+ * the held lock a reentrancy count of 1 and set its lock.owner field
307
+ * directly (no compare-and-swap needed while scope->ownercx is still
308
+ * non-null). See below in ClaimScope, before the ShareScope call,
309
+ * for more on why this is necessary.
310
+ *
311
+ * If NSPR_LOCK is defined, we cannot deadlock holding rt->gcLock and
312
+ * acquiring scope->lock.fat here, against another thread holding that
313
+ * fat lock and trying to grab rt->gcLock. This is because no other
314
+ * thread can attempt to acquire scope->lock.fat until scope->ownercx
315
+ * is null *and* our thread has released rt->gcLock, which interlocks
316
+ * scope->ownercx's transition to null against tests of that member
317
+ * in ClaimScope.
318
+ */
319
+ scope->lock.owner = scope->ownercx->thread;
320
+ #ifdef NSPR_LOCK
321
+ JS_ACQUIRE_LOCK((JSLock*)scope->lock.fat);
322
+ #endif
323
+ scope->u.count = 1;
324
+ } else {
325
+ scope->u.count = 0;
326
+ }
327
+ js_FinishSharingScope(rt, scope);
328
+ }
329
+
330
+ /*
331
+ * js_FinishSharingScope is the tail part of ShareScope, split out to become a
332
+ * subroutine of JS_EndRequest too. The bulk of the work here involves making
333
+ * mutable strings in the scope's object's slots be immutable. We have to do
334
+ * this because such strings will soon be available to multiple threads, so
335
+ * their buffers can't be realloc'd any longer in js_ConcatStrings, and their
336
+ * members can't be modified by js_ConcatStrings, js_MinimizeDependentStrings,
337
+ * or js_UndependString.
338
+ *
339
+ * The last bit of work done by js_FinishSharingScope nulls scope->ownercx and
340
+ * updates rt->sharedScopes.
341
+ */
342
+ #define MAKE_STRING_IMMUTABLE(rt, v, vp) \
343
+ JS_BEGIN_MACRO \
344
+ JSString *str_ = JSVAL_TO_STRING(v); \
345
+ uint8 *flagp_ = js_GetGCThingFlags(str_); \
346
+ if (*flagp_ & GCF_MUTABLE) { \
347
+ if (JSSTRING_IS_DEPENDENT(str_) && \
348
+ !js_UndependString(NULL, str_)) { \
349
+ JS_RUNTIME_METER(rt, badUndependStrings); \
350
+ *vp = JSVAL_VOID; \
351
+ } else { \
352
+ *flagp_ &= ~GCF_MUTABLE; \
353
+ } \
354
+ } \
355
+ JS_END_MACRO
356
+
357
+ void
358
+ js_FinishSharingScope(JSRuntime *rt, JSScope *scope)
359
+ {
360
+ JSObject *obj;
361
+ uint32 nslots;
362
+ jsval v, *vp, *end;
363
+
364
+ obj = scope->object;
365
+ nslots = JS_MIN(obj->map->freeslot, obj->map->nslots);
366
+ for (vp = obj->slots, end = vp + nslots; vp < end; vp++) {
367
+ v = *vp;
368
+ if (JSVAL_IS_STRING(v))
369
+ MAKE_STRING_IMMUTABLE(rt, v, vp);
370
+ }
371
+
372
+ scope->ownercx = NULL; /* NB: set last, after lock init */
373
+ JS_RUNTIME_METER(rt, sharedScopes);
374
+ }
375
+
376
+ /*
377
+ * Given a scope with apparently non-null ownercx different from cx, try to
378
+ * set ownercx to cx, claiming exclusive (single-threaded) ownership of scope.
379
+ * If we claim ownership, return true. Otherwise, we wait for ownercx to be
380
+ * set to null (indicating that scope is multi-threaded); or if waiting would
381
+ * deadlock, we set ownercx to null ourselves via ShareScope. In any case,
382
+ * once ownercx is null we return false.
383
+ */
384
+ static JSBool
385
+ ClaimScope(JSScope *scope, JSContext *cx)
386
+ {
387
+ JSRuntime *rt;
388
+ JSContext *ownercx;
389
+ jsrefcount saveDepth;
390
+ PRStatus stat;
391
+
392
+ rt = cx->runtime;
393
+ JS_RUNTIME_METER(rt, claimAttempts);
394
+ JS_LOCK_GC(rt);
395
+
396
+ /* Reload in case ownercx went away while we blocked on the lock. */
397
+ while ((ownercx = scope->ownercx) != NULL) {
398
+ /*
399
+ * Avoid selflock if ownercx is dead, or is not running a request, or
400
+ * has the same thread as cx. Set scope->ownercx to cx so that the
401
+ * matching JS_UNLOCK_SCOPE or JS_UNLOCK_OBJ macro call will take the
402
+ * fast path around the corresponding js_UnlockScope or js_UnlockObj
403
+ * function call.
404
+ *
405
+ * If scope->u.link is non-null, scope has already been inserted on
406
+ * the rt->scopeSharingTodo list, because another thread's context
407
+ * already wanted to lock scope while ownercx was running a request.
408
+ * We can't claim any scope whose u.link is non-null at this point,
409
+ * even if ownercx->requestDepth is 0 (see below where we suspend our
410
+ * request before waiting on rt->scopeSharingDone).
411
+ */
412
+ if (!scope->u.link &&
413
+ (!js_ValidContextPointer(rt, ownercx) ||
414
+ !ownercx->requestDepth ||
415
+ ownercx->thread == cx->thread)) {
416
+ JS_ASSERT(scope->u.count == 0);
417
+ scope->ownercx = cx;
418
+ JS_UNLOCK_GC(rt);
419
+ JS_RUNTIME_METER(rt, claimedScopes);
420
+ return JS_TRUE;
421
+ }
422
+
423
+ /*
424
+ * Avoid deadlock if scope's owner context is waiting on a scope that
425
+ * we own, by revoking scope's ownership. This approach to deadlock
426
+ * avoidance works because the engine never nests scope locks, except
427
+ * for the notable case of js_SetProtoOrParent (see jsobj.c).
428
+ *
429
+ * If cx could hold locks on ownercx->scopeToShare, or if ownercx
430
+ * could hold locks on scope, we would need to keep reentrancy counts
431
+ * for all such "flyweight" (ownercx != NULL) locks, so that control
432
+ * would unwind properly once these locks became "thin" or "fat".
433
+ * Apart from the js_SetProtoOrParent exception, the engine promotes
434
+ * a scope from exclusive to shared access only when locking, never
435
+ * when holding or unlocking.
436
+ *
437
+ * If ownercx's thread is calling js_SetProtoOrParent, trying to lock
438
+ * the inner scope (the scope of the object being set as the prototype
439
+ * of the outer object), ShareScope will find the outer object's scope
440
+ * at rt->setSlotScope. If it's the same as scope, we give it a lock
441
+ * held by ownercx's thread with reentrancy count of 1, then we return
442
+ * here and break. After that we unwind to js_[GS]etSlotThreadSafe or
443
+ * js_LockScope (our caller), where we wait on the newly-fattened lock
444
+ * until ownercx's thread unwinds from js_SetProtoOrParent.
445
+ *
446
+ * Avoid deadlock before any of this scope/context cycle detection if
447
+ * cx is on the active GC's thread, because in that case, no requests
448
+ * will run until the GC completes. Any scope wanted by the GC (from
449
+ * a finalizer) that can't be claimed must be slated for sharing.
450
+ */
451
+ if (rt->gcThread == cx->thread ||
452
+ (ownercx->scopeToShare &&
453
+ WillDeadlock(ownercx->scopeToShare, cx))) {
454
+ ShareScope(rt, scope);
455
+ break;
456
+ }
457
+
458
+ /*
459
+ * Thanks to the non-zero NO_SCOPE_SHARING_TODO link terminator, we
460
+ * can decide whether scope is on rt->scopeSharingTodo with a single
461
+ * non-null test, and avoid double-insertion bugs.
462
+ */
463
+ if (!scope->u.link) {
464
+ scope->u.link = rt->scopeSharingTodo;
465
+ rt->scopeSharingTodo = scope;
466
+ js_HoldObjectMap(cx, &scope->map);
467
+ }
468
+
469
+ /*
470
+ * Inline JS_SuspendRequest before we wait on rt->scopeSharingDone,
471
+ * saving and clearing cx->requestDepth so we don't deadlock if the
472
+ * GC needs to run on ownercx.
473
+ *
474
+ * Unlike JS_SuspendRequest and JS_EndRequest, we must take care not
475
+ * to decrement rt->requestCount if cx is active on the GC's thread,
476
+ * because the GC has already reduced rt->requestCount to exclude all
477
+ * such such contexts.
478
+ */
479
+ saveDepth = cx->requestDepth;
480
+ if (saveDepth) {
481
+ cx->requestDepth = 0;
482
+ if (rt->gcThread != cx->thread) {
483
+ JS_ASSERT(rt->requestCount > 0);
484
+ rt->requestCount--;
485
+ if (rt->requestCount == 0)
486
+ JS_NOTIFY_REQUEST_DONE(rt);
487
+ }
488
+ }
489
+
490
+ /*
491
+ * We know that some other thread's context owns scope, which is now
492
+ * linked onto rt->scopeSharingTodo, awaiting the end of that other
493
+ * thread's request. So it is safe to wait on rt->scopeSharingDone.
494
+ */
495
+ cx->scopeToShare = scope;
496
+ stat = PR_WaitCondVar(rt->scopeSharingDone, PR_INTERVAL_NO_TIMEOUT);
497
+ JS_ASSERT(stat != PR_FAILURE);
498
+
499
+ /*
500
+ * Inline JS_ResumeRequest after waiting on rt->scopeSharingDone,
501
+ * restoring cx->requestDepth. Same note as above for the inlined,
502
+ * specialized JS_SuspendRequest code: beware rt->gcThread.
503
+ */
504
+ if (saveDepth) {
505
+ if (rt->gcThread != cx->thread) {
506
+ while (rt->gcLevel > 0)
507
+ JS_AWAIT_GC_DONE(rt);
508
+ rt->requestCount++;
509
+ }
510
+ cx->requestDepth = saveDepth;
511
+ }
512
+
513
+ /*
514
+ * Don't clear cx->scopeToShare until after we're through waiting on
515
+ * all condition variables protected by rt->gcLock -- that includes
516
+ * rt->scopeSharingDone *and* rt->gcDone (hidden in JS_AWAIT_GC_DONE,
517
+ * in the inlined JS_ResumeRequest code immediately above).
518
+ *
519
+ * Otherwise, the GC could easily deadlock with another thread that
520
+ * owns a scope wanted by a finalizer. By keeping cx->scopeToShare
521
+ * set till here, we ensure that such deadlocks are detected, which
522
+ * results in the finalized object's scope being shared (it must, of
523
+ * course, have other, live objects sharing it).
524
+ */
525
+ cx->scopeToShare = NULL;
526
+ }
527
+
528
+ JS_UNLOCK_GC(rt);
529
+ return JS_FALSE;
530
+ }
531
+
532
+ /* Exported to js.c, which calls it via OBJ_GET_* and JSVAL_IS_* macros. */
533
+ JS_FRIEND_API(jsval)
534
+ js_GetSlotThreadSafe(JSContext *cx, JSObject *obj, uint32 slot)
535
+ {
536
+ jsval v;
537
+ JSScope *scope;
538
+ #ifndef NSPR_LOCK
539
+ JSThinLock *tl;
540
+ jsword me;
541
+ #endif
542
+
543
+ /*
544
+ * We handle non-native objects via JSObjectOps.getRequiredSlot, treating
545
+ * all slots starting from 0 as required slots. A property definition or
546
+ * some prior arrangement must have allocated slot.
547
+ *
548
+ * Note once again (see jspubtd.h, before JSGetRequiredSlotOp's typedef)
549
+ * the crucial distinction between a |required slot number| that's passed
550
+ * to the get/setRequiredSlot JSObjectOps, and a |reserved slot index|
551
+ * passed to the JS_Get/SetReservedSlot APIs.
552
+ */
553
+ if (!OBJ_IS_NATIVE(obj))
554
+ return OBJ_GET_REQUIRED_SLOT(cx, obj, slot);
555
+
556
+ /*
557
+ * Native object locking is inlined here to optimize the single-threaded
558
+ * and contention-free multi-threaded cases.
559
+ */
560
+ scope = OBJ_SCOPE(obj);
561
+ JS_ASSERT(scope->ownercx != cx);
562
+ JS_ASSERT(obj->slots && slot < obj->map->freeslot);
563
+
564
+ /*
565
+ * Avoid locking if called from the GC (see GC_AWARE_GET_SLOT in jsobj.h).
566
+ * Also avoid locking an object owning a sealed scope. If neither of those
567
+ * special cases applies, try to claim scope's flyweight lock from whatever
568
+ * context may have had it in an earlier request.
569
+ */
570
+ if (CX_THREAD_IS_RUNNING_GC(cx) ||
571
+ (SCOPE_IS_SEALED(scope) && scope->object == obj) ||
572
+ (scope->ownercx && ClaimScope(scope, cx))) {
573
+ return obj->slots[slot];
574
+ }
575
+
576
+ #ifndef NSPR_LOCK
577
+ tl = &scope->lock;
578
+ me = cx->thread;
579
+ JS_ASSERT(me == CurrentThreadId());
580
+ if (js_CompareAndSwap(&tl->owner, 0, me)) {
581
+ /*
582
+ * Got the lock with one compare-and-swap. Even so, someone else may
583
+ * have mutated obj so it now has its own scope and lock, which would
584
+ * require either a restart from the top of this routine, or a thin
585
+ * lock release followed by fat lock acquisition.
586
+ */
587
+ if (scope == OBJ_SCOPE(obj)) {
588
+ v = obj->slots[slot];
589
+ if (!js_CompareAndSwap(&tl->owner, me, 0)) {
590
+ /* Assert that scope locks never revert to flyweight. */
591
+ JS_ASSERT(scope->ownercx != cx);
592
+ LOGIT(scope, '1');
593
+ scope->u.count = 1;
594
+ js_UnlockObj(cx, obj);
595
+ }
596
+ return v;
597
+ }
598
+ if (!js_CompareAndSwap(&tl->owner, me, 0))
599
+ js_Dequeue(tl);
600
+ }
601
+ else if (Thin_RemoveWait(ReadWord(tl->owner)) == me) {
602
+ return obj->slots[slot];
603
+ }
604
+ #endif
605
+
606
+ js_LockObj(cx, obj);
607
+ v = obj->slots[slot];
608
+
609
+ /*
610
+ * Test whether cx took ownership of obj's scope during js_LockObj.
611
+ *
612
+ * This does not mean that a given scope reverted to flyweight from "thin"
613
+ * or "fat" -- it does mean that obj's map pointer changed due to another
614
+ * thread setting a property, requiring obj to cease sharing a prototype
615
+ * object's scope (whose lock was not flyweight, else we wouldn't be here
616
+ * in the first place!).
617
+ */
618
+ scope = OBJ_SCOPE(obj);
619
+ if (scope->ownercx != cx)
620
+ js_UnlockScope(cx, scope);
621
+ return v;
622
+ }
623
+
624
+ void
625
+ js_SetSlotThreadSafe(JSContext *cx, JSObject *obj, uint32 slot, jsval v)
626
+ {
627
+ JSScope *scope;
628
+ #ifndef NSPR_LOCK
629
+ JSThinLock *tl;
630
+ jsword me;
631
+ #endif
632
+
633
+ /* Any string stored in a thread-safe object must be immutable. */
634
+ if (JSVAL_IS_STRING(v))
635
+ MAKE_STRING_IMMUTABLE(cx->runtime, v, &v);
636
+
637
+ /*
638
+ * We handle non-native objects via JSObjectOps.setRequiredSlot, as above
639
+ * for the Get case.
640
+ */
641
+ if (!OBJ_IS_NATIVE(obj)) {
642
+ OBJ_SET_REQUIRED_SLOT(cx, obj, slot, v);
643
+ return;
644
+ }
645
+
646
+ /*
647
+ * Native object locking is inlined here to optimize the single-threaded
648
+ * and contention-free multi-threaded cases.
649
+ */
650
+ scope = OBJ_SCOPE(obj);
651
+ JS_ASSERT(scope->ownercx != cx);
652
+ JS_ASSERT(obj->slots && slot < obj->map->freeslot);
653
+
654
+ /*
655
+ * Avoid locking if called from the GC (see GC_AWARE_GET_SLOT in jsobj.h).
656
+ * Also avoid locking an object owning a sealed scope. If neither of those
657
+ * special cases applies, try to claim scope's flyweight lock from whatever
658
+ * context may have had it in an earlier request.
659
+ */
660
+ if (CX_THREAD_IS_RUNNING_GC(cx) ||
661
+ (SCOPE_IS_SEALED(scope) && scope->object == obj) ||
662
+ (scope->ownercx && ClaimScope(scope, cx))) {
663
+ obj->slots[slot] = v;
664
+ return;
665
+ }
666
+
667
+ #ifndef NSPR_LOCK
668
+ tl = &scope->lock;
669
+ me = cx->thread;
670
+ JS_ASSERT(me == CurrentThreadId());
671
+ if (js_CompareAndSwap(&tl->owner, 0, me)) {
672
+ if (scope == OBJ_SCOPE(obj)) {
673
+ obj->slots[slot] = v;
674
+ if (!js_CompareAndSwap(&tl->owner, me, 0)) {
675
+ /* Assert that scope locks never revert to flyweight. */
676
+ JS_ASSERT(scope->ownercx != cx);
677
+ LOGIT(scope, '1');
678
+ scope->u.count = 1;
679
+ js_UnlockObj(cx, obj);
680
+ }
681
+ return;
682
+ }
683
+ if (!js_CompareAndSwap(&tl->owner, me, 0))
684
+ js_Dequeue(tl);
685
+ }
686
+ else if (Thin_RemoveWait(ReadWord(tl->owner)) == me) {
687
+ obj->slots[slot] = v;
688
+ return;
689
+ }
690
+ #endif
691
+
692
+ js_LockObj(cx, obj);
693
+ obj->slots[slot] = v;
694
+
695
+ /*
696
+ * Same drill as above, in js_GetSlotThreadSafe. Note that we cannot
697
+ * assume obj has its own mutable scope (where scope->object == obj) yet,
698
+ * because OBJ_SET_SLOT is called for the "universal", common slots such
699
+ * as JSSLOT_PROTO and JSSLOT_PARENT, without a prior js_GetMutableScope.
700
+ * See also the JSPROP_SHARED attribute and its usage.
701
+ */
702
+ scope = OBJ_SCOPE(obj);
703
+ if (scope->ownercx != cx)
704
+ js_UnlockScope(cx, scope);
705
+ }
706
+
707
+ #ifndef NSPR_LOCK
708
+
709
+ static JSFatLock *
710
+ NewFatlock()
711
+ {
712
+ JSFatLock *fl = (JSFatLock *)malloc(sizeof(JSFatLock)); /* for now */
713
+ if (!fl) return NULL;
714
+ fl->susp = 0;
715
+ fl->next = NULL;
716
+ fl->prevp = NULL;
717
+ fl->slock = PR_NewLock();
718
+ fl->svar = PR_NewCondVar(fl->slock);
719
+ return fl;
720
+ }
721
+
722
+ static void
723
+ DestroyFatlock(JSFatLock *fl)
724
+ {
725
+ PR_DestroyLock(fl->slock);
726
+ PR_DestroyCondVar(fl->svar);
727
+ free(fl);
728
+ }
729
+
730
+ static JSFatLock *
731
+ ListOfFatlocks(int listc)
732
+ {
733
+ JSFatLock *m;
734
+ JSFatLock *m0;
735
+ int i;
736
+
737
+ JS_ASSERT(listc>0);
738
+ m0 = m = NewFatlock();
739
+ for (i=1; i<listc; i++) {
740
+ m->next = NewFatlock();
741
+ m = m->next;
742
+ }
743
+ return m0;
744
+ }
745
+
746
+ static void
747
+ DeleteListOfFatlocks(JSFatLock *m)
748
+ {
749
+ JSFatLock *m0;
750
+ for (; m; m=m0) {
751
+ m0 = m->next;
752
+ DestroyFatlock(m);
753
+ }
754
+ }
755
+
756
+ static JSFatLockTable *fl_list_table = NULL;
757
+ static uint32 fl_list_table_len = 0;
758
+ static uint32 fl_list_chunk_len = 0;
759
+
760
+ static JSFatLock *
761
+ GetFatlock(void *id)
762
+ {
763
+ JSFatLock *m;
764
+
765
+ uint32 i = GLOBAL_LOCK_INDEX(id);
766
+ if (fl_list_table[i].free == NULL) {
767
+ #ifdef DEBUG
768
+ if (fl_list_table[i].taken)
769
+ printf("Ran out of fat locks!\n");
770
+ #endif
771
+ fl_list_table[i].free = ListOfFatlocks(fl_list_chunk_len);
772
+ }
773
+ m = fl_list_table[i].free;
774
+ fl_list_table[i].free = m->next;
775
+ m->susp = 0;
776
+ m->next = fl_list_table[i].taken;
777
+ m->prevp = &fl_list_table[i].taken;
778
+ if (fl_list_table[i].taken)
779
+ fl_list_table[i].taken->prevp = &m->next;
780
+ fl_list_table[i].taken = m;
781
+ return m;
782
+ }
783
+
784
+ static void
785
+ PutFatlock(JSFatLock *m, void *id)
786
+ {
787
+ uint32 i;
788
+ if (m == NULL)
789
+ return;
790
+
791
+ /* Unlink m from fl_list_table[i].taken. */
792
+ *m->prevp = m->next;
793
+ if (m->next)
794
+ m->next->prevp = m->prevp;
795
+
796
+ /* Insert m in fl_list_table[i].free. */
797
+ i = GLOBAL_LOCK_INDEX(id);
798
+ m->next = fl_list_table[i].free;
799
+ fl_list_table[i].free = m;
800
+ }
801
+
802
+ #endif /* !NSPR_LOCK */
803
+
804
+ JSBool
805
+ js_SetupLocks(int listc, int globc)
806
+ {
807
+ #ifndef NSPR_LOCK
808
+ uint32 i;
809
+
810
+ if (global_locks)
811
+ return JS_TRUE;
812
+ #ifdef DEBUG
813
+ if (listc > 10000 || listc < 0) /* listc == fat lock list chunk length */
814
+ printf("Bad number %d in js_SetupLocks()!\n", listc);
815
+ if (globc > 100 || globc < 0) /* globc == number of global locks */
816
+ printf("Bad number %d in js_SetupLocks()!\n", listc);
817
+ #endif
818
+ global_locks_log2 = JS_CeilingLog2(globc);
819
+ global_locks_mask = JS_BITMASK(global_locks_log2);
820
+ global_lock_count = JS_BIT(global_locks_log2);
821
+ global_locks = (PRLock **) malloc(global_lock_count * sizeof(PRLock*));
822
+ if (!global_locks)
823
+ return JS_FALSE;
824
+ for (i = 0; i < global_lock_count; i++) {
825
+ global_locks[i] = PR_NewLock();
826
+ if (!global_locks[i]) {
827
+ global_lock_count = i;
828
+ js_CleanupLocks();
829
+ return JS_FALSE;
830
+ }
831
+ }
832
+ fl_list_table = (JSFatLockTable *) malloc(i * sizeof(JSFatLockTable));
833
+ if (!fl_list_table) {
834
+ js_CleanupLocks();
835
+ return JS_FALSE;
836
+ }
837
+ fl_list_table_len = global_lock_count;
838
+ for (i = 0; i < global_lock_count; i++)
839
+ fl_list_table[i].free = fl_list_table[i].taken = NULL;
840
+ fl_list_chunk_len = listc;
841
+ #endif /* !NSPR_LOCK */
842
+ return JS_TRUE;
843
+ }
844
+
845
+ void
846
+ js_CleanupLocks()
847
+ {
848
+ #ifndef NSPR_LOCK
849
+ uint32 i;
850
+
851
+ if (global_locks) {
852
+ for (i = 0; i < global_lock_count; i++)
853
+ PR_DestroyLock(global_locks[i]);
854
+ free(global_locks);
855
+ global_locks = NULL;
856
+ global_lock_count = 1;
857
+ global_locks_log2 = 0;
858
+ global_locks_mask = 0;
859
+ }
860
+ if (fl_list_table) {
861
+ for (i = 0; i < fl_list_table_len; i++) {
862
+ DeleteListOfFatlocks(fl_list_table[i].free);
863
+ fl_list_table[i].free = NULL;
864
+ DeleteListOfFatlocks(fl_list_table[i].taken);
865
+ fl_list_table[i].taken = NULL;
866
+ }
867
+ free(fl_list_table);
868
+ fl_list_table = NULL;
869
+ fl_list_table_len = 0;
870
+ }
871
+ #endif /* !NSPR_LOCK */
872
+ }
873
+
874
+ void
875
+ js_InitContextForLocking(JSContext *cx)
876
+ {
877
+ cx->thread = CurrentThreadId();
878
+ JS_ASSERT(Thin_GetWait(cx->thread) == 0);
879
+ }
880
+
881
+ #ifndef NSPR_LOCK
882
+
883
+ /*
884
+ * Fast locking and unlocking is implemented by delaying the allocation of a
885
+ * system lock (fat lock) until contention. As long as a locking thread A
886
+ * runs uncontended, the lock is represented solely by storing A's identity in
887
+ * the object being locked.
888
+ *
889
+ * If another thread B tries to lock the object currently locked by A, B is
890
+ * enqueued into a fat lock structure (which might have to be allocated and
891
+ * pointed to by the object), and suspended using NSPR conditional variables
892
+ * (wait). A wait bit (Bacon bit) is set in the lock word of the object,
893
+ * signalling to A that when releasing the lock, B must be dequeued and
894
+ * notified.
895
+ *
896
+ * The basic operation of the locking primitives (js_Lock, js_Unlock,
897
+ * js_Enqueue, and js_Dequeue) is compare-and-swap. Hence, when locking into
898
+ * the word pointed at by p, compare-and-swap(p, 0, A) success implies that p
899
+ * is unlocked. Similarly, when unlocking p, if compare-and-swap(p, A, 0)
900
+ * succeeds this implies that p is uncontended (no one is waiting because the
901
+ * wait bit is not set).
902
+ *
903
+ * When dequeueing, the lock is released, and one of the threads suspended on
904
+ * the lock is notified. If other threads still are waiting, the wait bit is
905
+ * kept (in js_Enqueue), and if not, the fat lock is deallocated.
906
+ *
907
+ * The functions js_Enqueue, js_Dequeue, js_SuspendThread, and js_ResumeThread
908
+ * are serialized using a global lock. For scalability, a hashtable of global
909
+ * locks is used, which is indexed modulo the thin lock pointer.
910
+ */
911
+
912
+ /*
913
+ * Invariants:
914
+ * (i) global lock is held
915
+ * (ii) fl->susp >= 0
916
+ */
917
+ static int
918
+ js_SuspendThread(JSThinLock *tl)
919
+ {
920
+ JSFatLock *fl;
921
+ PRStatus stat;
922
+
923
+ if (tl->fat == NULL)
924
+ fl = tl->fat = GetFatlock(tl);
925
+ else
926
+ fl = tl->fat;
927
+ JS_ASSERT(fl->susp >= 0);
928
+ fl->susp++;
929
+ PR_Lock(fl->slock);
930
+ js_UnlockGlobal(tl);
931
+ stat = PR_WaitCondVar(fl->svar, PR_INTERVAL_NO_TIMEOUT);
932
+ JS_ASSERT(stat != PR_FAILURE);
933
+ PR_Unlock(fl->slock);
934
+ js_LockGlobal(tl);
935
+ fl->susp--;
936
+ if (fl->susp == 0) {
937
+ PutFatlock(fl, tl);
938
+ tl->fat = NULL;
939
+ }
940
+ return tl->fat == NULL;
941
+ }
942
+
943
+ /*
944
+ * (i) global lock is held
945
+ * (ii) fl->susp > 0
946
+ */
947
+ static void
948
+ js_ResumeThread(JSThinLock *tl)
949
+ {
950
+ JSFatLock *fl = tl->fat;
951
+ PRStatus stat;
952
+
953
+ JS_ASSERT(fl != NULL);
954
+ JS_ASSERT(fl->susp > 0);
955
+ PR_Lock(fl->slock);
956
+ js_UnlockGlobal(tl);
957
+ stat = PR_NotifyCondVar(fl->svar);
958
+ JS_ASSERT(stat != PR_FAILURE);
959
+ PR_Unlock(fl->slock);
960
+ }
961
+
962
+ static void
963
+ js_Enqueue(JSThinLock *tl, jsword me)
964
+ {
965
+ jsword o, n;
966
+
967
+ js_LockGlobal(tl);
968
+ for (;;) {
969
+ o = ReadWord(tl->owner);
970
+ n = Thin_SetWait(o);
971
+ if (o != 0 && js_CompareAndSwap(&tl->owner, o, n)) {
972
+ if (js_SuspendThread(tl))
973
+ me = Thin_RemoveWait(me);
974
+ else
975
+ me = Thin_SetWait(me);
976
+ }
977
+ else if (js_CompareAndSwap(&tl->owner, 0, me)) {
978
+ js_UnlockGlobal(tl);
979
+ return;
980
+ }
981
+ }
982
+ }
983
+
984
+ static void
985
+ js_Dequeue(JSThinLock *tl)
986
+ {
987
+ jsword o;
988
+
989
+ js_LockGlobal(tl);
990
+ o = ReadWord(tl->owner);
991
+ JS_ASSERT(Thin_GetWait(o) != 0);
992
+ JS_ASSERT(tl->fat != NULL);
993
+ if (!js_CompareAndSwap(&tl->owner, o, 0)) /* release it */
994
+ JS_ASSERT(0);
995
+ js_ResumeThread(tl);
996
+ }
997
+
998
+ JS_INLINE void
999
+ js_Lock(JSThinLock *tl, jsword me)
1000
+ {
1001
+ JS_ASSERT(me == CurrentThreadId());
1002
+ if (js_CompareAndSwap(&tl->owner, 0, me))
1003
+ return;
1004
+ if (Thin_RemoveWait(ReadWord(tl->owner)) != me)
1005
+ js_Enqueue(tl, me);
1006
+ #ifdef DEBUG
1007
+ else
1008
+ JS_ASSERT(0);
1009
+ #endif
1010
+ }
1011
+
1012
+ JS_INLINE void
1013
+ js_Unlock(JSThinLock *tl, jsword me)
1014
+ {
1015
+ JS_ASSERT(me == CurrentThreadId());
1016
+ if (js_CompareAndSwap(&tl->owner, me, 0))
1017
+ return;
1018
+ if (Thin_RemoveWait(ReadWord(tl->owner)) == me)
1019
+ js_Dequeue(tl);
1020
+ #ifdef DEBUG
1021
+ else
1022
+ JS_ASSERT(0);
1023
+ #endif
1024
+ }
1025
+
1026
+ #endif /* !NSPR_LOCK */
1027
+
1028
+ void
1029
+ js_LockRuntime(JSRuntime *rt)
1030
+ {
1031
+ PR_Lock(rt->rtLock);
1032
+ #ifdef DEBUG
1033
+ rt->rtLockOwner = CurrentThreadId();
1034
+ #endif
1035
+ }
1036
+
1037
+ void
1038
+ js_UnlockRuntime(JSRuntime *rt)
1039
+ {
1040
+ #ifdef DEBUG
1041
+ rt->rtLockOwner = 0;
1042
+ #endif
1043
+ PR_Unlock(rt->rtLock);
1044
+ }
1045
+
1046
+ void
1047
+ js_LockScope(JSContext *cx, JSScope *scope)
1048
+ {
1049
+ jsword me = cx->thread;
1050
+
1051
+ JS_ASSERT(me == CurrentThreadId());
1052
+ JS_ASSERT(scope->ownercx != cx);
1053
+ if (CX_THREAD_IS_RUNNING_GC(cx))
1054
+ return;
1055
+ if (scope->ownercx && ClaimScope(scope, cx))
1056
+ return;
1057
+
1058
+ if (Thin_RemoveWait(ReadWord(scope->lock.owner)) == me) {
1059
+ JS_ASSERT(scope->u.count > 0);
1060
+ LOGIT(scope, '+');
1061
+ scope->u.count++;
1062
+ } else {
1063
+ JSThinLock *tl = &scope->lock;
1064
+ JS_LOCK0(tl, me);
1065
+ JS_ASSERT(scope->u.count == 0);
1066
+ LOGIT(scope, '1');
1067
+ scope->u.count = 1;
1068
+ }
1069
+ }
1070
+
1071
+ void
1072
+ js_UnlockScope(JSContext *cx, JSScope *scope)
1073
+ {
1074
+ jsword me = cx->thread;
1075
+
1076
+ /* We hope compilers use me instead of reloading cx->thread in the macro. */
1077
+ if (CX_THREAD_IS_RUNNING_GC(cx))
1078
+ return;
1079
+ if (cx->lockedSealedScope == scope) {
1080
+ cx->lockedSealedScope = NULL;
1081
+ return;
1082
+ }
1083
+
1084
+ /*
1085
+ * If scope->ownercx is not null, it's likely that two contexts not using
1086
+ * requests nested locks for scope. The first context, cx here, claimed
1087
+ * scope; the second, scope->ownercx here, re-claimed it because the first
1088
+ * was not in a request, or was on the same thread. We don't want to keep
1089
+ * track of such nesting, because it penalizes the common non-nested case.
1090
+ * Instead of asserting here and silently coping, we simply re-claim scope
1091
+ * for cx and return.
1092
+ *
1093
+ * See http://bugzilla.mozilla.org/show_bug.cgi?id=229200 for a real world
1094
+ * case where an asymmetric thread model (Mozilla's main thread is known
1095
+ * to be the only thread that runs the GC) combined with multiple contexts
1096
+ * per thread has led to such request-less nesting.
1097
+ */
1098
+ if (scope->ownercx) {
1099
+ JS_ASSERT(scope->u.count == 0);
1100
+ JS_ASSERT(scope->lock.owner == 0);
1101
+ scope->ownercx = cx;
1102
+ return;
1103
+ }
1104
+
1105
+ JS_ASSERT(scope->u.count > 0);
1106
+ if (Thin_RemoveWait(ReadWord(scope->lock.owner)) != me) {
1107
+ JS_ASSERT(0); /* unbalanced unlock */
1108
+ return;
1109
+ }
1110
+ LOGIT(scope, '-');
1111
+ if (--scope->u.count == 0) {
1112
+ JSThinLock *tl = &scope->lock;
1113
+ JS_UNLOCK0(tl, me);
1114
+ }
1115
+ }
1116
+
1117
+ /*
1118
+ * NB: oldscope may be null if our caller is js_GetMutableScope and it just
1119
+ * dropped the last reference to oldscope.
1120
+ */
1121
+ void
1122
+ js_TransferScopeLock(JSContext *cx, JSScope *oldscope, JSScope *newscope)
1123
+ {
1124
+ jsword me;
1125
+ JSThinLock *tl;
1126
+
1127
+ JS_ASSERT(JS_IS_SCOPE_LOCKED(cx, newscope));
1128
+
1129
+ /*
1130
+ * If the last reference to oldscope went away, newscope needs no lock
1131
+ * state update.
1132
+ */
1133
+ if (!oldscope)
1134
+ return;
1135
+ JS_ASSERT(JS_IS_SCOPE_LOCKED(cx, oldscope));
1136
+
1137
+ /*
1138
+ * Special case in js_LockScope and js_UnlockScope for the GC calling
1139
+ * code that locks, unlocks, or mutates. Nothing to do in these cases,
1140
+ * because scope and newscope were "locked" by the GC thread, so neither
1141
+ * was actually locked.
1142
+ */
1143
+ if (CX_THREAD_IS_RUNNING_GC(cx))
1144
+ return;
1145
+
1146
+ /*
1147
+ * Special case in js_LockObj and js_UnlockScope for locking the sealed
1148
+ * scope of an object that owns that scope (the prototype or mutated obj
1149
+ * for which OBJ_SCOPE(obj)->object == obj), and unlocking it.
1150
+ */
1151
+ JS_ASSERT(cx->lockedSealedScope != newscope);
1152
+ if (cx->lockedSealedScope == oldscope) {
1153
+ JS_ASSERT(newscope->ownercx == cx ||
1154
+ (!newscope->ownercx && newscope->u.count == 1));
1155
+ cx->lockedSealedScope = NULL;
1156
+ return;
1157
+ }
1158
+
1159
+ /*
1160
+ * If oldscope is single-threaded, there's nothing to do.
1161
+ */
1162
+ if (oldscope->ownercx) {
1163
+ JS_ASSERT(oldscope->ownercx == cx);
1164
+ JS_ASSERT(newscope->ownercx == cx ||
1165
+ (!newscope->ownercx && newscope->u.count == 1));
1166
+ return;
1167
+ }
1168
+
1169
+ /*
1170
+ * We transfer oldscope->u.count only if newscope is not single-threaded.
1171
+ * Flow unwinds from here through some number of JS_UNLOCK_SCOPE and/or
1172
+ * JS_UNLOCK_OBJ macro calls, which will decrement newscope->u.count only
1173
+ * if they find newscope->ownercx != cx.
1174
+ */
1175
+ if (newscope->ownercx != cx) {
1176
+ JS_ASSERT(!newscope->ownercx);
1177
+ newscope->u.count = oldscope->u.count;
1178
+ }
1179
+
1180
+ /*
1181
+ * Reset oldscope's lock state so that it is completely unlocked.
1182
+ */
1183
+ LOGIT(oldscope, '0');
1184
+ oldscope->u.count = 0;
1185
+ tl = &oldscope->lock;
1186
+ me = cx->thread;
1187
+ JS_UNLOCK0(tl, me);
1188
+ }
1189
+
1190
+ void
1191
+ js_LockObj(JSContext *cx, JSObject *obj)
1192
+ {
1193
+ JSScope *scope;
1194
+
1195
+ JS_ASSERT(OBJ_IS_NATIVE(obj));
1196
+ for (;;) {
1197
+ scope = OBJ_SCOPE(obj);
1198
+ if (SCOPE_IS_SEALED(scope) && scope->object == obj &&
1199
+ !cx->lockedSealedScope) {
1200
+ cx->lockedSealedScope = scope;
1201
+ return;
1202
+ }
1203
+
1204
+ js_LockScope(cx, scope);
1205
+
1206
+ /* If obj still has this scope, we're done. */
1207
+ if (scope == OBJ_SCOPE(obj))
1208
+ return;
1209
+
1210
+ /* Lost a race with a mutator; retry with obj's new scope. */
1211
+ js_UnlockScope(cx, scope);
1212
+ }
1213
+ }
1214
+
1215
+ void
1216
+ js_UnlockObj(JSContext *cx, JSObject *obj)
1217
+ {
1218
+ JS_ASSERT(OBJ_IS_NATIVE(obj));
1219
+ js_UnlockScope(cx, OBJ_SCOPE(obj));
1220
+ }
1221
+
1222
+ #ifdef DEBUG
1223
+
1224
+ JSBool
1225
+ js_IsRuntimeLocked(JSRuntime *rt)
1226
+ {
1227
+ return CurrentThreadId() == rt->rtLockOwner;
1228
+ }
1229
+
1230
+ JSBool
1231
+ js_IsObjLocked(JSContext *cx, JSObject *obj)
1232
+ {
1233
+ JSScope *scope = OBJ_SCOPE(obj);
1234
+
1235
+ return MAP_IS_NATIVE(&scope->map) && js_IsScopeLocked(cx, scope);
1236
+ }
1237
+
1238
+ JSBool
1239
+ js_IsScopeLocked(JSContext *cx, JSScope *scope)
1240
+ {
1241
+ /* Special case: the GC locking any object's scope, see js_LockScope. */
1242
+ if (CX_THREAD_IS_RUNNING_GC(cx))
1243
+ return JS_TRUE;
1244
+
1245
+ /* Special case: locked object owning a sealed scope, see js_LockObj. */
1246
+ if (cx->lockedSealedScope == scope)
1247
+ return JS_TRUE;
1248
+
1249
+ /*
1250
+ * General case: the scope is either exclusively owned (by cx), or it has
1251
+ * a thin or fat lock to cope with shared (concurrent) ownership.
1252
+ */
1253
+ if (scope->ownercx) {
1254
+ JS_ASSERT(scope->ownercx == cx);
1255
+ return JS_TRUE;
1256
+ }
1257
+ return CurrentThreadId() == Thin_RemoveWait(ReadWord(scope->lock.owner));
1258
+ }
1259
+
1260
+ #endif /* DEBUG */
1261
+ #endif /* JS_THREADSAFE */