mustang 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (560) hide show
  1. data/.rspec +1 -0
  2. data/Isolate +9 -0
  3. data/README.md +6 -12
  4. data/Rakefile +30 -4
  5. data/TODO.md +9 -0
  6. data/ext/v8/extconf.rb +56 -0
  7. data/ext/v8/v8.cpp +37 -0
  8. data/ext/v8/v8_array.cpp +161 -0
  9. data/ext/v8/v8_array.h +17 -0
  10. data/ext/v8/v8_base.cpp +147 -0
  11. data/ext/v8/v8_base.h +23 -0
  12. data/ext/v8/v8_cast.cpp +151 -0
  13. data/ext/v8/v8_cast.h +64 -0
  14. data/ext/v8/v8_context.cpp +174 -0
  15. data/ext/v8/v8_context.h +12 -0
  16. data/ext/v8/v8_date.cpp +61 -0
  17. data/ext/v8/v8_date.h +16 -0
  18. data/ext/v8/v8_errors.cpp +147 -0
  19. data/ext/v8/v8_errors.h +19 -0
  20. data/ext/v8/v8_external.cpp +66 -0
  21. data/ext/v8/v8_external.h +16 -0
  22. data/ext/v8/v8_function.cpp +182 -0
  23. data/ext/v8/v8_function.h +14 -0
  24. data/ext/v8/v8_integer.cpp +70 -0
  25. data/ext/v8/v8_integer.h +16 -0
  26. data/ext/v8/v8_macros.h +30 -0
  27. data/ext/v8/v8_main.cpp +53 -0
  28. data/ext/v8/v8_main.h +13 -0
  29. data/ext/v8/v8_number.cpp +62 -0
  30. data/ext/v8/v8_number.h +16 -0
  31. data/ext/v8/v8_object.cpp +172 -0
  32. data/ext/v8/v8_object.h +17 -0
  33. data/ext/v8/v8_ref.cpp +72 -0
  34. data/ext/v8/v8_ref.h +43 -0
  35. data/ext/v8/v8_regexp.cpp +148 -0
  36. data/ext/v8/v8_regexp.h +16 -0
  37. data/ext/v8/v8_string.cpp +78 -0
  38. data/ext/v8/v8_string.h +16 -0
  39. data/ext/v8/v8_value.cpp +370 -0
  40. data/ext/v8/v8_value.h +19 -0
  41. data/gemspec.yml +2 -1
  42. data/lib/core_ext/class.rb +14 -0
  43. data/lib/core_ext/object.rb +12 -0
  44. data/lib/core_ext/symbol.rb +23 -0
  45. data/lib/mustang.rb +44 -0
  46. data/lib/mustang/context.rb +69 -0
  47. data/lib/mustang/errors.rb +36 -0
  48. data/lib/support/delegated.rb +25 -0
  49. data/lib/v8/array.rb +21 -0
  50. data/lib/v8/context.rb +13 -0
  51. data/lib/v8/date.rb +20 -0
  52. data/lib/v8/error.rb +15 -0
  53. data/lib/v8/external.rb +16 -0
  54. data/lib/v8/function.rb +11 -0
  55. data/lib/v8/integer.rb +16 -0
  56. data/lib/v8/number.rb +16 -0
  57. data/lib/v8/object.rb +66 -0
  58. data/lib/v8/regexp.rb +23 -0
  59. data/lib/v8/string.rb +27 -0
  60. data/mustang.gemspec +3 -0
  61. data/spec/core_ext/class_spec.rb +19 -0
  62. data/spec/core_ext/object_spec.rb +19 -0
  63. data/spec/core_ext/symbol_spec.rb +27 -0
  64. data/spec/fixtures/test1.js +2 -0
  65. data/spec/fixtures/test2.js +2 -0
  66. data/spec/spec_helper.rb +20 -0
  67. data/spec/v8/array_spec.rb +88 -0
  68. data/spec/v8/cast_spec.rb +151 -0
  69. data/spec/v8/context_spec.rb +78 -0
  70. data/spec/v8/data_spec.rb +39 -0
  71. data/spec/v8/date_spec.rb +45 -0
  72. data/spec/v8/empty_spec.rb +27 -0
  73. data/spec/v8/errors_spec.rb +142 -0
  74. data/spec/v8/external_spec.rb +44 -0
  75. data/spec/v8/function_spec.rb +170 -0
  76. data/spec/v8/integer_spec.rb +41 -0
  77. data/spec/v8/main_spec.rb +18 -0
  78. data/spec/v8/null_spec.rb +27 -0
  79. data/spec/v8/number_spec.rb +40 -0
  80. data/spec/v8/object_spec.rb +79 -0
  81. data/spec/v8/primitive_spec.rb +9 -0
  82. data/spec/v8/regexp_spec.rb +65 -0
  83. data/spec/v8/string_spec.rb +48 -0
  84. data/spec/v8/undefined_spec.rb +27 -0
  85. data/spec/v8/value_spec.rb +215 -0
  86. data/vendor/v8/.gitignore +2 -0
  87. data/vendor/v8/AUTHORS +3 -1
  88. data/vendor/v8/ChangeLog +117 -0
  89. data/vendor/v8/SConstruct +334 -53
  90. data/vendor/v8/include/v8-debug.h +21 -11
  91. data/vendor/v8/include/v8-preparser.h +1 -1
  92. data/vendor/v8/include/v8-profiler.h +122 -43
  93. data/vendor/v8/include/v8-testing.h +5 -0
  94. data/vendor/v8/include/v8.h +171 -17
  95. data/vendor/v8/preparser/SConscript +38 -0
  96. data/vendor/v8/preparser/preparser-process.cc +77 -114
  97. data/vendor/v8/samples/shell.cc +232 -46
  98. data/vendor/v8/src/SConscript +29 -5
  99. data/vendor/v8/src/accessors.cc +70 -211
  100. data/vendor/v8/{test/cctest/test-mips.cc → src/allocation-inl.h} +15 -18
  101. data/vendor/v8/src/allocation.cc +0 -82
  102. data/vendor/v8/src/allocation.h +9 -42
  103. data/vendor/v8/src/api.cc +1645 -1156
  104. data/vendor/v8/src/api.h +76 -12
  105. data/vendor/v8/src/apiutils.h +0 -7
  106. data/vendor/v8/src/arguments.h +15 -4
  107. data/vendor/v8/src/arm/assembler-arm-inl.h +10 -9
  108. data/vendor/v8/src/arm/assembler-arm.cc +62 -23
  109. data/vendor/v8/src/arm/assembler-arm.h +76 -11
  110. data/vendor/v8/src/arm/builtins-arm.cc +39 -33
  111. data/vendor/v8/src/arm/code-stubs-arm.cc +1182 -402
  112. data/vendor/v8/src/arm/code-stubs-arm.h +20 -54
  113. data/vendor/v8/src/arm/codegen-arm.cc +159 -106
  114. data/vendor/v8/src/arm/codegen-arm.h +6 -6
  115. data/vendor/v8/src/arm/constants-arm.h +16 -1
  116. data/vendor/v8/src/arm/cpu-arm.cc +7 -5
  117. data/vendor/v8/src/arm/debug-arm.cc +6 -4
  118. data/vendor/v8/src/arm/deoptimizer-arm.cc +51 -14
  119. data/vendor/v8/src/arm/disasm-arm.cc +47 -15
  120. data/vendor/v8/src/arm/frames-arm.h +1 -1
  121. data/vendor/v8/src/arm/full-codegen-arm.cc +724 -408
  122. data/vendor/v8/src/arm/ic-arm.cc +90 -85
  123. data/vendor/v8/src/arm/lithium-arm.cc +140 -69
  124. data/vendor/v8/src/arm/lithium-arm.h +161 -46
  125. data/vendor/v8/src/arm/lithium-codegen-arm.cc +567 -297
  126. data/vendor/v8/src/arm/lithium-codegen-arm.h +21 -9
  127. data/vendor/v8/src/arm/lithium-gap-resolver-arm.cc +2 -0
  128. data/vendor/v8/src/arm/macro-assembler-arm.cc +457 -96
  129. data/vendor/v8/src/arm/macro-assembler-arm.h +115 -18
  130. data/vendor/v8/src/arm/regexp-macro-assembler-arm.cc +20 -13
  131. data/vendor/v8/src/arm/regexp-macro-assembler-arm.h +1 -0
  132. data/vendor/v8/src/arm/simulator-arm.cc +184 -101
  133. data/vendor/v8/src/arm/simulator-arm.h +26 -21
  134. data/vendor/v8/src/arm/stub-cache-arm.cc +450 -467
  135. data/vendor/v8/src/arm/virtual-frame-arm.cc +14 -12
  136. data/vendor/v8/src/arm/virtual-frame-arm.h +11 -8
  137. data/vendor/v8/src/array.js +35 -18
  138. data/vendor/v8/src/assembler.cc +186 -92
  139. data/vendor/v8/src/assembler.h +106 -69
  140. data/vendor/v8/src/ast-inl.h +5 -0
  141. data/vendor/v8/src/ast.cc +46 -35
  142. data/vendor/v8/src/ast.h +107 -50
  143. data/vendor/v8/src/atomicops.h +2 -0
  144. data/vendor/v8/src/atomicops_internals_mips_gcc.h +169 -0
  145. data/vendor/v8/src/bootstrapper.cc +649 -399
  146. data/vendor/v8/src/bootstrapper.h +94 -27
  147. data/vendor/v8/src/builtins.cc +359 -227
  148. data/vendor/v8/src/builtins.h +157 -123
  149. data/vendor/v8/src/checks.cc +2 -2
  150. data/vendor/v8/src/checks.h +4 -0
  151. data/vendor/v8/src/code-stubs.cc +27 -17
  152. data/vendor/v8/src/code-stubs.h +38 -17
  153. data/vendor/v8/src/codegen-inl.h +5 -1
  154. data/vendor/v8/src/codegen.cc +27 -17
  155. data/vendor/v8/src/codegen.h +9 -9
  156. data/vendor/v8/src/compilation-cache.cc +92 -206
  157. data/vendor/v8/src/compilation-cache.h +205 -30
  158. data/vendor/v8/src/compiler.cc +107 -120
  159. data/vendor/v8/src/compiler.h +17 -2
  160. data/vendor/v8/src/contexts.cc +22 -15
  161. data/vendor/v8/src/contexts.h +14 -8
  162. data/vendor/v8/src/conversions.cc +86 -30
  163. data/vendor/v8/src/counters.cc +19 -4
  164. data/vendor/v8/src/counters.h +28 -16
  165. data/vendor/v8/src/cpu-profiler-inl.h +4 -3
  166. data/vendor/v8/src/cpu-profiler.cc +123 -72
  167. data/vendor/v8/src/cpu-profiler.h +33 -19
  168. data/vendor/v8/src/cpu.h +2 -0
  169. data/vendor/v8/src/d8-debug.cc +3 -3
  170. data/vendor/v8/src/d8-debug.h +7 -6
  171. data/vendor/v8/src/d8-posix.cc +2 -0
  172. data/vendor/v8/src/d8.cc +22 -12
  173. data/vendor/v8/src/d8.gyp +3 -0
  174. data/vendor/v8/src/d8.js +618 -0
  175. data/vendor/v8/src/data-flow.h +3 -3
  176. data/vendor/v8/src/dateparser.h +4 -2
  177. data/vendor/v8/src/debug-agent.cc +10 -9
  178. data/vendor/v8/src/debug-agent.h +9 -11
  179. data/vendor/v8/src/debug-debugger.js +121 -0
  180. data/vendor/v8/src/debug.cc +331 -227
  181. data/vendor/v8/src/debug.h +248 -219
  182. data/vendor/v8/src/deoptimizer.cc +173 -62
  183. data/vendor/v8/src/deoptimizer.h +119 -19
  184. data/vendor/v8/src/disasm.h +3 -0
  185. data/vendor/v8/src/disassembler.cc +10 -9
  186. data/vendor/v8/src/execution.cc +185 -129
  187. data/vendor/v8/src/execution.h +47 -78
  188. data/vendor/v8/src/extensions/experimental/break-iterator.cc +250 -0
  189. data/vendor/v8/src/extensions/experimental/break-iterator.h +89 -0
  190. data/vendor/v8/src/extensions/experimental/experimental.gyp +2 -0
  191. data/vendor/v8/src/extensions/experimental/i18n-extension.cc +22 -2
  192. data/vendor/v8/src/extensions/externalize-string-extension.cc +2 -2
  193. data/vendor/v8/src/extensions/gc-extension.cc +1 -1
  194. data/vendor/v8/src/factory.cc +261 -154
  195. data/vendor/v8/src/factory.h +162 -158
  196. data/vendor/v8/src/flag-definitions.h +17 -11
  197. data/vendor/v8/src/frame-element.cc +0 -5
  198. data/vendor/v8/src/frame-element.h +9 -13
  199. data/vendor/v8/src/frames-inl.h +7 -0
  200. data/vendor/v8/src/frames.cc +56 -46
  201. data/vendor/v8/src/frames.h +36 -25
  202. data/vendor/v8/src/full-codegen.cc +15 -24
  203. data/vendor/v8/src/full-codegen.h +13 -41
  204. data/vendor/v8/src/func-name-inferrer.cc +7 -6
  205. data/vendor/v8/src/func-name-inferrer.h +1 -1
  206. data/vendor/v8/src/gdb-jit.cc +1 -0
  207. data/vendor/v8/src/global-handles.cc +118 -56
  208. data/vendor/v8/src/global-handles.h +98 -40
  209. data/vendor/v8/src/globals.h +2 -2
  210. data/vendor/v8/src/handles-inl.h +106 -9
  211. data/vendor/v8/src/handles.cc +220 -157
  212. data/vendor/v8/src/handles.h +38 -59
  213. data/vendor/v8/src/hashmap.h +3 -3
  214. data/vendor/v8/src/heap-inl.h +141 -25
  215. data/vendor/v8/src/heap-profiler.cc +117 -63
  216. data/vendor/v8/src/heap-profiler.h +38 -21
  217. data/vendor/v8/src/heap.cc +805 -564
  218. data/vendor/v8/src/heap.h +640 -594
  219. data/vendor/v8/src/hydrogen-instructions.cc +216 -73
  220. data/vendor/v8/src/hydrogen-instructions.h +259 -124
  221. data/vendor/v8/src/hydrogen.cc +996 -1171
  222. data/vendor/v8/src/hydrogen.h +163 -144
  223. data/vendor/v8/src/ia32/assembler-ia32-inl.h +12 -11
  224. data/vendor/v8/src/ia32/assembler-ia32.cc +85 -39
  225. data/vendor/v8/src/ia32/assembler-ia32.h +82 -16
  226. data/vendor/v8/src/ia32/builtins-ia32.cc +64 -58
  227. data/vendor/v8/src/ia32/code-stubs-ia32.cc +248 -324
  228. data/vendor/v8/src/ia32/code-stubs-ia32.h +3 -44
  229. data/vendor/v8/src/ia32/codegen-ia32.cc +217 -165
  230. data/vendor/v8/src/ia32/codegen-ia32.h +3 -0
  231. data/vendor/v8/src/ia32/cpu-ia32.cc +6 -5
  232. data/vendor/v8/src/ia32/debug-ia32.cc +8 -5
  233. data/vendor/v8/src/ia32/deoptimizer-ia32.cc +124 -14
  234. data/vendor/v8/src/ia32/disasm-ia32.cc +85 -62
  235. data/vendor/v8/src/ia32/frames-ia32.h +1 -1
  236. data/vendor/v8/src/ia32/full-codegen-ia32.cc +348 -435
  237. data/vendor/v8/src/ia32/ic-ia32.cc +91 -91
  238. data/vendor/v8/src/ia32/lithium-codegen-ia32.cc +500 -255
  239. data/vendor/v8/src/ia32/lithium-codegen-ia32.h +13 -4
  240. data/vendor/v8/src/ia32/lithium-gap-resolver-ia32.cc +6 -0
  241. data/vendor/v8/src/ia32/lithium-ia32.cc +122 -45
  242. data/vendor/v8/src/ia32/lithium-ia32.h +128 -41
  243. data/vendor/v8/src/ia32/macro-assembler-ia32.cc +109 -84
  244. data/vendor/v8/src/ia32/macro-assembler-ia32.h +18 -9
  245. data/vendor/v8/src/ia32/regexp-macro-assembler-ia32.cc +26 -15
  246. data/vendor/v8/src/ia32/regexp-macro-assembler-ia32.h +1 -0
  247. data/vendor/v8/src/ia32/register-allocator-ia32.cc +30 -30
  248. data/vendor/v8/src/ia32/simulator-ia32.h +4 -4
  249. data/vendor/v8/src/ia32/stub-cache-ia32.cc +383 -400
  250. data/vendor/v8/src/ia32/virtual-frame-ia32.cc +36 -13
  251. data/vendor/v8/src/ia32/virtual-frame-ia32.h +11 -5
  252. data/vendor/v8/src/ic-inl.h +12 -2
  253. data/vendor/v8/src/ic.cc +304 -221
  254. data/vendor/v8/src/ic.h +115 -58
  255. data/vendor/v8/src/interpreter-irregexp.cc +25 -21
  256. data/vendor/v8/src/interpreter-irregexp.h +2 -1
  257. data/vendor/v8/src/isolate.cc +883 -0
  258. data/vendor/v8/src/isolate.h +1304 -0
  259. data/vendor/v8/src/json.js +10 -10
  260. data/vendor/v8/src/jsregexp.cc +111 -80
  261. data/vendor/v8/src/jsregexp.h +6 -7
  262. data/vendor/v8/src/jump-target-heavy.cc +5 -8
  263. data/vendor/v8/src/jump-target-heavy.h +0 -6
  264. data/vendor/v8/src/jump-target-inl.h +1 -1
  265. data/vendor/v8/src/jump-target-light.cc +3 -3
  266. data/vendor/v8/src/lithium-allocator-inl.h +2 -0
  267. data/vendor/v8/src/lithium-allocator.cc +42 -30
  268. data/vendor/v8/src/lithium-allocator.h +8 -22
  269. data/vendor/v8/src/lithium.cc +1 -0
  270. data/vendor/v8/src/liveedit.cc +141 -99
  271. data/vendor/v8/src/liveedit.h +7 -2
  272. data/vendor/v8/src/liveobjectlist-inl.h +90 -0
  273. data/vendor/v8/src/liveobjectlist.cc +2537 -1
  274. data/vendor/v8/src/liveobjectlist.h +245 -35
  275. data/vendor/v8/src/log-utils.cc +122 -35
  276. data/vendor/v8/src/log-utils.h +33 -36
  277. data/vendor/v8/src/log.cc +299 -241
  278. data/vendor/v8/src/log.h +177 -110
  279. data/vendor/v8/src/mark-compact.cc +612 -470
  280. data/vendor/v8/src/mark-compact.h +153 -80
  281. data/vendor/v8/src/messages.cc +16 -14
  282. data/vendor/v8/src/messages.js +30 -7
  283. data/vendor/v8/src/mips/assembler-mips-inl.h +155 -35
  284. data/vendor/v8/src/mips/assembler-mips.cc +1093 -219
  285. data/vendor/v8/src/mips/assembler-mips.h +552 -153
  286. data/vendor/v8/src/mips/builtins-mips.cc +43 -100
  287. data/vendor/v8/src/mips/code-stubs-mips.cc +752 -0
  288. data/vendor/v8/src/mips/code-stubs-mips.h +511 -0
  289. data/vendor/v8/src/mips/codegen-mips-inl.h +8 -14
  290. data/vendor/v8/src/mips/codegen-mips.cc +672 -896
  291. data/vendor/v8/src/mips/codegen-mips.h +271 -69
  292. data/vendor/v8/src/mips/constants-mips.cc +44 -20
  293. data/vendor/v8/src/mips/constants-mips.h +238 -40
  294. data/vendor/v8/src/mips/cpu-mips.cc +20 -3
  295. data/vendor/v8/src/mips/debug-mips.cc +35 -7
  296. data/vendor/v8/src/mips/deoptimizer-mips.cc +91 -0
  297. data/vendor/v8/src/mips/disasm-mips.cc +329 -93
  298. data/vendor/v8/src/mips/frames-mips.cc +2 -50
  299. data/vendor/v8/src/mips/frames-mips.h +24 -9
  300. data/vendor/v8/src/mips/full-codegen-mips.cc +473 -23
  301. data/vendor/v8/src/mips/ic-mips.cc +81 -45
  302. data/vendor/v8/src/mips/jump-target-mips.cc +11 -106
  303. data/vendor/v8/src/mips/lithium-codegen-mips.h +65 -0
  304. data/vendor/v8/src/mips/lithium-mips.h +304 -0
  305. data/vendor/v8/src/mips/macro-assembler-mips.cc +2391 -390
  306. data/vendor/v8/src/mips/macro-assembler-mips.h +718 -121
  307. data/vendor/v8/src/mips/regexp-macro-assembler-mips.cc +478 -0
  308. data/vendor/v8/src/mips/regexp-macro-assembler-mips.h +250 -0
  309. data/vendor/v8/src/mips/register-allocator-mips-inl.h +0 -3
  310. data/vendor/v8/src/mips/register-allocator-mips.h +3 -2
  311. data/vendor/v8/src/mips/simulator-mips.cc +1009 -221
  312. data/vendor/v8/src/mips/simulator-mips.h +119 -36
  313. data/vendor/v8/src/mips/stub-cache-mips.cc +331 -148
  314. data/vendor/v8/src/mips/{fast-codegen-mips.cc → virtual-frame-mips-inl.h} +11 -30
  315. data/vendor/v8/src/mips/virtual-frame-mips.cc +137 -149
  316. data/vendor/v8/src/mips/virtual-frame-mips.h +294 -312
  317. data/vendor/v8/src/mirror-debugger.js +9 -8
  318. data/vendor/v8/src/mksnapshot.cc +2 -2
  319. data/vendor/v8/src/objects-debug.cc +16 -16
  320. data/vendor/v8/src/objects-inl.h +421 -195
  321. data/vendor/v8/src/objects-printer.cc +7 -7
  322. data/vendor/v8/src/objects-visiting.cc +1 -1
  323. data/vendor/v8/src/objects-visiting.h +33 -12
  324. data/vendor/v8/src/objects.cc +935 -658
  325. data/vendor/v8/src/objects.h +234 -139
  326. data/vendor/v8/src/parser.cc +484 -439
  327. data/vendor/v8/src/parser.h +35 -14
  328. data/vendor/v8/src/platform-cygwin.cc +173 -107
  329. data/vendor/v8/src/platform-freebsd.cc +224 -72
  330. data/vendor/v8/src/platform-linux.cc +234 -95
  331. data/vendor/v8/src/platform-macos.cc +215 -82
  332. data/vendor/v8/src/platform-nullos.cc +9 -3
  333. data/vendor/v8/src/platform-openbsd.cc +22 -7
  334. data/vendor/v8/src/platform-posix.cc +30 -5
  335. data/vendor/v8/src/platform-solaris.cc +120 -38
  336. data/vendor/v8/src/platform-tls-mac.h +62 -0
  337. data/vendor/v8/src/platform-tls-win32.h +62 -0
  338. data/vendor/v8/src/platform-tls.h +50 -0
  339. data/vendor/v8/src/platform-win32.cc +195 -97
  340. data/vendor/v8/src/platform.h +72 -15
  341. data/vendor/v8/src/preparse-data.cc +2 -0
  342. data/vendor/v8/src/preparser-api.cc +8 -2
  343. data/vendor/v8/src/preparser.cc +1 -1
  344. data/vendor/v8/src/prettyprinter.cc +43 -52
  345. data/vendor/v8/src/prettyprinter.h +1 -1
  346. data/vendor/v8/src/profile-generator-inl.h +0 -28
  347. data/vendor/v8/src/profile-generator.cc +942 -685
  348. data/vendor/v8/src/profile-generator.h +210 -176
  349. data/vendor/v8/src/property.cc +6 -0
  350. data/vendor/v8/src/property.h +14 -3
  351. data/vendor/v8/src/regexp-macro-assembler-irregexp.cc +1 -1
  352. data/vendor/v8/src/regexp-macro-assembler.cc +28 -19
  353. data/vendor/v8/src/regexp-macro-assembler.h +11 -6
  354. data/vendor/v8/src/regexp-stack.cc +18 -10
  355. data/vendor/v8/src/regexp-stack.h +45 -21
  356. data/vendor/v8/src/regexp.js +3 -3
  357. data/vendor/v8/src/register-allocator-inl.h +3 -3
  358. data/vendor/v8/src/register-allocator.cc +1 -7
  359. data/vendor/v8/src/register-allocator.h +5 -15
  360. data/vendor/v8/src/rewriter.cc +2 -1
  361. data/vendor/v8/src/runtime-profiler.cc +158 -128
  362. data/vendor/v8/src/runtime-profiler.h +131 -15
  363. data/vendor/v8/src/runtime.cc +2409 -1692
  364. data/vendor/v8/src/runtime.h +93 -17
  365. data/vendor/v8/src/safepoint-table.cc +3 -0
  366. data/vendor/v8/src/safepoint-table.h +9 -3
  367. data/vendor/v8/src/scanner-base.cc +21 -28
  368. data/vendor/v8/src/scanner-base.h +22 -11
  369. data/vendor/v8/src/scanner.cc +3 -5
  370. data/vendor/v8/src/scanner.h +4 -2
  371. data/vendor/v8/src/scopeinfo.cc +11 -16
  372. data/vendor/v8/src/scopeinfo.h +26 -15
  373. data/vendor/v8/src/scopes.cc +67 -37
  374. data/vendor/v8/src/scopes.h +26 -12
  375. data/vendor/v8/src/serialize.cc +193 -154
  376. data/vendor/v8/src/serialize.h +41 -36
  377. data/vendor/v8/src/small-pointer-list.h +163 -0
  378. data/vendor/v8/src/snapshot-common.cc +1 -1
  379. data/vendor/v8/src/snapshot.h +3 -1
  380. data/vendor/v8/src/spaces-inl.h +30 -25
  381. data/vendor/v8/src/spaces.cc +263 -370
  382. data/vendor/v8/src/spaces.h +178 -166
  383. data/vendor/v8/src/string-search.cc +4 -3
  384. data/vendor/v8/src/string-search.h +21 -20
  385. data/vendor/v8/src/string-stream.cc +32 -24
  386. data/vendor/v8/src/string.js +7 -7
  387. data/vendor/v8/src/stub-cache.cc +324 -248
  388. data/vendor/v8/src/stub-cache.h +181 -155
  389. data/vendor/v8/src/token.cc +3 -3
  390. data/vendor/v8/src/token.h +3 -3
  391. data/vendor/v8/src/top.cc +218 -390
  392. data/vendor/v8/src/type-info.cc +98 -32
  393. data/vendor/v8/src/type-info.h +10 -3
  394. data/vendor/v8/src/unicode.cc +1 -1
  395. data/vendor/v8/src/unicode.h +1 -1
  396. data/vendor/v8/src/utils.h +3 -0
  397. data/vendor/v8/src/v8-counters.cc +18 -11
  398. data/vendor/v8/src/v8-counters.h +34 -13
  399. data/vendor/v8/src/v8.cc +66 -121
  400. data/vendor/v8/src/v8.h +7 -4
  401. data/vendor/v8/src/v8globals.h +18 -12
  402. data/vendor/v8/src/{memory.h → v8memory.h} +0 -0
  403. data/vendor/v8/src/v8natives.js +59 -18
  404. data/vendor/v8/src/v8threads.cc +127 -114
  405. data/vendor/v8/src/v8threads.h +42 -35
  406. data/vendor/v8/src/v8utils.h +2 -39
  407. data/vendor/v8/src/variables.h +1 -1
  408. data/vendor/v8/src/version.cc +26 -5
  409. data/vendor/v8/src/version.h +4 -0
  410. data/vendor/v8/src/virtual-frame-heavy-inl.h +2 -4
  411. data/vendor/v8/src/virtual-frame-light-inl.h +5 -4
  412. data/vendor/v8/src/vm-state-inl.h +21 -17
  413. data/vendor/v8/src/vm-state.h +7 -5
  414. data/vendor/v8/src/win32-headers.h +1 -0
  415. data/vendor/v8/src/x64/assembler-x64-inl.h +12 -11
  416. data/vendor/v8/src/x64/assembler-x64.cc +80 -40
  417. data/vendor/v8/src/x64/assembler-x64.h +67 -17
  418. data/vendor/v8/src/x64/builtins-x64.cc +34 -33
  419. data/vendor/v8/src/x64/code-stubs-x64.cc +636 -377
  420. data/vendor/v8/src/x64/code-stubs-x64.h +14 -48
  421. data/vendor/v8/src/x64/codegen-x64-inl.h +1 -1
  422. data/vendor/v8/src/x64/codegen-x64.cc +158 -136
  423. data/vendor/v8/src/x64/codegen-x64.h +4 -1
  424. data/vendor/v8/src/x64/cpu-x64.cc +7 -5
  425. data/vendor/v8/src/x64/debug-x64.cc +8 -6
  426. data/vendor/v8/src/x64/deoptimizer-x64.cc +195 -20
  427. data/vendor/v8/src/x64/disasm-x64.cc +42 -23
  428. data/vendor/v8/src/x64/frames-x64.cc +1 -1
  429. data/vendor/v8/src/x64/frames-x64.h +2 -2
  430. data/vendor/v8/src/x64/full-codegen-x64.cc +780 -218
  431. data/vendor/v8/src/x64/ic-x64.cc +77 -79
  432. data/vendor/v8/src/x64/jump-target-x64.cc +1 -1
  433. data/vendor/v8/src/x64/lithium-codegen-x64.cc +698 -181
  434. data/vendor/v8/src/x64/lithium-codegen-x64.h +31 -6
  435. data/vendor/v8/src/x64/lithium-x64.cc +136 -54
  436. data/vendor/v8/src/x64/lithium-x64.h +142 -51
  437. data/vendor/v8/src/x64/macro-assembler-x64.cc +456 -187
  438. data/vendor/v8/src/x64/macro-assembler-x64.h +166 -34
  439. data/vendor/v8/src/x64/regexp-macro-assembler-x64.cc +44 -28
  440. data/vendor/v8/src/x64/regexp-macro-assembler-x64.h +8 -4
  441. data/vendor/v8/src/x64/register-allocator-x64-inl.h +3 -3
  442. data/vendor/v8/src/x64/register-allocator-x64.cc +12 -8
  443. data/vendor/v8/src/x64/simulator-x64.h +5 -5
  444. data/vendor/v8/src/x64/stub-cache-x64.cc +299 -344
  445. data/vendor/v8/src/x64/virtual-frame-x64.cc +37 -13
  446. data/vendor/v8/src/x64/virtual-frame-x64.h +13 -7
  447. data/vendor/v8/src/zone-inl.h +49 -3
  448. data/vendor/v8/src/zone.cc +42 -41
  449. data/vendor/v8/src/zone.h +37 -34
  450. data/vendor/v8/test/benchmarks/testcfg.py +100 -0
  451. data/vendor/v8/test/cctest/SConscript +5 -4
  452. data/vendor/v8/test/cctest/cctest.h +3 -2
  453. data/vendor/v8/test/cctest/cctest.status +6 -11
  454. data/vendor/v8/test/cctest/test-accessors.cc +3 -3
  455. data/vendor/v8/test/cctest/test-alloc.cc +39 -33
  456. data/vendor/v8/test/cctest/test-api.cc +1092 -205
  457. data/vendor/v8/test/cctest/test-assembler-arm.cc +39 -25
  458. data/vendor/v8/test/cctest/test-assembler-ia32.cc +36 -37
  459. data/vendor/v8/test/cctest/test-assembler-mips.cc +1098 -40
  460. data/vendor/v8/test/cctest/test-assembler-x64.cc +32 -25
  461. data/vendor/v8/test/cctest/test-ast.cc +1 -0
  462. data/vendor/v8/test/cctest/test-circular-queue.cc +8 -5
  463. data/vendor/v8/test/cctest/test-compiler.cc +24 -24
  464. data/vendor/v8/test/cctest/test-cpu-profiler.cc +140 -5
  465. data/vendor/v8/test/cctest/test-dataflow.cc +1 -0
  466. data/vendor/v8/test/cctest/test-debug.cc +136 -77
  467. data/vendor/v8/test/cctest/test-decls.cc +1 -1
  468. data/vendor/v8/test/cctest/test-deoptimization.cc +25 -24
  469. data/vendor/v8/test/cctest/test-disasm-arm.cc +9 -4
  470. data/vendor/v8/test/cctest/test-disasm-ia32.cc +10 -8
  471. data/vendor/v8/test/cctest/test-func-name-inference.cc +10 -4
  472. data/vendor/v8/test/cctest/test-heap-profiler.cc +226 -164
  473. data/vendor/v8/test/cctest/test-heap.cc +240 -217
  474. data/vendor/v8/test/cctest/test-liveedit.cc +1 -0
  475. data/vendor/v8/test/cctest/test-log-stack-tracer.cc +18 -20
  476. data/vendor/v8/test/cctest/test-log.cc +114 -108
  477. data/vendor/v8/test/cctest/test-macro-assembler-x64.cc +247 -177
  478. data/vendor/v8/test/cctest/test-mark-compact.cc +129 -90
  479. data/vendor/v8/test/cctest/test-parsing.cc +15 -14
  480. data/vendor/v8/test/cctest/test-platform-linux.cc +1 -0
  481. data/vendor/v8/test/cctest/test-platform-tls.cc +66 -0
  482. data/vendor/v8/test/cctest/test-platform-win32.cc +1 -0
  483. data/vendor/v8/test/cctest/test-profile-generator.cc +1 -1
  484. data/vendor/v8/test/cctest/test-regexp.cc +53 -41
  485. data/vendor/v8/test/cctest/test-reloc-info.cc +18 -11
  486. data/vendor/v8/test/cctest/test-serialize.cc +44 -43
  487. data/vendor/v8/test/cctest/test-sockets.cc +8 -3
  488. data/vendor/v8/test/cctest/test-spaces.cc +47 -29
  489. data/vendor/v8/test/cctest/test-strings.cc +20 -20
  490. data/vendor/v8/test/cctest/test-thread-termination.cc +8 -3
  491. data/vendor/v8/test/cctest/test-threads.cc +5 -3
  492. data/vendor/v8/test/cctest/test-utils.cc +5 -4
  493. data/vendor/v8/test/cctest/testcfg.py +7 -3
  494. data/vendor/v8/test/es5conform/es5conform.status +2 -77
  495. data/vendor/v8/test/es5conform/testcfg.py +1 -1
  496. data/vendor/v8/test/message/testcfg.py +1 -1
  497. data/vendor/v8/test/mjsunit/accessors-on-global-object.js +3 -3
  498. data/vendor/v8/test/mjsunit/array-concat.js +43 -1
  499. data/vendor/v8/test/mjsunit/array-join.js +25 -0
  500. data/vendor/v8/test/mjsunit/bitops-info.js +7 -1
  501. data/vendor/v8/test/mjsunit/compiler/array-length.js +2 -2
  502. data/vendor/v8/test/mjsunit/compiler/global-accessors.js +47 -0
  503. data/vendor/v8/test/mjsunit/compiler/pic.js +1 -1
  504. data/vendor/v8/test/mjsunit/compiler/regress-loadfield.js +65 -0
  505. data/vendor/v8/test/mjsunit/math-sqrt.js +5 -1
  506. data/vendor/v8/test/mjsunit/mjsunit.js +59 -8
  507. data/vendor/v8/test/mjsunit/mjsunit.status +0 -12
  508. data/vendor/v8/test/mjsunit/mul-exhaustive.js +129 -11
  509. data/vendor/v8/test/mjsunit/negate-zero.js +1 -1
  510. data/vendor/v8/test/mjsunit/object-freeze.js +5 -13
  511. data/vendor/v8/test/mjsunit/object-prevent-extensions.js +9 -50
  512. data/vendor/v8/test/mjsunit/object-seal.js +4 -13
  513. data/vendor/v8/test/mjsunit/override-eval-with-non-function.js +36 -0
  514. data/vendor/v8/test/mjsunit/regress/regress-1145.js +54 -0
  515. data/vendor/v8/test/mjsunit/regress/regress-1172-bis.js +37 -0
  516. data/vendor/v8/test/mjsunit/regress/regress-1181.js +54 -0
  517. data/vendor/v8/test/mjsunit/regress/regress-1207.js +35 -0
  518. data/vendor/v8/test/mjsunit/regress/regress-1209.js +34 -0
  519. data/vendor/v8/test/mjsunit/regress/regress-1210.js +48 -0
  520. data/vendor/v8/test/mjsunit/regress/regress-1213.js +43 -0
  521. data/vendor/v8/test/mjsunit/regress/regress-1218.js +29 -0
  522. data/vendor/v8/test/mjsunit/regress/regress-1229.js +79 -0
  523. data/vendor/v8/test/mjsunit/regress/regress-1233.js +47 -0
  524. data/vendor/v8/test/mjsunit/regress/regress-1236.js +34 -0
  525. data/vendor/v8/test/mjsunit/regress/regress-1237.js +36 -0
  526. data/vendor/v8/test/mjsunit/regress/regress-1240.js +39 -0
  527. data/vendor/v8/test/mjsunit/regress/regress-1257.js +58 -0
  528. data/vendor/v8/test/mjsunit/regress/regress-1278.js +69 -0
  529. data/vendor/v8/test/mjsunit/regress/regress-create-exception.js +1 -0
  530. data/vendor/v8/test/mjsunit/regress/regress-lazy-deopt-reloc.js +52 -0
  531. data/vendor/v8/test/mjsunit/sin-cos.js +15 -10
  532. data/vendor/v8/test/mjsunit/smi-negative-zero.js +2 -2
  533. data/vendor/v8/test/mjsunit/str-to-num.js +1 -1
  534. data/vendor/v8/test/mjsunit/strict-mode.js +435 -0
  535. data/vendor/v8/test/mjsunit/testcfg.py +23 -6
  536. data/vendor/v8/test/mozilla/mozilla.status +0 -2
  537. data/vendor/v8/test/mozilla/testcfg.py +1 -1
  538. data/vendor/v8/test/preparser/empty.js +28 -0
  539. data/vendor/v8/test/preparser/functions-only.js +38 -0
  540. data/vendor/v8/test/preparser/non-alphanum.js +34 -0
  541. data/vendor/v8/test/preparser/symbols-only.js +49 -0
  542. data/vendor/v8/test/preparser/testcfg.py +90 -0
  543. data/vendor/v8/test/sputnik/testcfg.py +1 -1
  544. data/vendor/v8/test/test262/README +16 -0
  545. data/vendor/v8/test/test262/harness-adapt.js +80 -0
  546. data/vendor/v8/test/test262/test262.status +1506 -0
  547. data/vendor/v8/test/test262/testcfg.py +123 -0
  548. data/vendor/v8/tools/freebsd-tick-processor +10 -0
  549. data/vendor/v8/tools/gyp/v8.gyp +8 -33
  550. data/vendor/v8/tools/linux-tick-processor +5 -3
  551. data/vendor/v8/tools/test.py +37 -14
  552. data/vendor/v8/tools/tickprocessor.js +22 -8
  553. data/vendor/v8/tools/visual_studio/v8_base.vcproj +13 -1
  554. data/vendor/v8/tools/visual_studio/v8_base_arm.vcproj +5 -1
  555. data/vendor/v8/tools/visual_studio/v8_base_x64.vcproj +5 -1
  556. data/vendor/v8/tools/visual_studio/x64.vsprops +1 -0
  557. metadata +1495 -1341
  558. data/ext/extconf.rb +0 -22
  559. data/ext/mustang.cpp +0 -58
  560. data/vendor/v8/src/top.h +0 -608
