therubyracer 0.9.0beta4 → 0.9.0beta5

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of therubyracer might be problematic. Click here for more details.

Files changed (771) hide show
  1. data/.gitignore +1 -0
  2. data/Rakefile +0 -11
  3. data/ext/v8/extconf.rb +9 -9
  4. data/ext/v8/v8_external.cpp +40 -10
  5. data/lib/v8/cli.rb +2 -1
  6. data/lib/v8/version.rb +1 -1
  7. data/spec/redjs/.gitignore +1 -0
  8. data/therubyracer.gemspec +2 -3
  9. metadata +33 -779
  10. data/ext/v8/upstream/Makefile +0 -38
  11. data/ext/v8/upstream/detect_cpu.rb +0 -27
  12. data/ext/v8/upstream/fpic-on-linux-amd64.patch +0 -13
  13. data/ext/v8/upstream/scons/CHANGES.txt +0 -5183
  14. data/ext/v8/upstream/scons/LICENSE.txt +0 -20
  15. data/ext/v8/upstream/scons/MANIFEST +0 -202
  16. data/ext/v8/upstream/scons/PKG-INFO +0 -13
  17. data/ext/v8/upstream/scons/README.txt +0 -273
  18. data/ext/v8/upstream/scons/RELEASE.txt +0 -1040
  19. data/ext/v8/upstream/scons/engine/SCons/Action.py +0 -1256
  20. data/ext/v8/upstream/scons/engine/SCons/Builder.py +0 -868
  21. data/ext/v8/upstream/scons/engine/SCons/CacheDir.py +0 -217
  22. data/ext/v8/upstream/scons/engine/SCons/Conftest.py +0 -794
  23. data/ext/v8/upstream/scons/engine/SCons/Debug.py +0 -237
  24. data/ext/v8/upstream/scons/engine/SCons/Defaults.py +0 -485
  25. data/ext/v8/upstream/scons/engine/SCons/Environment.py +0 -2327
  26. data/ext/v8/upstream/scons/engine/SCons/Errors.py +0 -207
  27. data/ext/v8/upstream/scons/engine/SCons/Executor.py +0 -636
  28. data/ext/v8/upstream/scons/engine/SCons/Job.py +0 -435
  29. data/ext/v8/upstream/scons/engine/SCons/Memoize.py +0 -292
  30. data/ext/v8/upstream/scons/engine/SCons/Node/Alias.py +0 -153
  31. data/ext/v8/upstream/scons/engine/SCons/Node/FS.py +0 -3220
  32. data/ext/v8/upstream/scons/engine/SCons/Node/Python.py +0 -128
  33. data/ext/v8/upstream/scons/engine/SCons/Node/__init__.py +0 -1341
  34. data/ext/v8/upstream/scons/engine/SCons/Options/BoolOption.py +0 -50
  35. data/ext/v8/upstream/scons/engine/SCons/Options/EnumOption.py +0 -50
  36. data/ext/v8/upstream/scons/engine/SCons/Options/ListOption.py +0 -50
  37. data/ext/v8/upstream/scons/engine/SCons/Options/PackageOption.py +0 -50
  38. data/ext/v8/upstream/scons/engine/SCons/Options/PathOption.py +0 -76
  39. data/ext/v8/upstream/scons/engine/SCons/Options/__init__.py +0 -74
  40. data/ext/v8/upstream/scons/engine/SCons/PathList.py +0 -232
  41. data/ext/v8/upstream/scons/engine/SCons/Platform/__init__.py +0 -236
  42. data/ext/v8/upstream/scons/engine/SCons/Platform/aix.py +0 -70
  43. data/ext/v8/upstream/scons/engine/SCons/Platform/cygwin.py +0 -55
  44. data/ext/v8/upstream/scons/engine/SCons/Platform/darwin.py +0 -46
  45. data/ext/v8/upstream/scons/engine/SCons/Platform/hpux.py +0 -46
  46. data/ext/v8/upstream/scons/engine/SCons/Platform/irix.py +0 -44
  47. data/ext/v8/upstream/scons/engine/SCons/Platform/os2.py +0 -58
  48. data/ext/v8/upstream/scons/engine/SCons/Platform/posix.py +0 -264
  49. data/ext/v8/upstream/scons/engine/SCons/Platform/sunos.py +0 -50
  50. data/ext/v8/upstream/scons/engine/SCons/Platform/win32.py +0 -386
  51. data/ext/v8/upstream/scons/engine/SCons/SConf.py +0 -1038
  52. data/ext/v8/upstream/scons/engine/SCons/SConsign.py +0 -381
  53. data/ext/v8/upstream/scons/engine/SCons/Scanner/C.py +0 -132
  54. data/ext/v8/upstream/scons/engine/SCons/Scanner/D.py +0 -74
  55. data/ext/v8/upstream/scons/engine/SCons/Scanner/Dir.py +0 -111
  56. data/ext/v8/upstream/scons/engine/SCons/Scanner/Fortran.py +0 -320
  57. data/ext/v8/upstream/scons/engine/SCons/Scanner/IDL.py +0 -48
  58. data/ext/v8/upstream/scons/engine/SCons/Scanner/LaTeX.py +0 -378
  59. data/ext/v8/upstream/scons/engine/SCons/Scanner/Prog.py +0 -103
  60. data/ext/v8/upstream/scons/engine/SCons/Scanner/RC.py +0 -55
  61. data/ext/v8/upstream/scons/engine/SCons/Scanner/__init__.py +0 -415
  62. data/ext/v8/upstream/scons/engine/SCons/Script/Interactive.py +0 -386
  63. data/ext/v8/upstream/scons/engine/SCons/Script/Main.py +0 -1360
  64. data/ext/v8/upstream/scons/engine/SCons/Script/SConsOptions.py +0 -944
  65. data/ext/v8/upstream/scons/engine/SCons/Script/SConscript.py +0 -642
  66. data/ext/v8/upstream/scons/engine/SCons/Script/__init__.py +0 -414
  67. data/ext/v8/upstream/scons/engine/SCons/Sig.py +0 -63
  68. data/ext/v8/upstream/scons/engine/SCons/Subst.py +0 -911
  69. data/ext/v8/upstream/scons/engine/SCons/Taskmaster.py +0 -1030
  70. data/ext/v8/upstream/scons/engine/SCons/Tool/386asm.py +0 -61
  71. data/ext/v8/upstream/scons/engine/SCons/Tool/BitKeeper.py +0 -65
  72. data/ext/v8/upstream/scons/engine/SCons/Tool/CVS.py +0 -73
  73. data/ext/v8/upstream/scons/engine/SCons/Tool/FortranCommon.py +0 -247
  74. data/ext/v8/upstream/scons/engine/SCons/Tool/JavaCommon.py +0 -324
  75. data/ext/v8/upstream/scons/engine/SCons/Tool/MSCommon/__init__.py +0 -56
  76. data/ext/v8/upstream/scons/engine/SCons/Tool/MSCommon/arch.py +0 -61
  77. data/ext/v8/upstream/scons/engine/SCons/Tool/MSCommon/common.py +0 -210
  78. data/ext/v8/upstream/scons/engine/SCons/Tool/MSCommon/netframework.py +0 -84
  79. data/ext/v8/upstream/scons/engine/SCons/Tool/MSCommon/sdk.py +0 -321
  80. data/ext/v8/upstream/scons/engine/SCons/Tool/MSCommon/vc.py +0 -367
  81. data/ext/v8/upstream/scons/engine/SCons/Tool/MSCommon/vs.py +0 -497
  82. data/ext/v8/upstream/scons/engine/SCons/Tool/Perforce.py +0 -104
  83. data/ext/v8/upstream/scons/engine/SCons/Tool/PharLapCommon.py +0 -138
  84. data/ext/v8/upstream/scons/engine/SCons/Tool/RCS.py +0 -64
  85. data/ext/v8/upstream/scons/engine/SCons/Tool/SCCS.py +0 -64
  86. data/ext/v8/upstream/scons/engine/SCons/Tool/Subversion.py +0 -71
  87. data/ext/v8/upstream/scons/engine/SCons/Tool/__init__.py +0 -675
  88. data/ext/v8/upstream/scons/engine/SCons/Tool/aixc++.py +0 -82
  89. data/ext/v8/upstream/scons/engine/SCons/Tool/aixcc.py +0 -74
  90. data/ext/v8/upstream/scons/engine/SCons/Tool/aixf77.py +0 -80
  91. data/ext/v8/upstream/scons/engine/SCons/Tool/aixlink.py +0 -76
  92. data/ext/v8/upstream/scons/engine/SCons/Tool/applelink.py +0 -71
  93. data/ext/v8/upstream/scons/engine/SCons/Tool/ar.py +0 -63
  94. data/ext/v8/upstream/scons/engine/SCons/Tool/as.py +0 -78
  95. data/ext/v8/upstream/scons/engine/SCons/Tool/bcc32.py +0 -82
  96. data/ext/v8/upstream/scons/engine/SCons/Tool/c++.py +0 -99
  97. data/ext/v8/upstream/scons/engine/SCons/Tool/cc.py +0 -114
  98. data/ext/v8/upstream/scons/engine/SCons/Tool/cvf.py +0 -58
  99. data/ext/v8/upstream/scons/engine/SCons/Tool/default.py +0 -50
  100. data/ext/v8/upstream/scons/engine/SCons/Tool/dmd.py +0 -224
  101. data/ext/v8/upstream/scons/engine/SCons/Tool/dvi.py +0 -64
  102. data/ext/v8/upstream/scons/engine/SCons/Tool/dvipdf.py +0 -125
  103. data/ext/v8/upstream/scons/engine/SCons/Tool/dvips.py +0 -94
  104. data/ext/v8/upstream/scons/engine/SCons/Tool/f77.py +0 -62
  105. data/ext/v8/upstream/scons/engine/SCons/Tool/f90.py +0 -62
  106. data/ext/v8/upstream/scons/engine/SCons/Tool/f95.py +0 -63
  107. data/ext/v8/upstream/scons/engine/SCons/Tool/filesystem.py +0 -98
  108. data/ext/v8/upstream/scons/engine/SCons/Tool/fortran.py +0 -63
  109. data/ext/v8/upstream/scons/engine/SCons/Tool/g++.py +0 -90
  110. data/ext/v8/upstream/scons/engine/SCons/Tool/g77.py +0 -73
  111. data/ext/v8/upstream/scons/engine/SCons/Tool/gas.py +0 -53
  112. data/ext/v8/upstream/scons/engine/SCons/Tool/gcc.py +0 -80
  113. data/ext/v8/upstream/scons/engine/SCons/Tool/gfortran.py +0 -64
  114. data/ext/v8/upstream/scons/engine/SCons/Tool/gnulink.py +0 -63
  115. data/ext/v8/upstream/scons/engine/SCons/Tool/gs.py +0 -81
  116. data/ext/v8/upstream/scons/engine/SCons/Tool/hpc++.py +0 -85
  117. data/ext/v8/upstream/scons/engine/SCons/Tool/hpcc.py +0 -53
  118. data/ext/v8/upstream/scons/engine/SCons/Tool/hplink.py +0 -77
  119. data/ext/v8/upstream/scons/engine/SCons/Tool/icc.py +0 -59
  120. data/ext/v8/upstream/scons/engine/SCons/Tool/icl.py +0 -52
  121. data/ext/v8/upstream/scons/engine/SCons/Tool/ifl.py +0 -72
  122. data/ext/v8/upstream/scons/engine/SCons/Tool/ifort.py +0 -90
  123. data/ext/v8/upstream/scons/engine/SCons/Tool/ilink.py +0 -59
  124. data/ext/v8/upstream/scons/engine/SCons/Tool/ilink32.py +0 -60
  125. data/ext/v8/upstream/scons/engine/SCons/Tool/install.py +0 -229
  126. data/ext/v8/upstream/scons/engine/SCons/Tool/intelc.py +0 -490
  127. data/ext/v8/upstream/scons/engine/SCons/Tool/ipkg.py +0 -71
  128. data/ext/v8/upstream/scons/engine/SCons/Tool/jar.py +0 -110
  129. data/ext/v8/upstream/scons/engine/SCons/Tool/javac.py +0 -234
  130. data/ext/v8/upstream/scons/engine/SCons/Tool/javah.py +0 -138
  131. data/ext/v8/upstream/scons/engine/SCons/Tool/latex.py +0 -79
  132. data/ext/v8/upstream/scons/engine/SCons/Tool/lex.py +0 -99
  133. data/ext/v8/upstream/scons/engine/SCons/Tool/link.py +0 -121
  134. data/ext/v8/upstream/scons/engine/SCons/Tool/linkloc.py +0 -112
  135. data/ext/v8/upstream/scons/engine/SCons/Tool/m4.py +0 -63
  136. data/ext/v8/upstream/scons/engine/SCons/Tool/masm.py +0 -77
  137. data/ext/v8/upstream/scons/engine/SCons/Tool/midl.py +0 -90
  138. data/ext/v8/upstream/scons/engine/SCons/Tool/mingw.py +0 -159
  139. data/ext/v8/upstream/scons/engine/SCons/Tool/mslib.py +0 -64
  140. data/ext/v8/upstream/scons/engine/SCons/Tool/mslink.py +0 -266
  141. data/ext/v8/upstream/scons/engine/SCons/Tool/mssdk.py +0 -50
  142. data/ext/v8/upstream/scons/engine/SCons/Tool/msvc.py +0 -269
  143. data/ext/v8/upstream/scons/engine/SCons/Tool/msvs.py +0 -1439
  144. data/ext/v8/upstream/scons/engine/SCons/Tool/mwcc.py +0 -208
  145. data/ext/v8/upstream/scons/engine/SCons/Tool/mwld.py +0 -107
  146. data/ext/v8/upstream/scons/engine/SCons/Tool/nasm.py +0 -72
  147. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/__init__.py +0 -314
  148. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/ipk.py +0 -185
  149. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/msi.py +0 -526
  150. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/rpm.py +0 -367
  151. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/src_tarbz2.py +0 -43
  152. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/src_targz.py +0 -43
  153. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/src_zip.py +0 -43
  154. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/tarbz2.py +0 -44
  155. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/targz.py +0 -44
  156. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/zip.py +0 -44
  157. data/ext/v8/upstream/scons/engine/SCons/Tool/pdf.py +0 -78
  158. data/ext/v8/upstream/scons/engine/SCons/Tool/pdflatex.py +0 -83
  159. data/ext/v8/upstream/scons/engine/SCons/Tool/pdftex.py +0 -108
  160. data/ext/v8/upstream/scons/engine/SCons/Tool/qt.py +0 -336
  161. data/ext/v8/upstream/scons/engine/SCons/Tool/rmic.py +0 -121
  162. data/ext/v8/upstream/scons/engine/SCons/Tool/rpcgen.py +0 -70
  163. data/ext/v8/upstream/scons/engine/SCons/Tool/rpm.py +0 -132
  164. data/ext/v8/upstream/scons/engine/SCons/Tool/sgiar.py +0 -68
  165. data/ext/v8/upstream/scons/engine/SCons/Tool/sgic++.py +0 -58
  166. data/ext/v8/upstream/scons/engine/SCons/Tool/sgicc.py +0 -53
  167. data/ext/v8/upstream/scons/engine/SCons/Tool/sgilink.py +0 -63
  168. data/ext/v8/upstream/scons/engine/SCons/Tool/sunar.py +0 -67
  169. data/ext/v8/upstream/scons/engine/SCons/Tool/sunc++.py +0 -142
  170. data/ext/v8/upstream/scons/engine/SCons/Tool/suncc.py +0 -58
  171. data/ext/v8/upstream/scons/engine/SCons/Tool/sunf77.py +0 -63
  172. data/ext/v8/upstream/scons/engine/SCons/Tool/sunf90.py +0 -64
  173. data/ext/v8/upstream/scons/engine/SCons/Tool/sunf95.py +0 -64
  174. data/ext/v8/upstream/scons/engine/SCons/Tool/sunlink.py +0 -77
  175. data/ext/v8/upstream/scons/engine/SCons/Tool/swig.py +0 -186
  176. data/ext/v8/upstream/scons/engine/SCons/Tool/tar.py +0 -73
  177. data/ext/v8/upstream/scons/engine/SCons/Tool/tex.py +0 -805
  178. data/ext/v8/upstream/scons/engine/SCons/Tool/textfile.py +0 -175
  179. data/ext/v8/upstream/scons/engine/SCons/Tool/tlib.py +0 -53
  180. data/ext/v8/upstream/scons/engine/SCons/Tool/wix.py +0 -100
  181. data/ext/v8/upstream/scons/engine/SCons/Tool/yacc.py +0 -131
  182. data/ext/v8/upstream/scons/engine/SCons/Tool/zip.py +0 -100
  183. data/ext/v8/upstream/scons/engine/SCons/Util.py +0 -1645
  184. data/ext/v8/upstream/scons/engine/SCons/Variables/BoolVariable.py +0 -91
  185. data/ext/v8/upstream/scons/engine/SCons/Variables/EnumVariable.py +0 -107
  186. data/ext/v8/upstream/scons/engine/SCons/Variables/ListVariable.py +0 -139
  187. data/ext/v8/upstream/scons/engine/SCons/Variables/PackageVariable.py +0 -109
  188. data/ext/v8/upstream/scons/engine/SCons/Variables/PathVariable.py +0 -147
  189. data/ext/v8/upstream/scons/engine/SCons/Variables/__init__.py +0 -317
  190. data/ext/v8/upstream/scons/engine/SCons/Warnings.py +0 -228
  191. data/ext/v8/upstream/scons/engine/SCons/__init__.py +0 -49
  192. data/ext/v8/upstream/scons/engine/SCons/compat/__init__.py +0 -302
  193. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_UserString.py +0 -98
  194. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_hashlib.py +0 -91
  195. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_itertools.py +0 -124
  196. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_optparse.py +0 -1725
  197. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_sets.py +0 -583
  198. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_sets15.py +0 -176
  199. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_shlex.py +0 -325
  200. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_subprocess.py +0 -1296
  201. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_textwrap.py +0 -382
  202. data/ext/v8/upstream/scons/engine/SCons/compat/builtins.py +0 -187
  203. data/ext/v8/upstream/scons/engine/SCons/cpp.py +0 -598
  204. data/ext/v8/upstream/scons/engine/SCons/dblite.py +0 -248
  205. data/ext/v8/upstream/scons/engine/SCons/exitfuncs.py +0 -77
  206. data/ext/v8/upstream/scons/os_spawnv_fix.diff +0 -83
  207. data/ext/v8/upstream/scons/scons-time.1 +0 -1017
  208. data/ext/v8/upstream/scons/scons.1 +0 -15179
  209. data/ext/v8/upstream/scons/sconsign.1 +0 -208
  210. data/ext/v8/upstream/scons/script/scons +0 -184
  211. data/ext/v8/upstream/scons/script/scons-time +0 -1529
  212. data/ext/v8/upstream/scons/script/scons.bat +0 -31
  213. data/ext/v8/upstream/scons/script/sconsign +0 -508
  214. data/ext/v8/upstream/scons/setup.cfg +0 -6
  215. data/ext/v8/upstream/scons/setup.py +0 -427
  216. data/ext/v8/upstream/v8/.gitignore +0 -33
  217. data/ext/v8/upstream/v8/AUTHORS +0 -42
  218. data/ext/v8/upstream/v8/ChangeLog +0 -2663
  219. data/ext/v8/upstream/v8/LICENSE +0 -52
  220. data/ext/v8/upstream/v8/LICENSE.strongtalk +0 -29
  221. data/ext/v8/upstream/v8/LICENSE.v8 +0 -26
  222. data/ext/v8/upstream/v8/LICENSE.valgrind +0 -45
  223. data/ext/v8/upstream/v8/SConstruct +0 -1473
  224. data/ext/v8/upstream/v8/build/README.txt +0 -25
  225. data/ext/v8/upstream/v8/build/all.gyp +0 -18
  226. data/ext/v8/upstream/v8/build/armu.gypi +0 -32
  227. data/ext/v8/upstream/v8/build/common.gypi +0 -82
  228. data/ext/v8/upstream/v8/build/gyp_v8 +0 -145
  229. data/ext/v8/upstream/v8/include/v8-debug.h +0 -394
  230. data/ext/v8/upstream/v8/include/v8-preparser.h +0 -116
  231. data/ext/v8/upstream/v8/include/v8-profiler.h +0 -505
  232. data/ext/v8/upstream/v8/include/v8-testing.h +0 -104
  233. data/ext/v8/upstream/v8/include/v8.h +0 -4000
  234. data/ext/v8/upstream/v8/include/v8stdint.h +0 -53
  235. data/ext/v8/upstream/v8/preparser/SConscript +0 -38
  236. data/ext/v8/upstream/v8/preparser/preparser-process.cc +0 -169
  237. data/ext/v8/upstream/v8/src/SConscript +0 -380
  238. data/ext/v8/upstream/v8/src/accessors.cc +0 -766
  239. data/ext/v8/upstream/v8/src/accessors.h +0 -121
  240. data/ext/v8/upstream/v8/src/allocation-inl.h +0 -49
  241. data/ext/v8/upstream/v8/src/allocation.cc +0 -122
  242. data/ext/v8/upstream/v8/src/allocation.h +0 -143
  243. data/ext/v8/upstream/v8/src/api.cc +0 -5678
  244. data/ext/v8/upstream/v8/src/api.h +0 -572
  245. data/ext/v8/upstream/v8/src/apinatives.js +0 -110
  246. data/ext/v8/upstream/v8/src/apiutils.h +0 -73
  247. data/ext/v8/upstream/v8/src/arguments.h +0 -116
  248. data/ext/v8/upstream/v8/src/arm/assembler-arm-inl.h +0 -353
  249. data/ext/v8/upstream/v8/src/arm/assembler-arm.cc +0 -2877
  250. data/ext/v8/upstream/v8/src/arm/assembler-arm.h +0 -1382
  251. data/ext/v8/upstream/v8/src/arm/builtins-arm.cc +0 -1634
  252. data/ext/v8/upstream/v8/src/arm/code-stubs-arm.cc +0 -6917
  253. data/ext/v8/upstream/v8/src/arm/code-stubs-arm.h +0 -623
  254. data/ext/v8/upstream/v8/src/arm/codegen-arm-inl.h +0 -48
  255. data/ext/v8/upstream/v8/src/arm/codegen-arm.cc +0 -7437
  256. data/ext/v8/upstream/v8/src/arm/codegen-arm.h +0 -595
  257. data/ext/v8/upstream/v8/src/arm/constants-arm.cc +0 -152
  258. data/ext/v8/upstream/v8/src/arm/constants-arm.h +0 -778
  259. data/ext/v8/upstream/v8/src/arm/cpu-arm.cc +0 -149
  260. data/ext/v8/upstream/v8/src/arm/debug-arm.cc +0 -317
  261. data/ext/v8/upstream/v8/src/arm/deoptimizer-arm.cc +0 -737
  262. data/ext/v8/upstream/v8/src/arm/disasm-arm.cc +0 -1503
  263. data/ext/v8/upstream/v8/src/arm/frames-arm.cc +0 -45
  264. data/ext/v8/upstream/v8/src/arm/frames-arm.h +0 -168
  265. data/ext/v8/upstream/v8/src/arm/full-codegen-arm.cc +0 -4374
  266. data/ext/v8/upstream/v8/src/arm/ic-arm.cc +0 -1793
  267. data/ext/v8/upstream/v8/src/arm/jump-target-arm.cc +0 -174
  268. data/ext/v8/upstream/v8/src/arm/lithium-arm.cc +0 -2120
  269. data/ext/v8/upstream/v8/src/arm/lithium-arm.h +0 -2179
  270. data/ext/v8/upstream/v8/src/arm/lithium-codegen-arm.cc +0 -4132
  271. data/ext/v8/upstream/v8/src/arm/lithium-codegen-arm.h +0 -329
  272. data/ext/v8/upstream/v8/src/arm/lithium-gap-resolver-arm.cc +0 -305
  273. data/ext/v8/upstream/v8/src/arm/lithium-gap-resolver-arm.h +0 -84
  274. data/ext/v8/upstream/v8/src/arm/macro-assembler-arm.cc +0 -2939
  275. data/ext/v8/upstream/v8/src/arm/macro-assembler-arm.h +0 -1071
  276. data/ext/v8/upstream/v8/src/arm/regexp-macro-assembler-arm.cc +0 -1287
  277. data/ext/v8/upstream/v8/src/arm/regexp-macro-assembler-arm.h +0 -253
  278. data/ext/v8/upstream/v8/src/arm/register-allocator-arm-inl.h +0 -100
  279. data/ext/v8/upstream/v8/src/arm/register-allocator-arm.cc +0 -63
  280. data/ext/v8/upstream/v8/src/arm/register-allocator-arm.h +0 -44
  281. data/ext/v8/upstream/v8/src/arm/simulator-arm.cc +0 -3288
  282. data/ext/v8/upstream/v8/src/arm/simulator-arm.h +0 -413
  283. data/ext/v8/upstream/v8/src/arm/stub-cache-arm.cc +0 -4034
  284. data/ext/v8/upstream/v8/src/arm/virtual-frame-arm-inl.h +0 -59
  285. data/ext/v8/upstream/v8/src/arm/virtual-frame-arm.cc +0 -843
  286. data/ext/v8/upstream/v8/src/arm/virtual-frame-arm.h +0 -523
  287. data/ext/v8/upstream/v8/src/array.js +0 -1249
  288. data/ext/v8/upstream/v8/src/assembler.cc +0 -1067
  289. data/ext/v8/upstream/v8/src/assembler.h +0 -823
  290. data/ext/v8/upstream/v8/src/ast-inl.h +0 -112
  291. data/ext/v8/upstream/v8/src/ast.cc +0 -1078
  292. data/ext/v8/upstream/v8/src/ast.h +0 -2234
  293. data/ext/v8/upstream/v8/src/atomicops.h +0 -167
  294. data/ext/v8/upstream/v8/src/atomicops_internals_arm_gcc.h +0 -145
  295. data/ext/v8/upstream/v8/src/atomicops_internals_mips_gcc.h +0 -169
  296. data/ext/v8/upstream/v8/src/atomicops_internals_x86_gcc.cc +0 -126
  297. data/ext/v8/upstream/v8/src/atomicops_internals_x86_gcc.h +0 -287
  298. data/ext/v8/upstream/v8/src/atomicops_internals_x86_macosx.h +0 -301
  299. data/ext/v8/upstream/v8/src/atomicops_internals_x86_msvc.h +0 -203
  300. data/ext/v8/upstream/v8/src/bignum-dtoa.cc +0 -655
  301. data/ext/v8/upstream/v8/src/bignum-dtoa.h +0 -81
  302. data/ext/v8/upstream/v8/src/bignum.cc +0 -768
  303. data/ext/v8/upstream/v8/src/bignum.h +0 -140
  304. data/ext/v8/upstream/v8/src/bootstrapper.cc +0 -2138
  305. data/ext/v8/upstream/v8/src/bootstrapper.h +0 -185
  306. data/ext/v8/upstream/v8/src/builtins.cc +0 -1708
  307. data/ext/v8/upstream/v8/src/builtins.h +0 -368
  308. data/ext/v8/upstream/v8/src/bytecodes-irregexp.h +0 -105
  309. data/ext/v8/upstream/v8/src/cached-powers.cc +0 -177
  310. data/ext/v8/upstream/v8/src/cached-powers.h +0 -65
  311. data/ext/v8/upstream/v8/src/char-predicates-inl.h +0 -94
  312. data/ext/v8/upstream/v8/src/char-predicates.h +0 -65
  313. data/ext/v8/upstream/v8/src/checks.cc +0 -110
  314. data/ext/v8/upstream/v8/src/checks.h +0 -296
  315. data/ext/v8/upstream/v8/src/circular-queue-inl.h +0 -53
  316. data/ext/v8/upstream/v8/src/circular-queue.cc +0 -122
  317. data/ext/v8/upstream/v8/src/circular-queue.h +0 -103
  318. data/ext/v8/upstream/v8/src/code-stubs.cc +0 -240
  319. data/ext/v8/upstream/v8/src/code-stubs.h +0 -971
  320. data/ext/v8/upstream/v8/src/code.h +0 -68
  321. data/ext/v8/upstream/v8/src/codegen-inl.h +0 -68
  322. data/ext/v8/upstream/v8/src/codegen.cc +0 -505
  323. data/ext/v8/upstream/v8/src/codegen.h +0 -245
  324. data/ext/v8/upstream/v8/src/compilation-cache.cc +0 -540
  325. data/ext/v8/upstream/v8/src/compilation-cache.h +0 -287
  326. data/ext/v8/upstream/v8/src/compiler.cc +0 -792
  327. data/ext/v8/upstream/v8/src/compiler.h +0 -307
  328. data/ext/v8/upstream/v8/src/contexts.cc +0 -327
  329. data/ext/v8/upstream/v8/src/contexts.h +0 -382
  330. data/ext/v8/upstream/v8/src/conversions-inl.h +0 -110
  331. data/ext/v8/upstream/v8/src/conversions.cc +0 -1125
  332. data/ext/v8/upstream/v8/src/conversions.h +0 -122
  333. data/ext/v8/upstream/v8/src/counters.cc +0 -93
  334. data/ext/v8/upstream/v8/src/counters.h +0 -254
  335. data/ext/v8/upstream/v8/src/cpu-profiler-inl.h +0 -101
  336. data/ext/v8/upstream/v8/src/cpu-profiler.cc +0 -606
  337. data/ext/v8/upstream/v8/src/cpu-profiler.h +0 -305
  338. data/ext/v8/upstream/v8/src/cpu.h +0 -67
  339. data/ext/v8/upstream/v8/src/d8-debug.cc +0 -367
  340. data/ext/v8/upstream/v8/src/d8-debug.h +0 -158
  341. data/ext/v8/upstream/v8/src/d8-posix.cc +0 -695
  342. data/ext/v8/upstream/v8/src/d8-readline.cc +0 -128
  343. data/ext/v8/upstream/v8/src/d8-windows.cc +0 -42
  344. data/ext/v8/upstream/v8/src/d8.cc +0 -796
  345. data/ext/v8/upstream/v8/src/d8.gyp +0 -88
  346. data/ext/v8/upstream/v8/src/d8.h +0 -231
  347. data/ext/v8/upstream/v8/src/d8.js +0 -2798
  348. data/ext/v8/upstream/v8/src/data-flow.cc +0 -545
  349. data/ext/v8/upstream/v8/src/data-flow.h +0 -379
  350. data/ext/v8/upstream/v8/src/date.js +0 -1103
  351. data/ext/v8/upstream/v8/src/dateparser-inl.h +0 -125
  352. data/ext/v8/upstream/v8/src/dateparser.cc +0 -178
  353. data/ext/v8/upstream/v8/src/dateparser.h +0 -265
  354. data/ext/v8/upstream/v8/src/debug-agent.cc +0 -447
  355. data/ext/v8/upstream/v8/src/debug-agent.h +0 -129
  356. data/ext/v8/upstream/v8/src/debug-debugger.js +0 -2569
  357. data/ext/v8/upstream/v8/src/debug.cc +0 -3188
  358. data/ext/v8/upstream/v8/src/debug.h +0 -1055
  359. data/ext/v8/upstream/v8/src/deoptimizer.cc +0 -1296
  360. data/ext/v8/upstream/v8/src/deoptimizer.h +0 -629
  361. data/ext/v8/upstream/v8/src/disasm.h +0 -80
  362. data/ext/v8/upstream/v8/src/disassembler.cc +0 -339
  363. data/ext/v8/upstream/v8/src/disassembler.h +0 -56
  364. data/ext/v8/upstream/v8/src/diy-fp.cc +0 -58
  365. data/ext/v8/upstream/v8/src/diy-fp.h +0 -117
  366. data/ext/v8/upstream/v8/src/double.h +0 -238
  367. data/ext/v8/upstream/v8/src/dtoa.cc +0 -103
  368. data/ext/v8/upstream/v8/src/dtoa.h +0 -85
  369. data/ext/v8/upstream/v8/src/execution.cc +0 -791
  370. data/ext/v8/upstream/v8/src/execution.h +0 -291
  371. data/ext/v8/upstream/v8/src/extensions/experimental/break-iterator.cc +0 -250
  372. data/ext/v8/upstream/v8/src/extensions/experimental/break-iterator.h +0 -89
  373. data/ext/v8/upstream/v8/src/extensions/experimental/experimental.gyp +0 -55
  374. data/ext/v8/upstream/v8/src/extensions/experimental/i18n-extension.cc +0 -284
  375. data/ext/v8/upstream/v8/src/extensions/experimental/i18n-extension.h +0 -64
  376. data/ext/v8/upstream/v8/src/extensions/externalize-string-extension.cc +0 -141
  377. data/ext/v8/upstream/v8/src/extensions/externalize-string-extension.h +0 -50
  378. data/ext/v8/upstream/v8/src/extensions/gc-extension.cc +0 -58
  379. data/ext/v8/upstream/v8/src/extensions/gc-extension.h +0 -49
  380. data/ext/v8/upstream/v8/src/factory.cc +0 -1194
  381. data/ext/v8/upstream/v8/src/factory.h +0 -436
  382. data/ext/v8/upstream/v8/src/fast-dtoa.cc +0 -736
  383. data/ext/v8/upstream/v8/src/fast-dtoa.h +0 -83
  384. data/ext/v8/upstream/v8/src/fixed-dtoa.cc +0 -405
  385. data/ext/v8/upstream/v8/src/fixed-dtoa.h +0 -55
  386. data/ext/v8/upstream/v8/src/flag-definitions.h +0 -556
  387. data/ext/v8/upstream/v8/src/flags.cc +0 -551
  388. data/ext/v8/upstream/v8/src/flags.h +0 -79
  389. data/ext/v8/upstream/v8/src/frame-element.cc +0 -37
  390. data/ext/v8/upstream/v8/src/frame-element.h +0 -269
  391. data/ext/v8/upstream/v8/src/frames-inl.h +0 -236
  392. data/ext/v8/upstream/v8/src/frames.cc +0 -1273
  393. data/ext/v8/upstream/v8/src/frames.h +0 -854
  394. data/ext/v8/upstream/v8/src/full-codegen.cc +0 -1385
  395. data/ext/v8/upstream/v8/src/full-codegen.h +0 -753
  396. data/ext/v8/upstream/v8/src/func-name-inferrer.cc +0 -91
  397. data/ext/v8/upstream/v8/src/func-name-inferrer.h +0 -111
  398. data/ext/v8/upstream/v8/src/gdb-jit.cc +0 -1548
  399. data/ext/v8/upstream/v8/src/gdb-jit.h +0 -138
  400. data/ext/v8/upstream/v8/src/global-handles.cc +0 -596
  401. data/ext/v8/upstream/v8/src/global-handles.h +0 -239
  402. data/ext/v8/upstream/v8/src/globals.h +0 -325
  403. data/ext/v8/upstream/v8/src/handles-inl.h +0 -177
  404. data/ext/v8/upstream/v8/src/handles.cc +0 -965
  405. data/ext/v8/upstream/v8/src/handles.h +0 -372
  406. data/ext/v8/upstream/v8/src/hashmap.cc +0 -230
  407. data/ext/v8/upstream/v8/src/hashmap.h +0 -121
  408. data/ext/v8/upstream/v8/src/heap-inl.h +0 -703
  409. data/ext/v8/upstream/v8/src/heap-profiler.cc +0 -1173
  410. data/ext/v8/upstream/v8/src/heap-profiler.h +0 -396
  411. data/ext/v8/upstream/v8/src/heap.cc +0 -5856
  412. data/ext/v8/upstream/v8/src/heap.h +0 -2264
  413. data/ext/v8/upstream/v8/src/hydrogen-instructions.cc +0 -1639
  414. data/ext/v8/upstream/v8/src/hydrogen-instructions.h +0 -3657
  415. data/ext/v8/upstream/v8/src/hydrogen.cc +0 -6011
  416. data/ext/v8/upstream/v8/src/hydrogen.h +0 -1137
  417. data/ext/v8/upstream/v8/src/ia32/assembler-ia32-inl.h +0 -430
  418. data/ext/v8/upstream/v8/src/ia32/assembler-ia32.cc +0 -2846
  419. data/ext/v8/upstream/v8/src/ia32/assembler-ia32.h +0 -1159
  420. data/ext/v8/upstream/v8/src/ia32/builtins-ia32.cc +0 -1596
  421. data/ext/v8/upstream/v8/src/ia32/code-stubs-ia32.cc +0 -6549
  422. data/ext/v8/upstream/v8/src/ia32/code-stubs-ia32.h +0 -495
  423. data/ext/v8/upstream/v8/src/ia32/codegen-ia32-inl.h +0 -46
  424. data/ext/v8/upstream/v8/src/ia32/codegen-ia32.cc +0 -10385
  425. data/ext/v8/upstream/v8/src/ia32/codegen-ia32.h +0 -801
  426. data/ext/v8/upstream/v8/src/ia32/cpu-ia32.cc +0 -88
  427. data/ext/v8/upstream/v8/src/ia32/debug-ia32.cc +0 -312
  428. data/ext/v8/upstream/v8/src/ia32/deoptimizer-ia32.cc +0 -774
  429. data/ext/v8/upstream/v8/src/ia32/disasm-ia32.cc +0 -1620
  430. data/ext/v8/upstream/v8/src/ia32/frames-ia32.cc +0 -45
  431. data/ext/v8/upstream/v8/src/ia32/frames-ia32.h +0 -140
  432. data/ext/v8/upstream/v8/src/ia32/full-codegen-ia32.cc +0 -4357
  433. data/ext/v8/upstream/v8/src/ia32/ic-ia32.cc +0 -1779
  434. data/ext/v8/upstream/v8/src/ia32/jump-target-ia32.cc +0 -437
  435. data/ext/v8/upstream/v8/src/ia32/lithium-codegen-ia32.cc +0 -4158
  436. data/ext/v8/upstream/v8/src/ia32/lithium-codegen-ia32.h +0 -318
  437. data/ext/v8/upstream/v8/src/ia32/lithium-gap-resolver-ia32.cc +0 -466
  438. data/ext/v8/upstream/v8/src/ia32/lithium-gap-resolver-ia32.h +0 -110
  439. data/ext/v8/upstream/v8/src/ia32/lithium-ia32.cc +0 -2181
  440. data/ext/v8/upstream/v8/src/ia32/lithium-ia32.h +0 -2235
  441. data/ext/v8/upstream/v8/src/ia32/macro-assembler-ia32.cc +0 -2056
  442. data/ext/v8/upstream/v8/src/ia32/macro-assembler-ia32.h +0 -807
  443. data/ext/v8/upstream/v8/src/ia32/regexp-macro-assembler-ia32.cc +0 -1264
  444. data/ext/v8/upstream/v8/src/ia32/regexp-macro-assembler-ia32.h +0 -216
  445. data/ext/v8/upstream/v8/src/ia32/register-allocator-ia32-inl.h +0 -82
  446. data/ext/v8/upstream/v8/src/ia32/register-allocator-ia32.cc +0 -157
  447. data/ext/v8/upstream/v8/src/ia32/register-allocator-ia32.h +0 -43
  448. data/ext/v8/upstream/v8/src/ia32/simulator-ia32.cc +0 -30
  449. data/ext/v8/upstream/v8/src/ia32/simulator-ia32.h +0 -72
  450. data/ext/v8/upstream/v8/src/ia32/stub-cache-ia32.cc +0 -3711
  451. data/ext/v8/upstream/v8/src/ia32/virtual-frame-ia32.cc +0 -1366
  452. data/ext/v8/upstream/v8/src/ia32/virtual-frame-ia32.h +0 -650
  453. data/ext/v8/upstream/v8/src/ic-inl.h +0 -130
  454. data/ext/v8/upstream/v8/src/ic.cc +0 -2389
  455. data/ext/v8/upstream/v8/src/ic.h +0 -675
  456. data/ext/v8/upstream/v8/src/inspector.cc +0 -63
  457. data/ext/v8/upstream/v8/src/inspector.h +0 -62
  458. data/ext/v8/upstream/v8/src/interpreter-irregexp.cc +0 -659
  459. data/ext/v8/upstream/v8/src/interpreter-irregexp.h +0 -49
  460. data/ext/v8/upstream/v8/src/isolate.cc +0 -883
  461. data/ext/v8/upstream/v8/src/isolate.h +0 -1306
  462. data/ext/v8/upstream/v8/src/json.js +0 -342
  463. data/ext/v8/upstream/v8/src/jsregexp.cc +0 -5371
  464. data/ext/v8/upstream/v8/src/jsregexp.h +0 -1483
  465. data/ext/v8/upstream/v8/src/jump-target-heavy-inl.h +0 -51
  466. data/ext/v8/upstream/v8/src/jump-target-heavy.cc +0 -427
  467. data/ext/v8/upstream/v8/src/jump-target-heavy.h +0 -238
  468. data/ext/v8/upstream/v8/src/jump-target-inl.h +0 -48
  469. data/ext/v8/upstream/v8/src/jump-target-light-inl.h +0 -56
  470. data/ext/v8/upstream/v8/src/jump-target-light.cc +0 -111
  471. data/ext/v8/upstream/v8/src/jump-target-light.h +0 -193
  472. data/ext/v8/upstream/v8/src/jump-target.cc +0 -91
  473. data/ext/v8/upstream/v8/src/jump-target.h +0 -90
  474. data/ext/v8/upstream/v8/src/list-inl.h +0 -206
  475. data/ext/v8/upstream/v8/src/list.h +0 -164
  476. data/ext/v8/upstream/v8/src/lithium-allocator-inl.h +0 -142
  477. data/ext/v8/upstream/v8/src/lithium-allocator.cc +0 -2105
  478. data/ext/v8/upstream/v8/src/lithium-allocator.h +0 -630
  479. data/ext/v8/upstream/v8/src/lithium.cc +0 -169
  480. data/ext/v8/upstream/v8/src/lithium.h +0 -592
  481. data/ext/v8/upstream/v8/src/liveedit-debugger.js +0 -1082
  482. data/ext/v8/upstream/v8/src/liveedit.cc +0 -1693
  483. data/ext/v8/upstream/v8/src/liveedit.h +0 -179
  484. data/ext/v8/upstream/v8/src/liveobjectlist-inl.h +0 -126
  485. data/ext/v8/upstream/v8/src/liveobjectlist.cc +0 -2589
  486. data/ext/v8/upstream/v8/src/liveobjectlist.h +0 -322
  487. data/ext/v8/upstream/v8/src/log-inl.h +0 -59
  488. data/ext/v8/upstream/v8/src/log-utils.cc +0 -423
  489. data/ext/v8/upstream/v8/src/log-utils.h +0 -229
  490. data/ext/v8/upstream/v8/src/log.cc +0 -1666
  491. data/ext/v8/upstream/v8/src/log.h +0 -446
  492. data/ext/v8/upstream/v8/src/macro-assembler.h +0 -120
  493. data/ext/v8/upstream/v8/src/macros.py +0 -178
  494. data/ext/v8/upstream/v8/src/mark-compact.cc +0 -3092
  495. data/ext/v8/upstream/v8/src/mark-compact.h +0 -506
  496. data/ext/v8/upstream/v8/src/math.js +0 -264
  497. data/ext/v8/upstream/v8/src/messages.cc +0 -166
  498. data/ext/v8/upstream/v8/src/messages.h +0 -114
  499. data/ext/v8/upstream/v8/src/messages.js +0 -1090
  500. data/ext/v8/upstream/v8/src/mips/assembler-mips-inl.h +0 -335
  501. data/ext/v8/upstream/v8/src/mips/assembler-mips.cc +0 -2093
  502. data/ext/v8/upstream/v8/src/mips/assembler-mips.h +0 -1066
  503. data/ext/v8/upstream/v8/src/mips/builtins-mips.cc +0 -148
  504. data/ext/v8/upstream/v8/src/mips/code-stubs-mips.cc +0 -752
  505. data/ext/v8/upstream/v8/src/mips/code-stubs-mips.h +0 -511
  506. data/ext/v8/upstream/v8/src/mips/codegen-mips-inl.h +0 -64
  507. data/ext/v8/upstream/v8/src/mips/codegen-mips.cc +0 -1213
  508. data/ext/v8/upstream/v8/src/mips/codegen-mips.h +0 -633
  509. data/ext/v8/upstream/v8/src/mips/constants-mips.cc +0 -352
  510. data/ext/v8/upstream/v8/src/mips/constants-mips.h +0 -723
  511. data/ext/v8/upstream/v8/src/mips/cpu-mips.cc +0 -90
  512. data/ext/v8/upstream/v8/src/mips/debug-mips.cc +0 -155
  513. data/ext/v8/upstream/v8/src/mips/deoptimizer-mips.cc +0 -91
  514. data/ext/v8/upstream/v8/src/mips/disasm-mips.cc +0 -1023
  515. data/ext/v8/upstream/v8/src/mips/frames-mips.cc +0 -48
  516. data/ext/v8/upstream/v8/src/mips/frames-mips.h +0 -179
  517. data/ext/v8/upstream/v8/src/mips/full-codegen-mips.cc +0 -727
  518. data/ext/v8/upstream/v8/src/mips/ic-mips.cc +0 -244
  519. data/ext/v8/upstream/v8/src/mips/jump-target-mips.cc +0 -80
  520. data/ext/v8/upstream/v8/src/mips/lithium-codegen-mips.h +0 -65
  521. data/ext/v8/upstream/v8/src/mips/lithium-mips.h +0 -304
  522. data/ext/v8/upstream/v8/src/mips/macro-assembler-mips.cc +0 -3327
  523. data/ext/v8/upstream/v8/src/mips/macro-assembler-mips.h +0 -1058
  524. data/ext/v8/upstream/v8/src/mips/regexp-macro-assembler-mips.cc +0 -478
  525. data/ext/v8/upstream/v8/src/mips/regexp-macro-assembler-mips.h +0 -250
  526. data/ext/v8/upstream/v8/src/mips/register-allocator-mips-inl.h +0 -134
  527. data/ext/v8/upstream/v8/src/mips/register-allocator-mips.cc +0 -63
  528. data/ext/v8/upstream/v8/src/mips/register-allocator-mips.h +0 -47
  529. data/ext/v8/upstream/v8/src/mips/simulator-mips.cc +0 -2438
  530. data/ext/v8/upstream/v8/src/mips/simulator-mips.h +0 -394
  531. data/ext/v8/upstream/v8/src/mips/stub-cache-mips.cc +0 -601
  532. data/ext/v8/upstream/v8/src/mips/virtual-frame-mips-inl.h +0 -58
  533. data/ext/v8/upstream/v8/src/mips/virtual-frame-mips.cc +0 -307
  534. data/ext/v8/upstream/v8/src/mips/virtual-frame-mips.h +0 -530
  535. data/ext/v8/upstream/v8/src/mirror-debugger.js +0 -2381
  536. data/ext/v8/upstream/v8/src/mksnapshot.cc +0 -256
  537. data/ext/v8/upstream/v8/src/natives.h +0 -63
  538. data/ext/v8/upstream/v8/src/objects-debug.cc +0 -722
  539. data/ext/v8/upstream/v8/src/objects-inl.h +0 -4166
  540. data/ext/v8/upstream/v8/src/objects-printer.cc +0 -801
  541. data/ext/v8/upstream/v8/src/objects-visiting.cc +0 -142
  542. data/ext/v8/upstream/v8/src/objects-visiting.h +0 -422
  543. data/ext/v8/upstream/v8/src/objects.cc +0 -10296
  544. data/ext/v8/upstream/v8/src/objects.h +0 -6662
  545. data/ext/v8/upstream/v8/src/parser.cc +0 -5168
  546. data/ext/v8/upstream/v8/src/parser.h +0 -823
  547. data/ext/v8/upstream/v8/src/platform-cygwin.cc +0 -811
  548. data/ext/v8/upstream/v8/src/platform-freebsd.cc +0 -854
  549. data/ext/v8/upstream/v8/src/platform-linux.cc +0 -1120
  550. data/ext/v8/upstream/v8/src/platform-macos.cc +0 -865
  551. data/ext/v8/upstream/v8/src/platform-nullos.cc +0 -504
  552. data/ext/v8/upstream/v8/src/platform-openbsd.cc +0 -672
  553. data/ext/v8/upstream/v8/src/platform-posix.cc +0 -424
  554. data/ext/v8/upstream/v8/src/platform-solaris.cc +0 -796
  555. data/ext/v8/upstream/v8/src/platform-tls-mac.h +0 -62
  556. data/ext/v8/upstream/v8/src/platform-tls-win32.h +0 -62
  557. data/ext/v8/upstream/v8/src/platform-tls.h +0 -50
  558. data/ext/v8/upstream/v8/src/platform-win32.cc +0 -2072
  559. data/ext/v8/upstream/v8/src/platform.h +0 -693
  560. data/ext/v8/upstream/v8/src/preparse-data.cc +0 -185
  561. data/ext/v8/upstream/v8/src/preparse-data.h +0 -249
  562. data/ext/v8/upstream/v8/src/preparser-api.cc +0 -219
  563. data/ext/v8/upstream/v8/src/preparser.cc +0 -1205
  564. data/ext/v8/upstream/v8/src/preparser.h +0 -278
  565. data/ext/v8/upstream/v8/src/prettyprinter.cc +0 -1530
  566. data/ext/v8/upstream/v8/src/prettyprinter.h +0 -223
  567. data/ext/v8/upstream/v8/src/profile-generator-inl.h +0 -128
  568. data/ext/v8/upstream/v8/src/profile-generator.cc +0 -3095
  569. data/ext/v8/upstream/v8/src/profile-generator.h +0 -1125
  570. data/ext/v8/upstream/v8/src/property.cc +0 -102
  571. data/ext/v8/upstream/v8/src/property.h +0 -348
  572. data/ext/v8/upstream/v8/src/regexp-macro-assembler-irregexp-inl.h +0 -78
  573. data/ext/v8/upstream/v8/src/regexp-macro-assembler-irregexp.cc +0 -470
  574. data/ext/v8/upstream/v8/src/regexp-macro-assembler-irregexp.h +0 -142
  575. data/ext/v8/upstream/v8/src/regexp-macro-assembler-tracer.cc +0 -373
  576. data/ext/v8/upstream/v8/src/regexp-macro-assembler-tracer.h +0 -104
  577. data/ext/v8/upstream/v8/src/regexp-macro-assembler.cc +0 -266
  578. data/ext/v8/upstream/v8/src/regexp-macro-assembler.h +0 -236
  579. data/ext/v8/upstream/v8/src/regexp-stack.cc +0 -111
  580. data/ext/v8/upstream/v8/src/regexp-stack.h +0 -147
  581. data/ext/v8/upstream/v8/src/regexp.js +0 -483
  582. data/ext/v8/upstream/v8/src/register-allocator-inl.h +0 -141
  583. data/ext/v8/upstream/v8/src/register-allocator.cc +0 -98
  584. data/ext/v8/upstream/v8/src/register-allocator.h +0 -310
  585. data/ext/v8/upstream/v8/src/rewriter.cc +0 -1024
  586. data/ext/v8/upstream/v8/src/rewriter.h +0 -59
  587. data/ext/v8/upstream/v8/src/runtime-profiler.cc +0 -478
  588. data/ext/v8/upstream/v8/src/runtime-profiler.h +0 -192
  589. data/ext/v8/upstream/v8/src/runtime.cc +0 -11949
  590. data/ext/v8/upstream/v8/src/runtime.h +0 -643
  591. data/ext/v8/upstream/v8/src/runtime.js +0 -643
  592. data/ext/v8/upstream/v8/src/safepoint-table.cc +0 -256
  593. data/ext/v8/upstream/v8/src/safepoint-table.h +0 -269
  594. data/ext/v8/upstream/v8/src/scanner-base.cc +0 -964
  595. data/ext/v8/upstream/v8/src/scanner-base.h +0 -664
  596. data/ext/v8/upstream/v8/src/scanner.cc +0 -584
  597. data/ext/v8/upstream/v8/src/scanner.h +0 -196
  598. data/ext/v8/upstream/v8/src/scopeinfo.cc +0 -631
  599. data/ext/v8/upstream/v8/src/scopeinfo.h +0 -249
  600. data/ext/v8/upstream/v8/src/scopes.cc +0 -1093
  601. data/ext/v8/upstream/v8/src/scopes.h +0 -508
  602. data/ext/v8/upstream/v8/src/serialize.cc +0 -1574
  603. data/ext/v8/upstream/v8/src/serialize.h +0 -589
  604. data/ext/v8/upstream/v8/src/shell.h +0 -55
  605. data/ext/v8/upstream/v8/src/simulator.h +0 -43
  606. data/ext/v8/upstream/v8/src/small-pointer-list.h +0 -163
  607. data/ext/v8/upstream/v8/src/smart-pointer.h +0 -109
  608. data/ext/v8/upstream/v8/src/snapshot-common.cc +0 -82
  609. data/ext/v8/upstream/v8/src/snapshot-empty.cc +0 -50
  610. data/ext/v8/upstream/v8/src/snapshot.h +0 -73
  611. data/ext/v8/upstream/v8/src/spaces-inl.h +0 -529
  612. data/ext/v8/upstream/v8/src/spaces.cc +0 -3147
  613. data/ext/v8/upstream/v8/src/spaces.h +0 -2368
  614. data/ext/v8/upstream/v8/src/splay-tree-inl.h +0 -310
  615. data/ext/v8/upstream/v8/src/splay-tree.h +0 -203
  616. data/ext/v8/upstream/v8/src/string-search.cc +0 -41
  617. data/ext/v8/upstream/v8/src/string-search.h +0 -568
  618. data/ext/v8/upstream/v8/src/string-stream.cc +0 -592
  619. data/ext/v8/upstream/v8/src/string-stream.h +0 -191
  620. data/ext/v8/upstream/v8/src/string.js +0 -915
  621. data/ext/v8/upstream/v8/src/strtod.cc +0 -440
  622. data/ext/v8/upstream/v8/src/strtod.h +0 -40
  623. data/ext/v8/upstream/v8/src/stub-cache.cc +0 -1940
  624. data/ext/v8/upstream/v8/src/stub-cache.h +0 -866
  625. data/ext/v8/upstream/v8/src/third_party/valgrind/valgrind.h +0 -3925
  626. data/ext/v8/upstream/v8/src/token.cc +0 -63
  627. data/ext/v8/upstream/v8/src/token.h +0 -288
  628. data/ext/v8/upstream/v8/src/top.cc +0 -983
  629. data/ext/v8/upstream/v8/src/type-info.cc +0 -472
  630. data/ext/v8/upstream/v8/src/type-info.h +0 -290
  631. data/ext/v8/upstream/v8/src/unbound-queue-inl.h +0 -95
  632. data/ext/v8/upstream/v8/src/unbound-queue.h +0 -67
  633. data/ext/v8/upstream/v8/src/unicode-inl.h +0 -238
  634. data/ext/v8/upstream/v8/src/unicode.cc +0 -1624
  635. data/ext/v8/upstream/v8/src/unicode.h +0 -280
  636. data/ext/v8/upstream/v8/src/uri.js +0 -402
  637. data/ext/v8/upstream/v8/src/utils.cc +0 -371
  638. data/ext/v8/upstream/v8/src/utils.h +0 -796
  639. data/ext/v8/upstream/v8/src/v8-counters.cc +0 -62
  640. data/ext/v8/upstream/v8/src/v8-counters.h +0 -311
  641. data/ext/v8/upstream/v8/src/v8.cc +0 -215
  642. data/ext/v8/upstream/v8/src/v8.h +0 -130
  643. data/ext/v8/upstream/v8/src/v8checks.h +0 -64
  644. data/ext/v8/upstream/v8/src/v8dll-main.cc +0 -39
  645. data/ext/v8/upstream/v8/src/v8globals.h +0 -486
  646. data/ext/v8/upstream/v8/src/v8memory.h +0 -82
  647. data/ext/v8/upstream/v8/src/v8natives.js +0 -1293
  648. data/ext/v8/upstream/v8/src/v8preparserdll-main.cc +0 -39
  649. data/ext/v8/upstream/v8/src/v8threads.cc +0 -453
  650. data/ext/v8/upstream/v8/src/v8threads.h +0 -164
  651. data/ext/v8/upstream/v8/src/v8utils.h +0 -317
  652. data/ext/v8/upstream/v8/src/variables.cc +0 -132
  653. data/ext/v8/upstream/v8/src/variables.h +0 -212
  654. data/ext/v8/upstream/v8/src/version.cc +0 -116
  655. data/ext/v8/upstream/v8/src/version.h +0 -68
  656. data/ext/v8/upstream/v8/src/virtual-frame-heavy-inl.h +0 -190
  657. data/ext/v8/upstream/v8/src/virtual-frame-heavy.cc +0 -312
  658. data/ext/v8/upstream/v8/src/virtual-frame-inl.h +0 -39
  659. data/ext/v8/upstream/v8/src/virtual-frame-light-inl.h +0 -171
  660. data/ext/v8/upstream/v8/src/virtual-frame-light.cc +0 -52
  661. data/ext/v8/upstream/v8/src/virtual-frame.cc +0 -49
  662. data/ext/v8/upstream/v8/src/virtual-frame.h +0 -59
  663. data/ext/v8/upstream/v8/src/vm-state-inl.h +0 -138
  664. data/ext/v8/upstream/v8/src/vm-state.h +0 -70
  665. data/ext/v8/upstream/v8/src/win32-headers.h +0 -96
  666. data/ext/v8/upstream/v8/src/x64/assembler-x64-inl.h +0 -456
  667. data/ext/v8/upstream/v8/src/x64/assembler-x64.cc +0 -2954
  668. data/ext/v8/upstream/v8/src/x64/assembler-x64.h +0 -1630
  669. data/ext/v8/upstream/v8/src/x64/builtins-x64.cc +0 -1493
  670. data/ext/v8/upstream/v8/src/x64/code-stubs-x64.cc +0 -5132
  671. data/ext/v8/upstream/v8/src/x64/code-stubs-x64.h +0 -477
  672. data/ext/v8/upstream/v8/src/x64/codegen-x64-inl.h +0 -46
  673. data/ext/v8/upstream/v8/src/x64/codegen-x64.cc +0 -8843
  674. data/ext/v8/upstream/v8/src/x64/codegen-x64.h +0 -753
  675. data/ext/v8/upstream/v8/src/x64/cpu-x64.cc +0 -88
  676. data/ext/v8/upstream/v8/src/x64/debug-x64.cc +0 -318
  677. data/ext/v8/upstream/v8/src/x64/deoptimizer-x64.cc +0 -815
  678. data/ext/v8/upstream/v8/src/x64/disasm-x64.cc +0 -1752
  679. data/ext/v8/upstream/v8/src/x64/frames-x64.cc +0 -45
  680. data/ext/v8/upstream/v8/src/x64/frames-x64.h +0 -130
  681. data/ext/v8/upstream/v8/src/x64/full-codegen-x64.cc +0 -4339
  682. data/ext/v8/upstream/v8/src/x64/ic-x64.cc +0 -1752
  683. data/ext/v8/upstream/v8/src/x64/jump-target-x64.cc +0 -437
  684. data/ext/v8/upstream/v8/src/x64/lithium-codegen-x64.cc +0 -3970
  685. data/ext/v8/upstream/v8/src/x64/lithium-codegen-x64.h +0 -318
  686. data/ext/v8/upstream/v8/src/x64/lithium-gap-resolver-x64.cc +0 -320
  687. data/ext/v8/upstream/v8/src/x64/lithium-gap-resolver-x64.h +0 -74
  688. data/ext/v8/upstream/v8/src/x64/lithium-x64.cc +0 -2115
  689. data/ext/v8/upstream/v8/src/x64/lithium-x64.h +0 -2161
  690. data/ext/v8/upstream/v8/src/x64/macro-assembler-x64.cc +0 -2911
  691. data/ext/v8/upstream/v8/src/x64/macro-assembler-x64.h +0 -1984
  692. data/ext/v8/upstream/v8/src/x64/regexp-macro-assembler-x64.cc +0 -1398
  693. data/ext/v8/upstream/v8/src/x64/regexp-macro-assembler-x64.h +0 -282
  694. data/ext/v8/upstream/v8/src/x64/register-allocator-x64-inl.h +0 -87
  695. data/ext/v8/upstream/v8/src/x64/register-allocator-x64.cc +0 -95
  696. data/ext/v8/upstream/v8/src/x64/register-allocator-x64.h +0 -43
  697. data/ext/v8/upstream/v8/src/x64/simulator-x64.cc +0 -27
  698. data/ext/v8/upstream/v8/src/x64/simulator-x64.h +0 -71
  699. data/ext/v8/upstream/v8/src/x64/stub-cache-x64.cc +0 -3460
  700. data/ext/v8/upstream/v8/src/x64/virtual-frame-x64.cc +0 -1296
  701. data/ext/v8/upstream/v8/src/x64/virtual-frame-x64.h +0 -597
  702. data/ext/v8/upstream/v8/src/zone-inl.h +0 -129
  703. data/ext/v8/upstream/v8/src/zone.cc +0 -196
  704. data/ext/v8/upstream/v8/src/zone.h +0 -236
  705. data/ext/v8/upstream/v8/tools/codemap.js +0 -265
  706. data/ext/v8/upstream/v8/tools/consarray.js +0 -93
  707. data/ext/v8/upstream/v8/tools/csvparser.js +0 -78
  708. data/ext/v8/upstream/v8/tools/disasm.py +0 -92
  709. data/ext/v8/upstream/v8/tools/freebsd-tick-processor +0 -10
  710. data/ext/v8/upstream/v8/tools/gc-nvp-trace-processor.py +0 -328
  711. data/ext/v8/upstream/v8/tools/generate-ten-powers.scm +0 -286
  712. data/ext/v8/upstream/v8/tools/grokdump.py +0 -840
  713. data/ext/v8/upstream/v8/tools/gyp/v8.gyp +0 -844
  714. data/ext/v8/upstream/v8/tools/js2c.py +0 -380
  715. data/ext/v8/upstream/v8/tools/jsmin.py +0 -280
  716. data/ext/v8/upstream/v8/tools/linux-tick-processor +0 -35
  717. data/ext/v8/upstream/v8/tools/ll_prof.py +0 -919
  718. data/ext/v8/upstream/v8/tools/logreader.js +0 -185
  719. data/ext/v8/upstream/v8/tools/mac-nm +0 -18
  720. data/ext/v8/upstream/v8/tools/mac-tick-processor +0 -6
  721. data/ext/v8/upstream/v8/tools/oom_dump/README +0 -31
  722. data/ext/v8/upstream/v8/tools/oom_dump/SConstruct +0 -42
  723. data/ext/v8/upstream/v8/tools/oom_dump/oom_dump.cc +0 -288
  724. data/ext/v8/upstream/v8/tools/presubmit.py +0 -305
  725. data/ext/v8/upstream/v8/tools/process-heap-prof.py +0 -120
  726. data/ext/v8/upstream/v8/tools/profile.js +0 -751
  727. data/ext/v8/upstream/v8/tools/profile_view.js +0 -219
  728. data/ext/v8/upstream/v8/tools/run-valgrind.py +0 -77
  729. data/ext/v8/upstream/v8/tools/splaytree.js +0 -316
  730. data/ext/v8/upstream/v8/tools/stats-viewer.py +0 -468
  731. data/ext/v8/upstream/v8/tools/test.py +0 -1490
  732. data/ext/v8/upstream/v8/tools/tickprocessor-driver.js +0 -59
  733. data/ext/v8/upstream/v8/tools/tickprocessor.js +0 -877
  734. data/ext/v8/upstream/v8/tools/utils.py +0 -96
  735. data/ext/v8/upstream/v8/tools/visual_studio/README.txt +0 -70
  736. data/ext/v8/upstream/v8/tools/visual_studio/arm.vsprops +0 -14
  737. data/ext/v8/upstream/v8/tools/visual_studio/common.vsprops +0 -34
  738. data/ext/v8/upstream/v8/tools/visual_studio/d8.vcproj +0 -193
  739. data/ext/v8/upstream/v8/tools/visual_studio/d8_arm.vcproj +0 -193
  740. data/ext/v8/upstream/v8/tools/visual_studio/d8_x64.vcproj +0 -209
  741. data/ext/v8/upstream/v8/tools/visual_studio/d8js2c.cmd +0 -6
  742. data/ext/v8/upstream/v8/tools/visual_studio/debug.vsprops +0 -17
  743. data/ext/v8/upstream/v8/tools/visual_studio/ia32.vsprops +0 -17
  744. data/ext/v8/upstream/v8/tools/visual_studio/js2c.cmd +0 -6
  745. data/ext/v8/upstream/v8/tools/visual_studio/release.vsprops +0 -24
  746. data/ext/v8/upstream/v8/tools/visual_studio/v8.sln +0 -101
  747. data/ext/v8/upstream/v8/tools/visual_studio/v8.vcproj +0 -227
  748. data/ext/v8/upstream/v8/tools/visual_studio/v8_arm.sln +0 -74
  749. data/ext/v8/upstream/v8/tools/visual_studio/v8_arm.vcproj +0 -227
  750. data/ext/v8/upstream/v8/tools/visual_studio/v8_base.vcproj +0 -1308
  751. data/ext/v8/upstream/v8/tools/visual_studio/v8_base_arm.vcproj +0 -1238
  752. data/ext/v8/upstream/v8/tools/visual_studio/v8_base_x64.vcproj +0 -1300
  753. data/ext/v8/upstream/v8/tools/visual_studio/v8_cctest.vcproj +0 -265
  754. data/ext/v8/upstream/v8/tools/visual_studio/v8_cctest_arm.vcproj +0 -249
  755. data/ext/v8/upstream/v8/tools/visual_studio/v8_cctest_x64.vcproj +0 -257
  756. data/ext/v8/upstream/v8/tools/visual_studio/v8_mksnapshot.vcproj +0 -145
  757. data/ext/v8/upstream/v8/tools/visual_studio/v8_mksnapshot_x64.vcproj +0 -145
  758. data/ext/v8/upstream/v8/tools/visual_studio/v8_process_sample.vcproj +0 -145
  759. data/ext/v8/upstream/v8/tools/visual_studio/v8_process_sample_arm.vcproj +0 -145
  760. data/ext/v8/upstream/v8/tools/visual_studio/v8_process_sample_x64.vcproj +0 -161
  761. data/ext/v8/upstream/v8/tools/visual_studio/v8_shell_sample.vcproj +0 -147
  762. data/ext/v8/upstream/v8/tools/visual_studio/v8_shell_sample_arm.vcproj +0 -147
  763. data/ext/v8/upstream/v8/tools/visual_studio/v8_shell_sample_x64.vcproj +0 -163
  764. data/ext/v8/upstream/v8/tools/visual_studio/v8_snapshot.vcproj +0 -142
  765. data/ext/v8/upstream/v8/tools/visual_studio/v8_snapshot_cc.vcproj +0 -92
  766. data/ext/v8/upstream/v8/tools/visual_studio/v8_snapshot_cc_x64.vcproj +0 -92
  767. data/ext/v8/upstream/v8/tools/visual_studio/v8_snapshot_x64.vcproj +0 -142
  768. data/ext/v8/upstream/v8/tools/visual_studio/v8_x64.sln +0 -101
  769. data/ext/v8/upstream/v8/tools/visual_studio/v8_x64.vcproj +0 -227
  770. data/ext/v8/upstream/v8/tools/visual_studio/x64.vsprops +0 -18
  771. data/ext/v8/upstream/v8/tools/windows-tick-processor.bat +0 -30
