mustang 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (560) hide show
  1. data/.rspec +1 -0
  2. data/Isolate +9 -0
  3. data/README.md +6 -12
  4. data/Rakefile +30 -4
  5. data/TODO.md +9 -0
  6. data/ext/v8/extconf.rb +56 -0
  7. data/ext/v8/v8.cpp +37 -0
  8. data/ext/v8/v8_array.cpp +161 -0
  9. data/ext/v8/v8_array.h +17 -0
  10. data/ext/v8/v8_base.cpp +147 -0
  11. data/ext/v8/v8_base.h +23 -0
  12. data/ext/v8/v8_cast.cpp +151 -0
  13. data/ext/v8/v8_cast.h +64 -0
  14. data/ext/v8/v8_context.cpp +174 -0
  15. data/ext/v8/v8_context.h +12 -0
  16. data/ext/v8/v8_date.cpp +61 -0
  17. data/ext/v8/v8_date.h +16 -0
  18. data/ext/v8/v8_errors.cpp +147 -0
  19. data/ext/v8/v8_errors.h +19 -0
  20. data/ext/v8/v8_external.cpp +66 -0
  21. data/ext/v8/v8_external.h +16 -0
  22. data/ext/v8/v8_function.cpp +182 -0
  23. data/ext/v8/v8_function.h +14 -0
  24. data/ext/v8/v8_integer.cpp +70 -0
  25. data/ext/v8/v8_integer.h +16 -0
  26. data/ext/v8/v8_macros.h +30 -0
  27. data/ext/v8/v8_main.cpp +53 -0
  28. data/ext/v8/v8_main.h +13 -0
  29. data/ext/v8/v8_number.cpp +62 -0
  30. data/ext/v8/v8_number.h +16 -0
  31. data/ext/v8/v8_object.cpp +172 -0
  32. data/ext/v8/v8_object.h +17 -0
  33. data/ext/v8/v8_ref.cpp +72 -0
  34. data/ext/v8/v8_ref.h +43 -0
  35. data/ext/v8/v8_regexp.cpp +148 -0
  36. data/ext/v8/v8_regexp.h +16 -0
  37. data/ext/v8/v8_string.cpp +78 -0
  38. data/ext/v8/v8_string.h +16 -0
  39. data/ext/v8/v8_value.cpp +370 -0
  40. data/ext/v8/v8_value.h +19 -0
  41. data/gemspec.yml +2 -1
  42. data/lib/core_ext/class.rb +14 -0
  43. data/lib/core_ext/object.rb +12 -0
  44. data/lib/core_ext/symbol.rb +23 -0
  45. data/lib/mustang.rb +44 -0
  46. data/lib/mustang/context.rb +69 -0
  47. data/lib/mustang/errors.rb +36 -0
  48. data/lib/support/delegated.rb +25 -0
  49. data/lib/v8/array.rb +21 -0
  50. data/lib/v8/context.rb +13 -0
  51. data/lib/v8/date.rb +20 -0
  52. data/lib/v8/error.rb +15 -0
  53. data/lib/v8/external.rb +16 -0
  54. data/lib/v8/function.rb +11 -0
  55. data/lib/v8/integer.rb +16 -0
  56. data/lib/v8/number.rb +16 -0
  57. data/lib/v8/object.rb +66 -0
  58. data/lib/v8/regexp.rb +23 -0
  59. data/lib/v8/string.rb +27 -0
  60. data/mustang.gemspec +3 -0
  61. data/spec/core_ext/class_spec.rb +19 -0
  62. data/spec/core_ext/object_spec.rb +19 -0
  63. data/spec/core_ext/symbol_spec.rb +27 -0
  64. data/spec/fixtures/test1.js +2 -0
  65. data/spec/fixtures/test2.js +2 -0
  66. data/spec/spec_helper.rb +20 -0
  67. data/spec/v8/array_spec.rb +88 -0
  68. data/spec/v8/cast_spec.rb +151 -0
  69. data/spec/v8/context_spec.rb +78 -0
  70. data/spec/v8/data_spec.rb +39 -0
  71. data/spec/v8/date_spec.rb +45 -0
  72. data/spec/v8/empty_spec.rb +27 -0
  73. data/spec/v8/errors_spec.rb +142 -0
  74. data/spec/v8/external_spec.rb +44 -0
  75. data/spec/v8/function_spec.rb +170 -0
  76. data/spec/v8/integer_spec.rb +41 -0
  77. data/spec/v8/main_spec.rb +18 -0
  78. data/spec/v8/null_spec.rb +27 -0
  79. data/spec/v8/number_spec.rb +40 -0
  80. data/spec/v8/object_spec.rb +79 -0
  81. data/spec/v8/primitive_spec.rb +9 -0
  82. data/spec/v8/regexp_spec.rb +65 -0
  83. data/spec/v8/string_spec.rb +48 -0
  84. data/spec/v8/undefined_spec.rb +27 -0
  85. data/spec/v8/value_spec.rb +215 -0
  86. data/vendor/v8/.gitignore +2 -0
  87. data/vendor/v8/AUTHORS +3 -1
  88. data/vendor/v8/ChangeLog +117 -0
  89. data/vendor/v8/SConstruct +334 -53
  90. data/vendor/v8/include/v8-debug.h +21 -11
  91. data/vendor/v8/include/v8-preparser.h +1 -1
  92. data/vendor/v8/include/v8-profiler.h +122 -43
  93. data/vendor/v8/include/v8-testing.h +5 -0
  94. data/vendor/v8/include/v8.h +171 -17
  95. data/vendor/v8/preparser/SConscript +38 -0
  96. data/vendor/v8/preparser/preparser-process.cc +77 -114
  97. data/vendor/v8/samples/shell.cc +232 -46
  98. data/vendor/v8/src/SConscript +29 -5
  99. data/vendor/v8/src/accessors.cc +70 -211
  100. data/vendor/v8/{test/cctest/test-mips.cc → src/allocation-inl.h} +15 -18
  101. data/vendor/v8/src/allocation.cc +0 -82
  102. data/vendor/v8/src/allocation.h +9 -42
  103. data/vendor/v8/src/api.cc +1645 -1156
  104. data/vendor/v8/src/api.h +76 -12
  105. data/vendor/v8/src/apiutils.h +0 -7
  106. data/vendor/v8/src/arguments.h +15 -4
  107. data/vendor/v8/src/arm/assembler-arm-inl.h +10 -9
  108. data/vendor/v8/src/arm/assembler-arm.cc +62 -23
  109. data/vendor/v8/src/arm/assembler-arm.h +76 -11
  110. data/vendor/v8/src/arm/builtins-arm.cc +39 -33
  111. data/vendor/v8/src/arm/code-stubs-arm.cc +1182 -402
  112. data/vendor/v8/src/arm/code-stubs-arm.h +20 -54
  113. data/vendor/v8/src/arm/codegen-arm.cc +159 -106
  114. data/vendor/v8/src/arm/codegen-arm.h +6 -6
  115. data/vendor/v8/src/arm/constants-arm.h +16 -1
  116. data/vendor/v8/src/arm/cpu-arm.cc +7 -5
  117. data/vendor/v8/src/arm/debug-arm.cc +6 -4
  118. data/vendor/v8/src/arm/deoptimizer-arm.cc +51 -14
  119. data/vendor/v8/src/arm/disasm-arm.cc +47 -15
  120. data/vendor/v8/src/arm/frames-arm.h +1 -1
  121. data/vendor/v8/src/arm/full-codegen-arm.cc +724 -408
  122. data/vendor/v8/src/arm/ic-arm.cc +90 -85
  123. data/vendor/v8/src/arm/lithium-arm.cc +140 -69
  124. data/vendor/v8/src/arm/lithium-arm.h +161 -46
  125. data/vendor/v8/src/arm/lithium-codegen-arm.cc +567 -297
  126. data/vendor/v8/src/arm/lithium-codegen-arm.h +21 -9
  127. data/vendor/v8/src/arm/lithium-gap-resolver-arm.cc +2 -0
  128. data/vendor/v8/src/arm/macro-assembler-arm.cc +457 -96
  129. data/vendor/v8/src/arm/macro-assembler-arm.h +115 -18
  130. data/vendor/v8/src/arm/regexp-macro-assembler-arm.cc +20 -13
  131. data/vendor/v8/src/arm/regexp-macro-assembler-arm.h +1 -0
  132. data/vendor/v8/src/arm/simulator-arm.cc +184 -101
  133. data/vendor/v8/src/arm/simulator-arm.h +26 -21
  134. data/vendor/v8/src/arm/stub-cache-arm.cc +450 -467
  135. data/vendor/v8/src/arm/virtual-frame-arm.cc +14 -12
  136. data/vendor/v8/src/arm/virtual-frame-arm.h +11 -8
  137. data/vendor/v8/src/array.js +35 -18
  138. data/vendor/v8/src/assembler.cc +186 -92
  139. data/vendor/v8/src/assembler.h +106 -69
  140. data/vendor/v8/src/ast-inl.h +5 -0
  141. data/vendor/v8/src/ast.cc +46 -35
  142. data/vendor/v8/src/ast.h +107 -50
  143. data/vendor/v8/src/atomicops.h +2 -0
  144. data/vendor/v8/src/atomicops_internals_mips_gcc.h +169 -0
  145. data/vendor/v8/src/bootstrapper.cc +649 -399
  146. data/vendor/v8/src/bootstrapper.h +94 -27
  147. data/vendor/v8/src/builtins.cc +359 -227
  148. data/vendor/v8/src/builtins.h +157 -123
  149. data/vendor/v8/src/checks.cc +2 -2
  150. data/vendor/v8/src/checks.h +4 -0
  151. data/vendor/v8/src/code-stubs.cc +27 -17
  152. data/vendor/v8/src/code-stubs.h +38 -17
  153. data/vendor/v8/src/codegen-inl.h +5 -1
  154. data/vendor/v8/src/codegen.cc +27 -17
  155. data/vendor/v8/src/codegen.h +9 -9
  156. data/vendor/v8/src/compilation-cache.cc +92 -206
  157. data/vendor/v8/src/compilation-cache.h +205 -30
  158. data/vendor/v8/src/compiler.cc +107 -120
  159. data/vendor/v8/src/compiler.h +17 -2
  160. data/vendor/v8/src/contexts.cc +22 -15
  161. data/vendor/v8/src/contexts.h +14 -8
  162. data/vendor/v8/src/conversions.cc +86 -30
  163. data/vendor/v8/src/counters.cc +19 -4
  164. data/vendor/v8/src/counters.h +28 -16
  165. data/vendor/v8/src/cpu-profiler-inl.h +4 -3
  166. data/vendor/v8/src/cpu-profiler.cc +123 -72
  167. data/vendor/v8/src/cpu-profiler.h +33 -19
  168. data/vendor/v8/src/cpu.h +2 -0
  169. data/vendor/v8/src/d8-debug.cc +3 -3
  170. data/vendor/v8/src/d8-debug.h +7 -6
  171. data/vendor/v8/src/d8-posix.cc +2 -0
  172. data/vendor/v8/src/d8.cc +22 -12
  173. data/vendor/v8/src/d8.gyp +3 -0
  174. data/vendor/v8/src/d8.js +618 -0
  175. data/vendor/v8/src/data-flow.h +3 -3
  176. data/vendor/v8/src/dateparser.h +4 -2
  177. data/vendor/v8/src/debug-agent.cc +10 -9
  178. data/vendor/v8/src/debug-agent.h +9 -11
  179. data/vendor/v8/src/debug-debugger.js +121 -0
  180. data/vendor/v8/src/debug.cc +331 -227
  181. data/vendor/v8/src/debug.h +248 -219
  182. data/vendor/v8/src/deoptimizer.cc +173 -62
  183. data/vendor/v8/src/deoptimizer.h +119 -19
  184. data/vendor/v8/src/disasm.h +3 -0
  185. data/vendor/v8/src/disassembler.cc +10 -9
  186. data/vendor/v8/src/execution.cc +185 -129
  187. data/vendor/v8/src/execution.h +47 -78
  188. data/vendor/v8/src/extensions/experimental/break-iterator.cc +250 -0
  189. data/vendor/v8/src/extensions/experimental/break-iterator.h +89 -0
  190. data/vendor/v8/src/extensions/experimental/experimental.gyp +2 -0
  191. data/vendor/v8/src/extensions/experimental/i18n-extension.cc +22 -2
  192. data/vendor/v8/src/extensions/externalize-string-extension.cc +2 -2
  193. data/vendor/v8/src/extensions/gc-extension.cc +1 -1
  194. data/vendor/v8/src/factory.cc +261 -154
  195. data/vendor/v8/src/factory.h +162 -158
  196. data/vendor/v8/src/flag-definitions.h +17 -11
  197. data/vendor/v8/src/frame-element.cc +0 -5
  198. data/vendor/v8/src/frame-element.h +9 -13
  199. data/vendor/v8/src/frames-inl.h +7 -0
  200. data/vendor/v8/src/frames.cc +56 -46
  201. data/vendor/v8/src/frames.h +36 -25
  202. data/vendor/v8/src/full-codegen.cc +15 -24
  203. data/vendor/v8/src/full-codegen.h +13 -41
  204. data/vendor/v8/src/func-name-inferrer.cc +7 -6
  205. data/vendor/v8/src/func-name-inferrer.h +1 -1
  206. data/vendor/v8/src/gdb-jit.cc +1 -0
  207. data/vendor/v8/src/global-handles.cc +118 -56
  208. data/vendor/v8/src/global-handles.h +98 -40
  209. data/vendor/v8/src/globals.h +2 -2
  210. data/vendor/v8/src/handles-inl.h +106 -9
  211. data/vendor/v8/src/handles.cc +220 -157
  212. data/vendor/v8/src/handles.h +38 -59
  213. data/vendor/v8/src/hashmap.h +3 -3
  214. data/vendor/v8/src/heap-inl.h +141 -25
  215. data/vendor/v8/src/heap-profiler.cc +117 -63
  216. data/vendor/v8/src/heap-profiler.h +38 -21
  217. data/vendor/v8/src/heap.cc +805 -564
  218. data/vendor/v8/src/heap.h +640 -594
  219. data/vendor/v8/src/hydrogen-instructions.cc +216 -73
  220. data/vendor/v8/src/hydrogen-instructions.h +259 -124
  221. data/vendor/v8/src/hydrogen.cc +996 -1171
  222. data/vendor/v8/src/hydrogen.h +163 -144
  223. data/vendor/v8/src/ia32/assembler-ia32-inl.h +12 -11
  224. data/vendor/v8/src/ia32/assembler-ia32.cc +85 -39
  225. data/vendor/v8/src/ia32/assembler-ia32.h +82 -16
  226. data/vendor/v8/src/ia32/builtins-ia32.cc +64 -58
  227. data/vendor/v8/src/ia32/code-stubs-ia32.cc +248 -324
  228. data/vendor/v8/src/ia32/code-stubs-ia32.h +3 -44
  229. data/vendor/v8/src/ia32/codegen-ia32.cc +217 -165
  230. data/vendor/v8/src/ia32/codegen-ia32.h +3 -0
  231. data/vendor/v8/src/ia32/cpu-ia32.cc +6 -5
  232. data/vendor/v8/src/ia32/debug-ia32.cc +8 -5
  233. data/vendor/v8/src/ia32/deoptimizer-ia32.cc +124 -14
  234. data/vendor/v8/src/ia32/disasm-ia32.cc +85 -62
  235. data/vendor/v8/src/ia32/frames-ia32.h +1 -1
  236. data/vendor/v8/src/ia32/full-codegen-ia32.cc +348 -435
  237. data/vendor/v8/src/ia32/ic-ia32.cc +91 -91
  238. data/vendor/v8/src/ia32/lithium-codegen-ia32.cc +500 -255
  239. data/vendor/v8/src/ia32/lithium-codegen-ia32.h +13 -4
  240. data/vendor/v8/src/ia32/lithium-gap-resolver-ia32.cc +6 -0
  241. data/vendor/v8/src/ia32/lithium-ia32.cc +122 -45
  242. data/vendor/v8/src/ia32/lithium-ia32.h +128 -41
  243. data/vendor/v8/src/ia32/macro-assembler-ia32.cc +109 -84
  244. data/vendor/v8/src/ia32/macro-assembler-ia32.h +18 -9
  245. data/vendor/v8/src/ia32/regexp-macro-assembler-ia32.cc +26 -15
  246. data/vendor/v8/src/ia32/regexp-macro-assembler-ia32.h +1 -0
  247. data/vendor/v8/src/ia32/register-allocator-ia32.cc +30 -30
  248. data/vendor/v8/src/ia32/simulator-ia32.h +4 -4
  249. data/vendor/v8/src/ia32/stub-cache-ia32.cc +383 -400
  250. data/vendor/v8/src/ia32/virtual-frame-ia32.cc +36 -13
  251. data/vendor/v8/src/ia32/virtual-frame-ia32.h +11 -5
  252. data/vendor/v8/src/ic-inl.h +12 -2
  253. data/vendor/v8/src/ic.cc +304 -221
  254. data/vendor/v8/src/ic.h +115 -58
  255. data/vendor/v8/src/interpreter-irregexp.cc +25 -21
  256. data/vendor/v8/src/interpreter-irregexp.h +2 -1
  257. data/vendor/v8/src/isolate.cc +883 -0
  258. data/vendor/v8/src/isolate.h +1304 -0
  259. data/vendor/v8/src/json.js +10 -10
  260. data/vendor/v8/src/jsregexp.cc +111 -80
  261. data/vendor/v8/src/jsregexp.h +6 -7
  262. data/vendor/v8/src/jump-target-heavy.cc +5 -8
  263. data/vendor/v8/src/jump-target-heavy.h +0 -6
  264. data/vendor/v8/src/jump-target-inl.h +1 -1
  265. data/vendor/v8/src/jump-target-light.cc +3 -3
  266. data/vendor/v8/src/lithium-allocator-inl.h +2 -0
  267. data/vendor/v8/src/lithium-allocator.cc +42 -30
  268. data/vendor/v8/src/lithium-allocator.h +8 -22
  269. data/vendor/v8/src/lithium.cc +1 -0
  270. data/vendor/v8/src/liveedit.cc +141 -99
  271. data/vendor/v8/src/liveedit.h +7 -2
  272. data/vendor/v8/src/liveobjectlist-inl.h +90 -0
  273. data/vendor/v8/src/liveobjectlist.cc +2537 -1
  274. data/vendor/v8/src/liveobjectlist.h +245 -35
  275. data/vendor/v8/src/log-utils.cc +122 -35
  276. data/vendor/v8/src/log-utils.h +33 -36
  277. data/vendor/v8/src/log.cc +299 -241
  278. data/vendor/v8/src/log.h +177 -110
  279. data/vendor/v8/src/mark-compact.cc +612 -470
  280. data/vendor/v8/src/mark-compact.h +153 -80
  281. data/vendor/v8/src/messages.cc +16 -14
  282. data/vendor/v8/src/messages.js +30 -7
  283. data/vendor/v8/src/mips/assembler-mips-inl.h +155 -35
  284. data/vendor/v8/src/mips/assembler-mips.cc +1093 -219
  285. data/vendor/v8/src/mips/assembler-mips.h +552 -153
  286. data/vendor/v8/src/mips/builtins-mips.cc +43 -100
  287. data/vendor/v8/src/mips/code-stubs-mips.cc +752 -0
  288. data/vendor/v8/src/mips/code-stubs-mips.h +511 -0
  289. data/vendor/v8/src/mips/codegen-mips-inl.h +8 -14
  290. data/vendor/v8/src/mips/codegen-mips.cc +672 -896
  291. data/vendor/v8/src/mips/codegen-mips.h +271 -69
  292. data/vendor/v8/src/mips/constants-mips.cc +44 -20
  293. data/vendor/v8/src/mips/constants-mips.h +238 -40
  294. data/vendor/v8/src/mips/cpu-mips.cc +20 -3
  295. data/vendor/v8/src/mips/debug-mips.cc +35 -7
  296. data/vendor/v8/src/mips/deoptimizer-mips.cc +91 -0
  297. data/vendor/v8/src/mips/disasm-mips.cc +329 -93
  298. data/vendor/v8/src/mips/frames-mips.cc +2 -50
  299. data/vendor/v8/src/mips/frames-mips.h +24 -9
  300. data/vendor/v8/src/mips/full-codegen-mips.cc +473 -23
  301. data/vendor/v8/src/mips/ic-mips.cc +81 -45
  302. data/vendor/v8/src/mips/jump-target-mips.cc +11 -106
  303. data/vendor/v8/src/mips/lithium-codegen-mips.h +65 -0
  304. data/vendor/v8/src/mips/lithium-mips.h +304 -0
  305. data/vendor/v8/src/mips/macro-assembler-mips.cc +2391 -390
  306. data/vendor/v8/src/mips/macro-assembler-mips.h +718 -121
  307. data/vendor/v8/src/mips/regexp-macro-assembler-mips.cc +478 -0
  308. data/vendor/v8/src/mips/regexp-macro-assembler-mips.h +250 -0
  309. data/vendor/v8/src/mips/register-allocator-mips-inl.h +0 -3
  310. data/vendor/v8/src/mips/register-allocator-mips.h +3 -2
  311. data/vendor/v8/src/mips/simulator-mips.cc +1009 -221
  312. data/vendor/v8/src/mips/simulator-mips.h +119 -36
  313. data/vendor/v8/src/mips/stub-cache-mips.cc +331 -148
  314. data/vendor/v8/src/mips/{fast-codegen-mips.cc → virtual-frame-mips-inl.h} +11 -30
  315. data/vendor/v8/src/mips/virtual-frame-mips.cc +137 -149
  316. data/vendor/v8/src/mips/virtual-frame-mips.h +294 -312
  317. data/vendor/v8/src/mirror-debugger.js +9 -8
  318. data/vendor/v8/src/mksnapshot.cc +2 -2
  319. data/vendor/v8/src/objects-debug.cc +16 -16
  320. data/vendor/v8/src/objects-inl.h +421 -195
  321. data/vendor/v8/src/objects-printer.cc +7 -7
  322. data/vendor/v8/src/objects-visiting.cc +1 -1
  323. data/vendor/v8/src/objects-visiting.h +33 -12
  324. data/vendor/v8/src/objects.cc +935 -658
  325. data/vendor/v8/src/objects.h +234 -139
  326. data/vendor/v8/src/parser.cc +484 -439
  327. data/vendor/v8/src/parser.h +35 -14
  328. data/vendor/v8/src/platform-cygwin.cc +173 -107
  329. data/vendor/v8/src/platform-freebsd.cc +224 -72
  330. data/vendor/v8/src/platform-linux.cc +234 -95
  331. data/vendor/v8/src/platform-macos.cc +215 -82
  332. data/vendor/v8/src/platform-nullos.cc +9 -3
  333. data/vendor/v8/src/platform-openbsd.cc +22 -7
  334. data/vendor/v8/src/platform-posix.cc +30 -5
  335. data/vendor/v8/src/platform-solaris.cc +120 -38
  336. data/vendor/v8/src/platform-tls-mac.h +62 -0
  337. data/vendor/v8/src/platform-tls-win32.h +62 -0
  338. data/vendor/v8/src/platform-tls.h +50 -0
  339. data/vendor/v8/src/platform-win32.cc +195 -97
  340. data/vendor/v8/src/platform.h +72 -15
  341. data/vendor/v8/src/preparse-data.cc +2 -0
  342. data/vendor/v8/src/preparser-api.cc +8 -2
  343. data/vendor/v8/src/preparser.cc +1 -1
  344. data/vendor/v8/src/prettyprinter.cc +43 -52
  345. data/vendor/v8/src/prettyprinter.h +1 -1
  346. data/vendor/v8/src/profile-generator-inl.h +0 -28
  347. data/vendor/v8/src/profile-generator.cc +942 -685
  348. data/vendor/v8/src/profile-generator.h +210 -176
  349. data/vendor/v8/src/property.cc +6 -0
  350. data/vendor/v8/src/property.h +14 -3
  351. data/vendor/v8/src/regexp-macro-assembler-irregexp.cc +1 -1
  352. data/vendor/v8/src/regexp-macro-assembler.cc +28 -19
  353. data/vendor/v8/src/regexp-macro-assembler.h +11 -6
  354. data/vendor/v8/src/regexp-stack.cc +18 -10
  355. data/vendor/v8/src/regexp-stack.h +45 -21
  356. data/vendor/v8/src/regexp.js +3 -3
  357. data/vendor/v8/src/register-allocator-inl.h +3 -3
  358. data/vendor/v8/src/register-allocator.cc +1 -7
  359. data/vendor/v8/src/register-allocator.h +5 -15
  360. data/vendor/v8/src/rewriter.cc +2 -1
  361. data/vendor/v8/src/runtime-profiler.cc +158 -128
  362. data/vendor/v8/src/runtime-profiler.h +131 -15
  363. data/vendor/v8/src/runtime.cc +2409 -1692
  364. data/vendor/v8/src/runtime.h +93 -17
  365. data/vendor/v8/src/safepoint-table.cc +3 -0
  366. data/vendor/v8/src/safepoint-table.h +9 -3
  367. data/vendor/v8/src/scanner-base.cc +21 -28
  368. data/vendor/v8/src/scanner-base.h +22 -11
  369. data/vendor/v8/src/scanner.cc +3 -5
  370. data/vendor/v8/src/scanner.h +4 -2
  371. data/vendor/v8/src/scopeinfo.cc +11 -16
  372. data/vendor/v8/src/scopeinfo.h +26 -15
  373. data/vendor/v8/src/scopes.cc +67 -37
  374. data/vendor/v8/src/scopes.h +26 -12
  375. data/vendor/v8/src/serialize.cc +193 -154
  376. data/vendor/v8/src/serialize.h +41 -36
  377. data/vendor/v8/src/small-pointer-list.h +163 -0
  378. data/vendor/v8/src/snapshot-common.cc +1 -1
  379. data/vendor/v8/src/snapshot.h +3 -1
  380. data/vendor/v8/src/spaces-inl.h +30 -25
  381. data/vendor/v8/src/spaces.cc +263 -370
  382. data/vendor/v8/src/spaces.h +178 -166
  383. data/vendor/v8/src/string-search.cc +4 -3
  384. data/vendor/v8/src/string-search.h +21 -20
  385. data/vendor/v8/src/string-stream.cc +32 -24
  386. data/vendor/v8/src/string.js +7 -7
  387. data/vendor/v8/src/stub-cache.cc +324 -248
  388. data/vendor/v8/src/stub-cache.h +181 -155
  389. data/vendor/v8/src/token.cc +3 -3
  390. data/vendor/v8/src/token.h +3 -3
  391. data/vendor/v8/src/top.cc +218 -390
  392. data/vendor/v8/src/type-info.cc +98 -32
  393. data/vendor/v8/src/type-info.h +10 -3
  394. data/vendor/v8/src/unicode.cc +1 -1
  395. data/vendor/v8/src/unicode.h +1 -1
  396. data/vendor/v8/src/utils.h +3 -0
  397. data/vendor/v8/src/v8-counters.cc +18 -11
  398. data/vendor/v8/src/v8-counters.h +34 -13
  399. data/vendor/v8/src/v8.cc +66 -121
  400. data/vendor/v8/src/v8.h +7 -4
  401. data/vendor/v8/src/v8globals.h +18 -12
  402. data/vendor/v8/src/{memory.h → v8memory.h} +0 -0
  403. data/vendor/v8/src/v8natives.js +59 -18
  404. data/vendor/v8/src/v8threads.cc +127 -114
  405. data/vendor/v8/src/v8threads.h +42 -35
  406. data/vendor/v8/src/v8utils.h +2 -39
  407. data/vendor/v8/src/variables.h +1 -1
  408. data/vendor/v8/src/version.cc +26 -5
  409. data/vendor/v8/src/version.h +4 -0
  410. data/vendor/v8/src/virtual-frame-heavy-inl.h +2 -4
  411. data/vendor/v8/src/virtual-frame-light-inl.h +5 -4
  412. data/vendor/v8/src/vm-state-inl.h +21 -17
  413. data/vendor/v8/src/vm-state.h +7 -5
  414. data/vendor/v8/src/win32-headers.h +1 -0
  415. data/vendor/v8/src/x64/assembler-x64-inl.h +12 -11
  416. data/vendor/v8/src/x64/assembler-x64.cc +80 -40
  417. data/vendor/v8/src/x64/assembler-x64.h +67 -17
  418. data/vendor/v8/src/x64/builtins-x64.cc +34 -33
  419. data/vendor/v8/src/x64/code-stubs-x64.cc +636 -377
  420. data/vendor/v8/src/x64/code-stubs-x64.h +14 -48
  421. data/vendor/v8/src/x64/codegen-x64-inl.h +1 -1
  422. data/vendor/v8/src/x64/codegen-x64.cc +158 -136
  423. data/vendor/v8/src/x64/codegen-x64.h +4 -1
  424. data/vendor/v8/src/x64/cpu-x64.cc +7 -5
  425. data/vendor/v8/src/x64/debug-x64.cc +8 -6
  426. data/vendor/v8/src/x64/deoptimizer-x64.cc +195 -20
  427. data/vendor/v8/src/x64/disasm-x64.cc +42 -23
  428. data/vendor/v8/src/x64/frames-x64.cc +1 -1
  429. data/vendor/v8/src/x64/frames-x64.h +2 -2
  430. data/vendor/v8/src/x64/full-codegen-x64.cc +780 -218
  431. data/vendor/v8/src/x64/ic-x64.cc +77 -79
  432. data/vendor/v8/src/x64/jump-target-x64.cc +1 -1
  433. data/vendor/v8/src/x64/lithium-codegen-x64.cc +698 -181
  434. data/vendor/v8/src/x64/lithium-codegen-x64.h +31 -6
  435. data/vendor/v8/src/x64/lithium-x64.cc +136 -54
  436. data/vendor/v8/src/x64/lithium-x64.h +142 -51
  437. data/vendor/v8/src/x64/macro-assembler-x64.cc +456 -187
  438. data/vendor/v8/src/x64/macro-assembler-x64.h +166 -34
  439. data/vendor/v8/src/x64/regexp-macro-assembler-x64.cc +44 -28
  440. data/vendor/v8/src/x64/regexp-macro-assembler-x64.h +8 -4
  441. data/vendor/v8/src/x64/register-allocator-x64-inl.h +3 -3
  442. data/vendor/v8/src/x64/register-allocator-x64.cc +12 -8
  443. data/vendor/v8/src/x64/simulator-x64.h +5 -5
  444. data/vendor/v8/src/x64/stub-cache-x64.cc +299 -344
  445. data/vendor/v8/src/x64/virtual-frame-x64.cc +37 -13
  446. data/vendor/v8/src/x64/virtual-frame-x64.h +13 -7
  447. data/vendor/v8/src/zone-inl.h +49 -3
  448. data/vendor/v8/src/zone.cc +42 -41
  449. data/vendor/v8/src/zone.h +37 -34
  450. data/vendor/v8/test/benchmarks/testcfg.py +100 -0
  451. data/vendor/v8/test/cctest/SConscript +5 -4
  452. data/vendor/v8/test/cctest/cctest.h +3 -2
  453. data/vendor/v8/test/cctest/cctest.status +6 -11
  454. data/vendor/v8/test/cctest/test-accessors.cc +3 -3
  455. data/vendor/v8/test/cctest/test-alloc.cc +39 -33
  456. data/vendor/v8/test/cctest/test-api.cc +1092 -205
  457. data/vendor/v8/test/cctest/test-assembler-arm.cc +39 -25
  458. data/vendor/v8/test/cctest/test-assembler-ia32.cc +36 -37
  459. data/vendor/v8/test/cctest/test-assembler-mips.cc +1098 -40
  460. data/vendor/v8/test/cctest/test-assembler-x64.cc +32 -25
  461. data/vendor/v8/test/cctest/test-ast.cc +1 -0
  462. data/vendor/v8/test/cctest/test-circular-queue.cc +8 -5
  463. data/vendor/v8/test/cctest/test-compiler.cc +24 -24
  464. data/vendor/v8/test/cctest/test-cpu-profiler.cc +140 -5
  465. data/vendor/v8/test/cctest/test-dataflow.cc +1 -0
  466. data/vendor/v8/test/cctest/test-debug.cc +136 -77
  467. data/vendor/v8/test/cctest/test-decls.cc +1 -1
  468. data/vendor/v8/test/cctest/test-deoptimization.cc +25 -24
  469. data/vendor/v8/test/cctest/test-disasm-arm.cc +9 -4
  470. data/vendor/v8/test/cctest/test-disasm-ia32.cc +10 -8
  471. data/vendor/v8/test/cctest/test-func-name-inference.cc +10 -4
  472. data/vendor/v8/test/cctest/test-heap-profiler.cc +226 -164
  473. data/vendor/v8/test/cctest/test-heap.cc +240 -217
  474. data/vendor/v8/test/cctest/test-liveedit.cc +1 -0
  475. data/vendor/v8/test/cctest/test-log-stack-tracer.cc +18 -20
  476. data/vendor/v8/test/cctest/test-log.cc +114 -108
  477. data/vendor/v8/test/cctest/test-macro-assembler-x64.cc +247 -177
  478. data/vendor/v8/test/cctest/test-mark-compact.cc +129 -90
  479. data/vendor/v8/test/cctest/test-parsing.cc +15 -14
  480. data/vendor/v8/test/cctest/test-platform-linux.cc +1 -0
  481. data/vendor/v8/test/cctest/test-platform-tls.cc +66 -0
  482. data/vendor/v8/test/cctest/test-platform-win32.cc +1 -0
  483. data/vendor/v8/test/cctest/test-profile-generator.cc +1 -1
  484. data/vendor/v8/test/cctest/test-regexp.cc +53 -41
  485. data/vendor/v8/test/cctest/test-reloc-info.cc +18 -11
  486. data/vendor/v8/test/cctest/test-serialize.cc +44 -43
  487. data/vendor/v8/test/cctest/test-sockets.cc +8 -3
  488. data/vendor/v8/test/cctest/test-spaces.cc +47 -29
  489. data/vendor/v8/test/cctest/test-strings.cc +20 -20
  490. data/vendor/v8/test/cctest/test-thread-termination.cc +8 -3
  491. data/vendor/v8/test/cctest/test-threads.cc +5 -3
  492. data/vendor/v8/test/cctest/test-utils.cc +5 -4
  493. data/vendor/v8/test/cctest/testcfg.py +7 -3
  494. data/vendor/v8/test/es5conform/es5conform.status +2 -77
  495. data/vendor/v8/test/es5conform/testcfg.py +1 -1
  496. data/vendor/v8/test/message/testcfg.py +1 -1
  497. data/vendor/v8/test/mjsunit/accessors-on-global-object.js +3 -3
  498. data/vendor/v8/test/mjsunit/array-concat.js +43 -1
  499. data/vendor/v8/test/mjsunit/array-join.js +25 -0
  500. data/vendor/v8/test/mjsunit/bitops-info.js +7 -1
  501. data/vendor/v8/test/mjsunit/compiler/array-length.js +2 -2
  502. data/vendor/v8/test/mjsunit/compiler/global-accessors.js +47 -0
  503. data/vendor/v8/test/mjsunit/compiler/pic.js +1 -1
  504. data/vendor/v8/test/mjsunit/compiler/regress-loadfield.js +65 -0
  505. data/vendor/v8/test/mjsunit/math-sqrt.js +5 -1
  506. data/vendor/v8/test/mjsunit/mjsunit.js +59 -8
  507. data/vendor/v8/test/mjsunit/mjsunit.status +0 -12
  508. data/vendor/v8/test/mjsunit/mul-exhaustive.js +129 -11
  509. data/vendor/v8/test/mjsunit/negate-zero.js +1 -1
  510. data/vendor/v8/test/mjsunit/object-freeze.js +5 -13
  511. data/vendor/v8/test/mjsunit/object-prevent-extensions.js +9 -50
  512. data/vendor/v8/test/mjsunit/object-seal.js +4 -13
  513. data/vendor/v8/test/mjsunit/override-eval-with-non-function.js +36 -0
  514. data/vendor/v8/test/mjsunit/regress/regress-1145.js +54 -0
  515. data/vendor/v8/test/mjsunit/regress/regress-1172-bis.js +37 -0
  516. data/vendor/v8/test/mjsunit/regress/regress-1181.js +54 -0
  517. data/vendor/v8/test/mjsunit/regress/regress-1207.js +35 -0
  518. data/vendor/v8/test/mjsunit/regress/regress-1209.js +34 -0
  519. data/vendor/v8/test/mjsunit/regress/regress-1210.js +48 -0
  520. data/vendor/v8/test/mjsunit/regress/regress-1213.js +43 -0
  521. data/vendor/v8/test/mjsunit/regress/regress-1218.js +29 -0
  522. data/vendor/v8/test/mjsunit/regress/regress-1229.js +79 -0
  523. data/vendor/v8/test/mjsunit/regress/regress-1233.js +47 -0
  524. data/vendor/v8/test/mjsunit/regress/regress-1236.js +34 -0
  525. data/vendor/v8/test/mjsunit/regress/regress-1237.js +36 -0
  526. data/vendor/v8/test/mjsunit/regress/regress-1240.js +39 -0
  527. data/vendor/v8/test/mjsunit/regress/regress-1257.js +58 -0
  528. data/vendor/v8/test/mjsunit/regress/regress-1278.js +69 -0
  529. data/vendor/v8/test/mjsunit/regress/regress-create-exception.js +1 -0
  530. data/vendor/v8/test/mjsunit/regress/regress-lazy-deopt-reloc.js +52 -0
  531. data/vendor/v8/test/mjsunit/sin-cos.js +15 -10
  532. data/vendor/v8/test/mjsunit/smi-negative-zero.js +2 -2
  533. data/vendor/v8/test/mjsunit/str-to-num.js +1 -1
  534. data/vendor/v8/test/mjsunit/strict-mode.js +435 -0
  535. data/vendor/v8/test/mjsunit/testcfg.py +23 -6
  536. data/vendor/v8/test/mozilla/mozilla.status +0 -2
  537. data/vendor/v8/test/mozilla/testcfg.py +1 -1
  538. data/vendor/v8/test/preparser/empty.js +28 -0
  539. data/vendor/v8/test/preparser/functions-only.js +38 -0
  540. data/vendor/v8/test/preparser/non-alphanum.js +34 -0
  541. data/vendor/v8/test/preparser/symbols-only.js +49 -0
  542. data/vendor/v8/test/preparser/testcfg.py +90 -0
  543. data/vendor/v8/test/sputnik/testcfg.py +1 -1
  544. data/vendor/v8/test/test262/README +16 -0
  545. data/vendor/v8/test/test262/harness-adapt.js +80 -0
  546. data/vendor/v8/test/test262/test262.status +1506 -0
  547. data/vendor/v8/test/test262/testcfg.py +123 -0
  548. data/vendor/v8/tools/freebsd-tick-processor +10 -0
  549. data/vendor/v8/tools/gyp/v8.gyp +8 -33
  550. data/vendor/v8/tools/linux-tick-processor +5 -3
  551. data/vendor/v8/tools/test.py +37 -14
  552. data/vendor/v8/tools/tickprocessor.js +22 -8
  553. data/vendor/v8/tools/visual_studio/v8_base.vcproj +13 -1
  554. data/vendor/v8/tools/visual_studio/v8_base_arm.vcproj +5 -1
  555. data/vendor/v8/tools/visual_studio/v8_base_x64.vcproj +5 -1
  556. data/vendor/v8/tools/visual_studio/x64.vsprops +1 -0
  557. metadata +1495 -1341
  558. data/ext/extconf.rb +0 -22
  559. data/ext/mustang.cpp +0 -58
  560. data/vendor/v8/src/top.h +0 -608
