therubyracer 0.4.9-x86-linux

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of therubyracer might be problematic. Click here for more details.

Files changed (637) hide show
  1. data/.gitignore +11 -0
  2. data/.gitmodules +3 -0
  3. data/Doxyfile +1514 -0
  4. data/History.txt +43 -0
  5. data/README.rdoc +157 -0
  6. data/Rakefile +51 -0
  7. data/docs/data_conversion.txt +18 -0
  8. data/ext/v8/callbacks.cpp +160 -0
  9. data/ext/v8/callbacks.h +14 -0
  10. data/ext/v8/convert_ruby.cpp +8 -0
  11. data/ext/v8/convert_ruby.h +99 -0
  12. data/ext/v8/convert_string.cpp +10 -0
  13. data/ext/v8/convert_string.h +73 -0
  14. data/ext/v8/convert_v8.cpp +9 -0
  15. data/ext/v8/convert_v8.h +121 -0
  16. data/ext/v8/converters.cpp +83 -0
  17. data/ext/v8/converters.h +23 -0
  18. data/ext/v8/extconf.rb +36 -0
  19. data/ext/v8/upstream/2.0.6/.gitignore +26 -0
  20. data/ext/v8/upstream/2.0.6/AUTHORS +23 -0
  21. data/ext/v8/upstream/2.0.6/ChangeLog +1479 -0
  22. data/ext/v8/upstream/2.0.6/LICENSE +55 -0
  23. data/ext/v8/upstream/2.0.6/SConstruct +1028 -0
  24. data/ext/v8/upstream/2.0.6/include/v8-debug.h +275 -0
  25. data/ext/v8/upstream/2.0.6/include/v8.h +3236 -0
  26. data/ext/v8/upstream/2.0.6/src/SConscript +283 -0
  27. data/ext/v8/upstream/2.0.6/src/accessors.cc +695 -0
  28. data/ext/v8/upstream/2.0.6/src/accessors.h +114 -0
  29. data/ext/v8/upstream/2.0.6/src/allocation.cc +198 -0
  30. data/ext/v8/upstream/2.0.6/src/allocation.h +169 -0
  31. data/ext/v8/upstream/2.0.6/src/api.cc +3831 -0
  32. data/ext/v8/upstream/2.0.6/src/api.h +479 -0
  33. data/ext/v8/upstream/2.0.6/src/apinatives.js +110 -0
  34. data/ext/v8/upstream/2.0.6/src/apiutils.h +69 -0
  35. data/ext/v8/upstream/2.0.6/src/arguments.h +97 -0
  36. data/ext/v8/upstream/2.0.6/src/arm/assembler-arm-inl.h +277 -0
  37. data/ext/v8/upstream/2.0.6/src/arm/assembler-arm.cc +1821 -0
  38. data/ext/v8/upstream/2.0.6/src/arm/assembler-arm.h +1027 -0
  39. data/ext/v8/upstream/2.0.6/src/arm/assembler-thumb2-inl.h +267 -0
  40. data/ext/v8/upstream/2.0.6/src/arm/assembler-thumb2.cc +1821 -0
  41. data/ext/v8/upstream/2.0.6/src/arm/assembler-thumb2.h +1027 -0
  42. data/ext/v8/upstream/2.0.6/src/arm/builtins-arm.cc +1271 -0
  43. data/ext/v8/upstream/2.0.6/src/arm/codegen-arm-inl.h +74 -0
  44. data/ext/v8/upstream/2.0.6/src/arm/codegen-arm.cc +6682 -0
  45. data/ext/v8/upstream/2.0.6/src/arm/codegen-arm.h +535 -0
  46. data/ext/v8/upstream/2.0.6/src/arm/constants-arm.cc +112 -0
  47. data/ext/v8/upstream/2.0.6/src/arm/constants-arm.h +347 -0
  48. data/ext/v8/upstream/2.0.6/src/arm/cpu-arm.cc +132 -0
  49. data/ext/v8/upstream/2.0.6/src/arm/debug-arm.cc +213 -0
  50. data/ext/v8/upstream/2.0.6/src/arm/disasm-arm.cc +1166 -0
  51. data/ext/v8/upstream/2.0.6/src/arm/fast-codegen-arm.cc +1698 -0
  52. data/ext/v8/upstream/2.0.6/src/arm/frames-arm.cc +123 -0
  53. data/ext/v8/upstream/2.0.6/src/arm/frames-arm.h +162 -0
  54. data/ext/v8/upstream/2.0.6/src/arm/ic-arm.cc +849 -0
  55. data/ext/v8/upstream/2.0.6/src/arm/jump-target-arm.cc +238 -0
  56. data/ext/v8/upstream/2.0.6/src/arm/macro-assembler-arm.cc +1259 -0
  57. data/ext/v8/upstream/2.0.6/src/arm/macro-assembler-arm.h +423 -0
  58. data/ext/v8/upstream/2.0.6/src/arm/regexp-macro-assembler-arm.cc +1266 -0
  59. data/ext/v8/upstream/2.0.6/src/arm/regexp-macro-assembler-arm.h +282 -0
  60. data/ext/v8/upstream/2.0.6/src/arm/register-allocator-arm-inl.h +103 -0
  61. data/ext/v8/upstream/2.0.6/src/arm/register-allocator-arm.cc +59 -0
  62. data/ext/v8/upstream/2.0.6/src/arm/register-allocator-arm.h +43 -0
  63. data/ext/v8/upstream/2.0.6/src/arm/simulator-arm.cc +2264 -0
  64. data/ext/v8/upstream/2.0.6/src/arm/simulator-arm.h +306 -0
  65. data/ext/v8/upstream/2.0.6/src/arm/stub-cache-arm.cc +1516 -0
  66. data/ext/v8/upstream/2.0.6/src/arm/virtual-frame-arm.cc +412 -0
  67. data/ext/v8/upstream/2.0.6/src/arm/virtual-frame-arm.h +532 -0
  68. data/ext/v8/upstream/2.0.6/src/array.js +1154 -0
  69. data/ext/v8/upstream/2.0.6/src/assembler.cc +772 -0
  70. data/ext/v8/upstream/2.0.6/src/assembler.h +525 -0
  71. data/ext/v8/upstream/2.0.6/src/ast.cc +512 -0
  72. data/ext/v8/upstream/2.0.6/src/ast.h +1820 -0
  73. data/ext/v8/upstream/2.0.6/src/bootstrapper.cc +1680 -0
  74. data/ext/v8/upstream/2.0.6/src/bootstrapper.h +103 -0
  75. data/ext/v8/upstream/2.0.6/src/builtins.cc +851 -0
  76. data/ext/v8/upstream/2.0.6/src/builtins.h +245 -0
  77. data/ext/v8/upstream/2.0.6/src/bytecodes-irregexp.h +104 -0
  78. data/ext/v8/upstream/2.0.6/src/char-predicates-inl.h +86 -0
  79. data/ext/v8/upstream/2.0.6/src/char-predicates.h +65 -0
  80. data/ext/v8/upstream/2.0.6/src/checks.cc +100 -0
  81. data/ext/v8/upstream/2.0.6/src/checks.h +284 -0
  82. data/ext/v8/upstream/2.0.6/src/code-stubs.cc +164 -0
  83. data/ext/v8/upstream/2.0.6/src/code-stubs.h +164 -0
  84. data/ext/v8/upstream/2.0.6/src/code.h +68 -0
  85. data/ext/v8/upstream/2.0.6/src/codegen-inl.h +88 -0
  86. data/ext/v8/upstream/2.0.6/src/codegen.cc +504 -0
  87. data/ext/v8/upstream/2.0.6/src/codegen.h +522 -0
  88. data/ext/v8/upstream/2.0.6/src/compilation-cache.cc +490 -0
  89. data/ext/v8/upstream/2.0.6/src/compilation-cache.h +98 -0
  90. data/ext/v8/upstream/2.0.6/src/compiler.cc +1132 -0
  91. data/ext/v8/upstream/2.0.6/src/compiler.h +107 -0
  92. data/ext/v8/upstream/2.0.6/src/contexts.cc +256 -0
  93. data/ext/v8/upstream/2.0.6/src/contexts.h +345 -0
  94. data/ext/v8/upstream/2.0.6/src/conversions-inl.h +95 -0
  95. data/ext/v8/upstream/2.0.6/src/conversions.cc +709 -0
  96. data/ext/v8/upstream/2.0.6/src/conversions.h +118 -0
  97. data/ext/v8/upstream/2.0.6/src/counters.cc +78 -0
  98. data/ext/v8/upstream/2.0.6/src/counters.h +239 -0
  99. data/ext/v8/upstream/2.0.6/src/cpu.h +65 -0
  100. data/ext/v8/upstream/2.0.6/src/d8-debug.cc +345 -0
  101. data/ext/v8/upstream/2.0.6/src/d8-debug.h +155 -0
  102. data/ext/v8/upstream/2.0.6/src/d8-posix.cc +675 -0
  103. data/ext/v8/upstream/2.0.6/src/d8-readline.cc +128 -0
  104. data/ext/v8/upstream/2.0.6/src/d8-windows.cc +42 -0
  105. data/ext/v8/upstream/2.0.6/src/d8.cc +776 -0
  106. data/ext/v8/upstream/2.0.6/src/d8.h +225 -0
  107. data/ext/v8/upstream/2.0.6/src/d8.js +1625 -0
  108. data/ext/v8/upstream/2.0.6/src/date-delay.js +1138 -0
  109. data/ext/v8/upstream/2.0.6/src/dateparser-inl.h +114 -0
  110. data/ext/v8/upstream/2.0.6/src/dateparser.cc +186 -0
  111. data/ext/v8/upstream/2.0.6/src/dateparser.h +240 -0
  112. data/ext/v8/upstream/2.0.6/src/debug-agent.cc +425 -0
  113. data/ext/v8/upstream/2.0.6/src/debug-agent.h +129 -0
  114. data/ext/v8/upstream/2.0.6/src/debug-delay.js +2073 -0
  115. data/ext/v8/upstream/2.0.6/src/debug.cc +2751 -0
  116. data/ext/v8/upstream/2.0.6/src/debug.h +866 -0
  117. data/ext/v8/upstream/2.0.6/src/disasm.h +77 -0
  118. data/ext/v8/upstream/2.0.6/src/disassembler.cc +318 -0
  119. data/ext/v8/upstream/2.0.6/src/disassembler.h +56 -0
  120. data/ext/v8/upstream/2.0.6/src/dtoa-config.c +91 -0
  121. data/ext/v8/upstream/2.0.6/src/execution.cc +701 -0
  122. data/ext/v8/upstream/2.0.6/src/execution.h +312 -0
  123. data/ext/v8/upstream/2.0.6/src/factory.cc +957 -0
  124. data/ext/v8/upstream/2.0.6/src/factory.h +393 -0
  125. data/ext/v8/upstream/2.0.6/src/fast-codegen.cc +725 -0
  126. data/ext/v8/upstream/2.0.6/src/fast-codegen.h +371 -0
  127. data/ext/v8/upstream/2.0.6/src/flag-definitions.h +426 -0
  128. data/ext/v8/upstream/2.0.6/src/flags.cc +555 -0
  129. data/ext/v8/upstream/2.0.6/src/flags.h +81 -0
  130. data/ext/v8/upstream/2.0.6/src/frame-element.cc +45 -0
  131. data/ext/v8/upstream/2.0.6/src/frame-element.h +235 -0
  132. data/ext/v8/upstream/2.0.6/src/frames-inl.h +215 -0
  133. data/ext/v8/upstream/2.0.6/src/frames.cc +749 -0
  134. data/ext/v8/upstream/2.0.6/src/frames.h +659 -0
  135. data/ext/v8/upstream/2.0.6/src/func-name-inferrer.cc +76 -0
  136. data/ext/v8/upstream/2.0.6/src/func-name-inferrer.h +135 -0
  137. data/ext/v8/upstream/2.0.6/src/global-handles.cc +516 -0
  138. data/ext/v8/upstream/2.0.6/src/global-handles.h +180 -0
  139. data/ext/v8/upstream/2.0.6/src/globals.h +608 -0
  140. data/ext/v8/upstream/2.0.6/src/handles-inl.h +76 -0
  141. data/ext/v8/upstream/2.0.6/src/handles.cc +811 -0
  142. data/ext/v8/upstream/2.0.6/src/handles.h +367 -0
  143. data/ext/v8/upstream/2.0.6/src/hashmap.cc +226 -0
  144. data/ext/v8/upstream/2.0.6/src/hashmap.h +120 -0
  145. data/ext/v8/upstream/2.0.6/src/heap-inl.h +407 -0
  146. data/ext/v8/upstream/2.0.6/src/heap-profiler.cc +695 -0
  147. data/ext/v8/upstream/2.0.6/src/heap-profiler.h +277 -0
  148. data/ext/v8/upstream/2.0.6/src/heap.cc +4204 -0
  149. data/ext/v8/upstream/2.0.6/src/heap.h +1704 -0
  150. data/ext/v8/upstream/2.0.6/src/ia32/assembler-ia32-inl.h +325 -0
  151. data/ext/v8/upstream/2.0.6/src/ia32/assembler-ia32.cc +2375 -0
  152. data/ext/v8/upstream/2.0.6/src/ia32/assembler-ia32.h +914 -0
  153. data/ext/v8/upstream/2.0.6/src/ia32/builtins-ia32.cc +1222 -0
  154. data/ext/v8/upstream/2.0.6/src/ia32/codegen-ia32-inl.h +46 -0
  155. data/ext/v8/upstream/2.0.6/src/ia32/codegen-ia32.cc +9770 -0
  156. data/ext/v8/upstream/2.0.6/src/ia32/codegen-ia32.h +834 -0
  157. data/ext/v8/upstream/2.0.6/src/ia32/cpu-ia32.cc +79 -0
  158. data/ext/v8/upstream/2.0.6/src/ia32/debug-ia32.cc +208 -0
  159. data/ext/v8/upstream/2.0.6/src/ia32/disasm-ia32.cc +1357 -0
  160. data/ext/v8/upstream/2.0.6/src/ia32/fast-codegen-ia32.cc +1813 -0
  161. data/ext/v8/upstream/2.0.6/src/ia32/frames-ia32.cc +111 -0
  162. data/ext/v8/upstream/2.0.6/src/ia32/frames-ia32.h +135 -0
  163. data/ext/v8/upstream/2.0.6/src/ia32/ic-ia32.cc +1490 -0
  164. data/ext/v8/upstream/2.0.6/src/ia32/jump-target-ia32.cc +432 -0
  165. data/ext/v8/upstream/2.0.6/src/ia32/macro-assembler-ia32.cc +1517 -0
  166. data/ext/v8/upstream/2.0.6/src/ia32/macro-assembler-ia32.h +528 -0
  167. data/ext/v8/upstream/2.0.6/src/ia32/regexp-macro-assembler-ia32.cc +1219 -0
  168. data/ext/v8/upstream/2.0.6/src/ia32/regexp-macro-assembler-ia32.h +230 -0
  169. data/ext/v8/upstream/2.0.6/src/ia32/register-allocator-ia32-inl.h +82 -0
  170. data/ext/v8/upstream/2.0.6/src/ia32/register-allocator-ia32.cc +99 -0
  171. data/ext/v8/upstream/2.0.6/src/ia32/register-allocator-ia32.h +43 -0
  172. data/ext/v8/upstream/2.0.6/src/ia32/simulator-ia32.cc +30 -0
  173. data/ext/v8/upstream/2.0.6/src/ia32/simulator-ia32.h +62 -0
  174. data/ext/v8/upstream/2.0.6/src/ia32/stub-cache-ia32.cc +1961 -0
  175. data/ext/v8/upstream/2.0.6/src/ia32/virtual-frame-ia32.cc +1105 -0
  176. data/ext/v8/upstream/2.0.6/src/ia32/virtual-frame-ia32.h +580 -0
  177. data/ext/v8/upstream/2.0.6/src/ic-inl.h +93 -0
  178. data/ext/v8/upstream/2.0.6/src/ic.cc +1426 -0
  179. data/ext/v8/upstream/2.0.6/src/ic.h +443 -0
  180. data/ext/v8/upstream/2.0.6/src/interpreter-irregexp.cc +646 -0
  181. data/ext/v8/upstream/2.0.6/src/interpreter-irregexp.h +48 -0
  182. data/ext/v8/upstream/2.0.6/src/json-delay.js +254 -0
  183. data/ext/v8/upstream/2.0.6/src/jsregexp.cc +5234 -0
  184. data/ext/v8/upstream/2.0.6/src/jsregexp.h +1439 -0
  185. data/ext/v8/upstream/2.0.6/src/jump-target-inl.h +49 -0
  186. data/ext/v8/upstream/2.0.6/src/jump-target.cc +383 -0
  187. data/ext/v8/upstream/2.0.6/src/jump-target.h +280 -0
  188. data/ext/v8/upstream/2.0.6/src/list-inl.h +166 -0
  189. data/ext/v8/upstream/2.0.6/src/list.h +158 -0
  190. data/ext/v8/upstream/2.0.6/src/log-inl.h +126 -0
  191. data/ext/v8/upstream/2.0.6/src/log-utils.cc +503 -0
  192. data/ext/v8/upstream/2.0.6/src/log-utils.h +292 -0
  193. data/ext/v8/upstream/2.0.6/src/log.cc +1457 -0
  194. data/ext/v8/upstream/2.0.6/src/log.h +371 -0
  195. data/ext/v8/upstream/2.0.6/src/macro-assembler.h +93 -0
  196. data/ext/v8/upstream/2.0.6/src/macros.py +137 -0
  197. data/ext/v8/upstream/2.0.6/src/mark-compact.cc +2007 -0
  198. data/ext/v8/upstream/2.0.6/src/mark-compact.h +442 -0
  199. data/ext/v8/upstream/2.0.6/src/math.js +263 -0
  200. data/ext/v8/upstream/2.0.6/src/memory.h +74 -0
  201. data/ext/v8/upstream/2.0.6/src/messages.cc +177 -0
  202. data/ext/v8/upstream/2.0.6/src/messages.h +112 -0
  203. data/ext/v8/upstream/2.0.6/src/messages.js +937 -0
  204. data/ext/v8/upstream/2.0.6/src/mirror-delay.js +2332 -0
  205. data/ext/v8/upstream/2.0.6/src/mksnapshot.cc +169 -0
  206. data/ext/v8/upstream/2.0.6/src/natives.h +63 -0
  207. data/ext/v8/upstream/2.0.6/src/objects-debug.cc +1317 -0
  208. data/ext/v8/upstream/2.0.6/src/objects-inl.h +3044 -0
  209. data/ext/v8/upstream/2.0.6/src/objects.cc +8306 -0
  210. data/ext/v8/upstream/2.0.6/src/objects.h +4960 -0
  211. data/ext/v8/upstream/2.0.6/src/oprofile-agent.cc +116 -0
  212. data/ext/v8/upstream/2.0.6/src/oprofile-agent.h +69 -0
  213. data/ext/v8/upstream/2.0.6/src/parser.cc +4810 -0
  214. data/ext/v8/upstream/2.0.6/src/parser.h +195 -0
  215. data/ext/v8/upstream/2.0.6/src/platform-freebsd.cc +645 -0
  216. data/ext/v8/upstream/2.0.6/src/platform-linux.cc +808 -0
  217. data/ext/v8/upstream/2.0.6/src/platform-macos.cc +643 -0
  218. data/ext/v8/upstream/2.0.6/src/platform-nullos.cc +454 -0
  219. data/ext/v8/upstream/2.0.6/src/platform-openbsd.cc +597 -0
  220. data/ext/v8/upstream/2.0.6/src/platform-posix.cc +380 -0
  221. data/ext/v8/upstream/2.0.6/src/platform-win32.cc +1908 -0
  222. data/ext/v8/upstream/2.0.6/src/platform.h +556 -0
  223. data/ext/v8/upstream/2.0.6/src/prettyprinter.cc +1511 -0
  224. data/ext/v8/upstream/2.0.6/src/prettyprinter.h +219 -0
  225. data/ext/v8/upstream/2.0.6/src/property.cc +96 -0
  226. data/ext/v8/upstream/2.0.6/src/property.h +327 -0
  227. data/ext/v8/upstream/2.0.6/src/regexp-delay.js +406 -0
  228. data/ext/v8/upstream/2.0.6/src/regexp-macro-assembler-irregexp-inl.h +78 -0
  229. data/ext/v8/upstream/2.0.6/src/regexp-macro-assembler-irregexp.cc +464 -0
  230. data/ext/v8/upstream/2.0.6/src/regexp-macro-assembler-irregexp.h +141 -0
  231. data/ext/v8/upstream/2.0.6/src/regexp-macro-assembler-tracer.cc +356 -0
  232. data/ext/v8/upstream/2.0.6/src/regexp-macro-assembler-tracer.h +103 -0
  233. data/ext/v8/upstream/2.0.6/src/regexp-macro-assembler.cc +240 -0
  234. data/ext/v8/upstream/2.0.6/src/regexp-macro-assembler.h +220 -0
  235. data/ext/v8/upstream/2.0.6/src/regexp-stack.cc +103 -0
  236. data/ext/v8/upstream/2.0.6/src/regexp-stack.h +123 -0
  237. data/ext/v8/upstream/2.0.6/src/register-allocator-inl.h +74 -0
  238. data/ext/v8/upstream/2.0.6/src/register-allocator.cc +100 -0
  239. data/ext/v8/upstream/2.0.6/src/register-allocator.h +295 -0
  240. data/ext/v8/upstream/2.0.6/src/rewriter.cc +855 -0
  241. data/ext/v8/upstream/2.0.6/src/rewriter.h +54 -0
  242. data/ext/v8/upstream/2.0.6/src/runtime.cc +8163 -0
  243. data/ext/v8/upstream/2.0.6/src/runtime.h +432 -0
  244. data/ext/v8/upstream/2.0.6/src/runtime.js +626 -0
  245. data/ext/v8/upstream/2.0.6/src/scanner.cc +1098 -0
  246. data/ext/v8/upstream/2.0.6/src/scanner.h +425 -0
  247. data/ext/v8/upstream/2.0.6/src/scopeinfo.cc +649 -0
  248. data/ext/v8/upstream/2.0.6/src/scopeinfo.h +236 -0
  249. data/ext/v8/upstream/2.0.6/src/scopes.cc +963 -0
  250. data/ext/v8/upstream/2.0.6/src/scopes.h +401 -0
  251. data/ext/v8/upstream/2.0.6/src/serialize.cc +1260 -0
  252. data/ext/v8/upstream/2.0.6/src/serialize.h +404 -0
  253. data/ext/v8/upstream/2.0.6/src/shell.h +55 -0
  254. data/ext/v8/upstream/2.0.6/src/simulator.h +41 -0
  255. data/ext/v8/upstream/2.0.6/src/smart-pointer.h +109 -0
  256. data/ext/v8/upstream/2.0.6/src/snapshot-common.cc +97 -0
  257. data/ext/v8/upstream/2.0.6/src/snapshot-empty.cc +40 -0
  258. data/ext/v8/upstream/2.0.6/src/snapshot.h +59 -0
  259. data/ext/v8/upstream/2.0.6/src/spaces-inl.h +372 -0
  260. data/ext/v8/upstream/2.0.6/src/spaces.cc +2864 -0
  261. data/ext/v8/upstream/2.0.6/src/spaces.h +2072 -0
  262. data/ext/v8/upstream/2.0.6/src/string-stream.cc +584 -0
  263. data/ext/v8/upstream/2.0.6/src/string-stream.h +189 -0
  264. data/ext/v8/upstream/2.0.6/src/string.js +901 -0
  265. data/ext/v8/upstream/2.0.6/src/stub-cache.cc +1108 -0
  266. data/ext/v8/upstream/2.0.6/src/stub-cache.h +578 -0
  267. data/ext/v8/upstream/2.0.6/src/third_party/dtoa/COPYING +15 -0
  268. data/ext/v8/upstream/2.0.6/src/third_party/dtoa/dtoa.c +3330 -0
  269. data/ext/v8/upstream/2.0.6/src/third_party/valgrind/valgrind.h +3925 -0
  270. data/ext/v8/upstream/2.0.6/src/token.cc +56 -0
  271. data/ext/v8/upstream/2.0.6/src/token.h +270 -0
  272. data/ext/v8/upstream/2.0.6/src/top.cc +991 -0
  273. data/ext/v8/upstream/2.0.6/src/top.h +459 -0
  274. data/ext/v8/upstream/2.0.6/src/unicode-inl.h +238 -0
  275. data/ext/v8/upstream/2.0.6/src/unicode.cc +749 -0
  276. data/ext/v8/upstream/2.0.6/src/unicode.h +279 -0
  277. data/ext/v8/upstream/2.0.6/src/uri.js +415 -0
  278. data/ext/v8/upstream/2.0.6/src/usage-analyzer.cc +426 -0
  279. data/ext/v8/upstream/2.0.6/src/usage-analyzer.h +40 -0
  280. data/ext/v8/upstream/2.0.6/src/utils.cc +322 -0
  281. data/ext/v8/upstream/2.0.6/src/utils.h +592 -0
  282. data/ext/v8/upstream/2.0.6/src/v8-counters.cc +55 -0
  283. data/ext/v8/upstream/2.0.6/src/v8-counters.h +198 -0
  284. data/ext/v8/upstream/2.0.6/src/v8.cc +193 -0
  285. data/ext/v8/upstream/2.0.6/src/v8.h +119 -0
  286. data/ext/v8/upstream/2.0.6/src/v8natives.js +846 -0
  287. data/ext/v8/upstream/2.0.6/src/v8threads.cc +450 -0
  288. data/ext/v8/upstream/2.0.6/src/v8threads.h +144 -0
  289. data/ext/v8/upstream/2.0.6/src/variables.cc +163 -0
  290. data/ext/v8/upstream/2.0.6/src/variables.h +235 -0
  291. data/ext/v8/upstream/2.0.6/src/version.cc +88 -0
  292. data/ext/v8/upstream/2.0.6/src/version.h +64 -0
  293. data/ext/v8/upstream/2.0.6/src/virtual-frame.cc +381 -0
  294. data/ext/v8/upstream/2.0.6/src/virtual-frame.h +44 -0
  295. data/ext/v8/upstream/2.0.6/src/x64/assembler-x64-inl.h +352 -0
  296. data/ext/v8/upstream/2.0.6/src/x64/assembler-x64.cc +2539 -0
  297. data/ext/v8/upstream/2.0.6/src/x64/assembler-x64.h +1399 -0
  298. data/ext/v8/upstream/2.0.6/src/x64/builtins-x64.cc +1255 -0
  299. data/ext/v8/upstream/2.0.6/src/x64/codegen-x64-inl.h +46 -0
  300. data/ext/v8/upstream/2.0.6/src/x64/codegen-x64.cc +8223 -0
  301. data/ext/v8/upstream/2.0.6/src/x64/codegen-x64.h +785 -0
  302. data/ext/v8/upstream/2.0.6/src/x64/cpu-x64.cc +79 -0
  303. data/ext/v8/upstream/2.0.6/src/x64/debug-x64.cc +202 -0
  304. data/ext/v8/upstream/2.0.6/src/x64/disasm-x64.cc +1596 -0
  305. data/ext/v8/upstream/2.0.6/src/x64/fast-codegen-x64.cc +1820 -0
  306. data/ext/v8/upstream/2.0.6/src/x64/frames-x64.cc +109 -0
  307. data/ext/v8/upstream/2.0.6/src/x64/frames-x64.h +121 -0
  308. data/ext/v8/upstream/2.0.6/src/x64/ic-x64.cc +1392 -0
  309. data/ext/v8/upstream/2.0.6/src/x64/jump-target-x64.cc +432 -0
  310. data/ext/v8/upstream/2.0.6/src/x64/macro-assembler-x64.cc +2409 -0
  311. data/ext/v8/upstream/2.0.6/src/x64/macro-assembler-x64.h +765 -0
  312. data/ext/v8/upstream/2.0.6/src/x64/regexp-macro-assembler-x64.cc +1337 -0
  313. data/ext/v8/upstream/2.0.6/src/x64/regexp-macro-assembler-x64.h +295 -0
  314. data/ext/v8/upstream/2.0.6/src/x64/register-allocator-x64-inl.h +86 -0
  315. data/ext/v8/upstream/2.0.6/src/x64/register-allocator-x64.cc +84 -0
  316. data/ext/v8/upstream/2.0.6/src/x64/register-allocator-x64.h +43 -0
  317. data/ext/v8/upstream/2.0.6/src/x64/simulator-x64.cc +27 -0
  318. data/ext/v8/upstream/2.0.6/src/x64/simulator-x64.h +63 -0
  319. data/ext/v8/upstream/2.0.6/src/x64/stub-cache-x64.cc +1884 -0
  320. data/ext/v8/upstream/2.0.6/src/x64/virtual-frame-x64.cc +1089 -0
  321. data/ext/v8/upstream/2.0.6/src/x64/virtual-frame-x64.h +560 -0
  322. data/ext/v8/upstream/2.0.6/src/zone-inl.h +297 -0
  323. data/ext/v8/upstream/2.0.6/src/zone.cc +193 -0
  324. data/ext/v8/upstream/2.0.6/src/zone.h +305 -0
  325. data/ext/v8/upstream/2.0.6/tools/codemap.js +258 -0
  326. data/ext/v8/upstream/2.0.6/tools/consarray.js +93 -0
  327. data/ext/v8/upstream/2.0.6/tools/csvparser.js +98 -0
  328. data/ext/v8/upstream/2.0.6/tools/gyp/v8.gyp +620 -0
  329. data/ext/v8/upstream/2.0.6/tools/js2c.py +376 -0
  330. data/ext/v8/upstream/2.0.6/tools/jsmin.py +280 -0
  331. data/ext/v8/upstream/2.0.6/tools/linux-tick-processor +24 -0
  332. data/ext/v8/upstream/2.0.6/tools/linux-tick-processor.py +78 -0
  333. data/ext/v8/upstream/2.0.6/tools/logreader.js +320 -0
  334. data/ext/v8/upstream/2.0.6/tools/mac-nm +18 -0
  335. data/ext/v8/upstream/2.0.6/tools/mac-tick-processor +6 -0
  336. data/ext/v8/upstream/2.0.6/tools/oprofile/annotate +7 -0
  337. data/ext/v8/upstream/2.0.6/tools/oprofile/common +19 -0
  338. data/ext/v8/upstream/2.0.6/tools/oprofile/dump +7 -0
  339. data/ext/v8/upstream/2.0.6/tools/oprofile/report +7 -0
  340. data/ext/v8/upstream/2.0.6/tools/oprofile/reset +7 -0
  341. data/ext/v8/upstream/2.0.6/tools/oprofile/run +14 -0
  342. data/ext/v8/upstream/2.0.6/tools/oprofile/shutdown +7 -0
  343. data/ext/v8/upstream/2.0.6/tools/oprofile/start +7 -0
  344. data/ext/v8/upstream/2.0.6/tools/presubmit.py +299 -0
  345. data/ext/v8/upstream/2.0.6/tools/process-heap-prof.py +120 -0
  346. data/ext/v8/upstream/2.0.6/tools/profile.js +621 -0
  347. data/ext/v8/upstream/2.0.6/tools/profile_view.js +224 -0
  348. data/ext/v8/upstream/2.0.6/tools/run-valgrind.py +77 -0
  349. data/ext/v8/upstream/2.0.6/tools/splaytree.js +322 -0
  350. data/ext/v8/upstream/2.0.6/tools/splaytree.py +226 -0
  351. data/ext/v8/upstream/2.0.6/tools/stats-viewer.py +456 -0
  352. data/ext/v8/upstream/2.0.6/tools/test.py +1370 -0
  353. data/ext/v8/upstream/2.0.6/tools/tickprocessor-driver.js +53 -0
  354. data/ext/v8/upstream/2.0.6/tools/tickprocessor.js +731 -0
  355. data/ext/v8/upstream/2.0.6/tools/tickprocessor.py +535 -0
  356. data/ext/v8/upstream/2.0.6/tools/utils.py +82 -0
  357. data/ext/v8/upstream/2.0.6/tools/visual_studio/README.txt +71 -0
  358. data/ext/v8/upstream/2.0.6/tools/visual_studio/arm.vsprops +14 -0
  359. data/ext/v8/upstream/2.0.6/tools/visual_studio/common.vsprops +35 -0
  360. data/ext/v8/upstream/2.0.6/tools/visual_studio/d8.vcproj +199 -0
  361. data/ext/v8/upstream/2.0.6/tools/visual_studio/d8_arm.vcproj +199 -0
  362. data/ext/v8/upstream/2.0.6/tools/visual_studio/d8_x64.vcproj +201 -0
  363. data/ext/v8/upstream/2.0.6/tools/visual_studio/d8js2c.cmd +6 -0
  364. data/ext/v8/upstream/2.0.6/tools/visual_studio/debug.vsprops +17 -0
  365. data/ext/v8/upstream/2.0.6/tools/visual_studio/ia32.vsprops +13 -0
  366. data/ext/v8/upstream/2.0.6/tools/visual_studio/js2c.cmd +6 -0
  367. data/ext/v8/upstream/2.0.6/tools/visual_studio/release.vsprops +24 -0
  368. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8.sln +101 -0
  369. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8.vcproj +223 -0
  370. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_arm.sln +74 -0
  371. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_arm.vcproj +223 -0
  372. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_base.vcproj +971 -0
  373. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_base_arm.vcproj +983 -0
  374. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_base_x64.vcproj +959 -0
  375. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_cctest.vcproj +255 -0
  376. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_cctest_arm.vcproj +243 -0
  377. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_cctest_x64.vcproj +257 -0
  378. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_mksnapshot.vcproj +151 -0
  379. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_mksnapshot_x64.vcproj +151 -0
  380. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_process_sample.vcproj +151 -0
  381. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_process_sample_arm.vcproj +151 -0
  382. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_process_sample_x64.vcproj +151 -0
  383. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_shell_sample.vcproj +151 -0
  384. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_shell_sample_arm.vcproj +151 -0
  385. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_shell_sample_x64.vcproj +153 -0
  386. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_snapshot.vcproj +142 -0
  387. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_snapshot_cc.vcproj +92 -0
  388. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_snapshot_cc_x64.vcproj +92 -0
  389. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_snapshot_x64.vcproj +142 -0
  390. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_x64.sln +101 -0
  391. data/ext/v8/upstream/2.0.6/tools/visual_studio/v8_x64.vcproj +223 -0
  392. data/ext/v8/upstream/2.0.6/tools/visual_studio/x64.vsprops +13 -0
  393. data/ext/v8/upstream/2.0.6/tools/windows-tick-processor.bat +5 -0
  394. data/ext/v8/upstream/2.0.6/tools/windows-tick-processor.py +137 -0
  395. data/ext/v8/upstream/Makefile +31 -0
  396. data/ext/v8/upstream/no-strict-aliasing.patch +13 -0
  397. data/ext/v8/upstream/scons/CHANGES.txt +5183 -0
  398. data/ext/v8/upstream/scons/LICENSE.txt +20 -0
  399. data/ext/v8/upstream/scons/MANIFEST +202 -0
  400. data/ext/v8/upstream/scons/PKG-INFO +13 -0
  401. data/ext/v8/upstream/scons/README.txt +273 -0
  402. data/ext/v8/upstream/scons/RELEASE.txt +1040 -0
  403. data/ext/v8/upstream/scons/engine/SCons/Action.py +1256 -0
  404. data/ext/v8/upstream/scons/engine/SCons/Builder.py +868 -0
  405. data/ext/v8/upstream/scons/engine/SCons/CacheDir.py +217 -0
  406. data/ext/v8/upstream/scons/engine/SCons/Conftest.py +794 -0
  407. data/ext/v8/upstream/scons/engine/SCons/Debug.py +237 -0
  408. data/ext/v8/upstream/scons/engine/SCons/Defaults.py +485 -0
  409. data/ext/v8/upstream/scons/engine/SCons/Environment.py +2327 -0
  410. data/ext/v8/upstream/scons/engine/SCons/Errors.py +207 -0
  411. data/ext/v8/upstream/scons/engine/SCons/Executor.py +636 -0
  412. data/ext/v8/upstream/scons/engine/SCons/Job.py +435 -0
  413. data/ext/v8/upstream/scons/engine/SCons/Memoize.py +292 -0
  414. data/ext/v8/upstream/scons/engine/SCons/Node/Alias.py +153 -0
  415. data/ext/v8/upstream/scons/engine/SCons/Node/FS.py +3220 -0
  416. data/ext/v8/upstream/scons/engine/SCons/Node/Python.py +128 -0
  417. data/ext/v8/upstream/scons/engine/SCons/Node/__init__.py +1341 -0
  418. data/ext/v8/upstream/scons/engine/SCons/Options/BoolOption.py +50 -0
  419. data/ext/v8/upstream/scons/engine/SCons/Options/EnumOption.py +50 -0
  420. data/ext/v8/upstream/scons/engine/SCons/Options/ListOption.py +50 -0
  421. data/ext/v8/upstream/scons/engine/SCons/Options/PackageOption.py +50 -0
  422. data/ext/v8/upstream/scons/engine/SCons/Options/PathOption.py +76 -0
  423. data/ext/v8/upstream/scons/engine/SCons/Options/__init__.py +74 -0
  424. data/ext/v8/upstream/scons/engine/SCons/PathList.py +232 -0
  425. data/ext/v8/upstream/scons/engine/SCons/Platform/__init__.py +236 -0
  426. data/ext/v8/upstream/scons/engine/SCons/Platform/aix.py +70 -0
  427. data/ext/v8/upstream/scons/engine/SCons/Platform/cygwin.py +55 -0
  428. data/ext/v8/upstream/scons/engine/SCons/Platform/darwin.py +46 -0
  429. data/ext/v8/upstream/scons/engine/SCons/Platform/hpux.py +46 -0
  430. data/ext/v8/upstream/scons/engine/SCons/Platform/irix.py +44 -0
  431. data/ext/v8/upstream/scons/engine/SCons/Platform/os2.py +58 -0
  432. data/ext/v8/upstream/scons/engine/SCons/Platform/posix.py +264 -0
  433. data/ext/v8/upstream/scons/engine/SCons/Platform/sunos.py +50 -0
  434. data/ext/v8/upstream/scons/engine/SCons/Platform/win32.py +386 -0
  435. data/ext/v8/upstream/scons/engine/SCons/SConf.py +1038 -0
  436. data/ext/v8/upstream/scons/engine/SCons/SConsign.py +381 -0
  437. data/ext/v8/upstream/scons/engine/SCons/Scanner/C.py +132 -0
  438. data/ext/v8/upstream/scons/engine/SCons/Scanner/D.py +74 -0
  439. data/ext/v8/upstream/scons/engine/SCons/Scanner/Dir.py +111 -0
  440. data/ext/v8/upstream/scons/engine/SCons/Scanner/Fortran.py +320 -0
  441. data/ext/v8/upstream/scons/engine/SCons/Scanner/IDL.py +48 -0
  442. data/ext/v8/upstream/scons/engine/SCons/Scanner/LaTeX.py +378 -0
  443. data/ext/v8/upstream/scons/engine/SCons/Scanner/Prog.py +103 -0
  444. data/ext/v8/upstream/scons/engine/SCons/Scanner/RC.py +55 -0
  445. data/ext/v8/upstream/scons/engine/SCons/Scanner/__init__.py +415 -0
  446. data/ext/v8/upstream/scons/engine/SCons/Script/Interactive.py +386 -0
  447. data/ext/v8/upstream/scons/engine/SCons/Script/Main.py +1360 -0
  448. data/ext/v8/upstream/scons/engine/SCons/Script/SConsOptions.py +944 -0
  449. data/ext/v8/upstream/scons/engine/SCons/Script/SConscript.py +642 -0
  450. data/ext/v8/upstream/scons/engine/SCons/Script/__init__.py +414 -0
  451. data/ext/v8/upstream/scons/engine/SCons/Sig.py +63 -0
  452. data/ext/v8/upstream/scons/engine/SCons/Subst.py +911 -0
  453. data/ext/v8/upstream/scons/engine/SCons/Taskmaster.py +1030 -0
  454. data/ext/v8/upstream/scons/engine/SCons/Tool/386asm.py +61 -0
  455. data/ext/v8/upstream/scons/engine/SCons/Tool/BitKeeper.py +65 -0
  456. data/ext/v8/upstream/scons/engine/SCons/Tool/CVS.py +73 -0
  457. data/ext/v8/upstream/scons/engine/SCons/Tool/FortranCommon.py +247 -0
  458. data/ext/v8/upstream/scons/engine/SCons/Tool/JavaCommon.py +324 -0
  459. data/ext/v8/upstream/scons/engine/SCons/Tool/MSCommon/__init__.py +56 -0
  460. data/ext/v8/upstream/scons/engine/SCons/Tool/MSCommon/arch.py +61 -0
  461. data/ext/v8/upstream/scons/engine/SCons/Tool/MSCommon/common.py +210 -0
  462. data/ext/v8/upstream/scons/engine/SCons/Tool/MSCommon/netframework.py +84 -0
  463. data/ext/v8/upstream/scons/engine/SCons/Tool/MSCommon/sdk.py +321 -0
  464. data/ext/v8/upstream/scons/engine/SCons/Tool/MSCommon/vc.py +367 -0
  465. data/ext/v8/upstream/scons/engine/SCons/Tool/MSCommon/vs.py +497 -0
  466. data/ext/v8/upstream/scons/engine/SCons/Tool/Perforce.py +104 -0
  467. data/ext/v8/upstream/scons/engine/SCons/Tool/PharLapCommon.py +138 -0
  468. data/ext/v8/upstream/scons/engine/SCons/Tool/RCS.py +64 -0
  469. data/ext/v8/upstream/scons/engine/SCons/Tool/SCCS.py +64 -0
  470. data/ext/v8/upstream/scons/engine/SCons/Tool/Subversion.py +71 -0
  471. data/ext/v8/upstream/scons/engine/SCons/Tool/__init__.py +675 -0
  472. data/ext/v8/upstream/scons/engine/SCons/Tool/aixc++.py +82 -0
  473. data/ext/v8/upstream/scons/engine/SCons/Tool/aixcc.py +74 -0
  474. data/ext/v8/upstream/scons/engine/SCons/Tool/aixf77.py +80 -0
  475. data/ext/v8/upstream/scons/engine/SCons/Tool/aixlink.py +76 -0
  476. data/ext/v8/upstream/scons/engine/SCons/Tool/applelink.py +71 -0
  477. data/ext/v8/upstream/scons/engine/SCons/Tool/ar.py +63 -0
  478. data/ext/v8/upstream/scons/engine/SCons/Tool/as.py +78 -0
  479. data/ext/v8/upstream/scons/engine/SCons/Tool/bcc32.py +82 -0
  480. data/ext/v8/upstream/scons/engine/SCons/Tool/c++.py +99 -0
  481. data/ext/v8/upstream/scons/engine/SCons/Tool/cc.py +114 -0
  482. data/ext/v8/upstream/scons/engine/SCons/Tool/cvf.py +58 -0
  483. data/ext/v8/upstream/scons/engine/SCons/Tool/default.py +50 -0
  484. data/ext/v8/upstream/scons/engine/SCons/Tool/dmd.py +224 -0
  485. data/ext/v8/upstream/scons/engine/SCons/Tool/dvi.py +64 -0
  486. data/ext/v8/upstream/scons/engine/SCons/Tool/dvipdf.py +125 -0
  487. data/ext/v8/upstream/scons/engine/SCons/Tool/dvips.py +94 -0
  488. data/ext/v8/upstream/scons/engine/SCons/Tool/f77.py +62 -0
  489. data/ext/v8/upstream/scons/engine/SCons/Tool/f90.py +62 -0
  490. data/ext/v8/upstream/scons/engine/SCons/Tool/f95.py +63 -0
  491. data/ext/v8/upstream/scons/engine/SCons/Tool/filesystem.py +98 -0
  492. data/ext/v8/upstream/scons/engine/SCons/Tool/fortran.py +63 -0
  493. data/ext/v8/upstream/scons/engine/SCons/Tool/g++.py +90 -0
  494. data/ext/v8/upstream/scons/engine/SCons/Tool/g77.py +73 -0
  495. data/ext/v8/upstream/scons/engine/SCons/Tool/gas.py +53 -0
  496. data/ext/v8/upstream/scons/engine/SCons/Tool/gcc.py +80 -0
  497. data/ext/v8/upstream/scons/engine/SCons/Tool/gfortran.py +64 -0
  498. data/ext/v8/upstream/scons/engine/SCons/Tool/gnulink.py +63 -0
  499. data/ext/v8/upstream/scons/engine/SCons/Tool/gs.py +81 -0
  500. data/ext/v8/upstream/scons/engine/SCons/Tool/hpc++.py +85 -0
  501. data/ext/v8/upstream/scons/engine/SCons/Tool/hpcc.py +53 -0
  502. data/ext/v8/upstream/scons/engine/SCons/Tool/hplink.py +77 -0
  503. data/ext/v8/upstream/scons/engine/SCons/Tool/icc.py +59 -0
  504. data/ext/v8/upstream/scons/engine/SCons/Tool/icl.py +52 -0
  505. data/ext/v8/upstream/scons/engine/SCons/Tool/ifl.py +72 -0
  506. data/ext/v8/upstream/scons/engine/SCons/Tool/ifort.py +90 -0
  507. data/ext/v8/upstream/scons/engine/SCons/Tool/ilink.py +59 -0
  508. data/ext/v8/upstream/scons/engine/SCons/Tool/ilink32.py +60 -0
  509. data/ext/v8/upstream/scons/engine/SCons/Tool/install.py +229 -0
  510. data/ext/v8/upstream/scons/engine/SCons/Tool/intelc.py +490 -0
  511. data/ext/v8/upstream/scons/engine/SCons/Tool/ipkg.py +71 -0
  512. data/ext/v8/upstream/scons/engine/SCons/Tool/jar.py +110 -0
  513. data/ext/v8/upstream/scons/engine/SCons/Tool/javac.py +234 -0
  514. data/ext/v8/upstream/scons/engine/SCons/Tool/javah.py +138 -0
  515. data/ext/v8/upstream/scons/engine/SCons/Tool/latex.py +79 -0
  516. data/ext/v8/upstream/scons/engine/SCons/Tool/lex.py +99 -0
  517. data/ext/v8/upstream/scons/engine/SCons/Tool/link.py +121 -0
  518. data/ext/v8/upstream/scons/engine/SCons/Tool/linkloc.py +112 -0
  519. data/ext/v8/upstream/scons/engine/SCons/Tool/m4.py +63 -0
  520. data/ext/v8/upstream/scons/engine/SCons/Tool/masm.py +77 -0
  521. data/ext/v8/upstream/scons/engine/SCons/Tool/midl.py +90 -0
  522. data/ext/v8/upstream/scons/engine/SCons/Tool/mingw.py +159 -0
  523. data/ext/v8/upstream/scons/engine/SCons/Tool/mslib.py +64 -0
  524. data/ext/v8/upstream/scons/engine/SCons/Tool/mslink.py +266 -0
  525. data/ext/v8/upstream/scons/engine/SCons/Tool/mssdk.py +50 -0
  526. data/ext/v8/upstream/scons/engine/SCons/Tool/msvc.py +269 -0
  527. data/ext/v8/upstream/scons/engine/SCons/Tool/msvs.py +1439 -0
  528. data/ext/v8/upstream/scons/engine/SCons/Tool/mwcc.py +208 -0
  529. data/ext/v8/upstream/scons/engine/SCons/Tool/mwld.py +107 -0
  530. data/ext/v8/upstream/scons/engine/SCons/Tool/nasm.py +72 -0
  531. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/__init__.py +314 -0
  532. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/ipk.py +185 -0
  533. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/msi.py +526 -0
  534. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/rpm.py +367 -0
  535. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/src_tarbz2.py +43 -0
  536. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/src_targz.py +43 -0
  537. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/src_zip.py +43 -0
  538. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/tarbz2.py +44 -0
  539. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/targz.py +44 -0
  540. data/ext/v8/upstream/scons/engine/SCons/Tool/packaging/zip.py +44 -0
  541. data/ext/v8/upstream/scons/engine/SCons/Tool/pdf.py +78 -0
  542. data/ext/v8/upstream/scons/engine/SCons/Tool/pdflatex.py +83 -0
  543. data/ext/v8/upstream/scons/engine/SCons/Tool/pdftex.py +108 -0
  544. data/ext/v8/upstream/scons/engine/SCons/Tool/qt.py +336 -0
  545. data/ext/v8/upstream/scons/engine/SCons/Tool/rmic.py +121 -0
  546. data/ext/v8/upstream/scons/engine/SCons/Tool/rpcgen.py +70 -0
  547. data/ext/v8/upstream/scons/engine/SCons/Tool/rpm.py +132 -0
  548. data/ext/v8/upstream/scons/engine/SCons/Tool/sgiar.py +68 -0
  549. data/ext/v8/upstream/scons/engine/SCons/Tool/sgic++.py +58 -0
  550. data/ext/v8/upstream/scons/engine/SCons/Tool/sgicc.py +53 -0
  551. data/ext/v8/upstream/scons/engine/SCons/Tool/sgilink.py +63 -0
  552. data/ext/v8/upstream/scons/engine/SCons/Tool/sunar.py +67 -0
  553. data/ext/v8/upstream/scons/engine/SCons/Tool/sunc++.py +142 -0
  554. data/ext/v8/upstream/scons/engine/SCons/Tool/suncc.py +58 -0
  555. data/ext/v8/upstream/scons/engine/SCons/Tool/sunf77.py +63 -0
  556. data/ext/v8/upstream/scons/engine/SCons/Tool/sunf90.py +64 -0
  557. data/ext/v8/upstream/scons/engine/SCons/Tool/sunf95.py +64 -0
  558. data/ext/v8/upstream/scons/engine/SCons/Tool/sunlink.py +77 -0
  559. data/ext/v8/upstream/scons/engine/SCons/Tool/swig.py +186 -0
  560. data/ext/v8/upstream/scons/engine/SCons/Tool/tar.py +73 -0
  561. data/ext/v8/upstream/scons/engine/SCons/Tool/tex.py +805 -0
  562. data/ext/v8/upstream/scons/engine/SCons/Tool/textfile.py +175 -0
  563. data/ext/v8/upstream/scons/engine/SCons/Tool/tlib.py +53 -0
  564. data/ext/v8/upstream/scons/engine/SCons/Tool/wix.py +100 -0
  565. data/ext/v8/upstream/scons/engine/SCons/Tool/yacc.py +131 -0
  566. data/ext/v8/upstream/scons/engine/SCons/Tool/zip.py +100 -0
  567. data/ext/v8/upstream/scons/engine/SCons/Util.py +1645 -0
  568. data/ext/v8/upstream/scons/engine/SCons/Variables/BoolVariable.py +91 -0
  569. data/ext/v8/upstream/scons/engine/SCons/Variables/EnumVariable.py +107 -0
  570. data/ext/v8/upstream/scons/engine/SCons/Variables/ListVariable.py +139 -0
  571. data/ext/v8/upstream/scons/engine/SCons/Variables/PackageVariable.py +109 -0
  572. data/ext/v8/upstream/scons/engine/SCons/Variables/PathVariable.py +147 -0
  573. data/ext/v8/upstream/scons/engine/SCons/Variables/__init__.py +317 -0
  574. data/ext/v8/upstream/scons/engine/SCons/Warnings.py +228 -0
  575. data/ext/v8/upstream/scons/engine/SCons/__init__.py +49 -0
  576. data/ext/v8/upstream/scons/engine/SCons/compat/__init__.py +302 -0
  577. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_UserString.py +98 -0
  578. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_hashlib.py +91 -0
  579. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_itertools.py +124 -0
  580. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_optparse.py +1725 -0
  581. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_sets.py +583 -0
  582. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_sets15.py +176 -0
  583. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_shlex.py +325 -0
  584. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_subprocess.py +1296 -0
  585. data/ext/v8/upstream/scons/engine/SCons/compat/_scons_textwrap.py +382 -0
  586. data/ext/v8/upstream/scons/engine/SCons/compat/builtins.py +187 -0
  587. data/ext/v8/upstream/scons/engine/SCons/cpp.py +598 -0
  588. data/ext/v8/upstream/scons/engine/SCons/dblite.py +248 -0
  589. data/ext/v8/upstream/scons/engine/SCons/exitfuncs.py +77 -0
  590. data/ext/v8/upstream/scons/os_spawnv_fix.diff +83 -0
  591. data/ext/v8/upstream/scons/scons-time.1 +1017 -0
  592. data/ext/v8/upstream/scons/scons.1 +15179 -0
  593. data/ext/v8/upstream/scons/sconsign.1 +208 -0
  594. data/ext/v8/upstream/scons/script/scons +184 -0
  595. data/ext/v8/upstream/scons/script/scons-time +1529 -0
  596. data/ext/v8/upstream/scons/script/scons.bat +31 -0
  597. data/ext/v8/upstream/scons/script/sconsign +508 -0
  598. data/ext/v8/upstream/scons/setup.cfg +6 -0
  599. data/ext/v8/upstream/scons/setup.py +427 -0
  600. data/ext/v8/v8.cpp +89 -0
  601. data/ext/v8/v8_cxt.cpp +92 -0
  602. data/ext/v8/v8_cxt.h +20 -0
  603. data/ext/v8/v8_func.cpp +10 -0
  604. data/ext/v8/v8_func.h +11 -0
  605. data/ext/v8/v8_msg.cpp +54 -0
  606. data/ext/v8/v8_msg.h +18 -0
  607. data/ext/v8/v8_obj.cpp +52 -0
  608. data/ext/v8/v8_obj.h +13 -0
  609. data/ext/v8/v8_ref.cpp +26 -0
  610. data/ext/v8/v8_ref.h +31 -0
  611. data/ext/v8/v8_script.cpp +20 -0
  612. data/ext/v8/v8_script.h +8 -0
  613. data/ext/v8/v8_standalone.cpp +69 -0
  614. data/ext/v8/v8_standalone.h +31 -0
  615. data/ext/v8/v8_str.cpp +17 -0
  616. data/ext/v8/v8_str.h +9 -0
  617. data/ext/v8/v8_template.cpp +53 -0
  618. data/ext/v8/v8_template.h +13 -0
  619. data/lib/v8.rb +10 -0
  620. data/lib/v8/context.rb +101 -0
  621. data/lib/v8/object.rb +38 -0
  622. data/lib/v8/to.rb +33 -0
  623. data/lib/v8/v8.so +0 -0
  624. data/script/console +10 -0
  625. data/script/destroy +14 -0
  626. data/script/generate +14 -0
  627. data/spec/ext/cxt_spec.rb +25 -0
  628. data/spec/ext/obj_spec.rb +13 -0
  629. data/spec/redjs/jsapi_spec.rb +405 -0
  630. data/spec/redjs/tap.rb +8 -0
  631. data/spec/redjs_helper.rb +3 -0
  632. data/spec/spec.opts +1 -0
  633. data/spec/spec_helper.rb +14 -0
  634. data/spec/v8/to_spec.rb +15 -0
  635. data/tasks/rspec.rake +21 -0
  636. data/therubyracer.gemspec +680 -0
  637. metadata +697 -0
