therubyracer 0.8.1.pre2 → 0.8.1

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 (877) hide show
  1. data/Changelog.md +2 -1
  2. data/README.md +6 -3
  3. data/ext/v8/upstream/3.1.8/.gitignore +31 -0
  4. data/ext/v8/upstream/3.1.8/AUTHORS +40 -0
  5. data/ext/v8/upstream/3.1.8/ChangeLog +2566 -0
  6. data/ext/v8/upstream/3.1.8/LICENSE +52 -0
  7. data/ext/v8/upstream/3.1.8/LICENSE.strongtalk +29 -0
  8. data/ext/v8/upstream/3.1.8/LICENSE.v8 +26 -0
  9. data/ext/v8/upstream/3.1.8/LICENSE.valgrind +45 -0
  10. data/ext/v8/upstream/3.1.8/SConstruct +1192 -0
  11. data/ext/v8/upstream/3.1.8/build/README.txt +25 -0
  12. data/ext/v8/upstream/3.1.8/build/all.gyp +18 -0
  13. data/ext/v8/upstream/3.1.8/build/armu.gypi +32 -0
  14. data/ext/v8/upstream/3.1.8/build/common.gypi +82 -0
  15. data/ext/v8/upstream/3.1.8/build/gyp_v8 +145 -0
  16. data/ext/v8/upstream/3.1.8/include/v8-debug.h +384 -0
  17. data/ext/v8/upstream/3.1.8/include/v8-preparser.h +116 -0
  18. data/ext/v8/upstream/3.1.8/include/v8-profiler.h +426 -0
  19. data/ext/v8/upstream/3.1.8/include/v8-testing.h +99 -0
  20. data/ext/v8/upstream/3.1.8/include/v8.h +3846 -0
  21. data/ext/v8/upstream/3.1.8/include/v8stdint.h +53 -0
  22. data/ext/v8/upstream/3.1.8/preparser/preparser-process.cc +206 -0
  23. data/ext/v8/upstream/3.1.8/src/SConscript +356 -0
  24. data/ext/v8/upstream/3.1.8/src/accessors.cc +907 -0
  25. data/ext/v8/upstream/3.1.8/src/accessors.h +121 -0
  26. data/ext/v8/upstream/3.1.8/src/allocation.cc +204 -0
  27. data/ext/v8/upstream/3.1.8/src/allocation.h +176 -0
  28. data/ext/v8/upstream/3.1.8/src/api.cc +5191 -0
  29. data/ext/v8/upstream/3.1.8/src/api.h +508 -0
  30. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/apinatives.js +0 -0
  31. data/ext/v8/upstream/3.1.8/src/apiutils.h +80 -0
  32. data/ext/v8/upstream/3.1.8/src/arguments.h +105 -0
  33. data/ext/v8/upstream/3.1.8/src/arm/assembler-arm-inl.h +352 -0
  34. data/ext/v8/upstream/3.1.8/src/arm/assembler-arm.cc +2756 -0
  35. data/ext/v8/upstream/3.1.8/src/arm/assembler-arm.h +1294 -0
  36. data/ext/v8/upstream/3.1.8/src/arm/builtins-arm.cc +1628 -0
  37. data/ext/v8/upstream/3.1.8/src/arm/code-stubs-arm.cc +6783 -0
  38. data/ext/v8/upstream/3.1.8/src/arm/code-stubs-arm.h +657 -0
  39. data/ext/v8/upstream/3.1.8/src/arm/codegen-arm-inl.h +48 -0
  40. data/ext/v8/upstream/3.1.8/src/arm/codegen-arm.cc +7403 -0
  41. data/ext/v8/upstream/3.1.8/src/arm/codegen-arm.h +595 -0
  42. data/ext/v8/upstream/3.1.8/src/arm/constants-arm.cc +152 -0
  43. data/ext/v8/upstream/3.1.8/src/arm/constants-arm.h +769 -0
  44. data/ext/v8/upstream/3.1.8/src/arm/cpu-arm.cc +147 -0
  45. data/ext/v8/upstream/3.1.8/src/arm/debug-arm.cc +315 -0
  46. data/ext/v8/upstream/3.1.8/src/arm/deoptimizer-arm.cc +700 -0
  47. data/ext/v8/upstream/3.1.8/src/arm/disasm-arm.cc +1439 -0
  48. data/ext/v8/upstream/3.1.8/src/arm/frames-arm.cc +45 -0
  49. data/ext/v8/upstream/3.1.8/src/arm/frames-arm.h +168 -0
  50. data/ext/v8/upstream/3.1.8/src/arm/full-codegen-arm.cc +4230 -0
  51. data/ext/v8/upstream/3.1.8/src/arm/ic-arm.cc +1799 -0
  52. data/ext/v8/upstream/3.1.8/src/arm/jump-target-arm.cc +174 -0
  53. data/ext/v8/upstream/3.1.8/src/arm/lithium-arm.cc +2041 -0
  54. data/ext/v8/upstream/3.1.8/src/arm/lithium-arm.h +2046 -0
  55. data/ext/v8/upstream/3.1.8/src/arm/lithium-codegen-arm.cc +3822 -0
  56. data/ext/v8/upstream/3.1.8/src/arm/lithium-codegen-arm.h +312 -0
  57. data/ext/v8/upstream/3.1.8/src/arm/lithium-gap-resolver-arm.cc +303 -0
  58. data/ext/v8/upstream/3.1.8/src/arm/lithium-gap-resolver-arm.h +84 -0
  59. data/ext/v8/upstream/3.1.8/src/arm/macro-assembler-arm.cc +2701 -0
  60. data/ext/v8/upstream/3.1.8/src/arm/macro-assembler-arm.h +1015 -0
  61. data/ext/v8/upstream/3.1.8/src/arm/regexp-macro-assembler-arm.cc +1280 -0
  62. data/ext/v8/upstream/3.1.8/src/arm/regexp-macro-assembler-arm.h +252 -0
  63. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/arm/register-allocator-arm-inl.h +0 -0
  64. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/arm/register-allocator-arm.cc +0 -0
  65. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/arm/register-allocator-arm.h +0 -0
  66. data/ext/v8/upstream/3.1.8/src/arm/simulator-arm.cc +3165 -0
  67. data/ext/v8/upstream/3.1.8/src/arm/simulator-arm.h +402 -0
  68. data/ext/v8/upstream/3.1.8/src/arm/stub-cache-arm.cc +4077 -0
  69. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/arm/virtual-frame-arm-inl.h +0 -0
  70. data/ext/v8/upstream/3.1.8/src/arm/virtual-frame-arm.cc +843 -0
  71. data/ext/v8/upstream/3.1.8/src/arm/virtual-frame-arm.h +520 -0
  72. data/ext/v8/upstream/3.1.8/src/array.js +1231 -0
  73. data/ext/v8/upstream/3.1.8/src/assembler.cc +973 -0
  74. data/ext/v8/upstream/3.1.8/src/assembler.h +787 -0
  75. data/ext/v8/upstream/3.1.8/src/ast-inl.h +107 -0
  76. data/ext/v8/upstream/3.1.8/src/ast.cc +1067 -0
  77. data/ext/v8/upstream/3.1.8/src/ast.h +2177 -0
  78. data/ext/v8/upstream/3.1.8/src/atomicops.h +165 -0
  79. data/ext/v8/upstream/3.1.8/src/atomicops_internals_arm_gcc.h +145 -0
  80. data/ext/v8/upstream/3.1.8/src/atomicops_internals_x86_gcc.cc +126 -0
  81. data/ext/v8/upstream/3.1.8/src/atomicops_internals_x86_gcc.h +287 -0
  82. data/ext/v8/upstream/3.1.8/src/atomicops_internals_x86_macosx.h +301 -0
  83. data/ext/v8/upstream/3.1.8/src/atomicops_internals_x86_msvc.h +203 -0
  84. data/ext/v8/upstream/3.1.8/src/bignum-dtoa.cc +655 -0
  85. data/ext/v8/upstream/3.1.8/src/bignum-dtoa.h +81 -0
  86. data/ext/v8/upstream/3.1.8/src/bignum.cc +768 -0
  87. data/ext/v8/upstream/3.1.8/src/bignum.h +140 -0
  88. data/ext/v8/upstream/3.1.8/src/bootstrapper.cc +1888 -0
  89. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/bootstrapper.h +0 -0
  90. data/ext/v8/upstream/3.1.8/src/builtins.cc +1586 -0
  91. data/ext/v8/upstream/3.1.8/src/builtins.h +339 -0
  92. data/ext/v8/upstream/3.1.8/src/bytecodes-irregexp.h +105 -0
  93. data/ext/v8/upstream/3.1.8/src/cached-powers.cc +177 -0
  94. data/ext/v8/upstream/3.1.8/src/cached-powers.h +65 -0
  95. data/ext/v8/upstream/3.1.8/src/char-predicates-inl.h +94 -0
  96. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/char-predicates.h +0 -0
  97. data/ext/v8/upstream/3.1.8/src/checks.cc +110 -0
  98. data/ext/v8/upstream/3.1.8/src/checks.h +292 -0
  99. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/circular-queue-inl.h +0 -0
  100. data/ext/v8/upstream/3.1.8/src/circular-queue.cc +122 -0
  101. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/circular-queue.h +0 -0
  102. data/ext/v8/upstream/3.1.8/src/code-stubs.cc +230 -0
  103. data/ext/v8/upstream/3.1.8/src/code-stubs.h +950 -0
  104. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/code.h +0 -0
  105. data/ext/v8/upstream/3.1.8/src/codegen-inl.h +64 -0
  106. data/ext/v8/upstream/3.1.8/src/codegen.cc +495 -0
  107. data/ext/v8/upstream/3.1.8/src/codegen.h +245 -0
  108. data/ext/v8/upstream/3.1.8/src/compilation-cache.cc +654 -0
  109. data/ext/v8/upstream/3.1.8/src/compilation-cache.h +112 -0
  110. data/ext/v8/upstream/3.1.8/src/compiler.cc +806 -0
  111. data/ext/v8/upstream/3.1.8/src/compiler.h +290 -0
  112. data/ext/v8/upstream/3.1.8/src/contexts.cc +320 -0
  113. data/ext/v8/upstream/3.1.8/src/contexts.h +376 -0
  114. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/conversions-inl.h +0 -0
  115. data/ext/v8/upstream/3.1.8/src/conversions.cc +1069 -0
  116. data/ext/v8/upstream/3.1.8/src/conversions.h +122 -0
  117. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/counters.cc +0 -0
  118. data/ext/v8/upstream/3.1.8/src/counters.h +242 -0
  119. data/ext/v8/upstream/3.1.8/src/cpu-profiler-inl.h +100 -0
  120. data/ext/v8/upstream/3.1.8/src/cpu-profiler.cc +554 -0
  121. data/ext/v8/upstream/3.1.8/src/cpu-profiler.h +291 -0
  122. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/cpu.h +0 -0
  123. data/ext/v8/upstream/3.1.8/src/d8-debug.cc +367 -0
  124. data/ext/v8/upstream/3.1.8/src/d8-debug.h +157 -0
  125. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/d8-posix.cc +0 -0
  126. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/d8-readline.cc +0 -0
  127. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/d8-windows.cc +0 -0
  128. data/ext/v8/upstream/3.1.8/src/d8.cc +792 -0
  129. data/ext/v8/upstream/3.1.8/src/d8.gyp +85 -0
  130. data/ext/v8/upstream/3.1.8/src/d8.h +231 -0
  131. data/ext/v8/upstream/3.1.8/src/d8.js +2798 -0
  132. data/ext/v8/upstream/3.1.8/src/data-flow.cc +545 -0
  133. data/ext/v8/upstream/3.1.8/src/data-flow.h +379 -0
  134. data/ext/v8/upstream/3.1.8/src/date.js +1103 -0
  135. data/ext/v8/upstream/3.1.8/src/dateparser-inl.h +125 -0
  136. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/dateparser.cc +0 -0
  137. data/ext/v8/upstream/3.1.8/src/dateparser.h +263 -0
  138. data/ext/v8/upstream/3.1.8/src/debug-agent.cc +446 -0
  139. data/ext/v8/upstream/3.1.8/src/debug-agent.h +131 -0
  140. data/ext/v8/upstream/3.1.8/src/debug-debugger.js +2569 -0
  141. data/ext/v8/upstream/3.1.8/src/debug.cc +3085 -0
  142. data/ext/v8/upstream/3.1.8/src/debug.h +1025 -0
  143. data/ext/v8/upstream/3.1.8/src/deoptimizer.cc +1185 -0
  144. data/ext/v8/upstream/3.1.8/src/deoptimizer.h +529 -0
  145. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/disasm.h +0 -0
  146. data/ext/v8/upstream/3.1.8/src/disassembler.cc +338 -0
  147. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/disassembler.h +0 -0
  148. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/diy-fp.cc +0 -0
  149. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/diy-fp.h +0 -0
  150. data/ext/v8/upstream/3.1.8/src/double.h +238 -0
  151. data/ext/v8/upstream/3.1.8/src/dtoa.cc +103 -0
  152. data/ext/v8/upstream/3.1.8/src/dtoa.h +85 -0
  153. data/ext/v8/upstream/3.1.8/src/execution.cc +735 -0
  154. data/ext/v8/upstream/3.1.8/src/execution.h +322 -0
  155. data/ext/v8/upstream/3.1.8/src/extensions/experimental/experimental.gyp +53 -0
  156. data/ext/v8/upstream/3.1.8/src/extensions/experimental/i18n-extension.cc +264 -0
  157. data/ext/v8/upstream/3.1.8/src/extensions/experimental/i18n-extension.h +64 -0
  158. data/ext/v8/upstream/3.1.8/src/extensions/externalize-string-extension.cc +141 -0
  159. data/ext/v8/upstream/3.1.8/src/extensions/externalize-string-extension.h +50 -0
  160. data/ext/v8/upstream/3.1.8/src/extensions/gc-extension.cc +58 -0
  161. data/ext/v8/upstream/3.1.8/src/extensions/gc-extension.h +49 -0
  162. data/ext/v8/upstream/3.1.8/src/factory.cc +1087 -0
  163. data/ext/v8/upstream/3.1.8/src/factory.h +432 -0
  164. data/ext/v8/upstream/3.1.8/src/fast-dtoa.cc +736 -0
  165. data/ext/v8/upstream/3.1.8/src/fast-dtoa.h +83 -0
  166. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/fixed-dtoa.cc +0 -0
  167. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/fixed-dtoa.h +0 -0
  168. data/ext/v8/upstream/3.1.8/src/flag-definitions.h +552 -0
  169. data/ext/v8/upstream/3.1.8/src/flags.cc +551 -0
  170. data/ext/v8/upstream/3.1.8/src/flags.h +79 -0
  171. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/frame-element.cc +0 -0
  172. data/ext/v8/upstream/3.1.8/src/frame-element.h +277 -0
  173. data/ext/v8/upstream/3.1.8/src/frames-inl.h +210 -0
  174. data/ext/v8/upstream/3.1.8/src/frames.cc +1232 -0
  175. data/ext/v8/upstream/3.1.8/src/frames.h +826 -0
  176. data/ext/v8/upstream/3.1.8/src/full-codegen.cc +1382 -0
  177. data/ext/v8/upstream/3.1.8/src/full-codegen.h +751 -0
  178. data/ext/v8/upstream/3.1.8/src/func-name-inferrer.cc +90 -0
  179. data/ext/v8/upstream/3.1.8/src/func-name-inferrer.h +111 -0
  180. data/ext/v8/upstream/3.1.8/src/gdb-jit.cc +1547 -0
  181. data/ext/v8/upstream/3.1.8/src/gdb-jit.h +138 -0
  182. data/ext/v8/upstream/3.1.8/src/global-handles.cc +534 -0
  183. data/ext/v8/upstream/3.1.8/src/global-handles.h +181 -0
  184. data/ext/v8/upstream/3.1.8/src/globals.h +325 -0
  185. data/ext/v8/upstream/3.1.8/src/handles-inl.h +80 -0
  186. data/ext/v8/upstream/3.1.8/src/handles.cc +910 -0
  187. data/ext/v8/upstream/3.1.8/src/handles.h +424 -0
  188. data/ext/v8/upstream/3.1.8/src/hashmap.cc +230 -0
  189. data/ext/v8/upstream/3.1.8/src/hashmap.h +121 -0
  190. data/ext/v8/upstream/3.1.8/src/heap-inl.h +587 -0
  191. data/ext/v8/upstream/3.1.8/src/heap-profiler.cc +1128 -0
  192. data/ext/v8/upstream/3.1.8/src/heap-profiler.h +381 -0
  193. data/ext/v8/upstream/3.1.8/src/heap.cc +5610 -0
  194. data/ext/v8/upstream/3.1.8/src/heap.h +2218 -0
  195. data/ext/v8/upstream/3.1.8/src/hydrogen-instructions.cc +1490 -0
  196. data/ext/v8/upstream/3.1.8/src/hydrogen-instructions.h +3493 -0
  197. data/ext/v8/upstream/3.1.8/src/hydrogen.cc +6056 -0
  198. data/ext/v8/upstream/3.1.8/src/hydrogen.h +1091 -0
  199. data/ext/v8/upstream/3.1.8/src/ia32/assembler-ia32-inl.h +429 -0
  200. data/ext/v8/upstream/3.1.8/src/ia32/assembler-ia32.cc +2800 -0
  201. data/ext/v8/upstream/3.1.8/src/ia32/assembler-ia32.h +1093 -0
  202. data/ext/v8/upstream/3.1.8/src/ia32/builtins-ia32.cc +1590 -0
  203. data/ext/v8/upstream/3.1.8/src/ia32/code-stubs-ia32.cc +6624 -0
  204. data/ext/v8/upstream/3.1.8/src/ia32/code-stubs-ia32.h +536 -0
  205. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/ia32/codegen-ia32-inl.h +0 -0
  206. data/ext/v8/upstream/3.1.8/src/ia32/codegen-ia32.cc +10354 -0
  207. data/ext/v8/upstream/3.1.8/src/ia32/codegen-ia32.h +798 -0
  208. data/ext/v8/upstream/3.1.8/src/ia32/cpu-ia32.cc +87 -0
  209. data/ext/v8/upstream/3.1.8/src/ia32/debug-ia32.cc +309 -0
  210. data/ext/v8/upstream/3.1.8/src/ia32/deoptimizer-ia32.cc +664 -0
  211. data/ext/v8/upstream/3.1.8/src/ia32/disasm-ia32.cc +1597 -0
  212. data/ext/v8/upstream/3.1.8/src/ia32/frames-ia32.cc +45 -0
  213. data/ext/v8/upstream/3.1.8/src/ia32/frames-ia32.h +140 -0
  214. data/ext/v8/upstream/3.1.8/src/ia32/full-codegen-ia32.cc +4278 -0
  215. data/ext/v8/upstream/3.1.8/src/ia32/ic-ia32.cc +1786 -0
  216. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/ia32/jump-target-ia32.cc +0 -0
  217. data/ext/v8/upstream/3.1.8/src/ia32/lithium-codegen-ia32.cc +3880 -0
  218. data/ext/v8/upstream/3.1.8/src/ia32/lithium-codegen-ia32.h +309 -0
  219. data/ext/v8/upstream/3.1.8/src/ia32/lithium-gap-resolver-ia32.cc +460 -0
  220. data/ext/v8/upstream/3.1.8/src/ia32/lithium-gap-resolver-ia32.h +110 -0
  221. data/ext/v8/upstream/3.1.8/src/ia32/lithium-ia32.cc +2095 -0
  222. data/ext/v8/upstream/3.1.8/src/ia32/lithium-ia32.h +2127 -0
  223. data/ext/v8/upstream/3.1.8/src/ia32/macro-assembler-ia32.cc +2031 -0
  224. data/ext/v8/upstream/3.1.8/src/ia32/macro-assembler-ia32.h +798 -0
  225. data/ext/v8/upstream/3.1.8/src/ia32/regexp-macro-assembler-ia32.cc +1253 -0
  226. data/ext/v8/upstream/3.1.8/src/ia32/regexp-macro-assembler-ia32.h +215 -0
  227. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/ia32/register-allocator-ia32-inl.h +0 -0
  228. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/ia32/register-allocator-ia32.cc +0 -0
  229. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/ia32/register-allocator-ia32.h +0 -0
  230. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/ia32/simulator-ia32.cc +0 -0
  231. data/ext/v8/upstream/3.1.8/src/ia32/simulator-ia32.h +72 -0
  232. data/ext/v8/upstream/3.1.8/src/ia32/stub-cache-ia32.cc +3732 -0
  233. data/ext/v8/upstream/3.1.8/src/ia32/virtual-frame-ia32.cc +1360 -0
  234. data/ext/v8/upstream/3.1.8/src/ia32/virtual-frame-ia32.h +646 -0
  235. data/ext/v8/upstream/3.1.8/src/ic-inl.h +129 -0
  236. data/ext/v8/upstream/3.1.8/src/ic.cc +2333 -0
  237. data/ext/v8/upstream/3.1.8/src/ic.h +639 -0
  238. data/ext/v8/upstream/3.1.8/src/inspector.cc +63 -0
  239. data/ext/v8/upstream/3.1.8/src/inspector.h +62 -0
  240. data/ext/v8/upstream/3.1.8/src/interpreter-irregexp.cc +655 -0
  241. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/interpreter-irregexp.h +0 -0
  242. data/ext/v8/upstream/3.1.8/src/json.js +342 -0
  243. data/ext/v8/upstream/3.1.8/src/jsregexp.cc +5340 -0
  244. data/ext/v8/upstream/3.1.8/src/jsregexp.h +1484 -0
  245. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/jump-target-heavy-inl.h +0 -0
  246. data/ext/v8/upstream/3.1.8/src/jump-target-heavy.cc +430 -0
  247. data/ext/v8/upstream/3.1.8/src/jump-target-heavy.h +244 -0
  248. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/jump-target-inl.h +0 -0
  249. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/jump-target-light-inl.h +0 -0
  250. data/ext/v8/upstream/3.1.8/src/jump-target-light.cc +111 -0
  251. data/ext/v8/upstream/3.1.8/src/jump-target-light.h +193 -0
  252. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/jump-target.cc +0 -0
  253. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/jump-target.h +0 -0
  254. data/ext/v8/upstream/3.1.8/src/list-inl.h +206 -0
  255. data/ext/v8/upstream/3.1.8/src/list.h +164 -0
  256. data/ext/v8/upstream/3.1.8/src/lithium-allocator-inl.h +140 -0
  257. data/ext/v8/upstream/3.1.8/src/lithium-allocator.cc +2093 -0
  258. data/ext/v8/upstream/3.1.8/src/lithium-allocator.h +644 -0
  259. data/ext/v8/upstream/3.1.8/src/lithium.cc +168 -0
  260. data/ext/v8/upstream/3.1.8/src/lithium.h +592 -0
  261. data/ext/v8/upstream/3.1.8/src/liveedit-debugger.js +1082 -0
  262. data/ext/v8/upstream/3.1.8/src/liveedit.cc +1650 -0
  263. data/ext/v8/upstream/3.1.8/src/liveedit.h +174 -0
  264. data/ext/v8/upstream/3.1.8/src/liveobjectlist-inl.h +126 -0
  265. data/ext/v8/upstream/3.1.8/src/liveobjectlist.cc +2527 -0
  266. data/ext/v8/upstream/3.1.8/src/liveobjectlist.h +322 -0
  267. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/log-inl.h +0 -0
  268. data/ext/v8/upstream/3.1.8/src/log-utils.cc +336 -0
  269. data/ext/v8/upstream/3.1.8/src/log-utils.h +232 -0
  270. data/ext/v8/upstream/3.1.8/src/log.cc +1608 -0
  271. data/ext/v8/upstream/3.1.8/src/log.h +379 -0
  272. data/ext/v8/upstream/3.1.8/src/macro-assembler.h +120 -0
  273. data/ext/v8/upstream/3.1.8/src/macros.py +178 -0
  274. data/ext/v8/upstream/3.1.8/src/mark-compact.cc +2957 -0
  275. data/ext/v8/upstream/3.1.8/src/mark-compact.h +433 -0
  276. data/ext/v8/upstream/3.1.8/src/math.js +264 -0
  277. data/ext/v8/upstream/3.1.8/src/memory.h +82 -0
  278. data/ext/v8/upstream/3.1.8/src/messages.cc +164 -0
  279. data/ext/v8/upstream/3.1.8/src/messages.h +114 -0
  280. data/ext/v8/upstream/3.1.8/src/messages.js +1071 -0
  281. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/mips/assembler-mips-inl.h +0 -0
  282. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/mips/assembler-mips.cc +0 -0
  283. data/ext/v8/upstream/3.1.8/src/mips/assembler-mips.h +667 -0
  284. data/ext/v8/upstream/3.1.8/src/mips/builtins-mips.cc +205 -0
  285. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/mips/codegen-mips-inl.h +0 -0
  286. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/mips/codegen-mips.cc +0 -0
  287. data/ext/v8/upstream/3.1.8/src/mips/codegen-mips.h +431 -0
  288. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/mips/constants-mips.cc +0 -0
  289. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/mips/constants-mips.h +0 -0
  290. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/mips/cpu-mips.cc +0 -0
  291. data/ext/v8/upstream/3.1.8/src/mips/debug-mips.cc +127 -0
  292. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/mips/disasm-mips.cc +0 -0
  293. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/mips/fast-codegen-mips.cc +0 -0
  294. data/ext/v8/upstream/3.1.8/src/mips/frames-mips.cc +96 -0
  295. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/mips/frames-mips.h +0 -0
  296. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/mips/full-codegen-mips.cc +0 -0
  297. data/ext/v8/upstream/3.1.8/src/mips/ic-mips.cc +208 -0
  298. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/mips/jump-target-mips.cc +0 -0
  299. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/mips/macro-assembler-mips.cc +0 -0
  300. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/mips/macro-assembler-mips.h +0 -0
  301. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/mips/register-allocator-mips-inl.h +0 -0
  302. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/mips/register-allocator-mips.cc +0 -0
  303. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/mips/register-allocator-mips.h +0 -0
  304. data/ext/v8/upstream/3.1.8/src/mips/simulator-mips.cc +1650 -0
  305. data/ext/v8/upstream/3.1.8/src/mips/simulator-mips.h +311 -0
  306. data/ext/v8/upstream/3.1.8/src/mips/stub-cache-mips.cc +418 -0
  307. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/mips/virtual-frame-mips.cc +0 -0
  308. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/mips/virtual-frame-mips.h +0 -0
  309. data/ext/v8/upstream/3.1.8/src/mirror-debugger.js +2380 -0
  310. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/mksnapshot.cc +0 -0
  311. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/natives.h +0 -0
  312. data/ext/v8/upstream/3.1.8/src/objects-debug.cc +722 -0
  313. data/ext/v8/upstream/3.1.8/src/objects-inl.h +3946 -0
  314. data/ext/v8/upstream/3.1.8/src/objects-printer.cc +801 -0
  315. data/ext/v8/upstream/3.1.8/src/objects-visiting.cc +142 -0
  316. data/ext/v8/upstream/3.1.8/src/objects-visiting.h +401 -0
  317. data/ext/v8/upstream/3.1.8/src/objects.cc +10044 -0
  318. data/ext/v8/upstream/3.1.8/src/objects.h +6571 -0
  319. data/ext/v8/upstream/3.1.8/src/parser.cc +5165 -0
  320. data/ext/v8/upstream/3.1.8/src/parser.h +802 -0
  321. data/ext/v8/upstream/3.1.8/src/platform-cygwin.cc +745 -0
  322. data/ext/v8/upstream/3.1.8/src/platform-freebsd.cc +702 -0
  323. data/ext/v8/upstream/3.1.8/src/platform-linux.cc +981 -0
  324. data/ext/v8/upstream/3.1.8/src/platform-macos.cc +732 -0
  325. data/ext/v8/upstream/3.1.8/src/platform-nullos.cc +498 -0
  326. data/ext/v8/upstream/3.1.8/src/platform-openbsd.cc +657 -0
  327. data/ext/v8/upstream/3.1.8/src/platform-posix.cc +399 -0
  328. data/ext/v8/upstream/3.1.8/src/platform-solaris.cc +714 -0
  329. data/ext/v8/upstream/3.1.8/src/platform-win32.cc +1974 -0
  330. data/ext/v8/upstream/3.1.8/src/platform.h +636 -0
  331. data/ext/v8/upstream/3.1.8/src/preparse-data.cc +183 -0
  332. data/ext/v8/upstream/3.1.8/src/preparse-data.h +249 -0
  333. data/ext/v8/upstream/3.1.8/src/preparser-api.cc +213 -0
  334. data/ext/v8/upstream/3.1.8/src/preparser.cc +1205 -0
  335. data/ext/v8/upstream/3.1.8/src/preparser.h +278 -0
  336. data/ext/v8/upstream/3.1.8/src/prettyprinter.cc +1539 -0
  337. data/ext/v8/upstream/3.1.8/src/prettyprinter.h +223 -0
  338. data/ext/v8/upstream/3.1.8/src/profile-generator-inl.h +128 -0
  339. data/ext/v8/upstream/3.1.8/src/profile-generator.cc +2899 -0
  340. data/ext/v8/upstream/3.1.8/src/profile-generator.h +1151 -0
  341. data/ext/v8/upstream/3.1.8/src/property.cc +96 -0
  342. data/ext/v8/upstream/3.1.8/src/property.h +337 -0
  343. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/regexp-macro-assembler-irregexp-inl.h +0 -0
  344. data/ext/v8/upstream/3.1.8/src/regexp-macro-assembler-irregexp.cc +470 -0
  345. data/ext/v8/upstream/3.1.8/src/regexp-macro-assembler-irregexp.h +142 -0
  346. data/ext/v8/upstream/3.1.8/src/regexp-macro-assembler-tracer.cc +373 -0
  347. data/ext/v8/upstream/3.1.8/src/regexp-macro-assembler-tracer.h +104 -0
  348. data/ext/v8/upstream/3.1.8/src/regexp-macro-assembler.cc +257 -0
  349. data/ext/v8/upstream/3.1.8/src/regexp-macro-assembler.h +231 -0
  350. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/regexp-stack.cc +0 -0
  351. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/regexp-stack.h +0 -0
  352. data/ext/v8/upstream/3.1.8/src/regexp.js +483 -0
  353. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/register-allocator-inl.h +0 -0
  354. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/register-allocator.cc +0 -0
  355. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/register-allocator.h +0 -0
  356. data/ext/v8/upstream/3.1.8/src/rewriter.cc +1023 -0
  357. data/ext/v8/upstream/3.1.8/src/rewriter.h +59 -0
  358. data/ext/v8/upstream/3.1.8/src/runtime-profiler.cc +443 -0
  359. data/ext/v8/upstream/3.1.8/src/runtime-profiler.h +77 -0
  360. data/ext/v8/upstream/3.1.8/src/runtime.cc +11592 -0
  361. data/ext/v8/upstream/3.1.8/src/runtime.h +582 -0
  362. data/ext/v8/upstream/3.1.8/src/runtime.js +643 -0
  363. data/ext/v8/upstream/3.1.8/src/safepoint-table.cc +253 -0
  364. data/ext/v8/upstream/3.1.8/src/safepoint-table.h +263 -0
  365. data/ext/v8/upstream/3.1.8/src/scanner-base.cc +971 -0
  366. data/ext/v8/upstream/3.1.8/src/scanner-base.h +653 -0
  367. data/ext/v8/upstream/3.1.8/src/scanner.cc +586 -0
  368. data/ext/v8/upstream/3.1.8/src/scanner.h +194 -0
  369. data/ext/v8/upstream/3.1.8/src/scopeinfo.cc +636 -0
  370. data/ext/v8/upstream/3.1.8/src/scopeinfo.h +238 -0
  371. data/ext/v8/upstream/3.1.8/src/scopes.cc +1063 -0
  372. data/ext/v8/upstream/3.1.8/src/scopes.h +494 -0
  373. data/ext/v8/upstream/3.1.8/src/serialize.cc +1535 -0
  374. data/ext/v8/upstream/3.1.8/src/serialize.h +584 -0
  375. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/shell.h +0 -0
  376. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/simulator.h +0 -0
  377. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/smart-pointer.h +0 -0
  378. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/snapshot-common.cc +0 -0
  379. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/snapshot-empty.cc +0 -0
  380. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/snapshot.h +0 -0
  381. data/ext/v8/upstream/3.1.8/src/spaces-inl.h +524 -0
  382. data/ext/v8/upstream/3.1.8/src/spaces.cc +3254 -0
  383. data/ext/v8/upstream/3.1.8/src/spaces.h +2362 -0
  384. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/splay-tree-inl.h +0 -0
  385. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/splay-tree.h +0 -0
  386. data/ext/v8/upstream/3.1.8/src/string-search.cc +40 -0
  387. data/ext/v8/upstream/3.1.8/src/string-search.h +567 -0
  388. data/ext/v8/upstream/3.1.8/src/string-stream.cc +584 -0
  389. data/ext/v8/upstream/3.1.8/src/string-stream.h +191 -0
  390. data/ext/v8/upstream/3.1.8/src/string.js +915 -0
  391. data/ext/v8/upstream/3.1.8/src/strtod.cc +440 -0
  392. data/ext/v8/upstream/3.1.8/src/strtod.h +40 -0
  393. data/ext/v8/upstream/3.1.8/src/stub-cache.cc +1878 -0
  394. data/ext/v8/upstream/3.1.8/src/stub-cache.h +849 -0
  395. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/third_party/valgrind/valgrind.h +0 -0
  396. data/ext/v8/upstream/3.1.8/src/token.cc +63 -0
  397. data/ext/v8/upstream/3.1.8/src/token.h +288 -0
  398. data/ext/v8/upstream/3.1.8/src/top.cc +1152 -0
  399. data/ext/v8/upstream/3.1.8/src/top.h +608 -0
  400. data/ext/v8/upstream/3.1.8/src/type-info.cc +406 -0
  401. data/ext/v8/upstream/3.1.8/src/type-info.h +283 -0
  402. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/unbound-queue-inl.h +0 -0
  403. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/unbound-queue.h +0 -0
  404. data/ext/v8/upstream/3.1.8/src/unicode-inl.h +238 -0
  405. data/ext/v8/upstream/3.1.8/src/unicode.cc +1624 -0
  406. data/ext/v8/upstream/3.1.8/src/unicode.h +280 -0
  407. data/ext/v8/upstream/3.1.8/src/uri.js +402 -0
  408. data/ext/v8/upstream/3.1.8/src/utils.cc +371 -0
  409. data/ext/v8/upstream/3.1.8/src/utils.h +793 -0
  410. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/v8-counters.cc +0 -0
  411. data/ext/v8/upstream/3.1.8/src/v8-counters.h +290 -0
  412. data/ext/v8/upstream/3.1.8/src/v8.cc +270 -0
  413. data/ext/v8/upstream/3.1.8/src/v8.h +127 -0
  414. data/ext/v8/upstream/3.1.8/src/v8checks.h +64 -0
  415. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/v8dll-main.cc +0 -0
  416. data/ext/v8/upstream/3.1.8/src/v8globals.h +480 -0
  417. data/ext/v8/upstream/3.1.8/src/v8natives.js +1252 -0
  418. data/ext/v8/upstream/3.1.8/src/v8preparserdll-main.cc +39 -0
  419. data/ext/v8/upstream/3.1.8/src/v8threads.cc +440 -0
  420. data/ext/v8/upstream/3.1.8/src/v8threads.h +157 -0
  421. data/ext/v8/upstream/3.1.8/src/v8utils.h +354 -0
  422. data/ext/v8/upstream/3.1.8/src/variables.cc +132 -0
  423. data/ext/v8/upstream/3.1.8/src/variables.h +212 -0
  424. data/ext/v8/upstream/3.1.8/src/version.cc +95 -0
  425. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/version.h +0 -0
  426. data/ext/v8/upstream/3.1.8/src/virtual-frame-heavy-inl.h +190 -0
  427. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/virtual-frame-heavy.cc +0 -0
  428. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/virtual-frame-inl.h +0 -0
  429. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/virtual-frame-light-inl.h +0 -0
  430. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/virtual-frame-light.cc +0 -0
  431. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/virtual-frame.cc +0 -0
  432. data/ext/v8/upstream/3.1.8/src/virtual-frame.h +59 -0
  433. data/ext/v8/upstream/3.1.8/src/vm-state-inl.h +134 -0
  434. data/ext/v8/upstream/3.1.8/src/vm-state.h +68 -0
  435. data/ext/v8/upstream/3.1.8/src/win32-headers.h +95 -0
  436. data/ext/v8/upstream/3.1.8/src/x64/assembler-x64-inl.h +455 -0
  437. data/ext/v8/upstream/3.1.8/src/x64/assembler-x64.cc +3162 -0
  438. data/ext/v8/upstream/3.1.8/src/x64/assembler-x64.h +1584 -0
  439. data/ext/v8/upstream/3.1.8/src/x64/builtins-x64.cc +1492 -0
  440. data/ext/v8/upstream/3.1.8/src/x64/code-stubs-x64.cc +5150 -0
  441. data/ext/v8/upstream/3.1.8/src/x64/code-stubs-x64.h +519 -0
  442. data/ext/v8/upstream/3.1.8/src/x64/codegen-x64-inl.h +46 -0
  443. data/ext/v8/upstream/3.1.8/src/x64/codegen-x64.cc +8835 -0
  444. data/ext/v8/upstream/3.1.8/src/x64/codegen-x64.h +750 -0
  445. data/ext/v8/upstream/3.1.8/src/x64/cpu-x64.cc +86 -0
  446. data/ext/v8/upstream/3.1.8/src/x64/debug-x64.cc +316 -0
  447. data/ext/v8/upstream/3.1.8/src/x64/deoptimizer-x64.cc +781 -0
  448. data/ext/v8/upstream/3.1.8/src/x64/disasm-x64.cc +1737 -0
  449. data/ext/v8/upstream/3.1.8/src/x64/frames-x64.cc +45 -0
  450. data/ext/v8/upstream/3.1.8/src/x64/frames-x64.h +130 -0
  451. data/ext/v8/upstream/3.1.8/src/x64/full-codegen-x64.cc +3984 -0
  452. data/ext/v8/upstream/3.1.8/src/x64/ic-x64.cc +1761 -0
  453. data/ext/v8/upstream/3.1.8/src/x64/jump-target-x64.cc +437 -0
  454. data/ext/v8/upstream/3.1.8/src/x64/lithium-codegen-x64.cc +3639 -0
  455. data/ext/v8/upstream/3.1.8/src/x64/lithium-codegen-x64.h +305 -0
  456. data/ext/v8/upstream/3.1.8/src/x64/lithium-gap-resolver-x64.cc +320 -0
  457. data/ext/v8/upstream/3.1.8/src/x64/lithium-gap-resolver-x64.h +74 -0
  458. data/ext/v8/upstream/3.1.8/src/x64/lithium-x64.cc +2044 -0
  459. data/ext/v8/upstream/3.1.8/src/x64/lithium-x64.h +2052 -0
  460. data/ext/v8/upstream/3.1.8/src/x64/macro-assembler-x64.cc +2660 -0
  461. data/ext/v8/upstream/3.1.8/src/x64/macro-assembler-x64.h +1852 -0
  462. data/ext/v8/upstream/3.1.8/src/x64/regexp-macro-assembler-x64.cc +1382 -0
  463. data/ext/v8/upstream/3.1.8/src/x64/regexp-macro-assembler-x64.h +278 -0
  464. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/x64/register-allocator-x64-inl.h +0 -0
  465. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/x64/register-allocator-x64.cc +0 -0
  466. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/x64/register-allocator-x64.h +0 -0
  467. data/ext/v8/upstream/{2.3.3 → 3.1.8}/src/x64/simulator-x64.cc +0 -0
  468. data/ext/v8/upstream/3.1.8/src/x64/simulator-x64.h +71 -0
  469. data/ext/v8/upstream/3.1.8/src/x64/stub-cache-x64.cc +3509 -0
  470. data/ext/v8/upstream/3.1.8/src/x64/virtual-frame-x64.cc +1292 -0
  471. data/ext/v8/upstream/3.1.8/src/x64/virtual-frame-x64.h +593 -0
  472. data/ext/v8/upstream/3.1.8/src/zone-inl.h +83 -0
  473. data/ext/v8/upstream/3.1.8/src/zone.cc +195 -0
  474. data/ext/v8/upstream/3.1.8/src/zone.h +233 -0
  475. data/ext/v8/upstream/3.1.8/tools/codemap.js +265 -0
  476. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/consarray.js +0 -0
  477. data/ext/v8/upstream/3.1.8/tools/csvparser.js +78 -0
  478. data/ext/v8/upstream/3.1.8/tools/disasm.py +92 -0
  479. data/ext/v8/upstream/3.1.8/tools/gc-nvp-trace-processor.py +328 -0
  480. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/generate-ten-powers.scm +0 -0
  481. data/ext/v8/upstream/3.1.8/tools/grokdump.py +840 -0
  482. data/ext/v8/upstream/3.1.8/tools/gyp/v8.gyp +869 -0
  483. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/js2c.py +0 -0
  484. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/jsmin.py +0 -0
  485. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/linux-tick-processor +0 -0
  486. data/ext/v8/upstream/3.1.8/tools/ll_prof.py +919 -0
  487. data/ext/v8/upstream/3.1.8/tools/logreader.js +185 -0
  488. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/mac-nm +0 -0
  489. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/mac-tick-processor +0 -0
  490. data/ext/v8/upstream/3.1.8/tools/oom_dump/README +31 -0
  491. data/ext/v8/upstream/3.1.8/tools/oom_dump/SConstruct +42 -0
  492. data/ext/v8/upstream/3.1.8/tools/oom_dump/oom_dump.cc +288 -0
  493. data/ext/v8/upstream/3.1.8/tools/presubmit.py +305 -0
  494. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/process-heap-prof.py +0 -0
  495. data/ext/v8/upstream/3.1.8/tools/profile.js +751 -0
  496. data/ext/v8/upstream/3.1.8/tools/profile_view.js +219 -0
  497. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/run-valgrind.py +0 -0
  498. data/ext/v8/upstream/3.1.8/tools/splaytree.js +316 -0
  499. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/stats-viewer.py +0 -0
  500. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/tickprocessor-driver.js +0 -0
  501. data/ext/v8/upstream/3.1.8/tools/tickprocessor.js +863 -0
  502. data/ext/v8/upstream/3.1.8/tools/utils.py +96 -0
  503. data/ext/v8/upstream/3.1.8/tools/visual_studio/README.txt +70 -0
  504. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/visual_studio/arm.vsprops +0 -0
  505. data/ext/v8/upstream/3.1.8/tools/visual_studio/common.vsprops +34 -0
  506. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/visual_studio/d8.vcproj +0 -0
  507. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/visual_studio/d8_arm.vcproj +0 -0
  508. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/visual_studio/d8_x64.vcproj +0 -0
  509. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/visual_studio/d8js2c.cmd +0 -0
  510. data/ext/v8/upstream/3.1.8/tools/visual_studio/debug.vsprops +17 -0
  511. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/visual_studio/ia32.vsprops +0 -0
  512. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/visual_studio/js2c.cmd +0 -0
  513. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/visual_studio/release.vsprops +0 -0
  514. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/visual_studio/v8.sln +0 -0
  515. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/visual_studio/v8.vcproj +0 -0
  516. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/visual_studio/v8_arm.sln +0 -0
  517. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/visual_studio/v8_arm.vcproj +0 -0
  518. data/ext/v8/upstream/3.1.8/tools/visual_studio/v8_base.vcproj +1296 -0
  519. data/ext/v8/upstream/3.1.8/tools/visual_studio/v8_base_arm.vcproj +1234 -0
  520. data/ext/v8/upstream/3.1.8/tools/visual_studio/v8_base_x64.vcproj +1296 -0
  521. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/visual_studio/v8_cctest.vcproj +0 -0
  522. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/visual_studio/v8_cctest_arm.vcproj +0 -0
  523. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/visual_studio/v8_cctest_x64.vcproj +0 -0
  524. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/visual_studio/v8_mksnapshot.vcproj +0 -0
  525. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/visual_studio/v8_mksnapshot_x64.vcproj +0 -0
  526. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/visual_studio/v8_process_sample.vcproj +0 -0
  527. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/visual_studio/v8_process_sample_arm.vcproj +0 -0
  528. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/visual_studio/v8_process_sample_x64.vcproj +0 -0
  529. data/ext/v8/upstream/3.1.8/tools/visual_studio/v8_shell_sample.vcproj +147 -0
  530. data/ext/v8/upstream/3.1.8/tools/visual_studio/v8_shell_sample_arm.vcproj +147 -0
  531. data/ext/v8/upstream/3.1.8/tools/visual_studio/v8_shell_sample_x64.vcproj +163 -0
  532. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/visual_studio/v8_snapshot.vcproj +0 -0
  533. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/visual_studio/v8_snapshot_cc.vcproj +0 -0
  534. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/visual_studio/v8_snapshot_cc_x64.vcproj +0 -0
  535. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/visual_studio/v8_snapshot_x64.vcproj +0 -0
  536. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/visual_studio/v8_x64.sln +0 -0
  537. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/visual_studio/v8_x64.vcproj +0 -0
  538. data/ext/v8/upstream/{2.3.3 → 3.1.8}/tools/visual_studio/x64.vsprops +0 -0
  539. data/ext/v8/upstream/3.1.8/tools/windows-tick-processor.bat +30 -0
  540. data/ext/v8/upstream/Makefile +2 -1
  541. data/ext/v8/v8_template.cpp +2 -2
  542. data/lib/v8/version.rb +1 -1
  543. data/spec/redjs/jsapi_spec.rb +2 -2
  544. metadata +552 -490
  545. data/ext/v8/upstream/2.3.3/.gitignore +0 -26
  546. data/ext/v8/upstream/2.3.3/AUTHORS +0 -31
  547. data/ext/v8/upstream/2.3.3/ChangeLog +0 -1916
  548. data/ext/v8/upstream/2.3.3/LICENSE +0 -55
  549. data/ext/v8/upstream/2.3.3/SConstruct +0 -1154
  550. data/ext/v8/upstream/2.3.3/include/v8-debug.h +0 -381
  551. data/ext/v8/upstream/2.3.3/include/v8-profiler.h +0 -353
  552. data/ext/v8/upstream/2.3.3/include/v8.h +0 -3616
  553. data/ext/v8/upstream/2.3.3/src/SConscript +0 -330
  554. data/ext/v8/upstream/2.3.3/src/accessors.cc +0 -661
  555. data/ext/v8/upstream/2.3.3/src/accessors.h +0 -114
  556. data/ext/v8/upstream/2.3.3/src/allocation.cc +0 -198
  557. data/ext/v8/upstream/2.3.3/src/allocation.h +0 -169
  558. data/ext/v8/upstream/2.3.3/src/api.cc +0 -4795
  559. data/ext/v8/upstream/2.3.3/src/api.h +0 -485
  560. data/ext/v8/upstream/2.3.3/src/apiutils.h +0 -69
  561. data/ext/v8/upstream/2.3.3/src/arguments.h +0 -96
  562. data/ext/v8/upstream/2.3.3/src/arm/assembler-arm-inl.h +0 -305
  563. data/ext/v8/upstream/2.3.3/src/arm/assembler-arm.cc +0 -2580
  564. data/ext/v8/upstream/2.3.3/src/arm/assembler-arm.h +0 -1275
  565. data/ext/v8/upstream/2.3.3/src/arm/builtins-arm.cc +0 -1320
  566. data/ext/v8/upstream/2.3.3/src/arm/codegen-arm-inl.h +0 -48
  567. data/ext/v8/upstream/2.3.3/src/arm/codegen-arm.cc +0 -11398
  568. data/ext/v8/upstream/2.3.3/src/arm/codegen-arm.h +0 -1102
  569. data/ext/v8/upstream/2.3.3/src/arm/constants-arm.cc +0 -154
  570. data/ext/v8/upstream/2.3.3/src/arm/constants-arm.h +0 -388
  571. data/ext/v8/upstream/2.3.3/src/arm/cpu-arm.cc +0 -142
  572. data/ext/v8/upstream/2.3.3/src/arm/debug-arm.cc +0 -309
  573. data/ext/v8/upstream/2.3.3/src/arm/disasm-arm.cc +0 -1459
  574. data/ext/v8/upstream/2.3.3/src/arm/fast-codegen-arm.cc +0 -241
  575. data/ext/v8/upstream/2.3.3/src/arm/frames-arm.cc +0 -123
  576. data/ext/v8/upstream/2.3.3/src/arm/frames-arm.h +0 -162
  577. data/ext/v8/upstream/2.3.3/src/arm/full-codegen-arm.cc +0 -3178
  578. data/ext/v8/upstream/2.3.3/src/arm/ic-arm.cc +0 -2258
  579. data/ext/v8/upstream/2.3.3/src/arm/jump-target-arm.cc +0 -164
  580. data/ext/v8/upstream/2.3.3/src/arm/macro-assembler-arm.cc +0 -1892
  581. data/ext/v8/upstream/2.3.3/src/arm/macro-assembler-arm.h +0 -727
  582. data/ext/v8/upstream/2.3.3/src/arm/regexp-macro-assembler-arm.cc +0 -1261
  583. data/ext/v8/upstream/2.3.3/src/arm/regexp-macro-assembler-arm.h +0 -266
  584. data/ext/v8/upstream/2.3.3/src/arm/simulator-arm.cc +0 -2822
  585. data/ext/v8/upstream/2.3.3/src/arm/simulator-arm.h +0 -361
  586. data/ext/v8/upstream/2.3.3/src/arm/stub-cache-arm.cc +0 -2387
  587. data/ext/v8/upstream/2.3.3/src/arm/virtual-frame-arm.cc +0 -834
  588. data/ext/v8/upstream/2.3.3/src/arm/virtual-frame-arm.h +0 -519
  589. data/ext/v8/upstream/2.3.3/src/array.js +0 -1127
  590. data/ext/v8/upstream/2.3.3/src/assembler.cc +0 -801
  591. data/ext/v8/upstream/2.3.3/src/assembler.h +0 -573
  592. data/ext/v8/upstream/2.3.3/src/ast-inl.h +0 -81
  593. data/ext/v8/upstream/2.3.3/src/ast.cc +0 -1152
  594. data/ext/v8/upstream/2.3.3/src/ast.h +0 -2106
  595. data/ext/v8/upstream/2.3.3/src/bootstrapper.cc +0 -1819
  596. data/ext/v8/upstream/2.3.3/src/builtins.cc +0 -1529
  597. data/ext/v8/upstream/2.3.3/src/builtins.h +0 -263
  598. data/ext/v8/upstream/2.3.3/src/bytecodes-irregexp.h +0 -104
  599. data/ext/v8/upstream/2.3.3/src/cached-powers.h +0 -119
  600. data/ext/v8/upstream/2.3.3/src/char-predicates-inl.h +0 -86
  601. data/ext/v8/upstream/2.3.3/src/checks.cc +0 -100
  602. data/ext/v8/upstream/2.3.3/src/checks.h +0 -310
  603. data/ext/v8/upstream/2.3.3/src/circular-queue.cc +0 -121
  604. data/ext/v8/upstream/2.3.3/src/code-stubs.cc +0 -177
  605. data/ext/v8/upstream/2.3.3/src/code-stubs.h +0 -177
  606. data/ext/v8/upstream/2.3.3/src/codegen-inl.h +0 -60
  607. data/ext/v8/upstream/2.3.3/src/codegen.cc +0 -516
  608. data/ext/v8/upstream/2.3.3/src/codegen.h +0 -897
  609. data/ext/v8/upstream/2.3.3/src/compilation-cache.cc +0 -562
  610. data/ext/v8/upstream/2.3.3/src/compilation-cache.h +0 -102
  611. data/ext/v8/upstream/2.3.3/src/compiler.cc +0 -654
  612. data/ext/v8/upstream/2.3.3/src/compiler.h +0 -299
  613. data/ext/v8/upstream/2.3.3/src/contexts.cc +0 -256
  614. data/ext/v8/upstream/2.3.3/src/contexts.h +0 -342
  615. data/ext/v8/upstream/2.3.3/src/conversions.cc +0 -1119
  616. data/ext/v8/upstream/2.3.3/src/conversions.h +0 -123
  617. data/ext/v8/upstream/2.3.3/src/counters.h +0 -239
  618. data/ext/v8/upstream/2.3.3/src/cpu-profiler-inl.h +0 -100
  619. data/ext/v8/upstream/2.3.3/src/cpu-profiler.cc +0 -538
  620. data/ext/v8/upstream/2.3.3/src/cpu-profiler.h +0 -285
  621. data/ext/v8/upstream/2.3.3/src/d8-debug.cc +0 -356
  622. data/ext/v8/upstream/2.3.3/src/d8-debug.h +0 -155
  623. data/ext/v8/upstream/2.3.3/src/d8.cc +0 -783
  624. data/ext/v8/upstream/2.3.3/src/d8.h +0 -227
  625. data/ext/v8/upstream/2.3.3/src/d8.js +0 -1683
  626. data/ext/v8/upstream/2.3.3/src/data-flow.cc +0 -758
  627. data/ext/v8/upstream/2.3.3/src/data-flow.h +0 -278
  628. data/ext/v8/upstream/2.3.3/src/date.js +0 -1059
  629. data/ext/v8/upstream/2.3.3/src/dateparser-inl.h +0 -123
  630. data/ext/v8/upstream/2.3.3/src/dateparser.h +0 -244
  631. data/ext/v8/upstream/2.3.3/src/debug-agent.cc +0 -427
  632. data/ext/v8/upstream/2.3.3/src/debug-agent.h +0 -129
  633. data/ext/v8/upstream/2.3.3/src/debug-debugger.js +0 -2227
  634. data/ext/v8/upstream/2.3.3/src/debug.cc +0 -3005
  635. data/ext/v8/upstream/2.3.3/src/debug.h +0 -993
  636. data/ext/v8/upstream/2.3.3/src/disassembler.cc +0 -312
  637. data/ext/v8/upstream/2.3.3/src/double.h +0 -169
  638. data/ext/v8/upstream/2.3.3/src/dtoa-config.c +0 -92
  639. data/ext/v8/upstream/2.3.3/src/dtoa.cc +0 -77
  640. data/ext/v8/upstream/2.3.3/src/dtoa.h +0 -81
  641. data/ext/v8/upstream/2.3.3/src/execution.cc +0 -809
  642. data/ext/v8/upstream/2.3.3/src/execution.h +0 -336
  643. data/ext/v8/upstream/2.3.3/src/factory.cc +0 -1003
  644. data/ext/v8/upstream/2.3.3/src/factory.h +0 -410
  645. data/ext/v8/upstream/2.3.3/src/fast-codegen.cc +0 -746
  646. data/ext/v8/upstream/2.3.3/src/fast-codegen.h +0 -161
  647. data/ext/v8/upstream/2.3.3/src/fast-dtoa.cc +0 -505
  648. data/ext/v8/upstream/2.3.3/src/fast-dtoa.h +0 -58
  649. data/ext/v8/upstream/2.3.3/src/flag-definitions.h +0 -455
  650. data/ext/v8/upstream/2.3.3/src/flags.cc +0 -551
  651. data/ext/v8/upstream/2.3.3/src/flags.h +0 -81
  652. data/ext/v8/upstream/2.3.3/src/flow-graph.cc +0 -763
  653. data/ext/v8/upstream/2.3.3/src/flow-graph.h +0 -180
  654. data/ext/v8/upstream/2.3.3/src/frame-element.h +0 -273
  655. data/ext/v8/upstream/2.3.3/src/frames-inl.h +0 -217
  656. data/ext/v8/upstream/2.3.3/src/frames.cc +0 -826
  657. data/ext/v8/upstream/2.3.3/src/frames.h +0 -682
  658. data/ext/v8/upstream/2.3.3/src/full-codegen.cc +0 -1443
  659. data/ext/v8/upstream/2.3.3/src/full-codegen.h +0 -548
  660. data/ext/v8/upstream/2.3.3/src/func-name-inferrer.cc +0 -76
  661. data/ext/v8/upstream/2.3.3/src/func-name-inferrer.h +0 -135
  662. data/ext/v8/upstream/2.3.3/src/global-handles.cc +0 -520
  663. data/ext/v8/upstream/2.3.3/src/global-handles.h +0 -180
  664. data/ext/v8/upstream/2.3.3/src/globals.h +0 -669
  665. data/ext/v8/upstream/2.3.3/src/handles-inl.h +0 -76
  666. data/ext/v8/upstream/2.3.3/src/handles.cc +0 -825
  667. data/ext/v8/upstream/2.3.3/src/handles.h +0 -393
  668. data/ext/v8/upstream/2.3.3/src/hashmap.cc +0 -226
  669. data/ext/v8/upstream/2.3.3/src/hashmap.h +0 -120
  670. data/ext/v8/upstream/2.3.3/src/heap-inl.h +0 -493
  671. data/ext/v8/upstream/2.3.3/src/heap-profiler.cc +0 -779
  672. data/ext/v8/upstream/2.3.3/src/heap-profiler.h +0 -323
  673. data/ext/v8/upstream/2.3.3/src/heap.cc +0 -4994
  674. data/ext/v8/upstream/2.3.3/src/heap.h +0 -1984
  675. data/ext/v8/upstream/2.3.3/src/ia32/assembler-ia32-inl.h +0 -360
  676. data/ext/v8/upstream/2.3.3/src/ia32/assembler-ia32.cc +0 -2600
  677. data/ext/v8/upstream/2.3.3/src/ia32/assembler-ia32.h +0 -969
  678. data/ext/v8/upstream/2.3.3/src/ia32/builtins-ia32.cc +0 -1261
  679. data/ext/v8/upstream/2.3.3/src/ia32/codegen-ia32.cc +0 -13968
  680. data/ext/v8/upstream/2.3.3/src/ia32/codegen-ia32.h +0 -1097
  681. data/ext/v8/upstream/2.3.3/src/ia32/cpu-ia32.cc +0 -83
  682. data/ext/v8/upstream/2.3.3/src/ia32/debug-ia32.cc +0 -309
  683. data/ext/v8/upstream/2.3.3/src/ia32/disasm-ia32.cc +0 -1471
  684. data/ext/v8/upstream/2.3.3/src/ia32/fast-codegen-ia32.cc +0 -954
  685. data/ext/v8/upstream/2.3.3/src/ia32/fast-codegen-ia32.h +0 -155
  686. data/ext/v8/upstream/2.3.3/src/ia32/frames-ia32.cc +0 -115
  687. data/ext/v8/upstream/2.3.3/src/ia32/frames-ia32.h +0 -135
  688. data/ext/v8/upstream/2.3.3/src/ia32/full-codegen-ia32.cc +0 -3281
  689. data/ext/v8/upstream/2.3.3/src/ia32/ic-ia32.cc +0 -1966
  690. data/ext/v8/upstream/2.3.3/src/ia32/macro-assembler-ia32.cc +0 -1610
  691. data/ext/v8/upstream/2.3.3/src/ia32/macro-assembler-ia32.h +0 -610
  692. data/ext/v8/upstream/2.3.3/src/ia32/regexp-macro-assembler-ia32.cc +0 -1247
  693. data/ext/v8/upstream/2.3.3/src/ia32/regexp-macro-assembler-ia32.h +0 -214
  694. data/ext/v8/upstream/2.3.3/src/ia32/simulator-ia32.h +0 -62
  695. data/ext/v8/upstream/2.3.3/src/ia32/stub-cache-ia32.cc +0 -2750
  696. data/ext/v8/upstream/2.3.3/src/ia32/virtual-frame-ia32.cc +0 -1334
  697. data/ext/v8/upstream/2.3.3/src/ia32/virtual-frame-ia32.h +0 -627
  698. data/ext/v8/upstream/2.3.3/src/ic-inl.h +0 -120
  699. data/ext/v8/upstream/2.3.3/src/ic.cc +0 -1827
  700. data/ext/v8/upstream/2.3.3/src/ic.h +0 -515
  701. data/ext/v8/upstream/2.3.3/src/interpreter-irregexp.cc +0 -646
  702. data/ext/v8/upstream/2.3.3/src/json.js +0 -268
  703. data/ext/v8/upstream/2.3.3/src/jsregexp.cc +0 -5283
  704. data/ext/v8/upstream/2.3.3/src/jsregexp.h +0 -1463
  705. data/ext/v8/upstream/2.3.3/src/jump-target-heavy.cc +0 -429
  706. data/ext/v8/upstream/2.3.3/src/jump-target-heavy.h +0 -244
  707. data/ext/v8/upstream/2.3.3/src/jump-target-light.cc +0 -110
  708. data/ext/v8/upstream/2.3.3/src/jump-target-light.h +0 -192
  709. data/ext/v8/upstream/2.3.3/src/list-inl.h +0 -166
  710. data/ext/v8/upstream/2.3.3/src/list.h +0 -159
  711. data/ext/v8/upstream/2.3.3/src/liveedit-debugger.js +0 -1057
  712. data/ext/v8/upstream/2.3.3/src/liveedit.cc +0 -1480
  713. data/ext/v8/upstream/2.3.3/src/liveedit.h +0 -170
  714. data/ext/v8/upstream/2.3.3/src/log-utils.cc +0 -497
  715. data/ext/v8/upstream/2.3.3/src/log-utils.h +0 -289
  716. data/ext/v8/upstream/2.3.3/src/log.cc +0 -1561
  717. data/ext/v8/upstream/2.3.3/src/log.h +0 -384
  718. data/ext/v8/upstream/2.3.3/src/macro-assembler.h +0 -86
  719. data/ext/v8/upstream/2.3.3/src/macros.py +0 -177
  720. data/ext/v8/upstream/2.3.3/src/mark-compact.cc +0 -2330
  721. data/ext/v8/upstream/2.3.3/src/mark-compact.h +0 -451
  722. data/ext/v8/upstream/2.3.3/src/math.js +0 -264
  723. data/ext/v8/upstream/2.3.3/src/memory.h +0 -74
  724. data/ext/v8/upstream/2.3.3/src/messages.cc +0 -183
  725. data/ext/v8/upstream/2.3.3/src/messages.h +0 -113
  726. data/ext/v8/upstream/2.3.3/src/messages.js +0 -982
  727. data/ext/v8/upstream/2.3.3/src/mips/assembler-mips.h +0 -668
  728. data/ext/v8/upstream/2.3.3/src/mips/builtins-mips.cc +0 -205
  729. data/ext/v8/upstream/2.3.3/src/mips/codegen-mips.h +0 -434
  730. data/ext/v8/upstream/2.3.3/src/mips/debug-mips.cc +0 -131
  731. data/ext/v8/upstream/2.3.3/src/mips/frames-mips.cc +0 -102
  732. data/ext/v8/upstream/2.3.3/src/mips/ic-mips.cc +0 -220
  733. data/ext/v8/upstream/2.3.3/src/mips/simulator-mips.cc +0 -1651
  734. data/ext/v8/upstream/2.3.3/src/mips/simulator-mips.h +0 -311
  735. data/ext/v8/upstream/2.3.3/src/mips/stub-cache-mips.cc +0 -403
  736. data/ext/v8/upstream/2.3.3/src/mirror-debugger.js +0 -2380
  737. data/ext/v8/upstream/2.3.3/src/objects-debug.cc +0 -1366
  738. data/ext/v8/upstream/2.3.3/src/objects-inl.h +0 -3333
  739. data/ext/v8/upstream/2.3.3/src/objects.cc +0 -8820
  740. data/ext/v8/upstream/2.3.3/src/objects.h +0 -5373
  741. data/ext/v8/upstream/2.3.3/src/oprofile-agent.cc +0 -108
  742. data/ext/v8/upstream/2.3.3/src/oprofile-agent.h +0 -77
  743. data/ext/v8/upstream/2.3.3/src/parser.cc +0 -5207
  744. data/ext/v8/upstream/2.3.3/src/parser.h +0 -197
  745. data/ext/v8/upstream/2.3.3/src/platform-freebsd.cc +0 -667
  746. data/ext/v8/upstream/2.3.3/src/platform-linux.cc +0 -862
  747. data/ext/v8/upstream/2.3.3/src/platform-macos.cc +0 -665
  748. data/ext/v8/upstream/2.3.3/src/platform-nullos.cc +0 -454
  749. data/ext/v8/upstream/2.3.3/src/platform-openbsd.cc +0 -622
  750. data/ext/v8/upstream/2.3.3/src/platform-posix.cc +0 -362
  751. data/ext/v8/upstream/2.3.3/src/platform-solaris.cc +0 -653
  752. data/ext/v8/upstream/2.3.3/src/platform-win32.cc +0 -1911
  753. data/ext/v8/upstream/2.3.3/src/platform.h +0 -577
  754. data/ext/v8/upstream/2.3.3/src/powers-ten.h +0 -2461
  755. data/ext/v8/upstream/2.3.3/src/prettyprinter.cc +0 -1531
  756. data/ext/v8/upstream/2.3.3/src/prettyprinter.h +0 -221
  757. data/ext/v8/upstream/2.3.3/src/profile-generator-inl.h +0 -148
  758. data/ext/v8/upstream/2.3.3/src/profile-generator.cc +0 -1830
  759. data/ext/v8/upstream/2.3.3/src/profile-generator.h +0 -853
  760. data/ext/v8/upstream/2.3.3/src/property.cc +0 -96
  761. data/ext/v8/upstream/2.3.3/src/property.h +0 -315
  762. data/ext/v8/upstream/2.3.3/src/regexp-macro-assembler-irregexp.cc +0 -464
  763. data/ext/v8/upstream/2.3.3/src/regexp-macro-assembler-irregexp.h +0 -141
  764. data/ext/v8/upstream/2.3.3/src/regexp-macro-assembler-tracer.cc +0 -356
  765. data/ext/v8/upstream/2.3.3/src/regexp-macro-assembler-tracer.h +0 -103
  766. data/ext/v8/upstream/2.3.3/src/regexp-macro-assembler.cc +0 -261
  767. data/ext/v8/upstream/2.3.3/src/regexp-macro-assembler.h +0 -228
  768. data/ext/v8/upstream/2.3.3/src/regexp.js +0 -549
  769. data/ext/v8/upstream/2.3.3/src/rewriter.cc +0 -1038
  770. data/ext/v8/upstream/2.3.3/src/rewriter.h +0 -54
  771. data/ext/v8/upstream/2.3.3/src/runtime.cc +0 -10599
  772. data/ext/v8/upstream/2.3.3/src/runtime.h +0 -459
  773. data/ext/v8/upstream/2.3.3/src/runtime.js +0 -629
  774. data/ext/v8/upstream/2.3.3/src/scanner.cc +0 -1346
  775. data/ext/v8/upstream/2.3.3/src/scanner.h +0 -503
  776. data/ext/v8/upstream/2.3.3/src/scopeinfo.cc +0 -637
  777. data/ext/v8/upstream/2.3.3/src/scopeinfo.h +0 -233
  778. data/ext/v8/upstream/2.3.3/src/scopes.cc +0 -962
  779. data/ext/v8/upstream/2.3.3/src/scopes.h +0 -400
  780. data/ext/v8/upstream/2.3.3/src/serialize.cc +0 -1461
  781. data/ext/v8/upstream/2.3.3/src/serialize.h +0 -581
  782. data/ext/v8/upstream/2.3.3/src/spaces-inl.h +0 -483
  783. data/ext/v8/upstream/2.3.3/src/spaces.cc +0 -2901
  784. data/ext/v8/upstream/2.3.3/src/spaces.h +0 -2197
  785. data/ext/v8/upstream/2.3.3/src/string-stream.cc +0 -584
  786. data/ext/v8/upstream/2.3.3/src/string-stream.h +0 -189
  787. data/ext/v8/upstream/2.3.3/src/string.js +0 -1006
  788. data/ext/v8/upstream/2.3.3/src/stub-cache.cc +0 -1379
  789. data/ext/v8/upstream/2.3.3/src/stub-cache.h +0 -756
  790. data/ext/v8/upstream/2.3.3/src/third_party/dtoa/COPYING +0 -15
  791. data/ext/v8/upstream/2.3.3/src/third_party/dtoa/dtoa.c +0 -3334
  792. data/ext/v8/upstream/2.3.3/src/token.cc +0 -56
  793. data/ext/v8/upstream/2.3.3/src/token.h +0 -270
  794. data/ext/v8/upstream/2.3.3/src/top.cc +0 -1067
  795. data/ext/v8/upstream/2.3.3/src/top.h +0 -463
  796. data/ext/v8/upstream/2.3.3/src/type-info.cc +0 -53
  797. data/ext/v8/upstream/2.3.3/src/type-info.h +0 -244
  798. data/ext/v8/upstream/2.3.3/src/unicode-inl.h +0 -238
  799. data/ext/v8/upstream/2.3.3/src/unicode.cc +0 -749
  800. data/ext/v8/upstream/2.3.3/src/unicode.h +0 -279
  801. data/ext/v8/upstream/2.3.3/src/uri.js +0 -415
  802. data/ext/v8/upstream/2.3.3/src/utils.cc +0 -285
  803. data/ext/v8/upstream/2.3.3/src/utils.h +0 -745
  804. data/ext/v8/upstream/2.3.3/src/v8-counters.h +0 -250
  805. data/ext/v8/upstream/2.3.3/src/v8.cc +0 -228
  806. data/ext/v8/upstream/2.3.3/src/v8.h +0 -121
  807. data/ext/v8/upstream/2.3.3/src/v8natives.js +0 -1188
  808. data/ext/v8/upstream/2.3.3/src/v8threads.cc +0 -461
  809. data/ext/v8/upstream/2.3.3/src/v8threads.h +0 -159
  810. data/ext/v8/upstream/2.3.3/src/variables.cc +0 -119
  811. data/ext/v8/upstream/2.3.3/src/variables.h +0 -205
  812. data/ext/v8/upstream/2.3.3/src/version.cc +0 -88
  813. data/ext/v8/upstream/2.3.3/src/virtual-frame-heavy-inl.h +0 -192
  814. data/ext/v8/upstream/2.3.3/src/virtual-frame.h +0 -46
  815. data/ext/v8/upstream/2.3.3/src/vm-state-inl.h +0 -137
  816. data/ext/v8/upstream/2.3.3/src/vm-state.cc +0 -39
  817. data/ext/v8/upstream/2.3.3/src/vm-state.h +0 -77
  818. data/ext/v8/upstream/2.3.3/src/x64/assembler-x64-inl.h +0 -400
  819. data/ext/v8/upstream/2.3.3/src/x64/assembler-x64.cc +0 -2963
  820. data/ext/v8/upstream/2.3.3/src/x64/assembler-x64.h +0 -1438
  821. data/ext/v8/upstream/2.3.3/src/x64/builtins-x64.cc +0 -1296
  822. data/ext/v8/upstream/2.3.3/src/x64/codegen-x64-inl.h +0 -46
  823. data/ext/v8/upstream/2.3.3/src/x64/codegen-x64.cc +0 -12491
  824. data/ext/v8/upstream/2.3.3/src/x64/codegen-x64.h +0 -1090
  825. data/ext/v8/upstream/2.3.3/src/x64/cpu-x64.cc +0 -83
  826. data/ext/v8/upstream/2.3.3/src/x64/debug-x64.cc +0 -267
  827. data/ext/v8/upstream/2.3.3/src/x64/disasm-x64.cc +0 -1696
  828. data/ext/v8/upstream/2.3.3/src/x64/fast-codegen-x64.cc +0 -250
  829. data/ext/v8/upstream/2.3.3/src/x64/frames-x64.cc +0 -113
  830. data/ext/v8/upstream/2.3.3/src/x64/frames-x64.h +0 -125
  831. data/ext/v8/upstream/2.3.3/src/x64/full-codegen-x64.cc +0 -3270
  832. data/ext/v8/upstream/2.3.3/src/x64/ic-x64.cc +0 -1907
  833. data/ext/v8/upstream/2.3.3/src/x64/jump-target-x64.cc +0 -437
  834. data/ext/v8/upstream/2.3.3/src/x64/macro-assembler-x64.cc +0 -2793
  835. data/ext/v8/upstream/2.3.3/src/x64/macro-assembler-x64.h +0 -916
  836. data/ext/v8/upstream/2.3.3/src/x64/regexp-macro-assembler-x64.cc +0 -1374
  837. data/ext/v8/upstream/2.3.3/src/x64/regexp-macro-assembler-x64.h +0 -277
  838. data/ext/v8/upstream/2.3.3/src/x64/simulator-x64.h +0 -63
  839. data/ext/v8/upstream/2.3.3/src/x64/stub-cache-x64.cc +0 -2560
  840. data/ext/v8/upstream/2.3.3/src/x64/virtual-frame-x64.cc +0 -1264
  841. data/ext/v8/upstream/2.3.3/src/x64/virtual-frame-x64.h +0 -590
  842. data/ext/v8/upstream/2.3.3/src/zone-inl.h +0 -82
  843. data/ext/v8/upstream/2.3.3/src/zone.cc +0 -194
  844. data/ext/v8/upstream/2.3.3/src/zone.h +0 -221
  845. data/ext/v8/upstream/2.3.3/tools/codemap.js +0 -270
  846. data/ext/v8/upstream/2.3.3/tools/csvparser.js +0 -83
  847. data/ext/v8/upstream/2.3.3/tools/gc-nvp-trace-processor.py +0 -317
  848. data/ext/v8/upstream/2.3.3/tools/gyp/v8.gyp +0 -749
  849. data/ext/v8/upstream/2.3.3/tools/linux-tick-processor.py +0 -78
  850. data/ext/v8/upstream/2.3.3/tools/logreader.js +0 -338
  851. data/ext/v8/upstream/2.3.3/tools/oprofile/annotate +0 -7
  852. data/ext/v8/upstream/2.3.3/tools/oprofile/common +0 -19
  853. data/ext/v8/upstream/2.3.3/tools/oprofile/dump +0 -7
  854. data/ext/v8/upstream/2.3.3/tools/oprofile/report +0 -7
  855. data/ext/v8/upstream/2.3.3/tools/oprofile/reset +0 -7
  856. data/ext/v8/upstream/2.3.3/tools/oprofile/run +0 -14
  857. data/ext/v8/upstream/2.3.3/tools/oprofile/shutdown +0 -7
  858. data/ext/v8/upstream/2.3.3/tools/oprofile/start +0 -7
  859. data/ext/v8/upstream/2.3.3/tools/presubmit.py +0 -299
  860. data/ext/v8/upstream/2.3.3/tools/profile.js +0 -691
  861. data/ext/v8/upstream/2.3.3/tools/profile_view.js +0 -224
  862. data/ext/v8/upstream/2.3.3/tools/splaytree.js +0 -322
  863. data/ext/v8/upstream/2.3.3/tools/splaytree.py +0 -226
  864. data/ext/v8/upstream/2.3.3/tools/tickprocessor.js +0 -862
  865. data/ext/v8/upstream/2.3.3/tools/tickprocessor.py +0 -571
  866. data/ext/v8/upstream/2.3.3/tools/utils.py +0 -88
  867. data/ext/v8/upstream/2.3.3/tools/visual_studio/README.txt +0 -71
  868. data/ext/v8/upstream/2.3.3/tools/visual_studio/common.vsprops +0 -34
  869. data/ext/v8/upstream/2.3.3/tools/visual_studio/debug.vsprops +0 -17
  870. data/ext/v8/upstream/2.3.3/tools/visual_studio/v8_base.vcproj +0 -1143
  871. data/ext/v8/upstream/2.3.3/tools/visual_studio/v8_base_arm.vcproj +0 -1115
  872. data/ext/v8/upstream/2.3.3/tools/visual_studio/v8_base_x64.vcproj +0 -1096
  873. data/ext/v8/upstream/2.3.3/tools/visual_studio/v8_shell_sample.vcproj +0 -145
  874. data/ext/v8/upstream/2.3.3/tools/visual_studio/v8_shell_sample_arm.vcproj +0 -145
  875. data/ext/v8/upstream/2.3.3/tools/visual_studio/v8_shell_sample_x64.vcproj +0 -161
  876. data/ext/v8/upstream/2.3.3/tools/windows-tick-processor.bat +0 -29
  877. data/ext/v8/upstream/2.3.3/tools/windows-tick-processor.py +0 -137
