therubyracer 0.6.3 → 0.7.0.pre

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 (520) hide show
  1. data/Rakefile +10 -9
  2. data/ext/v8/callbacks.cpp +15 -8
  3. data/ext/v8/converters.cpp +7 -8
  4. data/ext/v8/converters.h +0 -2
  5. data/ext/v8/extconf.rb +2 -0
  6. data/ext/v8/rr.cpp +169 -0
  7. data/ext/v8/rr.h +34 -0
  8. data/ext/v8/upstream/{2.0.6 → 2.1.10}/AUTHORS +8 -1
  9. data/ext/v8/upstream/{2.0.6 → 2.1.10}/ChangeLog +198 -0
  10. data/ext/v8/upstream/{2.0.6 → 2.1.10}/LICENSE +0 -0
  11. data/ext/v8/upstream/{2.0.6 → 2.1.10}/SConstruct +152 -38
  12. data/ext/v8/upstream/{2.0.6 → 2.1.10}/include/v8-debug.h +52 -4
  13. data/ext/v8/upstream/2.1.10/include/v8-profiler.h +176 -0
  14. data/ext/v8/upstream/{2.0.6 → 2.1.10}/include/v8.h +227 -48
  15. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/SConscript +60 -10
  16. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/accessors.cc +5 -39
  17. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/accessors.h +0 -0
  18. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/allocation.cc +0 -0
  19. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/allocation.h +0 -0
  20. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/api.cc +477 -57
  21. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/api.h +8 -4
  22. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/apinatives.js +1 -1
  23. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/apiutils.h +0 -0
  24. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arguments.h +5 -6
  25. data/ext/v8/upstream/{2.0.6/src/arm/assembler-thumb2-inl.h → 2.1.10/src/arm/assembler-arm-inl.h} +42 -27
  26. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/assembler-arm.cc +430 -216
  27. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/assembler-arm.h +199 -110
  28. data/ext/v8/upstream/{2.0.6/src/arm/assembler-arm-inl.h → 2.1.10/src/arm/assembler-thumb2-inl.h} +4 -18
  29. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/assembler-thumb2.cc +142 -85
  30. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/assembler-thumb2.h +18 -9
  31. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/builtins-arm.cc +127 -87
  32. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/codegen-arm-inl.h +3 -5
  33. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/codegen-arm.cc +4634 -1427
  34. data/ext/v8/upstream/2.1.10/src/arm/codegen-arm.h +946 -0
  35. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/constants-arm.cc +21 -3
  36. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/constants-arm.h +39 -13
  37. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/cpu-arm.cc +9 -3
  38. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/debug-arm.cc +34 -8
  39. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/disasm-arm.cc +262 -117
  40. data/ext/v8/upstream/2.1.10/src/arm/fast-codegen-arm.cc +238 -0
  41. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/frames-arm.cc +0 -0
  42. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/frames-arm.h +0 -0
  43. data/ext/v8/upstream/{2.0.6/src/arm/fast-codegen-arm.cc → 2.1.10/src/arm/full-codegen-arm.cc} +453 -283
  44. data/ext/v8/upstream/2.1.10/src/arm/ic-arm.cc +1833 -0
  45. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/jump-target-arm.cc +3 -29
  46. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/macro-assembler-arm.cc +564 -104
  47. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/macro-assembler-arm.h +255 -46
  48. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/regexp-macro-assembler-arm.cc +78 -104
  49. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/regexp-macro-assembler-arm.h +6 -22
  50. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/register-allocator-arm-inl.h +0 -3
  51. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/register-allocator-arm.cc +0 -0
  52. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/register-allocator-arm.h +2 -1
  53. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/simulator-arm.cc +557 -180
  54. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/simulator-arm.h +52 -4
  55. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/arm/stub-cache-arm.cc +904 -240
  56. data/ext/v8/upstream/2.1.10/src/arm/virtual-frame-arm.cc +668 -0
  57. data/ext/v8/upstream/2.1.10/src/arm/virtual-frame-arm.h +503 -0
  58. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/array.js +82 -109
  59. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/assembler.cc +49 -13
  60. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/assembler.h +27 -5
  61. data/ext/v8/upstream/2.1.10/src/ast.cc +1138 -0
  62. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ast.h +354 -53
  63. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/bootstrapper.cc +609 -501
  64. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/bootstrapper.h +27 -8
  65. data/ext/v8/upstream/2.1.10/src/builtins.cc +1512 -0
  66. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/builtins.h +41 -25
  67. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/bytecodes-irregexp.h +0 -0
  68. data/ext/v8/upstream/2.1.10/src/cached-powers.h +119 -0
  69. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/char-predicates-inl.h +0 -0
  70. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/char-predicates.h +0 -0
  71. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/checks.cc +0 -0
  72. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/checks.h +25 -1
  73. data/ext/v8/upstream/2.1.10/src/circular-queue-inl.h +101 -0
  74. data/ext/v8/upstream/2.1.10/src/circular-queue.cc +121 -0
  75. data/ext/v8/upstream/2.1.10/src/circular-queue.h +129 -0
  76. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/code-stubs.cc +23 -8
  77. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/code-stubs.h +16 -4
  78. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/code.h +0 -0
  79. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/codegen-inl.h +6 -34
  80. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/codegen.cc +73 -92
  81. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/codegen.h +164 -68
  82. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/compilation-cache.cc +117 -73
  83. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/compilation-cache.h +18 -17
  84. data/ext/v8/upstream/2.1.10/src/compiler.cc +623 -0
  85. data/ext/v8/upstream/2.1.10/src/compiler.h +299 -0
  86. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/contexts.cc +0 -0
  87. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/contexts.h +8 -11
  88. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/conversions-inl.h +28 -13
  89. data/ext/v8/upstream/2.1.10/src/conversions.cc +1105 -0
  90. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/conversions.h +9 -4
  91. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/counters.cc +0 -0
  92. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/counters.h +1 -1
  93. data/ext/v8/upstream/2.1.10/src/cpu-profiler-inl.h +99 -0
  94. data/ext/v8/upstream/2.1.10/src/cpu-profiler.cc +494 -0
  95. data/ext/v8/upstream/2.1.10/src/cpu-profiler.h +277 -0
  96. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/cpu.h +0 -0
  97. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/d8-debug.cc +15 -4
  98. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/d8-debug.h +0 -0
  99. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/d8-posix.cc +18 -0
  100. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/d8-readline.cc +2 -2
  101. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/d8-windows.cc +0 -0
  102. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/d8.cc +10 -6
  103. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/d8.h +2 -0
  104. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/d8.js +43 -38
  105. data/ext/v8/upstream/2.1.10/src/data-flow.cc +755 -0
  106. data/ext/v8/upstream/2.1.10/src/data-flow.h +278 -0
  107. data/ext/v8/upstream/{2.0.6/src/date-delay.js → 2.1.10/src/date.js} +100 -110
  108. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/dateparser-inl.h +11 -2
  109. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/dateparser.cc +24 -26
  110. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/dateparser.h +8 -4
  111. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/debug-agent.cc +3 -1
  112. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/debug-agent.h +0 -0
  113. data/ext/v8/upstream/{2.0.6/src/debug-delay.js → 2.1.10/src/debug-debugger.js} +111 -15
  114. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/debug.cc +156 -96
  115. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/debug.h +53 -5
  116. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/disasm.h +0 -0
  117. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/disassembler.cc +2 -8
  118. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/disassembler.h +0 -0
  119. data/ext/v8/upstream/2.1.10/src/diy-fp.cc +58 -0
  120. data/ext/v8/upstream/2.1.10/src/diy-fp.h +117 -0
  121. data/ext/v8/upstream/2.1.10/src/double.h +169 -0
  122. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/dtoa-config.c +4 -3
  123. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/execution.cc +22 -22
  124. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/execution.h +17 -4
  125. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/factory.cc +70 -46
  126. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/factory.h +27 -17
  127. data/ext/v8/upstream/2.1.10/src/fast-codegen.cc +746 -0
  128. data/ext/v8/upstream/2.1.10/src/fast-codegen.h +161 -0
  129. data/ext/v8/upstream/2.1.10/src/fast-dtoa.cc +512 -0
  130. data/ext/v8/upstream/2.1.10/src/fast-dtoa.h +59 -0
  131. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/flag-definitions.h +32 -11
  132. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/flags.cc +0 -0
  133. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/flags.h +0 -0
  134. data/ext/v8/upstream/2.1.10/src/flow-graph.cc +763 -0
  135. data/ext/v8/upstream/2.1.10/src/flow-graph.h +180 -0
  136. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/frame-element.cc +1 -4
  137. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/frame-element.h +49 -11
  138. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/frames-inl.h +2 -0
  139. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/frames.cc +91 -17
  140. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/frames.h +24 -2
  141. data/ext/v8/upstream/{2.0.6/src/fast-codegen.cc → 2.1.10/src/full-codegen.cc} +549 -198
  142. data/ext/v8/upstream/{2.0.6/src/fast-codegen.h → 2.1.10/src/full-codegen.h} +109 -29
  143. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/func-name-inferrer.cc +0 -0
  144. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/func-name-inferrer.h +0 -0
  145. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/global-handles.cc +0 -0
  146. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/global-handles.h +0 -0
  147. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/globals.h +67 -43
  148. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/handles-inl.h +0 -0
  149. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/handles.cc +124 -129
  150. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/handles.h +33 -15
  151. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/hashmap.cc +0 -0
  152. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/hashmap.h +0 -0
  153. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/heap-inl.h +56 -12
  154. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/heap-profiler.cc +2 -2
  155. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/heap-profiler.h +2 -0
  156. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/heap.cc +413 -221
  157. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/heap.h +192 -67
  158. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/assembler-ia32-inl.h +6 -0
  159. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/assembler-ia32.cc +187 -32
  160. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/assembler-ia32.h +31 -4
  161. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/builtins-ia32.cc +160 -133
  162. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/codegen-ia32-inl.h +0 -0
  163. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/codegen-ia32.cc +5533 -2177
  164. data/ext/v8/upstream/{2.0.6/src/x64/codegen-x64.h → 2.1.10/src/ia32/codegen-ia32.h} +453 -134
  165. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/cpu-ia32.cc +0 -0
  166. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/debug-ia32.cc +63 -8
  167. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/disasm-ia32.cc +99 -16
  168. data/ext/v8/upstream/2.1.10/src/ia32/fast-codegen-ia32.cc +950 -0
  169. data/ext/v8/upstream/2.1.10/src/ia32/fast-codegen-ia32.h +155 -0
  170. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/frames-ia32.cc +0 -0
  171. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/frames-ia32.h +0 -0
  172. data/ext/v8/upstream/{2.0.6/src/ia32/fast-codegen-ia32.cc → 2.1.10/src/ia32/full-codegen-ia32.cc} +454 -253
  173. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/ic-ia32.cc +545 -390
  174. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/jump-target-ia32.cc +1 -0
  175. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/macro-assembler-ia32.cc +330 -139
  176. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/macro-assembler-ia32.h +96 -30
  177. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/regexp-macro-assembler-ia32.cc +73 -89
  178. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/regexp-macro-assembler-ia32.h +6 -21
  179. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/register-allocator-ia32-inl.h +0 -0
  180. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/register-allocator-ia32.cc +59 -5
  181. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/register-allocator-ia32.h +0 -0
  182. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/simulator-ia32.cc +0 -0
  183. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/simulator-ia32.h +2 -2
  184. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/stub-cache-ia32.cc +745 -303
  185. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/virtual-frame-ia32.cc +278 -71
  186. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ia32/virtual-frame-ia32.h +78 -22
  187. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ic-inl.h +0 -0
  188. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ic.cc +172 -89
  189. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/ic.h +51 -20
  190. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/interpreter-irregexp.cc +0 -0
  191. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/interpreter-irregexp.h +0 -0
  192. data/ext/v8/upstream/{2.0.6/src/json-delay.js → 2.1.10/src/json.js} +26 -12
  193. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/jsregexp.cc +151 -118
  194. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/jsregexp.h +31 -7
  195. data/ext/v8/upstream/2.1.10/src/jump-target-heavy-inl.h +51 -0
  196. data/ext/v8/upstream/{2.0.6/src/jump-target.cc → 2.1.10/src/jump-target-heavy.cc} +164 -184
  197. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/jump-target-inl.h +8 -9
  198. data/ext/v8/upstream/{2.0.6/src/usage-analyzer.h → 2.1.10/src/jump-target-light-inl.h} +9 -7
  199. data/ext/v8/upstream/2.1.10/src/jump-target-light.cc +86 -0
  200. data/ext/v8/upstream/2.1.10/src/jump-target.cc +155 -0
  201. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/jump-target.h +6 -0
  202. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/list-inl.h +0 -0
  203. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/list.h +2 -1
  204. data/ext/v8/upstream/2.1.10/src/liveedit-debugger.js +944 -0
  205. data/ext/v8/upstream/2.1.10/src/liveedit.cc +1468 -0
  206. data/ext/v8/upstream/2.1.10/src/liveedit.h +170 -0
  207. data/ext/v8/upstream/2.1.10/src/log-inl.h +59 -0
  208. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/log-utils.cc +3 -9
  209. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/log-utils.h +1 -4
  210. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/log.cc +198 -95
  211. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/log.h +50 -49
  212. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/macro-assembler.h +9 -0
  213. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/macros.py +30 -11
  214. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/mark-compact.cc +464 -152
  215. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/mark-compact.h +41 -20
  216. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/math.js +9 -8
  217. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/memory.h +0 -0
  218. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/messages.cc +1 -0
  219. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/messages.h +0 -0
  220. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/messages.js +46 -9
  221. data/ext/v8/upstream/2.1.10/src/mips/assembler-mips-inl.h +215 -0
  222. data/ext/v8/upstream/2.1.10/src/mips/assembler-mips.cc +1208 -0
  223. data/ext/v8/upstream/2.1.10/src/mips/assembler-mips.h +665 -0
  224. data/ext/v8/upstream/2.1.10/src/mips/builtins-mips.cc +202 -0
  225. data/ext/v8/upstream/2.1.10/src/mips/codegen-mips-inl.h +70 -0
  226. data/ext/v8/upstream/2.1.10/src/mips/codegen-mips.cc +1428 -0
  227. data/ext/v8/upstream/{2.0.6/src/arm/codegen-arm.h → 2.1.10/src/mips/codegen-mips.h} +103 -205
  228. data/ext/v8/upstream/2.1.10/src/mips/constants-mips.cc +323 -0
  229. data/ext/v8/upstream/2.1.10/src/mips/constants-mips.h +525 -0
  230. data/ext/v8/upstream/2.1.10/src/mips/cpu-mips.cc +69 -0
  231. data/ext/v8/upstream/2.1.10/src/mips/debug-mips.cc +128 -0
  232. data/ext/v8/upstream/2.1.10/src/mips/disasm-mips.cc +784 -0
  233. data/ext/v8/upstream/2.1.10/src/mips/fast-codegen-mips.cc +74 -0
  234. data/ext/v8/upstream/2.1.10/src/mips/frames-mips.cc +99 -0
  235. data/ext/v8/upstream/2.1.10/src/mips/frames-mips.h +164 -0
  236. data/ext/v8/upstream/2.1.10/src/mips/full-codegen-mips.cc +273 -0
  237. data/ext/v8/upstream/2.1.10/src/mips/ic-mips.cc +217 -0
  238. data/ext/v8/upstream/2.1.10/src/mips/jump-target-mips.cc +172 -0
  239. data/ext/v8/upstream/2.1.10/src/mips/macro-assembler-mips.cc +1323 -0
  240. data/ext/v8/upstream/2.1.10/src/mips/macro-assembler-mips.h +461 -0
  241. data/ext/v8/upstream/2.1.10/src/mips/register-allocator-mips-inl.h +137 -0
  242. data/ext/v8/upstream/2.1.10/src/mips/register-allocator-mips.cc +60 -0
  243. data/ext/v8/upstream/2.1.10/src/mips/register-allocator-mips.h +46 -0
  244. data/ext/v8/upstream/2.1.10/src/mips/simulator-mips.cc +1648 -0
  245. data/ext/v8/upstream/2.1.10/src/mips/simulator-mips.h +311 -0
  246. data/ext/v8/upstream/2.1.10/src/mips/stub-cache-mips.cc +400 -0
  247. data/ext/v8/upstream/2.1.10/src/mips/virtual-frame-mips.cc +316 -0
  248. data/ext/v8/upstream/{2.0.6/src/arm/virtual-frame-arm.h → 2.1.10/src/mips/virtual-frame-mips.h} +87 -71
  249. data/ext/v8/upstream/{2.0.6/src/mirror-delay.js → 2.1.10/src/mirror-debugger.js} +51 -45
  250. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/mksnapshot.cc +97 -10
  251. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/natives.h +6 -6
  252. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/objects-debug.cc +47 -5
  253. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/objects-inl.h +154 -38
  254. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/objects.cc +528 -280
  255. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/objects.h +302 -95
  256. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/oprofile-agent.cc +25 -33
  257. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/oprofile-agent.h +9 -1
  258. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/parser.cc +444 -72
  259. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/parser.h +4 -2
  260. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/platform-freebsd.cc +32 -13
  261. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/platform-linux.cc +59 -25
  262. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/platform-macos.cc +30 -13
  263. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/platform-nullos.cc +0 -0
  264. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/platform-openbsd.cc +21 -2
  265. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/platform-posix.cc +0 -18
  266. data/ext/v8/upstream/2.1.10/src/platform-solaris.cc +607 -0
  267. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/platform-win32.cc +16 -17
  268. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/platform.h +25 -8
  269. data/ext/v8/upstream/2.1.10/src/powers-ten.h +2461 -0
  270. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/prettyprinter.cc +49 -29
  271. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/prettyprinter.h +3 -1
  272. data/ext/v8/upstream/2.1.10/src/profile-generator-inl.h +124 -0
  273. data/ext/v8/upstream/2.1.10/src/profile-generator.cc +583 -0
  274. data/ext/v8/upstream/2.1.10/src/profile-generator.h +364 -0
  275. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/property.cc +1 -1
  276. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/property.h +12 -24
  277. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/regexp-macro-assembler-irregexp-inl.h +2 -2
  278. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/regexp-macro-assembler-irregexp.cc +2 -2
  279. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/regexp-macro-assembler-irregexp.h +2 -2
  280. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/regexp-macro-assembler-tracer.cc +2 -2
  281. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/regexp-macro-assembler-tracer.h +0 -0
  282. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/regexp-macro-assembler.cc +33 -10
  283. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/regexp-macro-assembler.h +12 -4
  284. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/regexp-stack.cc +0 -0
  285. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/regexp-stack.h +0 -0
  286. data/ext/v8/upstream/{2.0.6/src/regexp-delay.js → 2.1.10/src/regexp.js} +180 -58
  287. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/register-allocator-inl.h +68 -1
  288. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/register-allocator.cc +5 -2
  289. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/register-allocator.h +42 -17
  290. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/rewriter.cc +110 -4
  291. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/rewriter.h +0 -0
  292. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/runtime.cc +2733 -623
  293. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/runtime.h +43 -20
  294. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/runtime.js +46 -35
  295. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/scanner.cc +278 -36
  296. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/scanner.h +97 -26
  297. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/scopeinfo.cc +3 -3
  298. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/scopeinfo.h +1 -0
  299. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/scopes.cc +11 -12
  300. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/scopes.h +0 -1
  301. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/serialize.cc +298 -175
  302. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/serialize.h +184 -40
  303. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/shell.h +0 -0
  304. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/simulator.h +2 -0
  305. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/smart-pointer.h +0 -0
  306. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/snapshot-common.cc +16 -31
  307. data/ext/v8/upstream/2.1.10/src/snapshot-empty.cc +50 -0
  308. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/snapshot.h +13 -1
  309. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/spaces-inl.h +35 -27
  310. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/spaces.cc +256 -42
  311. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/spaces.h +136 -42
  312. data/ext/v8/upstream/{2.0.6/src/zone-inl.h → 2.1.10/src/splay-tree-inl.h} +102 -89
  313. data/ext/v8/upstream/2.1.10/src/splay-tree.h +203 -0
  314. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/string-stream.cc +0 -0
  315. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/string-stream.h +0 -0
  316. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/string.js +260 -149
  317. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/stub-cache.cc +195 -69
  318. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/stub-cache.h +127 -12
  319. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/third_party/dtoa/COPYING +0 -0
  320. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/third_party/dtoa/dtoa.c +0 -0
  321. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/third_party/valgrind/valgrind.h +0 -0
  322. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/token.cc +0 -0
  323. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/token.h +0 -0
  324. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/top.cc +26 -31
  325. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/top.h +3 -4
  326. data/ext/v8/upstream/2.1.10/src/type-info.cc +53 -0
  327. data/ext/v8/upstream/2.1.10/src/type-info.h +244 -0
  328. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/unicode-inl.h +0 -0
  329. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/unicode.cc +0 -0
  330. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/unicode.h +0 -0
  331. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/uri.js +6 -6
  332. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/utils.cc +0 -37
  333. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/utils.h +121 -50
  334. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/v8-counters.cc +0 -0
  335. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/v8-counters.h +130 -98
  336. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/v8.cc +42 -11
  337. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/v8.h +4 -2
  338. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/v8natives.js +202 -37
  339. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/v8threads.cc +11 -0
  340. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/v8threads.h +15 -0
  341. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/variables.cc +7 -51
  342. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/variables.h +5 -35
  343. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/version.cc +3 -3
  344. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/version.h +0 -0
  345. data/ext/v8/upstream/2.1.10/src/virtual-frame-heavy-inl.h +152 -0
  346. data/ext/v8/upstream/{2.0.6/src/virtual-frame.cc → 2.1.10/src/virtual-frame-heavy.cc} +107 -176
  347. data/ext/v8/upstream/2.1.10/src/virtual-frame-inl.h +39 -0
  348. data/ext/v8/upstream/2.1.10/src/virtual-frame-light-inl.h +69 -0
  349. data/ext/v8/upstream/2.1.10/src/virtual-frame-light.cc +49 -0
  350. data/ext/v8/upstream/2.1.10/src/virtual-frame.cc +49 -0
  351. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/virtual-frame.h +2 -0
  352. data/ext/v8/upstream/{2.0.6/src/log-inl.h → 2.1.10/src/vm-state-inl.h} +28 -20
  353. data/ext/v8/upstream/{2.0.6/src/snapshot-empty.cc → 2.1.10/src/vm-state.cc} +5 -6
  354. data/ext/v8/upstream/2.1.10/src/vm-state.h +75 -0
  355. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/assembler-x64-inl.h +11 -0
  356. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/assembler-x64.cc +285 -93
  357. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/assembler-x64.h +81 -78
  358. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/builtins-x64.cc +130 -87
  359. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/codegen-x64-inl.h +0 -0
  360. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/codegen-x64.cc +4520 -1317
  361. data/ext/v8/upstream/{2.0.6/src/ia32/codegen-ia32.h → 2.1.10/src/x64/codegen-x64.h} +362 -141
  362. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/cpu-x64.cc +0 -0
  363. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/debug-x64.cc +20 -4
  364. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/disasm-x64.cc +121 -44
  365. data/ext/v8/upstream/2.1.10/src/x64/fast-codegen-x64.cc +246 -0
  366. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/frames-x64.cc +0 -0
  367. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/frames-x64.h +0 -0
  368. data/ext/v8/upstream/{2.0.6/src/x64/fast-codegen-x64.cc → 2.1.10/src/x64/full-codegen-x64.cc} +404 -231
  369. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/ic-x64.cc +346 -117
  370. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/jump-target-x64.cc +1 -0
  371. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/macro-assembler-x64.cc +537 -181
  372. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/macro-assembler-x64.h +140 -34
  373. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/regexp-macro-assembler-x64.cc +74 -96
  374. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/regexp-macro-assembler-x64.h +8 -25
  375. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/register-allocator-x64-inl.h +1 -1
  376. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/register-allocator-x64.cc +3 -0
  377. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/register-allocator-x64.h +0 -0
  378. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/simulator-x64.cc +0 -0
  379. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/simulator-x64.h +2 -2
  380. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/stub-cache-x64.cc +785 -288
  381. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/virtual-frame-x64.cc +128 -52
  382. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/x64/virtual-frame-x64.h +40 -19
  383. data/ext/v8/upstream/2.1.10/src/zone-inl.h +82 -0
  384. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/zone.cc +1 -0
  385. data/ext/v8/upstream/{2.0.6 → 2.1.10}/src/zone.h +6 -90
  386. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/codemap.js +12 -0
  387. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/consarray.js +0 -0
  388. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/csvparser.js +22 -37
  389. data/ext/v8/upstream/2.1.10/tools/generate-ten-powers.scm +286 -0
  390. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/gyp/v8.gyp +86 -24
  391. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/js2c.py +22 -22
  392. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/jsmin.py +0 -0
  393. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/linux-tick-processor +10 -1
  394. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/linux-tick-processor.py +0 -0
  395. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/logreader.js +34 -16
  396. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/mac-nm +0 -0
  397. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/mac-tick-processor +0 -0
  398. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/oprofile/annotate +0 -0
  399. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/oprofile/common +0 -0
  400. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/oprofile/dump +0 -0
  401. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/oprofile/report +0 -0
  402. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/oprofile/reset +0 -0
  403. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/oprofile/run +0 -0
  404. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/oprofile/shutdown +0 -0
  405. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/oprofile/start +0 -0
  406. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/presubmit.py +0 -0
  407. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/process-heap-prof.py +0 -0
  408. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/profile.js +70 -0
  409. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/profile_view.js +0 -0
  410. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/run-valgrind.py +0 -0
  411. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/splaytree.js +0 -0
  412. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/splaytree.py +0 -0
  413. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/stats-viewer.py +0 -0
  414. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/test.py +7 -7
  415. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/tickprocessor-driver.js +7 -1
  416. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/tickprocessor.js +140 -9
  417. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/tickprocessor.py +40 -4
  418. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/utils.py +6 -0
  419. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/README.txt +0 -0
  420. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/arm.vsprops +1 -1
  421. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/common.vsprops +1 -2
  422. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/d8.vcproj +0 -6
  423. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/d8_arm.vcproj +193 -199
  424. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/d8_x64.vcproj +16 -8
  425. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/d8js2c.cmd +0 -0
  426. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/debug.vsprops +0 -0
  427. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/ia32.vsprops +5 -1
  428. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/js2c.cmd +1 -1
  429. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/release.vsprops +0 -0
  430. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8.sln +0 -0
  431. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8.vcproj +11 -7
  432. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_arm.sln +0 -0
  433. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_arm.vcproj +227 -223
  434. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_base.vcproj +137 -5
  435. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_base_arm.vcproj +116 -4
  436. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_base_x64.vcproj +125 -4
  437. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_cctest.vcproj +12 -6
  438. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_cctest_arm.vcproj +12 -6
  439. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_cctest_x64.vcproj +11 -11
  440. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_mksnapshot.vcproj +0 -6
  441. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_mksnapshot_x64.vcproj +0 -6
  442. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_process_sample.vcproj +0 -6
  443. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_process_sample_arm.vcproj +145 -151
  444. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_process_sample_x64.vcproj +16 -6
  445. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_shell_sample.vcproj +0 -6
  446. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_shell_sample_arm.vcproj +145 -151
  447. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_shell_sample_x64.vcproj +16 -8
  448. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_snapshot.vcproj +0 -0
  449. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_snapshot_cc.vcproj +0 -0
  450. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_snapshot_cc_x64.vcproj +0 -0
  451. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_snapshot_x64.vcproj +0 -0
  452. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_x64.sln +0 -0
  453. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/v8_x64.vcproj +11 -7
  454. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/visual_studio/x64.vsprops +5 -1
  455. data/ext/v8/upstream/2.1.10/tools/windows-tick-processor.bat +29 -0
  456. data/ext/v8/upstream/{2.0.6 → 2.1.10}/tools/windows-tick-processor.py +0 -0
  457. data/ext/v8/upstream/Makefile +8 -2
  458. data/ext/v8/v8.cpp +21 -73
  459. data/ext/v8/v8_array.cpp +56 -0
  460. data/ext/v8/v8_array.h +8 -0
  461. data/ext/v8/v8_callbacks.cpp +121 -0
  462. data/ext/v8/v8_callbacks.h +8 -0
  463. data/ext/v8/v8_cxt.cpp +74 -77
  464. data/ext/v8/v8_cxt.h +2 -9
  465. data/ext/v8/v8_date.cpp +26 -0
  466. data/ext/v8/v8_date.h +6 -0
  467. data/ext/v8/v8_exception.cpp +55 -0
  468. data/ext/v8/v8_exception.h +6 -0
  469. data/ext/v8/v8_external.cpp +50 -0
  470. data/ext/v8/v8_external.h +8 -0
  471. data/ext/v8/v8_func.cpp +76 -18
  472. data/ext/v8/v8_func.h +5 -4
  473. data/ext/v8/v8_msg.cpp +55 -46
  474. data/ext/v8/v8_msg.h +3 -11
  475. data/ext/v8/v8_obj.cpp +67 -36
  476. data/ext/v8/v8_obj.h +6 -8
  477. data/ext/v8/v8_ref.cpp +25 -9
  478. data/ext/v8/v8_ref.h +3 -5
  479. data/ext/v8/v8_script.cpp +17 -10
  480. data/ext/v8/v8_script.h +3 -3
  481. data/ext/v8/v8_str.cpp +34 -6
  482. data/ext/v8/v8_str.h +4 -2
  483. data/ext/v8/v8_template.cpp +195 -33
  484. data/ext/v8/v8_template.h +4 -5
  485. data/ext/v8/v8_try_catch.cpp +99 -0
  486. data/ext/v8/v8_try_catch.h +5 -0
  487. data/ext/v8/v8_value.cpp +164 -0
  488. data/ext/v8/v8_value.h +10 -0
  489. data/lib/v8.rb +3 -1
  490. data/lib/v8/access.rb +60 -0
  491. data/lib/v8/array.rb +15 -0
  492. data/lib/v8/callbacks.rb +88 -0
  493. data/lib/v8/cli.rb +1 -1
  494. data/lib/v8/context.rb +55 -66
  495. data/lib/v8/function.rb +20 -2
  496. data/lib/v8/object.rb +14 -12
  497. data/lib/v8/ruby_error.rb +3 -0
  498. data/lib/v8/to.rb +59 -7
  499. data/spec/ext/cxt_spec.rb +2 -15
  500. data/spec/ext/func_spec.rb +17 -10
  501. data/spec/ext/try_catch_spec.rb +32 -0
  502. data/spec/foo.rb +17 -0
  503. data/spec/redjs/jsapi_spec.rb +173 -96
  504. data/spec/spec_helper.rb +7 -0
  505. data/spec/v8/to_spec.rb +0 -1
  506. data/therubyracer.gemspec +6 -6
  507. metadata +493 -386
  508. data/ext/v8/upstream/2.0.6/src/arm/ic-arm.cc +0 -849
  509. data/ext/v8/upstream/2.0.6/src/arm/virtual-frame-arm.cc +0 -412
  510. data/ext/v8/upstream/2.0.6/src/ast.cc +0 -512
  511. data/ext/v8/upstream/2.0.6/src/builtins.cc +0 -851
  512. data/ext/v8/upstream/2.0.6/src/compiler.cc +0 -1132
  513. data/ext/v8/upstream/2.0.6/src/compiler.h +0 -107
  514. data/ext/v8/upstream/2.0.6/src/conversions.cc +0 -709
  515. data/ext/v8/upstream/2.0.6/src/usage-analyzer.cc +0 -426
  516. data/ext/v8/upstream/2.0.6/tools/windows-tick-processor.bat +0 -5
  517. data/ext/v8/upstream/no-strict-aliasing.patch +0 -13
  518. data/ext/v8/v8_standalone.cpp +0 -69
  519. data/ext/v8/v8_standalone.h +0 -31
  520. data/spec/ext/obj_spec.rb +0 -13
