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,130 @@
1
+ // Copyright 2006-2008 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_IC_INL_H_
29
+ #define V8_IC_INL_H_
30
+
31
+ #include "ic.h"
32
+ #include "debug.h"
33
+ #include "macro-assembler.h"
34
+
35
+ namespace v8 {
36
+ namespace internal {
37
+
38
+
39
+ Address IC::address() {
40
+ // Get the address of the call.
41
+ Address result = pc() - Assembler::kCallTargetAddressOffset;
42
+
43
+ #ifdef ENABLE_DEBUGGER_SUPPORT
44
+ Debug* debug = Isolate::Current()->debug();
45
+ // First check if any break points are active if not just return the address
46
+ // of the call.
47
+ if (!debug->has_break_points()) return result;
48
+
49
+ // At least one break point is active perform additional test to ensure that
50
+ // break point locations are updated correctly.
51
+ if (debug->IsDebugBreak(Assembler::target_address_at(result))) {
52
+ // If the call site is a call to debug break then return the address in
53
+ // the original code instead of the address in the running code. This will
54
+ // cause the original code to be updated and keeps the breakpoint active in
55
+ // the running code.
56
+ return OriginalCodeAddress();
57
+ } else {
58
+ // No break point here just return the address of the call.
59
+ return result;
60
+ }
61
+ #else
62
+ return result;
63
+ #endif
64
+ }
65
+
66
+
67
+ Code* IC::GetTargetAtAddress(Address address) {
68
+ // Get the target address of the IC.
69
+ Address target = Assembler::target_address_at(address);
70
+ // Convert target address to the code object. Code::GetCodeFromTargetAddress
71
+ // is safe for use during GC where the map might be marked.
72
+ Code* result = Code::GetCodeFromTargetAddress(target);
73
+ ASSERT(result->is_inline_cache_stub());
74
+ return result;
75
+ }
76
+
77
+
78
+ void IC::SetTargetAtAddress(Address address, Code* target) {
79
+ ASSERT(target->is_inline_cache_stub() || target->is_compare_ic_stub());
80
+ #ifdef DEBUG
81
+ // STORE_IC and KEYED_STORE_IC use Code::extra_ic_state() to mark
82
+ // ICs as strict mode. The strict-ness of the IC must be preserved.
83
+ Code* old_target = GetTargetAtAddress(address);
84
+ if (old_target->kind() == Code::STORE_IC ||
85
+ old_target->kind() == Code::KEYED_STORE_IC) {
86
+ ASSERT(old_target->extra_ic_state() == target->extra_ic_state());
87
+ }
88
+ #endif
89
+ Assembler::set_target_address_at(address, target->instruction_start());
90
+ }
91
+
92
+
93
+ InlineCacheHolderFlag IC::GetCodeCacheForObject(Object* object,
94
+ JSObject* holder) {
95
+ if (object->IsJSObject()) {
96
+ return GetCodeCacheForObject(JSObject::cast(object), holder);
97
+ }
98
+ // If the object is a value, we use the prototype map for the cache.
99
+ ASSERT(object->IsString() || object->IsNumber() || object->IsBoolean());
100
+ return PROTOTYPE_MAP;
101
+ }
102
+
103
+
104
+ InlineCacheHolderFlag IC::GetCodeCacheForObject(JSObject* object,
105
+ JSObject* holder) {
106
+ // Fast-properties and global objects store stubs in their own maps.
107
+ // Slow properties objects use prototype's map (unless the property is its own
108
+ // when holder == object). It works because slow properties objects having
109
+ // the same prototype (or a prototype with the same map) and not having
110
+ // the property are interchangeable for such a stub.
111
+ if (holder != object &&
112
+ !object->HasFastProperties() &&
113
+ !object->IsJSGlobalProxy() &&
114
+ !object->IsJSGlobalObject()) {
115
+ return PROTOTYPE_MAP;
116
+ }
117
+ return OWN_MAP;
118
+ }
119
+
120
+
121
+ JSObject* IC::GetCodeCacheHolder(Object* object, InlineCacheHolderFlag holder) {
122
+ Object* map_owner = (holder == OWN_MAP ? object : object->GetPrototype());
123
+ ASSERT(map_owner->IsJSObject());
124
+ return JSObject::cast(map_owner);
125
+ }
126
+
127
+
128
+ } } // namespace v8::internal
129
+
130
+ #endif // V8_IC_INL_H_
@@ -0,0 +1,2577 @@
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 "arguments.h"
33
+ #include "codegen.h"
34
+ #include "execution.h"
35
+ #include "ic-inl.h"
36
+ #include "runtime.h"
37
+ #include "stub-cache.h"
38
+
39
+ namespace v8 {
40
+ namespace internal {
41
+
42
+ #ifdef DEBUG
43
+ static char TransitionMarkFromState(IC::State state) {
44
+ switch (state) {
45
+ case UNINITIALIZED: return '0';
46
+ case PREMONOMORPHIC: return 'P';
47
+ case MONOMORPHIC: return '1';
48
+ case MONOMORPHIC_PROTOTYPE_FAILURE: return '^';
49
+ case MEGAMORPHIC: return 'N';
50
+
51
+ // We never see the debugger states here, because the state is
52
+ // computed from the original code - not the patched code. Let
53
+ // these cases fall through to the unreachable code below.
54
+ case DEBUG_BREAK: break;
55
+ case DEBUG_PREPARE_STEP_IN: break;
56
+ }
57
+ UNREACHABLE();
58
+ return 0;
59
+ }
60
+
61
+ void IC::TraceIC(const char* type,
62
+ Handle<Object> name,
63
+ State old_state,
64
+ Code* new_target,
65
+ const char* extra_info) {
66
+ if (FLAG_trace_ic) {
67
+ State new_state = StateFrom(new_target,
68
+ HEAP->undefined_value(),
69
+ HEAP->undefined_value());
70
+ PrintF("[%s in ", type);
71
+ StackFrameIterator it;
72
+ while (it.frame()->fp() != this->fp()) it.Advance();
73
+ StackFrame* raw_frame = it.frame();
74
+ if (raw_frame->is_internal()) {
75
+ Isolate* isolate = new_target->GetIsolate();
76
+ Code* apply_builtin = isolate->builtins()->builtin(
77
+ Builtins::kFunctionApply);
78
+ if (raw_frame->unchecked_code() == apply_builtin) {
79
+ PrintF("apply from ");
80
+ it.Advance();
81
+ raw_frame = it.frame();
82
+ }
83
+ }
84
+ if (raw_frame->is_java_script()) {
85
+ JavaScriptFrame* frame = JavaScriptFrame::cast(raw_frame);
86
+ Code* js_code = frame->unchecked_code();
87
+ // Find the function on the stack and both the active code for the
88
+ // function and the original code.
89
+ JSFunction* function = JSFunction::cast(frame->function());
90
+ function->PrintName();
91
+ int code_offset = address() - js_code->instruction_start();
92
+ PrintF("+%d", code_offset);
93
+ } else {
94
+ PrintF("<unknown>");
95
+ }
96
+ PrintF(" (%c->%c)%s",
97
+ TransitionMarkFromState(old_state),
98
+ TransitionMarkFromState(new_state),
99
+ extra_info);
100
+ name->Print();
101
+ PrintF("]\n");
102
+ }
103
+ }
104
+ #endif
105
+
106
+
107
+ IC::IC(FrameDepth depth, Isolate* isolate) : isolate_(isolate) {
108
+ ASSERT(isolate == Isolate::Current());
109
+ // To improve the performance of the (much used) IC code, we unfold
110
+ // a few levels of the stack frame iteration code. This yields a
111
+ // ~35% speedup when running DeltaBlue with the '--nouse-ic' flag.
112
+ const Address entry =
113
+ Isolate::c_entry_fp(isolate->thread_local_top());
114
+ Address* pc_address =
115
+ reinterpret_cast<Address*>(entry + ExitFrameConstants::kCallerPCOffset);
116
+ Address fp = Memory::Address_at(entry + ExitFrameConstants::kCallerFPOffset);
117
+ // If there's another JavaScript frame on the stack, we need to look
118
+ // one frame further down the stack to find the frame pointer and
119
+ // the return address stack slot.
120
+ if (depth == EXTRA_CALL_FRAME) {
121
+ const int kCallerPCOffset = StandardFrameConstants::kCallerPCOffset;
122
+ pc_address = reinterpret_cast<Address*>(fp + kCallerPCOffset);
123
+ fp = Memory::Address_at(fp + StandardFrameConstants::kCallerFPOffset);
124
+ }
125
+ #ifdef DEBUG
126
+ StackFrameIterator it;
127
+ for (int i = 0; i < depth + 1; i++) it.Advance();
128
+ StackFrame* frame = it.frame();
129
+ ASSERT(fp == frame->fp() && pc_address == frame->pc_address());
130
+ #endif
131
+ fp_ = fp;
132
+ pc_address_ = pc_address;
133
+ }
134
+
135
+
136
+ #ifdef ENABLE_DEBUGGER_SUPPORT
137
+ Address IC::OriginalCodeAddress() {
138
+ HandleScope scope;
139
+ // Compute the JavaScript frame for the frame pointer of this IC
140
+ // structure. We need this to be able to find the function
141
+ // corresponding to the frame.
142
+ StackFrameIterator it;
143
+ while (it.frame()->fp() != this->fp()) it.Advance();
144
+ JavaScriptFrame* frame = JavaScriptFrame::cast(it.frame());
145
+ // Find the function on the stack and both the active code for the
146
+ // function and the original code.
147
+ JSFunction* function = JSFunction::cast(frame->function());
148
+ Handle<SharedFunctionInfo> shared(function->shared());
149
+ Code* code = shared->code();
150
+ ASSERT(Debug::HasDebugInfo(shared));
151
+ Code* original_code = Debug::GetDebugInfo(shared)->original_code();
152
+ ASSERT(original_code->IsCode());
153
+ // Get the address of the call site in the active code. This is the
154
+ // place where the call to DebugBreakXXX is and where the IC
155
+ // normally would be.
156
+ Address addr = pc() - Assembler::kCallTargetAddressOffset;
157
+ // Return the address in the original code. This is the place where
158
+ // the call which has been overwritten by the DebugBreakXXX resides
159
+ // and the place where the inline cache system should look.
160
+ intptr_t delta =
161
+ original_code->instruction_start() - code->instruction_start();
162
+ return addr + delta;
163
+ }
164
+ #endif
165
+
166
+
167
+ static bool HasNormalObjectsInPrototypeChain(Isolate* isolate,
168
+ LookupResult* lookup,
169
+ Object* receiver) {
170
+ Object* end = lookup->IsProperty()
171
+ ? lookup->holder() : isolate->heap()->null_value();
172
+ for (Object* current = receiver;
173
+ current != end;
174
+ current = current->GetPrototype()) {
175
+ if (current->IsJSObject() &&
176
+ !JSObject::cast(current)->HasFastProperties() &&
177
+ !current->IsJSGlobalProxy() &&
178
+ !current->IsJSGlobalObject()) {
179
+ return true;
180
+ }
181
+ }
182
+
183
+ return false;
184
+ }
185
+
186
+
187
+ static bool TryRemoveInvalidPrototypeDependentStub(Code* target,
188
+ Object* receiver,
189
+ Object* name) {
190
+ InlineCacheHolderFlag cache_holder =
191
+ Code::ExtractCacheHolderFromFlags(target->flags());
192
+
193
+ if (cache_holder == OWN_MAP && !receiver->IsJSObject()) {
194
+ // The stub was generated for JSObject but called for non-JSObject.
195
+ // IC::GetCodeCacheHolder is not applicable.
196
+ return false;
197
+ } else if (cache_holder == PROTOTYPE_MAP &&
198
+ receiver->GetPrototype()->IsNull()) {
199
+ // IC::GetCodeCacheHolder is not applicable.
200
+ return false;
201
+ }
202
+ Map* map = IC::GetCodeCacheHolder(receiver, cache_holder)->map();
203
+
204
+ // Decide whether the inline cache failed because of changes to the
205
+ // receiver itself or changes to one of its prototypes.
206
+ //
207
+ // If there are changes to the receiver itself, the map of the
208
+ // receiver will have changed and the current target will not be in
209
+ // the receiver map's code cache. Therefore, if the current target
210
+ // is in the receiver map's code cache, the inline cache failed due
211
+ // to prototype check failure.
212
+ int index = map->IndexInCodeCache(name, target);
213
+ if (index >= 0) {
214
+ map->RemoveFromCodeCache(String::cast(name), target, index);
215
+ return true;
216
+ }
217
+
218
+ return false;
219
+ }
220
+
221
+
222
+ IC::State IC::StateFrom(Code* target, Object* receiver, Object* name) {
223
+ IC::State state = target->ic_state();
224
+
225
+ if (state != MONOMORPHIC || !name->IsString()) return state;
226
+ if (receiver->IsUndefined() || receiver->IsNull()) return state;
227
+
228
+ // For keyed load/store/call, the most likely cause of cache failure is
229
+ // that the key has changed. We do not distinguish between
230
+ // prototype and non-prototype failures for keyed access.
231
+ Code::Kind kind = target->kind();
232
+ if (kind == Code::KEYED_LOAD_IC ||
233
+ kind == Code::KEYED_STORE_IC ||
234
+ kind == Code::KEYED_CALL_IC) {
235
+ return MONOMORPHIC;
236
+ }
237
+
238
+ // Remove the target from the code cache if it became invalid
239
+ // because of changes in the prototype chain to avoid hitting it
240
+ // again.
241
+ // Call stubs handle this later to allow extra IC state
242
+ // transitions.
243
+ if (kind != Code::CALL_IC &&
244
+ TryRemoveInvalidPrototypeDependentStub(target, receiver, name)) {
245
+ return MONOMORPHIC_PROTOTYPE_FAILURE;
246
+ }
247
+
248
+ // The builtins object is special. It only changes when JavaScript
249
+ // builtins are loaded lazily. It is important to keep inline
250
+ // caches for the builtins object monomorphic. Therefore, if we get
251
+ // an inline cache miss for the builtins object after lazily loading
252
+ // JavaScript builtins, we return uninitialized as the state to
253
+ // force the inline cache back to monomorphic state.
254
+ if (receiver->IsJSBuiltinsObject()) {
255
+ return UNINITIALIZED;
256
+ }
257
+
258
+ return MONOMORPHIC;
259
+ }
260
+
261
+
262
+ RelocInfo::Mode IC::ComputeMode() {
263
+ Address addr = address();
264
+ Code* code = Code::cast(isolate()->heap()->FindCodeObject(addr));
265
+ for (RelocIterator it(code, RelocInfo::kCodeTargetMask);
266
+ !it.done(); it.next()) {
267
+ RelocInfo* info = it.rinfo();
268
+ if (info->pc() == addr) return info->rmode();
269
+ }
270
+ UNREACHABLE();
271
+ return RelocInfo::NONE;
272
+ }
273
+
274
+
275
+ Failure* IC::TypeError(const char* type,
276
+ Handle<Object> object,
277
+ Handle<Object> key) {
278
+ HandleScope scope(isolate());
279
+ Handle<Object> args[2] = { key, object };
280
+ Handle<Object> error = isolate()->factory()->NewTypeError(
281
+ type, HandleVector(args, 2));
282
+ return isolate()->Throw(*error);
283
+ }
284
+
285
+
286
+ Failure* IC::ReferenceError(const char* type, Handle<String> name) {
287
+ HandleScope scope(isolate());
288
+ Handle<Object> error = isolate()->factory()->NewReferenceError(
289
+ type, HandleVector(&name, 1));
290
+ return isolate()->Throw(*error);
291
+ }
292
+
293
+
294
+ void IC::Clear(Address address) {
295
+ Code* target = GetTargetAtAddress(address);
296
+
297
+ // Don't clear debug break inline cache as it will remove the break point.
298
+ if (target->ic_state() == DEBUG_BREAK) return;
299
+
300
+ switch (target->kind()) {
301
+ case Code::LOAD_IC: return LoadIC::Clear(address, target);
302
+ case Code::KEYED_LOAD_IC:
303
+ return KeyedLoadIC::Clear(address, target);
304
+ case Code::STORE_IC: return StoreIC::Clear(address, target);
305
+ case Code::KEYED_STORE_IC:
306
+ return KeyedStoreIC::Clear(address, target);
307
+ case Code::CALL_IC: return CallIC::Clear(address, target);
308
+ case Code::KEYED_CALL_IC: return KeyedCallIC::Clear(address, target);
309
+ case Code::UNARY_OP_IC:
310
+ case Code::BINARY_OP_IC:
311
+ case Code::COMPARE_IC:
312
+ // Clearing these is tricky and does not
313
+ // make any performance difference.
314
+ return;
315
+ default: UNREACHABLE();
316
+ }
317
+ }
318
+
319
+
320
+ void CallICBase::Clear(Address address, Code* target) {
321
+ bool contextual = CallICBase::Contextual::decode(target->extra_ic_state());
322
+ State state = target->ic_state();
323
+ if (state == UNINITIALIZED) return;
324
+ Code* code =
325
+ Isolate::Current()->stub_cache()->FindCallInitialize(
326
+ target->arguments_count(),
327
+ target->ic_in_loop(),
328
+ contextual ? RelocInfo::CODE_TARGET_CONTEXT : RelocInfo::CODE_TARGET,
329
+ target->kind());
330
+ SetTargetAtAddress(address, code);
331
+ }
332
+
333
+
334
+ void KeyedLoadIC::Clear(Address address, Code* target) {
335
+ if (target->ic_state() == UNINITIALIZED) return;
336
+ // Make sure to also clear the map used in inline fast cases. If we
337
+ // do not clear these maps, cached code can keep objects alive
338
+ // through the embedded maps.
339
+ SetTargetAtAddress(address, initialize_stub());
340
+ }
341
+
342
+
343
+ void LoadIC::Clear(Address address, Code* target) {
344
+ if (target->ic_state() == UNINITIALIZED) return;
345
+ SetTargetAtAddress(address, initialize_stub());
346
+ }
347
+
348
+
349
+ void StoreIC::Clear(Address address, Code* target) {
350
+ if (target->ic_state() == UNINITIALIZED) return;
351
+ SetTargetAtAddress(address,
352
+ (target->extra_ic_state() == kStrictMode)
353
+ ? initialize_stub_strict()
354
+ : initialize_stub());
355
+ }
356
+
357
+
358
+ void KeyedStoreIC::Clear(Address address, Code* target) {
359
+ if (target->ic_state() == UNINITIALIZED) return;
360
+ SetTargetAtAddress(address,
361
+ (target->extra_ic_state() == kStrictMode)
362
+ ? initialize_stub_strict()
363
+ : initialize_stub());
364
+ }
365
+
366
+
367
+ static bool HasInterceptorGetter(JSObject* object) {
368
+ return !object->GetNamedInterceptor()->getter()->IsUndefined();
369
+ }
370
+
371
+
372
+ static void LookupForRead(Object* object,
373
+ String* name,
374
+ LookupResult* lookup) {
375
+ AssertNoAllocation no_gc; // pointers must stay valid
376
+
377
+ // Skip all the objects with named interceptors, but
378
+ // without actual getter.
379
+ while (true) {
380
+ object->Lookup(name, lookup);
381
+ // Besides normal conditions (property not found or it's not
382
+ // an interceptor), bail out if lookup is not cacheable: we won't
383
+ // be able to IC it anyway and regular lookup should work fine.
384
+ if (!lookup->IsFound()
385
+ || (lookup->type() != INTERCEPTOR)
386
+ || !lookup->IsCacheable()) {
387
+ return;
388
+ }
389
+
390
+ JSObject* holder = lookup->holder();
391
+ if (HasInterceptorGetter(holder)) {
392
+ return;
393
+ }
394
+
395
+ holder->LocalLookupRealNamedProperty(name, lookup);
396
+ if (lookup->IsProperty()) {
397
+ ASSERT(lookup->type() != INTERCEPTOR);
398
+ return;
399
+ }
400
+
401
+ Object* proto = holder->GetPrototype();
402
+ if (proto->IsNull()) {
403
+ lookup->NotFound();
404
+ return;
405
+ }
406
+
407
+ object = proto;
408
+ }
409
+ }
410
+
411
+
412
+ Object* CallICBase::TryCallAsFunction(Object* object) {
413
+ HandleScope scope(isolate());
414
+ Handle<Object> target(object, isolate());
415
+ Handle<Object> delegate = Execution::GetFunctionDelegate(target);
416
+
417
+ if (delegate->IsJSFunction()) {
418
+ // Patch the receiver and use the delegate as the function to
419
+ // invoke. This is used for invoking objects as if they were
420
+ // functions.
421
+ const int argc = this->target()->arguments_count();
422
+ StackFrameLocator locator;
423
+ JavaScriptFrame* frame = locator.FindJavaScriptFrame(0);
424
+ int index = frame->ComputeExpressionsCount() - (argc + 1);
425
+ frame->SetExpression(index, *target);
426
+ }
427
+
428
+ return *delegate;
429
+ }
430
+
431
+
432
+ void CallICBase::ReceiverToObjectIfRequired(Handle<Object> callee,
433
+ Handle<Object> object) {
434
+ if (callee->IsJSFunction()) {
435
+ Handle<JSFunction> function = Handle<JSFunction>::cast(callee);
436
+ if (function->shared()->strict_mode() || function->IsBuiltin()) {
437
+ // Do not wrap receiver for strict mode functions or for builtins.
438
+ return;
439
+ }
440
+ }
441
+
442
+ // And only wrap string, number or boolean.
443
+ if (object->IsString() || object->IsNumber() || object->IsBoolean()) {
444
+ // Change the receiver to the result of calling ToObject on it.
445
+ const int argc = this->target()->arguments_count();
446
+ StackFrameLocator locator;
447
+ JavaScriptFrame* frame = locator.FindJavaScriptFrame(0);
448
+ int index = frame->ComputeExpressionsCount() - (argc + 1);
449
+ frame->SetExpression(index, *isolate()->factory()->ToObject(object));
450
+ }
451
+ }
452
+
453
+
454
+ MaybeObject* CallICBase::LoadFunction(State state,
455
+ Code::ExtraICState extra_ic_state,
456
+ Handle<Object> object,
457
+ Handle<String> name) {
458
+ // If the object is undefined or null it's illegal to try to get any
459
+ // of its properties; throw a TypeError in that case.
460
+ if (object->IsUndefined() || object->IsNull()) {
461
+ return TypeError("non_object_property_call", object, name);
462
+ }
463
+
464
+ // Check if the name is trivially convertible to an index and get
465
+ // the element if so.
466
+ uint32_t index;
467
+ if (name->AsArrayIndex(&index)) {
468
+ Object* result;
469
+ { MaybeObject* maybe_result = object->GetElement(index);
470
+ if (!maybe_result->ToObject(&result)) return maybe_result;
471
+ }
472
+
473
+ if (result->IsJSFunction()) return result;
474
+
475
+ // Try to find a suitable function delegate for the object at hand.
476
+ result = TryCallAsFunction(result);
477
+ if (result->IsJSFunction()) return result;
478
+
479
+ // Otherwise, it will fail in the lookup step.
480
+ }
481
+
482
+ // Lookup the property in the object.
483
+ LookupResult lookup;
484
+ LookupForRead(*object, *name, &lookup);
485
+
486
+ if (!lookup.IsProperty()) {
487
+ // If the object does not have the requested property, check which
488
+ // exception we need to throw.
489
+ if (IsContextual(object)) {
490
+ return ReferenceError("not_defined", name);
491
+ }
492
+ return TypeError("undefined_method", object, name);
493
+ }
494
+
495
+ // Lookup is valid: Update inline cache and stub cache.
496
+ if (FLAG_use_ic) {
497
+ UpdateCaches(&lookup, state, extra_ic_state, object, name);
498
+ }
499
+
500
+ // Get the property.
501
+ PropertyAttributes attr;
502
+ Object* result;
503
+ { MaybeObject* maybe_result =
504
+ object->GetProperty(*object, &lookup, *name, &attr);
505
+ if (!maybe_result->ToObject(&result)) return maybe_result;
506
+ }
507
+
508
+ if (lookup.type() == INTERCEPTOR) {
509
+ // If the object does not have the requested property, check which
510
+ // exception we need to throw.
511
+ if (attr == ABSENT) {
512
+ if (IsContextual(object)) {
513
+ return ReferenceError("not_defined", name);
514
+ }
515
+ return TypeError("undefined_method", object, name);
516
+ }
517
+ }
518
+
519
+ ASSERT(!result->IsTheHole());
520
+
521
+ HandleScope scope(isolate());
522
+ // Wrap result in a handle because ReceiverToObjectIfRequired may allocate
523
+ // new object and cause GC.
524
+ Handle<Object> result_handle(result);
525
+ // Make receiver an object if the callee requires it. Strict mode or builtin
526
+ // functions do not wrap the receiver, non-strict functions and objects
527
+ // called as functions do.
528
+ ReceiverToObjectIfRequired(result_handle, object);
529
+
530
+ if (result_handle->IsJSFunction()) {
531
+ #ifdef ENABLE_DEBUGGER_SUPPORT
532
+ // Handle stepping into a function if step into is active.
533
+ Debug* debug = isolate()->debug();
534
+ if (debug->StepInActive()) {
535
+ // Protect the result in a handle as the debugger can allocate and might
536
+ // cause GC.
537
+ Handle<JSFunction> function(JSFunction::cast(*result_handle), isolate());
538
+ debug->HandleStepIn(function, object, fp(), false);
539
+ return *function;
540
+ }
541
+ #endif
542
+
543
+ return *result_handle;
544
+ }
545
+
546
+ // Try to find a suitable function delegate for the object at hand.
547
+ result_handle = Handle<Object>(TryCallAsFunction(*result_handle));
548
+ if (result_handle->IsJSFunction()) return *result_handle;
549
+
550
+ return TypeError("property_not_function", object, name);
551
+ }
552
+
553
+
554
+ bool CallICBase::TryUpdateExtraICState(LookupResult* lookup,
555
+ Handle<Object> object,
556
+ Code::ExtraICState* extra_ic_state) {
557
+ ASSERT(kind_ == Code::CALL_IC);
558
+ if (lookup->type() != CONSTANT_FUNCTION) return false;
559
+ JSFunction* function = lookup->GetConstantFunction();
560
+ if (!function->shared()->HasBuiltinFunctionId()) return false;
561
+
562
+ // Fetch the arguments passed to the called function.
563
+ const int argc = target()->arguments_count();
564
+ Address entry = isolate()->c_entry_fp(isolate()->thread_local_top());
565
+ Address fp = Memory::Address_at(entry + ExitFrameConstants::kCallerFPOffset);
566
+ Arguments args(argc + 1,
567
+ &Memory::Object_at(fp +
568
+ StandardFrameConstants::kCallerSPOffset +
569
+ argc * kPointerSize));
570
+ switch (function->shared()->builtin_function_id()) {
571
+ case kStringCharCodeAt:
572
+ case kStringCharAt:
573
+ if (object->IsString()) {
574
+ String* string = String::cast(*object);
575
+ // Check there's the right string value or wrapper in the receiver slot.
576
+ ASSERT(string == args[0] || string == JSValue::cast(args[0])->value());
577
+ // If we're in the default (fastest) state and the index is
578
+ // out of bounds, update the state to record this fact.
579
+ if (StringStubState::decode(*extra_ic_state) == DEFAULT_STRING_STUB &&
580
+ argc >= 1 && args[1]->IsNumber()) {
581
+ double index;
582
+ if (args[1]->IsSmi()) {
583
+ index = Smi::cast(args[1])->value();
584
+ } else {
585
+ ASSERT(args[1]->IsHeapNumber());
586
+ index = DoubleToInteger(HeapNumber::cast(args[1])->value());
587
+ }
588
+ if (index < 0 || index >= string->length()) {
589
+ *extra_ic_state =
590
+ StringStubState::update(*extra_ic_state,
591
+ STRING_INDEX_OUT_OF_BOUNDS);
592
+ return true;
593
+ }
594
+ }
595
+ }
596
+ break;
597
+ default:
598
+ return false;
599
+ }
600
+ return false;
601
+ }
602
+
603
+
604
+ MaybeObject* CallICBase::ComputeMonomorphicStub(
605
+ LookupResult* lookup,
606
+ State state,
607
+ Code::ExtraICState extra_ic_state,
608
+ Handle<Object> object,
609
+ Handle<String> name) {
610
+ int argc = target()->arguments_count();
611
+ InLoopFlag in_loop = target()->ic_in_loop();
612
+ MaybeObject* maybe_code = NULL;
613
+ switch (lookup->type()) {
614
+ case FIELD: {
615
+ int index = lookup->GetFieldIndex();
616
+ maybe_code = isolate()->stub_cache()->ComputeCallField(argc,
617
+ in_loop,
618
+ kind_,
619
+ extra_ic_state,
620
+ *name,
621
+ *object,
622
+ lookup->holder(),
623
+ index);
624
+ break;
625
+ }
626
+ case CONSTANT_FUNCTION: {
627
+ // Get the constant function and compute the code stub for this
628
+ // call; used for rewriting to monomorphic state and making sure
629
+ // that the code stub is in the stub cache.
630
+ JSFunction* function = lookup->GetConstantFunction();
631
+ maybe_code =
632
+ isolate()->stub_cache()->ComputeCallConstant(argc,
633
+ in_loop,
634
+ kind_,
635
+ extra_ic_state,
636
+ *name,
637
+ *object,
638
+ lookup->holder(),
639
+ function);
640
+ break;
641
+ }
642
+ case NORMAL: {
643
+ if (!object->IsJSObject()) return NULL;
644
+ Handle<JSObject> receiver = Handle<JSObject>::cast(object);
645
+
646
+ if (lookup->holder()->IsGlobalObject()) {
647
+ GlobalObject* global = GlobalObject::cast(lookup->holder());
648
+ JSGlobalPropertyCell* cell =
649
+ JSGlobalPropertyCell::cast(global->GetPropertyCell(lookup));
650
+ if (!cell->value()->IsJSFunction()) return NULL;
651
+ JSFunction* function = JSFunction::cast(cell->value());
652
+ maybe_code = isolate()->stub_cache()->ComputeCallGlobal(argc,
653
+ in_loop,
654
+ kind_,
655
+ extra_ic_state,
656
+ *name,
657
+ *receiver,
658
+ global,
659
+ cell,
660
+ function);
661
+ } else {
662
+ // There is only one shared stub for calling normalized
663
+ // properties. It does not traverse the prototype chain, so the
664
+ // property must be found in the receiver for the stub to be
665
+ // applicable.
666
+ if (lookup->holder() != *receiver) return NULL;
667
+ maybe_code = isolate()->stub_cache()->ComputeCallNormal(argc,
668
+ in_loop,
669
+ kind_,
670
+ extra_ic_state,
671
+ *name,
672
+ *receiver);
673
+ }
674
+ break;
675
+ }
676
+ case INTERCEPTOR: {
677
+ ASSERT(HasInterceptorGetter(lookup->holder()));
678
+ maybe_code = isolate()->stub_cache()->ComputeCallInterceptor(
679
+ argc,
680
+ kind_,
681
+ extra_ic_state,
682
+ *name,
683
+ *object,
684
+ lookup->holder());
685
+ break;
686
+ }
687
+ default:
688
+ maybe_code = NULL;
689
+ break;
690
+ }
691
+ return maybe_code;
692
+ }
693
+
694
+
695
+ void CallICBase::UpdateCaches(LookupResult* lookup,
696
+ State state,
697
+ Code::ExtraICState extra_ic_state,
698
+ Handle<Object> object,
699
+ Handle<String> name) {
700
+ // Bail out if we didn't find a result.
701
+ if (!lookup->IsProperty() || !lookup->IsCacheable()) return;
702
+
703
+ if (lookup->holder() != *object &&
704
+ HasNormalObjectsInPrototypeChain(
705
+ isolate(), lookup, object->GetPrototype())) {
706
+ // Suppress optimization for prototype chains with slow properties objects
707
+ // in the middle.
708
+ return;
709
+ }
710
+
711
+ // Compute the number of arguments.
712
+ int argc = target()->arguments_count();
713
+ InLoopFlag in_loop = target()->ic_in_loop();
714
+ MaybeObject* maybe_code = NULL;
715
+ bool had_proto_failure = false;
716
+ if (state == UNINITIALIZED) {
717
+ // This is the first time we execute this inline cache.
718
+ // Set the target to the pre monomorphic stub to delay
719
+ // setting the monomorphic state.
720
+ maybe_code =
721
+ isolate()->stub_cache()->ComputeCallPreMonomorphic(argc,
722
+ in_loop,
723
+ kind_,
724
+ extra_ic_state);
725
+ } else if (state == MONOMORPHIC) {
726
+ if (kind_ == Code::CALL_IC &&
727
+ TryUpdateExtraICState(lookup, object, &extra_ic_state)) {
728
+ maybe_code = ComputeMonomorphicStub(lookup,
729
+ state,
730
+ extra_ic_state,
731
+ object,
732
+ name);
733
+ } else if (kind_ == Code::CALL_IC &&
734
+ TryRemoveInvalidPrototypeDependentStub(target(),
735
+ *object,
736
+ *name)) {
737
+ had_proto_failure = true;
738
+ maybe_code = ComputeMonomorphicStub(lookup,
739
+ state,
740
+ extra_ic_state,
741
+ object,
742
+ name);
743
+ } else {
744
+ maybe_code =
745
+ isolate()->stub_cache()->ComputeCallMegamorphic(argc,
746
+ in_loop,
747
+ kind_,
748
+ extra_ic_state);
749
+ }
750
+ } else {
751
+ maybe_code = ComputeMonomorphicStub(lookup,
752
+ state,
753
+ extra_ic_state,
754
+ object,
755
+ name);
756
+ }
757
+
758
+ // If we're unable to compute the stub (not enough memory left), we
759
+ // simply avoid updating the caches.
760
+ Object* code;
761
+ if (maybe_code == NULL || !maybe_code->ToObject(&code)) return;
762
+
763
+ // Patch the call site depending on the state of the cache.
764
+ if (state == UNINITIALIZED ||
765
+ state == PREMONOMORPHIC ||
766
+ state == MONOMORPHIC ||
767
+ state == MONOMORPHIC_PROTOTYPE_FAILURE) {
768
+ set_target(Code::cast(code));
769
+ } else if (state == MEGAMORPHIC) {
770
+ // Cache code holding map should be consistent with
771
+ // GenerateMonomorphicCacheProbe. It is not the map which holds the stub.
772
+ Map* map = JSObject::cast(object->IsJSObject() ? *object :
773
+ object->GetPrototype())->map();
774
+
775
+ // Update the stub cache.
776
+ isolate()->stub_cache()->Set(*name, map, Code::cast(code));
777
+ }
778
+
779
+ USE(had_proto_failure);
780
+ #ifdef DEBUG
781
+ if (had_proto_failure) state = MONOMORPHIC_PROTOTYPE_FAILURE;
782
+ TraceIC(kind_ == Code::CALL_IC ? "CallIC" : "KeyedCallIC",
783
+ name, state, target(), in_loop ? " (in-loop)" : "");
784
+ #endif
785
+ }
786
+
787
+
788
+ MaybeObject* KeyedCallIC::LoadFunction(State state,
789
+ Handle<Object> object,
790
+ Handle<Object> key) {
791
+ if (key->IsSymbol()) {
792
+ return CallICBase::LoadFunction(state,
793
+ Code::kNoExtraICState,
794
+ object,
795
+ Handle<String>::cast(key));
796
+ }
797
+
798
+ if (object->IsUndefined() || object->IsNull()) {
799
+ return TypeError("non_object_property_call", object, key);
800
+ }
801
+
802
+ if (FLAG_use_ic && state != MEGAMORPHIC && !object->IsAccessCheckNeeded()) {
803
+ int argc = target()->arguments_count();
804
+ InLoopFlag in_loop = target()->ic_in_loop();
805
+ MaybeObject* maybe_code = isolate()->stub_cache()->ComputeCallMegamorphic(
806
+ argc, in_loop, Code::KEYED_CALL_IC, Code::kNoExtraICState);
807
+ Object* code;
808
+ if (maybe_code->ToObject(&code)) {
809
+ set_target(Code::cast(code));
810
+ #ifdef DEBUG
811
+ TraceIC(
812
+ "KeyedCallIC", key, state, target(), in_loop ? " (in-loop)" : "");
813
+ #endif
814
+ }
815
+ }
816
+
817
+ HandleScope scope(isolate());
818
+ Handle<Object> result = GetProperty(object, key);
819
+ RETURN_IF_EMPTY_HANDLE(isolate(), result);
820
+
821
+ // Make receiver an object if the callee requires it. Strict mode or builtin
822
+ // functions do not wrap the receiver, non-strict functions and objects
823
+ // called as functions do.
824
+ ReceiverToObjectIfRequired(result, object);
825
+
826
+ if (result->IsJSFunction()) return *result;
827
+ result = Handle<Object>(TryCallAsFunction(*result));
828
+ if (result->IsJSFunction()) return *result;
829
+
830
+ return TypeError("property_not_function", object, key);
831
+ }
832
+
833
+
834
+ #ifdef DEBUG
835
+ #define TRACE_IC_NAMED(msg, name) \
836
+ if (FLAG_trace_ic) PrintF(msg, *(name)->ToCString())
837
+ #else
838
+ #define TRACE_IC_NAMED(msg, name)
839
+ #endif
840
+
841
+
842
+ MaybeObject* LoadIC::Load(State state,
843
+ Handle<Object> object,
844
+ Handle<String> name) {
845
+ // If the object is undefined or null it's illegal to try to get any
846
+ // of its properties; throw a TypeError in that case.
847
+ if (object->IsUndefined() || object->IsNull()) {
848
+ return TypeError("non_object_property_load", object, name);
849
+ }
850
+
851
+ if (FLAG_use_ic) {
852
+ Code* non_monomorphic_stub =
853
+ (state == UNINITIALIZED) ? pre_monomorphic_stub() : megamorphic_stub();
854
+
855
+ // Use specialized code for getting the length of strings and
856
+ // string wrapper objects. The length property of string wrapper
857
+ // objects is read-only and therefore always returns the length of
858
+ // the underlying string value. See ECMA-262 15.5.5.1.
859
+ if ((object->IsString() || object->IsStringWrapper()) &&
860
+ name->Equals(isolate()->heap()->length_symbol())) {
861
+ HandleScope scope(isolate());
862
+ #ifdef DEBUG
863
+ if (FLAG_trace_ic) PrintF("[LoadIC : +#length /string]\n");
864
+ #endif
865
+ if (state == PREMONOMORPHIC) {
866
+ if (object->IsString()) {
867
+ set_target(isolate()->builtins()->builtin(
868
+ Builtins::kLoadIC_StringLength));
869
+ } else {
870
+ set_target(isolate()->builtins()->builtin(
871
+ Builtins::kLoadIC_StringWrapperLength));
872
+ }
873
+ } else if (state == MONOMORPHIC && object->IsStringWrapper()) {
874
+ set_target(isolate()->builtins()->builtin(
875
+ Builtins::kLoadIC_StringWrapperLength));
876
+ } else {
877
+ set_target(non_monomorphic_stub);
878
+ }
879
+ // Get the string if we have a string wrapper object.
880
+ if (object->IsJSValue()) {
881
+ object = Handle<Object>(Handle<JSValue>::cast(object)->value(),
882
+ isolate());
883
+ }
884
+ return Smi::FromInt(String::cast(*object)->length());
885
+ }
886
+
887
+ // Use specialized code for getting the length of arrays.
888
+ if (object->IsJSArray() &&
889
+ name->Equals(isolate()->heap()->length_symbol())) {
890
+ #ifdef DEBUG
891
+ if (FLAG_trace_ic) PrintF("[LoadIC : +#length /array]\n");
892
+ #endif
893
+ if (state == PREMONOMORPHIC) {
894
+ set_target(isolate()->builtins()->builtin(
895
+ Builtins::kLoadIC_ArrayLength));
896
+ } else {
897
+ set_target(non_monomorphic_stub);
898
+ }
899
+ return JSArray::cast(*object)->length();
900
+ }
901
+
902
+ // Use specialized code for getting prototype of functions.
903
+ if (object->IsJSFunction() &&
904
+ name->Equals(isolate()->heap()->prototype_symbol()) &&
905
+ JSFunction::cast(*object)->should_have_prototype()) {
906
+ #ifdef DEBUG
907
+ if (FLAG_trace_ic) PrintF("[LoadIC : +#prototype /function]\n");
908
+ #endif
909
+ if (state == PREMONOMORPHIC) {
910
+ set_target(isolate()->builtins()->builtin(
911
+ Builtins::kLoadIC_FunctionPrototype));
912
+ } else {
913
+ set_target(non_monomorphic_stub);
914
+ }
915
+ return Accessors::FunctionGetPrototype(*object, 0);
916
+ }
917
+ }
918
+
919
+ // Check if the name is trivially convertible to an index and get
920
+ // the element if so.
921
+ uint32_t index;
922
+ if (name->AsArrayIndex(&index)) return object->GetElement(index);
923
+
924
+ // Named lookup in the object.
925
+ LookupResult lookup;
926
+ LookupForRead(*object, *name, &lookup);
927
+
928
+ // If we did not find a property, check if we need to throw an exception.
929
+ if (!lookup.IsProperty()) {
930
+ if (FLAG_strict || IsContextual(object)) {
931
+ return ReferenceError("not_defined", name);
932
+ }
933
+ LOG(isolate(), SuspectReadEvent(*name, *object));
934
+ }
935
+
936
+ // Update inline cache and stub cache.
937
+ if (FLAG_use_ic) {
938
+ UpdateCaches(&lookup, state, object, name);
939
+ }
940
+
941
+ PropertyAttributes attr;
942
+ if (lookup.IsProperty() &&
943
+ (lookup.type() == INTERCEPTOR || lookup.type() == HANDLER)) {
944
+ // Get the property.
945
+ Object* result;
946
+ { MaybeObject* maybe_result =
947
+ object->GetProperty(*object, &lookup, *name, &attr);
948
+ if (!maybe_result->ToObject(&result)) return maybe_result;
949
+ }
950
+ // If the property is not present, check if we need to throw an
951
+ // exception.
952
+ if (attr == ABSENT && IsContextual(object)) {
953
+ return ReferenceError("not_defined", name);
954
+ }
955
+ return result;
956
+ }
957
+
958
+ // Get the property.
959
+ return object->GetProperty(*object, &lookup, *name, &attr);
960
+ }
961
+
962
+
963
+ void LoadIC::UpdateCaches(LookupResult* lookup,
964
+ State state,
965
+ Handle<Object> object,
966
+ Handle<String> name) {
967
+ // Bail out if the result is not cacheable.
968
+ if (!lookup->IsCacheable()) return;
969
+
970
+ // Loading properties from values is not common, so don't try to
971
+ // deal with non-JS objects here.
972
+ if (!object->IsJSObject()) return;
973
+ Handle<JSObject> receiver = Handle<JSObject>::cast(object);
974
+
975
+ if (HasNormalObjectsInPrototypeChain(isolate(), lookup, *object)) return;
976
+
977
+ // Compute the code stub for this load.
978
+ MaybeObject* maybe_code = NULL;
979
+ Object* code;
980
+ if (state == UNINITIALIZED) {
981
+ // This is the first time we execute this inline cache.
982
+ // Set the target to the pre monomorphic stub to delay
983
+ // setting the monomorphic state.
984
+ maybe_code = pre_monomorphic_stub();
985
+ } else if (!lookup->IsProperty()) {
986
+ // Nonexistent property. The result is undefined.
987
+ maybe_code = isolate()->stub_cache()->ComputeLoadNonexistent(*name,
988
+ *receiver);
989
+ } else {
990
+ // Compute monomorphic stub.
991
+ switch (lookup->type()) {
992
+ case FIELD: {
993
+ maybe_code = isolate()->stub_cache()->ComputeLoadField(
994
+ *name,
995
+ *receiver,
996
+ lookup->holder(),
997
+ lookup->GetFieldIndex());
998
+ break;
999
+ }
1000
+ case CONSTANT_FUNCTION: {
1001
+ Object* constant = lookup->GetConstantFunction();
1002
+ maybe_code = isolate()->stub_cache()->ComputeLoadConstant(
1003
+ *name, *receiver, lookup->holder(), constant);
1004
+ break;
1005
+ }
1006
+ case NORMAL: {
1007
+ if (lookup->holder()->IsGlobalObject()) {
1008
+ GlobalObject* global = GlobalObject::cast(lookup->holder());
1009
+ JSGlobalPropertyCell* cell =
1010
+ JSGlobalPropertyCell::cast(global->GetPropertyCell(lookup));
1011
+ maybe_code = isolate()->stub_cache()->ComputeLoadGlobal(*name,
1012
+ *receiver,
1013
+ global,
1014
+ cell,
1015
+ lookup->IsDontDelete());
1016
+ } else {
1017
+ // There is only one shared stub for loading normalized
1018
+ // properties. It does not traverse the prototype chain, so the
1019
+ // property must be found in the receiver for the stub to be
1020
+ // applicable.
1021
+ if (lookup->holder() != *receiver) return;
1022
+ maybe_code = isolate()->stub_cache()->ComputeLoadNormal();
1023
+ }
1024
+ break;
1025
+ }
1026
+ case CALLBACKS: {
1027
+ if (!lookup->GetCallbackObject()->IsAccessorInfo()) return;
1028
+ AccessorInfo* callback =
1029
+ AccessorInfo::cast(lookup->GetCallbackObject());
1030
+ if (v8::ToCData<Address>(callback->getter()) == 0) return;
1031
+ maybe_code = isolate()->stub_cache()->ComputeLoadCallback(
1032
+ *name, *receiver, lookup->holder(), callback);
1033
+ break;
1034
+ }
1035
+ case INTERCEPTOR: {
1036
+ ASSERT(HasInterceptorGetter(lookup->holder()));
1037
+ maybe_code = isolate()->stub_cache()->ComputeLoadInterceptor(
1038
+ *name, *receiver, lookup->holder());
1039
+ break;
1040
+ }
1041
+ default:
1042
+ return;
1043
+ }
1044
+ }
1045
+
1046
+ // If we're unable to compute the stub (not enough memory left), we
1047
+ // simply avoid updating the caches.
1048
+ if (maybe_code == NULL || !maybe_code->ToObject(&code)) return;
1049
+
1050
+ // Patch the call site depending on the state of the cache.
1051
+ if (state == UNINITIALIZED || state == PREMONOMORPHIC ||
1052
+ state == MONOMORPHIC_PROTOTYPE_FAILURE) {
1053
+ set_target(Code::cast(code));
1054
+ } else if (state == MONOMORPHIC) {
1055
+ set_target(megamorphic_stub());
1056
+ } else if (state == MEGAMORPHIC) {
1057
+ // Cache code holding map should be consistent with
1058
+ // GenerateMonomorphicCacheProbe.
1059
+ Map* map = JSObject::cast(object->IsJSObject() ? *object :
1060
+ object->GetPrototype())->map();
1061
+
1062
+ isolate()->stub_cache()->Set(*name, map, Code::cast(code));
1063
+ }
1064
+
1065
+ #ifdef DEBUG
1066
+ TraceIC("LoadIC", name, state, target());
1067
+ #endif
1068
+ }
1069
+
1070
+
1071
+ String* KeyedLoadIC::GetStubNameForCache(IC::State ic_state) {
1072
+ if (ic_state == MONOMORPHIC) {
1073
+ return isolate()->heap()->KeyedLoadSpecializedMonomorphic_symbol();
1074
+ } else {
1075
+ ASSERT(ic_state == MEGAMORPHIC);
1076
+ return isolate()->heap()->KeyedLoadSpecializedPolymorphic_symbol();
1077
+ }
1078
+ }
1079
+
1080
+
1081
+ MaybeObject* KeyedLoadIC::GetFastElementStubWithoutMapCheck(
1082
+ bool is_js_array) {
1083
+ return KeyedLoadFastElementStub().TryGetCode();
1084
+ }
1085
+
1086
+
1087
+ MaybeObject* KeyedLoadIC::GetExternalArrayStubWithoutMapCheck(
1088
+ ExternalArrayType array_type) {
1089
+ return KeyedLoadExternalArrayStub(array_type).TryGetCode();
1090
+ }
1091
+
1092
+
1093
+ MaybeObject* KeyedLoadIC::ConstructMegamorphicStub(
1094
+ MapList* receiver_maps,
1095
+ CodeList* targets,
1096
+ StrictModeFlag strict_mode) {
1097
+ Object* object;
1098
+ KeyedLoadStubCompiler compiler;
1099
+ MaybeObject* maybe_code = compiler.CompileLoadMegamorphic(receiver_maps,
1100
+ targets);
1101
+ if (!maybe_code->ToObject(&object)) return maybe_code;
1102
+ isolate()->counters()->keyed_load_polymorphic_stubs()->Increment();
1103
+ PROFILE(isolate(), CodeCreateEvent(
1104
+ Logger::KEYED_LOAD_MEGAMORPHIC_IC_TAG,
1105
+ Code::cast(object), 0));
1106
+ return object;
1107
+ }
1108
+
1109
+
1110
+ MaybeObject* KeyedLoadIC::Load(State state,
1111
+ Handle<Object> object,
1112
+ Handle<Object> key,
1113
+ bool force_generic_stub) {
1114
+ // Check for values that can be converted into a symbol.
1115
+ // TODO(1295): Remove this code.
1116
+ HandleScope scope(isolate());
1117
+ if (key->IsHeapNumber() &&
1118
+ isnan(HeapNumber::cast(*key)->value())) {
1119
+ key = isolate()->factory()->nan_symbol();
1120
+ } else if (key->IsUndefined()) {
1121
+ key = isolate()->factory()->undefined_symbol();
1122
+ }
1123
+
1124
+ if (key->IsSymbol()) {
1125
+ Handle<String> name = Handle<String>::cast(key);
1126
+
1127
+ // If the object is undefined or null it's illegal to try to get any
1128
+ // of its properties; throw a TypeError in that case.
1129
+ if (object->IsUndefined() || object->IsNull()) {
1130
+ return TypeError("non_object_property_load", object, name);
1131
+ }
1132
+
1133
+ if (FLAG_use_ic) {
1134
+ // TODO(1073): don't ignore the current stub state.
1135
+
1136
+ // Use specialized code for getting the length of strings.
1137
+ if (object->IsString() &&
1138
+ name->Equals(isolate()->heap()->length_symbol())) {
1139
+ Handle<String> string = Handle<String>::cast(object);
1140
+ Object* code = NULL;
1141
+ { MaybeObject* maybe_code =
1142
+ isolate()->stub_cache()->ComputeKeyedLoadStringLength(*name,
1143
+ *string);
1144
+ if (!maybe_code->ToObject(&code)) return maybe_code;
1145
+ }
1146
+ set_target(Code::cast(code));
1147
+ #ifdef DEBUG
1148
+ TraceIC("KeyedLoadIC", name, state, target());
1149
+ #endif // DEBUG
1150
+ return Smi::FromInt(string->length());
1151
+ }
1152
+
1153
+ // Use specialized code for getting the length of arrays.
1154
+ if (object->IsJSArray() &&
1155
+ name->Equals(isolate()->heap()->length_symbol())) {
1156
+ Handle<JSArray> array = Handle<JSArray>::cast(object);
1157
+ Object* code;
1158
+ { MaybeObject* maybe_code =
1159
+ isolate()->stub_cache()->ComputeKeyedLoadArrayLength(*name,
1160
+ *array);
1161
+ if (!maybe_code->ToObject(&code)) return maybe_code;
1162
+ }
1163
+ set_target(Code::cast(code));
1164
+ #ifdef DEBUG
1165
+ TraceIC("KeyedLoadIC", name, state, target());
1166
+ #endif // DEBUG
1167
+ return JSArray::cast(*object)->length();
1168
+ }
1169
+
1170
+ // Use specialized code for getting prototype of functions.
1171
+ if (object->IsJSFunction() &&
1172
+ name->Equals(isolate()->heap()->prototype_symbol()) &&
1173
+ JSFunction::cast(*object)->should_have_prototype()) {
1174
+ Handle<JSFunction> function = Handle<JSFunction>::cast(object);
1175
+ Object* code;
1176
+ { MaybeObject* maybe_code =
1177
+ isolate()->stub_cache()->ComputeKeyedLoadFunctionPrototype(
1178
+ *name, *function);
1179
+ if (!maybe_code->ToObject(&code)) return maybe_code;
1180
+ }
1181
+ set_target(Code::cast(code));
1182
+ #ifdef DEBUG
1183
+ TraceIC("KeyedLoadIC", name, state, target());
1184
+ #endif // DEBUG
1185
+ return Accessors::FunctionGetPrototype(*object, 0);
1186
+ }
1187
+ }
1188
+
1189
+ // Check if the name is trivially convertible to an index and get
1190
+ // the element or char if so.
1191
+ uint32_t index = 0;
1192
+ if (name->AsArrayIndex(&index)) {
1193
+ HandleScope scope(isolate());
1194
+ // Rewrite to the generic keyed load stub.
1195
+ if (FLAG_use_ic) set_target(generic_stub());
1196
+ return Runtime::GetElementOrCharAt(isolate(), object, index);
1197
+ }
1198
+
1199
+ // Named lookup.
1200
+ LookupResult lookup;
1201
+ LookupForRead(*object, *name, &lookup);
1202
+
1203
+ // If we did not find a property, check if we need to throw an exception.
1204
+ if (!lookup.IsProperty()) {
1205
+ if (FLAG_strict || IsContextual(object)) {
1206
+ return ReferenceError("not_defined", name);
1207
+ }
1208
+ }
1209
+
1210
+ if (FLAG_use_ic) {
1211
+ UpdateCaches(&lookup, state, object, name);
1212
+ }
1213
+
1214
+ PropertyAttributes attr;
1215
+ if (lookup.IsProperty() && lookup.type() == INTERCEPTOR) {
1216
+ // Get the property.
1217
+ Object* result;
1218
+ { MaybeObject* maybe_result =
1219
+ object->GetProperty(*object, &lookup, *name, &attr);
1220
+ if (!maybe_result->ToObject(&result)) return maybe_result;
1221
+ }
1222
+ // If the property is not present, check if we need to throw an
1223
+ // exception.
1224
+ if (attr == ABSENT && IsContextual(object)) {
1225
+ return ReferenceError("not_defined", name);
1226
+ }
1227
+ return result;
1228
+ }
1229
+
1230
+ return object->GetProperty(*object, &lookup, *name, &attr);
1231
+ }
1232
+
1233
+ // Do not use ICs for objects that require access checks (including
1234
+ // the global object).
1235
+ bool use_ic = FLAG_use_ic && !object->IsAccessCheckNeeded();
1236
+
1237
+ if (use_ic) {
1238
+ Code* stub = generic_stub();
1239
+ if (!force_generic_stub) {
1240
+ if (object->IsString() && key->IsNumber()) {
1241
+ if (state == UNINITIALIZED) {
1242
+ stub = string_stub();
1243
+ }
1244
+ } else if (object->IsJSObject()) {
1245
+ JSObject* receiver = JSObject::cast(*object);
1246
+ if (receiver->HasIndexedInterceptor()) {
1247
+ stub = indexed_interceptor_stub();
1248
+ } else if (key->IsSmi()) {
1249
+ MaybeObject* maybe_stub = ComputeStub(receiver,
1250
+ false,
1251
+ kNonStrictMode,
1252
+ stub);
1253
+ stub = maybe_stub->IsFailure() ?
1254
+ NULL : Code::cast(maybe_stub->ToObjectUnchecked());
1255
+ }
1256
+ }
1257
+ }
1258
+ if (stub != NULL) set_target(stub);
1259
+ }
1260
+
1261
+ #ifdef DEBUG
1262
+ TraceIC("KeyedLoadIC", key, state, target());
1263
+ #endif // DEBUG
1264
+
1265
+ // Get the property.
1266
+ return Runtime::GetObjectProperty(isolate(), object, key);
1267
+ }
1268
+
1269
+
1270
+ void KeyedLoadIC::UpdateCaches(LookupResult* lookup, State state,
1271
+ Handle<Object> object, Handle<String> name) {
1272
+ // Bail out if we didn't find a result.
1273
+ if (!lookup->IsProperty() || !lookup->IsCacheable()) return;
1274
+
1275
+ if (!object->IsJSObject()) return;
1276
+ Handle<JSObject> receiver = Handle<JSObject>::cast(object);
1277
+
1278
+ if (HasNormalObjectsInPrototypeChain(isolate(), lookup, *object)) return;
1279
+
1280
+ // Compute the code stub for this load.
1281
+ MaybeObject* maybe_code = NULL;
1282
+ Object* code;
1283
+
1284
+ if (state == UNINITIALIZED) {
1285
+ // This is the first time we execute this inline cache.
1286
+ // Set the target to the pre monomorphic stub to delay
1287
+ // setting the monomorphic state.
1288
+ maybe_code = pre_monomorphic_stub();
1289
+ } else {
1290
+ // Compute a monomorphic stub.
1291
+ switch (lookup->type()) {
1292
+ case FIELD: {
1293
+ maybe_code = isolate()->stub_cache()->ComputeKeyedLoadField(
1294
+ *name, *receiver, lookup->holder(), lookup->GetFieldIndex());
1295
+ break;
1296
+ }
1297
+ case CONSTANT_FUNCTION: {
1298
+ Object* constant = lookup->GetConstantFunction();
1299
+ maybe_code = isolate()->stub_cache()->ComputeKeyedLoadConstant(
1300
+ *name, *receiver, lookup->holder(), constant);
1301
+ break;
1302
+ }
1303
+ case CALLBACKS: {
1304
+ if (!lookup->GetCallbackObject()->IsAccessorInfo()) return;
1305
+ AccessorInfo* callback =
1306
+ AccessorInfo::cast(lookup->GetCallbackObject());
1307
+ if (v8::ToCData<Address>(callback->getter()) == 0) return;
1308
+ maybe_code = isolate()->stub_cache()->ComputeKeyedLoadCallback(
1309
+ *name, *receiver, lookup->holder(), callback);
1310
+ break;
1311
+ }
1312
+ case INTERCEPTOR: {
1313
+ ASSERT(HasInterceptorGetter(lookup->holder()));
1314
+ maybe_code = isolate()->stub_cache()->ComputeKeyedLoadInterceptor(
1315
+ *name, *receiver, lookup->holder());
1316
+ break;
1317
+ }
1318
+ default: {
1319
+ // Always rewrite to the generic case so that we do not
1320
+ // repeatedly try to rewrite.
1321
+ maybe_code = generic_stub();
1322
+ break;
1323
+ }
1324
+ }
1325
+ }
1326
+
1327
+ // If we're unable to compute the stub (not enough memory left), we
1328
+ // simply avoid updating the caches.
1329
+ if (maybe_code == NULL || !maybe_code->ToObject(&code)) return;
1330
+
1331
+ // Patch the call site depending on the state of the cache. Make
1332
+ // sure to always rewrite from monomorphic to megamorphic.
1333
+ ASSERT(state != MONOMORPHIC_PROTOTYPE_FAILURE);
1334
+ if (state == UNINITIALIZED || state == PREMONOMORPHIC) {
1335
+ set_target(Code::cast(code));
1336
+ } else if (state == MONOMORPHIC) {
1337
+ set_target(megamorphic_stub());
1338
+ }
1339
+
1340
+ #ifdef DEBUG
1341
+ TraceIC("KeyedLoadIC", name, state, target());
1342
+ #endif
1343
+ }
1344
+
1345
+
1346
+ static bool StoreICableLookup(LookupResult* lookup) {
1347
+ // Bail out if we didn't find a result.
1348
+ if (!lookup->IsPropertyOrTransition() || !lookup->IsCacheable()) return false;
1349
+
1350
+ // If the property is read-only, we leave the IC in its current
1351
+ // state.
1352
+ if (lookup->IsReadOnly()) return false;
1353
+
1354
+ return true;
1355
+ }
1356
+
1357
+
1358
+ static bool LookupForWrite(JSObject* object,
1359
+ String* name,
1360
+ LookupResult* lookup) {
1361
+ object->LocalLookup(name, lookup);
1362
+ if (!StoreICableLookup(lookup)) {
1363
+ return false;
1364
+ }
1365
+
1366
+ if (lookup->type() == INTERCEPTOR) {
1367
+ if (object->GetNamedInterceptor()->setter()->IsUndefined()) {
1368
+ object->LocalLookupRealNamedProperty(name, lookup);
1369
+ return StoreICableLookup(lookup);
1370
+ }
1371
+ }
1372
+
1373
+ return true;
1374
+ }
1375
+
1376
+
1377
+ MaybeObject* StoreIC::Store(State state,
1378
+ StrictModeFlag strict_mode,
1379
+ Handle<Object> object,
1380
+ Handle<String> name,
1381
+ Handle<Object> value) {
1382
+ // If the object is undefined or null it's illegal to try to set any
1383
+ // properties on it; throw a TypeError in that case.
1384
+ if (object->IsUndefined() || object->IsNull()) {
1385
+ return TypeError("non_object_property_store", object, name);
1386
+ }
1387
+
1388
+ if (!object->IsJSObject()) {
1389
+ // The length property of string values is read-only. Throw in strict mode.
1390
+ if (strict_mode == kStrictMode && object->IsString() &&
1391
+ name->Equals(isolate()->heap()->length_symbol())) {
1392
+ return TypeError("strict_read_only_property", object, name);
1393
+ }
1394
+ // Ignore stores where the receiver is not a JSObject.
1395
+ return *value;
1396
+ }
1397
+
1398
+ Handle<JSObject> receiver = Handle<JSObject>::cast(object);
1399
+
1400
+ // Check if the given name is an array index.
1401
+ uint32_t index;
1402
+ if (name->AsArrayIndex(&index)) {
1403
+ HandleScope scope(isolate());
1404
+ Handle<Object> result = SetElement(receiver, index, value, strict_mode);
1405
+ if (result.is_null()) return Failure::Exception();
1406
+ return *value;
1407
+ }
1408
+
1409
+ // Use specialized code for setting the length of arrays.
1410
+ if (receiver->IsJSArray()
1411
+ && name->Equals(isolate()->heap()->length_symbol())
1412
+ && receiver->AllowsSetElementsLength()) {
1413
+ #ifdef DEBUG
1414
+ if (FLAG_trace_ic) PrintF("[StoreIC : +#length /array]\n");
1415
+ #endif
1416
+ Builtins::Name target = (strict_mode == kStrictMode)
1417
+ ? Builtins::kStoreIC_ArrayLength_Strict
1418
+ : Builtins::kStoreIC_ArrayLength;
1419
+ set_target(isolate()->builtins()->builtin(target));
1420
+ return receiver->SetProperty(*name, *value, NONE, strict_mode);
1421
+ }
1422
+
1423
+ // Lookup the property locally in the receiver.
1424
+ if (FLAG_use_ic && !receiver->IsJSGlobalProxy()) {
1425
+ LookupResult lookup;
1426
+
1427
+ if (LookupForWrite(*receiver, *name, &lookup)) {
1428
+ // Generate a stub for this store.
1429
+ UpdateCaches(&lookup, state, strict_mode, receiver, name, value);
1430
+ } else {
1431
+ // Strict mode doesn't allow setting non-existent global property
1432
+ // or an assignment to a read only property.
1433
+ if (strict_mode == kStrictMode) {
1434
+ if (lookup.IsFound() && lookup.IsReadOnly()) {
1435
+ return TypeError("strict_read_only_property", object, name);
1436
+ } else if (IsContextual(object)) {
1437
+ return ReferenceError("not_defined", name);
1438
+ }
1439
+ }
1440
+ }
1441
+ }
1442
+
1443
+ if (receiver->IsJSGlobalProxy()) {
1444
+ // Generate a generic stub that goes to the runtime when we see a global
1445
+ // proxy as receiver.
1446
+ Code* stub = (strict_mode == kStrictMode)
1447
+ ? global_proxy_stub_strict()
1448
+ : global_proxy_stub();
1449
+ if (target() != stub) {
1450
+ set_target(stub);
1451
+ #ifdef DEBUG
1452
+ TraceIC("StoreIC", name, state, target());
1453
+ #endif
1454
+ }
1455
+ }
1456
+
1457
+ // Set the property.
1458
+ return receiver->SetProperty(*name, *value, NONE, strict_mode);
1459
+ }
1460
+
1461
+
1462
+ void StoreIC::UpdateCaches(LookupResult* lookup,
1463
+ State state,
1464
+ StrictModeFlag strict_mode,
1465
+ Handle<JSObject> receiver,
1466
+ Handle<String> name,
1467
+ Handle<Object> value) {
1468
+ // Skip JSGlobalProxy.
1469
+ ASSERT(!receiver->IsJSGlobalProxy());
1470
+
1471
+ ASSERT(StoreICableLookup(lookup));
1472
+
1473
+ // If the property has a non-field type allowing map transitions
1474
+ // where there is extra room in the object, we leave the IC in its
1475
+ // current state.
1476
+ PropertyType type = lookup->type();
1477
+
1478
+ // Compute the code stub for this store; used for rewriting to
1479
+ // monomorphic state and making sure that the code stub is in the
1480
+ // stub cache.
1481
+ MaybeObject* maybe_code = NULL;
1482
+ Object* code = NULL;
1483
+ switch (type) {
1484
+ case FIELD: {
1485
+ maybe_code = isolate()->stub_cache()->ComputeStoreField(
1486
+ *name, *receiver, lookup->GetFieldIndex(), NULL, strict_mode);
1487
+ break;
1488
+ }
1489
+ case MAP_TRANSITION: {
1490
+ if (lookup->GetAttributes() != NONE) return;
1491
+ HandleScope scope(isolate());
1492
+ ASSERT(type == MAP_TRANSITION);
1493
+ Handle<Map> transition(lookup->GetTransitionMap());
1494
+ int index = transition->PropertyIndexFor(*name);
1495
+ maybe_code = isolate()->stub_cache()->ComputeStoreField(
1496
+ *name, *receiver, index, *transition, strict_mode);
1497
+ break;
1498
+ }
1499
+ case NORMAL: {
1500
+ if (receiver->IsGlobalObject()) {
1501
+ // The stub generated for the global object picks the value directly
1502
+ // from the property cell. So the property must be directly on the
1503
+ // global object.
1504
+ Handle<GlobalObject> global = Handle<GlobalObject>::cast(receiver);
1505
+ JSGlobalPropertyCell* cell =
1506
+ JSGlobalPropertyCell::cast(global->GetPropertyCell(lookup));
1507
+ maybe_code = isolate()->stub_cache()->ComputeStoreGlobal(
1508
+ *name, *global, cell, strict_mode);
1509
+ } else {
1510
+ if (lookup->holder() != *receiver) return;
1511
+ maybe_code = isolate()->stub_cache()->ComputeStoreNormal(strict_mode);
1512
+ }
1513
+ break;
1514
+ }
1515
+ case CALLBACKS: {
1516
+ if (!lookup->GetCallbackObject()->IsAccessorInfo()) return;
1517
+ AccessorInfo* callback = AccessorInfo::cast(lookup->GetCallbackObject());
1518
+ if (v8::ToCData<Address>(callback->setter()) == 0) return;
1519
+ maybe_code = isolate()->stub_cache()->ComputeStoreCallback(
1520
+ *name, *receiver, callback, strict_mode);
1521
+ break;
1522
+ }
1523
+ case INTERCEPTOR: {
1524
+ ASSERT(!receiver->GetNamedInterceptor()->setter()->IsUndefined());
1525
+ maybe_code = isolate()->stub_cache()->ComputeStoreInterceptor(
1526
+ *name, *receiver, strict_mode);
1527
+ break;
1528
+ }
1529
+ default:
1530
+ return;
1531
+ }
1532
+
1533
+ // If we're unable to compute the stub (not enough memory left), we
1534
+ // simply avoid updating the caches.
1535
+ if (maybe_code == NULL || !maybe_code->ToObject(&code)) return;
1536
+
1537
+ // Patch the call site depending on the state of the cache.
1538
+ if (state == UNINITIALIZED || state == MONOMORPHIC_PROTOTYPE_FAILURE) {
1539
+ set_target(Code::cast(code));
1540
+ } else if (state == MONOMORPHIC) {
1541
+ // Only move to megamorphic if the target changes.
1542
+ if (target() != Code::cast(code)) {
1543
+ set_target((strict_mode == kStrictMode)
1544
+ ? megamorphic_stub_strict()
1545
+ : megamorphic_stub());
1546
+ }
1547
+ } else if (state == MEGAMORPHIC) {
1548
+ // Update the stub cache.
1549
+ isolate()->stub_cache()->Set(*name,
1550
+ receiver->map(),
1551
+ Code::cast(code));
1552
+ }
1553
+
1554
+ #ifdef DEBUG
1555
+ TraceIC("StoreIC", name, state, target());
1556
+ #endif
1557
+ }
1558
+
1559
+
1560
+ static bool AddOneReceiverMapIfMissing(MapList* receiver_maps,
1561
+ Map* new_receiver_map) {
1562
+ for (int current = 0; current < receiver_maps->length(); ++current) {
1563
+ if (receiver_maps->at(current) == new_receiver_map) {
1564
+ return false;
1565
+ }
1566
+ }
1567
+ receiver_maps->Add(new_receiver_map);
1568
+ return true;
1569
+ }
1570
+
1571
+
1572
+ void KeyedIC::GetReceiverMapsForStub(Code* stub, MapList* result) {
1573
+ ASSERT(stub->is_inline_cache_stub());
1574
+ if (stub == string_stub()) {
1575
+ return result->Add(isolate()->heap()->string_map());
1576
+ } else if (stub->is_keyed_load_stub() || stub->is_keyed_store_stub()) {
1577
+ if (stub->ic_state() == MONOMORPHIC) {
1578
+ result->Add(Map::cast(stub->FindFirstMap()));
1579
+ } else {
1580
+ ASSERT(stub->ic_state() == MEGAMORPHIC);
1581
+ AssertNoAllocation no_allocation;
1582
+ int mask = RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT);
1583
+ for (RelocIterator it(stub, mask); !it.done(); it.next()) {
1584
+ RelocInfo* info = it.rinfo();
1585
+ Object* object = info->target_object();
1586
+ ASSERT(object->IsMap());
1587
+ result->Add(Map::cast(object));
1588
+ }
1589
+ }
1590
+ }
1591
+ }
1592
+
1593
+
1594
+ MaybeObject* KeyedIC::ComputeStub(JSObject* receiver,
1595
+ bool is_store,
1596
+ StrictModeFlag strict_mode,
1597
+ Code* generic_stub) {
1598
+ State ic_state = target()->ic_state();
1599
+ Code* monomorphic_stub;
1600
+ // Always compute the MONOMORPHIC stub, even if the MEGAMORPHIC stub ends up
1601
+ // being used. This is necessary because the megamorphic stub needs to have
1602
+ // access to more information than what is stored in the receiver map in some
1603
+ // cases (external arrays need the array type from the MONOMORPHIC stub).
1604
+ MaybeObject* maybe_stub = ComputeMonomorphicStub(receiver,
1605
+ is_store,
1606
+ strict_mode,
1607
+ generic_stub);
1608
+ if (!maybe_stub->To(&monomorphic_stub)) return maybe_stub;
1609
+
1610
+ if (ic_state == UNINITIALIZED || ic_state == PREMONOMORPHIC) {
1611
+ return monomorphic_stub;
1612
+ }
1613
+ ASSERT(target() != generic_stub);
1614
+
1615
+ // Don't handle megamorphic property accesses for INTERCEPTORS or CALLBACKS
1616
+ // via megamorphic stubs, since they don't have a map in their relocation info
1617
+ // and so the stubs can't be harvested for the object needed for a map check.
1618
+ if (target()->type() != NORMAL) {
1619
+ return generic_stub;
1620
+ }
1621
+
1622
+ // Determine the list of receiver maps that this call site has seen,
1623
+ // adding the map that was just encountered.
1624
+ MapList target_receiver_maps;
1625
+ GetReceiverMapsForStub(target(), &target_receiver_maps);
1626
+ if (!AddOneReceiverMapIfMissing(&target_receiver_maps, receiver->map())) {
1627
+ // If the miss wasn't due to an unseen map, a MEGAMORPHIC stub
1628
+ // won't help, use the generic stub.
1629
+ return generic_stub;
1630
+ }
1631
+
1632
+ // TODO(1385): Currently MEGAMORPHIC stubs are cached in the receiver map stub
1633
+ // cache, but that can put receiver types together from unrelated call sites
1634
+ // into the same stub--they always handle the union of all receiver maps seen
1635
+ // at all call sites involving the receiver map. This is only an
1636
+ // approximation: ideally, there would be a global cache that mapped sets of
1637
+ // receiver maps to MEGAMORPHIC stubs. The complexity of the MEGAMORPHIC stub
1638
+ // computation also leads to direct manipulation of the stub cache from the IC
1639
+ // code, which the global cache solution would avoid.
1640
+ Code::Kind kind = this->kind();
1641
+ Code::Flags flags = Code::ComputeFlags(kind,
1642
+ NOT_IN_LOOP,
1643
+ MEGAMORPHIC,
1644
+ strict_mode);
1645
+ String* megamorphic_name = GetStubNameForCache(MEGAMORPHIC);
1646
+ Object* maybe_cached_stub = receiver->map()->FindInCodeCache(megamorphic_name,
1647
+ flags);
1648
+
1649
+ // Create a set of all receiver maps that have been seen at the IC call site
1650
+ // and those seen by the MEGAMORPHIC cached stub, if that's the stub that's
1651
+ // been selected.
1652
+ MapList receiver_maps;
1653
+ if (!maybe_cached_stub->IsUndefined()) {
1654
+ GetReceiverMapsForStub(Code::cast(maybe_cached_stub), &receiver_maps);
1655
+ }
1656
+ bool added_map = false;
1657
+ for (int i = 0; i < target_receiver_maps.length(); ++i) {
1658
+ if (AddOneReceiverMapIfMissing(&receiver_maps,
1659
+ target_receiver_maps.at(i))) {
1660
+ added_map = true;
1661
+ }
1662
+ }
1663
+ ASSERT(receiver_maps.length() > 0);
1664
+
1665
+ // If the maximum number of receiver maps has been exceeded, use the Generic
1666
+ // version of the IC.
1667
+ if (receiver_maps.length() > KeyedIC::kMaxKeyedPolymorphism) {
1668
+ return generic_stub;
1669
+ }
1670
+
1671
+ // If no maps have been seen at the call site that aren't in the cached
1672
+ // stub, then use it.
1673
+ if (!added_map) {
1674
+ ASSERT(!maybe_cached_stub->IsUndefined());
1675
+ ASSERT(maybe_cached_stub->IsCode());
1676
+ return Code::cast(maybe_cached_stub);
1677
+ }
1678
+
1679
+ // Lookup all of the receiver maps in the cache, they should all already
1680
+ // have MONOMORPHIC stubs.
1681
+ CodeList handler_ics(KeyedIC::kMaxKeyedPolymorphism);
1682
+ for (int current = 0; current < receiver_maps.length(); ++current) {
1683
+ Map* receiver_map(receiver_maps.at(current));
1684
+ MaybeObject* maybe_cached_stub = ComputeMonomorphicStubWithoutMapCheck(
1685
+ receiver_map,
1686
+ strict_mode,
1687
+ generic_stub);
1688
+ Code* cached_stub;
1689
+ if (!maybe_cached_stub->To(&cached_stub)) {
1690
+ return maybe_cached_stub;
1691
+ }
1692
+ handler_ics.Add(cached_stub);
1693
+ }
1694
+
1695
+ Code* stub;
1696
+ // Build the MEGAMORPHIC stub.
1697
+ maybe_stub = ConstructMegamorphicStub(&receiver_maps,
1698
+ &handler_ics,
1699
+ strict_mode);
1700
+ if (!maybe_stub->To(&stub)) return maybe_stub;
1701
+
1702
+ MaybeObject* maybe_update = receiver->UpdateMapCodeCache(
1703
+ megamorphic_name,
1704
+ stub);
1705
+ if (maybe_update->IsFailure()) return maybe_update;
1706
+ return stub;
1707
+ }
1708
+
1709
+
1710
+ MaybeObject* KeyedIC::ComputeMonomorphicStubWithoutMapCheck(
1711
+ Map* receiver_map,
1712
+ StrictModeFlag strict_mode,
1713
+ Code* generic_stub) {
1714
+ if ((receiver_map->instance_type() & kNotStringTag) == 0) {
1715
+ ASSERT(string_stub() != NULL);
1716
+ return string_stub();
1717
+ } else if (receiver_map->has_external_array_elements()) {
1718
+ // Determine the array type from the default MONOMORPHIC already generated
1719
+ // stub. There is no other way to determine the type of the external array
1720
+ // directly from the receiver type.
1721
+ Code::Kind kind = this->kind();
1722
+ Code::Flags flags = Code::ComputeMonomorphicFlags(kind,
1723
+ NORMAL,
1724
+ strict_mode);
1725
+ String* monomorphic_name = GetStubNameForCache(MONOMORPHIC);
1726
+ Object* maybe_default_stub = receiver_map->FindInCodeCache(monomorphic_name,
1727
+ flags);
1728
+ if (maybe_default_stub->IsUndefined()) {
1729
+ return generic_stub;
1730
+ }
1731
+ Code* default_stub = Code::cast(maybe_default_stub);
1732
+ return GetExternalArrayStubWithoutMapCheck(
1733
+ default_stub->external_array_type());
1734
+ } else if (receiver_map->has_fast_elements()) {
1735
+ bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE;
1736
+ return GetFastElementStubWithoutMapCheck(is_js_array);
1737
+ } else {
1738
+ return generic_stub;
1739
+ }
1740
+ }
1741
+
1742
+
1743
+ MaybeObject* KeyedIC::ComputeMonomorphicStub(JSObject* receiver,
1744
+ bool is_store,
1745
+ StrictModeFlag strict_mode,
1746
+ Code* generic_stub) {
1747
+ Code* result = NULL;
1748
+ if (receiver->HasExternalArrayElements()) {
1749
+ MaybeObject* maybe_stub =
1750
+ isolate()->stub_cache()->ComputeKeyedLoadOrStoreExternalArray(
1751
+ receiver, is_store, strict_mode);
1752
+ if (!maybe_stub->To(&result)) return maybe_stub;
1753
+ } else if (receiver->map()->has_fast_elements()) {
1754
+ MaybeObject* maybe_stub =
1755
+ isolate()->stub_cache()->ComputeKeyedLoadOrStoreFastElement(
1756
+ receiver, is_store, strict_mode);
1757
+ if (!maybe_stub->To(&result)) return maybe_stub;
1758
+ } else {
1759
+ result = generic_stub;
1760
+ }
1761
+ return result;
1762
+ }
1763
+
1764
+
1765
+ String* KeyedStoreIC::GetStubNameForCache(IC::State ic_state) {
1766
+ if (ic_state == MONOMORPHIC) {
1767
+ return isolate()->heap()->KeyedStoreSpecializedMonomorphic_symbol();
1768
+ } else {
1769
+ ASSERT(ic_state == MEGAMORPHIC);
1770
+ return isolate()->heap()->KeyedStoreSpecializedPolymorphic_symbol();
1771
+ }
1772
+ }
1773
+
1774
+
1775
+ MaybeObject* KeyedStoreIC::GetFastElementStubWithoutMapCheck(
1776
+ bool is_js_array) {
1777
+ return KeyedStoreFastElementStub(is_js_array).TryGetCode();
1778
+ }
1779
+
1780
+
1781
+ MaybeObject* KeyedStoreIC::GetExternalArrayStubWithoutMapCheck(
1782
+ ExternalArrayType array_type) {
1783
+ return KeyedStoreExternalArrayStub(array_type).TryGetCode();
1784
+ }
1785
+
1786
+
1787
+ MaybeObject* KeyedStoreIC::ConstructMegamorphicStub(
1788
+ MapList* receiver_maps,
1789
+ CodeList* targets,
1790
+ StrictModeFlag strict_mode) {
1791
+ Object* object;
1792
+ KeyedStoreStubCompiler compiler(strict_mode);
1793
+ MaybeObject* maybe_code = compiler.CompileStoreMegamorphic(receiver_maps,
1794
+ targets);
1795
+ if (!maybe_code->ToObject(&object)) return maybe_code;
1796
+ isolate()->counters()->keyed_store_polymorphic_stubs()->Increment();
1797
+ PROFILE(isolate(), CodeCreateEvent(
1798
+ Logger::KEYED_STORE_MEGAMORPHIC_IC_TAG,
1799
+ Code::cast(object), 0));
1800
+ return object;
1801
+ }
1802
+
1803
+
1804
+ MaybeObject* KeyedStoreIC::Store(State state,
1805
+ StrictModeFlag strict_mode,
1806
+ Handle<Object> object,
1807
+ Handle<Object> key,
1808
+ Handle<Object> value,
1809
+ bool force_generic) {
1810
+ if (key->IsSymbol()) {
1811
+ Handle<String> name = Handle<String>::cast(key);
1812
+
1813
+ // If the object is undefined or null it's illegal to try to set any
1814
+ // properties on it; throw a TypeError in that case.
1815
+ if (object->IsUndefined() || object->IsNull()) {
1816
+ return TypeError("non_object_property_store", object, name);
1817
+ }
1818
+
1819
+ // Ignore stores where the receiver is not a JSObject.
1820
+ if (!object->IsJSObject()) return *value;
1821
+ Handle<JSObject> receiver = Handle<JSObject>::cast(object);
1822
+
1823
+ // Check if the given name is an array index.
1824
+ uint32_t index;
1825
+ if (name->AsArrayIndex(&index)) {
1826
+ HandleScope scope(isolate());
1827
+ Handle<Object> result = SetElement(receiver, index, value, strict_mode);
1828
+ if (result.is_null()) return Failure::Exception();
1829
+ return *value;
1830
+ }
1831
+
1832
+ // Lookup the property locally in the receiver.
1833
+ LookupResult lookup;
1834
+ receiver->LocalLookup(*name, &lookup);
1835
+
1836
+ // Update inline cache and stub cache.
1837
+ if (FLAG_use_ic) {
1838
+ UpdateCaches(&lookup, state, strict_mode, receiver, name, value);
1839
+ }
1840
+
1841
+ // Set the property.
1842
+ return receiver->SetProperty(*name, *value, NONE, strict_mode);
1843
+ }
1844
+
1845
+ // Do not use ICs for objects that require access checks (including
1846
+ // the global object).
1847
+ bool use_ic = FLAG_use_ic && !object->IsAccessCheckNeeded();
1848
+ ASSERT(!(use_ic && object->IsJSGlobalProxy()));
1849
+
1850
+ if (use_ic) {
1851
+ Code* stub = (strict_mode == kStrictMode)
1852
+ ? generic_stub_strict()
1853
+ : generic_stub();
1854
+ if (!force_generic) {
1855
+ if (object->IsJSObject() && key->IsSmi()) {
1856
+ JSObject* receiver = JSObject::cast(*object);
1857
+ MaybeObject* maybe_stub = ComputeStub(receiver,
1858
+ true,
1859
+ strict_mode,
1860
+ stub);
1861
+ stub = maybe_stub->IsFailure() ?
1862
+ NULL : Code::cast(maybe_stub->ToObjectUnchecked());
1863
+ }
1864
+ }
1865
+ if (stub != NULL) set_target(stub);
1866
+ }
1867
+
1868
+ #ifdef DEBUG
1869
+ TraceIC("KeyedStoreIC", key, state, target());
1870
+ #endif
1871
+
1872
+ // Set the property.
1873
+ return Runtime::SetObjectProperty(
1874
+ isolate(), object , key, value, NONE, strict_mode);
1875
+ }
1876
+
1877
+
1878
+ void KeyedStoreIC::UpdateCaches(LookupResult* lookup,
1879
+ State state,
1880
+ StrictModeFlag strict_mode,
1881
+ Handle<JSObject> receiver,
1882
+ Handle<String> name,
1883
+ Handle<Object> value) {
1884
+ // Skip JSGlobalProxy.
1885
+ if (receiver->IsJSGlobalProxy()) return;
1886
+
1887
+ // Bail out if we didn't find a result.
1888
+ if (!lookup->IsPropertyOrTransition() || !lookup->IsCacheable()) return;
1889
+
1890
+ // If the property is read-only, we leave the IC in its current
1891
+ // state.
1892
+ if (lookup->IsReadOnly()) return;
1893
+
1894
+ // If the property has a non-field type allowing map transitions
1895
+ // where there is extra room in the object, we leave the IC in its
1896
+ // current state.
1897
+ PropertyType type = lookup->type();
1898
+
1899
+ // Compute the code stub for this store; used for rewriting to
1900
+ // monomorphic state and making sure that the code stub is in the
1901
+ // stub cache.
1902
+ MaybeObject* maybe_code = NULL;
1903
+ Object* code = NULL;
1904
+
1905
+ switch (type) {
1906
+ case FIELD: {
1907
+ maybe_code = isolate()->stub_cache()->ComputeKeyedStoreField(
1908
+ *name, *receiver, lookup->GetFieldIndex(), NULL, strict_mode);
1909
+ break;
1910
+ }
1911
+ case MAP_TRANSITION: {
1912
+ if (lookup->GetAttributes() == NONE) {
1913
+ HandleScope scope(isolate());
1914
+ ASSERT(type == MAP_TRANSITION);
1915
+ Handle<Map> transition(lookup->GetTransitionMap());
1916
+ int index = transition->PropertyIndexFor(*name);
1917
+ maybe_code = isolate()->stub_cache()->ComputeKeyedStoreField(
1918
+ *name, *receiver, index, *transition, strict_mode);
1919
+ break;
1920
+ }
1921
+ // fall through.
1922
+ }
1923
+ default: {
1924
+ // Always rewrite to the generic case so that we do not
1925
+ // repeatedly try to rewrite.
1926
+ maybe_code = (strict_mode == kStrictMode)
1927
+ ? generic_stub_strict()
1928
+ : generic_stub();
1929
+ break;
1930
+ }
1931
+ }
1932
+
1933
+ // If we're unable to compute the stub (not enough memory left), we
1934
+ // simply avoid updating the caches.
1935
+ if (maybe_code == NULL || !maybe_code->ToObject(&code)) return;
1936
+
1937
+ // Patch the call site depending on the state of the cache. Make
1938
+ // sure to always rewrite from monomorphic to megamorphic.
1939
+ ASSERT(state != MONOMORPHIC_PROTOTYPE_FAILURE);
1940
+ if (state == UNINITIALIZED || state == PREMONOMORPHIC) {
1941
+ set_target(Code::cast(code));
1942
+ } else if (state == MONOMORPHIC) {
1943
+ set_target((strict_mode == kStrictMode)
1944
+ ? megamorphic_stub_strict()
1945
+ : megamorphic_stub());
1946
+ }
1947
+
1948
+ #ifdef DEBUG
1949
+ TraceIC("KeyedStoreIC", name, state, target());
1950
+ #endif
1951
+ }
1952
+
1953
+
1954
+ // ----------------------------------------------------------------------------
1955
+ // Static IC stub generators.
1956
+ //
1957
+
1958
+ static JSFunction* CompileFunction(Isolate* isolate,
1959
+ JSFunction* function,
1960
+ InLoopFlag in_loop) {
1961
+ // Compile now with optimization.
1962
+ HandleScope scope(isolate);
1963
+ Handle<JSFunction> function_handle(function, isolate);
1964
+ if (in_loop == IN_LOOP) {
1965
+ CompileLazyInLoop(function_handle, CLEAR_EXCEPTION);
1966
+ } else {
1967
+ CompileLazy(function_handle, CLEAR_EXCEPTION);
1968
+ }
1969
+ return *function_handle;
1970
+ }
1971
+
1972
+
1973
+ // Used from ic-<arch>.cc.
1974
+ RUNTIME_FUNCTION(MaybeObject*, CallIC_Miss) {
1975
+ NoHandleAllocation na;
1976
+ ASSERT(args.length() == 2);
1977
+ CallIC ic(isolate);
1978
+ IC::State state = IC::StateFrom(ic.target(), args[0], args[1]);
1979
+ Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state();
1980
+ MaybeObject* maybe_result = ic.LoadFunction(state,
1981
+ extra_ic_state,
1982
+ args.at<Object>(0),
1983
+ args.at<String>(1));
1984
+ Object* result;
1985
+ if (!maybe_result->ToObject(&result)) return maybe_result;
1986
+
1987
+ // The first time the inline cache is updated may be the first time the
1988
+ // function it references gets called. If the function was lazily compiled
1989
+ // then the first call will trigger a compilation. We check for this case
1990
+ // and we do the compilation immediately, instead of waiting for the stub
1991
+ // currently attached to the JSFunction object to trigger compilation. We
1992
+ // do this in the case where we know that the inline cache is inside a loop,
1993
+ // because then we know that we want to optimize the function.
1994
+ if (!result->IsJSFunction() || JSFunction::cast(result)->is_compiled()) {
1995
+ return result;
1996
+ }
1997
+ return CompileFunction(isolate,
1998
+ JSFunction::cast(result),
1999
+ ic.target()->ic_in_loop());
2000
+ }
2001
+
2002
+
2003
+ // Used from ic-<arch>.cc.
2004
+ RUNTIME_FUNCTION(MaybeObject*, KeyedCallIC_Miss) {
2005
+ NoHandleAllocation na;
2006
+ ASSERT(args.length() == 2);
2007
+ KeyedCallIC ic(isolate);
2008
+ IC::State state = IC::StateFrom(ic.target(), args[0], args[1]);
2009
+ Object* result;
2010
+ { MaybeObject* maybe_result =
2011
+ ic.LoadFunction(state, args.at<Object>(0), args.at<Object>(1));
2012
+ if (!maybe_result->ToObject(&result)) return maybe_result;
2013
+ }
2014
+
2015
+ if (!result->IsJSFunction() || JSFunction::cast(result)->is_compiled()) {
2016
+ return result;
2017
+ }
2018
+ return CompileFunction(isolate,
2019
+ JSFunction::cast(result),
2020
+ ic.target()->ic_in_loop());
2021
+ }
2022
+
2023
+
2024
+ // Used from ic-<arch>.cc.
2025
+ RUNTIME_FUNCTION(MaybeObject*, LoadIC_Miss) {
2026
+ NoHandleAllocation na;
2027
+ ASSERT(args.length() == 2);
2028
+ LoadIC ic(isolate);
2029
+ IC::State state = IC::StateFrom(ic.target(), args[0], args[1]);
2030
+ return ic.Load(state, args.at<Object>(0), args.at<String>(1));
2031
+ }
2032
+
2033
+
2034
+ // Used from ic-<arch>.cc
2035
+ RUNTIME_FUNCTION(MaybeObject*, KeyedLoadIC_Miss) {
2036
+ NoHandleAllocation na;
2037
+ ASSERT(args.length() == 2);
2038
+ KeyedLoadIC ic(isolate);
2039
+ IC::State state = IC::StateFrom(ic.target(), args[0], args[1]);
2040
+ return ic.Load(state, args.at<Object>(0), args.at<Object>(1), false);
2041
+ }
2042
+
2043
+
2044
+ RUNTIME_FUNCTION(MaybeObject*, KeyedLoadIC_MissForceGeneric) {
2045
+ NoHandleAllocation na;
2046
+ ASSERT(args.length() == 2);
2047
+ KeyedLoadIC ic(isolate);
2048
+ IC::State state = IC::StateFrom(ic.target(), args[0], args[1]);
2049
+ return ic.Load(state, args.at<Object>(0), args.at<Object>(1), true);
2050
+ }
2051
+
2052
+
2053
+ // Used from ic-<arch>.cc.
2054
+ RUNTIME_FUNCTION(MaybeObject*, StoreIC_Miss) {
2055
+ NoHandleAllocation na;
2056
+ ASSERT(args.length() == 3);
2057
+ StoreIC ic(isolate);
2058
+ IC::State state = IC::StateFrom(ic.target(), args[0], args[1]);
2059
+ Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state();
2060
+ return ic.Store(state,
2061
+ static_cast<StrictModeFlag>(extra_ic_state & kStrictMode),
2062
+ args.at<Object>(0),
2063
+ args.at<String>(1),
2064
+ args.at<Object>(2));
2065
+ }
2066
+
2067
+
2068
+ RUNTIME_FUNCTION(MaybeObject*, StoreIC_ArrayLength) {
2069
+ NoHandleAllocation nha;
2070
+
2071
+ ASSERT(args.length() == 2);
2072
+ JSObject* receiver = JSObject::cast(args[0]);
2073
+ Object* len = args[1];
2074
+
2075
+ // The generated code should filter out non-Smis before we get here.
2076
+ ASSERT(len->IsSmi());
2077
+
2078
+ Object* result;
2079
+ { MaybeObject* maybe_result = receiver->SetElementsLength(len);
2080
+ if (!maybe_result->ToObject(&result)) return maybe_result;
2081
+ }
2082
+ return len;
2083
+ }
2084
+
2085
+
2086
+ // Extend storage is called in a store inline cache when
2087
+ // it is necessary to extend the properties array of a
2088
+ // JSObject.
2089
+ RUNTIME_FUNCTION(MaybeObject*, SharedStoreIC_ExtendStorage) {
2090
+ NoHandleAllocation na;
2091
+ ASSERT(args.length() == 3);
2092
+
2093
+ // Convert the parameters
2094
+ JSObject* object = JSObject::cast(args[0]);
2095
+ Map* transition = Map::cast(args[1]);
2096
+ Object* value = args[2];
2097
+
2098
+ // Check the object has run out out property space.
2099
+ ASSERT(object->HasFastProperties());
2100
+ ASSERT(object->map()->unused_property_fields() == 0);
2101
+
2102
+ // Expand the properties array.
2103
+ FixedArray* old_storage = object->properties();
2104
+ int new_unused = transition->unused_property_fields();
2105
+ int new_size = old_storage->length() + new_unused + 1;
2106
+ Object* result;
2107
+ { MaybeObject* maybe_result = old_storage->CopySize(new_size);
2108
+ if (!maybe_result->ToObject(&result)) return maybe_result;
2109
+ }
2110
+ FixedArray* new_storage = FixedArray::cast(result);
2111
+ new_storage->set(old_storage->length(), value);
2112
+
2113
+ // Set the new property value and do the map transition.
2114
+ object->set_properties(new_storage);
2115
+ object->set_map(transition);
2116
+
2117
+ // Return the stored value.
2118
+ return value;
2119
+ }
2120
+
2121
+
2122
+ // Used from ic-<arch>.cc.
2123
+ RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_Miss) {
2124
+ NoHandleAllocation na;
2125
+ ASSERT(args.length() == 3);
2126
+ KeyedStoreIC ic(isolate);
2127
+ IC::State state = IC::StateFrom(ic.target(), args[0], args[1]);
2128
+ Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state();
2129
+ return ic.Store(state,
2130
+ static_cast<StrictModeFlag>(extra_ic_state & kStrictMode),
2131
+ args.at<Object>(0),
2132
+ args.at<Object>(1),
2133
+ args.at<Object>(2),
2134
+ false);
2135
+ }
2136
+
2137
+
2138
+ RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_Slow) {
2139
+ NoHandleAllocation na;
2140
+ ASSERT(args.length() == 3);
2141
+ KeyedStoreIC ic(isolate);
2142
+ Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state();
2143
+ Handle<Object> object = args.at<Object>(0);
2144
+ Handle<Object> key = args.at<Object>(1);
2145
+ Handle<Object> value = args.at<Object>(2);
2146
+ StrictModeFlag strict_mode =
2147
+ static_cast<StrictModeFlag>(extra_ic_state & kStrictMode);
2148
+ return Runtime::SetObjectProperty(isolate,
2149
+ object,
2150
+ key,
2151
+ value,
2152
+ NONE,
2153
+ strict_mode);
2154
+ }
2155
+
2156
+
2157
+ RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_MissForceGeneric) {
2158
+ NoHandleAllocation na;
2159
+ ASSERT(args.length() == 3);
2160
+ KeyedStoreIC ic(isolate);
2161
+ IC::State state = IC::StateFrom(ic.target(), args[0], args[1]);
2162
+ Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state();
2163
+ return ic.Store(state,
2164
+ static_cast<StrictModeFlag>(extra_ic_state & kStrictMode),
2165
+ args.at<Object>(0),
2166
+ args.at<Object>(1),
2167
+ args.at<Object>(2),
2168
+ true);
2169
+ }
2170
+
2171
+
2172
+ void UnaryOpIC::patch(Code* code) {
2173
+ set_target(code);
2174
+ }
2175
+
2176
+
2177
+ const char* UnaryOpIC::GetName(TypeInfo type_info) {
2178
+ switch (type_info) {
2179
+ case UNINITIALIZED: return "Uninitialized";
2180
+ case SMI: return "Smi";
2181
+ case HEAP_NUMBER: return "HeapNumbers";
2182
+ case GENERIC: return "Generic";
2183
+ default: return "Invalid";
2184
+ }
2185
+ }
2186
+
2187
+
2188
+ UnaryOpIC::State UnaryOpIC::ToState(TypeInfo type_info) {
2189
+ switch (type_info) {
2190
+ case UNINITIALIZED:
2191
+ return ::v8::internal::UNINITIALIZED;
2192
+ case SMI:
2193
+ case HEAP_NUMBER:
2194
+ return MONOMORPHIC;
2195
+ case GENERIC:
2196
+ return MEGAMORPHIC;
2197
+ }
2198
+ UNREACHABLE();
2199
+ return ::v8::internal::UNINITIALIZED;
2200
+ }
2201
+
2202
+ UnaryOpIC::TypeInfo UnaryOpIC::GetTypeInfo(Handle<Object> operand) {
2203
+ ::v8::internal::TypeInfo operand_type =
2204
+ ::v8::internal::TypeInfo::TypeFromValue(operand);
2205
+ if (operand_type.IsSmi()) {
2206
+ return SMI;
2207
+ } else if (operand_type.IsNumber()) {
2208
+ return HEAP_NUMBER;
2209
+ } else {
2210
+ return GENERIC;
2211
+ }
2212
+ }
2213
+
2214
+
2215
+ UnaryOpIC::TypeInfo UnaryOpIC::ComputeNewType(
2216
+ UnaryOpIC::TypeInfo current_type,
2217
+ UnaryOpIC::TypeInfo previous_type) {
2218
+ switch (previous_type) {
2219
+ case UnaryOpIC::UNINITIALIZED:
2220
+ return current_type;
2221
+ case UnaryOpIC::SMI:
2222
+ return (current_type == UnaryOpIC::GENERIC)
2223
+ ? UnaryOpIC::GENERIC
2224
+ : UnaryOpIC::HEAP_NUMBER;
2225
+ case UnaryOpIC::HEAP_NUMBER:
2226
+ return UnaryOpIC::GENERIC;
2227
+ case UnaryOpIC::GENERIC:
2228
+ // We should never do patching if we are in GENERIC state.
2229
+ UNREACHABLE();
2230
+ return UnaryOpIC::GENERIC;
2231
+ }
2232
+ UNREACHABLE();
2233
+ return UnaryOpIC::GENERIC;
2234
+ }
2235
+
2236
+
2237
+ void BinaryOpIC::patch(Code* code) {
2238
+ set_target(code);
2239
+ }
2240
+
2241
+
2242
+ const char* BinaryOpIC::GetName(TypeInfo type_info) {
2243
+ switch (type_info) {
2244
+ case UNINITIALIZED: return "Uninitialized";
2245
+ case SMI: return "SMI";
2246
+ case INT32: return "Int32s";
2247
+ case HEAP_NUMBER: return "HeapNumbers";
2248
+ case ODDBALL: return "Oddball";
2249
+ case BOTH_STRING: return "BothStrings";
2250
+ case STRING: return "Strings";
2251
+ case GENERIC: return "Generic";
2252
+ default: return "Invalid";
2253
+ }
2254
+ }
2255
+
2256
+
2257
+ BinaryOpIC::State BinaryOpIC::ToState(TypeInfo type_info) {
2258
+ switch (type_info) {
2259
+ case UNINITIALIZED:
2260
+ return ::v8::internal::UNINITIALIZED;
2261
+ case SMI:
2262
+ case INT32:
2263
+ case HEAP_NUMBER:
2264
+ case ODDBALL:
2265
+ case BOTH_STRING:
2266
+ case STRING:
2267
+ return MONOMORPHIC;
2268
+ case GENERIC:
2269
+ return MEGAMORPHIC;
2270
+ }
2271
+ UNREACHABLE();
2272
+ return ::v8::internal::UNINITIALIZED;
2273
+ }
2274
+
2275
+
2276
+ BinaryOpIC::TypeInfo BinaryOpIC::JoinTypes(BinaryOpIC::TypeInfo x,
2277
+ BinaryOpIC::TypeInfo y) {
2278
+ if (x == UNINITIALIZED) return y;
2279
+ if (y == UNINITIALIZED) return x;
2280
+ if (x == y) return x;
2281
+ if (x == BOTH_STRING && y == STRING) return STRING;
2282
+ if (x == STRING && y == BOTH_STRING) return STRING;
2283
+ if (x == STRING || x == BOTH_STRING || y == STRING || y == BOTH_STRING) {
2284
+ return GENERIC;
2285
+ }
2286
+ if (x > y) return x;
2287
+ return y;
2288
+ }
2289
+
2290
+
2291
+ BinaryOpIC::TypeInfo BinaryOpIC::GetTypeInfo(Handle<Object> left,
2292
+ Handle<Object> right) {
2293
+ ::v8::internal::TypeInfo left_type =
2294
+ ::v8::internal::TypeInfo::TypeFromValue(left);
2295
+ ::v8::internal::TypeInfo right_type =
2296
+ ::v8::internal::TypeInfo::TypeFromValue(right);
2297
+
2298
+ if (left_type.IsSmi() && right_type.IsSmi()) {
2299
+ return SMI;
2300
+ }
2301
+
2302
+ if (left_type.IsInteger32() && right_type.IsInteger32()) {
2303
+ // Platforms with 32-bit Smis have no distinct INT32 type.
2304
+ if (kSmiValueSize == 32) return SMI;
2305
+ return INT32;
2306
+ }
2307
+
2308
+ if (left_type.IsNumber() && right_type.IsNumber()) {
2309
+ return HEAP_NUMBER;
2310
+ }
2311
+
2312
+ // Patching for fast string ADD makes sense even if only one of the
2313
+ // arguments is a string.
2314
+ if (left_type.IsString()) {
2315
+ return right_type.IsString() ? BOTH_STRING : STRING;
2316
+ } else if (right_type.IsString()) {
2317
+ return STRING;
2318
+ }
2319
+
2320
+ // Check for oddball objects.
2321
+ if (left->IsUndefined() && right->IsNumber()) return ODDBALL;
2322
+ if (left->IsNumber() && right->IsUndefined()) return ODDBALL;
2323
+
2324
+ return GENERIC;
2325
+ }
2326
+
2327
+
2328
+ // defined in code-stubs-<arch>.cc
2329
+ // Only needed to remove dependency of ic.cc on code-stubs-<arch>.h.
2330
+ Handle<Code> GetUnaryOpStub(int key, UnaryOpIC::TypeInfo type_info);
2331
+
2332
+
2333
+ RUNTIME_FUNCTION(MaybeObject*, UnaryOp_Patch) {
2334
+ ASSERT(args.length() == 4);
2335
+
2336
+ HandleScope scope(isolate);
2337
+ Handle<Object> operand = args.at<Object>(0);
2338
+ int key = Smi::cast(args[1])->value();
2339
+ Token::Value op = static_cast<Token::Value>(Smi::cast(args[2])->value());
2340
+ UnaryOpIC::TypeInfo previous_type =
2341
+ static_cast<UnaryOpIC::TypeInfo>(Smi::cast(args[3])->value());
2342
+
2343
+ UnaryOpIC::TypeInfo type = UnaryOpIC::GetTypeInfo(operand);
2344
+ type = UnaryOpIC::ComputeNewType(type, previous_type);
2345
+
2346
+ Handle<Code> code = GetUnaryOpStub(key, type);
2347
+ if (!code.is_null()) {
2348
+ if (FLAG_trace_ic) {
2349
+ PrintF("[UnaryOpIC (%s->%s)#%s]\n",
2350
+ UnaryOpIC::GetName(previous_type),
2351
+ UnaryOpIC::GetName(type),
2352
+ Token::Name(op));
2353
+ }
2354
+ UnaryOpIC ic(isolate);
2355
+ ic.patch(*code);
2356
+ }
2357
+
2358
+ Handle<JSBuiltinsObject> builtins = Handle<JSBuiltinsObject>(
2359
+ isolate->thread_local_top()->context_->builtins(), isolate);
2360
+ Object* builtin = NULL; // Initialization calms down the compiler.
2361
+ switch (op) {
2362
+ case Token::SUB:
2363
+ builtin = builtins->javascript_builtin(Builtins::UNARY_MINUS);
2364
+ break;
2365
+ case Token::BIT_NOT:
2366
+ builtin = builtins->javascript_builtin(Builtins::BIT_NOT);
2367
+ break;
2368
+ default:
2369
+ UNREACHABLE();
2370
+ }
2371
+
2372
+ Handle<JSFunction> builtin_function(JSFunction::cast(builtin), isolate);
2373
+
2374
+ bool caught_exception;
2375
+ Handle<Object> result = Execution::Call(builtin_function, operand, 0, NULL,
2376
+ &caught_exception);
2377
+ if (caught_exception) {
2378
+ return Failure::Exception();
2379
+ }
2380
+ return *result;
2381
+ }
2382
+
2383
+ // defined in code-stubs-<arch>.cc
2384
+ // Only needed to remove dependency of ic.cc on code-stubs-<arch>.h.
2385
+ Handle<Code> GetBinaryOpStub(int key,
2386
+ BinaryOpIC::TypeInfo type_info,
2387
+ BinaryOpIC::TypeInfo result_type);
2388
+
2389
+
2390
+ RUNTIME_FUNCTION(MaybeObject*, BinaryOp_Patch) {
2391
+ ASSERT(args.length() == 5);
2392
+
2393
+ HandleScope scope(isolate);
2394
+ Handle<Object> left = args.at<Object>(0);
2395
+ Handle<Object> right = args.at<Object>(1);
2396
+ int key = Smi::cast(args[2])->value();
2397
+ Token::Value op = static_cast<Token::Value>(Smi::cast(args[3])->value());
2398
+ BinaryOpIC::TypeInfo previous_type =
2399
+ static_cast<BinaryOpIC::TypeInfo>(Smi::cast(args[4])->value());
2400
+
2401
+ BinaryOpIC::TypeInfo type = BinaryOpIC::GetTypeInfo(left, right);
2402
+ type = BinaryOpIC::JoinTypes(type, previous_type);
2403
+ BinaryOpIC::TypeInfo result_type = BinaryOpIC::UNINITIALIZED;
2404
+ if ((type == BinaryOpIC::STRING || type == BinaryOpIC::BOTH_STRING) &&
2405
+ op != Token::ADD) {
2406
+ type = BinaryOpIC::GENERIC;
2407
+ }
2408
+ if (type == BinaryOpIC::SMI && previous_type == BinaryOpIC::SMI) {
2409
+ if (op == Token::DIV ||
2410
+ op == Token::MUL ||
2411
+ op == Token::SHR ||
2412
+ kSmiValueSize == 32) {
2413
+ // Arithmetic on two Smi inputs has yielded a heap number.
2414
+ // That is the only way to get here from the Smi stub.
2415
+ // With 32-bit Smis, all overflows give heap numbers, but with
2416
+ // 31-bit Smis, most operations overflow to int32 results.
2417
+ result_type = BinaryOpIC::HEAP_NUMBER;
2418
+ } else {
2419
+ // Other operations on SMIs that overflow yield int32s.
2420
+ result_type = BinaryOpIC::INT32;
2421
+ }
2422
+ }
2423
+ if (type == BinaryOpIC::INT32 && previous_type == BinaryOpIC::INT32) {
2424
+ // We must be here because an operation on two INT32 types overflowed.
2425
+ result_type = BinaryOpIC::HEAP_NUMBER;
2426
+ }
2427
+
2428
+ Handle<Code> code = GetBinaryOpStub(key, type, result_type);
2429
+ if (!code.is_null()) {
2430
+ if (FLAG_trace_ic) {
2431
+ PrintF("[BinaryOpIC (%s->(%s->%s))#%s]\n",
2432
+ BinaryOpIC::GetName(previous_type),
2433
+ BinaryOpIC::GetName(type),
2434
+ BinaryOpIC::GetName(result_type),
2435
+ Token::Name(op));
2436
+ }
2437
+ BinaryOpIC ic(isolate);
2438
+ ic.patch(*code);
2439
+
2440
+ // Activate inlined smi code.
2441
+ if (previous_type == BinaryOpIC::UNINITIALIZED) {
2442
+ PatchInlinedSmiCode(ic.address());
2443
+ }
2444
+ }
2445
+
2446
+ Handle<JSBuiltinsObject> builtins = Handle<JSBuiltinsObject>(
2447
+ isolate->thread_local_top()->context_->builtins(), isolate);
2448
+ Object* builtin = NULL; // Initialization calms down the compiler.
2449
+ switch (op) {
2450
+ case Token::ADD:
2451
+ builtin = builtins->javascript_builtin(Builtins::ADD);
2452
+ break;
2453
+ case Token::SUB:
2454
+ builtin = builtins->javascript_builtin(Builtins::SUB);
2455
+ break;
2456
+ case Token::MUL:
2457
+ builtin = builtins->javascript_builtin(Builtins::MUL);
2458
+ break;
2459
+ case Token::DIV:
2460
+ builtin = builtins->javascript_builtin(Builtins::DIV);
2461
+ break;
2462
+ case Token::MOD:
2463
+ builtin = builtins->javascript_builtin(Builtins::MOD);
2464
+ break;
2465
+ case Token::BIT_AND:
2466
+ builtin = builtins->javascript_builtin(Builtins::BIT_AND);
2467
+ break;
2468
+ case Token::BIT_OR:
2469
+ builtin = builtins->javascript_builtin(Builtins::BIT_OR);
2470
+ break;
2471
+ case Token::BIT_XOR:
2472
+ builtin = builtins->javascript_builtin(Builtins::BIT_XOR);
2473
+ break;
2474
+ case Token::SHR:
2475
+ builtin = builtins->javascript_builtin(Builtins::SHR);
2476
+ break;
2477
+ case Token::SAR:
2478
+ builtin = builtins->javascript_builtin(Builtins::SAR);
2479
+ break;
2480
+ case Token::SHL:
2481
+ builtin = builtins->javascript_builtin(Builtins::SHL);
2482
+ break;
2483
+ default:
2484
+ UNREACHABLE();
2485
+ }
2486
+
2487
+ Handle<JSFunction> builtin_function(JSFunction::cast(builtin), isolate);
2488
+
2489
+ bool caught_exception;
2490
+ Object** builtin_args[] = { right.location() };
2491
+ Handle<Object> result = Execution::Call(builtin_function,
2492
+ left,
2493
+ ARRAY_SIZE(builtin_args),
2494
+ builtin_args,
2495
+ &caught_exception);
2496
+ if (caught_exception) {
2497
+ return Failure::Exception();
2498
+ }
2499
+ return *result;
2500
+ }
2501
+
2502
+
2503
+ Handle<Code> CompareIC::GetUninitialized(Token::Value op) {
2504
+ ICCompareStub stub(op, UNINITIALIZED);
2505
+ return stub.GetCode();
2506
+ }
2507
+
2508
+
2509
+ CompareIC::State CompareIC::ComputeState(Code* target) {
2510
+ int key = target->major_key();
2511
+ if (key == CodeStub::Compare) return GENERIC;
2512
+ ASSERT(key == CodeStub::CompareIC);
2513
+ return static_cast<State>(target->compare_state());
2514
+ }
2515
+
2516
+
2517
+ const char* CompareIC::GetStateName(State state) {
2518
+ switch (state) {
2519
+ case UNINITIALIZED: return "UNINITIALIZED";
2520
+ case SMIS: return "SMIS";
2521
+ case HEAP_NUMBERS: return "HEAP_NUMBERS";
2522
+ case OBJECTS: return "OBJECTS";
2523
+ case SYMBOLS: return "SYMBOLS";
2524
+ case STRINGS: return "STRINGS";
2525
+ case GENERIC: return "GENERIC";
2526
+ default:
2527
+ UNREACHABLE();
2528
+ return NULL;
2529
+ }
2530
+ }
2531
+
2532
+
2533
+ CompareIC::State CompareIC::TargetState(State state,
2534
+ bool has_inlined_smi_code,
2535
+ Handle<Object> x,
2536
+ Handle<Object> y) {
2537
+ if (!has_inlined_smi_code && state != UNINITIALIZED && state != SYMBOLS) {
2538
+ return GENERIC;
2539
+ }
2540
+ if (state == UNINITIALIZED && x->IsSmi() && y->IsSmi()) return SMIS;
2541
+ if ((state == UNINITIALIZED || (state == SMIS && has_inlined_smi_code)) &&
2542
+ x->IsNumber() && y->IsNumber()) return HEAP_NUMBERS;
2543
+ if (op_ != Token::EQ && op_ != Token::EQ_STRICT) return GENERIC;
2544
+ if (state == UNINITIALIZED &&
2545
+ x->IsSymbol() && y->IsSymbol()) return SYMBOLS;
2546
+ if ((state == UNINITIALIZED || state == SYMBOLS) &&
2547
+ x->IsString() && y->IsString()) return STRINGS;
2548
+ if (state == UNINITIALIZED &&
2549
+ x->IsJSObject() && y->IsJSObject()) return OBJECTS;
2550
+ return GENERIC;
2551
+ }
2552
+
2553
+
2554
+ // Used from ic_<arch>.cc.
2555
+ RUNTIME_FUNCTION(Code*, CompareIC_Miss) {
2556
+ NoHandleAllocation na;
2557
+ ASSERT(args.length() == 3);
2558
+ CompareIC ic(isolate, static_cast<Token::Value>(Smi::cast(args[2])->value()));
2559
+ ic.UpdateCaches(args.at<Object>(0), args.at<Object>(1));
2560
+ return ic.target();
2561
+ }
2562
+
2563
+
2564
+ static const Address IC_utilities[] = {
2565
+ #define ADDR(name) FUNCTION_ADDR(name),
2566
+ IC_UTIL_LIST(ADDR)
2567
+ NULL
2568
+ #undef ADDR
2569
+ };
2570
+
2571
+
2572
+ Address IC::AddressFromUtilityId(IC::UtilityId id) {
2573
+ return IC_utilities[id];
2574
+ }
2575
+
2576
+
2577
+ } } // namespace v8::internal