libv8-sgonyea 3.3.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (500) hide show
  1. data/.gitignore +8 -0
  2. data/.gitmodules +3 -0
  3. data/Gemfile +4 -0
  4. data/README.md +76 -0
  5. data/Rakefile +113 -0
  6. data/ext/libv8/extconf.rb +28 -0
  7. data/lib/libv8.rb +15 -0
  8. data/lib/libv8/Makefile +30 -0
  9. data/lib/libv8/detect_cpu.rb +27 -0
  10. data/lib/libv8/fpic-on-linux-amd64.patch +13 -0
  11. data/lib/libv8/v8/.gitignore +35 -0
  12. data/lib/libv8/v8/AUTHORS +44 -0
  13. data/lib/libv8/v8/ChangeLog +2839 -0
  14. data/lib/libv8/v8/LICENSE +52 -0
  15. data/lib/libv8/v8/LICENSE.strongtalk +29 -0
  16. data/lib/libv8/v8/LICENSE.v8 +26 -0
  17. data/lib/libv8/v8/LICENSE.valgrind +45 -0
  18. data/lib/libv8/v8/SConstruct +1478 -0
  19. data/lib/libv8/v8/build/README.txt +49 -0
  20. data/lib/libv8/v8/build/all.gyp +18 -0
  21. data/lib/libv8/v8/build/armu.gypi +32 -0
  22. data/lib/libv8/v8/build/common.gypi +144 -0
  23. data/lib/libv8/v8/build/gyp_v8 +145 -0
  24. data/lib/libv8/v8/include/v8-debug.h +395 -0
  25. data/lib/libv8/v8/include/v8-preparser.h +117 -0
  26. data/lib/libv8/v8/include/v8-profiler.h +505 -0
  27. data/lib/libv8/v8/include/v8-testing.h +104 -0
  28. data/lib/libv8/v8/include/v8.h +4124 -0
  29. data/lib/libv8/v8/include/v8stdint.h +53 -0
  30. data/lib/libv8/v8/preparser/SConscript +38 -0
  31. data/lib/libv8/v8/preparser/preparser-process.cc +379 -0
  32. data/lib/libv8/v8/src/SConscript +368 -0
  33. data/lib/libv8/v8/src/accessors.cc +767 -0
  34. data/lib/libv8/v8/src/accessors.h +123 -0
  35. data/lib/libv8/v8/src/allocation-inl.h +49 -0
  36. data/lib/libv8/v8/src/allocation.cc +122 -0
  37. data/lib/libv8/v8/src/allocation.h +143 -0
  38. data/lib/libv8/v8/src/api.cc +5845 -0
  39. data/lib/libv8/v8/src/api.h +574 -0
  40. data/lib/libv8/v8/src/apinatives.js +110 -0
  41. data/lib/libv8/v8/src/apiutils.h +73 -0
  42. data/lib/libv8/v8/src/arguments.h +118 -0
  43. data/lib/libv8/v8/src/arm/assembler-arm-inl.h +353 -0
  44. data/lib/libv8/v8/src/arm/assembler-arm.cc +2661 -0
  45. data/lib/libv8/v8/src/arm/assembler-arm.h +1375 -0
  46. data/lib/libv8/v8/src/arm/builtins-arm.cc +1658 -0
  47. data/lib/libv8/v8/src/arm/code-stubs-arm.cc +6398 -0
  48. data/lib/libv8/v8/src/arm/code-stubs-arm.h +673 -0
  49. data/lib/libv8/v8/src/arm/codegen-arm.cc +52 -0
  50. data/lib/libv8/v8/src/arm/codegen-arm.h +91 -0
  51. data/lib/libv8/v8/src/arm/constants-arm.cc +152 -0
  52. data/lib/libv8/v8/src/arm/constants-arm.h +775 -0
  53. data/lib/libv8/v8/src/arm/cpu-arm.cc +120 -0
  54. data/lib/libv8/v8/src/arm/debug-arm.cc +317 -0
  55. data/lib/libv8/v8/src/arm/deoptimizer-arm.cc +754 -0
  56. data/lib/libv8/v8/src/arm/disasm-arm.cc +1506 -0
  57. data/lib/libv8/v8/src/arm/frames-arm.cc +45 -0
  58. data/lib/libv8/v8/src/arm/frames-arm.h +168 -0
  59. data/lib/libv8/v8/src/arm/full-codegen-arm.cc +4375 -0
  60. data/lib/libv8/v8/src/arm/ic-arm.cc +1562 -0
  61. data/lib/libv8/v8/src/arm/lithium-arm.cc +2206 -0
  62. data/lib/libv8/v8/src/arm/lithium-arm.h +2348 -0
  63. data/lib/libv8/v8/src/arm/lithium-codegen-arm.cc +4526 -0
  64. data/lib/libv8/v8/src/arm/lithium-codegen-arm.h +403 -0
  65. data/lib/libv8/v8/src/arm/lithium-gap-resolver-arm.cc +305 -0
  66. data/lib/libv8/v8/src/arm/lithium-gap-resolver-arm.h +84 -0
  67. data/lib/libv8/v8/src/arm/macro-assembler-arm.cc +3163 -0
  68. data/lib/libv8/v8/src/arm/macro-assembler-arm.h +1126 -0
  69. data/lib/libv8/v8/src/arm/regexp-macro-assembler-arm.cc +1287 -0
  70. data/lib/libv8/v8/src/arm/regexp-macro-assembler-arm.h +253 -0
  71. data/lib/libv8/v8/src/arm/simulator-arm.cc +3424 -0
  72. data/lib/libv8/v8/src/arm/simulator-arm.h +431 -0
  73. data/lib/libv8/v8/src/arm/stub-cache-arm.cc +4243 -0
  74. data/lib/libv8/v8/src/array.js +1366 -0
  75. data/lib/libv8/v8/src/assembler.cc +1207 -0
  76. data/lib/libv8/v8/src/assembler.h +858 -0
  77. data/lib/libv8/v8/src/ast-inl.h +112 -0
  78. data/lib/libv8/v8/src/ast.cc +1146 -0
  79. data/lib/libv8/v8/src/ast.h +2188 -0
  80. data/lib/libv8/v8/src/atomicops.h +167 -0
  81. data/lib/libv8/v8/src/atomicops_internals_arm_gcc.h +145 -0
  82. data/lib/libv8/v8/src/atomicops_internals_mips_gcc.h +169 -0
  83. data/lib/libv8/v8/src/atomicops_internals_x86_gcc.cc +133 -0
  84. data/lib/libv8/v8/src/atomicops_internals_x86_gcc.h +287 -0
  85. data/lib/libv8/v8/src/atomicops_internals_x86_macosx.h +301 -0
  86. data/lib/libv8/v8/src/atomicops_internals_x86_msvc.h +203 -0
  87. data/lib/libv8/v8/src/bignum-dtoa.cc +655 -0
  88. data/lib/libv8/v8/src/bignum-dtoa.h +81 -0
  89. data/lib/libv8/v8/src/bignum.cc +768 -0
  90. data/lib/libv8/v8/src/bignum.h +140 -0
  91. data/lib/libv8/v8/src/bootstrapper.cc +2184 -0
  92. data/lib/libv8/v8/src/bootstrapper.h +188 -0
  93. data/lib/libv8/v8/src/builtins.cc +1707 -0
  94. data/lib/libv8/v8/src/builtins.h +371 -0
  95. data/lib/libv8/v8/src/bytecodes-irregexp.h +105 -0
  96. data/lib/libv8/v8/src/cached-powers.cc +177 -0
  97. data/lib/libv8/v8/src/cached-powers.h +65 -0
  98. data/lib/libv8/v8/src/char-predicates-inl.h +94 -0
  99. data/lib/libv8/v8/src/char-predicates.h +67 -0
  100. data/lib/libv8/v8/src/checks.cc +110 -0
  101. data/lib/libv8/v8/src/checks.h +296 -0
  102. data/lib/libv8/v8/src/circular-queue-inl.h +53 -0
  103. data/lib/libv8/v8/src/circular-queue.cc +122 -0
  104. data/lib/libv8/v8/src/circular-queue.h +103 -0
  105. data/lib/libv8/v8/src/code-stubs.cc +267 -0
  106. data/lib/libv8/v8/src/code-stubs.h +1011 -0
  107. data/lib/libv8/v8/src/code.h +70 -0
  108. data/lib/libv8/v8/src/codegen.cc +231 -0
  109. data/lib/libv8/v8/src/codegen.h +84 -0
  110. data/lib/libv8/v8/src/compilation-cache.cc +540 -0
  111. data/lib/libv8/v8/src/compilation-cache.h +287 -0
  112. data/lib/libv8/v8/src/compiler.cc +786 -0
  113. data/lib/libv8/v8/src/compiler.h +312 -0
  114. data/lib/libv8/v8/src/contexts.cc +347 -0
  115. data/lib/libv8/v8/src/contexts.h +391 -0
  116. data/lib/libv8/v8/src/conversions-inl.h +106 -0
  117. data/lib/libv8/v8/src/conversions.cc +1131 -0
  118. data/lib/libv8/v8/src/conversions.h +135 -0
  119. data/lib/libv8/v8/src/counters.cc +93 -0
  120. data/lib/libv8/v8/src/counters.h +254 -0
  121. data/lib/libv8/v8/src/cpu-profiler-inl.h +101 -0
  122. data/lib/libv8/v8/src/cpu-profiler.cc +609 -0
  123. data/lib/libv8/v8/src/cpu-profiler.h +302 -0
  124. data/lib/libv8/v8/src/cpu.h +69 -0
  125. data/lib/libv8/v8/src/d8-debug.cc +367 -0
  126. data/lib/libv8/v8/src/d8-debug.h +158 -0
  127. data/lib/libv8/v8/src/d8-posix.cc +695 -0
  128. data/lib/libv8/v8/src/d8-readline.cc +130 -0
  129. data/lib/libv8/v8/src/d8-windows.cc +42 -0
  130. data/lib/libv8/v8/src/d8.cc +803 -0
  131. data/lib/libv8/v8/src/d8.gyp +91 -0
  132. data/lib/libv8/v8/src/d8.h +235 -0
  133. data/lib/libv8/v8/src/d8.js +2798 -0
  134. data/lib/libv8/v8/src/data-flow.cc +66 -0
  135. data/lib/libv8/v8/src/data-flow.h +205 -0
  136. data/lib/libv8/v8/src/date.js +1103 -0
  137. data/lib/libv8/v8/src/dateparser-inl.h +127 -0
  138. data/lib/libv8/v8/src/dateparser.cc +178 -0
  139. data/lib/libv8/v8/src/dateparser.h +266 -0
  140. data/lib/libv8/v8/src/debug-agent.cc +447 -0
  141. data/lib/libv8/v8/src/debug-agent.h +129 -0
  142. data/lib/libv8/v8/src/debug-debugger.js +2569 -0
  143. data/lib/libv8/v8/src/debug.cc +3165 -0
  144. data/lib/libv8/v8/src/debug.h +1057 -0
  145. data/lib/libv8/v8/src/deoptimizer.cc +1256 -0
  146. data/lib/libv8/v8/src/deoptimizer.h +602 -0
  147. data/lib/libv8/v8/src/disasm.h +80 -0
  148. data/lib/libv8/v8/src/disassembler.cc +343 -0
  149. data/lib/libv8/v8/src/disassembler.h +58 -0
  150. data/lib/libv8/v8/src/diy-fp.cc +58 -0
  151. data/lib/libv8/v8/src/diy-fp.h +117 -0
  152. data/lib/libv8/v8/src/double.h +238 -0
  153. data/lib/libv8/v8/src/dtoa.cc +103 -0
  154. data/lib/libv8/v8/src/dtoa.h +85 -0
  155. data/lib/libv8/v8/src/execution.cc +849 -0
  156. data/lib/libv8/v8/src/execution.h +297 -0
  157. data/lib/libv8/v8/src/extensions/experimental/break-iterator.cc +250 -0
  158. data/lib/libv8/v8/src/extensions/experimental/break-iterator.h +89 -0
  159. data/lib/libv8/v8/src/extensions/experimental/collator.cc +218 -0
  160. data/lib/libv8/v8/src/extensions/experimental/collator.h +69 -0
  161. data/lib/libv8/v8/src/extensions/experimental/experimental.gyp +94 -0
  162. data/lib/libv8/v8/src/extensions/experimental/i18n-extension.cc +78 -0
  163. data/lib/libv8/v8/src/extensions/experimental/i18n-extension.h +54 -0
  164. data/lib/libv8/v8/src/extensions/experimental/i18n-locale.cc +112 -0
  165. data/lib/libv8/v8/src/extensions/experimental/i18n-locale.h +60 -0
  166. data/lib/libv8/v8/src/extensions/experimental/i18n-utils.cc +43 -0
  167. data/lib/libv8/v8/src/extensions/experimental/i18n-utils.h +49 -0
  168. data/lib/libv8/v8/src/extensions/experimental/i18n.js +180 -0
  169. data/lib/libv8/v8/src/extensions/experimental/language-matcher.cc +251 -0
  170. data/lib/libv8/v8/src/extensions/experimental/language-matcher.h +95 -0
  171. data/lib/libv8/v8/src/extensions/externalize-string-extension.cc +141 -0
  172. data/lib/libv8/v8/src/extensions/externalize-string-extension.h +50 -0
  173. data/lib/libv8/v8/src/extensions/gc-extension.cc +58 -0
  174. data/lib/libv8/v8/src/extensions/gc-extension.h +49 -0
  175. data/lib/libv8/v8/src/factory.cc +1222 -0
  176. data/lib/libv8/v8/src/factory.h +442 -0
  177. data/lib/libv8/v8/src/fast-dtoa.cc +736 -0
  178. data/lib/libv8/v8/src/fast-dtoa.h +83 -0
  179. data/lib/libv8/v8/src/fixed-dtoa.cc +405 -0
  180. data/lib/libv8/v8/src/fixed-dtoa.h +55 -0
  181. data/lib/libv8/v8/src/flag-definitions.h +560 -0
  182. data/lib/libv8/v8/src/flags.cc +551 -0
  183. data/lib/libv8/v8/src/flags.h +79 -0
  184. data/lib/libv8/v8/src/frames-inl.h +247 -0
  185. data/lib/libv8/v8/src/frames.cc +1243 -0
  186. data/lib/libv8/v8/src/frames.h +870 -0
  187. data/lib/libv8/v8/src/full-codegen.cc +1374 -0
  188. data/lib/libv8/v8/src/full-codegen.h +771 -0
  189. data/lib/libv8/v8/src/func-name-inferrer.cc +92 -0
  190. data/lib/libv8/v8/src/func-name-inferrer.h +111 -0
  191. data/lib/libv8/v8/src/gdb-jit.cc +1555 -0
  192. data/lib/libv8/v8/src/gdb-jit.h +143 -0
  193. data/lib/libv8/v8/src/global-handles.cc +665 -0
  194. data/lib/libv8/v8/src/global-handles.h +284 -0
  195. data/lib/libv8/v8/src/globals.h +325 -0
  196. data/lib/libv8/v8/src/handles-inl.h +177 -0
  197. data/lib/libv8/v8/src/handles.cc +987 -0
  198. data/lib/libv8/v8/src/handles.h +382 -0
  199. data/lib/libv8/v8/src/hashmap.cc +230 -0
  200. data/lib/libv8/v8/src/hashmap.h +123 -0
  201. data/lib/libv8/v8/src/heap-inl.h +704 -0
  202. data/lib/libv8/v8/src/heap-profiler.cc +1173 -0
  203. data/lib/libv8/v8/src/heap-profiler.h +397 -0
  204. data/lib/libv8/v8/src/heap.cc +5930 -0
  205. data/lib/libv8/v8/src/heap.h +2268 -0
  206. data/lib/libv8/v8/src/hydrogen-instructions.cc +1769 -0
  207. data/lib/libv8/v8/src/hydrogen-instructions.h +3971 -0
  208. data/lib/libv8/v8/src/hydrogen.cc +6239 -0
  209. data/lib/libv8/v8/src/hydrogen.h +1202 -0
  210. data/lib/libv8/v8/src/ia32/assembler-ia32-inl.h +446 -0
  211. data/lib/libv8/v8/src/ia32/assembler-ia32.cc +2487 -0
  212. data/lib/libv8/v8/src/ia32/assembler-ia32.h +1144 -0
  213. data/lib/libv8/v8/src/ia32/builtins-ia32.cc +1621 -0
  214. data/lib/libv8/v8/src/ia32/code-stubs-ia32.cc +6198 -0
  215. data/lib/libv8/v8/src/ia32/code-stubs-ia32.h +517 -0
  216. data/lib/libv8/v8/src/ia32/codegen-ia32.cc +265 -0
  217. data/lib/libv8/v8/src/ia32/codegen-ia32.h +79 -0
  218. data/lib/libv8/v8/src/ia32/cpu-ia32.cc +88 -0
  219. data/lib/libv8/v8/src/ia32/debug-ia32.cc +312 -0
  220. data/lib/libv8/v8/src/ia32/deoptimizer-ia32.cc +774 -0
  221. data/lib/libv8/v8/src/ia32/disasm-ia32.cc +1628 -0
  222. data/lib/libv8/v8/src/ia32/frames-ia32.cc +45 -0
  223. data/lib/libv8/v8/src/ia32/frames-ia32.h +142 -0
  224. data/lib/libv8/v8/src/ia32/full-codegen-ia32.cc +4338 -0
  225. data/lib/libv8/v8/src/ia32/ic-ia32.cc +1597 -0
  226. data/lib/libv8/v8/src/ia32/lithium-codegen-ia32.cc +4461 -0
  227. data/lib/libv8/v8/src/ia32/lithium-codegen-ia32.h +375 -0
  228. data/lib/libv8/v8/src/ia32/lithium-gap-resolver-ia32.cc +475 -0
  229. data/lib/libv8/v8/src/ia32/lithium-gap-resolver-ia32.h +110 -0
  230. data/lib/libv8/v8/src/ia32/lithium-ia32.cc +2261 -0
  231. data/lib/libv8/v8/src/ia32/lithium-ia32.h +2396 -0
  232. data/lib/libv8/v8/src/ia32/macro-assembler-ia32.cc +2136 -0
  233. data/lib/libv8/v8/src/ia32/macro-assembler-ia32.h +775 -0
  234. data/lib/libv8/v8/src/ia32/regexp-macro-assembler-ia32.cc +1263 -0
  235. data/lib/libv8/v8/src/ia32/regexp-macro-assembler-ia32.h +216 -0
  236. data/lib/libv8/v8/src/ia32/simulator-ia32.cc +30 -0
  237. data/lib/libv8/v8/src/ia32/simulator-ia32.h +74 -0
  238. data/lib/libv8/v8/src/ia32/stub-cache-ia32.cc +3847 -0
  239. data/lib/libv8/v8/src/ic-inl.h +130 -0
  240. data/lib/libv8/v8/src/ic.cc +2577 -0
  241. data/lib/libv8/v8/src/ic.h +736 -0
  242. data/lib/libv8/v8/src/inspector.cc +63 -0
  243. data/lib/libv8/v8/src/inspector.h +62 -0
  244. data/lib/libv8/v8/src/interpreter-irregexp.cc +659 -0
  245. data/lib/libv8/v8/src/interpreter-irregexp.h +49 -0
  246. data/lib/libv8/v8/src/isolate-inl.h +50 -0
  247. data/lib/libv8/v8/src/isolate.cc +1869 -0
  248. data/lib/libv8/v8/src/isolate.h +1382 -0
  249. data/lib/libv8/v8/src/json-parser.cc +504 -0
  250. data/lib/libv8/v8/src/json-parser.h +161 -0
  251. data/lib/libv8/v8/src/json.js +342 -0
  252. data/lib/libv8/v8/src/jsregexp.cc +5385 -0
  253. data/lib/libv8/v8/src/jsregexp.h +1492 -0
  254. data/lib/libv8/v8/src/list-inl.h +212 -0
  255. data/lib/libv8/v8/src/list.h +174 -0
  256. data/lib/libv8/v8/src/lithium-allocator-inl.h +142 -0
  257. data/lib/libv8/v8/src/lithium-allocator.cc +2123 -0
  258. data/lib/libv8/v8/src/lithium-allocator.h +630 -0
  259. data/lib/libv8/v8/src/lithium.cc +190 -0
  260. data/lib/libv8/v8/src/lithium.h +597 -0
  261. data/lib/libv8/v8/src/liveedit-debugger.js +1082 -0
  262. data/lib/libv8/v8/src/liveedit.cc +1691 -0
  263. data/lib/libv8/v8/src/liveedit.h +180 -0
  264. data/lib/libv8/v8/src/liveobjectlist-inl.h +126 -0
  265. data/lib/libv8/v8/src/liveobjectlist.cc +2589 -0
  266. data/lib/libv8/v8/src/liveobjectlist.h +322 -0
  267. data/lib/libv8/v8/src/log-inl.h +59 -0
  268. data/lib/libv8/v8/src/log-utils.cc +428 -0
  269. data/lib/libv8/v8/src/log-utils.h +231 -0
  270. data/lib/libv8/v8/src/log.cc +1993 -0
  271. data/lib/libv8/v8/src/log.h +476 -0
  272. data/lib/libv8/v8/src/macro-assembler.h +120 -0
  273. data/lib/libv8/v8/src/macros.py +178 -0
  274. data/lib/libv8/v8/src/mark-compact.cc +3143 -0
  275. data/lib/libv8/v8/src/mark-compact.h +506 -0
  276. data/lib/libv8/v8/src/math.js +264 -0
  277. data/lib/libv8/v8/src/messages.cc +179 -0
  278. data/lib/libv8/v8/src/messages.h +113 -0
  279. data/lib/libv8/v8/src/messages.js +1096 -0
  280. data/lib/libv8/v8/src/mips/assembler-mips-inl.h +312 -0
  281. data/lib/libv8/v8/src/mips/assembler-mips.cc +1960 -0
  282. data/lib/libv8/v8/src/mips/assembler-mips.h +1138 -0
  283. data/lib/libv8/v8/src/mips/builtins-mips.cc +1628 -0
  284. data/lib/libv8/v8/src/mips/code-stubs-mips.cc +6656 -0
  285. data/lib/libv8/v8/src/mips/code-stubs-mips.h +682 -0
  286. data/lib/libv8/v8/src/mips/codegen-mips.cc +52 -0
  287. data/lib/libv8/v8/src/mips/codegen-mips.h +98 -0
  288. data/lib/libv8/v8/src/mips/constants-mips.cc +352 -0
  289. data/lib/libv8/v8/src/mips/constants-mips.h +739 -0
  290. data/lib/libv8/v8/src/mips/cpu-mips.cc +96 -0
  291. data/lib/libv8/v8/src/mips/debug-mips.cc +308 -0
  292. data/lib/libv8/v8/src/mips/deoptimizer-mips.cc +91 -0
  293. data/lib/libv8/v8/src/mips/disasm-mips.cc +1050 -0
  294. data/lib/libv8/v8/src/mips/frames-mips.cc +47 -0
  295. data/lib/libv8/v8/src/mips/frames-mips.h +219 -0
  296. data/lib/libv8/v8/src/mips/full-codegen-mips.cc +4388 -0
  297. data/lib/libv8/v8/src/mips/ic-mips.cc +1580 -0
  298. data/lib/libv8/v8/src/mips/lithium-codegen-mips.h +65 -0
  299. data/lib/libv8/v8/src/mips/lithium-mips.h +307 -0
  300. data/lib/libv8/v8/src/mips/macro-assembler-mips.cc +4056 -0
  301. data/lib/libv8/v8/src/mips/macro-assembler-mips.h +1214 -0
  302. data/lib/libv8/v8/src/mips/regexp-macro-assembler-mips.cc +1251 -0
  303. data/lib/libv8/v8/src/mips/regexp-macro-assembler-mips.h +252 -0
  304. data/lib/libv8/v8/src/mips/simulator-mips.cc +2621 -0
  305. data/lib/libv8/v8/src/mips/simulator-mips.h +401 -0
  306. data/lib/libv8/v8/src/mips/stub-cache-mips.cc +4285 -0
  307. data/lib/libv8/v8/src/mirror-debugger.js +2382 -0
  308. data/lib/libv8/v8/src/mksnapshot.cc +328 -0
  309. data/lib/libv8/v8/src/natives.h +64 -0
  310. data/lib/libv8/v8/src/objects-debug.cc +738 -0
  311. data/lib/libv8/v8/src/objects-inl.h +4323 -0
  312. data/lib/libv8/v8/src/objects-printer.cc +829 -0
  313. data/lib/libv8/v8/src/objects-visiting.cc +148 -0
  314. data/lib/libv8/v8/src/objects-visiting.h +424 -0
  315. data/lib/libv8/v8/src/objects.cc +10585 -0
  316. data/lib/libv8/v8/src/objects.h +6838 -0
  317. data/lib/libv8/v8/src/parser.cc +4997 -0
  318. data/lib/libv8/v8/src/parser.h +765 -0
  319. data/lib/libv8/v8/src/platform-cygwin.cc +779 -0
  320. data/lib/libv8/v8/src/platform-freebsd.cc +826 -0
  321. data/lib/libv8/v8/src/platform-linux.cc +1149 -0
  322. data/lib/libv8/v8/src/platform-macos.cc +830 -0
  323. data/lib/libv8/v8/src/platform-nullos.cc +479 -0
  324. data/lib/libv8/v8/src/platform-openbsd.cc +640 -0
  325. data/lib/libv8/v8/src/platform-posix.cc +424 -0
  326. data/lib/libv8/v8/src/platform-solaris.cc +762 -0
  327. data/lib/libv8/v8/src/platform-tls-mac.h +62 -0
  328. data/lib/libv8/v8/src/platform-tls-win32.h +62 -0
  329. data/lib/libv8/v8/src/platform-tls.h +50 -0
  330. data/lib/libv8/v8/src/platform-win32.cc +2021 -0
  331. data/lib/libv8/v8/src/platform.h +667 -0
  332. data/lib/libv8/v8/src/preparse-data-format.h +62 -0
  333. data/lib/libv8/v8/src/preparse-data.cc +183 -0
  334. data/lib/libv8/v8/src/preparse-data.h +225 -0
  335. data/lib/libv8/v8/src/preparser-api.cc +220 -0
  336. data/lib/libv8/v8/src/preparser.cc +1450 -0
  337. data/lib/libv8/v8/src/preparser.h +493 -0
  338. data/lib/libv8/v8/src/prettyprinter.cc +1493 -0
  339. data/lib/libv8/v8/src/prettyprinter.h +223 -0
  340. data/lib/libv8/v8/src/profile-generator-inl.h +128 -0
  341. data/lib/libv8/v8/src/profile-generator.cc +3098 -0
  342. data/lib/libv8/v8/src/profile-generator.h +1126 -0
  343. data/lib/libv8/v8/src/property.cc +105 -0
  344. data/lib/libv8/v8/src/property.h +365 -0
  345. data/lib/libv8/v8/src/proxy.js +83 -0
  346. data/lib/libv8/v8/src/regexp-macro-assembler-irregexp-inl.h +78 -0
  347. data/lib/libv8/v8/src/regexp-macro-assembler-irregexp.cc +471 -0
  348. data/lib/libv8/v8/src/regexp-macro-assembler-irregexp.h +142 -0
  349. data/lib/libv8/v8/src/regexp-macro-assembler-tracer.cc +373 -0
  350. data/lib/libv8/v8/src/regexp-macro-assembler-tracer.h +104 -0
  351. data/lib/libv8/v8/src/regexp-macro-assembler.cc +267 -0
  352. data/lib/libv8/v8/src/regexp-macro-assembler.h +243 -0
  353. data/lib/libv8/v8/src/regexp-stack.cc +111 -0
  354. data/lib/libv8/v8/src/regexp-stack.h +147 -0
  355. data/lib/libv8/v8/src/regexp.js +483 -0
  356. data/lib/libv8/v8/src/rewriter.cc +360 -0
  357. data/lib/libv8/v8/src/rewriter.h +50 -0
  358. data/lib/libv8/v8/src/runtime-profiler.cc +489 -0
  359. data/lib/libv8/v8/src/runtime-profiler.h +201 -0
  360. data/lib/libv8/v8/src/runtime.cc +12227 -0
  361. data/lib/libv8/v8/src/runtime.h +652 -0
  362. data/lib/libv8/v8/src/runtime.js +649 -0
  363. data/lib/libv8/v8/src/safepoint-table.cc +256 -0
  364. data/lib/libv8/v8/src/safepoint-table.h +270 -0
  365. data/lib/libv8/v8/src/scanner-base.cc +952 -0
  366. data/lib/libv8/v8/src/scanner-base.h +670 -0
  367. data/lib/libv8/v8/src/scanner.cc +345 -0
  368. data/lib/libv8/v8/src/scanner.h +146 -0
  369. data/lib/libv8/v8/src/scopeinfo.cc +646 -0
  370. data/lib/libv8/v8/src/scopeinfo.h +254 -0
  371. data/lib/libv8/v8/src/scopes.cc +1150 -0
  372. data/lib/libv8/v8/src/scopes.h +507 -0
  373. data/lib/libv8/v8/src/serialize.cc +1574 -0
  374. data/lib/libv8/v8/src/serialize.h +589 -0
  375. data/lib/libv8/v8/src/shell.h +55 -0
  376. data/lib/libv8/v8/src/simulator.h +43 -0
  377. data/lib/libv8/v8/src/small-pointer-list.h +163 -0
  378. data/lib/libv8/v8/src/smart-pointer.h +109 -0
  379. data/lib/libv8/v8/src/snapshot-common.cc +83 -0
  380. data/lib/libv8/v8/src/snapshot-empty.cc +54 -0
  381. data/lib/libv8/v8/src/snapshot.h +91 -0
  382. data/lib/libv8/v8/src/spaces-inl.h +529 -0
  383. data/lib/libv8/v8/src/spaces.cc +3145 -0
  384. data/lib/libv8/v8/src/spaces.h +2369 -0
  385. data/lib/libv8/v8/src/splay-tree-inl.h +310 -0
  386. data/lib/libv8/v8/src/splay-tree.h +205 -0
  387. data/lib/libv8/v8/src/string-search.cc +41 -0
  388. data/lib/libv8/v8/src/string-search.h +568 -0
  389. data/lib/libv8/v8/src/string-stream.cc +592 -0
  390. data/lib/libv8/v8/src/string-stream.h +191 -0
  391. data/lib/libv8/v8/src/string.js +994 -0
  392. data/lib/libv8/v8/src/strtod.cc +440 -0
  393. data/lib/libv8/v8/src/strtod.h +40 -0
  394. data/lib/libv8/v8/src/stub-cache.cc +1965 -0
  395. data/lib/libv8/v8/src/stub-cache.h +924 -0
  396. data/lib/libv8/v8/src/third_party/valgrind/valgrind.h +3925 -0
  397. data/lib/libv8/v8/src/token.cc +63 -0
  398. data/lib/libv8/v8/src/token.h +288 -0
  399. data/lib/libv8/v8/src/type-info.cc +507 -0
  400. data/lib/libv8/v8/src/type-info.h +272 -0
  401. data/lib/libv8/v8/src/unbound-queue-inl.h +95 -0
  402. data/lib/libv8/v8/src/unbound-queue.h +69 -0
  403. data/lib/libv8/v8/src/unicode-inl.h +238 -0
  404. data/lib/libv8/v8/src/unicode.cc +1624 -0
  405. data/lib/libv8/v8/src/unicode.h +280 -0
  406. data/lib/libv8/v8/src/uri.js +408 -0
  407. data/lib/libv8/v8/src/utils-inl.h +48 -0
  408. data/lib/libv8/v8/src/utils.cc +371 -0
  409. data/lib/libv8/v8/src/utils.h +800 -0
  410. data/lib/libv8/v8/src/v8-counters.cc +62 -0
  411. data/lib/libv8/v8/src/v8-counters.h +314 -0
  412. data/lib/libv8/v8/src/v8.cc +213 -0
  413. data/lib/libv8/v8/src/v8.h +131 -0
  414. data/lib/libv8/v8/src/v8checks.h +64 -0
  415. data/lib/libv8/v8/src/v8dll-main.cc +44 -0
  416. data/lib/libv8/v8/src/v8globals.h +512 -0
  417. data/lib/libv8/v8/src/v8memory.h +82 -0
  418. data/lib/libv8/v8/src/v8natives.js +1310 -0
  419. data/lib/libv8/v8/src/v8preparserdll-main.cc +39 -0
  420. data/lib/libv8/v8/src/v8threads.cc +464 -0
  421. data/lib/libv8/v8/src/v8threads.h +165 -0
  422. data/lib/libv8/v8/src/v8utils.h +319 -0
  423. data/lib/libv8/v8/src/variables.cc +114 -0
  424. data/lib/libv8/v8/src/variables.h +167 -0
  425. data/lib/libv8/v8/src/version.cc +116 -0
  426. data/lib/libv8/v8/src/version.h +68 -0
  427. data/lib/libv8/v8/src/vm-state-inl.h +138 -0
  428. data/lib/libv8/v8/src/vm-state.h +71 -0
  429. data/lib/libv8/v8/src/win32-headers.h +96 -0
  430. data/lib/libv8/v8/src/x64/assembler-x64-inl.h +462 -0
  431. data/lib/libv8/v8/src/x64/assembler-x64.cc +3027 -0
  432. data/lib/libv8/v8/src/x64/assembler-x64.h +1633 -0
  433. data/lib/libv8/v8/src/x64/builtins-x64.cc +1520 -0
  434. data/lib/libv8/v8/src/x64/code-stubs-x64.cc +5132 -0
  435. data/lib/libv8/v8/src/x64/code-stubs-x64.h +514 -0
  436. data/lib/libv8/v8/src/x64/codegen-x64.cc +146 -0
  437. data/lib/libv8/v8/src/x64/codegen-x64.h +76 -0
  438. data/lib/libv8/v8/src/x64/cpu-x64.cc +88 -0
  439. data/lib/libv8/v8/src/x64/debug-x64.cc +319 -0
  440. data/lib/libv8/v8/src/x64/deoptimizer-x64.cc +815 -0
  441. data/lib/libv8/v8/src/x64/disasm-x64.cc +1832 -0
  442. data/lib/libv8/v8/src/x64/frames-x64.cc +45 -0
  443. data/lib/libv8/v8/src/x64/frames-x64.h +130 -0
  444. data/lib/libv8/v8/src/x64/full-codegen-x64.cc +4318 -0
  445. data/lib/libv8/v8/src/x64/ic-x64.cc +1608 -0
  446. data/lib/libv8/v8/src/x64/lithium-codegen-x64.cc +4267 -0
  447. data/lib/libv8/v8/src/x64/lithium-codegen-x64.h +367 -0
  448. data/lib/libv8/v8/src/x64/lithium-gap-resolver-x64.cc +320 -0
  449. data/lib/libv8/v8/src/x64/lithium-gap-resolver-x64.h +74 -0
  450. data/lib/libv8/v8/src/x64/lithium-x64.cc +2202 -0
  451. data/lib/libv8/v8/src/x64/lithium-x64.h +2333 -0
  452. data/lib/libv8/v8/src/x64/macro-assembler-x64.cc +3745 -0
  453. data/lib/libv8/v8/src/x64/macro-assembler-x64.h +1290 -0
  454. data/lib/libv8/v8/src/x64/regexp-macro-assembler-x64.cc +1398 -0
  455. data/lib/libv8/v8/src/x64/regexp-macro-assembler-x64.h +282 -0
  456. data/lib/libv8/v8/src/x64/simulator-x64.cc +27 -0
  457. data/lib/libv8/v8/src/x64/simulator-x64.h +72 -0
  458. data/lib/libv8/v8/src/x64/stub-cache-x64.cc +3610 -0
  459. data/lib/libv8/v8/src/zone-inl.h +140 -0
  460. data/lib/libv8/v8/src/zone.cc +196 -0
  461. data/lib/libv8/v8/src/zone.h +240 -0
  462. data/lib/libv8/v8/tools/codemap.js +265 -0
  463. data/lib/libv8/v8/tools/consarray.js +93 -0
  464. data/lib/libv8/v8/tools/csvparser.js +78 -0
  465. data/lib/libv8/v8/tools/disasm.py +92 -0
  466. data/lib/libv8/v8/tools/freebsd-tick-processor +10 -0
  467. data/lib/libv8/v8/tools/gc-nvp-trace-processor.py +342 -0
  468. data/lib/libv8/v8/tools/gcmole/README +62 -0
  469. data/lib/libv8/v8/tools/gcmole/gccause.lua +60 -0
  470. data/lib/libv8/v8/tools/gcmole/gcmole.cc +1261 -0
  471. data/lib/libv8/v8/tools/gcmole/gcmole.lua +378 -0
  472. data/lib/libv8/v8/tools/generate-ten-powers.scm +286 -0
  473. data/lib/libv8/v8/tools/grokdump.py +841 -0
  474. data/lib/libv8/v8/tools/gyp/v8.gyp +995 -0
  475. data/lib/libv8/v8/tools/js2c.py +364 -0
  476. data/lib/libv8/v8/tools/jsmin.py +280 -0
  477. data/lib/libv8/v8/tools/linux-tick-processor +35 -0
  478. data/lib/libv8/v8/tools/ll_prof.py +942 -0
  479. data/lib/libv8/v8/tools/logreader.js +185 -0
  480. data/lib/libv8/v8/tools/mac-nm +18 -0
  481. data/lib/libv8/v8/tools/mac-tick-processor +6 -0
  482. data/lib/libv8/v8/tools/oom_dump/README +31 -0
  483. data/lib/libv8/v8/tools/oom_dump/SConstruct +42 -0
  484. data/lib/libv8/v8/tools/oom_dump/oom_dump.cc +288 -0
  485. data/lib/libv8/v8/tools/presubmit.py +305 -0
  486. data/lib/libv8/v8/tools/process-heap-prof.py +120 -0
  487. data/lib/libv8/v8/tools/profile.js +751 -0
  488. data/lib/libv8/v8/tools/profile_view.js +219 -0
  489. data/lib/libv8/v8/tools/run-valgrind.py +77 -0
  490. data/lib/libv8/v8/tools/splaytree.js +316 -0
  491. data/lib/libv8/v8/tools/stats-viewer.py +468 -0
  492. data/lib/libv8/v8/tools/test.py +1510 -0
  493. data/lib/libv8/v8/tools/tickprocessor-driver.js +59 -0
  494. data/lib/libv8/v8/tools/tickprocessor.js +877 -0
  495. data/lib/libv8/v8/tools/utils.py +96 -0
  496. data/lib/libv8/v8/tools/visual_studio/README.txt +12 -0
  497. data/lib/libv8/v8/tools/windows-tick-processor.bat +30 -0
  498. data/lib/libv8/version.rb +5 -0
  499. data/libv8.gemspec +36 -0
  500. metadata +578 -0
