Changeset 147729 in webkit
- Timestamp:
- Apr 5, 2013 2:05:03 AM (11 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r147690 r147729 1 2013-04-05 Allan Sandfeld Jensen <allan.jensen@digia.com> 2 3 LLint should be able to use x87 instead of SSE for floating pointer 4 5 https://bugs.webkit.org/show_bug.cgi?id=112239 6 7 Reviewed by Filip Pizlo. 8 9 Implements LLInt floating point operations in x87, to ensure we support 10 x86 without SSE2. 11 12 X86 (except 64bit) now defaults to using x87 instructions in order to 13 support all 32bit x86 back to i686. The implementation uses the fucomi 14 instruction from i686 which sets the new minimum. 15 16 * offlineasm/x86.rb: 17 1 18 2013-04-04 Christophe Dumez <ch.dumez@sisa.samsung.com> 2 19 -
trunk/Source/JavaScriptCore/offlineasm/x86.rb
r133953 r147729 35 35 end 36 36 37 def useX87 38 case $activeBackend 39 when "X86" 40 true 41 when "X86_64" 42 false 43 else 44 raise "bad value for $activeBackend: #{$activeBackend}" 45 end 46 end 47 37 48 class SpecialRegister < NoChildren 38 49 def x86Operand(kind) … … 256 267 def x86Operand(kind) 257 268 raise unless kind == :double 269 raise if useX87 258 270 case name 259 271 when "ft0", "fa0", "fr" … … 269 281 when "ft5" 270 282 "%xmm5" 283 else 284 raise "Bad register #{name} for X86 at #{codeOriginString}" 285 end 286 end 287 def x87Operand(offset) 288 raise unless useX87 289 raise unless offset == 0 or offset == 1 290 case name 291 when "ft0", "fa0", "fr" 292 "%st(#{0 + offset})" 293 when "ft1", "fa1" 294 "%st(#{1 + offset})" 295 when "ft2", "fa2" 296 "%st(#{2 + offset})" 297 when "ft3", "fa3" 298 "%st(#{3 + offset})" 299 when "ft4" 300 "%st(#{4 + offset})" 301 when "ft5" 302 "%st(#{5 + offset})" 271 303 else 272 304 raise "Bad register #{name} for X86 at #{codeOriginString}" … … 423 455 isX64 ? "q" : raise 424 456 when :double 425 "sd"457 not useX87 ? "sd" : raise 426 458 else 427 459 raise … … 479 511 480 512 def handleX86DoubleBranch(branchOpcode, mode) 481 case mode 482 when :normal 483 $asm.puts "ucomisd #{operands[1].x86Operand(:double)}, #{operands[0].x86Operand(:double)}" 484 when :reverse 485 $asm.puts "ucomisd #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:double)}" 486 else 487 raise mode.inspect 513 if useX87 514 case mode 515 when :normal 516 $asm.puts "fld #{operands[0].x87Operand(0)}" 517 $asm.puts "fucomip #{operands[1].x87Operand(1)}" 518 when :reverse 519 $asm.puts "fld #{operands[1].x87Operand(0)}" 520 $asm.puts "fucomip #{operands[0].x87Operand(1)}" 521 else 522 raise mode.inspect 523 end 524 else 525 case mode 526 when :normal 527 $asm.puts "ucomisd #{operands[1].x86Operand(:double)}, #{operands[0].x86Operand(:double)}" 528 when :reverse 529 $asm.puts "ucomisd #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:double)}" 530 else 531 raise mode.inspect 532 end 488 533 end 489 534 $asm.puts "#{branchOpcode} #{operands[2].asmLabel}" … … 750 795 when "storeb" 751 796 $asm.puts "movb #{x86Operands(:byte, :byte)}" 752 when "loadd", "moved", "stored" 753 $asm.puts "movsd #{x86Operands(:double, :double)}" 797 when "loadd" 798 if useX87 799 $asm.puts "fldl #{operands[0].x86Operand(:double)}" 800 $asm.puts "fstp #{operands[1].x87Operand(1)}" 801 else 802 $asm.puts "movsd #{x86Operands(:double, :double)}" 803 end 804 when "moved" 805 if useX87 806 $asm.puts "fld #{operands[0].x87Operand(0)}" 807 $asm.puts "fstp #{operands[0].x87Operand(1)}" 808 else 809 $asm.puts "movsd #{x86Operands(:double, :double)}" 810 end 811 when "stored" 812 if useX87 813 $asm.puts "fld #{operands[0].x87Operand(0)}" 814 $asm.puts "fstpl #{operands[1].x86Operand(:double)}" 815 else 816 $asm.puts "movsd #{x86Operands(:double, :double)}" 817 end 754 818 when "addd" 755 $asm.puts "addsd #{x86Operands(:double, :double)}" 819 if useX87 820 $asm.puts "fld #{operands[0].x87Operand(0)}" 821 $asm.puts "faddp %st, #{operands[1].x87Operand(1)}" 822 else 823 $asm.puts "addsd #{x86Operands(:double, :double)}" 824 end 756 825 when "divd" 757 $asm.puts "divsd #{x86Operands(:double, :double)}" 826 if useX87 827 $asm.puts "fld #{operands[0].x87Operand(0)}" 828 $asm.puts "fdivrp %st, #{operands[1].x87Operand(1)}" 829 else 830 $asm.puts "divsd #{x86Operands(:double, :double)}" 831 end 758 832 when "subd" 759 $asm.puts "subsd #{x86Operands(:double, :double)}" 833 if useX87 834 $asm.puts "fld #{operands[0].x87Operand(0)}" 835 $asm.puts "fsubrp %st, #{operands[1].x87Operand(1)}" 836 else 837 $asm.puts "subsd #{x86Operands(:double, :double)}" 838 end 760 839 when "muld" 761 $asm.puts "mulsd #{x86Operands(:double, :double)}" 840 if useX87 841 $asm.puts "fld #{operands[0].x87Operand(0)}" 842 $asm.puts "fmulp %st, #{operands[1].x87Operand(1)}" 843 else 844 $asm.puts "mulsd #{x86Operands(:double, :double)}" 845 end 762 846 when "sqrtd" 763 $asm.puts "sqrtsd #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:double)}" 847 if useX87 848 $asm.puts "fld #{operands[0].x87Operand(0)}" 849 $asm.puts "fsqrtl" 850 $asm.puts "fstp #{operands[1].x87Operand(1)}" 851 else 852 $asm.puts "sqrtsd #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:double)}" 853 end 764 854 when "ci2d" 765 $asm.puts "cvtsi2sd #{operands[0].x86Operand(:int)}, #{operands[1].x86Operand(:double)}" 855 if useX87 856 if isX64 857 $asm.puts "sub#{x86Suffix(:ptr)} $4, %rsp" 858 $asm.puts "movl #{operands[0].x86Operand(:int)}, 0(%rsp)" 859 $asm.puts "fildl 0(%rsp)" 860 $asm.puts "add#{x86Suffix(:ptr)} $4, %rsp" 861 else 862 $asm.puts "sub#{x86Suffix(:ptr)} $4, %esp" 863 $asm.puts "movl #{operands[0].x86Operand(:int)}, 0(%esp)" 864 $asm.puts "fildl 0(%esp)" 865 $asm.puts "add#{x86Suffix(:ptr)} $4, %esp" 866 end 867 $asm.puts "fstp #{operands[1].x87Operand(1)}" 868 else 869 $asm.puts "cvtsi2sd #{operands[0].x86Operand(:int)}, #{operands[1].x86Operand(:double)}" 870 end 766 871 when "bdeq" 767 $asm.puts "ucomisd #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:double)}" 872 if useX87 873 $asm.puts "fld #{operands[1].x87Operand(0)}" 874 $asm.puts "fucomip #{operands[0].x87Operand(1)}" 875 else 876 $asm.puts "ucomisd #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:double)}" 877 end 768 878 if operands[0] == operands[1] 769 879 # This is just a jump ordered, which is a jnp. … … 788 898 handleX86DoubleBranch("je", :normal) 789 899 when "bdnequn" 790 $asm.puts "ucomisd #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:double)}" 900 if useX87 901 $asm.puts "fld #{operands[1].x87Operand(0)}" 902 $asm.puts "fucomip #{operands[0].x87Operand(1)}" 903 else 904 $asm.puts "ucomisd #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:double)}" 905 end 791 906 if operands[0] == operands[1] 792 907 # This is just a jump unordered, which is a jp. … … 810 925 handleX86DoubleBranch("jbe", :normal) 811 926 when "btd2i" 927 # FIXME: unused and unimplemented for x87 928 raise if useX87 812 929 $asm.puts "cvttsd2si #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:int)}" 813 930 $asm.puts "cmpl $0x80000000 #{operands[1].x86Operand(:int)}" 814 931 $asm.puts "je #{operands[2].asmLabel}" 815 932 when "td2i" 933 # FIXME: unused and unimplemented for x87 934 raise if useX87 816 935 $asm.puts "cvttsd2si #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:int)}" 817 936 when "bcd2i" 818 $asm.puts "cvttsd2si #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:int)}" 819 $asm.puts "testl #{operands[1].x86Operand(:int)}, #{operands[1].x86Operand(:int)}" 820 $asm.puts "je #{operands[2].asmLabel}" 821 $asm.puts "cvtsi2sd #{operands[1].x86Operand(:int)}, %xmm7" 822 $asm.puts "ucomisd #{operands[0].x86Operand(:double)}, %xmm7" 823 $asm.puts "jp #{operands[2].asmLabel}" 824 $asm.puts "jne #{operands[2].asmLabel}" 937 if useX87 938 raise if isX64 939 $asm.puts "fld #{operands[0].x87Operand(0)}" 940 $asm.puts "sub#{x86Suffix(:ptr)} $4, %esp" 941 $asm.puts "fistl 0(%esp)" 942 $asm.puts "ficomp 0(%esp)" 943 $asm.puts "popl #{operands[1].x86Operand(:int)}" 944 $asm.puts "jp #{operands[2].asmLabel}" 945 $asm.puts "jne #{operands[2].asmLabel}" 946 else 947 $asm.puts "cvttsd2si #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:int)}" 948 $asm.puts "testl #{operands[1].x86Operand(:int)}, #{operands[1].x86Operand(:int)}" 949 $asm.puts "je #{operands[2].asmLabel}" 950 $asm.puts "cvtsi2sd #{operands[1].x86Operand(:int)}, %xmm7" 951 $asm.puts "ucomisd #{operands[0].x86Operand(:double)}, %xmm7" 952 $asm.puts "jp #{operands[2].asmLabel}" 953 $asm.puts "jne #{operands[2].asmLabel}" 954 end 825 955 when "movdz" 826 $asm.puts "xorpd #{operands[0].x86Operand(:double)}, #{operands[0].x86Operand(:double)}" 956 if useX87 957 $asm.puts "fldzl" 958 $asm.puts "fstp #{operands[0].x87Operand(1)}" 959 else 960 $asm.puts "xorpd #{operands[0].x86Operand(:double)}, #{operands[0].x86Operand(:double)}" 961 end 827 962 when "pop" 828 963 $asm.puts "pop #{operands[0].x86Operand(:ptr)}" … … 1118 1253 $asm.puts "idivl #{operands[0].x86Operand(:int)}" 1119 1254 when "fii2d" 1120 $asm.puts "movd #{operands[0].x86Operand(:int)}, #{operands[2].x86Operand(:double)}" 1121 $asm.puts "movd #{operands[1].x86Operand(:int)}, %xmm7" 1122 $asm.puts "psllq $32, %xmm7" 1123 $asm.puts "por %xmm7, #{operands[2].x86Operand(:double)}" 1255 if useX87 1256 raise if isX64 1257 $asm.puts "sub#{x86Suffix(:ptr)} $8, %esp" 1258 $asm.puts "movl #{operands[0].x86Operand(:int)}, 0(%esp)" 1259 $asm.puts "movl #{operands[1].x86Operand(:int)}, 4(%esp)" 1260 $asm.puts "fldl 0(%esp)" 1261 $asm.puts "add#{x86Suffix(:ptr)} $8, %esp" 1262 $asm.puts "fstp #{operands[2].x87Operand(1)}" 1263 else 1264 $asm.puts "movd #{operands[0].x86Operand(:int)}, #{operands[2].x86Operand(:double)}" 1265 $asm.puts "movd #{operands[1].x86Operand(:int)}, %xmm7" 1266 $asm.puts "psllq $32, %xmm7" 1267 $asm.puts "por %xmm7, #{operands[2].x86Operand(:double)}" 1268 end 1124 1269 when "fd2ii" 1125 $asm.puts "movd #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:int)}" 1126 $asm.puts "movsd #{operands[0].x86Operand(:double)}, %xmm7" 1127 $asm.puts "psrlq $32, %xmm7" 1128 $asm.puts "movd %xmm7, #{operands[2].x86Operand(:int)}" 1270 if useX87 1271 raise if isX64 1272 $asm.puts "fld #{operands[0].x87Operand(0)}" 1273 $asm.puts "sub#{x86Suffix(:ptr)} $8, %esp" 1274 $asm.puts "fstpl 0(%esp)" 1275 $asm.puts "movl 0(%esp), #{operands[1].x86Operand(:int)}" 1276 $asm.puts "movl 4(%esp), #{operands[2].x86Operand(:int)}" 1277 $asm.puts "add#{x86Suffix(:ptr)} $8, %esp" 1278 else 1279 $asm.puts "movd #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:int)}" 1280 $asm.puts "movsd #{operands[0].x86Operand(:double)}, %xmm7" 1281 $asm.puts "psrlq $32, %xmm7" 1282 $asm.puts "movd %xmm7, #{operands[2].x86Operand(:int)}" 1283 end 1129 1284 when "fq2d" 1130 $asm.puts "movd #{operands[0].x86Operand(:quad)}, #{operands[1].x86Operand(:double)}" 1285 if useX87 1286 raise unless isX64 1287 $asm.puts "push #{operands[0].x86Operand(:quad)}" 1288 $asm.puts "fldl 0(%rsp)" 1289 $asm.puts "add#{x86Suffix(:ptr)} $8, %rsp" 1290 $asm.puts "fstp #{operands[1].x87Operand(1)}" 1291 else 1292 $asm.puts "movq #{operands[0].x86Operand(:quad)}, #{operands[1].x86Operand(:double)}" 1293 end 1131 1294 when "fd2q" 1132 $asm.puts "movd #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:quad)}" 1295 if useX87 1296 raise unless isX64 1297 $asm.puts "fld #{operands[0].x87Operand(0)}" 1298 $asm.puts "sub#{x86Suffix(:ptr)} $8, %rsp" 1299 $asm.puts "fstpl 0(%rsp)" 1300 $asm.puts "pop #{operands[1].x86Operand(:quad)}" 1301 else 1302 $asm.puts "movq #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:quad)}" 1303 end 1133 1304 when "bo" 1134 1305 $asm.puts "jo #{operands[0].asmLabel}"
Note: See TracChangeset
for help on using the changeset viewer.