therubyracer 0.9.0beta2 → 0.9.0beta3

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 (920) hide show
  1. data/.gitmodules +3 -0
  2. data/ext/v8/upstream/Makefile +1 -2
  3. data/ext/v8/upstream/v8/.gitignore +33 -0
  4. data/ext/v8/upstream/v8/AUTHORS +42 -0
  5. data/ext/v8/upstream/v8/ChangeLog +2663 -0
  6. data/ext/v8/upstream/{3.1.8 → v8}/LICENSE +0 -0
  7. data/ext/v8/upstream/{3.1.8 → v8}/LICENSE.strongtalk +0 -0
  8. data/ext/v8/upstream/{3.1.8 → v8}/LICENSE.v8 +0 -0
  9. data/ext/v8/upstream/{3.1.8 → v8}/LICENSE.valgrind +0 -0
  10. data/ext/v8/upstream/v8/SConstruct +1473 -0
  11. data/ext/v8/upstream/{3.1.8 → v8}/build/README.txt +0 -0
  12. data/ext/v8/upstream/{3.1.8 → v8}/build/all.gyp +0 -0
  13. data/ext/v8/upstream/{3.1.8 → v8}/build/armu.gypi +0 -0
  14. data/ext/v8/upstream/{3.1.8 → v8}/build/common.gypi +0 -0
  15. data/ext/v8/upstream/{3.1.8 → v8}/build/gyp_v8 +0 -0
  16. data/ext/v8/upstream/v8/include/v8-debug.h +394 -0
  17. data/ext/v8/upstream/v8/include/v8-preparser.h +116 -0
  18. data/ext/v8/upstream/v8/include/v8-profiler.h +505 -0
  19. data/ext/v8/upstream/v8/include/v8-testing.h +104 -0
  20. data/ext/v8/upstream/v8/include/v8.h +4000 -0
  21. data/ext/v8/upstream/{3.1.8 → v8}/include/v8stdint.h +0 -0
  22. data/ext/v8/upstream/v8/preparser/SConscript +38 -0
  23. data/ext/v8/upstream/v8/preparser/preparser-process.cc +169 -0
  24. data/ext/v8/upstream/v8/src/SConscript +380 -0
  25. data/ext/v8/upstream/v8/src/accessors.cc +766 -0
  26. data/ext/v8/upstream/{3.1.8 → v8}/src/accessors.h +0 -0
  27. data/ext/v8/upstream/v8/src/allocation-inl.h +49 -0
  28. data/ext/v8/upstream/v8/src/allocation.cc +122 -0
  29. data/ext/v8/upstream/v8/src/allocation.h +143 -0
  30. data/ext/v8/upstream/v8/src/api.cc +5678 -0
  31. data/ext/v8/upstream/v8/src/api.h +572 -0
  32. data/ext/v8/upstream/{3.1.8 → v8}/src/apinatives.js +0 -0
  33. data/ext/v8/upstream/v8/src/apiutils.h +73 -0
  34. data/ext/v8/upstream/v8/src/arguments.h +116 -0
  35. data/ext/v8/upstream/v8/src/arm/assembler-arm-inl.h +353 -0
  36. data/ext/v8/upstream/v8/src/arm/assembler-arm.cc +2877 -0
  37. data/ext/v8/upstream/v8/src/arm/assembler-arm.h +1382 -0
  38. data/ext/v8/upstream/v8/src/arm/builtins-arm.cc +1634 -0
  39. data/ext/v8/upstream/v8/src/arm/code-stubs-arm.cc +6917 -0
  40. data/ext/v8/upstream/v8/src/arm/code-stubs-arm.h +623 -0
  41. data/ext/v8/upstream/{3.1.8 → v8}/src/arm/codegen-arm-inl.h +0 -0
  42. data/ext/v8/upstream/v8/src/arm/codegen-arm.cc +7437 -0
  43. data/ext/v8/upstream/v8/src/arm/codegen-arm.h +595 -0
  44. data/ext/v8/upstream/{3.1.8 → v8}/src/arm/constants-arm.cc +0 -0
  45. data/ext/v8/upstream/v8/src/arm/constants-arm.h +778 -0
  46. data/ext/v8/upstream/v8/src/arm/cpu-arm.cc +149 -0
  47. data/ext/v8/upstream/v8/src/arm/debug-arm.cc +317 -0
  48. data/ext/v8/upstream/v8/src/arm/deoptimizer-arm.cc +737 -0
  49. data/ext/v8/upstream/v8/src/arm/disasm-arm.cc +1503 -0
  50. data/ext/v8/upstream/{3.1.8 → v8}/src/arm/frames-arm.cc +0 -0
  51. data/ext/v8/upstream/v8/src/arm/frames-arm.h +168 -0
  52. data/ext/v8/upstream/v8/src/arm/full-codegen-arm.cc +4374 -0
  53. data/ext/v8/upstream/v8/src/arm/ic-arm.cc +1793 -0
  54. data/ext/v8/upstream/{3.1.8 → v8}/src/arm/jump-target-arm.cc +0 -0
  55. data/ext/v8/upstream/v8/src/arm/lithium-arm.cc +2120 -0
  56. data/ext/v8/upstream/v8/src/arm/lithium-arm.h +2179 -0
  57. data/ext/v8/upstream/v8/src/arm/lithium-codegen-arm.cc +4132 -0
  58. data/ext/v8/upstream/v8/src/arm/lithium-codegen-arm.h +329 -0
  59. data/ext/v8/upstream/v8/src/arm/lithium-gap-resolver-arm.cc +305 -0
  60. data/ext/v8/upstream/{3.1.8 → v8}/src/arm/lithium-gap-resolver-arm.h +0 -0
  61. data/ext/v8/upstream/v8/src/arm/macro-assembler-arm.cc +2939 -0
  62. data/ext/v8/upstream/v8/src/arm/macro-assembler-arm.h +1071 -0
  63. data/ext/v8/upstream/v8/src/arm/regexp-macro-assembler-arm.cc +1287 -0
  64. data/ext/v8/upstream/v8/src/arm/regexp-macro-assembler-arm.h +253 -0
  65. data/ext/v8/upstream/{3.1.8 → v8}/src/arm/register-allocator-arm-inl.h +0 -0
  66. data/ext/v8/upstream/{3.1.8 → v8}/src/arm/register-allocator-arm.cc +0 -0
  67. data/ext/v8/upstream/{3.1.8 → v8}/src/arm/register-allocator-arm.h +0 -0
  68. data/ext/v8/upstream/v8/src/arm/simulator-arm.cc +3288 -0
  69. data/ext/v8/upstream/v8/src/arm/simulator-arm.h +413 -0
  70. data/ext/v8/upstream/v8/src/arm/stub-cache-arm.cc +4034 -0
  71. data/ext/v8/upstream/{3.1.8 → v8}/src/arm/virtual-frame-arm-inl.h +0 -0
  72. data/ext/v8/upstream/v8/src/arm/virtual-frame-arm.cc +843 -0
  73. data/ext/v8/upstream/v8/src/arm/virtual-frame-arm.h +523 -0
  74. data/ext/v8/upstream/v8/src/array.js +1249 -0
  75. data/ext/v8/upstream/v8/src/assembler.cc +1067 -0
  76. data/ext/v8/upstream/v8/src/assembler.h +823 -0
  77. data/ext/v8/upstream/v8/src/ast-inl.h +112 -0
  78. data/ext/v8/upstream/v8/src/ast.cc +1078 -0
  79. data/ext/v8/upstream/v8/src/ast.h +2234 -0
  80. data/ext/v8/upstream/v8/src/atomicops.h +167 -0
  81. data/ext/v8/upstream/{3.1.8 → v8}/src/atomicops_internals_arm_gcc.h +0 -0
  82. data/ext/v8/upstream/v8/src/atomicops_internals_mips_gcc.h +169 -0
  83. data/ext/v8/upstream/{3.1.8 → v8}/src/atomicops_internals_x86_gcc.cc +0 -0
  84. data/ext/v8/upstream/{3.1.8 → v8}/src/atomicops_internals_x86_gcc.h +0 -0
  85. data/ext/v8/upstream/{3.1.8 → v8}/src/atomicops_internals_x86_macosx.h +0 -0
  86. data/ext/v8/upstream/{3.1.8 → v8}/src/atomicops_internals_x86_msvc.h +0 -0
  87. data/ext/v8/upstream/{3.1.8 → v8}/src/bignum-dtoa.cc +0 -0
  88. data/ext/v8/upstream/{3.1.8 → v8}/src/bignum-dtoa.h +0 -0
  89. data/ext/v8/upstream/{3.1.8 → v8}/src/bignum.cc +0 -0
  90. data/ext/v8/upstream/{3.1.8 → v8}/src/bignum.h +0 -0
  91. data/ext/v8/upstream/v8/src/bootstrapper.cc +2138 -0
  92. data/ext/v8/upstream/v8/src/bootstrapper.h +185 -0
  93. data/ext/v8/upstream/v8/src/builtins.cc +1708 -0
  94. data/ext/v8/upstream/v8/src/builtins.h +368 -0
  95. data/ext/v8/upstream/{3.1.8 → v8}/src/bytecodes-irregexp.h +0 -0
  96. data/ext/v8/upstream/{3.1.8 → v8}/src/cached-powers.cc +0 -0
  97. data/ext/v8/upstream/{3.1.8 → v8}/src/cached-powers.h +0 -0
  98. data/ext/v8/upstream/{3.1.8 → v8}/src/char-predicates-inl.h +0 -0
  99. data/ext/v8/upstream/{3.1.8 → v8}/src/char-predicates.h +0 -0
  100. data/ext/v8/upstream/v8/src/checks.cc +110 -0
  101. data/ext/v8/upstream/v8/src/checks.h +296 -0
  102. data/ext/v8/upstream/{3.1.8 → v8}/src/circular-queue-inl.h +0 -0
  103. data/ext/v8/upstream/{3.1.8 → v8}/src/circular-queue.cc +0 -0
  104. data/ext/v8/upstream/{3.1.8 → v8}/src/circular-queue.h +0 -0
  105. data/ext/v8/upstream/v8/src/code-stubs.cc +240 -0
  106. data/ext/v8/upstream/v8/src/code-stubs.h +971 -0
  107. data/ext/v8/upstream/{3.1.8 → v8}/src/code.h +0 -0
  108. data/ext/v8/upstream/v8/src/codegen-inl.h +68 -0
  109. data/ext/v8/upstream/v8/src/codegen.cc +505 -0
  110. data/ext/v8/upstream/v8/src/codegen.h +245 -0
  111. data/ext/v8/upstream/v8/src/compilation-cache.cc +540 -0
  112. data/ext/v8/upstream/v8/src/compilation-cache.h +287 -0
  113. data/ext/v8/upstream/v8/src/compiler.cc +792 -0
  114. data/ext/v8/upstream/v8/src/compiler.h +307 -0
  115. data/ext/v8/upstream/v8/src/contexts.cc +327 -0
  116. data/ext/v8/upstream/v8/src/contexts.h +382 -0
  117. data/ext/v8/upstream/{3.1.8 → v8}/src/conversions-inl.h +0 -0
  118. data/ext/v8/upstream/v8/src/conversions.cc +1125 -0
  119. data/ext/v8/upstream/{3.1.8 → v8}/src/conversions.h +0 -0
  120. data/ext/v8/upstream/v8/src/counters.cc +93 -0
  121. data/ext/v8/upstream/v8/src/counters.h +254 -0
  122. data/ext/v8/upstream/v8/src/cpu-profiler-inl.h +101 -0
  123. data/ext/v8/upstream/v8/src/cpu-profiler.cc +606 -0
  124. data/ext/v8/upstream/v8/src/cpu-profiler.h +305 -0
  125. data/ext/v8/upstream/v8/src/cpu.h +67 -0
  126. data/ext/v8/upstream/v8/src/d8-debug.cc +367 -0
  127. data/ext/v8/upstream/v8/src/d8-debug.h +158 -0
  128. data/ext/v8/upstream/v8/src/d8-posix.cc +695 -0
  129. data/ext/v8/upstream/{3.1.8 → v8}/src/d8-readline.cc +0 -0
  130. data/ext/v8/upstream/{3.1.8 → v8}/src/d8-windows.cc +0 -0
  131. data/ext/v8/upstream/v8/src/d8.cc +796 -0
  132. data/ext/v8/upstream/v8/src/d8.gyp +88 -0
  133. data/ext/v8/upstream/{3.1.8 → v8}/src/d8.h +0 -0
  134. data/ext/v8/upstream/{3.1.8 → v8}/src/d8.js +0 -0
  135. data/ext/v8/upstream/{3.1.8 → v8}/src/data-flow.cc +0 -0
  136. data/ext/v8/upstream/v8/src/data-flow.h +379 -0
  137. data/ext/v8/upstream/{3.1.8 → v8}/src/date.js +0 -0
  138. data/ext/v8/upstream/{3.1.8 → v8}/src/dateparser-inl.h +0 -0
  139. data/ext/v8/upstream/{3.1.8 → v8}/src/dateparser.cc +0 -0
  140. data/ext/v8/upstream/v8/src/dateparser.h +265 -0
  141. data/ext/v8/upstream/v8/src/debug-agent.cc +447 -0
  142. data/ext/v8/upstream/v8/src/debug-agent.h +129 -0
  143. data/ext/v8/upstream/{3.1.8 → v8}/src/debug-debugger.js +0 -0
  144. data/ext/v8/upstream/v8/src/debug.cc +3188 -0
  145. data/ext/v8/upstream/v8/src/debug.h +1055 -0
  146. data/ext/v8/upstream/v8/src/deoptimizer.cc +1296 -0
  147. data/ext/v8/upstream/v8/src/deoptimizer.h +629 -0
  148. data/ext/v8/upstream/v8/src/disasm.h +80 -0
  149. data/ext/v8/upstream/v8/src/disassembler.cc +339 -0
  150. data/ext/v8/upstream/{3.1.8 → v8}/src/disassembler.h +0 -0
  151. data/ext/v8/upstream/{3.1.8 → v8}/src/diy-fp.cc +0 -0
  152. data/ext/v8/upstream/{3.1.8 → v8}/src/diy-fp.h +0 -0
  153. data/ext/v8/upstream/{3.1.8 → v8}/src/double.h +0 -0
  154. data/ext/v8/upstream/{3.1.8 → v8}/src/dtoa.cc +0 -0
  155. data/ext/v8/upstream/{3.1.8 → v8}/src/dtoa.h +0 -0
  156. data/ext/v8/upstream/v8/src/execution.cc +791 -0
  157. data/ext/v8/upstream/v8/src/execution.h +291 -0
  158. data/ext/v8/upstream/v8/src/extensions/experimental/break-iterator.cc +250 -0
  159. data/ext/v8/upstream/v8/src/extensions/experimental/break-iterator.h +89 -0
  160. data/ext/v8/upstream/v8/src/extensions/experimental/experimental.gyp +55 -0
  161. data/ext/v8/upstream/v8/src/extensions/experimental/i18n-extension.cc +284 -0
  162. data/ext/v8/upstream/{3.1.8 → v8}/src/extensions/experimental/i18n-extension.h +0 -0
  163. data/ext/v8/upstream/v8/src/extensions/externalize-string-extension.cc +141 -0
  164. data/ext/v8/upstream/{3.1.8 → v8}/src/extensions/externalize-string-extension.h +0 -0
  165. data/ext/v8/upstream/v8/src/extensions/gc-extension.cc +58 -0
  166. data/ext/v8/upstream/{3.1.8 → v8}/src/extensions/gc-extension.h +0 -0
  167. data/ext/v8/upstream/v8/src/factory.cc +1194 -0
  168. data/ext/v8/upstream/v8/src/factory.h +436 -0
  169. data/ext/v8/upstream/{3.1.8 → v8}/src/fast-dtoa.cc +0 -0
  170. data/ext/v8/upstream/{3.1.8 → v8}/src/fast-dtoa.h +0 -0
  171. data/ext/v8/upstream/{3.1.8 → v8}/src/fixed-dtoa.cc +0 -0
  172. data/ext/v8/upstream/{3.1.8 → v8}/src/fixed-dtoa.h +0 -0
  173. data/ext/v8/upstream/v8/src/flag-definitions.h +556 -0
  174. data/ext/v8/upstream/{3.1.8 → v8}/src/flags.cc +0 -0
  175. data/ext/v8/upstream/{3.1.8 → v8}/src/flags.h +0 -0
  176. data/ext/v8/upstream/v8/src/frame-element.cc +37 -0
  177. data/ext/v8/upstream/v8/src/frame-element.h +269 -0
  178. data/ext/v8/upstream/v8/src/frames-inl.h +236 -0
  179. data/ext/v8/upstream/v8/src/frames.cc +1273 -0
  180. data/ext/v8/upstream/v8/src/frames.h +854 -0
  181. data/ext/v8/upstream/v8/src/full-codegen.cc +1385 -0
  182. data/ext/v8/upstream/v8/src/full-codegen.h +753 -0
  183. data/ext/v8/upstream/v8/src/func-name-inferrer.cc +91 -0
  184. data/ext/v8/upstream/v8/src/func-name-inferrer.h +111 -0
  185. data/ext/v8/upstream/v8/src/gdb-jit.cc +1548 -0
  186. data/ext/v8/upstream/{3.1.8 → v8}/src/gdb-jit.h +0 -0
  187. data/ext/v8/upstream/v8/src/global-handles.cc +596 -0
  188. data/ext/v8/upstream/v8/src/global-handles.h +239 -0
  189. data/ext/v8/upstream/v8/src/globals.h +325 -0
  190. data/ext/v8/upstream/v8/src/handles-inl.h +177 -0
  191. data/ext/v8/upstream/v8/src/handles.cc +965 -0
  192. data/ext/v8/upstream/v8/src/handles.h +372 -0
  193. data/ext/v8/upstream/{3.1.8 → v8}/src/hashmap.cc +0 -0
  194. data/ext/v8/upstream/v8/src/hashmap.h +121 -0
  195. data/ext/v8/upstream/v8/src/heap-inl.h +703 -0
  196. data/ext/v8/upstream/v8/src/heap-profiler.cc +1173 -0
  197. data/ext/v8/upstream/v8/src/heap-profiler.h +396 -0
  198. data/ext/v8/upstream/v8/src/heap.cc +5856 -0
  199. data/ext/v8/upstream/v8/src/heap.h +2264 -0
  200. data/ext/v8/upstream/v8/src/hydrogen-instructions.cc +1639 -0
  201. data/ext/v8/upstream/v8/src/hydrogen-instructions.h +3657 -0
  202. data/ext/v8/upstream/v8/src/hydrogen.cc +6011 -0
  203. data/ext/v8/upstream/v8/src/hydrogen.h +1137 -0
  204. data/ext/v8/upstream/v8/src/ia32/assembler-ia32-inl.h +430 -0
  205. data/ext/v8/upstream/v8/src/ia32/assembler-ia32.cc +2846 -0
  206. data/ext/v8/upstream/v8/src/ia32/assembler-ia32.h +1159 -0
  207. data/ext/v8/upstream/v8/src/ia32/builtins-ia32.cc +1596 -0
  208. data/ext/v8/upstream/v8/src/ia32/code-stubs-ia32.cc +6549 -0
  209. data/ext/v8/upstream/v8/src/ia32/code-stubs-ia32.h +495 -0
  210. data/ext/v8/upstream/{3.1.8 → v8}/src/ia32/codegen-ia32-inl.h +0 -0
  211. data/ext/v8/upstream/v8/src/ia32/codegen-ia32.cc +10385 -0
  212. data/ext/v8/upstream/v8/src/ia32/codegen-ia32.h +801 -0
  213. data/ext/v8/upstream/v8/src/ia32/cpu-ia32.cc +88 -0
  214. data/ext/v8/upstream/v8/src/ia32/debug-ia32.cc +312 -0
  215. data/ext/v8/upstream/v8/src/ia32/deoptimizer-ia32.cc +774 -0
  216. data/ext/v8/upstream/v8/src/ia32/disasm-ia32.cc +1620 -0
  217. data/ext/v8/upstream/{3.1.8 → v8}/src/ia32/frames-ia32.cc +0 -0
  218. data/ext/v8/upstream/v8/src/ia32/frames-ia32.h +140 -0
  219. data/ext/v8/upstream/v8/src/ia32/full-codegen-ia32.cc +4357 -0
  220. data/ext/v8/upstream/v8/src/ia32/ic-ia32.cc +1779 -0
  221. data/ext/v8/upstream/{3.1.8 → v8}/src/ia32/jump-target-ia32.cc +0 -0
  222. data/ext/v8/upstream/v8/src/ia32/lithium-codegen-ia32.cc +4158 -0
  223. data/ext/v8/upstream/v8/src/ia32/lithium-codegen-ia32.h +318 -0
  224. data/ext/v8/upstream/v8/src/ia32/lithium-gap-resolver-ia32.cc +466 -0
  225. data/ext/v8/upstream/{3.1.8 → v8}/src/ia32/lithium-gap-resolver-ia32.h +0 -0
  226. data/ext/v8/upstream/v8/src/ia32/lithium-ia32.cc +2181 -0
  227. data/ext/v8/upstream/v8/src/ia32/lithium-ia32.h +2235 -0
  228. data/ext/v8/upstream/v8/src/ia32/macro-assembler-ia32.cc +2056 -0
  229. data/ext/v8/upstream/v8/src/ia32/macro-assembler-ia32.h +807 -0
  230. data/ext/v8/upstream/v8/src/ia32/regexp-macro-assembler-ia32.cc +1264 -0
  231. data/ext/v8/upstream/v8/src/ia32/regexp-macro-assembler-ia32.h +216 -0
  232. data/ext/v8/upstream/{3.1.8 → v8}/src/ia32/register-allocator-ia32-inl.h +0 -0
  233. data/ext/v8/upstream/v8/src/ia32/register-allocator-ia32.cc +157 -0
  234. data/ext/v8/upstream/{3.1.8 → v8}/src/ia32/register-allocator-ia32.h +0 -0
  235. data/ext/v8/upstream/{3.1.8 → v8}/src/ia32/simulator-ia32.cc +0 -0
  236. data/ext/v8/upstream/v8/src/ia32/simulator-ia32.h +72 -0
  237. data/ext/v8/upstream/v8/src/ia32/stub-cache-ia32.cc +3711 -0
  238. data/ext/v8/upstream/v8/src/ia32/virtual-frame-ia32.cc +1366 -0
  239. data/ext/v8/upstream/v8/src/ia32/virtual-frame-ia32.h +650 -0
  240. data/ext/v8/upstream/v8/src/ic-inl.h +130 -0
  241. data/ext/v8/upstream/v8/src/ic.cc +2389 -0
  242. data/ext/v8/upstream/v8/src/ic.h +675 -0
  243. data/ext/v8/upstream/{3.1.8 → v8}/src/inspector.cc +0 -0
  244. data/ext/v8/upstream/{3.1.8 → v8}/src/inspector.h +0 -0
  245. data/ext/v8/upstream/v8/src/interpreter-irregexp.cc +659 -0
  246. data/ext/v8/upstream/v8/src/interpreter-irregexp.h +49 -0
  247. data/ext/v8/upstream/v8/src/isolate.cc +883 -0
  248. data/ext/v8/upstream/v8/src/isolate.h +1306 -0
  249. data/ext/v8/upstream/v8/src/json.js +342 -0
  250. data/ext/v8/upstream/v8/src/jsregexp.cc +5371 -0
  251. data/ext/v8/upstream/v8/src/jsregexp.h +1483 -0
  252. data/ext/v8/upstream/{3.1.8 → v8}/src/jump-target-heavy-inl.h +0 -0
  253. data/ext/v8/upstream/v8/src/jump-target-heavy.cc +427 -0
  254. data/ext/v8/upstream/v8/src/jump-target-heavy.h +238 -0
  255. data/ext/v8/upstream/v8/src/jump-target-inl.h +48 -0
  256. data/ext/v8/upstream/{3.1.8 → v8}/src/jump-target-light-inl.h +0 -0
  257. data/ext/v8/upstream/v8/src/jump-target-light.cc +111 -0
  258. data/ext/v8/upstream/{3.1.8 → v8}/src/jump-target-light.h +0 -0
  259. data/ext/v8/upstream/{3.1.8 → v8}/src/jump-target.cc +0 -0
  260. data/ext/v8/upstream/{3.1.8 → v8}/src/jump-target.h +0 -0
  261. data/ext/v8/upstream/{3.1.8 → v8}/src/list-inl.h +0 -0
  262. data/ext/v8/upstream/{3.1.8 → v8}/src/list.h +0 -0
  263. data/ext/v8/upstream/v8/src/lithium-allocator-inl.h +142 -0
  264. data/ext/v8/upstream/v8/src/lithium-allocator.cc +2105 -0
  265. data/ext/v8/upstream/v8/src/lithium-allocator.h +630 -0
  266. data/ext/v8/upstream/v8/src/lithium.cc +169 -0
  267. data/ext/v8/upstream/{3.1.8 → v8}/src/lithium.h +0 -0
  268. data/ext/v8/upstream/{3.1.8 → v8}/src/liveedit-debugger.js +0 -0
  269. data/ext/v8/upstream/v8/src/liveedit.cc +1693 -0
  270. data/ext/v8/upstream/v8/src/liveedit.h +179 -0
  271. data/ext/v8/upstream/{3.1.8 → v8}/src/liveobjectlist-inl.h +0 -0
  272. data/ext/v8/upstream/v8/src/liveobjectlist.cc +2589 -0
  273. data/ext/v8/upstream/v8/src/liveobjectlist.h +322 -0
  274. data/ext/v8/upstream/{3.1.8 → v8}/src/log-inl.h +0 -0
  275. data/ext/v8/upstream/v8/src/log-utils.cc +423 -0
  276. data/ext/v8/upstream/v8/src/log-utils.h +229 -0
  277. data/ext/v8/upstream/v8/src/log.cc +1666 -0
  278. data/ext/v8/upstream/v8/src/log.h +446 -0
  279. data/ext/v8/upstream/{3.1.8 → v8}/src/macro-assembler.h +0 -0
  280. data/ext/v8/upstream/{3.1.8 → v8}/src/macros.py +0 -0
  281. data/ext/v8/upstream/v8/src/mark-compact.cc +3092 -0
  282. data/ext/v8/upstream/v8/src/mark-compact.h +506 -0
  283. data/ext/v8/upstream/{3.1.8 → v8}/src/math.js +0 -0
  284. data/ext/v8/upstream/v8/src/messages.cc +166 -0
  285. data/ext/v8/upstream/{3.1.8 → v8}/src/messages.h +0 -0
  286. data/ext/v8/upstream/v8/src/messages.js +1090 -0
  287. data/ext/v8/upstream/v8/src/mips/assembler-mips-inl.h +335 -0
  288. data/ext/v8/upstream/v8/src/mips/assembler-mips.cc +2093 -0
  289. data/ext/v8/upstream/v8/src/mips/assembler-mips.h +1066 -0
  290. data/ext/v8/upstream/v8/src/mips/builtins-mips.cc +148 -0
  291. data/ext/v8/upstream/v8/src/mips/code-stubs-mips.cc +752 -0
  292. data/ext/v8/upstream/v8/src/mips/code-stubs-mips.h +511 -0
  293. data/ext/v8/upstream/v8/src/mips/codegen-mips-inl.h +64 -0
  294. data/ext/v8/upstream/v8/src/mips/codegen-mips.cc +1213 -0
  295. data/ext/v8/upstream/v8/src/mips/codegen-mips.h +633 -0
  296. data/ext/v8/upstream/v8/src/mips/constants-mips.cc +352 -0
  297. data/ext/v8/upstream/v8/src/mips/constants-mips.h +723 -0
  298. data/ext/v8/upstream/v8/src/mips/cpu-mips.cc +90 -0
  299. data/ext/v8/upstream/v8/src/mips/debug-mips.cc +155 -0
  300. data/ext/v8/upstream/v8/src/mips/deoptimizer-mips.cc +91 -0
  301. data/ext/v8/upstream/v8/src/mips/disasm-mips.cc +1023 -0
  302. data/ext/v8/upstream/v8/src/mips/frames-mips.cc +48 -0
  303. data/ext/v8/upstream/v8/src/mips/frames-mips.h +179 -0
  304. data/ext/v8/upstream/v8/src/mips/full-codegen-mips.cc +727 -0
  305. data/ext/v8/upstream/v8/src/mips/ic-mips.cc +244 -0
  306. data/ext/v8/upstream/v8/src/mips/jump-target-mips.cc +80 -0
  307. data/ext/v8/upstream/v8/src/mips/lithium-codegen-mips.h +65 -0
  308. data/ext/v8/upstream/v8/src/mips/lithium-mips.h +304 -0
  309. data/ext/v8/upstream/v8/src/mips/macro-assembler-mips.cc +3327 -0
  310. data/ext/v8/upstream/v8/src/mips/macro-assembler-mips.h +1058 -0
  311. data/ext/v8/upstream/v8/src/mips/regexp-macro-assembler-mips.cc +478 -0
  312. data/ext/v8/upstream/v8/src/mips/regexp-macro-assembler-mips.h +250 -0
  313. data/ext/v8/upstream/v8/src/mips/register-allocator-mips-inl.h +134 -0
  314. data/ext/v8/upstream/{3.1.8 → v8}/src/mips/register-allocator-mips.cc +0 -0
  315. data/ext/v8/upstream/v8/src/mips/register-allocator-mips.h +47 -0
  316. data/ext/v8/upstream/v8/src/mips/simulator-mips.cc +2438 -0
  317. data/ext/v8/upstream/v8/src/mips/simulator-mips.h +394 -0
  318. data/ext/v8/upstream/v8/src/mips/stub-cache-mips.cc +601 -0
  319. data/ext/v8/upstream/v8/src/mips/virtual-frame-mips-inl.h +58 -0
  320. data/ext/v8/upstream/v8/src/mips/virtual-frame-mips.cc +307 -0
  321. data/ext/v8/upstream/v8/src/mips/virtual-frame-mips.h +530 -0
  322. data/ext/v8/upstream/v8/src/mirror-debugger.js +2381 -0
  323. data/ext/v8/upstream/v8/src/mksnapshot.cc +256 -0
  324. data/ext/v8/upstream/{3.1.8 → v8}/src/natives.h +0 -0
  325. data/ext/v8/upstream/v8/src/objects-debug.cc +722 -0
  326. data/ext/v8/upstream/v8/src/objects-inl.h +4166 -0
  327. data/ext/v8/upstream/v8/src/objects-printer.cc +801 -0
  328. data/ext/v8/upstream/v8/src/objects-visiting.cc +142 -0
  329. data/ext/v8/upstream/v8/src/objects-visiting.h +422 -0
  330. data/ext/v8/upstream/v8/src/objects.cc +10296 -0
  331. data/ext/v8/upstream/v8/src/objects.h +6662 -0
  332. data/ext/v8/upstream/v8/src/parser.cc +5168 -0
  333. data/ext/v8/upstream/v8/src/parser.h +823 -0
  334. data/ext/v8/upstream/v8/src/platform-cygwin.cc +811 -0
  335. data/ext/v8/upstream/v8/src/platform-freebsd.cc +854 -0
  336. data/ext/v8/upstream/v8/src/platform-linux.cc +1120 -0
  337. data/ext/v8/upstream/v8/src/platform-macos.cc +865 -0
  338. data/ext/v8/upstream/v8/src/platform-nullos.cc +504 -0
  339. data/ext/v8/upstream/v8/src/platform-openbsd.cc +672 -0
  340. data/ext/v8/upstream/v8/src/platform-posix.cc +424 -0
  341. data/ext/v8/upstream/v8/src/platform-solaris.cc +796 -0
  342. data/ext/v8/upstream/v8/src/platform-tls-mac.h +62 -0
  343. data/ext/v8/upstream/v8/src/platform-tls-win32.h +62 -0
  344. data/ext/v8/upstream/v8/src/platform-tls.h +50 -0
  345. data/ext/v8/upstream/v8/src/platform-win32.cc +2072 -0
  346. data/ext/v8/upstream/v8/src/platform.h +693 -0
  347. data/ext/v8/upstream/v8/src/preparse-data.cc +185 -0
  348. data/ext/v8/upstream/{3.1.8 → v8}/src/preparse-data.h +0 -0
  349. data/ext/v8/upstream/v8/src/preparser-api.cc +219 -0
  350. data/ext/v8/upstream/v8/src/preparser.cc +1205 -0
  351. data/ext/v8/upstream/{3.1.8 → v8}/src/preparser.h +0 -0
  352. data/ext/v8/upstream/v8/src/prettyprinter.cc +1530 -0
  353. data/ext/v8/upstream/v8/src/prettyprinter.h +223 -0
  354. data/ext/v8/upstream/{3.1.8 → v8}/src/profile-generator-inl.h +0 -0
  355. data/ext/v8/upstream/v8/src/profile-generator.cc +3095 -0
  356. data/ext/v8/upstream/v8/src/profile-generator.h +1125 -0
  357. data/ext/v8/upstream/v8/src/property.cc +102 -0
  358. data/ext/v8/upstream/v8/src/property.h +348 -0
  359. data/ext/v8/upstream/{3.1.8 → v8}/src/regexp-macro-assembler-irregexp-inl.h +0 -0
  360. data/ext/v8/upstream/v8/src/regexp-macro-assembler-irregexp.cc +470 -0
  361. data/ext/v8/upstream/{3.1.8 → v8}/src/regexp-macro-assembler-irregexp.h +0 -0
  362. data/ext/v8/upstream/{3.1.8 → v8}/src/regexp-macro-assembler-tracer.cc +0 -0
  363. data/ext/v8/upstream/{3.1.8 → v8}/src/regexp-macro-assembler-tracer.h +0 -0
  364. data/ext/v8/upstream/v8/src/regexp-macro-assembler.cc +266 -0
  365. data/ext/v8/upstream/v8/src/regexp-macro-assembler.h +236 -0
  366. data/ext/v8/upstream/v8/src/regexp-stack.cc +111 -0
  367. data/ext/v8/upstream/v8/src/regexp-stack.h +147 -0
  368. data/ext/v8/upstream/v8/src/regexp.js +483 -0
  369. data/ext/v8/upstream/v8/src/register-allocator-inl.h +141 -0
  370. data/ext/v8/upstream/v8/src/register-allocator.cc +98 -0
  371. data/ext/v8/upstream/v8/src/register-allocator.h +310 -0
  372. data/ext/v8/upstream/v8/src/rewriter.cc +1024 -0
  373. data/ext/v8/upstream/{3.1.8 → v8}/src/rewriter.h +0 -0
  374. data/ext/v8/upstream/v8/src/runtime-profiler.cc +478 -0
  375. data/ext/v8/upstream/v8/src/runtime-profiler.h +192 -0
  376. data/ext/v8/upstream/v8/src/runtime.cc +11949 -0
  377. data/ext/v8/upstream/v8/src/runtime.h +643 -0
  378. data/ext/v8/upstream/{3.1.8 → v8}/src/runtime.js +0 -0
  379. data/ext/v8/upstream/v8/src/safepoint-table.cc +256 -0
  380. data/ext/v8/upstream/v8/src/safepoint-table.h +269 -0
  381. data/ext/v8/upstream/v8/src/scanner-base.cc +964 -0
  382. data/ext/v8/upstream/v8/src/scanner-base.h +664 -0
  383. data/ext/v8/upstream/v8/src/scanner.cc +584 -0
  384. data/ext/v8/upstream/v8/src/scanner.h +196 -0
  385. data/ext/v8/upstream/v8/src/scopeinfo.cc +631 -0
  386. data/ext/v8/upstream/v8/src/scopeinfo.h +249 -0
  387. data/ext/v8/upstream/v8/src/scopes.cc +1093 -0
  388. data/ext/v8/upstream/v8/src/scopes.h +508 -0
  389. data/ext/v8/upstream/v8/src/serialize.cc +1574 -0
  390. data/ext/v8/upstream/v8/src/serialize.h +589 -0
  391. data/ext/v8/upstream/{3.1.8 → v8}/src/shell.h +0 -0
  392. data/ext/v8/upstream/{3.1.8 → v8}/src/simulator.h +0 -0
  393. data/ext/v8/upstream/v8/src/small-pointer-list.h +163 -0
  394. data/ext/v8/upstream/{3.1.8 → v8}/src/smart-pointer.h +0 -0
  395. data/ext/v8/upstream/v8/src/snapshot-common.cc +82 -0
  396. data/ext/v8/upstream/{3.1.8 → v8}/src/snapshot-empty.cc +0 -0
  397. data/ext/v8/upstream/v8/src/snapshot.h +73 -0
  398. data/ext/v8/upstream/v8/src/spaces-inl.h +529 -0
  399. data/ext/v8/upstream/v8/src/spaces.cc +3147 -0
  400. data/ext/v8/upstream/v8/src/spaces.h +2368 -0
  401. data/ext/v8/upstream/{3.1.8 → v8}/src/splay-tree-inl.h +0 -0
  402. data/ext/v8/upstream/{3.1.8 → v8}/src/splay-tree.h +0 -0
  403. data/ext/v8/upstream/v8/src/string-search.cc +41 -0
  404. data/ext/v8/upstream/v8/src/string-search.h +568 -0
  405. data/ext/v8/upstream/v8/src/string-stream.cc +592 -0
  406. data/ext/v8/upstream/{3.1.8 → v8}/src/string-stream.h +0 -0
  407. data/ext/v8/upstream/v8/src/string.js +915 -0
  408. data/ext/v8/upstream/{3.1.8 → v8}/src/strtod.cc +0 -0
  409. data/ext/v8/upstream/{3.1.8 → v8}/src/strtod.h +0 -0
  410. data/ext/v8/upstream/v8/src/stub-cache.cc +1940 -0
  411. data/ext/v8/upstream/v8/src/stub-cache.h +866 -0
  412. data/ext/v8/upstream/{3.1.8 → v8}/src/third_party/valgrind/valgrind.h +0 -0
  413. data/ext/v8/upstream/v8/src/token.cc +63 -0
  414. data/ext/v8/upstream/v8/src/token.h +288 -0
  415. data/ext/v8/upstream/v8/src/top.cc +983 -0
  416. data/ext/v8/upstream/v8/src/type-info.cc +472 -0
  417. data/ext/v8/upstream/v8/src/type-info.h +290 -0
  418. data/ext/v8/upstream/{3.1.8 → v8}/src/unbound-queue-inl.h +0 -0
  419. data/ext/v8/upstream/{3.1.8 → v8}/src/unbound-queue.h +0 -0
  420. data/ext/v8/upstream/{3.1.8 → v8}/src/unicode-inl.h +0 -0
  421. data/ext/v8/upstream/v8/src/unicode.cc +1624 -0
  422. data/ext/v8/upstream/v8/src/unicode.h +280 -0
  423. data/ext/v8/upstream/{3.1.8 → v8}/src/uri.js +0 -0
  424. data/ext/v8/upstream/{3.1.8 → v8}/src/utils.cc +0 -0
  425. data/ext/v8/upstream/v8/src/utils.h +796 -0
  426. data/ext/v8/upstream/v8/src/v8-counters.cc +62 -0
  427. data/ext/v8/upstream/v8/src/v8-counters.h +311 -0
  428. data/ext/v8/upstream/v8/src/v8.cc +215 -0
  429. data/ext/v8/upstream/v8/src/v8.h +130 -0
  430. data/ext/v8/upstream/{3.1.8 → v8}/src/v8checks.h +0 -0
  431. data/ext/v8/upstream/{3.1.8 → v8}/src/v8dll-main.cc +0 -0
  432. data/ext/v8/upstream/v8/src/v8globals.h +486 -0
  433. data/ext/v8/upstream/{3.1.8/src/memory.h → v8/src/v8memory.h} +0 -0
  434. data/ext/v8/upstream/v8/src/v8natives.js +1293 -0
  435. data/ext/v8/upstream/{3.1.8 → v8}/src/v8preparserdll-main.cc +0 -0
  436. data/ext/v8/upstream/v8/src/v8threads.cc +453 -0
  437. data/ext/v8/upstream/v8/src/v8threads.h +164 -0
  438. data/ext/v8/upstream/v8/src/v8utils.h +317 -0
  439. data/ext/v8/upstream/{3.1.8 → v8}/src/variables.cc +0 -0
  440. data/ext/v8/upstream/v8/src/variables.h +212 -0
  441. data/ext/v8/upstream/v8/src/version.cc +116 -0
  442. data/ext/v8/upstream/v8/src/version.h +68 -0
  443. data/ext/v8/upstream/{3.1.8 → v8}/src/virtual-frame-heavy-inl.h +0 -0
  444. data/ext/v8/upstream/{3.1.8 → v8}/src/virtual-frame-heavy.cc +0 -0
  445. data/ext/v8/upstream/{3.1.8 → v8}/src/virtual-frame-inl.h +0 -0
  446. data/ext/v8/upstream/v8/src/virtual-frame-light-inl.h +171 -0
  447. data/ext/v8/upstream/{3.1.8 → v8}/src/virtual-frame-light.cc +0 -0
  448. data/ext/v8/upstream/{3.1.8 → v8}/src/virtual-frame.cc +0 -0
  449. data/ext/v8/upstream/{3.1.8 → v8}/src/virtual-frame.h +0 -0
  450. data/ext/v8/upstream/v8/src/vm-state-inl.h +138 -0
  451. data/ext/v8/upstream/v8/src/vm-state.h +70 -0
  452. data/ext/v8/upstream/v8/src/win32-headers.h +96 -0
  453. data/ext/v8/upstream/v8/src/x64/assembler-x64-inl.h +456 -0
  454. data/ext/v8/upstream/v8/src/x64/assembler-x64.cc +2954 -0
  455. data/ext/v8/upstream/v8/src/x64/assembler-x64.h +1630 -0
  456. data/ext/v8/upstream/v8/src/x64/builtins-x64.cc +1493 -0
  457. data/ext/v8/upstream/v8/src/x64/code-stubs-x64.cc +5132 -0
  458. data/ext/v8/upstream/v8/src/x64/code-stubs-x64.h +477 -0
  459. data/ext/v8/upstream/{3.1.8 → v8}/src/x64/codegen-x64-inl.h +0 -0
  460. data/ext/v8/upstream/v8/src/x64/codegen-x64.cc +8843 -0
  461. data/ext/v8/upstream/v8/src/x64/codegen-x64.h +753 -0
  462. data/ext/v8/upstream/v8/src/x64/cpu-x64.cc +88 -0
  463. data/ext/v8/upstream/v8/src/x64/debug-x64.cc +318 -0
  464. data/ext/v8/upstream/v8/src/x64/deoptimizer-x64.cc +815 -0
  465. data/ext/v8/upstream/v8/src/x64/disasm-x64.cc +1752 -0
  466. data/ext/v8/upstream/{3.1.8 → v8}/src/x64/frames-x64.cc +0 -0
  467. data/ext/v8/upstream/v8/src/x64/frames-x64.h +130 -0
  468. data/ext/v8/upstream/v8/src/x64/full-codegen-x64.cc +4339 -0
  469. data/ext/v8/upstream/v8/src/x64/ic-x64.cc +1752 -0
  470. data/ext/v8/upstream/{3.1.8 → v8}/src/x64/jump-target-x64.cc +0 -0
  471. data/ext/v8/upstream/v8/src/x64/lithium-codegen-x64.cc +3970 -0
  472. data/ext/v8/upstream/v8/src/x64/lithium-codegen-x64.h +318 -0
  473. data/ext/v8/upstream/{3.1.8 → v8}/src/x64/lithium-gap-resolver-x64.cc +0 -0
  474. data/ext/v8/upstream/{3.1.8 → v8}/src/x64/lithium-gap-resolver-x64.h +0 -0
  475. data/ext/v8/upstream/v8/src/x64/lithium-x64.cc +2115 -0
  476. data/ext/v8/upstream/v8/src/x64/lithium-x64.h +2161 -0
  477. data/ext/v8/upstream/v8/src/x64/macro-assembler-x64.cc +2911 -0
  478. data/ext/v8/upstream/v8/src/x64/macro-assembler-x64.h +1984 -0
  479. data/ext/v8/upstream/v8/src/x64/regexp-macro-assembler-x64.cc +1398 -0
  480. data/ext/v8/upstream/v8/src/x64/regexp-macro-assembler-x64.h +282 -0
  481. data/ext/v8/upstream/v8/src/x64/register-allocator-x64-inl.h +87 -0
  482. data/ext/v8/upstream/v8/src/x64/register-allocator-x64.cc +95 -0
  483. data/ext/v8/upstream/{3.1.8 → v8}/src/x64/register-allocator-x64.h +0 -0
  484. data/ext/v8/upstream/{3.1.8 → v8}/src/x64/simulator-x64.cc +0 -0
  485. data/ext/v8/upstream/v8/src/x64/simulator-x64.h +71 -0
  486. data/ext/v8/upstream/v8/src/x64/stub-cache-x64.cc +3460 -0
  487. data/ext/v8/upstream/v8/src/x64/virtual-frame-x64.cc +1296 -0
  488. data/ext/v8/upstream/v8/src/x64/virtual-frame-x64.h +597 -0
  489. data/ext/v8/upstream/v8/src/zone-inl.h +129 -0
  490. data/ext/v8/upstream/v8/src/zone.cc +196 -0
  491. data/ext/v8/upstream/v8/src/zone.h +236 -0
  492. data/ext/v8/upstream/{3.1.8 → v8}/tools/codemap.js +0 -0
  493. data/ext/v8/upstream/{3.1.8 → v8}/tools/consarray.js +0 -0
  494. data/ext/v8/upstream/{3.1.8 → v8}/tools/csvparser.js +0 -0
  495. data/ext/v8/upstream/{3.1.8 → v8}/tools/disasm.py +0 -0
  496. data/ext/v8/upstream/v8/tools/freebsd-tick-processor +10 -0
  497. data/ext/v8/upstream/{3.1.8 → v8}/tools/gc-nvp-trace-processor.py +0 -0
  498. data/ext/v8/upstream/{3.1.8 → v8}/tools/generate-ten-powers.scm +0 -0
  499. data/ext/v8/upstream/{3.1.8 → v8}/tools/grokdump.py +0 -0
  500. data/ext/v8/upstream/v8/tools/gyp/v8.gyp +844 -0
  501. data/ext/v8/upstream/{3.1.8 → v8}/tools/js2c.py +0 -0
  502. data/ext/v8/upstream/{3.1.8 → v8}/tools/jsmin.py +0 -0
  503. data/ext/v8/upstream/v8/tools/linux-tick-processor +35 -0
  504. data/ext/v8/upstream/{3.1.8 → v8}/tools/ll_prof.py +0 -0
  505. data/ext/v8/upstream/{3.1.8 → v8}/tools/logreader.js +0 -0
  506. data/ext/v8/upstream/{3.1.8 → v8}/tools/mac-nm +0 -0
  507. data/ext/v8/upstream/{3.1.8 → v8}/tools/mac-tick-processor +0 -0
  508. data/ext/v8/upstream/{3.1.8 → v8}/tools/oom_dump/README +0 -0
  509. data/ext/v8/upstream/{3.1.8 → v8}/tools/oom_dump/SConstruct +0 -0
  510. data/ext/v8/upstream/{3.1.8 → v8}/tools/oom_dump/oom_dump.cc +0 -0
  511. data/ext/v8/upstream/{3.1.8 → v8}/tools/presubmit.py +0 -0
  512. data/ext/v8/upstream/{3.1.8 → v8}/tools/process-heap-prof.py +0 -0
  513. data/ext/v8/upstream/{3.1.8 → v8}/tools/profile.js +0 -0
  514. data/ext/v8/upstream/{3.1.8 → v8}/tools/profile_view.js +0 -0
  515. data/ext/v8/upstream/{3.1.8 → v8}/tools/run-valgrind.py +0 -0
  516. data/ext/v8/upstream/{3.1.8 → v8}/tools/splaytree.js +0 -0
  517. data/ext/v8/upstream/{3.1.8 → v8}/tools/stats-viewer.py +0 -0
  518. data/ext/v8/upstream/v8/tools/test.py +1490 -0
  519. data/ext/v8/upstream/{3.1.8 → v8}/tools/tickprocessor-driver.js +0 -0
  520. data/ext/v8/upstream/v8/tools/tickprocessor.js +877 -0
  521. data/ext/v8/upstream/{3.1.8 → v8}/tools/utils.py +0 -0
  522. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/README.txt +0 -0
  523. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/arm.vsprops +0 -0
  524. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/common.vsprops +0 -0
  525. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/d8.vcproj +0 -0
  526. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/d8_arm.vcproj +0 -0
  527. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/d8_x64.vcproj +0 -0
  528. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/d8js2c.cmd +0 -0
  529. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/debug.vsprops +0 -0
  530. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/ia32.vsprops +0 -0
  531. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/js2c.cmd +0 -0
  532. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/release.vsprops +0 -0
  533. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8.sln +0 -0
  534. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8.vcproj +0 -0
  535. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_arm.sln +0 -0
  536. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_arm.vcproj +0 -0
  537. data/ext/v8/upstream/v8/tools/visual_studio/v8_base.vcproj +1308 -0
  538. data/ext/v8/upstream/v8/tools/visual_studio/v8_base_arm.vcproj +1238 -0
  539. data/ext/v8/upstream/v8/tools/visual_studio/v8_base_x64.vcproj +1300 -0
  540. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_cctest.vcproj +0 -0
  541. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_cctest_arm.vcproj +0 -0
  542. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_cctest_x64.vcproj +0 -0
  543. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_mksnapshot.vcproj +0 -0
  544. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_mksnapshot_x64.vcproj +0 -0
  545. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_process_sample.vcproj +0 -0
  546. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_process_sample_arm.vcproj +0 -0
  547. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_process_sample_x64.vcproj +0 -0
  548. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_shell_sample.vcproj +0 -0
  549. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_shell_sample_arm.vcproj +0 -0
  550. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_shell_sample_x64.vcproj +0 -0
  551. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_snapshot.vcproj +0 -0
  552. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_snapshot_cc.vcproj +0 -0
  553. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_snapshot_cc_x64.vcproj +0 -0
  554. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_snapshot_x64.vcproj +0 -0
  555. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_x64.sln +0 -0
  556. data/ext/v8/upstream/{3.1.8 → v8}/tools/visual_studio/v8_x64.vcproj +0 -0
  557. data/ext/v8/upstream/v8/tools/visual_studio/x64.vsprops +18 -0
  558. data/ext/v8/upstream/{3.1.8 → v8}/tools/windows-tick-processor.bat +0 -0
  559. data/ext/v8/v8_callbacks.cpp +52 -92
  560. data/ext/v8/v8_date.cpp +2 -3
  561. data/ext/v8/v8_object.cpp +4 -0
  562. data/ext/v8/v8_template.cpp +2 -2
  563. data/ext/v8/v8_try_catch.cpp +8 -38
  564. data/lib/v8/version.rb +1 -1
  565. data/spec/ext/ext_spec_helper.rb +2 -20
  566. data/spec/ext/object_spec.rb +0 -12
  567. data/spec/ext/try_catch_spec.rb +29 -1
  568. data/spec/spec_helper.rb +1 -0
  569. data/spec/v8/portal/proxies_spec.rb +1 -84
  570. data/specmem/handle_memspec.rb +41 -0
  571. data/specmem/object_memspec.rb +16 -0
  572. data/specmem/proxies_memspec.rb +86 -0
  573. data/specmem/spec_helper.rb +24 -0
  574. data/therubyracer.gemspec +7 -2
  575. metadata +564 -541
  576. data/ext/v8/upstream/3.1.8/.gitignore +0 -31
  577. data/ext/v8/upstream/3.1.8/AUTHORS +0 -40
  578. data/ext/v8/upstream/3.1.8/ChangeLog +0 -2566
  579. data/ext/v8/upstream/3.1.8/SConstruct +0 -1192
  580. data/ext/v8/upstream/3.1.8/include/v8-debug.h +0 -384
  581. data/ext/v8/upstream/3.1.8/include/v8-preparser.h +0 -116
  582. data/ext/v8/upstream/3.1.8/include/v8-profiler.h +0 -426
  583. data/ext/v8/upstream/3.1.8/include/v8-testing.h +0 -99
  584. data/ext/v8/upstream/3.1.8/include/v8.h +0 -3846
  585. data/ext/v8/upstream/3.1.8/preparser/preparser-process.cc +0 -206
  586. data/ext/v8/upstream/3.1.8/src/SConscript +0 -356
  587. data/ext/v8/upstream/3.1.8/src/accessors.cc +0 -907
  588. data/ext/v8/upstream/3.1.8/src/allocation.cc +0 -204
  589. data/ext/v8/upstream/3.1.8/src/allocation.h +0 -176
  590. data/ext/v8/upstream/3.1.8/src/api.cc +0 -5191
  591. data/ext/v8/upstream/3.1.8/src/api.h +0 -508
  592. data/ext/v8/upstream/3.1.8/src/apiutils.h +0 -80
  593. data/ext/v8/upstream/3.1.8/src/arguments.h +0 -105
  594. data/ext/v8/upstream/3.1.8/src/arm/assembler-arm-inl.h +0 -352
  595. data/ext/v8/upstream/3.1.8/src/arm/assembler-arm.cc +0 -2756
  596. data/ext/v8/upstream/3.1.8/src/arm/assembler-arm.h +0 -1294
  597. data/ext/v8/upstream/3.1.8/src/arm/builtins-arm.cc +0 -1628
  598. data/ext/v8/upstream/3.1.8/src/arm/code-stubs-arm.cc +0 -6783
  599. data/ext/v8/upstream/3.1.8/src/arm/code-stubs-arm.h +0 -657
  600. data/ext/v8/upstream/3.1.8/src/arm/codegen-arm.cc +0 -7403
  601. data/ext/v8/upstream/3.1.8/src/arm/codegen-arm.h +0 -595
  602. data/ext/v8/upstream/3.1.8/src/arm/constants-arm.h +0 -769
  603. data/ext/v8/upstream/3.1.8/src/arm/cpu-arm.cc +0 -147
  604. data/ext/v8/upstream/3.1.8/src/arm/debug-arm.cc +0 -315
  605. data/ext/v8/upstream/3.1.8/src/arm/deoptimizer-arm.cc +0 -700
  606. data/ext/v8/upstream/3.1.8/src/arm/disasm-arm.cc +0 -1439
  607. data/ext/v8/upstream/3.1.8/src/arm/frames-arm.h +0 -168
  608. data/ext/v8/upstream/3.1.8/src/arm/full-codegen-arm.cc +0 -4230
  609. data/ext/v8/upstream/3.1.8/src/arm/ic-arm.cc +0 -1799
  610. data/ext/v8/upstream/3.1.8/src/arm/lithium-arm.cc +0 -2041
  611. data/ext/v8/upstream/3.1.8/src/arm/lithium-arm.h +0 -2046
  612. data/ext/v8/upstream/3.1.8/src/arm/lithium-codegen-arm.cc +0 -3822
  613. data/ext/v8/upstream/3.1.8/src/arm/lithium-codegen-arm.h +0 -312
  614. data/ext/v8/upstream/3.1.8/src/arm/lithium-gap-resolver-arm.cc +0 -303
  615. data/ext/v8/upstream/3.1.8/src/arm/macro-assembler-arm.cc +0 -2701
  616. data/ext/v8/upstream/3.1.8/src/arm/macro-assembler-arm.h +0 -1015
  617. data/ext/v8/upstream/3.1.8/src/arm/regexp-macro-assembler-arm.cc +0 -1280
  618. data/ext/v8/upstream/3.1.8/src/arm/regexp-macro-assembler-arm.h +0 -252
  619. data/ext/v8/upstream/3.1.8/src/arm/simulator-arm.cc +0 -3165
  620. data/ext/v8/upstream/3.1.8/src/arm/simulator-arm.h +0 -402
  621. data/ext/v8/upstream/3.1.8/src/arm/stub-cache-arm.cc +0 -4077
  622. data/ext/v8/upstream/3.1.8/src/arm/virtual-frame-arm.cc +0 -843
  623. data/ext/v8/upstream/3.1.8/src/arm/virtual-frame-arm.h +0 -520
  624. data/ext/v8/upstream/3.1.8/src/array.js +0 -1231
  625. data/ext/v8/upstream/3.1.8/src/assembler.cc +0 -973
  626. data/ext/v8/upstream/3.1.8/src/assembler.h +0 -787
  627. data/ext/v8/upstream/3.1.8/src/ast-inl.h +0 -107
  628. data/ext/v8/upstream/3.1.8/src/ast.cc +0 -1067
  629. data/ext/v8/upstream/3.1.8/src/ast.h +0 -2177
  630. data/ext/v8/upstream/3.1.8/src/atomicops.h +0 -165
  631. data/ext/v8/upstream/3.1.8/src/bootstrapper.cc +0 -1888
  632. data/ext/v8/upstream/3.1.8/src/bootstrapper.h +0 -118
  633. data/ext/v8/upstream/3.1.8/src/builtins.cc +0 -1586
  634. data/ext/v8/upstream/3.1.8/src/builtins.h +0 -339
  635. data/ext/v8/upstream/3.1.8/src/checks.cc +0 -110
  636. data/ext/v8/upstream/3.1.8/src/checks.h +0 -292
  637. data/ext/v8/upstream/3.1.8/src/code-stubs.cc +0 -230
  638. data/ext/v8/upstream/3.1.8/src/code-stubs.h +0 -950
  639. data/ext/v8/upstream/3.1.8/src/codegen-inl.h +0 -64
  640. data/ext/v8/upstream/3.1.8/src/codegen.cc +0 -495
  641. data/ext/v8/upstream/3.1.8/src/codegen.h +0 -245
  642. data/ext/v8/upstream/3.1.8/src/compilation-cache.cc +0 -654
  643. data/ext/v8/upstream/3.1.8/src/compilation-cache.h +0 -112
  644. data/ext/v8/upstream/3.1.8/src/compiler.cc +0 -806
  645. data/ext/v8/upstream/3.1.8/src/compiler.h +0 -290
  646. data/ext/v8/upstream/3.1.8/src/contexts.cc +0 -320
  647. data/ext/v8/upstream/3.1.8/src/contexts.h +0 -376
  648. data/ext/v8/upstream/3.1.8/src/conversions.cc +0 -1069
  649. data/ext/v8/upstream/3.1.8/src/counters.cc +0 -78
  650. data/ext/v8/upstream/3.1.8/src/counters.h +0 -242
  651. data/ext/v8/upstream/3.1.8/src/cpu-profiler-inl.h +0 -100
  652. data/ext/v8/upstream/3.1.8/src/cpu-profiler.cc +0 -554
  653. data/ext/v8/upstream/3.1.8/src/cpu-profiler.h +0 -291
  654. data/ext/v8/upstream/3.1.8/src/cpu.h +0 -65
  655. data/ext/v8/upstream/3.1.8/src/d8-debug.cc +0 -367
  656. data/ext/v8/upstream/3.1.8/src/d8-debug.h +0 -157
  657. data/ext/v8/upstream/3.1.8/src/d8-posix.cc +0 -693
  658. data/ext/v8/upstream/3.1.8/src/d8.cc +0 -792
  659. data/ext/v8/upstream/3.1.8/src/d8.gyp +0 -85
  660. data/ext/v8/upstream/3.1.8/src/data-flow.h +0 -379
  661. data/ext/v8/upstream/3.1.8/src/dateparser.h +0 -263
  662. data/ext/v8/upstream/3.1.8/src/debug-agent.cc +0 -446
  663. data/ext/v8/upstream/3.1.8/src/debug-agent.h +0 -131
  664. data/ext/v8/upstream/3.1.8/src/debug.cc +0 -3085
  665. data/ext/v8/upstream/3.1.8/src/debug.h +0 -1025
  666. data/ext/v8/upstream/3.1.8/src/deoptimizer.cc +0 -1185
  667. data/ext/v8/upstream/3.1.8/src/deoptimizer.h +0 -529
  668. data/ext/v8/upstream/3.1.8/src/disasm.h +0 -77
  669. data/ext/v8/upstream/3.1.8/src/disassembler.cc +0 -338
  670. data/ext/v8/upstream/3.1.8/src/execution.cc +0 -735
  671. data/ext/v8/upstream/3.1.8/src/execution.h +0 -322
  672. data/ext/v8/upstream/3.1.8/src/extensions/experimental/experimental.gyp +0 -53
  673. data/ext/v8/upstream/3.1.8/src/extensions/experimental/i18n-extension.cc +0 -264
  674. data/ext/v8/upstream/3.1.8/src/extensions/externalize-string-extension.cc +0 -141
  675. data/ext/v8/upstream/3.1.8/src/extensions/gc-extension.cc +0 -58
  676. data/ext/v8/upstream/3.1.8/src/factory.cc +0 -1087
  677. data/ext/v8/upstream/3.1.8/src/factory.h +0 -432
  678. data/ext/v8/upstream/3.1.8/src/flag-definitions.h +0 -552
  679. data/ext/v8/upstream/3.1.8/src/frame-element.cc +0 -42
  680. data/ext/v8/upstream/3.1.8/src/frame-element.h +0 -277
  681. data/ext/v8/upstream/3.1.8/src/frames-inl.h +0 -210
  682. data/ext/v8/upstream/3.1.8/src/frames.cc +0 -1232
  683. data/ext/v8/upstream/3.1.8/src/frames.h +0 -826
  684. data/ext/v8/upstream/3.1.8/src/full-codegen.cc +0 -1382
  685. data/ext/v8/upstream/3.1.8/src/full-codegen.h +0 -751
  686. data/ext/v8/upstream/3.1.8/src/func-name-inferrer.cc +0 -90
  687. data/ext/v8/upstream/3.1.8/src/func-name-inferrer.h +0 -111
  688. data/ext/v8/upstream/3.1.8/src/gdb-jit.cc +0 -1547
  689. data/ext/v8/upstream/3.1.8/src/global-handles.cc +0 -534
  690. data/ext/v8/upstream/3.1.8/src/global-handles.h +0 -181
  691. data/ext/v8/upstream/3.1.8/src/globals.h +0 -325
  692. data/ext/v8/upstream/3.1.8/src/handles-inl.h +0 -80
  693. data/ext/v8/upstream/3.1.8/src/handles.cc +0 -910
  694. data/ext/v8/upstream/3.1.8/src/handles.h +0 -424
  695. data/ext/v8/upstream/3.1.8/src/hashmap.h +0 -121
  696. data/ext/v8/upstream/3.1.8/src/heap-inl.h +0 -587
  697. data/ext/v8/upstream/3.1.8/src/heap-profiler.cc +0 -1128
  698. data/ext/v8/upstream/3.1.8/src/heap-profiler.h +0 -381
  699. data/ext/v8/upstream/3.1.8/src/heap.cc +0 -5610
  700. data/ext/v8/upstream/3.1.8/src/heap.h +0 -2218
  701. data/ext/v8/upstream/3.1.8/src/hydrogen-instructions.cc +0 -1490
  702. data/ext/v8/upstream/3.1.8/src/hydrogen-instructions.h +0 -3493
  703. data/ext/v8/upstream/3.1.8/src/hydrogen.cc +0 -6056
  704. data/ext/v8/upstream/3.1.8/src/hydrogen.h +0 -1091
  705. data/ext/v8/upstream/3.1.8/src/ia32/assembler-ia32-inl.h +0 -429
  706. data/ext/v8/upstream/3.1.8/src/ia32/assembler-ia32.cc +0 -2800
  707. data/ext/v8/upstream/3.1.8/src/ia32/assembler-ia32.h +0 -1093
  708. data/ext/v8/upstream/3.1.8/src/ia32/builtins-ia32.cc +0 -1590
  709. data/ext/v8/upstream/3.1.8/src/ia32/code-stubs-ia32.cc +0 -6624
  710. data/ext/v8/upstream/3.1.8/src/ia32/code-stubs-ia32.h +0 -536
  711. data/ext/v8/upstream/3.1.8/src/ia32/codegen-ia32.cc +0 -10354
  712. data/ext/v8/upstream/3.1.8/src/ia32/codegen-ia32.h +0 -798
  713. data/ext/v8/upstream/3.1.8/src/ia32/cpu-ia32.cc +0 -87
  714. data/ext/v8/upstream/3.1.8/src/ia32/debug-ia32.cc +0 -309
  715. data/ext/v8/upstream/3.1.8/src/ia32/deoptimizer-ia32.cc +0 -664
  716. data/ext/v8/upstream/3.1.8/src/ia32/disasm-ia32.cc +0 -1597
  717. data/ext/v8/upstream/3.1.8/src/ia32/frames-ia32.h +0 -140
  718. data/ext/v8/upstream/3.1.8/src/ia32/full-codegen-ia32.cc +0 -4278
  719. data/ext/v8/upstream/3.1.8/src/ia32/ic-ia32.cc +0 -1786
  720. data/ext/v8/upstream/3.1.8/src/ia32/lithium-codegen-ia32.cc +0 -3880
  721. data/ext/v8/upstream/3.1.8/src/ia32/lithium-codegen-ia32.h +0 -309
  722. data/ext/v8/upstream/3.1.8/src/ia32/lithium-gap-resolver-ia32.cc +0 -460
  723. data/ext/v8/upstream/3.1.8/src/ia32/lithium-ia32.cc +0 -2095
  724. data/ext/v8/upstream/3.1.8/src/ia32/lithium-ia32.h +0 -2127
  725. data/ext/v8/upstream/3.1.8/src/ia32/macro-assembler-ia32.cc +0 -2031
  726. data/ext/v8/upstream/3.1.8/src/ia32/macro-assembler-ia32.h +0 -798
  727. data/ext/v8/upstream/3.1.8/src/ia32/regexp-macro-assembler-ia32.cc +0 -1253
  728. data/ext/v8/upstream/3.1.8/src/ia32/regexp-macro-assembler-ia32.h +0 -215
  729. data/ext/v8/upstream/3.1.8/src/ia32/register-allocator-ia32.cc +0 -157
  730. data/ext/v8/upstream/3.1.8/src/ia32/simulator-ia32.h +0 -72
  731. data/ext/v8/upstream/3.1.8/src/ia32/stub-cache-ia32.cc +0 -3732
  732. data/ext/v8/upstream/3.1.8/src/ia32/virtual-frame-ia32.cc +0 -1360
  733. data/ext/v8/upstream/3.1.8/src/ia32/virtual-frame-ia32.h +0 -646
  734. data/ext/v8/upstream/3.1.8/src/ic-inl.h +0 -129
  735. data/ext/v8/upstream/3.1.8/src/ic.cc +0 -2333
  736. data/ext/v8/upstream/3.1.8/src/ic.h +0 -639
  737. data/ext/v8/upstream/3.1.8/src/interpreter-irregexp.cc +0 -655
  738. data/ext/v8/upstream/3.1.8/src/interpreter-irregexp.h +0 -48
  739. data/ext/v8/upstream/3.1.8/src/json.js +0 -342
  740. data/ext/v8/upstream/3.1.8/src/jsregexp.cc +0 -5340
  741. data/ext/v8/upstream/3.1.8/src/jsregexp.h +0 -1484
  742. data/ext/v8/upstream/3.1.8/src/jump-target-heavy.cc +0 -430
  743. data/ext/v8/upstream/3.1.8/src/jump-target-heavy.h +0 -244
  744. data/ext/v8/upstream/3.1.8/src/jump-target-inl.h +0 -48
  745. data/ext/v8/upstream/3.1.8/src/jump-target-light.cc +0 -111
  746. data/ext/v8/upstream/3.1.8/src/lithium-allocator-inl.h +0 -140
  747. data/ext/v8/upstream/3.1.8/src/lithium-allocator.cc +0 -2093
  748. data/ext/v8/upstream/3.1.8/src/lithium-allocator.h +0 -644
  749. data/ext/v8/upstream/3.1.8/src/lithium.cc +0 -168
  750. data/ext/v8/upstream/3.1.8/src/liveedit.cc +0 -1650
  751. data/ext/v8/upstream/3.1.8/src/liveedit.h +0 -174
  752. data/ext/v8/upstream/3.1.8/src/liveobjectlist.cc +0 -2527
  753. data/ext/v8/upstream/3.1.8/src/liveobjectlist.h +0 -322
  754. data/ext/v8/upstream/3.1.8/src/log-utils.cc +0 -336
  755. data/ext/v8/upstream/3.1.8/src/log-utils.h +0 -232
  756. data/ext/v8/upstream/3.1.8/src/log.cc +0 -1608
  757. data/ext/v8/upstream/3.1.8/src/log.h +0 -379
  758. data/ext/v8/upstream/3.1.8/src/mark-compact.cc +0 -2957
  759. data/ext/v8/upstream/3.1.8/src/mark-compact.h +0 -433
  760. data/ext/v8/upstream/3.1.8/src/messages.cc +0 -164
  761. data/ext/v8/upstream/3.1.8/src/messages.js +0 -1071
  762. data/ext/v8/upstream/3.1.8/src/mips/assembler-mips-inl.h +0 -215
  763. data/ext/v8/upstream/3.1.8/src/mips/assembler-mips.cc +0 -1219
  764. data/ext/v8/upstream/3.1.8/src/mips/assembler-mips.h +0 -667
  765. data/ext/v8/upstream/3.1.8/src/mips/builtins-mips.cc +0 -205
  766. data/ext/v8/upstream/3.1.8/src/mips/codegen-mips-inl.h +0 -70
  767. data/ext/v8/upstream/3.1.8/src/mips/codegen-mips.cc +0 -1437
  768. data/ext/v8/upstream/3.1.8/src/mips/codegen-mips.h +0 -431
  769. data/ext/v8/upstream/3.1.8/src/mips/constants-mips.cc +0 -328
  770. data/ext/v8/upstream/3.1.8/src/mips/constants-mips.h +0 -525
  771. data/ext/v8/upstream/3.1.8/src/mips/cpu-mips.cc +0 -73
  772. data/ext/v8/upstream/3.1.8/src/mips/debug-mips.cc +0 -127
  773. data/ext/v8/upstream/3.1.8/src/mips/disasm-mips.cc +0 -787
  774. data/ext/v8/upstream/3.1.8/src/mips/fast-codegen-mips.cc +0 -77
  775. data/ext/v8/upstream/3.1.8/src/mips/frames-mips.cc +0 -96
  776. data/ext/v8/upstream/3.1.8/src/mips/frames-mips.h +0 -164
  777. data/ext/v8/upstream/3.1.8/src/mips/full-codegen-mips.cc +0 -277
  778. data/ext/v8/upstream/3.1.8/src/mips/ic-mips.cc +0 -208
  779. data/ext/v8/upstream/3.1.8/src/mips/jump-target-mips.cc +0 -175
  780. data/ext/v8/upstream/3.1.8/src/mips/macro-assembler-mips.cc +0 -1326
  781. data/ext/v8/upstream/3.1.8/src/mips/macro-assembler-mips.h +0 -461
  782. data/ext/v8/upstream/3.1.8/src/mips/register-allocator-mips-inl.h +0 -137
  783. data/ext/v8/upstream/3.1.8/src/mips/register-allocator-mips.h +0 -46
  784. data/ext/v8/upstream/3.1.8/src/mips/simulator-mips.cc +0 -1650
  785. data/ext/v8/upstream/3.1.8/src/mips/simulator-mips.h +0 -311
  786. data/ext/v8/upstream/3.1.8/src/mips/stub-cache-mips.cc +0 -418
  787. data/ext/v8/upstream/3.1.8/src/mips/virtual-frame-mips.cc +0 -319
  788. data/ext/v8/upstream/3.1.8/src/mips/virtual-frame-mips.h +0 -548
  789. data/ext/v8/upstream/3.1.8/src/mirror-debugger.js +0 -2380
  790. data/ext/v8/upstream/3.1.8/src/mksnapshot.cc +0 -256
  791. data/ext/v8/upstream/3.1.8/src/objects-debug.cc +0 -722
  792. data/ext/v8/upstream/3.1.8/src/objects-inl.h +0 -3946
  793. data/ext/v8/upstream/3.1.8/src/objects-printer.cc +0 -801
  794. data/ext/v8/upstream/3.1.8/src/objects-visiting.cc +0 -142
  795. data/ext/v8/upstream/3.1.8/src/objects-visiting.h +0 -401
  796. data/ext/v8/upstream/3.1.8/src/objects.cc +0 -10044
  797. data/ext/v8/upstream/3.1.8/src/objects.h +0 -6571
  798. data/ext/v8/upstream/3.1.8/src/parser.cc +0 -5165
  799. data/ext/v8/upstream/3.1.8/src/parser.h +0 -802
  800. data/ext/v8/upstream/3.1.8/src/platform-cygwin.cc +0 -745
  801. data/ext/v8/upstream/3.1.8/src/platform-freebsd.cc +0 -702
  802. data/ext/v8/upstream/3.1.8/src/platform-linux.cc +0 -981
  803. data/ext/v8/upstream/3.1.8/src/platform-macos.cc +0 -732
  804. data/ext/v8/upstream/3.1.8/src/platform-nullos.cc +0 -498
  805. data/ext/v8/upstream/3.1.8/src/platform-openbsd.cc +0 -657
  806. data/ext/v8/upstream/3.1.8/src/platform-posix.cc +0 -399
  807. data/ext/v8/upstream/3.1.8/src/platform-solaris.cc +0 -714
  808. data/ext/v8/upstream/3.1.8/src/platform-win32.cc +0 -1974
  809. data/ext/v8/upstream/3.1.8/src/platform.h +0 -636
  810. data/ext/v8/upstream/3.1.8/src/preparse-data.cc +0 -183
  811. data/ext/v8/upstream/3.1.8/src/preparser-api.cc +0 -213
  812. data/ext/v8/upstream/3.1.8/src/preparser.cc +0 -1205
  813. data/ext/v8/upstream/3.1.8/src/prettyprinter.cc +0 -1539
  814. data/ext/v8/upstream/3.1.8/src/prettyprinter.h +0 -223
  815. data/ext/v8/upstream/3.1.8/src/profile-generator.cc +0 -2899
  816. data/ext/v8/upstream/3.1.8/src/profile-generator.h +0 -1151
  817. data/ext/v8/upstream/3.1.8/src/property.cc +0 -96
  818. data/ext/v8/upstream/3.1.8/src/property.h +0 -337
  819. data/ext/v8/upstream/3.1.8/src/regexp-macro-assembler-irregexp.cc +0 -470
  820. data/ext/v8/upstream/3.1.8/src/regexp-macro-assembler.cc +0 -257
  821. data/ext/v8/upstream/3.1.8/src/regexp-macro-assembler.h +0 -231
  822. data/ext/v8/upstream/3.1.8/src/regexp-stack.cc +0 -103
  823. data/ext/v8/upstream/3.1.8/src/regexp-stack.h +0 -123
  824. data/ext/v8/upstream/3.1.8/src/regexp.js +0 -483
  825. data/ext/v8/upstream/3.1.8/src/register-allocator-inl.h +0 -141
  826. data/ext/v8/upstream/3.1.8/src/register-allocator.cc +0 -104
  827. data/ext/v8/upstream/3.1.8/src/register-allocator.h +0 -320
  828. data/ext/v8/upstream/3.1.8/src/rewriter.cc +0 -1023
  829. data/ext/v8/upstream/3.1.8/src/runtime-profiler.cc +0 -443
  830. data/ext/v8/upstream/3.1.8/src/runtime-profiler.h +0 -77
  831. data/ext/v8/upstream/3.1.8/src/runtime.cc +0 -11592
  832. data/ext/v8/upstream/3.1.8/src/runtime.h +0 -582
  833. data/ext/v8/upstream/3.1.8/src/safepoint-table.cc +0 -253
  834. data/ext/v8/upstream/3.1.8/src/safepoint-table.h +0 -263
  835. data/ext/v8/upstream/3.1.8/src/scanner-base.cc +0 -971
  836. data/ext/v8/upstream/3.1.8/src/scanner-base.h +0 -653
  837. data/ext/v8/upstream/3.1.8/src/scanner.cc +0 -586
  838. data/ext/v8/upstream/3.1.8/src/scanner.h +0 -194
  839. data/ext/v8/upstream/3.1.8/src/scopeinfo.cc +0 -636
  840. data/ext/v8/upstream/3.1.8/src/scopeinfo.h +0 -238
  841. data/ext/v8/upstream/3.1.8/src/scopes.cc +0 -1063
  842. data/ext/v8/upstream/3.1.8/src/scopes.h +0 -494
  843. data/ext/v8/upstream/3.1.8/src/serialize.cc +0 -1535
  844. data/ext/v8/upstream/3.1.8/src/serialize.h +0 -584
  845. data/ext/v8/upstream/3.1.8/src/snapshot-common.cc +0 -82
  846. data/ext/v8/upstream/3.1.8/src/snapshot.h +0 -71
  847. data/ext/v8/upstream/3.1.8/src/spaces-inl.h +0 -524
  848. data/ext/v8/upstream/3.1.8/src/spaces.cc +0 -3254
  849. data/ext/v8/upstream/3.1.8/src/spaces.h +0 -2362
  850. data/ext/v8/upstream/3.1.8/src/string-search.cc +0 -40
  851. data/ext/v8/upstream/3.1.8/src/string-search.h +0 -567
  852. data/ext/v8/upstream/3.1.8/src/string-stream.cc +0 -584
  853. data/ext/v8/upstream/3.1.8/src/string.js +0 -915
  854. data/ext/v8/upstream/3.1.8/src/stub-cache.cc +0 -1878
  855. data/ext/v8/upstream/3.1.8/src/stub-cache.h +0 -849
  856. data/ext/v8/upstream/3.1.8/src/token.cc +0 -63
  857. data/ext/v8/upstream/3.1.8/src/token.h +0 -288
  858. data/ext/v8/upstream/3.1.8/src/top.cc +0 -1152
  859. data/ext/v8/upstream/3.1.8/src/top.h +0 -608
  860. data/ext/v8/upstream/3.1.8/src/type-info.cc +0 -406
  861. data/ext/v8/upstream/3.1.8/src/type-info.h +0 -283
  862. data/ext/v8/upstream/3.1.8/src/unicode.cc +0 -1624
  863. data/ext/v8/upstream/3.1.8/src/unicode.h +0 -280
  864. data/ext/v8/upstream/3.1.8/src/utils.h +0 -793
  865. data/ext/v8/upstream/3.1.8/src/v8-counters.cc +0 -55
  866. data/ext/v8/upstream/3.1.8/src/v8-counters.h +0 -290
  867. data/ext/v8/upstream/3.1.8/src/v8.cc +0 -270
  868. data/ext/v8/upstream/3.1.8/src/v8.h +0 -127
  869. data/ext/v8/upstream/3.1.8/src/v8globals.h +0 -480
  870. data/ext/v8/upstream/3.1.8/src/v8natives.js +0 -1252
  871. data/ext/v8/upstream/3.1.8/src/v8threads.cc +0 -440
  872. data/ext/v8/upstream/3.1.8/src/v8threads.h +0 -157
  873. data/ext/v8/upstream/3.1.8/src/v8utils.h +0 -354
  874. data/ext/v8/upstream/3.1.8/src/variables.h +0 -212
  875. data/ext/v8/upstream/3.1.8/src/version.cc +0 -95
  876. data/ext/v8/upstream/3.1.8/src/version.h +0 -64
  877. data/ext/v8/upstream/3.1.8/src/virtual-frame-light-inl.h +0 -170
  878. data/ext/v8/upstream/3.1.8/src/vm-state-inl.h +0 -134
  879. data/ext/v8/upstream/3.1.8/src/vm-state.h +0 -68
  880. data/ext/v8/upstream/3.1.8/src/win32-headers.h +0 -95
  881. data/ext/v8/upstream/3.1.8/src/x64/assembler-x64-inl.h +0 -455
  882. data/ext/v8/upstream/3.1.8/src/x64/assembler-x64.cc +0 -3162
  883. data/ext/v8/upstream/3.1.8/src/x64/assembler-x64.h +0 -1584
  884. data/ext/v8/upstream/3.1.8/src/x64/builtins-x64.cc +0 -1492
  885. data/ext/v8/upstream/3.1.8/src/x64/code-stubs-x64.cc +0 -5150
  886. data/ext/v8/upstream/3.1.8/src/x64/code-stubs-x64.h +0 -519
  887. data/ext/v8/upstream/3.1.8/src/x64/codegen-x64.cc +0 -8835
  888. data/ext/v8/upstream/3.1.8/src/x64/codegen-x64.h +0 -750
  889. data/ext/v8/upstream/3.1.8/src/x64/cpu-x64.cc +0 -86
  890. data/ext/v8/upstream/3.1.8/src/x64/debug-x64.cc +0 -316
  891. data/ext/v8/upstream/3.1.8/src/x64/deoptimizer-x64.cc +0 -781
  892. data/ext/v8/upstream/3.1.8/src/x64/disasm-x64.cc +0 -1737
  893. data/ext/v8/upstream/3.1.8/src/x64/frames-x64.h +0 -130
  894. data/ext/v8/upstream/3.1.8/src/x64/full-codegen-x64.cc +0 -3984
  895. data/ext/v8/upstream/3.1.8/src/x64/ic-x64.cc +0 -1761
  896. data/ext/v8/upstream/3.1.8/src/x64/lithium-codegen-x64.cc +0 -3639
  897. data/ext/v8/upstream/3.1.8/src/x64/lithium-codegen-x64.h +0 -305
  898. data/ext/v8/upstream/3.1.8/src/x64/lithium-x64.cc +0 -2044
  899. data/ext/v8/upstream/3.1.8/src/x64/lithium-x64.h +0 -2052
  900. data/ext/v8/upstream/3.1.8/src/x64/macro-assembler-x64.cc +0 -2660
  901. data/ext/v8/upstream/3.1.8/src/x64/macro-assembler-x64.h +0 -1852
  902. data/ext/v8/upstream/3.1.8/src/x64/regexp-macro-assembler-x64.cc +0 -1382
  903. data/ext/v8/upstream/3.1.8/src/x64/regexp-macro-assembler-x64.h +0 -278
  904. data/ext/v8/upstream/3.1.8/src/x64/register-allocator-x64-inl.h +0 -87
  905. data/ext/v8/upstream/3.1.8/src/x64/register-allocator-x64.cc +0 -91
  906. data/ext/v8/upstream/3.1.8/src/x64/simulator-x64.h +0 -71
  907. data/ext/v8/upstream/3.1.8/src/x64/stub-cache-x64.cc +0 -3509
  908. data/ext/v8/upstream/3.1.8/src/x64/virtual-frame-x64.cc +0 -1292
  909. data/ext/v8/upstream/3.1.8/src/x64/virtual-frame-x64.h +0 -593
  910. data/ext/v8/upstream/3.1.8/src/zone-inl.h +0 -83
  911. data/ext/v8/upstream/3.1.8/src/zone.cc +0 -195
  912. data/ext/v8/upstream/3.1.8/src/zone.h +0 -233
  913. data/ext/v8/upstream/3.1.8/tools/gyp/v8.gyp +0 -869
  914. data/ext/v8/upstream/3.1.8/tools/linux-tick-processor +0 -33
  915. data/ext/v8/upstream/3.1.8/tools/tickprocessor.js +0 -863
  916. data/ext/v8/upstream/3.1.8/tools/visual_studio/v8_base.vcproj +0 -1296
  917. data/ext/v8/upstream/3.1.8/tools/visual_studio/v8_base_arm.vcproj +0 -1234
  918. data/ext/v8/upstream/3.1.8/tools/visual_studio/v8_base_x64.vcproj +0 -1296
  919. data/ext/v8/upstream/3.1.8/tools/visual_studio/x64.vsprops +0 -17
  920. data/spec/ext/mem_spec.rb +0 -42
