libv8 3.3.10.2

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 (700) hide show
  1. data/.gitignore +8 -0
  2. data/.gitmodules +3 -0
  3. data/Gemfile +4 -0
  4. data/README.md +44 -0
  5. data/Rakefile +73 -0
  6. data/ext/libv8/extconf.rb +9 -0
  7. data/lib/libv8.rb +15 -0
  8. data/lib/libv8/Makefile +38 -0
  9. data/lib/libv8/detect_cpu.rb +27 -0
  10. data/lib/libv8/fpic-on-linux-amd64.patch +13 -0
  11. data/lib/libv8/scons/CHANGES.txt +5334 -0
  12. data/lib/libv8/scons/LICENSE.txt +20 -0
  13. data/lib/libv8/scons/MANIFEST +199 -0
  14. data/lib/libv8/scons/PKG-INFO +13 -0
  15. data/lib/libv8/scons/README.txt +243 -0
  16. data/lib/libv8/scons/RELEASE.txt +98 -0
  17. data/lib/libv8/scons/engine/SCons/Action.py +1241 -0
  18. data/lib/libv8/scons/engine/SCons/Builder.py +877 -0
  19. data/lib/libv8/scons/engine/SCons/CacheDir.py +216 -0
  20. data/lib/libv8/scons/engine/SCons/Conftest.py +793 -0
  21. data/lib/libv8/scons/engine/SCons/Debug.py +220 -0
  22. data/lib/libv8/scons/engine/SCons/Defaults.py +480 -0
  23. data/lib/libv8/scons/engine/SCons/Environment.py +2318 -0
  24. data/lib/libv8/scons/engine/SCons/Errors.py +205 -0
  25. data/lib/libv8/scons/engine/SCons/Executor.py +633 -0
  26. data/lib/libv8/scons/engine/SCons/Job.py +435 -0
  27. data/lib/libv8/scons/engine/SCons/Memoize.py +244 -0
  28. data/lib/libv8/scons/engine/SCons/Node/Alias.py +152 -0
  29. data/lib/libv8/scons/engine/SCons/Node/FS.py +3142 -0
  30. data/lib/libv8/scons/engine/SCons/Node/Python.py +128 -0
  31. data/lib/libv8/scons/engine/SCons/Node/__init__.py +1328 -0
  32. data/lib/libv8/scons/engine/SCons/Options/BoolOption.py +50 -0
  33. data/lib/libv8/scons/engine/SCons/Options/EnumOption.py +50 -0
  34. data/lib/libv8/scons/engine/SCons/Options/ListOption.py +50 -0
  35. data/lib/libv8/scons/engine/SCons/Options/PackageOption.py +50 -0
  36. data/lib/libv8/scons/engine/SCons/Options/PathOption.py +76 -0
  37. data/lib/libv8/scons/engine/SCons/Options/__init__.py +67 -0
  38. data/lib/libv8/scons/engine/SCons/PathList.py +231 -0
  39. data/lib/libv8/scons/engine/SCons/Platform/__init__.py +241 -0
  40. data/lib/libv8/scons/engine/SCons/Platform/aix.py +69 -0
  41. data/lib/libv8/scons/engine/SCons/Platform/cygwin.py +55 -0
  42. data/lib/libv8/scons/engine/SCons/Platform/darwin.py +46 -0
  43. data/lib/libv8/scons/engine/SCons/Platform/hpux.py +46 -0
  44. data/lib/libv8/scons/engine/SCons/Platform/irix.py +44 -0
  45. data/lib/libv8/scons/engine/SCons/Platform/os2.py +58 -0
  46. data/lib/libv8/scons/engine/SCons/Platform/posix.py +263 -0
  47. data/lib/libv8/scons/engine/SCons/Platform/sunos.py +50 -0
  48. data/lib/libv8/scons/engine/SCons/Platform/win32.py +385 -0
  49. data/lib/libv8/scons/engine/SCons/SConf.py +1030 -0
  50. data/lib/libv8/scons/engine/SCons/SConsign.py +383 -0
  51. data/lib/libv8/scons/engine/SCons/Scanner/C.py +132 -0
  52. data/lib/libv8/scons/engine/SCons/Scanner/D.py +73 -0
  53. data/lib/libv8/scons/engine/SCons/Scanner/Dir.py +109 -0
  54. data/lib/libv8/scons/engine/SCons/Scanner/Fortran.py +316 -0
  55. data/lib/libv8/scons/engine/SCons/Scanner/IDL.py +48 -0
  56. data/lib/libv8/scons/engine/SCons/Scanner/LaTeX.py +384 -0
  57. data/lib/libv8/scons/engine/SCons/Scanner/Prog.py +101 -0
  58. data/lib/libv8/scons/engine/SCons/Scanner/RC.py +55 -0
  59. data/lib/libv8/scons/engine/SCons/Scanner/__init__.py +413 -0
  60. data/lib/libv8/scons/engine/SCons/Script/Interactive.py +384 -0
  61. data/lib/libv8/scons/engine/SCons/Script/Main.py +1334 -0
  62. data/lib/libv8/scons/engine/SCons/Script/SConsOptions.py +939 -0
  63. data/lib/libv8/scons/engine/SCons/Script/SConscript.py +640 -0
  64. data/lib/libv8/scons/engine/SCons/Script/__init__.py +412 -0
  65. data/lib/libv8/scons/engine/SCons/Sig.py +63 -0
  66. data/lib/libv8/scons/engine/SCons/Subst.py +904 -0
  67. data/lib/libv8/scons/engine/SCons/Taskmaster.py +1017 -0
  68. data/lib/libv8/scons/engine/SCons/Tool/386asm.py +61 -0
  69. data/lib/libv8/scons/engine/SCons/Tool/BitKeeper.py +67 -0
  70. data/lib/libv8/scons/engine/SCons/Tool/CVS.py +73 -0
  71. data/lib/libv8/scons/engine/SCons/Tool/FortranCommon.py +246 -0
  72. data/lib/libv8/scons/engine/SCons/Tool/JavaCommon.py +323 -0
  73. data/lib/libv8/scons/engine/SCons/Tool/MSCommon/__init__.py +56 -0
  74. data/lib/libv8/scons/engine/SCons/Tool/MSCommon/arch.py +61 -0
  75. data/lib/libv8/scons/engine/SCons/Tool/MSCommon/common.py +240 -0
  76. data/lib/libv8/scons/engine/SCons/Tool/MSCommon/netframework.py +82 -0
  77. data/lib/libv8/scons/engine/SCons/Tool/MSCommon/sdk.py +391 -0
  78. data/lib/libv8/scons/engine/SCons/Tool/MSCommon/vc.py +456 -0
  79. data/lib/libv8/scons/engine/SCons/Tool/MSCommon/vs.py +499 -0
  80. data/lib/libv8/scons/engine/SCons/Tool/Perforce.py +103 -0
  81. data/lib/libv8/scons/engine/SCons/Tool/PharLapCommon.py +137 -0
  82. data/lib/libv8/scons/engine/SCons/Tool/RCS.py +64 -0
  83. data/lib/libv8/scons/engine/SCons/Tool/SCCS.py +64 -0
  84. data/lib/libv8/scons/engine/SCons/Tool/Subversion.py +71 -0
  85. data/lib/libv8/scons/engine/SCons/Tool/__init__.py +681 -0
  86. data/lib/libv8/scons/engine/SCons/Tool/aixc++.py +82 -0
  87. data/lib/libv8/scons/engine/SCons/Tool/aixcc.py +74 -0
  88. data/lib/libv8/scons/engine/SCons/Tool/aixf77.py +80 -0
  89. data/lib/libv8/scons/engine/SCons/Tool/aixlink.py +76 -0
  90. data/lib/libv8/scons/engine/SCons/Tool/applelink.py +71 -0
  91. data/lib/libv8/scons/engine/SCons/Tool/ar.py +63 -0
  92. data/lib/libv8/scons/engine/SCons/Tool/as.py +78 -0
  93. data/lib/libv8/scons/engine/SCons/Tool/bcc32.py +81 -0
  94. data/lib/libv8/scons/engine/SCons/Tool/c++.py +99 -0
  95. data/lib/libv8/scons/engine/SCons/Tool/cc.py +102 -0
  96. data/lib/libv8/scons/engine/SCons/Tool/cvf.py +58 -0
  97. data/lib/libv8/scons/engine/SCons/Tool/default.py +50 -0
  98. data/lib/libv8/scons/engine/SCons/Tool/dmd.py +223 -0
  99. data/lib/libv8/scons/engine/SCons/Tool/dvi.py +64 -0
  100. data/lib/libv8/scons/engine/SCons/Tool/dvipdf.py +124 -0
  101. data/lib/libv8/scons/engine/SCons/Tool/dvips.py +94 -0
  102. data/lib/libv8/scons/engine/SCons/Tool/f77.py +62 -0
  103. data/lib/libv8/scons/engine/SCons/Tool/f90.py +62 -0
  104. data/lib/libv8/scons/engine/SCons/Tool/f95.py +63 -0
  105. data/lib/libv8/scons/engine/SCons/Tool/filesystem.py +98 -0
  106. data/lib/libv8/scons/engine/SCons/Tool/fortran.py +62 -0
  107. data/lib/libv8/scons/engine/SCons/Tool/g++.py +90 -0
  108. data/lib/libv8/scons/engine/SCons/Tool/g77.py +73 -0
  109. data/lib/libv8/scons/engine/SCons/Tool/gas.py +53 -0
  110. data/lib/libv8/scons/engine/SCons/Tool/gcc.py +80 -0
  111. data/lib/libv8/scons/engine/SCons/Tool/gfortran.py +64 -0
  112. data/lib/libv8/scons/engine/SCons/Tool/gnulink.py +63 -0
  113. data/lib/libv8/scons/engine/SCons/Tool/gs.py +81 -0
  114. data/lib/libv8/scons/engine/SCons/Tool/hpc++.py +84 -0
  115. data/lib/libv8/scons/engine/SCons/Tool/hpcc.py +53 -0
  116. data/lib/libv8/scons/engine/SCons/Tool/hplink.py +77 -0
  117. data/lib/libv8/scons/engine/SCons/Tool/icc.py +59 -0
  118. data/lib/libv8/scons/engine/SCons/Tool/icl.py +52 -0
  119. data/lib/libv8/scons/engine/SCons/Tool/ifl.py +72 -0
  120. data/lib/libv8/scons/engine/SCons/Tool/ifort.py +88 -0
  121. data/lib/libv8/scons/engine/SCons/Tool/ilink.py +59 -0
  122. data/lib/libv8/scons/engine/SCons/Tool/ilink32.py +60 -0
  123. data/lib/libv8/scons/engine/SCons/Tool/install.py +229 -0
  124. data/lib/libv8/scons/engine/SCons/Tool/intelc.py +482 -0
  125. data/lib/libv8/scons/engine/SCons/Tool/ipkg.py +67 -0
  126. data/lib/libv8/scons/engine/SCons/Tool/jar.py +110 -0
  127. data/lib/libv8/scons/engine/SCons/Tool/javac.py +230 -0
  128. data/lib/libv8/scons/engine/SCons/Tool/javah.py +137 -0
  129. data/lib/libv8/scons/engine/SCons/Tool/latex.py +79 -0
  130. data/lib/libv8/scons/engine/SCons/Tool/lex.py +97 -0
  131. data/lib/libv8/scons/engine/SCons/Tool/link.py +121 -0
  132. data/lib/libv8/scons/engine/SCons/Tool/linkloc.py +112 -0
  133. data/lib/libv8/scons/engine/SCons/Tool/m4.py +63 -0
  134. data/lib/libv8/scons/engine/SCons/Tool/masm.py +77 -0
  135. data/lib/libv8/scons/engine/SCons/Tool/midl.py +88 -0
  136. data/lib/libv8/scons/engine/SCons/Tool/mingw.py +158 -0
  137. data/lib/libv8/scons/engine/SCons/Tool/mslib.py +64 -0
  138. data/lib/libv8/scons/engine/SCons/Tool/mslink.py +266 -0
  139. data/lib/libv8/scons/engine/SCons/Tool/mssdk.py +50 -0
  140. data/lib/libv8/scons/engine/SCons/Tool/msvc.py +268 -0
  141. data/lib/libv8/scons/engine/SCons/Tool/msvs.py +1388 -0
  142. data/lib/libv8/scons/engine/SCons/Tool/mwcc.py +207 -0
  143. data/lib/libv8/scons/engine/SCons/Tool/mwld.py +107 -0
  144. data/lib/libv8/scons/engine/SCons/Tool/nasm.py +72 -0
  145. data/lib/libv8/scons/engine/SCons/Tool/packaging/__init__.py +312 -0
  146. data/lib/libv8/scons/engine/SCons/Tool/packaging/ipk.py +185 -0
  147. data/lib/libv8/scons/engine/SCons/Tool/packaging/msi.py +527 -0
  148. data/lib/libv8/scons/engine/SCons/Tool/packaging/rpm.py +365 -0
  149. data/lib/libv8/scons/engine/SCons/Tool/packaging/src_tarbz2.py +43 -0
  150. data/lib/libv8/scons/engine/SCons/Tool/packaging/src_targz.py +43 -0
  151. data/lib/libv8/scons/engine/SCons/Tool/packaging/src_zip.py +43 -0
  152. data/lib/libv8/scons/engine/SCons/Tool/packaging/tarbz2.py +44 -0
  153. data/lib/libv8/scons/engine/SCons/Tool/packaging/targz.py +44 -0
  154. data/lib/libv8/scons/engine/SCons/Tool/packaging/zip.py +44 -0
  155. data/lib/libv8/scons/engine/SCons/Tool/pdf.py +78 -0
  156. data/lib/libv8/scons/engine/SCons/Tool/pdflatex.py +83 -0
  157. data/lib/libv8/scons/engine/SCons/Tool/pdftex.py +108 -0
  158. data/lib/libv8/scons/engine/SCons/Tool/qt.py +336 -0
  159. data/lib/libv8/scons/engine/SCons/Tool/rmic.py +120 -0
  160. data/lib/libv8/scons/engine/SCons/Tool/rpcgen.py +70 -0
  161. data/lib/libv8/scons/engine/SCons/Tool/rpm.py +132 -0
  162. data/lib/libv8/scons/engine/SCons/Tool/sgiar.py +68 -0
  163. data/lib/libv8/scons/engine/SCons/Tool/sgic++.py +58 -0
  164. data/lib/libv8/scons/engine/SCons/Tool/sgicc.py +53 -0
  165. data/lib/libv8/scons/engine/SCons/Tool/sgilink.py +63 -0
  166. data/lib/libv8/scons/engine/SCons/Tool/sunar.py +67 -0
  167. data/lib/libv8/scons/engine/SCons/Tool/sunc++.py +142 -0
  168. data/lib/libv8/scons/engine/SCons/Tool/suncc.py +58 -0
  169. data/lib/libv8/scons/engine/SCons/Tool/sunf77.py +63 -0
  170. data/lib/libv8/scons/engine/SCons/Tool/sunf90.py +64 -0
  171. data/lib/libv8/scons/engine/SCons/Tool/sunf95.py +64 -0
  172. data/lib/libv8/scons/engine/SCons/Tool/sunlink.py +77 -0
  173. data/lib/libv8/scons/engine/SCons/Tool/swig.py +182 -0
  174. data/lib/libv8/scons/engine/SCons/Tool/tar.py +73 -0
  175. data/lib/libv8/scons/engine/SCons/Tool/tex.py +813 -0
  176. data/lib/libv8/scons/engine/SCons/Tool/textfile.py +175 -0
  177. data/lib/libv8/scons/engine/SCons/Tool/tlib.py +53 -0
  178. data/lib/libv8/scons/engine/SCons/Tool/wix.py +99 -0
  179. data/lib/libv8/scons/engine/SCons/Tool/yacc.py +130 -0
  180. data/lib/libv8/scons/engine/SCons/Tool/zip.py +99 -0
  181. data/lib/libv8/scons/engine/SCons/Util.py +1492 -0
  182. data/lib/libv8/scons/engine/SCons/Variables/BoolVariable.py +89 -0
  183. data/lib/libv8/scons/engine/SCons/Variables/EnumVariable.py +103 -0
  184. data/lib/libv8/scons/engine/SCons/Variables/ListVariable.py +135 -0
  185. data/lib/libv8/scons/engine/SCons/Variables/PackageVariable.py +106 -0
  186. data/lib/libv8/scons/engine/SCons/Variables/PathVariable.py +147 -0
  187. data/lib/libv8/scons/engine/SCons/Variables/__init__.py +312 -0
  188. data/lib/libv8/scons/engine/SCons/Warnings.py +246 -0
  189. data/lib/libv8/scons/engine/SCons/__init__.py +49 -0
  190. data/lib/libv8/scons/engine/SCons/compat/__init__.py +237 -0
  191. data/lib/libv8/scons/engine/SCons/compat/_scons_builtins.py +150 -0
  192. data/lib/libv8/scons/engine/SCons/compat/_scons_collections.py +45 -0
  193. data/lib/libv8/scons/engine/SCons/compat/_scons_dbm.py +45 -0
  194. data/lib/libv8/scons/engine/SCons/compat/_scons_hashlib.py +76 -0
  195. data/lib/libv8/scons/engine/SCons/compat/_scons_io.py +45 -0
  196. data/lib/libv8/scons/engine/SCons/compat/_scons_sets.py +563 -0
  197. data/lib/libv8/scons/engine/SCons/compat/_scons_subprocess.py +1281 -0
  198. data/lib/libv8/scons/engine/SCons/cpp.py +589 -0
  199. data/lib/libv8/scons/engine/SCons/dblite.py +251 -0
  200. data/lib/libv8/scons/engine/SCons/exitfuncs.py +77 -0
  201. data/lib/libv8/scons/os_spawnv_fix.diff +83 -0
  202. data/lib/libv8/scons/scons-time.1 +1017 -0
  203. data/lib/libv8/scons/scons.1 +15219 -0
  204. data/lib/libv8/scons/sconsign.1 +208 -0
  205. data/lib/libv8/scons/script/scons +196 -0
  206. data/lib/libv8/scons/script/scons-time +1544 -0
  207. data/lib/libv8/scons/script/scons.bat +31 -0
  208. data/lib/libv8/scons/script/sconsign +513 -0
  209. data/lib/libv8/scons/setup.cfg +6 -0
  210. data/lib/libv8/scons/setup.py +425 -0
  211. data/lib/libv8/v8/.gitignore +35 -0
  212. data/lib/libv8/v8/AUTHORS +44 -0
  213. data/lib/libv8/v8/ChangeLog +2839 -0
  214. data/lib/libv8/v8/LICENSE +52 -0
  215. data/lib/libv8/v8/LICENSE.strongtalk +29 -0
  216. data/lib/libv8/v8/LICENSE.v8 +26 -0
  217. data/lib/libv8/v8/LICENSE.valgrind +45 -0
  218. data/lib/libv8/v8/SConstruct +1478 -0
  219. data/lib/libv8/v8/build/README.txt +49 -0
  220. data/lib/libv8/v8/build/all.gyp +18 -0
  221. data/lib/libv8/v8/build/armu.gypi +32 -0
  222. data/lib/libv8/v8/build/common.gypi +144 -0
  223. data/lib/libv8/v8/build/gyp_v8 +145 -0
  224. data/lib/libv8/v8/include/v8-debug.h +395 -0
  225. data/lib/libv8/v8/include/v8-preparser.h +117 -0
  226. data/lib/libv8/v8/include/v8-profiler.h +505 -0
  227. data/lib/libv8/v8/include/v8-testing.h +104 -0
  228. data/lib/libv8/v8/include/v8.h +4124 -0
  229. data/lib/libv8/v8/include/v8stdint.h +53 -0
  230. data/lib/libv8/v8/preparser/SConscript +38 -0
  231. data/lib/libv8/v8/preparser/preparser-process.cc +379 -0
  232. data/lib/libv8/v8/src/SConscript +368 -0
  233. data/lib/libv8/v8/src/accessors.cc +767 -0
  234. data/lib/libv8/v8/src/accessors.h +123 -0
  235. data/lib/libv8/v8/src/allocation-inl.h +49 -0
  236. data/lib/libv8/v8/src/allocation.cc +122 -0
  237. data/lib/libv8/v8/src/allocation.h +143 -0
  238. data/lib/libv8/v8/src/api.cc +5845 -0
  239. data/lib/libv8/v8/src/api.h +574 -0
  240. data/lib/libv8/v8/src/apinatives.js +110 -0
  241. data/lib/libv8/v8/src/apiutils.h +73 -0
  242. data/lib/libv8/v8/src/arguments.h +118 -0
  243. data/lib/libv8/v8/src/arm/assembler-arm-inl.h +353 -0
  244. data/lib/libv8/v8/src/arm/assembler-arm.cc +2661 -0
  245. data/lib/libv8/v8/src/arm/assembler-arm.h +1375 -0
  246. data/lib/libv8/v8/src/arm/builtins-arm.cc +1658 -0
  247. data/lib/libv8/v8/src/arm/code-stubs-arm.cc +6398 -0
  248. data/lib/libv8/v8/src/arm/code-stubs-arm.h +673 -0
  249. data/lib/libv8/v8/src/arm/codegen-arm.cc +52 -0
  250. data/lib/libv8/v8/src/arm/codegen-arm.h +91 -0
  251. data/lib/libv8/v8/src/arm/constants-arm.cc +152 -0
  252. data/lib/libv8/v8/src/arm/constants-arm.h +775 -0
  253. data/lib/libv8/v8/src/arm/cpu-arm.cc +120 -0
  254. data/lib/libv8/v8/src/arm/debug-arm.cc +317 -0
  255. data/lib/libv8/v8/src/arm/deoptimizer-arm.cc +754 -0
  256. data/lib/libv8/v8/src/arm/disasm-arm.cc +1506 -0
  257. data/lib/libv8/v8/src/arm/frames-arm.cc +45 -0
  258. data/lib/libv8/v8/src/arm/frames-arm.h +168 -0
  259. data/lib/libv8/v8/src/arm/full-codegen-arm.cc +4375 -0
  260. data/lib/libv8/v8/src/arm/ic-arm.cc +1562 -0
  261. data/lib/libv8/v8/src/arm/lithium-arm.cc +2206 -0
  262. data/lib/libv8/v8/src/arm/lithium-arm.h +2348 -0
  263. data/lib/libv8/v8/src/arm/lithium-codegen-arm.cc +4526 -0
  264. data/lib/libv8/v8/src/arm/lithium-codegen-arm.h +403 -0
  265. data/lib/libv8/v8/src/arm/lithium-gap-resolver-arm.cc +305 -0
  266. data/lib/libv8/v8/src/arm/lithium-gap-resolver-arm.h +84 -0
  267. data/lib/libv8/v8/src/arm/macro-assembler-arm.cc +3163 -0
  268. data/lib/libv8/v8/src/arm/macro-assembler-arm.h +1126 -0
  269. data/lib/libv8/v8/src/arm/regexp-macro-assembler-arm.cc +1287 -0
  270. data/lib/libv8/v8/src/arm/regexp-macro-assembler-arm.h +253 -0
  271. data/lib/libv8/v8/src/arm/simulator-arm.cc +3424 -0
  272. data/lib/libv8/v8/src/arm/simulator-arm.h +431 -0
  273. data/lib/libv8/v8/src/arm/stub-cache-arm.cc +4243 -0
  274. data/lib/libv8/v8/src/array.js +1366 -0
  275. data/lib/libv8/v8/src/assembler.cc +1207 -0
  276. data/lib/libv8/v8/src/assembler.h +858 -0
  277. data/lib/libv8/v8/src/ast-inl.h +112 -0
  278. data/lib/libv8/v8/src/ast.cc +1146 -0
  279. data/lib/libv8/v8/src/ast.h +2188 -0
  280. data/lib/libv8/v8/src/atomicops.h +167 -0
  281. data/lib/libv8/v8/src/atomicops_internals_arm_gcc.h +145 -0
  282. data/lib/libv8/v8/src/atomicops_internals_mips_gcc.h +169 -0
  283. data/lib/libv8/v8/src/atomicops_internals_x86_gcc.cc +133 -0
  284. data/lib/libv8/v8/src/atomicops_internals_x86_gcc.h +287 -0
  285. data/lib/libv8/v8/src/atomicops_internals_x86_macosx.h +301 -0
  286. data/lib/libv8/v8/src/atomicops_internals_x86_msvc.h +203 -0
  287. data/lib/libv8/v8/src/bignum-dtoa.cc +655 -0
  288. data/lib/libv8/v8/src/bignum-dtoa.h +81 -0
  289. data/lib/libv8/v8/src/bignum.cc +768 -0
  290. data/lib/libv8/v8/src/bignum.h +140 -0
  291. data/lib/libv8/v8/src/bootstrapper.cc +2184 -0
  292. data/lib/libv8/v8/src/bootstrapper.h +188 -0
  293. data/lib/libv8/v8/src/builtins.cc +1707 -0
  294. data/lib/libv8/v8/src/builtins.h +371 -0
  295. data/lib/libv8/v8/src/bytecodes-irregexp.h +105 -0
  296. data/lib/libv8/v8/src/cached-powers.cc +177 -0
  297. data/lib/libv8/v8/src/cached-powers.h +65 -0
  298. data/lib/libv8/v8/src/char-predicates-inl.h +94 -0
  299. data/lib/libv8/v8/src/char-predicates.h +67 -0
  300. data/lib/libv8/v8/src/checks.cc +110 -0
  301. data/lib/libv8/v8/src/checks.h +296 -0
  302. data/lib/libv8/v8/src/circular-queue-inl.h +53 -0
  303. data/lib/libv8/v8/src/circular-queue.cc +122 -0
  304. data/lib/libv8/v8/src/circular-queue.h +103 -0
  305. data/lib/libv8/v8/src/code-stubs.cc +267 -0
  306. data/lib/libv8/v8/src/code-stubs.h +1011 -0
  307. data/lib/libv8/v8/src/code.h +70 -0
  308. data/lib/libv8/v8/src/codegen.cc +231 -0
  309. data/lib/libv8/v8/src/codegen.h +84 -0
  310. data/lib/libv8/v8/src/compilation-cache.cc +540 -0
  311. data/lib/libv8/v8/src/compilation-cache.h +287 -0
  312. data/lib/libv8/v8/src/compiler.cc +786 -0
  313. data/lib/libv8/v8/src/compiler.h +312 -0
  314. data/lib/libv8/v8/src/contexts.cc +347 -0
  315. data/lib/libv8/v8/src/contexts.h +391 -0
  316. data/lib/libv8/v8/src/conversions-inl.h +106 -0
  317. data/lib/libv8/v8/src/conversions.cc +1131 -0
  318. data/lib/libv8/v8/src/conversions.h +135 -0
  319. data/lib/libv8/v8/src/counters.cc +93 -0
  320. data/lib/libv8/v8/src/counters.h +254 -0
  321. data/lib/libv8/v8/src/cpu-profiler-inl.h +101 -0
  322. data/lib/libv8/v8/src/cpu-profiler.cc +609 -0
  323. data/lib/libv8/v8/src/cpu-profiler.h +302 -0
  324. data/lib/libv8/v8/src/cpu.h +69 -0
  325. data/lib/libv8/v8/src/d8-debug.cc +367 -0
  326. data/lib/libv8/v8/src/d8-debug.h +158 -0
  327. data/lib/libv8/v8/src/d8-posix.cc +695 -0
  328. data/lib/libv8/v8/src/d8-readline.cc +130 -0
  329. data/lib/libv8/v8/src/d8-windows.cc +42 -0
  330. data/lib/libv8/v8/src/d8.cc +803 -0
  331. data/lib/libv8/v8/src/d8.gyp +91 -0
  332. data/lib/libv8/v8/src/d8.h +235 -0
  333. data/lib/libv8/v8/src/d8.js +2798 -0
  334. data/lib/libv8/v8/src/data-flow.cc +66 -0
  335. data/lib/libv8/v8/src/data-flow.h +205 -0
  336. data/lib/libv8/v8/src/date.js +1103 -0
  337. data/lib/libv8/v8/src/dateparser-inl.h +127 -0
  338. data/lib/libv8/v8/src/dateparser.cc +178 -0
  339. data/lib/libv8/v8/src/dateparser.h +266 -0
  340. data/lib/libv8/v8/src/debug-agent.cc +447 -0
  341. data/lib/libv8/v8/src/debug-agent.h +129 -0
  342. data/lib/libv8/v8/src/debug-debugger.js +2569 -0
  343. data/lib/libv8/v8/src/debug.cc +3165 -0
  344. data/lib/libv8/v8/src/debug.h +1057 -0
  345. data/lib/libv8/v8/src/deoptimizer.cc +1256 -0
  346. data/lib/libv8/v8/src/deoptimizer.h +602 -0
  347. data/lib/libv8/v8/src/disasm.h +80 -0
  348. data/lib/libv8/v8/src/disassembler.cc +343 -0
  349. data/lib/libv8/v8/src/disassembler.h +58 -0
  350. data/lib/libv8/v8/src/diy-fp.cc +58 -0
  351. data/lib/libv8/v8/src/diy-fp.h +117 -0
  352. data/lib/libv8/v8/src/double.h +238 -0
  353. data/lib/libv8/v8/src/dtoa.cc +103 -0
  354. data/lib/libv8/v8/src/dtoa.h +85 -0
  355. data/lib/libv8/v8/src/execution.cc +849 -0
  356. data/lib/libv8/v8/src/execution.h +297 -0
  357. data/lib/libv8/v8/src/extensions/experimental/break-iterator.cc +250 -0
  358. data/lib/libv8/v8/src/extensions/experimental/break-iterator.h +89 -0
  359. data/lib/libv8/v8/src/extensions/experimental/collator.cc +218 -0
  360. data/lib/libv8/v8/src/extensions/experimental/collator.h +69 -0
  361. data/lib/libv8/v8/src/extensions/experimental/experimental.gyp +94 -0
  362. data/lib/libv8/v8/src/extensions/experimental/i18n-extension.cc +78 -0
  363. data/lib/libv8/v8/src/extensions/experimental/i18n-extension.h +54 -0
  364. data/lib/libv8/v8/src/extensions/experimental/i18n-locale.cc +112 -0
  365. data/lib/libv8/v8/src/extensions/experimental/i18n-locale.h +60 -0
  366. data/lib/libv8/v8/src/extensions/experimental/i18n-utils.cc +43 -0
  367. data/lib/libv8/v8/src/extensions/experimental/i18n-utils.h +49 -0
  368. data/lib/libv8/v8/src/extensions/experimental/i18n.js +180 -0
  369. data/lib/libv8/v8/src/extensions/experimental/language-matcher.cc +251 -0
  370. data/lib/libv8/v8/src/extensions/experimental/language-matcher.h +95 -0
  371. data/lib/libv8/v8/src/extensions/externalize-string-extension.cc +141 -0
  372. data/lib/libv8/v8/src/extensions/externalize-string-extension.h +50 -0
  373. data/lib/libv8/v8/src/extensions/gc-extension.cc +58 -0
  374. data/lib/libv8/v8/src/extensions/gc-extension.h +49 -0
  375. data/lib/libv8/v8/src/factory.cc +1222 -0
  376. data/lib/libv8/v8/src/factory.h +442 -0
  377. data/lib/libv8/v8/src/fast-dtoa.cc +736 -0
  378. data/lib/libv8/v8/src/fast-dtoa.h +83 -0
  379. data/lib/libv8/v8/src/fixed-dtoa.cc +405 -0
  380. data/lib/libv8/v8/src/fixed-dtoa.h +55 -0
  381. data/lib/libv8/v8/src/flag-definitions.h +560 -0
  382. data/lib/libv8/v8/src/flags.cc +551 -0
  383. data/lib/libv8/v8/src/flags.h +79 -0
  384. data/lib/libv8/v8/src/frames-inl.h +247 -0
  385. data/lib/libv8/v8/src/frames.cc +1243 -0
  386. data/lib/libv8/v8/src/frames.h +870 -0
  387. data/lib/libv8/v8/src/full-codegen.cc +1374 -0
  388. data/lib/libv8/v8/src/full-codegen.h +771 -0
  389. data/lib/libv8/v8/src/func-name-inferrer.cc +92 -0
  390. data/lib/libv8/v8/src/func-name-inferrer.h +111 -0
  391. data/lib/libv8/v8/src/gdb-jit.cc +1555 -0
  392. data/lib/libv8/v8/src/gdb-jit.h +143 -0
  393. data/lib/libv8/v8/src/global-handles.cc +665 -0
  394. data/lib/libv8/v8/src/global-handles.h +284 -0
  395. data/lib/libv8/v8/src/globals.h +325 -0
  396. data/lib/libv8/v8/src/handles-inl.h +177 -0
  397. data/lib/libv8/v8/src/handles.cc +987 -0
  398. data/lib/libv8/v8/src/handles.h +382 -0
  399. data/lib/libv8/v8/src/hashmap.cc +230 -0
  400. data/lib/libv8/v8/src/hashmap.h +123 -0
  401. data/lib/libv8/v8/src/heap-inl.h +704 -0
  402. data/lib/libv8/v8/src/heap-profiler.cc +1173 -0
  403. data/lib/libv8/v8/src/heap-profiler.h +397 -0
  404. data/lib/libv8/v8/src/heap.cc +5930 -0
  405. data/lib/libv8/v8/src/heap.h +2268 -0
  406. data/lib/libv8/v8/src/hydrogen-instructions.cc +1769 -0
  407. data/lib/libv8/v8/src/hydrogen-instructions.h +3971 -0
  408. data/lib/libv8/v8/src/hydrogen.cc +6239 -0
  409. data/lib/libv8/v8/src/hydrogen.h +1202 -0
  410. data/lib/libv8/v8/src/ia32/assembler-ia32-inl.h +446 -0
  411. data/lib/libv8/v8/src/ia32/assembler-ia32.cc +2487 -0
  412. data/lib/libv8/v8/src/ia32/assembler-ia32.h +1144 -0
  413. data/lib/libv8/v8/src/ia32/builtins-ia32.cc +1621 -0
  414. data/lib/libv8/v8/src/ia32/code-stubs-ia32.cc +6198 -0
  415. data/lib/libv8/v8/src/ia32/code-stubs-ia32.h +517 -0
  416. data/lib/libv8/v8/src/ia32/codegen-ia32.cc +265 -0
  417. data/lib/libv8/v8/src/ia32/codegen-ia32.h +79 -0
  418. data/lib/libv8/v8/src/ia32/cpu-ia32.cc +88 -0
  419. data/lib/libv8/v8/src/ia32/debug-ia32.cc +312 -0
  420. data/lib/libv8/v8/src/ia32/deoptimizer-ia32.cc +774 -0
  421. data/lib/libv8/v8/src/ia32/disasm-ia32.cc +1628 -0
  422. data/lib/libv8/v8/src/ia32/frames-ia32.cc +45 -0
  423. data/lib/libv8/v8/src/ia32/frames-ia32.h +142 -0
  424. data/lib/libv8/v8/src/ia32/full-codegen-ia32.cc +4338 -0
  425. data/lib/libv8/v8/src/ia32/ic-ia32.cc +1597 -0
  426. data/lib/libv8/v8/src/ia32/lithium-codegen-ia32.cc +4461 -0
  427. data/lib/libv8/v8/src/ia32/lithium-codegen-ia32.h +375 -0
  428. data/lib/libv8/v8/src/ia32/lithium-gap-resolver-ia32.cc +475 -0
  429. data/lib/libv8/v8/src/ia32/lithium-gap-resolver-ia32.h +110 -0
  430. data/lib/libv8/v8/src/ia32/lithium-ia32.cc +2261 -0
  431. data/lib/libv8/v8/src/ia32/lithium-ia32.h +2396 -0
  432. data/lib/libv8/v8/src/ia32/macro-assembler-ia32.cc +2136 -0
  433. data/lib/libv8/v8/src/ia32/macro-assembler-ia32.h +775 -0
  434. data/lib/libv8/v8/src/ia32/regexp-macro-assembler-ia32.cc +1263 -0
  435. data/lib/libv8/v8/src/ia32/regexp-macro-assembler-ia32.h +216 -0
  436. data/lib/libv8/v8/src/ia32/simulator-ia32.cc +30 -0
  437. data/lib/libv8/v8/src/ia32/simulator-ia32.h +74 -0
  438. data/lib/libv8/v8/src/ia32/stub-cache-ia32.cc +3847 -0
  439. data/lib/libv8/v8/src/ic-inl.h +130 -0
  440. data/lib/libv8/v8/src/ic.cc +2577 -0
  441. data/lib/libv8/v8/src/ic.h +736 -0
  442. data/lib/libv8/v8/src/inspector.cc +63 -0
  443. data/lib/libv8/v8/src/inspector.h +62 -0
  444. data/lib/libv8/v8/src/interpreter-irregexp.cc +659 -0
  445. data/lib/libv8/v8/src/interpreter-irregexp.h +49 -0
  446. data/lib/libv8/v8/src/isolate-inl.h +50 -0
  447. data/lib/libv8/v8/src/isolate.cc +1869 -0
  448. data/lib/libv8/v8/src/isolate.h +1382 -0
  449. data/lib/libv8/v8/src/json-parser.cc +504 -0
  450. data/lib/libv8/v8/src/json-parser.h +161 -0
  451. data/lib/libv8/v8/src/json.js +342 -0
  452. data/lib/libv8/v8/src/jsregexp.cc +5385 -0
  453. data/lib/libv8/v8/src/jsregexp.h +1492 -0
  454. data/lib/libv8/v8/src/list-inl.h +212 -0
  455. data/lib/libv8/v8/src/list.h +174 -0
  456. data/lib/libv8/v8/src/lithium-allocator-inl.h +142 -0
  457. data/lib/libv8/v8/src/lithium-allocator.cc +2123 -0
  458. data/lib/libv8/v8/src/lithium-allocator.h +630 -0
  459. data/lib/libv8/v8/src/lithium.cc +190 -0
  460. data/lib/libv8/v8/src/lithium.h +597 -0
  461. data/lib/libv8/v8/src/liveedit-debugger.js +1082 -0
  462. data/lib/libv8/v8/src/liveedit.cc +1691 -0
  463. data/lib/libv8/v8/src/liveedit.h +180 -0
  464. data/lib/libv8/v8/src/liveobjectlist-inl.h +126 -0
  465. data/lib/libv8/v8/src/liveobjectlist.cc +2589 -0
  466. data/lib/libv8/v8/src/liveobjectlist.h +322 -0
  467. data/lib/libv8/v8/src/log-inl.h +59 -0
  468. data/lib/libv8/v8/src/log-utils.cc +428 -0
  469. data/lib/libv8/v8/src/log-utils.h +231 -0
  470. data/lib/libv8/v8/src/log.cc +1993 -0
  471. data/lib/libv8/v8/src/log.h +476 -0
  472. data/lib/libv8/v8/src/macro-assembler.h +120 -0
  473. data/lib/libv8/v8/src/macros.py +178 -0
  474. data/lib/libv8/v8/src/mark-compact.cc +3143 -0
  475. data/lib/libv8/v8/src/mark-compact.h +506 -0
  476. data/lib/libv8/v8/src/math.js +264 -0
  477. data/lib/libv8/v8/src/messages.cc +179 -0
  478. data/lib/libv8/v8/src/messages.h +113 -0
  479. data/lib/libv8/v8/src/messages.js +1096 -0
  480. data/lib/libv8/v8/src/mips/assembler-mips-inl.h +312 -0
  481. data/lib/libv8/v8/src/mips/assembler-mips.cc +1960 -0
  482. data/lib/libv8/v8/src/mips/assembler-mips.h +1138 -0
  483. data/lib/libv8/v8/src/mips/builtins-mips.cc +1628 -0
  484. data/lib/libv8/v8/src/mips/code-stubs-mips.cc +6656 -0
  485. data/lib/libv8/v8/src/mips/code-stubs-mips.h +682 -0
  486. data/lib/libv8/v8/src/mips/codegen-mips.cc +52 -0
  487. data/lib/libv8/v8/src/mips/codegen-mips.h +98 -0
  488. data/lib/libv8/v8/src/mips/constants-mips.cc +352 -0
  489. data/lib/libv8/v8/src/mips/constants-mips.h +739 -0
  490. data/lib/libv8/v8/src/mips/cpu-mips.cc +96 -0
  491. data/lib/libv8/v8/src/mips/debug-mips.cc +308 -0
  492. data/lib/libv8/v8/src/mips/deoptimizer-mips.cc +91 -0
  493. data/lib/libv8/v8/src/mips/disasm-mips.cc +1050 -0
  494. data/lib/libv8/v8/src/mips/frames-mips.cc +47 -0
  495. data/lib/libv8/v8/src/mips/frames-mips.h +219 -0
  496. data/lib/libv8/v8/src/mips/full-codegen-mips.cc +4388 -0
  497. data/lib/libv8/v8/src/mips/ic-mips.cc +1580 -0
  498. data/lib/libv8/v8/src/mips/lithium-codegen-mips.h +65 -0
  499. data/lib/libv8/v8/src/mips/lithium-mips.h +307 -0
  500. data/lib/libv8/v8/src/mips/macro-assembler-mips.cc +4056 -0
  501. data/lib/libv8/v8/src/mips/macro-assembler-mips.h +1214 -0
  502. data/lib/libv8/v8/src/mips/regexp-macro-assembler-mips.cc +1251 -0
  503. data/lib/libv8/v8/src/mips/regexp-macro-assembler-mips.h +252 -0
  504. data/lib/libv8/v8/src/mips/simulator-mips.cc +2621 -0
  505. data/lib/libv8/v8/src/mips/simulator-mips.h +401 -0
  506. data/lib/libv8/v8/src/mips/stub-cache-mips.cc +4285 -0
  507. data/lib/libv8/v8/src/mirror-debugger.js +2382 -0
  508. data/lib/libv8/v8/src/mksnapshot.cc +328 -0
  509. data/lib/libv8/v8/src/natives.h +64 -0
  510. data/lib/libv8/v8/src/objects-debug.cc +738 -0
  511. data/lib/libv8/v8/src/objects-inl.h +4323 -0
  512. data/lib/libv8/v8/src/objects-printer.cc +829 -0
  513. data/lib/libv8/v8/src/objects-visiting.cc +148 -0
  514. data/lib/libv8/v8/src/objects-visiting.h +424 -0
  515. data/lib/libv8/v8/src/objects.cc +10585 -0
  516. data/lib/libv8/v8/src/objects.h +6838 -0
  517. data/lib/libv8/v8/src/parser.cc +4997 -0
  518. data/lib/libv8/v8/src/parser.h +765 -0
  519. data/lib/libv8/v8/src/platform-cygwin.cc +779 -0
  520. data/lib/libv8/v8/src/platform-freebsd.cc +826 -0
  521. data/lib/libv8/v8/src/platform-linux.cc +1149 -0
  522. data/lib/libv8/v8/src/platform-macos.cc +830 -0
  523. data/lib/libv8/v8/src/platform-nullos.cc +479 -0
  524. data/lib/libv8/v8/src/platform-openbsd.cc +640 -0
  525. data/lib/libv8/v8/src/platform-posix.cc +424 -0
  526. data/lib/libv8/v8/src/platform-solaris.cc +762 -0
  527. data/lib/libv8/v8/src/platform-tls-mac.h +62 -0
  528. data/lib/libv8/v8/src/platform-tls-win32.h +62 -0
  529. data/lib/libv8/v8/src/platform-tls.h +50 -0
  530. data/lib/libv8/v8/src/platform-win32.cc +2021 -0
  531. data/lib/libv8/v8/src/platform.h +667 -0
  532. data/lib/libv8/v8/src/preparse-data-format.h +62 -0
  533. data/lib/libv8/v8/src/preparse-data.cc +183 -0
  534. data/lib/libv8/v8/src/preparse-data.h +225 -0
  535. data/lib/libv8/v8/src/preparser-api.cc +220 -0
  536. data/lib/libv8/v8/src/preparser.cc +1450 -0
  537. data/lib/libv8/v8/src/preparser.h +493 -0
  538. data/lib/libv8/v8/src/prettyprinter.cc +1493 -0
  539. data/lib/libv8/v8/src/prettyprinter.h +223 -0
  540. data/lib/libv8/v8/src/profile-generator-inl.h +128 -0
  541. data/lib/libv8/v8/src/profile-generator.cc +3098 -0
  542. data/lib/libv8/v8/src/profile-generator.h +1126 -0
  543. data/lib/libv8/v8/src/property.cc +105 -0
  544. data/lib/libv8/v8/src/property.h +365 -0
  545. data/lib/libv8/v8/src/proxy.js +83 -0
  546. data/lib/libv8/v8/src/regexp-macro-assembler-irregexp-inl.h +78 -0
  547. data/lib/libv8/v8/src/regexp-macro-assembler-irregexp.cc +471 -0
  548. data/lib/libv8/v8/src/regexp-macro-assembler-irregexp.h +142 -0
  549. data/lib/libv8/v8/src/regexp-macro-assembler-tracer.cc +373 -0
  550. data/lib/libv8/v8/src/regexp-macro-assembler-tracer.h +104 -0
  551. data/lib/libv8/v8/src/regexp-macro-assembler.cc +267 -0
  552. data/lib/libv8/v8/src/regexp-macro-assembler.h +243 -0
  553. data/lib/libv8/v8/src/regexp-stack.cc +111 -0
  554. data/lib/libv8/v8/src/regexp-stack.h +147 -0
  555. data/lib/libv8/v8/src/regexp.js +483 -0
  556. data/lib/libv8/v8/src/rewriter.cc +360 -0
  557. data/lib/libv8/v8/src/rewriter.h +50 -0
  558. data/lib/libv8/v8/src/runtime-profiler.cc +489 -0
  559. data/lib/libv8/v8/src/runtime-profiler.h +201 -0
  560. data/lib/libv8/v8/src/runtime.cc +12227 -0
  561. data/lib/libv8/v8/src/runtime.h +652 -0
  562. data/lib/libv8/v8/src/runtime.js +649 -0
  563. data/lib/libv8/v8/src/safepoint-table.cc +256 -0
  564. data/lib/libv8/v8/src/safepoint-table.h +270 -0
  565. data/lib/libv8/v8/src/scanner-base.cc +952 -0
  566. data/lib/libv8/v8/src/scanner-base.h +670 -0
  567. data/lib/libv8/v8/src/scanner.cc +345 -0
  568. data/lib/libv8/v8/src/scanner.h +146 -0
  569. data/lib/libv8/v8/src/scopeinfo.cc +646 -0
  570. data/lib/libv8/v8/src/scopeinfo.h +254 -0
  571. data/lib/libv8/v8/src/scopes.cc +1150 -0
  572. data/lib/libv8/v8/src/scopes.h +507 -0
  573. data/lib/libv8/v8/src/serialize.cc +1574 -0
  574. data/lib/libv8/v8/src/serialize.h +589 -0
  575. data/lib/libv8/v8/src/shell.h +55 -0
  576. data/lib/libv8/v8/src/simulator.h +43 -0
  577. data/lib/libv8/v8/src/small-pointer-list.h +163 -0
  578. data/lib/libv8/v8/src/smart-pointer.h +109 -0
  579. data/lib/libv8/v8/src/snapshot-common.cc +83 -0
  580. data/lib/libv8/v8/src/snapshot-empty.cc +54 -0
  581. data/lib/libv8/v8/src/snapshot.h +91 -0
  582. data/lib/libv8/v8/src/spaces-inl.h +529 -0
  583. data/lib/libv8/v8/src/spaces.cc +3145 -0
  584. data/lib/libv8/v8/src/spaces.h +2369 -0
  585. data/lib/libv8/v8/src/splay-tree-inl.h +310 -0
  586. data/lib/libv8/v8/src/splay-tree.h +205 -0
  587. data/lib/libv8/v8/src/string-search.cc +41 -0
  588. data/lib/libv8/v8/src/string-search.h +568 -0
  589. data/lib/libv8/v8/src/string-stream.cc +592 -0
  590. data/lib/libv8/v8/src/string-stream.h +191 -0
  591. data/lib/libv8/v8/src/string.js +994 -0
  592. data/lib/libv8/v8/src/strtod.cc +440 -0
  593. data/lib/libv8/v8/src/strtod.h +40 -0
  594. data/lib/libv8/v8/src/stub-cache.cc +1965 -0
  595. data/lib/libv8/v8/src/stub-cache.h +924 -0
  596. data/lib/libv8/v8/src/third_party/valgrind/valgrind.h +3925 -0
  597. data/lib/libv8/v8/src/token.cc +63 -0
  598. data/lib/libv8/v8/src/token.h +288 -0
  599. data/lib/libv8/v8/src/type-info.cc +507 -0
  600. data/lib/libv8/v8/src/type-info.h +272 -0
  601. data/lib/libv8/v8/src/unbound-queue-inl.h +95 -0
  602. data/lib/libv8/v8/src/unbound-queue.h +69 -0
  603. data/lib/libv8/v8/src/unicode-inl.h +238 -0
  604. data/lib/libv8/v8/src/unicode.cc +1624 -0
  605. data/lib/libv8/v8/src/unicode.h +280 -0
  606. data/lib/libv8/v8/src/uri.js +408 -0
  607. data/lib/libv8/v8/src/utils-inl.h +48 -0
  608. data/lib/libv8/v8/src/utils.cc +371 -0
  609. data/lib/libv8/v8/src/utils.h +800 -0
  610. data/lib/libv8/v8/src/v8-counters.cc +62 -0
  611. data/lib/libv8/v8/src/v8-counters.h +314 -0
  612. data/lib/libv8/v8/src/v8.cc +213 -0
  613. data/lib/libv8/v8/src/v8.h +131 -0
  614. data/lib/libv8/v8/src/v8checks.h +64 -0
  615. data/lib/libv8/v8/src/v8dll-main.cc +44 -0
  616. data/lib/libv8/v8/src/v8globals.h +512 -0
  617. data/lib/libv8/v8/src/v8memory.h +82 -0
  618. data/lib/libv8/v8/src/v8natives.js +1310 -0
  619. data/lib/libv8/v8/src/v8preparserdll-main.cc +39 -0
  620. data/lib/libv8/v8/src/v8threads.cc +464 -0
  621. data/lib/libv8/v8/src/v8threads.h +165 -0
  622. data/lib/libv8/v8/src/v8utils.h +319 -0
  623. data/lib/libv8/v8/src/variables.cc +114 -0
  624. data/lib/libv8/v8/src/variables.h +167 -0
  625. data/lib/libv8/v8/src/version.cc +116 -0
  626. data/lib/libv8/v8/src/version.h +68 -0
  627. data/lib/libv8/v8/src/vm-state-inl.h +138 -0
  628. data/lib/libv8/v8/src/vm-state.h +71 -0
  629. data/lib/libv8/v8/src/win32-headers.h +96 -0
  630. data/lib/libv8/v8/src/x64/assembler-x64-inl.h +462 -0
  631. data/lib/libv8/v8/src/x64/assembler-x64.cc +3027 -0
  632. data/lib/libv8/v8/src/x64/assembler-x64.h +1633 -0
  633. data/lib/libv8/v8/src/x64/builtins-x64.cc +1520 -0
  634. data/lib/libv8/v8/src/x64/code-stubs-x64.cc +5132 -0
  635. data/lib/libv8/v8/src/x64/code-stubs-x64.h +514 -0
  636. data/lib/libv8/v8/src/x64/codegen-x64.cc +146 -0
  637. data/lib/libv8/v8/src/x64/codegen-x64.h +76 -0
  638. data/lib/libv8/v8/src/x64/cpu-x64.cc +88 -0
  639. data/lib/libv8/v8/src/x64/debug-x64.cc +319 -0
  640. data/lib/libv8/v8/src/x64/deoptimizer-x64.cc +815 -0
  641. data/lib/libv8/v8/src/x64/disasm-x64.cc +1832 -0
  642. data/lib/libv8/v8/src/x64/frames-x64.cc +45 -0
  643. data/lib/libv8/v8/src/x64/frames-x64.h +130 -0
  644. data/lib/libv8/v8/src/x64/full-codegen-x64.cc +4318 -0
  645. data/lib/libv8/v8/src/x64/ic-x64.cc +1608 -0
  646. data/lib/libv8/v8/src/x64/lithium-codegen-x64.cc +4267 -0
  647. data/lib/libv8/v8/src/x64/lithium-codegen-x64.h +367 -0
  648. data/lib/libv8/v8/src/x64/lithium-gap-resolver-x64.cc +320 -0
  649. data/lib/libv8/v8/src/x64/lithium-gap-resolver-x64.h +74 -0
  650. data/lib/libv8/v8/src/x64/lithium-x64.cc +2202 -0
  651. data/lib/libv8/v8/src/x64/lithium-x64.h +2333 -0
  652. data/lib/libv8/v8/src/x64/macro-assembler-x64.cc +3745 -0
  653. data/lib/libv8/v8/src/x64/macro-assembler-x64.h +1290 -0
  654. data/lib/libv8/v8/src/x64/regexp-macro-assembler-x64.cc +1398 -0
  655. data/lib/libv8/v8/src/x64/regexp-macro-assembler-x64.h +282 -0
  656. data/lib/libv8/v8/src/x64/simulator-x64.cc +27 -0
  657. data/lib/libv8/v8/src/x64/simulator-x64.h +72 -0
  658. data/lib/libv8/v8/src/x64/stub-cache-x64.cc +3610 -0
  659. data/lib/libv8/v8/src/zone-inl.h +140 -0
  660. data/lib/libv8/v8/src/zone.cc +196 -0
  661. data/lib/libv8/v8/src/zone.h +240 -0
  662. data/lib/libv8/v8/tools/codemap.js +265 -0
  663. data/lib/libv8/v8/tools/consarray.js +93 -0
  664. data/lib/libv8/v8/tools/csvparser.js +78 -0
  665. data/lib/libv8/v8/tools/disasm.py +92 -0
  666. data/lib/libv8/v8/tools/freebsd-tick-processor +10 -0
  667. data/lib/libv8/v8/tools/gc-nvp-trace-processor.py +342 -0
  668. data/lib/libv8/v8/tools/gcmole/README +62 -0
  669. data/lib/libv8/v8/tools/gcmole/gccause.lua +60 -0
  670. data/lib/libv8/v8/tools/gcmole/gcmole.cc +1261 -0
  671. data/lib/libv8/v8/tools/gcmole/gcmole.lua +378 -0
  672. data/lib/libv8/v8/tools/generate-ten-powers.scm +286 -0
  673. data/lib/libv8/v8/tools/grokdump.py +841 -0
  674. data/lib/libv8/v8/tools/gyp/v8.gyp +995 -0
  675. data/lib/libv8/v8/tools/js2c.py +364 -0
  676. data/lib/libv8/v8/tools/jsmin.py +280 -0
  677. data/lib/libv8/v8/tools/linux-tick-processor +35 -0
  678. data/lib/libv8/v8/tools/ll_prof.py +942 -0
  679. data/lib/libv8/v8/tools/logreader.js +185 -0
  680. data/lib/libv8/v8/tools/mac-nm +18 -0
  681. data/lib/libv8/v8/tools/mac-tick-processor +6 -0
  682. data/lib/libv8/v8/tools/oom_dump/README +31 -0
  683. data/lib/libv8/v8/tools/oom_dump/SConstruct +42 -0
  684. data/lib/libv8/v8/tools/oom_dump/oom_dump.cc +288 -0
  685. data/lib/libv8/v8/tools/presubmit.py +305 -0
  686. data/lib/libv8/v8/tools/process-heap-prof.py +120 -0
  687. data/lib/libv8/v8/tools/profile.js +751 -0
  688. data/lib/libv8/v8/tools/profile_view.js +219 -0
  689. data/lib/libv8/v8/tools/run-valgrind.py +77 -0
  690. data/lib/libv8/v8/tools/splaytree.js +316 -0
  691. data/lib/libv8/v8/tools/stats-viewer.py +468 -0
  692. data/lib/libv8/v8/tools/test.py +1510 -0
  693. data/lib/libv8/v8/tools/tickprocessor-driver.js +59 -0
  694. data/lib/libv8/v8/tools/tickprocessor.js +877 -0
  695. data/lib/libv8/v8/tools/utils.py +96 -0
  696. data/lib/libv8/v8/tools/visual_studio/README.txt +12 -0
  697. data/lib/libv8/v8/tools/windows-tick-processor.bat +30 -0
  698. data/lib/libv8/version.rb +4 -0
  699. data/libv8.gemspec +31 -0
  700. metadata +800 -0
