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
@@ -36,69 +36,171 @@ namespace internal {
36
36
 
37
37
  // Forward declaration.
38
38
  class JumpTarget;
39
+ class PostCallGenerator;
39
40
 
40
- // Register at is used for instruction generation. So it is not safe to use it
41
- // unless we know exactly what we do.
41
+ // Reserved Register Usage Summary.
42
+ //
43
+ // Registers t8, t9, and at are reserved for use by the MacroAssembler.
44
+ //
45
+ // The programmer should know that the MacroAssembler may clobber these three,
46
+ // but won't touch other registers except in special cases.
47
+ //
48
+ // Per the MIPS ABI, register t9 must be used for indirect function call
49
+ // via 'jalr t9' or 'jr t9' instructions. This is relied upon by gcc when
50
+ // trying to update gp register for position-independent-code. Whenever
51
+ // MIPS generated code calls C code, it must be via t9 register.
42
52
 
43
53
  // Registers aliases
44
54
  // cp is assumed to be a callee saved register.
55
+ const Register roots = s6; // Roots array pointer.
45
56
  const Register cp = s7; // JavaScript context pointer
46
57
  const Register fp = s8_fp; // Alias fp
58
+ // Register used for condition evaluation.
59
+ const Register condReg1 = s4;
60
+ const Register condReg2 = s5;
47
61
 
48
62
  enum InvokeJSFlags {
49
63
  CALL_JS,
50
64
  JUMP_JS
51
65
  };
52
66
 
67
+
68
+ // Flags used for the AllocateInNewSpace functions.
69
+ enum AllocationFlags {
70
+ // No special flags.
71
+ NO_ALLOCATION_FLAGS = 0,
72
+ // Return the pointer to the allocated already tagged as a heap object.
73
+ TAG_OBJECT = 1 << 0,
74
+ // The content of the result register already contains the allocation top in
75
+ // new space.
76
+ RESULT_CONTAINS_TOP = 1 << 1,
77
+ // Specify that the requested size of the space to allocate is specified in
78
+ // words instead of bytes.
79
+ SIZE_IN_WORDS = 1 << 2
80
+ };
81
+
82
+ // Flags used for the ObjectToDoubleFPURegister function.
83
+ enum ObjectToDoubleFlags {
84
+ // No special flags.
85
+ NO_OBJECT_TO_DOUBLE_FLAGS = 0,
86
+ // Object is known to be a non smi.
87
+ OBJECT_NOT_SMI = 1 << 0,
88
+ // Don't load NaNs or infinities, branch to the non number case instead.
89
+ AVOID_NANS_AND_INFINITIES = 1 << 1
90
+ };
91
+
92
+ // Allow programmer to use Branch Delay Slot of Branches, Jumps, Calls.
93
+ enum BranchDelaySlot {
94
+ USE_DELAY_SLOT,
95
+ PROTECT
96
+ };
97
+
53
98
  // MacroAssembler implements a collection of frequently used macros.
54
99
  class MacroAssembler: public Assembler {
55
100
  public:
56
101
  MacroAssembler(void* buffer, int size);
57
102
 
58
- // Jump, Call, and Ret pseudo instructions implementing inter-working.
59
- void Jump(const Operand& target,
60
- Condition cond = cc_always,
61
- Register r1 = zero_reg, const Operand& r2 = Operand(zero_reg));
62
- void Call(const Operand& target,
63
- Condition cond = cc_always,
64
- Register r1 = zero_reg, const Operand& r2 = Operand(zero_reg));
65
- void Jump(Register target,
66
- Condition cond = cc_always,
67
- Register r1 = zero_reg, const Operand& r2 = Operand(zero_reg));
68
- void Jump(byte* target, RelocInfo::Mode rmode,
69
- Condition cond = cc_always,
70
- Register r1 = zero_reg, const Operand& r2 = Operand(zero_reg));
71
- void Jump(Handle<Code> code, RelocInfo::Mode rmode,
72
- Condition cond = cc_always,
73
- Register r1 = zero_reg, const Operand& r2 = Operand(zero_reg));
74
- void Call(Register target,
75
- Condition cond = cc_always,
76
- Register r1 = zero_reg, const Operand& r2 = Operand(zero_reg));
77
- void Call(byte* target, RelocInfo::Mode rmode,
78
- Condition cond = cc_always,
79
- Register r1 = zero_reg, const Operand& r2 = Operand(zero_reg));
80
- void Call(Handle<Code> code, RelocInfo::Mode rmode,
81
- Condition cond = cc_always,
82
- Register r1 = zero_reg, const Operand& r2 = Operand(zero_reg));
83
- void Ret(Condition cond = cc_always,
84
- Register r1 = zero_reg, const Operand& r2 = Operand(zero_reg));
85
- void Branch(Condition cond, int16_t offset, Register rs = zero_reg,
86
- const Operand& rt = Operand(zero_reg), Register scratch = at);
87
- void Branch(Condition cond, Label* L, Register rs = zero_reg,
88
- const Operand& rt = Operand(zero_reg), Register scratch = at);
89
- // conditionnal branch and link
90
- void BranchAndLink(Condition cond, int16_t offset, Register rs = zero_reg,
91
- const Operand& rt = Operand(zero_reg),
92
- Register scratch = at);
93
- void BranchAndLink(Condition cond, Label* L, Register rs = zero_reg,
94
- const Operand& rt = Operand(zero_reg),
95
- Register scratch = at);
103
+ // Arguments macros
104
+ #define COND_TYPED_ARGS Condition cond, Register r1, const Operand& r2
105
+ #define COND_ARGS cond, r1, r2
106
+
107
+ // ** Prototypes
108
+
109
+ // * Prototypes for functions with no target (eg Ret()).
110
+ #define DECLARE_NOTARGET_PROTOTYPE(Name) \
111
+ void Name(BranchDelaySlot bd = PROTECT); \
112
+ void Name(COND_TYPED_ARGS, BranchDelaySlot bd = PROTECT); \
113
+ inline void Name(BranchDelaySlot bd, COND_TYPED_ARGS) { \
114
+ Name(COND_ARGS, bd); \
115
+ }
116
+
117
+ // * Prototypes for functions with a target.
118
+
119
+ // Cases when relocation may be needed.
120
+ #define DECLARE_RELOC_PROTOTYPE(Name, target_type) \
121
+ void Name(target_type target, \
122
+ RelocInfo::Mode rmode, \
123
+ BranchDelaySlot bd = PROTECT); \
124
+ inline void Name(BranchDelaySlot bd, \
125
+ target_type target, \
126
+ RelocInfo::Mode rmode) { \
127
+ Name(target, rmode, bd); \
128
+ } \
129
+ void Name(target_type target, \
130
+ RelocInfo::Mode rmode, \
131
+ COND_TYPED_ARGS, \
132
+ BranchDelaySlot bd = PROTECT); \
133
+ inline void Name(BranchDelaySlot bd, \
134
+ target_type target, \
135
+ RelocInfo::Mode rmode, \
136
+ COND_TYPED_ARGS) { \
137
+ Name(target, rmode, COND_ARGS, bd); \
138
+ }
139
+
140
+ // Cases when relocation is not needed.
141
+ #define DECLARE_NORELOC_PROTOTYPE(Name, target_type) \
142
+ void Name(target_type target, BranchDelaySlot bd = PROTECT); \
143
+ inline void Name(BranchDelaySlot bd, target_type target) { \
144
+ Name(target, bd); \
145
+ } \
146
+ void Name(target_type target, \
147
+ COND_TYPED_ARGS, \
148
+ BranchDelaySlot bd = PROTECT); \
149
+ inline void Name(BranchDelaySlot bd, \
150
+ target_type target, \
151
+ COND_TYPED_ARGS) { \
152
+ Name(target, COND_ARGS, bd); \
153
+ }
154
+
155
+ // ** Target prototypes.
156
+
157
+ #define DECLARE_JUMP_CALL_PROTOTYPES(Name) \
158
+ DECLARE_NORELOC_PROTOTYPE(Name, Register) \
159
+ DECLARE_NORELOC_PROTOTYPE(Name, const Operand&) \
160
+ DECLARE_RELOC_PROTOTYPE(Name, byte*) \
161
+ DECLARE_RELOC_PROTOTYPE(Name, Handle<Code>)
162
+
163
+ #define DECLARE_BRANCH_PROTOTYPES(Name) \
164
+ DECLARE_NORELOC_PROTOTYPE(Name, Label*) \
165
+ DECLARE_NORELOC_PROTOTYPE(Name, int16_t)
166
+
167
+
168
+ DECLARE_JUMP_CALL_PROTOTYPES(Jump)
169
+ DECLARE_JUMP_CALL_PROTOTYPES(Call)
170
+
171
+ DECLARE_BRANCH_PROTOTYPES(Branch)
172
+ DECLARE_BRANCH_PROTOTYPES(BranchAndLink)
173
+
174
+ DECLARE_NOTARGET_PROTOTYPE(Ret)
175
+
176
+ #undef COND_TYPED_ARGS
177
+ #undef COND_ARGS
178
+ #undef DECLARE_NOTARGET_PROTOTYPE
179
+ #undef DECLARE_NORELOC_PROTOTYPE
180
+ #undef DECLARE_RELOC_PROTOTYPE
181
+ #undef DECLARE_JUMP_CALL_PROTOTYPES
182
+ #undef DECLARE_BRANCH_PROTOTYPES
96
183
 
97
184
  // Emit code to discard a non-negative number of pointer-sized elements
98
185
  // from the stack, clobbering only the sp register.
99
- void Drop(int count, Condition cond = cc_always);
186
+ void Drop(int count,
187
+ Condition cond = cc_always,
188
+ Register reg = no_reg,
189
+ const Operand& op = Operand(no_reg));
190
+
191
+ void DropAndRet(int drop = 0,
192
+ Condition cond = cc_always,
193
+ Register reg = no_reg,
194
+ const Operand& op = Operand(no_reg));
195
+
196
+ // Swap two registers. If the scratch register is omitted then a slightly
197
+ // less efficient form using xor instead of mov is emitted.
198
+ void Swap(Register reg1, Register reg2, Register scratch = no_reg);
100
199
 
101
200
  void Call(Label* target);
201
+ // May do nothing if the registers are identical.
202
+ void Move(Register dst, Register src);
203
+
102
204
 
103
205
  // Jump unconditionally to given label.
104
206
  // We NEED a nop in the branch delay slot, as it used by v8, for example in
@@ -106,7 +208,7 @@ class MacroAssembler: public Assembler {
106
208
  // Currently the branch delay slot is filled by the MacroAssembler.
107
209
  // Use rather b(Label) for code generation.
108
210
  void jmp(Label* L) {
109
- Branch(cc_always, L);
211
+ Branch(L);
110
212
  }
111
213
 
112
214
  // Load an object from the root table.
@@ -116,19 +218,164 @@ class MacroAssembler: public Assembler {
116
218
  Heap::RootListIndex index,
117
219
  Condition cond, Register src1, const Operand& src2);
118
220
 
119
- // Load an external reference.
120
- void LoadExternalReference(Register reg, ExternalReference ext) {
121
- li(reg, Operand(ext));
221
+ // Store an object to the root table.
222
+ void StoreRoot(Register source,
223
+ Heap::RootListIndex index);
224
+ void StoreRoot(Register source,
225
+ Heap::RootListIndex index,
226
+ Condition cond, Register src1, const Operand& src2);
227
+
228
+
229
+ // Check if object is in new space.
230
+ // scratch can be object itself, but it will be clobbered.
231
+ void InNewSpace(Register object,
232
+ Register scratch,
233
+ Condition cc, // eq for new space, ne otherwise.
234
+ Label* branch);
235
+
236
+
237
+ // For the page containing |object| mark the region covering [address]
238
+ // dirty. The object address must be in the first 8K of an allocated page.
239
+ void RecordWriteHelper(Register object,
240
+ Register address,
241
+ Register scratch);
242
+
243
+ // For the page containing |object| mark the region covering
244
+ // [object+offset] dirty. The object address must be in the first 8K
245
+ // of an allocated page. The 'scratch' registers are used in the
246
+ // implementation and all 3 registers are clobbered by the
247
+ // operation, as well as the 'at' register. RecordWrite updates the
248
+ // write barrier even when storing smis.
249
+ void RecordWrite(Register object,
250
+ Operand offset,
251
+ Register scratch0,
252
+ Register scratch1);
253
+
254
+ // For the page containing |object| mark the region covering
255
+ // [address] dirty. The object address must be in the first 8K of an
256
+ // allocated page. All 3 registers are clobbered by the operation,
257
+ // as well as the ip register. RecordWrite updates the write barrier
258
+ // even when storing smis.
259
+ void RecordWrite(Register object,
260
+ Register address,
261
+ Register scratch);
262
+
263
+
264
+ // ---------------------------------------------------------------------------
265
+ // Inline caching support
266
+
267
+ // Generate code for checking access rights - used for security checks
268
+ // on access to global objects across environments. The holder register
269
+ // is left untouched, whereas both scratch registers are clobbered.
270
+ void CheckAccessGlobalProxy(Register holder_reg,
271
+ Register scratch,
272
+ Label* miss);
273
+
274
+ inline void MarkCode(NopMarkerTypes type) {
275
+ nop(type);
276
+ }
277
+
278
+ // Check if the given instruction is a 'type' marker.
279
+ // ie. check if it is a sll zero_reg, zero_reg, <type> (referenced as
280
+ // nop(type)). These instructions are generated to mark special location in
281
+ // the code, like some special IC code.
282
+ static inline bool IsMarkedCode(Instr instr, int type) {
283
+ ASSERT((FIRST_IC_MARKER <= type) && (type < LAST_CODE_MARKER));
284
+ return IsNop(instr, type);
285
+ }
286
+
287
+
288
+ static inline int GetCodeMarker(Instr instr) {
289
+ uint32_t opcode = ((instr & kOpcodeMask));
290
+ uint32_t rt = ((instr & kRtFieldMask) >> kRtShift);
291
+ uint32_t rs = ((instr & kRsFieldMask) >> kRsShift);
292
+ uint32_t sa = ((instr & kSaFieldMask) >> kSaShift);
293
+
294
+ // Return <n> if we have a sll zero_reg, zero_reg, n
295
+ // else return -1.
296
+ bool sllzz = (opcode == SLL &&
297
+ rt == static_cast<uint32_t>(ToNumber(zero_reg)) &&
298
+ rs == static_cast<uint32_t>(ToNumber(zero_reg)));
299
+ int type =
300
+ (sllzz && FIRST_IC_MARKER <= sa && sa < LAST_CODE_MARKER) ? sa : -1;
301
+ ASSERT((type == -1) ||
302
+ ((FIRST_IC_MARKER <= type) && (type < LAST_CODE_MARKER)));
303
+ return type;
122
304
  }
123
305
 
124
- // Sets the remembered set bit for [address+offset].
125
- void RecordWrite(Register object, Register offset, Register scratch);
126
306
 
127
307
 
308
+ // ---------------------------------------------------------------------------
309
+ // Allocation support
310
+
311
+ // Allocate an object in new space. The object_size is specified
312
+ // either in bytes or in words if the allocation flag SIZE_IN_WORDS
313
+ // is passed. If the new space is exhausted control continues at the
314
+ // gc_required label. The allocated object is returned in result. If
315
+ // the flag tag_allocated_object is true the result is tagged as as
316
+ // a heap object. All registers are clobbered also when control
317
+ // continues at the gc_required label.
318
+ void AllocateInNewSpace(int object_size,
319
+ Register result,
320
+ Register scratch1,
321
+ Register scratch2,
322
+ Label* gc_required,
323
+ AllocationFlags flags);
324
+ void AllocateInNewSpace(Register object_size,
325
+ Register result,
326
+ Register scratch1,
327
+ Register scratch2,
328
+ Label* gc_required,
329
+ AllocationFlags flags);
330
+
331
+ // Undo allocation in new space. The object passed and objects allocated after
332
+ // it will no longer be allocated. The caller must make sure that no pointers
333
+ // are left to the object(s) no longer allocated as they would be invalid when
334
+ // allocation is undone.
335
+ void UndoAllocationInNewSpace(Register object, Register scratch);
336
+
337
+
338
+ void AllocateTwoByteString(Register result,
339
+ Register length,
340
+ Register scratch1,
341
+ Register scratch2,
342
+ Register scratch3,
343
+ Label* gc_required);
344
+ void AllocateAsciiString(Register result,
345
+ Register length,
346
+ Register scratch1,
347
+ Register scratch2,
348
+ Register scratch3,
349
+ Label* gc_required);
350
+ void AllocateTwoByteConsString(Register result,
351
+ Register length,
352
+ Register scratch1,
353
+ Register scratch2,
354
+ Label* gc_required);
355
+ void AllocateAsciiConsString(Register result,
356
+ Register length,
357
+ Register scratch1,
358
+ Register scratch2,
359
+ Label* gc_required);
360
+
361
+ // Allocates a heap number or jumps to the gc_required label if the young
362
+ // space is full and a scavenge is needed. All registers are clobbered also
363
+ // when control continues at the gc_required label.
364
+ void AllocateHeapNumber(Register result,
365
+ Register scratch1,
366
+ Register scratch2,
367
+ Register heap_number_map,
368
+ Label* gc_required);
369
+ void AllocateHeapNumberWithValue(Register result,
370
+ FPURegister value,
371
+ Register scratch1,
372
+ Register scratch2,
373
+ Label* gc_required);
374
+
128
375
  // ---------------------------------------------------------------------------
129
376
  // Instruction macros
130
377
 
131
- #define DEFINE_INSTRUCTION(instr) \
378
+ #define DEFINE_INSTRUCTION(instr) \
132
379
  void instr(Register rd, Register rs, const Operand& rt); \
133
380
  void instr(Register rd, Register rs, Register rt) { \
134
381
  instr(rd, rs, Operand(rt)); \
@@ -137,7 +384,7 @@ class MacroAssembler: public Assembler {
137
384
  instr(rs, rt, Operand(j)); \
138
385
  }
139
386
 
140
- #define DEFINE_INSTRUCTION2(instr) \
387
+ #define DEFINE_INSTRUCTION2(instr) \
141
388
  void instr(Register rs, const Operand& rt); \
142
389
  void instr(Register rs, Register rt) { \
143
390
  instr(rs, Operand(rt)); \
@@ -146,8 +393,8 @@ class MacroAssembler: public Assembler {
146
393
  instr(rs, Operand(j)); \
147
394
  }
148
395
 
149
- DEFINE_INSTRUCTION(Add);
150
396
  DEFINE_INSTRUCTION(Addu);
397
+ DEFINE_INSTRUCTION(Subu);
151
398
  DEFINE_INSTRUCTION(Mul);
152
399
  DEFINE_INSTRUCTION2(Mult);
153
400
  DEFINE_INSTRUCTION2(Multu);
@@ -162,6 +409,9 @@ class MacroAssembler: public Assembler {
162
409
  DEFINE_INSTRUCTION(Slt);
163
410
  DEFINE_INSTRUCTION(Sltu);
164
411
 
412
+ // MIPS32 R2 instruction macro.
413
+ DEFINE_INSTRUCTION(Ror);
414
+
165
415
  #undef DEFINE_INSTRUCTION
166
416
  #undef DEFINE_INSTRUCTION2
167
417
 
@@ -169,8 +419,6 @@ class MacroAssembler: public Assembler {
169
419
  //------------Pseudo-instructions-------------
170
420
 
171
421
  void mov(Register rd, Register rt) { or_(rd, rt, zero_reg); }
172
- // Move the logical ones complement of source to dest.
173
- void movn(Register rd, Register rt);
174
422
 
175
423
 
176
424
  // load int32 in the rd register
@@ -178,6 +426,9 @@ class MacroAssembler: public Assembler {
178
426
  inline void li(Register rd, int32_t j, bool gen2instr = false) {
179
427
  li(rd, Operand(j), gen2instr);
180
428
  }
429
+ inline void li(Register dst, Handle<Object> value, bool gen2instr = false) {
430
+ li(dst, Operand(value), gen2instr);
431
+ }
181
432
 
182
433
  // Exception-generating instructions and debugging support
183
434
  void stop(const char* msg);
@@ -188,19 +439,51 @@ class MacroAssembler: public Assembler {
188
439
  // saved in higher memory addresses
189
440
  void MultiPush(RegList regs);
190
441
  void MultiPushReversed(RegList regs);
442
+
191
443
  void Push(Register src) {
192
444
  Addu(sp, sp, Operand(-kPointerSize));
193
445
  sw(src, MemOperand(sp, 0));
194
446
  }
447
+
448
+ // Push two registers. Pushes leftmost register first (to highest address).
449
+ void Push(Register src1, Register src2, Condition cond = al) {
450
+ ASSERT(cond == al); // Do not support conditional versions yet.
451
+ Subu(sp, sp, Operand(2 * kPointerSize));
452
+ sw(src1, MemOperand(sp, 1 * kPointerSize));
453
+ sw(src2, MemOperand(sp, 0 * kPointerSize));
454
+ }
455
+
456
+ // Push three registers. Pushes leftmost register first (to highest address).
457
+ void Push(Register src1, Register src2, Register src3, Condition cond = al) {
458
+ ASSERT(cond == al); // Do not support conditional versions yet.
459
+ Addu(sp, sp, Operand(3 * -kPointerSize));
460
+ sw(src1, MemOperand(sp, 2 * kPointerSize));
461
+ sw(src2, MemOperand(sp, 1 * kPointerSize));
462
+ sw(src3, MemOperand(sp, 0 * kPointerSize));
463
+ }
464
+
465
+ // Push four registers. Pushes leftmost register first (to highest address).
466
+ void Push(Register src1, Register src2,
467
+ Register src3, Register src4, Condition cond = al) {
468
+ ASSERT(cond == al); // Do not support conditional versions yet.
469
+ Addu(sp, sp, Operand(4 * -kPointerSize));
470
+ sw(src1, MemOperand(sp, 3 * kPointerSize));
471
+ sw(src2, MemOperand(sp, 2 * kPointerSize));
472
+ sw(src3, MemOperand(sp, 1 * kPointerSize));
473
+ sw(src4, MemOperand(sp, 0 * kPointerSize));
474
+ }
475
+
195
476
  inline void push(Register src) { Push(src); }
477
+ inline void pop(Register src) { Pop(src); }
196
478
 
197
479
  void Push(Register src, Condition cond, Register tst1, Register tst2) {
198
480
  // Since we don't have conditionnal execution we use a Branch.
199
- Branch(cond, 3, tst1, Operand(tst2));
481
+ Branch(3, cond, tst1, Operand(tst2));
200
482
  Addu(sp, sp, Operand(-kPointerSize));
201
483
  sw(src, MemOperand(sp, 0));
202
484
  }
203
485
 
486
+
204
487
  // Pops multiple values from the stack and load them in the
205
488
  // registers specified in regs. Pop order is the opposite as in MultiPush.
206
489
  void MultiPop(RegList regs);
@@ -209,44 +492,108 @@ class MacroAssembler: public Assembler {
209
492
  lw(dst, MemOperand(sp, 0));
210
493
  Addu(sp, sp, Operand(kPointerSize));
211
494
  }
212
- void Pop() {
213
- Add(sp, sp, Operand(kPointerSize));
495
+ void Pop(uint32_t count = 1) {
496
+ Addu(sp, sp, Operand(count * kPointerSize));
497
+ }
498
+
499
+ // ---------------------------------------------------------------------------
500
+ // These functions are only used by crankshaft, so they are currently
501
+ // unimplemented.
502
+
503
+ // Push and pop the registers that can hold pointers, as defined by the
504
+ // RegList constant kSafepointSavedRegisters.
505
+ void PushSafepointRegisters() {
506
+ UNIMPLEMENTED_MIPS();
507
+ }
508
+
509
+ void PopSafepointRegisters() {
510
+ UNIMPLEMENTED_MIPS();
511
+ }
512
+
513
+ void PushSafepointRegistersAndDoubles() {
514
+ UNIMPLEMENTED_MIPS();
214
515
  }
215
516
 
517
+ void PopSafepointRegistersAndDoubles() {
518
+ UNIMPLEMENTED_MIPS();
519
+ }
520
+
521
+ static int SafepointRegisterStackIndex(int reg_code) {
522
+ UNIMPLEMENTED_MIPS();
523
+ return 0;
524
+ }
216
525
 
217
526
  // ---------------------------------------------------------------------------
527
+
528
+ // MIPS32 R2 instruction macro.
529
+ void Ins(Register rt, Register rs, uint16_t pos, uint16_t size);
530
+ void Ext(Register rt, Register rs, uint16_t pos, uint16_t size);
531
+
532
+ // Convert unsigned word to double.
533
+ void Cvt_d_uw(FPURegister fd, FPURegister fs);
534
+ void Cvt_d_uw(FPURegister fd, Register rs);
535
+
536
+ // Convert double to unsigned word.
537
+ void Trunc_uw_d(FPURegister fd, FPURegister fs);
538
+ void Trunc_uw_d(FPURegister fd, Register rs);
539
+
540
+ // Convert the HeapNumber pointed to by source to a 32bits signed integer
541
+ // dest. If the HeapNumber does not fit into a 32bits signed integer branch
542
+ // to not_int32 label. If FPU is available double_scratch is used but not
543
+ // scratch2.
544
+ void ConvertToInt32(Register source,
545
+ Register dest,
546
+ Register scratch,
547
+ Register scratch2,
548
+ FPURegister double_scratch,
549
+ Label *not_int32);
550
+
551
+ // -------------------------------------------------------------------------
218
552
  // Activation frames
219
553
 
220
554
  void EnterInternalFrame() { EnterFrame(StackFrame::INTERNAL); }
221
555
  void LeaveInternalFrame() { LeaveFrame(StackFrame::INTERNAL); }
222
556
 
223
- // Enter specific kind of exit frame; either EXIT or
224
- // EXIT_DEBUG. Expects the number of arguments in register a0 and
557
+ void EnterConstructFrame() { EnterFrame(StackFrame::CONSTRUCT); }
558
+ void LeaveConstructFrame() { LeaveFrame(StackFrame::CONSTRUCT); }
559
+
560
+ // Enter exit frame.
561
+ // Expects the number of arguments in register a0 and
225
562
  // the builtin function to call in register a1.
226
563
  // On output hold_argc, hold_function, and hold_argv are setup.
227
- void EnterExitFrame(ExitFrame::Mode mode,
228
- Register hold_argc,
564
+ void EnterExitFrame(Register hold_argc,
229
565
  Register hold_argv,
230
- Register hold_function);
566
+ Register hold_function,
567
+ bool save_doubles);
231
568
 
232
569
  // Leave the current exit frame. Expects the return value in v0.
233
- void LeaveExitFrame(ExitFrame::Mode mode);
570
+ void LeaveExitFrame(bool save_doubles);
234
571
 
235
572
  // Align the stack by optionally pushing a Smi zero.
236
- void AlignStack(int offset);
573
+ void AlignStack(int offset); // TODO(mips) : remove this function.
237
574
 
238
- void SetupAlignedCall(Register scratch, int arg_count = 0);
239
- void ReturnFromAlignedCall();
575
+ // Get the actual activation frame alignment for target environment.
576
+ static int ActivationFrameAlignment();
240
577
 
578
+ void LoadContext(Register dst, int context_chain_length);
241
579
 
242
- // ---------------------------------------------------------------------------
580
+ void LoadGlobalFunction(int index, Register function);
581
+
582
+ // Load the initial map from the global function. The registers
583
+ // function and map can be the same, function is then overwritten.
584
+ void LoadGlobalFunctionInitialMap(Register function,
585
+ Register map,
586
+ Register scratch);
587
+
588
+ // -------------------------------------------------------------------------
243
589
  // JavaScript invokes
244
590
 
245
591
  // Invoke the JavaScript function code by either calling or jumping.
246
592
  void InvokeCode(Register code,
247
593
  const ParameterCount& expected,
248
594
  const ParameterCount& actual,
249
- InvokeFlag flag);
595
+ InvokeFlag flag,
596
+ PostCallGenerator* post_call_generator = NULL);
250
597
 
251
598
  void InvokeCode(Handle<Code> code,
252
599
  const ParameterCount& expected,
@@ -257,85 +604,136 @@ class MacroAssembler: public Assembler {
257
604
  // Invoke the JavaScript function in the given register. Changes the
258
605
  // current context to the context in the function before invoking.
259
606
  void InvokeFunction(Register function,
607
+ const ParameterCount& actual,
608
+ InvokeFlag flag,
609
+ PostCallGenerator* post_call_generator = NULL);
610
+
611
+ void InvokeFunction(JSFunction* function,
260
612
  const ParameterCount& actual,
261
613
  InvokeFlag flag);
262
614
 
263
615
 
616
+ void IsObjectJSObjectType(Register heap_object,
617
+ Register map,
618
+ Register scratch,
619
+ Label* fail);
620
+
621
+ void IsInstanceJSObjectType(Register map,
622
+ Register scratch,
623
+ Label* fail);
624
+
625
+ void IsObjectJSStringType(Register object,
626
+ Register scratch,
627
+ Label* fail);
628
+
264
629
  #ifdef ENABLE_DEBUGGER_SUPPORT
265
- // ---------------------------------------------------------------------------
630
+ // -------------------------------------------------------------------------
266
631
  // Debugger Support
267
632
 
268
- void SaveRegistersToMemory(RegList regs);
269
- void RestoreRegistersFromMemory(RegList regs);
270
- void CopyRegistersFromMemoryToStack(Register base, RegList regs);
271
- void CopyRegistersFromStackToMemory(Register base,
272
- Register scratch,
273
- RegList regs);
274
633
  void DebugBreak();
275
634
  #endif
276
635
 
277
636
 
278
- // ---------------------------------------------------------------------------
637
+ // -------------------------------------------------------------------------
279
638
  // Exception handling
280
639
 
281
640
  // Push a new try handler and link into try handler chain.
282
641
  // The return address must be passed in register ra.
642
+ // Clobber t0, t1, t2.
283
643
  void PushTryHandler(CodeLocation try_location, HandlerType type);
284
644
 
285
645
  // Unlink the stack handler on top of the stack from the try handler chain.
286
646
  // Must preserve the result register.
287
647
  void PopTryHandler();
288
648
 
649
+ // Copies a fixed number of fields of heap objects from src to dst.
650
+ void CopyFields(Register dst, Register src, RegList temps, int field_count);
289
651
 
290
- // ---------------------------------------------------------------------------
652
+ // -------------------------------------------------------------------------
291
653
  // Support functions.
292
654
 
655
+ // Try to get function prototype of a function and puts the value in
656
+ // the result register. Checks that the function really is a
657
+ // function and jumps to the miss label if the fast checks fail. The
658
+ // function register will be untouched; the other registers may be
659
+ // clobbered.
660
+ void TryGetFunctionPrototype(Register function,
661
+ Register result,
662
+ Register scratch,
663
+ Label* miss);
664
+
293
665
  void GetObjectType(Register function,
294
666
  Register map,
295
667
  Register type_reg);
296
668
 
297
- inline void BranchOnSmi(Register value, Label* smi_label,
298
- Register scratch = at) {
299
- ASSERT_EQ(0, kSmiTag);
300
- andi(scratch, value, kSmiTagMask);
301
- Branch(eq, smi_label, scratch, Operand(zero_reg));
302
- }
303
-
304
-
305
- inline void BranchOnNotSmi(Register value, Label* not_smi_label,
306
- Register scratch = at) {
307
- ASSERT_EQ(0, kSmiTag);
308
- andi(scratch, value, kSmiTagMask);
309
- Branch(ne, not_smi_label, scratch, Operand(zero_reg));
310
- }
311
-
312
- void CallBuiltin(ExternalReference builtin_entry);
313
- void CallBuiltin(Register target);
314
- void JumpToBuiltin(ExternalReference builtin_entry);
315
- void JumpToBuiltin(Register target);
669
+ // Check if the map of an object is equal to a specified map (either
670
+ // given directly or as an index into the root list) and branch to
671
+ // label if not. Skip the smi check if not required (object is known
672
+ // to be a heap object)
673
+ void CheckMap(Register obj,
674
+ Register scratch,
675
+ Handle<Map> map,
676
+ Label* fail,
677
+ bool is_heap_object);
678
+
679
+ void CheckMap(Register obj,
680
+ Register scratch,
681
+ Heap::RootListIndex index,
682
+ Label* fail,
683
+ bool is_heap_object);
316
684
 
317
685
  // Generates code for reporting that an illegal operation has
318
686
  // occurred.
319
687
  void IllegalOperation(int num_arguments);
320
688
 
321
-
322
- // ---------------------------------------------------------------------------
689
+ // Picks out an array index from the hash field.
690
+ // Register use:
691
+ // hash - holds the index's hash. Clobbered.
692
+ // index - holds the overwritten index on exit.
693
+ void IndexFromHash(Register hash, Register index);
694
+
695
+ // Load the value of a number object into a FPU double register. If the
696
+ // object is not a number a jump to the label not_number is performed
697
+ // and the FPU double register is unchanged.
698
+ void ObjectToDoubleFPURegister(
699
+ Register object,
700
+ FPURegister value,
701
+ Register scratch1,
702
+ Register scratch2,
703
+ Register heap_number_map,
704
+ Label* not_number,
705
+ ObjectToDoubleFlags flags = NO_OBJECT_TO_DOUBLE_FLAGS);
706
+
707
+ // Load the value of a smi object into a FPU double register. The register
708
+ // scratch1 can be the same register as smi in which case smi will hold the
709
+ // untagged value afterwards.
710
+ void SmiToDoubleFPURegister(Register smi,
711
+ FPURegister value,
712
+ Register scratch1);
713
+
714
+ // -------------------------------------------------------------------------
323
715
  // Runtime calls
324
716
 
325
717
  // Call a code stub.
326
718
  void CallStub(CodeStub* stub, Condition cond = cc_always,
327
719
  Register r1 = zero_reg, const Operand& r2 = Operand(zero_reg));
328
- void CallJSExitStub(CodeStub* stub);
329
720
 
330
- // Return from a code stub after popping its arguments.
331
- void StubReturn(int argc);
721
+ // Tail call a code stub (jump).
722
+ void TailCallStub(CodeStub* stub);
723
+
724
+ void CallJSExitStub(CodeStub* stub);
332
725
 
333
726
  // Call a runtime routine.
334
- void CallRuntime(Runtime::Function* f, int num_arguments);
727
+ void CallRuntime(const Runtime::Function* f, int num_arguments);
728
+ void CallRuntimeSaveDoubles(Runtime::FunctionId id);
335
729
 
336
730
  // Convenience function: Same as above, but takes the fid instead.
337
731
  void CallRuntime(Runtime::FunctionId fid, int num_arguments);
338
732
 
733
+ // Convenience function: call an external reference.
734
+ void CallExternalReference(const ExternalReference& ext,
735
+ int num_arguments);
736
+
339
737
  // Tail call of a runtime routine (jump).
340
738
  // Like JumpToExternalReference, but also takes care of passing the number
341
739
  // of parameters.
@@ -348,34 +746,54 @@ class MacroAssembler: public Assembler {
348
746
  int num_arguments,
349
747
  int result_size);
350
748
 
749
+ // Before calling a C-function from generated code, align arguments on stack
750
+ // and add space for the four mips argument slots.
751
+ // After aligning the frame, non-register arguments must be stored on the
752
+ // stack, after the argument-slots using helper: CFunctionArgumentOperand().
753
+ // The argument count assumes all arguments are word sized.
754
+ // Some compilers/platforms require the stack to be aligned when calling
755
+ // C++ code.
756
+ // Needs a scratch register to do some arithmetic. This register will be
757
+ // trashed.
758
+ void PrepareCallCFunction(int num_arguments, Register scratch);
759
+
760
+ // Arguments 1-4 are placed in registers a0 thru a3 respectively.
761
+ // Arguments 5..n are stored to stack using following:
762
+ // sw(t0, CFunctionArgumentOperand(5));
763
+
764
+ // Calls a C function and cleans up the space for arguments allocated
765
+ // by PrepareCallCFunction. The called function is not allowed to trigger a
766
+ // garbage collection, since that might move the code and invalidate the
767
+ // return address (unless this is somehow accounted for by the called
768
+ // function).
769
+ void CallCFunction(ExternalReference function, int num_arguments);
770
+ void CallCFunction(Register function, Register scratch, int num_arguments);
771
+
351
772
  // Jump to the builtin routine.
352
773
  void JumpToExternalReference(const ExternalReference& builtin);
353
774
 
354
775
  // Invoke specified builtin JavaScript function. Adds an entry to
355
776
  // the unresolved list if the name does not resolve.
356
- void InvokeBuiltin(Builtins::JavaScript id, InvokeJSFlags flags);
777
+ void InvokeBuiltin(Builtins::JavaScript id,
778
+ InvokeJSFlags flags,
779
+ PostCallGenerator* post_call_generator = NULL);
357
780
 
358
781
  // Store the code object for the given builtin in the target register and
359
- // setup the function in r1.
782
+ // setup the function in a1.
360
783
  void GetBuiltinEntry(Register target, Builtins::JavaScript id);
361
784
 
785
+ // Store the function for the given builtin in the target register.
786
+ void GetBuiltinFunction(Register target, Builtins::JavaScript id);
787
+
362
788
  struct Unresolved {
363
789
  int pc;
364
790
  uint32_t flags; // see Bootstrapper::FixupFlags decoders/encoders.
365
791
  const char* name;
366
792
  };
367
- List<Unresolved>* unresolved() { return &unresolved_; }
368
793
 
369
794
  Handle<Object> CodeObject() { return code_object_; }
370
795
 
371
-
372
- // ---------------------------------------------------------------------------
373
- // Stack limit support
374
-
375
- void StackLimitCheck(Label* on_stack_limit_hit);
376
-
377
-
378
- // ---------------------------------------------------------------------------
796
+ // -------------------------------------------------------------------------
379
797
  // StatsCounter support
380
798
 
381
799
  void SetCounter(StatsCounter* counter, int value,
@@ -386,12 +804,14 @@ class MacroAssembler: public Assembler {
386
804
  Register scratch1, Register scratch2);
387
805
 
388
806
 
389
- // ---------------------------------------------------------------------------
807
+ // -------------------------------------------------------------------------
390
808
  // Debugging
391
809
 
392
810
  // Calls Abort(msg) if the condition cc is not satisfied.
393
811
  // Use --debug_code to enable.
394
812
  void Assert(Condition cc, const char* msg, Register rs, Operand rt);
813
+ void AssertRegisterIsRoot(Register reg, Heap::RootListIndex index);
814
+ void AssertFastElements(Register elements);
395
815
 
396
816
  // Like Assert(), but always enabled.
397
817
  void Check(Condition cc, const char* msg, Register rs, Operand rt);
@@ -405,17 +825,132 @@ class MacroAssembler: public Assembler {
405
825
  void set_allow_stub_calls(bool value) { allow_stub_calls_ = value; }
406
826
  bool allow_stub_calls() { return allow_stub_calls_; }
407
827
 
828
+ // ---------------------------------------------------------------------------
829
+ // Number utilities
830
+
831
+ // Check whether the value of reg is a power of two and not zero. If not
832
+ // control continues at the label not_power_of_two. If reg is a power of two
833
+ // the register scratch contains the value of (reg - 1) when control falls
834
+ // through.
835
+ void JumpIfNotPowerOfTwoOrZero(Register reg,
836
+ Register scratch,
837
+ Label* not_power_of_two_or_zero);
838
+
839
+ // -------------------------------------------------------------------------
840
+ // Smi utilities
841
+
842
+ // Try to convert int32 to smi. If the value is to large, preserve
843
+ // the original value and jump to not_a_smi. Destroys scratch and
844
+ // sets flags.
845
+ // This is only used by crankshaft atm so it is unimplemented on MIPS.
846
+ void TrySmiTag(Register reg, Label* not_a_smi, Register scratch) {
847
+ UNIMPLEMENTED_MIPS();
848
+ }
849
+
850
+ void SmiTag(Register reg) {
851
+ Addu(reg, reg, reg);
852
+ }
853
+
854
+ void SmiTag(Register dst, Register src) {
855
+ Addu(dst, src, src);
856
+ }
857
+
858
+ void SmiUntag(Register reg) {
859
+ sra(reg, reg, kSmiTagSize);
860
+ }
861
+
862
+ void SmiUntag(Register dst, Register src) {
863
+ sra(dst, src, kSmiTagSize);
864
+ }
865
+
866
+ // Jump the register contains a smi.
867
+ inline void JumpIfSmi(Register value, Label* smi_label,
868
+ Register scratch = at) {
869
+ ASSERT_EQ(0, kSmiTag);
870
+ andi(scratch, value, kSmiTagMask);
871
+ Branch(smi_label, eq, scratch, Operand(zero_reg));
872
+ }
873
+
874
+ // Jump if the register contains a non-smi.
875
+ inline void JumpIfNotSmi(Register value, Label* not_smi_label,
876
+ Register scratch = at) {
877
+ ASSERT_EQ(0, kSmiTag);
878
+ andi(scratch, value, kSmiTagMask);
879
+ Branch(not_smi_label, ne, scratch, Operand(zero_reg));
880
+ }
881
+
882
+ // Jump if either of the registers contain a non-smi.
883
+ void JumpIfNotBothSmi(Register reg1, Register reg2, Label* on_not_both_smi);
884
+ // Jump if either of the registers contain a smi.
885
+ void JumpIfEitherSmi(Register reg1, Register reg2, Label* on_either_smi);
886
+
887
+ // Abort execution if argument is a smi. Used in debug code.
888
+ void AbortIfSmi(Register object);
889
+ void AbortIfNotSmi(Register object);
890
+
891
+ // Abort execution if argument is not the root value with the given index.
892
+ void AbortIfNotRootValue(Register src,
893
+ Heap::RootListIndex root_value_index,
894
+ const char* message);
895
+
896
+ // ---------------------------------------------------------------------------
897
+ // HeapNumber utilities
898
+
899
+ void JumpIfNotHeapNumber(Register object,
900
+ Register heap_number_map,
901
+ Register scratch,
902
+ Label* on_not_heap_number);
903
+
904
+ // -------------------------------------------------------------------------
905
+ // String utilities
906
+
907
+ // Checks if both instance types are sequential ASCII strings and jumps to
908
+ // label if either is not.
909
+ void JumpIfBothInstanceTypesAreNotSequentialAscii(
910
+ Register first_object_instance_type,
911
+ Register second_object_instance_type,
912
+ Register scratch1,
913
+ Register scratch2,
914
+ Label* failure);
915
+
916
+ // Check if instance type is sequential ASCII string and jump to label if
917
+ // it is not.
918
+ void JumpIfInstanceTypeIsNotSequentialAscii(Register type,
919
+ Register scratch,
920
+ Label* failure);
921
+
922
+ // Test that both first and second are sequential ASCII strings.
923
+ // Assume that they are non-smis.
924
+ void JumpIfNonSmisNotBothSequentialAsciiStrings(Register first,
925
+ Register second,
926
+ Register scratch1,
927
+ Register scratch2,
928
+ Label* failure);
929
+
930
+ // Test that both first and second are sequential ASCII strings.
931
+ // Check that they are non-smis.
932
+ void JumpIfNotBothSequentialAsciiStrings(Register first,
933
+ Register second,
934
+ Register scratch1,
935
+ Register scratch2,
936
+ Label* failure);
937
+
408
938
  private:
409
- List<Unresolved> unresolved_;
410
- bool generating_stub_;
411
- bool allow_stub_calls_;
412
- // This handle will be patched with the code object on installation.
413
- Handle<Object> code_object_;
939
+ void CallCFunctionHelper(Register function,
940
+ ExternalReference function_reference,
941
+ Register scratch,
942
+ int num_arguments);
414
943
 
944
+ void Jump(intptr_t target, RelocInfo::Mode rmode,
945
+ BranchDelaySlot bd = PROTECT);
415
946
  void Jump(intptr_t target, RelocInfo::Mode rmode, Condition cond = cc_always,
416
- Register r1 = zero_reg, const Operand& r2 = Operand(zero_reg));
947
+ Register r1 = zero_reg, const Operand& r2 = Operand(zero_reg),
948
+ BranchDelaySlot bd = PROTECT);
949
+ void Call(intptr_t target, RelocInfo::Mode rmode,
950
+ BranchDelaySlot bd = PROTECT);
417
951
  void Call(intptr_t target, RelocInfo::Mode rmode, Condition cond = cc_always,
418
- Register r1 = zero_reg, const Operand& r2 = Operand(zero_reg));
952
+ Register r1 = zero_reg, const Operand& r2 = Operand(zero_reg),
953
+ BranchDelaySlot bd = PROTECT);
419
954
 
420
955
  // Helper functions for generating invokes.
421
956
  void InvokePrologue(const ParameterCount& expected,
@@ -423,22 +958,84 @@ class MacroAssembler: public Assembler {
423
958
  Handle<Code> code_constant,
424
959
  Register code_reg,
425
960
  Label* done,
426
- InvokeFlag flag);
961
+ InvokeFlag flag,
962
+ PostCallGenerator* post_call_generator = NULL);
427
963
 
428
964
  // Get the code for the given builtin. Returns if able to resolve
429
965
  // the function in the 'resolved' flag.
430
966
  Handle<Code> ResolveBuiltin(Builtins::JavaScript id, bool* resolved);
431
967
 
432
968
  // Activation support.
433
- // EnterFrame clobbers t0 and t1.
434
969
  void EnterFrame(StackFrame::Type type);
435
970
  void LeaveFrame(StackFrame::Type type);
971
+
972
+ void InitializeNewString(Register string,
973
+ Register length,
974
+ Heap::RootListIndex map_index,
975
+ Register scratch1,
976
+ Register scratch2);
977
+
978
+
979
+ bool generating_stub_;
980
+ bool allow_stub_calls_;
981
+ // This handle will be patched with the code object on installation.
982
+ Handle<Object> code_object_;
983
+ };
984
+
985
+
986
+ #ifdef ENABLE_DEBUGGER_SUPPORT
987
+ // The code patcher is used to patch (typically) small parts of code e.g. for
988
+ // debugging and other types of instrumentation. When using the code patcher
989
+ // the exact number of bytes specified must be emitted. It is not legal to emit
990
+ // relocation information. If any of these constraints are violated it causes
991
+ // an assertion to fail.
992
+ class CodePatcher {
993
+ public:
994
+ CodePatcher(byte* address, int instructions);
995
+ virtual ~CodePatcher();
996
+
997
+ // Macro assembler to emit code.
998
+ MacroAssembler* masm() { return &masm_; }
999
+
1000
+ // Emit an instruction directly.
1001
+ void Emit(Instr x);
1002
+
1003
+ // Emit an address directly.
1004
+ void Emit(Address addr);
1005
+
1006
+ private:
1007
+ byte* address_; // The address of the code being patched.
1008
+ int instructions_; // Number of instructions of the expected patch size.
1009
+ int size_; // Number of bytes of the expected patch size.
1010
+ MacroAssembler masm_; // Macro assembler used to generate the code.
1011
+ };
1012
+ #endif // ENABLE_DEBUGGER_SUPPORT
1013
+
1014
+
1015
+ // Helper class for generating code or data associated with the code
1016
+ // right after a call instruction. As an example this can be used to
1017
+ // generate safepoint data after calls for crankshaft.
1018
+ class PostCallGenerator {
1019
+ public:
1020
+ PostCallGenerator() { }
1021
+ virtual ~PostCallGenerator() { }
1022
+ virtual void Generate() = 0;
436
1023
  };
437
1024
 
438
1025
 
439
1026
  // -----------------------------------------------------------------------------
440
1027
  // Static helper functions.
441
1028
 
1029
+ static MemOperand ContextOperand(Register context, int index) {
1030
+ return MemOperand(context, Context::SlotOffset(index));
1031
+ }
1032
+
1033
+
1034
+ static inline MemOperand GlobalObjectOperand() {
1035
+ return ContextOperand(cp, Context::GLOBAL_INDEX);
1036
+ }
1037
+
1038
+
442
1039
  // Generate a MemOperand for loading a field from an object.
443
1040
  static inline MemOperand FieldMemOperand(Register object, int offset) {
444
1041
  return MemOperand(object, offset - kHeapObjectTag);