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
@@ -565,7 +565,7 @@ TEST(HeapSnapshotJSONSerialization) {
565
565
  // Get node and edge "member" offsets.
566
566
  v8::Local<v8::Value> meta_analysis_result = CompileRun(
567
567
  "var meta = parsed.snapshot.meta;\n"
568
- "var edges_index_offset = meta.node_fields.indexOf('edges_index');\n"
568
+ "var edge_count_offset = meta.node_fields.indexOf('edge_count');\n"
569
569
  "var node_fields_count = meta.node_fields.length;\n"
570
570
  "var edge_fields_count = meta.edge_fields.length;\n"
571
571
  "var edge_type_offset = meta.edge_fields.indexOf('type');\n"
@@ -575,7 +575,13 @@ TEST(HeapSnapshotJSONSerialization) {
575
575
  " meta.edge_types[edge_type_offset].indexOf('property');\n"
576
576
  "var shortcut_type ="
577
577
  " meta.edge_types[edge_type_offset].indexOf('shortcut');\n"
578
- "parsed.nodes.concat(0, 0, 0, 0, 0, 0, parsed.edges.length);");
578
+ "var node_count = parsed.nodes.length / node_fields_count;\n"
579
+ "var first_edge_indexes = parsed.first_edge_indexes = [];\n"
580
+ "for (var i = 0, first_edge_index = 0; i < node_count; ++i) {\n"
581
+ " first_edge_indexes[i] = first_edge_index;\n"
582
+ " first_edge_index += edge_fields_count *\n"
583
+ " parsed.nodes[i * node_fields_count + edge_count_offset];\n"
584
+ "}\n");
579
585
  CHECK(!meta_analysis_result.IsEmpty());
580
586
 
581
587
  // A helper function for processing encoded nodes.
@@ -584,8 +590,9 @@ TEST(HeapSnapshotJSONSerialization) {
584
590
  " var nodes = parsed.nodes;\n"
585
591
  " var edges = parsed.edges;\n"
586
592
  " var strings = parsed.strings;\n"
587
- " for (var i = nodes[pos + edges_index_offset],\n"
588
- " count = nodes[pos + node_fields_count + edges_index_offset];\n"
593
+ " var node_ordinal = pos / node_fields_count;\n"
594
+ " for (var i = parsed.first_edge_indexes[node_ordinal],\n"
595
+ " count = parsed.first_edge_indexes[node_ordinal + 1];\n"
589
596
  " i < count; i += edge_fields_count) {\n"
590
597
  " if (edges[i + edge_type_offset] === prop_type\n"
591
598
  " && strings[edges[i + edge_name_offset]] === prop_name)\n"
@@ -598,8 +605,7 @@ TEST(HeapSnapshotJSONSerialization) {
598
605
  "GetChildPosByProperty(\n"
599
606
  " GetChildPosByProperty(\n"
600
607
  " GetChildPosByProperty("
601
- " parsed.edges[parsed.nodes[edges_index_offset]"
602
- " + edge_to_node_offset],"
608
+ " parsed.edges[edge_to_node_offset],"
603
609
  " \"b\", property_type),\n"
604
610
  " \"x\", property_type),"
605
611
  " \"s\", property_type)");
@@ -691,9 +697,13 @@ class TestStatsStream : public v8::OutputStream {
691
697
 
692
698
  } // namespace
693
699
 
694
- static TestStatsStream GetHeapStatsUpdate() {
700
+ static TestStatsStream GetHeapStatsUpdate(
701
+ v8::SnapshotObjectId* object_id = NULL) {
695
702
  TestStatsStream stream;
696
- v8::HeapProfiler::PushHeapObjectsStats(&stream);
703
+ v8::SnapshotObjectId last_seen_id =
704
+ v8::HeapProfiler::PushHeapObjectsStats(&stream);
705
+ if (object_id)
706
+ *object_id = last_seen_id;
697
707
  CHECK_EQ(1, stream.eos_signaled());
698
708
  return stream;
699
709
  }
@@ -704,15 +714,16 @@ TEST(HeapSnapshotObjectsStats) {
704
714
  LocalContext env;
705
715
 
706
716
  v8::HeapProfiler::StartHeapObjectsTracking();
707
- // We have to call GC 5 times. In other case the garbage will be
717
+ // We have to call GC 6 times. In other case the garbage will be
708
718
  // the reason of flakiness.
709
- for (int i = 0; i < 5; ++i) {
719
+ for (int i = 0; i < 6; ++i) {
710
720
  HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
711
721
  }
712
722
 
723
+ v8::SnapshotObjectId initial_id;
713
724
  {
714
725
  // Single chunk of data expected in update. Initial data.
715
- TestStatsStream stats_update = GetHeapStatsUpdate();
726
+ TestStatsStream stats_update = GetHeapStatsUpdate(&initial_id);
716
727
  CHECK_EQ(1, stats_update.intervals_count());
717
728
  CHECK_EQ(1, stats_update.updates_written());
718
729
  CHECK_LT(0, stats_update.entries_size());
@@ -720,13 +731,18 @@ TEST(HeapSnapshotObjectsStats) {
720
731
  }
721
732
 
722
733
  // No data expected in update because nothing has happened.
723
- CHECK_EQ(0, GetHeapStatsUpdate().updates_written());
734
+ v8::SnapshotObjectId same_id;
735
+ CHECK_EQ(0, GetHeapStatsUpdate(&same_id).updates_written());
736
+ CHECK_EQ_SNAPSHOT_OBJECT_ID(initial_id, same_id);
737
+
724
738
  {
739
+ v8::SnapshotObjectId additional_string_id;
725
740
  v8::HandleScope inner_scope_1;
726
741
  v8_str("string1");
727
742
  {
728
743
  // Single chunk of data with one new entry expected in update.
729
- TestStatsStream stats_update = GetHeapStatsUpdate();
744
+ TestStatsStream stats_update = GetHeapStatsUpdate(&additional_string_id);
745
+ CHECK_LT(same_id, additional_string_id);
730
746
  CHECK_EQ(1, stats_update.intervals_count());
731
747
  CHECK_EQ(1, stats_update.updates_written());
732
748
  CHECK_LT(0, stats_update.entries_size());
@@ -735,7 +751,9 @@ TEST(HeapSnapshotObjectsStats) {
735
751
  }
736
752
 
737
753
  // No data expected in update because nothing happened.
738
- CHECK_EQ(0, GetHeapStatsUpdate().updates_written());
754
+ v8::SnapshotObjectId last_id;
755
+ CHECK_EQ(0, GetHeapStatsUpdate(&last_id).updates_written());
756
+ CHECK_EQ_SNAPSHOT_OBJECT_ID(additional_string_id, last_id);
739
757
 
740
758
  {
741
759
  v8::HandleScope inner_scope_2;
@@ -997,7 +1015,6 @@ class TestRetainedObjectInfo : public v8::RetainedObjectInfo {
997
1015
 
998
1016
  private:
999
1017
  bool disposed_;
1000
- int category_;
1001
1018
  int hash_;
1002
1019
  const char* group_label_;
1003
1020
  const char* label_;
@@ -1028,20 +1045,21 @@ static const v8::HeapGraphNode* GetNode(const v8::HeapGraphNode* parent,
1028
1045
  TEST(HeapSnapshotRetainedObjectInfo) {
1029
1046
  v8::HandleScope scope;
1030
1047
  LocalContext env;
1048
+ v8::Isolate* isolate = env->GetIsolate();
1031
1049
 
1032
1050
  v8::HeapProfiler::DefineWrapperClass(
1033
1051
  1, TestRetainedObjectInfo::WrapperInfoCallback);
1034
1052
  v8::HeapProfiler::DefineWrapperClass(
1035
1053
  2, TestRetainedObjectInfo::WrapperInfoCallback);
1036
1054
  v8::Persistent<v8::String> p_AAA =
1037
- v8::Persistent<v8::String>::New(v8_str("AAA"));
1038
- p_AAA.SetWrapperClassId(1);
1055
+ v8::Persistent<v8::String>::New(isolate, v8_str("AAA"));
1056
+ p_AAA.SetWrapperClassId(isolate, 1);
1039
1057
  v8::Persistent<v8::String> p_BBB =
1040
- v8::Persistent<v8::String>::New(v8_str("BBB"));
1041
- p_BBB.SetWrapperClassId(1);
1058
+ v8::Persistent<v8::String>::New(isolate, v8_str("BBB"));
1059
+ p_BBB.SetWrapperClassId(isolate, 1);
1042
1060
  v8::Persistent<v8::String> p_CCC =
1043
- v8::Persistent<v8::String>::New(v8_str("CCC"));
1044
- p_CCC.SetWrapperClassId(2);
1061
+ v8::Persistent<v8::String>::New(isolate, v8_str("CCC"));
1062
+ p_CCC.SetWrapperClassId(isolate, 2);
1045
1063
  CHECK_EQ(0, TestRetainedObjectInfo::instances.length());
1046
1064
  const v8::HeapSnapshot* snapshot =
1047
1065
  v8::HeapProfiler::TakeSnapshot(v8_str("retained"));
@@ -1090,8 +1108,9 @@ class GraphWithImplicitRefs {
1090
1108
  explicit GraphWithImplicitRefs(LocalContext* env) {
1091
1109
  CHECK_EQ(NULL, instance_);
1092
1110
  instance_ = this;
1111
+ v8::Isolate* isolate = (*env)->GetIsolate();
1093
1112
  for (int i = 0; i < kObjectsCount; i++) {
1094
- objects_[i] = v8::Persistent<v8::Object>::New(v8::Object::New());
1113
+ objects_[i] = v8::Persistent<v8::Object>::New(isolate, v8::Object::New());
1095
1114
  }
1096
1115
  (*env)->Global()->Set(v8_str("root_object"), objects_[0]);
1097
1116
  }
@@ -1099,7 +1118,7 @@ class GraphWithImplicitRefs {
1099
1118
  instance_ = NULL;
1100
1119
  }
1101
1120
 
1102
- static void gcPrologue() {
1121
+ static void gcPrologue(v8::GCType type, v8::GCCallbackFlags flags) {
1103
1122
  instance_->AddImplicitReferences();
1104
1123
  }
1105
1124
 
@@ -1125,7 +1144,7 @@ TEST(HeapSnapshotImplicitReferences) {
1125
1144
  LocalContext env;
1126
1145
 
1127
1146
  GraphWithImplicitRefs graph(&env);
1128
- v8::V8::SetGlobalGCPrologueCallback(&GraphWithImplicitRefs::gcPrologue);
1147
+ v8::V8::AddGCPrologueCallback(&GraphWithImplicitRefs::gcPrologue);
1129
1148
 
1130
1149
  const v8::HeapSnapshot* snapshot =
1131
1150
  v8::HeapProfiler::TakeSnapshot(v8_str("implicit_refs"));
@@ -1148,7 +1167,7 @@ TEST(HeapSnapshotImplicitReferences) {
1148
1167
  }
1149
1168
  }
1150
1169
  CHECK_EQ(2, implicit_targets_count);
1151
- v8::V8::SetGlobalGCPrologueCallback(NULL);
1170
+ v8::V8::RemoveGCPrologueCallback(&GraphWithImplicitRefs::gcPrologue);
1152
1171
  }
1153
1172
 
1154
1173
 
@@ -1210,51 +1229,28 @@ TEST(DeleteHeapSnapshot) {
1210
1229
  }
1211
1230
 
1212
1231
 
1213
- TEST(DocumentURL) {
1214
- v8::HandleScope scope;
1215
- LocalContext env;
1216
-
1217
- CompileRun("document = { URL:\"abcdefgh\" };");
1218
-
1219
- const v8::HeapSnapshot* snapshot =
1220
- v8::HeapProfiler::TakeSnapshot(v8_str("document"));
1221
- const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1222
- CHECK_NE(NULL, global);
1223
- CHECK_EQ("Object / abcdefgh",
1224
- const_cast<i::HeapEntry*>(
1225
- reinterpret_cast<const i::HeapEntry*>(global))->name());
1226
- }
1227
-
1232
+ class NameResolver : public v8::HeapProfiler::ObjectNameResolver {
1233
+ public:
1234
+ virtual const char* GetName(v8::Handle<v8::Object> object) {
1235
+ return "Global object name";
1236
+ }
1237
+ };
1228
1238
 
1229
- TEST(DocumentWithException) {
1239
+ TEST(GlobalObjectName) {
1230
1240
  v8::HandleScope scope;
1231
1241
  LocalContext env;
1232
1242
 
1233
- CompileRun(
1234
- "this.__defineGetter__(\"document\", function() { throw new Error(); })");
1235
- const v8::HeapSnapshot* snapshot =
1236
- v8::HeapProfiler::TakeSnapshot(v8_str("document"));
1237
- const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1238
- CHECK_NE(NULL, global);
1239
- CHECK_EQ("Object",
1240
- const_cast<i::HeapEntry*>(
1241
- reinterpret_cast<const i::HeapEntry*>(global))->name());
1242
- }
1243
-
1244
-
1245
- TEST(DocumentURLWithException) {
1246
- v8::HandleScope scope;
1247
- LocalContext env;
1243
+ CompileRun("document = { URL:\"abcdefgh\" };");
1248
1244
 
1249
- CompileRun(
1250
- "function URLWithException() {}\n"
1251
- "URLWithException.prototype = { get URL() { throw new Error(); } };\n"
1252
- "document = { URL: new URLWithException() };");
1245
+ NameResolver name_resolver;
1253
1246
  const v8::HeapSnapshot* snapshot =
1254
- v8::HeapProfiler::TakeSnapshot(v8_str("document"));
1247
+ v8::HeapProfiler::TakeSnapshot(v8_str("document"),
1248
+ v8::HeapSnapshot::kFull,
1249
+ NULL,
1250
+ &name_resolver);
1255
1251
  const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1256
1252
  CHECK_NE(NULL, global);
1257
- CHECK_EQ("Object",
1253
+ CHECK_EQ("Object / Global object name" ,
1258
1254
  const_cast<i::HeapEntry*>(
1259
1255
  reinterpret_cast<const i::HeapEntry*>(global))->name());
1260
1256
  }
@@ -1431,6 +1427,36 @@ TEST(FastCaseGetter) {
1431
1427
  CHECK_NE(NULL, setterFunction);
1432
1428
  }
1433
1429
 
1430
+ TEST(HiddenPropertiesFastCase) {
1431
+ v8::HandleScope scope;
1432
+ LocalContext env;
1433
+
1434
+ CompileRun(
1435
+ "function C(x) { this.a = this; this.b = x; }\n"
1436
+ "c = new C(2012);\n");
1437
+ const v8::HeapSnapshot* snapshot =
1438
+ v8::HeapProfiler::TakeSnapshot(v8_str("HiddenPropertiesFastCase1"));
1439
+ const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1440
+ const v8::HeapGraphNode* c =
1441
+ GetProperty(global, v8::HeapGraphEdge::kProperty, "c");
1442
+ CHECK_NE(NULL, c);
1443
+ const v8::HeapGraphNode* hidden_props =
1444
+ GetProperty(c, v8::HeapGraphEdge::kInternal, "hidden_properties");
1445
+ CHECK_EQ(NULL, hidden_props);
1446
+
1447
+ v8::Handle<v8::Value> cHandle = env->Global()->Get(v8::String::New("c"));
1448
+ CHECK(!cHandle.IsEmpty() && cHandle->IsObject());
1449
+ cHandle->ToObject()->SetHiddenValue(v8_str("key"), v8_str("val"));
1450
+
1451
+ snapshot = v8::HeapProfiler::TakeSnapshot(
1452
+ v8_str("HiddenPropertiesFastCase2"));
1453
+ global = GetGlobalObject(snapshot);
1454
+ c = GetProperty(global, v8::HeapGraphEdge::kProperty, "c");
1455
+ CHECK_NE(NULL, c);
1456
+ hidden_props = GetProperty(c, v8::HeapGraphEdge::kInternal,
1457
+ "hidden_properties");
1458
+ CHECK_NE(NULL, hidden_props);
1459
+ }
1434
1460
 
1435
1461
  bool HasWeakEdge(const v8::HeapGraphNode* node) {
1436
1462
  for (int i = 0; i < node->GetChildrenCount(); ++i) {
@@ -1454,8 +1480,10 @@ bool HasWeakGlobalHandle() {
1454
1480
  }
1455
1481
 
1456
1482
 
1457
- static void PersistentHandleCallback(v8::Persistent<v8::Value> handle, void*) {
1458
- handle.Dispose();
1483
+ static void PersistentHandleCallback(v8::Isolate* isolate,
1484
+ v8::Persistent<v8::Value> handle,
1485
+ void*) {
1486
+ handle.Dispose(isolate);
1459
1487
  }
1460
1488
 
1461
1489
 
@@ -1466,14 +1494,14 @@ TEST(WeakGlobalHandle) {
1466
1494
  CHECK(!HasWeakGlobalHandle());
1467
1495
 
1468
1496
  v8::Persistent<v8::Object> handle =
1469
- v8::Persistent<v8::Object>::New(v8::Object::New());
1470
- handle.MakeWeak(NULL, PersistentHandleCallback);
1497
+ v8::Persistent<v8::Object>::New(env->GetIsolate(), v8::Object::New());
1498
+ handle.MakeWeak(env->GetIsolate(), NULL, PersistentHandleCallback);
1471
1499
 
1472
1500
  CHECK(HasWeakGlobalHandle());
1473
1501
  }
1474
1502
 
1475
1503
 
1476
- TEST(WeakGlobalContextRefs) {
1504
+ TEST(WeakNativeContextRefs) {
1477
1505
  v8::HandleScope scope;
1478
1506
  LocalContext env;
1479
1507
 
@@ -1485,10 +1513,10 @@ TEST(WeakGlobalContextRefs) {
1485
1513
  const v8::HeapGraphNode* global_handles = GetNode(
1486
1514
  gc_roots, v8::HeapGraphNode::kObject, "(Global handles)");
1487
1515
  CHECK_NE(NULL, global_handles);
1488
- const v8::HeapGraphNode* global_context = GetNode(
1489
- global_handles, v8::HeapGraphNode::kHidden, "system / GlobalContext");
1490
- CHECK_NE(NULL, global_context);
1491
- CHECK(HasWeakEdge(global_context));
1516
+ const v8::HeapGraphNode* native_context = GetNode(
1517
+ global_handles, v8::HeapGraphNode::kHidden, "system / NativeContext");
1518
+ CHECK_NE(NULL, native_context);
1519
+ CHECK(HasWeakEdge(native_context));
1492
1520
  }
1493
1521
 
1494
1522
 
@@ -1511,6 +1539,7 @@ TEST(SfiAndJsFunctionWeakRefs) {
1511
1539
  }
1512
1540
 
1513
1541
 
1542
+ #ifdef ENABLE_DEBUGGER_SUPPORT
1514
1543
  TEST(NoDebugObjectInSnapshot) {
1515
1544
  v8::HandleScope scope;
1516
1545
  LocalContext env;
@@ -1533,11 +1562,13 @@ TEST(NoDebugObjectInSnapshot) {
1533
1562
  }
1534
1563
  CHECK_EQ(1, globals_count);
1535
1564
  }
1565
+ #endif // ENABLE_DEBUGGER_SUPPORT
1536
1566
 
1537
1567
 
1538
1568
  TEST(PersistentHandleCount) {
1539
1569
  v8::HandleScope scope;
1540
1570
  LocalContext env;
1571
+ v8::Isolate* isolate = env->GetIsolate();
1541
1572
 
1542
1573
  // V8 also uses global handles internally, so we can't test for an absolute
1543
1574
  // number.
@@ -1545,26 +1576,26 @@ TEST(PersistentHandleCount) {
1545
1576
 
1546
1577
  // Create some persistent handles.
1547
1578
  v8::Persistent<v8::String> p_AAA =
1548
- v8::Persistent<v8::String>::New(v8_str("AAA"));
1579
+ v8::Persistent<v8::String>::New(isolate, v8_str("AAA"));
1549
1580
  CHECK_EQ(global_handle_count + 1,
1550
1581
  v8::HeapProfiler::GetPersistentHandleCount());
1551
1582
  v8::Persistent<v8::String> p_BBB =
1552
- v8::Persistent<v8::String>::New(v8_str("BBB"));
1583
+ v8::Persistent<v8::String>::New(isolate, v8_str("BBB"));
1553
1584
  CHECK_EQ(global_handle_count + 2,
1554
1585
  v8::HeapProfiler::GetPersistentHandleCount());
1555
1586
  v8::Persistent<v8::String> p_CCC =
1556
- v8::Persistent<v8::String>::New(v8_str("CCC"));
1587
+ v8::Persistent<v8::String>::New(isolate, v8_str("CCC"));
1557
1588
  CHECK_EQ(global_handle_count + 3,
1558
1589
  v8::HeapProfiler::GetPersistentHandleCount());
1559
1590
 
1560
1591
  // Dipose the persistent handles in a different order.
1561
- p_AAA.Dispose();
1592
+ p_AAA.Dispose(env->GetIsolate());
1562
1593
  CHECK_EQ(global_handle_count + 2,
1563
1594
  v8::HeapProfiler::GetPersistentHandleCount());
1564
- p_CCC.Dispose();
1595
+ p_CCC.Dispose(env->GetIsolate());
1565
1596
  CHECK_EQ(global_handle_count + 1,
1566
1597
  v8::HeapProfiler::GetPersistentHandleCount());
1567
- p_BBB.Dispose();
1598
+ p_BBB.Dispose(env->GetIsolate());
1568
1599
  CHECK_EQ(global_handle_count, v8::HeapProfiler::GetPersistentHandleCount());
1569
1600
  }
1570
1601
 
@@ -1608,3 +1639,26 @@ TEST(NoRefsToNonEssentialEntries) {
1608
1639
  GetProperty(global_object, v8::HeapGraphEdge::kInternal, "elements");
1609
1640
  CHECK_EQ(NULL, elements);
1610
1641
  }
1642
+
1643
+
1644
+ TEST(MapHasDescriptorsAndTransitions) {
1645
+ v8::HandleScope scope;
1646
+ LocalContext env;
1647
+ CompileRun("obj = { a: 10 };\n");
1648
+ const v8::HeapSnapshot* snapshot =
1649
+ v8::HeapProfiler::TakeSnapshot(v8_str("snapshot"));
1650
+ const v8::HeapGraphNode* global = GetGlobalObject(snapshot);
1651
+ const v8::HeapGraphNode* global_object =
1652
+ GetProperty(global, v8::HeapGraphEdge::kProperty, "obj");
1653
+ CHECK_NE(NULL, global_object);
1654
+
1655
+ const v8::HeapGraphNode* map =
1656
+ GetProperty(global_object, v8::HeapGraphEdge::kInternal, "map");
1657
+ CHECK_NE(NULL, map);
1658
+ const v8::HeapGraphNode* own_descriptors = GetProperty(
1659
+ map, v8::HeapGraphEdge::kInternal, "descriptors");
1660
+ CHECK_NE(NULL, own_descriptors);
1661
+ const v8::HeapGraphNode* own_transitions = GetProperty(
1662
+ map, v8::HeapGraphEdge::kInternal, "transitions");
1663
+ CHECK_EQ(NULL, own_transitions);
1664
+ }
@@ -4,10 +4,12 @@
4
4
 
5
5
  #include "v8.h"
6
6
 
7
+ #include "compilation-cache.h"
7
8
  #include "execution.h"
8
9
  #include "factory.h"
9
10
  #include "macro-assembler.h"
10
11
  #include "global-handles.h"
12
+ #include "stub-cache.h"
11
13
  #include "cctest.h"
12
14
 
13
15
  using namespace v8::internal;
@@ -21,6 +23,21 @@ static void InitializeVM() {
21
23
  }
22
24
 
23
25
 
26
+ // Go through all incremental marking steps in one swoop.
27
+ static void SimulateIncrementalMarking() {
28
+ IncrementalMarking* marking = HEAP->incremental_marking();
29
+ CHECK(marking->IsMarking() || marking->IsStopped());
30
+ if (marking->IsStopped()) {
31
+ marking->Start();
32
+ }
33
+ CHECK(marking->IsMarking());
34
+ while (!marking->IsComplete()) {
35
+ marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
36
+ }
37
+ CHECK(marking->IsComplete());
38
+ }
39
+
40
+
24
41
  static void CheckMap(Map* map, int type, int instance_size) {
25
42
  CHECK(map->IsHeapObject());
26
43
  #ifdef DEBUG
@@ -45,7 +62,7 @@ static void CheckOddball(Object* obj, const char* string) {
45
62
  CHECK(obj->IsOddball());
46
63
  bool exc;
47
64
  Object* print_string = *Execution::ToString(Handle<Object>(obj), &exc);
48
- CHECK(String::cast(print_string)->IsEqualTo(CStrVector(string)));
65
+ CHECK(String::cast(print_string)->IsUtf8EqualTo(CStrVector(string)));
49
66
  }
50
67
 
51
68
 
@@ -53,7 +70,7 @@ static void CheckSmi(int value, const char* string) {
53
70
  bool exc;
54
71
  Object* print_string =
55
72
  *Execution::ToString(Handle<Object>(Smi::FromInt(value)), &exc);
56
- CHECK(String::cast(print_string)->IsEqualTo(CStrVector(string)));
73
+ CHECK(String::cast(print_string)->IsUtf8EqualTo(CStrVector(string)));
57
74
  }
58
75
 
59
76
 
@@ -62,7 +79,7 @@ static void CheckNumber(double value, const char* string) {
62
79
  CHECK(obj->IsNumber());
63
80
  bool exc;
64
81
  Object* print_string = *Execution::ToString(Handle<Object>(obj), &exc);
65
- CHECK(String::cast(print_string)->IsEqualTo(CStrVector(string)));
82
+ CHECK(String::cast(print_string)->IsUtf8EqualTo(CStrVector(string)));
66
83
  }
67
84
 
68
85
 
@@ -147,6 +164,13 @@ TEST(HeapObjects) {
147
164
  CHECK_EQ(static_cast<double>(static_cast<uint32_t>(Smi::kMaxValue) + 1),
148
165
  value->Number());
149
166
 
167
+ maybe_value = HEAP->NumberFromUint32(static_cast<uint32_t>(1) << 31);
168
+ value = maybe_value->ToObjectChecked();
169
+ CHECK(value->IsHeapNumber());
170
+ CHECK(value->IsNumber());
171
+ CHECK_EQ(static_cast<double>(static_cast<uint32_t>(1) << 31),
172
+ value->Number());
173
+
150
174
  // nan oddball checks
151
175
  CHECK(HEAP->nan_value()->IsNumber());
152
176
  CHECK(isnan(HEAP->nan_value()->Number()));
@@ -157,7 +181,8 @@ TEST(HeapObjects) {
157
181
 
158
182
  String* object_symbol = String::cast(HEAP->Object_symbol());
159
183
  CHECK(
160
- Isolate::Current()->context()->global()->HasLocalProperty(object_symbol));
184
+ Isolate::Current()->context()->global_object()->HasLocalProperty(
185
+ object_symbol));
161
186
 
162
187
  // Check ToString for oddballs
163
188
  CheckOddball(HEAP->true_value(), "true");
@@ -200,10 +225,10 @@ TEST(GarbageCollection) {
200
225
  // Check GC.
201
226
  HEAP->CollectGarbage(NEW_SPACE);
202
227
 
203
- Handle<String> name = FACTORY->LookupAsciiSymbol("theFunction");
204
- Handle<String> prop_name = FACTORY->LookupAsciiSymbol("theSlot");
205
- Handle<String> prop_namex = FACTORY->LookupAsciiSymbol("theSlotx");
206
- Handle<String> obj_name = FACTORY->LookupAsciiSymbol("theObject");
228
+ Handle<String> name = FACTORY->LookupUtf8Symbol("theFunction");
229
+ Handle<String> prop_name = FACTORY->LookupUtf8Symbol("theSlot");
230
+ Handle<String> prop_namex = FACTORY->LookupUtf8Symbol("theSlotx");
231
+ Handle<String> obj_name = FACTORY->LookupUtf8Symbol("theObject");
207
232
 
208
233
  {
209
234
  v8::HandleScope inner_scope;
@@ -213,7 +238,7 @@ TEST(GarbageCollection) {
213
238
  Handle<Map> initial_map =
214
239
  FACTORY->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
215
240
  function->set_initial_map(*initial_map);
216
- Isolate::Current()->context()->global()->SetProperty(
241
+ Isolate::Current()->context()->global_object()->SetProperty(
217
242
  *name, *function, NONE, kNonStrictMode)->ToObjectChecked();
218
243
  // Allocate an object. Unrooted after leaving the scope.
219
244
  Handle<JSObject> obj = FACTORY->NewJSObject(function);
@@ -229,9 +254,10 @@ TEST(GarbageCollection) {
229
254
  HEAP->CollectGarbage(NEW_SPACE);
230
255
 
231
256
  // Function should be alive.
232
- CHECK(Isolate::Current()->context()->global()->HasLocalProperty(*name));
257
+ CHECK(Isolate::Current()->context()->global_object()->
258
+ HasLocalProperty(*name));
233
259
  // Check function is retained.
234
- Object* func_value = Isolate::Current()->context()->global()->
260
+ Object* func_value = Isolate::Current()->context()->global_object()->
235
261
  GetProperty(*name)->ToObjectChecked();
236
262
  CHECK(func_value->IsJSFunction());
237
263
  Handle<JSFunction> function(JSFunction::cast(func_value));
@@ -240,7 +266,7 @@ TEST(GarbageCollection) {
240
266
  HandleScope inner_scope;
241
267
  // Allocate another object, make it reachable from global.
242
268
  Handle<JSObject> obj = FACTORY->NewJSObject(function);
243
- Isolate::Current()->context()->global()->SetProperty(
269
+ Isolate::Current()->context()->global_object()->SetProperty(
244
270
  *obj_name, *obj, NONE, kNonStrictMode)->ToObjectChecked();
245
271
  obj->SetProperty(
246
272
  *prop_name, Smi::FromInt(23), NONE, kNonStrictMode)->ToObjectChecked();
@@ -249,10 +275,11 @@ TEST(GarbageCollection) {
249
275
  // After gc, it should survive.
250
276
  HEAP->CollectGarbage(NEW_SPACE);
251
277
 
252
- CHECK(Isolate::Current()->context()->global()->HasLocalProperty(*obj_name));
253
- CHECK(Isolate::Current()->context()->global()->
278
+ CHECK(Isolate::Current()->context()->global_object()->
279
+ HasLocalProperty(*obj_name));
280
+ CHECK(Isolate::Current()->context()->global_object()->
254
281
  GetProperty(*obj_name)->ToObjectChecked()->IsJSObject());
255
- Object* obj = Isolate::Current()->context()->global()->
282
+ Object* obj = Isolate::Current()->context()->global_object()->
256
283
  GetProperty(*obj_name)->ToObjectChecked();
257
284
  JSObject* js_obj = JSObject::cast(obj);
258
285
  CHECK_EQ(Smi::FromInt(23), js_obj->GetProperty(*prop_name));
@@ -331,10 +358,11 @@ TEST(GlobalHandles) {
331
358
 
332
359
  static bool WeakPointerCleared = false;
333
360
 
334
- static void TestWeakGlobalHandleCallback(v8::Persistent<v8::Value> handle,
361
+ static void TestWeakGlobalHandleCallback(v8::Isolate* isolate,
362
+ v8::Persistent<v8::Value> handle,
335
363
  void* id) {
336
364
  if (1234 == reinterpret_cast<intptr_t>(id)) WeakPointerCleared = true;
337
- handle.Dispose();
365
+ handle.Dispose(isolate);
338
366
  }
339
367
 
340
368
 
@@ -359,6 +387,7 @@ TEST(WeakGlobalHandlesScavenge) {
359
387
 
360
388
  global_handles->MakeWeak(h2.location(),
361
389
  reinterpret_cast<void*>(1234),
390
+ NULL,
362
391
  &TestWeakGlobalHandleCallback);
363
392
 
364
393
  // Scavenge treats weak pointers as normal roots.
@@ -395,17 +424,20 @@ TEST(WeakGlobalHandlesMark) {
395
424
  h2 = global_handles->Create(*u);
396
425
  }
397
426
 
427
+ // Make sure the objects are promoted.
398
428
  HEAP->CollectGarbage(OLD_POINTER_SPACE);
399
429
  HEAP->CollectGarbage(NEW_SPACE);
400
- // Make sure the object is promoted.
430
+ CHECK(!HEAP->InNewSpace(*h1) && !HEAP->InNewSpace(*h2));
401
431
 
402
432
  global_handles->MakeWeak(h2.location(),
403
433
  reinterpret_cast<void*>(1234),
434
+ NULL,
404
435
  &TestWeakGlobalHandleCallback);
405
436
  CHECK(!GlobalHandles::IsNearDeath(h1.location()));
406
437
  CHECK(!GlobalHandles::IsNearDeath(h2.location()));
407
438
 
408
- HEAP->CollectGarbage(OLD_POINTER_SPACE);
439
+ // Incremental marking potentially marked handles before they turned weak.
440
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
409
441
 
410
442
  CHECK((*h1)->IsString());
411
443
 
@@ -415,6 +447,7 @@ TEST(WeakGlobalHandlesMark) {
415
447
  global_handles->Destroy(h1.location());
416
448
  }
417
449
 
450
+
418
451
  TEST(DeleteWeakGlobalHandle) {
419
452
  InitializeVM();
420
453
  GlobalHandles* global_handles = Isolate::Current()->global_handles();
@@ -432,6 +465,7 @@ TEST(DeleteWeakGlobalHandle) {
432
465
 
433
466
  global_handles->MakeWeak(h.location(),
434
467
  reinterpret_cast<void*>(1234),
468
+ NULL,
435
469
  &TestWeakGlobalHandleCallback);
436
470
 
437
471
  // Scanvenge does not recognize weak reference.
@@ -445,6 +479,7 @@ TEST(DeleteWeakGlobalHandle) {
445
479
  CHECK(WeakPointerCleared);
446
480
  }
447
481
 
482
+
448
483
  static const char* not_so_random_string_table[] = {
449
484
  "abstract",
450
485
  "boolean",
@@ -512,15 +547,15 @@ static const char* not_so_random_string_table[] = {
512
547
  static void CheckSymbols(const char** strings) {
513
548
  for (const char* string = *strings; *strings != 0; string = *strings++) {
514
549
  Object* a;
515
- MaybeObject* maybe_a = HEAP->LookupAsciiSymbol(string);
516
- // LookupAsciiSymbol may return a failure if a GC is needed.
550
+ MaybeObject* maybe_a = HEAP->LookupUtf8Symbol(string);
551
+ // LookupUtf8Symbol may return a failure if a GC is needed.
517
552
  if (!maybe_a->ToObject(&a)) continue;
518
553
  CHECK(a->IsSymbol());
519
554
  Object* b;
520
- MaybeObject* maybe_b = HEAP->LookupAsciiSymbol(string);
555
+ MaybeObject* maybe_b = HEAP->LookupUtf8Symbol(string);
521
556
  if (!maybe_b->ToObject(&b)) continue;
522
557
  CHECK_EQ(b, a);
523
- CHECK(String::cast(b)->IsEqualTo(CStrVector(string)));
558
+ CHECK(String::cast(b)->IsUtf8EqualTo(CStrVector(string)));
524
559
  }
525
560
  }
526
561
 
@@ -537,14 +572,14 @@ TEST(FunctionAllocation) {
537
572
  InitializeVM();
538
573
 
539
574
  v8::HandleScope sc;
540
- Handle<String> name = FACTORY->LookupAsciiSymbol("theFunction");
575
+ Handle<String> name = FACTORY->LookupUtf8Symbol("theFunction");
541
576
  Handle<JSFunction> function =
542
577
  FACTORY->NewFunction(name, FACTORY->undefined_value());
543
578
  Handle<Map> initial_map =
544
579
  FACTORY->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
545
580
  function->set_initial_map(*initial_map);
546
581
 
547
- Handle<String> prop_name = FACTORY->LookupAsciiSymbol("theSlot");
582
+ Handle<String> prop_name = FACTORY->LookupUtf8Symbol("theSlot");
548
583
  Handle<JSObject> obj = FACTORY->NewJSObject(function);
549
584
  obj->SetProperty(
550
585
  *prop_name, Smi::FromInt(23), NONE, kNonStrictMode)->ToObjectChecked();
@@ -561,13 +596,13 @@ TEST(ObjectProperties) {
561
596
 
562
597
  v8::HandleScope sc;
563
598
  String* object_symbol = String::cast(HEAP->Object_symbol());
564
- Object* raw_object = Isolate::Current()->context()->global()->
599
+ Object* raw_object = Isolate::Current()->context()->global_object()->
565
600
  GetProperty(object_symbol)->ToObjectChecked();
566
601
  JSFunction* object_function = JSFunction::cast(raw_object);
567
602
  Handle<JSFunction> constructor(object_function);
568
603
  Handle<JSObject> obj = FACTORY->NewJSObject(constructor);
569
- Handle<String> first = FACTORY->LookupAsciiSymbol("first");
570
- Handle<String> second = FACTORY->LookupAsciiSymbol("second");
604
+ Handle<String> first = FACTORY->LookupUtf8Symbol("first");
605
+ Handle<String> second = FACTORY->LookupUtf8Symbol("second");
571
606
 
572
607
  // check for empty
573
608
  CHECK(!obj->HasLocalProperty(*first));
@@ -616,12 +651,12 @@ TEST(ObjectProperties) {
616
651
  Handle<String> s1 = FACTORY->NewStringFromAscii(CStrVector(string1));
617
652
  obj->SetProperty(
618
653
  *s1, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
619
- Handle<String> s1_symbol = FACTORY->LookupAsciiSymbol(string1);
654
+ Handle<String> s1_symbol = FACTORY->LookupUtf8Symbol(string1);
620
655
  CHECK(obj->HasLocalProperty(*s1_symbol));
621
656
 
622
657
  // check symbol and string match
623
658
  const char* string2 = "fugl";
624
- Handle<String> s2_symbol = FACTORY->LookupAsciiSymbol(string2);
659
+ Handle<String> s2_symbol = FACTORY->LookupUtf8Symbol(string2);
625
660
  obj->SetProperty(
626
661
  *s2_symbol, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
627
662
  Handle<String> s2 = FACTORY->NewStringFromAscii(CStrVector(string2));
@@ -633,14 +668,14 @@ TEST(JSObjectMaps) {
633
668
  InitializeVM();
634
669
 
635
670
  v8::HandleScope sc;
636
- Handle<String> name = FACTORY->LookupAsciiSymbol("theFunction");
671
+ Handle<String> name = FACTORY->LookupUtf8Symbol("theFunction");
637
672
  Handle<JSFunction> function =
638
673
  FACTORY->NewFunction(name, FACTORY->undefined_value());
639
674
  Handle<Map> initial_map =
640
675
  FACTORY->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize);
641
676
  function->set_initial_map(*initial_map);
642
677
 
643
- Handle<String> prop_name = FACTORY->LookupAsciiSymbol("theSlot");
678
+ Handle<String> prop_name = FACTORY->LookupUtf8Symbol("theSlot");
644
679
  Handle<JSObject> obj = FACTORY->NewJSObject(function);
645
680
 
646
681
  // Set a propery
@@ -657,8 +692,8 @@ TEST(JSArray) {
657
692
  InitializeVM();
658
693
 
659
694
  v8::HandleScope sc;
660
- Handle<String> name = FACTORY->LookupAsciiSymbol("Array");
661
- Object* raw_object = Isolate::Current()->context()->global()->
695
+ Handle<String> name = FACTORY->LookupUtf8Symbol("Array");
696
+ Object* raw_object = Isolate::Current()->context()->global_object()->
662
697
  GetProperty(*name)->ToObjectChecked();
663
698
  Handle<JSFunction> function = Handle<JSFunction>(
664
699
  JSFunction::cast(raw_object));
@@ -705,13 +740,13 @@ TEST(JSObjectCopy) {
705
740
 
706
741
  v8::HandleScope sc;
707
742
  String* object_symbol = String::cast(HEAP->Object_symbol());
708
- Object* raw_object = Isolate::Current()->context()->global()->
743
+ Object* raw_object = Isolate::Current()->context()->global_object()->
709
744
  GetProperty(object_symbol)->ToObjectChecked();
710
745
  JSFunction* object_function = JSFunction::cast(raw_object);
711
746
  Handle<JSFunction> constructor(object_function);
712
747
  Handle<JSObject> obj = FACTORY->NewJSObject(constructor);
713
- Handle<String> first = FACTORY->LookupAsciiSymbol("first");
714
- Handle<String> second = FACTORY->LookupAsciiSymbol("second");
748
+ Handle<String> first = FACTORY->LookupUtf8Symbol("first");
749
+ Handle<String> second = FACTORY->LookupUtf8Symbol("second");
715
750
 
716
751
  obj->SetProperty(
717
752
  *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked();
@@ -766,10 +801,10 @@ TEST(StringAllocation) {
766
801
  non_ascii[3 * i + 2] = chars[2];
767
802
  }
768
803
  Handle<String> non_ascii_sym =
769
- FACTORY->LookupSymbol(Vector<const char>(non_ascii, 3 * length));
804
+ FACTORY->LookupUtf8Symbol(Vector<const char>(non_ascii, 3 * length));
770
805
  CHECK_EQ(length, non_ascii_sym->length());
771
806
  Handle<String> ascii_sym =
772
- FACTORY->LookupSymbol(Vector<const char>(ascii, length));
807
+ FACTORY->LookupOneByteSymbol(OneByteVector(ascii, length));
773
808
  CHECK_EQ(length, ascii_sym->length());
774
809
  Handle<String> non_ascii_str =
775
810
  FACTORY->NewStringFromUtf8(Vector<const char>(non_ascii, 3 * length));
@@ -874,7 +909,7 @@ TEST(Regression39128) {
874
909
 
875
910
  // Step 1: prepare a map for the object. We add 1 inobject property to it.
876
911
  Handle<JSFunction> object_ctor(
877
- Isolate::Current()->global_context()->object_function());
912
+ Isolate::Current()->native_context()->object_function());
878
913
  CHECK(object_ctor->has_initial_map());
879
914
  Handle<Map> object_map(object_ctor->initial_map());
880
915
  // Create a map with single inobject property.
@@ -935,9 +970,9 @@ TEST(Regression39128) {
935
970
 
936
971
 
937
972
  TEST(TestCodeFlushing) {
938
- i::FLAG_allow_natives_syntax = true;
939
973
  // If we do not flush code this test is invalid.
940
974
  if (!FLAG_flush_code) return;
975
+ i::FLAG_allow_natives_syntax = true;
941
976
  InitializeVM();
942
977
  v8::HandleScope scope;
943
978
  const char* source = "function foo() {"
@@ -946,7 +981,7 @@ TEST(TestCodeFlushing) {
946
981
  " var z = x + y;"
947
982
  "};"
948
983
  "foo()";
949
- Handle<String> foo_name = FACTORY->LookupAsciiSymbol("foo");
984
+ Handle<String> foo_name = FACTORY->LookupUtf8Symbol("foo");
950
985
 
951
986
  // This compile will add the code to the compilation cache.
952
987
  { v8::HandleScope scope;
@@ -954,24 +989,22 @@ TEST(TestCodeFlushing) {
954
989
  }
955
990
 
956
991
  // Check function is compiled.
957
- Object* func_value = Isolate::Current()->context()->global()->
992
+ Object* func_value = Isolate::Current()->context()->global_object()->
958
993
  GetProperty(*foo_name)->ToObjectChecked();
959
994
  CHECK(func_value->IsJSFunction());
960
995
  Handle<JSFunction> function(JSFunction::cast(func_value));
961
996
  CHECK(function->shared()->is_compiled());
962
997
 
963
- // TODO(1609) Currently incremental marker does not support code flushing.
998
+ // The code will survive at least two GCs.
964
999
  HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
965
1000
  HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
966
-
967
1001
  CHECK(function->shared()->is_compiled());
968
1002
 
969
- HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
970
- HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
971
- HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
972
- HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
973
- HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
974
- HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1003
+ // Simulate several GCs that use full marking.
1004
+ const int kAgingThreshold = 6;
1005
+ for (int i = 0; i < kAgingThreshold; i++) {
1006
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1007
+ }
975
1008
 
976
1009
  // foo should no longer be in the compilation cache
977
1010
  CHECK(!function->shared()->is_compiled() || function->IsOptimized());
@@ -983,10 +1016,203 @@ TEST(TestCodeFlushing) {
983
1016
  }
984
1017
 
985
1018
 
986
- // Count the number of global contexts in the weak list of global contexts.
987
- static int CountGlobalContexts() {
1019
+ TEST(TestCodeFlushingIncremental) {
1020
+ // If we do not flush code this test is invalid.
1021
+ if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return;
1022
+ i::FLAG_allow_natives_syntax = true;
1023
+ InitializeVM();
1024
+ v8::HandleScope scope;
1025
+ const char* source = "function foo() {"
1026
+ " var x = 42;"
1027
+ " var y = 42;"
1028
+ " var z = x + y;"
1029
+ "};"
1030
+ "foo()";
1031
+ Handle<String> foo_name = FACTORY->LookupUtf8Symbol("foo");
1032
+
1033
+ // This compile will add the code to the compilation cache.
1034
+ { v8::HandleScope scope;
1035
+ CompileRun(source);
1036
+ }
1037
+
1038
+ // Check function is compiled.
1039
+ Object* func_value = Isolate::Current()->context()->global_object()->
1040
+ GetProperty(*foo_name)->ToObjectChecked();
1041
+ CHECK(func_value->IsJSFunction());
1042
+ Handle<JSFunction> function(JSFunction::cast(func_value));
1043
+ CHECK(function->shared()->is_compiled());
1044
+
1045
+ // The code will survive at least two GCs.
1046
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1047
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1048
+ CHECK(function->shared()->is_compiled());
1049
+
1050
+ // Simulate several GCs that use incremental marking.
1051
+ const int kAgingThreshold = 6;
1052
+ for (int i = 0; i < kAgingThreshold; i++) {
1053
+ SimulateIncrementalMarking();
1054
+ HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1055
+ }
1056
+ CHECK(!function->shared()->is_compiled() || function->IsOptimized());
1057
+ CHECK(!function->is_compiled() || function->IsOptimized());
1058
+
1059
+ // This compile will compile the function again.
1060
+ { v8::HandleScope scope;
1061
+ CompileRun("foo();");
1062
+ }
1063
+
1064
+ // Simulate several GCs that use incremental marking but make sure
1065
+ // the loop breaks once the function is enqueued as a candidate.
1066
+ for (int i = 0; i < kAgingThreshold; i++) {
1067
+ SimulateIncrementalMarking();
1068
+ if (!function->next_function_link()->IsUndefined()) break;
1069
+ HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1070
+ }
1071
+
1072
+ // Force optimization while incremental marking is active and while
1073
+ // the function is enqueued as a candidate.
1074
+ { v8::HandleScope scope;
1075
+ CompileRun("%OptimizeFunctionOnNextCall(foo); foo();");
1076
+ }
1077
+
1078
+ // Simulate one final GC to make sure the candidate queue is sane.
1079
+ HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1080
+ CHECK(function->shared()->is_compiled() || !function->IsOptimized());
1081
+ CHECK(function->is_compiled() || !function->IsOptimized());
1082
+ }
1083
+
1084
+
1085
+ TEST(TestCodeFlushingIncrementalScavenge) {
1086
+ // If we do not flush code this test is invalid.
1087
+ if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return;
1088
+ i::FLAG_allow_natives_syntax = true;
1089
+ InitializeVM();
1090
+ v8::HandleScope scope;
1091
+ const char* source = "var foo = function() {"
1092
+ " var x = 42;"
1093
+ " var y = 42;"
1094
+ " var z = x + y;"
1095
+ "};"
1096
+ "foo();"
1097
+ "var bar = function() {"
1098
+ " var x = 23;"
1099
+ "};"
1100
+ "bar();";
1101
+ Handle<String> foo_name = FACTORY->LookupUtf8Symbol("foo");
1102
+ Handle<String> bar_name = FACTORY->LookupUtf8Symbol("bar");
1103
+
1104
+ // Perfrom one initial GC to enable code flushing.
1105
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1106
+
1107
+ // This compile will add the code to the compilation cache.
1108
+ { v8::HandleScope scope;
1109
+ CompileRun(source);
1110
+ }
1111
+
1112
+ // Check functions are compiled.
1113
+ Object* func_value = Isolate::Current()->context()->global_object()->
1114
+ GetProperty(*foo_name)->ToObjectChecked();
1115
+ CHECK(func_value->IsJSFunction());
1116
+ Handle<JSFunction> function(JSFunction::cast(func_value));
1117
+ CHECK(function->shared()->is_compiled());
1118
+ Object* func_value2 = Isolate::Current()->context()->global_object()->
1119
+ GetProperty(*bar_name)->ToObjectChecked();
1120
+ CHECK(func_value2->IsJSFunction());
1121
+ Handle<JSFunction> function2(JSFunction::cast(func_value2));
1122
+ CHECK(function2->shared()->is_compiled());
1123
+
1124
+ // Clear references to functions so that one of them can die.
1125
+ { v8::HandleScope scope;
1126
+ CompileRun("foo = 0; bar = 0;");
1127
+ }
1128
+
1129
+ // Bump the code age so that flushing is triggered while the function
1130
+ // object is still located in new-space.
1131
+ const int kAgingThreshold = 6;
1132
+ for (int i = 0; i < kAgingThreshold; i++) {
1133
+ function->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2));
1134
+ function2->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2));
1135
+ }
1136
+
1137
+ // Simulate incremental marking so that the functions are enqueued as
1138
+ // code flushing candidates. Then kill one of the functions. Finally
1139
+ // perform a scavenge while incremental marking is still running.
1140
+ SimulateIncrementalMarking();
1141
+ *function2.location() = NULL;
1142
+ HEAP->CollectGarbage(NEW_SPACE, "test scavenge while marking");
1143
+
1144
+ // Simulate one final GC to make sure the candidate queue is sane.
1145
+ HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1146
+ CHECK(!function->shared()->is_compiled() || function->IsOptimized());
1147
+ CHECK(!function->is_compiled() || function->IsOptimized());
1148
+ }
1149
+
1150
+
1151
+ TEST(TestCodeFlushingIncrementalAbort) {
1152
+ // If we do not flush code this test is invalid.
1153
+ if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return;
1154
+ i::FLAG_allow_natives_syntax = true;
1155
+ InitializeVM();
1156
+ v8::HandleScope scope;
1157
+ const char* source = "function foo() {"
1158
+ " var x = 42;"
1159
+ " var y = 42;"
1160
+ " var z = x + y;"
1161
+ "};"
1162
+ "foo()";
1163
+ Handle<String> foo_name = FACTORY->LookupUtf8Symbol("foo");
1164
+
1165
+ // This compile will add the code to the compilation cache.
1166
+ { v8::HandleScope scope;
1167
+ CompileRun(source);
1168
+ }
1169
+
1170
+ // Check function is compiled.
1171
+ Object* func_value = Isolate::Current()->context()->global_object()->
1172
+ GetProperty(*foo_name)->ToObjectChecked();
1173
+ CHECK(func_value->IsJSFunction());
1174
+ Handle<JSFunction> function(JSFunction::cast(func_value));
1175
+ CHECK(function->shared()->is_compiled());
1176
+
1177
+ // The code will survive at least two GCs.
1178
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1179
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
1180
+ CHECK(function->shared()->is_compiled());
1181
+
1182
+ // Bump the code age so that flushing is triggered.
1183
+ const int kAgingThreshold = 6;
1184
+ for (int i = 0; i < kAgingThreshold; i++) {
1185
+ function->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2));
1186
+ }
1187
+
1188
+ // Simulate incremental marking so that the function is enqueued as
1189
+ // code flushing candidate.
1190
+ SimulateIncrementalMarking();
1191
+
1192
+ // Enable the debugger and add a breakpoint while incremental marking
1193
+ // is running so that incremental marking aborts and code flushing is
1194
+ // disabled.
1195
+ int position = 0;
1196
+ Handle<Object> breakpoint_object(Smi::FromInt(0));
1197
+ ISOLATE->debug()->SetBreakPoint(function, breakpoint_object, &position);
1198
+ ISOLATE->debug()->ClearAllBreakPoints();
1199
+
1200
+ // Force optimization now that code flushing is disabled.
1201
+ { v8::HandleScope scope;
1202
+ CompileRun("%OptimizeFunctionOnNextCall(foo); foo();");
1203
+ }
1204
+
1205
+ // Simulate one final GC to make sure the candidate queue is sane.
1206
+ HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1207
+ CHECK(function->shared()->is_compiled() || !function->IsOptimized());
1208
+ CHECK(function->is_compiled() || !function->IsOptimized());
1209
+ }
1210
+
1211
+
1212
+ // Count the number of native contexts in the weak list of native contexts.
1213
+ int CountNativeContexts() {
988
1214
  int count = 0;
989
- Object* object = HEAP->global_contexts_list();
1215
+ Object* object = HEAP->native_contexts_list();
990
1216
  while (!object->IsUndefined()) {
991
1217
  count++;
992
1218
  object = Context::cast(object)->get(Context::NEXT_CONTEXT_LINK);
@@ -996,7 +1222,7 @@ static int CountGlobalContexts() {
996
1222
 
997
1223
 
998
1224
  // Count the number of user functions in the weak list of optimized
999
- // functions attached to a global context.
1225
+ // functions attached to a native context.
1000
1226
  static int CountOptimizedUserFunctions(v8::Handle<v8::Context> context) {
1001
1227
  int count = 0;
1002
1228
  Handle<Context> icontext = v8::Utils::OpenHandle(*context);
@@ -1012,12 +1238,16 @@ static int CountOptimizedUserFunctions(v8::Handle<v8::Context> context) {
1012
1238
  TEST(TestInternalWeakLists) {
1013
1239
  v8::V8::Initialize();
1014
1240
 
1241
+ // Some flags turn Scavenge collections into Mark-sweep collections
1242
+ // and hence are incompatible with this test case.
1243
+ if (FLAG_gc_global || FLAG_stress_compaction) return;
1244
+
1015
1245
  static const int kNumTestContexts = 10;
1016
1246
 
1017
1247
  v8::HandleScope scope;
1018
1248
  v8::Persistent<v8::Context> ctx[kNumTestContexts];
1019
1249
 
1020
- CHECK_EQ(0, CountGlobalContexts());
1250
+ CHECK_EQ(0, CountNativeContexts());
1021
1251
 
1022
1252
  // Create a number of global contests which gets linked together.
1023
1253
  for (int i = 0; i < kNumTestContexts; i++) {
@@ -1025,7 +1255,7 @@ TEST(TestInternalWeakLists) {
1025
1255
 
1026
1256
  bool opt = (FLAG_always_opt && i::V8::UseCrankshaft());
1027
1257
 
1028
- CHECK_EQ(i + 1, CountGlobalContexts());
1258
+ CHECK_EQ(i + 1, CountNativeContexts());
1029
1259
 
1030
1260
  ctx[i]->Enter();
1031
1261
 
@@ -1060,6 +1290,7 @@ TEST(TestInternalWeakLists) {
1060
1290
  }
1061
1291
 
1062
1292
  // Mark compact handles the weak references.
1293
+ ISOLATE->compilation_cache()->Clear();
1063
1294
  HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1064
1295
  CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i]));
1065
1296
 
@@ -1085,31 +1316,31 @@ TEST(TestInternalWeakLists) {
1085
1316
  // Force compilation cache cleanup.
1086
1317
  HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1087
1318
 
1088
- // Dispose the global contexts one by one.
1319
+ // Dispose the native contexts one by one.
1089
1320
  for (int i = 0; i < kNumTestContexts; i++) {
1090
- ctx[i].Dispose();
1321
+ ctx[i].Dispose(ctx[i]->GetIsolate());
1091
1322
  ctx[i].Clear();
1092
1323
 
1093
1324
  // Scavenge treats these references as strong.
1094
1325
  for (int j = 0; j < 10; j++) {
1095
1326
  HEAP->PerformScavenge();
1096
- CHECK_EQ(kNumTestContexts - i, CountGlobalContexts());
1327
+ CHECK_EQ(kNumTestContexts - i, CountNativeContexts());
1097
1328
  }
1098
1329
 
1099
1330
  // Mark compact handles the weak references.
1100
1331
  HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1101
- CHECK_EQ(kNumTestContexts - i - 1, CountGlobalContexts());
1332
+ CHECK_EQ(kNumTestContexts - i - 1, CountNativeContexts());
1102
1333
  }
1103
1334
 
1104
- CHECK_EQ(0, CountGlobalContexts());
1335
+ CHECK_EQ(0, CountNativeContexts());
1105
1336
  }
1106
1337
 
1107
1338
 
1108
- // Count the number of global contexts in the weak list of global contexts
1339
+ // Count the number of native contexts in the weak list of native contexts
1109
1340
  // causing a GC after the specified number of elements.
1110
- static int CountGlobalContextsWithGC(int n) {
1341
+ static int CountNativeContextsWithGC(int n) {
1111
1342
  int count = 0;
1112
- Handle<Object> object(HEAP->global_contexts_list());
1343
+ Handle<Object> object(HEAP->native_contexts_list());
1113
1344
  while (!object->IsUndefined()) {
1114
1345
  count++;
1115
1346
  if (count == n) HEAP->CollectAllGarbage(Heap::kNoGCFlags);
@@ -1121,7 +1352,7 @@ static int CountGlobalContextsWithGC(int n) {
1121
1352
 
1122
1353
 
1123
1354
  // Count the number of user functions in the weak list of optimized
1124
- // functions attached to a global context causing a GC after the
1355
+ // functions attached to a native context causing a GC after the
1125
1356
  // specified number of elements.
1126
1357
  static int CountOptimizedUserFunctionsWithGC(v8::Handle<v8::Context> context,
1127
1358
  int n) {
@@ -1147,14 +1378,14 @@ TEST(TestInternalWeakListsTraverseWithGC) {
1147
1378
  v8::HandleScope scope;
1148
1379
  v8::Persistent<v8::Context> ctx[kNumTestContexts];
1149
1380
 
1150
- CHECK_EQ(0, CountGlobalContexts());
1381
+ CHECK_EQ(0, CountNativeContexts());
1151
1382
 
1152
1383
  // Create an number of contexts and check the length of the weak list both
1153
1384
  // with and without GCs while iterating the list.
1154
1385
  for (int i = 0; i < kNumTestContexts; i++) {
1155
1386
  ctx[i] = v8::Context::New();
1156
- CHECK_EQ(i + 1, CountGlobalContexts());
1157
- CHECK_EQ(i + 1, CountGlobalContextsWithGC(i / 2 + 1));
1387
+ CHECK_EQ(i + 1, CountNativeContexts());
1388
+ CHECK_EQ(i + 1, CountNativeContextsWithGC(i / 2 + 1));
1158
1389
  }
1159
1390
 
1160
1391
  bool opt = (FLAG_always_opt && i::V8::UseCrankshaft());
@@ -1198,7 +1429,8 @@ TEST(TestSizeOfObjects) {
1198
1429
  HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1199
1430
  HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1200
1431
  HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1201
- CHECK(HEAP->old_pointer_space()->IsSweepingComplete());
1432
+ HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1433
+ CHECK(HEAP->old_pointer_space()->IsLazySweepingComplete());
1202
1434
  int initial_size = static_cast<int>(HEAP->SizeOfObjects());
1203
1435
 
1204
1436
  {
@@ -1222,7 +1454,7 @@ TEST(TestSizeOfObjects) {
1222
1454
  CHECK_EQ(initial_size, static_cast<int>(HEAP->SizeOfObjects()));
1223
1455
 
1224
1456
  // Advancing the sweeper step-wise should not change the heap size.
1225
- while (!HEAP->old_pointer_space()->IsSweepingComplete()) {
1457
+ while (!HEAP->old_pointer_space()->IsLazySweepingComplete()) {
1226
1458
  HEAP->old_pointer_space()->AdvanceSweeper(KB);
1227
1459
  CHECK_EQ(initial_size, static_cast<int>(HEAP->SizeOfObjects()));
1228
1460
  }
@@ -1238,7 +1470,9 @@ TEST(TestSizeOfObjectsVsHeapIteratorPrecision) {
1238
1470
  for (HeapObject* obj = iterator.next();
1239
1471
  obj != NULL;
1240
1472
  obj = iterator.next()) {
1241
- size_of_objects_2 += obj->Size();
1473
+ if (!obj->IsFreeSpace()) {
1474
+ size_of_objects_2 += obj->Size();
1475
+ }
1242
1476
  }
1243
1477
  // Delta must be within 5% of the larger result.
1244
1478
  // TODO(gc): Tighten this up by distinguishing between byte
@@ -1279,7 +1513,8 @@ TEST(GrowAndShrinkNewSpace) {
1279
1513
  InitializeVM();
1280
1514
  NewSpace* new_space = HEAP->new_space();
1281
1515
 
1282
- if (HEAP->ReservedSemiSpaceSize() == HEAP->InitialSemiSpaceSize()) {
1516
+ if (HEAP->ReservedSemiSpaceSize() == HEAP->InitialSemiSpaceSize() ||
1517
+ HEAP->MaxSemiSpaceSize() == HEAP->InitialSemiSpaceSize()) {
1283
1518
  // The max size cannot exceed the reserved size, since semispaces must be
1284
1519
  // always within the reserved space. We can't test new space growing and
1285
1520
  // shrinking if the reserved size is the same as the minimum (initial) size.
@@ -1327,7 +1562,8 @@ TEST(GrowAndShrinkNewSpace) {
1327
1562
  TEST(CollectingAllAvailableGarbageShrinksNewSpace) {
1328
1563
  InitializeVM();
1329
1564
 
1330
- if (HEAP->ReservedSemiSpaceSize() == HEAP->InitialSemiSpaceSize()) {
1565
+ if (HEAP->ReservedSemiSpaceSize() == HEAP->InitialSemiSpaceSize() ||
1566
+ HEAP->MaxSemiSpaceSize() == HEAP->InitialSemiSpaceSize()) {
1331
1567
  // The max size cannot exceed the reserved size, since semispaces must be
1332
1568
  // always within the reserved space. We can't test new space growing and
1333
1569
  // shrinking if the reserved size is the same as the minimum (initial) size.
@@ -1360,7 +1596,7 @@ static int NumberOfGlobalObjects() {
1360
1596
 
1361
1597
  // Test that we don't embed maps from foreign contexts into
1362
1598
  // optimized code.
1363
- TEST(LeakGlobalContextViaMap) {
1599
+ TEST(LeakNativeContextViaMap) {
1364
1600
  i::FLAG_allow_natives_syntax = true;
1365
1601
  v8::HandleScope outer_scope;
1366
1602
  v8::Persistent<v8::Context> ctx1 = v8::Context::New();
@@ -1385,11 +1621,12 @@ TEST(LeakGlobalContextViaMap) {
1385
1621
  ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0));
1386
1622
  ctx2->Exit();
1387
1623
  ctx1->Exit();
1388
- ctx1.Dispose();
1624
+ ctx1.Dispose(ctx1->GetIsolate());
1625
+ v8::V8::ContextDisposedNotification();
1389
1626
  }
1390
1627
  HEAP->CollectAllAvailableGarbage();
1391
1628
  CHECK_EQ(2, NumberOfGlobalObjects());
1392
- ctx2.Dispose();
1629
+ ctx2.Dispose(ctx2->GetIsolate());
1393
1630
  HEAP->CollectAllAvailableGarbage();
1394
1631
  CHECK_EQ(0, NumberOfGlobalObjects());
1395
1632
  }
@@ -1397,7 +1634,7 @@ TEST(LeakGlobalContextViaMap) {
1397
1634
 
1398
1635
  // Test that we don't embed functions from foreign contexts into
1399
1636
  // optimized code.
1400
- TEST(LeakGlobalContextViaFunction) {
1637
+ TEST(LeakNativeContextViaFunction) {
1401
1638
  i::FLAG_allow_natives_syntax = true;
1402
1639
  v8::HandleScope outer_scope;
1403
1640
  v8::Persistent<v8::Context> ctx1 = v8::Context::New();
@@ -1422,17 +1659,18 @@ TEST(LeakGlobalContextViaFunction) {
1422
1659
  ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0));
1423
1660
  ctx2->Exit();
1424
1661
  ctx1->Exit();
1425
- ctx1.Dispose();
1662
+ ctx1.Dispose(ctx1->GetIsolate());
1663
+ v8::V8::ContextDisposedNotification();
1426
1664
  }
1427
1665
  HEAP->CollectAllAvailableGarbage();
1428
1666
  CHECK_EQ(2, NumberOfGlobalObjects());
1429
- ctx2.Dispose();
1667
+ ctx2.Dispose(ctx2->GetIsolate());
1430
1668
  HEAP->CollectAllAvailableGarbage();
1431
1669
  CHECK_EQ(0, NumberOfGlobalObjects());
1432
1670
  }
1433
1671
 
1434
1672
 
1435
- TEST(LeakGlobalContextViaMapKeyed) {
1673
+ TEST(LeakNativeContextViaMapKeyed) {
1436
1674
  i::FLAG_allow_natives_syntax = true;
1437
1675
  v8::HandleScope outer_scope;
1438
1676
  v8::Persistent<v8::Context> ctx1 = v8::Context::New();
@@ -1457,17 +1695,18 @@ TEST(LeakGlobalContextViaMapKeyed) {
1457
1695
  ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0));
1458
1696
  ctx2->Exit();
1459
1697
  ctx1->Exit();
1460
- ctx1.Dispose();
1698
+ ctx1.Dispose(ctx1->GetIsolate());
1699
+ v8::V8::ContextDisposedNotification();
1461
1700
  }
1462
1701
  HEAP->CollectAllAvailableGarbage();
1463
1702
  CHECK_EQ(2, NumberOfGlobalObjects());
1464
- ctx2.Dispose();
1703
+ ctx2.Dispose(ctx2->GetIsolate());
1465
1704
  HEAP->CollectAllAvailableGarbage();
1466
1705
  CHECK_EQ(0, NumberOfGlobalObjects());
1467
1706
  }
1468
1707
 
1469
1708
 
1470
- TEST(LeakGlobalContextViaMapProto) {
1709
+ TEST(LeakNativeContextViaMapProto) {
1471
1710
  i::FLAG_allow_natives_syntax = true;
1472
1711
  v8::HandleScope outer_scope;
1473
1712
  v8::Persistent<v8::Context> ctx1 = v8::Context::New();
@@ -1496,11 +1735,12 @@ TEST(LeakGlobalContextViaMapProto) {
1496
1735
  ctx2->Global()->Set(v8_str("o"), v8::Int32::New(0));
1497
1736
  ctx2->Exit();
1498
1737
  ctx1->Exit();
1499
- ctx1.Dispose();
1738
+ ctx1.Dispose(ctx1->GetIsolate());
1739
+ v8::V8::ContextDisposedNotification();
1500
1740
  }
1501
1741
  HEAP->CollectAllAvailableGarbage();
1502
1742
  CHECK_EQ(2, NumberOfGlobalObjects());
1503
- ctx2.Dispose();
1743
+ ctx2.Dispose(ctx2->GetIsolate());
1504
1744
  HEAP->CollectAllAvailableGarbage();
1505
1745
  CHECK_EQ(0, NumberOfGlobalObjects());
1506
1746
  }
@@ -1508,11 +1748,13 @@ TEST(LeakGlobalContextViaMapProto) {
1508
1748
 
1509
1749
  TEST(InstanceOfStubWriteBarrier) {
1510
1750
  i::FLAG_allow_natives_syntax = true;
1511
- #ifdef DEBUG
1751
+ #ifdef VERIFY_HEAP
1512
1752
  i::FLAG_verify_heap = true;
1513
1753
  #endif
1754
+
1514
1755
  InitializeVM();
1515
1756
  if (!i::V8::UseCrankshaft()) return;
1757
+ if (i::FLAG_force_marking_deque_overflows) return;
1516
1758
  v8::HandleScope outer_scope;
1517
1759
 
1518
1760
  {
@@ -1582,30 +1824,34 @@ TEST(PrototypeTransitionClearing) {
1582
1824
  // Verify that only dead prototype transitions are cleared.
1583
1825
  CHECK_EQ(10, baseObject->map()->NumberOfProtoTransitions());
1584
1826
  HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1585
- CHECK_EQ(10 - 3, baseObject->map()->NumberOfProtoTransitions());
1827
+ const int transitions = 10 - 3;
1828
+ CHECK_EQ(transitions, baseObject->map()->NumberOfProtoTransitions());
1586
1829
 
1587
1830
  // Verify that prototype transitions array was compacted.
1588
- FixedArray* trans = baseObject->map()->prototype_transitions();
1589
- for (int i = 0; i < 10 - 3; i++) {
1831
+ FixedArray* trans = baseObject->map()->GetPrototypeTransitions();
1832
+ for (int i = 0; i < transitions; i++) {
1590
1833
  int j = Map::kProtoTransitionHeaderSize +
1591
1834
  i * Map::kProtoTransitionElementsPerEntry;
1592
1835
  CHECK(trans->get(j + Map::kProtoTransitionMapOffset)->IsMap());
1593
- CHECK(trans->get(j + Map::kProtoTransitionPrototypeOffset)->IsJSObject());
1836
+ Object* proto = trans->get(j + Map::kProtoTransitionPrototypeOffset);
1837
+ CHECK(proto->IsTheHole() || proto->IsJSObject());
1594
1838
  }
1595
1839
 
1596
1840
  // Make sure next prototype is placed on an old-space evacuation candidate.
1597
1841
  Handle<JSObject> prototype;
1598
1842
  PagedSpace* space = HEAP->old_pointer_space();
1599
- do {
1843
+ {
1844
+ AlwaysAllocateScope always_allocate;
1845
+ SimulateFullSpace(space);
1600
1846
  prototype = FACTORY->NewJSArray(32 * KB, FAST_HOLEY_ELEMENTS, TENURED);
1601
- } while (space->FirstPage() == space->LastPage() ||
1602
- !space->LastPage()->Contains(prototype->address()));
1847
+ }
1603
1848
 
1604
1849
  // Add a prototype on an evacuation candidate and verify that transition
1605
1850
  // clearing correctly records slots in prototype transition array.
1606
1851
  i::FLAG_always_compact = true;
1607
1852
  Handle<Map> map(baseObject->map());
1608
- CHECK(!space->LastPage()->Contains(map->prototype_transitions()->address()));
1853
+ CHECK(!space->LastPage()->Contains(
1854
+ map->GetPrototypeTransitions()->address()));
1609
1855
  CHECK(space->LastPage()->Contains(prototype->address()));
1610
1856
  baseObject->SetPrototype(*prototype, false)->ToObjectChecked();
1611
1857
  CHECK(map->GetPrototypeTransition(*prototype)->IsMap());
@@ -1616,9 +1862,10 @@ TEST(PrototypeTransitionClearing) {
1616
1862
 
1617
1863
  TEST(ResetSharedFunctionInfoCountersDuringIncrementalMarking) {
1618
1864
  i::FLAG_allow_natives_syntax = true;
1619
- #ifdef DEBUG
1865
+ #ifdef VERIFY_HEAP
1620
1866
  i::FLAG_verify_heap = true;
1621
1867
  #endif
1868
+
1622
1869
  InitializeVM();
1623
1870
  if (!i::V8::UseCrankshaft()) return;
1624
1871
  v8::HandleScope outer_scope;
@@ -1671,9 +1918,10 @@ TEST(ResetSharedFunctionInfoCountersDuringIncrementalMarking) {
1671
1918
 
1672
1919
  TEST(ResetSharedFunctionInfoCountersDuringMarkSweep) {
1673
1920
  i::FLAG_allow_natives_syntax = true;
1674
- #ifdef DEBUG
1921
+ #ifdef VERIFY_HEAP
1675
1922
  i::FLAG_verify_heap = true;
1676
1923
  #endif
1924
+
1677
1925
  InitializeVM();
1678
1926
  if (!i::V8::UseCrankshaft()) return;
1679
1927
  v8::HandleScope outer_scope;
@@ -1715,9 +1963,10 @@ TEST(OptimizedAllocationAlwaysInNewSpace) {
1715
1963
  i::FLAG_allow_natives_syntax = true;
1716
1964
  InitializeVM();
1717
1965
  if (!i::V8::UseCrankshaft() || i::FLAG_always_opt) return;
1966
+ if (i::FLAG_gc_global || i::FLAG_stress_compaction) return;
1718
1967
  v8::HandleScope scope;
1719
1968
 
1720
- FillUpNewSpace(HEAP->new_space());
1969
+ SimulateFullSpace(HEAP->new_space());
1721
1970
  AlwaysAllocateScope always_allocate;
1722
1971
  v8::Local<v8::Value> res = CompileRun(
1723
1972
  "function c(x) {"
@@ -1740,14 +1989,7 @@ TEST(OptimizedAllocationAlwaysInNewSpace) {
1740
1989
 
1741
1990
 
1742
1991
  static int CountMapTransitions(Map* map) {
1743
- int result = 0;
1744
- DescriptorArray* descs = map->instance_descriptors();
1745
- for (int i = 0; i < descs->number_of_descriptors(); i++) {
1746
- if (descs->IsTransitionOnly(i)) {
1747
- result++;
1748
- }
1749
- }
1750
- return result;
1992
+ return map->transitions()->number_of_transitions();
1751
1993
  }
1752
1994
 
1753
1995
 
@@ -1758,14 +2000,18 @@ TEST(Regress1465) {
1758
2000
  i::FLAG_trace_incremental_marking = true;
1759
2001
  InitializeVM();
1760
2002
  v8::HandleScope scope;
2003
+ static const int transitions_count = 256;
1761
2004
 
1762
- #define TRANSITION_COUNT 256
1763
- for (int i = 0; i < TRANSITION_COUNT; i++) {
1764
- EmbeddedVector<char, 64> buffer;
1765
- OS::SNPrintF(buffer, "var o = new Object; o.prop%d = %d;", i, i);
1766
- CompileRun(buffer.start());
2005
+ {
2006
+ AlwaysAllocateScope always_allocate;
2007
+ for (int i = 0; i < transitions_count; i++) {
2008
+ EmbeddedVector<char, 64> buffer;
2009
+ OS::SNPrintF(buffer, "var o = new Object; o.prop%d = %d;", i, i);
2010
+ CompileRun(buffer.start());
2011
+ }
2012
+ CompileRun("var root = new Object;");
1767
2013
  }
1768
- CompileRun("var root = new Object;");
2014
+
1769
2015
  Handle<JSObject> root =
1770
2016
  v8::Utils::OpenHandle(
1771
2017
  *v8::Handle<v8::Object>::Cast(
@@ -1774,19 +2020,10 @@ TEST(Regress1465) {
1774
2020
  // Count number of live transitions before marking.
1775
2021
  int transitions_before = CountMapTransitions(root->map());
1776
2022
  CompileRun("%DebugPrint(root);");
1777
- CHECK_EQ(TRANSITION_COUNT, transitions_before);
2023
+ CHECK_EQ(transitions_count, transitions_before);
1778
2024
 
1779
- // Go through all incremental marking steps in one swoop.
1780
- IncrementalMarking* marking = HEAP->incremental_marking();
1781
- CHECK(marking->IsStopped());
1782
- marking->Start();
1783
- CHECK(marking->IsMarking());
1784
- while (!marking->IsComplete()) {
1785
- marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
1786
- }
1787
- CHECK(marking->IsComplete());
2025
+ SimulateIncrementalMarking();
1788
2026
  HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1789
- CHECK(marking->IsStopped());
1790
2027
 
1791
2028
  // Count number of live transitions after marking. Note that one transition
1792
2029
  // is left, because 'o' still holds an instance of one transition target.
@@ -1808,15 +2045,7 @@ TEST(Regress2143a) {
1808
2045
  "root.foo = 0;"
1809
2046
  "root = new Object;");
1810
2047
 
1811
- // Go through all incremental marking steps in one swoop.
1812
- IncrementalMarking* marking = HEAP->incremental_marking();
1813
- CHECK(marking->IsStopped());
1814
- marking->Start();
1815
- CHECK(marking->IsMarking());
1816
- while (!marking->IsComplete()) {
1817
- marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
1818
- }
1819
- CHECK(marking->IsComplete());
2048
+ SimulateIncrementalMarking();
1820
2049
 
1821
2050
  // Compile a StoreIC that performs the prepared map transition. This
1822
2051
  // will restart incremental marking and should make sure the root is
@@ -1832,7 +2061,6 @@ TEST(Regress2143a) {
1832
2061
 
1833
2062
  // Explicitly request GC to perform final marking step and sweeping.
1834
2063
  HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1835
- CHECK(marking->IsStopped());
1836
2064
 
1837
2065
  Handle<JSObject> root =
1838
2066
  v8::Utils::OpenHandle(
@@ -1858,15 +2086,7 @@ TEST(Regress2143b) {
1858
2086
  "root.foo = 0;"
1859
2087
  "root = new Object;");
1860
2088
 
1861
- // Go through all incremental marking steps in one swoop.
1862
- IncrementalMarking* marking = HEAP->incremental_marking();
1863
- CHECK(marking->IsStopped());
1864
- marking->Start();
1865
- CHECK(marking->IsMarking());
1866
- while (!marking->IsComplete()) {
1867
- marking->Step(MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD);
1868
- }
1869
- CHECK(marking->IsComplete());
2089
+ SimulateIncrementalMarking();
1870
2090
 
1871
2091
  // Compile an optimized LStoreNamedField that performs the prepared
1872
2092
  // map transition. This will restart incremental marking and should
@@ -1885,7 +2105,6 @@ TEST(Regress2143b) {
1885
2105
 
1886
2106
  // Explicitly request GC to perform final marking step and sweeping.
1887
2107
  HEAP->CollectAllGarbage(Heap::kNoGCFlags);
1888
- CHECK(marking->IsStopped());
1889
2108
 
1890
2109
  Handle<JSObject> root =
1891
2110
  v8::Utils::OpenHandle(
@@ -1896,3 +2115,725 @@ TEST(Regress2143b) {
1896
2115
  CHECK(root->IsJSObject());
1897
2116
  CHECK(root->map()->IsMap());
1898
2117
  }
2118
+
2119
+
2120
+ TEST(ReleaseOverReservedPages) {
2121
+ i::FLAG_trace_gc = true;
2122
+ // The optimizer can allocate stuff, messing up the test.
2123
+ i::FLAG_crankshaft = false;
2124
+ i::FLAG_always_opt = false;
2125
+ InitializeVM();
2126
+ v8::HandleScope scope;
2127
+ static const int number_of_test_pages = 20;
2128
+
2129
+ // Prepare many pages with low live-bytes count.
2130
+ PagedSpace* old_pointer_space = HEAP->old_pointer_space();
2131
+ CHECK_EQ(1, old_pointer_space->CountTotalPages());
2132
+ for (int i = 0; i < number_of_test_pages; i++) {
2133
+ AlwaysAllocateScope always_allocate;
2134
+ SimulateFullSpace(old_pointer_space);
2135
+ FACTORY->NewFixedArray(1, TENURED);
2136
+ }
2137
+ CHECK_EQ(number_of_test_pages + 1, old_pointer_space->CountTotalPages());
2138
+
2139
+ // Triggering one GC will cause a lot of garbage to be discovered but
2140
+ // even spread across all allocated pages.
2141
+ HEAP->CollectAllGarbage(Heap::kNoGCFlags, "triggered for preparation");
2142
+ CHECK_GE(number_of_test_pages + 1, old_pointer_space->CountTotalPages());
2143
+
2144
+ // Triggering subsequent GCs should cause at least half of the pages
2145
+ // to be released to the OS after at most two cycles.
2146
+ HEAP->CollectAllGarbage(Heap::kNoGCFlags, "triggered by test 1");
2147
+ CHECK_GE(number_of_test_pages + 1, old_pointer_space->CountTotalPages());
2148
+ HEAP->CollectAllGarbage(Heap::kNoGCFlags, "triggered by test 2");
2149
+ CHECK_GE(number_of_test_pages + 1, old_pointer_space->CountTotalPages() * 2);
2150
+
2151
+ // Triggering a last-resort GC should cause all pages to be released to the
2152
+ // OS so that other processes can seize the memory. If we get a failure here
2153
+ // where there are 2 pages left instead of 1, then we should increase the
2154
+ // size of the first page a little in SizeOfFirstPage in spaces.cc. The
2155
+ // first page should be small in order to reduce memory used when the VM
2156
+ // boots, but if the 20 small arrays don't fit on the first page then that's
2157
+ // an indication that it is too small.
2158
+ HEAP->CollectAllAvailableGarbage("triggered really hard");
2159
+ CHECK_EQ(1, old_pointer_space->CountTotalPages());
2160
+ }
2161
+
2162
+
2163
+ TEST(Regress2237) {
2164
+ InitializeVM();
2165
+ v8::HandleScope scope;
2166
+ Handle<String> slice(HEAP->empty_string());
2167
+
2168
+ {
2169
+ // Generate a parent that lives in new-space.
2170
+ v8::HandleScope inner_scope;
2171
+ const char* c = "This text is long enough to trigger sliced strings.";
2172
+ Handle<String> s = FACTORY->NewStringFromAscii(CStrVector(c));
2173
+ CHECK(s->IsSeqOneByteString());
2174
+ CHECK(HEAP->InNewSpace(*s));
2175
+
2176
+ // Generate a sliced string that is based on the above parent and
2177
+ // lives in old-space.
2178
+ SimulateFullSpace(HEAP->new_space());
2179
+ AlwaysAllocateScope always_allocate;
2180
+ Handle<String> t = FACTORY->NewProperSubString(s, 5, 35);
2181
+ CHECK(t->IsSlicedString());
2182
+ CHECK(!HEAP->InNewSpace(*t));
2183
+ *slice.location() = *t.location();
2184
+ }
2185
+
2186
+ CHECK(SlicedString::cast(*slice)->parent()->IsSeqOneByteString());
2187
+ HEAP->CollectAllGarbage(Heap::kNoGCFlags);
2188
+ CHECK(SlicedString::cast(*slice)->parent()->IsSeqOneByteString());
2189
+ }
2190
+
2191
+
2192
+ #ifdef OBJECT_PRINT
2193
+ TEST(PrintSharedFunctionInfo) {
2194
+ InitializeVM();
2195
+ v8::HandleScope scope;
2196
+ const char* source = "f = function() { return 987654321; }\n"
2197
+ "g = function() { return 123456789; }\n";
2198
+ CompileRun(source);
2199
+ Handle<JSFunction> g =
2200
+ v8::Utils::OpenHandle(
2201
+ *v8::Handle<v8::Function>::Cast(
2202
+ v8::Context::GetCurrent()->Global()->Get(v8_str("g"))));
2203
+
2204
+ AssertNoAllocation no_alloc;
2205
+ g->shared()->PrintLn();
2206
+ }
2207
+ #endif // OBJECT_PRINT
2208
+
2209
+
2210
+ TEST(Regress2211) {
2211
+ InitializeVM();
2212
+ v8::HandleScope scope;
2213
+
2214
+ v8::Handle<v8::String> value = v8_str("val string");
2215
+ Smi* hash = Smi::FromInt(321);
2216
+ Heap* heap = Isolate::Current()->heap();
2217
+
2218
+ for (int i = 0; i < 2; i++) {
2219
+ // Store identity hash first and common hidden property second.
2220
+ v8::Handle<v8::Object> obj = v8::Object::New();
2221
+ Handle<JSObject> internal_obj = v8::Utils::OpenHandle(*obj);
2222
+ CHECK(internal_obj->HasFastProperties());
2223
+
2224
+ // In the first iteration, set hidden value first and identity hash second.
2225
+ // In the second iteration, reverse the order.
2226
+ if (i == 0) obj->SetHiddenValue(v8_str("key string"), value);
2227
+ MaybeObject* maybe_obj = internal_obj->SetIdentityHash(hash,
2228
+ ALLOW_CREATION);
2229
+ CHECK(!maybe_obj->IsFailure());
2230
+ if (i == 1) obj->SetHiddenValue(v8_str("key string"), value);
2231
+
2232
+ // Check values.
2233
+ CHECK_EQ(hash,
2234
+ internal_obj->GetHiddenProperty(heap->identity_hash_symbol()));
2235
+ CHECK(value->Equals(obj->GetHiddenValue(v8_str("key string"))));
2236
+
2237
+ // Check size.
2238
+ DescriptorArray* descriptors = internal_obj->map()->instance_descriptors();
2239
+ ObjectHashTable* hashtable = ObjectHashTable::cast(
2240
+ internal_obj->FastPropertyAt(descriptors->GetFieldIndex(0)));
2241
+ // HashTable header (5) and 4 initial entries (8).
2242
+ CHECK_LE(hashtable->SizeFor(hashtable->length()), 13 * kPointerSize);
2243
+ }
2244
+ }
2245
+
2246
+
2247
+ TEST(IncrementalMarkingClearsTypeFeedbackCells) {
2248
+ if (i::FLAG_always_opt) return;
2249
+ InitializeVM();
2250
+ v8::HandleScope scope;
2251
+ v8::Local<v8::Value> fun1, fun2;
2252
+
2253
+ {
2254
+ LocalContext env;
2255
+ CompileRun("function fun() {};");
2256
+ fun1 = env->Global()->Get(v8_str("fun"));
2257
+ }
2258
+
2259
+ {
2260
+ LocalContext env;
2261
+ CompileRun("function fun() {};");
2262
+ fun2 = env->Global()->Get(v8_str("fun"));
2263
+ }
2264
+
2265
+ // Prepare function f that contains type feedback for closures
2266
+ // originating from two different native contexts.
2267
+ v8::Context::GetCurrent()->Global()->Set(v8_str("fun1"), fun1);
2268
+ v8::Context::GetCurrent()->Global()->Set(v8_str("fun2"), fun2);
2269
+ CompileRun("function f(a, b) { a(); b(); } f(fun1, fun2);");
2270
+ Handle<JSFunction> f =
2271
+ v8::Utils::OpenHandle(
2272
+ *v8::Handle<v8::Function>::Cast(
2273
+ v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
2274
+ Handle<TypeFeedbackCells> cells(TypeFeedbackInfo::cast(
2275
+ f->shared()->code()->type_feedback_info())->type_feedback_cells());
2276
+
2277
+ CHECK_EQ(2, cells->CellCount());
2278
+ CHECK(cells->Cell(0)->value()->IsJSFunction());
2279
+ CHECK(cells->Cell(1)->value()->IsJSFunction());
2280
+
2281
+ SimulateIncrementalMarking();
2282
+ HEAP->CollectAllGarbage(Heap::kNoGCFlags);
2283
+
2284
+ CHECK_EQ(2, cells->CellCount());
2285
+ CHECK(cells->Cell(0)->value()->IsTheHole());
2286
+ CHECK(cells->Cell(1)->value()->IsTheHole());
2287
+ }
2288
+
2289
+
2290
+ static Code* FindFirstIC(Code* code, Code::Kind kind) {
2291
+ int mask = RelocInfo::ModeMask(RelocInfo::CODE_TARGET) |
2292
+ RelocInfo::ModeMask(RelocInfo::CONSTRUCT_CALL) |
2293
+ RelocInfo::ModeMask(RelocInfo::CODE_TARGET_WITH_ID) |
2294
+ RelocInfo::ModeMask(RelocInfo::CODE_TARGET_CONTEXT);
2295
+ for (RelocIterator it(code, mask); !it.done(); it.next()) {
2296
+ RelocInfo* info = it.rinfo();
2297
+ Code* target = Code::GetCodeFromTargetAddress(info->target_address());
2298
+ if (target->is_inline_cache_stub() && target->kind() == kind) {
2299
+ return target;
2300
+ }
2301
+ }
2302
+ return NULL;
2303
+ }
2304
+
2305
+
2306
+ TEST(IncrementalMarkingPreservesMonomorhpicIC) {
2307
+ if (i::FLAG_always_opt) return;
2308
+ InitializeVM();
2309
+ v8::HandleScope scope;
2310
+
2311
+ // Prepare function f that contains a monomorphic IC for object
2312
+ // originating from the same native context.
2313
+ CompileRun("function fun() { this.x = 1; }; var obj = new fun();"
2314
+ "function f(o) { return o.x; } f(obj); f(obj);");
2315
+ Handle<JSFunction> f =
2316
+ v8::Utils::OpenHandle(
2317
+ *v8::Handle<v8::Function>::Cast(
2318
+ v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
2319
+
2320
+ Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
2321
+ CHECK(ic_before->ic_state() == MONOMORPHIC);
2322
+
2323
+ SimulateIncrementalMarking();
2324
+ HEAP->CollectAllGarbage(Heap::kNoGCFlags);
2325
+
2326
+ Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
2327
+ CHECK(ic_after->ic_state() == MONOMORPHIC);
2328
+ }
2329
+
2330
+
2331
+ TEST(IncrementalMarkingClearsMonomorhpicIC) {
2332
+ if (i::FLAG_always_opt) return;
2333
+ InitializeVM();
2334
+ v8::HandleScope scope;
2335
+ v8::Local<v8::Value> obj1;
2336
+
2337
+ {
2338
+ LocalContext env;
2339
+ CompileRun("function fun() { this.x = 1; }; var obj = new fun();");
2340
+ obj1 = env->Global()->Get(v8_str("obj"));
2341
+ }
2342
+
2343
+ // Prepare function f that contains a monomorphic IC for object
2344
+ // originating from a different native context.
2345
+ v8::Context::GetCurrent()->Global()->Set(v8_str("obj1"), obj1);
2346
+ CompileRun("function f(o) { return o.x; } f(obj1); f(obj1);");
2347
+ Handle<JSFunction> f =
2348
+ v8::Utils::OpenHandle(
2349
+ *v8::Handle<v8::Function>::Cast(
2350
+ v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
2351
+
2352
+ Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
2353
+ CHECK(ic_before->ic_state() == MONOMORPHIC);
2354
+
2355
+ // Fire context dispose notification.
2356
+ v8::V8::ContextDisposedNotification();
2357
+ SimulateIncrementalMarking();
2358
+ HEAP->CollectAllGarbage(Heap::kNoGCFlags);
2359
+
2360
+ Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
2361
+ CHECK(ic_after->ic_state() == UNINITIALIZED);
2362
+ }
2363
+
2364
+
2365
+ TEST(IncrementalMarkingClearsPolymorhpicIC) {
2366
+ if (i::FLAG_always_opt) return;
2367
+ InitializeVM();
2368
+ v8::HandleScope scope;
2369
+ v8::Local<v8::Value> obj1, obj2;
2370
+
2371
+ {
2372
+ LocalContext env;
2373
+ CompileRun("function fun() { this.x = 1; }; var obj = new fun();");
2374
+ obj1 = env->Global()->Get(v8_str("obj"));
2375
+ }
2376
+
2377
+ {
2378
+ LocalContext env;
2379
+ CompileRun("function fun() { this.x = 2; }; var obj = new fun();");
2380
+ obj2 = env->Global()->Get(v8_str("obj"));
2381
+ }
2382
+
2383
+ // Prepare function f that contains a polymorphic IC for objects
2384
+ // originating from two different native contexts.
2385
+ v8::Context::GetCurrent()->Global()->Set(v8_str("obj1"), obj1);
2386
+ v8::Context::GetCurrent()->Global()->Set(v8_str("obj2"), obj2);
2387
+ CompileRun("function f(o) { return o.x; } f(obj1); f(obj1); f(obj2);");
2388
+ Handle<JSFunction> f =
2389
+ v8::Utils::OpenHandle(
2390
+ *v8::Handle<v8::Function>::Cast(
2391
+ v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
2392
+
2393
+ Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
2394
+ CHECK(ic_before->ic_state() == MEGAMORPHIC);
2395
+
2396
+ // Fire context dispose notification.
2397
+ v8::V8::ContextDisposedNotification();
2398
+ SimulateIncrementalMarking();
2399
+ HEAP->CollectAllGarbage(Heap::kNoGCFlags);
2400
+
2401
+ Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC);
2402
+ CHECK(ic_after->ic_state() == UNINITIALIZED);
2403
+ }
2404
+
2405
+
2406
+ class SourceResource: public v8::String::ExternalAsciiStringResource {
2407
+ public:
2408
+ explicit SourceResource(const char* data)
2409
+ : data_(data), length_(strlen(data)) { }
2410
+
2411
+ virtual void Dispose() {
2412
+ i::DeleteArray(data_);
2413
+ data_ = NULL;
2414
+ }
2415
+
2416
+ const char* data() const { return data_; }
2417
+
2418
+ size_t length() const { return length_; }
2419
+
2420
+ bool IsDisposed() { return data_ == NULL; }
2421
+
2422
+ private:
2423
+ const char* data_;
2424
+ size_t length_;
2425
+ };
2426
+
2427
+
2428
+ void ReleaseStackTraceDataTest(const char* source) {
2429
+ // Test that the data retained by the Error.stack accessor is released
2430
+ // after the first time the accessor is fired. We use external string
2431
+ // to check whether the data is being released since the external string
2432
+ // resource's callback is fired when the external string is GC'ed.
2433
+ InitializeVM();
2434
+ v8::HandleScope scope;
2435
+ SourceResource* resource = new SourceResource(i::StrDup(source));
2436
+ {
2437
+ v8::HandleScope scope;
2438
+ v8::Handle<v8::String> source_string = v8::String::NewExternal(resource);
2439
+ v8::Script::Compile(source_string)->Run();
2440
+ CHECK(!resource->IsDisposed());
2441
+ }
2442
+ HEAP->CollectAllAvailableGarbage();
2443
+
2444
+ // External source has been released.
2445
+ CHECK(resource->IsDisposed());
2446
+ delete resource;
2447
+ }
2448
+
2449
+
2450
+ TEST(ReleaseStackTraceData) {
2451
+ static const char* source1 = "var error = null; "
2452
+ /* Normal Error */ "try { "
2453
+ " throw new Error(); "
2454
+ "} catch (e) { "
2455
+ " error = e; "
2456
+ "} ";
2457
+ static const char* source2 = "var error = null; "
2458
+ /* Stack overflow */ "try { "
2459
+ " (function f() { f(); })(); "
2460
+ "} catch (e) { "
2461
+ " error = e; "
2462
+ "} ";
2463
+ ReleaseStackTraceDataTest(source1);
2464
+ ReleaseStackTraceDataTest(source2);
2465
+ }
2466
+
2467
+
2468
+ TEST(Regression144230) {
2469
+ InitializeVM();
2470
+ v8::HandleScope scope;
2471
+
2472
+ // First make sure that the uninitialized CallIC stub is on a single page
2473
+ // that will later be selected as an evacuation candidate.
2474
+ {
2475
+ v8::HandleScope inner_scope;
2476
+ AlwaysAllocateScope always_allocate;
2477
+ SimulateFullSpace(HEAP->code_space());
2478
+ ISOLATE->stub_cache()->ComputeCallInitialize(9, RelocInfo::CODE_TARGET);
2479
+ }
2480
+
2481
+ // Second compile a CallIC and execute it once so that it gets patched to
2482
+ // the pre-monomorphic stub. These code objects are on yet another page.
2483
+ {
2484
+ v8::HandleScope inner_scope;
2485
+ AlwaysAllocateScope always_allocate;
2486
+ SimulateFullSpace(HEAP->code_space());
2487
+ CompileRun("var o = { f:function(a,b,c,d,e,f,g,h,i) {}};"
2488
+ "function call() { o.f(1,2,3,4,5,6,7,8,9); };"
2489
+ "call();");
2490
+ }
2491
+
2492
+ // Third we fill up the last page of the code space so that it does not get
2493
+ // chosen as an evacuation candidate.
2494
+ {
2495
+ v8::HandleScope inner_scope;
2496
+ AlwaysAllocateScope always_allocate;
2497
+ CompileRun("for (var i = 0; i < 2000; i++) {"
2498
+ " eval('function f' + i + '() { return ' + i +'; };' +"
2499
+ " 'f' + i + '();');"
2500
+ "}");
2501
+ }
2502
+ HEAP->CollectAllGarbage(Heap::kNoGCFlags);
2503
+
2504
+ // Fourth is the tricky part. Make sure the code containing the CallIC is
2505
+ // visited first without clearing the IC. The shared function info is then
2506
+ // visited later, causing the CallIC to be cleared.
2507
+ Handle<String> name = FACTORY->LookupUtf8Symbol("call");
2508
+ Handle<GlobalObject> global(ISOLATE->context()->global_object());
2509
+ MaybeObject* maybe_call = global->GetProperty(*name);
2510
+ JSFunction* call = JSFunction::cast(maybe_call->ToObjectChecked());
2511
+ USE(global->SetProperty(*name, Smi::FromInt(0), NONE, kNonStrictMode));
2512
+ ISOLATE->compilation_cache()->Clear();
2513
+ call->shared()->set_ic_age(HEAP->global_ic_age() + 1);
2514
+ Handle<Object> call_code(call->code());
2515
+ Handle<Object> call_function(call);
2516
+
2517
+ // Now we are ready to mess up the heap.
2518
+ HEAP->CollectAllGarbage(Heap::kReduceMemoryFootprintMask);
2519
+
2520
+ // Either heap verification caught the problem already or we go kaboom once
2521
+ // the CallIC is executed the next time.
2522
+ USE(global->SetProperty(*name, *call_function, NONE, kNonStrictMode));
2523
+ CompileRun("call();");
2524
+ }
2525
+
2526
+
2527
+ TEST(Regress159140) {
2528
+ i::FLAG_allow_natives_syntax = true;
2529
+ i::FLAG_flush_code_incrementally = true;
2530
+ InitializeVM();
2531
+ v8::HandleScope scope;
2532
+
2533
+ // Perform one initial GC to enable code flushing.
2534
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
2535
+
2536
+ // Prepare several closures that are all eligible for code flushing
2537
+ // because all reachable ones are not optimized. Make sure that the
2538
+ // optimized code object is directly reachable through a handle so
2539
+ // that it is marked black during incremental marking.
2540
+ Handle<Code> code;
2541
+ {
2542
+ HandleScope inner_scope;
2543
+ CompileRun("function h(x) {}"
2544
+ "function mkClosure() {"
2545
+ " return function(x) { return x + 1; };"
2546
+ "}"
2547
+ "var f = mkClosure();"
2548
+ "var g = mkClosure();"
2549
+ "f(1); f(2);"
2550
+ "g(1); g(2);"
2551
+ "h(1); h(2);"
2552
+ "%OptimizeFunctionOnNextCall(f); f(3);"
2553
+ "%OptimizeFunctionOnNextCall(h); h(3);");
2554
+
2555
+ Handle<JSFunction> f =
2556
+ v8::Utils::OpenHandle(
2557
+ *v8::Handle<v8::Function>::Cast(
2558
+ v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
2559
+ CHECK(f->is_compiled());
2560
+ CompileRun("f = null;");
2561
+
2562
+ Handle<JSFunction> g =
2563
+ v8::Utils::OpenHandle(
2564
+ *v8::Handle<v8::Function>::Cast(
2565
+ v8::Context::GetCurrent()->Global()->Get(v8_str("g"))));
2566
+ CHECK(g->is_compiled());
2567
+ const int kAgingThreshold = 6;
2568
+ for (int i = 0; i < kAgingThreshold; i++) {
2569
+ g->code()->MakeOlder(static_cast<MarkingParity>(i % 2));
2570
+ }
2571
+
2572
+ code = inner_scope.CloseAndEscape(Handle<Code>(f->code()));
2573
+ }
2574
+
2575
+ // Simulate incremental marking so that the functions are enqueued as
2576
+ // code flushing candidates. Then optimize one function. Finally
2577
+ // finish the GC to complete code flushing.
2578
+ SimulateIncrementalMarking();
2579
+ CompileRun("%OptimizeFunctionOnNextCall(g); g(3);");
2580
+ HEAP->CollectAllGarbage(Heap::kNoGCFlags);
2581
+
2582
+ // Unoptimized code is missing and the deoptimizer will go ballistic.
2583
+ CompileRun("g('bozo');");
2584
+ }
2585
+
2586
+
2587
+ TEST(Regress165495) {
2588
+ i::FLAG_allow_natives_syntax = true;
2589
+ i::FLAG_flush_code_incrementally = true;
2590
+ InitializeVM();
2591
+ v8::HandleScope scope;
2592
+
2593
+ // Perform one initial GC to enable code flushing.
2594
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
2595
+
2596
+ // Prepare an optimized closure that the optimized code map will get
2597
+ // populated. Then age the unoptimized code to trigger code flushing
2598
+ // but make sure the optimized code is unreachable.
2599
+ {
2600
+ HandleScope inner_scope;
2601
+ CompileRun("function mkClosure() {"
2602
+ " return function(x) { return x + 1; };"
2603
+ "}"
2604
+ "var f = mkClosure();"
2605
+ "f(1); f(2);"
2606
+ "%OptimizeFunctionOnNextCall(f); f(3);");
2607
+
2608
+ Handle<JSFunction> f =
2609
+ v8::Utils::OpenHandle(
2610
+ *v8::Handle<v8::Function>::Cast(
2611
+ v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
2612
+ CHECK(f->is_compiled());
2613
+ const int kAgingThreshold = 6;
2614
+ for (int i = 0; i < kAgingThreshold; i++) {
2615
+ f->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2));
2616
+ }
2617
+
2618
+ CompileRun("f = null;");
2619
+ }
2620
+
2621
+ // Simulate incremental marking so that unoptimized code is flushed
2622
+ // even though it still is cached in the optimized code map.
2623
+ SimulateIncrementalMarking();
2624
+ HEAP->CollectAllGarbage(Heap::kNoGCFlags);
2625
+
2626
+ // Make a new closure that will get code installed from the code map.
2627
+ // Unoptimized code is missing and the deoptimizer will go ballistic.
2628
+ CompileRun("var g = mkClosure(); g('bozo');");
2629
+ }
2630
+
2631
+
2632
+ TEST(Regress169209) {
2633
+ i::FLAG_stress_compaction = false;
2634
+ i::FLAG_allow_natives_syntax = true;
2635
+ i::FLAG_flush_code_incrementally = true;
2636
+ InitializeVM();
2637
+ v8::HandleScope scope;
2638
+
2639
+ // Perform one initial GC to enable code flushing.
2640
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
2641
+
2642
+ // Prepare a shared function info eligible for code flushing for which
2643
+ // the unoptimized code will be replaced during optimization.
2644
+ Handle<SharedFunctionInfo> shared1;
2645
+ {
2646
+ HandleScope inner_scope;
2647
+ CompileRun("function f() { return 'foobar'; }"
2648
+ "function g(x) { if (x) f(); }"
2649
+ "f();"
2650
+ "g(false);"
2651
+ "g(false);");
2652
+
2653
+ Handle<JSFunction> f =
2654
+ v8::Utils::OpenHandle(
2655
+ *v8::Handle<v8::Function>::Cast(
2656
+ v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
2657
+ CHECK(f->is_compiled());
2658
+ const int kAgingThreshold = 6;
2659
+ for (int i = 0; i < kAgingThreshold; i++) {
2660
+ f->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2));
2661
+ }
2662
+
2663
+ shared1 = inner_scope.CloseAndEscape(handle(f->shared(), ISOLATE));
2664
+ }
2665
+
2666
+ // Prepare a shared function info eligible for code flushing that will
2667
+ // represent the dangling tail of the candidate list.
2668
+ Handle<SharedFunctionInfo> shared2;
2669
+ {
2670
+ HandleScope inner_scope;
2671
+ CompileRun("function flushMe() { return 0; }"
2672
+ "flushMe(1);");
2673
+
2674
+ Handle<JSFunction> f =
2675
+ v8::Utils::OpenHandle(
2676
+ *v8::Handle<v8::Function>::Cast(
2677
+ v8::Context::GetCurrent()->Global()->Get(v8_str("flushMe"))));
2678
+ CHECK(f->is_compiled());
2679
+ const int kAgingThreshold = 6;
2680
+ for (int i = 0; i < kAgingThreshold; i++) {
2681
+ f->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2));
2682
+ }
2683
+
2684
+ shared2 = inner_scope.CloseAndEscape(handle(f->shared(), ISOLATE));
2685
+ }
2686
+
2687
+ // Simulate incremental marking and collect code flushing candidates.
2688
+ SimulateIncrementalMarking();
2689
+ CHECK(shared1->code()->gc_metadata() != NULL);
2690
+
2691
+ // Optimize function and make sure the unoptimized code is replaced.
2692
+ #ifdef DEBUG
2693
+ FLAG_stop_at = "f";
2694
+ #endif
2695
+ CompileRun("%OptimizeFunctionOnNextCall(g);"
2696
+ "g(false);");
2697
+
2698
+ // Finish garbage collection cycle.
2699
+ HEAP->CollectAllGarbage(Heap::kNoGCFlags);
2700
+ CHECK(shared1->code()->gc_metadata() == NULL);
2701
+ }
2702
+
2703
+
2704
+ // Helper function that simulates a fill new-space in the heap.
2705
+ static inline void AllocateAllButNBytes(v8::internal::NewSpace* space,
2706
+ int extra_bytes) {
2707
+ int space_remaining = static_cast<int>(
2708
+ *space->allocation_limit_address() - *space->allocation_top_address());
2709
+ CHECK(space_remaining >= extra_bytes);
2710
+ int new_linear_size = space_remaining - extra_bytes;
2711
+ v8::internal::MaybeObject* maybe = space->AllocateRaw(new_linear_size);
2712
+ v8::internal::FreeListNode* node = v8::internal::FreeListNode::cast(maybe);
2713
+ node->set_size(space->heap(), new_linear_size);
2714
+ }
2715
+
2716
+
2717
+ TEST(Regress169928) {
2718
+ i::FLAG_allow_natives_syntax = true;
2719
+ i::FLAG_crankshaft = false;
2720
+ InitializeVM();
2721
+ v8::HandleScope scope;
2722
+
2723
+ // Some flags turn Scavenge collections into Mark-sweep collections
2724
+ // and hence are incompatible with this test case.
2725
+ if (FLAG_gc_global || FLAG_stress_compaction) return;
2726
+
2727
+ // Prepare the environment
2728
+ CompileRun("function fastliteralcase(literal, value) {"
2729
+ " literal[0] = value;"
2730
+ " return literal;"
2731
+ "}"
2732
+ "function get_standard_literal() {"
2733
+ " var literal = [1, 2, 3];"
2734
+ " return literal;"
2735
+ "}"
2736
+ "obj = fastliteralcase(get_standard_literal(), 1);"
2737
+ "obj = fastliteralcase(get_standard_literal(), 1.5);"
2738
+ "obj = fastliteralcase(get_standard_literal(), 2);");
2739
+
2740
+ // prepare the heap
2741
+ v8::Local<v8::String> mote_code_string =
2742
+ v8_str("fastliteralcase(mote, 2.5);");
2743
+
2744
+ v8::Local<v8::String> array_name = v8_str("mote");
2745
+ v8::Context::GetCurrent()->Global()->Set(array_name, v8::Int32::New(0));
2746
+
2747
+ // First make sure we flip spaces
2748
+ HEAP->CollectGarbage(NEW_SPACE);
2749
+
2750
+ // Allocate the object.
2751
+ Handle<FixedArray> array_data = FACTORY->NewFixedArray(2, NOT_TENURED);
2752
+ array_data->set(0, Smi::FromInt(1));
2753
+ array_data->set(1, Smi::FromInt(2));
2754
+
2755
+ AllocateAllButNBytes(HEAP->new_space(),
2756
+ JSArray::kSize + AllocationSiteInfo::kSize +
2757
+ kPointerSize);
2758
+
2759
+ Handle<JSArray> array = FACTORY->NewJSArrayWithElements(array_data,
2760
+ FAST_SMI_ELEMENTS,
2761
+ NOT_TENURED);
2762
+
2763
+ CHECK_EQ(Smi::FromInt(2), array->length());
2764
+ CHECK(array->HasFastSmiOrObjectElements());
2765
+
2766
+ // We need filler the size of AllocationSiteInfo object, plus an extra
2767
+ // fill pointer value.
2768
+ MaybeObject* maybe_object = HEAP->AllocateRaw(
2769
+ AllocationSiteInfo::kSize + kPointerSize, NEW_SPACE, OLD_POINTER_SPACE);
2770
+ Object* obj = NULL;
2771
+ CHECK(maybe_object->ToObject(&obj));
2772
+ Address addr_obj = reinterpret_cast<Address>(
2773
+ reinterpret_cast<byte*>(obj - kHeapObjectTag));
2774
+ HEAP->CreateFillerObjectAt(addr_obj,
2775
+ AllocationSiteInfo::kSize + kPointerSize);
2776
+
2777
+ // Give the array a name, making sure not to allocate strings.
2778
+ v8::Handle<v8::Object> array_obj = v8::Utils::ToLocal(array);
2779
+ v8::Context::GetCurrent()->Global()->Set(array_name, array_obj);
2780
+
2781
+ // This should crash with a protection violation if we are running a build
2782
+ // with the bug.
2783
+ AlwaysAllocateScope aa_scope;
2784
+ v8::Script::Compile(mote_code_string)->Run();
2785
+ }
2786
+
2787
+
2788
+ TEST(Regress168801) {
2789
+ i::FLAG_always_compact = true;
2790
+ i::FLAG_cache_optimized_code = false;
2791
+ i::FLAG_allow_natives_syntax = true;
2792
+ i::FLAG_flush_code_incrementally = true;
2793
+ InitializeVM();
2794
+ v8::HandleScope scope;
2795
+
2796
+ // Perform one initial GC to enable code flushing.
2797
+ HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
2798
+
2799
+ // Ensure the code ends up on an evacuation candidate.
2800
+ SimulateFullSpace(HEAP->code_space());
2801
+
2802
+ // Prepare an unoptimized function that is eligible for code flushing.
2803
+ Handle<JSFunction> function;
2804
+ {
2805
+ HandleScope inner_scope;
2806
+ CompileRun("function mkClosure() {"
2807
+ " return function(x) { return x + 1; };"
2808
+ "}"
2809
+ "var f = mkClosure();"
2810
+ "f(1); f(2);");
2811
+
2812
+ Handle<JSFunction> f =
2813
+ v8::Utils::OpenHandle(
2814
+ *v8::Handle<v8::Function>::Cast(
2815
+ v8::Context::GetCurrent()->Global()->Get(v8_str("f"))));
2816
+ CHECK(f->is_compiled());
2817
+ const int kAgingThreshold = 6;
2818
+ for (int i = 0; i < kAgingThreshold; i++) {
2819
+ f->shared()->code()->MakeOlder(static_cast<MarkingParity>(i % 2));
2820
+ }
2821
+
2822
+ function = inner_scope.CloseAndEscape(handle(*f, ISOLATE));
2823
+ }
2824
+
2825
+ // Simulate incremental marking so that unoptimized function is enqueued as a
2826
+ // candidate for code flushing. The shared function info however will not be
2827
+ // explicitly enqueued.
2828
+ SimulateIncrementalMarking();
2829
+
2830
+ // Now optimize the function so that it is taken off the candidate list.
2831
+ {
2832
+ HandleScope inner_scope;
2833
+ CompileRun("%OptimizeFunctionOnNextCall(f); f(3);");
2834
+ }
2835
+
2836
+ // This cycle will bust the heap and subsequent cycles will go ballistic.
2837
+ HEAP->CollectAllGarbage(Heap::kNoGCFlags);
2838
+ HEAP->CollectAllGarbage(Heap::kNoGCFlags);
2839
+ }