@@ -0,0 +1,62 @@
1
+ // Copyright 2011 the V8 project authors. All rights reserved.
2
+ // Redistribution and use in source and binary forms, with or without
3
+ // modification, are permitted provided that the following conditions are
4
+ // met:
5
+ //
6
+ // * Redistributions of source code must retain the above copyright
7
+ // notice, this list of conditions and the following disclaimer.
8
+ // * Redistributions in binary form must reproduce the above
9
+ // copyright notice, this list of conditions and the following
10
+ // disclaimer in the documentation and/or other materials provided
11
+ // with the distribution.
12
+ // * Neither the name of Google Inc. nor the names of its
13
+ // contributors may be used to endorse or promote products derived
14
+ // from this software without specific prior written permission.
15
+ //
16
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+
28
+ #ifndef V8_PLATFORM_TLS_MAC_H_
29
+ #define V8_PLATFORM_TLS_MAC_H_
30
+
31
+ #include "globals.h"
32
+
33
+ namespace v8 {
34
+ namespace internal {
35
+
36
+ #if defined(V8_HOST_ARCH_IA32) || defined(V8_HOST_ARCH_X64)
37
+
38
+ #define V8_FAST_TLS_SUPPORTED 1
39
+
40
+ extern intptr_t kMacTlsBaseOffset;
41
+
42
+ INLINE(intptr_t InternalGetExistingThreadLocal(intptr_t index));
43
+
44
+ inline intptr_t InternalGetExistingThreadLocal(intptr_t index) {
45
+ intptr_t result;
46
+ #if defined(V8_HOST_ARCH_IA32)
47
+ asm("movl %%gs:(%1,%2,4), %0;"
48
+ :"=r"(result) // Output must be a writable register.
49
+ :"r"(kMacTlsBaseOffset), "r"(index));
50
+ #else
51
+ asm("movq %%gs:(%1,%2,8), %0;"
52
+ :"=r"(result)
53
+ :"r"(kMacTlsBaseOffset), "r"(index));
54
+ #endif
55
+ return result;
56
+ }
57
+
58
+ #endif
59
+
60
+ } } // namespace v8::internal
61
+
62
+ #endif // V8_PLATFORM_TLS_MAC_H_
@@ -0,0 +1,62 @@
1
+ // Copyright 2011 the V8 project authors. All rights reserved.
2
+ // Redistribution and use in source and binary forms, with or without
3
+ // modification, are permitted provided that the following conditions are
4
+ // met:
5
+ //
6
+ // * Redistributions of source code must retain the above copyright
7
+ // notice, this list of conditions and the following disclaimer.
8
+ // * Redistributions in binary form must reproduce the above
9
+ // copyright notice, this list of conditions and the following
10
+ // disclaimer in the documentation and/or other materials provided
11
+ // with the distribution.
12
+ // * Neither the name of Google Inc. nor the names of its
13
+ // contributors may be used to endorse or promote products derived
14
+ // from this software without specific prior written permission.
15
+ //
16
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+
28
+ #ifndef V8_PLATFORM_TLS_WIN32_H_
29
+ #define V8_PLATFORM_TLS_WIN32_H_
30
+
31
+ #include "checks.h"
32
+ #include "globals.h"
33
+ #include "win32-headers.h"
34
+
35
+ namespace v8 {
36
+ namespace internal {
37
+
38
+ #if defined(_WIN32) && !defined(_WIN64)
39
+
40
+ #define V8_FAST_TLS_SUPPORTED 1
41
+
42
+ inline intptr_t InternalGetExistingThreadLocal(intptr_t index) {
43
+ const intptr_t kTibInlineTlsOffset = 0xE10;
44
+ const intptr_t kTibExtraTlsOffset = 0xF94;
45
+ const intptr_t kMaxInlineSlots = 64;
46
+ const intptr_t kMaxSlots = kMaxInlineSlots + 1024;
47
+ ASSERT(0 <= index && index < kMaxSlots);
48
+ if (index < kMaxInlineSlots) {
49
+ return static_cast<intptr_t>(__readfsdword(kTibInlineTlsOffset +
50
+ kPointerSize * index));
51
+ }
52
+ intptr_t extra = static_cast<intptr_t>(__readfsdword(kTibExtraTlsOffset));
53
+ ASSERT(extra != 0);
54
+ return *reinterpret_cast<intptr_t*>(extra +
55
+ kPointerSize * (index - kMaxInlineSlots));
56
+ }
57
+
58
+ #endif
59
+
60
+ } } // namespace v8::internal
61
+
62
+ #endif // V8_PLATFORM_TLS_WIN32_H_
@@ -0,0 +1,50 @@
1
+ // Copyright 2011 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
+ // Platform and architecture specific thread local store functions.
29
+
30
+ #ifndef V8_PLATFORM_TLS_H_
31
+ #define V8_PLATFORM_TLS_H_
32
+
33
+ #ifdef V8_FAST_TLS
34
+
35
+ // When fast TLS is requested we include the appropriate
36
+ // implementation header.
37
+ //
38
+ // The implementation header defines V8_FAST_TLS_SUPPORTED if it
39
+ // provides fast TLS support for the current platform and architecture
40
+ // combination.
41
+
42
+ #if defined(_MSC_VER) && (defined(_WIN32) || defined(_WIN64))
43
+ #include "platform-tls-win32.h"
44
+ #elif defined(__APPLE__)
45
+ #include "platform-tls-mac.h"
46
+ #endif
47
+
48
+ #endif
49
+
50
+ #endif // V8_PLATFORM_TLS_H_
@@ -0,0 +1,2072 @@
1
+ // Copyright 2006-2008 the V8 project authors. All rights reserved.
2
+ // Redistribution and use in source and binary forms, with or without
3
+ // modification, are permitted provided that the following conditions are
4
+ // met:
5
+ //
6
+ // * Redistributions of source code must retain the above copyright
7
+ // notice, this list of conditions and the following disclaimer.
8
+ // * Redistributions in binary form must reproduce the above
9
+ // copyright notice, this list of conditions and the following
10
+ // disclaimer in the documentation and/or other materials provided
11
+ // with the distribution.
12
+ // * Neither the name of Google Inc. nor the names of its
13
+ // contributors may be used to endorse or promote products derived
14
+ // from this software without specific prior written permission.
15
+ //
16
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+
28
+ // Platform specific code for Win32.
29
+
30
+ #define V8_WIN32_HEADERS_FULL
31
+ #include "win32-headers.h"
32
+
33
+ #include "v8.h"
34
+
35
+ #include "platform.h"
36
+ #include "vm-state-inl.h"
37
+
38
+ // Extra POSIX/ANSI routines for Win32 when when using Visual Studio C++. Please
39
+ // refer to The Open Group Base Specification for specification of the correct
40
+ // semantics for these functions.
41
+ // (http://www.opengroup.org/onlinepubs/000095399/)
42
+ #ifdef _MSC_VER
43
+
44
+ namespace v8 {
45
+ namespace internal {
46
+
47
+ // Test for finite value - usually defined in math.h
48
+ int isfinite(double x) {
49
+ return _finite(x);
50
+ }
51
+
52
+ } // namespace v8
53
+ } // namespace internal
54
+
55
+ // Test for a NaN (not a number) value - usually defined in math.h
56
+ int isnan(double x) {
57
+ return _isnan(x);
58
+ }
59
+
60
+
61
+ // Test for infinity - usually defined in math.h
62
+ int isinf(double x) {
63
+ return (_fpclass(x) & (_FPCLASS_PINF | _FPCLASS_NINF)) != 0;
64
+ }
65
+
66
+
67
+ // Test if x is less than y and both nominal - usually defined in math.h
68
+ int isless(double x, double y) {
69
+ return isnan(x) || isnan(y) ? 0 : x < y;
70
+ }
71
+
72
+
73
+ // Test if x is greater than y and both nominal - usually defined in math.h
74
+ int isgreater(double x, double y) {
75
+ return isnan(x) || isnan(y) ? 0 : x > y;
76
+ }
77
+
78
+
79
+ // Classify floating point number - usually defined in math.h
80
+ int fpclassify(double x) {
81
+ // Use the MS-specific _fpclass() for classification.
82
+ int flags = _fpclass(x);
83
+
84
+ // Determine class. We cannot use a switch statement because
85
+ // the _FPCLASS_ constants are defined as flags.
86
+ if (flags & (_FPCLASS_PN | _FPCLASS_NN)) return FP_NORMAL;
87
+ if (flags & (_FPCLASS_PZ | _FPCLASS_NZ)) return FP_ZERO;
88
+ if (flags & (_FPCLASS_PD | _FPCLASS_ND)) return FP_SUBNORMAL;
89
+ if (flags & (_FPCLASS_PINF | _FPCLASS_NINF)) return FP_INFINITE;
90
+
91
+ // All cases should be covered by the code above.
92
+ ASSERT(flags & (_FPCLASS_SNAN | _FPCLASS_QNAN));
93
+ return FP_NAN;
94
+ }
95
+
96
+
97
+ // Test sign - usually defined in math.h
98
+ int signbit(double x) {
99
+ // We need to take care of the special case of both positive
100
+ // and negative versions of zero.
101
+ if (x == 0)
102
+ return _fpclass(x) & _FPCLASS_NZ;
103
+ else
104
+ return x < 0;
105
+ }
106
+
107
+
108
+ // Case-insensitive bounded string comparisons. Use stricmp() on Win32. Usually
109
+ // defined in strings.h.
110
+ int strncasecmp(const char* s1, const char* s2, int n) {
111
+ return _strnicmp(s1, s2, n);
112
+ }
113
+
114
+ #endif // _MSC_VER
115
+
116
+
117
+ // Extra functions for MinGW. Most of these are the _s functions which are in
118
+ // the Microsoft Visual Studio C++ CRT.
119
+ #ifdef __MINGW32__
120
+
121
+ int localtime_s(tm* out_tm, const time_t* time) {
122
+ tm* posix_local_time_struct = localtime(time);
123
+ if (posix_local_time_struct == NULL) return 1;
124
+ *out_tm = *posix_local_time_struct;
125
+ return 0;
126
+ }
127
+
128
+
129
+ // Not sure this the correct interpretation of _mkgmtime
130
+ time_t _mkgmtime(tm* timeptr) {
131
+ return mktime(timeptr);
132
+ }
133
+
134
+
135
+ int fopen_s(FILE** pFile, const char* filename, const char* mode) {
136
+ *pFile = fopen(filename, mode);
137
+ return *pFile != NULL ? 0 : 1;
138
+ }
139
+
140
+
141
+ int _vsnprintf_s(char* buffer, size_t sizeOfBuffer, size_t count,
142
+ const char* format, va_list argptr) {
143
+ return _vsnprintf(buffer, sizeOfBuffer, format, argptr);
144
+ }
145
+ #define _TRUNCATE 0
146
+
147
+
148
+ int strncpy_s(char* strDest, size_t numberOfElements,
149
+ const char* strSource, size_t count) {
150
+ strncpy(strDest, strSource, count);
151
+ return 0;
152
+ }
153
+
154
+
155
+ inline void MemoryBarrier() {
156
+ int barrier = 0;
157
+ __asm__ __volatile__("xchgl %%eax,%0 ":"=r" (barrier));
158
+ }
159
+
160
+ #endif // __MINGW32__
161
+
162
+ // Generate a pseudo-random number in the range 0-2^31-1. Usually
163
+ // defined in stdlib.h. Missing in both Microsoft Visual Studio C++ and MinGW.
164
+ int random() {
165
+ return rand();
166
+ }
167
+
168
+
169
+ namespace v8 {
170
+ namespace internal {
171
+
172
+ double ceiling(double x) {
173
+ return ceil(x);
174
+ }
175
+
176
+
177
+ static Mutex* limit_mutex = NULL;
178
+
179
+ #if defined(V8_TARGET_ARCH_IA32)
180
+ static OS::MemCopyFunction memcopy_function = NULL;
181
+ static Mutex* memcopy_function_mutex = OS::CreateMutex();
182
+ // Defined in codegen-ia32.cc.
183
+ OS::MemCopyFunction CreateMemCopyFunction();
184
+
185
+ // Copy memory area to disjoint memory area.
186
+ void OS::MemCopy(void* dest, const void* src, size_t size) {
187
+ if (memcopy_function == NULL) {
188
+ ScopedLock lock(memcopy_function_mutex);
189
+ if (memcopy_function == NULL) {
190
+ OS::MemCopyFunction temp = CreateMemCopyFunction();
191
+ MemoryBarrier();
192
+ memcopy_function = temp;
193
+ }
194
+ }
195
+ // Note: here we rely on dependent reads being ordered. This is true
196
+ // on all architectures we currently support.
197
+ (*memcopy_function)(dest, src, size);
198
+ #ifdef DEBUG
199
+ CHECK_EQ(0, memcmp(dest, src, size));
200
+ #endif
201
+ }
202
+ #endif // V8_TARGET_ARCH_IA32
203
+
204
+ #ifdef _WIN64
205
+ typedef double (*ModuloFunction)(double, double);
206
+ static ModuloFunction modulo_function = NULL;
207
+ static Mutex* modulo_function_mutex = OS::CreateMutex();
208
+ // Defined in codegen-x64.cc.
209
+ ModuloFunction CreateModuloFunction();
210
+
211
+ double modulo(double x, double y) {
212
+ if (modulo_function == NULL) {
213
+ ScopedLock lock(modulo_function_mutex);
214
+ if (modulo_function == NULL) {
215
+ ModuloFunction temp = CreateModuloFunction();
216
+ MemoryBarrier();
217
+ modulo_function = temp;
218
+ }
219
+ }
220
+ // Note: here we rely on dependent reads being ordered. This is true
221
+ // on all architectures we currently support.
222
+ return (*modulo_function)(x, y);
223
+ }
224
+ #else // Win32
225
+
226
+ double modulo(double x, double y) {
227
+ // Workaround MS fmod bugs. ECMA-262 says:
228
+ // dividend is finite and divisor is an infinity => result equals dividend
229
+ // dividend is a zero and divisor is nonzero finite => result equals dividend
230
+ if (!(isfinite(x) && (!isfinite(y) && !isnan(y))) &&
231
+ !(x == 0 && (y != 0 && isfinite(y)))) {
232
+ x = fmod(x, y);
233
+ }
234
+ return x;
235
+ }
236
+
237
+ #endif // _WIN64
238
+
239
+ // ----------------------------------------------------------------------------
240
+ // The Time class represents time on win32. A timestamp is represented as
241
+ // a 64-bit integer in 100 nano-seconds since January 1, 1601 (UTC). JavaScript
242
+ // timestamps are represented as a doubles in milliseconds since 00:00:00 UTC,
243
+ // January 1, 1970.
244
+
245
+ class Time {
246
+ public:
247
+ // Constructors.
248
+ Time();
249
+ explicit Time(double jstime);
250
+ Time(int year, int mon, int day, int hour, int min, int sec);
251
+
252
+ // Convert timestamp to JavaScript representation.
253
+ double ToJSTime();
254
+
255
+ // Set timestamp to current time.
256
+ void SetToCurrentTime();
257
+
258
+ // Returns the local timezone offset in milliseconds east of UTC. This is
259
+ // the number of milliseconds you must add to UTC to get local time, i.e.
260
+ // LocalOffset(CET) = 3600000 and LocalOffset(PST) = -28800000. This
261
+ // routine also takes into account whether daylight saving is effect
262
+ // at the time.
263
+ int64_t LocalOffset();
264
+
265
+ // Returns the daylight savings time offset for the time in milliseconds.
266
+ int64_t DaylightSavingsOffset();
267
+
268
+ // Returns a string identifying the current timezone for the
269
+ // timestamp taking into account daylight saving.
270
+ char* LocalTimezone();
271
+
272
+ private:
273
+ // Constants for time conversion.
274
+ static const int64_t kTimeEpoc = 116444736000000000LL;
275
+ static const int64_t kTimeScaler = 10000;
276
+ static const int64_t kMsPerMinute = 60000;
277
+
278
+ // Constants for timezone information.
279
+ static const int kTzNameSize = 128;
280
+ static const bool kShortTzNames = false;
281
+
282
+ // Timezone information. We need to have static buffers for the
283
+ // timezone names because we return pointers to these in
284
+ // LocalTimezone().
285
+ static bool tz_initialized_;
286
+ static TIME_ZONE_INFORMATION tzinfo_;
287
+ static char std_tz_name_[kTzNameSize];
288
+ static char dst_tz_name_[kTzNameSize];
289
+
290
+ // Initialize the timezone information (if not already done).
291
+ static void TzSet();
292
+
293
+ // Guess the name of the timezone from the bias.
294
+ static const char* GuessTimezoneNameFromBias(int bias);
295
+
296
+ // Return whether or not daylight savings time is in effect at this time.
297
+ bool InDST();
298
+
299
+ // Return the difference (in milliseconds) between this timestamp and
300
+ // another timestamp.
301
+ int64_t Diff(Time* other);
302
+
303
+ // Accessor for FILETIME representation.
304
+ FILETIME& ft() { return time_.ft_; }
305
+
306
+ // Accessor for integer representation.
307
+ int64_t& t() { return time_.t_; }
308
+
309
+ // Although win32 uses 64-bit integers for representing timestamps,
310
+ // these are packed into a FILETIME structure. The FILETIME structure
311
+ // is just a struct representing a 64-bit integer. The TimeStamp union
312
+ // allows access to both a FILETIME and an integer representation of
313
+ // the timestamp.
314
+ union TimeStamp {
315
+ FILETIME ft_;
316
+ int64_t t_;
317
+ };
318
+
319
+ TimeStamp time_;
320
+ };
321
+
322
+ // Static variables.
323
+ bool Time::tz_initialized_ = false;
324
+ TIME_ZONE_INFORMATION Time::tzinfo_;
325
+ char Time::std_tz_name_[kTzNameSize];
326
+ char Time::dst_tz_name_[kTzNameSize];
327
+
328
+
329
+ // Initialize timestamp to start of epoc.
330
+ Time::Time() {
331
+ t() = 0;
332
+ }
333
+
334
+
335
+ // Initialize timestamp from a JavaScript timestamp.
336
+ Time::Time(double jstime) {
337
+ t() = static_cast<int64_t>(jstime) * kTimeScaler + kTimeEpoc;
338
+ }
339
+
340
+
341
+ // Initialize timestamp from date/time components.
342
+ Time::Time(int year, int mon, int day, int hour, int min, int sec) {
343
+ SYSTEMTIME st;
344
+ st.wYear = year;
345
+ st.wMonth = mon;
346
+ st.wDay = day;
347
+ st.wHour = hour;
348
+ st.wMinute = min;
349
+ st.wSecond = sec;
350
+ st.wMilliseconds = 0;
351
+ SystemTimeToFileTime(&st, &ft());
352
+ }
353
+
354
+
355
+ // Convert timestamp to JavaScript timestamp.
356
+ double Time::ToJSTime() {
357
+ return static_cast<double>((t() - kTimeEpoc) / kTimeScaler);
358
+ }
359
+
360
+
361
+ // Guess the name of the timezone from the bias.
362
+ // The guess is very biased towards the northern hemisphere.
363
+ const char* Time::GuessTimezoneNameFromBias(int bias) {
364
+ static const int kHour = 60;
365
+ switch (-bias) {
366
+ case -9*kHour: return "Alaska";
367
+ case -8*kHour: return "Pacific";
368
+ case -7*kHour: return "Mountain";
369
+ case -6*kHour: return "Central";
370
+ case -5*kHour: return "Eastern";
371
+ case -4*kHour: return "Atlantic";
372
+ case 0*kHour: return "GMT";
373
+ case +1*kHour: return "Central Europe";
374
+ case +2*kHour: return "Eastern Europe";
375
+ case +3*kHour: return "Russia";
376
+ case +5*kHour + 30: return "India";
377
+ case +8*kHour: return "China";
378
+ case +9*kHour: return "Japan";
379
+ case +12*kHour: return "New Zealand";
380
+ default: return "Local";
381
+ }
382
+ }
383
+
384
+
385
+ // Initialize timezone information. The timezone information is obtained from
386
+ // windows. If we cannot get the timezone information we fall back to CET.
387
+ // Please notice that this code is not thread-safe.
388
+ void Time::TzSet() {
389
+ // Just return if timezone information has already been initialized.
390
+ if (tz_initialized_) return;
391
+
392
+ // Initialize POSIX time zone data.
393
+ _tzset();
394
+ // Obtain timezone information from operating system.
395
+ memset(&tzinfo_, 0, sizeof(tzinfo_));
396
+ if (GetTimeZoneInformation(&tzinfo_) == TIME_ZONE_ID_INVALID) {
397
+ // If we cannot get timezone information we fall back to CET.
398
+ tzinfo_.Bias = -60;
399
+ tzinfo_.StandardDate.wMonth = 10;
400
+ tzinfo_.StandardDate.wDay = 5;
401
+ tzinfo_.StandardDate.wHour = 3;
402
+ tzinfo_.StandardBias = 0;
403
+ tzinfo_.DaylightDate.wMonth = 3;
404
+ tzinfo_.DaylightDate.wDay = 5;
405
+ tzinfo_.DaylightDate.wHour = 2;
406
+ tzinfo_.DaylightBias = -60;
407
+ }
408
+
409
+ // Make standard and DST timezone names.
410
+ OS::SNPrintF(Vector<char>(std_tz_name_, kTzNameSize),
411
+ "%S",
412
+ tzinfo_.StandardName);
413
+ std_tz_name_[kTzNameSize - 1] = '\0';
414
+ OS::SNPrintF(Vector<char>(dst_tz_name_, kTzNameSize),
415
+ "%S",
416
+ tzinfo_.DaylightName);
417
+ dst_tz_name_[kTzNameSize - 1] = '\0';
418
+
419
+ // If OS returned empty string or resource id (like "@tzres.dll,-211")
420
+ // simply guess the name from the UTC bias of the timezone.
421
+ // To properly resolve the resource identifier requires a library load,
422
+ // which is not possible in a sandbox.
423
+ if (std_tz_name_[0] == '\0' || std_tz_name_[0] == '@') {
424
+ OS::SNPrintF(Vector<char>(std_tz_name_, kTzNameSize - 1),
425
+ "%s Standard Time",
426
+ GuessTimezoneNameFromBias(tzinfo_.Bias));
427
+ }
428
+ if (dst_tz_name_[0] == '\0' || dst_tz_name_[0] == '@') {
429
+ OS::SNPrintF(Vector<char>(dst_tz_name_, kTzNameSize - 1),
430
+ "%s Daylight Time",
431
+ GuessTimezoneNameFromBias(tzinfo_.Bias));
432
+ }
433
+
434
+ // Timezone information initialized.
435
+ tz_initialized_ = true;
436
+ }
437
+
438
+
439
+ // Return the difference in milliseconds between this and another timestamp.
440
+ int64_t Time::Diff(Time* other) {
441
+ return (t() - other->t()) / kTimeScaler;
442
+ }
443
+
444
+
445
+ // Set timestamp to current time.
446
+ void Time::SetToCurrentTime() {
447
+ // The default GetSystemTimeAsFileTime has a ~15.5ms resolution.
448
+ // Because we're fast, we like fast timers which have at least a
449
+ // 1ms resolution.
450
+ //
451
+ // timeGetTime() provides 1ms granularity when combined with
452
+ // timeBeginPeriod(). If the host application for v8 wants fast
453
+ // timers, it can use timeBeginPeriod to increase the resolution.
454
+ //
455
+ // Using timeGetTime() has a drawback because it is a 32bit value
456
+ // and hence rolls-over every ~49days.
457
+ //
458
+ // To use the clock, we use GetSystemTimeAsFileTime as our base;
459
+ // and then use timeGetTime to extrapolate current time from the
460
+ // start time. To deal with rollovers, we resync the clock
461
+ // any time when more than kMaxClockElapsedTime has passed or
462
+ // whenever timeGetTime creates a rollover.
463
+
464
+ static bool initialized = false;
465
+ static TimeStamp init_time;
466
+ static DWORD init_ticks;
467
+ static const int64_t kHundredNanosecondsPerSecond = 10000000;
468
+ static const int64_t kMaxClockElapsedTime =
469
+ 60*kHundredNanosecondsPerSecond; // 1 minute
470
+
471
+ // If we are uninitialized, we need to resync the clock.
472
+ bool needs_resync = !initialized;
473
+
474
+ // Get the current time.
475
+ TimeStamp time_now;
476
+ GetSystemTimeAsFileTime(&time_now.ft_);
477
+ DWORD ticks_now = timeGetTime();
478
+
479
+ // Check if we need to resync due to clock rollover.
480
+ needs_resync |= ticks_now < init_ticks;
481
+
482
+ // Check if we need to resync due to elapsed time.
483
+ needs_resync |= (time_now.t_ - init_time.t_) > kMaxClockElapsedTime;
484
+
485
+ // Resync the clock if necessary.
486
+ if (needs_resync) {
487
+ GetSystemTimeAsFileTime(&init_time.ft_);
488
+ init_ticks = ticks_now = timeGetTime();
489
+ initialized = true;
490
+ }
491
+
492
+ // Finally, compute the actual time. Why is this so hard.
493
+ DWORD elapsed = ticks_now - init_ticks;
494
+ this->time_.t_ = init_time.t_ + (static_cast<int64_t>(elapsed) * 10000);
495
+ }
496
+
497
+
498
+ // Return the local timezone offset in milliseconds east of UTC. This
499
+ // takes into account whether daylight saving is in effect at the time.
500
+ // Only times in the 32-bit Unix range may be passed to this function.
501
+ // Also, adding the time-zone offset to the input must not overflow.
502
+ // The function EquivalentTime() in date.js guarantees this.
503
+ int64_t Time::LocalOffset() {
504
+ // Initialize timezone information, if needed.
505
+ TzSet();
506
+
507
+ Time rounded_to_second(*this);
508
+ rounded_to_second.t() = rounded_to_second.t() / 1000 / kTimeScaler *
509
+ 1000 * kTimeScaler;
510
+ // Convert to local time using POSIX localtime function.
511
+ // Windows XP Service Pack 3 made SystemTimeToTzSpecificLocalTime()
512
+ // very slow. Other browsers use localtime().
513
+
514
+ // Convert from JavaScript milliseconds past 1/1/1970 0:00:00 to
515
+ // POSIX seconds past 1/1/1970 0:00:00.
516
+ double unchecked_posix_time = rounded_to_second.ToJSTime() / 1000;
517
+ if (unchecked_posix_time > INT_MAX || unchecked_posix_time < 0) {
518
+ return 0;
519
+ }
520
+ // Because _USE_32BIT_TIME_T is defined, time_t is a 32-bit int.
521
+ time_t posix_time = static_cast<time_t>(unchecked_posix_time);
522
+
523
+ // Convert to local time, as struct with fields for day, hour, year, etc.
524
+ tm posix_local_time_struct;
525
+ if (localtime_s(&posix_local_time_struct, &posix_time)) return 0;
526
+ // Convert local time in struct to POSIX time as if it were a UTC time.
527
+ time_t local_posix_time = _mkgmtime(&posix_local_time_struct);
528
+ Time localtime(1000.0 * local_posix_time);
529
+
530
+ return localtime.Diff(&rounded_to_second);
531
+ }
532
+
533
+
534
+ // Return whether or not daylight savings time is in effect at this time.
535
+ bool Time::InDST() {
536
+ // Initialize timezone information, if needed.
537
+ TzSet();
538
+
539
+ // Determine if DST is in effect at the specified time.
540
+ bool in_dst = false;
541
+ if (tzinfo_.StandardDate.wMonth != 0 || tzinfo_.DaylightDate.wMonth != 0) {
542
+ // Get the local timezone offset for the timestamp in milliseconds.
543
+ int64_t offset = LocalOffset();
544
+
545
+ // Compute the offset for DST. The bias parameters in the timezone info
546
+ // are specified in minutes. These must be converted to milliseconds.
547
+ int64_t dstofs = -(tzinfo_.Bias + tzinfo_.DaylightBias) * kMsPerMinute;
548
+
549
+ // If the local time offset equals the timezone bias plus the daylight
550
+ // bias then DST is in effect.
551
+ in_dst = offset == dstofs;
552
+ }
553
+
554
+ return in_dst;
555
+ }
556
+
557
+
558
+ // Return the daylight savings time offset for this time.
559
+ int64_t Time::DaylightSavingsOffset() {
560
+ return InDST() ? 60 * kMsPerMinute : 0;
561
+ }
562
+
563
+
564
+ // Returns a string identifying the current timezone for the
565
+ // timestamp taking into account daylight saving.
566
+ char* Time::LocalTimezone() {
567
+ // Return the standard or DST time zone name based on whether daylight
568
+ // saving is in effect at the given time.
569
+ return InDST() ? dst_tz_name_ : std_tz_name_;
570
+ }
571
+
572
+
573
+ void OS::Setup() {
574
+ // Seed the random number generator.
575
+ // Convert the current time to a 64-bit integer first, before converting it
576
+ // to an unsigned. Going directly can cause an overflow and the seed to be
577
+ // set to all ones. The seed will be identical for different instances that
578
+ // call this setup code within the same millisecond.
579
+ uint64_t seed = static_cast<uint64_t>(TimeCurrentMillis());
580
+ srand(static_cast<unsigned int>(seed));
581
+ limit_mutex = CreateMutex();
582
+ }
583
+
584
+
585
+ // Returns the accumulated user time for thread.
586
+ int OS::GetUserTime(uint32_t* secs, uint32_t* usecs) {
587
+ FILETIME dummy;
588
+ uint64_t usertime;
589
+
590
+ // Get the amount of time that the thread has executed in user mode.
591
+ if (!GetThreadTimes(GetCurrentThread(), &dummy, &dummy, &dummy,
592
+ reinterpret_cast<FILETIME*>(&usertime))) return -1;
593
+
594
+ // Adjust the resolution to micro-seconds.
595
+ usertime /= 10;
596
+
597
+ // Convert to seconds and microseconds
598
+ *secs = static_cast<uint32_t>(usertime / 1000000);
599
+ *usecs = static_cast<uint32_t>(usertime % 1000000);
600
+ return 0;
601
+ }
602
+
603
+
604
+ // Returns current time as the number of milliseconds since
605
+ // 00:00:00 UTC, January 1, 1970.
606
+ double OS::TimeCurrentMillis() {
607
+ Time t;
608
+ t.SetToCurrentTime();
609
+ return t.ToJSTime();
610
+ }
611
+
612
+ // Returns the tickcounter based on timeGetTime.
613
+ int64_t OS::Ticks() {
614
+ return timeGetTime() * 1000; // Convert to microseconds.
615
+ }
616
+
617
+
618
+ // Returns a string identifying the current timezone taking into
619
+ // account daylight saving.
620
+ const char* OS::LocalTimezone(double time) {
621
+ return Time(time).LocalTimezone();
622
+ }
623
+
624
+
625
+ // Returns the local time offset in milliseconds east of UTC without
626
+ // taking daylight savings time into account.
627
+ double OS::LocalTimeOffset() {
628
+ // Use current time, rounded to the millisecond.
629
+ Time t(TimeCurrentMillis());
630
+ // Time::LocalOffset inlcudes any daylight savings offset, so subtract it.
631
+ return static_cast<double>(t.LocalOffset() - t.DaylightSavingsOffset());
632
+ }
633
+
634
+
635
+ // Returns the daylight savings offset in milliseconds for the given
636
+ // time.
637
+ double OS::DaylightSavingsOffset(double time) {
638
+ int64_t offset = Time(time).DaylightSavingsOffset();
639
+ return static_cast<double>(offset);
640
+ }
641
+
642
+
643
+ int OS::GetLastError() {
644
+ return ::GetLastError();
645
+ }
646
+
647
+
648
+ // ----------------------------------------------------------------------------
649
+ // Win32 console output.
650
+ //
651
+ // If a Win32 application is linked as a console application it has a normal
652
+ // standard output and standard error. In this case normal printf works fine
653
+ // for output. However, if the application is linked as a GUI application,
654
+ // the process doesn't have a console, and therefore (debugging) output is lost.
655
+ // This is the case if we are embedded in a windows program (like a browser).
656
+ // In order to be able to get debug output in this case the the debugging
657
+ // facility using OutputDebugString. This output goes to the active debugger
658
+ // for the process (if any). Else the output can be monitored using DBMON.EXE.
659
+
660
+ enum OutputMode {
661
+ UNKNOWN, // Output method has not yet been determined.
662
+ CONSOLE, // Output is written to stdout.
663
+ ODS // Output is written to debug facility.
664
+ };
665
+
666
+ static OutputMode output_mode = UNKNOWN; // Current output mode.
667
+
668
+
669
+ // Determine if the process has a console for output.
670
+ static bool HasConsole() {
671
+ // Only check the first time. Eventual race conditions are not a problem,
672
+ // because all threads will eventually determine the same mode.
673
+ if (output_mode == UNKNOWN) {
674
+ // We cannot just check that the standard output is attached to a console
675
+ // because this would fail if output is redirected to a file. Therefore we
676
+ // say that a process does not have an output console if either the
677
+ // standard output handle is invalid or its file type is unknown.
678
+ if (GetStdHandle(STD_OUTPUT_HANDLE) != INVALID_HANDLE_VALUE &&
679
+ GetFileType(GetStdHandle(STD_OUTPUT_HANDLE)) != FILE_TYPE_UNKNOWN)
680
+ output_mode = CONSOLE;
681
+ else
682
+ output_mode = ODS;
683
+ }
684
+ return output_mode == CONSOLE;
685
+ }
686
+
687
+
688
+ static void VPrintHelper(FILE* stream, const char* format, va_list args) {
689
+ if (HasConsole()) {
690
+ vfprintf(stream, format, args);
691
+ } else {
692
+ // It is important to use safe print here in order to avoid
693
+ // overflowing the buffer. We might truncate the output, but this
694
+ // does not crash.
695
+ EmbeddedVector<char, 4096> buffer;
696
+ OS::VSNPrintF(buffer, format, args);
697
+ OutputDebugStringA(buffer.start());
698
+ }
699
+ }
700
+
701
+
702
+ FILE* OS::FOpen(const char* path, const char* mode) {
703
+ FILE* result;
704
+ if (fopen_s(&result, path, mode) == 0) {
705
+ return result;
706
+ } else {
707
+ return NULL;
708
+ }
709
+ }
710
+
711
+
712
+ bool OS::Remove(const char* path) {
713
+ return (DeleteFileA(path) != 0);
714
+ }
715
+
716
+
717
+ // Open log file in binary mode to avoid /n -> /r/n conversion.
718
+ const char* const OS::LogFileOpenMode = "wb";
719
+
720
+
721
+ // Print (debug) message to console.
722
+ void OS::Print(const char* format, ...) {
723
+ va_list args;
724
+ va_start(args, format);
725
+ VPrint(format, args);
726
+ va_end(args);
727
+ }
728
+
729
+
730
+ void OS::VPrint(const char* format, va_list args) {
731
+ VPrintHelper(stdout, format, args);
732
+ }
733
+
734
+
735
+ void OS::FPrint(FILE* out, const char* format, ...) {
736
+ va_list args;
737
+ va_start(args, format);
738
+ VFPrint(out, format, args);
739
+ va_end(args);
740
+ }
741
+
742
+
743
+ void OS::VFPrint(FILE* out, const char* format, va_list args) {
744
+ VPrintHelper(out, format, args);
745
+ }
746
+
747
+
748
+ // Print error message to console.
749
+ void OS::PrintError(const char* format, ...) {
750
+ va_list args;
751
+ va_start(args, format);
752
+ VPrintError(format, args);
753
+ va_end(args);
754
+ }
755
+
756
+
757
+ void OS::VPrintError(const char* format, va_list args) {
758
+ VPrintHelper(stderr, format, args);
759
+ }
760
+
761
+
762
+ int OS::SNPrintF(Vector<char> str, const char* format, ...) {
763
+ va_list args;
764
+ va_start(args, format);
765
+ int result = VSNPrintF(str, format, args);
766
+ va_end(args);
767
+ return result;
768
+ }
769
+
770
+
771
+ int OS::VSNPrintF(Vector<char> str, const char* format, va_list args) {
772
+ int n = _vsnprintf_s(str.start(), str.length(), _TRUNCATE, format, args);
773
+ // Make sure to zero-terminate the string if the output was
774
+ // truncated or if there was an error.
775
+ if (n < 0 || n >= str.length()) {
776
+ if (str.length() > 0)
777
+ str[str.length() - 1] = '\0';
778
+ return -1;
779
+ } else {
780
+ return n;
781
+ }
782
+ }
783
+
784
+
785
+ char* OS::StrChr(char* str, int c) {
786
+ return const_cast<char*>(strchr(str, c));
787
+ }
788
+
789
+
790
+ void OS::StrNCpy(Vector<char> dest, const char* src, size_t n) {
791
+ // Use _TRUNCATE or strncpy_s crashes (by design) if buffer is too small.
792
+ size_t buffer_size = static_cast<size_t>(dest.length());
793
+ if (n + 1 > buffer_size) // count for trailing '\0'
794
+ n = _TRUNCATE;
795
+ int result = strncpy_s(dest.start(), dest.length(), src, n);
796
+ USE(result);
797
+ ASSERT(result == 0 || (n == _TRUNCATE && result == STRUNCATE));
798
+ }
799
+
800
+
801
+ // We keep the lowest and highest addresses mapped as a quick way of
802
+ // determining that pointers are outside the heap (used mostly in assertions
803
+ // and verification). The estimate is conservative, ie, not all addresses in
804
+ // 'allocated' space are actually allocated to our heap. The range is
805
+ // [lowest, highest), inclusive on the low and and exclusive on the high end.
806
+ static void* lowest_ever_allocated = reinterpret_cast<void*>(-1);
807
+ static void* highest_ever_allocated = reinterpret_cast<void*>(0);
808
+
809
+
810
+ static void UpdateAllocatedSpaceLimits(void* address, int size) {
811
+ ASSERT(limit_mutex != NULL);
812
+ ScopedLock lock(limit_mutex);
813
+
814
+ lowest_ever_allocated = Min(lowest_ever_allocated, address);
815
+ highest_ever_allocated =
816
+ Max(highest_ever_allocated,
817
+ reinterpret_cast<void*>(reinterpret_cast<char*>(address) + size));
818
+ }
819
+
820
+
821
+ bool OS::IsOutsideAllocatedSpace(void* pointer) {
822
+ if (pointer < lowest_ever_allocated || pointer >= highest_ever_allocated)
823
+ return true;
824
+ // Ask the Windows API
825
+ if (IsBadWritePtr(pointer, 1))
826
+ return true;
827
+ return false;
828
+ }
829
+
830
+
831
+ // Get the system's page size used by VirtualAlloc() or the next power
832
+ // of two. The reason for always returning a power of two is that the
833
+ // rounding up in OS::Allocate expects that.
834
+ static size_t GetPageSize() {
835
+ static size_t page_size = 0;
836
+ if (page_size == 0) {
837
+ SYSTEM_INFO info;
838
+ GetSystemInfo(&info);
839
+ page_size = RoundUpToPowerOf2(info.dwPageSize);
840
+ }
841
+ return page_size;
842
+ }
843
+
844
+
845
+ // The allocation alignment is the guaranteed alignment for
846
+ // VirtualAlloc'ed blocks of memory.
847
+ size_t OS::AllocateAlignment() {
848
+ static size_t allocate_alignment = 0;
849
+ if (allocate_alignment == 0) {
850
+ SYSTEM_INFO info;
851
+ GetSystemInfo(&info);
852
+ allocate_alignment = info.dwAllocationGranularity;
853
+ }
854
+ return allocate_alignment;
855
+ }
856
+
857
+
858
+ void* OS::Allocate(const size_t requested,
859
+ size_t* allocated,
860
+ bool is_executable) {
861
+ // The address range used to randomize RWX allocations in OS::Allocate
862
+ // Try not to map pages into the default range that windows loads DLLs
863
+ // Use a multiple of 64k to prevent committing unused memory.
864
+ // Note: This does not guarantee RWX regions will be within the
865
+ // range kAllocationRandomAddressMin to kAllocationRandomAddressMax
866
+ #ifdef V8_HOST_ARCH_64_BIT
867
+ static const intptr_t kAllocationRandomAddressMin = 0x0000000080000000;
868
+ static const intptr_t kAllocationRandomAddressMax = 0x000003FFFFFF0000;
869
+ #else
870
+ static const intptr_t kAllocationRandomAddressMin = 0x04000000;
871
+ static const intptr_t kAllocationRandomAddressMax = 0x3FFF0000;
872
+ #endif
873
+
874
+ // VirtualAlloc rounds allocated size to page size automatically.
875
+ size_t msize = RoundUp(requested, static_cast<int>(GetPageSize()));
876
+ intptr_t address = 0;
877
+
878
+ // Windows XP SP2 allows Data Excution Prevention (DEP).
879
+ int prot = is_executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
880
+
881
+ // For exectutable pages try and randomize the allocation address
882
+ if (prot == PAGE_EXECUTE_READWRITE &&
883
+ msize >= static_cast<size_t>(Page::kPageSize)) {
884
+ address = (V8::RandomPrivate(Isolate::Current()) << kPageSizeBits)
885
+ | kAllocationRandomAddressMin;
886
+ address &= kAllocationRandomAddressMax;
887
+ }
888
+
889
+ LPVOID mbase = VirtualAlloc(reinterpret_cast<void *>(address),
890
+ msize,
891
+ MEM_COMMIT | MEM_RESERVE,
892
+ prot);
893
+ if (mbase == NULL && address != 0)
894
+ mbase = VirtualAlloc(NULL, msize, MEM_COMMIT | MEM_RESERVE, prot);
895
+
896
+ if (mbase == NULL) {
897
+ LOG(ISOLATE, StringEvent("OS::Allocate", "VirtualAlloc failed"));
898
+ return NULL;
899
+ }
900
+
901
+ ASSERT(IsAligned(reinterpret_cast<size_t>(mbase), OS::AllocateAlignment()));
902
+
903
+ *allocated = msize;
904
+ UpdateAllocatedSpaceLimits(mbase, static_cast<int>(msize));
905
+ return mbase;
906
+ }
907
+
908
+
909
+ void OS::Free(void* address, const size_t size) {
910
+ // TODO(1240712): VirtualFree has a return value which is ignored here.
911
+ VirtualFree(address, 0, MEM_RELEASE);
912
+ USE(size);
913
+ }
914
+
915
+
916
+ #ifdef ENABLE_HEAP_PROTECTION
917
+
918
+ void OS::Protect(void* address, size_t size) {
919
+ // TODO(1240712): VirtualProtect has a return value which is ignored here.
920
+ DWORD old_protect;
921
+ VirtualProtect(address, size, PAGE_READONLY, &old_protect);
922
+ }
923
+
924
+
925
+ void OS::Unprotect(void* address, size_t size, bool is_executable) {
926
+ // TODO(1240712): VirtualProtect has a return value which is ignored here.
927
+ DWORD new_protect = is_executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
928
+ DWORD old_protect;
929
+ VirtualProtect(address, size, new_protect, &old_protect);
930
+ }
931
+
932
+ #endif
933
+
934
+
935
+ void OS::Sleep(int milliseconds) {
936
+ ::Sleep(milliseconds);
937
+ }
938
+
939
+
940
+ void OS::Abort() {
941
+ if (!IsDebuggerPresent()) {
942
+ #ifdef _MSC_VER
943
+ // Make the MSVCRT do a silent abort.
944
+ _set_abort_behavior(0, _WRITE_ABORT_MSG);
945
+ _set_abort_behavior(0, _CALL_REPORTFAULT);
946
+ #endif // _MSC_VER
947
+ abort();
948
+ } else {
949
+ DebugBreak();
950
+ }
951
+ }
952
+
953
+
954
+ void OS::DebugBreak() {
955
+ #ifdef _MSC_VER
956
+ __debugbreak();
957
+ #else
958
+ ::DebugBreak();
959
+ #endif
960
+ }
961
+
962
+
963
+ class Win32MemoryMappedFile : public OS::MemoryMappedFile {
964
+ public:
965
+ Win32MemoryMappedFile(HANDLE file,
966
+ HANDLE file_mapping,
967
+ void* memory,
968
+ int size)
969
+ : file_(file),
970
+ file_mapping_(file_mapping),
971
+ memory_(memory),
972
+ size_(size) { }
973
+ virtual ~Win32MemoryMappedFile();
974
+ virtual void* memory() { return memory_; }
975
+ virtual int size() { return size_; }
976
+ private:
977
+ HANDLE file_;
978
+ HANDLE file_mapping_;
979
+ void* memory_;
980
+ int size_;
981
+ };
982
+
983
+
984
+ OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
985
+ // Open a physical file
986
+ HANDLE file = CreateFileA(name, GENERIC_READ | GENERIC_WRITE,
987
+ FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
988
+ if (file == INVALID_HANDLE_VALUE) return NULL;
989
+
990
+ int size = static_cast<int>(GetFileSize(file, NULL));
991
+
992
+ // Create a file mapping for the physical file
993
+ HANDLE file_mapping = CreateFileMapping(file, NULL,
994
+ PAGE_READWRITE, 0, static_cast<DWORD>(size), NULL);
995
+ if (file_mapping == NULL) return NULL;
996
+
997
+ // Map a view of the file into memory
998
+ void* memory = MapViewOfFile(file_mapping, FILE_MAP_ALL_ACCESS, 0, 0, size);
999
+ return new Win32MemoryMappedFile(file, file_mapping, memory, size);
1000
+ }
1001
+
1002
+
1003
+ OS::MemoryMappedFile* OS::MemoryMappedFile::create(const char* name, int size,
1004
+ void* initial) {
1005
+ // Open a physical file
1006
+ HANDLE file = CreateFileA(name, GENERIC_READ | GENERIC_WRITE,
1007
+ FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, 0, NULL);
1008
+ if (file == NULL) return NULL;
1009
+ // Create a file mapping for the physical file
1010
+ HANDLE file_mapping = CreateFileMapping(file, NULL,
1011
+ PAGE_READWRITE, 0, static_cast<DWORD>(size), NULL);
1012
+ if (file_mapping == NULL) return NULL;
1013
+ // Map a view of the file into memory
1014
+ void* memory = MapViewOfFile(file_mapping, FILE_MAP_ALL_ACCESS, 0, 0, size);
1015
+ if (memory) memmove(memory, initial, size);
1016
+ return new Win32MemoryMappedFile(file, file_mapping, memory, size);
1017
+ }
1018
+
1019
+
1020
+ Win32MemoryMappedFile::~Win32MemoryMappedFile() {
1021
+ if (memory_ != NULL)
1022
+ UnmapViewOfFile(memory_);
1023
+ CloseHandle(file_mapping_);
1024
+ CloseHandle(file_);
1025
+ }
1026
+
1027
+
1028
+ // The following code loads functions defined in DbhHelp.h and TlHelp32.h
1029
+ // dynamically. This is to avoid being depending on dbghelp.dll and
1030
+ // tlhelp32.dll when running (the functions in tlhelp32.dll have been moved to
1031
+ // kernel32.dll at some point so loading functions defines in TlHelp32.h
1032
+ // dynamically might not be necessary any more - for some versions of Windows?).
1033
+
1034
+ // Function pointers to functions dynamically loaded from dbghelp.dll.
1035
+ #define DBGHELP_FUNCTION_LIST(V) \
1036
+ V(SymInitialize) \
1037
+ V(SymGetOptions) \
1038
+ V(SymSetOptions) \
1039
+ V(SymGetSearchPath) \
1040
+ V(SymLoadModule64) \
1041
+ V(StackWalk64) \
1042
+ V(SymGetSymFromAddr64) \
1043
+ V(SymGetLineFromAddr64) \
1044
+ V(SymFunctionTableAccess64) \
1045
+ V(SymGetModuleBase64)
1046
+
1047
+ // Function pointers to functions dynamically loaded from dbghelp.dll.
1048
+ #define TLHELP32_FUNCTION_LIST(V) \
1049
+ V(CreateToolhelp32Snapshot) \
1050
+ V(Module32FirstW) \
1051
+ V(Module32NextW)
1052
+
1053
+ // Define the decoration to use for the type and variable name used for
1054
+ // dynamically loaded DLL function..
1055
+ #define DLL_FUNC_TYPE(name) _##name##_
1056
+ #define DLL_FUNC_VAR(name) _##name
1057
+
1058
+ // Define the type for each dynamically loaded DLL function. The function
1059
+ // definitions are copied from DbgHelp.h and TlHelp32.h. The IN and VOID macros
1060
+ // from the Windows include files are redefined here to have the function
1061
+ // definitions to be as close to the ones in the original .h files as possible.
1062
+ #ifndef IN
1063
+ #define IN
1064
+ #endif
1065
+ #ifndef VOID
1066
+ #define VOID void
1067
+ #endif
1068
+
1069
+ // DbgHelp isn't supported on MinGW yet
1070
+ #ifndef __MINGW32__
1071
+ // DbgHelp.h functions.
1072
+ typedef BOOL (__stdcall *DLL_FUNC_TYPE(SymInitialize))(IN HANDLE hProcess,
1073
+ IN PSTR UserSearchPath,
1074
+ IN BOOL fInvadeProcess);
1075
+ typedef DWORD (__stdcall *DLL_FUNC_TYPE(SymGetOptions))(VOID);
1076
+ typedef DWORD (__stdcall *DLL_FUNC_TYPE(SymSetOptions))(IN DWORD SymOptions);
1077
+ typedef BOOL (__stdcall *DLL_FUNC_TYPE(SymGetSearchPath))(
1078
+ IN HANDLE hProcess,
1079
+ OUT PSTR SearchPath,
1080
+ IN DWORD SearchPathLength);
1081
+ typedef DWORD64 (__stdcall *DLL_FUNC_TYPE(SymLoadModule64))(
1082
+ IN HANDLE hProcess,
1083
+ IN HANDLE hFile,
1084
+ IN PSTR ImageName,
1085
+ IN PSTR ModuleName,
1086
+ IN DWORD64 BaseOfDll,
1087
+ IN DWORD SizeOfDll);
1088
+ typedef BOOL (__stdcall *DLL_FUNC_TYPE(StackWalk64))(
1089
+ DWORD MachineType,
1090
+ HANDLE hProcess,
1091
+ HANDLE hThread,
1092
+ LPSTACKFRAME64 StackFrame,
1093
+ PVOID ContextRecord,
1094
+ PREAD_PROCESS_MEMORY_ROUTINE64 ReadMemoryRoutine,
1095
+ PFUNCTION_TABLE_ACCESS_ROUTINE64 FunctionTableAccessRoutine,
1096
+ PGET_MODULE_BASE_ROUTINE64 GetModuleBaseRoutine,
1097
+ PTRANSLATE_ADDRESS_ROUTINE64 TranslateAddress);
1098
+ typedef BOOL (__stdcall *DLL_FUNC_TYPE(SymGetSymFromAddr64))(
1099
+ IN HANDLE hProcess,
1100
+ IN DWORD64 qwAddr,
1101
+ OUT PDWORD64 pdwDisplacement,
1102
+ OUT PIMAGEHLP_SYMBOL64 Symbol);
1103
+ typedef BOOL (__stdcall *DLL_FUNC_TYPE(SymGetLineFromAddr64))(
1104
+ IN HANDLE hProcess,
1105
+ IN DWORD64 qwAddr,
1106
+ OUT PDWORD pdwDisplacement,
1107
+ OUT PIMAGEHLP_LINE64 Line64);
1108
+ // DbgHelp.h typedefs. Implementation found in dbghelp.dll.
1109
+ typedef PVOID (__stdcall *DLL_FUNC_TYPE(SymFunctionTableAccess64))(
1110
+ HANDLE hProcess,
1111
+ DWORD64 AddrBase); // DbgHelp.h typedef PFUNCTION_TABLE_ACCESS_ROUTINE64
1112
+ typedef DWORD64 (__stdcall *DLL_FUNC_TYPE(SymGetModuleBase64))(
1113
+ HANDLE hProcess,
1114
+ DWORD64 AddrBase); // DbgHelp.h typedef PGET_MODULE_BASE_ROUTINE64
1115
+
1116
+ // TlHelp32.h functions.
1117
+ typedef HANDLE (__stdcall *DLL_FUNC_TYPE(CreateToolhelp32Snapshot))(
1118
+ DWORD dwFlags,
1119
+ DWORD th32ProcessID);
1120
+ typedef BOOL (__stdcall *DLL_FUNC_TYPE(Module32FirstW))(HANDLE hSnapshot,
1121
+ LPMODULEENTRY32W lpme);
1122
+ typedef BOOL (__stdcall *DLL_FUNC_TYPE(Module32NextW))(HANDLE hSnapshot,
1123
+ LPMODULEENTRY32W lpme);
1124
+
1125
+ #undef IN
1126
+ #undef VOID
1127
+
1128
+ // Declare a variable for each dynamically loaded DLL function.
1129
+ #define DEF_DLL_FUNCTION(name) DLL_FUNC_TYPE(name) DLL_FUNC_VAR(name) = NULL;
1130
+ DBGHELP_FUNCTION_LIST(DEF_DLL_FUNCTION)
1131
+ TLHELP32_FUNCTION_LIST(DEF_DLL_FUNCTION)
1132
+ #undef DEF_DLL_FUNCTION
1133
+
1134
+ // Load the functions. This function has a lot of "ugly" macros in order to
1135
+ // keep down code duplication.
1136
+
1137
+ static bool LoadDbgHelpAndTlHelp32() {
1138
+ static bool dbghelp_loaded = false;
1139
+
1140
+ if (dbghelp_loaded) return true;
1141
+
1142
+ HMODULE module;
1143
+
1144
+ // Load functions from the dbghelp.dll module.
1145
+ module = LoadLibrary(TEXT("dbghelp.dll"));
1146
+ if (module == NULL) {
1147
+ return false;
1148
+ }
1149
+
1150
+ #define LOAD_DLL_FUNC(name) \
1151
+ DLL_FUNC_VAR(name) = \
1152
+ reinterpret_cast<DLL_FUNC_TYPE(name)>(GetProcAddress(module, #name));
1153
+
1154
+ DBGHELP_FUNCTION_LIST(LOAD_DLL_FUNC)
1155
+
1156
+ #undef LOAD_DLL_FUNC
1157
+
1158
+ // Load functions from the kernel32.dll module (the TlHelp32.h function used
1159
+ // to be in tlhelp32.dll but are now moved to kernel32.dll).
1160
+ module = LoadLibrary(TEXT("kernel32.dll"));
1161
+ if (module == NULL) {
1162
+ return false;
1163
+ }
1164
+
1165
+ #define LOAD_DLL_FUNC(name) \
1166
+ DLL_FUNC_VAR(name) = \
1167
+ reinterpret_cast<DLL_FUNC_TYPE(name)>(GetProcAddress(module, #name));
1168
+
1169
+ TLHELP32_FUNCTION_LIST(LOAD_DLL_FUNC)
1170
+
1171
+ #undef LOAD_DLL_FUNC
1172
+
1173
+ // Check that all functions where loaded.
1174
+ bool result =
1175
+ #define DLL_FUNC_LOADED(name) (DLL_FUNC_VAR(name) != NULL) &&
1176
+
1177
+ DBGHELP_FUNCTION_LIST(DLL_FUNC_LOADED)
1178
+ TLHELP32_FUNCTION_LIST(DLL_FUNC_LOADED)
1179
+
1180
+ #undef DLL_FUNC_LOADED
1181
+ true;
1182
+
1183
+ dbghelp_loaded = result;
1184
+ return result;
1185
+ // NOTE: The modules are never unloaded and will stay around until the
1186
+ // application is closed.
1187
+ }
1188
+
1189
+
1190
+ // Load the symbols for generating stack traces.
1191
+ static bool LoadSymbols(HANDLE process_handle) {
1192
+ static bool symbols_loaded = false;
1193
+
1194
+ if (symbols_loaded) return true;
1195
+
1196
+ BOOL ok;
1197
+
1198
+ // Initialize the symbol engine.
1199
+ ok = _SymInitialize(process_handle, // hProcess
1200
+ NULL, // UserSearchPath
1201
+ false); // fInvadeProcess
1202
+ if (!ok) return false;
1203
+
1204
+ DWORD options = _SymGetOptions();
1205
+ options |= SYMOPT_LOAD_LINES;
1206
+ options |= SYMOPT_FAIL_CRITICAL_ERRORS;
1207
+ options = _SymSetOptions(options);
1208
+
1209
+ char buf[OS::kStackWalkMaxNameLen] = {0};
1210
+ ok = _SymGetSearchPath(process_handle, buf, OS::kStackWalkMaxNameLen);
1211
+ if (!ok) {
1212
+ int err = GetLastError();
1213
+ PrintF("%d\n", err);
1214
+ return false;
1215
+ }
1216
+
1217
+ HANDLE snapshot = _CreateToolhelp32Snapshot(
1218
+ TH32CS_SNAPMODULE, // dwFlags
1219
+ GetCurrentProcessId()); // th32ProcessId
1220
+ if (snapshot == INVALID_HANDLE_VALUE) return false;
1221
+ MODULEENTRY32W module_entry;
1222
+ module_entry.dwSize = sizeof(module_entry); // Set the size of the structure.
1223
+ BOOL cont = _Module32FirstW(snapshot, &module_entry);
1224
+ while (cont) {
1225
+ DWORD64 base;
1226
+ // NOTE the SymLoadModule64 function has the peculiarity of accepting a
1227
+ // both unicode and ASCII strings even though the parameter is PSTR.
1228
+ base = _SymLoadModule64(
1229
+ process_handle, // hProcess
1230
+ 0, // hFile
1231
+ reinterpret_cast<PSTR>(module_entry.szExePath), // ImageName
1232
+ reinterpret_cast<PSTR>(module_entry.szModule), // ModuleName
1233
+ reinterpret_cast<DWORD64>(module_entry.modBaseAddr), // BaseOfDll
1234
+ module_entry.modBaseSize); // SizeOfDll
1235
+ if (base == 0) {
1236
+ int err = GetLastError();
1237
+ if (err != ERROR_MOD_NOT_FOUND &&
1238
+ err != ERROR_INVALID_HANDLE) return false;
1239
+ }
1240
+ LOG(i::Isolate::Current(),
1241
+ SharedLibraryEvent(
1242
+ module_entry.szExePath,
1243
+ reinterpret_cast<unsigned int>(module_entry.modBaseAddr),
1244
+ reinterpret_cast<unsigned int>(module_entry.modBaseAddr +
1245
+ module_entry.modBaseSize)));
1246
+ cont = _Module32NextW(snapshot, &module_entry);
1247
+ }
1248
+ CloseHandle(snapshot);
1249
+
1250
+ symbols_loaded = true;
1251
+ return true;
1252
+ }
1253
+
1254
+
1255
+ void OS::LogSharedLibraryAddresses() {
1256
+ // SharedLibraryEvents are logged when loading symbol information.
1257
+ // Only the shared libraries loaded at the time of the call to
1258
+ // LogSharedLibraryAddresses are logged. DLLs loaded after
1259
+ // initialization are not accounted for.
1260
+ if (!LoadDbgHelpAndTlHelp32()) return;
1261
+ HANDLE process_handle = GetCurrentProcess();
1262
+ LoadSymbols(process_handle);
1263
+ }
1264
+
1265
+
1266
+ void OS::SignalCodeMovingGC() {
1267
+ }
1268
+
1269
+
1270
+ // Walk the stack using the facilities in dbghelp.dll and tlhelp32.dll
1271
+
1272
+ // Switch off warning 4748 (/GS can not protect parameters and local variables
1273
+ // from local buffer overrun because optimizations are disabled in function) as
1274
+ // it is triggered by the use of inline assembler.
1275
+ #pragma warning(push)
1276
+ #pragma warning(disable : 4748)
1277
+ int OS::StackWalk(Vector<OS::StackFrame> frames) {
1278
+ BOOL ok;
1279
+
1280
+ // Load the required functions from DLL's.
1281
+ if (!LoadDbgHelpAndTlHelp32()) return kStackWalkError;
1282
+
1283
+ // Get the process and thread handles.
1284
+ HANDLE process_handle = GetCurrentProcess();
1285
+ HANDLE thread_handle = GetCurrentThread();
1286
+
1287
+ // Read the symbols.
1288
+ if (!LoadSymbols(process_handle)) return kStackWalkError;
1289
+
1290
+ // Capture current context.
1291
+ CONTEXT context;
1292
+ RtlCaptureContext(&context);
1293
+
1294
+ // Initialize the stack walking
1295
+ STACKFRAME64 stack_frame;
1296
+ memset(&stack_frame, 0, sizeof(stack_frame));
1297
+ #ifdef _WIN64
1298
+ stack_frame.AddrPC.Offset = context.Rip;
1299
+ stack_frame.AddrFrame.Offset = context.Rbp;
1300
+ stack_frame.AddrStack.Offset = context.Rsp;
1301
+ #else
1302
+ stack_frame.AddrPC.Offset = context.Eip;
1303
+ stack_frame.AddrFrame.Offset = context.Ebp;
1304
+ stack_frame.AddrStack.Offset = context.Esp;
1305
+ #endif
1306
+ stack_frame.AddrPC.Mode = AddrModeFlat;
1307
+ stack_frame.AddrFrame.Mode = AddrModeFlat;
1308
+ stack_frame.AddrStack.Mode = AddrModeFlat;
1309
+ int frames_count = 0;
1310
+
1311
+ // Collect stack frames.
1312
+ int frames_size = frames.length();
1313
+ while (frames_count < frames_size) {
1314
+ ok = _StackWalk64(
1315
+ IMAGE_FILE_MACHINE_I386, // MachineType
1316
+ process_handle, // hProcess
1317
+ thread_handle, // hThread
1318
+ &stack_frame, // StackFrame
1319
+ &context, // ContextRecord
1320
+ NULL, // ReadMemoryRoutine
1321
+ _SymFunctionTableAccess64, // FunctionTableAccessRoutine
1322
+ _SymGetModuleBase64, // GetModuleBaseRoutine
1323
+ NULL); // TranslateAddress
1324
+ if (!ok) break;
1325
+
1326
+ // Store the address.
1327
+ ASSERT((stack_frame.AddrPC.Offset >> 32) == 0); // 32-bit address.
1328
+ frames[frames_count].address =
1329
+ reinterpret_cast<void*>(stack_frame.AddrPC.Offset);
1330
+
1331
+ // Try to locate a symbol for this frame.
1332
+ DWORD64 symbol_displacement;
1333
+ SmartPointer<IMAGEHLP_SYMBOL64> symbol(
1334
+ NewArray<IMAGEHLP_SYMBOL64>(kStackWalkMaxNameLen));
1335
+ if (symbol.is_empty()) return kStackWalkError; // Out of memory.
1336
+ memset(*symbol, 0, sizeof(IMAGEHLP_SYMBOL64) + kStackWalkMaxNameLen);
1337
+ (*symbol)->SizeOfStruct = sizeof(IMAGEHLP_SYMBOL64);
1338
+ (*symbol)->MaxNameLength = kStackWalkMaxNameLen;
1339
+ ok = _SymGetSymFromAddr64(process_handle, // hProcess
1340
+ stack_frame.AddrPC.Offset, // Address
1341
+ &symbol_displacement, // Displacement
1342
+ *symbol); // Symbol
1343
+ if (ok) {
1344
+ // Try to locate more source information for the symbol.
1345
+ IMAGEHLP_LINE64 Line;
1346
+ memset(&Line, 0, sizeof(Line));
1347
+ Line.SizeOfStruct = sizeof(Line);
1348
+ DWORD line_displacement;
1349
+ ok = _SymGetLineFromAddr64(
1350
+ process_handle, // hProcess
1351
+ stack_frame.AddrPC.Offset, // dwAddr
1352
+ &line_displacement, // pdwDisplacement
1353
+ &Line); // Line
1354
+ // Format a text representation of the frame based on the information
1355
+ // available.
1356
+ if (ok) {
1357
+ SNPrintF(MutableCStrVector(frames[frames_count].text,
1358
+ kStackWalkMaxTextLen),
1359
+ "%s %s:%d:%d",
1360
+ (*symbol)->Name, Line.FileName, Line.LineNumber,
1361
+ line_displacement);
1362
+ } else {
1363
+ SNPrintF(MutableCStrVector(frames[frames_count].text,
1364
+ kStackWalkMaxTextLen),
1365
+ "%s",
1366
+ (*symbol)->Name);
1367
+ }
1368
+ // Make sure line termination is in place.
1369
+ frames[frames_count].text[kStackWalkMaxTextLen - 1] = '\0';
1370
+ } else {
1371
+ // No text representation of this frame
1372
+ frames[frames_count].text[0] = '\0';
1373
+
1374
+ // Continue if we are just missing a module (for non C/C++ frames a
1375
+ // module will never be found).
1376
+ int err = GetLastError();
1377
+ if (err != ERROR_MOD_NOT_FOUND) {
1378
+ break;
1379
+ }
1380
+ }
1381
+
1382
+ frames_count++;
1383
+ }
1384
+
1385
+ // Return the number of frames filled in.
1386
+ return frames_count;
1387
+ }
1388
+
1389
+ // Restore warnings to previous settings.
1390
+ #pragma warning(pop)
1391
+
1392
+ #else // __MINGW32__
1393
+ void OS::LogSharedLibraryAddresses() { }
1394
+ void OS::SignalCodeMovingGC() { }
1395
+ int OS::StackWalk(Vector<OS::StackFrame> frames) { return 0; }
1396
+ #endif // __MINGW32__
1397
+
1398
+
1399
+ uint64_t OS::CpuFeaturesImpliedByPlatform() {
1400
+ return 0; // Windows runs on anything.
1401
+ }
1402
+
1403
+
1404
+ double OS::nan_value() {
1405
+ #ifdef _MSC_VER
1406
+ // Positive Quiet NaN with no payload (aka. Indeterminate) has all bits
1407
+ // in mask set, so value equals mask.
1408
+ static const __int64 nanval = kQuietNaNMask;
1409
+ return *reinterpret_cast<const double*>(&nanval);
1410
+ #else // _MSC_VER
1411
+ return NAN;
1412
+ #endif // _MSC_VER
1413
+ }
1414
+
1415
+
1416
+ int OS::ActivationFrameAlignment() {
1417
+ #ifdef _WIN64
1418
+ return 16; // Windows 64-bit ABI requires the stack to be 16-byte aligned.
1419
+ #else
1420
+ return 8; // Floating-point math runs faster with 8-byte alignment.
1421
+ #endif
1422
+ }
1423
+
1424
+
1425
+ void OS::ReleaseStore(volatile AtomicWord* ptr, AtomicWord value) {
1426
+ MemoryBarrier();
1427
+ *ptr = value;
1428
+ }
1429
+
1430
+
1431
+ bool VirtualMemory::IsReserved() {
1432
+ return address_ != NULL;
1433
+ }
1434
+
1435
+
1436
+ VirtualMemory::VirtualMemory(size_t size) {
1437
+ address_ = VirtualAlloc(NULL, size, MEM_RESERVE, PAGE_NOACCESS);
1438
+ size_ = size;
1439
+ }
1440
+
1441
+
1442
+ VirtualMemory::~VirtualMemory() {
1443
+ if (IsReserved()) {
1444
+ if (0 == VirtualFree(address(), 0, MEM_RELEASE)) address_ = NULL;
1445
+ }
1446
+ }
1447
+
1448
+
1449
+ bool VirtualMemory::Commit(void* address, size_t size, bool is_executable) {
1450
+ int prot = is_executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
1451
+ if (NULL == VirtualAlloc(address, size, MEM_COMMIT, prot)) {
1452
+ return false;
1453
+ }
1454
+
1455
+ UpdateAllocatedSpaceLimits(address, static_cast<int>(size));
1456
+ return true;
1457
+ }
1458
+
1459
+
1460
+ bool VirtualMemory::Uncommit(void* address, size_t size) {
1461
+ ASSERT(IsReserved());
1462
+ return VirtualFree(address, size, MEM_DECOMMIT) != false;
1463
+ }
1464
+
1465
+
1466
+ // ----------------------------------------------------------------------------
1467
+ // Win32 thread support.
1468
+
1469
+ // Definition of invalid thread handle and id.
1470
+ static const HANDLE kNoThread = INVALID_HANDLE_VALUE;
1471
+ static const DWORD kNoThreadId = 0;
1472
+
1473
+
1474
+ class ThreadHandle::PlatformData : public Malloced {
1475
+ public:
1476
+ explicit PlatformData(ThreadHandle::Kind kind) {
1477
+ Initialize(kind);
1478
+ }
1479
+
1480
+ void Initialize(ThreadHandle::Kind kind) {
1481
+ switch (kind) {
1482
+ case ThreadHandle::SELF: tid_ = GetCurrentThreadId(); break;
1483
+ case ThreadHandle::INVALID: tid_ = kNoThreadId; break;
1484
+ }
1485
+ }
1486
+ DWORD tid_; // Win32 thread identifier.
1487
+ };
1488
+
1489
+
1490
+ // Entry point for threads. The supplied argument is a pointer to the thread
1491
+ // object. The entry function dispatches to the run method in the thread
1492
+ // object. It is important that this function has __stdcall calling
1493
+ // convention.
1494
+ static unsigned int __stdcall ThreadEntry(void* arg) {
1495
+ Thread* thread = reinterpret_cast<Thread*>(arg);
1496
+ // This is also initialized by the last parameter to _beginthreadex() but we
1497
+ // don't know which thread will run first (the original thread or the new
1498
+ // one) so we initialize it here too.
1499
+ thread->thread_handle_data()->tid_ = GetCurrentThreadId();
1500
+ Thread::SetThreadLocal(Isolate::isolate_key(), thread->isolate());
1501
+ thread->Run();
1502
+ return 0;
1503
+ }
1504
+
1505
+
1506
+ // Initialize thread handle to invalid handle.
1507
+ ThreadHandle::ThreadHandle(ThreadHandle::Kind kind) {
1508
+ data_ = new PlatformData(kind);
1509
+ }
1510
+
1511
+
1512
+ ThreadHandle::~ThreadHandle() {
1513
+ delete data_;
1514
+ }
1515
+
1516
+
1517
+ // The thread is running if it has the same id as the current thread.
1518
+ bool ThreadHandle::IsSelf() const {
1519
+ return GetCurrentThreadId() == data_->tid_;
1520
+ }
1521
+
1522
+
1523
+ // Test for invalid thread handle.
1524
+ bool ThreadHandle::IsValid() const {
1525
+ return data_->tid_ != kNoThreadId;
1526
+ }
1527
+
1528
+
1529
+ void ThreadHandle::Initialize(ThreadHandle::Kind kind) {
1530
+ data_->Initialize(kind);
1531
+ }
1532
+
1533
+
1534
+ class Thread::PlatformData : public Malloced {
1535
+ public:
1536
+ explicit PlatformData(HANDLE thread) : thread_(thread) {}
1537
+ HANDLE thread_;
1538
+ };
1539
+
1540
+
1541
+ // Initialize a Win32 thread object. The thread has an invalid thread
1542
+ // handle until it is started.
1543
+
1544
+ Thread::Thread(Isolate* isolate, const Options& options)
1545
+ : ThreadHandle(ThreadHandle::INVALID),
1546
+ isolate_(isolate),
1547
+ stack_size_(options.stack_size) {
1548
+ data_ = new PlatformData(kNoThread);
1549
+ set_name(options.name);
1550
+ }
1551
+
1552
+
1553
+ Thread::Thread(Isolate* isolate, const char* name)
1554
+ : ThreadHandle(ThreadHandle::INVALID),
1555
+ isolate_(isolate),
1556
+ stack_size_(0) {
1557
+ data_ = new PlatformData(kNoThread);
1558
+ set_name(name);
1559
+ }
1560
+
1561
+
1562
+ void Thread::set_name(const char* name) {
1563
+ OS::StrNCpy(Vector<char>(name_, sizeof(name_)), name, strlen(name));
1564
+ name_[sizeof(name_) - 1] = '\0';
1565
+ }
1566
+
1567
+
1568
+ // Close our own handle for the thread.
1569
+ Thread::~Thread() {
1570
+ if (data_->thread_ != kNoThread) CloseHandle(data_->thread_);
1571
+ delete data_;
1572
+ }
1573
+
1574
+
1575
+ // Create a new thread. It is important to use _beginthreadex() instead of
1576
+ // the Win32 function CreateThread(), because the CreateThread() does not
1577
+ // initialize thread specific structures in the C runtime library.
1578
+ void Thread::Start() {
1579
+ data_->thread_ = reinterpret_cast<HANDLE>(
1580
+ _beginthreadex(NULL,
1581
+ static_cast<unsigned>(stack_size_),
1582
+ ThreadEntry,
1583
+ this,
1584
+ 0,
1585
+ reinterpret_cast<unsigned int*>(
1586
+ &thread_handle_data()->tid_)));
1587
+ ASSERT(IsValid());
1588
+ }
1589
+
1590
+
1591
+ // Wait for thread to terminate.
1592
+ void Thread::Join() {
1593
+ WaitForSingleObject(data_->thread_, INFINITE);
1594
+ }
1595
+
1596
+
1597
+ Thread::LocalStorageKey Thread::CreateThreadLocalKey() {
1598
+ DWORD result = TlsAlloc();
1599
+ ASSERT(result != TLS_OUT_OF_INDEXES);
1600
+ return static_cast<LocalStorageKey>(result);
1601
+ }
1602
+
1603
+
1604
+ void Thread::DeleteThreadLocalKey(LocalStorageKey key) {
1605
+ BOOL result = TlsFree(static_cast<DWORD>(key));
1606
+ USE(result);
1607
+ ASSERT(result);
1608
+ }
1609
+
1610
+
1611
+ void* Thread::GetThreadLocal(LocalStorageKey key) {
1612
+ return TlsGetValue(static_cast<DWORD>(key));
1613
+ }
1614
+
1615
+
1616
+ void Thread::SetThreadLocal(LocalStorageKey key, void* value) {
1617
+ BOOL result = TlsSetValue(static_cast<DWORD>(key), value);
1618
+ USE(result);
1619
+ ASSERT(result);
1620
+ }
1621
+
1622
+
1623
+
1624
+ void Thread::YieldCPU() {
1625
+ Sleep(0);
1626
+ }
1627
+
1628
+
1629
+ // ----------------------------------------------------------------------------
1630
+ // Win32 mutex support.
1631
+ //
1632
+ // On Win32 mutexes are implemented using CRITICAL_SECTION objects. These are
1633
+ // faster than Win32 Mutex objects because they are implemented using user mode
1634
+ // atomic instructions. Therefore we only do ring transitions if there is lock
1635
+ // contention.
1636
+
1637
+ class Win32Mutex : public Mutex {
1638
+ public:
1639
+
1640
+ Win32Mutex() { InitializeCriticalSection(&cs_); }
1641
+
1642
+ virtual ~Win32Mutex() { DeleteCriticalSection(&cs_); }
1643
+
1644
+ virtual int Lock() {
1645
+ EnterCriticalSection(&cs_);
1646
+ return 0;
1647
+ }
1648
+
1649
+ virtual int Unlock() {
1650
+ LeaveCriticalSection(&cs_);
1651
+ return 0;
1652
+ }
1653
+
1654
+
1655
+ virtual bool TryLock() {
1656
+ // Returns non-zero if critical section is entered successfully entered.
1657
+ return TryEnterCriticalSection(&cs_);
1658
+ }
1659
+
1660
+ private:
1661
+ CRITICAL_SECTION cs_; // Critical section used for mutex
1662
+ };
1663
+
1664
+
1665
+ Mutex* OS::CreateMutex() {
1666
+ return new Win32Mutex();
1667
+ }
1668
+
1669
+
1670
+ // ----------------------------------------------------------------------------
1671
+ // Win32 semaphore support.
1672
+ //
1673
+ // On Win32 semaphores are implemented using Win32 Semaphore objects. The
1674
+ // semaphores are anonymous. Also, the semaphores are initialized to have
1675
+ // no upper limit on count.
1676
+
1677
+
1678
+ class Win32Semaphore : public Semaphore {
1679
+ public:
1680
+ explicit Win32Semaphore(int count) {
1681
+ sem = ::CreateSemaphoreA(NULL, count, 0x7fffffff, NULL);
1682
+ }
1683
+
1684
+ ~Win32Semaphore() {
1685
+ CloseHandle(sem);
1686
+ }
1687
+
1688
+ void Wait() {
1689
+ WaitForSingleObject(sem, INFINITE);
1690
+ }
1691
+
1692
+ bool Wait(int timeout) {
1693
+ // Timeout in Windows API is in milliseconds.
1694
+ DWORD millis_timeout = timeout / 1000;
1695
+ return WaitForSingleObject(sem, millis_timeout) != WAIT_TIMEOUT;
1696
+ }
1697
+
1698
+ void Signal() {
1699
+ LONG dummy;
1700
+ ReleaseSemaphore(sem, 1, &dummy);
1701
+ }
1702
+
1703
+ private:
1704
+ HANDLE sem;
1705
+ };
1706
+
1707
+
1708
+ Semaphore* OS::CreateSemaphore(int count) {
1709
+ return new Win32Semaphore(count);
1710
+ }
1711
+
1712
+
1713
+ // ----------------------------------------------------------------------------
1714
+ // Win32 socket support.
1715
+ //
1716
+
1717
+ class Win32Socket : public Socket {
1718
+ public:
1719
+ explicit Win32Socket() {
1720
+ // Create the socket.
1721
+ socket_ = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
1722
+ }
1723
+ explicit Win32Socket(SOCKET socket): socket_(socket) { }
1724
+ virtual ~Win32Socket() { Shutdown(); }
1725
+
1726
+ // Server initialization.
1727
+ bool Bind(const int port);
1728
+ bool Listen(int backlog) const;
1729
+ Socket* Accept() const;
1730
+
1731
+ // Client initialization.
1732
+ bool Connect(const char* host, const char* port);
1733
+
1734
+ // Shutdown socket for both read and write.
1735
+ bool Shutdown();
1736
+
1737
+ // Data Transimission
1738
+ int Send(const char* data, int len) const;
1739
+ int Receive(char* data, int len) const;
1740
+
1741
+ bool SetReuseAddress(bool reuse_address);
1742
+
1743
+ bool IsValid() const { return socket_ != INVALID_SOCKET; }
1744
+
1745
+ private:
1746
+ SOCKET socket_;
1747
+ };
1748
+
1749
+
1750
+ bool Win32Socket::Bind(const int port) {
1751
+ if (!IsValid()) {
1752
+ return false;
1753
+ }
1754
+
1755
+ sockaddr_in addr;
1756
+ memset(&addr, 0, sizeof(addr));
1757
+ addr.sin_family = AF_INET;
1758
+ addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
1759
+ addr.sin_port = htons(port);
1760
+ int status = bind(socket_,
1761
+ reinterpret_cast<struct sockaddr *>(&addr),
1762
+ sizeof(addr));
1763
+ return status == 0;
1764
+ }
1765
+
1766
+
1767
+ bool Win32Socket::Listen(int backlog) const {
1768
+ if (!IsValid()) {
1769
+ return false;
1770
+ }
1771
+
1772
+ int status = listen(socket_, backlog);
1773
+ return status == 0;
1774
+ }
1775
+
1776
+
1777
+ Socket* Win32Socket::Accept() const {
1778
+ if (!IsValid()) {
1779
+ return NULL;
1780
+ }
1781
+
1782
+ SOCKET socket = accept(socket_, NULL, NULL);
1783
+ if (socket == INVALID_SOCKET) {
1784
+ return NULL;
1785
+ } else {
1786
+ return new Win32Socket(socket);
1787
+ }
1788
+ }
1789
+
1790
+
1791
+ bool Win32Socket::Connect(const char* host, const char* port) {
1792
+ if (!IsValid()) {
1793
+ return false;
1794
+ }
1795
+
1796
+ // Lookup host and port.
1797
+ struct addrinfo *result = NULL;
1798
+ struct addrinfo hints;
1799
+ memset(&hints, 0, sizeof(addrinfo));
1800
+ hints.ai_family = AF_INET;
1801
+ hints.ai_socktype = SOCK_STREAM;
1802
+ hints.ai_protocol = IPPROTO_TCP;
1803
+ int status = getaddrinfo(host, port, &hints, &result);
1804
+ if (status != 0) {
1805
+ return false;
1806
+ }
1807
+
1808
+ // Connect.
1809
+ status = connect(socket_,
1810
+ result->ai_addr,
1811
+ static_cast<int>(result->ai_addrlen));
1812
+ freeaddrinfo(result);
1813
+ return status == 0;
1814
+ }
1815
+
1816
+
1817
+ bool Win32Socket::Shutdown() {
1818
+ if (IsValid()) {
1819
+ // Shutdown socket for both read and write.
1820
+ int status = shutdown(socket_, SD_BOTH);
1821
+ closesocket(socket_);
1822
+ socket_ = INVALID_SOCKET;
1823
+ return status == SOCKET_ERROR;
1824
+ }
1825
+ return true;
1826
+ }
1827
+
1828
+
1829
+ int Win32Socket::Send(const char* data, int len) const {
1830
+ int status = send(socket_, data, len, 0);
1831
+ return status;
1832
+ }
1833
+
1834
+
1835
+ int Win32Socket::Receive(char* data, int len) const {
1836
+ int status = recv(socket_, data, len, 0);
1837
+ return status;
1838
+ }
1839
+
1840
+
1841
+ bool Win32Socket::SetReuseAddress(bool reuse_address) {
1842
+ BOOL on = reuse_address ? true : false;
1843
+ int status = setsockopt(socket_, SOL_SOCKET, SO_REUSEADDR,
1844
+ reinterpret_cast<char*>(&on), sizeof(on));
1845
+ return status == SOCKET_ERROR;
1846
+ }
1847
+
1848
+
1849
+ bool Socket::Setup() {
1850
+ // Initialize Winsock32
1851
+ int err;
1852
+ WSADATA winsock_data;
1853
+ WORD version_requested = MAKEWORD(1, 0);
1854
+ err = WSAStartup(version_requested, &winsock_data);
1855
+ if (err != 0) {
1856
+ PrintF("Unable to initialize Winsock, err = %d\n", Socket::LastError());
1857
+ }
1858
+
1859
+ return err == 0;
1860
+ }
1861
+
1862
+
1863
+ int Socket::LastError() {
1864
+ return WSAGetLastError();
1865
+ }
1866
+
1867
+
1868
+ uint16_t Socket::HToN(uint16_t value) {
1869
+ return htons(value);
1870
+ }
1871
+
1872
+
1873
+ uint16_t Socket::NToH(uint16_t value) {
1874
+ return ntohs(value);
1875
+ }
1876
+
1877
+
1878
+ uint32_t Socket::HToN(uint32_t value) {
1879
+ return htonl(value);
1880
+ }
1881
+
1882
+
1883
+ uint32_t Socket::NToH(uint32_t value) {
1884
+ return ntohl(value);
1885
+ }
1886
+
1887
+
1888
+ Socket* OS::CreateSocket() {
1889
+ return new Win32Socket();
1890
+ }
1891
+
1892
+
1893
+ #ifdef ENABLE_LOGGING_AND_PROFILING
1894
+
1895
+ // ----------------------------------------------------------------------------
1896
+ // Win32 profiler support.
1897
+
1898
+ class Sampler::PlatformData : public Malloced {
1899
+ public:
1900
+ // Get a handle to the calling thread. This is the thread that we are
1901
+ // going to profile. We need to make a copy of the handle because we are
1902
+ // going to use it in the sampler thread. Using GetThreadHandle() will
1903
+ // not work in this case. We're using OpenThread because DuplicateHandle
1904
+ // for some reason doesn't work in Chrome's sandbox.
1905
+ PlatformData() : profiled_thread_(OpenThread(THREAD_GET_CONTEXT |
1906
+ THREAD_SUSPEND_RESUME |
1907
+ THREAD_QUERY_INFORMATION,
1908
+ false,
1909
+ GetCurrentThreadId())) {}
1910
+
1911
+ ~PlatformData() {
1912
+ if (profiled_thread_ != NULL) {
1913
+ CloseHandle(profiled_thread_);
1914
+ profiled_thread_ = NULL;
1915
+ }
1916
+ }
1917
+
1918
+ HANDLE profiled_thread() { return profiled_thread_; }
1919
+
1920
+ private:
1921
+ HANDLE profiled_thread_;
1922
+ };
1923
+
1924
+
1925
+ class SamplerThread : public Thread {
1926
+ public:
1927
+ explicit SamplerThread(int interval)
1928
+ : Thread(NULL, "SamplerThread"),
1929
+ interval_(interval) {}
1930
+
1931
+ static void AddActiveSampler(Sampler* sampler) {
1932
+ ScopedLock lock(mutex_);
1933
+ SamplerRegistry::AddActiveSampler(sampler);
1934
+ if (instance_ == NULL) {
1935
+ instance_ = new SamplerThread(sampler->interval());
1936
+ instance_->Start();
1937
+ } else {
1938
+ ASSERT(instance_->interval_ == sampler->interval());
1939
+ }
1940
+ }
1941
+
1942
+ static void RemoveActiveSampler(Sampler* sampler) {
1943
+ ScopedLock lock(mutex_);
1944
+ SamplerRegistry::RemoveActiveSampler(sampler);
1945
+ if (SamplerRegistry::GetState() == SamplerRegistry::HAS_NO_SAMPLERS) {
1946
+ RuntimeProfiler::WakeUpRuntimeProfilerThreadBeforeShutdown();
1947
+ instance_->Join();
1948
+ delete instance_;
1949
+ instance_ = NULL;
1950
+ }
1951
+ }
1952
+
1953
+ // Implement Thread::Run().
1954
+ virtual void Run() {
1955
+ SamplerRegistry::State state;
1956
+ while ((state = SamplerRegistry::GetState()) !=
1957
+ SamplerRegistry::HAS_NO_SAMPLERS) {
1958
+ bool cpu_profiling_enabled =
1959
+ (state == SamplerRegistry::HAS_CPU_PROFILING_SAMPLERS);
1960
+ bool runtime_profiler_enabled = RuntimeProfiler::IsEnabled();
1961
+ // When CPU profiling is enabled both JavaScript and C++ code is
1962
+ // profiled. We must not suspend.
1963
+ if (!cpu_profiling_enabled) {
1964
+ if (rate_limiter_.SuspendIfNecessary()) continue;
1965
+ }
1966
+ if (cpu_profiling_enabled) {
1967
+ if (!SamplerRegistry::IterateActiveSamplers(&DoCpuProfile, this)) {
1968
+ return;
1969
+ }
1970
+ }
1971
+ if (runtime_profiler_enabled) {
1972
+ if (!SamplerRegistry::IterateActiveSamplers(&DoRuntimeProfile, NULL)) {
1973
+ return;
1974
+ }
1975
+ }
1976
+ OS::Sleep(interval_);
1977
+ }
1978
+ }
1979
+
1980
+ static void DoCpuProfile(Sampler* sampler, void* raw_sampler_thread) {
1981
+ if (!sampler->isolate()->IsInitialized()) return;
1982
+ if (!sampler->IsProfiling()) return;
1983
+ SamplerThread* sampler_thread =
1984
+ reinterpret_cast<SamplerThread*>(raw_sampler_thread);
1985
+ sampler_thread->SampleContext(sampler);
1986
+ }
1987
+
1988
+ static void DoRuntimeProfile(Sampler* sampler, void* ignored) {
1989
+ if (!sampler->isolate()->IsInitialized()) return;
1990
+ sampler->isolate()->runtime_profiler()->NotifyTick();
1991
+ }
1992
+
1993
+ void SampleContext(Sampler* sampler) {
1994
+ HANDLE profiled_thread = sampler->platform_data()->profiled_thread();
1995
+ if (profiled_thread == NULL) return;
1996
+
1997
+ // Context used for sampling the register state of the profiled thread.
1998
+ CONTEXT context;
1999
+ memset(&context, 0, sizeof(context));
2000
+
2001
+ TickSample sample_obj;
2002
+ TickSample* sample = CpuProfiler::TickSampleEvent(sampler->isolate());
2003
+ if (sample == NULL) sample = &sample_obj;
2004
+
2005
+ static const DWORD kSuspendFailed = static_cast<DWORD>(-1);
2006
+ if (SuspendThread(profiled_thread) == kSuspendFailed) return;
2007
+ sample->state = sampler->isolate()->current_vm_state();
2008
+
2009
+ context.ContextFlags = CONTEXT_FULL;
2010
+ if (GetThreadContext(profiled_thread, &context) != 0) {
2011
+ #if V8_HOST_ARCH_X64
2012
+ sample->pc = reinterpret_cast<Address>(context.Rip);
2013
+ sample->sp = reinterpret_cast<Address>(context.Rsp);
2014
+ sample->fp = reinterpret_cast<Address>(context.Rbp);
2015
+ #else
2016
+ sample->pc = reinterpret_cast<Address>(context.Eip);
2017
+ sample->sp = reinterpret_cast<Address>(context.Esp);
2018
+ sample->fp = reinterpret_cast<Address>(context.Ebp);
2019
+ #endif
2020
+ sampler->SampleStack(sample);
2021
+ sampler->Tick(sample);
2022
+ }
2023
+ ResumeThread(profiled_thread);
2024
+ }
2025
+
2026
+ const int interval_;
2027
+ RuntimeProfilerRateLimiter rate_limiter_;
2028
+
2029
+ // Protects the process wide state below.
2030
+ static Mutex* mutex_;
2031
+ static SamplerThread* instance_;
2032
+
2033
+ DISALLOW_COPY_AND_ASSIGN(SamplerThread);
2034
+ };
2035
+
2036
+
2037
+ Mutex* SamplerThread::mutex_ = OS::CreateMutex();
2038
+ SamplerThread* SamplerThread::instance_ = NULL;
2039
+
2040
+
2041
+ Sampler::Sampler(Isolate* isolate, int interval)
2042
+ : isolate_(isolate),
2043
+ interval_(interval),
2044
+ profiling_(false),
2045
+ active_(false),
2046
+ samples_taken_(0) {
2047
+ data_ = new PlatformData;
2048
+ }
2049
+
2050
+
2051
+ Sampler::~Sampler() {
2052
+ ASSERT(!IsActive());
2053
+ delete data_;
2054
+ }
2055
+
2056
+
2057
+ void Sampler::Start() {
2058
+ ASSERT(!IsActive());
2059
+ SetActive(true);
2060
+ SamplerThread::AddActiveSampler(this);
2061
+ }
2062
+
2063
+
2064
+ void Sampler::Stop() {
2065
+ ASSERT(IsActive());
2066
+ SamplerThread::RemoveActiveSampler(this);
2067
+ SetActive(false);
2068
+ }
2069
+
2070
+ #endif // ENABLE_LOGGING_AND_PROFILING
2071
+
2072
+ } } // namespace v8::internal