@@ -0,0 +1,223 @@
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_PRETTYPRINTER_H_
29
+ #define V8_PRETTYPRINTER_H_
30
+
31
+ #include "ast.h"
32
+
33
+ namespace v8 {
34
+ namespace internal {
35
+
36
+ #ifdef DEBUG
37
+
38
+ class PrettyPrinter: public AstVisitor {
39
+ public:
40
+ PrettyPrinter();
41
+ virtual ~PrettyPrinter();
42
+
43
+ // The following routines print a node into a string.
44
+ // The result string is alive as long as the PrettyPrinter is alive.
45
+ const char* Print(AstNode* node);
46
+ const char* PrintExpression(FunctionLiteral* program);
47
+ const char* PrintProgram(FunctionLiteral* program);
48
+
49
+ void Print(const char* format, ...);
50
+
51
+ // Print a node to stdout.
52
+ static void PrintOut(AstNode* node);
53
+
54
+ virtual void VisitSlot(Slot* node);
55
+ // Individual nodes
56
+ #define DECLARE_VISIT(type) virtual void Visit##type(type* node);
57
+ AST_NODE_LIST(DECLARE_VISIT)
58
+ #undef DECLARE_VISIT
59
+
60
+ private:
61
+ char* output_; // output string buffer
62
+ int size_; // output_ size
63
+ int pos_; // current printing position
64
+
65
+ protected:
66
+ void Init();
67
+ const char* Output() const { return output_; }
68
+
69
+ virtual void PrintStatements(ZoneList<Statement*>* statements);
70
+ void PrintLabels(ZoneStringList* labels);
71
+ virtual void PrintArguments(ZoneList<Expression*>* arguments);
72
+ void PrintLiteral(Handle<Object> value, bool quote);
73
+ void PrintParameters(Scope* scope);
74
+ void PrintDeclarations(ZoneList<Declaration*>* declarations);
75
+ void PrintFunctionLiteral(FunctionLiteral* function);
76
+ void PrintCaseClause(CaseClause* clause);
77
+ };
78
+
79
+
80
+ // Prints the AST structure
81
+ class AstPrinter: public PrettyPrinter {
82
+ public:
83
+ AstPrinter();
84
+ virtual ~AstPrinter();
85
+
86
+ const char* PrintProgram(FunctionLiteral* program);
87
+
88
+ // Individual nodes
89
+ virtual void VisitSlot(Slot* node);
90
+ #define DECLARE_VISIT(type) virtual void Visit##type(type* node);
91
+ AST_NODE_LIST(DECLARE_VISIT)
92
+ #undef DECLARE_VISIT
93
+
94
+ private:
95
+ friend class IndentedScope;
96
+ void PrintIndented(const char* txt);
97
+ void PrintIndentedVisit(const char* s, AstNode* node);
98
+
99
+ void PrintStatements(ZoneList<Statement*>* statements);
100
+ void PrintDeclarations(ZoneList<Declaration*>* declarations);
101
+ void PrintParameters(Scope* scope);
102
+ void PrintArguments(ZoneList<Expression*>* arguments);
103
+ void PrintCaseClause(CaseClause* clause);
104
+ void PrintLiteralIndented(const char* info, Handle<Object> value, bool quote);
105
+ void PrintLiteralWithModeIndented(const char* info,
106
+ Variable* var,
107
+ Handle<Object> value,
108
+ StaticType* type);
109
+ void PrintLabelsIndented(const char* info, ZoneStringList* labels);
110
+
111
+ void inc_indent() { indent_++; }
112
+ void dec_indent() { indent_--; }
113
+
114
+ static int indent_;
115
+ };
116
+
117
+
118
+ // Forward declaration of helper classes.
119
+ class TagScope;
120
+ class AttributesScope;
121
+
122
+ // Build a C string containing a JSON representation of a function's
123
+ // AST. The representation is based on JsonML (www.jsonml.org).
124
+ class JsonAstBuilder: public PrettyPrinter {
125
+ public:
126
+ JsonAstBuilder()
127
+ : indent_(0), top_tag_scope_(NULL), attributes_scope_(NULL) {
128
+ }
129
+ virtual ~JsonAstBuilder() {}
130
+
131
+ // Controls the indentation of subsequent lines of a tag body after
132
+ // the first line.
133
+ static const int kTagIndentSize = 2;
134
+
135
+ // Controls the indentation of subsequent lines of an attributes
136
+ // blocks's body after the first line.
137
+ static const int kAttributesIndentSize = 1;
138
+
139
+ // Construct a JSON representation of a function literal.
140
+ const char* BuildProgram(FunctionLiteral* program);
141
+
142
+ // Print text indented by the current indentation level.
143
+ void PrintIndented(const char* text) { Print("%*s%s", indent_, "", text); }
144
+
145
+ // Change the indentation level.
146
+ void increase_indent(int amount) { indent_ += amount; }
147
+ void decrease_indent(int amount) { indent_ -= amount; }
148
+
149
+ // The builder maintains a stack of opened AST node constructors.
150
+ // Each node constructor corresponds to a JsonML tag.
151
+ TagScope* tag() { return top_tag_scope_; }
152
+ void set_tag(TagScope* scope) { top_tag_scope_ = scope; }
153
+
154
+ // The builder maintains a pointer to the currently opened attributes
155
+ // of current AST node or NULL if the attributes are not opened.
156
+ AttributesScope* attributes() { return attributes_scope_; }
157
+ void set_attributes(AttributesScope* scope) { attributes_scope_ = scope; }
158
+
159
+ // Add an attribute to the currently opened attributes.
160
+ void AddAttribute(const char* name, Handle<String> value);
161
+ void AddAttribute(const char* name, const char* value);
162
+ void AddAttribute(const char* name, int value);
163
+ void AddAttribute(const char* name, bool value);
164
+
165
+ // AST node visit functions.
166
+ virtual void VisitSlot(Slot* node);
167
+ #define DECLARE_VISIT(type) virtual void Visit##type(type* node);
168
+ AST_NODE_LIST(DECLARE_VISIT)
169
+ #undef DECLARE_VISIT
170
+
171
+ private:
172
+ int indent_;
173
+ TagScope* top_tag_scope_;
174
+ AttributesScope* attributes_scope_;
175
+
176
+ // Utility function used by AddAttribute implementations.
177
+ void AddAttributePrefix(const char* name);
178
+ };
179
+
180
+
181
+ // The JSON AST builder keeps a stack of open element tags (AST node
182
+ // constructors from the current iteration point to the root of the
183
+ // AST). TagScope is a helper class to manage the opening and closing
184
+ // of tags, the indentation of their bodies, and comma separating their
185
+ // contents.
186
+ class TagScope BASE_EMBEDDED {
187
+ public:
188
+ TagScope(JsonAstBuilder* builder, const char* name);
189
+ ~TagScope();
190
+
191
+ void use() { has_body_ = true; }
192
+
193
+ private:
194
+ JsonAstBuilder* builder_;
195
+ TagScope* next_;
196
+ bool has_body_;
197
+ };
198
+
199
+
200
+ // AttributesScope is a helper class to manage the opening and closing
201
+ // of attribute blocks, the indentation of their bodies, and comma
202
+ // separating their contents. JsonAstBuilder::AddAttribute adds an
203
+ // attribute to the currently open AttributesScope. They cannot be
204
+ // nested so the builder keeps an optional single scope rather than a
205
+ // stack.
206
+ class AttributesScope BASE_EMBEDDED {
207
+ public:
208
+ explicit AttributesScope(JsonAstBuilder* builder);
209
+ ~AttributesScope();
210
+
211
+ bool is_used() { return attribute_count_ > 0; }
212
+ void use() { ++attribute_count_; }
213
+
214
+ private:
215
+ JsonAstBuilder* builder_;
216
+ int attribute_count_;
217
+ };
218
+
219
+ #endif // DEBUG
220
+
221
+ } } // namespace v8::internal
222
+
223
+ #endif // V8_PRETTYPRINTER_H_
@@ -0,0 +1,128 @@
1
+ // Copyright 2010 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_PROFILE_GENERATOR_INL_H_
29
+ #define V8_PROFILE_GENERATOR_INL_H_
30
+
31
+ #ifdef ENABLE_LOGGING_AND_PROFILING
32
+
33
+ #include "profile-generator.h"
34
+
35
+ namespace v8 {
36
+ namespace internal {
37
+
38
+ const char* StringsStorage::GetFunctionName(String* name) {
39
+ return GetFunctionName(GetName(name));
40
+ }
41
+
42
+
43
+ const char* StringsStorage::GetFunctionName(const char* name) {
44
+ return strlen(name) > 0 ? name : ProfileGenerator::kAnonymousFunctionName;
45
+ }
46
+
47
+
48
+ CodeEntry::CodeEntry(Logger::LogEventsAndTags tag,
49
+ const char* name_prefix,
50
+ const char* name,
51
+ const char* resource_name,
52
+ int line_number,
53
+ int security_token_id)
54
+ : tag_(tag),
55
+ name_prefix_(name_prefix),
56
+ name_(name),
57
+ resource_name_(resource_name),
58
+ line_number_(line_number),
59
+ shared_id_(0),
60
+ security_token_id_(security_token_id) {
61
+ }
62
+
63
+
64
+ bool CodeEntry::is_js_function_tag(Logger::LogEventsAndTags tag) {
65
+ return tag == Logger::FUNCTION_TAG
66
+ || tag == Logger::LAZY_COMPILE_TAG
67
+ || tag == Logger::SCRIPT_TAG
68
+ || tag == Logger::NATIVE_FUNCTION_TAG
69
+ || tag == Logger::NATIVE_LAZY_COMPILE_TAG
70
+ || tag == Logger::NATIVE_SCRIPT_TAG;
71
+ }
72
+
73
+
74
+ ProfileNode::ProfileNode(ProfileTree* tree, CodeEntry* entry)
75
+ : tree_(tree),
76
+ entry_(entry),
77
+ total_ticks_(0),
78
+ self_ticks_(0),
79
+ children_(CodeEntriesMatch) {
80
+ }
81
+
82
+
83
+ void CodeMap::AddCode(Address addr, CodeEntry* entry, unsigned size) {
84
+ CodeTree::Locator locator;
85
+ tree_.Insert(addr, &locator);
86
+ locator.set_value(CodeEntryInfo(entry, size));
87
+ }
88
+
89
+
90
+ void CodeMap::MoveCode(Address from, Address to) {
91
+ tree_.Move(from, to);
92
+ }
93
+
94
+ void CodeMap::DeleteCode(Address addr) {
95
+ tree_.Remove(addr);
96
+ }
97
+
98
+
99
+ CodeEntry* ProfileGenerator::EntryForVMState(StateTag tag) {
100
+ switch (tag) {
101
+ case GC:
102
+ return gc_entry_;
103
+ case JS:
104
+ case COMPILER:
105
+ // DOM events handlers are reported as OTHER / EXTERNAL entries.
106
+ // To avoid confusing people, let's put all these entries into
107
+ // one bucket.
108
+ case OTHER:
109
+ case EXTERNAL:
110
+ return program_entry_;
111
+ default: return NULL;
112
+ }
113
+ }
114
+
115
+
116
+ uint64_t HeapEntry::id() {
117
+ union {
118
+ Id stored_id;
119
+ uint64_t returned_id;
120
+ } id_adaptor = {id_};
121
+ return id_adaptor.returned_id;
122
+ }
123
+
124
+ } } // namespace v8::internal
125
+
126
+ #endif // ENABLE_LOGGING_AND_PROFILING
127
+
128
+ #endif // V8_PROFILE_GENERATOR_INL_H_
@@ -0,0 +1,2899 @@
1
+ // Copyright 2010 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
+ #ifdef ENABLE_LOGGING_AND_PROFILING
29
+
30
+ #include "v8.h"
31
+ #include "global-handles.h"
32
+ #include "scopeinfo.h"
33
+ #include "top.h"
34
+ #include "unicode.h"
35
+ #include "zone-inl.h"
36
+
37
+ #include "profile-generator-inl.h"
38
+
39
+ namespace v8 {
40
+ namespace internal {
41
+
42
+
43
+ TokenEnumerator::TokenEnumerator()
44
+ : token_locations_(4),
45
+ token_removed_(4) {
46
+ }
47
+
48
+
49
+ TokenEnumerator::~TokenEnumerator() {
50
+ for (int i = 0; i < token_locations_.length(); ++i) {
51
+ if (!token_removed_[i]) {
52
+ GlobalHandles::ClearWeakness(token_locations_[i]);
53
+ GlobalHandles::Destroy(token_locations_[i]);
54
+ }
55
+ }
56
+ }
57
+
58
+
59
+ int TokenEnumerator::GetTokenId(Object* token) {
60
+ if (token == NULL) return TokenEnumerator::kNoSecurityToken;
61
+ for (int i = 0; i < token_locations_.length(); ++i) {
62
+ if (*token_locations_[i] == token && !token_removed_[i]) return i;
63
+ }
64
+ Handle<Object> handle = GlobalHandles::Create(token);
65
+ // handle.location() points to a memory cell holding a pointer
66
+ // to a token object in the V8's heap.
67
+ GlobalHandles::MakeWeak(handle.location(), this, TokenRemovedCallback);
68
+ token_locations_.Add(handle.location());
69
+ token_removed_.Add(false);
70
+ return token_locations_.length() - 1;
71
+ }
72
+
73
+
74
+ void TokenEnumerator::TokenRemovedCallback(v8::Persistent<v8::Value> handle,
75
+ void* parameter) {
76
+ reinterpret_cast<TokenEnumerator*>(parameter)->TokenRemoved(
77
+ Utils::OpenHandle(*handle).location());
78
+ handle.Dispose();
79
+ }
80
+
81
+
82
+ void TokenEnumerator::TokenRemoved(Object** token_location) {
83
+ for (int i = 0; i < token_locations_.length(); ++i) {
84
+ if (token_locations_[i] == token_location && !token_removed_[i]) {
85
+ token_removed_[i] = true;
86
+ return;
87
+ }
88
+ }
89
+ }
90
+
91
+
92
+ StringsStorage::StringsStorage()
93
+ : names_(StringsMatch) {
94
+ }
95
+
96
+
97
+ static void DeleteIndexName(char** name_ptr) {
98
+ DeleteArray(*name_ptr);
99
+ }
100
+
101
+
102
+ StringsStorage::~StringsStorage() {
103
+ for (HashMap::Entry* p = names_.Start();
104
+ p != NULL;
105
+ p = names_.Next(p)) {
106
+ DeleteArray(reinterpret_cast<const char*>(p->value));
107
+ }
108
+ index_names_.Iterate(DeleteIndexName);
109
+ }
110
+
111
+
112
+ const char* StringsStorage::GetName(String* name) {
113
+ if (name->IsString()) {
114
+ char* c_name =
115
+ name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL).Detach();
116
+ HashMap::Entry* cache_entry = names_.Lookup(c_name, name->Hash(), true);
117
+ if (cache_entry->value == NULL) {
118
+ // New entry added.
119
+ cache_entry->value = c_name;
120
+ } else {
121
+ DeleteArray(c_name);
122
+ }
123
+ return reinterpret_cast<const char*>(cache_entry->value);
124
+ }
125
+ return "";
126
+ }
127
+
128
+
129
+ const char* StringsStorage::GetName(int index) {
130
+ ASSERT(index >= 0);
131
+ if (index_names_.length() <= index) {
132
+ index_names_.AddBlock(
133
+ NULL, index - index_names_.length() + 1);
134
+ }
135
+ if (index_names_[index] == NULL) {
136
+ const int kMaximumNameLength = 32;
137
+ char* name = NewArray<char>(kMaximumNameLength);
138
+ OS::SNPrintF(Vector<char>(name, kMaximumNameLength), "%d", index);
139
+ index_names_[index] = name;
140
+ }
141
+ return index_names_[index];
142
+ }
143
+
144
+
145
+ const char* CodeEntry::kEmptyNamePrefix = "";
146
+
147
+
148
+ void CodeEntry::CopyData(const CodeEntry& source) {
149
+ tag_ = source.tag_;
150
+ name_prefix_ = source.name_prefix_;
151
+ name_ = source.name_;
152
+ resource_name_ = source.resource_name_;
153
+ line_number_ = source.line_number_;
154
+ }
155
+
156
+
157
+ uint32_t CodeEntry::GetCallUid() const {
158
+ uint32_t hash = ComputeIntegerHash(tag_);
159
+ if (shared_id_ != 0) {
160
+ hash ^= ComputeIntegerHash(
161
+ static_cast<uint32_t>(shared_id_));
162
+ } else {
163
+ hash ^= ComputeIntegerHash(
164
+ static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name_prefix_)));
165
+ hash ^= ComputeIntegerHash(
166
+ static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name_)));
167
+ hash ^= ComputeIntegerHash(
168
+ static_cast<uint32_t>(reinterpret_cast<uintptr_t>(resource_name_)));
169
+ hash ^= ComputeIntegerHash(line_number_);
170
+ }
171
+ return hash;
172
+ }
173
+
174
+
175
+ bool CodeEntry::IsSameAs(CodeEntry* entry) const {
176
+ return this == entry
177
+ || (tag_ == entry->tag_
178
+ && shared_id_ == entry->shared_id_
179
+ && (shared_id_ != 0
180
+ || (name_prefix_ == entry->name_prefix_
181
+ && name_ == entry->name_
182
+ && resource_name_ == entry->resource_name_
183
+ && line_number_ == entry->line_number_)));
184
+ }
185
+
186
+
187
+ ProfileNode* ProfileNode::FindChild(CodeEntry* entry) {
188
+ HashMap::Entry* map_entry =
189
+ children_.Lookup(entry, CodeEntryHash(entry), false);
190
+ return map_entry != NULL ?
191
+ reinterpret_cast<ProfileNode*>(map_entry->value) : NULL;
192
+ }
193
+
194
+
195
+ ProfileNode* ProfileNode::FindOrAddChild(CodeEntry* entry) {
196
+ HashMap::Entry* map_entry =
197
+ children_.Lookup(entry, CodeEntryHash(entry), true);
198
+ if (map_entry->value == NULL) {
199
+ // New node added.
200
+ ProfileNode* new_node = new ProfileNode(tree_, entry);
201
+ map_entry->value = new_node;
202
+ children_list_.Add(new_node);
203
+ }
204
+ return reinterpret_cast<ProfileNode*>(map_entry->value);
205
+ }
206
+
207
+
208
+ double ProfileNode::GetSelfMillis() const {
209
+ return tree_->TicksToMillis(self_ticks_);
210
+ }
211
+
212
+
213
+ double ProfileNode::GetTotalMillis() const {
214
+ return tree_->TicksToMillis(total_ticks_);
215
+ }
216
+
217
+
218
+ void ProfileNode::Print(int indent) {
219
+ OS::Print("%5u %5u %*c %s%s [%d]",
220
+ total_ticks_, self_ticks_,
221
+ indent, ' ',
222
+ entry_->name_prefix(),
223
+ entry_->name(),
224
+ entry_->security_token_id());
225
+ if (entry_->resource_name()[0] != '\0')
226
+ OS::Print(" %s:%d", entry_->resource_name(), entry_->line_number());
227
+ OS::Print("\n");
228
+ for (HashMap::Entry* p = children_.Start();
229
+ p != NULL;
230
+ p = children_.Next(p)) {
231
+ reinterpret_cast<ProfileNode*>(p->value)->Print(indent + 2);
232
+ }
233
+ }
234
+
235
+
236
+ class DeleteNodesCallback {
237
+ public:
238
+ void BeforeTraversingChild(ProfileNode*, ProfileNode*) { }
239
+
240
+ void AfterAllChildrenTraversed(ProfileNode* node) {
241
+ delete node;
242
+ }
243
+
244
+ void AfterChildTraversed(ProfileNode*, ProfileNode*) { }
245
+ };
246
+
247
+
248
+ ProfileTree::ProfileTree()
249
+ : root_entry_(Logger::FUNCTION_TAG,
250
+ "",
251
+ "(root)",
252
+ "",
253
+ 0,
254
+ TokenEnumerator::kNoSecurityToken),
255
+ root_(new ProfileNode(this, &root_entry_)) {
256
+ }
257
+
258
+
259
+ ProfileTree::~ProfileTree() {
260
+ DeleteNodesCallback cb;
261
+ TraverseDepthFirst(&cb);
262
+ }
263
+
264
+
265
+ void ProfileTree::AddPathFromEnd(const Vector<CodeEntry*>& path) {
266
+ ProfileNode* node = root_;
267
+ for (CodeEntry** entry = path.start() + path.length() - 1;
268
+ entry != path.start() - 1;
269
+ --entry) {
270
+ if (*entry != NULL) {
271
+ node = node->FindOrAddChild(*entry);
272
+ }
273
+ }
274
+ node->IncrementSelfTicks();
275
+ }
276
+
277
+
278
+ void ProfileTree::AddPathFromStart(const Vector<CodeEntry*>& path) {
279
+ ProfileNode* node = root_;
280
+ for (CodeEntry** entry = path.start();
281
+ entry != path.start() + path.length();
282
+ ++entry) {
283
+ if (*entry != NULL) {
284
+ node = node->FindOrAddChild(*entry);
285
+ }
286
+ }
287
+ node->IncrementSelfTicks();
288
+ }
289
+
290
+
291
+ struct NodesPair {
292
+ NodesPair(ProfileNode* src, ProfileNode* dst)
293
+ : src(src), dst(dst) { }
294
+ ProfileNode* src;
295
+ ProfileNode* dst;
296
+ };
297
+
298
+
299
+ class FilteredCloneCallback {
300
+ public:
301
+ explicit FilteredCloneCallback(ProfileNode* dst_root, int security_token_id)
302
+ : stack_(10),
303
+ security_token_id_(security_token_id) {
304
+ stack_.Add(NodesPair(NULL, dst_root));
305
+ }
306
+
307
+ void BeforeTraversingChild(ProfileNode* parent, ProfileNode* child) {
308
+ if (IsTokenAcceptable(child->entry()->security_token_id(),
309
+ parent->entry()->security_token_id())) {
310
+ ProfileNode* clone = stack_.last().dst->FindOrAddChild(child->entry());
311
+ clone->IncreaseSelfTicks(child->self_ticks());
312
+ stack_.Add(NodesPair(child, clone));
313
+ } else {
314
+ // Attribute ticks to parent node.
315
+ stack_.last().dst->IncreaseSelfTicks(child->self_ticks());
316
+ }
317
+ }
318
+
319
+ void AfterAllChildrenTraversed(ProfileNode* parent) { }
320
+
321
+ void AfterChildTraversed(ProfileNode*, ProfileNode* child) {
322
+ if (stack_.last().src == child) {
323
+ stack_.RemoveLast();
324
+ }
325
+ }
326
+
327
+ private:
328
+ bool IsTokenAcceptable(int token, int parent_token) {
329
+ if (token == TokenEnumerator::kNoSecurityToken
330
+ || token == security_token_id_) return true;
331
+ if (token == TokenEnumerator::kInheritsSecurityToken) {
332
+ ASSERT(parent_token != TokenEnumerator::kInheritsSecurityToken);
333
+ return parent_token == TokenEnumerator::kNoSecurityToken
334
+ || parent_token == security_token_id_;
335
+ }
336
+ return false;
337
+ }
338
+
339
+ List<NodesPair> stack_;
340
+ int security_token_id_;
341
+ };
342
+
343
+ void ProfileTree::FilteredClone(ProfileTree* src, int security_token_id) {
344
+ ms_to_ticks_scale_ = src->ms_to_ticks_scale_;
345
+ FilteredCloneCallback cb(root_, security_token_id);
346
+ src->TraverseDepthFirst(&cb);
347
+ CalculateTotalTicks();
348
+ }
349
+
350
+
351
+ void ProfileTree::SetTickRatePerMs(double ticks_per_ms) {
352
+ ms_to_ticks_scale_ = ticks_per_ms > 0 ? 1.0 / ticks_per_ms : 1.0;
353
+ }
354
+
355
+
356
+ class Position {
357
+ public:
358
+ explicit Position(ProfileNode* node)
359
+ : node(node), child_idx_(0) { }
360
+ INLINE(ProfileNode* current_child()) {
361
+ return node->children()->at(child_idx_);
362
+ }
363
+ INLINE(bool has_current_child()) {
364
+ return child_idx_ < node->children()->length();
365
+ }
366
+ INLINE(void next_child()) { ++child_idx_; }
367
+
368
+ ProfileNode* node;
369
+ private:
370
+ int child_idx_;
371
+ };
372
+
373
+
374
+ // Non-recursive implementation of a depth-first post-order tree traversal.
375
+ template <typename Callback>
376
+ void ProfileTree::TraverseDepthFirst(Callback* callback) {
377
+ List<Position> stack(10);
378
+ stack.Add(Position(root_));
379
+ while (stack.length() > 0) {
380
+ Position& current = stack.last();
381
+ if (current.has_current_child()) {
382
+ callback->BeforeTraversingChild(current.node, current.current_child());
383
+ stack.Add(Position(current.current_child()));
384
+ } else {
385
+ callback->AfterAllChildrenTraversed(current.node);
386
+ if (stack.length() > 1) {
387
+ Position& parent = stack[stack.length() - 2];
388
+ callback->AfterChildTraversed(parent.node, current.node);
389
+ parent.next_child();
390
+ }
391
+ // Remove child from the stack.
392
+ stack.RemoveLast();
393
+ }
394
+ }
395
+ }
396
+
397
+
398
+ class CalculateTotalTicksCallback {
399
+ public:
400
+ void BeforeTraversingChild(ProfileNode*, ProfileNode*) { }
401
+
402
+ void AfterAllChildrenTraversed(ProfileNode* node) {
403
+ node->IncreaseTotalTicks(node->self_ticks());
404
+ }
405
+
406
+ void AfterChildTraversed(ProfileNode* parent, ProfileNode* child) {
407
+ parent->IncreaseTotalTicks(child->total_ticks());
408
+ }
409
+ };
410
+
411
+
412
+ void ProfileTree::CalculateTotalTicks() {
413
+ CalculateTotalTicksCallback cb;
414
+ TraverseDepthFirst(&cb);
415
+ }
416
+
417
+
418
+ void ProfileTree::ShortPrint() {
419
+ OS::Print("root: %u %u %.2fms %.2fms\n",
420
+ root_->total_ticks(), root_->self_ticks(),
421
+ root_->GetTotalMillis(), root_->GetSelfMillis());
422
+ }
423
+
424
+
425
+ void CpuProfile::AddPath(const Vector<CodeEntry*>& path) {
426
+ top_down_.AddPathFromEnd(path);
427
+ bottom_up_.AddPathFromStart(path);
428
+ }
429
+
430
+
431
+ void CpuProfile::CalculateTotalTicks() {
432
+ top_down_.CalculateTotalTicks();
433
+ bottom_up_.CalculateTotalTicks();
434
+ }
435
+
436
+
437
+ void CpuProfile::SetActualSamplingRate(double actual_sampling_rate) {
438
+ top_down_.SetTickRatePerMs(actual_sampling_rate);
439
+ bottom_up_.SetTickRatePerMs(actual_sampling_rate);
440
+ }
441
+
442
+
443
+ CpuProfile* CpuProfile::FilteredClone(int security_token_id) {
444
+ ASSERT(security_token_id != TokenEnumerator::kNoSecurityToken);
445
+ CpuProfile* clone = new CpuProfile(title_, uid_);
446
+ clone->top_down_.FilteredClone(&top_down_, security_token_id);
447
+ clone->bottom_up_.FilteredClone(&bottom_up_, security_token_id);
448
+ return clone;
449
+ }
450
+
451
+
452
+ void CpuProfile::ShortPrint() {
453
+ OS::Print("top down ");
454
+ top_down_.ShortPrint();
455
+ OS::Print("bottom up ");
456
+ bottom_up_.ShortPrint();
457
+ }
458
+
459
+
460
+ void CpuProfile::Print() {
461
+ OS::Print("[Top down]:\n");
462
+ top_down_.Print();
463
+ OS::Print("[Bottom up]:\n");
464
+ bottom_up_.Print();
465
+ }
466
+
467
+
468
+ CodeEntry* const CodeMap::kSfiCodeEntry = NULL;
469
+ const CodeMap::CodeTreeConfig::Key CodeMap::CodeTreeConfig::kNoKey = NULL;
470
+ const CodeMap::CodeTreeConfig::Value CodeMap::CodeTreeConfig::kNoValue =
471
+ CodeMap::CodeEntryInfo(NULL, 0);
472
+
473
+
474
+ CodeEntry* CodeMap::FindEntry(Address addr) {
475
+ CodeTree::Locator locator;
476
+ if (tree_.FindGreatestLessThan(addr, &locator)) {
477
+ // locator.key() <= addr. Need to check that addr is within entry.
478
+ const CodeEntryInfo& entry = locator.value();
479
+ if (addr < (locator.key() + entry.size))
480
+ return entry.entry;
481
+ }
482
+ return NULL;
483
+ }
484
+
485
+
486
+ int CodeMap::GetSFITag(Address addr) {
487
+ CodeTree::Locator locator;
488
+ // For SFI entries, 'size' field is used to store their IDs.
489
+ if (tree_.Find(addr, &locator)) {
490
+ const CodeEntryInfo& entry = locator.value();
491
+ ASSERT(entry.entry == kSfiCodeEntry);
492
+ return entry.size;
493
+ } else {
494
+ tree_.Insert(addr, &locator);
495
+ int tag = next_sfi_tag_++;
496
+ locator.set_value(CodeEntryInfo(kSfiCodeEntry, tag));
497
+ return tag;
498
+ }
499
+ }
500
+
501
+
502
+ void CodeMap::CodeTreePrinter::Call(
503
+ const Address& key, const CodeMap::CodeEntryInfo& value) {
504
+ OS::Print("%p %5d %s\n", key, value.size, value.entry->name());
505
+ }
506
+
507
+
508
+ void CodeMap::Print() {
509
+ CodeTreePrinter printer;
510
+ tree_.ForEach(&printer);
511
+ }
512
+
513
+
514
+ CpuProfilesCollection::CpuProfilesCollection()
515
+ : profiles_uids_(UidsMatch),
516
+ current_profiles_semaphore_(OS::CreateSemaphore(1)) {
517
+ // Create list of unabridged profiles.
518
+ profiles_by_token_.Add(new List<CpuProfile*>());
519
+ }
520
+
521
+
522
+ static void DeleteCodeEntry(CodeEntry** entry_ptr) {
523
+ delete *entry_ptr;
524
+ }
525
+
526
+ static void DeleteCpuProfile(CpuProfile** profile_ptr) {
527
+ delete *profile_ptr;
528
+ }
529
+
530
+ static void DeleteProfilesList(List<CpuProfile*>** list_ptr) {
531
+ (*list_ptr)->Iterate(DeleteCpuProfile);
532
+ delete *list_ptr;
533
+ }
534
+
535
+ CpuProfilesCollection::~CpuProfilesCollection() {
536
+ delete current_profiles_semaphore_;
537
+ current_profiles_.Iterate(DeleteCpuProfile);
538
+ profiles_by_token_.Iterate(DeleteProfilesList);
539
+ code_entries_.Iterate(DeleteCodeEntry);
540
+ }
541
+
542
+
543
+ bool CpuProfilesCollection::StartProfiling(const char* title, unsigned uid) {
544
+ ASSERT(uid > 0);
545
+ current_profiles_semaphore_->Wait();
546
+ if (current_profiles_.length() >= kMaxSimultaneousProfiles) {
547
+ current_profiles_semaphore_->Signal();
548
+ return false;
549
+ }
550
+ for (int i = 0; i < current_profiles_.length(); ++i) {
551
+ if (strcmp(current_profiles_[i]->title(), title) == 0) {
552
+ // Ignore attempts to start profile with the same title.
553
+ current_profiles_semaphore_->Signal();
554
+ return false;
555
+ }
556
+ }
557
+ current_profiles_.Add(new CpuProfile(title, uid));
558
+ current_profiles_semaphore_->Signal();
559
+ return true;
560
+ }
561
+
562
+
563
+ bool CpuProfilesCollection::StartProfiling(String* title, unsigned uid) {
564
+ return StartProfiling(GetName(title), uid);
565
+ }
566
+
567
+
568
+ CpuProfile* CpuProfilesCollection::StopProfiling(int security_token_id,
569
+ const char* title,
570
+ double actual_sampling_rate) {
571
+ const int title_len = StrLength(title);
572
+ CpuProfile* profile = NULL;
573
+ current_profiles_semaphore_->Wait();
574
+ for (int i = current_profiles_.length() - 1; i >= 0; --i) {
575
+ if (title_len == 0 || strcmp(current_profiles_[i]->title(), title) == 0) {
576
+ profile = current_profiles_.Remove(i);
577
+ break;
578
+ }
579
+ }
580
+ current_profiles_semaphore_->Signal();
581
+
582
+ if (profile != NULL) {
583
+ profile->CalculateTotalTicks();
584
+ profile->SetActualSamplingRate(actual_sampling_rate);
585
+ List<CpuProfile*>* unabridged_list =
586
+ profiles_by_token_[TokenToIndex(TokenEnumerator::kNoSecurityToken)];
587
+ unabridged_list->Add(profile);
588
+ HashMap::Entry* entry =
589
+ profiles_uids_.Lookup(reinterpret_cast<void*>(profile->uid()),
590
+ static_cast<uint32_t>(profile->uid()),
591
+ true);
592
+ ASSERT(entry->value == NULL);
593
+ entry->value = reinterpret_cast<void*>(unabridged_list->length() - 1);
594
+ return GetProfile(security_token_id, profile->uid());
595
+ }
596
+ return NULL;
597
+ }
598
+
599
+
600
+ CpuProfile* CpuProfilesCollection::GetProfile(int security_token_id,
601
+ unsigned uid) {
602
+ HashMap::Entry* entry = profiles_uids_.Lookup(reinterpret_cast<void*>(uid),
603
+ static_cast<uint32_t>(uid),
604
+ false);
605
+ int index;
606
+ if (entry != NULL) {
607
+ index = static_cast<int>(reinterpret_cast<intptr_t>(entry->value));
608
+ } else {
609
+ return NULL;
610
+ }
611
+ List<CpuProfile*>* unabridged_list =
612
+ profiles_by_token_[TokenToIndex(TokenEnumerator::kNoSecurityToken)];
613
+ if (security_token_id == TokenEnumerator::kNoSecurityToken) {
614
+ return unabridged_list->at(index);
615
+ }
616
+ List<CpuProfile*>* list = GetProfilesList(security_token_id);
617
+ if (list->at(index) == NULL) {
618
+ (*list)[index] =
619
+ unabridged_list->at(index)->FilteredClone(security_token_id);
620
+ }
621
+ return list->at(index);
622
+ }
623
+
624
+
625
+ bool CpuProfilesCollection::IsLastProfile(const char* title) {
626
+ // Called from VM thread, and only it can mutate the list,
627
+ // so no locking is needed here.
628
+ if (current_profiles_.length() != 1) return false;
629
+ return StrLength(title) == 0
630
+ || strcmp(current_profiles_[0]->title(), title) == 0;
631
+ }
632
+
633
+
634
+ int CpuProfilesCollection::TokenToIndex(int security_token_id) {
635
+ ASSERT(TokenEnumerator::kNoSecurityToken == -1);
636
+ return security_token_id + 1; // kNoSecurityToken -> 0, 0 -> 1, ...
637
+ }
638
+
639
+
640
+ List<CpuProfile*>* CpuProfilesCollection::GetProfilesList(
641
+ int security_token_id) {
642
+ const int index = TokenToIndex(security_token_id);
643
+ const int lists_to_add = index - profiles_by_token_.length() + 1;
644
+ if (lists_to_add > 0) profiles_by_token_.AddBlock(NULL, lists_to_add);
645
+ List<CpuProfile*>* unabridged_list =
646
+ profiles_by_token_[TokenToIndex(TokenEnumerator::kNoSecurityToken)];
647
+ const int current_count = unabridged_list->length();
648
+ if (profiles_by_token_[index] == NULL) {
649
+ profiles_by_token_[index] = new List<CpuProfile*>(current_count);
650
+ }
651
+ List<CpuProfile*>* list = profiles_by_token_[index];
652
+ const int profiles_to_add = current_count - list->length();
653
+ if (profiles_to_add > 0) list->AddBlock(NULL, profiles_to_add);
654
+ return list;
655
+ }
656
+
657
+
658
+ List<CpuProfile*>* CpuProfilesCollection::Profiles(int security_token_id) {
659
+ List<CpuProfile*>* unabridged_list =
660
+ profiles_by_token_[TokenToIndex(TokenEnumerator::kNoSecurityToken)];
661
+ if (security_token_id == TokenEnumerator::kNoSecurityToken) {
662
+ return unabridged_list;
663
+ }
664
+ List<CpuProfile*>* list = GetProfilesList(security_token_id);
665
+ const int current_count = unabridged_list->length();
666
+ for (int i = 0; i < current_count; ++i) {
667
+ if (list->at(i) == NULL) {
668
+ (*list)[i] = unabridged_list->at(i)->FilteredClone(security_token_id);
669
+ }
670
+ }
671
+ return list;
672
+ }
673
+
674
+
675
+ CodeEntry* CpuProfilesCollection::NewCodeEntry(Logger::LogEventsAndTags tag,
676
+ String* name,
677
+ String* resource_name,
678
+ int line_number) {
679
+ CodeEntry* entry = new CodeEntry(tag,
680
+ CodeEntry::kEmptyNamePrefix,
681
+ GetFunctionName(name),
682
+ GetName(resource_name),
683
+ line_number,
684
+ TokenEnumerator::kNoSecurityToken);
685
+ code_entries_.Add(entry);
686
+ return entry;
687
+ }
688
+
689
+
690
+ CodeEntry* CpuProfilesCollection::NewCodeEntry(Logger::LogEventsAndTags tag,
691
+ const char* name) {
692
+ CodeEntry* entry = new CodeEntry(tag,
693
+ CodeEntry::kEmptyNamePrefix,
694
+ GetFunctionName(name),
695
+ "",
696
+ v8::CpuProfileNode::kNoLineNumberInfo,
697
+ TokenEnumerator::kNoSecurityToken);
698
+ code_entries_.Add(entry);
699
+ return entry;
700
+ }
701
+
702
+
703
+ CodeEntry* CpuProfilesCollection::NewCodeEntry(Logger::LogEventsAndTags tag,
704
+ const char* name_prefix,
705
+ String* name) {
706
+ CodeEntry* entry = new CodeEntry(tag,
707
+ name_prefix,
708
+ GetName(name),
709
+ "",
710
+ v8::CpuProfileNode::kNoLineNumberInfo,
711
+ TokenEnumerator::kInheritsSecurityToken);
712
+ code_entries_.Add(entry);
713
+ return entry;
714
+ }
715
+
716
+
717
+ CodeEntry* CpuProfilesCollection::NewCodeEntry(Logger::LogEventsAndTags tag,
718
+ int args_count) {
719
+ CodeEntry* entry = new CodeEntry(tag,
720
+ "args_count: ",
721
+ GetName(args_count),
722
+ "",
723
+ v8::CpuProfileNode::kNoLineNumberInfo,
724
+ TokenEnumerator::kInheritsSecurityToken);
725
+ code_entries_.Add(entry);
726
+ return entry;
727
+ }
728
+
729
+
730
+ void CpuProfilesCollection::AddPathToCurrentProfiles(
731
+ const Vector<CodeEntry*>& path) {
732
+ // As starting / stopping profiles is rare relatively to this
733
+ // method, we don't bother minimizing the duration of lock holding,
734
+ // e.g. copying contents of the list to a local vector.
735
+ current_profiles_semaphore_->Wait();
736
+ for (int i = 0; i < current_profiles_.length(); ++i) {
737
+ current_profiles_[i]->AddPath(path);
738
+ }
739
+ current_profiles_semaphore_->Signal();
740
+ }
741
+
742
+
743
+ void SampleRateCalculator::Tick() {
744
+ if (--wall_time_query_countdown_ == 0)
745
+ UpdateMeasurements(OS::TimeCurrentMillis());
746
+ }
747
+
748
+
749
+ void SampleRateCalculator::UpdateMeasurements(double current_time) {
750
+ if (measurements_count_++ != 0) {
751
+ const double measured_ticks_per_ms =
752
+ (kWallTimeQueryIntervalMs * ticks_per_ms_) /
753
+ (current_time - last_wall_time_);
754
+ // Update the average value.
755
+ ticks_per_ms_ +=
756
+ (measured_ticks_per_ms - ticks_per_ms_) / measurements_count_;
757
+ // Update the externally accessible result.
758
+ result_ = static_cast<AtomicWord>(ticks_per_ms_ * kResultScale);
759
+ }
760
+ last_wall_time_ = current_time;
761
+ wall_time_query_countdown_ =
762
+ static_cast<unsigned>(kWallTimeQueryIntervalMs * ticks_per_ms_);
763
+ }
764
+
765
+
766
+ const char* ProfileGenerator::kAnonymousFunctionName = "(anonymous function)";
767
+ const char* ProfileGenerator::kProgramEntryName = "(program)";
768
+ const char* ProfileGenerator::kGarbageCollectorEntryName =
769
+ "(garbage collector)";
770
+
771
+
772
+ ProfileGenerator::ProfileGenerator(CpuProfilesCollection* profiles)
773
+ : profiles_(profiles),
774
+ program_entry_(
775
+ profiles->NewCodeEntry(Logger::FUNCTION_TAG, kProgramEntryName)),
776
+ gc_entry_(
777
+ profiles->NewCodeEntry(Logger::BUILTIN_TAG,
778
+ kGarbageCollectorEntryName)) {
779
+ }
780
+
781
+
782
+ void ProfileGenerator::RecordTickSample(const TickSample& sample) {
783
+ // Allocate space for stack frames + pc + function + vm-state.
784
+ ScopedVector<CodeEntry*> entries(sample.frames_count + 3);
785
+ // As actual number of decoded code entries may vary, initialize
786
+ // entries vector with NULL values.
787
+ CodeEntry** entry = entries.start();
788
+ memset(entry, 0, entries.length() * sizeof(*entry));
789
+ if (sample.pc != NULL) {
790
+ *entry++ = code_map_.FindEntry(sample.pc);
791
+
792
+ if (sample.tos != NULL) {
793
+ *entry = code_map_.FindEntry(sample.tos);
794
+ if (*entry != NULL && !(*entry)->is_js_function()) {
795
+ *entry = NULL;
796
+ }
797
+ entry++;
798
+ }
799
+
800
+ for (const Address *stack_pos = sample.stack,
801
+ *stack_end = stack_pos + sample.frames_count;
802
+ stack_pos != stack_end;
803
+ ++stack_pos) {
804
+ *entry++ = code_map_.FindEntry(*stack_pos);
805
+ }
806
+ }
807
+
808
+ if (FLAG_prof_browser_mode) {
809
+ bool no_symbolized_entries = true;
810
+ for (CodeEntry** e = entries.start(); e != entry; ++e) {
811
+ if (*e != NULL) {
812
+ no_symbolized_entries = false;
813
+ break;
814
+ }
815
+ }
816
+ // If no frames were symbolized, put the VM state entry in.
817
+ if (no_symbolized_entries) {
818
+ *entry++ = EntryForVMState(sample.state);
819
+ }
820
+ }
821
+
822
+ profiles_->AddPathToCurrentProfiles(entries);
823
+ }
824
+
825
+
826
+ void HeapGraphEdge::Init(
827
+ int child_index, Type type, const char* name, HeapEntry* to) {
828
+ ASSERT(type == kContextVariable
829
+ || type == kProperty
830
+ || type == kInternal
831
+ || type == kShortcut);
832
+ child_index_ = child_index;
833
+ type_ = type;
834
+ name_ = name;
835
+ to_ = to;
836
+ }
837
+
838
+
839
+ void HeapGraphEdge::Init(int child_index, Type type, int index, HeapEntry* to) {
840
+ ASSERT(type == kElement || type == kHidden);
841
+ child_index_ = child_index;
842
+ type_ = type;
843
+ index_ = index;
844
+ to_ = to;
845
+ }
846
+
847
+
848
+ void HeapGraphEdge::Init(int child_index, int index, HeapEntry* to) {
849
+ Init(child_index, kElement, index, to);
850
+ }
851
+
852
+
853
+ HeapEntry* HeapGraphEdge::From() {
854
+ return reinterpret_cast<HeapEntry*>(this - child_index_) - 1;
855
+ }
856
+
857
+
858
+ void HeapEntry::Init(HeapSnapshot* snapshot,
859
+ Type type,
860
+ const char* name,
861
+ uint64_t id,
862
+ int self_size,
863
+ int children_count,
864
+ int retainers_count) {
865
+ snapshot_ = snapshot;
866
+ type_ = type;
867
+ painted_ = kUnpainted;
868
+ name_ = name;
869
+ self_size_ = self_size;
870
+ retained_size_ = 0;
871
+ children_count_ = children_count;
872
+ retainers_count_ = retainers_count;
873
+ dominator_ = NULL;
874
+
875
+ union {
876
+ uint64_t set_id;
877
+ Id stored_id;
878
+ } id_adaptor = {id};
879
+ id_ = id_adaptor.stored_id;
880
+ }
881
+
882
+
883
+ void HeapEntry::SetNamedReference(HeapGraphEdge::Type type,
884
+ int child_index,
885
+ const char* name,
886
+ HeapEntry* entry,
887
+ int retainer_index) {
888
+ children_arr()[child_index].Init(child_index, type, name, entry);
889
+ entry->retainers_arr()[retainer_index] = children_arr() + child_index;
890
+ }
891
+
892
+
893
+ void HeapEntry::SetIndexedReference(HeapGraphEdge::Type type,
894
+ int child_index,
895
+ int index,
896
+ HeapEntry* entry,
897
+ int retainer_index) {
898
+ children_arr()[child_index].Init(child_index, type, index, entry);
899
+ entry->retainers_arr()[retainer_index] = children_arr() + child_index;
900
+ }
901
+
902
+
903
+ void HeapEntry::SetUnidirElementReference(
904
+ int child_index, int index, HeapEntry* entry) {
905
+ children_arr()[child_index].Init(child_index, index, entry);
906
+ }
907
+
908
+
909
+ int HeapEntry::RetainedSize(bool exact) {
910
+ if (exact && (retained_size_ & kExactRetainedSizeTag) == 0) {
911
+ CalculateExactRetainedSize();
912
+ }
913
+ return retained_size_ & (~kExactRetainedSizeTag);
914
+ }
915
+
916
+
917
+ List<HeapGraphPath*>* HeapEntry::GetRetainingPaths() {
918
+ return snapshot_->GetRetainingPaths(this);
919
+ }
920
+
921
+
922
+ template<class Visitor>
923
+ void HeapEntry::ApplyAndPaintAllReachable(Visitor* visitor) {
924
+ List<HeapEntry*> list(10);
925
+ list.Add(this);
926
+ this->paint_reachable();
927
+ visitor->Apply(this);
928
+ while (!list.is_empty()) {
929
+ HeapEntry* entry = list.RemoveLast();
930
+ Vector<HeapGraphEdge> children = entry->children();
931
+ for (int i = 0; i < children.length(); ++i) {
932
+ if (children[i].type() == HeapGraphEdge::kShortcut) continue;
933
+ HeapEntry* child = children[i].to();
934
+ if (!child->painted_reachable()) {
935
+ list.Add(child);
936
+ child->paint_reachable();
937
+ visitor->Apply(child);
938
+ }
939
+ }
940
+ }
941
+ }
942
+
943
+
944
+ class NullClass {
945
+ public:
946
+ void Apply(HeapEntry* entry) { }
947
+ };
948
+
949
+ void HeapEntry::PaintAllReachable() {
950
+ NullClass null;
951
+ ApplyAndPaintAllReachable(&null);
952
+ }
953
+
954
+
955
+ void HeapEntry::Print(int max_depth, int indent) {
956
+ OS::Print("%6d %6d [%llu] ", self_size(), RetainedSize(false), id());
957
+ if (type() != kString) {
958
+ OS::Print("%s %.40s\n", TypeAsString(), name_);
959
+ } else {
960
+ OS::Print("\"");
961
+ const char* c = name_;
962
+ while (*c && (c - name_) <= 40) {
963
+ if (*c != '\n')
964
+ OS::Print("%c", *c);
965
+ else
966
+ OS::Print("\\n");
967
+ ++c;
968
+ }
969
+ OS::Print("\"\n");
970
+ }
971
+ if (--max_depth == 0) return;
972
+ Vector<HeapGraphEdge> ch = children();
973
+ for (int i = 0; i < ch.length(); ++i) {
974
+ HeapGraphEdge& edge = ch[i];
975
+ switch (edge.type()) {
976
+ case HeapGraphEdge::kContextVariable:
977
+ OS::Print(" %*c #%s: ", indent, ' ', edge.name());
978
+ break;
979
+ case HeapGraphEdge::kElement:
980
+ OS::Print(" %*c %d: ", indent, ' ', edge.index());
981
+ break;
982
+ case HeapGraphEdge::kInternal:
983
+ OS::Print(" %*c $%s: ", indent, ' ', edge.name());
984
+ break;
985
+ case HeapGraphEdge::kProperty:
986
+ OS::Print(" %*c %s: ", indent, ' ', edge.name());
987
+ break;
988
+ case HeapGraphEdge::kHidden:
989
+ OS::Print(" %*c $%d: ", indent, ' ', edge.index());
990
+ break;
991
+ case HeapGraphEdge::kShortcut:
992
+ OS::Print(" %*c ^%s: ", indent, ' ', edge.name());
993
+ break;
994
+ default:
995
+ OS::Print("!!! unknown edge type: %d ", edge.type());
996
+ }
997
+ edge.to()->Print(max_depth, indent + 2);
998
+ }
999
+ }
1000
+
1001
+
1002
+ const char* HeapEntry::TypeAsString() {
1003
+ switch (type()) {
1004
+ case kHidden: return "/hidden/";
1005
+ case kObject: return "/object/";
1006
+ case kClosure: return "/closure/";
1007
+ case kString: return "/string/";
1008
+ case kCode: return "/code/";
1009
+ case kArray: return "/array/";
1010
+ case kRegExp: return "/regexp/";
1011
+ case kHeapNumber: return "/number/";
1012
+ default: return "???";
1013
+ }
1014
+ }
1015
+
1016
+
1017
+ int HeapEntry::EntriesSize(int entries_count,
1018
+ int children_count,
1019
+ int retainers_count) {
1020
+ return sizeof(HeapEntry) * entries_count // NOLINT
1021
+ + sizeof(HeapGraphEdge) * children_count // NOLINT
1022
+ + sizeof(HeapGraphEdge*) * retainers_count; // NOLINT
1023
+ }
1024
+
1025
+
1026
+ class RetainedSizeCalculator {
1027
+ public:
1028
+ RetainedSizeCalculator()
1029
+ : retained_size_(0) {
1030
+ }
1031
+
1032
+ int reained_size() const { return retained_size_; }
1033
+
1034
+ void Apply(HeapEntry** entry_ptr) {
1035
+ if ((*entry_ptr)->painted_reachable()) {
1036
+ retained_size_ += (*entry_ptr)->self_size();
1037
+ }
1038
+ }
1039
+
1040
+ private:
1041
+ int retained_size_;
1042
+ };
1043
+
1044
+ void HeapEntry::CalculateExactRetainedSize() {
1045
+ // To calculate retained size, first we paint all reachable nodes in
1046
+ // one color, then we paint (or re-paint) all nodes reachable from
1047
+ // other nodes with a different color. Then we sum up self sizes of
1048
+ // nodes painted with the first color.
1049
+ snapshot()->ClearPaint();
1050
+ PaintAllReachable();
1051
+
1052
+ List<HeapEntry*> list(10);
1053
+ HeapEntry* root = snapshot()->root();
1054
+ if (this != root) {
1055
+ list.Add(root);
1056
+ root->paint_reachable_from_others();
1057
+ }
1058
+ while (!list.is_empty()) {
1059
+ HeapEntry* curr = list.RemoveLast();
1060
+ Vector<HeapGraphEdge> children = curr->children();
1061
+ for (int i = 0; i < children.length(); ++i) {
1062
+ if (children[i].type() == HeapGraphEdge::kShortcut) continue;
1063
+ HeapEntry* child = children[i].to();
1064
+ if (child != this && child->not_painted_reachable_from_others()) {
1065
+ list.Add(child);
1066
+ child->paint_reachable_from_others();
1067
+ }
1068
+ }
1069
+ }
1070
+
1071
+ RetainedSizeCalculator ret_size_calc;
1072
+ snapshot()->IterateEntries(&ret_size_calc);
1073
+ retained_size_ = ret_size_calc.reained_size();
1074
+ ASSERT((retained_size_ & kExactRetainedSizeTag) == 0);
1075
+ retained_size_ |= kExactRetainedSizeTag;
1076
+ }
1077
+
1078
+
1079
+ class CachedHeapGraphPath {
1080
+ public:
1081
+ CachedHeapGraphPath()
1082
+ : nodes_(NodesMatch) { }
1083
+ CachedHeapGraphPath(const CachedHeapGraphPath& src)
1084
+ : nodes_(NodesMatch, &HashMap::DefaultAllocator, src.nodes_.capacity()),
1085
+ path_(src.path_.length() + 1) {
1086
+ for (HashMap::Entry* p = src.nodes_.Start();
1087
+ p != NULL;
1088
+ p = src.nodes_.Next(p)) {
1089
+ nodes_.Lookup(p->key, p->hash, true);
1090
+ }
1091
+ path_.AddAll(src.path_);
1092
+ }
1093
+ void Add(HeapGraphEdge* edge) {
1094
+ nodes_.Lookup(edge->to(), Hash(edge->to()), true);
1095
+ path_.Add(edge);
1096
+ }
1097
+ bool ContainsNode(HeapEntry* node) {
1098
+ return nodes_.Lookup(node, Hash(node), false) != NULL;
1099
+ }
1100
+ const List<HeapGraphEdge*>* path() const { return &path_; }
1101
+
1102
+ private:
1103
+ static uint32_t Hash(HeapEntry* entry) {
1104
+ return static_cast<uint32_t>(reinterpret_cast<intptr_t>(entry));
1105
+ }
1106
+ static bool NodesMatch(void* key1, void* key2) { return key1 == key2; }
1107
+
1108
+ HashMap nodes_;
1109
+ List<HeapGraphEdge*> path_;
1110
+ };
1111
+
1112
+
1113
+ List<HeapGraphPath*>* HeapEntry::CalculateRetainingPaths() {
1114
+ List<HeapGraphPath*>* retaining_paths = new List<HeapGraphPath*>(4);
1115
+ CachedHeapGraphPath path;
1116
+ FindRetainingPaths(&path, retaining_paths);
1117
+ return retaining_paths;
1118
+ }
1119
+
1120
+
1121
+ void HeapEntry::FindRetainingPaths(CachedHeapGraphPath* prev_path,
1122
+ List<HeapGraphPath*>* retaining_paths) {
1123
+ Vector<HeapGraphEdge*> rets = retainers();
1124
+ for (int i = 0; i < rets.length(); ++i) {
1125
+ HeapGraphEdge* ret_edge = rets[i];
1126
+ if (prev_path->ContainsNode(ret_edge->From())) continue;
1127
+ if (ret_edge->From() != snapshot()->root()) {
1128
+ CachedHeapGraphPath path(*prev_path);
1129
+ path.Add(ret_edge);
1130
+ ret_edge->From()->FindRetainingPaths(&path, retaining_paths);
1131
+ } else {
1132
+ HeapGraphPath* ret_path = new HeapGraphPath(*prev_path->path());
1133
+ ret_path->Set(0, ret_edge);
1134
+ retaining_paths->Add(ret_path);
1135
+ }
1136
+ }
1137
+ }
1138
+
1139
+
1140
+ HeapGraphPath::HeapGraphPath(const List<HeapGraphEdge*>& path)
1141
+ : path_(path.length() + 1) {
1142
+ Add(NULL);
1143
+ for (int i = path.length() - 1; i >= 0; --i) {
1144
+ Add(path[i]);
1145
+ }
1146
+ }
1147
+
1148
+
1149
+ void HeapGraphPath::Print() {
1150
+ path_[0]->From()->Print(1, 0);
1151
+ for (int i = 0; i < path_.length(); ++i) {
1152
+ OS::Print(" -> ");
1153
+ HeapGraphEdge* edge = path_[i];
1154
+ switch (edge->type()) {
1155
+ case HeapGraphEdge::kContextVariable:
1156
+ OS::Print("[#%s] ", edge->name());
1157
+ break;
1158
+ case HeapGraphEdge::kElement:
1159
+ case HeapGraphEdge::kHidden:
1160
+ OS::Print("[%d] ", edge->index());
1161
+ break;
1162
+ case HeapGraphEdge::kInternal:
1163
+ OS::Print("[$%s] ", edge->name());
1164
+ break;
1165
+ case HeapGraphEdge::kProperty:
1166
+ OS::Print("[%s] ", edge->name());
1167
+ break;
1168
+ case HeapGraphEdge::kShortcut:
1169
+ OS::Print("[^%s] ", edge->name());
1170
+ break;
1171
+ default:
1172
+ OS::Print("!!! unknown edge type: %d ", edge->type());
1173
+ }
1174
+ edge->to()->Print(1, 0);
1175
+ }
1176
+ OS::Print("\n");
1177
+ }
1178
+
1179
+
1180
+ // It is very important to keep objects that form a heap snapshot
1181
+ // as small as possible.
1182
+ namespace { // Avoid littering the global namespace.
1183
+
1184
+ template <size_t ptr_size> struct SnapshotSizeConstants;
1185
+
1186
+ template <> struct SnapshotSizeConstants<4> {
1187
+ static const int kExpectedHeapGraphEdgeSize = 12;
1188
+ static const int kExpectedHeapEntrySize = 36;
1189
+ };
1190
+
1191
+ template <> struct SnapshotSizeConstants<8> {
1192
+ static const int kExpectedHeapGraphEdgeSize = 24;
1193
+ static const int kExpectedHeapEntrySize = 48;
1194
+ };
1195
+
1196
+ } // namespace
1197
+
1198
+ HeapSnapshot::HeapSnapshot(HeapSnapshotsCollection* collection,
1199
+ HeapSnapshot::Type type,
1200
+ const char* title,
1201
+ unsigned uid)
1202
+ : collection_(collection),
1203
+ type_(type),
1204
+ title_(title),
1205
+ uid_(uid),
1206
+ root_entry_(NULL),
1207
+ gc_roots_entry_(NULL),
1208
+ raw_entries_(NULL),
1209
+ entries_sorted_(false),
1210
+ retaining_paths_(HeapEntry::Match) {
1211
+ STATIC_ASSERT(
1212
+ sizeof(HeapGraphEdge) ==
1213
+ SnapshotSizeConstants<sizeof(void*)>::kExpectedHeapGraphEdgeSize); // NOLINT
1214
+ STATIC_ASSERT(
1215
+ sizeof(HeapEntry) ==
1216
+ SnapshotSizeConstants<sizeof(void*)>::kExpectedHeapEntrySize); // NOLINT
1217
+ }
1218
+
1219
+
1220
+ static void DeleteHeapGraphPath(HeapGraphPath** path_ptr) {
1221
+ delete *path_ptr;
1222
+ }
1223
+
1224
+ HeapSnapshot::~HeapSnapshot() {
1225
+ DeleteArray(raw_entries_);
1226
+ for (HashMap::Entry* p = retaining_paths_.Start();
1227
+ p != NULL;
1228
+ p = retaining_paths_.Next(p)) {
1229
+ List<HeapGraphPath*>* list =
1230
+ reinterpret_cast<List<HeapGraphPath*>*>(p->value);
1231
+ list->Iterate(DeleteHeapGraphPath);
1232
+ delete list;
1233
+ }
1234
+ }
1235
+
1236
+
1237
+ void HeapSnapshot::AllocateEntries(int entries_count,
1238
+ int children_count,
1239
+ int retainers_count) {
1240
+ ASSERT(raw_entries_ == NULL);
1241
+ raw_entries_ = NewArray<char>(
1242
+ HeapEntry::EntriesSize(entries_count, children_count, retainers_count));
1243
+ #ifdef DEBUG
1244
+ raw_entries_size_ =
1245
+ HeapEntry::EntriesSize(entries_count, children_count, retainers_count);
1246
+ #endif
1247
+ }
1248
+
1249
+
1250
+ static void HeapEntryClearPaint(HeapEntry** entry_ptr) {
1251
+ (*entry_ptr)->clear_paint();
1252
+ }
1253
+
1254
+ void HeapSnapshot::ClearPaint() {
1255
+ entries_.Iterate(HeapEntryClearPaint);
1256
+ }
1257
+
1258
+
1259
+ HeapEntry* HeapSnapshot::AddRootEntry(int children_count) {
1260
+ ASSERT(root_entry_ == NULL);
1261
+ return (root_entry_ = AddEntry(HeapEntry::kObject,
1262
+ "",
1263
+ HeapObjectsMap::kInternalRootObjectId,
1264
+ 0,
1265
+ children_count,
1266
+ 0));
1267
+ }
1268
+
1269
+
1270
+ HeapEntry* HeapSnapshot::AddGcRootsEntry(int children_count,
1271
+ int retainers_count) {
1272
+ ASSERT(gc_roots_entry_ == NULL);
1273
+ return (gc_roots_entry_ = AddEntry(HeapEntry::kObject,
1274
+ "(GC roots)",
1275
+ HeapObjectsMap::kGcRootsObjectId,
1276
+ 0,
1277
+ children_count,
1278
+ retainers_count));
1279
+ }
1280
+
1281
+
1282
+ HeapEntry* HeapSnapshot::AddEntry(HeapEntry::Type type,
1283
+ const char* name,
1284
+ uint64_t id,
1285
+ int size,
1286
+ int children_count,
1287
+ int retainers_count) {
1288
+ HeapEntry* entry = GetNextEntryToInit();
1289
+ entry->Init(this, type, name, id, size, children_count, retainers_count);
1290
+ return entry;
1291
+ }
1292
+
1293
+
1294
+ void HeapSnapshot::SetDominatorsToSelf() {
1295
+ for (int i = 0; i < entries_.length(); ++i) {
1296
+ HeapEntry* entry = entries_[i];
1297
+ if (entry->dominator() == NULL) entry->set_dominator(entry);
1298
+ }
1299
+ }
1300
+
1301
+
1302
+ HeapEntry* HeapSnapshot::GetNextEntryToInit() {
1303
+ if (entries_.length() > 0) {
1304
+ HeapEntry* last_entry = entries_.last();
1305
+ entries_.Add(reinterpret_cast<HeapEntry*>(
1306
+ reinterpret_cast<char*>(last_entry) + last_entry->EntrySize()));
1307
+ } else {
1308
+ entries_.Add(reinterpret_cast<HeapEntry*>(raw_entries_));
1309
+ }
1310
+ ASSERT(reinterpret_cast<char*>(entries_.last()) <
1311
+ (raw_entries_ + raw_entries_size_));
1312
+ return entries_.last();
1313
+ }
1314
+
1315
+
1316
+ HeapSnapshotsDiff* HeapSnapshot::CompareWith(HeapSnapshot* snapshot) {
1317
+ return collection_->CompareSnapshots(this, snapshot);
1318
+ }
1319
+
1320
+
1321
+ HeapEntry* HeapSnapshot::GetEntryById(uint64_t id) {
1322
+ // GetSortedEntriesList is used in diff algorithm and sorts
1323
+ // entries by their id.
1324
+ List<HeapEntry*>* entries_by_id = GetSortedEntriesList();
1325
+
1326
+ // Perform a binary search by id.
1327
+ int low = 0;
1328
+ int high = entries_by_id->length() - 1;
1329
+ while (low <= high) {
1330
+ int mid =
1331
+ (static_cast<unsigned int>(low) + static_cast<unsigned int>(high)) >> 1;
1332
+ uint64_t mid_id = entries_by_id->at(mid)->id();
1333
+ if (mid_id > id)
1334
+ high = mid - 1;
1335
+ else if (mid_id < id)
1336
+ low = mid + 1;
1337
+ else
1338
+ return entries_by_id->at(mid);
1339
+ }
1340
+ return NULL;
1341
+ }
1342
+
1343
+
1344
+ List<HeapGraphPath*>* HeapSnapshot::GetRetainingPaths(HeapEntry* entry) {
1345
+ HashMap::Entry* p =
1346
+ retaining_paths_.Lookup(entry, HeapEntry::Hash(entry), true);
1347
+ if (p->value == NULL) {
1348
+ p->value = entry->CalculateRetainingPaths();
1349
+ }
1350
+ return reinterpret_cast<List<HeapGraphPath*>*>(p->value);
1351
+ }
1352
+
1353
+
1354
+ template<class T>
1355
+ static int SortByIds(const T* entry1_ptr,
1356
+ const T* entry2_ptr) {
1357
+ if ((*entry1_ptr)->id() == (*entry2_ptr)->id()) return 0;
1358
+ return (*entry1_ptr)->id() < (*entry2_ptr)->id() ? -1 : 1;
1359
+ }
1360
+
1361
+ List<HeapEntry*>* HeapSnapshot::GetSortedEntriesList() {
1362
+ if (!entries_sorted_) {
1363
+ entries_.Sort(SortByIds);
1364
+ entries_sorted_ = true;
1365
+ }
1366
+ return &entries_;
1367
+ }
1368
+
1369
+
1370
+ void HeapSnapshot::Print(int max_depth) {
1371
+ root()->Print(max_depth, 0);
1372
+ }
1373
+
1374
+
1375
+ const uint64_t HeapObjectsMap::kInternalRootObjectId = 0;
1376
+ const uint64_t HeapObjectsMap::kGcRootsObjectId = 1;
1377
+ // Increase kFirstAvailableObjectId if new 'special' objects appear.
1378
+ const uint64_t HeapObjectsMap::kFirstAvailableObjectId = 2;
1379
+
1380
+ HeapObjectsMap::HeapObjectsMap()
1381
+ : initial_fill_mode_(true),
1382
+ next_id_(kFirstAvailableObjectId),
1383
+ entries_map_(AddressesMatch),
1384
+ entries_(new List<EntryInfo>()) { }
1385
+
1386
+
1387
+ HeapObjectsMap::~HeapObjectsMap() {
1388
+ delete entries_;
1389
+ }
1390
+
1391
+
1392
+ void HeapObjectsMap::SnapshotGenerationFinished() {
1393
+ initial_fill_mode_ = false;
1394
+ RemoveDeadEntries();
1395
+ }
1396
+
1397
+
1398
+ uint64_t HeapObjectsMap::FindObject(Address addr) {
1399
+ if (!initial_fill_mode_) {
1400
+ uint64_t existing = FindEntry(addr);
1401
+ if (existing != 0) return existing;
1402
+ }
1403
+ uint64_t id = next_id_++;
1404
+ AddEntry(addr, id);
1405
+ return id;
1406
+ }
1407
+
1408
+
1409
+ void HeapObjectsMap::MoveObject(Address from, Address to) {
1410
+ if (from == to) return;
1411
+ HashMap::Entry* entry = entries_map_.Lookup(from, AddressHash(from), false);
1412
+ if (entry != NULL) {
1413
+ void* value = entry->value;
1414
+ entries_map_.Remove(from, AddressHash(from));
1415
+ entry = entries_map_.Lookup(to, AddressHash(to), true);
1416
+ // We can have an entry at the new location, it is OK, as GC can overwrite
1417
+ // dead objects with alive objects being moved.
1418
+ entry->value = value;
1419
+ }
1420
+ }
1421
+
1422
+
1423
+ void HeapObjectsMap::AddEntry(Address addr, uint64_t id) {
1424
+ HashMap::Entry* entry = entries_map_.Lookup(addr, AddressHash(addr), true);
1425
+ ASSERT(entry->value == NULL);
1426
+ entry->value = reinterpret_cast<void*>(entries_->length());
1427
+ entries_->Add(EntryInfo(id));
1428
+ }
1429
+
1430
+
1431
+ uint64_t HeapObjectsMap::FindEntry(Address addr) {
1432
+ HashMap::Entry* entry = entries_map_.Lookup(addr, AddressHash(addr), false);
1433
+ if (entry != NULL) {
1434
+ int entry_index =
1435
+ static_cast<int>(reinterpret_cast<intptr_t>(entry->value));
1436
+ EntryInfo& entry_info = entries_->at(entry_index);
1437
+ entry_info.accessed = true;
1438
+ return entry_info.id;
1439
+ } else {
1440
+ return 0;
1441
+ }
1442
+ }
1443
+
1444
+
1445
+ void HeapObjectsMap::RemoveDeadEntries() {
1446
+ List<EntryInfo>* new_entries = new List<EntryInfo>();
1447
+ List<void*> dead_entries;
1448
+ for (HashMap::Entry* entry = entries_map_.Start();
1449
+ entry != NULL;
1450
+ entry = entries_map_.Next(entry)) {
1451
+ int entry_index =
1452
+ static_cast<int>(reinterpret_cast<intptr_t>(entry->value));
1453
+ EntryInfo& entry_info = entries_->at(entry_index);
1454
+ if (entry_info.accessed) {
1455
+ entry->value = reinterpret_cast<void*>(new_entries->length());
1456
+ new_entries->Add(EntryInfo(entry_info.id, false));
1457
+ } else {
1458
+ dead_entries.Add(entry->key);
1459
+ }
1460
+ }
1461
+ for (int i = 0; i < dead_entries.length(); ++i) {
1462
+ void* raw_entry = dead_entries[i];
1463
+ entries_map_.Remove(
1464
+ raw_entry, AddressHash(reinterpret_cast<Address>(raw_entry)));
1465
+ }
1466
+ delete entries_;
1467
+ entries_ = new_entries;
1468
+ }
1469
+
1470
+
1471
+ HeapSnapshotsCollection::HeapSnapshotsCollection()
1472
+ : is_tracking_objects_(false),
1473
+ snapshots_uids_(HeapSnapshotsMatch),
1474
+ token_enumerator_(new TokenEnumerator()) {
1475
+ }
1476
+
1477
+
1478
+ static void DeleteHeapSnapshot(HeapSnapshot** snapshot_ptr) {
1479
+ delete *snapshot_ptr;
1480
+ }
1481
+
1482
+
1483
+ HeapSnapshotsCollection::~HeapSnapshotsCollection() {
1484
+ delete token_enumerator_;
1485
+ snapshots_.Iterate(DeleteHeapSnapshot);
1486
+ }
1487
+
1488
+
1489
+ HeapSnapshot* HeapSnapshotsCollection::NewSnapshot(HeapSnapshot::Type type,
1490
+ const char* name,
1491
+ unsigned uid) {
1492
+ is_tracking_objects_ = true; // Start watching for heap objects moves.
1493
+ return new HeapSnapshot(this, type, name, uid);
1494
+ }
1495
+
1496
+
1497
+ void HeapSnapshotsCollection::SnapshotGenerationFinished(
1498
+ HeapSnapshot* snapshot) {
1499
+ ids_.SnapshotGenerationFinished();
1500
+ if (snapshot != NULL) {
1501
+ snapshots_.Add(snapshot);
1502
+ HashMap::Entry* entry =
1503
+ snapshots_uids_.Lookup(reinterpret_cast<void*>(snapshot->uid()),
1504
+ static_cast<uint32_t>(snapshot->uid()),
1505
+ true);
1506
+ ASSERT(entry->value == NULL);
1507
+ entry->value = snapshot;
1508
+ }
1509
+ }
1510
+
1511
+
1512
+ HeapSnapshot* HeapSnapshotsCollection::GetSnapshot(unsigned uid) {
1513
+ HashMap::Entry* entry = snapshots_uids_.Lookup(reinterpret_cast<void*>(uid),
1514
+ static_cast<uint32_t>(uid),
1515
+ false);
1516
+ return entry != NULL ? reinterpret_cast<HeapSnapshot*>(entry->value) : NULL;
1517
+ }
1518
+
1519
+
1520
+ HeapSnapshotsDiff* HeapSnapshotsCollection::CompareSnapshots(
1521
+ HeapSnapshot* snapshot1,
1522
+ HeapSnapshot* snapshot2) {
1523
+ return comparator_.Compare(snapshot1, snapshot2);
1524
+ }
1525
+
1526
+
1527
+ HeapEntry *const HeapEntriesMap::kHeapEntryPlaceholder =
1528
+ reinterpret_cast<HeapEntry*>(1);
1529
+
1530
+ HeapEntriesMap::HeapEntriesMap()
1531
+ : entries_(HeapThingsMatch),
1532
+ entries_count_(0),
1533
+ total_children_count_(0),
1534
+ total_retainers_count_(0) {
1535
+ }
1536
+
1537
+
1538
+ HeapEntriesMap::~HeapEntriesMap() {
1539
+ for (HashMap::Entry* p = entries_.Start(); p != NULL; p = entries_.Next(p)) {
1540
+ delete reinterpret_cast<EntryInfo*>(p->value);
1541
+ }
1542
+ }
1543
+
1544
+
1545
+ void HeapEntriesMap::AllocateEntries() {
1546
+ for (HashMap::Entry* p = entries_.Start();
1547
+ p != NULL;
1548
+ p = entries_.Next(p)) {
1549
+ EntryInfo* entry_info = reinterpret_cast<EntryInfo*>(p->value);
1550
+ entry_info->entry = entry_info->allocator->AllocateEntry(
1551
+ p->key,
1552
+ entry_info->children_count,
1553
+ entry_info->retainers_count);
1554
+ entry_info->children_count = 0;
1555
+ entry_info->retainers_count = 0;
1556
+ }
1557
+ }
1558
+
1559
+
1560
+ HeapEntry* HeapEntriesMap::Map(HeapThing thing) {
1561
+ HashMap::Entry* cache_entry = entries_.Lookup(thing, Hash(thing), false);
1562
+ if (cache_entry != NULL) {
1563
+ EntryInfo* entry_info = reinterpret_cast<EntryInfo*>(cache_entry->value);
1564
+ return entry_info->entry;
1565
+ } else {
1566
+ return NULL;
1567
+ }
1568
+ }
1569
+
1570
+
1571
+ void HeapEntriesMap::Pair(
1572
+ HeapThing thing, HeapEntriesAllocator* allocator, HeapEntry* entry) {
1573
+ HashMap::Entry* cache_entry = entries_.Lookup(thing, Hash(thing), true);
1574
+ ASSERT(cache_entry->value == NULL);
1575
+ cache_entry->value = new EntryInfo(entry, allocator);
1576
+ ++entries_count_;
1577
+ }
1578
+
1579
+
1580
+ void HeapEntriesMap::CountReference(HeapThing from, HeapThing to,
1581
+ int* prev_children_count,
1582
+ int* prev_retainers_count) {
1583
+ HashMap::Entry* from_cache_entry = entries_.Lookup(from, Hash(from), false);
1584
+ HashMap::Entry* to_cache_entry = entries_.Lookup(to, Hash(to), false);
1585
+ ASSERT(from_cache_entry != NULL);
1586
+ ASSERT(to_cache_entry != NULL);
1587
+ EntryInfo* from_entry_info =
1588
+ reinterpret_cast<EntryInfo*>(from_cache_entry->value);
1589
+ EntryInfo* to_entry_info =
1590
+ reinterpret_cast<EntryInfo*>(to_cache_entry->value);
1591
+ if (prev_children_count)
1592
+ *prev_children_count = from_entry_info->children_count;
1593
+ if (prev_retainers_count)
1594
+ *prev_retainers_count = to_entry_info->retainers_count;
1595
+ ++from_entry_info->children_count;
1596
+ ++to_entry_info->retainers_count;
1597
+ ++total_children_count_;
1598
+ ++total_retainers_count_;
1599
+ }
1600
+
1601
+
1602
+ HeapObjectsSet::HeapObjectsSet()
1603
+ : entries_(HeapEntriesMap::HeapThingsMatch) {
1604
+ }
1605
+
1606
+
1607
+ void HeapObjectsSet::Clear() {
1608
+ entries_.Clear();
1609
+ }
1610
+
1611
+
1612
+ bool HeapObjectsSet::Contains(Object* obj) {
1613
+ if (!obj->IsHeapObject()) return false;
1614
+ HeapObject* object = HeapObject::cast(obj);
1615
+ HashMap::Entry* cache_entry =
1616
+ entries_.Lookup(object, HeapEntriesMap::Hash(object), false);
1617
+ return cache_entry != NULL;
1618
+ }
1619
+
1620
+
1621
+ void HeapObjectsSet::Insert(Object* obj) {
1622
+ if (!obj->IsHeapObject()) return;
1623
+ HeapObject* object = HeapObject::cast(obj);
1624
+ HashMap::Entry* cache_entry =
1625
+ entries_.Lookup(object, HeapEntriesMap::Hash(object), true);
1626
+ if (cache_entry->value == NULL) {
1627
+ cache_entry->value = HeapEntriesMap::kHeapEntryPlaceholder;
1628
+ }
1629
+ }
1630
+
1631
+
1632
+ HeapObject *const V8HeapExplorer::kInternalRootObject =
1633
+ reinterpret_cast<HeapObject*>(1);
1634
+ HeapObject *const V8HeapExplorer::kGcRootsObject =
1635
+ reinterpret_cast<HeapObject*>(2);
1636
+
1637
+
1638
+ V8HeapExplorer::V8HeapExplorer(
1639
+ HeapSnapshot* snapshot,
1640
+ SnapshottingProgressReportingInterface* progress)
1641
+ : snapshot_(snapshot),
1642
+ collection_(snapshot_->collection()),
1643
+ progress_(progress),
1644
+ filler_(NULL) {
1645
+ }
1646
+
1647
+
1648
+ V8HeapExplorer::~V8HeapExplorer() {
1649
+ }
1650
+
1651
+
1652
+ HeapEntry* V8HeapExplorer::AllocateEntry(
1653
+ HeapThing ptr, int children_count, int retainers_count) {
1654
+ return AddEntry(
1655
+ reinterpret_cast<HeapObject*>(ptr), children_count, retainers_count);
1656
+ }
1657
+
1658
+
1659
+ HeapEntry* V8HeapExplorer::AddEntry(HeapObject* object,
1660
+ int children_count,
1661
+ int retainers_count) {
1662
+ if (object == kInternalRootObject) {
1663
+ ASSERT(retainers_count == 0);
1664
+ return snapshot_->AddRootEntry(children_count);
1665
+ } else if (object == kGcRootsObject) {
1666
+ return snapshot_->AddGcRootsEntry(children_count, retainers_count);
1667
+ } else if (object->IsJSFunction()) {
1668
+ JSFunction* func = JSFunction::cast(object);
1669
+ SharedFunctionInfo* shared = func->shared();
1670
+ return AddEntry(object,
1671
+ HeapEntry::kClosure,
1672
+ collection_->GetName(String::cast(shared->name())),
1673
+ children_count,
1674
+ retainers_count);
1675
+ } else if (object->IsJSRegExp()) {
1676
+ JSRegExp* re = JSRegExp::cast(object);
1677
+ return AddEntry(object,
1678
+ HeapEntry::kRegExp,
1679
+ collection_->GetName(re->Pattern()),
1680
+ children_count,
1681
+ retainers_count);
1682
+ } else if (object->IsJSObject()) {
1683
+ return AddEntry(object,
1684
+ HeapEntry::kObject,
1685
+ collection_->GetName(GetConstructorNameForHeapProfile(
1686
+ JSObject::cast(object))),
1687
+ children_count,
1688
+ retainers_count);
1689
+ } else if (object->IsString()) {
1690
+ return AddEntry(object,
1691
+ HeapEntry::kString,
1692
+ collection_->GetName(String::cast(object)),
1693
+ children_count,
1694
+ retainers_count);
1695
+ } else if (object->IsCode()) {
1696
+ return AddEntry(object,
1697
+ HeapEntry::kCode,
1698
+ "",
1699
+ children_count,
1700
+ retainers_count);
1701
+ } else if (object->IsSharedFunctionInfo()) {
1702
+ SharedFunctionInfo* shared = SharedFunctionInfo::cast(object);
1703
+ return AddEntry(object,
1704
+ HeapEntry::kCode,
1705
+ collection_->GetName(String::cast(shared->name())),
1706
+ children_count,
1707
+ retainers_count);
1708
+ } else if (object->IsScript()) {
1709
+ Script* script = Script::cast(object);
1710
+ return AddEntry(object,
1711
+ HeapEntry::kCode,
1712
+ script->name()->IsString() ?
1713
+ collection_->GetName(String::cast(script->name())) : "",
1714
+ children_count,
1715
+ retainers_count);
1716
+ } else if (object->IsFixedArray()) {
1717
+ return AddEntry(object,
1718
+ HeapEntry::kArray,
1719
+ "",
1720
+ children_count,
1721
+ retainers_count);
1722
+ } else if (object->IsHeapNumber()) {
1723
+ return AddEntry(object,
1724
+ HeapEntry::kHeapNumber,
1725
+ "number",
1726
+ children_count,
1727
+ retainers_count);
1728
+ }
1729
+ return AddEntry(object,
1730
+ HeapEntry::kHidden,
1731
+ "system",
1732
+ children_count,
1733
+ retainers_count);
1734
+ }
1735
+
1736
+
1737
+ HeapEntry* V8HeapExplorer::AddEntry(HeapObject* object,
1738
+ HeapEntry::Type type,
1739
+ const char* name,
1740
+ int children_count,
1741
+ int retainers_count) {
1742
+ return snapshot_->AddEntry(type,
1743
+ name,
1744
+ collection_->GetObjectId(object->address()),
1745
+ object->Size(),
1746
+ children_count,
1747
+ retainers_count);
1748
+ }
1749
+
1750
+
1751
+ void V8HeapExplorer::AddRootEntries(SnapshotFillerInterface* filler) {
1752
+ filler->AddEntry(kInternalRootObject);
1753
+ filler->AddEntry(kGcRootsObject);
1754
+ }
1755
+
1756
+
1757
+ int V8HeapExplorer::EstimateObjectsCount() {
1758
+ HeapIterator iterator(HeapIterator::kFilterUnreachable);
1759
+ int objects_count = 0;
1760
+ for (HeapObject* obj = iterator.next();
1761
+ obj != NULL;
1762
+ obj = iterator.next(), ++objects_count) {}
1763
+ return objects_count;
1764
+ }
1765
+
1766
+
1767
+ class IndexedReferencesExtractor : public ObjectVisitor {
1768
+ public:
1769
+ IndexedReferencesExtractor(V8HeapExplorer* generator,
1770
+ HeapObject* parent_obj,
1771
+ HeapEntry* parent_entry,
1772
+ HeapObjectsSet* known_references = NULL)
1773
+ : generator_(generator),
1774
+ parent_obj_(parent_obj),
1775
+ parent_(parent_entry),
1776
+ known_references_(known_references),
1777
+ next_index_(1) {
1778
+ }
1779
+ void VisitPointers(Object** start, Object** end) {
1780
+ for (Object** p = start; p < end; p++) {
1781
+ if (!known_references_ || !known_references_->Contains(*p)) {
1782
+ generator_->SetHiddenReference(parent_obj_, parent_, next_index_++, *p);
1783
+ }
1784
+ }
1785
+ }
1786
+ private:
1787
+ V8HeapExplorer* generator_;
1788
+ HeapObject* parent_obj_;
1789
+ HeapEntry* parent_;
1790
+ HeapObjectsSet* known_references_;
1791
+ int next_index_;
1792
+ };
1793
+
1794
+
1795
+ void V8HeapExplorer::ExtractReferences(HeapObject* obj) {
1796
+ HeapEntry* entry = GetEntry(obj);
1797
+ if (entry == NULL) return; // No interest in this object.
1798
+
1799
+ known_references_.Clear();
1800
+ if (obj->IsJSGlobalProxy()) {
1801
+ // We need to reference JS global objects from snapshot's root.
1802
+ // We use JSGlobalProxy because this is what embedder (e.g. browser)
1803
+ // uses for the global object.
1804
+ JSGlobalProxy* proxy = JSGlobalProxy::cast(obj);
1805
+ SetRootShortcutReference(proxy->map()->prototype());
1806
+ IndexedReferencesExtractor refs_extractor(this, obj, entry);
1807
+ obj->Iterate(&refs_extractor);
1808
+ } else if (obj->IsJSObject()) {
1809
+ JSObject* js_obj = JSObject::cast(obj);
1810
+ ExtractClosureReferences(js_obj, entry);
1811
+ ExtractPropertyReferences(js_obj, entry);
1812
+ ExtractElementReferences(js_obj, entry);
1813
+ ExtractInternalReferences(js_obj, entry);
1814
+ SetPropertyReference(
1815
+ obj, entry, Heap::Proto_symbol(), js_obj->GetPrototype());
1816
+ if (obj->IsJSFunction()) {
1817
+ JSFunction* js_fun = JSFunction::cast(obj);
1818
+ if (js_fun->has_prototype()) {
1819
+ SetPropertyReference(
1820
+ obj, entry, Heap::prototype_symbol(), js_fun->prototype());
1821
+ }
1822
+ }
1823
+ IndexedReferencesExtractor refs_extractor(
1824
+ this, obj, entry, &known_references_);
1825
+ obj->Iterate(&refs_extractor);
1826
+ } else if (obj->IsString()) {
1827
+ if (obj->IsConsString()) {
1828
+ ConsString* cs = ConsString::cast(obj);
1829
+ SetInternalReference(obj, entry, 1, cs->first());
1830
+ SetInternalReference(obj, entry, 2, cs->second());
1831
+ }
1832
+ } else {
1833
+ IndexedReferencesExtractor refs_extractor(this, obj, entry);
1834
+ obj->Iterate(&refs_extractor);
1835
+ }
1836
+ }
1837
+
1838
+
1839
+ void V8HeapExplorer::ExtractClosureReferences(JSObject* js_obj,
1840
+ HeapEntry* entry) {
1841
+ if (js_obj->IsJSFunction()) {
1842
+ HandleScope hs;
1843
+ JSFunction* func = JSFunction::cast(js_obj);
1844
+ Context* context = func->context();
1845
+ ZoneScope zscope(DELETE_ON_EXIT);
1846
+ SerializedScopeInfo* serialized_scope_info =
1847
+ context->closure()->shared()->scope_info();
1848
+ ScopeInfo<ZoneListAllocationPolicy> zone_scope_info(serialized_scope_info);
1849
+ int locals_number = zone_scope_info.NumberOfLocals();
1850
+ for (int i = 0; i < locals_number; ++i) {
1851
+ String* local_name = *zone_scope_info.LocalName(i);
1852
+ int idx = serialized_scope_info->ContextSlotIndex(local_name, NULL);
1853
+ if (idx >= 0 && idx < context->length()) {
1854
+ SetClosureReference(js_obj, entry, local_name, context->get(idx));
1855
+ }
1856
+ }
1857
+ SetInternalReference(js_obj, entry, "code", func->shared());
1858
+ }
1859
+ }
1860
+
1861
+
1862
+ void V8HeapExplorer::ExtractPropertyReferences(JSObject* js_obj,
1863
+ HeapEntry* entry) {
1864
+ if (js_obj->HasFastProperties()) {
1865
+ DescriptorArray* descs = js_obj->map()->instance_descriptors();
1866
+ for (int i = 0; i < descs->number_of_descriptors(); i++) {
1867
+ switch (descs->GetType(i)) {
1868
+ case FIELD: {
1869
+ int index = descs->GetFieldIndex(i);
1870
+ SetPropertyReference(
1871
+ js_obj, entry, descs->GetKey(i), js_obj->FastPropertyAt(index));
1872
+ break;
1873
+ }
1874
+ case CONSTANT_FUNCTION:
1875
+ SetPropertyReference(
1876
+ js_obj, entry, descs->GetKey(i), descs->GetConstantFunction(i));
1877
+ break;
1878
+ default: ;
1879
+ }
1880
+ }
1881
+ } else {
1882
+ StringDictionary* dictionary = js_obj->property_dictionary();
1883
+ int length = dictionary->Capacity();
1884
+ for (int i = 0; i < length; ++i) {
1885
+ Object* k = dictionary->KeyAt(i);
1886
+ if (dictionary->IsKey(k)) {
1887
+ Object* target = dictionary->ValueAt(i);
1888
+ SetPropertyReference(
1889
+ js_obj, entry, String::cast(k), target);
1890
+ // We assume that global objects can only have slow properties.
1891
+ if (target->IsJSGlobalPropertyCell()) {
1892
+ SetPropertyShortcutReference(js_obj,
1893
+ entry,
1894
+ String::cast(k),
1895
+ JSGlobalPropertyCell::cast(
1896
+ target)->value());
1897
+ }
1898
+ }
1899
+ }
1900
+ }
1901
+ }
1902
+
1903
+
1904
+ void V8HeapExplorer::ExtractElementReferences(JSObject* js_obj,
1905
+ HeapEntry* entry) {
1906
+ if (js_obj->HasFastElements()) {
1907
+ FixedArray* elements = FixedArray::cast(js_obj->elements());
1908
+ int length = js_obj->IsJSArray() ?
1909
+ Smi::cast(JSArray::cast(js_obj)->length())->value() :
1910
+ elements->length();
1911
+ for (int i = 0; i < length; ++i) {
1912
+ if (!elements->get(i)->IsTheHole()) {
1913
+ SetElementReference(js_obj, entry, i, elements->get(i));
1914
+ }
1915
+ }
1916
+ } else if (js_obj->HasDictionaryElements()) {
1917
+ NumberDictionary* dictionary = js_obj->element_dictionary();
1918
+ int length = dictionary->Capacity();
1919
+ for (int i = 0; i < length; ++i) {
1920
+ Object* k = dictionary->KeyAt(i);
1921
+ if (dictionary->IsKey(k)) {
1922
+ ASSERT(k->IsNumber());
1923
+ uint32_t index = static_cast<uint32_t>(k->Number());
1924
+ SetElementReference(js_obj, entry, index, dictionary->ValueAt(i));
1925
+ }
1926
+ }
1927
+ }
1928
+ }
1929
+
1930
+
1931
+ void V8HeapExplorer::ExtractInternalReferences(JSObject* js_obj,
1932
+ HeapEntry* entry) {
1933
+ int length = js_obj->GetInternalFieldCount();
1934
+ for (int i = 0; i < length; ++i) {
1935
+ Object* o = js_obj->GetInternalField(i);
1936
+ SetInternalReference(js_obj, entry, i, o);
1937
+ }
1938
+ }
1939
+
1940
+
1941
+ HeapEntry* V8HeapExplorer::GetEntry(Object* obj) {
1942
+ if (!obj->IsHeapObject()) return NULL;
1943
+ return filler_->FindOrAddEntry(obj);
1944
+ }
1945
+
1946
+
1947
+ class RootsReferencesExtractor : public ObjectVisitor {
1948
+ public:
1949
+ explicit RootsReferencesExtractor(V8HeapExplorer* explorer)
1950
+ : explorer_(explorer) {
1951
+ }
1952
+ void VisitPointers(Object** start, Object** end) {
1953
+ for (Object** p = start; p < end; p++) explorer_->SetGcRootsReference(*p);
1954
+ }
1955
+ private:
1956
+ V8HeapExplorer* explorer_;
1957
+ };
1958
+
1959
+
1960
+ bool V8HeapExplorer::IterateAndExtractReferences(
1961
+ SnapshotFillerInterface* filler) {
1962
+ filler_ = filler;
1963
+ HeapIterator iterator(HeapIterator::kFilterUnreachable);
1964
+ bool interrupted = false;
1965
+ // Heap iteration with filtering must be finished in any case.
1966
+ for (HeapObject* obj = iterator.next();
1967
+ obj != NULL;
1968
+ obj = iterator.next(), progress_->ProgressStep()) {
1969
+ if (!interrupted) {
1970
+ ExtractReferences(obj);
1971
+ if (!progress_->ProgressReport(false)) interrupted = true;
1972
+ }
1973
+ }
1974
+ if (interrupted) {
1975
+ filler_ = NULL;
1976
+ return false;
1977
+ }
1978
+ SetRootGcRootsReference();
1979
+ RootsReferencesExtractor extractor(this);
1980
+ Heap::IterateRoots(&extractor, VISIT_ALL);
1981
+ filler_ = NULL;
1982
+ return progress_->ProgressReport(false);
1983
+ }
1984
+
1985
+
1986
+ void V8HeapExplorer::SetClosureReference(HeapObject* parent_obj,
1987
+ HeapEntry* parent_entry,
1988
+ String* reference_name,
1989
+ Object* child_obj) {
1990
+ HeapEntry* child_entry = GetEntry(child_obj);
1991
+ if (child_entry != NULL) {
1992
+ filler_->SetNamedReference(HeapGraphEdge::kContextVariable,
1993
+ parent_obj,
1994
+ parent_entry,
1995
+ collection_->GetName(reference_name),
1996
+ child_obj,
1997
+ child_entry);
1998
+ known_references_.Insert(child_obj);
1999
+ }
2000
+ }
2001
+
2002
+
2003
+ void V8HeapExplorer::SetElementReference(HeapObject* parent_obj,
2004
+ HeapEntry* parent_entry,
2005
+ int index,
2006
+ Object* child_obj) {
2007
+ HeapEntry* child_entry = GetEntry(child_obj);
2008
+ if (child_entry != NULL) {
2009
+ filler_->SetIndexedReference(HeapGraphEdge::kElement,
2010
+ parent_obj,
2011
+ parent_entry,
2012
+ index,
2013
+ child_obj,
2014
+ child_entry);
2015
+ known_references_.Insert(child_obj);
2016
+ }
2017
+ }
2018
+
2019
+
2020
+ void V8HeapExplorer::SetInternalReference(HeapObject* parent_obj,
2021
+ HeapEntry* parent_entry,
2022
+ const char* reference_name,
2023
+ Object* child_obj) {
2024
+ HeapEntry* child_entry = GetEntry(child_obj);
2025
+ if (child_entry != NULL) {
2026
+ filler_->SetNamedReference(HeapGraphEdge::kInternal,
2027
+ parent_obj,
2028
+ parent_entry,
2029
+ reference_name,
2030
+ child_obj,
2031
+ child_entry);
2032
+ known_references_.Insert(child_obj);
2033
+ }
2034
+ }
2035
+
2036
+
2037
+ void V8HeapExplorer::SetInternalReference(HeapObject* parent_obj,
2038
+ HeapEntry* parent_entry,
2039
+ int index,
2040
+ Object* child_obj) {
2041
+ HeapEntry* child_entry = GetEntry(child_obj);
2042
+ if (child_entry != NULL) {
2043
+ filler_->SetNamedReference(HeapGraphEdge::kInternal,
2044
+ parent_obj,
2045
+ parent_entry,
2046
+ collection_->GetName(index),
2047
+ child_obj,
2048
+ child_entry);
2049
+ known_references_.Insert(child_obj);
2050
+ }
2051
+ }
2052
+
2053
+
2054
+ void V8HeapExplorer::SetHiddenReference(HeapObject* parent_obj,
2055
+ HeapEntry* parent_entry,
2056
+ int index,
2057
+ Object* child_obj) {
2058
+ HeapEntry* child_entry = GetEntry(child_obj);
2059
+ if (child_entry != NULL) {
2060
+ filler_->SetIndexedReference(HeapGraphEdge::kHidden,
2061
+ parent_obj,
2062
+ parent_entry,
2063
+ index,
2064
+ child_obj,
2065
+ child_entry);
2066
+ }
2067
+ }
2068
+
2069
+
2070
+ void V8HeapExplorer::SetPropertyReference(HeapObject* parent_obj,
2071
+ HeapEntry* parent_entry,
2072
+ String* reference_name,
2073
+ Object* child_obj) {
2074
+ HeapEntry* child_entry = GetEntry(child_obj);
2075
+ if (child_entry != NULL) {
2076
+ HeapGraphEdge::Type type = reference_name->length() > 0 ?
2077
+ HeapGraphEdge::kProperty : HeapGraphEdge::kInternal;
2078
+ filler_->SetNamedReference(type,
2079
+ parent_obj,
2080
+ parent_entry,
2081
+ collection_->GetName(reference_name),
2082
+ child_obj,
2083
+ child_entry);
2084
+ known_references_.Insert(child_obj);
2085
+ }
2086
+ }
2087
+
2088
+
2089
+ void V8HeapExplorer::SetPropertyShortcutReference(
2090
+ HeapObject* parent_obj,
2091
+ HeapEntry* parent_entry,
2092
+ String* reference_name,
2093
+ Object* child_obj) {
2094
+ HeapEntry* child_entry = GetEntry(child_obj);
2095
+ if (child_entry != NULL) {
2096
+ filler_->SetNamedReference(HeapGraphEdge::kShortcut,
2097
+ parent_obj,
2098
+ parent_entry,
2099
+ collection_->GetName(reference_name),
2100
+ child_obj,
2101
+ child_entry);
2102
+ }
2103
+ }
2104
+
2105
+
2106
+ void V8HeapExplorer::SetRootGcRootsReference() {
2107
+ filler_->SetIndexedAutoIndexReference(
2108
+ HeapGraphEdge::kElement,
2109
+ kInternalRootObject, snapshot_->root(),
2110
+ kGcRootsObject, snapshot_->gc_roots());
2111
+ }
2112
+
2113
+
2114
+ void V8HeapExplorer::SetRootShortcutReference(Object* child_obj) {
2115
+ HeapEntry* child_entry = GetEntry(child_obj);
2116
+ ASSERT(child_entry != NULL);
2117
+ filler_->SetNamedAutoIndexReference(
2118
+ HeapGraphEdge::kShortcut,
2119
+ kInternalRootObject, snapshot_->root(),
2120
+ child_obj, child_entry);
2121
+ }
2122
+
2123
+
2124
+ void V8HeapExplorer::SetGcRootsReference(Object* child_obj) {
2125
+ HeapEntry* child_entry = GetEntry(child_obj);
2126
+ if (child_entry != NULL) {
2127
+ filler_->SetIndexedAutoIndexReference(
2128
+ HeapGraphEdge::kElement,
2129
+ kGcRootsObject, snapshot_->gc_roots(),
2130
+ child_obj, child_entry);
2131
+ }
2132
+ }
2133
+
2134
+
2135
+ HeapSnapshotGenerator::HeapSnapshotGenerator(HeapSnapshot* snapshot,
2136
+ v8::ActivityControl* control)
2137
+ : snapshot_(snapshot),
2138
+ control_(control),
2139
+ v8_heap_explorer_(snapshot_, this) {
2140
+ }
2141
+
2142
+
2143
+ class SnapshotCounter : public SnapshotFillerInterface {
2144
+ public:
2145
+ SnapshotCounter(HeapEntriesAllocator* allocator, HeapEntriesMap* entries)
2146
+ : allocator_(allocator), entries_(entries) { }
2147
+ HeapEntry* AddEntry(HeapThing ptr) {
2148
+ entries_->Pair(ptr, allocator_, HeapEntriesMap::kHeapEntryPlaceholder);
2149
+ return HeapEntriesMap::kHeapEntryPlaceholder;
2150
+ }
2151
+ HeapEntry* FindOrAddEntry(HeapThing ptr) {
2152
+ HeapEntry* entry = entries_->Map(ptr);
2153
+ return entry != NULL ? entry : AddEntry(ptr);
2154
+ }
2155
+ void SetIndexedReference(HeapGraphEdge::Type,
2156
+ HeapThing parent_ptr,
2157
+ HeapEntry*,
2158
+ int,
2159
+ HeapThing child_ptr,
2160
+ HeapEntry*) {
2161
+ entries_->CountReference(parent_ptr, child_ptr);
2162
+ }
2163
+ void SetIndexedAutoIndexReference(HeapGraphEdge::Type,
2164
+ HeapThing parent_ptr,
2165
+ HeapEntry*,
2166
+ HeapThing child_ptr,
2167
+ HeapEntry*) {
2168
+ entries_->CountReference(parent_ptr, child_ptr);
2169
+ }
2170
+ void SetNamedReference(HeapGraphEdge::Type,
2171
+ HeapThing parent_ptr,
2172
+ HeapEntry*,
2173
+ const char*,
2174
+ HeapThing child_ptr,
2175
+ HeapEntry*) {
2176
+ entries_->CountReference(parent_ptr, child_ptr);
2177
+ }
2178
+ void SetNamedAutoIndexReference(HeapGraphEdge::Type,
2179
+ HeapThing parent_ptr,
2180
+ HeapEntry*,
2181
+ HeapThing child_ptr,
2182
+ HeapEntry*) {
2183
+ entries_->CountReference(parent_ptr, child_ptr);
2184
+ }
2185
+ private:
2186
+ HeapEntriesAllocator* allocator_;
2187
+ HeapEntriesMap* entries_;
2188
+ };
2189
+
2190
+
2191
+ class SnapshotFiller : public SnapshotFillerInterface {
2192
+ public:
2193
+ explicit SnapshotFiller(HeapSnapshot* snapshot, HeapEntriesMap* entries)
2194
+ : snapshot_(snapshot),
2195
+ collection_(snapshot->collection()),
2196
+ entries_(entries) { }
2197
+ HeapEntry* AddEntry(HeapThing ptr) {
2198
+ UNREACHABLE();
2199
+ return NULL;
2200
+ }
2201
+ HeapEntry* FindOrAddEntry(HeapThing ptr) {
2202
+ HeapEntry* entry = entries_->Map(ptr);
2203
+ return entry != NULL ? entry : AddEntry(ptr);
2204
+ }
2205
+ void SetIndexedReference(HeapGraphEdge::Type type,
2206
+ HeapThing parent_ptr,
2207
+ HeapEntry* parent_entry,
2208
+ int index,
2209
+ HeapThing child_ptr,
2210
+ HeapEntry* child_entry) {
2211
+ int child_index, retainer_index;
2212
+ entries_->CountReference(
2213
+ parent_ptr, child_ptr, &child_index, &retainer_index);
2214
+ parent_entry->SetIndexedReference(
2215
+ type, child_index, index, child_entry, retainer_index);
2216
+ }
2217
+ void SetIndexedAutoIndexReference(HeapGraphEdge::Type type,
2218
+ HeapThing parent_ptr,
2219
+ HeapEntry* parent_entry,
2220
+ HeapThing child_ptr,
2221
+ HeapEntry* child_entry) {
2222
+ int child_index, retainer_index;
2223
+ entries_->CountReference(
2224
+ parent_ptr, child_ptr, &child_index, &retainer_index);
2225
+ parent_entry->SetIndexedReference(
2226
+ type, child_index, child_index + 1, child_entry, retainer_index);
2227
+ }
2228
+ void SetNamedReference(HeapGraphEdge::Type type,
2229
+ HeapThing parent_ptr,
2230
+ HeapEntry* parent_entry,
2231
+ const char* reference_name,
2232
+ HeapThing child_ptr,
2233
+ HeapEntry* child_entry) {
2234
+ int child_index, retainer_index;
2235
+ entries_->CountReference(
2236
+ parent_ptr, child_ptr, &child_index, &retainer_index);
2237
+ parent_entry->SetNamedReference(
2238
+ type, child_index, reference_name, child_entry, retainer_index);
2239
+ }
2240
+ void SetNamedAutoIndexReference(HeapGraphEdge::Type type,
2241
+ HeapThing parent_ptr,
2242
+ HeapEntry* parent_entry,
2243
+ HeapThing child_ptr,
2244
+ HeapEntry* child_entry) {
2245
+ int child_index, retainer_index;
2246
+ entries_->CountReference(
2247
+ parent_ptr, child_ptr, &child_index, &retainer_index);
2248
+ parent_entry->SetNamedReference(type,
2249
+ child_index,
2250
+ collection_->GetName(child_index + 1),
2251
+ child_entry,
2252
+ retainer_index);
2253
+ }
2254
+ private:
2255
+ HeapSnapshot* snapshot_;
2256
+ HeapSnapshotsCollection* collection_;
2257
+ HeapEntriesMap* entries_;
2258
+ };
2259
+
2260
+
2261
+ bool HeapSnapshotGenerator::GenerateSnapshot() {
2262
+ AssertNoAllocation no_alloc;
2263
+
2264
+ SetProgressTotal(4); // 2 passes + dominators + sizes.
2265
+
2266
+ // Pass 1. Iterate heap contents to count entries and references.
2267
+ if (!CountEntriesAndReferences()) return false;
2268
+
2269
+ // Allocate and fill entries in the snapshot, allocate references.
2270
+ snapshot_->AllocateEntries(entries_.entries_count(),
2271
+ entries_.total_children_count(),
2272
+ entries_.total_retainers_count());
2273
+ entries_.AllocateEntries();
2274
+
2275
+ // Pass 2. Fill references.
2276
+ if (!FillReferences()) return false;
2277
+
2278
+ if (!SetEntriesDominators()) return false;
2279
+ if (!ApproximateRetainedSizes()) return false;
2280
+
2281
+ progress_counter_ = progress_total_;
2282
+ if (!ProgressReport(true)) return false;
2283
+ return true;
2284
+ }
2285
+
2286
+
2287
+ void HeapSnapshotGenerator::ProgressStep() {
2288
+ ++progress_counter_;
2289
+ }
2290
+
2291
+
2292
+ bool HeapSnapshotGenerator::ProgressReport(bool force) {
2293
+ const int kProgressReportGranularity = 10000;
2294
+ if (control_ != NULL
2295
+ && (force || progress_counter_ % kProgressReportGranularity == 0)) {
2296
+ return
2297
+ control_->ReportProgressValue(progress_counter_, progress_total_) ==
2298
+ v8::ActivityControl::kContinue;
2299
+ }
2300
+ return true;
2301
+ }
2302
+
2303
+
2304
+ void HeapSnapshotGenerator::SetProgressTotal(int iterations_count) {
2305
+ if (control_ == NULL) return;
2306
+ progress_total_ = v8_heap_explorer_.EstimateObjectsCount() * iterations_count;
2307
+ progress_counter_ = 0;
2308
+ }
2309
+
2310
+
2311
+ bool HeapSnapshotGenerator::CountEntriesAndReferences() {
2312
+ SnapshotCounter counter(&v8_heap_explorer_, &entries_);
2313
+ v8_heap_explorer_.AddRootEntries(&counter);
2314
+ return v8_heap_explorer_.IterateAndExtractReferences(&counter);
2315
+ }
2316
+
2317
+
2318
+ bool HeapSnapshotGenerator::FillReferences() {
2319
+ SnapshotFiller filler(snapshot_, &entries_);
2320
+ return v8_heap_explorer_.IterateAndExtractReferences(&filler);
2321
+ }
2322
+
2323
+
2324
+ void HeapSnapshotGenerator::FillReversePostorderIndexes(
2325
+ Vector<HeapEntry*>* entries) {
2326
+ snapshot_->ClearPaint();
2327
+ int current_entry = 0;
2328
+ List<HeapEntry*> nodes_to_visit;
2329
+ nodes_to_visit.Add(snapshot_->root());
2330
+ snapshot_->root()->paint_reachable();
2331
+ while (!nodes_to_visit.is_empty()) {
2332
+ HeapEntry* entry = nodes_to_visit.last();
2333
+ Vector<HeapGraphEdge> children = entry->children();
2334
+ bool has_new_edges = false;
2335
+ for (int i = 0; i < children.length(); ++i) {
2336
+ if (children[i].type() == HeapGraphEdge::kShortcut) continue;
2337
+ HeapEntry* child = children[i].to();
2338
+ if (!child->painted_reachable()) {
2339
+ nodes_to_visit.Add(child);
2340
+ child->paint_reachable();
2341
+ has_new_edges = true;
2342
+ }
2343
+ }
2344
+ if (!has_new_edges) {
2345
+ entry->set_ordered_index(current_entry);
2346
+ (*entries)[current_entry++] = entry;
2347
+ nodes_to_visit.RemoveLast();
2348
+ }
2349
+ }
2350
+ entries->Truncate(current_entry);
2351
+ }
2352
+
2353
+
2354
+ static int Intersect(int i1, int i2, const Vector<HeapEntry*>& dominators) {
2355
+ int finger1 = i1, finger2 = i2;
2356
+ while (finger1 != finger2) {
2357
+ while (finger1 < finger2) finger1 = dominators[finger1]->ordered_index();
2358
+ while (finger2 < finger1) finger2 = dominators[finger2]->ordered_index();
2359
+ }
2360
+ return finger1;
2361
+ }
2362
+
2363
+ // The algorithm is based on the article:
2364
+ // K. Cooper, T. Harvey and K. Kennedy "A Simple, Fast Dominance Algorithm"
2365
+ // Softw. Pract. Exper. 4 (2001), pp. 1-10.
2366
+ bool HeapSnapshotGenerator::BuildDominatorTree(
2367
+ const Vector<HeapEntry*>& entries,
2368
+ Vector<HeapEntry*>* dominators) {
2369
+ if (entries.length() == 0) return true;
2370
+ const int entries_length = entries.length(), root_index = entries_length - 1;
2371
+ for (int i = 0; i < root_index; ++i) (*dominators)[i] = NULL;
2372
+ (*dominators)[root_index] = entries[root_index];
2373
+ int changed = 1;
2374
+ const int base_progress_counter = progress_counter_;
2375
+ while (changed != 0) {
2376
+ changed = 0;
2377
+ for (int i = root_index - 1; i >= 0; --i) {
2378
+ HeapEntry* new_idom = NULL;
2379
+ Vector<HeapGraphEdge*> rets = entries[i]->retainers();
2380
+ int j = 0;
2381
+ for (; j < rets.length(); ++j) {
2382
+ if (rets[j]->type() == HeapGraphEdge::kShortcut) continue;
2383
+ HeapEntry* ret = rets[j]->From();
2384
+ if (dominators->at(ret->ordered_index()) != NULL) {
2385
+ new_idom = ret;
2386
+ break;
2387
+ }
2388
+ }
2389
+ for (++j; j < rets.length(); ++j) {
2390
+ if (rets[j]->type() == HeapGraphEdge::kShortcut) continue;
2391
+ HeapEntry* ret = rets[j]->From();
2392
+ if (dominators->at(ret->ordered_index()) != NULL) {
2393
+ new_idom = entries[Intersect(ret->ordered_index(),
2394
+ new_idom->ordered_index(),
2395
+ *dominators)];
2396
+ }
2397
+ }
2398
+ if (new_idom != NULL && dominators->at(i) != new_idom) {
2399
+ (*dominators)[i] = new_idom;
2400
+ ++changed;
2401
+ }
2402
+ }
2403
+ int remaining = entries_length - changed;
2404
+ if (remaining < 0) remaining = 0;
2405
+ progress_counter_ = base_progress_counter + remaining;
2406
+ if (!ProgressReport(true)) return false;
2407
+ }
2408
+ return true;
2409
+ }
2410
+
2411
+
2412
+ bool HeapSnapshotGenerator::SetEntriesDominators() {
2413
+ // This array is used for maintaining reverse postorder of nodes.
2414
+ ScopedVector<HeapEntry*> ordered_entries(snapshot_->entries()->length());
2415
+ FillReversePostorderIndexes(&ordered_entries);
2416
+ ScopedVector<HeapEntry*> dominators(ordered_entries.length());
2417
+ if (!BuildDominatorTree(ordered_entries, &dominators)) return false;
2418
+ for (int i = 0; i < ordered_entries.length(); ++i) {
2419
+ ASSERT(dominators[i] != NULL);
2420
+ ordered_entries[i]->set_dominator(dominators[i]);
2421
+ }
2422
+ return true;
2423
+ }
2424
+
2425
+
2426
+ bool HeapSnapshotGenerator::ApproximateRetainedSizes() {
2427
+ // As for the dominators tree we only know parent nodes, not
2428
+ // children, to sum up total sizes we "bubble" node's self size
2429
+ // adding it to all of its parents.
2430
+ for (int i = 0; i < snapshot_->entries()->length(); ++i) {
2431
+ HeapEntry* entry = snapshot_->entries()->at(i);
2432
+ entry->set_retained_size(entry->self_size());
2433
+ }
2434
+ for (int i = 0;
2435
+ i < snapshot_->entries()->length();
2436
+ ++i, ProgressStep()) {
2437
+ HeapEntry* entry = snapshot_->entries()->at(i);
2438
+ int entry_size = entry->self_size();
2439
+ for (HeapEntry* dominator = entry->dominator();
2440
+ dominator != entry;
2441
+ entry = dominator, dominator = entry->dominator()) {
2442
+ dominator->add_retained_size(entry_size);
2443
+ }
2444
+ if (!ProgressReport()) return false;
2445
+ }
2446
+ return true;
2447
+ }
2448
+
2449
+
2450
+ void HeapSnapshotsDiff::CreateRoots(int additions_count, int deletions_count) {
2451
+ raw_additions_root_ =
2452
+ NewArray<char>(HeapEntry::EntriesSize(1, additions_count, 0));
2453
+ additions_root()->Init(
2454
+ snapshot2_, HeapEntry::kHidden, "", 0, 0, additions_count, 0);
2455
+ raw_deletions_root_ =
2456
+ NewArray<char>(HeapEntry::EntriesSize(1, deletions_count, 0));
2457
+ deletions_root()->Init(
2458
+ snapshot1_, HeapEntry::kHidden, "", 0, 0, deletions_count, 0);
2459
+ }
2460
+
2461
+
2462
+ static void DeleteHeapSnapshotsDiff(HeapSnapshotsDiff** diff_ptr) {
2463
+ delete *diff_ptr;
2464
+ }
2465
+
2466
+ HeapSnapshotsComparator::~HeapSnapshotsComparator() {
2467
+ diffs_.Iterate(DeleteHeapSnapshotsDiff);
2468
+ }
2469
+
2470
+
2471
+ HeapSnapshotsDiff* HeapSnapshotsComparator::Compare(HeapSnapshot* snapshot1,
2472
+ HeapSnapshot* snapshot2) {
2473
+ snapshot1->ClearPaint();
2474
+ snapshot1->root()->PaintAllReachable();
2475
+ snapshot2->ClearPaint();
2476
+ snapshot2->root()->PaintAllReachable();
2477
+
2478
+ List<HeapEntry*>* entries1 = snapshot1->GetSortedEntriesList();
2479
+ List<HeapEntry*>* entries2 = snapshot2->GetSortedEntriesList();
2480
+ int i = 0, j = 0;
2481
+ List<HeapEntry*> added_entries, deleted_entries;
2482
+ while (i < entries1->length() && j < entries2->length()) {
2483
+ uint64_t id1 = entries1->at(i)->id();
2484
+ uint64_t id2 = entries2->at(j)->id();
2485
+ if (id1 == id2) {
2486
+ HeapEntry* entry1 = entries1->at(i++);
2487
+ HeapEntry* entry2 = entries2->at(j++);
2488
+ if (entry1->painted_reachable() != entry2->painted_reachable()) {
2489
+ if (entry1->painted_reachable())
2490
+ deleted_entries.Add(entry1);
2491
+ else
2492
+ added_entries.Add(entry2);
2493
+ }
2494
+ } else if (id1 < id2) {
2495
+ HeapEntry* entry = entries1->at(i++);
2496
+ deleted_entries.Add(entry);
2497
+ } else {
2498
+ HeapEntry* entry = entries2->at(j++);
2499
+ added_entries.Add(entry);
2500
+ }
2501
+ }
2502
+ while (i < entries1->length()) {
2503
+ HeapEntry* entry = entries1->at(i++);
2504
+ deleted_entries.Add(entry);
2505
+ }
2506
+ while (j < entries2->length()) {
2507
+ HeapEntry* entry = entries2->at(j++);
2508
+ added_entries.Add(entry);
2509
+ }
2510
+
2511
+ HeapSnapshotsDiff* diff = new HeapSnapshotsDiff(snapshot1, snapshot2);
2512
+ diffs_.Add(diff);
2513
+ diff->CreateRoots(added_entries.length(), deleted_entries.length());
2514
+
2515
+ for (int i = 0; i < deleted_entries.length(); ++i) {
2516
+ HeapEntry* entry = deleted_entries[i];
2517
+ diff->AddDeletedEntry(i, i + 1, entry);
2518
+ }
2519
+ for (int i = 0; i < added_entries.length(); ++i) {
2520
+ HeapEntry* entry = added_entries[i];
2521
+ diff->AddAddedEntry(i, i + 1, entry);
2522
+ }
2523
+ return diff;
2524
+ }
2525
+
2526
+
2527
+ class OutputStreamWriter {
2528
+ public:
2529
+ explicit OutputStreamWriter(v8::OutputStream* stream)
2530
+ : stream_(stream),
2531
+ chunk_size_(stream->GetChunkSize()),
2532
+ chunk_(chunk_size_),
2533
+ chunk_pos_(0),
2534
+ aborted_(false) {
2535
+ ASSERT(chunk_size_ > 0);
2536
+ }
2537
+ bool aborted() { return aborted_; }
2538
+ void AddCharacter(char c) {
2539
+ ASSERT(c != '\0');
2540
+ ASSERT(chunk_pos_ < chunk_size_);
2541
+ chunk_[chunk_pos_++] = c;
2542
+ MaybeWriteChunk();
2543
+ }
2544
+ void AddString(const char* s) {
2545
+ AddSubstring(s, StrLength(s));
2546
+ }
2547
+ void AddSubstring(const char* s, int n) {
2548
+ if (n <= 0) return;
2549
+ ASSERT(static_cast<size_t>(n) <= strlen(s));
2550
+ const char* s_end = s + n;
2551
+ while (s < s_end) {
2552
+ int s_chunk_size = Min(
2553
+ chunk_size_ - chunk_pos_, static_cast<int>(s_end - s));
2554
+ ASSERT(s_chunk_size > 0);
2555
+ memcpy(chunk_.start() + chunk_pos_, s, s_chunk_size);
2556
+ s += s_chunk_size;
2557
+ chunk_pos_ += s_chunk_size;
2558
+ MaybeWriteChunk();
2559
+ }
2560
+ }
2561
+ void AddNumber(int n) { AddNumberImpl<int>(n, "%d"); }
2562
+ void AddNumber(unsigned n) { AddNumberImpl<unsigned>(n, "%u"); }
2563
+ void AddNumber(uint64_t n) { AddNumberImpl<uint64_t>(n, "%llu"); }
2564
+ void Finalize() {
2565
+ if (aborted_) return;
2566
+ ASSERT(chunk_pos_ < chunk_size_);
2567
+ if (chunk_pos_ != 0) {
2568
+ WriteChunk();
2569
+ }
2570
+ stream_->EndOfStream();
2571
+ }
2572
+
2573
+ private:
2574
+ template<typename T>
2575
+ void AddNumberImpl(T n, const char* format) {
2576
+ ScopedVector<char> buffer(32);
2577
+ int result = OS::SNPrintF(buffer, format, n);
2578
+ USE(result);
2579
+ ASSERT(result != -1);
2580
+ AddString(buffer.start());
2581
+ }
2582
+ void MaybeWriteChunk() {
2583
+ ASSERT(chunk_pos_ <= chunk_size_);
2584
+ if (chunk_pos_ == chunk_size_) {
2585
+ WriteChunk();
2586
+ chunk_pos_ = 0;
2587
+ }
2588
+ }
2589
+ void WriteChunk() {
2590
+ if (aborted_) return;
2591
+ if (stream_->WriteAsciiChunk(chunk_.start(), chunk_pos_) ==
2592
+ v8::OutputStream::kAbort) aborted_ = true;
2593
+ }
2594
+
2595
+ v8::OutputStream* stream_;
2596
+ int chunk_size_;
2597
+ ScopedVector<char> chunk_;
2598
+ int chunk_pos_;
2599
+ bool aborted_;
2600
+ };
2601
+
2602
+ void HeapSnapshotJSONSerializer::Serialize(v8::OutputStream* stream) {
2603
+ ASSERT(writer_ == NULL);
2604
+ writer_ = new OutputStreamWriter(stream);
2605
+
2606
+ // Since nodes graph is cyclic, we need the first pass to enumerate
2607
+ // them. Strings can be serialized in one pass.
2608
+ EnumerateNodes();
2609
+ SerializeImpl();
2610
+
2611
+ delete writer_;
2612
+ writer_ = NULL;
2613
+ }
2614
+
2615
+
2616
+ void HeapSnapshotJSONSerializer::SerializeImpl() {
2617
+ writer_->AddCharacter('{');
2618
+ writer_->AddString("\"snapshot\":{");
2619
+ SerializeSnapshot();
2620
+ if (writer_->aborted()) return;
2621
+ writer_->AddString("},\n");
2622
+ writer_->AddString("\"nodes\":[");
2623
+ SerializeNodes();
2624
+ if (writer_->aborted()) return;
2625
+ writer_->AddString("],\n");
2626
+ writer_->AddString("\"strings\":[");
2627
+ SerializeStrings();
2628
+ if (writer_->aborted()) return;
2629
+ writer_->AddCharacter(']');
2630
+ writer_->AddCharacter('}');
2631
+ writer_->Finalize();
2632
+ }
2633
+
2634
+
2635
+ class HeapSnapshotJSONSerializerEnumerator {
2636
+ public:
2637
+ explicit HeapSnapshotJSONSerializerEnumerator(HeapSnapshotJSONSerializer* s)
2638
+ : s_(s) {
2639
+ }
2640
+ void Apply(HeapEntry** entry) {
2641
+ s_->GetNodeId(*entry);
2642
+ }
2643
+ private:
2644
+ HeapSnapshotJSONSerializer* s_;
2645
+ };
2646
+
2647
+ void HeapSnapshotJSONSerializer::EnumerateNodes() {
2648
+ GetNodeId(snapshot_->root()); // Make sure root gets the first id.
2649
+ HeapSnapshotJSONSerializerEnumerator iter(this);
2650
+ snapshot_->IterateEntries(&iter);
2651
+ }
2652
+
2653
+
2654
+ int HeapSnapshotJSONSerializer::GetNodeId(HeapEntry* entry) {
2655
+ HashMap::Entry* cache_entry = nodes_.Lookup(entry, ObjectHash(entry), true);
2656
+ if (cache_entry->value == NULL) {
2657
+ cache_entry->value = reinterpret_cast<void*>(next_node_id_++);
2658
+ }
2659
+ return static_cast<int>(reinterpret_cast<intptr_t>(cache_entry->value));
2660
+ }
2661
+
2662
+
2663
+ int HeapSnapshotJSONSerializer::GetStringId(const char* s) {
2664
+ HashMap::Entry* cache_entry = strings_.Lookup(
2665
+ const_cast<char*>(s), ObjectHash(s), true);
2666
+ if (cache_entry->value == NULL) {
2667
+ cache_entry->value = reinterpret_cast<void*>(next_string_id_++);
2668
+ }
2669
+ return static_cast<int>(reinterpret_cast<intptr_t>(cache_entry->value));
2670
+ }
2671
+
2672
+
2673
+ void HeapSnapshotJSONSerializer::SerializeEdge(HeapGraphEdge* edge) {
2674
+ writer_->AddCharacter(',');
2675
+ writer_->AddNumber(edge->type());
2676
+ writer_->AddCharacter(',');
2677
+ if (edge->type() == HeapGraphEdge::kElement
2678
+ || edge->type() == HeapGraphEdge::kHidden) {
2679
+ writer_->AddNumber(edge->index());
2680
+ } else {
2681
+ writer_->AddNumber(GetStringId(edge->name()));
2682
+ }
2683
+ writer_->AddCharacter(',');
2684
+ writer_->AddNumber(GetNodeId(edge->to()));
2685
+ }
2686
+
2687
+
2688
+ void HeapSnapshotJSONSerializer::SerializeNode(HeapEntry* entry) {
2689
+ writer_->AddCharacter('\n');
2690
+ writer_->AddCharacter(',');
2691
+ writer_->AddNumber(entry->type());
2692
+ writer_->AddCharacter(',');
2693
+ writer_->AddNumber(GetStringId(entry->name()));
2694
+ writer_->AddCharacter(',');
2695
+ writer_->AddNumber(entry->id());
2696
+ writer_->AddCharacter(',');
2697
+ writer_->AddNumber(entry->self_size());
2698
+ writer_->AddCharacter(',');
2699
+ writer_->AddNumber(entry->RetainedSize(false));
2700
+ writer_->AddCharacter(',');
2701
+ writer_->AddNumber(GetNodeId(entry->dominator()));
2702
+ Vector<HeapGraphEdge> children = entry->children();
2703
+ writer_->AddCharacter(',');
2704
+ writer_->AddNumber(children.length());
2705
+ for (int i = 0; i < children.length(); ++i) {
2706
+ SerializeEdge(&children[i]);
2707
+ if (writer_->aborted()) return;
2708
+ }
2709
+ }
2710
+
2711
+
2712
+ void HeapSnapshotJSONSerializer::SerializeNodes() {
2713
+ // The first (zero) item of nodes array is an object describing node
2714
+ // serialization layout. We use a set of macros to improve
2715
+ // readability.
2716
+ #define JSON_A(s) "["s"]"
2717
+ #define JSON_O(s) "{"s"}"
2718
+ #define JSON_S(s) "\""s"\""
2719
+ writer_->AddString(JSON_O(
2720
+ JSON_S("fields") ":" JSON_A(
2721
+ JSON_S("type")
2722
+ "," JSON_S("name")
2723
+ "," JSON_S("id")
2724
+ "," JSON_S("self_size")
2725
+ "," JSON_S("retained_size")
2726
+ "," JSON_S("dominator")
2727
+ "," JSON_S("children_count")
2728
+ "," JSON_S("children"))
2729
+ "," JSON_S("types") ":" JSON_A(
2730
+ JSON_A(
2731
+ JSON_S("hidden")
2732
+ "," JSON_S("array")
2733
+ "," JSON_S("string")
2734
+ "," JSON_S("object")
2735
+ "," JSON_S("code")
2736
+ "," JSON_S("closure")
2737
+ "," JSON_S("regexp")
2738
+ "," JSON_S("number"))
2739
+ "," JSON_S("string")
2740
+ "," JSON_S("number")
2741
+ "," JSON_S("number")
2742
+ "," JSON_S("number")
2743
+ "," JSON_S("number")
2744
+ "," JSON_S("number")
2745
+ "," JSON_O(
2746
+ JSON_S("fields") ":" JSON_A(
2747
+ JSON_S("type")
2748
+ "," JSON_S("name_or_index")
2749
+ "," JSON_S("to_node"))
2750
+ "," JSON_S("types") ":" JSON_A(
2751
+ JSON_A(
2752
+ JSON_S("context")
2753
+ "," JSON_S("element")
2754
+ "," JSON_S("property")
2755
+ "," JSON_S("internal")
2756
+ "," JSON_S("hidden")
2757
+ "," JSON_S("shortcut"))
2758
+ "," JSON_S("string_or_number")
2759
+ "," JSON_S("node"))))));
2760
+ #undef JSON_S
2761
+ #undef JSON_O
2762
+ #undef JSON_A
2763
+
2764
+ const int node_fields_count = 7;
2765
+ // type,name,id,self_size,retained_size,dominator,children_count.
2766
+ const int edge_fields_count = 3; // type,name|index,to_node.
2767
+ List<HashMap::Entry*> sorted_nodes;
2768
+ SortHashMap(&nodes_, &sorted_nodes);
2769
+ // Rewrite node ids, so they refer to actual array positions.
2770
+ if (sorted_nodes.length() > 1) {
2771
+ // Nodes start from array index 1.
2772
+ int prev_value = 1;
2773
+ sorted_nodes[0]->value = reinterpret_cast<void*>(prev_value);
2774
+ for (int i = 1; i < sorted_nodes.length(); ++i) {
2775
+ HeapEntry* prev_heap_entry =
2776
+ reinterpret_cast<HeapEntry*>(sorted_nodes[i-1]->key);
2777
+ prev_value += node_fields_count +
2778
+ prev_heap_entry->children().length() * edge_fields_count;
2779
+ sorted_nodes[i]->value = reinterpret_cast<void*>(prev_value);
2780
+ }
2781
+ }
2782
+ for (int i = 0; i < sorted_nodes.length(); ++i) {
2783
+ SerializeNode(reinterpret_cast<HeapEntry*>(sorted_nodes[i]->key));
2784
+ if (writer_->aborted()) return;
2785
+ }
2786
+ }
2787
+
2788
+
2789
+ void HeapSnapshotJSONSerializer::SerializeSnapshot() {
2790
+ writer_->AddString("\"title\":\"");
2791
+ writer_->AddString(snapshot_->title());
2792
+ writer_->AddString("\"");
2793
+ writer_->AddString(",\"uid\":");
2794
+ writer_->AddNumber(snapshot_->uid());
2795
+ }
2796
+
2797
+
2798
+ static void WriteUChar(OutputStreamWriter* w, unibrow::uchar u) {
2799
+ static const char hex_chars[] = "0123456789ABCDEF";
2800
+ w->AddString("\\u");
2801
+ w->AddCharacter(hex_chars[(u >> 12) & 0xf]);
2802
+ w->AddCharacter(hex_chars[(u >> 8) & 0xf]);
2803
+ w->AddCharacter(hex_chars[(u >> 4) & 0xf]);
2804
+ w->AddCharacter(hex_chars[u & 0xf]);
2805
+ }
2806
+
2807
+ void HeapSnapshotJSONSerializer::SerializeString(const unsigned char* s) {
2808
+ writer_->AddCharacter('\n');
2809
+ writer_->AddCharacter('\"');
2810
+ for ( ; *s != '\0'; ++s) {
2811
+ switch (*s) {
2812
+ case '\b':
2813
+ writer_->AddString("\\b");
2814
+ continue;
2815
+ case '\f':
2816
+ writer_->AddString("\\f");
2817
+ continue;
2818
+ case '\n':
2819
+ writer_->AddString("\\n");
2820
+ continue;
2821
+ case '\r':
2822
+ writer_->AddString("\\r");
2823
+ continue;
2824
+ case '\t':
2825
+ writer_->AddString("\\t");
2826
+ continue;
2827
+ case '\"':
2828
+ case '\\':
2829
+ writer_->AddCharacter('\\');
2830
+ writer_->AddCharacter(*s);
2831
+ continue;
2832
+ default:
2833
+ if (*s > 31 && *s < 128) {
2834
+ writer_->AddCharacter(*s);
2835
+ } else if (*s <= 31) {
2836
+ // Special character with no dedicated literal.
2837
+ WriteUChar(writer_, *s);
2838
+ } else {
2839
+ // Convert UTF-8 into \u UTF-16 literal.
2840
+ unsigned length = 1, cursor = 0;
2841
+ for ( ; length <= 4 && *(s + length) != '\0'; ++length) { }
2842
+ unibrow::uchar c = unibrow::Utf8::CalculateValue(s, length, &cursor);
2843
+ if (c != unibrow::Utf8::kBadChar) {
2844
+ WriteUChar(writer_, c);
2845
+ ASSERT(cursor != 0);
2846
+ s += cursor - 1;
2847
+ } else {
2848
+ writer_->AddCharacter('?');
2849
+ }
2850
+ }
2851
+ }
2852
+ }
2853
+ writer_->AddCharacter('\"');
2854
+ }
2855
+
2856
+
2857
+ void HeapSnapshotJSONSerializer::SerializeStrings() {
2858
+ List<HashMap::Entry*> sorted_strings;
2859
+ SortHashMap(&strings_, &sorted_strings);
2860
+ writer_->AddString("\"<dummy>\"");
2861
+ for (int i = 0; i < sorted_strings.length(); ++i) {
2862
+ writer_->AddCharacter(',');
2863
+ SerializeString(
2864
+ reinterpret_cast<const unsigned char*>(sorted_strings[i]->key));
2865
+ if (writer_->aborted()) return;
2866
+ }
2867
+ }
2868
+
2869
+
2870
+ template<typename T>
2871
+ inline static int SortUsingEntryValue(const T* x, const T* y) {
2872
+ uintptr_t x_uint = reinterpret_cast<uintptr_t>((*x)->value);
2873
+ uintptr_t y_uint = reinterpret_cast<uintptr_t>((*y)->value);
2874
+ if (x_uint > y_uint) {
2875
+ return 1;
2876
+ } else if (x_uint == y_uint) {
2877
+ return 0;
2878
+ } else {
2879
+ return -1;
2880
+ }
2881
+ }
2882
+
2883
+
2884
+ void HeapSnapshotJSONSerializer::SortHashMap(
2885
+ HashMap* map, List<HashMap::Entry*>* sorted_entries) {
2886
+ for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p))
2887
+ sorted_entries->Add(p);
2888
+ sorted_entries->Sort(SortUsingEntryValue);
2889
+ }
2890
+
2891
+
2892
+ String* GetConstructorNameForHeapProfile(JSObject* object) {
2893
+ if (object->IsJSFunction()) return Heap::closure_symbol();
2894
+ return object->constructor_name();
2895
+ }
2896
+
2897
+ } } // namespace v8::internal
2898
+
2899
+ #endif // ENABLE_LOGGING_AND_PROFILING