@@ -0,0 +1,100 @@
1
+ # Copyright 2011 the V8 project authors. All rights reserved.
2
+ # Redistribution and use in source and binary forms, with or without
3
+ # modification, are permitted provided that the following conditions are
4
+ # met:
5
+ #
6
+ # * Redistributions of source code must retain the above copyright
7
+ # notice, this list of conditions and the following disclaimer.
8
+ # * Redistributions in binary form must reproduce the above
9
+ # copyright notice, this list of conditions and the following
10
+ # disclaimer in the documentation and/or other materials provided
11
+ # with the distribution.
12
+ # * Neither the name of Google Inc. nor the names of its
13
+ # contributors may be used to endorse or promote products derived
14
+ # from this software without specific prior written permission.
15
+ #
16
+ # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
+ # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
+ # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
+ # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+ # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+ # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+
28
+
29
+ import test
30
+ import os
31
+ from os.path import join, split
32
+
33
+ def IsNumber(string):
34
+ try:
35
+ float(string)
36
+ return True
37
+ except ValueError:
38
+ return False
39
+
40
+
41
+ class BenchmarkTestCase(test.TestCase):
42
+
43
+ def __init__(self, path, context, mode):
44
+ super(BenchmarkTestCase, self).__init__(context, split(path), mode)
45
+ self.root = path
46
+
47
+ def GetLabel(self):
48
+ return '%s benchmark %s' % (self.mode, self.GetName())
49
+
50
+ def IsFailureOutput(self, output):
51
+ if output.exit_code != 0:
52
+ return True
53
+ lines = output.stdout.splitlines()
54
+ for line in lines:
55
+ colon_index = line.find(':')
56
+ if colon_index >= 0:
57
+ if not IsNumber(line[colon_index+1:].strip()):
58
+ return True
59
+ return False
60
+
61
+ def GetCommand(self):
62
+ result = self.context.GetVmCommand(self, self.mode)
63
+ result.append(join(self.root, 'run.js'))
64
+ return result
65
+
66
+ def GetName(self):
67
+ return 'V8'
68
+
69
+ def BeforeRun(self):
70
+ os.chdir(self.root)
71
+
72
+ def AfterRun(self, result):
73
+ os.chdir(self.context.buildspace)
74
+
75
+ def GetSource(self):
76
+ return open(join(self.root, 'run.js')).read()
77
+
78
+ def GetCustomFlags(self, mode):
79
+ return []
80
+
81
+
82
+ class BenchmarkTestConfiguration(test.TestConfiguration):
83
+
84
+ def __init__(self, context, root):
85
+ super(BenchmarkTestConfiguration, self).__init__(context, root)
86
+
87
+ def ListTests(self, current_path, path, mode, variant_flags):
88
+ path = self.context.workspace
89
+ path = join(path, 'benchmarks')
90
+ test = BenchmarkTestCase(path, self.context, mode)
91
+ return [test]
92
+
93
+ def GetBuildRequirements(self):
94
+ return ['sample', 'sample=shell']
95
+
96
+ def GetTestStatus(self, sections, defs):
97
+ pass
98
+
99
+ def GetConfiguration(context, root):
100
+ return BenchmarkTestConfiguration(context, root)
@@ -41,8 +41,8 @@ SOURCES = {
41
41
  'test-alloc.cc',
42
42
  'test-api.cc',
43
43
  'test-ast.cc',
44
- 'test-bignum.cc',
45
44
  'test-bignum-dtoa.cc',
45
+ 'test-bignum.cc',
46
46
  'test-circular-queue.cc',
47
47
  'test-compiler.cc',
48
48
  'test-conversions.cc',
@@ -59,15 +59,16 @@ SOURCES = {
59
59
  'test-flags.cc',
60
60
  'test-func-name-inference.cc',
61
61
  'test-hashmap.cc',
62
- 'test-heap.cc',
63
62
  'test-heap-profiler.cc',
63
+ 'test-heap.cc',
64
64
  'test-list.cc',
65
65
  'test-liveedit.cc',
66
66
  'test-lock.cc',
67
- 'test-log.cc',
68
67
  'test-log-utils.cc',
68
+ 'test-log.cc',
69
69
  'test-mark-compact.cc',
70
70
  'test-parsing.cc',
71
+ 'test-platform-tls.cc',
71
72
  'test-profile-generator.cc',
72
73
  'test-regexp.cc',
73
74
  'test-reloc-info.cc',
@@ -95,7 +96,7 @@ SOURCES = {
95
96
  'arch:x64': ['test-assembler-x64.cc',
96
97
  'test-macro-assembler-x64.cc',
97
98
  'test-log-stack-tracer.cc'],
98
- 'arch:mips': ['test-assembler-mips.cc', 'test-mips.cc'],
99
+ 'arch:mips': ['test-assembler-mips.cc'],
99
100
  'os:linux': ['test-platform-linux.cc'],
100
101
  'os:macos': ['test-platform-macos.cc'],
101
102
  'os:nullos': ['test-platform-nullos.cc'],
@@ -87,8 +87,9 @@ class CcTest {
87
87
  class ApiTestFuzzer: public v8::internal::Thread {
88
88
  public:
89
89
  void CallTest();
90
- explicit ApiTestFuzzer(int num)
91
- : test_number_(num),
90
+ explicit ApiTestFuzzer(v8::internal::Isolate* isolate, int num)
91
+ : Thread(isolate, "ApiTestFuzzer"),
92
+ test_number_(num),
92
93
  gate_(v8::internal::OS::CreateSemaphore(0)),
93
94
  active_(true) {
94
95
  }
@@ -36,11 +36,6 @@ test-debug/DebuggerAgent: PASS, (PASS || FAIL) if $system == linux
36
36
  # BUG(382): Weird test. Can't guarantee that it never times out.
37
37
  test-api/ApplyInterruption: PASS || TIMEOUT
38
38
 
39
- # BUG(484): This test which we thought was originally corrected in r5236
40
- # is re-appearing. Disabled until bug in test is fixed. This only fails
41
- # when snapshot is on, so I am marking it PASS || FAIL
42
- test-heap-profiler/HeapSnapshotsDiff: PASS || FAIL
43
-
44
39
  # These tests always fail. They are here to test test.py. If
45
40
  # they don't fail then test.py has failed.
46
41
  test-serialize/TestThatAlwaysFails: FAIL
@@ -62,12 +57,6 @@ test-log/ProfLazyMode: SKIP
62
57
  test-debug/DebuggerAgentProtocolOverflowHeader: SKIP
63
58
  test-sockets/Socket: SKIP
64
59
 
65
- # BUG(1075): Some deserialization tests fail om ARM
66
- test-serialize/Deserialize: SKIP
67
- test-serialize/DeserializeFromSecondSerializationAndRunScript2: SKIP
68
- test-serialize/DeserializeAndRunScript2: SKIP
69
- test-serialize/DeserializeFromSecondSerialization: SKIP
70
-
71
60
  ##############################################################################
72
61
  [ $arch == arm && $crankshaft ]
73
62
 
@@ -85,15 +74,21 @@ test-compiler: SKIP
85
74
  test-cpu-profiler: SKIP
86
75
  test-debug: SKIP
87
76
  test-decls: SKIP
77
+ test-deoptimization: SKIP
88
78
  test-func-name-inference: SKIP
89
79
  test-heap: SKIP
90
80
  test-heap-profiler: SKIP
91
81
  test-log: SKIP
92
82
  test-log-utils: SKIP
93
83
  test-mark-compact: SKIP
84
+ test-parsing: SKIP
85
+ test-profile-generator: SKIP
94
86
  test-regexp: SKIP
95
87
  test-serialize: SKIP
96
88
  test-sockets: SKIP
97
89
  test-strings: SKIP
98
90
  test-threads: SKIP
99
91
  test-thread-termination: SKIP
92
+
93
+ ##############################################################################
94
+ # Tests that time out with Isolates
@@ -243,7 +243,7 @@ static v8::Handle<Value> CheckAccessorArgsCorrect(Local<String> name,
243
243
  ApiTestFuzzer::Fuzz();
244
244
  CHECK(info.This() == info.Holder());
245
245
  CHECK(info.Data()->Equals(v8::String::New("data")));
246
- i::Heap::CollectAllGarbage(true);
246
+ HEAP->CollectAllGarbage(true);
247
247
  CHECK(info.This() == info.Holder());
248
248
  CHECK(info.Data()->Equals(v8::String::New("data")));
249
249
  return v8::Integer::New(17);
@@ -397,9 +397,9 @@ static v8::Handle<Value> StackCheck(Local<String> name,
397
397
  for (int i = 0; !iter.done(); i++) {
398
398
  i::StackFrame* frame = iter.frame();
399
399
  CHECK(i != 0 || (frame->type() == i::StackFrame::EXIT));
400
- CHECK(frame->code()->IsCode());
400
+ i::Code* code = frame->LookupCode(i::Isolate::Current());
401
+ CHECK(code->IsCode());
401
402
  i::Address pc = frame->pc();
402
- i::Code* code = frame->code();
403
403
  CHECK(code->contains(pc));
404
404
  iter.Advance();
405
405
  }
@@ -27,7 +27,6 @@
27
27
 
28
28
  #include "v8.h"
29
29
  #include "accessors.h"
30
- #include "top.h"
31
30
 
32
31
  #include "cctest.h"
33
32
 
@@ -38,13 +37,14 @@ using namespace v8::internal;
38
37
  static MaybeObject* AllocateAfterFailures() {
39
38
  static int attempts = 0;
40
39
  if (++attempts < 3) return Failure::RetryAfterGC();
40
+ Heap* heap = Isolate::Current()->heap();
41
41
 
42
42
  // New space.
43
- NewSpace* new_space = Heap::new_space();
43
+ NewSpace* new_space = heap->new_space();
44
44
  static const int kNewSpaceFillerSize = ByteArray::SizeFor(0);
45
45
  while (new_space->Available() > kNewSpaceFillerSize) {
46
46
  int available_before = static_cast<int>(new_space->Available());
47
- CHECK(!Heap::AllocateByteArray(0)->IsFailure());
47
+ CHECK(!heap->AllocateByteArray(0)->IsFailure());
48
48
  if (available_before == new_space->Available()) {
49
49
  // It seems that we are avoiding new space allocations when
50
50
  // allocation is forced, so no need to fill up new space
@@ -52,45 +52,46 @@ static MaybeObject* AllocateAfterFailures() {
52
52
  break;
53
53
  }
54
54
  }
55
- CHECK(!Heap::AllocateByteArray(100)->IsFailure());
56
- CHECK(!Heap::AllocateFixedArray(100, NOT_TENURED)->IsFailure());
55
+ CHECK(!heap->AllocateByteArray(100)->IsFailure());
56
+ CHECK(!heap->AllocateFixedArray(100, NOT_TENURED)->IsFailure());
57
57
 
58
58
  // Make sure we can allocate through optimized allocation functions
59
59
  // for specific kinds.
60
- CHECK(!Heap::AllocateFixedArray(100)->IsFailure());
61
- CHECK(!Heap::AllocateHeapNumber(0.42)->IsFailure());
62
- CHECK(!Heap::AllocateArgumentsObject(Smi::FromInt(87), 10)->IsFailure());
63
- Object* object =
64
- Heap::AllocateJSObject(*Top::object_function())->ToObjectChecked();
65
- CHECK(!Heap::CopyJSObject(JSObject::cast(object))->IsFailure());
60
+ CHECK(!heap->AllocateFixedArray(100)->IsFailure());
61
+ CHECK(!heap->AllocateHeapNumber(0.42)->IsFailure());
62
+ CHECK(!heap->AllocateArgumentsObject(Smi::FromInt(87), 10)->IsFailure());
63
+ Object* object = heap->AllocateJSObject(
64
+ *Isolate::Current()->object_function())->ToObjectChecked();
65
+ CHECK(!heap->CopyJSObject(JSObject::cast(object))->IsFailure());
66
66
 
67
67
  // Old data space.
68
- OldSpace* old_data_space = Heap::old_data_space();
68
+ OldSpace* old_data_space = heap->old_data_space();
69
69
  static const int kOldDataSpaceFillerSize = ByteArray::SizeFor(0);
70
70
  while (old_data_space->Available() > kOldDataSpaceFillerSize) {
71
- CHECK(!Heap::AllocateByteArray(0, TENURED)->IsFailure());
71
+ CHECK(!heap->AllocateByteArray(0, TENURED)->IsFailure());
72
72
  }
73
- CHECK(!Heap::AllocateRawAsciiString(100, TENURED)->IsFailure());
73
+ CHECK(!heap->AllocateRawAsciiString(100, TENURED)->IsFailure());
74
74
 
75
75
  // Large object space.
76
- while (!Heap::OldGenerationAllocationLimitReached()) {
77
- CHECK(!Heap::AllocateFixedArray(10000, TENURED)->IsFailure());
76
+ while (!heap->OldGenerationAllocationLimitReached()) {
77
+ CHECK(!heap->AllocateFixedArray(10000, TENURED)->IsFailure());
78
78
  }
79
- CHECK(!Heap::AllocateFixedArray(10000, TENURED)->IsFailure());
79
+ CHECK(!heap->AllocateFixedArray(10000, TENURED)->IsFailure());
80
80
 
81
81
  // Map space.
82
- MapSpace* map_space = Heap::map_space();
82
+ MapSpace* map_space = heap->map_space();
83
83
  static const int kMapSpaceFillerSize = Map::kSize;
84
84
  InstanceType instance_type = JS_OBJECT_TYPE;
85
85
  int instance_size = JSObject::kHeaderSize;
86
86
  while (map_space->Available() > kMapSpaceFillerSize) {
87
- CHECK(!Heap::AllocateMap(instance_type, instance_size)->IsFailure());
87
+ CHECK(!heap->AllocateMap(instance_type, instance_size)->IsFailure());
88
88
  }
89
- CHECK(!Heap::AllocateMap(instance_type, instance_size)->IsFailure());
89
+ CHECK(!heap->AllocateMap(instance_type, instance_size)->IsFailure());
90
90
 
91
91
  // Test that we can allocate in old pointer space and code space.
92
- CHECK(!Heap::AllocateFixedArray(100, TENURED)->IsFailure());
93
- CHECK(!Heap::CopyCode(Builtins::builtin(Builtins::Illegal))->IsFailure());
92
+ CHECK(!heap->AllocateFixedArray(100, TENURED)->IsFailure());
93
+ CHECK(!heap->CopyCode(Isolate::Current()->builtins()->builtin(
94
+ Builtins::kIllegal))->IsFailure());
94
95
 
95
96
  // Return success.
96
97
  return Smi::FromInt(42);
@@ -98,7 +99,7 @@ static MaybeObject* AllocateAfterFailures() {
98
99
 
99
100
 
100
101
  static Handle<Object> Test() {
101
- CALL_HEAP_FUNCTION(AllocateAfterFailures(), Object);
102
+ CALL_HEAP_FUNCTION(ISOLATE, AllocateAfterFailures(), Object);
102
103
  }
103
104
 
104
105
 
@@ -129,18 +130,19 @@ TEST(StressJS) {
129
130
  v8::HandleScope scope;
130
131
  env->Enter();
131
132
  Handle<JSFunction> function =
132
- Factory::NewFunction(Factory::function_symbol(), Factory::null_value());
133
+ FACTORY->NewFunction(FACTORY->function_symbol(), FACTORY->null_value());
133
134
  // Force the creation of an initial map and set the code to
134
135
  // something empty.
135
- Factory::NewJSObject(function);
136
- function->ReplaceCode(Builtins::builtin(Builtins::EmptyFunction));
136
+ FACTORY->NewJSObject(function);
137
+ function->ReplaceCode(Isolate::Current()->builtins()->builtin(
138
+ Builtins::kEmptyFunction));
137
139
  // Patch the map to have an accessor for "get".
138
140
  Handle<Map> map(function->initial_map());
139
141
  Handle<DescriptorArray> instance_descriptors(map->instance_descriptors());
140
- Handle<Proxy> proxy = Factory::NewProxy(&kDescriptor);
141
- instance_descriptors = Factory::CopyAppendProxyDescriptor(
142
+ Handle<Proxy> proxy = FACTORY->NewProxy(&kDescriptor);
143
+ instance_descriptors = FACTORY->CopyAppendProxyDescriptor(
142
144
  instance_descriptors,
143
- Factory::NewStringFromAscii(Vector<const char>("get", 3)),
145
+ FACTORY->NewStringFromAscii(Vector<const char>("get", 3)),
144
146
  proxy,
145
147
  static_cast<PropertyAttributes>(0));
146
148
  map->set_instance_descriptors(*instance_descriptors);
@@ -183,7 +185,8 @@ class Block {
183
185
 
184
186
  TEST(CodeRange) {
185
187
  const int code_range_size = 16*MB;
186
- CodeRange::Setup(code_range_size);
188
+ OS::Setup();
189
+ Isolate::Current()->code_range()->Setup(code_range_size);
187
190
  int current_allocated = 0;
188
191
  int total_allocated = 0;
189
192
  List<Block> blocks(1000);
@@ -195,14 +198,17 @@ TEST(CodeRange) {
195
198
  size_t requested = (Page::kPageSize << (Pseudorandom() % 6)) +
196
199
  Pseudorandom() % 5000 + 1;
197
200
  size_t allocated = 0;
198
- void* base = CodeRange::AllocateRawMemory(requested, &allocated);
201
+ void* base = Isolate::Current()->code_range()->
202
+ AllocateRawMemory(requested, &allocated);
203
+ CHECK(base != NULL);
199
204
  blocks.Add(Block(base, static_cast<int>(allocated)));
200
205
  current_allocated += static_cast<int>(allocated);
201
206
  total_allocated += static_cast<int>(allocated);
202
207
  } else {
203
208
  // Free a block.
204
209
  int index = Pseudorandom() % blocks.length();
205
- CodeRange::FreeRawMemory(blocks[index].base, blocks[index].size);
210
+ Isolate::Current()->code_range()->FreeRawMemory(
211
+ blocks[index].base, blocks[index].size);
206
212
  current_allocated -= blocks[index].size;
207
213
  if (index < blocks.length() - 1) {
208
214
  blocks[index] = blocks.RemoveLast();
@@ -212,5 +218,5 @@ TEST(CodeRange) {
212
218
  }
213
219
  }
214
220
 
215
- CodeRange::TearDown();
221
+ Isolate::Current()->code_range()->TearDown();
216
222
  }
@@ -34,7 +34,6 @@
34
34
  #include "execution.h"
35
35
  #include "snapshot.h"
36
36
  #include "platform.h"
37
- #include "top.h"
38
37
  #include "utils.h"
39
38
  #include "cctest.h"
40
39
  #include "parser.h"
@@ -50,15 +49,19 @@ static bool IsNaN(double x) {
50
49
  #endif
51
50
  }
52
51
 
53
- using ::v8::ObjectTemplate;
54
- using ::v8::Value;
52
+ using ::v8::AccessorInfo;
55
53
  using ::v8::Context;
54
+ using ::v8::Extension;
55
+ using ::v8::Function;
56
+ using ::v8::HandleScope;
56
57
  using ::v8::Local;
57
- using ::v8::String;
58
+ using ::v8::Object;
59
+ using ::v8::ObjectTemplate;
60
+ using ::v8::Persistent;
58
61
  using ::v8::Script;
59
- using ::v8::Function;
60
- using ::v8::AccessorInfo;
61
- using ::v8::Extension;
62
+ using ::v8::String;
63
+ using ::v8::Value;
64
+ using ::v8::V8;
62
65
 
63
66
  namespace i = ::i;
64
67
 
@@ -394,11 +397,11 @@ THREADED_TEST(ScriptUsingStringResource) {
394
397
  CHECK(source->IsExternal());
395
398
  CHECK_EQ(resource,
396
399
  static_cast<TestResource*>(source->GetExternalStringResource()));
397
- i::Heap::CollectAllGarbage(false);
400
+ HEAP->CollectAllGarbage(false);
398
401
  CHECK_EQ(0, TestResource::dispose_count);
399
402
  }
400
- i::CompilationCache::Clear();
401
- i::Heap::CollectAllGarbage(false);
403
+ v8::internal::Isolate::Current()->compilation_cache()->Clear();
404
+ HEAP->CollectAllGarbage(false);
402
405
  CHECK_EQ(1, TestResource::dispose_count);
403
406
  }
404
407
 
@@ -415,11 +418,11 @@ THREADED_TEST(ScriptUsingAsciiStringResource) {
415
418
  Local<Value> value = script->Run();
416
419
  CHECK(value->IsNumber());
417
420
  CHECK_EQ(7, value->Int32Value());
418
- i::Heap::CollectAllGarbage(false);
421
+ HEAP->CollectAllGarbage(false);
419
422
  CHECK_EQ(0, TestAsciiResource::dispose_count);
420
423
  }
421
- i::CompilationCache::Clear();
422
- i::Heap::CollectAllGarbage(false);
424
+ i::Isolate::Current()->compilation_cache()->Clear();
425
+ HEAP->CollectAllGarbage(false);
423
426
  CHECK_EQ(1, TestAsciiResource::dispose_count);
424
427
  }
425
428
 
@@ -432,19 +435,19 @@ THREADED_TEST(ScriptMakingExternalString) {
432
435
  LocalContext env;
433
436
  Local<String> source = String::New(two_byte_source);
434
437
  // Trigger GCs so that the newly allocated string moves to old gen.
435
- i::Heap::CollectGarbage(i::NEW_SPACE); // in survivor space now
436
- i::Heap::CollectGarbage(i::NEW_SPACE); // in old gen now
438
+ HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now
439
+ HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now
437
440
  bool success = source->MakeExternal(new TestResource(two_byte_source));
438
441
  CHECK(success);
439
442
  Local<Script> script = Script::Compile(source);
440
443
  Local<Value> value = script->Run();
441
444
  CHECK(value->IsNumber());
442
445
  CHECK_EQ(7, value->Int32Value());
443
- i::Heap::CollectAllGarbage(false);
446
+ HEAP->CollectAllGarbage(false);
444
447
  CHECK_EQ(0, TestResource::dispose_count);
445
448
  }
446
- i::CompilationCache::Clear();
447
- i::Heap::CollectAllGarbage(false);
449
+ i::Isolate::Current()->compilation_cache()->Clear();
450
+ HEAP->CollectAllGarbage(false);
448
451
  CHECK_EQ(1, TestResource::dispose_count);
449
452
  }
450
453
 
@@ -457,8 +460,8 @@ THREADED_TEST(ScriptMakingExternalAsciiString) {
457
460
  LocalContext env;
458
461
  Local<String> source = v8_str(c_source);
459
462
  // Trigger GCs so that the newly allocated string moves to old gen.
460
- i::Heap::CollectGarbage(i::NEW_SPACE); // in survivor space now
461
- i::Heap::CollectGarbage(i::NEW_SPACE); // in old gen now
463
+ HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now
464
+ HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now
462
465
  bool success = source->MakeExternal(
463
466
  new TestAsciiResource(i::StrDup(c_source)));
464
467
  CHECK(success);
@@ -466,11 +469,11 @@ THREADED_TEST(ScriptMakingExternalAsciiString) {
466
469
  Local<Value> value = script->Run();
467
470
  CHECK(value->IsNumber());
468
471
  CHECK_EQ(7, value->Int32Value());
469
- i::Heap::CollectAllGarbage(false);
472
+ HEAP->CollectAllGarbage(false);
470
473
  CHECK_EQ(0, TestAsciiResource::dispose_count);
471
474
  }
472
- i::CompilationCache::Clear();
473
- i::Heap::CollectAllGarbage(false);
475
+ i::Isolate::Current()->compilation_cache()->Clear();
476
+ HEAP->CollectAllGarbage(false);
474
477
  CHECK_EQ(1, TestAsciiResource::dispose_count);
475
478
  }
476
479
 
@@ -480,8 +483,8 @@ TEST(MakingExternalStringConditions) {
480
483
  LocalContext env;
481
484
 
482
485
  // Free some space in the new space so that we can check freshness.
483
- i::Heap::CollectGarbage(i::NEW_SPACE);
484
- i::Heap::CollectGarbage(i::NEW_SPACE);
486
+ HEAP->CollectGarbage(i::NEW_SPACE);
487
+ HEAP->CollectGarbage(i::NEW_SPACE);
485
488
 
486
489
  uint16_t* two_byte_string = AsciiToTwoByteString("small");
487
490
  Local<String> small_string = String::New(two_byte_string);
@@ -490,8 +493,8 @@ TEST(MakingExternalStringConditions) {
490
493
  // We should refuse to externalize newly created small string.
491
494
  CHECK(!small_string->CanMakeExternal());
492
495
  // Trigger GCs so that the newly allocated string moves to old gen.
493
- i::Heap::CollectGarbage(i::NEW_SPACE); // in survivor space now
494
- i::Heap::CollectGarbage(i::NEW_SPACE); // in old gen now
496
+ HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now
497
+ HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now
495
498
  // Old space strings should be accepted.
496
499
  CHECK(small_string->CanMakeExternal());
497
500
 
@@ -526,15 +529,15 @@ TEST(MakingExternalAsciiStringConditions) {
526
529
  LocalContext env;
527
530
 
528
531
  // Free some space in the new space so that we can check freshness.
529
- i::Heap::CollectGarbage(i::NEW_SPACE);
530
- i::Heap::CollectGarbage(i::NEW_SPACE);
532
+ HEAP->CollectGarbage(i::NEW_SPACE);
533
+ HEAP->CollectGarbage(i::NEW_SPACE);
531
534
 
532
535
  Local<String> small_string = String::New("small");
533
536
  // We should refuse to externalize newly created small string.
534
537
  CHECK(!small_string->CanMakeExternal());
535
538
  // Trigger GCs so that the newly allocated string moves to old gen.
536
- i::Heap::CollectGarbage(i::NEW_SPACE); // in survivor space now
537
- i::Heap::CollectGarbage(i::NEW_SPACE); // in old gen now
539
+ HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now
540
+ HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now
538
541
  // Old space strings should be accepted.
539
542
  CHECK(small_string->CanMakeExternal());
540
543
 
@@ -566,13 +569,13 @@ THREADED_TEST(UsingExternalString) {
566
569
  String::NewExternal(new TestResource(two_byte_string));
567
570
  i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
568
571
  // Trigger GCs so that the newly allocated string moves to old gen.
569
- i::Heap::CollectGarbage(i::NEW_SPACE); // in survivor space now
570
- i::Heap::CollectGarbage(i::NEW_SPACE); // in old gen now
571
- i::Handle<i::String> isymbol = i::Factory::SymbolFromString(istring);
572
+ HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now
573
+ HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now
574
+ i::Handle<i::String> isymbol = FACTORY->SymbolFromString(istring);
572
575
  CHECK(isymbol->IsSymbol());
573
576
  }
574
- i::Heap::CollectAllGarbage(false);
575
- i::Heap::CollectAllGarbage(false);
577
+ HEAP->CollectAllGarbage(false);
578
+ HEAP->CollectAllGarbage(false);
576
579
  }
577
580
 
578
581
 
@@ -584,13 +587,13 @@ THREADED_TEST(UsingExternalAsciiString) {
584
587
  new TestAsciiResource(i::StrDup(one_byte_string)));
585
588
  i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
586
589
  // Trigger GCs so that the newly allocated string moves to old gen.
587
- i::Heap::CollectGarbage(i::NEW_SPACE); // in survivor space now
588
- i::Heap::CollectGarbage(i::NEW_SPACE); // in old gen now
589
- i::Handle<i::String> isymbol = i::Factory::SymbolFromString(istring);
590
+ HEAP->CollectGarbage(i::NEW_SPACE); // in survivor space now
591
+ HEAP->CollectGarbage(i::NEW_SPACE); // in old gen now
592
+ i::Handle<i::String> isymbol = FACTORY->SymbolFromString(istring);
590
593
  CHECK(isymbol->IsSymbol());
591
594
  }
592
- i::Heap::CollectAllGarbage(false);
593
- i::Heap::CollectAllGarbage(false);
595
+ HEAP->CollectAllGarbage(false);
596
+ HEAP->CollectAllGarbage(false);
594
597
  }
595
598
 
596
599
 
@@ -603,12 +606,12 @@ THREADED_TEST(ScavengeExternalString) {
603
606
  Local<String> string =
604
607
  String::NewExternal(new TestResource(two_byte_string));
605
608
  i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
606
- i::Heap::CollectGarbage(i::NEW_SPACE);
607
- in_new_space = i::Heap::InNewSpace(*istring);
608
- CHECK(in_new_space || i::Heap::old_data_space()->Contains(*istring));
609
+ HEAP->CollectGarbage(i::NEW_SPACE);
610
+ in_new_space = HEAP->InNewSpace(*istring);
611
+ CHECK(in_new_space || HEAP->old_data_space()->Contains(*istring));
609
612
  CHECK_EQ(0, TestResource::dispose_count);
610
613
  }
611
- i::Heap::CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE);
614
+ HEAP->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE);
612
615
  CHECK_EQ(1, TestResource::dispose_count);
613
616
  }
614
617
 
@@ -622,12 +625,12 @@ THREADED_TEST(ScavengeExternalAsciiString) {
622
625
  Local<String> string = String::NewExternal(
623
626
  new TestAsciiResource(i::StrDup(one_byte_string)));
624
627
  i::Handle<i::String> istring = v8::Utils::OpenHandle(*string);
625
- i::Heap::CollectGarbage(i::NEW_SPACE);
626
- in_new_space = i::Heap::InNewSpace(*istring);
627
- CHECK(in_new_space || i::Heap::old_data_space()->Contains(*istring));
628
+ HEAP->CollectGarbage(i::NEW_SPACE);
629
+ in_new_space = HEAP->InNewSpace(*istring);
630
+ CHECK(in_new_space || HEAP->old_data_space()->Contains(*istring));
628
631
  CHECK_EQ(0, TestAsciiResource::dispose_count);
629
632
  }
630
- i::Heap::CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE);
633
+ HEAP->CollectGarbage(in_new_space ? i::NEW_SPACE : i::OLD_DATA_SPACE);
631
634
  CHECK_EQ(1, TestAsciiResource::dispose_count);
632
635
  }
633
636
 
@@ -667,11 +670,11 @@ TEST(ExternalStringWithDisposeHandling) {
667
670
  Local<Value> value = script->Run();
668
671
  CHECK(value->IsNumber());
669
672
  CHECK_EQ(7, value->Int32Value());
670
- i::Heap::CollectAllGarbage(false);
673
+ HEAP->CollectAllGarbage(false);
671
674
  CHECK_EQ(0, TestAsciiResource::dispose_count);
672
675
  }
673
- i::CompilationCache::Clear();
674
- i::Heap::CollectAllGarbage(false);
676
+ i::Isolate::Current()->compilation_cache()->Clear();
677
+ HEAP->CollectAllGarbage(false);
675
678
  CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls);
676
679
  CHECK_EQ(0, TestAsciiResource::dispose_count);
677
680
 
@@ -688,11 +691,11 @@ TEST(ExternalStringWithDisposeHandling) {
688
691
  Local<Value> value = script->Run();
689
692
  CHECK(value->IsNumber());
690
693
  CHECK_EQ(7, value->Int32Value());
691
- i::Heap::CollectAllGarbage(false);
694
+ HEAP->CollectAllGarbage(false);
692
695
  CHECK_EQ(0, TestAsciiResource::dispose_count);
693
696
  }
694
- i::CompilationCache::Clear();
695
- i::Heap::CollectAllGarbage(false);
697
+ i::Isolate::Current()->compilation_cache()->Clear();
698
+ HEAP->CollectAllGarbage(false);
696
699
  CHECK_EQ(1, TestAsciiResourceWithDisposeControl::dispose_calls);
697
700
  CHECK_EQ(1, TestAsciiResource::dispose_count);
698
701
  }
@@ -738,9 +741,9 @@ THREADED_TEST(StringConcat) {
738
741
  CHECK(value->IsNumber());
739
742
  CHECK_EQ(68, value->Int32Value());
740
743
  }
741
- i::CompilationCache::Clear();
742
- i::Heap::CollectAllGarbage(false);
743
- i::Heap::CollectAllGarbage(false);
744
+ i::Isolate::Current()->compilation_cache()->Clear();
745
+ HEAP->CollectAllGarbage(false);
746
+ HEAP->CollectAllGarbage(false);
744
747
  }
745
748
 
746
749
 
@@ -1575,12 +1578,12 @@ THREADED_TEST(InternalFieldsNativePointers) {
1575
1578
 
1576
1579
  // Check reading and writing aligned pointers.
1577
1580
  obj->SetPointerInInternalField(0, aligned);
1578
- i::Heap::CollectAllGarbage(false);
1581
+ HEAP->CollectAllGarbage(false);
1579
1582
  CHECK_EQ(aligned, obj->GetPointerFromInternalField(0));
1580
1583
 
1581
1584
  // Check reading and writing unaligned pointers.
1582
1585
  obj->SetPointerInInternalField(0, unaligned);
1583
- i::Heap::CollectAllGarbage(false);
1586
+ HEAP->CollectAllGarbage(false);
1584
1587
  CHECK_EQ(unaligned, obj->GetPointerFromInternalField(0));
1585
1588
 
1586
1589
  delete[] data;
@@ -1606,19 +1609,19 @@ THREADED_TEST(InternalFieldsNativePointersAndExternal) {
1606
1609
  CHECK_EQ(1, static_cast<int>(reinterpret_cast<uintptr_t>(unaligned) & 0x1));
1607
1610
 
1608
1611
  obj->SetPointerInInternalField(0, aligned);
1609
- i::Heap::CollectAllGarbage(false);
1612
+ HEAP->CollectAllGarbage(false);
1610
1613
  CHECK_EQ(aligned, v8::External::Unwrap(obj->GetInternalField(0)));
1611
1614
 
1612
1615
  obj->SetPointerInInternalField(0, unaligned);
1613
- i::Heap::CollectAllGarbage(false);
1616
+ HEAP->CollectAllGarbage(false);
1614
1617
  CHECK_EQ(unaligned, v8::External::Unwrap(obj->GetInternalField(0)));
1615
1618
 
1616
1619
  obj->SetInternalField(0, v8::External::Wrap(aligned));
1617
- i::Heap::CollectAllGarbage(false);
1620
+ HEAP->CollectAllGarbage(false);
1618
1621
  CHECK_EQ(aligned, obj->GetPointerFromInternalField(0));
1619
1622
 
1620
1623
  obj->SetInternalField(0, v8::External::Wrap(unaligned));
1621
- i::Heap::CollectAllGarbage(false);
1624
+ HEAP->CollectAllGarbage(false);
1622
1625
  CHECK_EQ(unaligned, obj->GetPointerFromInternalField(0));
1623
1626
 
1624
1627
  delete[] data;
@@ -1631,7 +1634,7 @@ THREADED_TEST(IdentityHash) {
1631
1634
 
1632
1635
  // Ensure that the test starts with an fresh heap to test whether the hash
1633
1636
  // code is based on the address.
1634
- i::Heap::CollectAllGarbage(false);
1637
+ HEAP->CollectAllGarbage(false);
1635
1638
  Local<v8::Object> obj = v8::Object::New();
1636
1639
  int hash = obj->GetIdentityHash();
1637
1640
  int hash1 = obj->GetIdentityHash();
@@ -1641,7 +1644,7 @@ THREADED_TEST(IdentityHash) {
1641
1644
  // objects should not be assigned the same hash code. If the test below fails
1642
1645
  // the random number generator should be evaluated.
1643
1646
  CHECK_NE(hash, hash2);
1644
- i::Heap::CollectAllGarbage(false);
1647
+ HEAP->CollectAllGarbage(false);
1645
1648
  int hash3 = v8::Object::New()->GetIdentityHash();
1646
1649
  // Make sure that the identity hash is not based on the initial address of
1647
1650
  // the object alone. If the test below fails the random number generator
@@ -1678,7 +1681,7 @@ THREADED_TEST(HiddenProperties) {
1678
1681
  v8::Local<v8::String> empty = v8_str("");
1679
1682
  v8::Local<v8::String> prop_name = v8_str("prop_name");
1680
1683
 
1681
- i::Heap::CollectAllGarbage(false);
1684
+ HEAP->CollectAllGarbage(false);
1682
1685
 
1683
1686
  // Make sure delete of a non-existent hidden value works
1684
1687
  CHECK(obj->DeleteHiddenValue(key));
@@ -1688,7 +1691,7 @@ THREADED_TEST(HiddenProperties) {
1688
1691
  CHECK(obj->SetHiddenValue(key, v8::Integer::New(2002)));
1689
1692
  CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value());
1690
1693
 
1691
- i::Heap::CollectAllGarbage(false);
1694
+ HEAP->CollectAllGarbage(false);
1692
1695
 
1693
1696
  // Make sure we do not find the hidden property.
1694
1697
  CHECK(!obj->Has(empty));
@@ -1699,7 +1702,7 @@ THREADED_TEST(HiddenProperties) {
1699
1702
  CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value());
1700
1703
  CHECK_EQ(2003, obj->Get(empty)->Int32Value());
1701
1704
 
1702
- i::Heap::CollectAllGarbage(false);
1705
+ HEAP->CollectAllGarbage(false);
1703
1706
 
1704
1707
  // Add another property and delete it afterwards to force the object in
1705
1708
  // slow case.
@@ -1710,7 +1713,7 @@ THREADED_TEST(HiddenProperties) {
1710
1713
  CHECK(obj->Delete(prop_name));
1711
1714
  CHECK_EQ(2002, obj->GetHiddenValue(key)->Int32Value());
1712
1715
 
1713
- i::Heap::CollectAllGarbage(false);
1716
+ HEAP->CollectAllGarbage(false);
1714
1717
 
1715
1718
  CHECK(obj->DeleteHiddenValue(key));
1716
1719
  CHECK(obj->GetHiddenValue(key).IsEmpty());
@@ -1789,6 +1792,180 @@ THREADED_TEST(GlobalHandle) {
1789
1792
  }
1790
1793
 
1791
1794
 
1795
+ static int NumberOfWeakCalls = 0;
1796
+ static void WeakPointerCallback(Persistent<Value> handle, void* id) {
1797
+ CHECK_EQ(reinterpret_cast<void*>(1234), id);
1798
+ NumberOfWeakCalls++;
1799
+ handle.Dispose();
1800
+ }
1801
+
1802
+ THREADED_TEST(ApiObjectGroups) {
1803
+ HandleScope scope;
1804
+ LocalContext env;
1805
+
1806
+ NumberOfWeakCalls = 0;
1807
+
1808
+ Persistent<Object> g1s1;
1809
+ Persistent<Object> g1s2;
1810
+ Persistent<Object> g1c1;
1811
+ Persistent<Object> g2s1;
1812
+ Persistent<Object> g2s2;
1813
+ Persistent<Object> g2c1;
1814
+
1815
+ {
1816
+ HandleScope scope;
1817
+ g1s1 = Persistent<Object>::New(Object::New());
1818
+ g1s2 = Persistent<Object>::New(Object::New());
1819
+ g1c1 = Persistent<Object>::New(Object::New());
1820
+ g1s1.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback);
1821
+ g1s2.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback);
1822
+ g1c1.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback);
1823
+
1824
+ g2s1 = Persistent<Object>::New(Object::New());
1825
+ g2s2 = Persistent<Object>::New(Object::New());
1826
+ g2c1 = Persistent<Object>::New(Object::New());
1827
+ g2s1.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback);
1828
+ g2s2.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback);
1829
+ g2c1.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback);
1830
+ }
1831
+
1832
+ Persistent<Object> root = Persistent<Object>::New(g1s1); // make a root.
1833
+
1834
+ // Connect group 1 and 2, make a cycle.
1835
+ CHECK(g1s2->Set(0, g2s2));
1836
+ CHECK(g2s1->Set(0, g1s1));
1837
+
1838
+ {
1839
+ Persistent<Value> g1_objects[] = { g1s1, g1s2 };
1840
+ Persistent<Value> g1_children[] = { g1c1 };
1841
+ Persistent<Value> g2_objects[] = { g2s1, g2s2 };
1842
+ Persistent<Value> g2_children[] = { g2c1 };
1843
+ V8::AddObjectGroup(g1_objects, 2);
1844
+ V8::AddImplicitReferences(g1s1, g1_children, 1);
1845
+ V8::AddObjectGroup(g2_objects, 2);
1846
+ V8::AddImplicitReferences(g2s2, g2_children, 1);
1847
+ }
1848
+ // Do a full GC
1849
+ HEAP->CollectGarbage(i::OLD_POINTER_SPACE);
1850
+
1851
+ // All object should be alive.
1852
+ CHECK_EQ(0, NumberOfWeakCalls);
1853
+
1854
+ // Weaken the root.
1855
+ root.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback);
1856
+ // But make children strong roots---all the objects (except for children)
1857
+ // should be collectable now.
1858
+ g1c1.ClearWeak();
1859
+ g2c1.ClearWeak();
1860
+
1861
+ // Groups are deleted, rebuild groups.
1862
+ {
1863
+ Persistent<Value> g1_objects[] = { g1s1, g1s2 };
1864
+ Persistent<Value> g1_children[] = { g1c1 };
1865
+ Persistent<Value> g2_objects[] = { g2s1, g2s2 };
1866
+ Persistent<Value> g2_children[] = { g2c1 };
1867
+ V8::AddObjectGroup(g1_objects, 2);
1868
+ V8::AddImplicitReferences(g1s1, g1_children, 1);
1869
+ V8::AddObjectGroup(g2_objects, 2);
1870
+ V8::AddImplicitReferences(g2s2, g2_children, 1);
1871
+ }
1872
+
1873
+ HEAP->CollectGarbage(i::OLD_POINTER_SPACE);
1874
+
1875
+ // All objects should be gone. 5 global handles in total.
1876
+ CHECK_EQ(5, NumberOfWeakCalls);
1877
+
1878
+ // And now make children weak again and collect them.
1879
+ g1c1.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback);
1880
+ g2c1.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback);
1881
+
1882
+ HEAP->CollectGarbage(i::OLD_POINTER_SPACE);
1883
+ CHECK_EQ(7, NumberOfWeakCalls);
1884
+ }
1885
+
1886
+
1887
+ THREADED_TEST(ApiObjectGroupsCycle) {
1888
+ HandleScope scope;
1889
+ LocalContext env;
1890
+
1891
+ NumberOfWeakCalls = 0;
1892
+
1893
+ Persistent<Object> g1s1;
1894
+ Persistent<Object> g1s2;
1895
+ Persistent<Object> g2s1;
1896
+ Persistent<Object> g2s2;
1897
+ Persistent<Object> g3s1;
1898
+ Persistent<Object> g3s2;
1899
+
1900
+ {
1901
+ HandleScope scope;
1902
+ g1s1 = Persistent<Object>::New(Object::New());
1903
+ g1s2 = Persistent<Object>::New(Object::New());
1904
+ g1s1.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback);
1905
+ g1s2.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback);
1906
+
1907
+ g2s1 = Persistent<Object>::New(Object::New());
1908
+ g2s2 = Persistent<Object>::New(Object::New());
1909
+ g2s1.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback);
1910
+ g2s2.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback);
1911
+
1912
+ g3s1 = Persistent<Object>::New(Object::New());
1913
+ g3s2 = Persistent<Object>::New(Object::New());
1914
+ g3s1.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback);
1915
+ g3s2.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback);
1916
+ }
1917
+
1918
+ Persistent<Object> root = Persistent<Object>::New(g1s1); // make a root.
1919
+
1920
+ // Connect groups. We're building the following cycle:
1921
+ // G1: { g1s1, g2s1 }, g1s1 implicitly references g2s1, ditto for other
1922
+ // groups.
1923
+ {
1924
+ Persistent<Value> g1_objects[] = { g1s1, g1s2 };
1925
+ Persistent<Value> g1_children[] = { g2s1 };
1926
+ Persistent<Value> g2_objects[] = { g2s1, g2s2 };
1927
+ Persistent<Value> g2_children[] = { g3s1 };
1928
+ Persistent<Value> g3_objects[] = { g3s1, g3s2 };
1929
+ Persistent<Value> g3_children[] = { g1s1 };
1930
+ V8::AddObjectGroup(g1_objects, 2);
1931
+ V8::AddImplicitReferences(g1s1, g1_children, 1);
1932
+ V8::AddObjectGroup(g2_objects, 2);
1933
+ V8::AddImplicitReferences(g2s1, g2_children, 1);
1934
+ V8::AddObjectGroup(g3_objects, 2);
1935
+ V8::AddImplicitReferences(g3s1, g3_children, 1);
1936
+ }
1937
+ // Do a full GC
1938
+ HEAP->CollectGarbage(i::OLD_POINTER_SPACE);
1939
+
1940
+ // All object should be alive.
1941
+ CHECK_EQ(0, NumberOfWeakCalls);
1942
+
1943
+ // Weaken the root.
1944
+ root.MakeWeak(reinterpret_cast<void*>(1234), &WeakPointerCallback);
1945
+
1946
+ // Groups are deleted, rebuild groups.
1947
+ {
1948
+ Persistent<Value> g1_objects[] = { g1s1, g1s2 };
1949
+ Persistent<Value> g1_children[] = { g2s1 };
1950
+ Persistent<Value> g2_objects[] = { g2s1, g2s2 };
1951
+ Persistent<Value> g2_children[] = { g3s1 };
1952
+ Persistent<Value> g3_objects[] = { g3s1, g3s2 };
1953
+ Persistent<Value> g3_children[] = { g1s1 };
1954
+ V8::AddObjectGroup(g1_objects, 2);
1955
+ V8::AddImplicitReferences(g1s1, g1_children, 1);
1956
+ V8::AddObjectGroup(g2_objects, 2);
1957
+ V8::AddImplicitReferences(g2s1, g2_children, 1);
1958
+ V8::AddObjectGroup(g3_objects, 2);
1959
+ V8::AddImplicitReferences(g3s1, g3_children, 1);
1960
+ }
1961
+
1962
+ HEAP->CollectGarbage(i::OLD_POINTER_SPACE);
1963
+
1964
+ // All objects should be gone. 7 global handles in total.
1965
+ CHECK_EQ(7, NumberOfWeakCalls);
1966
+ }
1967
+
1968
+
1792
1969
  THREADED_TEST(ScriptException) {
1793
1970
  v8::HandleScope scope;
1794
1971
  LocalContext env;
@@ -1900,6 +2077,10 @@ THREADED_TEST(Array) {
1900
2077
  CHECK_EQ(1, arr->Get(0)->Int32Value());
1901
2078
  CHECK_EQ(2, arr->Get(1)->Int32Value());
1902
2079
  CHECK_EQ(3, arr->Get(2)->Int32Value());
2080
+ array = v8::Array::New(27);
2081
+ CHECK_EQ(27, array->Length());
2082
+ array = v8::Array::New(-27);
2083
+ CHECK_EQ(0, array->Length());
1903
2084
  }
1904
2085
 
1905
2086
 
@@ -2082,8 +2263,6 @@ TEST(OutOfMemoryNested) {
2082
2263
  TEST(HugeConsStringOutOfMemory) {
2083
2264
  // It's not possible to read a snapshot into a heap with different dimensions.
2084
2265
  if (i::Snapshot::IsEnabled()) return;
2085
- v8::HandleScope scope;
2086
- LocalContext context;
2087
2266
  // Set heap limits.
2088
2267
  static const int K = 1024;
2089
2268
  v8::ResourceConstraints constraints;
@@ -2094,6 +2273,9 @@ TEST(HugeConsStringOutOfMemory) {
2094
2273
  // Execute a script that causes out of memory.
2095
2274
  v8::V8::IgnoreOutOfMemoryException();
2096
2275
 
2276
+ v8::HandleScope scope;
2277
+ LocalContext context;
2278
+
2097
2279
  // Build huge string. This should fail with out of memory exception.
2098
2280
  Local<Value> result = CompileRun(
2099
2281
  "var str = Array.prototype.join.call({length: 513}, \"A\").toUpperCase();"
@@ -2513,7 +2695,7 @@ v8::Handle<Value> CThrowCountDown(const v8::Arguments& args) {
2513
2695
  if (try_catch.HasCaught()) {
2514
2696
  CHECK_EQ(expected, count);
2515
2697
  CHECK(result.IsEmpty());
2516
- CHECK(!i::Top::has_scheduled_exception());
2698
+ CHECK(!i::Isolate::Current()->has_scheduled_exception());
2517
2699
  } else {
2518
2700
  CHECK_NE(expected, count);
2519
2701
  }
@@ -3688,10 +3870,8 @@ THREADED_TEST(ExtensibleOnUndetectable) {
3688
3870
 
3689
3871
  source = v8_str("undetectable.y = 2000;");
3690
3872
  script = Script::Compile(source);
3691
- v8::TryCatch try_catch;
3692
3873
  Local<Value> result = script->Run();
3693
- CHECK(result.IsEmpty());
3694
- CHECK(try_catch.HasCaught());
3874
+ ExpectBoolean("undetectable.y == undefined", true);
3695
3875
  }
3696
3876
 
3697
3877
 
@@ -4205,7 +4385,7 @@ static void ForceScavenge(v8::Persistent<v8::Value> obj, void* data) {
4205
4385
  obj.Dispose();
4206
4386
  obj.Clear();
4207
4387
  in_scavenge = true;
4208
- i::Heap::PerformScavenge();
4388
+ HEAP->PerformScavenge();
4209
4389
  in_scavenge = false;
4210
4390
  *(reinterpret_cast<bool*>(data)) = true;
4211
4391
  }
@@ -4242,7 +4422,7 @@ THREADED_TEST(NoWeakRefCallbacksInScavenge) {
4242
4422
  object_b.MakeWeak(&released_in_scavenge, &CheckIsNotInvokedInScavenge);
4243
4423
 
4244
4424
  while (!object_a_disposed) {
4245
- i::Heap::CollectAllGarbage(false);
4425
+ HEAP->CollectAllGarbage(false);
4246
4426
  }
4247
4427
  CHECK(!released_in_scavenge);
4248
4428
  }
@@ -4260,7 +4440,7 @@ static v8::Handle<Value> ArgumentsTestCallback(const v8::Arguments& args) {
4260
4440
  CHECK_EQ(v8::Integer::New(3), args[2]);
4261
4441
  CHECK_EQ(v8::Undefined(), args[3]);
4262
4442
  v8::HandleScope scope;
4263
- i::Heap::CollectAllGarbage(false);
4443
+ HEAP->CollectAllGarbage(false);
4264
4444
  return v8::Undefined();
4265
4445
  }
4266
4446
 
@@ -4562,130 +4742,130 @@ THREADED_TEST(StringWrite) {
4562
4742
 
4563
4743
  memset(utf8buf, 0x1, sizeof(utf8buf));
4564
4744
  len = str2->WriteUtf8(utf8buf, sizeof(utf8buf), &charlen);
4565
- CHECK_EQ(len, 9);
4566
- CHECK_EQ(charlen, 5);
4567
- CHECK_EQ(strcmp(utf8buf, "abc\303\260\342\230\203"), 0);
4745
+ CHECK_EQ(9, len);
4746
+ CHECK_EQ(5, charlen);
4747
+ CHECK_EQ(0, strcmp(utf8buf, "abc\303\260\342\230\203"));
4568
4748
 
4569
4749
  memset(utf8buf, 0x1, sizeof(utf8buf));
4570
4750
  len = str2->WriteUtf8(utf8buf, 8, &charlen);
4571
- CHECK_EQ(len, 8);
4572
- CHECK_EQ(charlen, 5);
4573
- CHECK_EQ(strncmp(utf8buf, "abc\303\260\342\230\203\1", 9), 0);
4751
+ CHECK_EQ(8, len);
4752
+ CHECK_EQ(5, charlen);
4753
+ CHECK_EQ(0, strncmp(utf8buf, "abc\303\260\342\230\203\1", 9));
4574
4754
 
4575
4755
  memset(utf8buf, 0x1, sizeof(utf8buf));
4576
4756
  len = str2->WriteUtf8(utf8buf, 7, &charlen);
4577
- CHECK_EQ(len, 5);
4578
- CHECK_EQ(charlen, 4);
4579
- CHECK_EQ(strncmp(utf8buf, "abc\303\260\1", 5), 0);
4757
+ CHECK_EQ(5, len);
4758
+ CHECK_EQ(4, charlen);
4759
+ CHECK_EQ(0, strncmp(utf8buf, "abc\303\260\1", 5));
4580
4760
 
4581
4761
  memset(utf8buf, 0x1, sizeof(utf8buf));
4582
4762
  len = str2->WriteUtf8(utf8buf, 6, &charlen);
4583
- CHECK_EQ(len, 5);
4584
- CHECK_EQ(charlen, 4);
4585
- CHECK_EQ(strncmp(utf8buf, "abc\303\260\1", 5), 0);
4763
+ CHECK_EQ(5, len);
4764
+ CHECK_EQ(4, charlen);
4765
+ CHECK_EQ(0, strncmp(utf8buf, "abc\303\260\1", 5));
4586
4766
 
4587
4767
  memset(utf8buf, 0x1, sizeof(utf8buf));
4588
4768
  len = str2->WriteUtf8(utf8buf, 5, &charlen);
4589
- CHECK_EQ(len, 5);
4590
- CHECK_EQ(charlen, 4);
4591
- CHECK_EQ(strncmp(utf8buf, "abc\303\260\1", 5), 0);
4769
+ CHECK_EQ(5, len);
4770
+ CHECK_EQ(4, charlen);
4771
+ CHECK_EQ(0, strncmp(utf8buf, "abc\303\260\1", 5));
4592
4772
 
4593
4773
  memset(utf8buf, 0x1, sizeof(utf8buf));
4594
4774
  len = str2->WriteUtf8(utf8buf, 4, &charlen);
4595
- CHECK_EQ(len, 3);
4596
- CHECK_EQ(charlen, 3);
4597
- CHECK_EQ(strncmp(utf8buf, "abc\1", 4), 0);
4775
+ CHECK_EQ(3, len);
4776
+ CHECK_EQ(3, charlen);
4777
+ CHECK_EQ(0, strncmp(utf8buf, "abc\1", 4));
4598
4778
 
4599
4779
  memset(utf8buf, 0x1, sizeof(utf8buf));
4600
4780
  len = str2->WriteUtf8(utf8buf, 3, &charlen);
4601
- CHECK_EQ(len, 3);
4602
- CHECK_EQ(charlen, 3);
4603
- CHECK_EQ(strncmp(utf8buf, "abc\1", 4), 0);
4781
+ CHECK_EQ(3, len);
4782
+ CHECK_EQ(3, charlen);
4783
+ CHECK_EQ(0, strncmp(utf8buf, "abc\1", 4));
4604
4784
 
4605
4785
  memset(utf8buf, 0x1, sizeof(utf8buf));
4606
4786
  len = str2->WriteUtf8(utf8buf, 2, &charlen);
4607
- CHECK_EQ(len, 2);
4608
- CHECK_EQ(charlen, 2);
4609
- CHECK_EQ(strncmp(utf8buf, "ab\1", 3), 0);
4787
+ CHECK_EQ(2, len);
4788
+ CHECK_EQ(2, charlen);
4789
+ CHECK_EQ(0, strncmp(utf8buf, "ab\1", 3));
4610
4790
 
4611
4791
  memset(buf, 0x1, sizeof(buf));
4612
4792
  memset(wbuf, 0x1, sizeof(wbuf));
4613
4793
  len = str->WriteAscii(buf);
4614
- CHECK_EQ(len, 5);
4794
+ CHECK_EQ(5, len);
4615
4795
  len = str->Write(wbuf);
4616
- CHECK_EQ(len, 5);
4617
- CHECK_EQ(strcmp("abcde", buf), 0);
4796
+ CHECK_EQ(5, len);
4797
+ CHECK_EQ(0, strcmp("abcde", buf));
4618
4798
  uint16_t answer1[] = {'a', 'b', 'c', 'd', 'e', '\0'};
4619
- CHECK_EQ(StrCmp16(answer1, wbuf), 0);
4799
+ CHECK_EQ(0, StrCmp16(answer1, wbuf));
4620
4800
 
4621
4801
  memset(buf, 0x1, sizeof(buf));
4622
4802
  memset(wbuf, 0x1, sizeof(wbuf));
4623
4803
  len = str->WriteAscii(buf, 0, 4);
4624
- CHECK_EQ(len, 4);
4804
+ CHECK_EQ(4, len);
4625
4805
  len = str->Write(wbuf, 0, 4);
4626
- CHECK_EQ(len, 4);
4627
- CHECK_EQ(strncmp("abcd\1", buf, 5), 0);
4806
+ CHECK_EQ(4, len);
4807
+ CHECK_EQ(0, strncmp("abcd\1", buf, 5));
4628
4808
  uint16_t answer2[] = {'a', 'b', 'c', 'd', 0x101};
4629
- CHECK_EQ(StrNCmp16(answer2, wbuf, 5), 0);
4809
+ CHECK_EQ(0, StrNCmp16(answer2, wbuf, 5));
4630
4810
 
4631
4811
  memset(buf, 0x1, sizeof(buf));
4632
4812
  memset(wbuf, 0x1, sizeof(wbuf));
4633
4813
  len = str->WriteAscii(buf, 0, 5);
4634
- CHECK_EQ(len, 5);
4814
+ CHECK_EQ(5, len);
4635
4815
  len = str->Write(wbuf, 0, 5);
4636
- CHECK_EQ(len, 5);
4637
- CHECK_EQ(strncmp("abcde\1", buf, 6), 0);
4816
+ CHECK_EQ(5, len);
4817
+ CHECK_EQ(0, strncmp("abcde\1", buf, 6));
4638
4818
  uint16_t answer3[] = {'a', 'b', 'c', 'd', 'e', 0x101};
4639
- CHECK_EQ(StrNCmp16(answer3, wbuf, 6), 0);
4819
+ CHECK_EQ(0, StrNCmp16(answer3, wbuf, 6));
4640
4820
 
4641
4821
  memset(buf, 0x1, sizeof(buf));
4642
4822
  memset(wbuf, 0x1, sizeof(wbuf));
4643
4823
  len = str->WriteAscii(buf, 0, 6);
4644
- CHECK_EQ(len, 5);
4824
+ CHECK_EQ(5, len);
4645
4825
  len = str->Write(wbuf, 0, 6);
4646
- CHECK_EQ(len, 5);
4647
- CHECK_EQ(strcmp("abcde", buf), 0);
4826
+ CHECK_EQ(5, len);
4827
+ CHECK_EQ(0, strcmp("abcde", buf));
4648
4828
  uint16_t answer4[] = {'a', 'b', 'c', 'd', 'e', '\0'};
4649
- CHECK_EQ(StrCmp16(answer4, wbuf), 0);
4829
+ CHECK_EQ(0, StrCmp16(answer4, wbuf));
4650
4830
 
4651
4831
  memset(buf, 0x1, sizeof(buf));
4652
4832
  memset(wbuf, 0x1, sizeof(wbuf));
4653
4833
  len = str->WriteAscii(buf, 4, -1);
4654
- CHECK_EQ(len, 1);
4834
+ CHECK_EQ(1, len);
4655
4835
  len = str->Write(wbuf, 4, -1);
4656
- CHECK_EQ(len, 1);
4657
- CHECK_EQ(strcmp("e", buf), 0);
4836
+ CHECK_EQ(1, len);
4837
+ CHECK_EQ(0, strcmp("e", buf));
4658
4838
  uint16_t answer5[] = {'e', '\0'};
4659
- CHECK_EQ(StrCmp16(answer5, wbuf), 0);
4839
+ CHECK_EQ(0, StrCmp16(answer5, wbuf));
4660
4840
 
4661
4841
  memset(buf, 0x1, sizeof(buf));
4662
4842
  memset(wbuf, 0x1, sizeof(wbuf));
4663
4843
  len = str->WriteAscii(buf, 4, 6);
4664
- CHECK_EQ(len, 1);
4844
+ CHECK_EQ(1, len);
4665
4845
  len = str->Write(wbuf, 4, 6);
4666
- CHECK_EQ(len, 1);
4667
- CHECK_EQ(strcmp("e", buf), 0);
4668
- CHECK_EQ(StrCmp16(answer5, wbuf), 0);
4846
+ CHECK_EQ(1, len);
4847
+ CHECK_EQ(0, strcmp("e", buf));
4848
+ CHECK_EQ(0, StrCmp16(answer5, wbuf));
4669
4849
 
4670
4850
  memset(buf, 0x1, sizeof(buf));
4671
4851
  memset(wbuf, 0x1, sizeof(wbuf));
4672
4852
  len = str->WriteAscii(buf, 4, 1);
4673
- CHECK_EQ(len, 1);
4853
+ CHECK_EQ(1, len);
4674
4854
  len = str->Write(wbuf, 4, 1);
4675
- CHECK_EQ(len, 1);
4676
- CHECK_EQ(strncmp("e\1", buf, 2), 0);
4855
+ CHECK_EQ(1, len);
4856
+ CHECK_EQ(0, strncmp("e\1", buf, 2));
4677
4857
  uint16_t answer6[] = {'e', 0x101};
4678
- CHECK_EQ(StrNCmp16(answer6, wbuf, 2), 0);
4858
+ CHECK_EQ(0, StrNCmp16(answer6, wbuf, 2));
4679
4859
 
4680
4860
  memset(buf, 0x1, sizeof(buf));
4681
4861
  memset(wbuf, 0x1, sizeof(wbuf));
4682
4862
  len = str->WriteAscii(buf, 3, 1);
4683
- CHECK_EQ(len, 1);
4863
+ CHECK_EQ(1, len);
4684
4864
  len = str->Write(wbuf, 3, 1);
4685
- CHECK_EQ(len, 1);
4686
- CHECK_EQ(strncmp("d\1", buf, 2), 0);
4865
+ CHECK_EQ(1, len);
4866
+ CHECK_EQ(0, strncmp("d\1", buf, 2));
4687
4867
  uint16_t answer7[] = {'d', 0x101};
4688
- CHECK_EQ(StrNCmp16(answer7, wbuf, 2), 0);
4868
+ CHECK_EQ(0, StrNCmp16(answer7, wbuf, 2));
4689
4869
  }
4690
4870
 
4691
4871
 
@@ -5659,6 +5839,14 @@ TEST(AccessControlES5) {
5659
5839
  global_template->SetAccessCheckCallbacks(NamedAccessBlocker,
5660
5840
  IndexedAccessBlocker);
5661
5841
 
5842
+ // Add accessible accessor.
5843
+ global_template->SetAccessor(
5844
+ v8_str("accessible_prop"),
5845
+ EchoGetter, EchoSetter,
5846
+ v8::Handle<Value>(),
5847
+ v8::AccessControl(v8::ALL_CAN_READ | v8::ALL_CAN_WRITE));
5848
+
5849
+
5662
5850
  // Add an accessor that is not accessible by cross-domain JS code.
5663
5851
  global_template->SetAccessor(v8_str("blocked_prop"),
5664
5852
  UnreachableGetter, UnreachableSetter,
@@ -5699,6 +5887,18 @@ TEST(AccessControlES5) {
5699
5887
 
5700
5888
  CompileRun("Object.seal(other)");
5701
5889
  ExpectTrue("Object.isExtensible(other)");
5890
+
5891
+ // Regression test for issue 1250.
5892
+ // Make sure that we can set the accessible accessors value using normal
5893
+ // assignment.
5894
+ CompileRun("other.accessible_prop = 42");
5895
+ CHECK_EQ(42, g_echo_value);
5896
+
5897
+ v8::Handle<Value> value;
5898
+ // We follow Safari in ignoring assignments to host object accessors.
5899
+ CompileRun("Object.defineProperty(other, 'accessible_prop', {value: -1})");
5900
+ value = CompileRun("other.accessible_prop == 42");
5901
+ CHECK(value->IsTrue());
5702
5902
  }
5703
5903
 
5704
5904
 
@@ -6481,7 +6681,7 @@ THREADED_TEST(SetPrototypeThrows) {
6481
6681
  v8::TryCatch try_catch;
6482
6682
  CHECK(!o1->SetPrototype(o0));
6483
6683
  CHECK(!try_catch.HasCaught());
6484
- ASSERT(!i::Top::has_pending_exception());
6684
+ ASSERT(!i::Isolate::Current()->has_pending_exception());
6485
6685
 
6486
6686
  CHECK_EQ(42, CompileRun("function f() { return 42; }; f()")->Int32Value());
6487
6687
  }
@@ -6863,7 +7063,7 @@ static v8::Handle<Value> InterceptorHasOwnPropertyGetterGC(
6863
7063
  Local<String> name,
6864
7064
  const AccessorInfo& info) {
6865
7065
  ApiTestFuzzer::Fuzz();
6866
- i::Heap::CollectAllGarbage(false);
7066
+ HEAP->CollectAllGarbage(false);
6867
7067
  return v8::Handle<Value>();
6868
7068
  }
6869
7069
 
@@ -7593,7 +7793,7 @@ static v8::Handle<Value> InterceptorCallICFastApi(Local<String> name,
7593
7793
  int* call_count = reinterpret_cast<int*>(v8::External::Unwrap(info.Data()));
7594
7794
  ++(*call_count);
7595
7795
  if ((*call_count) % 20 == 0) {
7596
- i::Heap::CollectAllGarbage(true);
7796
+ HEAP->CollectAllGarbage(true);
7597
7797
  }
7598
7798
  return v8::Handle<Value>();
7599
7799
  }
@@ -7627,10 +7827,11 @@ static void GenerateSomeGarbage() {
7627
7827
  "garbage = undefined;");
7628
7828
  }
7629
7829
 
7830
+
7630
7831
  v8::Handle<v8::Value> DirectApiCallback(const v8::Arguments& args) {
7631
7832
  static int count = 0;
7632
7833
  if (count++ % 3 == 0) {
7633
- v8::V8::LowMemoryNotification(); // This should move the stub
7834
+ HEAP-> CollectAllGarbage(true); // This should move the stub
7634
7835
  GenerateSomeGarbage(); // This should ensure the old stub memory is flushed
7635
7836
  }
7636
7837
  return v8::Handle<v8::Value>();
@@ -7682,6 +7883,54 @@ THREADED_TEST(CallICFastApi_DirectCall_Throw) {
7682
7883
  }
7683
7884
 
7684
7885
 
7886
+ v8::Handle<v8::Value> DirectGetterCallback(Local<String> name,
7887
+ const v8::AccessorInfo& info) {
7888
+ if (++p_getter_count % 3 == 0) {
7889
+ HEAP->CollectAllGarbage(true);
7890
+ GenerateSomeGarbage();
7891
+ }
7892
+ return v8::Handle<v8::Value>();
7893
+ }
7894
+
7895
+
7896
+ THREADED_TEST(LoadICFastApi_DirectCall_GCMoveStub) {
7897
+ v8::HandleScope scope;
7898
+ LocalContext context;
7899
+ v8::Handle<v8::ObjectTemplate> obj = v8::ObjectTemplate::New();
7900
+ obj->SetAccessor(v8_str("p1"), DirectGetterCallback);
7901
+ context->Global()->Set(v8_str("o1"), obj->NewInstance());
7902
+ p_getter_count = 0;
7903
+ CompileRun(
7904
+ "function f() {"
7905
+ " for (var i = 0; i < 30; i++) o1.p1;"
7906
+ "}"
7907
+ "f();");
7908
+ CHECK_EQ(30, p_getter_count);
7909
+ }
7910
+
7911
+
7912
+ v8::Handle<v8::Value> ThrowingDirectGetterCallback(
7913
+ Local<String> name, const v8::AccessorInfo& info) {
7914
+ return v8::ThrowException(v8_str("g"));
7915
+ }
7916
+
7917
+
7918
+ THREADED_TEST(LoadICFastApi_DirectCall_Throw) {
7919
+ v8::HandleScope scope;
7920
+ LocalContext context;
7921
+ v8::Handle<v8::ObjectTemplate> obj = v8::ObjectTemplate::New();
7922
+ obj->SetAccessor(v8_str("p1"), ThrowingDirectGetterCallback);
7923
+ context->Global()->Set(v8_str("o1"), obj->NewInstance());
7924
+ v8::Handle<Value> result = CompileRun(
7925
+ "var result = '';"
7926
+ "for (var i = 0; i < 5; i++) {"
7927
+ " try { o1.p1; } catch (e) { result += e; }"
7928
+ "}"
7929
+ "result;");
7930
+ CHECK_EQ(v8_str("ggggg"), result);
7931
+ }
7932
+
7933
+
7685
7934
  THREADED_TEST(InterceptorCallICFastApi_TrivialSignature) {
7686
7935
  int interceptor_call_count = 0;
7687
7936
  v8::HandleScope scope;
@@ -8552,7 +8801,8 @@ void ApiTestFuzzer::Setup(PartOfTest part) {
8552
8801
  : RegisterThreadedTest::count();
8553
8802
  active_tests_ = tests_being_run_ = end - start;
8554
8803
  for (int i = 0; i < tests_being_run_; i++) {
8555
- RegisterThreadedTest::nth(i)->fuzzer_ = new ApiTestFuzzer(i + start);
8804
+ RegisterThreadedTest::nth(i)->fuzzer_ = new ApiTestFuzzer(
8805
+ i::Isolate::Current(), i + start);
8556
8806
  }
8557
8807
  for (int i = 0; i < active_tests_; i++) {
8558
8808
  RegisterThreadedTest::nth(i)->fuzzer_->Start();
@@ -8774,11 +9024,11 @@ static void CheckSurvivingGlobalObjectsCount(int expected) {
8774
9024
  // the first garbage collection but some of the maps have already
8775
9025
  // been marked at that point. Therefore some of the maps are not
8776
9026
  // collected until the second garbage collection.
8777
- i::Heap::CollectAllGarbage(false);
8778
- i::Heap::CollectAllGarbage(false);
9027
+ HEAP->CollectAllGarbage(false);
9028
+ HEAP->CollectAllGarbage(false);
8779
9029
  int count = GetGlobalObjectsCount();
8780
9030
  #ifdef DEBUG
8781
- if (count != expected) i::Heap::TracePathToGlobal();
9031
+ if (count != expected) HEAP->TracePathToGlobal();
8782
9032
  #endif
8783
9033
  CHECK_EQ(expected, count);
8784
9034
  }
@@ -8844,7 +9094,7 @@ THREADED_TEST(NewPersistentHandleFromWeakCallback) {
8844
9094
  // weak callback of the first handle would be able to 'reallocate' it.
8845
9095
  handle1.MakeWeak(NULL, NewPersistentHandleCallback);
8846
9096
  handle2.Dispose();
8847
- i::Heap::CollectAllGarbage(false);
9097
+ HEAP->CollectAllGarbage(false);
8848
9098
  }
8849
9099
 
8850
9100
 
@@ -8852,7 +9102,7 @@ v8::Persistent<v8::Object> to_be_disposed;
8852
9102
 
8853
9103
  void DisposeAndForceGcCallback(v8::Persistent<v8::Value> handle, void*) {
8854
9104
  to_be_disposed.Dispose();
8855
- i::Heap::CollectAllGarbage(false);
9105
+ HEAP->CollectAllGarbage(false);
8856
9106
  handle.Dispose();
8857
9107
  }
8858
9108
 
@@ -8868,7 +9118,7 @@ THREADED_TEST(DoNotUseDeletedNodesInSecondLevelGc) {
8868
9118
  }
8869
9119
  handle1.MakeWeak(NULL, DisposeAndForceGcCallback);
8870
9120
  to_be_disposed = handle2;
8871
- i::Heap::CollectAllGarbage(false);
9121
+ HEAP->CollectAllGarbage(false);
8872
9122
  }
8873
9123
 
8874
9124
  void DisposingCallback(v8::Persistent<v8::Value> handle, void*) {
@@ -8894,7 +9144,7 @@ THREADED_TEST(NoGlobalHandlesOrphaningDueToWeakCallback) {
8894
9144
  }
8895
9145
  handle2.MakeWeak(NULL, DisposingCallback);
8896
9146
  handle3.MakeWeak(NULL, HandleCreatingCallback);
8897
- i::Heap::CollectAllGarbage(false);
9147
+ HEAP->CollectAllGarbage(false);
8898
9148
  }
8899
9149
 
8900
9150
 
@@ -9140,6 +9390,31 @@ THREADED_TEST(PropertyEnumeration) {
9140
9390
  CheckProperties(elms->Get(v8::Integer::New(3)), elmc3, elmv3);
9141
9391
  }
9142
9392
 
9393
+ THREADED_TEST(PropertyEnumeration2) {
9394
+ v8::HandleScope scope;
9395
+ LocalContext context;
9396
+ v8::Handle<v8::Value> obj = v8::Script::Compile(v8::String::New(
9397
+ "var result = [];"
9398
+ "result[0] = {};"
9399
+ "result[1] = {a: 1, b: 2};"
9400
+ "result[2] = [1, 2, 3];"
9401
+ "var proto = {x: 1, y: 2, z: 3};"
9402
+ "var x = { __proto__: proto, w: 0, z: 1 };"
9403
+ "result[3] = x;"
9404
+ "result;"))->Run();
9405
+ v8::Handle<v8::Array> elms = obj.As<v8::Array>();
9406
+ CHECK_EQ(4, elms->Length());
9407
+ int elmc0 = 0;
9408
+ const char** elmv0 = NULL;
9409
+ CheckProperties(elms->Get(v8::Integer::New(0)), elmc0, elmv0);
9410
+
9411
+ v8::Handle<v8::Value> val = elms->Get(v8::Integer::New(0));
9412
+ v8::Handle<v8::Array> props = val.As<v8::Object>()->GetPropertyNames();
9413
+ CHECK_EQ(0, props->Length());
9414
+ for (uint32_t i = 0; i < props->Length(); i++) {
9415
+ printf("p[%d]\n", i);
9416
+ }
9417
+ }
9143
9418
 
9144
9419
  static bool NamedSetAccessBlocker(Local<v8::Object> obj,
9145
9420
  Local<Value> name,
@@ -9632,7 +9907,7 @@ class RegExpInterruptTest {
9632
9907
  gc_during_regexp_ = 0;
9633
9908
  regexp_success_ = false;
9634
9909
  gc_success_ = false;
9635
- GCThread gc_thread(this);
9910
+ GCThread gc_thread(i::Isolate::Current(), this);
9636
9911
  gc_thread.Start();
9637
9912
  v8::Locker::StartPreemption(1);
9638
9913
 
@@ -9651,8 +9926,8 @@ class RegExpInterruptTest {
9651
9926
 
9652
9927
  class GCThread : public i::Thread {
9653
9928
  public:
9654
- explicit GCThread(RegExpInterruptTest* test)
9655
- : test_(test) {}
9929
+ explicit GCThread(i::Isolate* isolate, RegExpInterruptTest* test)
9930
+ : Thread(isolate, "GCThread"), test_(test) {}
9656
9931
  virtual void Run() {
9657
9932
  test_->CollectGarbage();
9658
9933
  }
@@ -9666,7 +9941,7 @@ class RegExpInterruptTest {
9666
9941
  {
9667
9942
  v8::Locker lock;
9668
9943
  // TODO(lrn): Perhaps create some garbage before collecting.
9669
- i::Heap::CollectAllGarbage(false);
9944
+ HEAP->CollectAllGarbage(false);
9670
9945
  gc_count_++;
9671
9946
  }
9672
9947
  i::OS::Sleep(1);
@@ -9754,7 +10029,7 @@ class ApplyInterruptTest {
9754
10029
  gc_during_apply_ = 0;
9755
10030
  apply_success_ = false;
9756
10031
  gc_success_ = false;
9757
- GCThread gc_thread(this);
10032
+ GCThread gc_thread(i::Isolate::Current(), this);
9758
10033
  gc_thread.Start();
9759
10034
  v8::Locker::StartPreemption(1);
9760
10035
 
@@ -9773,8 +10048,8 @@ class ApplyInterruptTest {
9773
10048
 
9774
10049
  class GCThread : public i::Thread {
9775
10050
  public:
9776
- explicit GCThread(ApplyInterruptTest* test)
9777
- : test_(test) {}
10051
+ explicit GCThread(i::Isolate* isolate, ApplyInterruptTest* test)
10052
+ : Thread(isolate, "GCThread"), test_(test) {}
9778
10053
  virtual void Run() {
9779
10054
  test_->CollectGarbage();
9780
10055
  }
@@ -9787,7 +10062,7 @@ class ApplyInterruptTest {
9787
10062
  while (gc_during_apply_ < kRequiredGCs) {
9788
10063
  {
9789
10064
  v8::Locker lock;
9790
- i::Heap::CollectAllGarbage(false);
10065
+ HEAP->CollectAllGarbage(false);
9791
10066
  gc_count_++;
9792
10067
  }
9793
10068
  i::OS::Sleep(1);
@@ -9916,17 +10191,17 @@ static void MorphAString(i::String* string,
9916
10191
  CHECK(i::StringShape(string).IsExternal());
9917
10192
  if (string->IsAsciiRepresentation()) {
9918
10193
  // Check old map is not symbol or long.
9919
- CHECK(string->map() == i::Heap::external_ascii_string_map());
10194
+ CHECK(string->map() == HEAP->external_ascii_string_map());
9920
10195
  // Morph external string to be TwoByte string.
9921
- string->set_map(i::Heap::external_string_map());
10196
+ string->set_map(HEAP->external_string_map());
9922
10197
  i::ExternalTwoByteString* morphed =
9923
10198
  i::ExternalTwoByteString::cast(string);
9924
10199
  morphed->set_resource(uc16_resource);
9925
10200
  } else {
9926
10201
  // Check old map is not symbol or long.
9927
- CHECK(string->map() == i::Heap::external_string_map());
10202
+ CHECK(string->map() == HEAP->external_string_map());
9928
10203
  // Morph external string to be ASCII string.
9929
- string->set_map(i::Heap::external_ascii_string_map());
10204
+ string->set_map(HEAP->external_ascii_string_map());
9930
10205
  i::ExternalAsciiString* morphed =
9931
10206
  i::ExternalAsciiString::cast(string);
9932
10207
  morphed->set_resource(ascii_resource);
@@ -9950,9 +10225,9 @@ THREADED_TEST(MorphCompositeStringTest) {
9950
10225
  i::StrLength(c_string)));
9951
10226
 
9952
10227
  Local<String> lhs(v8::Utils::ToLocal(
9953
- i::Factory::NewExternalStringFromAscii(&ascii_resource)));
10228
+ FACTORY->NewExternalStringFromAscii(&ascii_resource)));
9954
10229
  Local<String> rhs(v8::Utils::ToLocal(
9955
- i::Factory::NewExternalStringFromAscii(&ascii_resource)));
10230
+ FACTORY->NewExternalStringFromAscii(&ascii_resource)));
9956
10231
 
9957
10232
  env->Global()->Set(v8_str("lhs"), lhs);
9958
10233
  env->Global()->Set(v8_str("rhs"), rhs);
@@ -10037,17 +10312,18 @@ class RegExpStringModificationTest {
10037
10312
 
10038
10313
  // Create the input string for the regexp - the one we are going to change
10039
10314
  // properties of.
10040
- input_ = i::Factory::NewExternalStringFromAscii(&ascii_resource_);
10315
+ input_ = FACTORY->NewExternalStringFromAscii(&ascii_resource_);
10041
10316
 
10042
10317
  // Inject the input as a global variable.
10043
10318
  i::Handle<i::String> input_name =
10044
- i::Factory::NewStringFromAscii(i::Vector<const char>("input", 5));
10045
- i::Top::global_context()->global()->SetProperty(*input_name,
10046
- *input_,
10047
- NONE)->ToObjectChecked();
10048
-
10049
-
10050
- MorphThread morph_thread(this);
10319
+ FACTORY->NewStringFromAscii(i::Vector<const char>("input", 5));
10320
+ i::Isolate::Current()->global_context()->global()->SetProperty(
10321
+ *input_name,
10322
+ *input_,
10323
+ NONE,
10324
+ i::kNonStrictMode)->ToObjectChecked();
10325
+
10326
+ MorphThread morph_thread(i::Isolate::Current(), this);
10051
10327
  morph_thread.Start();
10052
10328
  v8::Locker::StartPreemption(1);
10053
10329
  LongRunningRegExp();
@@ -10067,8 +10343,9 @@ class RegExpStringModificationTest {
10067
10343
 
10068
10344
  class MorphThread : public i::Thread {
10069
10345
  public:
10070
- explicit MorphThread(RegExpStringModificationTest* test)
10071
- : test_(test) {}
10346
+ explicit MorphThread(i::Isolate* isolate,
10347
+ RegExpStringModificationTest* test)
10348
+ : Thread(isolate, "MorphThread"), test_(test) {}
10072
10349
  virtual void Run() {
10073
10350
  test_->MorphString();
10074
10351
  }
@@ -10499,13 +10776,16 @@ THREADED_TEST(PixelArray) {
10499
10776
  LocalContext context;
10500
10777
  const int kElementCount = 260;
10501
10778
  uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(kElementCount));
10502
- i::Handle<i::PixelArray> pixels = i::Factory::NewPixelArray(kElementCount,
10503
- pixel_data);
10504
- i::Heap::CollectAllGarbage(false); // Force GC to trigger verification.
10779
+ i::Handle<i::ExternalPixelArray> pixels =
10780
+ i::Handle<i::ExternalPixelArray>::cast(
10781
+ FACTORY->NewExternalArray(kElementCount,
10782
+ v8::kExternalPixelArray,
10783
+ pixel_data));
10784
+ HEAP->CollectAllGarbage(false); // Force GC to trigger verification.
10505
10785
  for (int i = 0; i < kElementCount; i++) {
10506
10786
  pixels->set(i, i % 256);
10507
10787
  }
10508
- i::Heap::CollectAllGarbage(false); // Force GC to trigger verification.
10788
+ HEAP->CollectAllGarbage(false); // Force GC to trigger verification.
10509
10789
  for (int i = 0; i < kElementCount; i++) {
10510
10790
  CHECK_EQ(i % 256, pixels->get(i));
10511
10791
  CHECK_EQ(i % 256, pixel_data[i]);
@@ -10567,14 +10847,14 @@ THREADED_TEST(PixelArray) {
10567
10847
  CHECK_EQ(28, result->Int32Value());
10568
10848
 
10569
10849
  i::Handle<i::Smi> value(i::Smi::FromInt(2));
10570
- i::SetElement(jsobj, 1, value);
10850
+ i::SetElement(jsobj, 1, value, i::kNonStrictMode);
10571
10851
  CHECK_EQ(2, i::Smi::cast(jsobj->GetElement(1)->ToObjectChecked())->value());
10572
10852
  *value.location() = i::Smi::FromInt(256);
10573
- i::SetElement(jsobj, 1, value);
10853
+ i::SetElement(jsobj, 1, value, i::kNonStrictMode);
10574
10854
  CHECK_EQ(255,
10575
10855
  i::Smi::cast(jsobj->GetElement(1)->ToObjectChecked())->value());
10576
10856
  *value.location() = i::Smi::FromInt(-1);
10577
- i::SetElement(jsobj, 1, value);
10857
+ i::SetElement(jsobj, 1, value, i::kNonStrictMode);
10578
10858
  CHECK_EQ(0, i::Smi::cast(jsobj->GetElement(1)->ToObjectChecked())->value());
10579
10859
 
10580
10860
  result = CompileRun("for (var i = 0; i < 8; i++) {"
@@ -10840,7 +11120,7 @@ THREADED_TEST(PixelArray) {
10840
11120
  " return sum; "
10841
11121
  "}"
10842
11122
  "for (var i = 0; i < 256; ++i) { pixels[i] = i; }"
10843
- "for (var i = 0; i < 10000; ++i) {"
11123
+ "for (var i = 0; i < 5000; ++i) {"
10844
11124
  " result = pa_load(pixels);"
10845
11125
  "}"
10846
11126
  "result");
@@ -10857,7 +11137,7 @@ THREADED_TEST(PixelArray) {
10857
11137
  " }"
10858
11138
  " return sum; "
10859
11139
  "}"
10860
- "for (var i = 0; i < 100000; ++i) {"
11140
+ "for (var i = 0; i < 5000; ++i) {"
10861
11141
  " pa_init(pixels);"
10862
11142
  "}"
10863
11143
  "result = pa_load(pixels);"
@@ -10905,8 +11185,11 @@ THREADED_TEST(PixelArrayWithInterceptor) {
10905
11185
  LocalContext context;
10906
11186
  const int kElementCount = 260;
10907
11187
  uint8_t* pixel_data = reinterpret_cast<uint8_t*>(malloc(kElementCount));
10908
- i::Handle<i::PixelArray> pixels =
10909
- i::Factory::NewPixelArray(kElementCount, pixel_data);
11188
+ i::Handle<i::ExternalPixelArray> pixels =
11189
+ i::Handle<i::ExternalPixelArray>::cast(
11190
+ FACTORY->NewExternalArray(kElementCount,
11191
+ v8::kExternalPixelArray,
11192
+ pixel_data));
10910
11193
  for (int i = 0; i < kElementCount; i++) {
10911
11194
  pixels->set(i, i % 256);
10912
11195
  }
@@ -10934,6 +11217,7 @@ static int ExternalArrayElementSize(v8::ExternalArrayType array_type) {
10934
11217
  switch (array_type) {
10935
11218
  case v8::kExternalByteArray:
10936
11219
  case v8::kExternalUnsignedByteArray:
11220
+ case v8::kExternalPixelArray:
10937
11221
  return 1;
10938
11222
  break;
10939
11223
  case v8::kExternalShortArray:
@@ -10966,12 +11250,12 @@ static void ExternalArrayTestHelper(v8::ExternalArrayType array_type,
10966
11250
  static_cast<ElementType*>(malloc(kElementCount * element_size));
10967
11251
  i::Handle<ExternalArrayClass> array =
10968
11252
  i::Handle<ExternalArrayClass>::cast(
10969
- i::Factory::NewExternalArray(kElementCount, array_type, array_data));
10970
- i::Heap::CollectAllGarbage(false); // Force GC to trigger verification.
11253
+ FACTORY->NewExternalArray(kElementCount, array_type, array_data));
11254
+ HEAP->CollectAllGarbage(false); // Force GC to trigger verification.
10971
11255
  for (int i = 0; i < kElementCount; i++) {
10972
11256
  array->set(i, static_cast<ElementType>(i));
10973
11257
  }
10974
- i::Heap::CollectAllGarbage(false); // Force GC to trigger verification.
11258
+ HEAP->CollectAllGarbage(false); // Force GC to trigger verification.
10975
11259
  for (int i = 0; i < kElementCount; i++) {
10976
11260
  CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(array->get(i)));
10977
11261
  CHECK_EQ(static_cast<int64_t>(i), static_cast<int64_t>(array_data[i]));
@@ -11088,7 +11372,7 @@ static void ExternalArrayTestHelper(v8::ExternalArrayType array_type,
11088
11372
  " }"
11089
11373
  "}"
11090
11374
  "sum;");
11091
- i::Heap::CollectAllGarbage(false); // Force GC to trigger verification.
11375
+ HEAP->CollectAllGarbage(false); // Force GC to trigger verification.
11092
11376
  CHECK_EQ(28, result->Int32Value());
11093
11377
 
11094
11378
  // Make sure out-of-range loads do not throw.
@@ -11155,8 +11439,10 @@ static void ExternalArrayTestHelper(v8::ExternalArrayType array_type,
11155
11439
  " ext_array[i] = Infinity;"
11156
11440
  "}"
11157
11441
  "ext_array[5];");
11158
- CHECK_EQ(0, result->Int32Value());
11159
- CHECK_EQ(0,
11442
+ int expected_value =
11443
+ (array_type == v8::kExternalPixelArray) ? 255 : 0;
11444
+ CHECK_EQ(expected_value, result->Int32Value());
11445
+ CHECK_EQ(expected_value,
11160
11446
  i::Smi::cast(jsobj->GetElement(5)->ToObjectChecked())->value());
11161
11447
 
11162
11448
  result = CompileRun("for (var i = 0; i < 8; i++) {"
@@ -11177,10 +11463,14 @@ static void ExternalArrayTestHelper(v8::ExternalArrayType array_type,
11177
11463
  const char* signed_data =
11178
11464
  "var source_data = [0.6, 10.6, -0.6, -10.6];"
11179
11465
  "var expected_results = [0, 10, 0, -10];";
11466
+ const char* pixel_data =
11467
+ "var source_data = [0.6, 10.6];"
11468
+ "var expected_results = [1, 11];";
11180
11469
  bool is_unsigned =
11181
11470
  (array_type == v8::kExternalUnsignedByteArray ||
11182
11471
  array_type == v8::kExternalUnsignedShortArray ||
11183
11472
  array_type == v8::kExternalUnsignedIntArray);
11473
+ bool is_pixel_data = array_type == v8::kExternalPixelArray;
11184
11474
 
11185
11475
  i::OS::SNPrintF(test_buf,
11186
11476
  "%s"
@@ -11193,11 +11483,42 @@ static void ExternalArrayTestHelper(v8::ExternalArrayType array_type,
11193
11483
  " (ext_array[5] == expected_results[i]);"
11194
11484
  "}"
11195
11485
  "all_passed;",
11196
- (is_unsigned ? unsigned_data : signed_data));
11486
+ (is_unsigned ?
11487
+ unsigned_data :
11488
+ (is_pixel_data ? pixel_data : signed_data)));
11197
11489
  result = CompileRun(test_buf.start());
11198
11490
  CHECK_EQ(true, result->BooleanValue());
11199
11491
  }
11200
11492
 
11493
+ // Test crankshaft external array loads
11494
+ for (int i = 0; i < kElementCount; i++) {
11495
+ array->set(i, static_cast<ElementType>(i));
11496
+ }
11497
+ result = CompileRun("function ee_load_test_func(sum) {"
11498
+ " for (var i=0;i<40;++i)"
11499
+ " sum += ext_array[i];"
11500
+ " return sum;"
11501
+ "}"
11502
+ "sum=0;"
11503
+ "for (var i=0;i<10000;++i) {"
11504
+ " sum=ee_load_test_func(sum);"
11505
+ "}"
11506
+ "sum;");
11507
+ CHECK_EQ(7800000, result->Int32Value());
11508
+
11509
+ // Test crankshaft external array stores
11510
+ result = CompileRun("function ee_store_test_func(sum) {"
11511
+ " for (var i=0;i<40;++i)"
11512
+ " sum += ext_array[i] = i;"
11513
+ " return sum;"
11514
+ "}"
11515
+ "sum=0;"
11516
+ "for (var i=0;i<10000;++i) {"
11517
+ " sum=ee_store_test_func(sum);"
11518
+ "}"
11519
+ "sum;");
11520
+ CHECK_EQ(7800000, result->Int32Value());
11521
+
11201
11522
  result = CompileRun("ext_array[3] = 33;"
11202
11523
  "delete ext_array[3];"
11203
11524
  "ext_array[3];");
@@ -11237,7 +11558,7 @@ static void ExternalArrayTestHelper(v8::ExternalArrayType array_type,
11237
11558
  static_cast<ElementType*>(malloc(kLargeElementCount * element_size));
11238
11559
  i::Handle<ExternalArrayClass> large_array =
11239
11560
  i::Handle<ExternalArrayClass>::cast(
11240
- i::Factory::NewExternalArray(kLargeElementCount,
11561
+ FACTORY->NewExternalArray(kLargeElementCount,
11241
11562
  array_type,
11242
11563
  array_data));
11243
11564
  v8::Handle<v8::Object> large_obj = v8::Object::New();
@@ -11304,6 +11625,95 @@ static void ExternalArrayTestHelper(v8::ExternalArrayType array_type,
11304
11625
  free(large_array_data);
11305
11626
  }
11306
11627
 
11628
+ // The "" property descriptor is overloaded to store information about
11629
+ // the external array. Ensure that setting and accessing the "" property
11630
+ // works (it should overwrite the information cached about the external
11631
+ // array in the DescriptorArray) in various situations.
11632
+ result = CompileRun("ext_array[''] = 23; ext_array['']");
11633
+ CHECK_EQ(23, result->Int32Value());
11634
+
11635
+ // Property "" set after the external array is associated with the object.
11636
+ {
11637
+ v8::Handle<v8::Object> obj2 = v8::Object::New();
11638
+ obj2->Set(v8_str("ee_test_field"), v8::Int32::New(256));
11639
+ obj2->Set(v8_str(""), v8::Int32::New(1503));
11640
+ // Set the elements to be the external array.
11641
+ obj2->SetIndexedPropertiesToExternalArrayData(array_data,
11642
+ array_type,
11643
+ kElementCount);
11644
+ context->Global()->Set(v8_str("ext_array"), obj2);
11645
+ result = CompileRun("ext_array['']");
11646
+ CHECK_EQ(1503, result->Int32Value());
11647
+ }
11648
+
11649
+ // Property "" set after the external array is associated with the object.
11650
+ {
11651
+ v8::Handle<v8::Object> obj2 = v8::Object::New();
11652
+ obj2->Set(v8_str("ee_test_field_2"), v8::Int32::New(256));
11653
+ // Set the elements to be the external array.
11654
+ obj2->SetIndexedPropertiesToExternalArrayData(array_data,
11655
+ array_type,
11656
+ kElementCount);
11657
+ obj2->Set(v8_str(""), v8::Int32::New(1503));
11658
+ context->Global()->Set(v8_str("ext_array"), obj2);
11659
+ result = CompileRun("ext_array['']");
11660
+ CHECK_EQ(1503, result->Int32Value());
11661
+ }
11662
+
11663
+ // Should reuse the map from previous test.
11664
+ {
11665
+ v8::Handle<v8::Object> obj2 = v8::Object::New();
11666
+ obj2->Set(v8_str("ee_test_field_2"), v8::Int32::New(256));
11667
+ // Set the elements to be the external array. Should re-use the map
11668
+ // from previous test.
11669
+ obj2->SetIndexedPropertiesToExternalArrayData(array_data,
11670
+ array_type,
11671
+ kElementCount);
11672
+ context->Global()->Set(v8_str("ext_array"), obj2);
11673
+ result = CompileRun("ext_array['']");
11674
+ }
11675
+
11676
+ // Property "" is a constant function that shouldn't not be interfered with
11677
+ // when an external array is set.
11678
+ {
11679
+ v8::Handle<v8::Object> obj2 = v8::Object::New();
11680
+ // Start
11681
+ obj2->Set(v8_str("ee_test_field3"), v8::Int32::New(256));
11682
+
11683
+ // Add a constant function to an object.
11684
+ context->Global()->Set(v8_str("ext_array"), obj2);
11685
+ result = CompileRun("ext_array[''] = function() {return 1503;};"
11686
+ "ext_array['']();");
11687
+
11688
+ // Add an external array transition to the same map that
11689
+ // has the constant transition.
11690
+ v8::Handle<v8::Object> obj3 = v8::Object::New();
11691
+ obj3->Set(v8_str("ee_test_field3"), v8::Int32::New(256));
11692
+ obj3->SetIndexedPropertiesToExternalArrayData(array_data,
11693
+ array_type,
11694
+ kElementCount);
11695
+ context->Global()->Set(v8_str("ext_array"), obj3);
11696
+ }
11697
+
11698
+ // If a external array transition is in the map, it should get clobbered
11699
+ // by a constant function.
11700
+ {
11701
+ // Add an external array transition.
11702
+ v8::Handle<v8::Object> obj3 = v8::Object::New();
11703
+ obj3->Set(v8_str("ee_test_field4"), v8::Int32::New(256));
11704
+ obj3->SetIndexedPropertiesToExternalArrayData(array_data,
11705
+ array_type,
11706
+ kElementCount);
11707
+
11708
+ // Add a constant function to the same map that just got an external array
11709
+ // transition.
11710
+ v8::Handle<v8::Object> obj2 = v8::Object::New();
11711
+ obj2->Set(v8_str("ee_test_field4"), v8::Int32::New(256));
11712
+ context->Global()->Set(v8_str("ext_array"), obj2);
11713
+ result = CompileRun("ext_array[''] = function() {return 1503;};"
11714
+ "ext_array['']();");
11715
+ }
11716
+
11307
11717
  free(array_data);
11308
11718
  }
11309
11719
 
@@ -11324,6 +11734,14 @@ THREADED_TEST(ExternalUnsignedByteArray) {
11324
11734
  }
11325
11735
 
11326
11736
 
11737
+ THREADED_TEST(ExternalPixelArray) {
11738
+ ExternalArrayTestHelper<i::ExternalPixelArray, uint8_t>(
11739
+ v8::kExternalPixelArray,
11740
+ 0,
11741
+ 255);
11742
+ }
11743
+
11744
+
11327
11745
  THREADED_TEST(ExternalShortArray) {
11328
11746
  ExternalArrayTestHelper<i::ExternalShortArray, int16_t>(
11329
11747
  v8::kExternalShortArray,
@@ -11401,6 +11819,7 @@ THREADED_TEST(ExternalArrayInfo) {
11401
11819
  ExternalArrayInfoTestHelper(v8::kExternalIntArray);
11402
11820
  ExternalArrayInfoTestHelper(v8::kExternalUnsignedIntArray);
11403
11821
  ExternalArrayInfoTestHelper(v8::kExternalFloatArray);
11822
+ ExternalArrayInfoTestHelper(v8::kExternalPixelArray);
11404
11823
  }
11405
11824
 
11406
11825
 
@@ -11664,7 +12083,8 @@ THREADED_TEST(IdleNotification) {
11664
12083
  static uint32_t* stack_limit;
11665
12084
 
11666
12085
  static v8::Handle<Value> GetStackLimitCallback(const v8::Arguments& args) {
11667
- stack_limit = reinterpret_cast<uint32_t*>(i::StackGuard::real_climit());
12086
+ stack_limit = reinterpret_cast<uint32_t*>(
12087
+ i::Isolate::Current()->stack_guard()->real_climit());
11668
12088
  return v8::Undefined();
11669
12089
  }
11670
12090
 
@@ -11930,7 +12350,7 @@ TEST(Regress528) {
11930
12350
  other_context->Enter();
11931
12351
  CompileRun(source_simple);
11932
12352
  other_context->Exit();
11933
- i::Heap::CollectAllGarbage(false);
12353
+ HEAP->CollectAllGarbage(false);
11934
12354
  if (GetGlobalObjectsCount() == 1) break;
11935
12355
  }
11936
12356
  CHECK_GE(2, gc_count);
@@ -11952,7 +12372,7 @@ TEST(Regress528) {
11952
12372
  other_context->Enter();
11953
12373
  CompileRun(source_eval);
11954
12374
  other_context->Exit();
11955
- i::Heap::CollectAllGarbage(false);
12375
+ HEAP->CollectAllGarbage(false);
11956
12376
  if (GetGlobalObjectsCount() == 1) break;
11957
12377
  }
11958
12378
  CHECK_GE(2, gc_count);
@@ -11979,7 +12399,7 @@ TEST(Regress528) {
11979
12399
  other_context->Enter();
11980
12400
  CompileRun(source_exception);
11981
12401
  other_context->Exit();
11982
- i::Heap::CollectAllGarbage(false);
12402
+ HEAP->CollectAllGarbage(false);
11983
12403
  if (GetGlobalObjectsCount() == 1) break;
11984
12404
  }
11985
12405
  CHECK_GE(2, gc_count);
@@ -12197,26 +12617,26 @@ TEST(GCCallbacks) {
12197
12617
  v8::V8::AddGCEpilogueCallback(EpilogueCallback);
12198
12618
  CHECK_EQ(0, prologue_call_count);
12199
12619
  CHECK_EQ(0, epilogue_call_count);
12200
- i::Heap::CollectAllGarbage(false);
12620
+ HEAP->CollectAllGarbage(false);
12201
12621
  CHECK_EQ(1, prologue_call_count);
12202
12622
  CHECK_EQ(1, epilogue_call_count);
12203
12623
  v8::V8::AddGCPrologueCallback(PrologueCallbackSecond);
12204
12624
  v8::V8::AddGCEpilogueCallback(EpilogueCallbackSecond);
12205
- i::Heap::CollectAllGarbage(false);
12625
+ HEAP->CollectAllGarbage(false);
12206
12626
  CHECK_EQ(2, prologue_call_count);
12207
12627
  CHECK_EQ(2, epilogue_call_count);
12208
12628
  CHECK_EQ(1, prologue_call_count_second);
12209
12629
  CHECK_EQ(1, epilogue_call_count_second);
12210
12630
  v8::V8::RemoveGCPrologueCallback(PrologueCallback);
12211
12631
  v8::V8::RemoveGCEpilogueCallback(EpilogueCallback);
12212
- i::Heap::CollectAllGarbage(false);
12632
+ HEAP->CollectAllGarbage(false);
12213
12633
  CHECK_EQ(2, prologue_call_count);
12214
12634
  CHECK_EQ(2, epilogue_call_count);
12215
12635
  CHECK_EQ(2, prologue_call_count_second);
12216
12636
  CHECK_EQ(2, epilogue_call_count_second);
12217
12637
  v8::V8::RemoveGCPrologueCallback(PrologueCallbackSecond);
12218
12638
  v8::V8::RemoveGCEpilogueCallback(EpilogueCallbackSecond);
12219
- i::Heap::CollectAllGarbage(false);
12639
+ HEAP->CollectAllGarbage(false);
12220
12640
  CHECK_EQ(2, prologue_call_count);
12221
12641
  CHECK_EQ(2, epilogue_call_count);
12222
12642
  CHECK_EQ(2, prologue_call_count_second);
@@ -12244,7 +12664,7 @@ THREADED_TEST(AddToJSFunctionResultCache) {
12244
12664
  " return 'Different results for ' + key1 + ': ' + r1 + ' vs. ' + r1_;"
12245
12665
  " return 'PASSED';"
12246
12666
  "})()";
12247
- i::Heap::ClearJSFunctionResultCaches();
12667
+ HEAP->ClearJSFunctionResultCaches();
12248
12668
  ExpectString(code, "PASSED");
12249
12669
  }
12250
12670
 
@@ -12268,7 +12688,7 @@ THREADED_TEST(FillJSFunctionResultCache) {
12268
12688
  " return 'FAILED: k0CacheSize is too small';"
12269
12689
  " return 'PASSED';"
12270
12690
  "})()";
12271
- i::Heap::ClearJSFunctionResultCaches();
12691
+ HEAP->ClearJSFunctionResultCaches();
12272
12692
  ExpectString(code, "PASSED");
12273
12693
  }
12274
12694
 
@@ -12293,7 +12713,7 @@ THREADED_TEST(RoundRobinGetFromCache) {
12293
12713
  " };"
12294
12714
  " return 'PASSED';"
12295
12715
  "})()";
12296
- i::Heap::ClearJSFunctionResultCaches();
12716
+ HEAP->ClearJSFunctionResultCaches();
12297
12717
  ExpectString(code, "PASSED");
12298
12718
  }
12299
12719
 
@@ -12318,7 +12738,7 @@ THREADED_TEST(ReverseGetFromCache) {
12318
12738
  " };"
12319
12739
  " return 'PASSED';"
12320
12740
  "})()";
12321
- i::Heap::ClearJSFunctionResultCaches();
12741
+ HEAP->ClearJSFunctionResultCaches();
12322
12742
  ExpectString(code, "PASSED");
12323
12743
  }
12324
12744
 
@@ -12336,7 +12756,7 @@ THREADED_TEST(TestEviction) {
12336
12756
  " };"
12337
12757
  " return 'PASSED';"
12338
12758
  "})()";
12339
- i::Heap::ClearJSFunctionResultCaches();
12759
+ HEAP->ClearJSFunctionResultCaches();
12340
12760
  ExpectString(code, "PASSED");
12341
12761
  }
12342
12762
 
@@ -12426,7 +12846,7 @@ THREADED_TEST(TwoByteStringInAsciiCons) {
12426
12846
  void FailedAccessCheckCallbackGC(Local<v8::Object> target,
12427
12847
  v8::AccessType type,
12428
12848
  Local<v8::Value> data) {
12429
- i::Heap::CollectAllGarbage(true);
12849
+ HEAP->CollectAllGarbage(true);
12430
12850
  }
12431
12851
 
12432
12852
 
@@ -12507,6 +12927,374 @@ TEST(GCInFailedAccessCheckCallback) {
12507
12927
  v8::V8::SetFailedAccessCheckCallbackFunction(NULL);
12508
12928
  }
12509
12929
 
12930
+ TEST(DefaultIsolateGetCurrent) {
12931
+ CHECK(v8::Isolate::GetCurrent() != NULL);
12932
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
12933
+ CHECK(reinterpret_cast<i::Isolate*>(isolate)->IsDefaultIsolate());
12934
+ printf("*** %s\n", "DefaultIsolateGetCurrent success");
12935
+ }
12936
+
12937
+ TEST(IsolateNewDispose) {
12938
+ v8::Isolate* current_isolate = v8::Isolate::GetCurrent();
12939
+ v8::Isolate* isolate = v8::Isolate::New();
12940
+ CHECK(isolate != NULL);
12941
+ CHECK(!reinterpret_cast<i::Isolate*>(isolate)->IsDefaultIsolate());
12942
+ CHECK(current_isolate != isolate);
12943
+ CHECK(current_isolate == v8::Isolate::GetCurrent());
12944
+
12945
+ v8::V8::SetFatalErrorHandler(StoringErrorCallback);
12946
+ last_location = last_message = NULL;
12947
+ isolate->Dispose();
12948
+ CHECK_EQ(last_location, NULL);
12949
+ CHECK_EQ(last_message, NULL);
12950
+ }
12951
+
12952
+ TEST(IsolateEnterExitDefault) {
12953
+ v8::HandleScope scope;
12954
+ LocalContext context;
12955
+ v8::Isolate* current_isolate = v8::Isolate::GetCurrent();
12956
+ CHECK(current_isolate != NULL); // Default isolate.
12957
+ ExpectString("'hello'", "hello");
12958
+ current_isolate->Enter();
12959
+ ExpectString("'still working'", "still working");
12960
+ current_isolate->Exit();
12961
+ ExpectString("'still working 2'", "still working 2");
12962
+ current_isolate->Exit();
12963
+ // Default isolate is always, well, 'default current'.
12964
+ CHECK_EQ(v8::Isolate::GetCurrent(), current_isolate);
12965
+ // Still working since default isolate is auto-entering any thread
12966
+ // that has no isolate and attempts to execute V8 APIs.
12967
+ ExpectString("'still working 3'", "still working 3");
12968
+ }
12969
+
12970
+ TEST(DisposeDefaultIsolate) {
12971
+ v8::V8::SetFatalErrorHandler(StoringErrorCallback);
12972
+
12973
+ // Run some V8 code to trigger default isolate to become 'current'.
12974
+ v8::HandleScope scope;
12975
+ LocalContext context;
12976
+ ExpectString("'run some V8'", "run some V8");
12977
+
12978
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
12979
+ CHECK(reinterpret_cast<i::Isolate*>(isolate)->IsDefaultIsolate());
12980
+ last_location = last_message = NULL;
12981
+ isolate->Dispose();
12982
+ // It is not possible to dispose default isolate via Isolate API.
12983
+ CHECK_NE(last_location, NULL);
12984
+ CHECK_NE(last_message, NULL);
12985
+ }
12986
+
12987
+ TEST(RunDefaultAndAnotherIsolate) {
12988
+ v8::HandleScope scope;
12989
+ LocalContext context;
12990
+
12991
+ // Enter new isolate.
12992
+ v8::Isolate* isolate = v8::Isolate::New();
12993
+ CHECK(isolate);
12994
+ isolate->Enter();
12995
+ { // Need this block because subsequent Exit() will deallocate Heap,
12996
+ // so we need all scope objects to be deconstructed when it happens.
12997
+ v8::HandleScope scope_new;
12998
+ LocalContext context_new;
12999
+
13000
+ // Run something in new isolate.
13001
+ CompileRun("var foo = 153;");
13002
+ ExpectTrue("function f() { return foo == 153; }; f()");
13003
+ }
13004
+ isolate->Exit();
13005
+
13006
+ // This runs automatically in default isolate.
13007
+ // Variables in another isolate should be not available.
13008
+ ExpectTrue("function f() {"
13009
+ " try {"
13010
+ " foo;"
13011
+ " return false;"
13012
+ " } catch(e) {"
13013
+ " return true;"
13014
+ " }"
13015
+ "};"
13016
+ "var bar = 371;"
13017
+ "f()");
13018
+
13019
+ v8::V8::SetFatalErrorHandler(StoringErrorCallback);
13020
+ last_location = last_message = NULL;
13021
+ isolate->Dispose();
13022
+ CHECK_EQ(last_location, NULL);
13023
+ CHECK_EQ(last_message, NULL);
13024
+
13025
+ // Check that default isolate still runs.
13026
+ ExpectTrue("function f() { return bar == 371; }; f()");
13027
+ }
13028
+
13029
+ TEST(DisposeIsolateWhenInUse) {
13030
+ v8::Isolate* isolate = v8::Isolate::New();
13031
+ CHECK(isolate);
13032
+ isolate->Enter();
13033
+ v8::HandleScope scope;
13034
+ LocalContext context;
13035
+ // Run something in this isolate.
13036
+ ExpectTrue("true");
13037
+ v8::V8::SetFatalErrorHandler(StoringErrorCallback);
13038
+ last_location = last_message = NULL;
13039
+ // Still entered, should fail.
13040
+ isolate->Dispose();
13041
+ CHECK_NE(last_location, NULL);
13042
+ CHECK_NE(last_message, NULL);
13043
+ }
13044
+
13045
+ TEST(RunTwoIsolatesOnSingleThread) {
13046
+ // Run isolate 1.
13047
+ v8::Isolate* isolate1 = v8::Isolate::New();
13048
+ isolate1->Enter();
13049
+ v8::Persistent<v8::Context> context1 = v8::Context::New();
13050
+
13051
+ {
13052
+ v8::Context::Scope cscope(context1);
13053
+ v8::HandleScope scope;
13054
+ // Run something in new isolate.
13055
+ CompileRun("var foo = 'isolate 1';");
13056
+ ExpectString("function f() { return foo; }; f()", "isolate 1");
13057
+ }
13058
+
13059
+ // Run isolate 2.
13060
+ v8::Isolate* isolate2 = v8::Isolate::New();
13061
+ v8::Persistent<v8::Context> context2;
13062
+
13063
+ {
13064
+ v8::Isolate::Scope iscope(isolate2);
13065
+ context2 = v8::Context::New();
13066
+ v8::Context::Scope cscope(context2);
13067
+ v8::HandleScope scope;
13068
+
13069
+ // Run something in new isolate.
13070
+ CompileRun("var foo = 'isolate 2';");
13071
+ ExpectString("function f() { return foo; }; f()", "isolate 2");
13072
+ }
13073
+
13074
+ {
13075
+ v8::Context::Scope cscope(context1);
13076
+ v8::HandleScope scope;
13077
+ // Now again in isolate 1
13078
+ ExpectString("function f() { return foo; }; f()", "isolate 1");
13079
+ }
13080
+
13081
+ isolate1->Exit();
13082
+
13083
+ // Run some stuff in default isolate.
13084
+ v8::Persistent<v8::Context> context_default = v8::Context::New();
13085
+
13086
+ {
13087
+ v8::Context::Scope cscope(context_default);
13088
+ v8::HandleScope scope;
13089
+ // Variables in other isolates should be not available, verify there
13090
+ // is an exception.
13091
+ ExpectTrue("function f() {"
13092
+ " try {"
13093
+ " foo;"
13094
+ " return false;"
13095
+ " } catch(e) {"
13096
+ " return true;"
13097
+ " }"
13098
+ "};"
13099
+ "var isDefaultIsolate = true;"
13100
+ "f()");
13101
+ }
13102
+
13103
+ isolate1->Enter();
13104
+
13105
+ {
13106
+ v8::Isolate::Scope iscope(isolate2);
13107
+ v8::Context::Scope cscope(context2);
13108
+ v8::HandleScope scope;
13109
+ ExpectString("function f() { return foo; }; f()", "isolate 2");
13110
+ }
13111
+
13112
+ {
13113
+ v8::Context::Scope cscope(context1);
13114
+ v8::HandleScope scope;
13115
+ ExpectString("function f() { return foo; }; f()", "isolate 1");
13116
+ }
13117
+
13118
+ {
13119
+ v8::Isolate::Scope iscope(isolate2);
13120
+ context2.Dispose();
13121
+ }
13122
+
13123
+ context1.Dispose();
13124
+ isolate1->Exit();
13125
+
13126
+ v8::V8::SetFatalErrorHandler(StoringErrorCallback);
13127
+ last_location = last_message = NULL;
13128
+
13129
+ isolate1->Dispose();
13130
+ CHECK_EQ(last_location, NULL);
13131
+ CHECK_EQ(last_message, NULL);
13132
+
13133
+ isolate2->Dispose();
13134
+ CHECK_EQ(last_location, NULL);
13135
+ CHECK_EQ(last_message, NULL);
13136
+
13137
+ // Check that default isolate still runs.
13138
+ {
13139
+ v8::Context::Scope cscope(context_default);
13140
+ v8::HandleScope scope;
13141
+ ExpectTrue("function f() { return isDefaultIsolate; }; f()");
13142
+ }
13143
+ }
13144
+
13145
+ static int CalcFibonacci(v8::Isolate* isolate, int limit) {
13146
+ v8::Isolate::Scope isolate_scope(isolate);
13147
+ v8::HandleScope scope;
13148
+ LocalContext context;
13149
+ i::ScopedVector<char> code(1024);
13150
+ i::OS::SNPrintF(code, "function fib(n) {"
13151
+ " if (n <= 2) return 1;"
13152
+ " return fib(n-1) + fib(n-2);"
13153
+ "}"
13154
+ "fib(%d)", limit);
13155
+ Local<Value> value = CompileRun(code.start());
13156
+ CHECK(value->IsNumber());
13157
+ return static_cast<int>(value->NumberValue());
13158
+ }
13159
+
13160
+ class IsolateThread : public v8::internal::Thread {
13161
+ public:
13162
+ explicit IsolateThread(v8::Isolate* isolate, int fib_limit)
13163
+ : Thread(NULL, "IsolateThread"),
13164
+ isolate_(isolate),
13165
+ fib_limit_(fib_limit),
13166
+ result_(0) { }
13167
+
13168
+ void Run() {
13169
+ result_ = CalcFibonacci(isolate_, fib_limit_);
13170
+ }
13171
+
13172
+ int result() { return result_; }
13173
+
13174
+ private:
13175
+ v8::Isolate* isolate_;
13176
+ int fib_limit_;
13177
+ int result_;
13178
+ };
13179
+
13180
+ TEST(MultipleIsolatesOnIndividualThreads) {
13181
+ v8::Isolate* isolate1 = v8::Isolate::New();
13182
+ v8::Isolate* isolate2 = v8::Isolate::New();
13183
+
13184
+ IsolateThread thread1(isolate1, 21);
13185
+ IsolateThread thread2(isolate2, 12);
13186
+
13187
+ // Compute some fibonacci numbers on 3 threads in 3 isolates.
13188
+ thread1.Start();
13189
+ thread2.Start();
13190
+
13191
+ int result1 = CalcFibonacci(v8::Isolate::GetCurrent(), 21);
13192
+ int result2 = CalcFibonacci(v8::Isolate::GetCurrent(), 12);
13193
+
13194
+ thread1.Join();
13195
+ thread2.Join();
13196
+
13197
+ // Compare results. The actual fibonacci numbers for 12 and 21 are taken
13198
+ // (I'm lazy!) from http://en.wikipedia.org/wiki/Fibonacci_number
13199
+ CHECK_EQ(result1, 10946);
13200
+ CHECK_EQ(result2, 144);
13201
+ CHECK_EQ(result1, thread1.result());
13202
+ CHECK_EQ(result2, thread2.result());
13203
+
13204
+ isolate1->Dispose();
13205
+ isolate2->Dispose();
13206
+ }
13207
+
13208
+
13209
+ class InitDefaultIsolateThread : public v8::internal::Thread {
13210
+ public:
13211
+ enum TestCase {
13212
+ IgnoreOOM,
13213
+ SetResourceConstraints,
13214
+ SetFatalHandler,
13215
+ SetCounterFunction,
13216
+ SetCreateHistogramFunction,
13217
+ SetAddHistogramSampleFunction
13218
+ };
13219
+
13220
+ explicit InitDefaultIsolateThread(TestCase testCase)
13221
+ : Thread(NULL, "InitDefaultIsolateThread"),
13222
+ testCase_(testCase),
13223
+ result_(false) { }
13224
+
13225
+ void Run() {
13226
+ switch (testCase_) {
13227
+ case IgnoreOOM:
13228
+ v8::V8::IgnoreOutOfMemoryException();
13229
+ break;
13230
+
13231
+ case SetResourceConstraints: {
13232
+ static const int K = 1024;
13233
+ v8::ResourceConstraints constraints;
13234
+ constraints.set_max_young_space_size(256 * K);
13235
+ constraints.set_max_old_space_size(4 * K * K);
13236
+ v8::SetResourceConstraints(&constraints);
13237
+ break;
13238
+ }
13239
+
13240
+ case SetFatalHandler:
13241
+ v8::V8::SetFatalErrorHandler(NULL);
13242
+ break;
13243
+
13244
+ case SetCounterFunction:
13245
+ v8::V8::SetCounterFunction(NULL);
13246
+ break;
13247
+
13248
+ case SetCreateHistogramFunction:
13249
+ v8::V8::SetCreateHistogramFunction(NULL);
13250
+ break;
13251
+
13252
+ case SetAddHistogramSampleFunction:
13253
+ v8::V8::SetAddHistogramSampleFunction(NULL);
13254
+ break;
13255
+ }
13256
+ result_ = true;
13257
+ }
13258
+
13259
+ bool result() { return result_; }
13260
+
13261
+ private:
13262
+ TestCase testCase_;
13263
+ bool result_;
13264
+ };
13265
+
13266
+
13267
+ static void InitializeTestHelper(InitDefaultIsolateThread::TestCase testCase) {
13268
+ InitDefaultIsolateThread thread(testCase);
13269
+ thread.Start();
13270
+ thread.Join();
13271
+ CHECK_EQ(thread.result(), true);
13272
+ }
13273
+
13274
+ TEST(InitializeDefaultIsolateOnSecondaryThread1) {
13275
+ InitializeTestHelper(InitDefaultIsolateThread::IgnoreOOM);
13276
+ }
13277
+
13278
+ TEST(InitializeDefaultIsolateOnSecondaryThread2) {
13279
+ InitializeTestHelper(InitDefaultIsolateThread::SetResourceConstraints);
13280
+ }
13281
+
13282
+ TEST(InitializeDefaultIsolateOnSecondaryThread3) {
13283
+ InitializeTestHelper(InitDefaultIsolateThread::SetFatalHandler);
13284
+ }
13285
+
13286
+ TEST(InitializeDefaultIsolateOnSecondaryThread4) {
13287
+ InitializeTestHelper(InitDefaultIsolateThread::SetCounterFunction);
13288
+ }
13289
+
13290
+ TEST(InitializeDefaultIsolateOnSecondaryThread5) {
13291
+ InitializeTestHelper(InitDefaultIsolateThread::SetCreateHistogramFunction);
13292
+ }
13293
+
13294
+ TEST(InitializeDefaultIsolateOnSecondaryThread6) {
13295
+ InitializeTestHelper(InitDefaultIsolateThread::SetAddHistogramSampleFunction);
13296
+ }
13297
+
12510
13298
 
12511
13299
  TEST(StringCheckMultipleContexts) {
12512
13300
  const char* code =
@@ -12610,7 +13398,7 @@ TEST(DontDeleteCellLoadIC) {
12610
13398
  "})()",
12611
13399
  "ReferenceError: cell is not defined");
12612
13400
  CompileRun("cell = \"new_second\";");
12613
- i::Heap::CollectAllGarbage(true);
13401
+ HEAP->CollectAllGarbage(true);
12614
13402
  ExpectString("readCell()", "new_second");
12615
13403
  ExpectString("readCell()", "new_second");
12616
13404
  }
@@ -12841,3 +13629,102 @@ TEST(DefinePropertyPostDetach) {
12841
13629
  context->DetachGlobal();
12842
13630
  define_property->Call(proxy, 0, NULL);
12843
13631
  }
13632
+
13633
+
13634
+ static void InstallContextId(v8::Handle<Context> context, int id) {
13635
+ Context::Scope scope(context);
13636
+ CompileRun("Object.prototype").As<Object>()->
13637
+ Set(v8_str("context_id"), v8::Integer::New(id));
13638
+ }
13639
+
13640
+
13641
+ static void CheckContextId(v8::Handle<Object> object, int expected) {
13642
+ CHECK_EQ(expected, object->Get(v8_str("context_id"))->Int32Value());
13643
+ }
13644
+
13645
+
13646
+ THREADED_TEST(CreationContext) {
13647
+ HandleScope handle_scope;
13648
+ Persistent<Context> context1 = Context::New();
13649
+ InstallContextId(context1, 1);
13650
+ Persistent<Context> context2 = Context::New();
13651
+ InstallContextId(context2, 2);
13652
+ Persistent<Context> context3 = Context::New();
13653
+ InstallContextId(context3, 3);
13654
+
13655
+ Local<v8::FunctionTemplate> tmpl = v8::FunctionTemplate::New();
13656
+
13657
+ Local<Object> object1;
13658
+ Local<Function> func1;
13659
+ {
13660
+ Context::Scope scope(context1);
13661
+ object1 = Object::New();
13662
+ func1 = tmpl->GetFunction();
13663
+ }
13664
+
13665
+ Local<Object> object2;
13666
+ Local<Function> func2;
13667
+ {
13668
+ Context::Scope scope(context2);
13669
+ object2 = Object::New();
13670
+ func2 = tmpl->GetFunction();
13671
+ }
13672
+
13673
+ Local<Object> instance1;
13674
+ Local<Object> instance2;
13675
+
13676
+ {
13677
+ Context::Scope scope(context3);
13678
+ instance1 = func1->NewInstance();
13679
+ instance2 = func2->NewInstance();
13680
+ }
13681
+
13682
+ CHECK(object1->CreationContext() == context1);
13683
+ CheckContextId(object1, 1);
13684
+ CHECK(func1->CreationContext() == context1);
13685
+ CheckContextId(func1, 1);
13686
+ CHECK(instance1->CreationContext() == context1);
13687
+ CheckContextId(instance1, 1);
13688
+ CHECK(object2->CreationContext() == context2);
13689
+ CheckContextId(object2, 2);
13690
+ CHECK(func2->CreationContext() == context2);
13691
+ CheckContextId(func2, 2);
13692
+ CHECK(instance2->CreationContext() == context2);
13693
+ CheckContextId(instance2, 2);
13694
+
13695
+ {
13696
+ Context::Scope scope(context1);
13697
+ CHECK(object1->CreationContext() == context1);
13698
+ CheckContextId(object1, 1);
13699
+ CHECK(func1->CreationContext() == context1);
13700
+ CheckContextId(func1, 1);
13701
+ CHECK(instance1->CreationContext() == context1);
13702
+ CheckContextId(instance1, 1);
13703
+ CHECK(object2->CreationContext() == context2);
13704
+ CheckContextId(object2, 2);
13705
+ CHECK(func2->CreationContext() == context2);
13706
+ CheckContextId(func2, 2);
13707
+ CHECK(instance2->CreationContext() == context2);
13708
+ CheckContextId(instance2, 2);
13709
+ }
13710
+
13711
+ {
13712
+ Context::Scope scope(context2);
13713
+ CHECK(object1->CreationContext() == context1);
13714
+ CheckContextId(object1, 1);
13715
+ CHECK(func1->CreationContext() == context1);
13716
+ CheckContextId(func1, 1);
13717
+ CHECK(instance1->CreationContext() == context1);
13718
+ CheckContextId(instance1, 1);
13719
+ CHECK(object2->CreationContext() == context2);
13720
+ CheckContextId(object2, 2);
13721
+ CHECK(func2->CreationContext() == context2);
13722
+ CheckContextId(func2, 2);
13723
+ CHECK(instance2->CreationContext() == context2);
13724
+ CheckContextId(instance2, 2);
13725
+ }
13726
+
13727
+ context1.Dispose();
13728
+ context2.Dispose();
13729
+ context3.Dispose();
13730
+ }