libv8-sgonyea 3.3.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (500) hide show
  1. data/.gitignore +8 -0
  2. data/.gitmodules +3 -0
  3. data/Gemfile +4 -0
  4. data/README.md +76 -0
  5. data/Rakefile +113 -0
  6. data/ext/libv8/extconf.rb +28 -0
  7. data/lib/libv8.rb +15 -0
  8. data/lib/libv8/Makefile +30 -0
  9. data/lib/libv8/detect_cpu.rb +27 -0
  10. data/lib/libv8/fpic-on-linux-amd64.patch +13 -0
  11. data/lib/libv8/v8/.gitignore +35 -0
  12. data/lib/libv8/v8/AUTHORS +44 -0
  13. data/lib/libv8/v8/ChangeLog +2839 -0
  14. data/lib/libv8/v8/LICENSE +52 -0
  15. data/lib/libv8/v8/LICENSE.strongtalk +29 -0
  16. data/lib/libv8/v8/LICENSE.v8 +26 -0
  17. data/lib/libv8/v8/LICENSE.valgrind +45 -0
  18. data/lib/libv8/v8/SConstruct +1478 -0
  19. data/lib/libv8/v8/build/README.txt +49 -0
  20. data/lib/libv8/v8/build/all.gyp +18 -0
  21. data/lib/libv8/v8/build/armu.gypi +32 -0
  22. data/lib/libv8/v8/build/common.gypi +144 -0
  23. data/lib/libv8/v8/build/gyp_v8 +145 -0
  24. data/lib/libv8/v8/include/v8-debug.h +395 -0
  25. data/lib/libv8/v8/include/v8-preparser.h +117 -0
  26. data/lib/libv8/v8/include/v8-profiler.h +505 -0
  27. data/lib/libv8/v8/include/v8-testing.h +104 -0
  28. data/lib/libv8/v8/include/v8.h +4124 -0
  29. data/lib/libv8/v8/include/v8stdint.h +53 -0
  30. data/lib/libv8/v8/preparser/SConscript +38 -0
  31. data/lib/libv8/v8/preparser/preparser-process.cc +379 -0
  32. data/lib/libv8/v8/src/SConscript +368 -0
  33. data/lib/libv8/v8/src/accessors.cc +767 -0
  34. data/lib/libv8/v8/src/accessors.h +123 -0
  35. data/lib/libv8/v8/src/allocation-inl.h +49 -0
  36. data/lib/libv8/v8/src/allocation.cc +122 -0
  37. data/lib/libv8/v8/src/allocation.h +143 -0
  38. data/lib/libv8/v8/src/api.cc +5845 -0
  39. data/lib/libv8/v8/src/api.h +574 -0
  40. data/lib/libv8/v8/src/apinatives.js +110 -0
  41. data/lib/libv8/v8/src/apiutils.h +73 -0
  42. data/lib/libv8/v8/src/arguments.h +118 -0
  43. data/lib/libv8/v8/src/arm/assembler-arm-inl.h +353 -0
  44. data/lib/libv8/v8/src/arm/assembler-arm.cc +2661 -0
  45. data/lib/libv8/v8/src/arm/assembler-arm.h +1375 -0
  46. data/lib/libv8/v8/src/arm/builtins-arm.cc +1658 -0
  47. data/lib/libv8/v8/src/arm/code-stubs-arm.cc +6398 -0
  48. data/lib/libv8/v8/src/arm/code-stubs-arm.h +673 -0
  49. data/lib/libv8/v8/src/arm/codegen-arm.cc +52 -0
  50. data/lib/libv8/v8/src/arm/codegen-arm.h +91 -0
  51. data/lib/libv8/v8/src/arm/constants-arm.cc +152 -0
  52. data/lib/libv8/v8/src/arm/constants-arm.h +775 -0
  53. data/lib/libv8/v8/src/arm/cpu-arm.cc +120 -0
  54. data/lib/libv8/v8/src/arm/debug-arm.cc +317 -0
  55. data/lib/libv8/v8/src/arm/deoptimizer-arm.cc +754 -0
  56. data/lib/libv8/v8/src/arm/disasm-arm.cc +1506 -0
  57. data/lib/libv8/v8/src/arm/frames-arm.cc +45 -0
  58. data/lib/libv8/v8/src/arm/frames-arm.h +168 -0
  59. data/lib/libv8/v8/src/arm/full-codegen-arm.cc +4375 -0
  60. data/lib/libv8/v8/src/arm/ic-arm.cc +1562 -0
  61. data/lib/libv8/v8/src/arm/lithium-arm.cc +2206 -0
  62. data/lib/libv8/v8/src/arm/lithium-arm.h +2348 -0
  63. data/lib/libv8/v8/src/arm/lithium-codegen-arm.cc +4526 -0
  64. data/lib/libv8/v8/src/arm/lithium-codegen-arm.h +403 -0
  65. data/lib/libv8/v8/src/arm/lithium-gap-resolver-arm.cc +305 -0
  66. data/lib/libv8/v8/src/arm/lithium-gap-resolver-arm.h +84 -0
  67. data/lib/libv8/v8/src/arm/macro-assembler-arm.cc +3163 -0
  68. data/lib/libv8/v8/src/arm/macro-assembler-arm.h +1126 -0
  69. data/lib/libv8/v8/src/arm/regexp-macro-assembler-arm.cc +1287 -0
  70. data/lib/libv8/v8/src/arm/regexp-macro-assembler-arm.h +253 -0
  71. data/lib/libv8/v8/src/arm/simulator-arm.cc +3424 -0
  72. data/lib/libv8/v8/src/arm/simulator-arm.h +431 -0
  73. data/lib/libv8/v8/src/arm/stub-cache-arm.cc +4243 -0
  74. data/lib/libv8/v8/src/array.js +1366 -0
  75. data/lib/libv8/v8/src/assembler.cc +1207 -0
  76. data/lib/libv8/v8/src/assembler.h +858 -0
  77. data/lib/libv8/v8/src/ast-inl.h +112 -0
  78. data/lib/libv8/v8/src/ast.cc +1146 -0
  79. data/lib/libv8/v8/src/ast.h +2188 -0
  80. data/lib/libv8/v8/src/atomicops.h +167 -0
  81. data/lib/libv8/v8/src/atomicops_internals_arm_gcc.h +145 -0
  82. data/lib/libv8/v8/src/atomicops_internals_mips_gcc.h +169 -0
  83. data/lib/libv8/v8/src/atomicops_internals_x86_gcc.cc +133 -0
  84. data/lib/libv8/v8/src/atomicops_internals_x86_gcc.h +287 -0
  85. data/lib/libv8/v8/src/atomicops_internals_x86_macosx.h +301 -0
  86. data/lib/libv8/v8/src/atomicops_internals_x86_msvc.h +203 -0
  87. data/lib/libv8/v8/src/bignum-dtoa.cc +655 -0
  88. data/lib/libv8/v8/src/bignum-dtoa.h +81 -0
  89. data/lib/libv8/v8/src/bignum.cc +768 -0
  90. data/lib/libv8/v8/src/bignum.h +140 -0
  91. data/lib/libv8/v8/src/bootstrapper.cc +2184 -0
  92. data/lib/libv8/v8/src/bootstrapper.h +188 -0
  93. data/lib/libv8/v8/src/builtins.cc +1707 -0
  94. data/lib/libv8/v8/src/builtins.h +371 -0
  95. data/lib/libv8/v8/src/bytecodes-irregexp.h +105 -0
  96. data/lib/libv8/v8/src/cached-powers.cc +177 -0
  97. data/lib/libv8/v8/src/cached-powers.h +65 -0
  98. data/lib/libv8/v8/src/char-predicates-inl.h +94 -0
  99. data/lib/libv8/v8/src/char-predicates.h +67 -0
  100. data/lib/libv8/v8/src/checks.cc +110 -0
  101. data/lib/libv8/v8/src/checks.h +296 -0
  102. data/lib/libv8/v8/src/circular-queue-inl.h +53 -0
  103. data/lib/libv8/v8/src/circular-queue.cc +122 -0
  104. data/lib/libv8/v8/src/circular-queue.h +103 -0
  105. data/lib/libv8/v8/src/code-stubs.cc +267 -0
  106. data/lib/libv8/v8/src/code-stubs.h +1011 -0
  107. data/lib/libv8/v8/src/code.h +70 -0
  108. data/lib/libv8/v8/src/codegen.cc +231 -0
  109. data/lib/libv8/v8/src/codegen.h +84 -0
  110. data/lib/libv8/v8/src/compilation-cache.cc +540 -0
  111. data/lib/libv8/v8/src/compilation-cache.h +287 -0
  112. data/lib/libv8/v8/src/compiler.cc +786 -0
  113. data/lib/libv8/v8/src/compiler.h +312 -0
  114. data/lib/libv8/v8/src/contexts.cc +347 -0
  115. data/lib/libv8/v8/src/contexts.h +391 -0
  116. data/lib/libv8/v8/src/conversions-inl.h +106 -0
  117. data/lib/libv8/v8/src/conversions.cc +1131 -0
  118. data/lib/libv8/v8/src/conversions.h +135 -0
  119. data/lib/libv8/v8/src/counters.cc +93 -0
  120. data/lib/libv8/v8/src/counters.h +254 -0
  121. data/lib/libv8/v8/src/cpu-profiler-inl.h +101 -0
  122. data/lib/libv8/v8/src/cpu-profiler.cc +609 -0
  123. data/lib/libv8/v8/src/cpu-profiler.h +302 -0
  124. data/lib/libv8/v8/src/cpu.h +69 -0
  125. data/lib/libv8/v8/src/d8-debug.cc +367 -0
  126. data/lib/libv8/v8/src/d8-debug.h +158 -0
  127. data/lib/libv8/v8/src/d8-posix.cc +695 -0
  128. data/lib/libv8/v8/src/d8-readline.cc +130 -0
  129. data/lib/libv8/v8/src/d8-windows.cc +42 -0
  130. data/lib/libv8/v8/src/d8.cc +803 -0
  131. data/lib/libv8/v8/src/d8.gyp +91 -0
  132. data/lib/libv8/v8/src/d8.h +235 -0
  133. data/lib/libv8/v8/src/d8.js +2798 -0
  134. data/lib/libv8/v8/src/data-flow.cc +66 -0
  135. data/lib/libv8/v8/src/data-flow.h +205 -0
  136. data/lib/libv8/v8/src/date.js +1103 -0
  137. data/lib/libv8/v8/src/dateparser-inl.h +127 -0
  138. data/lib/libv8/v8/src/dateparser.cc +178 -0
  139. data/lib/libv8/v8/src/dateparser.h +266 -0
  140. data/lib/libv8/v8/src/debug-agent.cc +447 -0
  141. data/lib/libv8/v8/src/debug-agent.h +129 -0
  142. data/lib/libv8/v8/src/debug-debugger.js +2569 -0
  143. data/lib/libv8/v8/src/debug.cc +3165 -0
  144. data/lib/libv8/v8/src/debug.h +1057 -0
  145. data/lib/libv8/v8/src/deoptimizer.cc +1256 -0
  146. data/lib/libv8/v8/src/deoptimizer.h +602 -0
  147. data/lib/libv8/v8/src/disasm.h +80 -0
  148. data/lib/libv8/v8/src/disassembler.cc +343 -0
  149. data/lib/libv8/v8/src/disassembler.h +58 -0
  150. data/lib/libv8/v8/src/diy-fp.cc +58 -0
  151. data/lib/libv8/v8/src/diy-fp.h +117 -0
  152. data/lib/libv8/v8/src/double.h +238 -0
  153. data/lib/libv8/v8/src/dtoa.cc +103 -0
  154. data/lib/libv8/v8/src/dtoa.h +85 -0
  155. data/lib/libv8/v8/src/execution.cc +849 -0
  156. data/lib/libv8/v8/src/execution.h +297 -0
  157. data/lib/libv8/v8/src/extensions/experimental/break-iterator.cc +250 -0
  158. data/lib/libv8/v8/src/extensions/experimental/break-iterator.h +89 -0
  159. data/lib/libv8/v8/src/extensions/experimental/collator.cc +218 -0
  160. data/lib/libv8/v8/src/extensions/experimental/collator.h +69 -0
  161. data/lib/libv8/v8/src/extensions/experimental/experimental.gyp +94 -0
  162. data/lib/libv8/v8/src/extensions/experimental/i18n-extension.cc +78 -0
  163. data/lib/libv8/v8/src/extensions/experimental/i18n-extension.h +54 -0
  164. data/lib/libv8/v8/src/extensions/experimental/i18n-locale.cc +112 -0
  165. data/lib/libv8/v8/src/extensions/experimental/i18n-locale.h +60 -0
  166. data/lib/libv8/v8/src/extensions/experimental/i18n-utils.cc +43 -0
  167. data/lib/libv8/v8/src/extensions/experimental/i18n-utils.h +49 -0
  168. data/lib/libv8/v8/src/extensions/experimental/i18n.js +180 -0
  169. data/lib/libv8/v8/src/extensions/experimental/language-matcher.cc +251 -0
  170. data/lib/libv8/v8/src/extensions/experimental/language-matcher.h +95 -0
  171. data/lib/libv8/v8/src/extensions/externalize-string-extension.cc +141 -0
  172. data/lib/libv8/v8/src/extensions/externalize-string-extension.h +50 -0
  173. data/lib/libv8/v8/src/extensions/gc-extension.cc +58 -0
  174. data/lib/libv8/v8/src/extensions/gc-extension.h +49 -0
  175. data/lib/libv8/v8/src/factory.cc +1222 -0
  176. data/lib/libv8/v8/src/factory.h +442 -0
  177. data/lib/libv8/v8/src/fast-dtoa.cc +736 -0
  178. data/lib/libv8/v8/src/fast-dtoa.h +83 -0
  179. data/lib/libv8/v8/src/fixed-dtoa.cc +405 -0
  180. data/lib/libv8/v8/src/fixed-dtoa.h +55 -0
  181. data/lib/libv8/v8/src/flag-definitions.h +560 -0
  182. data/lib/libv8/v8/src/flags.cc +551 -0
  183. data/lib/libv8/v8/src/flags.h +79 -0
  184. data/lib/libv8/v8/src/frames-inl.h +247 -0
  185. data/lib/libv8/v8/src/frames.cc +1243 -0
  186. data/lib/libv8/v8/src/frames.h +870 -0
  187. data/lib/libv8/v8/src/full-codegen.cc +1374 -0
  188. data/lib/libv8/v8/src/full-codegen.h +771 -0
  189. data/lib/libv8/v8/src/func-name-inferrer.cc +92 -0
  190. data/lib/libv8/v8/src/func-name-inferrer.h +111 -0
  191. data/lib/libv8/v8/src/gdb-jit.cc +1555 -0
  192. data/lib/libv8/v8/src/gdb-jit.h +143 -0
  193. data/lib/libv8/v8/src/global-handles.cc +665 -0
  194. data/lib/libv8/v8/src/global-handles.h +284 -0
  195. data/lib/libv8/v8/src/globals.h +325 -0
  196. data/lib/libv8/v8/src/handles-inl.h +177 -0
  197. data/lib/libv8/v8/src/handles.cc +987 -0
  198. data/lib/libv8/v8/src/handles.h +382 -0
  199. data/lib/libv8/v8/src/hashmap.cc +230 -0
  200. data/lib/libv8/v8/src/hashmap.h +123 -0
  201. data/lib/libv8/v8/src/heap-inl.h +704 -0
  202. data/lib/libv8/v8/src/heap-profiler.cc +1173 -0
  203. data/lib/libv8/v8/src/heap-profiler.h +397 -0
  204. data/lib/libv8/v8/src/heap.cc +5930 -0
  205. data/lib/libv8/v8/src/heap.h +2268 -0
  206. data/lib/libv8/v8/src/hydrogen-instructions.cc +1769 -0
  207. data/lib/libv8/v8/src/hydrogen-instructions.h +3971 -0
  208. data/lib/libv8/v8/src/hydrogen.cc +6239 -0
  209. data/lib/libv8/v8/src/hydrogen.h +1202 -0
  210. data/lib/libv8/v8/src/ia32/assembler-ia32-inl.h +446 -0
  211. data/lib/libv8/v8/src/ia32/assembler-ia32.cc +2487 -0
  212. data/lib/libv8/v8/src/ia32/assembler-ia32.h +1144 -0
  213. data/lib/libv8/v8/src/ia32/builtins-ia32.cc +1621 -0
  214. data/lib/libv8/v8/src/ia32/code-stubs-ia32.cc +6198 -0
  215. data/lib/libv8/v8/src/ia32/code-stubs-ia32.h +517 -0
  216. data/lib/libv8/v8/src/ia32/codegen-ia32.cc +265 -0
  217. data/lib/libv8/v8/src/ia32/codegen-ia32.h +79 -0
  218. data/lib/libv8/v8/src/ia32/cpu-ia32.cc +88 -0
  219. data/lib/libv8/v8/src/ia32/debug-ia32.cc +312 -0
  220. data/lib/libv8/v8/src/ia32/deoptimizer-ia32.cc +774 -0
  221. data/lib/libv8/v8/src/ia32/disasm-ia32.cc +1628 -0
  222. data/lib/libv8/v8/src/ia32/frames-ia32.cc +45 -0
  223. data/lib/libv8/v8/src/ia32/frames-ia32.h +142 -0
  224. data/lib/libv8/v8/src/ia32/full-codegen-ia32.cc +4338 -0
  225. data/lib/libv8/v8/src/ia32/ic-ia32.cc +1597 -0
  226. data/lib/libv8/v8/src/ia32/lithium-codegen-ia32.cc +4461 -0
  227. data/lib/libv8/v8/src/ia32/lithium-codegen-ia32.h +375 -0
  228. data/lib/libv8/v8/src/ia32/lithium-gap-resolver-ia32.cc +475 -0
  229. data/lib/libv8/v8/src/ia32/lithium-gap-resolver-ia32.h +110 -0
  230. data/lib/libv8/v8/src/ia32/lithium-ia32.cc +2261 -0
  231. data/lib/libv8/v8/src/ia32/lithium-ia32.h +2396 -0
  232. data/lib/libv8/v8/src/ia32/macro-assembler-ia32.cc +2136 -0
  233. data/lib/libv8/v8/src/ia32/macro-assembler-ia32.h +775 -0
  234. data/lib/libv8/v8/src/ia32/regexp-macro-assembler-ia32.cc +1263 -0
  235. data/lib/libv8/v8/src/ia32/regexp-macro-assembler-ia32.h +216 -0
  236. data/lib/libv8/v8/src/ia32/simulator-ia32.cc +30 -0
  237. data/lib/libv8/v8/src/ia32/simulator-ia32.h +74 -0
  238. data/lib/libv8/v8/src/ia32/stub-cache-ia32.cc +3847 -0
  239. data/lib/libv8/v8/src/ic-inl.h +130 -0
  240. data/lib/libv8/v8/src/ic.cc +2577 -0
  241. data/lib/libv8/v8/src/ic.h +736 -0
  242. data/lib/libv8/v8/src/inspector.cc +63 -0
  243. data/lib/libv8/v8/src/inspector.h +62 -0
  244. data/lib/libv8/v8/src/interpreter-irregexp.cc +659 -0
  245. data/lib/libv8/v8/src/interpreter-irregexp.h +49 -0
  246. data/lib/libv8/v8/src/isolate-inl.h +50 -0
  247. data/lib/libv8/v8/src/isolate.cc +1869 -0
  248. data/lib/libv8/v8/src/isolate.h +1382 -0
  249. data/lib/libv8/v8/src/json-parser.cc +504 -0
  250. data/lib/libv8/v8/src/json-parser.h +161 -0
  251. data/lib/libv8/v8/src/json.js +342 -0
  252. data/lib/libv8/v8/src/jsregexp.cc +5385 -0
  253. data/lib/libv8/v8/src/jsregexp.h +1492 -0
  254. data/lib/libv8/v8/src/list-inl.h +212 -0
  255. data/lib/libv8/v8/src/list.h +174 -0
  256. data/lib/libv8/v8/src/lithium-allocator-inl.h +142 -0
  257. data/lib/libv8/v8/src/lithium-allocator.cc +2123 -0
  258. data/lib/libv8/v8/src/lithium-allocator.h +630 -0
  259. data/lib/libv8/v8/src/lithium.cc +190 -0
  260. data/lib/libv8/v8/src/lithium.h +597 -0
  261. data/lib/libv8/v8/src/liveedit-debugger.js +1082 -0
  262. data/lib/libv8/v8/src/liveedit.cc +1691 -0
  263. data/lib/libv8/v8/src/liveedit.h +180 -0
  264. data/lib/libv8/v8/src/liveobjectlist-inl.h +126 -0
  265. data/lib/libv8/v8/src/liveobjectlist.cc +2589 -0
  266. data/lib/libv8/v8/src/liveobjectlist.h +322 -0
  267. data/lib/libv8/v8/src/log-inl.h +59 -0
  268. data/lib/libv8/v8/src/log-utils.cc +428 -0
  269. data/lib/libv8/v8/src/log-utils.h +231 -0
  270. data/lib/libv8/v8/src/log.cc +1993 -0
  271. data/lib/libv8/v8/src/log.h +476 -0
  272. data/lib/libv8/v8/src/macro-assembler.h +120 -0
  273. data/lib/libv8/v8/src/macros.py +178 -0
  274. data/lib/libv8/v8/src/mark-compact.cc +3143 -0
  275. data/lib/libv8/v8/src/mark-compact.h +506 -0
  276. data/lib/libv8/v8/src/math.js +264 -0
  277. data/lib/libv8/v8/src/messages.cc +179 -0
  278. data/lib/libv8/v8/src/messages.h +113 -0
  279. data/lib/libv8/v8/src/messages.js +1096 -0
  280. data/lib/libv8/v8/src/mips/assembler-mips-inl.h +312 -0
  281. data/lib/libv8/v8/src/mips/assembler-mips.cc +1960 -0
  282. data/lib/libv8/v8/src/mips/assembler-mips.h +1138 -0
  283. data/lib/libv8/v8/src/mips/builtins-mips.cc +1628 -0
  284. data/lib/libv8/v8/src/mips/code-stubs-mips.cc +6656 -0
  285. data/lib/libv8/v8/src/mips/code-stubs-mips.h +682 -0
  286. data/lib/libv8/v8/src/mips/codegen-mips.cc +52 -0
  287. data/lib/libv8/v8/src/mips/codegen-mips.h +98 -0
  288. data/lib/libv8/v8/src/mips/constants-mips.cc +352 -0
  289. data/lib/libv8/v8/src/mips/constants-mips.h +739 -0
  290. data/lib/libv8/v8/src/mips/cpu-mips.cc +96 -0
  291. data/lib/libv8/v8/src/mips/debug-mips.cc +308 -0
  292. data/lib/libv8/v8/src/mips/deoptimizer-mips.cc +91 -0
  293. data/lib/libv8/v8/src/mips/disasm-mips.cc +1050 -0
  294. data/lib/libv8/v8/src/mips/frames-mips.cc +47 -0
  295. data/lib/libv8/v8/src/mips/frames-mips.h +219 -0
  296. data/lib/libv8/v8/src/mips/full-codegen-mips.cc +4388 -0
  297. data/lib/libv8/v8/src/mips/ic-mips.cc +1580 -0
  298. data/lib/libv8/v8/src/mips/lithium-codegen-mips.h +65 -0
  299. data/lib/libv8/v8/src/mips/lithium-mips.h +307 -0
  300. data/lib/libv8/v8/src/mips/macro-assembler-mips.cc +4056 -0
  301. data/lib/libv8/v8/src/mips/macro-assembler-mips.h +1214 -0
  302. data/lib/libv8/v8/src/mips/regexp-macro-assembler-mips.cc +1251 -0
  303. data/lib/libv8/v8/src/mips/regexp-macro-assembler-mips.h +252 -0
  304. data/lib/libv8/v8/src/mips/simulator-mips.cc +2621 -0
  305. data/lib/libv8/v8/src/mips/simulator-mips.h +401 -0
  306. data/lib/libv8/v8/src/mips/stub-cache-mips.cc +4285 -0
  307. data/lib/libv8/v8/src/mirror-debugger.js +2382 -0
  308. data/lib/libv8/v8/src/mksnapshot.cc +328 -0
  309. data/lib/libv8/v8/src/natives.h +64 -0
  310. data/lib/libv8/v8/src/objects-debug.cc +738 -0
  311. data/lib/libv8/v8/src/objects-inl.h +4323 -0
  312. data/lib/libv8/v8/src/objects-printer.cc +829 -0
  313. data/lib/libv8/v8/src/objects-visiting.cc +148 -0
  314. data/lib/libv8/v8/src/objects-visiting.h +424 -0
  315. data/lib/libv8/v8/src/objects.cc +10585 -0
  316. data/lib/libv8/v8/src/objects.h +6838 -0
  317. data/lib/libv8/v8/src/parser.cc +4997 -0
  318. data/lib/libv8/v8/src/parser.h +765 -0
  319. data/lib/libv8/v8/src/platform-cygwin.cc +779 -0
  320. data/lib/libv8/v8/src/platform-freebsd.cc +826 -0
  321. data/lib/libv8/v8/src/platform-linux.cc +1149 -0
  322. data/lib/libv8/v8/src/platform-macos.cc +830 -0
  323. data/lib/libv8/v8/src/platform-nullos.cc +479 -0
  324. data/lib/libv8/v8/src/platform-openbsd.cc +640 -0
  325. data/lib/libv8/v8/src/platform-posix.cc +424 -0
  326. data/lib/libv8/v8/src/platform-solaris.cc +762 -0
  327. data/lib/libv8/v8/src/platform-tls-mac.h +62 -0
  328. data/lib/libv8/v8/src/platform-tls-win32.h +62 -0
  329. data/lib/libv8/v8/src/platform-tls.h +50 -0
  330. data/lib/libv8/v8/src/platform-win32.cc +2021 -0
  331. data/lib/libv8/v8/src/platform.h +667 -0
  332. data/lib/libv8/v8/src/preparse-data-format.h +62 -0
  333. data/lib/libv8/v8/src/preparse-data.cc +183 -0
  334. data/lib/libv8/v8/src/preparse-data.h +225 -0
  335. data/lib/libv8/v8/src/preparser-api.cc +220 -0
  336. data/lib/libv8/v8/src/preparser.cc +1450 -0
  337. data/lib/libv8/v8/src/preparser.h +493 -0
  338. data/lib/libv8/v8/src/prettyprinter.cc +1493 -0
  339. data/lib/libv8/v8/src/prettyprinter.h +223 -0
  340. data/lib/libv8/v8/src/profile-generator-inl.h +128 -0
  341. data/lib/libv8/v8/src/profile-generator.cc +3098 -0
  342. data/lib/libv8/v8/src/profile-generator.h +1126 -0
  343. data/lib/libv8/v8/src/property.cc +105 -0
  344. data/lib/libv8/v8/src/property.h +365 -0
  345. data/lib/libv8/v8/src/proxy.js +83 -0
  346. data/lib/libv8/v8/src/regexp-macro-assembler-irregexp-inl.h +78 -0
  347. data/lib/libv8/v8/src/regexp-macro-assembler-irregexp.cc +471 -0
  348. data/lib/libv8/v8/src/regexp-macro-assembler-irregexp.h +142 -0
  349. data/lib/libv8/v8/src/regexp-macro-assembler-tracer.cc +373 -0
  350. data/lib/libv8/v8/src/regexp-macro-assembler-tracer.h +104 -0
  351. data/lib/libv8/v8/src/regexp-macro-assembler.cc +267 -0
  352. data/lib/libv8/v8/src/regexp-macro-assembler.h +243 -0
  353. data/lib/libv8/v8/src/regexp-stack.cc +111 -0
  354. data/lib/libv8/v8/src/regexp-stack.h +147 -0
  355. data/lib/libv8/v8/src/regexp.js +483 -0
  356. data/lib/libv8/v8/src/rewriter.cc +360 -0
  357. data/lib/libv8/v8/src/rewriter.h +50 -0
  358. data/lib/libv8/v8/src/runtime-profiler.cc +489 -0
  359. data/lib/libv8/v8/src/runtime-profiler.h +201 -0
  360. data/lib/libv8/v8/src/runtime.cc +12227 -0
  361. data/lib/libv8/v8/src/runtime.h +652 -0
  362. data/lib/libv8/v8/src/runtime.js +649 -0
  363. data/lib/libv8/v8/src/safepoint-table.cc +256 -0
  364. data/lib/libv8/v8/src/safepoint-table.h +270 -0
  365. data/lib/libv8/v8/src/scanner-base.cc +952 -0
  366. data/lib/libv8/v8/src/scanner-base.h +670 -0
  367. data/lib/libv8/v8/src/scanner.cc +345 -0
  368. data/lib/libv8/v8/src/scanner.h +146 -0
  369. data/lib/libv8/v8/src/scopeinfo.cc +646 -0
  370. data/lib/libv8/v8/src/scopeinfo.h +254 -0
  371. data/lib/libv8/v8/src/scopes.cc +1150 -0
  372. data/lib/libv8/v8/src/scopes.h +507 -0
  373. data/lib/libv8/v8/src/serialize.cc +1574 -0
  374. data/lib/libv8/v8/src/serialize.h +589 -0
  375. data/lib/libv8/v8/src/shell.h +55 -0
  376. data/lib/libv8/v8/src/simulator.h +43 -0
  377. data/lib/libv8/v8/src/small-pointer-list.h +163 -0
  378. data/lib/libv8/v8/src/smart-pointer.h +109 -0
  379. data/lib/libv8/v8/src/snapshot-common.cc +83 -0
  380. data/lib/libv8/v8/src/snapshot-empty.cc +54 -0
  381. data/lib/libv8/v8/src/snapshot.h +91 -0
  382. data/lib/libv8/v8/src/spaces-inl.h +529 -0
  383. data/lib/libv8/v8/src/spaces.cc +3145 -0
  384. data/lib/libv8/v8/src/spaces.h +2369 -0
  385. data/lib/libv8/v8/src/splay-tree-inl.h +310 -0
  386. data/lib/libv8/v8/src/splay-tree.h +205 -0
  387. data/lib/libv8/v8/src/string-search.cc +41 -0
  388. data/lib/libv8/v8/src/string-search.h +568 -0
  389. data/lib/libv8/v8/src/string-stream.cc +592 -0
  390. data/lib/libv8/v8/src/string-stream.h +191 -0
  391. data/lib/libv8/v8/src/string.js +994 -0
  392. data/lib/libv8/v8/src/strtod.cc +440 -0
  393. data/lib/libv8/v8/src/strtod.h +40 -0
  394. data/lib/libv8/v8/src/stub-cache.cc +1965 -0
  395. data/lib/libv8/v8/src/stub-cache.h +924 -0
  396. data/lib/libv8/v8/src/third_party/valgrind/valgrind.h +3925 -0
  397. data/lib/libv8/v8/src/token.cc +63 -0
  398. data/lib/libv8/v8/src/token.h +288 -0
  399. data/lib/libv8/v8/src/type-info.cc +507 -0
  400. data/lib/libv8/v8/src/type-info.h +272 -0
  401. data/lib/libv8/v8/src/unbound-queue-inl.h +95 -0
  402. data/lib/libv8/v8/src/unbound-queue.h +69 -0
  403. data/lib/libv8/v8/src/unicode-inl.h +238 -0
  404. data/lib/libv8/v8/src/unicode.cc +1624 -0
  405. data/lib/libv8/v8/src/unicode.h +280 -0
  406. data/lib/libv8/v8/src/uri.js +408 -0
  407. data/lib/libv8/v8/src/utils-inl.h +48 -0
  408. data/lib/libv8/v8/src/utils.cc +371 -0
  409. data/lib/libv8/v8/src/utils.h +800 -0
  410. data/lib/libv8/v8/src/v8-counters.cc +62 -0
  411. data/lib/libv8/v8/src/v8-counters.h +314 -0
  412. data/lib/libv8/v8/src/v8.cc +213 -0
  413. data/lib/libv8/v8/src/v8.h +131 -0
  414. data/lib/libv8/v8/src/v8checks.h +64 -0
  415. data/lib/libv8/v8/src/v8dll-main.cc +44 -0
  416. data/lib/libv8/v8/src/v8globals.h +512 -0
  417. data/lib/libv8/v8/src/v8memory.h +82 -0
  418. data/lib/libv8/v8/src/v8natives.js +1310 -0
  419. data/lib/libv8/v8/src/v8preparserdll-main.cc +39 -0
  420. data/lib/libv8/v8/src/v8threads.cc +464 -0
  421. data/lib/libv8/v8/src/v8threads.h +165 -0
  422. data/lib/libv8/v8/src/v8utils.h +319 -0
  423. data/lib/libv8/v8/src/variables.cc +114 -0
  424. data/lib/libv8/v8/src/variables.h +167 -0
  425. data/lib/libv8/v8/src/version.cc +116 -0
  426. data/lib/libv8/v8/src/version.h +68 -0
  427. data/lib/libv8/v8/src/vm-state-inl.h +138 -0
  428. data/lib/libv8/v8/src/vm-state.h +71 -0
  429. data/lib/libv8/v8/src/win32-headers.h +96 -0
  430. data/lib/libv8/v8/src/x64/assembler-x64-inl.h +462 -0
  431. data/lib/libv8/v8/src/x64/assembler-x64.cc +3027 -0
  432. data/lib/libv8/v8/src/x64/assembler-x64.h +1633 -0
  433. data/lib/libv8/v8/src/x64/builtins-x64.cc +1520 -0
  434. data/lib/libv8/v8/src/x64/code-stubs-x64.cc +5132 -0
  435. data/lib/libv8/v8/src/x64/code-stubs-x64.h +514 -0
  436. data/lib/libv8/v8/src/x64/codegen-x64.cc +146 -0
  437. data/lib/libv8/v8/src/x64/codegen-x64.h +76 -0
  438. data/lib/libv8/v8/src/x64/cpu-x64.cc +88 -0
  439. data/lib/libv8/v8/src/x64/debug-x64.cc +319 -0
  440. data/lib/libv8/v8/src/x64/deoptimizer-x64.cc +815 -0
  441. data/lib/libv8/v8/src/x64/disasm-x64.cc +1832 -0
  442. data/lib/libv8/v8/src/x64/frames-x64.cc +45 -0
  443. data/lib/libv8/v8/src/x64/frames-x64.h +130 -0
  444. data/lib/libv8/v8/src/x64/full-codegen-x64.cc +4318 -0
  445. data/lib/libv8/v8/src/x64/ic-x64.cc +1608 -0
  446. data/lib/libv8/v8/src/x64/lithium-codegen-x64.cc +4267 -0
  447. data/lib/libv8/v8/src/x64/lithium-codegen-x64.h +367 -0
  448. data/lib/libv8/v8/src/x64/lithium-gap-resolver-x64.cc +320 -0
  449. data/lib/libv8/v8/src/x64/lithium-gap-resolver-x64.h +74 -0
  450. data/lib/libv8/v8/src/x64/lithium-x64.cc +2202 -0
  451. data/lib/libv8/v8/src/x64/lithium-x64.h +2333 -0
  452. data/lib/libv8/v8/src/x64/macro-assembler-x64.cc +3745 -0
  453. data/lib/libv8/v8/src/x64/macro-assembler-x64.h +1290 -0
  454. data/lib/libv8/v8/src/x64/regexp-macro-assembler-x64.cc +1398 -0
  455. data/lib/libv8/v8/src/x64/regexp-macro-assembler-x64.h +282 -0
  456. data/lib/libv8/v8/src/x64/simulator-x64.cc +27 -0
  457. data/lib/libv8/v8/src/x64/simulator-x64.h +72 -0
  458. data/lib/libv8/v8/src/x64/stub-cache-x64.cc +3610 -0
  459. data/lib/libv8/v8/src/zone-inl.h +140 -0
  460. data/lib/libv8/v8/src/zone.cc +196 -0
  461. data/lib/libv8/v8/src/zone.h +240 -0
  462. data/lib/libv8/v8/tools/codemap.js +265 -0
  463. data/lib/libv8/v8/tools/consarray.js +93 -0
  464. data/lib/libv8/v8/tools/csvparser.js +78 -0
  465. data/lib/libv8/v8/tools/disasm.py +92 -0
  466. data/lib/libv8/v8/tools/freebsd-tick-processor +10 -0
  467. data/lib/libv8/v8/tools/gc-nvp-trace-processor.py +342 -0
  468. data/lib/libv8/v8/tools/gcmole/README +62 -0
  469. data/lib/libv8/v8/tools/gcmole/gccause.lua +60 -0
  470. data/lib/libv8/v8/tools/gcmole/gcmole.cc +1261 -0
  471. data/lib/libv8/v8/tools/gcmole/gcmole.lua +378 -0
  472. data/lib/libv8/v8/tools/generate-ten-powers.scm +286 -0
  473. data/lib/libv8/v8/tools/grokdump.py +841 -0
  474. data/lib/libv8/v8/tools/gyp/v8.gyp +995 -0
  475. data/lib/libv8/v8/tools/js2c.py +364 -0
  476. data/lib/libv8/v8/tools/jsmin.py +280 -0
  477. data/lib/libv8/v8/tools/linux-tick-processor +35 -0
  478. data/lib/libv8/v8/tools/ll_prof.py +942 -0
  479. data/lib/libv8/v8/tools/logreader.js +185 -0
  480. data/lib/libv8/v8/tools/mac-nm +18 -0
  481. data/lib/libv8/v8/tools/mac-tick-processor +6 -0
  482. data/lib/libv8/v8/tools/oom_dump/README +31 -0
  483. data/lib/libv8/v8/tools/oom_dump/SConstruct +42 -0
  484. data/lib/libv8/v8/tools/oom_dump/oom_dump.cc +288 -0
  485. data/lib/libv8/v8/tools/presubmit.py +305 -0
  486. data/lib/libv8/v8/tools/process-heap-prof.py +120 -0
  487. data/lib/libv8/v8/tools/profile.js +751 -0
  488. data/lib/libv8/v8/tools/profile_view.js +219 -0
  489. data/lib/libv8/v8/tools/run-valgrind.py +77 -0
  490. data/lib/libv8/v8/tools/splaytree.js +316 -0
  491. data/lib/libv8/v8/tools/stats-viewer.py +468 -0
  492. data/lib/libv8/v8/tools/test.py +1510 -0
  493. data/lib/libv8/v8/tools/tickprocessor-driver.js +59 -0
  494. data/lib/libv8/v8/tools/tickprocessor.js +877 -0
  495. data/lib/libv8/v8/tools/utils.py +96 -0
  496. data/lib/libv8/v8/tools/visual_studio/README.txt +12 -0
  497. data/lib/libv8/v8/tools/windows-tick-processor.bat +30 -0
  498. data/lib/libv8/version.rb +5 -0
  499. data/libv8.gemspec +36 -0
  500. metadata +578 -0
