libv8 3.3.10.4 → 3.5.10.beta1

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 (538) hide show
  1. data/lib/libv8/scons/CHANGES.txt +24 -231
  2. data/lib/libv8/scons/LICENSE.txt +1 -1
  3. data/lib/libv8/scons/MANIFEST +0 -1
  4. data/lib/libv8/scons/PKG-INFO +1 -1
  5. data/lib/libv8/scons/README.txt +9 -9
  6. data/lib/libv8/scons/RELEASE.txt +75 -77
  7. data/lib/libv8/scons/engine/SCons/Action.py +6 -22
  8. data/lib/libv8/scons/engine/SCons/Builder.py +2 -2
  9. data/lib/libv8/scons/engine/SCons/CacheDir.py +2 -2
  10. data/lib/libv8/scons/engine/SCons/Debug.py +2 -2
  11. data/lib/libv8/scons/engine/SCons/Defaults.py +10 -24
  12. data/lib/libv8/scons/engine/SCons/Environment.py +19 -118
  13. data/lib/libv8/scons/engine/SCons/Errors.py +2 -2
  14. data/lib/libv8/scons/engine/SCons/Executor.py +2 -2
  15. data/lib/libv8/scons/engine/SCons/Job.py +2 -2
  16. data/lib/libv8/scons/engine/SCons/Memoize.py +2 -2
  17. data/lib/libv8/scons/engine/SCons/Node/Alias.py +2 -2
  18. data/lib/libv8/scons/engine/SCons/Node/FS.py +121 -281
  19. data/lib/libv8/scons/engine/SCons/Node/Python.py +2 -2
  20. data/lib/libv8/scons/engine/SCons/Node/__init__.py +5 -6
  21. data/lib/libv8/scons/engine/SCons/Options/BoolOption.py +2 -2
  22. data/lib/libv8/scons/engine/SCons/Options/EnumOption.py +2 -2
  23. data/lib/libv8/scons/engine/SCons/Options/ListOption.py +2 -2
  24. data/lib/libv8/scons/engine/SCons/Options/PackageOption.py +2 -2
  25. data/lib/libv8/scons/engine/SCons/Options/PathOption.py +2 -2
  26. data/lib/libv8/scons/engine/SCons/Options/__init__.py +2 -2
  27. data/lib/libv8/scons/engine/SCons/PathList.py +2 -2
  28. data/lib/libv8/scons/engine/SCons/Platform/__init__.py +2 -2
  29. data/lib/libv8/scons/engine/SCons/Platform/aix.py +2 -2
  30. data/lib/libv8/scons/engine/SCons/Platform/cygwin.py +2 -2
  31. data/lib/libv8/scons/engine/SCons/Platform/darwin.py +3 -27
  32. data/lib/libv8/scons/engine/SCons/Platform/hpux.py +2 -2
  33. data/lib/libv8/scons/engine/SCons/Platform/irix.py +2 -2
  34. data/lib/libv8/scons/engine/SCons/Platform/os2.py +2 -2
  35. data/lib/libv8/scons/engine/SCons/Platform/posix.py +2 -2
  36. data/lib/libv8/scons/engine/SCons/Platform/sunos.py +2 -2
  37. data/lib/libv8/scons/engine/SCons/Platform/win32.py +2 -2
  38. data/lib/libv8/scons/engine/SCons/SConf.py +2 -2
  39. data/lib/libv8/scons/engine/SCons/SConsign.py +3 -9
  40. data/lib/libv8/scons/engine/SCons/Scanner/C.py +2 -2
  41. data/lib/libv8/scons/engine/SCons/Scanner/D.py +2 -2
  42. data/lib/libv8/scons/engine/SCons/Scanner/Dir.py +2 -2
  43. data/lib/libv8/scons/engine/SCons/Scanner/Fortran.py +2 -2
  44. data/lib/libv8/scons/engine/SCons/Scanner/IDL.py +2 -2
  45. data/lib/libv8/scons/engine/SCons/Scanner/LaTeX.py +2 -5
  46. data/lib/libv8/scons/engine/SCons/Scanner/Prog.py +2 -2
  47. data/lib/libv8/scons/engine/SCons/Scanner/RC.py +3 -3
  48. data/lib/libv8/scons/engine/SCons/Scanner/__init__.py +2 -2
  49. data/lib/libv8/scons/engine/SCons/Script/Interactive.py +2 -2
  50. data/lib/libv8/scons/engine/SCons/Script/Main.py +11 -82
  51. data/lib/libv8/scons/engine/SCons/Script/SConsOptions.py +5 -5
  52. data/lib/libv8/scons/engine/SCons/Script/SConscript.py +2 -2
  53. data/lib/libv8/scons/engine/SCons/Script/__init__.py +2 -2
  54. data/lib/libv8/scons/engine/SCons/Sig.py +2 -2
  55. data/lib/libv8/scons/engine/SCons/Subst.py +2 -2
  56. data/lib/libv8/scons/engine/SCons/Taskmaster.py +2 -10
  57. data/lib/libv8/scons/engine/SCons/Tool/386asm.py +2 -2
  58. data/lib/libv8/scons/engine/SCons/Tool/BitKeeper.py +2 -2
  59. data/lib/libv8/scons/engine/SCons/Tool/CVS.py +2 -2
  60. data/lib/libv8/scons/engine/SCons/Tool/FortranCommon.py +2 -19
  61. data/lib/libv8/scons/engine/SCons/Tool/JavaCommon.py +2 -2
  62. data/lib/libv8/scons/engine/SCons/Tool/MSCommon/__init__.py +2 -2
  63. data/lib/libv8/scons/engine/SCons/Tool/MSCommon/arch.py +2 -2
  64. data/lib/libv8/scons/engine/SCons/Tool/MSCommon/common.py +2 -2
  65. data/lib/libv8/scons/engine/SCons/Tool/MSCommon/netframework.py +2 -2
  66. data/lib/libv8/scons/engine/SCons/Tool/MSCommon/sdk.py +2 -2
  67. data/lib/libv8/scons/engine/SCons/Tool/MSCommon/vc.py +6 -9
  68. data/lib/libv8/scons/engine/SCons/Tool/MSCommon/vs.py +2 -29
  69. data/lib/libv8/scons/engine/SCons/Tool/Perforce.py +2 -2
  70. data/lib/libv8/scons/engine/SCons/Tool/PharLapCommon.py +2 -2
  71. data/lib/libv8/scons/engine/SCons/Tool/RCS.py +2 -2
  72. data/lib/libv8/scons/engine/SCons/Tool/SCCS.py +2 -2
  73. data/lib/libv8/scons/engine/SCons/Tool/Subversion.py +2 -2
  74. data/lib/libv8/scons/engine/SCons/Tool/__init__.py +3 -3
  75. data/lib/libv8/scons/engine/SCons/Tool/aixc++.py +2 -2
  76. data/lib/libv8/scons/engine/SCons/Tool/aixcc.py +2 -2
  77. data/lib/libv8/scons/engine/SCons/Tool/aixf77.py +2 -2
  78. data/lib/libv8/scons/engine/SCons/Tool/aixlink.py +2 -2
  79. data/lib/libv8/scons/engine/SCons/Tool/applelink.py +2 -2
  80. data/lib/libv8/scons/engine/SCons/Tool/ar.py +2 -2
  81. data/lib/libv8/scons/engine/SCons/Tool/as.py +2 -2
  82. data/lib/libv8/scons/engine/SCons/Tool/bcc32.py +2 -2
  83. data/lib/libv8/scons/engine/SCons/Tool/c++.py +2 -2
  84. data/lib/libv8/scons/engine/SCons/Tool/cc.py +2 -2
  85. data/lib/libv8/scons/engine/SCons/Tool/cvf.py +2 -2
  86. data/lib/libv8/scons/engine/SCons/Tool/default.py +2 -2
  87. data/lib/libv8/scons/engine/SCons/Tool/dmd.py +7 -24
  88. data/lib/libv8/scons/engine/SCons/Tool/dvi.py +2 -2
  89. data/lib/libv8/scons/engine/SCons/Tool/dvipdf.py +2 -3
  90. data/lib/libv8/scons/engine/SCons/Tool/dvips.py +2 -3
  91. data/lib/libv8/scons/engine/SCons/Tool/f77.py +2 -2
  92. data/lib/libv8/scons/engine/SCons/Tool/f90.py +2 -2
  93. data/lib/libv8/scons/engine/SCons/Tool/f95.py +2 -2
  94. data/lib/libv8/scons/engine/SCons/Tool/filesystem.py +2 -2
  95. data/lib/libv8/scons/engine/SCons/Tool/fortran.py +2 -2
  96. data/lib/libv8/scons/engine/SCons/Tool/g++.py +2 -2
  97. data/lib/libv8/scons/engine/SCons/Tool/g77.py +2 -2
  98. data/lib/libv8/scons/engine/SCons/Tool/gas.py +2 -2
  99. data/lib/libv8/scons/engine/SCons/Tool/gcc.py +2 -2
  100. data/lib/libv8/scons/engine/SCons/Tool/gfortran.py +3 -3
  101. data/lib/libv8/scons/engine/SCons/Tool/gnulink.py +3 -2
  102. data/lib/libv8/scons/engine/SCons/Tool/gs.py +2 -2
  103. data/lib/libv8/scons/engine/SCons/Tool/hpc++.py +2 -2
  104. data/lib/libv8/scons/engine/SCons/Tool/hpcc.py +2 -2
  105. data/lib/libv8/scons/engine/SCons/Tool/hplink.py +2 -2
  106. data/lib/libv8/scons/engine/SCons/Tool/icc.py +2 -2
  107. data/lib/libv8/scons/engine/SCons/Tool/icl.py +2 -2
  108. data/lib/libv8/scons/engine/SCons/Tool/ifl.py +2 -2
  109. data/lib/libv8/scons/engine/SCons/Tool/ifort.py +2 -2
  110. data/lib/libv8/scons/engine/SCons/Tool/ilink.py +2 -2
  111. data/lib/libv8/scons/engine/SCons/Tool/ilink32.py +2 -2
  112. data/lib/libv8/scons/engine/SCons/Tool/install.py +3 -57
  113. data/lib/libv8/scons/engine/SCons/Tool/intelc.py +25 -65
  114. data/lib/libv8/scons/engine/SCons/Tool/ipkg.py +2 -2
  115. data/lib/libv8/scons/engine/SCons/Tool/jar.py +3 -9
  116. data/lib/libv8/scons/engine/SCons/Tool/javac.py +2 -2
  117. data/lib/libv8/scons/engine/SCons/Tool/javah.py +2 -2
  118. data/lib/libv8/scons/engine/SCons/Tool/latex.py +2 -3
  119. data/lib/libv8/scons/engine/SCons/Tool/lex.py +2 -2
  120. data/lib/libv8/scons/engine/SCons/Tool/link.py +5 -6
  121. data/lib/libv8/scons/engine/SCons/Tool/linkloc.py +2 -2
  122. data/lib/libv8/scons/engine/SCons/Tool/m4.py +2 -2
  123. data/lib/libv8/scons/engine/SCons/Tool/masm.py +2 -2
  124. data/lib/libv8/scons/engine/SCons/Tool/midl.py +2 -2
  125. data/lib/libv8/scons/engine/SCons/Tool/mingw.py +10 -31
  126. data/lib/libv8/scons/engine/SCons/Tool/mslib.py +2 -2
  127. data/lib/libv8/scons/engine/SCons/Tool/mslink.py +9 -61
  128. data/lib/libv8/scons/engine/SCons/Tool/mssdk.py +2 -2
  129. data/lib/libv8/scons/engine/SCons/Tool/msvc.py +11 -21
  130. data/lib/libv8/scons/engine/SCons/Tool/msvs.py +59 -477
  131. data/lib/libv8/scons/engine/SCons/Tool/mwcc.py +2 -2
  132. data/lib/libv8/scons/engine/SCons/Tool/mwld.py +2 -2
  133. data/lib/libv8/scons/engine/SCons/Tool/nasm.py +2 -2
  134. data/lib/libv8/scons/engine/SCons/Tool/packaging/__init__.py +2 -2
  135. data/lib/libv8/scons/engine/SCons/Tool/packaging/ipk.py +2 -2
  136. data/lib/libv8/scons/engine/SCons/Tool/packaging/msi.py +2 -2
  137. data/lib/libv8/scons/engine/SCons/Tool/packaging/rpm.py +2 -2
  138. data/lib/libv8/scons/engine/SCons/Tool/packaging/src_tarbz2.py +2 -2
  139. data/lib/libv8/scons/engine/SCons/Tool/packaging/src_targz.py +2 -2
  140. data/lib/libv8/scons/engine/SCons/Tool/packaging/src_zip.py +2 -2
  141. data/lib/libv8/scons/engine/SCons/Tool/packaging/tarbz2.py +2 -2
  142. data/lib/libv8/scons/engine/SCons/Tool/packaging/targz.py +2 -2
  143. data/lib/libv8/scons/engine/SCons/Tool/packaging/zip.py +2 -2
  144. data/lib/libv8/scons/engine/SCons/Tool/pdf.py +2 -2
  145. data/lib/libv8/scons/engine/SCons/Tool/pdflatex.py +2 -3
  146. data/lib/libv8/scons/engine/SCons/Tool/pdftex.py +2 -3
  147. data/lib/libv8/scons/engine/SCons/Tool/qt.py +2 -2
  148. data/lib/libv8/scons/engine/SCons/Tool/rmic.py +3 -9
  149. data/lib/libv8/scons/engine/SCons/Tool/rpcgen.py +2 -2
  150. data/lib/libv8/scons/engine/SCons/Tool/rpm.py +2 -2
  151. data/lib/libv8/scons/engine/SCons/Tool/sgiar.py +2 -2
  152. data/lib/libv8/scons/engine/SCons/Tool/sgic++.py +2 -2
  153. data/lib/libv8/scons/engine/SCons/Tool/sgicc.py +2 -2
  154. data/lib/libv8/scons/engine/SCons/Tool/sgilink.py +3 -2
  155. data/lib/libv8/scons/engine/SCons/Tool/sunar.py +2 -2
  156. data/lib/libv8/scons/engine/SCons/Tool/sunc++.py +2 -2
  157. data/lib/libv8/scons/engine/SCons/Tool/suncc.py +2 -2
  158. data/lib/libv8/scons/engine/SCons/Tool/sunf77.py +2 -2
  159. data/lib/libv8/scons/engine/SCons/Tool/sunf90.py +2 -2
  160. data/lib/libv8/scons/engine/SCons/Tool/sunf95.py +2 -2
  161. data/lib/libv8/scons/engine/SCons/Tool/sunlink.py +3 -2
  162. data/lib/libv8/scons/engine/SCons/Tool/swig.py +5 -6
  163. data/lib/libv8/scons/engine/SCons/Tool/tar.py +2 -2
  164. data/lib/libv8/scons/engine/SCons/Tool/tex.py +43 -96
  165. data/lib/libv8/scons/engine/SCons/Tool/textfile.py +2 -2
  166. data/lib/libv8/scons/engine/SCons/Tool/tlib.py +2 -2
  167. data/lib/libv8/scons/engine/SCons/Tool/wix.py +2 -2
  168. data/lib/libv8/scons/engine/SCons/Tool/yacc.py +2 -12
  169. data/lib/libv8/scons/engine/SCons/Tool/zip.py +2 -2
  170. data/lib/libv8/scons/engine/SCons/Util.py +3 -3
  171. data/lib/libv8/scons/engine/SCons/Variables/BoolVariable.py +2 -2
  172. data/lib/libv8/scons/engine/SCons/Variables/EnumVariable.py +3 -3
  173. data/lib/libv8/scons/engine/SCons/Variables/ListVariable.py +2 -2
  174. data/lib/libv8/scons/engine/SCons/Variables/PackageVariable.py +2 -2
  175. data/lib/libv8/scons/engine/SCons/Variables/PathVariable.py +2 -2
  176. data/lib/libv8/scons/engine/SCons/Variables/__init__.py +2 -2
  177. data/lib/libv8/scons/engine/SCons/Warnings.py +2 -2
  178. data/lib/libv8/scons/engine/SCons/__init__.py +6 -6
  179. data/lib/libv8/scons/engine/SCons/compat/__init__.py +2 -2
  180. data/lib/libv8/scons/engine/SCons/compat/_scons_builtins.py +2 -2
  181. data/lib/libv8/scons/engine/SCons/compat/_scons_collections.py +2 -2
  182. data/lib/libv8/scons/engine/SCons/compat/_scons_dbm.py +2 -2
  183. data/lib/libv8/scons/engine/SCons/compat/_scons_hashlib.py +2 -2
  184. data/lib/libv8/scons/engine/SCons/compat/_scons_io.py +2 -2
  185. data/lib/libv8/scons/engine/SCons/cpp.py +2 -2
  186. data/lib/libv8/scons/engine/SCons/dblite.py +1 -4
  187. data/lib/libv8/scons/engine/SCons/exitfuncs.py +2 -2
  188. data/lib/libv8/scons/scons-time.1 +3 -3
  189. data/lib/libv8/scons/scons.1 +1164 -1170
  190. data/lib/libv8/scons/sconsign.1 +3 -3
  191. data/lib/libv8/scons/script/scons +22 -22
  192. data/lib/libv8/scons/script/scons-time +2 -2
  193. data/lib/libv8/scons/script/scons.bat +4 -7
  194. data/lib/libv8/scons/script/sconsign +20 -21
  195. data/lib/libv8/scons/setup.cfg +1 -0
  196. data/lib/libv8/scons/setup.py +40 -38
  197. data/lib/libv8/v8/.gitignore +1 -1
  198. data/lib/libv8/v8/AUTHORS +2 -0
  199. data/lib/libv8/v8/ChangeLog +387 -0
  200. data/lib/libv8/v8/Makefile +171 -0
  201. data/lib/libv8/v8/SConstruct +124 -51
  202. data/lib/libv8/v8/build/README.txt +31 -14
  203. data/lib/libv8/v8/build/all.gyp +11 -4
  204. data/lib/libv8/v8/build/armu.gypi +6 -2
  205. data/lib/libv8/v8/build/common.gypi +240 -94
  206. data/lib/libv8/v8/build/gyp_v8 +32 -4
  207. data/lib/libv8/v8/build/standalone.gypi +200 -0
  208. data/lib/libv8/v8/include/v8-debug.h +0 -0
  209. data/lib/libv8/v8/include/v8-profiler.h +8 -11
  210. data/lib/libv8/v8/include/v8.h +191 -108
  211. data/lib/libv8/v8/preparser/SConscript +2 -2
  212. data/lib/libv8/v8/preparser/preparser-process.cc +3 -3
  213. data/lib/libv8/v8/preparser/preparser.gyp +42 -0
  214. data/lib/libv8/v8/src/SConscript +33 -8
  215. data/lib/libv8/v8/src/accessors.cc +77 -43
  216. data/lib/libv8/v8/src/api.cc +393 -191
  217. data/lib/libv8/v8/src/api.h +4 -8
  218. data/lib/libv8/v8/src/apinatives.js +15 -3
  219. data/lib/libv8/v8/src/arguments.h +8 -0
  220. data/lib/libv8/v8/src/arm/assembler-arm.cc +120 -120
  221. data/lib/libv8/v8/src/arm/assembler-arm.h +92 -43
  222. data/lib/libv8/v8/src/arm/builtins-arm.cc +32 -39
  223. data/lib/libv8/v8/src/arm/code-stubs-arm.cc +572 -351
  224. data/lib/libv8/v8/src/arm/code-stubs-arm.h +8 -77
  225. data/lib/libv8/v8/src/arm/codegen-arm.h +0 -2
  226. data/lib/libv8/v8/src/arm/deoptimizer-arm.cc +50 -30
  227. data/lib/libv8/v8/src/arm/disasm-arm.cc +1 -1
  228. data/lib/libv8/v8/src/arm/frames-arm.h +9 -5
  229. data/lib/libv8/v8/src/arm/full-codegen-arm.cc +331 -432
  230. data/lib/libv8/v8/src/arm/ic-arm.cc +192 -124
  231. data/lib/libv8/v8/src/arm/lithium-arm.cc +216 -232
  232. data/lib/libv8/v8/src/arm/lithium-arm.h +106 -259
  233. data/lib/libv8/v8/src/arm/lithium-codegen-arm.cc +633 -642
  234. data/lib/libv8/v8/src/arm/lithium-codegen-arm.h +4 -4
  235. data/lib/libv8/v8/src/arm/lithium-gap-resolver-arm.cc +1 -3
  236. data/lib/libv8/v8/src/arm/macro-assembler-arm.cc +260 -185
  237. data/lib/libv8/v8/src/arm/macro-assembler-arm.h +45 -25
  238. data/lib/libv8/v8/src/arm/regexp-macro-assembler-arm.cc +25 -13
  239. data/lib/libv8/v8/src/arm/regexp-macro-assembler-arm.h +3 -0
  240. data/lib/libv8/v8/src/arm/stub-cache-arm.cc +413 -226
  241. data/lib/libv8/v8/src/array.js +38 -18
  242. data/lib/libv8/v8/src/assembler.cc +12 -5
  243. data/lib/libv8/v8/src/assembler.h +15 -9
  244. data/lib/libv8/v8/src/ast-inl.h +34 -25
  245. data/lib/libv8/v8/src/ast.cc +141 -72
  246. data/lib/libv8/v8/src/ast.h +255 -181
  247. data/lib/libv8/v8/src/bignum.cc +3 -4
  248. data/lib/libv8/v8/src/bootstrapper.cc +55 -11
  249. data/lib/libv8/v8/src/bootstrapper.h +3 -2
  250. data/lib/libv8/v8/src/builtins.cc +8 -2
  251. data/lib/libv8/v8/src/builtins.h +4 -0
  252. data/lib/libv8/v8/src/cached-powers.cc +8 -4
  253. data/lib/libv8/v8/src/checks.h +3 -3
  254. data/lib/libv8/v8/src/code-stubs.cc +173 -28
  255. data/lib/libv8/v8/src/code-stubs.h +104 -148
  256. data/lib/libv8/v8/src/codegen.cc +8 -8
  257. data/lib/libv8/v8/src/compilation-cache.cc +2 -47
  258. data/lib/libv8/v8/src/compilation-cache.h +0 -10
  259. data/lib/libv8/v8/src/compiler.cc +27 -16
  260. data/lib/libv8/v8/src/compiler.h +13 -18
  261. data/lib/libv8/v8/src/contexts.cc +107 -72
  262. data/lib/libv8/v8/src/contexts.h +70 -34
  263. data/lib/libv8/v8/src/conversions-inl.h +572 -14
  264. data/lib/libv8/v8/src/conversions.cc +9 -707
  265. data/lib/libv8/v8/src/conversions.h +23 -12
  266. data/lib/libv8/v8/src/cpu-profiler-inl.h +2 -19
  267. data/lib/libv8/v8/src/cpu-profiler.cc +4 -21
  268. data/lib/libv8/v8/src/cpu-profiler.h +8 -17
  269. data/lib/libv8/v8/src/d8-debug.cc +5 -3
  270. data/lib/libv8/v8/src/d8-debug.h +6 -7
  271. data/lib/libv8/v8/src/d8-posix.cc +1 -10
  272. data/lib/libv8/v8/src/d8.cc +721 -219
  273. data/lib/libv8/v8/src/d8.gyp +37 -12
  274. data/lib/libv8/v8/src/d8.h +141 -19
  275. data/lib/libv8/v8/src/d8.js +17 -8
  276. data/lib/libv8/v8/src/date.js +16 -5
  277. data/lib/libv8/v8/src/dateparser-inl.h +242 -39
  278. data/lib/libv8/v8/src/dateparser.cc +38 -4
  279. data/lib/libv8/v8/src/dateparser.h +170 -28
  280. data/lib/libv8/v8/src/debug-agent.cc +5 -3
  281. data/lib/libv8/v8/src/debug-agent.h +11 -7
  282. data/lib/libv8/v8/src/debug-debugger.js +65 -34
  283. data/lib/libv8/v8/src/debug.cc +30 -60
  284. data/lib/libv8/v8/src/debug.h +5 -3
  285. data/lib/libv8/v8/src/deoptimizer.cc +227 -10
  286. data/lib/libv8/v8/src/deoptimizer.h +133 -9
  287. data/lib/libv8/v8/src/disassembler.cc +22 -14
  288. data/lib/libv8/v8/src/diy-fp.cc +4 -3
  289. data/lib/libv8/v8/src/diy-fp.h +3 -3
  290. data/lib/libv8/v8/src/elements.cc +634 -0
  291. data/lib/libv8/v8/src/elements.h +95 -0
  292. data/lib/libv8/v8/src/execution.cc +5 -21
  293. data/lib/libv8/v8/src/extensions/experimental/break-iterator.cc +3 -1
  294. data/lib/libv8/v8/src/extensions/experimental/break-iterator.h +1 -1
  295. data/lib/libv8/v8/src/extensions/experimental/collator.cc +6 -2
  296. data/lib/libv8/v8/src/extensions/experimental/collator.h +1 -2
  297. data/lib/libv8/v8/src/extensions/experimental/datetime-format.cc +384 -0
  298. data/lib/libv8/v8/src/extensions/experimental/datetime-format.h +83 -0
  299. data/lib/libv8/v8/src/extensions/experimental/experimental.gyp +18 -7
  300. data/lib/libv8/v8/src/extensions/experimental/i18n-extension.cc +12 -16
  301. data/lib/libv8/v8/src/extensions/experimental/i18n-extension.h +1 -1
  302. data/lib/libv8/v8/src/extensions/experimental/i18n-js2c.py +126 -0
  303. data/lib/libv8/v8/src/extensions/experimental/i18n-locale.cc +3 -4
  304. data/lib/libv8/v8/src/extensions/experimental/i18n-locale.h +1 -1
  305. data/lib/libv8/v8/src/{shell.h → extensions/experimental/i18n-natives.h} +8 -20
  306. data/lib/libv8/v8/src/extensions/experimental/i18n-utils.cc +45 -1
  307. data/lib/libv8/v8/src/extensions/experimental/i18n-utils.h +21 -1
  308. data/lib/libv8/v8/src/extensions/experimental/i18n.js +211 -11
  309. data/lib/libv8/v8/src/extensions/experimental/language-matcher.cc +4 -3
  310. data/lib/libv8/v8/src/extensions/experimental/language-matcher.h +1 -1
  311. data/lib/libv8/v8/src/extensions/experimental/number-format.cc +374 -0
  312. data/lib/libv8/v8/src/extensions/experimental/number-format.h +71 -0
  313. data/lib/libv8/v8/src/factory.cc +89 -18
  314. data/lib/libv8/v8/src/factory.h +36 -8
  315. data/lib/libv8/v8/src/flag-definitions.h +11 -44
  316. data/lib/libv8/v8/src/frames-inl.h +8 -1
  317. data/lib/libv8/v8/src/frames.cc +39 -3
  318. data/lib/libv8/v8/src/frames.h +10 -3
  319. data/lib/libv8/v8/src/full-codegen.cc +311 -293
  320. data/lib/libv8/v8/src/full-codegen.h +183 -143
  321. data/lib/libv8/v8/src/func-name-inferrer.cc +29 -15
  322. data/lib/libv8/v8/src/func-name-inferrer.h +19 -9
  323. data/lib/libv8/v8/src/gdb-jit.cc +658 -55
  324. data/lib/libv8/v8/src/gdb-jit.h +6 -2
  325. data/lib/libv8/v8/src/global-handles.cc +368 -312
  326. data/lib/libv8/v8/src/global-handles.h +29 -36
  327. data/lib/libv8/v8/src/globals.h +3 -1
  328. data/lib/libv8/v8/src/handles.cc +43 -69
  329. data/lib/libv8/v8/src/handles.h +21 -16
  330. data/lib/libv8/v8/src/heap-inl.h +11 -13
  331. data/lib/libv8/v8/src/heap-profiler.cc +0 -999
  332. data/lib/libv8/v8/src/heap-profiler.h +0 -303
  333. data/lib/libv8/v8/src/heap.cc +366 -141
  334. data/lib/libv8/v8/src/heap.h +87 -26
  335. data/lib/libv8/v8/src/hydrogen-instructions.cc +192 -81
  336. data/lib/libv8/v8/src/hydrogen-instructions.h +711 -482
  337. data/lib/libv8/v8/src/hydrogen.cc +1146 -629
  338. data/lib/libv8/v8/src/hydrogen.h +100 -64
  339. data/lib/libv8/v8/src/ia32/assembler-ia32.cc +19 -0
  340. data/lib/libv8/v8/src/ia32/assembler-ia32.h +15 -2
  341. data/lib/libv8/v8/src/ia32/builtins-ia32.cc +34 -39
  342. data/lib/libv8/v8/src/ia32/code-stubs-ia32.cc +675 -377
  343. data/lib/libv8/v8/src/ia32/code-stubs-ia32.h +8 -69
  344. data/lib/libv8/v8/src/ia32/codegen-ia32.cc +1 -0
  345. data/lib/libv8/v8/src/ia32/codegen-ia32.h +0 -2
  346. data/lib/libv8/v8/src/ia32/cpu-ia32.cc +3 -2
  347. data/lib/libv8/v8/src/ia32/deoptimizer-ia32.cc +28 -3
  348. data/lib/libv8/v8/src/ia32/disasm-ia32.cc +21 -10
  349. data/lib/libv8/v8/src/ia32/frames-ia32.h +6 -5
  350. data/lib/libv8/v8/src/ia32/full-codegen-ia32.cc +459 -465
  351. data/lib/libv8/v8/src/ia32/ic-ia32.cc +196 -147
  352. data/lib/libv8/v8/src/ia32/lithium-codegen-ia32.cc +575 -650
  353. data/lib/libv8/v8/src/ia32/lithium-codegen-ia32.h +19 -21
  354. data/lib/libv8/v8/src/ia32/lithium-gap-resolver-ia32.cc +7 -2
  355. data/lib/libv8/v8/src/ia32/lithium-ia32.cc +261 -256
  356. data/lib/libv8/v8/src/ia32/lithium-ia32.h +234 -335
  357. data/lib/libv8/v8/src/ia32/macro-assembler-ia32.cc +224 -67
  358. data/lib/libv8/v8/src/ia32/macro-assembler-ia32.h +63 -19
  359. data/lib/libv8/v8/src/ia32/regexp-macro-assembler-ia32.cc +22 -8
  360. data/lib/libv8/v8/src/ia32/regexp-macro-assembler-ia32.h +3 -0
  361. data/lib/libv8/v8/src/ia32/stub-cache-ia32.cc +380 -239
  362. data/lib/libv8/v8/src/ic.cc +198 -234
  363. data/lib/libv8/v8/src/ic.h +32 -30
  364. data/lib/libv8/v8/src/interpreter-irregexp.cc +6 -4
  365. data/lib/libv8/v8/src/isolate.cc +112 -95
  366. data/lib/libv8/v8/src/isolate.h +55 -71
  367. data/lib/libv8/v8/src/json-parser.h +486 -48
  368. data/lib/libv8/v8/src/json.js +28 -23
  369. data/lib/libv8/v8/src/jsregexp.cc +163 -208
  370. data/lib/libv8/v8/src/jsregexp.h +0 -1
  371. data/lib/libv8/v8/src/lithium-allocator-inl.h +29 -27
  372. data/lib/libv8/v8/src/lithium-allocator.cc +22 -17
  373. data/lib/libv8/v8/src/lithium-allocator.h +8 -8
  374. data/lib/libv8/v8/src/lithium.cc +16 -11
  375. data/lib/libv8/v8/src/lithium.h +31 -34
  376. data/lib/libv8/v8/src/liveedit.cc +111 -15
  377. data/lib/libv8/v8/src/liveedit.h +3 -4
  378. data/lib/libv8/v8/src/liveobjectlist.cc +116 -80
  379. data/lib/libv8/v8/src/liveobjectlist.h +2 -2
  380. data/lib/libv8/v8/src/log-inl.h +0 -4
  381. data/lib/libv8/v8/src/log-utils.cc +25 -143
  382. data/lib/libv8/v8/src/log-utils.h +13 -92
  383. data/lib/libv8/v8/src/log.cc +26 -249
  384. data/lib/libv8/v8/src/log.h +6 -17
  385. data/lib/libv8/v8/src/macros.py +9 -6
  386. data/lib/libv8/v8/src/mark-compact.cc +276 -56
  387. data/lib/libv8/v8/src/mark-compact.h +20 -0
  388. data/lib/libv8/v8/src/messages.js +93 -39
  389. data/lib/libv8/v8/src/mips/assembler-mips-inl.h +9 -3
  390. data/lib/libv8/v8/src/mips/assembler-mips.cc +297 -189
  391. data/lib/libv8/v8/src/mips/assembler-mips.h +121 -54
  392. data/lib/libv8/v8/src/mips/builtins-mips.cc +23 -24
  393. data/lib/libv8/v8/src/mips/code-stubs-mips.cc +484 -263
  394. data/lib/libv8/v8/src/mips/code-stubs-mips.h +8 -83
  395. data/lib/libv8/v8/src/mips/codegen-mips.h +0 -2
  396. data/lib/libv8/v8/src/mips/constants-mips.h +37 -11
  397. data/lib/libv8/v8/src/mips/deoptimizer-mips.cc +6 -1
  398. data/lib/libv8/v8/src/mips/frames-mips.h +8 -7
  399. data/lib/libv8/v8/src/mips/full-codegen-mips.cc +258 -419
  400. data/lib/libv8/v8/src/mips/ic-mips.cc +181 -121
  401. data/lib/libv8/v8/src/mips/macro-assembler-mips.cc +640 -382
  402. data/lib/libv8/v8/src/mips/macro-assembler-mips.h +94 -89
  403. data/lib/libv8/v8/src/mips/regexp-macro-assembler-mips.cc +23 -10
  404. data/lib/libv8/v8/src/mips/regexp-macro-assembler-mips.h +6 -1
  405. data/lib/libv8/v8/src/mips/simulator-mips.cc +249 -49
  406. data/lib/libv8/v8/src/mips/simulator-mips.h +25 -1
  407. data/lib/libv8/v8/src/mips/stub-cache-mips.cc +373 -161
  408. data/lib/libv8/v8/src/mirror-debugger.js +55 -8
  409. data/lib/libv8/v8/src/misc-intrinsics.h +89 -0
  410. data/lib/libv8/v8/src/mksnapshot.cc +36 -4
  411. data/lib/libv8/v8/src/natives.h +5 -2
  412. data/lib/libv8/v8/src/objects-debug.cc +73 -6
  413. data/lib/libv8/v8/src/objects-inl.h +529 -164
  414. data/lib/libv8/v8/src/objects-printer.cc +67 -12
  415. data/lib/libv8/v8/src/objects-visiting.cc +13 -2
  416. data/lib/libv8/v8/src/objects-visiting.h +41 -1
  417. data/lib/libv8/v8/src/objects.cc +2200 -1177
  418. data/lib/libv8/v8/src/objects.h +912 -283
  419. data/lib/libv8/v8/src/parser.cc +566 -371
  420. data/lib/libv8/v8/src/parser.h +35 -33
  421. data/lib/libv8/v8/src/platform-cygwin.cc +10 -25
  422. data/lib/libv8/v8/src/platform-freebsd.cc +4 -29
  423. data/lib/libv8/v8/src/platform-linux.cc +60 -57
  424. data/lib/libv8/v8/src/platform-macos.cc +4 -27
  425. data/lib/libv8/v8/src/platform-nullos.cc +3 -16
  426. data/lib/libv8/v8/src/platform-openbsd.cc +247 -85
  427. data/lib/libv8/v8/src/platform-posix.cc +43 -1
  428. data/lib/libv8/v8/src/platform-solaris.cc +151 -112
  429. data/lib/libv8/v8/src/platform-tls.h +1 -1
  430. data/lib/libv8/v8/src/platform-win32.cc +65 -39
  431. data/lib/libv8/v8/src/platform.h +17 -14
  432. data/lib/libv8/v8/src/preparse-data-format.h +2 -2
  433. data/lib/libv8/v8/src/preparse-data.h +8 -2
  434. data/lib/libv8/v8/src/preparser-api.cc +2 -18
  435. data/lib/libv8/v8/src/preparser.cc +106 -65
  436. data/lib/libv8/v8/src/preparser.h +26 -5
  437. data/lib/libv8/v8/src/prettyprinter.cc +25 -43
  438. data/lib/libv8/v8/src/profile-generator-inl.h +0 -4
  439. data/lib/libv8/v8/src/profile-generator.cc +213 -34
  440. data/lib/libv8/v8/src/profile-generator.h +9 -9
  441. data/lib/libv8/v8/src/property.h +1 -0
  442. data/lib/libv8/v8/src/proxy.js +74 -4
  443. data/lib/libv8/v8/src/regexp-macro-assembler.cc +10 -6
  444. data/lib/libv8/v8/src/regexp.js +16 -11
  445. data/lib/libv8/v8/src/rewriter.cc +24 -133
  446. data/lib/libv8/v8/src/runtime-profiler.cc +27 -151
  447. data/lib/libv8/v8/src/runtime-profiler.h +5 -31
  448. data/lib/libv8/v8/src/runtime.cc +1450 -681
  449. data/lib/libv8/v8/src/runtime.h +47 -31
  450. data/lib/libv8/v8/src/runtime.js +2 -1
  451. data/lib/libv8/v8/src/scanner-base.cc +358 -220
  452. data/lib/libv8/v8/src/scanner-base.h +30 -138
  453. data/lib/libv8/v8/src/scanner.cc +0 -18
  454. data/lib/libv8/v8/src/scanner.h +0 -15
  455. data/lib/libv8/v8/src/scopeinfo.cc +3 -1
  456. data/lib/libv8/v8/src/scopeinfo.h +1 -6
  457. data/lib/libv8/v8/src/scopes.cc +243 -253
  458. data/lib/libv8/v8/src/scopes.h +58 -109
  459. data/lib/libv8/v8/src/serialize.cc +12 -54
  460. data/lib/libv8/v8/src/serialize.h +47 -0
  461. data/lib/libv8/v8/src/small-pointer-list.h +25 -0
  462. data/lib/libv8/v8/src/spaces-inl.h +4 -50
  463. data/lib/libv8/v8/src/spaces.cc +64 -131
  464. data/lib/libv8/v8/src/spaces.h +19 -70
  465. data/lib/libv8/v8/src/string-stream.cc +3 -1
  466. data/lib/libv8/v8/src/string.js +10 -6
  467. data/lib/libv8/v8/src/strtod.cc +7 -3
  468. data/lib/libv8/v8/src/stub-cache.cc +59 -129
  469. data/lib/libv8/v8/src/stub-cache.h +42 -54
  470. data/lib/libv8/v8/src/third_party/valgrind/valgrind.h +1447 -1339
  471. data/lib/libv8/v8/src/token.cc +4 -4
  472. data/lib/libv8/v8/src/token.h +6 -5
  473. data/lib/libv8/v8/src/type-info.cc +173 -129
  474. data/lib/libv8/v8/src/type-info.h +40 -22
  475. data/lib/libv8/v8/src/utils.cc +25 -304
  476. data/lib/libv8/v8/src/utils.h +118 -3
  477. data/lib/libv8/v8/src/v8-counters.h +3 -6
  478. data/lib/libv8/v8/src/v8.cc +34 -27
  479. data/lib/libv8/v8/src/v8.h +7 -7
  480. data/lib/libv8/v8/src/v8conversions.cc +129 -0
  481. data/lib/libv8/v8/src/v8conversions.h +60 -0
  482. data/lib/libv8/v8/src/v8globals.h +15 -6
  483. data/lib/libv8/v8/src/v8natives.js +300 -78
  484. data/lib/libv8/v8/src/v8threads.cc +14 -6
  485. data/lib/libv8/v8/src/v8threads.h +4 -1
  486. data/lib/libv8/v8/src/v8utils.cc +360 -0
  487. data/lib/libv8/v8/src/v8utils.h +17 -66
  488. data/lib/libv8/v8/src/variables.cc +7 -12
  489. data/lib/libv8/v8/src/variables.h +12 -10
  490. data/lib/libv8/v8/src/version.cc +2 -2
  491. data/lib/libv8/v8/src/vm-state-inl.h +0 -41
  492. data/lib/libv8/v8/src/vm-state.h +0 -11
  493. data/lib/libv8/v8/src/weakmap.js +103 -0
  494. data/lib/libv8/v8/src/x64/assembler-x64.h +6 -3
  495. data/lib/libv8/v8/src/x64/builtins-x64.cc +25 -22
  496. data/lib/libv8/v8/src/x64/code-stubs-x64.cc +523 -250
  497. data/lib/libv8/v8/src/x64/code-stubs-x64.h +8 -71
  498. data/lib/libv8/v8/src/x64/codegen-x64.cc +1 -0
  499. data/lib/libv8/v8/src/x64/codegen-x64.h +0 -2
  500. data/lib/libv8/v8/src/x64/cpu-x64.cc +2 -1
  501. data/lib/libv8/v8/src/x64/deoptimizer-x64.cc +40 -8
  502. data/lib/libv8/v8/src/x64/disasm-x64.cc +12 -10
  503. data/lib/libv8/v8/src/x64/frames-x64.h +7 -6
  504. data/lib/libv8/v8/src/x64/full-codegen-x64.cc +310 -415
  505. data/lib/libv8/v8/src/x64/ic-x64.cc +180 -117
  506. data/lib/libv8/v8/src/x64/lithium-codegen-x64.cc +411 -523
  507. data/lib/libv8/v8/src/x64/lithium-codegen-x64.h +11 -6
  508. data/lib/libv8/v8/src/x64/lithium-x64.cc +191 -216
  509. data/lib/libv8/v8/src/x64/lithium-x64.h +112 -263
  510. data/lib/libv8/v8/src/x64/macro-assembler-x64.cc +177 -61
  511. data/lib/libv8/v8/src/x64/macro-assembler-x64.h +23 -7
  512. data/lib/libv8/v8/src/x64/regexp-macro-assembler-x64.cc +21 -9
  513. data/lib/libv8/v8/src/x64/regexp-macro-assembler-x64.h +6 -0
  514. data/lib/libv8/v8/src/x64/stub-cache-x64.cc +273 -107
  515. data/lib/libv8/v8/src/zone.cc +31 -22
  516. data/lib/libv8/v8/src/zone.h +12 -6
  517. data/lib/libv8/v8/tools/codemap.js +8 -0
  518. data/lib/libv8/v8/tools/gcmole/Makefile +43 -0
  519. data/lib/libv8/v8/tools/gcmole/gcmole.lua +0 -2
  520. data/lib/libv8/v8/tools/gdb-v8-support.py +154 -0
  521. data/lib/libv8/v8/tools/grokdump.py +44 -35
  522. data/lib/libv8/v8/tools/gyp/v8.gyp +94 -248
  523. data/lib/libv8/v8/tools/js2c.py +83 -52
  524. data/lib/libv8/v8/tools/linux-tick-processor +4 -6
  525. data/lib/libv8/v8/tools/ll_prof.py +3 -3
  526. data/lib/libv8/v8/tools/oom_dump/README +3 -1
  527. data/lib/libv8/v8/tools/presubmit.py +11 -4
  528. data/lib/libv8/v8/tools/profile.js +46 -2
  529. data/lib/libv8/v8/tools/splaytree.js +11 -0
  530. data/lib/libv8/v8/tools/stats-viewer.py +15 -11
  531. data/lib/libv8/v8/tools/test-wrapper-gypbuild.py +227 -0
  532. data/lib/libv8/v8/tools/test.py +28 -8
  533. data/lib/libv8/v8/tools/tickprocessor.js +0 -16
  534. data/lib/libv8/version.rb +1 -1
  535. data/libv8.gemspec +2 -2
  536. metadata +31 -19
  537. data/lib/libv8/scons/engine/SCons/Tool/f03.py +0 -63
  538. data/lib/libv8/v8/src/json-parser.cc +0 -504