@@ -0,0 +1,2072 @@
1
+ // Copyright 2006-2008 the V8 project authors. All rights reserved.
2
+ // Redistribution and use in source and binary forms, with or without
3
+ // modification, are permitted provided that the following conditions are
4
+ // met:
5
+ //
6
+ // * Redistributions of source code must retain the above copyright
7
+ // notice, this list of conditions and the following disclaimer.
8
+ // * Redistributions in binary form must reproduce the above
9
+ // copyright notice, this list of conditions and the following
10
+ // disclaimer in the documentation and/or other materials provided
11
+ // with the distribution.
12
+ // * Neither the name of Google Inc. nor the names of its
13
+ // contributors may be used to endorse or promote products derived
14
+ // from this software without specific prior written permission.
15
+ //
16
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+
28
+ #ifndef V8_SPACES_H_
29
+ #define V8_SPACES_H_
30
+
31
+ #include "list-inl.h"
32
+ #include "log.h"
33
+
34
+ namespace v8 {
35
+ namespace internal {
36
+
37
+ // -----------------------------------------------------------------------------
38
+ // Heap structures:
39
+ //
40
+ // A JS heap consists of a young generation, an old generation, and a large
41
+ // object space. The young generation is divided into two semispaces. A
42
+ // scavenger implements Cheney's copying algorithm. The old generation is
43
+ // separated into a map space and an old object space. The map space contains
44
+ // all (and only) map objects, the rest of old objects go into the old space.
45
+ // The old generation is collected by a mark-sweep-compact collector.
46
+ //
47
+ // The semispaces of the young generation are contiguous. The old and map
48
+ // spaces consists of a list of pages. A page has a page header, a remembered
49
+ // set area, and an object area. A page size is deliberately chosen as 8K
50
+ // bytes. The first word of a page is an opaque page header that has the
51
+ // address of the next page and its ownership information. The second word may
52
+ // have the allocation top address of this page. The next 248 bytes are
53
+ // remembered sets. Heap objects are aligned to the pointer size (4 bytes). A
54
+ // remembered set bit corresponds to a pointer in the object area.
55
+ //
56
+ // There is a separate large object space for objects larger than
57
+ // Page::kMaxHeapObjectSize, so that they do not have to move during
58
+ // collection. The large object space is paged and uses the same remembered
59
+ // set implementation. Pages in large object space may be larger than 8K.
60
+ //
61
+ // NOTE: The mark-compact collector rebuilds the remembered set after a
62
+ // collection. It reuses first a few words of the remembered set for
63
+ // bookkeeping relocation information.
64
+
65
+
66
+ // Some assertion macros used in the debugging mode.
67
+
68
+ #define ASSERT_PAGE_ALIGNED(address) \
69
+ ASSERT((OffsetFrom(address) & Page::kPageAlignmentMask) == 0)
70
+
71
+ #define ASSERT_OBJECT_ALIGNED(address) \
72
+ ASSERT((OffsetFrom(address) & kObjectAlignmentMask) == 0)
73
+
74
+ #define ASSERT_MAP_ALIGNED(address) \
75
+ ASSERT((OffsetFrom(address) & kMapAlignmentMask) == 0)
76
+
77
+ #define ASSERT_OBJECT_SIZE(size) \
78
+ ASSERT((0 < size) && (size <= Page::kMaxHeapObjectSize))
79
+
80
+ #define ASSERT_PAGE_OFFSET(offset) \
81
+ ASSERT((Page::kObjectStartOffset <= offset) \
82
+ && (offset <= Page::kPageSize))
83
+
84
+ #define ASSERT_MAP_PAGE_INDEX(index) \
85
+ ASSERT((0 <= index) && (index <= MapSpace::kMaxMapPageIndex))
86
+
87
+
88
+ class PagedSpace;
89
+ class MemoryAllocator;
90
+ class AllocationInfo;
91
+
92
+ // -----------------------------------------------------------------------------
93
+ // A page normally has 8K bytes. Large object pages may be larger. A page
94
+ // address is always aligned to the 8K page size. A page is divided into
95
+ // three areas: the first two words are used for bookkeeping, the next 248
96
+ // bytes are used as remembered set, and the rest of the page is the object
97
+ // area.
98
+ //
99
+ // Pointers are aligned to the pointer size (4), only 1 bit is needed
100
+ // for a pointer in the remembered set. Given an address, its remembered set
101
+ // bit position (offset from the start of the page) is calculated by dividing
102
+ // its page offset by 32. Therefore, the object area in a page starts at the
103
+ // 256th byte (8K/32). Bytes 0 to 255 do not need the remembered set, so that
104
+ // the first two words (64 bits) in a page can be used for other purposes.
105
+ //
106
+ // On the 64-bit platform, we add an offset to the start of the remembered set,
107
+ // and pointers are aligned to 8-byte pointer size. This means that we need
108
+ // only 128 bytes for the RSet, and only get two bytes free in the RSet's RSet.
109
+ // For this reason we add an offset to get room for the Page data at the start.
110
+ //
111
+ // The mark-compact collector transforms a map pointer into a page index and a
112
+ // page offset. The excact encoding is described in the comments for
113
+ // class MapWord in objects.h.
114
+ //
115
+ // The only way to get a page pointer is by calling factory methods:
116
+ // Page* p = Page::FromAddress(addr); or
117
+ // Page* p = Page::FromAllocationTop(top);
118
+ class Page {
119
+ public:
120
+ // Returns the page containing a given address. The address ranges
121
+ // from [page_addr .. page_addr + kPageSize[
122
+ //
123
+ // Note that this function only works for addresses in normal paged
124
+ // spaces and addresses in the first 8K of large object pages (i.e.,
125
+ // the start of large objects but not necessarily derived pointers
126
+ // within them).
127
+ INLINE(static Page* FromAddress(Address a)) {
128
+ return reinterpret_cast<Page*>(OffsetFrom(a) & ~kPageAlignmentMask);
129
+ }
130
+
131
+ // Returns the page containing an allocation top. Because an allocation
132
+ // top address can be the upper bound of the page, we need to subtract
133
+ // it with kPointerSize first. The address ranges from
134
+ // [page_addr + kObjectStartOffset .. page_addr + kPageSize].
135
+ INLINE(static Page* FromAllocationTop(Address top)) {
136
+ Page* p = FromAddress(top - kPointerSize);
137
+ ASSERT_PAGE_OFFSET(p->Offset(top));
138
+ return p;
139
+ }
140
+
141
+ // Returns the start address of this page.
142
+ Address address() { return reinterpret_cast<Address>(this); }
143
+
144
+ // Checks whether this is a valid page address.
145
+ bool is_valid() { return address() != NULL; }
146
+
147
+ // Returns the next page of this page.
148
+ inline Page* next_page();
149
+
150
+ // Return the end of allocation in this page. Undefined for unused pages.
151
+ inline Address AllocationTop();
152
+
153
+ // Returns the start address of the object area in this page.
154
+ Address ObjectAreaStart() { return address() + kObjectStartOffset; }
155
+
156
+ // Returns the end address (exclusive) of the object area in this page.
157
+ Address ObjectAreaEnd() { return address() + Page::kPageSize; }
158
+
159
+ // Returns the start address of the remembered set area.
160
+ Address RSetStart() { return address() + kRSetStartOffset; }
161
+
162
+ // Returns the end address of the remembered set area (exclusive).
163
+ Address RSetEnd() { return address() + kRSetEndOffset; }
164
+
165
+ // Checks whether an address is page aligned.
166
+ static bool IsAlignedToPageSize(Address a) {
167
+ return 0 == (OffsetFrom(a) & kPageAlignmentMask);
168
+ }
169
+
170
+ // True if this page is a large object page.
171
+ bool IsLargeObjectPage() { return (is_normal_page & 0x1) == 0; }
172
+
173
+ // Returns the offset of a given address to this page.
174
+ INLINE(int Offset(Address a)) {
175
+ int offset = static_cast<int>(a - address());
176
+ ASSERT_PAGE_OFFSET(offset);
177
+ return offset;
178
+ }
179
+
180
+ // Returns the address for a given offset to the this page.
181
+ Address OffsetToAddress(int offset) {
182
+ ASSERT_PAGE_OFFSET(offset);
183
+ return address() + offset;
184
+ }
185
+
186
+ // ---------------------------------------------------------------------
187
+ // Remembered set support
188
+
189
+ // Clears remembered set in this page.
190
+ inline void ClearRSet();
191
+
192
+ // Return the address of the remembered set word corresponding to an
193
+ // object address/offset pair, and the bit encoded as a single-bit
194
+ // mask in the output parameter 'bitmask'.
195
+ INLINE(static Address ComputeRSetBitPosition(Address address, int offset,
196
+ uint32_t* bitmask));
197
+
198
+ // Sets the corresponding remembered set bit for a given address.
199
+ INLINE(static void SetRSet(Address address, int offset));
200
+
201
+ // Clears the corresponding remembered set bit for a given address.
202
+ static inline void UnsetRSet(Address address, int offset);
203
+
204
+ // Checks whether the remembered set bit for a given address is set.
205
+ static inline bool IsRSetSet(Address address, int offset);
206
+
207
+ #ifdef DEBUG
208
+ // Use a state to mark whether remembered set space can be used for other
209
+ // purposes.
210
+ enum RSetState { IN_USE, NOT_IN_USE };
211
+ static bool is_rset_in_use() { return rset_state_ == IN_USE; }
212
+ static void set_rset_state(RSetState state) { rset_state_ = state; }
213
+ #endif
214
+
215
+ // Page size in bytes. This must be a multiple of the OS page size.
216
+ static const int kPageSize = 1 << kPageSizeBits;
217
+
218
+ // Page size mask.
219
+ static const intptr_t kPageAlignmentMask = (1 << kPageSizeBits) - 1;
220
+
221
+ // The offset of the remembered set in a page, in addition to the empty bytes
222
+ // formed as the remembered bits of the remembered set itself.
223
+ #ifdef V8_TARGET_ARCH_X64
224
+ static const int kRSetOffset = 4 * kPointerSize; // Room for four pointers.
225
+ #else
226
+ static const int kRSetOffset = 0;
227
+ #endif
228
+ // The end offset of the remembered set in a page
229
+ // (heaps are aligned to pointer size).
230
+ static const int kRSetEndOffset = kRSetOffset + kPageSize / kBitsPerPointer;
231
+
232
+ // The start offset of the object area in a page.
233
+ // This needs to be at least (bits per uint32_t) * kBitsPerPointer,
234
+ // to align start of rset to a uint32_t address.
235
+ static const int kObjectStartOffset = 256;
236
+
237
+ // The start offset of the used part of the remembered set in a page.
238
+ static const int kRSetStartOffset = kRSetOffset +
239
+ kObjectStartOffset / kBitsPerPointer;
240
+
241
+ // Object area size in bytes.
242
+ static const int kObjectAreaSize = kPageSize - kObjectStartOffset;
243
+
244
+ // Maximum object size that fits in a page.
245
+ static const int kMaxHeapObjectSize = kObjectAreaSize;
246
+
247
+ //---------------------------------------------------------------------------
248
+ // Page header description.
249
+ //
250
+ // If a page is not in the large object space, the first word,
251
+ // opaque_header, encodes the next page address (aligned to kPageSize 8K)
252
+ // and the chunk number (0 ~ 8K-1). Only MemoryAllocator should use
253
+ // opaque_header. The value range of the opaque_header is [0..kPageSize[,
254
+ // or [next_page_start, next_page_end[. It cannot point to a valid address
255
+ // in the current page. If a page is in the large object space, the first
256
+ // word *may* (if the page start and large object chunk start are the
257
+ // same) contain the address of the next large object chunk.
258
+ intptr_t opaque_header;
259
+
260
+ // If the page is not in the large object space, the low-order bit of the
261
+ // second word is set. If the page is in the large object space, the
262
+ // second word *may* (if the page start and large object chunk start are
263
+ // the same) contain the large object chunk size. In either case, the
264
+ // low-order bit for large object pages will be cleared.
265
+ int is_normal_page;
266
+
267
+ // The following fields may overlap with remembered set, they can only
268
+ // be used in the mark-compact collector when remembered set is not
269
+ // used.
270
+
271
+ // The index of the page in its owner space.
272
+ int mc_page_index;
273
+
274
+ // The allocation pointer after relocating objects to this page.
275
+ Address mc_relocation_top;
276
+
277
+ // The forwarding address of the first live object in this page.
278
+ Address mc_first_forwarded;
279
+
280
+ #ifdef DEBUG
281
+ private:
282
+ static RSetState rset_state_; // state of the remembered set
283
+ #endif
284
+ };
285
+
286
+
287
+ // ----------------------------------------------------------------------------
288
+ // Space is the abstract superclass for all allocation spaces.
289
+ class Space : public Malloced {
290
+ public:
291
+ Space(AllocationSpace id, Executability executable)
292
+ : id_(id), executable_(executable) {}
293
+
294
+ virtual ~Space() {}
295
+
296
+ // Does the space need executable memory?
297
+ Executability executable() { return executable_; }
298
+
299
+ // Identity used in error reporting.
300
+ AllocationSpace identity() { return id_; }
301
+
302
+ virtual int Size() = 0;
303
+
304
+ #ifdef DEBUG
305
+ virtual void Print() = 0;
306
+ #endif
307
+
308
+ // After calling this we can allocate a certain number of bytes using only
309
+ // linear allocation (with a LinearAllocationScope and an AlwaysAllocateScope)
310
+ // without using freelists or causing a GC. This is used by partial
311
+ // snapshots. It returns true of space was reserved or false if a GC is
312
+ // needed. For paged spaces the space requested must include the space wasted
313
+ // at the end of each when allocating linearly.
314
+ virtual bool ReserveSpace(int bytes) = 0;
315
+
316
+ private:
317
+ AllocationSpace id_;
318
+ Executability executable_;
319
+ };
320
+
321
+
322
+ // ----------------------------------------------------------------------------
323
+ // All heap objects containing executable code (code objects) must be allocated
324
+ // from a 2 GB range of memory, so that they can call each other using 32-bit
325
+ // displacements. This happens automatically on 32-bit platforms, where 32-bit
326
+ // displacements cover the entire 4GB virtual address space. On 64-bit
327
+ // platforms, we support this using the CodeRange object, which reserves and
328
+ // manages a range of virtual memory.
329
+ class CodeRange : public AllStatic {
330
+ public:
331
+ // Reserves a range of virtual memory, but does not commit any of it.
332
+ // Can only be called once, at heap initialization time.
333
+ // Returns false on failure.
334
+ static bool Setup(const size_t requested_size);
335
+
336
+ // Frees the range of virtual memory, and frees the data structures used to
337
+ // manage it.
338
+ static void TearDown();
339
+
340
+ static bool exists() { return code_range_ != NULL; }
341
+ static bool contains(Address address) {
342
+ if (code_range_ == NULL) return false;
343
+ Address start = static_cast<Address>(code_range_->address());
344
+ return start <= address && address < start + code_range_->size();
345
+ }
346
+
347
+ // Allocates a chunk of memory from the large-object portion of
348
+ // the code range. On platforms with no separate code range, should
349
+ // not be called.
350
+ static void* AllocateRawMemory(const size_t requested, size_t* allocated);
351
+ static void FreeRawMemory(void* buf, size_t length);
352
+
353
+ private:
354
+ // The reserved range of virtual memory that all code objects are put in.
355
+ static VirtualMemory* code_range_;
356
+ // Plain old data class, just a struct plus a constructor.
357
+ class FreeBlock {
358
+ public:
359
+ FreeBlock(Address start_arg, size_t size_arg)
360
+ : start(start_arg), size(size_arg) {}
361
+ FreeBlock(void* start_arg, size_t size_arg)
362
+ : start(static_cast<Address>(start_arg)), size(size_arg) {}
363
+
364
+ Address start;
365
+ size_t size;
366
+ };
367
+
368
+ // Freed blocks of memory are added to the free list. When the allocation
369
+ // list is exhausted, the free list is sorted and merged to make the new
370
+ // allocation list.
371
+ static List<FreeBlock> free_list_;
372
+ // Memory is allocated from the free blocks on the allocation list.
373
+ // The block at current_allocation_block_index_ is the current block.
374
+ static List<FreeBlock> allocation_list_;
375
+ static int current_allocation_block_index_;
376
+
377
+ // Finds a block on the allocation list that contains at least the
378
+ // requested amount of memory. If none is found, sorts and merges
379
+ // the existing free memory blocks, and searches again.
380
+ // If none can be found, terminates V8 with FatalProcessOutOfMemory.
381
+ static void GetNextAllocationBlock(size_t requested);
382
+ // Compares the start addresses of two free blocks.
383
+ static int CompareFreeBlockAddress(const FreeBlock* left,
384
+ const FreeBlock* right);
385
+ };
386
+
387
+
388
+ // ----------------------------------------------------------------------------
389
+ // A space acquires chunks of memory from the operating system. The memory
390
+ // allocator manages chunks for the paged heap spaces (old space and map
391
+ // space). A paged chunk consists of pages. Pages in a chunk have contiguous
392
+ // addresses and are linked as a list.
393
+ //
394
+ // The allocator keeps an initial chunk which is used for the new space. The
395
+ // leftover regions of the initial chunk are used for the initial chunks of
396
+ // old space and map space if they are big enough to hold at least one page.
397
+ // The allocator assumes that there is one old space and one map space, each
398
+ // expands the space by allocating kPagesPerChunk pages except the last
399
+ // expansion (before running out of space). The first chunk may contain fewer
400
+ // than kPagesPerChunk pages as well.
401
+ //
402
+ // The memory allocator also allocates chunks for the large object space, but
403
+ // they are managed by the space itself. The new space does not expand.
404
+
405
+ class MemoryAllocator : public AllStatic {
406
+ public:
407
+ // Initializes its internal bookkeeping structures.
408
+ // Max capacity of the total space.
409
+ static bool Setup(int max_capacity);
410
+
411
+ // Deletes valid chunks.
412
+ static void TearDown();
413
+
414
+ // Reserves an initial address range of virtual memory to be split between
415
+ // the two new space semispaces, the old space, and the map space. The
416
+ // memory is not yet committed or assigned to spaces and split into pages.
417
+ // The initial chunk is unmapped when the memory allocator is torn down.
418
+ // This function should only be called when there is not already a reserved
419
+ // initial chunk (initial_chunk_ should be NULL). It returns the start
420
+ // address of the initial chunk if successful, with the side effect of
421
+ // setting the initial chunk, or else NULL if unsuccessful and leaves the
422
+ // initial chunk NULL.
423
+ static void* ReserveInitialChunk(const size_t requested);
424
+
425
+ // Commits pages from an as-yet-unmanaged block of virtual memory into a
426
+ // paged space. The block should be part of the initial chunk reserved via
427
+ // a call to ReserveInitialChunk. The number of pages is always returned in
428
+ // the output parameter num_pages. This function assumes that the start
429
+ // address is non-null and that it is big enough to hold at least one
430
+ // page-aligned page. The call always succeeds, and num_pages is always
431
+ // greater than zero.
432
+ static Page* CommitPages(Address start, size_t size, PagedSpace* owner,
433
+ int* num_pages);
434
+
435
+ // Commit a contiguous block of memory from the initial chunk. Assumes that
436
+ // the address is not NULL, the size is greater than zero, and that the
437
+ // block is contained in the initial chunk. Returns true if it succeeded
438
+ // and false otherwise.
439
+ static bool CommitBlock(Address start, size_t size, Executability executable);
440
+
441
+
442
+ // Uncommit a contiguous block of memory [start..(start+size)[.
443
+ // start is not NULL, the size is greater than zero, and the
444
+ // block is contained in the initial chunk. Returns true if it succeeded
445
+ // and false otherwise.
446
+ static bool UncommitBlock(Address start, size_t size);
447
+
448
+ // Attempts to allocate the requested (non-zero) number of pages from the
449
+ // OS. Fewer pages might be allocated than requested. If it fails to
450
+ // allocate memory for the OS or cannot allocate a single page, this
451
+ // function returns an invalid page pointer (NULL). The caller must check
452
+ // whether the returned page is valid (by calling Page::is_valid()). It is
453
+ // guaranteed that allocated pages have contiguous addresses. The actual
454
+ // number of allocated pages is returned in the output parameter
455
+ // allocated_pages. If the PagedSpace owner is executable and there is
456
+ // a code range, the pages are allocated from the code range.
457
+ static Page* AllocatePages(int requested_pages, int* allocated_pages,
458
+ PagedSpace* owner);
459
+
460
+ // Frees pages from a given page and after. If 'p' is the first page
461
+ // of a chunk, pages from 'p' are freed and this function returns an
462
+ // invalid page pointer. Otherwise, the function searches a page
463
+ // after 'p' that is the first page of a chunk. Pages after the
464
+ // found page are freed and the function returns 'p'.
465
+ static Page* FreePages(Page* p);
466
+
467
+ // Allocates and frees raw memory of certain size.
468
+ // These are just thin wrappers around OS::Allocate and OS::Free,
469
+ // but keep track of allocated bytes as part of heap.
470
+ // If the flag is EXECUTABLE and a code range exists, the requested
471
+ // memory is allocated from the code range. If a code range exists
472
+ // and the freed memory is in it, the code range manages the freed memory.
473
+ static void* AllocateRawMemory(const size_t requested,
474
+ size_t* allocated,
475
+ Executability executable);
476
+ static void FreeRawMemory(void* buf, size_t length);
477
+
478
+ // Returns the maximum available bytes of heaps.
479
+ static int Available() { return capacity_ < size_ ? 0 : capacity_ - size_; }
480
+
481
+ // Returns allocated spaces in bytes.
482
+ static int Size() { return size_; }
483
+
484
+ // Returns maximum available bytes that the old space can have.
485
+ static int MaxAvailable() {
486
+ return (Available() / Page::kPageSize) * Page::kObjectAreaSize;
487
+ }
488
+
489
+ // Links two pages.
490
+ static inline void SetNextPage(Page* prev, Page* next);
491
+
492
+ // Returns the next page of a given page.
493
+ static inline Page* GetNextPage(Page* p);
494
+
495
+ // Checks whether a page belongs to a space.
496
+ static inline bool IsPageInSpace(Page* p, PagedSpace* space);
497
+
498
+ // Returns the space that owns the given page.
499
+ static inline PagedSpace* PageOwner(Page* page);
500
+
501
+ // Finds the first/last page in the same chunk as a given page.
502
+ static Page* FindFirstPageInSameChunk(Page* p);
503
+ static Page* FindLastPageInSameChunk(Page* p);
504
+
505
+ #ifdef ENABLE_HEAP_PROTECTION
506
+ // Protect/unprotect a block of memory by marking it read-only/writable.
507
+ static inline void Protect(Address start, size_t size);
508
+ static inline void Unprotect(Address start, size_t size,
509
+ Executability executable);
510
+
511
+ // Protect/unprotect a chunk given a page in the chunk.
512
+ static inline void ProtectChunkFromPage(Page* page);
513
+ static inline void UnprotectChunkFromPage(Page* page);
514
+ #endif
515
+
516
+ #ifdef DEBUG
517
+ // Reports statistic info of the space.
518
+ static void ReportStatistics();
519
+ #endif
520
+
521
+ // Due to encoding limitation, we can only have 8K chunks.
522
+ static const int kMaxNofChunks = 1 << kPageSizeBits;
523
+ // If a chunk has at least 16 pages, the maximum heap size is about
524
+ // 8K * 8K * 16 = 1G bytes.
525
+ #ifdef V8_TARGET_ARCH_X64
526
+ static const int kPagesPerChunk = 32;
527
+ #else
528
+ static const int kPagesPerChunk = 16;
529
+ #endif
530
+ static const int kChunkSize = kPagesPerChunk * Page::kPageSize;
531
+
532
+ private:
533
+ // Maximum space size in bytes.
534
+ static int capacity_;
535
+
536
+ // Allocated space size in bytes.
537
+ static int size_;
538
+
539
+ // The initial chunk of virtual memory.
540
+ static VirtualMemory* initial_chunk_;
541
+
542
+ // Allocated chunk info: chunk start address, chunk size, and owning space.
543
+ class ChunkInfo BASE_EMBEDDED {
544
+ public:
545
+ ChunkInfo() : address_(NULL), size_(0), owner_(NULL) {}
546
+ void init(Address a, size_t s, PagedSpace* o) {
547
+ address_ = a;
548
+ size_ = s;
549
+ owner_ = o;
550
+ }
551
+ Address address() { return address_; }
552
+ size_t size() { return size_; }
553
+ PagedSpace* owner() { return owner_; }
554
+
555
+ private:
556
+ Address address_;
557
+ size_t size_;
558
+ PagedSpace* owner_;
559
+ };
560
+
561
+ // Chunks_, free_chunk_ids_ and top_ act as a stack of free chunk ids.
562
+ static List<ChunkInfo> chunks_;
563
+ static List<int> free_chunk_ids_;
564
+ static int max_nof_chunks_;
565
+ static int top_;
566
+
567
+ // Push/pop a free chunk id onto/from the stack.
568
+ static void Push(int free_chunk_id);
569
+ static int Pop();
570
+ static bool OutOfChunkIds() { return top_ == 0; }
571
+
572
+ // Frees a chunk.
573
+ static void DeleteChunk(int chunk_id);
574
+
575
+ // Basic check whether a chunk id is in the valid range.
576
+ static inline bool IsValidChunkId(int chunk_id);
577
+
578
+ // Checks whether a chunk id identifies an allocated chunk.
579
+ static inline bool IsValidChunk(int chunk_id);
580
+
581
+ // Returns the chunk id that a page belongs to.
582
+ static inline int GetChunkId(Page* p);
583
+
584
+ // True if the address lies in the initial chunk.
585
+ static inline bool InInitialChunk(Address address);
586
+
587
+ // Initializes pages in a chunk. Returns the first page address.
588
+ // This function and GetChunkId() are provided for the mark-compact
589
+ // collector to rebuild page headers in the from space, which is
590
+ // used as a marking stack and its page headers are destroyed.
591
+ static Page* InitializePagesInChunk(int chunk_id, int pages_in_chunk,
592
+ PagedSpace* owner);
593
+ };
594
+
595
+
596
+ // -----------------------------------------------------------------------------
597
+ // Interface for heap object iterator to be implemented by all object space
598
+ // object iterators.
599
+ //
600
+ // NOTE: The space specific object iterators also implements the own has_next()
601
+ // and next() methods which are used to avoid using virtual functions
602
+ // iterating a specific space.
603
+
604
+ class ObjectIterator : public Malloced {
605
+ public:
606
+ virtual ~ObjectIterator() { }
607
+
608
+ virtual bool has_next_object() = 0;
609
+ virtual HeapObject* next_object() = 0;
610
+ };
611
+
612
+
613
+ // -----------------------------------------------------------------------------
614
+ // Heap object iterator in new/old/map spaces.
615
+ //
616
+ // A HeapObjectIterator iterates objects from a given address to the
617
+ // top of a space. The given address must be below the current
618
+ // allocation pointer (space top). There are some caveats.
619
+ //
620
+ // (1) If the space top changes upward during iteration (because of
621
+ // allocating new objects), the iterator does not iterate objects
622
+ // above the original space top. The caller must create a new
623
+ // iterator starting from the old top in order to visit these new
624
+ // objects.
625
+ //
626
+ // (2) If new objects are allocated below the original allocation top
627
+ // (e.g., free-list allocation in paged spaces), the new objects
628
+ // may or may not be iterated depending on their position with
629
+ // respect to the current point of iteration.
630
+ //
631
+ // (3) The space top should not change downward during iteration,
632
+ // otherwise the iterator will return not-necessarily-valid
633
+ // objects.
634
+
635
+ class HeapObjectIterator: public ObjectIterator {
636
+ public:
637
+ // Creates a new object iterator in a given space. If a start
638
+ // address is not given, the iterator starts from the space bottom.
639
+ // If the size function is not given, the iterator calls the default
640
+ // Object::Size().
641
+ explicit HeapObjectIterator(PagedSpace* space);
642
+ HeapObjectIterator(PagedSpace* space, HeapObjectCallback size_func);
643
+ HeapObjectIterator(PagedSpace* space, Address start);
644
+ HeapObjectIterator(PagedSpace* space,
645
+ Address start,
646
+ HeapObjectCallback size_func);
647
+
648
+ inline bool has_next();
649
+ inline HeapObject* next();
650
+
651
+ // implementation of ObjectIterator.
652
+ virtual bool has_next_object() { return has_next(); }
653
+ virtual HeapObject* next_object() { return next(); }
654
+
655
+ private:
656
+ Address cur_addr_; // current iteration point
657
+ Address end_addr_; // end iteration point
658
+ Address cur_limit_; // current page limit
659
+ HeapObjectCallback size_func_; // size function
660
+ Page* end_page_; // caches the page of the end address
661
+
662
+ // Slow path of has_next, checks whether there are more objects in
663
+ // the next page.
664
+ bool HasNextInNextPage();
665
+
666
+ // Initializes fields.
667
+ void Initialize(Address start, Address end, HeapObjectCallback size_func);
668
+
669
+ #ifdef DEBUG
670
+ // Verifies whether fields have valid values.
671
+ void Verify();
672
+ #endif
673
+ };
674
+
675
+
676
+ // -----------------------------------------------------------------------------
677
+ // A PageIterator iterates the pages in a paged space.
678
+ //
679
+ // The PageIterator class provides three modes for iterating pages in a space:
680
+ // PAGES_IN_USE iterates pages containing allocated objects.
681
+ // PAGES_USED_BY_MC iterates pages that hold relocated objects during a
682
+ // mark-compact collection.
683
+ // ALL_PAGES iterates all pages in the space.
684
+ //
685
+ // There are some caveats.
686
+ //
687
+ // (1) If the space expands during iteration, new pages will not be
688
+ // returned by the iterator in any mode.
689
+ //
690
+ // (2) If new objects are allocated during iteration, they will appear
691
+ // in pages returned by the iterator. Allocation may cause the
692
+ // allocation pointer or MC allocation pointer in the last page to
693
+ // change between constructing the iterator and iterating the last
694
+ // page.
695
+ //
696
+ // (3) The space should not shrink during iteration, otherwise the
697
+ // iterator will return deallocated pages.
698
+
699
+ class PageIterator BASE_EMBEDDED {
700
+ public:
701
+ enum Mode {
702
+ PAGES_IN_USE,
703
+ PAGES_USED_BY_MC,
704
+ ALL_PAGES
705
+ };
706
+
707
+ PageIterator(PagedSpace* space, Mode mode);
708
+
709
+ inline bool has_next();
710
+ inline Page* next();
711
+
712
+ private:
713
+ PagedSpace* space_;
714
+ Page* prev_page_; // Previous page returned.
715
+ Page* stop_page_; // Page to stop at (last page returned by the iterator).
716
+ };
717
+
718
+
719
+ // -----------------------------------------------------------------------------
720
+ // A space has a list of pages. The next page can be accessed via
721
+ // Page::next_page() call. The next page of the last page is an
722
+ // invalid page pointer. A space can expand and shrink dynamically.
723
+
724
+ // An abstraction of allocation and relocation pointers in a page-structured
725
+ // space.
726
+ class AllocationInfo {
727
+ public:
728
+ Address top; // current allocation top
729
+ Address limit; // current allocation limit
730
+
731
+ #ifdef DEBUG
732
+ bool VerifyPagedAllocation() {
733
+ return (Page::FromAllocationTop(top) == Page::FromAllocationTop(limit))
734
+ && (top <= limit);
735
+ }
736
+ #endif
737
+ };
738
+
739
+
740
+ // An abstraction of the accounting statistics of a page-structured space.
741
+ // The 'capacity' of a space is the number of object-area bytes (ie, not
742
+ // including page bookkeeping structures) currently in the space. The 'size'
743
+ // of a space is the number of allocated bytes, the 'waste' in the space is
744
+ // the number of bytes that are not allocated and not available to
745
+ // allocation without reorganizing the space via a GC (eg, small blocks due
746
+ // to internal fragmentation, top of page areas in map space), and the bytes
747
+ // 'available' is the number of unallocated bytes that are not waste. The
748
+ // capacity is the sum of size, waste, and available.
749
+ //
750
+ // The stats are only set by functions that ensure they stay balanced. These
751
+ // functions increase or decrease one of the non-capacity stats in
752
+ // conjunction with capacity, or else they always balance increases and
753
+ // decreases to the non-capacity stats.
754
+ class AllocationStats BASE_EMBEDDED {
755
+ public:
756
+ AllocationStats() { Clear(); }
757
+
758
+ // Zero out all the allocation statistics (ie, no capacity).
759
+ void Clear() {
760
+ capacity_ = 0;
761
+ available_ = 0;
762
+ size_ = 0;
763
+ waste_ = 0;
764
+ }
765
+
766
+ // Reset the allocation statistics (ie, available = capacity with no
767
+ // wasted or allocated bytes).
768
+ void Reset() {
769
+ available_ = capacity_;
770
+ size_ = 0;
771
+ waste_ = 0;
772
+ }
773
+
774
+ // Accessors for the allocation statistics.
775
+ int Capacity() { return capacity_; }
776
+ int Available() { return available_; }
777
+ int Size() { return size_; }
778
+ int Waste() { return waste_; }
779
+
780
+ // Grow the space by adding available bytes.
781
+ void ExpandSpace(int size_in_bytes) {
782
+ capacity_ += size_in_bytes;
783
+ available_ += size_in_bytes;
784
+ }
785
+
786
+ // Shrink the space by removing available bytes.
787
+ void ShrinkSpace(int size_in_bytes) {
788
+ capacity_ -= size_in_bytes;
789
+ available_ -= size_in_bytes;
790
+ }
791
+
792
+ // Allocate from available bytes (available -> size).
793
+ void AllocateBytes(int size_in_bytes) {
794
+ available_ -= size_in_bytes;
795
+ size_ += size_in_bytes;
796
+ }
797
+
798
+ // Free allocated bytes, making them available (size -> available).
799
+ void DeallocateBytes(int size_in_bytes) {
800
+ size_ -= size_in_bytes;
801
+ available_ += size_in_bytes;
802
+ }
803
+
804
+ // Waste free bytes (available -> waste).
805
+ void WasteBytes(int size_in_bytes) {
806
+ available_ -= size_in_bytes;
807
+ waste_ += size_in_bytes;
808
+ }
809
+
810
+ // Consider the wasted bytes to be allocated, as they contain filler
811
+ // objects (waste -> size).
812
+ void FillWastedBytes(int size_in_bytes) {
813
+ waste_ -= size_in_bytes;
814
+ size_ += size_in_bytes;
815
+ }
816
+
817
+ private:
818
+ int capacity_;
819
+ int available_;
820
+ int size_;
821
+ int waste_;
822
+ };
823
+
824
+
825
+ class PagedSpace : public Space {
826
+ public:
827
+ // Creates a space with a maximum capacity, and an id.
828
+ PagedSpace(int max_capacity, AllocationSpace id, Executability executable);
829
+
830
+ virtual ~PagedSpace() {}
831
+
832
+ // Set up the space using the given address range of virtual memory (from
833
+ // the memory allocator's initial chunk) if possible. If the block of
834
+ // addresses is not big enough to contain a single page-aligned page, a
835
+ // fresh chunk will be allocated.
836
+ bool Setup(Address start, size_t size);
837
+
838
+ // Returns true if the space has been successfully set up and not
839
+ // subsequently torn down.
840
+ bool HasBeenSetup();
841
+
842
+ // Cleans up the space, frees all pages in this space except those belonging
843
+ // to the initial chunk, uncommits addresses in the initial chunk.
844
+ void TearDown();
845
+
846
+ // Checks whether an object/address is in this space.
847
+ inline bool Contains(Address a);
848
+ bool Contains(HeapObject* o) { return Contains(o->address()); }
849
+
850
+ // Given an address occupied by a live object, return that object if it is
851
+ // in this space, or Failure::Exception() if it is not. The implementation
852
+ // iterates over objects in the page containing the address, the cost is
853
+ // linear in the number of objects in the page. It may be slow.
854
+ Object* FindObject(Address addr);
855
+
856
+ // Checks whether page is currently in use by this space.
857
+ bool IsUsed(Page* page);
858
+
859
+ // Clears remembered sets of pages in this space.
860
+ void ClearRSet();
861
+
862
+ // Prepares for a mark-compact GC.
863
+ virtual void PrepareForMarkCompact(bool will_compact) = 0;
864
+
865
+ virtual Address PageAllocationTop(Page* page) = 0;
866
+
867
+ // Current capacity without growing (Size() + Available() + Waste()).
868
+ int Capacity() { return accounting_stats_.Capacity(); }
869
+
870
+ // Total amount of memory committed for this space. For paged
871
+ // spaces this equals the capacity.
872
+ int CommittedMemory() { return Capacity(); }
873
+
874
+ // Available bytes without growing.
875
+ int Available() { return accounting_stats_.Available(); }
876
+
877
+ // Allocated bytes in this space.
878
+ virtual int Size() { return accounting_stats_.Size(); }
879
+
880
+ // Wasted bytes due to fragmentation and not recoverable until the
881
+ // next GC of this space.
882
+ int Waste() { return accounting_stats_.Waste(); }
883
+
884
+ // Returns the address of the first object in this space.
885
+ Address bottom() { return first_page_->ObjectAreaStart(); }
886
+
887
+ // Returns the allocation pointer in this space.
888
+ Address top() { return allocation_info_.top; }
889
+
890
+ // Allocate the requested number of bytes in the space if possible, return a
891
+ // failure object if not.
892
+ inline Object* AllocateRaw(int size_in_bytes);
893
+
894
+ // Allocate the requested number of bytes for relocation during mark-compact
895
+ // collection.
896
+ inline Object* MCAllocateRaw(int size_in_bytes);
897
+
898
+ virtual bool ReserveSpace(int bytes);
899
+
900
+ // Used by ReserveSpace.
901
+ virtual void PutRestOfCurrentPageOnFreeList(Page* current_page) = 0;
902
+
903
+ // ---------------------------------------------------------------------------
904
+ // Mark-compact collection support functions
905
+
906
+ // Set the relocation point to the beginning of the space.
907
+ void MCResetRelocationInfo();
908
+
909
+ // Writes relocation info to the top page.
910
+ void MCWriteRelocationInfoToPage() {
911
+ TopPageOf(mc_forwarding_info_)->mc_relocation_top = mc_forwarding_info_.top;
912
+ }
913
+
914
+ // Computes the offset of a given address in this space to the beginning
915
+ // of the space.
916
+ int MCSpaceOffsetForAddress(Address addr);
917
+
918
+ // Updates the allocation pointer to the relocation top after a mark-compact
919
+ // collection.
920
+ virtual void MCCommitRelocationInfo() = 0;
921
+
922
+ // Releases half of unused pages.
923
+ void Shrink();
924
+
925
+ // Ensures that the capacity is at least 'capacity'. Returns false on failure.
926
+ bool EnsureCapacity(int capacity);
927
+
928
+ #ifdef ENABLE_HEAP_PROTECTION
929
+ // Protect/unprotect the space by marking it read-only/writable.
930
+ void Protect();
931
+ void Unprotect();
932
+ #endif
933
+
934
+ #ifdef DEBUG
935
+ // Print meta info and objects in this space.
936
+ virtual void Print();
937
+
938
+ // Verify integrity of this space.
939
+ virtual void Verify(ObjectVisitor* visitor);
940
+
941
+ // Overridden by subclasses to verify space-specific object
942
+ // properties (e.g., only maps or free-list nodes are in map space).
943
+ virtual void VerifyObject(HeapObject* obj) {}
944
+
945
+ // Report code object related statistics
946
+ void CollectCodeStatistics();
947
+ static void ReportCodeStatistics();
948
+ static void ResetCodeStatistics();
949
+ #endif
950
+
951
+ protected:
952
+ // Maximum capacity of this space.
953
+ int max_capacity_;
954
+
955
+ // Accounting information for this space.
956
+ AllocationStats accounting_stats_;
957
+
958
+ // The first page in this space.
959
+ Page* first_page_;
960
+
961
+ // The last page in this space. Initially set in Setup, updated in
962
+ // Expand and Shrink.
963
+ Page* last_page_;
964
+
965
+ // Normal allocation information.
966
+ AllocationInfo allocation_info_;
967
+
968
+ // Relocation information during mark-compact collections.
969
+ AllocationInfo mc_forwarding_info_;
970
+
971
+ // Bytes of each page that cannot be allocated. Possibly non-zero
972
+ // for pages in spaces with only fixed-size objects. Always zero
973
+ // for pages in spaces with variable sized objects (those pages are
974
+ // padded with free-list nodes).
975
+ int page_extra_;
976
+
977
+ // Sets allocation pointer to a page bottom.
978
+ static void SetAllocationInfo(AllocationInfo* alloc_info, Page* p);
979
+
980
+ // Returns the top page specified by an allocation info structure.
981
+ static Page* TopPageOf(AllocationInfo alloc_info) {
982
+ return Page::FromAllocationTop(alloc_info.limit);
983
+ }
984
+
985
+ int CountPagesToTop() {
986
+ Page* p = Page::FromAllocationTop(allocation_info_.top);
987
+ PageIterator it(this, PageIterator::ALL_PAGES);
988
+ int counter = 1;
989
+ while (it.has_next()) {
990
+ if (it.next() == p) return counter;
991
+ counter++;
992
+ }
993
+ UNREACHABLE();
994
+ return -1;
995
+ }
996
+
997
+ // Expands the space by allocating a fixed number of pages. Returns false if
998
+ // it cannot allocate requested number of pages from OS. Newly allocated
999
+ // pages are append to the last_page;
1000
+ bool Expand(Page* last_page);
1001
+
1002
+ // Generic fast case allocation function that tries linear allocation in
1003
+ // the top page of 'alloc_info'. Returns NULL on failure.
1004
+ inline HeapObject* AllocateLinearly(AllocationInfo* alloc_info,
1005
+ int size_in_bytes);
1006
+
1007
+ // During normal allocation or deserialization, roll to the next page in
1008
+ // the space (there is assumed to be one) and allocate there. This
1009
+ // function is space-dependent.
1010
+ virtual HeapObject* AllocateInNextPage(Page* current_page,
1011
+ int size_in_bytes) = 0;
1012
+
1013
+ // Slow path of AllocateRaw. This function is space-dependent.
1014
+ virtual HeapObject* SlowAllocateRaw(int size_in_bytes) = 0;
1015
+
1016
+ // Slow path of MCAllocateRaw.
1017
+ HeapObject* SlowMCAllocateRaw(int size_in_bytes);
1018
+
1019
+ #ifdef DEBUG
1020
+ // Returns the number of total pages in this space.
1021
+ int CountTotalPages();
1022
+
1023
+ void DoPrintRSet(const char* space_name);
1024
+ #endif
1025
+ private:
1026
+ // Returns the page of the allocation pointer.
1027
+ Page* AllocationTopPage() { return TopPageOf(allocation_info_); }
1028
+
1029
+ // Returns a pointer to the page of the relocation pointer.
1030
+ Page* MCRelocationTopPage() { return TopPageOf(mc_forwarding_info_); }
1031
+
1032
+ friend class PageIterator;
1033
+ };
1034
+
1035
+
1036
+ #if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING)
1037
+ class NumberAndSizeInfo BASE_EMBEDDED {
1038
+ public:
1039
+ NumberAndSizeInfo() : number_(0), bytes_(0) {}
1040
+
1041
+ int number() const { return number_; }
1042
+ void increment_number(int num) { number_ += num; }
1043
+
1044
+ int bytes() const { return bytes_; }
1045
+ void increment_bytes(int size) { bytes_ += size; }
1046
+
1047
+ void clear() {
1048
+ number_ = 0;
1049
+ bytes_ = 0;
1050
+ }
1051
+
1052
+ private:
1053
+ int number_;
1054
+ int bytes_;
1055
+ };
1056
+
1057
+
1058
+ // HistogramInfo class for recording a single "bar" of a histogram. This
1059
+ // class is used for collecting statistics to print to stdout (when compiled
1060
+ // with DEBUG) or to the log file (when compiled with
1061
+ // ENABLE_LOGGING_AND_PROFILING).
1062
+ class HistogramInfo: public NumberAndSizeInfo {
1063
+ public:
1064
+ HistogramInfo() : NumberAndSizeInfo() {}
1065
+
1066
+ const char* name() { return name_; }
1067
+ void set_name(const char* name) { name_ = name; }
1068
+
1069
+ private:
1070
+ const char* name_;
1071
+ };
1072
+ #endif
1073
+
1074
+
1075
+ // -----------------------------------------------------------------------------
1076
+ // SemiSpace in young generation
1077
+ //
1078
+ // A semispace is a contiguous chunk of memory. The mark-compact collector
1079
+ // uses the memory in the from space as a marking stack when tracing live
1080
+ // objects.
1081
+
1082
+ class SemiSpace : public Space {
1083
+ public:
1084
+ // Constructor.
1085
+ SemiSpace() :Space(NEW_SPACE, NOT_EXECUTABLE) {
1086
+ start_ = NULL;
1087
+ age_mark_ = NULL;
1088
+ }
1089
+
1090
+ // Sets up the semispace using the given chunk.
1091
+ bool Setup(Address start, int initial_capacity, int maximum_capacity);
1092
+
1093
+ // Tear down the space. Heap memory was not allocated by the space, so it
1094
+ // is not deallocated here.
1095
+ void TearDown();
1096
+
1097
+ // True if the space has been set up but not torn down.
1098
+ bool HasBeenSetup() { return start_ != NULL; }
1099
+
1100
+ // Grow the size of the semispace by committing extra virtual memory.
1101
+ // Assumes that the caller has checked that the semispace has not reached
1102
+ // its maximum capacity (and thus there is space available in the reserved
1103
+ // address range to grow).
1104
+ bool Grow();
1105
+
1106
+ // Grow the semispace to the new capacity. The new capacity
1107
+ // requested must be larger than the current capacity.
1108
+ bool GrowTo(int new_capacity);
1109
+
1110
+ // Shrinks the semispace to the new capacity. The new capacity
1111
+ // requested must be more than the amount of used memory in the
1112
+ // semispace and less than the current capacity.
1113
+ bool ShrinkTo(int new_capacity);
1114
+
1115
+ // Returns the start address of the space.
1116
+ Address low() { return start_; }
1117
+ // Returns one past the end address of the space.
1118
+ Address high() { return low() + capacity_; }
1119
+
1120
+ // Age mark accessors.
1121
+ Address age_mark() { return age_mark_; }
1122
+ void set_age_mark(Address mark) { age_mark_ = mark; }
1123
+
1124
+ // True if the address is in the address range of this semispace (not
1125
+ // necessarily below the allocation pointer).
1126
+ bool Contains(Address a) {
1127
+ return (reinterpret_cast<uintptr_t>(a) & address_mask_)
1128
+ == reinterpret_cast<uintptr_t>(start_);
1129
+ }
1130
+
1131
+ // True if the object is a heap object in the address range of this
1132
+ // semispace (not necessarily below the allocation pointer).
1133
+ bool Contains(Object* o) {
1134
+ return (reinterpret_cast<uintptr_t>(o) & object_mask_) == object_expected_;
1135
+ }
1136
+
1137
+ // The offset of an address from the beginning of the space.
1138
+ int SpaceOffsetForAddress(Address addr) {
1139
+ return static_cast<int>(addr - low());
1140
+ }
1141
+
1142
+ // If we don't have these here then SemiSpace will be abstract. However
1143
+ // they should never be called.
1144
+ virtual int Size() {
1145
+ UNREACHABLE();
1146
+ return 0;
1147
+ }
1148
+
1149
+ virtual bool ReserveSpace(int bytes) {
1150
+ UNREACHABLE();
1151
+ return false;
1152
+ }
1153
+
1154
+ bool is_committed() { return committed_; }
1155
+ bool Commit();
1156
+ bool Uncommit();
1157
+
1158
+ #ifdef DEBUG
1159
+ virtual void Print();
1160
+ virtual void Verify();
1161
+ #endif
1162
+
1163
+ // Returns the current capacity of the semi space.
1164
+ int Capacity() { return capacity_; }
1165
+
1166
+ // Returns the maximum capacity of the semi space.
1167
+ int MaximumCapacity() { return maximum_capacity_; }
1168
+
1169
+ // Returns the initial capacity of the semi space.
1170
+ int InitialCapacity() { return initial_capacity_; }
1171
+
1172
+ private:
1173
+ // The current and maximum capacity of the space.
1174
+ int capacity_;
1175
+ int maximum_capacity_;
1176
+ int initial_capacity_;
1177
+
1178
+ // The start address of the space.
1179
+ Address start_;
1180
+ // Used to govern object promotion during mark-compact collection.
1181
+ Address age_mark_;
1182
+
1183
+ // Masks and comparison values to test for containment in this semispace.
1184
+ uintptr_t address_mask_;
1185
+ uintptr_t object_mask_;
1186
+ uintptr_t object_expected_;
1187
+
1188
+ bool committed_;
1189
+
1190
+ public:
1191
+ TRACK_MEMORY("SemiSpace")
1192
+ };
1193
+
1194
+
1195
+ // A SemiSpaceIterator is an ObjectIterator that iterates over the active
1196
+ // semispace of the heap's new space. It iterates over the objects in the
1197
+ // semispace from a given start address (defaulting to the bottom of the
1198
+ // semispace) to the top of the semispace. New objects allocated after the
1199
+ // iterator is created are not iterated.
1200
+ class SemiSpaceIterator : public ObjectIterator {
1201
+ public:
1202
+ // Create an iterator over the objects in the given space. If no start
1203
+ // address is given, the iterator starts from the bottom of the space. If
1204
+ // no size function is given, the iterator calls Object::Size().
1205
+ explicit SemiSpaceIterator(NewSpace* space);
1206
+ SemiSpaceIterator(NewSpace* space, HeapObjectCallback size_func);
1207
+ SemiSpaceIterator(NewSpace* space, Address start);
1208
+
1209
+ bool has_next() {return current_ < limit_; }
1210
+
1211
+ HeapObject* next() {
1212
+ ASSERT(has_next());
1213
+
1214
+ HeapObject* object = HeapObject::FromAddress(current_);
1215
+ int size = (size_func_ == NULL) ? object->Size() : size_func_(object);
1216
+
1217
+ current_ += size;
1218
+ return object;
1219
+ }
1220
+
1221
+ // Implementation of the ObjectIterator functions.
1222
+ virtual bool has_next_object() { return has_next(); }
1223
+ virtual HeapObject* next_object() { return next(); }
1224
+
1225
+ private:
1226
+ void Initialize(NewSpace* space, Address start, Address end,
1227
+ HeapObjectCallback size_func);
1228
+
1229
+ // The semispace.
1230
+ SemiSpace* space_;
1231
+ // The current iteration point.
1232
+ Address current_;
1233
+ // The end of iteration.
1234
+ Address limit_;
1235
+ // The callback function.
1236
+ HeapObjectCallback size_func_;
1237
+ };
1238
+
1239
+
1240
+ // -----------------------------------------------------------------------------
1241
+ // The young generation space.
1242
+ //
1243
+ // The new space consists of a contiguous pair of semispaces. It simply
1244
+ // forwards most functions to the appropriate semispace.
1245
+
1246
+ class NewSpace : public Space {
1247
+ public:
1248
+ // Constructor.
1249
+ NewSpace() : Space(NEW_SPACE, NOT_EXECUTABLE) {}
1250
+
1251
+ // Sets up the new space using the given chunk.
1252
+ bool Setup(Address start, int size);
1253
+
1254
+ // Tears down the space. Heap memory was not allocated by the space, so it
1255
+ // is not deallocated here.
1256
+ void TearDown();
1257
+
1258
+ // True if the space has been set up but not torn down.
1259
+ bool HasBeenSetup() {
1260
+ return to_space_.HasBeenSetup() && from_space_.HasBeenSetup();
1261
+ }
1262
+
1263
+ // Flip the pair of spaces.
1264
+ void Flip();
1265
+
1266
+ // Grow the capacity of the semispaces. Assumes that they are not at
1267
+ // their maximum capacity.
1268
+ void Grow();
1269
+
1270
+ // Shrink the capacity of the semispaces.
1271
+ void Shrink();
1272
+
1273
+ // True if the address or object lies in the address range of either
1274
+ // semispace (not necessarily below the allocation pointer).
1275
+ bool Contains(Address a) {
1276
+ return (reinterpret_cast<uintptr_t>(a) & address_mask_)
1277
+ == reinterpret_cast<uintptr_t>(start_);
1278
+ }
1279
+ bool Contains(Object* o) {
1280
+ return (reinterpret_cast<uintptr_t>(o) & object_mask_) == object_expected_;
1281
+ }
1282
+
1283
+ // Return the allocated bytes in the active semispace.
1284
+ virtual int Size() { return static_cast<int>(top() - bottom()); }
1285
+
1286
+ // Return the current capacity of a semispace.
1287
+ int Capacity() {
1288
+ ASSERT(to_space_.Capacity() == from_space_.Capacity());
1289
+ return to_space_.Capacity();
1290
+ }
1291
+
1292
+ // Return the total amount of memory committed for new space.
1293
+ int CommittedMemory() {
1294
+ if (from_space_.is_committed()) return 2 * Capacity();
1295
+ return Capacity();
1296
+ }
1297
+
1298
+ // Return the available bytes without growing in the active semispace.
1299
+ int Available() { return Capacity() - Size(); }
1300
+
1301
+ // Return the maximum capacity of a semispace.
1302
+ int MaximumCapacity() {
1303
+ ASSERT(to_space_.MaximumCapacity() == from_space_.MaximumCapacity());
1304
+ return to_space_.MaximumCapacity();
1305
+ }
1306
+
1307
+ // Returns the initial capacity of a semispace.
1308
+ int InitialCapacity() {
1309
+ ASSERT(to_space_.InitialCapacity() == from_space_.InitialCapacity());
1310
+ return to_space_.InitialCapacity();
1311
+ }
1312
+
1313
+ // Return the address of the allocation pointer in the active semispace.
1314
+ Address top() { return allocation_info_.top; }
1315
+ // Return the address of the first object in the active semispace.
1316
+ Address bottom() { return to_space_.low(); }
1317
+
1318
+ // Get the age mark of the inactive semispace.
1319
+ Address age_mark() { return from_space_.age_mark(); }
1320
+ // Set the age mark in the active semispace.
1321
+ void set_age_mark(Address mark) { to_space_.set_age_mark(mark); }
1322
+
1323
+ // The start address of the space and a bit mask. Anding an address in the
1324
+ // new space with the mask will result in the start address.
1325
+ Address start() { return start_; }
1326
+ uintptr_t mask() { return address_mask_; }
1327
+
1328
+ // The allocation top and limit addresses.
1329
+ Address* allocation_top_address() { return &allocation_info_.top; }
1330
+ Address* allocation_limit_address() { return &allocation_info_.limit; }
1331
+
1332
+ Object* AllocateRaw(int size_in_bytes) {
1333
+ return AllocateRawInternal(size_in_bytes, &allocation_info_);
1334
+ }
1335
+
1336
+ // Allocate the requested number of bytes for relocation during mark-compact
1337
+ // collection.
1338
+ Object* MCAllocateRaw(int size_in_bytes) {
1339
+ return AllocateRawInternal(size_in_bytes, &mc_forwarding_info_);
1340
+ }
1341
+
1342
+ // Reset the allocation pointer to the beginning of the active semispace.
1343
+ void ResetAllocationInfo();
1344
+ // Reset the reloction pointer to the bottom of the inactive semispace in
1345
+ // preparation for mark-compact collection.
1346
+ void MCResetRelocationInfo();
1347
+ // Update the allocation pointer in the active semispace after a
1348
+ // mark-compact collection.
1349
+ void MCCommitRelocationInfo();
1350
+
1351
+ // Get the extent of the inactive semispace (for use as a marking stack).
1352
+ Address FromSpaceLow() { return from_space_.low(); }
1353
+ Address FromSpaceHigh() { return from_space_.high(); }
1354
+
1355
+ // Get the extent of the active semispace (to sweep newly copied objects
1356
+ // during a scavenge collection).
1357
+ Address ToSpaceLow() { return to_space_.low(); }
1358
+ Address ToSpaceHigh() { return to_space_.high(); }
1359
+
1360
+ // Offsets from the beginning of the semispaces.
1361
+ int ToSpaceOffsetForAddress(Address a) {
1362
+ return to_space_.SpaceOffsetForAddress(a);
1363
+ }
1364
+ int FromSpaceOffsetForAddress(Address a) {
1365
+ return from_space_.SpaceOffsetForAddress(a);
1366
+ }
1367
+
1368
+ // True if the object is a heap object in the address range of the
1369
+ // respective semispace (not necessarily below the allocation pointer of the
1370
+ // semispace).
1371
+ bool ToSpaceContains(Object* o) { return to_space_.Contains(o); }
1372
+ bool FromSpaceContains(Object* o) { return from_space_.Contains(o); }
1373
+
1374
+ bool ToSpaceContains(Address a) { return to_space_.Contains(a); }
1375
+ bool FromSpaceContains(Address a) { return from_space_.Contains(a); }
1376
+
1377
+ virtual bool ReserveSpace(int bytes);
1378
+
1379
+ #ifdef ENABLE_HEAP_PROTECTION
1380
+ // Protect/unprotect the space by marking it read-only/writable.
1381
+ virtual void Protect();
1382
+ virtual void Unprotect();
1383
+ #endif
1384
+
1385
+ #ifdef DEBUG
1386
+ // Verify the active semispace.
1387
+ virtual void Verify();
1388
+ // Print the active semispace.
1389
+ virtual void Print() { to_space_.Print(); }
1390
+ #endif
1391
+
1392
+ #if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING)
1393
+ // Iterates the active semispace to collect statistics.
1394
+ void CollectStatistics();
1395
+ // Reports previously collected statistics of the active semispace.
1396
+ void ReportStatistics();
1397
+ // Clears previously collected statistics.
1398
+ void ClearHistograms();
1399
+
1400
+ // Record the allocation or promotion of a heap object. Note that we don't
1401
+ // record every single allocation, but only those that happen in the
1402
+ // to space during a scavenge GC.
1403
+ void RecordAllocation(HeapObject* obj);
1404
+ void RecordPromotion(HeapObject* obj);
1405
+ #endif
1406
+
1407
+ // Return whether the operation succeded.
1408
+ bool CommitFromSpaceIfNeeded() {
1409
+ if (from_space_.is_committed()) return true;
1410
+ return from_space_.Commit();
1411
+ }
1412
+
1413
+ bool UncommitFromSpace() {
1414
+ if (!from_space_.is_committed()) return true;
1415
+ return from_space_.Uncommit();
1416
+ }
1417
+
1418
+ private:
1419
+ // The semispaces.
1420
+ SemiSpace to_space_;
1421
+ SemiSpace from_space_;
1422
+
1423
+ // Start address and bit mask for containment testing.
1424
+ Address start_;
1425
+ uintptr_t address_mask_;
1426
+ uintptr_t object_mask_;
1427
+ uintptr_t object_expected_;
1428
+
1429
+ // Allocation pointer and limit for normal allocation and allocation during
1430
+ // mark-compact collection.
1431
+ AllocationInfo allocation_info_;
1432
+ AllocationInfo mc_forwarding_info_;
1433
+
1434
+ #if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING)
1435
+ HistogramInfo* allocated_histogram_;
1436
+ HistogramInfo* promoted_histogram_;
1437
+ #endif
1438
+
1439
+ // Implementation of AllocateRaw and MCAllocateRaw.
1440
+ inline Object* AllocateRawInternal(int size_in_bytes,
1441
+ AllocationInfo* alloc_info);
1442
+
1443
+ friend class SemiSpaceIterator;
1444
+
1445
+ public:
1446
+ TRACK_MEMORY("NewSpace")
1447
+ };
1448
+
1449
+
1450
+ // -----------------------------------------------------------------------------
1451
+ // Free lists for old object spaces
1452
+ //
1453
+ // Free-list nodes are free blocks in the heap. They look like heap objects
1454
+ // (free-list node pointers have the heap object tag, and they have a map like
1455
+ // a heap object). They have a size and a next pointer. The next pointer is
1456
+ // the raw address of the next free list node (or NULL).
1457
+ class FreeListNode: public HeapObject {
1458
+ public:
1459
+ // Obtain a free-list node from a raw address. This is not a cast because
1460
+ // it does not check nor require that the first word at the address is a map
1461
+ // pointer.
1462
+ static FreeListNode* FromAddress(Address address) {
1463
+ return reinterpret_cast<FreeListNode*>(HeapObject::FromAddress(address));
1464
+ }
1465
+
1466
+ static inline bool IsFreeListNode(HeapObject* object);
1467
+
1468
+ // Set the size in bytes, which can be read with HeapObject::Size(). This
1469
+ // function also writes a map to the first word of the block so that it
1470
+ // looks like a heap object to the garbage collector and heap iteration
1471
+ // functions.
1472
+ void set_size(int size_in_bytes);
1473
+
1474
+ // Accessors for the next field.
1475
+ inline Address next();
1476
+ inline void set_next(Address next);
1477
+
1478
+ private:
1479
+ static const int kNextOffset = POINTER_SIZE_ALIGN(ByteArray::kHeaderSize);
1480
+
1481
+ DISALLOW_IMPLICIT_CONSTRUCTORS(FreeListNode);
1482
+ };
1483
+
1484
+
1485
+ // The free list for the old space.
1486
+ class OldSpaceFreeList BASE_EMBEDDED {
1487
+ public:
1488
+ explicit OldSpaceFreeList(AllocationSpace owner);
1489
+
1490
+ // Clear the free list.
1491
+ void Reset();
1492
+
1493
+ // Return the number of bytes available on the free list.
1494
+ int available() { return available_; }
1495
+
1496
+ // Place a node on the free list. The block of size 'size_in_bytes'
1497
+ // starting at 'start' is placed on the free list. The return value is the
1498
+ // number of bytes that have been lost due to internal fragmentation by
1499
+ // freeing the block. Bookkeeping information will be written to the block,
1500
+ // ie, its contents will be destroyed. The start address should be word
1501
+ // aligned, and the size should be a non-zero multiple of the word size.
1502
+ int Free(Address start, int size_in_bytes);
1503
+
1504
+ // Allocate a block of size 'size_in_bytes' from the free list. The block
1505
+ // is unitialized. A failure is returned if no block is available. The
1506
+ // number of bytes lost to fragmentation is returned in the output parameter
1507
+ // 'wasted_bytes'. The size should be a non-zero multiple of the word size.
1508
+ Object* Allocate(int size_in_bytes, int* wasted_bytes);
1509
+
1510
+ private:
1511
+ // The size range of blocks, in bytes. (Smaller allocations are allowed, but
1512
+ // will always result in waste.)
1513
+ static const int kMinBlockSize = 2 * kPointerSize;
1514
+ static const int kMaxBlockSize = Page::kMaxHeapObjectSize;
1515
+
1516
+ // The identity of the owning space, for building allocation Failure
1517
+ // objects.
1518
+ AllocationSpace owner_;
1519
+
1520
+ // Total available bytes in all blocks on this free list.
1521
+ int available_;
1522
+
1523
+ // Blocks are put on exact free lists in an array, indexed by size in words.
1524
+ // The available sizes are kept in an increasingly ordered list. Entries
1525
+ // corresponding to sizes < kMinBlockSize always have an empty free list
1526
+ // (but index kHead is used for the head of the size list).
1527
+ struct SizeNode {
1528
+ // Address of the head FreeListNode of the implied block size or NULL.
1529
+ Address head_node_;
1530
+ // Size (words) of the next larger available size if head_node_ != NULL.
1531
+ int next_size_;
1532
+ };
1533
+ static const int kFreeListsLength = kMaxBlockSize / kPointerSize + 1;
1534
+ SizeNode free_[kFreeListsLength];
1535
+
1536
+ // Sentinel elements for the size list. Real elements are in ]kHead..kEnd[.
1537
+ static const int kHead = kMinBlockSize / kPointerSize - 1;
1538
+ static const int kEnd = kMaxInt;
1539
+
1540
+ // We keep a "finger" in the size list to speed up a common pattern:
1541
+ // repeated requests for the same or increasing sizes.
1542
+ int finger_;
1543
+
1544
+ // Starting from *prev, find and return the smallest size >= index (words),
1545
+ // or kEnd. Update *prev to be the largest size < index, or kHead.
1546
+ int FindSize(int index, int* prev) {
1547
+ int cur = free_[*prev].next_size_;
1548
+ while (cur < index) {
1549
+ *prev = cur;
1550
+ cur = free_[cur].next_size_;
1551
+ }
1552
+ return cur;
1553
+ }
1554
+
1555
+ // Remove an existing element from the size list.
1556
+ void RemoveSize(int index) {
1557
+ int prev = kHead;
1558
+ int cur = FindSize(index, &prev);
1559
+ ASSERT(cur == index);
1560
+ free_[prev].next_size_ = free_[cur].next_size_;
1561
+ finger_ = prev;
1562
+ }
1563
+
1564
+ // Insert a new element into the size list.
1565
+ void InsertSize(int index) {
1566
+ int prev = kHead;
1567
+ int cur = FindSize(index, &prev);
1568
+ ASSERT(cur != index);
1569
+ free_[prev].next_size_ = index;
1570
+ free_[index].next_size_ = cur;
1571
+ }
1572
+
1573
+ // The size list is not updated during a sequence of calls to Free, but is
1574
+ // rebuilt before the next allocation.
1575
+ void RebuildSizeList();
1576
+ bool needs_rebuild_;
1577
+
1578
+ #ifdef DEBUG
1579
+ // Does this free list contain a free block located at the address of 'node'?
1580
+ bool Contains(FreeListNode* node);
1581
+ #endif
1582
+
1583
+ DISALLOW_COPY_AND_ASSIGN(OldSpaceFreeList);
1584
+ };
1585
+
1586
+
1587
+ // The free list for the map space.
1588
+ class FixedSizeFreeList BASE_EMBEDDED {
1589
+ public:
1590
+ FixedSizeFreeList(AllocationSpace owner, int object_size);
1591
+
1592
+ // Clear the free list.
1593
+ void Reset();
1594
+
1595
+ // Return the number of bytes available on the free list.
1596
+ int available() { return available_; }
1597
+
1598
+ // Place a node on the free list. The block starting at 'start' (assumed to
1599
+ // have size object_size_) is placed on the free list. Bookkeeping
1600
+ // information will be written to the block, ie, its contents will be
1601
+ // destroyed. The start address should be word aligned.
1602
+ void Free(Address start);
1603
+
1604
+ // Allocate a fixed sized block from the free list. The block is unitialized.
1605
+ // A failure is returned if no block is available.
1606
+ Object* Allocate();
1607
+
1608
+ private:
1609
+ // Available bytes on the free list.
1610
+ int available_;
1611
+
1612
+ // The head of the free list.
1613
+ Address head_;
1614
+
1615
+ // The identity of the owning space, for building allocation Failure
1616
+ // objects.
1617
+ AllocationSpace owner_;
1618
+
1619
+ // The size of the objects in this space.
1620
+ int object_size_;
1621
+
1622
+ DISALLOW_COPY_AND_ASSIGN(FixedSizeFreeList);
1623
+ };
1624
+
1625
+
1626
+ // -----------------------------------------------------------------------------
1627
+ // Old object space (excluding map objects)
1628
+
1629
+ class OldSpace : public PagedSpace {
1630
+ public:
1631
+ // Creates an old space object with a given maximum capacity.
1632
+ // The constructor does not allocate pages from OS.
1633
+ explicit OldSpace(int max_capacity,
1634
+ AllocationSpace id,
1635
+ Executability executable)
1636
+ : PagedSpace(max_capacity, id, executable), free_list_(id) {
1637
+ page_extra_ = 0;
1638
+ }
1639
+
1640
+ // The bytes available on the free list (ie, not above the linear allocation
1641
+ // pointer).
1642
+ int AvailableFree() { return free_list_.available(); }
1643
+
1644
+ // The top of allocation in a page in this space. Undefined if page is unused.
1645
+ virtual Address PageAllocationTop(Page* page) {
1646
+ return page == TopPageOf(allocation_info_) ? top() : page->ObjectAreaEnd();
1647
+ }
1648
+
1649
+ // Give a block of memory to the space's free list. It might be added to
1650
+ // the free list or accounted as waste.
1651
+ void Free(Address start, int size_in_bytes) {
1652
+ int wasted_bytes = free_list_.Free(start, size_in_bytes);
1653
+ accounting_stats_.DeallocateBytes(size_in_bytes);
1654
+ accounting_stats_.WasteBytes(wasted_bytes);
1655
+ }
1656
+
1657
+ // Prepare for full garbage collection. Resets the relocation pointer and
1658
+ // clears the free list.
1659
+ virtual void PrepareForMarkCompact(bool will_compact);
1660
+
1661
+ // Updates the allocation pointer to the relocation top after a mark-compact
1662
+ // collection.
1663
+ virtual void MCCommitRelocationInfo();
1664
+
1665
+ virtual void PutRestOfCurrentPageOnFreeList(Page* current_page);
1666
+
1667
+ #ifdef DEBUG
1668
+ // Reports statistics for the space
1669
+ void ReportStatistics();
1670
+ // Dump the remembered sets in the space to stdout.
1671
+ void PrintRSet();
1672
+ #endif
1673
+
1674
+ protected:
1675
+ // Virtual function in the superclass. Slow path of AllocateRaw.
1676
+ HeapObject* SlowAllocateRaw(int size_in_bytes);
1677
+
1678
+ // Virtual function in the superclass. Allocate linearly at the start of
1679
+ // the page after current_page (there is assumed to be one).
1680
+ HeapObject* AllocateInNextPage(Page* current_page, int size_in_bytes);
1681
+
1682
+ private:
1683
+ // The space's free list.
1684
+ OldSpaceFreeList free_list_;
1685
+
1686
+ public:
1687
+ TRACK_MEMORY("OldSpace")
1688
+ };
1689
+
1690
+
1691
+ // -----------------------------------------------------------------------------
1692
+ // Old space for objects of a fixed size
1693
+
1694
+ class FixedSpace : public PagedSpace {
1695
+ public:
1696
+ FixedSpace(int max_capacity,
1697
+ AllocationSpace id,
1698
+ int object_size_in_bytes,
1699
+ const char* name)
1700
+ : PagedSpace(max_capacity, id, NOT_EXECUTABLE),
1701
+ object_size_in_bytes_(object_size_in_bytes),
1702
+ name_(name),
1703
+ free_list_(id, object_size_in_bytes) {
1704
+ page_extra_ = Page::kObjectAreaSize % object_size_in_bytes;
1705
+ }
1706
+
1707
+ // The top of allocation in a page in this space. Undefined if page is unused.
1708
+ virtual Address PageAllocationTop(Page* page) {
1709
+ return page == TopPageOf(allocation_info_) ? top()
1710
+ : page->ObjectAreaEnd() - page_extra_;
1711
+ }
1712
+
1713
+ int object_size_in_bytes() { return object_size_in_bytes_; }
1714
+
1715
+ // Give a fixed sized block of memory to the space's free list.
1716
+ void Free(Address start) {
1717
+ free_list_.Free(start);
1718
+ accounting_stats_.DeallocateBytes(object_size_in_bytes_);
1719
+ }
1720
+
1721
+ // Prepares for a mark-compact GC.
1722
+ virtual void PrepareForMarkCompact(bool will_compact);
1723
+
1724
+ // Updates the allocation pointer to the relocation top after a mark-compact
1725
+ // collection.
1726
+ virtual void MCCommitRelocationInfo();
1727
+
1728
+ virtual void PutRestOfCurrentPageOnFreeList(Page* current_page);
1729
+
1730
+ #ifdef DEBUG
1731
+ // Reports statistic info of the space
1732
+ void ReportStatistics();
1733
+
1734
+ // Dump the remembered sets in the space to stdout.
1735
+ void PrintRSet();
1736
+ #endif
1737
+
1738
+ protected:
1739
+ // Virtual function in the superclass. Slow path of AllocateRaw.
1740
+ HeapObject* SlowAllocateRaw(int size_in_bytes);
1741
+
1742
+ // Virtual function in the superclass. Allocate linearly at the start of
1743
+ // the page after current_page (there is assumed to be one).
1744
+ HeapObject* AllocateInNextPage(Page* current_page, int size_in_bytes);
1745
+
1746
+ void ResetFreeList() {
1747
+ free_list_.Reset();
1748
+ }
1749
+
1750
+ private:
1751
+ // The size of objects in this space.
1752
+ int object_size_in_bytes_;
1753
+
1754
+ // The name of this space.
1755
+ const char* name_;
1756
+
1757
+ // The space's free list.
1758
+ FixedSizeFreeList free_list_;
1759
+ };
1760
+
1761
+
1762
+ // -----------------------------------------------------------------------------
1763
+ // Old space for all map objects
1764
+
1765
+ class MapSpace : public FixedSpace {
1766
+ public:
1767
+ // Creates a map space object with a maximum capacity.
1768
+ MapSpace(int max_capacity, int max_map_space_pages, AllocationSpace id)
1769
+ : FixedSpace(max_capacity, id, Map::kSize, "map"),
1770
+ max_map_space_pages_(max_map_space_pages) {
1771
+ ASSERT(max_map_space_pages < kMaxMapPageIndex);
1772
+ }
1773
+
1774
+ // Prepares for a mark-compact GC.
1775
+ virtual void PrepareForMarkCompact(bool will_compact);
1776
+
1777
+ // Given an index, returns the page address.
1778
+ Address PageAddress(int page_index) { return page_addresses_[page_index]; }
1779
+
1780
+ static const int kMaxMapPageIndex = 1 << MapWord::kMapPageIndexBits;
1781
+
1782
+ // Are map pointers encodable into map word?
1783
+ bool MapPointersEncodable() {
1784
+ if (!FLAG_use_big_map_space) {
1785
+ ASSERT(CountPagesToTop() <= kMaxMapPageIndex);
1786
+ return true;
1787
+ }
1788
+ return CountPagesToTop() <= max_map_space_pages_;
1789
+ }
1790
+
1791
+ // Should be called after forced sweep to find out if map space needs
1792
+ // compaction.
1793
+ bool NeedsCompaction(int live_maps) {
1794
+ return !MapPointersEncodable() && live_maps <= CompactionThreshold();
1795
+ }
1796
+
1797
+ Address TopAfterCompaction(int live_maps) {
1798
+ ASSERT(NeedsCompaction(live_maps));
1799
+
1800
+ int pages_left = live_maps / kMapsPerPage;
1801
+ PageIterator it(this, PageIterator::ALL_PAGES);
1802
+ while (pages_left-- > 0) {
1803
+ it.has_next(); // Must be called for side-effects, see bug 586.
1804
+ ASSERT(it.has_next());
1805
+ it.next()->ClearRSet();
1806
+ }
1807
+ it.has_next(); // Must be called for side-effects, see bug 586.
1808
+ ASSERT(it.has_next());
1809
+ Page* top_page = it.next();
1810
+ top_page->ClearRSet();
1811
+ ASSERT(top_page->is_valid());
1812
+
1813
+ int offset = live_maps % kMapsPerPage * Map::kSize;
1814
+ Address top = top_page->ObjectAreaStart() + offset;
1815
+ ASSERT(top < top_page->ObjectAreaEnd());
1816
+ ASSERT(Contains(top));
1817
+
1818
+ return top;
1819
+ }
1820
+
1821
+ void FinishCompaction(Address new_top, int live_maps) {
1822
+ Page* top_page = Page::FromAddress(new_top);
1823
+ ASSERT(top_page->is_valid());
1824
+
1825
+ SetAllocationInfo(&allocation_info_, top_page);
1826
+ allocation_info_.top = new_top;
1827
+
1828
+ int new_size = live_maps * Map::kSize;
1829
+ accounting_stats_.DeallocateBytes(accounting_stats_.Size());
1830
+ accounting_stats_.AllocateBytes(new_size);
1831
+
1832
+ #ifdef DEBUG
1833
+ if (FLAG_enable_slow_asserts) {
1834
+ int actual_size = 0;
1835
+ for (Page* p = first_page_; p != top_page; p = p->next_page())
1836
+ actual_size += kMapsPerPage * Map::kSize;
1837
+ actual_size += (new_top - top_page->ObjectAreaStart());
1838
+ ASSERT(accounting_stats_.Size() == actual_size);
1839
+ }
1840
+ #endif
1841
+
1842
+ Shrink();
1843
+ ResetFreeList();
1844
+ }
1845
+
1846
+ protected:
1847
+ #ifdef DEBUG
1848
+ virtual void VerifyObject(HeapObject* obj);
1849
+ #endif
1850
+
1851
+ private:
1852
+ static const int kMapsPerPage = Page::kObjectAreaSize / Map::kSize;
1853
+
1854
+ // Do map space compaction if there is a page gap.
1855
+ int CompactionThreshold() {
1856
+ return kMapsPerPage * (max_map_space_pages_ - 1);
1857
+ }
1858
+
1859
+ const int max_map_space_pages_;
1860
+
1861
+ // An array of page start address in a map space.
1862
+ Address page_addresses_[kMaxMapPageIndex];
1863
+
1864
+ public:
1865
+ TRACK_MEMORY("MapSpace")
1866
+ };
1867
+
1868
+
1869
+ // -----------------------------------------------------------------------------
1870
+ // Old space for all global object property cell objects
1871
+
1872
+ class CellSpace : public FixedSpace {
1873
+ public:
1874
+ // Creates a property cell space object with a maximum capacity.
1875
+ CellSpace(int max_capacity, AllocationSpace id)
1876
+ : FixedSpace(max_capacity, id, JSGlobalPropertyCell::kSize, "cell") {}
1877
+
1878
+ protected:
1879
+ #ifdef DEBUG
1880
+ virtual void VerifyObject(HeapObject* obj);
1881
+ #endif
1882
+
1883
+ public:
1884
+ TRACK_MEMORY("CellSpace")
1885
+ };
1886
+
1887
+
1888
+ // -----------------------------------------------------------------------------
1889
+ // Large objects ( > Page::kMaxHeapObjectSize ) are allocated and managed by
1890
+ // the large object space. A large object is allocated from OS heap with
1891
+ // extra padding bytes (Page::kPageSize + Page::kObjectStartOffset).
1892
+ // A large object always starts at Page::kObjectStartOffset to a page.
1893
+ // Large objects do not move during garbage collections.
1894
+
1895
+ // A LargeObjectChunk holds exactly one large object page with exactly one
1896
+ // large object.
1897
+ class LargeObjectChunk {
1898
+ public:
1899
+ // Allocates a new LargeObjectChunk that contains a large object page
1900
+ // (Page::kPageSize aligned) that has at least size_in_bytes (for a large
1901
+ // object and possibly extra remembered set words) bytes after the object
1902
+ // area start of that page. The allocated chunk size is set in the output
1903
+ // parameter chunk_size.
1904
+ static LargeObjectChunk* New(int size_in_bytes,
1905
+ size_t* chunk_size,
1906
+ Executability executable);
1907
+
1908
+ // Interpret a raw address as a large object chunk.
1909
+ static LargeObjectChunk* FromAddress(Address address) {
1910
+ return reinterpret_cast<LargeObjectChunk*>(address);
1911
+ }
1912
+
1913
+ // Returns the address of this chunk.
1914
+ Address address() { return reinterpret_cast<Address>(this); }
1915
+
1916
+ // Accessors for the fields of the chunk.
1917
+ LargeObjectChunk* next() { return next_; }
1918
+ void set_next(LargeObjectChunk* chunk) { next_ = chunk; }
1919
+
1920
+ size_t size() { return size_; }
1921
+ void set_size(size_t size_in_bytes) { size_ = size_in_bytes; }
1922
+
1923
+ // Returns the object in this chunk.
1924
+ inline HeapObject* GetObject();
1925
+
1926
+ // Given a requested size (including any extra remembered set words),
1927
+ // returns the physical size of a chunk to be allocated.
1928
+ static int ChunkSizeFor(int size_in_bytes);
1929
+
1930
+ // Given a chunk size, returns the object size it can accommodate (not
1931
+ // including any extra remembered set words). Used by
1932
+ // LargeObjectSpace::Available. Note that this can overestimate the size
1933
+ // of object that will fit in a chunk---if the object requires extra
1934
+ // remembered set words (eg, for large fixed arrays), the actual object
1935
+ // size for the chunk will be smaller than reported by this function.
1936
+ static int ObjectSizeFor(int chunk_size) {
1937
+ if (chunk_size <= (Page::kPageSize + Page::kObjectStartOffset)) return 0;
1938
+ return chunk_size - Page::kPageSize - Page::kObjectStartOffset;
1939
+ }
1940
+
1941
+ private:
1942
+ // A pointer to the next large object chunk in the space or NULL.
1943
+ LargeObjectChunk* next_;
1944
+
1945
+ // The size of this chunk.
1946
+ size_t size_;
1947
+
1948
+ public:
1949
+ TRACK_MEMORY("LargeObjectChunk")
1950
+ };
1951
+
1952
+
1953
+ class LargeObjectSpace : public Space {
1954
+ public:
1955
+ explicit LargeObjectSpace(AllocationSpace id);
1956
+ virtual ~LargeObjectSpace() {}
1957
+
1958
+ // Initializes internal data structures.
1959
+ bool Setup();
1960
+
1961
+ // Releases internal resources, frees objects in this space.
1962
+ void TearDown();
1963
+
1964
+ // Allocates a (non-FixedArray, non-Code) large object.
1965
+ Object* AllocateRaw(int size_in_bytes);
1966
+ // Allocates a large Code object.
1967
+ Object* AllocateRawCode(int size_in_bytes);
1968
+ // Allocates a large FixedArray.
1969
+ Object* AllocateRawFixedArray(int size_in_bytes);
1970
+
1971
+ // Available bytes for objects in this space, not including any extra
1972
+ // remembered set words.
1973
+ int Available() {
1974
+ return LargeObjectChunk::ObjectSizeFor(MemoryAllocator::Available());
1975
+ }
1976
+
1977
+ virtual int Size() {
1978
+ return size_;
1979
+ }
1980
+
1981
+ int PageCount() {
1982
+ return page_count_;
1983
+ }
1984
+
1985
+ // Finds an object for a given address, returns Failure::Exception()
1986
+ // if it is not found. The function iterates through all objects in this
1987
+ // space, may be slow.
1988
+ Object* FindObject(Address a);
1989
+
1990
+ // Clears remembered sets.
1991
+ void ClearRSet();
1992
+
1993
+ // Iterates objects whose remembered set bits are set.
1994
+ void IterateRSet(ObjectSlotCallback func);
1995
+
1996
+ // Frees unmarked objects.
1997
+ void FreeUnmarkedObjects();
1998
+
1999
+ // Checks whether a heap object is in this space; O(1).
2000
+ bool Contains(HeapObject* obj);
2001
+
2002
+ // Checks whether the space is empty.
2003
+ bool IsEmpty() { return first_chunk_ == NULL; }
2004
+
2005
+ // See the comments for ReserveSpace in the Space class. This has to be
2006
+ // called after ReserveSpace has been called on the paged spaces, since they
2007
+ // may use some memory, leaving less for large objects.
2008
+ virtual bool ReserveSpace(int bytes);
2009
+
2010
+ #ifdef ENABLE_HEAP_PROTECTION
2011
+ // Protect/unprotect the space by marking it read-only/writable.
2012
+ void Protect();
2013
+ void Unprotect();
2014
+ #endif
2015
+
2016
+ #ifdef DEBUG
2017
+ virtual void Verify();
2018
+ virtual void Print();
2019
+ void ReportStatistics();
2020
+ void CollectCodeStatistics();
2021
+ // Dump the remembered sets in the space to stdout.
2022
+ void PrintRSet();
2023
+ #endif
2024
+ // Checks whether an address is in the object area in this space. It
2025
+ // iterates all objects in the space. May be slow.
2026
+ bool SlowContains(Address addr) { return !FindObject(addr)->IsFailure(); }
2027
+
2028
+ private:
2029
+ // The head of the linked list of large object chunks.
2030
+ LargeObjectChunk* first_chunk_;
2031
+ int size_; // allocated bytes
2032
+ int page_count_; // number of chunks
2033
+
2034
+
2035
+ // Shared implementation of AllocateRaw, AllocateRawCode and
2036
+ // AllocateRawFixedArray.
2037
+ Object* AllocateRawInternal(int requested_size,
2038
+ int object_size,
2039
+ Executability executable);
2040
+
2041
+ // Returns the number of extra bytes (rounded up to the nearest full word)
2042
+ // required for extra_object_bytes of extra pointers (in bytes).
2043
+ static inline int ExtraRSetBytesFor(int extra_object_bytes);
2044
+
2045
+ friend class LargeObjectIterator;
2046
+
2047
+ public:
2048
+ TRACK_MEMORY("LargeObjectSpace")
2049
+ };
2050
+
2051
+
2052
+ class LargeObjectIterator: public ObjectIterator {
2053
+ public:
2054
+ explicit LargeObjectIterator(LargeObjectSpace* space);
2055
+ LargeObjectIterator(LargeObjectSpace* space, HeapObjectCallback size_func);
2056
+
2057
+ bool has_next() { return current_ != NULL; }
2058
+ HeapObject* next();
2059
+
2060
+ // implementation of ObjectIterator.
2061
+ virtual bool has_next_object() { return has_next(); }
2062
+ virtual HeapObject* next_object() { return next(); }
2063
+
2064
+ private:
2065
+ LargeObjectChunk* current_;
2066
+ HeapObjectCallback size_func_;
2067
+ };
2068
+
2069
+
2070
+ } } // namespace v8::internal
2071
+
2072
+ #endif // V8_SPACES_H_