@@ -0,0 +1,287 @@
1
+ // Copyright 2008 the V8 project authors. All rights reserved.
2
+ // Redistribution and use in source and binary forms, with or without
3
+ // modification, are permitted provided that the following conditions are
4
+ // met:
5
+ //
6
+ // * Redistributions of source code must retain the above copyright
7
+ // notice, this list of conditions and the following disclaimer.
8
+ // * Redistributions in binary form must reproduce the above
9
+ // copyright notice, this list of conditions and the following
10
+ // disclaimer in the documentation and/or other materials provided
11
+ // with the distribution.
12
+ // * Neither the name of Google Inc. nor the names of its
13
+ // contributors may be used to endorse or promote products derived
14
+ // from this software without specific prior written permission.
15
+ //
16
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+
28
+ #ifndef V8_COMPILATION_CACHE_H_
29
+ #define V8_COMPILATION_CACHE_H_
30
+
31
+ namespace v8 {
32
+ namespace internal {
33
+
34
+ class HashMap;
35
+
36
+ // The compilation cache consists of several generational sub-caches which uses
37
+ // this class as a base class. A sub-cache contains a compilation cache tables
38
+ // for each generation of the sub-cache. Since the same source code string has
39
+ // different compiled code for scripts and evals, we use separate sub-caches
40
+ // for different compilation modes, to avoid retrieving the wrong result.
41
+ class CompilationSubCache {
42
+ public:
43
+ CompilationSubCache(Isolate* isolate, int generations)
44
+ : isolate_(isolate),
45
+ generations_(generations) {
46
+ tables_ = NewArray<Object*>(generations);
47
+ }
48
+
49
+ ~CompilationSubCache() { DeleteArray(tables_); }
50
+
51
+ // Index for the first generation in the cache.
52
+ static const int kFirstGeneration = 0;
53
+
54
+ // Get the compilation cache tables for a specific generation.
55
+ Handle<CompilationCacheTable> GetTable(int generation);
56
+
57
+ // Accessors for first generation.
58
+ Handle<CompilationCacheTable> GetFirstTable() {
59
+ return GetTable(kFirstGeneration);
60
+ }
61
+ void SetFirstTable(Handle<CompilationCacheTable> value) {
62
+ ASSERT(kFirstGeneration < generations_);
63
+ tables_[kFirstGeneration] = *value;
64
+ }
65
+
66
+ // Age the sub-cache by evicting the oldest generation and creating a new
67
+ // young generation.
68
+ void Age();
69
+
70
+ // GC support.
71
+ void Iterate(ObjectVisitor* v);
72
+ void IterateFunctions(ObjectVisitor* v);
73
+
74
+ // Clear this sub-cache evicting all its content.
75
+ void Clear();
76
+
77
+ // Remove given shared function info from sub-cache.
78
+ void Remove(Handle<SharedFunctionInfo> function_info);
79
+
80
+ // Number of generations in this sub-cache.
81
+ inline int generations() { return generations_; }
82
+
83
+ protected:
84
+ Isolate* isolate() { return isolate_; }
85
+
86
+ private:
87
+ Isolate* isolate_;
88
+ int generations_; // Number of generations.
89
+ Object** tables_; // Compilation cache tables - one for each generation.
90
+
91
+ DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationSubCache);
92
+ };
93
+
94
+
95
+ // Sub-cache for scripts.
96
+ class CompilationCacheScript : public CompilationSubCache {
97
+ public:
98
+ CompilationCacheScript(Isolate* isolate, int generations);
99
+
100
+ Handle<SharedFunctionInfo> Lookup(Handle<String> source,
101
+ Handle<Object> name,
102
+ int line_offset,
103
+ int column_offset);
104
+ void Put(Handle<String> source, Handle<SharedFunctionInfo> function_info);
105
+
106
+ private:
107
+ MUST_USE_RESULT MaybeObject* TryTablePut(
108
+ Handle<String> source, Handle<SharedFunctionInfo> function_info);
109
+
110
+ // Note: Returns a new hash table if operation results in expansion.
111
+ Handle<CompilationCacheTable> TablePut(
112
+ Handle<String> source, Handle<SharedFunctionInfo> function_info);
113
+
114
+ bool HasOrigin(Handle<SharedFunctionInfo> function_info,
115
+ Handle<Object> name,
116
+ int line_offset,
117
+ int column_offset);
118
+
119
+ void* script_histogram_;
120
+ bool script_histogram_initialized_;
121
+
122
+ DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheScript);
123
+ };
124
+
125
+
126
+ // Sub-cache for eval scripts.
127
+ class CompilationCacheEval: public CompilationSubCache {
128
+ public:
129
+ CompilationCacheEval(Isolate* isolate, int generations)
130
+ : CompilationSubCache(isolate, generations) { }
131
+
132
+ Handle<SharedFunctionInfo> Lookup(Handle<String> source,
133
+ Handle<Context> context,
134
+ StrictModeFlag strict_mode);
135
+
136
+ void Put(Handle<String> source,
137
+ Handle<Context> context,
138
+ Handle<SharedFunctionInfo> function_info);
139
+
140
+ private:
141
+ MUST_USE_RESULT MaybeObject* TryTablePut(
142
+ Handle<String> source,
143
+ Handle<Context> context,
144
+ Handle<SharedFunctionInfo> function_info);
145
+
146
+ // Note: Returns a new hash table if operation results in expansion.
147
+ Handle<CompilationCacheTable> TablePut(
148
+ Handle<String> source,
149
+ Handle<Context> context,
150
+ Handle<SharedFunctionInfo> function_info);
151
+
152
+ DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheEval);
153
+ };
154
+
155
+
156
+ // Sub-cache for regular expressions.
157
+ class CompilationCacheRegExp: public CompilationSubCache {
158
+ public:
159
+ CompilationCacheRegExp(Isolate* isolate, int generations)
160
+ : CompilationSubCache(isolate, generations) { }
161
+
162
+ Handle<FixedArray> Lookup(Handle<String> source, JSRegExp::Flags flags);
163
+
164
+ void Put(Handle<String> source,
165
+ JSRegExp::Flags flags,
166
+ Handle<FixedArray> data);
167
+ private:
168
+ MUST_USE_RESULT MaybeObject* TryTablePut(Handle<String> source,
169
+ JSRegExp::Flags flags,
170
+ Handle<FixedArray> data);
171
+
172
+ // Note: Returns a new hash table if operation results in expansion.
173
+ Handle<CompilationCacheTable> TablePut(Handle<String> source,
174
+ JSRegExp::Flags flags,
175
+ Handle<FixedArray> data);
176
+
177
+ DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheRegExp);
178
+ };
179
+
180
+
181
+ // The compilation cache keeps shared function infos for compiled
182
+ // scripts and evals. The shared function infos are looked up using
183
+ // the source string as the key. For regular expressions the
184
+ // compilation data is cached.
185
+ class CompilationCache {
186
+ public:
187
+ // Finds the script shared function info for a source
188
+ // string. Returns an empty handle if the cache doesn't contain a
189
+ // script for the given source string with the right origin.
190
+ Handle<SharedFunctionInfo> LookupScript(Handle<String> source,
191
+ Handle<Object> name,
192
+ int line_offset,
193
+ int column_offset);
194
+
195
+ // Finds the shared function info for a source string for eval in a
196
+ // given context. Returns an empty handle if the cache doesn't
197
+ // contain a script for the given source string.
198
+ Handle<SharedFunctionInfo> LookupEval(Handle<String> source,
199
+ Handle<Context> context,
200
+ bool is_global,
201
+ StrictModeFlag strict_mode);
202
+
203
+ // Returns the regexp data associated with the given regexp if it
204
+ // is in cache, otherwise an empty handle.
205
+ Handle<FixedArray> LookupRegExp(Handle<String> source,
206
+ JSRegExp::Flags flags);
207
+
208
+ // Associate the (source, kind) pair to the shared function
209
+ // info. This may overwrite an existing mapping.
210
+ void PutScript(Handle<String> source,
211
+ Handle<SharedFunctionInfo> function_info);
212
+
213
+ // Associate the (source, context->closure()->shared(), kind) triple
214
+ // with the shared function info. This may overwrite an existing mapping.
215
+ void PutEval(Handle<String> source,
216
+ Handle<Context> context,
217
+ bool is_global,
218
+ Handle<SharedFunctionInfo> function_info);
219
+
220
+ // Associate the (source, flags) pair to the given regexp data.
221
+ // This may overwrite an existing mapping.
222
+ void PutRegExp(Handle<String> source,
223
+ JSRegExp::Flags flags,
224
+ Handle<FixedArray> data);
225
+
226
+ // Support for eager optimization tracking.
227
+ bool ShouldOptimizeEagerly(Handle<JSFunction> function);
228
+ void MarkForEagerOptimizing(Handle<JSFunction> function);
229
+ void MarkForLazyOptimizing(Handle<JSFunction> function);
230
+
231
+ // Reset the eager optimization tracking data.
232
+ void ResetEagerOptimizingData();
233
+
234
+ // Clear the cache - also used to initialize the cache at startup.
235
+ void Clear();
236
+
237
+ // Remove given shared function info from all caches.
238
+ void Remove(Handle<SharedFunctionInfo> function_info);
239
+
240
+ // GC support.
241
+ void Iterate(ObjectVisitor* v);
242
+ void IterateFunctions(ObjectVisitor* v);
243
+
244
+ // Notify the cache that a mark-sweep garbage collection is about to
245
+ // take place. This is used to retire entries from the cache to
246
+ // avoid keeping them alive too long without using them.
247
+ void MarkCompactPrologue();
248
+
249
+ // Enable/disable compilation cache. Used by debugger to disable compilation
250
+ // cache during debugging to make sure new scripts are always compiled.
251
+ void Enable();
252
+ void Disable();
253
+ private:
254
+ explicit CompilationCache(Isolate* isolate);
255
+ ~CompilationCache();
256
+
257
+ HashMap* EagerOptimizingSet();
258
+
259
+ // The number of sub caches covering the different types to cache.
260
+ static const int kSubCacheCount = 4;
261
+
262
+ bool IsEnabled() { return FLAG_compilation_cache && enabled_; }
263
+
264
+ Isolate* isolate() { return isolate_; }
265
+
266
+ Isolate* isolate_;
267
+
268
+ CompilationCacheScript script_;
269
+ CompilationCacheEval eval_global_;
270
+ CompilationCacheEval eval_contextual_;
271
+ CompilationCacheRegExp reg_exp_;
272
+ CompilationSubCache* subcaches_[kSubCacheCount];
273
+
274
+ // Current enable state of the compilation cache.
275
+ bool enabled_;
276
+
277
+ HashMap* eager_optimizing_set_;
278
+
279
+ friend class Isolate;
280
+
281
+ DISALLOW_COPY_AND_ASSIGN(CompilationCache);
282
+ };
283
+
284
+
285
+ } } // namespace v8::internal
286
+
287
+ #endif // V8_COMPILATION_CACHE_H_
@@ -0,0 +1,786 @@
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
+ #include "v8.h"
29
+
30
+ #include "compiler.h"
31
+
32
+ #include "bootstrapper.h"
33
+ #include "codegen.h"
34
+ #include "compilation-cache.h"
35
+ #include "debug.h"
36
+ #include "full-codegen.h"
37
+ #include "gdb-jit.h"
38
+ #include "hydrogen.h"
39
+ #include "lithium.h"
40
+ #include "liveedit.h"
41
+ #include "parser.h"
42
+ #include "rewriter.h"
43
+ #include "runtime-profiler.h"
44
+ #include "scopeinfo.h"
45
+ #include "scopes.h"
46
+ #include "vm-state-inl.h"
47
+
48
+ namespace v8 {
49
+ namespace internal {
50
+
51
+
52
+ CompilationInfo::CompilationInfo(Handle<Script> script)
53
+ : isolate_(script->GetIsolate()),
54
+ flags_(0),
55
+ function_(NULL),
56
+ scope_(NULL),
57
+ script_(script),
58
+ extension_(NULL),
59
+ pre_parse_data_(NULL),
60
+ supports_deoptimization_(false),
61
+ osr_ast_id_(AstNode::kNoNumber) {
62
+ Initialize(NONOPT);
63
+ }
64
+
65
+
66
+ CompilationInfo::CompilationInfo(Handle<SharedFunctionInfo> shared_info)
67
+ : isolate_(shared_info->GetIsolate()),
68
+ flags_(IsLazy::encode(true)),
69
+ function_(NULL),
70
+ scope_(NULL),
71
+ shared_info_(shared_info),
72
+ script_(Handle<Script>(Script::cast(shared_info->script()))),
73
+ extension_(NULL),
74
+ pre_parse_data_(NULL),
75
+ supports_deoptimization_(false),
76
+ osr_ast_id_(AstNode::kNoNumber) {
77
+ Initialize(BASE);
78
+ }
79
+
80
+
81
+ CompilationInfo::CompilationInfo(Handle<JSFunction> closure)
82
+ : isolate_(closure->GetIsolate()),
83
+ flags_(IsLazy::encode(true)),
84
+ function_(NULL),
85
+ scope_(NULL),
86
+ closure_(closure),
87
+ shared_info_(Handle<SharedFunctionInfo>(closure->shared())),
88
+ script_(Handle<Script>(Script::cast(shared_info_->script()))),
89
+ extension_(NULL),
90
+ pre_parse_data_(NULL),
91
+ supports_deoptimization_(false),
92
+ osr_ast_id_(AstNode::kNoNumber) {
93
+ Initialize(BASE);
94
+ }
95
+
96
+
97
+ // Disable optimization for the rest of the compilation pipeline.
98
+ void CompilationInfo::DisableOptimization() {
99
+ bool is_optimizable_closure =
100
+ FLAG_optimize_closures &&
101
+ closure_.is_null() &&
102
+ !scope_->HasTrivialOuterContext() &&
103
+ !scope_->outer_scope_calls_non_strict_eval() &&
104
+ !scope_->inside_with();
105
+ SetMode(is_optimizable_closure ? BASE : NONOPT);
106
+ }
107
+
108
+
109
+ void CompilationInfo::AbortOptimization() {
110
+ Handle<Code> code(shared_info()->code());
111
+ SetCode(code);
112
+ Isolate* isolate = code->GetIsolate();
113
+ isolate->compilation_cache()->MarkForLazyOptimizing(closure());
114
+ }
115
+
116
+
117
+ // Determine whether to use the full compiler for all code. If the flag
118
+ // --always-full-compiler is specified this is the case. For the virtual frame
119
+ // based compiler the full compiler is also used if a debugger is connected, as
120
+ // the code from the full compiler supports mode precise break points. For the
121
+ // crankshaft adaptive compiler debugging the optimized code is not possible at
122
+ // all. However crankshaft support recompilation of functions, so in this case
123
+ // the full compiler need not be be used if a debugger is attached, but only if
124
+ // break points has actually been set.
125
+ static bool is_debugging_active() {
126
+ #ifdef ENABLE_DEBUGGER_SUPPORT
127
+ Isolate* isolate = Isolate::Current();
128
+ return V8::UseCrankshaft() ?
129
+ isolate->debug()->has_break_points() :
130
+ isolate->debugger()->IsDebuggerActive();
131
+ #else
132
+ return false;
133
+ #endif
134
+ }
135
+
136
+
137
+ static bool AlwaysFullCompiler() {
138
+ return FLAG_always_full_compiler || is_debugging_active();
139
+ }
140
+
141
+
142
+ static void FinishOptimization(Handle<JSFunction> function, int64_t start) {
143
+ int opt_count = function->shared()->opt_count();
144
+ function->shared()->set_opt_count(opt_count + 1);
145
+ double ms = static_cast<double>(OS::Ticks() - start) / 1000;
146
+ if (FLAG_trace_opt) {
147
+ PrintF("[optimizing: ");
148
+ function->PrintName();
149
+ PrintF(" / %" V8PRIxPTR, reinterpret_cast<intptr_t>(*function));
150
+ PrintF(" - took %0.3f ms]\n", ms);
151
+ }
152
+ if (FLAG_trace_opt_stats) {
153
+ static double compilation_time = 0.0;
154
+ static int compiled_functions = 0;
155
+ static int code_size = 0;
156
+
157
+ compilation_time += ms;
158
+ compiled_functions++;
159
+ code_size += function->shared()->SourceSize();
160
+ PrintF("Compiled: %d functions with %d byte source size in %fms.\n",
161
+ compiled_functions,
162
+ code_size,
163
+ compilation_time);
164
+ }
165
+ }
166
+
167
+
168
+ static bool MakeCrankshaftCode(CompilationInfo* info) {
169
+ // Test if we can optimize this function when asked to. We can only
170
+ // do this after the scopes are computed.
171
+ if (!info->AllowOptimize()) info->DisableOptimization();
172
+
173
+ // In case we are not optimizing simply return the code from
174
+ // the full code generator.
175
+ if (!info->IsOptimizing()) {
176
+ return FullCodeGenerator::MakeCode(info);
177
+ }
178
+
179
+ // We should never arrive here if there is not code object on the
180
+ // shared function object.
181
+ Handle<Code> code(info->shared_info()->code());
182
+ ASSERT(code->kind() == Code::FUNCTION);
183
+
184
+ // We should never arrive here if optimization has been disabled on the
185
+ // shared function info.
186
+ ASSERT(!info->shared_info()->optimization_disabled());
187
+
188
+ // Fall back to using the full code generator if it's not possible
189
+ // to use the Hydrogen-based optimizing compiler. We already have
190
+ // generated code for this from the shared function object.
191
+ if (AlwaysFullCompiler() || !FLAG_use_hydrogen) {
192
+ info->SetCode(code);
193
+ return true;
194
+ }
195
+
196
+ // Limit the number of times we re-compile a functions with
197
+ // the optimizing compiler.
198
+ const int kMaxOptCount =
199
+ FLAG_deopt_every_n_times == 0 ? Compiler::kDefaultMaxOptCount : 1000;
200
+ if (info->shared_info()->opt_count() > kMaxOptCount) {
201
+ info->AbortOptimization();
202
+ Handle<JSFunction> closure = info->closure();
203
+ info->shared_info()->DisableOptimization(*closure);
204
+ // True indicates the compilation pipeline is still going, not
205
+ // necessarily that we optimized the code.
206
+ return true;
207
+ }
208
+
209
+ // Due to an encoding limit on LUnallocated operands in the Lithium
210
+ // language, we cannot optimize functions with too many formal parameters
211
+ // or perform on-stack replacement for function with too many
212
+ // stack-allocated local variables.
213
+ //
214
+ // The encoding is as a signed value, with parameters and receiver using
215
+ // the negative indices and locals the non-negative ones.
216
+ const int limit = LUnallocated::kMaxFixedIndices / 2;
217
+ Scope* scope = info->scope();
218
+ if ((scope->num_parameters() + 1) > limit ||
219
+ scope->num_stack_slots() > limit) {
220
+ info->AbortOptimization();
221
+ Handle<JSFunction> closure = info->closure();
222
+ info->shared_info()->DisableOptimization(*closure);
223
+ // True indicates the compilation pipeline is still going, not
224
+ // necessarily that we optimized the code.
225
+ return true;
226
+ }
227
+
228
+ // Take --hydrogen-filter into account.
229
+ Vector<const char> filter = CStrVector(FLAG_hydrogen_filter);
230
+ Handle<String> name = info->function()->debug_name();
231
+ bool match = filter.is_empty() || name->IsEqualTo(filter);
232
+ if (!match) {
233
+ info->SetCode(code);
234
+ return true;
235
+ }
236
+
237
+ // Recompile the unoptimized version of the code if the current version
238
+ // doesn't have deoptimization support. Alternatively, we may decide to
239
+ // run the full code generator to get a baseline for the compile-time
240
+ // performance of the hydrogen-based compiler.
241
+ int64_t start = OS::Ticks();
242
+ bool should_recompile = !info->shared_info()->has_deoptimization_support();
243
+ if (should_recompile || FLAG_hydrogen_stats) {
244
+ HPhase phase(HPhase::kFullCodeGen);
245
+ CompilationInfo unoptimized(info->shared_info());
246
+ // Note that we use the same AST that we will use for generating the
247
+ // optimized code.
248
+ unoptimized.SetFunction(info->function());
249
+ unoptimized.SetScope(info->scope());
250
+ if (should_recompile) unoptimized.EnableDeoptimizationSupport();
251
+ bool succeeded = FullCodeGenerator::MakeCode(&unoptimized);
252
+ if (should_recompile) {
253
+ if (!succeeded) return false;
254
+ Handle<SharedFunctionInfo> shared = info->shared_info();
255
+ shared->EnableDeoptimizationSupport(*unoptimized.code());
256
+ // The existing unoptimized code was replaced with the new one.
257
+ Compiler::RecordFunctionCompilation(
258
+ Logger::LAZY_COMPILE_TAG, &unoptimized, shared);
259
+ }
260
+ }
261
+
262
+ // Check that the unoptimized, shared code is ready for
263
+ // optimizations. When using the always_opt flag we disregard the
264
+ // optimizable marker in the code object and optimize anyway. This
265
+ // is safe as long as the unoptimized code has deoptimization
266
+ // support.
267
+ ASSERT(FLAG_always_opt || code->optimizable());
268
+ ASSERT(info->shared_info()->has_deoptimization_support());
269
+
270
+ if (FLAG_trace_hydrogen) {
271
+ PrintF("-----------------------------------------------------------\n");
272
+ PrintF("Compiling method %s using hydrogen\n", *name->ToCString());
273
+ HTracer::Instance()->TraceCompilation(info->function());
274
+ }
275
+
276
+ Handle<Context> global_context(info->closure()->context()->global_context());
277
+ TypeFeedbackOracle oracle(code, global_context);
278
+ HGraphBuilder builder(info, &oracle);
279
+ HPhase phase(HPhase::kTotal);
280
+ HGraph* graph = builder.CreateGraph();
281
+ if (info->isolate()->has_pending_exception()) {
282
+ info->SetCode(Handle<Code>::null());
283
+ return false;
284
+ }
285
+
286
+ if (graph != NULL && FLAG_build_lithium) {
287
+ Handle<Code> optimized_code = graph->Compile(info);
288
+ if (!optimized_code.is_null()) {
289
+ info->SetCode(optimized_code);
290
+ FinishOptimization(info->closure(), start);
291
+ return true;
292
+ }
293
+ }
294
+
295
+ // Keep using the shared code.
296
+ info->AbortOptimization();
297
+ if (!builder.inline_bailout()) {
298
+ // Mark the shared code as unoptimizable unless it was an inlined
299
+ // function that bailed out.
300
+ Handle<JSFunction> closure = info->closure();
301
+ info->shared_info()->DisableOptimization(*closure);
302
+ }
303
+ // True indicates the compilation pipeline is still going, not necessarily
304
+ // that we optimized the code.
305
+ return true;
306
+ }
307
+
308
+
309
+ static bool GenerateCode(CompilationInfo* info) {
310
+ return V8::UseCrankshaft() ?
311
+ MakeCrankshaftCode(info) :
312
+ FullCodeGenerator::MakeCode(info);
313
+ }
314
+
315
+
316
+ static bool MakeCode(CompilationInfo* info) {
317
+ // Precondition: code has been parsed. Postcondition: the code field in
318
+ // the compilation info is set if compilation succeeded.
319
+ ASSERT(info->function() != NULL);
320
+ return Rewriter::Rewrite(info) && Scope::Analyze(info) && GenerateCode(info);
321
+ }
322
+
323
+
324
+ #ifdef ENABLE_DEBUGGER_SUPPORT
325
+ bool Compiler::MakeCodeForLiveEdit(CompilationInfo* info) {
326
+ // Precondition: code has been parsed. Postcondition: the code field in
327
+ // the compilation info is set if compilation succeeded.
328
+ bool succeeded = MakeCode(info);
329
+ if (!info->shared_info().is_null()) {
330
+ Handle<SerializedScopeInfo> scope_info =
331
+ SerializedScopeInfo::Create(info->scope());
332
+ info->shared_info()->set_scope_info(*scope_info);
333
+ }
334
+ return succeeded;
335
+ }
336
+ #endif
337
+
338
+
339
+ static Handle<SharedFunctionInfo> MakeFunctionInfo(CompilationInfo* info) {
340
+ Isolate* isolate = info->isolate();
341
+ CompilationZoneScope zone_scope(isolate, DELETE_ON_EXIT);
342
+ PostponeInterruptsScope postpone(isolate);
343
+
344
+ ASSERT(!isolate->global_context().is_null());
345
+ Handle<Script> script = info->script();
346
+ script->set_context_data((*isolate->global_context())->data());
347
+
348
+ #ifdef ENABLE_DEBUGGER_SUPPORT
349
+ if (info->is_eval()) {
350
+ Script::CompilationType compilation_type = Script::COMPILATION_TYPE_EVAL;
351
+ script->set_compilation_type(Smi::FromInt(compilation_type));
352
+ // For eval scripts add information on the function from which eval was
353
+ // called.
354
+ if (info->is_eval()) {
355
+ StackTraceFrameIterator it(isolate);
356
+ if (!it.done()) {
357
+ script->set_eval_from_shared(
358
+ JSFunction::cast(it.frame()->function())->shared());
359
+ Code* code = it.frame()->LookupCode();
360
+ int offset = static_cast<int>(
361
+ it.frame()->pc() - code->instruction_start());
362
+ script->set_eval_from_instructions_offset(Smi::FromInt(offset));
363
+ }
364
+ }
365
+ }
366
+
367
+ // Notify debugger
368
+ isolate->debugger()->OnBeforeCompile(script);
369
+ #endif
370
+
371
+ // Only allow non-global compiles for eval.
372
+ ASSERT(info->is_eval() || info->is_global());
373
+
374
+ if (!ParserApi::Parse(info)) return Handle<SharedFunctionInfo>::null();
375
+
376
+ // Measure how long it takes to do the compilation; only take the
377
+ // rest of the function into account to avoid overlap with the
378
+ // parsing statistics.
379
+ HistogramTimer* rate = info->is_eval()
380
+ ? info->isolate()->counters()->compile_eval()
381
+ : info->isolate()->counters()->compile();
382
+ HistogramTimerScope timer(rate);
383
+
384
+ // Compile the code.
385
+ FunctionLiteral* lit = info->function();
386
+ LiveEditFunctionTracker live_edit_tracker(isolate, lit);
387
+ if (!MakeCode(info)) {
388
+ isolate->StackOverflow();
389
+ return Handle<SharedFunctionInfo>::null();
390
+ }
391
+
392
+ // Allocate function.
393
+ ASSERT(!info->code().is_null());
394
+ Handle<SharedFunctionInfo> result =
395
+ isolate->factory()->NewSharedFunctionInfo(
396
+ lit->name(),
397
+ lit->materialized_literal_count(),
398
+ info->code(),
399
+ SerializedScopeInfo::Create(info->scope()));
400
+
401
+ ASSERT_EQ(RelocInfo::kNoPosition, lit->function_token_position());
402
+ Compiler::SetFunctionInfo(result, lit, true, script);
403
+
404
+ if (script->name()->IsString()) {
405
+ PROFILE(isolate, CodeCreateEvent(
406
+ info->is_eval()
407
+ ? Logger::EVAL_TAG
408
+ : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script),
409
+ *info->code(),
410
+ *result,
411
+ String::cast(script->name())));
412
+ GDBJIT(AddCode(Handle<String>(String::cast(script->name())),
413
+ script,
414
+ info->code()));
415
+ } else {
416
+ PROFILE(isolate, CodeCreateEvent(
417
+ info->is_eval()
418
+ ? Logger::EVAL_TAG
419
+ : Logger::ToNativeByScript(Logger::SCRIPT_TAG, *script),
420
+ *info->code(),
421
+ *result,
422
+ isolate->heap()->empty_string()));
423
+ GDBJIT(AddCode(Handle<String>(), script, info->code()));
424
+ }
425
+
426
+ // Hint to the runtime system used when allocating space for initial
427
+ // property space by setting the expected number of properties for
428
+ // the instances of the function.
429
+ SetExpectedNofPropertiesFromEstimate(result, lit->expected_property_count());
430
+
431
+ #ifdef ENABLE_DEBUGGER_SUPPORT
432
+ // Notify debugger
433
+ isolate->debugger()->OnAfterCompile(
434
+ script, Debugger::NO_AFTER_COMPILE_FLAGS);
435
+ #endif
436
+
437
+ live_edit_tracker.RecordFunctionInfo(result, lit);
438
+
439
+ return result;
440
+ }
441
+
442
+
443
+ Handle<SharedFunctionInfo> Compiler::Compile(Handle<String> source,
444
+ Handle<Object> script_name,
445
+ int line_offset,
446
+ int column_offset,
447
+ v8::Extension* extension,
448
+ ScriptDataImpl* input_pre_data,
449
+ Handle<Object> script_data,
450
+ NativesFlag natives) {
451
+ Isolate* isolate = source->GetIsolate();
452
+ int source_length = source->length();
453
+ isolate->counters()->total_load_size()->Increment(source_length);
454
+ isolate->counters()->total_compile_size()->Increment(source_length);
455
+
456
+ // The VM is in the COMPILER state until exiting this function.
457
+ VMState state(isolate, COMPILER);
458
+
459
+ CompilationCache* compilation_cache = isolate->compilation_cache();
460
+
461
+ // Do a lookup in the compilation cache but not for extensions.
462
+ Handle<SharedFunctionInfo> result;
463
+ if (extension == NULL) {
464
+ result = compilation_cache->LookupScript(source,
465
+ script_name,
466
+ line_offset,
467
+ column_offset);
468
+ }
469
+
470
+ if (result.is_null()) {
471
+ // No cache entry found. Do pre-parsing, if it makes sense, and compile
472
+ // the script.
473
+ // Building preparse data that is only used immediately after is only a
474
+ // saving if we might skip building the AST for lazily compiled functions.
475
+ // I.e., preparse data isn't relevant when the lazy flag is off, and
476
+ // for small sources, odds are that there aren't many functions
477
+ // that would be compiled lazily anyway, so we skip the preparse step
478
+ // in that case too.
479
+ ScriptDataImpl* pre_data = input_pre_data;
480
+ if (pre_data == NULL
481
+ && source_length >= FLAG_min_preparse_length) {
482
+ if (source->IsExternalTwoByteString()) {
483
+ ExternalTwoByteStringUC16CharacterStream stream(
484
+ Handle<ExternalTwoByteString>::cast(source), 0, source->length());
485
+ pre_data = ParserApi::PartialPreParse(&stream, extension);
486
+ } else {
487
+ GenericStringUC16CharacterStream stream(source, 0, source->length());
488
+ pre_data = ParserApi::PartialPreParse(&stream, extension);
489
+ }
490
+ }
491
+
492
+ // Create a script object describing the script to be compiled.
493
+ Handle<Script> script = FACTORY->NewScript(source);
494
+ if (natives == NATIVES_CODE) {
495
+ script->set_type(Smi::FromInt(Script::TYPE_NATIVE));
496
+ }
497
+ if (!script_name.is_null()) {
498
+ script->set_name(*script_name);
499
+ script->set_line_offset(Smi::FromInt(line_offset));
500
+ script->set_column_offset(Smi::FromInt(column_offset));
501
+ }
502
+
503
+ script->set_data(script_data.is_null() ? HEAP->undefined_value()
504
+ : *script_data);
505
+
506
+ // Compile the function and add it to the cache.
507
+ CompilationInfo info(script);
508
+ info.MarkAsGlobal();
509
+ info.SetExtension(extension);
510
+ info.SetPreParseData(pre_data);
511
+ if (natives == NATIVES_CODE) info.MarkAsAllowingNativesSyntax();
512
+ result = MakeFunctionInfo(&info);
513
+ if (extension == NULL && !result.is_null()) {
514
+ compilation_cache->PutScript(source, result);
515
+ }
516
+
517
+ // Get rid of the pre-parsing data (if necessary).
518
+ if (input_pre_data == NULL && pre_data != NULL) {
519
+ delete pre_data;
520
+ }
521
+ }
522
+
523
+ if (result.is_null()) isolate->ReportPendingMessages();
524
+ return result;
525
+ }
526
+
527
+
528
+ Handle<SharedFunctionInfo> Compiler::CompileEval(Handle<String> source,
529
+ Handle<Context> context,
530
+ bool is_global,
531
+ StrictModeFlag strict_mode) {
532
+ Isolate* isolate = source->GetIsolate();
533
+ int source_length = source->length();
534
+ isolate->counters()->total_eval_size()->Increment(source_length);
535
+ isolate->counters()->total_compile_size()->Increment(source_length);
536
+
537
+ // The VM is in the COMPILER state until exiting this function.
538
+ VMState state(isolate, COMPILER);
539
+
540
+ // Do a lookup in the compilation cache; if the entry is not there, invoke
541
+ // the compiler and add the result to the cache.
542
+ Handle<SharedFunctionInfo> result;
543
+ CompilationCache* compilation_cache = isolate->compilation_cache();
544
+ result = compilation_cache->LookupEval(source,
545
+ context,
546
+ is_global,
547
+ strict_mode);
548
+
549
+ if (result.is_null()) {
550
+ // Create a script object describing the script to be compiled.
551
+ Handle<Script> script = isolate->factory()->NewScript(source);
552
+ CompilationInfo info(script);
553
+ info.MarkAsEval();
554
+ if (is_global) info.MarkAsGlobal();
555
+ if (strict_mode == kStrictMode) info.MarkAsStrictMode();
556
+ info.SetCallingContext(context);
557
+ result = MakeFunctionInfo(&info);
558
+ if (!result.is_null()) {
559
+ CompilationCache* compilation_cache = isolate->compilation_cache();
560
+ // If caller is strict mode, the result must be strict as well,
561
+ // but not the other way around. Consider:
562
+ // eval("'use strict'; ...");
563
+ ASSERT(strict_mode == kNonStrictMode || result->strict_mode());
564
+ compilation_cache->PutEval(source, context, is_global, result);
565
+ }
566
+ }
567
+
568
+ return result;
569
+ }
570
+
571
+
572
+ bool Compiler::CompileLazy(CompilationInfo* info) {
573
+ Isolate* isolate = info->isolate();
574
+
575
+ CompilationZoneScope zone_scope(isolate, DELETE_ON_EXIT);
576
+
577
+ // The VM is in the COMPILER state until exiting this function.
578
+ VMState state(isolate, COMPILER);
579
+
580
+ PostponeInterruptsScope postpone(isolate);
581
+
582
+ Handle<SharedFunctionInfo> shared = info->shared_info();
583
+ int compiled_size = shared->end_position() - shared->start_position();
584
+ isolate->counters()->total_compile_size()->Increment(compiled_size);
585
+
586
+ // Generate the AST for the lazily compiled function.
587
+ if (ParserApi::Parse(info)) {
588
+ // Measure how long it takes to do the lazy compilation; only take the
589
+ // rest of the function into account to avoid overlap with the lazy
590
+ // parsing statistics.
591
+ HistogramTimerScope timer(isolate->counters()->compile_lazy());
592
+
593
+ // After parsing we know function's strict mode. Remember it.
594
+ if (info->function()->strict_mode()) {
595
+ shared->set_strict_mode(true);
596
+ info->MarkAsStrictMode();
597
+ }
598
+
599
+ // Compile the code.
600
+ if (!MakeCode(info)) {
601
+ if (!isolate->has_pending_exception()) {
602
+ isolate->StackOverflow();
603
+ }
604
+ } else {
605
+ ASSERT(!info->code().is_null());
606
+ Handle<Code> code = info->code();
607
+ // Set optimizable to false if this is disallowed by the shared
608
+ // function info, e.g., we might have flushed the code and must
609
+ // reset this bit when lazy compiling the code again.
610
+ if (shared->optimization_disabled()) code->set_optimizable(false);
611
+
612
+ Handle<JSFunction> function = info->closure();
613
+ RecordFunctionCompilation(Logger::LAZY_COMPILE_TAG, info, shared);
614
+
615
+ if (info->IsOptimizing()) {
616
+ function->ReplaceCode(*code);
617
+ } else {
618
+ // Update the shared function info with the compiled code and the
619
+ // scope info. Please note, that the order of the shared function
620
+ // info initialization is important since set_scope_info might
621
+ // trigger a GC, causing the ASSERT below to be invalid if the code
622
+ // was flushed. By settting the code object last we avoid this.
623
+ Handle<SerializedScopeInfo> scope_info =
624
+ SerializedScopeInfo::Create(info->scope());
625
+ shared->set_scope_info(*scope_info);
626
+ shared->set_code(*code);
627
+ if (!function.is_null()) {
628
+ function->ReplaceCode(*code);
629
+ ASSERT(!function->IsOptimized());
630
+ }
631
+
632
+ // Set the expected number of properties for instances.
633
+ FunctionLiteral* lit = info->function();
634
+ int expected = lit->expected_property_count();
635
+ SetExpectedNofPropertiesFromEstimate(shared, expected);
636
+
637
+ // Set the optimization hints after performing lazy compilation, as
638
+ // these are not set when the function is set up as a lazily
639
+ // compiled function.
640
+ shared->SetThisPropertyAssignmentsInfo(
641
+ lit->has_only_simple_this_property_assignments(),
642
+ *lit->this_property_assignments());
643
+
644
+ // Check the function has compiled code.
645
+ ASSERT(shared->is_compiled());
646
+ shared->set_code_age(0);
647
+
648
+ if (info->AllowOptimize() && !shared->optimization_disabled()) {
649
+ // If we're asked to always optimize, we compile the optimized
650
+ // version of the function right away - unless the debugger is
651
+ // active as it makes no sense to compile optimized code then.
652
+ if (FLAG_always_opt &&
653
+ !Isolate::Current()->DebuggerHasBreakPoints()) {
654
+ CompilationInfo optimized(function);
655
+ optimized.SetOptimizing(AstNode::kNoNumber);
656
+ return CompileLazy(&optimized);
657
+ } else if (isolate->compilation_cache()->ShouldOptimizeEagerly(
658
+ function)) {
659
+ isolate->runtime_profiler()->OptimizeSoon(*function);
660
+ }
661
+ }
662
+ }
663
+
664
+ return true;
665
+ }
666
+ }
667
+
668
+ ASSERT(info->code().is_null());
669
+ return false;
670
+ }
671
+
672
+
673
+ Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(FunctionLiteral* literal,
674
+ Handle<Script> script) {
675
+ // Precondition: code has been parsed and scopes have been analyzed.
676
+ CompilationInfo info(script);
677
+ info.SetFunction(literal);
678
+ info.SetScope(literal->scope());
679
+ if (literal->scope()->is_strict_mode()) info.MarkAsStrictMode();
680
+
681
+ LiveEditFunctionTracker live_edit_tracker(info.isolate(), literal);
682
+ // Determine if the function can be lazily compiled. This is necessary to
683
+ // allow some of our builtin JS files to be lazily compiled. These
684
+ // builtins cannot be handled lazily by the parser, since we have to know
685
+ // if a function uses the special natives syntax, which is something the
686
+ // parser records.
687
+ bool allow_lazy = literal->AllowsLazyCompilation() &&
688
+ !LiveEditFunctionTracker::IsActive(info.isolate());
689
+
690
+ Handle<SerializedScopeInfo> scope_info(SerializedScopeInfo::Empty());
691
+
692
+ // Generate code
693
+ if (FLAG_lazy && allow_lazy) {
694
+ Handle<Code> code = info.isolate()->builtins()->LazyCompile();
695
+ info.SetCode(code);
696
+ } else if ((V8::UseCrankshaft() && MakeCrankshaftCode(&info)) ||
697
+ (!V8::UseCrankshaft() && FullCodeGenerator::MakeCode(&info))) {
698
+ ASSERT(!info.code().is_null());
699
+ scope_info = SerializedScopeInfo::Create(info.scope());
700
+ } else {
701
+ return Handle<SharedFunctionInfo>::null();
702
+ }
703
+
704
+ // Create a shared function info object.
705
+ Handle<SharedFunctionInfo> result =
706
+ FACTORY->NewSharedFunctionInfo(literal->name(),
707
+ literal->materialized_literal_count(),
708
+ info.code(),
709
+ scope_info);
710
+ SetFunctionInfo(result, literal, false, script);
711
+ RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result);
712
+ result->set_allows_lazy_compilation(allow_lazy);
713
+
714
+ // Set the expected number of properties for instances and return
715
+ // the resulting function.
716
+ SetExpectedNofPropertiesFromEstimate(result,
717
+ literal->expected_property_count());
718
+ live_edit_tracker.RecordFunctionInfo(result, literal);
719
+ return result;
720
+ }
721
+
722
+
723
+ // Sets the function info on a function.
724
+ // The start_position points to the first '(' character after the function name
725
+ // in the full script source. When counting characters in the script source the
726
+ // the first character is number 0 (not 1).
727
+ void Compiler::SetFunctionInfo(Handle<SharedFunctionInfo> function_info,
728
+ FunctionLiteral* lit,
729
+ bool is_toplevel,
730
+ Handle<Script> script) {
731
+ function_info->set_length(lit->num_parameters());
732
+ function_info->set_formal_parameter_count(lit->num_parameters());
733
+ function_info->set_script(*script);
734
+ function_info->set_function_token_position(lit->function_token_position());
735
+ function_info->set_start_position(lit->start_position());
736
+ function_info->set_end_position(lit->end_position());
737
+ function_info->set_is_expression(lit->is_expression());
738
+ function_info->set_is_toplevel(is_toplevel);
739
+ function_info->set_inferred_name(*lit->inferred_name());
740
+ function_info->SetThisPropertyAssignmentsInfo(
741
+ lit->has_only_simple_this_property_assignments(),
742
+ *lit->this_property_assignments());
743
+ function_info->set_allows_lazy_compilation(lit->AllowsLazyCompilation());
744
+ function_info->set_strict_mode(lit->strict_mode());
745
+ }
746
+
747
+
748
+ void Compiler::RecordFunctionCompilation(Logger::LogEventsAndTags tag,
749
+ CompilationInfo* info,
750
+ Handle<SharedFunctionInfo> shared) {
751
+ // SharedFunctionInfo is passed separately, because if CompilationInfo
752
+ // was created using Script object, it will not have it.
753
+
754
+ // Log the code generation. If source information is available include
755
+ // script name and line number. Check explicitly whether logging is
756
+ // enabled as finding the line number is not free.
757
+ if (info->isolate()->logger()->is_logging() ||
758
+ CpuProfiler::is_profiling(info->isolate())) {
759
+ Handle<Script> script = info->script();
760
+ Handle<Code> code = info->code();
761
+ if (*code == info->isolate()->builtins()->builtin(Builtins::kLazyCompile))
762
+ return;
763
+ if (script->name()->IsString()) {
764
+ int line_num = GetScriptLineNumber(script, shared->start_position()) + 1;
765
+ USE(line_num);
766
+ PROFILE(info->isolate(),
767
+ CodeCreateEvent(Logger::ToNativeByScript(tag, *script),
768
+ *code,
769
+ *shared,
770
+ String::cast(script->name()),
771
+ line_num));
772
+ } else {
773
+ PROFILE(info->isolate(),
774
+ CodeCreateEvent(Logger::ToNativeByScript(tag, *script),
775
+ *code,
776
+ *shared,
777
+ shared->DebugName()));
778
+ }
779
+ }
780
+
781
+ GDBJIT(AddCode(Handle<String>(shared->DebugName()),
782
+ Handle<Script>(info->script()),
783
+ Handle<Code>(info->code())));
784
+ }
785
+
786
+ } } // namespace v8::internal