@@ -0,0 +1,1468 @@
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
+
29
+ #include "v8.h"
30
+
31
+ #include "liveedit.h"
32
+ #include "compiler.h"
33
+ #include "oprofile-agent.h"
34
+ #include "scopes.h"
35
+ #include "global-handles.h"
36
+ #include "debug.h"
37
+ #include "memory.h"
38
+
39
+ namespace v8 {
40
+ namespace internal {
41
+
42
+
43
+ #ifdef ENABLE_DEBUGGER_SUPPORT
44
+
45
+
46
+ // A simple implementation of dynamic programming algorithm. It solves
47
+ // the problem of finding the difference of 2 arrays. It uses a table of results
48
+ // of subproblems. Each cell contains a number together with 2-bit flag
49
+ // that helps building the chunk list.
50
+ class Differencer {
51
+ public:
52
+ explicit Differencer(Comparator::Input* input)
53
+ : input_(input), len1_(input->getLength1()), len2_(input->getLength2()) {
54
+ buffer_ = NewArray<int>(len1_ * len2_);
55
+ }
56
+ ~Differencer() {
57
+ DeleteArray(buffer_);
58
+ }
59
+
60
+ void Initialize() {
61
+ int array_size = len1_ * len2_;
62
+ for (int i = 0; i < array_size; i++) {
63
+ buffer_[i] = kEmptyCellValue;
64
+ }
65
+ }
66
+
67
+ // Makes sure that result for the full problem is calculated and stored
68
+ // in the table together with flags showing a path through subproblems.
69
+ void FillTable() {
70
+ CompareUpToTail(0, 0);
71
+ }
72
+
73
+ void SaveResult(Comparator::Output* chunk_writer) {
74
+ ResultWriter writer(chunk_writer);
75
+
76
+ int pos1 = 0;
77
+ int pos2 = 0;
78
+ while (true) {
79
+ if (pos1 < len1_) {
80
+ if (pos2 < len2_) {
81
+ Direction dir = get_direction(pos1, pos2);
82
+ switch (dir) {
83
+ case EQ:
84
+ writer.eq();
85
+ pos1++;
86
+ pos2++;
87
+ break;
88
+ case SKIP1:
89
+ writer.skip1(1);
90
+ pos1++;
91
+ break;
92
+ case SKIP2:
93
+ case SKIP_ANY:
94
+ writer.skip2(1);
95
+ pos2++;
96
+ break;
97
+ default:
98
+ UNREACHABLE();
99
+ }
100
+ } else {
101
+ writer.skip1(len1_ - pos1);
102
+ break;
103
+ }
104
+ } else {
105
+ if (len2_ != pos2) {
106
+ writer.skip2(len2_ - pos2);
107
+ }
108
+ break;
109
+ }
110
+ }
111
+ writer.close();
112
+ }
113
+
114
+ private:
115
+ Comparator::Input* input_;
116
+ int* buffer_;
117
+ int len1_;
118
+ int len2_;
119
+
120
+ enum Direction {
121
+ EQ = 0,
122
+ SKIP1,
123
+ SKIP2,
124
+ SKIP_ANY,
125
+
126
+ MAX_DIRECTION_FLAG_VALUE = SKIP_ANY
127
+ };
128
+
129
+ // Computes result for a subtask and optionally caches it in the buffer table.
130
+ // All results values are shifted to make space for flags in the lower bits.
131
+ int CompareUpToTail(int pos1, int pos2) {
132
+ if (pos1 < len1_) {
133
+ if (pos2 < len2_) {
134
+ int cached_res = get_value4(pos1, pos2);
135
+ if (cached_res == kEmptyCellValue) {
136
+ Direction dir;
137
+ int res;
138
+ if (input_->equals(pos1, pos2)) {
139
+ res = CompareUpToTail(pos1 + 1, pos2 + 1);
140
+ dir = EQ;
141
+ } else {
142
+ int res1 = CompareUpToTail(pos1 + 1, pos2) +
143
+ (1 << kDirectionSizeBits);
144
+ int res2 = CompareUpToTail(pos1, pos2 + 1) +
145
+ (1 << kDirectionSizeBits);
146
+ if (res1 == res2) {
147
+ res = res1;
148
+ dir = SKIP_ANY;
149
+ } else if (res1 < res2) {
150
+ res = res1;
151
+ dir = SKIP1;
152
+ } else {
153
+ res = res2;
154
+ dir = SKIP2;
155
+ }
156
+ }
157
+ set_value4_and_dir(pos1, pos2, res, dir);
158
+ cached_res = res;
159
+ }
160
+ return cached_res;
161
+ } else {
162
+ return (len1_ - pos1) << kDirectionSizeBits;
163
+ }
164
+ } else {
165
+ return (len2_ - pos2) << kDirectionSizeBits;
166
+ }
167
+ }
168
+
169
+ inline int& get_cell(int i1, int i2) {
170
+ return buffer_[i1 + i2 * len1_];
171
+ }
172
+
173
+ // Each cell keeps a value plus direction. Value is multiplied by 4.
174
+ void set_value4_and_dir(int i1, int i2, int value4, Direction dir) {
175
+ ASSERT((value4 & kDirectionMask) == 0);
176
+ get_cell(i1, i2) = value4 | dir;
177
+ }
178
+
179
+ int get_value4(int i1, int i2) {
180
+ return get_cell(i1, i2) & (kMaxUInt32 ^ kDirectionMask);
181
+ }
182
+ Direction get_direction(int i1, int i2) {
183
+ return static_cast<Direction>(get_cell(i1, i2) & kDirectionMask);
184
+ }
185
+
186
+ static const int kDirectionSizeBits = 2;
187
+ static const int kDirectionMask = (1 << kDirectionSizeBits) - 1;
188
+ static const int kEmptyCellValue = -1 << kDirectionSizeBits;
189
+
190
+ // This method only holds static assert statement (unfortunately you cannot
191
+ // place one in class scope).
192
+ void StaticAssertHolder() {
193
+ STATIC_ASSERT(MAX_DIRECTION_FLAG_VALUE < (1 << kDirectionSizeBits));
194
+ }
195
+
196
+ class ResultWriter {
197
+ public:
198
+ explicit ResultWriter(Comparator::Output* chunk_writer)
199
+ : chunk_writer_(chunk_writer), pos1_(0), pos2_(0),
200
+ pos1_begin_(-1), pos2_begin_(-1), has_open_chunk_(false) {
201
+ }
202
+ void eq() {
203
+ FlushChunk();
204
+ pos1_++;
205
+ pos2_++;
206
+ }
207
+ void skip1(int len1) {
208
+ StartChunk();
209
+ pos1_ += len1;
210
+ }
211
+ void skip2(int len2) {
212
+ StartChunk();
213
+ pos2_ += len2;
214
+ }
215
+ void close() {
216
+ FlushChunk();
217
+ }
218
+
219
+ private:
220
+ Comparator::Output* chunk_writer_;
221
+ int pos1_;
222
+ int pos2_;
223
+ int pos1_begin_;
224
+ int pos2_begin_;
225
+ bool has_open_chunk_;
226
+
227
+ void StartChunk() {
228
+ if (!has_open_chunk_) {
229
+ pos1_begin_ = pos1_;
230
+ pos2_begin_ = pos2_;
231
+ has_open_chunk_ = true;
232
+ }
233
+ }
234
+
235
+ void FlushChunk() {
236
+ if (has_open_chunk_) {
237
+ chunk_writer_->AddChunk(pos1_begin_, pos2_begin_,
238
+ pos1_ - pos1_begin_, pos2_ - pos2_begin_);
239
+ has_open_chunk_ = false;
240
+ }
241
+ }
242
+ };
243
+ };
244
+
245
+
246
+ void Comparator::CalculateDifference(Comparator::Input* input,
247
+ Comparator::Output* result_writer) {
248
+ Differencer differencer(input);
249
+ differencer.Initialize();
250
+ differencer.FillTable();
251
+ differencer.SaveResult(result_writer);
252
+ }
253
+
254
+
255
+ static bool CompareSubstrings(Handle<String> s1, int pos1,
256
+ Handle<String> s2, int pos2, int len) {
257
+ static StringInputBuffer buf1;
258
+ static StringInputBuffer buf2;
259
+ buf1.Reset(*s1);
260
+ buf1.Seek(pos1);
261
+ buf2.Reset(*s2);
262
+ buf2.Seek(pos2);
263
+ for (int i = 0; i < len; i++) {
264
+ ASSERT(buf1.has_more() && buf2.has_more());
265
+ if (buf1.GetNext() != buf2.GetNext()) {
266
+ return false;
267
+ }
268
+ }
269
+ return true;
270
+ }
271
+
272
+
273
+ // Wraps raw n-elements line_ends array as a list of n+1 lines. The last line
274
+ // never has terminating new line character.
275
+ class LineEndsWrapper {
276
+ public:
277
+ explicit LineEndsWrapper(Handle<String> string)
278
+ : ends_array_(CalculateLineEnds(string, false)),
279
+ string_len_(string->length()) {
280
+ }
281
+ int length() {
282
+ return ends_array_->length() + 1;
283
+ }
284
+ // Returns start for any line including start of the imaginary line after
285
+ // the last line.
286
+ int GetLineStart(int index) {
287
+ if (index == 0) {
288
+ return 0;
289
+ } else {
290
+ return GetLineEnd(index - 1);
291
+ }
292
+ }
293
+ int GetLineEnd(int index) {
294
+ if (index == ends_array_->length()) {
295
+ // End of the last line is always an end of the whole string.
296
+ // If the string ends with a new line character, the last line is an
297
+ // empty string after this character.
298
+ return string_len_;
299
+ } else {
300
+ return GetPosAfterNewLine(index);
301
+ }
302
+ }
303
+
304
+ private:
305
+ Handle<FixedArray> ends_array_;
306
+ int string_len_;
307
+
308
+ int GetPosAfterNewLine(int index) {
309
+ return Smi::cast(ends_array_->get(index))->value() + 1;
310
+ }
311
+ };
312
+
313
+
314
+ // Represents 2 strings as 2 arrays of lines.
315
+ class LineArrayCompareInput : public Comparator::Input {
316
+ public:
317
+ LineArrayCompareInput(Handle<String> s1, Handle<String> s2,
318
+ LineEndsWrapper line_ends1, LineEndsWrapper line_ends2)
319
+ : s1_(s1), s2_(s2), line_ends1_(line_ends1), line_ends2_(line_ends2) {
320
+ }
321
+ int getLength1() {
322
+ return line_ends1_.length();
323
+ }
324
+ int getLength2() {
325
+ return line_ends2_.length();
326
+ }
327
+ bool equals(int index1, int index2) {
328
+ int line_start1 = line_ends1_.GetLineStart(index1);
329
+ int line_start2 = line_ends2_.GetLineStart(index2);
330
+ int line_end1 = line_ends1_.GetLineEnd(index1);
331
+ int line_end2 = line_ends2_.GetLineEnd(index2);
332
+ int len1 = line_end1 - line_start1;
333
+ int len2 = line_end2 - line_start2;
334
+ if (len1 != len2) {
335
+ return false;
336
+ }
337
+ return CompareSubstrings(s1_, line_start1, s2_, line_start2, len1);
338
+ }
339
+
340
+ private:
341
+ Handle<String> s1_;
342
+ Handle<String> s2_;
343
+ LineEndsWrapper line_ends1_;
344
+ LineEndsWrapper line_ends2_;
345
+ };
346
+
347
+
348
+ // Stores compare result in JSArray. Each chunk is stored as 3 array elements:
349
+ // (pos1_begin, pos1_end, pos2_end).
350
+ class LineArrayCompareOutput : public Comparator::Output {
351
+ public:
352
+ LineArrayCompareOutput(LineEndsWrapper line_ends1, LineEndsWrapper line_ends2)
353
+ : array_(Factory::NewJSArray(10)), current_size_(0),
354
+ line_ends1_(line_ends1), line_ends2_(line_ends2) {
355
+ }
356
+
357
+ void AddChunk(int line_pos1, int line_pos2, int line_len1, int line_len2) {
358
+ int char_pos1 = line_ends1_.GetLineStart(line_pos1);
359
+ int char_pos2 = line_ends2_.GetLineStart(line_pos2);
360
+ int char_len1 = line_ends1_.GetLineStart(line_pos1 + line_len1) - char_pos1;
361
+ int char_len2 = line_ends2_.GetLineStart(line_pos2 + line_len2) - char_pos2;
362
+
363
+ SetElement(array_, current_size_, Handle<Object>(Smi::FromInt(char_pos1)));
364
+ SetElement(array_, current_size_ + 1,
365
+ Handle<Object>(Smi::FromInt(char_pos1 + char_len1)));
366
+ SetElement(array_, current_size_ + 2,
367
+ Handle<Object>(Smi::FromInt(char_pos2 + char_len2)));
368
+ current_size_ += 3;
369
+ }
370
+
371
+ Handle<JSArray> GetResult() {
372
+ return array_;
373
+ }
374
+
375
+ private:
376
+ Handle<JSArray> array_;
377
+ int current_size_;
378
+ LineEndsWrapper line_ends1_;
379
+ LineEndsWrapper line_ends2_;
380
+ };
381
+
382
+
383
+ Handle<JSArray> LiveEdit::CompareStringsLinewise(Handle<String> s1,
384
+ Handle<String> s2) {
385
+ LineEndsWrapper line_ends1(s1);
386
+ LineEndsWrapper line_ends2(s2);
387
+
388
+ LineArrayCompareInput input(s1, s2, line_ends1, line_ends2);
389
+ LineArrayCompareOutput output(line_ends1, line_ends2);
390
+
391
+ Comparator::CalculateDifference(&input, &output);
392
+
393
+ return output.GetResult();
394
+ }
395
+
396
+
397
+ static void CompileScriptForTracker(Handle<Script> script) {
398
+ const bool is_eval = false;
399
+ const bool is_global = true;
400
+ // TODO(635): support extensions.
401
+ Extension* extension = NULL;
402
+
403
+ PostponeInterruptsScope postpone;
404
+
405
+ // Only allow non-global compiles for eval.
406
+ ASSERT(is_eval || is_global);
407
+
408
+ // Build AST.
409
+ ScriptDataImpl* pre_data = NULL;
410
+ FunctionLiteral* lit = MakeAST(is_global, script, extension, pre_data);
411
+
412
+ // Check for parse errors.
413
+ if (lit == NULL) {
414
+ ASSERT(Top::has_pending_exception());
415
+ return;
416
+ }
417
+
418
+ // Compile the code.
419
+ CompilationInfo info(lit, script, is_eval);
420
+
421
+ LiveEditFunctionTracker tracker(lit);
422
+ Handle<Code> code = MakeCodeForLiveEdit(&info);
423
+
424
+ // Check for stack-overflow exceptions.
425
+ if (code.is_null()) {
426
+ Top::StackOverflow();
427
+ return;
428
+ }
429
+ tracker.RecordRootFunctionInfo(code);
430
+ }
431
+
432
+ // Unwraps JSValue object, returning its field "value"
433
+ static Handle<Object> UnwrapJSValue(Handle<JSValue> jsValue) {
434
+ return Handle<Object>(jsValue->value());
435
+ }
436
+
437
+ // Wraps any object into a OpaqueReference, that will hide the object
438
+ // from JavaScript.
439
+ static Handle<JSValue> WrapInJSValue(Object* object) {
440
+ Handle<JSFunction> constructor = Top::opaque_reference_function();
441
+ Handle<JSValue> result =
442
+ Handle<JSValue>::cast(Factory::NewJSObject(constructor));
443
+ result->set_value(object);
444
+ return result;
445
+ }
446
+
447
+ // Simple helper class that creates more or less typed structures over
448
+ // JSArray object. This is an adhoc method of passing structures from C++
449
+ // to JavaScript.
450
+ template<typename S>
451
+ class JSArrayBasedStruct {
452
+ public:
453
+ static S Create() {
454
+ Handle<JSArray> array = Factory::NewJSArray(S::kSize_);
455
+ return S(array);
456
+ }
457
+ static S cast(Object* object) {
458
+ JSArray* array = JSArray::cast(object);
459
+ Handle<JSArray> array_handle(array);
460
+ return S(array_handle);
461
+ }
462
+ explicit JSArrayBasedStruct(Handle<JSArray> array) : array_(array) {
463
+ }
464
+ Handle<JSArray> GetJSArray() {
465
+ return array_;
466
+ }
467
+ protected:
468
+ void SetField(int field_position, Handle<Object> value) {
469
+ SetElement(array_, field_position, value);
470
+ }
471
+ void SetSmiValueField(int field_position, int value) {
472
+ SetElement(array_, field_position, Handle<Smi>(Smi::FromInt(value)));
473
+ }
474
+ Object* GetField(int field_position) {
475
+ return array_->GetElement(field_position);
476
+ }
477
+ int GetSmiValueField(int field_position) {
478
+ Object* res = GetField(field_position);
479
+ return Smi::cast(res)->value();
480
+ }
481
+ private:
482
+ Handle<JSArray> array_;
483
+ };
484
+
485
+
486
+ // Represents some function compilation details. This structure will be used
487
+ // from JavaScript. It contains Code object, which is kept wrapped
488
+ // into a BlindReference for sanitizing reasons.
489
+ class FunctionInfoWrapper : public JSArrayBasedStruct<FunctionInfoWrapper> {
490
+ public:
491
+ explicit FunctionInfoWrapper(Handle<JSArray> array)
492
+ : JSArrayBasedStruct<FunctionInfoWrapper>(array) {
493
+ }
494
+ void SetInitialProperties(Handle<String> name, int start_position,
495
+ int end_position, int param_num, int parent_index) {
496
+ HandleScope scope;
497
+ this->SetField(kFunctionNameOffset_, name);
498
+ this->SetSmiValueField(kStartPositionOffset_, start_position);
499
+ this->SetSmiValueField(kEndPositionOffset_, end_position);
500
+ this->SetSmiValueField(kParamNumOffset_, param_num);
501
+ this->SetSmiValueField(kParentIndexOffset_, parent_index);
502
+ }
503
+ void SetFunctionCode(Handle<Code> function_code) {
504
+ Handle<JSValue> wrapper = WrapInJSValue(*function_code);
505
+ this->SetField(kCodeOffset_, wrapper);
506
+ }
507
+ void SetScopeInfo(Handle<Object> scope_info_array) {
508
+ this->SetField(kScopeInfoOffset_, scope_info_array);
509
+ }
510
+ void SetSharedFunctionInfo(Handle<SharedFunctionInfo> info) {
511
+ Handle<JSValue> info_holder = WrapInJSValue(*info);
512
+ this->SetField(kSharedFunctionInfoOffset_, info_holder);
513
+ }
514
+ int GetParentIndex() {
515
+ return this->GetSmiValueField(kParentIndexOffset_);
516
+ }
517
+ Handle<Code> GetFunctionCode() {
518
+ Handle<Object> raw_result = UnwrapJSValue(Handle<JSValue>(
519
+ JSValue::cast(this->GetField(kCodeOffset_))));
520
+ return Handle<Code>::cast(raw_result);
521
+ }
522
+ int GetStartPosition() {
523
+ return this->GetSmiValueField(kStartPositionOffset_);
524
+ }
525
+ int GetEndPosition() {
526
+ return this->GetSmiValueField(kEndPositionOffset_);
527
+ }
528
+
529
+ private:
530
+ static const int kFunctionNameOffset_ = 0;
531
+ static const int kStartPositionOffset_ = 1;
532
+ static const int kEndPositionOffset_ = 2;
533
+ static const int kParamNumOffset_ = 3;
534
+ static const int kCodeOffset_ = 4;
535
+ static const int kScopeInfoOffset_ = 5;
536
+ static const int kParentIndexOffset_ = 6;
537
+ static const int kSharedFunctionInfoOffset_ = 7;
538
+ static const int kSize_ = 8;
539
+
540
+ friend class JSArrayBasedStruct<FunctionInfoWrapper>;
541
+ };
542
+
543
+ // Wraps SharedFunctionInfo along with some of its fields for passing it
544
+ // back to JavaScript. SharedFunctionInfo object itself is additionally
545
+ // wrapped into BlindReference for sanitizing reasons.
546
+ class SharedInfoWrapper : public JSArrayBasedStruct<SharedInfoWrapper> {
547
+ public:
548
+ static bool IsInstance(Handle<JSArray> array) {
549
+ return array->length() == Smi::FromInt(kSize_) &&
550
+ array->GetElement(kSharedInfoOffset_)->IsJSValue();
551
+ }
552
+
553
+ explicit SharedInfoWrapper(Handle<JSArray> array)
554
+ : JSArrayBasedStruct<SharedInfoWrapper>(array) {
555
+ }
556
+
557
+ void SetProperties(Handle<String> name, int start_position, int end_position,
558
+ Handle<SharedFunctionInfo> info) {
559
+ HandleScope scope;
560
+ this->SetField(kFunctionNameOffset_, name);
561
+ Handle<JSValue> info_holder = WrapInJSValue(*info);
562
+ this->SetField(kSharedInfoOffset_, info_holder);
563
+ this->SetSmiValueField(kStartPositionOffset_, start_position);
564
+ this->SetSmiValueField(kEndPositionOffset_, end_position);
565
+ }
566
+ Handle<SharedFunctionInfo> GetInfo() {
567
+ Object* element = this->GetField(kSharedInfoOffset_);
568
+ Handle<JSValue> value_wrapper(JSValue::cast(element));
569
+ Handle<Object> raw_result = UnwrapJSValue(value_wrapper);
570
+ return Handle<SharedFunctionInfo>::cast(raw_result);
571
+ }
572
+
573
+ private:
574
+ static const int kFunctionNameOffset_ = 0;
575
+ static const int kStartPositionOffset_ = 1;
576
+ static const int kEndPositionOffset_ = 2;
577
+ static const int kSharedInfoOffset_ = 3;
578
+ static const int kSize_ = 4;
579
+
580
+ friend class JSArrayBasedStruct<SharedInfoWrapper>;
581
+ };
582
+
583
+ class FunctionInfoListener {
584
+ public:
585
+ FunctionInfoListener() {
586
+ current_parent_index_ = -1;
587
+ len_ = 0;
588
+ result_ = Factory::NewJSArray(10);
589
+ }
590
+
591
+ void FunctionStarted(FunctionLiteral* fun) {
592
+ HandleScope scope;
593
+ FunctionInfoWrapper info = FunctionInfoWrapper::Create();
594
+ info.SetInitialProperties(fun->name(), fun->start_position(),
595
+ fun->end_position(), fun->num_parameters(),
596
+ current_parent_index_);
597
+ current_parent_index_ = len_;
598
+ SetElement(result_, len_, info.GetJSArray());
599
+ len_++;
600
+ }
601
+
602
+ void FunctionDone() {
603
+ HandleScope scope;
604
+ FunctionInfoWrapper info =
605
+ FunctionInfoWrapper::cast(result_->GetElement(current_parent_index_));
606
+ current_parent_index_ = info.GetParentIndex();
607
+ }
608
+
609
+ // TODO(LiveEdit): Move private method below.
610
+ // This private section was created here to avoid moving the function
611
+ // to keep already complex diff simpler.
612
+ private:
613
+ Object* SerializeFunctionScope(Scope* scope) {
614
+ HandleScope handle_scope;
615
+
616
+ Handle<JSArray> scope_info_list = Factory::NewJSArray(10);
617
+ int scope_info_length = 0;
618
+
619
+ // Saves some description of scope. It stores name and indexes of
620
+ // variables in the whole scope chain. Null-named slots delimit
621
+ // scopes of this chain.
622
+ Scope* outer_scope = scope->outer_scope();
623
+ if (outer_scope == NULL) {
624
+ return Heap::undefined_value();
625
+ }
626
+ do {
627
+ ZoneList<Variable*> list(10);
628
+ outer_scope->CollectUsedVariables(&list);
629
+ int j = 0;
630
+ for (int i = 0; i < list.length(); i++) {
631
+ Variable* var1 = list[i];
632
+ Slot* slot = var1->slot();
633
+ if (slot != NULL && slot->type() == Slot::CONTEXT) {
634
+ if (j != i) {
635
+ list[j] = var1;
636
+ }
637
+ j++;
638
+ }
639
+ }
640
+
641
+ // Sort it.
642
+ for (int k = 1; k < j; k++) {
643
+ int l = k;
644
+ for (int m = k + 1; m < j; m++) {
645
+ if (list[l]->slot()->index() > list[m]->slot()->index()) {
646
+ l = m;
647
+ }
648
+ }
649
+ list[k] = list[l];
650
+ }
651
+ for (int i = 0; i < j; i++) {
652
+ SetElement(scope_info_list, scope_info_length, list[i]->name());
653
+ scope_info_length++;
654
+ SetElement(scope_info_list, scope_info_length,
655
+ Handle<Smi>(Smi::FromInt(list[i]->slot()->index())));
656
+ scope_info_length++;
657
+ }
658
+ SetElement(scope_info_list, scope_info_length,
659
+ Handle<Object>(Heap::null_value()));
660
+ scope_info_length++;
661
+
662
+ outer_scope = outer_scope->outer_scope();
663
+ } while (outer_scope != NULL);
664
+
665
+ return *scope_info_list;
666
+ }
667
+
668
+ public:
669
+ // Saves only function code, because for a script function we
670
+ // may never create a SharedFunctionInfo object.
671
+ void FunctionCode(Handle<Code> function_code) {
672
+ FunctionInfoWrapper info =
673
+ FunctionInfoWrapper::cast(result_->GetElement(current_parent_index_));
674
+ info.SetFunctionCode(function_code);
675
+ }
676
+
677
+ // Saves full information about a function: its code, its scope info
678
+ // and a SharedFunctionInfo object.
679
+ void FunctionInfo(Handle<SharedFunctionInfo> shared, Scope* scope) {
680
+ if (!shared->IsSharedFunctionInfo()) {
681
+ return;
682
+ }
683
+ FunctionInfoWrapper info =
684
+ FunctionInfoWrapper::cast(result_->GetElement(current_parent_index_));
685
+ info.SetFunctionCode(Handle<Code>(shared->code()));
686
+ info.SetSharedFunctionInfo(shared);
687
+
688
+ Handle<Object> scope_info_list(SerializeFunctionScope(scope));
689
+ info.SetScopeInfo(scope_info_list);
690
+ }
691
+
692
+ Handle<JSArray> GetResult() {
693
+ return result_;
694
+ }
695
+
696
+ private:
697
+ Handle<JSArray> result_;
698
+ int len_;
699
+ int current_parent_index_;
700
+ };
701
+
702
+ static FunctionInfoListener* active_function_info_listener = NULL;
703
+
704
+ JSArray* LiveEdit::GatherCompileInfo(Handle<Script> script,
705
+ Handle<String> source) {
706
+ CompilationZoneScope zone_scope(DELETE_ON_EXIT);
707
+
708
+ FunctionInfoListener listener;
709
+ Handle<Object> original_source = Handle<Object>(script->source());
710
+ script->set_source(*source);
711
+ active_function_info_listener = &listener;
712
+ CompileScriptForTracker(script);
713
+ active_function_info_listener = NULL;
714
+ script->set_source(*original_source);
715
+
716
+ return *(listener.GetResult());
717
+ }
718
+
719
+
720
+ void LiveEdit::WrapSharedFunctionInfos(Handle<JSArray> array) {
721
+ HandleScope scope;
722
+ int len = Smi::cast(array->length())->value();
723
+ for (int i = 0; i < len; i++) {
724
+ Handle<SharedFunctionInfo> info(
725
+ SharedFunctionInfo::cast(array->GetElement(i)));
726
+ SharedInfoWrapper info_wrapper = SharedInfoWrapper::Create();
727
+ Handle<String> name_handle(String::cast(info->name()));
728
+ info_wrapper.SetProperties(name_handle, info->start_position(),
729
+ info->end_position(), info);
730
+ array->SetElement(i, *(info_wrapper.GetJSArray()));
731
+ }
732
+ }
733
+
734
+
735
+ // Visitor that collects all references to a particular code object,
736
+ // including "CODE_TARGET" references in other code objects.
737
+ // It works in context of ZoneScope.
738
+ class ReferenceCollectorVisitor : public ObjectVisitor {
739
+ public:
740
+ explicit ReferenceCollectorVisitor(Code* original)
741
+ : original_(original), rvalues_(10), reloc_infos_(10) {
742
+ }
743
+
744
+ virtual void VisitPointers(Object** start, Object** end) {
745
+ for (Object** p = start; p < end; p++) {
746
+ if (*p == original_) {
747
+ rvalues_.Add(p);
748
+ }
749
+ }
750
+ }
751
+
752
+ void VisitCodeTarget(RelocInfo* rinfo) {
753
+ if (RelocInfo::IsCodeTarget(rinfo->rmode()) &&
754
+ Code::GetCodeFromTargetAddress(rinfo->target_address()) == original_) {
755
+ reloc_infos_.Add(*rinfo);
756
+ }
757
+ }
758
+
759
+ virtual void VisitDebugTarget(RelocInfo* rinfo) {
760
+ VisitCodeTarget(rinfo);
761
+ }
762
+
763
+ // Post-visiting method that iterates over all collected references and
764
+ // modifies them.
765
+ void Replace(Code* substitution) {
766
+ for (int i = 0; i < rvalues_.length(); i++) {
767
+ *(rvalues_[i]) = substitution;
768
+ }
769
+ for (int i = 0; i < reloc_infos_.length(); i++) {
770
+ reloc_infos_[i].set_target_address(substitution->instruction_start());
771
+ }
772
+ }
773
+
774
+ private:
775
+ Code* original_;
776
+ ZoneList<Object**> rvalues_;
777
+ ZoneList<RelocInfo> reloc_infos_;
778
+ };
779
+
780
+
781
+ class FrameCookingThreadVisitor : public ThreadVisitor {
782
+ public:
783
+ void VisitThread(ThreadLocalTop* top) {
784
+ StackFrame::CookFramesForThread(top);
785
+ }
786
+ };
787
+
788
+ class FrameUncookingThreadVisitor : public ThreadVisitor {
789
+ public:
790
+ void VisitThread(ThreadLocalTop* top) {
791
+ StackFrame::UncookFramesForThread(top);
792
+ }
793
+ };
794
+
795
+ static void IterateAllThreads(ThreadVisitor* visitor) {
796
+ Top::IterateThread(visitor);
797
+ ThreadManager::IterateThreads(visitor);
798
+ }
799
+
800
+ // Finds all references to original and replaces them with substitution.
801
+ static void ReplaceCodeObject(Code* original, Code* substitution) {
802
+ ASSERT(!Heap::InNewSpace(substitution));
803
+
804
+ AssertNoAllocation no_allocations_please;
805
+
806
+ // A zone scope for ReferenceCollectorVisitor.
807
+ ZoneScope scope(DELETE_ON_EXIT);
808
+
809
+ ReferenceCollectorVisitor visitor(original);
810
+
811
+ // Iterate over all roots. Stack frames may have pointer into original code,
812
+ // so temporary replace the pointers with offset numbers
813
+ // in prologue/epilogue.
814
+ {
815
+ FrameCookingThreadVisitor cooking_visitor;
816
+ IterateAllThreads(&cooking_visitor);
817
+
818
+ Heap::IterateStrongRoots(&visitor, VISIT_ALL);
819
+
820
+ FrameUncookingThreadVisitor uncooking_visitor;
821
+ IterateAllThreads(&uncooking_visitor);
822
+ }
823
+
824
+ // Now iterate over all pointers of all objects, including code_target
825
+ // implicit pointers.
826
+ HeapIterator iterator;
827
+ for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) {
828
+ obj->Iterate(&visitor);
829
+ }
830
+
831
+ visitor.Replace(substitution);
832
+ }
833
+
834
+
835
+ // Check whether the code is natural function code (not a lazy-compile stub
836
+ // code).
837
+ static bool IsJSFunctionCode(Code* code) {
838
+ return code->kind() == Code::FUNCTION;
839
+ }
840
+
841
+
842
+ Object* LiveEdit::ReplaceFunctionCode(Handle<JSArray> new_compile_info_array,
843
+ Handle<JSArray> shared_info_array) {
844
+ HandleScope scope;
845
+
846
+ if (!SharedInfoWrapper::IsInstance(shared_info_array)) {
847
+ return Top::ThrowIllegalOperation();
848
+ }
849
+
850
+ FunctionInfoWrapper compile_info_wrapper(new_compile_info_array);
851
+ SharedInfoWrapper shared_info_wrapper(shared_info_array);
852
+
853
+ Handle<SharedFunctionInfo> shared_info = shared_info_wrapper.GetInfo();
854
+
855
+ if (IsJSFunctionCode(shared_info->code())) {
856
+ ReplaceCodeObject(shared_info->code(),
857
+ *(compile_info_wrapper.GetFunctionCode()));
858
+ }
859
+
860
+ if (shared_info->debug_info()->IsDebugInfo()) {
861
+ Handle<DebugInfo> debug_info(DebugInfo::cast(shared_info->debug_info()));
862
+ Handle<Code> new_original_code =
863
+ Factory::CopyCode(compile_info_wrapper.GetFunctionCode());
864
+ debug_info->set_original_code(*new_original_code);
865
+ }
866
+
867
+ shared_info->set_start_position(compile_info_wrapper.GetStartPosition());
868
+ shared_info->set_end_position(compile_info_wrapper.GetEndPosition());
869
+
870
+ shared_info->set_construct_stub(
871
+ Builtins::builtin(Builtins::JSConstructStubGeneric));
872
+
873
+ return Heap::undefined_value();
874
+ }
875
+
876
+
877
+ // TODO(635): Eval caches its scripts (same text -- same compiled info).
878
+ // Make sure we clear such caches.
879
+ void LiveEdit::SetFunctionScript(Handle<JSValue> function_wrapper,
880
+ Handle<Object> script_handle) {
881
+ Handle<SharedFunctionInfo> shared_info =
882
+ Handle<SharedFunctionInfo>::cast(UnwrapJSValue(function_wrapper));
883
+ shared_info->set_script(*script_handle);
884
+ }
885
+
886
+
887
+ // For a script text change (defined as position_change_array), translates
888
+ // position in unchanged text to position in changed text.
889
+ // Text change is a set of non-overlapping regions in text, that have changed
890
+ // their contents and length. It is specified as array of groups of 3 numbers:
891
+ // (change_begin, change_end, change_end_new_position).
892
+ // Each group describes a change in text; groups are sorted by change_begin.
893
+ // Only position in text beyond any changes may be successfully translated.
894
+ // If a positions is inside some region that changed, result is currently
895
+ // undefined.
896
+ static int TranslatePosition(int original_position,
897
+ Handle<JSArray> position_change_array) {
898
+ int position_diff = 0;
899
+ int array_len = Smi::cast(position_change_array->length())->value();
900
+ // TODO(635): binary search may be used here
901
+ for (int i = 0; i < array_len; i += 3) {
902
+ int chunk_start =
903
+ Smi::cast(position_change_array->GetElement(i))->value();
904
+ if (original_position < chunk_start) {
905
+ break;
906
+ }
907
+ int chunk_end =
908
+ Smi::cast(position_change_array->GetElement(i + 1))->value();
909
+ // Position mustn't be inside a chunk.
910
+ ASSERT(original_position >= chunk_end);
911
+ int chunk_changed_end =
912
+ Smi::cast(position_change_array->GetElement(i + 2))->value();
913
+ position_diff = chunk_changed_end - chunk_end;
914
+ }
915
+
916
+ return original_position + position_diff;
917
+ }
918
+
919
+
920
+ // Auto-growing buffer for writing relocation info code section. This buffer
921
+ // is a simplified version of buffer from Assembler. Unlike Assembler, this
922
+ // class is platform-independent and it works without dealing with instructions.
923
+ // As specified by RelocInfo format, the buffer is filled in reversed order:
924
+ // from upper to lower addresses.
925
+ // It uses NewArray/DeleteArray for memory management.
926
+ class RelocInfoBuffer {
927
+ public:
928
+ RelocInfoBuffer(int buffer_initial_capicity, byte* pc) {
929
+ buffer_size_ = buffer_initial_capicity + kBufferGap;
930
+ buffer_ = NewArray<byte>(buffer_size_);
931
+
932
+ reloc_info_writer_.Reposition(buffer_ + buffer_size_, pc);
933
+ }
934
+ ~RelocInfoBuffer() {
935
+ DeleteArray(buffer_);
936
+ }
937
+
938
+ // As specified by RelocInfo format, the buffer is filled in reversed order:
939
+ // from upper to lower addresses.
940
+ void Write(const RelocInfo* rinfo) {
941
+ if (buffer_ + kBufferGap >= reloc_info_writer_.pos()) {
942
+ Grow();
943
+ }
944
+ reloc_info_writer_.Write(rinfo);
945
+ }
946
+
947
+ Vector<byte> GetResult() {
948
+ // Return the bytes from pos up to end of buffer.
949
+ int result_size =
950
+ static_cast<int>((buffer_ + buffer_size_) - reloc_info_writer_.pos());
951
+ return Vector<byte>(reloc_info_writer_.pos(), result_size);
952
+ }
953
+
954
+ private:
955
+ void Grow() {
956
+ // Compute new buffer size.
957
+ int new_buffer_size;
958
+ if (buffer_size_ < 2 * KB) {
959
+ new_buffer_size = 4 * KB;
960
+ } else {
961
+ new_buffer_size = 2 * buffer_size_;
962
+ }
963
+ // Some internal data structures overflow for very large buffers,
964
+ // they must ensure that kMaximalBufferSize is not too large.
965
+ if (new_buffer_size > kMaximalBufferSize) {
966
+ V8::FatalProcessOutOfMemory("RelocInfoBuffer::GrowBuffer");
967
+ }
968
+
969
+ // Setup new buffer.
970
+ byte* new_buffer = NewArray<byte>(new_buffer_size);
971
+
972
+ // Copy the data.
973
+ int curently_used_size =
974
+ static_cast<int>(buffer_ + buffer_size_ - reloc_info_writer_.pos());
975
+ memmove(new_buffer + new_buffer_size - curently_used_size,
976
+ reloc_info_writer_.pos(), curently_used_size);
977
+
978
+ reloc_info_writer_.Reposition(
979
+ new_buffer + new_buffer_size - curently_used_size,
980
+ reloc_info_writer_.last_pc());
981
+
982
+ DeleteArray(buffer_);
983
+ buffer_ = new_buffer;
984
+ buffer_size_ = new_buffer_size;
985
+ }
986
+
987
+ RelocInfoWriter reloc_info_writer_;
988
+ byte* buffer_;
989
+ int buffer_size_;
990
+
991
+ static const int kBufferGap = 8;
992
+ static const int kMaximalBufferSize = 512*MB;
993
+ };
994
+
995
+ // Patch positions in code (changes relocation info section) and possibly
996
+ // returns new instance of code.
997
+ static Handle<Code> PatchPositionsInCode(Handle<Code> code,
998
+ Handle<JSArray> position_change_array) {
999
+
1000
+ RelocInfoBuffer buffer_writer(code->relocation_size(),
1001
+ code->instruction_start());
1002
+
1003
+ {
1004
+ AssertNoAllocation no_allocations_please;
1005
+ for (RelocIterator it(*code); !it.done(); it.next()) {
1006
+ RelocInfo* rinfo = it.rinfo();
1007
+ if (RelocInfo::IsPosition(rinfo->rmode())) {
1008
+ int position = static_cast<int>(rinfo->data());
1009
+ int new_position = TranslatePosition(position,
1010
+ position_change_array);
1011
+ if (position != new_position) {
1012
+ RelocInfo info_copy(rinfo->pc(), rinfo->rmode(), new_position);
1013
+ buffer_writer.Write(&info_copy);
1014
+ continue;
1015
+ }
1016
+ }
1017
+ buffer_writer.Write(it.rinfo());
1018
+ }
1019
+ }
1020
+
1021
+ Vector<byte> buffer = buffer_writer.GetResult();
1022
+
1023
+ if (buffer.length() == code->relocation_size()) {
1024
+ // Simply patch relocation area of code.
1025
+ memcpy(code->relocation_start(), buffer.start(), buffer.length());
1026
+ return code;
1027
+ } else {
1028
+ // Relocation info section now has different size. We cannot simply
1029
+ // rewrite it inside code object. Instead we have to create a new
1030
+ // code object.
1031
+ Handle<Code> result(Factory::CopyCode(code, buffer));
1032
+ return result;
1033
+ }
1034
+ }
1035
+
1036
+
1037
+ Object* LiveEdit::PatchFunctionPositions(
1038
+ Handle<JSArray> shared_info_array, Handle<JSArray> position_change_array) {
1039
+
1040
+ if (!SharedInfoWrapper::IsInstance(shared_info_array)) {
1041
+ return Top::ThrowIllegalOperation();
1042
+ }
1043
+
1044
+ SharedInfoWrapper shared_info_wrapper(shared_info_array);
1045
+ Handle<SharedFunctionInfo> info = shared_info_wrapper.GetInfo();
1046
+
1047
+ int old_function_start = info->start_position();
1048
+ int new_function_start = TranslatePosition(old_function_start,
1049
+ position_change_array);
1050
+ info->set_start_position(new_function_start);
1051
+ info->set_end_position(TranslatePosition(info->end_position(),
1052
+ position_change_array));
1053
+
1054
+ info->set_function_token_position(
1055
+ TranslatePosition(info->function_token_position(),
1056
+ position_change_array));
1057
+
1058
+ if (IsJSFunctionCode(info->code())) {
1059
+ // Patch relocation info section of the code.
1060
+ Handle<Code> patched_code = PatchPositionsInCode(Handle<Code>(info->code()),
1061
+ position_change_array);
1062
+ if (*patched_code != info->code()) {
1063
+ // Replace all references to the code across the heap. In particular,
1064
+ // some stubs may refer to this code and this code may be being executed
1065
+ // on stack (it is safe to substitute the code object on stack, because
1066
+ // we only change the structure of rinfo and leave instructions
1067
+ // untouched).
1068
+ ReplaceCodeObject(info->code(), *patched_code);
1069
+ }
1070
+ }
1071
+
1072
+ return Heap::undefined_value();
1073
+ }
1074
+
1075
+
1076
+ static Handle<Script> CreateScriptCopy(Handle<Script> original) {
1077
+ Handle<String> original_source(String::cast(original->source()));
1078
+
1079
+ Handle<Script> copy = Factory::NewScript(original_source);
1080
+
1081
+ copy->set_name(original->name());
1082
+ copy->set_line_offset(original->line_offset());
1083
+ copy->set_column_offset(original->column_offset());
1084
+ copy->set_data(original->data());
1085
+ copy->set_type(original->type());
1086
+ copy->set_context_data(original->context_data());
1087
+ copy->set_compilation_type(original->compilation_type());
1088
+ copy->set_eval_from_shared(original->eval_from_shared());
1089
+ copy->set_eval_from_instructions_offset(
1090
+ original->eval_from_instructions_offset());
1091
+
1092
+ return copy;
1093
+ }
1094
+
1095
+
1096
+ Object* LiveEdit::ChangeScriptSource(Handle<Script> original_script,
1097
+ Handle<String> new_source,
1098
+ Handle<Object> old_script_name) {
1099
+ Handle<Object> old_script_object;
1100
+ if (old_script_name->IsString()) {
1101
+ Handle<Script> old_script = CreateScriptCopy(original_script);
1102
+ old_script->set_name(String::cast(*old_script_name));
1103
+ old_script_object = old_script;
1104
+ Debugger::OnAfterCompile(old_script, Debugger::SEND_WHEN_DEBUGGING);
1105
+ } else {
1106
+ old_script_object = Handle<Object>(Heap::null_value());
1107
+ }
1108
+
1109
+ original_script->set_source(*new_source);
1110
+
1111
+ // Drop line ends so that they will be recalculated.
1112
+ original_script->set_line_ends(Heap::undefined_value());
1113
+
1114
+ return *old_script_object;
1115
+ }
1116
+
1117
+
1118
+
1119
+ void LiveEdit::ReplaceRefToNestedFunction(
1120
+ Handle<JSValue> parent_function_wrapper,
1121
+ Handle<JSValue> orig_function_wrapper,
1122
+ Handle<JSValue> subst_function_wrapper) {
1123
+
1124
+ Handle<SharedFunctionInfo> parent_shared =
1125
+ Handle<SharedFunctionInfo>::cast(UnwrapJSValue(parent_function_wrapper));
1126
+ Handle<SharedFunctionInfo> orig_shared =
1127
+ Handle<SharedFunctionInfo>::cast(UnwrapJSValue(orig_function_wrapper));
1128
+ Handle<SharedFunctionInfo> subst_shared =
1129
+ Handle<SharedFunctionInfo>::cast(UnwrapJSValue(subst_function_wrapper));
1130
+
1131
+ for (RelocIterator it(parent_shared->code()); !it.done(); it.next()) {
1132
+ if (it.rinfo()->rmode() == RelocInfo::EMBEDDED_OBJECT) {
1133
+ if (it.rinfo()->target_object() == *orig_shared) {
1134
+ it.rinfo()->set_target_object(*subst_shared);
1135
+ }
1136
+ }
1137
+ }
1138
+ }
1139
+
1140
+
1141
+ // Check an activation against list of functions. If there is a function
1142
+ // that matches, its status in result array is changed to status argument value.
1143
+ static bool CheckActivation(Handle<JSArray> shared_info_array,
1144
+ Handle<JSArray> result, StackFrame* frame,
1145
+ LiveEdit::FunctionPatchabilityStatus status) {
1146
+ if (!frame->is_java_script()) {
1147
+ return false;
1148
+ }
1149
+ int len = Smi::cast(shared_info_array->length())->value();
1150
+ for (int i = 0; i < len; i++) {
1151
+ JSValue* wrapper = JSValue::cast(shared_info_array->GetElement(i));
1152
+ Handle<SharedFunctionInfo> shared(
1153
+ SharedFunctionInfo::cast(wrapper->value()));
1154
+
1155
+ if (frame->code() == shared->code()) {
1156
+ SetElement(result, i, Handle<Smi>(Smi::FromInt(status)));
1157
+ return true;
1158
+ }
1159
+ }
1160
+ return false;
1161
+ }
1162
+
1163
+
1164
+ // Iterates over handler chain and removes all elements that are inside
1165
+ // frames being dropped.
1166
+ static bool FixTryCatchHandler(StackFrame* top_frame,
1167
+ StackFrame* bottom_frame) {
1168
+ Address* pointer_address =
1169
+ &Memory::Address_at(Top::get_address_from_id(Top::k_handler_address));
1170
+
1171
+ while (*pointer_address < top_frame->sp()) {
1172
+ pointer_address = &Memory::Address_at(*pointer_address);
1173
+ }
1174
+ Address* above_frame_address = pointer_address;
1175
+ while (*pointer_address < bottom_frame->fp()) {
1176
+ pointer_address = &Memory::Address_at(*pointer_address);
1177
+ }
1178
+ bool change = *above_frame_address != *pointer_address;
1179
+ *above_frame_address = *pointer_address;
1180
+ return change;
1181
+ }
1182
+
1183
+
1184
+ // Removes specified range of frames from stack. There may be 1 or more
1185
+ // frames in range. Anyway the bottom frame is restarted rather than dropped,
1186
+ // and therefore has to be a JavaScript frame.
1187
+ // Returns error message or NULL.
1188
+ static const char* DropFrames(Vector<StackFrame*> frames,
1189
+ int top_frame_index,
1190
+ int bottom_js_frame_index) {
1191
+ StackFrame* pre_top_frame = frames[top_frame_index - 1];
1192
+ StackFrame* top_frame = frames[top_frame_index];
1193
+ StackFrame* bottom_js_frame = frames[bottom_js_frame_index];
1194
+
1195
+ ASSERT(bottom_js_frame->is_java_script());
1196
+
1197
+ // Check the nature of the top frame.
1198
+ if (pre_top_frame->code()->is_inline_cache_stub() &&
1199
+ pre_top_frame->code()->ic_state() == DEBUG_BREAK) {
1200
+ // OK, we can drop inline cache calls.
1201
+ } else if (pre_top_frame->code() ==
1202
+ Builtins::builtin(Builtins::FrameDropper_LiveEdit)) {
1203
+ // OK, we can drop our own code.
1204
+ } else if (pre_top_frame->code()->kind() == Code::STUB &&
1205
+ pre_top_frame->code()->major_key()) {
1206
+ // Unit Test entry, it's fine, we support this case.
1207
+ } else {
1208
+ return "Unknown structure of stack above changing function";
1209
+ }
1210
+
1211
+ Address unused_stack_top = top_frame->sp();
1212
+ Address unused_stack_bottom = bottom_js_frame->fp()
1213
+ - Debug::kFrameDropperFrameSize * kPointerSize // Size of the new frame.
1214
+ + kPointerSize; // Bigger address end is exclusive.
1215
+
1216
+ if (unused_stack_top > unused_stack_bottom) {
1217
+ return "Not enough space for frame dropper frame";
1218
+ }
1219
+
1220
+ // Committing now. After this point we should return only NULL value.
1221
+
1222
+ FixTryCatchHandler(pre_top_frame, bottom_js_frame);
1223
+ // Make sure FixTryCatchHandler is idempotent.
1224
+ ASSERT(!FixTryCatchHandler(pre_top_frame, bottom_js_frame));
1225
+
1226
+ Handle<Code> code(Builtins::builtin(Builtins::FrameDropper_LiveEdit));
1227
+ top_frame->set_pc(code->entry());
1228
+ pre_top_frame->SetCallerFp(bottom_js_frame->fp());
1229
+
1230
+ Debug::SetUpFrameDropperFrame(bottom_js_frame, code);
1231
+
1232
+ for (Address a = unused_stack_top;
1233
+ a < unused_stack_bottom;
1234
+ a += kPointerSize) {
1235
+ Memory::Object_at(a) = Smi::FromInt(0);
1236
+ }
1237
+
1238
+ return NULL;
1239
+ }
1240
+
1241
+
1242
+ static bool IsDropableFrame(StackFrame* frame) {
1243
+ return !frame->is_exit();
1244
+ }
1245
+
1246
+ // Fills result array with statuses of functions. Modifies the stack
1247
+ // removing all listed function if possible and if do_drop is true.
1248
+ static const char* DropActivationsInActiveThread(
1249
+ Handle<JSArray> shared_info_array, Handle<JSArray> result, bool do_drop) {
1250
+
1251
+ ZoneScope scope(DELETE_ON_EXIT);
1252
+ Vector<StackFrame*> frames = CreateStackMap();
1253
+
1254
+ int array_len = Smi::cast(shared_info_array->length())->value();
1255
+
1256
+ int top_frame_index = -1;
1257
+ int frame_index = 0;
1258
+ for (; frame_index < frames.length(); frame_index++) {
1259
+ StackFrame* frame = frames[frame_index];
1260
+ if (frame->id() == Debug::break_frame_id()) {
1261
+ top_frame_index = frame_index;
1262
+ break;
1263
+ }
1264
+ if (CheckActivation(shared_info_array, result, frame,
1265
+ LiveEdit::FUNCTION_BLOCKED_UNDER_NATIVE_CODE)) {
1266
+ // We are still above break_frame. It is not a target frame,
1267
+ // it is a problem.
1268
+ return "Debugger mark-up on stack is not found";
1269
+ }
1270
+ }
1271
+
1272
+ if (top_frame_index == -1) {
1273
+ // We haven't found break frame, but no function is blocking us anyway.
1274
+ return NULL;
1275
+ }
1276
+
1277
+ bool target_frame_found = false;
1278
+ int bottom_js_frame_index = top_frame_index;
1279
+ bool c_code_found = false;
1280
+
1281
+ for (; frame_index < frames.length(); frame_index++) {
1282
+ StackFrame* frame = frames[frame_index];
1283
+ if (!IsDropableFrame(frame)) {
1284
+ c_code_found = true;
1285
+ break;
1286
+ }
1287
+ if (CheckActivation(shared_info_array, result, frame,
1288
+ LiveEdit::FUNCTION_BLOCKED_ON_ACTIVE_STACK)) {
1289
+ target_frame_found = true;
1290
+ bottom_js_frame_index = frame_index;
1291
+ }
1292
+ }
1293
+
1294
+ if (c_code_found) {
1295
+ // There is a C frames on stack. Check that there are no target frames
1296
+ // below them.
1297
+ for (; frame_index < frames.length(); frame_index++) {
1298
+ StackFrame* frame = frames[frame_index];
1299
+ if (frame->is_java_script()) {
1300
+ if (CheckActivation(shared_info_array, result, frame,
1301
+ LiveEdit::FUNCTION_BLOCKED_UNDER_NATIVE_CODE)) {
1302
+ // Cannot drop frame under C frames.
1303
+ return NULL;
1304
+ }
1305
+ }
1306
+ }
1307
+ }
1308
+
1309
+ if (!do_drop) {
1310
+ // We are in check-only mode.
1311
+ return NULL;
1312
+ }
1313
+
1314
+ if (!target_frame_found) {
1315
+ // Nothing to drop.
1316
+ return NULL;
1317
+ }
1318
+
1319
+ const char* error_message = DropFrames(frames, top_frame_index,
1320
+ bottom_js_frame_index);
1321
+
1322
+ if (error_message != NULL) {
1323
+ return error_message;
1324
+ }
1325
+
1326
+ // Adjust break_frame after some frames has been dropped.
1327
+ StackFrame::Id new_id = StackFrame::NO_ID;
1328
+ for (int i = bottom_js_frame_index + 1; i < frames.length(); i++) {
1329
+ if (frames[i]->type() == StackFrame::JAVA_SCRIPT) {
1330
+ new_id = frames[i]->id();
1331
+ break;
1332
+ }
1333
+ }
1334
+ Debug::FramesHaveBeenDropped(new_id);
1335
+
1336
+ // Replace "blocked on active" with "replaced on active" status.
1337
+ for (int i = 0; i < array_len; i++) {
1338
+ if (result->GetElement(i) ==
1339
+ Smi::FromInt(LiveEdit::FUNCTION_BLOCKED_ON_ACTIVE_STACK)) {
1340
+ result->SetElement(i, Smi::FromInt(
1341
+ LiveEdit::FUNCTION_REPLACED_ON_ACTIVE_STACK));
1342
+ }
1343
+ }
1344
+ return NULL;
1345
+ }
1346
+
1347
+
1348
+ class InactiveThreadActivationsChecker : public ThreadVisitor {
1349
+ public:
1350
+ InactiveThreadActivationsChecker(Handle<JSArray> shared_info_array,
1351
+ Handle<JSArray> result)
1352
+ : shared_info_array_(shared_info_array), result_(result),
1353
+ has_blocked_functions_(false) {
1354
+ }
1355
+ void VisitThread(ThreadLocalTop* top) {
1356
+ for (StackFrameIterator it(top); !it.done(); it.Advance()) {
1357
+ has_blocked_functions_ |= CheckActivation(
1358
+ shared_info_array_, result_, it.frame(),
1359
+ LiveEdit::FUNCTION_BLOCKED_ON_OTHER_STACK);
1360
+ }
1361
+ }
1362
+ bool HasBlockedFunctions() {
1363
+ return has_blocked_functions_;
1364
+ }
1365
+
1366
+ private:
1367
+ Handle<JSArray> shared_info_array_;
1368
+ Handle<JSArray> result_;
1369
+ bool has_blocked_functions_;
1370
+ };
1371
+
1372
+
1373
+ Handle<JSArray> LiveEdit::CheckAndDropActivations(
1374
+ Handle<JSArray> shared_info_array, bool do_drop) {
1375
+ int len = Smi::cast(shared_info_array->length())->value();
1376
+
1377
+ Handle<JSArray> result = Factory::NewJSArray(len);
1378
+
1379
+ // Fill the default values.
1380
+ for (int i = 0; i < len; i++) {
1381
+ SetElement(result, i,
1382
+ Handle<Smi>(Smi::FromInt(FUNCTION_AVAILABLE_FOR_PATCH)));
1383
+ }
1384
+
1385
+
1386
+ // First check inactive threads. Fail if some functions are blocked there.
1387
+ InactiveThreadActivationsChecker inactive_threads_checker(shared_info_array,
1388
+ result);
1389
+ ThreadManager::IterateThreads(&inactive_threads_checker);
1390
+ if (inactive_threads_checker.HasBlockedFunctions()) {
1391
+ return result;
1392
+ }
1393
+
1394
+ // Try to drop activations from the current stack.
1395
+ const char* error_message =
1396
+ DropActivationsInActiveThread(shared_info_array, result, do_drop);
1397
+ if (error_message != NULL) {
1398
+ // Add error message as an array extra element.
1399
+ Vector<const char> vector_message(error_message, StrLength(error_message));
1400
+ Handle<String> str = Factory::NewStringFromAscii(vector_message);
1401
+ SetElement(result, len, str);
1402
+ }
1403
+ return result;
1404
+ }
1405
+
1406
+
1407
+ LiveEditFunctionTracker::LiveEditFunctionTracker(FunctionLiteral* fun) {
1408
+ if (active_function_info_listener != NULL) {
1409
+ active_function_info_listener->FunctionStarted(fun);
1410
+ }
1411
+ }
1412
+
1413
+
1414
+ LiveEditFunctionTracker::~LiveEditFunctionTracker() {
1415
+ if (active_function_info_listener != NULL) {
1416
+ active_function_info_listener->FunctionDone();
1417
+ }
1418
+ }
1419
+
1420
+
1421
+ void LiveEditFunctionTracker::RecordFunctionInfo(
1422
+ Handle<SharedFunctionInfo> info, FunctionLiteral* lit) {
1423
+ if (active_function_info_listener != NULL) {
1424
+ active_function_info_listener->FunctionInfo(info, lit->scope());
1425
+ }
1426
+ }
1427
+
1428
+
1429
+ void LiveEditFunctionTracker::RecordRootFunctionInfo(Handle<Code> code) {
1430
+ active_function_info_listener->FunctionCode(code);
1431
+ }
1432
+
1433
+
1434
+ bool LiveEditFunctionTracker::IsActive() {
1435
+ return active_function_info_listener != NULL;
1436
+ }
1437
+
1438
+
1439
+ #else // ENABLE_DEBUGGER_SUPPORT
1440
+
1441
+ // This ifdef-else-endif section provides working or stub implementation of
1442
+ // LiveEditFunctionTracker.
1443
+ LiveEditFunctionTracker::LiveEditFunctionTracker(FunctionLiteral* fun) {
1444
+ }
1445
+
1446
+
1447
+ LiveEditFunctionTracker::~LiveEditFunctionTracker() {
1448
+ }
1449
+
1450
+
1451
+ void LiveEditFunctionTracker::RecordFunctionInfo(
1452
+ Handle<SharedFunctionInfo> info, FunctionLiteral* lit) {
1453
+ }
1454
+
1455
+
1456
+ void LiveEditFunctionTracker::RecordRootFunctionInfo(Handle<Code> code) {
1457
+ }
1458
+
1459
+
1460
+ bool LiveEditFunctionTracker::IsActive() {
1461
+ return false;
1462
+ }
1463
+
1464
+ #endif // ENABLE_DEBUGGER_SUPPORT
1465
+
1466
+
1467
+
1468
+ } } // namespace v8::internal