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
@@ -88,8 +88,8 @@ void HeapObject::HeapObjectPrint(FILE* out) {
88
88
  case BYTE_ARRAY_TYPE:
89
89
  ByteArray::cast(this)->ByteArrayPrint(out);
90
90
  break;
91
- case PIXEL_ARRAY_TYPE:
92
- PixelArray::cast(this)->PixelArrayPrint(out);
91
+ case EXTERNAL_PIXEL_ARRAY_TYPE:
92
+ ExternalPixelArray::cast(this)->ExternalPixelArrayPrint(out);
93
93
  break;
94
94
  case EXTERNAL_BYTE_ARRAY_TYPE:
95
95
  ExternalByteArray::cast(this)->ExternalByteArrayPrint(out);
@@ -177,8 +177,8 @@ void ByteArray::ByteArrayPrint(FILE* out) {
177
177
  }
178
178
 
179
179
 
180
- void PixelArray::PixelArrayPrint(FILE* out) {
181
- PrintF(out, "pixel array");
180
+ void ExternalPixelArray::ExternalPixelArrayPrint(FILE* out) {
181
+ PrintF(out, "external pixel array");
182
182
  }
183
183
 
184
184
 
@@ -271,8 +271,8 @@ void JSObject::PrintElements(FILE* out) {
271
271
  }
272
272
  break;
273
273
  }
274
- case PIXEL_ELEMENTS: {
275
- PixelArray* p = PixelArray::cast(elements());
274
+ case EXTERNAL_PIXEL_ELEMENTS: {
275
+ ExternalPixelArray* p = ExternalPixelArray::cast(elements());
276
276
  for (int i = 0; i < p->length(); i++) {
277
277
  PrintF(out, " %d: %d\n", i, p->get(i));
278
278
  }
@@ -372,7 +372,7 @@ static const char* TypeToString(InstanceType type) {
372
372
  case EXTERNAL_STRING_TYPE: return "EXTERNAL_STRING";
373
373
  case FIXED_ARRAY_TYPE: return "FIXED_ARRAY";
374
374
  case BYTE_ARRAY_TYPE: return "BYTE_ARRAY";
375
- case PIXEL_ARRAY_TYPE: return "PIXEL_ARRAY";
375
+ case EXTERNAL_PIXEL_ARRAY_TYPE: return "EXTERNAL_PIXEL_ARRAY";
376
376
  case EXTERNAL_BYTE_ARRAY_TYPE: return "EXTERNAL_BYTE_ARRAY";
377
377
  case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE:
378
378
  return "EXTERNAL_UNSIGNED_BYTE_ARRAY";
@@ -113,7 +113,7 @@ StaticVisitorBase::VisitorId StaticVisitorBase::GetVisitorId(
113
113
  return kVisitJSFunction;
114
114
 
115
115
  case HEAP_NUMBER_TYPE:
116
- case PIXEL_ARRAY_TYPE:
116
+ case EXTERNAL_PIXEL_ARRAY_TYPE:
117
117
  case EXTERNAL_BYTE_ARRAY_TYPE:
118
118
  case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE:
119
119
  case EXTERNAL_SHORT_ARRAY_TYPE:
@@ -141,13 +141,22 @@ class StaticVisitorBase : public AllStatic {
141
141
  template<typename Callback>
142
142
  class VisitorDispatchTable {
143
143
  public:
144
+ void CopyFrom(VisitorDispatchTable* other) {
145
+ // We are not using memcpy to guarantee that during update
146
+ // every element of callbacks_ array will remain correct
147
+ // pointer (memcpy might be implemented as a byte copying loop).
148
+ for (int i = 0; i < StaticVisitorBase::kVisitorIdCount; i++) {
149
+ NoBarrier_Store(&callbacks_[i], other->callbacks_[i]);
150
+ }
151
+ }
152
+
144
153
  inline Callback GetVisitor(Map* map) {
145
- return callbacks_[map->visitor_id()];
154
+ return reinterpret_cast<Callback>(callbacks_[map->visitor_id()]);
146
155
  }
147
156
 
148
157
  void Register(StaticVisitorBase::VisitorId id, Callback callback) {
149
158
  ASSERT(id < StaticVisitorBase::kVisitorIdCount); // id is unsigned.
150
- callbacks_[id] = callback;
159
+ callbacks_[id] = reinterpret_cast<AtomicWord>(callback);
151
160
  }
152
161
 
153
162
  template<typename Visitor,
@@ -179,21 +188,22 @@ class VisitorDispatchTable {
179
188
  }
180
189
 
181
190
  private:
182
- Callback callbacks_[StaticVisitorBase::kVisitorIdCount];
191
+ AtomicWord callbacks_[StaticVisitorBase::kVisitorIdCount];
183
192
  };
184
193
 
185
194
 
186
195
  template<typename StaticVisitor>
187
196
  class BodyVisitorBase : public AllStatic {
188
197
  public:
189
- INLINE(static void IteratePointers(HeapObject* object,
198
+ INLINE(static void IteratePointers(Heap* heap,
199
+ HeapObject* object,
190
200
  int start_offset,
191
201
  int end_offset)) {
192
202
  Object** start_slot = reinterpret_cast<Object**>(object->address() +
193
203
  start_offset);
194
204
  Object** end_slot = reinterpret_cast<Object**>(object->address() +
195
205
  end_offset);
196
- StaticVisitor::VisitPointers(start_slot, end_slot);
206
+ StaticVisitor::VisitPointers(heap, start_slot, end_slot);
197
207
  }
198
208
  };
199
209
 
@@ -204,7 +214,10 @@ class FlexibleBodyVisitor : public BodyVisitorBase<StaticVisitor> {
204
214
  static inline ReturnType Visit(Map* map, HeapObject* object) {
205
215
  int object_size = BodyDescriptor::SizeOf(map, object);
206
216
  BodyVisitorBase<StaticVisitor>::IteratePointers(
207
- object, BodyDescriptor::kStartOffset, object_size);
217
+ map->heap(),
218
+ object,
219
+ BodyDescriptor::kStartOffset,
220
+ object_size);
208
221
  return static_cast<ReturnType>(object_size);
209
222
  }
210
223
 
@@ -212,7 +225,10 @@ class FlexibleBodyVisitor : public BodyVisitorBase<StaticVisitor> {
212
225
  static inline ReturnType VisitSpecialized(Map* map, HeapObject* object) {
213
226
  ASSERT(BodyDescriptor::SizeOf(map, object) == object_size);
214
227
  BodyVisitorBase<StaticVisitor>::IteratePointers(
215
- object, BodyDescriptor::kStartOffset, object_size);
228
+ map->heap(),
229
+ object,
230
+ BodyDescriptor::kStartOffset,
231
+ object_size);
216
232
  return static_cast<ReturnType>(object_size);
217
233
  }
218
234
  };
@@ -223,7 +239,10 @@ class FixedBodyVisitor : public BodyVisitorBase<StaticVisitor> {
223
239
  public:
224
240
  static inline ReturnType Visit(Map* map, HeapObject* object) {
225
241
  BodyVisitorBase<StaticVisitor>::IteratePointers(
226
- object, BodyDescriptor::kStartOffset, BodyDescriptor::kEndOffset);
242
+ map->heap(),
243
+ object,
244
+ BodyDescriptor::kStartOffset,
245
+ BodyDescriptor::kEndOffset);
227
246
  return static_cast<ReturnType>(BodyDescriptor::kSize);
228
247
  }
229
248
  };
@@ -299,8 +318,8 @@ class StaticNewSpaceVisitor : public StaticVisitorBase {
299
318
  return table_.GetVisitor(map)(map, obj);
300
319
  }
301
320
 
302
- static inline void VisitPointers(Object** start, Object** end) {
303
- for (Object** p = start; p < end; p++) StaticVisitor::VisitPointer(p);
321
+ static inline void VisitPointers(Heap* heap, Object** start, Object** end) {
322
+ for (Object** p = start; p < end; p++) StaticVisitor::VisitPointer(heap, p);
304
323
  }
305
324
 
306
325
  private:
@@ -372,7 +391,7 @@ void Code::CodeIterateBody(ObjectVisitor* v) {
372
391
 
373
392
 
374
393
  template<typename StaticVisitor>
375
- void Code::CodeIterateBody() {
394
+ void Code::CodeIterateBody(Heap* heap) {
376
395
  int mode_mask = RelocInfo::kCodeTargetMask |
377
396
  RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT) |
378
397
  RelocInfo::ModeMask(RelocInfo::GLOBAL_PROPERTY_CELL) |
@@ -386,12 +405,14 @@ void Code::CodeIterateBody() {
386
405
  RelocIterator it(this, mode_mask);
387
406
 
388
407
  StaticVisitor::VisitPointer(
408
+ heap,
389
409
  reinterpret_cast<Object**>(this->address() + kRelocationInfoOffset));
390
410
  StaticVisitor::VisitPointer(
411
+ heap,
391
412
  reinterpret_cast<Object**>(this->address() + kDeoptimizationDataOffset));
392
413
 
393
414
  for (; !it.done(); it.next()) {
394
- it.rinfo()->template Visit<StaticVisitor>();
415
+ it.rinfo()->template Visit<StaticVisitor>(heap);
395
416
  }
396
417
  }
397
418
 
@@ -51,7 +51,6 @@
51
51
  #include "disassembler.h"
52
52
  #endif
53
53
 
54
-
55
54
  namespace v8 {
56
55
  namespace internal {
57
56
 
@@ -64,7 +63,8 @@ const int kSetterIndex = 1;
64
63
  MUST_USE_RESULT static MaybeObject* CreateJSValue(JSFunction* constructor,
65
64
  Object* value) {
66
65
  Object* result;
67
- { MaybeObject* maybe_result = Heap::AllocateJSObject(constructor);
66
+ { MaybeObject* maybe_result =
67
+ constructor->GetHeap()->AllocateJSObject(constructor);
68
68
  if (!maybe_result->ToObject(&result)) return maybe_result;
69
69
  }
70
70
  JSValue::cast(result)->set_value(value);
@@ -86,14 +86,19 @@ MaybeObject* Object::ToObject(Context* global_context) {
86
86
 
87
87
 
88
88
  MaybeObject* Object::ToObject() {
89
- Context* global_context = Top::context()->global_context();
90
89
  if (IsJSObject()) {
91
90
  return this;
92
91
  } else if (IsNumber()) {
92
+ Isolate* isolate = Isolate::Current();
93
+ Context* global_context = isolate->context()->global_context();
93
94
  return CreateJSValue(global_context->number_function(), this);
94
95
  } else if (IsBoolean()) {
96
+ Isolate* isolate = HeapObject::cast(this)->GetIsolate();
97
+ Context* global_context = isolate->context()->global_context();
95
98
  return CreateJSValue(global_context->boolean_function(), this);
96
99
  } else if (IsString()) {
100
+ Isolate* isolate = HeapObject::cast(this)->GetIsolate();
101
+ Context* global_context = isolate->context()->global_context();
97
102
  return CreateJSValue(global_context->string_function(), this);
98
103
  }
99
104
 
@@ -103,36 +108,52 @@ MaybeObject* Object::ToObject() {
103
108
 
104
109
 
105
110
  Object* Object::ToBoolean() {
106
- if (IsTrue()) return Heap::true_value();
107
- if (IsFalse()) return Heap::false_value();
111
+ if (IsTrue()) return this;
112
+ if (IsFalse()) return this;
108
113
  if (IsSmi()) {
109
- return Heap::ToBoolean(Smi::cast(this)->value() != 0);
114
+ return Isolate::Current()->heap()->ToBoolean(Smi::cast(this)->value() != 0);
115
+ }
116
+ HeapObject* heap_object = HeapObject::cast(this);
117
+ if (heap_object->IsUndefined() || heap_object->IsNull()) {
118
+ return heap_object->GetHeap()->false_value();
110
119
  }
111
- if (IsUndefined() || IsNull()) return Heap::false_value();
112
120
  // Undetectable object is false
113
- if (IsUndetectableObject()) {
114
- return Heap::false_value();
121
+ if (heap_object->IsUndetectableObject()) {
122
+ return heap_object->GetHeap()->false_value();
115
123
  }
116
- if (IsString()) {
117
- return Heap::ToBoolean(String::cast(this)->length() != 0);
124
+ if (heap_object->IsString()) {
125
+ return heap_object->GetHeap()->ToBoolean(
126
+ String::cast(this)->length() != 0);
118
127
  }
119
- if (IsHeapNumber()) {
128
+ if (heap_object->IsHeapNumber()) {
120
129
  return HeapNumber::cast(this)->HeapNumberToBoolean();
121
130
  }
122
- return Heap::true_value();
131
+ return heap_object->GetHeap()->true_value();
123
132
  }
124
133
 
125
134
 
126
135
  void Object::Lookup(String* name, LookupResult* result) {
127
- if (IsJSObject()) return JSObject::cast(this)->Lookup(name, result);
128
136
  Object* holder = NULL;
129
- Context* global_context = Top::context()->global_context();
130
- if (IsString()) {
131
- holder = global_context->string_function()->instance_prototype();
132
- } else if (IsNumber()) {
137
+ if (IsSmi()) {
138
+ Heap* heap = Isolate::Current()->heap();
139
+ Context* global_context = heap->isolate()->context()->global_context();
133
140
  holder = global_context->number_function()->instance_prototype();
134
- } else if (IsBoolean()) {
135
- holder = global_context->boolean_function()->instance_prototype();
141
+ } else {
142
+ HeapObject* heap_object = HeapObject::cast(this);
143
+ if (heap_object->IsJSObject()) {
144
+ return JSObject::cast(this)->Lookup(name, result);
145
+ }
146
+ Heap* heap = heap_object->GetHeap();
147
+ if (heap_object->IsString()) {
148
+ Context* global_context = heap->isolate()->context()->global_context();
149
+ holder = global_context->string_function()->instance_prototype();
150
+ } else if (heap_object->IsHeapNumber()) {
151
+ Context* global_context = heap->isolate()->context()->global_context();
152
+ holder = global_context->number_function()->instance_prototype();
153
+ } else if (heap_object->IsBoolean()) {
154
+ Context* global_context = heap->isolate()->context()->global_context();
155
+ holder = global_context->boolean_function()->instance_prototype();
156
+ }
136
157
  }
137
158
  ASSERT(holder != NULL); // Cannot handle null or undefined.
138
159
  JSObject::cast(holder)->Lookup(name, result);
@@ -154,6 +175,7 @@ MaybeObject* Object::GetPropertyWithCallback(Object* receiver,
154
175
  Object* structure,
155
176
  String* name,
156
177
  Object* holder) {
178
+ Isolate* isolate = name->GetIsolate();
157
179
  // To accommodate both the old and the new api we switch on the
158
180
  // data structure used to store the callbacks. Eventually proxy
159
181
  // callbacks should be phased out.
@@ -161,7 +183,7 @@ MaybeObject* Object::GetPropertyWithCallback(Object* receiver,
161
183
  AccessorDescriptor* callback =
162
184
  reinterpret_cast<AccessorDescriptor*>(Proxy::cast(structure)->proxy());
163
185
  MaybeObject* value = (callback->getter)(receiver, callback->data);
164
- RETURN_IF_SCHEDULED_EXCEPTION();
186
+ RETURN_IF_SCHEDULED_EXCEPTION(isolate);
165
187
  return value;
166
188
  }
167
189
 
@@ -174,17 +196,19 @@ MaybeObject* Object::GetPropertyWithCallback(Object* receiver,
174
196
  JSObject* self = JSObject::cast(receiver);
175
197
  JSObject* holder_handle = JSObject::cast(holder);
176
198
  Handle<String> key(name);
177
- LOG(ApiNamedPropertyAccess("load", self, name));
178
- CustomArguments args(data->data(), self, holder_handle);
199
+ LOG(isolate, ApiNamedPropertyAccess("load", self, name));
200
+ CustomArguments args(isolate, data->data(), self, holder_handle);
179
201
  v8::AccessorInfo info(args.end());
180
202
  v8::Handle<v8::Value> result;
181
203
  {
182
204
  // Leaving JavaScript.
183
- VMState state(EXTERNAL);
205
+ VMState state(isolate, EXTERNAL);
184
206
  result = call_fun(v8::Utils::ToLocal(key), info);
185
207
  }
186
- RETURN_IF_SCHEDULED_EXCEPTION();
187
- if (result.IsEmpty()) return Heap::undefined_value();
208
+ RETURN_IF_SCHEDULED_EXCEPTION(isolate);
209
+ if (result.IsEmpty()) {
210
+ return isolate->heap()->undefined_value();
211
+ }
188
212
  return *v8::Utils::OpenHandle(*result);
189
213
  }
190
214
 
@@ -196,7 +220,7 @@ MaybeObject* Object::GetPropertyWithCallback(Object* receiver,
196
220
  JSFunction::cast(getter));
197
221
  }
198
222
  // Getter is not a function.
199
- return Heap::undefined_value();
223
+ return isolate->heap()->undefined_value();
200
224
  }
201
225
 
202
226
  UNREACHABLE();
@@ -210,9 +234,10 @@ MaybeObject* Object::GetPropertyWithDefinedGetter(Object* receiver,
210
234
  Handle<JSFunction> fun(JSFunction::cast(getter));
211
235
  Handle<Object> self(receiver);
212
236
  #ifdef ENABLE_DEBUGGER_SUPPORT
237
+ Debug* debug = fun->GetHeap()->isolate()->debug();
213
238
  // Handle stepping into a getter if step into is active.
214
- if (Debug::StepInActive()) {
215
- Debug::HandleStepIn(fun, Handle<Object>::null(), 0, false);
239
+ if (debug->StepInActive()) {
240
+ debug->HandleStepIn(fun, Handle<Object>::null(), 0, false);
216
241
  }
217
242
  #endif
218
243
  bool has_pending_exception;
@@ -281,8 +306,9 @@ MaybeObject* JSObject::GetPropertyWithFailedAccessCheck(
281
306
 
282
307
  // No accessible property found.
283
308
  *attributes = ABSENT;
284
- Top::ReportFailedAccessCheck(this, v8::ACCESS_GET);
285
- return Heap::undefined_value();
309
+ Heap* heap = name->GetHeap();
310
+ heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_GET);
311
+ return heap->undefined_value();
286
312
  }
287
313
 
288
314
 
@@ -344,7 +370,7 @@ PropertyAttributes JSObject::GetPropertyAttributeWithFailedAccessCheck(
344
370
  }
345
371
  }
346
372
 
347
- Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS);
373
+ GetHeap()->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
348
374
  return ABSENT;
349
375
  }
350
376
 
@@ -382,12 +408,10 @@ MaybeObject* JSObject::SetNormalizedProperty(String* name,
382
408
  if (entry == StringDictionary::kNotFound) {
383
409
  Object* store_value = value;
384
410
  if (IsGlobalObject()) {
385
- { MaybeObject* maybe_store_value =
386
- Heap::AllocateJSGlobalPropertyCell(value);
387
- if (!maybe_store_value->ToObject(&store_value)) {
388
- return maybe_store_value;
389
- }
390
- }
411
+ Heap* heap = name->GetHeap();
412
+ MaybeObject* maybe_store_value =
413
+ heap->AllocateJSGlobalPropertyCell(value);
414
+ if (!maybe_store_value->ToObject(&store_value)) return maybe_store_value;
391
415
  }
392
416
  Object* dict;
393
417
  { MaybeObject* maybe_dict =
@@ -423,7 +447,7 @@ MaybeObject* JSObject::DeleteNormalizedProperty(String* name, DeleteMode mode) {
423
447
  if (IsGlobalObject()) {
424
448
  PropertyDetails details = dictionary->DetailsAt(entry);
425
449
  if (details.IsDontDelete()) {
426
- if (mode != FORCE_DELETION) return Heap::false_value();
450
+ if (mode != FORCE_DELETION) return GetHeap()->false_value();
427
451
  // When forced to delete global properties, we have to make a
428
452
  // map change to invalidate any ICs that think they can load
429
453
  // from the DontDelete cell without checking if it contains
@@ -436,13 +460,13 @@ MaybeObject* JSObject::DeleteNormalizedProperty(String* name, DeleteMode mode) {
436
460
  }
437
461
  JSGlobalPropertyCell* cell =
438
462
  JSGlobalPropertyCell::cast(dictionary->ValueAt(entry));
439
- cell->set_value(Heap::the_hole_value());
463
+ cell->set_value(cell->heap()->the_hole_value());
440
464
  dictionary->DetailsAtPut(entry, details.AsDeleted());
441
465
  } else {
442
466
  return dictionary->DeleteProperty(entry, mode);
443
467
  }
444
468
  }
445
- return Heap::true_value();
469
+ return GetHeap()->true_value();
446
470
  }
447
471
 
448
472
 
@@ -468,6 +492,7 @@ MaybeObject* Object::GetProperty(Object* receiver,
468
492
  // Make sure that the top context does not change when doing
469
493
  // callbacks or interceptor calls.
470
494
  AssertNoContextChange ncc;
495
+ Heap* heap = name->GetHeap();
471
496
 
472
497
  // Traverse the prototype chain from the current object (this) to
473
498
  // the holder and check for access rights. This avoid traversing the
@@ -475,7 +500,7 @@ MaybeObject* Object::GetProperty(Object* receiver,
475
500
  // holder will always be the interceptor holder and the search may
476
501
  // only continue with a current object just after the interceptor
477
502
  // holder in the prototype chain.
478
- Object* last = result->IsProperty() ? result->holder() : Heap::null_value();
503
+ Object* last = result->IsProperty() ? result->holder() : heap->null_value();
479
504
  for (Object* current = this; true; current = current->GetPrototype()) {
480
505
  if (current->IsAccessCheckNeeded()) {
481
506
  // Check if we're allowed to read from the current object. Note
@@ -483,7 +508,7 @@ MaybeObject* Object::GetProperty(Object* receiver,
483
508
  // property from the current object, we still check that we have
484
509
  // access to it.
485
510
  JSObject* checked = JSObject::cast(current);
486
- if (!Top::MayNamedAccess(checked, name, v8::ACCESS_GET)) {
511
+ if (!heap->isolate()->MayNamedAccess(checked, name, v8::ACCESS_GET)) {
487
512
  return checked->GetPropertyWithFailedAccessCheck(receiver,
488
513
  result,
489
514
  name,
@@ -498,7 +523,7 @@ MaybeObject* Object::GetProperty(Object* receiver,
498
523
 
499
524
  if (!result->IsProperty()) {
500
525
  *attributes = ABSENT;
501
- return Heap::undefined_value();
526
+ return heap->undefined_value();
502
527
  }
503
528
  *attributes = result->GetAttributes();
504
529
  Object* value;
@@ -507,11 +532,11 @@ MaybeObject* Object::GetProperty(Object* receiver,
507
532
  case NORMAL:
508
533
  value = holder->GetNormalizedProperty(result);
509
534
  ASSERT(!value->IsTheHole() || result->IsReadOnly());
510
- return value->IsTheHole() ? Heap::undefined_value() : value;
535
+ return value->IsTheHole() ? heap->undefined_value() : value;
511
536
  case FIELD:
512
537
  value = holder->FastPropertyAt(result->GetFieldIndex());
513
538
  ASSERT(!value->IsTheHole() || result->IsReadOnly());
514
- return value->IsTheHole() ? Heap::undefined_value() : value;
539
+ return value->IsTheHole() ? heap->undefined_value() : value;
515
540
  case CONSTANT_FUNCTION:
516
541
  return result->GetConstantFunction();
517
542
  case CALLBACKS:
@@ -531,22 +556,31 @@ MaybeObject* Object::GetProperty(Object* receiver,
531
556
 
532
557
 
533
558
  MaybeObject* Object::GetElementWithReceiver(Object* receiver, uint32_t index) {
534
- if (IsJSObject()) {
535
- return JSObject::cast(this)->GetElementWithReceiver(receiver, index);
536
- }
537
-
538
559
  Object* holder = NULL;
539
- Context* global_context = Top::context()->global_context();
540
- if (IsString()) {
541
- holder = global_context->string_function()->instance_prototype();
542
- } else if (IsNumber()) {
560
+ if (IsSmi()) {
561
+ Context* global_context = Isolate::Current()->context()->global_context();
543
562
  holder = global_context->number_function()->instance_prototype();
544
- } else if (IsBoolean()) {
545
- holder = global_context->boolean_function()->instance_prototype();
546
563
  } else {
547
- // Undefined and null have no indexed properties.
548
- ASSERT(IsUndefined() || IsNull());
549
- return Heap::undefined_value();
564
+ HeapObject* heap_object = HeapObject::cast(this);
565
+
566
+ if (heap_object->IsJSObject()) {
567
+ return JSObject::cast(this)->GetElementWithReceiver(receiver, index);
568
+ }
569
+ Heap* heap = heap_object->GetHeap();
570
+ Isolate* isolate = heap->isolate();
571
+
572
+ Context* global_context = isolate->context()->global_context();
573
+ if (heap_object->IsString()) {
574
+ holder = global_context->string_function()->instance_prototype();
575
+ } else if (heap_object->IsHeapNumber()) {
576
+ holder = global_context->number_function()->instance_prototype();
577
+ } else if (heap_object->IsBoolean()) {
578
+ holder = global_context->boolean_function()->instance_prototype();
579
+ } else {
580
+ // Undefined and null have no indexed properties.
581
+ ASSERT(heap_object->IsUndefined() || heap_object->IsNull());
582
+ return heap->undefined_value();
583
+ }
550
584
  }
551
585
 
552
586
  return JSObject::cast(holder)->GetElementWithReceiver(receiver, index);
@@ -554,16 +588,31 @@ MaybeObject* Object::GetElementWithReceiver(Object* receiver, uint32_t index) {
554
588
 
555
589
 
556
590
  Object* Object::GetPrototype() {
591
+ if (IsSmi()) {
592
+ Heap* heap = Isolate::Current()->heap();
593
+ Context* context = heap->isolate()->context()->global_context();
594
+ return context->number_function()->instance_prototype();
595
+ }
596
+
597
+ HeapObject* heap_object = HeapObject::cast(this);
598
+
557
599
  // The object is either a number, a string, a boolean, or a real JS object.
558
- if (IsJSObject()) return JSObject::cast(this)->map()->prototype();
559
- Context* context = Top::context()->global_context();
600
+ if (heap_object->IsJSObject()) {
601
+ return JSObject::cast(this)->map()->prototype();
602
+ }
603
+ Heap* heap = heap_object->GetHeap();
604
+ Context* context = heap->isolate()->context()->global_context();
560
605
 
561
- if (IsNumber()) return context->number_function()->instance_prototype();
562
- if (IsString()) return context->string_function()->instance_prototype();
563
- if (IsBoolean()) {
606
+ if (heap_object->IsHeapNumber()) {
607
+ return context->number_function()->instance_prototype();
608
+ }
609
+ if (heap_object->IsString()) {
610
+ return context->string_function()->instance_prototype();
611
+ }
612
+ if (heap_object->IsBoolean()) {
564
613
  return context->boolean_function()->instance_prototype();
565
614
  } else {
566
- return Heap::null_value();
615
+ return heap->null_value();
567
616
  }
568
617
  }
569
618
 
@@ -637,9 +686,10 @@ MaybeObject* String::SlowTryFlatten(PretenureFlag pretenure) {
637
686
  // allowed. This is to avoid an assertion failure when allocating.
638
687
  // Flattening strings is the only case where we always allow
639
688
  // allocation because no GC is performed if the allocation fails.
640
- if (!Heap::IsAllocationAllowed()) return this;
689
+ if (!HEAP->IsAllocationAllowed()) return this;
641
690
  #endif
642
691
 
692
+ Heap* heap = GetHeap();
643
693
  switch (StringShape(this).representation_tag()) {
644
694
  case kConsStringTag: {
645
695
  ConsString* cs = ConsString::cast(this);
@@ -649,12 +699,12 @@ MaybeObject* String::SlowTryFlatten(PretenureFlag pretenure) {
649
699
  // There's little point in putting the flat string in new space if the
650
700
  // cons string is in old space. It can never get GCed until there is
651
701
  // an old space GC.
652
- PretenureFlag tenure = Heap::InNewSpace(this) ? pretenure : TENURED;
702
+ PretenureFlag tenure = heap->InNewSpace(this) ? pretenure : TENURED;
653
703
  int len = length();
654
704
  Object* object;
655
705
  String* result;
656
706
  if (IsAsciiRepresentation()) {
657
- { MaybeObject* maybe_object = Heap::AllocateRawAsciiString(len, tenure);
707
+ { MaybeObject* maybe_object = heap->AllocateRawAsciiString(len, tenure);
658
708
  if (!maybe_object->ToObject(&object)) return maybe_object;
659
709
  }
660
710
  result = String::cast(object);
@@ -669,7 +719,7 @@ MaybeObject* String::SlowTryFlatten(PretenureFlag pretenure) {
669
719
  len - first_length);
670
720
  } else {
671
721
  { MaybeObject* maybe_object =
672
- Heap::AllocateRawTwoByteString(len, tenure);
722
+ heap->AllocateRawTwoByteString(len, tenure);
673
723
  if (!maybe_object->ToObject(&object)) return maybe_object;
674
724
  }
675
725
  result = String::cast(object);
@@ -684,7 +734,7 @@ MaybeObject* String::SlowTryFlatten(PretenureFlag pretenure) {
684
734
  len - first_length);
685
735
  }
686
736
  cs->set_first(result);
687
- cs->set_second(Heap::empty_string());
737
+ cs->set_second(heap->empty_string());
688
738
  return result;
689
739
  }
690
740
  default:
@@ -708,7 +758,7 @@ bool String::MakeExternal(v8::String::ExternalStringResource* resource) {
708
758
  resource->length() * sizeof(smart_chars[0])) == 0);
709
759
  }
710
760
  #endif // DEBUG
711
-
761
+ Heap* heap = GetHeap();
712
762
  int size = this->Size(); // Byte size of the original string.
713
763
  if (size < ExternalString::kSize) {
714
764
  // The string is too small to fit an external String in its place. This can
@@ -724,8 +774,8 @@ bool String::MakeExternal(v8::String::ExternalStringResource* resource) {
724
774
  // Morph the object to an external string by adjusting the map and
725
775
  // reinitializing the fields.
726
776
  this->set_map(is_ascii ?
727
- Heap::external_string_with_ascii_data_map() :
728
- Heap::external_string_map());
777
+ heap->external_string_with_ascii_data_map() :
778
+ heap->external_string_map());
729
779
  ExternalTwoByteString* self = ExternalTwoByteString::cast(this);
730
780
  self->set_length(length);
731
781
  self->set_hash_field(hash_field);
@@ -736,13 +786,13 @@ bool String::MakeExternal(v8::String::ExternalStringResource* resource) {
736
786
  self->Hash(); // Force regeneration of the hash value.
737
787
  // Now morph this external string into a external symbol.
738
788
  this->set_map(is_ascii ?
739
- Heap::external_symbol_with_ascii_data_map() :
740
- Heap::external_symbol_map());
789
+ heap->external_symbol_with_ascii_data_map() :
790
+ heap->external_symbol_map());
741
791
  }
742
792
 
743
793
  // Fill the remainder of the string with dead wood.
744
794
  int new_size = this->Size(); // Byte size of the external String object.
745
- Heap::CreateFillerObjectAt(this->address() + new_size, size - new_size);
795
+ heap->CreateFillerObjectAt(this->address() + new_size, size - new_size);
746
796
  return true;
747
797
  }
748
798
 
@@ -759,7 +809,7 @@ bool String::MakeExternal(v8::String::ExternalAsciiStringResource* resource) {
759
809
  resource->length() * sizeof(smart_chars[0])) == 0);
760
810
  }
761
811
  #endif // DEBUG
762
-
812
+ Heap* heap = GetHeap();
763
813
  int size = this->Size(); // Byte size of the original string.
764
814
  if (size < ExternalString::kSize) {
765
815
  // The string is too small to fit an external String in its place. This can
@@ -773,7 +823,7 @@ bool String::MakeExternal(v8::String::ExternalAsciiStringResource* resource) {
773
823
 
774
824
  // Morph the object to an external string by adjusting the map and
775
825
  // reinitializing the fields.
776
- this->set_map(Heap::external_ascii_string_map());
826
+ this->set_map(heap->external_ascii_string_map());
777
827
  ExternalAsciiString* self = ExternalAsciiString::cast(this);
778
828
  self->set_length(length);
779
829
  self->set_hash_field(hash_field);
@@ -783,12 +833,12 @@ bool String::MakeExternal(v8::String::ExternalAsciiStringResource* resource) {
783
833
  if (is_symbol) {
784
834
  self->Hash(); // Force regeneration of the hash value.
785
835
  // Now morph this external string into a external symbol.
786
- this->set_map(Heap::external_ascii_symbol_map());
836
+ this->set_map(heap->external_ascii_symbol_map());
787
837
  }
788
838
 
789
839
  // Fill the remainder of the string with dead wood.
790
840
  int new_size = this->Size(); // Byte size of the external String object.
791
- Heap::CreateFillerObjectAt(this->address() + new_size, size - new_size);
841
+ heap->CreateFillerObjectAt(this->address() + new_size, size - new_size);
792
842
  return true;
793
843
  }
794
844
 
@@ -887,15 +937,17 @@ void JSObject::JSObjectShortPrint(StringStream* accumulator) {
887
937
  // All other JSObjects are rather similar to each other (JSObject,
888
938
  // JSGlobalProxy, JSGlobalObject, JSUndetectableObject, JSValue).
889
939
  default: {
890
- Object* constructor = map()->constructor();
940
+ Map* map_of_this = map();
941
+ Heap* heap = map_of_this->heap();
942
+ Object* constructor = map_of_this->constructor();
891
943
  bool printed = false;
892
944
  if (constructor->IsHeapObject() &&
893
- !Heap::Contains(HeapObject::cast(constructor))) {
945
+ !heap->Contains(HeapObject::cast(constructor))) {
894
946
  accumulator->Add("!!!INVALID CONSTRUCTOR!!!");
895
947
  } else {
896
948
  bool global_object = IsJSGlobalProxy();
897
949
  if (constructor->IsJSFunction()) {
898
- if (!Heap::Contains(JSFunction::cast(constructor)->shared())) {
950
+ if (!heap->Contains(JSFunction::cast(constructor)->shared())) {
899
951
  accumulator->Add("!!!INVALID SHARED ON CONSTRUCTOR!!!");
900
952
  } else {
901
953
  Object* constructor_name =
@@ -930,12 +982,13 @@ void JSObject::JSObjectShortPrint(StringStream* accumulator) {
930
982
 
931
983
 
932
984
  void HeapObject::HeapObjectShortPrint(StringStream* accumulator) {
933
- // if (!Heap::InNewSpace(this)) PrintF("*", this);
934
- if (!Heap::Contains(this)) {
985
+ // if (!HEAP->InNewSpace(this)) PrintF("*", this);
986
+ Heap* heap = GetHeap();
987
+ if (!heap->Contains(this)) {
935
988
  accumulator->Add("!!!INVALID POINTER!!!");
936
989
  return;
937
990
  }
938
- if (!Heap::Contains(map())) {
991
+ if (!heap->Contains(map())) {
939
992
  accumulator->Add("!!!INVALID MAP!!!");
940
993
  return;
941
994
  }
@@ -960,8 +1013,9 @@ void HeapObject::HeapObjectShortPrint(StringStream* accumulator) {
960
1013
  case BYTE_ARRAY_TYPE:
961
1014
  accumulator->Add("<ByteArray[%u]>", ByteArray::cast(this)->length());
962
1015
  break;
963
- case PIXEL_ARRAY_TYPE:
964
- accumulator->Add("<PixelArray[%u]>", PixelArray::cast(this)->length());
1016
+ case EXTERNAL_PIXEL_ARRAY_TYPE:
1017
+ accumulator->Add("<ExternalPixelArray[%u]>",
1018
+ ExternalPixelArray::cast(this)->length());
965
1019
  break;
966
1020
  case EXTERNAL_BYTE_ARRAY_TYPE:
967
1021
  accumulator->Add("<ExternalByteArray[%u]>",
@@ -1112,7 +1166,7 @@ void HeapObject::IterateBody(InstanceType type, int object_size,
1112
1166
  case HEAP_NUMBER_TYPE:
1113
1167
  case FILLER_TYPE:
1114
1168
  case BYTE_ARRAY_TYPE:
1115
- case PIXEL_ARRAY_TYPE:
1169
+ case EXTERNAL_PIXEL_ARRAY_TYPE:
1116
1170
  case EXTERNAL_BYTE_ARRAY_TYPE:
1117
1171
  case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE:
1118
1172
  case EXTERNAL_SHORT_ARRAY_TYPE:
@@ -1149,14 +1203,14 @@ Object* HeapNumber::HeapNumberToBoolean() {
1149
1203
  if (u.bits.exp == 2047) {
1150
1204
  // Detect NaN for IEEE double precision floating point.
1151
1205
  if ((u.bits.man_low | u.bits.man_high) != 0)
1152
- return Heap::false_value();
1206
+ return GetHeap()->false_value();
1153
1207
  }
1154
1208
  if (u.bits.exp == 0) {
1155
1209
  // Detect +0, and -0 for IEEE double precision floating point.
1156
1210
  if ((u.bits.man_low | u.bits.man_high) == 0)
1157
- return Heap::false_value();
1211
+ return GetHeap()->false_value();
1158
1212
  }
1159
- return Heap::true_value();
1213
+ return GetHeap()->true_value();
1160
1214
  }
1161
1215
 
1162
1216
 
@@ -1180,14 +1234,14 @@ void HeapNumber::HeapNumberPrint(StringStream* accumulator) {
1180
1234
 
1181
1235
  String* JSObject::class_name() {
1182
1236
  if (IsJSFunction()) {
1183
- return Heap::function_class_symbol();
1237
+ return GetHeap()->function_class_symbol();
1184
1238
  }
1185
1239
  if (map()->constructor()->IsJSFunction()) {
1186
1240
  JSFunction* constructor = JSFunction::cast(map()->constructor());
1187
1241
  return String::cast(constructor->shared()->instance_class_name());
1188
1242
  }
1189
1243
  // If the constructor is not present, return "Object".
1190
- return Heap::Object_symbol();
1244
+ return GetHeap()->Object_symbol();
1191
1245
  }
1192
1246
 
1193
1247
 
@@ -1202,7 +1256,7 @@ String* JSObject::constructor_name() {
1202
1256
  if (proto->IsJSObject()) return JSObject::cast(proto)->constructor_name();
1203
1257
  }
1204
1258
  // If the constructor is not present, return "Object".
1205
- return Heap::Object_symbol();
1259
+ return GetHeap()->Object_symbol();
1206
1260
  }
1207
1261
 
1208
1262
 
@@ -1232,9 +1286,10 @@ MaybeObject* JSObject::AddFastProperty(String* name,
1232
1286
 
1233
1287
  // Normalize the object if the name is an actual string (not the
1234
1288
  // hidden symbols) and is not a real identifier.
1289
+ Isolate* isolate = GetHeap()->isolate();
1235
1290
  StringInputBuffer buffer(name);
1236
- if (!ScannerConstants::IsIdentifier(&buffer)
1237
- && name != Heap::hidden_symbol()) {
1291
+ if (!isolate->scanner_constants()->IsIdentifier(&buffer)
1292
+ && name != isolate->heap()->hidden_symbol()) {
1238
1293
  Object* obj;
1239
1294
  { MaybeObject* maybe_obj =
1240
1295
  NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0);
@@ -1257,11 +1312,21 @@ MaybeObject* JSObject::AddFastProperty(String* name,
1257
1312
  }
1258
1313
  }
1259
1314
 
1260
- // Only allow map transition if the object's map is NOT equal to the
1261
- // global object_function's map and there is not a transition for name.
1315
+ // Only allow map transition if the object isn't the global object and there
1316
+ // is not a transition for the name, or there's a transition for the name but
1317
+ // it's unrelated to properties.
1318
+ int descriptor_index = old_descriptors->Search(name);
1319
+
1320
+ // External array transitions are stored in the descriptor for property "",
1321
+ // which is not a identifier and should have forced a switch to slow
1322
+ // properties above.
1323
+ ASSERT(descriptor_index == DescriptorArray::kNotFound ||
1324
+ old_descriptors->GetType(descriptor_index) != EXTERNAL_ARRAY_TRANSITION);
1325
+ bool can_insert_transition = descriptor_index == DescriptorArray::kNotFound ||
1326
+ old_descriptors->GetType(descriptor_index) == EXTERNAL_ARRAY_TRANSITION;
1262
1327
  bool allow_map_transition =
1263
- !old_descriptors->Contains(name) &&
1264
- (Top::context()->global_context()->object_function()->map() != map());
1328
+ can_insert_transition &&
1329
+ (isolate->context()->global_context()->object_function()->map() != map());
1265
1330
 
1266
1331
  ASSERT(index < map()->inobject_properties() ||
1267
1332
  (index - map()->inobject_properties()) < properties()->length() ||
@@ -1315,7 +1380,7 @@ MaybeObject* JSObject::AddConstantFunctionProperty(
1315
1380
  String* name,
1316
1381
  JSFunction* function,
1317
1382
  PropertyAttributes attributes) {
1318
- ASSERT(!Heap::InNewSpace(function));
1383
+ ASSERT(!GetHeap()->InNewSpace(function));
1319
1384
 
1320
1385
  // Allocate new instance descriptors with (name, function) added
1321
1386
  ConstantFunctionDescriptor d(name, function, attributes);
@@ -1340,7 +1405,9 @@ MaybeObject* JSObject::AddConstantFunctionProperty(
1340
1405
 
1341
1406
  // If the old map is the global object map (from new Object()),
1342
1407
  // then transitions are not added to it, so we are done.
1343
- if (old_map == Top::context()->global_context()->object_function()->map()) {
1408
+ Heap* heap = old_map->heap();
1409
+ if (old_map == heap->isolate()->context()->global_context()->
1410
+ object_function()->map()) {
1344
1411
  return function;
1345
1412
  }
1346
1413
 
@@ -1391,8 +1458,9 @@ MaybeObject* JSObject::AddSlowProperty(String* name,
1391
1458
  dict->SetEntry(entry, name, store_value, details);
1392
1459
  return value;
1393
1460
  }
1461
+ Heap* heap = GetHeap();
1394
1462
  { MaybeObject* maybe_store_value =
1395
- Heap::AllocateJSGlobalPropertyCell(value);
1463
+ heap->AllocateJSGlobalPropertyCell(value);
1396
1464
  if (!maybe_store_value->ToObject(&store_value)) return maybe_store_value;
1397
1465
  }
1398
1466
  JSGlobalPropertyCell::cast(store_value)->set_value(value);
@@ -1409,18 +1477,26 @@ MaybeObject* JSObject::AddSlowProperty(String* name,
1409
1477
 
1410
1478
  MaybeObject* JSObject::AddProperty(String* name,
1411
1479
  Object* value,
1412
- PropertyAttributes attributes) {
1480
+ PropertyAttributes attributes,
1481
+ StrictModeFlag strict_mode) {
1413
1482
  ASSERT(!IsJSGlobalProxy());
1414
- if (!map()->is_extensible()) {
1415
- Handle<Object> args[1] = {Handle<String>(name)};
1416
- return Top::Throw(*Factory::NewTypeError("object_not_extensible",
1417
- HandleVector(args, 1)));
1483
+ Map* map_of_this = map();
1484
+ Heap* heap = map_of_this->heap();
1485
+ if (!map_of_this->is_extensible()) {
1486
+ if (strict_mode == kNonStrictMode) {
1487
+ return heap->undefined_value();
1488
+ } else {
1489
+ Handle<Object> args[1] = {Handle<String>(name)};
1490
+ return heap->isolate()->Throw(
1491
+ *FACTORY->NewTypeError("object_not_extensible",
1492
+ HandleVector(args, 1)));
1493
+ }
1418
1494
  }
1419
1495
  if (HasFastProperties()) {
1420
1496
  // Ensure the descriptor array does not get too big.
1421
- if (map()->instance_descriptors()->number_of_descriptors() <
1497
+ if (map_of_this->instance_descriptors()->number_of_descriptors() <
1422
1498
  DescriptorArray::kMaxNumberOfDescriptors) {
1423
- if (value->IsJSFunction() && !Heap::InNewSpace(value)) {
1499
+ if (value->IsJSFunction() && !heap->InNewSpace(value)) {
1424
1500
  return AddConstantFunctionProperty(name,
1425
1501
  JSFunction::cast(value),
1426
1502
  attributes);
@@ -1444,17 +1520,18 @@ MaybeObject* JSObject::AddProperty(String* name,
1444
1520
  MaybeObject* JSObject::SetPropertyPostInterceptor(
1445
1521
  String* name,
1446
1522
  Object* value,
1447
- PropertyAttributes attributes) {
1523
+ PropertyAttributes attributes,
1524
+ StrictModeFlag strict_mode) {
1448
1525
  // Check local property, ignore interceptor.
1449
1526
  LookupResult result;
1450
1527
  LocalLookupRealNamedProperty(name, &result);
1451
1528
  if (result.IsFound()) {
1452
1529
  // An existing property, a map transition or a null descriptor was
1453
1530
  // found. Use set property to handle all these cases.
1454
- return SetProperty(&result, name, value, attributes);
1531
+ return SetProperty(&result, name, value, attributes, strict_mode);
1455
1532
  }
1456
1533
  // Add a new real property.
1457
- return AddProperty(name, value, attributes);
1534
+ return AddProperty(name, value, attributes, strict_mode);
1458
1535
  }
1459
1536
 
1460
1537
 
@@ -1491,7 +1568,8 @@ MaybeObject* JSObject::ConvertDescriptorToFieldAndMapTransition(
1491
1568
  return result;
1492
1569
  }
1493
1570
  // Do not add transitions to the map of "new Object()".
1494
- if (map() == Top::context()->global_context()->object_function()->map()) {
1571
+ if (map() == old_map->heap()->isolate()->context()->global_context()->
1572
+ object_function()->map()) {
1495
1573
  return result;
1496
1574
  }
1497
1575
 
@@ -1576,47 +1654,52 @@ MaybeObject* JSObject::ConvertDescriptorToField(String* name,
1576
1654
  MaybeObject* JSObject::SetPropertyWithInterceptor(
1577
1655
  String* name,
1578
1656
  Object* value,
1579
- PropertyAttributes attributes) {
1580
- HandleScope scope;
1657
+ PropertyAttributes attributes,
1658
+ StrictModeFlag strict_mode) {
1659
+ Isolate* isolate = GetIsolate();
1660
+ HandleScope scope(isolate);
1581
1661
  Handle<JSObject> this_handle(this);
1582
1662
  Handle<String> name_handle(name);
1583
- Handle<Object> value_handle(value);
1663
+ Handle<Object> value_handle(value, isolate);
1584
1664
  Handle<InterceptorInfo> interceptor(GetNamedInterceptor());
1585
1665
  if (!interceptor->setter()->IsUndefined()) {
1586
- LOG(ApiNamedPropertyAccess("interceptor-named-set", this, name));
1587
- CustomArguments args(interceptor->data(), this, this);
1666
+ LOG(isolate, ApiNamedPropertyAccess("interceptor-named-set", this, name));
1667
+ CustomArguments args(isolate, interceptor->data(), this, this);
1588
1668
  v8::AccessorInfo info(args.end());
1589
1669
  v8::NamedPropertySetter setter =
1590
1670
  v8::ToCData<v8::NamedPropertySetter>(interceptor->setter());
1591
1671
  v8::Handle<v8::Value> result;
1592
1672
  {
1593
1673
  // Leaving JavaScript.
1594
- VMState state(EXTERNAL);
1674
+ VMState state(isolate, EXTERNAL);
1595
1675
  Handle<Object> value_unhole(value->IsTheHole() ?
1596
- Heap::undefined_value() :
1597
- value);
1676
+ isolate->heap()->undefined_value() :
1677
+ value,
1678
+ isolate);
1598
1679
  result = setter(v8::Utils::ToLocal(name_handle),
1599
1680
  v8::Utils::ToLocal(value_unhole),
1600
1681
  info);
1601
1682
  }
1602
- RETURN_IF_SCHEDULED_EXCEPTION();
1683
+ RETURN_IF_SCHEDULED_EXCEPTION(isolate);
1603
1684
  if (!result.IsEmpty()) return *value_handle;
1604
1685
  }
1605
1686
  MaybeObject* raw_result =
1606
1687
  this_handle->SetPropertyPostInterceptor(*name_handle,
1607
1688
  *value_handle,
1608
- attributes);
1609
- RETURN_IF_SCHEDULED_EXCEPTION();
1689
+ attributes,
1690
+ strict_mode);
1691
+ RETURN_IF_SCHEDULED_EXCEPTION(isolate);
1610
1692
  return raw_result;
1611
1693
  }
1612
1694
 
1613
1695
 
1614
1696
  MaybeObject* JSObject::SetProperty(String* name,
1615
1697
  Object* value,
1616
- PropertyAttributes attributes) {
1698
+ PropertyAttributes attributes,
1699
+ StrictModeFlag strict_mode) {
1617
1700
  LookupResult result;
1618
1701
  LocalLookup(name, &result);
1619
- return SetProperty(&result, name, value, attributes);
1702
+ return SetProperty(&result, name, value, attributes, strict_mode);
1620
1703
  }
1621
1704
 
1622
1705
 
@@ -1624,12 +1707,13 @@ MaybeObject* JSObject::SetPropertyWithCallback(Object* structure,
1624
1707
  String* name,
1625
1708
  Object* value,
1626
1709
  JSObject* holder) {
1627
- HandleScope scope;
1710
+ Isolate* isolate = GetIsolate();
1711
+ HandleScope scope(isolate);
1628
1712
 
1629
1713
  // We should never get here to initialize a const with the hole
1630
1714
  // value since a const declaration would conflict with the setter.
1631
1715
  ASSERT(!value->IsTheHole());
1632
- Handle<Object> value_handle(value);
1716
+ Handle<Object> value_handle(value, isolate);
1633
1717
 
1634
1718
  // To accommodate both the old and the new api we switch on the
1635
1719
  // data structure used to store the callbacks. Eventually proxy
@@ -1638,7 +1722,7 @@ MaybeObject* JSObject::SetPropertyWithCallback(Object* structure,
1638
1722
  AccessorDescriptor* callback =
1639
1723
  reinterpret_cast<AccessorDescriptor*>(Proxy::cast(structure)->proxy());
1640
1724
  MaybeObject* obj = (callback->setter)(this, value, callback->data);
1641
- RETURN_IF_SCHEDULED_EXCEPTION();
1725
+ RETURN_IF_SCHEDULED_EXCEPTION(isolate);
1642
1726
  if (obj->IsFailure()) return obj;
1643
1727
  return *value_handle;
1644
1728
  }
@@ -1650,17 +1734,17 @@ MaybeObject* JSObject::SetPropertyWithCallback(Object* structure,
1650
1734
  v8::AccessorSetter call_fun = v8::ToCData<v8::AccessorSetter>(call_obj);
1651
1735
  if (call_fun == NULL) return value;
1652
1736
  Handle<String> key(name);
1653
- LOG(ApiNamedPropertyAccess("store", this, name));
1654
- CustomArguments args(data->data(), this, JSObject::cast(holder));
1737
+ LOG(isolate, ApiNamedPropertyAccess("store", this, name));
1738
+ CustomArguments args(isolate, data->data(), this, JSObject::cast(holder));
1655
1739
  v8::AccessorInfo info(args.end());
1656
1740
  {
1657
1741
  // Leaving JavaScript.
1658
- VMState state(EXTERNAL);
1742
+ VMState state(isolate, EXTERNAL);
1659
1743
  call_fun(v8::Utils::ToLocal(key),
1660
1744
  v8::Utils::ToLocal(value_handle),
1661
1745
  info);
1662
1746
  }
1663
- RETURN_IF_SCHEDULED_EXCEPTION();
1747
+ RETURN_IF_SCHEDULED_EXCEPTION(isolate);
1664
1748
  return *value_handle;
1665
1749
  }
1666
1750
 
@@ -1670,10 +1754,11 @@ MaybeObject* JSObject::SetPropertyWithCallback(Object* structure,
1670
1754
  return SetPropertyWithDefinedSetter(JSFunction::cast(setter), value);
1671
1755
  } else {
1672
1756
  Handle<String> key(name);
1673
- Handle<Object> holder_handle(holder);
1757
+ Handle<Object> holder_handle(holder, isolate);
1674
1758
  Handle<Object> args[2] = { key, holder_handle };
1675
- return Top::Throw(*Factory::NewTypeError("no_setter_in_callback",
1676
- HandleVector(args, 2)));
1759
+ return isolate->Throw(
1760
+ *isolate->factory()->NewTypeError("no_setter_in_callback",
1761
+ HandleVector(args, 2)));
1677
1762
  }
1678
1763
  }
1679
1764
 
@@ -1684,13 +1769,15 @@ MaybeObject* JSObject::SetPropertyWithCallback(Object* structure,
1684
1769
 
1685
1770
  MaybeObject* JSObject::SetPropertyWithDefinedSetter(JSFunction* setter,
1686
1771
  Object* value) {
1687
- Handle<Object> value_handle(value);
1688
- Handle<JSFunction> fun(JSFunction::cast(setter));
1689
- Handle<JSObject> self(this);
1772
+ Isolate* isolate = GetIsolate();
1773
+ Handle<Object> value_handle(value, isolate);
1774
+ Handle<JSFunction> fun(JSFunction::cast(setter), isolate);
1775
+ Handle<JSObject> self(this, isolate);
1690
1776
  #ifdef ENABLE_DEBUGGER_SUPPORT
1777
+ Debug* debug = isolate->debug();
1691
1778
  // Handle stepping into a setter if step into is active.
1692
- if (Debug::StepInActive()) {
1693
- Debug::HandleStepIn(fun, Handle<Object>::null(), 0, false);
1779
+ if (debug->StepInActive()) {
1780
+ debug->HandleStepIn(fun, Handle<Object>::null(), 0, false);
1694
1781
  }
1695
1782
  #endif
1696
1783
  bool has_pending_exception;
@@ -1704,8 +1791,9 @@ MaybeObject* JSObject::SetPropertyWithDefinedSetter(JSFunction* setter,
1704
1791
 
1705
1792
  void JSObject::LookupCallbackSetterInPrototypes(String* name,
1706
1793
  LookupResult* result) {
1794
+ Heap* heap = GetHeap();
1707
1795
  for (Object* pt = GetPrototype();
1708
- pt != Heap::null_value();
1796
+ pt != heap->null_value();
1709
1797
  pt = pt->GetPrototype()) {
1710
1798
  JSObject::cast(pt)->LocalLookupRealNamedProperty(name, result);
1711
1799
  if (result->IsProperty()) {
@@ -1725,8 +1813,9 @@ void JSObject::LookupCallbackSetterInPrototypes(String* name,
1725
1813
  MaybeObject* JSObject::SetElementWithCallbackSetterInPrototypes(uint32_t index,
1726
1814
  Object* value,
1727
1815
  bool* found) {
1816
+ Heap* heap = GetHeap();
1728
1817
  for (Object* pt = GetPrototype();
1729
- pt != Heap::null_value();
1818
+ pt != heap->null_value();
1730
1819
  pt = pt->GetPrototype()) {
1731
1820
  if (!JSObject::cast(pt)->HasDictionaryElements()) {
1732
1821
  continue;
@@ -1743,7 +1832,7 @@ MaybeObject* JSObject::SetElementWithCallbackSetterInPrototypes(uint32_t index,
1743
1832
  }
1744
1833
  }
1745
1834
  *found = false;
1746
- return Heap::the_hole_value();
1835
+ return heap->the_hole_value();
1747
1836
  }
1748
1837
 
1749
1838
 
@@ -1762,10 +1851,11 @@ void Map::LookupInDescriptors(JSObject* holder,
1762
1851
  String* name,
1763
1852
  LookupResult* result) {
1764
1853
  DescriptorArray* descriptors = instance_descriptors();
1765
- int number = DescriptorLookupCache::Lookup(descriptors, name);
1854
+ DescriptorLookupCache* cache = heap()->isolate()->descriptor_lookup_cache();
1855
+ int number = cache->Lookup(descriptors, name);
1766
1856
  if (number == DescriptorLookupCache::kAbsent) {
1767
1857
  number = descriptors->Search(name);
1768
- DescriptorLookupCache::Update(descriptors, name, number);
1858
+ cache->Update(descriptors, name, number);
1769
1859
  }
1770
1860
  if (number != DescriptorArray::kNotFound) {
1771
1861
  result->DescriptorResult(holder, descriptors->GetDetails(number), number);
@@ -1775,6 +1865,79 @@ void Map::LookupInDescriptors(JSObject* holder,
1775
1865
  }
1776
1866
 
1777
1867
 
1868
+ MaybeObject* Map::GetExternalArrayElementsMap(ExternalArrayType array_type,
1869
+ bool safe_to_add_transition) {
1870
+ Heap* current_heap = heap();
1871
+ DescriptorArray* descriptors = instance_descriptors();
1872
+ String* external_array_sentinel_name = current_heap->empty_symbol();
1873
+
1874
+ if (safe_to_add_transition) {
1875
+ // It's only safe to manipulate the descriptor array if it would be
1876
+ // safe to add a transition.
1877
+
1878
+ ASSERT(!is_shared()); // no transitions can be added to shared maps.
1879
+ // Check if the external array transition already exists.
1880
+ DescriptorLookupCache* cache =
1881
+ current_heap->isolate()->descriptor_lookup_cache();
1882
+ int index = cache->Lookup(descriptors, external_array_sentinel_name);
1883
+ if (index == DescriptorLookupCache::kAbsent) {
1884
+ index = descriptors->Search(external_array_sentinel_name);
1885
+ cache->Update(descriptors,
1886
+ external_array_sentinel_name,
1887
+ index);
1888
+ }
1889
+
1890
+ // If the transition already exists, check the type. If there is a match,
1891
+ // return it.
1892
+ if (index != DescriptorArray::kNotFound) {
1893
+ PropertyDetails details(PropertyDetails(descriptors->GetDetails(index)));
1894
+ if (details.type() == EXTERNAL_ARRAY_TRANSITION &&
1895
+ details.array_type() == array_type) {
1896
+ return descriptors->GetValue(index);
1897
+ } else {
1898
+ safe_to_add_transition = false;
1899
+ }
1900
+ }
1901
+ }
1902
+
1903
+ // No transition to an existing external array map. Make a new one.
1904
+ Object* obj;
1905
+ { MaybeObject* maybe_map = CopyDropTransitions();
1906
+ if (!maybe_map->ToObject(&obj)) return maybe_map;
1907
+ }
1908
+ Map* new_map = Map::cast(obj);
1909
+
1910
+ new_map->set_has_fast_elements(false);
1911
+ new_map->set_has_external_array_elements(true);
1912
+ GetIsolate()->counters()->map_to_external_array_elements()->Increment();
1913
+
1914
+ // Only remember the map transition if the object's map is NOT equal to the
1915
+ // global object_function's map and there is not an already existing
1916
+ // non-matching external array transition.
1917
+ bool allow_map_transition =
1918
+ safe_to_add_transition &&
1919
+ (GetIsolate()->context()->global_context()->object_function()->map() !=
1920
+ map());
1921
+ if (allow_map_transition) {
1922
+ // Allocate new instance descriptors for the old map with map transition.
1923
+ ExternalArrayTransitionDescriptor desc(external_array_sentinel_name,
1924
+ Map::cast(new_map),
1925
+ array_type);
1926
+ Object* new_descriptors;
1927
+ MaybeObject* maybe_new_descriptors = descriptors->CopyInsert(
1928
+ &desc,
1929
+ KEEP_TRANSITIONS);
1930
+ if (!maybe_new_descriptors->ToObject(&new_descriptors)) {
1931
+ return maybe_new_descriptors;
1932
+ }
1933
+ descriptors = DescriptorArray::cast(new_descriptors);
1934
+ set_instance_descriptors(descriptors);
1935
+ }
1936
+
1937
+ return new_map;
1938
+ }
1939
+
1940
+
1778
1941
  void JSObject::LocalLookupRealNamedProperty(String* name,
1779
1942
  LookupResult* result) {
1780
1943
  if (IsJSGlobalProxy()) {
@@ -1833,8 +1996,9 @@ void JSObject::LookupRealNamedProperty(String* name, LookupResult* result) {
1833
1996
 
1834
1997
  void JSObject::LookupRealNamedPropertyInPrototypes(String* name,
1835
1998
  LookupResult* result) {
1999
+ Heap* heap = GetHeap();
1836
2000
  for (Object* pt = GetPrototype();
1837
- pt != Heap::null_value();
2001
+ pt != heap->null_value();
1838
2002
  pt = JSObject::cast(pt)->GetPrototype()) {
1839
2003
  JSObject::cast(pt)->LocalLookupRealNamedProperty(name, result);
1840
2004
  if (result->IsProperty() && (result->type() != INTERCEPTOR)) return;
@@ -1888,7 +2052,8 @@ MaybeObject* JSObject::SetPropertyWithFailedAccessCheck(LookupResult* result,
1888
2052
 
1889
2053
  HandleScope scope;
1890
2054
  Handle<Object> value_handle(value);
1891
- Top::ReportFailedAccessCheck(this, v8::ACCESS_SET);
2055
+ Heap* heap = GetHeap();
2056
+ heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_SET);
1892
2057
  return *value_handle;
1893
2058
  }
1894
2059
 
@@ -1896,7 +2061,9 @@ MaybeObject* JSObject::SetPropertyWithFailedAccessCheck(LookupResult* result,
1896
2061
  MaybeObject* JSObject::SetProperty(LookupResult* result,
1897
2062
  String* name,
1898
2063
  Object* value,
1899
- PropertyAttributes attributes) {
2064
+ PropertyAttributes attributes,
2065
+ StrictModeFlag strict_mode) {
2066
+ Heap* heap = GetHeap();
1900
2067
  // Make sure that the top context does not change when doing callbacks or
1901
2068
  // interceptor calls.
1902
2069
  AssertNoContextChange ncc;
@@ -1906,7 +2073,7 @@ MaybeObject* JSObject::SetProperty(LookupResult* result,
1906
2073
  // reallocating them.
1907
2074
  if (!name->IsSymbol() && name->length() <= 2) {
1908
2075
  Object* symbol_version;
1909
- { MaybeObject* maybe_symbol_version = Heap::LookupSymbol(name);
2076
+ { MaybeObject* maybe_symbol_version = heap->LookupSymbol(name);
1910
2077
  if (maybe_symbol_version->ToObject(&symbol_version)) {
1911
2078
  name = String::cast(symbol_version);
1912
2079
  }
@@ -1915,7 +2082,7 @@ MaybeObject* JSObject::SetProperty(LookupResult* result,
1915
2082
 
1916
2083
  // Check access rights if needed.
1917
2084
  if (IsAccessCheckNeeded()
1918
- && !Top::MayNamedAccess(this, name, v8::ACCESS_SET)) {
2085
+ && !heap->isolate()->MayNamedAccess(this, name, v8::ACCESS_SET)) {
1919
2086
  return SetPropertyWithFailedAccessCheck(result, name, value, true);
1920
2087
  }
1921
2088
 
@@ -1923,7 +2090,8 @@ MaybeObject* JSObject::SetProperty(LookupResult* result,
1923
2090
  Object* proto = GetPrototype();
1924
2091
  if (proto->IsNull()) return value;
1925
2092
  ASSERT(proto->IsJSGlobalObject());
1926
- return JSObject::cast(proto)->SetProperty(result, name, value, attributes);
2093
+ return JSObject::cast(proto)->SetProperty(
2094
+ result, name, value, attributes, strict_mode);
1927
2095
  }
1928
2096
 
1929
2097
  if (!result->IsProperty() && !IsJSContextExtensionObject()) {
@@ -1940,9 +2108,20 @@ MaybeObject* JSObject::SetProperty(LookupResult* result,
1940
2108
  }
1941
2109
  if (!result->IsFound()) {
1942
2110
  // Neither properties nor transitions found.
1943
- return AddProperty(name, value, attributes);
2111
+ return AddProperty(name, value, attributes, strict_mode);
2112
+ }
2113
+ if (result->IsReadOnly() && result->IsProperty()) {
2114
+ if (strict_mode == kStrictMode) {
2115
+ HandleScope scope;
2116
+ Handle<String> key(name);
2117
+ Handle<Object> holder(this);
2118
+ Handle<Object> args[2] = { key, holder };
2119
+ return heap->isolate()->Throw(*heap->isolate()->factory()->NewTypeError(
2120
+ "strict_read_only_property", HandleVector(args, 2)));
2121
+ } else {
2122
+ return value;
2123
+ }
1944
2124
  }
1945
- if (result->IsReadOnly() && result->IsProperty()) return value;
1946
2125
  // This is a real property that is not read-only, or it is a
1947
2126
  // transition or null descriptor and there are no setters in the prototypes.
1948
2127
  switch (result->type()) {
@@ -1970,7 +2149,7 @@ MaybeObject* JSObject::SetProperty(LookupResult* result,
1970
2149
  value,
1971
2150
  result->holder());
1972
2151
  case INTERCEPTOR:
1973
- return SetPropertyWithInterceptor(name, value, attributes);
2152
+ return SetPropertyWithInterceptor(name, value, attributes, strict_mode);
1974
2153
  case CONSTANT_TRANSITION: {
1975
2154
  // If the same constant function is being added we can simply
1976
2155
  // transition to the target map.
@@ -1981,7 +2160,7 @@ MaybeObject* JSObject::SetProperty(LookupResult* result,
1981
2160
  ASSERT(target_descriptors->GetType(number) == CONSTANT_FUNCTION);
1982
2161
  JSFunction* function =
1983
2162
  JSFunction::cast(target_descriptors->GetValue(number));
1984
- ASSERT(!Heap::InNewSpace(function));
2163
+ ASSERT(!HEAP->InNewSpace(function));
1985
2164
  if (value == function) {
1986
2165
  set_map(target_map);
1987
2166
  return value;
@@ -1991,6 +2170,7 @@ MaybeObject* JSObject::SetProperty(LookupResult* result,
1991
2170
  return ConvertDescriptorToFieldAndMapTransition(name, value, attributes);
1992
2171
  }
1993
2172
  case NULL_DESCRIPTOR:
2173
+ case EXTERNAL_ARRAY_TRANSITION:
1994
2174
  return ConvertDescriptorToFieldAndMapTransition(name, value, attributes);
1995
2175
  default:
1996
2176
  UNREACHABLE();
@@ -2010,15 +2190,18 @@ MaybeObject* JSObject::SetLocalPropertyIgnoreAttributes(
2010
2190
  String* name,
2011
2191
  Object* value,
2012
2192
  PropertyAttributes attributes) {
2193
+
2013
2194
  // Make sure that the top context does not change when doing callbacks or
2014
2195
  // interceptor calls.
2015
2196
  AssertNoContextChange ncc;
2016
2197
  LookupResult result;
2017
2198
  LocalLookup(name, &result);
2018
2199
  // Check access rights if needed.
2019
- if (IsAccessCheckNeeded()
2020
- && !Top::MayNamedAccess(this, name, v8::ACCESS_SET)) {
2021
- return SetPropertyWithFailedAccessCheck(&result, name, value, false);
2200
+ if (IsAccessCheckNeeded()) {
2201
+ Heap* heap = GetHeap();
2202
+ if (!heap->isolate()->MayNamedAccess(this, name, v8::ACCESS_SET)) {
2203
+ return SetPropertyWithFailedAccessCheck(&result, name, value, false);
2204
+ }
2022
2205
  }
2023
2206
 
2024
2207
  if (IsJSGlobalProxy()) {
@@ -2034,7 +2217,7 @@ MaybeObject* JSObject::SetLocalPropertyIgnoreAttributes(
2034
2217
  // Check for accessor in prototype chain removed here in clone.
2035
2218
  if (!result.IsFound()) {
2036
2219
  // Neither properties nor transitions found.
2037
- return AddProperty(name, value, attributes);
2220
+ return AddProperty(name, value, attributes, kNonStrictMode);
2038
2221
  }
2039
2222
 
2040
2223
  PropertyDetails details = PropertyDetails(attributes, NORMAL);
@@ -2068,6 +2251,7 @@ MaybeObject* JSObject::SetLocalPropertyIgnoreAttributes(
2068
2251
  // if the value is a function.
2069
2252
  return ConvertDescriptorToFieldAndMapTransition(name, value, attributes);
2070
2253
  case NULL_DESCRIPTOR:
2254
+ case EXTERNAL_ARRAY_TRANSITION:
2071
2255
  return ConvertDescriptorToFieldAndMapTransition(name, value, attributes);
2072
2256
  default:
2073
2257
  UNREACHABLE();
@@ -2089,7 +2273,7 @@ PropertyAttributes JSObject::GetPropertyAttributePostInterceptor(
2089
2273
  if (continue_search) {
2090
2274
  // Continue searching via the prototype chain.
2091
2275
  Object* pt = GetPrototype();
2092
- if (pt != Heap::null_value()) {
2276
+ if (!pt->IsNull()) {
2093
2277
  return JSObject::cast(pt)->
2094
2278
  GetPropertyAttributeWithReceiver(receiver, name);
2095
2279
  }
@@ -2102,25 +2286,28 @@ PropertyAttributes JSObject::GetPropertyAttributeWithInterceptor(
2102
2286
  JSObject* receiver,
2103
2287
  String* name,
2104
2288
  bool continue_search) {
2289
+ Isolate* isolate = GetIsolate();
2290
+
2105
2291
  // Make sure that the top context does not change when doing
2106
2292
  // callbacks or interceptor calls.
2107
2293
  AssertNoContextChange ncc;
2108
2294
 
2109
- HandleScope scope;
2295
+ HandleScope scope(isolate);
2110
2296
  Handle<InterceptorInfo> interceptor(GetNamedInterceptor());
2111
2297
  Handle<JSObject> receiver_handle(receiver);
2112
2298
  Handle<JSObject> holder_handle(this);
2113
2299
  Handle<String> name_handle(name);
2114
- CustomArguments args(interceptor->data(), receiver, this);
2300
+ CustomArguments args(isolate, interceptor->data(), receiver, this);
2115
2301
  v8::AccessorInfo info(args.end());
2116
2302
  if (!interceptor->query()->IsUndefined()) {
2117
2303
  v8::NamedPropertyQuery query =
2118
2304
  v8::ToCData<v8::NamedPropertyQuery>(interceptor->query());
2119
- LOG(ApiNamedPropertyAccess("interceptor-named-has", *holder_handle, name));
2305
+ LOG(isolate,
2306
+ ApiNamedPropertyAccess("interceptor-named-has", *holder_handle, name));
2120
2307
  v8::Handle<v8::Integer> result;
2121
2308
  {
2122
2309
  // Leaving JavaScript.
2123
- VMState state(EXTERNAL);
2310
+ VMState state(isolate, EXTERNAL);
2124
2311
  result = query(v8::Utils::ToLocal(name_handle), info);
2125
2312
  }
2126
2313
  if (!result.IsEmpty()) {
@@ -2130,11 +2317,12 @@ PropertyAttributes JSObject::GetPropertyAttributeWithInterceptor(
2130
2317
  } else if (!interceptor->getter()->IsUndefined()) {
2131
2318
  v8::NamedPropertyGetter getter =
2132
2319
  v8::ToCData<v8::NamedPropertyGetter>(interceptor->getter());
2133
- LOG(ApiNamedPropertyAccess("interceptor-named-get-has", this, name));
2320
+ LOG(isolate,
2321
+ ApiNamedPropertyAccess("interceptor-named-get-has", this, name));
2134
2322
  v8::Handle<v8::Value> result;
2135
2323
  {
2136
2324
  // Leaving JavaScript.
2137
- VMState state(EXTERNAL);
2325
+ VMState state(isolate, EXTERNAL);
2138
2326
  result = getter(v8::Utils::ToLocal(name_handle), info);
2139
2327
  }
2140
2328
  if (!result.IsEmpty()) return DONT_ENUM;
@@ -2165,12 +2353,14 @@ PropertyAttributes JSObject::GetPropertyAttribute(JSObject* receiver,
2165
2353
  String* name,
2166
2354
  bool continue_search) {
2167
2355
  // Check access rights if needed.
2168
- if (IsAccessCheckNeeded() &&
2169
- !Top::MayNamedAccess(this, name, v8::ACCESS_HAS)) {
2170
- return GetPropertyAttributeWithFailedAccessCheck(receiver,
2171
- result,
2172
- name,
2173
- continue_search);
2356
+ if (IsAccessCheckNeeded()) {
2357
+ Heap* heap = GetHeap();
2358
+ if (!heap->isolate()->MayNamedAccess(this, name, v8::ACCESS_HAS)) {
2359
+ return GetPropertyAttributeWithFailedAccessCheck(receiver,
2360
+ result,
2361
+ name,
2362
+ continue_search);
2363
+ }
2174
2364
  }
2175
2365
  if (result->IsProperty()) {
2176
2366
  switch (result->type()) {
@@ -2206,6 +2396,7 @@ PropertyAttributes JSObject::GetLocalPropertyAttribute(String* name) {
2206
2396
 
2207
2397
  MaybeObject* NormalizedMapCache::Get(JSObject* obj,
2208
2398
  PropertyNormalizationMode mode) {
2399
+ Isolate* isolate = obj->GetIsolate();
2209
2400
  Map* fast = obj->map();
2210
2401
  int index = Hash(fast) % kEntries;
2211
2402
  Object* result = get(index);
@@ -2232,7 +2423,7 @@ MaybeObject* NormalizedMapCache::Get(JSObject* obj,
2232
2423
  if (!maybe_result->ToObject(&result)) return maybe_result;
2233
2424
  }
2234
2425
  set(index, result);
2235
- Counters::normalized_maps.Increment();
2426
+ isolate->counters()->normalized_maps()->Increment();
2236
2427
 
2237
2428
  return result;
2238
2429
  }
@@ -2292,7 +2483,7 @@ MaybeObject* JSObject::UpdateMapCodeCache(String* name, Code* code) {
2292
2483
  UNIQUE_NORMALIZED_MAP);
2293
2484
  if (!maybe_obj->ToObject(&obj)) return maybe_obj;
2294
2485
  }
2295
- Counters::normalized_maps.Increment();
2486
+ GetIsolate()->counters()->normalized_maps()->Increment();
2296
2487
 
2297
2488
  set_map(Map::cast(obj));
2298
2489
  }
@@ -2306,12 +2497,13 @@ MaybeObject* JSObject::NormalizeProperties(PropertyNormalizationMode mode,
2306
2497
 
2307
2498
  // The global object is always normalized.
2308
2499
  ASSERT(!IsGlobalObject());
2309
-
2310
2500
  // JSGlobalProxy must never be normalized
2311
2501
  ASSERT(!IsJSGlobalProxy());
2312
2502
 
2503
+ Map* map_of_this = map();
2504
+
2313
2505
  // Allocate new content.
2314
- int property_count = map()->NumberOfDescribedProperties();
2506
+ int property_count = map_of_this->NumberOfDescribedProperties();
2315
2507
  if (expected_additional_properties > 0) {
2316
2508
  property_count += expected_additional_properties;
2317
2509
  } else {
@@ -2324,7 +2516,7 @@ MaybeObject* JSObject::NormalizeProperties(PropertyNormalizationMode mode,
2324
2516
  }
2325
2517
  StringDictionary* dictionary = StringDictionary::cast(obj);
2326
2518
 
2327
- DescriptorArray* descs = map()->instance_descriptors();
2519
+ DescriptorArray* descs = map_of_this->instance_descriptors();
2328
2520
  for (int i = 0; i < descs->number_of_descriptors(); i++) {
2329
2521
  PropertyDetails details = descs->GetDetails(i);
2330
2522
  switch (details.type()) {
@@ -2374,12 +2566,15 @@ MaybeObject* JSObject::NormalizeProperties(PropertyNormalizationMode mode,
2374
2566
  }
2375
2567
  }
2376
2568
 
2569
+ Heap* current_heap = map_of_this->heap();
2570
+
2377
2571
  // Copy the next enumeration index from instance descriptor.
2378
- int index = map()->instance_descriptors()->NextEnumerationIndex();
2572
+ int index = map_of_this->instance_descriptors()->NextEnumerationIndex();
2379
2573
  dictionary->SetNextEnumerationIndex(index);
2380
2574
 
2381
- { MaybeObject* maybe_obj = Top::context()->global_context()->
2382
- normalized_map_cache()->Get(this, mode);
2575
+ { MaybeObject* maybe_obj =
2576
+ current_heap->isolate()->context()->global_context()->
2577
+ normalized_map_cache()->Get(this, mode);
2383
2578
  if (!maybe_obj->ToObject(&obj)) return maybe_obj;
2384
2579
  }
2385
2580
  Map* new_map = Map::cast(obj);
@@ -2389,16 +2584,17 @@ MaybeObject* JSObject::NormalizeProperties(PropertyNormalizationMode mode,
2389
2584
 
2390
2585
  // Resize the object in the heap if necessary.
2391
2586
  int new_instance_size = new_map->instance_size();
2392
- int instance_size_delta = map()->instance_size() - new_instance_size;
2587
+ int instance_size_delta = map_of_this->instance_size() - new_instance_size;
2393
2588
  ASSERT(instance_size_delta >= 0);
2394
- Heap::CreateFillerObjectAt(this->address() + new_instance_size,
2395
- instance_size_delta);
2589
+ current_heap->CreateFillerObjectAt(this->address() + new_instance_size,
2590
+ instance_size_delta);
2396
2591
 
2397
2592
  set_map(new_map);
2593
+ new_map->set_instance_descriptors(current_heap->empty_descriptor_array());
2398
2594
 
2399
2595
  set_properties(dictionary);
2400
2596
 
2401
- Counters::props_to_dictionary.Increment();
2597
+ current_heap->isolate()->counters()->props_to_dictionary()->Increment();
2402
2598
 
2403
2599
  #ifdef DEBUG
2404
2600
  if (FLAG_trace_normalization) {
@@ -2419,12 +2615,13 @@ MaybeObject* JSObject::TransformToFastProperties(int unused_property_fields) {
2419
2615
 
2420
2616
 
2421
2617
  MaybeObject* JSObject::NormalizeElements() {
2422
- ASSERT(!HasPixelElements() && !HasExternalArrayElements());
2618
+ ASSERT(!HasExternalArrayElements());
2423
2619
  if (HasDictionaryElements()) return this;
2424
- ASSERT(map()->has_fast_elements());
2620
+ Map* old_map = map();
2621
+ ASSERT(old_map->has_fast_elements());
2425
2622
 
2426
2623
  Object* obj;
2427
- { MaybeObject* maybe_obj = map()->GetSlowElementsMap();
2624
+ { MaybeObject* maybe_obj = old_map->GetSlowElementsMap();
2428
2625
  if (!maybe_obj->ToObject(&obj)) return maybe_obj;
2429
2626
  }
2430
2627
  Map* new_map = Map::cast(obj);
@@ -2459,7 +2656,8 @@ MaybeObject* JSObject::NormalizeElements() {
2459
2656
  set_map(new_map);
2460
2657
  set_elements(dictionary);
2461
2658
 
2462
- Counters::elements_to_dictionary.Increment();
2659
+ new_map->heap()->isolate()->counters()->elements_to_dictionary()->
2660
+ Increment();
2463
2661
 
2464
2662
  #ifdef DEBUG
2465
2663
  if (FLAG_trace_normalization) {
@@ -2477,7 +2675,7 @@ MaybeObject* JSObject::DeletePropertyPostInterceptor(String* name,
2477
2675
  // Check local property, ignore interceptor.
2478
2676
  LookupResult result;
2479
2677
  LocalLookupRealNamedProperty(name, &result);
2480
- if (!result.IsProperty()) return Heap::true_value();
2678
+ if (!result.IsProperty()) return GetHeap()->true_value();
2481
2679
 
2482
2680
  // Normalize object if needed.
2483
2681
  Object* obj;
@@ -2490,23 +2688,25 @@ MaybeObject* JSObject::DeletePropertyPostInterceptor(String* name,
2490
2688
 
2491
2689
 
2492
2690
  MaybeObject* JSObject::DeletePropertyWithInterceptor(String* name) {
2493
- HandleScope scope;
2691
+ Isolate* isolate = GetIsolate();
2692
+ HandleScope scope(isolate);
2494
2693
  Handle<InterceptorInfo> interceptor(GetNamedInterceptor());
2495
2694
  Handle<String> name_handle(name);
2496
2695
  Handle<JSObject> this_handle(this);
2497
2696
  if (!interceptor->deleter()->IsUndefined()) {
2498
2697
  v8::NamedPropertyDeleter deleter =
2499
2698
  v8::ToCData<v8::NamedPropertyDeleter>(interceptor->deleter());
2500
- LOG(ApiNamedPropertyAccess("interceptor-named-delete", *this_handle, name));
2501
- CustomArguments args(interceptor->data(), this, this);
2699
+ LOG(isolate,
2700
+ ApiNamedPropertyAccess("interceptor-named-delete", *this_handle, name));
2701
+ CustomArguments args(isolate, interceptor->data(), this, this);
2502
2702
  v8::AccessorInfo info(args.end());
2503
2703
  v8::Handle<v8::Boolean> result;
2504
2704
  {
2505
2705
  // Leaving JavaScript.
2506
- VMState state(EXTERNAL);
2706
+ VMState state(isolate, EXTERNAL);
2507
2707
  result = deleter(v8::Utils::ToLocal(name_handle), info);
2508
2708
  }
2509
- RETURN_IF_SCHEDULED_EXCEPTION();
2709
+ RETURN_IF_SCHEDULED_EXCEPTION(isolate);
2510
2710
  if (!result.IsEmpty()) {
2511
2711
  ASSERT(result->IsBoolean());
2512
2712
  return *v8::Utils::OpenHandle(*result);
@@ -2514,14 +2714,14 @@ MaybeObject* JSObject::DeletePropertyWithInterceptor(String* name) {
2514
2714
  }
2515
2715
  MaybeObject* raw_result =
2516
2716
  this_handle->DeletePropertyPostInterceptor(*name_handle, NORMAL_DELETION);
2517
- RETURN_IF_SCHEDULED_EXCEPTION();
2717
+ RETURN_IF_SCHEDULED_EXCEPTION(isolate);
2518
2718
  return raw_result;
2519
2719
  }
2520
2720
 
2521
2721
 
2522
2722
  MaybeObject* JSObject::DeleteElementPostInterceptor(uint32_t index,
2523
2723
  DeleteMode mode) {
2524
- ASSERT(!HasPixelElements() && !HasExternalArrayElements());
2724
+ ASSERT(!HasExternalArrayElements());
2525
2725
  switch (GetElementsKind()) {
2526
2726
  case FAST_ELEMENTS: {
2527
2727
  Object* obj;
@@ -2548,52 +2748,56 @@ MaybeObject* JSObject::DeleteElementPostInterceptor(uint32_t index,
2548
2748
  UNREACHABLE();
2549
2749
  break;
2550
2750
  }
2551
- return Heap::true_value();
2751
+ return GetHeap()->true_value();
2552
2752
  }
2553
2753
 
2554
2754
 
2555
2755
  MaybeObject* JSObject::DeleteElementWithInterceptor(uint32_t index) {
2756
+ Isolate* isolate = GetIsolate();
2757
+ Heap* heap = isolate->heap();
2556
2758
  // Make sure that the top context does not change when doing
2557
2759
  // callbacks or interceptor calls.
2558
2760
  AssertNoContextChange ncc;
2559
- HandleScope scope;
2761
+ HandleScope scope(isolate);
2560
2762
  Handle<InterceptorInfo> interceptor(GetIndexedInterceptor());
2561
- if (interceptor->deleter()->IsUndefined()) return Heap::false_value();
2763
+ if (interceptor->deleter()->IsUndefined()) return heap->false_value();
2562
2764
  v8::IndexedPropertyDeleter deleter =
2563
2765
  v8::ToCData<v8::IndexedPropertyDeleter>(interceptor->deleter());
2564
2766
  Handle<JSObject> this_handle(this);
2565
- LOG(ApiIndexedPropertyAccess("interceptor-indexed-delete", this, index));
2566
- CustomArguments args(interceptor->data(), this, this);
2767
+ LOG(isolate,
2768
+ ApiIndexedPropertyAccess("interceptor-indexed-delete", this, index));
2769
+ CustomArguments args(isolate, interceptor->data(), this, this);
2567
2770
  v8::AccessorInfo info(args.end());
2568
2771
  v8::Handle<v8::Boolean> result;
2569
2772
  {
2570
2773
  // Leaving JavaScript.
2571
- VMState state(EXTERNAL);
2774
+ VMState state(isolate, EXTERNAL);
2572
2775
  result = deleter(index, info);
2573
2776
  }
2574
- RETURN_IF_SCHEDULED_EXCEPTION();
2777
+ RETURN_IF_SCHEDULED_EXCEPTION(isolate);
2575
2778
  if (!result.IsEmpty()) {
2576
2779
  ASSERT(result->IsBoolean());
2577
2780
  return *v8::Utils::OpenHandle(*result);
2578
2781
  }
2579
2782
  MaybeObject* raw_result =
2580
2783
  this_handle->DeleteElementPostInterceptor(index, NORMAL_DELETION);
2581
- RETURN_IF_SCHEDULED_EXCEPTION();
2784
+ RETURN_IF_SCHEDULED_EXCEPTION(isolate);
2582
2785
  return raw_result;
2583
2786
  }
2584
2787
 
2585
2788
 
2586
2789
  MaybeObject* JSObject::DeleteElement(uint32_t index, DeleteMode mode) {
2790
+ Isolate* isolate = GetIsolate();
2587
2791
  // Check access rights if needed.
2588
2792
  if (IsAccessCheckNeeded() &&
2589
- !Top::MayIndexedAccess(this, index, v8::ACCESS_DELETE)) {
2590
- Top::ReportFailedAccessCheck(this, v8::ACCESS_DELETE);
2591
- return Heap::false_value();
2793
+ !isolate->MayIndexedAccess(this, index, v8::ACCESS_DELETE)) {
2794
+ isolate->ReportFailedAccessCheck(this, v8::ACCESS_DELETE);
2795
+ return isolate->heap()->false_value();
2592
2796
  }
2593
2797
 
2594
2798
  if (IsJSGlobalProxy()) {
2595
2799
  Object* proto = GetPrototype();
2596
- if (proto->IsNull()) return Heap::false_value();
2800
+ if (proto->IsNull()) return isolate->heap()->false_value();
2597
2801
  ASSERT(proto->IsJSGlobalObject());
2598
2802
  return JSGlobalObject::cast(proto)->DeleteElement(index, mode);
2599
2803
  }
@@ -2620,7 +2824,7 @@ MaybeObject* JSObject::DeleteElement(uint32_t index, DeleteMode mode) {
2620
2824
  }
2621
2825
  break;
2622
2826
  }
2623
- case PIXEL_ELEMENTS:
2827
+ case EXTERNAL_PIXEL_ELEMENTS:
2624
2828
  case EXTERNAL_BYTE_ELEMENTS:
2625
2829
  case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
2626
2830
  case EXTERNAL_SHORT_ELEMENTS:
@@ -2636,15 +2840,16 @@ MaybeObject* JSObject::DeleteElement(uint32_t index, DeleteMode mode) {
2636
2840
  int entry = dictionary->FindEntry(index);
2637
2841
  if (entry != NumberDictionary::kNotFound) {
2638
2842
  Object* result = dictionary->DeleteProperty(entry, mode);
2639
- if (mode == STRICT_DELETION && result == Heap::false_value()) {
2843
+ if (mode == STRICT_DELETION && result ==
2844
+ isolate->heap()->false_value()) {
2640
2845
  // In strict mode, deleting a non-configurable property throws
2641
2846
  // exception. dictionary->DeleteProperty will return false_value()
2642
2847
  // if a non-configurable property is being deleted.
2643
2848
  HandleScope scope;
2644
- Handle<Object> i = Factory::NewNumberFromUint(index);
2849
+ Handle<Object> i = isolate->factory()->NewNumberFromUint(index);
2645
2850
  Handle<Object> args[2] = { i, Handle<Object>(this) };
2646
- return Top::Throw(*Factory::NewTypeError("strict_delete_property",
2647
- HandleVector(args, 2)));
2851
+ return isolate->Throw(*isolate->factory()->NewTypeError(
2852
+ "strict_delete_property", HandleVector(args, 2)));
2648
2853
  }
2649
2854
  }
2650
2855
  break;
@@ -2653,24 +2858,25 @@ MaybeObject* JSObject::DeleteElement(uint32_t index, DeleteMode mode) {
2653
2858
  UNREACHABLE();
2654
2859
  break;
2655
2860
  }
2656
- return Heap::true_value();
2861
+ return isolate->heap()->true_value();
2657
2862
  }
2658
2863
 
2659
2864
 
2660
2865
  MaybeObject* JSObject::DeleteProperty(String* name, DeleteMode mode) {
2866
+ Isolate* isolate = GetIsolate();
2661
2867
  // ECMA-262, 3rd, 8.6.2.5
2662
2868
  ASSERT(name->IsString());
2663
2869
 
2664
2870
  // Check access rights if needed.
2665
2871
  if (IsAccessCheckNeeded() &&
2666
- !Top::MayNamedAccess(this, name, v8::ACCESS_DELETE)) {
2667
- Top::ReportFailedAccessCheck(this, v8::ACCESS_DELETE);
2668
- return Heap::false_value();
2872
+ !isolate->MayNamedAccess(this, name, v8::ACCESS_DELETE)) {
2873
+ isolate->ReportFailedAccessCheck(this, v8::ACCESS_DELETE);
2874
+ return isolate->heap()->false_value();
2669
2875
  }
2670
2876
 
2671
2877
  if (IsJSGlobalProxy()) {
2672
2878
  Object* proto = GetPrototype();
2673
- if (proto->IsNull()) return Heap::false_value();
2879
+ if (proto->IsNull()) return isolate->heap()->false_value();
2674
2880
  ASSERT(proto->IsJSGlobalObject());
2675
2881
  return JSGlobalObject::cast(proto)->DeleteProperty(name, mode);
2676
2882
  }
@@ -2681,17 +2887,17 @@ MaybeObject* JSObject::DeleteProperty(String* name, DeleteMode mode) {
2681
2887
  } else {
2682
2888
  LookupResult result;
2683
2889
  LocalLookup(name, &result);
2684
- if (!result.IsProperty()) return Heap::true_value();
2890
+ if (!result.IsProperty()) return isolate->heap()->true_value();
2685
2891
  // Ignore attributes if forcing a deletion.
2686
2892
  if (result.IsDontDelete() && mode != FORCE_DELETION) {
2687
2893
  if (mode == STRICT_DELETION) {
2688
2894
  // Deleting a non-configurable property in strict mode.
2689
- HandleScope scope;
2895
+ HandleScope scope(isolate);
2690
2896
  Handle<Object> args[2] = { Handle<Object>(name), Handle<Object>(this) };
2691
- return Top::Throw(*Factory::NewTypeError("strict_delete_property",
2692
- HandleVector(args, 2)));
2897
+ return isolate->Throw(*isolate->factory()->NewTypeError(
2898
+ "strict_delete_property", HandleVector(args, 2)));
2693
2899
  }
2694
- return Heap::false_value();
2900
+ return isolate->heap()->false_value();
2695
2901
  }
2696
2902
  // Check for interceptor.
2697
2903
  if (result.type() == INTERCEPTOR) {
@@ -2715,27 +2921,29 @@ MaybeObject* JSObject::DeleteProperty(String* name, DeleteMode mode) {
2715
2921
 
2716
2922
  // Check whether this object references another object.
2717
2923
  bool JSObject::ReferencesObject(Object* obj) {
2924
+ Map* map_of_this = map();
2925
+ Heap* heap = map_of_this->heap();
2718
2926
  AssertNoAllocation no_alloc;
2719
2927
 
2720
2928
  // Is the object the constructor for this object?
2721
- if (map()->constructor() == obj) {
2929
+ if (map_of_this->constructor() == obj) {
2722
2930
  return true;
2723
2931
  }
2724
2932
 
2725
2933
  // Is the object the prototype for this object?
2726
- if (map()->prototype() == obj) {
2934
+ if (map_of_this->prototype() == obj) {
2727
2935
  return true;
2728
2936
  }
2729
2937
 
2730
2938
  // Check if the object is among the named properties.
2731
2939
  Object* key = SlowReverseLookup(obj);
2732
- if (key != Heap::undefined_value()) {
2940
+ if (!key->IsUndefined()) {
2733
2941
  return true;
2734
2942
  }
2735
2943
 
2736
2944
  // Check if the object is among the indexed properties.
2737
2945
  switch (GetElementsKind()) {
2738
- case PIXEL_ELEMENTS:
2946
+ case EXTERNAL_PIXEL_ELEMENTS:
2739
2947
  case EXTERNAL_BYTE_ELEMENTS:
2740
2948
  case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
2741
2949
  case EXTERNAL_SHORT_ELEMENTS:
@@ -2760,7 +2968,7 @@ bool JSObject::ReferencesObject(Object* obj) {
2760
2968
  }
2761
2969
  case DICTIONARY_ELEMENTS: {
2762
2970
  key = element_dictionary()->SlowReverseLookup(obj);
2763
- if (key != Heap::undefined_value()) {
2971
+ if (!key->IsUndefined()) {
2764
2972
  return true;
2765
2973
  }
2766
2974
  break;
@@ -2774,7 +2982,8 @@ bool JSObject::ReferencesObject(Object* obj) {
2774
2982
  if (IsJSFunction()) {
2775
2983
  // Get the constructor function for arguments array.
2776
2984
  JSObject* arguments_boilerplate =
2777
- Top::context()->global_context()->arguments_boilerplate();
2985
+ heap->isolate()->context()->global_context()->
2986
+ arguments_boilerplate();
2778
2987
  JSFunction* arguments_function =
2779
2988
  JSFunction::cast(arguments_boilerplate->map()->constructor());
2780
2989
 
@@ -2813,10 +3022,13 @@ bool JSObject::ReferencesObject(Object* obj) {
2813
3022
 
2814
3023
 
2815
3024
  MaybeObject* JSObject::PreventExtensions() {
3025
+ Isolate* isolate = GetIsolate();
2816
3026
  if (IsAccessCheckNeeded() &&
2817
- !Top::MayNamedAccess(this, Heap::undefined_value(), v8::ACCESS_KEYS)) {
2818
- Top::ReportFailedAccessCheck(this, v8::ACCESS_KEYS);
2819
- return Heap::false_value();
3027
+ !isolate->MayNamedAccess(this,
3028
+ isolate->heap()->undefined_value(),
3029
+ v8::ACCESS_KEYS)) {
3030
+ isolate->ReportFailedAccessCheck(this, v8::ACCESS_KEYS);
3031
+ return isolate->heap()->false_value();
2820
3032
  }
2821
3033
 
2822
3034
  if (IsJSGlobalProxy()) {
@@ -2855,8 +3067,9 @@ MaybeObject* JSObject::PreventExtensions() {
2855
3067
  // - This object has no elements.
2856
3068
  // - No prototype has enumerable properties/elements.
2857
3069
  bool JSObject::IsSimpleEnum() {
3070
+ Heap* heap = GetHeap();
2858
3071
  for (Object* o = this;
2859
- o != Heap::null_value();
3072
+ o != heap->null_value();
2860
3073
  o = JSObject::cast(o)->GetPrototype()) {
2861
3074
  JSObject* curr = JSObject::cast(o);
2862
3075
  if (!curr->map()->instance_descriptors()->HasEnumCache()) return false;
@@ -2922,6 +3135,8 @@ AccessorDescriptor* Map::FindAccessor(String* name) {
2922
3135
  void JSObject::LocalLookup(String* name, LookupResult* result) {
2923
3136
  ASSERT(name->IsString());
2924
3137
 
3138
+ Heap* heap = GetHeap();
3139
+
2925
3140
  if (IsJSGlobalProxy()) {
2926
3141
  Object* proto = GetPrototype();
2927
3142
  if (proto->IsNull()) return result->NotFound();
@@ -2936,13 +3151,14 @@ void JSObject::LocalLookup(String* name, LookupResult* result) {
2936
3151
  }
2937
3152
 
2938
3153
  // Check __proto__ before interceptor.
2939
- if (name->Equals(Heap::Proto_symbol()) && !IsJSContextExtensionObject()) {
3154
+ if (name->Equals(heap->Proto_symbol()) &&
3155
+ !IsJSContextExtensionObject()) {
2940
3156
  result->ConstantResult(this);
2941
3157
  return;
2942
3158
  }
2943
3159
 
2944
3160
  // Check for lookup interceptor except when bootstrapping.
2945
- if (HasNamedInterceptor() && !Bootstrapper::IsActive()) {
3161
+ if (HasNamedInterceptor() && !heap->isolate()->bootstrapper()->IsActive()) {
2946
3162
  result->InterceptorResult(this);
2947
3163
  return;
2948
3164
  }
@@ -2953,8 +3169,9 @@ void JSObject::LocalLookup(String* name, LookupResult* result) {
2953
3169
 
2954
3170
  void JSObject::Lookup(String* name, LookupResult* result) {
2955
3171
  // Ecma-262 3rd 8.6.2.4
3172
+ Heap* heap = GetHeap();
2956
3173
  for (Object* current = this;
2957
- current != Heap::null_value();
3174
+ current != heap->null_value();
2958
3175
  current = JSObject::cast(current)->GetPrototype()) {
2959
3176
  JSObject::cast(current)->LocalLookup(name, result);
2960
3177
  if (result->IsProperty()) return;
@@ -2965,8 +3182,9 @@ void JSObject::Lookup(String* name, LookupResult* result) {
2965
3182
 
2966
3183
  // Search object and it's prototype chain for callback properties.
2967
3184
  void JSObject::LookupCallback(String* name, LookupResult* result) {
3185
+ Heap* heap = GetHeap();
2968
3186
  for (Object* current = this;
2969
- current != Heap::null_value();
3187
+ current != heap->null_value();
2970
3188
  current = JSObject::cast(current)->GetPrototype()) {
2971
3189
  JSObject::cast(current)->LocalLookupRealNamedProperty(name, result);
2972
3190
  if (result->IsProperty() && result->type() == CALLBACKS) return;
@@ -2977,6 +3195,7 @@ void JSObject::LookupCallback(String* name, LookupResult* result) {
2977
3195
 
2978
3196
  MaybeObject* JSObject::DefineGetterSetter(String* name,
2979
3197
  PropertyAttributes attributes) {
3198
+ Heap* heap = GetHeap();
2980
3199
  // Make sure that the top context does not change when doing callbacks or
2981
3200
  // interceptor calls.
2982
3201
  AssertNoContextChange ncc;
@@ -2985,7 +3204,7 @@ MaybeObject* JSObject::DefineGetterSetter(String* name,
2985
3204
  name->TryFlatten();
2986
3205
 
2987
3206
  if (!CanSetCallback(name)) {
2988
- return Heap::undefined_value();
3207
+ return heap->undefined_value();
2989
3208
  }
2990
3209
 
2991
3210
  uint32_t index = 0;
@@ -2995,7 +3214,7 @@ MaybeObject* JSObject::DefineGetterSetter(String* name,
2995
3214
  switch (GetElementsKind()) {
2996
3215
  case FAST_ELEMENTS:
2997
3216
  break;
2998
- case PIXEL_ELEMENTS:
3217
+ case EXTERNAL_PIXEL_ELEMENTS:
2999
3218
  case EXTERNAL_BYTE_ELEMENTS:
3000
3219
  case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
3001
3220
  case EXTERNAL_SHORT_ELEMENTS:
@@ -3005,7 +3224,7 @@ MaybeObject* JSObject::DefineGetterSetter(String* name,
3005
3224
  case EXTERNAL_FLOAT_ELEMENTS:
3006
3225
  // Ignore getters and setters on pixel and external array
3007
3226
  // elements.
3008
- return Heap::undefined_value();
3227
+ return heap->undefined_value();
3009
3228
  case DICTIONARY_ELEMENTS: {
3010
3229
  // Lookup the index.
3011
3230
  NumberDictionary* dictionary = element_dictionary();
@@ -3013,7 +3232,7 @@ MaybeObject* JSObject::DefineGetterSetter(String* name,
3013
3232
  if (entry != NumberDictionary::kNotFound) {
3014
3233
  Object* result = dictionary->ValueAt(entry);
3015
3234
  PropertyDetails details = dictionary->DetailsAt(entry);
3016
- if (details.IsReadOnly()) return Heap::undefined_value();
3235
+ if (details.IsReadOnly()) return heap->undefined_value();
3017
3236
  if (details.type() == CALLBACKS) {
3018
3237
  if (result->IsFixedArray()) {
3019
3238
  return result;
@@ -3032,7 +3251,7 @@ MaybeObject* JSObject::DefineGetterSetter(String* name,
3032
3251
  LookupResult result;
3033
3252
  LocalLookup(name, &result);
3034
3253
  if (result.IsProperty()) {
3035
- if (result.IsReadOnly()) return Heap::undefined_value();
3254
+ if (result.IsReadOnly()) return heap->undefined_value();
3036
3255
  if (result.type() == CALLBACKS) {
3037
3256
  Object* obj = result.GetCallbackObject();
3038
3257
  // Need to preserve old getters/setters.
@@ -3046,7 +3265,7 @@ MaybeObject* JSObject::DefineGetterSetter(String* name,
3046
3265
 
3047
3266
  // Allocate the fixed array to hold getter and setter.
3048
3267
  Object* structure;
3049
- { MaybeObject* maybe_structure = Heap::AllocateFixedArray(2, TENURED);
3268
+ { MaybeObject* maybe_structure = heap->AllocateFixedArray(2, TENURED);
3050
3269
  if (!maybe_structure->ToObject(&structure)) return maybe_structure;
3051
3270
  }
3052
3271
 
@@ -3060,7 +3279,7 @@ MaybeObject* JSObject::DefineGetterSetter(String* name,
3060
3279
 
3061
3280
  bool JSObject::CanSetCallback(String* name) {
3062
3281
  ASSERT(!IsAccessCheckNeeded()
3063
- || Top::MayNamedAccess(this, name, v8::ACCESS_SET));
3282
+ || Isolate::Current()->MayNamedAccess(this, name, v8::ACCESS_SET));
3064
3283
 
3065
3284
  // Check if there is an API defined callback object which prohibits
3066
3285
  // callback overwriting in this object or it's prototype chain.
@@ -3157,11 +3376,12 @@ MaybeObject* JSObject::DefineAccessor(String* name,
3157
3376
  Object* fun,
3158
3377
  PropertyAttributes attributes) {
3159
3378
  ASSERT(fun->IsJSFunction() || fun->IsUndefined());
3379
+ Isolate* isolate = GetIsolate();
3160
3380
  // Check access rights if needed.
3161
3381
  if (IsAccessCheckNeeded() &&
3162
- !Top::MayNamedAccess(this, name, v8::ACCESS_SET)) {
3163
- Top::ReportFailedAccessCheck(this, v8::ACCESS_SET);
3164
- return Heap::undefined_value();
3382
+ !isolate->MayNamedAccess(this, name, v8::ACCESS_SET)) {
3383
+ isolate->ReportFailedAccessCheck(this, v8::ACCESS_SET);
3384
+ return isolate->heap()->undefined_value();
3165
3385
  }
3166
3386
 
3167
3387
  if (IsJSGlobalProxy()) {
@@ -3183,12 +3403,13 @@ MaybeObject* JSObject::DefineAccessor(String* name,
3183
3403
 
3184
3404
 
3185
3405
  MaybeObject* JSObject::DefineAccessor(AccessorInfo* info) {
3406
+ Isolate* isolate = GetIsolate();
3186
3407
  String* name = String::cast(info->name());
3187
3408
  // Check access rights if needed.
3188
3409
  if (IsAccessCheckNeeded() &&
3189
- !Top::MayNamedAccess(this, name, v8::ACCESS_SET)) {
3190
- Top::ReportFailedAccessCheck(this, v8::ACCESS_SET);
3191
- return Heap::undefined_value();
3410
+ !isolate->MayNamedAccess(this, name, v8::ACCESS_SET)) {
3411
+ isolate->ReportFailedAccessCheck(this, v8::ACCESS_SET);
3412
+ return isolate->heap()->undefined_value();
3192
3413
  }
3193
3414
 
3194
3415
  if (IsJSGlobalProxy()) {
@@ -3206,20 +3427,20 @@ MaybeObject* JSObject::DefineAccessor(AccessorInfo* info) {
3206
3427
  name->TryFlatten();
3207
3428
 
3208
3429
  if (!CanSetCallback(name)) {
3209
- return Heap::undefined_value();
3430
+ return isolate->heap()->undefined_value();
3210
3431
  }
3211
3432
 
3212
3433
  uint32_t index = 0;
3213
3434
  bool is_element = name->AsArrayIndex(&index);
3214
3435
 
3215
3436
  if (is_element) {
3216
- if (IsJSArray()) return Heap::undefined_value();
3437
+ if (IsJSArray()) return isolate->heap()->undefined_value();
3217
3438
 
3218
3439
  // Accessors overwrite previous callbacks (cf. with getters/setters).
3219
3440
  switch (GetElementsKind()) {
3220
3441
  case FAST_ELEMENTS:
3221
3442
  break;
3222
- case PIXEL_ELEMENTS:
3443
+ case EXTERNAL_PIXEL_ELEMENTS:
3223
3444
  case EXTERNAL_BYTE_ELEMENTS:
3224
3445
  case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
3225
3446
  case EXTERNAL_SHORT_ELEMENTS:
@@ -3229,7 +3450,7 @@ MaybeObject* JSObject::DefineAccessor(AccessorInfo* info) {
3229
3450
  case EXTERNAL_FLOAT_ELEMENTS:
3230
3451
  // Ignore getters and setters on pixel and external array
3231
3452
  // elements.
3232
- return Heap::undefined_value();
3453
+ return isolate->heap()->undefined_value();
3233
3454
  case DICTIONARY_ELEMENTS:
3234
3455
  break;
3235
3456
  default:
@@ -3249,7 +3470,7 @@ MaybeObject* JSObject::DefineAccessor(AccessorInfo* info) {
3249
3470
  // ES5 forbids turning a property into an accessor if it's not
3250
3471
  // configurable (that is IsDontDelete in ES3 and v8), see 8.6.1 (Table 5).
3251
3472
  if (result.IsProperty() && (result.IsReadOnly() || result.IsDontDelete())) {
3252
- return Heap::undefined_value();
3473
+ return isolate->heap()->undefined_value();
3253
3474
  }
3254
3475
  Object* ok;
3255
3476
  { MaybeObject* maybe_ok =
@@ -3263,15 +3484,17 @@ MaybeObject* JSObject::DefineAccessor(AccessorInfo* info) {
3263
3484
 
3264
3485
 
3265
3486
  Object* JSObject::LookupAccessor(String* name, bool is_getter) {
3487
+ Heap* heap = GetHeap();
3488
+
3266
3489
  // Make sure that the top context does not change when doing callbacks or
3267
3490
  // interceptor calls.
3268
3491
  AssertNoContextChange ncc;
3269
3492
 
3270
3493
  // Check access rights if needed.
3271
3494
  if (IsAccessCheckNeeded() &&
3272
- !Top::MayNamedAccess(this, name, v8::ACCESS_HAS)) {
3273
- Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS);
3274
- return Heap::undefined_value();
3495
+ !heap->isolate()->MayNamedAccess(this, name, v8::ACCESS_HAS)) {
3496
+ heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
3497
+ return heap->undefined_value();
3275
3498
  }
3276
3499
 
3277
3500
  // Make the lookup and include prototypes.
@@ -3279,7 +3502,7 @@ Object* JSObject::LookupAccessor(String* name, bool is_getter) {
3279
3502
  uint32_t index = 0;
3280
3503
  if (name->AsArrayIndex(&index)) {
3281
3504
  for (Object* obj = this;
3282
- obj != Heap::null_value();
3505
+ obj != heap->null_value();
3283
3506
  obj = JSObject::cast(obj)->GetPrototype()) {
3284
3507
  JSObject* js_object = JSObject::cast(obj);
3285
3508
  if (js_object->HasDictionaryElements()) {
@@ -3298,12 +3521,12 @@ Object* JSObject::LookupAccessor(String* name, bool is_getter) {
3298
3521
  }
3299
3522
  } else {
3300
3523
  for (Object* obj = this;
3301
- obj != Heap::null_value();
3524
+ obj != heap->null_value();
3302
3525
  obj = JSObject::cast(obj)->GetPrototype()) {
3303
3526
  LookupResult result;
3304
3527
  JSObject::cast(obj)->LocalLookup(name, &result);
3305
3528
  if (result.IsProperty()) {
3306
- if (result.IsReadOnly()) return Heap::undefined_value();
3529
+ if (result.IsReadOnly()) return heap->undefined_value();
3307
3530
  if (result.type() == CALLBACKS) {
3308
3531
  Object* obj = result.GetCallbackObject();
3309
3532
  if (obj->IsFixedArray()) {
@@ -3313,7 +3536,7 @@ Object* JSObject::LookupAccessor(String* name, bool is_getter) {
3313
3536
  }
3314
3537
  }
3315
3538
  }
3316
- return Heap::undefined_value();
3539
+ return heap->undefined_value();
3317
3540
  }
3318
3541
 
3319
3542
 
@@ -3331,7 +3554,7 @@ Object* JSObject::SlowReverseLookup(Object* value) {
3331
3554
  }
3332
3555
  }
3333
3556
  }
3334
- return Heap::undefined_value();
3557
+ return GetHeap()->undefined_value();
3335
3558
  } else {
3336
3559
  return property_dictionary()->SlowReverseLookup(value);
3337
3560
  }
@@ -3339,9 +3562,10 @@ Object* JSObject::SlowReverseLookup(Object* value) {
3339
3562
 
3340
3563
 
3341
3564
  MaybeObject* Map::CopyDropDescriptors() {
3565
+ Heap* heap = GetHeap();
3342
3566
  Object* result;
3343
3567
  { MaybeObject* maybe_result =
3344
- Heap::AllocateMap(instance_type(), instance_size());
3568
+ heap->AllocateMap(instance_type(), instance_size());
3345
3569
  if (!maybe_result->ToObject(&result)) return maybe_result;
3346
3570
  }
3347
3571
  Map::cast(result)->set_prototype(prototype());
@@ -3351,7 +3575,8 @@ MaybeObject* Map::CopyDropDescriptors() {
3351
3575
  // pointing to the same transition which is bad because the garbage
3352
3576
  // collector relies on being able to reverse pointers from transitions
3353
3577
  // to maps. If properties need to be retained use CopyDropTransitions.
3354
- Map::cast(result)->set_instance_descriptors(Heap::empty_descriptor_array());
3578
+ Map::cast(result)->set_instance_descriptors(
3579
+ heap->empty_descriptor_array());
3355
3580
  // Please note instance_type and instance_size are set when allocated.
3356
3581
  Map::cast(result)->set_inobject_properties(inobject_properties());
3357
3582
  Map::cast(result)->set_unused_property_fields(unused_property_fields());
@@ -3374,7 +3599,7 @@ MaybeObject* Map::CopyDropDescriptors() {
3374
3599
  Map::cast(result)->set_bit_field(bit_field());
3375
3600
  Map::cast(result)->set_bit_field2(bit_field2());
3376
3601
  Map::cast(result)->set_is_shared(false);
3377
- Map::cast(result)->ClearCodeCache();
3602
+ Map::cast(result)->ClearCodeCache(heap);
3378
3603
  return result;
3379
3604
  }
3380
3605
 
@@ -3388,7 +3613,7 @@ MaybeObject* Map::CopyNormalized(PropertyNormalizationMode mode,
3388
3613
 
3389
3614
  Object* result;
3390
3615
  { MaybeObject* maybe_result =
3391
- Heap::AllocateMap(instance_type(), new_instance_size);
3616
+ GetHeap()->AllocateMap(instance_type(), new_instance_size);
3392
3617
  if (!maybe_result->ToObject(&result)) return maybe_result;
3393
3618
  }
3394
3619
 
@@ -3433,7 +3658,7 @@ MaybeObject* Map::UpdateCodeCache(String* name, Code* code) {
3433
3658
  // Allocate the code cache if not present.
3434
3659
  if (code_cache()->IsFixedArray()) {
3435
3660
  Object* result;
3436
- { MaybeObject* maybe_result = Heap::AllocateCodeCache();
3661
+ { MaybeObject* maybe_result = code->heap()->AllocateCodeCache();
3437
3662
  if (!maybe_result->ToObject(&result)) return maybe_result;
3438
3663
  }
3439
3664
  set_code_cache(result);
@@ -3449,7 +3674,7 @@ Object* Map::FindInCodeCache(String* name, Code::Flags flags) {
3449
3674
  if (!code_cache()->IsFixedArray()) {
3450
3675
  return CodeCache::cast(code_cache())->Lookup(name, flags);
3451
3676
  } else {
3452
- return Heap::undefined_value();
3677
+ return GetHeap()->undefined_value();
3453
3678
  }
3454
3679
  }
3455
3680
 
@@ -3473,12 +3698,13 @@ void Map::RemoveFromCodeCache(String* name, Code* code, int index) {
3473
3698
 
3474
3699
  void Map::TraverseTransitionTree(TraverseCallback callback, void* data) {
3475
3700
  Map* current = this;
3476
- while (current != Heap::meta_map()) {
3701
+ Map* meta_map = heap()->meta_map();
3702
+ while (current != meta_map) {
3477
3703
  DescriptorArray* d = reinterpret_cast<DescriptorArray*>(
3478
3704
  *RawField(current, Map::kInstanceDescriptorsOffset));
3479
- if (d == Heap::empty_descriptor_array()) {
3705
+ if (d == heap()->empty_descriptor_array()) {
3480
3706
  Map* prev = current->map();
3481
- current->set_map(Heap::meta_map());
3707
+ current->set_map(meta_map);
3482
3708
  callback(current, data);
3483
3709
  current = prev;
3484
3710
  continue;
@@ -3503,9 +3729,9 @@ void Map::TraverseTransitionTree(TraverseCallback callback, void* data) {
3503
3729
  }
3504
3730
  }
3505
3731
  if (!map_done) continue;
3506
- *map_or_index_field = Heap::fixed_array_map();
3732
+ *map_or_index_field = heap()->fixed_array_map();
3507
3733
  Map* prev = current->map();
3508
- current->set_map(Heap::meta_map());
3734
+ current->set_map(meta_map);
3509
3735
  callback(current, data);
3510
3736
  current = prev;
3511
3737
  }
@@ -3632,7 +3858,7 @@ Object* CodeCache::LookupDefaultCache(String* name, Code::Flags flags) {
3632
3858
  }
3633
3859
  }
3634
3860
  }
3635
- return Heap::undefined_value();
3861
+ return GetHeap()->undefined_value();
3636
3862
  }
3637
3863
 
3638
3864
 
@@ -3641,7 +3867,7 @@ Object* CodeCache::LookupNormalTypeCache(String* name, Code::Flags flags) {
3641
3867
  CodeCacheHashTable* cache = CodeCacheHashTable::cast(normal_type_cache());
3642
3868
  return cache->Lookup(name, flags);
3643
3869
  } else {
3644
- return Heap::undefined_value();
3870
+ return GetHeap()->undefined_value();
3645
3871
  }
3646
3872
  }
3647
3873
 
@@ -3723,7 +3949,7 @@ class CodeCacheHashTableKey : public HashTableKey {
3723
3949
  MUST_USE_RESULT MaybeObject* AsObject() {
3724
3950
  ASSERT(code_ != NULL);
3725
3951
  Object* obj;
3726
- { MaybeObject* maybe_obj = Heap::AllocateFixedArray(2);
3952
+ { MaybeObject* maybe_obj = code_->heap()->AllocateFixedArray(2);
3727
3953
  if (!maybe_obj->ToObject(&obj)) return maybe_obj;
3728
3954
  }
3729
3955
  FixedArray* pair = FixedArray::cast(obj);
@@ -3742,7 +3968,7 @@ class CodeCacheHashTableKey : public HashTableKey {
3742
3968
  Object* CodeCacheHashTable::Lookup(String* name, Code::Flags flags) {
3743
3969
  CodeCacheHashTableKey key(name, flags);
3744
3970
  int entry = FindEntry(&key);
3745
- if (entry == kNotFound) return Heap::undefined_value();
3971
+ if (entry == kNotFound) return GetHeap()->undefined_value();
3746
3972
  return get(EntryToIndex(entry) + 1);
3747
3973
  }
3748
3974
 
@@ -3779,8 +4005,9 @@ int CodeCacheHashTable::GetIndex(String* name, Code::Flags flags) {
3779
4005
 
3780
4006
  void CodeCacheHashTable::RemoveByIndex(int index) {
3781
4007
  ASSERT(index >= 0);
3782
- set(EntryToIndex(index), Heap::null_value());
3783
- set(EntryToIndex(index) + 1, Heap::null_value());
4008
+ Heap* heap = GetHeap();
4009
+ set(EntryToIndex(index), heap->null_value());
4010
+ set(EntryToIndex(index) + 1, heap->null_value());
3784
4011
  ElementRemoved();
3785
4012
  }
3786
4013
 
@@ -3800,7 +4027,7 @@ static bool HasKey(FixedArray* array, Object* key) {
3800
4027
 
3801
4028
 
3802
4029
  MaybeObject* FixedArray::AddKeysFromJSArray(JSArray* array) {
3803
- ASSERT(!array->HasPixelElements() && !array->HasExternalArrayElements());
4030
+ ASSERT(!array->HasExternalArrayElements());
3804
4031
  switch (array->GetElementsKind()) {
3805
4032
  case JSObject::FAST_ELEMENTS:
3806
4033
  return UnionOfKeys(FixedArray::cast(array->elements()));
@@ -3810,7 +4037,7 @@ MaybeObject* FixedArray::AddKeysFromJSArray(JSArray* array) {
3810
4037
 
3811
4038
  // Allocate a temporary fixed array.
3812
4039
  Object* object;
3813
- { MaybeObject* maybe_object = Heap::AllocateFixedArray(size);
4040
+ { MaybeObject* maybe_object = GetHeap()->AllocateFixedArray(size);
3814
4041
  if (!maybe_object->ToObject(&object)) return maybe_object;
3815
4042
  }
3816
4043
  FixedArray* key_array = FixedArray::cast(object);
@@ -3830,7 +4057,7 @@ MaybeObject* FixedArray::AddKeysFromJSArray(JSArray* array) {
3830
4057
  UNREACHABLE();
3831
4058
  }
3832
4059
  UNREACHABLE();
3833
- return Heap::null_value(); // Failure case needs to "return" a value.
4060
+ return GetHeap()->null_value(); // Failure case needs to "return" a value.
3834
4061
  }
3835
4062
 
3836
4063
 
@@ -3860,7 +4087,7 @@ MaybeObject* FixedArray::UnionOfKeys(FixedArray* other) {
3860
4087
 
3861
4088
  // Allocate the result
3862
4089
  Object* obj;
3863
- { MaybeObject* maybe_obj = Heap::AllocateFixedArray(len0 + extra);
4090
+ { MaybeObject* maybe_obj = GetHeap()->AllocateFixedArray(len0 + extra);
3864
4091
  if (!maybe_obj->ToObject(&obj)) return maybe_obj;
3865
4092
  }
3866
4093
  // Fill in the content
@@ -3889,9 +4116,10 @@ MaybeObject* FixedArray::UnionOfKeys(FixedArray* other) {
3889
4116
 
3890
4117
 
3891
4118
  MaybeObject* FixedArray::CopySize(int new_length) {
3892
- if (new_length == 0) return Heap::empty_fixed_array();
4119
+ Heap* heap = GetHeap();
4120
+ if (new_length == 0) return heap->empty_fixed_array();
3893
4121
  Object* obj;
3894
- { MaybeObject* maybe_obj = Heap::AllocateFixedArray(new_length);
4122
+ { MaybeObject* maybe_obj = heap->AllocateFixedArray(new_length);
3895
4123
  if (!maybe_obj->ToObject(&obj)) return maybe_obj;
3896
4124
  }
3897
4125
  FixedArray* result = FixedArray::cast(obj);
@@ -3929,13 +4157,14 @@ bool FixedArray::IsEqualTo(FixedArray* other) {
3929
4157
 
3930
4158
 
3931
4159
  MaybeObject* DescriptorArray::Allocate(int number_of_descriptors) {
4160
+ Heap* heap = Isolate::Current()->heap();
3932
4161
  if (number_of_descriptors == 0) {
3933
- return Heap::empty_descriptor_array();
4162
+ return heap->empty_descriptor_array();
3934
4163
  }
3935
4164
  // Allocate the array of keys.
3936
4165
  Object* array;
3937
4166
  { MaybeObject* maybe_array =
3938
- Heap::AllocateFixedArray(ToKeyIndex(number_of_descriptors));
4167
+ heap->AllocateFixedArray(ToKeyIndex(number_of_descriptors));
3939
4168
  if (!maybe_array->ToObject(&array)) return maybe_array;
3940
4169
  }
3941
4170
  // Do not use DescriptorArray::cast on incomplete object.
@@ -3943,7 +4172,7 @@ MaybeObject* DescriptorArray::Allocate(int number_of_descriptors) {
3943
4172
 
3944
4173
  // Allocate the content array and set it in the descriptor array.
3945
4174
  { MaybeObject* maybe_array =
3946
- Heap::AllocateFixedArray(number_of_descriptors << 1);
4175
+ heap->AllocateFixedArray(number_of_descriptors << 1);
3947
4176
  if (!maybe_array->ToObject(&array)) return maybe_array;
3948
4177
  }
3949
4178
  result->set(kContentArrayIndex, array);
@@ -4212,15 +4441,15 @@ int DescriptorArray::LinearSearch(String* name, int len) {
4212
4441
  MaybeObject* DeoptimizationInputData::Allocate(int deopt_entry_count,
4213
4442
  PretenureFlag pretenure) {
4214
4443
  ASSERT(deopt_entry_count > 0);
4215
- return Heap::AllocateFixedArray(LengthFor(deopt_entry_count),
4444
+ return HEAP->AllocateFixedArray(LengthFor(deopt_entry_count),
4216
4445
  pretenure);
4217
4446
  }
4218
4447
 
4219
4448
 
4220
4449
  MaybeObject* DeoptimizationOutputData::Allocate(int number_of_deopt_points,
4221
4450
  PretenureFlag pretenure) {
4222
- if (number_of_deopt_points == 0) return Heap::empty_fixed_array();
4223
- return Heap::AllocateFixedArray(LengthOfFixedArray(number_of_deopt_points),
4451
+ if (number_of_deopt_points == 0) return HEAP->empty_fixed_array();
4452
+ return HEAP->AllocateFixedArray(LengthOfFixedArray(number_of_deopt_points),
4224
4453
  pretenure);
4225
4454
  }
4226
4455
 
@@ -4238,11 +4467,8 @@ bool DescriptorArray::IsEqualTo(DescriptorArray* other) {
4238
4467
  #endif
4239
4468
 
4240
4469
 
4241
- static StaticResource<StringInputBuffer> string_input_buffer;
4242
-
4243
-
4244
4470
  bool String::LooksValid() {
4245
- if (!Heap::Contains(this)) return false;
4471
+ if (!Isolate::Current()->heap()->Contains(this)) return false;
4246
4472
  return true;
4247
4473
  }
4248
4474
 
@@ -4253,8 +4479,10 @@ int String::Utf8Length() {
4253
4479
  // doesn't make Utf8Length faster, but it is very likely that
4254
4480
  // the string will be accessed later (for example by WriteUtf8)
4255
4481
  // so it's still a good idea.
4482
+ Heap* heap = GetHeap();
4256
4483
  TryFlatten();
4257
- Access<StringInputBuffer> buffer(&string_input_buffer);
4484
+ Access<StringInputBuffer> buffer(
4485
+ heap->isolate()->objects_string_input_buffer());
4258
4486
  buffer->Reset(0, this);
4259
4487
  int result = 0;
4260
4488
  while (buffer->has_more())
@@ -4320,16 +4548,17 @@ SmartPointer<char> String::ToCString(AllowNullsFlag allow_nulls,
4320
4548
  int offset,
4321
4549
  int length,
4322
4550
  int* length_return) {
4323
- ASSERT(NativeAllocationChecker::allocation_allowed());
4324
4551
  if (robust_flag == ROBUST_STRING_TRAVERSAL && !LooksValid()) {
4325
4552
  return SmartPointer<char>(NULL);
4326
4553
  }
4554
+ Heap* heap = GetHeap();
4327
4555
 
4328
4556
  // Negative length means the to the end of the string.
4329
4557
  if (length < 0) length = kMaxInt - offset;
4330
4558
 
4331
4559
  // Compute the size of the UTF-8 string. Start at the specified offset.
4332
- Access<StringInputBuffer> buffer(&string_input_buffer);
4560
+ Access<StringInputBuffer> buffer(
4561
+ heap->isolate()->objects_string_input_buffer());
4333
4562
  buffer->Reset(offset, this);
4334
4563
  int character_position = offset;
4335
4564
  int utf8_bytes = 0;
@@ -4398,13 +4627,13 @@ const uc16* String::GetTwoByteData(unsigned start) {
4398
4627
 
4399
4628
 
4400
4629
  SmartPointer<uc16> String::ToWideCString(RobustnessFlag robust_flag) {
4401
- ASSERT(NativeAllocationChecker::allocation_allowed());
4402
-
4403
4630
  if (robust_flag == ROBUST_STRING_TRAVERSAL && !LooksValid()) {
4404
4631
  return SmartPointer<uc16>();
4405
4632
  }
4633
+ Heap* heap = GetHeap();
4406
4634
 
4407
- Access<StringInputBuffer> buffer(&string_input_buffer);
4635
+ Access<StringInputBuffer> buffer(
4636
+ heap->isolate()->objects_string_input_buffer());
4408
4637
  buffer->Reset(this);
4409
4638
 
4410
4639
  uc16* result = NewArray<uc16>(length() + 1);
@@ -4687,11 +4916,9 @@ const unibrow::byte* String::ReadBlock(String* input,
4687
4916
  }
4688
4917
 
4689
4918
 
4690
- Relocatable* Relocatable::top_ = NULL;
4691
-
4692
-
4693
4919
  void Relocatable::PostGarbageCollectionProcessing() {
4694
- Relocatable* current = top_;
4920
+ Isolate* isolate = Isolate::Current();
4921
+ Relocatable* current = isolate->relocatable_top();
4695
4922
  while (current != NULL) {
4696
4923
  current->PostGarbageCollection();
4697
4924
  current = current->prev_;
@@ -4701,21 +4928,23 @@ void Relocatable::PostGarbageCollectionProcessing() {
4701
4928
 
4702
4929
  // Reserve space for statics needing saving and restoring.
4703
4930
  int Relocatable::ArchiveSpacePerThread() {
4704
- return sizeof(top_);
4931
+ return sizeof(Isolate::Current()->relocatable_top());
4705
4932
  }
4706
4933
 
4707
4934
 
4708
4935
  // Archive statics that are thread local.
4709
4936
  char* Relocatable::ArchiveState(char* to) {
4710
- *reinterpret_cast<Relocatable**>(to) = top_;
4711
- top_ = NULL;
4937
+ Isolate* isolate = Isolate::Current();
4938
+ *reinterpret_cast<Relocatable**>(to) = isolate->relocatable_top();
4939
+ isolate->set_relocatable_top(NULL);
4712
4940
  return to + ArchiveSpacePerThread();
4713
4941
  }
4714
4942
 
4715
4943
 
4716
4944
  // Restore statics that are thread local.
4717
4945
  char* Relocatable::RestoreState(char* from) {
4718
- top_ = *reinterpret_cast<Relocatable**>(from);
4946
+ Isolate* isolate = Isolate::Current();
4947
+ isolate->set_relocatable_top(*reinterpret_cast<Relocatable**>(from));
4719
4948
  return from + ArchiveSpacePerThread();
4720
4949
  }
4721
4950
 
@@ -4728,7 +4957,8 @@ char* Relocatable::Iterate(ObjectVisitor* v, char* thread_storage) {
4728
4957
 
4729
4958
 
4730
4959
  void Relocatable::Iterate(ObjectVisitor* v) {
4731
- Iterate(v, top_);
4960
+ Isolate* isolate = Isolate::Current();
4961
+ Iterate(v, isolate->relocatable_top());
4732
4962
  }
4733
4963
 
4734
4964
 
@@ -4741,15 +4971,17 @@ void Relocatable::Iterate(ObjectVisitor* v, Relocatable* top) {
4741
4971
  }
4742
4972
 
4743
4973
 
4744
- FlatStringReader::FlatStringReader(Handle<String> str)
4745
- : str_(str.location()),
4974
+ FlatStringReader::FlatStringReader(Isolate* isolate, Handle<String> str)
4975
+ : Relocatable(isolate),
4976
+ str_(str.location()),
4746
4977
  length_(str->length()) {
4747
4978
  PostGarbageCollection();
4748
4979
  }
4749
4980
 
4750
4981
 
4751
- FlatStringReader::FlatStringReader(Vector<const char> input)
4752
- : str_(0),
4982
+ FlatStringReader::FlatStringReader(Isolate* isolate, Vector<const char> input)
4983
+ : Relocatable(isolate),
4984
+ str_(0),
4753
4985
  is_ascii_(true),
4754
4986
  length_(input.length()),
4755
4987
  start_(input.start()) { }
@@ -5079,11 +5311,10 @@ static inline bool CompareRawStringContents(Vector<Char> a, Vector<Char> b) {
5079
5311
  }
5080
5312
 
5081
5313
 
5082
- static StringInputBuffer string_compare_buffer_b;
5083
-
5084
-
5085
5314
  template <typename IteratorA>
5086
- static inline bool CompareStringContentsPartial(IteratorA* ia, String* b) {
5315
+ static inline bool CompareStringContentsPartial(Isolate* isolate,
5316
+ IteratorA* ia,
5317
+ String* b) {
5087
5318
  if (b->IsFlat()) {
5088
5319
  if (b->IsAsciiRepresentation()) {
5089
5320
  VectorIterator<char> ib(b->ToAsciiVector());
@@ -5093,15 +5324,13 @@ static inline bool CompareStringContentsPartial(IteratorA* ia, String* b) {
5093
5324
  return CompareStringContents(ia, &ib);
5094
5325
  }
5095
5326
  } else {
5096
- string_compare_buffer_b.Reset(0, b);
5097
- return CompareStringContents(ia, &string_compare_buffer_b);
5327
+ isolate->objects_string_compare_buffer_b()->Reset(0, b);
5328
+ return CompareStringContents(ia,
5329
+ isolate->objects_string_compare_buffer_b());
5098
5330
  }
5099
5331
  }
5100
5332
 
5101
5333
 
5102
- static StringInputBuffer string_compare_buffer_a;
5103
-
5104
-
5105
5334
  bool String::SlowEquals(String* other) {
5106
5335
  // Fast check: negative check with lengths.
5107
5336
  int len = length();
@@ -5129,6 +5358,7 @@ bool String::SlowEquals(String* other) {
5129
5358
  Vector<const char>(str2, len));
5130
5359
  }
5131
5360
 
5361
+ Isolate* isolate = GetIsolate();
5132
5362
  if (lhs->IsFlat()) {
5133
5363
  if (lhs->IsAsciiRepresentation()) {
5134
5364
  Vector<const char> vec1 = lhs->ToAsciiVector();
@@ -5143,8 +5373,9 @@ bool String::SlowEquals(String* other) {
5143
5373
  }
5144
5374
  } else {
5145
5375
  VectorIterator<char> buf1(vec1);
5146
- string_compare_buffer_b.Reset(0, rhs);
5147
- return CompareStringContents(&buf1, &string_compare_buffer_b);
5376
+ isolate->objects_string_compare_buffer_b()->Reset(0, rhs);
5377
+ return CompareStringContents(&buf1,
5378
+ isolate->objects_string_compare_buffer_b());
5148
5379
  }
5149
5380
  } else {
5150
5381
  Vector<const uc16> vec1 = lhs->ToUC16Vector();
@@ -5159,13 +5390,15 @@ bool String::SlowEquals(String* other) {
5159
5390
  }
5160
5391
  } else {
5161
5392
  VectorIterator<uc16> buf1(vec1);
5162
- string_compare_buffer_b.Reset(0, rhs);
5163
- return CompareStringContents(&buf1, &string_compare_buffer_b);
5393
+ isolate->objects_string_compare_buffer_b()->Reset(0, rhs);
5394
+ return CompareStringContents(&buf1,
5395
+ isolate->objects_string_compare_buffer_b());
5164
5396
  }
5165
5397
  }
5166
5398
  } else {
5167
- string_compare_buffer_a.Reset(0, lhs);
5168
- return CompareStringContentsPartial(&string_compare_buffer_a, rhs);
5399
+ isolate->objects_string_compare_buffer_a()->Reset(0, lhs);
5400
+ return CompareStringContentsPartial(isolate,
5401
+ isolate->objects_string_compare_buffer_a(), rhs);
5169
5402
  }
5170
5403
  }
5171
5404
 
@@ -5174,11 +5407,12 @@ bool String::MarkAsUndetectable() {
5174
5407
  if (StringShape(this).IsSymbol()) return false;
5175
5408
 
5176
5409
  Map* map = this->map();
5177
- if (map == Heap::string_map()) {
5178
- this->set_map(Heap::undetectable_string_map());
5410
+ Heap* heap = map->heap();
5411
+ if (map == heap->string_map()) {
5412
+ this->set_map(heap->undetectable_string_map());
5179
5413
  return true;
5180
- } else if (map == Heap::ascii_string_map()) {
5181
- this->set_map(Heap::undetectable_ascii_string_map());
5414
+ } else if (map == heap->ascii_string_map()) {
5415
+ this->set_map(heap->undetectable_ascii_string_map());
5182
5416
  return true;
5183
5417
  }
5184
5418
  // Rest cannot be marked as undetectable
@@ -5187,9 +5421,10 @@ bool String::MarkAsUndetectable() {
5187
5421
 
5188
5422
 
5189
5423
  bool String::IsEqualTo(Vector<const char> str) {
5424
+ Isolate* isolate = GetIsolate();
5190
5425
  int slen = length();
5191
5426
  Access<ScannerConstants::Utf8Decoder>
5192
- decoder(ScannerConstants::utf8_decoder());
5427
+ decoder(isolate->scanner_constants()->utf8_decoder());
5193
5428
  decoder->Reset(str.start(), str.length());
5194
5429
  int i;
5195
5430
  for (i = 0; i < slen && decoder->has_more(); i++) {
@@ -5220,22 +5455,6 @@ bool String::IsTwoByteEqualTo(Vector<const uc16> str) {
5220
5455
  }
5221
5456
 
5222
5457
 
5223
- template <typename schar>
5224
- static inline uint32_t HashSequentialString(const schar* chars, int length) {
5225
- StringHasher hasher(length);
5226
- if (!hasher.has_trivial_hash()) {
5227
- int i;
5228
- for (i = 0; hasher.is_array_index() && (i < length); i++) {
5229
- hasher.AddCharacter(chars[i]);
5230
- }
5231
- for (; i < length; i++) {
5232
- hasher.AddCharacterNoIndex(chars[i]);
5233
- }
5234
- }
5235
- return hasher.GetHashField();
5236
- }
5237
-
5238
-
5239
5458
  uint32_t String::ComputeAndSetHash() {
5240
5459
  // Should only be called if hash code has not yet been computed.
5241
5460
  ASSERT(!HasHashCode());
@@ -5367,8 +5586,9 @@ uint32_t String::ComputeHashField(unibrow::CharacterStream* buffer,
5367
5586
 
5368
5587
 
5369
5588
  MaybeObject* String::SubString(int start, int end, PretenureFlag pretenure) {
5589
+ Heap* heap = GetHeap();
5370
5590
  if (start == 0 && end == length()) return this;
5371
- MaybeObject* result = Heap::AllocateSubString(this, start, end, pretenure);
5591
+ MaybeObject* result = heap->AllocateSubString(this, start, end, pretenure);
5372
5592
  return result;
5373
5593
  }
5374
5594
 
@@ -5385,6 +5605,7 @@ void Map::CreateBackPointers() {
5385
5605
  DescriptorArray* descriptors = instance_descriptors();
5386
5606
  for (int i = 0; i < descriptors->number_of_descriptors(); i++) {
5387
5607
  if (descriptors->GetType(i) == MAP_TRANSITION ||
5608
+ descriptors->GetType(i) == EXTERNAL_ARRAY_TRANSITION ||
5388
5609
  descriptors->GetType(i) == CONSTANT_TRANSITION) {
5389
5610
  // Get target.
5390
5611
  Map* target = Map::cast(descriptors->GetValue(i));
@@ -5408,12 +5629,12 @@ void Map::CreateBackPointers() {
5408
5629
  }
5409
5630
 
5410
5631
 
5411
- void Map::ClearNonLiveTransitions(Object* real_prototype) {
5632
+ void Map::ClearNonLiveTransitions(Heap* heap, Object* real_prototype) {
5412
5633
  // Live DescriptorArray objects will be marked, so we must use
5413
5634
  // low-level accessors to get and modify their data.
5414
5635
  DescriptorArray* d = reinterpret_cast<DescriptorArray*>(
5415
5636
  *RawField(this, Map::kInstanceDescriptorsOffset));
5416
- if (d == Heap::raw_unchecked_empty_descriptor_array()) return;
5637
+ if (d == heap->raw_unchecked_empty_descriptor_array()) return;
5417
5638
  Smi* NullDescriptorDetails =
5418
5639
  PropertyDetails(NONE, NULL_DESCRIPTOR).AsSmi();
5419
5640
  FixedArray* contents = reinterpret_cast<FixedArray*>(
@@ -5427,13 +5648,14 @@ void Map::ClearNonLiveTransitions(Object* real_prototype) {
5427
5648
  // non-live object.
5428
5649
  PropertyDetails details(Smi::cast(contents->get(i + 1)));
5429
5650
  if (details.type() == MAP_TRANSITION ||
5651
+ details.type() == EXTERNAL_ARRAY_TRANSITION ||
5430
5652
  details.type() == CONSTANT_TRANSITION) {
5431
5653
  Map* target = reinterpret_cast<Map*>(contents->get(i));
5432
5654
  ASSERT(target->IsHeapObject());
5433
5655
  if (!target->IsMarked()) {
5434
5656
  ASSERT(target->IsMap());
5435
5657
  contents->set_unchecked(i + 1, NullDescriptorDetails);
5436
- contents->set_null_unchecked(i);
5658
+ contents->set_null_unchecked(heap, i);
5437
5659
  ASSERT(target->prototype() == this ||
5438
5660
  target->prototype() == real_prototype);
5439
5661
  // Getter prototype() is read-only, set_prototype() has side effects.
@@ -5457,7 +5679,8 @@ void JSFunction::MarkForLazyRecompilation() {
5457
5679
  ASSERT(is_compiled() && !IsOptimized());
5458
5680
  ASSERT(shared()->allows_lazy_compilation() ||
5459
5681
  code()->optimizable());
5460
- ReplaceCode(Builtins::builtin(Builtins::LazyRecompile));
5682
+ Builtins* builtins = GetIsolate()->builtins();
5683
+ ReplaceCode(builtins->builtin(Builtins::kLazyRecompile));
5461
5684
  }
5462
5685
 
5463
5686
 
@@ -5476,9 +5699,11 @@ uint32_t JSFunction::SourceHash() {
5476
5699
 
5477
5700
  bool JSFunction::IsInlineable() {
5478
5701
  if (IsBuiltin()) return false;
5702
+ SharedFunctionInfo* shared_info = shared();
5479
5703
  // Check that the function has a script associated with it.
5480
- if (!shared()->script()->IsScript()) return false;
5481
- Code* code = shared()->code();
5704
+ if (!shared_info->script()->IsScript()) return false;
5705
+ if (shared_info->optimization_disabled()) return false;
5706
+ Code* code = shared_info->code();
5482
5707
  if (code->kind() == Code::OPTIMIZED_FUNCTION) return true;
5483
5708
  // If we never ran this (unlikely) then lets try to optimize it.
5484
5709
  if (code->kind() != Code::FUNCTION) return true;
@@ -5488,7 +5713,7 @@ bool JSFunction::IsInlineable() {
5488
5713
 
5489
5714
  Object* JSFunction::SetInstancePrototype(Object* value) {
5490
5715
  ASSERT(value->IsJSObject());
5491
-
5716
+ Heap* heap = GetHeap();
5492
5717
  if (has_initial_map()) {
5493
5718
  initial_map()->set_prototype(value);
5494
5719
  } else {
@@ -5497,7 +5722,7 @@ Object* JSFunction::SetInstancePrototype(Object* value) {
5497
5722
  // prototype is put into the initial map where it belongs.
5498
5723
  set_prototype_or_initial_map(value);
5499
5724
  }
5500
- Heap::ClearInstanceofCache();
5725
+ heap->ClearInstanceofCache();
5501
5726
  return value;
5502
5727
  }
5503
5728
 
@@ -5514,15 +5739,18 @@ MaybeObject* JSFunction::SetPrototype(Object* value) {
5514
5739
  // Copy the map so this does not affect unrelated functions.
5515
5740
  // Remove map transitions because they point to maps with a
5516
5741
  // different prototype.
5517
- Object* new_map;
5742
+ Object* new_object;
5518
5743
  { MaybeObject* maybe_new_map = map()->CopyDropTransitions();
5519
- if (!maybe_new_map->ToObject(&new_map)) return maybe_new_map;
5744
+ if (!maybe_new_map->ToObject(&new_object)) return maybe_new_map;
5520
5745
  }
5521
- set_map(Map::cast(new_map));
5522
- map()->set_constructor(value);
5523
- map()->set_non_instance_prototype(true);
5746
+ Map* new_map = Map::cast(new_object);
5747
+ Heap* heap = new_map->heap();
5748
+ set_map(new_map);
5749
+ new_map->set_constructor(value);
5750
+ new_map->set_non_instance_prototype(true);
5524
5751
  construct_prototype =
5525
- Top::context()->global_context()->initial_object_prototype();
5752
+ heap->isolate()->context()->global_context()->
5753
+ initial_object_prototype();
5526
5754
  } else {
5527
5755
  map()->set_non_instance_prototype(false);
5528
5756
  }
@@ -5532,9 +5760,22 @@ MaybeObject* JSFunction::SetPrototype(Object* value) {
5532
5760
 
5533
5761
 
5534
5762
  Object* JSFunction::RemovePrototype() {
5535
- ASSERT(map() == context()->global_context()->function_map());
5536
- set_map(context()->global_context()->function_without_prototype_map());
5537
- set_prototype_or_initial_map(Heap::the_hole_value());
5763
+ Context* global_context = context()->global_context();
5764
+ Map* no_prototype_map = shared()->strict_mode()
5765
+ ? global_context->strict_mode_function_without_prototype_map()
5766
+ : global_context->function_without_prototype_map();
5767
+
5768
+ if (map() == no_prototype_map) {
5769
+ // Be idempotent.
5770
+ return this;
5771
+ }
5772
+
5773
+ ASSERT(!shared()->strict_mode() ||
5774
+ map() == global_context->strict_mode_function_map());
5775
+ ASSERT(shared()->strict_mode() || map() == global_context->function_map());
5776
+
5777
+ set_map(no_prototype_map);
5778
+ set_prototype_or_initial_map(no_prototype_map->heap()->the_hole_value());
5538
5779
  return this;
5539
5780
  }
5540
5781
 
@@ -5556,13 +5797,17 @@ Context* JSFunction::GlobalContextFromLiterals(FixedArray* literals) {
5556
5797
  }
5557
5798
 
5558
5799
 
5559
- MaybeObject* Oddball::Initialize(const char* to_string, Object* to_number) {
5800
+ MaybeObject* Oddball::Initialize(const char* to_string,
5801
+ Object* to_number,
5802
+ byte kind) {
5560
5803
  Object* symbol;
5561
- { MaybeObject* maybe_symbol = Heap::LookupAsciiSymbol(to_string);
5804
+ { MaybeObject* maybe_symbol =
5805
+ Isolate::Current()->heap()->LookupAsciiSymbol(to_string);
5562
5806
  if (!maybe_symbol->ToObject(&symbol)) return maybe_symbol;
5563
5807
  }
5564
5808
  set_to_string(String::cast(symbol));
5565
5809
  set_to_number(to_number);
5810
+ set_kind(kind);
5566
5811
  return this;
5567
5812
  }
5568
5813
 
@@ -5581,10 +5826,11 @@ bool SharedFunctionInfo::HasSourceCode() {
5581
5826
 
5582
5827
 
5583
5828
  Object* SharedFunctionInfo::GetSourceCode() {
5584
- if (!HasSourceCode()) return Heap::undefined_value();
5585
- HandleScope scope;
5829
+ Isolate* isolate = GetIsolate();
5830
+ if (!HasSourceCode()) return isolate->heap()->undefined_value();
5831
+ HandleScope scope(isolate);
5586
5832
  Object* source = Script::cast(script())->source();
5587
- return *SubString(Handle<String>(String::cast(source)),
5833
+ return *SubString(Handle<String>(String::cast(source), isolate),
5588
5834
  start_position(), end_position());
5589
5835
  }
5590
5836
 
@@ -5624,10 +5870,12 @@ bool SharedFunctionInfo::CanGenerateInlineConstructor(Object* prototype) {
5624
5870
  return true;
5625
5871
  }
5626
5872
 
5873
+ Heap* heap = GetHeap();
5874
+
5627
5875
  // Traverse the proposed prototype chain looking for setters for properties of
5628
5876
  // the same names as are set by the inline constructor.
5629
5877
  for (Object* obj = prototype;
5630
- obj != Heap::null_value();
5878
+ obj != heap->null_value();
5631
5879
  obj = obj->GetPrototype()) {
5632
5880
  JSObject* js_object = JSObject::cast(obj);
5633
5881
  for (int i = 0; i < this_property_assignments_count(); i++) {
@@ -5663,10 +5911,11 @@ void SharedFunctionInfo::SetThisPropertyAssignmentsInfo(
5663
5911
 
5664
5912
 
5665
5913
  void SharedFunctionInfo::ClearThisPropertyAssignmentsInfo() {
5914
+ Heap* heap = GetHeap();
5666
5915
  set_compiler_hints(BooleanBit::set(compiler_hints(),
5667
5916
  kHasOnlySimpleThisPropertyAssignments,
5668
5917
  false));
5669
- set_this_property_assignments(Heap::undefined_value());
5918
+ set_this_property_assignments(heap->undefined_value());
5670
5919
  set_this_property_assignments_count(0);
5671
5920
  }
5672
5921
 
@@ -5811,9 +6060,10 @@ void SharedFunctionInfo::StartInobjectSlackTracking(Map* map) {
5811
6060
  set_construction_count(kGenerousAllocationCount);
5812
6061
  }
5813
6062
  set_initial_map(map);
5814
- ASSERT_EQ(Builtins::builtin(Builtins::JSConstructStubGeneric),
6063
+ Builtins* builtins = map->heap()->isolate()->builtins();
6064
+ ASSERT_EQ(builtins->builtin(Builtins::kJSConstructStubGeneric),
5815
6065
  construct_stub());
5816
- set_construct_stub(Builtins::builtin(Builtins::JSConstructStubCountdown));
6066
+ set_construct_stub(builtins->builtin(Builtins::kJSConstructStubCountdown));
5817
6067
  }
5818
6068
 
5819
6069
 
@@ -5830,10 +6080,11 @@ void SharedFunctionInfo::DetachInitialMap() {
5830
6080
  // then StartInobjectTracking will be called again the next time the
5831
6081
  // constructor is called. The countdown will continue and (possibly after
5832
6082
  // several more GCs) CompleteInobjectSlackTracking will eventually be called.
5833
- set_initial_map(Heap::raw_unchecked_undefined_value());
5834
- ASSERT_EQ(Builtins::builtin(Builtins::JSConstructStubCountdown),
6083
+ set_initial_map(map->heap()->raw_unchecked_undefined_value());
6084
+ Builtins* builtins = map->heap()->isolate()->builtins();
6085
+ ASSERT_EQ(builtins->builtin(Builtins::kJSConstructStubCountdown),
5835
6086
  *RawField(this, kConstructStubOffset));
5836
- set_construct_stub(Builtins::builtin(Builtins::JSConstructStubGeneric));
6087
+ set_construct_stub(builtins->builtin(Builtins::kJSConstructStubGeneric));
5837
6088
  // It is safe to clear the flag: it will be set again if the map is live.
5838
6089
  set_live_objects_may_exist(false);
5839
6090
  }
@@ -5846,9 +6097,10 @@ void SharedFunctionInfo::AttachInitialMap(Map* map) {
5846
6097
 
5847
6098
  // Resume inobject slack tracking.
5848
6099
  set_initial_map(map);
5849
- ASSERT_EQ(Builtins::builtin(Builtins::JSConstructStubGeneric),
6100
+ Builtins* builtins = map->heap()->isolate()->builtins();
6101
+ ASSERT_EQ(builtins->builtin(Builtins::kJSConstructStubGeneric),
5850
6102
  *RawField(this, kConstructStubOffset));
5851
- set_construct_stub(Builtins::builtin(Builtins::JSConstructStubCountdown));
6103
+ set_construct_stub(builtins->builtin(Builtins::kJSConstructStubCountdown));
5852
6104
  // The map survived the gc, so there may be objects referencing it.
5853
6105
  set_live_objects_may_exist(true);
5854
6106
  }
@@ -5877,10 +6129,12 @@ void SharedFunctionInfo::CompleteInobjectSlackTracking() {
5877
6129
  ASSERT(live_objects_may_exist() && IsInobjectSlackTrackingInProgress());
5878
6130
  Map* map = Map::cast(initial_map());
5879
6131
 
5880
- set_initial_map(Heap::undefined_value());
5881
- ASSERT_EQ(Builtins::builtin(Builtins::JSConstructStubCountdown),
6132
+ Heap* heap = map->heap();
6133
+ set_initial_map(heap->undefined_value());
6134
+ Builtins* builtins = heap->isolate()->builtins();
6135
+ ASSERT_EQ(builtins->builtin(Builtins::kJSConstructStubCountdown),
5882
6136
  construct_stub());
5883
- set_construct_stub(Builtins::builtin(Builtins::JSConstructStubGeneric));
6137
+ set_construct_stub(builtins->builtin(Builtins::kJSConstructStubGeneric));
5884
6138
 
5885
6139
  int slack = map->unused_property_fields();
5886
6140
  map->TraverseTransitionTree(&GetMinInobjectSlack, &slack);
@@ -5937,8 +6191,7 @@ void ObjectVisitor::VisitDebugTarget(RelocInfo* rinfo) {
5937
6191
 
5938
6192
 
5939
6193
  void Code::InvalidateRelocation() {
5940
- HandleScope scope;
5941
- set_relocation_info(Heap::empty_byte_array());
6194
+ set_relocation_info(heap()->empty_byte_array());
5942
6195
  }
5943
6196
 
5944
6197
 
@@ -6232,8 +6485,10 @@ const char* Code::Kind2String(Kind kind) {
6232
6485
  case BUILTIN: return "BUILTIN";
6233
6486
  case LOAD_IC: return "LOAD_IC";
6234
6487
  case KEYED_LOAD_IC: return "KEYED_LOAD_IC";
6488
+ case KEYED_EXTERNAL_ARRAY_LOAD_IC: return "KEYED_EXTERNAL_ARRAY_LOAD_IC";
6235
6489
  case STORE_IC: return "STORE_IC";
6236
6490
  case KEYED_STORE_IC: return "KEYED_STORE_IC";
6491
+ case KEYED_EXTERNAL_ARRAY_STORE_IC: return "KEYED_EXTERNAL_ARRAY_STORE_IC";
6237
6492
  case CALL_IC: return "CALL_IC";
6238
6493
  case KEYED_CALL_IC: return "KEYED_CALL_IC";
6239
6494
  case BINARY_OP_IC: return "BINARY_OP_IC";
@@ -6268,6 +6523,7 @@ const char* Code::PropertyType2String(PropertyType type) {
6268
6523
  case CALLBACKS: return "CALLBACKS";
6269
6524
  case INTERCEPTOR: return "INTERCEPTOR";
6270
6525
  case MAP_TRANSITION: return "MAP_TRANSITION";
6526
+ case EXTERNAL_ARRAY_TRANSITION: return "EXTERNAL_ARRAY_TRANSITION";
6271
6527
  case CONSTANT_TRANSITION: return "CONSTANT_TRANSITION";
6272
6528
  case NULL_DESCRIPTOR: return "NULL_DESCRIPTOR";
6273
6529
  }
@@ -6285,7 +6541,8 @@ void Code::PrintExtraICState(FILE* out, Kind kind, ExtraICState extra) {
6285
6541
  }
6286
6542
  break;
6287
6543
  case STORE_IC:
6288
- if (extra == StoreIC::kStoreICStrict) {
6544
+ case KEYED_STORE_IC:
6545
+ if (extra == kStrictMode) {
6289
6546
  name = "STRICT";
6290
6547
  }
6291
6548
  break;
@@ -6381,11 +6638,12 @@ void Code::Disassemble(const char* name, FILE* out) {
6381
6638
 
6382
6639
  MaybeObject* JSObject::SetFastElementsCapacityAndLength(int capacity,
6383
6640
  int length) {
6641
+ Heap* heap = GetHeap();
6384
6642
  // We should never end in here with a pixel or external array.
6385
- ASSERT(!HasPixelElements() && !HasExternalArrayElements());
6643
+ ASSERT(!HasExternalArrayElements());
6386
6644
 
6387
6645
  Object* obj;
6388
- { MaybeObject* maybe_obj = Heap::AllocateFixedArrayWithHoles(capacity);
6646
+ { MaybeObject* maybe_obj = heap->AllocateFixedArrayWithHoles(capacity);
6389
6647
  if (!maybe_obj->ToObject(&obj)) return maybe_obj;
6390
6648
  }
6391
6649
  FixedArray* elems = FixedArray::cast(obj);
@@ -6436,7 +6694,7 @@ MaybeObject* JSObject::SetFastElementsCapacityAndLength(int capacity,
6436
6694
 
6437
6695
  MaybeObject* JSObject::SetSlowElements(Object* len) {
6438
6696
  // We should never end in here with a pixel or external array.
6439
- ASSERT(!HasPixelElements() && !HasExternalArrayElements());
6697
+ ASSERT(!HasExternalArrayElements());
6440
6698
 
6441
6699
  uint32_t new_length = static_cast<uint32_t>(len->Number());
6442
6700
 
@@ -6472,14 +6730,15 @@ MaybeObject* JSObject::SetSlowElements(Object* len) {
6472
6730
 
6473
6731
 
6474
6732
  MaybeObject* JSArray::Initialize(int capacity) {
6733
+ Heap* heap = GetHeap();
6475
6734
  ASSERT(capacity >= 0);
6476
6735
  set_length(Smi::FromInt(0));
6477
6736
  FixedArray* new_elements;
6478
6737
  if (capacity == 0) {
6479
- new_elements = Heap::empty_fixed_array();
6738
+ new_elements = heap->empty_fixed_array();
6480
6739
  } else {
6481
6740
  Object* obj;
6482
- { MaybeObject* maybe_obj = Heap::AllocateFixedArrayWithHoles(capacity);
6741
+ { MaybeObject* maybe_obj = heap->AllocateFixedArrayWithHoles(capacity);
6483
6742
  if (!maybe_obj->ToObject(&obj)) return maybe_obj;
6484
6743
  }
6485
6744
  new_elements = FixedArray::cast(obj);
@@ -6494,24 +6753,18 @@ void JSArray::Expand(int required_size) {
6494
6753
  Handle<FixedArray> old_backing(FixedArray::cast(elements()));
6495
6754
  int old_size = old_backing->length();
6496
6755
  int new_size = required_size > old_size ? required_size : old_size;
6497
- Handle<FixedArray> new_backing = Factory::NewFixedArray(new_size);
6756
+ Handle<FixedArray> new_backing = FACTORY->NewFixedArray(new_size);
6498
6757
  // Can't use this any more now because we may have had a GC!
6499
6758
  for (int i = 0; i < old_size; i++) new_backing->set(i, old_backing->get(i));
6500
6759
  self->SetContent(*new_backing);
6501
6760
  }
6502
6761
 
6503
6762
 
6504
- // Computes the new capacity when expanding the elements of a JSObject.
6505
- static int NewElementsCapacity(int old_capacity) {
6506
- // (old_capacity + 50%) + 16
6507
- return old_capacity + (old_capacity >> 1) + 16;
6508
- }
6509
-
6510
-
6511
- static Failure* ArrayLengthRangeError() {
6763
+ static Failure* ArrayLengthRangeError(Heap* heap) {
6512
6764
  HandleScope scope;
6513
- return Top::Throw(*Factory::NewRangeError("invalid_array_length",
6514
- HandleVector<Object>(NULL, 0)));
6765
+ return heap->isolate()->Throw(
6766
+ *FACTORY->NewRangeError("invalid_array_length",
6767
+ HandleVector<Object>(NULL, 0)));
6515
6768
  }
6516
6769
 
6517
6770
 
@@ -6523,7 +6776,7 @@ MaybeObject* JSObject::SetElementsLength(Object* len) {
6523
6776
  Object* smi_length = Smi::FromInt(0);
6524
6777
  if (maybe_smi_length->ToObject(&smi_length) && smi_length->IsSmi()) {
6525
6778
  const int value = Smi::cast(smi_length)->value();
6526
- if (value < 0) return ArrayLengthRangeError();
6779
+ if (value < 0) return ArrayLengthRangeError(GetHeap());
6527
6780
  switch (GetElementsKind()) {
6528
6781
  case FAST_ELEMENTS: {
6529
6782
  int old_capacity = FixedArray::cast(elements())->length();
@@ -6589,14 +6842,14 @@ MaybeObject* JSObject::SetElementsLength(Object* len) {
6589
6842
  if (len->ToArrayIndex(&length)) {
6590
6843
  return SetSlowElements(len);
6591
6844
  } else {
6592
- return ArrayLengthRangeError();
6845
+ return ArrayLengthRangeError(GetHeap());
6593
6846
  }
6594
6847
  }
6595
6848
 
6596
6849
  // len is not a number so make the array size one and
6597
6850
  // set only element to len.
6598
6851
  Object* obj;
6599
- { MaybeObject* maybe_obj = Heap::AllocateFixedArray(1);
6852
+ { MaybeObject* maybe_obj = GetHeap()->AllocateFixedArray(1);
6600
6853
  if (!maybe_obj->ToObject(&obj)) return maybe_obj;
6601
6854
  }
6602
6855
  FixedArray::cast(obj)->set(0, len);
@@ -6608,6 +6861,7 @@ MaybeObject* JSObject::SetElementsLength(Object* len) {
6608
6861
 
6609
6862
  MaybeObject* JSObject::SetPrototype(Object* value,
6610
6863
  bool skip_hidden_prototypes) {
6864
+ Heap* heap = GetHeap();
6611
6865
  // Silently ignore the change if value is not a JSObject or null.
6612
6866
  // SpiderMonkey behaves this way.
6613
6867
  if (!value->IsJSObject() && !value->IsNull()) return value;
@@ -6616,12 +6870,12 @@ MaybeObject* JSObject::SetPrototype(Object* value,
6616
6870
  // prototype cycles are prevented.
6617
6871
  // It is sufficient to validate that the receiver is not in the new prototype
6618
6872
  // chain.
6619
- for (Object* pt = value; pt != Heap::null_value(); pt = pt->GetPrototype()) {
6873
+ for (Object* pt = value; pt != heap->null_value(); pt = pt->GetPrototype()) {
6620
6874
  if (JSObject::cast(pt) == this) {
6621
6875
  // Cycle detected.
6622
6876
  HandleScope scope;
6623
- return Top::Throw(*Factory::NewError("cyclic_proto",
6624
- HandleVector<Object>(NULL, 0)));
6877
+ return heap->isolate()->Throw(
6878
+ *FACTORY->NewError("cyclic_proto", HandleVector<Object>(NULL, 0)));
6625
6879
  }
6626
6880
  }
6627
6881
 
@@ -6646,7 +6900,7 @@ MaybeObject* JSObject::SetPrototype(Object* value,
6646
6900
  Map::cast(new_map)->set_prototype(value);
6647
6901
  real_receiver->set_map(Map::cast(new_map));
6648
6902
 
6649
- Heap::ClearInstanceofCache();
6903
+ heap->ClearInstanceofCache();
6650
6904
 
6651
6905
  return value;
6652
6906
  }
@@ -6665,8 +6919,8 @@ bool JSObject::HasElementPostInterceptor(JSObject* receiver, uint32_t index) {
6665
6919
  }
6666
6920
  break;
6667
6921
  }
6668
- case PIXEL_ELEMENTS: {
6669
- PixelArray* pixels = PixelArray::cast(elements());
6922
+ case EXTERNAL_PIXEL_ELEMENTS: {
6923
+ ExternalPixelArray* pixels = ExternalPixelArray::cast(elements());
6670
6924
  if (index < static_cast<uint32_t>(pixels->length())) {
6671
6925
  return true;
6672
6926
  }
@@ -6701,29 +6955,31 @@ bool JSObject::HasElementPostInterceptor(JSObject* receiver, uint32_t index) {
6701
6955
  if (this->IsStringObjectWithCharacterAt(index)) return true;
6702
6956
 
6703
6957
  Object* pt = GetPrototype();
6704
- if (pt == Heap::null_value()) return false;
6958
+ if (pt->IsNull()) return false;
6705
6959
  return JSObject::cast(pt)->HasElementWithReceiver(receiver, index);
6706
6960
  }
6707
6961
 
6708
6962
 
6709
6963
  bool JSObject::HasElementWithInterceptor(JSObject* receiver, uint32_t index) {
6964
+ Isolate* isolate = GetIsolate();
6710
6965
  // Make sure that the top context does not change when doing
6711
6966
  // callbacks or interceptor calls.
6712
6967
  AssertNoContextChange ncc;
6713
- HandleScope scope;
6968
+ HandleScope scope(isolate);
6714
6969
  Handle<InterceptorInfo> interceptor(GetIndexedInterceptor());
6715
6970
  Handle<JSObject> receiver_handle(receiver);
6716
6971
  Handle<JSObject> holder_handle(this);
6717
- CustomArguments args(interceptor->data(), receiver, this);
6972
+ CustomArguments args(isolate, interceptor->data(), receiver, this);
6718
6973
  v8::AccessorInfo info(args.end());
6719
6974
  if (!interceptor->query()->IsUndefined()) {
6720
6975
  v8::IndexedPropertyQuery query =
6721
6976
  v8::ToCData<v8::IndexedPropertyQuery>(interceptor->query());
6722
- LOG(ApiIndexedPropertyAccess("interceptor-indexed-has", this, index));
6977
+ LOG(isolate,
6978
+ ApiIndexedPropertyAccess("interceptor-indexed-has", this, index));
6723
6979
  v8::Handle<v8::Integer> result;
6724
6980
  {
6725
6981
  // Leaving JavaScript.
6726
- VMState state(EXTERNAL);
6982
+ VMState state(isolate, EXTERNAL);
6727
6983
  result = query(index, info);
6728
6984
  }
6729
6985
  if (!result.IsEmpty()) {
@@ -6733,11 +6989,12 @@ bool JSObject::HasElementWithInterceptor(JSObject* receiver, uint32_t index) {
6733
6989
  } else if (!interceptor->getter()->IsUndefined()) {
6734
6990
  v8::IndexedPropertyGetter getter =
6735
6991
  v8::ToCData<v8::IndexedPropertyGetter>(interceptor->getter());
6736
- LOG(ApiIndexedPropertyAccess("interceptor-indexed-has-get", this, index));
6992
+ LOG(isolate,
6993
+ ApiIndexedPropertyAccess("interceptor-indexed-has-get", this, index));
6737
6994
  v8::Handle<v8::Value> result;
6738
6995
  {
6739
6996
  // Leaving JavaScript.
6740
- VMState state(EXTERNAL);
6997
+ VMState state(isolate, EXTERNAL);
6741
6998
  result = getter(index, info);
6742
6999
  }
6743
7000
  if (!result.IsEmpty()) return true;
@@ -6748,10 +7005,12 @@ bool JSObject::HasElementWithInterceptor(JSObject* receiver, uint32_t index) {
6748
7005
 
6749
7006
  JSObject::LocalElementType JSObject::HasLocalElement(uint32_t index) {
6750
7007
  // Check access rights if needed.
6751
- if (IsAccessCheckNeeded() &&
6752
- !Top::MayIndexedAccess(this, index, v8::ACCESS_HAS)) {
6753
- Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS);
6754
- return UNDEFINED_ELEMENT;
7008
+ if (IsAccessCheckNeeded()) {
7009
+ Heap* heap = GetHeap();
7010
+ if (!heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_HAS)) {
7011
+ heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
7012
+ return UNDEFINED_ELEMENT;
7013
+ }
6755
7014
  }
6756
7015
 
6757
7016
  if (IsJSGlobalProxy()) {
@@ -6784,8 +7043,8 @@ JSObject::LocalElementType JSObject::HasLocalElement(uint32_t index) {
6784
7043
  }
6785
7044
  break;
6786
7045
  }
6787
- case PIXEL_ELEMENTS: {
6788
- PixelArray* pixels = PixelArray::cast(elements());
7046
+ case EXTERNAL_PIXEL_ELEMENTS: {
7047
+ ExternalPixelArray* pixels = ExternalPixelArray::cast(elements());
6789
7048
  if (index < static_cast<uint32_t>(pixels->length())) return FAST_ELEMENT;
6790
7049
  break;
6791
7050
  }
@@ -6818,10 +7077,12 @@ JSObject::LocalElementType JSObject::HasLocalElement(uint32_t index) {
6818
7077
 
6819
7078
  bool JSObject::HasElementWithReceiver(JSObject* receiver, uint32_t index) {
6820
7079
  // Check access rights if needed.
6821
- if (IsAccessCheckNeeded() &&
6822
- !Top::MayIndexedAccess(this, index, v8::ACCESS_HAS)) {
6823
- Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS);
6824
- return false;
7080
+ if (IsAccessCheckNeeded()) {
7081
+ Heap* heap = GetHeap();
7082
+ if (!heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_HAS)) {
7083
+ heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
7084
+ return false;
7085
+ }
6825
7086
  }
6826
7087
 
6827
7088
  // Check for lookup interceptor
@@ -6839,8 +7100,8 @@ bool JSObject::HasElementWithReceiver(JSObject* receiver, uint32_t index) {
6839
7100
  !FixedArray::cast(elements())->get(index)->IsTheHole()) return true;
6840
7101
  break;
6841
7102
  }
6842
- case PIXEL_ELEMENTS: {
6843
- PixelArray* pixels = PixelArray::cast(elements());
7103
+ case EXTERNAL_PIXEL_ELEMENTS: {
7104
+ ExternalPixelArray* pixels = ExternalPixelArray::cast(elements());
6844
7105
  if (index < static_cast<uint32_t>(pixels->length())) {
6845
7106
  return true;
6846
7107
  }
@@ -6875,41 +7136,45 @@ bool JSObject::HasElementWithReceiver(JSObject* receiver, uint32_t index) {
6875
7136
  if (this->IsStringObjectWithCharacterAt(index)) return true;
6876
7137
 
6877
7138
  Object* pt = GetPrototype();
6878
- if (pt == Heap::null_value()) return false;
7139
+ if (pt->IsNull()) return false;
6879
7140
  return JSObject::cast(pt)->HasElementWithReceiver(receiver, index);
6880
7141
  }
6881
7142
 
6882
7143
 
6883
7144
  MaybeObject* JSObject::SetElementWithInterceptor(uint32_t index,
6884
7145
  Object* value,
7146
+ StrictModeFlag strict_mode,
6885
7147
  bool check_prototype) {
7148
+ Isolate* isolate = GetIsolate();
6886
7149
  // Make sure that the top context does not change when doing
6887
7150
  // callbacks or interceptor calls.
6888
7151
  AssertNoContextChange ncc;
6889
- HandleScope scope;
7152
+ HandleScope scope(isolate);
6890
7153
  Handle<InterceptorInfo> interceptor(GetIndexedInterceptor());
6891
7154
  Handle<JSObject> this_handle(this);
6892
- Handle<Object> value_handle(value);
7155
+ Handle<Object> value_handle(value, isolate);
6893
7156
  if (!interceptor->setter()->IsUndefined()) {
6894
7157
  v8::IndexedPropertySetter setter =
6895
7158
  v8::ToCData<v8::IndexedPropertySetter>(interceptor->setter());
6896
- LOG(ApiIndexedPropertyAccess("interceptor-indexed-set", this, index));
6897
- CustomArguments args(interceptor->data(), this, this);
7159
+ LOG(isolate,
7160
+ ApiIndexedPropertyAccess("interceptor-indexed-set", this, index));
7161
+ CustomArguments args(isolate, interceptor->data(), this, this);
6898
7162
  v8::AccessorInfo info(args.end());
6899
7163
  v8::Handle<v8::Value> result;
6900
7164
  {
6901
7165
  // Leaving JavaScript.
6902
- VMState state(EXTERNAL);
7166
+ VMState state(isolate, EXTERNAL);
6903
7167
  result = setter(index, v8::Utils::ToLocal(value_handle), info);
6904
7168
  }
6905
- RETURN_IF_SCHEDULED_EXCEPTION();
7169
+ RETURN_IF_SCHEDULED_EXCEPTION(isolate);
6906
7170
  if (!result.IsEmpty()) return *value_handle;
6907
7171
  }
6908
7172
  MaybeObject* raw_result =
6909
7173
  this_handle->SetElementWithoutInterceptor(index,
6910
7174
  *value_handle,
7175
+ strict_mode,
6911
7176
  check_prototype);
6912
- RETURN_IF_SCHEDULED_EXCEPTION();
7177
+ RETURN_IF_SCHEDULED_EXCEPTION(isolate);
6913
7178
  return raw_result;
6914
7179
  }
6915
7180
 
@@ -6918,6 +7183,7 @@ MaybeObject* JSObject::GetElementWithCallback(Object* receiver,
6918
7183
  Object* structure,
6919
7184
  uint32_t index,
6920
7185
  Object* holder) {
7186
+ Isolate* isolate = GetIsolate();
6921
7187
  ASSERT(!structure->IsProxy());
6922
7188
 
6923
7189
  // api style callbacks.
@@ -6925,22 +7191,22 @@ MaybeObject* JSObject::GetElementWithCallback(Object* receiver,
6925
7191
  AccessorInfo* data = AccessorInfo::cast(structure);
6926
7192
  Object* fun_obj = data->getter();
6927
7193
  v8::AccessorGetter call_fun = v8::ToCData<v8::AccessorGetter>(fun_obj);
6928
- HandleScope scope;
7194
+ HandleScope scope(isolate);
6929
7195
  Handle<JSObject> self(JSObject::cast(receiver));
6930
7196
  Handle<JSObject> holder_handle(JSObject::cast(holder));
6931
- Handle<Object> number = Factory::NewNumberFromUint(index);
6932
- Handle<String> key(Factory::NumberToString(number));
6933
- LOG(ApiNamedPropertyAccess("load", *self, *key));
6934
- CustomArguments args(data->data(), *self, *holder_handle);
7197
+ Handle<Object> number = isolate->factory()->NewNumberFromUint(index);
7198
+ Handle<String> key(isolate->factory()->NumberToString(number));
7199
+ LOG(isolate, ApiNamedPropertyAccess("load", *self, *key));
7200
+ CustomArguments args(isolate, data->data(), *self, *holder_handle);
6935
7201
  v8::AccessorInfo info(args.end());
6936
7202
  v8::Handle<v8::Value> result;
6937
7203
  {
6938
7204
  // Leaving JavaScript.
6939
- VMState state(EXTERNAL);
7205
+ VMState state(isolate, EXTERNAL);
6940
7206
  result = call_fun(v8::Utils::ToLocal(key), info);
6941
7207
  }
6942
- RETURN_IF_SCHEDULED_EXCEPTION();
6943
- if (result.IsEmpty()) return Heap::undefined_value();
7208
+ RETURN_IF_SCHEDULED_EXCEPTION(isolate);
7209
+ if (result.IsEmpty()) return isolate->heap()->undefined_value();
6944
7210
  return *v8::Utils::OpenHandle(*result);
6945
7211
  }
6946
7212
 
@@ -6952,7 +7218,7 @@ MaybeObject* JSObject::GetElementWithCallback(Object* receiver,
6952
7218
  JSFunction::cast(getter));
6953
7219
  }
6954
7220
  // Getter is not a function.
6955
- return Heap::undefined_value();
7221
+ return isolate->heap()->undefined_value();
6956
7222
  }
6957
7223
 
6958
7224
  UNREACHABLE();
@@ -6964,12 +7230,13 @@ MaybeObject* JSObject::SetElementWithCallback(Object* structure,
6964
7230
  uint32_t index,
6965
7231
  Object* value,
6966
7232
  JSObject* holder) {
6967
- HandleScope scope;
7233
+ Isolate* isolate = GetIsolate();
7234
+ HandleScope scope(isolate);
6968
7235
 
6969
7236
  // We should never get here to initialize a const with the hole
6970
7237
  // value since a const declaration would conflict with the setter.
6971
7238
  ASSERT(!value->IsTheHole());
6972
- Handle<Object> value_handle(value);
7239
+ Handle<Object> value_handle(value, isolate);
6973
7240
 
6974
7241
  // To accommodate both the old and the new api we switch on the
6975
7242
  // data structure used to store the callbacks. Eventually proxy
@@ -6982,19 +7249,19 @@ MaybeObject* JSObject::SetElementWithCallback(Object* structure,
6982
7249
  Object* call_obj = data->setter();
6983
7250
  v8::AccessorSetter call_fun = v8::ToCData<v8::AccessorSetter>(call_obj);
6984
7251
  if (call_fun == NULL) return value;
6985
- Handle<Object> number = Factory::NewNumberFromUint(index);
6986
- Handle<String> key(Factory::NumberToString(number));
6987
- LOG(ApiNamedPropertyAccess("store", this, *key));
6988
- CustomArguments args(data->data(), this, JSObject::cast(holder));
7252
+ Handle<Object> number = isolate->factory()->NewNumberFromUint(index);
7253
+ Handle<String> key(isolate->factory()->NumberToString(number));
7254
+ LOG(isolate, ApiNamedPropertyAccess("store", this, *key));
7255
+ CustomArguments args(isolate, data->data(), this, JSObject::cast(holder));
6989
7256
  v8::AccessorInfo info(args.end());
6990
7257
  {
6991
7258
  // Leaving JavaScript.
6992
- VMState state(EXTERNAL);
7259
+ VMState state(isolate, EXTERNAL);
6993
7260
  call_fun(v8::Utils::ToLocal(key),
6994
7261
  v8::Utils::ToLocal(value_handle),
6995
7262
  info);
6996
7263
  }
6997
- RETURN_IF_SCHEDULED_EXCEPTION();
7264
+ RETURN_IF_SCHEDULED_EXCEPTION(isolate);
6998
7265
  return *value_handle;
6999
7266
  }
7000
7267
 
@@ -7003,11 +7270,12 @@ MaybeObject* JSObject::SetElementWithCallback(Object* structure,
7003
7270
  if (setter->IsJSFunction()) {
7004
7271
  return SetPropertyWithDefinedSetter(JSFunction::cast(setter), value);
7005
7272
  } else {
7006
- Handle<Object> holder_handle(holder);
7007
- Handle<Object> key(Factory::NewNumberFromUint(index));
7273
+ Handle<Object> holder_handle(holder, isolate);
7274
+ Handle<Object> key(isolate->factory()->NewNumberFromUint(index));
7008
7275
  Handle<Object> args[2] = { key, holder_handle };
7009
- return Top::Throw(*Factory::NewTypeError("no_setter_in_callback",
7010
- HandleVector(args, 2)));
7276
+ return isolate->Throw(
7277
+ *isolate->factory()->NewTypeError("no_setter_in_callback",
7278
+ HandleVector(args, 2)));
7011
7279
  }
7012
7280
  }
7013
7281
 
@@ -7021,6 +7289,7 @@ MaybeObject* JSObject::SetElementWithCallback(Object* structure,
7021
7289
  // elements.
7022
7290
  MaybeObject* JSObject::SetFastElement(uint32_t index,
7023
7291
  Object* value,
7292
+ StrictModeFlag strict_mode,
7024
7293
  bool check_prototype) {
7025
7294
  ASSERT(HasFastElements());
7026
7295
 
@@ -7077,47 +7346,61 @@ MaybeObject* JSObject::SetFastElement(uint32_t index,
7077
7346
  if (!maybe_obj->ToObject(&obj)) return maybe_obj;
7078
7347
  }
7079
7348
  ASSERT(HasDictionaryElements());
7080
- return SetElement(index, value, check_prototype);
7349
+ return SetElement(index, value, strict_mode, check_prototype);
7081
7350
  }
7082
7351
 
7083
7352
 
7084
7353
  MaybeObject* JSObject::SetElement(uint32_t index,
7085
7354
  Object* value,
7355
+ StrictModeFlag strict_mode,
7086
7356
  bool check_prototype) {
7087
7357
  // Check access rights if needed.
7088
- if (IsAccessCheckNeeded() &&
7089
- !Top::MayIndexedAccess(this, index, v8::ACCESS_SET)) {
7090
- HandleScope scope;
7091
- Handle<Object> value_handle(value);
7092
- Top::ReportFailedAccessCheck(this, v8::ACCESS_SET);
7093
- return *value_handle;
7358
+ if (IsAccessCheckNeeded()) {
7359
+ Heap* heap = GetHeap();
7360
+ if (!heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_SET)) {
7361
+ HandleScope scope;
7362
+ Handle<Object> value_handle(value);
7363
+ heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_SET);
7364
+ return *value_handle;
7365
+ }
7094
7366
  }
7095
7367
 
7096
7368
  if (IsJSGlobalProxy()) {
7097
7369
  Object* proto = GetPrototype();
7098
7370
  if (proto->IsNull()) return value;
7099
7371
  ASSERT(proto->IsJSGlobalObject());
7100
- return JSObject::cast(proto)->SetElement(index, value, check_prototype);
7372
+ return JSObject::cast(proto)->SetElement(index,
7373
+ value,
7374
+ strict_mode,
7375
+ check_prototype);
7101
7376
  }
7102
7377
 
7103
7378
  // Check for lookup interceptor
7104
7379
  if (HasIndexedInterceptor()) {
7105
- return SetElementWithInterceptor(index, value, check_prototype);
7380
+ return SetElementWithInterceptor(index,
7381
+ value,
7382
+ strict_mode,
7383
+ check_prototype);
7106
7384
  }
7107
7385
 
7108
- return SetElementWithoutInterceptor(index, value, check_prototype);
7386
+ return SetElementWithoutInterceptor(index,
7387
+ value,
7388
+ strict_mode,
7389
+ check_prototype);
7109
7390
  }
7110
7391
 
7111
7392
 
7112
7393
  MaybeObject* JSObject::SetElementWithoutInterceptor(uint32_t index,
7113
7394
  Object* value,
7395
+ StrictModeFlag strict_mode,
7114
7396
  bool check_prototype) {
7397
+ Isolate* isolate = GetIsolate();
7115
7398
  switch (GetElementsKind()) {
7116
7399
  case FAST_ELEMENTS:
7117
7400
  // Fast case.
7118
- return SetFastElement(index, value, check_prototype);
7119
- case PIXEL_ELEMENTS: {
7120
- PixelArray* pixels = PixelArray::cast(elements());
7401
+ return SetFastElement(index, value, strict_mode, check_prototype);
7402
+ case EXTERNAL_PIXEL_ELEMENTS: {
7403
+ ExternalPixelArray* pixels = ExternalPixelArray::cast(elements());
7121
7404
  return pixels->SetValue(index, value);
7122
7405
  }
7123
7406
  case EXTERNAL_BYTE_ELEMENTS: {
@@ -7164,24 +7447,40 @@ MaybeObject* JSObject::SetElementWithoutInterceptor(uint32_t index,
7164
7447
  return SetElementWithCallback(element, index, value, this);
7165
7448
  } else {
7166
7449
  dictionary->UpdateMaxNumberKey(index);
7167
- dictionary->ValueAtPut(entry, value);
7450
+ // If put fails instrict mode, throw exception.
7451
+ if (!dictionary->ValueAtPut(entry, value) &&
7452
+ strict_mode == kStrictMode) {
7453
+ Handle<Object> number(isolate->factory()->NewNumberFromUint(index));
7454
+ Handle<Object> holder(this);
7455
+ Handle<Object> args[2] = { number, holder };
7456
+ return isolate->Throw(
7457
+ *isolate->factory()->NewTypeError("strict_read_only_property",
7458
+ HandleVector(args, 2)));
7459
+ }
7168
7460
  }
7169
7461
  } else {
7170
7462
  // Index not already used. Look for an accessor in the prototype chain.
7171
7463
  if (check_prototype) {
7172
7464
  bool found;
7173
7465
  MaybeObject* result =
7466
+ // Strict mode not needed. No-setter case already handled.
7174
7467
  SetElementWithCallbackSetterInPrototypes(index, value, &found);
7175
7468
  if (found) return result;
7176
7469
  }
7177
7470
  // When we set the is_extensible flag to false we always force
7178
7471
  // the element into dictionary mode (and force them to stay there).
7179
7472
  if (!map()->is_extensible()) {
7180
- Handle<Object> number(Factory::NewNumberFromUint(index));
7181
- Handle<String> index_string(Factory::NumberToString(number));
7182
- Handle<Object> args[1] = { index_string };
7183
- return Top::Throw(*Factory::NewTypeError("object_not_extensible",
7184
- HandleVector(args, 1)));
7473
+ if (strict_mode == kNonStrictMode) {
7474
+ return isolate->heap()->undefined_value();
7475
+ } else {
7476
+ Handle<Object> number(isolate->factory()->NewNumberFromUint(index));
7477
+ Handle<String> index_string(
7478
+ isolate->factory()->NumberToString(number));
7479
+ Handle<Object> args[1] = { index_string };
7480
+ return isolate->Throw(
7481
+ *isolate->factory()->NewTypeError("object_not_extensible",
7482
+ HandleVector(args, 1)));
7483
+ }
7185
7484
  }
7186
7485
  Object* result;
7187
7486
  { MaybeObject* maybe_result = dictionary->AtNumberPut(index, value);
@@ -7234,7 +7533,7 @@ MaybeObject* JSObject::SetElementWithoutInterceptor(uint32_t index,
7234
7533
  // All possible cases have been handled above. Add a return to avoid the
7235
7534
  // complaints from the compiler.
7236
7535
  UNREACHABLE();
7237
- return Heap::null_value();
7536
+ return isolate->heap()->null_value();
7238
7537
  }
7239
7538
 
7240
7539
 
@@ -7247,7 +7546,7 @@ MaybeObject* JSArray::JSArrayUpdateLengthFromIndex(uint32_t index,
7247
7546
  if (index >= old_len && index != 0xffffffff) {
7248
7547
  Object* len;
7249
7548
  { MaybeObject* maybe_len =
7250
- Heap::NumberFromDouble(static_cast<double>(index) + 1);
7549
+ GetHeap()->NumberFromDouble(static_cast<double>(index) + 1);
7251
7550
  if (!maybe_len->ToObject(&len)) return maybe_len;
7252
7551
  }
7253
7552
  set_length(len);
@@ -7269,7 +7568,7 @@ MaybeObject* JSObject::GetElementPostInterceptor(Object* receiver,
7269
7568
  }
7270
7569
  break;
7271
7570
  }
7272
- case PIXEL_ELEMENTS:
7571
+ case EXTERNAL_PIXEL_ELEMENTS:
7273
7572
  case EXTERNAL_BYTE_ELEMENTS:
7274
7573
  case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
7275
7574
  case EXTERNAL_SHORT_ELEMENTS:
@@ -7277,8 +7576,10 @@ MaybeObject* JSObject::GetElementPostInterceptor(Object* receiver,
7277
7576
  case EXTERNAL_INT_ELEMENTS:
7278
7577
  case EXTERNAL_UNSIGNED_INT_ELEMENTS:
7279
7578
  case EXTERNAL_FLOAT_ELEMENTS: {
7280
- MaybeObject* value = GetExternalElement(index);
7281
- if (!value->ToObjectUnchecked()->IsUndefined()) return value;
7579
+ MaybeObject* maybe_value = GetExternalElement(index);
7580
+ Object* value;
7581
+ if (!maybe_value->ToObject(&value)) return maybe_value;
7582
+ if (!value->IsUndefined()) return value;
7282
7583
  break;
7283
7584
  }
7284
7585
  case DICTIONARY_ELEMENTS: {
@@ -7304,40 +7605,42 @@ MaybeObject* JSObject::GetElementPostInterceptor(Object* receiver,
7304
7605
 
7305
7606
  // Continue searching via the prototype chain.
7306
7607
  Object* pt = GetPrototype();
7307
- if (pt == Heap::null_value()) return Heap::undefined_value();
7608
+ if (pt->IsNull()) return GetHeap()->undefined_value();
7308
7609
  return pt->GetElementWithReceiver(receiver, index);
7309
7610
  }
7310
7611
 
7311
7612
 
7312
7613
  MaybeObject* JSObject::GetElementWithInterceptor(Object* receiver,
7313
7614
  uint32_t index) {
7615
+ Isolate* isolate = GetIsolate();
7314
7616
  // Make sure that the top context does not change when doing
7315
7617
  // callbacks or interceptor calls.
7316
7618
  AssertNoContextChange ncc;
7317
- HandleScope scope;
7318
- Handle<InterceptorInfo> interceptor(GetIndexedInterceptor());
7319
- Handle<Object> this_handle(receiver);
7320
- Handle<JSObject> holder_handle(this);
7619
+ HandleScope scope(isolate);
7620
+ Handle<InterceptorInfo> interceptor(GetIndexedInterceptor(), isolate);
7621
+ Handle<Object> this_handle(receiver, isolate);
7622
+ Handle<JSObject> holder_handle(this, isolate);
7321
7623
 
7322
7624
  if (!interceptor->getter()->IsUndefined()) {
7323
7625
  v8::IndexedPropertyGetter getter =
7324
7626
  v8::ToCData<v8::IndexedPropertyGetter>(interceptor->getter());
7325
- LOG(ApiIndexedPropertyAccess("interceptor-indexed-get", this, index));
7326
- CustomArguments args(interceptor->data(), receiver, this);
7627
+ LOG(isolate,
7628
+ ApiIndexedPropertyAccess("interceptor-indexed-get", this, index));
7629
+ CustomArguments args(isolate, interceptor->data(), receiver, this);
7327
7630
  v8::AccessorInfo info(args.end());
7328
7631
  v8::Handle<v8::Value> result;
7329
7632
  {
7330
7633
  // Leaving JavaScript.
7331
- VMState state(EXTERNAL);
7634
+ VMState state(isolate, EXTERNAL);
7332
7635
  result = getter(index, info);
7333
7636
  }
7334
- RETURN_IF_SCHEDULED_EXCEPTION();
7637
+ RETURN_IF_SCHEDULED_EXCEPTION(isolate);
7335
7638
  if (!result.IsEmpty()) return *v8::Utils::OpenHandle(*result);
7336
7639
  }
7337
7640
 
7338
7641
  MaybeObject* raw_result =
7339
7642
  holder_handle->GetElementPostInterceptor(*this_handle, index);
7340
- RETURN_IF_SCHEDULED_EXCEPTION();
7643
+ RETURN_IF_SCHEDULED_EXCEPTION(isolate);
7341
7644
  return raw_result;
7342
7645
  }
7343
7646
 
@@ -7345,10 +7648,12 @@ MaybeObject* JSObject::GetElementWithInterceptor(Object* receiver,
7345
7648
  MaybeObject* JSObject::GetElementWithReceiver(Object* receiver,
7346
7649
  uint32_t index) {
7347
7650
  // Check access rights if needed.
7348
- if (IsAccessCheckNeeded() &&
7349
- !Top::MayIndexedAccess(this, index, v8::ACCESS_GET)) {
7350
- Top::ReportFailedAccessCheck(this, v8::ACCESS_GET);
7351
- return Heap::undefined_value();
7651
+ if (IsAccessCheckNeeded()) {
7652
+ Heap* heap = GetHeap();
7653
+ if (!heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_GET)) {
7654
+ heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_GET);
7655
+ return heap->undefined_value();
7656
+ }
7352
7657
  }
7353
7658
 
7354
7659
  if (HasIndexedInterceptor()) {
@@ -7366,7 +7671,7 @@ MaybeObject* JSObject::GetElementWithReceiver(Object* receiver,
7366
7671
  }
7367
7672
  break;
7368
7673
  }
7369
- case PIXEL_ELEMENTS:
7674
+ case EXTERNAL_PIXEL_ELEMENTS:
7370
7675
  case EXTERNAL_BYTE_ELEMENTS:
7371
7676
  case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
7372
7677
  case EXTERNAL_SHORT_ELEMENTS:
@@ -7374,8 +7679,10 @@ MaybeObject* JSObject::GetElementWithReceiver(Object* receiver,
7374
7679
  case EXTERNAL_INT_ELEMENTS:
7375
7680
  case EXTERNAL_UNSIGNED_INT_ELEMENTS:
7376
7681
  case EXTERNAL_FLOAT_ELEMENTS: {
7377
- MaybeObject* value = GetExternalElement(index);
7378
- if (!value->ToObjectUnchecked()->IsUndefined()) return value;
7682
+ MaybeObject* maybe_value = GetExternalElement(index);
7683
+ Object* value;
7684
+ if (!maybe_value->ToObject(&value)) return maybe_value;
7685
+ if (!value->IsUndefined()) return value;
7379
7686
  break;
7380
7687
  }
7381
7688
  case DICTIONARY_ELEMENTS: {
@@ -7397,7 +7704,8 @@ MaybeObject* JSObject::GetElementWithReceiver(Object* receiver,
7397
7704
  }
7398
7705
 
7399
7706
  Object* pt = GetPrototype();
7400
- if (pt == Heap::null_value()) return Heap::undefined_value();
7707
+ Heap* heap = GetHeap();
7708
+ if (pt == heap->null_value()) return heap->undefined_value();
7401
7709
  return pt->GetElementWithReceiver(receiver, index);
7402
7710
  }
7403
7711
 
@@ -7406,8 +7714,8 @@ MaybeObject* JSObject::GetExternalElement(uint32_t index) {
7406
7714
  // Get element works for both JSObject and JSArray since
7407
7715
  // JSArray::length cannot change.
7408
7716
  switch (GetElementsKind()) {
7409
- case PIXEL_ELEMENTS: {
7410
- PixelArray* pixels = PixelArray::cast(elements());
7717
+ case EXTERNAL_PIXEL_ELEMENTS: {
7718
+ ExternalPixelArray* pixels = ExternalPixelArray::cast(elements());
7411
7719
  if (index < static_cast<uint32_t>(pixels->length())) {
7412
7720
  uint8_t value = pixels->get(index);
7413
7721
  return Smi::FromInt(value);
@@ -7452,7 +7760,7 @@ MaybeObject* JSObject::GetExternalElement(uint32_t index) {
7452
7760
  ExternalIntArray* array = ExternalIntArray::cast(elements());
7453
7761
  if (index < static_cast<uint32_t>(array->length())) {
7454
7762
  int32_t value = array->get(index);
7455
- return Heap::NumberFromInt32(value);
7763
+ return GetHeap()->NumberFromInt32(value);
7456
7764
  }
7457
7765
  break;
7458
7766
  }
@@ -7461,7 +7769,7 @@ MaybeObject* JSObject::GetExternalElement(uint32_t index) {
7461
7769
  ExternalUnsignedIntArray::cast(elements());
7462
7770
  if (index < static_cast<uint32_t>(array->length())) {
7463
7771
  uint32_t value = array->get(index);
7464
- return Heap::NumberFromUint32(value);
7772
+ return GetHeap()->NumberFromUint32(value);
7465
7773
  }
7466
7774
  break;
7467
7775
  }
@@ -7469,7 +7777,7 @@ MaybeObject* JSObject::GetExternalElement(uint32_t index) {
7469
7777
  ExternalFloatArray* array = ExternalFloatArray::cast(elements());
7470
7778
  if (index < static_cast<uint32_t>(array->length())) {
7471
7779
  float value = array->get(index);
7472
- return Heap::AllocateHeapNumber(value);
7780
+ return GetHeap()->AllocateHeapNumber(value);
7473
7781
  }
7474
7782
  break;
7475
7783
  }
@@ -7478,7 +7786,7 @@ MaybeObject* JSObject::GetExternalElement(uint32_t index) {
7478
7786
  UNREACHABLE();
7479
7787
  break;
7480
7788
  }
7481
- return Heap::undefined_value();
7789
+ return GetHeap()->undefined_value();
7482
7790
  }
7483
7791
 
7484
7792
 
@@ -7495,7 +7803,7 @@ bool JSObject::HasDenseElements() {
7495
7803
  }
7496
7804
  break;
7497
7805
  }
7498
- case PIXEL_ELEMENTS:
7806
+ case EXTERNAL_PIXEL_ELEMENTS:
7499
7807
  case EXTERNAL_BYTE_ELEMENTS:
7500
7808
  case EXTERNAL_UNSIGNED_BYTE_ELEMENTS:
7501
7809
  case EXTERNAL_SHORT_ELEMENTS:
@@ -7632,7 +7940,7 @@ MaybeObject* JSObject::GetPropertyPostInterceptor(
7632
7940
  // Continue searching via the prototype chain.
7633
7941
  Object* pt = GetPrototype();
7634
7942
  *attributes = ABSENT;
7635
- if (pt == Heap::null_value()) return Heap::undefined_value();
7943
+ if (pt->IsNull()) return GetHeap()->undefined_value();
7636
7944
  return pt->GetPropertyWithReceiver(receiver, name, attributes);
7637
7945
  }
7638
7946
 
@@ -7647,7 +7955,7 @@ MaybeObject* JSObject::GetLocalPropertyPostInterceptor(
7647
7955
  if (result.IsProperty()) {
7648
7956
  return GetProperty(receiver, &result, name, attributes);
7649
7957
  }
7650
- return Heap::undefined_value();
7958
+ return GetHeap()->undefined_value();
7651
7959
  }
7652
7960
 
7653
7961
 
@@ -7655,8 +7963,9 @@ MaybeObject* JSObject::GetPropertyWithInterceptor(
7655
7963
  JSObject* receiver,
7656
7964
  String* name,
7657
7965
  PropertyAttributes* attributes) {
7966
+ Isolate* isolate = GetIsolate();
7658
7967
  InterceptorInfo* interceptor = GetNamedInterceptor();
7659
- HandleScope scope;
7968
+ HandleScope scope(isolate);
7660
7969
  Handle<JSObject> receiver_handle(receiver);
7661
7970
  Handle<JSObject> holder_handle(this);
7662
7971
  Handle<String> name_handle(name);
@@ -7664,16 +7973,17 @@ MaybeObject* JSObject::GetPropertyWithInterceptor(
7664
7973
  if (!interceptor->getter()->IsUndefined()) {
7665
7974
  v8::NamedPropertyGetter getter =
7666
7975
  v8::ToCData<v8::NamedPropertyGetter>(interceptor->getter());
7667
- LOG(ApiNamedPropertyAccess("interceptor-named-get", *holder_handle, name));
7668
- CustomArguments args(interceptor->data(), receiver, this);
7976
+ LOG(isolate,
7977
+ ApiNamedPropertyAccess("interceptor-named-get", *holder_handle, name));
7978
+ CustomArguments args(isolate, interceptor->data(), receiver, this);
7669
7979
  v8::AccessorInfo info(args.end());
7670
7980
  v8::Handle<v8::Value> result;
7671
7981
  {
7672
7982
  // Leaving JavaScript.
7673
- VMState state(EXTERNAL);
7983
+ VMState state(isolate, EXTERNAL);
7674
7984
  result = getter(v8::Utils::ToLocal(name_handle), info);
7675
7985
  }
7676
- RETURN_IF_SCHEDULED_EXCEPTION();
7986
+ RETURN_IF_SCHEDULED_EXCEPTION(isolate);
7677
7987
  if (!result.IsEmpty()) {
7678
7988
  *attributes = NONE;
7679
7989
  return *v8::Utils::OpenHandle(*result);
@@ -7684,17 +7994,19 @@ MaybeObject* JSObject::GetPropertyWithInterceptor(
7684
7994
  *receiver_handle,
7685
7995
  *name_handle,
7686
7996
  attributes);
7687
- RETURN_IF_SCHEDULED_EXCEPTION();
7997
+ RETURN_IF_SCHEDULED_EXCEPTION(isolate);
7688
7998
  return result;
7689
7999
  }
7690
8000
 
7691
8001
 
7692
8002
  bool JSObject::HasRealNamedProperty(String* key) {
7693
8003
  // Check access rights if needed.
7694
- if (IsAccessCheckNeeded() &&
7695
- !Top::MayNamedAccess(this, key, v8::ACCESS_HAS)) {
7696
- Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS);
7697
- return false;
8004
+ if (IsAccessCheckNeeded()) {
8005
+ Heap* heap = GetHeap();
8006
+ if (!heap->isolate()->MayNamedAccess(this, key, v8::ACCESS_HAS)) {
8007
+ heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
8008
+ return false;
8009
+ }
7698
8010
  }
7699
8011
 
7700
8012
  LookupResult result;
@@ -7705,10 +8017,12 @@ bool JSObject::HasRealNamedProperty(String* key) {
7705
8017
 
7706
8018
  bool JSObject::HasRealElementProperty(uint32_t index) {
7707
8019
  // Check access rights if needed.
7708
- if (IsAccessCheckNeeded() &&
7709
- !Top::MayIndexedAccess(this, index, v8::ACCESS_HAS)) {
7710
- Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS);
7711
- return false;
8020
+ if (IsAccessCheckNeeded()) {
8021
+ Heap* heap = GetHeap();
8022
+ if (!heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_HAS)) {
8023
+ heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
8024
+ return false;
8025
+ }
7712
8026
  }
7713
8027
 
7714
8028
  // Handle [] on String objects.
@@ -7723,8 +8037,8 @@ bool JSObject::HasRealElementProperty(uint32_t index) {
7723
8037
  return (index < length) &&
7724
8038
  !FixedArray::cast(elements())->get(index)->IsTheHole();
7725
8039
  }
7726
- case PIXEL_ELEMENTS: {
7727
- PixelArray* pixels = PixelArray::cast(elements());
8040
+ case EXTERNAL_PIXEL_ELEMENTS: {
8041
+ ExternalPixelArray* pixels = ExternalPixelArray::cast(elements());
7728
8042
  return index < static_cast<uint32_t>(pixels->length());
7729
8043
  }
7730
8044
  case EXTERNAL_BYTE_ELEMENTS:
@@ -7747,16 +8061,18 @@ bool JSObject::HasRealElementProperty(uint32_t index) {
7747
8061
  }
7748
8062
  // All possibilities have been handled above already.
7749
8063
  UNREACHABLE();
7750
- return Heap::null_value();
8064
+ return GetHeap()->null_value();
7751
8065
  }
7752
8066
 
7753
8067
 
7754
8068
  bool JSObject::HasRealNamedCallbackProperty(String* key) {
7755
8069
  // Check access rights if needed.
7756
- if (IsAccessCheckNeeded() &&
7757
- !Top::MayNamedAccess(this, key, v8::ACCESS_HAS)) {
7758
- Top::ReportFailedAccessCheck(this, v8::ACCESS_HAS);
7759
- return false;
8070
+ if (IsAccessCheckNeeded()) {
8071
+ Heap* heap = GetHeap();
8072
+ if (!heap->isolate()->MayNamedAccess(this, key, v8::ACCESS_HAS)) {
8073
+ heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
8074
+ return false;
8075
+ }
7760
8076
  }
7761
8077
 
7762
8078
  LookupResult result;
@@ -7955,8 +8271,8 @@ int JSObject::GetLocalElementKeys(FixedArray* storage,
7955
8271
  ASSERT(!storage || storage->length() >= counter);
7956
8272
  break;
7957
8273
  }
7958
- case PIXEL_ELEMENTS: {
7959
- int length = PixelArray::cast(elements())->length();
8274
+ case EXTERNAL_PIXEL_ELEMENTS: {
8275
+ int length = ExternalPixelArray::cast(elements())->length();
7960
8276
  while (counter < length) {
7961
8277
  if (storage != NULL) {
7962
8278
  storage->set(counter, Smi::FromInt(counter));
@@ -8018,51 +8334,6 @@ int JSObject::GetEnumElementKeys(FixedArray* storage) {
8018
8334
  }
8019
8335
 
8020
8336
 
8021
- bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) {
8022
- ASSERT(other->IsNumber());
8023
- return key == static_cast<uint32_t>(other->Number());
8024
- }
8025
-
8026
-
8027
- uint32_t NumberDictionaryShape::Hash(uint32_t key) {
8028
- return ComputeIntegerHash(key);
8029
- }
8030
-
8031
-
8032
- uint32_t NumberDictionaryShape::HashForObject(uint32_t key, Object* other) {
8033
- ASSERT(other->IsNumber());
8034
- return ComputeIntegerHash(static_cast<uint32_t>(other->Number()));
8035
- }
8036
-
8037
-
8038
- MaybeObject* NumberDictionaryShape::AsObject(uint32_t key) {
8039
- return Heap::NumberFromUint32(key);
8040
- }
8041
-
8042
-
8043
- bool StringDictionaryShape::IsMatch(String* key, Object* other) {
8044
- // We know that all entries in a hash table had their hash keys created.
8045
- // Use that knowledge to have fast failure.
8046
- if (key->Hash() != String::cast(other)->Hash()) return false;
8047
- return key->Equals(String::cast(other));
8048
- }
8049
-
8050
-
8051
- uint32_t StringDictionaryShape::Hash(String* key) {
8052
- return key->Hash();
8053
- }
8054
-
8055
-
8056
- uint32_t StringDictionaryShape::HashForObject(String* key, Object* other) {
8057
- return String::cast(other)->Hash();
8058
- }
8059
-
8060
-
8061
- MaybeObject* StringDictionaryShape::AsObject(String* key) {
8062
- return key;
8063
- }
8064
-
8065
-
8066
8337
  // StringKey simply carries a string object as key.
8067
8338
  class StringKey : public HashTableKey {
8068
8339
  public:
@@ -8145,7 +8416,7 @@ class StringSharedKey : public HashTableKey {
8145
8416
 
8146
8417
  MUST_USE_RESULT MaybeObject* AsObject() {
8147
8418
  Object* obj;
8148
- { MaybeObject* maybe_obj = Heap::AllocateFixedArray(3);
8419
+ { MaybeObject* maybe_obj = source_->GetHeap()->AllocateFixedArray(3);
8149
8420
  if (!maybe_obj->ToObject(&obj)) return maybe_obj;
8150
8421
  }
8151
8422
  FixedArray* pair = FixedArray::cast(obj);
@@ -8229,7 +8500,8 @@ class Utf8SymbolKey : public HashTableKey {
8229
8500
 
8230
8501
  MaybeObject* AsObject() {
8231
8502
  if (hash_field_ == 0) Hash();
8232
- return Heap::AllocateSymbol(string_, chars_, hash_field_);
8503
+ return Isolate::Current()->heap()->AllocateSymbol(
8504
+ string_, chars_, hash_field_);
8233
8505
  }
8234
8506
 
8235
8507
  Vector<const char> string_;
@@ -8296,7 +8568,7 @@ class AsciiSymbolKey : public SequentialSymbolKey<char> {
8296
8568
 
8297
8569
  MaybeObject* AsObject() {
8298
8570
  if (hash_field_ == 0) Hash();
8299
- return Heap::AllocateAsciiSymbol(string_, hash_field_);
8571
+ return HEAP->AllocateAsciiSymbol(string_, hash_field_);
8300
8572
  }
8301
8573
  };
8302
8574
 
@@ -8312,7 +8584,7 @@ class TwoByteSymbolKey : public SequentialSymbolKey<uc16> {
8312
8584
 
8313
8585
  MaybeObject* AsObject() {
8314
8586
  if (hash_field_ == 0) Hash();
8315
- return Heap::AllocateTwoByteSymbol(string_, hash_field_);
8587
+ return HEAP->AllocateTwoByteSymbol(string_, hash_field_);
8316
8588
  }
8317
8589
  };
8318
8590
 
@@ -8320,7 +8592,8 @@ class TwoByteSymbolKey : public SequentialSymbolKey<uc16> {
8320
8592
  // SymbolKey carries a string/symbol object as key.
8321
8593
  class SymbolKey : public HashTableKey {
8322
8594
  public:
8323
- explicit SymbolKey(String* string) : string_(string) { }
8595
+ explicit SymbolKey(String* string)
8596
+ : string_(string) { }
8324
8597
 
8325
8598
  bool IsMatch(Object* string) {
8326
8599
  return String::cast(string)->Equals(string_);
@@ -8336,8 +8609,9 @@ class SymbolKey : public HashTableKey {
8336
8609
  // Attempt to flatten the string, so that symbols will most often
8337
8610
  // be flat strings.
8338
8611
  string_ = string_->TryFlattenGetString();
8612
+ Heap* heap = string_->GetHeap();
8339
8613
  // Transform string to symbol if possible.
8340
- Map* map = Heap::SymbolMapForString(string_);
8614
+ Map* map = heap->SymbolMapForString(string_);
8341
8615
  if (map != NULL) {
8342
8616
  string_->set_map(map);
8343
8617
  ASSERT(string_->IsSymbol());
@@ -8345,7 +8619,7 @@ class SymbolKey : public HashTableKey {
8345
8619
  }
8346
8620
  // Otherwise allocate a new symbol.
8347
8621
  StringInputBuffer buffer(string_);
8348
- return Heap::AllocateInternalSymbol(&buffer,
8622
+ return heap->AllocateInternalSymbol(&buffer,
8349
8623
  string_->length(),
8350
8624
  string_->hash_field());
8351
8625
  }
@@ -8384,8 +8658,8 @@ MaybeObject* HashTable<Shape, Key>::Allocate(int at_least_space_for,
8384
8658
  }
8385
8659
 
8386
8660
  Object* obj;
8387
- { MaybeObject* maybe_obj =
8388
- Heap::AllocateHashTable(EntryToIndex(capacity), pretenure);
8661
+ { MaybeObject* maybe_obj = Isolate::Current()->heap()->
8662
+ AllocateHashTable(EntryToIndex(capacity), pretenure);
8389
8663
  if (!maybe_obj->ToObject(&obj)) return maybe_obj;
8390
8664
  }
8391
8665
  HashTable::cast(obj)->SetNumberOfElements(0);
@@ -8395,23 +8669,6 @@ MaybeObject* HashTable<Shape, Key>::Allocate(int at_least_space_for,
8395
8669
  }
8396
8670
 
8397
8671
 
8398
- // Find entry for key otherwise return kNotFound.
8399
- template<typename Shape, typename Key>
8400
- int HashTable<Shape, Key>::FindEntry(Key key) {
8401
- uint32_t capacity = Capacity();
8402
- uint32_t entry = FirstProbe(Shape::Hash(key), capacity);
8403
- uint32_t count = 1;
8404
- // EnsureCapacity will guarantee the hash table is never full.
8405
- while (true) {
8406
- Object* element = KeyAt(entry);
8407
- if (element->IsUndefined()) break; // Empty entry.
8408
- if (!element->IsNull() && Shape::IsMatch(key, element)) return entry;
8409
- entry = NextProbe(entry, count++, capacity);
8410
- }
8411
- return kNotFound;
8412
- }
8413
-
8414
-
8415
8672
  // Find entry for key otherwise return kNotFound.
8416
8673
  int StringDictionary::FindEntry(String* key) {
8417
8674
  if (!key->IsSymbol()) {
@@ -8467,7 +8724,7 @@ MaybeObject* HashTable<Shape, Key>::EnsureCapacity(int n, Key key) {
8467
8724
 
8468
8725
  const int kMinCapacityForPretenure = 256;
8469
8726
  bool pretenure =
8470
- (capacity > kMinCapacityForPretenure) && !Heap::InNewSpace(this);
8727
+ (capacity > kMinCapacityForPretenure) && !GetHeap()->InNewSpace(this);
8471
8728
  Object* obj;
8472
8729
  { MaybeObject* maybe_obj =
8473
8730
  Allocate(nof * 2, pretenure ? TENURED : NOT_TENURED);
@@ -8608,7 +8865,7 @@ MaybeObject* JSObject::PrepareSlowElementsForSort(uint32_t limit) {
8608
8865
  if (limit > static_cast<uint32_t>(Smi::kMaxValue)) {
8609
8866
  // Allocate space for result before we start mutating the object.
8610
8867
  Object* new_double;
8611
- { MaybeObject* maybe_new_double = Heap::AllocateHeapNumber(0.0);
8868
+ { MaybeObject* maybe_new_double = GetHeap()->AllocateHeapNumber(0.0);
8612
8869
  if (!maybe_new_double->ToObject(&new_double)) return maybe_new_double;
8613
8870
  }
8614
8871
  result_double = HeapNumber::cast(new_double);
@@ -8668,13 +8925,14 @@ MaybeObject* JSObject::PrepareSlowElementsForSort(uint32_t limit) {
8668
8925
 
8669
8926
  uint32_t result = pos;
8670
8927
  PropertyDetails no_details = PropertyDetails(NONE, NORMAL);
8928
+ Heap* heap = GetHeap();
8671
8929
  while (undefs > 0) {
8672
8930
  if (pos > static_cast<uint32_t>(Smi::kMaxValue)) {
8673
8931
  // Adding an entry with the key beyond smi-range requires
8674
8932
  // allocation. Bailout.
8675
8933
  return Smi::FromInt(-1);
8676
8934
  }
8677
- new_dict->AddNumberEntry(pos, Heap::undefined_value(), no_details)->
8935
+ new_dict->AddNumberEntry(pos, heap->undefined_value(), no_details)->
8678
8936
  ToObjectUnchecked();
8679
8937
  pos++;
8680
8938
  undefs--;
@@ -8697,7 +8955,9 @@ MaybeObject* JSObject::PrepareSlowElementsForSort(uint32_t limit) {
8697
8955
  // If the object is in dictionary mode, it is converted to fast elements
8698
8956
  // mode.
8699
8957
  MaybeObject* JSObject::PrepareElementsForSort(uint32_t limit) {
8700
- ASSERT(!HasPixelElements() && !HasExternalArrayElements());
8958
+ ASSERT(!HasExternalArrayElements());
8959
+
8960
+ Heap* heap = GetHeap();
8701
8961
 
8702
8962
  if (HasDictionaryElements()) {
8703
8963
  // Convert to fast elements containing only the existing properties.
@@ -8715,10 +8975,10 @@ MaybeObject* JSObject::PrepareElementsForSort(uint32_t limit) {
8715
8975
  }
8716
8976
  Map* new_map = Map::cast(obj);
8717
8977
 
8718
- PretenureFlag tenure = Heap::InNewSpace(this) ? NOT_TENURED: TENURED;
8978
+ PretenureFlag tenure = heap->InNewSpace(this) ? NOT_TENURED: TENURED;
8719
8979
  Object* new_array;
8720
8980
  { MaybeObject* maybe_new_array =
8721
- Heap::AllocateFixedArray(dict->NumberOfElements(), tenure);
8981
+ heap->AllocateFixedArray(dict->NumberOfElements(), tenure);
8722
8982
  if (!maybe_new_array->ToObject(&new_array)) return maybe_new_array;
8723
8983
  }
8724
8984
  FixedArray* fast_elements = FixedArray::cast(new_array);
@@ -8751,7 +9011,7 @@ MaybeObject* JSObject::PrepareElementsForSort(uint32_t limit) {
8751
9011
  // Pessimistically allocate space for return value before
8752
9012
  // we start mutating the array.
8753
9013
  Object* new_double;
8754
- { MaybeObject* maybe_new_double = Heap::AllocateHeapNumber(0.0);
9014
+ { MaybeObject* maybe_new_double = heap->AllocateHeapNumber(0.0);
8755
9015
  if (!maybe_new_double->ToObject(&new_double)) return maybe_new_double;
8756
9016
  }
8757
9017
  result_double = HeapNumber::cast(new_double);
@@ -8809,7 +9069,7 @@ MaybeObject* JSObject::PrepareElementsForSort(uint32_t limit) {
8809
9069
  }
8810
9070
 
8811
9071
 
8812
- Object* PixelArray::SetValue(uint32_t index, Object* value) {
9072
+ Object* ExternalPixelArray::SetValue(uint32_t index, Object* value) {
8813
9073
  uint8_t clamped_value = 0;
8814
9074
  if (index < static_cast<uint32_t>(length())) {
8815
9075
  if (value->IsSmi()) {
@@ -8845,7 +9105,8 @@ Object* PixelArray::SetValue(uint32_t index, Object* value) {
8845
9105
 
8846
9106
 
8847
9107
  template<typename ExternalArrayClass, typename ValueType>
8848
- static MaybeObject* ExternalArrayIntSetter(ExternalArrayClass* receiver,
9108
+ static MaybeObject* ExternalArrayIntSetter(Heap* heap,
9109
+ ExternalArrayClass* receiver,
8849
9110
  uint32_t index,
8850
9111
  Object* value) {
8851
9112
  ValueType cast_value = 0;
@@ -8863,45 +9124,46 @@ static MaybeObject* ExternalArrayIntSetter(ExternalArrayClass* receiver,
8863
9124
  }
8864
9125
  receiver->set(index, cast_value);
8865
9126
  }
8866
- return Heap::NumberFromInt32(cast_value);
9127
+ return heap->NumberFromInt32(cast_value);
8867
9128
  }
8868
9129
 
8869
9130
 
8870
9131
  MaybeObject* ExternalByteArray::SetValue(uint32_t index, Object* value) {
8871
9132
  return ExternalArrayIntSetter<ExternalByteArray, int8_t>
8872
- (this, index, value);
9133
+ (GetHeap(), this, index, value);
8873
9134
  }
8874
9135
 
8875
9136
 
8876
9137
  MaybeObject* ExternalUnsignedByteArray::SetValue(uint32_t index,
8877
9138
  Object* value) {
8878
9139
  return ExternalArrayIntSetter<ExternalUnsignedByteArray, uint8_t>
8879
- (this, index, value);
9140
+ (GetHeap(), this, index, value);
8880
9141
  }
8881
9142
 
8882
9143
 
8883
9144
  MaybeObject* ExternalShortArray::SetValue(uint32_t index,
8884
9145
  Object* value) {
8885
9146
  return ExternalArrayIntSetter<ExternalShortArray, int16_t>
8886
- (this, index, value);
9147
+ (GetHeap(), this, index, value);
8887
9148
  }
8888
9149
 
8889
9150
 
8890
9151
  MaybeObject* ExternalUnsignedShortArray::SetValue(uint32_t index,
8891
9152
  Object* value) {
8892
9153
  return ExternalArrayIntSetter<ExternalUnsignedShortArray, uint16_t>
8893
- (this, index, value);
9154
+ (GetHeap(), this, index, value);
8894
9155
  }
8895
9156
 
8896
9157
 
8897
9158
  MaybeObject* ExternalIntArray::SetValue(uint32_t index, Object* value) {
8898
9159
  return ExternalArrayIntSetter<ExternalIntArray, int32_t>
8899
- (this, index, value);
9160
+ (GetHeap(), this, index, value);
8900
9161
  }
8901
9162
 
8902
9163
 
8903
9164
  MaybeObject* ExternalUnsignedIntArray::SetValue(uint32_t index, Object* value) {
8904
9165
  uint32_t cast_value = 0;
9166
+ Heap* heap = GetHeap();
8905
9167
  if (index < static_cast<uint32_t>(length())) {
8906
9168
  if (value->IsSmi()) {
8907
9169
  int int_value = Smi::cast(value)->value();
@@ -8916,12 +9178,13 @@ MaybeObject* ExternalUnsignedIntArray::SetValue(uint32_t index, Object* value) {
8916
9178
  }
8917
9179
  set(index, cast_value);
8918
9180
  }
8919
- return Heap::NumberFromUint32(cast_value);
9181
+ return heap->NumberFromUint32(cast_value);
8920
9182
  }
8921
9183
 
8922
9184
 
8923
9185
  MaybeObject* ExternalFloatArray::SetValue(uint32_t index, Object* value) {
8924
9186
  float cast_value = 0;
9187
+ Heap* heap = GetHeap();
8925
9188
  if (index < static_cast<uint32_t>(length())) {
8926
9189
  if (value->IsSmi()) {
8927
9190
  int int_value = Smi::cast(value)->value();
@@ -8936,7 +9199,7 @@ MaybeObject* ExternalFloatArray::SetValue(uint32_t index, Object* value) {
8936
9199
  }
8937
9200
  set(index, cast_value);
8938
9201
  }
8939
- return Heap::AllocateHeapNumber(cast_value);
9202
+ return heap->AllocateHeapNumber(cast_value);
8940
9203
  }
8941
9204
 
8942
9205
 
@@ -8951,9 +9214,10 @@ MaybeObject* GlobalObject::EnsurePropertyCell(String* name) {
8951
9214
  ASSERT(!HasFastProperties());
8952
9215
  int entry = property_dictionary()->FindEntry(name);
8953
9216
  if (entry == StringDictionary::kNotFound) {
9217
+ Heap* heap = GetHeap();
8954
9218
  Object* cell;
8955
9219
  { MaybeObject* maybe_cell =
8956
- Heap::AllocateJSGlobalPropertyCell(Heap::the_hole_value());
9220
+ heap->AllocateJSGlobalPropertyCell(heap->the_hole_value());
8957
9221
  if (!maybe_cell->ToObject(&cell)) return maybe_cell;
8958
9222
  }
8959
9223
  PropertyDetails details(NONE, NORMAL);
@@ -9127,7 +9391,7 @@ MaybeObject* SymbolTable::LookupKey(HashTableKey* key, Object** s) {
9127
9391
  Object* CompilationCacheTable::Lookup(String* src) {
9128
9392
  StringKey key(src);
9129
9393
  int entry = FindEntry(&key);
9130
- if (entry == kNotFound) return Heap::undefined_value();
9394
+ if (entry == kNotFound) return GetHeap()->undefined_value();
9131
9395
  return get(EntryToIndex(entry) + 1);
9132
9396
  }
9133
9397
 
@@ -9137,7 +9401,7 @@ Object* CompilationCacheTable::LookupEval(String* src,
9137
9401
  StrictModeFlag strict_mode) {
9138
9402
  StringSharedKey key(src, context->closure()->shared(), strict_mode);
9139
9403
  int entry = FindEntry(&key);
9140
- if (entry == kNotFound) return Heap::undefined_value();
9404
+ if (entry == kNotFound) return GetHeap()->undefined_value();
9141
9405
  return get(EntryToIndex(entry) + 1);
9142
9406
  }
9143
9407
 
@@ -9146,7 +9410,7 @@ Object* CompilationCacheTable::LookupRegExp(String* src,
9146
9410
  JSRegExp::Flags flags) {
9147
9411
  RegExpKey key(src, flags);
9148
9412
  int entry = FindEntry(&key);
9149
- if (entry == kNotFound) return Heap::undefined_value();
9413
+ if (entry == kNotFound) return GetHeap()->undefined_value();
9150
9414
  return get(EntryToIndex(entry) + 1);
9151
9415
  }
9152
9416
 
@@ -9217,12 +9481,13 @@ MaybeObject* CompilationCacheTable::PutRegExp(String* src,
9217
9481
 
9218
9482
 
9219
9483
  void CompilationCacheTable::Remove(Object* value) {
9484
+ Object* null_value = GetHeap()->null_value();
9220
9485
  for (int entry = 0, size = Capacity(); entry < size; entry++) {
9221
9486
  int entry_index = EntryToIndex(entry);
9222
9487
  int value_index = entry_index + 1;
9223
9488
  if (get(value_index) == value) {
9224
- fast_set(this, entry_index, Heap::null_value());
9225
- fast_set(this, value_index, Heap::null_value());
9489
+ fast_set(this, entry_index, null_value);
9490
+ fast_set(this, value_index, null_value);
9226
9491
  ElementRemoved();
9227
9492
  }
9228
9493
  }
@@ -9267,7 +9532,7 @@ class SymbolsKey : public HashTableKey {
9267
9532
  Object* MapCache::Lookup(FixedArray* array) {
9268
9533
  SymbolsKey key(array);
9269
9534
  int entry = FindEntry(&key);
9270
- if (entry == kNotFound) return Heap::undefined_value();
9535
+ if (entry == kNotFound) return GetHeap()->undefined_value();
9271
9536
  return get(EntryToIndex(entry) + 1);
9272
9537
  }
9273
9538
 
@@ -9304,11 +9569,12 @@ MaybeObject* Dictionary<Shape, Key>::Allocate(int at_least_space_for) {
9304
9569
 
9305
9570
  template<typename Shape, typename Key>
9306
9571
  MaybeObject* Dictionary<Shape, Key>::GenerateNewEnumerationIndices() {
9572
+ Heap* heap = Dictionary<Shape, Key>::GetHeap();
9307
9573
  int length = HashTable<Shape, Key>::NumberOfElements();
9308
9574
 
9309
9575
  // Allocate and initialize iteration order array.
9310
9576
  Object* obj;
9311
- { MaybeObject* maybe_obj = Heap::AllocateFixedArray(length);
9577
+ { MaybeObject* maybe_obj = heap->AllocateFixedArray(length);
9312
9578
  if (!maybe_obj->ToObject(&obj)) return maybe_obj;
9313
9579
  }
9314
9580
  FixedArray* iteration_order = FixedArray::cast(obj);
@@ -9317,7 +9583,7 @@ MaybeObject* Dictionary<Shape, Key>::GenerateNewEnumerationIndices() {
9317
9583
  }
9318
9584
 
9319
9585
  // Allocate array with enumeration order.
9320
- { MaybeObject* maybe_obj = Heap::AllocateFixedArray(length);
9586
+ { MaybeObject* maybe_obj = heap->AllocateFixedArray(length);
9321
9587
  if (!maybe_obj->ToObject(&obj)) return maybe_obj;
9322
9588
  }
9323
9589
  FixedArray* enumeration_order = FixedArray::cast(obj);
@@ -9378,8 +9644,9 @@ void NumberDictionary::RemoveNumberEntries(uint32_t from, uint32_t to) {
9378
9644
  // Do nothing if the interval [from, to) is empty.
9379
9645
  if (from >= to) return;
9380
9646
 
9647
+ Heap* heap = GetHeap();
9381
9648
  int removed_entries = 0;
9382
- Object* sentinel = Heap::null_value();
9649
+ Object* sentinel = heap->null_value();
9383
9650
  int capacity = Capacity();
9384
9651
  for (int i = 0; i < capacity; i++) {
9385
9652
  Object* key = KeyAt(i);
@@ -9400,14 +9667,15 @@ void NumberDictionary::RemoveNumberEntries(uint32_t from, uint32_t to) {
9400
9667
  template<typename Shape, typename Key>
9401
9668
  Object* Dictionary<Shape, Key>::DeleteProperty(int entry,
9402
9669
  JSObject::DeleteMode mode) {
9670
+ Heap* heap = Dictionary<Shape, Key>::GetHeap();
9403
9671
  PropertyDetails details = DetailsAt(entry);
9404
9672
  // Ignore attributes if forcing a deletion.
9405
9673
  if (details.IsDontDelete() && mode != JSObject::FORCE_DELETION) {
9406
- return Heap::false_value();
9674
+ return heap->false_value();
9407
9675
  }
9408
- SetEntry(entry, Heap::null_value(), Heap::null_value(), Smi::FromInt(0));
9676
+ SetEntry(entry, heap->null_value(), heap->null_value(), Smi::FromInt(0));
9409
9677
  HashTable<Shape, Key>::ElementRemoved();
9410
- return Heap::true_value();
9678
+ return heap->true_value();
9411
9679
  }
9412
9680
 
9413
9681
 
@@ -9631,7 +9899,8 @@ Object* Dictionary<Shape, Key>::SlowReverseLookup(Object* value) {
9631
9899
  if (e == value) return k;
9632
9900
  }
9633
9901
  }
9634
- return Heap::undefined_value();
9902
+ Heap* heap = Dictionary<Shape, Key>::GetHeap();
9903
+ return heap->undefined_value();
9635
9904
  }
9636
9905
 
9637
9906
 
@@ -9656,6 +9925,8 @@ MaybeObject* StringDictionary::TransformPropertiesToFastFor(
9656
9925
  int instance_descriptor_length = 0;
9657
9926
  int number_of_fields = 0;
9658
9927
 
9928
+ Heap* heap = GetHeap();
9929
+
9659
9930
  // Compute the length of the instance descriptor.
9660
9931
  int capacity = Capacity();
9661
9932
  for (int i = 0; i < capacity; i++) {
@@ -9666,7 +9937,7 @@ MaybeObject* StringDictionary::TransformPropertiesToFastFor(
9666
9937
  ASSERT(type != FIELD);
9667
9938
  instance_descriptor_length++;
9668
9939
  if (type == NORMAL &&
9669
- (!value->IsJSFunction() || Heap::InNewSpace(value))) {
9940
+ (!value->IsJSFunction() || heap->InNewSpace(value))) {
9670
9941
  number_of_fields += 1;
9671
9942
  }
9672
9943
  }
@@ -9694,7 +9965,7 @@ MaybeObject* StringDictionary::TransformPropertiesToFastFor(
9694
9965
  // Allocate the fixed array for the fields.
9695
9966
  Object* fields;
9696
9967
  { MaybeObject* maybe_fields =
9697
- Heap::AllocateFixedArray(number_of_allocated_fields);
9968
+ heap->AllocateFixedArray(number_of_allocated_fields);
9698
9969
  if (!maybe_fields->ToObject(&fields)) return maybe_fields;
9699
9970
  }
9700
9971
 
@@ -9707,13 +9978,13 @@ MaybeObject* StringDictionary::TransformPropertiesToFastFor(
9707
9978
  Object* value = ValueAt(i);
9708
9979
  // Ensure the key is a symbol before writing into the instance descriptor.
9709
9980
  Object* key;
9710
- { MaybeObject* maybe_key = Heap::LookupSymbol(String::cast(k));
9981
+ { MaybeObject* maybe_key = heap->LookupSymbol(String::cast(k));
9711
9982
  if (!maybe_key->ToObject(&key)) return maybe_key;
9712
9983
  }
9713
9984
  PropertyDetails details = DetailsAt(i);
9714
9985
  PropertyType type = details.type();
9715
9986
 
9716
- if (value->IsJSFunction() && !Heap::InNewSpace(value)) {
9987
+ if (value->IsJSFunction() && !heap->InNewSpace(value)) {
9717
9988
  ConstantFunctionDescriptor d(String::cast(key),
9718
9989
  JSFunction::cast(value),
9719
9990
  details.attributes(),
@@ -9788,7 +10059,7 @@ Object* DebugInfo::GetBreakPointInfo(int code_position) {
9788
10059
  int index = GetBreakPointInfoIndex(code_position);
9789
10060
 
9790
10061
  // Return the break point info object if any.
9791
- if (index == kNoBreakPointInfo) return Heap::undefined_value();
10062
+ if (index == kNoBreakPointInfo) return GetHeap()->undefined_value();
9792
10063
  return BreakPointInfo::cast(break_points()->get(index));
9793
10064
  }
9794
10065
 
@@ -9810,6 +10081,7 @@ void DebugInfo::SetBreakPoint(Handle<DebugInfo> debug_info,
9810
10081
  int source_position,
9811
10082
  int statement_position,
9812
10083
  Handle<Object> break_point_object) {
10084
+ Isolate* isolate = Isolate::Current();
9813
10085
  Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_position));
9814
10086
  if (!break_point_info->IsUndefined()) {
9815
10087
  BreakPointInfo::SetBreakPoint(
@@ -9832,8 +10104,9 @@ void DebugInfo::SetBreakPoint(Handle<DebugInfo> debug_info,
9832
10104
  Handle<FixedArray> old_break_points =
9833
10105
  Handle<FixedArray>(FixedArray::cast(debug_info->break_points()));
9834
10106
  Handle<FixedArray> new_break_points =
9835
- Factory::NewFixedArray(old_break_points->length() +
9836
- Debug::kEstimatedNofBreakPointsInFunction);
10107
+ isolate->factory()->NewFixedArray(
10108
+ old_break_points->length() +
10109
+ Debug::kEstimatedNofBreakPointsInFunction);
9837
10110
 
9838
10111
  debug_info->set_break_points(*new_break_points);
9839
10112
  for (int i = 0; i < old_break_points->length(); i++) {
@@ -9844,13 +10117,14 @@ void DebugInfo::SetBreakPoint(Handle<DebugInfo> debug_info,
9844
10117
  ASSERT(index != kNoBreakPointInfo);
9845
10118
 
9846
10119
  // Allocate new BreakPointInfo object and set the break point.
9847
- Handle<BreakPointInfo> new_break_point_info =
9848
- Handle<BreakPointInfo>::cast(Factory::NewStruct(BREAK_POINT_INFO_TYPE));
10120
+ Handle<BreakPointInfo> new_break_point_info = Handle<BreakPointInfo>::cast(
10121
+ isolate->factory()->NewStruct(BREAK_POINT_INFO_TYPE));
9849
10122
  new_break_point_info->set_code_position(Smi::FromInt(code_position));
9850
10123
  new_break_point_info->set_source_position(Smi::FromInt(source_position));
9851
10124
  new_break_point_info->
9852
10125
  set_statement_position(Smi::FromInt(statement_position));
9853
- new_break_point_info->set_break_point_objects(Heap::undefined_value());
10126
+ new_break_point_info->set_break_point_objects(
10127
+ isolate->heap()->undefined_value());
9854
10128
  BreakPointInfo::SetBreakPoint(new_break_point_info, break_point_object);
9855
10129
  debug_info->break_points()->set(index, *new_break_point_info);
9856
10130
  }
@@ -9860,7 +10134,7 @@ void DebugInfo::SetBreakPoint(Handle<DebugInfo> debug_info,
9860
10134
  Object* DebugInfo::GetBreakPointObjects(int code_position) {
9861
10135
  Object* break_point_info = GetBreakPointInfo(code_position);
9862
10136
  if (break_point_info->IsUndefined()) {
9863
- return Heap::undefined_value();
10137
+ return GetHeap()->undefined_value();
9864
10138
  }
9865
10139
  return BreakPointInfo::cast(break_point_info)->break_point_objects();
9866
10140
  }
@@ -9883,7 +10157,8 @@ int DebugInfo::GetBreakPointCount() {
9883
10157
 
9884
10158
  Object* DebugInfo::FindBreakPointInfo(Handle<DebugInfo> debug_info,
9885
10159
  Handle<Object> break_point_object) {
9886
- if (debug_info->break_points()->IsUndefined()) return Heap::undefined_value();
10160
+ Heap* heap = debug_info->GetHeap();
10161
+ if (debug_info->break_points()->IsUndefined()) return heap->undefined_value();
9887
10162
  for (int i = 0; i < debug_info->break_points()->length(); i++) {
9888
10163
  if (!debug_info->break_points()->get(i)->IsUndefined()) {
9889
10164
  Handle<BreakPointInfo> break_point_info =
@@ -9895,7 +10170,7 @@ Object* DebugInfo::FindBreakPointInfo(Handle<DebugInfo> debug_info,
9895
10170
  }
9896
10171
  }
9897
10172
  }
9898
- return Heap::undefined_value();
10173
+ return heap->undefined_value();
9899
10174
  }
9900
10175
 
9901
10176
 
@@ -9919,12 +10194,14 @@ int DebugInfo::GetBreakPointInfoIndex(int code_position) {
9919
10194
  // Remove the specified break point object.
9920
10195
  void BreakPointInfo::ClearBreakPoint(Handle<BreakPointInfo> break_point_info,
9921
10196
  Handle<Object> break_point_object) {
10197
+ Isolate* isolate = Isolate::Current();
9922
10198
  // If there are no break points just ignore.
9923
10199
  if (break_point_info->break_point_objects()->IsUndefined()) return;
9924
10200
  // If there is a single break point clear it if it is the same.
9925
10201
  if (!break_point_info->break_point_objects()->IsFixedArray()) {
9926
10202
  if (break_point_info->break_point_objects() == *break_point_object) {
9927
- break_point_info->set_break_point_objects(Heap::undefined_value());
10203
+ break_point_info->set_break_point_objects(
10204
+ isolate->heap()->undefined_value());
9928
10205
  }
9929
10206
  return;
9930
10207
  }
@@ -9934,7 +10211,7 @@ void BreakPointInfo::ClearBreakPoint(Handle<BreakPointInfo> break_point_info,
9934
10211
  Handle<FixedArray>(
9935
10212
  FixedArray::cast(break_point_info->break_point_objects()));
9936
10213
  Handle<FixedArray> new_array =
9937
- Factory::NewFixedArray(old_array->length() - 1);
10214
+ isolate->factory()->NewFixedArray(old_array->length() - 1);
9938
10215
  int found_count = 0;
9939
10216
  for (int i = 0; i < old_array->length(); i++) {
9940
10217
  if (old_array->get(i) == *break_point_object) {
@@ -9961,7 +10238,7 @@ void BreakPointInfo::SetBreakPoint(Handle<BreakPointInfo> break_point_info,
9961
10238
  if (break_point_info->break_point_objects() == *break_point_object) return;
9962
10239
  // If there was one break point object before replace with array.
9963
10240
  if (!break_point_info->break_point_objects()->IsFixedArray()) {
9964
- Handle<FixedArray> array = Factory::NewFixedArray(2);
10241
+ Handle<FixedArray> array = FACTORY->NewFixedArray(2);
9965
10242
  array->set(0, break_point_info->break_point_objects());
9966
10243
  array->set(1, *break_point_object);
9967
10244
  break_point_info->set_break_point_objects(*array);
@@ -9972,7 +10249,7 @@ void BreakPointInfo::SetBreakPoint(Handle<BreakPointInfo> break_point_info,
9972
10249
  Handle<FixedArray>(
9973
10250
  FixedArray::cast(break_point_info->break_point_objects()));
9974
10251
  Handle<FixedArray> new_array =
9975
- Factory::NewFixedArray(old_array->length() + 1);
10252
+ FACTORY->NewFixedArray(old_array->length() + 1);
9976
10253
  for (int i = 0; i < old_array->length(); i++) {
9977
10254
  // If the break point was there before just ignore.
9978
10255
  if (old_array->get(i) == *break_point_object) return;