therubyracer 0.7.4 → 0.7.5

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 (482) hide show
  1. data/History.txt +11 -0
  2. data/Rakefile +1 -1
  3. data/ext/v8/extconf.rb +0 -18
  4. data/ext/v8/rr.cpp +2 -2
  5. data/ext/v8/upstream/{2.1.10 → 2.3.3}/AUTHORS +1 -0
  6. data/ext/v8/upstream/{2.1.10 → 2.3.3}/ChangeLog +239 -0
  7. data/ext/v8/upstream/{2.1.10 → 2.3.3}/LICENSE +0 -0
  8. data/ext/v8/upstream/{2.1.10 → 2.3.3}/SConstruct +29 -17
  9. data/ext/v8/upstream/{2.1.10 → 2.3.3}/include/v8-debug.h +61 -3
  10. data/ext/v8/upstream/{2.1.10 → 2.3.3}/include/v8-profiler.h +182 -5
  11. data/ext/v8/upstream/{2.1.10 → 2.3.3}/include/v8.h +458 -257
  12. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/SConscript +2 -5
  13. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/accessors.cc +2 -2
  14. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/accessors.h +0 -0
  15. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/allocation.cc +0 -0
  16. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/allocation.h +0 -0
  17. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/api.cc +574 -30
  18. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/api.h +12 -10
  19. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/apinatives.js +0 -0
  20. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/apiutils.h +0 -0
  21. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/arguments.h +0 -0
  22. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/arm/assembler-arm-inl.h +38 -15
  23. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/arm/assembler-arm.cc +646 -101
  24. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/arm/assembler-arm.h +174 -15
  25. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/arm/builtins-arm.cc +56 -47
  26. data/ext/v8/upstream/2.3.3/src/arm/codegen-arm-inl.h +48 -0
  27. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/arm/codegen-arm.cc +2957 -1448
  28. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/arm/codegen-arm.h +230 -74
  29. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/arm/constants-arm.cc +25 -1
  30. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/arm/constants-arm.h +16 -1
  31. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/arm/cpu-arm.cc +4 -0
  32. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/arm/debug-arm.cc +76 -6
  33. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/arm/disasm-arm.cc +168 -20
  34. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/arm/fast-codegen-arm.cc +5 -2
  35. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/arm/frames-arm.cc +4 -4
  36. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/arm/frames-arm.h +0 -0
  37. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/arm/full-codegen-arm.cc +1558 -248
  38. data/ext/v8/upstream/2.3.3/src/arm/ic-arm.cc +2258 -0
  39. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/arm/jump-target-arm.cc +55 -103
  40. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/arm/macro-assembler-arm.cc +358 -185
  41. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/arm/macro-assembler-arm.h +136 -41
  42. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/arm/regexp-macro-assembler-arm.cc +26 -5
  43. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/arm/regexp-macro-assembler-arm.h +0 -0
  44. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/arm/register-allocator-arm-inl.h +0 -0
  45. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/arm/register-allocator-arm.cc +4 -0
  46. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/arm/register-allocator-arm.h +0 -0
  47. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/arm/simulator-arm.cc +203 -22
  48. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/arm/simulator-arm.h +7 -0
  49. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/arm/stub-cache-arm.cc +531 -324
  50. data/ext/v8/upstream/2.3.3/src/arm/virtual-frame-arm-inl.h +59 -0
  51. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/arm/virtual-frame-arm.cc +247 -81
  52. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/arm/virtual-frame-arm.h +99 -83
  53. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/array.js +2 -2
  54. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/assembler.cc +6 -13
  55. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/assembler.h +36 -10
  56. data/ext/v8/upstream/2.3.3/src/ast-inl.h +81 -0
  57. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ast.cc +14 -0
  58. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ast.h +20 -35
  59. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/bootstrapper.cc +32 -1
  60. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/bootstrapper.h +0 -4
  61. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/builtins.cc +50 -33
  62. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/builtins.h +2 -0
  63. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/bytecodes-irregexp.h +0 -0
  64. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/cached-powers.h +0 -0
  65. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/char-predicates-inl.h +0 -0
  66. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/char-predicates.h +0 -0
  67. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/checks.cc +0 -0
  68. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/checks.h +8 -6
  69. data/ext/v8/upstream/2.3.3/src/circular-queue-inl.h +53 -0
  70. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/circular-queue.cc +0 -0
  71. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/circular-queue.h +0 -26
  72. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/code-stubs.cc +2 -4
  73. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/code-stubs.h +1 -0
  74. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/code.h +0 -0
  75. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/codegen-inl.h +0 -0
  76. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/codegen.cc +44 -13
  77. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/codegen.h +310 -31
  78. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/compilation-cache.cc +28 -0
  79. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/compilation-cache.h +3 -0
  80. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/compiler.cc +45 -14
  81. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/compiler.h +0 -0
  82. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/contexts.cc +11 -11
  83. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/contexts.h +0 -0
  84. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/conversions-inl.h +0 -0
  85. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/conversions.cc +25 -11
  86. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/conversions.h +0 -0
  87. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/counters.cc +0 -0
  88. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/counters.h +0 -0
  89. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/cpu-profiler-inl.h +2 -1
  90. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/cpu-profiler.cc +68 -24
  91. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/cpu-profiler.h +19 -11
  92. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/cpu.h +0 -0
  93. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/d8-debug.cc +0 -0
  94. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/d8-debug.h +0 -0
  95. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/d8-posix.cc +0 -0
  96. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/d8-readline.cc +0 -0
  97. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/d8-windows.cc +0 -0
  98. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/d8.cc +3 -0
  99. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/d8.h +0 -0
  100. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/d8.js +55 -2
  101. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/data-flow.cc +3 -0
  102. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/data-flow.h +0 -0
  103. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/date.js +68 -137
  104. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/dateparser-inl.h +0 -0
  105. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/dateparser.cc +2 -8
  106. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/dateparser.h +0 -0
  107. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/debug-agent.cc +3 -3
  108. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/debug-agent.h +0 -0
  109. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/debug-debugger.js +81 -23
  110. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/debug.cc +275 -81
  111. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/debug.h +85 -6
  112. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/disasm.h +0 -0
  113. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/disassembler.cc +1 -1
  114. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/disassembler.h +0 -0
  115. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/diy-fp.cc +0 -0
  116. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/diy-fp.h +0 -0
  117. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/double.h +0 -0
  118. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/dtoa-config.c +0 -0
  119. data/ext/v8/upstream/2.3.3/src/dtoa.cc +77 -0
  120. data/ext/v8/upstream/2.3.3/src/dtoa.h +81 -0
  121. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/execution.cc +111 -3
  122. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/execution.h +12 -1
  123. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/factory.cc +25 -3
  124. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/factory.h +16 -9
  125. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/fast-codegen.cc +0 -0
  126. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/fast-codegen.h +0 -0
  127. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/fast-dtoa.cc +2 -9
  128. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/fast-dtoa.h +1 -2
  129. data/ext/v8/upstream/2.3.3/src/fixed-dtoa.cc +405 -0
  130. data/ext/v8/upstream/{2.1.10/src/jump-target-light.cc → 2.3.3/src/fixed-dtoa.h} +22 -53
  131. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/flag-definitions.h +14 -6
  132. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/flags.cc +5 -9
  133. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/flags.h +0 -0
  134. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/flow-graph.cc +0 -0
  135. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/flow-graph.h +0 -0
  136. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/frame-element.cc +0 -0
  137. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/frame-element.h +0 -0
  138. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/frames-inl.h +0 -0
  139. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/frames.cc +5 -2
  140. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/frames.h +1 -0
  141. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/full-codegen.cc +387 -20
  142. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/full-codegen.h +102 -5
  143. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/func-name-inferrer.cc +0 -0
  144. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/func-name-inferrer.h +0 -0
  145. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/global-handles.cc +8 -4
  146. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/global-handles.h +0 -0
  147. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/globals.h +44 -7
  148. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/handles-inl.h +0 -0
  149. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/handles.cc +19 -0
  150. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/handles.h +8 -0
  151. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/hashmap.cc +0 -0
  152. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/hashmap.h +0 -0
  153. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/heap-inl.h +56 -14
  154. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/heap-profiler.cc +85 -1
  155. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/heap-profiler.h +45 -1
  156. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/heap.cc +994 -396
  157. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/heap.h +220 -65
  158. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ia32/assembler-ia32-inl.h +41 -12
  159. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ia32/assembler-ia32.cc +94 -24
  160. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ia32/assembler-ia32.h +32 -4
  161. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ia32/builtins-ia32.cc +42 -30
  162. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ia32/codegen-ia32-inl.h +0 -0
  163. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ia32/codegen-ia32.cc +1758 -916
  164. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ia32/codegen-ia32.h +67 -74
  165. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ia32/cpu-ia32.cc +4 -0
  166. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ia32/debug-ia32.cc +46 -0
  167. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ia32/disasm-ia32.cc +37 -6
  168. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ia32/fast-codegen-ia32.cc +4 -0
  169. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ia32/fast-codegen-ia32.h +0 -0
  170. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ia32/frames-ia32.cc +4 -0
  171. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ia32/frames-ia32.h +0 -0
  172. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ia32/full-codegen-ia32.cc +1465 -198
  173. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ia32/ic-ia32.cc +688 -367
  174. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ia32/jump-target-ia32.cc +4 -0
  175. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ia32/macro-assembler-ia32.cc +82 -180
  176. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ia32/macro-assembler-ia32.h +41 -25
  177. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ia32/regexp-macro-assembler-ia32.cc +68 -24
  178. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ia32/regexp-macro-assembler-ia32.h +1 -2
  179. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ia32/register-allocator-ia32-inl.h +0 -0
  180. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ia32/register-allocator-ia32.cc +4 -0
  181. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ia32/register-allocator-ia32.h +0 -0
  182. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ia32/simulator-ia32.cc +0 -0
  183. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ia32/simulator-ia32.h +0 -0
  184. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ia32/stub-cache-ia32.cc +649 -302
  185. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ia32/virtual-frame-ia32.cc +23 -1
  186. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ia32/virtual-frame-ia32.h +18 -27
  187. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ic-inl.h +30 -3
  188. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ic.cc +384 -66
  189. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/ic.h +65 -24
  190. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/interpreter-irregexp.cc +0 -0
  191. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/interpreter-irregexp.h +0 -0
  192. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/json.js +3 -3
  193. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/jsregexp.cc +20 -4
  194. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/jsregexp.h +0 -0
  195. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/jump-target-heavy-inl.h +0 -0
  196. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/jump-target-heavy.cc +79 -13
  197. data/ext/v8/upstream/{2.1.10/src/jump-target.h → 2.3.3/src/jump-target-heavy.h} +5 -47
  198. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/jump-target-inl.h +0 -0
  199. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/jump-target-light-inl.h +16 -2
  200. data/ext/v8/upstream/2.3.3/src/jump-target-light.cc +110 -0
  201. data/ext/v8/upstream/2.3.3/src/jump-target-light.h +192 -0
  202. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/jump-target.cc +0 -64
  203. data/ext/v8/upstream/2.3.3/src/jump-target.h +90 -0
  204. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/list-inl.h +0 -0
  205. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/list.h +0 -0
  206. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/liveedit-debugger.js +141 -28
  207. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/liveedit.cc +19 -7
  208. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/liveedit.h +0 -0
  209. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/log-inl.h +0 -0
  210. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/log-utils.cc +0 -0
  211. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/log-utils.h +0 -0
  212. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/log.cc +12 -11
  213. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/log.h +12 -0
  214. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/macro-assembler.h +0 -16
  215. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/macros.py +21 -0
  216. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mark-compact.cc +120 -109
  217. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mark-compact.h +25 -37
  218. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/math.js +0 -0
  219. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/memory.h +0 -0
  220. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/messages.cc +8 -3
  221. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/messages.h +2 -1
  222. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/messages.js +15 -7
  223. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mips/assembler-mips-inl.h +0 -0
  224. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mips/assembler-mips.cc +12 -1
  225. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mips/assembler-mips.h +4 -1
  226. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mips/builtins-mips.cc +3 -0
  227. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mips/codegen-mips-inl.h +0 -0
  228. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mips/codegen-mips.cc +9 -0
  229. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mips/codegen-mips.h +1 -0
  230. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mips/constants-mips.cc +5 -0
  231. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mips/constants-mips.h +0 -0
  232. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mips/cpu-mips.cc +4 -0
  233. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mips/debug-mips.cc +3 -0
  234. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mips/disasm-mips.cc +3 -0
  235. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mips/fast-codegen-mips.cc +3 -0
  236. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mips/frames-mips.cc +3 -0
  237. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mips/frames-mips.h +0 -0
  238. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mips/full-codegen-mips.cc +5 -1
  239. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mips/ic-mips.cc +3 -0
  240. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mips/jump-target-mips.cc +3 -0
  241. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mips/macro-assembler-mips.cc +3 -0
  242. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mips/macro-assembler-mips.h +0 -0
  243. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mips/register-allocator-mips-inl.h +0 -0
  244. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mips/register-allocator-mips.cc +3 -0
  245. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mips/register-allocator-mips.h +0 -0
  246. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mips/simulator-mips.cc +3 -0
  247. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mips/simulator-mips.h +0 -0
  248. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mips/stub-cache-mips.cc +3 -0
  249. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mips/virtual-frame-mips.cc +3 -0
  250. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mips/virtual-frame-mips.h +0 -0
  251. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mirror-debugger.js +46 -4
  252. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/mksnapshot.cc +0 -0
  253. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/natives.h +0 -0
  254. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/objects-debug.cc +8 -1
  255. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/objects-inl.h +235 -62
  256. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/objects.cc +497 -231
  257. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/objects.h +355 -149
  258. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/oprofile-agent.cc +0 -0
  259. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/oprofile-agent.h +0 -0
  260. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/parser.cc +31 -6
  261. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/parser.h +1 -1
  262. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/platform-freebsd.cc +9 -6
  263. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/platform-linux.cc +26 -6
  264. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/platform-macos.cc +11 -6
  265. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/platform-nullos.cc +0 -0
  266. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/platform-openbsd.cc +6 -0
  267. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/platform-posix.cc +0 -0
  268. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/platform-solaris.cc +69 -23
  269. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/platform-win32.cc +15 -11
  270. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/platform.h +10 -6
  271. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/powers-ten.h +0 -0
  272. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/prettyprinter.cc +0 -0
  273. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/prettyprinter.h +0 -0
  274. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/profile-generator-inl.h +26 -2
  275. data/ext/v8/upstream/2.3.3/src/profile-generator.cc +1830 -0
  276. data/ext/v8/upstream/2.3.3/src/profile-generator.h +853 -0
  277. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/property.cc +0 -0
  278. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/property.h +0 -0
  279. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/regexp-macro-assembler-irregexp-inl.h +0 -0
  280. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/regexp-macro-assembler-irregexp.cc +0 -0
  281. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/regexp-macro-assembler-irregexp.h +0 -0
  282. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/regexp-macro-assembler-tracer.cc +0 -0
  283. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/regexp-macro-assembler-tracer.h +0 -0
  284. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/regexp-macro-assembler.cc +1 -3
  285. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/regexp-macro-assembler.h +0 -0
  286. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/regexp-stack.cc +0 -0
  287. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/regexp-stack.h +0 -0
  288. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/regexp.js +25 -4
  289. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/register-allocator-inl.h +0 -0
  290. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/register-allocator.cc +4 -3
  291. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/register-allocator.h +0 -0
  292. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/rewriter.cc +85 -8
  293. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/rewriter.h +0 -0
  294. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/runtime.cc +547 -221
  295. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/runtime.h +5 -1
  296. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/runtime.js +23 -31
  297. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/scanner.cc +12 -6
  298. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/scanner.h +60 -53
  299. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/scopeinfo.cc +156 -168
  300. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/scopeinfo.h +58 -62
  301. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/scopes.cc +0 -0
  302. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/scopes.h +0 -0
  303. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/serialize.cc +320 -242
  304. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/serialize.h +81 -48
  305. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/shell.h +0 -0
  306. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/simulator.h +0 -0
  307. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/smart-pointer.h +0 -0
  308. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/snapshot-common.cc +0 -0
  309. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/snapshot-empty.cc +0 -0
  310. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/snapshot.h +0 -0
  311. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/spaces-inl.h +177 -74
  312. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/spaces.cc +138 -315
  313. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/spaces.h +155 -124
  314. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/splay-tree-inl.h +0 -0
  315. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/splay-tree.h +0 -0
  316. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/string-stream.cc +0 -0
  317. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/string-stream.h +0 -0
  318. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/string.js +113 -119
  319. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/stub-cache.cc +242 -97
  320. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/stub-cache.h +118 -55
  321. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/third_party/dtoa/COPYING +0 -0
  322. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/third_party/dtoa/dtoa.c +4 -0
  323. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/third_party/valgrind/valgrind.h +0 -0
  324. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/token.cc +0 -0
  325. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/token.h +0 -0
  326. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/top.cc +107 -26
  327. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/top.h +9 -4
  328. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/type-info.cc +0 -0
  329. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/type-info.h +2 -2
  330. data/ext/v8/upstream/2.3.3/src/unbound-queue-inl.h +95 -0
  331. data/ext/v8/upstream/2.3.3/src/unbound-queue.h +67 -0
  332. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/unicode-inl.h +0 -0
  333. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/unicode.cc +0 -0
  334. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/unicode.h +0 -0
  335. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/uri.js +0 -0
  336. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/utils.cc +0 -0
  337. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/utils.h +83 -1
  338. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/v8-counters.cc +0 -0
  339. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/v8-counters.h +20 -0
  340. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/v8.cc +5 -1
  341. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/v8.h +0 -0
  342. data/ext/v8/upstream/2.3.3/src/v8dll-main.cc +39 -0
  343. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/v8natives.js +210 -33
  344. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/v8threads.cc +1 -1
  345. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/v8threads.h +1 -1
  346. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/variables.cc +0 -0
  347. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/variables.h +0 -0
  348. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/version.cc +3 -3
  349. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/version.h +0 -0
  350. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/virtual-frame-heavy-inl.h +40 -0
  351. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/virtual-frame-heavy.cc +0 -0
  352. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/virtual-frame-inl.h +0 -0
  353. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/virtual-frame-light-inl.h +106 -5
  354. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/virtual-frame-light.cc +4 -1
  355. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/virtual-frame.cc +0 -0
  356. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/virtual-frame.h +0 -0
  357. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/vm-state-inl.h +6 -3
  358. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/vm-state.cc +1 -1
  359. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/vm-state.h +6 -4
  360. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/x64/assembler-x64-inl.h +42 -5
  361. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/x64/assembler-x64.cc +285 -53
  362. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/x64/assembler-x64.h +54 -18
  363. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/x64/builtins-x64.cc +31 -33
  364. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/x64/codegen-x64-inl.h +0 -0
  365. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/x64/codegen-x64.cc +9787 -8722
  366. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/x64/codegen-x64.h +82 -47
  367. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/x64/cpu-x64.cc +4 -0
  368. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/x64/debug-x64.cc +55 -6
  369. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/x64/disasm-x64.cc +42 -19
  370. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/x64/fast-codegen-x64.cc +4 -0
  371. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/x64/frames-x64.cc +4 -0
  372. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/x64/frames-x64.h +4 -0
  373. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/x64/full-codegen-x64.cc +1487 -210
  374. data/ext/v8/upstream/2.3.3/src/x64/ic-x64.cc +1907 -0
  375. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/x64/jump-target-x64.cc +4 -0
  376. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/x64/macro-assembler-x64.cc +366 -338
  377. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/x64/macro-assembler-x64.h +83 -38
  378. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/x64/regexp-macro-assembler-x64.cc +82 -23
  379. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/x64/regexp-macro-assembler-x64.h +1 -2
  380. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/x64/register-allocator-x64-inl.h +6 -5
  381. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/x64/register-allocator-x64.cc +4 -0
  382. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/x64/register-allocator-x64.h +1 -1
  383. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/x64/simulator-x64.cc +0 -0
  384. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/x64/simulator-x64.h +0 -0
  385. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/x64/stub-cache-x64.cc +556 -377
  386. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/x64/virtual-frame-x64.cc +197 -98
  387. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/x64/virtual-frame-x64.h +37 -28
  388. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/zone-inl.h +0 -0
  389. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/zone.cc +0 -0
  390. data/ext/v8/upstream/{2.1.10 → 2.3.3}/src/zone.h +0 -0
  391. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/codemap.js +0 -0
  392. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/consarray.js +0 -0
  393. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/csvparser.js +0 -0
  394. data/ext/v8/upstream/2.3.3/tools/gc-nvp-trace-processor.py +317 -0
  395. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/generate-ten-powers.scm +0 -0
  396. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/gyp/v8.gyp +87 -20
  397. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/js2c.py +19 -15
  398. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/jsmin.py +0 -0
  399. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/linux-tick-processor +0 -0
  400. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/linux-tick-processor.py +0 -0
  401. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/logreader.js +0 -0
  402. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/mac-nm +0 -0
  403. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/mac-tick-processor +0 -0
  404. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/oprofile/annotate +0 -0
  405. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/oprofile/common +0 -0
  406. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/oprofile/dump +0 -0
  407. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/oprofile/report +0 -0
  408. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/oprofile/reset +0 -0
  409. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/oprofile/run +0 -0
  410. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/oprofile/shutdown +0 -0
  411. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/oprofile/start +0 -0
  412. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/presubmit.py +0 -0
  413. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/process-heap-prof.py +0 -0
  414. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/profile.js +0 -0
  415. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/profile_view.js +0 -0
  416. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/run-valgrind.py +0 -0
  417. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/splaytree.js +0 -0
  418. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/splaytree.py +0 -0
  419. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/stats-viewer.py +25 -13
  420. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/test.py +0 -0
  421. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/tickprocessor-driver.js +0 -0
  422. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/tickprocessor.js +0 -0
  423. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/tickprocessor.py +0 -0
  424. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/utils.py +0 -0
  425. data/ext/v8/upstream/2.3.3/tools/v8.xcodeproj/project.pbxproj +1855 -0
  426. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/README.txt +0 -0
  427. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/arm.vsprops +0 -0
  428. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/common.vsprops +0 -0
  429. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/d8.vcproj +0 -0
  430. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/d8_arm.vcproj +0 -0
  431. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/d8_x64.vcproj +0 -0
  432. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/d8js2c.cmd +0 -0
  433. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/debug.vsprops +0 -0
  434. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/ia32.vsprops +0 -0
  435. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/js2c.cmd +0 -0
  436. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/release.vsprops +0 -0
  437. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/v8.sln +0 -0
  438. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/v8.vcproj +0 -0
  439. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/v8_arm.sln +0 -0
  440. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/v8_arm.vcproj +0 -0
  441. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/v8_base.vcproj +40 -0
  442. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/v8_base_arm.vcproj +20 -0
  443. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/v8_base_x64.vcproj +16 -0
  444. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/v8_cctest.vcproj +4 -0
  445. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/v8_cctest_arm.vcproj +0 -0
  446. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/v8_cctest_x64.vcproj +0 -0
  447. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/v8_mksnapshot.vcproj +0 -0
  448. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/v8_mksnapshot_x64.vcproj +0 -0
  449. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/v8_process_sample.vcproj +0 -0
  450. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/v8_process_sample_arm.vcproj +0 -0
  451. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/v8_process_sample_x64.vcproj +0 -0
  452. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/v8_shell_sample.vcproj +0 -0
  453. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/v8_shell_sample_arm.vcproj +0 -0
  454. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/v8_shell_sample_x64.vcproj +0 -0
  455. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/v8_snapshot.vcproj +0 -0
  456. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/v8_snapshot_cc.vcproj +0 -0
  457. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/v8_snapshot_cc_x64.vcproj +0 -0
  458. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/v8_snapshot_x64.vcproj +0 -0
  459. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/v8_x64.sln +0 -0
  460. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/v8_x64.vcproj +0 -0
  461. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/visual_studio/x64.vsprops +0 -0
  462. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/windows-tick-processor.bat +0 -0
  463. data/ext/v8/upstream/{2.1.10 → 2.3.3}/tools/windows-tick-processor.py +0 -0
  464. data/ext/v8/upstream/Makefile +1 -1
  465. data/ext/v8/v8_template.cpp +94 -2
  466. data/ext/v8/v8_try_catch.cpp +2 -2
  467. data/lib/v8.rb +1 -1
  468. data/lib/v8/access.rb +93 -40
  469. data/lib/v8/cli.rb +1 -1
  470. data/lib/v8/function.rb +14 -2
  471. data/spec/redjs/jsapi_spec.rb +231 -42
  472. data/therubyracer.gemspec +3 -3
  473. metadata +463 -453
  474. data/ext/v8/upstream/2.1.10/src/arm/assembler-thumb2-inl.h +0 -263
  475. data/ext/v8/upstream/2.1.10/src/arm/assembler-thumb2.cc +0 -1878
  476. data/ext/v8/upstream/2.1.10/src/arm/assembler-thumb2.h +0 -1036
  477. data/ext/v8/upstream/2.1.10/src/arm/codegen-arm-inl.h +0 -72
  478. data/ext/v8/upstream/2.1.10/src/arm/ic-arm.cc +0 -1833
  479. data/ext/v8/upstream/2.1.10/src/circular-queue-inl.h +0 -101
  480. data/ext/v8/upstream/2.1.10/src/profile-generator.cc +0 -583
  481. data/ext/v8/upstream/2.1.10/src/profile-generator.h +0 -364
  482. data/ext/v8/upstream/2.1.10/src/x64/ic-x64.cc +0 -1621
