libv8 3.11.8.17 → 3.16.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (754) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -2
  3. data/Gemfile +1 -1
  4. data/Rakefile +6 -7
  5. data/lib/libv8/version.rb +1 -1
  6. data/vendor/v8/.gitignore +24 -3
  7. data/vendor/v8/AUTHORS +7 -0
  8. data/vendor/v8/ChangeLog +839 -0
  9. data/vendor/v8/DEPS +1 -1
  10. data/vendor/v8/Makefile.android +92 -0
  11. data/vendor/v8/OWNERS +11 -0
  12. data/vendor/v8/PRESUBMIT.py +71 -0
  13. data/vendor/v8/SConstruct +34 -39
  14. data/vendor/v8/build/android.gypi +56 -37
  15. data/vendor/v8/build/common.gypi +112 -30
  16. data/vendor/v8/build/gyp_v8 +1 -1
  17. data/vendor/v8/build/standalone.gypi +15 -11
  18. data/vendor/v8/include/v8-debug.h +9 -1
  19. data/vendor/v8/include/v8-preparser.h +4 -3
  20. data/vendor/v8/include/v8-profiler.h +25 -25
  21. data/vendor/v8/include/v8-testing.h +4 -3
  22. data/vendor/v8/include/v8.h +994 -540
  23. data/vendor/v8/preparser/preparser-process.cc +3 -3
  24. data/vendor/v8/samples/lineprocessor.cc +20 -27
  25. data/vendor/v8/samples/process.cc +18 -14
  26. data/vendor/v8/samples/shell.cc +16 -15
  27. data/vendor/v8/src/SConscript +15 -14
  28. data/vendor/v8/src/accessors.cc +169 -77
  29. data/vendor/v8/src/accessors.h +4 -0
  30. data/vendor/v8/src/allocation-inl.h +2 -2
  31. data/vendor/v8/src/allocation.h +7 -7
  32. data/vendor/v8/src/api.cc +810 -497
  33. data/vendor/v8/src/api.h +85 -60
  34. data/vendor/v8/src/arm/assembler-arm-inl.h +179 -22
  35. data/vendor/v8/src/arm/assembler-arm.cc +633 -264
  36. data/vendor/v8/src/arm/assembler-arm.h +264 -197
  37. data/vendor/v8/src/arm/builtins-arm.cc +117 -27
  38. data/vendor/v8/src/arm/code-stubs-arm.cc +1241 -700
  39. data/vendor/v8/src/arm/code-stubs-arm.h +35 -138
  40. data/vendor/v8/src/arm/codegen-arm.cc +285 -16
  41. data/vendor/v8/src/arm/codegen-arm.h +22 -0
  42. data/vendor/v8/src/arm/constants-arm.cc +5 -3
  43. data/vendor/v8/src/arm/constants-arm.h +24 -11
  44. data/vendor/v8/src/arm/debug-arm.cc +3 -3
  45. data/vendor/v8/src/arm/deoptimizer-arm.cc +382 -92
  46. data/vendor/v8/src/arm/disasm-arm.cc +61 -12
  47. data/vendor/v8/src/arm/frames-arm.h +0 -14
  48. data/vendor/v8/src/arm/full-codegen-arm.cc +332 -304
  49. data/vendor/v8/src/arm/ic-arm.cc +180 -259
  50. data/vendor/v8/src/arm/lithium-arm.cc +364 -316
  51. data/vendor/v8/src/arm/lithium-arm.h +512 -275
  52. data/vendor/v8/src/arm/lithium-codegen-arm.cc +1768 -809
  53. data/vendor/v8/src/arm/lithium-codegen-arm.h +97 -35
  54. data/vendor/v8/src/arm/lithium-gap-resolver-arm.cc +12 -5
  55. data/vendor/v8/src/arm/macro-assembler-arm.cc +439 -228
  56. data/vendor/v8/src/arm/macro-assembler-arm.h +116 -70
  57. data/vendor/v8/src/arm/regexp-macro-assembler-arm.cc +54 -44
  58. data/vendor/v8/src/arm/regexp-macro-assembler-arm.h +3 -10
  59. data/vendor/v8/src/arm/simulator-arm.cc +272 -238
  60. data/vendor/v8/src/arm/simulator-arm.h +38 -8
  61. data/vendor/v8/src/arm/stub-cache-arm.cc +522 -895
  62. data/vendor/v8/src/array.js +101 -70
  63. data/vendor/v8/src/assembler.cc +270 -19
  64. data/vendor/v8/src/assembler.h +110 -15
  65. data/vendor/v8/src/ast.cc +79 -69
  66. data/vendor/v8/src/ast.h +255 -301
  67. data/vendor/v8/src/atomicops.h +7 -1
  68. data/vendor/v8/src/atomicops_internals_tsan.h +335 -0
  69. data/vendor/v8/src/bootstrapper.cc +481 -418
  70. data/vendor/v8/src/bootstrapper.h +4 -4
  71. data/vendor/v8/src/builtins.cc +498 -311
  72. data/vendor/v8/src/builtins.h +75 -47
  73. data/vendor/v8/src/checks.cc +2 -1
  74. data/vendor/v8/src/checks.h +8 -0
  75. data/vendor/v8/src/code-stubs-hydrogen.cc +253 -0
  76. data/vendor/v8/src/code-stubs.cc +249 -84
  77. data/vendor/v8/src/code-stubs.h +501 -169
  78. data/vendor/v8/src/codegen.cc +36 -18
  79. data/vendor/v8/src/codegen.h +25 -3
  80. data/vendor/v8/src/collection.js +54 -17
  81. data/vendor/v8/src/compilation-cache.cc +24 -16
  82. data/vendor/v8/src/compilation-cache.h +15 -6
  83. data/vendor/v8/src/compiler.cc +497 -195
  84. data/vendor/v8/src/compiler.h +246 -38
  85. data/vendor/v8/src/contexts.cc +64 -24
  86. data/vendor/v8/src/contexts.h +60 -29
  87. data/vendor/v8/src/conversions-inl.h +24 -14
  88. data/vendor/v8/src/conversions.h +7 -4
  89. data/vendor/v8/src/counters.cc +21 -12
  90. data/vendor/v8/src/counters.h +44 -16
  91. data/vendor/v8/src/cpu-profiler.h +1 -1
  92. data/vendor/v8/src/d8-debug.cc +2 -2
  93. data/vendor/v8/src/d8-readline.cc +13 -2
  94. data/vendor/v8/src/d8.cc +681 -273
  95. data/vendor/v8/src/d8.gyp +4 -4
  96. data/vendor/v8/src/d8.h +38 -18
  97. data/vendor/v8/src/d8.js +0 -617
  98. data/vendor/v8/src/data-flow.h +55 -0
  99. data/vendor/v8/src/date.js +1 -42
  100. data/vendor/v8/src/dateparser-inl.h +5 -1
  101. data/vendor/v8/src/debug-agent.cc +10 -15
  102. data/vendor/v8/src/debug-debugger.js +147 -149
  103. data/vendor/v8/src/debug.cc +323 -164
  104. data/vendor/v8/src/debug.h +26 -14
  105. data/vendor/v8/src/deoptimizer.cc +765 -290
  106. data/vendor/v8/src/deoptimizer.h +130 -28
  107. data/vendor/v8/src/disassembler.cc +10 -4
  108. data/vendor/v8/src/elements-kind.cc +7 -2
  109. data/vendor/v8/src/elements-kind.h +19 -0
  110. data/vendor/v8/src/elements.cc +607 -285
  111. data/vendor/v8/src/elements.h +36 -13
  112. data/vendor/v8/src/execution.cc +52 -31
  113. data/vendor/v8/src/execution.h +4 -4
  114. data/vendor/v8/src/extensions/externalize-string-extension.cc +5 -4
  115. data/vendor/v8/src/extensions/gc-extension.cc +5 -1
  116. data/vendor/v8/src/extensions/statistics-extension.cc +153 -0
  117. data/vendor/v8/src/{inspector.h → extensions/statistics-extension.h} +12 -23
  118. data/vendor/v8/src/factory.cc +101 -134
  119. data/vendor/v8/src/factory.h +36 -31
  120. data/vendor/v8/src/flag-definitions.h +102 -25
  121. data/vendor/v8/src/flags.cc +9 -5
  122. data/vendor/v8/src/frames-inl.h +10 -0
  123. data/vendor/v8/src/frames.cc +116 -26
  124. data/vendor/v8/src/frames.h +96 -12
  125. data/vendor/v8/src/full-codegen.cc +219 -74
  126. data/vendor/v8/src/full-codegen.h +63 -21
  127. data/vendor/v8/src/func-name-inferrer.cc +8 -7
  128. data/vendor/v8/src/func-name-inferrer.h +5 -3
  129. data/vendor/v8/src/gdb-jit.cc +71 -57
  130. data/vendor/v8/src/global-handles.cc +230 -101
  131. data/vendor/v8/src/global-handles.h +26 -27
  132. data/vendor/v8/src/globals.h +17 -19
  133. data/vendor/v8/src/handles-inl.h +59 -12
  134. data/vendor/v8/src/handles.cc +180 -200
  135. data/vendor/v8/src/handles.h +80 -11
  136. data/vendor/v8/src/hashmap.h +60 -40
  137. data/vendor/v8/src/heap-inl.h +107 -45
  138. data/vendor/v8/src/heap-profiler.cc +38 -19
  139. data/vendor/v8/src/heap-profiler.h +24 -14
  140. data/vendor/v8/src/heap.cc +1123 -738
  141. data/vendor/v8/src/heap.h +385 -146
  142. data/vendor/v8/src/hydrogen-instructions.cc +700 -217
  143. data/vendor/v8/src/hydrogen-instructions.h +1158 -472
  144. data/vendor/v8/src/hydrogen.cc +3319 -1662
  145. data/vendor/v8/src/hydrogen.h +411 -170
  146. data/vendor/v8/src/ia32/assembler-ia32-inl.h +46 -16
  147. data/vendor/v8/src/ia32/assembler-ia32.cc +131 -61
  148. data/vendor/v8/src/ia32/assembler-ia32.h +115 -57
  149. data/vendor/v8/src/ia32/builtins-ia32.cc +99 -5
  150. data/vendor/v8/src/ia32/code-stubs-ia32.cc +787 -495
  151. data/vendor/v8/src/ia32/code-stubs-ia32.h +10 -100
  152. data/vendor/v8/src/ia32/codegen-ia32.cc +227 -23
  153. data/vendor/v8/src/ia32/codegen-ia32.h +14 -0
  154. data/vendor/v8/src/ia32/deoptimizer-ia32.cc +428 -87
  155. data/vendor/v8/src/ia32/disasm-ia32.cc +28 -1
  156. data/vendor/v8/src/ia32/frames-ia32.h +6 -16
  157. data/vendor/v8/src/ia32/full-codegen-ia32.cc +280 -272
  158. data/vendor/v8/src/ia32/ic-ia32.cc +150 -250
  159. data/vendor/v8/src/ia32/lithium-codegen-ia32.cc +1600 -517
  160. data/vendor/v8/src/ia32/lithium-codegen-ia32.h +90 -24
  161. data/vendor/v8/src/ia32/lithium-gap-resolver-ia32.cc +10 -6
  162. data/vendor/v8/src/ia32/lithium-gap-resolver-ia32.h +2 -2
  163. data/vendor/v8/src/ia32/lithium-ia32.cc +405 -302
  164. data/vendor/v8/src/ia32/lithium-ia32.h +526 -271
  165. data/vendor/v8/src/ia32/macro-assembler-ia32.cc +378 -119
  166. data/vendor/v8/src/ia32/macro-assembler-ia32.h +62 -28
  167. data/vendor/v8/src/ia32/regexp-macro-assembler-ia32.cc +43 -30
  168. data/vendor/v8/src/ia32/regexp-macro-assembler-ia32.h +2 -10
  169. data/vendor/v8/src/ia32/stub-cache-ia32.cc +492 -678
  170. data/vendor/v8/src/ic-inl.h +9 -4
  171. data/vendor/v8/src/ic.cc +836 -923
  172. data/vendor/v8/src/ic.h +228 -247
  173. data/vendor/v8/src/incremental-marking-inl.h +26 -30
  174. data/vendor/v8/src/incremental-marking.cc +276 -248
  175. data/vendor/v8/src/incremental-marking.h +29 -37
  176. data/vendor/v8/src/interface.cc +34 -25
  177. data/vendor/v8/src/interface.h +69 -25
  178. data/vendor/v8/src/interpreter-irregexp.cc +2 -2
  179. data/vendor/v8/src/isolate.cc +382 -76
  180. data/vendor/v8/src/isolate.h +109 -56
  181. data/vendor/v8/src/json-parser.h +217 -104
  182. data/vendor/v8/src/json-stringifier.h +745 -0
  183. data/vendor/v8/src/json.js +10 -132
  184. data/vendor/v8/src/jsregexp-inl.h +106 -0
  185. data/vendor/v8/src/jsregexp.cc +517 -285
  186. data/vendor/v8/src/jsregexp.h +145 -117
  187. data/vendor/v8/src/list-inl.h +35 -22
  188. data/vendor/v8/src/list.h +46 -19
  189. data/vendor/v8/src/lithium-allocator-inl.h +22 -2
  190. data/vendor/v8/src/lithium-allocator.cc +85 -70
  191. data/vendor/v8/src/lithium-allocator.h +21 -39
  192. data/vendor/v8/src/lithium.cc +259 -5
  193. data/vendor/v8/src/lithium.h +131 -32
  194. data/vendor/v8/src/liveedit-debugger.js +52 -3
  195. data/vendor/v8/src/liveedit.cc +393 -113
  196. data/vendor/v8/src/liveedit.h +7 -3
  197. data/vendor/v8/src/log-utils.cc +4 -2
  198. data/vendor/v8/src/log.cc +170 -140
  199. data/vendor/v8/src/log.h +62 -11
  200. data/vendor/v8/src/macro-assembler.h +17 -0
  201. data/vendor/v8/src/macros.py +2 -0
  202. data/vendor/v8/src/mark-compact-inl.h +3 -23
  203. data/vendor/v8/src/mark-compact.cc +801 -830
  204. data/vendor/v8/src/mark-compact.h +154 -47
  205. data/vendor/v8/src/marking-thread.cc +85 -0
  206. data/vendor/v8/src/{inspector.cc → marking-thread.h} +32 -24
  207. data/vendor/v8/src/math.js +12 -18
  208. data/vendor/v8/src/messages.cc +18 -8
  209. data/vendor/v8/src/messages.js +314 -261
  210. data/vendor/v8/src/mips/assembler-mips-inl.h +58 -6
  211. data/vendor/v8/src/mips/assembler-mips.cc +92 -75
  212. data/vendor/v8/src/mips/assembler-mips.h +54 -60
  213. data/vendor/v8/src/mips/builtins-mips.cc +116 -17
  214. data/vendor/v8/src/mips/code-stubs-mips.cc +919 -556
  215. data/vendor/v8/src/mips/code-stubs-mips.h +22 -131
  216. data/vendor/v8/src/mips/codegen-mips.cc +281 -6
  217. data/vendor/v8/src/mips/codegen-mips.h +22 -0
  218. data/vendor/v8/src/mips/constants-mips.cc +2 -0
  219. data/vendor/v8/src/mips/constants-mips.h +12 -2
  220. data/vendor/v8/src/mips/deoptimizer-mips.cc +286 -50
  221. data/vendor/v8/src/mips/disasm-mips.cc +13 -0
  222. data/vendor/v8/src/mips/full-codegen-mips.cc +297 -284
  223. data/vendor/v8/src/mips/ic-mips.cc +182 -263
  224. data/vendor/v8/src/mips/lithium-codegen-mips.cc +1208 -556
  225. data/vendor/v8/src/mips/lithium-codegen-mips.h +72 -19
  226. data/vendor/v8/src/mips/lithium-gap-resolver-mips.cc +9 -2
  227. data/vendor/v8/src/mips/lithium-mips.cc +290 -302
  228. data/vendor/v8/src/mips/lithium-mips.h +463 -266
  229. data/vendor/v8/src/mips/macro-assembler-mips.cc +208 -115
  230. data/vendor/v8/src/mips/macro-assembler-mips.h +67 -24
  231. data/vendor/v8/src/mips/regexp-macro-assembler-mips.cc +40 -25
  232. data/vendor/v8/src/mips/regexp-macro-assembler-mips.h +3 -9
  233. data/vendor/v8/src/mips/simulator-mips.cc +112 -40
  234. data/vendor/v8/src/mips/simulator-mips.h +5 -0
  235. data/vendor/v8/src/mips/stub-cache-mips.cc +502 -884
  236. data/vendor/v8/src/mirror-debugger.js +157 -30
  237. data/vendor/v8/src/mksnapshot.cc +88 -14
  238. data/vendor/v8/src/object-observe.js +235 -0
  239. data/vendor/v8/src/objects-debug.cc +178 -176
  240. data/vendor/v8/src/objects-inl.h +1333 -486
  241. data/vendor/v8/src/objects-printer.cc +125 -43
  242. data/vendor/v8/src/objects-visiting-inl.h +578 -6
  243. data/vendor/v8/src/objects-visiting.cc +2 -2
  244. data/vendor/v8/src/objects-visiting.h +172 -79
  245. data/vendor/v8/src/objects.cc +3533 -2885
  246. data/vendor/v8/src/objects.h +1352 -1131
  247. data/vendor/v8/src/optimizing-compiler-thread.cc +152 -0
  248. data/vendor/v8/src/optimizing-compiler-thread.h +111 -0
  249. data/vendor/v8/src/parser.cc +390 -500
  250. data/vendor/v8/src/parser.h +45 -33
  251. data/vendor/v8/src/platform-cygwin.cc +10 -21
  252. data/vendor/v8/src/platform-freebsd.cc +36 -41
  253. data/vendor/v8/src/platform-linux.cc +160 -124
  254. data/vendor/v8/src/platform-macos.cc +30 -27
  255. data/vendor/v8/src/platform-nullos.cc +17 -1
  256. data/vendor/v8/src/platform-openbsd.cc +19 -50
  257. data/vendor/v8/src/platform-posix.cc +14 -0
  258. data/vendor/v8/src/platform-solaris.cc +20 -53
  259. data/vendor/v8/src/platform-win32.cc +49 -26
  260. data/vendor/v8/src/platform.h +40 -1
  261. data/vendor/v8/src/preparser.cc +8 -5
  262. data/vendor/v8/src/preparser.h +2 -2
  263. data/vendor/v8/src/prettyprinter.cc +16 -0
  264. data/vendor/v8/src/prettyprinter.h +2 -0
  265. data/vendor/v8/src/profile-generator-inl.h +1 -0
  266. data/vendor/v8/src/profile-generator.cc +209 -147
  267. data/vendor/v8/src/profile-generator.h +15 -12
  268. data/vendor/v8/src/property-details.h +46 -31
  269. data/vendor/v8/src/property.cc +27 -46
  270. data/vendor/v8/src/property.h +163 -83
  271. data/vendor/v8/src/proxy.js +7 -2
  272. data/vendor/v8/src/regexp-macro-assembler-irregexp.cc +4 -13
  273. data/vendor/v8/src/regexp-macro-assembler-irregexp.h +1 -2
  274. data/vendor/v8/src/regexp-macro-assembler-tracer.cc +1 -11
  275. data/vendor/v8/src/regexp-macro-assembler-tracer.h +0 -1
  276. data/vendor/v8/src/regexp-macro-assembler.cc +31 -14
  277. data/vendor/v8/src/regexp-macro-assembler.h +14 -11
  278. data/vendor/v8/src/regexp-stack.cc +1 -0
  279. data/vendor/v8/src/regexp.js +9 -8
  280. data/vendor/v8/src/rewriter.cc +18 -7
  281. data/vendor/v8/src/runtime-profiler.cc +52 -43
  282. data/vendor/v8/src/runtime-profiler.h +0 -25
  283. data/vendor/v8/src/runtime.cc +2006 -2023
  284. data/vendor/v8/src/runtime.h +56 -49
  285. data/vendor/v8/src/safepoint-table.cc +12 -18
  286. data/vendor/v8/src/safepoint-table.h +11 -8
  287. data/vendor/v8/src/scanner.cc +1 -0
  288. data/vendor/v8/src/scanner.h +4 -10
  289. data/vendor/v8/src/scopeinfo.cc +35 -9
  290. data/vendor/v8/src/scopeinfo.h +64 -3
  291. data/vendor/v8/src/scopes.cc +251 -156
  292. data/vendor/v8/src/scopes.h +61 -27
  293. data/vendor/v8/src/serialize.cc +348 -396
  294. data/vendor/v8/src/serialize.h +125 -114
  295. data/vendor/v8/src/small-pointer-list.h +11 -11
  296. data/vendor/v8/src/{smart-array-pointer.h → smart-pointers.h} +64 -15
  297. data/vendor/v8/src/snapshot-common.cc +64 -15
  298. data/vendor/v8/src/snapshot-empty.cc +7 -1
  299. data/vendor/v8/src/snapshot.h +9 -2
  300. data/vendor/v8/src/spaces-inl.h +17 -0
  301. data/vendor/v8/src/spaces.cc +477 -183
  302. data/vendor/v8/src/spaces.h +238 -58
  303. data/vendor/v8/src/splay-tree-inl.h +8 -7
  304. data/vendor/v8/src/splay-tree.h +24 -10
  305. data/vendor/v8/src/store-buffer.cc +12 -5
  306. data/vendor/v8/src/store-buffer.h +2 -4
  307. data/vendor/v8/src/string-search.h +22 -6
  308. data/vendor/v8/src/string-stream.cc +11 -8
  309. data/vendor/v8/src/string.js +47 -15
  310. data/vendor/v8/src/stub-cache.cc +461 -224
  311. data/vendor/v8/src/stub-cache.h +164 -102
  312. data/vendor/v8/src/sweeper-thread.cc +105 -0
  313. data/vendor/v8/src/sweeper-thread.h +81 -0
  314. data/vendor/v8/src/token.h +1 -0
  315. data/vendor/v8/src/transitions-inl.h +220 -0
  316. data/vendor/v8/src/transitions.cc +160 -0
  317. data/vendor/v8/src/transitions.h +207 -0
  318. data/vendor/v8/src/type-info.cc +182 -181
  319. data/vendor/v8/src/type-info.h +31 -19
  320. data/vendor/v8/src/unicode-inl.h +62 -106
  321. data/vendor/v8/src/unicode.cc +57 -67
  322. data/vendor/v8/src/unicode.h +45 -91
  323. data/vendor/v8/src/uri.js +57 -29
  324. data/vendor/v8/src/utils.h +105 -5
  325. data/vendor/v8/src/v8-counters.cc +54 -11
  326. data/vendor/v8/src/v8-counters.h +134 -19
  327. data/vendor/v8/src/v8.cc +29 -29
  328. data/vendor/v8/src/v8.h +1 -0
  329. data/vendor/v8/src/v8conversions.cc +26 -22
  330. data/vendor/v8/src/v8globals.h +56 -43
  331. data/vendor/v8/src/v8natives.js +83 -30
  332. data/vendor/v8/src/v8threads.cc +42 -21
  333. data/vendor/v8/src/v8threads.h +4 -1
  334. data/vendor/v8/src/v8utils.cc +9 -93
  335. data/vendor/v8/src/v8utils.h +37 -33
  336. data/vendor/v8/src/variables.cc +6 -3
  337. data/vendor/v8/src/variables.h +6 -13
  338. data/vendor/v8/src/version.cc +2 -2
  339. data/vendor/v8/src/vm-state-inl.h +11 -0
  340. data/vendor/v8/src/x64/assembler-x64-inl.h +39 -8
  341. data/vendor/v8/src/x64/assembler-x64.cc +78 -64
  342. data/vendor/v8/src/x64/assembler-x64.h +38 -33
  343. data/vendor/v8/src/x64/builtins-x64.cc +105 -7
  344. data/vendor/v8/src/x64/code-stubs-x64.cc +790 -413
  345. data/vendor/v8/src/x64/code-stubs-x64.h +10 -106
  346. data/vendor/v8/src/x64/codegen-x64.cc +210 -8
  347. data/vendor/v8/src/x64/codegen-x64.h +20 -1
  348. data/vendor/v8/src/x64/deoptimizer-x64.cc +336 -75
  349. data/vendor/v8/src/x64/disasm-x64.cc +15 -0
  350. data/vendor/v8/src/x64/frames-x64.h +0 -14
  351. data/vendor/v8/src/x64/full-codegen-x64.cc +293 -270
  352. data/vendor/v8/src/x64/ic-x64.cc +153 -251
  353. data/vendor/v8/src/x64/lithium-codegen-x64.cc +1379 -531
  354. data/vendor/v8/src/x64/lithium-codegen-x64.h +67 -23
  355. data/vendor/v8/src/x64/lithium-gap-resolver-x64.cc +2 -2
  356. data/vendor/v8/src/x64/lithium-x64.cc +349 -289
  357. data/vendor/v8/src/x64/lithium-x64.h +460 -250
  358. data/vendor/v8/src/x64/macro-assembler-x64.cc +350 -177
  359. data/vendor/v8/src/x64/macro-assembler-x64.h +67 -49
  360. data/vendor/v8/src/x64/regexp-macro-assembler-x64.cc +46 -33
  361. data/vendor/v8/src/x64/regexp-macro-assembler-x64.h +2 -3
  362. data/vendor/v8/src/x64/stub-cache-x64.cc +484 -653
  363. data/vendor/v8/src/zone-inl.h +9 -27
  364. data/vendor/v8/src/zone.cc +5 -5
  365. data/vendor/v8/src/zone.h +53 -27
  366. data/vendor/v8/test/benchmarks/testcfg.py +5 -0
  367. data/vendor/v8/test/cctest/cctest.cc +4 -0
  368. data/vendor/v8/test/cctest/cctest.gyp +3 -1
  369. data/vendor/v8/test/cctest/cctest.h +57 -9
  370. data/vendor/v8/test/cctest/cctest.status +15 -15
  371. data/vendor/v8/test/cctest/test-accessors.cc +26 -0
  372. data/vendor/v8/test/cctest/test-alloc.cc +22 -30
  373. data/vendor/v8/test/cctest/test-api.cc +1943 -314
  374. data/vendor/v8/test/cctest/test-assembler-arm.cc +133 -13
  375. data/vendor/v8/test/cctest/test-assembler-ia32.cc +1 -1
  376. data/vendor/v8/test/cctest/test-assembler-mips.cc +12 -0
  377. data/vendor/v8/test/cctest/test-ast.cc +4 -2
  378. data/vendor/v8/test/cctest/test-compiler.cc +61 -29
  379. data/vendor/v8/test/cctest/test-dataflow.cc +2 -2
  380. data/vendor/v8/test/cctest/test-debug.cc +212 -33
  381. data/vendor/v8/test/cctest/test-decls.cc +257 -11
  382. data/vendor/v8/test/cctest/test-dictionary.cc +24 -10
  383. data/vendor/v8/test/cctest/test-disasm-arm.cc +118 -1
  384. data/vendor/v8/test/cctest/test-disasm-ia32.cc +3 -2
  385. data/vendor/v8/test/cctest/test-flags.cc +14 -1
  386. data/vendor/v8/test/cctest/test-func-name-inference.cc +7 -4
  387. data/vendor/v8/test/cctest/test-global-object.cc +51 -0
  388. data/vendor/v8/test/cctest/test-hashing.cc +32 -23
  389. data/vendor/v8/test/cctest/test-heap-profiler.cc +131 -77
  390. data/vendor/v8/test/cctest/test-heap.cc +1084 -143
  391. data/vendor/v8/test/cctest/test-list.cc +1 -1
  392. data/vendor/v8/test/cctest/test-liveedit.cc +3 -2
  393. data/vendor/v8/test/cctest/test-lockers.cc +12 -13
  394. data/vendor/v8/test/cctest/test-log.cc +10 -8
  395. data/vendor/v8/test/cctest/test-macro-assembler-x64.cc +2 -2
  396. data/vendor/v8/test/cctest/test-mark-compact.cc +44 -22
  397. data/vendor/v8/test/cctest/test-object-observe.cc +434 -0
  398. data/vendor/v8/test/cctest/test-parsing.cc +86 -39
  399. data/vendor/v8/test/cctest/test-platform-linux.cc +6 -0
  400. data/vendor/v8/test/cctest/test-platform-win32.cc +7 -0
  401. data/vendor/v8/test/cctest/test-random.cc +5 -4
  402. data/vendor/v8/test/cctest/test-regexp.cc +137 -101
  403. data/vendor/v8/test/cctest/test-serialize.cc +150 -230
  404. data/vendor/v8/test/cctest/test-sockets.cc +1 -1
  405. data/vendor/v8/test/cctest/test-spaces.cc +139 -0
  406. data/vendor/v8/test/cctest/test-strings.cc +736 -74
  407. data/vendor/v8/test/cctest/test-thread-termination.cc +10 -11
  408. data/vendor/v8/test/cctest/test-threads.cc +4 -4
  409. data/vendor/v8/test/cctest/test-utils.cc +16 -0
  410. data/vendor/v8/test/cctest/test-weakmaps.cc +7 -3
  411. data/vendor/v8/test/cctest/testcfg.py +64 -5
  412. data/vendor/v8/test/es5conform/testcfg.py +5 -0
  413. data/vendor/v8/test/message/message.status +1 -1
  414. data/vendor/v8/test/message/overwritten-builtins.out +3 -0
  415. data/vendor/v8/test/message/testcfg.py +89 -8
  416. data/vendor/v8/test/message/try-catch-finally-no-message.out +26 -26
  417. data/vendor/v8/test/mjsunit/accessor-map-sharing.js +18 -2
  418. data/vendor/v8/test/mjsunit/allocation-site-info.js +126 -0
  419. data/vendor/v8/test/mjsunit/array-bounds-check-removal.js +62 -1
  420. data/vendor/v8/test/mjsunit/array-iteration.js +1 -1
  421. data/vendor/v8/test/mjsunit/array-literal-transitions.js +2 -0
  422. data/vendor/v8/test/mjsunit/array-natives-elements.js +317 -0
  423. data/vendor/v8/test/mjsunit/array-reduce.js +8 -8
  424. data/vendor/v8/test/mjsunit/array-slice.js +12 -0
  425. data/vendor/v8/test/mjsunit/array-store-and-grow.js +4 -1
  426. data/vendor/v8/test/mjsunit/assert-opt-and-deopt.js +1 -1
  427. data/vendor/v8/test/mjsunit/bugs/bug-2337.js +53 -0
  428. data/vendor/v8/test/mjsunit/compare-known-objects-slow.js +69 -0
  429. data/vendor/v8/test/mjsunit/compiler/alloc-object-huge.js +3 -1
  430. data/vendor/v8/test/mjsunit/compiler/inline-accessors.js +368 -0
  431. data/vendor/v8/test/mjsunit/compiler/inline-arguments.js +87 -1
  432. data/vendor/v8/test/mjsunit/compiler/inline-closures.js +49 -0
  433. data/vendor/v8/test/mjsunit/compiler/inline-construct.js +55 -43
  434. data/vendor/v8/test/mjsunit/compiler/inline-literals.js +39 -0
  435. data/vendor/v8/test/mjsunit/compiler/multiply-add.js +69 -0
  436. data/vendor/v8/test/mjsunit/compiler/optimized-closures.js +57 -0
  437. data/vendor/v8/test/mjsunit/compiler/parallel-proto-change.js +44 -0
  438. data/vendor/v8/test/mjsunit/compiler/property-static.js +69 -0
  439. data/vendor/v8/test/mjsunit/compiler/proto-chain-constant.js +55 -0
  440. data/vendor/v8/test/mjsunit/compiler/proto-chain-load.js +44 -0
  441. data/vendor/v8/test/mjsunit/compiler/regress-gvn.js +3 -2
  442. data/vendor/v8/test/mjsunit/compiler/regress-or.js +6 -2
  443. data/vendor/v8/test/mjsunit/compiler/rotate.js +224 -0
  444. data/vendor/v8/test/mjsunit/compiler/uint32.js +173 -0
  445. data/vendor/v8/test/mjsunit/count-based-osr.js +2 -1
  446. data/vendor/v8/test/mjsunit/d8-os.js +3 -3
  447. data/vendor/v8/test/mjsunit/date-parse.js +3 -0
  448. data/vendor/v8/test/mjsunit/date.js +22 -0
  449. data/vendor/v8/test/mjsunit/debug-break-inline.js +1 -0
  450. data/vendor/v8/test/mjsunit/debug-evaluate-locals-optimized-double.js +22 -12
  451. data/vendor/v8/test/mjsunit/debug-evaluate-locals-optimized.js +21 -10
  452. data/vendor/v8/test/mjsunit/debug-liveedit-compile-error.js +60 -0
  453. data/vendor/v8/test/mjsunit/debug-liveedit-double-call.js +142 -0
  454. data/vendor/v8/test/mjsunit/debug-liveedit-literals.js +94 -0
  455. data/vendor/v8/test/mjsunit/debug-liveedit-restart-frame.js +153 -0
  456. data/vendor/v8/test/mjsunit/debug-multiple-breakpoints.js +1 -1
  457. data/vendor/v8/test/mjsunit/debug-script-breakpoints-closure.js +67 -0
  458. data/vendor/v8/test/mjsunit/debug-script-breakpoints-nested.js +82 -0
  459. data/vendor/v8/test/mjsunit/debug-script.js +4 -2
  460. data/vendor/v8/test/mjsunit/debug-set-variable-value.js +308 -0
  461. data/vendor/v8/test/mjsunit/debug-stepout-scope-part1.js +190 -0
  462. data/vendor/v8/test/mjsunit/debug-stepout-scope-part2.js +83 -0
  463. data/vendor/v8/test/mjsunit/debug-stepout-scope-part3.js +80 -0
  464. data/vendor/v8/test/mjsunit/debug-stepout-scope-part4.js +80 -0
  465. data/vendor/v8/test/mjsunit/debug-stepout-scope-part5.js +77 -0
  466. data/vendor/v8/test/mjsunit/debug-stepout-scope-part6.js +79 -0
  467. data/vendor/v8/test/mjsunit/debug-stepout-scope-part7.js +79 -0
  468. data/vendor/v8/test/mjsunit/{debug-stepout-scope.js → debug-stepout-scope-part8.js} +0 -189
  469. data/vendor/v8/test/mjsunit/delete-non-configurable.js +74 -0
  470. data/vendor/v8/test/mjsunit/deopt-minus-zero.js +56 -0
  471. data/vendor/v8/test/mjsunit/elements-kind.js +6 -4
  472. data/vendor/v8/test/mjsunit/elements-length-no-holey.js +33 -0
  473. data/vendor/v8/test/mjsunit/elements-transition-hoisting.js +46 -19
  474. data/vendor/v8/test/mjsunit/error-accessors.js +54 -0
  475. data/vendor/v8/test/mjsunit/error-constructors.js +1 -14
  476. data/vendor/v8/test/mjsunit/error-tostring.js +8 -0
  477. data/vendor/v8/test/mjsunit/eval-stack-trace.js +204 -0
  478. data/vendor/v8/test/mjsunit/external-array.js +364 -1
  479. data/vendor/v8/test/mjsunit/fast-array-length.js +37 -0
  480. data/vendor/v8/test/mjsunit/fast-non-keyed.js +113 -0
  481. data/vendor/v8/test/mjsunit/fast-prototype.js +117 -0
  482. data/vendor/v8/test/mjsunit/function-call.js +14 -18
  483. data/vendor/v8/test/mjsunit/fuzz-natives-part1.js +230 -0
  484. data/vendor/v8/test/mjsunit/fuzz-natives-part2.js +229 -0
  485. data/vendor/v8/test/mjsunit/fuzz-natives-part3.js +229 -0
  486. data/vendor/v8/test/mjsunit/{fuzz-natives.js → fuzz-natives-part4.js} +12 -2
  487. data/vendor/v8/test/mjsunit/generated-transition-stub.js +218 -0
  488. data/vendor/v8/test/mjsunit/greedy.js +1 -1
  489. data/vendor/v8/test/mjsunit/harmony/block-conflicts.js +2 -1
  490. data/vendor/v8/test/mjsunit/harmony/block-let-crankshaft.js +1 -1
  491. data/vendor/v8/test/mjsunit/harmony/collections.js +69 -11
  492. data/vendor/v8/test/mjsunit/harmony/debug-blockscopes.js +2 -2
  493. data/vendor/v8/test/mjsunit/harmony/module-linking.js +180 -3
  494. data/vendor/v8/test/mjsunit/harmony/module-parsing.js +31 -0
  495. data/vendor/v8/test/mjsunit/harmony/module-recompile.js +87 -0
  496. data/vendor/v8/test/mjsunit/harmony/module-resolution.js +15 -2
  497. data/vendor/v8/test/mjsunit/harmony/object-observe.js +1056 -0
  498. data/vendor/v8/test/mjsunit/harmony/proxies-json.js +178 -0
  499. data/vendor/v8/test/mjsunit/harmony/proxies.js +25 -10
  500. data/vendor/v8/test/mjsunit/json-parser-recursive.js +33 -0
  501. data/vendor/v8/test/mjsunit/json-stringify-recursive.js +52 -0
  502. data/vendor/v8/test/mjsunit/json.js +38 -2
  503. data/vendor/v8/test/mjsunit/json2.js +153 -0
  504. data/vendor/v8/test/mjsunit/limit-locals.js +5 -4
  505. data/vendor/v8/test/mjsunit/manual-parallel-recompile.js +79 -0
  506. data/vendor/v8/test/mjsunit/math-exp-precision.js +64 -0
  507. data/vendor/v8/test/mjsunit/math-floor-negative.js +59 -0
  508. data/vendor/v8/test/mjsunit/math-floor-of-div-minus-zero.js +41 -0
  509. data/vendor/v8/test/mjsunit/math-floor-of-div-nosudiv.js +288 -0
  510. data/vendor/v8/test/mjsunit/math-floor-of-div.js +81 -9
  511. data/vendor/v8/test/mjsunit/{math-floor.js → math-floor-part1.js} +1 -72
  512. data/vendor/v8/test/mjsunit/math-floor-part2.js +76 -0
  513. data/vendor/v8/test/mjsunit/math-floor-part3.js +78 -0
  514. data/vendor/v8/test/mjsunit/math-floor-part4.js +76 -0
  515. data/vendor/v8/test/mjsunit/mirror-object.js +43 -9
  516. data/vendor/v8/test/mjsunit/mjsunit.js +1 -1
  517. data/vendor/v8/test/mjsunit/mjsunit.status +52 -27
  518. data/vendor/v8/test/mjsunit/mul-exhaustive-part1.js +491 -0
  519. data/vendor/v8/test/mjsunit/mul-exhaustive-part10.js +470 -0
  520. data/vendor/v8/test/mjsunit/mul-exhaustive-part2.js +525 -0
  521. data/vendor/v8/test/mjsunit/mul-exhaustive-part3.js +532 -0
  522. data/vendor/v8/test/mjsunit/mul-exhaustive-part4.js +509 -0
  523. data/vendor/v8/test/mjsunit/mul-exhaustive-part5.js +505 -0
  524. data/vendor/v8/test/mjsunit/mul-exhaustive-part6.js +554 -0
  525. data/vendor/v8/test/mjsunit/mul-exhaustive-part7.js +497 -0
  526. data/vendor/v8/test/mjsunit/mul-exhaustive-part8.js +526 -0
  527. data/vendor/v8/test/mjsunit/mul-exhaustive-part9.js +533 -0
  528. data/vendor/v8/test/mjsunit/new-function.js +34 -0
  529. data/vendor/v8/test/mjsunit/numops-fuzz-part1.js +1172 -0
  530. data/vendor/v8/test/mjsunit/numops-fuzz-part2.js +1178 -0
  531. data/vendor/v8/test/mjsunit/numops-fuzz-part3.js +1178 -0
  532. data/vendor/v8/test/mjsunit/numops-fuzz-part4.js +1177 -0
  533. data/vendor/v8/test/mjsunit/object-define-property.js +107 -2
  534. data/vendor/v8/test/mjsunit/override-read-only-property.js +6 -4
  535. data/vendor/v8/test/mjsunit/packed-elements.js +2 -2
  536. data/vendor/v8/test/mjsunit/parse-int-float.js +4 -4
  537. data/vendor/v8/test/mjsunit/pixel-array-rounding.js +1 -1
  538. data/vendor/v8/test/mjsunit/readonly.js +228 -0
  539. data/vendor/v8/test/mjsunit/regexp-capture-3.js +16 -18
  540. data/vendor/v8/test/mjsunit/regexp-capture.js +2 -0
  541. data/vendor/v8/test/mjsunit/regexp-global.js +122 -0
  542. data/vendor/v8/test/mjsunit/regexp-results-cache.js +78 -0
  543. data/vendor/v8/test/mjsunit/regress/regress-1117.js +12 -3
  544. data/vendor/v8/test/mjsunit/regress/regress-1118.js +1 -1
  545. data/vendor/v8/test/mjsunit/regress/regress-115100.js +36 -0
  546. data/vendor/v8/test/mjsunit/regress/regress-1199637.js +1 -3
  547. data/vendor/v8/test/mjsunit/regress/regress-121407.js +1 -1
  548. data/vendor/v8/test/mjsunit/regress/regress-131923.js +30 -0
  549. data/vendor/v8/test/mjsunit/regress/regress-131994.js +70 -0
  550. data/vendor/v8/test/mjsunit/regress/regress-133211.js +35 -0
  551. data/vendor/v8/test/mjsunit/regress/regress-133211b.js +39 -0
  552. data/vendor/v8/test/mjsunit/regress/regress-136048.js +34 -0
  553. data/vendor/v8/test/mjsunit/regress/regress-137768.js +73 -0
  554. data/vendor/v8/test/mjsunit/regress/regress-143967.js +34 -0
  555. data/vendor/v8/test/mjsunit/regress/regress-145201.js +107 -0
  556. data/vendor/v8/test/mjsunit/regress/regress-147497.js +45 -0
  557. data/vendor/v8/test/mjsunit/regress/regress-148378.js +38 -0
  558. data/vendor/v8/test/mjsunit/regress/regress-1563.js +1 -1
  559. data/vendor/v8/test/mjsunit/regress/regress-1591.js +48 -0
  560. data/vendor/v8/test/mjsunit/regress/regress-164442.js +45 -0
  561. data/vendor/v8/test/mjsunit/regress/regress-165637.js +61 -0
  562. data/vendor/v8/test/mjsunit/regress/regress-166379.js +39 -0
  563. data/vendor/v8/test/mjsunit/regress/regress-166553.js +33 -0
  564. data/vendor/v8/test/mjsunit/regress/regress-1692.js +1 -1
  565. data/vendor/v8/test/mjsunit/regress/regress-171641.js +40 -0
  566. data/vendor/v8/test/mjsunit/regress/regress-1980.js +1 -1
  567. data/vendor/v8/test/mjsunit/regress/regress-2073.js +99 -0
  568. data/vendor/v8/test/mjsunit/regress/regress-2119.js +36 -0
  569. data/vendor/v8/test/mjsunit/regress/regress-2156.js +39 -0
  570. data/vendor/v8/test/mjsunit/regress/regress-2163.js +70 -0
  571. data/vendor/v8/test/mjsunit/regress/regress-2170.js +58 -0
  572. data/vendor/v8/test/mjsunit/regress/regress-2172.js +35 -0
  573. data/vendor/v8/test/mjsunit/regress/regress-2185-2.js +145 -0
  574. data/vendor/v8/test/mjsunit/regress/regress-2185.js +38 -0
  575. data/vendor/v8/test/mjsunit/regress/regress-2186.js +49 -0
  576. data/vendor/v8/test/mjsunit/regress/regress-2193.js +58 -0
  577. data/vendor/v8/test/mjsunit/regress/regress-2219.js +32 -0
  578. data/vendor/v8/test/mjsunit/regress/regress-2225.js +65 -0
  579. data/vendor/v8/test/mjsunit/regress/regress-2226.js +36 -0
  580. data/vendor/v8/test/mjsunit/regress/regress-2234.js +41 -0
  581. data/vendor/v8/test/mjsunit/regress/regress-2243.js +31 -0
  582. data/vendor/v8/test/mjsunit/regress/regress-2249.js +33 -0
  583. data/vendor/v8/test/mjsunit/regress/regress-2250.js +68 -0
  584. data/vendor/v8/test/mjsunit/regress/regress-2261.js +113 -0
  585. data/vendor/v8/test/mjsunit/regress/regress-2263.js +30 -0
  586. data/vendor/v8/test/mjsunit/regress/regress-2284.js +32 -0
  587. data/vendor/v8/test/mjsunit/regress/regress-2285.js +32 -0
  588. data/vendor/v8/test/mjsunit/regress/regress-2286.js +32 -0
  589. data/vendor/v8/test/mjsunit/regress/regress-2289.js +34 -0
  590. data/vendor/v8/test/mjsunit/regress/regress-2291.js +36 -0
  591. data/vendor/v8/test/mjsunit/regress/regress-2294.js +70 -0
  592. data/vendor/v8/test/mjsunit/regress/regress-2296.js +40 -0
  593. data/vendor/v8/test/mjsunit/regress/regress-2315.js +40 -0
  594. data/vendor/v8/test/mjsunit/regress/regress-2318.js +66 -0
  595. data/vendor/v8/test/mjsunit/regress/regress-2322.js +36 -0
  596. data/vendor/v8/test/mjsunit/regress/regress-2326.js +54 -0
  597. data/vendor/v8/test/mjsunit/regress/regress-2336.js +53 -0
  598. data/vendor/v8/test/mjsunit/regress/regress-2339.js +59 -0
  599. data/vendor/v8/test/mjsunit/regress/regress-2346.js +123 -0
  600. data/vendor/v8/test/mjsunit/regress/regress-2373.js +29 -0
  601. data/vendor/v8/test/mjsunit/regress/regress-2374.js +33 -0
  602. data/vendor/v8/test/mjsunit/regress/regress-2398.js +41 -0
  603. data/vendor/v8/test/mjsunit/regress/regress-2410.js +36 -0
  604. data/vendor/v8/test/mjsunit/regress/regress-2416.js +75 -0
  605. data/vendor/v8/test/mjsunit/regress/regress-2419.js +37 -0
  606. data/vendor/v8/test/mjsunit/regress/regress-2433.js +36 -0
  607. data/vendor/v8/test/mjsunit/regress/regress-2437.js +156 -0
  608. data/vendor/v8/test/mjsunit/regress/regress-2438.js +52 -0
  609. data/vendor/v8/test/mjsunit/regress/regress-2443.js +129 -0
  610. data/vendor/v8/test/mjsunit/regress/regress-2444.js +120 -0
  611. data/vendor/v8/test/mjsunit/regress/regress-2489.js +50 -0
  612. data/vendor/v8/test/mjsunit/regress/regress-2499.js +40 -0
  613. data/vendor/v8/test/mjsunit/regress/regress-334.js +1 -1
  614. data/vendor/v8/test/mjsunit/regress/regress-492.js +39 -1
  615. data/vendor/v8/test/mjsunit/regress/regress-builtin-array-op.js +38 -0
  616. data/vendor/v8/test/mjsunit/regress/regress-cnlt-elements.js +43 -0
  617. data/vendor/v8/test/mjsunit/regress/regress-cnlt-enum-indices.js +45 -0
  618. data/vendor/v8/test/mjsunit/regress/regress-cntl-descriptors-enum.js +46 -0
  619. data/vendor/v8/test/mjsunit/regress/regress-convert-enum.js +60 -0
  620. data/vendor/v8/test/mjsunit/regress/regress-convert-enum2.js +46 -0
  621. data/vendor/v8/test/mjsunit/regress/regress-convert-transition.js +40 -0
  622. data/vendor/v8/test/mjsunit/regress/regress-crbug-119926.js +3 -1
  623. data/vendor/v8/test/mjsunit/regress/regress-crbug-125148.js +90 -0
  624. data/vendor/v8/test/mjsunit/regress/regress-crbug-134055.js +63 -0
  625. data/vendor/v8/test/mjsunit/regress/regress-crbug-134609.js +59 -0
  626. data/vendor/v8/test/mjsunit/regress/regress-crbug-135008.js +45 -0
  627. data/vendor/v8/test/mjsunit/regress/regress-crbug-135066.js +55 -0
  628. data/vendor/v8/test/mjsunit/regress/regress-crbug-137689.js +47 -0
  629. data/vendor/v8/test/mjsunit/regress/regress-crbug-138887.js +48 -0
  630. data/vendor/v8/test/mjsunit/regress/regress-crbug-140083.js +44 -0
  631. data/vendor/v8/test/mjsunit/regress/regress-crbug-142087.js +38 -0
  632. data/vendor/v8/test/mjsunit/regress/regress-crbug-142218.js +44 -0
  633. data/vendor/v8/test/mjsunit/regress/regress-crbug-145961.js +39 -0
  634. data/vendor/v8/test/mjsunit/regress/regress-crbug-146910.js +33 -0
  635. data/vendor/v8/test/mjsunit/regress/regress-crbug-147475.js +48 -0
  636. data/vendor/v8/test/mjsunit/regress/regress-crbug-148376.js +35 -0
  637. data/vendor/v8/test/mjsunit/regress/regress-crbug-150545.js +53 -0
  638. data/vendor/v8/test/mjsunit/regress/regress-crbug-150729.js +39 -0
  639. data/vendor/v8/test/mjsunit/regress/regress-crbug-157019.js +54 -0
  640. data/vendor/v8/test/mjsunit/regress/regress-crbug-157520.js +38 -0
  641. data/vendor/v8/test/mjsunit/regress/regress-crbug-158185.js +39 -0
  642. data/vendor/v8/test/mjsunit/regress/regress-crbug-160010.js +35 -0
  643. data/vendor/v8/test/mjsunit/regress/regress-crbug-162085.js +71 -0
  644. data/vendor/v8/test/mjsunit/regress/regress-crbug-168545.js +34 -0
  645. data/vendor/v8/test/mjsunit/regress/regress-crbug-170856.js +33 -0
  646. data/vendor/v8/test/mjsunit/regress/regress-crbug-172345.js +34 -0
  647. data/vendor/v8/test/mjsunit/regress/regress-crbug-173974.js +36 -0
  648. data/vendor/v8/test/mjsunit/regress/regress-crbug-18639.js +9 -5
  649. data/vendor/v8/test/mjsunit/regress/regress-debug-code-recompilation.js +2 -1
  650. data/vendor/v8/test/mjsunit/regress/regress-deep-proto.js +45 -0
  651. data/vendor/v8/test/mjsunit/regress/regress-delete-empty-double.js +40 -0
  652. data/vendor/v8/test/mjsunit/regress/regress-iteration-order.js +42 -0
  653. data/vendor/v8/test/mjsunit/regress/regress-json-stringify-gc.js +41 -0
  654. data/vendor/v8/test/mjsunit/regress/regress-latin-1.js +78 -0
  655. data/vendor/v8/test/mjsunit/regress/regress-load-elements.js +49 -0
  656. data/vendor/v8/test/mjsunit/regress/regress-observe-empty-double-array.js +38 -0
  657. data/vendor/v8/test/mjsunit/regress/regress-undefined-store-keyed-fast-element.js +37 -0
  658. data/vendor/v8/test/mjsunit/shift-for-integer-div.js +59 -0
  659. data/vendor/v8/test/mjsunit/stack-traces-gc.js +119 -0
  660. data/vendor/v8/test/mjsunit/stack-traces-overflow.js +122 -0
  661. data/vendor/v8/test/mjsunit/stack-traces.js +39 -1
  662. data/vendor/v8/test/mjsunit/str-to-num.js +7 -2
  663. data/vendor/v8/test/mjsunit/strict-mode.js +36 -11
  664. data/vendor/v8/test/mjsunit/string-charcodeat.js +3 -0
  665. data/vendor/v8/test/mjsunit/string-natives.js +72 -0
  666. data/vendor/v8/test/mjsunit/string-split.js +17 -0
  667. data/vendor/v8/test/mjsunit/testcfg.py +76 -6
  668. data/vendor/v8/test/mjsunit/tools/tickprocessor.js +4 -1
  669. data/vendor/v8/test/mjsunit/try-finally-continue.js +72 -0
  670. data/vendor/v8/test/mjsunit/typed-array-slice.js +61 -0
  671. data/vendor/v8/test/mjsunit/unbox-double-arrays.js +2 -0
  672. data/vendor/v8/test/mjsunit/uri.js +12 -0
  673. data/vendor/v8/test/mjsunit/with-readonly.js +4 -2
  674. data/vendor/v8/test/mozilla/mozilla.status +19 -113
  675. data/vendor/v8/test/mozilla/testcfg.py +122 -3
  676. data/vendor/v8/test/preparser/preparser.status +5 -0
  677. data/vendor/v8/test/preparser/strict-identifiers.pyt +1 -1
  678. data/vendor/v8/test/preparser/testcfg.py +101 -5
  679. data/vendor/v8/test/sputnik/sputnik.status +1 -1
  680. data/vendor/v8/test/sputnik/testcfg.py +5 -0
  681. data/vendor/v8/test/test262/README +2 -2
  682. data/vendor/v8/test/test262/test262.status +13 -36
  683. data/vendor/v8/test/test262/testcfg.py +102 -8
  684. data/vendor/v8/tools/android-build.sh +0 -0
  685. data/vendor/v8/tools/android-ll-prof.sh +69 -0
  686. data/vendor/v8/tools/android-run.py +109 -0
  687. data/vendor/v8/tools/android-sync.sh +105 -0
  688. data/vendor/v8/tools/bash-completion.sh +0 -0
  689. data/vendor/v8/tools/check-static-initializers.sh +0 -0
  690. data/vendor/v8/tools/common-includes.sh +15 -22
  691. data/vendor/v8/tools/disasm.py +4 -4
  692. data/vendor/v8/tools/fuzz-harness.sh +0 -0
  693. data/vendor/v8/tools/gen-postmortem-metadata.py +6 -8
  694. data/vendor/v8/tools/grokdump.py +404 -129
  695. data/vendor/v8/tools/gyp/v8.gyp +105 -43
  696. data/vendor/v8/tools/linux-tick-processor +5 -5
  697. data/vendor/v8/tools/ll_prof.py +75 -15
  698. data/vendor/v8/tools/merge-to-branch.sh +2 -2
  699. data/vendor/v8/tools/plot-timer-events +70 -0
  700. data/vendor/v8/tools/plot-timer-events.js +510 -0
  701. data/vendor/v8/tools/presubmit.py +1 -0
  702. data/vendor/v8/tools/push-to-trunk.sh +14 -4
  703. data/vendor/v8/tools/run-llprof.sh +69 -0
  704. data/vendor/v8/tools/run-tests.py +372 -0
  705. data/vendor/v8/tools/run-valgrind.py +1 -1
  706. data/vendor/v8/tools/status-file-converter.py +39 -0
  707. data/vendor/v8/tools/test-server.py +224 -0
  708. data/vendor/v8/tools/test-wrapper-gypbuild.py +13 -16
  709. data/vendor/v8/tools/test.py +10 -19
  710. data/vendor/v8/tools/testrunner/README +174 -0
  711. data/vendor/v8/tools/testrunner/__init__.py +26 -0
  712. data/vendor/v8/tools/testrunner/local/__init__.py +26 -0
  713. data/vendor/v8/tools/testrunner/local/commands.py +153 -0
  714. data/vendor/v8/tools/testrunner/local/execution.py +182 -0
  715. data/vendor/v8/tools/testrunner/local/old_statusfile.py +460 -0
  716. data/vendor/v8/tools/testrunner/local/progress.py +238 -0
  717. data/vendor/v8/tools/testrunner/local/statusfile.py +145 -0
  718. data/vendor/v8/tools/testrunner/local/testsuite.py +187 -0
  719. data/vendor/v8/tools/testrunner/local/utils.py +108 -0
  720. data/vendor/v8/tools/testrunner/local/verbose.py +99 -0
  721. data/vendor/v8/tools/testrunner/network/__init__.py +26 -0
  722. data/vendor/v8/tools/testrunner/network/distro.py +90 -0
  723. data/vendor/v8/tools/testrunner/network/endpoint.py +124 -0
  724. data/vendor/v8/tools/testrunner/network/network_execution.py +253 -0
  725. data/vendor/v8/tools/testrunner/network/perfdata.py +120 -0
  726. data/vendor/v8/tools/testrunner/objects/__init__.py +26 -0
  727. data/vendor/v8/tools/testrunner/objects/context.py +50 -0
  728. data/vendor/v8/tools/testrunner/objects/output.py +60 -0
  729. data/vendor/v8/tools/testrunner/objects/peer.py +80 -0
  730. data/vendor/v8/tools/testrunner/objects/testcase.py +83 -0
  731. data/vendor/v8/tools/testrunner/objects/workpacket.py +90 -0
  732. data/vendor/v8/tools/testrunner/server/__init__.py +26 -0
  733. data/vendor/v8/tools/testrunner/server/compression.py +111 -0
  734. data/vendor/v8/tools/testrunner/server/constants.py +51 -0
  735. data/vendor/v8/tools/testrunner/server/daemon.py +147 -0
  736. data/vendor/v8/tools/testrunner/server/local_handler.py +119 -0
  737. data/vendor/v8/tools/testrunner/server/main.py +245 -0
  738. data/vendor/v8/tools/testrunner/server/presence_handler.py +120 -0
  739. data/vendor/v8/tools/testrunner/server/signatures.py +63 -0
  740. data/vendor/v8/tools/testrunner/server/status_handler.py +112 -0
  741. data/vendor/v8/tools/testrunner/server/work_handler.py +150 -0
  742. data/vendor/v8/tools/tick-processor.html +168 -0
  743. data/vendor/v8/tools/tickprocessor-driver.js +5 -3
  744. data/vendor/v8/tools/tickprocessor.js +58 -15
  745. metadata +534 -30
  746. data/patches/add-freebsd9-and-freebsd10-to-gyp-GetFlavor.patch +0 -11
  747. data/patches/do-not-imply-vfp3-and-armv7.patch +0 -44
  748. data/patches/fPIC-on-x64.patch +0 -14
  749. data/vendor/v8/src/liveobjectlist-inl.h +0 -126
  750. data/vendor/v8/src/liveobjectlist.cc +0 -2631
  751. data/vendor/v8/src/liveobjectlist.h +0 -319
  752. data/vendor/v8/test/mjsunit/mul-exhaustive.js +0 -4629
  753. data/vendor/v8/test/mjsunit/numops-fuzz.js +0 -4609
  754. data/vendor/v8/test/mjsunit/regress/regress-1969.js +0 -5045
