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
@@ -41,8 +41,6 @@
41
41
  #include "constants-mips.h"
42
42
  #include "serialize.h"
43
43
 
44
- using namespace assembler::mips;
45
-
46
44
  namespace v8 {
47
45
  namespace internal {
48
46
 
@@ -73,6 +71,44 @@ namespace internal {
73
71
 
74
72
  // Core register.
75
73
  struct Register {
74
+ static const int kNumRegisters = v8::internal::kNumRegisters;
75
+ static const int kNumAllocatableRegisters = 14; // v0 through t7
76
+
77
+ static int ToAllocationIndex(Register reg) {
78
+ return reg.code() - 2; // zero_reg and 'at' are skipped.
79
+ }
80
+
81
+ static Register FromAllocationIndex(int index) {
82
+ ASSERT(index >= 0 && index < kNumAllocatableRegisters);
83
+ return from_code(index + 2); // zero_reg and 'at' are skipped.
84
+ }
85
+
86
+ static const char* AllocationIndexToString(int index) {
87
+ ASSERT(index >= 0 && index < kNumAllocatableRegisters);
88
+ const char* const names[] = {
89
+ "v0",
90
+ "v1",
91
+ "a0",
92
+ "a1",
93
+ "a2",
94
+ "a3",
95
+ "t0",
96
+ "t1",
97
+ "t2",
98
+ "t3",
99
+ "t4",
100
+ "t5",
101
+ "t6",
102
+ "t7",
103
+ };
104
+ return names[index];
105
+ }
106
+
107
+ static Register from_code(int code) {
108
+ Register r = { code };
109
+ return r;
110
+ }
111
+
76
112
  bool is_valid() const { return 0 <= code_ && code_ < kNumRegisters; }
77
113
  bool is(Register reg) const { return code_ == reg.code_; }
78
114
  int code() const {
@@ -88,40 +124,41 @@ struct Register {
88
124
  int code_;
89
125
  };
90
126
 
91
- extern const Register no_reg;
92
-
93
- extern const Register zero_reg;
94
- extern const Register at;
95
- extern const Register v0;
96
- extern const Register v1;
97
- extern const Register a0;
98
- extern const Register a1;
99
- extern const Register a2;
100
- extern const Register a3;
101
- extern const Register t0;
102
- extern const Register t1;
103
- extern const Register t2;
104
- extern const Register t3;
105
- extern const Register t4;
106
- extern const Register t5;
107
- extern const Register t6;
108
- extern const Register t7;
109
- extern const Register s0;
110
- extern const Register s1;
111
- extern const Register s2;
112
- extern const Register s3;
113
- extern const Register s4;
114
- extern const Register s5;
115
- extern const Register s6;
116
- extern const Register s7;
117
- extern const Register t8;
118
- extern const Register t9;
119
- extern const Register k0;
120
- extern const Register k1;
121
- extern const Register gp;
122
- extern const Register sp;
123
- extern const Register s8_fp;
124
- extern const Register ra;
127
+ const Register no_reg = { -1 };
128
+
129
+ const Register zero_reg = { 0 };
130
+ const Register at = { 1 };
131
+ const Register v0 = { 2 };
132
+ const Register v1 = { 3 };
133
+ const Register a0 = { 4 };
134
+ const Register a1 = { 5 };
135
+ const Register a2 = { 6 };
136
+ const Register a3 = { 7 };
137
+ const Register t0 = { 8 };
138
+ const Register t1 = { 9 };
139
+ const Register t2 = { 10 };
140
+ const Register t3 = { 11 };
141
+ const Register t4 = { 12 };
142
+ const Register t5 = { 13 };
143
+ const Register t6 = { 14 };
144
+ const Register t7 = { 15 };
145
+ const Register s0 = { 16 };
146
+ const Register s1 = { 17 };
147
+ const Register s2 = { 18 };
148
+ const Register s3 = { 19 };
149
+ const Register s4 = { 20 };
150
+ const Register s5 = { 21 };
151
+ const Register s6 = { 22 };
152
+ const Register s7 = { 23 };
153
+ const Register t8 = { 24 };
154
+ const Register t9 = { 25 };
155
+ const Register k0 = { 26 };
156
+ const Register k1 = { 27 };
157
+ const Register gp = { 28 };
158
+ const Register sp = { 29 };
159
+ const Register s8_fp = { 30 };
160
+ const Register ra = { 31 };
161
+
125
162
 
126
163
  int ToNumber(Register reg);
127
164
 
@@ -129,7 +166,50 @@ Register ToRegister(int num);
129
166
 
130
167
  // Coprocessor register.
131
168
  struct FPURegister {
132
- bool is_valid() const { return 0 <= code_ && code_ < kNumFPURegister ; }
169
+ static const int kNumRegisters = v8::internal::kNumFPURegisters;
170
+ // f0 has been excluded from allocation. This is following ia32
171
+ // where xmm0 is excluded.
172
+ static const int kNumAllocatableRegisters = 15;
173
+
174
+ static int ToAllocationIndex(FPURegister reg) {
175
+ ASSERT(reg.code() != 0);
176
+ ASSERT(reg.code() % 2 == 0);
177
+ return (reg.code() / 2) - 1;
178
+ }
179
+
180
+ static FPURegister FromAllocationIndex(int index) {
181
+ ASSERT(index >= 0 && index < kNumAllocatableRegisters);
182
+ return from_code((index + 1) * 2);
183
+ }
184
+
185
+ static const char* AllocationIndexToString(int index) {
186
+ ASSERT(index >= 0 && index < kNumAllocatableRegisters);
187
+ const char* const names[] = {
188
+ "f2",
189
+ "f4",
190
+ "f6",
191
+ "f8",
192
+ "f10",
193
+ "f12",
194
+ "f14",
195
+ "f16",
196
+ "f18",
197
+ "f20",
198
+ "f22",
199
+ "f24",
200
+ "f26",
201
+ "f28",
202
+ "f30"
203
+ };
204
+ return names[index];
205
+ }
206
+
207
+ static FPURegister from_code(int code) {
208
+ FPURegister r = { code };
209
+ return r;
210
+ }
211
+
212
+ bool is_valid() const { return 0 <= code_ && code_ < kNumFPURegisters ; }
133
213
  bool is(FPURegister creg) const { return code_ == creg.code_; }
134
214
  int code() const {
135
215
  ASSERT(is_valid());
@@ -139,84 +219,77 @@ struct FPURegister {
139
219
  ASSERT(is_valid());
140
220
  return 1 << code_;
141
221
  }
142
-
222
+ void setcode(int f) {
223
+ code_ = f;
224
+ ASSERT(is_valid());
225
+ }
143
226
  // Unfortunately we can't make this private in a struct.
144
227
  int code_;
145
228
  };
146
229
 
147
- extern const FPURegister no_creg;
148
-
149
- extern const FPURegister f0;
150
- extern const FPURegister f1;
151
- extern const FPURegister f2;
152
- extern const FPURegister f3;
153
- extern const FPURegister f4;
154
- extern const FPURegister f5;
155
- extern const FPURegister f6;
156
- extern const FPURegister f7;
157
- extern const FPURegister f8;
158
- extern const FPURegister f9;
159
- extern const FPURegister f10;
160
- extern const FPURegister f11;
161
- extern const FPURegister f12; // arg
162
- extern const FPURegister f13;
163
- extern const FPURegister f14; // arg
164
- extern const FPURegister f15;
165
- extern const FPURegister f16;
166
- extern const FPURegister f17;
167
- extern const FPURegister f18;
168
- extern const FPURegister f19;
169
- extern const FPURegister f20;
170
- extern const FPURegister f21;
171
- extern const FPURegister f22;
172
- extern const FPURegister f23;
173
- extern const FPURegister f24;
174
- extern const FPURegister f25;
175
- extern const FPURegister f26;
176
- extern const FPURegister f27;
177
- extern const FPURegister f28;
178
- extern const FPURegister f29;
179
- extern const FPURegister f30;
180
- extern const FPURegister f31;
181
-
182
-
183
- // Returns the equivalent of !cc.
184
- // Negation of the default no_condition (-1) results in a non-default
185
- // no_condition value (-2). As long as tests for no_condition check
186
- // for condition < 0, this will work as expected.
187
- inline Condition NegateCondition(Condition cc);
188
-
189
- inline Condition ReverseCondition(Condition cc) {
190
- switch (cc) {
191
- case Uless:
192
- return Ugreater;
193
- case Ugreater:
194
- return Uless;
195
- case Ugreater_equal:
196
- return Uless_equal;
197
- case Uless_equal:
198
- return Ugreater_equal;
199
- case less:
200
- return greater;
201
- case greater:
202
- return less;
203
- case greater_equal:
204
- return less_equal;
205
- case less_equal:
206
- return greater_equal;
207
- default:
208
- return cc;
209
- };
210
- }
211
-
212
-
213
- enum Hint {
214
- no_hint = 0
230
+ typedef FPURegister DoubleRegister;
231
+
232
+ const FPURegister no_creg = { -1 };
233
+
234
+ const FPURegister f0 = { 0 }; // Return value in hard float mode.
235
+ const FPURegister f1 = { 1 };
236
+ const FPURegister f2 = { 2 };
237
+ const FPURegister f3 = { 3 };
238
+ const FPURegister f4 = { 4 };
239
+ const FPURegister f5 = { 5 };
240
+ const FPURegister f6 = { 6 };
241
+ const FPURegister f7 = { 7 };
242
+ const FPURegister f8 = { 8 };
243
+ const FPURegister f9 = { 9 };
244
+ const FPURegister f10 = { 10 };
245
+ const FPURegister f11 = { 11 };
246
+ const FPURegister f12 = { 12 }; // Arg 0 in hard float mode.
247
+ const FPURegister f13 = { 13 };
248
+ const FPURegister f14 = { 14 }; // Arg 1 in hard float mode.
249
+ const FPURegister f15 = { 15 };
250
+ const FPURegister f16 = { 16 };
251
+ const FPURegister f17 = { 17 };
252
+ const FPURegister f18 = { 18 };
253
+ const FPURegister f19 = { 19 };
254
+ const FPURegister f20 = { 20 };
255
+ const FPURegister f21 = { 21 };
256
+ const FPURegister f22 = { 22 };
257
+ const FPURegister f23 = { 23 };
258
+ const FPURegister f24 = { 24 };
259
+ const FPURegister f25 = { 25 };
260
+ const FPURegister f26 = { 26 };
261
+ const FPURegister f27 = { 27 };
262
+ const FPURegister f28 = { 28 };
263
+ const FPURegister f29 = { 29 };
264
+ const FPURegister f30 = { 30 };
265
+ const FPURegister f31 = { 31 };
266
+
267
+ // FPU (coprocessor 1) control registers.
268
+ // Currently only FCSR (#31) is implemented.
269
+ struct FPUControlRegister {
270
+ static const int kFCSRRegister = 31;
271
+ static const int kInvalidFPUControlRegister = -1;
272
+
273
+ bool is_valid() const { return code_ == kFCSRRegister; }
274
+ bool is(FPUControlRegister creg) const { return code_ == creg.code_; }
275
+ int code() const {
276
+ ASSERT(is_valid());
277
+ return code_;
278
+ }
279
+ int bit() const {
280
+ ASSERT(is_valid());
281
+ return 1 << code_;
282
+ }
283
+ void setcode(int f) {
284
+ code_ = f;
285
+ ASSERT(is_valid());
286
+ }
287
+ // Unfortunately we can't make this private in a struct.
288
+ int code_;
215
289
  };
216
290
 
217
- inline Hint NegateHint(Hint hint) {
218
- return no_hint;
219
- }
291
+ const FPUControlRegister no_fpucreg = { -1 };
292
+ const FPUControlRegister FCSR = { kFCSRRegister };
220
293
 
221
294
 
222
295
  // -----------------------------------------------------------------------------
@@ -258,16 +331,75 @@ class Operand BASE_EMBEDDED {
258
331
  class MemOperand : public Operand {
259
332
  public:
260
333
 
261
- explicit MemOperand(Register rn, int16_t offset = 0);
334
+ explicit MemOperand(Register rn, int32_t offset = 0);
262
335
 
263
336
  private:
264
- int16_t offset_;
337
+ int32_t offset_;
265
338
 
266
339
  friend class Assembler;
267
340
  };
268
341
 
269
342
 
270
- class Assembler : public Malloced {
343
+ // CpuFeatures keeps track of which features are supported by the target CPU.
344
+ // Supported features must be enabled by a Scope before use.
345
+ class CpuFeatures {
346
+ public:
347
+ // Detect features of the target CPU. Set safe defaults if the serializer
348
+ // is enabled (snapshots must be portable).
349
+ void Probe(bool portable);
350
+
351
+ // Check whether a feature is supported by the target CPU.
352
+ bool IsSupported(CpuFeature f) const {
353
+ if (f == FPU && !FLAG_enable_fpu) return false;
354
+ return (supported_ & (1u << f)) != 0;
355
+ }
356
+
357
+ // Check whether a feature is currently enabled.
358
+ bool IsEnabled(CpuFeature f) const {
359
+ return (enabled_ & (1u << f)) != 0;
360
+ }
361
+
362
+ // Enable a specified feature within a scope.
363
+ class Scope BASE_EMBEDDED {
364
+ #ifdef DEBUG
365
+ public:
366
+ explicit Scope(CpuFeature f)
367
+ : cpu_features_(Isolate::Current()->cpu_features()),
368
+ isolate_(Isolate::Current()) {
369
+ ASSERT(cpu_features_->IsSupported(f));
370
+ ASSERT(!Serializer::enabled() ||
371
+ (cpu_features_->found_by_runtime_probing_ & (1u << f)) == 0);
372
+ old_enabled_ = cpu_features_->enabled_;
373
+ cpu_features_->enabled_ |= 1u << f;
374
+ }
375
+ ~Scope() {
376
+ ASSERT_EQ(Isolate::Current(), isolate_);
377
+ cpu_features_->enabled_ = old_enabled_;
378
+ }
379
+ private:
380
+ unsigned old_enabled_;
381
+ CpuFeatures* cpu_features_;
382
+ Isolate* isolate_;
383
+ #else
384
+ public:
385
+ explicit Scope(CpuFeature f) {}
386
+ #endif
387
+ };
388
+
389
+ private:
390
+ CpuFeatures();
391
+
392
+ unsigned supported_;
393
+ unsigned enabled_;
394
+ unsigned found_by_runtime_probing_;
395
+
396
+ friend class Isolate;
397
+
398
+ DISALLOW_COPY_AND_ASSIGN(CpuFeatures);
399
+ };
400
+
401
+
402
+ class Assembler : public AssemblerBase {
271
403
  public:
272
404
  // Create an assembler. Instructions and relocation information are emitted
273
405
  // into a buffer, with the instructions starting from the beginning and the
@@ -285,6 +417,9 @@ class Assembler : public Malloced {
285
417
  Assembler(void* buffer, int buffer_size);
286
418
  ~Assembler();
287
419
 
420
+ // Overrides the default provided by FLAG_debug_code.
421
+ void set_emit_debug_code(bool value) { emit_debug_code_ = value; }
422
+
288
423
  // GetCode emits any pending (non-emitted) code and fills the descriptor
289
424
  // desc. GetCode() is idempotent; it returns the same result if no other
290
425
  // Assembler functions are invoked in between GetCode() calls.
@@ -320,12 +455,6 @@ class Assembler : public Malloced {
320
455
  // The high 8 bits are set to zero.
321
456
  void label_at_put(Label* L, int at_offset);
322
457
 
323
- // Size of an instruction.
324
- static const int kInstrSize = sizeof(Instr);
325
-
326
- // Difference between address of current opcode and target address offset.
327
- static const int kBranchPCOffset = 4;
328
-
329
458
  // Read/Modify the code target address in the branch/call instruction at pc.
330
459
  static Address target_address_at(Address pc);
331
460
  static void set_target_address_at(Address pc, Address target);
@@ -344,8 +473,25 @@ class Assembler : public Malloced {
344
473
  set_target_address_at(instruction_payload, target);
345
474
  }
346
475
 
347
- static const int kCallTargetSize = 3 * kPointerSize;
348
- static const int kExternalTargetSize = 3 * kPointerSize;
476
+ // Size of an instruction.
477
+ static const int kInstrSize = sizeof(Instr);
478
+
479
+ // Difference between address of current opcode and target address offset.
480
+ static const int kBranchPCOffset = 4;
481
+
482
+ // Here we are patching the address in the LUI/ORI instruction pair.
483
+ // These values are used in the serialization process and must be zero for
484
+ // MIPS platform, as Code, Embedded Object or External-reference pointers
485
+ // are split across two consecutive instructions and don't exist separately
486
+ // in the code, so the serializer should not step forwards in memory after
487
+ // a target is resolved and written.
488
+ static const int kCallTargetSize = 0 * kInstrSize;
489
+ static const int kExternalTargetSize = 0 * kInstrSize;
490
+
491
+ // Number of consecutive instructions used to store 32bit constant.
492
+ // Used in RelocInfo::target_address_address() function to tell serializer
493
+ // address of the instruction that follows LUI/ORI instruction pair.
494
+ static const int kInstructionsFor32BitConstant = 2;
349
495
 
350
496
  // Distance between the instruction referring to the address of the call
351
497
  // target and the return address.
@@ -353,16 +499,53 @@ class Assembler : public Malloced {
353
499
 
354
500
  // Distance between start of patched return sequence and the emitted address
355
501
  // to jump to.
356
- static const int kPatchReturnSequenceAddressOffset = kInstrSize;
502
+ static const int kPatchReturnSequenceAddressOffset = 0;
357
503
 
358
504
  // Distance between start of patched debug break slot and the emitted address
359
505
  // to jump to.
360
- static const int kPatchDebugBreakSlotAddressOffset = kInstrSize;
506
+ static const int kPatchDebugBreakSlotAddressOffset = 0 * kInstrSize;
507
+
508
+ // Difference between address of current opcode and value read from pc
509
+ // register.
510
+ static const int kPcLoadDelta = 4;
511
+
512
+ // Number of instructions used for the JS return sequence. The constant is
513
+ // used by the debugger to patch the JS return sequence.
514
+ static const int kJSReturnSequenceInstructions = 7;
515
+ static const int kDebugBreakSlotInstructions = 4;
516
+ static const int kDebugBreakSlotLength =
517
+ kDebugBreakSlotInstructions * kInstrSize;
518
+
361
519
 
362
520
  // ---------------------------------------------------------------------------
363
521
  // Code generation.
364
522
 
365
- void nop() { sll(zero_reg, zero_reg, 0); }
523
+ // Insert the smallest number of nop instructions
524
+ // possible to align the pc offset to a multiple
525
+ // of m. m must be a power of 2 (>= 4).
526
+ void Align(int m);
527
+ // Aligns code to something that's optimal for a jump target for the platform.
528
+ void CodeTargetAlign();
529
+
530
+ // Different nop operations are used by the code generator to detect certain
531
+ // states of the generated code.
532
+ enum NopMarkerTypes {
533
+ NON_MARKING_NOP = 0,
534
+ DEBUG_BREAK_NOP,
535
+ // IC markers.
536
+ PROPERTY_ACCESS_INLINED,
537
+ PROPERTY_ACCESS_INLINED_CONTEXT,
538
+ PROPERTY_ACCESS_INLINED_CONTEXT_DONT_DELETE,
539
+ // Helper values.
540
+ LAST_CODE_MARKER,
541
+ FIRST_IC_MARKER = PROPERTY_ACCESS_INLINED
542
+ };
543
+
544
+ // type == 0 is the default non-marking type.
545
+ void nop(unsigned int type = 0) {
546
+ ASSERT(type < 32);
547
+ sll(zero_reg, zero_reg, type, true);
548
+ }
366
549
 
367
550
 
368
551
  //------- Branch and jump instructions --------
@@ -400,9 +583,7 @@ class Assembler : public Malloced {
400
583
  //-------Data-processing-instructions---------
401
584
 
402
585
  // Arithmetic.
403
- void add(Register rd, Register rs, Register rt);
404
586
  void addu(Register rd, Register rs, Register rt);
405
- void sub(Register rd, Register rs, Register rt);
406
587
  void subu(Register rd, Register rs, Register rt);
407
588
  void mult(Register rs, Register rt);
408
589
  void multu(Register rs, Register rt);
@@ -410,7 +591,6 @@ class Assembler : public Malloced {
410
591
  void divu(Register rs, Register rt);
411
592
  void mul(Register rd, Register rs, Register rt);
412
593
 
413
- void addi(Register rd, Register rs, int32_t j);
414
594
  void addiu(Register rd, Register rs, int32_t j);
415
595
 
416
596
  // Logical.
@@ -425,21 +605,33 @@ class Assembler : public Malloced {
425
605
  void lui(Register rd, int32_t j);
426
606
 
427
607
  // Shifts.
428
- void sll(Register rd, Register rt, uint16_t sa);
608
+ // Please note: sll(zero_reg, zero_reg, x) instructions are reserved as nop
609
+ // and may cause problems in normal code. coming_from_nop makes sure this
610
+ // doesn't happen.
611
+ void sll(Register rd, Register rt, uint16_t sa, bool coming_from_nop = false);
429
612
  void sllv(Register rd, Register rt, Register rs);
430
613
  void srl(Register rd, Register rt, uint16_t sa);
431
614
  void srlv(Register rd, Register rt, Register rs);
432
615
  void sra(Register rt, Register rd, uint16_t sa);
433
616
  void srav(Register rt, Register rd, Register rs);
617
+ void rotr(Register rd, Register rt, uint16_t sa);
618
+ void rotrv(Register rd, Register rt, Register rs);
434
619
 
435
620
 
436
621
  //------------Memory-instructions-------------
437
622
 
438
623
  void lb(Register rd, const MemOperand& rs);
439
624
  void lbu(Register rd, const MemOperand& rs);
625
+ void lh(Register rd, const MemOperand& rs);
626
+ void lhu(Register rd, const MemOperand& rs);
440
627
  void lw(Register rd, const MemOperand& rs);
628
+ void lwl(Register rd, const MemOperand& rs);
629
+ void lwr(Register rd, const MemOperand& rs);
441
630
  void sb(Register rd, const MemOperand& rs);
631
+ void sh(Register rd, const MemOperand& rs);
442
632
  void sw(Register rd, const MemOperand& rs);
633
+ void swl(Register rd, const MemOperand& rs);
634
+ void swr(Register rd, const MemOperand& rs);
443
635
 
444
636
 
445
637
  //-------------Misc-instructions--------------
@@ -463,6 +655,16 @@ class Assembler : public Malloced {
463
655
  void slti(Register rd, Register rs, int32_t j);
464
656
  void sltiu(Register rd, Register rs, int32_t j);
465
657
 
658
+ // Conditional move.
659
+ void movz(Register rd, Register rs, Register rt);
660
+ void movn(Register rd, Register rs, Register rt);
661
+ void movt(Register rd, Register rs, uint16_t cc = 0);
662
+ void movf(Register rd, Register rs, uint16_t cc = 0);
663
+
664
+ // Bit twiddling.
665
+ void clz(Register rd, Register rs);
666
+ void ins_(Register rt, Register rs, uint16_t pos, uint16_t size);
667
+ void ext_(Register rt, Register rs, uint16_t pos, uint16_t size);
466
668
 
467
669
  //--------Coprocessor-instructions----------------
468
670
 
@@ -473,19 +675,44 @@ class Assembler : public Malloced {
473
675
  void swc1(FPURegister fs, const MemOperand& dst);
474
676
  void sdc1(FPURegister fs, const MemOperand& dst);
475
677
 
476
- // When paired with MTC1 to write a value to a 64-bit FPR, the MTC1 must be
477
- // executed first, followed by the MTHC1.
478
- void mtc1(FPURegister fs, Register rt);
479
- void mthc1(FPURegister fs, Register rt);
480
- void mfc1(FPURegister fs, Register rt);
481
- void mfhc1(FPURegister fs, Register rt);
678
+ void mtc1(Register rt, FPURegister fs);
679
+ void mfc1(Register rt, FPURegister fs);
680
+
681
+ void ctc1(Register rt, FPUControlRegister fs);
682
+ void cfc1(Register rt, FPUControlRegister fs);
683
+
684
+ // Arithmetic.
685
+ void add_d(FPURegister fd, FPURegister fs, FPURegister ft);
686
+ void sub_d(FPURegister fd, FPURegister fs, FPURegister ft);
687
+ void mul_d(FPURegister fd, FPURegister fs, FPURegister ft);
688
+ void div_d(FPURegister fd, FPURegister fs, FPURegister ft);
689
+ void abs_d(FPURegister fd, FPURegister fs);
690
+ void mov_d(FPURegister fd, FPURegister fs);
691
+ void neg_d(FPURegister fd, FPURegister fs);
692
+ void sqrt_d(FPURegister fd, FPURegister fs);
482
693
 
483
694
  // Conversion.
484
695
  void cvt_w_s(FPURegister fd, FPURegister fs);
485
696
  void cvt_w_d(FPURegister fd, FPURegister fs);
697
+ void trunc_w_s(FPURegister fd, FPURegister fs);
698
+ void trunc_w_d(FPURegister fd, FPURegister fs);
699
+ void round_w_s(FPURegister fd, FPURegister fs);
700
+ void round_w_d(FPURegister fd, FPURegister fs);
701
+ void floor_w_s(FPURegister fd, FPURegister fs);
702
+ void floor_w_d(FPURegister fd, FPURegister fs);
703
+ void ceil_w_s(FPURegister fd, FPURegister fs);
704
+ void ceil_w_d(FPURegister fd, FPURegister fs);
486
705
 
487
706
  void cvt_l_s(FPURegister fd, FPURegister fs);
488
707
  void cvt_l_d(FPURegister fd, FPURegister fs);
708
+ void trunc_l_s(FPURegister fd, FPURegister fs);
709
+ void trunc_l_d(FPURegister fd, FPURegister fs);
710
+ void round_l_s(FPURegister fd, FPURegister fs);
711
+ void round_l_d(FPURegister fd, FPURegister fs);
712
+ void floor_l_s(FPURegister fd, FPURegister fs);
713
+ void floor_l_d(FPURegister fd, FPURegister fs);
714
+ void ceil_l_s(FPURegister fd, FPURegister fs);
715
+ void ceil_l_d(FPURegister fd, FPURegister fs);
489
716
 
490
717
  void cvt_s_w(FPURegister fd, FPURegister fs);
491
718
  void cvt_s_l(FPURegister fd, FPURegister fs);
@@ -503,32 +730,60 @@ class Assembler : public Malloced {
503
730
  void bc1f(Label* L, uint16_t cc = 0) { bc1f(branch_offset(L, false)>>2, cc); }
504
731
  void bc1t(int16_t offset, uint16_t cc = 0);
505
732
  void bc1t(Label* L, uint16_t cc = 0) { bc1t(branch_offset(L, false)>>2, cc); }
506
-
733
+ void fcmp(FPURegister src1, const double src2, FPUCondition cond);
507
734
 
508
735
  // Check the code size generated from label to here.
509
736
  int InstructionsGeneratedSince(Label* l) {
510
737
  return (pc_offset() - l->pos()) / kInstrSize;
511
738
  }
512
739
 
740
+ // Class for scoping postponing the trampoline pool generation.
741
+ class BlockTrampolinePoolScope {
742
+ public:
743
+ explicit BlockTrampolinePoolScope(Assembler* assem) : assem_(assem) {
744
+ assem_->StartBlockTrampolinePool();
745
+ }
746
+ ~BlockTrampolinePoolScope() {
747
+ assem_->EndBlockTrampolinePool();
748
+ }
749
+
750
+ private:
751
+ Assembler* assem_;
752
+
753
+ DISALLOW_IMPLICIT_CONSTRUCTORS(BlockTrampolinePoolScope);
754
+ };
755
+
513
756
  // Debugging.
514
757
 
515
758
  // Mark address of the ExitJSFrame code.
516
759
  void RecordJSReturn();
517
760
 
761
+ // Mark address of a debug break slot.
762
+ void RecordDebugBreakSlot();
763
+
518
764
  // Record a comment relocation entry that can be used by a disassembler.
519
- // Use --debug_code to enable.
765
+ // Use --code-comments to enable.
520
766
  void RecordComment(const char* msg);
521
767
 
522
- void RecordPosition(int pos);
523
- void RecordStatementPosition(int pos);
524
- bool WriteRecordedPositions();
768
+ // Writes a single byte or word of data in the code stream. Used for
769
+ // inline tables, e.g., jump-tables.
770
+ void db(uint8_t data);
771
+ void dd(uint32_t data);
525
772
 
526
773
  int32_t pc_offset() const { return pc_ - buffer_; }
527
- int32_t current_position() const { return current_position_; }
528
- int32_t current_statement_position() const {
529
- return current_statement_position_;
774
+
775
+ PositionsRecorder* positions_recorder() { return &positions_recorder_; }
776
+
777
+ bool can_peephole_optimize(int instructions) {
778
+ if (!allow_peephole_optimization_) return false;
779
+ if (last_bound_pos_ > pc_offset() - instructions * kInstrSize) return false;
780
+ return reloc_info_writer.last_pc() <= pc_ - instructions * kInstrSize;
530
781
  }
531
782
 
783
+ // Postpone the generation of the trampoline pool for the specified number of
784
+ // instructions.
785
+ void BlockTrampolinePoolFor(int instructions);
786
+
532
787
  // Check if there is less than kGap bytes available in the buffer.
533
788
  // If this is the case, we need to grow the buffer before emitting
534
789
  // an instruction or relocation information.
@@ -537,12 +792,9 @@ class Assembler : public Malloced {
537
792
  // Get the number of bytes available in the buffer.
538
793
  inline int available_space() const { return reloc_info_writer.pos() - pc_; }
539
794
 
540
- protected:
541
- int32_t buffer_space() const { return reloc_info_writer.pos() - pc_; }
542
-
543
795
  // Read/patch instructions.
544
796
  static Instr instr_at(byte* pc) { return *reinterpret_cast<Instr*>(pc); }
545
- void instr_at_put(byte* pc, Instr instr) {
797
+ static void instr_at_put(byte* pc, Instr instr) {
546
798
  *reinterpret_cast<Instr*>(pc) = instr;
547
799
  }
548
800
  Instr instr_at(int pos) { return *reinterpret_cast<Instr*>(buffer_ + pos); }
@@ -551,7 +803,34 @@ class Assembler : public Malloced {
551
803
  }
552
804
 
553
805
  // Check if an instruction is a branch of some kind.
554
- bool is_branch(Instr instr);
806
+ static bool IsBranch(Instr instr);
807
+
808
+ static bool IsNop(Instr instr, unsigned int type);
809
+ static bool IsPop(Instr instr);
810
+ static bool IsPush(Instr instr);
811
+ static bool IsLwRegFpOffset(Instr instr);
812
+ static bool IsSwRegFpOffset(Instr instr);
813
+ static bool IsLwRegFpNegOffset(Instr instr);
814
+ static bool IsSwRegFpNegOffset(Instr instr);
815
+
816
+ static Register GetRt(Instr instr);
817
+
818
+ static int32_t GetBranchOffset(Instr instr);
819
+ static bool IsLw(Instr instr);
820
+ static int16_t GetLwOffset(Instr instr);
821
+ static Instr SetLwOffset(Instr instr, int16_t offset);
822
+
823
+ static bool IsSw(Instr instr);
824
+ static Instr SetSwOffset(Instr instr, int16_t offset);
825
+ static bool IsAddImmediate(Instr instr);
826
+ static Instr SetAddImmediateOffset(Instr instr, int16_t offset);
827
+
828
+ void CheckTrampolinePool(bool force_emit = false);
829
+
830
+ protected:
831
+ bool emit_debug_code() const { return emit_debug_code_; }
832
+
833
+ int32_t buffer_space() const { return reloc_info_writer.pos() - pc_; }
555
834
 
556
835
  // Decode branch instruction at pos and return branch target pos.
557
836
  int target_at(int32_t pos);
@@ -560,11 +839,28 @@ class Assembler : public Malloced {
560
839
  void target_at_put(int32_t pos, int32_t target_pos);
561
840
 
562
841
  // Say if we need to relocate with this mode.
563
- bool MustUseAt(RelocInfo::Mode rmode);
842
+ bool MustUseReg(RelocInfo::Mode rmode);
564
843
 
565
844
  // Record reloc info for current pc_.
566
845
  void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0);
567
846
 
847
+ // Block the emission of the trampoline pool before pc_offset.
848
+ void BlockTrampolinePoolBefore(int pc_offset) {
849
+ if (no_trampoline_pool_before_ < pc_offset)
850
+ no_trampoline_pool_before_ = pc_offset;
851
+ }
852
+
853
+ void StartBlockTrampolinePool() {
854
+ trampoline_pool_blocked_nesting_++;
855
+ }
856
+ void EndBlockTrampolinePool() {
857
+ trampoline_pool_blocked_nesting_--;
858
+ }
859
+
860
+ bool is_trampoline_pool_blocked() const {
861
+ return trampoline_pool_blocked_nesting_ > 0;
862
+ }
863
+
568
864
  private:
569
865
  // Code buffer:
570
866
  // The buffer into which code and relocation info are generated.
@@ -585,6 +881,22 @@ class Assembler : public Malloced {
585
881
  static const int kGap = 32;
586
882
  byte* pc_; // The program counter - moves forward.
587
883
 
884
+
885
+ // Repeated checking whether the trampoline pool should be emitted is rather
886
+ // expensive. By default we only check again once a number of instructions
887
+ // has been generated.
888
+ static const int kCheckConstIntervalInst = 32;
889
+ static const int kCheckConstInterval = kCheckConstIntervalInst * kInstrSize;
890
+
891
+ int next_buffer_check_; // pc offset of next buffer check.
892
+
893
+ // Emission of the trampoline pool may be blocked in some code sequences.
894
+ int trampoline_pool_blocked_nesting_; // Block emission if this is not zero.
895
+ int no_trampoline_pool_before_; // Block emission before this pc offset.
896
+
897
+ // Keep track of the last emitted pool to guarantee a maximal distance.
898
+ int last_trampoline_pool_end_; // pc offset of the end of the last pool.
899
+
588
900
  // Relocation information generation.
589
901
  // Each relocation is encoded as a variable size value.
590
902
  static const int kMaxRelocSize = RelocInfoWriter::kMaxSize;
@@ -593,16 +905,11 @@ class Assembler : public Malloced {
593
905
  // The bound position, before this we cannot do instruction elimination.
594
906
  int last_bound_pos_;
595
907
 
596
- // Source position information.
597
- int current_position_;
598
- int current_statement_position_;
599
- int written_position_;
600
- int written_statement_position_;
601
-
602
908
  // Code emission.
603
909
  inline void CheckBuffer();
604
910
  void GrowBuffer();
605
911
  inline void emit(Instr x);
912
+ inline void CheckTrampolinePoolQuick();
606
913
 
607
914
  // Instruction generation.
608
915
  // We have 3 different kind of encoding layout on MIPS.
@@ -619,6 +926,13 @@ class Assembler : public Malloced {
619
926
  uint16_t sa = 0,
620
927
  SecondaryField func = NULLSF);
621
928
 
929
+ void GenInstrRegister(Opcode opcode,
930
+ Register rs,
931
+ Register rt,
932
+ uint16_t msb,
933
+ uint16_t lsb,
934
+ SecondaryField func);
935
+
622
936
  void GenInstrRegister(Opcode opcode,
623
937
  SecondaryField fmt,
624
938
  FPURegister ft,
@@ -633,6 +947,12 @@ class Assembler : public Malloced {
633
947
  FPURegister fd,
634
948
  SecondaryField func = NULLSF);
635
949
 
950
+ void GenInstrRegister(Opcode opcode,
951
+ SecondaryField fmt,
952
+ Register rt,
953
+ FPUControlRegister fs,
954
+ SecondaryField func = NULLSF);
955
+
636
956
 
637
957
  void GenInstrImmediate(Opcode opcode,
638
958
  Register rs,
@@ -651,6 +971,8 @@ class Assembler : public Malloced {
651
971
  void GenInstrJump(Opcode opcode,
652
972
  uint32_t address);
653
973
 
974
+ // Helpers.
975
+ void LoadRegPlusOffsetToAt(const MemOperand& src);
654
976
 
655
977
  // Labels.
656
978
  void print(Label* L);
@@ -658,8 +980,85 @@ class Assembler : public Malloced {
658
980
  void link_to(Label* L, Label* appendix);
659
981
  void next(Label* L);
660
982
 
983
+ // One trampoline consists of:
984
+ // - space for trampoline slots,
985
+ // - space for labels.
986
+ //
987
+ // Space for trampoline slots is equal to slot_count * 2 * kInstrSize.
988
+ // Space for trampoline slots preceeds space for labels. Each label is of one
989
+ // instruction size, so total amount for labels is equal to
990
+ // label_count * kInstrSize.
991
+ class Trampoline {
992
+ public:
993
+ Trampoline(int start, int slot_count, int label_count) {
994
+ start_ = start;
995
+ next_slot_ = start;
996
+ free_slot_count_ = slot_count;
997
+ next_label_ = start + slot_count * 2 * kInstrSize;
998
+ free_label_count_ = label_count;
999
+ end_ = next_label_ + (label_count - 1) * kInstrSize;
1000
+ }
1001
+ int start() {
1002
+ return start_;
1003
+ }
1004
+ int end() {
1005
+ return end_;
1006
+ }
1007
+ int take_slot() {
1008
+ int trampoline_slot = next_slot_;
1009
+ ASSERT(free_slot_count_ > 0);
1010
+ free_slot_count_--;
1011
+ next_slot_ += 2 * kInstrSize;
1012
+ return trampoline_slot;
1013
+ }
1014
+ int take_label() {
1015
+ int label_pos = next_label_;
1016
+ ASSERT(free_label_count_ > 0);
1017
+ free_label_count_--;
1018
+ next_label_ += kInstrSize;
1019
+ return label_pos;
1020
+ }
1021
+ private:
1022
+ int start_;
1023
+ int end_;
1024
+ int next_slot_;
1025
+ int free_slot_count_;
1026
+ int next_label_;
1027
+ int free_label_count_;
1028
+ };
1029
+
1030
+ int32_t get_label_entry(int32_t pos, bool next_pool = true);
1031
+ int32_t get_trampoline_entry(int32_t pos, bool next_pool = true);
1032
+
1033
+ static const int kSlotsPerTrampoline = 2304;
1034
+ static const int kLabelsPerTrampoline = 8;
1035
+ static const int kTrampolineInst =
1036
+ 2 * kSlotsPerTrampoline + kLabelsPerTrampoline;
1037
+ static const int kTrampolineSize = kTrampolineInst * kInstrSize;
1038
+ static const int kMaxBranchOffset = (1 << (18 - 1)) - 1;
1039
+ static const int kMaxDistBetweenPools =
1040
+ kMaxBranchOffset - 2 * kTrampolineSize;
1041
+
1042
+ List<Trampoline> trampolines_;
1043
+
661
1044
  friend class RegExpMacroAssemblerMIPS;
662
1045
  friend class RelocInfo;
1046
+ friend class CodePatcher;
1047
+ friend class BlockTrampolinePoolScope;
1048
+
1049
+ PositionsRecorder positions_recorder_;
1050
+ bool allow_peephole_optimization_;
1051
+ bool emit_debug_code_;
1052
+ friend class PositionsRecorder;
1053
+ friend class EnsureSpace;
1054
+ };
1055
+
1056
+
1057
+ class EnsureSpace BASE_EMBEDDED {
1058
+ public:
1059
+ explicit EnsureSpace(Assembler* assembler) {
1060
+ assembler->CheckBuffer();
1061
+ }
663
1062
  };
664
1063
 
665
1064
  } } // namespace v8::internal