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
data/vendor/v8/src/heap.h CHANGED
@@ -32,6 +32,7 @@
32
32
 
33
33
  #include "globals.h"
34
34
  #include "list.h"
35
+ #include "mark-compact.h"
35
36
  #include "spaces.h"
36
37
  #include "splay-tree-inl.h"
37
38
  #include "v8-counters.h"
@@ -39,9 +40,14 @@
39
40
  namespace v8 {
40
41
  namespace internal {
41
42
 
43
+ // TODO(isolates): remove HEAP here
44
+ #define HEAP (_inline_get_heap_())
45
+ class Heap;
46
+ inline Heap* _inline_get_heap_();
47
+
42
48
 
43
49
  // Defines all the roots in Heap.
44
- #define UNCONDITIONAL_STRONG_ROOT_LIST(V) \
50
+ #define STRONG_ROOT_LIST(V) \
45
51
  /* Put the byte array map early. We need it to be in place by the time */ \
46
52
  /* the deserializer hits the next page, since it wants to put a byte */ \
47
53
  /* array in the unused space at the end of the page. */ \
@@ -49,7 +55,6 @@ namespace internal {
49
55
  V(Map, one_pointer_filler_map, OnePointerFillerMap) \
50
56
  V(Map, two_pointer_filler_map, TwoPointerFillerMap) \
51
57
  /* Cluster the most popular ones in a few cache lines here at the top. */ \
52
- V(Smi, stack_limit, StackLimit) \
53
58
  V(Object, undefined_value, UndefinedValue) \
54
59
  V(Object, the_hole_value, TheHoleValue) \
55
60
  V(Object, null_value, NullValue) \
@@ -62,27 +67,35 @@ namespace internal {
62
67
  V(Map, fixed_cow_array_map, FixedCOWArrayMap) \
63
68
  V(Object, no_interceptor_result_sentinel, NoInterceptorResultSentinel) \
64
69
  V(Map, meta_map, MetaMap) \
65
- V(Object, termination_exception, TerminationException) \
66
70
  V(Map, hash_table_map, HashTableMap) \
71
+ V(Smi, stack_limit, StackLimit) \
72
+ V(FixedArray, number_string_cache, NumberStringCache) \
73
+ V(Object, instanceof_cache_function, InstanceofCacheFunction) \
74
+ V(Object, instanceof_cache_map, InstanceofCacheMap) \
75
+ V(Object, instanceof_cache_answer, InstanceofCacheAnswer) \
76
+ V(FixedArray, single_character_string_cache, SingleCharacterStringCache) \
77
+ V(Object, termination_exception, TerminationException) \
67
78
  V(FixedArray, empty_fixed_array, EmptyFixedArray) \
68
79
  V(ByteArray, empty_byte_array, EmptyByteArray) \
80
+ V(String, empty_string, EmptyString) \
81
+ V(DescriptorArray, empty_descriptor_array, EmptyDescriptorArray) \
69
82
  V(Map, string_map, StringMap) \
70
83
  V(Map, ascii_string_map, AsciiStringMap) \
71
84
  V(Map, symbol_map, SymbolMap) \
85
+ V(Map, cons_string_map, ConsStringMap) \
86
+ V(Map, cons_ascii_string_map, ConsAsciiStringMap) \
72
87
  V(Map, ascii_symbol_map, AsciiSymbolMap) \
73
88
  V(Map, cons_symbol_map, ConsSymbolMap) \
74
89
  V(Map, cons_ascii_symbol_map, ConsAsciiSymbolMap) \
75
90
  V(Map, external_symbol_map, ExternalSymbolMap) \
76
91
  V(Map, external_symbol_with_ascii_data_map, ExternalSymbolWithAsciiDataMap) \
77
92
  V(Map, external_ascii_symbol_map, ExternalAsciiSymbolMap) \
78
- V(Map, cons_string_map, ConsStringMap) \
79
- V(Map, cons_ascii_string_map, ConsAsciiStringMap) \
80
93
  V(Map, external_string_map, ExternalStringMap) \
81
94
  V(Map, external_string_with_ascii_data_map, ExternalStringWithAsciiDataMap) \
82
95
  V(Map, external_ascii_string_map, ExternalAsciiStringMap) \
83
96
  V(Map, undetectable_string_map, UndetectableStringMap) \
84
97
  V(Map, undetectable_ascii_string_map, UndetectableAsciiStringMap) \
85
- V(Map, pixel_array_map, PixelArrayMap) \
98
+ V(Map, external_pixel_array_map, ExternalPixelArrayMap) \
86
99
  V(Map, external_byte_array_map, ExternalByteArrayMap) \
87
100
  V(Map, external_unsigned_byte_array_map, ExternalUnsignedByteArrayMap) \
88
101
  V(Map, external_short_array_map, ExternalShortArrayMap) \
@@ -100,11 +113,6 @@ namespace internal {
100
113
  V(Map, proxy_map, ProxyMap) \
101
114
  V(Object, nan_value, NanValue) \
102
115
  V(Object, minus_zero_value, MinusZeroValue) \
103
- V(Object, instanceof_cache_function, InstanceofCacheFunction) \
104
- V(Object, instanceof_cache_map, InstanceofCacheMap) \
105
- V(Object, instanceof_cache_answer, InstanceofCacheAnswer) \
106
- V(String, empty_string, EmptyString) \
107
- V(DescriptorArray, empty_descriptor_array, EmptyDescriptorArray) \
108
116
  V(Map, neander_map, NeanderMap) \
109
117
  V(JSObject, message_listeners, MessageListeners) \
110
118
  V(Proxy, prototype_accessors, PrototypeAccessors) \
@@ -112,28 +120,12 @@ namespace internal {
112
120
  V(NumberDictionary, non_monomorphic_cache, NonMonomorphicCache) \
113
121
  V(Code, js_entry_code, JsEntryCode) \
114
122
  V(Code, js_construct_entry_code, JsConstructEntryCode) \
115
- V(Code, c_entry_code, CEntryCode) \
116
- V(FixedArray, number_string_cache, NumberStringCache) \
117
- V(FixedArray, single_character_string_cache, SingleCharacterStringCache) \
118
123
  V(FixedArray, natives_source_cache, NativesSourceCache) \
119
124
  V(Object, last_script_id, LastScriptId) \
120
125
  V(Script, empty_script, EmptyScript) \
121
126
  V(Smi, real_stack_limit, RealStackLimit) \
122
127
  V(StringDictionary, intrinsic_function_names, IntrinsicFunctionNames) \
123
128
 
124
- #if V8_TARGET_ARCH_ARM && !V8_INTERPRETED_REGEXP
125
- #define STRONG_ROOT_LIST(V) \
126
- UNCONDITIONAL_STRONG_ROOT_LIST(V) \
127
- V(Code, re_c_entry_code, RegExpCEntryCode) \
128
- V(Code, direct_c_entry_code, DirectCEntryCode)
129
- #elif V8_TARGET_ARCH_ARM
130
- #define STRONG_ROOT_LIST(V) \
131
- UNCONDITIONAL_STRONG_ROOT_LIST(V) \
132
- V(Code, direct_c_entry_code, DirectCEntryCode)
133
- #else
134
- #define STRONG_ROOT_LIST(V) UNCONDITIONAL_STRONG_ROOT_LIST(V)
135
- #endif
136
-
137
129
  #define ROOT_LIST(V) \
138
130
  STRONG_ROOT_LIST(V) \
139
131
  V(SymbolTable, symbol_table, SymbolTable)
@@ -163,6 +155,7 @@ namespace internal {
163
155
  V(name_symbol, "name") \
164
156
  V(number_symbol, "number") \
165
157
  V(Number_symbol, "Number") \
158
+ V(nan_symbol, "NaN") \
166
159
  V(RegExp_symbol, "RegExp") \
167
160
  V(source_symbol, "source") \
168
161
  V(global_symbol, "global") \
@@ -185,8 +178,6 @@ namespace internal {
185
178
  V(InitializeConstGlobal_symbol, "InitializeConstGlobal") \
186
179
  V(KeyedLoadSpecialized_symbol, "KeyedLoadSpecialized") \
187
180
  V(KeyedStoreSpecialized_symbol, "KeyedStoreSpecialized") \
188
- V(KeyedLoadPixelArray_symbol, "KeyedLoadPixelArray") \
189
- V(KeyedStorePixelArray_symbol, "KeyedStorePixelArray") \
190
181
  V(stack_overflow_symbol, "kStackOverflowBoilerplate") \
191
182
  V(illegal_access_symbol, "illegal access") \
192
183
  V(out_of_memory_symbol, "out-of-memory") \
@@ -215,19 +206,42 @@ namespace internal {
215
206
  V(identity_hash_symbol, "v8::IdentityHash") \
216
207
  V(closure_symbol, "(closure)") \
217
208
  V(use_strict, "use strict") \
218
- V(KeyedLoadExternalArray_symbol, "KeyedLoadExternalArray") \
219
- V(KeyedStoreExternalArray_symbol, "KeyedStoreExternalArray")
220
-
209
+ V(KeyedLoadExternalByteArray_symbol, "KeyedLoadExternalByteArray") \
210
+ V(KeyedLoadExternalUnsignedByteArray_symbol, \
211
+ "KeyedLoadExternalUnsignedByteArray") \
212
+ V(KeyedLoadExternalShortArray_symbol, \
213
+ "KeyedLoadExternalShortArray") \
214
+ V(KeyedLoadExternalUnsignedShortArray_symbol, \
215
+ "KeyedLoadExternalUnsignedShortArray") \
216
+ V(KeyedLoadExternalIntArray_symbol, "KeyedLoadExternalIntArray") \
217
+ V(KeyedLoadExternalUnsignedIntArray_symbol, \
218
+ "KeyedLoadExternalUnsignedIntArray") \
219
+ V(KeyedLoadExternalFloatArray_symbol, "KeyedLoadExternalFloatArray") \
220
+ V(KeyedLoadExternalPixelArray_symbol, "KeyedLoadExternalPixelArray") \
221
+ V(KeyedStoreExternalByteArray_symbol, "KeyedStoreExternalByteArray") \
222
+ V(KeyedStoreExternalUnsignedByteArray_symbol, \
223
+ "KeyedStoreExternalUnsignedByteArray") \
224
+ V(KeyedStoreExternalShortArray_symbol, "KeyedStoreExternalShortArray") \
225
+ V(KeyedStoreExternalUnsignedShortArray_symbol, \
226
+ "KeyedStoreExternalUnsignedShortArray") \
227
+ V(KeyedStoreExternalIntArray_symbol, "KeyedStoreExternalIntArray") \
228
+ V(KeyedStoreExternalUnsignedIntArray_symbol, \
229
+ "KeyedStoreExternalUnsignedIntArray") \
230
+ V(KeyedStoreExternalFloatArray_symbol, "KeyedStoreExternalFloatArray") \
231
+ V(KeyedStoreExternalPixelArray_symbol, "KeyedStoreExternalPixelArray")
221
232
 
222
233
  // Forward declarations.
223
234
  class GCTracer;
224
235
  class HeapStats;
236
+ class Isolate;
225
237
  class WeakObjectRetainer;
226
238
 
227
239
 
228
- typedef String* (*ExternalStringTableUpdaterCallback)(Object** pointer);
240
+ typedef String* (*ExternalStringTableUpdaterCallback)(Heap* heap,
241
+ Object** pointer);
229
242
 
230
- typedef bool (*DirtyRegionCallback)(Address start,
243
+ typedef bool (*DirtyRegionCallback)(Heap* heap,
244
+ Address start,
231
245
  Address end,
232
246
  ObjectSlotCallback copy_object_func);
233
247
 
@@ -235,103 +249,178 @@ typedef bool (*DirtyRegionCallback)(Address start,
235
249
  // The all static Heap captures the interface to the global object heap.
236
250
  // All JavaScript contexts by this process share the same object heap.
237
251
 
238
- class Heap : public AllStatic {
252
+ #ifdef DEBUG
253
+ class HeapDebugUtils;
254
+ #endif
255
+
256
+
257
+ // A queue of objects promoted during scavenge. Each object is accompanied
258
+ // by it's size to avoid dereferencing a map pointer for scanning.
259
+ class PromotionQueue {
260
+ public:
261
+ PromotionQueue() : front_(NULL), rear_(NULL) { }
262
+
263
+ void Initialize(Address start_address) {
264
+ front_ = rear_ = reinterpret_cast<intptr_t*>(start_address);
265
+ }
266
+
267
+ bool is_empty() { return front_ <= rear_; }
268
+
269
+ inline void insert(HeapObject* target, int size);
270
+
271
+ void remove(HeapObject** target, int* size) {
272
+ *target = reinterpret_cast<HeapObject*>(*(--front_));
273
+ *size = static_cast<int>(*(--front_));
274
+ // Assert no underflow.
275
+ ASSERT(front_ >= rear_);
276
+ }
277
+
278
+ private:
279
+ // The front of the queue is higher in memory than the rear.
280
+ intptr_t* front_;
281
+ intptr_t* rear_;
282
+
283
+ DISALLOW_COPY_AND_ASSIGN(PromotionQueue);
284
+ };
285
+
286
+
287
+ // External strings table is a place where all external strings are
288
+ // registered. We need to keep track of such strings to properly
289
+ // finalize them.
290
+ class ExternalStringTable {
291
+ public:
292
+ // Registers an external string.
293
+ inline void AddString(String* string);
294
+
295
+ inline void Iterate(ObjectVisitor* v);
296
+
297
+ // Restores internal invariant and gets rid of collected strings.
298
+ // Must be called after each Iterate() that modified the strings.
299
+ void CleanUp();
300
+
301
+ // Destroys all allocated memory.
302
+ void TearDown();
303
+
304
+ private:
305
+ ExternalStringTable() { }
306
+
307
+ friend class Heap;
308
+
309
+ inline void Verify();
310
+
311
+ inline void AddOldString(String* string);
312
+
313
+ // Notifies the table that only a prefix of the new list is valid.
314
+ inline void ShrinkNewStrings(int position);
315
+
316
+ // To speed up scavenge collections new space string are kept
317
+ // separate from old space strings.
318
+ List<Object*> new_space_strings_;
319
+ List<Object*> old_space_strings_;
320
+
321
+ Heap* heap_;
322
+
323
+ DISALLOW_COPY_AND_ASSIGN(ExternalStringTable);
324
+ };
325
+
326
+
327
+ class Heap {
239
328
  public:
240
329
  // Configure heap size before setup. Return false if the heap has been
241
330
  // setup already.
242
- static bool ConfigureHeap(int max_semispace_size,
243
- int max_old_gen_size,
244
- int max_executable_size);
245
- static bool ConfigureHeapDefault();
331
+ bool ConfigureHeap(int max_semispace_size,
332
+ int max_old_gen_size,
333
+ int max_executable_size);
334
+ bool ConfigureHeapDefault();
246
335
 
247
336
  // Initializes the global object heap. If create_heap_objects is true,
248
337
  // also creates the basic non-mutable objects.
249
338
  // Returns whether it succeeded.
250
- static bool Setup(bool create_heap_objects);
339
+ bool Setup(bool create_heap_objects);
251
340
 
252
341
  // Destroys all memory allocated by the heap.
253
- static void TearDown();
342
+ void TearDown();
254
343
 
255
344
  // Set the stack limit in the roots_ array. Some architectures generate
256
345
  // code that looks here, because it is faster than loading from the static
257
346
  // jslimit_/real_jslimit_ variable in the StackGuard.
258
- static void SetStackLimits();
347
+ void SetStackLimits();
259
348
 
260
349
  // Returns whether Setup has been called.
261
- static bool HasBeenSetup();
350
+ bool HasBeenSetup();
262
351
 
263
352
  // Returns the maximum amount of memory reserved for the heap. For
264
353
  // the young generation, we reserve 4 times the amount needed for a
265
354
  // semi space. The young generation consists of two semi spaces and
266
355
  // we reserve twice the amount needed for those in order to ensure
267
356
  // that new space can be aligned to its size.
268
- static intptr_t MaxReserved() {
357
+ intptr_t MaxReserved() {
269
358
  return 4 * reserved_semispace_size_ + max_old_generation_size_;
270
359
  }
271
- static int MaxSemiSpaceSize() { return max_semispace_size_; }
272
- static int ReservedSemiSpaceSize() { return reserved_semispace_size_; }
273
- static int InitialSemiSpaceSize() { return initial_semispace_size_; }
274
- static intptr_t MaxOldGenerationSize() { return max_old_generation_size_; }
275
- static intptr_t MaxExecutableSize() { return max_executable_size_; }
360
+ int MaxSemiSpaceSize() { return max_semispace_size_; }
361
+ int ReservedSemiSpaceSize() { return reserved_semispace_size_; }
362
+ int InitialSemiSpaceSize() { return initial_semispace_size_; }
363
+ intptr_t MaxOldGenerationSize() { return max_old_generation_size_; }
364
+ intptr_t MaxExecutableSize() { return max_executable_size_; }
276
365
 
277
366
  // Returns the capacity of the heap in bytes w/o growing. Heap grows when
278
367
  // more spaces are needed until it reaches the limit.
279
- static intptr_t Capacity();
368
+ intptr_t Capacity();
280
369
 
281
370
  // Returns the amount of memory currently committed for the heap.
282
- static intptr_t CommittedMemory();
371
+ intptr_t CommittedMemory();
283
372
 
284
373
  // Returns the amount of executable memory currently committed for the heap.
285
- static intptr_t CommittedMemoryExecutable();
374
+ intptr_t CommittedMemoryExecutable();
286
375
 
287
376
  // Returns the available bytes in space w/o growing.
288
377
  // Heap doesn't guarantee that it can allocate an object that requires
289
378
  // all available bytes. Check MaxHeapObjectSize() instead.
290
- static intptr_t Available();
379
+ intptr_t Available();
291
380
 
292
381
  // Returns the maximum object size in paged space.
293
- static inline int MaxObjectSizeInPagedSpace();
382
+ inline int MaxObjectSizeInPagedSpace();
294
383
 
295
384
  // Returns of size of all objects residing in the heap.
296
- static intptr_t SizeOfObjects();
385
+ intptr_t SizeOfObjects();
297
386
 
298
387
  // Return the starting address and a mask for the new space. And-masking an
299
388
  // address with the mask will result in the start address of the new space
300
389
  // for all addresses in either semispace.
301
- static Address NewSpaceStart() { return new_space_.start(); }
302
- static uintptr_t NewSpaceMask() { return new_space_.mask(); }
303
- static Address NewSpaceTop() { return new_space_.top(); }
304
-
305
- static NewSpace* new_space() { return &new_space_; }
306
- static OldSpace* old_pointer_space() { return old_pointer_space_; }
307
- static OldSpace* old_data_space() { return old_data_space_; }
308
- static OldSpace* code_space() { return code_space_; }
309
- static MapSpace* map_space() { return map_space_; }
310
- static CellSpace* cell_space() { return cell_space_; }
311
- static LargeObjectSpace* lo_space() { return lo_space_; }
312
-
313
- static bool always_allocate() { return always_allocate_scope_depth_ != 0; }
314
- static Address always_allocate_scope_depth_address() {
390
+ Address NewSpaceStart() { return new_space_.start(); }
391
+ uintptr_t NewSpaceMask() { return new_space_.mask(); }
392
+ Address NewSpaceTop() { return new_space_.top(); }
393
+
394
+ NewSpace* new_space() { return &new_space_; }
395
+ OldSpace* old_pointer_space() { return old_pointer_space_; }
396
+ OldSpace* old_data_space() { return old_data_space_; }
397
+ OldSpace* code_space() { return code_space_; }
398
+ MapSpace* map_space() { return map_space_; }
399
+ CellSpace* cell_space() { return cell_space_; }
400
+ LargeObjectSpace* lo_space() { return lo_space_; }
401
+
402
+ bool always_allocate() { return always_allocate_scope_depth_ != 0; }
403
+ Address always_allocate_scope_depth_address() {
315
404
  return reinterpret_cast<Address>(&always_allocate_scope_depth_);
316
405
  }
317
- static bool linear_allocation() {
406
+ bool linear_allocation() {
318
407
  return linear_allocation_scope_depth_ != 0;
319
408
  }
320
409
 
321
- static Address* NewSpaceAllocationTopAddress() {
410
+ Address* NewSpaceAllocationTopAddress() {
322
411
  return new_space_.allocation_top_address();
323
412
  }
324
- static Address* NewSpaceAllocationLimitAddress() {
413
+ Address* NewSpaceAllocationLimitAddress() {
325
414
  return new_space_.allocation_limit_address();
326
415
  }
327
416
 
328
417
  // Uncommit unused semi space.
329
- static bool UncommitFromSpace() { return new_space_.UncommitFromSpace(); }
418
+ bool UncommitFromSpace() { return new_space_.UncommitFromSpace(); }
330
419
 
331
420
  #ifdef ENABLE_HEAP_PROTECTION
332
421
  // Protect/unprotect the heap by marking all spaces read-only/writable.
333
- static void Protect();
334
- static void Unprotect();
422
+ void Protect();
423
+ void Unprotect();
335
424
  #endif
336
425
 
337
426
  // Allocates and initializes a new JavaScript object based on a
@@ -339,71 +428,65 @@ class Heap : public AllStatic {
339
428
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
340
429
  // failed.
341
430
  // Please note this does not perform a garbage collection.
342
- MUST_USE_RESULT static MaybeObject* AllocateJSObject(
431
+ MUST_USE_RESULT MaybeObject* AllocateJSObject(
343
432
  JSFunction* constructor, PretenureFlag pretenure = NOT_TENURED);
344
433
 
345
434
  // Allocates and initializes a new global object based on a constructor.
346
435
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
347
436
  // failed.
348
437
  // Please note this does not perform a garbage collection.
349
- MUST_USE_RESULT static MaybeObject* AllocateGlobalObject(
350
- JSFunction* constructor);
438
+ MUST_USE_RESULT MaybeObject* AllocateGlobalObject(JSFunction* constructor);
351
439
 
352
440
  // Returns a deep copy of the JavaScript object.
353
441
  // Properties and elements are copied too.
354
442
  // Returns failure if allocation failed.
355
- MUST_USE_RESULT static MaybeObject* CopyJSObject(JSObject* source);
443
+ MUST_USE_RESULT MaybeObject* CopyJSObject(JSObject* source);
356
444
 
357
445
  // Allocates the function prototype.
358
446
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
359
447
  // failed.
360
448
  // Please note this does not perform a garbage collection.
361
- MUST_USE_RESULT static MaybeObject* AllocateFunctionPrototype(
362
- JSFunction* function);
449
+ MUST_USE_RESULT MaybeObject* AllocateFunctionPrototype(JSFunction* function);
363
450
 
364
451
  // Reinitialize an JSGlobalProxy based on a constructor. The object
365
452
  // must have the same size as objects allocated using the
366
453
  // constructor. The object is reinitialized and behaves as an
367
454
  // object that has been freshly allocated using the constructor.
368
- MUST_USE_RESULT static MaybeObject* ReinitializeJSGlobalProxy(
369
- JSFunction* constructor,
370
- JSGlobalProxy* global);
455
+ MUST_USE_RESULT MaybeObject* ReinitializeJSGlobalProxy(
456
+ JSFunction* constructor, JSGlobalProxy* global);
371
457
 
372
458
  // Allocates and initializes a new JavaScript object based on a map.
373
459
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
374
460
  // failed.
375
461
  // Please note this does not perform a garbage collection.
376
- MUST_USE_RESULT static MaybeObject* AllocateJSObjectFromMap(
462
+ MUST_USE_RESULT MaybeObject* AllocateJSObjectFromMap(
377
463
  Map* map, PretenureFlag pretenure = NOT_TENURED);
378
464
 
379
465
  // Allocates a heap object based on the map.
380
466
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
381
467
  // failed.
382
468
  // Please note this function does not perform a garbage collection.
383
- MUST_USE_RESULT static MaybeObject* Allocate(Map* map, AllocationSpace space);
469
+ MUST_USE_RESULT MaybeObject* Allocate(Map* map, AllocationSpace space);
384
470
 
385
471
  // Allocates a JS Map in the heap.
386
472
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
387
473
  // failed.
388
474
  // Please note this function does not perform a garbage collection.
389
- MUST_USE_RESULT static MaybeObject* AllocateMap(InstanceType instance_type,
390
- int instance_size);
475
+ MUST_USE_RESULT MaybeObject* AllocateMap(InstanceType instance_type,
476
+ int instance_size);
391
477
 
392
478
  // Allocates a partial map for bootstrapping.
393
- MUST_USE_RESULT static MaybeObject* AllocatePartialMap(
394
- InstanceType instance_type,
395
- int instance_size);
479
+ MUST_USE_RESULT MaybeObject* AllocatePartialMap(InstanceType instance_type,
480
+ int instance_size);
396
481
 
397
482
  // Allocate a map for the specified function
398
- MUST_USE_RESULT static MaybeObject* AllocateInitialMap(JSFunction* fun);
483
+ MUST_USE_RESULT MaybeObject* AllocateInitialMap(JSFunction* fun);
399
484
 
400
485
  // Allocates an empty code cache.
401
- MUST_USE_RESULT static MaybeObject* AllocateCodeCache();
486
+ MUST_USE_RESULT MaybeObject* AllocateCodeCache();
402
487
 
403
488
  // Clear the Instanceof cache (used when a prototype changes).
404
- static void ClearInstanceofCache() {
405
- set_instanceof_cache_function(the_hole_value());
406
- }
489
+ inline void ClearInstanceofCache();
407
490
 
408
491
  // Allocates and fully initializes a String. There are two String
409
492
  // encodings: ASCII and two byte. One should choose between the three string
@@ -423,16 +506,16 @@ class Heap : public AllStatic {
423
506
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
424
507
  // failed.
425
508
  // Please note this does not perform a garbage collection.
426
- MUST_USE_RESULT static MaybeObject* AllocateStringFromAscii(
509
+ MUST_USE_RESULT MaybeObject* AllocateStringFromAscii(
427
510
  Vector<const char> str,
428
511
  PretenureFlag pretenure = NOT_TENURED);
429
- MUST_USE_RESULT static inline MaybeObject* AllocateStringFromUtf8(
512
+ MUST_USE_RESULT inline MaybeObject* AllocateStringFromUtf8(
430
513
  Vector<const char> str,
431
514
  PretenureFlag pretenure = NOT_TENURED);
432
- MUST_USE_RESULT static MaybeObject* AllocateStringFromUtf8Slow(
515
+ MUST_USE_RESULT MaybeObject* AllocateStringFromUtf8Slow(
433
516
  Vector<const char> str,
434
517
  PretenureFlag pretenure = NOT_TENURED);
435
- MUST_USE_RESULT static MaybeObject* AllocateStringFromTwoByte(
518
+ MUST_USE_RESULT MaybeObject* AllocateStringFromTwoByte(
436
519
  Vector<const uc16> str,
437
520
  PretenureFlag pretenure = NOT_TENURED);
438
521
 
@@ -440,27 +523,25 @@ class Heap : public AllStatic {
440
523
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
441
524
  // failed.
442
525
  // Please note this function does not perform a garbage collection.
443
- MUST_USE_RESULT static inline MaybeObject* AllocateSymbol(
444
- Vector<const char> str,
445
- int chars,
446
- uint32_t hash_field);
526
+ MUST_USE_RESULT inline MaybeObject* AllocateSymbol(Vector<const char> str,
527
+ int chars,
528
+ uint32_t hash_field);
447
529
 
448
- MUST_USE_RESULT static inline MaybeObject* AllocateAsciiSymbol(
530
+ MUST_USE_RESULT inline MaybeObject* AllocateAsciiSymbol(
449
531
  Vector<const char> str,
450
532
  uint32_t hash_field);
451
533
 
452
- MUST_USE_RESULT static inline MaybeObject* AllocateTwoByteSymbol(
534
+ MUST_USE_RESULT inline MaybeObject* AllocateTwoByteSymbol(
453
535
  Vector<const uc16> str,
454
536
  uint32_t hash_field);
455
537
 
456
- MUST_USE_RESULT static MaybeObject* AllocateInternalSymbol(
538
+ MUST_USE_RESULT MaybeObject* AllocateInternalSymbol(
457
539
  unibrow::CharacterStream* buffer, int chars, uint32_t hash_field);
458
540
 
459
- MUST_USE_RESULT static MaybeObject* AllocateExternalSymbol(
541
+ MUST_USE_RESULT MaybeObject* AllocateExternalSymbol(
460
542
  Vector<const char> str,
461
543
  int chars);
462
544
 
463
-
464
545
  // Allocates and partially initializes a String. There are two String
465
546
  // encodings: ASCII and two byte. These functions allocate a string of the
466
547
  // given length and set its map and length fields. The characters of the
@@ -468,10 +549,10 @@ class Heap : public AllStatic {
468
549
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
469
550
  // failed.
470
551
  // Please note this does not perform a garbage collection.
471
- MUST_USE_RESULT static MaybeObject* AllocateRawAsciiString(
552
+ MUST_USE_RESULT MaybeObject* AllocateRawAsciiString(
472
553
  int length,
473
554
  PretenureFlag pretenure = NOT_TENURED);
474
- MUST_USE_RESULT static MaybeObject* AllocateRawTwoByteString(
555
+ MUST_USE_RESULT MaybeObject* AllocateRawTwoByteString(
475
556
  int length,
476
557
  PretenureFlag pretenure = NOT_TENURED);
477
558
 
@@ -479,35 +560,27 @@ class Heap : public AllStatic {
479
560
  // A cache is used for ascii codes.
480
561
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
481
562
  // failed. Please note this does not perform a garbage collection.
482
- MUST_USE_RESULT static MaybeObject* LookupSingleCharacterStringFromCode(
563
+ MUST_USE_RESULT MaybeObject* LookupSingleCharacterStringFromCode(
483
564
  uint16_t code);
484
565
 
485
566
  // Allocate a byte array of the specified length
486
567
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
487
568
  // failed.
488
569
  // Please note this does not perform a garbage collection.
489
- MUST_USE_RESULT static MaybeObject* AllocateByteArray(int length,
490
- PretenureFlag pretenure);
570
+ MUST_USE_RESULT MaybeObject* AllocateByteArray(int length,
571
+ PretenureFlag pretenure);
491
572
 
492
573
  // Allocate a non-tenured byte array of the specified length
493
574
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
494
575
  // failed.
495
576
  // Please note this does not perform a garbage collection.
496
- MUST_USE_RESULT static MaybeObject* AllocateByteArray(int length);
497
-
498
- // Allocate a pixel array of the specified length
499
- // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
500
- // failed.
501
- // Please note this does not perform a garbage collection.
502
- MUST_USE_RESULT static MaybeObject* AllocatePixelArray(int length,
503
- uint8_t* external_pointer,
504
- PretenureFlag pretenure);
577
+ MUST_USE_RESULT MaybeObject* AllocateByteArray(int length);
505
578
 
506
579
  // Allocates an external array of the specified length and type.
507
580
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
508
581
  // failed.
509
582
  // Please note this does not perform a garbage collection.
510
- MUST_USE_RESULT static MaybeObject* AllocateExternalArray(
583
+ MUST_USE_RESULT MaybeObject* AllocateExternalArray(
511
584
  int length,
512
585
  ExternalArrayType array_type,
513
586
  void* external_pointer,
@@ -517,132 +590,130 @@ class Heap : public AllStatic {
517
590
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
518
591
  // failed.
519
592
  // Please note this does not perform a garbage collection.
520
- MUST_USE_RESULT static MaybeObject* AllocateJSGlobalPropertyCell(
521
- Object* value);
593
+ MUST_USE_RESULT MaybeObject* AllocateJSGlobalPropertyCell(Object* value);
522
594
 
523
595
  // Allocates a fixed array initialized with undefined values
524
596
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
525
597
  // failed.
526
598
  // Please note this does not perform a garbage collection.
527
- MUST_USE_RESULT static MaybeObject* AllocateFixedArray(
528
- int length,
529
- PretenureFlag pretenure);
599
+ MUST_USE_RESULT MaybeObject* AllocateFixedArray(int length,
600
+ PretenureFlag pretenure);
530
601
  // Allocates a fixed array initialized with undefined values
531
- MUST_USE_RESULT static MaybeObject* AllocateFixedArray(int length);
602
+ MUST_USE_RESULT MaybeObject* AllocateFixedArray(int length);
532
603
 
533
604
  // Allocates an uninitialized fixed array. It must be filled by the caller.
534
605
  //
535
606
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
536
607
  // failed.
537
608
  // Please note this does not perform a garbage collection.
538
- MUST_USE_RESULT static MaybeObject* AllocateUninitializedFixedArray(
539
- int length);
609
+ MUST_USE_RESULT MaybeObject* AllocateUninitializedFixedArray(int length);
540
610
 
541
611
  // Make a copy of src and return it. Returns
542
612
  // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed.
543
- MUST_USE_RESULT static inline MaybeObject* CopyFixedArray(FixedArray* src);
613
+ MUST_USE_RESULT inline MaybeObject* CopyFixedArray(FixedArray* src);
544
614
 
545
615
  // Make a copy of src, set the map, and return the copy. Returns
546
616
  // Failure::RetryAfterGC(requested_bytes, space) if the allocation failed.
547
- MUST_USE_RESULT static MaybeObject* CopyFixedArrayWithMap(FixedArray* src,
548
- Map* map);
617
+ MUST_USE_RESULT MaybeObject* CopyFixedArrayWithMap(FixedArray* src, Map* map);
549
618
 
550
619
  // Allocates a fixed array initialized with the hole values.
551
620
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
552
621
  // failed.
553
622
  // Please note this does not perform a garbage collection.
554
- MUST_USE_RESULT static MaybeObject* AllocateFixedArrayWithHoles(
623
+ MUST_USE_RESULT MaybeObject* AllocateFixedArrayWithHoles(
555
624
  int length,
556
625
  PretenureFlag pretenure = NOT_TENURED);
557
626
 
558
627
  // AllocateHashTable is identical to AllocateFixedArray except
559
628
  // that the resulting object has hash_table_map as map.
560
- MUST_USE_RESULT static MaybeObject* AllocateHashTable(
629
+ MUST_USE_RESULT MaybeObject* AllocateHashTable(
561
630
  int length, PretenureFlag pretenure = NOT_TENURED);
562
631
 
563
632
  // Allocate a global (but otherwise uninitialized) context.
564
- MUST_USE_RESULT static MaybeObject* AllocateGlobalContext();
633
+ MUST_USE_RESULT MaybeObject* AllocateGlobalContext();
565
634
 
566
635
  // Allocate a function context.
567
- MUST_USE_RESULT static MaybeObject* AllocateFunctionContext(
568
- int length,
569
- JSFunction* closure);
636
+ MUST_USE_RESULT MaybeObject* AllocateFunctionContext(int length,
637
+ JSFunction* closure);
570
638
 
571
639
  // Allocate a 'with' context.
572
- MUST_USE_RESULT static MaybeObject* AllocateWithContext(
573
- Context* previous,
574
- JSObject* extension,
575
- bool is_catch_context);
640
+ MUST_USE_RESULT MaybeObject* AllocateWithContext(Context* previous,
641
+ JSObject* extension,
642
+ bool is_catch_context);
576
643
 
577
644
  // Allocates a new utility object in the old generation.
578
- MUST_USE_RESULT static MaybeObject* AllocateStruct(InstanceType type);
645
+ MUST_USE_RESULT MaybeObject* AllocateStruct(InstanceType type);
579
646
 
580
647
  // Allocates a function initialized with a shared part.
581
648
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
582
649
  // failed.
583
650
  // Please note this does not perform a garbage collection.
584
- MUST_USE_RESULT static MaybeObject* AllocateFunction(
651
+ MUST_USE_RESULT MaybeObject* AllocateFunction(
585
652
  Map* function_map,
586
653
  SharedFunctionInfo* shared,
587
654
  Object* prototype,
588
655
  PretenureFlag pretenure = TENURED);
589
656
 
590
- // Indicies for direct access into argument objects.
657
+ // Arguments object size.
591
658
  static const int kArgumentsObjectSize =
592
659
  JSObject::kHeaderSize + 2 * kPointerSize;
593
- static const int arguments_callee_index = 0;
594
- static const int arguments_length_index = 1;
660
+ // Strict mode arguments has no callee so it is smaller.
661
+ static const int kArgumentsObjectSizeStrict =
662
+ JSObject::kHeaderSize + 1 * kPointerSize;
663
+ // Indicies for direct access into argument objects.
664
+ static const int kArgumentsLengthIndex = 0;
665
+ // callee is only valid in non-strict mode.
666
+ static const int kArgumentsCalleeIndex = 1;
595
667
 
596
668
  // Allocates an arguments object - optionally with an elements array.
597
669
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
598
670
  // failed.
599
671
  // Please note this does not perform a garbage collection.
600
- MUST_USE_RESULT static MaybeObject* AllocateArgumentsObject(Object* callee,
601
- int length);
672
+ MUST_USE_RESULT MaybeObject* AllocateArgumentsObject(
673
+ Object* callee, int length);
602
674
 
603
675
  // Same as NewNumberFromDouble, but may return a preallocated/immutable
604
676
  // number object (e.g., minus_zero_value_, nan_value_)
605
- MUST_USE_RESULT static MaybeObject* NumberFromDouble(
677
+ MUST_USE_RESULT MaybeObject* NumberFromDouble(
606
678
  double value, PretenureFlag pretenure = NOT_TENURED);
607
679
 
608
680
  // Allocated a HeapNumber from value.
609
- MUST_USE_RESULT static MaybeObject* AllocateHeapNumber(
681
+ MUST_USE_RESULT MaybeObject* AllocateHeapNumber(
610
682
  double value,
611
683
  PretenureFlag pretenure);
612
- // pretenure = NOT_TENURED.
613
- MUST_USE_RESULT static MaybeObject* AllocateHeapNumber(double value);
684
+ // pretenure = NOT_TENURED
685
+ MUST_USE_RESULT MaybeObject* AllocateHeapNumber(double value);
614
686
 
615
687
  // Converts an int into either a Smi or a HeapNumber object.
616
688
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
617
689
  // failed.
618
690
  // Please note this does not perform a garbage collection.
619
- MUST_USE_RESULT static inline MaybeObject* NumberFromInt32(int32_t value);
691
+ MUST_USE_RESULT inline MaybeObject* NumberFromInt32(int32_t value);
620
692
 
621
693
  // Converts an int into either a Smi or a HeapNumber object.
622
694
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
623
695
  // failed.
624
696
  // Please note this does not perform a garbage collection.
625
- MUST_USE_RESULT static inline MaybeObject* NumberFromUint32(uint32_t value);
697
+ MUST_USE_RESULT inline MaybeObject* NumberFromUint32(uint32_t value);
626
698
 
627
699
  // Allocates a new proxy object.
628
700
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
629
701
  // failed.
630
702
  // Please note this does not perform a garbage collection.
631
- MUST_USE_RESULT static MaybeObject* AllocateProxy(
632
- Address proxy,
633
- PretenureFlag pretenure = NOT_TENURED);
703
+ MUST_USE_RESULT MaybeObject* AllocateProxy(
704
+ Address proxy, PretenureFlag pretenure = NOT_TENURED);
634
705
 
635
706
  // Allocates a new SharedFunctionInfo object.
636
707
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
637
708
  // failed.
638
709
  // Please note this does not perform a garbage collection.
639
- MUST_USE_RESULT static MaybeObject* AllocateSharedFunctionInfo(Object* name);
710
+ MUST_USE_RESULT MaybeObject* AllocateSharedFunctionInfo(Object* name);
640
711
 
641
712
  // Allocates a new JSMessageObject object.
642
713
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
643
714
  // failed.
644
715
  // Please note that this does not perform a garbage collection.
645
- MUST_USE_RESULT static MaybeObject* AllocateJSMessageObject(
716
+ MUST_USE_RESULT MaybeObject* AllocateJSMessageObject(
646
717
  String* type,
647
718
  JSArray* arguments,
648
719
  int start_position,
@@ -655,8 +726,8 @@ class Heap : public AllStatic {
655
726
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
656
727
  // failed.
657
728
  // Please note this does not perform a garbage collection.
658
- MUST_USE_RESULT static MaybeObject* AllocateConsString(String* first,
659
- String* second);
729
+ MUST_USE_RESULT MaybeObject* AllocateConsString(String* first,
730
+ String* second);
660
731
 
661
732
  // Allocates a new sub string object which is a substring of an underlying
662
733
  // string buffer stretching from the index start (inclusive) to the index
@@ -664,7 +735,7 @@ class Heap : public AllStatic {
664
735
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
665
736
  // failed.
666
737
  // Please note this does not perform a garbage collection.
667
- MUST_USE_RESULT static MaybeObject* AllocateSubString(
738
+ MUST_USE_RESULT MaybeObject* AllocateSubString(
668
739
  String* buffer,
669
740
  int start,
670
741
  int end,
@@ -675,28 +746,27 @@ class Heap : public AllStatic {
675
746
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
676
747
  // failed.
677
748
  // Please note this does not perform a garbage collection.
678
- MUST_USE_RESULT static MaybeObject* AllocateExternalStringFromAscii(
749
+ MUST_USE_RESULT MaybeObject* AllocateExternalStringFromAscii(
679
750
  ExternalAsciiString::Resource* resource);
680
- MUST_USE_RESULT static MaybeObject* AllocateExternalStringFromTwoByte(
751
+ MUST_USE_RESULT MaybeObject* AllocateExternalStringFromTwoByte(
681
752
  ExternalTwoByteString::Resource* resource);
682
753
 
683
754
  // Finalizes an external string by deleting the associated external
684
755
  // data and clearing the resource pointer.
685
- static inline void FinalizeExternalString(String* string);
756
+ inline void FinalizeExternalString(String* string);
686
757
 
687
758
  // Allocates an uninitialized object. The memory is non-executable if the
688
759
  // hardware and OS allow.
689
760
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
690
761
  // failed.
691
762
  // Please note this function does not perform a garbage collection.
692
- MUST_USE_RESULT static inline MaybeObject* AllocateRaw(
693
- int size_in_bytes,
694
- AllocationSpace space,
695
- AllocationSpace retry_space);
763
+ MUST_USE_RESULT inline MaybeObject* AllocateRaw(int size_in_bytes,
764
+ AllocationSpace space,
765
+ AllocationSpace retry_space);
696
766
 
697
767
  // Initialize a filler object to keep the ability to iterate over the heap
698
768
  // when shortening objects.
699
- static void CreateFillerObjectAt(Address addr, int size);
769
+ void CreateFillerObjectAt(Address addr, int size);
700
770
 
701
771
  // Makes a new native code object
702
772
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
@@ -704,36 +774,36 @@ class Heap : public AllStatic {
704
774
  // self_reference. This allows generated code to reference its own Code
705
775
  // object by containing this pointer.
706
776
  // Please note this function does not perform a garbage collection.
707
- MUST_USE_RESULT static MaybeObject* CreateCode(const CodeDesc& desc,
708
- Code::Flags flags,
709
- Handle<Object> self_reference);
777
+ MUST_USE_RESULT MaybeObject* CreateCode(const CodeDesc& desc,
778
+ Code::Flags flags,
779
+ Handle<Object> self_reference,
780
+ bool immovable = false);
710
781
 
711
- MUST_USE_RESULT static MaybeObject* CopyCode(Code* code);
782
+ MUST_USE_RESULT MaybeObject* CopyCode(Code* code);
712
783
 
713
784
  // Copy the code and scope info part of the code object, but insert
714
785
  // the provided data as the relocation information.
715
- MUST_USE_RESULT static MaybeObject* CopyCode(Code* code,
716
- Vector<byte> reloc_info);
786
+ MUST_USE_RESULT MaybeObject* CopyCode(Code* code, Vector<byte> reloc_info);
717
787
 
718
788
  // Finds the symbol for string in the symbol table.
719
789
  // If not found, a new symbol is added to the table and returned.
720
790
  // Returns Failure::RetryAfterGC(requested_bytes, space) if allocation
721
791
  // failed.
722
792
  // Please note this function does not perform a garbage collection.
723
- MUST_USE_RESULT static MaybeObject* LookupSymbol(Vector<const char> str);
724
- MUST_USE_RESULT static MaybeObject* LookupAsciiSymbol(Vector<const char> str);
725
- MUST_USE_RESULT static MaybeObject* LookupTwoByteSymbol(
793
+ MUST_USE_RESULT MaybeObject* LookupSymbol(Vector<const char> str);
794
+ MUST_USE_RESULT MaybeObject* LookupAsciiSymbol(Vector<const char> str);
795
+ MUST_USE_RESULT MaybeObject* LookupTwoByteSymbol(
726
796
  Vector<const uc16> str);
727
- MUST_USE_RESULT static MaybeObject* LookupAsciiSymbol(const char* str) {
797
+ MUST_USE_RESULT MaybeObject* LookupAsciiSymbol(const char* str) {
728
798
  return LookupSymbol(CStrVector(str));
729
799
  }
730
- MUST_USE_RESULT static MaybeObject* LookupSymbol(String* str);
731
- static bool LookupSymbolIfExists(String* str, String** symbol);
732
- static bool LookupTwoCharsSymbolIfExists(String* str, String** symbol);
800
+ MUST_USE_RESULT MaybeObject* LookupSymbol(String* str);
801
+ bool LookupSymbolIfExists(String* str, String** symbol);
802
+ bool LookupTwoCharsSymbolIfExists(String* str, String** symbol);
733
803
 
734
804
  // Compute the matching symbol map for a string if possible.
735
805
  // NULL is returned if string is in new space or not flattened.
736
- static Map* SymbolMapForString(String* str);
806
+ Map* SymbolMapForString(String* str);
737
807
 
738
808
  // Tries to flatten a string before compare operation.
739
809
  //
@@ -742,60 +812,60 @@ class Heap : public AllStatic {
742
812
  // string might stay non-flat even when not a failure is returned.
743
813
  //
744
814
  // Please note this function does not perform a garbage collection.
745
- MUST_USE_RESULT static inline MaybeObject* PrepareForCompare(String* str);
815
+ MUST_USE_RESULT inline MaybeObject* PrepareForCompare(String* str);
746
816
 
747
817
  // Converts the given boolean condition to JavaScript boolean value.
748
- static Object* ToBoolean(bool condition) {
749
- return condition ? true_value() : false_value();
750
- }
818
+ inline Object* ToBoolean(bool condition);
751
819
 
752
820
  // Code that should be run before and after each GC. Includes some
753
821
  // reporting/verification activities when compiled with DEBUG set.
754
- static void GarbageCollectionPrologue();
755
- static void GarbageCollectionEpilogue();
822
+ void GarbageCollectionPrologue();
823
+ void GarbageCollectionEpilogue();
756
824
 
757
825
  // Performs garbage collection operation.
758
826
  // Returns whether there is a chance that another major GC could
759
827
  // collect more garbage.
760
- static bool CollectGarbage(AllocationSpace space, GarbageCollector collector);
828
+ bool CollectGarbage(AllocationSpace space, GarbageCollector collector);
761
829
 
762
830
  // Performs garbage collection operation.
763
831
  // Returns whether there is a chance that another major GC could
764
832
  // collect more garbage.
765
- inline static bool CollectGarbage(AllocationSpace space);
833
+ inline bool CollectGarbage(AllocationSpace space);
766
834
 
767
835
  // Performs a full garbage collection. Force compaction if the
768
836
  // parameter is true.
769
- static void CollectAllGarbage(bool force_compaction);
837
+ void CollectAllGarbage(bool force_compaction);
770
838
 
771
839
  // Last hope GC, should try to squeeze as much as possible.
772
- static void CollectAllAvailableGarbage();
840
+ void CollectAllAvailableGarbage();
773
841
 
774
842
  // Notify the heap that a context has been disposed.
775
- static int NotifyContextDisposed() { return ++contexts_disposed_; }
843
+ int NotifyContextDisposed() { return ++contexts_disposed_; }
776
844
 
777
845
  // Utility to invoke the scavenger. This is needed in test code to
778
846
  // ensure correct callback for weak global handles.
779
- static void PerformScavenge();
847
+ void PerformScavenge();
848
+
849
+ PromotionQueue* promotion_queue() { return &promotion_queue_; }
780
850
 
781
851
  #ifdef DEBUG
782
852
  // Utility used with flag gc-greedy.
783
- static void GarbageCollectionGreedyCheck();
853
+ void GarbageCollectionGreedyCheck();
784
854
  #endif
785
855
 
786
- static void AddGCPrologueCallback(
856
+ void AddGCPrologueCallback(
787
857
  GCEpilogueCallback callback, GCType gc_type_filter);
788
- static void RemoveGCPrologueCallback(GCEpilogueCallback callback);
858
+ void RemoveGCPrologueCallback(GCEpilogueCallback callback);
789
859
 
790
- static void AddGCEpilogueCallback(
860
+ void AddGCEpilogueCallback(
791
861
  GCEpilogueCallback callback, GCType gc_type_filter);
792
- static void RemoveGCEpilogueCallback(GCEpilogueCallback callback);
862
+ void RemoveGCEpilogueCallback(GCEpilogueCallback callback);
793
863
 
794
- static void SetGlobalGCPrologueCallback(GCCallback callback) {
864
+ void SetGlobalGCPrologueCallback(GCCallback callback) {
795
865
  ASSERT((callback == NULL) ^ (global_gc_prologue_callback_ == NULL));
796
866
  global_gc_prologue_callback_ = callback;
797
867
  }
798
- static void SetGlobalGCEpilogueCallback(GCCallback callback) {
868
+ void SetGlobalGCEpilogueCallback(GCCallback callback) {
799
869
  ASSERT((callback == NULL) ^ (global_gc_epilogue_callback_ == NULL));
800
870
  global_gc_epilogue_callback_ = callback;
801
871
  }
@@ -803,10 +873,10 @@ class Heap : public AllStatic {
803
873
  // Heap root getters. We have versions with and without type::cast() here.
804
874
  // You can't use type::cast during GC because the assert fails.
805
875
  #define ROOT_ACCESSOR(type, name, camel_name) \
806
- static inline type* name() { \
876
+ type* name() { \
807
877
  return type::cast(roots_[k##camel_name##RootIndex]); \
808
878
  } \
809
- static inline type* raw_unchecked_##name() { \
879
+ type* raw_unchecked_##name() { \
810
880
  return reinterpret_cast<type*>(roots_[k##camel_name##RootIndex]); \
811
881
  }
812
882
  ROOT_LIST(ROOT_ACCESSOR)
@@ -814,13 +884,13 @@ class Heap : public AllStatic {
814
884
 
815
885
  // Utility type maps
816
886
  #define STRUCT_MAP_ACCESSOR(NAME, Name, name) \
817
- static inline Map* name##_map() { \
887
+ Map* name##_map() { \
818
888
  return Map::cast(roots_[k##Name##MapRootIndex]); \
819
889
  }
820
890
  STRUCT_LIST(STRUCT_MAP_ACCESSOR)
821
891
  #undef STRUCT_MAP_ACCESSOR
822
892
 
823
- #define SYMBOL_ACCESSOR(name, str) static inline String* name() { \
893
+ #define SYMBOL_ACCESSOR(name, str) String* name() { \
824
894
  return String::cast(roots_[k##name##RootIndex]); \
825
895
  }
826
896
  SYMBOL_LIST(SYMBOL_ACCESSOR)
@@ -828,19 +898,19 @@ class Heap : public AllStatic {
828
898
 
829
899
  // The hidden_symbol is special because it is the empty string, but does
830
900
  // not match the empty string.
831
- static String* hidden_symbol() { return hidden_symbol_; }
901
+ String* hidden_symbol() { return hidden_symbol_; }
832
902
 
833
- static void set_global_contexts_list(Object* object) {
903
+ void set_global_contexts_list(Object* object) {
834
904
  global_contexts_list_ = object;
835
905
  }
836
- static Object* global_contexts_list() { return global_contexts_list_; }
906
+ Object* global_contexts_list() { return global_contexts_list_; }
837
907
 
838
908
  // Iterates over all roots in the heap.
839
- static void IterateRoots(ObjectVisitor* v, VisitMode mode);
909
+ void IterateRoots(ObjectVisitor* v, VisitMode mode);
840
910
  // Iterates over all strong roots in the heap.
841
- static void IterateStrongRoots(ObjectVisitor* v, VisitMode mode);
911
+ void IterateStrongRoots(ObjectVisitor* v, VisitMode mode);
842
912
  // Iterates over all the other roots in the heap.
843
- static void IterateWeakRoots(ObjectVisitor* v, VisitMode mode);
913
+ void IterateWeakRoots(ObjectVisitor* v, VisitMode mode);
844
914
 
845
915
  enum ExpectedPageWatermarkState {
846
916
  WATERMARK_SHOULD_BE_VALID,
@@ -854,7 +924,7 @@ class Heap : public AllStatic {
854
924
  // can_preallocate_during_iteration should be set to true.
855
925
  // All pages will be marked as having invalid watermark upon
856
926
  // iteration completion.
857
- static void IterateDirtyRegions(
927
+ void IterateDirtyRegions(
858
928
  PagedSpace* space,
859
929
  DirtyRegionCallback visit_dirty_region,
860
930
  ObjectSlotCallback callback,
@@ -864,22 +934,23 @@ class Heap : public AllStatic {
864
934
  // Page::kRegionSize aligned by Page::kRegionAlignmentMask and covering
865
935
  // memory interval from start to top. For each dirty region call a
866
936
  // visit_dirty_region callback. Return updated bitvector of dirty marks.
867
- static uint32_t IterateDirtyRegions(uint32_t marks,
868
- Address start,
869
- Address end,
870
- DirtyRegionCallback visit_dirty_region,
871
- ObjectSlotCallback callback);
937
+ uint32_t IterateDirtyRegions(uint32_t marks,
938
+ Address start,
939
+ Address end,
940
+ DirtyRegionCallback visit_dirty_region,
941
+ ObjectSlotCallback callback);
872
942
 
873
943
  // Iterate pointers to from semispace of new space found in memory interval
874
944
  // from start to end.
875
945
  // Update dirty marks for page containing start address.
876
- static void IterateAndMarkPointersToFromSpace(Address start,
877
- Address end,
878
- ObjectSlotCallback callback);
946
+ void IterateAndMarkPointersToFromSpace(Address start,
947
+ Address end,
948
+ ObjectSlotCallback callback);
879
949
 
880
950
  // Iterate pointers to new space found in memory interval from start to end.
881
951
  // Return true if pointers to new space was found.
882
- static bool IteratePointersInDirtyRegion(Address start,
952
+ static bool IteratePointersInDirtyRegion(Heap* heap,
953
+ Address start,
883
954
  Address end,
884
955
  ObjectSlotCallback callback);
885
956
 
@@ -887,127 +958,127 @@ class Heap : public AllStatic {
887
958
  // Iterate pointers to new space found in memory interval from start to end.
888
959
  // This interval is considered to belong to the map space.
889
960
  // Return true if pointers to new space was found.
890
- static bool IteratePointersInDirtyMapsRegion(Address start,
961
+ static bool IteratePointersInDirtyMapsRegion(Heap* heap,
962
+ Address start,
891
963
  Address end,
892
964
  ObjectSlotCallback callback);
893
965
 
894
966
 
895
967
  // Returns whether the object resides in new space.
896
- static inline bool InNewSpace(Object* object);
897
- static inline bool InFromSpace(Object* object);
898
- static inline bool InToSpace(Object* object);
968
+ inline bool InNewSpace(Object* object);
969
+ inline bool InFromSpace(Object* object);
970
+ inline bool InToSpace(Object* object);
899
971
 
900
972
  // Checks whether an address/object in the heap (including auxiliary
901
973
  // area and unused area).
902
- static bool Contains(Address addr);
903
- static bool Contains(HeapObject* value);
974
+ bool Contains(Address addr);
975
+ bool Contains(HeapObject* value);
904
976
 
905
977
  // Checks whether an address/object in a space.
906
978
  // Currently used by tests, serialization and heap verification only.
907
- static bool InSpace(Address addr, AllocationSpace space);
908
- static bool InSpace(HeapObject* value, AllocationSpace space);
979
+ bool InSpace(Address addr, AllocationSpace space);
980
+ bool InSpace(HeapObject* value, AllocationSpace space);
909
981
 
910
982
  // Finds out which space an object should get promoted to based on its type.
911
- static inline OldSpace* TargetSpace(HeapObject* object);
912
- static inline AllocationSpace TargetSpaceId(InstanceType type);
983
+ inline OldSpace* TargetSpace(HeapObject* object);
984
+ inline AllocationSpace TargetSpaceId(InstanceType type);
913
985
 
914
986
  // Sets the stub_cache_ (only used when expanding the dictionary).
915
- static void public_set_code_stubs(NumberDictionary* value) {
987
+ void public_set_code_stubs(NumberDictionary* value) {
916
988
  roots_[kCodeStubsRootIndex] = value;
917
989
  }
918
990
 
919
991
  // Support for computing object sizes for old objects during GCs. Returns
920
992
  // a function that is guaranteed to be safe for computing object sizes in
921
993
  // the current GC phase.
922
- static HeapObjectCallback GcSafeSizeOfOldObjectFunction() {
994
+ HeapObjectCallback GcSafeSizeOfOldObjectFunction() {
923
995
  return gc_safe_size_of_old_object_;
924
996
  }
925
997
 
926
998
  // Sets the non_monomorphic_cache_ (only used when expanding the dictionary).
927
- static void public_set_non_monomorphic_cache(NumberDictionary* value) {
999
+ void public_set_non_monomorphic_cache(NumberDictionary* value) {
928
1000
  roots_[kNonMonomorphicCacheRootIndex] = value;
929
1001
  }
930
1002
 
931
- static void public_set_empty_script(Script* script) {
1003
+ void public_set_empty_script(Script* script) {
932
1004
  roots_[kEmptyScriptRootIndex] = script;
933
1005
  }
934
1006
 
935
1007
  // Update the next script id.
936
- static inline void SetLastScriptId(Object* last_script_id);
1008
+ inline void SetLastScriptId(Object* last_script_id);
937
1009
 
938
1010
  // Generated code can embed this address to get access to the roots.
939
- static Object** roots_address() { return roots_; }
1011
+ Object** roots_address() { return roots_; }
940
1012
 
941
1013
  // Get address of global contexts list for serialization support.
942
- static Object** global_contexts_list_address() {
1014
+ Object** global_contexts_list_address() {
943
1015
  return &global_contexts_list_;
944
1016
  }
945
1017
 
946
1018
  #ifdef DEBUG
947
- static void Print();
948
- static void PrintHandles();
1019
+ void Print();
1020
+ void PrintHandles();
949
1021
 
950
1022
  // Verify the heap is in its normal state before or after a GC.
951
- static void Verify();
1023
+ void Verify();
952
1024
 
953
1025
  // Report heap statistics.
954
- static void ReportHeapStatistics(const char* title);
955
- static void ReportCodeStatistics(const char* title);
1026
+ void ReportHeapStatistics(const char* title);
1027
+ void ReportCodeStatistics(const char* title);
956
1028
 
957
1029
  // Fill in bogus values in from space
958
- static void ZapFromSpace();
1030
+ void ZapFromSpace();
959
1031
  #endif
960
1032
 
961
1033
  #if defined(ENABLE_LOGGING_AND_PROFILING)
962
1034
  // Print short heap statistics.
963
- static void PrintShortHeapStatistics();
1035
+ void PrintShortHeapStatistics();
964
1036
  #endif
965
1037
 
966
1038
  // Makes a new symbol object
967
1039
  // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
968
1040
  // failed.
969
1041
  // Please note this function does not perform a garbage collection.
970
- MUST_USE_RESULT static MaybeObject* CreateSymbol(const char* str,
971
- int length,
972
- int hash);
973
- MUST_USE_RESULT static MaybeObject* CreateSymbol(String* str);
1042
+ MUST_USE_RESULT MaybeObject* CreateSymbol(
1043
+ const char* str, int length, int hash);
1044
+ MUST_USE_RESULT MaybeObject* CreateSymbol(String* str);
974
1045
 
975
1046
  // Write barrier support for address[offset] = o.
976
- static inline void RecordWrite(Address address, int offset);
1047
+ inline void RecordWrite(Address address, int offset);
977
1048
 
978
1049
  // Write barrier support for address[start : start + len[ = o.
979
- static inline void RecordWrites(Address address, int start, int len);
1050
+ inline void RecordWrites(Address address, int start, int len);
980
1051
 
981
1052
  // Given an address occupied by a live code object, return that object.
982
- static Object* FindCodeObject(Address a);
1053
+ Object* FindCodeObject(Address a);
983
1054
 
984
1055
  // Invoke Shrink on shrinkable spaces.
985
- static void Shrink();
1056
+ void Shrink();
986
1057
 
987
1058
  enum HeapState { NOT_IN_GC, SCAVENGE, MARK_COMPACT };
988
- static inline HeapState gc_state() { return gc_state_; }
1059
+ inline HeapState gc_state() { return gc_state_; }
989
1060
 
990
1061
  #ifdef DEBUG
991
- static bool IsAllocationAllowed() { return allocation_allowed_; }
992
- static inline bool allow_allocation(bool enable);
1062
+ bool IsAllocationAllowed() { return allocation_allowed_; }
1063
+ inline bool allow_allocation(bool enable);
993
1064
 
994
- static bool disallow_allocation_failure() {
1065
+ bool disallow_allocation_failure() {
995
1066
  return disallow_allocation_failure_;
996
1067
  }
997
1068
 
998
- static void TracePathToObject(Object* target);
999
- static void TracePathToGlobal();
1069
+ void TracePathToObject(Object* target);
1070
+ void TracePathToGlobal();
1000
1071
  #endif
1001
1072
 
1002
1073
  // Callback function passed to Heap::Iterate etc. Copies an object if
1003
1074
  // necessary, the object might be promoted to an old space. The caller must
1004
1075
  // ensure the precondition that the object is (a) a heap object and (b) in
1005
1076
  // the heap's from space.
1006
- static void ScavengePointer(HeapObject** p);
1077
+ static inline void ScavengePointer(HeapObject** p);
1007
1078
  static inline void ScavengeObject(HeapObject** p, HeapObject* object);
1008
1079
 
1009
1080
  // Commits from space if it is uncommitted.
1010
- static void EnsureFromSpaceIsCommitted();
1081
+ void EnsureFromSpaceIsCommitted();
1011
1082
 
1012
1083
  // Support for partial snapshots. After calling this we can allocate a
1013
1084
  // certain number of bytes using only linear allocation (with a
@@ -1015,7 +1086,7 @@ class Heap : public AllStatic {
1015
1086
  // or causing a GC. It returns true of space was reserved or false if a GC is
1016
1087
  // needed. For paged spaces the space requested must include the space wasted
1017
1088
  // at the end of each page when allocating linearly.
1018
- static void ReserveSpace(
1089
+ void ReserveSpace(
1019
1090
  int new_space_size,
1020
1091
  int pointer_space_size,
1021
1092
  int data_space_size,
@@ -1028,45 +1099,44 @@ class Heap : public AllStatic {
1028
1099
  // Support for the API.
1029
1100
  //
1030
1101
 
1031
- static bool CreateApiObjects();
1102
+ bool CreateApiObjects();
1032
1103
 
1033
1104
  // Attempt to find the number in a small cache. If we finds it, return
1034
1105
  // the string representation of the number. Otherwise return undefined.
1035
- static Object* GetNumberStringCache(Object* number);
1106
+ Object* GetNumberStringCache(Object* number);
1036
1107
 
1037
1108
  // Update the cache with a new number-string pair.
1038
- static void SetNumberStringCache(Object* number, String* str);
1109
+ void SetNumberStringCache(Object* number, String* str);
1039
1110
 
1040
1111
  // Adjusts the amount of registered external memory.
1041
1112
  // Returns the adjusted value.
1042
- static inline int AdjustAmountOfExternalAllocatedMemory(int change_in_bytes);
1113
+ inline int AdjustAmountOfExternalAllocatedMemory(int change_in_bytes);
1043
1114
 
1044
1115
  // Allocate uninitialized fixed array.
1045
- MUST_USE_RESULT static MaybeObject* AllocateRawFixedArray(int length);
1046
- MUST_USE_RESULT static MaybeObject* AllocateRawFixedArray(
1047
- int length,
1048
- PretenureFlag pretenure);
1116
+ MUST_USE_RESULT MaybeObject* AllocateRawFixedArray(int length);
1117
+ MUST_USE_RESULT MaybeObject* AllocateRawFixedArray(int length,
1118
+ PretenureFlag pretenure);
1049
1119
 
1050
1120
  // True if we have reached the allocation limit in the old generation that
1051
1121
  // should force the next GC (caused normally) to be a full one.
1052
- static bool OldGenerationPromotionLimitReached() {
1122
+ bool OldGenerationPromotionLimitReached() {
1053
1123
  return (PromotedSpaceSize() + PromotedExternalMemorySize())
1054
1124
  > old_gen_promotion_limit_;
1055
1125
  }
1056
1126
 
1057
- static intptr_t OldGenerationSpaceAvailable() {
1127
+ intptr_t OldGenerationSpaceAvailable() {
1058
1128
  return old_gen_allocation_limit_ -
1059
1129
  (PromotedSpaceSize() + PromotedExternalMemorySize());
1060
1130
  }
1061
1131
 
1062
1132
  // True if we have reached the allocation limit in the old generation that
1063
1133
  // should artificially cause a GC right now.
1064
- static bool OldGenerationAllocationLimitReached() {
1134
+ bool OldGenerationAllocationLimitReached() {
1065
1135
  return OldGenerationSpaceAvailable() < 0;
1066
1136
  }
1067
1137
 
1068
1138
  // Can be called when the embedding application is idle.
1069
- static bool IdleNotification();
1139
+ bool IdleNotification();
1070
1140
 
1071
1141
  // Declare all the root indices.
1072
1142
  enum RootListIndex {
@@ -1088,76 +1158,109 @@ class Heap : public AllStatic {
1088
1158
  kRootListLength
1089
1159
  };
1090
1160
 
1091
- MUST_USE_RESULT static MaybeObject* NumberToString(
1092
- Object* number,
1093
- bool check_number_string_cache = true);
1161
+ MUST_USE_RESULT MaybeObject* NumberToString(
1162
+ Object* number, bool check_number_string_cache = true);
1094
1163
 
1095
- static Map* MapForExternalArrayType(ExternalArrayType array_type);
1096
- static RootListIndex RootIndexForExternalArrayType(
1164
+ Map* MapForExternalArrayType(ExternalArrayType array_type);
1165
+ RootListIndex RootIndexForExternalArrayType(
1097
1166
  ExternalArrayType array_type);
1098
1167
 
1099
- static void RecordStats(HeapStats* stats, bool take_snapshot = false);
1168
+ void RecordStats(HeapStats* stats, bool take_snapshot = false);
1100
1169
 
1101
1170
  // Copy block of memory from src to dst. Size of block should be aligned
1102
1171
  // by pointer size.
1103
1172
  static inline void CopyBlock(Address dst, Address src, int byte_size);
1104
1173
 
1105
- static inline void CopyBlockToOldSpaceAndUpdateRegionMarks(Address dst,
1106
- Address src,
1107
- int byte_size);
1174
+ inline void CopyBlockToOldSpaceAndUpdateRegionMarks(Address dst,
1175
+ Address src,
1176
+ int byte_size);
1108
1177
 
1109
1178
  // Optimized version of memmove for blocks with pointer size aligned sizes and
1110
1179
  // pointer size aligned addresses.
1111
1180
  static inline void MoveBlock(Address dst, Address src, int byte_size);
1112
1181
 
1113
- static inline void MoveBlockToOldSpaceAndUpdateRegionMarks(Address dst,
1114
- Address src,
1115
- int byte_size);
1182
+ inline void MoveBlockToOldSpaceAndUpdateRegionMarks(Address dst,
1183
+ Address src,
1184
+ int byte_size);
1116
1185
 
1117
1186
  // Check new space expansion criteria and expand semispaces if it was hit.
1118
- static void CheckNewSpaceExpansionCriteria();
1187
+ void CheckNewSpaceExpansionCriteria();
1119
1188
 
1120
- static inline void IncrementYoungSurvivorsCounter(int survived) {
1189
+ inline void IncrementYoungSurvivorsCounter(int survived) {
1121
1190
  young_survivors_after_last_gc_ = survived;
1122
1191
  survived_since_last_expansion_ += survived;
1123
1192
  }
1124
1193
 
1125
- static void UpdateNewSpaceReferencesInExternalStringTable(
1194
+ void UpdateNewSpaceReferencesInExternalStringTable(
1126
1195
  ExternalStringTableUpdaterCallback updater_func);
1127
1196
 
1128
- static void ProcessWeakReferences(WeakObjectRetainer* retainer);
1197
+ void ProcessWeakReferences(WeakObjectRetainer* retainer);
1129
1198
 
1130
1199
  // Helper function that governs the promotion policy from new space to
1131
1200
  // old. If the object's old address lies below the new space's age
1132
1201
  // mark or if we've already filled the bottom 1/16th of the to space,
1133
1202
  // we try to promote this object.
1134
- static inline bool ShouldBePromoted(Address old_address, int object_size);
1203
+ inline bool ShouldBePromoted(Address old_address, int object_size);
1135
1204
 
1136
- static int MaxObjectSizeInNewSpace() { return kMaxObjectSizeInNewSpace; }
1205
+ int MaxObjectSizeInNewSpace() { return kMaxObjectSizeInNewSpace; }
1137
1206
 
1138
- static void ClearJSFunctionResultCaches();
1207
+ void ClearJSFunctionResultCaches();
1139
1208
 
1140
- static void ClearNormalizedMapCaches();
1209
+ void ClearNormalizedMapCaches();
1210
+
1211
+ GCTracer* tracer() { return tracer_; }
1212
+
1213
+ // Returns maximum GC pause.
1214
+ int get_max_gc_pause() { return max_gc_pause_; }
1141
1215
 
1142
- static GCTracer* tracer() { return tracer_; }
1216
+ // Returns maximum size of objects alive after GC.
1217
+ intptr_t get_max_alive_after_gc() { return max_alive_after_gc_; }
1218
+
1219
+ // Returns minimal interval between two subsequent collections.
1220
+ int get_min_in_mutator() { return min_in_mutator_; }
1221
+
1222
+ MarkCompactCollector* mark_compact_collector() {
1223
+ return &mark_compact_collector_;
1224
+ }
1225
+
1226
+ ExternalStringTable* external_string_table() {
1227
+ return &external_string_table_;
1228
+ }
1229
+
1230
+ inline Isolate* isolate();
1231
+ bool is_safe_to_read_maps() { return is_safe_to_read_maps_; }
1232
+
1233
+ void CallGlobalGCPrologueCallback() {
1234
+ if (global_gc_prologue_callback_ != NULL) global_gc_prologue_callback_();
1235
+ }
1236
+
1237
+ void CallGlobalGCEpilogueCallback() {
1238
+ if (global_gc_epilogue_callback_ != NULL) global_gc_epilogue_callback_();
1239
+ }
1143
1240
 
1144
1241
  private:
1145
- static int reserved_semispace_size_;
1146
- static int max_semispace_size_;
1147
- static int initial_semispace_size_;
1148
- static intptr_t max_old_generation_size_;
1149
- static intptr_t max_executable_size_;
1150
- static intptr_t code_range_size_;
1242
+ Heap();
1243
+
1244
+ // This can be calculated directly from a pointer to the heap; however, it is
1245
+ // more expedient to get at the isolate directly from within Heap methods.
1246
+ Isolate* isolate_;
1247
+
1248
+ int reserved_semispace_size_;
1249
+ int max_semispace_size_;
1250
+ int initial_semispace_size_;
1251
+ intptr_t max_old_generation_size_;
1252
+ intptr_t max_executable_size_;
1253
+ intptr_t code_range_size_;
1151
1254
 
1152
1255
  // For keeping track of how much data has survived
1153
1256
  // scavenge since last new space expansion.
1154
- static int survived_since_last_expansion_;
1257
+ int survived_since_last_expansion_;
1155
1258
 
1156
- static int always_allocate_scope_depth_;
1157
- static int linear_allocation_scope_depth_;
1259
+ int always_allocate_scope_depth_;
1260
+ int linear_allocation_scope_depth_;
1158
1261
 
1159
1262
  // For keeping track of context disposals.
1160
- static int contexts_disposed_;
1263
+ int contexts_disposed_;
1161
1264
 
1162
1265
  #if defined(V8_TARGET_ARCH_X64)
1163
1266
  static const int kMaxObjectSizeInNewSpace = 1024*KB;
@@ -1165,76 +1268,78 @@ class Heap : public AllStatic {
1165
1268
  static const int kMaxObjectSizeInNewSpace = 512*KB;
1166
1269
  #endif
1167
1270
 
1168
- static NewSpace new_space_;
1169
- static OldSpace* old_pointer_space_;
1170
- static OldSpace* old_data_space_;
1171
- static OldSpace* code_space_;
1172
- static MapSpace* map_space_;
1173
- static CellSpace* cell_space_;
1174
- static LargeObjectSpace* lo_space_;
1175
- static HeapState gc_state_;
1271
+ NewSpace new_space_;
1272
+ OldSpace* old_pointer_space_;
1273
+ OldSpace* old_data_space_;
1274
+ OldSpace* code_space_;
1275
+ MapSpace* map_space_;
1276
+ CellSpace* cell_space_;
1277
+ LargeObjectSpace* lo_space_;
1278
+ HeapState gc_state_;
1176
1279
 
1177
1280
  // Returns the size of object residing in non new spaces.
1178
- static intptr_t PromotedSpaceSize();
1281
+ intptr_t PromotedSpaceSize();
1179
1282
 
1180
1283
  // Returns the amount of external memory registered since last global gc.
1181
- static int PromotedExternalMemorySize();
1284
+ int PromotedExternalMemorySize();
1182
1285
 
1183
- static int mc_count_; // how many mark-compact collections happened
1184
- static int ms_count_; // how many mark-sweep collections happened
1185
- static unsigned int gc_count_; // how many gc happened
1286
+ int mc_count_; // how many mark-compact collections happened
1287
+ int ms_count_; // how many mark-sweep collections happened
1288
+ unsigned int gc_count_; // how many gc happened
1186
1289
 
1187
1290
  // Total length of the strings we failed to flatten since the last GC.
1188
- static int unflattened_strings_length_;
1291
+ int unflattened_strings_length_;
1189
1292
 
1190
1293
  #define ROOT_ACCESSOR(type, name, camel_name) \
1191
- static inline void set_##name(type* value) { \
1294
+ inline void set_##name(type* value) { \
1192
1295
  roots_[k##camel_name##RootIndex] = value; \
1193
1296
  }
1194
1297
  ROOT_LIST(ROOT_ACCESSOR)
1195
1298
  #undef ROOT_ACCESSOR
1196
1299
 
1197
1300
  #ifdef DEBUG
1198
- static bool allocation_allowed_;
1301
+ bool allocation_allowed_;
1199
1302
 
1200
1303
  // If the --gc-interval flag is set to a positive value, this
1201
1304
  // variable holds the value indicating the number of allocations
1202
1305
  // remain until the next failure and garbage collection.
1203
- static int allocation_timeout_;
1306
+ int allocation_timeout_;
1204
1307
 
1205
1308
  // Do we expect to be able to handle allocation failure at this
1206
1309
  // time?
1207
- static bool disallow_allocation_failure_;
1310
+ bool disallow_allocation_failure_;
1311
+
1312
+ HeapDebugUtils* debug_utils_;
1208
1313
  #endif // DEBUG
1209
1314
 
1210
1315
  // Limit that triggers a global GC on the next (normally caused) GC. This
1211
1316
  // is checked when we have already decided to do a GC to help determine
1212
1317
  // which collector to invoke.
1213
- static intptr_t old_gen_promotion_limit_;
1318
+ intptr_t old_gen_promotion_limit_;
1214
1319
 
1215
1320
  // Limit that triggers a global GC as soon as is reasonable. This is
1216
1321
  // checked before expanding a paged space in the old generation and on
1217
1322
  // every allocation in large object space.
1218
- static intptr_t old_gen_allocation_limit_;
1323
+ intptr_t old_gen_allocation_limit_;
1219
1324
 
1220
1325
  // Limit on the amount of externally allocated memory allowed
1221
1326
  // between global GCs. If reached a global GC is forced.
1222
- static intptr_t external_allocation_limit_;
1327
+ intptr_t external_allocation_limit_;
1223
1328
 
1224
1329
  // The amount of external memory registered through the API kept alive
1225
1330
  // by global handles
1226
- static int amount_of_external_allocated_memory_;
1331
+ int amount_of_external_allocated_memory_;
1227
1332
 
1228
1333
  // Caches the amount of external memory registered at the last global gc.
1229
- static int amount_of_external_allocated_memory_at_last_global_gc_;
1334
+ int amount_of_external_allocated_memory_at_last_global_gc_;
1230
1335
 
1231
1336
  // Indicates that an allocation has failed in the old generation since the
1232
1337
  // last GC.
1233
- static int old_gen_exhausted_;
1338
+ int old_gen_exhausted_;
1234
1339
 
1235
- static Object* roots_[kRootListLength];
1340
+ Object* roots_[kRootListLength];
1236
1341
 
1237
- static Object* global_contexts_list_;
1342
+ Object* global_contexts_list_;
1238
1343
 
1239
1344
  struct StringTypeTable {
1240
1345
  InstanceType type;
@@ -1259,7 +1364,7 @@ class Heap : public AllStatic {
1259
1364
 
1260
1365
  // The special hidden symbol which is an empty string, but does not match
1261
1366
  // any string when looked up in properties.
1262
- static String* hidden_symbol_;
1367
+ String* hidden_symbol_;
1263
1368
 
1264
1369
  // GC callback function, called before and after mark-compact GC.
1265
1370
  // Allocations in the callback function are disallowed.
@@ -1273,7 +1378,7 @@ class Heap : public AllStatic {
1273
1378
  GCPrologueCallback callback;
1274
1379
  GCType gc_type;
1275
1380
  };
1276
- static List<GCPrologueCallbackPair> gc_prologue_callbacks_;
1381
+ List<GCPrologueCallbackPair> gc_prologue_callbacks_;
1277
1382
 
1278
1383
  struct GCEpilogueCallbackPair {
1279
1384
  GCEpilogueCallbackPair(GCEpilogueCallback callback, GCType gc_type)
@@ -1285,91 +1390,93 @@ class Heap : public AllStatic {
1285
1390
  GCEpilogueCallback callback;
1286
1391
  GCType gc_type;
1287
1392
  };
1288
- static List<GCEpilogueCallbackPair> gc_epilogue_callbacks_;
1393
+ List<GCEpilogueCallbackPair> gc_epilogue_callbacks_;
1289
1394
 
1290
- static GCCallback global_gc_prologue_callback_;
1291
- static GCCallback global_gc_epilogue_callback_;
1395
+ GCCallback global_gc_prologue_callback_;
1396
+ GCCallback global_gc_epilogue_callback_;
1292
1397
 
1293
1398
  // Support for computing object sizes during GC.
1294
- static HeapObjectCallback gc_safe_size_of_old_object_;
1399
+ HeapObjectCallback gc_safe_size_of_old_object_;
1295
1400
  static int GcSafeSizeOfOldObject(HeapObject* object);
1296
1401
  static int GcSafeSizeOfOldObjectWithEncodedMap(HeapObject* object);
1297
1402
 
1298
1403
  // Update the GC state. Called from the mark-compact collector.
1299
- static void MarkMapPointersAsEncoded(bool encoded) {
1404
+ void MarkMapPointersAsEncoded(bool encoded) {
1300
1405
  gc_safe_size_of_old_object_ = encoded
1301
1406
  ? &GcSafeSizeOfOldObjectWithEncodedMap
1302
1407
  : &GcSafeSizeOfOldObject;
1303
1408
  }
1304
1409
 
1305
1410
  // Checks whether a global GC is necessary
1306
- static GarbageCollector SelectGarbageCollector(AllocationSpace space);
1411
+ GarbageCollector SelectGarbageCollector(AllocationSpace space);
1307
1412
 
1308
1413
  // Performs garbage collection
1309
1414
  // Returns whether there is a chance another major GC could
1310
1415
  // collect more garbage.
1311
- static bool PerformGarbageCollection(GarbageCollector collector,
1312
- GCTracer* tracer);
1416
+ bool PerformGarbageCollection(GarbageCollector collector,
1417
+ GCTracer* tracer);
1418
+
1419
+ static const intptr_t kMinimumPromotionLimit = 2 * MB;
1420
+ static const intptr_t kMinimumAllocationLimit = 8 * MB;
1421
+
1422
+ inline void UpdateOldSpaceLimits();
1313
1423
 
1314
1424
  // Allocate an uninitialized object in map space. The behavior is identical
1315
1425
  // to Heap::AllocateRaw(size_in_bytes, MAP_SPACE), except that (a) it doesn't
1316
1426
  // have to test the allocation space argument and (b) can reduce code size
1317
1427
  // (since both AllocateRaw and AllocateRawMap are inlined).
1318
- MUST_USE_RESULT static inline MaybeObject* AllocateRawMap();
1428
+ MUST_USE_RESULT inline MaybeObject* AllocateRawMap();
1319
1429
 
1320
1430
  // Allocate an uninitialized object in the global property cell space.
1321
- MUST_USE_RESULT static inline MaybeObject* AllocateRawCell();
1431
+ MUST_USE_RESULT inline MaybeObject* AllocateRawCell();
1322
1432
 
1323
1433
  // Initializes a JSObject based on its map.
1324
- static void InitializeJSObjectFromMap(JSObject* obj,
1325
- FixedArray* properties,
1326
- Map* map);
1434
+ void InitializeJSObjectFromMap(JSObject* obj,
1435
+ FixedArray* properties,
1436
+ Map* map);
1327
1437
 
1328
- static bool CreateInitialMaps();
1329
- static bool CreateInitialObjects();
1438
+ bool CreateInitialMaps();
1439
+ bool CreateInitialObjects();
1330
1440
 
1331
1441
  // These five Create*EntryStub functions are here and forced to not be inlined
1332
1442
  // because of a gcc-4.4 bug that assigns wrong vtable entries.
1333
- NO_INLINE(static void CreateCEntryStub());
1334
- NO_INLINE(static void CreateJSEntryStub());
1335
- NO_INLINE(static void CreateJSConstructEntryStub());
1336
- NO_INLINE(static void CreateRegExpCEntryStub());
1337
- NO_INLINE(static void CreateDirectCEntryStub());
1443
+ NO_INLINE(void CreateJSEntryStub());
1444
+ NO_INLINE(void CreateJSConstructEntryStub());
1338
1445
 
1339
- static void CreateFixedStubs();
1446
+ void CreateFixedStubs();
1340
1447
 
1341
- MUST_USE_RESULT static MaybeObject* CreateOddball(const char* to_string,
1342
- Object* to_number);
1448
+ MaybeObject* CreateOddball(const char* to_string,
1449
+ Object* to_number,
1450
+ byte kind);
1343
1451
 
1344
1452
  // Allocate empty fixed array.
1345
- MUST_USE_RESULT static MaybeObject* AllocateEmptyFixedArray();
1453
+ MUST_USE_RESULT MaybeObject* AllocateEmptyFixedArray();
1454
+
1455
+ void SwitchScavengingVisitorsTableIfProfilingWasEnabled();
1346
1456
 
1347
1457
  // Performs a minor collection in new generation.
1348
- static void Scavenge();
1458
+ void Scavenge();
1349
1459
 
1350
1460
  static String* UpdateNewSpaceReferenceInExternalStringTableEntry(
1461
+ Heap* heap,
1351
1462
  Object** pointer);
1352
1463
 
1353
- static Address DoScavenge(ObjectVisitor* scavenge_visitor,
1354
- Address new_space_front);
1464
+ Address DoScavenge(ObjectVisitor* scavenge_visitor, Address new_space_front);
1355
1465
 
1356
1466
  // Performs a major collection in the whole heap.
1357
- static void MarkCompact(GCTracer* tracer);
1467
+ void MarkCompact(GCTracer* tracer);
1358
1468
 
1359
1469
  // Code to be run before and after mark-compact.
1360
- static void MarkCompactPrologue(bool is_compacting);
1470
+ void MarkCompactPrologue(bool is_compacting);
1361
1471
 
1362
1472
  // Completely clear the Instanceof cache (to stop it keeping objects alive
1363
1473
  // around a GC).
1364
- static void CompletelyClearInstanceofCache() {
1365
- set_instanceof_cache_map(the_hole_value());
1366
- set_instanceof_cache_function(the_hole_value());
1367
- }
1474
+ inline void CompletelyClearInstanceofCache();
1368
1475
 
1369
1476
  #if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING)
1370
1477
  // Record statistics before and after garbage collection.
1371
- static void ReportStatisticsBeforeGC();
1372
- static void ReportStatisticsAfterGC();
1478
+ void ReportStatisticsBeforeGC();
1479
+ void ReportStatisticsAfterGC();
1373
1480
  #endif
1374
1481
 
1375
1482
  // Slow part of scavenge object.
@@ -1381,39 +1488,39 @@ class Heap : public AllStatic {
1381
1488
  // other parts of the VM could use it. Specifically, a function that creates
1382
1489
  // instances of type JS_FUNCTION_TYPE benefit from the use of this function.
1383
1490
  // Please note this does not perform a garbage collection.
1384
- MUST_USE_RESULT static inline MaybeObject* InitializeFunction(
1491
+ MUST_USE_RESULT inline MaybeObject* InitializeFunction(
1385
1492
  JSFunction* function,
1386
1493
  SharedFunctionInfo* shared,
1387
1494
  Object* prototype);
1388
1495
 
1389
- static GCTracer* tracer_;
1496
+ GCTracer* tracer_;
1390
1497
 
1391
1498
 
1392
1499
  // Initializes the number to string cache based on the max semispace size.
1393
- MUST_USE_RESULT static MaybeObject* InitializeNumberStringCache();
1500
+ MUST_USE_RESULT MaybeObject* InitializeNumberStringCache();
1394
1501
  // Flush the number to string cache.
1395
- static void FlushNumberStringCache();
1502
+ void FlushNumberStringCache();
1396
1503
 
1397
- static void UpdateSurvivalRateTrend(int start_new_space_size);
1504
+ void UpdateSurvivalRateTrend(int start_new_space_size);
1398
1505
 
1399
1506
  enum SurvivalRateTrend { INCREASING, STABLE, DECREASING, FLUCTUATING };
1400
1507
 
1401
1508
  static const int kYoungSurvivalRateThreshold = 90;
1402
1509
  static const int kYoungSurvivalRateAllowedDeviation = 15;
1403
1510
 
1404
- static int young_survivors_after_last_gc_;
1405
- static int high_survival_rate_period_length_;
1406
- static double survival_rate_;
1407
- static SurvivalRateTrend previous_survival_rate_trend_;
1408
- static SurvivalRateTrend survival_rate_trend_;
1511
+ int young_survivors_after_last_gc_;
1512
+ int high_survival_rate_period_length_;
1513
+ double survival_rate_;
1514
+ SurvivalRateTrend previous_survival_rate_trend_;
1515
+ SurvivalRateTrend survival_rate_trend_;
1409
1516
 
1410
- static void set_survival_rate_trend(SurvivalRateTrend survival_rate_trend) {
1517
+ void set_survival_rate_trend(SurvivalRateTrend survival_rate_trend) {
1411
1518
  ASSERT(survival_rate_trend != FLUCTUATING);
1412
1519
  previous_survival_rate_trend_ = survival_rate_trend_;
1413
1520
  survival_rate_trend_ = survival_rate_trend;
1414
1521
  }
1415
1522
 
1416
- static SurvivalRateTrend survival_rate_trend() {
1523
+ SurvivalRateTrend survival_rate_trend() {
1417
1524
  if (survival_rate_trend_ == STABLE) {
1418
1525
  return STABLE;
1419
1526
  } else if (previous_survival_rate_trend_ == STABLE) {
@@ -1425,7 +1532,7 @@ class Heap : public AllStatic {
1425
1532
  }
1426
1533
  }
1427
1534
 
1428
- static bool IsStableOrIncreasingSurvivalTrend() {
1535
+ bool IsStableOrIncreasingSurvivalTrend() {
1429
1536
  switch (survival_rate_trend()) {
1430
1537
  case STABLE:
1431
1538
  case INCREASING:
@@ -1435,22 +1542,64 @@ class Heap : public AllStatic {
1435
1542
  }
1436
1543
  }
1437
1544
 
1438
- static bool IsIncreasingSurvivalTrend() {
1545
+ bool IsIncreasingSurvivalTrend() {
1439
1546
  return survival_rate_trend() == INCREASING;
1440
1547
  }
1441
1548
 
1442
- static bool IsHighSurvivalRate() {
1549
+ bool IsHighSurvivalRate() {
1443
1550
  return high_survival_rate_period_length_ > 0;
1444
1551
  }
1445
1552
 
1446
1553
  static const int kInitialSymbolTableSize = 2048;
1447
1554
  static const int kInitialEvalCacheSize = 64;
1448
1555
 
1556
+ // Maximum GC pause.
1557
+ int max_gc_pause_;
1558
+
1559
+ // Maximum size of objects alive after GC.
1560
+ intptr_t max_alive_after_gc_;
1561
+
1562
+ // Minimal interval between two subsequent collections.
1563
+ int min_in_mutator_;
1564
+
1565
+ // Size of objects alive after last GC.
1566
+ intptr_t alive_after_last_gc_;
1567
+
1568
+ double last_gc_end_timestamp_;
1569
+
1570
+ MarkCompactCollector mark_compact_collector_;
1571
+
1572
+ // This field contains the meaning of the WATERMARK_INVALIDATED flag.
1573
+ // Instead of clearing this flag from all pages we just flip
1574
+ // its meaning at the beginning of a scavenge.
1575
+ intptr_t page_watermark_invalidated_mark_;
1576
+
1577
+ int number_idle_notifications_;
1578
+ unsigned int last_idle_notification_gc_count_;
1579
+ bool last_idle_notification_gc_count_init_;
1580
+
1581
+ // Shared state read by the scavenge collector and set by ScavengeObject.
1582
+ PromotionQueue promotion_queue_;
1583
+
1584
+ // Flag is set when the heap has been configured. The heap can be repeatedly
1585
+ // configured through the API until it is setup.
1586
+ bool configured_;
1587
+
1588
+ ExternalStringTable external_string_table_;
1589
+
1590
+ bool is_safe_to_read_maps_;
1591
+
1449
1592
  friend class Factory;
1593
+ friend class GCTracer;
1450
1594
  friend class DisallowAllocationFailure;
1451
1595
  friend class AlwaysAllocateScope;
1452
1596
  friend class LinearAllocationScope;
1597
+ friend class Page;
1598
+ friend class Isolate;
1453
1599
  friend class MarkCompactCollector;
1600
+ friend class MapCompact;
1601
+
1602
+ DISALLOW_COPY_AND_ASSIGN(Heap);
1454
1603
  };
1455
1604
 
1456
1605
 
@@ -1494,13 +1643,13 @@ class AlwaysAllocateScope {
1494
1643
  // non-handle code to call handle code. The code still works but
1495
1644
  // performance will degrade, so we want to catch this situation
1496
1645
  // in debug mode.
1497
- ASSERT(Heap::always_allocate_scope_depth_ == 0);
1498
- Heap::always_allocate_scope_depth_++;
1646
+ ASSERT(HEAP->always_allocate_scope_depth_ == 0);
1647
+ HEAP->always_allocate_scope_depth_++;
1499
1648
  }
1500
1649
 
1501
1650
  ~AlwaysAllocateScope() {
1502
- Heap::always_allocate_scope_depth_--;
1503
- ASSERT(Heap::always_allocate_scope_depth_ == 0);
1651
+ HEAP->always_allocate_scope_depth_--;
1652
+ ASSERT(HEAP->always_allocate_scope_depth_ == 0);
1504
1653
  }
1505
1654
  };
1506
1655
 
@@ -1508,12 +1657,12 @@ class AlwaysAllocateScope {
1508
1657
  class LinearAllocationScope {
1509
1658
  public:
1510
1659
  LinearAllocationScope() {
1511
- Heap::linear_allocation_scope_depth_++;
1660
+ HEAP->linear_allocation_scope_depth_++;
1512
1661
  }
1513
1662
 
1514
1663
  ~LinearAllocationScope() {
1515
- Heap::linear_allocation_scope_depth_--;
1516
- ASSERT(Heap::linear_allocation_scope_depth_ >= 0);
1664
+ HEAP->linear_allocation_scope_depth_--;
1665
+ ASSERT(HEAP->linear_allocation_scope_depth_ >= 0);
1517
1666
  }
1518
1667
  };
1519
1668
 
@@ -1530,7 +1679,7 @@ class VerifyPointersVisitor: public ObjectVisitor {
1530
1679
  for (Object** current = start; current < end; current++) {
1531
1680
  if ((*current)->IsHeapObject()) {
1532
1681
  HeapObject* object = HeapObject::cast(*current);
1533
- ASSERT(Heap::Contains(object));
1682
+ ASSERT(HEAP->Contains(object));
1534
1683
  ASSERT(object->map()->IsMap());
1535
1684
  }
1536
1685
  }
@@ -1548,10 +1697,10 @@ class VerifyPointersAndDirtyRegionsVisitor: public ObjectVisitor {
1548
1697
  for (Object** current = start; current < end; current++) {
1549
1698
  if ((*current)->IsHeapObject()) {
1550
1699
  HeapObject* object = HeapObject::cast(*current);
1551
- ASSERT(Heap::Contains(object));
1700
+ ASSERT(HEAP->Contains(object));
1552
1701
  ASSERT(object->map()->IsMap());
1553
- if (Heap::InNewSpace(object)) {
1554
- ASSERT(Heap::InToSpace(object));
1702
+ if (HEAP->InNewSpace(object)) {
1703
+ ASSERT(HEAP->InToSpace(object));
1555
1704
  Address addr = reinterpret_cast<Address>(current);
1556
1705
  ASSERT(Page::FromAddress(addr)->IsRegionDirty(addr));
1557
1706
  }
@@ -1665,28 +1814,37 @@ class HeapIterator BASE_EMBEDDED {
1665
1814
  class KeyedLookupCache {
1666
1815
  public:
1667
1816
  // Lookup field offset for (map, name). If absent, -1 is returned.
1668
- static int Lookup(Map* map, String* name);
1817
+ int Lookup(Map* map, String* name);
1669
1818
 
1670
1819
  // Update an element in the cache.
1671
- static void Update(Map* map, String* name, int field_offset);
1820
+ void Update(Map* map, String* name, int field_offset);
1672
1821
 
1673
1822
  // Clear the cache.
1674
- static void Clear();
1823
+ void Clear();
1675
1824
 
1676
1825
  static const int kLength = 64;
1677
1826
  static const int kCapacityMask = kLength - 1;
1678
1827
  static const int kMapHashShift = 2;
1828
+ static const int kNotFound = -1;
1679
1829
 
1680
1830
  private:
1831
+ KeyedLookupCache() {
1832
+ for (int i = 0; i < kLength; ++i) {
1833
+ keys_[i].map = NULL;
1834
+ keys_[i].name = NULL;
1835
+ field_offsets_[i] = kNotFound;
1836
+ }
1837
+ }
1838
+
1681
1839
  static inline int Hash(Map* map, String* name);
1682
1840
 
1683
1841
  // Get the address of the keys and field_offsets arrays. Used in
1684
1842
  // generated code to perform cache lookups.
1685
- static Address keys_address() {
1843
+ Address keys_address() {
1686
1844
  return reinterpret_cast<Address>(&keys_);
1687
1845
  }
1688
1846
 
1689
- static Address field_offsets_address() {
1847
+ Address field_offsets_address() {
1690
1848
  return reinterpret_cast<Address>(&field_offsets_);
1691
1849
  }
1692
1850
 
@@ -1694,10 +1852,13 @@ class KeyedLookupCache {
1694
1852
  Map* map;
1695
1853
  String* name;
1696
1854
  };
1697
- static Key keys_[kLength];
1698
- static int field_offsets_[kLength];
1855
+
1856
+ Key keys_[kLength];
1857
+ int field_offsets_[kLength];
1699
1858
 
1700
1859
  friend class ExternalReference;
1860
+ friend class Isolate;
1861
+ DISALLOW_COPY_AND_ASSIGN(KeyedLookupCache);
1701
1862
  };
1702
1863
 
1703
1864
 
@@ -1709,7 +1870,7 @@ class DescriptorLookupCache {
1709
1870
  public:
1710
1871
  // Lookup descriptor index for (map, name).
1711
1872
  // If absent, kAbsent is returned.
1712
- static int Lookup(DescriptorArray* array, String* name) {
1873
+ int Lookup(DescriptorArray* array, String* name) {
1713
1874
  if (!StringShape(name).IsSymbol()) return kAbsent;
1714
1875
  int index = Hash(array, name);
1715
1876
  Key& key = keys_[index];
@@ -1718,7 +1879,7 @@ class DescriptorLookupCache {
1718
1879
  }
1719
1880
 
1720
1881
  // Update an element in the cache.
1721
- static void Update(DescriptorArray* array, String* name, int result) {
1882
+ void Update(DescriptorArray* array, String* name, int result) {
1722
1883
  ASSERT(result != kAbsent);
1723
1884
  if (StringShape(name).IsSymbol()) {
1724
1885
  int index = Hash(array, name);
@@ -1730,10 +1891,18 @@ class DescriptorLookupCache {
1730
1891
  }
1731
1892
 
1732
1893
  // Clear the cache.
1733
- static void Clear();
1894
+ void Clear();
1734
1895
 
1735
1896
  static const int kAbsent = -2;
1736
1897
  private:
1898
+ DescriptorLookupCache() {
1899
+ for (int i = 0; i < kLength; ++i) {
1900
+ keys_[i].array = NULL;
1901
+ keys_[i].name = NULL;
1902
+ results_[i] = kAbsent;
1903
+ }
1904
+ }
1905
+
1737
1906
  static int Hash(DescriptorArray* array, String* name) {
1738
1907
  // Uses only lower 32 bits if pointers are larger.
1739
1908
  uint32_t array_hash =
@@ -1749,55 +1918,11 @@ class DescriptorLookupCache {
1749
1918
  String* name;
1750
1919
  };
1751
1920
 
1752
- static Key keys_[kLength];
1753
- static int results_[kLength];
1754
- };
1755
-
1756
-
1757
- // ----------------------------------------------------------------------------
1758
- // Marking stack for tracing live objects.
1759
-
1760
- class MarkingStack {
1761
- public:
1762
- void Initialize(Address low, Address high) {
1763
- top_ = low_ = reinterpret_cast<HeapObject**>(low);
1764
- high_ = reinterpret_cast<HeapObject**>(high);
1765
- overflowed_ = false;
1766
- }
1767
-
1768
- bool is_full() { return top_ >= high_; }
1769
-
1770
- bool is_empty() { return top_ <= low_; }
1921
+ Key keys_[kLength];
1922
+ int results_[kLength];
1771
1923
 
1772
- bool overflowed() { return overflowed_; }
1773
-
1774
- void clear_overflowed() { overflowed_ = false; }
1775
-
1776
- // Push the (marked) object on the marking stack if there is room,
1777
- // otherwise mark the object as overflowed and wait for a rescan of the
1778
- // heap.
1779
- void Push(HeapObject* object) {
1780
- CHECK(object->IsHeapObject());
1781
- if (is_full()) {
1782
- object->SetOverflow();
1783
- overflowed_ = true;
1784
- } else {
1785
- *(top_++) = object;
1786
- }
1787
- }
1788
-
1789
- HeapObject* Pop() {
1790
- ASSERT(!is_empty());
1791
- HeapObject* object = *(--top_);
1792
- CHECK(object->IsHeapObject());
1793
- return object;
1794
- }
1795
-
1796
- private:
1797
- HeapObject** low_;
1798
- HeapObject** top_;
1799
- HeapObject** high_;
1800
- bool overflowed_;
1924
+ friend class Isolate;
1925
+ DISALLOW_COPY_AND_ASSIGN(DescriptorLookupCache);
1801
1926
  };
1802
1927
 
1803
1928
 
@@ -1814,11 +1939,11 @@ class MarkingStack {
1814
1939
  class DisallowAllocationFailure {
1815
1940
  public:
1816
1941
  DisallowAllocationFailure() {
1817
- old_state_ = Heap::disallow_allocation_failure_;
1818
- Heap::disallow_allocation_failure_ = true;
1942
+ old_state_ = HEAP->disallow_allocation_failure_;
1943
+ HEAP->disallow_allocation_failure_ = true;
1819
1944
  }
1820
1945
  ~DisallowAllocationFailure() {
1821
- Heap::disallow_allocation_failure_ = old_state_;
1946
+ HEAP->disallow_allocation_failure_ = old_state_;
1822
1947
  }
1823
1948
  private:
1824
1949
  bool old_state_;
@@ -1827,11 +1952,11 @@ class DisallowAllocationFailure {
1827
1952
  class AssertNoAllocation {
1828
1953
  public:
1829
1954
  AssertNoAllocation() {
1830
- old_state_ = Heap::allow_allocation(false);
1955
+ old_state_ = HEAP->allow_allocation(false);
1831
1956
  }
1832
1957
 
1833
1958
  ~AssertNoAllocation() {
1834
- Heap::allow_allocation(old_state_);
1959
+ HEAP->allow_allocation(old_state_);
1835
1960
  }
1836
1961
 
1837
1962
  private:
@@ -1841,11 +1966,11 @@ class AssertNoAllocation {
1841
1966
  class DisableAssertNoAllocation {
1842
1967
  public:
1843
1968
  DisableAssertNoAllocation() {
1844
- old_state_ = Heap::allow_allocation(true);
1969
+ old_state_ = HEAP->allow_allocation(true);
1845
1970
  }
1846
1971
 
1847
1972
  ~DisableAssertNoAllocation() {
1848
- Heap::allow_allocation(old_state_);
1973
+ HEAP->allow_allocation(old_state_);
1849
1974
  }
1850
1975
 
1851
1976
  private:
@@ -1902,7 +2027,7 @@ class GCTracer BASE_EMBEDDED {
1902
2027
  double start_time_;
1903
2028
  };
1904
2029
 
1905
- GCTracer();
2030
+ explicit GCTracer(Heap* heap);
1906
2031
  ~GCTracer();
1907
2032
 
1908
2033
  // Sets the collector.
@@ -1928,22 +2053,13 @@ class GCTracer BASE_EMBEDDED {
1928
2053
  promoted_objects_size_ += object_size;
1929
2054
  }
1930
2055
 
1931
- // Returns maximum GC pause.
1932
- static int get_max_gc_pause() { return max_gc_pause_; }
1933
-
1934
- // Returns maximum size of objects alive after GC.
1935
- static intptr_t get_max_alive_after_gc() { return max_alive_after_gc_; }
1936
-
1937
- // Returns minimal interval between two subsequent collections.
1938
- static int get_min_in_mutator() { return min_in_mutator_; }
1939
-
1940
2056
  private:
1941
2057
  // Returns a string matching the collector.
1942
2058
  const char* CollectorString();
1943
2059
 
1944
2060
  // Returns size of object in heap (in MB).
1945
2061
  double SizeOfHeapObjects() {
1946
- return (static_cast<double>(Heap::SizeOfObjects())) / MB;
2062
+ return (static_cast<double>(HEAP->SizeOfObjects())) / MB;
1947
2063
  }
1948
2064
 
1949
2065
  double start_time_; // Timestamp set in the constructor.
@@ -1992,19 +2108,7 @@ class GCTracer BASE_EMBEDDED {
1992
2108
  // Size of objects promoted during the current collection.
1993
2109
  intptr_t promoted_objects_size_;
1994
2110
 
1995
- // Maximum GC pause.
1996
- static int max_gc_pause_;
1997
-
1998
- // Maximum size of objects alive after GC.
1999
- static intptr_t max_alive_after_gc_;
2000
-
2001
- // Minimal interval between two subsequent collections.
2002
- static int min_in_mutator_;
2003
-
2004
- // Size of objects alive after last GC.
2005
- static intptr_t alive_after_last_gc_;
2006
-
2007
- static double last_gc_end_timestamp_;
2111
+ Heap* heap_;
2008
2112
  };
2009
2113
 
2010
2114
 
@@ -2014,131 +2118,71 @@ class TranscendentalCache {
2014
2118
  static const int kTranscendentalTypeBits = 3;
2015
2119
  STATIC_ASSERT((1 << kTranscendentalTypeBits) >= kNumberOfCaches);
2016
2120
 
2017
- explicit TranscendentalCache(Type t);
2018
-
2019
2121
  // Returns a heap number with f(input), where f is a math function specified
2020
2122
  // by the 'type' argument.
2021
- MUST_USE_RESULT static inline MaybeObject* Get(Type type, double input) {
2022
- TranscendentalCache* cache = caches_[type];
2023
- if (cache == NULL) {
2024
- caches_[type] = cache = new TranscendentalCache(type);
2025
- }
2026
- return cache->Get(input);
2027
- }
2123
+ MUST_USE_RESULT inline MaybeObject* Get(Type type, double input);
2028
2124
 
2029
2125
  // The cache contains raw Object pointers. This method disposes of
2030
2126
  // them before a garbage collection.
2031
- static void Clear();
2127
+ void Clear();
2032
2128
 
2033
2129
  private:
2034
- MUST_USE_RESULT inline MaybeObject* Get(double input) {
2035
- Converter c;
2036
- c.dbl = input;
2037
- int hash = Hash(c);
2038
- Element e = elements_[hash];
2039
- if (e.in[0] == c.integers[0] &&
2040
- e.in[1] == c.integers[1]) {
2041
- ASSERT(e.output != NULL);
2042
- Counters::transcendental_cache_hit.Increment();
2043
- return e.output;
2044
- }
2045
- double answer = Calculate(input);
2046
- Counters::transcendental_cache_miss.Increment();
2047
- Object* heap_number;
2048
- { MaybeObject* maybe_heap_number = Heap::AllocateHeapNumber(answer);
2049
- if (!maybe_heap_number->ToObject(&heap_number)) return maybe_heap_number;
2050
- }
2051
- elements_[hash].in[0] = c.integers[0];
2052
- elements_[hash].in[1] = c.integers[1];
2053
- elements_[hash].output = heap_number;
2054
- return heap_number;
2055
- }
2130
+ class SubCache {
2131
+ static const int kCacheSize = 512;
2056
2132
 
2057
- inline double Calculate(double input) {
2058
- switch (type_) {
2059
- case ACOS:
2060
- return acos(input);
2061
- case ASIN:
2062
- return asin(input);
2063
- case ATAN:
2064
- return atan(input);
2065
- case COS:
2066
- return cos(input);
2067
- case EXP:
2068
- return exp(input);
2069
- case LOG:
2070
- return log(input);
2071
- case SIN:
2072
- return sin(input);
2073
- case TAN:
2074
- return tan(input);
2075
- default:
2076
- return 0.0; // Never happens.
2077
- }
2078
- }
2079
- static const int kCacheSize = 512;
2080
- struct Element {
2081
- uint32_t in[2];
2082
- Object* output;
2083
- };
2084
- union Converter {
2085
- double dbl;
2086
- uint32_t integers[2];
2087
- };
2088
- inline static int Hash(const Converter& c) {
2089
- uint32_t hash = (c.integers[0] ^ c.integers[1]);
2090
- hash ^= static_cast<int32_t>(hash) >> 16;
2091
- hash ^= static_cast<int32_t>(hash) >> 8;
2092
- return (hash & (kCacheSize - 1));
2093
- }
2133
+ explicit SubCache(Type t);
2094
2134
 
2095
- static Address cache_array_address() {
2096
- // Used to create an external reference.
2097
- return reinterpret_cast<Address>(caches_);
2098
- }
2135
+ MUST_USE_RESULT inline MaybeObject* Get(double input);
2099
2136
 
2100
- // Allow access to the caches_ array as an ExternalReference.
2101
- friend class ExternalReference;
2102
- // Inline implementation of the cache.
2103
- friend class TranscendentalCacheStub;
2137
+ inline double Calculate(double input);
2104
2138
 
2105
- static TranscendentalCache* caches_[kNumberOfCaches];
2106
- Element elements_[kCacheSize];
2107
- Type type_;
2108
- };
2139
+ struct Element {
2140
+ uint32_t in[2];
2141
+ Object* output;
2142
+ };
2109
2143
 
2144
+ union Converter {
2145
+ double dbl;
2146
+ uint32_t integers[2];
2147
+ };
2110
2148
 
2111
- // External strings table is a place where all external strings are
2112
- // registered. We need to keep track of such strings to properly
2113
- // finalize them.
2114
- class ExternalStringTable : public AllStatic {
2115
- public:
2116
- // Registers an external string.
2117
- inline static void AddString(String* string);
2149
+ inline static int Hash(const Converter& c) {
2150
+ uint32_t hash = (c.integers[0] ^ c.integers[1]);
2151
+ hash ^= static_cast<int32_t>(hash) >> 16;
2152
+ hash ^= static_cast<int32_t>(hash) >> 8;
2153
+ return (hash & (kCacheSize - 1));
2154
+ }
2118
2155
 
2119
- inline static void Iterate(ObjectVisitor* v);
2156
+ Element elements_[kCacheSize];
2157
+ Type type_;
2158
+ Isolate* isolate_;
2120
2159
 
2121
- // Restores internal invariant and gets rid of collected strings.
2122
- // Must be called after each Iterate() that modified the strings.
2123
- static void CleanUp();
2160
+ // Allow access to the caches_ array as an ExternalReference.
2161
+ friend class ExternalReference;
2162
+ // Inline implementation of the cache.
2163
+ friend class TranscendentalCacheStub;
2164
+ // For evaluating value.
2165
+ friend class TranscendentalCache;
2124
2166
 
2125
- // Destroys all allocated memory.
2126
- static void TearDown();
2127
-
2128
- private:
2129
- friend class Heap;
2167
+ DISALLOW_COPY_AND_ASSIGN(SubCache);
2168
+ };
2130
2169
 
2131
- inline static void Verify();
2170
+ TranscendentalCache() {
2171
+ for (int i = 0; i < kNumberOfCaches; ++i) caches_[i] = NULL;
2172
+ }
2132
2173
 
2133
- inline static void AddOldString(String* string);
2174
+ // Used to create an external reference.
2175
+ inline Address cache_array_address();
2134
2176
 
2135
- // Notifies the table that only a prefix of the new list is valid.
2136
- inline static void ShrinkNewStrings(int position);
2177
+ // Instantiation
2178
+ friend class Isolate;
2179
+ // Inline implementation of the caching.
2180
+ friend class TranscendentalCacheStub;
2181
+ // Allow access to the caches_ array as an ExternalReference.
2182
+ friend class ExternalReference;
2137
2183
 
2138
- // To speed up scavenge collections new space string are kept
2139
- // separate from old space strings.
2140
- static List<Object*> new_space_strings_;
2141
- static List<Object*> old_space_strings_;
2184
+ SubCache* caches_[kNumberOfCaches];
2185
+ DISALLOW_COPY_AND_ASSIGN(TranscendentalCache);
2142
2186
  };
2143
2187
 
2144
2188
 
@@ -2215,4 +2259,6 @@ class PathTracer : public ObjectVisitor {
2215
2259
 
2216
2260
  } } // namespace v8::internal
2217
2261
 
2262
+ #undef HEAP
2263
+
2218
2264
  #endif // V8_HEAP_H_