@@ -45,6 +45,7 @@ namespace internal {
45
45
  // Forward declarations.
46
46
  class HBasicBlock;
47
47
  class HEnvironment;
48
+ class HInferRepresentation;
48
49
  class HInstruction;
49
50
  class HLoopInformation;
50
51
  class HValue;
@@ -53,6 +54,7 @@ class LChunkBuilder;
53
54
 
54
55
 
55
56
  #define HYDROGEN_ABSTRACT_INSTRUCTION_LIST(V) \
57
+ V(BinaryOperation) \
56
58
  V(BitwiseBinaryOperation) \
57
59
  V(ControlInstruction) \
58
60
  V(Instruction) \
@@ -62,6 +64,7 @@ class LChunkBuilder;
62
64
  V(AbnormalExit) \
63
65
  V(AccessArgumentsAt) \
64
66
  V(Add) \
67
+ V(Allocate) \
65
68
  V(AllocateObject) \
66
69
  V(ApplyArguments) \
67
70
  V(ArgumentsElements) \
@@ -102,6 +105,7 @@ class LChunkBuilder;
102
105
  V(DeleteProperty) \
103
106
  V(Deoptimize) \
104
107
  V(Div) \
108
+ V(DummyUse) \
105
109
  V(ElementsKind) \
106
110
  V(EnterInlined) \
107
111
  V(FastLiteral) \
@@ -124,7 +128,6 @@ class LChunkBuilder;
124
128
  V(IsStringAndBranch) \
125
129
  V(IsSmiAndBranch) \
126
130
  V(IsUndetectableAndBranch) \
127
- V(StringCompareAndBranch) \
128
131
  V(JSArrayLength) \
129
132
  V(LeaveInlined) \
130
133
  V(LoadContextSlot) \
@@ -133,14 +136,14 @@ class LChunkBuilder;
133
136
  V(LoadFunctionPrototype) \
134
137
  V(LoadGlobalCell) \
135
138
  V(LoadGlobalGeneric) \
136
- V(LoadKeyedFastDoubleElement) \
137
- V(LoadKeyedFastElement) \
139
+ V(LoadKeyed) \
138
140
  V(LoadKeyedGeneric) \
139
- V(LoadKeyedSpecializedArrayElement) \
140
141
  V(LoadNamedField) \
141
142
  V(LoadNamedFieldPolymorphic) \
142
143
  V(LoadNamedGeneric) \
144
+ V(MapEnumLength) \
143
145
  V(MathFloorOfDiv) \
146
+ V(MathMinMax) \
144
147
  V(Mod) \
145
148
  V(Mul) \
146
149
  V(ObjectLiteral) \
@@ -152,7 +155,9 @@ class LChunkBuilder;
152
155
  V(Random) \
153
156
  V(RegExpLiteral) \
154
157
  V(Return) \
158
+ V(Ror) \
155
159
  V(Sar) \
160
+ V(SeqStringSetChar) \
156
161
  V(Shl) \
157
162
  V(Shr) \
158
163
  V(Simulate) \
@@ -161,21 +166,21 @@ class LChunkBuilder;
161
166
  V(StoreContextSlot) \
162
167
  V(StoreGlobalCell) \
163
168
  V(StoreGlobalGeneric) \
164
- V(StoreKeyedFastDoubleElement) \
165
- V(StoreKeyedFastElement) \
169
+ V(StoreKeyed) \
166
170
  V(StoreKeyedGeneric) \
167
- V(StoreKeyedSpecializedArrayElement) \
168
171
  V(StoreNamedField) \
169
172
  V(StoreNamedGeneric) \
170
173
  V(StringAdd) \
171
174
  V(StringCharCodeAt) \
172
175
  V(StringCharFromCode) \
176
+ V(StringCompareAndBranch) \
173
177
  V(StringLength) \
174
178
  V(Sub) \
175
179
  V(ThisFunction) \
176
180
  V(Throw) \
177
181
  V(ToFastProperties) \
178
182
  V(TransitionElementsKind) \
183
+ V(TrapAllocationMemento) \
179
184
  V(Typeof) \
180
185
  V(TypeofIsAndBranch) \
181
186
  V(UnaryMathOperation) \
@@ -190,6 +195,7 @@ class LChunkBuilder;
190
195
  V(WrapReceiver)
191
196
 
192
197
  #define GVN_TRACKED_FLAG_LIST(V) \
198
+ V(Maps) \
193
199
  V(NewSpacePromotion)
194
200
 
195
201
  #define GVN_UNTRACKED_FLAG_LIST(V) \
@@ -202,7 +208,6 @@ class LChunkBuilder;
202
208
  V(DoubleArrayElements) \
203
209
  V(SpecializedArrayElements) \
204
210
  V(GlobalVars) \
205
- V(Maps) \
206
211
  V(ArrayLengths) \
207
212
  V(ContextSlots) \
208
213
  V(OsrEntries)
@@ -224,6 +229,16 @@ class LChunkBuilder;
224
229
  virtual Opcode opcode() const { return HValue::k##type; }
225
230
 
226
231
 
232
+ #ifdef DEBUG
233
+ #define ASSERT_ALLOCATION_DISABLED do { \
234
+ OptimizingCompilerThread* thread = \
235
+ ISOLATE->optimizing_compiler_thread(); \
236
+ ASSERT(thread->IsOptimizerThread() || !HEAP->IsAllocationAllowed()); \
237
+ } while (0)
238
+ #else
239
+ #define ASSERT_ALLOCATION_DISABLED do {} while (0)
240
+ #endif
241
+
227
242
  class Range: public ZoneObject {
228
243
  public:
229
244
  Range()
@@ -276,6 +291,8 @@ class Range: public ZoneObject {
276
291
 
277
292
  void Intersect(Range* other);
278
293
  void Union(Range* other);
294
+ void CombinedMax(Range* other);
295
+ void CombinedMin(Range* other);
279
296
 
280
297
  void AddConstant(int32_t value);
281
298
  void Sar(int32_t value);
@@ -296,9 +313,9 @@ class Representation {
296
313
  public:
297
314
  enum Kind {
298
315
  kNone,
299
- kTagged,
300
- kDouble,
301
316
  kInteger32,
317
+ kDouble,
318
+ kTagged,
302
319
  kExternal,
303
320
  kNumRepresentations
304
321
  };
@@ -311,10 +328,18 @@ class Representation {
311
328
  static Representation Double() { return Representation(kDouble); }
312
329
  static Representation External() { return Representation(kExternal); }
313
330
 
331
+ static Representation FromKind(Kind kind) { return Representation(kind); }
332
+
314
333
  bool Equals(const Representation& other) {
315
334
  return kind_ == other.kind_;
316
335
  }
317
336
 
337
+ bool is_more_general_than(const Representation& other) {
338
+ ASSERT(kind_ != kExternal);
339
+ ASSERT(other.kind_ != kExternal);
340
+ return kind_ > other.kind_;
341
+ }
342
+
318
343
  Kind kind() const { return static_cast<Kind>(kind_); }
319
344
  bool IsNone() const { return kind_ == kNone; }
320
345
  bool IsTagged() const { return kind_ == kTagged; }
@@ -549,7 +574,17 @@ class HValue: public ZoneObject {
549
574
  kIsArguments,
550
575
  kTruncatingToInt32,
551
576
  kIsDead,
552
- kLastFlag = kIsDead
577
+ // Instructions that are allowed to produce full range unsigned integer
578
+ // values are marked with kUint32 flag. If arithmetic shift or a load from
579
+ // EXTERNAL_UNSIGNED_INT_ELEMENTS array is not marked with this flag
580
+ // it will deoptimize if result does not fit into signed integer range.
581
+ // HGraph::ComputeSafeUint32Operations is responsible for setting this
582
+ // flag.
583
+ kUint32,
584
+ // This flag is set to true after the SetupInformativeDefinitions() pass
585
+ // has processed this instruction.
586
+ kIDefsProcessingDone,
587
+ kLastFlag = kIDefsProcessingDone
553
588
  };
554
589
 
555
590
  STATIC_ASSERT(kLastFlag < kBitsPerInt);
@@ -610,13 +645,15 @@ class HValue: public ZoneObject {
610
645
  virtual bool EmitAtUses() { return false; }
611
646
  Representation representation() const { return representation_; }
612
647
  void ChangeRepresentation(Representation r) {
613
- // Representation was already set and is allowed to be changed.
614
- ASSERT(!r.IsNone());
615
648
  ASSERT(CheckFlag(kFlexibleRepresentation));
616
649
  RepresentationChanged(r);
617
650
  representation_ = r;
651
+ if (r.IsTagged()) {
652
+ // Tagged is the bottom of the lattice, don't go any further.
653
+ ClearFlag(kFlexibleRepresentation);
654
+ }
618
655
  }
619
- void AssumeRepresentation(Representation r);
656
+ virtual void AssumeRepresentation(Representation r);
620
657
 
621
658
  virtual bool IsConvertibleToInteger() const { return true; }
622
659
 
@@ -641,11 +678,45 @@ class HValue: public ZoneObject {
641
678
  return NULL;
642
679
  }
643
680
 
681
+ // There are HInstructions that do not really change a value, they
682
+ // only add pieces of information to it (like bounds checks, map checks,
683
+ // smi checks...).
684
+ // We call these instructions "informative definitions", or "iDef".
685
+ // One of the iDef operands is special because it is the value that is
686
+ // "transferred" to the output, we call it the "redefined operand".
687
+ // If an HValue is an iDef it must override RedefinedOperandIndex() so that
688
+ // it does not return kNoRedefinedOperand;
689
+ static const int kNoRedefinedOperand = -1;
690
+ virtual int RedefinedOperandIndex() { return kNoRedefinedOperand; }
691
+ bool IsInformativeDefinition() {
692
+ return RedefinedOperandIndex() != kNoRedefinedOperand;
693
+ }
694
+ HValue* RedefinedOperand() {
695
+ return IsInformativeDefinition() ? OperandAt(RedefinedOperandIndex())
696
+ : NULL;
697
+ }
698
+
699
+ // This method must always return the original HValue SSA definition
700
+ // (regardless of any iDef of this value).
701
+ HValue* ActualValue() {
702
+ return IsInformativeDefinition() ? RedefinedOperand()->ActualValue()
703
+ : this;
704
+ }
705
+
706
+ virtual void AddInformativeDefinitions() {}
707
+
708
+ void UpdateRedefinedUsesWhileSettingUpInformativeDefinitions() {
709
+ UpdateRedefinedUsesInner<TestDominanceUsingProcessedFlag>();
710
+ }
711
+ void UpdateRedefinedUses() {
712
+ UpdateRedefinedUsesInner<Dominates>();
713
+ }
714
+
644
715
  bool IsDefinedAfter(HBasicBlock* other) const;
645
716
 
646
717
  // Operands.
647
718
  virtual int OperandCount() = 0;
648
- virtual HValue* OperandAt(int index) = 0;
719
+ virtual HValue* OperandAt(int index) const = 0;
649
720
  void SetOperandAt(int index, HValue* value);
650
721
 
651
722
  void DeleteAndReplaceWith(HValue* other);
@@ -714,11 +785,11 @@ class HValue: public ZoneObject {
714
785
  void ComputeInitialRange(Zone* zone);
715
786
 
716
787
  // Representation helpers.
717
- virtual Representation RequiredInputRepresentation(int index) = 0;
718
-
719
- virtual Representation InferredRepresentation() {
720
- return representation();
788
+ virtual Representation observed_input_representation(int index) {
789
+ return Representation::None();
721
790
  }
791
+ virtual Representation RequiredInputRepresentation(int index) = 0;
792
+ virtual void InferRepresentation(HInferRepresentation* h_infer);
722
793
 
723
794
  // This gives the instruction an opportunity to replace itself with an
724
795
  // instruction that does the same in some better way. To replace an
@@ -738,6 +809,14 @@ class HValue: public ZoneObject {
738
809
 
739
810
  const char* Mnemonic() const;
740
811
 
812
+ // Type information helpers.
813
+ bool HasMonomorphicJSObjectType();
814
+
815
+ // TODO(mstarzinger): For now instructions can override this function to
816
+ // specify statically known types, once HType can convey more information
817
+ // it should be based on the HType.
818
+ virtual Handle<Map> GetMonomorphicJSObjectMap() { return Handle<Map>(); }
819
+
741
820
  // Updated the inferred type of this instruction and returns true if
742
821
  // it has changed.
743
822
  bool UpdateInferredType();
@@ -751,6 +830,10 @@ class HValue: public ZoneObject {
751
830
  UNREACHABLE();
752
831
  }
753
832
 
833
+ bool IsDead() const {
834
+ return HasNoUses() && !HasObservableSideEffects() && IsDeletable();
835
+ }
836
+
754
837
  #ifdef DEBUG
755
838
  virtual void Verify() = 0;
756
839
  #endif
@@ -762,7 +845,18 @@ class HValue: public ZoneObject {
762
845
  UNREACHABLE();
763
846
  return false;
764
847
  }
848
+
849
+ virtual Representation RepresentationFromInputs() {
850
+ return representation();
851
+ }
852
+ Representation RepresentationFromUses();
853
+ virtual void UpdateRepresentation(Representation new_rep,
854
+ HInferRepresentation* h_infer,
855
+ const char* reason);
856
+ void AddDependantsToWorklist(HInferRepresentation* h_infer);
857
+
765
858
  virtual void RepresentationChanged(Representation to) { }
859
+
766
860
  virtual Range* InferRange(Zone* zone);
767
861
  virtual void DeleteFromGraph() = 0;
768
862
  virtual void InternalSetOperandAt(int index, HValue* value) = 0;
@@ -772,11 +866,40 @@ class HValue: public ZoneObject {
772
866
  }
773
867
 
774
868
  void set_representation(Representation r) {
775
- // Representation is set-once.
776
869
  ASSERT(representation_.IsNone() && !r.IsNone());
777
870
  representation_ = r;
778
871
  }
779
872
 
873
+ // Signature of a function testing if a HValue properly dominates another.
874
+ typedef bool (*DominanceTest)(HValue*, HValue*);
875
+
876
+ // Simple implementation of DominanceTest implemented walking the chain
877
+ // of Hinstructions (used in UpdateRedefinedUsesInner).
878
+ static bool Dominates(HValue* dominator, HValue* dominated);
879
+
880
+ // A fast implementation of DominanceTest that works only for the
881
+ // "current" instruction in the SetupInformativeDefinitions() phase.
882
+ // During that phase we use a flag to mark processed instructions, and by
883
+ // checking the flag we can quickly test if an instruction comes before or
884
+ // after the "current" one.
885
+ static bool TestDominanceUsingProcessedFlag(HValue* dominator,
886
+ HValue* dominated);
887
+
888
+ // If we are redefining an operand, update all its dominated uses (the
889
+ // function that checks if a use is dominated is the template argument).
890
+ template<DominanceTest TestDominance>
891
+ void UpdateRedefinedUsesInner() {
892
+ HValue* input = RedefinedOperand();
893
+ if (input != NULL) {
894
+ for (HUseIterator uses = input->uses(); !uses.Done(); uses.Advance()) {
895
+ HValue* use = uses.value();
896
+ if (TestDominance(this, use)) {
897
+ use->SetOperandAt(uses.index(), this);
898
+ }
899
+ }
900
+ }
901
+ }
902
+
780
903
  static GVNFlagSet AllDependsOnFlagSet() {
781
904
  GVNFlagSet result;
782
905
  // Create changes mask.
@@ -835,6 +958,8 @@ class HValue: public ZoneObject {
835
958
  GVNFlagSet gvn_flags_;
836
959
 
837
960
  private:
961
+ virtual bool IsDeletable() const { return false; }
962
+
838
963
  DISALLOW_COPY_AND_ASSIGN(HValue);
839
964
  };
840
965
 
@@ -852,9 +977,14 @@ class HInstruction: public HValue {
852
977
  void InsertBefore(HInstruction* next);
853
978
  void InsertAfter(HInstruction* previous);
854
979
 
980
+ // The position is a write-once variable.
855
981
  int position() const { return position_; }
856
982
  bool has_position() const { return position_ != RelocInfo::kNoPosition; }
857
- void set_position(int position) { position_ = position; }
983
+ void set_position(int position) {
984
+ ASSERT(!has_position());
985
+ ASSERT(position != RelocInfo::kNoPosition);
986
+ position_ = position;
987
+ }
858
988
 
859
989
  bool CanTruncateToInt32() const { return CheckFlag(kTruncatingToInt32); }
860
990
 
@@ -898,7 +1028,7 @@ template<int V>
898
1028
  class HTemplateInstruction : public HInstruction {
899
1029
  public:
900
1030
  int OperandCount() { return V; }
901
- HValue* OperandAt(int i) { return inputs_[i]; }
1031
+ HValue* OperandAt(int i) const { return inputs_[i]; }
902
1032
 
903
1033
  protected:
904
1034
  void InternalSetOperandAt(int i, HValue* value) { inputs_[i] = value; }
@@ -950,7 +1080,7 @@ class HTemplateControlInstruction: public HControlInstruction {
950
1080
  void SetSuccessorAt(int i, HBasicBlock* block) { successors_[i] = block; }
951
1081
 
952
1082
  int OperandCount() { return V; }
953
- HValue* OperandAt(int i) { return inputs_[i]; }
1083
+ HValue* OperandAt(int i) const { return inputs_[i]; }
954
1084
 
955
1085
 
956
1086
  protected:
@@ -972,6 +1102,28 @@ class HBlockEntry: public HTemplateInstruction<0> {
972
1102
  };
973
1103
 
974
1104
 
1105
+ class HDummyUse: public HTemplateInstruction<1> {
1106
+ public:
1107
+ explicit HDummyUse(HValue* value) {
1108
+ SetOperandAt(0, value);
1109
+ // Pretend to be a Smi so that the HChange instructions inserted
1110
+ // before any use generate as little code as possible.
1111
+ set_representation(Representation::Tagged());
1112
+ set_type(HType::Smi());
1113
+ }
1114
+
1115
+ HValue* value() { return OperandAt(0); }
1116
+
1117
+ virtual Representation RequiredInputRepresentation(int index) {
1118
+ return Representation::None();
1119
+ }
1120
+
1121
+ virtual void PrintDataTo(StringStream* stream);
1122
+
1123
+ DECLARE_CONCRETE_INSTRUCTION(DummyUse);
1124
+ };
1125
+
1126
+
975
1127
  // We insert soft-deoptimize when we hit code with unknown typefeedback,
976
1128
  // so that we get a chance of re-optimizing with useful typefeedback.
977
1129
  // HSoftDeoptimize does not end a basic block as opposed to HDeoptimize.
@@ -987,14 +1139,15 @@ class HSoftDeoptimize: public HTemplateInstruction<0> {
987
1139
 
988
1140
  class HDeoptimize: public HControlInstruction {
989
1141
  public:
990
- explicit HDeoptimize(int environment_length) : values_(environment_length) { }
1142
+ HDeoptimize(int environment_length, Zone* zone)
1143
+ : values_(environment_length, zone) { }
991
1144
 
992
1145
  virtual Representation RequiredInputRepresentation(int index) {
993
1146
  return Representation::None();
994
1147
  }
995
1148
 
996
1149
  virtual int OperandCount() { return values_.length(); }
997
- virtual HValue* OperandAt(int index) { return values_[index]; }
1150
+ virtual HValue* OperandAt(int index) const { return values_[index]; }
998
1151
  virtual void PrintDataTo(StringStream* stream);
999
1152
 
1000
1153
  virtual int SuccessorCount() { return 0; }
@@ -1006,8 +1159,8 @@ class HDeoptimize: public HControlInstruction {
1006
1159
  UNREACHABLE();
1007
1160
  }
1008
1161
 
1009
- void AddEnvironmentValue(HValue* value) {
1010
- values_.Add(NULL);
1162
+ void AddEnvironmentValue(HValue* value, Zone* zone) {
1163
+ values_.Add(NULL, zone);
1011
1164
  SetOperandAt(values_.length() - 1, value);
1012
1165
  }
1013
1166
 
@@ -1077,6 +1230,7 @@ class HBranch: public HUnaryControlInstruction {
1077
1230
  virtual Representation RequiredInputRepresentation(int index) {
1078
1231
  return Representation::None();
1079
1232
  }
1233
+ virtual Representation observed_input_representation(int index);
1080
1234
 
1081
1235
  ToBooleanStub::Types expected_input_types() const {
1082
1236
  return expected_input_types_;
@@ -1117,10 +1271,11 @@ class HCompareMap: public HUnaryControlInstruction {
1117
1271
  };
1118
1272
 
1119
1273
 
1120
- class HReturn: public HTemplateControlInstruction<0, 1> {
1274
+ class HReturn: public HTemplateControlInstruction<0, 2> {
1121
1275
  public:
1122
- explicit HReturn(HValue* value) {
1276
+ HReturn(HValue* value, HValue* context) {
1123
1277
  SetOperandAt(0, value);
1278
+ SetOperandAt(1, context);
1124
1279
  }
1125
1280
 
1126
1281
  virtual Representation RequiredInputRepresentation(int index) {
@@ -1130,6 +1285,7 @@ class HReturn: public HTemplateControlInstruction<0, 1> {
1130
1285
  virtual void PrintDataTo(StringStream* stream);
1131
1286
 
1132
1287
  HValue* value() { return OperandAt(0); }
1288
+ HValue* context() { return OperandAt(1); }
1133
1289
 
1134
1290
  DECLARE_CONCRETE_INSTRUCTION(Return)
1135
1291
  };
@@ -1155,7 +1311,7 @@ class HUnaryOperation: public HTemplateInstruction<1> {
1155
1311
  return reinterpret_cast<HUnaryOperation*>(value);
1156
1312
  }
1157
1313
 
1158
- HValue* value() { return OperandAt(0); }
1314
+ HValue* value() const { return OperandAt(0); }
1159
1315
  virtual void PrintDataTo(StringStream* stream);
1160
1316
  };
1161
1317
 
@@ -1206,6 +1362,8 @@ class HForceRepresentation: public HTemplateInstruction<1> {
1206
1362
  return representation(); // Same as the output representation.
1207
1363
  }
1208
1364
 
1365
+ virtual void PrintDataTo(StringStream* stream);
1366
+
1209
1367
  DECLARE_CONCRETE_INSTRUCTION(ForceRepresentation)
1210
1368
  };
1211
1369
 
@@ -1231,8 +1389,8 @@ class HChange: public HUnaryOperation {
1231
1389
  virtual HType CalculateInferredType();
1232
1390
  virtual HValue* Canonicalize();
1233
1391
 
1234
- Representation from() { return value()->representation(); }
1235
- Representation to() { return representation(); }
1392
+ Representation from() const { return value()->representation(); }
1393
+ Representation to() const { return representation(); }
1236
1394
  bool deoptimize_on_undefined() const {
1237
1395
  return CheckFlag(kDeoptimizeOnUndefined);
1238
1396
  }
@@ -1251,6 +1409,11 @@ class HChange: public HUnaryOperation {
1251
1409
 
1252
1410
  protected:
1253
1411
  virtual bool DataEquals(HValue* other) { return true; }
1412
+
1413
+ private:
1414
+ virtual bool IsDeletable() const {
1415
+ return !from().IsTagged() || value()->type().IsSmi();
1416
+ }
1254
1417
  };
1255
1418
 
1256
1419
 
@@ -1270,23 +1433,37 @@ class HClampToUint8: public HUnaryOperation {
1270
1433
 
1271
1434
  protected:
1272
1435
  virtual bool DataEquals(HValue* other) { return true; }
1436
+
1437
+ private:
1438
+ virtual bool IsDeletable() const { return true; }
1439
+ };
1440
+
1441
+
1442
+ enum RemovableSimulate {
1443
+ REMOVABLE_SIMULATE,
1444
+ FIXED_SIMULATE
1273
1445
  };
1274
1446
 
1275
1447
 
1276
1448
  class HSimulate: public HInstruction {
1277
1449
  public:
1278
- HSimulate(int ast_id, int pop_count)
1450
+ HSimulate(BailoutId ast_id,
1451
+ int pop_count,
1452
+ Zone* zone,
1453
+ RemovableSimulate removable)
1279
1454
  : ast_id_(ast_id),
1280
1455
  pop_count_(pop_count),
1281
- values_(2),
1282
- assigned_indexes_(2) {}
1456
+ values_(2, zone),
1457
+ assigned_indexes_(2, zone),
1458
+ zone_(zone),
1459
+ removable_(removable) {}
1283
1460
  virtual ~HSimulate() {}
1284
1461
 
1285
1462
  virtual void PrintDataTo(StringStream* stream);
1286
1463
 
1287
- bool HasAstId() const { return ast_id_ != AstNode::kNoNumber; }
1288
- int ast_id() const { return ast_id_; }
1289
- void set_ast_id(int id) {
1464
+ bool HasAstId() const { return !ast_id_.IsNone(); }
1465
+ BailoutId ast_id() const { return ast_id_; }
1466
+ void set_ast_id(BailoutId id) {
1290
1467
  ASSERT(!HasAstId());
1291
1468
  ast_id_ = id;
1292
1469
  }
@@ -1307,12 +1484,15 @@ class HSimulate: public HInstruction {
1307
1484
  AddValue(kNoIndex, value);
1308
1485
  }
1309
1486
  virtual int OperandCount() { return values_.length(); }
1310
- virtual HValue* OperandAt(int index) { return values_[index]; }
1487
+ virtual HValue* OperandAt(int index) const { return values_[index]; }
1311
1488
 
1312
1489
  virtual Representation RequiredInputRepresentation(int index) {
1313
1490
  return Representation::None();
1314
1491
  }
1315
1492
 
1493
+ void MergeInto(HSimulate* other);
1494
+ bool is_candidate_for_removal() { return removable_ == REMOVABLE_SIMULATE; }
1495
+
1316
1496
  DECLARE_CONCRETE_INSTRUCTION(Simulate)
1317
1497
 
1318
1498
  #ifdef DEBUG
@@ -1327,17 +1507,19 @@ class HSimulate: public HInstruction {
1327
1507
  private:
1328
1508
  static const int kNoIndex = -1;
1329
1509
  void AddValue(int index, HValue* value) {
1330
- assigned_indexes_.Add(index);
1510
+ assigned_indexes_.Add(index, zone_);
1331
1511
  // Resize the list of pushed values.
1332
- values_.Add(NULL);
1512
+ values_.Add(NULL, zone_);
1333
1513
  // Set the operand through the base method in HValue to make sure that the
1334
1514
  // use lists are correctly updated.
1335
1515
  SetOperandAt(values_.length() - 1, value);
1336
1516
  }
1337
- int ast_id_;
1517
+ BailoutId ast_id_;
1338
1518
  int pop_count_;
1339
1519
  ZoneList<HValue*> values_;
1340
1520
  ZoneList<int> assigned_indexes_;
1521
+ Zone* zone_;
1522
+ RemovableSimulate removable_;
1341
1523
  };
1342
1524
 
1343
1525
 
@@ -1377,31 +1559,43 @@ class HStackCheck: public HTemplateInstruction<1> {
1377
1559
  };
1378
1560
 
1379
1561
 
1562
+ enum InliningKind {
1563
+ NORMAL_RETURN, // Normal function/method call and return.
1564
+ DROP_EXTRA_ON_RETURN, // Drop an extra value from the environment on return.
1565
+ CONSTRUCT_CALL_RETURN, // Either use allocated receiver or return value.
1566
+ GETTER_CALL_RETURN, // Returning from a getter, need to restore context.
1567
+ SETTER_CALL_RETURN // Use the RHS of the assignment as the return value.
1568
+ };
1569
+
1570
+
1380
1571
  class HEnterInlined: public HTemplateInstruction<0> {
1381
1572
  public:
1382
1573
  HEnterInlined(Handle<JSFunction> closure,
1383
1574
  int arguments_count,
1384
1575
  FunctionLiteral* function,
1385
- CallKind call_kind,
1386
- bool is_construct,
1576
+ InliningKind inlining_kind,
1387
1577
  Variable* arguments_var,
1388
- ZoneList<HValue*>* arguments_values)
1578
+ ZoneList<HValue*>* arguments_values,
1579
+ bool undefined_receiver)
1389
1580
  : closure_(closure),
1390
1581
  arguments_count_(arguments_count),
1582
+ arguments_pushed_(false),
1391
1583
  function_(function),
1392
- call_kind_(call_kind),
1393
- is_construct_(is_construct),
1584
+ inlining_kind_(inlining_kind),
1394
1585
  arguments_var_(arguments_var),
1395
- arguments_values_(arguments_values) {
1586
+ arguments_values_(arguments_values),
1587
+ undefined_receiver_(undefined_receiver) {
1396
1588
  }
1397
1589
 
1398
1590
  virtual void PrintDataTo(StringStream* stream);
1399
1591
 
1400
1592
  Handle<JSFunction> closure() const { return closure_; }
1401
1593
  int arguments_count() const { return arguments_count_; }
1594
+ bool arguments_pushed() const { return arguments_pushed_; }
1595
+ void set_arguments_pushed() { arguments_pushed_ = true; }
1402
1596
  FunctionLiteral* function() const { return function_; }
1403
- CallKind call_kind() const { return call_kind_; }
1404
- bool is_construct() const { return is_construct_; }
1597
+ InliningKind inlining_kind() const { return inlining_kind_; }
1598
+ bool undefined_receiver() const { return undefined_receiver_; }
1405
1599
 
1406
1600
  virtual Representation RequiredInputRepresentation(int index) {
1407
1601
  return Representation::None();
@@ -1415,31 +1609,24 @@ class HEnterInlined: public HTemplateInstruction<0> {
1415
1609
  private:
1416
1610
  Handle<JSFunction> closure_;
1417
1611
  int arguments_count_;
1612
+ bool arguments_pushed_;
1418
1613
  FunctionLiteral* function_;
1419
- CallKind call_kind_;
1420
- bool is_construct_;
1614
+ InliningKind inlining_kind_;
1421
1615
  Variable* arguments_var_;
1422
1616
  ZoneList<HValue*>* arguments_values_;
1617
+ bool undefined_receiver_;
1423
1618
  };
1424
1619
 
1425
1620
 
1426
1621
  class HLeaveInlined: public HTemplateInstruction<0> {
1427
1622
  public:
1428
- explicit HLeaveInlined(bool arguments_pushed)
1429
- : arguments_pushed_(arguments_pushed) { }
1623
+ HLeaveInlined() { }
1430
1624
 
1431
1625
  virtual Representation RequiredInputRepresentation(int index) {
1432
1626
  return Representation::None();
1433
1627
  }
1434
1628
 
1435
- bool arguments_pushed() {
1436
- return arguments_pushed_;
1437
- }
1438
-
1439
1629
  DECLARE_CONCRETE_INSTRUCTION(LeaveInlined)
1440
-
1441
- private:
1442
- bool arguments_pushed_;
1443
1630
  };
1444
1631
 
1445
1632
 
@@ -1461,7 +1648,7 @@ class HPushArgument: public HUnaryOperation {
1461
1648
 
1462
1649
  class HThisFunction: public HTemplateInstruction<0> {
1463
1650
  public:
1464
- explicit HThisFunction(Handle<JSFunction> closure) : closure_(closure) {
1651
+ HThisFunction() {
1465
1652
  set_representation(Representation::Tagged());
1466
1653
  SetFlag(kUseGVN);
1467
1654
  }
@@ -1470,18 +1657,13 @@ class HThisFunction: public HTemplateInstruction<0> {
1470
1657
  return Representation::None();
1471
1658
  }
1472
1659
 
1473
- Handle<JSFunction> closure() const { return closure_; }
1474
-
1475
1660
  DECLARE_CONCRETE_INSTRUCTION(ThisFunction)
1476
1661
 
1477
1662
  protected:
1478
- virtual bool DataEquals(HValue* other) {
1479
- HThisFunction* b = HThisFunction::cast(other);
1480
- return *closure() == *b->closure();
1481
- }
1663
+ virtual bool DataEquals(HValue* other) { return true; }
1482
1664
 
1483
1665
  private:
1484
- Handle<JSFunction> closure_;
1666
+ virtual bool IsDeletable() const { return true; }
1485
1667
  };
1486
1668
 
1487
1669
 
@@ -1500,6 +1682,9 @@ class HContext: public HTemplateInstruction<0> {
1500
1682
 
1501
1683
  protected:
1502
1684
  virtual bool DataEquals(HValue* other) { return true; }
1685
+
1686
+ private:
1687
+ virtual bool IsDeletable() const { return true; }
1503
1688
  };
1504
1689
 
1505
1690
 
@@ -1518,6 +1703,9 @@ class HOuterContext: public HUnaryOperation {
1518
1703
 
1519
1704
  protected:
1520
1705
  virtual bool DataEquals(HValue* other) { return true; }
1706
+
1707
+ private:
1708
+ virtual bool IsDeletable() const { return true; }
1521
1709
  };
1522
1710
 
1523
1711
 
@@ -1563,6 +1751,9 @@ class HGlobalObject: public HUnaryOperation {
1563
1751
 
1564
1752
  protected:
1565
1753
  virtual bool DataEquals(HValue* other) { return true; }
1754
+
1755
+ private:
1756
+ virtual bool IsDeletable() const { return true; }
1566
1757
  };
1567
1758
 
1568
1759
 
@@ -1582,6 +1773,9 @@ class HGlobalReceiver: public HUnaryOperation {
1582
1773
 
1583
1774
  protected:
1584
1775
  virtual bool DataEquals(HValue* other) { return true; }
1776
+
1777
+ private:
1778
+ virtual bool IsDeletable() const { return true; }
1585
1779
  };
1586
1780
 
1587
1781
 
@@ -1840,12 +2034,14 @@ class HCallRuntime: public HCall<1> {
1840
2034
 
1841
2035
  class HJSArrayLength: public HTemplateInstruction<2> {
1842
2036
  public:
1843
- HJSArrayLength(HValue* value, HValue* typecheck) {
2037
+ HJSArrayLength(HValue* value, HValue* typecheck,
2038
+ HType type = HType::Tagged()) {
2039
+ set_type(type);
1844
2040
  // The length of an array is stored as a tagged value in the array
1845
2041
  // object. It is guaranteed to be 32 bit integer, but it can be
1846
2042
  // represented as either a smi or heap number.
1847
2043
  SetOperandAt(0, value);
1848
- SetOperandAt(1, typecheck);
2044
+ SetOperandAt(1, typecheck != NULL ? typecheck : value);
1849
2045
  set_representation(Representation::Tagged());
1850
2046
  SetFlag(kUseGVN);
1851
2047
  SetGVNFlag(kDependsOnArrayLengths);
@@ -1859,18 +2055,26 @@ class HJSArrayLength: public HTemplateInstruction<2> {
1859
2055
  virtual void PrintDataTo(StringStream* stream);
1860
2056
 
1861
2057
  HValue* value() { return OperandAt(0); }
1862
- HValue* typecheck() { return OperandAt(1); }
2058
+ HValue* typecheck() {
2059
+ ASSERT(HasTypeCheck());
2060
+ return OperandAt(1);
2061
+ }
2062
+ bool HasTypeCheck() const { return OperandAt(0) != OperandAt(1); }
1863
2063
 
1864
2064
  DECLARE_CONCRETE_INSTRUCTION(JSArrayLength)
1865
2065
 
1866
2066
  protected:
1867
- virtual bool DataEquals(HValue* other) { return true; }
2067
+ virtual bool DataEquals(HValue* other_raw) { return true; }
2068
+
2069
+ private:
2070
+ virtual bool IsDeletable() const { return true; }
1868
2071
  };
1869
2072
 
1870
2073
 
1871
2074
  class HFixedArrayBaseLength: public HUnaryOperation {
1872
2075
  public:
1873
2076
  explicit HFixedArrayBaseLength(HValue* value) : HUnaryOperation(value) {
2077
+ set_type(HType::Smi());
1874
2078
  set_representation(Representation::Tagged());
1875
2079
  SetFlag(kUseGVN);
1876
2080
  SetGVNFlag(kDependsOnArrayLengths);
@@ -1884,6 +2088,32 @@ class HFixedArrayBaseLength: public HUnaryOperation {
1884
2088
 
1885
2089
  protected:
1886
2090
  virtual bool DataEquals(HValue* other) { return true; }
2091
+
2092
+ private:
2093
+ virtual bool IsDeletable() const { return true; }
2094
+ };
2095
+
2096
+
2097
+ class HMapEnumLength: public HUnaryOperation {
2098
+ public:
2099
+ explicit HMapEnumLength(HValue* value) : HUnaryOperation(value) {
2100
+ set_type(HType::Smi());
2101
+ set_representation(Representation::Tagged());
2102
+ SetFlag(kUseGVN);
2103
+ SetGVNFlag(kDependsOnMaps);
2104
+ }
2105
+
2106
+ virtual Representation RequiredInputRepresentation(int index) {
2107
+ return Representation::Tagged();
2108
+ }
2109
+
2110
+ DECLARE_CONCRETE_INSTRUCTION(MapEnumLength)
2111
+
2112
+ protected:
2113
+ virtual bool DataEquals(HValue* other) { return true; }
2114
+
2115
+ private:
2116
+ virtual bool IsDeletable() const { return true; }
1887
2117
  };
1888
2118
 
1889
2119
 
@@ -1903,6 +2133,9 @@ class HElementsKind: public HUnaryOperation {
1903
2133
 
1904
2134
  protected:
1905
2135
  virtual bool DataEquals(HValue* other) { return true; }
2136
+
2137
+ private:
2138
+ virtual bool IsDeletable() const { return true; }
1906
2139
  };
1907
2140
 
1908
2141
 
@@ -1917,6 +2150,9 @@ class HBitNot: public HUnaryOperation {
1917
2150
  virtual Representation RequiredInputRepresentation(int index) {
1918
2151
  return Representation::Integer32();
1919
2152
  }
2153
+ virtual Representation observed_input_representation(int index) {
2154
+ return Representation::Integer32();
2155
+ }
1920
2156
  virtual HType CalculateInferredType();
1921
2157
 
1922
2158
  virtual HValue* Canonicalize();
@@ -1925,6 +2161,9 @@ class HBitNot: public HUnaryOperation {
1925
2161
 
1926
2162
  protected:
1927
2163
  virtual bool DataEquals(HValue* other) { return true; }
2164
+
2165
+ private:
2166
+ virtual bool IsDeletable() const { return true; }
1928
2167
  };
1929
2168
 
1930
2169
 
@@ -1941,7 +2180,7 @@ class HUnaryMathOperation: public HTemplateInstruction<2> {
1941
2180
  set_representation(Representation::Integer32());
1942
2181
  break;
1943
2182
  case kMathAbs:
1944
- set_representation(Representation::Tagged());
2183
+ // Not setting representation here: it is None intentionally.
1945
2184
  SetFlag(kFlexibleRepresentation);
1946
2185
  SetGVNFlag(kChangesNewSpacePromotion);
1947
2186
  break;
@@ -1954,6 +2193,9 @@ class HUnaryMathOperation: public HTemplateInstruction<2> {
1954
2193
  set_representation(Representation::Double());
1955
2194
  SetGVNFlag(kChangesNewSpacePromotion);
1956
2195
  break;
2196
+ case kMathExp:
2197
+ set_representation(Representation::Double());
2198
+ break;
1957
2199
  default:
1958
2200
  UNREACHABLE();
1959
2201
  }
@@ -1980,6 +2222,7 @@ class HUnaryMathOperation: public HTemplateInstruction<2> {
1980
2222
  case kMathSqrt:
1981
2223
  case kMathPowHalf:
1982
2224
  case kMathLog:
2225
+ case kMathExp:
1983
2226
  case kMathSin:
1984
2227
  case kMathCos:
1985
2228
  case kMathTan:
@@ -2007,18 +2250,31 @@ class HUnaryMathOperation: public HTemplateInstruction<2> {
2007
2250
  }
2008
2251
 
2009
2252
  private:
2253
+ virtual bool IsDeletable() const { return true; }
2254
+
2010
2255
  BuiltinFunctionId op_;
2011
2256
  };
2012
2257
 
2013
2258
 
2014
- class HLoadElements: public HUnaryOperation {
2259
+ class HLoadElements: public HTemplateInstruction<2> {
2015
2260
  public:
2016
- explicit HLoadElements(HValue* value) : HUnaryOperation(value) {
2261
+ HLoadElements(HValue* value, HValue* typecheck) {
2262
+ SetOperandAt(0, value);
2263
+ SetOperandAt(1, typecheck != NULL ? typecheck : value);
2017
2264
  set_representation(Representation::Tagged());
2018
2265
  SetFlag(kUseGVN);
2019
2266
  SetGVNFlag(kDependsOnElementsPointer);
2020
2267
  }
2021
2268
 
2269
+ HValue* value() { return OperandAt(0); }
2270
+ HValue* typecheck() {
2271
+ ASSERT(HasTypeCheck());
2272
+ return OperandAt(1);
2273
+ }
2274
+ bool HasTypeCheck() const { return OperandAt(0) != OperandAt(1); }
2275
+
2276
+ virtual void PrintDataTo(StringStream* stream);
2277
+
2022
2278
  virtual Representation RequiredInputRepresentation(int index) {
2023
2279
  return Representation::Tagged();
2024
2280
  }
@@ -2027,6 +2283,9 @@ class HLoadElements: public HUnaryOperation {
2027
2283
 
2028
2284
  protected:
2029
2285
  virtual bool DataEquals(HValue* other) { return true; }
2286
+
2287
+ private:
2288
+ virtual bool IsDeletable() const { return true; }
2030
2289
  };
2031
2290
 
2032
2291
 
@@ -2050,37 +2309,44 @@ class HLoadExternalArrayPointer: public HUnaryOperation {
2050
2309
 
2051
2310
  protected:
2052
2311
  virtual bool DataEquals(HValue* other) { return true; }
2312
+
2313
+ private:
2314
+ virtual bool IsDeletable() const { return true; }
2053
2315
  };
2054
2316
 
2055
2317
 
2056
2318
  class HCheckMaps: public HTemplateInstruction<2> {
2057
2319
  public:
2058
- HCheckMaps(HValue* value, Handle<Map> map, HValue* typecheck = NULL) {
2320
+ HCheckMaps(HValue* value, Handle<Map> map, Zone* zone,
2321
+ HValue* typecheck = NULL) {
2059
2322
  SetOperandAt(0, value);
2060
2323
  // If callers don't depend on a typecheck, they can pass in NULL. In that
2061
2324
  // case we use a copy of the |value| argument as a dummy value.
2062
2325
  SetOperandAt(1, typecheck != NULL ? typecheck : value);
2063
2326
  set_representation(Representation::Tagged());
2064
2327
  SetFlag(kUseGVN);
2328
+ SetFlag(kTrackSideEffectDominators);
2065
2329
  SetGVNFlag(kDependsOnMaps);
2066
2330
  SetGVNFlag(kDependsOnElementsKind);
2067
- map_set()->Add(map);
2331
+ map_set()->Add(map, zone);
2068
2332
  }
2069
- HCheckMaps(HValue* value, SmallMapList* maps) {
2333
+ HCheckMaps(HValue* value, SmallMapList* maps, Zone* zone) {
2070
2334
  SetOperandAt(0, value);
2071
2335
  SetOperandAt(1, value);
2072
2336
  set_representation(Representation::Tagged());
2073
2337
  SetFlag(kUseGVN);
2338
+ SetFlag(kTrackSideEffectDominators);
2074
2339
  SetGVNFlag(kDependsOnMaps);
2075
2340
  SetGVNFlag(kDependsOnElementsKind);
2076
2341
  for (int i = 0; i < maps->length(); i++) {
2077
- map_set()->Add(maps->at(i));
2342
+ map_set()->Add(maps->at(i), zone);
2078
2343
  }
2079
2344
  map_set()->Sort();
2080
2345
  }
2081
2346
 
2082
- static HCheckMaps* NewWithTransitions(HValue* object, Handle<Map> map) {
2083
- HCheckMaps* check_map = new HCheckMaps(object, map);
2347
+ static HCheckMaps* NewWithTransitions(HValue* object, Handle<Map> map,
2348
+ Zone* zone) {
2349
+ HCheckMaps* check_map = new(zone) HCheckMaps(object, map, zone);
2084
2350
  SmallMapList* map_set = check_map->map_set();
2085
2351
 
2086
2352
  // Since transitioned elements maps of the initial map don't fail the map
@@ -2092,9 +2358,9 @@ class HCheckMaps: public HTemplateInstruction<2> {
2092
2358
  while (CanTransitionToMoreGeneralFastElementsKind(kind, packed)) {
2093
2359
  kind = GetNextMoreGeneralFastElementsKind(kind, packed);
2094
2360
  Map* transitioned_map =
2095
- map->LookupElementsTransitionMap(kind, NULL);
2361
+ map->LookupElementsTransitionMap(kind);
2096
2362
  if (transitioned_map) {
2097
- map_set->Add(Handle<Map>(transitioned_map));
2363
+ map_set->Add(Handle<Map>(transitioned_map), zone);
2098
2364
  }
2099
2365
  };
2100
2366
  map_set->Sort();
@@ -2104,6 +2370,7 @@ class HCheckMaps: public HTemplateInstruction<2> {
2104
2370
  virtual Representation RequiredInputRepresentation(int index) {
2105
2371
  return Representation::Tagged();
2106
2372
  }
2373
+ virtual void SetSideEffectDominator(GVNFlag side_effect, HValue* dominator);
2107
2374
  virtual void PrintDataTo(StringStream* stream);
2108
2375
  virtual HType CalculateInferredType();
2109
2376
 
@@ -2134,6 +2401,7 @@ class HCheckFunction: public HUnaryOperation {
2134
2401
  : HUnaryOperation(value), target_(function) {
2135
2402
  set_representation(Representation::Tagged());
2136
2403
  SetFlag(kUseGVN);
2404
+ target_in_new_space_ = Isolate::Current()->heap()->InNewSpace(*function);
2137
2405
  }
2138
2406
 
2139
2407
  virtual Representation RequiredInputRepresentation(int index) {
@@ -2147,6 +2415,7 @@ class HCheckFunction: public HUnaryOperation {
2147
2415
  #endif
2148
2416
 
2149
2417
  Handle<JSFunction> target() const { return target_; }
2418
+ bool target_in_new_space() const { return target_in_new_space_; }
2150
2419
 
2151
2420
  DECLARE_CONCRETE_INSTRUCTION(CheckFunction)
2152
2421
 
@@ -2158,22 +2427,23 @@ class HCheckFunction: public HUnaryOperation {
2158
2427
 
2159
2428
  private:
2160
2429
  Handle<JSFunction> target_;
2430
+ bool target_in_new_space_;
2161
2431
  };
2162
2432
 
2163
2433
 
2164
2434
  class HCheckInstanceType: public HUnaryOperation {
2165
2435
  public:
2166
- static HCheckInstanceType* NewIsSpecObject(HValue* value) {
2167
- return new HCheckInstanceType(value, IS_SPEC_OBJECT);
2436
+ static HCheckInstanceType* NewIsSpecObject(HValue* value, Zone* zone) {
2437
+ return new(zone) HCheckInstanceType(value, IS_SPEC_OBJECT);
2168
2438
  }
2169
- static HCheckInstanceType* NewIsJSArray(HValue* value) {
2170
- return new HCheckInstanceType(value, IS_JS_ARRAY);
2439
+ static HCheckInstanceType* NewIsJSArray(HValue* value, Zone* zone) {
2440
+ return new(zone) HCheckInstanceType(value, IS_JS_ARRAY);
2171
2441
  }
2172
- static HCheckInstanceType* NewIsString(HValue* value) {
2173
- return new HCheckInstanceType(value, IS_STRING);
2442
+ static HCheckInstanceType* NewIsString(HValue* value, Zone* zone) {
2443
+ return new(zone) HCheckInstanceType(value, IS_STRING);
2174
2444
  }
2175
- static HCheckInstanceType* NewIsSymbol(HValue* value) {
2176
- return new HCheckInstanceType(value, IS_SYMBOL);
2445
+ static HCheckInstanceType* NewIsSymbol(HValue* value, Zone* zone) {
2446
+ return new(zone) HCheckInstanceType(value, IS_SYMBOL);
2177
2447
  }
2178
2448
 
2179
2449
  virtual void PrintDataTo(StringStream* stream);
@@ -2258,18 +2528,24 @@ class HCheckNonSmi: public HUnaryOperation {
2258
2528
 
2259
2529
  class HCheckPrototypeMaps: public HTemplateInstruction<0> {
2260
2530
  public:
2261
- HCheckPrototypeMaps(Handle<JSObject> prototype, Handle<JSObject> holder)
2262
- : prototype_(prototype), holder_(holder) {
2531
+ HCheckPrototypeMaps(Handle<JSObject> prototype,
2532
+ Handle<JSObject> holder,
2533
+ Zone* zone) : prototypes_(2, zone), maps_(2, zone) {
2263
2534
  SetFlag(kUseGVN);
2264
2535
  SetGVNFlag(kDependsOnMaps);
2536
+ // Keep a list of all objects on the prototype chain up to the holder
2537
+ // and the expected maps.
2538
+ while (true) {
2539
+ prototypes_.Add(prototype, zone);
2540
+ maps_.Add(Handle<Map>(prototype->map()), zone);
2541
+ if (prototype.is_identical_to(holder)) break;
2542
+ prototype = Handle<JSObject>(JSObject::cast(prototype->GetPrototype()));
2543
+ }
2265
2544
  }
2266
2545
 
2267
- #ifdef DEBUG
2268
- virtual void Verify();
2269
- #endif
2546
+ ZoneList<Handle<JSObject> >* prototypes() { return &prototypes_; }
2270
2547
 
2271
- Handle<JSObject> prototype() const { return prototype_; }
2272
- Handle<JSObject> holder() const { return holder_; }
2548
+ ZoneList<Handle<Map> >* maps() { return &maps_; }
2273
2549
 
2274
2550
  DECLARE_CONCRETE_INSTRUCTION(CheckPrototypeMaps)
2275
2551
 
@@ -2277,23 +2553,39 @@ class HCheckPrototypeMaps: public HTemplateInstruction<0> {
2277
2553
  return Representation::None();
2278
2554
  }
2279
2555
 
2556
+ virtual void PrintDataTo(StringStream* stream);
2557
+
2280
2558
  virtual intptr_t Hashcode() {
2281
- ASSERT(!HEAP->IsAllocationAllowed());
2282
- intptr_t hash = reinterpret_cast<intptr_t>(*prototype());
2283
- hash = 17 * hash + reinterpret_cast<intptr_t>(*holder());
2559
+ ASSERT_ALLOCATION_DISABLED;
2560
+ // Dereferencing to use the object's raw address for hashing is safe.
2561
+ AllowHandleDereference allow_handle_deref;
2562
+ intptr_t hash = 0;
2563
+ for (int i = 0; i < prototypes_.length(); i++) {
2564
+ hash = 17 * hash + reinterpret_cast<intptr_t>(*prototypes_[i]);
2565
+ hash = 17 * hash + reinterpret_cast<intptr_t>(*maps_[i]);
2566
+ }
2284
2567
  return hash;
2285
2568
  }
2286
2569
 
2287
2570
  protected:
2288
2571
  virtual bool DataEquals(HValue* other) {
2289
2572
  HCheckPrototypeMaps* b = HCheckPrototypeMaps::cast(other);
2290
- return prototype_.is_identical_to(b->prototype()) &&
2291
- holder_.is_identical_to(b->holder());
2573
+ #ifdef DEBUG
2574
+ if (prototypes_.length() != b->prototypes()->length()) return false;
2575
+ for (int i = 0; i < prototypes_.length(); i++) {
2576
+ if (!prototypes_[i].is_identical_to(b->prototypes()->at(i))) return false;
2577
+ if (!maps_[i].is_identical_to(b->maps()->at(i))) return false;
2578
+ }
2579
+ return true;
2580
+ #else
2581
+ return prototypes_.first().is_identical_to(b->prototypes()->first()) &&
2582
+ prototypes_.last().is_identical_to(b->prototypes()->last());
2583
+ #endif // DEBUG
2292
2584
  }
2293
2585
 
2294
2586
  private:
2295
- Handle<JSObject> prototype_;
2296
- Handle<JSObject> holder_;
2587
+ ZoneList<Handle<JSObject> > prototypes_;
2588
+ ZoneList<Handle<Map> > maps_;
2297
2589
  };
2298
2590
 
2299
2591
 
@@ -2322,8 +2614,8 @@ class HCheckSmi: public HUnaryOperation {
2322
2614
 
2323
2615
  class HPhi: public HValue {
2324
2616
  public:
2325
- explicit HPhi(int merged_index)
2326
- : inputs_(2),
2617
+ HPhi(int merged_index, Zone* zone)
2618
+ : inputs_(2, zone),
2327
2619
  merged_index_(merged_index),
2328
2620
  phi_id_(-1),
2329
2621
  is_live_(false),
@@ -2333,19 +2625,21 @@ class HPhi: public HValue {
2333
2625
  indirect_uses_[i] = 0;
2334
2626
  }
2335
2627
  ASSERT(merged_index >= 0);
2336
- set_representation(Representation::Tagged());
2337
2628
  SetFlag(kFlexibleRepresentation);
2338
2629
  }
2339
2630
 
2340
- virtual Representation InferredRepresentation();
2631
+ virtual Representation RepresentationFromInputs();
2341
2632
 
2342
2633
  virtual Range* InferRange(Zone* zone);
2634
+ virtual void InferRepresentation(HInferRepresentation* h_infer);
2635
+ Representation RepresentationObservedByAllNonPhiUses();
2636
+ Representation RepresentationFromUseRequirements();
2343
2637
  virtual Representation RequiredInputRepresentation(int index) {
2344
2638
  return representation();
2345
2639
  }
2346
2640
  virtual HType CalculateInferredType();
2347
2641
  virtual int OperandCount() { return inputs_.length(); }
2348
- virtual HValue* OperandAt(int index) { return inputs_[index]; }
2642
+ virtual HValue* OperandAt(int index) const { return inputs_[index]; }
2349
2643
  HValue* GetRedundantReplacement();
2350
2644
  void AddInput(HValue* value);
2351
2645
  bool HasRealUses();
@@ -2402,7 +2696,14 @@ class HPhi: public HValue {
2402
2696
 
2403
2697
  bool AllOperandsConvertibleToInteger() {
2404
2698
  for (int i = 0; i < OperandCount(); ++i) {
2405
- if (!OperandAt(i)->IsConvertibleToInteger()) return false;
2699
+ if (!OperandAt(i)->IsConvertibleToInteger()) {
2700
+ if (FLAG_trace_representation) {
2701
+ HValue* input = OperandAt(i);
2702
+ PrintF("#%d %s: Input #%d %s at %d is NCTI\n",
2703
+ id(), Mnemonic(), input->id(), input->Mnemonic(), i);
2704
+ }
2705
+ return false;
2706
+ }
2406
2707
  }
2407
2708
  return true;
2408
2709
  }
@@ -2437,28 +2738,54 @@ class HArgumentsObject: public HTemplateInstruction<0> {
2437
2738
  }
2438
2739
 
2439
2740
  DECLARE_CONCRETE_INSTRUCTION(ArgumentsObject)
2741
+
2742
+ private:
2743
+ virtual bool IsDeletable() const { return true; }
2440
2744
  };
2441
2745
 
2442
2746
 
2443
2747
  class HConstant: public HTemplateInstruction<0> {
2444
2748
  public:
2445
2749
  HConstant(Handle<Object> handle, Representation r);
2750
+ HConstant(int32_t value, Representation r);
2751
+ HConstant(double value, Representation r);
2446
2752
 
2447
- Handle<Object> handle() const { return handle_; }
2753
+ Handle<Object> handle() {
2754
+ if (handle_.is_null()) {
2755
+ handle_ = FACTORY->NewNumber(double_value_, TENURED);
2756
+ }
2757
+ ASSERT(has_int32_value_ || !handle_->IsSmi());
2758
+ return handle_;
2759
+ }
2448
2760
 
2449
2761
  bool InOldSpace() const { return !HEAP->InNewSpace(*handle_); }
2450
2762
 
2451
2763
  bool ImmortalImmovable() const {
2764
+ if (has_int32_value_) {
2765
+ return false;
2766
+ }
2767
+ if (has_double_value_) {
2768
+ if (BitCast<int64_t>(double_value_) == BitCast<int64_t>(-0.0) ||
2769
+ isnan(double_value_)) {
2770
+ return true;
2771
+ }
2772
+ return false;
2773
+ }
2774
+
2775
+ ASSERT(!handle_.is_null());
2452
2776
  Heap* heap = HEAP;
2453
- if (*handle_ == heap->undefined_value()) return true;
2454
- if (*handle_ == heap->null_value()) return true;
2455
- if (*handle_ == heap->true_value()) return true;
2456
- if (*handle_ == heap->false_value()) return true;
2457
- if (*handle_ == heap->the_hole_value()) return true;
2458
- if (*handle_ == heap->minus_zero_value()) return true;
2459
- if (*handle_ == heap->nan_value()) return true;
2460
- if (*handle_ == heap->empty_string()) return true;
2461
- return false;
2777
+ // We should have handled minus_zero_value and nan_value in the
2778
+ // has_double_value_ clause above.
2779
+ // Dereferencing is safe to compare against singletons.
2780
+ AllowHandleDereference allow_handle_deref;
2781
+ ASSERT(*handle_ != heap->minus_zero_value());
2782
+ ASSERT(*handle_ != heap->nan_value());
2783
+ return *handle_ == heap->undefined_value() ||
2784
+ *handle_ == heap->null_value() ||
2785
+ *handle_ == heap->true_value() ||
2786
+ *handle_ == heap->false_value() ||
2787
+ *handle_ == heap->the_hole_value() ||
2788
+ *handle_ == heap->empty_string();
2462
2789
  }
2463
2790
 
2464
2791
  virtual Representation RequiredInputRepresentation(int index) {
@@ -2466,20 +2793,15 @@ class HConstant: public HTemplateInstruction<0> {
2466
2793
  }
2467
2794
 
2468
2795
  virtual bool IsConvertibleToInteger() const {
2469
- if (handle_->IsSmi()) return true;
2470
- if (handle_->IsHeapNumber() &&
2471
- (HeapNumber::cast(*handle_)->value() ==
2472
- static_cast<double>(NumberToInt32(*handle_)))) return true;
2473
- return false;
2796
+ return has_int32_value_;
2474
2797
  }
2475
2798
 
2476
2799
  virtual bool EmitAtUses() { return !representation().IsDouble(); }
2477
- virtual HValue* Canonicalize();
2478
2800
  virtual void PrintDataTo(StringStream* stream);
2479
2801
  virtual HType CalculateInferredType();
2480
- bool IsInteger() const { return handle_->IsSmi(); }
2481
- HConstant* CopyToRepresentation(Representation r) const;
2482
- HConstant* CopyToTruncatedInt32() const;
2802
+ bool IsInteger() { return handle()->IsSmi(); }
2803
+ HConstant* CopyToRepresentation(Representation r, Zone* zone) const;
2804
+ HConstant* CopyToTruncatedInt32(Zone* zone) const;
2483
2805
  bool HasInteger32Value() const { return has_int32_value_; }
2484
2806
  int32_t Integer32Value() const {
2485
2807
  ASSERT(HasInteger32Value());
@@ -2490,24 +2812,37 @@ class HConstant: public HTemplateInstruction<0> {
2490
2812
  ASSERT(HasDoubleValue());
2491
2813
  return double_value_;
2492
2814
  }
2493
- bool HasNumberValue() const { return has_int32_value_ || has_double_value_; }
2815
+ bool HasNumberValue() const { return has_double_value_; }
2494
2816
  int32_t NumberValueAsInteger32() const {
2495
2817
  ASSERT(HasNumberValue());
2496
- if (has_int32_value_) return int32_value_;
2497
- return DoubleToInt32(double_value_);
2818
+ // Irrespective of whether a numeric HConstant can be safely
2819
+ // represented as an int32, we store the (in some cases lossy)
2820
+ // representation of the number in int32_value_.
2821
+ return int32_value_;
2498
2822
  }
2499
- bool HasStringValue() const { return handle_->IsString(); }
2500
2823
 
2501
- bool ToBoolean() const;
2824
+ bool ToBoolean();
2825
+
2826
+ bool IsUint32() {
2827
+ return HasInteger32Value() && (Integer32Value() >= 0);
2828
+ }
2502
2829
 
2503
2830
  virtual intptr_t Hashcode() {
2504
- ASSERT(!HEAP->allow_allocation(false));
2505
- intptr_t hash = reinterpret_cast<intptr_t>(*handle());
2506
- // Prevent smis from having fewer hash values when truncated to
2507
- // the least significant bits.
2508
- const int kShiftSize = kSmiShiftSize + kSmiTagSize;
2509
- STATIC_ASSERT(kShiftSize != 0);
2510
- return hash ^ (hash >> kShiftSize);
2831
+ ASSERT_ALLOCATION_DISABLED;
2832
+ intptr_t hash;
2833
+
2834
+ if (has_int32_value_) {
2835
+ hash = static_cast<intptr_t>(int32_value_);
2836
+ } else if (has_double_value_) {
2837
+ hash = static_cast<intptr_t>(BitCast<int64_t>(double_value_));
2838
+ } else {
2839
+ ASSERT(!handle_.is_null());
2840
+ // Dereferencing to use the object's raw address for hashing is safe.
2841
+ AllowHandleDereference allow_handle_deref;
2842
+ hash = reinterpret_cast<intptr_t>(*handle_);
2843
+ }
2844
+
2845
+ return hash;
2511
2846
  }
2512
2847
 
2513
2848
  #ifdef DEBUG
@@ -2521,15 +2856,34 @@ class HConstant: public HTemplateInstruction<0> {
2521
2856
 
2522
2857
  virtual bool DataEquals(HValue* other) {
2523
2858
  HConstant* other_constant = HConstant::cast(other);
2524
- return handle().is_identical_to(other_constant->handle());
2859
+ if (has_int32_value_) {
2860
+ return other_constant->has_int32_value_ &&
2861
+ int32_value_ == other_constant->int32_value_;
2862
+ } else if (has_double_value_) {
2863
+ return other_constant->has_double_value_ &&
2864
+ BitCast<int64_t>(double_value_) ==
2865
+ BitCast<int64_t>(other_constant->double_value_);
2866
+ } else {
2867
+ ASSERT(!handle_.is_null());
2868
+ return !other_constant->handle_.is_null() &&
2869
+ handle_.is_identical_to(other_constant->handle_);
2870
+ }
2525
2871
  }
2526
2872
 
2527
2873
  private:
2874
+ virtual bool IsDeletable() const { return true; }
2875
+
2876
+ // If this is a numerical constant, handle_ either points to to the
2877
+ // HeapObject the constant originated from or is null. If the
2878
+ // constant is non-numeric, handle_ always points to a valid
2879
+ // constant HeapObject.
2528
2880
  Handle<Object> handle_;
2529
2881
 
2530
- // The following two values represent the int32 and the double value of the
2531
- // given constant if there is a lossless conversion between the constant
2532
- // and the specific representation.
2882
+ // We store the HConstant in the most specific form safely possible.
2883
+ // The two flags, has_int32_value_ and has_double_value_ tell us if
2884
+ // int32_value_ and double_value_ hold valid, safe representations
2885
+ // of the constant. has_int32_value_ implies has_double_value_ but
2886
+ // not the converse.
2533
2887
  bool has_int32_value_ : 1;
2534
2888
  bool has_double_value_ : 1;
2535
2889
  int32_t int32_value_;
@@ -2539,11 +2893,14 @@ class HConstant: public HTemplateInstruction<0> {
2539
2893
 
2540
2894
  class HBinaryOperation: public HTemplateInstruction<3> {
2541
2895
  public:
2542
- HBinaryOperation(HValue* context, HValue* left, HValue* right) {
2896
+ HBinaryOperation(HValue* context, HValue* left, HValue* right)
2897
+ : observed_output_representation_(Representation::None()) {
2543
2898
  ASSERT(left != NULL && right != NULL);
2544
2899
  SetOperandAt(0, context);
2545
2900
  SetOperandAt(1, left);
2546
2901
  SetOperandAt(2, right);
2902
+ observed_input_representation_[0] = Representation::None();
2903
+ observed_input_representation_[1] = Representation::None();
2547
2904
  }
2548
2905
 
2549
2906
  HValue* context() { return OperandAt(0); }
@@ -2556,14 +2913,40 @@ class HBinaryOperation: public HTemplateInstruction<3> {
2556
2913
  if (IsCommutative() && left()->IsConstant()) return right();
2557
2914
  return left();
2558
2915
  }
2916
+
2559
2917
  HValue* MostConstantOperand() {
2560
2918
  if (IsCommutative() && left()->IsConstant()) return left();
2561
2919
  return right();
2562
2920
  }
2563
2921
 
2922
+ void set_observed_input_representation(Representation left,
2923
+ Representation right) {
2924
+ observed_input_representation_[0] = left;
2925
+ observed_input_representation_[1] = right;
2926
+ }
2927
+
2928
+ virtual void initialize_output_representation(Representation observed) {
2929
+ observed_output_representation_ = observed;
2930
+ }
2931
+
2932
+ virtual Representation observed_input_representation(int index) {
2933
+ if (index == 0) return Representation::Tagged();
2934
+ return observed_input_representation_[index - 1];
2935
+ }
2936
+
2937
+ virtual void InferRepresentation(HInferRepresentation* h_infer);
2938
+ virtual Representation RepresentationFromInputs();
2939
+ virtual void AssumeRepresentation(Representation r);
2940
+
2564
2941
  virtual bool IsCommutative() const { return false; }
2565
2942
 
2566
2943
  virtual void PrintDataTo(StringStream* stream);
2944
+
2945
+ DECLARE_ABSTRACT_INSTRUCTION(BinaryOperation)
2946
+
2947
+ private:
2948
+ Representation observed_input_representation_[2];
2949
+ Representation observed_output_representation_;
2567
2950
  };
2568
2951
 
2569
2952
 
@@ -2584,6 +2967,8 @@ class HWrapReceiver: public HTemplateInstruction<2> {
2584
2967
 
2585
2968
  virtual HValue* Canonicalize();
2586
2969
 
2970
+ virtual void PrintDataTo(StringStream* stream);
2971
+
2587
2972
  DECLARE_CONCRETE_INSTRUCTION(WrapReceiver)
2588
2973
  };
2589
2974
 
@@ -2638,6 +3023,9 @@ class HArgumentsElements: public HTemplateInstruction<0> {
2638
3023
  protected:
2639
3024
  virtual bool DataEquals(HValue* other) { return true; }
2640
3025
 
3026
+ private:
3027
+ virtual bool IsDeletable() const { return true; }
3028
+
2641
3029
  bool from_inlined_;
2642
3030
  };
2643
3031
 
@@ -2657,6 +3045,9 @@ class HArgumentsLength: public HUnaryOperation {
2657
3045
 
2658
3046
  protected:
2659
3047
  virtual bool DataEquals(HValue* other) { return true; }
3048
+
3049
+ private:
3050
+ virtual bool IsDeletable() const { return true; }
2660
3051
  };
2661
3052
 
2662
3053
 
@@ -2689,28 +3080,52 @@ class HAccessArgumentsAt: public HTemplateInstruction<3> {
2689
3080
  };
2690
3081
 
2691
3082
 
3083
+ enum BoundsCheckKeyMode {
3084
+ DONT_ALLOW_SMI_KEY,
3085
+ ALLOW_SMI_KEY
3086
+ };
3087
+
3088
+
2692
3089
  class HBoundsCheck: public HTemplateInstruction<2> {
2693
3090
  public:
2694
- HBoundsCheck(HValue* index, HValue* length) {
3091
+ HBoundsCheck(HValue* index, HValue* length,
3092
+ BoundsCheckKeyMode key_mode = DONT_ALLOW_SMI_KEY,
3093
+ Representation r = Representation::None())
3094
+ : key_mode_(key_mode) {
2695
3095
  SetOperandAt(0, index);
2696
3096
  SetOperandAt(1, length);
2697
- set_representation(Representation::Integer32());
3097
+ if (r.IsNone()) {
3098
+ // In the normal compilation pipeline the representation is flexible
3099
+ // (see comment to RequiredInputRepresentation).
3100
+ SetFlag(kFlexibleRepresentation);
3101
+ } else {
3102
+ // When compiling stubs we want to set the representation explicitly
3103
+ // so the compilation pipeline can skip the HInferRepresentation phase.
3104
+ set_representation(r);
3105
+ }
2698
3106
  SetFlag(kUseGVN);
2699
3107
  }
2700
3108
 
2701
- virtual Representation RequiredInputRepresentation(int index) {
3109
+ virtual Representation RequiredInputRepresentation(int arg_index) {
3110
+ return representation();
3111
+ }
3112
+ virtual Representation observed_input_representation(int index) {
2702
3113
  return Representation::Integer32();
2703
3114
  }
2704
3115
 
2705
3116
  virtual void PrintDataTo(StringStream* stream);
3117
+ virtual void InferRepresentation(HInferRepresentation* h_infer);
2706
3118
 
2707
3119
  HValue* index() { return OperandAt(0); }
2708
3120
  HValue* length() { return OperandAt(1); }
2709
3121
 
3122
+ virtual int RedefinedOperandIndex() { return 0; }
3123
+
2710
3124
  DECLARE_CONCRETE_INSTRUCTION(BoundsCheck)
2711
3125
 
2712
3126
  protected:
2713
3127
  virtual bool DataEquals(HValue* other) { return true; }
3128
+ BoundsCheckKeyMode key_mode_;
2714
3129
  };
2715
3130
 
2716
3131
 
@@ -2718,8 +3133,8 @@ class HBitwiseBinaryOperation: public HBinaryOperation {
2718
3133
  public:
2719
3134
  HBitwiseBinaryOperation(HValue* context, HValue* left, HValue* right)
2720
3135
  : HBinaryOperation(context, left, right) {
2721
- set_representation(Representation::Tagged());
2722
3136
  SetFlag(kFlexibleRepresentation);
3137
+ SetFlag(kTruncatingToInt32);
2723
3138
  SetAllSideEffects();
2724
3139
  }
2725
3140
 
@@ -2733,14 +3148,32 @@ class HBitwiseBinaryOperation: public HBinaryOperation {
2733
3148
  if (!to.IsTagged()) {
2734
3149
  ASSERT(to.IsInteger32());
2735
3150
  ClearAllSideEffects();
2736
- SetFlag(kTruncatingToInt32);
2737
3151
  SetFlag(kUseGVN);
3152
+ } else {
3153
+ SetAllSideEffects();
3154
+ ClearFlag(kUseGVN);
2738
3155
  }
2739
3156
  }
2740
3157
 
3158
+ virtual void UpdateRepresentation(Representation new_rep,
3159
+ HInferRepresentation* h_infer,
3160
+ const char* reason) {
3161
+ // We only generate either int32 or generic tagged bitwise operations.
3162
+ if (new_rep.IsDouble()) new_rep = Representation::Integer32();
3163
+ HValue::UpdateRepresentation(new_rep, h_infer, reason);
3164
+ }
3165
+
3166
+ virtual void initialize_output_representation(Representation observed) {
3167
+ if (observed.IsDouble()) observed = Representation::Integer32();
3168
+ HBinaryOperation::initialize_output_representation(observed);
3169
+ }
3170
+
2741
3171
  virtual HType CalculateInferredType();
2742
3172
 
2743
3173
  DECLARE_ABSTRACT_INSTRUCTION(BitwiseBinaryOperation)
3174
+
3175
+ private:
3176
+ virtual bool IsDeletable() const { return true; }
2744
3177
  };
2745
3178
 
2746
3179
 
@@ -2750,8 +3183,14 @@ class HMathFloorOfDiv: public HBinaryOperation {
2750
3183
  : HBinaryOperation(context, left, right) {
2751
3184
  set_representation(Representation::Integer32());
2752
3185
  SetFlag(kUseGVN);
3186
+ SetFlag(kCanOverflow);
3187
+ if (!right->IsConstant()) {
3188
+ SetFlag(kCanBeDivByZero);
3189
+ }
2753
3190
  }
2754
3191
 
3192
+ virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
3193
+
2755
3194
  virtual Representation RequiredInputRepresentation(int index) {
2756
3195
  return Representation::Integer32();
2757
3196
  }
@@ -2760,6 +3199,9 @@ class HMathFloorOfDiv: public HBinaryOperation {
2760
3199
 
2761
3200
  protected:
2762
3201
  virtual bool DataEquals(HValue* other) { return true; }
3202
+
3203
+ private:
3204
+ virtual bool IsDeletable() const { return true; }
2763
3205
  };
2764
3206
 
2765
3207
 
@@ -2767,13 +3209,15 @@ class HArithmeticBinaryOperation: public HBinaryOperation {
2767
3209
  public:
2768
3210
  HArithmeticBinaryOperation(HValue* context, HValue* left, HValue* right)
2769
3211
  : HBinaryOperation(context, left, right) {
2770
- set_representation(Representation::Tagged());
2771
- SetFlag(kFlexibleRepresentation);
2772
3212
  SetAllSideEffects();
3213
+ SetFlag(kFlexibleRepresentation);
2773
3214
  }
2774
3215
 
2775
3216
  virtual void RepresentationChanged(Representation to) {
2776
- if (!to.IsTagged()) {
3217
+ if (to.IsTagged()) {
3218
+ SetAllSideEffects();
3219
+ ClearFlag(kUseGVN);
3220
+ } else {
2777
3221
  ClearAllSideEffects();
2778
3222
  SetFlag(kUseGVN);
2779
3223
  }
@@ -2786,12 +3230,8 @@ class HArithmeticBinaryOperation: public HBinaryOperation {
2786
3230
  : representation();
2787
3231
  }
2788
3232
 
2789
- virtual Representation InferredRepresentation() {
2790
- if (left()->representation().Equals(right()->representation())) {
2791
- return left()->representation();
2792
- }
2793
- return HValue::InferredRepresentation();
2794
- }
3233
+ private:
3234
+ virtual bool IsDeletable() const { return true; }
2795
3235
  };
2796
3236
 
2797
3237
 
@@ -2808,11 +3248,9 @@ class HCompareGeneric: public HBinaryOperation {
2808
3248
  }
2809
3249
 
2810
3250
  virtual Representation RequiredInputRepresentation(int index) {
2811
- return Representation::Tagged();
2812
- }
2813
-
2814
- Representation GetInputRepresentation() const {
2815
- return Representation::Tagged();
3251
+ return index == 0
3252
+ ? Representation::Tagged()
3253
+ : representation();
2816
3254
  }
2817
3255
 
2818
3256
  Token::Value token() const { return token_; }
@@ -2831,6 +3269,7 @@ class HCompareIDAndBranch: public HTemplateControlInstruction<2, 2> {
2831
3269
  public:
2832
3270
  HCompareIDAndBranch(HValue* left, HValue* right, Token::Value token)
2833
3271
  : token_(token) {
3272
+ SetFlag(kFlexibleRepresentation);
2834
3273
  ASSERT(Token::IsCompareOp(token));
2835
3274
  SetOperandAt(0, left);
2836
3275
  SetOperandAt(1, right);
@@ -2840,20 +3279,26 @@ class HCompareIDAndBranch: public HTemplateControlInstruction<2, 2> {
2840
3279
  HValue* right() { return OperandAt(1); }
2841
3280
  Token::Value token() const { return token_; }
2842
3281
 
2843
- void SetInputRepresentation(Representation r);
2844
- Representation GetInputRepresentation() const {
2845
- return input_representation_;
3282
+ void set_observed_input_representation(Representation left,
3283
+ Representation right) {
3284
+ observed_input_representation_[0] = left;
3285
+ observed_input_representation_[1] = right;
2846
3286
  }
2847
3287
 
3288
+ virtual void InferRepresentation(HInferRepresentation* h_infer);
3289
+
2848
3290
  virtual Representation RequiredInputRepresentation(int index) {
2849
- return input_representation_;
3291
+ return representation();
3292
+ }
3293
+ virtual Representation observed_input_representation(int index) {
3294
+ return observed_input_representation_[index];
2850
3295
  }
2851
3296
  virtual void PrintDataTo(StringStream* stream);
2852
3297
 
2853
3298
  DECLARE_CONCRETE_INSTRUCTION(CompareIDAndBranch)
2854
3299
 
2855
3300
  private:
2856
- Representation input_representation_;
3301
+ Representation observed_input_representation_[2];
2857
3302
  Token::Value token_;
2858
3303
  };
2859
3304
 
@@ -2914,6 +3359,9 @@ class HIsNilAndBranch: public HUnaryControlInstruction {
2914
3359
  virtual Representation RequiredInputRepresentation(int index) {
2915
3360
  return Representation::Tagged();
2916
3361
  }
3362
+ virtual Representation observed_input_representation(int index) {
3363
+ return Representation::Tagged();
3364
+ }
2917
3365
 
2918
3366
  DECLARE_CONCRETE_INSTRUCTION(IsNilAndBranch)
2919
3367
 
@@ -3077,6 +3525,9 @@ class HGetCachedArrayIndex: public HUnaryOperation {
3077
3525
 
3078
3526
  protected:
3079
3527
  virtual bool DataEquals(HValue* other) { return true; }
3528
+
3529
+ private:
3530
+ virtual bool IsDeletable() const { return true; }
3080
3531
  };
3081
3532
 
3082
3533
 
@@ -3181,18 +3632,26 @@ class HPower: public HTemplateInstruction<2> {
3181
3632
  }
3182
3633
 
3183
3634
  HValue* left() { return OperandAt(0); }
3184
- HValue* right() { return OperandAt(1); }
3635
+ HValue* right() const { return OperandAt(1); }
3185
3636
 
3186
3637
  virtual Representation RequiredInputRepresentation(int index) {
3187
3638
  return index == 0
3188
3639
  ? Representation::Double()
3189
3640
  : Representation::None();
3190
3641
  }
3642
+ virtual Representation observed_input_representation(int index) {
3643
+ return RequiredInputRepresentation(index);
3644
+ }
3191
3645
 
3192
3646
  DECLARE_CONCRETE_INSTRUCTION(Power)
3193
3647
 
3194
3648
  protected:
3195
3649
  virtual bool DataEquals(HValue* other) { return true; }
3650
+
3651
+ private:
3652
+ virtual bool IsDeletable() const {
3653
+ return !right()->representation().IsTagged();
3654
+ }
3196
3655
  };
3197
3656
 
3198
3657
 
@@ -3210,6 +3669,9 @@ class HRandom: public HTemplateInstruction<1> {
3210
3669
  }
3211
3670
 
3212
3671
  DECLARE_CONCRETE_INSTRUCTION(Random)
3672
+
3673
+ private:
3674
+ virtual bool IsDeletable() const { return true; }
3213
3675
  };
3214
3676
 
3215
3677
 
@@ -3258,11 +3720,11 @@ class HSub: public HArithmeticBinaryOperation {
3258
3720
  virtual HValue* Canonicalize();
3259
3721
 
3260
3722
  static HInstruction* NewHSub(Zone* zone,
3261
- HValue* context,
3262
- HValue* left,
3263
- HValue* right);
3264
-
3265
- DECLARE_CONCRETE_INSTRUCTION(Sub)
3723
+ HValue* context,
3724
+ HValue* left,
3725
+ HValue* right);
3726
+
3727
+ DECLARE_CONCRETE_INSTRUCTION(Sub)
3266
3728
 
3267
3729
  protected:
3268
3730
  virtual bool DataEquals(HValue* other) { return true; }
@@ -3340,6 +3802,16 @@ class HDiv: public HArithmeticBinaryOperation {
3340
3802
  SetFlag(kCanOverflow);
3341
3803
  }
3342
3804
 
3805
+ bool HasPowerOf2Divisor() {
3806
+ if (right()->IsConstant() &&
3807
+ HConstant::cast(right())->HasInteger32Value()) {
3808
+ int32_t value = HConstant::cast(right())->Integer32Value();
3809
+ return value != 0 && (IsPowerOf2(value) || IsPowerOf2(-value));
3810
+ }
3811
+
3812
+ return false;
3813
+ }
3814
+
3343
3815
  virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
3344
3816
 
3345
3817
  static HInstruction* NewHDiv(Zone* zone,
@@ -3356,6 +3828,54 @@ class HDiv: public HArithmeticBinaryOperation {
3356
3828
  };
3357
3829
 
3358
3830
 
3831
+ class HMathMinMax: public HArithmeticBinaryOperation {
3832
+ public:
3833
+ enum Operation { kMathMin, kMathMax };
3834
+
3835
+ HMathMinMax(HValue* context, HValue* left, HValue* right, Operation op)
3836
+ : HArithmeticBinaryOperation(context, left, right),
3837
+ operation_(op) { }
3838
+
3839
+ virtual Representation RequiredInputRepresentation(int index) {
3840
+ return index == 0 ? Representation::Tagged()
3841
+ : representation();
3842
+ }
3843
+
3844
+ virtual Representation observed_input_representation(int index) {
3845
+ return RequiredInputRepresentation(index);
3846
+ }
3847
+
3848
+ virtual void InferRepresentation(HInferRepresentation* h_infer);
3849
+
3850
+ virtual Representation RepresentationFromInputs() {
3851
+ Representation left_rep = left()->representation();
3852
+ Representation right_rep = right()->representation();
3853
+ if ((left_rep.IsNone() || left_rep.IsInteger32()) &&
3854
+ (right_rep.IsNone() || right_rep.IsInteger32())) {
3855
+ return Representation::Integer32();
3856
+ }
3857
+ return Representation::Double();
3858
+ }
3859
+
3860
+ virtual bool IsCommutative() const { return true; }
3861
+
3862
+ Operation operation() { return operation_; }
3863
+
3864
+ DECLARE_CONCRETE_INSTRUCTION(MathMinMax)
3865
+
3866
+ protected:
3867
+ virtual bool DataEquals(HValue* other) {
3868
+ return other->IsMathMinMax() &&
3869
+ HMathMinMax::cast(other)->operation_ == operation_;
3870
+ }
3871
+
3872
+ virtual Range* InferRange(Zone* zone);
3873
+
3874
+ private:
3875
+ Operation operation_;
3876
+ };
3877
+
3878
+
3359
3879
  class HBitwise: public HBitwiseBinaryOperation {
3360
3880
  public:
3361
3881
  HBitwise(Token::Value op, HValue* context, HValue* left, HValue* right)
@@ -3450,13 +3970,32 @@ class HSar: public HBitwiseBinaryOperation {
3450
3970
  };
3451
3971
 
3452
3972
 
3973
+ class HRor: public HBitwiseBinaryOperation {
3974
+ public:
3975
+ HRor(HValue* context, HValue* left, HValue* right)
3976
+ : HBitwiseBinaryOperation(context, left, right) {
3977
+ ChangeRepresentation(Representation::Integer32());
3978
+ }
3979
+
3980
+ static HInstruction* NewHRor(Zone* zone,
3981
+ HValue* context,
3982
+ HValue* left,
3983
+ HValue* right);
3984
+
3985
+ DECLARE_CONCRETE_INSTRUCTION(Ror)
3986
+
3987
+ protected:
3988
+ virtual bool DataEquals(HValue* other) { return true; }
3989
+ };
3990
+
3991
+
3453
3992
  class HOsrEntry: public HTemplateInstruction<0> {
3454
3993
  public:
3455
- explicit HOsrEntry(int ast_id) : ast_id_(ast_id) {
3994
+ explicit HOsrEntry(BailoutId ast_id) : ast_id_(ast_id) {
3456
3995
  SetGVNFlag(kChangesOsrEntries);
3457
3996
  }
3458
3997
 
3459
- int ast_id() const { return ast_id_; }
3998
+ BailoutId ast_id() const { return ast_id_; }
3460
3999
 
3461
4000
  virtual Representation RequiredInputRepresentation(int index) {
3462
4001
  return Representation::None();
@@ -3465,17 +4004,26 @@ class HOsrEntry: public HTemplateInstruction<0> {
3465
4004
  DECLARE_CONCRETE_INSTRUCTION(OsrEntry)
3466
4005
 
3467
4006
  private:
3468
- int ast_id_;
4007
+ BailoutId ast_id_;
3469
4008
  };
3470
4009
 
3471
4010
 
3472
4011
  class HParameter: public HTemplateInstruction<0> {
3473
4012
  public:
3474
- explicit HParameter(unsigned index) : index_(index) {
4013
+ enum ParameterKind {
4014
+ STACK_PARAMETER,
4015
+ REGISTER_PARAMETER
4016
+ };
4017
+
4018
+ explicit HParameter(unsigned index,
4019
+ ParameterKind kind = STACK_PARAMETER)
4020
+ : index_(index),
4021
+ kind_(kind) {
3475
4022
  set_representation(Representation::Tagged());
3476
4023
  }
3477
4024
 
3478
4025
  unsigned index() const { return index_; }
4026
+ ParameterKind kind() const { return kind_; }
3479
4027
 
3480
4028
  virtual void PrintDataTo(StringStream* stream);
3481
4029
 
@@ -3487,6 +4035,7 @@ class HParameter: public HTemplateInstruction<0> {
3487
4035
 
3488
4036
  private:
3489
4037
  unsigned index_;
4038
+ ParameterKind kind_;
3490
4039
  };
3491
4040
 
3492
4041
 
@@ -3558,13 +4107,15 @@ class HLoadGlobalCell: public HTemplateInstruction<0> {
3558
4107
  SetGVNFlag(kDependsOnGlobalVars);
3559
4108
  }
3560
4109
 
3561
- Handle<JSGlobalPropertyCell> cell() const { return cell_; }
3562
- bool RequiresHoleCheck();
4110
+ Handle<JSGlobalPropertyCell> cell() const { return cell_; }
4111
+ bool RequiresHoleCheck() const;
3563
4112
 
3564
4113
  virtual void PrintDataTo(StringStream* stream);
3565
4114
 
3566
4115
  virtual intptr_t Hashcode() {
3567
- ASSERT(!HEAP->allow_allocation(false));
4116
+ ASSERT_ALLOCATION_DISABLED;
4117
+ // Dereferencing to use the object's raw address for hashing is safe.
4118
+ AllowHandleDereference allow_handle_deref;
3568
4119
  return reinterpret_cast<intptr_t>(*cell_);
3569
4120
  }
3570
4121
 
@@ -3581,6 +4132,8 @@ class HLoadGlobalCell: public HTemplateInstruction<0> {
3581
4132
  }
3582
4133
 
3583
4134
  private:
4135
+ virtual bool IsDeletable() const { return !RequiresHoleCheck(); }
4136
+
3584
4137
  Handle<JSGlobalPropertyCell> cell_;
3585
4138
  PropertyDetails details_;
3586
4139
  };
@@ -3619,6 +4172,106 @@ class HLoadGlobalGeneric: public HTemplateInstruction<2> {
3619
4172
  };
3620
4173
 
3621
4174
 
4175
+ class HAllocateObject: public HTemplateInstruction<1> {
4176
+ public:
4177
+ HAllocateObject(HValue* context, Handle<JSFunction> constructor)
4178
+ : constructor_(constructor) {
4179
+ SetOperandAt(0, context);
4180
+ set_representation(Representation::Tagged());
4181
+ SetGVNFlag(kChangesNewSpacePromotion);
4182
+ }
4183
+
4184
+ // Maximum instance size for which allocations will be inlined.
4185
+ static const int kMaxSize = 64 * kPointerSize;
4186
+
4187
+ HValue* context() { return OperandAt(0); }
4188
+ Handle<JSFunction> constructor() { return constructor_; }
4189
+
4190
+ virtual Representation RequiredInputRepresentation(int index) {
4191
+ return Representation::Tagged();
4192
+ }
4193
+ virtual Handle<Map> GetMonomorphicJSObjectMap() {
4194
+ ASSERT(constructor()->has_initial_map());
4195
+ return Handle<Map>(constructor()->initial_map());
4196
+ }
4197
+ virtual HType CalculateInferredType();
4198
+
4199
+ DECLARE_CONCRETE_INSTRUCTION(AllocateObject)
4200
+
4201
+ private:
4202
+ // TODO(svenpanne) Might be safe, but leave it out until we know for sure.
4203
+ // virtual bool IsDeletable() const { return true; }
4204
+
4205
+ Handle<JSFunction> constructor_;
4206
+ };
4207
+
4208
+
4209
+ class HAllocate: public HTemplateInstruction<2> {
4210
+ public:
4211
+ enum Flags {
4212
+ CAN_ALLOCATE_IN_NEW_SPACE = 1 << 0,
4213
+ CAN_ALLOCATE_IN_OLD_DATA_SPACE = 1 << 1,
4214
+ CAN_ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2,
4215
+ ALLOCATE_DOUBLE_ALIGNED = 1 << 3
4216
+ };
4217
+
4218
+ HAllocate(HValue* context, HValue* size, HType type, Flags flags)
4219
+ : type_(type),
4220
+ flags_(flags) {
4221
+ ASSERT((flags & CAN_ALLOCATE_IN_OLD_DATA_SPACE) == 0); // unimplemented
4222
+ ASSERT((flags & CAN_ALLOCATE_IN_OLD_POINTER_SPACE) == 0); // unimplemented
4223
+ SetOperandAt(0, context);
4224
+ SetOperandAt(1, size);
4225
+ set_representation(Representation::Tagged());
4226
+ SetGVNFlag(kChangesNewSpacePromotion);
4227
+ }
4228
+
4229
+ HValue* context() { return OperandAt(0); }
4230
+ HValue* size() { return OperandAt(1); }
4231
+
4232
+ virtual Representation RequiredInputRepresentation(int index) {
4233
+ if (index == 0) {
4234
+ return Representation::Tagged();
4235
+ } else {
4236
+ return Representation::Integer32();
4237
+ }
4238
+ }
4239
+
4240
+ virtual HType CalculateInferredType();
4241
+
4242
+ bool CanAllocateInNewSpace() const {
4243
+ return (flags_ & CAN_ALLOCATE_IN_NEW_SPACE) != 0;
4244
+ }
4245
+
4246
+ bool CanAllocateInOldDataSpace() const {
4247
+ return (flags_ & CAN_ALLOCATE_IN_OLD_DATA_SPACE) != 0;
4248
+ }
4249
+
4250
+ bool CanAllocateInOldPointerSpace() const {
4251
+ return (flags_ & CAN_ALLOCATE_IN_OLD_POINTER_SPACE) != 0;
4252
+ }
4253
+
4254
+ bool CanAllocateInOldSpace() const {
4255
+ return CanAllocateInOldDataSpace() ||
4256
+ CanAllocateInOldPointerSpace();
4257
+ }
4258
+
4259
+ bool GuaranteedInNewSpace() const {
4260
+ return CanAllocateInNewSpace() && !CanAllocateInOldSpace();
4261
+ }
4262
+
4263
+ bool MustAllocateDoubleAligned() const {
4264
+ return (flags_ & ALLOCATE_DOUBLE_ALIGNED) != 0;
4265
+ }
4266
+
4267
+ DECLARE_CONCRETE_INSTRUCTION(Allocate)
4268
+
4269
+ private:
4270
+ HType type_;
4271
+ Flags flags_;
4272
+ };
4273
+
4274
+
3622
4275
  inline bool StoringValueNeedsWriteBarrier(HValue* value) {
3623
4276
  return !value->type().IsBoolean()
3624
4277
  && !value->type().IsSmi()
@@ -3628,7 +4281,13 @@ inline bool StoringValueNeedsWriteBarrier(HValue* value) {
3628
4281
 
3629
4282
  inline bool ReceiverObjectNeedsWriteBarrier(HValue* object,
3630
4283
  HValue* new_space_dominator) {
3631
- return !object->IsAllocateObject() || (object != new_space_dominator);
4284
+ if (object != new_space_dominator) return true;
4285
+ if (object->IsFastLiteral()) return false;
4286
+ if (object->IsAllocateObject()) return false;
4287
+ if (object->IsAllocate()) {
4288
+ return !HAllocate::cast(object)->GuaranteedInNewSpace();
4289
+ }
4290
+ return true;
3632
4291
  }
3633
4292
 
3634
4293
 
@@ -3741,7 +4400,7 @@ class HLoadContextSlot: public HUnaryOperation {
3741
4400
  return mode_ == kCheckDeoptimize;
3742
4401
  }
3743
4402
 
3744
- bool RequiresHoleCheck() {
4403
+ bool RequiresHoleCheck() const {
3745
4404
  return mode_ != kNoCheck;
3746
4405
  }
3747
4406
 
@@ -3760,6 +4419,8 @@ class HLoadContextSlot: public HUnaryOperation {
3760
4419
  }
3761
4420
 
3762
4421
  private:
4422
+ virtual bool IsDeletable() const { return !RequiresHoleCheck(); }
4423
+
3763
4424
  int slot_index_;
3764
4425
  Mode mode_;
3765
4426
  };
@@ -3852,6 +4513,8 @@ class HLoadNamedField: public HUnaryOperation {
3852
4513
  }
3853
4514
 
3854
4515
  private:
4516
+ virtual bool IsDeletable() const { return true; }
4517
+
3855
4518
  bool is_in_object_;
3856
4519
  int offset_;
3857
4520
  };
@@ -3862,7 +4525,8 @@ class HLoadNamedFieldPolymorphic: public HTemplateInstruction<2> {
3862
4525
  HLoadNamedFieldPolymorphic(HValue* context,
3863
4526
  HValue* object,
3864
4527
  SmallMapList* types,
3865
- Handle<String> name);
4528
+ Handle<String> name,
4529
+ Zone* zone);
3866
4530
 
3867
4531
  HValue* context() { return OperandAt(0); }
3868
4532
  HValue* object() { return OperandAt(1); }
@@ -3947,180 +4611,168 @@ class ArrayInstructionInterface {
3947
4611
  virtual bool IsDehoisted() = 0;
3948
4612
  virtual void SetDehoisted(bool is_dehoisted) = 0;
3949
4613
  virtual ~ArrayInstructionInterface() { };
4614
+
4615
+ static Representation KeyedAccessIndexRequirement(Representation r) {
4616
+ return r.IsInteger32() ? Representation::Integer32()
4617
+ : Representation::Tagged();
4618
+ }
3950
4619
  };
3951
4620
 
3952
4621
 
3953
- enum HoleCheckMode { PERFORM_HOLE_CHECK, OMIT_HOLE_CHECK };
4622
+ enum LoadKeyedHoleMode {
4623
+ NEVER_RETURN_HOLE,
4624
+ ALLOW_RETURN_HOLE
4625
+ };
3954
4626
 
3955
- class HLoadKeyedFastElement
3956
- : public HTemplateInstruction<2>, public ArrayInstructionInterface {
4627
+
4628
+ class HLoadKeyed
4629
+ : public HTemplateInstruction<3>, public ArrayInstructionInterface {
3957
4630
  public:
3958
- HLoadKeyedFastElement(HValue* obj,
3959
- HValue* key,
3960
- HoleCheckMode hole_check_mode = PERFORM_HOLE_CHECK)
3961
- : hole_check_mode_(hole_check_mode),
3962
- index_offset_(0),
3963
- is_dehoisted_(false) {
4631
+ HLoadKeyed(HValue* obj,
4632
+ HValue* key,
4633
+ HValue* dependency,
4634
+ ElementsKind elements_kind,
4635
+ LoadKeyedHoleMode mode = NEVER_RETURN_HOLE)
4636
+ : bit_field_(0) {
4637
+ bit_field_ = ElementsKindField::encode(elements_kind) |
4638
+ HoleModeField::encode(mode);
4639
+
3964
4640
  SetOperandAt(0, obj);
3965
4641
  SetOperandAt(1, key);
3966
- set_representation(Representation::Tagged());
3967
- SetGVNFlag(kDependsOnArrayElements);
3968
- SetFlag(kUseGVN);
3969
- }
3970
-
3971
- HValue* object() { return OperandAt(0); }
3972
- HValue* key() { return OperandAt(1); }
3973
- uint32_t index_offset() { return index_offset_; }
3974
- void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; }
3975
- HValue* GetKey() { return key(); }
3976
- void SetKey(HValue* key) { SetOperandAt(1, key); }
3977
- bool IsDehoisted() { return is_dehoisted_; }
3978
- void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; }
4642
+ SetOperandAt(2, dependency != NULL ? dependency : obj);
3979
4643
 
3980
- virtual Representation RequiredInputRepresentation(int index) {
3981
- // The key is supposed to be Integer32.
3982
- return index == 0
3983
- ? Representation::Tagged()
3984
- : Representation::Integer32();
3985
- }
3986
-
3987
- virtual void PrintDataTo(StringStream* stream);
3988
-
3989
- bool RequiresHoleCheck();
4644
+ if (!is_external()) {
4645
+ // I can detect the case between storing double (holey and fast) and
4646
+ // smi/object by looking at elements_kind_.
4647
+ ASSERT(IsFastSmiOrObjectElementsKind(elements_kind) ||
4648
+ IsFastDoubleElementsKind(elements_kind));
3990
4649
 
3991
- DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastElement)
4650
+ if (IsFastSmiOrObjectElementsKind(elements_kind)) {
4651
+ if (IsFastSmiElementsKind(elements_kind)) {
4652
+ set_type(HType::Smi());
4653
+ }
3992
4654
 
3993
- protected:
3994
- virtual bool DataEquals(HValue* other) {
3995
- if (!other->IsLoadKeyedFastElement()) return false;
3996
- HLoadKeyedFastElement* other_load = HLoadKeyedFastElement::cast(other);
3997
- if (is_dehoisted_ && index_offset_ != other_load->index_offset_)
3998
- return false;
3999
- return hole_check_mode_ == other_load->hole_check_mode_;
4000
- }
4001
-
4002
- private:
4003
- HoleCheckMode hole_check_mode_;
4004
- uint32_t index_offset_;
4005
- bool is_dehoisted_;
4006
- };
4655
+ set_representation(Representation::Tagged());
4656
+ SetGVNFlag(kDependsOnArrayElements);
4657
+ } else {
4658
+ set_representation(Representation::Double());
4659
+ SetGVNFlag(kDependsOnDoubleArrayElements);
4660
+ }
4661
+ } else {
4662
+ if (elements_kind == EXTERNAL_FLOAT_ELEMENTS ||
4663
+ elements_kind == EXTERNAL_DOUBLE_ELEMENTS) {
4664
+ set_representation(Representation::Double());
4665
+ } else {
4666
+ set_representation(Representation::Integer32());
4667
+ }
4007
4668
 
4669
+ SetGVNFlag(kDependsOnSpecializedArrayElements);
4670
+ // Native code could change the specialized array.
4671
+ SetGVNFlag(kDependsOnCalls);
4672
+ }
4008
4673
 
4009
- class HLoadKeyedFastDoubleElement
4010
- : public HTemplateInstruction<2>, public ArrayInstructionInterface {
4011
- public:
4012
- HLoadKeyedFastDoubleElement(
4013
- HValue* elements,
4014
- HValue* key,
4015
- HoleCheckMode hole_check_mode = PERFORM_HOLE_CHECK)
4016
- : index_offset_(0),
4017
- is_dehoisted_(false),
4018
- hole_check_mode_(hole_check_mode) {
4019
- SetOperandAt(0, elements);
4020
- SetOperandAt(1, key);
4021
- set_representation(Representation::Double());
4022
- SetGVNFlag(kDependsOnDoubleArrayElements);
4023
4674
  SetFlag(kUseGVN);
4024
- }
4675
+ }
4025
4676
 
4677
+ bool is_external() const {
4678
+ return IsExternalArrayElementsKind(elements_kind());
4679
+ }
4026
4680
  HValue* elements() { return OperandAt(0); }
4027
4681
  HValue* key() { return OperandAt(1); }
4028
- uint32_t index_offset() { return index_offset_; }
4029
- void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; }
4682
+ HValue* dependency() {
4683
+ ASSERT(HasDependency());
4684
+ return OperandAt(2);
4685
+ }
4686
+ bool HasDependency() const { return OperandAt(0) != OperandAt(2); }
4687
+ uint32_t index_offset() { return IndexOffsetField::decode(bit_field_); }
4688
+ void SetIndexOffset(uint32_t index_offset) {
4689
+ bit_field_ = IndexOffsetField::update(bit_field_, index_offset);
4690
+ }
4030
4691
  HValue* GetKey() { return key(); }
4031
4692
  void SetKey(HValue* key) { SetOperandAt(1, key); }
4032
- bool IsDehoisted() { return is_dehoisted_; }
4033
- void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; }
4034
-
4035
- virtual Representation RequiredInputRepresentation(int index) {
4036
- // The key is supposed to be Integer32.
4037
- return index == 0
4038
- ? Representation::Tagged()
4039
- : Representation::Integer32();
4693
+ bool IsDehoisted() { return IsDehoistedField::decode(bit_field_); }
4694
+ void SetDehoisted(bool is_dehoisted) {
4695
+ bit_field_ = IsDehoistedField::update(bit_field_, is_dehoisted);
4040
4696
  }
4041
-
4042
- bool RequiresHoleCheck() {
4043
- return hole_check_mode_ == PERFORM_HOLE_CHECK;
4697
+ ElementsKind elements_kind() const {
4698
+ return ElementsKindField::decode(bit_field_);
4044
4699
  }
4045
-
4046
- virtual void PrintDataTo(StringStream* stream);
4047
-
4048
- DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastDoubleElement)
4049
-
4050
- protected:
4051
- virtual bool DataEquals(HValue* other) {
4052
- if (!other->IsLoadKeyedFastDoubleElement()) return false;
4053
- HLoadKeyedFastDoubleElement* other_load =
4054
- HLoadKeyedFastDoubleElement::cast(other);
4055
- return hole_check_mode_ == other_load->hole_check_mode_;
4700
+ LoadKeyedHoleMode hole_mode() const {
4701
+ return HoleModeField::decode(bit_field_);
4056
4702
  }
4057
4703
 
4058
- private:
4059
- uint32_t index_offset_;
4060
- bool is_dehoisted_;
4061
- HoleCheckMode hole_check_mode_;
4062
- };
4063
-
4064
-
4065
- class HLoadKeyedSpecializedArrayElement
4066
- : public HTemplateInstruction<2>, public ArrayInstructionInterface {
4067
- public:
4068
- HLoadKeyedSpecializedArrayElement(HValue* external_elements,
4069
- HValue* key,
4070
- ElementsKind elements_kind)
4071
- : elements_kind_(elements_kind),
4072
- index_offset_(0),
4073
- is_dehoisted_(false) {
4074
- SetOperandAt(0, external_elements);
4075
- SetOperandAt(1, key);
4076
- if (elements_kind == EXTERNAL_FLOAT_ELEMENTS ||
4077
- elements_kind == EXTERNAL_DOUBLE_ELEMENTS) {
4078
- set_representation(Representation::Double());
4079
- } else {
4080
- set_representation(Representation::Integer32());
4704
+ virtual Representation RequiredInputRepresentation(int index) {
4705
+ // kind_fast: tagged[int32] (none)
4706
+ // kind_double: tagged[int32] (none)
4707
+ // kind_external: external[int32] (none)
4708
+ if (index == 0) {
4709
+ return is_external() ? Representation::External()
4710
+ : Representation::Tagged();
4081
4711
  }
4082
- SetGVNFlag(kDependsOnSpecializedArrayElements);
4083
- // Native code could change the specialized array.
4084
- SetGVNFlag(kDependsOnCalls);
4085
- SetFlag(kUseGVN);
4712
+ if (index == 1) {
4713
+ return ArrayInstructionInterface::KeyedAccessIndexRequirement(
4714
+ OperandAt(1)->representation());
4715
+ }
4716
+ return Representation::None();
4086
4717
  }
4087
4718
 
4088
- virtual void PrintDataTo(StringStream* stream);
4089
-
4090
- virtual Representation RequiredInputRepresentation(int index) {
4091
- // The key is supposed to be Integer32, but the base pointer
4092
- // for the element load is a naked pointer.
4093
- return index == 0
4094
- ? Representation::External()
4095
- : Representation::Integer32();
4719
+ virtual Representation observed_input_representation(int index) {
4720
+ return RequiredInputRepresentation(index);
4096
4721
  }
4097
4722
 
4098
- HValue* external_pointer() { return OperandAt(0); }
4099
- HValue* key() { return OperandAt(1); }
4100
- ElementsKind elements_kind() const { return elements_kind_; }
4101
- uint32_t index_offset() { return index_offset_; }
4102
- void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; }
4103
- HValue* GetKey() { return key(); }
4104
- void SetKey(HValue* key) { SetOperandAt(1, key); }
4105
- bool IsDehoisted() { return is_dehoisted_; }
4106
- void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; }
4723
+ virtual void PrintDataTo(StringStream* stream);
4724
+
4725
+ bool UsesMustHandleHole() const;
4726
+ bool RequiresHoleCheck() const;
4107
4727
 
4108
4728
  virtual Range* InferRange(Zone* zone);
4109
4729
 
4110
- DECLARE_CONCRETE_INSTRUCTION(LoadKeyedSpecializedArrayElement)
4730
+ DECLARE_CONCRETE_INSTRUCTION(LoadKeyed)
4111
4731
 
4112
4732
  protected:
4113
4733
  virtual bool DataEquals(HValue* other) {
4114
- if (!other->IsLoadKeyedSpecializedArrayElement()) return false;
4115
- HLoadKeyedSpecializedArrayElement* cast_other =
4116
- HLoadKeyedSpecializedArrayElement::cast(other);
4117
- return elements_kind_ == cast_other->elements_kind();
4734
+ if (!other->IsLoadKeyed()) return false;
4735
+ HLoadKeyed* other_load = HLoadKeyed::cast(other);
4736
+
4737
+ if (IsDehoisted() && index_offset() != other_load->index_offset())
4738
+ return false;
4739
+ return elements_kind() == other_load->elements_kind();
4118
4740
  }
4119
4741
 
4120
4742
  private:
4121
- ElementsKind elements_kind_;
4122
- uint32_t index_offset_;
4123
- bool is_dehoisted_;
4743
+ virtual bool IsDeletable() const {
4744
+ return !RequiresHoleCheck();
4745
+ }
4746
+
4747
+ // Establish some checks around our packed fields
4748
+ enum LoadKeyedBits {
4749
+ kBitsForElementsKind = 5,
4750
+ kBitsForHoleMode = 1,
4751
+ kBitsForIndexOffset = 25,
4752
+ kBitsForIsDehoisted = 1,
4753
+
4754
+ kStartElementsKind = 0,
4755
+ kStartHoleMode = kStartElementsKind + kBitsForElementsKind,
4756
+ kStartIndexOffset = kStartHoleMode + kBitsForHoleMode,
4757
+ kStartIsDehoisted = kStartIndexOffset + kBitsForIndexOffset
4758
+ };
4759
+
4760
+ STATIC_ASSERT((kBitsForElementsKind + kBitsForIndexOffset +
4761
+ kBitsForIsDehoisted) <= sizeof(uint32_t)*8);
4762
+ STATIC_ASSERT(kElementsKindCount <= (1 << kBitsForElementsKind));
4763
+ class ElementsKindField:
4764
+ public BitField<ElementsKind, kStartElementsKind, kBitsForElementsKind>
4765
+ {}; // NOLINT
4766
+ class HoleModeField:
4767
+ public BitField<LoadKeyedHoleMode, kStartHoleMode, kBitsForHoleMode>
4768
+ {}; // NOLINT
4769
+ class IndexOffsetField:
4770
+ public BitField<uint32_t, kStartIndexOffset, kBitsForIndexOffset>
4771
+ {}; // NOLINT
4772
+ class IsDehoistedField:
4773
+ public BitField<bool, kStartIsDehoisted, kBitsForIsDehoisted>
4774
+ {}; // NOLINT
4775
+ uint32_t bit_field_;
4124
4776
  };
4125
4777
 
4126
4778
 
@@ -4141,6 +4793,7 @@ class HLoadKeyedGeneric: public HTemplateInstruction<3> {
4141
4793
  virtual void PrintDataTo(StringStream* stream);
4142
4794
 
4143
4795
  virtual Representation RequiredInputRepresentation(int index) {
4796
+ // tagged[tagged]
4144
4797
  return Representation::Tagged();
4145
4798
  }
4146
4799
 
@@ -4246,83 +4899,83 @@ class HStoreNamedGeneric: public HTemplateInstruction<3> {
4246
4899
  };
4247
4900
 
4248
4901
 
4249
- class HStoreKeyedFastElement
4902
+ class HStoreKeyed
4250
4903
  : public HTemplateInstruction<3>, public ArrayInstructionInterface {
4251
4904
  public:
4252
- HStoreKeyedFastElement(HValue* obj, HValue* key, HValue* val,
4253
- ElementsKind elements_kind = FAST_ELEMENTS)
4254
- : elements_kind_(elements_kind), index_offset_(0), is_dehoisted_(false) {
4905
+ HStoreKeyed(HValue* obj, HValue* key, HValue* val,
4906
+ ElementsKind elements_kind)
4907
+ : elements_kind_(elements_kind),
4908
+ index_offset_(0),
4909
+ is_dehoisted_(false),
4910
+ new_space_dominator_(NULL) {
4255
4911
  SetOperandAt(0, obj);
4256
4912
  SetOperandAt(1, key);
4257
4913
  SetOperandAt(2, val);
4258
- SetGVNFlag(kChangesArrayElements);
4259
- }
4260
-
4261
- virtual Representation RequiredInputRepresentation(int index) {
4262
- // The key is supposed to be Integer32.
4263
- return index == 1
4264
- ? Representation::Integer32()
4265
- : Representation::Tagged();
4266
- }
4267
-
4268
- HValue* object() { return OperandAt(0); }
4269
- HValue* key() { return OperandAt(1); }
4270
- HValue* value() { return OperandAt(2); }
4271
- bool value_is_smi() {
4272
- return IsFastSmiElementsKind(elements_kind_);
4273
- }
4274
- uint32_t index_offset() { return index_offset_; }
4275
- void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; }
4276
- HValue* GetKey() { return key(); }
4277
- void SetKey(HValue* key) { SetOperandAt(1, key); }
4278
- bool IsDehoisted() { return is_dehoisted_; }
4279
- void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; }
4280
4914
 
4281
- bool NeedsWriteBarrier() {
4282
- if (value_is_smi()) {
4283
- return false;
4915
+ if (IsFastObjectElementsKind(elements_kind)) {
4916
+ SetFlag(kTrackSideEffectDominators);
4917
+ SetGVNFlag(kDependsOnNewSpacePromotion);
4918
+ }
4919
+ if (is_external()) {
4920
+ SetGVNFlag(kChangesSpecializedArrayElements);
4921
+ } else if (IsFastDoubleElementsKind(elements_kind)) {
4922
+ SetGVNFlag(kChangesDoubleArrayElements);
4923
+ SetFlag(kDeoptimizeOnUndefined);
4284
4924
  } else {
4285
- return StoringValueNeedsWriteBarrier(value());
4925
+ SetGVNFlag(kChangesArrayElements);
4286
4926
  }
4287
- }
4288
4927
 
4289
- virtual void PrintDataTo(StringStream* stream);
4928
+ // EXTERNAL_{UNSIGNED_,}{BYTE,SHORT,INT}_ELEMENTS are truncating.
4929
+ if (elements_kind >= EXTERNAL_BYTE_ELEMENTS &&
4930
+ elements_kind <= EXTERNAL_UNSIGNED_INT_ELEMENTS) {
4931
+ SetFlag(kTruncatingToInt32);
4932
+ }
4933
+ }
4290
4934
 
4291
- DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastElement)
4935
+ virtual Representation RequiredInputRepresentation(int index) {
4936
+ // kind_fast: tagged[int32] = tagged
4937
+ // kind_double: tagged[int32] = double
4938
+ // kind_external: external[int32] = (double | int32)
4939
+ if (index == 0) {
4940
+ return is_external() ? Representation::External()
4941
+ : Representation::Tagged();
4942
+ } else if (index == 1) {
4943
+ return ArrayInstructionInterface::KeyedAccessIndexRequirement(
4944
+ OperandAt(1)->representation());
4945
+ }
4292
4946
 
4293
- private:
4294
- ElementsKind elements_kind_;
4295
- uint32_t index_offset_;
4296
- bool is_dehoisted_;
4297
- };
4947
+ ASSERT_EQ(index, 2);
4948
+ if (IsDoubleOrFloatElementsKind(elements_kind())) {
4949
+ return Representation::Double();
4950
+ }
4298
4951
 
4952
+ return is_external() ? Representation::Integer32()
4953
+ : Representation::Tagged();
4954
+ }
4299
4955
 
4300
- class HStoreKeyedFastDoubleElement
4301
- : public HTemplateInstruction<3>, public ArrayInstructionInterface {
4302
- public:
4303
- HStoreKeyedFastDoubleElement(HValue* elements,
4304
- HValue* key,
4305
- HValue* val)
4306
- : index_offset_(0), is_dehoisted_(false) {
4307
- SetOperandAt(0, elements);
4308
- SetOperandAt(1, key);
4309
- SetOperandAt(2, val);
4310
- SetGVNFlag(kChangesDoubleArrayElements);
4956
+ bool is_external() const {
4957
+ return IsExternalArrayElementsKind(elements_kind());
4311
4958
  }
4312
4959
 
4313
- virtual Representation RequiredInputRepresentation(int index) {
4314
- if (index == 1) {
4315
- return Representation::Integer32();
4316
- } else if (index == 2) {
4960
+ virtual Representation observed_input_representation(int index) {
4961
+ if (index < 2) return RequiredInputRepresentation(index);
4962
+ if (IsDoubleOrFloatElementsKind(elements_kind())) {
4317
4963
  return Representation::Double();
4318
- } else {
4319
- return Representation::Tagged();
4320
4964
  }
4965
+ if (is_external()) {
4966
+ return Representation::Integer32();
4967
+ }
4968
+ // For fast object elements kinds, don't assume anything.
4969
+ return Representation::None();
4321
4970
  }
4322
4971
 
4323
4972
  HValue* elements() { return OperandAt(0); }
4324
4973
  HValue* key() { return OperandAt(1); }
4325
4974
  HValue* value() { return OperandAt(2); }
4975
+ bool value_is_smi() const {
4976
+ return IsFastSmiElementsKind(elements_kind_);
4977
+ }
4978
+ ElementsKind elements_kind() const { return elements_kind_; }
4326
4979
  uint32_t index_offset() { return index_offset_; }
4327
4980
  void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; }
4328
4981
  HValue* GetKey() { return key(); }
@@ -4330,70 +4983,33 @@ class HStoreKeyedFastDoubleElement
4330
4983
  bool IsDehoisted() { return is_dehoisted_; }
4331
4984
  void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; }
4332
4985
 
4333
- bool NeedsWriteBarrier() {
4334
- return StoringValueNeedsWriteBarrier(value());
4335
- }
4336
-
4337
- bool NeedsCanonicalization();
4338
-
4339
- virtual void PrintDataTo(StringStream* stream);
4340
-
4341
- DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastDoubleElement)
4342
-
4343
- private:
4344
- uint32_t index_offset_;
4345
- bool is_dehoisted_;
4346
- };
4347
-
4348
-
4349
- class HStoreKeyedSpecializedArrayElement
4350
- : public HTemplateInstruction<3>, public ArrayInstructionInterface {
4351
- public:
4352
- HStoreKeyedSpecializedArrayElement(HValue* external_elements,
4353
- HValue* key,
4354
- HValue* val,
4355
- ElementsKind elements_kind)
4356
- : elements_kind_(elements_kind), index_offset_(0), is_dehoisted_(false) {
4357
- SetGVNFlag(kChangesSpecializedArrayElements);
4358
- SetOperandAt(0, external_elements);
4359
- SetOperandAt(1, key);
4360
- SetOperandAt(2, val);
4986
+ virtual void SetSideEffectDominator(GVNFlag side_effect, HValue* dominator) {
4987
+ ASSERT(side_effect == kChangesNewSpacePromotion);
4988
+ new_space_dominator_ = dominator;
4361
4989
  }
4362
4990
 
4363
- virtual void PrintDataTo(StringStream* stream);
4991
+ HValue* new_space_dominator() const { return new_space_dominator_; }
4364
4992
 
4365
- virtual Representation RequiredInputRepresentation(int index) {
4366
- if (index == 0) {
4367
- return Representation::External();
4993
+ bool NeedsWriteBarrier() {
4994
+ if (value_is_smi()) {
4995
+ return false;
4368
4996
  } else {
4369
- bool float_or_double_elements =
4370
- elements_kind() == EXTERNAL_FLOAT_ELEMENTS ||
4371
- elements_kind() == EXTERNAL_DOUBLE_ELEMENTS;
4372
- if (index == 2 && float_or_double_elements) {
4373
- return Representation::Double();
4374
- } else {
4375
- return Representation::Integer32();
4376
- }
4997
+ return StoringValueNeedsWriteBarrier(value()) &&
4998
+ ReceiverObjectNeedsWriteBarrier(elements(), new_space_dominator());
4377
4999
  }
4378
5000
  }
4379
5001
 
4380
- HValue* external_pointer() { return OperandAt(0); }
4381
- HValue* key() { return OperandAt(1); }
4382
- HValue* value() { return OperandAt(2); }
4383
- ElementsKind elements_kind() const { return elements_kind_; }
4384
- uint32_t index_offset() { return index_offset_; }
4385
- void SetIndexOffset(uint32_t index_offset) { index_offset_ = index_offset; }
4386
- HValue* GetKey() { return key(); }
4387
- void SetKey(HValue* key) { SetOperandAt(1, key); }
4388
- bool IsDehoisted() { return is_dehoisted_; }
4389
- void SetDehoisted(bool is_dehoisted) { is_dehoisted_ = is_dehoisted; }
5002
+ bool NeedsCanonicalization();
5003
+
5004
+ virtual void PrintDataTo(StringStream* stream);
4390
5005
 
4391
- DECLARE_CONCRETE_INSTRUCTION(StoreKeyedSpecializedArrayElement)
5006
+ DECLARE_CONCRETE_INSTRUCTION(StoreKeyed)
4392
5007
 
4393
5008
  private:
4394
5009
  ElementsKind elements_kind_;
4395
5010
  uint32_t index_offset_;
4396
5011
  bool is_dehoisted_;
5012
+ HValue* new_space_dominator_;
4397
5013
  };
4398
5014
 
4399
5015
 
@@ -4419,6 +5035,7 @@ class HStoreKeyedGeneric: public HTemplateInstruction<4> {
4419
5035
  StrictModeFlag strict_mode_flag() { return strict_mode_flag_; }
4420
5036
 
4421
5037
  virtual Representation RequiredInputRepresentation(int index) {
5038
+ // tagged[tagged] = tagged
4422
5039
  return Representation::Tagged();
4423
5040
  }
4424
5041
 
@@ -4431,19 +5048,19 @@ class HStoreKeyedGeneric: public HTemplateInstruction<4> {
4431
5048
  };
4432
5049
 
4433
5050
 
4434
- class HTransitionElementsKind: public HTemplateInstruction<1> {
5051
+ class HTransitionElementsKind: public HTemplateInstruction<2> {
4435
5052
  public:
4436
- HTransitionElementsKind(HValue* object,
5053
+ HTransitionElementsKind(HValue* context,
5054
+ HValue* object,
4437
5055
  Handle<Map> original_map,
4438
5056
  Handle<Map> transitioned_map)
4439
5057
  : original_map_(original_map),
4440
- transitioned_map_(transitioned_map) {
5058
+ transitioned_map_(transitioned_map),
5059
+ from_kind_(original_map->elements_kind()),
5060
+ to_kind_(transitioned_map->elements_kind()) {
4441
5061
  SetOperandAt(0, object);
5062
+ SetOperandAt(1, context);
4442
5063
  SetFlag(kUseGVN);
4443
- // Don't set GVN DependOn flags here. That would defeat GVN's detection of
4444
- // congruent HTransitionElementsKind instructions. Instruction hoisting
4445
- // handles HTransitionElementsKind instruction specially, explicitly adding
4446
- // DependsOn flags during its dependency calculations.
4447
5064
  SetGVNFlag(kChangesElementsKind);
4448
5065
  if (original_map->has_fast_double_elements()) {
4449
5066
  SetGVNFlag(kChangesElementsPointer);
@@ -4461,8 +5078,11 @@ class HTransitionElementsKind: public HTemplateInstruction<1> {
4461
5078
  }
4462
5079
 
4463
5080
  HValue* object() { return OperandAt(0); }
5081
+ HValue* context() { return OperandAt(1); }
4464
5082
  Handle<Map> original_map() { return original_map_; }
4465
5083
  Handle<Map> transitioned_map() { return transitioned_map_; }
5084
+ ElementsKind from_kind() { return from_kind_; }
5085
+ ElementsKind to_kind() { return to_kind_; }
4466
5086
 
4467
5087
  virtual void PrintDataTo(StringStream* stream);
4468
5088
 
@@ -4478,6 +5098,8 @@ class HTransitionElementsKind: public HTemplateInstruction<1> {
4478
5098
  private:
4479
5099
  Handle<Map> original_map_;
4480
5100
  Handle<Map> transitioned_map_;
5101
+ ElementsKind from_kind_;
5102
+ ElementsKind to_kind_;
4481
5103
  };
4482
5104
 
4483
5105
 
@@ -4488,6 +5110,7 @@ class HStringAdd: public HBinaryOperation {
4488
5110
  set_representation(Representation::Tagged());
4489
5111
  SetFlag(kUseGVN);
4490
5112
  SetGVNFlag(kDependsOnMaps);
5113
+ SetGVNFlag(kChangesNewSpacePromotion);
4491
5114
  }
4492
5115
 
4493
5116
  virtual Representation RequiredInputRepresentation(int index) {
@@ -4502,6 +5125,10 @@ class HStringAdd: public HBinaryOperation {
4502
5125
 
4503
5126
  protected:
4504
5127
  virtual bool DataEquals(HValue* other) { return true; }
5128
+
5129
+ // TODO(svenpanne) Might be safe, but leave it out until we know for sure.
5130
+ // private:
5131
+ // virtual bool IsDeletable() const { return true; }
4505
5132
  };
4506
5133
 
4507
5134
 
@@ -4536,6 +5163,10 @@ class HStringCharCodeAt: public HTemplateInstruction<3> {
4536
5163
  virtual Range* InferRange(Zone* zone) {
4537
5164
  return new(zone) Range(0, String::kMaxUtf16CodeUnit);
4538
5165
  }
5166
+
5167
+ // TODO(svenpanne) Might be safe, but leave it out until we know for sure.
5168
+ // private:
5169
+ // virtual bool IsDeletable() const { return true; }
4539
5170
  };
4540
5171
 
4541
5172
 
@@ -4562,6 +5193,10 @@ class HStringCharFromCode: public HTemplateInstruction<2> {
4562
5193
  virtual bool DataEquals(HValue* other) { return true; }
4563
5194
 
4564
5195
  DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode)
5196
+
5197
+ // TODO(svenpanne) Might be safe, but leave it out until we know for sure.
5198
+ // private:
5199
+ // virtual bool IsDeletable() const { return true; }
4565
5200
  };
4566
5201
 
4567
5202
 
@@ -4590,50 +5225,38 @@ class HStringLength: public HUnaryOperation {
4590
5225
  virtual Range* InferRange(Zone* zone) {
4591
5226
  return new(zone) Range(0, String::kMaxLength);
4592
5227
  }
4593
- };
4594
-
4595
-
4596
- class HAllocateObject: public HTemplateInstruction<1> {
4597
- public:
4598
- HAllocateObject(HValue* context, Handle<JSFunction> constructor)
4599
- : constructor_(constructor) {
4600
- SetOperandAt(0, context);
4601
- set_representation(Representation::Tagged());
4602
- SetGVNFlag(kChangesNewSpacePromotion);
4603
- }
4604
-
4605
- // Maximum instance size for which allocations will be inlined.
4606
- static const int kMaxSize = 64 * kPointerSize;
4607
-
4608
- HValue* context() { return OperandAt(0); }
4609
- Handle<JSFunction> constructor() { return constructor_; }
4610
-
4611
- virtual Representation RequiredInputRepresentation(int index) {
4612
- return Representation::Tagged();
4613
- }
4614
- virtual HType CalculateInferredType();
4615
-
4616
- DECLARE_CONCRETE_INSTRUCTION(AllocateObject)
4617
5228
 
4618
5229
  private:
4619
- Handle<JSFunction> constructor_;
5230
+ virtual bool IsDeletable() const { return true; }
4620
5231
  };
4621
5232
 
4622
5233
 
4623
5234
  template <int V>
4624
5235
  class HMaterializedLiteral: public HTemplateInstruction<V> {
4625
5236
  public:
5237
+ HMaterializedLiteral<V>(int index, int depth, AllocationSiteMode mode)
5238
+ : literal_index_(index), depth_(depth), allocation_site_mode_(mode) {
5239
+ this->set_representation(Representation::Tagged());
5240
+ }
5241
+
4626
5242
  HMaterializedLiteral<V>(int index, int depth)
4627
- : literal_index_(index), depth_(depth) {
5243
+ : literal_index_(index), depth_(depth),
5244
+ allocation_site_mode_(DONT_TRACK_ALLOCATION_SITE) {
4628
5245
  this->set_representation(Representation::Tagged());
4629
5246
  }
4630
5247
 
4631
5248
  int literal_index() const { return literal_index_; }
4632
5249
  int depth() const { return depth_; }
5250
+ AllocationSiteMode allocation_site_mode() const {
5251
+ return allocation_site_mode_;
5252
+ }
4633
5253
 
4634
5254
  private:
5255
+ virtual bool IsDeletable() const { return true; }
5256
+
4635
5257
  int literal_index_;
4636
5258
  int depth_;
5259
+ AllocationSiteMode allocation_site_mode_;
4637
5260
  };
4638
5261
 
4639
5262
 
@@ -4643,8 +5266,9 @@ class HFastLiteral: public HMaterializedLiteral<1> {
4643
5266
  Handle<JSObject> boilerplate,
4644
5267
  int total_size,
4645
5268
  int literal_index,
4646
- int depth)
4647
- : HMaterializedLiteral<1>(literal_index, depth),
5269
+ int depth,
5270
+ AllocationSiteMode mode)
5271
+ : HMaterializedLiteral<1>(literal_index, depth, mode),
4648
5272
  boilerplate_(boilerplate),
4649
5273
  total_size_(total_size) {
4650
5274
  SetOperandAt(0, context);
@@ -4659,10 +5283,12 @@ class HFastLiteral: public HMaterializedLiteral<1> {
4659
5283
  HValue* context() { return OperandAt(0); }
4660
5284
  Handle<JSObject> boilerplate() const { return boilerplate_; }
4661
5285
  int total_size() const { return total_size_; }
4662
-
4663
5286
  virtual Representation RequiredInputRepresentation(int index) {
4664
5287
  return Representation::Tagged();
4665
5288
  }
5289
+ virtual Handle<Map> GetMonomorphicJSObjectMap() {
5290
+ return Handle<Map>(boilerplate()->map());
5291
+ }
4666
5292
  virtual HType CalculateInferredType();
4667
5293
 
4668
5294
  DECLARE_CONCRETE_INSTRUCTION(FastLiteral)
@@ -4679,8 +5305,9 @@ class HArrayLiteral: public HMaterializedLiteral<1> {
4679
5305
  Handle<HeapObject> boilerplate_object,
4680
5306
  int length,
4681
5307
  int literal_index,
4682
- int depth)
4683
- : HMaterializedLiteral<1>(literal_index, depth),
5308
+ int depth,
5309
+ AllocationSiteMode mode)
5310
+ : HMaterializedLiteral<1>(literal_index, depth, mode),
4684
5311
  length_(length),
4685
5312
  boilerplate_object_(boilerplate_object) {
4686
5313
  SetOperandAt(0, context);
@@ -4696,7 +5323,6 @@ class HArrayLiteral: public HMaterializedLiteral<1> {
4696
5323
  }
4697
5324
  Handle<HeapObject> boilerplate_object() const { return boilerplate_object_; }
4698
5325
  int length() const { return length_; }
4699
-
4700
5326
  bool IsCopyOnWrite() const;
4701
5327
 
4702
5328
  virtual Representation RequiredInputRepresentation(int index) {
@@ -4752,10 +5378,12 @@ class HObjectLiteral: public HMaterializedLiteral<1> {
4752
5378
  class HRegExpLiteral: public HMaterializedLiteral<1> {
4753
5379
  public:
4754
5380
  HRegExpLiteral(HValue* context,
5381
+ Handle<FixedArray> literals,
4755
5382
  Handle<String> pattern,
4756
5383
  Handle<String> flags,
4757
5384
  int literal_index)
4758
5385
  : HMaterializedLiteral<1>(literal_index, 0),
5386
+ literals_(literals),
4759
5387
  pattern_(pattern),
4760
5388
  flags_(flags) {
4761
5389
  SetOperandAt(0, context);
@@ -4763,6 +5391,7 @@ class HRegExpLiteral: public HMaterializedLiteral<1> {
4763
5391
  }
4764
5392
 
4765
5393
  HValue* context() { return OperandAt(0); }
5394
+ Handle<FixedArray> literals() { return literals_; }
4766
5395
  Handle<String> pattern() { return pattern_; }
4767
5396
  Handle<String> flags() { return flags_; }
4768
5397
 
@@ -4774,6 +5403,7 @@ class HRegExpLiteral: public HMaterializedLiteral<1> {
4774
5403
  DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral)
4775
5404
 
4776
5405
  private:
5406
+ Handle<FixedArray> literals_;
4777
5407
  Handle<String> pattern_;
4778
5408
  Handle<String> flags_;
4779
5409
  };
@@ -4803,6 +5433,8 @@ class HFunctionLiteral: public HTemplateInstruction<1> {
4803
5433
  bool pretenure() const { return pretenure_; }
4804
5434
 
4805
5435
  private:
5436
+ virtual bool IsDeletable() const { return true; }
5437
+
4806
5438
  Handle<SharedFunctionInfo> shared_info_;
4807
5439
  bool pretenure_;
4808
5440
  };
@@ -4819,7 +5451,6 @@ class HTypeof: public HTemplateInstruction<2> {
4819
5451
  HValue* context() { return OperandAt(0); }
4820
5452
  HValue* value() { return OperandAt(1); }
4821
5453
 
4822
- virtual HValue* Canonicalize();
4823
5454
  virtual void PrintDataTo(StringStream* stream);
4824
5455
 
4825
5456
  virtual Representation RequiredInputRepresentation(int index) {
@@ -4827,6 +5458,25 @@ class HTypeof: public HTemplateInstruction<2> {
4827
5458
  }
4828
5459
 
4829
5460
  DECLARE_CONCRETE_INSTRUCTION(Typeof)
5461
+
5462
+ private:
5463
+ virtual bool IsDeletable() const { return true; }
5464
+ };
5465
+
5466
+
5467
+ class HTrapAllocationMemento : public HTemplateInstruction<1> {
5468
+ public:
5469
+ explicit HTrapAllocationMemento(HValue* obj) {
5470
+ SetOperandAt(0, obj);
5471
+ }
5472
+
5473
+ virtual Representation RequiredInputRepresentation(int index) {
5474
+ return Representation::Tagged();
5475
+ }
5476
+
5477
+ HValue* object() { return OperandAt(0); }
5478
+
5479
+ DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento)
4830
5480
  };
4831
5481
 
4832
5482
 
@@ -4845,6 +5495,9 @@ class HToFastProperties: public HUnaryOperation {
4845
5495
  }
4846
5496
 
4847
5497
  DECLARE_CONCRETE_INSTRUCTION(ToFastProperties)
5498
+
5499
+ private:
5500
+ virtual bool IsDeletable() const { return true; }
4848
5501
  };
4849
5502
 
4850
5503
 
@@ -4859,6 +5512,9 @@ class HValueOf: public HUnaryOperation {
4859
5512
  }
4860
5513
 
4861
5514
  DECLARE_CONCRETE_INSTRUCTION(ValueOf)
5515
+
5516
+ private:
5517
+ virtual bool IsDeletable() const { return true; }
4862
5518
  };
4863
5519
 
4864
5520
 
@@ -4882,6 +5538,33 @@ class HDateField: public HUnaryOperation {
4882
5538
  };
4883
5539
 
4884
5540
 
5541
+ class HSeqStringSetChar: public HTemplateInstruction<3> {
5542
+ public:
5543
+ HSeqStringSetChar(String::Encoding encoding,
5544
+ HValue* string,
5545
+ HValue* index,
5546
+ HValue* value) : encoding_(encoding) {
5547
+ SetOperandAt(0, string);
5548
+ SetOperandAt(1, index);
5549
+ SetOperandAt(2, value);
5550
+ }
5551
+
5552
+ String::Encoding encoding() { return encoding_; }
5553
+ HValue* string() { return OperandAt(0); }
5554
+ HValue* index() { return OperandAt(1); }
5555
+ HValue* value() { return OperandAt(2); }
5556
+
5557
+ virtual Representation RequiredInputRepresentation(int index) {
5558
+ return Representation::Tagged();
5559
+ }
5560
+
5561
+ DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar)
5562
+
5563
+ private:
5564
+ String::Encoding encoding_;
5565
+ };
5566
+
5567
+
4885
5568
  class HDeleteProperty: public HBinaryOperation {
4886
5569
  public:
4887
5570
  HDeleteProperty(HValue* context, HValue* obj, HValue* key)
@@ -5055,6 +5738,9 @@ class HLoadFieldByIndex : public HTemplateInstruction<2> {
5055
5738
  }
5056
5739
 
5057
5740
  DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex);
5741
+
5742
+ private:
5743
+ virtual bool IsDeletable() const { return true; }
5058
5744
  };
5059
5745
 
5060
5746