@@ -0,0 +1,140 @@
1
+ // Copyright 2010 the V8 project authors. All rights reserved.
2
+ // Redistribution and use in source and binary forms, with or without
3
+ // modification, are permitted provided that the following conditions are
4
+ // met:
5
+ //
6
+ // * Redistributions of source code must retain the above copyright
7
+ // notice, this list of conditions and the following disclaimer.
8
+ // * Redistributions in binary form must reproduce the above
9
+ // copyright notice, this list of conditions and the following
10
+ // disclaimer in the documentation and/or other materials provided
11
+ // with the distribution.
12
+ // * Neither the name of Google Inc. nor the names of its
13
+ // contributors may be used to endorse or promote products derived
14
+ // from this software without specific prior written permission.
15
+ //
16
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+
28
+ #ifndef V8_BIGNUM_H_
29
+ #define V8_BIGNUM_H_
30
+
31
+ namespace v8 {
32
+ namespace internal {
33
+
34
+ class Bignum {
35
+ public:
36
+ // 3584 = 128 * 28. We can represent 2^3584 > 10^1000 accurately.
37
+ // This bignum can encode much bigger numbers, since it contains an
38
+ // exponent.
39
+ static const int kMaxSignificantBits = 3584;
40
+
41
+ Bignum();
42
+ void AssignUInt16(uint16_t value);
43
+ void AssignUInt64(uint64_t value);
44
+ void AssignBignum(const Bignum& other);
45
+
46
+ void AssignDecimalString(Vector<const char> value);
47
+ void AssignHexString(Vector<const char> value);
48
+
49
+ void AssignPowerUInt16(uint16_t base, int exponent);
50
+
51
+ void AddUInt16(uint16_t operand);
52
+ void AddUInt64(uint64_t operand);
53
+ void AddBignum(const Bignum& other);
54
+ // Precondition: this >= other.
55
+ void SubtractBignum(const Bignum& other);
56
+
57
+ void Square();
58
+ void ShiftLeft(int shift_amount);
59
+ void MultiplyByUInt32(uint32_t factor);
60
+ void MultiplyByUInt64(uint64_t factor);
61
+ void MultiplyByPowerOfTen(int exponent);
62
+ void Times10() { return MultiplyByUInt32(10); }
63
+ // Pseudocode:
64
+ // int result = this / other;
65
+ // this = this % other;
66
+ // In the worst case this function is in O(this/other).
67
+ uint16_t DivideModuloIntBignum(const Bignum& other);
68
+
69
+ bool ToHexString(char* buffer, int buffer_size) const;
70
+
71
+ static int Compare(const Bignum& a, const Bignum& b);
72
+ static bool Equal(const Bignum& a, const Bignum& b) {
73
+ return Compare(a, b) == 0;
74
+ }
75
+ static bool LessEqual(const Bignum& a, const Bignum& b) {
76
+ return Compare(a, b) <= 0;
77
+ }
78
+ static bool Less(const Bignum& a, const Bignum& b) {
79
+ return Compare(a, b) < 0;
80
+ }
81
+ // Returns Compare(a + b, c);
82
+ static int PlusCompare(const Bignum& a, const Bignum& b, const Bignum& c);
83
+ // Returns a + b == c
84
+ static bool PlusEqual(const Bignum& a, const Bignum& b, const Bignum& c) {
85
+ return PlusCompare(a, b, c) == 0;
86
+ }
87
+ // Returns a + b <= c
88
+ static bool PlusLessEqual(const Bignum& a, const Bignum& b, const Bignum& c) {
89
+ return PlusCompare(a, b, c) <= 0;
90
+ }
91
+ // Returns a + b < c
92
+ static bool PlusLess(const Bignum& a, const Bignum& b, const Bignum& c) {
93
+ return PlusCompare(a, b, c) < 0;
94
+ }
95
+ private:
96
+ typedef uint32_t Chunk;
97
+ typedef uint64_t DoubleChunk;
98
+
99
+ static const int kChunkSize = sizeof(Chunk) * 8;
100
+ static const int kDoubleChunkSize = sizeof(DoubleChunk) * 8;
101
+ // With bigit size of 28 we loose some bits, but a double still fits easily
102
+ // into two chunks, and more importantly we can use the Comba multiplication.
103
+ static const int kBigitSize = 28;
104
+ static const Chunk kBigitMask = (1 << kBigitSize) - 1;
105
+ // Every instance allocates kBigitLength chunks on the stack. Bignums cannot
106
+ // grow. There are no checks if the stack-allocated space is sufficient.
107
+ static const int kBigitCapacity = kMaxSignificantBits / kBigitSize;
108
+
109
+ void EnsureCapacity(int size) {
110
+ if (size > kBigitCapacity) {
111
+ UNREACHABLE();
112
+ }
113
+ }
114
+ void Align(const Bignum& other);
115
+ void Clamp();
116
+ bool IsClamped() const;
117
+ void Zero();
118
+ // Requires this to have enough capacity (no tests done).
119
+ // Updates used_digits_ if necessary.
120
+ // by must be < kBigitSize.
121
+ void BigitsShiftLeft(int shift_amount);
122
+ // BigitLength includes the "hidden" digits encoded in the exponent.
123
+ int BigitLength() const { return used_digits_ + exponent_; }
124
+ Chunk BigitAt(int index) const;
125
+ void SubtractTimes(const Bignum& other, int factor);
126
+
127
+ Chunk bigits_buffer_[kBigitCapacity];
128
+ // A vector backed by bigits_buffer_. This way accesses to the array are
129
+ // checked for out-of-bounds errors.
130
+ Vector<Chunk> bigits_;
131
+ int used_digits_;
132
+ // The Bignum's value equals value(bigits_) * 2^(exponent_ * kBigitSize).
133
+ int exponent_;
134
+
135
+ DISALLOW_COPY_AND_ASSIGN(Bignum);
136
+ };
137
+
138
+ } } // namespace v8::internal
139
+
140
+ #endif // V8_BIGNUM_H_
@@ -0,0 +1,2184 @@
1
+ // Copyright 2011 the V8 project authors. All rights reserved.
2
+ // Redistribution and use in source and binary forms, with or without
3
+ // modification, are permitted provided that the following conditions are
4
+ // met:
5
+ //
6
+ // * Redistributions of source code must retain the above copyright
7
+ // notice, this list of conditions and the following disclaimer.
8
+ // * Redistributions in binary form must reproduce the above
9
+ // copyright notice, this list of conditions and the following
10
+ // disclaimer in the documentation and/or other materials provided
11
+ // with the distribution.
12
+ // * Neither the name of Google Inc. nor the names of its
13
+ // contributors may be used to endorse or promote products derived
14
+ // from this software without specific prior written permission.
15
+ //
16
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+
28
+ #include "v8.h"
29
+
30
+ #include "accessors.h"
31
+ #include "api.h"
32
+ #include "bootstrapper.h"
33
+ #include "compiler.h"
34
+ #include "debug.h"
35
+ #include "execution.h"
36
+ #include "global-handles.h"
37
+ #include "macro-assembler.h"
38
+ #include "natives.h"
39
+ #include "objects-visiting.h"
40
+ #include "snapshot.h"
41
+ #include "extensions/externalize-string-extension.h"
42
+ #include "extensions/gc-extension.h"
43
+
44
+ namespace v8 {
45
+ namespace internal {
46
+
47
+
48
+ NativesExternalStringResource::NativesExternalStringResource(
49
+ Bootstrapper* bootstrapper,
50
+ const char* source)
51
+ : data_(source), length_(StrLength(source)) {
52
+ if (bootstrapper->delete_these_non_arrays_on_tear_down_ == NULL) {
53
+ bootstrapper->delete_these_non_arrays_on_tear_down_ = new List<char*>(2);
54
+ }
55
+ // The resources are small objects and we only make a fixed number of
56
+ // them, but let's clean them up on exit for neatness.
57
+ bootstrapper->delete_these_non_arrays_on_tear_down_->
58
+ Add(reinterpret_cast<char*>(this));
59
+ }
60
+
61
+
62
+ Bootstrapper::Bootstrapper()
63
+ : nesting_(0),
64
+ extensions_cache_(Script::TYPE_EXTENSION),
65
+ delete_these_non_arrays_on_tear_down_(NULL),
66
+ delete_these_arrays_on_tear_down_(NULL) {
67
+ }
68
+
69
+
70
+ Handle<String> Bootstrapper::NativesSourceLookup(int index) {
71
+ ASSERT(0 <= index && index < Natives::GetBuiltinsCount());
72
+ Isolate* isolate = Isolate::Current();
73
+ Factory* factory = isolate->factory();
74
+ Heap* heap = isolate->heap();
75
+ if (heap->natives_source_cache()->get(index)->IsUndefined()) {
76
+ if (!Snapshot::IsEnabled() || FLAG_new_snapshot) {
77
+ // We can use external strings for the natives.
78
+ NativesExternalStringResource* resource =
79
+ new NativesExternalStringResource(this,
80
+ Natives::GetScriptSource(index).start());
81
+ Handle<String> source_code =
82
+ factory->NewExternalStringFromAscii(resource);
83
+ heap->natives_source_cache()->set(index, *source_code);
84
+ } else {
85
+ // Old snapshot code can't cope with external strings at all.
86
+ Handle<String> source_code =
87
+ factory->NewStringFromAscii(Natives::GetScriptSource(index));
88
+ heap->natives_source_cache()->set(index, *source_code);
89
+ }
90
+ }
91
+ Handle<Object> cached_source(heap->natives_source_cache()->get(index));
92
+ return Handle<String>::cast(cached_source);
93
+ }
94
+
95
+
96
+ void Bootstrapper::Initialize(bool create_heap_objects) {
97
+ extensions_cache_.Initialize(create_heap_objects);
98
+ GCExtension::Register();
99
+ ExternalizeStringExtension::Register();
100
+ }
101
+
102
+
103
+ char* Bootstrapper::AllocateAutoDeletedArray(int bytes) {
104
+ char* memory = new char[bytes];
105
+ if (memory != NULL) {
106
+ if (delete_these_arrays_on_tear_down_ == NULL) {
107
+ delete_these_arrays_on_tear_down_ = new List<char*>(2);
108
+ }
109
+ delete_these_arrays_on_tear_down_->Add(memory);
110
+ }
111
+ return memory;
112
+ }
113
+
114
+
115
+ void Bootstrapper::TearDown() {
116
+ if (delete_these_non_arrays_on_tear_down_ != NULL) {
117
+ int len = delete_these_non_arrays_on_tear_down_->length();
118
+ ASSERT(len < 20); // Don't use this mechanism for unbounded allocations.
119
+ for (int i = 0; i < len; i++) {
120
+ delete delete_these_non_arrays_on_tear_down_->at(i);
121
+ delete_these_non_arrays_on_tear_down_->at(i) = NULL;
122
+ }
123
+ delete delete_these_non_arrays_on_tear_down_;
124
+ delete_these_non_arrays_on_tear_down_ = NULL;
125
+ }
126
+
127
+ if (delete_these_arrays_on_tear_down_ != NULL) {
128
+ int len = delete_these_arrays_on_tear_down_->length();
129
+ ASSERT(len < 1000); // Don't use this mechanism for unbounded allocations.
130
+ for (int i = 0; i < len; i++) {
131
+ delete[] delete_these_arrays_on_tear_down_->at(i);
132
+ delete_these_arrays_on_tear_down_->at(i) = NULL;
133
+ }
134
+ delete delete_these_arrays_on_tear_down_;
135
+ delete_these_arrays_on_tear_down_ = NULL;
136
+ }
137
+
138
+ extensions_cache_.Initialize(false); // Yes, symmetrical
139
+ }
140
+
141
+
142
+ class Genesis BASE_EMBEDDED {
143
+ public:
144
+ Genesis(Isolate* isolate,
145
+ Handle<Object> global_object,
146
+ v8::Handle<v8::ObjectTemplate> global_template,
147
+ v8::ExtensionConfiguration* extensions);
148
+ ~Genesis() { }
149
+
150
+ Handle<Context> result() { return result_; }
151
+
152
+ Genesis* previous() { return previous_; }
153
+
154
+ Isolate* isolate() const { return isolate_; }
155
+ Factory* factory() const { return isolate_->factory(); }
156
+ Heap* heap() const { return isolate_->heap(); }
157
+
158
+ private:
159
+ Handle<Context> global_context_;
160
+ Isolate* isolate_;
161
+
162
+ // There may be more than one active genesis object: When GC is
163
+ // triggered during environment creation there may be weak handle
164
+ // processing callbacks which may create new environments.
165
+ Genesis* previous_;
166
+
167
+ Handle<Context> global_context() { return global_context_; }
168
+
169
+ // Creates some basic objects. Used for creating a context from scratch.
170
+ void CreateRoots();
171
+ // Creates the empty function. Used for creating a context from scratch.
172
+ Handle<JSFunction> CreateEmptyFunction(Isolate* isolate);
173
+ // Creates the ThrowTypeError function. ECMA 5th Ed. 13.2.3
174
+ Handle<JSFunction> GetThrowTypeErrorFunction();
175
+
176
+ void CreateStrictModeFunctionMaps(Handle<JSFunction> empty);
177
+ // Creates the global objects using the global and the template passed in
178
+ // through the API. We call this regardless of whether we are building a
179
+ // context from scratch or using a deserialized one from the partial snapshot
180
+ // but in the latter case we don't use the objects it produces directly, as
181
+ // we have to used the deserialized ones that are linked together with the
182
+ // rest of the context snapshot.
183
+ Handle<JSGlobalProxy> CreateNewGlobals(
184
+ v8::Handle<v8::ObjectTemplate> global_template,
185
+ Handle<Object> global_object,
186
+ Handle<GlobalObject>* global_proxy_out);
187
+ // Hooks the given global proxy into the context. If the context was created
188
+ // by deserialization then this will unhook the global proxy that was
189
+ // deserialized, leaving the GC to pick it up.
190
+ void HookUpGlobalProxy(Handle<GlobalObject> inner_global,
191
+ Handle<JSGlobalProxy> global_proxy);
192
+ // Similarly, we want to use the inner global that has been created by the
193
+ // templates passed through the API. The inner global from the snapshot is
194
+ // detached from the other objects in the snapshot.
195
+ void HookUpInnerGlobal(Handle<GlobalObject> inner_global);
196
+ // New context initialization. Used for creating a context from scratch.
197
+ void InitializeGlobal(Handle<GlobalObject> inner_global,
198
+ Handle<JSFunction> empty_function);
199
+ // Installs the contents of the native .js files on the global objects.
200
+ // Used for creating a context from scratch.
201
+ void InstallNativeFunctions();
202
+ void InstallExperimentalNativeFunctions();
203
+ bool InstallNatives();
204
+ bool InstallExperimentalNatives();
205
+ void InstallBuiltinFunctionIds();
206
+ void InstallJSFunctionResultCaches();
207
+ void InitializeNormalizedMapCaches();
208
+ // Used both for deserialized and from-scratch contexts to add the extensions
209
+ // provided.
210
+ static bool InstallExtensions(Handle<Context> global_context,
211
+ v8::ExtensionConfiguration* extensions);
212
+ static bool InstallExtension(const char* name);
213
+ static bool InstallExtension(v8::RegisteredExtension* current);
214
+ static void InstallSpecialObjects(Handle<Context> global_context);
215
+ bool InstallJSBuiltins(Handle<JSBuiltinsObject> builtins);
216
+ bool ConfigureApiObject(Handle<JSObject> object,
217
+ Handle<ObjectTemplateInfo> object_template);
218
+ bool ConfigureGlobalObjects(v8::Handle<v8::ObjectTemplate> global_template);
219
+
220
+ // Migrates all properties from the 'from' object to the 'to'
221
+ // object and overrides the prototype in 'to' with the one from
222
+ // 'from'.
223
+ void TransferObject(Handle<JSObject> from, Handle<JSObject> to);
224
+ void TransferNamedProperties(Handle<JSObject> from, Handle<JSObject> to);
225
+ void TransferIndexedProperties(Handle<JSObject> from, Handle<JSObject> to);
226
+
227
+ enum PrototypePropertyMode {
228
+ DONT_ADD_PROTOTYPE,
229
+ ADD_READONLY_PROTOTYPE,
230
+ ADD_WRITEABLE_PROTOTYPE
231
+ };
232
+
233
+ Handle<Map> CreateFunctionMap(PrototypePropertyMode prototype_mode);
234
+
235
+ Handle<DescriptorArray> ComputeFunctionInstanceDescriptor(
236
+ PrototypePropertyMode prototypeMode);
237
+ void MakeFunctionInstancePrototypeWritable();
238
+
239
+ Handle<Map> CreateStrictModeFunctionMap(
240
+ PrototypePropertyMode prototype_mode,
241
+ Handle<JSFunction> empty_function,
242
+ Handle<FixedArray> arguments_callbacks,
243
+ Handle<FixedArray> caller_callbacks);
244
+
245
+ Handle<DescriptorArray> ComputeStrictFunctionInstanceDescriptor(
246
+ PrototypePropertyMode propertyMode,
247
+ Handle<FixedArray> arguments,
248
+ Handle<FixedArray> caller);
249
+
250
+ static bool CompileBuiltin(Isolate* isolate, int index);
251
+ static bool CompileExperimentalBuiltin(Isolate* isolate, int index);
252
+ static bool CompileNative(Vector<const char> name, Handle<String> source);
253
+ static bool CompileScriptCached(Vector<const char> name,
254
+ Handle<String> source,
255
+ SourceCodeCache* cache,
256
+ v8::Extension* extension,
257
+ Handle<Context> top_context,
258
+ bool use_runtime_context);
259
+
260
+ Handle<Context> result_;
261
+
262
+ // Function instance maps. Function literal maps are created initially with
263
+ // a read only prototype for the processing of JS builtins. Later the function
264
+ // instance maps are replaced in order to make prototype writable.
265
+ // These are the final, writable prototype, maps.
266
+ Handle<Map> function_instance_map_writable_prototype_;
267
+ Handle<Map> strict_mode_function_instance_map_writable_prototype_;
268
+ Handle<JSFunction> throw_type_error_function;
269
+
270
+ BootstrapperActive active_;
271
+ friend class Bootstrapper;
272
+ };
273
+
274
+
275
+ void Bootstrapper::Iterate(ObjectVisitor* v) {
276
+ extensions_cache_.Iterate(v);
277
+ v->Synchronize("Extensions");
278
+ }
279
+
280
+
281
+ Handle<Context> Bootstrapper::CreateEnvironment(
282
+ Isolate* isolate,
283
+ Handle<Object> global_object,
284
+ v8::Handle<v8::ObjectTemplate> global_template,
285
+ v8::ExtensionConfiguration* extensions) {
286
+ HandleScope scope;
287
+ Handle<Context> env;
288
+ Genesis genesis(isolate, global_object, global_template, extensions);
289
+ env = genesis.result();
290
+ if (!env.is_null()) {
291
+ if (InstallExtensions(env, extensions)) {
292
+ return env;
293
+ }
294
+ }
295
+ return Handle<Context>();
296
+ }
297
+
298
+
299
+ static void SetObjectPrototype(Handle<JSObject> object, Handle<Object> proto) {
300
+ // object.__proto__ = proto;
301
+ Factory* factory = object->GetIsolate()->factory();
302
+ Handle<Map> old_to_map = Handle<Map>(object->map());
303
+ Handle<Map> new_to_map = factory->CopyMapDropTransitions(old_to_map);
304
+ new_to_map->set_prototype(*proto);
305
+ object->set_map(*new_to_map);
306
+ }
307
+
308
+
309
+ void Bootstrapper::DetachGlobal(Handle<Context> env) {
310
+ Factory* factory = env->GetIsolate()->factory();
311
+ JSGlobalProxy::cast(env->global_proxy())->set_context(*factory->null_value());
312
+ SetObjectPrototype(Handle<JSObject>(env->global_proxy()),
313
+ factory->null_value());
314
+ env->set_global_proxy(env->global());
315
+ env->global()->set_global_receiver(env->global());
316
+ }
317
+
318
+
319
+ void Bootstrapper::ReattachGlobal(Handle<Context> env,
320
+ Handle<Object> global_object) {
321
+ ASSERT(global_object->IsJSGlobalProxy());
322
+ Handle<JSGlobalProxy> global = Handle<JSGlobalProxy>::cast(global_object);
323
+ env->global()->set_global_receiver(*global);
324
+ env->set_global_proxy(*global);
325
+ SetObjectPrototype(global, Handle<JSObject>(env->global()));
326
+ global->set_context(*env);
327
+ }
328
+
329
+
330
+ static Handle<JSFunction> InstallFunction(Handle<JSObject> target,
331
+ const char* name,
332
+ InstanceType type,
333
+ int instance_size,
334
+ Handle<JSObject> prototype,
335
+ Builtins::Name call,
336
+ bool is_ecma_native) {
337
+ Isolate* isolate = target->GetIsolate();
338
+ Factory* factory = isolate->factory();
339
+ Handle<String> symbol = factory->LookupAsciiSymbol(name);
340
+ Handle<Code> call_code = Handle<Code>(isolate->builtins()->builtin(call));
341
+ Handle<JSFunction> function = prototype.is_null() ?
342
+ factory->NewFunctionWithoutPrototype(symbol, call_code) :
343
+ factory->NewFunctionWithPrototype(symbol,
344
+ type,
345
+ instance_size,
346
+ prototype,
347
+ call_code,
348
+ is_ecma_native);
349
+ SetLocalPropertyNoThrow(target, symbol, function, DONT_ENUM);
350
+ if (is_ecma_native) {
351
+ function->shared()->set_instance_class_name(*symbol);
352
+ }
353
+ return function;
354
+ }
355
+
356
+
357
+ Handle<DescriptorArray> Genesis::ComputeFunctionInstanceDescriptor(
358
+ PrototypePropertyMode prototypeMode) {
359
+ Handle<DescriptorArray> descriptors =
360
+ factory()->NewDescriptorArray(prototypeMode == DONT_ADD_PROTOTYPE
361
+ ? 4
362
+ : 5);
363
+ PropertyAttributes attributes =
364
+ static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
365
+
366
+ { // Add length.
367
+ Handle<Foreign> foreign = factory()->NewForeign(&Accessors::FunctionLength);
368
+ CallbacksDescriptor d(*factory()->length_symbol(), *foreign, attributes);
369
+ descriptors->Set(0, &d);
370
+ }
371
+ { // Add name.
372
+ Handle<Foreign> foreign = factory()->NewForeign(&Accessors::FunctionName);
373
+ CallbacksDescriptor d(*factory()->name_symbol(), *foreign, attributes);
374
+ descriptors->Set(1, &d);
375
+ }
376
+ { // Add arguments.
377
+ Handle<Foreign> foreign =
378
+ factory()->NewForeign(&Accessors::FunctionArguments);
379
+ CallbacksDescriptor d(*factory()->arguments_symbol(), *foreign, attributes);
380
+ descriptors->Set(2, &d);
381
+ }
382
+ { // Add caller.
383
+ Handle<Foreign> foreign = factory()->NewForeign(&Accessors::FunctionCaller);
384
+ CallbacksDescriptor d(*factory()->caller_symbol(), *foreign, attributes);
385
+ descriptors->Set(3, &d);
386
+ }
387
+ if (prototypeMode != DONT_ADD_PROTOTYPE) {
388
+ // Add prototype.
389
+ if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) {
390
+ attributes = static_cast<PropertyAttributes>(attributes & ~READ_ONLY);
391
+ }
392
+ Handle<Foreign> foreign =
393
+ factory()->NewForeign(&Accessors::FunctionPrototype);
394
+ CallbacksDescriptor d(*factory()->prototype_symbol(), *foreign, attributes);
395
+ descriptors->Set(4, &d);
396
+ }
397
+ descriptors->Sort();
398
+ return descriptors;
399
+ }
400
+
401
+
402
+ Handle<Map> Genesis::CreateFunctionMap(PrototypePropertyMode prototype_mode) {
403
+ Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize);
404
+ Handle<DescriptorArray> descriptors =
405
+ ComputeFunctionInstanceDescriptor(prototype_mode);
406
+ map->set_instance_descriptors(*descriptors);
407
+ map->set_function_with_prototype(prototype_mode != DONT_ADD_PROTOTYPE);
408
+ return map;
409
+ }
410
+
411
+
412
+ Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) {
413
+ // Allocate the map for function instances. Maps are allocated first and their
414
+ // prototypes patched later, once empty function is created.
415
+
416
+ // Please note that the prototype property for function instances must be
417
+ // writable.
418
+ Handle<Map> function_instance_map =
419
+ CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE);
420
+ global_context()->set_function_instance_map(*function_instance_map);
421
+
422
+ // Functions with this map will not have a 'prototype' property, and
423
+ // can not be used as constructors.
424
+ Handle<Map> function_without_prototype_map =
425
+ CreateFunctionMap(DONT_ADD_PROTOTYPE);
426
+ global_context()->set_function_without_prototype_map(
427
+ *function_without_prototype_map);
428
+
429
+ // Allocate the function map. This map is temporary, used only for processing
430
+ // of builtins.
431
+ // Later the map is replaced with writable prototype map, allocated below.
432
+ Handle<Map> function_map = CreateFunctionMap(ADD_READONLY_PROTOTYPE);
433
+ global_context()->set_function_map(*function_map);
434
+
435
+ // The final map for functions. Writeable prototype.
436
+ // This map is installed in MakeFunctionInstancePrototypeWritable.
437
+ function_instance_map_writable_prototype_ =
438
+ CreateFunctionMap(ADD_WRITEABLE_PROTOTYPE);
439
+
440
+ Factory* factory = isolate->factory();
441
+ Heap* heap = isolate->heap();
442
+
443
+ Handle<String> object_name = Handle<String>(heap->Object_symbol());
444
+
445
+ { // --- O b j e c t ---
446
+ Handle<JSFunction> object_fun =
447
+ factory->NewFunction(object_name, factory->null_value());
448
+ Handle<Map> object_function_map =
449
+ factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
450
+ object_fun->set_initial_map(*object_function_map);
451
+ object_function_map->set_constructor(*object_fun);
452
+
453
+ global_context()->set_object_function(*object_fun);
454
+
455
+ // Allocate a new prototype for the object function.
456
+ Handle<JSObject> prototype = factory->NewJSObject(
457
+ isolate->object_function(),
458
+ TENURED);
459
+
460
+ global_context()->set_initial_object_prototype(*prototype);
461
+ SetPrototype(object_fun, prototype);
462
+ object_function_map->
463
+ set_instance_descriptors(heap->empty_descriptor_array());
464
+ }
465
+
466
+ // Allocate the empty function as the prototype for function ECMAScript
467
+ // 262 15.3.4.
468
+ Handle<String> symbol = factory->LookupAsciiSymbol("Empty");
469
+ Handle<JSFunction> empty_function =
470
+ factory->NewFunctionWithoutPrototype(symbol, kNonStrictMode);
471
+
472
+ // --- E m p t y ---
473
+ Handle<Code> code =
474
+ Handle<Code>(isolate->builtins()->builtin(
475
+ Builtins::kEmptyFunction));
476
+ empty_function->set_code(*code);
477
+ empty_function->shared()->set_code(*code);
478
+ Handle<String> source = factory->NewStringFromAscii(CStrVector("() {}"));
479
+ Handle<Script> script = factory->NewScript(source);
480
+ script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
481
+ empty_function->shared()->set_script(*script);
482
+ empty_function->shared()->set_start_position(0);
483
+ empty_function->shared()->set_end_position(source->length());
484
+ empty_function->shared()->DontAdaptArguments();
485
+
486
+ // Set prototypes for the function maps.
487
+ global_context()->function_map()->set_prototype(*empty_function);
488
+ global_context()->function_instance_map()->set_prototype(*empty_function);
489
+ global_context()->function_without_prototype_map()->
490
+ set_prototype(*empty_function);
491
+ function_instance_map_writable_prototype_->set_prototype(*empty_function);
492
+
493
+ // Allocate the function map first and then patch the prototype later
494
+ Handle<Map> empty_fm = factory->CopyMapDropDescriptors(
495
+ function_without_prototype_map);
496
+ empty_fm->set_instance_descriptors(
497
+ function_without_prototype_map->instance_descriptors());
498
+ empty_fm->set_prototype(global_context()->object_function()->prototype());
499
+ empty_function->set_map(*empty_fm);
500
+ return empty_function;
501
+ }
502
+
503
+
504
+ Handle<DescriptorArray> Genesis::ComputeStrictFunctionInstanceDescriptor(
505
+ PrototypePropertyMode prototypeMode,
506
+ Handle<FixedArray> arguments,
507
+ Handle<FixedArray> caller) {
508
+ Handle<DescriptorArray> descriptors =
509
+ factory()->NewDescriptorArray(prototypeMode == DONT_ADD_PROTOTYPE
510
+ ? 4
511
+ : 5);
512
+ PropertyAttributes attributes = static_cast<PropertyAttributes>(
513
+ DONT_ENUM | DONT_DELETE | READ_ONLY);
514
+
515
+ { // length
516
+ Handle<Foreign> foreign = factory()->NewForeign(&Accessors::FunctionLength);
517
+ CallbacksDescriptor d(*factory()->length_symbol(), *foreign, attributes);
518
+ descriptors->Set(0, &d);
519
+ }
520
+ { // name
521
+ Handle<Foreign> foreign = factory()->NewForeign(&Accessors::FunctionName);
522
+ CallbacksDescriptor d(*factory()->name_symbol(), *foreign, attributes);
523
+ descriptors->Set(1, &d);
524
+ }
525
+ { // arguments
526
+ CallbacksDescriptor d(*factory()->arguments_symbol(),
527
+ *arguments,
528
+ attributes);
529
+ descriptors->Set(2, &d);
530
+ }
531
+ { // caller
532
+ CallbacksDescriptor d(*factory()->caller_symbol(), *caller, attributes);
533
+ descriptors->Set(3, &d);
534
+ }
535
+
536
+ // prototype
537
+ if (prototypeMode != DONT_ADD_PROTOTYPE) {
538
+ if (prototypeMode == ADD_WRITEABLE_PROTOTYPE) {
539
+ attributes = static_cast<PropertyAttributes>(attributes & ~READ_ONLY);
540
+ }
541
+ Handle<Foreign> foreign =
542
+ factory()->NewForeign(&Accessors::FunctionPrototype);
543
+ CallbacksDescriptor d(*factory()->prototype_symbol(), *foreign, attributes);
544
+ descriptors->Set(4, &d);
545
+ }
546
+
547
+ descriptors->Sort();
548
+ return descriptors;
549
+ }
550
+
551
+
552
+ // ECMAScript 5th Edition, 13.2.3
553
+ Handle<JSFunction> Genesis::GetThrowTypeErrorFunction() {
554
+ if (throw_type_error_function.is_null()) {
555
+ Handle<String> name = factory()->LookupAsciiSymbol("ThrowTypeError");
556
+ throw_type_error_function =
557
+ factory()->NewFunctionWithoutPrototype(name, kNonStrictMode);
558
+ Handle<Code> code(isolate()->builtins()->builtin(
559
+ Builtins::kStrictModePoisonPill));
560
+ throw_type_error_function->set_map(
561
+ global_context()->function_map());
562
+ throw_type_error_function->set_code(*code);
563
+ throw_type_error_function->shared()->set_code(*code);
564
+ throw_type_error_function->shared()->DontAdaptArguments();
565
+
566
+ PreventExtensions(throw_type_error_function);
567
+ }
568
+ return throw_type_error_function;
569
+ }
570
+
571
+
572
+ Handle<Map> Genesis::CreateStrictModeFunctionMap(
573
+ PrototypePropertyMode prototype_mode,
574
+ Handle<JSFunction> empty_function,
575
+ Handle<FixedArray> arguments_callbacks,
576
+ Handle<FixedArray> caller_callbacks) {
577
+ Handle<Map> map = factory()->NewMap(JS_FUNCTION_TYPE, JSFunction::kSize);
578
+ Handle<DescriptorArray> descriptors =
579
+ ComputeStrictFunctionInstanceDescriptor(prototype_mode,
580
+ arguments_callbacks,
581
+ caller_callbacks);
582
+ map->set_instance_descriptors(*descriptors);
583
+ map->set_function_with_prototype(prototype_mode != DONT_ADD_PROTOTYPE);
584
+ map->set_prototype(*empty_function);
585
+ return map;
586
+ }
587
+
588
+
589
+ void Genesis::CreateStrictModeFunctionMaps(Handle<JSFunction> empty) {
590
+ // Create the callbacks arrays for ThrowTypeError functions.
591
+ // The get/set callacks are filled in after the maps are created below.
592
+ Factory* factory = empty->GetIsolate()->factory();
593
+ Handle<FixedArray> arguments = factory->NewFixedArray(2, TENURED);
594
+ Handle<FixedArray> caller = factory->NewFixedArray(2, TENURED);
595
+
596
+ // Allocate map for the strict mode function instances.
597
+ Handle<Map> strict_mode_function_instance_map =
598
+ CreateStrictModeFunctionMap(
599
+ ADD_WRITEABLE_PROTOTYPE, empty, arguments, caller);
600
+ global_context()->set_strict_mode_function_instance_map(
601
+ *strict_mode_function_instance_map);
602
+
603
+ // Allocate map for the prototype-less strict mode instances.
604
+ Handle<Map> strict_mode_function_without_prototype_map =
605
+ CreateStrictModeFunctionMap(
606
+ DONT_ADD_PROTOTYPE, empty, arguments, caller);
607
+ global_context()->set_strict_mode_function_without_prototype_map(
608
+ *strict_mode_function_without_prototype_map);
609
+
610
+ // Allocate map for the strict mode functions. This map is temporary, used
611
+ // only for processing of builtins.
612
+ // Later the map is replaced with writable prototype map, allocated below.
613
+ Handle<Map> strict_mode_function_map =
614
+ CreateStrictModeFunctionMap(
615
+ ADD_READONLY_PROTOTYPE, empty, arguments, caller);
616
+ global_context()->set_strict_mode_function_map(
617
+ *strict_mode_function_map);
618
+
619
+ // The final map for the strict mode functions. Writeable prototype.
620
+ // This map is installed in MakeFunctionInstancePrototypeWritable.
621
+ strict_mode_function_instance_map_writable_prototype_ =
622
+ CreateStrictModeFunctionMap(
623
+ ADD_WRITEABLE_PROTOTYPE, empty, arguments, caller);
624
+
625
+ // Create the ThrowTypeError function instance.
626
+ Handle<JSFunction> throw_function =
627
+ GetThrowTypeErrorFunction();
628
+
629
+ // Complete the callback fixed arrays.
630
+ arguments->set(0, *throw_function);
631
+ arguments->set(1, *throw_function);
632
+ caller->set(0, *throw_function);
633
+ caller->set(1, *throw_function);
634
+ }
635
+
636
+
637
+ static void AddToWeakGlobalContextList(Context* context) {
638
+ ASSERT(context->IsGlobalContext());
639
+ Heap* heap = context->GetIsolate()->heap();
640
+ #ifdef DEBUG
641
+ { // NOLINT
642
+ ASSERT(context->get(Context::NEXT_CONTEXT_LINK)->IsUndefined());
643
+ // Check that context is not in the list yet.
644
+ for (Object* current = heap->global_contexts_list();
645
+ !current->IsUndefined();
646
+ current = Context::cast(current)->get(Context::NEXT_CONTEXT_LINK)) {
647
+ ASSERT(current != context);
648
+ }
649
+ }
650
+ #endif
651
+ context->set(Context::NEXT_CONTEXT_LINK, heap->global_contexts_list());
652
+ heap->set_global_contexts_list(context);
653
+ }
654
+
655
+
656
+ void Genesis::CreateRoots() {
657
+ // Allocate the global context FixedArray first and then patch the
658
+ // closure and extension object later (we need the empty function
659
+ // and the global object, but in order to create those, we need the
660
+ // global context).
661
+ global_context_ = Handle<Context>::cast(isolate()->global_handles()->Create(
662
+ *factory()->NewGlobalContext()));
663
+ AddToWeakGlobalContextList(*global_context_);
664
+ isolate()->set_context(*global_context());
665
+
666
+ // Allocate the message listeners object.
667
+ {
668
+ v8::NeanderArray listeners;
669
+ global_context()->set_message_listeners(*listeners.value());
670
+ }
671
+ }
672
+
673
+
674
+ Handle<JSGlobalProxy> Genesis::CreateNewGlobals(
675
+ v8::Handle<v8::ObjectTemplate> global_template,
676
+ Handle<Object> global_object,
677
+ Handle<GlobalObject>* inner_global_out) {
678
+ // The argument global_template aka data is an ObjectTemplateInfo.
679
+ // It has a constructor pointer that points at global_constructor which is a
680
+ // FunctionTemplateInfo.
681
+ // The global_constructor is used to create or reinitialize the global_proxy.
682
+ // The global_constructor also has a prototype_template pointer that points at
683
+ // js_global_template which is an ObjectTemplateInfo.
684
+ // That in turn has a constructor pointer that points at
685
+ // js_global_constructor which is a FunctionTemplateInfo.
686
+ // js_global_constructor is used to make js_global_function
687
+ // js_global_function is used to make the new inner_global.
688
+ //
689
+ // --- G l o b a l ---
690
+ // Step 1: Create a fresh inner JSGlobalObject.
691
+ Handle<JSFunction> js_global_function;
692
+ Handle<ObjectTemplateInfo> js_global_template;
693
+ if (!global_template.IsEmpty()) {
694
+ // Get prototype template of the global_template.
695
+ Handle<ObjectTemplateInfo> data =
696
+ v8::Utils::OpenHandle(*global_template);
697
+ Handle<FunctionTemplateInfo> global_constructor =
698
+ Handle<FunctionTemplateInfo>(
699
+ FunctionTemplateInfo::cast(data->constructor()));
700
+ Handle<Object> proto_template(global_constructor->prototype_template());
701
+ if (!proto_template->IsUndefined()) {
702
+ js_global_template =
703
+ Handle<ObjectTemplateInfo>::cast(proto_template);
704
+ }
705
+ }
706
+
707
+ if (js_global_template.is_null()) {
708
+ Handle<String> name = Handle<String>(heap()->empty_symbol());
709
+ Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin(
710
+ Builtins::kIllegal));
711
+ js_global_function =
712
+ factory()->NewFunction(name, JS_GLOBAL_OBJECT_TYPE,
713
+ JSGlobalObject::kSize, code, true);
714
+ // Change the constructor property of the prototype of the
715
+ // hidden global function to refer to the Object function.
716
+ Handle<JSObject> prototype =
717
+ Handle<JSObject>(
718
+ JSObject::cast(js_global_function->instance_prototype()));
719
+ SetLocalPropertyNoThrow(
720
+ prototype,
721
+ factory()->constructor_symbol(),
722
+ isolate()->object_function(),
723
+ NONE);
724
+ } else {
725
+ Handle<FunctionTemplateInfo> js_global_constructor(
726
+ FunctionTemplateInfo::cast(js_global_template->constructor()));
727
+ js_global_function =
728
+ factory()->CreateApiFunction(js_global_constructor,
729
+ factory()->InnerGlobalObject);
730
+ }
731
+
732
+ js_global_function->initial_map()->set_is_hidden_prototype();
733
+ Handle<GlobalObject> inner_global =
734
+ factory()->NewGlobalObject(js_global_function);
735
+ if (inner_global_out != NULL) {
736
+ *inner_global_out = inner_global;
737
+ }
738
+
739
+ // Step 2: create or re-initialize the global proxy object.
740
+ Handle<JSFunction> global_proxy_function;
741
+ if (global_template.IsEmpty()) {
742
+ Handle<String> name = Handle<String>(heap()->empty_symbol());
743
+ Handle<Code> code = Handle<Code>(isolate()->builtins()->builtin(
744
+ Builtins::kIllegal));
745
+ global_proxy_function =
746
+ factory()->NewFunction(name, JS_GLOBAL_PROXY_TYPE,
747
+ JSGlobalProxy::kSize, code, true);
748
+ } else {
749
+ Handle<ObjectTemplateInfo> data =
750
+ v8::Utils::OpenHandle(*global_template);
751
+ Handle<FunctionTemplateInfo> global_constructor(
752
+ FunctionTemplateInfo::cast(data->constructor()));
753
+ global_proxy_function =
754
+ factory()->CreateApiFunction(global_constructor,
755
+ factory()->OuterGlobalObject);
756
+ }
757
+
758
+ Handle<String> global_name = factory()->LookupAsciiSymbol("global");
759
+ global_proxy_function->shared()->set_instance_class_name(*global_name);
760
+ global_proxy_function->initial_map()->set_is_access_check_needed(true);
761
+
762
+ // Set global_proxy.__proto__ to js_global after ConfigureGlobalObjects
763
+ // Return the global proxy.
764
+
765
+ if (global_object.location() != NULL) {
766
+ ASSERT(global_object->IsJSGlobalProxy());
767
+ return ReinitializeJSGlobalProxy(
768
+ global_proxy_function,
769
+ Handle<JSGlobalProxy>::cast(global_object));
770
+ } else {
771
+ return Handle<JSGlobalProxy>::cast(
772
+ factory()->NewJSObject(global_proxy_function, TENURED));
773
+ }
774
+ }
775
+
776
+
777
+ void Genesis::HookUpGlobalProxy(Handle<GlobalObject> inner_global,
778
+ Handle<JSGlobalProxy> global_proxy) {
779
+ // Set the global context for the global object.
780
+ inner_global->set_global_context(*global_context());
781
+ inner_global->set_global_receiver(*global_proxy);
782
+ global_proxy->set_context(*global_context());
783
+ global_context()->set_global_proxy(*global_proxy);
784
+ }
785
+
786
+
787
+ void Genesis::HookUpInnerGlobal(Handle<GlobalObject> inner_global) {
788
+ Handle<GlobalObject> inner_global_from_snapshot(
789
+ GlobalObject::cast(global_context_->extension()));
790
+ Handle<JSBuiltinsObject> builtins_global(global_context_->builtins());
791
+ global_context_->set_extension(*inner_global);
792
+ global_context_->set_global(*inner_global);
793
+ global_context_->set_security_token(*inner_global);
794
+ static const PropertyAttributes attributes =
795
+ static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
796
+ ForceSetProperty(builtins_global,
797
+ factory()->LookupAsciiSymbol("global"),
798
+ inner_global,
799
+ attributes);
800
+ // Setup the reference from the global object to the builtins object.
801
+ JSGlobalObject::cast(*inner_global)->set_builtins(*builtins_global);
802
+ TransferNamedProperties(inner_global_from_snapshot, inner_global);
803
+ TransferIndexedProperties(inner_global_from_snapshot, inner_global);
804
+ }
805
+
806
+
807
+ // This is only called if we are not using snapshots. The equivalent
808
+ // work in the snapshot case is done in HookUpInnerGlobal.
809
+ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
810
+ Handle<JSFunction> empty_function) {
811
+ // --- G l o b a l C o n t e x t ---
812
+ // Use the empty function as closure (no scope info).
813
+ global_context()->set_closure(*empty_function);
814
+ global_context()->set_fcontext(*global_context());
815
+ global_context()->set_previous(NULL);
816
+ // Set extension and global object.
817
+ global_context()->set_extension(*inner_global);
818
+ global_context()->set_global(*inner_global);
819
+ // Security setup: Set the security token of the global object to
820
+ // its the inner global. This makes the security check between two
821
+ // different contexts fail by default even in case of global
822
+ // object reinitialization.
823
+ global_context()->set_security_token(*inner_global);
824
+
825
+ Isolate* isolate = inner_global->GetIsolate();
826
+ Factory* factory = isolate->factory();
827
+ Heap* heap = isolate->heap();
828
+
829
+ Handle<String> object_name = Handle<String>(heap->Object_symbol());
830
+ SetLocalPropertyNoThrow(inner_global, object_name,
831
+ isolate->object_function(), DONT_ENUM);
832
+
833
+ Handle<JSObject> global = Handle<JSObject>(global_context()->global());
834
+
835
+ // Install global Function object
836
+ InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize,
837
+ empty_function, Builtins::kIllegal, true); // ECMA native.
838
+
839
+ { // --- A r r a y ---
840
+ Handle<JSFunction> array_function =
841
+ InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize,
842
+ isolate->initial_object_prototype(),
843
+ Builtins::kArrayCode, true);
844
+ array_function->shared()->set_construct_stub(
845
+ isolate->builtins()->builtin(Builtins::kArrayConstructCode));
846
+ array_function->shared()->DontAdaptArguments();
847
+
848
+ // This seems a bit hackish, but we need to make sure Array.length
849
+ // is 1.
850
+ array_function->shared()->set_length(1);
851
+ Handle<DescriptorArray> array_descriptors =
852
+ factory->CopyAppendForeignDescriptor(
853
+ factory->empty_descriptor_array(),
854
+ factory->length_symbol(),
855
+ factory->NewForeign(&Accessors::ArrayLength),
856
+ static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE));
857
+
858
+ // Cache the fast JavaScript array map
859
+ global_context()->set_js_array_map(array_function->initial_map());
860
+ global_context()->js_array_map()->set_instance_descriptors(
861
+ *array_descriptors);
862
+ // array_function is used internally. JS code creating array object should
863
+ // search for the 'Array' property on the global object and use that one
864
+ // as the constructor. 'Array' property on a global object can be
865
+ // overwritten by JS code.
866
+ global_context()->set_array_function(*array_function);
867
+ }
868
+
869
+ { // --- N u m b e r ---
870
+ Handle<JSFunction> number_fun =
871
+ InstallFunction(global, "Number", JS_VALUE_TYPE, JSValue::kSize,
872
+ isolate->initial_object_prototype(),
873
+ Builtins::kIllegal, true);
874
+ global_context()->set_number_function(*number_fun);
875
+ }
876
+
877
+ { // --- B o o l e a n ---
878
+ Handle<JSFunction> boolean_fun =
879
+ InstallFunction(global, "Boolean", JS_VALUE_TYPE, JSValue::kSize,
880
+ isolate->initial_object_prototype(),
881
+ Builtins::kIllegal, true);
882
+ global_context()->set_boolean_function(*boolean_fun);
883
+ }
884
+
885
+ { // --- S t r i n g ---
886
+ Handle<JSFunction> string_fun =
887
+ InstallFunction(global, "String", JS_VALUE_TYPE, JSValue::kSize,
888
+ isolate->initial_object_prototype(),
889
+ Builtins::kIllegal, true);
890
+ string_fun->shared()->set_construct_stub(
891
+ isolate->builtins()->builtin(Builtins::kStringConstructCode));
892
+ global_context()->set_string_function(*string_fun);
893
+ // Add 'length' property to strings.
894
+ Handle<DescriptorArray> string_descriptors =
895
+ factory->CopyAppendForeignDescriptor(
896
+ factory->empty_descriptor_array(),
897
+ factory->length_symbol(),
898
+ factory->NewForeign(&Accessors::StringLength),
899
+ static_cast<PropertyAttributes>(DONT_ENUM |
900
+ DONT_DELETE |
901
+ READ_ONLY));
902
+
903
+ Handle<Map> string_map =
904
+ Handle<Map>(global_context()->string_function()->initial_map());
905
+ string_map->set_instance_descriptors(*string_descriptors);
906
+ }
907
+
908
+ { // --- D a t e ---
909
+ // Builtin functions for Date.prototype.
910
+ Handle<JSFunction> date_fun =
911
+ InstallFunction(global, "Date", JS_VALUE_TYPE, JSValue::kSize,
912
+ isolate->initial_object_prototype(),
913
+ Builtins::kIllegal, true);
914
+
915
+ global_context()->set_date_function(*date_fun);
916
+ }
917
+
918
+
919
+ { // -- R e g E x p
920
+ // Builtin functions for RegExp.prototype.
921
+ Handle<JSFunction> regexp_fun =
922
+ InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize,
923
+ isolate->initial_object_prototype(),
924
+ Builtins::kIllegal, true);
925
+ global_context()->set_regexp_function(*regexp_fun);
926
+
927
+ ASSERT(regexp_fun->has_initial_map());
928
+ Handle<Map> initial_map(regexp_fun->initial_map());
929
+
930
+ ASSERT_EQ(0, initial_map->inobject_properties());
931
+
932
+ Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(5);
933
+ PropertyAttributes final =
934
+ static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
935
+ int enum_index = 0;
936
+ {
937
+ // ECMA-262, section 15.10.7.1.
938
+ FieldDescriptor field(heap->source_symbol(),
939
+ JSRegExp::kSourceFieldIndex,
940
+ final,
941
+ enum_index++);
942
+ descriptors->Set(0, &field);
943
+ }
944
+ {
945
+ // ECMA-262, section 15.10.7.2.
946
+ FieldDescriptor field(heap->global_symbol(),
947
+ JSRegExp::kGlobalFieldIndex,
948
+ final,
949
+ enum_index++);
950
+ descriptors->Set(1, &field);
951
+ }
952
+ {
953
+ // ECMA-262, section 15.10.7.3.
954
+ FieldDescriptor field(heap->ignore_case_symbol(),
955
+ JSRegExp::kIgnoreCaseFieldIndex,
956
+ final,
957
+ enum_index++);
958
+ descriptors->Set(2, &field);
959
+ }
960
+ {
961
+ // ECMA-262, section 15.10.7.4.
962
+ FieldDescriptor field(heap->multiline_symbol(),
963
+ JSRegExp::kMultilineFieldIndex,
964
+ final,
965
+ enum_index++);
966
+ descriptors->Set(3, &field);
967
+ }
968
+ {
969
+ // ECMA-262, section 15.10.7.5.
970
+ PropertyAttributes writable =
971
+ static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE);
972
+ FieldDescriptor field(heap->last_index_symbol(),
973
+ JSRegExp::kLastIndexFieldIndex,
974
+ writable,
975
+ enum_index++);
976
+ descriptors->Set(4, &field);
977
+ }
978
+ descriptors->SetNextEnumerationIndex(enum_index);
979
+ descriptors->Sort();
980
+
981
+ initial_map->set_inobject_properties(5);
982
+ initial_map->set_pre_allocated_property_fields(5);
983
+ initial_map->set_unused_property_fields(0);
984
+ initial_map->set_instance_size(
985
+ initial_map->instance_size() + 5 * kPointerSize);
986
+ initial_map->set_instance_descriptors(*descriptors);
987
+ initial_map->set_visitor_id(StaticVisitorBase::GetVisitorId(*initial_map));
988
+ }
989
+
990
+ { // -- J S O N
991
+ Handle<String> name = factory->NewStringFromAscii(CStrVector("JSON"));
992
+ Handle<JSFunction> cons = factory->NewFunction(
993
+ name,
994
+ factory->the_hole_value());
995
+ cons->SetInstancePrototype(global_context()->initial_object_prototype());
996
+ cons->SetInstanceClassName(*name);
997
+ Handle<JSObject> json_object = factory->NewJSObject(cons, TENURED);
998
+ ASSERT(json_object->IsJSObject());
999
+ SetLocalPropertyNoThrow(global, name, json_object, DONT_ENUM);
1000
+ global_context()->set_json_object(*json_object);
1001
+ }
1002
+
1003
+ { // --- arguments_boilerplate_
1004
+ // Make sure we can recognize argument objects at runtime.
1005
+ // This is done by introducing an anonymous function with
1006
+ // class_name equals 'Arguments'.
1007
+ Handle<String> symbol = factory->LookupAsciiSymbol("Arguments");
1008
+ Handle<Code> code = Handle<Code>(
1009
+ isolate->builtins()->builtin(Builtins::kIllegal));
1010
+ Handle<JSObject> prototype =
1011
+ Handle<JSObject>(
1012
+ JSObject::cast(global_context()->object_function()->prototype()));
1013
+
1014
+ Handle<JSFunction> function =
1015
+ factory->NewFunctionWithPrototype(symbol,
1016
+ JS_OBJECT_TYPE,
1017
+ JSObject::kHeaderSize,
1018
+ prototype,
1019
+ code,
1020
+ false);
1021
+ ASSERT(!function->has_initial_map());
1022
+ function->shared()->set_instance_class_name(*symbol);
1023
+ function->shared()->set_expected_nof_properties(2);
1024
+ Handle<JSObject> result = factory->NewJSObject(function);
1025
+
1026
+ global_context()->set_arguments_boilerplate(*result);
1027
+ // Note: length must be added as the first property and
1028
+ // callee must be added as the second property.
1029
+ SetLocalPropertyNoThrow(result, factory->length_symbol(),
1030
+ factory->undefined_value(),
1031
+ DONT_ENUM);
1032
+ SetLocalPropertyNoThrow(result, factory->callee_symbol(),
1033
+ factory->undefined_value(),
1034
+ DONT_ENUM);
1035
+
1036
+ #ifdef DEBUG
1037
+ LookupResult lookup;
1038
+ result->LocalLookup(heap->callee_symbol(), &lookup);
1039
+ ASSERT(lookup.IsProperty() && (lookup.type() == FIELD));
1040
+ ASSERT(lookup.GetFieldIndex() == Heap::kArgumentsCalleeIndex);
1041
+
1042
+ result->LocalLookup(heap->length_symbol(), &lookup);
1043
+ ASSERT(lookup.IsProperty() && (lookup.type() == FIELD));
1044
+ ASSERT(lookup.GetFieldIndex() == Heap::kArgumentsLengthIndex);
1045
+
1046
+ ASSERT(result->map()->inobject_properties() > Heap::kArgumentsCalleeIndex);
1047
+ ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex);
1048
+
1049
+ // Check the state of the object.
1050
+ ASSERT(result->HasFastProperties());
1051
+ ASSERT(result->HasFastElements());
1052
+ #endif
1053
+ }
1054
+
1055
+ { // --- strict mode arguments boilerplate
1056
+ const PropertyAttributes attributes =
1057
+ static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
1058
+
1059
+ // Create the ThrowTypeError functions.
1060
+ Handle<FixedArray> callee = factory->NewFixedArray(2, TENURED);
1061
+ Handle<FixedArray> caller = factory->NewFixedArray(2, TENURED);
1062
+
1063
+ Handle<JSFunction> throw_function =
1064
+ GetThrowTypeErrorFunction();
1065
+
1066
+ // Install the ThrowTypeError functions.
1067
+ callee->set(0, *throw_function);
1068
+ callee->set(1, *throw_function);
1069
+ caller->set(0, *throw_function);
1070
+ caller->set(1, *throw_function);
1071
+
1072
+ // Create the descriptor array for the arguments object.
1073
+ Handle<DescriptorArray> descriptors = factory->NewDescriptorArray(3);
1074
+ { // length
1075
+ FieldDescriptor d(*factory->length_symbol(), 0, DONT_ENUM);
1076
+ descriptors->Set(0, &d);
1077
+ }
1078
+ { // callee
1079
+ CallbacksDescriptor d(*factory->callee_symbol(), *callee, attributes);
1080
+ descriptors->Set(1, &d);
1081
+ }
1082
+ { // caller
1083
+ CallbacksDescriptor d(*factory->caller_symbol(), *caller, attributes);
1084
+ descriptors->Set(2, &d);
1085
+ }
1086
+ descriptors->Sort();
1087
+
1088
+ // Create the map. Allocate one in-object field for length.
1089
+ Handle<Map> map = factory->NewMap(JS_OBJECT_TYPE,
1090
+ Heap::kArgumentsObjectSizeStrict);
1091
+ map->set_instance_descriptors(*descriptors);
1092
+ map->set_function_with_prototype(true);
1093
+ map->set_prototype(global_context()->object_function()->prototype());
1094
+ map->set_pre_allocated_property_fields(1);
1095
+ map->set_inobject_properties(1);
1096
+
1097
+ // Copy constructor from the non-strict arguments boilerplate.
1098
+ map->set_constructor(
1099
+ global_context()->arguments_boilerplate()->map()->constructor());
1100
+
1101
+ // Allocate the arguments boilerplate object.
1102
+ Handle<JSObject> result = factory->NewJSObjectFromMap(map);
1103
+ global_context()->set_strict_mode_arguments_boilerplate(*result);
1104
+
1105
+ // Add length property only for strict mode boilerplate.
1106
+ SetLocalPropertyNoThrow(result, factory->length_symbol(),
1107
+ factory->undefined_value(),
1108
+ DONT_ENUM);
1109
+
1110
+ #ifdef DEBUG
1111
+ LookupResult lookup;
1112
+ result->LocalLookup(heap->length_symbol(), &lookup);
1113
+ ASSERT(lookup.IsProperty() && (lookup.type() == FIELD));
1114
+ ASSERT(lookup.GetFieldIndex() == Heap::kArgumentsLengthIndex);
1115
+
1116
+ ASSERT(result->map()->inobject_properties() > Heap::kArgumentsLengthIndex);
1117
+
1118
+ // Check the state of the object.
1119
+ ASSERT(result->HasFastProperties());
1120
+ ASSERT(result->HasFastElements());
1121
+ #endif
1122
+ }
1123
+
1124
+ { // --- context extension
1125
+ // Create a function for the context extension objects.
1126
+ Handle<Code> code = Handle<Code>(
1127
+ isolate->builtins()->builtin(Builtins::kIllegal));
1128
+ Handle<JSFunction> context_extension_fun =
1129
+ factory->NewFunction(factory->empty_symbol(),
1130
+ JS_CONTEXT_EXTENSION_OBJECT_TYPE,
1131
+ JSObject::kHeaderSize,
1132
+ code,
1133
+ true);
1134
+
1135
+ Handle<String> name = factory->LookupAsciiSymbol("context_extension");
1136
+ context_extension_fun->shared()->set_instance_class_name(*name);
1137
+ global_context()->set_context_extension_function(*context_extension_fun);
1138
+ }
1139
+
1140
+
1141
+ {
1142
+ // Setup the call-as-function delegate.
1143
+ Handle<Code> code =
1144
+ Handle<Code>(isolate->builtins()->builtin(
1145
+ Builtins::kHandleApiCallAsFunction));
1146
+ Handle<JSFunction> delegate =
1147
+ factory->NewFunction(factory->empty_symbol(), JS_OBJECT_TYPE,
1148
+ JSObject::kHeaderSize, code, true);
1149
+ global_context()->set_call_as_function_delegate(*delegate);
1150
+ delegate->shared()->DontAdaptArguments();
1151
+ }
1152
+
1153
+ {
1154
+ // Setup the call-as-constructor delegate.
1155
+ Handle<Code> code =
1156
+ Handle<Code>(isolate->builtins()->builtin(
1157
+ Builtins::kHandleApiCallAsConstructor));
1158
+ Handle<JSFunction> delegate =
1159
+ factory->NewFunction(factory->empty_symbol(), JS_OBJECT_TYPE,
1160
+ JSObject::kHeaderSize, code, true);
1161
+ global_context()->set_call_as_constructor_delegate(*delegate);
1162
+ delegate->shared()->DontAdaptArguments();
1163
+ }
1164
+
1165
+ // Initialize the out of memory slot.
1166
+ global_context()->set_out_of_memory(heap->false_value());
1167
+
1168
+ // Initialize the data slot.
1169
+ global_context()->set_data(heap->undefined_value());
1170
+ }
1171
+
1172
+
1173
+ bool Genesis::CompileBuiltin(Isolate* isolate, int index) {
1174
+ Vector<const char> name = Natives::GetScriptName(index);
1175
+ Handle<String> source_code =
1176
+ isolate->bootstrapper()->NativesSourceLookup(index);
1177
+ return CompileNative(name, source_code);
1178
+ }
1179
+
1180
+
1181
+ bool Genesis::CompileExperimentalBuiltin(Isolate* isolate, int index) {
1182
+ Vector<const char> name = ExperimentalNatives::GetScriptName(index);
1183
+ Factory* factory = isolate->factory();
1184
+ Handle<String> source_code =
1185
+ factory->NewStringFromAscii(ExperimentalNatives::GetScriptSource(index));
1186
+ return CompileNative(name, source_code);
1187
+ }
1188
+
1189
+
1190
+ bool Genesis::CompileNative(Vector<const char> name, Handle<String> source) {
1191
+ HandleScope scope;
1192
+ Isolate* isolate = source->GetIsolate();
1193
+ #ifdef ENABLE_DEBUGGER_SUPPORT
1194
+ isolate->debugger()->set_compiling_natives(true);
1195
+ #endif
1196
+ bool result = CompileScriptCached(name,
1197
+ source,
1198
+ NULL,
1199
+ NULL,
1200
+ Handle<Context>(isolate->context()),
1201
+ true);
1202
+ ASSERT(isolate->has_pending_exception() != result);
1203
+ if (!result) isolate->clear_pending_exception();
1204
+ #ifdef ENABLE_DEBUGGER_SUPPORT
1205
+ isolate->debugger()->set_compiling_natives(false);
1206
+ #endif
1207
+ return result;
1208
+ }
1209
+
1210
+
1211
+ bool Genesis::CompileScriptCached(Vector<const char> name,
1212
+ Handle<String> source,
1213
+ SourceCodeCache* cache,
1214
+ v8::Extension* extension,
1215
+ Handle<Context> top_context,
1216
+ bool use_runtime_context) {
1217
+ Factory* factory = source->GetIsolate()->factory();
1218
+ HandleScope scope;
1219
+ Handle<SharedFunctionInfo> function_info;
1220
+
1221
+ // If we can't find the function in the cache, we compile a new
1222
+ // function and insert it into the cache.
1223
+ if (cache == NULL || !cache->Lookup(name, &function_info)) {
1224
+ ASSERT(source->IsAsciiRepresentation());
1225
+ Handle<String> script_name = factory->NewStringFromUtf8(name);
1226
+ function_info = Compiler::Compile(
1227
+ source,
1228
+ script_name,
1229
+ 0,
1230
+ 0,
1231
+ extension,
1232
+ NULL,
1233
+ Handle<String>::null(),
1234
+ use_runtime_context ? NATIVES_CODE : NOT_NATIVES_CODE);
1235
+ if (function_info.is_null()) return false;
1236
+ if (cache != NULL) cache->Add(name, function_info);
1237
+ }
1238
+
1239
+ // Setup the function context. Conceptually, we should clone the
1240
+ // function before overwriting the context but since we're in a
1241
+ // single-threaded environment it is not strictly necessary.
1242
+ ASSERT(top_context->IsGlobalContext());
1243
+ Handle<Context> context =
1244
+ Handle<Context>(use_runtime_context
1245
+ ? Handle<Context>(top_context->runtime_context())
1246
+ : top_context);
1247
+ Handle<JSFunction> fun =
1248
+ factory->NewFunctionFromSharedFunctionInfo(function_info, context);
1249
+
1250
+ // Call function using either the runtime object or the global
1251
+ // object as the receiver. Provide no parameters.
1252
+ Handle<Object> receiver =
1253
+ Handle<Object>(use_runtime_context
1254
+ ? top_context->builtins()
1255
+ : top_context->global());
1256
+ bool has_pending_exception;
1257
+ Execution::Call(fun, receiver, 0, NULL, &has_pending_exception);
1258
+ if (has_pending_exception) return false;
1259
+ return true;
1260
+ }
1261
+
1262
+
1263
+ #define INSTALL_NATIVE(Type, name, var) \
1264
+ Handle<String> var##_name = factory()->LookupAsciiSymbol(name); \
1265
+ Object* var##_native = \
1266
+ global_context()->builtins()->GetPropertyNoExceptionThrown( \
1267
+ *var##_name); \
1268
+ global_context()->set_##var(Type::cast(var##_native));
1269
+
1270
+
1271
+ void Genesis::InstallNativeFunctions() {
1272
+ HandleScope scope;
1273
+ INSTALL_NATIVE(JSFunction, "CreateDate", create_date_fun);
1274
+ INSTALL_NATIVE(JSFunction, "ToNumber", to_number_fun);
1275
+ INSTALL_NATIVE(JSFunction, "ToString", to_string_fun);
1276
+ INSTALL_NATIVE(JSFunction, "ToDetailString", to_detail_string_fun);
1277
+ INSTALL_NATIVE(JSFunction, "ToObject", to_object_fun);
1278
+ INSTALL_NATIVE(JSFunction, "ToInteger", to_integer_fun);
1279
+ INSTALL_NATIVE(JSFunction, "ToUint32", to_uint32_fun);
1280
+ INSTALL_NATIVE(JSFunction, "ToInt32", to_int32_fun);
1281
+ INSTALL_NATIVE(JSFunction, "GlobalEval", global_eval_fun);
1282
+ INSTALL_NATIVE(JSFunction, "Instantiate", instantiate_fun);
1283
+ INSTALL_NATIVE(JSFunction, "ConfigureTemplateInstance",
1284
+ configure_instance_fun);
1285
+ INSTALL_NATIVE(JSFunction, "GetStackTraceLine", get_stack_trace_line_fun);
1286
+ INSTALL_NATIVE(JSObject, "functionCache", function_cache);
1287
+ }
1288
+
1289
+ void Genesis::InstallExperimentalNativeFunctions() {
1290
+ if (FLAG_harmony_proxies) {
1291
+ INSTALL_NATIVE(JSFunction, "DerivedGetTrap", derived_get_trap);
1292
+ }
1293
+ }
1294
+
1295
+ #undef INSTALL_NATIVE
1296
+
1297
+
1298
+ bool Genesis::InstallNatives() {
1299
+ HandleScope scope;
1300
+
1301
+ // Create a function for the builtins object. Allocate space for the
1302
+ // JavaScript builtins, a reference to the builtins object
1303
+ // (itself) and a reference to the global_context directly in the object.
1304
+ Handle<Code> code = Handle<Code>(
1305
+ isolate()->builtins()->builtin(Builtins::kIllegal));
1306
+ Handle<JSFunction> builtins_fun =
1307
+ factory()->NewFunction(factory()->empty_symbol(),
1308
+ JS_BUILTINS_OBJECT_TYPE,
1309
+ JSBuiltinsObject::kSize, code, true);
1310
+
1311
+ Handle<String> name = factory()->LookupAsciiSymbol("builtins");
1312
+ builtins_fun->shared()->set_instance_class_name(*name);
1313
+
1314
+ // Allocate the builtins object.
1315
+ Handle<JSBuiltinsObject> builtins =
1316
+ Handle<JSBuiltinsObject>::cast(factory()->NewGlobalObject(builtins_fun));
1317
+ builtins->set_builtins(*builtins);
1318
+ builtins->set_global_context(*global_context());
1319
+ builtins->set_global_receiver(*builtins);
1320
+
1321
+ // Setup the 'global' properties of the builtins object. The
1322
+ // 'global' property that refers to the global object is the only
1323
+ // way to get from code running in the builtins context to the
1324
+ // global object.
1325
+ static const PropertyAttributes attributes =
1326
+ static_cast<PropertyAttributes>(READ_ONLY | DONT_DELETE);
1327
+ Handle<String> global_symbol = factory()->LookupAsciiSymbol("global");
1328
+ Handle<Object> global_obj(global_context()->global());
1329
+ SetLocalPropertyNoThrow(builtins, global_symbol, global_obj, attributes);
1330
+
1331
+ // Setup the reference from the global object to the builtins object.
1332
+ JSGlobalObject::cast(global_context()->global())->set_builtins(*builtins);
1333
+
1334
+ // Create a bridge function that has context in the global context.
1335
+ Handle<JSFunction> bridge =
1336
+ factory()->NewFunction(factory()->empty_symbol(),
1337
+ factory()->undefined_value());
1338
+ ASSERT(bridge->context() == *isolate()->global_context());
1339
+
1340
+ // Allocate the builtins context.
1341
+ Handle<Context> context =
1342
+ factory()->NewFunctionContext(Context::MIN_CONTEXT_SLOTS, bridge);
1343
+ context->set_global(*builtins); // override builtins global object
1344
+
1345
+ global_context()->set_runtime_context(*context);
1346
+
1347
+ { // -- S c r i p t
1348
+ // Builtin functions for Script.
1349
+ Handle<JSFunction> script_fun =
1350
+ InstallFunction(builtins, "Script", JS_VALUE_TYPE, JSValue::kSize,
1351
+ isolate()->initial_object_prototype(),
1352
+ Builtins::kIllegal, false);
1353
+ Handle<JSObject> prototype =
1354
+ factory()->NewJSObject(isolate()->object_function(), TENURED);
1355
+ SetPrototype(script_fun, prototype);
1356
+ global_context()->set_script_function(*script_fun);
1357
+
1358
+ // Add 'source' and 'data' property to scripts.
1359
+ PropertyAttributes common_attributes =
1360
+ static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE | READ_ONLY);
1361
+ Handle<Foreign> foreign_source =
1362
+ factory()->NewForeign(&Accessors::ScriptSource);
1363
+ Handle<DescriptorArray> script_descriptors =
1364
+ factory()->CopyAppendForeignDescriptor(
1365
+ factory()->empty_descriptor_array(),
1366
+ factory()->LookupAsciiSymbol("source"),
1367
+ foreign_source,
1368
+ common_attributes);
1369
+ Handle<Foreign> foreign_name =
1370
+ factory()->NewForeign(&Accessors::ScriptName);
1371
+ script_descriptors =
1372
+ factory()->CopyAppendForeignDescriptor(
1373
+ script_descriptors,
1374
+ factory()->LookupAsciiSymbol("name"),
1375
+ foreign_name,
1376
+ common_attributes);
1377
+ Handle<Foreign> foreign_id = factory()->NewForeign(&Accessors::ScriptId);
1378
+ script_descriptors =
1379
+ factory()->CopyAppendForeignDescriptor(
1380
+ script_descriptors,
1381
+ factory()->LookupAsciiSymbol("id"),
1382
+ foreign_id,
1383
+ common_attributes);
1384
+ Handle<Foreign> foreign_line_offset =
1385
+ factory()->NewForeign(&Accessors::ScriptLineOffset);
1386
+ script_descriptors =
1387
+ factory()->CopyAppendForeignDescriptor(
1388
+ script_descriptors,
1389
+ factory()->LookupAsciiSymbol("line_offset"),
1390
+ foreign_line_offset,
1391
+ common_attributes);
1392
+ Handle<Foreign> foreign_column_offset =
1393
+ factory()->NewForeign(&Accessors::ScriptColumnOffset);
1394
+ script_descriptors =
1395
+ factory()->CopyAppendForeignDescriptor(
1396
+ script_descriptors,
1397
+ factory()->LookupAsciiSymbol("column_offset"),
1398
+ foreign_column_offset,
1399
+ common_attributes);
1400
+ Handle<Foreign> foreign_data =
1401
+ factory()->NewForeign(&Accessors::ScriptData);
1402
+ script_descriptors =
1403
+ factory()->CopyAppendForeignDescriptor(
1404
+ script_descriptors,
1405
+ factory()->LookupAsciiSymbol("data"),
1406
+ foreign_data,
1407
+ common_attributes);
1408
+ Handle<Foreign> foreign_type =
1409
+ factory()->NewForeign(&Accessors::ScriptType);
1410
+ script_descriptors =
1411
+ factory()->CopyAppendForeignDescriptor(
1412
+ script_descriptors,
1413
+ factory()->LookupAsciiSymbol("type"),
1414
+ foreign_type,
1415
+ common_attributes);
1416
+ Handle<Foreign> foreign_compilation_type =
1417
+ factory()->NewForeign(&Accessors::ScriptCompilationType);
1418
+ script_descriptors =
1419
+ factory()->CopyAppendForeignDescriptor(
1420
+ script_descriptors,
1421
+ factory()->LookupAsciiSymbol("compilation_type"),
1422
+ foreign_compilation_type,
1423
+ common_attributes);
1424
+ Handle<Foreign> foreign_line_ends =
1425
+ factory()->NewForeign(&Accessors::ScriptLineEnds);
1426
+ script_descriptors =
1427
+ factory()->CopyAppendForeignDescriptor(
1428
+ script_descriptors,
1429
+ factory()->LookupAsciiSymbol("line_ends"),
1430
+ foreign_line_ends,
1431
+ common_attributes);
1432
+ Handle<Foreign> foreign_context_data =
1433
+ factory()->NewForeign(&Accessors::ScriptContextData);
1434
+ script_descriptors =
1435
+ factory()->CopyAppendForeignDescriptor(
1436
+ script_descriptors,
1437
+ factory()->LookupAsciiSymbol("context_data"),
1438
+ foreign_context_data,
1439
+ common_attributes);
1440
+ Handle<Foreign> foreign_eval_from_script =
1441
+ factory()->NewForeign(&Accessors::ScriptEvalFromScript);
1442
+ script_descriptors =
1443
+ factory()->CopyAppendForeignDescriptor(
1444
+ script_descriptors,
1445
+ factory()->LookupAsciiSymbol("eval_from_script"),
1446
+ foreign_eval_from_script,
1447
+ common_attributes);
1448
+ Handle<Foreign> foreign_eval_from_script_position =
1449
+ factory()->NewForeign(&Accessors::ScriptEvalFromScriptPosition);
1450
+ script_descriptors =
1451
+ factory()->CopyAppendForeignDescriptor(
1452
+ script_descriptors,
1453
+ factory()->LookupAsciiSymbol("eval_from_script_position"),
1454
+ foreign_eval_from_script_position,
1455
+ common_attributes);
1456
+ Handle<Foreign> foreign_eval_from_function_name =
1457
+ factory()->NewForeign(&Accessors::ScriptEvalFromFunctionName);
1458
+ script_descriptors =
1459
+ factory()->CopyAppendForeignDescriptor(
1460
+ script_descriptors,
1461
+ factory()->LookupAsciiSymbol("eval_from_function_name"),
1462
+ foreign_eval_from_function_name,
1463
+ common_attributes);
1464
+
1465
+ Handle<Map> script_map = Handle<Map>(script_fun->initial_map());
1466
+ script_map->set_instance_descriptors(*script_descriptors);
1467
+
1468
+ // Allocate the empty script.
1469
+ Handle<Script> script = factory()->NewScript(factory()->empty_string());
1470
+ script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
1471
+ heap()->public_set_empty_script(*script);
1472
+ }
1473
+ {
1474
+ // Builtin function for OpaqueReference -- a JSValue-based object,
1475
+ // that keeps its field isolated from JavaScript code. It may store
1476
+ // objects, that JavaScript code may not access.
1477
+ Handle<JSFunction> opaque_reference_fun =
1478
+ InstallFunction(builtins, "OpaqueReference", JS_VALUE_TYPE,
1479
+ JSValue::kSize,
1480
+ isolate()->initial_object_prototype(),
1481
+ Builtins::kIllegal, false);
1482
+ Handle<JSObject> prototype =
1483
+ factory()->NewJSObject(isolate()->object_function(), TENURED);
1484
+ SetPrototype(opaque_reference_fun, prototype);
1485
+ global_context()->set_opaque_reference_function(*opaque_reference_fun);
1486
+ }
1487
+
1488
+ { // --- I n t e r n a l A r r a y ---
1489
+ // An array constructor on the builtins object that works like
1490
+ // the public Array constructor, except that its prototype
1491
+ // doesn't inherit from Object.prototype.
1492
+ // To be used only for internal work by builtins. Instances
1493
+ // must not be leaked to user code.
1494
+ // Only works correctly when called as a constructor. The normal
1495
+ // Array code uses Array.prototype as prototype when called as
1496
+ // a function.
1497
+ Handle<JSFunction> array_function =
1498
+ InstallFunction(builtins,
1499
+ "InternalArray",
1500
+ JS_ARRAY_TYPE,
1501
+ JSArray::kSize,
1502
+ isolate()->initial_object_prototype(),
1503
+ Builtins::kArrayCode,
1504
+ true);
1505
+ Handle<JSObject> prototype =
1506
+ factory()->NewJSObject(isolate()->object_function(), TENURED);
1507
+ SetPrototype(array_function, prototype);
1508
+
1509
+ array_function->shared()->set_construct_stub(
1510
+ isolate()->builtins()->builtin(Builtins::kArrayConstructCode));
1511
+ array_function->shared()->DontAdaptArguments();
1512
+
1513
+ // Make "length" magic on instances.
1514
+ Handle<DescriptorArray> array_descriptors =
1515
+ factory()->CopyAppendForeignDescriptor(
1516
+ factory()->empty_descriptor_array(),
1517
+ factory()->length_symbol(),
1518
+ factory()->NewForeign(&Accessors::ArrayLength),
1519
+ static_cast<PropertyAttributes>(DONT_ENUM | DONT_DELETE));
1520
+
1521
+ array_function->initial_map()->set_instance_descriptors(
1522
+ *array_descriptors);
1523
+ }
1524
+
1525
+ if (FLAG_disable_native_files) {
1526
+ PrintF("Warning: Running without installed natives!\n");
1527
+ return true;
1528
+ }
1529
+
1530
+ // Install natives.
1531
+ for (int i = Natives::GetDebuggerCount();
1532
+ i < Natives::GetBuiltinsCount();
1533
+ i++) {
1534
+ if (!CompileBuiltin(isolate(), i)) return false;
1535
+ // TODO(ager): We really only need to install the JS builtin
1536
+ // functions on the builtins object after compiling and running
1537
+ // runtime.js.
1538
+ if (!InstallJSBuiltins(builtins)) return false;
1539
+ }
1540
+
1541
+ InstallNativeFunctions();
1542
+
1543
+ // Store the map for the string prototype after the natives has been compiled
1544
+ // and the String function has been setup.
1545
+ Handle<JSFunction> string_function(global_context()->string_function());
1546
+ ASSERT(JSObject::cast(
1547
+ string_function->initial_map()->prototype())->HasFastProperties());
1548
+ global_context()->set_string_function_prototype_map(
1549
+ HeapObject::cast(string_function->initial_map()->prototype())->map());
1550
+
1551
+ InstallBuiltinFunctionIds();
1552
+
1553
+ // Install Function.prototype.call and apply.
1554
+ { Handle<String> key = factory()->function_class_symbol();
1555
+ Handle<JSFunction> function =
1556
+ Handle<JSFunction>::cast(GetProperty(isolate()->global(), key));
1557
+ Handle<JSObject> proto =
1558
+ Handle<JSObject>(JSObject::cast(function->instance_prototype()));
1559
+
1560
+ // Install the call and the apply functions.
1561
+ Handle<JSFunction> call =
1562
+ InstallFunction(proto, "call", JS_OBJECT_TYPE, JSObject::kHeaderSize,
1563
+ Handle<JSObject>::null(),
1564
+ Builtins::kFunctionCall,
1565
+ false);
1566
+ Handle<JSFunction> apply =
1567
+ InstallFunction(proto, "apply", JS_OBJECT_TYPE, JSObject::kHeaderSize,
1568
+ Handle<JSObject>::null(),
1569
+ Builtins::kFunctionApply,
1570
+ false);
1571
+
1572
+ // Make sure that Function.prototype.call appears to be compiled.
1573
+ // The code will never be called, but inline caching for call will
1574
+ // only work if it appears to be compiled.
1575
+ call->shared()->DontAdaptArguments();
1576
+ ASSERT(call->is_compiled());
1577
+
1578
+ // Set the expected parameters for apply to 2; required by builtin.
1579
+ apply->shared()->set_formal_parameter_count(2);
1580
+
1581
+ // Set the lengths for the functions to satisfy ECMA-262.
1582
+ call->shared()->set_length(1);
1583
+ apply->shared()->set_length(2);
1584
+ }
1585
+
1586
+ // Create a constructor for RegExp results (a variant of Array that
1587
+ // predefines the two properties index and match).
1588
+ {
1589
+ // RegExpResult initial map.
1590
+
1591
+ // Find global.Array.prototype to inherit from.
1592
+ Handle<JSFunction> array_constructor(global_context()->array_function());
1593
+ Handle<JSObject> array_prototype(
1594
+ JSObject::cast(array_constructor->instance_prototype()));
1595
+
1596
+ // Add initial map.
1597
+ Handle<Map> initial_map =
1598
+ factory()->NewMap(JS_ARRAY_TYPE, JSRegExpResult::kSize);
1599
+ initial_map->set_constructor(*array_constructor);
1600
+
1601
+ // Set prototype on map.
1602
+ initial_map->set_non_instance_prototype(false);
1603
+ initial_map->set_prototype(*array_prototype);
1604
+
1605
+ // Update map with length accessor from Array and add "index" and "input".
1606
+ Handle<Map> array_map(global_context()->js_array_map());
1607
+ Handle<DescriptorArray> array_descriptors(
1608
+ array_map->instance_descriptors());
1609
+ ASSERT_EQ(1, array_descriptors->number_of_descriptors());
1610
+
1611
+ Handle<DescriptorArray> reresult_descriptors =
1612
+ factory()->NewDescriptorArray(3);
1613
+
1614
+ reresult_descriptors->CopyFrom(0, *array_descriptors, 0);
1615
+
1616
+ int enum_index = 0;
1617
+ {
1618
+ FieldDescriptor index_field(heap()->index_symbol(),
1619
+ JSRegExpResult::kIndexIndex,
1620
+ NONE,
1621
+ enum_index++);
1622
+ reresult_descriptors->Set(1, &index_field);
1623
+ }
1624
+
1625
+ {
1626
+ FieldDescriptor input_field(heap()->input_symbol(),
1627
+ JSRegExpResult::kInputIndex,
1628
+ NONE,
1629
+ enum_index++);
1630
+ reresult_descriptors->Set(2, &input_field);
1631
+ }
1632
+ reresult_descriptors->Sort();
1633
+
1634
+ initial_map->set_inobject_properties(2);
1635
+ initial_map->set_pre_allocated_property_fields(2);
1636
+ initial_map->set_unused_property_fields(0);
1637
+ initial_map->set_instance_descriptors(*reresult_descriptors);
1638
+
1639
+ global_context()->set_regexp_result_map(*initial_map);
1640
+ }
1641
+
1642
+
1643
+ #ifdef DEBUG
1644
+ builtins->Verify();
1645
+ #endif
1646
+
1647
+ return true;
1648
+ }
1649
+
1650
+
1651
+ bool Genesis::InstallExperimentalNatives() {
1652
+ for (int i = ExperimentalNatives::GetDebuggerCount();
1653
+ i < ExperimentalNatives::GetBuiltinsCount();
1654
+ i++) {
1655
+ if (FLAG_harmony_proxies &&
1656
+ strcmp(ExperimentalNatives::GetScriptName(i).start(),
1657
+ "native proxy.js") == 0) {
1658
+ if (!CompileExperimentalBuiltin(isolate(), i)) return false;
1659
+ }
1660
+ }
1661
+
1662
+ InstallExperimentalNativeFunctions();
1663
+
1664
+ return true;
1665
+ }
1666
+
1667
+
1668
+ static Handle<JSObject> ResolveBuiltinIdHolder(
1669
+ Handle<Context> global_context,
1670
+ const char* holder_expr) {
1671
+ Factory* factory = global_context->GetIsolate()->factory();
1672
+ Handle<GlobalObject> global(global_context->global());
1673
+ const char* period_pos = strchr(holder_expr, '.');
1674
+ if (period_pos == NULL) {
1675
+ return Handle<JSObject>::cast(
1676
+ GetProperty(global, factory->LookupAsciiSymbol(holder_expr)));
1677
+ }
1678
+ ASSERT_EQ(".prototype", period_pos);
1679
+ Vector<const char> property(holder_expr,
1680
+ static_cast<int>(period_pos - holder_expr));
1681
+ Handle<JSFunction> function = Handle<JSFunction>::cast(
1682
+ GetProperty(global, factory->LookupSymbol(property)));
1683
+ return Handle<JSObject>(JSObject::cast(function->prototype()));
1684
+ }
1685
+
1686
+
1687
+ static void InstallBuiltinFunctionId(Handle<JSObject> holder,
1688
+ const char* function_name,
1689
+ BuiltinFunctionId id) {
1690
+ Factory* factory = holder->GetIsolate()->factory();
1691
+ Handle<String> name = factory->LookupAsciiSymbol(function_name);
1692
+ Object* function_object = holder->GetProperty(*name)->ToObjectUnchecked();
1693
+ Handle<JSFunction> function(JSFunction::cast(function_object));
1694
+ function->shared()->set_function_data(Smi::FromInt(id));
1695
+ }
1696
+
1697
+
1698
+ void Genesis::InstallBuiltinFunctionIds() {
1699
+ HandleScope scope;
1700
+ #define INSTALL_BUILTIN_ID(holder_expr, fun_name, name) \
1701
+ { \
1702
+ Handle<JSObject> holder = ResolveBuiltinIdHolder( \
1703
+ global_context(), #holder_expr); \
1704
+ BuiltinFunctionId id = k##name; \
1705
+ InstallBuiltinFunctionId(holder, #fun_name, id); \
1706
+ }
1707
+ FUNCTIONS_WITH_ID_LIST(INSTALL_BUILTIN_ID)
1708
+ #undef INSTALL_BUILTIN_ID
1709
+ }
1710
+
1711
+
1712
+ // Do not forget to update macros.py with named constant
1713
+ // of cache id.
1714
+ #define JSFUNCTION_RESULT_CACHE_LIST(F) \
1715
+ F(16, global_context()->regexp_function())
1716
+
1717
+
1718
+ static FixedArray* CreateCache(int size, Handle<JSFunction> factory_function) {
1719
+ Factory* factory = factory_function->GetIsolate()->factory();
1720
+ // Caches are supposed to live for a long time, allocate in old space.
1721
+ int array_size = JSFunctionResultCache::kEntriesIndex + 2 * size;
1722
+ // Cannot use cast as object is not fully initialized yet.
1723
+ JSFunctionResultCache* cache = reinterpret_cast<JSFunctionResultCache*>(
1724
+ *factory->NewFixedArrayWithHoles(array_size, TENURED));
1725
+ cache->set(JSFunctionResultCache::kFactoryIndex, *factory_function);
1726
+ cache->MakeZeroSize();
1727
+ return cache;
1728
+ }
1729
+
1730
+
1731
+ void Genesis::InstallJSFunctionResultCaches() {
1732
+ const int kNumberOfCaches = 0 +
1733
+ #define F(size, func) + 1
1734
+ JSFUNCTION_RESULT_CACHE_LIST(F)
1735
+ #undef F
1736
+ ;
1737
+
1738
+ Handle<FixedArray> caches = FACTORY->NewFixedArray(kNumberOfCaches, TENURED);
1739
+
1740
+ int index = 0;
1741
+
1742
+ #define F(size, func) do { \
1743
+ FixedArray* cache = CreateCache((size), Handle<JSFunction>(func)); \
1744
+ caches->set(index++, cache); \
1745
+ } while (false)
1746
+
1747
+ JSFUNCTION_RESULT_CACHE_LIST(F);
1748
+
1749
+ #undef F
1750
+
1751
+ global_context()->set_jsfunction_result_caches(*caches);
1752
+ }
1753
+
1754
+
1755
+ void Genesis::InitializeNormalizedMapCaches() {
1756
+ Handle<FixedArray> array(
1757
+ FACTORY->NewFixedArray(NormalizedMapCache::kEntries, TENURED));
1758
+ global_context()->set_normalized_map_cache(NormalizedMapCache::cast(*array));
1759
+ }
1760
+
1761
+
1762
+ bool Bootstrapper::InstallExtensions(Handle<Context> global_context,
1763
+ v8::ExtensionConfiguration* extensions) {
1764
+ Isolate* isolate = global_context->GetIsolate();
1765
+ BootstrapperActive active;
1766
+ SaveContext saved_context(isolate);
1767
+ isolate->set_context(*global_context);
1768
+ if (!Genesis::InstallExtensions(global_context, extensions)) return false;
1769
+ Genesis::InstallSpecialObjects(global_context);
1770
+ return true;
1771
+ }
1772
+
1773
+
1774
+ void Genesis::InstallSpecialObjects(Handle<Context> global_context) {
1775
+ Factory* factory = global_context->GetIsolate()->factory();
1776
+ HandleScope scope;
1777
+ Handle<JSGlobalObject> js_global(
1778
+ JSGlobalObject::cast(global_context->global()));
1779
+ // Expose the natives in global if a name for it is specified.
1780
+ if (FLAG_expose_natives_as != NULL && strlen(FLAG_expose_natives_as) != 0) {
1781
+ Handle<String> natives_string =
1782
+ factory->LookupAsciiSymbol(FLAG_expose_natives_as);
1783
+ SetLocalPropertyNoThrow(js_global, natives_string,
1784
+ Handle<JSObject>(js_global->builtins()), DONT_ENUM);
1785
+ }
1786
+
1787
+ Handle<Object> Error = GetProperty(js_global, "Error");
1788
+ if (Error->IsJSObject()) {
1789
+ Handle<String> name = factory->LookupAsciiSymbol("stackTraceLimit");
1790
+ SetLocalPropertyNoThrow(Handle<JSObject>::cast(Error),
1791
+ name,
1792
+ Handle<Smi>(Smi::FromInt(FLAG_stack_trace_limit)),
1793
+ NONE);
1794
+ }
1795
+
1796
+ #ifdef ENABLE_DEBUGGER_SUPPORT
1797
+ // Expose the debug global object in global if a name for it is specified.
1798
+ if (FLAG_expose_debug_as != NULL && strlen(FLAG_expose_debug_as) != 0) {
1799
+ Debug* debug = Isolate::Current()->debug();
1800
+ // If loading fails we just bail out without installing the
1801
+ // debugger but without tanking the whole context.
1802
+ if (!debug->Load()) return;
1803
+ // Set the security token for the debugger context to the same as
1804
+ // the shell global context to allow calling between these (otherwise
1805
+ // exposing debug global object doesn't make much sense).
1806
+ debug->debug_context()->set_security_token(
1807
+ global_context->security_token());
1808
+
1809
+ Handle<String> debug_string =
1810
+ factory->LookupAsciiSymbol(FLAG_expose_debug_as);
1811
+ Handle<Object> global_proxy(debug->debug_context()->global_proxy());
1812
+ SetLocalPropertyNoThrow(js_global, debug_string, global_proxy, DONT_ENUM);
1813
+ }
1814
+ #endif
1815
+ }
1816
+
1817
+
1818
+ bool Genesis::InstallExtensions(Handle<Context> global_context,
1819
+ v8::ExtensionConfiguration* extensions) {
1820
+ // TODO(isolates): Extensions on multiple isolates may take a little more
1821
+ // effort. (The external API reads 'ignore'-- does that mean
1822
+ // we can break the interface?)
1823
+
1824
+ // Clear coloring of extension list
1825
+ v8::RegisteredExtension* current = v8::RegisteredExtension::first_extension();
1826
+ while (current != NULL) {
1827
+ current->set_state(v8::UNVISITED);
1828
+ current = current->next();
1829
+ }
1830
+ // Install auto extensions.
1831
+ current = v8::RegisteredExtension::first_extension();
1832
+ while (current != NULL) {
1833
+ if (current->extension()->auto_enable())
1834
+ InstallExtension(current);
1835
+ current = current->next();
1836
+ }
1837
+
1838
+ if (FLAG_expose_gc) InstallExtension("v8/gc");
1839
+ if (FLAG_expose_externalize_string) InstallExtension("v8/externalize");
1840
+
1841
+ if (extensions == NULL) return true;
1842
+ // Install required extensions
1843
+ int count = v8::ImplementationUtilities::GetNameCount(extensions);
1844
+ const char** names = v8::ImplementationUtilities::GetNames(extensions);
1845
+ for (int i = 0; i < count; i++) {
1846
+ if (!InstallExtension(names[i]))
1847
+ return false;
1848
+ }
1849
+
1850
+ return true;
1851
+ }
1852
+
1853
+
1854
+ // Installs a named extension. This methods is unoptimized and does
1855
+ // not scale well if we want to support a large number of extensions.
1856
+ bool Genesis::InstallExtension(const char* name) {
1857
+ v8::RegisteredExtension* current = v8::RegisteredExtension::first_extension();
1858
+ // Loop until we find the relevant extension
1859
+ while (current != NULL) {
1860
+ if (strcmp(name, current->extension()->name()) == 0) break;
1861
+ current = current->next();
1862
+ }
1863
+ // Didn't find the extension; fail.
1864
+ if (current == NULL) {
1865
+ v8::Utils::ReportApiFailure(
1866
+ "v8::Context::New()", "Cannot find required extension");
1867
+ return false;
1868
+ }
1869
+ return InstallExtension(current);
1870
+ }
1871
+
1872
+
1873
+ bool Genesis::InstallExtension(v8::RegisteredExtension* current) {
1874
+ HandleScope scope;
1875
+
1876
+ if (current->state() == v8::INSTALLED) return true;
1877
+ // The current node has already been visited so there must be a
1878
+ // cycle in the dependency graph; fail.
1879
+ if (current->state() == v8::VISITED) {
1880
+ v8::Utils::ReportApiFailure(
1881
+ "v8::Context::New()", "Circular extension dependency");
1882
+ return false;
1883
+ }
1884
+ ASSERT(current->state() == v8::UNVISITED);
1885
+ current->set_state(v8::VISITED);
1886
+ v8::Extension* extension = current->extension();
1887
+ // Install the extension's dependencies
1888
+ for (int i = 0; i < extension->dependency_count(); i++) {
1889
+ if (!InstallExtension(extension->dependencies()[i])) return false;
1890
+ }
1891
+ Isolate* isolate = Isolate::Current();
1892
+ Vector<const char> source = CStrVector(extension->source());
1893
+ Handle<String> source_code = isolate->factory()->NewStringFromAscii(source);
1894
+ bool result = CompileScriptCached(CStrVector(extension->name()),
1895
+ source_code,
1896
+ isolate->bootstrapper()->extensions_cache(),
1897
+ extension,
1898
+ Handle<Context>(isolate->context()),
1899
+ false);
1900
+ ASSERT(isolate->has_pending_exception() != result);
1901
+ if (!result) {
1902
+ isolate->clear_pending_exception();
1903
+ }
1904
+ current->set_state(v8::INSTALLED);
1905
+ return result;
1906
+ }
1907
+
1908
+
1909
+ bool Genesis::InstallJSBuiltins(Handle<JSBuiltinsObject> builtins) {
1910
+ HandleScope scope;
1911
+ Factory* factory = builtins->GetIsolate()->factory();
1912
+ for (int i = 0; i < Builtins::NumberOfJavaScriptBuiltins(); i++) {
1913
+ Builtins::JavaScript id = static_cast<Builtins::JavaScript>(i);
1914
+ Handle<String> name = factory->LookupAsciiSymbol(Builtins::GetName(id));
1915
+ Object* function_object = builtins->GetPropertyNoExceptionThrown(*name);
1916
+ Handle<JSFunction> function
1917
+ = Handle<JSFunction>(JSFunction::cast(function_object));
1918
+ builtins->set_javascript_builtin(id, *function);
1919
+ Handle<SharedFunctionInfo> shared
1920
+ = Handle<SharedFunctionInfo>(function->shared());
1921
+ if (!EnsureCompiled(shared, CLEAR_EXCEPTION)) return false;
1922
+ // Set the code object on the function object.
1923
+ function->ReplaceCode(function->shared()->code());
1924
+ builtins->set_javascript_builtin_code(id, shared->code());
1925
+ }
1926
+ return true;
1927
+ }
1928
+
1929
+
1930
+ bool Genesis::ConfigureGlobalObjects(
1931
+ v8::Handle<v8::ObjectTemplate> global_proxy_template) {
1932
+ Handle<JSObject> global_proxy(
1933
+ JSObject::cast(global_context()->global_proxy()));
1934
+ Handle<JSObject> inner_global(JSObject::cast(global_context()->global()));
1935
+
1936
+ if (!global_proxy_template.IsEmpty()) {
1937
+ // Configure the global proxy object.
1938
+ Handle<ObjectTemplateInfo> proxy_data =
1939
+ v8::Utils::OpenHandle(*global_proxy_template);
1940
+ if (!ConfigureApiObject(global_proxy, proxy_data)) return false;
1941
+
1942
+ // Configure the inner global object.
1943
+ Handle<FunctionTemplateInfo> proxy_constructor(
1944
+ FunctionTemplateInfo::cast(proxy_data->constructor()));
1945
+ if (!proxy_constructor->prototype_template()->IsUndefined()) {
1946
+ Handle<ObjectTemplateInfo> inner_data(
1947
+ ObjectTemplateInfo::cast(proxy_constructor->prototype_template()));
1948
+ if (!ConfigureApiObject(inner_global, inner_data)) return false;
1949
+ }
1950
+ }
1951
+
1952
+ SetObjectPrototype(global_proxy, inner_global);
1953
+ return true;
1954
+ }
1955
+
1956
+
1957
+ bool Genesis::ConfigureApiObject(Handle<JSObject> object,
1958
+ Handle<ObjectTemplateInfo> object_template) {
1959
+ ASSERT(!object_template.is_null());
1960
+ ASSERT(object->IsInstanceOf(
1961
+ FunctionTemplateInfo::cast(object_template->constructor())));
1962
+
1963
+ bool pending_exception = false;
1964
+ Handle<JSObject> obj =
1965
+ Execution::InstantiateObject(object_template, &pending_exception);
1966
+ if (pending_exception) {
1967
+ ASSERT(isolate()->has_pending_exception());
1968
+ isolate()->clear_pending_exception();
1969
+ return false;
1970
+ }
1971
+ TransferObject(obj, object);
1972
+ return true;
1973
+ }
1974
+
1975
+
1976
+ void Genesis::TransferNamedProperties(Handle<JSObject> from,
1977
+ Handle<JSObject> to) {
1978
+ if (from->HasFastProperties()) {
1979
+ Handle<DescriptorArray> descs =
1980
+ Handle<DescriptorArray>(from->map()->instance_descriptors());
1981
+ for (int i = 0; i < descs->number_of_descriptors(); i++) {
1982
+ PropertyDetails details = PropertyDetails(descs->GetDetails(i));
1983
+ switch (details.type()) {
1984
+ case FIELD: {
1985
+ HandleScope inner;
1986
+ Handle<String> key = Handle<String>(descs->GetKey(i));
1987
+ int index = descs->GetFieldIndex(i);
1988
+ Handle<Object> value = Handle<Object>(from->FastPropertyAt(index));
1989
+ SetLocalPropertyNoThrow(to, key, value, details.attributes());
1990
+ break;
1991
+ }
1992
+ case CONSTANT_FUNCTION: {
1993
+ HandleScope inner;
1994
+ Handle<String> key = Handle<String>(descs->GetKey(i));
1995
+ Handle<JSFunction> fun =
1996
+ Handle<JSFunction>(descs->GetConstantFunction(i));
1997
+ SetLocalPropertyNoThrow(to, key, fun, details.attributes());
1998
+ break;
1999
+ }
2000
+ case CALLBACKS: {
2001
+ LookupResult result;
2002
+ to->LocalLookup(descs->GetKey(i), &result);
2003
+ // If the property is already there we skip it
2004
+ if (result.IsProperty()) continue;
2005
+ HandleScope inner;
2006
+ ASSERT(!to->HasFastProperties());
2007
+ // Add to dictionary.
2008
+ Handle<String> key = Handle<String>(descs->GetKey(i));
2009
+ Handle<Object> callbacks(descs->GetCallbacksObject(i));
2010
+ PropertyDetails d =
2011
+ PropertyDetails(details.attributes(), CALLBACKS, details.index());
2012
+ SetNormalizedProperty(to, key, callbacks, d);
2013
+ break;
2014
+ }
2015
+ case MAP_TRANSITION:
2016
+ case EXTERNAL_ARRAY_TRANSITION:
2017
+ case CONSTANT_TRANSITION:
2018
+ case NULL_DESCRIPTOR:
2019
+ // Ignore non-properties.
2020
+ break;
2021
+ case NORMAL:
2022
+ // Do not occur since the from object has fast properties.
2023
+ case HANDLER:
2024
+ case INTERCEPTOR:
2025
+ // No element in instance descriptors have proxy or interceptor type.
2026
+ UNREACHABLE();
2027
+ break;
2028
+ }
2029
+ }
2030
+ } else {
2031
+ Handle<StringDictionary> properties =
2032
+ Handle<StringDictionary>(from->property_dictionary());
2033
+ int capacity = properties->Capacity();
2034
+ for (int i = 0; i < capacity; i++) {
2035
+ Object* raw_key(properties->KeyAt(i));
2036
+ if (properties->IsKey(raw_key)) {
2037
+ ASSERT(raw_key->IsString());
2038
+ // If the property is already there we skip it.
2039
+ LookupResult result;
2040
+ to->LocalLookup(String::cast(raw_key), &result);
2041
+ if (result.IsProperty()) continue;
2042
+ // Set the property.
2043
+ Handle<String> key = Handle<String>(String::cast(raw_key));
2044
+ Handle<Object> value = Handle<Object>(properties->ValueAt(i));
2045
+ if (value->IsJSGlobalPropertyCell()) {
2046
+ value = Handle<Object>(JSGlobalPropertyCell::cast(*value)->value());
2047
+ }
2048
+ PropertyDetails details = properties->DetailsAt(i);
2049
+ SetLocalPropertyNoThrow(to, key, value, details.attributes());
2050
+ }
2051
+ }
2052
+ }
2053
+ }
2054
+
2055
+
2056
+ void Genesis::TransferIndexedProperties(Handle<JSObject> from,
2057
+ Handle<JSObject> to) {
2058
+ // Cloning the elements array is sufficient.
2059
+ Handle<FixedArray> from_elements =
2060
+ Handle<FixedArray>(FixedArray::cast(from->elements()));
2061
+ Handle<FixedArray> to_elements = FACTORY->CopyFixedArray(from_elements);
2062
+ to->set_elements(*to_elements);
2063
+ }
2064
+
2065
+
2066
+ void Genesis::TransferObject(Handle<JSObject> from, Handle<JSObject> to) {
2067
+ HandleScope outer;
2068
+ Factory* factory = from->GetIsolate()->factory();
2069
+
2070
+ ASSERT(!from->IsJSArray());
2071
+ ASSERT(!to->IsJSArray());
2072
+
2073
+ TransferNamedProperties(from, to);
2074
+ TransferIndexedProperties(from, to);
2075
+
2076
+ // Transfer the prototype (new map is needed).
2077
+ Handle<Map> old_to_map = Handle<Map>(to->map());
2078
+ Handle<Map> new_to_map = factory->CopyMapDropTransitions(old_to_map);
2079
+ new_to_map->set_prototype(from->map()->prototype());
2080
+ to->set_map(*new_to_map);
2081
+ }
2082
+
2083
+
2084
+ void Genesis::MakeFunctionInstancePrototypeWritable() {
2085
+ // The maps with writable prototype are created in CreateEmptyFunction
2086
+ // and CreateStrictModeFunctionMaps respectively. Initially the maps are
2087
+ // created with read-only prototype for JS builtins processing.
2088
+ ASSERT(!function_instance_map_writable_prototype_.is_null());
2089
+ ASSERT(!strict_mode_function_instance_map_writable_prototype_.is_null());
2090
+
2091
+ // Replace function instance maps to make prototype writable.
2092
+ global_context()->set_function_map(
2093
+ *function_instance_map_writable_prototype_);
2094
+ global_context()->set_strict_mode_function_map(
2095
+ *strict_mode_function_instance_map_writable_prototype_);
2096
+ }
2097
+
2098
+
2099
+ Genesis::Genesis(Isolate* isolate,
2100
+ Handle<Object> global_object,
2101
+ v8::Handle<v8::ObjectTemplate> global_template,
2102
+ v8::ExtensionConfiguration* extensions) : isolate_(isolate) {
2103
+ result_ = Handle<Context>::null();
2104
+ // If V8 isn't running and cannot be initialized, just return.
2105
+ if (!V8::IsRunning() && !V8::Initialize(NULL)) return;
2106
+
2107
+ // Before creating the roots we must save the context and restore it
2108
+ // on all function exits.
2109
+ HandleScope scope;
2110
+ SaveContext saved_context(isolate);
2111
+
2112
+ Handle<Context> new_context = Snapshot::NewContextFromSnapshot();
2113
+ if (!new_context.is_null()) {
2114
+ global_context_ =
2115
+ Handle<Context>::cast(isolate->global_handles()->Create(*new_context));
2116
+ AddToWeakGlobalContextList(*global_context_);
2117
+ isolate->set_context(*global_context_);
2118
+ isolate->counters()->contexts_created_by_snapshot()->Increment();
2119
+ Handle<GlobalObject> inner_global;
2120
+ Handle<JSGlobalProxy> global_proxy =
2121
+ CreateNewGlobals(global_template,
2122
+ global_object,
2123
+ &inner_global);
2124
+
2125
+ HookUpGlobalProxy(inner_global, global_proxy);
2126
+ HookUpInnerGlobal(inner_global);
2127
+
2128
+ if (!ConfigureGlobalObjects(global_template)) return;
2129
+ } else {
2130
+ // We get here if there was no context snapshot.
2131
+ CreateRoots();
2132
+ Handle<JSFunction> empty_function = CreateEmptyFunction(isolate);
2133
+ CreateStrictModeFunctionMaps(empty_function);
2134
+ Handle<GlobalObject> inner_global;
2135
+ Handle<JSGlobalProxy> global_proxy =
2136
+ CreateNewGlobals(global_template, global_object, &inner_global);
2137
+ HookUpGlobalProxy(inner_global, global_proxy);
2138
+ InitializeGlobal(inner_global, empty_function);
2139
+ InstallJSFunctionResultCaches();
2140
+ InitializeNormalizedMapCaches();
2141
+ if (!InstallNatives()) return;
2142
+
2143
+ MakeFunctionInstancePrototypeWritable();
2144
+
2145
+ if (!ConfigureGlobalObjects(global_template)) return;
2146
+ isolate->counters()->contexts_created_from_scratch()->Increment();
2147
+ }
2148
+
2149
+ // Install experimental natives.
2150
+ if (!InstallExperimentalNatives()) return;
2151
+
2152
+ result_ = global_context_;
2153
+ }
2154
+
2155
+
2156
+ // Support for thread preemption.
2157
+
2158
+ // Reserve space for statics needing saving and restoring.
2159
+ int Bootstrapper::ArchiveSpacePerThread() {
2160
+ return sizeof(NestingCounterType);
2161
+ }
2162
+
2163
+
2164
+ // Archive statics that are thread local.
2165
+ char* Bootstrapper::ArchiveState(char* to) {
2166
+ *reinterpret_cast<NestingCounterType*>(to) = nesting_;
2167
+ nesting_ = 0;
2168
+ return to + sizeof(NestingCounterType);
2169
+ }
2170
+
2171
+
2172
+ // Restore statics that are thread local.
2173
+ char* Bootstrapper::RestoreState(char* from) {
2174
+ nesting_ = *reinterpret_cast<NestingCounterType*>(from);
2175
+ return from + sizeof(NestingCounterType);
2176
+ }
2177
+
2178
+
2179
+ // Called when the top-level V8 mutex is destroyed.
2180
+ void Bootstrapper::FreeThreadResources() {
2181
+ ASSERT(!IsActive());
2182
+ }
2183
+
2184
+ } } // namespace v8::internal