@@ -69,7 +69,6 @@ class InlineRuntimeFunctionsTable;
69
69
  class NoAllocationStringAllocator;
70
70
  class PcToCodeCache;
71
71
  class PreallocatedMemoryThread;
72
- class ProducerHeapProfile;
73
72
  class RegExpStack;
74
73
  class SaveContext;
75
74
  class UnicodeCache;
@@ -126,14 +125,8 @@ typedef ZoneList<Handle<Object> > ZoneObjectList;
126
125
  C(c_entry_fp_address) \
127
126
  C(context_address) \
128
127
  C(pending_exception_address) \
129
- C(external_caught_exception_address)
130
-
131
- #ifdef ENABLE_LOGGING_AND_PROFILING
132
- #define ISOLATE_ADDRESS_LIST_PROF(C) \
128
+ C(external_caught_exception_address) \
133
129
  C(js_entry_sp_address)
134
- #else
135
- #define ISOLATE_ADDRESS_LIST_PROF(C)
136
- #endif
137
130
 
138
131
 
139
132
  // Platform-independent, reliable thread identifier.
@@ -253,14 +246,9 @@ class ThreadLocalTop BASE_EMBEDDED {
253
246
  #endif
254
247
  #endif // USE_SIMULATOR
255
248
 
256
- #ifdef ENABLE_LOGGING_AND_PROFILING
257
249
  Address js_entry_sp_; // the stack pointer of the bottom js entry frame
258
250
  Address external_callback_; // the external callback we're currently in
259
- #endif
260
-
261
- #ifdef ENABLE_VMSTATE_TRACKING
262
251
  StateTag current_vm_state_;
263
- #endif
264
252
 
265
253
  // Generated code scratch locations.
266
254
  int32_t formal_count_;
@@ -268,6 +256,9 @@ class ThreadLocalTop BASE_EMBEDDED {
268
256
  // Call back function to report unsafe JS accesses.
269
257
  v8::FailedAccessCheckCallback failed_access_check_callback_;
270
258
 
259
+ // Whether out of memory exceptions should be ignored.
260
+ bool ignore_out_of_memory_;
261
+
271
262
  private:
272
263
  void InitializeInternal();
273
264
 
@@ -314,18 +305,6 @@ class HashMap;
314
305
 
315
306
  #endif
316
307
 
317
- #ifdef ENABLE_LOGGING_AND_PROFILING
318
-
319
- #define ISOLATE_LOGGING_INIT_LIST(V) \
320
- V(CpuProfiler*, cpu_profiler, NULL) \
321
- V(HeapProfiler*, heap_profiler, NULL)
322
-
323
- #else
324
-
325
- #define ISOLATE_LOGGING_INIT_LIST(V)
326
-
327
- #endif
328
-
329
308
  #define ISOLATE_INIT_ARRAY_LIST(V) \
330
309
  /* SerializerDeserializer state. */ \
331
310
  V(Object*, serialize_partial_snapshot_cache, kPartialSnapshotCacheCapacity) \
@@ -333,6 +312,8 @@ class HashMap;
333
312
  V(int, bad_char_shift_table, kUC16AlphabetSize) \
334
313
  V(int, good_suffix_shift_table, (kBMMaxShift + 1)) \
335
314
  V(int, suffix_table, (kBMMaxShift + 1)) \
315
+ V(uint32_t, random_seed, 2) \
316
+ V(uint32_t, private_random_seed, 2) \
336
317
  ISOLATE_INIT_DEBUG_ARRAY_LIST(V)
337
318
 
338
319
  typedef List<HeapObject*, PreallocatedStorage> DebugObjectCache;
@@ -372,8 +353,9 @@ typedef List<HeapObject*, PreallocatedStorage> DebugObjectCache;
372
353
  /* SafeStackFrameIterator activations count. */ \
373
354
  V(int, safe_stack_iterator_counter, 0) \
374
355
  V(uint64_t, enabled_cpu_features, 0) \
356
+ V(CpuProfiler*, cpu_profiler, NULL) \
357
+ V(HeapProfiler*, heap_profiler, NULL) \
375
358
  ISOLATE_PLATFORM_INIT_LIST(V) \
376
- ISOLATE_LOGGING_INIT_LIST(V) \
377
359
  ISOLATE_DEBUGGER_INIT_LIST(V)
378
360
 
379
361
  class Isolate {
@@ -444,7 +426,6 @@ class Isolate {
444
426
  enum AddressId {
445
427
  #define C(name) k_##name,
446
428
  ISOLATE_ADDRESS_LIST(C)
447
- ISOLATE_ADDRESS_LIST_PROF(C)
448
429
  #undef C
449
430
  k_isolate_address_count
450
431
  };
@@ -468,6 +449,13 @@ class Isolate {
468
449
  return reinterpret_cast<Isolate*>(Thread::GetThreadLocal(isolate_key_));
469
450
  }
470
451
 
452
+ // Usually called by Init(), but can be called early e.g. to allow
453
+ // testing components that require logging but not the whole
454
+ // isolate.
455
+ //
456
+ // Safe to call more than once.
457
+ void InitializeLoggingAndCounters();
458
+
471
459
  bool Init(Deserializer* des);
472
460
 
473
461
  bool IsInitialized() { return state_ == INITIALIZED; }
@@ -520,15 +508,18 @@ class Isolate {
520
508
  // switched to non-legacy behavior).
521
509
  static void EnterDefaultIsolate();
522
510
 
523
- // Debug.
524
511
  // Mutex for serializing access to break control structures.
525
512
  Mutex* break_access() { return break_access_; }
526
513
 
514
+ // Mutex for serializing access to debugger.
515
+ Mutex* debugger_access() { return debugger_access_; }
516
+
527
517
  Address get_address_from_id(AddressId id);
528
518
 
529
519
  // Access to top context (where the current function object was created).
530
520
  Context* context() { return thread_local_top_.context_; }
531
521
  void set_context(Context* context) {
522
+ ASSERT(context == NULL || context->IsContext());
532
523
  thread_local_top_.context_ = context;
533
524
  }
534
525
  Context** context_address() { return &thread_local_top_.context_; }
@@ -594,7 +585,7 @@ class Isolate {
594
585
  return thread_local_top_.scheduled_exception_;
595
586
  }
596
587
  bool has_scheduled_exception() {
597
- return !thread_local_top_.scheduled_exception_->IsTheHole();
588
+ return thread_local_top_.scheduled_exception_ != heap_.the_hole_value();
598
589
  }
599
590
  void clear_scheduled_exception() {
600
591
  thread_local_top_.scheduled_exception_ = heap_.the_hole_value();
@@ -618,7 +609,6 @@ class Isolate {
618
609
  }
619
610
  inline Address* handler_address() { return &thread_local_top_.handler_; }
620
611
 
621
- #ifdef ENABLE_LOGGING_AND_PROFILING
622
612
  // Bottom JS entry (see StackTracer::Trace in log.cc).
623
613
  static Address js_entry_sp(ThreadLocalTop* thread) {
624
614
  return thread->js_entry_sp_;
@@ -626,7 +616,6 @@ class Isolate {
626
616
  inline Address* js_entry_sp_address() {
627
617
  return &thread_local_top_.js_entry_sp_;
628
618
  }
629
- #endif
630
619
 
631
620
  // Generated code scratch locations.
632
621
  void* formal_count_address() { return &thread_local_top_.formal_count_; }
@@ -684,6 +673,12 @@ class Isolate {
684
673
  // Tells whether the current context has experienced an out of memory
685
674
  // exception.
686
675
  bool is_out_of_memory();
676
+ bool ignore_out_of_memory() {
677
+ return thread_local_top_.ignore_out_of_memory_;
678
+ }
679
+ void set_ignore_out_of_memory(bool value) {
680
+ thread_local_top_.ignore_out_of_memory_ = value;
681
+ }
687
682
 
688
683
  void PrintCurrentStackTrace(FILE* out);
689
684
  void PrintStackTrace(FILE* out, char* thread_data);
@@ -792,14 +787,24 @@ class Isolate {
792
787
  #undef GLOBAL_CONTEXT_FIELD_ACCESSOR
793
788
 
794
789
  Bootstrapper* bootstrapper() { return bootstrapper_; }
795
- Counters* counters() { return counters_; }
790
+ Counters* counters() {
791
+ // Call InitializeLoggingAndCounters() if logging is needed before
792
+ // the isolate is fully initialized.
793
+ ASSERT(counters_ != NULL);
794
+ return counters_;
795
+ }
796
796
  CodeRange* code_range() { return code_range_; }
797
797
  RuntimeProfiler* runtime_profiler() { return runtime_profiler_; }
798
798
  CompilationCache* compilation_cache() { return compilation_cache_; }
799
- Logger* logger() { return logger_; }
799
+ Logger* logger() {
800
+ // Call InitializeLoggingAndCounters() if logging is needed before
801
+ // the isolate is fully initialized.
802
+ ASSERT(logger_ != NULL);
803
+ return logger_;
804
+ }
800
805
  StackGuard* stack_guard() { return &stack_guard_; }
801
806
  Heap* heap() { return &heap_; }
802
- StatsTable* stats_table() { return stats_table_; }
807
+ StatsTable* stats_table();
803
808
  StubCache* stub_cache() { return stub_cache_; }
804
809
  DeoptimizerData* deoptimizer_data() { return deoptimizer_data_; }
805
810
  ThreadLocalTop* thread_local_top() { return &thread_local_top_; }
@@ -895,31 +900,23 @@ class Isolate {
895
900
  return &interp_canonicalize_mapping_;
896
901
  }
897
902
 
898
- ZoneObjectList* frame_element_constant_list() {
899
- return &frame_element_constant_list_;
900
- }
901
-
902
- ZoneObjectList* result_constant_list() {
903
- return &result_constant_list_;
904
- }
905
-
906
903
  void* PreallocatedStorageNew(size_t size);
907
904
  void PreallocatedStorageDelete(void* p);
908
905
  void PreallocatedStorageInit(size_t size);
909
906
 
910
907
  #ifdef ENABLE_DEBUGGER_SUPPORT
911
- Debugger* debugger() { return debugger_; }
912
- Debug* debug() { return debug_; }
908
+ Debugger* debugger() {
909
+ if (!NoBarrier_Load(&debugger_initialized_)) InitializeDebugger();
910
+ return debugger_;
911
+ }
912
+ Debug* debug() {
913
+ if (!NoBarrier_Load(&debugger_initialized_)) InitializeDebugger();
914
+ return debug_;
915
+ }
913
916
  #endif
914
917
 
915
918
  inline bool DebuggerHasBreakPoints();
916
919
 
917
- #ifdef ENABLE_LOGGING_AND_PROFILING
918
- ProducerHeapProfile* producer_heap_profile() {
919
- return producer_heap_profile_;
920
- }
921
- #endif
922
-
923
920
  #ifdef DEBUG
924
921
  HistogramInfo* heap_histograms() { return heap_histograms_; }
925
922
 
@@ -957,22 +954,21 @@ class Isolate {
957
954
 
958
955
  static const int kJSRegexpStaticOffsetsVectorSize = 50;
959
956
 
960
- #ifdef ENABLE_LOGGING_AND_PROFILING
961
957
  Address external_callback() {
962
958
  return thread_local_top_.external_callback_;
963
959
  }
964
960
  void set_external_callback(Address callback) {
965
961
  thread_local_top_.external_callback_ = callback;
966
962
  }
967
- #endif
968
963
 
969
- #ifdef ENABLE_VMSTATE_TRACKING
970
964
  StateTag current_vm_state() {
971
965
  return thread_local_top_.current_vm_state_;
972
966
  }
973
967
 
974
968
  void SetCurrentVMState(StateTag state) {
975
969
  if (RuntimeProfiler::IsEnabled()) {
970
+ // Make sure thread local top is initialized.
971
+ ASSERT(thread_local_top_.isolate_ == this);
976
972
  StateTag current_state = thread_local_top_.current_vm_state_;
977
973
  if (current_state != JS && state == JS) {
978
974
  // Non-JS -> JS transition.
@@ -990,9 +986,6 @@ class Isolate {
990
986
  }
991
987
  thread_local_top_.current_vm_state_ = state;
992
988
  }
993
- #endif
994
-
995
- void ResetEagerOptimizingData();
996
989
 
997
990
  void SetData(void* data) { embedder_data_ = data; }
998
991
  void* GetData() { return embedder_data_; }
@@ -1011,6 +1004,7 @@ class Isolate {
1011
1004
  void Insert(PerIsolateThreadData* data);
1012
1005
  void Remove(Isolate* isolate, ThreadId thread_id);
1013
1006
  void Remove(PerIsolateThreadData* data);
1007
+ void RemoveAllThreads(Isolate* isolate);
1014
1008
 
1015
1009
  private:
1016
1010
  PerIsolateThreadData* list_;
@@ -1050,8 +1044,6 @@ class Isolate {
1050
1044
  static Isolate* default_isolate_;
1051
1045
  static ThreadDataTable* thread_data_table_;
1052
1046
 
1053
- bool PreInit();
1054
-
1055
1047
  void Deinit();
1056
1048
 
1057
1049
  static void SetIsolateThreadLocals(Isolate* isolate,
@@ -1059,7 +1051,6 @@ class Isolate {
1059
1051
 
1060
1052
  enum State {
1061
1053
  UNINITIALIZED, // Some components may not have been allocated.
1062
- PREINITIALIZED, // Components have been allocated but not initialized.
1063
1054
  INITIALIZED // All components are fully initialized.
1064
1055
  };
1065
1056
 
@@ -1103,6 +1094,8 @@ class Isolate {
1103
1094
 
1104
1095
  void PropagatePendingExceptionToExternalTryCatch();
1105
1096
 
1097
+ void InitializeDebugger();
1098
+
1106
1099
  int stack_trace_nesting_level_;
1107
1100
  StringStream* incomplete_message_;
1108
1101
  // The preallocated memory thread singleton.
@@ -1116,6 +1109,8 @@ class Isolate {
1116
1109
  Counters* counters_;
1117
1110
  CodeRange* code_range_;
1118
1111
  Mutex* break_access_;
1112
+ Atomic32 debugger_initialized_;
1113
+ Mutex* debugger_access_;
1119
1114
  Heap heap_;
1120
1115
  Logger* logger_;
1121
1116
  StackGuard stack_guard_;
@@ -1157,8 +1152,6 @@ class Isolate {
1157
1152
  regexp_macro_assembler_canonicalize_;
1158
1153
  RegExpStack* regexp_stack_;
1159
1154
  unibrow::Mapping<unibrow::Ecma262Canonicalize> interp_canonicalize_mapping_;
1160
- ZoneObjectList frame_element_constant_list_;
1161
- ZoneObjectList result_constant_list_;
1162
1155
  void* embedder_data_;
1163
1156
 
1164
1157
  #if defined(V8_TARGET_ARCH_ARM) && !defined(__arm__) || \
@@ -1180,10 +1173,6 @@ class Isolate {
1180
1173
  Debug* debug_;
1181
1174
  #endif
1182
1175
 
1183
- #ifdef ENABLE_LOGGING_AND_PROFILING
1184
- ProducerHeapProfile* producer_heap_profile_;
1185
- #endif
1186
-
1187
1176
  #define GLOBAL_BACKING_STORE(type, name, initialvalue) \
1188
1177
  type name##_;
1189
1178
  ISOLATE_INIT_LIST(GLOBAL_BACKING_STORE)
@@ -1211,6 +1200,7 @@ class Isolate {
1211
1200
  friend class Simulator;
1212
1201
  friend class StackGuard;
1213
1202
  friend class ThreadId;
1203
+ friend class TestMemoryAllocatorScope;
1214
1204
  friend class v8::Isolate;
1215
1205
  friend class v8::Locker;
1216
1206
  friend class v8::Unlocker;
@@ -1373,10 +1363,4 @@ inline void Context::mark_out_of_memory() {
1373
1363
 
1374
1364
  } } // namespace v8::internal
1375
1365
 
1376
- // TODO(isolates): Get rid of these -inl.h includes and place them only where
1377
- // they're needed.
1378
- #include "allocation-inl.h"
1379
- #include "zone-inl.h"
1380
- #include "frames-inl.h"
1381
-
1382
1366
  #endif // V8_ISOLATE_H_
@@ -28,12 +28,19 @@
28
28
  #ifndef V8_JSON_PARSER_H_
29
29
  #define V8_JSON_PARSER_H_
30
30
 
31
+ #include "v8.h"
32
+
33
+ #include "char-predicates-inl.h"
34
+ #include "v8conversions.h"
35
+ #include "messages.h"
36
+ #include "spaces-inl.h"
31
37
  #include "token.h"
32
38
 
33
39
  namespace v8 {
34
40
  namespace internal {
35
41
 
36
42
  // A simple json parser.
43
+ template <bool seq_ascii>
37
44
  class JsonParser BASE_EMBEDDED {
38
45
  public:
39
46
  static Handle<Object> Parse(Handle<String> source) {
@@ -47,41 +54,64 @@ class JsonParser BASE_EMBEDDED {
47
54
  Handle<Object> ParseJson(Handle<String> source);
48
55
 
49
56
  inline void Advance() {
57
+ position_++;
50
58
  if (position_ >= source_length_) {
51
- position_++;
52
59
  c0_ = kEndOfString;
53
- } else if (is_sequential_ascii_) {
54
- position_++;
60
+ } else if (seq_ascii) {
55
61
  c0_ = seq_source_->SeqAsciiStringGet(position_);
56
62
  } else {
57
- position_++;
58
63
  c0_ = source_->Get(position_);
59
64
  }
60
65
  }
61
66
 
62
- inline Isolate* isolate() { return isolate_; }
67
+ // The JSON lexical grammar is specified in the ECMAScript 5 standard,
68
+ // section 15.12.1.1. The only allowed whitespace characters between tokens
69
+ // are tab, carriage-return, newline and space.
63
70
 
64
- // Get the string for the current string token.
65
- Handle<String> GetString(bool hint_symbol);
66
- Handle<String> GetString();
67
- Handle<String> GetSymbol();
71
+ inline void AdvanceSkipWhitespace() {
72
+ do {
73
+ Advance();
74
+ } while (c0_ == '\t' || c0_ == '\r' || c0_ == '\n' || c0_ == ' ');
75
+ }
68
76
 
69
- // Scan a single JSON token. The JSON lexical grammar is specified in the
70
- // ECMAScript 5 standard, section 15.12.1.1.
71
- // Recognizes all of the single-character tokens directly, or calls a function
72
- // to scan a number, string or identifier literal.
73
- // The only allowed whitespace characters between tokens are tab,
74
- // carriage-return, newline and space.
75
- void ScanJson();
77
+ inline void SkipWhitespace() {
78
+ while (c0_ == '\t' || c0_ == '\r' || c0_ == '\n' || c0_ == ' ') {
79
+ Advance();
80
+ }
81
+ }
82
+
83
+ inline uc32 AdvanceGetChar() {
84
+ Advance();
85
+ return c0_;
86
+ }
87
+
88
+ // Checks that current charater is c.
89
+ // If so, then consume c and skip whitespace.
90
+ inline bool MatchSkipWhiteSpace(uc32 c) {
91
+ if (c0_ == c) {
92
+ AdvanceSkipWhitespace();
93
+ return true;
94
+ }
95
+ return false;
96
+ }
76
97
 
77
98
  // A JSON string (production JSONString) is subset of valid JavaScript string
78
99
  // literals. The string must only be double-quoted (not single-quoted), and
79
100
  // the only allowed backslash-escapes are ", /, \, b, f, n, r, t and
80
101
  // four-digit hex escapes (uXXXX). Any other use of backslashes is invalid.
81
- Token::Value ScanJsonString();
82
- // Slow version for unicode support, uses the first ascii_count characters,
83
- // as first part of a ConsString
84
- Token::Value SlowScanJsonString();
102
+ Handle<String> ParseJsonString() {
103
+ return ScanJsonString<false>();
104
+ }
105
+ Handle<String> ParseJsonSymbol() {
106
+ return ScanJsonString<true>();
107
+ }
108
+ template <bool is_symbol>
109
+ Handle<String> ScanJsonString();
110
+ // Creates a new string and copies prefix[start..end] into the beginning
111
+ // of it. Then scans the rest of the string, adding characters after the
112
+ // prefix. Called by ScanJsonString when reaching a '\' or non-ASCII char.
113
+ template <typename StringType, typename SinkChar>
114
+ Handle<String> SlowScanJsonString(Handle<String> prefix, int start, int end);
85
115
 
86
116
  // A JSON number (production JSONNumber) is a subset of the valid JavaScript
87
117
  // decimal number literals.
@@ -89,12 +119,7 @@ class JsonParser BASE_EMBEDDED {
89
119
  // digit before and after a decimal point, may not have prefixed zeros (unless
90
120
  // the integer part is zero), and may include an exponent part (e.g., "e-10").
91
121
  // Hexadecimal and octal numbers are not allowed.
92
- Token::Value ScanJsonNumber();
93
-
94
- // Used to recognizes one of the literals "true", "false", or "null". These
95
- // are the only valid JSON identifiers (productions JSONBooleanLiteral,
96
- // JSONNullLiteral).
97
- Token::Value ScanJsonIdentifier(const char* text, Token::Value token);
122
+ Handle<Object> ParseJsonNumber();
98
123
 
99
124
  // Parse a single JSON value from input (grammar production JSONValue).
100
125
  // A JSON value is either a (double-quoted) string literal, a number literal,
@@ -119,23 +144,13 @@ class JsonParser BASE_EMBEDDED {
119
144
 
120
145
  // Mark that a parsing error has happened at the current token, and
121
146
  // return a null handle. Primarily for readability.
122
- Handle<Object> ReportUnexpectedToken() { return Handle<Object>::null(); }
123
-
124
- // Peek at the next token.
125
- Token::Value Peek() { return next_.token; }
126
- // Scan the next token and return the token scanned on the last call.
127
- Token::Value Next();
147
+ inline Handle<Object> ReportUnexpectedCharacter() {
148
+ return Handle<Object>::null();
149
+ }
128
150
 
129
- struct TokenInfo {
130
- TokenInfo() : token(Token::ILLEGAL),
131
- beg_pos(0),
132
- end_pos(0) { }
133
- Token::Value token;
134
- int beg_pos;
135
- int end_pos;
136
- };
151
+ inline Isolate* isolate() { return isolate_; }
137
152
 
138
- static const int kInitialSpecialStringSize = 100;
153
+ static const int kInitialSpecialStringLength = 1024;
139
154
 
140
155
 
141
156
  private:
@@ -143,18 +158,441 @@ class JsonParser BASE_EMBEDDED {
143
158
  int source_length_;
144
159
  Handle<SeqAsciiString> seq_source_;
145
160
 
146
- bool is_sequential_ascii_;
147
- // Current and next token
148
- TokenInfo current_;
149
- TokenInfo next_;
150
161
  Isolate* isolate_;
151
162
  uc32 c0_;
152
163
  int position_;
164
+ };
153
165
 
166
+ template <bool seq_ascii>
167
+ Handle<Object> JsonParser<seq_ascii>::ParseJson(Handle<String> source) {
168
+ isolate_ = source->map()->isolate();
169
+ FlattenString(source);
170
+ source_ = source;
171
+ source_length_ = source_->length();
154
172
 
155
- Handle<String> string_val_;
156
- double number_;
157
- };
173
+ // Optimized fast case where we only have ASCII characters.
174
+ if (seq_ascii) {
175
+ seq_source_ = Handle<SeqAsciiString>::cast(source_);
176
+ }
177
+
178
+ // Set initial position right before the string.
179
+ position_ = -1;
180
+ // Advance to the first character (posibly EOS)
181
+ AdvanceSkipWhitespace();
182
+ Handle<Object> result = ParseJsonValue();
183
+ if (result.is_null() || c0_ != kEndOfString) {
184
+ // Parse failed. Current character is the unexpected token.
185
+
186
+ const char* message;
187
+ Factory* factory = isolate()->factory();
188
+ Handle<JSArray> array;
189
+
190
+ switch (c0_) {
191
+ case kEndOfString:
192
+ message = "unexpected_eos";
193
+ array = factory->NewJSArray(0);
194
+ break;
195
+ case '-':
196
+ case '0':
197
+ case '1':
198
+ case '2':
199
+ case '3':
200
+ case '4':
201
+ case '5':
202
+ case '6':
203
+ case '7':
204
+ case '8':
205
+ case '9':
206
+ message = "unexpected_token_number";
207
+ array = factory->NewJSArray(0);
208
+ break;
209
+ case '"':
210
+ message = "unexpected_token_string";
211
+ array = factory->NewJSArray(0);
212
+ break;
213
+ default:
214
+ message = "unexpected_token";
215
+ Handle<Object> name = LookupSingleCharacterStringFromCode(c0_);
216
+ Handle<FixedArray> element = factory->NewFixedArray(1);
217
+ element->set(0, *name);
218
+ array = factory->NewJSArrayWithElements(element);
219
+ break;
220
+ }
221
+
222
+ MessageLocation location(factory->NewScript(source),
223
+ position_,
224
+ position_ + 1);
225
+ Handle<Object> result = factory->NewSyntaxError(message, array);
226
+ isolate()->Throw(*result, &location);
227
+ return Handle<Object>::null();
228
+ }
229
+ return result;
230
+ }
231
+
232
+
233
+ // Parse any JSON value.
234
+ template <bool seq_ascii>
235
+ Handle<Object> JsonParser<seq_ascii>::ParseJsonValue() {
236
+ switch (c0_) {
237
+ case '"':
238
+ return ParseJsonString();
239
+ case '-':
240
+ case '0':
241
+ case '1':
242
+ case '2':
243
+ case '3':
244
+ case '4':
245
+ case '5':
246
+ case '6':
247
+ case '7':
248
+ case '8':
249
+ case '9':
250
+ return ParseJsonNumber();
251
+ case 'f':
252
+ if (AdvanceGetChar() == 'a' && AdvanceGetChar() == 'l' &&
253
+ AdvanceGetChar() == 's' && AdvanceGetChar() == 'e') {
254
+ AdvanceSkipWhitespace();
255
+ return isolate()->factory()->false_value();
256
+ } else {
257
+ return ReportUnexpectedCharacter();
258
+ }
259
+ case 't':
260
+ if (AdvanceGetChar() == 'r' && AdvanceGetChar() == 'u' &&
261
+ AdvanceGetChar() == 'e') {
262
+ AdvanceSkipWhitespace();
263
+ return isolate()->factory()->true_value();
264
+ } else {
265
+ return ReportUnexpectedCharacter();
266
+ }
267
+ case 'n':
268
+ if (AdvanceGetChar() == 'u' && AdvanceGetChar() == 'l' &&
269
+ AdvanceGetChar() == 'l') {
270
+ AdvanceSkipWhitespace();
271
+ return isolate()->factory()->null_value();
272
+ } else {
273
+ return ReportUnexpectedCharacter();
274
+ }
275
+ case '{':
276
+ return ParseJsonObject();
277
+ case '[':
278
+ return ParseJsonArray();
279
+ default:
280
+ return ReportUnexpectedCharacter();
281
+ }
282
+ }
283
+
284
+
285
+ // Parse a JSON object. Position must be right at '{'.
286
+ template <bool seq_ascii>
287
+ Handle<Object> JsonParser<seq_ascii>::ParseJsonObject() {
288
+ Handle<JSFunction> object_constructor(
289
+ isolate()->global_context()->object_function());
290
+ Handle<JSObject> json_object =
291
+ isolate()->factory()->NewJSObject(object_constructor);
292
+ ASSERT_EQ(c0_, '{');
293
+
294
+ AdvanceSkipWhitespace();
295
+ if (c0_ != '}') {
296
+ do {
297
+ if (c0_ != '"') return ReportUnexpectedCharacter();
298
+ Handle<String> key = ParseJsonSymbol();
299
+ if (key.is_null() || c0_ != ':') return ReportUnexpectedCharacter();
300
+ AdvanceSkipWhitespace();
301
+ Handle<Object> value = ParseJsonValue();
302
+ if (value.is_null()) return ReportUnexpectedCharacter();
303
+
304
+ uint32_t index;
305
+ if (key->AsArrayIndex(&index)) {
306
+ SetOwnElement(json_object, index, value, kNonStrictMode);
307
+ } else if (key->Equals(isolate()->heap()->Proto_symbol())) {
308
+ SetPrototype(json_object, value);
309
+ } else {
310
+ SetLocalPropertyIgnoreAttributes(json_object, key, value, NONE);
311
+ }
312
+ } while (MatchSkipWhiteSpace(','));
313
+ if (c0_ != '}') {
314
+ return ReportUnexpectedCharacter();
315
+ }
316
+ }
317
+ AdvanceSkipWhitespace();
318
+ return json_object;
319
+ }
320
+
321
+ // Parse a JSON array. Position must be right at '['.
322
+ template <bool seq_ascii>
323
+ Handle<Object> JsonParser<seq_ascii>::ParseJsonArray() {
324
+ ZoneScope zone_scope(isolate(), DELETE_ON_EXIT);
325
+ ZoneList<Handle<Object> > elements(4);
326
+ ASSERT_EQ(c0_, '[');
327
+
328
+ AdvanceSkipWhitespace();
329
+ if (c0_ != ']') {
330
+ do {
331
+ Handle<Object> element = ParseJsonValue();
332
+ if (element.is_null()) return ReportUnexpectedCharacter();
333
+ elements.Add(element);
334
+ } while (MatchSkipWhiteSpace(','));
335
+ if (c0_ != ']') {
336
+ return ReportUnexpectedCharacter();
337
+ }
338
+ }
339
+ AdvanceSkipWhitespace();
340
+ // Allocate a fixed array with all the elements.
341
+ Handle<FixedArray> fast_elements =
342
+ isolate()->factory()->NewFixedArray(elements.length());
343
+ for (int i = 0, n = elements.length(); i < n; i++) {
344
+ fast_elements->set(i, *elements[i]);
345
+ }
346
+ return isolate()->factory()->NewJSArrayWithElements(fast_elements);
347
+ }
348
+
349
+
350
+ template <bool seq_ascii>
351
+ Handle<Object> JsonParser<seq_ascii>::ParseJsonNumber() {
352
+ bool negative = false;
353
+ int beg_pos = position_;
354
+ if (c0_ == '-') {
355
+ Advance();
356
+ negative = true;
357
+ }
358
+ if (c0_ == '0') {
359
+ Advance();
360
+ // Prefix zero is only allowed if it's the only digit before
361
+ // a decimal point or exponent.
362
+ if ('0' <= c0_ && c0_ <= '9') return ReportUnexpectedCharacter();
363
+ } else {
364
+ int i = 0;
365
+ int digits = 0;
366
+ if (c0_ < '1' || c0_ > '9') return ReportUnexpectedCharacter();
367
+ do {
368
+ i = i * 10 + c0_ - '0';
369
+ digits++;
370
+ Advance();
371
+ } while (c0_ >= '0' && c0_ <= '9');
372
+ if (c0_ != '.' && c0_ != 'e' && c0_ != 'E' && digits < 10) {
373
+ SkipWhitespace();
374
+ return Handle<Smi>(Smi::FromInt((negative ? -i : i)), isolate());
375
+ }
376
+ }
377
+ if (c0_ == '.') {
378
+ Advance();
379
+ if (c0_ < '0' || c0_ > '9') return ReportUnexpectedCharacter();
380
+ do {
381
+ Advance();
382
+ } while (c0_ >= '0' && c0_ <= '9');
383
+ }
384
+ if (AsciiAlphaToLower(c0_) == 'e') {
385
+ Advance();
386
+ if (c0_ == '-' || c0_ == '+') Advance();
387
+ if (c0_ < '0' || c0_ > '9') return ReportUnexpectedCharacter();
388
+ do {
389
+ Advance();
390
+ } while (c0_ >= '0' && c0_ <= '9');
391
+ }
392
+ int length = position_ - beg_pos;
393
+ double number;
394
+ if (seq_ascii) {
395
+ Vector<const char> chars(seq_source_->GetChars() + beg_pos, length);
396
+ number = StringToDouble(isolate()->unicode_cache(),
397
+ chars,
398
+ NO_FLAGS, // Hex, octal or trailing junk.
399
+ OS::nan_value());
400
+ } else {
401
+ Vector<char> buffer = Vector<char>::New(length);
402
+ String::WriteToFlat(*source_, buffer.start(), beg_pos, position_);
403
+ Vector<const char> result =
404
+ Vector<const char>(reinterpret_cast<const char*>(buffer.start()),
405
+ length);
406
+ number = StringToDouble(isolate()->unicode_cache(),
407
+ result,
408
+ NO_FLAGS, // Hex, octal or trailing junk.
409
+ 0.0);
410
+ buffer.Dispose();
411
+ }
412
+ SkipWhitespace();
413
+ return isolate()->factory()->NewNumber(number);
414
+ }
415
+
416
+
417
+ template <typename StringType>
418
+ inline void SeqStringSet(Handle<StringType> seq_str, int i, uc32 c);
419
+
420
+ template <>
421
+ inline void SeqStringSet(Handle<SeqTwoByteString> seq_str, int i, uc32 c) {
422
+ seq_str->SeqTwoByteStringSet(i, c);
423
+ }
424
+
425
+ template <>
426
+ inline void SeqStringSet(Handle<SeqAsciiString> seq_str, int i, uc32 c) {
427
+ seq_str->SeqAsciiStringSet(i, c);
428
+ }
429
+
430
+ template <typename StringType>
431
+ inline Handle<StringType> NewRawString(Factory* factory, int length);
432
+
433
+ template <>
434
+ inline Handle<SeqTwoByteString> NewRawString(Factory* factory, int length) {
435
+ return factory->NewRawTwoByteString(length, NOT_TENURED);
436
+ }
437
+
438
+ template <>
439
+ inline Handle<SeqAsciiString> NewRawString(Factory* factory, int length) {
440
+ return factory->NewRawAsciiString(length, NOT_TENURED);
441
+ }
442
+
443
+
444
+ // Scans the rest of a JSON string starting from position_ and writes
445
+ // prefix[start..end] along with the scanned characters into a
446
+ // sequential string of type StringType.
447
+ template <bool seq_ascii>
448
+ template <typename StringType, typename SinkChar>
449
+ Handle<String> JsonParser<seq_ascii>::SlowScanJsonString(
450
+ Handle<String> prefix, int start, int end) {
451
+ int count = end - start;
452
+ int max_length = count + source_length_ - position_;
453
+ int length = Min(max_length, Max(kInitialSpecialStringLength, 2 * count));
454
+ Handle<StringType> seq_str = NewRawString<StringType>(isolate()->factory(),
455
+ length);
456
+ // Copy prefix into seq_str.
457
+ SinkChar* dest = seq_str->GetChars();
458
+ String::WriteToFlat(*prefix, dest, start, end);
459
+
460
+ while (c0_ != '"') {
461
+ // Check for control character (0x00-0x1f) or unterminated string (<0).
462
+ if (c0_ < 0x20) return Handle<String>::null();
463
+ if (count >= length) {
464
+ // We need to create a longer sequential string for the result.
465
+ return SlowScanJsonString<StringType, SinkChar>(seq_str, 0, count);
466
+ }
467
+ if (c0_ != '\\') {
468
+ // If the sink can contain UC16 characters, or source_ contains only
469
+ // ASCII characters, there's no need to test whether we can store the
470
+ // character. Otherwise check whether the UC16 source character can fit
471
+ // in the ASCII sink.
472
+ if (sizeof(SinkChar) == kUC16Size ||
473
+ seq_ascii ||
474
+ c0_ <= kMaxAsciiCharCode) {
475
+ SeqStringSet(seq_str, count++, c0_);
476
+ Advance();
477
+ } else {
478
+ // StringType is SeqAsciiString and we just read a non-ASCII char.
479
+ return SlowScanJsonString<SeqTwoByteString, uc16>(seq_str, 0, count);
480
+ }
481
+ } else {
482
+ Advance(); // Advance past the \.
483
+ switch (c0_) {
484
+ case '"':
485
+ case '\\':
486
+ case '/':
487
+ SeqStringSet(seq_str, count++, c0_);
488
+ break;
489
+ case 'b':
490
+ SeqStringSet(seq_str, count++, '\x08');
491
+ break;
492
+ case 'f':
493
+ SeqStringSet(seq_str, count++, '\x0c');
494
+ break;
495
+ case 'n':
496
+ SeqStringSet(seq_str, count++, '\x0a');
497
+ break;
498
+ case 'r':
499
+ SeqStringSet(seq_str, count++, '\x0d');
500
+ break;
501
+ case 't':
502
+ SeqStringSet(seq_str, count++, '\x09');
503
+ break;
504
+ case 'u': {
505
+ uc32 value = 0;
506
+ for (int i = 0; i < 4; i++) {
507
+ Advance();
508
+ int digit = HexValue(c0_);
509
+ if (digit < 0) {
510
+ return Handle<String>::null();
511
+ }
512
+ value = value * 16 + digit;
513
+ }
514
+ if (sizeof(SinkChar) == kUC16Size || value <= kMaxAsciiCharCode) {
515
+ SeqStringSet(seq_str, count++, value);
516
+ break;
517
+ } else {
518
+ // StringType is SeqAsciiString and we just read a non-ASCII char.
519
+ position_ -= 6; // Rewind position_ to \ in \uxxxx.
520
+ Advance();
521
+ return SlowScanJsonString<SeqTwoByteString, uc16>(seq_str,
522
+ 0,
523
+ count);
524
+ }
525
+ }
526
+ default:
527
+ return Handle<String>::null();
528
+ }
529
+ Advance();
530
+ }
531
+ }
532
+ // Shrink seq_string length to count.
533
+ if (isolate()->heap()->InNewSpace(*seq_str)) {
534
+ isolate()->heap()->new_space()->
535
+ template ShrinkStringAtAllocationBoundary<StringType>(
536
+ *seq_str, count);
537
+ } else {
538
+ int string_size = StringType::SizeFor(count);
539
+ int allocated_string_size = StringType::SizeFor(length);
540
+ int delta = allocated_string_size - string_size;
541
+ Address start_filler_object = seq_str->address() + string_size;
542
+ seq_str->set_length(count);
543
+ isolate()->heap()->CreateFillerObjectAt(start_filler_object, delta);
544
+ }
545
+ ASSERT_EQ('"', c0_);
546
+ // Advance past the last '"'.
547
+ AdvanceSkipWhitespace();
548
+ return seq_str;
549
+ }
550
+
551
+
552
+ template <bool seq_ascii>
553
+ template <bool is_symbol>
554
+ Handle<String> JsonParser<seq_ascii>::ScanJsonString() {
555
+ ASSERT_EQ('"', c0_);
556
+ Advance();
557
+ if (c0_ == '"') {
558
+ AdvanceSkipWhitespace();
559
+ return Handle<String>(isolate()->heap()->empty_string());
560
+ }
561
+ int beg_pos = position_;
562
+ // Fast case for ASCII only without escape characters.
563
+ do {
564
+ // Check for control character (0x00-0x1f) or unterminated string (<0).
565
+ if (c0_ < 0x20) return Handle<String>::null();
566
+ if (c0_ != '\\') {
567
+ if (seq_ascii || c0_ <= kMaxAsciiCharCode) {
568
+ Advance();
569
+ } else {
570
+ return SlowScanJsonString<SeqTwoByteString, uc16>(source_,
571
+ beg_pos,
572
+ position_);
573
+ }
574
+ } else {
575
+ return SlowScanJsonString<SeqAsciiString, char>(source_,
576
+ beg_pos,
577
+ position_);
578
+ }
579
+ } while (c0_ != '"');
580
+ int length = position_ - beg_pos;
581
+ Handle<String> result;
582
+ if (seq_ascii && is_symbol) {
583
+ result = isolate()->factory()->LookupAsciiSymbol(seq_source_,
584
+ beg_pos,
585
+ length);
586
+ } else {
587
+ result = isolate()->factory()->NewRawAsciiString(length);
588
+ char* dest = SeqAsciiString::cast(*result)->GetChars();
589
+ String::WriteToFlat(*source_, dest, beg_pos, position_);
590
+ }
591
+ ASSERT_EQ('"', c0_);
592
+ // Advance past the last '"'.
593
+ AdvanceSkipWhitespace();
594
+ return result;
595
+ }
158
596
 
159
597
  } } // namespace v8::internal
160
598