@@ -30,11 +30,13 @@
30
30
  #define V8_MIPS_VIRTUAL_FRAME_MIPS_H_
31
31
 
32
32
  #include "register-allocator.h"
33
- #include "scopes.h"
34
33
 
35
34
  namespace v8 {
36
35
  namespace internal {
37
36
 
37
+ // This dummy class is only used to create invalid virtual frames.
38
+ extern class InvalidVirtualFrameInitializer {}* kInvalidVirtualFrameInitializer;
39
+
38
40
 
39
41
  // -------------------------------------------------------------------------
40
42
  // Virtual frames
@@ -47,14 +49,54 @@ namespace internal {
47
49
 
48
50
  class VirtualFrame : public ZoneObject {
49
51
  public:
52
+ class RegisterAllocationScope;
50
53
  // A utility class to introduce a scope where the virtual frame is
51
54
  // expected to remain spilled. The constructor spills the code
52
- // generator's current frame, but no attempt is made to require it
53
- // to stay spilled. It is intended as documentation while the code
54
- // generator is being transformed.
55
+ // generator's current frame, and keeps it spilled.
55
56
  class SpilledScope BASE_EMBEDDED {
56
57
  public:
58
+ explicit SpilledScope(VirtualFrame* frame)
59
+ : old_is_spilled_(
60
+ Isolate::Current()->is_virtual_frame_in_spilled_scope()) {
61
+ if (frame != NULL) {
62
+ if (!old_is_spilled_) {
63
+ frame->SpillAll();
64
+ } else {
65
+ frame->AssertIsSpilled();
66
+ }
67
+ }
68
+ Isolate::Current()->set_is_virtual_frame_in_spilled_scope(true);
69
+ }
70
+ ~SpilledScope() {
71
+ Isolate::Current()->set_is_virtual_frame_in_spilled_scope(
72
+ old_is_spilled_);
73
+ }
74
+ static bool is_spilled() {
75
+ return Isolate::Current()->is_virtual_frame_in_spilled_scope();
76
+ }
77
+
78
+ private:
79
+ int old_is_spilled_;
80
+
57
81
  SpilledScope() {}
82
+
83
+ friend class RegisterAllocationScope;
84
+ };
85
+
86
+ class RegisterAllocationScope BASE_EMBEDDED {
87
+ public:
88
+ // A utility class to introduce a scope where the virtual frame
89
+ // is not spilled, ie. where register allocation occurs. Eventually
90
+ // when RegisterAllocationScope is ubiquitous it can be removed
91
+ // along with the (by then unused) SpilledScope class.
92
+ inline explicit RegisterAllocationScope(CodeGenerator* cgen);
93
+ inline ~RegisterAllocationScope();
94
+
95
+ private:
96
+ CodeGenerator* cgen_;
97
+ bool old_is_spilled_;
98
+
99
+ RegisterAllocationScope() {}
58
100
  };
59
101
 
60
102
  // An illegal index into the virtual frame.
@@ -63,45 +105,49 @@ class VirtualFrame : public ZoneObject {
63
105
  // Construct an initial virtual frame on entry to a JS function.
64
106
  inline VirtualFrame();
65
107
 
108
+ // Construct an invalid virtual frame, used by JumpTargets.
109
+ inline VirtualFrame(InvalidVirtualFrameInitializer* dummy);
110
+
66
111
  // Construct a virtual frame as a clone of an existing one.
67
112
  explicit inline VirtualFrame(VirtualFrame* original);
68
113
 
69
- CodeGenerator* cgen() { return CodeGeneratorScope::Current(); }
70
- MacroAssembler* masm() { return cgen()->masm(); }
71
-
72
- // Create a duplicate of an existing valid frame element.
73
- FrameElement CopyElementAt(int index,
74
- NumberInfo info = NumberInfo::Unknown());
114
+ inline CodeGenerator* cgen() const;
115
+ inline MacroAssembler* masm();
75
116
 
76
117
  // The number of elements on the virtual frame.
77
- int element_count() { return elements_.length(); }
118
+ int element_count() const { return element_count_; }
78
119
 
79
120
  // The height of the virtual expression stack.
80
- int height() {
81
- return element_count() - expression_base_index();
82
- }
83
-
84
- int register_location(int num) {
85
- ASSERT(num >= 0 && num < RegisterAllocator::kNumRegisters);
86
- return register_locations_[num];
87
- }
88
-
89
- int register_location(Register reg) {
90
- return register_locations_[RegisterAllocator::ToNumber(reg)];
91
- }
92
-
93
- void set_register_location(Register reg, int index) {
94
- register_locations_[RegisterAllocator::ToNumber(reg)] = index;
95
- }
121
+ inline int height() const;
96
122
 
97
123
  bool is_used(int num) {
98
- ASSERT(num >= 0 && num < RegisterAllocator::kNumRegisters);
99
- return register_locations_[num] != kIllegalIndex;
100
- }
101
-
102
- bool is_used(Register reg) {
103
- return register_locations_[RegisterAllocator::ToNumber(reg)]
104
- != kIllegalIndex;
124
+ switch (num) {
125
+ case 0: { // a0.
126
+ return kA0InUse[top_of_stack_state_];
127
+ }
128
+ case 1: { // a1.
129
+ return kA1InUse[top_of_stack_state_];
130
+ }
131
+ case 2:
132
+ case 3:
133
+ case 4:
134
+ case 5:
135
+ case 6: { // a2 to a3, t0 to t2.
136
+ ASSERT(num - kFirstAllocatedRegister < kNumberOfAllocatedRegisters);
137
+ ASSERT(num >= kFirstAllocatedRegister);
138
+ if ((register_allocation_map_ &
139
+ (1 << (num - kFirstAllocatedRegister))) == 0) {
140
+ return false;
141
+ } else {
142
+ return true;
143
+ }
144
+ }
145
+ default: {
146
+ ASSERT(num < kFirstAllocatedRegister ||
147
+ num >= kFirstAllocatedRegister + kNumberOfAllocatedRegisters);
148
+ return false;
149
+ }
150
+ }
105
151
  }
106
152
 
107
153
  // Add extra in-memory elements to the top of the frame to match an actual
@@ -110,53 +156,60 @@ class VirtualFrame : public ZoneObject {
110
156
  void Adjust(int count);
111
157
 
112
158
  // Forget elements from the top of the frame to match an actual frame (eg,
113
- // the frame after a runtime call). No code is emitted.
114
- void Forget(int count) {
115
- ASSERT(count >= 0);
116
- ASSERT(stack_pointer_ == element_count() - 1);
117
- stack_pointer_ -= count;
118
- // On mips, all elements are in memory, so there is no extra bookkeeping
119
- // (registers, copies, etc.) beyond dropping the elements.
120
- elements_.Rewind(stack_pointer_ + 1);
121
- }
159
+ // the frame after a runtime call). No code is emitted except to bring the
160
+ // frame to a spilled state.
161
+ void Forget(int count);
122
162
 
123
- // Forget count elements from the top of the frame and adjust the stack
124
- // pointer downward. This is used, for example, before merging frames at
125
- // break, continue, and return targets.
126
- void ForgetElements(int count);
127
163
 
128
164
  // Spill all values from the frame to memory.
129
165
  void SpillAll();
130
166
 
167
+ void AssertIsSpilled() const {
168
+ ASSERT(top_of_stack_state_ == NO_TOS_REGISTERS);
169
+ ASSERT(register_allocation_map_ == 0);
170
+ }
171
+
172
+ void AssertIsNotSpilled() {
173
+ ASSERT(!SpilledScope::is_spilled());
174
+ }
175
+
131
176
  // Spill all occurrences of a specific register from the frame.
132
177
  void Spill(Register reg) {
133
- if (is_used(reg)) SpillElementAt(register_location(reg));
178
+ UNIMPLEMENTED();
134
179
  }
135
180
 
136
181
  // Spill all occurrences of an arbitrary register if possible. Return the
137
182
  // register spilled or no_reg if it was not possible to free any register
138
- // (ie, they all have frame-external references).
183
+ // (ie, they all have frame-external references). Unimplemented.
139
184
  Register SpillAnyRegister();
140
185
 
141
- // Prepare this virtual frame for merging to an expected frame by
142
- // performing some state changes that do not require generating
143
- // code. It is guaranteed that no code will be generated.
144
- void PrepareMergeTo(VirtualFrame* expected);
145
-
146
186
  // Make this virtual frame have a state identical to an expected virtual
147
187
  // frame. As a side effect, code may be emitted to make this frame match
148
188
  // the expected one.
149
- void MergeTo(VirtualFrame* expected);
189
+ void MergeTo(const VirtualFrame* expected,
190
+ Condition cond = al,
191
+ Register r1 = no_reg,
192
+ const Operand& r2 = Operand(no_reg));
193
+
194
+ void MergeTo(VirtualFrame* expected,
195
+ Condition cond = al,
196
+ Register r1 = no_reg,
197
+ const Operand& r2 = Operand(no_reg));
198
+
199
+ // Checks whether this frame can be branched to by the other frame.
200
+ bool IsCompatibleWith(const VirtualFrame* other) const {
201
+ return (tos_known_smi_map_ & (~other->tos_known_smi_map_)) == 0;
202
+ }
203
+
204
+ inline void ForgetTypeInfo() {
205
+ tos_known_smi_map_ = 0;
206
+ }
150
207
 
151
208
  // Detach a frame from its code generator, perhaps temporarily. This
152
209
  // tells the register allocator that it is free to use frame-internal
153
210
  // registers. Used when the code generator's frame is switched from this
154
211
  // one to NULL by an unconditional jump.
155
212
  void DetachFromCodeGenerator() {
156
- RegisterAllocator* cgen_allocator = cgen()->allocator();
157
- for (int i = 0; i < RegisterAllocator::kNumRegisters; i++) {
158
- if (is_used(i)) cgen_allocator->Unuse(i);
159
- }
160
213
  }
161
214
 
162
215
  // (Re)attach a frame to its code generator. This informs the register
@@ -164,10 +217,6 @@ class VirtualFrame : public ZoneObject {
164
217
  // Used when a code generator's frame is switched from NULL to this one by
165
218
  // binding a label.
166
219
  void AttachToCodeGenerator() {
167
- RegisterAllocator* cgen_allocator = cgen()->allocator();
168
- for (int i = 0; i < RegisterAllocator::kNumRegisters; i++) {
169
- if (is_used(i)) cgen_allocator->Unuse(i);
170
- }
171
220
  }
172
221
 
173
222
  // Emit code for the physical JS entry and exit frame sequences. After
@@ -177,176 +226,142 @@ class VirtualFrame : public ZoneObject {
177
226
  void Enter();
178
227
  void Exit();
179
228
 
180
- // Prepare for returning from the frame by spilling locals and
181
- // dropping all non-locals elements in the virtual frame. This
182
- // avoids generating unnecessary merge code when jumping to the
183
- // shared return site. Emits code for spills.
184
- void PrepareForReturn();
229
+ // Prepare for returning from the frame by elements in the virtual frame.
230
+ // This avoids generating unnecessary merge code when jumping to the shared
231
+ // return site. No spill code emitted. Value to return should be in v0.
232
+ inline void PrepareForReturn();
233
+
234
+ // Number of local variables after when we use a loop for allocating.
235
+ static const int kLocalVarBound = 5;
185
236
 
186
237
  // Allocate and initialize the frame-allocated locals.
187
238
  void AllocateStackSlots();
188
239
 
189
240
  // The current top of the expression stack as an assembly operand.
190
- MemOperand Top() { return MemOperand(sp, 0); }
241
+ MemOperand Top() {
242
+ AssertIsSpilled();
243
+ return MemOperand(sp, 0);
244
+ }
191
245
 
192
246
  // An element of the expression stack as an assembly operand.
193
247
  MemOperand ElementAt(int index) {
194
- return MemOperand(sp, index * kPointerSize);
195
- }
196
-
197
- // Random-access store to a frame-top relative frame element. The result
198
- // becomes owned by the frame and is invalidated.
199
- void SetElementAt(int index, Result* value);
200
-
201
- // Set a frame element to a constant. The index is frame-top relative.
202
- void SetElementAt(int index, Handle<Object> value) {
203
- Result temp(value);
204
- SetElementAt(index, &temp);
248
+ int adjusted_index = index - kVirtualElements[top_of_stack_state_];
249
+ ASSERT(adjusted_index >= 0);
250
+ return MemOperand(sp, adjusted_index * kPointerSize);
205
251
  }
206
252
 
207
- void PushElementAt(int index) {
208
- PushFrameSlotAt(element_count() - index - 1);
253
+ bool KnownSmiAt(int index) {
254
+ if (index >= kTOSKnownSmiMapSize) return false;
255
+ return (tos_known_smi_map_ & (1 << index)) != 0;
209
256
  }
210
-
211
257
  // A frame-allocated local as an assembly operand.
212
- MemOperand LocalAt(int index) {
213
- ASSERT(0 <= index);
214
- ASSERT(index < local_count());
215
- return MemOperand(s8_fp, kLocal0Offset - index * kPointerSize);
216
- }
217
-
218
- // Push a copy of the value of a local frame slot on top of the frame.
219
- void PushLocalAt(int index) {
220
- PushFrameSlotAt(local0_index() + index);
221
- }
222
-
223
- // Push the value of a local frame slot on top of the frame and invalidate
224
- // the local slot. The slot should be written to before trying to read
225
- // from it again.
226
- void TakeLocalAt(int index) {
227
- TakeFrameSlotAt(local0_index() + index);
228
- }
229
-
230
- // Store the top value on the virtual frame into a local frame slot. The
231
- // value is left in place on top of the frame.
232
- void StoreToLocalAt(int index) {
233
- StoreToFrameSlotAt(local0_index() + index);
234
- }
258
+ inline MemOperand LocalAt(int index);
235
259
 
236
260
  // Push the address of the receiver slot on the frame.
237
261
  void PushReceiverSlotAddress();
238
262
 
239
263
  // The function frame slot.
240
- MemOperand Function() { return MemOperand(s8_fp, kFunctionOffset); }
241
-
242
- // Push the function on top of the frame.
243
- void PushFunction() { PushFrameSlotAt(function_index()); }
264
+ MemOperand Function() { return MemOperand(fp, kFunctionOffset); }
244
265
 
245
266
  // The context frame slot.
246
- MemOperand Context() { return MemOperand(s8_fp, kContextOffset); }
247
-
248
- // Save the value of the cp register to the context frame slot.
249
- void SaveContextRegister();
250
-
251
- // Restore the cp register from the value of the context frame
252
- // slot.
253
- void RestoreContextRegister();
267
+ MemOperand Context() { return MemOperand(fp, kContextOffset); }
254
268
 
255
269
  // A parameter as an assembly operand.
256
- MemOperand ParameterAt(int index) {
257
- // Index -1 corresponds to the receiver.
258
- ASSERT(-1 <= index); // -1 is the receiver.
259
- ASSERT(index <= parameter_count());
260
- uint16_t a = 0; // Number of argument slots.
261
- return MemOperand(s8_fp, (1 + parameter_count() + a - index) *kPointerSize);
262
- }
263
-
264
- // Push a copy of the value of a parameter frame slot on top of the frame.
265
- void PushParameterAt(int index) {
266
- PushFrameSlotAt(param0_index() + index);
267
- }
268
-
269
- // Push the value of a paramter frame slot on top of the frame and
270
- // invalidate the parameter slot. The slot should be written to before
271
- // trying to read from it again.
272
- void TakeParameterAt(int index) {
273
- TakeFrameSlotAt(param0_index() + index);
274
- }
275
-
276
- // Store the top value on the virtual frame into a parameter frame slot.
277
- // The value is left in place on top of the frame.
278
- void StoreToParameterAt(int index) {
279
- StoreToFrameSlotAt(param0_index() + index);
280
- }
270
+ inline MemOperand ParameterAt(int index);
281
271
 
282
272
  // The receiver frame slot.
283
- MemOperand Receiver() { return ParameterAt(-1); }
273
+ inline MemOperand Receiver();
284
274
 
285
275
  // Push a try-catch or try-finally handler on top of the virtual frame.
286
276
  void PushTryHandler(HandlerType type);
287
277
 
288
278
  // Call stub given the number of arguments it expects on (and
289
279
  // removes from) the stack.
290
- void CallStub(CodeStub* stub, int arg_count) {
291
- PrepareForCall(arg_count, arg_count);
292
- RawCallStub(stub);
293
- }
280
+ inline void CallStub(CodeStub* stub, int arg_count);
294
281
 
295
- void CallStub(CodeStub* stub, Result* arg);
296
-
297
- void CallStub(CodeStub* stub, Result* arg0, Result* arg1);
282
+ // Call JS function from top of the stack with arguments
283
+ // taken from the stack.
284
+ void CallJSFunction(int arg_count);
298
285
 
299
286
  // Call runtime given the number of arguments expected on (and
300
287
  // removed from) the stack.
301
- void CallRuntime(Runtime::Function* f, int arg_count);
288
+ void CallRuntime(const Runtime::Function* f, int arg_count);
302
289
  void CallRuntime(Runtime::FunctionId id, int arg_count);
303
290
 
304
- // Call runtime with sp aligned to 8 bytes.
305
- void CallAlignedRuntime(Runtime::Function* f, int arg_count);
306
- void CallAlignedRuntime(Runtime::FunctionId id, int arg_count);
291
+ #ifdef ENABLE_DEBUGGER_SUPPORT
292
+ void DebugBreak();
293
+ #endif
307
294
 
308
295
  // Invoke builtin given the number of arguments it expects on (and
309
296
  // removes from) the stack.
310
297
  void InvokeBuiltin(Builtins::JavaScript id,
311
298
  InvokeJSFlags flag,
312
- Result* arg_count_register,
313
299
  int arg_count);
314
300
 
301
+ // Call load IC. Receiver is on the stack and is consumed. Result is returned
302
+ // in v0.
303
+ void CallLoadIC(Handle<String> name, RelocInfo::Mode mode);
304
+
305
+ // Call store IC. If the load is contextual, value is found on top of the
306
+ // frame. If not, value and receiver are on the frame. Both are consumed.
307
+ // Result is returned in v0.
308
+ void CallStoreIC(Handle<String> name, bool is_contextual);
309
+
310
+ // Call keyed load IC. Key and receiver are on the stack. Both are consumed.
311
+ // Result is returned in v0.
312
+ void CallKeyedLoadIC();
313
+
314
+ // Call keyed store IC. Value, key and receiver are on the stack. All three
315
+ // are consumed. Result is returned in v0 (and a0).
316
+ void CallKeyedStoreIC();
317
+
315
318
  // Call into an IC stub given the number of arguments it removes
316
- // from the stack. Register arguments are passed as results and
317
- // consumed by the call.
318
- void CallCodeObject(Handle<Code> ic,
319
- RelocInfo::Mode rmode,
320
- int dropped_args);
319
+ // from the stack. Register arguments to the IC stub are implicit,
320
+ // and depend on the type of IC stub.
321
321
  void CallCodeObject(Handle<Code> ic,
322
322
  RelocInfo::Mode rmode,
323
- Result* arg,
324
323
  int dropped_args);
325
- void CallCodeObject(Handle<Code> ic,
326
- RelocInfo::Mode rmode,
327
- Result* arg0,
328
- Result* arg1,
329
- int dropped_args,
330
- bool set_auto_args_slots = false);
331
324
 
332
325
  // Drop a number of elements from the top of the expression stack. May
333
326
  // emit code to affect the physical frame. Does not clobber any registers
334
327
  // excepting possibly the stack pointer.
335
328
  void Drop(int count);
336
- // Similar to VirtualFrame::Drop but we don't modify the actual stack.
337
- // This is because we need to manually restore sp to the correct position.
338
- void DropFromVFrameOnly(int count);
339
329
 
340
330
  // Drop one element.
341
331
  void Drop() { Drop(1); }
342
- void DropFromVFrameOnly() { DropFromVFrameOnly(1); }
343
332
 
344
- // Duplicate the top element of the frame.
345
- void Dup() { PushFrameSlotAt(element_count() - 1); }
333
+ // Pop an element from the top of the expression stack. Discards
334
+ // the result.
335
+ void Pop();
336
+
337
+ // Pop an element from the top of the expression stack. The register
338
+ // will be one normally used for the top of stack register allocation
339
+ // so you can't hold on to it if you push on the stack.
340
+ Register PopToRegister(Register but_not_to_this_one = no_reg);
341
+
342
+ // Look at the top of the stack. The register returned is aliased and
343
+ // must be copied to a scratch register before modification.
344
+ Register Peek();
345
+
346
+ // Look at the value beneath the top of the stack. The register returned is
347
+ // aliased and must be copied to a scratch register before modification.
348
+ Register Peek2();
349
+
350
+ // Duplicate the top of stack.
351
+ void Dup();
352
+
353
+ // Duplicate the two elements on top of stack.
354
+ void Dup2();
346
355
 
347
- // Pop an element from the top of the expression stack. Returns a
348
- // Result, which may be a constant or a register.
349
- Result Pop();
356
+ // Flushes all registers, but it puts a copy of the top-of-stack in a0.
357
+ void SpillAllButCopyTOSToA0();
358
+
359
+ // Flushes all registers, but it puts a copy of the top-of-stack in a1.
360
+ void SpillAllButCopyTOSToA1();
361
+
362
+ // Flushes all registers, but it puts a copy of the top-of-stack in a1
363
+ // and the next value on the stack in a0.
364
+ void SpillAllButCopyTOSToA1A0();
350
365
 
351
366
  // Pop and save an element from the top of the expression stack and
352
367
  // emit a corresponding pop instruction.
@@ -355,40 +370,41 @@ class VirtualFrame : public ZoneObject {
355
370
  void EmitMultiPop(RegList regs);
356
371
  void EmitMultiPopReversed(RegList regs);
357
372
 
373
+
374
+ // Takes the top two elements and puts them in a0 (top element) and a1
375
+ // (second element).
376
+ void PopToA1A0();
377
+
378
+ // Takes the top element and puts it in a1.
379
+ void PopToA1();
380
+
381
+ // Takes the top element and puts it in a0.
382
+ void PopToA0();
383
+
358
384
  // Push an element on top of the expression stack and emit a
359
385
  // corresponding push instruction.
360
- void EmitPush(Register reg);
361
- // Same but for multiple registers.
362
- void EmitMultiPush(RegList regs);
363
- void EmitMultiPushReversed(RegList regs);
386
+ void EmitPush(Register reg, TypeInfo type_info = TypeInfo::Unknown());
387
+ void EmitPush(Operand operand, TypeInfo type_info = TypeInfo::Unknown());
388
+ void EmitPush(MemOperand operand, TypeInfo type_info = TypeInfo::Unknown());
389
+ void EmitPushRoot(Heap::RootListIndex index);
364
390
 
365
- // Push an element on the virtual frame.
366
- inline void Push(Register reg, NumberInfo info = NumberInfo::Unknown());
367
- inline void Push(Handle<Object> value);
368
- inline void Push(Smi* value);
391
+ // Overwrite the nth thing on the stack. If the nth position is in a
392
+ // register then this turns into a Move, otherwise an sw. Afterwards
393
+ // you can still use the register even if it is a register that can be
394
+ // used for TOS (a0 or a1).
395
+ void SetElementAt(Register reg, int this_far_down);
369
396
 
370
- // Pushing a result invalidates it (its contents become owned by the frame).
371
- void Push(Result* result) {
372
- if (result->is_register()) {
373
- Push(result->reg());
374
- } else {
375
- ASSERT(result->is_constant());
376
- Push(result->handle());
377
- }
378
- result->Unuse();
379
- }
380
-
381
- // Nip removes zero or more elements from immediately below the top
382
- // of the frame, leaving the previous top-of-frame value on top of
383
- // the frame. Nip(k) is equivalent to x = Pop(), Drop(k), Push(x).
384
- inline void Nip(int num_dropped);
397
+ // Get a register which is free and which must be immediately used to
398
+ // push on the top of the stack.
399
+ Register GetTOSRegister();
385
400
 
386
- // This pushes 4 arguments slots on the stack and saves asked 'a' registers
387
- // 'a' registers are arguments register a0 to a3.
388
- void EmitArgumentSlots(RegList reglist);
401
+ // Same but for multiple registers.
402
+ void EmitMultiPush(RegList regs);
403
+ void EmitMultiPushReversed(RegList regs);
389
404
 
390
- inline void SetTypeForLocalAt(int index, NumberInfo info);
391
- inline void SetTypeForParamAt(int index, NumberInfo info);
405
+ static Register scratch0() { return t4; }
406
+ static Register scratch1() { return t5; }
407
+ static Register scratch2() { return t6; }
392
408
 
393
409
  private:
394
410
  static const int kLocal0Offset = JavaScriptFrameConstants::kLocal0Offset;
@@ -398,24 +414,51 @@ class VirtualFrame : public ZoneObject {
398
414
  static const int kHandlerSize = StackHandlerConstants::kSize / kPointerSize;
399
415
  static const int kPreallocatedElements = 5 + 8; // 8 expression stack slots.
400
416
 
401
- ZoneList<FrameElement> elements_;
417
+ // 5 states for the top of stack, which can be in memory or in a0 and a1.
418
+ enum TopOfStack { NO_TOS_REGISTERS, A0_TOS, A1_TOS, A1_A0_TOS, A0_A1_TOS,
419
+ TOS_STATES};
420
+ static const int kMaxTOSRegisters = 2;
421
+
422
+ static const bool kA0InUse[TOS_STATES];
423
+ static const bool kA1InUse[TOS_STATES];
424
+ static const int kVirtualElements[TOS_STATES];
425
+ static const TopOfStack kStateAfterPop[TOS_STATES];
426
+ static const TopOfStack kStateAfterPush[TOS_STATES];
427
+ static const Register kTopRegister[TOS_STATES];
428
+ static const Register kBottomRegister[TOS_STATES];
429
+
430
+ // We allocate up to 5 locals in registers.
431
+ static const int kNumberOfAllocatedRegisters = 5;
432
+ // r2 to r6 are allocated to locals.
433
+ static const int kFirstAllocatedRegister = 2;
434
+
435
+ static const Register kAllocatedRegisters[kNumberOfAllocatedRegisters];
436
+
437
+ static Register AllocatedRegister(int r) {
438
+ ASSERT(r >= 0 && r < kNumberOfAllocatedRegisters);
439
+ return kAllocatedRegisters[r];
440
+ }
402
441
 
403
- // The index of the element that is at the processor's stack pointer
404
- // (the sp register).
405
- int stack_pointer_;
442
+ // The number of elements on the stack frame.
443
+ int element_count_;
444
+ TopOfStack top_of_stack_state_:3;
445
+ int register_allocation_map_:kNumberOfAllocatedRegisters;
446
+ static const int kTOSKnownSmiMapSize = 4;
447
+ unsigned tos_known_smi_map_:kTOSKnownSmiMapSize;
406
448
 
407
- // The index of the register frame element using each register, or
408
- // kIllegalIndex if a register is not on the frame.
409
- int register_locations_[RegisterAllocator::kNumRegisters];
449
+ // The index of the element that is at the processor's stack pointer
450
+ // (the sp register). For now since everything is in memory it is given
451
+ // by the number of elements on the not-very-virtual stack frame.
452
+ int stack_pointer() { return element_count_ - 1; }
410
453
 
411
454
  // The number of frame-allocated locals and parameters respectively.
412
- int parameter_count() { return cgen()->scope()->num_parameters(); }
413
- int local_count() { return cgen()->scope()->num_stack_slots(); }
455
+ inline int parameter_count() const;
456
+ inline int local_count() const;
414
457
 
415
458
  // The index of the element that is at the processor's frame pointer
416
459
  // (the fp register). The parameters, receiver, function, and context
417
460
  // are below the frame pointer.
418
- int frame_pointer() { return parameter_count() + 3; }
461
+ inline int frame_pointer() const;
419
462
 
420
463
  // The index of the first parameter. The receiver lies below the first
421
464
  // parameter.
@@ -423,75 +466,22 @@ class VirtualFrame : public ZoneObject {
423
466
 
424
467
  // The index of the context slot in the frame. It is immediately
425
468
  // below the frame pointer.
426
- int context_index() { return frame_pointer() - 1; }
469
+ inline int context_index();
427
470
 
428
471
  // The index of the function slot in the frame. It is below the frame
429
472
  // pointer and context slot.
430
- int function_index() { return frame_pointer() - 2; }
473
+ inline int function_index();
431
474
 
432
475
  // The index of the first local. Between the frame pointer and the
433
476
  // locals lies the return address.
434
- int local0_index() { return frame_pointer() + 2; }
477
+ inline int local0_index() const;
435
478
 
436
479
  // The index of the base of the expression stack.
437
- int expression_base_index() { return local0_index() + local_count(); }
480
+ inline int expression_base_index() const;
438
481
 
439
482
  // Convert a frame index into a frame pointer relative offset into the
440
483
  // actual stack.
441
- int fp_relative(int index) {
442
- ASSERT(index < element_count());
443
- ASSERT(frame_pointer() < element_count()); // FP is on the frame.
444
- return (frame_pointer() - index) * kPointerSize;
445
- }
446
-
447
- // Record an occurrence of a register in the virtual frame. This has the
448
- // effect of incrementing the register's external reference count and
449
- // of updating the index of the register's location in the frame.
450
- void Use(Register reg, int index) {
451
- ASSERT(!is_used(reg));
452
- set_register_location(reg, index);
453
- cgen()->allocator()->Use(reg);
454
- }
455
-
456
- // Record that a register reference has been dropped from the frame. This
457
- // decrements the register's external reference count and invalidates the
458
- // index of the register's location in the frame.
459
- void Unuse(Register reg) {
460
- ASSERT(is_used(reg));
461
- set_register_location(reg, kIllegalIndex);
462
- cgen()->allocator()->Unuse(reg);
463
- }
464
-
465
- // Spill the element at a particular index---write it to memory if
466
- // necessary, free any associated register, and forget its value if
467
- // constant.
468
- void SpillElementAt(int index);
469
-
470
- // Sync the element at a particular index. If it is a register or
471
- // constant that disagrees with the value on the stack, write it to memory.
472
- // Keep the element type as register or constant, and clear the dirty bit.
473
- void SyncElementAt(int index);
474
-
475
- // Sync the range of elements in [begin, end] with memory.
476
- void SyncRange(int begin, int end);
477
-
478
- // Sync a single unsynced element that lies beneath or at the stack pointer.
479
- void SyncElementBelowStackPointer(int index);
480
-
481
- // Sync a single unsynced element that lies just above the stack pointer.
482
- void SyncElementByPushing(int index);
483
-
484
- // Push a copy of a frame slot (typically a local or parameter) on top of
485
- // the frame.
486
- inline void PushFrameSlotAt(int index);
487
-
488
- // Push a the value of a frame slot (typically a local or parameter) on
489
- // top of the frame and invalidate the slot.
490
- void TakeFrameSlotAt(int index);
491
-
492
- // Store the value on top of the frame to a frame slot (typically a local
493
- // or parameter).
494
- void StoreToFrameSlotAt(int index);
484
+ inline int fp_relative(int index);
495
485
 
496
486
  // Spill all elements in registers. Spill the top spilled_args elements
497
487
  // on the frame. Sync all other frame elements.
@@ -499,45 +489,37 @@ class VirtualFrame : public ZoneObject {
499
489
  // the effect of an upcoming call that will drop them from the stack.
500
490
  void PrepareForCall(int spilled_args, int dropped_args);
501
491
 
502
- // Move frame elements currently in registers or constants, that
503
- // should be in memory in the expected frame, to memory.
504
- void MergeMoveRegistersToMemory(VirtualFrame* expected);
505
-
506
- // Make the register-to-register moves necessary to
507
- // merge this frame with the expected frame.
508
- // Register to memory moves must already have been made,
509
- // and memory to register moves must follow this call.
510
- // This is because some new memory-to-register moves are
511
- // created in order to break cycles of register moves.
512
- // Used in the implementation of MergeTo().
513
- void MergeMoveRegistersToRegisters(VirtualFrame* expected);
514
-
515
- // Make the memory-to-register and constant-to-register moves
516
- // needed to make this frame equal the expected frame.
517
- // Called after all register-to-memory and register-to-register
518
- // moves have been made. After this function returns, the frames
519
- // should be equal.
520
- void MergeMoveMemoryToRegisters(VirtualFrame* expected);
521
-
522
- // Invalidates a frame slot (puts an invalid frame element in it).
523
- // Copies on the frame are correctly handled, and if this slot was
524
- // the backing store of copies, the index of the new backing store
525
- // is returned. Otherwise, returns kIllegalIndex.
526
- // Register counts are correctly updated.
527
- int InvalidateFrameSlotAt(int index);
528
-
529
- // Call a code stub that has already been prepared for calling (via
530
- // PrepareForCall).
531
- void RawCallStub(CodeStub* stub);
532
-
533
- // Calls a code object which has already been prepared for calling
534
- // (via PrepareForCall).
535
- void RawCallCodeObject(Handle<Code> code, RelocInfo::Mode rmode);
536
-
537
- inline bool Equals(VirtualFrame* other);
538
-
539
- // Classes that need raw access to the elements_ array.
540
- friend class DeferredCode;
492
+ // If all top-of-stack registers are in use then the lowest one is pushed
493
+ // onto the physical stack and made free.
494
+ void EnsureOneFreeTOSRegister();
495
+
496
+ // Emit instructions to get the top of stack state from where we are to where
497
+ // we want to be.
498
+ void MergeTOSTo(TopOfStack expected_state,
499
+ Condition cond = al,
500
+ Register r1 = no_reg,
501
+ const Operand& r2 = Operand(no_reg));
502
+
503
+ inline bool Equals(const VirtualFrame* other);
504
+
505
+ inline void LowerHeight(int count) {
506
+ element_count_ -= count;
507
+ if (count >= kTOSKnownSmiMapSize) {
508
+ tos_known_smi_map_ = 0;
509
+ } else {
510
+ tos_known_smi_map_ >>= count;
511
+ }
512
+ }
513
+
514
+ inline void RaiseHeight(int count, unsigned known_smi_map = 0) {
515
+ ASSERT(known_smi_map < (1u << count));
516
+ element_count_ += count;
517
+ if (count >= kTOSKnownSmiMapSize) {
518
+ tos_known_smi_map_ = known_smi_map;
519
+ } else {
520
+ tos_known_smi_map_ = ((tos_known_smi_map_ << count) | known_smi_map);
521
+ }
522
+ }
541
523
  friend class JumpTarget;
542
524
  };
543
525