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
@@ -170,14 +170,15 @@ PropertyKind.Indexed = 2;
170
170
 
171
171
  // A copy of the PropertyType enum from global.h
172
172
  PropertyType = {};
173
- PropertyType.Normal = 0;
174
- PropertyType.Field = 1;
175
- PropertyType.ConstantFunction = 2;
176
- PropertyType.Callbacks = 3;
177
- PropertyType.Interceptor = 4;
178
- PropertyType.MapTransition = 5;
179
- PropertyType.ConstantTransition = 6;
180
- PropertyType.NullDescriptor = 7;
173
+ PropertyType.Normal = 0;
174
+ PropertyType.Field = 1;
175
+ PropertyType.ConstantFunction = 2;
176
+ PropertyType.Callbacks = 3;
177
+ PropertyType.Interceptor = 4;
178
+ PropertyType.MapTransition = 5;
179
+ PropertyType.ExternalArrayTransition = 6;
180
+ PropertyType.ConstantTransition = 7;
181
+ PropertyType.NullDescriptor = 8;
181
182
 
182
183
 
183
184
  // Different attributes for a property.
@@ -223,12 +223,12 @@ int main(int argc, char** argv) {
223
223
  // Make sure all builtin scripts are cached.
224
224
  { HandleScope scope;
225
225
  for (int i = 0; i < i::Natives::GetBuiltinsCount(); i++) {
226
- i::Bootstrapper::NativesSourceLookup(i);
226
+ i::Isolate::Current()->bootstrapper()->NativesSourceLookup(i);
227
227
  }
228
228
  }
229
229
  // If we don't do this then we end up with a stray root pointing at the
230
230
  // context even after we have disposed of the context.
231
- i::Heap::CollectAllGarbage(true);
231
+ HEAP->CollectAllGarbage(true);
232
232
  i::Object* raw_context = *(v8::Utils::OpenHandle(*context));
233
233
  context.Dispose();
234
234
  CppByteSink sink(argv[1]);
@@ -91,8 +91,8 @@ void HeapObject::HeapObjectVerify() {
91
91
  case BYTE_ARRAY_TYPE:
92
92
  ByteArray::cast(this)->ByteArrayVerify();
93
93
  break;
94
- case PIXEL_ARRAY_TYPE:
95
- PixelArray::cast(this)->PixelArrayVerify();
94
+ case EXTERNAL_PIXEL_ARRAY_TYPE:
95
+ ExternalPixelArray::cast(this)->ExternalPixelArrayVerify();
96
96
  break;
97
97
  case EXTERNAL_BYTE_ARRAY_TYPE:
98
98
  ExternalByteArray::cast(this)->ExternalByteArrayVerify();
@@ -178,7 +178,7 @@ void HeapObject::HeapObjectVerify() {
178
178
 
179
179
  void HeapObject::VerifyHeapPointer(Object* p) {
180
180
  ASSERT(p->IsHeapObject());
181
- ASSERT(Heap::Contains(HeapObject::cast(p)));
181
+ ASSERT(HEAP->Contains(HeapObject::cast(p)));
182
182
  }
183
183
 
184
184
 
@@ -192,8 +192,8 @@ void ByteArray::ByteArrayVerify() {
192
192
  }
193
193
 
194
194
 
195
- void PixelArray::PixelArrayVerify() {
196
- ASSERT(IsPixelArray());
195
+ void ExternalPixelArray::ExternalPixelArrayVerify() {
196
+ ASSERT(IsExternalPixelArray());
197
197
  }
198
198
 
199
199
 
@@ -241,18 +241,18 @@ void JSObject::JSObjectVerify() {
241
241
  map()->NextFreePropertyIndex()));
242
242
  }
243
243
  ASSERT(map()->has_fast_elements() ==
244
- (elements()->map() == Heap::fixed_array_map() ||
245
- elements()->map() == Heap::fixed_cow_array_map()));
244
+ (elements()->map() == GetHeap()->fixed_array_map() ||
245
+ elements()->map() == GetHeap()->fixed_cow_array_map()));
246
246
  ASSERT(map()->has_fast_elements() == HasFastElements());
247
247
  }
248
248
 
249
249
 
250
250
  void Map::MapVerify() {
251
- ASSERT(!Heap::InNewSpace(this));
251
+ ASSERT(!HEAP->InNewSpace(this));
252
252
  ASSERT(FIRST_TYPE <= instance_type() && instance_type() <= LAST_TYPE);
253
253
  ASSERT(instance_size() == kVariableSizeSentinel ||
254
254
  (kPointerSize <= instance_size() &&
255
- instance_size() < Heap::Capacity()));
255
+ instance_size() < HEAP->Capacity()));
256
256
  VerifyHeapPointer(prototype());
257
257
  VerifyHeapPointer(instance_descriptors());
258
258
  }