@@ -44,12 +44,6 @@
44
44
  #ifndef V8_PLATFORM_H_
45
45
  #define V8_PLATFORM_H_
46
46
 
47
- #ifdef __sun
48
- // On Solaris, to get isinf, INFINITY, fpclassify and other macros one needs
49
- // to define this symbol
50
- #define __C99FEATURES__ 1
51
- #endif
52
-
53
47
  #define V8_INFINITY INFINITY
54
48
 
55
49
  // Windows specific stuff.
@@ -89,6 +83,14 @@ int random();
89
83
 
90
84
  #endif // WIN32
91
85
 
86
+
87
+ #ifdef __sun
88
+ # ifndef signbit
89
+ int signbit(double x);
90
+ # endif
91
+ #endif
92
+
93
+
92
94
  // GCC specific stuff
93
95
  #ifdef __GNUC__
94
96
 
@@ -275,6 +277,8 @@ class OS {
275
277
  // the platform doesn't care. Guaranteed to be a power of two.
276
278
  static int ActivationFrameAlignment();
277
279
 
280
+ static void ReleaseStore(volatile AtomicWord* ptr, AtomicWord value);
281
+
278
282
  private:
279
283
  static const int msPerSecond = 1000;
280
284
 
File without changes
@@ -35,17 +35,30 @@
35
35
  namespace v8 {
36
36
  namespace internal {
37
37
 
38
+ CodeEntry::CodeEntry(int security_token_id)
39
+ : call_uid_(0),
40
+ tag_(Logger::FUNCTION_TAG),
41
+ name_prefix_(kEmptyNamePrefix),
42
+ name_(""),
43
+ resource_name_(""),
44
+ line_number_(0),
45
+ security_token_id_(security_token_id) {
46
+ }
47
+
48
+
38
49
  CodeEntry::CodeEntry(Logger::LogEventsAndTags tag,
39
50
  const char* name_prefix,
40
51
  const char* name,
41
52
  const char* resource_name,
42
- int line_number)
53
+ int line_number,
54
+ int security_token_id)
43
55
  : call_uid_(next_call_uid_++),
44
56
  tag_(tag),
45
57
  name_prefix_(name_prefix),
46
58
  name_(name),
47
59
  resource_name_(resource_name),
48
- line_number_(line_number) {
60
+ line_number_(line_number),
61
+ security_token_id_(security_token_id) {
49
62
  }
50
63
 
51
64
 
@@ -117,6 +130,17 @@ CodeEntry* ProfileGenerator::EntryForVMState(StateTag tag) {
117
130
  }
118
131
  }
119
132
 
133
+
134
+ template<class Visitor>
135
+ void HeapEntriesMap::Apply(Visitor* visitor) {
136
+ for (HashMap::Entry* p = entries_.Start();
137
+ p != NULL;
138
+ p = entries_.Next(p)) {
139
+ if (!IsAlias(p->value))
140
+ visitor->Apply(reinterpret_cast<HeapEntry*>(p->value));
141
+ }
142
+ }
143
+
120
144
  } } // namespace v8::internal