@@ -1,437 +0,0 @@
1
- // Copyright 2010 the V8 project authors. All rights reserved.
2
- // Redistribution and use in source and binary forms, with or without
3
- // modification, are permitted provided that the following conditions are
4
- // met:
5
- //
6
- // * Redistributions of source code must retain the above copyright
7
- // notice, this list of conditions and the following disclaimer.
8
- // * Redistributions in binary form must reproduce the above
9
- // copyright notice, this list of conditions and the following
10
- // disclaimer in the documentation and/or other materials provided
11
- // with the distribution.
12
- // * Neither the name of Google Inc. nor the names of its
13
- // contributors may be used to endorse or promote products derived
14
- // from this software without specific prior written permission.
15
- //
16
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
- // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
- // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
- // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
- // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
- // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
- // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
- // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
- // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
- // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
- // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
-
28
- #include "v8.h"
29
-
30
- #if defined(V8_TARGET_ARCH_X64)
31
-
32
- #include "codegen-inl.h"
33
- #include "jump-target-inl.h"
34
- #include "register-allocator-inl.h"
35
- #include "virtual-frame-inl.h"
36
-
37
- namespace v8 {
38
- namespace internal {
39
-
40
- // -------------------------------------------------------------------------
41
- // JumpTarget implementation.
42
-
43
- #define __ ACCESS_MASM(cgen()->masm())
44
-
45
- void JumpTarget::DoJump() {
46
- ASSERT(cgen()->has_valid_frame());
47
- // Live non-frame registers are not allowed at unconditional jumps
48
- // because we have no way of invalidating the corresponding results
49
- // which are still live in the C++ code.
50
- ASSERT(cgen()->HasValidEntryRegisters());
51
-
52
- if (is_bound()) {
53
- // Backward jump. There is an expected frame to merge to.
54
- ASSERT(direction_ == BIDIRECTIONAL);
55
- cgen()->frame()->PrepareMergeTo(entry_frame_);
56
- cgen()->frame()->MergeTo(entry_frame_);
57
- cgen()->DeleteFrame();
58
- __ jmp(&entry_label_);
59
- } else if (entry_frame_ != NULL) {
60
- // Forward jump with a preconfigured entry frame. Assert the
61
- // current frame matches the expected one and jump to the block.
62
- ASSERT(cgen()->frame()->Equals(entry_frame_));
63
- cgen()->DeleteFrame();
64
- __ jmp(&entry_label_);
65
- } else {
66
- // Forward jump. Remember the current frame and emit a jump to
67
- // its merge code.
68
- AddReachingFrame(cgen()->frame());
69
- RegisterFile empty;
70
- cgen()->SetFrame(NULL, &empty);
71
- __ jmp(&merge_labels_.last());
72
- }
73
- }
74
-
75
-
76
- void JumpTarget::DoBranch(Condition cc, Hint b) {
77
- ASSERT(cgen() != NULL);
78
- ASSERT(cgen()->has_valid_frame());
79
-
80
- if (is_bound()) {
81
- ASSERT(direction_ == BIDIRECTIONAL);
82
- // Backward branch. We have an expected frame to merge to on the
83
- // backward edge.
84
-
85
- // Swap the current frame for a copy (we do the swapping to get
86
- // the off-frame registers off the fall through) to use for the
87
- // branch.
88
- VirtualFrame* fall_through_frame = cgen()->frame();
89
- VirtualFrame* branch_frame = new VirtualFrame(fall_through_frame);
90
- RegisterFile non_frame_registers;
91
- cgen()->SetFrame(branch_frame, &non_frame_registers);
92
-
93
- // Check if we can avoid merge code.
94
- cgen()->frame()->PrepareMergeTo(entry_frame_);
95
- if (cgen()->frame()->Equals(entry_frame_)) {
96
- // Branch right in to the block.
97
- cgen()->DeleteFrame();
98
- __ j(cc, &entry_label_);
99
- cgen()->SetFrame(fall_through_frame, &non_frame_registers);
100
- return;
101
- }
102
-
103
- // Check if we can reuse existing merge code.
104
- for (int i = 0; i < reaching_frames_.length(); i++) {
105
- if (reaching_frames_[i] != NULL &&
106
- cgen()->frame()->Equals(reaching_frames_[i])) {
107
- // Branch to the merge code.
108
- cgen()->DeleteFrame();
109
- __ j(cc, &merge_labels_[i]);
110
- cgen()->SetFrame(fall_through_frame, &non_frame_registers);
111
- return;
112
- }
113
- }
114
-
115
- // To emit the merge code here, we negate the condition and branch
116
- // around the merge code on the fall through path.
117
- Label original_fall_through;
118
- __ j(NegateCondition(cc), &original_fall_through);
119
- cgen()->frame()->MergeTo(entry_frame_);
120
- cgen()->DeleteFrame();
121
- __ jmp(&entry_label_);
122
- cgen()->SetFrame(fall_through_frame, &non_frame_registers);
123
- __ bind(&original_fall_through);
124
-
125
- } else if (entry_frame_ != NULL) {
126
- // Forward branch with a preconfigured entry frame. Assert the
127
- // current frame matches the expected one and branch to the block.
128
- ASSERT(cgen()->frame()->Equals(entry_frame_));
129
- // Explicitly use the macro assembler instead of __ as forward
130
- // branches are expected to be a fixed size (no inserted
131
- // coverage-checking instructions please). This is used in
132
- // Reference::GetValue.
133
- cgen()->masm()->j(cc, &entry_label_);
134
-
135
- } else {
136
- // Forward branch. A copy of the current frame is remembered and
137
- // a branch to the merge code is emitted. Explicitly use the
138
- // macro assembler instead of __ as forward branches are expected
139
- // to be a fixed size (no inserted coverage-checking instructions
140
- // please). This is used in Reference::GetValue.
141
- AddReachingFrame(new VirtualFrame(cgen()->frame()));
142
- cgen()->masm()->j(cc, &merge_labels_.last());
143
- }
144
- }
145
-
146
-
147
- void JumpTarget::Call() {
148
- // Call is used to push the address of the catch block on the stack as
149
- // a return address when compiling try/catch and try/finally. We
150
- // fully spill the frame before making the call. The expected frame
151
- // at the label (which should be the only one) is the spilled current
152
- // frame plus an in-memory return address. The "fall-through" frame
153
- // at the return site is the spilled current frame.
154
- ASSERT(cgen() != NULL);
155
- ASSERT(cgen()->has_valid_frame());
156
- // There are no non-frame references across the call.
157
- ASSERT(cgen()->HasValidEntryRegisters());
158
- ASSERT(!is_linked());
159
-
160
- cgen()->frame()->SpillAll();
161
- VirtualFrame* target_frame = new VirtualFrame(cgen()->frame());
162
- target_frame->Adjust(1);
163
- // We do not expect a call with a preconfigured entry frame.
164
- ASSERT(entry_frame_ == NULL);
165
- AddReachingFrame(target_frame);
166
- __ call(&merge_labels_.last());
167
- }
168
-
169
-
170
- void JumpTarget::DoBind() {
171
- ASSERT(cgen() != NULL);
172
- ASSERT(!is_bound());
173
-
174
- // Live non-frame registers are not allowed at the start of a basic
175
- // block.
176
- ASSERT(!cgen()->has_valid_frame() || cgen()->HasValidEntryRegisters());
177
-
178
- // Fast case: the jump target was manually configured with an entry
179
- // frame to use.
180
- if (entry_frame_ != NULL) {
181
- // Assert no reaching frames to deal with.
182
- ASSERT(reaching_frames_.is_empty());
183
- ASSERT(!cgen()->has_valid_frame());
184
-
185
- RegisterFile empty;
186
- if (direction_ == BIDIRECTIONAL) {
187
- // Copy the entry frame so the original can be used for a
188
- // possible backward jump.
189
- cgen()->SetFrame(new VirtualFrame(entry_frame_), &empty);
190
- } else {
191
- // Take ownership of the entry frame.
192
- cgen()->SetFrame(entry_frame_, &empty);
193
- entry_frame_ = NULL;
194
- }
195
- __ bind(&entry_label_);
196
- return;
197
- }
198
-
199
- if (!is_linked()) {
200
- ASSERT(cgen()->has_valid_frame());
201
- if (direction_ == FORWARD_ONLY) {
202
- // Fast case: no forward jumps and no possible backward jumps.
203
- // The stack pointer can be floating above the top of the
204
- // virtual frame before the bind. Afterward, it should not.
205
- VirtualFrame* frame = cgen()->frame();
206
- int difference = frame->stack_pointer_ - (frame->element_count() - 1);
207
- if (difference > 0) {
208
- frame->stack_pointer_ -= difference;
209
- __ addq(rsp, Immediate(difference * kPointerSize));
210
- }
211
- } else {
212
- ASSERT(direction_ == BIDIRECTIONAL);
213
- // Fast case: no forward jumps, possible backward ones. Remove
214
- // constants and copies above the watermark on the fall-through
215
- // frame and use it as the entry frame.
216
- cgen()->frame()->MakeMergable();
217
- entry_frame_ = new VirtualFrame(cgen()->frame());
218
- }
219
- __ bind(&entry_label_);
220
- return;
221
- }
222
-
223
- if (direction_ == FORWARD_ONLY &&
224
- !cgen()->has_valid_frame() &&
225
- reaching_frames_.length() == 1) {
226
- // Fast case: no fall-through, a single forward jump, and no
227
- // possible backward jumps. Pick up the only reaching frame, take
228
- // ownership of it, and use it for the block about to be emitted.
229
- VirtualFrame* frame = reaching_frames_[0];
230
- RegisterFile empty;
231
- cgen()->SetFrame(frame, &empty);
232
- reaching_frames_[0] = NULL;
233
- __ bind(&merge_labels_[0]);
234
-
235
- // The stack pointer can be floating above the top of the
236
- // virtual frame before the bind. Afterward, it should not.
237
- int difference = frame->stack_pointer_ - (frame->element_count() - 1);
238
- if (difference > 0) {
239
- frame->stack_pointer_ -= difference;
240
- __ addq(rsp, Immediate(difference * kPointerSize));
241
- }
242
-
243
- __ bind(&entry_label_);
244
- return;
245
- }
246
-
247
- // If there is a current frame, record it as the fall-through. It
248
- // is owned by the reaching frames for now.
249
- bool had_fall_through = false;
250
- if (cgen()->has_valid_frame()) {
251
- had_fall_through = true;
252
- AddReachingFrame(cgen()->frame()); // Return value ignored.
253
- RegisterFile empty;
254
- cgen()->SetFrame(NULL, &empty);
255
- }
256
-
257
- // Compute the frame to use for entry to the block.
258
- ComputeEntryFrame();
259
-
260
- // Some moves required to merge to an expected frame require purely
261
- // frame state changes, and do not require any code generation.
262
- // Perform those first to increase the possibility of finding equal
263
- // frames below.
264
- for (int i = 0; i < reaching_frames_.length(); i++) {
265
- if (reaching_frames_[i] != NULL) {
266
- reaching_frames_[i]->PrepareMergeTo(entry_frame_);
267
- }
268
- }
269
-
270
- if (is_linked()) {
271
- // There were forward jumps. Handle merging the reaching frames
272
- // to the entry frame.
273
-
274
- // Loop over the (non-null) reaching frames and process any that
275
- // need merge code. Iterate backwards through the list to handle
276
- // the fall-through frame first. Set frames that will be
277
- // processed after 'i' to NULL if we want to avoid processing
278
- // them.
279
- for (int i = reaching_frames_.length() - 1; i >= 0; i--) {
280
- VirtualFrame* frame = reaching_frames_[i];
281
-
282
- if (frame != NULL) {
283
- // Does the frame (probably) need merge code?
284
- if (!frame->Equals(entry_frame_)) {
285
- // We could have a valid frame as the fall through to the
286
- // binding site or as the fall through from a previous merge
287
- // code block. Jump around the code we are about to
288
- // generate.
289
- if (cgen()->has_valid_frame()) {
290
- cgen()->DeleteFrame();
291
- __ jmp(&entry_label_);
292
- }
293
- // Pick up the frame for this block. Assume ownership if
294
- // there cannot be backward jumps.
295
- RegisterFile empty;
296
- if (direction_ == BIDIRECTIONAL) {
297
- cgen()->SetFrame(new VirtualFrame(frame), &empty);
298
- } else {
299
- cgen()->SetFrame(frame, &empty);
300
- reaching_frames_[i] = NULL;
301
- }
302
- __ bind(&merge_labels_[i]);
303
-
304
- // Loop over the remaining (non-null) reaching frames,
305
- // looking for any that can share merge code with this one.
306
- for (int j = 0; j < i; j++) {
307
- VirtualFrame* other = reaching_frames_[j];
308
- if (other != NULL && other->Equals(cgen()->frame())) {
309
- // Set the reaching frame element to null to avoid
310
- // processing it later, and then bind its entry label.
311
- reaching_frames_[j] = NULL;
312
- __ bind(&merge_labels_[j]);
313
- }
314
- }
315
-
316
- // Emit the merge code.
317
- cgen()->frame()->MergeTo(entry_frame_);
318
- } else if (i == reaching_frames_.length() - 1 && had_fall_through) {
319
- // If this is the fall through frame, and it didn't need
320
- // merge code, we need to pick up the frame so we can jump
321
- // around subsequent merge blocks if necessary.
322
- RegisterFile empty;
323
- cgen()->SetFrame(frame, &empty);
324
- reaching_frames_[i] = NULL;
325
- }
326
- }
327
- }
328
-
329
- // The code generator may not have a current frame if there was no
330
- // fall through and none of the reaching frames needed merging.
331
- // In that case, clone the entry frame as the current frame.
332
- if (!cgen()->has_valid_frame()) {
333
- RegisterFile empty;
334
- cgen()->SetFrame(new VirtualFrame(entry_frame_), &empty);
335
- }
336
-
337
- // There may be unprocessed reaching frames that did not need
338
- // merge code. They will have unbound merge labels. Bind their
339
- // merge labels to be the same as the entry label and deallocate
340
- // them.
341
- for (int i = 0; i < reaching_frames_.length(); i++) {
342
- if (!merge_labels_[i].is_bound()) {
343
- reaching_frames_[i] = NULL;
344
- __ bind(&merge_labels_[i]);
345
- }
346
- }
347
-
348
- // There are non-NULL reaching frames with bound labels for each
349
- // merge block, but only on backward targets.
350
- } else {
351
- // There were no forward jumps. There must be a current frame and
352
- // this must be a bidirectional target.
353
- ASSERT(reaching_frames_.length() == 1);
354
- ASSERT(reaching_frames_[0] != NULL);
355
- ASSERT(direction_ == BIDIRECTIONAL);
356
-
357
- // Use a copy of the reaching frame so the original can be saved
358
- // for possible reuse as a backward merge block.
359
- RegisterFile empty;
360
- cgen()->SetFrame(new VirtualFrame(reaching_frames_[0]), &empty);
361
- __ bind(&merge_labels_[0]);
362
- cgen()->frame()->MergeTo(entry_frame_);
363
- }
364
-
365
- __ bind(&entry_label_);
366
- }
367
-
368
-
369
- void BreakTarget::Jump() {
370
- // Drop leftover statement state from the frame before merging, without
371
- // emitting code.
372
- ASSERT(cgen()->has_valid_frame());
373
- int count = cgen()->frame()->height() - expected_height_;
374
- cgen()->frame()->ForgetElements(count);
375
- DoJump();
376
- }
377
-
378
-
379
- void BreakTarget::Jump(Result* arg) {
380
- // Drop leftover statement state from the frame before merging, without
381
- // emitting code.
382
- ASSERT(cgen()->has_valid_frame());
383
- int count = cgen()->frame()->height() - expected_height_;
384
- cgen()->frame()->ForgetElements(count);
385
- cgen()->frame()->Push(arg);
386
- DoJump();
387
- }
388
-
389
-
390
- void BreakTarget::Bind() {
391
- #ifdef DEBUG
392
- // All the forward-reaching frames should have been adjusted at the
393
- // jumps to this target.
394
- for (int i = 0; i < reaching_frames_.length(); i++) {
395
- ASSERT(reaching_frames_[i] == NULL ||
396
- reaching_frames_[i]->height() == expected_height_);
397
- }
398
- #endif
399
- // Drop leftover statement state from the frame before merging, even on
400
- // the fall through. This is so we can bind the return target with state
401
- // on the frame.
402
- if (cgen()->has_valid_frame()) {
403
- int count = cgen()->frame()->height() - expected_height_;
404
- cgen()->frame()->ForgetElements(count);
405
- }
406
- DoBind();
407
- }
408
-
409
-
410
- void BreakTarget::Bind(Result* arg) {
411
- #ifdef DEBUG
412
- // All the forward-reaching frames should have been adjusted at the
413
- // jumps to this target.
414
- for (int i = 0; i < reaching_frames_.length(); i++) {
415
- ASSERT(reaching_frames_[i] == NULL ||
416
- reaching_frames_[i]->height() == expected_height_ + 1);
417
- }
418
- #endif
419
- // Drop leftover statement state from the frame before merging, even on
420
- // the fall through. This is so we can bind the return target with state
421
- // on the frame.
422
- if (cgen()->has_valid_frame()) {
423
- int count = cgen()->frame()->height() - expected_height_;
424
- cgen()->frame()->ForgetElements(count);
425
- cgen()->frame()->Push(arg);
426
- }
427
- DoBind();
428
- *arg = cgen()->frame()->Pop();
429
- }
430
-
431
-
432
- #undef __
433
-
434
-
435
- } } // namespace v8::internal
436
-
437
- #endif // V8_TARGET_ARCH_X64
@@ -1,3970 +0,0 @@
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
- #if defined(V8_TARGET_ARCH_X64)
31
-
32
- #include "x64/lithium-codegen-x64.h"
33
- #include "code-stubs.h"
34
- #include "stub-cache.h"
35
-
36
- namespace v8 {
37
- namespace internal {
38
-
39
-
40
- // When invoking builtins, we need to record the safepoint in the middle of
41
- // the invoke instruction sequence generated by the macro assembler.
42
- class SafepointGenerator : public CallWrapper {
43
- public:
44
- SafepointGenerator(LCodeGen* codegen,
45
- LPointerMap* pointers,
46
- int deoptimization_index)
47
- : codegen_(codegen),
48
- pointers_(pointers),
49
- deoptimization_index_(deoptimization_index) { }
50
- virtual ~SafepointGenerator() { }
51
-
52
- virtual void BeforeCall(int call_size) {
53
- ASSERT(call_size >= 0);
54
- // Ensure that we have enough space after the previous safepoint position
55
- // for the jump generated there.
56
- int call_end = codegen_->masm()->pc_offset() + call_size;
57
- int prev_jump_end = codegen_->LastSafepointEnd() + kMinSafepointSize;
58
- if (call_end < prev_jump_end) {
59
- int padding_size = prev_jump_end - call_end;
60
- STATIC_ASSERT(kMinSafepointSize <= 9); // One multibyte nop is enough.
61
- codegen_->masm()->nop(padding_size);
62
- }
63
- }
64
-
65
- virtual void AfterCall() {
66
- codegen_->RecordSafepoint(pointers_, deoptimization_index_);
67
- }
68
-
69
- private:
70
- static const int kMinSafepointSize =
71
- MacroAssembler::kShortCallInstructionLength;
72
- LCodeGen* codegen_;
73
- LPointerMap* pointers_;
74
- int deoptimization_index_;
75
- };
76
-
77
-
78
- #define __ masm()->
79
-
80
- bool LCodeGen::GenerateCode() {
81
- HPhase phase("Code generation", chunk());
82
- ASSERT(is_unused());
83
- status_ = GENERATING;
84
- return GeneratePrologue() &&
85
- GenerateBody() &&
86
- GenerateDeferredCode() &&
87
- GenerateJumpTable() &&
88
- GenerateSafepointTable();
89
- }
90
-
91
-
92
- void LCodeGen::FinishCode(Handle<Code> code) {
93
- ASSERT(is_done());
94
- code->set_stack_slots(StackSlotCount());
95
- code->set_safepoint_table_offset(safepoints_.GetCodeOffset());
96
- PopulateDeoptimizationData(code);
97
- Deoptimizer::EnsureRelocSpaceForLazyDeoptimization(code);
98
- }
99
-
100
-
101
- void LCodeGen::Abort(const char* format, ...) {
102
- if (FLAG_trace_bailout) {
103
- SmartPointer<char> name(info()->shared_info()->DebugName()->ToCString());
104
- PrintF("Aborting LCodeGen in @\"%s\": ", *name);
105
- va_list arguments;
106
- va_start(arguments, format);
107
- OS::VPrint(format, arguments);
108
- va_end(arguments);
109
- PrintF("\n");
110
- }
111
- status_ = ABORTED;
112
- }
113
-
114
-
115
- void LCodeGen::Comment(const char* format, ...) {
116
- if (!FLAG_code_comments) return;
117
- char buffer[4 * KB];
118
- StringBuilder builder(buffer, ARRAY_SIZE(buffer));
119
- va_list arguments;
120
- va_start(arguments, format);
121
- builder.AddFormattedList(format, arguments);
122
- va_end(arguments);
123
-
124
- // Copy the string before recording it in the assembler to avoid
125
- // issues when the stack allocated buffer goes out of scope.
126
- int length = builder.position();
127
- Vector<char> copy = Vector<char>::New(length + 1);
128
- memcpy(copy.start(), builder.Finalize(), copy.length());
129
- masm()->RecordComment(copy.start());
130
- }
131
-
132
-
133
- bool LCodeGen::GeneratePrologue() {
134
- ASSERT(is_generating());
135
-
136
- #ifdef DEBUG
137
- if (strlen(FLAG_stop_at) > 0 &&
138
- info_->function()->name()->IsEqualTo(CStrVector(FLAG_stop_at))) {
139
- __ int3();
140
- }
141
- #endif
142
-
143
- __ push(rbp); // Caller's frame pointer.
144
- __ movq(rbp, rsp);
145
- __ push(rsi); // Callee's context.
146
- __ push(rdi); // Callee's JS function.
147
-
148
- // Reserve space for the stack slots needed by the code.
149
- int slots = StackSlotCount();
150
- if (slots > 0) {
151
- if (FLAG_debug_code) {
152
- __ movl(rax, Immediate(slots));
153
- __ movq(kScratchRegister, kSlotsZapValue, RelocInfo::NONE);
154
- Label loop;
155
- __ bind(&loop);
156
- __ push(kScratchRegister);
157
- __ decl(rax);
158
- __ j(not_zero, &loop);
159
- } else {
160
- __ subq(rsp, Immediate(slots * kPointerSize));
161
- #ifdef _MSC_VER
162
- // On windows, you may not access the stack more than one page below
163
- // the most recently mapped page. To make the allocated area randomly
164
- // accessible, we write to each page in turn (the value is irrelevant).
165
- const int kPageSize = 4 * KB;
166
- for (int offset = slots * kPointerSize - kPageSize;
167
- offset > 0;
168
- offset -= kPageSize) {
169
- __ movq(Operand(rsp, offset), rax);
170
- }
171
- #endif
172
- }
173
- }
174
-
175
- // Possibly allocate a local context.
176
- int heap_slots = scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS;
177
- if (heap_slots > 0) {
178
- Comment(";;; Allocate local context");
179
- // Argument to NewContext is the function, which is still in rdi.
180
- __ push(rdi);
181
- if (heap_slots <= FastNewContextStub::kMaximumSlots) {
182
- FastNewContextStub stub(heap_slots);
183
- __ CallStub(&stub);
184
- } else {
185
- __ CallRuntime(Runtime::kNewContext, 1);
186
- }
187
- RecordSafepoint(Safepoint::kNoDeoptimizationIndex);
188
- // Context is returned in both rax and rsi. It replaces the context
189
- // passed to us. It's saved in the stack and kept live in rsi.
190
- __ movq(Operand(rbp, StandardFrameConstants::kContextOffset), rsi);
191
-
192
- // Copy any necessary parameters into the context.
193
- int num_parameters = scope()->num_parameters();
194
- for (int i = 0; i < num_parameters; i++) {
195
- Slot* slot = scope()->parameter(i)->AsSlot();
196
- if (slot != NULL && slot->type() == Slot::CONTEXT) {
197
- int parameter_offset = StandardFrameConstants::kCallerSPOffset +
198
- (num_parameters - 1 - i) * kPointerSize;
199
- // Load parameter from stack.
200
- __ movq(rax, Operand(rbp, parameter_offset));
201
- // Store it in the context.
202
- int context_offset = Context::SlotOffset(slot->index());
203
- __ movq(Operand(rsi, context_offset), rax);
204
- // Update the write barrier. This clobbers all involved
205
- // registers, so we have use a third register to avoid
206
- // clobbering rsi.
207
- __ movq(rcx, rsi);
208
- __ RecordWrite(rcx, context_offset, rax, rbx);
209
- }
210
- }
211
- Comment(";;; End allocate local context");
212
- }
213
-
214
- // Trace the call.
215
- if (FLAG_trace) {
216
- __ CallRuntime(Runtime::kTraceEnter, 0);
217
- }
218
- return !is_aborted();
219
- }
220
-
221
-
222
- bool LCodeGen::GenerateBody() {
223
- ASSERT(is_generating());
224
- bool emit_instructions = true;
225
- for (current_instruction_ = 0;
226
- !is_aborted() && current_instruction_ < instructions_->length();
227
- current_instruction_++) {
228
- LInstruction* instr = instructions_->at(current_instruction_);
229
- if (instr->IsLabel()) {
230
- LLabel* label = LLabel::cast(instr);
231
- emit_instructions = !label->HasReplacement();
232
- }
233
-
234
- if (emit_instructions) {
235
- Comment(";;; @%d: %s.", current_instruction_, instr->Mnemonic());
236
- instr->CompileToNative(this);
237
- }
238
- }
239
- return !is_aborted();
240
- }
241
-
242
-
243
- LInstruction* LCodeGen::GetNextInstruction() {
244
- if (current_instruction_ < instructions_->length() - 1) {
245
- return instructions_->at(current_instruction_ + 1);
246
- } else {
247
- return NULL;
248
- }
249
- }
250
-
251
-
252
- bool LCodeGen::GenerateJumpTable() {
253
- for (int i = 0; i < jump_table_.length(); i++) {
254
- __ bind(&jump_table_[i].label);
255
- __ Jump(jump_table_[i].address, RelocInfo::RUNTIME_ENTRY);
256
- }
257
- return !is_aborted();
258
- }
259
-
260
-
261
- bool LCodeGen::GenerateDeferredCode() {
262
- ASSERT(is_generating());
263
- for (int i = 0; !is_aborted() && i < deferred_.length(); i++) {
264
- LDeferredCode* code = deferred_[i];
265
- __ bind(code->entry());
266
- code->Generate();
267
- __ jmp(code->exit());
268
- }
269
-
270
- // Deferred code is the last part of the instruction sequence. Mark
271
- // the generated code as done unless we bailed out.
272
- if (!is_aborted()) status_ = DONE;
273
- return !is_aborted();
274
- }
275
-
276
-
277
- bool LCodeGen::GenerateSafepointTable() {
278
- ASSERT(is_done());
279
- // Ensure that there is space at the end of the code to write a number
280
- // of jump instructions, as well as to afford writing a call near the end
281
- // of the code.
282
- // The jumps are used when there isn't room in the code stream to write
283
- // a long call instruction. Instead it writes a shorter call to a
284
- // jump instruction in the same code object.
285
- // The calls are used when lazy deoptimizing a function and calls to a
286
- // deoptimization function.
287
- int short_deopts = safepoints_.CountShortDeoptimizationIntervals(
288
- static_cast<unsigned>(MacroAssembler::kJumpInstructionLength));
289
- int byte_count = (short_deopts) * MacroAssembler::kJumpInstructionLength;
290
- while (byte_count-- > 0) {
291
- __ int3();
292
- }
293
- safepoints_.Emit(masm(), StackSlotCount());
294
- return !is_aborted();
295
- }
296
-
297
-
298
- Register LCodeGen::ToRegister(int index) const {
299
- return Register::FromAllocationIndex(index);
300
- }
301
-
302
-
303
- XMMRegister LCodeGen::ToDoubleRegister(int index) const {
304
- return XMMRegister::FromAllocationIndex(index);
305
- }
306
-
307
-
308
- Register LCodeGen::ToRegister(LOperand* op) const {
309
- ASSERT(op->IsRegister());
310
- return ToRegister(op->index());
311
- }
312
-
313
-
314
- XMMRegister LCodeGen::ToDoubleRegister(LOperand* op) const {
315
- ASSERT(op->IsDoubleRegister());
316
- return ToDoubleRegister(op->index());
317
- }
318
-
319
-
320
- bool LCodeGen::IsInteger32Constant(LConstantOperand* op) const {
321
- return op->IsConstantOperand() &&
322
- chunk_->LookupLiteralRepresentation(op).IsInteger32();
323
- }
324
-
325
-
326
- bool LCodeGen::IsTaggedConstant(LConstantOperand* op) const {
327
- return op->IsConstantOperand() &&
328
- chunk_->LookupLiteralRepresentation(op).IsTagged();
329
- }
330
-
331
-
332
- int LCodeGen::ToInteger32(LConstantOperand* op) const {
333
- Handle<Object> value = chunk_->LookupLiteral(op);
334
- ASSERT(chunk_->LookupLiteralRepresentation(op).IsInteger32());
335
- ASSERT(static_cast<double>(static_cast<int32_t>(value->Number())) ==
336
- value->Number());
337
- return static_cast<int32_t>(value->Number());
338
- }
339
-
340
-
341
- Handle<Object> LCodeGen::ToHandle(LConstantOperand* op) const {
342
- Handle<Object> literal = chunk_->LookupLiteral(op);
343
- ASSERT(chunk_->LookupLiteralRepresentation(op).IsTagged());
344
- return literal;
345
- }
346
-
347
-
348
- Operand LCodeGen::ToOperand(LOperand* op) const {
349
- // Does not handle registers. In X64 assembler, plain registers are not
350
- // representable as an Operand.
351
- ASSERT(op->IsStackSlot() || op->IsDoubleStackSlot());
352
- int index = op->index();
353
- if (index >= 0) {
354
- // Local or spill slot. Skip the frame pointer, function, and
355
- // context in the fixed part of the frame.
356
- return Operand(rbp, -(index + 3) * kPointerSize);
357
- } else {
358
- // Incoming parameter. Skip the return address.
359
- return Operand(rbp, -(index - 1) * kPointerSize);
360
- }
361
- }
362
-
363
-
364
- void LCodeGen::WriteTranslation(LEnvironment* environment,
365
- Translation* translation) {
366
- if (environment == NULL) return;
367
-
368
- // The translation includes one command per value in the environment.
369
- int translation_size = environment->values()->length();
370
- // The output frame height does not include the parameters.
371
- int height = translation_size - environment->parameter_count();
372
-
373
- WriteTranslation(environment->outer(), translation);
374
- int closure_id = DefineDeoptimizationLiteral(environment->closure());
375
- translation->BeginFrame(environment->ast_id(), closure_id, height);
376
- for (int i = 0; i < translation_size; ++i) {
377
- LOperand* value = environment->values()->at(i);
378
- // spilled_registers_ and spilled_double_registers_ are either
379
- // both NULL or both set.
380
- if (environment->spilled_registers() != NULL && value != NULL) {
381
- if (value->IsRegister() &&
382
- environment->spilled_registers()[value->index()] != NULL) {
383
- translation->MarkDuplicate();
384
- AddToTranslation(translation,
385
- environment->spilled_registers()[value->index()],
386
- environment->HasTaggedValueAt(i));
387
- } else if (
388
- value->IsDoubleRegister() &&
389
- environment->spilled_double_registers()[value->index()] != NULL) {
390
- translation->MarkDuplicate();
391
- AddToTranslation(
392
- translation,
393
- environment->spilled_double_registers()[value->index()],
394
- false);
395
- }
396
- }
397
-
398
- AddToTranslation(translation, value, environment->HasTaggedValueAt(i));
399
- }
400
- }
401
-
402
-
403
- void LCodeGen::AddToTranslation(Translation* translation,
404
- LOperand* op,
405
- bool is_tagged) {
406
- if (op == NULL) {
407
- // TODO(twuerthinger): Introduce marker operands to indicate that this value
408
- // is not present and must be reconstructed from the deoptimizer. Currently
409
- // this is only used for the arguments object.
410
- translation->StoreArgumentsObject();
411
- } else if (op->IsStackSlot()) {
412
- if (is_tagged) {
413
- translation->StoreStackSlot(op->index());
414
- } else {
415
- translation->StoreInt32StackSlot(op->index());
416
- }
417
- } else if (op->IsDoubleStackSlot()) {
418
- translation->StoreDoubleStackSlot(op->index());
419
- } else if (op->IsArgument()) {
420
- ASSERT(is_tagged);
421
- int src_index = StackSlotCount() + op->index();
422
- translation->StoreStackSlot(src_index);
423
- } else if (op->IsRegister()) {
424
- Register reg = ToRegister(op);
425
- if (is_tagged) {
426
- translation->StoreRegister(reg);
427
- } else {
428
- translation->StoreInt32Register(reg);
429
- }
430
- } else if (op->IsDoubleRegister()) {
431
- XMMRegister reg = ToDoubleRegister(op);
432
- translation->StoreDoubleRegister(reg);
433
- } else if (op->IsConstantOperand()) {
434
- Handle<Object> literal = chunk()->LookupLiteral(LConstantOperand::cast(op));
435
- int src_index = DefineDeoptimizationLiteral(literal);
436
- translation->StoreLiteral(src_index);
437
- } else {
438
- UNREACHABLE();
439
- }
440
- }
441
-
442
-
443
- void LCodeGen::CallCode(Handle<Code> code,
444
- RelocInfo::Mode mode,
445
- LInstruction* instr) {
446
- ASSERT(instr != NULL);
447
- LPointerMap* pointers = instr->pointer_map();
448
- RecordPosition(pointers->position());
449
- __ call(code, mode);
450
- RegisterLazyDeoptimization(instr);
451
-
452
- // Signal that we don't inline smi code before these stubs in the
453
- // optimizing code generator.
454
- if (code->kind() == Code::TYPE_RECORDING_BINARY_OP_IC ||
455
- code->kind() == Code::COMPARE_IC) {
456
- __ nop();
457
- }
458
- }
459
-
460
-
461
- void LCodeGen::CallRuntime(const Runtime::Function* function,
462
- int num_arguments,
463
- LInstruction* instr) {
464
- ASSERT(instr != NULL);
465
- ASSERT(instr->HasPointerMap());
466
- LPointerMap* pointers = instr->pointer_map();
467
- RecordPosition(pointers->position());
468
-
469
- __ CallRuntime(function, num_arguments);
470
- RegisterLazyDeoptimization(instr);
471
- }
472
-
473
-
474
- void LCodeGen::RegisterLazyDeoptimization(LInstruction* instr) {
475
- // Create the environment to bailout to. If the call has side effects
476
- // execution has to continue after the call otherwise execution can continue
477
- // from a previous bailout point repeating the call.
478
- LEnvironment* deoptimization_environment;
479
- if (instr->HasDeoptimizationEnvironment()) {
480
- deoptimization_environment = instr->deoptimization_environment();
481
- } else {
482
- deoptimization_environment = instr->environment();
483
- }
484
-
485
- RegisterEnvironmentForDeoptimization(deoptimization_environment);
486
- RecordSafepoint(instr->pointer_map(),
487
- deoptimization_environment->deoptimization_index());
488
- }
489
-
490
-
491
- void LCodeGen::RegisterEnvironmentForDeoptimization(LEnvironment* environment) {
492
- if (!environment->HasBeenRegistered()) {
493
- // Physical stack frame layout:
494
- // -x ............. -4 0 ..................................... y
495
- // [incoming arguments] [spill slots] [pushed outgoing arguments]
496
-
497
- // Layout of the environment:
498
- // 0 ..................................................... size-1
499
- // [parameters] [locals] [expression stack including arguments]
500
-
501
- // Layout of the translation:
502
- // 0 ........................................................ size - 1 + 4
503
- // [expression stack including arguments] [locals] [4 words] [parameters]
504
- // |>------------ translation_size ------------<|
505
-
506
- int frame_count = 0;
507
- for (LEnvironment* e = environment; e != NULL; e = e->outer()) {
508
- ++frame_count;
509
- }
510
- Translation translation(&translations_, frame_count);
511
- WriteTranslation(environment, &translation);
512
- int deoptimization_index = deoptimizations_.length();
513
- environment->Register(deoptimization_index, translation.index());
514
- deoptimizations_.Add(environment);
515
- }
516
- }
517
-
518
-
519
- void LCodeGen::DeoptimizeIf(Condition cc, LEnvironment* environment) {
520
- RegisterEnvironmentForDeoptimization(environment);
521
- ASSERT(environment->HasBeenRegistered());
522
- int id = environment->deoptimization_index();
523
- Address entry = Deoptimizer::GetDeoptimizationEntry(id, Deoptimizer::EAGER);
524
- ASSERT(entry != NULL);
525
- if (entry == NULL) {
526
- Abort("bailout was not prepared");
527
- return;
528
- }
529
-
530
- if (cc == no_condition) {
531
- __ Jump(entry, RelocInfo::RUNTIME_ENTRY);
532
- } else {
533
- // We often have several deopts to the same entry, reuse the last
534
- // jump entry if this is the case.
535
- if (jump_table_.is_empty() ||
536
- jump_table_.last().address != entry) {
537
- jump_table_.Add(entry);
538
- }
539
- __ j(cc, &jump_table_.last().label);
540
- }
541
- }
542
-
543
-
544
- void LCodeGen::PopulateDeoptimizationData(Handle<Code> code) {
545
- int length = deoptimizations_.length();
546
- if (length == 0) return;
547
- ASSERT(FLAG_deopt);
548
- Handle<DeoptimizationInputData> data =
549
- factory()->NewDeoptimizationInputData(length, TENURED);
550
-
551
- Handle<ByteArray> translations = translations_.CreateByteArray();
552
- data->SetTranslationByteArray(*translations);
553
- data->SetInlinedFunctionCount(Smi::FromInt(inlined_function_count_));
554
-
555
- Handle<FixedArray> literals =
556
- factory()->NewFixedArray(deoptimization_literals_.length(), TENURED);
557
- for (int i = 0; i < deoptimization_literals_.length(); i++) {
558
- literals->set(i, *deoptimization_literals_[i]);
559
- }
560
- data->SetLiteralArray(*literals);
561
-
562
- data->SetOsrAstId(Smi::FromInt(info_->osr_ast_id()));
563
- data->SetOsrPcOffset(Smi::FromInt(osr_pc_offset_));
564
-
565
- // Populate the deoptimization entries.
566
- for (int i = 0; i < length; i++) {
567
- LEnvironment* env = deoptimizations_[i];
568
- data->SetAstId(i, Smi::FromInt(env->ast_id()));
569
- data->SetTranslationIndex(i, Smi::FromInt(env->translation_index()));
570
- data->SetArgumentsStackHeight(i,
571
- Smi::FromInt(env->arguments_stack_height()));
572
- }
573
- code->set_deoptimization_data(*data);
574
- }
575
-
576
-
577
- int LCodeGen::DefineDeoptimizationLiteral(Handle<Object> literal) {
578
- int result = deoptimization_literals_.length();
579
- for (int i = 0; i < deoptimization_literals_.length(); ++i) {
580
- if (deoptimization_literals_[i].is_identical_to(literal)) return i;
581
- }
582
- deoptimization_literals_.Add(literal);
583
- return result;
584
- }
585
-
586
-
587
- void LCodeGen::PopulateDeoptimizationLiteralsWithInlinedFunctions() {
588
- ASSERT(deoptimization_literals_.length() == 0);
589
-
590
- const ZoneList<Handle<JSFunction> >* inlined_closures =
591
- chunk()->inlined_closures();
592
-
593
- for (int i = 0, length = inlined_closures->length();
594
- i < length;
595
- i++) {
596
- DefineDeoptimizationLiteral(inlined_closures->at(i));
597
- }
598
-
599
- inlined_function_count_ = deoptimization_literals_.length();
600
- }
601
-
602
-
603
- void LCodeGen::RecordSafepoint(
604
- LPointerMap* pointers,
605
- Safepoint::Kind kind,
606
- int arguments,
607
- int deoptimization_index) {
608
- const ZoneList<LOperand*>* operands = pointers->operands();
609
-
610
- Safepoint safepoint = safepoints_.DefineSafepoint(masm(),
611
- kind, arguments, deoptimization_index);
612
- for (int i = 0; i < operands->length(); i++) {
613
- LOperand* pointer = operands->at(i);
614
- if (pointer->IsStackSlot()) {
615
- safepoint.DefinePointerSlot(pointer->index());
616
- } else if (pointer->IsRegister() && (kind & Safepoint::kWithRegisters)) {
617
- safepoint.DefinePointerRegister(ToRegister(pointer));
618
- }
619
- }
620
- if (kind & Safepoint::kWithRegisters) {
621
- // Register rsi always contains a pointer to the context.
622
- safepoint.DefinePointerRegister(rsi);
623
- }
624
- }
625
-
626
-
627
- void LCodeGen::RecordSafepoint(LPointerMap* pointers,
628
- int deoptimization_index) {
629
- RecordSafepoint(pointers, Safepoint::kSimple, 0, deoptimization_index);
630
- }
631
-
632
-
633
- void LCodeGen::RecordSafepoint(int deoptimization_index) {
634
- LPointerMap empty_pointers(RelocInfo::kNoPosition);
635
- RecordSafepoint(&empty_pointers, deoptimization_index);
636
- }
637
-
638
-
639
- void LCodeGen::RecordSafepointWithRegisters(LPointerMap* pointers,
640
- int arguments,
641
- int deoptimization_index) {
642
- RecordSafepoint(pointers, Safepoint::kWithRegisters, arguments,
643
- deoptimization_index);
644
- }
645
-
646
-
647
- void LCodeGen::RecordPosition(int position) {
648
- if (!FLAG_debug_info || position == RelocInfo::kNoPosition) return;
649
- masm()->positions_recorder()->RecordPosition(position);
650
- }
651
-
652
-
653
- void LCodeGen::DoLabel(LLabel* label) {
654
- if (label->is_loop_header()) {
655
- Comment(";;; B%d - LOOP entry", label->block_id());
656
- } else {
657
- Comment(";;; B%d", label->block_id());
658
- }
659
- __ bind(label->label());
660
- current_block_ = label->block_id();
661
- LCodeGen::DoGap(label);
662
- }
663
-
664
-
665
- void LCodeGen::DoParallelMove(LParallelMove* move) {
666
- resolver_.Resolve(move);
667
- }
668
-
669
-
670
- void LCodeGen::DoGap(LGap* gap) {
671
- for (int i = LGap::FIRST_INNER_POSITION;
672
- i <= LGap::LAST_INNER_POSITION;
673
- i++) {
674
- LGap::InnerPosition inner_pos = static_cast<LGap::InnerPosition>(i);
675
- LParallelMove* move = gap->GetParallelMove(inner_pos);
676
- if (move != NULL) DoParallelMove(move);
677
- }
678
-
679
- LInstruction* next = GetNextInstruction();
680
- if (next != NULL && next->IsLazyBailout()) {
681
- int pc = masm()->pc_offset();
682
- safepoints_.SetPcAfterGap(pc);
683
- }
684
- }
685
-
686
-
687
- void LCodeGen::DoParameter(LParameter* instr) {
688
- // Nothing to do.
689
- }
690
-
691
-
692
- void LCodeGen::DoCallStub(LCallStub* instr) {
693
- ASSERT(ToRegister(instr->result()).is(rax));
694
- switch (instr->hydrogen()->major_key()) {
695
- case CodeStub::RegExpConstructResult: {
696
- RegExpConstructResultStub stub;
697
- CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
698
- break;
699
- }
700
- case CodeStub::RegExpExec: {
701
- RegExpExecStub stub;
702
- CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
703
- break;
704
- }
705
- case CodeStub::SubString: {
706
- SubStringStub stub;
707
- CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
708
- break;
709
- }
710
- case CodeStub::NumberToString: {
711
- NumberToStringStub stub;
712
- CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
713
- break;
714
- }
715
- case CodeStub::StringAdd: {
716
- StringAddStub stub(NO_STRING_ADD_FLAGS);
717
- CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
718
- break;
719
- }
720
- case CodeStub::StringCompare: {
721
- StringCompareStub stub;
722
- CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
723
- break;
724
- }
725
- case CodeStub::TranscendentalCache: {
726
- TranscendentalCacheStub stub(instr->transcendental_type(),
727
- TranscendentalCacheStub::TAGGED);
728
- CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
729
- break;
730
- }
731
- default:
732
- UNREACHABLE();
733
- }
734
- }
735
-
736
-
737
- void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) {
738
- // Nothing to do.
739
- }
740
-
741
-
742
- void LCodeGen::DoModI(LModI* instr) {
743
- if (instr->hydrogen()->HasPowerOf2Divisor()) {
744
- Register dividend = ToRegister(instr->InputAt(0));
745
-
746
- int32_t divisor =
747
- HConstant::cast(instr->hydrogen()->right())->Integer32Value();
748
-
749
- if (divisor < 0) divisor = -divisor;
750
-
751
- NearLabel positive_dividend, done;
752
- __ testl(dividend, dividend);
753
- __ j(not_sign, &positive_dividend);
754
- __ negl(dividend);
755
- __ andl(dividend, Immediate(divisor - 1));
756
- __ negl(dividend);
757
- if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
758
- __ j(not_zero, &done);
759
- DeoptimizeIf(no_condition, instr->environment());
760
- }
761
- __ bind(&positive_dividend);
762
- __ andl(dividend, Immediate(divisor - 1));
763
- __ bind(&done);
764
- } else {
765
- LOperand* right = instr->InputAt(1);
766
- Register right_reg = ToRegister(right);
767
-
768
- ASSERT(ToRegister(instr->result()).is(rdx));
769
- ASSERT(ToRegister(instr->InputAt(0)).is(rax));
770
- ASSERT(!right_reg.is(rax));
771
- ASSERT(!right_reg.is(rdx));
772
-
773
- // Check for x % 0.
774
- if (instr->hydrogen()->CheckFlag(HValue::kCanBeDivByZero)) {
775
- __ testl(right_reg, right_reg);
776
- DeoptimizeIf(zero, instr->environment());
777
- }
778
-
779
- // Sign extend eax to edx.
780
- // (We are using only the low 32 bits of the values.)
781
- __ cdq();
782
-
783
- // Check for (0 % -x) that will produce negative zero.
784
- if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
785
- NearLabel positive_left;
786
- NearLabel done;
787
- __ testl(rax, rax);
788
- __ j(not_sign, &positive_left);
789
- __ idivl(right_reg);
790
-
791
- // Test the remainder for 0, because then the result would be -0.
792
- __ testl(rdx, rdx);
793
- __ j(not_zero, &done);
794
-
795
- DeoptimizeIf(no_condition, instr->environment());
796
- __ bind(&positive_left);
797
- __ idivl(right_reg);
798
- __ bind(&done);
799
- } else {
800
- __ idivl(right_reg);
801
- }
802
- }
803
- }
804
-
805
-
806
- void LCodeGen::DoDivI(LDivI* instr) {
807
- LOperand* right = instr->InputAt(1);
808
- ASSERT(ToRegister(instr->result()).is(rax));
809
- ASSERT(ToRegister(instr->InputAt(0)).is(rax));
810
- ASSERT(!ToRegister(instr->InputAt(1)).is(rax));
811
- ASSERT(!ToRegister(instr->InputAt(1)).is(rdx));
812
-
813
- Register left_reg = rax;
814
-
815
- // Check for x / 0.
816
- Register right_reg = ToRegister(right);
817
- if (instr->hydrogen()->CheckFlag(HValue::kCanBeDivByZero)) {
818
- __ testl(right_reg, right_reg);
819
- DeoptimizeIf(zero, instr->environment());
820
- }
821
-
822
- // Check for (0 / -x) that will produce negative zero.
823
- if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
824
- NearLabel left_not_zero;
825
- __ testl(left_reg, left_reg);
826
- __ j(not_zero, &left_not_zero);
827
- __ testl(right_reg, right_reg);
828
- DeoptimizeIf(sign, instr->environment());
829
- __ bind(&left_not_zero);
830
- }
831
-
832
- // Check for (-kMinInt / -1).
833
- if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) {
834
- NearLabel left_not_min_int;
835
- __ cmpl(left_reg, Immediate(kMinInt));
836
- __ j(not_zero, &left_not_min_int);
837
- __ cmpl(right_reg, Immediate(-1));
838
- DeoptimizeIf(zero, instr->environment());
839
- __ bind(&left_not_min_int);
840
- }
841
-
842
- // Sign extend to rdx.
843
- __ cdq();
844
- __ idivl(right_reg);
845
-
846
- // Deoptimize if remainder is not 0.
847
- __ testl(rdx, rdx);
848
- DeoptimizeIf(not_zero, instr->environment());
849
- }
850
-
851
-
852
- void LCodeGen::DoMulI(LMulI* instr) {
853
- Register left = ToRegister(instr->InputAt(0));
854
- LOperand* right = instr->InputAt(1);
855
-
856
- if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
857
- __ movl(kScratchRegister, left);
858
- }
859
-
860
- bool can_overflow =
861
- instr->hydrogen()->CheckFlag(HValue::kCanOverflow);
862
- if (right->IsConstantOperand()) {
863
- int right_value = ToInteger32(LConstantOperand::cast(right));
864
- if (right_value == -1) {
865
- __ negl(left);
866
- } else if (right_value == 0) {
867
- __ xorl(left, left);
868
- } else if (right_value == 2) {
869
- __ addl(left, left);
870
- } else if (!can_overflow) {
871
- // If the multiplication is known to not overflow, we
872
- // can use operations that don't set the overflow flag
873
- // correctly.
874
- switch (right_value) {
875
- case 1:
876
- // Do nothing.
877
- break;
878
- case 3:
879
- __ leal(left, Operand(left, left, times_2, 0));
880
- break;
881
- case 4:
882
- __ shll(left, Immediate(2));
883
- break;
884
- case 5:
885
- __ leal(left, Operand(left, left, times_4, 0));
886
- break;
887
- case 8:
888
- __ shll(left, Immediate(3));
889
- break;
890
- case 9:
891
- __ leal(left, Operand(left, left, times_8, 0));
892
- break;
893
- case 16:
894
- __ shll(left, Immediate(4));
895
- break;
896
- default:
897
- __ imull(left, left, Immediate(right_value));
898
- break;
899
- }
900
- } else {
901
- __ imull(left, left, Immediate(right_value));
902
- }
903
- } else if (right->IsStackSlot()) {
904
- __ imull(left, ToOperand(right));
905
- } else {
906
- __ imull(left, ToRegister(right));
907
- }
908
-
909
- if (can_overflow) {
910
- DeoptimizeIf(overflow, instr->environment());
911
- }
912
-
913
- if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
914
- // Bail out if the result is supposed to be negative zero.
915
- NearLabel done;
916
- __ testl(left, left);
917
- __ j(not_zero, &done);
918
- if (right->IsConstantOperand()) {
919
- if (ToInteger32(LConstantOperand::cast(right)) <= 0) {
920
- DeoptimizeIf(no_condition, instr->environment());
921
- }
922
- } else if (right->IsStackSlot()) {
923
- __ or_(kScratchRegister, ToOperand(right));
924
- DeoptimizeIf(sign, instr->environment());
925
- } else {
926
- // Test the non-zero operand for negative sign.
927
- __ or_(kScratchRegister, ToRegister(right));
928
- DeoptimizeIf(sign, instr->environment());
929
- }
930
- __ bind(&done);
931
- }
932
- }
933
-
934
-
935
- void LCodeGen::DoBitI(LBitI* instr) {
936
- LOperand* left = instr->InputAt(0);
937
- LOperand* right = instr->InputAt(1);
938
- ASSERT(left->Equals(instr->result()));
939
- ASSERT(left->IsRegister());
940
-
941
- if (right->IsConstantOperand()) {
942
- int right_operand = ToInteger32(LConstantOperand::cast(right));
943
- switch (instr->op()) {
944
- case Token::BIT_AND:
945
- __ andl(ToRegister(left), Immediate(right_operand));
946
- break;
947
- case Token::BIT_OR:
948
- __ orl(ToRegister(left), Immediate(right_operand));
949
- break;
950
- case Token::BIT_XOR:
951
- __ xorl(ToRegister(left), Immediate(right_operand));
952
- break;
953
- default:
954
- UNREACHABLE();
955
- break;
956
- }
957
- } else if (right->IsStackSlot()) {
958
- switch (instr->op()) {
959
- case Token::BIT_AND:
960
- __ andl(ToRegister(left), ToOperand(right));
961
- break;
962
- case Token::BIT_OR:
963
- __ orl(ToRegister(left), ToOperand(right));
964
- break;
965
- case Token::BIT_XOR:
966
- __ xorl(ToRegister(left), ToOperand(right));
967
- break;
968
- default:
969
- UNREACHABLE();
970
- break;
971
- }
972
- } else {
973
- ASSERT(right->IsRegister());
974
- switch (instr->op()) {
975
- case Token::BIT_AND:
976
- __ andl(ToRegister(left), ToRegister(right));
977
- break;
978
- case Token::BIT_OR:
979
- __ orl(ToRegister(left), ToRegister(right));
980
- break;
981
- case Token::BIT_XOR:
982
- __ xorl(ToRegister(left), ToRegister(right));
983
- break;
984
- default:
985
- UNREACHABLE();
986
- break;
987
- }
988
- }
989
- }
990
-
991
-
992
- void LCodeGen::DoShiftI(LShiftI* instr) {
993
- LOperand* left = instr->InputAt(0);
994
- LOperand* right = instr->InputAt(1);
995
- ASSERT(left->Equals(instr->result()));
996
- ASSERT(left->IsRegister());
997
- if (right->IsRegister()) {
998
- ASSERT(ToRegister(right).is(rcx));
999
-
1000
- switch (instr->op()) {
1001
- case Token::SAR:
1002
- __ sarl_cl(ToRegister(left));
1003
- break;
1004
- case Token::SHR:
1005
- __ shrl_cl(ToRegister(left));
1006
- if (instr->can_deopt()) {
1007
- __ testl(ToRegister(left), ToRegister(left));
1008
- DeoptimizeIf(negative, instr->environment());
1009
- }
1010
- break;
1011
- case Token::SHL:
1012
- __ shll_cl(ToRegister(left));
1013
- break;
1014
- default:
1015
- UNREACHABLE();
1016
- break;
1017
- }
1018
- } else {
1019
- int value = ToInteger32(LConstantOperand::cast(right));
1020
- uint8_t shift_count = static_cast<uint8_t>(value & 0x1F);
1021
- switch (instr->op()) {
1022
- case Token::SAR:
1023
- if (shift_count != 0) {
1024
- __ sarl(ToRegister(left), Immediate(shift_count));
1025
- }
1026
- break;
1027
- case Token::SHR:
1028
- if (shift_count == 0 && instr->can_deopt()) {
1029
- __ testl(ToRegister(left), ToRegister(left));
1030
- DeoptimizeIf(negative, instr->environment());
1031
- } else {
1032
- __ shrl(ToRegister(left), Immediate(shift_count));
1033
- }
1034
- break;
1035
- case Token::SHL:
1036
- if (shift_count != 0) {
1037
- __ shll(ToRegister(left), Immediate(shift_count));
1038
- }
1039
- break;
1040
- default:
1041
- UNREACHABLE();
1042
- break;
1043
- }
1044
- }
1045
- }
1046
-
1047
-
1048
- void LCodeGen::DoSubI(LSubI* instr) {
1049
- LOperand* left = instr->InputAt(0);
1050
- LOperand* right = instr->InputAt(1);
1051
- ASSERT(left->Equals(instr->result()));
1052
-
1053
- if (right->IsConstantOperand()) {
1054
- __ subl(ToRegister(left),
1055
- Immediate(ToInteger32(LConstantOperand::cast(right))));
1056
- } else if (right->IsRegister()) {
1057
- __ subl(ToRegister(left), ToRegister(right));
1058
- } else {
1059
- __ subl(ToRegister(left), ToOperand(right));
1060
- }
1061
-
1062
- if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) {
1063
- DeoptimizeIf(overflow, instr->environment());
1064
- }
1065
- }
1066
-
1067
-
1068
- void LCodeGen::DoConstantI(LConstantI* instr) {
1069
- ASSERT(instr->result()->IsRegister());
1070
- __ movl(ToRegister(instr->result()), Immediate(instr->value()));
1071
- }
1072
-
1073
-
1074
- void LCodeGen::DoConstantD(LConstantD* instr) {
1075
- ASSERT(instr->result()->IsDoubleRegister());
1076
- XMMRegister res = ToDoubleRegister(instr->result());
1077
- double v = instr->value();
1078
- uint64_t int_val = BitCast<uint64_t, double>(v);
1079
- // Use xor to produce +0.0 in a fast and compact way, but avoid to
1080
- // do so if the constant is -0.0.
1081
- if (int_val == 0) {
1082
- __ xorpd(res, res);
1083
- } else {
1084
- Register tmp = ToRegister(instr->TempAt(0));
1085
- __ Set(tmp, int_val);
1086
- __ movq(res, tmp);
1087
- }
1088
- }
1089
-
1090
-
1091
- void LCodeGen::DoConstantT(LConstantT* instr) {
1092
- ASSERT(instr->result()->IsRegister());
1093
- __ Move(ToRegister(instr->result()), instr->value());
1094
- }
1095
-
1096
-
1097
- void LCodeGen::DoJSArrayLength(LJSArrayLength* instr) {
1098
- Register result = ToRegister(instr->result());
1099
- Register array = ToRegister(instr->InputAt(0));
1100
- __ movq(result, FieldOperand(array, JSArray::kLengthOffset));
1101
- }
1102
-
1103
-
1104
- void LCodeGen::DoFixedArrayLength(LFixedArrayLength* instr) {
1105
- Register result = ToRegister(instr->result());
1106
- Register array = ToRegister(instr->InputAt(0));
1107
- __ movq(result, FieldOperand(array, FixedArray::kLengthOffset));
1108
- }
1109
-
1110
-
1111
- void LCodeGen::DoExternalArrayLength(LExternalArrayLength* instr) {
1112
- Register result = ToRegister(instr->result());
1113
- Register array = ToRegister(instr->InputAt(0));
1114
- __ movl(result, FieldOperand(array, ExternalPixelArray::kLengthOffset));
1115
- }
1116
-
1117
-
1118
- void LCodeGen::DoValueOf(LValueOf* instr) {
1119
- Register input = ToRegister(instr->InputAt(0));
1120
- Register result = ToRegister(instr->result());
1121
- ASSERT(input.is(result));
1122
- NearLabel done;
1123
- // If the object is a smi return the object.
1124
- __ JumpIfSmi(input, &done);
1125
-
1126
- // If the object is not a value type, return the object.
1127
- __ CmpObjectType(input, JS_VALUE_TYPE, kScratchRegister);
1128
- __ j(not_equal, &done);
1129
- __ movq(result, FieldOperand(input, JSValue::kValueOffset));
1130
-
1131
- __ bind(&done);
1132
- }
1133
-
1134
-
1135
- void LCodeGen::DoBitNotI(LBitNotI* instr) {
1136
- LOperand* input = instr->InputAt(0);
1137
- ASSERT(input->Equals(instr->result()));
1138
- __ not_(ToRegister(input));
1139
- }
1140
-
1141
-
1142
- void LCodeGen::DoThrow(LThrow* instr) {
1143
- __ push(ToRegister(instr->InputAt(0)));
1144
- CallRuntime(Runtime::kThrow, 1, instr);
1145
-
1146
- if (FLAG_debug_code) {
1147
- Comment("Unreachable code.");
1148
- __ int3();
1149
- }
1150
- }
1151
-
1152
-
1153
- void LCodeGen::DoAddI(LAddI* instr) {
1154
- LOperand* left = instr->InputAt(0);
1155
- LOperand* right = instr->InputAt(1);
1156
- ASSERT(left->Equals(instr->result()));
1157
-
1158
- if (right->IsConstantOperand()) {
1159
- __ addl(ToRegister(left),
1160
- Immediate(ToInteger32(LConstantOperand::cast(right))));
1161
- } else if (right->IsRegister()) {
1162
- __ addl(ToRegister(left), ToRegister(right));
1163
- } else {
1164
- __ addl(ToRegister(left), ToOperand(right));
1165
- }
1166
-
1167
- if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) {
1168
- DeoptimizeIf(overflow, instr->environment());
1169
- }
1170
- }
1171
-
1172
-
1173
- void LCodeGen::DoArithmeticD(LArithmeticD* instr) {
1174
- XMMRegister left = ToDoubleRegister(instr->InputAt(0));
1175
- XMMRegister right = ToDoubleRegister(instr->InputAt(1));
1176
- XMMRegister result = ToDoubleRegister(instr->result());
1177
- // All operations except MOD are computed in-place.
1178
- ASSERT(instr->op() == Token::MOD || left.is(result));
1179
- switch (instr->op()) {
1180
- case Token::ADD:
1181
- __ addsd(left, right);
1182
- break;
1183
- case Token::SUB:
1184
- __ subsd(left, right);
1185
- break;
1186
- case Token::MUL:
1187
- __ mulsd(left, right);
1188
- break;
1189
- case Token::DIV:
1190
- __ divsd(left, right);
1191
- break;
1192
- case Token::MOD:
1193
- __ PrepareCallCFunction(2);
1194
- __ movsd(xmm0, left);
1195
- ASSERT(right.is(xmm1));
1196
- __ CallCFunction(
1197
- ExternalReference::double_fp_operation(Token::MOD, isolate()), 2);
1198
- __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
1199
- __ movsd(result, xmm0);
1200
- break;
1201
- default:
1202
- UNREACHABLE();
1203
- break;
1204
- }
1205
- }
1206
-
1207
-
1208
- void LCodeGen::DoArithmeticT(LArithmeticT* instr) {
1209
- ASSERT(ToRegister(instr->InputAt(0)).is(rdx));
1210
- ASSERT(ToRegister(instr->InputAt(1)).is(rax));
1211
- ASSERT(ToRegister(instr->result()).is(rax));
1212
-
1213
- TypeRecordingBinaryOpStub stub(instr->op(), NO_OVERWRITE);
1214
- CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
1215
- }
1216
-
1217
-
1218
- int LCodeGen::GetNextEmittedBlock(int block) {
1219
- for (int i = block + 1; i < graph()->blocks()->length(); ++i) {
1220
- LLabel* label = chunk_->GetLabel(i);
1221
- if (!label->HasReplacement()) return i;
1222
- }
1223
- return -1;
1224
- }
1225
-
1226
-
1227
- void LCodeGen::EmitBranch(int left_block, int right_block, Condition cc) {
1228
- int next_block = GetNextEmittedBlock(current_block_);
1229
- right_block = chunk_->LookupDestination(right_block);
1230
- left_block = chunk_->LookupDestination(left_block);
1231
-
1232
- if (right_block == left_block) {
1233
- EmitGoto(left_block);
1234
- } else if (left_block == next_block) {
1235
- __ j(NegateCondition(cc), chunk_->GetAssemblyLabel(right_block));
1236
- } else if (right_block == next_block) {
1237
- __ j(cc, chunk_->GetAssemblyLabel(left_block));
1238
- } else {
1239
- __ j(cc, chunk_->GetAssemblyLabel(left_block));
1240
- if (cc != always) {
1241
- __ jmp(chunk_->GetAssemblyLabel(right_block));
1242
- }
1243
- }
1244
- }
1245
-
1246
-
1247
- void LCodeGen::DoBranch(LBranch* instr) {
1248
- int true_block = chunk_->LookupDestination(instr->true_block_id());
1249
- int false_block = chunk_->LookupDestination(instr->false_block_id());
1250
-
1251
- Representation r = instr->hydrogen()->representation();
1252
- if (r.IsInteger32()) {
1253
- Register reg = ToRegister(instr->InputAt(0));
1254
- __ testl(reg, reg);
1255
- EmitBranch(true_block, false_block, not_zero);
1256
- } else if (r.IsDouble()) {
1257
- XMMRegister reg = ToDoubleRegister(instr->InputAt(0));
1258
- __ xorpd(xmm0, xmm0);
1259
- __ ucomisd(reg, xmm0);
1260
- EmitBranch(true_block, false_block, not_equal);
1261
- } else {
1262
- ASSERT(r.IsTagged());
1263
- Register reg = ToRegister(instr->InputAt(0));
1264
- HType type = instr->hydrogen()->type();
1265
- if (type.IsBoolean()) {
1266
- __ CompareRoot(reg, Heap::kTrueValueRootIndex);
1267
- EmitBranch(true_block, false_block, equal);
1268
- } else if (type.IsSmi()) {
1269
- __ SmiCompare(reg, Smi::FromInt(0));
1270
- EmitBranch(true_block, false_block, not_equal);
1271
- } else {
1272
- Label* true_label = chunk_->GetAssemblyLabel(true_block);
1273
- Label* false_label = chunk_->GetAssemblyLabel(false_block);
1274
-
1275
- __ CompareRoot(reg, Heap::kUndefinedValueRootIndex);
1276
- __ j(equal, false_label);
1277
- __ CompareRoot(reg, Heap::kTrueValueRootIndex);
1278
- __ j(equal, true_label);
1279
- __ CompareRoot(reg, Heap::kFalseValueRootIndex);
1280
- __ j(equal, false_label);
1281
- __ Cmp(reg, Smi::FromInt(0));
1282
- __ j(equal, false_label);
1283
- __ JumpIfSmi(reg, true_label);
1284
-
1285
- // Test for double values. Plus/minus zero and NaN are false.
1286
- NearLabel call_stub;
1287
- __ CompareRoot(FieldOperand(reg, HeapObject::kMapOffset),
1288
- Heap::kHeapNumberMapRootIndex);
1289
- __ j(not_equal, &call_stub);
1290
-
1291
- // HeapNumber => false iff +0, -0, or NaN. These three cases set the
1292
- // zero flag when compared to zero using ucomisd.
1293
- __ xorpd(xmm0, xmm0);
1294
- __ ucomisd(xmm0, FieldOperand(reg, HeapNumber::kValueOffset));
1295
- __ j(zero, false_label);
1296
- __ jmp(true_label);
1297
-
1298
- // The conversion stub doesn't cause garbage collections so it's
1299
- // safe to not record a safepoint after the call.
1300
- __ bind(&call_stub);
1301
- ToBooleanStub stub;
1302
- __ Pushad();
1303
- __ push(reg);
1304
- __ CallStub(&stub);
1305
- __ testq(rax, rax);
1306
- __ Popad();
1307
- EmitBranch(true_block, false_block, not_zero);
1308
- }
1309
- }
1310
- }
1311
-
1312
-
1313
- void LCodeGen::EmitGoto(int block, LDeferredCode* deferred_stack_check) {
1314
- block = chunk_->LookupDestination(block);
1315
- int next_block = GetNextEmittedBlock(current_block_);
1316
- if (block != next_block) {
1317
- // Perform stack overflow check if this goto needs it before jumping.
1318
- if (deferred_stack_check != NULL) {
1319
- __ CompareRoot(rsp, Heap::kStackLimitRootIndex);
1320
- __ j(above_equal, chunk_->GetAssemblyLabel(block));
1321
- __ jmp(deferred_stack_check->entry());
1322
- deferred_stack_check->SetExit(chunk_->GetAssemblyLabel(block));
1323
- } else {
1324
- __ jmp(chunk_->GetAssemblyLabel(block));
1325
- }
1326
- }
1327
- }
1328
-
1329
-
1330
- void LCodeGen::DoDeferredStackCheck(LGoto* instr) {
1331
- __ Pushad();
1332
- __ CallRuntimeSaveDoubles(Runtime::kStackGuard);
1333
- RecordSafepointWithRegisters(
1334
- instr->pointer_map(), 0, Safepoint::kNoDeoptimizationIndex);
1335
- __ Popad();
1336
- }
1337
-
1338
-
1339
- void LCodeGen::DoGoto(LGoto* instr) {
1340
- class DeferredStackCheck: public LDeferredCode {
1341
- public:
1342
- DeferredStackCheck(LCodeGen* codegen, LGoto* instr)
1343
- : LDeferredCode(codegen), instr_(instr) { }
1344
- virtual void Generate() { codegen()->DoDeferredStackCheck(instr_); }
1345
- private:
1346
- LGoto* instr_;
1347
- };
1348
-
1349
- DeferredStackCheck* deferred = NULL;
1350
- if (instr->include_stack_check()) {
1351
- deferred = new DeferredStackCheck(this, instr);
1352
- }
1353
- EmitGoto(instr->block_id(), deferred);
1354
- }
1355
-
1356
-
1357
- inline Condition LCodeGen::TokenToCondition(Token::Value op, bool is_unsigned) {
1358
- Condition cond = no_condition;
1359
- switch (op) {
1360
- case Token::EQ:
1361
- case Token::EQ_STRICT:
1362
- cond = equal;
1363
- break;
1364
- case Token::LT:
1365
- cond = is_unsigned ? below : less;
1366
- break;
1367
- case Token::GT:
1368
- cond = is_unsigned ? above : greater;
1369
- break;
1370
- case Token::LTE:
1371
- cond = is_unsigned ? below_equal : less_equal;
1372
- break;
1373
- case Token::GTE:
1374
- cond = is_unsigned ? above_equal : greater_equal;
1375
- break;
1376
- case Token::IN:
1377
- case Token::INSTANCEOF:
1378
- default:
1379
- UNREACHABLE();
1380
- }
1381
- return cond;
1382
- }
1383
-
1384
-
1385
- void LCodeGen::EmitCmpI(LOperand* left, LOperand* right) {
1386
- if (right->IsConstantOperand()) {
1387
- int32_t value = ToInteger32(LConstantOperand::cast(right));
1388
- if (left->IsRegister()) {
1389
- __ cmpl(ToRegister(left), Immediate(value));
1390
- } else {
1391
- __ cmpl(ToOperand(left), Immediate(value));
1392
- }
1393
- } else if (right->IsRegister()) {
1394
- __ cmpl(ToRegister(left), ToRegister(right));
1395
- } else {
1396
- __ cmpl(ToRegister(left), ToOperand(right));
1397
- }
1398
- }
1399
-
1400
-
1401
- void LCodeGen::DoCmpID(LCmpID* instr) {
1402
- LOperand* left = instr->InputAt(0);
1403
- LOperand* right = instr->InputAt(1);
1404
- LOperand* result = instr->result();
1405
-
1406
- NearLabel unordered;
1407
- if (instr->is_double()) {
1408
- // Don't base result on EFLAGS when a NaN is involved. Instead
1409
- // jump to the unordered case, which produces a false value.
1410
- __ ucomisd(ToDoubleRegister(left), ToDoubleRegister(right));
1411
- __ j(parity_even, &unordered);
1412
- } else {
1413
- EmitCmpI(left, right);
1414
- }
1415
-
1416
- NearLabel done;
1417
- Condition cc = TokenToCondition(instr->op(), instr->is_double());
1418
- __ LoadRoot(ToRegister(result), Heap::kTrueValueRootIndex);
1419
- __ j(cc, &done);
1420
-
1421
- __ bind(&unordered);
1422
- __ LoadRoot(ToRegister(result), Heap::kFalseValueRootIndex);
1423
- __ bind(&done);
1424
- }
1425
-
1426
-
1427
- void LCodeGen::DoCmpIDAndBranch(LCmpIDAndBranch* instr) {
1428
- LOperand* left = instr->InputAt(0);
1429
- LOperand* right = instr->InputAt(1);
1430
- int false_block = chunk_->LookupDestination(instr->false_block_id());
1431
- int true_block = chunk_->LookupDestination(instr->true_block_id());
1432
-
1433
- if (instr->is_double()) {
1434
- // Don't base result on EFLAGS when a NaN is involved. Instead
1435
- // jump to the false block.
1436
- __ ucomisd(ToDoubleRegister(left), ToDoubleRegister(right));
1437
- __ j(parity_even, chunk_->GetAssemblyLabel(false_block));
1438
- } else {
1439
- EmitCmpI(left, right);
1440
- }
1441
-
1442
- Condition cc = TokenToCondition(instr->op(), instr->is_double());
1443
- EmitBranch(true_block, false_block, cc);
1444
- }
1445
-
1446
-
1447
- void LCodeGen::DoCmpJSObjectEq(LCmpJSObjectEq* instr) {
1448
- Register left = ToRegister(instr->InputAt(0));
1449
- Register right = ToRegister(instr->InputAt(1));
1450
- Register result = ToRegister(instr->result());
1451
-
1452
- NearLabel different, done;
1453
- __ cmpq(left, right);
1454
- __ j(not_equal, &different);
1455
- __ LoadRoot(result, Heap::kTrueValueRootIndex);
1456
- __ jmp(&done);
1457
- __ bind(&different);
1458
- __ LoadRoot(result, Heap::kFalseValueRootIndex);
1459
- __ bind(&done);
1460
- }
1461
-
1462
-
1463
- void LCodeGen::DoCmpJSObjectEqAndBranch(LCmpJSObjectEqAndBranch* instr) {
1464
- Register left = ToRegister(instr->InputAt(0));
1465
- Register right = ToRegister(instr->InputAt(1));
1466
- int false_block = chunk_->LookupDestination(instr->false_block_id());
1467
- int true_block = chunk_->LookupDestination(instr->true_block_id());
1468
-
1469
- __ cmpq(left, right);
1470
- EmitBranch(true_block, false_block, equal);
1471
- }
1472
-
1473
-
1474
- void LCodeGen::DoIsNull(LIsNull* instr) {
1475
- Register reg = ToRegister(instr->InputAt(0));
1476
- Register result = ToRegister(instr->result());
1477
-
1478
- // If the expression is known to be a smi, then it's
1479
- // definitely not null. Materialize false.
1480
- // Consider adding other type and representation tests too.
1481
- if (instr->hydrogen()->value()->type().IsSmi()) {
1482
- __ LoadRoot(result, Heap::kFalseValueRootIndex);
1483
- return;
1484
- }
1485
-
1486
- __ CompareRoot(reg, Heap::kNullValueRootIndex);
1487
- if (instr->is_strict()) {
1488
- __ movl(result, Immediate(Heap::kTrueValueRootIndex));
1489
- NearLabel load;
1490
- __ j(equal, &load);
1491
- __ movl(result, Immediate(Heap::kFalseValueRootIndex));
1492
- __ bind(&load);
1493
- __ LoadRootIndexed(result, result, 0);
1494
- } else {
1495
- NearLabel true_value, false_value, done;
1496
- __ j(equal, &true_value);
1497
- __ CompareRoot(reg, Heap::kUndefinedValueRootIndex);
1498
- __ j(equal, &true_value);
1499
- __ JumpIfSmi(reg, &false_value);
1500
- // Check for undetectable objects by looking in the bit field in
1501
- // the map. The object has already been smi checked.
1502
- Register scratch = result;
1503
- __ movq(scratch, FieldOperand(reg, HeapObject::kMapOffset));
1504
- __ testb(FieldOperand(scratch, Map::kBitFieldOffset),
1505
- Immediate(1 << Map::kIsUndetectable));
1506
- __ j(not_zero, &true_value);
1507
- __ bind(&false_value);
1508
- __ LoadRoot(result, Heap::kFalseValueRootIndex);
1509
- __ jmp(&done);
1510
- __ bind(&true_value);
1511
- __ LoadRoot(result, Heap::kTrueValueRootIndex);
1512
- __ bind(&done);
1513
- }
1514
- }
1515
-
1516
-
1517
- void LCodeGen::DoIsNullAndBranch(LIsNullAndBranch* instr) {
1518
- Register reg = ToRegister(instr->InputAt(0));
1519
-
1520
- int false_block = chunk_->LookupDestination(instr->false_block_id());
1521
-
1522
- if (instr->hydrogen()->representation().IsSpecialization() ||
1523
- instr->hydrogen()->type().IsSmi()) {
1524
- // If the expression is known to untagged or smi, then it's definitely
1525
- // not null, and it can't be a an undetectable object.
1526
- // Jump directly to the false block.
1527
- EmitGoto(false_block);
1528
- return;
1529
- }
1530
-
1531
- int true_block = chunk_->LookupDestination(instr->true_block_id());
1532
-
1533
- __ CompareRoot(reg, Heap::kNullValueRootIndex);
1534
- if (instr->is_strict()) {
1535
- EmitBranch(true_block, false_block, equal);
1536
- } else {
1537
- Label* true_label = chunk_->GetAssemblyLabel(true_block);
1538
- Label* false_label = chunk_->GetAssemblyLabel(false_block);
1539
- __ j(equal, true_label);
1540
- __ CompareRoot(reg, Heap::kUndefinedValueRootIndex);
1541
- __ j(equal, true_label);
1542
- __ JumpIfSmi(reg, false_label);
1543
- // Check for undetectable objects by looking in the bit field in
1544
- // the map. The object has already been smi checked.
1545
- Register scratch = ToRegister(instr->TempAt(0));
1546
- __ movq(scratch, FieldOperand(reg, HeapObject::kMapOffset));
1547
- __ testb(FieldOperand(scratch, Map::kBitFieldOffset),
1548
- Immediate(1 << Map::kIsUndetectable));
1549
- EmitBranch(true_block, false_block, not_zero);
1550
- }
1551
- }
1552
-
1553
-
1554
- Condition LCodeGen::EmitIsObject(Register input,
1555
- Label* is_not_object,
1556
- Label* is_object) {
1557
- ASSERT(!input.is(kScratchRegister));
1558
-
1559
- __ JumpIfSmi(input, is_not_object);
1560
-
1561
- __ CompareRoot(input, Heap::kNullValueRootIndex);
1562
- __ j(equal, is_object);
1563
-
1564
- __ movq(kScratchRegister, FieldOperand(input, HeapObject::kMapOffset));
1565
- // Undetectable objects behave like undefined.
1566
- __ testb(FieldOperand(kScratchRegister, Map::kBitFieldOffset),
1567
- Immediate(1 << Map::kIsUndetectable));
1568
- __ j(not_zero, is_not_object);
1569
-
1570
- __ movzxbl(kScratchRegister,
1571
- FieldOperand(kScratchRegister, Map::kInstanceTypeOffset));
1572
- __ cmpb(kScratchRegister, Immediate(FIRST_JS_OBJECT_TYPE));
1573
- __ j(below, is_not_object);
1574
- __ cmpb(kScratchRegister, Immediate(LAST_JS_OBJECT_TYPE));
1575
- return below_equal;
1576
- }
1577
-
1578
-
1579
- void LCodeGen::DoIsObject(LIsObject* instr) {
1580
- Register reg = ToRegister(instr->InputAt(0));
1581
- Register result = ToRegister(instr->result());
1582
- Label is_false, is_true, done;
1583
-
1584
- Condition true_cond = EmitIsObject(reg, &is_false, &is_true);
1585
- __ j(true_cond, &is_true);
1586
-
1587
- __ bind(&is_false);
1588
- __ LoadRoot(result, Heap::kFalseValueRootIndex);
1589
- __ jmp(&done);
1590
-
1591
- __ bind(&is_true);
1592
- __ LoadRoot(result, Heap::kTrueValueRootIndex);
1593
-
1594
- __ bind(&done);
1595
- }
1596
-
1597
-
1598
- void LCodeGen::DoIsObjectAndBranch(LIsObjectAndBranch* instr) {
1599
- Register reg = ToRegister(instr->InputAt(0));
1600
-
1601
- int true_block = chunk_->LookupDestination(instr->true_block_id());
1602
- int false_block = chunk_->LookupDestination(instr->false_block_id());
1603
- Label* true_label = chunk_->GetAssemblyLabel(true_block);
1604
- Label* false_label = chunk_->GetAssemblyLabel(false_block);
1605
-
1606
- Condition true_cond = EmitIsObject(reg, false_label, true_label);
1607
-
1608
- EmitBranch(true_block, false_block, true_cond);
1609
- }
1610
-
1611
-
1612
- void LCodeGen::DoIsSmi(LIsSmi* instr) {
1613
- LOperand* input_operand = instr->InputAt(0);
1614
- Register result = ToRegister(instr->result());
1615
- if (input_operand->IsRegister()) {
1616
- Register input = ToRegister(input_operand);
1617
- __ CheckSmiToIndicator(result, input);
1618
- } else {
1619
- Operand input = ToOperand(instr->InputAt(0));
1620
- __ CheckSmiToIndicator(result, input);
1621
- }
1622
- // result is zero if input is a smi, and one otherwise.
1623
- ASSERT(Heap::kFalseValueRootIndex == Heap::kTrueValueRootIndex + 1);
1624
- __ LoadRootIndexed(result, result, Heap::kTrueValueRootIndex);
1625
- }
1626
-
1627
-
1628
- void LCodeGen::DoIsSmiAndBranch(LIsSmiAndBranch* instr) {
1629
- int true_block = chunk_->LookupDestination(instr->true_block_id());
1630
- int false_block = chunk_->LookupDestination(instr->false_block_id());
1631
-
1632
- Condition is_smi;
1633
- if (instr->InputAt(0)->IsRegister()) {
1634
- Register input = ToRegister(instr->InputAt(0));
1635
- is_smi = masm()->CheckSmi(input);
1636
- } else {
1637
- Operand input = ToOperand(instr->InputAt(0));
1638
- is_smi = masm()->CheckSmi(input);
1639
- }
1640
- EmitBranch(true_block, false_block, is_smi);
1641
- }
1642
-
1643
-
1644
- static InstanceType TestType(HHasInstanceType* instr) {
1645
- InstanceType from = instr->from();
1646
- InstanceType to = instr->to();
1647
- if (from == FIRST_TYPE) return to;
1648
- ASSERT(from == to || to == LAST_TYPE);
1649
- return from;
1650
- }
1651
-
1652
-
1653
- static Condition BranchCondition(HHasInstanceType* instr) {
1654
- InstanceType from = instr->from();
1655
- InstanceType to = instr->to();
1656
- if (from == to) return equal;
1657
- if (to == LAST_TYPE) return above_equal;
1658
- if (from == FIRST_TYPE) return below_equal;
1659
- UNREACHABLE();
1660
- return equal;
1661
- }
1662
-
1663
-
1664
- void LCodeGen::DoHasInstanceType(LHasInstanceType* instr) {
1665
- Register input = ToRegister(instr->InputAt(0));
1666
- Register result = ToRegister(instr->result());
1667
-
1668
- ASSERT(instr->hydrogen()->value()->representation().IsTagged());
1669
- __ testl(input, Immediate(kSmiTagMask));
1670
- NearLabel done, is_false;
1671
- __ j(zero, &is_false);
1672
- __ CmpObjectType(input, TestType(instr->hydrogen()), result);
1673
- __ j(NegateCondition(BranchCondition(instr->hydrogen())), &is_false);
1674
- __ LoadRoot(result, Heap::kTrueValueRootIndex);
1675
- __ jmp(&done);
1676
- __ bind(&is_false);
1677
- __ LoadRoot(result, Heap::kFalseValueRootIndex);
1678
- __ bind(&done);
1679
- }
1680
-
1681
-
1682
- void LCodeGen::DoHasInstanceTypeAndBranch(LHasInstanceTypeAndBranch* instr) {
1683
- Register input = ToRegister(instr->InputAt(0));
1684
-
1685
- int true_block = chunk_->LookupDestination(instr->true_block_id());
1686
- int false_block = chunk_->LookupDestination(instr->false_block_id());
1687
-
1688
- Label* false_label = chunk_->GetAssemblyLabel(false_block);
1689
-
1690
- __ JumpIfSmi(input, false_label);
1691
-
1692
- __ CmpObjectType(input, TestType(instr->hydrogen()), kScratchRegister);
1693
- EmitBranch(true_block, false_block, BranchCondition(instr->hydrogen()));
1694
- }
1695
-
1696
-
1697
- void LCodeGen::DoGetCachedArrayIndex(LGetCachedArrayIndex* instr) {
1698
- Register input = ToRegister(instr->InputAt(0));
1699
- Register result = ToRegister(instr->result());
1700
-
1701
- if (FLAG_debug_code) {
1702
- __ AbortIfNotString(input);
1703
- }
1704
-
1705
- __ movl(result, FieldOperand(input, String::kHashFieldOffset));
1706
- ASSERT(String::kHashShift >= kSmiTagSize);
1707
- __ IndexFromHash(result, result);
1708
- }
1709
-
1710
-
1711
- void LCodeGen::DoHasCachedArrayIndex(LHasCachedArrayIndex* instr) {
1712
- Register input = ToRegister(instr->InputAt(0));
1713
- Register result = ToRegister(instr->result());
1714
-
1715
- ASSERT(instr->hydrogen()->value()->representation().IsTagged());
1716
- __ LoadRoot(result, Heap::kTrueValueRootIndex);
1717
- __ testl(FieldOperand(input, String::kHashFieldOffset),
1718
- Immediate(String::kContainsCachedArrayIndexMask));
1719
- NearLabel done;
1720
- __ j(zero, &done);
1721
- __ LoadRoot(result, Heap::kFalseValueRootIndex);
1722
- __ bind(&done);
1723
- }
1724
-
1725
-
1726
- void LCodeGen::DoHasCachedArrayIndexAndBranch(
1727
- LHasCachedArrayIndexAndBranch* instr) {
1728
- Register input = ToRegister(instr->InputAt(0));
1729
-
1730
- int true_block = chunk_->LookupDestination(instr->true_block_id());
1731
- int false_block = chunk_->LookupDestination(instr->false_block_id());
1732
-
1733
- __ testl(FieldOperand(input, String::kHashFieldOffset),
1734
- Immediate(String::kContainsCachedArrayIndexMask));
1735
- EmitBranch(true_block, false_block, equal);
1736
- }
1737
-
1738
-
1739
- // Branches to a label or falls through with the answer in the z flag.
1740
- // Trashes the temp register and possibly input (if it and temp are aliased).
1741
- void LCodeGen::EmitClassOfTest(Label* is_true,
1742
- Label* is_false,
1743
- Handle<String> class_name,
1744
- Register input,
1745
- Register temp) {
1746
- __ JumpIfSmi(input, is_false);
1747
- __ CmpObjectType(input, FIRST_JS_OBJECT_TYPE, temp);
1748
- __ j(below, is_false);
1749
-
1750
- // Map is now in temp.
1751
- // Functions have class 'Function'.
1752
- __ CmpInstanceType(temp, JS_FUNCTION_TYPE);
1753
- if (class_name->IsEqualTo(CStrVector("Function"))) {
1754
- __ j(equal, is_true);
1755
- } else {
1756
- __ j(equal, is_false);
1757
- }
1758
-
1759
- // Check if the constructor in the map is a function.
1760
- __ movq(temp, FieldOperand(temp, Map::kConstructorOffset));
1761
-
1762
- // As long as JS_FUNCTION_TYPE is the last instance type and it is
1763
- // right after LAST_JS_OBJECT_TYPE, we can avoid checking for
1764
- // LAST_JS_OBJECT_TYPE.
1765
- ASSERT(LAST_TYPE == JS_FUNCTION_TYPE);
1766
- ASSERT(JS_FUNCTION_TYPE == LAST_JS_OBJECT_TYPE + 1);
1767
-
1768
- // Objects with a non-function constructor have class 'Object'.
1769
- __ CmpObjectType(temp, JS_FUNCTION_TYPE, kScratchRegister);
1770
- if (class_name->IsEqualTo(CStrVector("Object"))) {
1771
- __ j(not_equal, is_true);
1772
- } else {
1773
- __ j(not_equal, is_false);
1774
- }
1775
-
1776
- // temp now contains the constructor function. Grab the
1777
- // instance class name from there.
1778
- __ movq(temp, FieldOperand(temp, JSFunction::kSharedFunctionInfoOffset));
1779
- __ movq(temp, FieldOperand(temp,
1780
- SharedFunctionInfo::kInstanceClassNameOffset));
1781
- // The class name we are testing against is a symbol because it's a literal.
1782
- // The name in the constructor is a symbol because of the way the context is
1783
- // booted. This routine isn't expected to work for random API-created
1784
- // classes and it doesn't have to because you can't access it with natives
1785
- // syntax. Since both sides are symbols it is sufficient to use an identity
1786
- // comparison.
1787
- ASSERT(class_name->IsSymbol());
1788
- __ Cmp(temp, class_name);
1789
- // End with the answer in the z flag.
1790
- }
1791
-
1792
-
1793
- void LCodeGen::DoClassOfTest(LClassOfTest* instr) {
1794
- Register input = ToRegister(instr->InputAt(0));
1795
- Register result = ToRegister(instr->result());
1796
- ASSERT(input.is(result));
1797
- Register temp = ToRegister(instr->TempAt(0));
1798
- Handle<String> class_name = instr->hydrogen()->class_name();
1799
- NearLabel done;
1800
- Label is_true, is_false;
1801
-
1802
- EmitClassOfTest(&is_true, &is_false, class_name, input, temp);
1803
-
1804
- __ j(not_equal, &is_false);
1805
-
1806
- __ bind(&is_true);
1807
- __ LoadRoot(result, Heap::kTrueValueRootIndex);
1808
- __ jmp(&done);
1809
-
1810
- __ bind(&is_false);
1811
- __ LoadRoot(result, Heap::kFalseValueRootIndex);
1812
- __ bind(&done);
1813
- }
1814
-
1815
-
1816
- void LCodeGen::DoClassOfTestAndBranch(LClassOfTestAndBranch* instr) {
1817
- Register input = ToRegister(instr->InputAt(0));
1818
- Register temp = ToRegister(instr->TempAt(0));
1819
- Handle<String> class_name = instr->hydrogen()->class_name();
1820
-
1821
- int true_block = chunk_->LookupDestination(instr->true_block_id());
1822
- int false_block = chunk_->LookupDestination(instr->false_block_id());
1823
-
1824
- Label* true_label = chunk_->GetAssemblyLabel(true_block);
1825
- Label* false_label = chunk_->GetAssemblyLabel(false_block);
1826
-
1827
- EmitClassOfTest(true_label, false_label, class_name, input, temp);
1828
-
1829
- EmitBranch(true_block, false_block, equal);
1830
- }
1831
-
1832
-
1833
- void LCodeGen::DoCmpMapAndBranch(LCmpMapAndBranch* instr) {
1834
- Register reg = ToRegister(instr->InputAt(0));
1835
- int true_block = instr->true_block_id();
1836
- int false_block = instr->false_block_id();
1837
-
1838
- __ Cmp(FieldOperand(reg, HeapObject::kMapOffset), instr->map());
1839
- EmitBranch(true_block, false_block, equal);
1840
- }
1841
-
1842
-
1843
- void LCodeGen::DoInstanceOf(LInstanceOf* instr) {
1844
- InstanceofStub stub(InstanceofStub::kNoFlags);
1845
- __ push(ToRegister(instr->InputAt(0)));
1846
- __ push(ToRegister(instr->InputAt(1)));
1847
- CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
1848
- NearLabel true_value, done;
1849
- __ testq(rax, rax);
1850
- __ j(zero, &true_value);
1851
- __ LoadRoot(ToRegister(instr->result()), Heap::kFalseValueRootIndex);
1852
- __ jmp(&done);
1853
- __ bind(&true_value);
1854
- __ LoadRoot(ToRegister(instr->result()), Heap::kTrueValueRootIndex);
1855
- __ bind(&done);
1856
- }
1857
-
1858
-
1859
- void LCodeGen::DoInstanceOfAndBranch(LInstanceOfAndBranch* instr) {
1860
- int true_block = chunk_->LookupDestination(instr->true_block_id());
1861
- int false_block = chunk_->LookupDestination(instr->false_block_id());
1862
-
1863
- InstanceofStub stub(InstanceofStub::kNoFlags);
1864
- __ push(ToRegister(instr->InputAt(0)));
1865
- __ push(ToRegister(instr->InputAt(1)));
1866
- CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
1867
- __ testq(rax, rax);
1868
- EmitBranch(true_block, false_block, zero);
1869
- }
1870
-
1871
-
1872
- void LCodeGen::DoInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr) {
1873
- class DeferredInstanceOfKnownGlobal: public LDeferredCode {
1874
- public:
1875
- DeferredInstanceOfKnownGlobal(LCodeGen* codegen,
1876
- LInstanceOfKnownGlobal* instr)
1877
- : LDeferredCode(codegen), instr_(instr) { }
1878
- virtual void Generate() {
1879
- codegen()->DoDeferredLInstanceOfKnownGlobal(instr_, &map_check_);
1880
- }
1881
-
1882
- Label* map_check() { return &map_check_; }
1883
-
1884
- private:
1885
- LInstanceOfKnownGlobal* instr_;
1886
- Label map_check_;
1887
- };
1888
-
1889
-
1890
- DeferredInstanceOfKnownGlobal* deferred;
1891
- deferred = new DeferredInstanceOfKnownGlobal(this, instr);
1892
-
1893
- Label done, false_result;
1894
- Register object = ToRegister(instr->InputAt(0));
1895
-
1896
- // A Smi is not an instance of anything.
1897
- __ JumpIfSmi(object, &false_result);
1898
-
1899
- // This is the inlined call site instanceof cache. The two occurences of the
1900
- // hole value will be patched to the last map/result pair generated by the
1901
- // instanceof stub.
1902
- NearLabel cache_miss;
1903
- // Use a temp register to avoid memory operands with variable lengths.
1904
- Register map = ToRegister(instr->TempAt(0));
1905
- __ movq(map, FieldOperand(object, HeapObject::kMapOffset));
1906
- __ bind(deferred->map_check()); // Label for calculating code patching.
1907
- __ movq(kScratchRegister, factory()->the_hole_value(),
1908
- RelocInfo::EMBEDDED_OBJECT);
1909
- __ cmpq(map, kScratchRegister); // Patched to cached map.
1910
- __ j(not_equal, &cache_miss);
1911
- // Patched to load either true or false.
1912
- __ LoadRoot(ToRegister(instr->result()), Heap::kTheHoleValueRootIndex);
1913
- #ifdef DEBUG
1914
- // Check that the code size between patch label and patch sites is invariant.
1915
- Label end_of_patched_code;
1916
- __ bind(&end_of_patched_code);
1917
- ASSERT(true);
1918
- #endif
1919
- __ jmp(&done);
1920
-
1921
- // The inlined call site cache did not match. Check for null and string
1922
- // before calling the deferred code.
1923
- __ bind(&cache_miss); // Null is not an instance of anything.
1924
- __ CompareRoot(object, Heap::kNullValueRootIndex);
1925
- __ j(equal, &false_result);
1926
-
1927
- // String values are not instances of anything.
1928
- __ JumpIfNotString(object, kScratchRegister, deferred->entry());
1929
-
1930
- __ bind(&false_result);
1931
- __ LoadRoot(ToRegister(instr->result()), Heap::kFalseValueRootIndex);
1932
-
1933
- __ bind(deferred->exit());
1934
- __ bind(&done);
1935
- }
1936
-
1937
-
1938
- void LCodeGen::DoDeferredLInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr,
1939
- Label* map_check) {
1940
- __ PushSafepointRegisters();
1941
- InstanceofStub::Flags flags = static_cast<InstanceofStub::Flags>(
1942
- InstanceofStub::kNoFlags | InstanceofStub::kCallSiteInlineCheck);
1943
- InstanceofStub stub(flags);
1944
-
1945
- __ push(ToRegister(instr->InputAt(0)));
1946
- __ Push(instr->function());
1947
- Register temp = ToRegister(instr->TempAt(0));
1948
- ASSERT(temp.is(rdi));
1949
- static const int kAdditionalDelta = 16;
1950
- int delta =
1951
- masm_->SizeOfCodeGeneratedSince(map_check) + kAdditionalDelta;
1952
- __ movq(temp, Immediate(delta));
1953
- __ push(temp);
1954
- CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
1955
- __ movq(kScratchRegister, rax);
1956
- __ PopSafepointRegisters();
1957
- __ testq(kScratchRegister, kScratchRegister);
1958
- Label load_false;
1959
- Label done;
1960
- __ j(not_zero, &load_false);
1961
- __ LoadRoot(rax, Heap::kTrueValueRootIndex);
1962
- __ jmp(&done);
1963
- __ bind(&load_false);
1964
- __ LoadRoot(rax, Heap::kFalseValueRootIndex);
1965
- __ bind(&done);
1966
- }
1967
-
1968
-
1969
- void LCodeGen::DoCmpT(LCmpT* instr) {
1970
- Token::Value op = instr->op();
1971
-
1972
- Handle<Code> ic = CompareIC::GetUninitialized(op);
1973
- CallCode(ic, RelocInfo::CODE_TARGET, instr);
1974
-
1975
- Condition condition = TokenToCondition(op, false);
1976
- if (op == Token::GT || op == Token::LTE) {
1977
- condition = ReverseCondition(condition);
1978
- }
1979
- NearLabel true_value, done;
1980
- __ testq(rax, rax);
1981
- __ j(condition, &true_value);
1982
- __ LoadRoot(ToRegister(instr->result()), Heap::kFalseValueRootIndex);
1983
- __ jmp(&done);
1984
- __ bind(&true_value);
1985
- __ LoadRoot(ToRegister(instr->result()), Heap::kTrueValueRootIndex);
1986
- __ bind(&done);
1987
- }
1988
-
1989
-
1990
- void LCodeGen::DoCmpTAndBranch(LCmpTAndBranch* instr) {
1991
- Token::Value op = instr->op();
1992
- int true_block = chunk_->LookupDestination(instr->true_block_id());
1993
- int false_block = chunk_->LookupDestination(instr->false_block_id());
1994
-
1995
- Handle<Code> ic = CompareIC::GetUninitialized(op);
1996
- CallCode(ic, RelocInfo::CODE_TARGET, instr);
1997
-
1998
- // The compare stub expects compare condition and the input operands
1999
- // reversed for GT and LTE.
2000
- Condition condition = TokenToCondition(op, false);
2001
- if (op == Token::GT || op == Token::LTE) {
2002
- condition = ReverseCondition(condition);
2003
- }
2004
- __ testq(rax, rax);
2005
- EmitBranch(true_block, false_block, condition);
2006
- }
2007
-
2008
-
2009
- void LCodeGen::DoReturn(LReturn* instr) {
2010
- if (FLAG_trace) {
2011
- // Preserve the return value on the stack and rely on the runtime
2012
- // call to return the value in the same register.
2013
- __ push(rax);
2014
- __ CallRuntime(Runtime::kTraceExit, 1);
2015
- }
2016
- __ movq(rsp, rbp);
2017
- __ pop(rbp);
2018
- __ Ret((ParameterCount() + 1) * kPointerSize, rcx);
2019
- }
2020
-
2021
-
2022
- void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) {
2023
- Register result = ToRegister(instr->result());
2024
- if (result.is(rax)) {
2025
- __ load_rax(instr->hydrogen()->cell().location(),
2026
- RelocInfo::GLOBAL_PROPERTY_CELL);
2027
- } else {
2028
- __ movq(result, instr->hydrogen()->cell(), RelocInfo::GLOBAL_PROPERTY_CELL);
2029
- __ movq(result, Operand(result, 0));
2030
- }
2031
- if (instr->hydrogen()->check_hole_value()) {
2032
- __ CompareRoot(result, Heap::kTheHoleValueRootIndex);
2033
- DeoptimizeIf(equal, instr->environment());
2034
- }
2035
- }
2036
-
2037
-
2038
- void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) {
2039
- ASSERT(ToRegister(instr->global_object()).is(rax));
2040
- ASSERT(ToRegister(instr->result()).is(rax));
2041
-
2042
- __ Move(rcx, instr->name());
2043
- RelocInfo::Mode mode = instr->for_typeof() ? RelocInfo::CODE_TARGET :
2044
- RelocInfo::CODE_TARGET_CONTEXT;
2045
- Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
2046
- CallCode(ic, mode, instr);
2047
- }
2048
-
2049
-
2050
- void LCodeGen::DoStoreGlobalCell(LStoreGlobalCell* instr) {
2051
- Register value = ToRegister(instr->InputAt(0));
2052
- Register temp = ToRegister(instr->TempAt(0));
2053
- ASSERT(!value.is(temp));
2054
- bool check_hole = instr->hydrogen()->check_hole_value();
2055
- if (!check_hole && value.is(rax)) {
2056
- __ store_rax(instr->hydrogen()->cell().location(),
2057
- RelocInfo::GLOBAL_PROPERTY_CELL);
2058
- return;
2059
- }
2060
- // If the cell we are storing to contains the hole it could have
2061
- // been deleted from the property dictionary. In that case, we need
2062
- // to update the property details in the property dictionary to mark
2063
- // it as no longer deleted. We deoptimize in that case.
2064
- __ movq(temp, instr->hydrogen()->cell(), RelocInfo::GLOBAL_PROPERTY_CELL);
2065
- if (check_hole) {
2066
- __ CompareRoot(Operand(temp, 0), Heap::kTheHoleValueRootIndex);
2067
- DeoptimizeIf(equal, instr->environment());
2068
- }
2069
- __ movq(Operand(temp, 0), value);
2070
- }
2071
-
2072
-
2073
- void LCodeGen::DoStoreGlobalGeneric(LStoreGlobalGeneric* instr) {
2074
- ASSERT(ToRegister(instr->global_object()).is(rdx));
2075
- ASSERT(ToRegister(instr->value()).is(rax));
2076
-
2077
- __ Move(rcx, instr->name());
2078
- Handle<Code> ic = isolate()->builtins()->StoreIC_Initialize();
2079
- CallCode(ic, RelocInfo::CODE_TARGET_CONTEXT, instr);
2080
- }
2081
-
2082
-
2083
- void LCodeGen::DoLoadContextSlot(LLoadContextSlot* instr) {
2084
- Register context = ToRegister(instr->context());
2085
- Register result = ToRegister(instr->result());
2086
- __ movq(result, ContextOperand(context, instr->slot_index()));
2087
- }
2088
-
2089
-
2090
- void LCodeGen::DoStoreContextSlot(LStoreContextSlot* instr) {
2091
- Register context = ToRegister(instr->context());
2092
- Register value = ToRegister(instr->value());
2093
- __ movq(ContextOperand(context, instr->slot_index()), value);
2094
- if (instr->needs_write_barrier()) {
2095
- int offset = Context::SlotOffset(instr->slot_index());
2096
- Register scratch = ToRegister(instr->TempAt(0));
2097
- __ RecordWrite(context, offset, value, scratch);
2098
- }
2099
- }
2100
-
2101
-
2102
- void LCodeGen::DoLoadNamedField(LLoadNamedField* instr) {
2103
- Register object = ToRegister(instr->InputAt(0));
2104
- Register result = ToRegister(instr->result());
2105
- if (instr->hydrogen()->is_in_object()) {
2106
- __ movq(result, FieldOperand(object, instr->hydrogen()->offset()));
2107
- } else {
2108
- __ movq(result, FieldOperand(object, JSObject::kPropertiesOffset));
2109
- __ movq(result, FieldOperand(result, instr->hydrogen()->offset()));
2110
- }
2111
- }
2112
-
2113
-
2114
- void LCodeGen::EmitLoadField(Register result,
2115
- Register object,
2116
- Handle<Map> type,
2117
- Handle<String> name) {
2118
- LookupResult lookup;
2119
- type->LookupInDescriptors(NULL, *name, &lookup);
2120
- ASSERT(lookup.IsProperty() && lookup.type() == FIELD);
2121
- int index = lookup.GetLocalFieldIndexFromMap(*type);
2122
- int offset = index * kPointerSize;
2123
- if (index < 0) {
2124
- // Negative property indices are in-object properties, indexed
2125
- // from the end of the fixed part of the object.
2126
- __ movq(result, FieldOperand(object, offset + type->instance_size()));
2127
- } else {
2128
- // Non-negative property indices are in the properties array.
2129
- __ movq(result, FieldOperand(object, JSObject::kPropertiesOffset));
2130
- __ movq(result, FieldOperand(result, offset + FixedArray::kHeaderSize));
2131
- }
2132
- }
2133
-
2134
-
2135
- void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) {
2136
- Register object = ToRegister(instr->object());
2137
- Register result = ToRegister(instr->result());
2138
-
2139
- int map_count = instr->hydrogen()->types()->length();
2140
- Handle<String> name = instr->hydrogen()->name();
2141
-
2142
- if (map_count == 0) {
2143
- ASSERT(instr->hydrogen()->need_generic());
2144
- __ Move(rcx, instr->hydrogen()->name());
2145
- Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
2146
- CallCode(ic, RelocInfo::CODE_TARGET, instr);
2147
- } else {
2148
- NearLabel done;
2149
- for (int i = 0; i < map_count - 1; ++i) {
2150
- Handle<Map> map = instr->hydrogen()->types()->at(i);
2151
- NearLabel next;
2152
- __ Cmp(FieldOperand(object, HeapObject::kMapOffset), map);
2153
- __ j(not_equal, &next);
2154
- EmitLoadField(result, object, map, name);
2155
- __ jmp(&done);
2156
- __ bind(&next);
2157
- }
2158
- Handle<Map> map = instr->hydrogen()->types()->last();
2159
- __ Cmp(FieldOperand(object, HeapObject::kMapOffset), map);
2160
- if (instr->hydrogen()->need_generic()) {
2161
- NearLabel generic;
2162
- __ j(not_equal, &generic);
2163
- EmitLoadField(result, object, map, name);
2164
- __ jmp(&done);
2165
- __ bind(&generic);
2166
- __ Move(rcx, instr->hydrogen()->name());
2167
- Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
2168
- CallCode(ic, RelocInfo::CODE_TARGET, instr);
2169
- } else {
2170
- DeoptimizeIf(not_equal, instr->environment());
2171
- EmitLoadField(result, object, map, name);
2172
- }
2173
- __ bind(&done);
2174
- }
2175
- }
2176
-
2177
-
2178
- void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) {
2179
- ASSERT(ToRegister(instr->object()).is(rax));
2180
- ASSERT(ToRegister(instr->result()).is(rax));
2181
-
2182
- __ Move(rcx, instr->name());
2183
- Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
2184
- CallCode(ic, RelocInfo::CODE_TARGET, instr);
2185
- }
2186
-
2187
-
2188
- void LCodeGen::DoLoadFunctionPrototype(LLoadFunctionPrototype* instr) {
2189
- Register function = ToRegister(instr->function());
2190
- Register result = ToRegister(instr->result());
2191
-
2192
- // Check that the function really is a function.
2193
- __ CmpObjectType(function, JS_FUNCTION_TYPE, result);
2194
- DeoptimizeIf(not_equal, instr->environment());
2195
-
2196
- // Check whether the function has an instance prototype.
2197
- NearLabel non_instance;
2198
- __ testb(FieldOperand(result, Map::kBitFieldOffset),
2199
- Immediate(1 << Map::kHasNonInstancePrototype));
2200
- __ j(not_zero, &non_instance);
2201
-
2202
- // Get the prototype or initial map from the function.
2203
- __ movq(result,
2204
- FieldOperand(function, JSFunction::kPrototypeOrInitialMapOffset));
2205
-
2206
- // Check that the function has a prototype or an initial map.
2207
- __ CompareRoot(result, Heap::kTheHoleValueRootIndex);
2208
- DeoptimizeIf(equal, instr->environment());
2209
-
2210
- // If the function does not have an initial map, we're done.
2211
- NearLabel done;
2212
- __ CmpObjectType(result, MAP_TYPE, kScratchRegister);
2213
- __ j(not_equal, &done);
2214
-
2215
- // Get the prototype from the initial map.
2216
- __ movq(result, FieldOperand(result, Map::kPrototypeOffset));
2217
- __ jmp(&done);
2218
-
2219
- // Non-instance prototype: Fetch prototype from constructor field
2220
- // in the function's map.
2221
- __ bind(&non_instance);
2222
- __ movq(result, FieldOperand(result, Map::kConstructorOffset));
2223
-
2224
- // All done.
2225
- __ bind(&done);
2226
- }
2227
-
2228
-
2229
- void LCodeGen::DoLoadElements(LLoadElements* instr) {
2230
- Register result = ToRegister(instr->result());
2231
- Register input = ToRegister(instr->InputAt(0));
2232
- __ movq(result, FieldOperand(input, JSObject::kElementsOffset));
2233
- if (FLAG_debug_code) {
2234
- NearLabel done;
2235
- __ CompareRoot(FieldOperand(result, HeapObject::kMapOffset),
2236
- Heap::kFixedArrayMapRootIndex);
2237
- __ j(equal, &done);
2238
- __ CompareRoot(FieldOperand(result, HeapObject::kMapOffset),
2239
- Heap::kFixedCOWArrayMapRootIndex);
2240
- __ j(equal, &done);
2241
- Register temp((result.is(rax)) ? rbx : rax);
2242
- __ push(temp);
2243
- __ movq(temp, FieldOperand(result, HeapObject::kMapOffset));
2244
- __ movzxbq(temp, FieldOperand(temp, Map::kInstanceTypeOffset));
2245
- __ subq(temp, Immediate(FIRST_EXTERNAL_ARRAY_TYPE));
2246
- __ cmpq(temp, Immediate(kExternalArrayTypeCount));
2247
- __ pop(temp);
2248
- __ Check(below, "Check for fast elements failed.");
2249
- __ bind(&done);
2250
- }
2251
- }
2252
-
2253
-
2254
- void LCodeGen::DoLoadExternalArrayPointer(
2255
- LLoadExternalArrayPointer* instr) {
2256
- Register result = ToRegister(instr->result());
2257
- Register input = ToRegister(instr->InputAt(0));
2258
- __ movq(result, FieldOperand(input,
2259
- ExternalPixelArray::kExternalPointerOffset));
2260
- }
2261
-
2262
-
2263
- void LCodeGen::DoAccessArgumentsAt(LAccessArgumentsAt* instr) {
2264
- Register arguments = ToRegister(instr->arguments());
2265
- Register length = ToRegister(instr->length());
2266
- Register result = ToRegister(instr->result());
2267
-
2268
- if (instr->index()->IsRegister()) {
2269
- __ subl(length, ToRegister(instr->index()));
2270
- } else {
2271
- __ subl(length, ToOperand(instr->index()));
2272
- }
2273
- DeoptimizeIf(below_equal, instr->environment());
2274
-
2275
- // There are two words between the frame pointer and the last argument.
2276
- // Subtracting from length accounts for one of them add one more.
2277
- __ movq(result, Operand(arguments, length, times_pointer_size, kPointerSize));
2278
- }
2279
-
2280
-
2281
- void LCodeGen::DoLoadKeyedFastElement(LLoadKeyedFastElement* instr) {
2282
- Register elements = ToRegister(instr->elements());
2283
- Register key = ToRegister(instr->key());
2284
- Register result = ToRegister(instr->result());
2285
- ASSERT(result.is(elements));
2286
-
2287
- // Load the result.
2288
- __ movq(result, FieldOperand(elements,
2289
- key,
2290
- times_pointer_size,
2291
- FixedArray::kHeaderSize));
2292
-
2293
- // Check for the hole value.
2294
- __ CompareRoot(result, Heap::kTheHoleValueRootIndex);
2295
- DeoptimizeIf(equal, instr->environment());
2296
- }
2297
-
2298
-
2299
- void LCodeGen::DoLoadKeyedSpecializedArrayElement(
2300
- LLoadKeyedSpecializedArrayElement* instr) {
2301
- Register external_pointer = ToRegister(instr->external_pointer());
2302
- Register key = ToRegister(instr->key());
2303
- ExternalArrayType array_type = instr->array_type();
2304
- if (array_type == kExternalFloatArray) {
2305
- XMMRegister result(ToDoubleRegister(instr->result()));
2306
- __ movss(result, Operand(external_pointer, key, times_4, 0));
2307
- __ cvtss2sd(result, result);
2308
- } else {
2309
- Register result(ToRegister(instr->result()));
2310
- switch (array_type) {
2311
- case kExternalByteArray:
2312
- __ movsxbq(result, Operand(external_pointer, key, times_1, 0));
2313
- break;
2314
- case kExternalUnsignedByteArray:
2315
- case kExternalPixelArray:
2316
- __ movzxbq(result, Operand(external_pointer, key, times_1, 0));
2317
- break;
2318
- case kExternalShortArray:
2319
- __ movsxwq(result, Operand(external_pointer, key, times_2, 0));
2320
- break;
2321
- case kExternalUnsignedShortArray:
2322
- __ movzxwq(result, Operand(external_pointer, key, times_2, 0));
2323
- break;
2324
- case kExternalIntArray:
2325
- __ movsxlq(result, Operand(external_pointer, key, times_4, 0));
2326
- break;
2327
- case kExternalUnsignedIntArray:
2328
- __ movl(result, Operand(external_pointer, key, times_4, 0));
2329
- __ testl(result, result);
2330
- // TODO(danno): we could be more clever here, perhaps having a special
2331
- // version of the stub that detects if the overflow case actually
2332
- // happens, and generate code that returns a double rather than int.
2333
- DeoptimizeIf(negative, instr->environment());
2334
- break;
2335
- case kExternalFloatArray:
2336
- UNREACHABLE();
2337
- break;
2338
- }
2339
- }
2340
- }
2341
-
2342
-
2343
- void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) {
2344
- ASSERT(ToRegister(instr->object()).is(rdx));
2345
- ASSERT(ToRegister(instr->key()).is(rax));
2346
-
2347
- Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize();
2348
- CallCode(ic, RelocInfo::CODE_TARGET, instr);
2349
- }
2350
-
2351
-
2352
- void LCodeGen::DoArgumentsElements(LArgumentsElements* instr) {
2353
- Register result = ToRegister(instr->result());
2354
-
2355
- // Check for arguments adapter frame.
2356
- NearLabel done, adapted;
2357
- __ movq(result, Operand(rbp, StandardFrameConstants::kCallerFPOffset));
2358
- __ Cmp(Operand(result, StandardFrameConstants::kContextOffset),
2359
- Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
2360
- __ j(equal, &adapted);
2361
-
2362
- // No arguments adaptor frame.
2363
- __ movq(result, rbp);
2364
- __ jmp(&done);
2365
-
2366
- // Arguments adaptor frame present.
2367
- __ bind(&adapted);
2368
- __ movq(result, Operand(rbp, StandardFrameConstants::kCallerFPOffset));
2369
-
2370
- // Result is the frame pointer for the frame if not adapted and for the real
2371
- // frame below the adaptor frame if adapted.
2372
- __ bind(&done);
2373
- }
2374
-
2375
-
2376
- void LCodeGen::DoArgumentsLength(LArgumentsLength* instr) {
2377
- Register result = ToRegister(instr->result());
2378
-
2379
- NearLabel done;
2380
-
2381
- // If no arguments adaptor frame the number of arguments is fixed.
2382
- if (instr->InputAt(0)->IsRegister()) {
2383
- __ cmpq(rbp, ToRegister(instr->InputAt(0)));
2384
- } else {
2385
- __ cmpq(rbp, ToOperand(instr->InputAt(0)));
2386
- }
2387
- __ movq(result, Immediate(scope()->num_parameters()));
2388
- __ j(equal, &done);
2389
-
2390
- // Arguments adaptor frame present. Get argument length from there.
2391
- __ movq(result, Operand(rbp, StandardFrameConstants::kCallerFPOffset));
2392
- __ movq(result, Operand(result,
2393
- ArgumentsAdaptorFrameConstants::kLengthOffset));
2394
- __ SmiToInteger32(result, result);
2395
-
2396
- // Argument length is in result register.
2397
- __ bind(&done);
2398
- }
2399
-
2400
-
2401
- void LCodeGen::DoApplyArguments(LApplyArguments* instr) {
2402
- Register receiver = ToRegister(instr->receiver());
2403
- Register function = ToRegister(instr->function());
2404
- Register length = ToRegister(instr->length());
2405
- Register elements = ToRegister(instr->elements());
2406
- ASSERT(receiver.is(rax)); // Used for parameter count.
2407
- ASSERT(function.is(rdi)); // Required by InvokeFunction.
2408
- ASSERT(ToRegister(instr->result()).is(rax));
2409
-
2410
- // If the receiver is null or undefined, we have to pass the global object
2411
- // as a receiver.
2412
- NearLabel global_object, receiver_ok;
2413
- __ CompareRoot(receiver, Heap::kNullValueRootIndex);
2414
- __ j(equal, &global_object);
2415
- __ CompareRoot(receiver, Heap::kUndefinedValueRootIndex);
2416
- __ j(equal, &global_object);
2417
-
2418
- // The receiver should be a JS object.
2419
- Condition is_smi = __ CheckSmi(receiver);
2420
- DeoptimizeIf(is_smi, instr->environment());
2421
- __ CmpObjectType(receiver, FIRST_JS_OBJECT_TYPE, kScratchRegister);
2422
- DeoptimizeIf(below, instr->environment());
2423
- __ jmp(&receiver_ok);
2424
-
2425
- __ bind(&global_object);
2426
- // TODO(kmillikin): We have a hydrogen value for the global object. See
2427
- // if it's better to use it than to explicitly fetch it from the context
2428
- // here.
2429
- __ movq(receiver, Operand(rbp, StandardFrameConstants::kContextOffset));
2430
- __ movq(receiver, ContextOperand(receiver, Context::GLOBAL_INDEX));
2431
- __ bind(&receiver_ok);
2432
-
2433
- // Copy the arguments to this function possibly from the
2434
- // adaptor frame below it.
2435
- const uint32_t kArgumentsLimit = 1 * KB;
2436
- __ cmpq(length, Immediate(kArgumentsLimit));
2437
- DeoptimizeIf(above, instr->environment());
2438
-
2439
- __ push(receiver);
2440
- __ movq(receiver, length);
2441
-
2442
- // Loop through the arguments pushing them onto the execution
2443
- // stack.
2444
- NearLabel invoke, loop;
2445
- // length is a small non-negative integer, due to the test above.
2446
- __ testl(length, length);
2447
- __ j(zero, &invoke);
2448
- __ bind(&loop);
2449
- __ push(Operand(elements, length, times_pointer_size, 1 * kPointerSize));
2450
- __ decl(length);
2451
- __ j(not_zero, &loop);
2452
-
2453
- // Invoke the function.
2454
- __ bind(&invoke);
2455
- ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment());
2456
- LPointerMap* pointers = instr->pointer_map();
2457
- LEnvironment* env = instr->deoptimization_environment();
2458
- RecordPosition(pointers->position());
2459
- RegisterEnvironmentForDeoptimization(env);
2460
- SafepointGenerator safepoint_generator(this,
2461
- pointers,
2462
- env->deoptimization_index());
2463
- v8::internal::ParameterCount actual(rax);
2464
- __ InvokeFunction(function, actual, CALL_FUNCTION, &safepoint_generator);
2465
- }
2466
-
2467
-
2468
- void LCodeGen::DoPushArgument(LPushArgument* instr) {
2469
- LOperand* argument = instr->InputAt(0);
2470
- if (argument->IsConstantOperand()) {
2471
- EmitPushConstantOperand(argument);
2472
- } else if (argument->IsRegister()) {
2473
- __ push(ToRegister(argument));
2474
- } else {
2475
- ASSERT(!argument->IsDoubleRegister());
2476
- __ push(ToOperand(argument));
2477
- }
2478
- }
2479
-
2480
-
2481
- void LCodeGen::DoContext(LContext* instr) {
2482
- Register result = ToRegister(instr->result());
2483
- __ movq(result, Operand(rbp, StandardFrameConstants::kContextOffset));
2484
- }
2485
-
2486
-
2487
- void LCodeGen::DoOuterContext(LOuterContext* instr) {
2488
- Register context = ToRegister(instr->context());
2489
- Register result = ToRegister(instr->result());
2490
- __ movq(result,
2491
- Operand(context, Context::SlotOffset(Context::CLOSURE_INDEX)));
2492
- __ movq(result, FieldOperand(result, JSFunction::kContextOffset));
2493
- }
2494
-
2495
-
2496
- void LCodeGen::DoGlobalObject(LGlobalObject* instr) {
2497
- Register result = ToRegister(instr->result());
2498
- __ movq(result, GlobalObjectOperand());
2499
- }
2500
-
2501
-
2502
- void LCodeGen::DoGlobalReceiver(LGlobalReceiver* instr) {
2503
- Register global = ToRegister(instr->global());
2504
- Register result = ToRegister(instr->result());
2505
- __ movq(result, FieldOperand(global, GlobalObject::kGlobalReceiverOffset));
2506
- }
2507
-
2508
-
2509
- void LCodeGen::CallKnownFunction(Handle<JSFunction> function,
2510
- int arity,
2511
- LInstruction* instr) {
2512
- // Change context if needed.
2513
- bool change_context =
2514
- (info()->closure()->context() != function->context()) ||
2515
- scope()->contains_with() ||
2516
- (scope()->num_heap_slots() > 0);
2517
- if (change_context) {
2518
- __ movq(rsi, FieldOperand(rdi, JSFunction::kContextOffset));
2519
- }
2520
-
2521
- // Set rax to arguments count if adaption is not needed. Assumes that rax
2522
- // is available to write to at this point.
2523
- if (!function->NeedsArgumentsAdaption()) {
2524
- __ Set(rax, arity);
2525
- }
2526
-
2527
- LPointerMap* pointers = instr->pointer_map();
2528
- RecordPosition(pointers->position());
2529
-
2530
- // Invoke function.
2531
- if (*function == *info()->closure()) {
2532
- __ CallSelf();
2533
- } else {
2534
- __ call(FieldOperand(rdi, JSFunction::kCodeEntryOffset));
2535
- }
2536
-
2537
- // Setup deoptimization.
2538
- RegisterLazyDeoptimization(instr);
2539
-
2540
- // Restore context.
2541
- __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
2542
- }
2543
-
2544
-
2545
- void LCodeGen::DoCallConstantFunction(LCallConstantFunction* instr) {
2546
- ASSERT(ToRegister(instr->result()).is(rax));
2547
- __ Move(rdi, instr->function());
2548
- CallKnownFunction(instr->function(), instr->arity(), instr);
2549
- }
2550
-
2551
-
2552
- void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LUnaryMathOperation* instr) {
2553
- Register input_reg = ToRegister(instr->InputAt(0));
2554
- __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset),
2555
- Heap::kHeapNumberMapRootIndex);
2556
- DeoptimizeIf(not_equal, instr->environment());
2557
-
2558
- Label done;
2559
- Register tmp = input_reg.is(rax) ? rcx : rax;
2560
- Register tmp2 = tmp.is(rcx) ? rdx : input_reg.is(rcx) ? rdx : rcx;
2561
-
2562
- // Preserve the value of all registers.
2563
- __ PushSafepointRegisters();
2564
-
2565
- Label negative;
2566
- __ movl(tmp, FieldOperand(input_reg, HeapNumber::kExponentOffset));
2567
- // Check the sign of the argument. If the argument is positive, just
2568
- // return it. We do not need to patch the stack since |input| and
2569
- // |result| are the same register and |input| will be restored
2570
- // unchanged by popping safepoint registers.
2571
- __ testl(tmp, Immediate(HeapNumber::kSignMask));
2572
- __ j(not_zero, &negative);
2573
- __ jmp(&done);
2574
-
2575
- __ bind(&negative);
2576
-
2577
- Label allocated, slow;
2578
- __ AllocateHeapNumber(tmp, tmp2, &slow);
2579
- __ jmp(&allocated);
2580
-
2581
- // Slow case: Call the runtime system to do the number allocation.
2582
- __ bind(&slow);
2583
-
2584
- __ CallRuntimeSaveDoubles(Runtime::kAllocateHeapNumber);
2585
- RecordSafepointWithRegisters(
2586
- instr->pointer_map(), 0, Safepoint::kNoDeoptimizationIndex);
2587
- // Set the pointer to the new heap number in tmp.
2588
- if (!tmp.is(rax)) {
2589
- __ movq(tmp, rax);
2590
- }
2591
-
2592
- // Restore input_reg after call to runtime.
2593
- __ LoadFromSafepointRegisterSlot(input_reg, input_reg);
2594
-
2595
- __ bind(&allocated);
2596
- __ movq(tmp2, FieldOperand(input_reg, HeapNumber::kValueOffset));
2597
- __ shl(tmp2, Immediate(1));
2598
- __ shr(tmp2, Immediate(1));
2599
- __ movq(FieldOperand(tmp, HeapNumber::kValueOffset), tmp2);
2600
- __ StoreToSafepointRegisterSlot(input_reg, tmp);
2601
-
2602
- __ bind(&done);
2603
- __ PopSafepointRegisters();
2604
- }
2605
-
2606
-
2607
- void LCodeGen::EmitIntegerMathAbs(LUnaryMathOperation* instr) {
2608
- Register input_reg = ToRegister(instr->InputAt(0));
2609
- __ testl(input_reg, input_reg);
2610
- Label is_positive;
2611
- __ j(not_sign, &is_positive);
2612
- __ negl(input_reg); // Sets flags.
2613
- DeoptimizeIf(negative, instr->environment());
2614
- __ bind(&is_positive);
2615
- }
2616
-
2617
-
2618
- void LCodeGen::DoMathAbs(LUnaryMathOperation* instr) {
2619
- // Class for deferred case.
2620
- class DeferredMathAbsTaggedHeapNumber: public LDeferredCode {
2621
- public:
2622
- DeferredMathAbsTaggedHeapNumber(LCodeGen* codegen,
2623
- LUnaryMathOperation* instr)
2624
- : LDeferredCode(codegen), instr_(instr) { }
2625
- virtual void Generate() {
2626
- codegen()->DoDeferredMathAbsTaggedHeapNumber(instr_);
2627
- }
2628
- private:
2629
- LUnaryMathOperation* instr_;
2630
- };
2631
-
2632
- ASSERT(instr->InputAt(0)->Equals(instr->result()));
2633
- Representation r = instr->hydrogen()->value()->representation();
2634
-
2635
- if (r.IsDouble()) {
2636
- XMMRegister scratch = xmm0;
2637
- XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0));
2638
- __ xorpd(scratch, scratch);
2639
- __ subsd(scratch, input_reg);
2640
- __ andpd(input_reg, scratch);
2641
- } else if (r.IsInteger32()) {
2642
- EmitIntegerMathAbs(instr);
2643
- } else { // Tagged case.
2644
- DeferredMathAbsTaggedHeapNumber* deferred =
2645
- new DeferredMathAbsTaggedHeapNumber(this, instr);
2646
- Register input_reg = ToRegister(instr->InputAt(0));
2647
- // Smi check.
2648
- __ JumpIfNotSmi(input_reg, deferred->entry());
2649
- EmitIntegerMathAbs(instr);
2650
- __ bind(deferred->exit());
2651
- }
2652
- }
2653
-
2654
-
2655
- void LCodeGen::DoMathFloor(LUnaryMathOperation* instr) {
2656
- XMMRegister xmm_scratch = xmm0;
2657
- Register output_reg = ToRegister(instr->result());
2658
- XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0));
2659
- __ xorpd(xmm_scratch, xmm_scratch); // Zero the register.
2660
- __ ucomisd(input_reg, xmm_scratch);
2661
-
2662
- if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
2663
- DeoptimizeIf(below_equal, instr->environment());
2664
- } else {
2665
- DeoptimizeIf(below, instr->environment());
2666
- }
2667
-
2668
- // Use truncating instruction (OK because input is positive).
2669
- __ cvttsd2si(output_reg, input_reg);
2670
-
2671
- // Overflow is signalled with minint.
2672
- __ cmpl(output_reg, Immediate(0x80000000));
2673
- DeoptimizeIf(equal, instr->environment());
2674
- }
2675
-
2676
-
2677
- void LCodeGen::DoMathRound(LUnaryMathOperation* instr) {
2678
- const XMMRegister xmm_scratch = xmm0;
2679
- Register output_reg = ToRegister(instr->result());
2680
- XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0));
2681
-
2682
- // xmm_scratch = 0.5
2683
- __ movq(kScratchRegister, V8_INT64_C(0x3FE0000000000000), RelocInfo::NONE);
2684
- __ movq(xmm_scratch, kScratchRegister);
2685
-
2686
- // input = input + 0.5
2687
- __ addsd(input_reg, xmm_scratch);
2688
-
2689
- // We need to return -0 for the input range [-0.5, 0[, otherwise
2690
- // compute Math.floor(value + 0.5).
2691
- if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
2692
- __ ucomisd(input_reg, xmm_scratch);
2693
- DeoptimizeIf(below_equal, instr->environment());
2694
- } else {
2695
- // If we don't need to bailout on -0, we check only bailout
2696
- // on negative inputs.
2697
- __ xorpd(xmm_scratch, xmm_scratch); // Zero the register.
2698
- __ ucomisd(input_reg, xmm_scratch);
2699
- DeoptimizeIf(below, instr->environment());
2700
- }
2701
-
2702
- // Compute Math.floor(value + 0.5).
2703
- // Use truncating instruction (OK because input is positive).
2704
- __ cvttsd2si(output_reg, input_reg);
2705
-
2706
- // Overflow is signalled with minint.
2707
- __ cmpl(output_reg, Immediate(0x80000000));
2708
- DeoptimizeIf(equal, instr->environment());
2709
- }
2710
-
2711
-
2712
- void LCodeGen::DoMathSqrt(LUnaryMathOperation* instr) {
2713
- XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0));
2714
- ASSERT(ToDoubleRegister(instr->result()).is(input_reg));
2715
- __ sqrtsd(input_reg, input_reg);
2716
- }
2717
-
2718
-
2719
- void LCodeGen::DoMathPowHalf(LUnaryMathOperation* instr) {
2720
- XMMRegister xmm_scratch = xmm0;
2721
- XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0));
2722
- ASSERT(ToDoubleRegister(instr->result()).is(input_reg));
2723
- __ xorpd(xmm_scratch, xmm_scratch);
2724
- __ addsd(input_reg, xmm_scratch); // Convert -0 to +0.
2725
- __ sqrtsd(input_reg, input_reg);
2726
- }
2727
-
2728
-
2729
- void LCodeGen::DoPower(LPower* instr) {
2730
- LOperand* left = instr->InputAt(0);
2731
- XMMRegister left_reg = ToDoubleRegister(left);
2732
- ASSERT(!left_reg.is(xmm1));
2733
- LOperand* right = instr->InputAt(1);
2734
- XMMRegister result_reg = ToDoubleRegister(instr->result());
2735
- Representation exponent_type = instr->hydrogen()->right()->representation();
2736
- if (exponent_type.IsDouble()) {
2737
- __ PrepareCallCFunction(2);
2738
- // Move arguments to correct registers
2739
- __ movsd(xmm0, left_reg);
2740
- ASSERT(ToDoubleRegister(right).is(xmm1));
2741
- __ CallCFunction(
2742
- ExternalReference::power_double_double_function(isolate()), 2);
2743
- } else if (exponent_type.IsInteger32()) {
2744
- __ PrepareCallCFunction(2);
2745
- // Move arguments to correct registers: xmm0 and edi (not rdi).
2746
- // On Windows, the registers are xmm0 and edx.
2747
- __ movsd(xmm0, left_reg);
2748
- #ifdef _WIN64
2749
- ASSERT(ToRegister(right).is(rdx));
2750
- #else
2751
- ASSERT(ToRegister(right).is(rdi));
2752
- #endif
2753
- __ CallCFunction(
2754
- ExternalReference::power_double_int_function(isolate()), 2);
2755
- } else {
2756
- ASSERT(exponent_type.IsTagged());
2757
- Register right_reg = ToRegister(right);
2758
-
2759
- Label non_smi, call;
2760
- __ JumpIfNotSmi(right_reg, &non_smi);
2761
- __ SmiToInteger32(right_reg, right_reg);
2762
- __ cvtlsi2sd(xmm1, right_reg);
2763
- __ jmp(&call);
2764
-
2765
- __ bind(&non_smi);
2766
- __ CmpObjectType(right_reg, HEAP_NUMBER_TYPE , kScratchRegister);
2767
- DeoptimizeIf(not_equal, instr->environment());
2768
- __ movsd(xmm1, FieldOperand(right_reg, HeapNumber::kValueOffset));
2769
-
2770
- __ bind(&call);
2771
- __ PrepareCallCFunction(2);
2772
- // Move arguments to correct registers xmm0 and xmm1.
2773
- __ movsd(xmm0, left_reg);
2774
- // Right argument is already in xmm1.
2775
- __ CallCFunction(
2776
- ExternalReference::power_double_double_function(isolate()), 2);
2777
- }
2778
- // Return value is in xmm0.
2779
- __ movsd(result_reg, xmm0);
2780
- // Restore context register.
2781
- __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
2782
- }
2783
-
2784
-
2785
- void LCodeGen::DoMathLog(LUnaryMathOperation* instr) {
2786
- ASSERT(ToDoubleRegister(instr->result()).is(xmm1));
2787
- TranscendentalCacheStub stub(TranscendentalCache::LOG,
2788
- TranscendentalCacheStub::UNTAGGED);
2789
- CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
2790
- }
2791
-
2792
-
2793
- void LCodeGen::DoMathCos(LUnaryMathOperation* instr) {
2794
- ASSERT(ToDoubleRegister(instr->result()).is(xmm1));
2795
- TranscendentalCacheStub stub(TranscendentalCache::COS,
2796
- TranscendentalCacheStub::UNTAGGED);
2797
- CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
2798
- }
2799
-
2800
-
2801
- void LCodeGen::DoMathSin(LUnaryMathOperation* instr) {
2802
- ASSERT(ToDoubleRegister(instr->result()).is(xmm1));
2803
- TranscendentalCacheStub stub(TranscendentalCache::SIN,
2804
- TranscendentalCacheStub::UNTAGGED);
2805
- CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
2806
- }
2807
-
2808
-
2809
- void LCodeGen::DoUnaryMathOperation(LUnaryMathOperation* instr) {
2810
- switch (instr->op()) {
2811
- case kMathAbs:
2812
- DoMathAbs(instr);
2813
- break;
2814
- case kMathFloor:
2815
- DoMathFloor(instr);
2816
- break;
2817
- case kMathRound:
2818
- DoMathRound(instr);
2819
- break;
2820
- case kMathSqrt:
2821
- DoMathSqrt(instr);
2822
- break;
2823
- case kMathPowHalf:
2824
- DoMathPowHalf(instr);
2825
- break;
2826
- case kMathCos:
2827
- DoMathCos(instr);
2828
- break;
2829
- case kMathSin:
2830
- DoMathSin(instr);
2831
- break;
2832
- case kMathLog:
2833
- DoMathLog(instr);
2834
- break;
2835
-
2836
- default:
2837
- UNREACHABLE();
2838
- }
2839
- }
2840
-
2841
-
2842
- void LCodeGen::DoCallKeyed(LCallKeyed* instr) {
2843
- ASSERT(ToRegister(instr->key()).is(rcx));
2844
- ASSERT(ToRegister(instr->result()).is(rax));
2845
-
2846
- int arity = instr->arity();
2847
- Handle<Code> ic = isolate()->stub_cache()->ComputeKeyedCallInitialize(
2848
- arity, NOT_IN_LOOP);
2849
- CallCode(ic, RelocInfo::CODE_TARGET, instr);
2850
- __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
2851
- }
2852
-
2853
-
2854
- void LCodeGen::DoCallNamed(LCallNamed* instr) {
2855
- ASSERT(ToRegister(instr->result()).is(rax));
2856
-
2857
- int arity = instr->arity();
2858
- Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(
2859
- arity, NOT_IN_LOOP);
2860
- __ Move(rcx, instr->name());
2861
- CallCode(ic, RelocInfo::CODE_TARGET, instr);
2862
- __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
2863
- }
2864
-
2865
-
2866
- void LCodeGen::DoCallFunction(LCallFunction* instr) {
2867
- ASSERT(ToRegister(instr->result()).is(rax));
2868
-
2869
- int arity = instr->arity();
2870
- CallFunctionStub stub(arity, NOT_IN_LOOP, RECEIVER_MIGHT_BE_VALUE);
2871
- CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
2872
- __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
2873
- __ Drop(1);
2874
- }
2875
-
2876
-
2877
- void LCodeGen::DoCallGlobal(LCallGlobal* instr) {
2878
- ASSERT(ToRegister(instr->result()).is(rax));
2879
- int arity = instr->arity();
2880
- Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(
2881
- arity, NOT_IN_LOOP);
2882
- __ Move(rcx, instr->name());
2883
- CallCode(ic, RelocInfo::CODE_TARGET_CONTEXT, instr);
2884
- __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
2885
- }
2886
-
2887
-
2888
- void LCodeGen::DoCallKnownGlobal(LCallKnownGlobal* instr) {
2889
- ASSERT(ToRegister(instr->result()).is(rax));
2890
- __ Move(rdi, instr->target());
2891
- CallKnownFunction(instr->target(), instr->arity(), instr);
2892
- }
2893
-
2894
-
2895
- void LCodeGen::DoCallNew(LCallNew* instr) {
2896
- ASSERT(ToRegister(instr->InputAt(0)).is(rdi));
2897
- ASSERT(ToRegister(instr->result()).is(rax));
2898
-
2899
- Handle<Code> builtin = isolate()->builtins()->JSConstructCall();
2900
- __ Set(rax, instr->arity());
2901
- CallCode(builtin, RelocInfo::CONSTRUCT_CALL, instr);
2902
- }
2903
-
2904
-
2905
- void LCodeGen::DoCallRuntime(LCallRuntime* instr) {
2906
- CallRuntime(instr->function(), instr->arity(), instr);
2907
- }
2908
-
2909
-
2910
- void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) {
2911
- Register object = ToRegister(instr->object());
2912
- Register value = ToRegister(instr->value());
2913
- int offset = instr->offset();
2914
-
2915
- if (!instr->transition().is_null()) {
2916
- __ Move(FieldOperand(object, HeapObject::kMapOffset), instr->transition());
2917
- }
2918
-
2919
- // Do the store.
2920
- if (instr->is_in_object()) {
2921
- __ movq(FieldOperand(object, offset), value);
2922
- if (instr->needs_write_barrier()) {
2923
- Register temp = ToRegister(instr->TempAt(0));
2924
- // Update the write barrier for the object for in-object properties.
2925
- __ RecordWrite(object, offset, value, temp);
2926
- }
2927
- } else {
2928
- Register temp = ToRegister(instr->TempAt(0));
2929
- __ movq(temp, FieldOperand(object, JSObject::kPropertiesOffset));
2930
- __ movq(FieldOperand(temp, offset), value);
2931
- if (instr->needs_write_barrier()) {
2932
- // Update the write barrier for the properties array.
2933
- // object is used as a scratch register.
2934
- __ RecordWrite(temp, offset, value, object);
2935
- }
2936
- }
2937
- }
2938
-
2939
-
2940
- void LCodeGen::DoStoreNamedGeneric(LStoreNamedGeneric* instr) {
2941
- ASSERT(ToRegister(instr->object()).is(rdx));
2942
- ASSERT(ToRegister(instr->value()).is(rax));
2943
-
2944
- __ Move(rcx, instr->hydrogen()->name());
2945
- Handle<Code> ic = info_->is_strict()
2946
- ? isolate()->builtins()->StoreIC_Initialize_Strict()
2947
- : isolate()->builtins()->StoreIC_Initialize();
2948
- CallCode(ic, RelocInfo::CODE_TARGET, instr);
2949
- }
2950
-
2951
-
2952
- void LCodeGen::DoStoreKeyedSpecializedArrayElement(
2953
- LStoreKeyedSpecializedArrayElement* instr) {
2954
- Register external_pointer = ToRegister(instr->external_pointer());
2955
- Register key = ToRegister(instr->key());
2956
- ExternalArrayType array_type = instr->array_type();
2957
- if (array_type == kExternalFloatArray) {
2958
- XMMRegister value(ToDoubleRegister(instr->value()));
2959
- __ cvtsd2ss(value, value);
2960
- __ movss(Operand(external_pointer, key, times_4, 0), value);
2961
- } else {
2962
- Register value(ToRegister(instr->value()));
2963
- switch (array_type) {
2964
- case kExternalPixelArray:
2965
- { // Clamp the value to [0..255].
2966
- NearLabel done;
2967
- __ testl(value, Immediate(0xFFFFFF00));
2968
- __ j(zero, &done);
2969
- __ setcc(negative, value); // 1 if negative, 0 if positive.
2970
- __ decb(value); // 0 if negative, 255 if positive.
2971
- __ bind(&done);
2972
- __ movb(Operand(external_pointer, key, times_1, 0), value);
2973
- }
2974
- break;
2975
- case kExternalByteArray:
2976
- case kExternalUnsignedByteArray:
2977
- __ movb(Operand(external_pointer, key, times_1, 0), value);
2978
- break;
2979
- case kExternalShortArray:
2980
- case kExternalUnsignedShortArray:
2981
- __ movw(Operand(external_pointer, key, times_2, 0), value);
2982
- break;
2983
- case kExternalIntArray:
2984
- case kExternalUnsignedIntArray:
2985
- __ movl(Operand(external_pointer, key, times_4, 0), value);
2986
- break;
2987
- case kExternalFloatArray:
2988
- UNREACHABLE();
2989
- break;
2990
- }
2991
- }
2992
- }
2993
-
2994
-
2995
- void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) {
2996
- if (instr->length()->IsRegister()) {
2997
- __ cmpq(ToRegister(instr->index()), ToRegister(instr->length()));
2998
- } else {
2999
- __ cmpq(ToRegister(instr->index()), ToOperand(instr->length()));
3000
- }
3001
- DeoptimizeIf(above_equal, instr->environment());
3002
- }
3003
-
3004
-
3005
- void LCodeGen::DoStoreKeyedFastElement(LStoreKeyedFastElement* instr) {
3006
- Register value = ToRegister(instr->value());
3007
- Register elements = ToRegister(instr->object());
3008
- Register key = instr->key()->IsRegister() ? ToRegister(instr->key()) : no_reg;
3009
-
3010
- // Do the store.
3011
- if (instr->key()->IsConstantOperand()) {
3012
- ASSERT(!instr->hydrogen()->NeedsWriteBarrier());
3013
- LConstantOperand* const_operand = LConstantOperand::cast(instr->key());
3014
- int offset =
3015
- ToInteger32(const_operand) * kPointerSize + FixedArray::kHeaderSize;
3016
- __ movq(FieldOperand(elements, offset), value);
3017
- } else {
3018
- __ movq(FieldOperand(elements,
3019
- key,
3020
- times_pointer_size,
3021
- FixedArray::kHeaderSize),
3022
- value);
3023
- }
3024
-
3025
- if (instr->hydrogen()->NeedsWriteBarrier()) {
3026
- // Compute address of modified element and store it into key register.
3027
- __ lea(key, FieldOperand(elements,
3028
- key,
3029
- times_pointer_size,
3030
- FixedArray::kHeaderSize));
3031
- __ RecordWrite(elements, key, value);
3032
- }
3033
- }
3034
-
3035
-
3036
- void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) {
3037
- ASSERT(ToRegister(instr->object()).is(rdx));
3038
- ASSERT(ToRegister(instr->key()).is(rcx));
3039
- ASSERT(ToRegister(instr->value()).is(rax));
3040
-
3041
- Handle<Code> ic = info_->is_strict()
3042
- ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict()
3043
- : isolate()->builtins()->KeyedStoreIC_Initialize();
3044
- CallCode(ic, RelocInfo::CODE_TARGET, instr);
3045
- }
3046
-
3047
-
3048
- void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) {
3049
- class DeferredStringCharCodeAt: public LDeferredCode {
3050
- public:
3051
- DeferredStringCharCodeAt(LCodeGen* codegen, LStringCharCodeAt* instr)
3052
- : LDeferredCode(codegen), instr_(instr) { }
3053
- virtual void Generate() { codegen()->DoDeferredStringCharCodeAt(instr_); }
3054
- private:
3055
- LStringCharCodeAt* instr_;
3056
- };
3057
-
3058
- Register string = ToRegister(instr->string());
3059
- Register index = no_reg;
3060
- int const_index = -1;
3061
- if (instr->index()->IsConstantOperand()) {
3062
- const_index = ToInteger32(LConstantOperand::cast(instr->index()));
3063
- STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue);
3064
- if (!Smi::IsValid(const_index)) {
3065
- // Guaranteed to be out of bounds because of the assert above.
3066
- // So the bounds check that must dominate this instruction must
3067
- // have deoptimized already.
3068
- if (FLAG_debug_code) {
3069
- __ Abort("StringCharCodeAt: out of bounds index.");
3070
- }
3071
- // No code needs to be generated.
3072
- return;
3073
- }
3074
- } else {
3075
- index = ToRegister(instr->index());
3076
- }
3077
- Register result = ToRegister(instr->result());
3078
-
3079
- DeferredStringCharCodeAt* deferred =
3080
- new DeferredStringCharCodeAt(this, instr);
3081
-
3082
- NearLabel flat_string, ascii_string, done;
3083
-
3084
- // Fetch the instance type of the receiver into result register.
3085
- __ movq(result, FieldOperand(string, HeapObject::kMapOffset));
3086
- __ movzxbl(result, FieldOperand(result, Map::kInstanceTypeOffset));
3087
-
3088
- // We need special handling for non-sequential strings.
3089
- STATIC_ASSERT(kSeqStringTag == 0);
3090
- __ testb(result, Immediate(kStringRepresentationMask));
3091
- __ j(zero, &flat_string);
3092
-
3093
- // Handle cons strings and go to deferred code for the rest.
3094
- __ testb(result, Immediate(kIsConsStringMask));
3095
- __ j(zero, deferred->entry());
3096
-
3097
- // ConsString.
3098
- // Check whether the right hand side is the empty string (i.e. if
3099
- // this is really a flat string in a cons string). If that is not
3100
- // the case we would rather go to the runtime system now to flatten
3101
- // the string.
3102
- __ CompareRoot(FieldOperand(string, ConsString::kSecondOffset),
3103
- Heap::kEmptyStringRootIndex);
3104
- __ j(not_equal, deferred->entry());
3105
- // Get the first of the two strings and load its instance type.
3106
- __ movq(string, FieldOperand(string, ConsString::kFirstOffset));
3107
- __ movq(result, FieldOperand(string, HeapObject::kMapOffset));
3108
- __ movzxbl(result, FieldOperand(result, Map::kInstanceTypeOffset));
3109
- // If the first cons component is also non-flat, then go to runtime.
3110
- STATIC_ASSERT(kSeqStringTag == 0);
3111
- __ testb(result, Immediate(kStringRepresentationMask));
3112
- __ j(not_zero, deferred->entry());
3113
-
3114
- // Check for ASCII or two-byte string.
3115
- __ bind(&flat_string);
3116
- STATIC_ASSERT(kAsciiStringTag != 0);
3117
- __ testb(result, Immediate(kStringEncodingMask));
3118
- __ j(not_zero, &ascii_string);
3119
-
3120
- // Two-byte string.
3121
- // Load the two-byte character code into the result register.
3122
- STATIC_ASSERT(kSmiTag == 0 && kSmiTagSize == 1);
3123
- if (instr->index()->IsConstantOperand()) {
3124
- __ movzxwl(result,
3125
- FieldOperand(string,
3126
- SeqTwoByteString::kHeaderSize +
3127
- (kUC16Size * const_index)));
3128
- } else {
3129
- __ movzxwl(result, FieldOperand(string,
3130
- index,
3131
- times_2,
3132
- SeqTwoByteString::kHeaderSize));
3133
- }
3134
- __ jmp(&done);
3135
-
3136
- // ASCII string.
3137
- // Load the byte into the result register.
3138
- __ bind(&ascii_string);
3139
- if (instr->index()->IsConstantOperand()) {
3140
- __ movzxbl(result, FieldOperand(string,
3141
- SeqAsciiString::kHeaderSize + const_index));
3142
- } else {
3143
- __ movzxbl(result, FieldOperand(string,
3144
- index,
3145
- times_1,
3146
- SeqAsciiString::kHeaderSize));
3147
- }
3148
- __ bind(&done);
3149
- __ bind(deferred->exit());
3150
- }
3151
-
3152
-
3153
- void LCodeGen::DoDeferredStringCharCodeAt(LStringCharCodeAt* instr) {
3154
- Register string = ToRegister(instr->string());
3155
- Register result = ToRegister(instr->result());
3156
-
3157
- // TODO(3095996): Get rid of this. For now, we need to make the
3158
- // result register contain a valid pointer because it is already
3159
- // contained in the register pointer map.
3160
- __ Set(result, 0);
3161
-
3162
- __ PushSafepointRegisters();
3163
- __ push(string);
3164
- // Push the index as a smi. This is safe because of the checks in
3165
- // DoStringCharCodeAt above.
3166
- STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue);
3167
- if (instr->index()->IsConstantOperand()) {
3168
- int const_index = ToInteger32(LConstantOperand::cast(instr->index()));
3169
- __ Push(Smi::FromInt(const_index));
3170
- } else {
3171
- Register index = ToRegister(instr->index());
3172
- __ Integer32ToSmi(index, index);
3173
- __ push(index);
3174
- }
3175
- __ movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset));
3176
- __ CallRuntimeSaveDoubles(Runtime::kStringCharCodeAt);
3177
- RecordSafepointWithRegisters(
3178
- instr->pointer_map(), 2, Safepoint::kNoDeoptimizationIndex);
3179
- if (FLAG_debug_code) {
3180
- __ AbortIfNotSmi(rax);
3181
- }
3182
- __ SmiToInteger32(rax, rax);
3183
- __ StoreToSafepointRegisterSlot(result, rax);
3184
- __ PopSafepointRegisters();
3185
- }
3186
-
3187
-
3188
- void LCodeGen::DoStringCharFromCode(LStringCharFromCode* instr) {
3189
- class DeferredStringCharFromCode: public LDeferredCode {
3190
- public:
3191
- DeferredStringCharFromCode(LCodeGen* codegen, LStringCharFromCode* instr)
3192
- : LDeferredCode(codegen), instr_(instr) { }
3193
- virtual void Generate() { codegen()->DoDeferredStringCharFromCode(instr_); }
3194
- private:
3195
- LStringCharFromCode* instr_;
3196
- };
3197
-
3198
- DeferredStringCharFromCode* deferred =
3199
- new DeferredStringCharFromCode(this, instr);
3200
-
3201
- ASSERT(instr->hydrogen()->value()->representation().IsInteger32());
3202
- Register char_code = ToRegister(instr->char_code());
3203
- Register result = ToRegister(instr->result());
3204
- ASSERT(!char_code.is(result));
3205
-
3206
- __ cmpl(char_code, Immediate(String::kMaxAsciiCharCode));
3207
- __ j(above, deferred->entry());
3208
- __ LoadRoot(result, Heap::kSingleCharacterStringCacheRootIndex);
3209
- __ movq(result, FieldOperand(result,
3210
- char_code, times_pointer_size,
3211
- FixedArray::kHeaderSize));
3212
- __ CompareRoot(result, Heap::kUndefinedValueRootIndex);
3213
- __ j(equal, deferred->entry());
3214
- __ bind(deferred->exit());
3215
- }
3216
-
3217
-
3218
- void LCodeGen::DoDeferredStringCharFromCode(LStringCharFromCode* instr) {
3219
- Register char_code = ToRegister(instr->char_code());
3220
- Register result = ToRegister(instr->result());
3221
-
3222
- // TODO(3095996): Get rid of this. For now, we need to make the
3223
- // result register contain a valid pointer because it is already
3224
- // contained in the register pointer map.
3225
- __ Set(result, 0);
3226
-
3227
- __ PushSafepointRegisters();
3228
- __ Integer32ToSmi(char_code, char_code);
3229
- __ push(char_code);
3230
- __ CallRuntimeSaveDoubles(Runtime::kCharFromCode);
3231
- RecordSafepointWithRegisters(
3232
- instr->pointer_map(), 1, Safepoint::kNoDeoptimizationIndex);
3233
- __ StoreToSafepointRegisterSlot(result, rax);
3234
- __ PopSafepointRegisters();
3235
- }
3236
-
3237
-
3238
- void LCodeGen::DoStringLength(LStringLength* instr) {
3239
- Register string = ToRegister(instr->string());
3240
- Register result = ToRegister(instr->result());
3241
- __ movq(result, FieldOperand(string, String::kLengthOffset));
3242
- }
3243
-
3244
-
3245
- void LCodeGen::DoInteger32ToDouble(LInteger32ToDouble* instr) {
3246
- LOperand* input = instr->InputAt(0);
3247
- ASSERT(input->IsRegister() || input->IsStackSlot());
3248
- LOperand* output = instr->result();
3249
- ASSERT(output->IsDoubleRegister());
3250
- if (input->IsRegister()) {
3251
- __ cvtlsi2sd(ToDoubleRegister(output), ToRegister(input));
3252
- } else {
3253
- __ cvtlsi2sd(ToDoubleRegister(output), ToOperand(input));
3254
- }
3255
- }
3256
-
3257
-
3258
- void LCodeGen::DoNumberTagI(LNumberTagI* instr) {
3259
- LOperand* input = instr->InputAt(0);
3260
- ASSERT(input->IsRegister() && input->Equals(instr->result()));
3261
- Register reg = ToRegister(input);
3262
-
3263
- __ Integer32ToSmi(reg, reg);
3264
- }
3265
-
3266
-
3267
- void LCodeGen::DoNumberTagD(LNumberTagD* instr) {
3268
- class DeferredNumberTagD: public LDeferredCode {
3269
- public:
3270
- DeferredNumberTagD(LCodeGen* codegen, LNumberTagD* instr)
3271
- : LDeferredCode(codegen), instr_(instr) { }
3272
- virtual void Generate() { codegen()->DoDeferredNumberTagD(instr_); }
3273
- private:
3274
- LNumberTagD* instr_;
3275
- };
3276
-
3277
- XMMRegister input_reg = ToDoubleRegister(instr->InputAt(0));
3278
- Register reg = ToRegister(instr->result());
3279
- Register tmp = ToRegister(instr->TempAt(0));
3280
-
3281
- DeferredNumberTagD* deferred = new DeferredNumberTagD(this, instr);
3282
- if (FLAG_inline_new) {
3283
- __ AllocateHeapNumber(reg, tmp, deferred->entry());
3284
- } else {
3285
- __ jmp(deferred->entry());
3286
- }
3287
- __ bind(deferred->exit());
3288
- __ movsd(FieldOperand(reg, HeapNumber::kValueOffset), input_reg);
3289
- }
3290
-
3291
-
3292
- void LCodeGen::DoDeferredNumberTagD(LNumberTagD* instr) {
3293
- // TODO(3095996): Get rid of this. For now, we need to make the
3294
- // result register contain a valid pointer because it is already
3295
- // contained in the register pointer map.
3296
- Register reg = ToRegister(instr->result());
3297
- __ Move(reg, Smi::FromInt(0));
3298
-
3299
- __ PushSafepointRegisters();
3300
- __ CallRuntimeSaveDoubles(Runtime::kAllocateHeapNumber);
3301
- RecordSafepointWithRegisters(
3302
- instr->pointer_map(), 0, Safepoint::kNoDeoptimizationIndex);
3303
- // Ensure that value in rax survives popping registers.
3304
- __ movq(kScratchRegister, rax);
3305
- __ PopSafepointRegisters();
3306
- __ movq(reg, kScratchRegister);
3307
- }
3308
-
3309
-
3310
- void LCodeGen::DoSmiTag(LSmiTag* instr) {
3311
- ASSERT(instr->InputAt(0)->Equals(instr->result()));
3312
- Register input = ToRegister(instr->InputAt(0));
3313
- ASSERT(!instr->hydrogen_value()->CheckFlag(HValue::kCanOverflow));
3314
- __ Integer32ToSmi(input, input);
3315
- }
3316
-
3317
-
3318
- void LCodeGen::DoSmiUntag(LSmiUntag* instr) {
3319
- ASSERT(instr->InputAt(0)->Equals(instr->result()));
3320
- Register input = ToRegister(instr->InputAt(0));
3321
- if (instr->needs_check()) {
3322
- Condition is_smi = __ CheckSmi(input);
3323
- DeoptimizeIf(NegateCondition(is_smi), instr->environment());
3324
- }
3325
- __ SmiToInteger32(input, input);
3326
- }
3327
-
3328
-
3329
- void LCodeGen::EmitNumberUntagD(Register input_reg,
3330
- XMMRegister result_reg,
3331
- LEnvironment* env) {
3332
- NearLabel load_smi, heap_number, done;
3333
-
3334
- // Smi check.
3335
- __ JumpIfSmi(input_reg, &load_smi);
3336
-
3337
- // Heap number map check.
3338
- __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset),
3339
- Heap::kHeapNumberMapRootIndex);
3340
- __ j(equal, &heap_number);
3341
-
3342
- __ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex);
3343
- DeoptimizeIf(not_equal, env);
3344
-
3345
- // Convert undefined to NaN. Compute NaN as 0/0.
3346
- __ xorpd(result_reg, result_reg);
3347
- __ divsd(result_reg, result_reg);
3348
- __ jmp(&done);
3349
-
3350
- // Heap number to XMM conversion.
3351
- __ bind(&heap_number);
3352
- __ movsd(result_reg, FieldOperand(input_reg, HeapNumber::kValueOffset));
3353
- __ jmp(&done);
3354
-
3355
- // Smi to XMM conversion
3356
- __ bind(&load_smi);
3357
- __ SmiToInteger32(kScratchRegister, input_reg);
3358
- __ cvtlsi2sd(result_reg, kScratchRegister);
3359
- __ bind(&done);
3360
- }
3361
-
3362
-
3363
- class DeferredTaggedToI: public LDeferredCode {
3364
- public:
3365
- DeferredTaggedToI(LCodeGen* codegen, LTaggedToI* instr)
3366
- : LDeferredCode(codegen), instr_(instr) { }
3367
- virtual void Generate() { codegen()->DoDeferredTaggedToI(instr_); }
3368
- private:
3369
- LTaggedToI* instr_;
3370
- };
3371
-
3372
-
3373
- void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr) {
3374
- NearLabel done, heap_number;
3375
- Register input_reg = ToRegister(instr->InputAt(0));
3376
-
3377
- // Heap number map check.
3378
- __ CompareRoot(FieldOperand(input_reg, HeapObject::kMapOffset),
3379
- Heap::kHeapNumberMapRootIndex);
3380
-
3381
- if (instr->truncating()) {
3382
- __ j(equal, &heap_number);
3383
- // Check for undefined. Undefined is converted to zero for truncating
3384
- // conversions.
3385
- __ CompareRoot(input_reg, Heap::kUndefinedValueRootIndex);
3386
- DeoptimizeIf(not_equal, instr->environment());
3387
- __ movl(input_reg, Immediate(0));
3388
- __ jmp(&done);
3389
-
3390
- __ bind(&heap_number);
3391
-
3392
- __ movsd(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset));
3393
- __ cvttsd2siq(input_reg, xmm0);
3394
- __ Set(kScratchRegister, V8_UINT64_C(0x8000000000000000));
3395
- __ cmpl(input_reg, kScratchRegister);
3396
- DeoptimizeIf(equal, instr->environment());
3397
- } else {
3398
- // Deoptimize if we don't have a heap number.
3399
- DeoptimizeIf(not_equal, instr->environment());
3400
-
3401
- XMMRegister xmm_temp = ToDoubleRegister(instr->TempAt(0));
3402
- __ movsd(xmm0, FieldOperand(input_reg, HeapNumber::kValueOffset));
3403
- __ cvttsd2si(input_reg, xmm0);
3404
- __ cvtlsi2sd(xmm_temp, input_reg);
3405
- __ ucomisd(xmm0, xmm_temp);
3406
- DeoptimizeIf(not_equal, instr->environment());
3407
- DeoptimizeIf(parity_even, instr->environment()); // NaN.
3408
- if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
3409
- __ testl(input_reg, input_reg);
3410
- __ j(not_zero, &done);
3411
- __ movmskpd(input_reg, xmm0);
3412
- __ andl(input_reg, Immediate(1));
3413
- DeoptimizeIf(not_zero, instr->environment());
3414
- }
3415
- }
3416
- __ bind(&done);
3417
- }
3418
-
3419
-
3420
- void LCodeGen::DoTaggedToI(LTaggedToI* instr) {
3421
- LOperand* input = instr->InputAt(0);
3422
- ASSERT(input->IsRegister());
3423
- ASSERT(input->Equals(instr->result()));
3424
-
3425
- Register input_reg = ToRegister(input);
3426
- DeferredTaggedToI* deferred = new DeferredTaggedToI(this, instr);
3427
- __ JumpIfNotSmi(input_reg, deferred->entry());
3428
- __ SmiToInteger32(input_reg, input_reg);
3429
- __ bind(deferred->exit());
3430
- }
3431
-
3432
-
3433
- void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) {
3434
- LOperand* input = instr->InputAt(0);
3435
- ASSERT(input->IsRegister());
3436
- LOperand* result = instr->result();
3437
- ASSERT(result->IsDoubleRegister());
3438
-
3439
- Register input_reg = ToRegister(input);
3440
- XMMRegister result_reg = ToDoubleRegister(result);
3441
-
3442
- EmitNumberUntagD(input_reg, result_reg, instr->environment());
3443
- }
3444
-
3445
-
3446
- void LCodeGen::DoDoubleToI(LDoubleToI* instr) {
3447
- LOperand* input = instr->InputAt(0);
3448
- ASSERT(input->IsDoubleRegister());
3449
- LOperand* result = instr->result();
3450
- ASSERT(result->IsRegister());
3451
-
3452
- XMMRegister input_reg = ToDoubleRegister(input);
3453
- Register result_reg = ToRegister(result);
3454
-
3455
- if (instr->truncating()) {
3456
- // Performs a truncating conversion of a floating point number as used by
3457
- // the JS bitwise operations.
3458
- __ cvttsd2siq(result_reg, input_reg);
3459
- __ movq(kScratchRegister, V8_INT64_C(0x8000000000000000), RelocInfo::NONE);
3460
- __ cmpl(result_reg, kScratchRegister);
3461
- DeoptimizeIf(equal, instr->environment());
3462
- } else {
3463
- __ cvttsd2si(result_reg, input_reg);
3464
- __ cvtlsi2sd(xmm0, result_reg);
3465
- __ ucomisd(xmm0, input_reg);
3466
- DeoptimizeIf(not_equal, instr->environment());
3467
- DeoptimizeIf(parity_even, instr->environment()); // NaN.
3468
- if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
3469
- NearLabel done;
3470
- // The integer converted back is equal to the original. We
3471
- // only have to test if we got -0 as an input.
3472
- __ testl(result_reg, result_reg);
3473
- __ j(not_zero, &done);
3474
- __ movmskpd(result_reg, input_reg);
3475
- // Bit 0 contains the sign of the double in input_reg.
3476
- // If input was positive, we are ok and return 0, otherwise
3477
- // deoptimize.
3478
- __ andl(result_reg, Immediate(1));
3479
- DeoptimizeIf(not_zero, instr->environment());
3480
- __ bind(&done);
3481
- }
3482
- }
3483
- }
3484
-
3485
-
3486
- void LCodeGen::DoCheckSmi(LCheckSmi* instr) {
3487
- LOperand* input = instr->InputAt(0);
3488
- Condition cc = masm()->CheckSmi(ToRegister(input));
3489
- DeoptimizeIf(NegateCondition(cc), instr->environment());
3490
- }
3491
-
3492
-
3493
- void LCodeGen::DoCheckNonSmi(LCheckNonSmi* instr) {
3494
- LOperand* input = instr->InputAt(0);
3495
- Condition cc = masm()->CheckSmi(ToRegister(input));
3496
- DeoptimizeIf(cc, instr->environment());
3497
- }
3498
-
3499
-
3500
- void LCodeGen::DoCheckInstanceType(LCheckInstanceType* instr) {
3501
- Register input = ToRegister(instr->InputAt(0));
3502
- InstanceType first = instr->hydrogen()->first();
3503
- InstanceType last = instr->hydrogen()->last();
3504
-
3505
- __ movq(kScratchRegister, FieldOperand(input, HeapObject::kMapOffset));
3506
-
3507
- // If there is only one type in the interval check for equality.
3508
- if (first == last) {
3509
- __ cmpb(FieldOperand(kScratchRegister, Map::kInstanceTypeOffset),
3510
- Immediate(static_cast<int8_t>(first)));
3511
- DeoptimizeIf(not_equal, instr->environment());
3512
- } else if (first == FIRST_STRING_TYPE && last == LAST_STRING_TYPE) {
3513
- // String has a dedicated bit in instance type.
3514
- __ testb(FieldOperand(kScratchRegister, Map::kInstanceTypeOffset),
3515
- Immediate(kIsNotStringMask));
3516
- DeoptimizeIf(not_zero, instr->environment());
3517
- } else {
3518
- __ cmpb(FieldOperand(kScratchRegister, Map::kInstanceTypeOffset),
3519
- Immediate(static_cast<int8_t>(first)));
3520
- DeoptimizeIf(below, instr->environment());
3521
- // Omit check for the last type.
3522
- if (last != LAST_TYPE) {
3523
- __ cmpb(FieldOperand(kScratchRegister, Map::kInstanceTypeOffset),
3524
- Immediate(static_cast<int8_t>(last)));
3525
- DeoptimizeIf(above, instr->environment());
3526
- }
3527
- }
3528
- }
3529
-
3530
-
3531
- void LCodeGen::DoCheckFunction(LCheckFunction* instr) {
3532
- ASSERT(instr->InputAt(0)->IsRegister());
3533
- Register reg = ToRegister(instr->InputAt(0));
3534
- __ Cmp(reg, instr->hydrogen()->target());
3535
- DeoptimizeIf(not_equal, instr->environment());
3536
- }
3537
-
3538
-
3539
- void LCodeGen::DoCheckMap(LCheckMap* instr) {
3540
- LOperand* input = instr->InputAt(0);
3541
- ASSERT(input->IsRegister());
3542
- Register reg = ToRegister(input);
3543
- __ Cmp(FieldOperand(reg, HeapObject::kMapOffset),
3544
- instr->hydrogen()->map());
3545
- DeoptimizeIf(not_equal, instr->environment());
3546
- }
3547
-
3548
-
3549
- void LCodeGen::LoadHeapObject(Register result, Handle<HeapObject> object) {
3550
- if (heap()->InNewSpace(*object)) {
3551
- Handle<JSGlobalPropertyCell> cell =
3552
- factory()->NewJSGlobalPropertyCell(object);
3553
- __ movq(result, cell, RelocInfo::GLOBAL_PROPERTY_CELL);
3554
- __ movq(result, Operand(result, 0));
3555
- } else {
3556
- __ Move(result, object);
3557
- }
3558
- }
3559
-
3560
-
3561
- void LCodeGen::DoCheckPrototypeMaps(LCheckPrototypeMaps* instr) {
3562
- Register reg = ToRegister(instr->TempAt(0));
3563
-
3564
- Handle<JSObject> holder = instr->holder();
3565
- Handle<JSObject> current_prototype = instr->prototype();
3566
-
3567
- // Load prototype object.
3568
- LoadHeapObject(reg, current_prototype);
3569
-
3570
- // Check prototype maps up to the holder.
3571
- while (!current_prototype.is_identical_to(holder)) {
3572
- __ Cmp(FieldOperand(reg, HeapObject::kMapOffset),
3573
- Handle<Map>(current_prototype->map()));
3574
- DeoptimizeIf(not_equal, instr->environment());
3575
- current_prototype =
3576
- Handle<JSObject>(JSObject::cast(current_prototype->GetPrototype()));
3577
- // Load next prototype object.
3578
- LoadHeapObject(reg, current_prototype);
3579
- }
3580
-
3581
- // Check the holder map.
3582
- __ Cmp(FieldOperand(reg, HeapObject::kMapOffset),
3583
- Handle<Map>(current_prototype->map()));
3584
- DeoptimizeIf(not_equal, instr->environment());
3585
- }
3586
-
3587
-
3588
- void LCodeGen::DoArrayLiteral(LArrayLiteral* instr) {
3589
- // Setup the parameters to the stub/runtime call.
3590
- __ movq(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
3591
- __ push(FieldOperand(rax, JSFunction::kLiteralsOffset));
3592
- __ Push(Smi::FromInt(instr->hydrogen()->literal_index()));
3593
- __ Push(instr->hydrogen()->constant_elements());
3594
-
3595
- // Pick the right runtime function or stub to call.
3596
- int length = instr->hydrogen()->length();
3597
- if (instr->hydrogen()->IsCopyOnWrite()) {
3598
- ASSERT(instr->hydrogen()->depth() == 1);
3599
- FastCloneShallowArrayStub::Mode mode =
3600
- FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS;
3601
- FastCloneShallowArrayStub stub(mode, length);
3602
- CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
3603
- } else if (instr->hydrogen()->depth() > 1) {
3604
- CallRuntime(Runtime::kCreateArrayLiteral, 3, instr);
3605
- } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) {
3606
- CallRuntime(Runtime::kCreateArrayLiteralShallow, 3, instr);
3607
- } else {
3608
- FastCloneShallowArrayStub::Mode mode =
3609
- FastCloneShallowArrayStub::CLONE_ELEMENTS;
3610
- FastCloneShallowArrayStub stub(mode, length);
3611
- CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
3612
- }
3613
- }
3614
-
3615
-
3616
- void LCodeGen::DoObjectLiteral(LObjectLiteral* instr) {
3617
- // Setup the parameters to the stub/runtime call.
3618
- __ movq(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
3619
- __ push(FieldOperand(rax, JSFunction::kLiteralsOffset));
3620
- __ Push(Smi::FromInt(instr->hydrogen()->literal_index()));
3621
- __ Push(instr->hydrogen()->constant_properties());
3622
- __ Push(Smi::FromInt(instr->hydrogen()->fast_elements() ? 1 : 0));
3623
-
3624
- // Pick the right runtime function to call.
3625
- if (instr->hydrogen()->depth() > 1) {
3626
- CallRuntime(Runtime::kCreateObjectLiteral, 4, instr);
3627
- } else {
3628
- CallRuntime(Runtime::kCreateObjectLiteralShallow, 4, instr);
3629
- }
3630
- }
3631
-
3632
-
3633
- void LCodeGen::DoToFastProperties(LToFastProperties* instr) {
3634
- ASSERT(ToRegister(instr->InputAt(0)).is(rax));
3635
- __ push(rax);
3636
- CallRuntime(Runtime::kToFastProperties, 1, instr);
3637
- }
3638
-
3639
-
3640
- void LCodeGen::DoRegExpLiteral(LRegExpLiteral* instr) {
3641
- NearLabel materialized;
3642
- // Registers will be used as follows:
3643
- // rdi = JS function.
3644
- // rcx = literals array.
3645
- // rbx = regexp literal.
3646
- // rax = regexp literal clone.
3647
- __ movq(rdi, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset));
3648
- __ movq(rcx, FieldOperand(rdi, JSFunction::kLiteralsOffset));
3649
- int literal_offset = FixedArray::kHeaderSize +
3650
- instr->hydrogen()->literal_index() * kPointerSize;
3651
- __ movq(rbx, FieldOperand(rcx, literal_offset));
3652
- __ CompareRoot(rbx, Heap::kUndefinedValueRootIndex);
3653
- __ j(not_equal, &materialized);
3654
-
3655
- // Create regexp literal using runtime function
3656
- // Result will be in rax.
3657
- __ push(rcx);
3658
- __ Push(Smi::FromInt(instr->hydrogen()->literal_index()));
3659
- __ Push(instr->hydrogen()->pattern());
3660
- __ Push(instr->hydrogen()->flags());
3661
- CallRuntime(Runtime::kMaterializeRegExpLiteral, 4, instr);
3662
- __ movq(rbx, rax);
3663
-
3664
- __ bind(&materialized);
3665
- int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
3666
- Label allocated, runtime_allocate;
3667
- __ AllocateInNewSpace(size, rax, rcx, rdx, &runtime_allocate, TAG_OBJECT);
3668
- __ jmp(&allocated);
3669
-
3670
- __ bind(&runtime_allocate);
3671
- __ push(rbx);
3672
- __ Push(Smi::FromInt(size));
3673
- CallRuntime(Runtime::kAllocateInNewSpace, 1, instr);
3674
- __ pop(rbx);
3675
-
3676
- __ bind(&allocated);
3677
- // Copy the content into the newly allocated memory.
3678
- // (Unroll copy loop once for better throughput).
3679
- for (int i = 0; i < size - kPointerSize; i += 2 * kPointerSize) {
3680
- __ movq(rdx, FieldOperand(rbx, i));
3681
- __ movq(rcx, FieldOperand(rbx, i + kPointerSize));
3682
- __ movq(FieldOperand(rax, i), rdx);
3683
- __ movq(FieldOperand(rax, i + kPointerSize), rcx);
3684
- }
3685
- if ((size % (2 * kPointerSize)) != 0) {
3686
- __ movq(rdx, FieldOperand(rbx, size - kPointerSize));
3687
- __ movq(FieldOperand(rax, size - kPointerSize), rdx);
3688
- }
3689
- }
3690
-
3691
-
3692
- void LCodeGen::DoFunctionLiteral(LFunctionLiteral* instr) {
3693
- // Use the fast case closure allocation code that allocates in new
3694
- // space for nested functions that don't need literals cloning.
3695
- Handle<SharedFunctionInfo> shared_info = instr->shared_info();
3696
- bool pretenure = instr->hydrogen()->pretenure();
3697
- if (!pretenure && shared_info->num_literals() == 0) {
3698
- FastNewClosureStub stub(
3699
- shared_info->strict_mode() ? kStrictMode : kNonStrictMode);
3700
- __ Push(shared_info);
3701
- CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
3702
- } else {
3703
- __ push(rsi);
3704
- __ Push(shared_info);
3705
- __ PushRoot(pretenure ?
3706
- Heap::kTrueValueRootIndex :
3707
- Heap::kFalseValueRootIndex);
3708
- CallRuntime(Runtime::kNewClosure, 3, instr);
3709
- }
3710
- }
3711
-
3712
-
3713
- void LCodeGen::DoTypeof(LTypeof* instr) {
3714
- LOperand* input = instr->InputAt(0);
3715
- if (input->IsConstantOperand()) {
3716
- __ Push(ToHandle(LConstantOperand::cast(input)));
3717
- } else if (input->IsRegister()) {
3718
- __ push(ToRegister(input));
3719
- } else {
3720
- ASSERT(input->IsStackSlot());
3721
- __ push(ToOperand(input));
3722
- }
3723
- CallRuntime(Runtime::kTypeof, 1, instr);
3724
- }
3725
-
3726
-
3727
- void LCodeGen::DoTypeofIs(LTypeofIs* instr) {
3728
- Register input = ToRegister(instr->InputAt(0));
3729
- Register result = ToRegister(instr->result());
3730
- Label true_label;
3731
- Label false_label;
3732
- NearLabel done;
3733
-
3734
- Condition final_branch_condition = EmitTypeofIs(&true_label,
3735
- &false_label,
3736
- input,
3737
- instr->type_literal());
3738
- __ j(final_branch_condition, &true_label);
3739
- __ bind(&false_label);
3740
- __ LoadRoot(result, Heap::kFalseValueRootIndex);
3741
- __ jmp(&done);
3742
-
3743
- __ bind(&true_label);
3744
- __ LoadRoot(result, Heap::kTrueValueRootIndex);
3745
-
3746
- __ bind(&done);
3747
- }
3748
-
3749
-
3750
- void LCodeGen::EmitPushConstantOperand(LOperand* operand) {
3751
- ASSERT(operand->IsConstantOperand());
3752
- LConstantOperand* const_op = LConstantOperand::cast(operand);
3753
- Handle<Object> literal = chunk_->LookupLiteral(const_op);
3754
- Representation r = chunk_->LookupLiteralRepresentation(const_op);
3755
- if (r.IsInteger32()) {
3756
- ASSERT(literal->IsNumber());
3757
- __ push(Immediate(static_cast<int32_t>(literal->Number())));
3758
- } else if (r.IsDouble()) {
3759
- Abort("unsupported double immediate");
3760
- } else {
3761
- ASSERT(r.IsTagged());
3762
- __ Push(literal);
3763
- }
3764
- }
3765
-
3766
-
3767
- void LCodeGen::DoTypeofIsAndBranch(LTypeofIsAndBranch* instr) {
3768
- Register input = ToRegister(instr->InputAt(0));
3769
- int true_block = chunk_->LookupDestination(instr->true_block_id());
3770
- int false_block = chunk_->LookupDestination(instr->false_block_id());
3771
- Label* true_label = chunk_->GetAssemblyLabel(true_block);
3772
- Label* false_label = chunk_->GetAssemblyLabel(false_block);
3773
-
3774
- Condition final_branch_condition = EmitTypeofIs(true_label,
3775
- false_label,
3776
- input,
3777
- instr->type_literal());
3778
-
3779
- EmitBranch(true_block, false_block, final_branch_condition);
3780
- }
3781
-
3782
-
3783
- Condition LCodeGen::EmitTypeofIs(Label* true_label,
3784
- Label* false_label,
3785
- Register input,
3786
- Handle<String> type_name) {
3787
- Condition final_branch_condition = no_condition;
3788
- if (type_name->Equals(heap()->number_symbol())) {
3789
- __ JumpIfSmi(input, true_label);
3790
- __ CompareRoot(FieldOperand(input, HeapObject::kMapOffset),
3791
- Heap::kHeapNumberMapRootIndex);
3792
-
3793
- final_branch_condition = equal;
3794
-
3795
- } else if (type_name->Equals(heap()->string_symbol())) {
3796
- __ JumpIfSmi(input, false_label);
3797
- __ CmpObjectType(input, FIRST_NONSTRING_TYPE, input);
3798
- __ j(above_equal, false_label);
3799
- __ testb(FieldOperand(input, Map::kBitFieldOffset),
3800
- Immediate(1 << Map::kIsUndetectable));
3801
- final_branch_condition = zero;
3802
-
3803
- } else if (type_name->Equals(heap()->boolean_symbol())) {
3804
- __ CompareRoot(input, Heap::kTrueValueRootIndex);
3805
- __ j(equal, true_label);
3806
- __ CompareRoot(input, Heap::kFalseValueRootIndex);
3807
- final_branch_condition = equal;
3808
-
3809
- } else if (type_name->Equals(heap()->undefined_symbol())) {
3810
- __ CompareRoot(input, Heap::kUndefinedValueRootIndex);
3811
- __ j(equal, true_label);
3812
- __ JumpIfSmi(input, false_label);
3813
- // Check for undetectable objects => true.
3814
- __ movq(input, FieldOperand(input, HeapObject::kMapOffset));
3815
- __ testb(FieldOperand(input, Map::kBitFieldOffset),
3816
- Immediate(1 << Map::kIsUndetectable));
3817
- final_branch_condition = not_zero;
3818
-
3819
- } else if (type_name->Equals(heap()->function_symbol())) {
3820
- __ JumpIfSmi(input, false_label);
3821
- __ CmpObjectType(input, FIRST_FUNCTION_CLASS_TYPE, input);
3822
- final_branch_condition = above_equal;
3823
-
3824
- } else if (type_name->Equals(heap()->object_symbol())) {
3825
- __ JumpIfSmi(input, false_label);
3826
- __ CompareRoot(input, Heap::kNullValueRootIndex);
3827
- __ j(equal, true_label);
3828
- __ CmpObjectType(input, FIRST_JS_OBJECT_TYPE, input);
3829
- __ j(below, false_label);
3830
- __ CmpInstanceType(input, FIRST_FUNCTION_CLASS_TYPE);
3831
- __ j(above_equal, false_label);
3832
- // Check for undetectable objects => false.
3833
- __ testb(FieldOperand(input, Map::kBitFieldOffset),
3834
- Immediate(1 << Map::kIsUndetectable));
3835
- final_branch_condition = zero;
3836
-
3837
- } else {
3838
- final_branch_condition = never;
3839
- __ jmp(false_label);
3840
- }
3841
-
3842
- return final_branch_condition;
3843
- }
3844
-
3845
-
3846
- void LCodeGen::DoIsConstructCall(LIsConstructCall* instr) {
3847
- Register result = ToRegister(instr->result());
3848
- NearLabel true_label;
3849
- NearLabel false_label;
3850
- NearLabel done;
3851
-
3852
- EmitIsConstructCall(result);
3853
- __ j(equal, &true_label);
3854
-
3855
- __ LoadRoot(result, Heap::kFalseValueRootIndex);
3856
- __ jmp(&done);
3857
-
3858
- __ bind(&true_label);
3859
- __ LoadRoot(result, Heap::kTrueValueRootIndex);
3860
-
3861
-
3862
- __ bind(&done);
3863
- }
3864
-
3865
-
3866
- void LCodeGen::DoIsConstructCallAndBranch(LIsConstructCallAndBranch* instr) {
3867
- Register temp = ToRegister(instr->TempAt(0));
3868
- int true_block = chunk_->LookupDestination(instr->true_block_id());
3869
- int false_block = chunk_->LookupDestination(instr->false_block_id());
3870
-
3871
- EmitIsConstructCall(temp);
3872
- EmitBranch(true_block, false_block, equal);
3873
- }
3874
-
3875
-
3876
- void LCodeGen::EmitIsConstructCall(Register temp) {
3877
- // Get the frame pointer for the calling frame.
3878
- __ movq(temp, Operand(rbp, StandardFrameConstants::kCallerFPOffset));
3879
-
3880
- // Skip the arguments adaptor frame if it exists.
3881
- NearLabel check_frame_marker;
3882
- __ Cmp(Operand(temp, StandardFrameConstants::kContextOffset),
3883
- Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR));
3884
- __ j(not_equal, &check_frame_marker);
3885
- __ movq(temp, Operand(rax, StandardFrameConstants::kCallerFPOffset));
3886
-
3887
- // Check the marker in the calling frame.
3888
- __ bind(&check_frame_marker);
3889
- __ Cmp(Operand(temp, StandardFrameConstants::kMarkerOffset),
3890
- Smi::FromInt(StackFrame::CONSTRUCT));
3891
- }
3892
-
3893
-
3894
- void LCodeGen::DoLazyBailout(LLazyBailout* instr) {
3895
- // No code for lazy bailout instruction. Used to capture environment after a
3896
- // call for populating the safepoint data with deoptimization data.
3897
- }
3898
-
3899
-
3900
- void LCodeGen::DoDeoptimize(LDeoptimize* instr) {
3901
- DeoptimizeIf(no_condition, instr->environment());
3902
- }
3903
-
3904
-
3905
- void LCodeGen::DoDeleteProperty(LDeleteProperty* instr) {
3906
- LOperand* obj = instr->object();
3907
- LOperand* key = instr->key();
3908
- // Push object.
3909
- if (obj->IsRegister()) {
3910
- __ push(ToRegister(obj));
3911
- } else {
3912
- __ push(ToOperand(obj));
3913
- }
3914
- // Push key.
3915
- if (key->IsConstantOperand()) {
3916
- EmitPushConstantOperand(key);
3917
- } else if (key->IsRegister()) {
3918
- __ push(ToRegister(key));
3919
- } else {
3920
- __ push(ToOperand(key));
3921
- }
3922
- ASSERT(instr->HasPointerMap() && instr->HasDeoptimizationEnvironment());
3923
- LPointerMap* pointers = instr->pointer_map();
3924
- LEnvironment* env = instr->deoptimization_environment();
3925
- RecordPosition(pointers->position());
3926
- RegisterEnvironmentForDeoptimization(env);
3927
- // Create safepoint generator that will also ensure enough space in the
3928
- // reloc info for patching in deoptimization (since this is invoking a
3929
- // builtin)
3930
- SafepointGenerator safepoint_generator(this,
3931
- pointers,
3932
- env->deoptimization_index());
3933
- __ Push(Smi::FromInt(strict_mode_flag()));
3934
- __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION, &safepoint_generator);
3935
- }
3936
-
3937
-
3938
- void LCodeGen::DoStackCheck(LStackCheck* instr) {
3939
- // Perform stack overflow check.
3940
- NearLabel done;
3941
- __ CompareRoot(rsp, Heap::kStackLimitRootIndex);
3942
- __ j(above_equal, &done);
3943
-
3944
- StackCheckStub stub;
3945
- CallCode(stub.GetCode(), RelocInfo::CODE_TARGET, instr);
3946
- __ bind(&done);
3947
- }
3948
-
3949
-
3950
- void LCodeGen::DoOsrEntry(LOsrEntry* instr) {
3951
- // This is a pseudo-instruction that ensures that the environment here is
3952
- // properly registered for deoptimization and records the assembler's PC
3953
- // offset.
3954
- LEnvironment* environment = instr->environment();
3955
- environment->SetSpilledRegisters(instr->SpilledRegisterArray(),
3956
- instr->SpilledDoubleRegisterArray());
3957
-
3958
- // If the environment were already registered, we would have no way of
3959
- // backpatching it with the spill slot operands.
3960
- ASSERT(!environment->HasBeenRegistered());
3961
- RegisterEnvironmentForDeoptimization(environment);
3962
- ASSERT(osr_pc_offset_ == -1);
3963
- osr_pc_offset_ = masm()->pc_offset();
3964
- }
3965
-
3966
- #undef __
3967
-
3968
- } } // namespace v8::internal
3969
-
3970
- #endif // V8_TARGET_ARCH_X64