@@ -261,8 +261,7 @@ void Map::MapVerify() {
261
261
  void Map::SharedMapVerify() {
262
262
  MapVerify();
263
263
  ASSERT(is_shared());
264
- ASSERT_EQ(Heap::empty_descriptor_array(), instance_descriptors());
265
- ASSERT_EQ(Heap::empty_fixed_array(), code_cache());
264
+ ASSERT_EQ(GetHeap()->empty_descriptor_array(), instance_descriptors());
266
265
  ASSERT_EQ(0, pre_allocated_property_fields());
267
266
  ASSERT_EQ(0, unused_property_fields());
268
267
  ASSERT_EQ(StaticVisitorBase::GetVisitorId(instance_type(), instance_size()),
@@ -316,7 +315,7 @@ void String::StringVerify() {
316
315
  CHECK(IsString());
317
316
  CHECK(length() >= 0 && length() <= Smi::kMaxValue);
318
317
  if (IsSymbol()) {
319
- CHECK(!Heap::InNewSpace(this));
318
+ CHECK(!HEAP->InNewSpace(this));
320
319
  }
321
320
  }
322
321
 
@@ -380,7 +379,7 @@ void Oddball::OddballVerify() {
380
379
  VerifyHeapPointer(to_string());
381
380
  Object* number = to_number();
382
381
  if (number->IsHeapObject()) {
383
- ASSERT(number == Heap::nan_value());
382
+ ASSERT(number == HEAP->nan_value());
384
383
  } else {
385
384
  ASSERT(number->IsSmi());
386
385
  int value = Smi::cast(number)->value();
@@ -591,16 +590,17 @@ void JSObject::IncrementSpillStatistics(SpillInformation* info) {
591
590
  int holes = 0;
592
591
  FixedArray* e = FixedArray::cast(elements());
593
592
  int len = e->length();
593
+ Heap* heap = HEAP;
594
594
  for (int i = 0; i < len; i++) {
595
- if (e->get(i) == Heap::the_hole_value()) holes++;
595
+ if (e->get(i) == heap->the_hole_value()) holes++;
596
596
  }
597
597
  info->number_of_fast_used_elements_ += len - holes;
598
598
  info->number_of_fast_unused_elements_ += holes;
599
599
  break;
600
600
  }
601
- case PIXEL_ELEMENTS: {
601
+ case EXTERNAL_PIXEL_ELEMENTS: {
602
602
  info->number_of_objects_with_fast_elements_++;
603
- PixelArray* e = PixelArray::cast(elements());
603
+ ExternalPixelArray* e = ExternalPixelArray::cast(elements());
604
604
  info->number_of_fast_used_elements_ += e->length();
605
605
  break;
606
606
  }
@@ -1,4 +1,4 @@
1
- // Copyright 2010 the V8 project authors. All rights reserved.
1
+ // Copyright 2011 the V8 project authors. All rights reserved.
2
2
  // Redistribution and use in source and binary forms, with or without
3
3
  // modification, are permitted provided that the following conditions are
4
4
  // met:
@@ -39,9 +39,10 @@
39
39
  #include "contexts.h"
40
40
  #include "conversions-inl.h"
41
41
  #include "heap.h"
42
- #include "memory.h"
42
+ #include "isolate.h"
43
43
  #include "property.h"
44
44
  #include "spaces.h"
45
+ #include "v8memory.h"
45
46
 
46
47
  namespace v8 {
47
48
  namespace internal {
@@ -78,7 +79,16 @@ PropertyDetails PropertyDetails::AsDeleted() {
78
79
  type* holder::name() { return type::cast(READ_FIELD(this, offset)); } \
79
80
  void holder::set_##name(type* value, WriteBarrierMode mode) { \
80
81
  WRITE_FIELD(this, offset, value); \
81
- CONDITIONAL_WRITE_BARRIER(this, offset, mode); \
82
+ CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, mode); \
83
+ }
84
+
85
+
86
+ // GC-safe accessors do not use HeapObject::GetHeap(), but access TLS instead.
87
+ #define ACCESSORS_GCSAFE(holder, name, type, offset) \
88
+ type* holder::name() { return type::cast(READ_FIELD(this, offset)); } \
89
+ void holder::set_##name(type* value, WriteBarrierMode mode) { \
90
+ WRITE_FIELD(this, offset, value); \
91
+ CONDITIONAL_WRITE_BARRIER(HEAP, this, offset, mode); \
82
92
  }
83
93
 
84
94
 
@@ -330,9 +340,10 @@ bool Object::IsByteArray() {
330
340
  }
331
341
 
332
342
 
333
- bool Object::IsPixelArray() {
343
+ bool Object::IsExternalPixelArray() {
334
344
  return Object::IsHeapObject() &&
335
- HeapObject::cast(this)->map()->instance_type() == PIXEL_ARRAY_TYPE;
345
+ HeapObject::cast(this)->map()->instance_type() ==
346
+ EXTERNAL_PIXEL_ARRAY_TYPE;
336
347
  }
337
348
 
338
349
 
@@ -418,7 +429,7 @@ bool MaybeObject::IsException() {
418
429
 
419
430
 
420
431
  bool MaybeObject::IsTheHole() {
421
- return this == Heap::the_hole_value();
432
+ return !IsFailure() && ToObjectUnchecked()->IsTheHole();
422
433
  }
423
434
 
424
435
 
@@ -486,22 +497,27 @@ bool Object::IsDeoptimizationOutputData() {
486
497
 
487
498
 
488
499
  bool Object::IsContext() {
489
- return Object::IsHeapObject()
490
- && (HeapObject::cast(this)->map() == Heap::context_map() ||
491
- HeapObject::cast(this)->map() == Heap::catch_context_map() ||
492
- HeapObject::cast(this)->map() == Heap::global_context_map());
500
+ if (Object::IsHeapObject()) {
501
+ Heap* heap = HeapObject::cast(this)->GetHeap();
502
+ return (HeapObject::cast(this)->map() == heap->context_map() ||
503
+ HeapObject::cast(this)->map() == heap->catch_context_map() ||
504
+ HeapObject::cast(this)->map() == heap->global_context_map());
505
+ }
506
+ return false;
493
507
  }
494
508
 
495
509
 
496
510
  bool Object::IsCatchContext() {
497
- return Object::IsHeapObject()
498
- && HeapObject::cast(this)->map() == Heap::catch_context_map();
511
+ return Object::IsHeapObject() &&
512
+ HeapObject::cast(this)->map() ==
513
+ HeapObject::cast(this)->GetHeap()->catch_context_map();
499
514
  }
500
515
 
501
516
 
502
517
  bool Object::IsGlobalContext() {
503
- return Object::IsHeapObject()
504
- && HeapObject::cast(this)->map() == Heap::global_context_map();
518
+ return Object::IsHeapObject() &&
519
+ HeapObject::cast(this)->map() ==
520
+ HeapObject::cast(this)->GetHeap()->global_context_map();
505
521
  }
506
522
 
507
523
 
@@ -523,6 +539,7 @@ bool Object::IsCode() {
523
539
 
524
540
 
525
541
  bool Object::IsOddball() {
542
+ ASSERT(HEAP->is_safe_to_read_maps());
526
543
  return Object::IsHeapObject()
527
544
  && HeapObject::cast(this)->map()->instance_type() == ODDBALL_TYPE;
528
545
  }
@@ -567,7 +584,8 @@ bool Object::IsProxy() {
567
584
 
568
585
 
569
586
  bool Object::IsBoolean() {
570
- return IsTrue() || IsFalse();
587
+ return IsOddball() &&
588
+ ((Oddball::cast(this)->kind() & Oddball::kNotBooleanMask) == 0);
571
589
  }
572
590
 
573
591
 
@@ -589,18 +607,21 @@ template <> inline bool Is<JSArray>(Object* obj) {
589
607
 
590
608
 
591
609
  bool Object::IsHashTable() {
592
- return Object::IsHeapObject()
593
- && HeapObject::cast(this)->map() == Heap::hash_table_map();
610
+ return Object::IsHeapObject() &&
611
+ HeapObject::cast(this)->map() ==
612
+ HeapObject::cast(this)->GetHeap()->hash_table_map();
594
613
  }
595
614
 
596
615
 
597
616
  bool Object::IsDictionary() {
598
- return IsHashTable() && this != Heap::symbol_table();
617
+ return IsHashTable() && this !=
618
+ HeapObject::cast(this)->GetHeap()->symbol_table();
599
619
  }
600
620
 
601
621
 
602
622
  bool Object::IsSymbolTable() {
603
- return IsHashTable() && this == Heap::raw_unchecked_symbol_table();
623
+ return IsHashTable() && this ==
624
+ HeapObject::cast(this)->GetHeap()->raw_unchecked_symbol_table();
604
625
  }
605
626
 
606
627
 
@@ -717,27 +738,32 @@ bool Object::IsStruct() {
717
738
 
718
739
 
719
740
  bool Object::IsUndefined() {
720
- return this == Heap::undefined_value();
741
+ return IsOddball() && Oddball::cast(this)->kind() == Oddball::kUndefined;
721
742
  }
722
743
 
723
744
 
724
745
  bool Object::IsNull() {
725
- return this == Heap::null_value();
746
+ return IsOddball() && Oddball::cast(this)->kind() == Oddball::kNull;
747
+ }
748
+
749
+
750
+ bool Object::IsTheHole() {
751
+ return IsOddball() && Oddball::cast(this)->kind() == Oddball::kTheHole;
726
752
  }
727
753
 
728
754
 
729
755
  bool Object::IsTrue() {
730
- return this == Heap::true_value();
756
+ return IsOddball() && Oddball::cast(this)->kind() == Oddball::kTrue;
731
757
  }
732
758
 
733
759
 
734
760
  bool Object::IsFalse() {
735
- return this == Heap::false_value();
761
+ return IsOddball() && Oddball::cast(this)->kind() == Oddball::kFalse;
736
762
  }
737
763
 
738
764
 
739
765
  bool Object::IsArgumentsMarker() {
740
- return this == Heap::arguments_marker();
766
+ return IsOddball() && Oddball::cast(this)->kind() == Oddball::kArgumentMarker;
741
767
  }
742
768
 
743
769
 
@@ -749,7 +775,6 @@ double Object::Number() {
749
775
  }
750
776
 
751
777
 
752
-
753
778
  MaybeObject* Object::ToSmi() {
754
779
  if (IsSmi()) return this;
755
780
  if (IsHeapNumber()) {
@@ -769,6 +794,10 @@ bool Object::HasSpecificClassOf(String* name) {
769
794
 
770
795
 
771
796
  MaybeObject* Object::GetElement(uint32_t index) {
797
+ // GetElement can trigger a getter which can cause allocation.
798
+ // This was not always the case. This ASSERT is here to catch
799
+ // leftover incorrect uses.
800
+ ASSERT(HEAP->IsAllocationAllowed());
772
801
  return GetElementWithReceiver(this, index);
773
802
  }
774
803
 
@@ -802,28 +831,62 @@ MaybeObject* Object::GetProperty(String* key, PropertyAttributes* attributes) {
802
831
  #define WRITE_FIELD(p, offset, value) \
803
832
  (*reinterpret_cast<Object**>(FIELD_ADDR(p, offset)) = value)
804
833
 
805
-
834
+ // TODO(isolates): Pass heap in to these macros.
806
835
  #define WRITE_BARRIER(object, offset) \
807
- Heap::RecordWrite(object->address(), offset);
836
+ object->GetHeap()->RecordWrite(object->address(), offset);
808
837
 
809
838
  // CONDITIONAL_WRITE_BARRIER must be issued after the actual
810
839
  // write due to the assert validating the written value.
811
- #define CONDITIONAL_WRITE_BARRIER(object, offset, mode) \
840
+ #define CONDITIONAL_WRITE_BARRIER(heap, object, offset, mode) \
812
841
  if (mode == UPDATE_WRITE_BARRIER) { \
813
- Heap::RecordWrite(object->address(), offset); \
842
+ heap->RecordWrite(object->address(), offset); \
814
843
  } else { \
815
844
  ASSERT(mode == SKIP_WRITE_BARRIER); \
816
- ASSERT(Heap::InNewSpace(object) || \
817
- !Heap::InNewSpace(READ_FIELD(object, offset)) || \
845
+ ASSERT(heap->InNewSpace(object) || \
846
+ !heap->InNewSpace(READ_FIELD(object, offset)) || \
818
847
  Page::FromAddress(object->address())-> \
819
848
  IsRegionDirty(object->address() + offset)); \
820
849
  }
821
850
 
822
- #define READ_DOUBLE_FIELD(p, offset) \
823
- (*reinterpret_cast<double*>(FIELD_ADDR(p, offset)))
851
+ #ifndef V8_TARGET_ARCH_MIPS
852
+ #define READ_DOUBLE_FIELD(p, offset) \
853
+ (*reinterpret_cast<double*>(FIELD_ADDR(p, offset)))
854
+ #else // V8_TARGET_ARCH_MIPS
855
+ // Prevent gcc from using load-double (mips ldc1) on (possibly)
856
+ // non-64-bit aligned HeapNumber::value.
857
+ static inline double read_double_field(HeapNumber* p, int offset) {
858
+ union conversion {
859
+ double d;
860
+ uint32_t u[2];
861
+ } c;
862
+ c.u[0] = (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset)));
863
+ c.u[1] = (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset + 4)));
864
+ return c.d;
865
+ }
866
+ #define READ_DOUBLE_FIELD(p, offset) read_double_field(p, offset)
867
+ #endif // V8_TARGET_ARCH_MIPS
868
+
869
+
870
+ #ifndef V8_TARGET_ARCH_MIPS
871
+ #define WRITE_DOUBLE_FIELD(p, offset, value) \
872
+ (*reinterpret_cast<double*>(FIELD_ADDR(p, offset)) = value)
873
+ #else // V8_TARGET_ARCH_MIPS
874
+ // Prevent gcc from using store-double (mips sdc1) on (possibly)
875
+ // non-64-bit aligned HeapNumber::value.
876
+ static inline void write_double_field(HeapNumber* p, int offset,
877
+ double value) {
878
+ union conversion {
879
+ double d;
880
+ uint32_t u[2];
881
+ } c;
882
+ c.d = value;
883
+ (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset))) = c.u[0];
884
+ (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset + 4))) = c.u[1];
885
+ }
886
+ #define WRITE_DOUBLE_FIELD(p, offset, value) \
887
+ write_double_field(p, offset, value)
888
+ #endif // V8_TARGET_ARCH_MIPS
824
889
 
825
- #define WRITE_DOUBLE_FIELD(p, offset, value) \
826
- (*reinterpret_cast<double*>(FIELD_ADDR(p, offset)) = value)
827
890
 
828
891
  #define READ_INT_FIELD(p, offset) \
829
892
  (*reinterpret_cast<int*>(FIELD_ADDR(p, offset)))
@@ -1094,6 +1157,21 @@ void HeapObject::VerifySmiField(int offset) {
1094
1157
  #endif
1095
1158
 
1096
1159
 
1160
+ Heap* HeapObject::GetHeap() {
1161
+ // During GC, the map pointer in HeapObject is used in various ways that
1162
+ // prevent us from retrieving Heap from the map.
1163
+ // Assert that we are not in GC, implement GC code in a way that it doesn't
1164
+ // pull heap from the map.
1165
+ ASSERT(HEAP->is_safe_to_read_maps());
1166
+ return map()->heap();
1167
+ }
1168
+
1169
+
1170
+ Isolate* HeapObject::GetIsolate() {
1171
+ return GetHeap()->isolate();
1172
+ }
1173
+
1174
+
1097
1175
  Map* HeapObject::map() {
1098
1176
  return map_word().ToMap();
1099
1177
  }
@@ -1211,34 +1289,32 @@ ACCESSORS(JSObject, properties, FixedArray, kPropertiesOffset)
1211
1289
  HeapObject* JSObject::elements() {
1212
1290
  Object* array = READ_FIELD(this, kElementsOffset);
1213
1291
  // In the assert below Dictionary is covered under FixedArray.
1214
- ASSERT(array->IsFixedArray() || array->IsPixelArray() ||
1215
- array->IsExternalArray());
1292
+ ASSERT(array->IsFixedArray() || array->IsExternalArray());
1216
1293
  return reinterpret_cast<HeapObject*>(array);
1217
1294
  }
1218
1295
 
1219
1296
 
1220
1297
  void JSObject::set_elements(HeapObject* value, WriteBarrierMode mode) {
1221
1298
  ASSERT(map()->has_fast_elements() ==
1222
- (value->map() == Heap::fixed_array_map() ||
1223
- value->map() == Heap::fixed_cow_array_map()));
1299
+ (value->map() == GetHeap()->fixed_array_map() ||
1300
+ value->map() == GetHeap()->fixed_cow_array_map()));
1224
1301
  // In the assert below Dictionary is covered under FixedArray.
1225
- ASSERT(value->IsFixedArray() || value->IsPixelArray() ||
1226
- value->IsExternalArray());
1302
+ ASSERT(value->IsFixedArray() || value->IsExternalArray());
1227
1303
  WRITE_FIELD(this, kElementsOffset, value);
1228
- CONDITIONAL_WRITE_BARRIER(this, kElementsOffset, mode);
1304
+ CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kElementsOffset, mode);
1229
1305
  }
1230
1306
 
1231
1307
 
1232
1308
  void JSObject::initialize_properties() {
1233
- ASSERT(!Heap::InNewSpace(Heap::empty_fixed_array()));
1234
- WRITE_FIELD(this, kPropertiesOffset, Heap::empty_fixed_array());
1309
+ ASSERT(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array()));
1310
+ WRITE_FIELD(this, kPropertiesOffset, GetHeap()->empty_fixed_array());
1235
1311
  }
1236
1312
 
1237
1313
 
1238
1314
  void JSObject::initialize_elements() {
1239
1315
  ASSERT(map()->has_fast_elements());
1240
- ASSERT(!Heap::InNewSpace(Heap::empty_fixed_array()));
1241
- WRITE_FIELD(this, kElementsOffset, Heap::empty_fixed_array());
1316
+ ASSERT(!GetHeap()->InNewSpace(GetHeap()->empty_fixed_array()));
1317
+ WRITE_FIELD(this, kElementsOffset, GetHeap()->empty_fixed_array());
1242
1318
  }
1243
1319
 
1244
1320
 
@@ -1257,6 +1333,16 @@ ACCESSORS(Oddball, to_string, String, kToStringOffset)
1257
1333
  ACCESSORS(Oddball, to_number, Object, kToNumberOffset)
1258
1334
 
1259
1335
 
1336
+ byte Oddball::kind() {
1337
+ return READ_BYTE_FIELD(this, kKindOffset);
1338
+ }
1339
+
1340
+
1341
+ void Oddball::set_kind(byte value) {
1342
+ WRITE_BYTE_FIELD(this, kKindOffset, value);
1343
+ }
1344
+
1345
+
1260
1346
  Object* JSGlobalPropertyCell::value() {
1261
1347
  return READ_FIELD(this, kValueOffset);
1262
1348
  }
@@ -1310,6 +1396,12 @@ int JSObject::GetInternalFieldCount() {
1310
1396
  }
1311
1397
 
1312
1398
 
1399
+ int JSObject::GetInternalFieldOffset(int index) {
1400
+ ASSERT(index < GetInternalFieldCount() && index >= 0);
1401
+ return GetHeaderSize() + (kPointerSize * index);
1402
+ }
1403
+
1404
+
1313
1405
  Object* JSObject::GetInternalField(int index) {
1314
1406
  ASSERT(index < GetInternalFieldCount() && index >= 0);
1315
1407
  // Internal objects do follow immediately after the header, whereas in-object
@@ -1361,6 +1453,14 @@ Object* JSObject::FastPropertyAtPut(int index, Object* value) {
1361
1453
  }
1362
1454
 
1363
1455
 
1456
+ int JSObject::GetInObjectPropertyOffset(int index) {
1457
+ // Adjust for the number of properties stored in the object.
1458
+ index -= map()->inobject_properties();
1459
+ ASSERT(index < 0);
1460
+ return map()->instance_size() + (index * kPointerSize);
1461
+ }
1462
+
1463
+
1364
1464
  Object* JSObject::InObjectPropertyAt(int index) {
1365
1465
  // Adjust for the number of properties stored in the object.
1366
1466
  index -= map()->inobject_properties();
@@ -1378,14 +1478,14 @@ Object* JSObject::InObjectPropertyAtPut(int index,
1378
1478
  ASSERT(index < 0);
1379
1479
  int offset = map()->instance_size() + (index * kPointerSize);
1380
1480
  WRITE_FIELD(this, offset, value);
1381
- CONDITIONAL_WRITE_BARRIER(this, offset, mode);
1481
+ CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, mode);
1382
1482
  return value;
1383
1483
  }
1384
1484
 
1385
1485
 
1386
1486
 
1387
1487
  void JSObject::InitializeBody(int object_size, Object* value) {
1388
- ASSERT(!value->IsHeapObject() || !Heap::InNewSpace(value));
1488
+ ASSERT(!value->IsHeapObject() || !GetHeap()->InNewSpace(value));
1389
1489
  for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) {
1390
1490
  WRITE_FIELD(this, offset, value);
1391
1491
  }
@@ -1408,7 +1508,7 @@ int JSObject::MaxFastProperties() {
1408
1508
 
1409
1509
 
1410
1510
  void Struct::InitializeBody(int object_size) {
1411
- Object* value = Heap::undefined_value();
1511
+ Object* value = GetHeap()->undefined_value();
1412
1512
  for (int offset = kHeaderSize; offset < object_size; offset += kPointerSize) {
1413
1513
  WRITE_FIELD(this, offset, value);
1414
1514
  }
@@ -1454,7 +1554,7 @@ Object* FixedArray::get(int index) {
1454
1554
 
1455
1555
 
1456
1556
  void FixedArray::set(int index, Smi* value) {
1457
- ASSERT(map() != Heap::fixed_cow_array_map());
1557
+ ASSERT(map() != HEAP->fixed_cow_array_map());
1458
1558
  ASSERT(reinterpret_cast<Object*>(value)->IsSmi());
1459
1559
  int offset = kHeaderSize + index * kPointerSize;
1460
1560
  WRITE_FIELD(this, offset, value);
@@ -1462,7 +1562,7 @@ void FixedArray::set(int index, Smi* value) {
1462
1562
 
1463
1563
 
1464
1564
  void FixedArray::set(int index, Object* value) {
1465
- ASSERT(map() != Heap::fixed_cow_array_map());
1565
+ ASSERT(map() != HEAP->fixed_cow_array_map());
1466
1566
  ASSERT(index >= 0 && index < this->length());
1467
1567
  int offset = kHeaderSize + index * kPointerSize;
1468
1568
  WRITE_FIELD(this, offset, value);
@@ -1471,7 +1571,7 @@ void FixedArray::set(int index, Object* value) {
1471
1571
 
1472
1572
 
1473
1573
  WriteBarrierMode HeapObject::GetWriteBarrierMode(const AssertNoAllocation&) {
1474
- if (Heap::InNewSpace(this)) return SKIP_WRITE_BARRIER;
1574
+ if (GetHeap()->InNewSpace(this)) return SKIP_WRITE_BARRIER;
1475
1575
  return UPDATE_WRITE_BARRIER;
1476
1576
  }
1477
1577
 
@@ -1479,44 +1579,55 @@ WriteBarrierMode HeapObject::GetWriteBarrierMode(const AssertNoAllocation&) {
1479
1579
  void FixedArray::set(int index,
1480
1580
  Object* value,
1481
1581
  WriteBarrierMode mode) {
1482
- ASSERT(map() != Heap::fixed_cow_array_map());
1582
+ ASSERT(map() != HEAP->fixed_cow_array_map());
1483
1583
  ASSERT(index >= 0 && index < this->length());
1484
1584
  int offset = kHeaderSize + index * kPointerSize;
1485
1585
  WRITE_FIELD(this, offset, value);
1486
- CONDITIONAL_WRITE_BARRIER(this, offset, mode);
1586
+ CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, mode);
1487
1587
  }
1488
1588
 
1489
1589
 
1490
1590
  void FixedArray::fast_set(FixedArray* array, int index, Object* value) {
1491
- ASSERT(array->map() != Heap::raw_unchecked_fixed_cow_array_map());
1591
+ ASSERT(array->map() != HEAP->raw_unchecked_fixed_cow_array_map());
1492
1592
  ASSERT(index >= 0 && index < array->length());
1493
- ASSERT(!Heap::InNewSpace(value));
1593
+ ASSERT(!HEAP->InNewSpace(value));
1494
1594
  WRITE_FIELD(array, kHeaderSize + index * kPointerSize, value);
1495
1595
  }
1496
1596
 
1497
1597
 
1498
1598
  void FixedArray::set_undefined(int index) {
1499
- ASSERT(map() != Heap::fixed_cow_array_map());
1599
+ ASSERT(map() != HEAP->fixed_cow_array_map());
1600
+ set_undefined(GetHeap(), index);
1601
+ }
1602
+
1603
+
1604
+ void FixedArray::set_undefined(Heap* heap, int index) {
1500
1605
  ASSERT(index >= 0 && index < this->length());
1501
- ASSERT(!Heap::InNewSpace(Heap::undefined_value()));
1606
+ ASSERT(!heap->InNewSpace(heap->undefined_value()));
1502
1607
  WRITE_FIELD(this, kHeaderSize + index * kPointerSize,
1503
- Heap::undefined_value());
1608
+ heap->undefined_value());
1504
1609
  }
1505
1610
 
1506
1611
 
1507
1612
  void FixedArray::set_null(int index) {
1508
- ASSERT(map() != Heap::fixed_cow_array_map());
1613
+ set_null(GetHeap(), index);
1614
+ }
1615
+
1616
+
1617
+ void FixedArray::set_null(Heap* heap, int index) {
1509
1618
  ASSERT(index >= 0 && index < this->length());
1510
- ASSERT(!Heap::InNewSpace(Heap::null_value()));
1511
- WRITE_FIELD(this, kHeaderSize + index * kPointerSize, Heap::null_value());
1619
+ ASSERT(!heap->InNewSpace(heap->null_value()));
1620
+ WRITE_FIELD(this, kHeaderSize + index * kPointerSize, heap->null_value());
1512
1621
  }
1513
1622
 
1514
1623
 
1515
1624
  void FixedArray::set_the_hole(int index) {
1516
- ASSERT(map() != Heap::fixed_cow_array_map());
1625
+ ASSERT(map() != HEAP->fixed_cow_array_map());
1517
1626
  ASSERT(index >= 0 && index < this->length());
1518
- ASSERT(!Heap::InNewSpace(Heap::the_hole_value()));
1519
- WRITE_FIELD(this, kHeaderSize + index * kPointerSize, Heap::the_hole_value());
1627
+ ASSERT(!HEAP->InNewSpace(HEAP->the_hole_value()));
1628
+ WRITE_FIELD(this,
1629
+ kHeaderSize + index * kPointerSize,
1630
+ GetHeap()->the_hole_value());
1520
1631
  }
1521
1632
 
1522
1633
 
@@ -1527,19 +1638,20 @@ void FixedArray::set_unchecked(int index, Smi* value) {
1527
1638
  }
1528
1639
 
1529
1640
 
1530
- void FixedArray::set_unchecked(int index,
1641
+ void FixedArray::set_unchecked(Heap* heap,
1642
+ int index,
1531
1643
  Object* value,
1532
1644
  WriteBarrierMode mode) {
1533
1645
  int offset = kHeaderSize + index * kPointerSize;
1534
1646
  WRITE_FIELD(this, offset, value);
1535
- CONDITIONAL_WRITE_BARRIER(this, offset, mode);
1647
+ CONDITIONAL_WRITE_BARRIER(heap, this, offset, mode);
1536
1648
  }
1537
1649
 
1538
1650
 
1539
- void FixedArray::set_null_unchecked(int index) {
1651
+ void FixedArray::set_null_unchecked(Heap* heap, int index) {
1540
1652
  ASSERT(index >= 0 && index < this->length());
1541
- ASSERT(!Heap::InNewSpace(Heap::null_value()));
1542
- WRITE_FIELD(this, kHeaderSize + index * kPointerSize, Heap::null_value());
1653
+ ASSERT(!HEAP->InNewSpace(heap->null_value()));
1654
+ WRITE_FIELD(this, kHeaderSize + index * kPointerSize, heap->null_value());
1543
1655
  }
1544
1656
 
1545
1657
 
@@ -1549,9 +1661,9 @@ Object** FixedArray::data_start() {
1549
1661
 
1550
1662
 
1551
1663
  bool DescriptorArray::IsEmpty() {
1552
- ASSERT(this == Heap::empty_descriptor_array() ||
1553
- this->length() > 2);
1554
- return this == Heap::empty_descriptor_array();
1664
+ ASSERT(this->length() > kFirstIndex ||
1665
+ this == HEAP->empty_descriptor_array());
1666
+ return length() <= kFirstIndex;
1555
1667
  }
1556
1668
 
1557
1669
 
@@ -1581,10 +1693,10 @@ int DescriptorArray::Search(String* name) {
1581
1693
 
1582
1694
 
1583
1695
  int DescriptorArray::SearchWithCache(String* name) {
1584
- int number = DescriptorLookupCache::Lookup(this, name);
1696
+ int number = GetIsolate()->descriptor_lookup_cache()->Lookup(this, name);
1585
1697
  if (number == DescriptorLookupCache::kAbsent) {
1586
1698
  number = Search(name);
1587
- DescriptorLookupCache::Update(this, name, number);
1699
+ GetIsolate()->descriptor_lookup_cache()->Update(this, name, number);
1588
1700
  }
1589
1701
  return number;
1590
1702
  }
@@ -1644,7 +1756,8 @@ bool DescriptorArray::IsProperty(int descriptor_number) {
1644
1756
 
1645
1757
  bool DescriptorArray::IsTransition(int descriptor_number) {
1646
1758
  PropertyType t = GetType(descriptor_number);
1647
- return t == MAP_TRANSITION || t == CONSTANT_TRANSITION;
1759
+ return t == MAP_TRANSITION || t == CONSTANT_TRANSITION ||
1760
+ t == EXTERNAL_ARRAY_TRANSITION;
1648
1761
  }
1649
1762
 
1650
1763
 
@@ -1670,8 +1783,8 @@ void DescriptorArray::Set(int descriptor_number, Descriptor* desc) {
1670
1783
  ASSERT(descriptor_number < number_of_descriptors());
1671
1784
 
1672
1785
  // Make sure none of the elements in desc are in new space.
1673
- ASSERT(!Heap::InNewSpace(desc->GetKey()));
1674
- ASSERT(!Heap::InNewSpace(desc->GetValue()));
1786
+ ASSERT(!HEAP->InNewSpace(desc->GetKey()));
1787
+ ASSERT(!HEAP->InNewSpace(desc->GetValue()));
1675
1788
 
1676
1789
  fast_set(this, ToKeyIndex(descriptor_number), desc->GetKey());
1677
1790
  FixedArray* content_array = GetContentArray();
@@ -1696,6 +1809,30 @@ void DescriptorArray::Swap(int first, int second) {
1696
1809
  }
1697
1810
 
1698
1811
 
1812
+ template<typename Shape, typename Key>
1813
+ int HashTable<Shape, Key>::FindEntry(Key key) {
1814
+ return FindEntry(GetIsolate(), key);
1815
+ }
1816
+
1817
+
1818
+ // Find entry for key otherwise return kNotFound.
1819
+ template<typename Shape, typename Key>
1820
+ int HashTable<Shape, Key>::FindEntry(Isolate* isolate, Key key) {
1821
+ uint32_t capacity = Capacity();
1822
+ uint32_t entry = FirstProbe(Shape::Hash(key), capacity);
1823
+ uint32_t count = 1;
1824
+ // EnsureCapacity will guarantee the hash table is never full.
1825
+ while (true) {
1826
+ Object* element = KeyAt(entry);
1827
+ if (element == isolate->heap()->undefined_value()) break; // Empty entry.
1828
+ if (element != isolate->heap()->null_value() &&
1829
+ Shape::IsMatch(key, element)) return entry;
1830
+ entry = NextProbe(entry, count++, capacity);
1831
+ }
1832
+ return kNotFound;
1833
+ }
1834
+
1835
+
1699
1836
  bool NumberDictionary::requires_slow_elements() {
1700
1837
  Object* max_index_object = get(kMaxNumberKeyIndex);
1701
1838
  if (!max_index_object->IsSmi()) return false;
@@ -1756,7 +1893,6 @@ CAST_ACCESSOR(JSArray)
1756
1893
  CAST_ACCESSOR(JSRegExp)
1757
1894
  CAST_ACCESSOR(Proxy)
1758
1895
  CAST_ACCESSOR(ByteArray)
1759
- CAST_ACCESSOR(PixelArray)
1760
1896
  CAST_ACCESSOR(ExternalArray)
1761
1897
  CAST_ACCESSOR(ExternalByteArray)
1762
1898
  CAST_ACCESSOR(ExternalUnsignedByteArray)
@@ -1765,6 +1901,7 @@ CAST_ACCESSOR(ExternalUnsignedShortArray)
1765
1901
  CAST_ACCESSOR(ExternalIntArray)
1766
1902
  CAST_ACCESSOR(ExternalUnsignedIntArray)
1767
1903
  CAST_ACCESSOR(ExternalFloatArray)
1904
+ CAST_ACCESSOR(ExternalPixelArray)
1768
1905
  CAST_ACCESSOR(Struct)
1769
1906
 
1770
1907
 
@@ -1783,7 +1920,6 @@ HashTable<Shape, Key>* HashTable<Shape, Key>::cast(Object* obj) {
1783
1920
  SMI_ACCESSORS(FixedArray, length, kLengthOffset)
1784
1921
  SMI_ACCESSORS(ByteArray, length, kLengthOffset)
1785
1922
 
1786
- INT_ACCESSORS(PixelArray, length, kLengthOffset)
1787
1923
  INT_ACCESSORS(ExternalArray, length, kLengthOffset)
1788
1924
 
1789
1925
 
@@ -1943,7 +2079,7 @@ Object* ConsString::unchecked_first() {
1943
2079
 
1944
2080
  void ConsString::set_first(String* value, WriteBarrierMode mode) {
1945
2081
  WRITE_FIELD(this, kFirstOffset, value);
1946
- CONDITIONAL_WRITE_BARRIER(this, kFirstOffset, mode);
2082
+ CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kFirstOffset, mode);
1947
2083
  }
1948
2084
 
1949
2085
 
@@ -1959,7 +2095,7 @@ Object* ConsString::unchecked_second() {
1959
2095
 
1960
2096
  void ConsString::set_second(String* value, WriteBarrierMode mode) {
1961
2097
  WRITE_FIELD(this, kSecondOffset, value);
1962
- CONDITIONAL_WRITE_BARRIER(this, kSecondOffset, mode);
2098
+ CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kSecondOffset, mode);
1963
2099
  }
1964
2100
 
1965
2101
 
@@ -1995,7 +2131,7 @@ void JSFunctionResultCache::Clear() {
1995
2131
  int cache_size = size();
1996
2132
  Object** entries_start = RawField(this, OffsetOfElementAt(kEntriesIndex));
1997
2133
  MemsetPointer(entries_start,
1998
- Heap::the_hole_value(),
2134
+ GetHeap()->the_hole_value(),
1999
2135
  cache_size - kEntriesIndex);
2000
2136
  MakeZeroSize();
2001
2137
  }
@@ -2050,28 +2186,21 @@ Address ByteArray::GetDataStartAddress() {
2050
2186
  }
2051
2187
 
2052
2188
 
2053
- uint8_t* PixelArray::external_pointer() {
2054
- intptr_t ptr = READ_INTPTR_FIELD(this, kExternalPointerOffset);
2055
- return reinterpret_cast<uint8_t*>(ptr);
2056
- }
2057
-
2058
-
2059
- void PixelArray::set_external_pointer(uint8_t* value, WriteBarrierMode mode) {
2060
- intptr_t ptr = reinterpret_cast<intptr_t>(value);
2061
- WRITE_INTPTR_FIELD(this, kExternalPointerOffset, ptr);
2189
+ uint8_t* ExternalPixelArray::external_pixel_pointer() {
2190
+ return reinterpret_cast<uint8_t*>(external_pointer());
2062
2191
  }
2063
2192
 
2064
2193
 
2065
- uint8_t PixelArray::get(int index) {
2194
+ uint8_t ExternalPixelArray::get(int index) {
2066
2195
  ASSERT((index >= 0) && (index < this->length()));
2067
- uint8_t* ptr = external_pointer();
2196
+ uint8_t* ptr = external_pixel_pointer();
2068
2197
  return ptr[index];
2069
2198
  }
2070
2199
 
2071
2200
 
2072
- void PixelArray::set(int index, uint8_t value) {
2201
+ void ExternalPixelArray::set(int index, uint8_t value) {
2073
2202
  ASSERT((index >= 0) && (index < this->length()));
2074
- uint8_t* ptr = external_pointer();
2203
+ uint8_t* ptr = external_pixel_pointer();
2075
2204
  ptr[index] = value;
2076
2205
  }
2077
2206
 
@@ -2549,6 +2678,19 @@ void Code::set_check_type(CheckType value) {
2549
2678
  }
2550
2679
 
2551
2680
 
2681
+ ExternalArrayType Code::external_array_type() {
2682
+ ASSERT(is_external_array_load_stub() || is_external_array_store_stub());
2683
+ byte type = READ_BYTE_FIELD(this, kExternalArrayTypeOffset);
2684
+ return static_cast<ExternalArrayType>(type);
2685
+ }
2686
+
2687
+
2688
+ void Code::set_external_array_type(ExternalArrayType value) {
2689
+ ASSERT(is_external_array_load_stub() || is_external_array_store_stub());
2690
+ WRITE_BYTE_FIELD(this, kExternalArrayTypeOffset, value);
2691
+ }
2692
+
2693
+
2552
2694
  byte Code::binary_op_type() {
2553
2695
  ASSERT(is_binary_op_stub());
2554
2696
  return READ_BYTE_FIELD(this, kBinaryOpTypeOffset);
@@ -2615,7 +2757,8 @@ Code::Flags Code::ComputeFlags(Kind kind,
2615
2757
  ASSERT(extra_ic_state == kNoExtraICState ||
2616
2758
  (kind == CALL_IC && (ic_state == MONOMORPHIC ||
2617
2759
  ic_state == MONOMORPHIC_PROTOTYPE_FAILURE)) ||
2618
- (kind == STORE_IC));
2760
+ (kind == STORE_IC) ||
2761
+ (kind == KEYED_STORE_IC));
2619
2762
  // Compute the bit mask.
2620
2763
  int bits = kind << kFlagsKindShift;
2621
2764
  if (in_loop) bits |= kFlagsICInLoopMask;
@@ -2705,6 +2848,48 @@ Code* Code::GetCodeFromTargetAddress(Address address) {
2705
2848
  }
2706
2849
 
2707
2850
 
2851
+ Isolate* Map::isolate() {
2852
+ return heap()->isolate();
2853
+ }
2854
+
2855
+
2856
+ Heap* Map::heap() {
2857
+ // NOTE: address() helper is not used to save one instruction.
2858
+ Heap* heap = Page::FromAddress(reinterpret_cast<Address>(this))->heap_;
2859
+ ASSERT(heap != NULL);
2860
+ ASSERT(heap->isolate() == Isolate::Current());
2861
+ return heap;
2862
+ }
2863
+
2864
+
2865
+ Heap* Code::heap() {
2866
+ // NOTE: address() helper is not used to save one instruction.
2867
+ Heap* heap = Page::FromAddress(reinterpret_cast<Address>(this))->heap_;
2868
+ ASSERT(heap != NULL);
2869
+ ASSERT(heap->isolate() == Isolate::Current());
2870
+ return heap;
2871
+ }
2872
+
2873
+
2874
+ Isolate* Code::isolate() {
2875
+ return heap()->isolate();
2876
+ }
2877
+
2878
+
2879
+ Heap* JSGlobalPropertyCell::heap() {
2880
+ // NOTE: address() helper is not used to save one instruction.
2881
+ Heap* heap = Page::FromAddress(reinterpret_cast<Address>(this))->heap_;
2882
+ ASSERT(heap != NULL);
2883
+ ASSERT(heap->isolate() == Isolate::Current());
2884
+ return heap;
2885
+ }
2886
+
2887
+
2888
+ Isolate* JSGlobalPropertyCell::isolate() {
2889
+ return heap()->isolate();
2890
+ }
2891
+
2892
+
2708
2893
  Object* Code::GetObjectFromEntryAddress(Address location_of_address) {
2709
2894
  return HeapObject::
2710
2895
  FromAddress(Memory::Address_at(location_of_address) - Code::kHeaderSize);
@@ -2719,7 +2904,7 @@ Object* Map::prototype() {
2719
2904
  void Map::set_prototype(Object* value, WriteBarrierMode mode) {
2720
2905
  ASSERT(value->IsNull() || value->IsJSObject());
2721
2906
  WRITE_FIELD(this, kPrototypeOffset, value);
2722
- CONDITIONAL_WRITE_BARRIER(this, kPrototypeOffset, mode);
2907
+ CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kPrototypeOffset, mode);
2723
2908
  }
2724
2909
 
2725
2910
 
@@ -2731,7 +2916,7 @@ MaybeObject* Map::GetFastElementsMap() {
2731
2916
  }
2732
2917
  Map* new_map = Map::cast(obj);
2733
2918
  new_map->set_has_fast_elements(true);
2734
- Counters::map_slow_to_fast_elements.Increment();
2919
+ isolate()->counters()->map_slow_to_fast_elements()->Increment();
2735
2920
  return new_map;
2736
2921
  }
2737
2922
 
@@ -2744,23 +2929,7 @@ MaybeObject* Map::GetSlowElementsMap() {
2744
2929
  }
2745
2930
  Map* new_map = Map::cast(obj);
2746
2931
  new_map->set_has_fast_elements(false);
2747
- Counters::map_fast_to_slow_elements.Increment();
2748
- return new_map;
2749
- }
2750
-
2751
-
2752
- MaybeObject* Map::GetPixelArrayElementsMap() {
2753
- if (has_pixel_array_elements()) return this;
2754
- // TODO(danno): Special case empty object map (or most common case)
2755
- // to return a pre-canned pixel array map.
2756
- Object* obj;
2757
- { MaybeObject* maybe_obj = CopyDropTransitions();
2758
- if (!maybe_obj->ToObject(&obj)) return maybe_obj;
2759
- }
2760
- Map* new_map = Map::cast(obj);
2761
- new_map->set_has_fast_elements(false);
2762
- new_map->set_has_pixel_array_elements(true);
2763
- Counters::map_to_pixel_array_elements.Increment();
2932
+ isolate()->counters()->map_fast_to_slow_elements()->Increment();
2764
2933
  return new_map;
2765
2934
  }
2766
2935
 
@@ -2772,7 +2941,8 @@ ACCESSORS(Map, constructor, Object, kConstructorOffset)
2772
2941
 
2773
2942
  ACCESSORS(JSFunction, shared, SharedFunctionInfo, kSharedFunctionInfoOffset)
2774
2943
  ACCESSORS(JSFunction, literals, FixedArray, kLiteralsOffset)
2775
- ACCESSORS(JSFunction, next_function_link, Object, kNextFunctionLinkOffset)
2944
+ ACCESSORS_GCSAFE(JSFunction, next_function_link, Object,
2945
+ kNextFunctionLinkOffset)
2776
2946
 
2777
2947
  ACCESSORS(GlobalObject, builtins, JSBuiltinsObject, kBuiltinsOffset)
2778
2948
  ACCESSORS(GlobalObject, global_context, Context, kGlobalContextOffset)
@@ -2861,8 +3031,8 @@ ACCESSORS(BreakPointInfo, break_point_objects, Object, kBreakPointObjectsIndex)
2861
3031
  #endif
2862
3032
 
2863
3033
  ACCESSORS(SharedFunctionInfo, name, Object, kNameOffset)
2864
- ACCESSORS(SharedFunctionInfo, construct_stub, Code, kConstructStubOffset)
2865
- ACCESSORS(SharedFunctionInfo, initial_map, Object, kInitialMapOffset)
3034
+ ACCESSORS_GCSAFE(SharedFunctionInfo, construct_stub, Code, kConstructStubOffset)
3035
+ ACCESSORS_GCSAFE(SharedFunctionInfo, initial_map, Object, kInitialMapOffset)
2866
3036
  ACCESSORS(SharedFunctionInfo, instance_class_name, Object,
2867
3037
  kInstanceClassNameOffset)
2868
3038
  ACCESSORS(SharedFunctionInfo, function_data, Object, kFunctionDataOffset)
@@ -2884,10 +3054,6 @@ BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_toplevel,
2884
3054
  BOOL_GETTER(SharedFunctionInfo, compiler_hints,
2885
3055
  has_only_simple_this_property_assignments,
2886
3056
  kHasOnlySimpleThisPropertyAssignments)
2887
- BOOL_ACCESSORS(SharedFunctionInfo,
2888
- compiler_hints,
2889
- try_full_codegen,
2890
- kTryFullCodegen)
2891
3057
  BOOL_ACCESSORS(SharedFunctionInfo,
2892
3058
  compiler_hints,
2893
3059
  allows_lazy_compilation,
@@ -2990,7 +3156,7 @@ void SharedFunctionInfo::set_live_objects_may_exist(bool value) {
2990
3156
 
2991
3157
 
2992
3158
  bool SharedFunctionInfo::IsInobjectSlackTrackingInProgress() {
2993
- return initial_map() != Heap::undefined_value();
3159
+ return initial_map() != HEAP->undefined_value();
2994
3160
  }
2995
3161
 
2996
3162
 
@@ -3069,7 +3235,7 @@ Code* SharedFunctionInfo::unchecked_code() {
3069
3235
 
3070
3236
  void SharedFunctionInfo::set_code(Code* value, WriteBarrierMode mode) {
3071
3237
  WRITE_FIELD(this, kCodeOffset, value);
3072
- CONDITIONAL_WRITE_BARRIER(this, kCodeOffset, mode);
3238
+ ASSERT(!Isolate::Current()->heap()->InNewSpace(value));
3073
3239
  }
3074
3240
 
3075
3241
 
@@ -3082,7 +3248,7 @@ SerializedScopeInfo* SharedFunctionInfo::scope_info() {
3082
3248
  void SharedFunctionInfo::set_scope_info(SerializedScopeInfo* value,
3083
3249
  WriteBarrierMode mode) {
3084
3250
  WRITE_FIELD(this, kScopeInfoOffset, reinterpret_cast<Object*>(value));
3085
- CONDITIONAL_WRITE_BARRIER(this, kScopeInfoOffset, mode);
3251
+ CONDITIONAL_WRITE_BARRIER(GetHeap(), this, kScopeInfoOffset, mode);
3086
3252
  }
3087
3253
 
3088
3254
 
@@ -3097,7 +3263,8 @@ void SharedFunctionInfo::set_deopt_counter(Smi* value) {
3097
3263
 
3098
3264
 
3099
3265
  bool SharedFunctionInfo::is_compiled() {
3100
- return code() != Builtins::builtin(Builtins::LazyCompile);
3266
+ return code() !=
3267
+ Isolate::Current()->builtins()->builtin(Builtins::kLazyCompile);
3101
3268
  }
3102
3269
 
3103
3270
 
@@ -3157,7 +3324,7 @@ bool JSFunction::IsOptimized() {
3157
3324
 
3158
3325
 
3159
3326
  bool JSFunction::IsMarkedForLazyRecompilation() {
3160
- return code() == Builtins::builtin(Builtins::LazyRecompile);
3327
+ return code() == GetIsolate()->builtins()->builtin(Builtins::kLazyRecompile);
3161
3328
  }
3162
3329
 
3163
3330
 
@@ -3174,7 +3341,7 @@ Code* JSFunction::unchecked_code() {
3174
3341
 
3175
3342
  void JSFunction::set_code(Code* value) {
3176
3343
  // Skip the write barrier because code is never in new space.
3177
- ASSERT(!Heap::InNewSpace(value));
3344
+ ASSERT(!HEAP->InNewSpace(value));
3178
3345
  Address entry = value->entry();
3179
3346
  WRITE_INTPTR_FIELD(this, kCodeEntryOffset, reinterpret_cast<intptr_t>(entry));
3180
3347
  }
@@ -3214,7 +3381,7 @@ SharedFunctionInfo* JSFunction::unchecked_shared() {
3214
3381
 
3215
3382
 
3216
3383
  void JSFunction::set_context(Object* value) {
3217
- ASSERT(value == Heap::undefined_value() || value->IsContext());
3384
+ ASSERT(value->IsUndefined() || value->IsContext());
3218
3385
  WRITE_FIELD(this, kContextOffset, value);
3219
3386
  WRITE_BARRIER(this, kContextOffset);
3220
3387
  }
@@ -3271,7 +3438,7 @@ bool JSFunction::should_have_prototype() {
3271
3438
 
3272
3439
 
3273
3440
  bool JSFunction::is_compiled() {
3274
- return code() != Builtins::builtin(Builtins::LazyCompile);
3441
+ return code() != GetIsolate()->builtins()->builtin(Builtins::kLazyCompile);
3275
3442
  }
3276
3443
 
3277
3444
 
@@ -3304,7 +3471,7 @@ void JSBuiltinsObject::set_javascript_builtin_code(Builtins::JavaScript id,
3304
3471
  Code* value) {
3305
3472
  ASSERT(id < kJSBuiltinsCount); // id is unsigned.
3306
3473
  WRITE_FIELD(this, OffsetOfCodeWithId(id), value);
3307
- ASSERT(!Heap::InNewSpace(value));
3474
+ ASSERT(!HEAP->InNewSpace(value));
3308
3475
  }
3309
3476
 
3310
3477
 
@@ -3454,8 +3621,8 @@ void JSRegExp::SetDataAt(int index, Object* value) {
3454
3621
 
3455
3622
  JSObject::ElementsKind JSObject::GetElementsKind() {
3456
3623
  if (map()->has_fast_elements()) {
3457
- ASSERT(elements()->map() == Heap::fixed_array_map() ||
3458
- elements()->map() == Heap::fixed_cow_array_map());
3624
+ ASSERT(elements()->map() == GetHeap()->fixed_array_map() ||
3625
+ elements()->map() == GetHeap()->fixed_cow_array_map());
3459
3626
  return FAST_ELEMENTS;
3460
3627
  }
3461
3628
  HeapObject* array = elements();
@@ -3465,6 +3632,7 @@ JSObject::ElementsKind JSObject::GetElementsKind() {
3465
3632
  ASSERT(array->IsDictionary());
3466
3633
  return DICTIONARY_ELEMENTS;
3467
3634
  }
3635
+ ASSERT(!map()->has_fast_elements());
3468
3636
  if (array->IsExternalArray()) {
3469
3637
  switch (array->map()->instance_type()) {
3470
3638
  case EXTERNAL_BYTE_ARRAY_TYPE:
@@ -3479,13 +3647,14 @@ JSObject::ElementsKind JSObject::GetElementsKind() {
3479
3647
  return EXTERNAL_INT_ELEMENTS;
3480
3648
  case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE:
3481
3649
  return EXTERNAL_UNSIGNED_INT_ELEMENTS;
3650
+ case EXTERNAL_PIXEL_ARRAY_TYPE:
3651
+ return EXTERNAL_PIXEL_ELEMENTS;
3482
3652
  default:
3483
- ASSERT(array->map()->instance_type() == EXTERNAL_FLOAT_ARRAY_TYPE);
3484
- return EXTERNAL_FLOAT_ELEMENTS;
3653
+ break;
3485
3654
  }
3486
3655
  }
3487
- ASSERT(array->IsPixelArray());
3488
- return PIXEL_ELEMENTS;
3656
+ ASSERT(array->map()->instance_type() == EXTERNAL_FLOAT_ARRAY_TYPE);
3657
+ return EXTERNAL_FLOAT_ELEMENTS;
3489
3658
  }
3490
3659
 
3491
3660
 
@@ -3499,55 +3668,34 @@ bool JSObject::HasDictionaryElements() {
3499
3668
  }
3500
3669
 
3501
3670
 
3502
- bool JSObject::HasPixelElements() {
3503
- return GetElementsKind() == PIXEL_ELEMENTS;
3504
- }
3505
-
3506
-
3507
3671
  bool JSObject::HasExternalArrayElements() {
3508
- return (HasExternalByteElements() ||
3509
- HasExternalUnsignedByteElements() ||
3510
- HasExternalShortElements() ||
3511
- HasExternalUnsignedShortElements() ||
3512
- HasExternalIntElements() ||
3513
- HasExternalUnsignedIntElements() ||
3514
- HasExternalFloatElements());
3515
- }
3516
-
3517
-
3518
- bool JSObject::HasExternalByteElements() {
3519
- return GetElementsKind() == EXTERNAL_BYTE_ELEMENTS;
3520
- }
3521
-
3522
-
3523
- bool JSObject::HasExternalUnsignedByteElements() {
3524
- return GetElementsKind() == EXTERNAL_UNSIGNED_BYTE_ELEMENTS;
3525
- }
3526
-
3527
-
3528
- bool JSObject::HasExternalShortElements() {
3529
- return GetElementsKind() == EXTERNAL_SHORT_ELEMENTS;
3530
- }
3531
-
3532
-
3533
- bool JSObject::HasExternalUnsignedShortElements() {
3534
- return GetElementsKind() == EXTERNAL_UNSIGNED_SHORT_ELEMENTS;
3535
- }
3536
-
3537
-
3538
- bool JSObject::HasExternalIntElements() {
3539
- return GetElementsKind() == EXTERNAL_INT_ELEMENTS;
3672
+ HeapObject* array = elements();
3673
+ ASSERT(array != NULL);
3674
+ return array->IsExternalArray();
3540
3675
  }
3541
3676
 
3542
3677
 
3543
- bool JSObject::HasExternalUnsignedIntElements() {
3544
- return GetElementsKind() == EXTERNAL_UNSIGNED_INT_ELEMENTS;
3678
+ #define EXTERNAL_ELEMENTS_CHECK(name, type) \
3679
+ bool JSObject::HasExternal##name##Elements() { \
3680
+ HeapObject* array = elements(); \
3681
+ ASSERT(array != NULL); \
3682
+ if (!array->IsHeapObject()) \
3683
+ return false; \
3684
+ return array->map()->instance_type() == type; \
3545
3685
  }
3546
3686
 
3547
3687
 
3548
- bool JSObject::HasExternalFloatElements() {
3549
- return GetElementsKind() == EXTERNAL_FLOAT_ELEMENTS;
3550
- }
3688
+ EXTERNAL_ELEMENTS_CHECK(Byte, EXTERNAL_BYTE_ARRAY_TYPE)
3689
+ EXTERNAL_ELEMENTS_CHECK(UnsignedByte, EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE)
3690
+ EXTERNAL_ELEMENTS_CHECK(Short, EXTERNAL_SHORT_ARRAY_TYPE)
3691
+ EXTERNAL_ELEMENTS_CHECK(UnsignedShort,
3692
+ EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE)
3693
+ EXTERNAL_ELEMENTS_CHECK(Int, EXTERNAL_INT_ARRAY_TYPE)
3694
+ EXTERNAL_ELEMENTS_CHECK(UnsignedInt,
3695
+ EXTERNAL_UNSIGNED_INT_ARRAY_TYPE)
3696
+ EXTERNAL_ELEMENTS_CHECK(Float,
3697
+ EXTERNAL_FLOAT_ARRAY_TYPE)
3698
+ EXTERNAL_ELEMENTS_CHECK(Pixel, EXTERNAL_PIXEL_ARRAY_TYPE)
3551
3699
 
3552
3700
 
3553
3701
  bool JSObject::HasNamedInterceptor() {
@@ -3562,7 +3710,7 @@ bool JSObject::HasIndexedInterceptor() {
3562
3710
 
3563
3711
  bool JSObject::AllowsSetElementsLength() {
3564
3712
  bool result = elements()->IsFixedArray();
3565
- ASSERT(result == (!HasPixelElements() && !HasExternalArrayElements()));
3713
+ ASSERT(result == !HasExternalArrayElements());
3566
3714
  return result;
3567
3715
  }
3568
3716
 
@@ -3570,16 +3718,17 @@ bool JSObject::AllowsSetElementsLength() {
3570
3718
  MaybeObject* JSObject::EnsureWritableFastElements() {
3571
3719
  ASSERT(HasFastElements());
3572
3720
  FixedArray* elems = FixedArray::cast(elements());
3573
- if (elems->map() != Heap::fixed_cow_array_map()) return elems;
3721
+ Isolate* isolate = GetIsolate();
3722
+ if (elems->map() != isolate->heap()->fixed_cow_array_map()) return elems;
3574
3723
  Object* writable_elems;
3575
- { MaybeObject* maybe_writable_elems =
3576
- Heap::CopyFixedArrayWithMap(elems, Heap::fixed_array_map());
3724
+ { MaybeObject* maybe_writable_elems = isolate->heap()->CopyFixedArrayWithMap(
3725
+ elems, isolate->heap()->fixed_array_map());
3577
3726
  if (!maybe_writable_elems->ToObject(&writable_elems)) {
3578
3727
  return maybe_writable_elems;
3579
3728
  }
3580
3729
  }
3581
3730
  set_elements(FixedArray::cast(writable_elems));
3582
- Counters::cow_arrays_converted.Increment();
3731
+ isolate->counters()->cow_arrays_converted()->Increment();
3583
3732
  return writable_elems;
3584
3733
  }
3585
3734
 
@@ -3680,6 +3829,22 @@ uint32_t StringHasher::GetHash() {
3680
3829
  }
3681
3830
 
3682
3831
 
3832
+ template <typename schar>
3833
+ uint32_t HashSequentialString(const schar* chars, int length) {
3834
+ StringHasher hasher(length);
3835
+ if (!hasher.has_trivial_hash()) {
3836
+ int i;
3837
+ for (i = 0; hasher.is_array_index() && (i < length); i++) {
3838
+ hasher.AddCharacter(chars[i]);
3839
+ }
3840
+ for (; i < length; i++) {
3841
+ hasher.AddCharacterNoIndex(chars[i]);
3842
+ }
3843
+ }
3844
+ return hasher.GetHashField();
3845
+ }
3846
+
3847
+
3683
3848
  bool String::AsArrayIndex(uint32_t* index) {
3684
3849
  uint32_t field = hash_field();
3685
3850
  if (IsHashFieldComputed(field) && (field & kIsNotArrayIndexMask)) {
@@ -3703,7 +3868,7 @@ PropertyAttributes JSObject::GetPropertyAttribute(String* key) {
3703
3868
  Object* JSObject::BypassGlobalProxy() {
3704
3869
  if (IsJSGlobalProxy()) {
3705
3870
  Object* proto = GetPrototype();
3706
- if (proto->IsNull()) return Heap::undefined_value();
3871
+ if (proto->IsNull()) return GetHeap()->undefined_value();
3707
3872
  ASSERT(proto->IsJSGlobalObject());
3708
3873
  return proto;
3709
3874
  }
@@ -3714,7 +3879,7 @@ Object* JSObject::BypassGlobalProxy() {
3714
3879
  bool JSObject::HasHiddenPropertiesObject() {
3715
3880
  ASSERT(!IsJSGlobalProxy());
3716
3881
  return GetPropertyAttributePostInterceptor(this,
3717
- Heap::hidden_symbol(),
3882
+ GetHeap()->hidden_symbol(),
3718
3883
  false) != ABSENT;
3719
3884
  }
3720
3885
 
@@ -3727,7 +3892,7 @@ Object* JSObject::GetHiddenPropertiesObject() {
3727
3892
  // object.
3728
3893
  Object* result =
3729
3894
  GetLocalPropertyPostInterceptor(this,
3730
- Heap::hidden_symbol(),
3895
+ GetHeap()->hidden_symbol(),
3731
3896
  &attributes)->ToObjectUnchecked();
3732
3897
  return result;
3733
3898
  }
@@ -3735,9 +3900,10 @@ Object* JSObject::GetHiddenPropertiesObject() {
3735
3900
 
3736
3901
  MaybeObject* JSObject::SetHiddenPropertiesObject(Object* hidden_obj) {
3737
3902
  ASSERT(!IsJSGlobalProxy());
3738
- return SetPropertyPostInterceptor(Heap::hidden_symbol(),
3903
+ return SetPropertyPostInterceptor(GetHeap()->hidden_symbol(),
3739
3904
  hidden_obj,
3740
- DONT_ENUM);
3905
+ DONT_ENUM,
3906
+ kNonStrictMode);
3741
3907
  }
3742
3908
 
3743
3909
 
@@ -3802,12 +3968,57 @@ void Dictionary<Shape, Key>::SetEntry(int entry,
3802
3968
  }
3803
3969
 
3804
3970
 
3805
- void Map::ClearCodeCache() {
3971
+ bool NumberDictionaryShape::IsMatch(uint32_t key, Object* other) {
3972
+ ASSERT(other->IsNumber());
3973
+ return key == static_cast<uint32_t>(other->Number());
3974
+ }
3975
+
3976
+
3977
+ uint32_t NumberDictionaryShape::Hash(uint32_t key) {
3978
+ return ComputeIntegerHash(key);
3979
+ }
3980
+
3981
+
3982
+ uint32_t NumberDictionaryShape::HashForObject(uint32_t key, Object* other) {
3983
+ ASSERT(other->IsNumber());
3984
+ return ComputeIntegerHash(static_cast<uint32_t>(other->Number()));
3985
+ }
3986
+
3987
+
3988
+ MaybeObject* NumberDictionaryShape::AsObject(uint32_t key) {
3989
+ return Isolate::Current()->heap()->NumberFromUint32(key);
3990
+ }
3991
+
3992
+
3993
+ bool StringDictionaryShape::IsMatch(String* key, Object* other) {
3994
+ // We know that all entries in a hash table had their hash keys created.
3995
+ // Use that knowledge to have fast failure.
3996
+ if (key->Hash() != String::cast(other)->Hash()) return false;
3997
+ return key->Equals(String::cast(other));
3998
+ }
3999
+
4000
+
4001
+ uint32_t StringDictionaryShape::Hash(String* key) {
4002
+ return key->Hash();
4003
+ }
4004
+
4005
+
4006
+ uint32_t StringDictionaryShape::HashForObject(String* key, Object* other) {
4007
+ return String::cast(other)->Hash();
4008
+ }
4009
+
4010
+
4011
+ MaybeObject* StringDictionaryShape::AsObject(String* key) {
4012
+ return key;
4013
+ }
4014
+
4015
+
4016
+ void Map::ClearCodeCache(Heap* heap) {
3806
4017
  // No write barrier is needed since empty_fixed_array is not in new space.
3807
4018
  // Please note this function is used during marking:
3808
4019
  // - MarkCompactCollector::MarkUnmarkedObject
3809
- ASSERT(!Heap::InNewSpace(Heap::raw_unchecked_empty_fixed_array()));
3810
- WRITE_FIELD(this, kCodeCacheOffset, Heap::raw_unchecked_empty_fixed_array());
4020
+ ASSERT(!heap->InNewSpace(heap->raw_unchecked_empty_fixed_array()));
4021
+ WRITE_FIELD(this, kCodeCacheOffset, heap->raw_unchecked_empty_fixed_array());
3811
4022
  }
3812
4023
 
3813
4024
 
@@ -3820,7 +4031,7 @@ void JSArray::EnsureSize(int required_size) {
3820
4031
  // constantly growing.
3821
4032
  Expand(required_size + (required_size >> 3));
3822
4033
  // It's a performance benefit to keep a frequently used array in new-space.
3823
- } else if (!Heap::new_space()->Contains(elts) &&
4034
+ } else if (!GetHeap()->new_space()->Contains(elts) &&
3824
4035
  required_size < kArraySizeThatFitsComfortablyInNewSpace) {
3825
4036
  // Expand will allocate a new backing store in new space even if the size
3826
4037
  // we asked for isn't larger than what we had before.
@@ -3842,7 +4053,22 @@ void JSArray::SetContent(FixedArray* storage) {
3842
4053
 
3843
4054
  MaybeObject* FixedArray::Copy() {
3844
4055
  if (length() == 0) return this;
3845
- return Heap::CopyFixedArray(this);
4056
+ return GetHeap()->CopyFixedArray(this);
4057
+ }
4058
+
4059
+
4060
+ Relocatable::Relocatable(Isolate* isolate) {
4061
+ ASSERT(isolate == Isolate::Current());
4062
+ isolate_ = isolate;
4063
+ prev_ = isolate->relocatable_top();
4064
+ isolate->set_relocatable_top(this);
4065
+ }
4066
+
4067
+
4068
+ Relocatable::~Relocatable() {
4069
+ ASSERT(isolate_ == Isolate::Current());
4070
+ ASSERT_EQ(isolate_->relocatable_top(), this);
4071
+ isolate_->set_relocatable_top(prev_);
3846
4072
  }
3847
4073
 
3848
4074