121
145
 
122
146
  #endif // ENABLE_LOGGING_AND_PROFILING
@@ -0,0 +1,1830 @@
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 "zone-inl.h"
35
+
36
+ #include "profile-generator-inl.h"
37
+
38
+ namespace v8 {
39
+ namespace internal {
40
+
41
+
42
+ TokenEnumerator::TokenEnumerator()
43
+ : token_locations_(4),
44
+ token_removed_(4) {
45
+ }
46
+
47
+
48
+ TokenEnumerator::~TokenEnumerator() {
49
+ for (int i = 0; i < token_locations_.length(); ++i) {
50
+ if (!token_removed_[i]) {
51
+ GlobalHandles::ClearWeakness(token_locations_[i]);
52
+ GlobalHandles::Destroy(token_locations_[i]);
53
+ }
54
+ }
55
+ }
56
+
57
+
58
+ int TokenEnumerator::GetTokenId(Object* token) {
59
+ if (token == NULL) return TokenEnumerator::kNoSecurityToken;
60
+ for (int i = 0; i < token_locations_.length(); ++i) {
61
+ if (*token_locations_[i] == token && !token_removed_[i]) return i;
62
+ }
63
+ Handle<Object> handle = GlobalHandles::Create(token);
64
+ // handle.location() points to a memory cell holding a pointer
65
+ // to a token object in the V8's heap.
66
+ GlobalHandles::MakeWeak(handle.location(), this, TokenRemovedCallback);
67
+ token_locations_.Add(handle.location());
68
+ token_removed_.Add(false);
69
+ return token_locations_.length() - 1;
70
+ }
71
+
72
+
73
+ void TokenEnumerator::TokenRemovedCallback(v8::Persistent<v8::Value> handle,
74
+ void* parameter) {
75
+ reinterpret_cast<TokenEnumerator*>(parameter)->TokenRemoved(
76
+ Utils::OpenHandle(*handle).location());
77
+ handle.Dispose();
78
+ }
79
+
80
+
81
+ void TokenEnumerator::TokenRemoved(Object** token_location) {
82
+ for (int i = 0; i < token_locations_.length(); ++i) {
83
+ if (token_locations_[i] == token_location && !token_removed_[i]) {
84
+ token_removed_[i] = true;
85
+ return;
86
+ }
87
+ }
88
+ }
89
+
90
+
91
+ StringsStorage::StringsStorage()
92
+ : names_(StringsMatch) {
93
+ }
94
+
95
+
96
+ StringsStorage::~StringsStorage() {
97
+ for (HashMap::Entry* p = names_.Start();
98
+ p != NULL;
99
+ p = names_.Next(p)) {
100
+ DeleteArray(reinterpret_cast<const char*>(p->value));
101
+ }
102
+ }
103
+
104
+
105
+ const char* StringsStorage::GetName(String* name) {
106
+ if (name->IsString()) {
107
+ char* c_name =
108
+ name->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL).Detach();
109
+ HashMap::Entry* cache_entry = names_.Lookup(c_name, name->Hash(), true);
110
+ if (cache_entry->value == NULL) {
111
+ // New entry added.
112
+ cache_entry->value = c_name;
113
+ } else {
114
+ DeleteArray(c_name);
115
+ }
116
+ return reinterpret_cast<const char*>(cache_entry->value);
117
+ }
118
+ return "";
119
+ }
120
+
121
+
122
+ const char* CodeEntry::kEmptyNamePrefix = "";
123
+ unsigned CodeEntry::next_call_uid_ = 1;
124
+
125
+
126
+ void CodeEntry::CopyData(const CodeEntry& source) {
127
+ call_uid_ = source.call_uid_;
128
+ tag_ = source.tag_;
129
+ name_prefix_ = source.name_prefix_;
130
+ name_ = source.name_;
131
+ resource_name_ = source.resource_name_;
132
+ line_number_ = source.line_number_;
133
+ }
134
+
135
+
136
+ ProfileNode* ProfileNode::FindChild(CodeEntry* entry) {
137
+ HashMap::Entry* map_entry =
138
+ children_.Lookup(entry, CodeEntryHash(entry), false);
139
+ return map_entry != NULL ?
140
+ reinterpret_cast<ProfileNode*>(map_entry->value) : NULL;
141
+ }
142
+
143
+
144
+ ProfileNode* ProfileNode::FindOrAddChild(CodeEntry* entry) {
145
+ HashMap::Entry* map_entry =
146
+ children_.Lookup(entry, CodeEntryHash(entry), true);
147
+ if (map_entry->value == NULL) {
148
+ // New node added.
149
+ ProfileNode* new_node = new ProfileNode(tree_, entry);
150
+ map_entry->value = new_node;
151
+ children_list_.Add(new_node);
152
+ }
153
+ return reinterpret_cast<ProfileNode*>(map_entry->value);
154
+ }
155
+
156
+
157
+ double ProfileNode::GetSelfMillis() const {
158
+ return tree_->TicksToMillis(self_ticks_);
159
+ }
160
+
161
+
162
+ double ProfileNode::GetTotalMillis() const {
163
+ return tree_->TicksToMillis(total_ticks_);
164
+ }
165
+
166
+
167
+ void ProfileNode::Print(int indent) {
168
+ OS::Print("%5u %5u %*c %s%s [%d]",
169
+ total_ticks_, self_ticks_,
170
+ indent, ' ',
171
+ entry_->name_prefix(),
172
+ entry_->name(),
173
+ entry_->security_token_id());
174
+ if (entry_->resource_name()[0] != '\0')
175
+ OS::Print(" %s:%d", entry_->resource_name(), entry_->line_number());
176
+ OS::Print("\n");
177
+ for (HashMap::Entry* p = children_.Start();
178
+ p != NULL;
179
+ p = children_.Next(p)) {
180
+ reinterpret_cast<ProfileNode*>(p->value)->Print(indent + 2);
181
+ }
182
+ }
183
+
184
+
185
+ class DeleteNodesCallback {
186
+ public:
187
+ void BeforeTraversingChild(ProfileNode*, ProfileNode*) { }
188
+
189
+ void AfterAllChildrenTraversed(ProfileNode* node) {
190
+ delete node;
191
+ }
192
+
193
+ void AfterChildTraversed(ProfileNode*, ProfileNode*) { }
194
+ };
195
+
196
+
197
+ ProfileTree::ProfileTree()
198
+ : root_entry_(Logger::FUNCTION_TAG,
199
+ "",
200
+ "(root)",
201
+ "",
202
+ 0,
203
+ TokenEnumerator::kNoSecurityToken),
204
+ root_(new ProfileNode(this, &root_entry_)) {
205
+ }
206
+
207
+
208
+ ProfileTree::~ProfileTree() {
209
+ DeleteNodesCallback cb;
210
+ TraverseDepthFirst(&cb);
211
+ }
212
+
213
+
214
+ void ProfileTree::AddPathFromEnd(const Vector<CodeEntry*>& path) {
215
+ ProfileNode* node = root_;
216
+ for (CodeEntry** entry = path.start() + path.length() - 1;
217
+ entry != path.start() - 1;
218
+ --entry) {
219
+ if (*entry != NULL) {
220
+ node = node->FindOrAddChild(*entry);
221
+ }
222
+ }
223
+ node->IncrementSelfTicks();
224
+ }
225
+
226
+
227
+ void ProfileTree::AddPathFromStart(const Vector<CodeEntry*>& path) {
228
+ ProfileNode* node = root_;
229
+ for (CodeEntry** entry = path.start();
230
+ entry != path.start() + path.length();
231
+ ++entry) {
232
+ if (*entry != NULL) {
233
+ node = node->FindOrAddChild(*entry);
234
+ }
235
+ }
236
+ node->IncrementSelfTicks();
237
+ }
238
+
239
+
240
+ struct NodesPair {
241
+ NodesPair(ProfileNode* src, ProfileNode* dst)
242
+ : src(src), dst(dst) { }
243
+ ProfileNode* src;
244
+ ProfileNode* dst;
245
+ };
246
+
247
+
248
+ class FilteredCloneCallback {
249
+ public:
250
+ explicit FilteredCloneCallback(ProfileNode* dst_root, int security_token_id)
251
+ : stack_(10),
252
+ security_token_id_(security_token_id) {
253
+ stack_.Add(NodesPair(NULL, dst_root));
254
+ }
255
+
256
+ void BeforeTraversingChild(ProfileNode* parent, ProfileNode* child) {
257
+ if (IsTokenAcceptable(child->entry()->security_token_id(),
258
+ parent->entry()->security_token_id())) {
259
+ ProfileNode* clone = stack_.last().dst->FindOrAddChild(child->entry());
260
+ clone->IncreaseSelfTicks(child->self_ticks());
261
+ stack_.Add(NodesPair(child, clone));
262
+ } else {
263
+ // Attribute ticks to parent node.
264
+ stack_.last().dst->IncreaseSelfTicks(child->self_ticks());
265
+ }
266
+ }
267
+
268
+ void AfterAllChildrenTraversed(ProfileNode* parent) { }
269
+
270
+ void AfterChildTraversed(ProfileNode*, ProfileNode* child) {
271
+ if (stack_.last().src == child) {
272
+ stack_.RemoveLast();
273
+ }
274
+ }
275
+
276
+ private:
277
+ bool IsTokenAcceptable(int token, int parent_token) {
278
+ if (token == TokenEnumerator::kNoSecurityToken
279
+ || token == security_token_id_) return true;
280
+ if (token == TokenEnumerator::kInheritsSecurityToken) {
281
+ ASSERT(parent_token != TokenEnumerator::kInheritsSecurityToken);
282
+ return parent_token == TokenEnumerator::kNoSecurityToken
283
+ || parent_token == security_token_id_;
284
+ }
285
+ return false;
286
+ }
287
+
288
+ List<NodesPair> stack_;
289
+ int security_token_id_;
290
+ };
291
+
292
+ void ProfileTree::FilteredClone(ProfileTree* src, int security_token_id) {
293
+ ms_to_ticks_scale_ = src->ms_to_ticks_scale_;
294
+ FilteredCloneCallback cb(root_, security_token_id);
295
+ src->TraverseDepthFirst(&cb);
296
+ CalculateTotalTicks();
297
+ }
298
+
299
+
300
+ void ProfileTree::SetTickRatePerMs(double ticks_per_ms) {
301
+ ms_to_ticks_scale_ = ticks_per_ms > 0 ? 1.0 / ticks_per_ms : 1.0;
302
+ }
303
+
304
+
305
+ class Position {
306
+ public:
307
+ explicit Position(ProfileNode* node)
308
+ : node(node), child_idx_(0) { }
309
+ INLINE(ProfileNode* current_child()) {
310
+ return node->children()->at(child_idx_);
311
+ }
312
+ INLINE(bool has_current_child()) {
313
+ return child_idx_ < node->children()->length();
314
+ }
315
+ INLINE(void next_child()) { ++child_idx_; }
316
+
317
+ ProfileNode* node;
318
+ private:
319
+ int child_idx_;
320
+ };
321
+
322
+
323
+ // Non-recursive implementation of a depth-first post-order tree traversal.
324
+ template <typename Callback>
325
+ void ProfileTree::TraverseDepthFirst(Callback* callback) {
326
+ List<Position> stack(10);
327
+ stack.Add(Position(root_));
328
+ while (stack.length() > 0) {
329
+ Position& current = stack.last();
330
+ if (current.has_current_child()) {
331
+ callback->BeforeTraversingChild(current.node, current.current_child());
332
+ stack.Add(Position(current.current_child()));
333
+ } else {
334
+ callback->AfterAllChildrenTraversed(current.node);
335
+ if (stack.length() > 1) {
336
+ Position& parent = stack[stack.length() - 2];
337
+ callback->AfterChildTraversed(parent.node, current.node);
338
+ parent.next_child();
339
+ }
340
+ // Remove child from the stack.
341
+ stack.RemoveLast();
342
+ }
343
+ }
344
+ }
345
+
346
+
347
+ class CalculateTotalTicksCallback {
348
+ public:
349
+ void BeforeTraversingChild(ProfileNode*, ProfileNode*) { }
350
+
351
+ void AfterAllChildrenTraversed(ProfileNode* node) {
352
+ node->IncreaseTotalTicks(node->self_ticks());
353
+ }
354
+
355
+ void AfterChildTraversed(ProfileNode* parent, ProfileNode* child) {
356
+ parent->IncreaseTotalTicks(child->total_ticks());
357
+ }
358
+ };
359
+
360
+
361
+ void ProfileTree::CalculateTotalTicks() {
362
+ CalculateTotalTicksCallback cb;
363
+ TraverseDepthFirst(&cb);
364
+ }
365
+
366
+
367
+ void ProfileTree::ShortPrint() {
368
+ OS::Print("root: %u %u %.2fms %.2fms\n",
369
+ root_->total_ticks(), root_->self_ticks(),
370
+ root_->GetTotalMillis(), root_->GetSelfMillis());
371
+ }
372
+
373
+
374
+ void CpuProfile::AddPath(const Vector<CodeEntry*>& path) {
375
+ top_down_.AddPathFromEnd(path);
376
+ bottom_up_.AddPathFromStart(path);
377
+ }
378
+
379
+
380
+ void CpuProfile::CalculateTotalTicks() {
381
+ top_down_.CalculateTotalTicks();
382
+ bottom_up_.CalculateTotalTicks();
383
+ }
384
+
385
+
386
+ void CpuProfile::SetActualSamplingRate(double actual_sampling_rate) {
387
+ top_down_.SetTickRatePerMs(actual_sampling_rate);
388
+ bottom_up_.SetTickRatePerMs(actual_sampling_rate);
389
+ }
390
+
391
+
392
+ CpuProfile* CpuProfile::FilteredClone(int security_token_id) {
393
+ ASSERT(security_token_id != TokenEnumerator::kNoSecurityToken);
394
+ CpuProfile* clone = new CpuProfile(title_, uid_);
395
+ clone->top_down_.FilteredClone(&top_down_, security_token_id);
396
+ clone->bottom_up_.FilteredClone(&bottom_up_, security_token_id);
397
+ return clone;
398
+ }
399
+
400
+
401
+ void CpuProfile::ShortPrint() {
402
+ OS::Print("top down ");
403
+ top_down_.ShortPrint();
404
+ OS::Print("bottom up ");
405
+ bottom_up_.ShortPrint();
406
+ }
407
+
408
+
409
+ void CpuProfile::Print() {
410
+ OS::Print("[Top down]:\n");
411
+ top_down_.Print();
412
+ OS::Print("[Bottom up]:\n");
413
+ bottom_up_.Print();
414
+ }
415
+
416
+
417
+ const CodeMap::CodeTreeConfig::Key CodeMap::CodeTreeConfig::kNoKey = NULL;
418
+ const CodeMap::CodeTreeConfig::Value CodeMap::CodeTreeConfig::kNoValue =
419
+ CodeMap::CodeEntryInfo(NULL, 0);
420
+
421
+
422
+ void CodeMap::AddAlias(Address start, CodeEntry* entry, Address code_start) {
423
+ CodeTree::Locator locator;
424
+ if (tree_.Find(code_start, &locator)) {
425
+ const CodeEntryInfo& code_info = locator.value();
426
+ entry->CopyData(*code_info.entry);
427
+ tree_.Insert(start, &locator);
428
+ locator.set_value(CodeEntryInfo(entry, code_info.size));
429
+ }
430
+ }
431
+
432
+
433
+ CodeEntry* CodeMap::FindEntry(Address addr) {
434
+ CodeTree::Locator locator;
435
+ if (tree_.FindGreatestLessThan(addr, &locator)) {
436
+ // locator.key() <= addr. Need to check that addr is within entry.
437
+ const CodeEntryInfo& entry = locator.value();
438
+ if (addr < (locator.key() + entry.size))
439
+ return entry.entry;
440
+ }
441
+ return NULL;
442
+ }
443
+
444
+
445
+ void CodeMap::CodeTreePrinter::Call(
446
+ const Address& key, const CodeMap::CodeEntryInfo& value) {
447
+ OS::Print("%p %5d %s\n", key, value.size, value.entry->name());
448
+ }
449
+
450
+
451
+ void CodeMap::Print() {
452
+ CodeTreePrinter printer;
453
+ tree_.ForEach(&printer);
454
+ }
455
+
456
+
457
+ CpuProfilesCollection::CpuProfilesCollection()
458
+ : profiles_uids_(UidsMatch),
459
+ current_profiles_semaphore_(OS::CreateSemaphore(1)) {
460
+ // Create list of unabridged profiles.
461
+ profiles_by_token_.Add(new List<CpuProfile*>());
462
+ }
463
+
464
+
465
+ static void DeleteArgsCountName(char** name_ptr) {
466
+ DeleteArray(*name_ptr);
467
+ }
468
+
469
+
470
+ static void DeleteCodeEntry(CodeEntry** entry_ptr) {
471
+ delete *entry_ptr;
472
+ }
473
+
474
+ static void DeleteCpuProfile(CpuProfile** profile_ptr) {
475
+ delete *profile_ptr;
476
+ }
477
+
478
+ static void DeleteProfilesList(List<CpuProfile*>** list_ptr) {
479
+ (*list_ptr)->Iterate(DeleteCpuProfile);
480
+ delete *list_ptr;
481
+ }
482
+
483
+ CpuProfilesCollection::~CpuProfilesCollection() {
484
+ delete current_profiles_semaphore_;
485
+ current_profiles_.Iterate(DeleteCpuProfile);
486
+ profiles_by_token_.Iterate(DeleteProfilesList);
487
+ code_entries_.Iterate(DeleteCodeEntry);
488
+ args_count_names_.Iterate(DeleteArgsCountName);
489
+ }
490
+
491
+
492
+ bool CpuProfilesCollection::StartProfiling(const char* title, unsigned uid) {
493
+ ASSERT(uid > 0);
494
+ current_profiles_semaphore_->Wait();
495
+ for (int i = 0; i < current_profiles_.length(); ++i) {
496
+ if (strcmp(current_profiles_[i]->title(), title) == 0) {
497
+ // Ignore attempts to start profile with the same title.
498
+ current_profiles_semaphore_->Signal();
499
+ return false;
500
+ }
501
+ }
502
+ current_profiles_.Add(new CpuProfile(title, uid));
503
+ current_profiles_semaphore_->Signal();
504
+ return true;
505
+ }
506
+
507
+
508
+ bool CpuProfilesCollection::StartProfiling(String* title, unsigned uid) {
509
+ return StartProfiling(GetName(title), uid);
510
+ }
511
+
512
+
513
+ CpuProfile* CpuProfilesCollection::StopProfiling(int security_token_id,
514
+ const char* title,
515
+ double actual_sampling_rate) {
516
+ const int title_len = StrLength(title);
517
+ CpuProfile* profile = NULL;
518
+ current_profiles_semaphore_->Wait();
519
+ for (int i = current_profiles_.length() - 1; i >= 0; --i) {
520
+ if (title_len == 0 || strcmp(current_profiles_[i]->title(), title) == 0) {
521
+ profile = current_profiles_.Remove(i);
522
+ break;
523
+ }
524
+ }
525
+ current_profiles_semaphore_->Signal();
526
+
527
+ if (profile != NULL) {
528
+ profile->CalculateTotalTicks();
529
+ profile->SetActualSamplingRate(actual_sampling_rate);
530
+ List<CpuProfile*>* unabridged_list =
531
+ profiles_by_token_[TokenToIndex(TokenEnumerator::kNoSecurityToken)];
532
+ unabridged_list->Add(profile);
533
+ HashMap::Entry* entry =
534
+ profiles_uids_.Lookup(reinterpret_cast<void*>(profile->uid()),
535
+ static_cast<uint32_t>(profile->uid()),
536
+ true);
537
+ ASSERT(entry->value == NULL);
538
+ entry->value = reinterpret_cast<void*>(unabridged_list->length() - 1);
539
+ return GetProfile(security_token_id, profile->uid());
540
+ }
541
+ return NULL;
542
+ }
543
+
544
+
545
+ CpuProfile* CpuProfilesCollection::StopProfiling(int security_token_id,
546
+ String* title,
547
+ double actual_sampling_rate) {
548
+ return StopProfiling(security_token_id, GetName(title), actual_sampling_rate);
549
+ }
550
+
551
+
552
+ CpuProfile* CpuProfilesCollection::GetProfile(int security_token_id,
553
+ unsigned uid) {
554
+ HashMap::Entry* entry = profiles_uids_.Lookup(reinterpret_cast<void*>(uid),
555
+ static_cast<uint32_t>(uid),
556
+ false);
557
+ int index;
558
+ if (entry != NULL) {
559
+ index = static_cast<int>(reinterpret_cast<intptr_t>(entry->value));
560
+ } else {
561
+ return NULL;
562
+ }
563
+ List<CpuProfile*>* unabridged_list =
564
+ profiles_by_token_[TokenToIndex(TokenEnumerator::kNoSecurityToken)];
565
+ if (security_token_id == TokenEnumerator::kNoSecurityToken) {
566
+ return unabridged_list->at(index);
567
+ }
568
+ List<CpuProfile*>* list = GetProfilesList(security_token_id);
569
+ if (list->at(index) == NULL) {
570
+ list->at(index) =
571
+ unabridged_list->at(index)->FilteredClone(security_token_id);
572
+ }
573
+ return list->at(index);
574
+ }
575
+
576
+
577
+ int CpuProfilesCollection::TokenToIndex(int security_token_id) {
578
+ ASSERT(TokenEnumerator::kNoSecurityToken == -1);
579
+ return security_token_id + 1; // kNoSecurityToken -> 0, 0 -> 1, ...
580
+ }
581
+
582
+
583
+ List<CpuProfile*>* CpuProfilesCollection::GetProfilesList(
584
+ int security_token_id) {
585
+ const int index = TokenToIndex(security_token_id);
586
+ const int lists_to_add = index - profiles_by_token_.length() + 1;
587
+ if (lists_to_add > 0) profiles_by_token_.AddBlock(NULL, lists_to_add);
588
+ List<CpuProfile*>* unabridged_list =
589
+ profiles_by_token_[TokenToIndex(TokenEnumerator::kNoSecurityToken)];
590
+ const int current_count = unabridged_list->length();
591
+ if (profiles_by_token_[index] == NULL) {
592
+ profiles_by_token_[index] = new List<CpuProfile*>(current_count);
593
+ }
594
+ List<CpuProfile*>* list = profiles_by_token_[index];
595
+ const int profiles_to_add = current_count - list->length();
596
+ if (profiles_to_add > 0) list->AddBlock(NULL, profiles_to_add);
597
+ return list;
598
+ }
599
+
600
+
601
+ List<CpuProfile*>* CpuProfilesCollection::Profiles(int security_token_id) {
602
+ List<CpuProfile*>* unabridged_list =
603
+ profiles_by_token_[TokenToIndex(TokenEnumerator::kNoSecurityToken)];
604
+ if (security_token_id == TokenEnumerator::kNoSecurityToken) {
605
+ return unabridged_list;
606
+ }
607
+ List<CpuProfile*>* list = GetProfilesList(security_token_id);
608
+ const int current_count = unabridged_list->length();
609
+ for (int i = 0; i < current_count; ++i) {
610
+ if (list->at(i) == NULL) {
611
+ list->at(i) = unabridged_list->at(i)->FilteredClone(security_token_id);
612
+ }
613
+ }
614
+ return list;
615
+ }
616
+
617
+
618
+ CodeEntry* CpuProfilesCollection::NewCodeEntry(Logger::LogEventsAndTags tag,
619
+ String* name,
620
+ String* resource_name,
621
+ int line_number) {
622
+ CodeEntry* entry = new CodeEntry(tag,
623
+ CodeEntry::kEmptyNamePrefix,
624
+ GetFunctionName(name),
625
+ GetName(resource_name),
626
+ line_number,
627
+ TokenEnumerator::kNoSecurityToken);
628
+ code_entries_.Add(entry);
629
+ return entry;
630
+ }
631
+
632
+
633
+ CodeEntry* CpuProfilesCollection::NewCodeEntry(Logger::LogEventsAndTags tag,
634
+ const char* name) {
635
+ CodeEntry* entry = new CodeEntry(tag,
636
+ CodeEntry::kEmptyNamePrefix,
637
+ GetFunctionName(name),
638
+ "",
639
+ v8::CpuProfileNode::kNoLineNumberInfo,
640
+ TokenEnumerator::kNoSecurityToken);
641
+ code_entries_.Add(entry);
642
+ return entry;
643
+ }
644
+
645
+
646
+ CodeEntry* CpuProfilesCollection::NewCodeEntry(Logger::LogEventsAndTags tag,
647
+ const char* name_prefix,
648
+ String* name) {
649
+ CodeEntry* entry = new CodeEntry(tag,
650
+ name_prefix,
651
+ GetName(name),
652
+ "",
653
+ v8::CpuProfileNode::kNoLineNumberInfo,
654
+ TokenEnumerator::kInheritsSecurityToken);
655
+ code_entries_.Add(entry);
656
+ return entry;
657
+ }
658
+
659
+
660
+ CodeEntry* CpuProfilesCollection::NewCodeEntry(Logger::LogEventsAndTags tag,
661
+ int args_count) {
662
+ CodeEntry* entry = new CodeEntry(tag,
663
+ "args_count: ",
664
+ GetName(args_count),
665
+ "",
666
+ v8::CpuProfileNode::kNoLineNumberInfo,
667
+ TokenEnumerator::kInheritsSecurityToken);
668
+ code_entries_.Add(entry);
669
+ return entry;
670
+ }
671
+
672
+
673
+ CodeEntry* CpuProfilesCollection::NewCodeEntry(int security_token_id) {
674
+ CodeEntry* entry = new CodeEntry(security_token_id);
675
+ code_entries_.Add(entry);
676
+ return entry;
677
+ }
678
+
679
+
680
+ const char* CpuProfilesCollection::GetName(int args_count) {
681
+ ASSERT(args_count >= 0);
682
+ if (args_count_names_.length() <= args_count) {
683
+ args_count_names_.AddBlock(
684
+ NULL, args_count - args_count_names_.length() + 1);
685
+ }
686
+ if (args_count_names_[args_count] == NULL) {
687
+ const int kMaximumNameLength = 32;
688
+ char* name = NewArray<char>(kMaximumNameLength);
689
+ OS::SNPrintF(Vector<char>(name, kMaximumNameLength), "%d", args_count);
690
+ args_count_names_[args_count] = name;
691
+ }
692
+ return args_count_names_[args_count];
693
+ }
694
+
695
+
696
+ void CpuProfilesCollection::AddPathToCurrentProfiles(
697
+ const Vector<CodeEntry*>& path) {
698
+ // As starting / stopping profiles is rare relatively to this
699
+ // method, we don't bother minimizing the duration of lock holding,
700
+ // e.g. copying contents of the list to a local vector.
701
+ current_profiles_semaphore_->Wait();
702
+ for (int i = 0; i < current_profiles_.length(); ++i) {
703
+ current_profiles_[i]->AddPath(path);
704
+ }
705
+ current_profiles_semaphore_->Signal();
706
+ }
707
+
708
+
709
+ void SampleRateCalculator::Tick() {
710
+ if (--wall_time_query_countdown_ == 0)
711
+ UpdateMeasurements(OS::TimeCurrentMillis());
712
+ }
713
+
714
+
715
+ void SampleRateCalculator::UpdateMeasurements(double current_time) {
716
+ if (measurements_count_++ != 0) {
717
+ const double measured_ticks_per_ms =
718
+ (kWallTimeQueryIntervalMs * ticks_per_ms_) /
719
+ (current_time - last_wall_time_);
720
+ // Update the average value.
721
+ ticks_per_ms_ +=
722
+ (measured_ticks_per_ms - ticks_per_ms_) / measurements_count_;
723
+ // Update the externally accessible result.
724
+ result_ = static_cast<AtomicWord>(ticks_per_ms_ * kResultScale);
725
+ }
726
+ last_wall_time_ = current_time;
727
+ wall_time_query_countdown_ =
728
+ static_cast<unsigned>(kWallTimeQueryIntervalMs * ticks_per_ms_);
729
+ }
730
+
731
+
732
+ const char* ProfileGenerator::kAnonymousFunctionName = "(anonymous function)";
733
+ const char* ProfileGenerator::kProgramEntryName = "(program)";
734
+ const char* ProfileGenerator::kGarbageCollectorEntryName =
735
+ "(garbage collector)";
736
+
737
+
738
+ ProfileGenerator::ProfileGenerator(CpuProfilesCollection* profiles)
739
+ : profiles_(profiles),
740
+ program_entry_(
741
+ profiles->NewCodeEntry(Logger::FUNCTION_TAG, kProgramEntryName)),
742
+ gc_entry_(
743
+ profiles->NewCodeEntry(Logger::BUILTIN_TAG,
744
+ kGarbageCollectorEntryName)) {
745
+ }
746
+
747
+
748
+ void ProfileGenerator::RecordTickSample(const TickSample& sample) {
749
+ // Allocate space for stack frames + pc + function + vm-state.
750
+ ScopedVector<CodeEntry*> entries(sample.frames_count + 3);
751
+ // As actual number of decoded code entries may vary, initialize
752
+ // entries vector with NULL values.
753
+ CodeEntry** entry = entries.start();
754
+ memset(entry, 0, entries.length() * sizeof(*entry));
755
+ if (sample.pc != NULL) {
756
+ *entry++ = code_map_.FindEntry(sample.pc);
757
+
758
+ if (sample.function != NULL) {
759
+ *entry = code_map_.FindEntry(sample.function);
760
+ if (*entry != NULL && !(*entry)->is_js_function()) {
761
+ *entry = NULL;
762
+ } else {
763
+ CodeEntry* pc_entry = *entries.start();
764
+ if (pc_entry == NULL) {
765
+ *entry = NULL;
766
+ } else if (pc_entry->is_js_function()) {
767
+ // Use function entry in favor of pc entry, as function
768
+ // entry has security token.
769
+ *entries.start() = NULL;
770
+ }
771
+ }
772
+ entry++;
773
+ }
774
+
775
+ for (const Address *stack_pos = sample.stack,
776
+ *stack_end = stack_pos + sample.frames_count;
777
+ stack_pos != stack_end;
778
+ ++stack_pos) {
779
+ *entry++ = code_map_.FindEntry(*stack_pos);
780
+ }
781
+ }
782
+
783
+ if (FLAG_prof_browser_mode) {
784
+ bool no_symbolized_entries = true;
785
+ for (CodeEntry** e = entries.start(); e != entry; ++e) {
786
+ if (*e != NULL) {
787
+ no_symbolized_entries = false;
788
+ break;
789
+ }
790
+ }
791
+ // If no frames were symbolized, put the VM state entry in.
792
+ if (no_symbolized_entries) {
793
+ *entry++ = EntryForVMState(sample.state);
794
+ }
795
+ }
796
+
797
+ profiles_->AddPathToCurrentProfiles(entries);
798
+ }
799
+
800
+
801
+ HeapGraphEdge::HeapGraphEdge(Type type,
802
+ const char* name,
803
+ HeapEntry* from,
804
+ HeapEntry* to)
805
+ : type_(type), name_(name), from_(from), to_(to) {
806
+ ASSERT(type_ == CONTEXT_VARIABLE || type_ == PROPERTY || type_ == INTERNAL);
807
+ }
808
+
809
+
810
+ HeapGraphEdge::HeapGraphEdge(int index,
811
+ HeapEntry* from,
812
+ HeapEntry* to)
813
+ : type_(ELEMENT), index_(index), from_(from), to_(to) {
814
+ }
815
+
816
+
817
+ static void DeleteHeapGraphEdge(HeapGraphEdge** edge_ptr) {
818
+ delete *edge_ptr;
819
+ }
820
+
821
+
822
+ static void DeleteHeapGraphPath(HeapGraphPath** path_ptr) {
823
+ delete *path_ptr;
824
+ }
825
+
826
+
827
+ HeapEntry::~HeapEntry() {
828
+ children_.Iterate(DeleteHeapGraphEdge);
829
+ retaining_paths_.Iterate(DeleteHeapGraphPath);
830
+ }
831
+
832
+
833
+ void HeapEntry::AddEdge(HeapGraphEdge* edge) {
834
+ children_.Add(edge);
835
+ edge->to()->retainers_.Add(edge);
836
+ }
837
+
838
+
839
+ void HeapEntry::SetClosureReference(const char* name, HeapEntry* entry) {
840
+ AddEdge(
841
+ new HeapGraphEdge(HeapGraphEdge::CONTEXT_VARIABLE, name, this, entry));
842
+ }
843
+
844
+
845
+ void HeapEntry::SetElementReference(int index, HeapEntry* entry) {
846
+ AddEdge(new HeapGraphEdge(index, this, entry));
847
+ }
848
+
849
+
850
+ void HeapEntry::SetInternalReference(const char* name, HeapEntry* entry) {
851
+ AddEdge(new HeapGraphEdge(HeapGraphEdge::INTERNAL, name, this, entry));
852
+ }
853
+
854
+
855
+ void HeapEntry::SetPropertyReference(const char* name, HeapEntry* entry) {
856
+ AddEdge(new HeapGraphEdge(HeapGraphEdge::PROPERTY, name, this, entry));
857
+ }
858
+
859
+
860
+ void HeapEntry::SetAutoIndexReference(HeapEntry* entry) {
861
+ SetElementReference(next_auto_index_++, entry);
862
+ }
863
+
864
+
865
+ void HeapEntry::SetUnidirAutoIndexReference(HeapEntry* entry) {
866
+ children_.Add(new HeapGraphEdge(next_auto_index_++, this, entry));
867
+ }
868
+
869
+
870
+ int HeapEntry::TotalSize() {
871
+ return total_size_ != kUnknownSize ? total_size_ : CalculateTotalSize();
872
+ }
873
+
874
+
875
+ int HeapEntry::NonSharedTotalSize() {
876
+ return non_shared_total_size_ != kUnknownSize ?
877
+ non_shared_total_size_ : CalculateNonSharedTotalSize();
878
+ }
879
+
880
+
881
+ template<class Visitor>
882
+ void HeapEntry::ApplyAndPaintAllReachable(Visitor* visitor) {
883
+ List<HeapEntry*> list(10);
884
+ list.Add(this);
885
+ this->PaintReachable();
886
+ visitor->Apply(this);
887
+ while (!list.is_empty()) {
888
+ HeapEntry* entry = list.RemoveLast();
889
+ const int children_count = entry->children_.length();
890
+ for (int i = 0; i < children_count; ++i) {
891
+ HeapEntry* child = entry->children_[i]->to();
892
+ if (!child->painted_reachable()) {
893
+ list.Add(child);
894
+ child->PaintReachable();
895
+ visitor->Apply(child);
896
+ }
897
+ }
898
+ }
899
+ }
900
+
901
+
902
+ class NullClass {
903
+ public:
904
+ void Apply(HeapEntry* entry) { }
905
+ };
906
+
907
+ void HeapEntry::PaintAllReachable() {
908
+ NullClass null;
909
+ ApplyAndPaintAllReachable(&null);
910
+ }
911
+
912
+
913
+ class TotalSizeCalculator {
914
+ public:
915
+ TotalSizeCalculator()
916
+ : total_size_(0) {
917
+ }
918
+
919
+ int total_size() const { return total_size_; }
920
+
921
+ void Apply(HeapEntry* entry) {
922
+ total_size_ += entry->self_size();
923
+ }
924
+
925
+ private:
926
+ int total_size_;
927
+ };
928
+
929
+ int HeapEntry::CalculateTotalSize() {
930
+ snapshot_->ClearPaint();
931
+ TotalSizeCalculator calc;
932
+ ApplyAndPaintAllReachable(&calc);
933
+ total_size_ = calc.total_size();
934
+ return total_size_;
935
+ }
936
+
937
+
938
+ class NonSharedSizeCalculator {
939
+ public:
940
+ NonSharedSizeCalculator()
941
+ : non_shared_total_size_(0) {
942
+ }
943
+
944
+ int non_shared_total_size() const { return non_shared_total_size_; }
945
+
946
+ void Apply(HeapEntry* entry) {
947
+ if (entry->painted_reachable()) {
948
+ non_shared_total_size_ += entry->self_size();
949
+ }
950
+ }
951
+
952
+ private:
953
+ int non_shared_total_size_;
954
+ };
955
+
956
+ int HeapEntry::CalculateNonSharedTotalSize() {
957
+ // To calculate non-shared total size, first we paint all reachable
958
+ // nodes in one color, then we paint all nodes reachable from other
959
+ // nodes with a different color. Then we consider only nodes painted
960
+ // with the first color for calculating the total size.
961
+ snapshot_->ClearPaint();
962
+ PaintAllReachable();
963
+
964
+ List<HeapEntry*> list(10);
965
+ if (this != snapshot_->root()) {
966
+ list.Add(snapshot_->root());
967
+ snapshot_->root()->PaintReachableFromOthers();
968
+ }
969
+ while (!list.is_empty()) {
970
+ HeapEntry* entry = list.RemoveLast();
971
+ const int children_count = entry->children_.length();
972
+ for (int i = 0; i < children_count; ++i) {
973
+ HeapEntry* child = entry->children_[i]->to();
974
+ if (child != this && child->not_painted_reachable_from_others()) {
975
+ list.Add(child);
976
+ child->PaintReachableFromOthers();
977
+ }
978
+ }
979
+ }
980
+
981
+ NonSharedSizeCalculator calculator;
982
+ snapshot_->IterateEntries(&calculator);
983
+ non_shared_total_size_ = calculator.non_shared_total_size();
984
+ return non_shared_total_size_;
985
+ }
986
+
987
+
988
+ class CachedHeapGraphPath {
989
+ public:
990
+ CachedHeapGraphPath()
991
+ : nodes_(NodesMatch) { }
992
+ CachedHeapGraphPath(const CachedHeapGraphPath& src)
993
+ : nodes_(NodesMatch, &HashMap::DefaultAllocator, src.nodes_.capacity()),
994
+ path_(src.path_.length() + 1) {
995
+ for (HashMap::Entry* p = src.nodes_.Start();
996
+ p != NULL;
997
+ p = src.nodes_.Next(p)) {
998
+ nodes_.Lookup(p->key, p->hash, true);
999
+ }
1000
+ path_.AddAll(src.path_);
1001
+ }
1002
+ void Add(HeapGraphEdge* edge) {
1003
+ nodes_.Lookup(edge->to(), Hash(edge->to()), true);
1004
+ path_.Add(edge);
1005
+ }
1006
+ bool ContainsNode(HeapEntry* node) {
1007
+ return nodes_.Lookup(node, Hash(node), false) != NULL;
1008
+ }
1009
+ const List<HeapGraphEdge*>* path() const { return &path_; }
1010
+
1011
+ private:
1012
+ static uint32_t Hash(HeapEntry* entry) {
1013
+ return static_cast<uint32_t>(reinterpret_cast<intptr_t>(entry));
1014
+ }
1015
+ static bool NodesMatch(void* key1, void* key2) { return key1 == key2; }
1016
+
1017
+ HashMap nodes_;
1018
+ List<HeapGraphEdge*> path_;
1019
+ };
1020
+
1021
+
1022
+ const List<HeapGraphPath*>* HeapEntry::GetRetainingPaths() {
1023
+ if (retaining_paths_.length() == 0 && retainers_.length() != 0) {
1024
+ CachedHeapGraphPath path;
1025
+ FindRetainingPaths(this, &path);
1026
+ }
1027
+ return &retaining_paths_;
1028
+ }
1029
+
1030
+
1031
+ void HeapEntry::FindRetainingPaths(HeapEntry* node,
1032
+ CachedHeapGraphPath* prev_path) {
1033
+ for (int i = 0; i < node->retainers_.length(); ++i) {
1034
+ HeapGraphEdge* ret_edge = node->retainers_[i];
1035
+ if (prev_path->ContainsNode(ret_edge->from())) continue;
1036
+ if (ret_edge->from() != snapshot_->root()) {
1037
+ CachedHeapGraphPath path(*prev_path);
1038
+ path.Add(ret_edge);
1039
+ FindRetainingPaths(ret_edge->from(), &path);
1040
+ } else {
1041
+ HeapGraphPath* ret_path = new HeapGraphPath(*prev_path->path());
1042
+ ret_path->Set(0, ret_edge);
1043
+ retaining_paths_.Add(ret_path);
1044
+ }
1045
+ }
1046
+ }
1047
+
1048
+
1049
+ static void RemoveEdge(List<HeapGraphEdge*>* list, HeapGraphEdge* edge) {
1050
+ for (int i = 0; i < list->length(); ) {
1051
+ if (list->at(i) == edge) {
1052
+ list->Remove(i);
1053
+ return;
1054
+ } else {
1055
+ ++i;
1056
+ }
1057
+ }
1058
+ UNREACHABLE();
1059
+ }
1060
+
1061
+
1062
+ void HeapEntry::RemoveChild(HeapGraphEdge* edge) {
1063
+ RemoveEdge(&children_, edge);
1064
+ delete edge;
1065
+ }
1066
+
1067
+
1068
+ void HeapEntry::RemoveRetainer(HeapGraphEdge* edge) {
1069
+ RemoveEdge(&retainers_, edge);
1070
+ }
1071
+
1072
+
1073
+ void HeapEntry::CutEdges() {
1074
+ for (int i = 0; i < children_.length(); ++i) {
1075
+ HeapGraphEdge* edge = children_[i];
1076
+ edge->to()->RemoveRetainer(edge);
1077
+ }
1078
+ children_.Iterate(DeleteHeapGraphEdge);
1079
+ children_.Clear();
1080
+
1081
+ for (int i = 0; i < retainers_.length(); ++i) {
1082
+ HeapGraphEdge* edge = retainers_[i];
1083
+ edge->from()->RemoveChild(edge);
1084
+ }
1085
+ retainers_.Clear();
1086
+ }
1087
+
1088
+
1089
+ void HeapEntry::Print(int max_depth, int indent) {
1090
+ OS::Print("%6d %6d %6d [%ld] ",
1091
+ self_size_, TotalSize(), NonSharedTotalSize(), id_);
1092
+ if (type_ != STRING) {
1093
+ OS::Print("%s %.40s\n", TypeAsString(), name_);
1094
+ } else {
1095
+ OS::Print("\"");
1096
+ const char* c = name_;
1097
+ while (*c && (c - name_) <= 40) {
1098
+ if (*c != '\n')
1099
+ OS::Print("%c", *c);
1100
+ else
1101
+ OS::Print("\\n");
1102
+ ++c;
1103
+ }
1104
+ OS::Print("\"\n");
1105
+ }
1106
+ if (--max_depth == 0) return;
1107
+ const int children_count = children_.length();
1108
+ for (int i = 0; i < children_count; ++i) {
1109
+ HeapGraphEdge* edge = children_[i];
1110
+ switch (edge->type()) {
1111
+ case HeapGraphEdge::CONTEXT_VARIABLE:
1112
+ OS::Print(" %*c #%s: ", indent, ' ', edge->name());
1113
+ break;
1114
+ case HeapGraphEdge::ELEMENT:
1115
+ OS::Print(" %*c %d: ", indent, ' ', edge->index());
1116
+ break;
1117
+ case HeapGraphEdge::INTERNAL:
1118
+ OS::Print(" %*c $%s: ", indent, ' ', edge->name());
1119
+ break;
1120
+ case HeapGraphEdge::PROPERTY:
1121
+ OS::Print(" %*c %s: ", indent, ' ', edge->name());
1122
+ break;
1123
+ default:
1124
+ OS::Print("!!! unknown edge type: %d ", edge->type());
1125
+ }
1126
+ edge->to()->Print(max_depth, indent + 2);
1127
+ }
1128
+ }
1129
+
1130
+
1131
+ const char* HeapEntry::TypeAsString() {
1132
+ switch (type_) {
1133
+ case INTERNAL: return "/internal/";
1134
+ case OBJECT: return "/object/";
1135
+ case CLOSURE: return "/closure/";
1136
+ case STRING: return "/string/";
1137
+ case CODE: return "/code/";
1138
+ case ARRAY: return "/array/";
1139
+ default: return "???";
1140
+ }
1141
+ }
1142
+
1143
+
1144
+ HeapGraphPath::HeapGraphPath(const List<HeapGraphEdge*>& path)
1145
+ : path_(path.length() + 1) {
1146
+ Add(NULL);
1147
+ for (int i = path.length() - 1; i >= 0; --i) {
1148
+ Add(path[i]);
1149
+ }
1150
+ }
1151
+
1152
+
1153
+ void HeapGraphPath::Print() {
1154
+ path_[0]->from()->Print(1, 0);
1155
+ for (int i = 0; i < path_.length(); ++i) {
1156
+ OS::Print(" -> ");
1157
+ HeapGraphEdge* edge = path_[i];
1158
+ switch (edge->type()) {
1159
+ case HeapGraphEdge::CONTEXT_VARIABLE:
1160
+ OS::Print("[#%s] ", edge->name());
1161
+ break;
1162
+ case HeapGraphEdge::ELEMENT:
1163
+ OS::Print("[%d] ", edge->index());
1164
+ break;
1165
+ case HeapGraphEdge::INTERNAL:
1166
+ OS::Print("[$%s] ", edge->name());
1167
+ break;
1168
+ case HeapGraphEdge::PROPERTY:
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
+ class IndexedReferencesExtractor : public ObjectVisitor {
1181
+ public:
1182
+ IndexedReferencesExtractor(HeapSnapshot* snapshot, HeapEntry* parent)
1183
+ : snapshot_(snapshot),
1184
+ parent_(parent) {
1185
+ }
1186
+
1187
+ void VisitPointer(Object** o) {
1188
+ if (!(*o)->IsHeapObject()) return;
1189
+ HeapEntry* entry = snapshot_->GetEntry(HeapObject::cast(*o));
1190
+ if (entry != NULL) {
1191
+ parent_->SetAutoIndexReference(entry);
1192
+ }
1193
+ }
1194
+
1195
+ void VisitPointers(Object** start, Object** end) {
1196
+ for (Object** p = start; p < end; p++) VisitPointer(p);
1197
+ }
1198
+
1199
+ private:
1200
+ HeapSnapshot* snapshot_;
1201
+ HeapEntry* parent_;
1202
+ };
1203
+
1204
+
1205
+ HeapEntriesMap::HeapEntriesMap()
1206
+ : entries_(HeapObjectsMatch) {
1207
+ }
1208
+
1209
+
1210
+ HeapEntriesMap::~HeapEntriesMap() {
1211
+ for (HashMap::Entry* p = entries_.Start();
1212
+ p != NULL;
1213
+ p = entries_.Next(p)) {
1214
+ if (!IsAlias(p->value)) delete reinterpret_cast<HeapEntry*>(p->value);
1215
+ }
1216
+ }
1217
+
1218
+
1219
+ void HeapEntriesMap::Alias(HeapObject* object, HeapEntry* entry) {
1220
+ HashMap::Entry* cache_entry = entries_.Lookup(object, Hash(object), true);
1221
+ if (cache_entry->value == NULL)
1222
+ cache_entry->value = reinterpret_cast<void*>(
1223
+ reinterpret_cast<intptr_t>(entry) | kAliasTag);
1224
+ }
1225
+
1226
+
1227
+ void HeapEntriesMap::Apply(void (HeapEntry::*Func)(void)) {
1228
+ for (HashMap::Entry* p = entries_.Start();
1229
+ p != NULL;
1230
+ p = entries_.Next(p)) {
1231
+ if (!IsAlias(p->value)) (reinterpret_cast<HeapEntry*>(p->value)->*Func)();
1232
+ }
1233
+ }
1234
+
1235
+
1236
+ HeapEntry* HeapEntriesMap::Map(HeapObject* object) {
1237
+ HashMap::Entry* cache_entry = entries_.Lookup(object, Hash(object), false);
1238
+ return cache_entry != NULL ?
1239
+ reinterpret_cast<HeapEntry*>(
1240
+ reinterpret_cast<intptr_t>(cache_entry->value) & (~kAliasTag)) : NULL;
1241
+ }
1242
+
1243
+
1244
+ void HeapEntriesMap::Pair(HeapObject* object, HeapEntry* entry) {
1245
+ HashMap::Entry* cache_entry = entries_.Lookup(object, Hash(object), true);
1246
+ ASSERT(cache_entry->value == NULL);
1247
+ cache_entry->value = entry;
1248
+ }
1249
+
1250
+
1251
+ HeapSnapshot::HeapSnapshot(HeapSnapshotsCollection* collection,
1252
+ const char* title,
1253
+ unsigned uid)
1254
+ : collection_(collection),
1255
+ title_(title),
1256
+ uid_(uid),
1257
+ root_(this),
1258
+ sorted_entries_(NULL) {
1259
+ }
1260
+
1261
+
1262
+ HeapSnapshot::~HeapSnapshot() {
1263
+ delete sorted_entries_;
1264
+ }
1265
+
1266
+
1267
+ void HeapSnapshot::ClearPaint() {
1268
+ root_.ClearPaint();
1269
+ entries_.Apply(&HeapEntry::ClearPaint);
1270
+ }
1271
+
1272
+
1273
+ HeapEntry* HeapSnapshot::GetEntry(Object* obj) {
1274
+ if (!obj->IsHeapObject()) return NULL;
1275
+ HeapObject* object = HeapObject::cast(obj);
1276
+
1277
+ {
1278
+ HeapEntry* existing = FindEntry(object);
1279
+ if (existing != NULL) return existing;
1280
+ }
1281
+
1282
+ // Add new entry.
1283
+ if (object->IsJSFunction()) {
1284
+ JSFunction* func = JSFunction::cast(object);
1285
+ SharedFunctionInfo* shared = func->shared();
1286
+ String* name = String::cast(shared->name())->length() > 0 ?
1287
+ String::cast(shared->name()) : shared->inferred_name();
1288
+ return AddEntry(object, HeapEntry::CLOSURE, collection_->GetName(name));
1289
+ } else if (object->IsJSObject()) {
1290
+ return AddEntry(object,
1291
+ HeapEntry::OBJECT,
1292
+ collection_->GetName(
1293
+ JSObject::cast(object)->constructor_name()));
1294
+ } else if (object->IsJSGlobalPropertyCell()) {
1295
+ HeapEntry* value = GetEntry(JSGlobalPropertyCell::cast(object)->value());
1296
+ // If GPC references an object that we have interest in, add the object.
1297
+ // We don't store HeapEntries for GPCs. Instead, we make our hash map
1298
+ // to point to object's HeapEntry by GPCs address.
1299
+ if (value != NULL) AddEntryAlias(object, value);
1300
+ return value;
1301
+ } else if (object->IsString()) {
1302
+ return AddEntry(object,
1303
+ HeapEntry::STRING,
1304
+ collection_->GetName(String::cast(object)));
1305
+ } else if (object->IsCode()) {
1306
+ return AddEntry(object, HeapEntry::CODE);
1307
+ } else if (object->IsSharedFunctionInfo()) {
1308
+ SharedFunctionInfo* shared = SharedFunctionInfo::cast(object);
1309
+ String* name = String::cast(shared->name())->length() > 0 ?
1310
+ String::cast(shared->name()) : shared->inferred_name();
1311
+ return AddEntry(object, HeapEntry::CODE, collection_->GetName(name));
1312
+ } else if (object->IsScript()) {
1313
+ Script* script = Script::cast(object);
1314
+ return AddEntry(object,
1315
+ HeapEntry::CODE,
1316
+ script->name()->IsString() ?
1317
+ collection_->GetName(String::cast(script->name())) : "");
1318
+ } else if (object->IsFixedArray()) {
1319
+ return AddEntry(object, HeapEntry::ARRAY);
1320
+ }
1321
+ // No interest in this object.
1322
+ return NULL;
1323
+ }
1324
+
1325
+
1326
+ void HeapSnapshot::SetClosureReference(HeapEntry* parent,
1327
+ String* reference_name,
1328
+ Object* child) {
1329
+ HeapEntry* child_entry = GetEntry(child);
1330
+ if (child_entry != NULL) {
1331
+ parent->SetClosureReference(
1332
+ collection_->GetName(reference_name), child_entry);
1333
+ }
1334
+ }
1335
+
1336
+
1337
+ void HeapSnapshot::SetElementReference(HeapEntry* parent,
1338
+ int index,
1339
+ Object* child) {
1340
+ HeapEntry* child_entry = GetEntry(child);
1341
+ if (child_entry != NULL) {
1342
+ parent->SetElementReference(index, child_entry);
1343
+ }
1344
+ }
1345
+
1346
+
1347
+ void HeapSnapshot::SetInternalReference(HeapEntry* parent,
1348
+ const char* reference_name,
1349
+ Object* child) {
1350
+ HeapEntry* child_entry = GetEntry(child);
1351
+ if (child_entry != NULL) {
1352
+ parent->SetInternalReference(reference_name, child_entry);
1353
+ }
1354
+ }
1355
+
1356
+
1357
+ void HeapSnapshot::SetPropertyReference(HeapEntry* parent,
1358
+ String* reference_name,
1359
+ Object* child) {
1360
+ HeapEntry* child_entry = GetEntry(child);
1361
+ if (child_entry != NULL) {
1362
+ parent->SetPropertyReference(
1363
+ collection_->GetName(reference_name), child_entry);
1364
+ }
1365
+ }
1366
+
1367
+
1368
+ HeapEntry* HeapSnapshot::AddEntry(HeapObject* object,
1369
+ HeapEntry::Type type,
1370
+ const char* name) {
1371
+ HeapEntry* entry = new HeapEntry(this,
1372
+ type,
1373
+ name,
1374
+ collection_->GetObjectId(object->address()),
1375
+ GetObjectSize(object),
1376
+ GetObjectSecurityToken(object));
1377
+ entries_.Pair(object, entry);
1378
+
1379
+ // Detect, if this is a JS global object of the current context, and
1380
+ // add it to snapshot's roots. There can be several JS global objects
1381
+ // in a context.
1382
+ if (object->IsJSGlobalProxy()) {
1383
+ int global_security_token = GetGlobalSecurityToken();
1384
+ int object_security_token =
1385
+ collection_->token_enumerator()->GetTokenId(
1386
+ Context::cast(
1387
+ JSGlobalProxy::cast(object)->context())->security_token());
1388
+ if (object_security_token == TokenEnumerator::kNoSecurityToken
1389
+ || object_security_token == global_security_token) {
1390
+ HeapEntry* global_object_entry =
1391
+ GetEntry(HeapObject::cast(object->map()->prototype()));
1392
+ ASSERT(global_object_entry != NULL);
1393
+ root_.SetAutoIndexReference(global_object_entry);
1394
+ }
1395
+ }
1396
+
1397
+ return entry;
1398
+ }
1399
+
1400
+
1401
+ class EdgesCutter {
1402
+ public:
1403
+ explicit EdgesCutter(int global_security_token)
1404
+ : global_security_token_(global_security_token) {
1405
+ }
1406
+
1407
+ void Apply(HeapEntry* entry) {
1408
+ if (entry->security_token_id() != TokenEnumerator::kNoSecurityToken
1409
+ && entry->security_token_id() != global_security_token_) {
1410
+ entry->CutEdges();
1411
+ }
1412
+ }
1413
+
1414
+ private:
1415
+ const int global_security_token_;
1416
+ };
1417
+
1418
+ void HeapSnapshot::CutObjectsFromForeignSecurityContexts() {
1419
+ EdgesCutter cutter(GetGlobalSecurityToken());
1420
+ entries_.Apply(&cutter);
1421
+ }
1422
+
1423
+
1424
+ int HeapSnapshot::GetGlobalSecurityToken() {
1425
+ return collection_->token_enumerator()->GetTokenId(
1426
+ Top::context()->global()->global_context()->security_token());
1427
+ }
1428
+
1429
+
1430
+ int HeapSnapshot::GetObjectSize(HeapObject* obj) {
1431
+ return obj->IsJSObject() ?
1432
+ CalculateNetworkSize(JSObject::cast(obj)) : obj->Size();
1433
+ }
1434
+
1435
+
1436
+ int HeapSnapshot::GetObjectSecurityToken(HeapObject* obj) {
1437
+ if (obj->IsGlobalContext()) {
1438
+ return collection_->token_enumerator()->GetTokenId(
1439
+ Context::cast(obj)->security_token());
1440
+ } else {
1441
+ return TokenEnumerator::kNoSecurityToken;
1442
+ }
1443
+ }
1444
+
1445
+
1446
+ int HeapSnapshot::CalculateNetworkSize(JSObject* obj) {
1447
+ int size = obj->Size();
1448
+ // If 'properties' and 'elements' are non-empty (thus, non-shared),
1449
+ // take their size into account.
1450
+ if (FixedArray::cast(obj->properties())->length() != 0) {
1451
+ size += obj->properties()->Size();
1452
+ }
1453
+ if (FixedArray::cast(obj->elements())->length() != 0) {
1454
+ size += obj->elements()->Size();
1455
+ }
1456
+ // For functions, also account non-empty context and literals sizes.
1457
+ if (obj->IsJSFunction()) {
1458
+ JSFunction* f = JSFunction::cast(obj);
1459
+ if (f->unchecked_context()->IsContext()) {
1460
+ size += f->context()->Size();
1461
+ }
1462
+ if (f->literals()->length() != 0) {
1463
+ size += f->literals()->Size();
1464
+ }
1465
+ }
1466
+ return size;
1467
+ }
1468
+
1469
+
1470
+ class EntriesCollector {
1471
+ public:
1472
+ explicit EntriesCollector(List<HeapEntry*>* list) : list_(list) { }
1473
+ void Apply(HeapEntry* entry) {
1474
+ list_->Add(entry);
1475
+ }
1476
+ private:
1477
+ List<HeapEntry*>* list_;
1478
+ };
1479
+
1480
+ template<class T>
1481
+ static int SortByIds(const T* entry1_ptr,
1482
+ const T* entry2_ptr) {
1483
+ if ((*entry1_ptr)->id() == (*entry2_ptr)->id()) return 0;
1484
+ return (*entry1_ptr)->id() < (*entry2_ptr)->id() ? -1 : 1;
1485
+ }
1486
+
1487
+ List<HeapEntry*>* HeapSnapshot::GetSortedEntriesList() {
1488
+ if (sorted_entries_ != NULL) return sorted_entries_;
1489
+ sorted_entries_ = new List<HeapEntry*>(entries_.capacity());
1490
+ EntriesCollector collector(sorted_entries_);
1491
+ entries_.Apply(&collector);
1492
+ sorted_entries_->Sort(SortByIds);
1493
+ return sorted_entries_;
1494
+ }
1495
+
1496
+
1497
+ HeapSnapshotsDiff* HeapSnapshot::CompareWith(HeapSnapshot* snapshot) {
1498
+ return collection_->CompareSnapshots(this, snapshot);
1499
+ }
1500
+
1501
+
1502
+ void HeapSnapshot::Print(int max_depth) {
1503
+ root_.Print(max_depth, 0);
1504
+ }
1505
+
1506
+
1507
+ HeapObjectsMap::HeapObjectsMap()
1508
+ : initial_fill_mode_(true),
1509
+ next_id_(1),
1510
+ entries_map_(AddressesMatch),
1511
+ entries_(new List<EntryInfo>()) { }
1512
+
1513
+
1514
+ HeapObjectsMap::~HeapObjectsMap() {
1515
+ delete entries_;
1516
+ }
1517
+
1518
+
1519
+ void HeapObjectsMap::SnapshotGenerationFinished() {
1520
+ initial_fill_mode_ = false;
1521
+ RemoveDeadEntries();
1522
+ }
1523
+
1524
+
1525
+ uint64_t HeapObjectsMap::FindObject(Address addr) {
1526
+ if (!initial_fill_mode_) {
1527
+ uint64_t existing = FindEntry(addr);
1528
+ if (existing != 0) return existing;
1529
+ }
1530
+ uint64_t id = next_id_++;
1531
+ AddEntry(addr, id);
1532
+ return id;
1533
+ }
1534
+
1535
+
1536
+ void HeapObjectsMap::MoveObject(Address from, Address to) {
1537
+ if (from == to) return;
1538
+ HashMap::Entry* entry = entries_map_.Lookup(from, AddressHash(from), false);
1539
+ if (entry != NULL) {
1540
+ void* value = entry->value;
1541
+ entries_map_.Remove(from, AddressHash(from));
1542
+ entry = entries_map_.Lookup(to, AddressHash(to), true);
1543
+ // We can have an entry at the new location, it is OK, as GC can overwrite
1544
+ // dead objects with alive objects being moved.
1545
+ entry->value = value;
1546
+ }
1547
+ }
1548
+
1549
+
1550
+ void HeapObjectsMap::AddEntry(Address addr, uint64_t id) {
1551
+ HashMap::Entry* entry = entries_map_.Lookup(addr, AddressHash(addr), true);
1552
+ ASSERT(entry->value == NULL);
1553
+ entry->value = reinterpret_cast<void*>(entries_->length());
1554
+ entries_->Add(EntryInfo(id));
1555
+ }
1556
+
1557
+
1558
+ uint64_t HeapObjectsMap::FindEntry(Address addr) {
1559
+ HashMap::Entry* entry = entries_map_.Lookup(addr, AddressHash(addr), false);
1560
+ if (entry != NULL) {
1561
+ int entry_index =
1562
+ static_cast<int>(reinterpret_cast<intptr_t>(entry->value));
1563
+ EntryInfo& entry_info = entries_->at(entry_index);
1564
+ entry_info.accessed = true;
1565
+ return entry_info.id;
1566
+ } else {
1567
+ return 0;
1568
+ }
1569
+ }
1570
+
1571
+
1572
+ void HeapObjectsMap::RemoveDeadEntries() {
1573
+ List<EntryInfo>* new_entries = new List<EntryInfo>();
1574
+ for (HashMap::Entry* entry = entries_map_.Start();
1575
+ entry != NULL;
1576
+ entry = entries_map_.Next(entry)) {
1577
+ int entry_index =
1578
+ static_cast<int>(reinterpret_cast<intptr_t>(entry->value));
1579
+ EntryInfo& entry_info = entries_->at(entry_index);
1580
+ if (entry_info.accessed) {
1581
+ entry->value = reinterpret_cast<void*>(new_entries->length());
1582
+ new_entries->Add(EntryInfo(entry_info.id, false));
1583
+ }
1584
+ }
1585
+ delete entries_;
1586
+ entries_ = new_entries;
1587
+ }
1588
+
1589
+
1590
+ HeapSnapshotsCollection::HeapSnapshotsCollection()
1591
+ : is_tracking_objects_(false),
1592
+ snapshots_uids_(HeapSnapshotsMatch),
1593
+ token_enumerator_(new TokenEnumerator()) {
1594
+ }
1595
+
1596
+
1597
+ static void DeleteHeapSnapshot(HeapSnapshot** snapshot_ptr) {
1598
+ delete *snapshot_ptr;
1599
+ }
1600
+
1601
+
1602
+ HeapSnapshotsCollection::~HeapSnapshotsCollection() {
1603
+ delete token_enumerator_;
1604
+ snapshots_.Iterate(DeleteHeapSnapshot);
1605
+ }
1606
+
1607
+
1608
+ HeapSnapshot* HeapSnapshotsCollection::NewSnapshot(const char* name,
1609
+ unsigned uid) {
1610
+ is_tracking_objects_ = true; // Start watching for heap objects moves.
1611
+ HeapSnapshot* snapshot = new HeapSnapshot(this, name, uid);
1612
+ snapshots_.Add(snapshot);
1613
+ HashMap::Entry* entry =
1614
+ snapshots_uids_.Lookup(reinterpret_cast<void*>(snapshot->uid()),
1615
+ static_cast<uint32_t>(snapshot->uid()),
1616
+ true);
1617
+ ASSERT(entry->value == NULL);
1618
+ entry->value = snapshot;
1619
+ return snapshot;
1620
+ }
1621
+
1622
+
1623
+ HeapSnapshot* HeapSnapshotsCollection::GetSnapshot(unsigned uid) {
1624
+ HashMap::Entry* entry = snapshots_uids_.Lookup(reinterpret_cast<void*>(uid),
1625
+ static_cast<uint32_t>(uid),
1626
+ false);
1627
+ return entry != NULL ? reinterpret_cast<HeapSnapshot*>(entry->value) : NULL;
1628
+ }
1629
+
1630
+
1631
+ HeapSnapshotsDiff* HeapSnapshotsCollection::CompareSnapshots(
1632
+ HeapSnapshot* snapshot1,
1633
+ HeapSnapshot* snapshot2) {
1634
+ return comparator_.Compare(snapshot1, snapshot2);
1635
+ }
1636
+
1637
+
1638
+ HeapSnapshotGenerator::HeapSnapshotGenerator(HeapSnapshot* snapshot)
1639
+ : snapshot_(snapshot) {
1640
+ }
1641
+
1642
+
1643
+ void HeapSnapshotGenerator::GenerateSnapshot() {
1644
+ AssertNoAllocation no_alloc;
1645
+
1646
+ // Iterate heap contents.
1647
+ HeapIterator iterator;
1648
+ for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) {
1649
+ ExtractReferences(obj);
1650
+ }
1651
+
1652
+ snapshot_->CutObjectsFromForeignSecurityContexts();
1653
+ }
1654
+
1655
+
1656
+ void HeapSnapshotGenerator::ExtractReferences(HeapObject* obj) {
1657
+ HeapEntry* entry = snapshot_->GetEntry(obj);
1658
+ if (entry == NULL) return;
1659
+ if (entry->visited()) return;
1660
+
1661
+ if (obj->IsJSObject()) {
1662
+ JSObject* js_obj = JSObject::cast(obj);
1663
+ ExtractClosureReferences(js_obj, entry);
1664
+ ExtractPropertyReferences(js_obj, entry);
1665
+ ExtractElementReferences(js_obj, entry);
1666
+ snapshot_->SetPropertyReference(
1667
+ entry, Heap::prototype_symbol(), js_obj->map()->prototype());
1668
+ } else if (obj->IsJSGlobalPropertyCell()) {
1669
+ JSGlobalPropertyCell* cell = JSGlobalPropertyCell::cast(obj);
1670
+ snapshot_->SetElementReference(entry, 0, cell->value());
1671
+ } else if (obj->IsString()) {
1672
+ if (obj->IsConsString()) {
1673
+ ConsString* cs = ConsString::cast(obj);
1674
+ snapshot_->SetElementReference(entry, 0, cs->first());
1675
+ snapshot_->SetElementReference(entry, 1, cs->second());
1676
+ }
1677
+ } else if (obj->IsCode() || obj->IsSharedFunctionInfo() || obj->IsScript()) {
1678
+ IndexedReferencesExtractor refs_extractor(snapshot_, entry);
1679
+ obj->Iterate(&refs_extractor);
1680
+ } else if (obj->IsFixedArray()) {
1681
+ IndexedReferencesExtractor refs_extractor(snapshot_, entry);
1682
+ obj->Iterate(&refs_extractor);
1683
+ }
1684
+ entry->MarkAsVisited();
1685
+ }
1686
+
1687
+
1688
+ void HeapSnapshotGenerator::ExtractClosureReferences(JSObject* js_obj,
1689
+ HeapEntry* entry) {
1690
+ if (js_obj->IsJSFunction()) {
1691
+ HandleScope hs;
1692
+ JSFunction* func = JSFunction::cast(js_obj);
1693
+ Context* context = func->context();
1694
+ ZoneScope zscope(DELETE_ON_EXIT);
1695
+ SerializedScopeInfo* serialized_scope_info =
1696
+ context->closure()->shared()->scope_info();
1697
+ ScopeInfo<ZoneListAllocationPolicy> zone_scope_info(serialized_scope_info);
1698
+ int locals_number = zone_scope_info.NumberOfLocals();
1699
+ for (int i = 0; i < locals_number; ++i) {
1700
+ String* local_name = *zone_scope_info.LocalName(i);
1701
+ int idx = serialized_scope_info->ContextSlotIndex(local_name, NULL);
1702
+ if (idx >= 0 && idx < context->length()) {
1703
+ snapshot_->SetClosureReference(entry, local_name, context->get(idx));
1704
+ }
1705
+ }
1706
+ snapshot_->SetInternalReference(entry, "code", func->shared());
1707
+ }
1708
+ }
1709
+
1710
+
1711
+ void HeapSnapshotGenerator::ExtractPropertyReferences(JSObject* js_obj,
1712
+ HeapEntry* entry) {
1713
+ if (js_obj->HasFastProperties()) {
1714
+ DescriptorArray* descs = js_obj->map()->instance_descriptors();
1715
+ for (int i = 0; i < descs->number_of_descriptors(); i++) {
1716
+ switch (descs->GetType(i)) {
1717
+ case FIELD: {
1718
+ int index = descs->GetFieldIndex(i);
1719
+ snapshot_->SetPropertyReference(
1720
+ entry, descs->GetKey(i), js_obj->FastPropertyAt(index));
1721
+ break;
1722
+ }
1723
+ case CONSTANT_FUNCTION:
1724
+ snapshot_->SetPropertyReference(
1725
+ entry, descs->GetKey(i), descs->GetConstantFunction(i));
1726
+ break;
1727
+ default: ;
1728
+ }
1729
+ }
1730
+ } else {
1731
+ StringDictionary* dictionary = js_obj->property_dictionary();
1732
+ int length = dictionary->Capacity();
1733
+ for (int i = 0; i < length; ++i) {
1734
+ Object* k = dictionary->KeyAt(i);
1735
+ if (dictionary->IsKey(k)) {
1736
+ snapshot_->SetPropertyReference(
1737
+ entry, String::cast(k), dictionary->ValueAt(i));
1738
+ }
1739
+ }
1740
+ }
1741
+ }
1742
+
1743
+
1744
+ void HeapSnapshotGenerator::ExtractElementReferences(JSObject* js_obj,
1745
+ HeapEntry* entry) {
1746
+ if (js_obj->HasFastElements()) {
1747
+ FixedArray* elements = FixedArray::cast(js_obj->elements());
1748
+ int length = js_obj->IsJSArray() ?
1749
+ Smi::cast(JSArray::cast(js_obj)->length())->value() :
1750
+ elements->length();
1751
+ for (int i = 0; i < length; ++i) {
1752
+ if (!elements->get(i)->IsTheHole()) {
1753
+ snapshot_->SetElementReference(entry, i, elements->get(i));
1754
+ }
1755
+ }
1756
+ } else if (js_obj->HasDictionaryElements()) {
1757
+ NumberDictionary* dictionary = js_obj->element_dictionary();
1758
+ int length = dictionary->Capacity();
1759
+ for (int i = 0; i < length; ++i) {
1760
+ Object* k = dictionary->KeyAt(i);
1761
+ if (dictionary->IsKey(k)) {
1762
+ ASSERT(k->IsNumber());
1763
+ uint32_t index = static_cast<uint32_t>(k->Number());
1764
+ snapshot_->SetElementReference(entry, index, dictionary->ValueAt(i));
1765
+ }
1766
+ }
1767
+ }
1768
+ }
1769
+
1770
+
1771
+ static void DeleteHeapSnapshotsDiff(HeapSnapshotsDiff** diff_ptr) {
1772
+ delete *diff_ptr;
1773
+ }
1774
+
1775
+ HeapSnapshotsComparator::~HeapSnapshotsComparator() {
1776
+ diffs_.Iterate(DeleteHeapSnapshotsDiff);
1777
+ }
1778
+
1779
+
1780
+ HeapSnapshotsDiff* HeapSnapshotsComparator::Compare(HeapSnapshot* snapshot1,
1781
+ HeapSnapshot* snapshot2) {
1782
+ HeapSnapshotsDiff* diff = new HeapSnapshotsDiff(snapshot1, snapshot2);
1783
+ diffs_.Add(diff);
1784
+ List<HeapEntry*>* entries1 = snapshot1->GetSortedEntriesList();
1785
+ List<HeapEntry*>* entries2 = snapshot2->GetSortedEntriesList();
1786
+ int i = 0, j = 0;
1787
+ List<HeapEntry*> added_entries, deleted_entries;
1788
+ while (i < entries1->length() && j < entries2->length()) {
1789
+ uint64_t id1 = entries1->at(i)->id();
1790
+ uint64_t id2 = entries2->at(j)->id();
1791
+ if (id1 == id2) {
1792
+ i++;
1793
+ j++;
1794
+ } else if (id1 < id2) {
1795
+ HeapEntry* entry = entries1->at(i++);
1796
+ deleted_entries.Add(entry);
1797
+ } else {
1798
+ HeapEntry* entry = entries2->at(j++);
1799
+ added_entries.Add(entry);
1800
+ }
1801
+ }
1802
+ while (i < entries1->length()) {
1803
+ HeapEntry* entry = entries1->at(i++);
1804
+ deleted_entries.Add(entry);
1805
+ }
1806
+ while (j < entries2->length()) {
1807
+ HeapEntry* entry = entries2->at(j++);
1808
+ added_entries.Add(entry);
1809
+ }
1810
+
1811
+ snapshot1->ClearPaint();
1812
+ snapshot1->root()->PaintAllReachable();
1813
+ for (int i = 0; i < deleted_entries.length(); ++i) {
1814
+ HeapEntry* entry = deleted_entries[i];
1815
+ if (entry->painted_reachable())
1816
+ diff->AddDeletedEntry(entry);
1817
+ }
1818
+ snapshot2->ClearPaint();
1819
+ snapshot2->root()->PaintAllReachable();
1820
+ for (int i = 0; i < added_entries.length(); ++i) {
1821
+ HeapEntry* entry = added_entries[i];
1822
+ if (entry->painted_reachable())
1823
+ diff->AddAddedEntry(entry);
1824
+ }
1825
+ return diff;
1826
+ }
1827
+
1828
+ } } // namespace v8::internal
1829
+
1830
+ #endif // ENABLE_LOGGING_AND_PROFILING