@@ -0,0 +1,1628 @@
1
+ // Copyright 2011 the V8 project authors. All rights reserved.
2
+ // Redistribution and use in source and binary forms, with or without
3
+ // modification, are permitted provided that the following conditions are
4
+ // met:
5
+ //
6
+ // * Redistributions of source code must retain the above copyright
7
+ // notice, this list of conditions and the following disclaimer.
8
+ // * Redistributions in binary form must reproduce the above
9
+ // copyright notice, this list of conditions and the following
10
+ // disclaimer in the documentation and/or other materials provided
11
+ // with the distribution.
12
+ // * Neither the name of Google Inc. nor the names of its
13
+ // contributors may be used to endorse or promote products derived
14
+ // from this software without specific prior written permission.
15
+ //
16
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
+
28
+ #include <assert.h>
29
+ #include <stdio.h>
30
+ #include <stdarg.h>
31
+
32
+ #include "v8.h"
33
+
34
+ #if defined(V8_TARGET_ARCH_IA32)
35
+
36
+ #include "disasm.h"
37
+
38
+ namespace disasm {
39
+
40
+ enum OperandOrder {
41
+ UNSET_OP_ORDER = 0,
42
+ REG_OPER_OP_ORDER,
43
+ OPER_REG_OP_ORDER
44
+ };
45
+
46
+
47
+ //------------------------------------------------------------------
48
+ // Tables
49
+ //------------------------------------------------------------------
50
+ struct ByteMnemonic {
51
+ int b; // -1 terminates, otherwise must be in range (0..255)
52
+ const char* mnem;
53
+ OperandOrder op_order_;
54
+ };
55
+
56
+
57
+ static ByteMnemonic two_operands_instr[] = {
58
+ {0x03, "add", REG_OPER_OP_ORDER},
59
+ {0x09, "or", OPER_REG_OP_ORDER},
60
+ {0x0B, "or", REG_OPER_OP_ORDER},
61
+ {0x1B, "sbb", REG_OPER_OP_ORDER},
62
+ {0x21, "and", OPER_REG_OP_ORDER},
63
+ {0x23, "and", REG_OPER_OP_ORDER},
64
+ {0x29, "sub", OPER_REG_OP_ORDER},
65
+ {0x2A, "subb", REG_OPER_OP_ORDER},
66
+ {0x2B, "sub", REG_OPER_OP_ORDER},
67
+ {0x31, "xor", OPER_REG_OP_ORDER},
68
+ {0x33, "xor", REG_OPER_OP_ORDER},
69
+ {0x38, "cmpb", OPER_REG_OP_ORDER},
70
+ {0x3A, "cmpb", REG_OPER_OP_ORDER},
71
+ {0x3B, "cmp", REG_OPER_OP_ORDER},
72
+ {0x84, "test_b", REG_OPER_OP_ORDER},
73
+ {0x85, "test", REG_OPER_OP_ORDER},
74
+ {0x87, "xchg", REG_OPER_OP_ORDER},
75
+ {0x8A, "mov_b", REG_OPER_OP_ORDER},
76
+ {0x8B, "mov", REG_OPER_OP_ORDER},
77
+ {0x8D, "lea", REG_OPER_OP_ORDER},
78
+ {-1, "", UNSET_OP_ORDER}
79
+ };
80
+
81
+
82
+ static ByteMnemonic zero_operands_instr[] = {
83
+ {0xC3, "ret", UNSET_OP_ORDER},
84
+ {0xC9, "leave", UNSET_OP_ORDER},
85
+ {0x90, "nop", UNSET_OP_ORDER},
86
+ {0xF4, "hlt", UNSET_OP_ORDER},
87
+ {0xCC, "int3", UNSET_OP_ORDER},
88
+ {0x60, "pushad", UNSET_OP_ORDER},
89
+ {0x61, "popad", UNSET_OP_ORDER},
90
+ {0x9C, "pushfd", UNSET_OP_ORDER},
91
+ {0x9D, "popfd", UNSET_OP_ORDER},
92
+ {0x9E, "sahf", UNSET_OP_ORDER},
93
+ {0x99, "cdq", UNSET_OP_ORDER},
94
+ {0x9B, "fwait", UNSET_OP_ORDER},
95
+ {0xFC, "cld", UNSET_OP_ORDER},
96
+ {0xAB, "stos", UNSET_OP_ORDER},
97
+ {-1, "", UNSET_OP_ORDER}
98
+ };
99
+
100
+
101
+ static ByteMnemonic call_jump_instr[] = {
102
+ {0xE8, "call", UNSET_OP_ORDER},
103
+ {0xE9, "jmp", UNSET_OP_ORDER},
104
+ {-1, "", UNSET_OP_ORDER}
105
+ };
106
+
107
+
108
+ static ByteMnemonic short_immediate_instr[] = {
109
+ {0x05, "add", UNSET_OP_ORDER},
110
+ {0x0D, "or", UNSET_OP_ORDER},
111
+ {0x15, "adc", UNSET_OP_ORDER},
112
+ {0x25, "and", UNSET_OP_ORDER},
113
+ {0x2D, "sub", UNSET_OP_ORDER},
114
+ {0x35, "xor", UNSET_OP_ORDER},
115
+ {0x3D, "cmp", UNSET_OP_ORDER},
116
+ {-1, "", UNSET_OP_ORDER}
117
+ };
118
+
119
+
120
+ static const char* jump_conditional_mnem[] = {
121
+ /*0*/ "jo", "jno", "jc", "jnc",
122
+ /*4*/ "jz", "jnz", "jna", "ja",
123
+ /*8*/ "js", "jns", "jpe", "jpo",
124
+ /*12*/ "jl", "jnl", "jng", "jg"
125
+ };
126
+
127
+
128
+ static const char* set_conditional_mnem[] = {
129
+ /*0*/ "seto", "setno", "setc", "setnc",
130
+ /*4*/ "setz", "setnz", "setna", "seta",
131
+ /*8*/ "sets", "setns", "setpe", "setpo",
132
+ /*12*/ "setl", "setnl", "setng", "setg"
133
+ };
134
+
135
+
136
+ static const char* conditional_move_mnem[] = {
137
+ /*0*/ "cmovo", "cmovno", "cmovc", "cmovnc",
138
+ /*4*/ "cmovz", "cmovnz", "cmovna", "cmova",
139
+ /*8*/ "cmovs", "cmovns", "cmovpe", "cmovpo",
140
+ /*12*/ "cmovl", "cmovnl", "cmovng", "cmovg"
141
+ };
142
+
143
+
144
+ enum InstructionType {
145
+ NO_INSTR,
146
+ ZERO_OPERANDS_INSTR,
147
+ TWO_OPERANDS_INSTR,
148
+ JUMP_CONDITIONAL_SHORT_INSTR,
149
+ REGISTER_INSTR,
150
+ MOVE_REG_INSTR,
151
+ CALL_JUMP_INSTR,
152
+ SHORT_IMMEDIATE_INSTR
153
+ };
154
+
155
+
156
+ struct InstructionDesc {
157
+ const char* mnem;
158
+ InstructionType type;
159
+ OperandOrder op_order_;
160
+ };
161
+
162
+
163
+ class InstructionTable {
164
+ public:
165
+ InstructionTable();
166
+ const InstructionDesc& Get(byte x) const { return instructions_[x]; }
167
+
168
+ private:
169
+ InstructionDesc instructions_[256];
170
+ void Clear();
171
+ void Init();
172
+ void CopyTable(ByteMnemonic bm[], InstructionType type);
173
+ void SetTableRange(InstructionType type,
174
+ byte start,
175
+ byte end,
176
+ const char* mnem);
177
+ void AddJumpConditionalShort();
178
+ };
179
+
180
+
181
+ InstructionTable::InstructionTable() {
182
+ Clear();
183
+ Init();
184
+ }
185
+
186
+
187
+ void InstructionTable::Clear() {
188
+ for (int i = 0; i < 256; i++) {
189
+ instructions_[i].mnem = "";
190
+ instructions_[i].type = NO_INSTR;
191
+ instructions_[i].op_order_ = UNSET_OP_ORDER;
192
+ }
193
+ }
194
+
195
+
196
+ void InstructionTable::Init() {
197
+ CopyTable(two_operands_instr, TWO_OPERANDS_INSTR);
198
+ CopyTable(zero_operands_instr, ZERO_OPERANDS_INSTR);
199
+ CopyTable(call_jump_instr, CALL_JUMP_INSTR);
200
+ CopyTable(short_immediate_instr, SHORT_IMMEDIATE_INSTR);
201
+ AddJumpConditionalShort();
202
+ SetTableRange(REGISTER_INSTR, 0x40, 0x47, "inc");
203
+ SetTableRange(REGISTER_INSTR, 0x48, 0x4F, "dec");
204
+ SetTableRange(REGISTER_INSTR, 0x50, 0x57, "push");
205
+ SetTableRange(REGISTER_INSTR, 0x58, 0x5F, "pop");
206
+ SetTableRange(REGISTER_INSTR, 0x91, 0x97, "xchg eax,"); // 0x90 is nop.
207
+ SetTableRange(MOVE_REG_INSTR, 0xB8, 0xBF, "mov");
208
+ }
209
+
210
+
211
+ void InstructionTable::CopyTable(ByteMnemonic bm[], InstructionType type) {
212
+ for (int i = 0; bm[i].b >= 0; i++) {
213
+ InstructionDesc* id = &instructions_[bm[i].b];
214
+ id->mnem = bm[i].mnem;
215
+ id->op_order_ = bm[i].op_order_;
216
+ ASSERT_EQ(NO_INSTR, id->type); // Information not already entered.
217
+ id->type = type;
218
+ }
219
+ }
220
+
221
+
222
+ void InstructionTable::SetTableRange(InstructionType type,
223
+ byte start,
224
+ byte end,
225
+ const char* mnem) {
226
+ for (byte b = start; b <= end; b++) {
227
+ InstructionDesc* id = &instructions_[b];
228
+ ASSERT_EQ(NO_INSTR, id->type); // Information not already entered.
229
+ id->mnem = mnem;
230
+ id->type = type;
231
+ }
232
+ }
233
+
234
+
235
+ void InstructionTable::AddJumpConditionalShort() {
236
+ for (byte b = 0x70; b <= 0x7F; b++) {
237
+ InstructionDesc* id = &instructions_[b];
238
+ ASSERT_EQ(NO_INSTR, id->type); // Information not already entered.
239
+ id->mnem = jump_conditional_mnem[b & 0x0F];
240
+ id->type = JUMP_CONDITIONAL_SHORT_INSTR;
241
+ }
242
+ }
243
+
244
+
245
+ static InstructionTable instruction_table;
246
+
247
+
248
+ // The IA32 disassembler implementation.
249
+ class DisassemblerIA32 {
250
+ public:
251
+ DisassemblerIA32(const NameConverter& converter,
252
+ bool abort_on_unimplemented = true)
253
+ : converter_(converter),
254
+ tmp_buffer_pos_(0),
255
+ abort_on_unimplemented_(abort_on_unimplemented) {
256
+ tmp_buffer_[0] = '\0';
257
+ }
258
+
259
+ virtual ~DisassemblerIA32() {}
260
+
261
+ // Writes one disassembled instruction into 'buffer' (0-terminated).
262
+ // Returns the length of the disassembled machine instruction in bytes.
263
+ int InstructionDecode(v8::internal::Vector<char> buffer, byte* instruction);
264
+
265
+ private:
266
+ const NameConverter& converter_;
267
+ v8::internal::EmbeddedVector<char, 128> tmp_buffer_;
268
+ unsigned int tmp_buffer_pos_;
269
+ bool abort_on_unimplemented_;
270
+
271
+
272
+ enum {
273
+ eax = 0,
274
+ ecx = 1,
275
+ edx = 2,
276
+ ebx = 3,
277
+ esp = 4,
278
+ ebp = 5,
279
+ esi = 6,
280
+ edi = 7
281
+ };
282
+
283
+
284
+ enum ShiftOpcodeExtension {
285
+ kROL = 0,
286
+ kROR = 1,
287
+ kRCL = 2,
288
+ kRCR = 3,
289
+ kSHL = 4,
290
+ KSHR = 5,
291
+ kSAR = 7
292
+ };
293
+
294
+
295
+ const char* NameOfCPURegister(int reg) const {
296
+ return converter_.NameOfCPURegister(reg);
297
+ }
298
+
299
+
300
+ const char* NameOfByteCPURegister(int reg) const {
301
+ return converter_.NameOfByteCPURegister(reg);
302
+ }
303
+
304
+
305
+ const char* NameOfXMMRegister(int reg) const {
306
+ return converter_.NameOfXMMRegister(reg);
307
+ }
308
+
309
+
310
+ const char* NameOfAddress(byte* addr) const {
311
+ return converter_.NameOfAddress(addr);
312
+ }
313
+
314
+
315
+ // Disassembler helper functions.
316
+ static void get_modrm(byte data, int* mod, int* regop, int* rm) {
317
+ *mod = (data >> 6) & 3;
318
+ *regop = (data & 0x38) >> 3;
319
+ *rm = data & 7;
320
+ }
321
+
322
+
323
+ static void get_sib(byte data, int* scale, int* index, int* base) {
324
+ *scale = (data >> 6) & 3;
325
+ *index = (data >> 3) & 7;
326
+ *base = data & 7;
327
+ }
328
+
329
+ typedef const char* (DisassemblerIA32::*RegisterNameMapping)(int reg) const;
330
+
331
+ int PrintRightOperandHelper(byte* modrmp, RegisterNameMapping register_name);
332
+ int PrintRightOperand(byte* modrmp);
333
+ int PrintRightByteOperand(byte* modrmp);
334
+ int PrintRightXMMOperand(byte* modrmp);
335
+ int PrintOperands(const char* mnem, OperandOrder op_order, byte* data);
336
+ int PrintImmediateOp(byte* data);
337
+ int F7Instruction(byte* data);
338
+ int D1D3C1Instruction(byte* data);
339
+ int JumpShort(byte* data);
340
+ int JumpConditional(byte* data, const char* comment);
341
+ int JumpConditionalShort(byte* data, const char* comment);
342
+ int SetCC(byte* data);
343
+ int CMov(byte* data);
344
+ int FPUInstruction(byte* data);
345
+ int MemoryFPUInstruction(int escape_opcode, int regop, byte* modrm_start);
346
+ int RegisterFPUInstruction(int escape_opcode, byte modrm_byte);
347
+ void AppendToBuffer(const char* format, ...);
348
+
349
+
350
+ void UnimplementedInstruction() {
351
+ if (abort_on_unimplemented_) {
352
+ UNIMPLEMENTED();
353
+ } else {
354
+ AppendToBuffer("'Unimplemented Instruction'");
355
+ }
356
+ }
357
+ };
358
+
359
+
360
+ void DisassemblerIA32::AppendToBuffer(const char* format, ...) {
361
+ v8::internal::Vector<char> buf = tmp_buffer_ + tmp_buffer_pos_;
362
+ va_list args;
363
+ va_start(args, format);
364
+ int result = v8::internal::OS::VSNPrintF(buf, format, args);
365
+ va_end(args);
366
+ tmp_buffer_pos_ += result;
367
+ }
368
+
369
+ int DisassemblerIA32::PrintRightOperandHelper(
370
+ byte* modrmp,
371
+ RegisterNameMapping direct_register_name) {
372
+ int mod, regop, rm;
373
+ get_modrm(*modrmp, &mod, &regop, &rm);
374
+ RegisterNameMapping register_name = (mod == 3) ? direct_register_name :
375
+ &DisassemblerIA32::NameOfCPURegister;
376
+ switch (mod) {
377
+ case 0:
378
+ if (rm == ebp) {
379
+ int32_t disp = *reinterpret_cast<int32_t*>(modrmp+1);
380
+ AppendToBuffer("[0x%x]", disp);
381
+ return 5;
382
+ } else if (rm == esp) {
383
+ byte sib = *(modrmp + 1);
384
+ int scale, index, base;
385
+ get_sib(sib, &scale, &index, &base);
386
+ if (index == esp && base == esp && scale == 0 /*times_1*/) {
387
+ AppendToBuffer("[%s]", (this->*register_name)(rm));
388
+ return 2;
389
+ } else if (base == ebp) {
390
+ int32_t disp = *reinterpret_cast<int32_t*>(modrmp + 2);
391
+ AppendToBuffer("[%s*%d+0x%x]",
392
+ (this->*register_name)(index),
393
+ 1 << scale,
394
+ disp);
395
+ return 6;
396
+ } else if (index != esp && base != ebp) {
397
+ // [base+index*scale]
398
+ AppendToBuffer("[%s+%s*%d]",
399
+ (this->*register_name)(base),
400
+ (this->*register_name)(index),
401
+ 1 << scale);
402
+ return 2;
403
+ } else {
404
+ UnimplementedInstruction();
405
+ return 1;
406
+ }
407
+ } else {
408
+ AppendToBuffer("[%s]", (this->*register_name)(rm));
409
+ return 1;
410
+ }
411
+ break;
412
+ case 1: // fall through
413
+ case 2:
414
+ if (rm == esp) {
415
+ byte sib = *(modrmp + 1);
416
+ int scale, index, base;
417
+ get_sib(sib, &scale, &index, &base);
418
+ int disp =
419
+ mod == 2 ? *reinterpret_cast<int32_t*>(modrmp + 2) : *(modrmp + 2);
420
+ if (index == base && index == rm /*esp*/ && scale == 0 /*times_1*/) {
421
+ AppendToBuffer("[%s+0x%x]", (this->*register_name)(rm), disp);
422
+ } else {
423
+ AppendToBuffer("[%s+%s*%d+0x%x]",
424
+ (this->*register_name)(base),
425
+ (this->*register_name)(index),
426
+ 1 << scale,
427
+ disp);
428
+ }
429
+ return mod == 2 ? 6 : 3;
430
+ } else {
431
+ // No sib.
432
+ int disp =
433
+ mod == 2 ? *reinterpret_cast<int32_t*>(modrmp + 1) : *(modrmp + 1);
434
+ AppendToBuffer("[%s+0x%x]", (this->*register_name)(rm), disp);
435
+ return mod == 2 ? 5 : 2;
436
+ }
437
+ break;
438
+ case 3:
439
+ AppendToBuffer("%s", (this->*register_name)(rm));
440
+ return 1;
441
+ default:
442
+ UnimplementedInstruction();
443
+ return 1;
444
+ }
445
+ UNREACHABLE();
446
+ }
447
+
448
+
449
+ int DisassemblerIA32::PrintRightOperand(byte* modrmp) {
450
+ return PrintRightOperandHelper(modrmp, &DisassemblerIA32::NameOfCPURegister);
451
+ }
452
+
453
+
454
+ int DisassemblerIA32::PrintRightByteOperand(byte* modrmp) {
455
+ return PrintRightOperandHelper(modrmp,
456
+ &DisassemblerIA32::NameOfByteCPURegister);
457
+ }
458
+
459
+
460
+ int DisassemblerIA32::PrintRightXMMOperand(byte* modrmp) {
461
+ return PrintRightOperandHelper(modrmp,
462
+ &DisassemblerIA32::NameOfXMMRegister);
463
+ }
464
+
465
+
466
+ // Returns number of bytes used including the current *data.
467
+ // Writes instruction's mnemonic, left and right operands to 'tmp_buffer_'.
468
+ int DisassemblerIA32::PrintOperands(const char* mnem,
469
+ OperandOrder op_order,
470
+ byte* data) {
471
+ byte modrm = *data;
472
+ int mod, regop, rm;
473
+ get_modrm(modrm, &mod, &regop, &rm);
474
+ int advance = 0;
475
+ switch (op_order) {
476
+ case REG_OPER_OP_ORDER: {
477
+ AppendToBuffer("%s %s,", mnem, NameOfCPURegister(regop));
478
+ advance = PrintRightOperand(data);
479
+ break;
480
+ }
481
+ case OPER_REG_OP_ORDER: {
482
+ AppendToBuffer("%s ", mnem);
483
+ advance = PrintRightOperand(data);
484
+ AppendToBuffer(",%s", NameOfCPURegister(regop));
485
+ break;
486
+ }
487
+ default:
488
+ UNREACHABLE();
489
+ break;
490
+ }
491
+ return advance;
492
+ }
493
+
494
+
495
+ // Returns number of bytes used by machine instruction, including *data byte.
496
+ // Writes immediate instructions to 'tmp_buffer_'.
497
+ int DisassemblerIA32::PrintImmediateOp(byte* data) {
498
+ bool sign_extension_bit = (*data & 0x02) != 0;
499
+ byte modrm = *(data+1);
500
+ int mod, regop, rm;
501
+ get_modrm(modrm, &mod, &regop, &rm);
502
+ const char* mnem = "Imm???";
503
+ switch (regop) {
504
+ case 0: mnem = "add"; break;
505
+ case 1: mnem = "or"; break;
506
+ case 2: mnem = "adc"; break;
507
+ case 4: mnem = "and"; break;
508
+ case 5: mnem = "sub"; break;
509
+ case 6: mnem = "xor"; break;
510
+ case 7: mnem = "cmp"; break;
511
+ default: UnimplementedInstruction();
512
+ }
513
+ AppendToBuffer("%s ", mnem);
514
+ int count = PrintRightOperand(data+1);
515
+ if (sign_extension_bit) {
516
+ AppendToBuffer(",0x%x", *(data + 1 + count));
517
+ return 1 + count + 1 /*int8*/;
518
+ } else {
519
+ AppendToBuffer(",0x%x", *reinterpret_cast<int32_t*>(data + 1 + count));
520
+ return 1 + count + 4 /*int32_t*/;
521
+ }
522
+ }
523
+
524
+
525
+ // Returns number of bytes used, including *data.
526
+ int DisassemblerIA32::F7Instruction(byte* data) {
527
+ ASSERT_EQ(0xF7, *data);
528
+ byte modrm = *(data+1);
529
+ int mod, regop, rm;
530
+ get_modrm(modrm, &mod, &regop, &rm);
531
+ if (mod == 3 && regop != 0) {
532
+ const char* mnem = NULL;
533
+ switch (regop) {
534
+ case 2: mnem = "not"; break;
535
+ case 3: mnem = "neg"; break;
536
+ case 4: mnem = "mul"; break;
537
+ case 7: mnem = "idiv"; break;
538
+ default: UnimplementedInstruction();
539
+ }
540
+ AppendToBuffer("%s %s", mnem, NameOfCPURegister(rm));
541
+ return 2;
542
+ } else if (mod == 3 && regop == eax) {
543
+ int32_t imm = *reinterpret_cast<int32_t*>(data+2);
544
+ AppendToBuffer("test %s,0x%x", NameOfCPURegister(rm), imm);
545
+ return 6;
546
+ } else if (regop == eax) {
547
+ AppendToBuffer("test ");
548
+ int count = PrintRightOperand(data+1);
549
+ int32_t imm = *reinterpret_cast<int32_t*>(data+1+count);
550
+ AppendToBuffer(",0x%x", imm);
551
+ return 1+count+4 /*int32_t*/;
552
+ } else {
553
+ UnimplementedInstruction();
554
+ return 2;
555
+ }
556
+ }
557
+
558
+ int DisassemblerIA32::D1D3C1Instruction(byte* data) {
559
+ byte op = *data;
560
+ ASSERT(op == 0xD1 || op == 0xD3 || op == 0xC1);
561
+ byte modrm = *(data+1);
562
+ int mod, regop, rm;
563
+ get_modrm(modrm, &mod, &regop, &rm);
564
+ int imm8 = -1;
565
+ int num_bytes = 2;
566
+ if (mod == 3) {
567
+ const char* mnem = NULL;
568
+ switch (regop) {
569
+ case kROL: mnem = "rol"; break;
570
+ case kROR: mnem = "ror"; break;
571
+ case kRCL: mnem = "rcl"; break;
572
+ case kRCR: mnem = "rcr"; break;
573
+ case kSHL: mnem = "shl"; break;
574
+ case KSHR: mnem = "shr"; break;
575
+ case kSAR: mnem = "sar"; break;
576
+ default: UnimplementedInstruction();
577
+ }
578
+ if (op == 0xD1) {
579
+ imm8 = 1;
580
+ } else if (op == 0xC1) {
581
+ imm8 = *(data+2);
582
+ num_bytes = 3;
583
+ } else if (op == 0xD3) {
584
+ // Shift/rotate by cl.
585
+ }
586
+ ASSERT_NE(NULL, mnem);
587
+ AppendToBuffer("%s %s,", mnem, NameOfCPURegister(rm));
588
+ if (imm8 > 0) {
589
+ AppendToBuffer("%d", imm8);
590
+ } else {
591
+ AppendToBuffer("cl");
592
+ }
593
+ } else {
594
+ UnimplementedInstruction();
595
+ }
596
+ return num_bytes;
597
+ }
598
+
599
+
600
+ // Returns number of bytes used, including *data.
601
+ int DisassemblerIA32::JumpShort(byte* data) {
602
+ ASSERT_EQ(0xEB, *data);
603
+ byte b = *(data+1);
604
+ byte* dest = data + static_cast<int8_t>(b) + 2;
605
+ AppendToBuffer("jmp %s", NameOfAddress(dest));
606
+ return 2;
607
+ }
608
+
609
+
610
+ // Returns number of bytes used, including *data.
611
+ int DisassemblerIA32::JumpConditional(byte* data, const char* comment) {
612
+ ASSERT_EQ(0x0F, *data);
613
+ byte cond = *(data+1) & 0x0F;
614
+ byte* dest = data + *reinterpret_cast<int32_t*>(data+2) + 6;
615
+ const char* mnem = jump_conditional_mnem[cond];
616
+ AppendToBuffer("%s %s", mnem, NameOfAddress(dest));
617
+ if (comment != NULL) {
618
+ AppendToBuffer(", %s", comment);
619
+ }
620
+ return 6; // includes 0x0F
621
+ }
622
+
623
+
624
+ // Returns number of bytes used, including *data.
625
+ int DisassemblerIA32::JumpConditionalShort(byte* data, const char* comment) {
626
+ byte cond = *data & 0x0F;
627
+ byte b = *(data+1);
628
+ byte* dest = data + static_cast<int8_t>(b) + 2;
629
+ const char* mnem = jump_conditional_mnem[cond];
630
+ AppendToBuffer("%s %s", mnem, NameOfAddress(dest));
631
+ if (comment != NULL) {
632
+ AppendToBuffer(", %s", comment);
633
+ }
634
+ return 2;
635
+ }
636
+
637
+
638
+ // Returns number of bytes used, including *data.
639
+ int DisassemblerIA32::SetCC(byte* data) {
640
+ ASSERT_EQ(0x0F, *data);
641
+ byte cond = *(data+1) & 0x0F;
642
+ const char* mnem = set_conditional_mnem[cond];
643
+ AppendToBuffer("%s ", mnem);
644
+ PrintRightByteOperand(data+2);
645
+ return 3; // Includes 0x0F.
646
+ }
647
+
648
+
649
+ // Returns number of bytes used, including *data.
650
+ int DisassemblerIA32::CMov(byte* data) {
651
+ ASSERT_EQ(0x0F, *data);
652
+ byte cond = *(data + 1) & 0x0F;
653
+ const char* mnem = conditional_move_mnem[cond];
654
+ int op_size = PrintOperands(mnem, REG_OPER_OP_ORDER, data + 2);
655
+ return 2 + op_size; // includes 0x0F
656
+ }
657
+
658
+
659
+ // Returns number of bytes used, including *data.
660
+ int DisassemblerIA32::FPUInstruction(byte* data) {
661
+ byte escape_opcode = *data;
662
+ ASSERT_EQ(0xD8, escape_opcode & 0xF8);
663
+ byte modrm_byte = *(data+1);
664
+
665
+ if (modrm_byte >= 0xC0) {
666
+ return RegisterFPUInstruction(escape_opcode, modrm_byte);
667
+ } else {
668
+ return MemoryFPUInstruction(escape_opcode, modrm_byte, data+1);
669
+ }
670
+ }
671
+
672
+ int DisassemblerIA32::MemoryFPUInstruction(int escape_opcode,
673
+ int modrm_byte,
674
+ byte* modrm_start) {
675
+ const char* mnem = "?";
676
+ int regop = (modrm_byte >> 3) & 0x7; // reg/op field of modrm byte.
677
+ switch (escape_opcode) {
678
+ case 0xD9: switch (regop) {
679
+ case 0: mnem = "fld_s"; break;
680
+ case 3: mnem = "fstp_s"; break;
681
+ case 7: mnem = "fstcw"; break;
682
+ default: UnimplementedInstruction();
683
+ }
684
+ break;
685
+
686
+ case 0xDB: switch (regop) {
687
+ case 0: mnem = "fild_s"; break;
688
+ case 1: mnem = "fisttp_s"; break;
689
+ case 2: mnem = "fist_s"; break;
690
+ case 3: mnem = "fistp_s"; break;
691
+ default: UnimplementedInstruction();
692
+ }
693
+ break;
694
+
695
+ case 0xDD: switch (regop) {
696
+ case 0: mnem = "fld_d"; break;
697
+ case 1: mnem = "fisttp_d"; break;
698
+ case 2: mnem = "fst_d"; break;
699
+ case 3: mnem = "fstp_d"; break;
700
+ default: UnimplementedInstruction();
701
+ }
702
+ break;
703
+
704
+ case 0xDF: switch (regop) {
705
+ case 5: mnem = "fild_d"; break;
706
+ case 7: mnem = "fistp_d"; break;
707
+ default: UnimplementedInstruction();
708
+ }
709
+ break;
710
+
711
+ default: UnimplementedInstruction();
712
+ }
713
+ AppendToBuffer("%s ", mnem);
714
+ int count = PrintRightOperand(modrm_start);
715
+ return count + 1;
716
+ }
717
+
718
+ int DisassemblerIA32::RegisterFPUInstruction(int escape_opcode,
719
+ byte modrm_byte) {
720
+ bool has_register = false; // Is the FPU register encoded in modrm_byte?
721
+ const char* mnem = "?";
722
+
723
+ switch (escape_opcode) {
724
+ case 0xD8:
725
+ UnimplementedInstruction();
726
+ break;
727
+
728
+ case 0xD9:
729
+ switch (modrm_byte & 0xF8) {
730
+ case 0xC0:
731
+ mnem = "fld";
732
+ has_register = true;
733
+ break;
734
+ case 0xC8:
735
+ mnem = "fxch";
736
+ has_register = true;
737
+ break;
738
+ default:
739
+ switch (modrm_byte) {
740
+ case 0xE0: mnem = "fchs"; break;
741
+ case 0xE1: mnem = "fabs"; break;
742
+ case 0xE4: mnem = "ftst"; break;
743
+ case 0xE8: mnem = "fld1"; break;
744
+ case 0xEB: mnem = "fldpi"; break;
745
+ case 0xED: mnem = "fldln2"; break;
746
+ case 0xEE: mnem = "fldz"; break;
747
+ case 0xF1: mnem = "fyl2x"; break;
748
+ case 0xF5: mnem = "fprem1"; break;
749
+ case 0xF7: mnem = "fincstp"; break;
750
+ case 0xF8: mnem = "fprem"; break;
751
+ case 0xFE: mnem = "fsin"; break;
752
+ case 0xFF: mnem = "fcos"; break;
753
+ default: UnimplementedInstruction();
754
+ }
755
+ }
756
+ break;
757
+
758
+ case 0xDA:
759
+ if (modrm_byte == 0xE9) {
760
+ mnem = "fucompp";
761
+ } else {
762
+ UnimplementedInstruction();
763
+ }
764
+ break;
765
+
766
+ case 0xDB:
767
+ if ((modrm_byte & 0xF8) == 0xE8) {
768
+ mnem = "fucomi";
769
+ has_register = true;
770
+ } else if (modrm_byte == 0xE2) {
771
+ mnem = "fclex";
772
+ } else {
773
+ UnimplementedInstruction();
774
+ }
775
+ break;
776
+
777
+ case 0xDC:
778
+ has_register = true;
779
+ switch (modrm_byte & 0xF8) {
780
+ case 0xC0: mnem = "fadd"; break;
781
+ case 0xE8: mnem = "fsub"; break;
782
+ case 0xC8: mnem = "fmul"; break;
783
+ case 0xF8: mnem = "fdiv"; break;
784
+ default: UnimplementedInstruction();
785
+ }
786
+ break;
787
+
788
+ case 0xDD:
789
+ has_register = true;
790
+ switch (modrm_byte & 0xF8) {
791
+ case 0xC0: mnem = "ffree"; break;
792
+ case 0xD8: mnem = "fstp"; break;
793
+ default: UnimplementedInstruction();
794
+ }
795
+ break;
796
+
797
+ case 0xDE:
798
+ if (modrm_byte == 0xD9) {
799
+ mnem = "fcompp";
800
+ } else {
801
+ has_register = true;
802
+ switch (modrm_byte & 0xF8) {
803
+ case 0xC0: mnem = "faddp"; break;
804
+ case 0xE8: mnem = "fsubp"; break;
805
+ case 0xC8: mnem = "fmulp"; break;
806
+ case 0xF8: mnem = "fdivp"; break;
807
+ default: UnimplementedInstruction();
808
+ }
809
+ }
810
+ break;
811
+
812
+ case 0xDF:
813
+ if (modrm_byte == 0xE0) {
814
+ mnem = "fnstsw_ax";
815
+ } else if ((modrm_byte & 0xF8) == 0xE8) {
816
+ mnem = "fucomip";
817
+ has_register = true;
818
+ }
819
+ break;
820
+
821
+ default: UnimplementedInstruction();
822
+ }
823
+
824
+ if (has_register) {
825
+ AppendToBuffer("%s st%d", mnem, modrm_byte & 0x7);
826
+ } else {
827
+ AppendToBuffer("%s", mnem);
828
+ }
829
+ return 2;
830
+ }
831
+
832
+
833
+ // Mnemonics for instructions 0xF0 byte.
834
+ // Returns NULL if the instruction is not handled here.
835
+ static const char* F0Mnem(byte f0byte) {
836
+ switch (f0byte) {
837
+ case 0x18: return "prefetch";
838
+ case 0xA2: return "cpuid";
839
+ case 0x31: return "rdtsc";
840
+ case 0xBE: return "movsx_b";
841
+ case 0xBF: return "movsx_w";
842
+ case 0xB6: return "movzx_b";
843
+ case 0xB7: return "movzx_w";
844
+ case 0xAF: return "imul";
845
+ case 0xA5: return "shld";
846
+ case 0xAD: return "shrd";
847
+ case 0xAB: return "bts";
848
+ default: return NULL;
849
+ }
850
+ }
851
+
852
+
853
+ // Disassembled instruction '*instr' and writes it into 'out_buffer'.
854
+ int DisassemblerIA32::InstructionDecode(v8::internal::Vector<char> out_buffer,
855
+ byte* instr) {
856
+ tmp_buffer_pos_ = 0; // starting to write as position 0
857
+ byte* data = instr;
858
+ // Check for hints.
859
+ const char* branch_hint = NULL;
860
+ // We use these two prefixes only with branch prediction
861
+ if (*data == 0x3E /*ds*/) {
862
+ branch_hint = "predicted taken";
863
+ data++;
864
+ } else if (*data == 0x2E /*cs*/) {
865
+ branch_hint = "predicted not taken";
866
+ data++;
867
+ }
868
+ bool processed = true; // Will be set to false if the current instruction
869
+ // is not in 'instructions' table.
870
+ const InstructionDesc& idesc = instruction_table.Get(*data);
871
+ switch (idesc.type) {
872
+ case ZERO_OPERANDS_INSTR:
873
+ AppendToBuffer(idesc.mnem);
874
+ data++;
875
+ break;
876
+
877
+ case TWO_OPERANDS_INSTR:
878
+ data++;
879
+ data += PrintOperands(idesc.mnem, idesc.op_order_, data);
880
+ break;
881
+
882
+ case JUMP_CONDITIONAL_SHORT_INSTR:
883
+ data += JumpConditionalShort(data, branch_hint);
884
+ break;
885
+
886
+ case REGISTER_INSTR:
887
+ AppendToBuffer("%s %s", idesc.mnem, NameOfCPURegister(*data & 0x07));
888
+ data++;
889
+ break;
890
+
891
+ case MOVE_REG_INSTR: {
892
+ byte* addr = reinterpret_cast<byte*>(*reinterpret_cast<int32_t*>(data+1));
893
+ AppendToBuffer("mov %s,%s",
894
+ NameOfCPURegister(*data & 0x07),
895
+ NameOfAddress(addr));
896
+ data += 5;
897
+ break;
898
+ }
899
+
900
+ case CALL_JUMP_INSTR: {
901
+ byte* addr = data + *reinterpret_cast<int32_t*>(data+1) + 5;
902
+ AppendToBuffer("%s %s", idesc.mnem, NameOfAddress(addr));
903
+ data += 5;
904
+ break;
905
+ }
906
+
907
+ case SHORT_IMMEDIATE_INSTR: {
908
+ byte* addr = reinterpret_cast<byte*>(*reinterpret_cast<int32_t*>(data+1));
909
+ AppendToBuffer("%s eax, %s", idesc.mnem, NameOfAddress(addr));
910
+ data += 5;
911
+ break;
912
+ }
913
+
914
+ case NO_INSTR:
915
+ processed = false;
916
+ break;
917
+
918
+ default:
919
+ UNIMPLEMENTED(); // This type is not implemented.
920
+ }
921
+ //----------------------------
922
+ if (!processed) {
923
+ switch (*data) {
924
+ case 0xC2:
925
+ AppendToBuffer("ret 0x%x", *reinterpret_cast<uint16_t*>(data+1));
926
+ data += 3;
927
+ break;
928
+
929
+ case 0x69: // fall through
930
+ case 0x6B:
931
+ { int mod, regop, rm;
932
+ get_modrm(*(data+1), &mod, &regop, &rm);
933
+ int32_t imm =
934
+ *data == 0x6B ? *(data+2) : *reinterpret_cast<int32_t*>(data+2);
935
+ AppendToBuffer("imul %s,%s,0x%x",
936
+ NameOfCPURegister(regop),
937
+ NameOfCPURegister(rm),
938
+ imm);
939
+ data += 2 + (*data == 0x6B ? 1 : 4);
940
+ }
941
+ break;
942
+
943
+ case 0xF6:
944
+ { data++;
945
+ int mod, regop, rm;
946
+ get_modrm(*data, &mod, &regop, &rm);
947
+ if (regop == eax) {
948
+ AppendToBuffer("test_b ");
949
+ data += PrintRightByteOperand(data);
950
+ int32_t imm = *data;
951
+ AppendToBuffer(",0x%x", imm);
952
+ data++;
953
+ } else {
954
+ UnimplementedInstruction();
955
+ }
956
+ }
957
+ break;
958
+
959
+ case 0x81: // fall through
960
+ case 0x83: // 0x81 with sign extension bit set
961
+ data += PrintImmediateOp(data);
962
+ break;
963
+
964
+ case 0x0F:
965
+ { byte f0byte = *(data+1);
966
+ const char* f0mnem = F0Mnem(f0byte);
967
+ if (f0byte == 0x18) {
968
+ int mod, regop, rm;
969
+ get_modrm(*data, &mod, &regop, &rm);
970
+ const char* suffix[] = {"nta", "1", "2", "3"};
971
+ AppendToBuffer("%s%s ", f0mnem, suffix[regop & 0x03]);
972
+ data += PrintRightOperand(data);
973
+ } else if (f0byte == 0xA2 || f0byte == 0x31) {
974
+ AppendToBuffer("%s", f0mnem);
975
+ data += 2;
976
+ } else if (f0byte == 0x28) {
977
+ data += 2;
978
+ int mod, regop, rm;
979
+ get_modrm(*data, &mod, &regop, &rm);
980
+ AppendToBuffer("movaps %s,%s",
981
+ NameOfXMMRegister(regop),
982
+ NameOfXMMRegister(rm));
983
+ data++;
984
+ } else if (f0byte == 0x57) {
985
+ data += 2;
986
+ int mod, regop, rm;
987
+ get_modrm(*data, &mod, &regop, &rm);
988
+ AppendToBuffer("xorps %s,%s",
989
+ NameOfXMMRegister(regop),
990
+ NameOfXMMRegister(rm));
991
+ data++;
992
+ } else if ((f0byte & 0xF0) == 0x80) {
993
+ data += JumpConditional(data, branch_hint);
994
+ } else if (f0byte == 0xBE || f0byte == 0xBF || f0byte == 0xB6 ||
995
+ f0byte == 0xB7 || f0byte == 0xAF) {
996
+ data += 2;
997
+ data += PrintOperands(f0mnem, REG_OPER_OP_ORDER, data);
998
+ } else if ((f0byte & 0xF0) == 0x90) {
999
+ data += SetCC(data);
1000
+ } else if ((f0byte & 0xF0) == 0x40) {
1001
+ data += CMov(data);
1002
+ } else {
1003
+ data += 2;
1004
+ if (f0byte == 0xAB || f0byte == 0xA5 || f0byte == 0xAD) {
1005
+ // shrd, shld, bts
1006
+ AppendToBuffer("%s ", f0mnem);
1007
+ int mod, regop, rm;
1008
+ get_modrm(*data, &mod, &regop, &rm);
1009
+ data += PrintRightOperand(data);
1010
+ if (f0byte == 0xAB) {
1011
+ AppendToBuffer(",%s", NameOfCPURegister(regop));
1012
+ } else {
1013
+ AppendToBuffer(",%s,cl", NameOfCPURegister(regop));
1014
+ }
1015
+ } else {
1016
+ UnimplementedInstruction();
1017
+ }
1018
+ }
1019
+ }
1020
+ break;
1021
+
1022
+ case 0x8F:
1023
+ { data++;
1024
+ int mod, regop, rm;
1025
+ get_modrm(*data, &mod, &regop, &rm);
1026
+ if (regop == eax) {
1027
+ AppendToBuffer("pop ");
1028
+ data += PrintRightOperand(data);
1029
+ }
1030
+ }
1031
+ break;
1032
+
1033
+ case 0xFF:
1034
+ { data++;
1035
+ int mod, regop, rm;
1036
+ get_modrm(*data, &mod, &regop, &rm);
1037
+ const char* mnem = NULL;
1038
+ switch (regop) {
1039
+ case esi: mnem = "push"; break;
1040
+ case eax: mnem = "inc"; break;
1041
+ case ecx: mnem = "dec"; break;
1042
+ case edx: mnem = "call"; break;
1043
+ case esp: mnem = "jmp"; break;
1044
+ default: mnem = "???";
1045
+ }
1046
+ AppendToBuffer("%s ", mnem);
1047
+ data += PrintRightOperand(data);
1048
+ }
1049
+ break;
1050
+
1051
+ case 0xC7: // imm32, fall through
1052
+ case 0xC6: // imm8
1053
+ { bool is_byte = *data == 0xC6;
1054
+ data++;
1055
+ if (is_byte) {
1056
+ AppendToBuffer("%s ", "mov_b");
1057
+ data += PrintRightByteOperand(data);
1058
+ int32_t imm = *data;
1059
+ AppendToBuffer(",0x%x", imm);
1060
+ data++;
1061
+ } else {
1062
+ AppendToBuffer("%s ", "mov");
1063
+ data += PrintRightOperand(data);
1064
+ int32_t imm = *reinterpret_cast<int32_t*>(data);
1065
+ AppendToBuffer(",0x%x", imm);
1066
+ data += 4;
1067
+ }
1068
+ }
1069
+ break;
1070
+
1071
+ case 0x80:
1072
+ { data++;
1073
+ int mod, regop, rm;
1074
+ get_modrm(*data, &mod, &regop, &rm);
1075
+ const char* mnem = NULL;
1076
+ switch (regop) {
1077
+ case 5: mnem = "subb"; break;
1078
+ case 7: mnem = "cmpb"; break;
1079
+ default: UnimplementedInstruction();
1080
+ }
1081
+ AppendToBuffer("%s ", mnem);
1082
+ data += PrintRightByteOperand(data);
1083
+ int32_t imm = *data;
1084
+ AppendToBuffer(",0x%x", imm);
1085
+ data++;
1086
+ }
1087
+ break;
1088
+
1089
+ case 0x88: // 8bit, fall through
1090
+ case 0x89: // 32bit
1091
+ { bool is_byte = *data == 0x88;
1092
+ int mod, regop, rm;
1093
+ data++;
1094
+ get_modrm(*data, &mod, &regop, &rm);
1095
+ if (is_byte) {
1096
+ AppendToBuffer("%s ", "mov_b");
1097
+ data += PrintRightByteOperand(data);
1098
+ AppendToBuffer(",%s", NameOfByteCPURegister(regop));
1099
+ } else {
1100
+ AppendToBuffer("%s ", "mov");
1101
+ data += PrintRightOperand(data);
1102
+ AppendToBuffer(",%s", NameOfCPURegister(regop));
1103
+ }
1104
+ }
1105
+ break;
1106
+
1107
+ case 0x66: // prefix
1108
+ data++;
1109
+ if (*data == 0x8B) {
1110
+ data++;
1111
+ data += PrintOperands("mov_w", REG_OPER_OP_ORDER, data);
1112
+ } else if (*data == 0x89) {
1113
+ data++;
1114
+ int mod, regop, rm;
1115
+ get_modrm(*data, &mod, &regop, &rm);
1116
+ AppendToBuffer("mov_w ");
1117
+ data += PrintRightOperand(data);
1118
+ AppendToBuffer(",%s", NameOfCPURegister(regop));
1119
+ } else if (*data == 0x0F) {
1120
+ data++;
1121
+ if (*data == 0x38) {
1122
+ data++;
1123
+ if (*data == 0x17) {
1124
+ data++;
1125
+ int mod, regop, rm;
1126
+ get_modrm(*data, &mod, &regop, &rm);
1127
+ AppendToBuffer("ptest %s,%s",
1128
+ NameOfXMMRegister(regop),
1129
+ NameOfXMMRegister(rm));
1130
+ data++;
1131
+ } else if (*data == 0x2A) {
1132
+ // movntdqa
1133
+ data++;
1134
+ int mod, regop, rm;
1135
+ get_modrm(*data, &mod, &regop, &rm);
1136
+ AppendToBuffer("movntdqa %s,", NameOfXMMRegister(regop));
1137
+ data += PrintRightOperand(data);
1138
+ } else {
1139
+ UnimplementedInstruction();
1140
+ }
1141
+ } else if (*data == 0x3A) {
1142
+ data++;
1143
+ if (*data == 0x16) {
1144
+ data++;
1145
+ int mod, regop, rm;
1146
+ get_modrm(*data, &mod, &regop, &rm);
1147
+ int8_t imm8 = static_cast<int8_t>(data[1]);
1148
+ AppendToBuffer("pextrd %s,%s,%d",
1149
+ NameOfCPURegister(regop),
1150
+ NameOfXMMRegister(rm),
1151
+ static_cast<int>(imm8));
1152
+ data += 2;
1153
+ } else if (*data == 0x22) {
1154
+ data++;
1155
+ int mod, regop, rm;
1156
+ get_modrm(*data, &mod, &regop, &rm);
1157
+ int8_t imm8 = static_cast<int8_t>(data[1]);
1158
+ AppendToBuffer("pinsrd %s,%s,%d",
1159
+ NameOfXMMRegister(regop),
1160
+ NameOfCPURegister(rm),
1161
+ static_cast<int>(imm8));
1162
+ data += 2;
1163
+ } else {
1164
+ UnimplementedInstruction();
1165
+ }
1166
+ } else if (*data == 0x2E || *data == 0x2F) {
1167
+ const char* mnem = (*data == 0x2E) ? "ucomisd" : "comisd";
1168
+ data++;
1169
+ int mod, regop, rm;
1170
+ get_modrm(*data, &mod, &regop, &rm);
1171
+ if (mod == 0x3) {
1172
+ AppendToBuffer("%s %s,%s", mnem,
1173
+ NameOfXMMRegister(regop),
1174
+ NameOfXMMRegister(rm));
1175
+ data++;
1176
+ } else {
1177
+ AppendToBuffer("%s %s,", mnem, NameOfXMMRegister(regop));
1178
+ data += PrintRightOperand(data);
1179
+ }
1180
+ } else if (*data == 0x50) {
1181
+ data++;
1182
+ int mod, regop, rm;
1183
+ get_modrm(*data, &mod, &regop, &rm);
1184
+ AppendToBuffer("movmskpd %s,%s",
1185
+ NameOfCPURegister(regop),
1186
+ NameOfXMMRegister(rm));
1187
+ data++;
1188
+ } else if (*data == 0x54) {
1189
+ data++;
1190
+ int mod, regop, rm;
1191
+ get_modrm(*data, &mod, &regop, &rm);
1192
+ AppendToBuffer("andpd %s,%s",
1193
+ NameOfXMMRegister(regop),
1194
+ NameOfXMMRegister(rm));
1195
+ data++;
1196
+ } else if (*data == 0x57) {
1197
+ data++;
1198
+ int mod, regop, rm;
1199
+ get_modrm(*data, &mod, &regop, &rm);
1200
+ AppendToBuffer("xorpd %s,%s",
1201
+ NameOfXMMRegister(regop),
1202
+ NameOfXMMRegister(rm));
1203
+ data++;
1204
+ } else if (*data == 0x6E) {
1205
+ data++;
1206
+ int mod, regop, rm;
1207
+ get_modrm(*data, &mod, &regop, &rm);
1208
+ AppendToBuffer("movd %s,", NameOfXMMRegister(regop));
1209
+ data += PrintRightOperand(data);
1210
+ } else if (*data == 0x6F) {
1211
+ data++;
1212
+ int mod, regop, rm;
1213
+ get_modrm(*data, &mod, &regop, &rm);
1214
+ AppendToBuffer("movdqa %s,", NameOfXMMRegister(regop));
1215
+ data += PrintRightXMMOperand(data);
1216
+ } else if (*data == 0x70) {
1217
+ data++;
1218
+ int mod, regop, rm;
1219
+ get_modrm(*data, &mod, &regop, &rm);
1220
+ int8_t imm8 = static_cast<int8_t>(data[1]);
1221
+ AppendToBuffer("pshufd %s,%s,%d",
1222
+ NameOfXMMRegister(regop),
1223
+ NameOfXMMRegister(rm),
1224
+ static_cast<int>(imm8));
1225
+ data += 2;
1226
+ } else if (*data == 0xF3) {
1227
+ data++;
1228
+ int mod, regop, rm;
1229
+ get_modrm(*data, &mod, &regop, &rm);
1230
+ AppendToBuffer("psllq %s,%s",
1231
+ NameOfXMMRegister(regop),
1232
+ NameOfXMMRegister(rm));
1233
+ data++;
1234
+ } else if (*data == 0x73) {
1235
+ data++;
1236
+ int mod, regop, rm;
1237
+ get_modrm(*data, &mod, &regop, &rm);
1238
+ int8_t imm8 = static_cast<int8_t>(data[1]);
1239
+ ASSERT(regop == esi || regop == edx);
1240
+ AppendToBuffer("%s %s,%d",
1241
+ (regop == esi) ? "psllq" : "psrlq",
1242
+ NameOfXMMRegister(rm),
1243
+ static_cast<int>(imm8));
1244
+ data += 2;
1245
+ } else if (*data == 0xD3) {
1246
+ data++;
1247
+ int mod, regop, rm;
1248
+ get_modrm(*data, &mod, &regop, &rm);
1249
+ AppendToBuffer("psrlq %s,%s",
1250
+ NameOfXMMRegister(regop),
1251
+ NameOfXMMRegister(rm));
1252
+ data++;
1253
+ } else if (*data == 0x7F) {
1254
+ AppendToBuffer("movdqa ");
1255
+ data++;
1256
+ int mod, regop, rm;
1257
+ get_modrm(*data, &mod, &regop, &rm);
1258
+ data += PrintRightXMMOperand(data);
1259
+ AppendToBuffer(",%s", NameOfXMMRegister(regop));
1260
+ } else if (*data == 0x7E) {
1261
+ data++;
1262
+ int mod, regop, rm;
1263
+ get_modrm(*data, &mod, &regop, &rm);
1264
+ AppendToBuffer("movd ");
1265
+ data += PrintRightOperand(data);
1266
+ AppendToBuffer(",%s", NameOfXMMRegister(regop));
1267
+ } else if (*data == 0xDB) {
1268
+ data++;
1269
+ int mod, regop, rm;
1270
+ get_modrm(*data, &mod, &regop, &rm);
1271
+ AppendToBuffer("pand %s,%s",
1272
+ NameOfXMMRegister(regop),
1273
+ NameOfXMMRegister(rm));
1274
+ data++;
1275
+ } else if (*data == 0xE7) {
1276
+ data++;
1277
+ int mod, regop, rm;
1278
+ get_modrm(*data, &mod, &regop, &rm);
1279
+ if (mod == 3) {
1280
+ AppendToBuffer("movntdq ");
1281
+ data += PrintRightOperand(data);
1282
+ AppendToBuffer(",%s", NameOfXMMRegister(regop));
1283
+ } else {
1284
+ UnimplementedInstruction();
1285
+ }
1286
+ } else if (*data == 0xEF) {
1287
+ data++;
1288
+ int mod, regop, rm;
1289
+ get_modrm(*data, &mod, &regop, &rm);
1290
+ AppendToBuffer("pxor %s,%s",
1291
+ NameOfXMMRegister(regop),
1292
+ NameOfXMMRegister(rm));
1293
+ data++;
1294
+ } else if (*data == 0xEB) {
1295
+ data++;
1296
+ int mod, regop, rm;
1297
+ get_modrm(*data, &mod, &regop, &rm);
1298
+ AppendToBuffer("por %s,%s",
1299
+ NameOfXMMRegister(regop),
1300
+ NameOfXMMRegister(rm));
1301
+ data++;
1302
+ } else {
1303
+ UnimplementedInstruction();
1304
+ }
1305
+ } else {
1306
+ UnimplementedInstruction();
1307
+ }
1308
+ break;
1309
+
1310
+ case 0xFE:
1311
+ { data++;
1312
+ int mod, regop, rm;
1313
+ get_modrm(*data, &mod, &regop, &rm);
1314
+ if (regop == ecx) {
1315
+ AppendToBuffer("dec_b ");
1316
+ data += PrintRightOperand(data);
1317
+ } else {
1318
+ UnimplementedInstruction();
1319
+ }
1320
+ }
1321
+ break;
1322
+
1323
+ case 0x68:
1324
+ AppendToBuffer("push 0x%x", *reinterpret_cast<int32_t*>(data+1));
1325
+ data += 5;
1326
+ break;
1327
+
1328
+ case 0x6A:
1329
+ AppendToBuffer("push 0x%x", *reinterpret_cast<int8_t*>(data + 1));
1330
+ data += 2;
1331
+ break;
1332
+
1333
+ case 0xA8:
1334
+ AppendToBuffer("test al,0x%x", *reinterpret_cast<uint8_t*>(data+1));
1335
+ data += 2;
1336
+ break;
1337
+
1338
+ case 0x2C:
1339
+ AppendToBuffer("subb eax,0x%x", *reinterpret_cast<uint8_t*>(data+1));
1340
+ data += 2;
1341
+ break;
1342
+
1343
+ case 0xA9:
1344
+ AppendToBuffer("test eax,0x%x", *reinterpret_cast<int32_t*>(data+1));
1345
+ data += 5;
1346
+ break;
1347
+
1348
+ case 0xD1: // fall through
1349
+ case 0xD3: // fall through
1350
+ case 0xC1:
1351
+ data += D1D3C1Instruction(data);
1352
+ break;
1353
+
1354
+ case 0xD9: // fall through
1355
+ case 0xDA: // fall through
1356
+ case 0xDB: // fall through
1357
+ case 0xDC: // fall through
1358
+ case 0xDD: // fall through
1359
+ case 0xDE: // fall through
1360
+ case 0xDF:
1361
+ data += FPUInstruction(data);
1362
+ break;
1363
+
1364
+ case 0xEB:
1365
+ data += JumpShort(data);
1366
+ break;
1367
+
1368
+ case 0xF2:
1369
+ if (*(data+1) == 0x0F) {
1370
+ byte b2 = *(data+2);
1371
+ if (b2 == 0x11) {
1372
+ AppendToBuffer("movsd ");
1373
+ data += 3;
1374
+ int mod, regop, rm;
1375
+ get_modrm(*data, &mod, &regop, &rm);
1376
+ data += PrintRightXMMOperand(data);
1377
+ AppendToBuffer(",%s", NameOfXMMRegister(regop));
1378
+ } else if (b2 == 0x10) {
1379
+ data += 3;
1380
+ int mod, regop, rm;
1381
+ get_modrm(*data, &mod, &regop, &rm);
1382
+ AppendToBuffer("movsd %s,", NameOfXMMRegister(regop));
1383
+ data += PrintRightXMMOperand(data);
1384
+ } else if (b2 == 0x5A) {
1385
+ data += 3;
1386
+ int mod, regop, rm;
1387
+ get_modrm(*data, &mod, &regop, &rm);
1388
+ AppendToBuffer("cvtsd2ss %s,", NameOfXMMRegister(regop));
1389
+ data += PrintRightXMMOperand(data);
1390
+ } else {
1391
+ const char* mnem = "?";
1392
+ switch (b2) {
1393
+ case 0x2A: mnem = "cvtsi2sd"; break;
1394
+ case 0x2C: mnem = "cvttsd2si"; break;
1395
+ case 0x51: mnem = "sqrtsd"; break;
1396
+ case 0x58: mnem = "addsd"; break;
1397
+ case 0x59: mnem = "mulsd"; break;
1398
+ case 0x5C: mnem = "subsd"; break;
1399
+ case 0x5E: mnem = "divsd"; break;
1400
+ }
1401
+ data += 3;
1402
+ int mod, regop, rm;
1403
+ get_modrm(*data, &mod, &regop, &rm);
1404
+ if (b2 == 0x2A) {
1405
+ AppendToBuffer("%s %s,", mnem, NameOfXMMRegister(regop));
1406
+ data += PrintRightOperand(data);
1407
+ } else if (b2 == 0x2C) {
1408
+ AppendToBuffer("%s %s,", mnem, NameOfCPURegister(regop));
1409
+ data += PrintRightXMMOperand(data);
1410
+ } else if (b2 == 0xC2) {
1411
+ // Intel manual 2A, Table 3-18.
1412
+ const char* const pseudo_op[] = {
1413
+ "cmpeqsd",
1414
+ "cmpltsd",
1415
+ "cmplesd",
1416
+ "cmpunordsd",
1417
+ "cmpneqsd",
1418
+ "cmpnltsd",
1419
+ "cmpnlesd",
1420
+ "cmpordsd"
1421
+ };
1422
+ AppendToBuffer("%s %s,%s",
1423
+ pseudo_op[data[1]],
1424
+ NameOfXMMRegister(regop),
1425
+ NameOfXMMRegister(rm));
1426
+ data += 2;
1427
+ } else {
1428
+ AppendToBuffer("%s %s,", mnem, NameOfXMMRegister(regop));
1429
+ data += PrintRightXMMOperand(data);
1430
+ }
1431
+ }
1432
+ } else {
1433
+ UnimplementedInstruction();
1434
+ }
1435
+ break;
1436
+
1437
+ case 0xF3:
1438
+ if (*(data+1) == 0x0F) {
1439
+ byte b2 = *(data+2);
1440
+ if (b2 == 0x11) {
1441
+ AppendToBuffer("movss ");
1442
+ data += 3;
1443
+ int mod, regop, rm;
1444
+ get_modrm(*data, &mod, &regop, &rm);
1445
+ data += PrintRightXMMOperand(data);
1446
+ AppendToBuffer(",%s", NameOfXMMRegister(regop));
1447
+ } else if (b2 == 0x10) {
1448
+ data += 3;
1449
+ int mod, regop, rm;
1450
+ get_modrm(*data, &mod, &regop, &rm);
1451
+ AppendToBuffer("movss %s,", NameOfXMMRegister(regop));
1452
+ data += PrintRightXMMOperand(data);
1453
+ } else if (b2 == 0x2C) {
1454
+ data += 3;
1455
+ int mod, regop, rm;
1456
+ get_modrm(*data, &mod, &regop, &rm);
1457
+ AppendToBuffer("cvttss2si %s,", NameOfCPURegister(regop));
1458
+ data += PrintRightXMMOperand(data);
1459
+ } else if (b2 == 0x5A) {
1460
+ data += 3;
1461
+ int mod, regop, rm;
1462
+ get_modrm(*data, &mod, &regop, &rm);
1463
+ AppendToBuffer("cvtss2sd %s,", NameOfXMMRegister(regop));
1464
+ data += PrintRightXMMOperand(data);
1465
+ } else if (b2 == 0x6F) {
1466
+ data += 3;
1467
+ int mod, regop, rm;
1468
+ get_modrm(*data, &mod, &regop, &rm);
1469
+ AppendToBuffer("movdqu %s,", NameOfXMMRegister(regop));
1470
+ data += PrintRightXMMOperand(data);
1471
+ } else if (b2 == 0x7F) {
1472
+ AppendToBuffer("movdqu ");
1473
+ data += 3;
1474
+ int mod, regop, rm;
1475
+ get_modrm(*data, &mod, &regop, &rm);
1476
+ data += PrintRightXMMOperand(data);
1477
+ AppendToBuffer(",%s", NameOfXMMRegister(regop));
1478
+ } else {
1479
+ UnimplementedInstruction();
1480
+ }
1481
+ } else if (*(data+1) == 0xA5) {
1482
+ data += 2;
1483
+ AppendToBuffer("rep_movs");
1484
+ } else if (*(data+1) == 0xAB) {
1485
+ data += 2;
1486
+ AppendToBuffer("rep_stos");
1487
+ } else {
1488
+ UnimplementedInstruction();
1489
+ }
1490
+ break;
1491
+
1492
+ case 0xF7:
1493
+ data += F7Instruction(data);
1494
+ break;
1495
+
1496
+ default:
1497
+ UnimplementedInstruction();
1498
+ }
1499
+ }
1500
+
1501
+ if (tmp_buffer_pos_ < sizeof tmp_buffer_) {
1502
+ tmp_buffer_[tmp_buffer_pos_] = '\0';
1503
+ }
1504
+
1505
+ int instr_len = data - instr;
1506
+ if (instr_len == 0) {
1507
+ printf("%02x", *data);
1508
+ }
1509
+ ASSERT(instr_len > 0); // Ensure progress.
1510
+
1511
+ int outp = 0;
1512
+ // Instruction bytes.
1513
+ for (byte* bp = instr; bp < data; bp++) {
1514
+ outp += v8::internal::OS::SNPrintF(out_buffer + outp,
1515
+ "%02x",
1516
+ *bp);
1517
+ }
1518
+ for (int i = 6 - instr_len; i >= 0; i--) {
1519
+ outp += v8::internal::OS::SNPrintF(out_buffer + outp,
1520
+ " ");
1521
+ }
1522
+
1523
+ outp += v8::internal::OS::SNPrintF(out_buffer + outp,
1524
+ " %s",
1525
+ tmp_buffer_.start());
1526
+ return instr_len;
1527
+ } // NOLINT (function is too long)
1528
+
1529
+
1530
+ //------------------------------------------------------------------------------
1531
+
1532
+
1533
+ static const char* cpu_regs[8] = {
1534
+ "eax", "ecx", "edx", "ebx", "esp", "ebp", "esi", "edi"
1535
+ };
1536
+
1537
+
1538
+ static const char* byte_cpu_regs[8] = {
1539
+ "al", "cl", "dl", "bl", "ah", "ch", "dh", "bh"
1540
+ };
1541
+
1542
+
1543
+ static const char* xmm_regs[8] = {
1544
+ "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7"
1545
+ };
1546
+
1547
+
1548
+ const char* NameConverter::NameOfAddress(byte* addr) const {
1549
+ v8::internal::OS::SNPrintF(tmp_buffer_, "%p", addr);
1550
+ return tmp_buffer_.start();
1551
+ }
1552
+
1553
+
1554
+ const char* NameConverter::NameOfConstant(byte* addr) const {
1555
+ return NameOfAddress(addr);
1556
+ }
1557
+
1558
+
1559
+ const char* NameConverter::NameOfCPURegister(int reg) const {
1560
+ if (0 <= reg && reg < 8) return cpu_regs[reg];
1561
+ return "noreg";
1562
+ }
1563
+
1564
+
1565
+ const char* NameConverter::NameOfByteCPURegister(int reg) const {
1566
+ if (0 <= reg && reg < 8) return byte_cpu_regs[reg];
1567
+ return "noreg";
1568
+ }
1569
+
1570
+
1571
+ const char* NameConverter::NameOfXMMRegister(int reg) const {
1572
+ if (0 <= reg && reg < 8) return xmm_regs[reg];
1573
+ return "noxmmreg";
1574
+ }
1575
+
1576
+
1577
+ const char* NameConverter::NameInCode(byte* addr) const {
1578
+ // IA32 does not embed debug strings at the moment.
1579
+ UNREACHABLE();
1580
+ return "";
1581
+ }
1582
+
1583
+
1584
+ //------------------------------------------------------------------------------
1585
+
1586
+ Disassembler::Disassembler(const NameConverter& converter)
1587
+ : converter_(converter) {}
1588
+
1589
+
1590
+ Disassembler::~Disassembler() {}
1591
+
1592
+
1593
+ int Disassembler::InstructionDecode(v8::internal::Vector<char> buffer,
1594
+ byte* instruction) {
1595
+ DisassemblerIA32 d(converter_, false /*do not crash if unimplemented*/);
1596
+ return d.InstructionDecode(buffer, instruction);
1597
+ }
1598
+
1599
+
1600
+ // The IA-32 assembler does not currently use constant pools.
1601
+ int Disassembler::ConstantPoolSizeAt(byte* instruction) { return -1; }
1602
+
1603
+
1604
+ /*static*/ void Disassembler::Disassemble(FILE* f, byte* begin, byte* end) {
1605
+ NameConverter converter;
1606
+ Disassembler d(converter);
1607
+ for (byte* pc = begin; pc < end;) {
1608
+ v8::internal::EmbeddedVector<char, 128> buffer;
1609
+ buffer[0] = '\0';
1610
+ byte* prev_pc = pc;
1611
+ pc += d.InstructionDecode(buffer, pc);
1612
+ fprintf(f, "%p", prev_pc);
1613
+ fprintf(f, " ");
1614
+
1615
+ for (byte* bp = prev_pc; bp < pc; bp++) {
1616
+ fprintf(f, "%02x", *bp);
1617
+ }
1618
+ for (int i = 6 - (pc - prev_pc); i >= 0; i--) {
1619
+ fprintf(f, " ");
1620
+ }
1621
+ fprintf(f, " %s\n", buffer.start());
1622
+ }
1623
+ }
1624
+
1625
+
1626
+ } // namespace disasm
1627
+
1628
+ #endif // V8_TARGET_ARCH_IA32