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,45 +0,0 @@
1
- // Copyright 2006-2008 the V8 project authors. All rights reserved.
2
- // Redistribution and use in source and binary forms, with or without
3
- // modification, are permitted provided that the following conditions are
4
- // met:
5
- //
6
- // * Redistributions of source code must retain the above copyright
7
- // notice, this list of conditions and the following disclaimer.
8
- // * Redistributions in binary form must reproduce the above
9
- // copyright notice, this list of conditions and the following
10
- // disclaimer in the documentation and/or other materials provided
11
- // with the distribution.
12
- // * Neither the name of Google Inc. nor the names of its
13
- // contributors may be used to endorse or promote products derived
14
- // from this software without specific prior written permission.
15
- //
16
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
- // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
- // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
- // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
- // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
- // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
- // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
- // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
- // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
- // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
- // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
-
28
- #include "v8.h"
29
-
30
- #if defined(V8_TARGET_ARCH_IA32)
31
-
32
- #include "frames-inl.h"
33
-
34
- namespace v8 {
35
- namespace internal {
36
-
37
-
38
- Address ExitFrame::ComputeStackPointer(Address fp) {
39
- return Memory::Address_at(fp + ExitFrameConstants::kSPOffset);
40
- }
41
-
42
-
43
- } } // namespace v8::internal
44
-
45
- #endif // V8_TARGET_ARCH_IA32
@@ -1,140 +0,0 @@
1
- // Copyright 2006-2008 the V8 project authors. All rights reserved.
2
- // Redistribution and use in source and binary forms, with or without
3
- // modification, are permitted provided that the following conditions are
4
- // met:
5
- //
6
- // * Redistributions of source code must retain the above copyright
7
- // notice, this list of conditions and the following disclaimer.
8
- // * Redistributions in binary form must reproduce the above
9
- // copyright notice, this list of conditions and the following
10
- // disclaimer in the documentation and/or other materials provided
11
- // with the distribution.
12
- // * Neither the name of Google Inc. nor the names of its
13
- // contributors may be used to endorse or promote products derived
14
- // from this software without specific prior written permission.
15
- //
16
- // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
- // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
- // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
- // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
- // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
- // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
- // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
- // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
- // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
- // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
- // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
-
28
- #ifndef V8_IA32_FRAMES_IA32_H_
29
- #define V8_IA32_FRAMES_IA32_H_
30
-
31
- namespace v8 {
32
- namespace internal {
33
-
34
-
35
- // Register lists
36
- // Note that the bit values must match those used in actual instruction encoding
37
- static const int kNumRegs = 8;
38
-
39
-
40
- // Caller-saved registers
41
- static const RegList kJSCallerSaved =
42
- 1 << 0 | // eax
43
- 1 << 1 | // ecx
44
- 1 << 2 | // edx
45
- 1 << 3 | // ebx - used as a caller-saved register in JavaScript code
46
- 1 << 7; // edi - callee function
47
-
48
- static const int kNumJSCallerSaved = 5;
49
-
50
- typedef Object* JSCallerSavedBuffer[kNumJSCallerSaved];
51
-
52
-
53
- // Number of registers for which space is reserved in safepoints.
54
- static const int kNumSafepointRegisters = 8;
55
-
56
- // ----------------------------------------------------
57
-
58
-
59
- class StackHandlerConstants : public AllStatic {
60
- public:
61
- static const int kNextOffset = 0 * kPointerSize;
62
- static const int kFPOffset = 1 * kPointerSize;
63
- static const int kStateOffset = 2 * kPointerSize;
64
- static const int kPCOffset = 3 * kPointerSize;
65
-
66
- static const int kSize = kPCOffset + kPointerSize;
67
- };
68
-
69
-
70
- class EntryFrameConstants : public AllStatic {
71
- public:
72
- static const int kCallerFPOffset = -6 * kPointerSize;
73
-
74
- static const int kFunctionArgOffset = +3 * kPointerSize;
75
- static const int kReceiverArgOffset = +4 * kPointerSize;
76
- static const int kArgcOffset = +5 * kPointerSize;
77
- static const int kArgvOffset = +6 * kPointerSize;
78
- };
79
-
80
-
81
- class ExitFrameConstants : public AllStatic {
82
- public:
83
- static const int kCodeOffset = -2 * kPointerSize;
84
- static const int kSPOffset = -1 * kPointerSize;
85
-
86
- static const int kCallerFPOffset = 0 * kPointerSize;
87
- static const int kCallerPCOffset = +1 * kPointerSize;
88
-
89
- // FP-relative displacement of the caller's SP. It points just
90
- // below the saved PC.
91
- static const int kCallerSPDisplacement = +2 * kPointerSize;
92
- };
93
-
94
-
95
- class StandardFrameConstants : public AllStatic {
96
- public:
97
- static const int kFixedFrameSize = 4;
98
- static const int kExpressionsOffset = -3 * kPointerSize;
99
- static const int kMarkerOffset = -2 * kPointerSize;
100
- static const int kContextOffset = -1 * kPointerSize;
101
- static const int kCallerFPOffset = 0 * kPointerSize;
102
- static const int kCallerPCOffset = +1 * kPointerSize;
103
- static const int kCallerSPOffset = +2 * kPointerSize;
104
- };
105
-
106
-
107
- class JavaScriptFrameConstants : public AllStatic {
108
- public:
109
- // FP-relative.
110
- static const int kLocal0Offset = StandardFrameConstants::kExpressionsOffset;
111
- static const int kLastParameterOffset = +2 * kPointerSize;
112
- static const int kFunctionOffset = StandardFrameConstants::kMarkerOffset;
113
-
114
- // Caller SP-relative.
115
- static const int kParam0Offset = -2 * kPointerSize;
116
- static const int kReceiverOffset = -1 * kPointerSize;
117
- };
118
-
119
-
120
- class ArgumentsAdaptorFrameConstants : public AllStatic {
121
- public:
122
- static const int kLengthOffset = StandardFrameConstants::kExpressionsOffset;
123
- };
124
-
125
-
126
- class InternalFrameConstants : public AllStatic {
127
- public:
128
- static const int kCodeOffset = StandardFrameConstants::kExpressionsOffset;
129
- };
130
-
131
-
132
- inline Object* JavaScriptFrame::function_slot_object() const {
133
- const int offset = JavaScriptFrameConstants::kFunctionOffset;
134
- return Memory::Object_at(fp() + offset);
135
- }
136
-
137
-
138
- } } // namespace v8::internal
139
-
140
- #endif // V8_IA32_FRAMES_IA32_H_
@@ -1,4357 +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_IA32)
31
-
32
- #include "code-stubs.h"
33
- #include "codegen-inl.h"
34
- #include "compiler.h"
35
- #include "debug.h"
36
- #include "full-codegen.h"
37
- #include "parser.h"
38
- #include "scopes.h"
39
- #include "stub-cache.h"
40
-
41
- namespace v8 {
42
- namespace internal {
43
-
44
-
45
- #define __ ACCESS_MASM(masm_)
46
-
47
-
48
- class JumpPatchSite BASE_EMBEDDED {
49
- public:
50
- explicit JumpPatchSite(MacroAssembler* masm) : masm_(masm) {
51
- #ifdef DEBUG
52
- info_emitted_ = false;
53
- #endif
54
- }
55
-
56
- ~JumpPatchSite() {
57
- ASSERT(patch_site_.is_bound() == info_emitted_);
58
- }
59
-
60
- void EmitJumpIfNotSmi(Register reg, NearLabel* target) {
61
- __ test(reg, Immediate(kSmiTagMask));
62
- EmitJump(not_carry, target); // Always taken before patched.
63
- }
64
-
65
- void EmitJumpIfSmi(Register reg, NearLabel* target) {
66
- __ test(reg, Immediate(kSmiTagMask));
67
- EmitJump(carry, target); // Never taken before patched.
68
- }
69
-
70
- void EmitPatchInfo() {
71
- int delta_to_patch_site = masm_->SizeOfCodeGeneratedSince(&patch_site_);
72
- ASSERT(is_int8(delta_to_patch_site));
73
- __ test(eax, Immediate(delta_to_patch_site));
74
- #ifdef DEBUG
75
- info_emitted_ = true;
76
- #endif
77
- }
78
-
79
- bool is_bound() const { return patch_site_.is_bound(); }
80
-
81
- private:
82
- // jc will be patched with jz, jnc will become jnz.
83
- void EmitJump(Condition cc, NearLabel* target) {
84
- ASSERT(!patch_site_.is_bound() && !info_emitted_);
85
- ASSERT(cc == carry || cc == not_carry);
86
- __ bind(&patch_site_);
87
- __ j(cc, target);
88
- }
89
-
90
- MacroAssembler* masm_;
91
- Label patch_site_;
92
- #ifdef DEBUG
93
- bool info_emitted_;
94
- #endif
95
- };
96
-
97
-
98
- // Generate code for a JS function. On entry to the function the receiver
99
- // and arguments have been pushed on the stack left to right, with the
100
- // return address on top of them. The actual argument count matches the
101
- // formal parameter count expected by the function.
102
- //
103
- // The live registers are:
104
- // o edi: the JS function object being called (ie, ourselves)
105
- // o esi: our context
106
- // o ebp: our caller's frame pointer
107
- // o esp: stack pointer (pointing to return address)
108
- //
109
- // The function builds a JS frame. Please see JavaScriptFrameConstants in
110
- // frames-ia32.h for its layout.
111
- void FullCodeGenerator::Generate(CompilationInfo* info) {
112
- ASSERT(info_ == NULL);
113
- info_ = info;
114
- SetFunctionPosition(function());
115
- Comment cmnt(masm_, "[ function compiled by full code generator");
116
-
117
- #ifdef DEBUG
118
- if (strlen(FLAG_stop_at) > 0 &&
119
- info->function()->name()->IsEqualTo(CStrVector(FLAG_stop_at))) {
120
- __ int3();
121
- }
122
- #endif
123
-
124
- __ push(ebp); // Caller's frame pointer.
125
- __ mov(ebp, esp);
126
- __ push(esi); // Callee's context.
127
- __ push(edi); // Callee's JS Function.
128
-
129
- { Comment cmnt(masm_, "[ Allocate locals");
130
- int locals_count = scope()->num_stack_slots();
131
- if (locals_count == 1) {
132
- __ push(Immediate(isolate()->factory()->undefined_value()));
133
- } else if (locals_count > 1) {
134
- __ mov(eax, Immediate(isolate()->factory()->undefined_value()));
135
- for (int i = 0; i < locals_count; i++) {
136
- __ push(eax);
137
- }
138
- }
139
- }
140
-
141
- bool function_in_register = true;
142
-
143
- // Possibly allocate a local context.
144
- int heap_slots = scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS;
145
- if (heap_slots > 0) {
146
- Comment cmnt(masm_, "[ Allocate local context");
147
- // Argument to NewContext is the function, which is still in edi.
148
- __ push(edi);
149
- if (heap_slots <= FastNewContextStub::kMaximumSlots) {
150
- FastNewContextStub stub(heap_slots);
151
- __ CallStub(&stub);
152
- } else {
153
- __ CallRuntime(Runtime::kNewContext, 1);
154
- }
155
- function_in_register = false;
156
- // Context is returned in both eax and esi. It replaces the context
157
- // passed to us. It's saved in the stack and kept live in esi.
158
- __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), esi);
159
-
160
- // Copy parameters into context if necessary.
161
- int num_parameters = scope()->num_parameters();
162
- for (int i = 0; i < num_parameters; i++) {
163
- Slot* slot = scope()->parameter(i)->AsSlot();
164
- if (slot != NULL && slot->type() == Slot::CONTEXT) {
165
- int parameter_offset = StandardFrameConstants::kCallerSPOffset +
166
- (num_parameters - 1 - i) * kPointerSize;
167
- // Load parameter from stack.
168
- __ mov(eax, Operand(ebp, parameter_offset));
169
- // Store it in the context.
170
- int context_offset = Context::SlotOffset(slot->index());
171
- __ mov(Operand(esi, context_offset), eax);
172
- // Update the write barrier. This clobbers all involved
173
- // registers, so we have use a third register to avoid
174
- // clobbering esi.
175
- __ mov(ecx, esi);
176
- __ RecordWrite(ecx, context_offset, eax, ebx);
177
- }
178
- }
179
- }
180
-
181
- Variable* arguments = scope()->arguments();
182
- if (arguments != NULL) {
183
- // Function uses arguments object.
184
- Comment cmnt(masm_, "[ Allocate arguments object");
185
- if (function_in_register) {
186
- __ push(edi);
187
- } else {
188
- __ push(Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
189
- }
190
- // Receiver is just before the parameters on the caller's stack.
191
- int offset = scope()->num_parameters() * kPointerSize;
192
- __ lea(edx,
193
- Operand(ebp, StandardFrameConstants::kCallerSPOffset + offset));
194
- __ push(edx);
195
- __ push(Immediate(Smi::FromInt(scope()->num_parameters())));
196
- // Arguments to ArgumentsAccessStub:
197
- // function, receiver address, parameter count.
198
- // The stub will rewrite receiver and parameter count if the previous
199
- // stack frame was an arguments adapter frame.
200
- ArgumentsAccessStub stub(
201
- is_strict_mode() ? ArgumentsAccessStub::NEW_STRICT
202
- : ArgumentsAccessStub::NEW_NON_STRICT);
203
- __ CallStub(&stub);
204
-
205
- Variable* arguments_shadow = scope()->arguments_shadow();
206
- if (arguments_shadow != NULL) {
207
- __ mov(ecx, eax); // Duplicate result.
208
- Move(arguments_shadow->AsSlot(), ecx, ebx, edx);
209
- }
210
- Move(arguments->AsSlot(), eax, ebx, edx);
211
- }
212
-
213
- if (FLAG_trace) {
214
- __ CallRuntime(Runtime::kTraceEnter, 0);
215
- }
216
-
217
- // Visit the declarations and body unless there is an illegal
218
- // redeclaration.
219
- if (scope()->HasIllegalRedeclaration()) {
220
- Comment cmnt(masm_, "[ Declarations");
221
- scope()->VisitIllegalRedeclaration(this);
222
-
223
- } else {
224
- { Comment cmnt(masm_, "[ Declarations");
225
- // For named function expressions, declare the function name as a
226
- // constant.
227
- if (scope()->is_function_scope() && scope()->function() != NULL) {
228
- EmitDeclaration(scope()->function(), Variable::CONST, NULL);
229
- }
230
- VisitDeclarations(scope()->declarations());
231
- }
232
-
233
- { Comment cmnt(masm_, "[ Stack check");
234
- PrepareForBailout(info->function(), NO_REGISTERS);
235
- NearLabel ok;
236
- ExternalReference stack_limit =
237
- ExternalReference::address_of_stack_limit(isolate());
238
- __ cmp(esp, Operand::StaticVariable(stack_limit));
239
- __ j(above_equal, &ok, taken);
240
- StackCheckStub stub;
241
- __ CallStub(&stub);
242
- __ bind(&ok);
243
- }
244
-
245
- { Comment cmnt(masm_, "[ Body");
246
- ASSERT(loop_depth() == 0);
247
- VisitStatements(function()->body());
248
- ASSERT(loop_depth() == 0);
249
- }
250
- }
251
-
252
- // Always emit a 'return undefined' in case control fell off the end of
253
- // the body.
254
- { Comment cmnt(masm_, "[ return <undefined>;");
255
- __ mov(eax, isolate()->factory()->undefined_value());
256
- EmitReturnSequence();
257
- }
258
- }
259
-
260
-
261
- void FullCodeGenerator::ClearAccumulator() {
262
- __ Set(eax, Immediate(Smi::FromInt(0)));
263
- }
264
-
265
-
266
- void FullCodeGenerator::EmitStackCheck(IterationStatement* stmt) {
267
- Comment cmnt(masm_, "[ Stack check");
268
- NearLabel ok;
269
- ExternalReference stack_limit =
270
- ExternalReference::address_of_stack_limit(isolate());
271
- __ cmp(esp, Operand::StaticVariable(stack_limit));
272
- __ j(above_equal, &ok, taken);
273
- StackCheckStub stub;
274
- __ CallStub(&stub);
275
- // Record a mapping of this PC offset to the OSR id. This is used to find
276
- // the AST id from the unoptimized code in order to use it as a key into
277
- // the deoptimization input data found in the optimized code.
278
- RecordStackCheck(stmt->OsrEntryId());
279
-
280
- // Loop stack checks can be patched to perform on-stack replacement. In
281
- // order to decide whether or not to perform OSR we embed the loop depth
282
- // in a test instruction after the call so we can extract it from the OSR
283
- // builtin.
284
- ASSERT(loop_depth() > 0);
285
- __ test(eax, Immediate(Min(loop_depth(), Code::kMaxLoopNestingMarker)));
286
-
287
- __ bind(&ok);
288
- PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS);
289
- // Record a mapping of the OSR id to this PC. This is used if the OSR
290
- // entry becomes the target of a bailout. We don't expect it to be, but
291
- // we want it to work if it is.
292
- PrepareForBailoutForId(stmt->OsrEntryId(), NO_REGISTERS);
293
- }
294
-
295
-
296
- void FullCodeGenerator::EmitReturnSequence() {
297
- Comment cmnt(masm_, "[ Return sequence");
298
- if (return_label_.is_bound()) {
299
- __ jmp(&return_label_);
300
- } else {
301
- // Common return label
302
- __ bind(&return_label_);
303
- if (FLAG_trace) {
304
- __ push(eax);
305
- __ CallRuntime(Runtime::kTraceExit, 1);
306
- }
307
- #ifdef DEBUG
308
- // Add a label for checking the size of the code used for returning.
309
- Label check_exit_codesize;
310
- masm_->bind(&check_exit_codesize);
311
- #endif
312
- SetSourcePosition(function()->end_position() - 1);
313
- __ RecordJSReturn();
314
- // Do not use the leave instruction here because it is too short to
315
- // patch with the code required by the debugger.
316
- __ mov(esp, ebp);
317
- __ pop(ebp);
318
-
319
- int arguments_bytes = (scope()->num_parameters() + 1) * kPointerSize;
320
- __ Ret(arguments_bytes, ecx);
321
- #ifdef ENABLE_DEBUGGER_SUPPORT
322
- // Check that the size of the code used for returning is large enough
323
- // for the debugger's requirements.
324
- ASSERT(Assembler::kJSReturnSequenceLength <=
325
- masm_->SizeOfCodeGeneratedSince(&check_exit_codesize));
326
- #endif
327
- }
328
- }
329
-
330
-
331
- void FullCodeGenerator::EffectContext::Plug(Slot* slot) const {
332
- }
333
-
334
-
335
- void FullCodeGenerator::AccumulatorValueContext::Plug(Slot* slot) const {
336
- MemOperand slot_operand = codegen()->EmitSlotSearch(slot, result_register());
337
- __ mov(result_register(), slot_operand);
338
- }
339
-
340
-
341
- void FullCodeGenerator::StackValueContext::Plug(Slot* slot) const {
342
- MemOperand slot_operand = codegen()->EmitSlotSearch(slot, result_register());
343
- // Memory operands can be pushed directly.
344
- __ push(slot_operand);
345
- }
346
-
347
-
348
- void FullCodeGenerator::TestContext::Plug(Slot* slot) const {
349
- // For simplicity we always test the accumulator register.
350
- codegen()->Move(result_register(), slot);
351
- codegen()->PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL);
352
- codegen()->DoTest(true_label_, false_label_, fall_through_);
353
- }
354
-
355
-
356
- void FullCodeGenerator::EffectContext::Plug(Heap::RootListIndex index) const {
357
- UNREACHABLE(); // Not used on IA32.
358
- }
359
-
360
-
361
- void FullCodeGenerator::AccumulatorValueContext::Plug(
362
- Heap::RootListIndex index) const {
363
- UNREACHABLE(); // Not used on IA32.
364
- }
365
-
366
-
367
- void FullCodeGenerator::StackValueContext::Plug(
368
- Heap::RootListIndex index) const {
369
- UNREACHABLE(); // Not used on IA32.
370
- }
371
-
372
-
373
- void FullCodeGenerator::TestContext::Plug(Heap::RootListIndex index) const {
374
- UNREACHABLE(); // Not used on IA32.
375
- }
376
-
377
-
378
- void FullCodeGenerator::EffectContext::Plug(Handle<Object> lit) const {
379
- }
380
-
381
-
382
- void FullCodeGenerator::AccumulatorValueContext::Plug(
383
- Handle<Object> lit) const {
384
- __ Set(result_register(), Immediate(lit));
385
- }
386
-
387
-
388
- void FullCodeGenerator::StackValueContext::Plug(Handle<Object> lit) const {
389
- // Immediates can be pushed directly.
390
- __ push(Immediate(lit));
391
- }
392
-
393
-
394
- void FullCodeGenerator::TestContext::Plug(Handle<Object> lit) const {
395
- codegen()->PrepareForBailoutBeforeSplit(TOS_REG,
396
- true,
397
- true_label_,
398
- false_label_);
399
- ASSERT(!lit->IsUndetectableObject()); // There are no undetectable literals.
400
- if (lit->IsUndefined() || lit->IsNull() || lit->IsFalse()) {
401
- if (false_label_ != fall_through_) __ jmp(false_label_);
402
- } else if (lit->IsTrue() || lit->IsJSObject()) {
403
- if (true_label_ != fall_through_) __ jmp(true_label_);
404
- } else if (lit->IsString()) {
405
- if (String::cast(*lit)->length() == 0) {
406
- if (false_label_ != fall_through_) __ jmp(false_label_);
407
- } else {
408
- if (true_label_ != fall_through_) __ jmp(true_label_);
409
- }
410
- } else if (lit->IsSmi()) {
411
- if (Smi::cast(*lit)->value() == 0) {
412
- if (false_label_ != fall_through_) __ jmp(false_label_);
413
- } else {
414
- if (true_label_ != fall_through_) __ jmp(true_label_);
415
- }
416
- } else {
417
- // For simplicity we always test the accumulator register.
418
- __ mov(result_register(), lit);
419
- codegen()->DoTest(true_label_, false_label_, fall_through_);
420
- }
421
- }
422
-
423
-
424
- void FullCodeGenerator::EffectContext::DropAndPlug(int count,
425
- Register reg) const {
426
- ASSERT(count > 0);
427
- __ Drop(count);
428
- }
429
-
430
-
431
- void FullCodeGenerator::AccumulatorValueContext::DropAndPlug(
432
- int count,
433
- Register reg) const {
434
- ASSERT(count > 0);
435
- __ Drop(count);
436
- __ Move(result_register(), reg);
437
- }
438
-
439
-
440
- void FullCodeGenerator::StackValueContext::DropAndPlug(int count,
441
- Register reg) const {
442
- ASSERT(count > 0);
443
- if (count > 1) __ Drop(count - 1);
444
- __ mov(Operand(esp, 0), reg);
445
- }
446
-
447
-
448
- void FullCodeGenerator::TestContext::DropAndPlug(int count,
449
- Register reg) const {
450
- ASSERT(count > 0);
451
- // For simplicity we always test the accumulator register.
452
- __ Drop(count);
453
- __ Move(result_register(), reg);
454
- codegen()->PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL);
455
- codegen()->DoTest(true_label_, false_label_, fall_through_);
456
- }
457
-
458
-
459
- void FullCodeGenerator::EffectContext::Plug(Label* materialize_true,
460
- Label* materialize_false) const {
461
- ASSERT(materialize_true == materialize_false);
462
- __ bind(materialize_true);
463
- }
464
-
465
-
466
- void FullCodeGenerator::AccumulatorValueContext::Plug(
467
- Label* materialize_true,
468
- Label* materialize_false) const {
469
- NearLabel done;
470
- __ bind(materialize_true);
471
- __ mov(result_register(), isolate()->factory()->true_value());
472
- __ jmp(&done);
473
- __ bind(materialize_false);
474
- __ mov(result_register(), isolate()->factory()->false_value());
475
- __ bind(&done);
476
- }
477
-
478
-
479
- void FullCodeGenerator::StackValueContext::Plug(
480
- Label* materialize_true,
481
- Label* materialize_false) const {
482
- NearLabel done;
483
- __ bind(materialize_true);
484
- __ push(Immediate(isolate()->factory()->true_value()));
485
- __ jmp(&done);
486
- __ bind(materialize_false);
487
- __ push(Immediate(isolate()->factory()->false_value()));
488
- __ bind(&done);
489
- }
490
-
491
-
492
- void FullCodeGenerator::TestContext::Plug(Label* materialize_true,
493
- Label* materialize_false) const {
494
- ASSERT(materialize_true == true_label_);
495
- ASSERT(materialize_false == false_label_);
496
- }
497
-
498
-
499
- void FullCodeGenerator::EffectContext::Plug(bool flag) const {
500
- }
501
-
502
-
503
- void FullCodeGenerator::AccumulatorValueContext::Plug(bool flag) const {
504
- Handle<Object> value = flag
505
- ? isolate()->factory()->true_value()
506
- : isolate()->factory()->false_value();
507
- __ mov(result_register(), value);
508
- }
509
-
510
-
511
- void FullCodeGenerator::StackValueContext::Plug(bool flag) const {
512
- Handle<Object> value = flag
513
- ? isolate()->factory()->true_value()
514
- : isolate()->factory()->false_value();
515
- __ push(Immediate(value));
516
- }
517
-
518
-
519
- void FullCodeGenerator::TestContext::Plug(bool flag) const {
520
- codegen()->PrepareForBailoutBeforeSplit(TOS_REG,
521
- true,
522
- true_label_,
523
- false_label_);
524
- if (flag) {
525
- if (true_label_ != fall_through_) __ jmp(true_label_);
526
- } else {
527
- if (false_label_ != fall_through_) __ jmp(false_label_);
528
- }
529
- }
530
-
531
-
532
- void FullCodeGenerator::DoTest(Label* if_true,
533
- Label* if_false,
534
- Label* fall_through) {
535
- // Emit the inlined tests assumed by the stub.
536
- __ cmp(result_register(), isolate()->factory()->undefined_value());
537
- __ j(equal, if_false);
538
- __ cmp(result_register(), isolate()->factory()->true_value());
539
- __ j(equal, if_true);
540
- __ cmp(result_register(), isolate()->factory()->false_value());
541
- __ j(equal, if_false);
542
- STATIC_ASSERT(kSmiTag == 0);
543
- __ test(result_register(), Operand(result_register()));
544
- __ j(zero, if_false);
545
- __ test(result_register(), Immediate(kSmiTagMask));
546
- __ j(zero, if_true);
547
-
548
- // Call the ToBoolean stub for all other cases.
549
- ToBooleanStub stub;
550
- __ push(result_register());
551
- __ CallStub(&stub);
552
- __ test(eax, Operand(eax));
553
-
554
- // The stub returns nonzero for true.
555
- Split(not_zero, if_true, if_false, fall_through);
556
- }
557
-
558
-
559
- void FullCodeGenerator::Split(Condition cc,
560
- Label* if_true,
561
- Label* if_false,
562
- Label* fall_through) {
563
- if (if_false == fall_through) {
564
- __ j(cc, if_true);
565
- } else if (if_true == fall_through) {
566
- __ j(NegateCondition(cc), if_false);
567
- } else {
568
- __ j(cc, if_true);
569
- __ jmp(if_false);
570
- }
571
- }
572
-
573
-
574
- MemOperand FullCodeGenerator::EmitSlotSearch(Slot* slot, Register scratch) {
575
- switch (slot->type()) {
576
- case Slot::PARAMETER:
577
- case Slot::LOCAL:
578
- return Operand(ebp, SlotOffset(slot));
579
- case Slot::CONTEXT: {
580
- int context_chain_length =
581
- scope()->ContextChainLength(slot->var()->scope());
582
- __ LoadContext(scratch, context_chain_length);
583
- return ContextOperand(scratch, slot->index());
584
- }
585
- case Slot::LOOKUP:
586
- UNREACHABLE();
587
- }
588
- UNREACHABLE();
589
- return Operand(eax, 0);
590
- }
591
-
592
-
593
- void FullCodeGenerator::Move(Register destination, Slot* source) {
594
- MemOperand location = EmitSlotSearch(source, destination);
595
- __ mov(destination, location);
596
- }
597
-
598
-
599
- void FullCodeGenerator::Move(Slot* dst,
600
- Register src,
601
- Register scratch1,
602
- Register scratch2) {
603
- ASSERT(dst->type() != Slot::LOOKUP); // Not yet implemented.
604
- ASSERT(!scratch1.is(src) && !scratch2.is(src));
605
- MemOperand location = EmitSlotSearch(dst, scratch1);
606
- __ mov(location, src);
607
- // Emit the write barrier code if the location is in the heap.
608
- if (dst->type() == Slot::CONTEXT) {
609
- int offset = Context::SlotOffset(dst->index());
610
- ASSERT(!scratch1.is(esi) && !src.is(esi) && !scratch2.is(esi));
611
- __ RecordWrite(scratch1, offset, src, scratch2);
612
- }
613
- }
614
-
615
-
616
- void FullCodeGenerator::PrepareForBailoutBeforeSplit(State state,
617
- bool should_normalize,
618
- Label* if_true,
619
- Label* if_false) {
620
- // Only prepare for bailouts before splits if we're in a test
621
- // context. Otherwise, we let the Visit function deal with the
622
- // preparation to avoid preparing with the same AST id twice.
623
- if (!context()->IsTest() || !info_->IsOptimizable()) return;
624
-
625
- NearLabel skip;
626
- if (should_normalize) __ jmp(&skip);
627
-
628
- ForwardBailoutStack* current = forward_bailout_stack_;
629
- while (current != NULL) {
630
- PrepareForBailout(current->expr(), state);
631
- current = current->parent();
632
- }
633
-
634
- if (should_normalize) {
635
- __ cmp(eax, isolate()->factory()->true_value());
636
- Split(equal, if_true, if_false, NULL);
637
- __ bind(&skip);
638
- }
639
- }
640
-
641
-
642
- void FullCodeGenerator::EmitDeclaration(Variable* variable,
643
- Variable::Mode mode,
644
- FunctionLiteral* function) {
645
- Comment cmnt(masm_, "[ Declaration");
646
- ASSERT(variable != NULL); // Must have been resolved.
647
- Slot* slot = variable->AsSlot();
648
- Property* prop = variable->AsProperty();
649
-
650
- if (slot != NULL) {
651
- switch (slot->type()) {
652
- case Slot::PARAMETER:
653
- case Slot::LOCAL:
654
- if (mode == Variable::CONST) {
655
- __ mov(Operand(ebp, SlotOffset(slot)),
656
- Immediate(isolate()->factory()->the_hole_value()));
657
- } else if (function != NULL) {
658
- VisitForAccumulatorValue(function);
659
- __ mov(Operand(ebp, SlotOffset(slot)), result_register());
660
- }
661
- break;
662
-
663
- case Slot::CONTEXT:
664
- // We bypass the general EmitSlotSearch because we know more about
665
- // this specific context.
666
-
667
- // The variable in the decl always resides in the current function
668
- // context.
669
- ASSERT_EQ(0, scope()->ContextChainLength(variable->scope()));
670
- if (FLAG_debug_code) {
671
- // Check that we're not inside a 'with'.
672
- __ mov(ebx, ContextOperand(esi, Context::FCONTEXT_INDEX));
673
- __ cmp(ebx, Operand(esi));
674
- __ Check(equal, "Unexpected declaration in current context.");
675
- }
676
- if (mode == Variable::CONST) {
677
- __ mov(ContextOperand(esi, slot->index()),
678
- Immediate(isolate()->factory()->the_hole_value()));
679
- // No write barrier since the hole value is in old space.
680
- } else if (function != NULL) {
681
- VisitForAccumulatorValue(function);
682
- __ mov(ContextOperand(esi, slot->index()), result_register());
683
- int offset = Context::SlotOffset(slot->index());
684
- __ mov(ebx, esi);
685
- __ RecordWrite(ebx, offset, result_register(), ecx);
686
- }
687
- break;
688
-
689
- case Slot::LOOKUP: {
690
- __ push(esi);
691
- __ push(Immediate(variable->name()));
692
- // Declaration nodes are always introduced in one of two modes.
693
- ASSERT(mode == Variable::VAR || mode == Variable::CONST);
694
- PropertyAttributes attr = (mode == Variable::VAR) ? NONE : READ_ONLY;
695
- __ push(Immediate(Smi::FromInt(attr)));
696
- // Push initial value, if any.
697
- // Note: For variables we must not push an initial value (such as
698
- // 'undefined') because we may have a (legal) redeclaration and we
699
- // must not destroy the current value.
700
- if (mode == Variable::CONST) {
701
- __ push(Immediate(isolate()->factory()->the_hole_value()));
702
- } else if (function != NULL) {
703
- VisitForStackValue(function);
704
- } else {
705
- __ push(Immediate(Smi::FromInt(0))); // No initial value!
706
- }
707
- __ CallRuntime(Runtime::kDeclareContextSlot, 4);
708
- break;
709
- }
710
- }
711
-
712
- } else if (prop != NULL) {
713
- if (function != NULL || mode == Variable::CONST) {
714
- // We are declaring a function or constant that rewrites to a
715
- // property. Use (keyed) IC to set the initial value. We cannot
716
- // visit the rewrite because it's shared and we risk recording
717
- // duplicate AST IDs for bailouts from optimized code.
718
- ASSERT(prop->obj()->AsVariableProxy() != NULL);
719
- { AccumulatorValueContext for_object(this);
720
- EmitVariableLoad(prop->obj()->AsVariableProxy()->var());
721
- }
722
-
723
- if (function != NULL) {
724
- __ push(eax);
725
- VisitForAccumulatorValue(function);
726
- __ pop(edx);
727
- } else {
728
- __ mov(edx, eax);
729
- __ mov(eax, isolate()->factory()->the_hole_value());
730
- }
731
- ASSERT(prop->key()->AsLiteral() != NULL &&
732
- prop->key()->AsLiteral()->handle()->IsSmi());
733
- __ Set(ecx, Immediate(prop->key()->AsLiteral()->handle()));
734
-
735
- Handle<Code> ic = is_strict_mode()
736
- ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict()
737
- : isolate()->builtins()->KeyedStoreIC_Initialize();
738
- EmitCallIC(ic, RelocInfo::CODE_TARGET);
739
- }
740
- }
741
- }
742
-
743
-
744
- void FullCodeGenerator::VisitDeclaration(Declaration* decl) {
745
- EmitDeclaration(decl->proxy()->var(), decl->mode(), decl->fun());
746
- }
747
-
748
-
749
- void FullCodeGenerator::DeclareGlobals(Handle<FixedArray> pairs) {
750
- // Call the runtime to declare the globals.
751
- __ push(esi); // The context is the first argument.
752
- __ push(Immediate(pairs));
753
- __ push(Immediate(Smi::FromInt(is_eval() ? 1 : 0)));
754
- __ push(Immediate(Smi::FromInt(strict_mode_flag())));
755
- __ CallRuntime(Runtime::kDeclareGlobals, 4);
756
- // Return value is ignored.
757
- }
758
-
759
-
760
- void FullCodeGenerator::VisitSwitchStatement(SwitchStatement* stmt) {
761
- Comment cmnt(masm_, "[ SwitchStatement");
762
- Breakable nested_statement(this, stmt);
763
- SetStatementPosition(stmt);
764
-
765
- // Keep the switch value on the stack until a case matches.
766
- VisitForStackValue(stmt->tag());
767
- PrepareForBailoutForId(stmt->EntryId(), NO_REGISTERS);
768
-
769
- ZoneList<CaseClause*>* clauses = stmt->cases();
770
- CaseClause* default_clause = NULL; // Can occur anywhere in the list.
771
-
772
- Label next_test; // Recycled for each test.
773
- // Compile all the tests with branches to their bodies.
774
- for (int i = 0; i < clauses->length(); i++) {
775
- CaseClause* clause = clauses->at(i);
776
- clause->body_target()->entry_label()->Unuse();
777
-
778
- // The default is not a test, but remember it as final fall through.
779
- if (clause->is_default()) {
780
- default_clause = clause;
781
- continue;
782
- }
783
-
784
- Comment cmnt(masm_, "[ Case comparison");
785
- __ bind(&next_test);
786
- next_test.Unuse();
787
-
788
- // Compile the label expression.
789
- VisitForAccumulatorValue(clause->label());
790
-
791
- // Perform the comparison as if via '==='.
792
- __ mov(edx, Operand(esp, 0)); // Switch value.
793
- bool inline_smi_code = ShouldInlineSmiCase(Token::EQ_STRICT);
794
- JumpPatchSite patch_site(masm_);
795
- if (inline_smi_code) {
796
- NearLabel slow_case;
797
- __ mov(ecx, edx);
798
- __ or_(ecx, Operand(eax));
799
- patch_site.EmitJumpIfNotSmi(ecx, &slow_case);
800
-
801
- __ cmp(edx, Operand(eax));
802
- __ j(not_equal, &next_test);
803
- __ Drop(1); // Switch value is no longer needed.
804
- __ jmp(clause->body_target()->entry_label());
805
- __ bind(&slow_case);
806
- }
807
-
808
- // Record position before stub call for type feedback.
809
- SetSourcePosition(clause->position());
810
- Handle<Code> ic = CompareIC::GetUninitialized(Token::EQ_STRICT);
811
- EmitCallIC(ic, &patch_site);
812
- __ test(eax, Operand(eax));
813
- __ j(not_equal, &next_test);
814
- __ Drop(1); // Switch value is no longer needed.
815
- __ jmp(clause->body_target()->entry_label());
816
- }
817
-
818
- // Discard the test value and jump to the default if present, otherwise to
819
- // the end of the statement.
820
- __ bind(&next_test);
821
- __ Drop(1); // Switch value is no longer needed.
822
- if (default_clause == NULL) {
823
- __ jmp(nested_statement.break_target());
824
- } else {
825
- __ jmp(default_clause->body_target()->entry_label());
826
- }
827
-
828
- // Compile all the case bodies.
829
- for (int i = 0; i < clauses->length(); i++) {
830
- Comment cmnt(masm_, "[ Case body");
831
- CaseClause* clause = clauses->at(i);
832
- __ bind(clause->body_target()->entry_label());
833
- PrepareForBailoutForId(clause->EntryId(), NO_REGISTERS);
834
- VisitStatements(clause->statements());
835
- }
836
-
837
- __ bind(nested_statement.break_target());
838
- PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS);
839
- }
840
-
841
-
842
- void FullCodeGenerator::VisitForInStatement(ForInStatement* stmt) {
843
- Comment cmnt(masm_, "[ ForInStatement");
844
- SetStatementPosition(stmt);
845
-
846
- Label loop, exit;
847
- ForIn loop_statement(this, stmt);
848
- increment_loop_depth();
849
-
850
- // Get the object to enumerate over. Both SpiderMonkey and JSC
851
- // ignore null and undefined in contrast to the specification; see
852
- // ECMA-262 section 12.6.4.
853
- VisitForAccumulatorValue(stmt->enumerable());
854
- __ cmp(eax, isolate()->factory()->undefined_value());
855
- __ j(equal, &exit);
856
- __ cmp(eax, isolate()->factory()->null_value());
857
- __ j(equal, &exit);
858
-
859
- // Convert the object to a JS object.
860
- NearLabel convert, done_convert;
861
- __ test(eax, Immediate(kSmiTagMask));
862
- __ j(zero, &convert);
863
- __ CmpObjectType(eax, FIRST_JS_OBJECT_TYPE, ecx);
864
- __ j(above_equal, &done_convert);
865
- __ bind(&convert);
866
- __ push(eax);
867
- __ InvokeBuiltin(Builtins::TO_OBJECT, CALL_FUNCTION);
868
- __ bind(&done_convert);
869
- __ push(eax);
870
-
871
- // Check cache validity in generated code. This is a fast case for
872
- // the JSObject::IsSimpleEnum cache validity checks. If we cannot
873
- // guarantee cache validity, call the runtime system to check cache
874
- // validity or get the property names in a fixed array.
875
- Label next, call_runtime;
876
- __ mov(ecx, eax);
877
- __ bind(&next);
878
-
879
- // Check that there are no elements. Register ecx contains the
880
- // current JS object we've reached through the prototype chain.
881
- __ cmp(FieldOperand(ecx, JSObject::kElementsOffset),
882
- isolate()->factory()->empty_fixed_array());
883
- __ j(not_equal, &call_runtime);
884
-
885
- // Check that instance descriptors are not empty so that we can
886
- // check for an enum cache. Leave the map in ebx for the subsequent
887
- // prototype load.
888
- __ mov(ebx, FieldOperand(ecx, HeapObject::kMapOffset));
889
- __ mov(edx, FieldOperand(ebx, Map::kInstanceDescriptorsOffset));
890
- __ cmp(edx, isolate()->factory()->empty_descriptor_array());
891
- __ j(equal, &call_runtime);
892
-
893
- // Check that there is an enum cache in the non-empty instance
894
- // descriptors (edx). This is the case if the next enumeration
895
- // index field does not contain a smi.
896
- __ mov(edx, FieldOperand(edx, DescriptorArray::kEnumerationIndexOffset));
897
- __ test(edx, Immediate(kSmiTagMask));
898
- __ j(zero, &call_runtime);
899
-
900
- // For all objects but the receiver, check that the cache is empty.
901
- NearLabel check_prototype;
902
- __ cmp(ecx, Operand(eax));
903
- __ j(equal, &check_prototype);
904
- __ mov(edx, FieldOperand(edx, DescriptorArray::kEnumCacheBridgeCacheOffset));
905
- __ cmp(edx, isolate()->factory()->empty_fixed_array());
906
- __ j(not_equal, &call_runtime);
907
-
908
- // Load the prototype from the map and loop if non-null.
909
- __ bind(&check_prototype);
910
- __ mov(ecx, FieldOperand(ebx, Map::kPrototypeOffset));
911
- __ cmp(ecx, isolate()->factory()->null_value());
912
- __ j(not_equal, &next);
913
-
914
- // The enum cache is valid. Load the map of the object being
915
- // iterated over and use the cache for the iteration.
916
- NearLabel use_cache;
917
- __ mov(eax, FieldOperand(eax, HeapObject::kMapOffset));
918
- __ jmp(&use_cache);
919
-
920
- // Get the set of properties to enumerate.
921
- __ bind(&call_runtime);
922
- __ push(eax); // Duplicate the enumerable object on the stack.
923
- __ CallRuntime(Runtime::kGetPropertyNamesFast, 1);
924
-
925
- // If we got a map from the runtime call, we can do a fast
926
- // modification check. Otherwise, we got a fixed array, and we have
927
- // to do a slow check.
928
- NearLabel fixed_array;
929
- __ cmp(FieldOperand(eax, HeapObject::kMapOffset),
930
- isolate()->factory()->meta_map());
931
- __ j(not_equal, &fixed_array);
932
-
933
- // We got a map in register eax. Get the enumeration cache from it.
934
- __ bind(&use_cache);
935
- __ mov(ecx, FieldOperand(eax, Map::kInstanceDescriptorsOffset));
936
- __ mov(ecx, FieldOperand(ecx, DescriptorArray::kEnumerationIndexOffset));
937
- __ mov(edx, FieldOperand(ecx, DescriptorArray::kEnumCacheBridgeCacheOffset));
938
-
939
- // Setup the four remaining stack slots.
940
- __ push(eax); // Map.
941
- __ push(edx); // Enumeration cache.
942
- __ mov(eax, FieldOperand(edx, FixedArray::kLengthOffset));
943
- __ push(eax); // Enumeration cache length (as smi).
944
- __ push(Immediate(Smi::FromInt(0))); // Initial index.
945
- __ jmp(&loop);
946
-
947
- // We got a fixed array in register eax. Iterate through that.
948
- __ bind(&fixed_array);
949
- __ push(Immediate(Smi::FromInt(0))); // Map (0) - force slow check.
950
- __ push(eax);
951
- __ mov(eax, FieldOperand(eax, FixedArray::kLengthOffset));
952
- __ push(eax); // Fixed array length (as smi).
953
- __ push(Immediate(Smi::FromInt(0))); // Initial index.
954
-
955
- // Generate code for doing the condition check.
956
- __ bind(&loop);
957
- __ mov(eax, Operand(esp, 0 * kPointerSize)); // Get the current index.
958
- __ cmp(eax, Operand(esp, 1 * kPointerSize)); // Compare to the array length.
959
- __ j(above_equal, loop_statement.break_target());
960
-
961
- // Get the current entry of the array into register ebx.
962
- __ mov(ebx, Operand(esp, 2 * kPointerSize));
963
- __ mov(ebx, FieldOperand(ebx, eax, times_2, FixedArray::kHeaderSize));
964
-
965
- // Get the expected map from the stack or a zero map in the
966
- // permanent slow case into register edx.
967
- __ mov(edx, Operand(esp, 3 * kPointerSize));
968
-
969
- // Check if the expected map still matches that of the enumerable.
970
- // If not, we have to filter the key.
971
- NearLabel update_each;
972
- __ mov(ecx, Operand(esp, 4 * kPointerSize));
973
- __ cmp(edx, FieldOperand(ecx, HeapObject::kMapOffset));
974
- __ j(equal, &update_each);
975
-
976
- // Convert the entry to a string or null if it isn't a property
977
- // anymore. If the property has been removed while iterating, we
978
- // just skip it.
979
- __ push(ecx); // Enumerable.
980
- __ push(ebx); // Current entry.
981
- __ InvokeBuiltin(Builtins::FILTER_KEY, CALL_FUNCTION);
982
- __ test(eax, Operand(eax));
983
- __ j(equal, loop_statement.continue_target());
984
- __ mov(ebx, Operand(eax));
985
-
986
- // Update the 'each' property or variable from the possibly filtered
987
- // entry in register ebx.
988
- __ bind(&update_each);
989
- __ mov(result_register(), ebx);
990
- // Perform the assignment as if via '='.
991
- { EffectContext context(this);
992
- EmitAssignment(stmt->each(), stmt->AssignmentId());
993
- }
994
-
995
- // Generate code for the body of the loop.
996
- Visit(stmt->body());
997
-
998
- // Generate code for going to the next element by incrementing the
999
- // index (smi) stored on top of the stack.
1000
- __ bind(loop_statement.continue_target());
1001
- __ add(Operand(esp, 0 * kPointerSize), Immediate(Smi::FromInt(1)));
1002
-
1003
- EmitStackCheck(stmt);
1004
- __ jmp(&loop);
1005
-
1006
- // Remove the pointers stored on the stack.
1007
- __ bind(loop_statement.break_target());
1008
- __ add(Operand(esp), Immediate(5 * kPointerSize));
1009
-
1010
- // Exit and decrement the loop depth.
1011
- __ bind(&exit);
1012
- decrement_loop_depth();
1013
- }
1014
-
1015
-
1016
- void FullCodeGenerator::EmitNewClosure(Handle<SharedFunctionInfo> info,
1017
- bool pretenure) {
1018
- // Use the fast case closure allocation code that allocates in new
1019
- // space for nested functions that don't need literals cloning. If
1020
- // we're running with the --always-opt or the --prepare-always-opt
1021
- // flag, we need to use the runtime function so that the new function
1022
- // we are creating here gets a chance to have its code optimized and
1023
- // doesn't just get a copy of the existing unoptimized code.
1024
- if (!FLAG_always_opt &&
1025
- !FLAG_prepare_always_opt &&
1026
- !pretenure &&
1027
- scope()->is_function_scope() &&
1028
- info->num_literals() == 0) {
1029
- FastNewClosureStub stub(info->strict_mode() ? kStrictMode : kNonStrictMode);
1030
- __ push(Immediate(info));
1031
- __ CallStub(&stub);
1032
- } else {
1033
- __ push(esi);
1034
- __ push(Immediate(info));
1035
- __ push(Immediate(pretenure
1036
- ? isolate()->factory()->true_value()
1037
- : isolate()->factory()->false_value()));
1038
- __ CallRuntime(Runtime::kNewClosure, 3);
1039
- }
1040
- context()->Plug(eax);
1041
- }
1042
-
1043
-
1044
- void FullCodeGenerator::VisitVariableProxy(VariableProxy* expr) {
1045
- Comment cmnt(masm_, "[ VariableProxy");
1046
- EmitVariableLoad(expr->var());
1047
- }
1048
-
1049
-
1050
- void FullCodeGenerator::EmitLoadGlobalSlotCheckExtensions(
1051
- Slot* slot,
1052
- TypeofState typeof_state,
1053
- Label* slow) {
1054
- Register context = esi;
1055
- Register temp = edx;
1056
-
1057
- Scope* s = scope();
1058
- while (s != NULL) {
1059
- if (s->num_heap_slots() > 0) {
1060
- if (s->calls_eval()) {
1061
- // Check that extension is NULL.
1062
- __ cmp(ContextOperand(context, Context::EXTENSION_INDEX),
1063
- Immediate(0));
1064
- __ j(not_equal, slow);
1065
- }
1066
- // Load next context in chain.
1067
- __ mov(temp, ContextOperand(context, Context::CLOSURE_INDEX));
1068
- __ mov(temp, FieldOperand(temp, JSFunction::kContextOffset));
1069
- // Walk the rest of the chain without clobbering esi.
1070
- context = temp;
1071
- }
1072
- // If no outer scope calls eval, we do not need to check more
1073
- // context extensions. If we have reached an eval scope, we check
1074
- // all extensions from this point.
1075
- if (!s->outer_scope_calls_eval() || s->is_eval_scope()) break;
1076
- s = s->outer_scope();
1077
- }
1078
-
1079
- if (s != NULL && s->is_eval_scope()) {
1080
- // Loop up the context chain. There is no frame effect so it is
1081
- // safe to use raw labels here.
1082
- NearLabel next, fast;
1083
- if (!context.is(temp)) {
1084
- __ mov(temp, context);
1085
- }
1086
- __ bind(&next);
1087
- // Terminate at global context.
1088
- __ cmp(FieldOperand(temp, HeapObject::kMapOffset),
1089
- Immediate(isolate()->factory()->global_context_map()));
1090
- __ j(equal, &fast);
1091
- // Check that extension is NULL.
1092
- __ cmp(ContextOperand(temp, Context::EXTENSION_INDEX), Immediate(0));
1093
- __ j(not_equal, slow);
1094
- // Load next context in chain.
1095
- __ mov(temp, ContextOperand(temp, Context::CLOSURE_INDEX));
1096
- __ mov(temp, FieldOperand(temp, JSFunction::kContextOffset));
1097
- __ jmp(&next);
1098
- __ bind(&fast);
1099
- }
1100
-
1101
- // All extension objects were empty and it is safe to use a global
1102
- // load IC call.
1103
- __ mov(eax, GlobalObjectOperand());
1104
- __ mov(ecx, slot->var()->name());
1105
- Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
1106
- RelocInfo::Mode mode = (typeof_state == INSIDE_TYPEOF)
1107
- ? RelocInfo::CODE_TARGET
1108
- : RelocInfo::CODE_TARGET_CONTEXT;
1109
- EmitCallIC(ic, mode);
1110
- }
1111
-
1112
-
1113
- MemOperand FullCodeGenerator::ContextSlotOperandCheckExtensions(
1114
- Slot* slot,
1115
- Label* slow) {
1116
- ASSERT(slot->type() == Slot::CONTEXT);
1117
- Register context = esi;
1118
- Register temp = ebx;
1119
-
1120
- for (Scope* s = scope(); s != slot->var()->scope(); s = s->outer_scope()) {
1121
- if (s->num_heap_slots() > 0) {
1122
- if (s->calls_eval()) {
1123
- // Check that extension is NULL.
1124
- __ cmp(ContextOperand(context, Context::EXTENSION_INDEX),
1125
- Immediate(0));
1126
- __ j(not_equal, slow);
1127
- }
1128
- __ mov(temp, ContextOperand(context, Context::CLOSURE_INDEX));
1129
- __ mov(temp, FieldOperand(temp, JSFunction::kContextOffset));
1130
- // Walk the rest of the chain without clobbering esi.
1131
- context = temp;
1132
- }
1133
- }
1134
- // Check that last extension is NULL.
1135
- __ cmp(ContextOperand(context, Context::EXTENSION_INDEX), Immediate(0));
1136
- __ j(not_equal, slow);
1137
-
1138
- // This function is used only for loads, not stores, so it's safe to
1139
- // return an esi-based operand (the write barrier cannot be allowed to
1140
- // destroy the esi register).
1141
- return ContextOperand(context, slot->index());
1142
- }
1143
-
1144
-
1145
- void FullCodeGenerator::EmitDynamicLoadFromSlotFastCase(
1146
- Slot* slot,
1147
- TypeofState typeof_state,
1148
- Label* slow,
1149
- Label* done) {
1150
- // Generate fast-case code for variables that might be shadowed by
1151
- // eval-introduced variables. Eval is used a lot without
1152
- // introducing variables. In those cases, we do not want to
1153
- // perform a runtime call for all variables in the scope
1154
- // containing the eval.
1155
- if (slot->var()->mode() == Variable::DYNAMIC_GLOBAL) {
1156
- EmitLoadGlobalSlotCheckExtensions(slot, typeof_state, slow);
1157
- __ jmp(done);
1158
- } else if (slot->var()->mode() == Variable::DYNAMIC_LOCAL) {
1159
- Slot* potential_slot = slot->var()->local_if_not_shadowed()->AsSlot();
1160
- Expression* rewrite = slot->var()->local_if_not_shadowed()->rewrite();
1161
- if (potential_slot != NULL) {
1162
- // Generate fast case for locals that rewrite to slots.
1163
- __ mov(eax,
1164
- ContextSlotOperandCheckExtensions(potential_slot, slow));
1165
- if (potential_slot->var()->mode() == Variable::CONST) {
1166
- __ cmp(eax, isolate()->factory()->the_hole_value());
1167
- __ j(not_equal, done);
1168
- __ mov(eax, isolate()->factory()->undefined_value());
1169
- }
1170
- __ jmp(done);
1171
- } else if (rewrite != NULL) {
1172
- // Generate fast case for calls of an argument function.
1173
- Property* property = rewrite->AsProperty();
1174
- if (property != NULL) {
1175
- VariableProxy* obj_proxy = property->obj()->AsVariableProxy();
1176
- Literal* key_literal = property->key()->AsLiteral();
1177
- if (obj_proxy != NULL &&
1178
- key_literal != NULL &&
1179
- obj_proxy->IsArguments() &&
1180
- key_literal->handle()->IsSmi()) {
1181
- // Load arguments object if there are no eval-introduced
1182
- // variables. Then load the argument from the arguments
1183
- // object using keyed load.
1184
- __ mov(edx,
1185
- ContextSlotOperandCheckExtensions(obj_proxy->var()->AsSlot(),
1186
- slow));
1187
- __ mov(eax, Immediate(key_literal->handle()));
1188
- Handle<Code> ic =
1189
- isolate()->builtins()->KeyedLoadIC_Initialize();
1190
- EmitCallIC(ic, RelocInfo::CODE_TARGET);
1191
- __ jmp(done);
1192
- }
1193
- }
1194
- }
1195
- }
1196
- }
1197
-
1198
-
1199
- void FullCodeGenerator::EmitVariableLoad(Variable* var) {
1200
- // Four cases: non-this global variables, lookup slots, all other
1201
- // types of slots, and parameters that rewrite to explicit property
1202
- // accesses on the arguments object.
1203
- Slot* slot = var->AsSlot();
1204
- Property* property = var->AsProperty();
1205
-
1206
- if (var->is_global() && !var->is_this()) {
1207
- Comment cmnt(masm_, "Global variable");
1208
- // Use inline caching. Variable name is passed in ecx and the global
1209
- // object on the stack.
1210
- __ mov(eax, GlobalObjectOperand());
1211
- __ mov(ecx, var->name());
1212
- Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
1213
- EmitCallIC(ic, RelocInfo::CODE_TARGET_CONTEXT);
1214
- context()->Plug(eax);
1215
-
1216
- } else if (slot != NULL && slot->type() == Slot::LOOKUP) {
1217
- Label done, slow;
1218
-
1219
- // Generate code for loading from variables potentially shadowed
1220
- // by eval-introduced variables.
1221
- EmitDynamicLoadFromSlotFastCase(slot, NOT_INSIDE_TYPEOF, &slow, &done);
1222
-
1223
- __ bind(&slow);
1224
- Comment cmnt(masm_, "Lookup slot");
1225
- __ push(esi); // Context.
1226
- __ push(Immediate(var->name()));
1227
- __ CallRuntime(Runtime::kLoadContextSlot, 2);
1228
- __ bind(&done);
1229
-
1230
- context()->Plug(eax);
1231
-
1232
- } else if (slot != NULL) {
1233
- Comment cmnt(masm_, (slot->type() == Slot::CONTEXT)
1234
- ? "Context slot"
1235
- : "Stack slot");
1236
- if (var->mode() == Variable::CONST) {
1237
- // Constants may be the hole value if they have not been initialized.
1238
- // Unhole them.
1239
- NearLabel done;
1240
- MemOperand slot_operand = EmitSlotSearch(slot, eax);
1241
- __ mov(eax, slot_operand);
1242
- __ cmp(eax, isolate()->factory()->the_hole_value());
1243
- __ j(not_equal, &done);
1244
- __ mov(eax, isolate()->factory()->undefined_value());
1245
- __ bind(&done);
1246
- context()->Plug(eax);
1247
- } else {
1248
- context()->Plug(slot);
1249
- }
1250
-
1251
- } else {
1252
- Comment cmnt(masm_, "Rewritten parameter");
1253
- ASSERT_NOT_NULL(property);
1254
- // Rewritten parameter accesses are of the form "slot[literal]".
1255
-
1256
- // Assert that the object is in a slot.
1257
- Variable* object_var = property->obj()->AsVariableProxy()->AsVariable();
1258
- ASSERT_NOT_NULL(object_var);
1259
- Slot* object_slot = object_var->AsSlot();
1260
- ASSERT_NOT_NULL(object_slot);
1261
-
1262
- // Load the object.
1263
- MemOperand object_loc = EmitSlotSearch(object_slot, eax);
1264
- __ mov(edx, object_loc);
1265
-
1266
- // Assert that the key is a smi.
1267
- Literal* key_literal = property->key()->AsLiteral();
1268
- ASSERT_NOT_NULL(key_literal);
1269
- ASSERT(key_literal->handle()->IsSmi());
1270
-
1271
- // Load the key.
1272
- __ mov(eax, Immediate(key_literal->handle()));
1273
-
1274
- // Do a keyed property load.
1275
- Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize();
1276
- EmitCallIC(ic, RelocInfo::CODE_TARGET);
1277
-
1278
- // Drop key and object left on the stack by IC.
1279
- context()->Plug(eax);
1280
- }
1281
- }
1282
-
1283
-
1284
- void FullCodeGenerator::VisitRegExpLiteral(RegExpLiteral* expr) {
1285
- Comment cmnt(masm_, "[ RegExpLiteral");
1286
- NearLabel materialized;
1287
- // Registers will be used as follows:
1288
- // edi = JS function.
1289
- // ecx = literals array.
1290
- // ebx = regexp literal.
1291
- // eax = regexp literal clone.
1292
- __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
1293
- __ mov(ecx, FieldOperand(edi, JSFunction::kLiteralsOffset));
1294
- int literal_offset =
1295
- FixedArray::kHeaderSize + expr->literal_index() * kPointerSize;
1296
- __ mov(ebx, FieldOperand(ecx, literal_offset));
1297
- __ cmp(ebx, isolate()->factory()->undefined_value());
1298
- __ j(not_equal, &materialized);
1299
-
1300
- // Create regexp literal using runtime function
1301
- // Result will be in eax.
1302
- __ push(ecx);
1303
- __ push(Immediate(Smi::FromInt(expr->literal_index())));
1304
- __ push(Immediate(expr->pattern()));
1305
- __ push(Immediate(expr->flags()));
1306
- __ CallRuntime(Runtime::kMaterializeRegExpLiteral, 4);
1307
- __ mov(ebx, eax);
1308
-
1309
- __ bind(&materialized);
1310
- int size = JSRegExp::kSize + JSRegExp::kInObjectFieldCount * kPointerSize;
1311
- Label allocated, runtime_allocate;
1312
- __ AllocateInNewSpace(size, eax, ecx, edx, &runtime_allocate, TAG_OBJECT);
1313
- __ jmp(&allocated);
1314
-
1315
- __ bind(&runtime_allocate);
1316
- __ push(ebx);
1317
- __ push(Immediate(Smi::FromInt(size)));
1318
- __ CallRuntime(Runtime::kAllocateInNewSpace, 1);
1319
- __ pop(ebx);
1320
-
1321
- __ bind(&allocated);
1322
- // Copy the content into the newly allocated memory.
1323
- // (Unroll copy loop once for better throughput).
1324
- for (int i = 0; i < size - kPointerSize; i += 2 * kPointerSize) {
1325
- __ mov(edx, FieldOperand(ebx, i));
1326
- __ mov(ecx, FieldOperand(ebx, i + kPointerSize));
1327
- __ mov(FieldOperand(eax, i), edx);
1328
- __ mov(FieldOperand(eax, i + kPointerSize), ecx);
1329
- }
1330
- if ((size % (2 * kPointerSize)) != 0) {
1331
- __ mov(edx, FieldOperand(ebx, size - kPointerSize));
1332
- __ mov(FieldOperand(eax, size - kPointerSize), edx);
1333
- }
1334
- context()->Plug(eax);
1335
- }
1336
-
1337
-
1338
- void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) {
1339
- Comment cmnt(masm_, "[ ObjectLiteral");
1340
- __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
1341
- __ push(FieldOperand(edi, JSFunction::kLiteralsOffset));
1342
- __ push(Immediate(Smi::FromInt(expr->literal_index())));
1343
- __ push(Immediate(expr->constant_properties()));
1344
- int flags = expr->fast_elements()
1345
- ? ObjectLiteral::kFastElements
1346
- : ObjectLiteral::kNoFlags;
1347
- flags |= expr->has_function()
1348
- ? ObjectLiteral::kHasFunction
1349
- : ObjectLiteral::kNoFlags;
1350
- __ push(Immediate(Smi::FromInt(flags)));
1351
- if (expr->depth() > 1) {
1352
- __ CallRuntime(Runtime::kCreateObjectLiteral, 4);
1353
- } else {
1354
- __ CallRuntime(Runtime::kCreateObjectLiteralShallow, 4);
1355
- }
1356
-
1357
- // If result_saved is true the result is on top of the stack. If
1358
- // result_saved is false the result is in eax.
1359
- bool result_saved = false;
1360
-
1361
- // Mark all computed expressions that are bound to a key that
1362
- // is shadowed by a later occurrence of the same key. For the
1363
- // marked expressions, no store code is emitted.
1364
- expr->CalculateEmitStore();
1365
-
1366
- for (int i = 0; i < expr->properties()->length(); i++) {
1367
- ObjectLiteral::Property* property = expr->properties()->at(i);
1368
- if (property->IsCompileTimeValue()) continue;
1369
-
1370
- Literal* key = property->key();
1371
- Expression* value = property->value();
1372
- if (!result_saved) {
1373
- __ push(eax); // Save result on the stack
1374
- result_saved = true;
1375
- }
1376
- switch (property->kind()) {
1377
- case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1378
- ASSERT(!CompileTimeValue::IsCompileTimeValue(value));
1379
- // Fall through.
1380
- case ObjectLiteral::Property::COMPUTED:
1381
- if (key->handle()->IsSymbol()) {
1382
- if (property->emit_store()) {
1383
- VisitForAccumulatorValue(value);
1384
- __ mov(ecx, Immediate(key->handle()));
1385
- __ mov(edx, Operand(esp, 0));
1386
- Handle<Code> ic = is_strict_mode()
1387
- ? isolate()->builtins()->StoreIC_Initialize_Strict()
1388
- : isolate()->builtins()->StoreIC_Initialize();
1389
- EmitCallIC(ic, RelocInfo::CODE_TARGET);
1390
- PrepareForBailoutForId(key->id(), NO_REGISTERS);
1391
- } else {
1392
- VisitForEffect(value);
1393
- }
1394
- break;
1395
- }
1396
- // Fall through.
1397
- case ObjectLiteral::Property::PROTOTYPE:
1398
- __ push(Operand(esp, 0)); // Duplicate receiver.
1399
- VisitForStackValue(key);
1400
- VisitForStackValue(value);
1401
- if (property->emit_store()) {
1402
- __ push(Immediate(Smi::FromInt(NONE))); // PropertyAttributes
1403
- __ CallRuntime(Runtime::kSetProperty, 4);
1404
- } else {
1405
- __ Drop(3);
1406
- }
1407
- break;
1408
- case ObjectLiteral::Property::SETTER:
1409
- case ObjectLiteral::Property::GETTER:
1410
- __ push(Operand(esp, 0)); // Duplicate receiver.
1411
- VisitForStackValue(key);
1412
- __ push(Immediate(property->kind() == ObjectLiteral::Property::SETTER ?
1413
- Smi::FromInt(1) :
1414
- Smi::FromInt(0)));
1415
- VisitForStackValue(value);
1416
- __ CallRuntime(Runtime::kDefineAccessor, 4);
1417
- break;
1418
- default: UNREACHABLE();
1419
- }
1420
- }
1421
-
1422
- if (expr->has_function()) {
1423
- ASSERT(result_saved);
1424
- __ push(Operand(esp, 0));
1425
- __ CallRuntime(Runtime::kToFastProperties, 1);
1426
- }
1427
-
1428
- if (result_saved) {
1429
- context()->PlugTOS();
1430
- } else {
1431
- context()->Plug(eax);
1432
- }
1433
- }
1434
-
1435
-
1436
- void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
1437
- Comment cmnt(masm_, "[ ArrayLiteral");
1438
-
1439
- ZoneList<Expression*>* subexprs = expr->values();
1440
- int length = subexprs->length();
1441
-
1442
- __ mov(ebx, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
1443
- __ push(FieldOperand(ebx, JSFunction::kLiteralsOffset));
1444
- __ push(Immediate(Smi::FromInt(expr->literal_index())));
1445
- __ push(Immediate(expr->constant_elements()));
1446
- if (expr->constant_elements()->map() ==
1447
- isolate()->heap()->fixed_cow_array_map()) {
1448
- ASSERT(expr->depth() == 1);
1449
- FastCloneShallowArrayStub stub(
1450
- FastCloneShallowArrayStub::COPY_ON_WRITE_ELEMENTS, length);
1451
- __ CallStub(&stub);
1452
- __ IncrementCounter(isolate()->counters()->cow_arrays_created_stub(), 1);
1453
- } else if (expr->depth() > 1) {
1454
- __ CallRuntime(Runtime::kCreateArrayLiteral, 3);
1455
- } else if (length > FastCloneShallowArrayStub::kMaximumClonedLength) {
1456
- __ CallRuntime(Runtime::kCreateArrayLiteralShallow, 3);
1457
- } else {
1458
- FastCloneShallowArrayStub stub(
1459
- FastCloneShallowArrayStub::CLONE_ELEMENTS, length);
1460
- __ CallStub(&stub);
1461
- }
1462
-
1463
- bool result_saved = false; // Is the result saved to the stack?
1464
-
1465
- // Emit code to evaluate all the non-constant subexpressions and to store
1466
- // them into the newly cloned array.
1467
- for (int i = 0; i < length; i++) {
1468
- Expression* subexpr = subexprs->at(i);
1469
- // If the subexpression is a literal or a simple materialized literal it
1470
- // is already set in the cloned array.
1471
- if (subexpr->AsLiteral() != NULL ||
1472
- CompileTimeValue::IsCompileTimeValue(subexpr)) {
1473
- continue;
1474
- }
1475
-
1476
- if (!result_saved) {
1477
- __ push(eax);
1478
- result_saved = true;
1479
- }
1480
- VisitForAccumulatorValue(subexpr);
1481
-
1482
- // Store the subexpression value in the array's elements.
1483
- __ mov(ebx, Operand(esp, 0)); // Copy of array literal.
1484
- __ mov(ebx, FieldOperand(ebx, JSObject::kElementsOffset));
1485
- int offset = FixedArray::kHeaderSize + (i * kPointerSize);
1486
- __ mov(FieldOperand(ebx, offset), result_register());
1487
-
1488
- // Update the write barrier for the array store.
1489
- __ RecordWrite(ebx, offset, result_register(), ecx);
1490
-
1491
- PrepareForBailoutForId(expr->GetIdForElement(i), NO_REGISTERS);
1492
- }
1493
-
1494
- if (result_saved) {
1495
- context()->PlugTOS();
1496
- } else {
1497
- context()->Plug(eax);
1498
- }
1499
- }
1500
-
1501
-
1502
- void FullCodeGenerator::VisitAssignment(Assignment* expr) {
1503
- Comment cmnt(masm_, "[ Assignment");
1504
- // Invalid left-hand sides are rewritten to have a 'throw ReferenceError'
1505
- // on the left-hand side.
1506
- if (!expr->target()->IsValidLeftHandSide()) {
1507
- VisitForEffect(expr->target());
1508
- return;
1509
- }
1510
-
1511
- // Left-hand side can only be a property, a global or a (parameter or local)
1512
- // slot. Variables with rewrite to .arguments are treated as KEYED_PROPERTY.
1513
- enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY };
1514
- LhsKind assign_type = VARIABLE;
1515
- Property* property = expr->target()->AsProperty();
1516
- if (property != NULL) {
1517
- assign_type = (property->key()->IsPropertyName())
1518
- ? NAMED_PROPERTY
1519
- : KEYED_PROPERTY;
1520
- }
1521
-
1522
- // Evaluate LHS expression.
1523
- switch (assign_type) {
1524
- case VARIABLE:
1525
- // Nothing to do here.
1526
- break;
1527
- case NAMED_PROPERTY:
1528
- if (expr->is_compound()) {
1529
- // We need the receiver both on the stack and in the accumulator.
1530
- VisitForAccumulatorValue(property->obj());
1531
- __ push(result_register());
1532
- } else {
1533
- VisitForStackValue(property->obj());
1534
- }
1535
- break;
1536
- case KEYED_PROPERTY: {
1537
- if (expr->is_compound()) {
1538
- if (property->is_arguments_access()) {
1539
- VariableProxy* obj_proxy = property->obj()->AsVariableProxy();
1540
- MemOperand slot_operand =
1541
- EmitSlotSearch(obj_proxy->var()->AsSlot(), ecx);
1542
- __ push(slot_operand);
1543
- __ mov(eax, Immediate(property->key()->AsLiteral()->handle()));
1544
- } else {
1545
- VisitForStackValue(property->obj());
1546
- VisitForAccumulatorValue(property->key());
1547
- }
1548
- __ mov(edx, Operand(esp, 0));
1549
- __ push(eax);
1550
- } else {
1551
- if (property->is_arguments_access()) {
1552
- VariableProxy* obj_proxy = property->obj()->AsVariableProxy();
1553
- MemOperand slot_operand =
1554
- EmitSlotSearch(obj_proxy->var()->AsSlot(), ecx);
1555
- __ push(slot_operand);
1556
- __ push(Immediate(property->key()->AsLiteral()->handle()));
1557
- } else {
1558
- VisitForStackValue(property->obj());
1559
- VisitForStackValue(property->key());
1560
- }
1561
- }
1562
- break;
1563
- }
1564
- }
1565
-
1566
- // For compound assignments we need another deoptimization point after the
1567
- // variable/property load.
1568
- if (expr->is_compound()) {
1569
- { AccumulatorValueContext context(this);
1570
- switch (assign_type) {
1571
- case VARIABLE:
1572
- EmitVariableLoad(expr->target()->AsVariableProxy()->var());
1573
- PrepareForBailout(expr->target(), TOS_REG);
1574
- break;
1575
- case NAMED_PROPERTY:
1576
- EmitNamedPropertyLoad(property);
1577
- PrepareForBailoutForId(expr->CompoundLoadId(), TOS_REG);
1578
- break;
1579
- case KEYED_PROPERTY:
1580
- EmitKeyedPropertyLoad(property);
1581
- PrepareForBailoutForId(expr->CompoundLoadId(), TOS_REG);
1582
- break;
1583
- }
1584
- }
1585
-
1586
- Token::Value op = expr->binary_op();
1587
- __ push(eax); // Left operand goes on the stack.
1588
- VisitForAccumulatorValue(expr->value());
1589
-
1590
- OverwriteMode mode = expr->value()->ResultOverwriteAllowed()
1591
- ? OVERWRITE_RIGHT
1592
- : NO_OVERWRITE;
1593
- SetSourcePosition(expr->position() + 1);
1594
- AccumulatorValueContext context(this);
1595
- if (ShouldInlineSmiCase(op)) {
1596
- EmitInlineSmiBinaryOp(expr,
1597
- op,
1598
- mode,
1599
- expr->target(),
1600
- expr->value());
1601
- } else {
1602
- EmitBinaryOp(op, mode);
1603
- }
1604
-
1605
- // Deoptimization point in case the binary operation may have side effects.
1606
- PrepareForBailout(expr->binary_operation(), TOS_REG);
1607
- } else {
1608
- VisitForAccumulatorValue(expr->value());
1609
- }
1610
-
1611
- // Record source position before possible IC call.
1612
- SetSourcePosition(expr->position());
1613
-
1614
- // Store the value.
1615
- switch (assign_type) {
1616
- case VARIABLE:
1617
- EmitVariableAssignment(expr->target()->AsVariableProxy()->var(),
1618
- expr->op());
1619
- PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
1620
- context()->Plug(eax);
1621
- break;
1622
- case NAMED_PROPERTY:
1623
- EmitNamedPropertyAssignment(expr);
1624
- break;
1625
- case KEYED_PROPERTY:
1626
- EmitKeyedPropertyAssignment(expr);
1627
- break;
1628
- }
1629
- }
1630
-
1631
-
1632
- void FullCodeGenerator::EmitNamedPropertyLoad(Property* prop) {
1633
- SetSourcePosition(prop->position());
1634
- Literal* key = prop->key()->AsLiteral();
1635
- __ mov(ecx, Immediate(key->handle()));
1636
- Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
1637
- EmitCallIC(ic, RelocInfo::CODE_TARGET);
1638
- }
1639
-
1640
-
1641
- void FullCodeGenerator::EmitKeyedPropertyLoad(Property* prop) {
1642
- SetSourcePosition(prop->position());
1643
- Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize();
1644
- EmitCallIC(ic, RelocInfo::CODE_TARGET);
1645
- }
1646
-
1647
-
1648
- void FullCodeGenerator::EmitInlineSmiBinaryOp(Expression* expr,
1649
- Token::Value op,
1650
- OverwriteMode mode,
1651
- Expression* left,
1652
- Expression* right) {
1653
- // Do combined smi check of the operands. Left operand is on the
1654
- // stack. Right operand is in eax.
1655
- NearLabel done, smi_case, stub_call;
1656
- __ pop(edx);
1657
- __ mov(ecx, eax);
1658
- __ or_(eax, Operand(edx));
1659
- JumpPatchSite patch_site(masm_);
1660
- patch_site.EmitJumpIfSmi(eax, &smi_case);
1661
-
1662
- __ bind(&stub_call);
1663
- __ mov(eax, ecx);
1664
- TypeRecordingBinaryOpStub stub(op, mode);
1665
- EmitCallIC(stub.GetCode(), &patch_site);
1666
- __ jmp(&done);
1667
-
1668
- // Smi case.
1669
- __ bind(&smi_case);
1670
- __ mov(eax, edx); // Copy left operand in case of a stub call.
1671
-
1672
- switch (op) {
1673
- case Token::SAR:
1674
- __ SmiUntag(eax);
1675
- __ SmiUntag(ecx);
1676
- __ sar_cl(eax); // No checks of result necessary
1677
- __ SmiTag(eax);
1678
- break;
1679
- case Token::SHL: {
1680
- Label result_ok;
1681
- __ SmiUntag(eax);
1682
- __ SmiUntag(ecx);
1683
- __ shl_cl(eax);
1684
- // Check that the *signed* result fits in a smi.
1685
- __ cmp(eax, 0xc0000000);
1686
- __ j(positive, &result_ok);
1687
- __ SmiTag(ecx);
1688
- __ jmp(&stub_call);
1689
- __ bind(&result_ok);
1690
- __ SmiTag(eax);
1691
- break;
1692
- }
1693
- case Token::SHR: {
1694
- Label result_ok;
1695
- __ SmiUntag(eax);
1696
- __ SmiUntag(ecx);
1697
- __ shr_cl(eax);
1698
- __ test(eax, Immediate(0xc0000000));
1699
- __ j(zero, &result_ok);
1700
- __ SmiTag(ecx);
1701
- __ jmp(&stub_call);
1702
- __ bind(&result_ok);
1703
- __ SmiTag(eax);
1704
- break;
1705
- }
1706
- case Token::ADD:
1707
- __ add(eax, Operand(ecx));
1708
- __ j(overflow, &stub_call);
1709
- break;
1710
- case Token::SUB:
1711
- __ sub(eax, Operand(ecx));
1712
- __ j(overflow, &stub_call);
1713
- break;
1714
- case Token::MUL: {
1715
- __ SmiUntag(eax);
1716
- __ imul(eax, Operand(ecx));
1717
- __ j(overflow, &stub_call);
1718
- __ test(eax, Operand(eax));
1719
- __ j(not_zero, &done, taken);
1720
- __ mov(ebx, edx);
1721
- __ or_(ebx, Operand(ecx));
1722
- __ j(negative, &stub_call);
1723
- break;
1724
- }
1725
- case Token::BIT_OR:
1726
- __ or_(eax, Operand(ecx));
1727
- break;
1728
- case Token::BIT_AND:
1729
- __ and_(eax, Operand(ecx));
1730
- break;
1731
- case Token::BIT_XOR:
1732
- __ xor_(eax, Operand(ecx));
1733
- break;
1734
- default:
1735
- UNREACHABLE();
1736
- }
1737
-
1738
- __ bind(&done);
1739
- context()->Plug(eax);
1740
- }
1741
-
1742
-
1743
- void FullCodeGenerator::EmitBinaryOp(Token::Value op,
1744
- OverwriteMode mode) {
1745
- __ pop(edx);
1746
- TypeRecordingBinaryOpStub stub(op, mode);
1747
- EmitCallIC(stub.GetCode(), NULL); // NULL signals no inlined smi code.
1748
- context()->Plug(eax);
1749
- }
1750
-
1751
-
1752
- void FullCodeGenerator::EmitAssignment(Expression* expr, int bailout_ast_id) {
1753
- // Invalid left-hand sides are rewritten to have a 'throw
1754
- // ReferenceError' on the left-hand side.
1755
- if (!expr->IsValidLeftHandSide()) {
1756
- VisitForEffect(expr);
1757
- return;
1758
- }
1759
-
1760
- // Left-hand side can only be a property, a global or a (parameter or local)
1761
- // slot. Variables with rewrite to .arguments are treated as KEYED_PROPERTY.
1762
- enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY };
1763
- LhsKind assign_type = VARIABLE;
1764
- Property* prop = expr->AsProperty();
1765
- if (prop != NULL) {
1766
- assign_type = (prop->key()->IsPropertyName())
1767
- ? NAMED_PROPERTY
1768
- : KEYED_PROPERTY;
1769
- }
1770
-
1771
- switch (assign_type) {
1772
- case VARIABLE: {
1773
- Variable* var = expr->AsVariableProxy()->var();
1774
- EffectContext context(this);
1775
- EmitVariableAssignment(var, Token::ASSIGN);
1776
- break;
1777
- }
1778
- case NAMED_PROPERTY: {
1779
- __ push(eax); // Preserve value.
1780
- VisitForAccumulatorValue(prop->obj());
1781
- __ mov(edx, eax);
1782
- __ pop(eax); // Restore value.
1783
- __ mov(ecx, prop->key()->AsLiteral()->handle());
1784
- Handle<Code> ic = is_strict_mode()
1785
- ? isolate()->builtins()->StoreIC_Initialize_Strict()
1786
- : isolate()->builtins()->StoreIC_Initialize();
1787
- EmitCallIC(ic, RelocInfo::CODE_TARGET);
1788
- break;
1789
- }
1790
- case KEYED_PROPERTY: {
1791
- __ push(eax); // Preserve value.
1792
- if (prop->is_synthetic()) {
1793
- ASSERT(prop->obj()->AsVariableProxy() != NULL);
1794
- ASSERT(prop->key()->AsLiteral() != NULL);
1795
- { AccumulatorValueContext for_object(this);
1796
- EmitVariableLoad(prop->obj()->AsVariableProxy()->var());
1797
- }
1798
- __ mov(edx, eax);
1799
- __ Set(ecx, Immediate(prop->key()->AsLiteral()->handle()));
1800
- } else {
1801
- VisitForStackValue(prop->obj());
1802
- VisitForAccumulatorValue(prop->key());
1803
- __ mov(ecx, eax);
1804
- __ pop(edx);
1805
- }
1806
- __ pop(eax); // Restore value.
1807
- Handle<Code> ic = is_strict_mode()
1808
- ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict()
1809
- : isolate()->builtins()->KeyedStoreIC_Initialize();
1810
- EmitCallIC(ic, RelocInfo::CODE_TARGET);
1811
- break;
1812
- }
1813
- }
1814
- PrepareForBailoutForId(bailout_ast_id, TOS_REG);
1815
- context()->Plug(eax);
1816
- }
1817
-
1818
-
1819
- void FullCodeGenerator::EmitVariableAssignment(Variable* var,
1820
- Token::Value op) {
1821
- // Left-hand sides that rewrite to explicit property accesses do not reach
1822
- // here.
1823
- ASSERT(var != NULL);
1824
- ASSERT(var->is_global() || var->AsSlot() != NULL);
1825
-
1826
- if (var->is_global()) {
1827
- ASSERT(!var->is_this());
1828
- // Assignment to a global variable. Use inline caching for the
1829
- // assignment. Right-hand-side value is passed in eax, variable name in
1830
- // ecx, and the global object on the stack.
1831
- __ mov(ecx, var->name());
1832
- __ mov(edx, GlobalObjectOperand());
1833
- Handle<Code> ic = is_strict_mode()
1834
- ? isolate()->builtins()->StoreIC_Initialize_Strict()
1835
- : isolate()->builtins()->StoreIC_Initialize();
1836
- EmitCallIC(ic, RelocInfo::CODE_TARGET_CONTEXT);
1837
-
1838
- } else if (op == Token::INIT_CONST) {
1839
- // Like var declarations, const declarations are hoisted to function
1840
- // scope. However, unlike var initializers, const initializers are able
1841
- // to drill a hole to that function context, even from inside a 'with'
1842
- // context. We thus bypass the normal static scope lookup.
1843
- Slot* slot = var->AsSlot();
1844
- Label skip;
1845
- switch (slot->type()) {
1846
- case Slot::PARAMETER:
1847
- // No const parameters.
1848
- UNREACHABLE();
1849
- break;
1850
- case Slot::LOCAL:
1851
- __ mov(edx, Operand(ebp, SlotOffset(slot)));
1852
- __ cmp(edx, isolate()->factory()->the_hole_value());
1853
- __ j(not_equal, &skip);
1854
- __ mov(Operand(ebp, SlotOffset(slot)), eax);
1855
- break;
1856
- case Slot::CONTEXT: {
1857
- __ mov(ecx, ContextOperand(esi, Context::FCONTEXT_INDEX));
1858
- __ mov(edx, ContextOperand(ecx, slot->index()));
1859
- __ cmp(edx, isolate()->factory()->the_hole_value());
1860
- __ j(not_equal, &skip);
1861
- __ mov(ContextOperand(ecx, slot->index()), eax);
1862
- int offset = Context::SlotOffset(slot->index());
1863
- __ mov(edx, eax); // Preserve the stored value in eax.
1864
- __ RecordWrite(ecx, offset, edx, ebx);
1865
- break;
1866
- }
1867
- case Slot::LOOKUP:
1868
- __ push(eax);
1869
- __ push(esi);
1870
- __ push(Immediate(var->name()));
1871
- __ CallRuntime(Runtime::kInitializeConstContextSlot, 3);
1872
- break;
1873
- }
1874
- __ bind(&skip);
1875
-
1876
- } else if (var->mode() != Variable::CONST) {
1877
- // Perform the assignment for non-const variables. Const assignments
1878
- // are simply skipped.
1879
- Slot* slot = var->AsSlot();
1880
- switch (slot->type()) {
1881
- case Slot::PARAMETER:
1882
- case Slot::LOCAL:
1883
- // Perform the assignment.
1884
- __ mov(Operand(ebp, SlotOffset(slot)), eax);
1885
- break;
1886
-
1887
- case Slot::CONTEXT: {
1888
- MemOperand target = EmitSlotSearch(slot, ecx);
1889
- // Perform the assignment and issue the write barrier.
1890
- __ mov(target, eax);
1891
- // The value of the assignment is in eax. RecordWrite clobbers its
1892
- // register arguments.
1893
- __ mov(edx, eax);
1894
- int offset = Context::SlotOffset(slot->index());
1895
- __ RecordWrite(ecx, offset, edx, ebx);
1896
- break;
1897
- }
1898
-
1899
- case Slot::LOOKUP:
1900
- // Call the runtime for the assignment.
1901
- __ push(eax); // Value.
1902
- __ push(esi); // Context.
1903
- __ push(Immediate(var->name()));
1904
- __ push(Immediate(Smi::FromInt(strict_mode_flag())));
1905
- __ CallRuntime(Runtime::kStoreContextSlot, 4);
1906
- break;
1907
- }
1908
- }
1909
- }
1910
-
1911
-
1912
- void FullCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) {
1913
- // Assignment to a property, using a named store IC.
1914
- Property* prop = expr->target()->AsProperty();
1915
- ASSERT(prop != NULL);
1916
- ASSERT(prop->key()->AsLiteral() != NULL);
1917
-
1918
- // If the assignment starts a block of assignments to the same object,
1919
- // change to slow case to avoid the quadratic behavior of repeatedly
1920
- // adding fast properties.
1921
- if (expr->starts_initialization_block()) {
1922
- __ push(result_register());
1923
- __ push(Operand(esp, kPointerSize)); // Receiver is now under value.
1924
- __ CallRuntime(Runtime::kToSlowProperties, 1);
1925
- __ pop(result_register());
1926
- }
1927
-
1928
- // Record source code position before IC call.
1929
- SetSourcePosition(expr->position());
1930
- __ mov(ecx, prop->key()->AsLiteral()->handle());
1931
- if (expr->ends_initialization_block()) {
1932
- __ mov(edx, Operand(esp, 0));
1933
- } else {
1934
- __ pop(edx);
1935
- }
1936
- Handle<Code> ic = is_strict_mode()
1937
- ? isolate()->builtins()->StoreIC_Initialize_Strict()
1938
- : isolate()->builtins()->StoreIC_Initialize();
1939
- EmitCallIC(ic, RelocInfo::CODE_TARGET);
1940
-
1941
- // If the assignment ends an initialization block, revert to fast case.
1942
- if (expr->ends_initialization_block()) {
1943
- __ push(eax); // Result of assignment, saved even if not needed.
1944
- __ push(Operand(esp, kPointerSize)); // Receiver is under value.
1945
- __ CallRuntime(Runtime::kToFastProperties, 1);
1946
- __ pop(eax);
1947
- __ Drop(1);
1948
- }
1949
- PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
1950
- context()->Plug(eax);
1951
- }
1952
-
1953
-
1954
- void FullCodeGenerator::EmitKeyedPropertyAssignment(Assignment* expr) {
1955
- // Assignment to a property, using a keyed store IC.
1956
-
1957
- // If the assignment starts a block of assignments to the same object,
1958
- // change to slow case to avoid the quadratic behavior of repeatedly
1959
- // adding fast properties.
1960
- if (expr->starts_initialization_block()) {
1961
- __ push(result_register());
1962
- // Receiver is now under the key and value.
1963
- __ push(Operand(esp, 2 * kPointerSize));
1964
- __ CallRuntime(Runtime::kToSlowProperties, 1);
1965
- __ pop(result_register());
1966
- }
1967
-
1968
- __ pop(ecx);
1969
- if (expr->ends_initialization_block()) {
1970
- __ mov(edx, Operand(esp, 0)); // Leave receiver on the stack for later.
1971
- } else {
1972
- __ pop(edx);
1973
- }
1974
- // Record source code position before IC call.
1975
- SetSourcePosition(expr->position());
1976
- Handle<Code> ic = is_strict_mode()
1977
- ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict()
1978
- : isolate()->builtins()->KeyedStoreIC_Initialize();
1979
- EmitCallIC(ic, RelocInfo::CODE_TARGET);
1980
-
1981
- // If the assignment ends an initialization block, revert to fast case.
1982
- if (expr->ends_initialization_block()) {
1983
- __ pop(edx);
1984
- __ push(eax); // Result of assignment, saved even if not needed.
1985
- __ push(edx);
1986
- __ CallRuntime(Runtime::kToFastProperties, 1);
1987
- __ pop(eax);
1988
- }
1989
-
1990
- PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
1991
- context()->Plug(eax);
1992
- }
1993
-
1994
-
1995
- void FullCodeGenerator::VisitProperty(Property* expr) {
1996
- Comment cmnt(masm_, "[ Property");
1997
- Expression* key = expr->key();
1998
-
1999
- if (key->IsPropertyName()) {
2000
- VisitForAccumulatorValue(expr->obj());
2001
- EmitNamedPropertyLoad(expr);
2002
- context()->Plug(eax);
2003
- } else {
2004
- VisitForStackValue(expr->obj());
2005
- VisitForAccumulatorValue(expr->key());
2006
- __ pop(edx);
2007
- EmitKeyedPropertyLoad(expr);
2008
- context()->Plug(eax);
2009
- }
2010
- }
2011
-
2012
-
2013
- void FullCodeGenerator::EmitCallWithIC(Call* expr,
2014
- Handle<Object> name,
2015
- RelocInfo::Mode mode) {
2016
- // Code common for calls using the IC.
2017
- ZoneList<Expression*>* args = expr->arguments();
2018
- int arg_count = args->length();
2019
- { PreservePositionScope scope(masm()->positions_recorder());
2020
- for (int i = 0; i < arg_count; i++) {
2021
- VisitForStackValue(args->at(i));
2022
- }
2023
- __ Set(ecx, Immediate(name));
2024
- }
2025
- // Record source position of the IC call.
2026
- SetSourcePosition(expr->position());
2027
- InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP;
2028
- Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(
2029
- arg_count, in_loop);
2030
- EmitCallIC(ic, mode);
2031
- RecordJSReturnSite(expr);
2032
- // Restore context register.
2033
- __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
2034
- context()->Plug(eax);
2035
- }
2036
-
2037
-
2038
- void FullCodeGenerator::EmitKeyedCallWithIC(Call* expr,
2039
- Expression* key,
2040
- RelocInfo::Mode mode) {
2041
- // Load the key.
2042
- VisitForAccumulatorValue(key);
2043
-
2044
- // Swap the name of the function and the receiver on the stack to follow
2045
- // the calling convention for call ICs.
2046
- __ pop(ecx);
2047
- __ push(eax);
2048
- __ push(ecx);
2049
-
2050
- // Load the arguments.
2051
- ZoneList<Expression*>* args = expr->arguments();
2052
- int arg_count = args->length();
2053
- { PreservePositionScope scope(masm()->positions_recorder());
2054
- for (int i = 0; i < arg_count; i++) {
2055
- VisitForStackValue(args->at(i));
2056
- }
2057
- }
2058
- // Record source position of the IC call.
2059
- SetSourcePosition(expr->position());
2060
- InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP;
2061
- Handle<Code> ic = isolate()->stub_cache()->ComputeKeyedCallInitialize(
2062
- arg_count, in_loop);
2063
- __ mov(ecx, Operand(esp, (arg_count + 1) * kPointerSize)); // Key.
2064
- EmitCallIC(ic, mode);
2065
- RecordJSReturnSite(expr);
2066
- // Restore context register.
2067
- __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
2068
- context()->DropAndPlug(1, eax); // Drop the key still on the stack.
2069
- }
2070
-
2071
-
2072
- void FullCodeGenerator::EmitCallWithStub(Call* expr) {
2073
- // Code common for calls using the call stub.
2074
- ZoneList<Expression*>* args = expr->arguments();
2075
- int arg_count = args->length();
2076
- { PreservePositionScope scope(masm()->positions_recorder());
2077
- for (int i = 0; i < arg_count; i++) {
2078
- VisitForStackValue(args->at(i));
2079
- }
2080
- }
2081
- // Record source position for debugger.
2082
- SetSourcePosition(expr->position());
2083
- InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP;
2084
- CallFunctionStub stub(arg_count, in_loop, RECEIVER_MIGHT_BE_VALUE);
2085
- __ CallStub(&stub);
2086
- RecordJSReturnSite(expr);
2087
- // Restore context register.
2088
- __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
2089
- context()->DropAndPlug(1, eax);
2090
- }
2091
-
2092
-
2093
- void FullCodeGenerator::EmitResolvePossiblyDirectEval(ResolveEvalFlag flag,
2094
- int arg_count) {
2095
- // Push copy of the first argument or undefined if it doesn't exist.
2096
- if (arg_count > 0) {
2097
- __ push(Operand(esp, arg_count * kPointerSize));
2098
- } else {
2099
- __ push(Immediate(isolate()->factory()->undefined_value()));
2100
- }
2101
-
2102
- // Push the receiver of the enclosing function.
2103
- __ push(Operand(ebp, (2 + scope()->num_parameters()) * kPointerSize));
2104
-
2105
- // Push the strict mode flag.
2106
- __ push(Immediate(Smi::FromInt(strict_mode_flag())));
2107
-
2108
- __ CallRuntime(flag == SKIP_CONTEXT_LOOKUP
2109
- ? Runtime::kResolvePossiblyDirectEvalNoLookup
2110
- : Runtime::kResolvePossiblyDirectEval, 4);
2111
- }
2112
-
2113
-
2114
- void FullCodeGenerator::VisitCall(Call* expr) {
2115
- #ifdef DEBUG
2116
- // We want to verify that RecordJSReturnSite gets called on all paths
2117
- // through this function. Avoid early returns.
2118
- expr->return_is_recorded_ = false;
2119
- #endif
2120
-
2121
- Comment cmnt(masm_, "[ Call");
2122
- Expression* fun = expr->expression();
2123
- Variable* var = fun->AsVariableProxy()->AsVariable();
2124
-
2125
- if (var != NULL && var->is_possibly_eval()) {
2126
- // In a call to eval, we first call %ResolvePossiblyDirectEval to
2127
- // resolve the function we need to call and the receiver of the
2128
- // call. Then we call the resolved function using the given
2129
- // arguments.
2130
- ZoneList<Expression*>* args = expr->arguments();
2131
- int arg_count = args->length();
2132
- { PreservePositionScope pos_scope(masm()->positions_recorder());
2133
- VisitForStackValue(fun);
2134
- // Reserved receiver slot.
2135
- __ push(Immediate(isolate()->factory()->undefined_value()));
2136
-
2137
- // Push the arguments.
2138
- for (int i = 0; i < arg_count; i++) {
2139
- VisitForStackValue(args->at(i));
2140
- }
2141
-
2142
- // If we know that eval can only be shadowed by eval-introduced
2143
- // variables we attempt to load the global eval function directly
2144
- // in generated code. If we succeed, there is no need to perform a
2145
- // context lookup in the runtime system.
2146
- Label done;
2147
- if (var->AsSlot() != NULL && var->mode() == Variable::DYNAMIC_GLOBAL) {
2148
- Label slow;
2149
- EmitLoadGlobalSlotCheckExtensions(var->AsSlot(),
2150
- NOT_INSIDE_TYPEOF,
2151
- &slow);
2152
- // Push the function and resolve eval.
2153
- __ push(eax);
2154
- EmitResolvePossiblyDirectEval(SKIP_CONTEXT_LOOKUP, arg_count);
2155
- __ jmp(&done);
2156
- __ bind(&slow);
2157
- }
2158
-
2159
- // Push copy of the function (found below the arguments) and
2160
- // resolve eval.
2161
- __ push(Operand(esp, (arg_count + 1) * kPointerSize));
2162
- EmitResolvePossiblyDirectEval(PERFORM_CONTEXT_LOOKUP, arg_count);
2163
- if (done.is_linked()) {
2164
- __ bind(&done);
2165
- }
2166
-
2167
- // The runtime call returns a pair of values in eax (function) and
2168
- // edx (receiver). Touch up the stack with the right values.
2169
- __ mov(Operand(esp, (arg_count + 0) * kPointerSize), edx);
2170
- __ mov(Operand(esp, (arg_count + 1) * kPointerSize), eax);
2171
- }
2172
- // Record source position for debugger.
2173
- SetSourcePosition(expr->position());
2174
- InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP;
2175
- CallFunctionStub stub(arg_count, in_loop, RECEIVER_MIGHT_BE_VALUE);
2176
- __ CallStub(&stub);
2177
- RecordJSReturnSite(expr);
2178
- // Restore context register.
2179
- __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
2180
- context()->DropAndPlug(1, eax);
2181
- } else if (var != NULL && !var->is_this() && var->is_global()) {
2182
- // Push global object as receiver for the call IC.
2183
- __ push(GlobalObjectOperand());
2184
- EmitCallWithIC(expr, var->name(), RelocInfo::CODE_TARGET_CONTEXT);
2185
- } else if (var != NULL && var->AsSlot() != NULL &&
2186
- var->AsSlot()->type() == Slot::LOOKUP) {
2187
- // Call to a lookup slot (dynamically introduced variable).
2188
- Label slow, done;
2189
-
2190
- { PreservePositionScope scope(masm()->positions_recorder());
2191
- // Generate code for loading from variables potentially shadowed
2192
- // by eval-introduced variables.
2193
- EmitDynamicLoadFromSlotFastCase(var->AsSlot(),
2194
- NOT_INSIDE_TYPEOF,
2195
- &slow,
2196
- &done);
2197
- }
2198
-
2199
- __ bind(&slow);
2200
- // Call the runtime to find the function to call (returned in eax)
2201
- // and the object holding it (returned in edx).
2202
- __ push(context_register());
2203
- __ push(Immediate(var->name()));
2204
- __ CallRuntime(Runtime::kLoadContextSlot, 2);
2205
- __ push(eax); // Function.
2206
- __ push(edx); // Receiver.
2207
-
2208
- // If fast case code has been generated, emit code to push the
2209
- // function and receiver and have the slow path jump around this
2210
- // code.
2211
- if (done.is_linked()) {
2212
- Label call;
2213
- __ jmp(&call);
2214
- __ bind(&done);
2215
- // Push function.
2216
- __ push(eax);
2217
- // Push global receiver.
2218
- __ mov(ebx, GlobalObjectOperand());
2219
- __ push(FieldOperand(ebx, GlobalObject::kGlobalReceiverOffset));
2220
- __ bind(&call);
2221
- }
2222
-
2223
- EmitCallWithStub(expr);
2224
- } else if (fun->AsProperty() != NULL) {
2225
- // Call to an object property.
2226
- Property* prop = fun->AsProperty();
2227
- Literal* key = prop->key()->AsLiteral();
2228
- if (key != NULL && key->handle()->IsSymbol()) {
2229
- // Call to a named property, use call IC.
2230
- { PreservePositionScope scope(masm()->positions_recorder());
2231
- VisitForStackValue(prop->obj());
2232
- }
2233
- EmitCallWithIC(expr, key->handle(), RelocInfo::CODE_TARGET);
2234
- } else {
2235
- // Call to a keyed property.
2236
- // For a synthetic property use keyed load IC followed by function call,
2237
- // for a regular property use keyed EmitCallIC.
2238
- if (prop->is_synthetic()) {
2239
- // Do not visit the object and key subexpressions (they are shared
2240
- // by all occurrences of the same rewritten parameter).
2241
- ASSERT(prop->obj()->AsVariableProxy() != NULL);
2242
- ASSERT(prop->obj()->AsVariableProxy()->var()->AsSlot() != NULL);
2243
- Slot* slot = prop->obj()->AsVariableProxy()->var()->AsSlot();
2244
- MemOperand operand = EmitSlotSearch(slot, edx);
2245
- __ mov(edx, operand);
2246
-
2247
- ASSERT(prop->key()->AsLiteral() != NULL);
2248
- ASSERT(prop->key()->AsLiteral()->handle()->IsSmi());
2249
- __ mov(eax, prop->key()->AsLiteral()->handle());
2250
-
2251
- // Record source code position for IC call.
2252
- SetSourcePosition(prop->position());
2253
-
2254
- Handle<Code> ic = isolate()->builtins()->KeyedLoadIC_Initialize();
2255
- EmitCallIC(ic, RelocInfo::CODE_TARGET);
2256
- // Push result (function).
2257
- __ push(eax);
2258
- // Push Global receiver.
2259
- __ mov(ecx, GlobalObjectOperand());
2260
- __ push(FieldOperand(ecx, GlobalObject::kGlobalReceiverOffset));
2261
- EmitCallWithStub(expr);
2262
- } else {
2263
- { PreservePositionScope scope(masm()->positions_recorder());
2264
- VisitForStackValue(prop->obj());
2265
- }
2266
- EmitKeyedCallWithIC(expr, prop->key(), RelocInfo::CODE_TARGET);
2267
- }
2268
- }
2269
- } else {
2270
- { PreservePositionScope scope(masm()->positions_recorder());
2271
- VisitForStackValue(fun);
2272
- }
2273
- // Load global receiver object.
2274
- __ mov(ebx, GlobalObjectOperand());
2275
- __ push(FieldOperand(ebx, GlobalObject::kGlobalReceiverOffset));
2276
- // Emit function call.
2277
- EmitCallWithStub(expr);
2278
- }
2279
-
2280
- #ifdef DEBUG
2281
- // RecordJSReturnSite should have been called.
2282
- ASSERT(expr->return_is_recorded_);
2283
- #endif
2284
- }
2285
-
2286
-
2287
- void FullCodeGenerator::VisitCallNew(CallNew* expr) {
2288
- Comment cmnt(masm_, "[ CallNew");
2289
- // According to ECMA-262, section 11.2.2, page 44, the function
2290
- // expression in new calls must be evaluated before the
2291
- // arguments.
2292
-
2293
- // Push constructor on the stack. If it's not a function it's used as
2294
- // receiver for CALL_NON_FUNCTION, otherwise the value on the stack is
2295
- // ignored.
2296
- VisitForStackValue(expr->expression());
2297
-
2298
- // Push the arguments ("left-to-right") on the stack.
2299
- ZoneList<Expression*>* args = expr->arguments();
2300
- int arg_count = args->length();
2301
- for (int i = 0; i < arg_count; i++) {
2302
- VisitForStackValue(args->at(i));
2303
- }
2304
-
2305
- // Call the construct call builtin that handles allocation and
2306
- // constructor invocation.
2307
- SetSourcePosition(expr->position());
2308
-
2309
- // Load function and argument count into edi and eax.
2310
- __ Set(eax, Immediate(arg_count));
2311
- __ mov(edi, Operand(esp, arg_count * kPointerSize));
2312
-
2313
- Handle<Code> construct_builtin =
2314
- isolate()->builtins()->JSConstructCall();
2315
- __ call(construct_builtin, RelocInfo::CONSTRUCT_CALL);
2316
- context()->Plug(eax);
2317
- }
2318
-
2319
-
2320
- void FullCodeGenerator::EmitIsSmi(ZoneList<Expression*>* args) {
2321
- ASSERT(args->length() == 1);
2322
-
2323
- VisitForAccumulatorValue(args->at(0));
2324
-
2325
- Label materialize_true, materialize_false;
2326
- Label* if_true = NULL;
2327
- Label* if_false = NULL;
2328
- Label* fall_through = NULL;
2329
- context()->PrepareTest(&materialize_true, &materialize_false,
2330
- &if_true, &if_false, &fall_through);
2331
-
2332
- PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
2333
- __ test(eax, Immediate(kSmiTagMask));
2334
- Split(zero, if_true, if_false, fall_through);
2335
-
2336
- context()->Plug(if_true, if_false);
2337
- }
2338
-
2339
-
2340
- void FullCodeGenerator::EmitIsNonNegativeSmi(ZoneList<Expression*>* args) {
2341
- ASSERT(args->length() == 1);
2342
-
2343
- VisitForAccumulatorValue(args->at(0));
2344
-
2345
- Label materialize_true, materialize_false;
2346
- Label* if_true = NULL;
2347
- Label* if_false = NULL;
2348
- Label* fall_through = NULL;
2349
- context()->PrepareTest(&materialize_true, &materialize_false,
2350
- &if_true, &if_false, &fall_through);
2351
-
2352
- PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
2353
- __ test(eax, Immediate(kSmiTagMask | 0x80000000));
2354
- Split(zero, if_true, if_false, fall_through);
2355
-
2356
- context()->Plug(if_true, if_false);
2357
- }
2358
-
2359
-
2360
- void FullCodeGenerator::EmitIsObject(ZoneList<Expression*>* args) {
2361
- ASSERT(args->length() == 1);
2362
-
2363
- VisitForAccumulatorValue(args->at(0));
2364
-
2365
- Label materialize_true, materialize_false;
2366
- Label* if_true = NULL;
2367
- Label* if_false = NULL;
2368
- Label* fall_through = NULL;
2369
- context()->PrepareTest(&materialize_true, &materialize_false,
2370
- &if_true, &if_false, &fall_through);
2371
-
2372
- __ test(eax, Immediate(kSmiTagMask));
2373
- __ j(zero, if_false);
2374
- __ cmp(eax, isolate()->factory()->null_value());
2375
- __ j(equal, if_true);
2376
- __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
2377
- // Undetectable objects behave like undefined when tested with typeof.
2378
- __ movzx_b(ecx, FieldOperand(ebx, Map::kBitFieldOffset));
2379
- __ test(ecx, Immediate(1 << Map::kIsUndetectable));
2380
- __ j(not_zero, if_false);
2381
- __ movzx_b(ecx, FieldOperand(ebx, Map::kInstanceTypeOffset));
2382
- __ cmp(ecx, FIRST_JS_OBJECT_TYPE);
2383
- __ j(below, if_false);
2384
- __ cmp(ecx, LAST_JS_OBJECT_TYPE);
2385
- PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
2386
- Split(below_equal, if_true, if_false, fall_through);
2387
-
2388
- context()->Plug(if_true, if_false);
2389
- }
2390
-
2391
-
2392
- void FullCodeGenerator::EmitIsSpecObject(ZoneList<Expression*>* args) {
2393
- ASSERT(args->length() == 1);
2394
-
2395
- VisitForAccumulatorValue(args->at(0));
2396
-
2397
- Label materialize_true, materialize_false;
2398
- Label* if_true = NULL;
2399
- Label* if_false = NULL;
2400
- Label* fall_through = NULL;
2401
- context()->PrepareTest(&materialize_true, &materialize_false,
2402
- &if_true, &if_false, &fall_through);
2403
-
2404
- __ test(eax, Immediate(kSmiTagMask));
2405
- __ j(equal, if_false);
2406
- __ CmpObjectType(eax, FIRST_JS_OBJECT_TYPE, ebx);
2407
- PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
2408
- Split(above_equal, if_true, if_false, fall_through);
2409
-
2410
- context()->Plug(if_true, if_false);
2411
- }
2412
-
2413
-
2414
- void FullCodeGenerator::EmitIsUndetectableObject(ZoneList<Expression*>* args) {
2415
- ASSERT(args->length() == 1);
2416
-
2417
- VisitForAccumulatorValue(args->at(0));
2418
-
2419
- Label materialize_true, materialize_false;
2420
- Label* if_true = NULL;
2421
- Label* if_false = NULL;
2422
- Label* fall_through = NULL;
2423
- context()->PrepareTest(&materialize_true, &materialize_false,
2424
- &if_true, &if_false, &fall_through);
2425
-
2426
- __ test(eax, Immediate(kSmiTagMask));
2427
- __ j(zero, if_false);
2428
- __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
2429
- __ movzx_b(ebx, FieldOperand(ebx, Map::kBitFieldOffset));
2430
- __ test(ebx, Immediate(1 << Map::kIsUndetectable));
2431
- PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
2432
- Split(not_zero, if_true, if_false, fall_through);
2433
-
2434
- context()->Plug(if_true, if_false);
2435
- }
2436
-
2437
-
2438
- void FullCodeGenerator::EmitIsStringWrapperSafeForDefaultValueOf(
2439
- ZoneList<Expression*>* args) {
2440
- ASSERT(args->length() == 1);
2441
-
2442
- VisitForAccumulatorValue(args->at(0));
2443
-
2444
- Label materialize_true, materialize_false;
2445
- Label* if_true = NULL;
2446
- Label* if_false = NULL;
2447
- Label* fall_through = NULL;
2448
- context()->PrepareTest(&materialize_true, &materialize_false,
2449
- &if_true, &if_false, &fall_through);
2450
-
2451
- if (FLAG_debug_code) __ AbortIfSmi(eax);
2452
-
2453
- // Check whether this map has already been checked to be safe for default
2454
- // valueOf.
2455
- __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
2456
- __ test_b(FieldOperand(ebx, Map::kBitField2Offset),
2457
- 1 << Map::kStringWrapperSafeForDefaultValueOf);
2458
- __ j(not_zero, if_true);
2459
-
2460
- // Check for fast case object. Return false for slow case objects.
2461
- __ mov(ecx, FieldOperand(eax, JSObject::kPropertiesOffset));
2462
- __ mov(ecx, FieldOperand(ecx, HeapObject::kMapOffset));
2463
- __ cmp(ecx, FACTORY->hash_table_map());
2464
- __ j(equal, if_false);
2465
-
2466
- // Look for valueOf symbol in the descriptor array, and indicate false if
2467
- // found. The type is not checked, so if it is a transition it is a false
2468
- // negative.
2469
- __ mov(ebx, FieldOperand(ebx, Map::kInstanceDescriptorsOffset));
2470
- __ mov(ecx, FieldOperand(ebx, FixedArray::kLengthOffset));
2471
- // ebx: descriptor array
2472
- // ecx: length of descriptor array
2473
- // Calculate the end of the descriptor array.
2474
- STATIC_ASSERT(kSmiTag == 0);
2475
- STATIC_ASSERT(kSmiTagSize == 1);
2476
- STATIC_ASSERT(kPointerSize == 4);
2477
- __ lea(ecx, Operand(ebx, ecx, times_2, FixedArray::kHeaderSize));
2478
- // Calculate location of the first key name.
2479
- __ add(Operand(ebx),
2480
- Immediate(FixedArray::kHeaderSize +
2481
- DescriptorArray::kFirstIndex * kPointerSize));
2482
- // Loop through all the keys in the descriptor array. If one of these is the
2483
- // symbol valueOf the result is false.
2484
- Label entry, loop;
2485
- __ jmp(&entry);
2486
- __ bind(&loop);
2487
- __ mov(edx, FieldOperand(ebx, 0));
2488
- __ cmp(edx, FACTORY->value_of_symbol());
2489
- __ j(equal, if_false);
2490
- __ add(Operand(ebx), Immediate(kPointerSize));
2491
- __ bind(&entry);
2492
- __ cmp(ebx, Operand(ecx));
2493
- __ j(not_equal, &loop);
2494
-
2495
- // Reload map as register ebx was used as temporary above.
2496
- __ mov(ebx, FieldOperand(eax, HeapObject::kMapOffset));
2497
-
2498
- // If a valueOf property is not found on the object check that it's
2499
- // prototype is the un-modified String prototype. If not result is false.
2500
- __ mov(ecx, FieldOperand(ebx, Map::kPrototypeOffset));
2501
- __ test(ecx, Immediate(kSmiTagMask));
2502
- __ j(zero, if_false);
2503
- __ mov(ecx, FieldOperand(ecx, HeapObject::kMapOffset));
2504
- __ mov(edx, Operand(esi, Context::SlotOffset(Context::GLOBAL_INDEX)));
2505
- __ mov(edx,
2506
- FieldOperand(edx, GlobalObject::kGlobalContextOffset));
2507
- __ cmp(ecx,
2508
- ContextOperand(edx,
2509
- Context::STRING_FUNCTION_PROTOTYPE_MAP_INDEX));
2510
- __ j(not_equal, if_false);
2511
- // Set the bit in the map to indicate that it has been checked safe for
2512
- // default valueOf and set true result.
2513
- __ or_(FieldOperand(ebx, Map::kBitField2Offset),
2514
- Immediate(1 << Map::kStringWrapperSafeForDefaultValueOf));
2515
- __ jmp(if_true);
2516
-
2517
- PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
2518
- context()->Plug(if_true, if_false);
2519
- }
2520
-
2521
-
2522
- void FullCodeGenerator::EmitIsFunction(ZoneList<Expression*>* args) {
2523
- ASSERT(args->length() == 1);
2524
-
2525
- VisitForAccumulatorValue(args->at(0));
2526
-
2527
- Label materialize_true, materialize_false;
2528
- Label* if_true = NULL;
2529
- Label* if_false = NULL;
2530
- Label* fall_through = NULL;
2531
- context()->PrepareTest(&materialize_true, &materialize_false,
2532
- &if_true, &if_false, &fall_through);
2533
-
2534
- __ test(eax, Immediate(kSmiTagMask));
2535
- __ j(zero, if_false);
2536
- __ CmpObjectType(eax, JS_FUNCTION_TYPE, ebx);
2537
- PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
2538
- Split(equal, if_true, if_false, fall_through);
2539
-
2540
- context()->Plug(if_true, if_false);
2541
- }
2542
-
2543
-
2544
- void FullCodeGenerator::EmitIsArray(ZoneList<Expression*>* args) {
2545
- ASSERT(args->length() == 1);
2546
-
2547
- VisitForAccumulatorValue(args->at(0));
2548
-
2549
- Label materialize_true, materialize_false;
2550
- Label* if_true = NULL;
2551
- Label* if_false = NULL;
2552
- Label* fall_through = NULL;
2553
- context()->PrepareTest(&materialize_true, &materialize_false,
2554
- &if_true, &if_false, &fall_through);
2555
-
2556
- __ test(eax, Immediate(kSmiTagMask));
2557
- __ j(equal, if_false);
2558
- __ CmpObjectType(eax, JS_ARRAY_TYPE, ebx);
2559
- PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
2560
- Split(equal, if_true, if_false, fall_through);
2561
-
2562
- context()->Plug(if_true, if_false);
2563
- }
2564
-
2565
-
2566
- void FullCodeGenerator::EmitIsRegExp(ZoneList<Expression*>* args) {
2567
- ASSERT(args->length() == 1);
2568
-
2569
- VisitForAccumulatorValue(args->at(0));
2570
-
2571
- Label materialize_true, materialize_false;
2572
- Label* if_true = NULL;
2573
- Label* if_false = NULL;
2574
- Label* fall_through = NULL;
2575
- context()->PrepareTest(&materialize_true, &materialize_false,
2576
- &if_true, &if_false, &fall_through);
2577
-
2578
- __ test(eax, Immediate(kSmiTagMask));
2579
- __ j(equal, if_false);
2580
- __ CmpObjectType(eax, JS_REGEXP_TYPE, ebx);
2581
- PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
2582
- Split(equal, if_true, if_false, fall_through);
2583
-
2584
- context()->Plug(if_true, if_false);
2585
- }
2586
-
2587
-
2588
-
2589
- void FullCodeGenerator::EmitIsConstructCall(ZoneList<Expression*>* args) {
2590
- ASSERT(args->length() == 0);
2591
-
2592
- Label materialize_true, materialize_false;
2593
- Label* if_true = NULL;
2594
- Label* if_false = NULL;
2595
- Label* fall_through = NULL;
2596
- context()->PrepareTest(&materialize_true, &materialize_false,
2597
- &if_true, &if_false, &fall_through);
2598
-
2599
- // Get the frame pointer for the calling frame.
2600
- __ mov(eax, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
2601
-
2602
- // Skip the arguments adaptor frame if it exists.
2603
- Label check_frame_marker;
2604
- __ cmp(Operand(eax, StandardFrameConstants::kContextOffset),
2605
- Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
2606
- __ j(not_equal, &check_frame_marker);
2607
- __ mov(eax, Operand(eax, StandardFrameConstants::kCallerFPOffset));
2608
-
2609
- // Check the marker in the calling frame.
2610
- __ bind(&check_frame_marker);
2611
- __ cmp(Operand(eax, StandardFrameConstants::kMarkerOffset),
2612
- Immediate(Smi::FromInt(StackFrame::CONSTRUCT)));
2613
- PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
2614
- Split(equal, if_true, if_false, fall_through);
2615
-
2616
- context()->Plug(if_true, if_false);
2617
- }
2618
-
2619
-
2620
- void FullCodeGenerator::EmitObjectEquals(ZoneList<Expression*>* args) {
2621
- ASSERT(args->length() == 2);
2622
-
2623
- // Load the two objects into registers and perform the comparison.
2624
- VisitForStackValue(args->at(0));
2625
- VisitForAccumulatorValue(args->at(1));
2626
-
2627
- Label materialize_true, materialize_false;
2628
- Label* if_true = NULL;
2629
- Label* if_false = NULL;
2630
- Label* fall_through = NULL;
2631
- context()->PrepareTest(&materialize_true, &materialize_false,
2632
- &if_true, &if_false, &fall_through);
2633
-
2634
- __ pop(ebx);
2635
- __ cmp(eax, Operand(ebx));
2636
- PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
2637
- Split(equal, if_true, if_false, fall_through);
2638
-
2639
- context()->Plug(if_true, if_false);
2640
- }
2641
-
2642
-
2643
- void FullCodeGenerator::EmitArguments(ZoneList<Expression*>* args) {
2644
- ASSERT(args->length() == 1);
2645
-
2646
- // ArgumentsAccessStub expects the key in edx and the formal
2647
- // parameter count in eax.
2648
- VisitForAccumulatorValue(args->at(0));
2649
- __ mov(edx, eax);
2650
- __ mov(eax, Immediate(Smi::FromInt(scope()->num_parameters())));
2651
- ArgumentsAccessStub stub(ArgumentsAccessStub::READ_ELEMENT);
2652
- __ CallStub(&stub);
2653
- context()->Plug(eax);
2654
- }
2655
-
2656
-
2657
- void FullCodeGenerator::EmitArgumentsLength(ZoneList<Expression*>* args) {
2658
- ASSERT(args->length() == 0);
2659
-
2660
- Label exit;
2661
- // Get the number of formal parameters.
2662
- __ Set(eax, Immediate(Smi::FromInt(scope()->num_parameters())));
2663
-
2664
- // Check if the calling frame is an arguments adaptor frame.
2665
- __ mov(ebx, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
2666
- __ cmp(Operand(ebx, StandardFrameConstants::kContextOffset),
2667
- Immediate(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
2668
- __ j(not_equal, &exit);
2669
-
2670
- // Arguments adaptor case: Read the arguments length from the
2671
- // adaptor frame.
2672
- __ mov(eax, Operand(ebx, ArgumentsAdaptorFrameConstants::kLengthOffset));
2673
-
2674
- __ bind(&exit);
2675
- if (FLAG_debug_code) __ AbortIfNotSmi(eax);
2676
- context()->Plug(eax);
2677
- }
2678
-
2679
-
2680
- void FullCodeGenerator::EmitClassOf(ZoneList<Expression*>* args) {
2681
- ASSERT(args->length() == 1);
2682
- Label done, null, function, non_function_constructor;
2683
-
2684
- VisitForAccumulatorValue(args->at(0));
2685
-
2686
- // If the object is a smi, we return null.
2687
- __ test(eax, Immediate(kSmiTagMask));
2688
- __ j(zero, &null);
2689
-
2690
- // Check that the object is a JS object but take special care of JS
2691
- // functions to make sure they have 'Function' as their class.
2692
- __ CmpObjectType(eax, FIRST_JS_OBJECT_TYPE, eax); // Map is now in eax.
2693
- __ j(below, &null);
2694
-
2695
- // As long as JS_FUNCTION_TYPE is the last instance type and it is
2696
- // right after LAST_JS_OBJECT_TYPE, we can avoid checking for
2697
- // LAST_JS_OBJECT_TYPE.
2698
- ASSERT(LAST_TYPE == JS_FUNCTION_TYPE);
2699
- ASSERT(JS_FUNCTION_TYPE == LAST_JS_OBJECT_TYPE + 1);
2700
- __ CmpInstanceType(eax, JS_FUNCTION_TYPE);
2701
- __ j(equal, &function);
2702
-
2703
- // Check if the constructor in the map is a function.
2704
- __ mov(eax, FieldOperand(eax, Map::kConstructorOffset));
2705
- __ CmpObjectType(eax, JS_FUNCTION_TYPE, ebx);
2706
- __ j(not_equal, &non_function_constructor);
2707
-
2708
- // eax now contains the constructor function. Grab the
2709
- // instance class name from there.
2710
- __ mov(eax, FieldOperand(eax, JSFunction::kSharedFunctionInfoOffset));
2711
- __ mov(eax, FieldOperand(eax, SharedFunctionInfo::kInstanceClassNameOffset));
2712
- __ jmp(&done);
2713
-
2714
- // Functions have class 'Function'.
2715
- __ bind(&function);
2716
- __ mov(eax, isolate()->factory()->function_class_symbol());
2717
- __ jmp(&done);
2718
-
2719
- // Objects with a non-function constructor have class 'Object'.
2720
- __ bind(&non_function_constructor);
2721
- __ mov(eax, isolate()->factory()->Object_symbol());
2722
- __ jmp(&done);
2723
-
2724
- // Non-JS objects have class null.
2725
- __ bind(&null);
2726
- __ mov(eax, isolate()->factory()->null_value());
2727
-
2728
- // All done.
2729
- __ bind(&done);
2730
-
2731
- context()->Plug(eax);
2732
- }
2733
-
2734
-
2735
- void FullCodeGenerator::EmitLog(ZoneList<Expression*>* args) {
2736
- // Conditionally generate a log call.
2737
- // Args:
2738
- // 0 (literal string): The type of logging (corresponds to the flags).
2739
- // This is used to determine whether or not to generate the log call.
2740
- // 1 (string): Format string. Access the string at argument index 2
2741
- // with '%2s' (see Logger::LogRuntime for all the formats).
2742
- // 2 (array): Arguments to the format string.
2743
- ASSERT_EQ(args->length(), 3);
2744
- #ifdef ENABLE_LOGGING_AND_PROFILING
2745
- if (CodeGenerator::ShouldGenerateLog(args->at(0))) {
2746
- VisitForStackValue(args->at(1));
2747
- VisitForStackValue(args->at(2));
2748
- __ CallRuntime(Runtime::kLog, 2);
2749
- }
2750
- #endif
2751
- // Finally, we're expected to leave a value on the top of the stack.
2752
- __ mov(eax, isolate()->factory()->undefined_value());
2753
- context()->Plug(eax);
2754
- }
2755
-
2756
-
2757
- void FullCodeGenerator::EmitRandomHeapNumber(ZoneList<Expression*>* args) {
2758
- ASSERT(args->length() == 0);
2759
-
2760
- Label slow_allocate_heapnumber;
2761
- Label heapnumber_allocated;
2762
-
2763
- __ AllocateHeapNumber(edi, ebx, ecx, &slow_allocate_heapnumber);
2764
- __ jmp(&heapnumber_allocated);
2765
-
2766
- __ bind(&slow_allocate_heapnumber);
2767
- // Allocate a heap number.
2768
- __ CallRuntime(Runtime::kNumberAlloc, 0);
2769
- __ mov(edi, eax);
2770
-
2771
- __ bind(&heapnumber_allocated);
2772
-
2773
- __ PrepareCallCFunction(1, ebx);
2774
- __ mov(Operand(esp, 0), Immediate(ExternalReference::isolate_address()));
2775
- __ CallCFunction(ExternalReference::random_uint32_function(isolate()),
2776
- 1);
2777
-
2778
- // Convert 32 random bits in eax to 0.(32 random bits) in a double
2779
- // by computing:
2780
- // ( 1.(20 0s)(32 random bits) x 2^20 ) - (1.0 x 2^20)).
2781
- // This is implemented on both SSE2 and FPU.
2782
- if (CpuFeatures::IsSupported(SSE2)) {
2783
- CpuFeatures::Scope fscope(SSE2);
2784
- __ mov(ebx, Immediate(0x49800000)); // 1.0 x 2^20 as single.
2785
- __ movd(xmm1, Operand(ebx));
2786
- __ movd(xmm0, Operand(eax));
2787
- __ cvtss2sd(xmm1, xmm1);
2788
- __ pxor(xmm0, xmm1);
2789
- __ subsd(xmm0, xmm1);
2790
- __ movdbl(FieldOperand(edi, HeapNumber::kValueOffset), xmm0);
2791
- } else {
2792
- // 0x4130000000000000 is 1.0 x 2^20 as a double.
2793
- __ mov(FieldOperand(edi, HeapNumber::kExponentOffset),
2794
- Immediate(0x41300000));
2795
- __ mov(FieldOperand(edi, HeapNumber::kMantissaOffset), eax);
2796
- __ fld_d(FieldOperand(edi, HeapNumber::kValueOffset));
2797
- __ mov(FieldOperand(edi, HeapNumber::kMantissaOffset), Immediate(0));
2798
- __ fld_d(FieldOperand(edi, HeapNumber::kValueOffset));
2799
- __ fsubp(1);
2800
- __ fstp_d(FieldOperand(edi, HeapNumber::kValueOffset));
2801
- }
2802
- __ mov(eax, edi);
2803
- context()->Plug(eax);
2804
- }
2805
-
2806
-
2807
- void FullCodeGenerator::EmitSubString(ZoneList<Expression*>* args) {
2808
- // Load the arguments on the stack and call the stub.
2809
- SubStringStub stub;
2810
- ASSERT(args->length() == 3);
2811
- VisitForStackValue(args->at(0));
2812
- VisitForStackValue(args->at(1));
2813
- VisitForStackValue(args->at(2));
2814
- __ CallStub(&stub);
2815
- context()->Plug(eax);
2816
- }
2817
-
2818
-
2819
- void FullCodeGenerator::EmitRegExpExec(ZoneList<Expression*>* args) {
2820
- // Load the arguments on the stack and call the stub.
2821
- RegExpExecStub stub;
2822
- ASSERT(args->length() == 4);
2823
- VisitForStackValue(args->at(0));
2824
- VisitForStackValue(args->at(1));
2825
- VisitForStackValue(args->at(2));
2826
- VisitForStackValue(args->at(3));
2827
- __ CallStub(&stub);
2828
- context()->Plug(eax);
2829
- }
2830
-
2831
-
2832
- void FullCodeGenerator::EmitValueOf(ZoneList<Expression*>* args) {
2833
- ASSERT(args->length() == 1);
2834
-
2835
- VisitForAccumulatorValue(args->at(0)); // Load the object.
2836
-
2837
- NearLabel done;
2838
- // If the object is a smi return the object.
2839
- __ test(eax, Immediate(kSmiTagMask));
2840
- __ j(zero, &done);
2841
- // If the object is not a value type, return the object.
2842
- __ CmpObjectType(eax, JS_VALUE_TYPE, ebx);
2843
- __ j(not_equal, &done);
2844
- __ mov(eax, FieldOperand(eax, JSValue::kValueOffset));
2845
-
2846
- __ bind(&done);
2847
- context()->Plug(eax);
2848
- }
2849
-
2850
-
2851
- void FullCodeGenerator::EmitMathPow(ZoneList<Expression*>* args) {
2852
- // Load the arguments on the stack and call the runtime function.
2853
- ASSERT(args->length() == 2);
2854
- VisitForStackValue(args->at(0));
2855
- VisitForStackValue(args->at(1));
2856
-
2857
- if (CpuFeatures::IsSupported(SSE2)) {
2858
- MathPowStub stub;
2859
- __ CallStub(&stub);
2860
- } else {
2861
- __ CallRuntime(Runtime::kMath_pow, 2);
2862
- }
2863
- context()->Plug(eax);
2864
- }
2865
-
2866
-
2867
- void FullCodeGenerator::EmitSetValueOf(ZoneList<Expression*>* args) {
2868
- ASSERT(args->length() == 2);
2869
-
2870
- VisitForStackValue(args->at(0)); // Load the object.
2871
- VisitForAccumulatorValue(args->at(1)); // Load the value.
2872
- __ pop(ebx); // eax = value. ebx = object.
2873
-
2874
- NearLabel done;
2875
- // If the object is a smi, return the value.
2876
- __ test(ebx, Immediate(kSmiTagMask));
2877
- __ j(zero, &done);
2878
-
2879
- // If the object is not a value type, return the value.
2880
- __ CmpObjectType(ebx, JS_VALUE_TYPE, ecx);
2881
- __ j(not_equal, &done);
2882
-
2883
- // Store the value.
2884
- __ mov(FieldOperand(ebx, JSValue::kValueOffset), eax);
2885
- // Update the write barrier. Save the value as it will be
2886
- // overwritten by the write barrier code and is needed afterward.
2887
- __ mov(edx, eax);
2888
- __ RecordWrite(ebx, JSValue::kValueOffset, edx, ecx);
2889
-
2890
- __ bind(&done);
2891
- context()->Plug(eax);
2892
- }
2893
-
2894
-
2895
- void FullCodeGenerator::EmitNumberToString(ZoneList<Expression*>* args) {
2896
- ASSERT_EQ(args->length(), 1);
2897
-
2898
- // Load the argument on the stack and call the stub.
2899
- VisitForStackValue(args->at(0));
2900
-
2901
- NumberToStringStub stub;
2902
- __ CallStub(&stub);
2903
- context()->Plug(eax);
2904
- }
2905
-
2906
-
2907
- void FullCodeGenerator::EmitStringCharFromCode(ZoneList<Expression*>* args) {
2908
- ASSERT(args->length() == 1);
2909
-
2910
- VisitForAccumulatorValue(args->at(0));
2911
-
2912
- Label done;
2913
- StringCharFromCodeGenerator generator(eax, ebx);
2914
- generator.GenerateFast(masm_);
2915
- __ jmp(&done);
2916
-
2917
- NopRuntimeCallHelper call_helper;
2918
- generator.GenerateSlow(masm_, call_helper);
2919
-
2920
- __ bind(&done);
2921
- context()->Plug(ebx);
2922
- }
2923
-
2924
-
2925
- void FullCodeGenerator::EmitStringCharCodeAt(ZoneList<Expression*>* args) {
2926
- ASSERT(args->length() == 2);
2927
-
2928
- VisitForStackValue(args->at(0));
2929
- VisitForAccumulatorValue(args->at(1));
2930
-
2931
- Register object = ebx;
2932
- Register index = eax;
2933
- Register scratch = ecx;
2934
- Register result = edx;
2935
-
2936
- __ pop(object);
2937
-
2938
- Label need_conversion;
2939
- Label index_out_of_range;
2940
- Label done;
2941
- StringCharCodeAtGenerator generator(object,
2942
- index,
2943
- scratch,
2944
- result,
2945
- &need_conversion,
2946
- &need_conversion,
2947
- &index_out_of_range,
2948
- STRING_INDEX_IS_NUMBER);
2949
- generator.GenerateFast(masm_);
2950
- __ jmp(&done);
2951
-
2952
- __ bind(&index_out_of_range);
2953
- // When the index is out of range, the spec requires us to return
2954
- // NaN.
2955
- __ Set(result, Immediate(isolate()->factory()->nan_value()));
2956
- __ jmp(&done);
2957
-
2958
- __ bind(&need_conversion);
2959
- // Move the undefined value into the result register, which will
2960
- // trigger conversion.
2961
- __ Set(result, Immediate(isolate()->factory()->undefined_value()));
2962
- __ jmp(&done);
2963
-
2964
- NopRuntimeCallHelper call_helper;
2965
- generator.GenerateSlow(masm_, call_helper);
2966
-
2967
- __ bind(&done);
2968
- context()->Plug(result);
2969
- }
2970
-
2971
-
2972
- void FullCodeGenerator::EmitStringCharAt(ZoneList<Expression*>* args) {
2973
- ASSERT(args->length() == 2);
2974
-
2975
- VisitForStackValue(args->at(0));
2976
- VisitForAccumulatorValue(args->at(1));
2977
-
2978
- Register object = ebx;
2979
- Register index = eax;
2980
- Register scratch1 = ecx;
2981
- Register scratch2 = edx;
2982
- Register result = eax;
2983
-
2984
- __ pop(object);
2985
-
2986
- Label need_conversion;
2987
- Label index_out_of_range;
2988
- Label done;
2989
- StringCharAtGenerator generator(object,
2990
- index,
2991
- scratch1,
2992
- scratch2,
2993
- result,
2994
- &need_conversion,
2995
- &need_conversion,
2996
- &index_out_of_range,
2997
- STRING_INDEX_IS_NUMBER);
2998
- generator.GenerateFast(masm_);
2999
- __ jmp(&done);
3000
-
3001
- __ bind(&index_out_of_range);
3002
- // When the index is out of range, the spec requires us to return
3003
- // the empty string.
3004
- __ Set(result, Immediate(isolate()->factory()->empty_string()));
3005
- __ jmp(&done);
3006
-
3007
- __ bind(&need_conversion);
3008
- // Move smi zero into the result register, which will trigger
3009
- // conversion.
3010
- __ Set(result, Immediate(Smi::FromInt(0)));
3011
- __ jmp(&done);
3012
-
3013
- NopRuntimeCallHelper call_helper;
3014
- generator.GenerateSlow(masm_, call_helper);
3015
-
3016
- __ bind(&done);
3017
- context()->Plug(result);
3018
- }
3019
-
3020
-
3021
- void FullCodeGenerator::EmitStringAdd(ZoneList<Expression*>* args) {
3022
- ASSERT_EQ(2, args->length());
3023
-
3024
- VisitForStackValue(args->at(0));
3025
- VisitForStackValue(args->at(1));
3026
-
3027
- StringAddStub stub(NO_STRING_ADD_FLAGS);
3028
- __ CallStub(&stub);
3029
- context()->Plug(eax);
3030
- }
3031
-
3032
-
3033
- void FullCodeGenerator::EmitStringCompare(ZoneList<Expression*>* args) {
3034
- ASSERT_EQ(2, args->length());
3035
-
3036
- VisitForStackValue(args->at(0));
3037
- VisitForStackValue(args->at(1));
3038
-
3039
- StringCompareStub stub;
3040
- __ CallStub(&stub);
3041
- context()->Plug(eax);
3042
- }
3043
-
3044
-
3045
- void FullCodeGenerator::EmitMathSin(ZoneList<Expression*>* args) {
3046
- // Load the argument on the stack and call the stub.
3047
- TranscendentalCacheStub stub(TranscendentalCache::SIN,
3048
- TranscendentalCacheStub::TAGGED);
3049
- ASSERT(args->length() == 1);
3050
- VisitForStackValue(args->at(0));
3051
- __ CallStub(&stub);
3052
- context()->Plug(eax);
3053
- }
3054
-
3055
-
3056
- void FullCodeGenerator::EmitMathCos(ZoneList<Expression*>* args) {
3057
- // Load the argument on the stack and call the stub.
3058
- TranscendentalCacheStub stub(TranscendentalCache::COS,
3059
- TranscendentalCacheStub::TAGGED);
3060
- ASSERT(args->length() == 1);
3061
- VisitForStackValue(args->at(0));
3062
- __ CallStub(&stub);
3063
- context()->Plug(eax);
3064
- }
3065
-
3066
-
3067
- void FullCodeGenerator::EmitMathLog(ZoneList<Expression*>* args) {
3068
- // Load the argument on the stack and call the stub.
3069
- TranscendentalCacheStub stub(TranscendentalCache::LOG,
3070
- TranscendentalCacheStub::TAGGED);
3071
- ASSERT(args->length() == 1);
3072
- VisitForStackValue(args->at(0));
3073
- __ CallStub(&stub);
3074
- context()->Plug(eax);
3075
- }
3076
-
3077
-
3078
- void FullCodeGenerator::EmitMathSqrt(ZoneList<Expression*>* args) {
3079
- // Load the argument on the stack and call the runtime function.
3080
- ASSERT(args->length() == 1);
3081
- VisitForStackValue(args->at(0));
3082
- __ CallRuntime(Runtime::kMath_sqrt, 1);
3083
- context()->Plug(eax);
3084
- }
3085
-
3086
-
3087
- void FullCodeGenerator::EmitCallFunction(ZoneList<Expression*>* args) {
3088
- ASSERT(args->length() >= 2);
3089
-
3090
- int arg_count = args->length() - 2; // For receiver and function.
3091
- VisitForStackValue(args->at(0)); // Receiver.
3092
- for (int i = 0; i < arg_count; i++) {
3093
- VisitForStackValue(args->at(i + 1));
3094
- }
3095
- VisitForAccumulatorValue(args->at(arg_count + 1)); // Function.
3096
-
3097
- // InvokeFunction requires function in edi. Move it in there.
3098
- if (!result_register().is(edi)) __ mov(edi, result_register());
3099
- ParameterCount count(arg_count);
3100
- __ InvokeFunction(edi, count, CALL_FUNCTION);
3101
- __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
3102
- context()->Plug(eax);
3103
- }
3104
-
3105
-
3106
- void FullCodeGenerator::EmitRegExpConstructResult(ZoneList<Expression*>* args) {
3107
- // Load the arguments on the stack and call the stub.
3108
- RegExpConstructResultStub stub;
3109
- ASSERT(args->length() == 3);
3110
- VisitForStackValue(args->at(0));
3111
- VisitForStackValue(args->at(1));
3112
- VisitForStackValue(args->at(2));
3113
- __ CallStub(&stub);
3114
- context()->Plug(eax);
3115
- }
3116
-
3117
-
3118
- void FullCodeGenerator::EmitSwapElements(ZoneList<Expression*>* args) {
3119
- ASSERT(args->length() == 3);
3120
- VisitForStackValue(args->at(0));
3121
- VisitForStackValue(args->at(1));
3122
- VisitForStackValue(args->at(2));
3123
- Label done;
3124
- Label slow_case;
3125
- Register object = eax;
3126
- Register index_1 = ebx;
3127
- Register index_2 = ecx;
3128
- Register elements = edi;
3129
- Register temp = edx;
3130
- __ mov(object, Operand(esp, 2 * kPointerSize));
3131
- // Fetch the map and check if array is in fast case.
3132
- // Check that object doesn't require security checks and
3133
- // has no indexed interceptor.
3134
- __ CmpObjectType(object, JS_ARRAY_TYPE, temp);
3135
- __ j(not_equal, &slow_case);
3136
- __ test_b(FieldOperand(temp, Map::kBitFieldOffset),
3137
- KeyedLoadIC::kSlowCaseBitFieldMask);
3138
- __ j(not_zero, &slow_case);
3139
-
3140
- // Check the object's elements are in fast case and writable.
3141
- __ mov(elements, FieldOperand(object, JSObject::kElementsOffset));
3142
- __ cmp(FieldOperand(elements, HeapObject::kMapOffset),
3143
- Immediate(isolate()->factory()->fixed_array_map()));
3144
- __ j(not_equal, &slow_case);
3145
-
3146
- // Check that both indices are smis.
3147
- __ mov(index_1, Operand(esp, 1 * kPointerSize));
3148
- __ mov(index_2, Operand(esp, 0));
3149
- __ mov(temp, index_1);
3150
- __ or_(temp, Operand(index_2));
3151
- __ test(temp, Immediate(kSmiTagMask));
3152
- __ j(not_zero, &slow_case);
3153
-
3154
- // Check that both indices are valid.
3155
- __ mov(temp, FieldOperand(object, JSArray::kLengthOffset));
3156
- __ cmp(temp, Operand(index_1));
3157
- __ j(below_equal, &slow_case);
3158
- __ cmp(temp, Operand(index_2));
3159
- __ j(below_equal, &slow_case);
3160
-
3161
- // Bring addresses into index1 and index2.
3162
- __ lea(index_1, CodeGenerator::FixedArrayElementOperand(elements, index_1));
3163
- __ lea(index_2, CodeGenerator::FixedArrayElementOperand(elements, index_2));
3164
-
3165
- // Swap elements. Use object and temp as scratch registers.
3166
- __ mov(object, Operand(index_1, 0));
3167
- __ mov(temp, Operand(index_2, 0));
3168
- __ mov(Operand(index_2, 0), object);
3169
- __ mov(Operand(index_1, 0), temp);
3170
-
3171
- Label new_space;
3172
- __ InNewSpace(elements, temp, equal, &new_space);
3173
-
3174
- __ mov(object, elements);
3175
- __ RecordWriteHelper(object, index_1, temp);
3176
- __ RecordWriteHelper(elements, index_2, temp);
3177
-
3178
- __ bind(&new_space);
3179
- // We are done. Drop elements from the stack, and return undefined.
3180
- __ add(Operand(esp), Immediate(3 * kPointerSize));
3181
- __ mov(eax, isolate()->factory()->undefined_value());
3182
- __ jmp(&done);
3183
-
3184
- __ bind(&slow_case);
3185
- __ CallRuntime(Runtime::kSwapElements, 3);
3186
-
3187
- __ bind(&done);
3188
- context()->Plug(eax);
3189
- }
3190
-
3191
-
3192
- void FullCodeGenerator::EmitGetFromCache(ZoneList<Expression*>* args) {
3193
- ASSERT_EQ(2, args->length());
3194
-
3195
- ASSERT_NE(NULL, args->at(0)->AsLiteral());
3196
- int cache_id = Smi::cast(*(args->at(0)->AsLiteral()->handle()))->value();
3197
-
3198
- Handle<FixedArray> jsfunction_result_caches(
3199
- isolate()->global_context()->jsfunction_result_caches());
3200
- if (jsfunction_result_caches->length() <= cache_id) {
3201
- __ Abort("Attempt to use undefined cache.");
3202
- __ mov(eax, isolate()->factory()->undefined_value());
3203
- context()->Plug(eax);
3204
- return;
3205
- }
3206
-
3207
- VisitForAccumulatorValue(args->at(1));
3208
-
3209
- Register key = eax;
3210
- Register cache = ebx;
3211
- Register tmp = ecx;
3212
- __ mov(cache, ContextOperand(esi, Context::GLOBAL_INDEX));
3213
- __ mov(cache,
3214
- FieldOperand(cache, GlobalObject::kGlobalContextOffset));
3215
- __ mov(cache, ContextOperand(cache, Context::JSFUNCTION_RESULT_CACHES_INDEX));
3216
- __ mov(cache,
3217
- FieldOperand(cache, FixedArray::OffsetOfElementAt(cache_id)));
3218
-
3219
- Label done, not_found;
3220
- // tmp now holds finger offset as a smi.
3221
- ASSERT(kSmiTag == 0 && kSmiTagSize == 1);
3222
- __ mov(tmp, FieldOperand(cache, JSFunctionResultCache::kFingerOffset));
3223
- __ cmp(key, CodeGenerator::FixedArrayElementOperand(cache, tmp));
3224
- __ j(not_equal, &not_found);
3225
-
3226
- __ mov(eax, CodeGenerator::FixedArrayElementOperand(cache, tmp, 1));
3227
- __ jmp(&done);
3228
-
3229
- __ bind(&not_found);
3230
- // Call runtime to perform the lookup.
3231
- __ push(cache);
3232
- __ push(key);
3233
- __ CallRuntime(Runtime::kGetFromCache, 2);
3234
-
3235
- __ bind(&done);
3236
- context()->Plug(eax);
3237
- }
3238
-
3239
-
3240
- void FullCodeGenerator::EmitIsRegExpEquivalent(ZoneList<Expression*>* args) {
3241
- ASSERT_EQ(2, args->length());
3242
-
3243
- Register right = eax;
3244
- Register left = ebx;
3245
- Register tmp = ecx;
3246
-
3247
- VisitForStackValue(args->at(0));
3248
- VisitForAccumulatorValue(args->at(1));
3249
- __ pop(left);
3250
-
3251
- Label done, fail, ok;
3252
- __ cmp(left, Operand(right));
3253
- __ j(equal, &ok);
3254
- // Fail if either is a non-HeapObject.
3255
- __ mov(tmp, left);
3256
- __ and_(Operand(tmp), right);
3257
- __ test(Operand(tmp), Immediate(kSmiTagMask));
3258
- __ j(zero, &fail);
3259
- __ mov(tmp, FieldOperand(left, HeapObject::kMapOffset));
3260
- __ CmpInstanceType(tmp, JS_REGEXP_TYPE);
3261
- __ j(not_equal, &fail);
3262
- __ cmp(tmp, FieldOperand(right, HeapObject::kMapOffset));
3263
- __ j(not_equal, &fail);
3264
- __ mov(tmp, FieldOperand(left, JSRegExp::kDataOffset));
3265
- __ cmp(tmp, FieldOperand(right, JSRegExp::kDataOffset));
3266
- __ j(equal, &ok);
3267
- __ bind(&fail);
3268
- __ mov(eax, Immediate(isolate()->factory()->false_value()));
3269
- __ jmp(&done);
3270
- __ bind(&ok);
3271
- __ mov(eax, Immediate(isolate()->factory()->true_value()));
3272
- __ bind(&done);
3273
-
3274
- context()->Plug(eax);
3275
- }
3276
-
3277
-
3278
- void FullCodeGenerator::EmitHasCachedArrayIndex(ZoneList<Expression*>* args) {
3279
- ASSERT(args->length() == 1);
3280
-
3281
- VisitForAccumulatorValue(args->at(0));
3282
-
3283
- if (FLAG_debug_code) {
3284
- __ AbortIfNotString(eax);
3285
- }
3286
-
3287
- Label materialize_true, materialize_false;
3288
- Label* if_true = NULL;
3289
- Label* if_false = NULL;
3290
- Label* fall_through = NULL;
3291
- context()->PrepareTest(&materialize_true, &materialize_false,
3292
- &if_true, &if_false, &fall_through);
3293
-
3294
- __ test(FieldOperand(eax, String::kHashFieldOffset),
3295
- Immediate(String::kContainsCachedArrayIndexMask));
3296
- PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
3297
- Split(zero, if_true, if_false, fall_through);
3298
-
3299
- context()->Plug(if_true, if_false);
3300
- }
3301
-
3302
-
3303
- void FullCodeGenerator::EmitGetCachedArrayIndex(ZoneList<Expression*>* args) {
3304
- ASSERT(args->length() == 1);
3305
- VisitForAccumulatorValue(args->at(0));
3306
-
3307
- if (FLAG_debug_code) {
3308
- __ AbortIfNotString(eax);
3309
- }
3310
-
3311
- __ mov(eax, FieldOperand(eax, String::kHashFieldOffset));
3312
- __ IndexFromHash(eax, eax);
3313
-
3314
- context()->Plug(eax);
3315
- }
3316
-
3317
-
3318
- void FullCodeGenerator::EmitFastAsciiArrayJoin(ZoneList<Expression*>* args) {
3319
- Label bailout, done, one_char_separator, long_separator,
3320
- non_trivial_array, not_size_one_array, loop,
3321
- loop_1, loop_1_condition, loop_2, loop_2_entry, loop_3, loop_3_entry;
3322
-
3323
- ASSERT(args->length() == 2);
3324
- // We will leave the separator on the stack until the end of the function.
3325
- VisitForStackValue(args->at(1));
3326
- // Load this to eax (= array)
3327
- VisitForAccumulatorValue(args->at(0));
3328
- // All aliases of the same register have disjoint lifetimes.
3329
- Register array = eax;
3330
- Register elements = no_reg; // Will be eax.
3331
-
3332
- Register index = edx;
3333
-
3334
- Register string_length = ecx;
3335
-
3336
- Register string = esi;
3337
-
3338
- Register scratch = ebx;
3339
-
3340
- Register array_length = edi;
3341
- Register result_pos = no_reg; // Will be edi.
3342
-
3343
- // Separator operand is already pushed.
3344
- Operand separator_operand = Operand(esp, 2 * kPointerSize);
3345
- Operand result_operand = Operand(esp, 1 * kPointerSize);
3346
- Operand array_length_operand = Operand(esp, 0);
3347
- __ sub(Operand(esp), Immediate(2 * kPointerSize));
3348
- __ cld();
3349
- // Check that the array is a JSArray
3350
- __ test(array, Immediate(kSmiTagMask));
3351
- __ j(zero, &bailout);
3352
- __ CmpObjectType(array, JS_ARRAY_TYPE, scratch);
3353
- __ j(not_equal, &bailout);
3354
-
3355
- // Check that the array has fast elements.
3356
- __ test_b(FieldOperand(scratch, Map::kBitField2Offset),
3357
- 1 << Map::kHasFastElements);
3358
- __ j(zero, &bailout);
3359
-
3360
- // If the array has length zero, return the empty string.
3361
- __ mov(array_length, FieldOperand(array, JSArray::kLengthOffset));
3362
- __ SmiUntag(array_length);
3363
- __ j(not_zero, &non_trivial_array);
3364
- __ mov(result_operand, isolate()->factory()->empty_string());
3365
- __ jmp(&done);
3366
-
3367
- // Save the array length.
3368
- __ bind(&non_trivial_array);
3369
- __ mov(array_length_operand, array_length);
3370
-
3371
- // Save the FixedArray containing array's elements.
3372
- // End of array's live range.
3373
- elements = array;
3374
- __ mov(elements, FieldOperand(array, JSArray::kElementsOffset));
3375
- array = no_reg;
3376
-
3377
-
3378
- // Check that all array elements are sequential ASCII strings, and
3379
- // accumulate the sum of their lengths, as a smi-encoded value.
3380
- __ Set(index, Immediate(0));
3381
- __ Set(string_length, Immediate(0));
3382
- // Loop condition: while (index < length).
3383
- // Live loop registers: index, array_length, string,
3384
- // scratch, string_length, elements.
3385
- if (FLAG_debug_code) {
3386
- __ cmp(index, Operand(array_length));
3387
- __ Assert(less, "No empty arrays here in EmitFastAsciiArrayJoin");
3388
- }
3389
- __ bind(&loop);
3390
- __ mov(string, FieldOperand(elements,
3391
- index,
3392
- times_pointer_size,
3393
- FixedArray::kHeaderSize));
3394
- __ test(string, Immediate(kSmiTagMask));
3395
- __ j(zero, &bailout);
3396
- __ mov(scratch, FieldOperand(string, HeapObject::kMapOffset));
3397
- __ movzx_b(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset));
3398
- __ and_(scratch, Immediate(
3399
- kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask));
3400
- __ cmp(scratch, kStringTag | kAsciiStringTag | kSeqStringTag);
3401
- __ j(not_equal, &bailout);
3402
- __ add(string_length,
3403
- FieldOperand(string, SeqAsciiString::kLengthOffset));
3404
- __ j(overflow, &bailout);
3405
- __ add(Operand(index), Immediate(1));
3406
- __ cmp(index, Operand(array_length));
3407
- __ j(less, &loop);
3408
-
3409
- // If array_length is 1, return elements[0], a string.
3410
- __ cmp(array_length, 1);
3411
- __ j(not_equal, &not_size_one_array);
3412
- __ mov(scratch, FieldOperand(elements, FixedArray::kHeaderSize));
3413
- __ mov(result_operand, scratch);
3414
- __ jmp(&done);
3415
-
3416
- __ bind(&not_size_one_array);
3417
-
3418
- // End of array_length live range.
3419
- result_pos = array_length;
3420
- array_length = no_reg;
3421
-
3422
- // Live registers:
3423
- // string_length: Sum of string lengths, as a smi.
3424
- // elements: FixedArray of strings.
3425
-
3426
- // Check that the separator is a flat ASCII string.
3427
- __ mov(string, separator_operand);
3428
- __ test(string, Immediate(kSmiTagMask));
3429
- __ j(zero, &bailout);
3430
- __ mov(scratch, FieldOperand(string, HeapObject::kMapOffset));
3431
- __ movzx_b(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset));
3432
- __ and_(scratch, Immediate(
3433
- kIsNotStringMask | kStringEncodingMask | kStringRepresentationMask));
3434
- __ cmp(scratch, ASCII_STRING_TYPE);
3435
- __ j(not_equal, &bailout);
3436
-
3437
- // Add (separator length times array_length) - separator length
3438
- // to string_length.
3439
- __ mov(scratch, separator_operand);
3440
- __ mov(scratch, FieldOperand(scratch, SeqAsciiString::kLengthOffset));
3441
- __ sub(string_length, Operand(scratch)); // May be negative, temporarily.
3442
- __ imul(scratch, array_length_operand);
3443
- __ j(overflow, &bailout);
3444
- __ add(string_length, Operand(scratch));
3445
- __ j(overflow, &bailout);
3446
-
3447
- __ shr(string_length, 1);
3448
- // Live registers and stack values:
3449
- // string_length
3450
- // elements
3451
- __ AllocateAsciiString(result_pos, string_length, scratch,
3452
- index, string, &bailout);
3453
- __ mov(result_operand, result_pos);
3454
- __ lea(result_pos, FieldOperand(result_pos, SeqAsciiString::kHeaderSize));
3455
-
3456
-
3457
- __ mov(string, separator_operand);
3458
- __ cmp(FieldOperand(string, SeqAsciiString::kLengthOffset),
3459
- Immediate(Smi::FromInt(1)));
3460
- __ j(equal, &one_char_separator);
3461
- __ j(greater, &long_separator);
3462
-
3463
-
3464
- // Empty separator case
3465
- __ mov(index, Immediate(0));
3466
- __ jmp(&loop_1_condition);
3467
- // Loop condition: while (index < length).
3468
- __ bind(&loop_1);
3469
- // Each iteration of the loop concatenates one string to the result.
3470
- // Live values in registers:
3471
- // index: which element of the elements array we are adding to the result.
3472
- // result_pos: the position to which we are currently copying characters.
3473
- // elements: the FixedArray of strings we are joining.
3474
-
3475
- // Get string = array[index].
3476
- __ mov(string, FieldOperand(elements, index,
3477
- times_pointer_size,
3478
- FixedArray::kHeaderSize));
3479
- __ mov(string_length,
3480
- FieldOperand(string, String::kLengthOffset));
3481
- __ shr(string_length, 1);
3482
- __ lea(string,
3483
- FieldOperand(string, SeqAsciiString::kHeaderSize));
3484
- __ CopyBytes(string, result_pos, string_length, scratch);
3485
- __ add(Operand(index), Immediate(1));
3486
- __ bind(&loop_1_condition);
3487
- __ cmp(index, array_length_operand);
3488
- __ j(less, &loop_1); // End while (index < length).
3489
- __ jmp(&done);
3490
-
3491
-
3492
-
3493
- // One-character separator case
3494
- __ bind(&one_char_separator);
3495
- // Replace separator with its ascii character value.
3496
- __ mov_b(scratch, FieldOperand(string, SeqAsciiString::kHeaderSize));
3497
- __ mov_b(separator_operand, scratch);
3498
-
3499
- __ Set(index, Immediate(0));
3500
- // Jump into the loop after the code that copies the separator, so the first
3501
- // element is not preceded by a separator
3502
- __ jmp(&loop_2_entry);
3503
- // Loop condition: while (index < length).
3504
- __ bind(&loop_2);
3505
- // Each iteration of the loop concatenates one string to the result.
3506
- // Live values in registers:
3507
- // index: which element of the elements array we are adding to the result.
3508
- // result_pos: the position to which we are currently copying characters.
3509
-
3510
- // Copy the separator character to the result.
3511
- __ mov_b(scratch, separator_operand);
3512
- __ mov_b(Operand(result_pos, 0), scratch);
3513
- __ inc(result_pos);
3514
-
3515
- __ bind(&loop_2_entry);
3516
- // Get string = array[index].
3517
- __ mov(string, FieldOperand(elements, index,
3518
- times_pointer_size,
3519
- FixedArray::kHeaderSize));
3520
- __ mov(string_length,
3521
- FieldOperand(string, String::kLengthOffset));
3522
- __ shr(string_length, 1);
3523
- __ lea(string,
3524
- FieldOperand(string, SeqAsciiString::kHeaderSize));
3525
- __ CopyBytes(string, result_pos, string_length, scratch);
3526
- __ add(Operand(index), Immediate(1));
3527
-
3528
- __ cmp(index, array_length_operand);
3529
- __ j(less, &loop_2); // End while (index < length).
3530
- __ jmp(&done);
3531
-
3532
-
3533
- // Long separator case (separator is more than one character).
3534
- __ bind(&long_separator);
3535
-
3536
- __ Set(index, Immediate(0));
3537
- // Jump into the loop after the code that copies the separator, so the first
3538
- // element is not preceded by a separator
3539
- __ jmp(&loop_3_entry);
3540
- // Loop condition: while (index < length).
3541
- __ bind(&loop_3);
3542
- // Each iteration of the loop concatenates one string to the result.
3543
- // Live values in registers:
3544
- // index: which element of the elements array we are adding to the result.
3545
- // result_pos: the position to which we are currently copying characters.
3546
-
3547
- // Copy the separator to the result.
3548
- __ mov(string, separator_operand);
3549
- __ mov(string_length,
3550
- FieldOperand(string, String::kLengthOffset));
3551
- __ shr(string_length, 1);
3552
- __ lea(string,
3553
- FieldOperand(string, SeqAsciiString::kHeaderSize));
3554
- __ CopyBytes(string, result_pos, string_length, scratch);
3555
-
3556
- __ bind(&loop_3_entry);
3557
- // Get string = array[index].
3558
- __ mov(string, FieldOperand(elements, index,
3559
- times_pointer_size,
3560
- FixedArray::kHeaderSize));
3561
- __ mov(string_length,
3562
- FieldOperand(string, String::kLengthOffset));
3563
- __ shr(string_length, 1);
3564
- __ lea(string,
3565
- FieldOperand(string, SeqAsciiString::kHeaderSize));
3566
- __ CopyBytes(string, result_pos, string_length, scratch);
3567
- __ add(Operand(index), Immediate(1));
3568
-
3569
- __ cmp(index, array_length_operand);
3570
- __ j(less, &loop_3); // End while (index < length).
3571
- __ jmp(&done);
3572
-
3573
-
3574
- __ bind(&bailout);
3575
- __ mov(result_operand, isolate()->factory()->undefined_value());
3576
- __ bind(&done);
3577
- __ mov(eax, result_operand);
3578
- // Drop temp values from the stack, and restore context register.
3579
- __ add(Operand(esp), Immediate(3 * kPointerSize));
3580
-
3581
- __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
3582
- context()->Plug(eax);
3583
- }
3584
-
3585
-
3586
- void FullCodeGenerator::VisitCallRuntime(CallRuntime* expr) {
3587
- Handle<String> name = expr->name();
3588
- if (name->length() > 0 && name->Get(0) == '_') {
3589
- Comment cmnt(masm_, "[ InlineRuntimeCall");
3590
- EmitInlineRuntimeCall(expr);
3591
- return;
3592
- }
3593
-
3594
- Comment cmnt(masm_, "[ CallRuntime");
3595
- ZoneList<Expression*>* args = expr->arguments();
3596
-
3597
- if (expr->is_jsruntime()) {
3598
- // Prepare for calling JS runtime function.
3599
- __ mov(eax, GlobalObjectOperand());
3600
- __ push(FieldOperand(eax, GlobalObject::kBuiltinsOffset));
3601
- }
3602
-
3603
- // Push the arguments ("left-to-right").
3604
- int arg_count = args->length();
3605
- for (int i = 0; i < arg_count; i++) {
3606
- VisitForStackValue(args->at(i));
3607
- }
3608
-
3609
- if (expr->is_jsruntime()) {
3610
- // Call the JS runtime function via a call IC.
3611
- __ Set(ecx, Immediate(expr->name()));
3612
- InLoopFlag in_loop = (loop_depth() > 0) ? IN_LOOP : NOT_IN_LOOP;
3613
- Handle<Code> ic = isolate()->stub_cache()->ComputeCallInitialize(
3614
- arg_count, in_loop);
3615
- EmitCallIC(ic, RelocInfo::CODE_TARGET);
3616
- // Restore context register.
3617
- __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
3618
- } else {
3619
- // Call the C runtime function.
3620
- __ CallRuntime(expr->function(), arg_count);
3621
- }
3622
- context()->Plug(eax);
3623
- }
3624
-
3625
-
3626
- void FullCodeGenerator::VisitUnaryOperation(UnaryOperation* expr) {
3627
- switch (expr->op()) {
3628
- case Token::DELETE: {
3629
- Comment cmnt(masm_, "[ UnaryOperation (DELETE)");
3630
- Property* prop = expr->expression()->AsProperty();
3631
- Variable* var = expr->expression()->AsVariableProxy()->AsVariable();
3632
-
3633
- if (prop != NULL) {
3634
- if (prop->is_synthetic()) {
3635
- // Result of deleting parameters is false, even when they rewrite
3636
- // to accesses on the arguments object.
3637
- context()->Plug(false);
3638
- } else {
3639
- VisitForStackValue(prop->obj());
3640
- VisitForStackValue(prop->key());
3641
- __ push(Immediate(Smi::FromInt(strict_mode_flag())));
3642
- __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
3643
- context()->Plug(eax);
3644
- }
3645
- } else if (var != NULL) {
3646
- // Delete of an unqualified identifier is disallowed in strict mode
3647
- // but "delete this" is.
3648
- ASSERT(strict_mode_flag() == kNonStrictMode || var->is_this());
3649
- if (var->is_global()) {
3650
- __ push(GlobalObjectOperand());
3651
- __ push(Immediate(var->name()));
3652
- __ push(Immediate(Smi::FromInt(kNonStrictMode)));
3653
- __ InvokeBuiltin(Builtins::DELETE, CALL_FUNCTION);
3654
- context()->Plug(eax);
3655
- } else if (var->AsSlot() != NULL &&
3656
- var->AsSlot()->type() != Slot::LOOKUP) {
3657
- // Result of deleting non-global, non-dynamic variables is false.
3658
- // The subexpression does not have side effects.
3659
- context()->Plug(false);
3660
- } else {
3661
- // Non-global variable. Call the runtime to try to delete from the
3662
- // context where the variable was introduced.
3663
- __ push(context_register());
3664
- __ push(Immediate(var->name()));
3665
- __ CallRuntime(Runtime::kDeleteContextSlot, 2);
3666
- context()->Plug(eax);
3667
- }
3668
- } else {
3669
- // Result of deleting non-property, non-variable reference is true.
3670
- // The subexpression may have side effects.
3671
- VisitForEffect(expr->expression());
3672
- context()->Plug(true);
3673
- }
3674
- break;
3675
- }
3676
-
3677
- case Token::VOID: {
3678
- Comment cmnt(masm_, "[ UnaryOperation (VOID)");
3679
- VisitForEffect(expr->expression());
3680
- context()->Plug(isolate()->factory()->undefined_value());
3681
- break;
3682
- }
3683
-
3684
- case Token::NOT: {
3685
- Comment cmnt(masm_, "[ UnaryOperation (NOT)");
3686
- if (context()->IsEffect()) {
3687
- // Unary NOT has no side effects so it's only necessary to visit the
3688
- // subexpression. Match the optimizing compiler by not branching.
3689
- VisitForEffect(expr->expression());
3690
- } else {
3691
- Label materialize_true, materialize_false;
3692
- Label* if_true = NULL;
3693
- Label* if_false = NULL;
3694
- Label* fall_through = NULL;
3695
-
3696
- // Notice that the labels are swapped.
3697
- context()->PrepareTest(&materialize_true, &materialize_false,
3698
- &if_false, &if_true, &fall_through);
3699
- if (context()->IsTest()) ForwardBailoutToChild(expr);
3700
- VisitForControl(expr->expression(), if_true, if_false, fall_through);
3701
- context()->Plug(if_false, if_true); // Labels swapped.
3702
- }
3703
- break;
3704
- }
3705
-
3706
- case Token::TYPEOF: {
3707
- Comment cmnt(masm_, "[ UnaryOperation (TYPEOF)");
3708
- { StackValueContext context(this);
3709
- VisitForTypeofValue(expr->expression());
3710
- }
3711
- __ CallRuntime(Runtime::kTypeof, 1);
3712
- context()->Plug(eax);
3713
- break;
3714
- }
3715
-
3716
- case Token::ADD: {
3717
- Comment cmt(masm_, "[ UnaryOperation (ADD)");
3718
- VisitForAccumulatorValue(expr->expression());
3719
- Label no_conversion;
3720
- __ test(result_register(), Immediate(kSmiTagMask));
3721
- __ j(zero, &no_conversion);
3722
- ToNumberStub convert_stub;
3723
- __ CallStub(&convert_stub);
3724
- __ bind(&no_conversion);
3725
- context()->Plug(result_register());
3726
- break;
3727
- }
3728
-
3729
- case Token::SUB: {
3730
- Comment cmt(masm_, "[ UnaryOperation (SUB)");
3731
- bool can_overwrite = expr->expression()->ResultOverwriteAllowed();
3732
- UnaryOverwriteMode overwrite =
3733
- can_overwrite ? UNARY_OVERWRITE : UNARY_NO_OVERWRITE;
3734
- GenericUnaryOpStub stub(Token::SUB, overwrite, NO_UNARY_FLAGS);
3735
- // GenericUnaryOpStub expects the argument to be in the
3736
- // accumulator register eax.
3737
- VisitForAccumulatorValue(expr->expression());
3738
- __ CallStub(&stub);
3739
- context()->Plug(eax);
3740
- break;
3741
- }
3742
-
3743
- case Token::BIT_NOT: {
3744
- Comment cmt(masm_, "[ UnaryOperation (BIT_NOT)");
3745
- // The generic unary operation stub expects the argument to be
3746
- // in the accumulator register eax.
3747
- VisitForAccumulatorValue(expr->expression());
3748
- Label done;
3749
- bool inline_smi_case = ShouldInlineSmiCase(expr->op());
3750
- if (inline_smi_case) {
3751
- NearLabel call_stub;
3752
- __ test(eax, Immediate(kSmiTagMask));
3753
- __ j(not_zero, &call_stub);
3754
- __ lea(eax, Operand(eax, kSmiTagMask));
3755
- __ not_(eax);
3756
- __ jmp(&done);
3757
- __ bind(&call_stub);
3758
- }
3759
- bool overwrite = expr->expression()->ResultOverwriteAllowed();
3760
- UnaryOverwriteMode mode =
3761
- overwrite ? UNARY_OVERWRITE : UNARY_NO_OVERWRITE;
3762
- UnaryOpFlags flags = inline_smi_case
3763
- ? NO_UNARY_SMI_CODE_IN_STUB
3764
- : NO_UNARY_FLAGS;
3765
- GenericUnaryOpStub stub(Token::BIT_NOT, mode, flags);
3766
- __ CallStub(&stub);
3767
- __ bind(&done);
3768
- context()->Plug(eax);
3769
- break;
3770
- }
3771
-
3772
- default:
3773
- UNREACHABLE();
3774
- }
3775
- }
3776
-
3777
-
3778
- void FullCodeGenerator::VisitCountOperation(CountOperation* expr) {
3779
- Comment cmnt(masm_, "[ CountOperation");
3780
- SetSourcePosition(expr->position());
3781
-
3782
- // Invalid left-hand sides are rewritten to have a 'throw ReferenceError'
3783
- // as the left-hand side.
3784
- if (!expr->expression()->IsValidLeftHandSide()) {
3785
- VisitForEffect(expr->expression());
3786
- return;
3787
- }
3788
-
3789
- // Expression can only be a property, a global or a (parameter or local)
3790
- // slot. Variables with rewrite to .arguments are treated as KEYED_PROPERTY.
3791
- enum LhsKind { VARIABLE, NAMED_PROPERTY, KEYED_PROPERTY };
3792
- LhsKind assign_type = VARIABLE;
3793
- Property* prop = expr->expression()->AsProperty();
3794
- // In case of a property we use the uninitialized expression context
3795
- // of the key to detect a named property.
3796
- if (prop != NULL) {
3797
- assign_type =
3798
- (prop->key()->IsPropertyName()) ? NAMED_PROPERTY : KEYED_PROPERTY;
3799
- }
3800
-
3801
- // Evaluate expression and get value.
3802
- if (assign_type == VARIABLE) {
3803
- ASSERT(expr->expression()->AsVariableProxy()->var() != NULL);
3804
- AccumulatorValueContext context(this);
3805
- EmitVariableLoad(expr->expression()->AsVariableProxy()->var());
3806
- } else {
3807
- // Reserve space for result of postfix operation.
3808
- if (expr->is_postfix() && !context()->IsEffect()) {
3809
- __ push(Immediate(Smi::FromInt(0)));
3810
- }
3811
- if (assign_type == NAMED_PROPERTY) {
3812
- // Put the object both on the stack and in the accumulator.
3813
- VisitForAccumulatorValue(prop->obj());
3814
- __ push(eax);
3815
- EmitNamedPropertyLoad(prop);
3816
- } else {
3817
- if (prop->is_arguments_access()) {
3818
- VariableProxy* obj_proxy = prop->obj()->AsVariableProxy();
3819
- MemOperand slot_operand =
3820
- EmitSlotSearch(obj_proxy->var()->AsSlot(), ecx);
3821
- __ push(slot_operand);
3822
- __ mov(eax, Immediate(prop->key()->AsLiteral()->handle()));
3823
- } else {
3824
- VisitForStackValue(prop->obj());
3825
- VisitForAccumulatorValue(prop->key());
3826
- }
3827
- __ mov(edx, Operand(esp, 0));
3828
- __ push(eax);
3829
- EmitKeyedPropertyLoad(prop);
3830
- }
3831
- }
3832
-
3833
- // We need a second deoptimization point after loading the value
3834
- // in case evaluating the property load my have a side effect.
3835
- if (assign_type == VARIABLE) {
3836
- PrepareForBailout(expr->expression(), TOS_REG);
3837
- } else {
3838
- PrepareForBailout(expr->increment(), TOS_REG);
3839
- }
3840
-
3841
- // Call ToNumber only if operand is not a smi.
3842
- NearLabel no_conversion;
3843
- if (ShouldInlineSmiCase(expr->op())) {
3844
- __ test(eax, Immediate(kSmiTagMask));
3845
- __ j(zero, &no_conversion);
3846
- }
3847
- ToNumberStub convert_stub;
3848
- __ CallStub(&convert_stub);
3849
- __ bind(&no_conversion);
3850
-
3851
- // Save result for postfix expressions.
3852
- if (expr->is_postfix()) {
3853
- if (!context()->IsEffect()) {
3854
- // Save the result on the stack. If we have a named or keyed property
3855
- // we store the result under the receiver that is currently on top
3856
- // of the stack.
3857
- switch (assign_type) {
3858
- case VARIABLE:
3859
- __ push(eax);
3860
- break;
3861
- case NAMED_PROPERTY:
3862
- __ mov(Operand(esp, kPointerSize), eax);
3863
- break;
3864
- case KEYED_PROPERTY:
3865
- __ mov(Operand(esp, 2 * kPointerSize), eax);
3866
- break;
3867
- }
3868
- }
3869
- }
3870
-
3871
- // Inline smi case if we are in a loop.
3872
- NearLabel stub_call, done;
3873
- JumpPatchSite patch_site(masm_);
3874
-
3875
- if (ShouldInlineSmiCase(expr->op())) {
3876
- if (expr->op() == Token::INC) {
3877
- __ add(Operand(eax), Immediate(Smi::FromInt(1)));
3878
- } else {
3879
- __ sub(Operand(eax), Immediate(Smi::FromInt(1)));
3880
- }
3881
- __ j(overflow, &stub_call);
3882
- // We could eliminate this smi check if we split the code at
3883
- // the first smi check before calling ToNumber.
3884
- patch_site.EmitJumpIfSmi(eax, &done);
3885
-
3886
- __ bind(&stub_call);
3887
- // Call stub. Undo operation first.
3888
- if (expr->op() == Token::INC) {
3889
- __ sub(Operand(eax), Immediate(Smi::FromInt(1)));
3890
- } else {
3891
- __ add(Operand(eax), Immediate(Smi::FromInt(1)));
3892
- }
3893
- }
3894
-
3895
- // Record position before stub call.
3896
- SetSourcePosition(expr->position());
3897
-
3898
- // Call stub for +1/-1.
3899
- __ mov(edx, eax);
3900
- __ mov(eax, Immediate(Smi::FromInt(1)));
3901
- TypeRecordingBinaryOpStub stub(expr->binary_op(), NO_OVERWRITE);
3902
- EmitCallIC(stub.GetCode(), &patch_site);
3903
- __ bind(&done);
3904
-
3905
- // Store the value returned in eax.
3906
- switch (assign_type) {
3907
- case VARIABLE:
3908
- if (expr->is_postfix()) {
3909
- // Perform the assignment as if via '='.
3910
- { EffectContext context(this);
3911
- EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(),
3912
- Token::ASSIGN);
3913
- PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
3914
- context.Plug(eax);
3915
- }
3916
- // For all contexts except EffectContext We have the result on
3917
- // top of the stack.
3918
- if (!context()->IsEffect()) {
3919
- context()->PlugTOS();
3920
- }
3921
- } else {
3922
- // Perform the assignment as if via '='.
3923
- EmitVariableAssignment(expr->expression()->AsVariableProxy()->var(),
3924
- Token::ASSIGN);
3925
- PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
3926
- context()->Plug(eax);
3927
- }
3928
- break;
3929
- case NAMED_PROPERTY: {
3930
- __ mov(ecx, prop->key()->AsLiteral()->handle());
3931
- __ pop(edx);
3932
- Handle<Code> ic = is_strict_mode()
3933
- ? isolate()->builtins()->StoreIC_Initialize_Strict()
3934
- : isolate()->builtins()->StoreIC_Initialize();
3935
- EmitCallIC(ic, RelocInfo::CODE_TARGET);
3936
- PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
3937
- if (expr->is_postfix()) {
3938
- if (!context()->IsEffect()) {
3939
- context()->PlugTOS();
3940
- }
3941
- } else {
3942
- context()->Plug(eax);
3943
- }
3944
- break;
3945
- }
3946
- case KEYED_PROPERTY: {
3947
- __ pop(ecx);
3948
- __ pop(edx);
3949
- Handle<Code> ic = is_strict_mode()
3950
- ? isolate()->builtins()->KeyedStoreIC_Initialize_Strict()
3951
- : isolate()->builtins()->KeyedStoreIC_Initialize();
3952
- EmitCallIC(ic, RelocInfo::CODE_TARGET);
3953
- PrepareForBailoutForId(expr->AssignmentId(), TOS_REG);
3954
- if (expr->is_postfix()) {
3955
- // Result is on the stack
3956
- if (!context()->IsEffect()) {
3957
- context()->PlugTOS();
3958
- }
3959
- } else {
3960
- context()->Plug(eax);
3961
- }
3962
- break;
3963
- }
3964
- }
3965
- }
3966
-
3967
-
3968
- void FullCodeGenerator::VisitForTypeofValue(Expression* expr) {
3969
- VariableProxy* proxy = expr->AsVariableProxy();
3970
- ASSERT(!context()->IsEffect());
3971
- ASSERT(!context()->IsTest());
3972
-
3973
- if (proxy != NULL && !proxy->var()->is_this() && proxy->var()->is_global()) {
3974
- Comment cmnt(masm_, "Global variable");
3975
- __ mov(eax, GlobalObjectOperand());
3976
- __ mov(ecx, Immediate(proxy->name()));
3977
- Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
3978
- // Use a regular load, not a contextual load, to avoid a reference
3979
- // error.
3980
- EmitCallIC(ic, RelocInfo::CODE_TARGET);
3981
- PrepareForBailout(expr, TOS_REG);
3982
- context()->Plug(eax);
3983
- } else if (proxy != NULL &&
3984
- proxy->var()->AsSlot() != NULL &&
3985
- proxy->var()->AsSlot()->type() == Slot::LOOKUP) {
3986
- Label done, slow;
3987
-
3988
- // Generate code for loading from variables potentially shadowed
3989
- // by eval-introduced variables.
3990
- Slot* slot = proxy->var()->AsSlot();
3991
- EmitDynamicLoadFromSlotFastCase(slot, INSIDE_TYPEOF, &slow, &done);
3992
-
3993
- __ bind(&slow);
3994
- __ push(esi);
3995
- __ push(Immediate(proxy->name()));
3996
- __ CallRuntime(Runtime::kLoadContextSlotNoReferenceError, 2);
3997
- PrepareForBailout(expr, TOS_REG);
3998
- __ bind(&done);
3999
-
4000
- context()->Plug(eax);
4001
- } else {
4002
- // This expression cannot throw a reference error at the top level.
4003
- context()->HandleExpression(expr);
4004
- }
4005
- }
4006
-
4007
-
4008
- bool FullCodeGenerator::TryLiteralCompare(Token::Value op,
4009
- Expression* left,
4010
- Expression* right,
4011
- Label* if_true,
4012
- Label* if_false,
4013
- Label* fall_through) {
4014
- if (op != Token::EQ && op != Token::EQ_STRICT) return false;
4015
-
4016
- // Check for the pattern: typeof <expression> == <string literal>.
4017
- Literal* right_literal = right->AsLiteral();
4018
- if (right_literal == NULL) return false;
4019
- Handle<Object> right_literal_value = right_literal->handle();
4020
- if (!right_literal_value->IsString()) return false;
4021
- UnaryOperation* left_unary = left->AsUnaryOperation();
4022
- if (left_unary == NULL || left_unary->op() != Token::TYPEOF) return false;
4023
- Handle<String> check = Handle<String>::cast(right_literal_value);
4024
-
4025
- { AccumulatorValueContext context(this);
4026
- VisitForTypeofValue(left_unary->expression());
4027
- }
4028
- PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
4029
-
4030
- if (check->Equals(isolate()->heap()->number_symbol())) {
4031
- __ JumpIfSmi(eax, if_true);
4032
- __ cmp(FieldOperand(eax, HeapObject::kMapOffset),
4033
- isolate()->factory()->heap_number_map());
4034
- Split(equal, if_true, if_false, fall_through);
4035
- } else if (check->Equals(isolate()->heap()->string_symbol())) {
4036
- __ JumpIfSmi(eax, if_false);
4037
- __ CmpObjectType(eax, FIRST_NONSTRING_TYPE, edx);
4038
- __ j(above_equal, if_false);
4039
- // Check for undetectable objects => false.
4040
- __ test_b(FieldOperand(edx, Map::kBitFieldOffset),
4041
- 1 << Map::kIsUndetectable);
4042
- Split(zero, if_true, if_false, fall_through);
4043
- } else if (check->Equals(isolate()->heap()->boolean_symbol())) {
4044
- __ cmp(eax, isolate()->factory()->true_value());
4045
- __ j(equal, if_true);
4046
- __ cmp(eax, isolate()->factory()->false_value());
4047
- Split(equal, if_true, if_false, fall_through);
4048
- } else if (check->Equals(isolate()->heap()->undefined_symbol())) {
4049
- __ cmp(eax, isolate()->factory()->undefined_value());
4050
- __ j(equal, if_true);
4051
- __ JumpIfSmi(eax, if_false);
4052
- // Check for undetectable objects => true.
4053
- __ mov(edx, FieldOperand(eax, HeapObject::kMapOffset));
4054
- __ movzx_b(ecx, FieldOperand(edx, Map::kBitFieldOffset));
4055
- __ test(ecx, Immediate(1 << Map::kIsUndetectable));
4056
- Split(not_zero, if_true, if_false, fall_through);
4057
- } else if (check->Equals(isolate()->heap()->function_symbol())) {
4058
- __ JumpIfSmi(eax, if_false);
4059
- __ CmpObjectType(eax, FIRST_FUNCTION_CLASS_TYPE, edx);
4060
- Split(above_equal, if_true, if_false, fall_through);
4061
- } else if (check->Equals(isolate()->heap()->object_symbol())) {
4062
- __ JumpIfSmi(eax, if_false);
4063
- __ cmp(eax, isolate()->factory()->null_value());
4064
- __ j(equal, if_true);
4065
- __ CmpObjectType(eax, FIRST_JS_OBJECT_TYPE, edx);
4066
- __ j(below, if_false);
4067
- __ CmpInstanceType(edx, FIRST_FUNCTION_CLASS_TYPE);
4068
- __ j(above_equal, if_false);
4069
- // Check for undetectable objects => false.
4070
- __ test_b(FieldOperand(edx, Map::kBitFieldOffset),
4071
- 1 << Map::kIsUndetectable);
4072
- Split(zero, if_true, if_false, fall_through);
4073
- } else {
4074
- if (if_false != fall_through) __ jmp(if_false);
4075
- }
4076
-
4077
- return true;
4078
- }
4079
-
4080
-
4081
- void FullCodeGenerator::VisitCompareOperation(CompareOperation* expr) {
4082
- Comment cmnt(masm_, "[ CompareOperation");
4083
- SetSourcePosition(expr->position());
4084
-
4085
- // Always perform the comparison for its control flow. Pack the result
4086
- // into the expression's context after the comparison is performed.
4087
-
4088
- Label materialize_true, materialize_false;
4089
- Label* if_true = NULL;
4090
- Label* if_false = NULL;
4091
- Label* fall_through = NULL;
4092
- context()->PrepareTest(&materialize_true, &materialize_false,
4093
- &if_true, &if_false, &fall_through);
4094
-
4095
- // First we try a fast inlined version of the compare when one of
4096
- // the operands is a literal.
4097
- Token::Value op = expr->op();
4098
- Expression* left = expr->left();
4099
- Expression* right = expr->right();
4100
- if (TryLiteralCompare(op, left, right, if_true, if_false, fall_through)) {
4101
- context()->Plug(if_true, if_false);
4102
- return;
4103
- }
4104
-
4105
- VisitForStackValue(expr->left());
4106
- switch (expr->op()) {
4107
- case Token::IN:
4108
- VisitForStackValue(expr->right());
4109
- __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION);
4110
- PrepareForBailoutBeforeSplit(TOS_REG, false, NULL, NULL);
4111
- __ cmp(eax, isolate()->factory()->true_value());
4112
- Split(equal, if_true, if_false, fall_through);
4113
- break;
4114
-
4115
- case Token::INSTANCEOF: {
4116
- VisitForStackValue(expr->right());
4117
- InstanceofStub stub(InstanceofStub::kNoFlags);
4118
- __ CallStub(&stub);
4119
- PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
4120
- __ test(eax, Operand(eax));
4121
- // The stub returns 0 for true.
4122
- Split(zero, if_true, if_false, fall_through);
4123
- break;
4124
- }
4125
-
4126
- default: {
4127
- VisitForAccumulatorValue(expr->right());
4128
- Condition cc = no_condition;
4129
- bool strict = false;
4130
- switch (op) {
4131
- case Token::EQ_STRICT:
4132
- strict = true;
4133
- // Fall through
4134
- case Token::EQ:
4135
- cc = equal;
4136
- __ pop(edx);
4137
- break;
4138
- case Token::LT:
4139
- cc = less;
4140
- __ pop(edx);
4141
- break;
4142
- case Token::GT:
4143
- // Reverse left and right sizes to obtain ECMA-262 conversion order.
4144
- cc = less;
4145
- __ mov(edx, result_register());
4146
- __ pop(eax);
4147
- break;
4148
- case Token::LTE:
4149
- // Reverse left and right sizes to obtain ECMA-262 conversion order.
4150
- cc = greater_equal;
4151
- __ mov(edx, result_register());
4152
- __ pop(eax);
4153
- break;
4154
- case Token::GTE:
4155
- cc = greater_equal;
4156
- __ pop(edx);
4157
- break;
4158
- case Token::IN:
4159
- case Token::INSTANCEOF:
4160
- default:
4161
- UNREACHABLE();
4162
- }
4163
-
4164
- bool inline_smi_code = ShouldInlineSmiCase(op);
4165
- JumpPatchSite patch_site(masm_);
4166
- if (inline_smi_code) {
4167
- NearLabel slow_case;
4168
- __ mov(ecx, Operand(edx));
4169
- __ or_(ecx, Operand(eax));
4170
- patch_site.EmitJumpIfNotSmi(ecx, &slow_case);
4171
- __ cmp(edx, Operand(eax));
4172
- Split(cc, if_true, if_false, NULL);
4173
- __ bind(&slow_case);
4174
- }
4175
-
4176
- // Record position and call the compare IC.
4177
- SetSourcePosition(expr->position());
4178
- Handle<Code> ic = CompareIC::GetUninitialized(op);
4179
- EmitCallIC(ic, &patch_site);
4180
-
4181
- PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
4182
- __ test(eax, Operand(eax));
4183
- Split(cc, if_true, if_false, fall_through);
4184
- }
4185
- }
4186
-
4187
- // Convert the result of the comparison into one expected for this
4188
- // expression's context.
4189
- context()->Plug(if_true, if_false);
4190
- }
4191
-
4192
-
4193
- void FullCodeGenerator::VisitCompareToNull(CompareToNull* expr) {
4194
- Label materialize_true, materialize_false;
4195
- Label* if_true = NULL;
4196
- Label* if_false = NULL;
4197
- Label* fall_through = NULL;
4198
- context()->PrepareTest(&materialize_true, &materialize_false,
4199
- &if_true, &if_false, &fall_through);
4200
-
4201
- VisitForAccumulatorValue(expr->expression());
4202
- PrepareForBailoutBeforeSplit(TOS_REG, true, if_true, if_false);
4203
-
4204
- __ cmp(eax, isolate()->factory()->null_value());
4205
- if (expr->is_strict()) {
4206
- Split(equal, if_true, if_false, fall_through);
4207
- } else {
4208
- __ j(equal, if_true);
4209
- __ cmp(eax, isolate()->factory()->undefined_value());
4210
- __ j(equal, if_true);
4211
- __ test(eax, Immediate(kSmiTagMask));
4212
- __ j(zero, if_false);
4213
- // It can be an undetectable object.
4214
- __ mov(edx, FieldOperand(eax, HeapObject::kMapOffset));
4215
- __ movzx_b(edx, FieldOperand(edx, Map::kBitFieldOffset));
4216
- __ test(edx, Immediate(1 << Map::kIsUndetectable));
4217
- Split(not_zero, if_true, if_false, fall_through);
4218
- }
4219
- context()->Plug(if_true, if_false);
4220
- }
4221
-
4222
-
4223
- void FullCodeGenerator::VisitThisFunction(ThisFunction* expr) {
4224
- __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
4225
- context()->Plug(eax);
4226
- }
4227
-
4228
-
4229
- Register FullCodeGenerator::result_register() {
4230
- return eax;
4231
- }
4232
-
4233
-
4234
- Register FullCodeGenerator::context_register() {
4235
- return esi;
4236
- }
4237
-
4238
-
4239
- void FullCodeGenerator::EmitCallIC(Handle<Code> ic, RelocInfo::Mode mode) {
4240
- ASSERT(mode == RelocInfo::CODE_TARGET ||
4241
- mode == RelocInfo::CODE_TARGET_CONTEXT);
4242
- switch (ic->kind()) {
4243
- case Code::LOAD_IC:
4244
- __ IncrementCounter(isolate()->counters()->named_load_full(), 1);
4245
- break;
4246
- case Code::KEYED_LOAD_IC:
4247
- __ IncrementCounter(isolate()->counters()->keyed_load_full(), 1);
4248
- break;
4249
- case Code::STORE_IC:
4250
- __ IncrementCounter(isolate()->counters()->named_store_full(), 1);
4251
- break;
4252
- case Code::KEYED_STORE_IC:
4253
- __ IncrementCounter(isolate()->counters()->keyed_store_full(), 1);
4254
- default:
4255
- break;
4256
- }
4257
-
4258
- __ call(ic, mode);
4259
-
4260
- // Crankshaft doesn't need patching of inlined loads and stores.
4261
- // When compiling the snapshot we need to produce code that works
4262
- // with and without Crankshaft.
4263
- if (V8::UseCrankshaft() && !Serializer::enabled()) {
4264
- return;
4265
- }
4266
-
4267
- // If we're calling a (keyed) load or store stub, we have to mark
4268
- // the call as containing no inlined code so we will not attempt to
4269
- // patch it.
4270
- switch (ic->kind()) {
4271
- case Code::LOAD_IC:
4272
- case Code::KEYED_LOAD_IC:
4273
- case Code::STORE_IC:
4274
- case Code::KEYED_STORE_IC:
4275
- __ nop(); // Signals no inlined code.
4276
- break;
4277
- default:
4278
- // Do nothing.
4279
- break;
4280
- }
4281
- }
4282
-
4283
-
4284
- void FullCodeGenerator::EmitCallIC(Handle<Code> ic, JumpPatchSite* patch_site) {
4285
- Counters* counters = isolate()->counters();
4286
- switch (ic->kind()) {
4287
- case Code::LOAD_IC:
4288
- __ IncrementCounter(counters->named_load_full(), 1);
4289
- break;
4290
- case Code::KEYED_LOAD_IC:
4291
- __ IncrementCounter(counters->keyed_load_full(), 1);
4292
- break;
4293
- case Code::STORE_IC:
4294
- __ IncrementCounter(counters->named_store_full(), 1);
4295
- break;
4296
- case Code::KEYED_STORE_IC:
4297
- __ IncrementCounter(counters->keyed_store_full(), 1);
4298
- default:
4299
- break;
4300
- }
4301
-
4302
- __ call(ic, RelocInfo::CODE_TARGET);
4303
- if (patch_site != NULL && patch_site->is_bound()) {
4304
- patch_site->EmitPatchInfo();
4305
- } else {
4306
- __ nop(); // Signals no inlined code.
4307
- }
4308
- }
4309
-
4310
-
4311
- void FullCodeGenerator::StoreToFrameField(int frame_offset, Register value) {
4312
- ASSERT_EQ(POINTER_SIZE_ALIGN(frame_offset), frame_offset);
4313
- __ mov(Operand(ebp, frame_offset), value);
4314
- }
4315
-
4316
-
4317
- void FullCodeGenerator::LoadContextField(Register dst, int context_index) {
4318
- __ mov(dst, ContextOperand(esi, context_index));
4319
- }
4320
-
4321
-
4322
- // ----------------------------------------------------------------------------
4323
- // Non-local control flow support.
4324
-
4325
- void FullCodeGenerator::EnterFinallyBlock() {
4326
- // Cook return address on top of stack (smi encoded Code* delta)
4327
- ASSERT(!result_register().is(edx));
4328
- __ mov(edx, Operand(esp, 0));
4329
- __ sub(Operand(edx), Immediate(masm_->CodeObject()));
4330
- ASSERT_EQ(1, kSmiTagSize + kSmiShiftSize);
4331
- ASSERT_EQ(0, kSmiTag);
4332
- __ add(edx, Operand(edx)); // Convert to smi.
4333
- __ mov(Operand(esp, 0), edx);
4334
- // Store result register while executing finally block.
4335
- __ push(result_register());
4336
- }
4337
-
4338
-
4339
- void FullCodeGenerator::ExitFinallyBlock() {
4340
- ASSERT(!result_register().is(edx));
4341
- // Restore result register from stack.
4342
- __ pop(result_register());
4343
- // Uncook return address.
4344
- __ mov(edx, Operand(esp, 0));
4345
- __ sar(edx, 1); // Convert smi to int.
4346
- __ add(Operand(edx), Immediate(masm_->CodeObject()));
4347
- __ mov(Operand(esp, 0), edx);
4348
- // And return.
4349
- __ ret(0);
4350
- }
4351
-
4352
-
4353
- #undef __
4354
-
4355
- } } // namespace v8::internal
4356
-
4357
- #endif // V8_TARGET_ARCH_IA32